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