1 | #include <stdlib.h> |
---|
2 | #include <stdio.h> |
---|
3 | #include <unistd.h> |
---|
4 | #include <termios.h> |
---|
5 | #include <fcntl.h> |
---|
6 | #include <string.h> |
---|
7 | #include <sys/errno.h> |
---|
8 | |
---|
9 | #include "LL.h" |
---|
10 | |
---|
11 | #include "lcd.h" |
---|
12 | |
---|
13 | #include "drv_base.h" |
---|
14 | |
---|
15 | #ifdef MTXORB_DRV |
---|
16 | #include "MtxOrb.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #ifdef ISET23A_DRV |
---|
20 | #include "IseT23A.h" |
---|
21 | #endif |
---|
22 | |
---|
23 | #ifdef CFONTZ_DRV |
---|
24 | #include "CFontz.h" |
---|
25 | #endif |
---|
26 | |
---|
27 | #ifdef TEXT_DRV |
---|
28 | #include "text.h" |
---|
29 | #endif |
---|
30 | |
---|
31 | #ifdef DEBUG_DRV |
---|
32 | #include "debug.h" |
---|
33 | #endif |
---|
34 | |
---|
35 | #ifdef CURSES_DRV |
---|
36 | #include "curses_drv.h" |
---|
37 | #endif |
---|
38 | |
---|
39 | #ifdef HD44780_DRV |
---|
40 | #include "hd44780.h" |
---|
41 | #endif |
---|
42 | |
---|
43 | #ifdef SLI_DRV |
---|
44 | #include "wirz-sli.h" |
---|
45 | #endif |
---|
46 | |
---|
47 | #ifdef JOY_DRV |
---|
48 | #include "joy.h" |
---|
49 | #endif |
---|
50 | |
---|
51 | #ifdef IRMANIN_DRV |
---|
52 | #include "irmanin.h" |
---|
53 | #endif |
---|
54 | |
---|
55 | // TODO: Make a Windows server, and clients...? |
---|
56 | |
---|
57 | |
---|
58 | lcd_logical_driver lcd; |
---|
59 | |
---|
60 | lcd_physical_driver drivers[] = |
---|
61 | { |
---|
62 | { "base", drv_base_init, }, |
---|
63 | #ifdef MTXORB_DRV |
---|
64 | { "MtxOrb", MtxOrb_init, }, |
---|
65 | #endif |
---|
66 | #ifdef ISET23A_DRV |
---|
67 | { "IseT23A", IseT23A_init, }, |
---|
68 | #endif |
---|
69 | #ifdef CFONTZ_DRV |
---|
70 | { "CFontz", CFontz_init, }, |
---|
71 | #endif |
---|
72 | #ifdef HD44780_DRV |
---|
73 | { "HD44780", HD44780_init, }, |
---|
74 | #endif |
---|
75 | #ifdef SLI_DRV |
---|
76 | { "sli", sli_init, }, |
---|
77 | #endif |
---|
78 | #ifdef TEXT_DRV |
---|
79 | { "text", text_init, }, |
---|
80 | #endif |
---|
81 | #ifdef DEBUG_DRV |
---|
82 | { "debug", debug_init, }, |
---|
83 | #endif |
---|
84 | #ifdef CURSES_DRV |
---|
85 | { "curses", curses_drv_init, }, |
---|
86 | #endif |
---|
87 | #ifdef JOY_DRV |
---|
88 | { "joy", joy_init, }, |
---|
89 | #endif |
---|
90 | #ifdef IRMANIN_DRV |
---|
91 | { "irmanin", irmanin_init, }, |
---|
92 | #endif |
---|
93 | { NULL, NULL, }, |
---|
94 | |
---|
95 | }; |
---|
96 | |
---|
97 | LL *list; |
---|
98 | |
---|
99 | //////////////////////////////////////////////////////////// |
---|
100 | // This sets up which driver to use and initializes stuff. |
---|
101 | // |
---|
102 | int lcd_init(char *args) |
---|
103 | { |
---|
104 | // int i; |
---|
105 | int err; |
---|
106 | |
---|
107 | list = LL_new(); |
---|
108 | if(!list) |
---|
109 | { |
---|
110 | printf("Error allocating driver list.\n"); |
---|
111 | return -1; |
---|
112 | } |
---|
113 | |
---|
114 | lcd_drv_init(NULL, NULL); |
---|
115 | |
---|
116 | err = lcd_add_driver("base", args); |
---|
117 | |
---|
118 | lcd.wid = 20; |
---|
119 | lcd.hgt = 4; |
---|
120 | |
---|
121 | return err; |
---|
122 | |
---|
123 | /* |
---|
124 | drv_base_init(args); |
---|
125 | |
---|
126 | for(i=0; drivers[i].name; i++) |
---|
127 | { |
---|
128 | if(!strcmp(driver, drivers[i].name)) |
---|
129 | { |
---|
130 | return drivers[i].init(args); |
---|
131 | } |
---|
132 | } |
---|
133 | |
---|
134 | printf("Invalid driver: %s\n", driver); |
---|
135 | return -1; |
---|
136 | */ |
---|
137 | |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | // TODO: lcd_remove_driver() |
---|
142 | |
---|
143 | int lcd_add_driver(char *driver, char *args) |
---|
144 | { |
---|
145 | int i; |
---|
146 | |
---|
147 | lcd_logical_driver *add; |
---|
148 | |
---|
149 | for(i=0; drivers[i].name; i++) |
---|
150 | { |
---|
151 | |
---|
152 | //printf("Checking driver: %s\n", drivers[i].name); |
---|
153 | |
---|
154 | if(0 == strcmp(driver, drivers[i].name)) |
---|
155 | { |
---|
156 | |
---|
157 | //printf("Found driver: %s (%s)\n", drivers[i].name, driver); |
---|
158 | |
---|
159 | add = malloc(sizeof(lcd_logical_driver)); |
---|
160 | if(!add) |
---|
161 | { |
---|
162 | printf("Couldn't allocate driver \"%s\".\n", driver); |
---|
163 | return -1; |
---|
164 | } |
---|
165 | //printf("Allocated driver\n"); |
---|
166 | memset(add, 0, sizeof(lcd_logical_driver)); |
---|
167 | |
---|
168 | add->wid = lcd.wid; add->hgt = lcd.hgt; |
---|
169 | add->cellwid = lcd.cellwid; add->cellhgt = lcd.cellhgt; |
---|
170 | |
---|
171 | // printf("LCD driver info:\n\twid: %i\thgt: %i\n", |
---|
172 | // add->wid, add->hgt); |
---|
173 | |
---|
174 | add->framebuf = malloc(add->wid * add->hgt); |
---|
175 | |
---|
176 | if(!add->framebuf) |
---|
177 | { |
---|
178 | printf("Couldn't allocate framebuffer for driver \"%s\".\n", |
---|
179 | driver); |
---|
180 | free(add); |
---|
181 | return -1; |
---|
182 | } |
---|
183 | //printf("Allocated frame buffer\n"); |
---|
184 | |
---|
185 | LL_Push(list, (void *)add); |
---|
186 | |
---|
187 | return drivers[i].init(add, args); |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | return -1; |
---|
192 | } |
---|
193 | |
---|
194 | // TODO: Put lcd_shutdown in the shutdown function... |
---|
195 | int lcd_shutdown() |
---|
196 | { |
---|
197 | lcd_logical_driver *driver; |
---|
198 | |
---|
199 | |
---|
200 | LL_Rewind(list); |
---|
201 | do { |
---|
202 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
203 | if(driver) |
---|
204 | { |
---|
205 | //printf("driver...\n"); |
---|
206 | lcd.framebuf = driver->framebuf; |
---|
207 | |
---|
208 | if((int)driver->close > 0) |
---|
209 | { |
---|
210 | driver->close(); |
---|
211 | } |
---|
212 | else if((int)driver->close == -1) |
---|
213 | { |
---|
214 | drv_base->close(); |
---|
215 | } |
---|
216 | |
---|
217 | LL_Shift(list); |
---|
218 | // FIXME: This crashes! |
---|
219 | //if(driver) free(driver); |
---|
220 | //printf("...freed\n"); |
---|
221 | } |
---|
222 | |
---|
223 | } while(LL_Length(list) > 0); |
---|
224 | |
---|
225 | return 0; |
---|
226 | } |
---|
227 | |
---|
228 | |
---|
229 | |
---|
230 | int lcd_drv_init(struct lcd_logical_driver *driver, char *args) |
---|
231 | { |
---|
232 | // printf("lcd_drv_init()\n"); |
---|
233 | |
---|
234 | lcd.wid = LCD_MAX_WID; |
---|
235 | lcd.hgt = LCD_MAX_HGT; |
---|
236 | |
---|
237 | lcd.framebuf = NULL; |
---|
238 | /* |
---|
239 | if(!lcd.framebuf) |
---|
240 | lcd.framebuf = malloc(lcd.wid * lcd.hgt); |
---|
241 | |
---|
242 | if(!lcd.framebuf) |
---|
243 | { |
---|
244 | lcd_drv_close(); |
---|
245 | return -1; |
---|
246 | } |
---|
247 | memset(lcd.framebuf, ' ', lcd.wid*lcd.hgt); |
---|
248 | */ |
---|
249 | // Debugging... |
---|
250 | // if(lcd.framebuf) printf("Frame buffer: %i\n", (int)lcd.framebuf); |
---|
251 | |
---|
252 | lcd.cellwid = 5; |
---|
253 | lcd.cellhgt = 8; |
---|
254 | |
---|
255 | // Set up these wrapper functions... |
---|
256 | lcd.clear = lcd_drv_clear; |
---|
257 | lcd.string = lcd_drv_string; |
---|
258 | lcd.chr = lcd_drv_chr; |
---|
259 | lcd.vbar = lcd_drv_vbar; |
---|
260 | lcd.hbar = lcd_drv_hbar; |
---|
261 | lcd.init_num = lcd_drv_init_num; |
---|
262 | lcd.num = lcd_drv_num; |
---|
263 | |
---|
264 | lcd.init = lcd_drv_init; |
---|
265 | lcd.close = lcd_drv_close; |
---|
266 | lcd.flush = lcd_drv_flush; |
---|
267 | lcd.flush_box = lcd_drv_flush_box; |
---|
268 | lcd.contrast = lcd_drv_contrast; |
---|
269 | lcd.backlight = lcd_drv_backlight; |
---|
270 | lcd.output = lcd_drv_output; |
---|
271 | lcd.set_char = lcd_drv_set_char; |
---|
272 | lcd.icon = lcd_drv_icon; |
---|
273 | lcd.init_vbar = lcd_drv_init_vbar; |
---|
274 | lcd.init_hbar = lcd_drv_init_hbar; |
---|
275 | lcd.draw_frame = lcd_drv_draw_frame; |
---|
276 | |
---|
277 | lcd.getkey = lcd_drv_getkey; |
---|
278 | |
---|
279 | |
---|
280 | return 1; // 1 is arbitrary. (must be 1 or more) |
---|
281 | } |
---|
282 | |
---|
283 | |
---|
284 | |
---|
285 | ////////////////////////////////////////////////////////////////////// |
---|
286 | // All functions below here call their respective driver functions... |
---|
287 | // |
---|
288 | // The way it works is this: |
---|
289 | // It loops through the list of drivers, calling each one to keep |
---|
290 | // them all synchronized. During this loop... |
---|
291 | // - First, set the framebuffer to point to the drivers' framebuffer. |
---|
292 | // (this ensures that whatever driver gets called will operate on |
---|
293 | // the correct buffer) |
---|
294 | // - Then, it checks to see what sort of call to make. |
---|
295 | // driver->func() > 0 means it should call the driver function. |
---|
296 | // driver->func() == NULL means it should not make a call. |
---|
297 | // driver->func() == -1 means it should call the generic driver. |
---|
298 | ////////////////////////////////////////////////////////////////////// |
---|
299 | |
---|
300 | |
---|
301 | void lcd_drv_close() |
---|
302 | { |
---|
303 | lcd_logical_driver *driver; |
---|
304 | |
---|
305 | // printf("lcd_drv_close()\n"); |
---|
306 | |
---|
307 | LL_Rewind(list); |
---|
308 | do { |
---|
309 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
310 | if(driver) |
---|
311 | { |
---|
312 | lcd.framebuf = driver->framebuf; |
---|
313 | |
---|
314 | if((int)driver->close > 0) |
---|
315 | { |
---|
316 | printf("Calling close()\n"); |
---|
317 | driver->close(); |
---|
318 | } |
---|
319 | else if((int)driver->close == -1) |
---|
320 | { |
---|
321 | drv_base->close(); |
---|
322 | } |
---|
323 | } |
---|
324 | } while(LL_Next(list) == 0); |
---|
325 | |
---|
326 | } |
---|
327 | |
---|
328 | void lcd_drv_clear() |
---|
329 | { |
---|
330 | lcd_logical_driver *driver; |
---|
331 | |
---|
332 | LL_Rewind(list); |
---|
333 | do { |
---|
334 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
335 | if(driver) |
---|
336 | { |
---|
337 | lcd.framebuf = driver->framebuf; |
---|
338 | |
---|
339 | if((int)driver->clear > 0) |
---|
340 | driver->clear(); |
---|
341 | else if((int)driver->clear == -1) |
---|
342 | { |
---|
343 | drv_base->clear(); |
---|
344 | } |
---|
345 | } |
---|
346 | } while(LL_Next(list) == 0); |
---|
347 | |
---|
348 | } |
---|
349 | |
---|
350 | |
---|
351 | void lcd_drv_flush() |
---|
352 | { |
---|
353 | lcd_logical_driver *driver; |
---|
354 | |
---|
355 | LL_Rewind(list); |
---|
356 | do { |
---|
357 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
358 | if(driver) |
---|
359 | { |
---|
360 | lcd.framebuf = driver->framebuf; |
---|
361 | |
---|
362 | if((int)driver->flush > 0) |
---|
363 | driver->flush(); |
---|
364 | else if((int)driver->flush == -1) |
---|
365 | { |
---|
366 | drv_base->flush(); |
---|
367 | } |
---|
368 | } |
---|
369 | } while(LL_Next(list) == 0); |
---|
370 | } |
---|
371 | |
---|
372 | |
---|
373 | void lcd_drv_string(int x, int y, char string[]) |
---|
374 | { |
---|
375 | lcd_logical_driver *driver; |
---|
376 | |
---|
377 | LL_Rewind(list); |
---|
378 | do { |
---|
379 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
380 | if(driver) |
---|
381 | { |
---|
382 | lcd.framebuf = driver->framebuf; |
---|
383 | |
---|
384 | if((int)driver->string > 0) |
---|
385 | driver->string(x,y,string); |
---|
386 | else if((int)driver->string == -1) |
---|
387 | { |
---|
388 | drv_base->string(x,y,string); |
---|
389 | } |
---|
390 | } |
---|
391 | } while(LL_Next(list) == 0); |
---|
392 | } |
---|
393 | |
---|
394 | void lcd_drv_chr(int x, int y, char c) |
---|
395 | { |
---|
396 | lcd_logical_driver *driver; |
---|
397 | |
---|
398 | LL_Rewind(list); |
---|
399 | do { |
---|
400 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
401 | if(driver) |
---|
402 | { |
---|
403 | lcd.framebuf = driver->framebuf; |
---|
404 | |
---|
405 | if((int)driver->chr > 0) |
---|
406 | driver->chr(x,y,c); |
---|
407 | else if((int)driver->chr == -1) |
---|
408 | { |
---|
409 | drv_base->chr(x,y,c); |
---|
410 | } |
---|
411 | } |
---|
412 | } while(LL_Next(list) == 0); |
---|
413 | } |
---|
414 | |
---|
415 | |
---|
416 | |
---|
417 | int lcd_drv_contrast(int contrast) |
---|
418 | { |
---|
419 | int res=0; |
---|
420 | |
---|
421 | lcd_logical_driver *driver; |
---|
422 | |
---|
423 | LL_Rewind(list); |
---|
424 | do { |
---|
425 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
426 | if(driver) |
---|
427 | { |
---|
428 | lcd.framebuf = driver->framebuf; |
---|
429 | |
---|
430 | if((int)driver->contrast > 0) |
---|
431 | { |
---|
432 | res=driver->contrast(contrast); |
---|
433 | if(res >= 0) return res; |
---|
434 | } |
---|
435 | /* |
---|
436 | else if((int)driver->contrast == -1) |
---|
437 | { |
---|
438 | res=drv_base->contrast(contrast); |
---|
439 | } |
---|
440 | */ |
---|
441 | } |
---|
442 | } while(LL_Next(list) == 0); |
---|
443 | |
---|
444 | return res; |
---|
445 | } |
---|
446 | |
---|
447 | void lcd_drv_backlight(int on) |
---|
448 | { |
---|
449 | lcd_logical_driver *driver; |
---|
450 | |
---|
451 | LL_Rewind(list); |
---|
452 | do { |
---|
453 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
454 | if(driver) |
---|
455 | { |
---|
456 | lcd.framebuf = driver->framebuf; |
---|
457 | |
---|
458 | if((int)driver->backlight > 0) |
---|
459 | driver->backlight(on); |
---|
460 | else if((int)driver->backlight == -1) |
---|
461 | { |
---|
462 | drv_base->backlight(on); |
---|
463 | } |
---|
464 | } |
---|
465 | } while(LL_Next(list) == 0); |
---|
466 | } |
---|
467 | |
---|
468 | void lcd_drv_output(int on) |
---|
469 | { |
---|
470 | lcd_logical_driver *driver; |
---|
471 | LL_Rewind(list); |
---|
472 | do |
---|
473 | { |
---|
474 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
475 | if(driver) |
---|
476 | { |
---|
477 | lcd.framebuf = driver->framebuf; |
---|
478 | if((int)driver->output > 0) |
---|
479 | driver->output(on); |
---|
480 | else if((int)driver->output == -1) |
---|
481 | { |
---|
482 | drv_base->output(on); |
---|
483 | } |
---|
484 | } |
---|
485 | } while(LL_Next(list) == 0); |
---|
486 | } |
---|
487 | |
---|
488 | |
---|
489 | void lcd_drv_init_vbar() |
---|
490 | { |
---|
491 | lcd_logical_driver *driver; |
---|
492 | |
---|
493 | LL_Rewind(list); |
---|
494 | do { |
---|
495 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
496 | if(driver) |
---|
497 | { |
---|
498 | lcd.framebuf = driver->framebuf; |
---|
499 | |
---|
500 | if((int)driver->init_vbar > 0) |
---|
501 | driver->init_vbar(); |
---|
502 | else if((int)driver->init_vbar == -1) |
---|
503 | { |
---|
504 | drv_base->init_vbar(); |
---|
505 | } |
---|
506 | } |
---|
507 | } while(LL_Next(list) == 0); |
---|
508 | } |
---|
509 | |
---|
510 | void lcd_drv_init_hbar() |
---|
511 | { |
---|
512 | lcd_logical_driver *driver; |
---|
513 | |
---|
514 | LL_Rewind(list); |
---|
515 | do { |
---|
516 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
517 | if(driver) |
---|
518 | { |
---|
519 | lcd.framebuf = driver->framebuf; |
---|
520 | |
---|
521 | if((int)driver->init_hbar > 0) |
---|
522 | driver->init_hbar(); |
---|
523 | else if((int)driver->init_hbar == -1) |
---|
524 | { |
---|
525 | drv_base->init_hbar(); |
---|
526 | } |
---|
527 | } |
---|
528 | } while(LL_Next(list) == 0); |
---|
529 | } |
---|
530 | |
---|
531 | void lcd_drv_init_num() |
---|
532 | { |
---|
533 | lcd_logical_driver *driver; |
---|
534 | |
---|
535 | LL_Rewind(list); |
---|
536 | do { |
---|
537 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
538 | if(driver) |
---|
539 | { |
---|
540 | lcd.framebuf = driver->framebuf; |
---|
541 | |
---|
542 | if((int)driver->init_num > 0) |
---|
543 | driver->init_num(); |
---|
544 | else if((int)driver->init_num == -1) |
---|
545 | { |
---|
546 | drv_base->init_num(); |
---|
547 | } |
---|
548 | } |
---|
549 | } while(LL_Next(list) == 0); |
---|
550 | } |
---|
551 | |
---|
552 | void lcd_drv_num(int x, int num) |
---|
553 | { |
---|
554 | lcd_logical_driver *driver; |
---|
555 | |
---|
556 | LL_Rewind(list); |
---|
557 | do { |
---|
558 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
559 | if(driver) |
---|
560 | { |
---|
561 | lcd.framebuf = driver->framebuf; |
---|
562 | |
---|
563 | if((int)driver->num > 0) |
---|
564 | driver->num(x,num); |
---|
565 | else if((int)driver->num == -1) |
---|
566 | { |
---|
567 | drv_base->num(x,num); |
---|
568 | } |
---|
569 | } |
---|
570 | } while(LL_Next(list) == 0); |
---|
571 | } |
---|
572 | |
---|
573 | void lcd_drv_set_char(int n, char *dat) |
---|
574 | { |
---|
575 | lcd_logical_driver *driver; |
---|
576 | |
---|
577 | LL_Rewind(list); |
---|
578 | do { |
---|
579 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
580 | if(driver) |
---|
581 | { |
---|
582 | lcd.framebuf = driver->framebuf; |
---|
583 | |
---|
584 | if((int)driver->set_char > 0) |
---|
585 | driver->set_char(n,dat); |
---|
586 | else if((int)driver->set_char == -1) |
---|
587 | { |
---|
588 | drv_base->set_char(n,dat); |
---|
589 | } |
---|
590 | } |
---|
591 | } while(LL_Next(list) == 0); |
---|
592 | } |
---|
593 | |
---|
594 | void lcd_drv_vbar(int x, int len) |
---|
595 | { |
---|
596 | lcd_logical_driver *driver; |
---|
597 | |
---|
598 | LL_Rewind(list); |
---|
599 | do { |
---|
600 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
601 | if(driver) |
---|
602 | { |
---|
603 | lcd.framebuf = driver->framebuf; |
---|
604 | |
---|
605 | if((int)driver->vbar > 0) |
---|
606 | driver->vbar(x,len); |
---|
607 | else if((int)driver->vbar == -1) |
---|
608 | { |
---|
609 | drv_base->vbar(x,len); |
---|
610 | } |
---|
611 | } |
---|
612 | } while(LL_Next(list) == 0); |
---|
613 | } |
---|
614 | |
---|
615 | void lcd_drv_hbar(int x, int y, int len) |
---|
616 | { |
---|
617 | lcd_logical_driver *driver; |
---|
618 | |
---|
619 | LL_Rewind(list); |
---|
620 | do { |
---|
621 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
622 | if(driver) |
---|
623 | { |
---|
624 | lcd.framebuf = driver->framebuf; |
---|
625 | |
---|
626 | if((int)driver->hbar > 0) |
---|
627 | driver->hbar(x,y,len); |
---|
628 | else if((int)driver->hbar == -1) |
---|
629 | { |
---|
630 | drv_base->hbar(x,y,len); |
---|
631 | } |
---|
632 | } |
---|
633 | } while(LL_Next(list) == 0); |
---|
634 | } |
---|
635 | |
---|
636 | |
---|
637 | void lcd_drv_icon(int which, char dest) |
---|
638 | { |
---|
639 | lcd_logical_driver *driver; |
---|
640 | |
---|
641 | LL_Rewind(list); |
---|
642 | do { |
---|
643 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
644 | if(driver) |
---|
645 | { |
---|
646 | lcd.framebuf = driver->framebuf; |
---|
647 | |
---|
648 | if((int)driver->icon > 0) |
---|
649 | driver->icon(which,dest); |
---|
650 | else if((int)driver->icon == -1) |
---|
651 | { |
---|
652 | drv_base->icon(which,dest); |
---|
653 | } |
---|
654 | } |
---|
655 | } while(LL_Next(list) == 0); |
---|
656 | } |
---|
657 | |
---|
658 | |
---|
659 | void lcd_drv_flush_box(int lft, int top, int rgt, int bot) |
---|
660 | { |
---|
661 | lcd_logical_driver *driver; |
---|
662 | |
---|
663 | LL_Rewind(list); |
---|
664 | do { |
---|
665 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
666 | if(driver) |
---|
667 | { |
---|
668 | lcd.framebuf = driver->framebuf; |
---|
669 | |
---|
670 | if((int)driver->flush_box > 0) |
---|
671 | driver->flush_box(lft,top,rgt,bot); |
---|
672 | else if((int)driver->flush_box == -1) |
---|
673 | { |
---|
674 | drv_base->flush_box(lft,top,rgt,bot); |
---|
675 | } |
---|
676 | } |
---|
677 | } while(LL_Next(list) == 0); |
---|
678 | |
---|
679 | } |
---|
680 | |
---|
681 | |
---|
682 | // TODO: Check whether lcd.draw_frame() should really take a framebuffer |
---|
683 | // TODO: as an argument, or if it should always use lcd.framebuf |
---|
684 | void lcd_drv_draw_frame(char *dat) |
---|
685 | { |
---|
686 | lcd_logical_driver *driver; |
---|
687 | |
---|
688 | LL_Rewind(list); |
---|
689 | do { |
---|
690 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
691 | if(driver) |
---|
692 | { |
---|
693 | lcd.framebuf = driver->framebuf; |
---|
694 | |
---|
695 | if((int)driver->draw_frame > 0) |
---|
696 | driver->draw_frame(dat); |
---|
697 | else if((int)driver->draw_frame == -1) |
---|
698 | { |
---|
699 | drv_base->draw_frame(dat); |
---|
700 | } |
---|
701 | } |
---|
702 | } while(LL_Next(list) == 0); |
---|
703 | |
---|
704 | } |
---|
705 | |
---|
706 | |
---|
707 | char lcd_drv_getkey() |
---|
708 | { |
---|
709 | lcd_logical_driver *driver; |
---|
710 | |
---|
711 | char key; |
---|
712 | |
---|
713 | LL_Rewind(list); |
---|
714 | do { |
---|
715 | driver = (lcd_logical_driver *)LL_Get(list); |
---|
716 | if(driver) |
---|
717 | { |
---|
718 | lcd.framebuf = driver->framebuf; |
---|
719 | |
---|
720 | if((int)driver->getkey > 0) |
---|
721 | { |
---|
722 | key = driver->getkey(); |
---|
723 | if(key) return key; |
---|
724 | } |
---|
725 | else if((int)driver->getkey == -1) |
---|
726 | { |
---|
727 | key = drv_base->getkey(); |
---|
728 | if(key) return key; |
---|
729 | } |
---|
730 | } |
---|
731 | } while(LL_Next(list) == 0); |
---|
732 | |
---|
733 | return 0; |
---|
734 | } |
---|