1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) Daniel Stenberg (2002)
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include "rbunicode.h"
26 #include "screen_access.h"
33 #ifdef HAVE_LCD_BITMAP
35 #define MAXLINES (LCD_HEIGHT/6)
38 #else /* HAVE_LCD_CHARCELLS */
45 #define RECT_SPACING 2
47 static void splash_internal(struct screen
* screen
, const char *fmt
, va_list ap
)
49 char splash_buf
[MAXBUFFER
];
50 short widths
[MAXLINES
];
51 char *lines
[MAXLINES
];
54 char *lastbreak
= NULL
;
60 #ifdef HAVE_LCD_BITMAP
64 viewport_set_defaults(&vp
, screen
->screen_type
);
65 screen
->set_viewport(&vp
);
67 screen
->getstringsize(" ", &space_w
, &h
);
68 #else /* HAVE_LCD_CHARCELLS */
71 screen
->double_height (false);
75 vsnprintf(splash_buf
, sizeof(splash_buf
), fmt
, ap
);
78 /* break splash string into display lines, doing proper word wrap */
80 next
= strtok_r(splash_buf
, " ", &store
);
82 goto end
; /* nothing to display */
87 #ifdef HAVE_LCD_BITMAP
88 screen
->getstringsize(next
, &w
, NULL
);
94 if (x
+ (next
- lastbreak
) * space_w
+ w
95 > screen
->lcdwidth
- RECT_SPACING
*2)
96 { /* too wide, wrap */
98 #ifdef HAVE_LCD_BITMAP
102 if ((y
+ h
> screen
->lcdheight
) || (line
>= (MAXLINES
-1)))
103 break; /* screen full or out of lines */
106 lines
[++line
] = next
;
110 /* restore & calculate spacing */
112 x
+= (next
- lastbreak
) * space_w
;
116 lastbreak
= next
+ strlen(next
);
117 next
= strtok_r(NULL
, " ", &store
);
119 { /* no more words */
121 #ifdef HAVE_LCD_BITMAP
130 * First boundaries, then the grey filling, then the black border and finally
133 screen
->stop_scroll();
135 #ifdef HAVE_LCD_BITMAP
136 /* If we center the display, then just clear the box we need and put
137 a nice little frame and put the text in there! */
138 vp
.y
= (screen
->lcdheight
- y
) / 2 - RECT_SPACING
; /* height => y start position */
139 vp
.x
= (screen
->lcdwidth
- maxw
) / 2 - RECT_SPACING
;
140 vp
.width
= maxw
+ 2*RECT_SPACING
;
141 vp
.height
= screen
->lcdheight
- (vp
.y
*2) + RECT_SPACING
;
147 if (vp
.width
> screen
->lcdwidth
)
148 vp
.width
= screen
->lcdwidth
;
149 if (vp
.height
> screen
->lcdheight
)
150 vp
.height
= screen
->lcdheight
;
153 if (screen
->depth
> 1)
155 vp
.drawmode
= DRMODE_FG
;
156 vp
.fg_pattern
= SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
);
160 vp
.drawmode
= (DRMODE_SOLID
|DRMODE_INVERSEVID
);
162 screen
->fillrect(0, 0, vp
.width
, vp
.height
);
165 if (screen
->depth
> 1)
166 vp
.fg_pattern
= SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
);
169 vp
.drawmode
= DRMODE_SOLID
;
171 screen
->drawrect(0, 0, vp
.width
, vp
.height
);
173 /* prepare putting the text */
175 #else /* HAVE_LCD_CHARCELLS */
176 y
= 0; /* vertical centering on 2 lines would be silly */
178 screen
->clear_display();
181 /* print the message to screen */
182 for (i
= 0; i
<= line
; i
++, y
+=h
)
184 #ifdef HAVE_LCD_BITMAP
185 #define W (vp.width - RECT_SPACING*2)
187 #define W (screens->lcdwidth)
189 x
= (W
- widths
[i
])/2;
192 #ifdef HAVE_LCD_BITMAP
193 screen
->putsxy(x
+RECT_SPACING
, y
, lines
[i
]);
195 screen
->puts(x
, y
, lines
[i
]);
199 screen
->update_viewport();
201 screen
->set_viewport(NULL
);
204 void splashf(int ticks
, const char *fmt
, ...)
209 /* If fmt is a lang ID then get the corresponding string (which
210 still might contain % place holders). */
211 fmt
= P2STR((unsigned char *)fmt
);
215 splash_internal(&(screens
[i
]), fmt
, ap
);
222 void splash(int ticks
, const char *str
)
224 #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
226 /* fmt may be a so called virtual pointer. See settings.h. */
227 if((id
= P2ID((const unsigned char*)str
)) >= 0)
228 /* If fmt specifies a voicefont ID, and voice menus are
229 enabled, then speak it. */
230 cond_talk_ids_fq(id
);
232 splashf(ticks
, "%s", P2STR((const unsigned char*)str
));