Root/
Source at commit 533 created 13 years 7 months ago. By meklort, GUI module should now work in the four main cases (combo of embededtheme and /Extra/Themes). Only tested on my machines. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 2009 Evan Lojewski. All rights reserved.␊ |
3 | *␊ |
4 | */␊ |
5 | ␊ |
6 | #include "libsaio.h"␊ |
7 | #include "options.h"␊ |
8 | #include "graphic_utils.h"␊ |
9 | #include "ramdisk.h"␊ |
10 | #include "embedded.h"␊ |
11 | ␊ |
12 | #include "picopng.h"␊ |
13 | #include "gui.h"␊ |
14 | ␊ |
15 | #include "modules.h"␊ |
16 | ␊ |
17 | /* Kabyl: BooterLog */␊ |
18 | #define BOOTER_LOG_SIZE␉(64 * 1024)␊ |
19 | #define SAFE_LOG_SIZE␉80␊ |
20 | ␊ |
21 | ␊ |
22 | bool useGUI;␊ |
23 | ␊ |
24 | void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4);␊ |
25 | void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4);␊ |
26 | ␊ |
27 | int GUI_getBootOptions(bool firstRun);␊ |
28 | ␊ |
29 | static void GUI_updateBootArgs( int key );␊ |
30 | void GUI_clearBootArgs(void);␊ |
31 | static void GUI_showBootPrompt(int row, bool visible);␊ |
32 | static void GUI_showMenu( const MenuItem * items, int count, int selection, int row, int height );␊ |
33 | static int GUI_updateMenu( int key, void ** paramPtr );␊ |
34 | static void GUI_showHelp(void);␊ |
35 | ␊ |
36 | int GUI_printf(const char * fmt, ...);␊ |
37 | int GUI_verbose(const char * fmt, ...);␊ |
38 | int GUI_error(const char * fmt, ...);␊ |
39 | void GUI_stop(const char * fmt, ...);␊ |
40 | ␊ |
41 | ␊ |
42 | /* console.c */␊ |
43 | struct putc_info {␊ |
44 | char * str;␊ |
45 | char * last_str;␊ |
46 | };␊ |
47 | void sputc(int c, struct putc_info * pi);␊ |
48 | extern char *msgbuf;␊ |
49 | extern char *cursor;␊ |
50 | ␊ |
51 | /**␊ |
52 | ** The kernel is about to start, draw the boot graphics if we are not in␊ |
53 | ** verbose mode.␊ |
54 | **/␊ |
55 | void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4)␊ |
56 | {␊ |
57 | ␉if(!gVerboseMode)␊ |
58 | ␉{␊ |
59 | ␉␉drawBootGraphics();␊ |
60 | ␉}␊ |
61 | ␉␊ |
62 | }␊ |
63 | ␊ |
64 | /**␊ |
65 | ** A boot option has been selected, disable the graphical elements on screen.␊ |
66 | **/␊ |
67 | void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
68 | {␊ |
69 | ␉// Turn off any GUI elements␊ |
70 | ␉if( bootArgs->Video.v_display == GRAPHICS_MODE )␊ |
71 | ␉{␊ |
72 | ␉␉gui.devicelist.draw = false;␊ |
73 | ␉␉gui.bootprompt.draw = false;␊ |
74 | ␉␉gui.menu.draw = false;␊ |
75 | ␉␉gui.infobox.draw = false;␊ |
76 | ␉␉gui.logo.draw = false;␊ |
77 | ␉␉drawBackground();␊ |
78 | ␉␉updateVRAM();␊ |
79 | ␉}␊ |
80 | }␊ |
81 | ␊ |
82 | /**␊ |
83 | ** Module startup code. Replace console only print functions as well as␊ |
84 | ** replace various menu functions. Finaly, initialize the gui and hook␊ |
85 | ** into important events.␊ |
86 | **/␊ |
87 | void GUI_start()␊ |
88 | {␊ |
89 | ␉␊ |
90 | ␉// Start the gui␊ |
91 | ␉␊ |
92 | ␉useGUI = true;␊ |
93 | ␉// Override useGUI default␊ |
94 | ␉getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig);␊ |
95 | ␉if (useGUI && initGUI())␊ |
96 | ␉{␊ |
97 | ␉␉// initGUI() returned with an error, disabling GUI.␊ |
98 | ␉␉useGUI = false;␊ |
99 | ␉}␊ |
100 | ␉else␊ |
101 | ␉{␊ |
102 | ␉␉replace_function("_initGraphicsMode", &GUI_initGraphicsMode);␊ |
103 | ␉␉replace_function("_getBootOptions", &GUI_getBootOptions);␊ |
104 | ␉␉replace_function("_clearBootArgs", &GUI_clearBootArgs);␊ |
105 | ␉␉replace_function("_showHelp", &GUI_showHelp);␊ |
106 | ␉␉␊ |
107 | ␉␉replace_function("_printf", &GUI_printf);␊ |
108 | ␉␉replace_function("_verbose", &GUI_verbose);␊ |
109 | ␉␉replace_function("_error", &GUI_error);␊ |
110 | ␉␉replace_function("_stop", &GUI_stop);␉␉␊ |
111 | ␉}␊ |
112 | ␉␊ |
113 | ␉// Hoot for the boot screen ␊ |
114 | ␉register_hook_callback("Kernel Start", &GUI_Kernel_Start_hook);␊ |
115 | ␉register_hook_callback("PreBoot", &GUI_PreBoot_hook);␉␉␊ |
116 | ␉␊ |
117 | }␊ |
118 | ␊ |
119 | /**␊ |
120 | ** Overriden chameleon function. Draws the updated menu.␊ |
121 | **/␊ |
122 | static int GUI_updateMenu( int key, void ** paramPtr )␊ |
123 | {␊ |
124 | int moved = 0;␊ |
125 | ␉␊ |
126 | union {␊ |
127 | struct {␊ |
128 | unsigned int␊ |
129 | ␉␉␉selectionUp : 1,␊ |
130 | ␉␉␉selectionDown : 1,␊ |
131 | ␉␉␉scrollUp : 1,␊ |
132 | ␉␉␉scrollDown : 1;␊ |
133 | } f;␊ |
134 | unsigned int w;␊ |
135 | } draw = {{0}};␊ |
136 | ␉␊ |
137 | if ( gMenuItems == NULL )␊ |
138 | ␉␉return 0;␊ |
139 | ␉␊ |
140 | ␉if( bootArgs->Video.v_display == GRAPHICS_MODE )␊ |
141 | ␉{␊ |
142 | ␉␉int res;␊ |
143 | ␉␉␊ |
144 | ␉␉// set navigation keys for horizontal layout as defaults␊ |
145 | ␉␉int previous␉= 0x4B00;␉␉// left arrow␊ |
146 | ␉␉int subsequent␉= 0x4D00;␉␉// right arrow␊ |
147 | ␉␉int menu␉␉= 0x5000;␉␉// down arrow␊ |
148 | ␉␉␊ |
149 | ␉␉if ( gui.layout == VerticalLayout )␊ |
150 | ␉␉{␊ |
151 | ␉␉␉// set navigation keys for vertical layout␊ |
152 | ␉␉␉previous␉= 0x4800;␉␉// up arrow␊ |
153 | ␉␉␉subsequent␉= 0x5000;␉␉// down arrow␊ |
154 | ␉␉␉menu␉␉= 0x4B00;␉␉// right arrow␊ |
155 | ␉␉} ␊ |
156 | ␉␉␊ |
157 | ␉␉if ( key == previous )␊ |
158 | ␉␉{␊ |
159 | ␉␉␉if ( gMenuSelection > gMenuTop )␊ |
160 | ␉␉␉␉draw.f.selectionUp = 1;␊ |
161 | ␉␉␉else if ( gMenuTop > 0 )␊ |
162 | ␉␉␉␉draw.f.scrollDown = 1;␊ |
163 | ␉␉␉␊ |
164 | ␉␉}␊ |
165 | ␉␉␊ |
166 | ␉␉else if ( key == subsequent )␊ |
167 | ␉␉{␊ |
168 | ␉␉␉if ( gMenuSelection != gMenuBottom)␊ |
169 | ␉␉␉␉draw.f.selectionDown = 1;␊ |
170 | ␉␉␉else if ( gMenuBottom < ( gMenuItemCount - 1 ) )␊ |
171 | ␉␉␉␉draw.f.scrollUp = 1;␊ |
172 | ␉␉}␊ |
173 | ␉␉␊ |
174 | ␉␉else if ( key == menu )␊ |
175 | ␉␉{␊ |
176 | ␉␉␉if ( gui.menu.draw )␊ |
177 | ␉␉␉␉updateInfoMenu(key);␊ |
178 | ␉␉␉else␊ |
179 | ␉␉␉␉drawInfoMenu();␊ |
180 | ␉␉}␊ |
181 | ␉␉␊ |
182 | ␉␉else if ( gui.menu.draw )␊ |
183 | ␉␉{␊ |
184 | ␉␉␉res = updateInfoMenu(key);␊ |
185 | ␉␉␉␊ |
186 | ␉␉␉if ( res == CLOSE_INFO_MENU )␊ |
187 | ␉␉␉␉gui.menu.draw = false;␊ |
188 | ␉␉␉else␊ |
189 | ␉␉␉{␊ |
190 | ␉␉␉␉shouldboot = ( res != DO_NOT_BOOT );␊ |
191 | ␉␉␉␉␊ |
192 | ␉␉␉␉if ( shouldboot )␊ |
193 | ␉␉␉␉␉gui.menu.draw = false;␊ |
194 | ␉␉␉␉␊ |
195 | ␉␉␉␉switch (res)␊ |
196 | ␉␉␉␉{␊ |
197 | ␉␉␉␉␉case BOOT_NORMAL:␊ |
198 | ␉␉␉␉␉␉gVerboseMode = false;␊ |
199 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
200 | ␉␉␉␉␉␉break;␊ |
201 | ␉␉␉␉␉␉␊ |
202 | ␉␉␉␉␉case BOOT_VERBOSE:␊ |
203 | ␉␉␉␉␉␉gVerboseMode = true;␊ |
204 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
205 | ␉␉␉␉␉␉addBootArg(kVerboseModeFlag);␊ |
206 | ␉␉␉␉␉␉break;␊ |
207 | ␉␉␉␉␉␉␊ |
208 | ␉␉␉␉␉case BOOT_IGNORECACHE:␊ |
209 | ␉␉␉␉␉␉gVerboseMode = false;␊ |
210 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
211 | ␉␉␉␉␉␉addBootArg(kIgnoreCachesFlag);␊ |
212 | ␉␉␉␉␉␉break;␊ |
213 | ␉␉␉␉␉␉␊ |
214 | ␉␉␉␉␉case BOOT_SINGLEUSER:␊ |
215 | ␉␉␉␉␉␉gVerboseMode = true;␊ |
216 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
217 | ␉␉␉␉␉␉addBootArg(kSingleUserModeFlag);␊ |
218 | ␉␉␉␉␉␉break;␊ |
219 | ␉␉␉␉}␊ |
220 | ␉␉␉␉␊ |
221 | ␉␉␉}␊ |
222 | ␉␉␉␊ |
223 | ␉␉}␉␊ |
224 | ␉␉␊ |
225 | ␉} else {␊ |
226 | ␉␉switch ( key )␊ |
227 | ␉␉{␊ |
228 | ␉case 0x4800: // Up Arrow␊ |
229 | ␉␉␉␉if ( gMenuSelection != gMenuTop )␊ |
230 | ␉␉␉␉{␊ |
231 | ␉␉␉␉␉draw.f.selectionUp = 1;␊ |
232 | ␉␉␉␉}␊ |
233 | ␉␉␉␉else if ( gMenuTop > 0 )␊ |
234 | ␉␉␉␉{␊ |
235 | ␉␉␉␉␉draw.f.scrollDown = 1;␊ |
236 | ␉␉␉␉}␊ |
237 | ␉␉␉␉break;␊ |
238 | ␉␉␉␉␊ |
239 | ␉␉␉case 0x5000: // Down Arrow␊ |
240 | ␉␉␉␉if ( gMenuSelection != gMenuBottom )␊ |
241 | ␉␉␉␉{␊ |
242 | ␉␉␉␉␉draw.f.selectionDown = 1;␊ |
243 | ␉␉␉␉}␊ |
244 | ␉␉␉␉else if ( gMenuBottom < (gMenuItemCount - 1) ) ␊ |
245 | ␉␉␉␉{␊ |
246 | ␉␉␉␉␉draw.f.scrollUp = 1;␊ |
247 | ␉␉␉␉}␊ |
248 | ␉␉␉␉break;␊ |
249 | ␉␉}␊ |
250 | ␉}␊ |
251 | ␉␊ |
252 | if ( draw.w )␊ |
253 | {␊ |
254 | if ( draw.f.scrollUp )␊ |
255 | {␊ |
256 | scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);␊ |
257 | gMenuTop++; gMenuBottom++;␊ |
258 | ␉␉␉gMenuStart++; gMenuEnd++;␊ |
259 | draw.f.selectionDown = 1;␊ |
260 | }␊ |
261 | ␉␉␊ |
262 | if ( draw.f.scrollDown )␊ |
263 | {␊ |
264 | scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);␊ |
265 | gMenuTop--; gMenuBottom--;␊ |
266 | gMenuStart--; gMenuEnd--;␊ |
267 | draw.f.selectionUp = 1;␊ |
268 | }␊ |
269 | ␉␉␊ |
270 | if ( draw.f.selectionUp || draw.f.selectionDown )␊ |
271 | {␊ |
272 | ␉␉␉␊ |
273 | ␉␉␉CursorState cursorState;␊ |
274 | ␉␉␉␊ |
275 | ␉␉␉// Set cursor at current position, and clear inverse video.␊ |
276 | ␉␉␉␊ |
277 | ␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
278 | ␉␉␉{␊ |
279 | ␉␉␉␉changeCursor( 0, (gMenuRow + gMenuSelection - gMenuTop), kCursorTypeHidden, &cursorState );␊ |
280 | ␉␉␉␉printMenuItem( &gMenuItems[gMenuSelection], 0 );␊ |
281 | ␉␉␉}␊ |
282 | ␉␉␉␊ |
283 | ␉␉␉if ( draw.f.selectionUp )␊ |
284 | ␉␉␉{␊ |
285 | ␉␉␉␉gMenuSelection--;␊ |
286 | ␉␉␉␉if(( gMenuSelection - gMenuStart) == -1 )␊ |
287 | ␉␉␉␉{␊ |
288 | ␉␉␉␉␉gMenuStart--;␊ |
289 | ␉␉␉␉␉gMenuEnd--;␊ |
290 | ␉␉␉␉}␊ |
291 | ␉␉␉␉␊ |
292 | ␉␉␉} else {␊ |
293 | ␉␉␉␉gMenuSelection++;␊ |
294 | ␉␉␉␉if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 )␊ |
295 | ␉␉␉␉{␊ |
296 | ␉␉␉␉␉gMenuStart++;␊ |
297 | ␉␉␉␉␉gMenuEnd++;␊ |
298 | ␉␉␉␉}␊ |
299 | ␉␉␉}␊ |
300 | ␉␉␉␊ |
301 | ␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
302 | ␉␉␉{␊ |
303 | ␉␉␉␉moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );␊ |
304 | ␉␉␉␉printMenuItem( &gMenuItems[gMenuSelection], 1 );␊ |
305 | ␉␉␉␉restoreCursor( &cursorState );␊ |
306 | ␉␉␉␉␊ |
307 | ␉␉␉}␊ |
308 | ␉␉␉else␊ |
309 | ␉␉␉{␊ |
310 | ␉␉␉␉drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);␊ |
311 | ␉␉␉}␊ |
312 | ␉␉␉␊ |
313 | ␉␉}␊ |
314 | ␉␉␊ |
315 | *paramPtr = gMenuItems[gMenuSelection].param; ␊ |
316 | moved = 1;␊ |
317 | }␊ |
318 | ␉␊ |
319 | ␉return moved;␊ |
320 | }␊ |
321 | ␊ |
322 | ␊ |
323 | static void GUI_showMenu( const MenuItem * items, int count,␊ |
324 | ␉␉␉␉␉␉ int selection, int row, int height )␊ |
325 | {␊ |
326 | int i;␊ |
327 | CursorState cursorState;␊ |
328 | ␉␊ |
329 | if ( items == NULL || count == 0 ) ␊ |
330 | ␉␉return;␊ |
331 | ␉␊ |
332 | // head and tail points to the start and the end of the list.␊ |
333 | // top and bottom points to the first and last visible items␊ |
334 | // in the menu window.␊ |
335 | ␉␊ |
336 | gMenuItems␉␉= items;␊ |
337 | gMenuRow␉␉= row;␊ |
338 | gMenuHeight␉␉= height;␊ |
339 | gMenuItemCount␉= count;␊ |
340 | gMenuTop␉␉= 0;␊ |
341 | gMenuBottom␉␉= min( count, height ) - 1;␊ |
342 | gMenuSelection␉= selection;␊ |
343 | ␉␊ |
344 | gMenuStart␉␉= 0;␊ |
345 | gMenuEnd␉ = min( count, gui.maxdevices ) - 1;␊ |
346 | ␉␊ |
347 | ␉// If the selected item is not visible, shift the list down.␊ |
348 | ␉␊ |
349 | if ( gMenuSelection > gMenuBottom )␊ |
350 | {␊ |
351 | gMenuTop += ( gMenuSelection - gMenuBottom );␊ |
352 | gMenuBottom = gMenuSelection;␊ |
353 | }␊ |
354 | ␉␊ |
355 | ␉if ( gMenuSelection > gMenuEnd )␊ |
356 | {␊ |
357 | ␉␉gMenuStart += ( gMenuSelection - gMenuEnd );␊ |
358 | gMenuEnd = gMenuSelection;␊ |
359 | }␊ |
360 | ␉␊ |
361 | ␉// Draw the visible items.␊ |
362 | ␉␊ |
363 | ␉if( bootArgs->Video.v_display == GRAPHICS_MODE )␊ |
364 | ␉{␊ |
365 | ␉␉drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection);␊ |
366 | ␉}␊ |
367 | ␉else ␊ |
368 | ␉{␊ |
369 | ␉␉␊ |
370 | ␉␉changeCursor( 0, row, kCursorTypeHidden, &cursorState );␊ |
371 | ␉␉␊ |
372 | ␉␉for ( i = gMenuTop; i <= gMenuBottom; i++ )␊ |
373 | ␉␉{␊ |
374 | ␉␉␉printMenuItem( &items[i], (i == gMenuSelection) );␊ |
375 | ␉␉}␊ |
376 | ␉␉␊ |
377 | ␉␉restoreCursor( &cursorState );␊ |
378 | }␊ |
379 | }␊ |
380 | ␊ |
381 | ␊ |
382 | static void GUI_updateBootArgs( int key )␊ |
383 | {␊ |
384 | key &= kASCIIKeyMask;␊ |
385 | ␉␊ |
386 | switch ( key )␊ |
387 | {␊ |
388 | case kBackspaceKey:␊ |
389 | if ( gBootArgsPtr > gBootArgs )␊ |
390 | {␊ |
391 | int x, y, t;␊ |
392 | getCursorPositionAndType( &x, &y, &t );␊ |
393 | if ( x == 0 && y )␊ |
394 | {␊ |
395 | x = 80; y--;␊ |
396 | }␊ |
397 | if (x)␊ |
398 | ␉␉␉␉␉x--;␊ |
399 | ␉␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
400 | ␉␉␉␉{␊ |
401 | ␉␉␉␉␉setCursorPosition( x, y, 0 );␊ |
402 | ␉␉␉␉␉putca(' ', 0x07, 1);␊ |
403 | ␉␉␉␉} else␊ |
404 | ␉␉␉␉{␊ |
405 | ␉␉␉␉␉updateGraphicBootPrompt(kBackspaceKey);␊ |
406 | ␉␉␉␉}␊ |
407 | ␉␉␉␉␊ |
408 | ␉␉␉␉*gBootArgsPtr-- = '\0';␊ |
409 | ␉␉␉}␊ |
410 | ␊ |
411 | ␉␉␉break;␊ |
412 | ␉␉␉␊ |
413 | default:␊ |
414 | if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd)␊ |
415 | {␊ |
416 | ␉␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
417 | ␉␉␉␉{␊ |
418 | ␉␉␉␉␉putchar(key); // echo to screen␊ |
419 | ␉␉␉␉}␊ |
420 | ␉␉␉␉else␊ |
421 | ␉␉␉␉{␊ |
422 | ␉␉␉␉␉updateGraphicBootPrompt(key);␊ |
423 | ␉␉␉␉}␊ |
424 | ␉␉␉␉*gBootArgsPtr++ = key;␊ |
425 | ␉␉␉}␊ |
426 | ␊ |
427 | ␉␉␉break;␊ |
428 | }␊ |
429 | }␊ |
430 | ␊ |
431 | ␊ |
432 | static void GUI_showBootPrompt(int row, bool visible)␊ |
433 | {␊ |
434 | ␉extern char bootPrompt[];␊ |
435 | ␉extern char bootRescanPrompt[];␊ |
436 | ␉␊ |
437 | ␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
438 | ␉{␊ |
439 | ␉␉changeCursor( 0, row, kCursorTypeUnderline, 0 ); ␊ |
440 | ␉␉clearScreenRows( row, kScreenLastRow );␊ |
441 | ␉}␊ |
442 | ␉␊ |
443 | ␉clearBootArgs();␊ |
444 | ␉␊ |
445 | ␉if (visible)␊ |
446 | ␉{␊ |
447 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE) ␊ |
448 | ␉␉{␊ |
449 | ␉␉␉if (gEnableCDROMRescan)␊ |
450 | ␉␉␉{␊ |
451 | ␉␉␉␉printf( bootRescanPrompt );␊ |
452 | ␉␉␉} ␊ |
453 | ␉␉␉else␊ |
454 | ␉␉␉{␊ |
455 | ␉␉␉␉printf( bootPrompt );␊ |
456 | ␉␉␉}␊ |
457 | ␉␉}␊ |
458 | ␉} ␊ |
459 | ␉else␊ |
460 | ␉{␊ |
461 | ␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
462 | ␉␉{␊ |
463 | ␉␉␉clearGraphicBootPrompt();␊ |
464 | ␉␉} ␊ |
465 | ␉␉else␊ |
466 | ␉␉{␊ |
467 | ␉␉␉printf("Press Enter to start up the foreign OS. ");␊ |
468 | ␉␉}␊ |
469 | ␉}␊ |
470 | }␊ |
471 | ␊ |
472 | ␊ |
473 | void GUI_clearBootArgs(void)␊ |
474 | {␊ |
475 | ␉gBootArgsPtr = gBootArgs;␊ |
476 | ␉memset(gBootArgs, '\0', BOOT_STRING_LEN);␊ |
477 | ␉␊ |
478 | ␉if (bootArgs->Video.v_display == GRAPHICS_MODE) ␊ |
479 | ␉{␊ |
480 | ␉␉clearGraphicBootPrompt();␊ |
481 | ␉}␊ |
482 | }␊ |
483 | ␊ |
484 | ␊ |
485 | int GUI_getBootOptions(bool firstRun)␊ |
486 | {␊ |
487 | ␉int i;␊ |
488 | ␉int key;␊ |
489 | ␉int nextRow;␊ |
490 | ␉int timeout;␊ |
491 | ␉int bvCount;␊ |
492 | ␉BVRef bvr;␊ |
493 | ␉BVRef menuBVR;␊ |
494 | ␉bool showPrompt, newShowPrompt, isCDROM;␊ |
495 | ␉␊ |
496 | ␉// Initialize default menu selection entry.␊ |
497 | ␉gBootVolume = menuBVR = selectBootVolume(bvChain);␊ |
498 | ␉␊ |
499 | ␉if (biosDevIsCDROM(gBIOSDev))␊ |
500 | ␉{␊ |
501 | ␉␉isCDROM = true;␊ |
502 | ␉} ␊ |
503 | ␉else␊ |
504 | ␉{␊ |
505 | ␉␉isCDROM = false;␊ |
506 | ␉}␊ |
507 | ␉␊ |
508 | ␉// ensure we're in graphics mode if gui is setup␊ |
509 | ␉if (gui.initialised && bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
510 | ␉{␊ |
511 | ␉␉setVideoMode(GRAPHICS_MODE, 0);␊ |
512 | ␉}␊ |
513 | ␉␊ |
514 | ␉// Clear command line boot arguments␊ |
515 | ␉clearBootArgs();␊ |
516 | ␉␊ |
517 | ␉// Allow user to override default timeout.␊ |
518 | ␉if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig))␊ |
519 | ␉{␊ |
520 | ␉␉/* If there is no timeout key in the file use the default timeout␊ |
521 | ␉␉ which is different for CDs vs. hard disks. However, if not booting␊ |
522 | ␉␉ a CD and no config file could be loaded set the timeout␊ |
523 | ␉␉ to zero which causes the menu to display immediately.␊ |
524 | ␉␉ This way, if no partitions can be found, that is the disk is unpartitioned␊ |
525 | ␉␉ or simply cannot be read) then an empty menu is displayed.␊ |
526 | ␉␉ If some partitions are found, for example a Windows partition, then␊ |
527 | ␉␉ these will be displayed in the menu as foreign partitions.␊ |
528 | ␉␉ */␊ |
529 | ␉␉if (isCDROM)␊ |
530 | ␉␉{␊ |
531 | ␉␉␉timeout = kCDBootTimeout;␊ |
532 | ␉␉}␊ |
533 | ␉␉else ␊ |
534 | ␉␉{␊ |
535 | ␉␉␉timeout = sysConfigValid ? kBootTimeout : 0;␊ |
536 | ␉␉}␊ |
537 | ␉}␊ |
538 | ␉␊ |
539 | ␉if (timeout < 0) ␊ |
540 | ␉{␊ |
541 | ␉␉gBootMode |= kBootModeQuiet;␊ |
542 | ␉}␊ |
543 | ␉␊ |
544 | ␉// If the user is holding down a modifier key, enter safe mode.␊ |
545 | ␉if ((readKeyboardShiftFlags() & 0x0F) != 0) ␊ |
546 | ␉{␊ |
547 | ␉␉␊ |
548 | ␉␉//gBootMode |= kBootModeSafe;␊ |
549 | ␉}␊ |
550 | ␉␊ |
551 | ␉// Checking user pressed keys␊ |
552 | ␉bool f8press = false, spress = false, vpress = false;␊ |
553 | ␉while (readKeyboardStatus())␊ |
554 | ␉{␊ |
555 | ␉␉key = bgetc ();␊ |
556 | ␉␉if (key == 0x4200) f8press = true;␊ |
557 | ␉␉if ((key & 0xff) == 's' || (key & 0xff) == 'S') spress = true;␊ |
558 | ␉␉if ((key & 0xff) == 'v' || (key & 0xff) == 'V') vpress = true;␊ |
559 | ␉}␊ |
560 | ␉// If user typed F8, abort quiet mode, and display the menu.␊ |
561 | ␉if (f8press)␊ |
562 | ␉{␊ |
563 | ␉␉gBootMode &= ~kBootModeQuiet;␊ |
564 | ␉␉timeout = 0;␊ |
565 | ␉}␊ |
566 | ␉// If user typed 'v' or 'V', boot in verbose mode.␊ |
567 | ␉if ((gBootMode & kBootModeQuiet) && firstRun && vpress)␊ |
568 | ␉{␊ |
569 | ␉␉addBootArg(kVerboseModeFlag);␊ |
570 | ␉}␊ |
571 | ␉// If user typed 's' or 'S', boot in single user mode.␊ |
572 | ␉if ((gBootMode & kBootModeQuiet) && firstRun && spress)␊ |
573 | ␉{␊ |
574 | ␉␉addBootArg(kSingleUserModeFlag);␊ |
575 | ␉}␊ |
576 | ␉␊ |
577 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
578 | ␉{␊ |
579 | ␉␉setCursorPosition(0, 0, 0);␊ |
580 | ␉␉clearScreenRows(0, kScreenLastRow);␊ |
581 | ␉␉if (!(gBootMode & kBootModeQuiet)) ␊ |
582 | ␉␉{␊ |
583 | ␉␉␉// Display banner and show hardware info.␊ |
584 | ␉␉␉printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
585 | ␉␉␉printf(getVBEInfoString());␊ |
586 | ␉␉}␊ |
587 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);␊ |
588 | ␉␉verbose("Scanning device %x...", gBIOSDev);␊ |
589 | ␉}␊ |
590 | ␉␊ |
591 | ␉// When booting from CD, default to hard drive boot when possible. ␊ |
592 | ␉if (isCDROM && firstRun)␊ |
593 | ␉{␊ |
594 | ␉␉const char *val;␊ |
595 | ␉␉char *prompt = NULL;␊ |
596 | ␉␉char *name = NULL;␊ |
597 | ␉␉int cnt;␊ |
598 | ␉␉int optionKey;␊ |
599 | ␉␉␊ |
600 | ␉␉if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig))␊ |
601 | ␉␉{␊ |
602 | ␉␉␉prompt = malloc(cnt + 1);␊ |
603 | ␉␉␉strncat(prompt, val, cnt);␊ |
604 | ␉␉}␊ |
605 | ␉␉else ␊ |
606 | ␉␉{␊ |
607 | ␉␉␉name = malloc(80);␊ |
608 | ␉␉␉getBootVolumeDescription(gBootVolume, name, 79, false);␊ |
609 | ␉␉␉prompt = malloc(256);␊ |
610 | ␉␉␉sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);␊ |
611 | ␉␉␉free(name);␊ |
612 | ␉␉}␊ |
613 | ␉␉␊ |
614 | ␉␉if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig ))␊ |
615 | ␉␉{␊ |
616 | ␉␉␉// The key specified is a special key.␊ |
617 | ␉␉}␊ |
618 | ␉␉else␊ |
619 | ␉␉{␊ |
620 | ␉␉␉// Default to F8.␊ |
621 | ␉␉␉optionKey = 0x4200;␊ |
622 | ␉␉}␊ |
623 | ␉␉␊ |
624 | ␉␉// If the timeout is zero then it must have been set above due to the␊ |
625 | ␉␉// early catch of F8 which means the user wants to set boot options␊ |
626 | ␉␉// which we ought to interpret as meaning he wants to boot the CD.␊ |
627 | ␉␉if (timeout != 0) {␊ |
628 | ␉␉␉key = GUI_countdown(prompt, kMenuTopRow, timeout);␊ |
629 | ␉␉} ␊ |
630 | ␉␉else ␊ |
631 | ␉␉{␊ |
632 | ␉␉␉key = optionKey;␊ |
633 | ␉␉}␊ |
634 | ␉␉␊ |
635 | ␉␉if (prompt != NULL)␊ |
636 | ␉␉{␊ |
637 | ␉␉␉free(prompt);␊ |
638 | ␉␉}␊ |
639 | ␉␉␊ |
640 | ␉␉clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );␊ |
641 | ␉␉␊ |
642 | ␉␉// Hit the option key ?␊ |
643 | ␉␉if (key == optionKey) ␊ |
644 | ␉␉{␊ |
645 | ␉␉␉gBootMode &= ~kBootModeQuiet;␊ |
646 | ␉␉␉timeout = 0;␊ |
647 | ␉␉} ␊ |
648 | ␉␉else ␊ |
649 | ␉␉{␊ |
650 | ␉␉␉key = key & 0xFF;␊ |
651 | ␉␉␉␊ |
652 | ␉␉␉// Try booting hard disk if user pressed 'h'␊ |
653 | ␉␉␉if (biosDevIsCDROM(gBIOSDev) && key == 'h')␊ |
654 | ␉␉␉{␊ |
655 | ␉␉␉␉BVRef bvr;␊ |
656 | ␉␉␉␉␊ |
657 | ␉␉␉␉// Look at partitions hosting OS X other than the CD-ROM␊ |
658 | ␉␉␉␉for (bvr = bvChain; bvr; bvr=bvr->next)␊ |
659 | ␉␉␉␉{␊ |
660 | ␉␉␉␉␉if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev)␊ |
661 | ␉␉␉␉␉{␊ |
662 | ␉␉␉␉␉␉gBootVolume = bvr;␊ |
663 | ␉␉␉␉␉}␊ |
664 | ␉␉␉␉}␊ |
665 | ␉␉␉}␊ |
666 | ␉␉␉goto done;␊ |
667 | ␉␉}␊ |
668 | ␉}␊ |
669 | ␉␊ |
670 | ␉if (gBootMode & kBootModeQuiet)␊ |
671 | ␉{␊ |
672 | ␉␉// No input allowed from user.␊ |
673 | ␉␉goto done;␊ |
674 | ␉}␊ |
675 | ␉␊ |
676 | ␉if (firstRun && timeout > 0 && GUI_countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0)␊ |
677 | ␉{␊ |
678 | ␉␉// If the user is holding down a modifier key,␊ |
679 | ␉␉// enter safe mode.␊ |
680 | ␉␉if ((readKeyboardShiftFlags() & 0x0F) != 0)␊ |
681 | ␉␉{␊ |
682 | ␉␉␉gBootMode |= kBootModeSafe;␊ |
683 | ␉␉}␊ |
684 | ␉␉goto done;␊ |
685 | ␉}␊ |
686 | ␉␊ |
687 | ␉if (gDeviceCount)␊ |
688 | ␉{␊ |
689 | ␉␉// Allocate memory for an array of menu items.␊ |
690 | ␉␉menuItems = malloc(sizeof(MenuItem) * gDeviceCount);␊ |
691 | ␉␉if (menuItems == NULL) ␊ |
692 | ␉␉{␊ |
693 | ␉␉␉goto done;␊ |
694 | ␉␉}␊ |
695 | ␉␉␊ |
696 | ␉␉// Associate a menu item for each BVRef.␊ |
697 | ␉␉for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next)␊ |
698 | ␉␉{␊ |
699 | ␉␉␉if (bvr->visible)␊ |
700 | ␉␉␉{␊ |
701 | ␉␉␉␉getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true);␊ |
702 | ␉␉␉␉menuItems[i].param = (void *) bvr;␊ |
703 | ␉␉␉␉if (bvr == menuBVR)␊ |
704 | ␉␉␉␉{␊ |
705 | ␉␉␉␉␉selectIndex = i;␊ |
706 | ␉␉␉␉}␊ |
707 | ␉␉␉␉i--;␊ |
708 | ␉␉␉}␊ |
709 | ␉␉}␊ |
710 | ␉}␊ |
711 | ␉␊ |
712 | ␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
713 | ␉{␊ |
714 | ␉␉// redraw the background buffer␊ |
715 | ␉␉gui.logo.draw = true;␊ |
716 | ␉␉drawBackground();␊ |
717 | ␉␉gui.devicelist.draw = true;␊ |
718 | ␉␉gui.redraw = true;␊ |
719 | ␉␉if (!(gBootMode & kBootModeQuiet))␊ |
720 | ␉␉{␊ |
721 | ␉␉␉bool showBootBanner = true;␊ |
722 | ␉␉␉␊ |
723 | ␉␉␉// Check if "Boot Banner"=N switch is present in config file.␊ |
724 | ␉␉␉getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig); ␊ |
725 | ␉␉␉if (showBootBanner)␊ |
726 | ␉␉␉{␊ |
727 | ␉␉␉␉// Display banner and show hardware info.␊ |
728 | ␉␉␉␉gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
729 | ␉␉␉}␊ |
730 | ␉␉␉␊ |
731 | ␉␉␉// redraw background␊ |
732 | ␉␉␉memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);␊ |
733 | ␉␉}␊ |
734 | ␉}␊ |
735 | ␉else ␊ |
736 | ␉{␊ |
737 | ␉␉// Clear screen and hide the blinking cursor.␊ |
738 | ␉␉clearScreenRows(kMenuTopRow, kMenuTopRow + 2);␊ |
739 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);␊ |
740 | ␉}␊ |
741 | ␉␊ |
742 | ␉nextRow = kMenuTopRow;␊ |
743 | ␉showPrompt = true;␊ |
744 | ␉␊ |
745 | ␉if (gDeviceCount)␊ |
746 | ␉{␊ |
747 | ␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
748 | ␉␉{␊ |
749 | ␉␉␉printf("Use \30\31 keys to select the startup volume.");␊ |
750 | ␉␉}␊ |
751 | ␉␉GUI_showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );␊ |
752 | ␉␉nextRow += min( gDeviceCount, kMenuMaxItems ) + 3;␊ |
753 | ␉}␊ |
754 | ␉␊ |
755 | ␉// Show the boot prompt.␊ |
756 | ␉showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
757 | ␉GUI_showBootPrompt( nextRow, showPrompt );␊ |
758 | ␉␊ |
759 | ␉do {␊ |
760 | ␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
761 | ␉␉{␊ |
762 | ␉␉␉// redraw background␊ |
763 | ␉␉␉memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );␊ |
764 | ␉␉␉// reset cursor co-ords␊ |
765 | ␉␉␉gui.debug.cursor = pos( gui.screen.width - 160 , 10 );␊ |
766 | ␉␉}␊ |
767 | ␉␉key = getc();␊ |
768 | ␉␉GUI_updateMenu( key, (void **) &menuBVR );␊ |
769 | ␉␉newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
770 | ␉␉␊ |
771 | ␉␉if (newShowPrompt != showPrompt)␊ |
772 | ␉␉{␊ |
773 | ␉␉␉showPrompt = newShowPrompt;␊ |
774 | ␉␉␉GUI_showBootPrompt( nextRow, showPrompt );␊ |
775 | ␉␉}␊ |
776 | ␉␉␊ |
777 | ␉␉if (showPrompt)␊ |
778 | ␉␉{␊ |
779 | ␉␉␉GUI_updateBootArgs(key);␊ |
780 | ␉␉}␊ |
781 | ␉␉␊ |
782 | ␉␉switch (key)␊ |
783 | ␉␉{␊ |
784 | ␉␉␉case kReturnKey:␊ |
785 | ␉␉␉␉if (gui.menu.draw)␊ |
786 | ␉␉␉␉{ ␊ |
787 | ␉␉␉␉␉key=0;␊ |
788 | ␉␉␉␉␉break;␊ |
789 | ␉␉␉␉}␊ |
790 | ␉␉␉␉if (*gBootArgs == '?')␊ |
791 | ␉␉␉␉{␊ |
792 | ␉␉␉␉␉char * argPtr = gBootArgs;␊ |
793 | ␉␉␉␉␉␊ |
794 | ␉␉␉␉␉// Skip the leading "?" character.␊ |
795 | ␉␉␉␉␉argPtr++;␊ |
796 | ␉␉␉␉␉getNextArg(&argPtr, booterCommand);␊ |
797 | ␉␉␉␉␉getNextArg(&argPtr, booterParam);␊ |
798 | ␉␉␉␉␉␊ |
799 | ␉␉␉␉␉/*␊ |
800 | ␉␉␉␉␉ * TODO: this needs to be refactored.␊ |
801 | ␉␉␉␉␉ */␊ |
802 | ␉␉␉␉␉if (strcmp( booterCommand, "video" ) == 0)␊ |
803 | ␉␉␉␉␉{␊ |
804 | ␉␉␉␉␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
805 | ␉␉␉␉␉␉{␊ |
806 | ␉␉␉␉␉␉␉showInfoBox(getVBEInfoString(), getVBEModeInfoString());␊ |
807 | ␉␉␉␉␉␉}␊ |
808 | ␉␉␉␉␉␉else␊ |
809 | ␉␉␉␉␉␉{␊ |
810 | ␉␉␉␉␉␉␉printVBEModeInfo();␊ |
811 | ␉␉␉␉␉␉}␊ |
812 | ␉␉␉␉␉}␊ |
813 | ␉␉␉␉␉else if ( strcmp( booterCommand, "memory" ) == 0)␊ |
814 | ␉␉␉␉␉{␊ |
815 | ␉␉␉␉␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE ) ␊ |
816 | ␉␉␉␉␉␉{␊ |
817 | ␉␉␉␉␉␉␉showInfoBox("Memory Map", getMemoryInfoString());␊ |
818 | ␉␉␉␉␉␉}␊ |
819 | ␉␉␉␉␉␉else␊ |
820 | ␉␉␉␉␉␉{␊ |
821 | ␉␉␉␉␉␉␉printMemoryInfo();␊ |
822 | ␉␉␉␉␉␉}␊ |
823 | ␉␉␉␉␉}␊ |
824 | ␉␉␉␉␉else if (strcmp(booterCommand, "lspci") == 0)␊ |
825 | ␉␉␉␉␉{␊ |
826 | ␉␉␉␉␉␉lspci();␊ |
827 | ␉␉␉␉␉}␊ |
828 | ␉␉␉␉␉else if (strcmp(booterCommand, "more") == 0)␊ |
829 | ␉␉␉␉␉{␊ |
830 | ␉␉␉␉␉␉showTextFile(booterParam);␊ |
831 | ␉␉␉␉␉}␊ |
832 | ␉␉␉␉␉else if (strcmp(booterCommand, "rd") == 0)␊ |
833 | ␉␉␉␉␉{␊ |
834 | ␉␉␉␉␉␉processRAMDiskCommand(&argPtr, booterParam);␊ |
835 | ␉␉␉␉␉} ␊ |
836 | ␉␉␉␉␉else if (strcmp(booterCommand, "norescan") == 0)␊ |
837 | ␉␉␉␉␉{␊ |
838 | ␉␉␉␉␉␉if (gEnableCDROMRescan)␊ |
839 | ␉␉␉␉␉␉{␊ |
840 | ␉␉␉␉␉␉␉gEnableCDROMRescan = false;␊ |
841 | ␉␉␉␉␉␉␉break;␊ |
842 | ␉␉␉␉␉␉}␊ |
843 | ␉␉␉␉␉} ␊ |
844 | ␉␉␉␉␉else␊ |
845 | ␉␉␉␉␉{␊ |
846 | ␉␉␉␉␉␉showHelp();␊ |
847 | ␉␉␉␉␉}␊ |
848 | ␉␉␉␉␉key = 0;␊ |
849 | ␉␉␉␉␉GUI_showBootPrompt(nextRow, showPrompt);␊ |
850 | ␉␉␉␉␉break;␊ |
851 | ␉␉␉␉}␊ |
852 | ␉␉␉␉gBootVolume = menuBVR;␊ |
853 | ␉␉␉␉setRootVolume(menuBVR);␊ |
854 | ␉␉␉␉gBIOSDev = menuBVR->biosdev;␊ |
855 | ␉␉␉␉break;␊ |
856 | ␉␉␉␉␊ |
857 | ␉␉␉case kEscapeKey:␊ |
858 | ␉␉␉␉clearBootArgs();␊ |
859 | ␉␉␉␉break;␊ |
860 | ␉␉␉␉␊ |
861 | ␉␉␉case kF5Key:␊ |
862 | ␉␉␉␉// New behavior:␊ |
863 | ␉␉␉␉// Clear gBootVolume to restart the loop␊ |
864 | ␉␉␉␉// if the user enabled rescanning the optical drive.␊ |
865 | ␉␉␉␉// Otherwise boot the default boot volume.␊ |
866 | ␉␉␉␉if (gEnableCDROMRescan)␊ |
867 | ␉␉␉␉{␊ |
868 | ␉␉␉␉␉gBootVolume = NULL;␊ |
869 | ␉␉␉␉␉clearBootArgs();␊ |
870 | ␉␉␉␉}␊ |
871 | ␉␉␉␉break;␊ |
872 | ␉␉␉␉␊ |
873 | ␉␉␉case kF10Key:␊ |
874 | ␉␉␉␉gScanSingleDrive = false;␊ |
875 | ␉␉␉␉scanDisks(gBIOSDev, &bvCount);␊ |
876 | ␉␉␉␉gBootVolume = NULL;␊ |
877 | ␉␉␉␉clearBootArgs();␊ |
878 | ␉␉␉␉break;␊ |
879 | ␉␉␉␉␊ |
880 | ␉␉␉case kTabKey:␊ |
881 | ␉␉␉␉// New behavior:␊ |
882 | ␉␉␉␉// Switch between text & graphic interfaces␊ |
883 | ␉␉␉␉// Only Permitted if started in graphics interface␊ |
884 | ␉␉␉␉if (useGUI)␊ |
885 | ␉␉␉␉{␊ |
886 | ␉␉␉␉␉if (bootArgs->Video.v_display == GRAPHICS_MODE)␊ |
887 | ␉␉␉␉␉{␊ |
888 | ␉␉␉␉␉␉setVideoMode(VGA_TEXT_MODE, 0);␊ |
889 | ␉␉␉␉␉␉␊ |
890 | ␉␉␉␉␉␉setCursorPosition(0, 0, 0);␊ |
891 | ␉␉␉␉␉␉clearScreenRows(0, kScreenLastRow);␊ |
892 | ␉␉␉␉␉␉␊ |
893 | ␉␉␉␉␉␉// Display banner and show hardware info.␊ |
894 | ␉␉␉␉␉␉printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
895 | ␉␉␉␉␉␉printf(getVBEInfoString());␊ |
896 | ␉␉␉␉␉␉␊ |
897 | ␉␉␉␉␉␉clearScreenRows(kMenuTopRow, kMenuTopRow + 2);␊ |
898 | ␉␉␉␉␉␉changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);␊ |
899 | ␉␉␉␉␉␉␊ |
900 | ␉␉␉␉␉␉nextRow = kMenuTopRow;␊ |
901 | ␉␉␉␉␉␉showPrompt = true;␊ |
902 | ␉␉␉␉␉␉␊ |
903 | ␉␉␉␉␉␉if (gDeviceCount)␊ |
904 | ␉␉␉␉␉␉{␊ |
905 | ␉␉␉␉␉␉␉printf("Use \30\31 keys to select the startup volume.");␊ |
906 | ␉␉␉␉␉␉␉GUI_showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);␊ |
907 | ␉␉␉␉␉␉␉nextRow += min(gDeviceCount, kMenuMaxItems) + 3;␊ |
908 | ␉␉␉␉␉␉}␊ |
909 | ␉␉␉␉␉␉␊ |
910 | ␉␉␉␉␉␉showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
911 | ␉␉␉␉␉␉GUI_showBootPrompt(nextRow, showPrompt);␊ |
912 | ␉␉␉␉␉␉//changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );␊ |
913 | ␉␉␉␉␉} ␊ |
914 | ␉␉␉␉␉else ␊ |
915 | ␉␉␉␉␉{␊ |
916 | ␉␉␉␉␉␉gui.redraw = true;␊ |
917 | ␉␉␉␉␉␉setVideoMode(GRAPHICS_MODE, 0);␊ |
918 | ␉␉␉␉␉␉updateVRAM();␊ |
919 | ␉␉␉␉␉}␊ |
920 | ␉␉␉␉}␊ |
921 | ␉␉␉␉key = 0;␊ |
922 | ␉␉␉␉break;␊ |
923 | ␉␉␉␉␊ |
924 | ␉␉␉default:␊ |
925 | ␉␉␉␉key = 0;␊ |
926 | ␉␉␉␉break;␊ |
927 | ␉␉}␊ |
928 | ␉} while (0 == key);␊ |
929 | ␉␊ |
930 | done:␊ |
931 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
932 | ␉{␊ |
933 | ␉␉clearScreenRows(kMenuTopRow, kScreenLastRow);␊ |
934 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);␊ |
935 | ␉}␊ |
936 | ␉shouldboot = false;␊ |
937 | ␉gui.menu.draw = false;␊ |
938 | ␉if (menuItems)␊ |
939 | ␉{␊ |
940 | ␉␉free(menuItems);␊ |
941 | ␉␉menuItems = NULL;␊ |
942 | ␉}␊ |
943 | ␉return 0;␊ |
944 | }␊ |
945 | ␊ |
946 | ␊ |
947 | ␊ |
948 | int GUI_error(const char * fmt, ...)␊ |
949 | {␊ |
950 | va_list ap;␊ |
951 | gErrors = true;␊ |
952 | va_start(ap, fmt);␊ |
953 | ␉␊ |
954 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
955 | ␉{␊ |
956 | ␉␉prf(fmt, ap, putchar, 0);␊ |
957 | }␊ |
958 | ␉else␊ |
959 | ␉{␊ |
960 | ␉␉vprf(fmt, ap);␊ |
961 | ␉}␊ |
962 | ␉␊ |
963 | ␉va_end(ap);␊ |
964 | return(0);␊ |
965 | }␊ |
966 | ␊ |
967 | int GUI_verbose(const char * fmt, ...)␊ |
968 | {␊ |
969 | va_list ap;␊ |
970 | ␊ |
971 | ␉va_start(ap, fmt);␊ |
972 | if (gVerboseMode)␊ |
973 | {␊ |
974 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
975 | ␉␉{␊ |
976 | ␉␉␉prf(fmt, ap, putchar, 0);␊ |
977 | ␉␉}␊ |
978 | ␉␉else␊ |
979 | ␉␉{␊ |
980 | ␉␉␉vprf(fmt, ap);␊ |
981 | ␉␉}␊ |
982 | }␊ |
983 | ␉␊ |
984 | ␉/* Kabyl: BooterLog */␊ |
985 | ␉struct putc_info pi;␊ |
986 | ␉␊ |
987 | ␉if (!msgbuf)␊ |
988 | ␉␉return 0;␊ |
989 | ␉␊ |
990 | ␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
991 | ␉␉return 0;␊ |
992 | ␉pi.str = cursor;␊ |
993 | ␉pi.last_str = 0;␊ |
994 | ␉prf(fmt, ap, sputc, &pi);␊ |
995 | ␉cursor += strlen((char *)cursor);␊ |
996 | ␉␊ |
997 | ␉␊ |
998 | va_end(ap);␊ |
999 | return(0);␊ |
1000 | }␊ |
1001 | ␊ |
1002 | int GUI_printf(const char * fmt, ...)␊ |
1003 | {␊ |
1004 | va_list ap;␊ |
1005 | ␉va_start(ap, fmt);␊ |
1006 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
1007 | ␉{␊ |
1008 | ␉␉prf(fmt, ap, putchar, 0);␊ |
1009 | ␉}␊ |
1010 | ␉else␊ |
1011 | ␉{␊ |
1012 | ␉␉vprf(fmt, ap);␊ |
1013 | ␉}␊ |
1014 | ␉␊ |
1015 | ␉/* Kabyl: BooterLog */␊ |
1016 | ␉struct putc_info pi;␊ |
1017 | ␉␊ |
1018 | ␉if (!msgbuf)␊ |
1019 | ␉␉return 0;␊ |
1020 | ␉␊ |
1021 | ␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
1022 | ␉␉return 0;␊ |
1023 | ␉pi.str = cursor;␊ |
1024 | ␉pi.last_str = 0;␊ |
1025 | ␉prf(fmt, ap, sputc, &pi);␊ |
1026 | ␉cursor += strlen((char *)cursor);␊ |
1027 | ␉␊ |
1028 | ␉va_end(ap);␊ |
1029 | return 0;␊ |
1030 | }␊ |
1031 | ␊ |
1032 | void GUI_stop(const char * fmt, ...)␊ |
1033 | {␊ |
1034 | ␉va_list ap;␊ |
1035 | ␉␊ |
1036 | ␉printf("\n");␊ |
1037 | ␉va_start(ap, fmt);␊ |
1038 | ␉␊ |
1039 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
1040 | ␉{␊ |
1041 | ␉␉prf(fmt, ap, putchar, 0);␊ |
1042 | ␉} ␊ |
1043 | ␉else ␊ |
1044 | ␉{␊ |
1045 | ␉␉vprf(fmt, ap);␊ |
1046 | ␉}␊ |
1047 | ␉va_end(ap);␊ |
1048 | ␉␊ |
1049 | ␉printf("\nThis is a non recoverable error! System HALTED!!!");␊ |
1050 | ␉halt();␊ |
1051 | ␉while (1);␊ |
1052 | }␊ |
1053 | ␊ |
1054 | void GUI_showHelp(void)␊ |
1055 | {␊ |
1056 | ␉if (bootArgs->Video.v_display == GRAPHICS_MODE) {␊ |
1057 | ␉␉showInfoBox("Help. Press q to quit.\n", (char *)BootHelp_txt);␊ |
1058 | ␉} else {␊ |
1059 | ␉␉showTextBuffer((char *)BootHelp_txt, BootHelp_txt_len);␊ |
1060 | ␉}␊ |
1061 | }␊ |
1062 |