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"
34 #ifdef HAVE_LCD_BITMAP
36 #define MAXLINES (LCD_HEIGHT/6)
38 #define RECT_SPACING 2
39 #define SPLASH_MEMORY_INTERVAL (HZ)
41 #else /* HAVE_LCD_CHARCELLS */
45 #define RECT_SPACING 0
50 static void splash_internal(struct screen
* screen
, const char *fmt
, va_list ap
)
52 char splash_buf
[MAXBUFFER
];
53 char *lines
[MAXLINES
];
56 char *lastbreak
= NULL
;
63 #ifdef HAVE_LCD_BITMAP
67 viewport_set_defaults(&vp
, screen
->screen_type
);
68 screen
->set_viewport(&vp
);
70 screen
->getstringsize(" ", &space_w
, &h
);
71 #else /* HAVE_LCD_CHARCELLS */
72 vp
.width
= screen
->lcdwidth
;
73 vp
.height
= screen
->lcdheight
;
76 screen
->double_height (false);
80 vsnprintf(splash_buf
, sizeof(splash_buf
), fmt
, ap
);
83 /* break splash string into display lines, doing proper word wrap */
85 next
= strtok_r(splash_buf
, " ", &store
);
87 goto end
; /* nothing to display */
92 #ifdef HAVE_LCD_BITMAP
93 screen
->getstringsize(next
, &w
, NULL
);
99 if (x
+ (next
- lastbreak
) * space_w
+ w
100 > vp
.width
- RECT_SPACING
*2)
101 { /* too wide, wrap */
102 #ifdef HAVE_LCD_BITMAP
106 if ((y
+ h
> vp
.height
) || (line
>= (MAXLINES
-1)))
107 break; /* screen full or out of lines */
110 lines
[++line
] = next
;
114 /* restore & calculate spacing */
116 x
+= (next
- lastbreak
) * space_w
;
120 lastbreak
= next
+ strlen(next
);
121 next
= strtok_r(NULL
, " ", &store
);
123 { /* no more words */
124 #ifdef HAVE_LCD_BITMAP
133 * First boundaries, then the grey filling, then the black border and finally
136 screen
->stop_scroll();
138 #ifdef HAVE_LCD_BITMAP
140 vp
.y
= (vp
.height
- vp
.y
- y
) / 2 - RECT_SPACING
; /* height => y start position */
141 vp
.x
+= (vp
.width
- maxw
) / 2 - RECT_SPACING
;
142 width
= maxw
+ 2*RECT_SPACING
;
143 height
= y
+ 2*RECT_SPACING
;
149 if (width
> vp
.width
)
151 if (height
> vp
.height
)
156 vp
.flags
|= VP_FLAG_ALIGN_CENTER
;
158 if (screen
->depth
> 1)
160 vp
.drawmode
= DRMODE_FG
;
161 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
163 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
));
167 vp
.drawmode
= (DRMODE_SOLID
|DRMODE_INVERSEVID
);
169 screen
->fillrect(0, 0, vp
.width
, vp
.height
);
172 if (screen
->depth
> 1)
173 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
175 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
));
178 vp
.drawmode
= DRMODE_SOLID
;
180 screen
->drawrect(0, 0, vp
.width
, vp
.height
);
182 /* prepare putting the text */
184 #else /* HAVE_LCD_CHARCELLS */
185 y
= 0; /* vertical centering on 2 lines would be silly */
186 screen
->clear_display();
189 /* print the message to screen */
190 for (i
= 0; i
<= line
; i
++, y
+=h
)
192 #ifdef HAVE_LCD_BITMAP
193 screen
->putsxy(0, y
, lines
[i
]);
195 screen
->puts(0, y
, lines
[i
]);
198 screen
->update_viewport();
200 screen
->set_viewport(NULL
);
203 void splashf(int ticks
, const char *fmt
, ...)
208 /* If fmt is a lang ID then get the corresponding string (which
209 still might contain % place holders). */
210 fmt
= P2STR((unsigned char *)fmt
);
214 splash_internal(&(screens
[i
]), fmt
, ap
);
221 void splash(int ticks
, const char *str
)
223 #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
225 /* fmt may be a so called virtual pointer. See settings.h. */
226 if((id
= P2ID((const unsigned char*)str
)) >= 0)
227 /* If fmt specifies a voicefont ID, and voice menus are
228 enabled, then speak it. */
229 cond_talk_ids_fq(id
);
231 splashf(ticks
, "%s", P2STR((const unsigned char*)str
));