diff options
author | Kjell Ericson <kjell@haxx.se> | 2003-01-10 09:58:04 +0000 |
---|---|---|
committer | Kjell Ericson <kjell@haxx.se> | 2003-01-10 09:58:04 +0000 |
commit | dd7f2948e4621c695999a79c3f635566b0daa46a (patch) | |
tree | 3dffe1b041db19f02323a5734dd5b99dd02643f4 /firmware/drivers/lcd-player.c | |
parent | c11b90fa49b09da7d50e728095dc8075069e3137 (diff) | |
download | rockbox-dd7f2948e4621c695999a79c3f635566b0daa46a.tar.gz rockbox-dd7f2948e4621c695999a79c3f635566b0daa46a.zip |
Implementing the Rocklatin character set for Rockbox player.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3052 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-player.c')
-rw-r--r-- | firmware/drivers/lcd-player.c | 384 |
1 files changed, 265 insertions, 119 deletions
diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index fd5bf552c9..464c872d97 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "debug.h" | 30 | #include "debug.h" |
31 | #include "system.h" | 31 | #include "system.h" |
32 | #include "font.h" | 32 | #include "font.h" |
33 | #include "lcd-player-charset.h" | ||
33 | 34 | ||
34 | /*** definitions ***/ | 35 | /*** definitions ***/ |
35 | 36 | ||
@@ -52,6 +53,11 @@ | |||
52 | #define SCROLL_MODE_PAUSE 1 | 53 | #define SCROLL_MODE_PAUSE 1 |
53 | #define SCROLL_MODE_RUN 2 | 54 | #define SCROLL_MODE_RUN 2 |
54 | 55 | ||
56 | extern unsigned short new_lcd_rocklatin1_to_xlcd[]; | ||
57 | extern unsigned short old_lcd_rocklatin1_to_xlcd[]; | ||
58 | extern unsigned char lcd_player_extended_lcd_to_rocklatin1[]; | ||
59 | extern unsigned char extended_font_player[NO_EXTENDED_LCD_CHARS][8]; | ||
60 | |||
55 | /*** generic code ***/ | 61 | /*** generic code ***/ |
56 | 62 | ||
57 | struct scrollinfo { | 63 | struct scrollinfo { |
@@ -76,110 +82,264 @@ static long scroll_start_tick; | |||
76 | 82 | ||
77 | static struct scrollinfo scroll[SCROLLABLE_LINES]; | 83 | static struct scrollinfo scroll[SCROLLABLE_LINES]; |
78 | 84 | ||
79 | static const unsigned char new_lcd_ascii[] = { | 85 | static char extended_chars_mapped[NO_EXTENDED_LCD_CHARS]; |
80 | 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, | 86 | static char extended_pattern_content[8]; /* Which char is mapped in pattern */ |
81 | 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, | 87 | static char extended_pattern_usage[8]; /* Counting number of times used */ |
82 | 0x10,0x11,0x05,0x13,0x14,0x15,0x16,0x17, | 88 | static char pattern_size; /* Last pattern, 3 for old LCD, 7 for new LCD */ |
83 | 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, | ||
84 | 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, | ||
85 | 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, | ||
86 | 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, | ||
87 | 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, | ||
88 | 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47, | ||
89 | 0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, | ||
90 | 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, | ||
91 | 0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, | ||
92 | 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67, | ||
93 | 0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, | ||
94 | 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, | ||
95 | 0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f, | ||
96 | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, | ||
97 | 0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, | ||
98 | 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, | ||
99 | 0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, | ||
100 | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7, | ||
101 | 0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, | ||
102 | 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7, | ||
103 | 0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, | ||
104 | 0x41,0x41,0x41,0x41,0x41,0x41,0x20,0x43, | ||
105 | 0x45,0x45,0x45,0x45,0x49,0x49,0x49,0x49, | ||
106 | 0x44,0x4e,0x4f,0x4f,0x4f,0x4f,0x4f,0x20, | ||
107 | 0x20,0x55,0x55,0x55,0x55,0x59,0x20,0x20, | ||
108 | 0x61,0x61,0x61,0x61,0x61,0x61,0x20,0x63, | ||
109 | 0x65,0x65,0x65,0x65,0x69,0x69,0x69,0x69, | ||
110 | 0x6f,0x6e,0x6f,0x6f,0x6f,0x6f,0x6f,0x20, | ||
111 | 0x20,0x75,0x75,0x75,0x75,0x79,0x20,0x79 | ||
112 | }; | ||
113 | |||
114 | static const unsigned char old_lcd_ascii[] = { | ||
115 | 0x00,0x01,0x02,0x03,0x00,0x84,0x85,0x89, | ||
116 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
117 | 0xec,0xe3,0xe2,0xe1,0xe0,0xdf,0x15,0x00, | ||
118 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
119 | 0x24,0x25,0x26,0x37,0x06,0x29,0x2a,0x2b, | ||
120 | 0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33, | ||
121 | 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b, | ||
122 | 0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43, | ||
123 | 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b, | ||
124 | 0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53, | ||
125 | 0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b, | ||
126 | 0x5c,0x5d,0x5e,0xa9,0x33,0xce,0x00,0x15, | ||
127 | 0x00,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b, | ||
128 | 0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73, | ||
129 | 0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b, | ||
130 | 0x7c,0x7d,0x7e,0x24,0x24,0x24,0x24,0x24, | ||
131 | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, | ||
132 | 0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, | ||
133 | 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, | ||
134 | 0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, | ||
135 | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7, | ||
136 | 0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, | ||
137 | 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7, | ||
138 | 0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, | ||
139 | 0x45,0x45,0x45,0x45,0x45,0x45,0x24,0x47, | ||
140 | 0x49,0x49,0x49,0x49,0x4d,0x4d,0x4d,0x4d, | ||
141 | 0x48,0x52,0x53,0x53,0x53,0x53,0x53,0x24, | ||
142 | 0x24,0x59,0x59,0x59,0x59,0x5d,0x24,0x24, | ||
143 | 0x65,0x65,0x65,0x65,0x65,0x65,0x24,0x67, | ||
144 | 0x69,0x69,0x69,0x69,0x6d,0x6d,0x6d,0x6d, | ||
145 | 0x73,0x72,0x73,0x73,0x73,0x73,0x73,0x24, | ||
146 | 0x24,0x79,0x79,0x79,0x79,0x7d,0x24,0x7d | ||
147 | }; | ||
148 | 89 | ||
149 | static bool new_lcd; | 90 | static bool new_lcd; |
150 | 91 | ||
151 | unsigned const char *lcd_ascii; | 92 | unsigned short *lcd_ascii; |
152 | static char lcd_contrast_set; | 93 | static char lcd_contrast_set; |
153 | static char lcd_cram; | 94 | static char lcd_cram; |
154 | static char lcd_pram; | 95 | static char lcd_pram; |
155 | static char lcd_iram; | 96 | static char lcd_iram; |
156 | 97 | ||
157 | #ifndef SIMULATOR | 98 | unsigned short buffer_xlcd[11][2]; |
99 | unsigned short buffer_lcd_mirror[11][2]; | ||
100 | |||
101 | #ifdef SIMULATOR | ||
102 | unsigned char hardware_buffer_lcd[11][2]; | ||
103 | #endif | ||
104 | #define NO_CHAR -1 | ||
105 | |||
106 | static void lcd_free_pat(int map_ch) | ||
107 | { | ||
108 | int x, y; | ||
109 | unsigned short substitute_char; | ||
110 | |||
111 | int pat; | ||
112 | pat=extended_chars_mapped[map_ch]; | ||
113 | if (pat!=NO_CHAR) { | ||
114 | |||
115 | substitute_char=lcd_player_extended_lcd_to_rocklatin1[map_ch]; | ||
116 | |||
117 | for (x=0; x<11; x++) { | ||
118 | for (y=0; y<2; y++) { | ||
119 | if (map_ch==lcd_ascii[buffer_xlcd[x][y]]-512) { | ||
120 | buffer_xlcd[x][y]=substitute_char; | ||
121 | buffer_lcd_mirror[x][y]=substitute_char; | ||
122 | #ifdef SIMULATOR | ||
123 | hardware_buffer_lcd[x][y]=substitute_char; | ||
124 | #else | ||
125 | lcd_write(true, LCD_CURSOR(x, y)); | ||
126 | lcd_write(false, substitute_char); | ||
127 | #endif | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | extended_chars_mapped[map_ch]=NO_CHAR; | ||
132 | extended_pattern_content[pat]=NO_CHAR; | ||
133 | extended_pattern_usage[pat]=0; | ||
134 | } | ||
135 | #ifdef SIMULATOR | ||
136 | lcd_update(); | ||
137 | #endif | ||
138 | } | ||
139 | |||
140 | static int lcd_get_free_pat(int ch) | ||
141 | { | ||
142 | int pat; | ||
143 | int last_pat=0; | ||
144 | static int last_used_pat=0; | ||
145 | int loop; | ||
146 | |||
147 | pat=last_pat; | ||
148 | for (loop=0; loop<=pattern_size; loop++) { | ||
149 | pat=(pat+1)&pattern_size; /* Keep 'pat' within limits */ | ||
150 | if (extended_pattern_usage[pat]==0) { | ||
151 | int map_ch=extended_pattern_content[pat]; | ||
152 | if (map_ch != NO_CHAR) { | ||
153 | extended_chars_mapped[map_ch]=NO_CHAR; | ||
154 | extended_pattern_content[pat]=NO_CHAR; | ||
155 | } | ||
156 | last_pat=pat; | ||
157 | return pat; | ||
158 | } | ||
159 | if (extended_pattern_content[pat]>extended_pattern_content[last_pat]) | ||
160 | last_pat=pat; | ||
161 | } | ||
162 | if (ch<32) { /* Prioritized char */ | ||
163 | /* Remove last_pat */ | ||
164 | lcd_free_pat(extended_pattern_content[last_pat]); | ||
165 | last_used_pat=last_pat; | ||
166 | return last_pat; | ||
167 | } | ||
168 | return NO_CHAR; | ||
169 | |||
170 | } | ||
171 | |||
172 | void xlcd_update() | ||
173 | { | ||
174 | int x, y; | ||
175 | for (x=0; x<11; x++) { | ||
176 | for (y=0; y<2; y++) { | ||
177 | unsigned short ch=buffer_xlcd[x][y]; | ||
178 | unsigned char hw_ch=0xff; | ||
179 | if (ch==buffer_lcd_mirror[x][y]) | ||
180 | continue; /* No need to redraw */ | ||
181 | buffer_lcd_mirror[x][y]=ch; | ||
182 | if (ch>=256 && ch<512) { | ||
183 | hw_ch=ch-256; | ||
184 | } else { | ||
185 | int map_ch=lcd_ascii[ch]; | ||
186 | if (map_ch<512) { | ||
187 | hw_ch=map_ch; | ||
188 | } else { | ||
189 | map_ch=map_ch-512; | ||
190 | if (extended_chars_mapped[map_ch]!=NO_CHAR) { | ||
191 | hw_ch=extended_chars_mapped[map_ch]; | ||
192 | extended_pattern_usage[hw_ch]++; | ||
193 | } else { | ||
194 | int pat; | ||
195 | pat=lcd_get_free_pat(map_ch); | ||
196 | if (pat<0) { | ||
197 | DEBUGF("Substitute for %02x (map 0x%02x) is used.\n", ch, map_ch); | ||
198 | /* Find substitute char */ | ||
199 | map_ch=lcd_player_extended_lcd_to_rocklatin1[map_ch]; | ||
200 | hw_ch=lcd_ascii[map_ch]; | ||
201 | } else { | ||
202 | #ifdef DEBUG | ||
203 | if (extended_pattern_usage[pat]!=0) { | ||
204 | fprintf(STDERR, "***Pattern %d is not zero!\n", | ||
205 | pat); | ||
206 | } | ||
207 | #endif | ||
208 | extended_chars_mapped[map_ch]=pat; | ||
209 | extended_pattern_content[pat]=map_ch; | ||
210 | extended_pattern_usage[pat]=1; | ||
211 | lcd_define_hw_pattern(pat*8, | ||
212 | extended_font_player[map_ch], 8); | ||
213 | hw_ch=pat; | ||
214 | } | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | #ifdef SIMULATOR | ||
219 | hardware_buffer_lcd[x][y]=hw_ch; | ||
220 | #else | ||
221 | lcd_write(true,LCD_CURSOR(x,y)); | ||
222 | lcd_write(false, hw_ch); | ||
223 | #endif | ||
224 | } | ||
225 | } | ||
226 | lcd_update(); | ||
227 | } | ||
228 | |||
229 | bool lcdx_putc(int x, int y, unsigned short ch) | ||
230 | { | ||
231 | int lcd_char; | ||
232 | if (buffer_xlcd[x][y]==ch) | ||
233 | return false; /* Same char, ignore any update */ | ||
234 | lcd_char=lcd_ascii[buffer_xlcd[x][y]]; | ||
235 | if (lcd_char>=512) { | ||
236 | /* The removed char is a defined pattern, count down the reference. */ | ||
237 | extended_pattern_usage[(int)extended_chars_mapped[lcd_char-512]]--; | ||
238 | #ifdef DEBUG | ||
239 | if (extended_pattern_usage[(int)extended_chars_mapped[lcd_char]]<0) { | ||
240 | DEBUGF("**** Mapped char %02x is less than 0!\n", lcd_char); | ||
241 | } | ||
242 | #endif | ||
243 | } | ||
244 | |||
245 | buffer_xlcd[x][y]=ch; | ||
246 | |||
247 | lcd_char=lcd_ascii[ch]; | ||
248 | if (lcd_char>=256) | ||
249 | return true; /* Caller shall call xlcd_update() when done */ | ||
250 | |||
251 | buffer_lcd_mirror[x][y]=lcd_char; | ||
252 | #ifdef SIMULATOR | ||
253 | hardware_buffer_lcd[x][y]=lcd_char; | ||
254 | lcd_update(); | ||
255 | #else | ||
256 | lcd_write(true, LCD_CURSOR(x, y)); | ||
257 | lcd_write(false, lcd_char); | ||
258 | #endif | ||
259 | return false; | ||
260 | } | ||
261 | |||
158 | void lcd_clear_display(void) | 262 | void lcd_clear_display(void) |
159 | { | 263 | { |
160 | int i; | 264 | int i; |
161 | lcd_write(true,LCD_CURSOR(0,0)); | 265 | bool update=false; |
162 | for (i=0;i<32;i++) | 266 | DEBUGF("lcd_clear_display()\n"); |
163 | lcd_write(false,lcd_ascii[' ']); | 267 | for (i=0;i<22;i++) |
268 | update|=lcdx_putc(i%11, i/11, ' '); | ||
269 | if (update) | ||
270 | xlcd_update(); | ||
164 | } | 271 | } |
165 | 272 | ||
166 | void lcd_puts(int x, int y, unsigned char *string) | 273 | void lcd_puts(int x, int y, unsigned char *string) |
167 | { | 274 | { |
168 | int i; | 275 | bool update=false; |
169 | lcd_write(true,LCD_CURSOR(x,y)); | 276 | // lcd_write(true,LCD_CURSOR(x,y)); |
170 | for (i=0; *string && x++<11; i++) | 277 | DEBUGF("lcd_puts(%d, %d, \"", x, y); |
171 | lcd_write(false,lcd_ascii[*(unsigned char*)string++]); | 278 | for (; *string && x<11; x++) |
279 | { | ||
280 | #ifdef DEBUGF | ||
281 | if (*string>=32 && *string<128) | ||
282 | {DEBUGF("%c", *string);} | ||
283 | else | ||
284 | {DEBUGF("(0x%02x)", *string);} | ||
285 | #endif | ||
286 | /* We should check if char is over 256 */ | ||
287 | update|=lcdx_putc(x, y, *(unsigned char*)string++); | ||
288 | } | ||
289 | DEBUGF("\")\n"); | ||
290 | |||
172 | for (; x<11; x++) | 291 | for (; x<11; x++) |
173 | lcd_write(false,lcd_ascii[' ']); | 292 | update|=lcdx_putc(x, y, ' '); |
293 | if (update) | ||
294 | xlcd_update(); | ||
295 | } | ||
296 | |||
297 | void lcd_putc(int x, int y, unsigned short ch) | ||
298 | { | ||
299 | bool update; | ||
300 | DEBUGF("lcd_putc(%d, %d, %d '0x%02x')\n", x, y, ch, ch); | ||
301 | if (x<0 || y<0) { | ||
302 | return; | ||
303 | } | ||
304 | // lcd_write(true,LCD_CURSOR(x,y)); | ||
305 | update=lcdx_putc(x, y, ch); | ||
306 | |||
307 | if (update) | ||
308 | xlcd_update(); | ||
309 | } | ||
310 | |||
311 | unsigned char lcd_get_locked_pattern() | ||
312 | { | ||
313 | unsigned char pat=1; | ||
314 | while (pat<LAST_RESERVED_CHAR) { | ||
315 | if (lcd_ascii[pat]==RESERVED_CHAR) { | ||
316 | lcd_ascii[pat]=0x200+pat; | ||
317 | return pat; | ||
318 | } | ||
319 | pat++; | ||
320 | } | ||
321 | return 0; | ||
322 | } | ||
323 | |||
324 | void lcd_unlock_pattern(unsigned char pat) | ||
325 | { | ||
326 | lcd_ascii[pat]=RESERVED_CHAR; | ||
327 | lcd_free_pat(pat); | ||
174 | } | 328 | } |
175 | 329 | ||
176 | void lcd_putc(int x, int y, unsigned char ch) | 330 | void lcd_define_pattern(int pat, char *pattern) |
177 | { | 331 | { |
178 | lcd_write(true,LCD_CURSOR(x,y)); | 332 | int i; |
179 | lcd_write(false,lcd_ascii[ch]); | 333 | for (i=0; i<7; i++) { |
334 | extended_font_player[pat][i]=pattern[i]; | ||
335 | } | ||
336 | if (extended_chars_mapped[pat]!=NO_CHAR) { | ||
337 | lcd_define_hw_pattern(pat*8, pattern, 7); | ||
338 | } | ||
180 | } | 339 | } |
181 | 340 | ||
182 | void lcd_define_pattern (int which,char *pattern,int length) | 341 | #ifndef SIMULATOR |
342 | void lcd_define_hw_pattern (int which,char *pattern,int length) | ||
183 | { | 343 | { |
184 | int i; | 344 | int i; |
185 | lcd_write(true,lcd_pram | which); | 345 | lcd_write(true,lcd_pram | which); |
@@ -259,19 +419,24 @@ void lcd_set_contrast(int val) | |||
259 | void lcd_init (void) | 419 | void lcd_init (void) |
260 | { | 420 | { |
261 | new_lcd = has_new_lcd(); | 421 | new_lcd = has_new_lcd(); |
422 | memset(extended_chars_mapped, NO_CHAR, sizeof(extended_chars_mapped)); | ||
423 | memset(extended_pattern_content, NO_CHAR,sizeof(extended_pattern_content)); | ||
424 | memset(extended_pattern_usage, 0, sizeof(extended_pattern_usage)); | ||
262 | 425 | ||
263 | if(new_lcd) { | 426 | if(new_lcd) { |
264 | lcd_ascii = new_lcd_ascii; | 427 | lcd_ascii = new_lcd_rocklatin1_to_xlcd; |
265 | lcd_contrast_set = NEW_LCD_CONTRAST_SET; | 428 | lcd_contrast_set = NEW_LCD_CONTRAST_SET; |
266 | lcd_cram = NEW_LCD_CRAM; | 429 | lcd_cram = NEW_LCD_CRAM; |
267 | lcd_pram = NEW_LCD_PRAM; | 430 | lcd_pram = NEW_LCD_PRAM; |
268 | lcd_iram = NEW_LCD_IRAM; | 431 | lcd_iram = NEW_LCD_IRAM; |
432 | pattern_size=7; /* Last pattern, 3 for old LCD, 7 for new LCD */ | ||
269 | } else { | 433 | } else { |
270 | lcd_ascii = old_lcd_ascii; | 434 | lcd_ascii = old_lcd_rocklatin1_to_xlcd; |
271 | lcd_contrast_set = OLD_LCD_CONTRAST_SET; | 435 | lcd_contrast_set = OLD_LCD_CONTRAST_SET; |
272 | lcd_cram = OLD_LCD_CRAM; | 436 | lcd_cram = OLD_LCD_CRAM; |
273 | lcd_pram = OLD_LCD_PRAM; | 437 | lcd_pram = OLD_LCD_PRAM; |
274 | lcd_iram = OLD_LCD_IRAM; | 438 | lcd_iram = OLD_LCD_IRAM; |
439 | pattern_size=3; /* Last pattern, 3 for old LCD, 7 for new LCD */ | ||
275 | } | 440 | } |
276 | 441 | ||
277 | create_thread(scroll_thread, scroll_stack, | 442 | create_thread(scroll_thread, scroll_stack, |
@@ -281,17 +446,11 @@ void lcd_init (void) | |||
281 | void lcd_puts_scroll(int x, int y, unsigned char* string ) | 446 | void lcd_puts_scroll(int x, int y, unsigned char* string ) |
282 | { | 447 | { |
283 | struct scrollinfo* s; | 448 | struct scrollinfo* s; |
284 | int index; | ||
285 | 449 | ||
450 | DEBUGF("lcd_puts_scroll(%d, %d, %s)\n", x, y, string); | ||
286 | scroll_start_tick = current_tick + scroll_delay; | 451 | scroll_start_tick = current_tick + scroll_delay; |
287 | 452 | ||
288 | /* search for the next free entry */ | 453 | s = &scroll[y]; |
289 | for (index = 0; index < SCROLLABLE_LINES; index++) { | ||
290 | s = &scroll[index]; | ||
291 | if (s->mode == SCROLL_MODE_OFF) { | ||
292 | break; | ||
293 | } | ||
294 | } | ||
295 | 454 | ||
296 | s->space = 11 - x; | 455 | s->space = 11 - x; |
297 | 456 | ||
@@ -334,17 +493,13 @@ void lcd_stop_scroll(void) | |||
334 | void lcd_stop_scroll_line(int line) | 493 | void lcd_stop_scroll_line(int line) |
335 | { | 494 | { |
336 | struct scrollinfo* s; | 495 | struct scrollinfo* s; |
337 | int index; | 496 | |
338 | 497 | s = &scroll[line]; | |
339 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | 498 | if ( s->mode == SCROLL_MODE_RUN || |
340 | s = &scroll[index]; | 499 | s->mode == SCROLL_MODE_PAUSE ) { |
341 | if ( s->startx == line && | 500 | /* restore scrolled row */ |
342 | ( s->mode == SCROLL_MODE_RUN || | 501 | lcd_puts(s->startx, s->starty, s->text); |
343 | s->mode == SCROLL_MODE_PAUSE )) { | 502 | s->mode = SCROLL_MODE_OFF; |
344 | /* restore scrolled row */ | ||
345 | lcd_puts(s->startx, s->starty, s->text); | ||
346 | s->mode = SCROLL_MODE_OFF; | ||
347 | } | ||
348 | } | 503 | } |
349 | 504 | ||
350 | lcd_update(); | 505 | lcd_update(); |
@@ -366,14 +521,10 @@ void lcd_scroll_pause(void) | |||
366 | void lcd_scroll_pause_line(int line) | 521 | void lcd_scroll_pause_line(int line) |
367 | { | 522 | { |
368 | struct scrollinfo* s; | 523 | struct scrollinfo* s; |
369 | int index; | ||
370 | 524 | ||
371 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | 525 | s = &scroll[line]; |
372 | s = &scroll[index]; | 526 | if ( s->mode == SCROLL_MODE_RUN ) { |
373 | if ( s->startx == line && | 527 | s->mode = SCROLL_MODE_PAUSE; |
374 | s->mode == SCROLL_MODE_RUN ) { | ||
375 | s->mode = SCROLL_MODE_PAUSE; | ||
376 | } | ||
377 | } | 528 | } |
378 | } | 529 | } |
379 | 530 | ||
@@ -395,16 +546,12 @@ void lcd_scroll_resume(void) | |||
395 | void lcd_scroll_resume_line(int line) | 546 | void lcd_scroll_resume_line(int line) |
396 | { | 547 | { |
397 | struct scrollinfo* s; | 548 | struct scrollinfo* s; |
398 | int index; | ||
399 | 549 | ||
400 | scroll_start_tick = current_tick + scroll_delay; | 550 | scroll_start_tick = current_tick + scroll_delay; |
401 | 551 | ||
402 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | 552 | s = &scroll[line]; |
403 | s = &scroll[index]; | 553 | if (s->mode == SCROLL_MODE_PAUSE ) { |
404 | if ( s->startx == line && | 554 | s->mode = SCROLL_MODE_RUN; |
405 | s->mode == SCROLL_MODE_PAUSE ) { | ||
406 | s->mode = SCROLL_MODE_RUN; | ||
407 | } | ||
408 | } | 555 | } |
409 | } | 556 | } |
410 | 557 | ||
@@ -457,7 +604,6 @@ static void scroll_thread(void) | |||
457 | else | 604 | else |
458 | s->offset = 0; | 605 | s->offset = 0; |
459 | } | 606 | } |
460 | |||
461 | lcd_puts(s->startx,s->starty,s->line); | 607 | lcd_puts(s->startx,s->starty,s->line); |
462 | } | 608 | } |
463 | } | 609 | } |