Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/GUI/gui.c

1/*
2 * gui.c
3 *
4 *
5 * Created by Jasmin Fazlic on 18.12.08.
6 * Copyright 2008/09 Jasmin Fazlic All rights reserved.
7 * Copyright 2008/09 iNDi All rights reserved.
8 *
9 */
10
11/*
12 * cparm : cleaned
13 */
14
15#include "gui.h"
16#include "appleboot.h"
17#include "vers.h"
18#include "modules.h"
19#include "rand.h"
20#include "sl.h"
21
22
23gui_t gui;// gui structure
24font_t font_small;
25font_t font_console;
26
27
28#define IMG_REQUIRED -1
29#define THEME_NAME_DEFAULT"Default"
30const char* theme_name = THEME_NAME_DEFAULT;
31
32char dirsrc[22];
33
34#ifdef EMBED_THEME
35#include "art.h"
36#endif
37
38static int loadThemeImage(char *src, const char *image, int alt_image);
39
40#define LOADPNG(src, img, alt_img) if (loadThemeImage(src, #img, alt_img) != 0) { return 1; }
41
42#ifndef MIN
43#define MIN(x, y) ((x) < (y) ? (x) : (y))
44#endif
45
46#ifndef MAX
47#define MAX(x, y) ((x) > (y) ? (x) : (y))
48#endif
49
50#define VIDEO(x) (bootArgs->Video.v_ ## x)
51
52#define vram VIDEO(baseAddr)
53
54int lasttime = 0; // we need this for animating maybe
55
56extern int gDeviceCount;
57
58/*
59 * ATTENTION: the enum and the following array images[] MUST match !!!
60 */
61enum {
62 iBackground = 0,
63 iLogo,
64
65 iDeviceGeneric,
66 iDeviceGeneric_o,
67 iDeviceHFS,
68 iDeviceHFS_o,
69 iDeviceHFSRAID,
70 iDeviceHFSRAID_o,
71 iDeviceEXT3,
72 iDeviceEXT3_o,
73iDeviceFreeBSD,
74 iDeviceFreeBSD_o,
75 iDeviceOpenBSD,
76 iDeviceOpenBSD_o,
77 iDeviceFAT,
78 iDeviceFAT_o,
79 iDeviceFAT16,
80 iDeviceFAT16_o,
81 iDeviceFAT32,
82 iDeviceFAT32_o,
83 iDeviceNTFS,
84 iDeviceNTFS_o,
85 iDeviceCDROM,
86 iDeviceCDROM_o,
87
88 iSelection,
89 iDeviceScrollPrev,
90 iDeviceScrollNext,
91
92 iMenuBoot,
93 iMenuVerbose,
94 iMenuIgnoreCaches,
95 iMenuSingleUser,
96 iMenuMemoryInfo,
97 iMenuVideoInfo,
98 iMenuHelp,
99 iMenuVerboseDisabled,
100 iMenuIgnoreCachesDisabled,
101 iMenuSingleUserDisabled,
102 iMenuSelection,
103
104 iProgressBar,
105 iProgressBarBackground,
106
107 iTextScrollPrev,
108 iTextScrollNext,
109
110 iFontConsole,
111 iFontSmall,
112};
113
114image_t images[] = {
115 {.name = "background", .image = NULL},
116 {.name = "logo", .image = NULL},
117
118 {.name = "device_generic", .image = NULL},
119 {.name = "device_generic_o", .image = NULL},
120 {.name = "device_hfsplus", .image = NULL},
121 {.name = "device_hfsplus_o", .image = NULL},
122 {.name = "device_hfsraid", .image = NULL},
123 {.name = "device_hfsraid_o", .image = NULL},
124 {.name = "device_ext3", .image = NULL},
125 {.name = "device_ext3_o", .image = NULL},
126{.name = "device_freebsd", .image = NULL},
127 {.name = "device_freebsd_o", .image = NULL},
128 {.name = "device_openbsd", .image = NULL},
129 {.name = "device_openbsd_o", .image = NULL},
130 {.name = "device_fat", .image = NULL},
131 {.name = "device_fat_o", .image = NULL},
132 {.name = "device_fat16", .image = NULL},
133 {.name = "device_fat16_o", .image = NULL},
134 {.name = "device_fat32", .image = NULL},
135 {.name = "device_fat32_o", .image = NULL},
136 {.name = "device_ntfs", .image = NULL},
137 {.name = "device_ntfs_o", .image = NULL},
138 {.name = "device_cdrom", .image = NULL},
139 {.name = "device_cdrom_o", .image = NULL},
140
141 {.name = "device_selection", .image = NULL},
142 {.name = "device_scroll_prev", .image = NULL},
143 {.name = "device_scroll_next", .image = NULL},
144
145 {.name = "menu_boot", .image = NULL},
146 {.name = "menu_verbose", .image = NULL},
147 {.name = "menu_ignore_caches", .image = NULL},
148 {.name = "menu_single_user", .image = NULL},
149 {.name = "menu_memory_info", .image = NULL},
150 {.name = "menu_video_info", .image = NULL},
151 {.name = "menu_help", .image = NULL},
152 {.name = "menu_verbose_disabled", .image = NULL},
153 {.name = "menu_ignore_caches_disabled", .image = NULL},
154 {.name = "menu_single_user_disabled", .image = NULL},
155 {.name = "menu_selection", .image = NULL},
156
157 {.name = "progress_bar", .image = NULL},
158 {.name = "progress_bar_background", .image = NULL},
159
160 {.name = "text_scroll_prev", .image = NULL},
161 {.name = "text_scroll_next", .image = NULL},
162
163 {.name = "font_console", .image = NULL},
164 {.name = "font_small", .image = NULL},
165};
166
167int imageCnt = 0;
168
169extern intgDeviceCount;
170extern intselectIndex;
171
172char prompt[BOOT_STRING_LEN];
173
174int prompt_pos=0;
175
176char prompt_text[] = "boot: ";
177
178menuitem_t infoMenuItems[] =
179{
180{ .text = "Boot" },
181{ .text = "Boot Verbose" },
182{ .text = "Boot Ignore Caches" },
183{ .text = "Boot Single User" },
184{ .text = "Memory Info" },
185{ .text = "Video Info" },
186{ .text = "Help" }
187};
188
189int initFont(font_t *font, image_t *image);
190void colorFont(font_t *font, uint32_t color);
191void makeRoundedCorners(pixmap_t *p);
192
193int infoMenuSelection = 0;
194int infoMenuItemsCount = sizeof(infoMenuItems)/sizeof(infoMenuItems[0]);
195
196bool infoMenuNativeBoot = false;
197
198unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0};// here we store the used screen resolution
199
200int getImageIndexByName(const char *name)
201{
202 int i;
203for (i = 0; (unsigned)i < sizeof(images) / sizeof(images[0]); i++)
204{
205 if (strcmp(name, images[i].name) == 0)
206 return i; // found the name
207}
208return -1;
209}
210
211#ifdef EMBED_THEME
212static int getEmbeddedImageIndexByName(const char *name)
213{
214int upperLimit = sizeof(embeddedImages) / sizeof(embeddedImages[0]) - 1;
215int lowerLimit = 0;
216int compareIndex = (upperLimit - lowerLimit) >> 1; // Midpoint
217int result;
218
219// NOTE: This algorithm assumes that the embeddedImages is sorted.
220// This is currently done using the make file. If the array is every
221// manualy generated, this *will* fail to work properly.
222while((result = strcmp(name, embeddedImages[compareIndex].name)) != 0)
223{
224if(result > 0)// We need to search a HIGHER index
225{
226if(compareIndex != lowerLimit)
227{
228lowerLimit = compareIndex;
229}
230else
231{
232return -1;
233}
234compareIndex = (upperLimit + lowerLimit + 1) >> 1;// Midpoint, round up
235}
236else // We Need to search a LOWER index
237{
238if(compareIndex != upperLimit)
239{
240upperLimit = compareIndex;
241}
242else
243{
244return -1;
245}
246compareIndex = (upperLimit + lowerLimit) >> 1;// Midpoint, round down
247}
248}
249return compareIndex;
250}
251#endif
252
253static int loadThemeImage(char* src, const char *image, int alt_image)
254{
255chardirspec[256];
256int i;
257#ifdef EMBED_THEME
258int e;
259#endif
260uint16_twidth;
261uint16_theight;
262uint8_t*imagedata;
263if ((unsigned)(strlen(image) + strlen(theme_name) + 30 ) > sizeof(dirspec)) {
264return 1;
265}
266
267 if ((i = getImageIndexByName(image)) >= 0)
268 {
269 if (images[i].image == NULL) {
270 images[i].image = malloc(sizeof(pixmap_t));
271 }
272 sprintf(dirspec, "%s/%s/%s.png", src, theme_name, image);
273
274 width = 0;
275 height = 0;
276 imagedata = NULL;
277 if ( strlen(theme_name) > 0 && (loadPngImage(dirspec, &width, &height, &imagedata)) == 0)
278 {
279 images[i].image->width = width;
280 images[i].image->height = height;
281 images[i].image->pixels = (pixel_t *)imagedata;
282 flipRB(images[i].image);
283 return 0;
284 }
285#ifdef EMBED_THEME
286 else if ((e = getEmbeddedImageIndexByName(image)) >= 0)
287 {
288 unsigned char *embed_data;
289 unsigned int embed_size;
290 embed_data = embeddedImages[e].pngdata;
291 embed_size = *embeddedImages[e].length;
292
293 if (loadEmbeddedPngImage(embed_data, embed_size, &width, &height, &imagedata) == 0)
294 {
295 images[i].image->width = width;
296 images[i].image->height = height;
297 images[i].image->pixels = (pixel_t *)imagedata;
298 flipRB(images[i].image);
299 return 0;
300 }
301
302 return 0;
303 }
304#endif
305 else if (alt_image != IMG_REQUIRED && images[alt_image].image->pixels != NULL)
306 {
307 // Using the passed alternate image for non-mandatory images.
308 // We don't clone the already existing pixmap, but using its properties instead!
309 images[i].image->width = images[alt_image].image->width;
310 images[i].image->height = images[alt_image].image->height;
311 images[i].image->pixels = images[alt_image].image->pixels;
312 return 0;
313 }
314 else
315 {
316#ifndef EMBED_THEME
317 printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image);
318sleep(2);
319#endif
320 return 1;
321 }
322 }
323
324return 1;
325}
326
327static int loadGraphics(char *src)
328{
329LOADPNG(src, background, IMG_REQUIRED);
330
331LOADPNG(src, logo, IMG_REQUIRED);
332
333LOADPNG(src, device_generic, IMG_REQUIRED);
334LOADPNG(src, device_generic_o, iDeviceGeneric);
335LOADPNG(src, device_hfsplus, iDeviceGeneric);
336LOADPNG(src, device_hfsplus_o, iDeviceHFS);
337LOADPNG(src, device_hfsraid, iDeviceGeneric);
338LOADPNG(src, device_hfsraid_o, iDeviceHFSRAID);
339LOADPNG(src, device_ext3, iDeviceGeneric);
340LOADPNG(src, device_ext3_o, iDeviceEXT3);
341LOADPNG(src, device_freebsd, iDeviceGeneric);
342LOADPNG(src, device_freebsd_o, iDeviceFreeBSD);
343LOADPNG(src, device_openbsd, iDeviceGeneric);
344LOADPNG(src, device_openbsd_o, iDeviceOpenBSD);
345LOADPNG(src, device_fat, iDeviceGeneric);
346LOADPNG(src, device_fat_o, iDeviceFAT);
347LOADPNG(src, device_fat16, iDeviceFAT);
348LOADPNG(src, device_fat16_o, iDeviceFAT_o);
349LOADPNG(src, device_fat32, iDeviceFAT);
350LOADPNG(src, device_fat32_o, iDeviceFAT_o);
351LOADPNG(src, device_ntfs, iDeviceGeneric);
352LOADPNG(src, device_ntfs_o, iDeviceNTFS);
353LOADPNG(src, device_cdrom, iDeviceGeneric);
354LOADPNG(src, device_cdrom_o, iDeviceCDROM);
355
356LOADPNG(src, device_selection, IMG_REQUIRED);
357LOADPNG(src, device_scroll_prev, IMG_REQUIRED);
358LOADPNG(src, device_scroll_next, IMG_REQUIRED);
359
360LOADPNG(src, menu_boot, IMG_REQUIRED);
361LOADPNG(src, menu_verbose, IMG_REQUIRED);
362LOADPNG(src, menu_ignore_caches, IMG_REQUIRED);
363LOADPNG(src, menu_single_user, IMG_REQUIRED);
364LOADPNG(src, menu_memory_info, IMG_REQUIRED);
365LOADPNG(src, menu_video_info, IMG_REQUIRED);
366LOADPNG(src, menu_help, IMG_REQUIRED);
367LOADPNG(src, menu_verbose_disabled, IMG_REQUIRED);
368LOADPNG(src, menu_ignore_caches_disabled, IMG_REQUIRED);
369LOADPNG(src, menu_single_user_disabled, IMG_REQUIRED);
370LOADPNG(src, menu_selection, IMG_REQUIRED);
371
372LOADPNG(src, progress_bar, IMG_REQUIRED);
373LOADPNG(src, progress_bar_background, IMG_REQUIRED);
374
375LOADPNG(src, text_scroll_prev, IMG_REQUIRED);
376LOADPNG(src, text_scroll_next, IMG_REQUIRED);
377
378LOADPNG(src, font_console, IMG_REQUIRED);
379LOADPNG(src, font_small, IMG_REQUIRED);
380
381initFont( &font_console, &images[iFontConsole]);
382initFont( &font_small, &images[iFontSmall]);
383
384return 0;
385}
386
387pixmap_t *getCroppedPixmapAtPosition( pixmap_t *from, position_t pos, uint16_t width, uint16_t height )
388{
389
390pixmap_t *cropped = malloc( sizeof( pixmap_t ) );
391if( !cropped )
392return 0;
393cropped->pixels = malloc( width * height * 4 );
394if ( !cropped->pixels )
395return 0;
396
397cropped->width = width;
398cropped->height = height;
399
400int destx = 0, desty = 0;
401int srcx = pos.x, srcy = pos.y;
402
403for( ; desty < height; desty++, srcy++)
404{
405for( destx = 0, srcx = pos.x; destx < width; destx++, srcx++ )
406{
407pixel( cropped, destx, desty ).value = pixel( from, srcx, srcy ).value;
408}
409}
410return cropped;
411}
412
413int createBackBuffer( window_t *window )
414{
415gui.backbuffer = malloc(sizeof(pixmap_t));
416if(!gui.backbuffer)
417return 1;
418
419gui.backbuffer->pixels = malloc( window->width * window->height * 4 );
420if(!gui.backbuffer->pixels)
421{
422free(gui.backbuffer);
423gui.backbuffer = 0;
424return 1;
425}
426
427gui.backbuffer->width = gui.screen.width;
428gui.backbuffer->height = gui.screen.height;
429
430return 0;
431}
432
433int createWindowBuffer( window_t *window )
434{
435window->pixmap = malloc(sizeof(pixmap_t));
436if(!window->pixmap)
437return 1;
438
439window->pixmap->pixels = malloc( window->width * window->height * 4 );
440if(!window->pixmap->pixels)
441{
442free(window->pixmap);
443window->pixmap = 0;
444return 1;
445}
446
447window->pixmap->width = window->width;
448window->pixmap->height = window->height;
449
450return 0;
451}
452
453int freeWindowBuffer( window_t *window )
454{
455if (window->pixmap && window->pixmap->pixels)
456 {
457free(window->pixmap->pixels);
458free(window->pixmap);
459return 0;
460}
461
462return 1;
463}
464
465void fillPixmapWithColor(pixmap_t *pm, uint32_t color)
466{
467int x,y;
468
469// fill with given color AARRGGBB
470for( x=0; x < pm->width; x++ )
471for( y=0; y< pm->height; y++)
472pixel(pm,x,y).value = color;
473}
474
475void drawBackground()
476{
477// reset text cursor
478gui.screen.cursor.x = gui.screen.hborder;
479gui.screen.cursor.y = gui.screen.vborder;
480
481fillPixmapWithColor( gui.screen.pixmap, gui.screen.bgcolor);
482
483// draw background.png into background buffer
484blend( images[iBackground].image, gui.screen.pixmap, gui.background.pos );
485
486// draw logo.png into background buffer
487if (gui.logo.draw)
488{
489 blend( images[iLogo].image, gui.screen.pixmap, gui.logo.pos);
490}
491
492memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
493}
494
495void setupDeviceList(config_file_t *theme)
496{
497unsigned int pixel;
498intalpha;// transparency level 0 (obligue) - 255 (transparent)
499uint32_t color;// color value formatted RRGGBB
500int val, len;
501const char *string;
502
503if(getIntForKey("devices_max_visible", &val, theme ))
504gui.maxdevices = MIN( val, gDeviceCount );
505
506if(getIntForKey("devices_iconspacing", &val, theme ))
507gui.devicelist.iconspacing = val;
508
509// check layout for horizontal or vertical
510gui.layout = HorizontalLayout;
511if(getValueForKey( "devices_layout", &string, &len, theme)) {
512if (!strcmp (string, "vertical")) {
513gui.layout = VerticalLayout;
514}
515}
516
517switch (gui.layout) {
518case VerticalLayout:
519gui.devicelist.height = ((images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing) * MIN(gui.maxdevices, gDeviceCount) + (images[iDeviceScrollPrev].image->height + images[iDeviceScrollNext].image->height) + gui.devicelist.iconspacing);
520gui.devicelist.width = (images[iSelection].image->width + gui.devicelist.iconspacing);
521
522if(getDimensionForKey("devices_pos_x", &pixel, theme, gui.screen.width , images[iSelection].image->width ) )
523gui.devicelist.pos.x = pixel;
524
525if(getDimensionForKey("devices_pos_y", &pixel, theme, gui.screen.height , gui.devicelist.height ) )
526gui.devicelist.pos.y = pixel;
527break;
528
529case HorizontalLayout:
530default:
531gui.devicelist.width = ((images[iSelection].image->width + gui.devicelist.iconspacing) * MIN(gui.maxdevices, gDeviceCount) + (images[iDeviceScrollPrev].image->width + images[iDeviceScrollNext].image->width) + gui.devicelist.iconspacing);
532gui.devicelist.height = (images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing);
533
534if(getDimensionForKey("devices_pos_x", &pixel, theme, gui.screen.width , gui.devicelist.width ) )
535gui.devicelist.pos.x = pixel;
536else
537gui.devicelist.pos.x = ( gui.screen.width - gui.devicelist.width ) / 2;
538
539if(getDimensionForKey("devices_pos_y", &pixel, theme, gui.screen.height , images[iSelection].image->height ) )
540gui.devicelist.pos.y = pixel;
541else
542gui.devicelist.pos.y = ( gui.screen.height - gui.devicelist.height ) / 2;
543break;
544}
545
546if(getColorForKey("devices_bgcolor", &color, theme))
547gui.devicelist.bgcolor = (color & 0x00FFFFFF);
548
549if(getIntForKey("devices_transparency", &alpha, theme))
550gui.devicelist.bgcolor = gui.devicelist.bgcolor | (( 255 - ( alpha & 0xFF) ) << 24);
551
552if (gui.devicelist.pixmap)
553{
554 freeWindowBuffer(&gui.devicelist);
555 createWindowBuffer(&gui.devicelist);
556 }
557}
558
559void loadThemeValues(config_file_t *theme)
560{
561unsigned int screen_width = gui.screen.width;
562unsigned int screen_height = gui.screen.height;
563unsigned int pixel;
564intalpha;// transparency level 0 (obligue) - 255 (transparent)
565uint32_t color;// color value formatted RRGGBB
566int val;
567
568/*
569 * Parse screen parameters
570 */
571if(getColorForKey("screen_bgcolor", &color, theme ))
572gui.screen.bgcolor = (color & 0x00FFFFFF);
573
574if(getIntForKey("screen_textmargin_h", &val, theme))
575gui.screen.hborder = MIN( gui.screen.width , val );
576
577if(getIntForKey("screen_textmargin_v", &val, theme))
578gui.screen.vborder = MIN( gui.screen.height , val );
579
580/*
581 * Parse background parameters
582 */
583if(getDimensionForKey("background_pos_x", &pixel, theme, screen_width , images[iBackground].image->width ) )
584gui.background.pos.x = pixel;
585
586if(getDimensionForKey("background_pos_y", &pixel, theme, screen_height , images[iBackground].image->height ) )
587gui.background.pos.y = pixel;
588
589/*
590 * Parse logo parameters
591 */
592if(getDimensionForKey("logo_pos_x", &pixel, theme, screen_width , images[iLogo].image->width ) )
593gui.logo.pos.x = pixel;
594
595if(getDimensionForKey("logo_pos_y", &pixel, theme, screen_height , images[iLogo].image->height ) )
596gui.logo.pos.y = pixel;
597
598/*
599 * Parse progress bar parameters
600 */
601if(getDimensionForKey("progressbar_pos_x", &pixel, theme, screen_width , 0 ) )
602gui.progressbar.pos.x = pixel;
603
604if(getDimensionForKey("progressbar_pos_y", &pixel, theme, screen_height , 0 ) )
605gui.progressbar.pos.y = pixel;
606
607/*
608 * Parse countdown text parameters
609 */
610if(getDimensionForKey("countdown_pos_x", &pixel, theme, screen_width , 0 ) )
611gui.countdown.pos.x = pixel;
612
613if(getDimensionForKey("countdown_pos_y", &pixel, theme, screen_height , 0 ) )
614gui.countdown.pos.y = pixel;
615
616 /*
617 * Parse devicelist parameters
618 */
619setupDeviceList(theme);
620
621/*
622 * Parse infobox parameters
623 */
624if(getIntForKey("infobox_width", &val, theme) && val >= 0)
625gui.infobox.width = MIN( screen_width ,(unsigned) val );
626
627if(getIntForKey("infobox_height", &val, theme) && val >= 0)
628gui.infobox.height = MIN( screen_height , (unsigned)val );
629
630if(getDimensionForKey("infobox_pos_x", &pixel, theme, screen_width , gui.infobox.width ) )
631gui.infobox.pos.x = pixel;
632
633if(getDimensionForKey("infobox_pos_y", &pixel, theme, screen_height , gui.infobox.height ) )
634gui.infobox.pos.y = pixel;
635
636if(getIntForKey("infobox_textmargin_h", &val, theme))
637gui.infobox.hborder = MIN( gui.infobox.width , val );
638
639if(getIntForKey("infobox_textmargin_v", &val, theme))
640gui.infobox.vborder = MIN( gui.infobox.height , val );
641
642if(getColorForKey("infobox_bgcolor", &color, theme))
643gui.infobox.bgcolor = (color & 0x00FFFFFF);
644
645if(getIntForKey("infobox_transparency", &alpha, theme))
646gui.infobox.bgcolor = gui.infobox.bgcolor | (( 255 - ( alpha & 0xFF) ) << 24);
647
648/*
649 * Parse menu parameters
650 */
651if(getDimensionForKey("menu_width", &pixel, theme, gui.screen.width , 0 ) )
652gui.menu.width = pixel;
653else
654gui.menu.width = images[iMenuSelection].image->width;
655
656if(getDimensionForKey("menu_height", &pixel, theme, gui.screen.height , 0 ) )
657gui.menu.height = pixel;
658else
659gui.menu.height = (infoMenuItemsCount) * images[iMenuSelection].image->height;
660
661if(getDimensionForKey("menu_pos_x", &pixel, theme, screen_width , gui.menu.width ) )
662gui.menu.pos.x = pixel;
663
664if(getDimensionForKey("menu_pos_y", &pixel, theme, screen_height , gui.menu.height ) )
665gui.menu.pos.y = pixel;
666
667if(getIntForKey("menu_textmargin_h", &val, theme))
668gui.menu.hborder = MIN( gui.menu.width , val );
669
670if(getIntForKey("menu_textmargin_v", &val, theme))
671gui.menu.vborder = MIN( gui.menu.height , val );
672
673if(getColorForKey("menu_bgcolor", &color, theme))
674gui.menu.bgcolor = (color & 0x00FFFFFF);
675
676if(getIntForKey("menu_transparency", &alpha, theme))
677gui.menu.bgcolor = gui.menu.bgcolor | (( 255 - ( alpha & 0xFF) ) << 24);
678
679/*
680 * Parse bootprompt parameters
681 */
682if(getDimensionForKey("bootprompt_width", &pixel, theme, screen_width , 0 ) )
683gui.bootprompt.width = pixel;
684
685if(getIntForKey("bootprompt_height", &val, theme) && val >= 0)
686gui.bootprompt.height = MIN( screen_height , (unsigned)val );
687
688if(getDimensionForKey("bootprompt_pos_x", &pixel, theme, screen_width , gui.bootprompt.width ) )
689gui.bootprompt.pos.x = pixel;
690
691if(getDimensionForKey("bootprompt_pos_y", &pixel, theme, screen_height , gui.bootprompt.height ) )
692gui.bootprompt.pos.y = pixel;
693
694if(getIntForKey("bootprompt_textmargin_h", &val, theme) && val >= 0)
695gui.bootprompt.hborder = MIN( gui.bootprompt.width , (unsigned)val );
696
697if(getIntForKey("bootprompt_textmargin_v", &val, theme) && val >= 0)
698gui.bootprompt.vborder = MIN( gui.bootprompt.height , (unsigned)val );
699
700if(getColorForKey("bootprompt_bgcolor", &color, theme))
701gui.bootprompt.bgcolor = (color & 0x00FFFFFF);
702
703if(getIntForKey("bootprompt_transparency", &alpha, theme))
704gui.bootprompt.bgcolor = gui.bootprompt.bgcolor | (( 255 - ( alpha & 0xFF) ) << 24);
705
706if(getColorForKey("font_small_color", &color, theme))
707gui.screen.font_small_color = (color & 0x00FFFFFF);
708
709if(getColorForKey("font_console_color", &color, theme))
710gui.screen.font_console_color = (color & 0x00FFFFFF);
711}
712
713#define MAX_tHEME 255
714
715int randomTheme(char *dirspec, const char **theme) {
716
717long ret, flags, time;
718long long index;
719
720const char * name;
721index = 0;
722uint8_t i=0;
723
724char *list[MAX_tHEME];
725#ifdef EMBED_THEME
726list[i] = "";
727i++;
728#endif
729
730while (i < MAX_tHEME) {
731ret = GetDirEntry(dirspec, &index, &name, &flags, &time);
732if (ret == -1) break;
733
734// Make sure this is a directory.
735if ((flags & kFileTypeMask) != kFileTypeDirectory) continue;
736
737if ((unsigned)(strlen(name) + 34) > 256) continue;
738
739if ((list[i] = (char *)malloc(strlen(name))) == NULL) continue;
740
741strcpy(list[i], name);
742
743i++;
744
745}
746
747if (i) {
748
749srand (time18());
750
751*theme = list[(rand() % i)];
752
753
754int ret = startGUI();
755
756uint8_t l=0;
757#ifdef EMBED_THEME
758l++;
759#endif
760while (l<i) {
761free(list[l]);
762l++;
763}
764
765return ret;
766}
767
768return 1;
769
770
771}
772
773int initGUI(void)
774{
775bool dummybool = true;
776getBoolForKey(kGUIKey, &dummybool, &bootInfo->bootConfig);
777if (!dummybool) {
778return 1;
779}
780
781{
782long flags;
783long time;
784long ret = -1;
785
786ret = GetFileInfo("/Extra/", "Themes", &flags, &time);
787if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)) {
788sprintf(dirsrc, "/Extra/Themes");
789
790} else {
791ret = GetFileInfo("bt(0,0)/Extra/", "Themes", &flags, &time);
792if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)) {
793sprintf(dirsrc, "bt(0,0)/Extra/Themes");
794
795} else {
796ret = GetFileInfo("rd(0,0)/Extra/", "Themes", &flags, &time);
797if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)) {
798sprintf(dirsrc, "rd(0,0)/Extra/Themes");
799
800} else {
801printf("Failed to find the /extra/Themes folder\n");
802return 1;
803}
804}
805
806}
807}
808
809int len;
810bool theme_ran= false;
811getBoolForKey("RandomTheme", &theme_ran, &bootInfo->bootConfig);
812int ret = 1;
813
814if (theme_ran) {
815
816ret = randomTheme(dirsrc, &theme_name);
817
818if (ret) printf("randomTheme Failed !! \n");
819
820}
821
822
823if (ret)
824{
825if (getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig ) == true)
826{
827ret = startGUI();
828
829if (ret) printf("Failed to load Theme : %s !! \n", theme_name);
830
831}
832#ifdef EMBED_THEME
833if (ret) {
834theme_name = "";
835ret = startGUI();
836
837if (ret) printf("Failed to load Embed Theme !! \n");
838
839}
840#endif
841if (ret) {
842theme_name = THEME_NAME_DEFAULT;
843ret = startGUI();
844
845if (ret) printf("Failed to load Default Theme : %s !! \n", THEME_NAME_DEFAULT);
846}
847}
848return ret;
849}
850
851int startGUI(void)
852{
853int val;
854char dirspec[256];
855
856
857if ((unsigned)(strlen(theme_name) + 34) > sizeof(dirspec)) {
858return 1;
859}
860
861sprintf(dirspec, "%s/%s/theme.plist", dirsrc ,theme_name);
862
863if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0) {
864
865#ifdef EMBED_THEME
866if (strlen(theme_name) == 0) {
867config_file_t *config;
868
869config = &bootInfo->themeConfig;
870if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0) {
871return 1;
872}
873}
874#else
875return 1;
876#endif
877 }
878
879if (execute_hook("getResolution_hook", &screen_params[0], &screen_params[1], &screen_params[2], NULL, NULL, NULL) != EFI_SUCCESS)
880{
881// parse display size parameters
882if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0) {
883screen_params[0] = val;
884}
885if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0) {
886screen_params[1] = val;
887}
888}
889
890
891// Initalizing GUI strucutre.
892bzero(&gui, sizeof(gui_t));
893
894// find best matching vesa mode for our requested width & height
895getGraphicModeParams(screen_params);
896
897// set our screen structure with the mode width & height
898gui.screen.width = screen_params[0];
899gui.screen.height = screen_params[1];
900
901// load graphics otherwise fail and return
902if (loadGraphics(dirsrc) == 0) {
903loadThemeValues(&bootInfo->themeConfig);
904colorFont(&font_small, gui.screen.font_small_color);
905colorFont(&font_console, gui.screen.font_console_color);
906
907// create the screen & window buffers
908if (createBackBuffer(&gui.screen) == 0)
909{
910if (createWindowBuffer(&gui.screen) == 0)
911{
912if (createWindowBuffer(&gui.devicelist) == 0)
913{
914if (createWindowBuffer(&gui.bootprompt) == 0)
915{
916if (createWindowBuffer(&gui.infobox) == 0)
917{
918if (createWindowBuffer(&gui.menu) == 0)
919{
920 gui.logo.draw = true;
921drawBackground();
922// lets copy the screen into the back buffer
923#if UNUSED
924setVideoMode( GRAPHICS_MODE, 0 );
925#else
926setVideoMode( GRAPHICS_MODE );
927#endif
928gui.initialised = true;
929return 0;
930}
931}
932}
933}
934}
935}
936}
937return 1;
938}
939
940void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected)
941{
942int devicetype;
943
944if( diskIsCDROM(device) )
945devicetype = iDeviceCDROM;// Use CDROM icon
946else
947{
948switch (device->part_type)
949{
950case kPartitionTypeHFS:
951#ifdef BOOT_HELPER_SUPPORT
952// Use HFS or HFSRAID icon depending on bvr flags.
953devicetype = (device->flags & kBVFlagBooter) ? iDeviceHFSRAID : iDeviceHFS;
954#else
955devicetype = iDeviceHFS;
956#endif
957break;
958
959case kPartitionTypeHPFS:
960devicetype = iDeviceNTFS;// Use HPFS / NTFS icon
961break;
962
963case kPartitionTypeFAT16:
964devicetype = iDeviceFAT16;// Use FAT16 icon
965break;
966
967case kPartitionTypeFAT32:
968devicetype = iDeviceFAT32;// Use FAT32 icon
969break;
970
971case kPartitionTypeEXT3:
972devicetype = iDeviceEXT3;// Use EXT2/3 icon
973break;
974
975case kPartitionTypeFreeBSD:
976devicetype = iDeviceFreeBSD;// Use FreeBSD icon
977break;
978
979case kPartitionTypeOpenBSD:
980devicetype = iDeviceOpenBSD;// Use OpenBSD icon
981break;
982
983default:
984devicetype = iDeviceGeneric;// Use Generic icon
985break;
986}
987}
988
989// Draw the selection image and use the next (device_*_o) image for the selected item.
990 if (isSelected)
991{
992blend(images[iSelection].image, buffer, centeredAt(images[iSelection].image, p));
993devicetype++; // selec override image
994}
995
996// draw icon
997blend( images[devicetype].image, buffer, centeredAt( images[devicetype].image, p ));
998
999p.y += (images[iSelection].image->height / 2) + font_console.chars[0]->height;
1000
1001// draw volume label
1002drawStrCenteredAt( device->label, &font_small, buffer, p);
1003
1004}
1005
1006void drawDeviceList (int start, int end, int selection)
1007{
1008int i;
1009position_t p, p_prev, p_next;
1010
1011//uint8_tmaxDevices = MIN( gui.maxdevices, menucount );
1012
1013fillPixmapWithColor( gui.devicelist.pixmap, gui.devicelist.bgcolor);
1014
1015makeRoundedCorners( gui.devicelist.pixmap);
1016
1017switch (gui.layout)
1018{
1019
1020case VerticalLayout:
1021p.x = (gui.devicelist.width /2);
1022p.y = ( ( images[iSelection].image->height / 2 ) + images[iDeviceScrollPrev].image->height + gui.devicelist.iconspacing );
1023
1024// place scroll indicators at top & bottom edges
1025p_prev = pos ( gui.devicelist.width / 2 , gui.devicelist.iconspacing );
1026p_next = pos ( p_prev.x, gui.devicelist.height - gui.devicelist.iconspacing );
1027
1028break;
1029
1030default:// use Horizontal layout as the default
1031
1032case HorizontalLayout:
1033p.x = (gui.devicelist.width - ( gui.devicelist.width / gui.maxdevices ) * gui.maxdevices ) / 2 + ( images[iSelection].image->width / 2) + images[iDeviceScrollPrev].image->width + gui.devicelist.iconspacing;
1034p.y = ((gui.devicelist.height - font_console.chars[0]->height ) - images[iSelection].image->height) / 2 + ( images[iSelection].image->height / 2 );
1035
1036// place scroll indicators at left & right edges
1037p_prev = pos ( images[iDeviceScrollPrev].image->width / 2 + gui.devicelist.iconspacing / 2, gui.devicelist.height / 2 );
1038p_next = pos ( gui.devicelist.width - ( images[iDeviceScrollNext].image->width / 2 + gui.devicelist.iconspacing / 2), gui.devicelist.height / 2 );
1039
1040break;
1041
1042}
1043
1044// draw visible device icons
1045for (i = 0; i < gui.maxdevices; i++)
1046{
1047BVRef param = menuItems[start + i].param;
1048
1049 bool isSelected = ((start + i) == selection) ? true : false;
1050if (isSelected)
1051{
1052 if (param->flags & kBVFlagNativeBoot)
1053 {
1054 infoMenuNativeBoot = true;
1055 }
1056 else
1057 {
1058 infoMenuNativeBoot = false;
1059 if(infoMenuSelection >= INFOMENU_NATIVEBOOT_START && infoMenuSelection <= INFOMENU_NATIVEBOOT_END)
1060infoMenuSelection = 0;
1061 }
1062
1063if(gui.menu.draw)
1064drawInfoMenuItems();
1065
1066#if DEBUG
1067 gui.debug.cursor = pos( 10, 100);
1068 dprintf( &gui.screen, "label %s\n", param->label );
1069 dprintf( &gui.screen, "biosdev 0x%x\n", param->biosdev );
1070 dprintf( &gui.screen, "width %d\n", gui.screen.width);
1071 dprintf( &gui.screen, "height %d\n", gui.screen.height);
1072 dprintf( &gui.screen, "type 0x%x\n", param->type );
1073 dprintf( &gui.screen, "flags 0x%x\n", param->flags );
1074 dprintf( &gui.screen, "part_no %d\n", param->part_no );
1075 dprintf( &gui.screen, "part_boff 0x%x\n", param->part_boff );
1076 dprintf( &gui.screen, "part_type 0x%x\n", param->part_type );
1077 dprintf( &gui.screen, "bps 0x%x\n", param->bps );
1078 dprintf( &gui.screen, "name %s\n", param->name );
1079 dprintf( &gui.screen, "type_name %s\n", param->type_name );
1080 dprintf( &gui.screen, "modtime %d\n", param->modTime );
1081#endif
1082}
1083
1084drawDeviceIcon( param, gui.devicelist.pixmap, p, isSelected);
1085
1086if (gui.layout == HorizontalLayout)
1087{
1088p.x += images[iSelection].image->width + gui.devicelist.iconspacing;
1089}
1090if (gui.layout == VerticalLayout)
1091{
1092p.y += ( images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing );
1093}
1094}
1095
1096// draw prev indicator
1097if(start)
1098blend( images[iDeviceScrollPrev].image, gui.devicelist.pixmap, centeredAt( images[iDeviceScrollPrev].image, p_prev ) );
1099
1100// draw next indicator
1101if( end < gDeviceCount - 1 )
1102blend( images[iDeviceScrollNext].image, gui.devicelist.pixmap, centeredAt( images[iDeviceScrollNext].image, p_next ) );
1103
1104gui.redraw = true;
1105
1106updateVRAM();
1107
1108}
1109
1110void clearGraphicBootPrompt()
1111{
1112// clear text buffer
1113prompt[0] = '\0';
1114prompt_pos=0;
1115
1116
1117if(gui.bootprompt.draw == true )
1118{
1119gui.bootprompt.draw = false;
1120gui.redraw = true;
1121// this causes extra frames to be drawn
1122//updateVRAM();
1123}
1124
1125return;
1126}
1127
1128void updateGraphicBootPrompt(int key)
1129{
1130if ( key == kBackspaceKey )
1131prompt[--prompt_pos] = '\0';
1132else
1133{
1134prompt[prompt_pos] = key;
1135prompt_pos++;
1136prompt[prompt_pos] = '\0';
1137}
1138
1139fillPixmapWithColor( gui.bootprompt.pixmap, gui.bootprompt.bgcolor);
1140
1141makeRoundedCorners( gui.bootprompt.pixmap);
1142
1143position_t p_text = pos( gui.bootprompt.hborder , ( ( gui.bootprompt.height - font_console.chars[0]->height) ) / 2 );
1144
1145// print the boot prompt text
1146drawStr(prompt_text, &font_console, gui.bootprompt.pixmap, p_text);
1147
1148// get the position of the end of the boot prompt text to display user input
1149position_t p_prompt = pos( p_text.x + ( ( strlen(prompt_text) ) * font_console.chars[0]->width ), p_text.y );
1150
1151// calculate the position of the cursor
1152intoffset = ( prompt_pos - ( ( gui.bootprompt.width / font_console.chars[0]->width ) - strlen(prompt_text) - 2 ) );
1153
1154if ( offset < 0)
1155offset = 0;
1156
1157drawStr( prompt+offset, &font_console, gui.bootprompt.pixmap, p_prompt);
1158
1159gui.menu.draw = false;
1160gui.bootprompt.draw = true;
1161gui.redraw = true;
1162
1163updateVRAM();
1164
1165return;
1166}
1167
1168#if UNUSED
1169inline
1170void vramwrite (void *data, int width, int height)
1171#else
1172inline
1173void vramwrite (void *data, int width)
1174#endif
1175{
1176if (VIDEO (depth) == 0x20 /*32*/ && VIDEO (rowBytes) == (unsigned long)gui.backbuffer->width * 4)
1177memcpy((uint8_t *)vram, gui.backbuffer->pixels, VIDEO (rowBytes)*VIDEO (height));
1178else
1179{
1180uint32_t r, g, b;
1181uint32_t i, j;
1182for (i = 0; i < VIDEO (height); i++)
1183for (j = 0; j < VIDEO (width); j++)
1184{
1185b = ((uint8_t *) data)[4*i*width + 4*j];
1186g = ((uint8_t *) data)[4*i*width + 4*j + 1];
1187r = ((uint8_t *) data)[4*i*width + 4*j + 2];
1188switch (VIDEO (depth))
1189{
1190case 32:
1191*(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*4) = (b&0xff) | ((g&0xff)<<8) | ((r&0xff)<<16);
1192break;
1193case 24:
1194*(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*3) = ((*(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*3))&0xff000000)
1195| (b&0xff) | ((g&0xff)<<8) | ((r&0xff)<<16);
1196break;
1197case 16:
1198// Somehow 16-bit is always 15-bits really
1199//*(uint16_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*2) = ((b&0xf8)>>3) | ((g&0xfc)<<3) | ((r&0xf8)<<8);
1200//break;
1201case 15:
1202*(uint16_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*2) = ((b&0xf8)>>3) | ((g&0xf8)<<2) | ((r&0xf8)<<7);
1203break;
1204default:
1205break;
1206}
1207}
1208}
1209}
1210
1211void updateVRAM()
1212{
1213if (gui.redraw)
1214{
1215if (gui.devicelist.draw)
1216blend( gui.devicelist.pixmap, gui.backbuffer, gui.devicelist.pos );
1217
1218if (gui.bootprompt.draw)
1219blend( gui.bootprompt.pixmap, gui.backbuffer, gui.bootprompt.pos );
1220
1221if (gui.menu.draw)
1222blend( gui.menu.pixmap, gui.backbuffer, gui.menu.pos );
1223
1224if (gui.infobox.draw)
1225blend( gui.infobox.pixmap, gui.backbuffer, gui.infobox.pos );
1226}
1227#if UNUSED
1228vramwrite ( gui.backbuffer->pixels, gui.backbuffer->width, gui.backbuffer->height );
1229#else
1230vramwrite ( gui.backbuffer->pixels, gui.backbuffer->width );
1231#endif
1232if (gui.redraw)
1233{
1234memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
1235gui.redraw = false;
1236}
1237}
1238
1239struct putc_info {
1240 char * str;
1241 char * last_str;
1242};
1243
1244static void
1245sputc(int c, struct putc_info * pi)
1246{
1247 if (pi->last_str)
1248 if (pi->str == pi->last_str) {
1249 *(pi->str) = '\0';
1250 return;
1251 }
1252 *(pi->str)++ = c;
1253}
1254
1255int gprintf( window_t * window, const char * fmt, ...)
1256{
1257char *formattedtext;
1258
1259va_list ap;
1260
1261struct putc_info pi;
1262
1263if ((formattedtext = malloc(1024)) != NULL) {
1264// format the text
1265va_start(ap, fmt);
1266pi.str = formattedtext;
1267pi.last_str = 0;
1268prf(fmt, ap, sputc, &pi);
1269*pi.str = '\0';
1270va_end(ap);
1271
1272position_torigin, cursor, bounds;
1273
1274int i;
1275int character;
1276
1277origin.x = MAX( window->cursor.x, window->hborder );
1278origin.y = MAX( window->cursor.y, window->vborder );
1279
1280bounds.x = ( window->width - window->hborder );
1281bounds.y = ( window->height - window->vborder );
1282
1283cursor = origin;
1284
1285font_t *font = &font_console;
1286
1287for( i=0; i< strlen(formattedtext); i++ )
1288{
1289character = formattedtext[i];
1290
1291character -= 32;
1292
1293// newline ?
1294if( formattedtext[i] == '\n' )
1295{
1296cursor.x = window->hborder;
1297cursor.y += font->height;
1298
1299if ( cursor.y > bounds.y )
1300cursor.y = origin.y;
1301
1302continue;
1303}
1304
1305// tab ?
1306if( formattedtext[i] == '\t' )
1307cursor.x += ( font->chars[0]->width * 5 );
1308
1309// draw the character
1310if( font->chars[character])
1311blend(font->chars[character], window->pixmap, cursor);
1312
1313cursor.x += font->chars[character]->width;
1314
1315// check x pos and do newline
1316if ( cursor.x > bounds.x )
1317{
1318cursor.x = origin.x;
1319cursor.y += font->height;
1320}
1321
1322// check y pos and reset to origin.y
1323if ( cursor.y > bounds.y )
1324cursor.y = origin.y;
1325}
1326
1327// update cursor postition
1328window->cursor = cursor;
1329
1330free(formattedtext);
1331
1332return 0;
1333
1334}
1335return 1;
1336}
1337
1338int dprintf( window_t * window, const char * fmt, ...)
1339{
1340char *formattedtext;
1341
1342va_list ap;
1343
1344//window = &gui.debug;
1345
1346struct putc_info pi;
1347
1348if ((formattedtext = malloc(1024)) != NULL) {
1349// format the text
1350va_start(ap, fmt);
1351pi.str = formattedtext;
1352pi.last_str = 0;
1353prf(fmt, ap, sputc, &pi);
1354*pi.str = '\0';
1355va_end(ap);
1356
1357position_torigin, cursor, bounds;
1358
1359int i;
1360int character;
1361
1362origin.x = MAX( gui.debug.cursor.x, window->hborder );
1363origin.y = MAX( gui.debug.cursor.y, window->vborder );
1364
1365bounds.x = ( window->width - window->hborder );
1366bounds.y = ( window->height - window->vborder );
1367
1368cursor = origin;
1369
1370font_t *font = &font_console;
1371
1372for( i=0; i< strlen(formattedtext); i++ )
1373{
1374character = formattedtext[i];
1375
1376character -= 32;
1377
1378// newline ?
1379if( formattedtext[i] == '\n' )
1380{
1381cursor.x = window->hborder;
1382cursor.y += font->height;
1383
1384if ( cursor.y > bounds.y )
1385cursor.y = origin.y;
1386
1387continue;
1388}
1389
1390// tab ?
1391if( formattedtext[i] == '\t' )
1392cursor.x += ( font->chars[0]->width * 5 );
1393
1394// draw the character
1395if( font->chars[character])
1396blend(font->chars[character], gui.backbuffer, cursor);
1397
1398cursor.x += font->chars[character]->width;
1399
1400// check x pos and do newline
1401if ( cursor.x > bounds.x )
1402{
1403cursor.x = origin.x;
1404cursor.y += font->height;
1405}
1406
1407// check y pos and reset to origin.y
1408if ( cursor.y > bounds.y )
1409cursor.y = origin.y;
1410}
1411
1412// update cursor postition
1413gui.debug.cursor = cursor;
1414
1415free(formattedtext);
1416
1417return 0;
1418
1419}
1420return 1;
1421}
1422
1423int vprf(const char * fmt, va_list ap)
1424{
1425int i;
1426int character;
1427
1428char *formattedtext;
1429window_t *window = &gui.screen;
1430struct putc_info pi;
1431
1432position_torigin, cursor, bounds;
1433font_t *font = &font_console;
1434
1435if ((formattedtext = malloc(1024)) != NULL) {
1436// format the text
1437pi.str = formattedtext;
1438pi.last_str = 0;
1439prf(fmt, ap, sputc, &pi);
1440*pi.str = '\0';
1441
1442origin.x = MAX( window->cursor.x, window->hborder );
1443origin.y = MAX( window->cursor.y, window->vborder );
1444bounds.x = ( window->width - ( window->hborder * 2 ) );
1445bounds.y = ( window->height - ( window->vborder * 2 ) );
1446cursor = origin;
1447
1448for( i=0; i< strlen(formattedtext); i++ )
1449{
1450character = formattedtext[i];
1451character -= 32;
1452
1453// newline ?
1454if( formattedtext[i] == '\n' )
1455{
1456cursor.x = window->hborder;
1457cursor.y += font->height;
1458if ( cursor.y > bounds.y )
1459{
1460gui.redraw = true;
1461updateVRAM();
1462cursor.y = window->vborder;
1463}
1464window->cursor.y = cursor.y;
1465continue;
1466}
1467
1468// tab ?
1469if( formattedtext[i] == '\t' )
1470{
1471cursor.x = ( cursor.x / ( font->chars[0]->width * 8 ) + 1 ) * ( font->chars[0]->width * 8 );
1472continue;
1473}
1474cursor.x += font->chars[character]->width;
1475
1476// check x pos and do newline
1477if ( cursor.x > bounds.x )
1478{
1479cursor.x = origin.x;
1480cursor.y += font->height;
1481}
1482
1483// check y pos and reset to origin.y
1484if ( cursor.y > ( bounds.y + font->chars[0]->height) )
1485{
1486gui.redraw = true;
1487updateVRAM();
1488cursor.y = window->vborder;
1489}
1490// draw the character
1491if( font->chars[character])
1492blend(font->chars[character], gui.backbuffer, cursor);
1493}
1494// save cursor postition
1495window->cursor.x = cursor.x;
1496updateVRAM();
1497free(formattedtext);
1498return 0;
1499}
1500return 1;
1501}
1502
1503void drawStr(char *ch, font_t *font, pixmap_t *blendInto, position_t p)
1504{
1505int i=0;
1506int y=0; // we need this to support multilines '\n'
1507int x=0;
1508
1509for(i=0;i<strlen(ch);i++)
1510{
1511int cha=(int)ch[i];
1512
1513cha-=32;
1514
1515// newline ?
1516if( ch[i] == '\n' )
1517{
1518x = 0;
1519y += font->height;
1520continue;
1521}
1522
1523// tab ?
1524if( ch[i] == '\t' )
1525x+=(font->chars[0]->width*5);
1526
1527if(font->chars[cha])
1528blend(font->chars[cha], blendInto, pos(p.x+x, p.y+y));
1529
1530x += font->chars[cha]->width;
1531}
1532}
1533
1534void drawStrCenteredAt(char *text, font_t *font, pixmap_t *blendInto, position_t p)
1535{
1536int i = 0;
1537int width = 0;
1538
1539// calculate the width in pixels
1540for(i=0;i<strlen(text);i++)
1541width += font->chars[text[i]-32]->width;
1542
1543p.x = ( p.x - ( width / 2 ) );
1544p.y = ( p.y - ( font->height / 2 ) );
1545
1546if ( p.x == -6 )
1547{
1548p.x = 0;
1549}
1550
1551for(i=0;i<strlen(text);i++)
1552{
1553int cha=(int)text[i];
1554
1555cha-=32;
1556
1557if(font->chars[cha])
1558{
1559blend(font->chars[cha], blendInto, p);
1560p.x += font->chars[cha]->width;
1561}
1562}
1563
1564}
1565
1566int initFont(font_t *font, image_t *data)
1567{
1568unsigned int x = 0, y = 0, x2 = 0, x3 = 0;
1569
1570int start = 0, end = 0, count = 0, space = 0;
1571
1572bool monospaced = false;
1573
1574font->height = data->image->height;
1575
1576for( x = 0; x < data->image->width; x++)
1577{
1578start = end;
1579
1580// if the pixel is red we've reached the end of the char
1581if( pixel( data->image, x, 0 ).value == 0xFFFF0000)
1582{
1583end = x + 1;
1584
1585if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) )
1586{
1587font->chars[count]->width = ( end - start) - 1;
1588font->chars[count]->height = font->height;
1589
1590if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) )
1591{
1592space += ( font->chars[count]->width * data->image->height * 4 );
1593// we skip the first line because there are just the red pixels for the char width
1594for( y = 1; y< (font->height); y++)
1595{
1596for( x2 = (unsigned)start, x3 = 0; x2 < (unsigned)end; x2++, x3++)
1597{
1598pixel( font->chars[count], x3, y ) = pixel( data->image, x2, y );
1599}
1600}
1601
1602// check if font is monospaced
1603if( ( count > 0 ) && ( font->width != font->chars[count]->width ) )
1604monospaced = true;
1605
1606font->width = font->chars[count]->width;
1607
1608count++;
1609}
1610}
1611}
1612}
1613
1614if(monospaced)
1615font->width = 0;
1616
1617return 0;
1618}
1619
1620void colorFont(font_t *font, uint32_t color)
1621{
1622if( !color )
1623return;
1624
1625int x, y, width, height;
1626int count = 0;
1627pixel_t *buff;
1628
1629while( font->chars[count++] )
1630{
1631width = font->chars[count-1]->width;
1632height = font->chars[count-1]->height;
1633for( y = 0; y < height; y++ )
1634{
1635for( x = 0; x < width; x++ )
1636{
1637buff = &(pixel( font->chars[count-1], x, y ));
1638if( buff->ch.a )
1639{
1640buff->ch.r = (color & 0xFFFF0000) >> 16;
1641buff->ch.g = (color & 0xFF00FF00) >> 8;
1642buff->ch.b = (color & 0xFF0000FF);
1643}
1644}
1645}
1646}
1647}
1648
1649void makeRoundedCorners(pixmap_t *p)
1650{
1651int x,y;
1652int width=p->width-1;
1653int height=p->height-1;
1654
1655// 10px rounded corner alpha values
1656uint8_t roundedCorner[10][10] =
1657{
1658{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0xC0, 0xFF},
1659{ 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF},
1660{ 0x00, 0x00, 0x00, 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1661{ 0x00, 0x00, 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1662{ 0x00, 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1663{ 0x00, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1664{ 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1665{ 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1666{ 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1667{ 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
1668};
1669
1670uint8_t alpha=0;
1671
1672for( y=0; y<10; y++)
1673{
1674for( x=0; x<10; x++)
1675{
1676// skip if the pixel should be visible
1677if(roundedCorner[y][x] != 0xFF)
1678{
1679alpha = ( roundedCorner[y][x] ? (uint8_t) (roundedCorner[y][x] * pixel(p, x, y).ch.a) / 255 : 0 );
1680// Upper left corner
1681pixel(p, x, y).ch.a = alpha;
1682
1683// upper right corner
1684pixel(p, width-x,y).ch.a = alpha;
1685
1686// lower left corner
1687pixel(p, x, height-y).ch.a = alpha;
1688
1689// lower right corner
1690pixel(p, width-x, height-y).ch.a = alpha;
1691}
1692}
1693}
1694}
1695
1696void showInfoBox(char *title, char *text)
1697{
1698int i, key, lines, visiblelines;
1699
1700int currentline=0;
1701int cnt=0;
1702int offset=0;
1703
1704if( !title || !text )
1705return;
1706
1707position_t pos_title = pos ( gui.infobox.vborder, gui.infobox.vborder );
1708
1709// calculate number of lines in the title
1710for ( i = 0, lines = 1; i<strlen(title); i++ )
1711if( title[i] == '\n')
1712lines++;
1713
1714// y position of text is lines in title * height of font
1715position_t pos_text = pos( pos_title.x , pos_title.y + ( font_console.height * lines ));
1716
1717// calculate number of lines in the text
1718for ( i=0, lines = 1; i<strlen(text); i++ )
1719if( text[i] == '\n')
1720lines++;
1721
1722// if text ends with \n strip off
1723if( text[i] == '\n' || text[i] == '\0')
1724lines--;
1725
1726visiblelines = ( ( gui.infobox.height - ( gui.infobox.vborder * 2 ) ) / font_console.height ) - 1;
1727
1728// lets display the text and allow scroll thru using up down / arrows
1729while(1)
1730{
1731// move to current line in text
1732for( offset = 0, i = 0; offset < strlen(text); offset++ )
1733{
1734if( currentline == i)
1735break;
1736if( text[offset] =='\n')
1737i++;
1738}
1739
1740// find last visible line in text and place \0
1741for( i = offset, cnt = 0; i < strlen(text); i++)
1742{
1743if(text[i]=='\n')
1744cnt++;
1745if ( cnt == visiblelines )
1746{
1747text[i]='\0';
1748break;
1749}
1750}
1751
1752fillPixmapWithColor( gui.infobox.pixmap, gui.infobox.bgcolor);
1753
1754makeRoundedCorners( gui.infobox.pixmap);
1755
1756// print the title if present
1757if( title )
1758drawStr(title, &font_console, gui.infobox.pixmap, pos_title);
1759
1760// print the text
1761drawStr( text + offset, &font_console, gui.infobox.pixmap, pos_text);
1762
1763// restore \n in text
1764if ( cnt == visiblelines )
1765text[i] = '\n';
1766
1767position_t pos_indicator = pos( gui.infobox.width - ( images[iTextScrollPrev].image->width - ( gui.infobox.vborder / 2) ), pos_text.y );
1768
1769// draw prev indicator
1770if(offset)
1771{
1772blend( images[iTextScrollPrev].image, gui.infobox.pixmap, centeredAt( images[iTextScrollPrev].image, pos_indicator ));
1773}
1774
1775// draw next indicator
1776if( lines > ( currentline + visiblelines ) )
1777{
1778pos_indicator.y = ( gui.infobox.height - ( ( images[iTextScrollNext].image->width + gui.infobox.vborder ) / 2 ) );
1779blend( images[iTextScrollNext].image, gui.infobox.pixmap, centeredAt( images[iTextScrollNext].image, pos_indicator ) );
1780}
1781
1782gui.bootprompt.draw = false;
1783gui.infobox.draw = true;
1784gui.redraw = true;
1785
1786updateVRAM();
1787
1788key = getc();
1789
1790if( key == kUpArrowkey )
1791if( currentline > 0 )
1792currentline--;
1793
1794if( key == kDownArrowkey )
1795if( lines > ( currentline + visiblelines ) )
1796currentline++;
1797
1798if( key == kEscapeKey || key == 'q' || key == 'Q')
1799{
1800gui.infobox.draw = false;
1801gui.redraw = true;
1802updateVRAM();
1803break;
1804}
1805}
1806}
1807
1808void animateProgressBar()
1809{
1810int y;
1811
1812if( time18() > (unsigned) lasttime)
1813{
1814lasttime = time18();
1815
1816pixmap_t *buffBar = images[iProgressBar].image;
1817
1818uint32_t buff = buffBar->pixels[0].value;
1819
1820memcpy( buffBar->pixels, buffBar->pixels + 1, ( (buffBar->width*buffBar->height) - 1 ) * 4 );
1821
1822for( y = buffBar->height - 1; y > 0; y--)
1823pixel(buffBar, buffBar->width - 1, y) = pixel(buffBar, buffBar->width - 1, y - 1);
1824
1825pixel(buffBar, buffBar->width-1, 0).value = buff;
1826}
1827}
1828
1829void drawProgressBar(pixmap_t *blendInto, uint16_t width, position_t p, uint8_t progress)
1830{
1831if(progress>100)
1832return;
1833
1834p.x = ( p.x - ( width / 2 ) );
1835
1836int todraw = (width * progress) / 100;
1837
1838pixmap_t *buff = images[iProgressBar].image;
1839pixmap_t *buffBG = images[iProgressBarBackground].image;
1840if(!buff || !buffBG)
1841return;
1842
1843pixmap_t progressbar;
1844progressbar.pixels=malloc(width * 4 * buff->height);
1845if(!progressbar.pixels)
1846return;
1847
1848progressbar.width = width;
1849progressbar.height = buff->height;
1850
1851int x=0,x2=0,y=0;
1852
1853for(y=0; y<buff->height; y++)
1854{
1855for(x=0; x<todraw; x++, x2++)
1856{
1857if(x2 == (buff->width-1)) x2=0;
1858pixel(&progressbar, x,y).value = pixel(buff, x2,y).value;
1859}
1860x2=0;
1861}
1862
1863for(y=0; y<buff->height; y++)
1864{
1865for(x=todraw, x2 = 0; x < width - 1; x++, x2++)
1866{
1867if(x2 == (buffBG->width -2 )) x2 = 0;
1868pixel(&progressbar, x,y).value = pixel(buffBG, x2,y).value;
1869}
1870if(progress < 100)
1871pixel(&progressbar, width - 1, y).value = pixel(buffBG, buffBG->width - 1, y).value;
1872if(progress == 0)
1873pixel(&progressbar, 0, y).value = pixel(buffBG, buffBG->width - 1, y).value;
1874x2=0;
1875}
1876
1877blend(&progressbar, blendInto, p);
1878animateProgressBar();
1879free(progressbar.pixels);
1880}
1881
1882void drawInfoMenuItems()
1883{
1884int i,n;
1885
1886position_t position;
1887
1888pixmap_t *selection = images[iMenuSelection].image;
1889
1890pixmap_t *pbuff;
1891
1892fillPixmapWithColor(gui.menu.pixmap, gui.menu.bgcolor);
1893
1894makeRoundedCorners(gui.menu.pixmap);
1895
1896uint8_t offset = infoMenuNativeBoot ? 0 : infoMenuItemsCount - 1;
1897
1898position = pos(0,0);
1899
1900for ( i = 0, n = iMenuBoot; i < infoMenuItemsCount; i++, n++)
1901{
1902if (i == infoMenuSelection)
1903{
1904blend(selection, gui.menu.pixmap, position);
1905}
1906
1907pbuff = images[n].image;
1908if (offset && i >= INFOMENU_NATIVEBOOT_START && i <= INFOMENU_NATIVEBOOT_END)
1909{
1910blend( images[n + (iMenuHelp - iMenuBoot)].image , gui.menu.pixmap,
1911 pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2)));
1912}
1913else
1914{
1915blend( pbuff, gui.menu.pixmap,
1916 pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2)));
1917}
1918
1919drawStr(infoMenuItems[i].text, &font_console, gui.menu.pixmap,
1920pos(position.x + (pbuff->width + gui.menu.hborder),
1921position.y + ((selection->height - font_console.height) / 2)));
1922position.y += images[iMenuSelection].image->height;
1923
1924}
1925
1926gui.redraw = true;
1927}
1928
1929int drawInfoMenu()
1930{
1931drawInfoMenuItems();
1932
1933gui.menu.draw = true;
1934
1935updateVRAM();
1936
1937return 1;
1938}
1939
1940int updateInfoMenu(int key)
1941{
1942switch (key)
1943{
1944
1945case kUpArrowkey:// up arrow
1946if (infoMenuSelection > 0)
1947{
1948if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_END + 1)
1949{
1950infoMenuSelection -= 4;
1951}
1952else
1953{
1954infoMenuSelection--;
1955}
1956drawInfoMenuItems();
1957updateVRAM();
1958
1959}
1960else
1961{
1962
1963gui.menu.draw = false;
1964gui.redraw = true;
1965
1966updateVRAM();
1967
1968return CLOSE_INFO_MENU;
1969}
1970break;
1971
1972case kDownArrowkey:// down arrow
1973if (infoMenuSelection < infoMenuItemsCount - 1)
1974{
1975if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_START - 1)
1976infoMenuSelection += 4;
1977else
1978infoMenuSelection++;
1979drawInfoMenuItems();
1980updateVRAM();
1981}
1982break;
1983
1984case kReturnKey:
1985key = 0;
1986if( infoMenuSelection == MENU_SHOW_MEMORY_INFO )
1987showInfoBox( "Memory Info. Press q to quit.\n", getMemoryInfoString());
1988
1989else if( infoMenuSelection == MENU_SHOW_VIDEO_INFO )
1990showInfoBox( getVBEInfoString(), getVBEModeInfoString() );
1991
1992else if( infoMenuSelection == MENU_SHOW_HELP )
1993showHelp();
1994
1995else
1996{
1997int buff = infoMenuSelection;
1998infoMenuSelection = 0;
1999return buff;
2000}
2001break;
2002default:
2003break;
2004}
2005return DO_NOT_BOOT;
2006}
2007
2008uint16_t bootImageWidth = 0;
2009uint16_t bootImageHeight = 0;
2010uint8_t *bootImageData = NULL;
2011static bool usePngImage = false;
2012
2013//==========================================================================
2014// loadBootGraphics
2015void loadBootGraphics(char *src)
2016{
2017if (bootImageData != NULL) {
2018return;
2019}
2020
2021char dirspec[256];
2022
2023if ((unsigned)(strlen(theme_name) + 34) > sizeof(dirspec)) {
2024usePngImage = false;
2025return;
2026}
2027sprintf(dirspec, "%s/%s/boot.png", src, theme_name);
2028if (strlen(theme_name) == 0 || loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) {
2029#ifdef EMBED_THEME
2030if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0)
2031#endif
2032usePngImage = false;
2033}
2034}
2035
2036//==========================================================================
2037// drawBootGraphics
2038void drawBootGraphics(void)
2039{
2040int pos;
2041int length;
2042const char *dummyVal;
2043int oldScreenWidth, oldScreenHeight;
2044uint16_t x, y;
2045bool legacy_logo = false;
2046getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig);
2047if (legacy_logo == false) {
2048usePngImage = true;
2049
2050if (bootImageData == NULL)
2051loadBootGraphics(dirsrc);
2052
2053}
2054
2055
2056if (execute_hook("getResolution_hook", &screen_params[0], &screen_params[1], &screen_params[2], NULL, NULL, NULL) != EFI_SUCCESS)
2057{
2058// parse screen size parameters
2059if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig) && pos > 0) {
2060screen_params[0] = pos;
2061} else {
2062screen_params[0] = DEFAULT_SCREEN_WIDTH;
2063}
2064if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0) {
2065screen_params[1] = pos;
2066} else {
2067screen_params[1] = DEFAULT_SCREEN_HEIGHT;
2068}
2069}
2070
2071 // Save current screen resolution.
2072oldScreenWidth = gui.screen.width;
2073oldScreenHeight = gui.screen.height;
2074
2075gui.screen.width = screen_params[0];
2076gui.screen.height = screen_params[1];
2077
2078// find best matching vesa mode for our requested width & height
2079getGraphicModeParams(screen_params);
2080
2081 // Set graphics mode if the booter was in text mode or the screen resolution has changed.
2082if (bootArgs->Video.v_display == VGA_TEXT_MODE
2083|| (screen_params[0] != (uint32_t)oldScreenWidth && screen_params[1] != (uint32_t)oldScreenHeight) )
2084{
2085#if UNUSED
2086setVideoMode(GRAPHICS_MODE, 0);
2087#else
2088setVideoMode(GRAPHICS_MODE);
2089#endif
2090}
2091
2092if (getValueForKey("-checkers", &dummyVal, &length, &bootInfo->bootConfig)) {
2093drawCheckerBoard();
2094} else {
2095// Fill the background to 75% grey (same as BootX).
2096drawColorRectangle(0, 0, screen_params[0], screen_params[1], 0x01);
2097}
2098if ((bootImageData) && (usePngImage)) {
2099x = (screen_params[0] - MIN(bootImageWidth, screen_params[0])) / 2;
2100y = (screen_params[1] - MIN(bootImageHeight, screen_params[1])) / 2;
2101
2102// Draw the image in the center of the display.
2103blendImage(x, y, bootImageWidth, bootImageHeight, bootImageData);
2104} else {
2105uint8_t *appleBootPict;
2106bootImageData = NULL;
2107bootImageWidth = kAppleBootWidth;
2108bootImageHeight = kAppleBootHeight;
2109
2110// Prepare the data for the default Apple boot image.
2111appleBootPict = (uint8_t *) decodeRLE(gAppleBootPictRLE, kAppleBootRLEBlocks, bootImageWidth * bootImageHeight);
2112if (appleBootPict) {
2113convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData);
2114if (bootImageData) {
2115x = (screen_params[0] - MIN(kAppleBootWidth, screen_params[0])) / 2;
2116y = (screen_params[1] - MIN(kAppleBootHeight, screen_params[1])) / 2;
2117drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData);
2118free(bootImageData);
2119}
2120free(appleBootPict);
2121}
2122}
2123}
2124
2125int GUI_initGraphicsMode ()
2126{
2127unsigned long params[4];
2128int count;
2129
2130params[3] = 0;
2131count = getNumberArrayFromProperty( kGraphicsModeKey, params, 4 );
2132
2133// Try to find a resolution if "Graphics Mode" setting is not available.
2134if ( count < 3 )
2135{
2136// Use the default resolution if we don't have an initialized GUI.
2137if (gui.screen.width == 0 || gui.screen.height == 0)
2138{
2139gui.screen.width = DEFAULT_SCREEN_WIDTH;
2140gui.screen.height = DEFAULT_SCREEN_HEIGHT;
2141}
2142
2143params[0] = gui.screen.width;
2144params[1] = gui.screen.height;
2145params[2] = 32;
2146}
2147
2148// Map from pixel format to bits per pixel.
2149
2150if ( params[2] == 256 ) params[2] = 8;
2151if ( params[2] == 555 ) params[2] = 16;
2152if ( params[2] == 888 ) params[2] = 32;
2153
2154#if UNUSED
2155return setVESAGraphicsMode( params[0], params[1], params[2], params[3] );
2156#else
2157return setVESAGraphicsMode( params[0], params[1], params[2] );
2158#endif
2159}
2160
2161
2162int GUI_countdown( const char * msg, int row, int timeout )
2163{
2164 unsigned long time;
2165 register int ch = 0;
2166 int col = strlen(msg) + 1;
2167
2168 flushKeyboardBuffer();
2169
2170if( bootArgs->Video.v_display == VGA_TEXT_MODE )
2171{
2172moveCursor( 0, row );
2173printf(msg);
2174
2175} else {
2176
2177position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) );
2178
2179char dummy[80];
2180getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );
2181drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, true );
2182drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos );
2183
2184// make this screen the new background
2185memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
2186
2187}
2188
2189int multi_buff = 18 * (timeout);
2190 int multi = ++multi_buff;
2191
2192 int lasttime=0;
2193
2194 for ( time = time18(), timeout++; timeout > 0; )
2195 {
2196if( time18() > (unsigned)lasttime)
2197{
2198multi--;
2199lasttime=time18();
2200}
2201
2202 if ((ch = readKeyboardStatus()))
2203 break;
2204
2205 // Count can be interrupted by holding down shift,
2206 // control or alt key
2207 if ( ( readKeyboardShiftFlags() & 0x0F ) != 0 )
2208{
2209 ch = 1;
2210 break;
2211 }
2212
2213 if ( time18() >= time )
2214 {
2215 time += 18;
2216 timeout--;
2217
2218if( bootArgs->Video.v_display == VGA_TEXT_MODE )
2219{
2220moveCursor( col, row );
2221printf("(%d) ", timeout);
2222}
2223 }
2224
2225if( bootArgs->Video.v_display == GRAPHICS_MODE )
2226{
2227drawProgressBar( gui.screen.pixmap, 100, gui.progressbar.pos , ( multi * 100 / multi_buff ) );
2228gui.redraw = true;
2229updateVRAM();
2230}
2231
2232 }
2233
2234 flushKeyboardBuffer();
2235
2236 return ch;
2237}
2238
2239

Archive Download this file

Revision: 1141