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 {
796return 1;
797}
798
799}
800}
801
802int len;
803bool theme_ran= false;
804getBoolForKey("RandomTheme", &theme_ran, &bootInfo->bootConfig);
805int ret = 1;
806
807if (theme_ran) {
808
809ret = randomTheme(dirsrc, &theme_name);
810
811}
812
813
814if (ret)
815{
816if (getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig ) == true)
817{
818ret = startGUI();
819
820}
821#ifdef EMBED_THEME
822if (ret) {
823theme_name = "";
824ret = startGUI();
825}
826#endif
827if (ret) {
828theme_name = THEME_NAME_DEFAULT;
829ret = startGUI();
830}
831}
832return ret;
833}
834
835int startGUI(void)
836{
837int val;
838char dirspec[256];
839
840
841if ((unsigned)(strlen(theme_name) + 34) > sizeof(dirspec)) {
842return 1;
843}
844
845sprintf(dirspec, "%s/%s/theme.plist", dirsrc ,theme_name);
846
847if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0) {
848
849#ifdef EMBED_THEME
850if (strlen(theme_name) == 0) {
851config_file_t *config;
852
853config = &bootInfo->themeConfig;
854if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0) {
855return 1;
856}
857}
858#else
859return 1;
860#endif
861 }
862
863if (execute_hook("getResolution_hook", &screen_params[0], &screen_params[1], &screen_params[2], NULL, NULL, NULL) != EFI_SUCCESS)
864{
865// parse display size parameters
866if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0) {
867screen_params[0] = val;
868}
869if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0) {
870screen_params[1] = val;
871}
872}
873
874
875// Initalizing GUI strucutre.
876bzero(&gui, sizeof(gui_t));
877
878// find best matching vesa mode for our requested width & height
879getGraphicModeParams(screen_params);
880
881// set our screen structure with the mode width & height
882gui.screen.width = screen_params[0];
883gui.screen.height = screen_params[1];
884
885// load graphics otherwise fail and return
886if (loadGraphics(dirsrc) == 0) {
887loadThemeValues(&bootInfo->themeConfig);
888colorFont(&font_small, gui.screen.font_small_color);
889colorFont(&font_console, gui.screen.font_console_color);
890
891// create the screen & window buffers
892if (createBackBuffer(&gui.screen) == 0)
893{
894if (createWindowBuffer(&gui.screen) == 0)
895{
896if (createWindowBuffer(&gui.devicelist) == 0)
897{
898if (createWindowBuffer(&gui.bootprompt) == 0)
899{
900if (createWindowBuffer(&gui.infobox) == 0)
901{
902if (createWindowBuffer(&gui.menu) == 0)
903{
904 gui.logo.draw = true;
905drawBackground();
906// lets copy the screen into the back buffer
907#if UNUSED
908setVideoMode( GRAPHICS_MODE, 0 );
909#else
910setVideoMode( GRAPHICS_MODE );
911#endif
912gui.initialised = true;
913return 0;
914}
915}
916}
917}
918}
919}
920}
921return 1;
922}
923
924void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected)
925{
926int devicetype;
927
928if( diskIsCDROM(device) )
929devicetype = iDeviceCDROM;// Use CDROM icon
930else
931{
932switch (device->part_type)
933{
934case kPartitionTypeHFS:
935#ifdef BOOT_HELPER_SUPPORT
936// Use HFS or HFSRAID icon depending on bvr flags.
937devicetype = (device->flags & kBVFlagBooter) ? iDeviceHFSRAID : iDeviceHFS;
938#else
939devicetype = iDeviceHFS;
940#endif
941break;
942
943case kPartitionTypeHPFS:
944devicetype = iDeviceNTFS;// Use HPFS / NTFS icon
945break;
946
947case kPartitionTypeFAT16:
948devicetype = iDeviceFAT16;// Use FAT16 icon
949break;
950
951case kPartitionTypeFAT32:
952devicetype = iDeviceFAT32;// Use FAT32 icon
953break;
954
955case kPartitionTypeEXT3:
956devicetype = iDeviceEXT3;// Use EXT2/3 icon
957break;
958
959case kPartitionTypeFreeBSD:
960devicetype = iDeviceFreeBSD;// Use FreeBSD icon
961break;
962
963case kPartitionTypeOpenBSD:
964devicetype = iDeviceOpenBSD;// Use OpenBSD icon
965break;
966
967default:
968devicetype = iDeviceGeneric;// Use Generic icon
969break;
970}
971}
972
973// Draw the selection image and use the next (device_*_o) image for the selected item.
974 if (isSelected)
975{
976blend(images[iSelection].image, buffer, centeredAt(images[iSelection].image, p));
977devicetype++; // selec override image
978}
979
980// draw icon
981blend( images[devicetype].image, buffer, centeredAt( images[devicetype].image, p ));
982
983p.y += (images[iSelection].image->height / 2) + font_console.chars[0]->height;
984
985// draw volume label
986drawStrCenteredAt( device->label, &font_small, buffer, p);
987
988}
989
990void drawDeviceList (int start, int end, int selection)
991{
992int i;
993position_t p, p_prev, p_next;
994
995//uint8_tmaxDevices = MIN( gui.maxdevices, menucount );
996
997fillPixmapWithColor( gui.devicelist.pixmap, gui.devicelist.bgcolor);
998
999makeRoundedCorners( gui.devicelist.pixmap);
1000
1001switch (gui.layout)
1002{
1003
1004case VerticalLayout:
1005p.x = (gui.devicelist.width /2);
1006p.y = ( ( images[iSelection].image->height / 2 ) + images[iDeviceScrollPrev].image->height + gui.devicelist.iconspacing );
1007
1008// place scroll indicators at top & bottom edges
1009p_prev = pos ( gui.devicelist.width / 2 , gui.devicelist.iconspacing );
1010p_next = pos ( p_prev.x, gui.devicelist.height - gui.devicelist.iconspacing );
1011
1012break;
1013
1014default:// use Horizontal layout as the default
1015
1016case HorizontalLayout:
1017p.x = (gui.devicelist.width - ( gui.devicelist.width / gui.maxdevices ) * gui.maxdevices ) / 2 + ( images[iSelection].image->width / 2) + images[iDeviceScrollPrev].image->width + gui.devicelist.iconspacing;
1018p.y = ((gui.devicelist.height - font_console.chars[0]->height ) - images[iSelection].image->height) / 2 + ( images[iSelection].image->height / 2 );
1019
1020// place scroll indicators at left & right edges
1021p_prev = pos ( images[iDeviceScrollPrev].image->width / 2 + gui.devicelist.iconspacing / 2, gui.devicelist.height / 2 );
1022p_next = pos ( gui.devicelist.width - ( images[iDeviceScrollNext].image->width / 2 + gui.devicelist.iconspacing / 2), gui.devicelist.height / 2 );
1023
1024break;
1025
1026}
1027
1028// draw visible device icons
1029for (i = 0; i < gui.maxdevices; i++)
1030{
1031BVRef param = menuItems[start + i].param;
1032
1033 bool isSelected = ((start + i) == selection) ? true : false;
1034if (isSelected)
1035{
1036 if (param->flags & kBVFlagNativeBoot)
1037 {
1038 infoMenuNativeBoot = true;
1039 }
1040 else
1041 {
1042 infoMenuNativeBoot = false;
1043 if(infoMenuSelection >= INFOMENU_NATIVEBOOT_START && infoMenuSelection <= INFOMENU_NATIVEBOOT_END)
1044infoMenuSelection = 0;
1045 }
1046
1047if(gui.menu.draw)
1048drawInfoMenuItems();
1049
1050#if DEBUG
1051 gui.debug.cursor = pos( 10, 100);
1052 dprintf( &gui.screen, "label %s\n", param->label );
1053 dprintf( &gui.screen, "biosdev 0x%x\n", param->biosdev );
1054 dprintf( &gui.screen, "width %d\n", gui.screen.width);
1055 dprintf( &gui.screen, "height %d\n", gui.screen.height);
1056 dprintf( &gui.screen, "type 0x%x\n", param->type );
1057 dprintf( &gui.screen, "flags 0x%x\n", param->flags );
1058 dprintf( &gui.screen, "part_no %d\n", param->part_no );
1059 dprintf( &gui.screen, "part_boff 0x%x\n", param->part_boff );
1060 dprintf( &gui.screen, "part_type 0x%x\n", param->part_type );
1061 dprintf( &gui.screen, "bps 0x%x\n", param->bps );
1062 dprintf( &gui.screen, "name %s\n", param->name );
1063 dprintf( &gui.screen, "type_name %s\n", param->type_name );
1064 dprintf( &gui.screen, "modtime %d\n", param->modTime );
1065#endif
1066}
1067
1068drawDeviceIcon( param, gui.devicelist.pixmap, p, isSelected);
1069
1070if (gui.layout == HorizontalLayout)
1071{
1072p.x += images[iSelection].image->width + gui.devicelist.iconspacing;
1073}
1074if (gui.layout == VerticalLayout)
1075{
1076p.y += ( images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing );
1077}
1078}
1079
1080// draw prev indicator
1081if(start)
1082blend( images[iDeviceScrollPrev].image, gui.devicelist.pixmap, centeredAt( images[iDeviceScrollPrev].image, p_prev ) );
1083
1084// draw next indicator
1085if( end < gDeviceCount - 1 )
1086blend( images[iDeviceScrollNext].image, gui.devicelist.pixmap, centeredAt( images[iDeviceScrollNext].image, p_next ) );
1087
1088gui.redraw = true;
1089
1090updateVRAM();
1091
1092}
1093
1094void clearGraphicBootPrompt()
1095{
1096// clear text buffer
1097prompt[0] = '\0';
1098prompt_pos=0;
1099
1100
1101if(gui.bootprompt.draw == true )
1102{
1103gui.bootprompt.draw = false;
1104gui.redraw = true;
1105// this causes extra frames to be drawn
1106//updateVRAM();
1107}
1108
1109return;
1110}
1111
1112void updateGraphicBootPrompt(int key)
1113{
1114if ( key == kBackspaceKey )
1115prompt[--prompt_pos] = '\0';
1116else
1117{
1118prompt[prompt_pos] = key;
1119prompt_pos++;
1120prompt[prompt_pos] = '\0';
1121}
1122
1123fillPixmapWithColor( gui.bootprompt.pixmap, gui.bootprompt.bgcolor);
1124
1125makeRoundedCorners( gui.bootprompt.pixmap);
1126
1127position_t p_text = pos( gui.bootprompt.hborder , ( ( gui.bootprompt.height - font_console.chars[0]->height) ) / 2 );
1128
1129// print the boot prompt text
1130drawStr(prompt_text, &font_console, gui.bootprompt.pixmap, p_text);
1131
1132// get the position of the end of the boot prompt text to display user input
1133position_t p_prompt = pos( p_text.x + ( ( strlen(prompt_text) ) * font_console.chars[0]->width ), p_text.y );
1134
1135// calculate the position of the cursor
1136intoffset = ( prompt_pos - ( ( gui.bootprompt.width / font_console.chars[0]->width ) - strlen(prompt_text) - 2 ) );
1137
1138if ( offset < 0)
1139offset = 0;
1140
1141drawStr( prompt+offset, &font_console, gui.bootprompt.pixmap, p_prompt);
1142
1143gui.menu.draw = false;
1144gui.bootprompt.draw = true;
1145gui.redraw = true;
1146
1147updateVRAM();
1148
1149return;
1150}
1151
1152#if UNUSED
1153inline
1154void vramwrite (void *data, int width, int height)
1155#else
1156inline
1157void vramwrite (void *data, int width)
1158#endif
1159{
1160if (VIDEO (depth) == 0x20 /*32*/ && VIDEO (rowBytes) == (unsigned long)gui.backbuffer->width * 4)
1161memcpy((uint8_t *)vram, gui.backbuffer->pixels, VIDEO (rowBytes)*VIDEO (height));
1162else
1163{
1164uint32_t r, g, b;
1165uint32_t i, j;
1166for (i = 0; i < VIDEO (height); i++)
1167for (j = 0; j < VIDEO (width); j++)
1168{
1169b = ((uint8_t *) data)[4*i*width + 4*j];
1170g = ((uint8_t *) data)[4*i*width + 4*j + 1];
1171r = ((uint8_t *) data)[4*i*width + 4*j + 2];
1172switch (VIDEO (depth))
1173{
1174case 32:
1175*(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*4) = (b&0xff) | ((g&0xff)<<8) | ((r&0xff)<<16);
1176break;
1177case 24:
1178*(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*3) = ((*(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*3))&0xff000000)
1179| (b&0xff) | ((g&0xff)<<8) | ((r&0xff)<<16);
1180break;
1181case 16:
1182// Somehow 16-bit is always 15-bits really
1183//*(uint16_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*2) = ((b&0xf8)>>3) | ((g&0xfc)<<3) | ((r&0xf8)<<8);
1184//break;
1185case 15:
1186*(uint16_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*2) = ((b&0xf8)>>3) | ((g&0xf8)<<2) | ((r&0xf8)<<7);
1187break;
1188default:
1189break;
1190}
1191}
1192}
1193}
1194
1195void updateVRAM()
1196{
1197if (gui.redraw)
1198{
1199if (gui.devicelist.draw)
1200blend( gui.devicelist.pixmap, gui.backbuffer, gui.devicelist.pos );
1201
1202if (gui.bootprompt.draw)
1203blend( gui.bootprompt.pixmap, gui.backbuffer, gui.bootprompt.pos );
1204
1205if (gui.menu.draw)
1206blend( gui.menu.pixmap, gui.backbuffer, gui.menu.pos );
1207
1208if (gui.infobox.draw)
1209blend( gui.infobox.pixmap, gui.backbuffer, gui.infobox.pos );
1210}
1211#if UNUSED
1212vramwrite ( gui.backbuffer->pixels, gui.backbuffer->width, gui.backbuffer->height );
1213#else
1214vramwrite ( gui.backbuffer->pixels, gui.backbuffer->width );
1215#endif
1216if (gui.redraw)
1217{
1218memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
1219gui.redraw = false;
1220}
1221}
1222
1223struct putc_info {
1224 char * str;
1225 char * last_str;
1226};
1227
1228static void
1229sputc(int c, struct putc_info * pi)
1230{
1231 if (pi->last_str)
1232 if (pi->str == pi->last_str) {
1233 *(pi->str) = '\0';
1234 return;
1235 }
1236 *(pi->str)++ = c;
1237}
1238
1239int gprintf( window_t * window, const char * fmt, ...)
1240{
1241char *formattedtext;
1242
1243va_list ap;
1244
1245struct putc_info pi;
1246
1247if ((formattedtext = malloc(1024)) != NULL) {
1248// format the text
1249va_start(ap, fmt);
1250pi.str = formattedtext;
1251pi.last_str = 0;
1252prf(fmt, ap, sputc, &pi);
1253*pi.str = '\0';
1254va_end(ap);
1255
1256position_torigin, cursor, bounds;
1257
1258int i;
1259int character;
1260
1261origin.x = MAX( window->cursor.x, window->hborder );
1262origin.y = MAX( window->cursor.y, window->vborder );
1263
1264bounds.x = ( window->width - window->hborder );
1265bounds.y = ( window->height - window->vborder );
1266
1267cursor = origin;
1268
1269font_t *font = &font_console;
1270
1271for( i=0; i< strlen(formattedtext); i++ )
1272{
1273character = formattedtext[i];
1274
1275character -= 32;
1276
1277// newline ?
1278if( formattedtext[i] == '\n' )
1279{
1280cursor.x = window->hborder;
1281cursor.y += font->height;
1282
1283if ( cursor.y > bounds.y )
1284cursor.y = origin.y;
1285
1286continue;
1287}
1288
1289// tab ?
1290if( formattedtext[i] == '\t' )
1291cursor.x += ( font->chars[0]->width * 5 );
1292
1293// draw the character
1294if( font->chars[character])
1295blend(font->chars[character], window->pixmap, cursor);
1296
1297cursor.x += font->chars[character]->width;
1298
1299// check x pos and do newline
1300if ( cursor.x > bounds.x )
1301{
1302cursor.x = origin.x;
1303cursor.y += font->height;
1304}
1305
1306// check y pos and reset to origin.y
1307if ( cursor.y > bounds.y )
1308cursor.y = origin.y;
1309}
1310
1311// update cursor postition
1312window->cursor = cursor;
1313
1314free(formattedtext);
1315
1316return 0;
1317
1318}
1319return 1;
1320}
1321
1322int dprintf( window_t * window, const char * fmt, ...)
1323{
1324char *formattedtext;
1325
1326va_list ap;
1327
1328//window = &gui.debug;
1329
1330struct putc_info pi;
1331
1332if ((formattedtext = malloc(1024)) != NULL) {
1333// format the text
1334va_start(ap, fmt);
1335pi.str = formattedtext;
1336pi.last_str = 0;
1337prf(fmt, ap, sputc, &pi);
1338*pi.str = '\0';
1339va_end(ap);
1340
1341position_torigin, cursor, bounds;
1342
1343int i;
1344int character;
1345
1346origin.x = MAX( gui.debug.cursor.x, window->hborder );
1347origin.y = MAX( gui.debug.cursor.y, window->vborder );
1348
1349bounds.x = ( window->width - window->hborder );
1350bounds.y = ( window->height - window->vborder );
1351
1352cursor = origin;
1353
1354font_t *font = &font_console;
1355
1356for( i=0; i< strlen(formattedtext); i++ )
1357{
1358character = formattedtext[i];
1359
1360character -= 32;
1361
1362// newline ?
1363if( formattedtext[i] == '\n' )
1364{
1365cursor.x = window->hborder;
1366cursor.y += font->height;
1367
1368if ( cursor.y > bounds.y )
1369cursor.y = origin.y;
1370
1371continue;
1372}
1373
1374// tab ?
1375if( formattedtext[i] == '\t' )
1376cursor.x += ( font->chars[0]->width * 5 );
1377
1378// draw the character
1379if( font->chars[character])
1380blend(font->chars[character], gui.backbuffer, cursor);
1381
1382cursor.x += font->chars[character]->width;
1383
1384// check x pos and do newline
1385if ( cursor.x > bounds.x )
1386{
1387cursor.x = origin.x;
1388cursor.y += font->height;
1389}
1390
1391// check y pos and reset to origin.y
1392if ( cursor.y > bounds.y )
1393cursor.y = origin.y;
1394}
1395
1396// update cursor postition
1397gui.debug.cursor = cursor;
1398
1399free(formattedtext);
1400
1401return 0;
1402
1403}
1404return 1;
1405}
1406
1407int vprf(const char * fmt, va_list ap)
1408{
1409int i;
1410int character;
1411
1412char *formattedtext;
1413window_t *window = &gui.screen;
1414struct putc_info pi;
1415
1416position_torigin, cursor, bounds;
1417font_t *font = &font_console;
1418
1419if ((formattedtext = malloc(1024)) != NULL) {
1420// format the text
1421pi.str = formattedtext;
1422pi.last_str = 0;
1423prf(fmt, ap, sputc, &pi);
1424*pi.str = '\0';
1425
1426origin.x = MAX( window->cursor.x, window->hborder );
1427origin.y = MAX( window->cursor.y, window->vborder );
1428bounds.x = ( window->width - ( window->hborder * 2 ) );
1429bounds.y = ( window->height - ( window->vborder * 2 ) );
1430cursor = origin;
1431
1432for( i=0; i< strlen(formattedtext); i++ )
1433{
1434character = formattedtext[i];
1435character -= 32;
1436
1437// newline ?
1438if( formattedtext[i] == '\n' )
1439{
1440cursor.x = window->hborder;
1441cursor.y += font->height;
1442if ( cursor.y > bounds.y )
1443{
1444gui.redraw = true;
1445updateVRAM();
1446cursor.y = window->vborder;
1447}
1448window->cursor.y = cursor.y;
1449continue;
1450}
1451
1452// tab ?
1453if( formattedtext[i] == '\t' )
1454{
1455cursor.x = ( cursor.x / ( font->chars[0]->width * 8 ) + 1 ) * ( font->chars[0]->width * 8 );
1456continue;
1457}
1458cursor.x += font->chars[character]->width;
1459
1460// check x pos and do newline
1461if ( cursor.x > bounds.x )
1462{
1463cursor.x = origin.x;
1464cursor.y += font->height;
1465}
1466
1467// check y pos and reset to origin.y
1468if ( cursor.y > ( bounds.y + font->chars[0]->height) )
1469{
1470gui.redraw = true;
1471updateVRAM();
1472cursor.y = window->vborder;
1473}
1474// draw the character
1475if( font->chars[character])
1476blend(font->chars[character], gui.backbuffer, cursor);
1477}
1478// save cursor postition
1479window->cursor.x = cursor.x;
1480updateVRAM();
1481free(formattedtext);
1482return 0;
1483}
1484return 1;
1485}
1486
1487void drawStr(char *ch, font_t *font, pixmap_t *blendInto, position_t p)
1488{
1489int i=0;
1490int y=0; // we need this to support multilines '\n'
1491int x=0;
1492
1493for(i=0;i<strlen(ch);i++)
1494{
1495int cha=(int)ch[i];
1496
1497cha-=32;
1498
1499// newline ?
1500if( ch[i] == '\n' )
1501{
1502x = 0;
1503y += font->height;
1504continue;
1505}
1506
1507// tab ?
1508if( ch[i] == '\t' )
1509x+=(font->chars[0]->width*5);
1510
1511if(font->chars[cha])
1512blend(font->chars[cha], blendInto, pos(p.x+x, p.y+y));
1513
1514x += font->chars[cha]->width;
1515}
1516}
1517
1518void drawStrCenteredAt(char *text, font_t *font, pixmap_t *blendInto, position_t p)
1519{
1520int i = 0;
1521int width = 0;
1522
1523// calculate the width in pixels
1524for(i=0;i<strlen(text);i++)
1525width += font->chars[text[i]-32]->width;
1526
1527p.x = ( p.x - ( width / 2 ) );
1528p.y = ( p.y - ( font->height / 2 ) );
1529
1530if ( p.x == -6 )
1531{
1532p.x = 0;
1533}
1534
1535for(i=0;i<strlen(text);i++)
1536{
1537int cha=(int)text[i];
1538
1539cha-=32;
1540
1541if(font->chars[cha])
1542{
1543blend(font->chars[cha], blendInto, p);
1544p.x += font->chars[cha]->width;
1545}
1546}
1547
1548}
1549
1550int initFont(font_t *font, image_t *data)
1551{
1552unsigned int x = 0, y = 0, x2 = 0, x3 = 0;
1553
1554int start = 0, end = 0, count = 0, space = 0;
1555
1556bool monospaced = false;
1557
1558font->height = data->image->height;
1559
1560for( x = 0; x < data->image->width; x++)
1561{
1562start = end;
1563
1564// if the pixel is red we've reached the end of the char
1565if( pixel( data->image, x, 0 ).value == 0xFFFF0000)
1566{
1567end = x + 1;
1568
1569if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) )
1570{
1571font->chars[count]->width = ( end - start) - 1;
1572font->chars[count]->height = font->height;
1573
1574if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) )
1575{
1576space += ( font->chars[count]->width * data->image->height * 4 );
1577// we skip the first line because there are just the red pixels for the char width
1578for( y = 1; y< (font->height); y++)
1579{
1580for( x2 = (unsigned)start, x3 = 0; x2 < (unsigned)end; x2++, x3++)
1581{
1582pixel( font->chars[count], x3, y ) = pixel( data->image, x2, y );
1583}
1584}
1585
1586// check if font is monospaced
1587if( ( count > 0 ) && ( font->width != font->chars[count]->width ) )
1588monospaced = true;
1589
1590font->width = font->chars[count]->width;
1591
1592count++;
1593}
1594}
1595}
1596}
1597
1598if(monospaced)
1599font->width = 0;
1600
1601return 0;
1602}
1603
1604void colorFont(font_t *font, uint32_t color)
1605{
1606if( !color )
1607return;
1608
1609int x, y, width, height;
1610int count = 0;
1611pixel_t *buff;
1612
1613while( font->chars[count++] )
1614{
1615width = font->chars[count-1]->width;
1616height = font->chars[count-1]->height;
1617for( y = 0; y < height; y++ )
1618{
1619for( x = 0; x < width; x++ )
1620{
1621buff = &(pixel( font->chars[count-1], x, y ));
1622if( buff->ch.a )
1623{
1624buff->ch.r = (color & 0xFFFF0000) >> 16;
1625buff->ch.g = (color & 0xFF00FF00) >> 8;
1626buff->ch.b = (color & 0xFF0000FF);
1627}
1628}
1629}
1630}
1631}
1632
1633void makeRoundedCorners(pixmap_t *p)
1634{
1635int x,y;
1636int width=p->width-1;
1637int height=p->height-1;
1638
1639// 10px rounded corner alpha values
1640uint8_t roundedCorner[10][10] =
1641{
1642{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0xC0, 0xFF},
1643{ 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF},
1644{ 0x00, 0x00, 0x00, 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1645{ 0x00, 0x00, 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1646{ 0x00, 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1647{ 0x00, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1648{ 0x40, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1649{ 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1650{ 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
1651{ 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
1652};
1653
1654uint8_t alpha=0;
1655
1656for( y=0; y<10; y++)
1657{
1658for( x=0; x<10; x++)
1659{
1660// skip if the pixel should be visible
1661if(roundedCorner[y][x] != 0xFF)
1662{
1663alpha = ( roundedCorner[y][x] ? (uint8_t) (roundedCorner[y][x] * pixel(p, x, y).ch.a) / 255 : 0 );
1664// Upper left corner
1665pixel(p, x, y).ch.a = alpha;
1666
1667// upper right corner
1668pixel(p, width-x,y).ch.a = alpha;
1669
1670// lower left corner
1671pixel(p, x, height-y).ch.a = alpha;
1672
1673// lower right corner
1674pixel(p, width-x, height-y).ch.a = alpha;
1675}
1676}
1677}
1678}
1679
1680void showInfoBox(char *title, char *text)
1681{
1682int i, key, lines, visiblelines;
1683
1684int currentline=0;
1685int cnt=0;
1686int offset=0;
1687
1688if( !title || !text )
1689return;
1690
1691position_t pos_title = pos ( gui.infobox.vborder, gui.infobox.vborder );
1692
1693// calculate number of lines in the title
1694for ( i = 0, lines = 1; i<strlen(title); i++ )
1695if( title[i] == '\n')
1696lines++;
1697
1698// y position of text is lines in title * height of font
1699position_t pos_text = pos( pos_title.x , pos_title.y + ( font_console.height * lines ));
1700
1701// calculate number of lines in the text
1702for ( i=0, lines = 1; i<strlen(text); i++ )
1703if( text[i] == '\n')
1704lines++;
1705
1706// if text ends with \n strip off
1707if( text[i] == '\n' || text[i] == '\0')
1708lines--;
1709
1710visiblelines = ( ( gui.infobox.height - ( gui.infobox.vborder * 2 ) ) / font_console.height ) - 1;
1711
1712// lets display the text and allow scroll thru using up down / arrows
1713while(1)
1714{
1715// move to current line in text
1716for( offset = 0, i = 0; offset < strlen(text); offset++ )
1717{
1718if( currentline == i)
1719break;
1720if( text[offset] =='\n')
1721i++;
1722}
1723
1724// find last visible line in text and place \0
1725for( i = offset, cnt = 0; i < strlen(text); i++)
1726{
1727if(text[i]=='\n')
1728cnt++;
1729if ( cnt == visiblelines )
1730{
1731text[i]='\0';
1732break;
1733}
1734}
1735
1736fillPixmapWithColor( gui.infobox.pixmap, gui.infobox.bgcolor);
1737
1738makeRoundedCorners( gui.infobox.pixmap);
1739
1740// print the title if present
1741if( title )
1742drawStr(title, &font_console, gui.infobox.pixmap, pos_title);
1743
1744// print the text
1745drawStr( text + offset, &font_console, gui.infobox.pixmap, pos_text);
1746
1747// restore \n in text
1748if ( cnt == visiblelines )
1749text[i] = '\n';
1750
1751position_t pos_indicator = pos( gui.infobox.width - ( images[iTextScrollPrev].image->width - ( gui.infobox.vborder / 2) ), pos_text.y );
1752
1753// draw prev indicator
1754if(offset)
1755{
1756blend( images[iTextScrollPrev].image, gui.infobox.pixmap, centeredAt( images[iTextScrollPrev].image, pos_indicator ));
1757}
1758
1759// draw next indicator
1760if( lines > ( currentline + visiblelines ) )
1761{
1762pos_indicator.y = ( gui.infobox.height - ( ( images[iTextScrollNext].image->width + gui.infobox.vborder ) / 2 ) );
1763blend( images[iTextScrollNext].image, gui.infobox.pixmap, centeredAt( images[iTextScrollNext].image, pos_indicator ) );
1764}
1765
1766gui.bootprompt.draw = false;
1767gui.infobox.draw = true;
1768gui.redraw = true;
1769
1770updateVRAM();
1771
1772key = getc();
1773
1774if( key == kUpArrowkey )
1775if( currentline > 0 )
1776currentline--;
1777
1778if( key == kDownArrowkey )
1779if( lines > ( currentline + visiblelines ) )
1780currentline++;
1781
1782if( key == kEscapeKey || key == 'q' || key == 'Q')
1783{
1784gui.infobox.draw = false;
1785gui.redraw = true;
1786updateVRAM();
1787break;
1788}
1789}
1790}
1791
1792void animateProgressBar()
1793{
1794int y;
1795
1796if( time18() > (unsigned) lasttime)
1797{
1798lasttime = time18();
1799
1800pixmap_t *buffBar = images[iProgressBar].image;
1801
1802uint32_t buff = buffBar->pixels[0].value;
1803
1804memcpy( buffBar->pixels, buffBar->pixels + 1, ( (buffBar->width*buffBar->height) - 1 ) * 4 );
1805
1806for( y = buffBar->height - 1; y > 0; y--)
1807pixel(buffBar, buffBar->width - 1, y) = pixel(buffBar, buffBar->width - 1, y - 1);
1808
1809pixel(buffBar, buffBar->width-1, 0).value = buff;
1810}
1811}
1812
1813void drawProgressBar(pixmap_t *blendInto, uint16_t width, position_t p, uint8_t progress)
1814{
1815if(progress>100)
1816return;
1817
1818p.x = ( p.x - ( width / 2 ) );
1819
1820int todraw = (width * progress) / 100;
1821
1822pixmap_t *buff = images[iProgressBar].image;
1823pixmap_t *buffBG = images[iProgressBarBackground].image;
1824if(!buff || !buffBG)
1825return;
1826
1827pixmap_t progressbar;
1828progressbar.pixels=malloc(width * 4 * buff->height);
1829if(!progressbar.pixels)
1830return;
1831
1832progressbar.width = width;
1833progressbar.height = buff->height;
1834
1835int x=0,x2=0,y=0;
1836
1837for(y=0; y<buff->height; y++)
1838{
1839for(x=0; x<todraw; x++, x2++)
1840{
1841if(x2 == (buff->width-1)) x2=0;
1842pixel(&progressbar, x,y).value = pixel(buff, x2,y).value;
1843}
1844x2=0;
1845}
1846
1847for(y=0; y<buff->height; y++)
1848{
1849for(x=todraw, x2 = 0; x < width - 1; x++, x2++)
1850{
1851if(x2 == (buffBG->width -2 )) x2 = 0;
1852pixel(&progressbar, x,y).value = pixel(buffBG, x2,y).value;
1853}
1854if(progress < 100)
1855pixel(&progressbar, width - 1, y).value = pixel(buffBG, buffBG->width - 1, y).value;
1856if(progress == 0)
1857pixel(&progressbar, 0, y).value = pixel(buffBG, buffBG->width - 1, y).value;
1858x2=0;
1859}
1860
1861blend(&progressbar, blendInto, p);
1862animateProgressBar();
1863free(progressbar.pixels);
1864}
1865
1866void drawInfoMenuItems()
1867{
1868int i,n;
1869
1870position_t position;
1871
1872pixmap_t *selection = images[iMenuSelection].image;
1873
1874pixmap_t *pbuff;
1875
1876fillPixmapWithColor(gui.menu.pixmap, gui.menu.bgcolor);
1877
1878makeRoundedCorners(gui.menu.pixmap);
1879
1880uint8_t offset = infoMenuNativeBoot ? 0 : infoMenuItemsCount - 1;
1881
1882position = pos(0,0);
1883
1884for ( i = 0, n = iMenuBoot; i < infoMenuItemsCount; i++, n++)
1885{
1886if (i == infoMenuSelection)
1887{
1888blend(selection, gui.menu.pixmap, position);
1889}
1890
1891pbuff = images[n].image;
1892if (offset && i >= INFOMENU_NATIVEBOOT_START && i <= INFOMENU_NATIVEBOOT_END)
1893{
1894blend( images[n + (iMenuHelp - iMenuBoot)].image , gui.menu.pixmap,
1895 pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2)));
1896}
1897else
1898{
1899blend( pbuff, gui.menu.pixmap,
1900 pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2)));
1901}
1902
1903drawStr(infoMenuItems[i].text, &font_console, gui.menu.pixmap,
1904pos(position.x + (pbuff->width + gui.menu.hborder),
1905position.y + ((selection->height - font_console.height) / 2)));
1906position.y += images[iMenuSelection].image->height;
1907
1908}
1909
1910gui.redraw = true;
1911}
1912
1913int drawInfoMenu()
1914{
1915drawInfoMenuItems();
1916
1917gui.menu.draw = true;
1918
1919updateVRAM();
1920
1921return 1;
1922}
1923
1924int updateInfoMenu(int key)
1925{
1926switch (key)
1927{
1928
1929case kUpArrowkey:// up arrow
1930if (infoMenuSelection > 0)
1931{
1932if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_END + 1)
1933{
1934infoMenuSelection -= 4;
1935}
1936else
1937{
1938infoMenuSelection--;
1939}
1940drawInfoMenuItems();
1941updateVRAM();
1942
1943}
1944else
1945{
1946
1947gui.menu.draw = false;
1948gui.redraw = true;
1949
1950updateVRAM();
1951
1952return CLOSE_INFO_MENU;
1953}
1954break;
1955
1956case kDownArrowkey:// down arrow
1957if (infoMenuSelection < infoMenuItemsCount - 1)
1958{
1959if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_START - 1)
1960infoMenuSelection += 4;
1961else
1962infoMenuSelection++;
1963drawInfoMenuItems();
1964updateVRAM();
1965}
1966break;
1967
1968case kReturnKey:
1969key = 0;
1970if( infoMenuSelection == MENU_SHOW_MEMORY_INFO )
1971showInfoBox( "Memory Info. Press q to quit.\n", getMemoryInfoString());
1972
1973else if( infoMenuSelection == MENU_SHOW_VIDEO_INFO )
1974showInfoBox( getVBEInfoString(), getVBEModeInfoString() );
1975
1976else if( infoMenuSelection == MENU_SHOW_HELP )
1977showHelp();
1978
1979else
1980{
1981int buff = infoMenuSelection;
1982infoMenuSelection = 0;
1983return buff;
1984}
1985break;
1986default:
1987break;
1988}
1989return DO_NOT_BOOT;
1990}
1991
1992uint16_t bootImageWidth = 0;
1993uint16_t bootImageHeight = 0;
1994uint8_t *bootImageData = NULL;
1995static bool usePngImage = false;
1996
1997//==========================================================================
1998// loadBootGraphics
1999void loadBootGraphics(char *src)
2000{
2001if (bootImageData != NULL) {
2002return;
2003}
2004
2005char dirspec[256];
2006
2007if ((unsigned)(strlen(theme_name) + 34) > sizeof(dirspec)) {
2008usePngImage = false;
2009return;
2010}
2011sprintf(dirspec, "%s/%s/boot.png", src, theme_name);
2012if (strlen(theme_name) == 0 || loadPngImage(dirspec, &bootImageWidth, &bootImageHeight, &bootImageData) != 0) {
2013#ifdef EMBED_THEME
2014if ((loadEmbeddedPngImage(__boot_png, __boot_png_len, &bootImageWidth, &bootImageHeight, &bootImageData)) != 0)
2015#endif
2016usePngImage = false;
2017}
2018}
2019
2020//==========================================================================
2021// drawBootGraphics
2022void drawBootGraphics(void)
2023{
2024int pos;
2025int length;
2026const char *dummyVal;
2027int oldScreenWidth, oldScreenHeight;
2028uint16_t x, y;
2029bool legacy_logo = false;
2030getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig);
2031if (legacy_logo == false) {
2032usePngImage = true;
2033
2034if (bootImageData == NULL)
2035loadBootGraphics(dirsrc);
2036
2037}
2038
2039
2040if (execute_hook("getResolution_hook", &screen_params[0], &screen_params[1], &screen_params[2], NULL, NULL, NULL) != EFI_SUCCESS)
2041{
2042// parse screen size parameters
2043if (getIntForKey("boot_width", &pos, &bootInfo->themeConfig) && pos > 0) {
2044screen_params[0] = pos;
2045} else {
2046screen_params[0] = DEFAULT_SCREEN_WIDTH;
2047}
2048if (getIntForKey("boot_height", &pos, &bootInfo->themeConfig) && pos > 0) {
2049screen_params[1] = pos;
2050} else {
2051screen_params[1] = DEFAULT_SCREEN_HEIGHT;
2052}
2053}
2054
2055 // Save current screen resolution.
2056oldScreenWidth = gui.screen.width;
2057oldScreenHeight = gui.screen.height;
2058
2059gui.screen.width = screen_params[0];
2060gui.screen.height = screen_params[1];
2061
2062// find best matching vesa mode for our requested width & height
2063getGraphicModeParams(screen_params);
2064
2065 // Set graphics mode if the booter was in text mode or the screen resolution has changed.
2066if (bootArgs->Video.v_display == VGA_TEXT_MODE
2067|| (screen_params[0] != (uint32_t)oldScreenWidth && screen_params[1] != (uint32_t)oldScreenHeight) )
2068{
2069#if UNUSED
2070setVideoMode(GRAPHICS_MODE, 0);
2071#else
2072setVideoMode(GRAPHICS_MODE);
2073#endif
2074}
2075
2076if (getValueForKey("-checkers", &dummyVal, &length, &bootInfo->bootConfig)) {
2077drawCheckerBoard();
2078} else {
2079// Fill the background to 75% grey (same as BootX).
2080drawColorRectangle(0, 0, screen_params[0], screen_params[1], 0x01);
2081}
2082if ((bootImageData) && (usePngImage)) {
2083x = (screen_params[0] - MIN(bootImageWidth, screen_params[0])) / 2;
2084y = (screen_params[1] - MIN(bootImageHeight, screen_params[1])) / 2;
2085
2086// Draw the image in the center of the display.
2087blendImage(x, y, bootImageWidth, bootImageHeight, bootImageData);
2088} else {
2089uint8_t *appleBootPict;
2090bootImageData = NULL;
2091bootImageWidth = kAppleBootWidth;
2092bootImageHeight = kAppleBootHeight;
2093
2094// Prepare the data for the default Apple boot image.
2095appleBootPict = (uint8_t *) decodeRLE(gAppleBootPictRLE, kAppleBootRLEBlocks, bootImageWidth * bootImageHeight);
2096if (appleBootPict) {
2097convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData);
2098if (bootImageData) {
2099x = (screen_params[0] - MIN(kAppleBootWidth, screen_params[0])) / 2;
2100y = (screen_params[1] - MIN(kAppleBootHeight, screen_params[1])) / 2;
2101drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData);
2102free(bootImageData);
2103}
2104free(appleBootPict);
2105}
2106}
2107}
2108
2109int GUI_initGraphicsMode ()
2110{
2111unsigned long params[4];
2112int count;
2113
2114params[3] = 0;
2115count = getNumberArrayFromProperty( kGraphicsModeKey, params, 4 );
2116
2117// Try to find a resolution if "Graphics Mode" setting is not available.
2118if ( count < 3 )
2119{
2120// Use the default resolution if we don't have an initialized GUI.
2121if (gui.screen.width == 0 || gui.screen.height == 0)
2122{
2123gui.screen.width = DEFAULT_SCREEN_WIDTH;
2124gui.screen.height = DEFAULT_SCREEN_HEIGHT;
2125}
2126
2127params[0] = gui.screen.width;
2128params[1] = gui.screen.height;
2129params[2] = 32;
2130}
2131
2132// Map from pixel format to bits per pixel.
2133
2134if ( params[2] == 256 ) params[2] = 8;
2135if ( params[2] == 555 ) params[2] = 16;
2136if ( params[2] == 888 ) params[2] = 32;
2137
2138#if UNUSED
2139return setVESAGraphicsMode( params[0], params[1], params[2], params[3] );
2140#else
2141return setVESAGraphicsMode( params[0], params[1], params[2] );
2142#endif
2143}
2144
2145
2146int GUI_countdown( const char * msg, int row, int timeout )
2147{
2148 unsigned long time;
2149 register int ch = 0;
2150 int col = strlen(msg) + 1;
2151
2152 flushKeyboardBuffer();
2153
2154if( bootArgs->Video.v_display == VGA_TEXT_MODE )
2155{
2156moveCursor( 0, row );
2157printf(msg);
2158
2159} else {
2160
2161position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) );
2162
2163char dummy[80];
2164getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );
2165drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, true );
2166drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos );
2167
2168// make this screen the new background
2169memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
2170
2171}
2172
2173int multi_buff = 18 * (timeout);
2174 int multi = ++multi_buff;
2175
2176 int lasttime=0;
2177
2178 for ( time = time18(), timeout++; timeout > 0; )
2179 {
2180if( time18() > (unsigned)lasttime)
2181{
2182multi--;
2183lasttime=time18();
2184}
2185
2186 if ((ch = readKeyboardStatus()))
2187 break;
2188
2189 // Count can be interrupted by holding down shift,
2190 // control or alt key
2191 if ( ( readKeyboardShiftFlags() & 0x0F ) != 0 )
2192{
2193 ch = 1;
2194 break;
2195 }
2196
2197 if ( time18() >= time )
2198 {
2199 time += 18;
2200 timeout--;
2201
2202if( bootArgs->Video.v_display == VGA_TEXT_MODE )
2203{
2204moveCursor( col, row );
2205printf("(%d) ", timeout);
2206}
2207 }
2208
2209if( bootArgs->Video.v_display == GRAPHICS_MODE )
2210{
2211drawProgressBar( gui.screen.pixmap, 100, gui.progressbar.pos , ( multi * 100 / multi_buff ) );
2212gui.redraw = true;
2213updateVRAM();
2214}
2215
2216 }
2217
2218 flushKeyboardBuffer();
2219
2220 return ch;
2221}
2222
2223

Archive Download this file

Revision: 1119