Index: branches/meklort/artwork/themes/embed/theme.plist =================================================================== --- branches/meklort/artwork/themes/embed/theme.plist (revision 531) +++ branches/meklort/artwork/themes/embed/theme.plist (revision 532) @@ -6,26 +6,22 @@ Blackosx Version 1.0 - Enabled no - screen_width 1024 screen_height - 768 + 600 screen_textmargin_h 10 screen_textmargin_v 10 screen_bgcolor #767f73 - background_pos_x 50% background_pos_y 0 - logo_pos_x logo_pos_y @@ -34,7 +30,6 @@ #000000 logo_transparency 255 - devices_pos_x devices_pos_y @@ -49,7 +44,6 @@ 35 devices_layout horizontal - bootprompt_pos_x bootprompt_pos_y @@ -66,7 +60,6 @@ #3e3e3e bootprompt_transparency 1 - infobox_pos_x infobox_pos_y @@ -83,7 +76,6 @@ #3e3e3e infobox_transparency 35 - menu_pos_x menu_pos_y @@ -96,7 +88,6 @@ #3e3e3e menu_transparency 1 - progressbar_pos_x progressbar_pos_y @@ -105,12 +96,10 @@ 100 progressbar_height 40 - countdown_pos_x countdown_pos_y -20% - boot_width 1024 boot_height Index: branches/meklort/i386/boot2/modules.c =================================================================== --- branches/meklort/i386/boot2/modules.c (revision 531) +++ branches/meklort/i386/boot2/modules.c (revision 532) @@ -545,6 +545,7 @@ case REBASE_OPCODE_SET_TYPE_IMM: // Set rebase type (pointer, absolute32, pcrel32) //printf("Rebase type = 0x%X\n", immediate); + //getc(); // NOTE: This is currently NOT used type = immediate; break; @@ -608,7 +609,7 @@ case REBASE_OPCODE_DO_REBASE_IMM_TIMES: index = 0; for (index = 0; index < immediate; ++index) { - rebase_location(base + segmentAddress, (char*)base); + rebase_location(base + segmentAddress, (char*)base, type); segmentAddress += sizeof(void*); } break; @@ -627,7 +628,7 @@ index = 0; for (index = 0; index < tmp; ++index) { //DBG("\tRebasing 0x%X\n", segmentAddress); - rebase_location(base + segmentAddress, (char*)base); + rebase_location(base + segmentAddress, (char*)base, type); segmentAddress += sizeof(void*); } break; @@ -642,7 +643,7 @@ } while(rebase_stream[i] & 0x80); - rebase_location(base + segmentAddress, (char*)base); + rebase_location(base + segmentAddress, (char*)base, type); segmentAddress += tmp + sizeof(void*); break; @@ -669,7 +670,8 @@ index = 0; for (index = 0; index < tmp; ++index) { - rebase_location(base + segmentAddress, (char*)base); + + rebase_location(base + segmentAddress, (char*)base, type); segmentAddress += tmp2 + sizeof(void*); } @@ -835,10 +837,7 @@ { address = segmentAddress + (UInt32)base; - ((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0; - ((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8; - ((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16; - ((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24; + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); } else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) { @@ -867,11 +866,8 @@ if(symbolAddr != 0xFFFFFFFF) { address = segmentAddress + (UInt32)base; - - ((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0; - ((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8; - ((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16; - ((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24; + + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); } else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) { @@ -888,11 +884,8 @@ if(symbolAddr != 0xFFFFFFFF) { address = segmentAddress + (UInt32)base; - - ((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0; - ((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8; - ((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16; - ((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24; + + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); } else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0) { @@ -934,12 +927,9 @@ { address = segmentAddress + (UInt32)base; + + bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER); - ((char*)address)[0] = (symbolAddr & 0x000000FF) >> 0; - ((char*)address)[1] = (symbolAddr & 0x0000FF00) >> 8; - ((char*)address)[2] = (symbolAddr & 0x00FF0000) >> 16; - ((char*)address)[3] = (symbolAddr & 0xFF000000) >> 24; - segmentAddress += tmp2 + sizeof(void*); } } @@ -956,11 +946,43 @@ } } -inline void rebase_location(UInt32* location, char* base) -{ - *location += (UInt32)base; +inline void rebase_location(UInt32* location, char* base, int type) +{ + switch(type) + { + case REBASE_TYPE_POINTER: + case REBASE_TYPE_TEXT_ABSOLUTE32: + *location += (UInt32)base; + break; + + default: + break; + } } +inline void bind_location(UInt32* location, char* value, UInt32 addend, int type) +{ + // do actual update + char* newValue = value + addend; + + switch (type) { + case BIND_TYPE_POINTER: + case BIND_TYPE_TEXT_ABSOLUTE32: + break; + + case BIND_TYPE_TEXT_PCREL32: + newValue -= ((UInt32)location + 4); + + break; + default: + return; + } + *location = (UInt32)newValue; + + +} + + /* * add_symbol * This function adds a symbol from a module to the list of known symbols Index: branches/meklort/i386/boot2/modules.h =================================================================== --- branches/meklort/i386/boot2/modules.h (revision 531) +++ branches/meklort/i386/boot2/modules.h (revision 532) @@ -7,6 +7,12 @@ #include #include + +// There is a bug with the module system / rebasing / binding +// that causes static variables to be incorrectly rebased or bound +// Disable static variables for the moment +#define static + #ifndef __BOOT_MODULES_H #define __BOOT_MODULES_H @@ -69,7 +75,8 @@ int execute_hook(const char* name, void*, void*, void*, void*); void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*)); -inline void rebase_location(UInt32* location, char* base); +inline void rebase_location(UInt32* location, char* base, int type); +inline void bind_location(UInt32* location, char* value, UInt32 addend, int type); void rebase_macho(void* base, char* rebase_stream, UInt32 size); void bind_macho(void* base, char* bind_stream, UInt32 size); Index: branches/meklort/i386/boot2/options.c =================================================================== --- branches/meklort/i386/boot2/options.c (revision 531) +++ branches/meklort/i386/boot2/options.c (revision 532) @@ -1091,7 +1091,7 @@ //========================================================================== // Load the help file and display the file contents on the screen. -static void showTextBuffer(char *buf, int size) +void showTextBuffer(char *buf, int size) { char *bp; int line; Index: branches/meklort/i386/modules/GUI/gui.c =================================================================== --- branches/meklort/i386/modules/GUI/gui.c (revision 531) +++ branches/meklort/i386/modules/GUI/gui.c (revision 532) @@ -22,7 +22,7 @@ #define IMG_REQUIRED -1 #define THEME_NAME_DEFAULT "Default" -static const char *theme_name = THEME_NAME_DEFAULT; +static const char* theme_name = THEME_NAME_DEFAULT; #ifdef EMBED_THEME #include "art.h" @@ -169,14 +169,14 @@ void colorFont(font_t *font, uint32_t color); void makeRoundedCorners(pixmap_t *p); -static int infoMenuSelection = 0; -static int infoMenuItemsCount = sizeof(infoMenuItems)/sizeof(infoMenuItems[0]); +int infoMenuSelection = 0; +int infoMenuItemsCount = sizeof(infoMenuItems)/sizeof(infoMenuItems[0]); -static bool infoMenuNativeBoot = false; +bool infoMenuNativeBoot = false; -static unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0}; // here we store the used screen resolution +unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0}; // here we store the used screen resolution -static int getImageIndexByName(const char *name) +int getImageIndexByName(const char *name) { int i; for (i = 0; i < sizeof(images) / sizeof(images[0]); i++) @@ -239,7 +239,6 @@ uint16_t width; uint16_t height; uint8_t *imagedata; - if ((strlen(image) + strlen(theme_name) + 20 ) > sizeof(dirspec)) { return 1; } @@ -250,6 +249,7 @@ images[i].image = malloc(sizeof(pixmap_t)); } sprintf(dirspec, "/Extra/Themes/%s/%s.png", theme_name, image); + width = 0; height = 0; imagedata = NULL; @@ -811,7 +811,7 @@ if (isSelected) { blend(images[iSelection].image, buffer, centeredAt(images[iSelection].image, p)); - devicetype++; + devicetype++; // selec override image } // draw icon @@ -888,8 +888,8 @@ gui.debug.cursor = pos( 10, 100); dprintf( &gui.screen, "label %s\n", param->label ); dprintf( &gui.screen, "biosdev 0x%x\n", param->biosdev ); - dprintf(&gui.screen, "width %d\n", gui.screen.width); - dprintf(&gui.screen, "height %d\n", gui.screen.height); + dprintf( &gui.screen, "width %d\n", gui.screen.width); + dprintf( &gui.screen, "height %d\n", gui.screen.height); dprintf( &gui.screen, "type 0x%x\n", param->type ); dprintf( &gui.screen, "flags 0x%x\n", param->flags ); dprintf( &gui.screen, "part_no %d\n", param->part_no ); @@ -1712,15 +1712,21 @@ for ( i = 0, n = iMenuBoot; i < infoMenuItemsCount; i++, n++) { if (i == infoMenuSelection) + { blend(selection, gui.menu.pixmap, position); + } pbuff = images[n].image; if (offset && i >= INFOMENU_NATIVEBOOT_START && i <= INFOMENU_NATIVEBOOT_END) + { blend( images[n + (iMenuHelp - iMenuBoot)].image , gui.menu.pixmap, pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2))); + } else + { blend( pbuff, gui.menu.pixmap, pos((position.x + (gui.menu.hborder / 2)), position.y + ((selection->height - pbuff->height) / 2))); + } drawStr(infoMenuItems[i].text, &font_console, gui.menu.pixmap, pos(position.x + (pbuff->width + gui.menu.hborder), @@ -1752,14 +1758,19 @@ if (infoMenuSelection > 0) { if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_END + 1) + { infoMenuSelection -= 4; - + } else + { infoMenuSelection--; + } drawInfoMenuItems(); updateVRAM(); - } else { + } + else + { gui.menu.draw = false; gui.redraw = true; @@ -1807,7 +1818,7 @@ uint16_t bootImageWidth = 0; uint16_t bootImageHeight = 0; uint8_t *bootImageData = NULL; -static bool usePngImage = true; +bool usePngImage = true; //========================================================================== // loadBootGraphics Index: branches/meklort/i386/modules/GUI/GUI_module.c =================================================================== --- branches/meklort/i386/modules/GUI/GUI_module.c (revision 531) +++ branches/meklort/i386/modules/GUI/GUI_module.c (revision 532) @@ -7,6 +7,8 @@ #include "options.h" #include "graphic_utils.h" #include "ramdisk.h" +#include "embedded.h" + #include "picopng.h" #include "gui.h" @@ -29,6 +31,7 @@ static void GUI_showBootPrompt(int row, bool visible); static void GUI_showMenu( const MenuItem * items, int count, int selection, int row, int height ); static int GUI_updateMenu( int key, void ** paramPtr ); +static void GUI_showHelp(void); int GUI_printf(const char * fmt, ...); int GUI_verbose(const char * fmt, ...); @@ -45,7 +48,10 @@ extern char *msgbuf; extern char *cursor; - +/** + ** The kernel is about to start, draw the boot graphics if we are not in + ** verbose mode. + **/ void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4) { if(!gVerboseMode) @@ -55,6 +61,9 @@ } +/** + ** A boot option has been selected, disable the graphical elements on screen. + **/ void GUI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4) { // Turn off any GUI elements @@ -70,20 +79,25 @@ } } - +/** + ** Module startup code. Replace console only print functions as well as + ** replace various menu functions. Finaly, initialize the gui and hook + ** into important events. + **/ void GUI_start() { replace_function("_initGraphicsMode", &GUI_initGraphicsMode); replace_function("_getBootOptions", &GUI_getBootOptions); replace_function("_clearBootArgs", &GUI_clearBootArgs); + replace_function("_showHelp", &GUI_showHelp); replace_function("_printf", &GUI_printf); replace_function("_verbose", &GUI_verbose); replace_function("_error", &GUI_error); replace_function("_stop", &GUI_stop); - - // Start the gui + // Start the gui + useGUI = true; // Override useGUI default getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig); @@ -98,6 +112,9 @@ register_hook_callback("PreBoot", &GUI_PreBoot_hook); } +/** + ** Overriden chameleon function. Draws the updated menu. + **/ static int GUI_updateMenu( int key, void ** paramPtr ) { int moved = 0; @@ -206,16 +223,24 @@ { case 0x4800: // Up Arrow if ( gMenuSelection != gMenuTop ) + { draw.f.selectionUp = 1; + } else if ( gMenuTop > 0 ) + { draw.f.scrollDown = 1; + } break; case 0x5000: // Down Arrow if ( gMenuSelection != gMenuBottom ) + { draw.f.selectionDown = 1; + } else if ( gMenuBottom < (gMenuItemCount - 1) ) + { draw.f.scrollUp = 1; + } break; } } @@ -275,9 +300,11 @@ printMenuItem( &gMenuItems[gMenuSelection], 1 ); restoreCursor( &cursorState ); - } else - + } + else + { drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection); + } } @@ -290,7 +317,7 @@ static void GUI_showMenu( const MenuItem * items, int count, - int selection, int row, int height ) + int selection, int row, int height ) { int i; CursorState cursorState; @@ -330,10 +357,11 @@ // Draw the visible items. if( bootArgs->Video.v_display == GRAPHICS_MODE ) - + { drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection); - - else { + } + else + { changeCursor( 0, row, kCursorTypeHidden, &cursorState ); @@ -369,7 +397,9 @@ setCursorPosition( x, y, 0 ); putca(' ', 0x07, 1); } else + { updateGraphicBootPrompt(kBackspaceKey); + } *gBootArgsPtr-- = '\0'; } @@ -380,9 +410,13 @@ if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd) { if( bootArgs->Video.v_display == VGA_TEXT_MODE ) + { putchar(key); // echo to screen + } else + { updateGraphicBootPrompt(key); + } *gBootArgsPtr++ = key; } @@ -396,25 +430,36 @@ extern char bootPrompt[]; extern char bootRescanPrompt[]; - if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { + if( bootArgs->Video.v_display == VGA_TEXT_MODE ) + { changeCursor( 0, row, kCursorTypeUnderline, 0 ); clearScreenRows( row, kScreenLastRow ); } clearBootArgs(); - if (visible) { - if (bootArgs->Video.v_display == VGA_TEXT_MODE) { - if (gEnableCDROMRescan) { + if (visible) + { + if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { + if (gEnableCDROMRescan) + { printf( bootRescanPrompt ); - } else { + } + else + { printf( bootPrompt ); } } - } else { - if (bootArgs->Video.v_display == GRAPHICS_MODE) { + } + else + { + if (bootArgs->Video.v_display == GRAPHICS_MODE) + { clearGraphicBootPrompt(); - } else { + } + else + { printf("Press Enter to start up the foreign OS. "); } } @@ -426,7 +471,8 @@ gBootArgsPtr = gBootArgs; memset(gBootArgs, '\0', BOOT_STRING_LEN); - if (bootArgs->Video.v_display == GRAPHICS_MODE) { + if (bootArgs->Video.v_display == GRAPHICS_MODE) + { clearGraphicBootPrompt(); } } @@ -446,9 +492,12 @@ // Initialize default menu selection entry. gBootVolume = menuBVR = selectBootVolume(bvChain); - if (biosDevIsCDROM(gBIOSDev)) { + if (biosDevIsCDROM(gBIOSDev)) + { isCDROM = true; - } else { + } + else + { isCDROM = false; } @@ -462,7 +511,8 @@ clearBootArgs(); // Allow user to override default timeout. - if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig)) { + if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->bootConfig)) + { /* If there is no timeout key in the file use the default timeout which is different for CDs vs. hard disks. However, if not booting a CD and no config file could be loaded set the timeout @@ -472,49 +522,60 @@ If some partitions are found, for example a Windows partition, then these will be displayed in the menu as foreign partitions. */ - if (isCDROM) { + if (isCDROM) + { timeout = kCDBootTimeout; - } else { + } + else + { timeout = sysConfigValid ? kBootTimeout : 0; } } - if (timeout < 0) { + if (timeout < 0) + { gBootMode |= kBootModeQuiet; } // If the user is holding down a modifier key, enter safe mode. - if ((readKeyboardShiftFlags() & 0x0F) != 0) { + if ((readKeyboardShiftFlags() & 0x0F) != 0) + { //gBootMode |= kBootModeSafe; } // Checking user pressed keys bool f8press = false, spress = false, vpress = false; - while (readKeyboardStatus()) { + while (readKeyboardStatus()) + { key = bgetc (); if (key == 0x4200) f8press = true; if ((key & 0xff) == 's' || (key & 0xff) == 'S') spress = true; if ((key & 0xff) == 'v' || (key & 0xff) == 'V') vpress = true; } // If user typed F8, abort quiet mode, and display the menu. - if (f8press) { + if (f8press) + { gBootMode &= ~kBootModeQuiet; timeout = 0; } // If user typed 'v' or 'V', boot in verbose mode. - if ((gBootMode & kBootModeQuiet) && firstRun && vpress) { + if ((gBootMode & kBootModeQuiet) && firstRun && vpress) + { addBootArg(kVerboseModeFlag); } // If user typed 's' or 'S', boot in single user mode. - if ((gBootMode & kBootModeQuiet) && firstRun && spress) { + if ((gBootMode & kBootModeQuiet) && firstRun && spress) + { addBootArg(kSingleUserModeFlag); } - if (bootArgs->Video.v_display == VGA_TEXT_MODE) { + if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { setCursorPosition(0, 0, 0); clearScreenRows(0, kScreenLastRow); - if (!(gBootMode & kBootModeQuiet)) { + if (!(gBootMode & kBootModeQuiet)) + { // Display banner and show hardware info. printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024); printf(getVBEInfoString()); @@ -524,17 +585,21 @@ } // When booting from CD, default to hard drive boot when possible. - if (isCDROM && firstRun) { + if (isCDROM && firstRun) + { const char *val; char *prompt = NULL; char *name = NULL; int cnt; int optionKey; - if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) { + if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) + { prompt = malloc(cnt + 1); strncat(prompt, val, cnt); - } else { + } + else + { name = malloc(80); getBootVolumeDescription(gBootVolume, name, 79, false); prompt = malloc(256); @@ -542,9 +607,12 @@ free(name); } - if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) { + if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) + { // The key specified is a special key. - } else { + } + else + { // Default to F8. optionKey = 0x4200; } @@ -554,30 +622,39 @@ // which we ought to interpret as meaning he wants to boot the CD. if (timeout != 0) { key = GUI_countdown(prompt, kMenuTopRow, timeout); - } else { + } + else + { key = optionKey; } - if (prompt != NULL) { + if (prompt != NULL) + { free(prompt); } clearScreenRows( kMenuTopRow, kMenuTopRow + 2 ); // Hit the option key ? - if (key == optionKey) { + if (key == optionKey) + { gBootMode &= ~kBootModeQuiet; timeout = 0; - } else { + } + else + { key = key & 0xFF; // Try booting hard disk if user pressed 'h' - if (biosDevIsCDROM(gBIOSDev) && key == 'h') { + if (biosDevIsCDROM(gBIOSDev) && key == 'h') + { BVRef bvr; // Look at partitions hosting OS X other than the CD-ROM - for (bvr = bvChain; bvr; bvr=bvr->next) { - if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev) { + for (bvr = bvChain; bvr; bvr=bvr->next) + { + if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev) + { gBootVolume = bvr; } } @@ -586,33 +663,41 @@ } } - if (gBootMode & kBootModeQuiet) { + if (gBootMode & kBootModeQuiet) + { // No input allowed from user. goto done; } - if (firstRun && timeout > 0 && GUI_countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0) { + if (firstRun && timeout > 0 && GUI_countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0) + { // If the user is holding down a modifier key, // enter safe mode. - if ((readKeyboardShiftFlags() & 0x0F) != 0) { + if ((readKeyboardShiftFlags() & 0x0F) != 0) + { gBootMode |= kBootModeSafe; } goto done; } - if (gDeviceCount) { + if (gDeviceCount) + { // Allocate memory for an array of menu items. menuItems = malloc(sizeof(MenuItem) * gDeviceCount); - if (menuItems == NULL) { + if (menuItems == NULL) + { goto done; } // Associate a menu item for each BVRef. - for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) { - if (bvr->visible) { + for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) + { + if (bvr->visible) + { getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true); menuItems[i].param = (void *) bvr; - if (bvr == menuBVR) { + if (bvr == menuBVR) + { selectIndex = i; } i--; @@ -620,18 +705,21 @@ } } - if (bootArgs->Video.v_display == GRAPHICS_MODE) { + if (bootArgs->Video.v_display == GRAPHICS_MODE) + { // redraw the background buffer gui.logo.draw = true; drawBackground(); gui.devicelist.draw = true; gui.redraw = true; - if (!(gBootMode & kBootModeQuiet)) { + if (!(gBootMode & kBootModeQuiet)) + { bool showBootBanner = true; // Check if "Boot Banner"=N switch is present in config file. getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig); - if (showBootBanner) { + if (showBootBanner) + { // Display banner and show hardware info. gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024); } @@ -639,7 +727,9 @@ // redraw background memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4); } - } else { + } + else + { // Clear screen and hide the blinking cursor. clearScreenRows(kMenuTopRow, kMenuTopRow + 2); changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0); @@ -648,8 +738,10 @@ nextRow = kMenuTopRow; showPrompt = true; - if (gDeviceCount) { - if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { + if (gDeviceCount) + { + if( bootArgs->Video.v_display == VGA_TEXT_MODE ) + { printf("Use \30\31 keys to select the startup volume."); } GUI_showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems ); @@ -661,7 +753,8 @@ GUI_showBootPrompt( nextRow, showPrompt ); do { - if (bootArgs->Video.v_display == GRAPHICS_MODE) { + if (bootArgs->Video.v_display == GRAPHICS_MODE) + { // redraw background memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 ); // reset cursor co-ords @@ -671,22 +764,27 @@ GUI_updateMenu( key, (void **) &menuBVR ); newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot); - if (newShowPrompt != showPrompt) { + if (newShowPrompt != showPrompt) + { showPrompt = newShowPrompt; GUI_showBootPrompt( nextRow, showPrompt ); } - if (showPrompt) { + if (showPrompt) + { GUI_updateBootArgs(key); } - switch (key) { + switch (key) + { case kReturnKey: - if (gui.menu.draw) { + if (gui.menu.draw) + { key=0; break; } - if (*gBootArgs == '?') { + if (*gBootArgs == '?') + { char * argPtr = gBootArgs; // Skip the leading "?" character. @@ -697,30 +795,50 @@ /* * TODO: this needs to be refactored. */ - if (strcmp( booterCommand, "video" ) == 0) { - if (bootArgs->Video.v_display == GRAPHICS_MODE) { + if (strcmp( booterCommand, "video" ) == 0) + { + if (bootArgs->Video.v_display == GRAPHICS_MODE) + { showInfoBox(getVBEInfoString(), getVBEModeInfoString()); - } else { + } + else + { printVBEModeInfo(); } - } else if ( strcmp( booterCommand, "memory" ) == 0) { - if (bootArgs->Video.v_display == GRAPHICS_MODE ) { + } + else if ( strcmp( booterCommand, "memory" ) == 0) + { + if (bootArgs->Video.v_display == GRAPHICS_MODE ) + { showInfoBox("Memory Map", getMemoryInfoString()); - } else { + } + else + { printMemoryInfo(); } - } else if (strcmp(booterCommand, "lspci") == 0) { + } + else if (strcmp(booterCommand, "lspci") == 0) + { lspci(); - } else if (strcmp(booterCommand, "more") == 0) { + } + else if (strcmp(booterCommand, "more") == 0) + { showTextFile(booterParam); - } else if (strcmp(booterCommand, "rd") == 0) { + } + else if (strcmp(booterCommand, "rd") == 0) + { processRAMDiskCommand(&argPtr, booterParam); - } else if (strcmp(booterCommand, "norescan") == 0) { - if (gEnableCDROMRescan) { + } + else if (strcmp(booterCommand, "norescan") == 0) + { + if (gEnableCDROMRescan) + { gEnableCDROMRescan = false; break; } - } else { + } + else + { showHelp(); } key = 0; @@ -741,7 +859,8 @@ // Clear gBootVolume to restart the loop // if the user enabled rescanning the optical drive. // Otherwise boot the default boot volume. - if (gEnableCDROMRescan) { + if (gEnableCDROMRescan) + { gBootVolume = NULL; clearBootArgs(); } @@ -758,8 +877,10 @@ // New behavior: // Switch between text & graphic interfaces // Only Permitted if started in graphics interface - if (useGUI) { - if (bootArgs->Video.v_display == GRAPHICS_MODE) { + if (useGUI) + { + if (bootArgs->Video.v_display == GRAPHICS_MODE) + { setVideoMode(VGA_TEXT_MODE, 0); setCursorPosition(0, 0, 0); @@ -775,7 +896,8 @@ nextRow = kMenuTopRow; showPrompt = true; - if (gDeviceCount) { + if (gDeviceCount) + { printf("Use \30\31 keys to select the startup volume."); GUI_showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems); nextRow += min(gDeviceCount, kMenuMaxItems) + 3; @@ -784,7 +906,9 @@ showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot); GUI_showBootPrompt(nextRow, showPrompt); //changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 ); - } else { + } + else + { gui.redraw = true; setVideoMode(GRAPHICS_MODE, 0); updateVRAM(); @@ -800,13 +924,15 @@ } while (0 == key); done: - if (bootArgs->Video.v_display == VGA_TEXT_MODE) { + if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { clearScreenRows(kMenuTopRow, kScreenLastRow); changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0); } shouldboot = false; gui.menu.draw = false; - if (menuItems) { + if (menuItems) + { free(menuItems); menuItems = NULL; } @@ -820,10 +946,16 @@ va_list ap; gErrors = true; va_start(ap, fmt); + if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { prf(fmt, ap, putchar, 0); - else + } + else + { vprf(fmt, ap); + } + va_end(ap); return(0); } @@ -836,26 +968,29 @@ if (gVerboseMode) { if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { prf(fmt, ap, putchar, 0); + } else + { vprf(fmt, ap); + } } - { - /* Kabyl: BooterLog */ - struct putc_info pi; - - if (!msgbuf) - return 0; - - if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) - return 0; - pi.str = cursor; - pi.last_str = 0; - prf(fmt, ap, sputc, &pi); - cursor += strlen((char *)cursor); - } + /* Kabyl: BooterLog */ + struct putc_info pi; + if (!msgbuf) + return 0; + + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) + return 0; + pi.str = cursor; + pi.last_str = 0; + prf(fmt, ap, sputc, &pi); + cursor += strlen((char *)cursor); + + va_end(ap); return(0); } @@ -865,25 +1000,27 @@ va_list ap; va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { prf(fmt, ap, putchar, 0); + } else + { vprf(fmt, ap); - - { - /* Kabyl: BooterLog */ - struct putc_info pi; - - if (!msgbuf) - return 0; - - if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) - return 0; - pi.str = cursor; - pi.last_str = 0; - prf(fmt, ap, sputc, &pi); - cursor += strlen((char *)cursor); } + /* Kabyl: BooterLog */ + struct putc_info pi; + + if (!msgbuf) + return 0; + + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) + return 0; + pi.str = cursor; + pi.last_str = 0; + prf(fmt, ap, sputc, &pi); + cursor += strlen((char *)cursor); + va_end(ap); return 0; } @@ -894,13 +1031,27 @@ printf("\n"); va_start(ap, fmt); - if (bootArgs->Video.v_display == VGA_TEXT_MODE) { + + if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { prf(fmt, ap, putchar, 0); - } else { + } + else + { vprf(fmt, ap); } va_end(ap); + printf("\nThis is a non recoverable error! System HALTED!!!"); halt(); while (1); } + +void GUI_showHelp(void) +{ + if (bootArgs->Video.v_display == GRAPHICS_MODE) { + showInfoBox("Help. Press q to quit.\n", (char *)BootHelp_txt); + } else { + showTextBuffer((char *)BootHelp_txt, BootHelp_txt_len); + } +} Index: branches/meklort/i386/modules/GUI/graphic_utils.c =================================================================== --- branches/meklort/i386/modules/GUI/graphic_utils.c (revision 531) +++ branches/meklort/i386/modules/GUI/graphic_utils.c (revision 532) @@ -1,15 +1,15 @@ - /* Graphic utility functions and data types - * Prashant Vaibhav (C) 12/12/2008 - * Chameleon - */ +/* Graphic utility functions and data types + * Prashant Vaibhav (C) 12/12/2008 + * Chameleon + */ #include "boot.h" #include "graphic_utils.h" #include "gui.h" void blend( const pixmap_t *blendThis, // Source image - pixmap_t *blendInto, // Dest image - const position_t position) // Where to place the source image + pixmap_t *blendInto, // Dest image + const position_t position) // Where to place the source image { uint16_t sx, sy, dx, dy; uint32_t dstrb, dstag, srcrb, srcag, drb, dag, rb, ag, alpha; @@ -17,23 +17,26 @@ uint16_t width = (blendThis->width + position.x < blendInto->width) ? blendThis->width: blendInto->width-position.x; uint16_t height = (blendThis->height + position.y < blendInto->height) ? blendThis->height: blendInto->height-position.y; - for (dy = position.y, sy = 0; sy < height; dy++, sy++) { - for (dx = position.x, sx = 0; sx < width; dx++, sx++) { + for (dy = position.y, sy = 0; sy < height; dy++, sy++) + { + for (dx = position.x, sx = 0; sx < width; dx++, sx++) + { alpha = (pixel(blendThis, sx, sy).ch.a); - - /* Skip blending for fully transparent pixel */ - if (alpha == 0) continue; - - /* For fully opaque pixel, there is no need to interpolate */ - if (alpha == 255) { - pixel(blendInto, dx, dy).value = pixel(blendThis, sx, sy).value; - continue; - } - - /* For semi-transparent pixels, do a full blend */ - //alpha++ - /* This is needed to spread the alpha over [0..256] instead of [0..255] - Boundary conditions were handled above */ + + /* Skip blending for fully transparent pixel */ + if (alpha == 0) continue; + + /* For fully opaque pixel, there is no need to interpolate */ + if (alpha == 255) + { + pixel(blendInto, dx, dy).value = pixel(blendThis, sx, sy).value; + continue; + } + + /* For semi-transparent pixels, do a full blend */ + //alpha++ + /* This is needed to spread the alpha over [0..256] instead of [0..255] + Boundary conditions were handled above */ dstrb = pixel(blendInto, dx, dy).value & 0xFF00FF; dstag = (pixel(blendInto, dx, dy).value >> 8) & 0xFF00FF; srcrb = pixel(blendThis, sx, sy).value & 0xFF00FF;