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