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 #define MAX(a, b) (((a)>(b))?(a):(b))
36 #ifdef HAVE_LCD_BITMAP
38 #define MAXLINES (LCD_HEIGHT/6)
41 #else /* HAVE_LCD_CHARCELLS */
48 static void splash_internal(struct screen
* screen
, const char *fmt
, va_list ap
)
50 char splash_buf
[MAXBUFFER
];
51 short widths
[MAXLINES
];
52 char *lines
[MAXLINES
];
55 char *lastbreak
= NULL
;
61 #ifdef HAVE_LCD_BITMAP
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 return; /* nothing to display */
87 #ifdef HAVE_LCD_BITMAP
88 screen
->getstringsize(next
, &w
, NULL
);
94 if (x
+ (next
- lastbreak
) * space_w
+ w
> screen
->lcdwidth
)
95 { /* too wide, wrap */
97 #ifdef HAVE_LCD_BITMAP
101 if ((y
+ h
> screen
->lcdheight
) || (line
>= (MAXLINES
-1)))
102 break; /* screen full or out of lines */
105 lines
[++line
] = next
;
109 /* restore & calculate spacing */
111 x
+= (next
- lastbreak
) * space_w
;
115 lastbreak
= next
+ strlen(next
);
116 next
= strtok_r(NULL
, " ", &store
);
118 { /* no more words */
120 #ifdef HAVE_LCD_BITMAP
130 screen
->stop_scroll();
132 #ifdef HAVE_LCD_BITMAP
133 /* If we center the display, then just clear the box we need and put
134 a nice little frame and put the text in there! */
135 y
= (screen
->lcdheight
- y
) / 2; /* height => y start position */
136 x
= (screen
->lcdwidth
- maxw
) / 2 - 2;
139 if (screen
->depth
> 1)
141 prevfg
= screen
->get_foreground();
142 screen
->set_drawmode(DRMODE_FG
);
143 screen
->set_foreground(
144 SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
));
148 screen
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
150 screen
->fillrect(x
, y
-2, maxw
+4, screen
->lcdheight
-y
*2+4);
153 if (screen
->depth
> 1)
154 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
));
157 screen
->set_drawmode(DRMODE_SOLID
);
159 screen
->drawrect(x
, y
-2, maxw
+4, screen
->lcdheight
-y
*2+4);
160 #else /* HAVE_LCD_CHARCELLS */
161 y
= 0; /* vertical centering on 2 lines would be silly */
163 screen
->clear_display();
166 /* print the message to screen */
168 for (i
= 0; i
<= line
; i
++)
170 x
= MAX((screen
->lcdwidth
- widths
[i
]) / 2, 0);
172 #ifdef HAVE_LCD_BITMAP
173 screen
->putsxy(x
, y
, lines
[i
]);
175 screen
->puts(x
, y
, lines
[i
]);
180 #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1)
181 if (screen
->depth
> 1)
183 screen
->set_foreground(prevfg
);
184 screen
->set_drawmode(DRMODE_SOLID
);
190 void splashf(int ticks
, const char *fmt
, ...)
195 /* If fmt is a lang ID then get the corresponding string (which
196 still might contain % place holders). */
197 fmt
= P2STR((unsigned char *)fmt
);
201 screens
[i
].set_viewport(NULL
);
202 splash_internal(&(screens
[i
]), fmt
, ap
);
210 void splash(int ticks
, const char *str
)
212 #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
214 /* fmt may be a so called virtual pointer. See settings.h. */
215 if((id
= P2ID((const unsigned char*)str
)) >= 0)
216 /* If fmt specifies a voicefont ID, and voice menus are
217 enabled, then speak it. */
218 cond_talk_ids_fq(id
);
220 splashf(ticks
, "%s", P2STR((const unsigned char*)str
));