Пример #1
0
static void GUI_showBootPrompt(int row, bool visible)
{
	extern char bootPrompt[];
	
	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)
			{
				printf( GUI_bootRescanPrompt );
			} 
			else
			{
				printf( bootPrompt );
			}
		}
	} 
	else
	{
		if (bootArgs->Video.v_display == GRAPHICS_MODE)
		{
			clearGraphicBootPrompt();
		} 
		else
		{
			printf("Press Enter to start up the foreign OS. ");
		}
	}
}
Пример #2
0
// Pressed on snapper
long ShutterBug::onPressSnapper(FXObject*,FXSelector sel,void* ptr){
  register FXint which=FXSELID(sel)-ID_SNAPPER_0;
  register FXEvent *event=(FXEvent*)ptr;
  if((event->state&CONTROLMASK) || (event->type!=SEL_LEFTBUTTONPRESS) || size){
    mode=MODE_WHOLERECT;
    spotx=event->root_x-rectangle.x;
    spoty=event->root_y-rectangle.y;
    }
  else{
    mode=where(event->root_x,event->root_y);
    if(mode&MODE_TOP) spoty=event->root_y-rectangle.y;
    else if(mode&MODE_BOTTOM) spoty=event->root_y-rectangle.y-rectangle.h;
    if(mode&MODE_LEFT) spotx=event->root_x-rectangle.x;
    else if(mode&MODE_RIGHT) spotx=event->root_x-rectangle.x-rectangle.w;
    }
  changeCursor(which,mode);
  snapper[0]->raise();
  snapper[1]->raise();
  snapper[2]->raise();
  snapper[3]->raise();
  raise();
  return 1;
  }
Пример #3
0
static void showBootPrompt(int row, bool visible)
{	
    char * bootPrompt = (char*)(uint32_t)get_env(envBootPrompt);
    char * bootRescanPrompt = (char*)(uint32_t)get_env(envBootRescanPrompt);
	
	changeCursor( 0, row, kCursorTypeUnderline, 0 );    
	clearScreenRows( row, kScreenLastRow );
	
	clearBootArgs();
	
	if (visible) {
        
		if (get_env(envgEnableCDROMRescan))
		{
			printf( "%s",bootRescanPrompt );
		}
		else
		{
            printf( "%s",bootPrompt );
		}
	} else {
		printf("Press Enter to start up the foreign OS. ");
	}
}
Пример #4
0
void askDisk(int16 discNumber) {
	char fileName[256];
	char string[256];
	char messageDrawn = 0;

	if (discNumber != -1) {
		currentDiskNumber = discNumber;
	}
	// skip drive selection stuff

	sprintf(fileName, "VOL.%d", currentDiskNumber);

	sprintf(string, "INSERER LE DISQUE %d EN ", currentDiskNumber);

	//while (Common::File::exists((const char*)fileName))
	{
		if (!messageDrawn) {
			drawMsgString(string);
			messageDrawn = 1;
		}
	}

	changeCursor(currentCursor);
}
Пример #5
0
void CursorManager::setDownCursor() {
	changeCursor("downarrow");
}
Пример #6
0
void CursorManager::setUpCursor() {
	changeCursor("zuparrow");
}
Пример #7
0
void CursorManager::setRightCursor() {
	changeCursor("rightarrow");
}
Пример #8
0
static int updateMenu( int key, void ** paramPtr )
{
    int moved = 0;

    union {
        struct {
            unsigned int
                selectionUp   : 1,
                selectionDown : 1,
                scrollUp      : 1,
                scrollDown    : 1;
        } f;
        unsigned int w;
    } draw = {{0}};

    if ( NULL == gMenuItems ) return 0;

    // Look at the scan code.

    switch ( key )
    {
        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;
    }

    if ( draw.w )
    {
        if ( draw.f.scrollUp )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);
            gMenuTop++; gMenuBottom++;
            draw.f.selectionDown = 1;
        }

        if ( draw.f.scrollDown )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);
            gMenuTop--; gMenuBottom--;
            draw.f.selectionUp = 1;
        }

        if ( draw.f.selectionUp || draw.f.selectionDown )
        {
            CursorState cursorState;

            // Set cursor at current position, and clear inverse video.

            changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop,
                          kCursorTypeHidden, &cursorState );

            printMenuItem( &gMenuItems[gMenuSelection], 0 );

            if ( draw.f.selectionUp ) gMenuSelection--;
            else                      gMenuSelection++;

            moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );

            printMenuItem( &gMenuItems[gMenuSelection], 1 );

            restoreCursor( &cursorState );
        }

        *paramPtr = gMenuItems[gMenuSelection].param;        
        moved = 1;
    }

    return moved;
}
Пример #9
0
int getBootOptions(bool firstRun)
{
	int     i;
	int     key;
	int     nextRow;
	int     timeout;
	int     bvCount;
	BVRef   bvr;
	BVRef   menuBVR;
	bool    showPrompt, newShowPrompt, isCDROM;

	// Initialize default menu selection entry.
	gBootVolume = menuBVR = selectBootVolume(bvChain);

	if (biosDevIsCDROM(gBIOSDev)) {
		isCDROM = true;
	} else {
		isCDROM = false;
	}

	// ensure we're in graphics mode if gui is setup
	if (gui.initialised && bootArgs->Video.v_display == VGA_TEXT_MODE)
	{
		setVideoMode(GRAPHICS_MODE, 0);
	}

	// Clear command line boot arguments
	clearBootArgs();

	// Allow user to override default timeout.
	if (multiboot_timeout_set) {
		timeout = multiboot_timeout;
	} else 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
		    to zero which causes the menu to display immediately.
		    This way, if no partitions can be found, that is the disk is unpartitioned
		    or simply cannot be read) then an empty menu is displayed.
		    If some partitions are found, for example a Windows partition, then
		    these will be displayed in the menu as foreign partitions.
		 */
		if (isCDROM) {
			timeout = kCDBootTimeout;
		} else {
			timeout = sysConfigValid ? kBootTimeout : 0;
		}
	}

	if (timeout < 0) {
		gBootMode |= kBootModeQuiet;
	}

	// If the user is holding down a modifier key, enter safe mode.
	if ((readKeyboardShiftFlags() & 0x0F) != 0) {
		gBootMode |= kBootModeSafe;
	}

	//	 18seven's Quick-args macro
		bool f8 = false, altf = false, shiftf = false, alts = false, 
		altv = false, altx = false; // x32 = false,  x64 = false;
		while (readKeyboardStatus())
		{
			key = bgetc ();
			if (key == 0x4200) f8 = true;
			if (key == 0x2100) altf = true;
			if (key == 0x0046) shiftf = true;
			if (key == 0x1F00) alts = true;
			if (key == 0x2F00) altv = true;
			if (key == 0x2D00) altx = true;
/*			if (key == 0x0004) x32 = true;
			if (key == 0x0007) x64 = true;
*/		}

	// If user typed F8, abort quiet mode, and display the menu.
	if (f8) {
		gBootMode &= ~kBootModeQuiet;
		timeout = 0;
	}

	// If user typed 'alt-v', boot in verbose mode.
	if ((gBootMode & kBootModeQuiet) && firstRun && altv) {
		addBootArg(kVerboseModeFlag);
	}

	// If user typed 'alt-s', boot in single user mode.
	if ((gBootMode & kBootModeQuiet) && firstRun && alts) {
		addBootArg(kSingleUserModeFlag);
	}

	if ((gBootMode & kBootModeQuiet) && firstRun && altf) {
		addBootArg(kIgnoreCachesFlag);
	}

	if ((gBootMode & kBootModeQuiet) && firstRun && shiftf) {
		addBootArg(kIgnoreBootFileFlag);
	}

	if ((gBootMode & kBootModeQuiet) && firstRun && altx) {
		addBootArg(kSafeModeFlag);
	}
/*
	if ((gBootMode & kBootModeQuiet) && firstRun && x32) {
		addBootArg(k32BitModeFlag);
	}

	if ((gBootMode & kBootModeQuiet) && firstRun && x64) {
		addBootArg(k64BitModeFlag);
	}
*/
	if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
		setCursorPosition(0, 0, 0);
		clearScreenRows(0, kScreenLastRow);
		if (!(gBootMode & kBootModeQuiet)) {
			// Display banner and show hardware info.
			printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);
			printf(getVBEInfoString());
		}
		changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
		verbose("Scanning device %x...", gBIOSDev);
	}

	// When booting from CD, default to hard drive boot when possible.
	if (isCDROM && firstRun) {
		const char *val;
		char *prompt = NULL;
		char *name = NULL;
		int cnt;
		int optionKey;

		if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) {
			prompt = malloc(cnt + 1);
			strncat(prompt, val, cnt);
		} else {
			name = malloc(80);
			getBootVolumeDescription(gBootVolume, name, 79, false);
			prompt = malloc(256);
			sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
			free(name);
		}

		if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) {
			// The key specified is a special key.
		} else {
			// Default to F8.
			optionKey = 0x4200;
		}

		// If the timeout is zero then it must have been set above due to the
		// early catch of F8 which means the user wants to set boot options
		// which we ought to interpret as meaning he wants to boot the CD.
		if (timeout != 0) {
			key = countdown(prompt, kMenuTopRow, timeout);
		} else {
			key = optionKey;
		}

		if (prompt != NULL) {
			free(prompt);
		}

		clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );

		// Hit the option key ?
		if (key == optionKey) {
			gBootMode &= ~kBootModeQuiet;
			timeout = 0;
		} else {
			key = key & 0xFF;

			// Try booting hard disk if user pressed '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) {
						gBootVolume = bvr;
					}
				}
			}
			goto done;
		}
	}

	if (gBootMode & kBootModeQuiet) {
		// No input allowed from user.
		goto done;
	}

	if (firstRun && timeout > 0 && 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) {
			gBootMode |= kBootModeSafe;
		}
		goto done;
	}

	if (gDeviceCount) {
		// Allocate memory for an array of menu items.
		menuItems = malloc(sizeof(MenuItem) * gDeviceCount);
		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) {
				getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true);
				menuItems[i].param = (void *) bvr;
				if (bvr == menuBVR) {
					selectIndex = i;
				}
				i--;
			}
		}
	}

	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)) {
			bool showBootBanner = true;
 
			// Check if "Boot Banner"=N switch is present in config file.
			getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig); 
			if (showBootBanner) {
				// Display banner and show hardware info.
				gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);
			}

			// redraw background
			memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);
		}
	} else {
		// Clear screen and hide the blinking cursor.
		clearScreenRows(kMenuTopRow, kMenuTopRow + 2);
		changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);
	}

	nextRow = kMenuTopRow;
	showPrompt = true;

	if (gDeviceCount) {
		if( bootArgs->Video.v_display == VGA_TEXT_MODE ) {
			printf("Use \30\31 keys to select the startup volume.");
		}
		showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
		nextRow += min( gDeviceCount, kMenuMaxItems ) + 3;
	}

	// Show the boot prompt.
	showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
	showBootPrompt( nextRow, showPrompt );
	
	do {
		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
			gui.debug.cursor = pos( gui.screen.width - 160 , 10 );
		}
		key = getc();
		updateMenu( key, (void **) &menuBVR );
		newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);

		if (newShowPrompt != showPrompt) {
			showPrompt = newShowPrompt;
			showBootPrompt( nextRow, showPrompt );
		}

		if (showPrompt) {
			updateBootArgs(key);
		}

		switch (key) {
		case kReturnKey:
			if (gui.menu.draw) { 
				key=0;
				break;
			}
			if (*gBootArgs == '?') {
				char * argPtr = gBootArgs;

				// Skip the leading "?" character.
				argPtr++;
				getNextArg(&argPtr, booterCommand);
				getNextArg(&argPtr, booterParam);

				/*
				* TODO: this needs to be refactored.
				*/
				if (strcmp( booterCommand, "video" ) == 0) {
					if (bootArgs->Video.v_display == GRAPHICS_MODE) {
						showInfoBox(getVBEInfoString(), getVBEModeInfoString());
					} else {
						printVBEModeInfo();
					}
				} else if ( strcmp( booterCommand, "memory" ) == 0) {
					if (bootArgs->Video.v_display == GRAPHICS_MODE ) {
						showInfoBox("Memory Map", getMemoryInfoString());
					} else {
						printMemoryInfo();
					}
				} else if (strcmp(booterCommand, "lspci") == 0) {
					lspci();
				} else if (strcmp(booterCommand, "more") == 0) {
					showTextFile(booterParam);
				} else if (strcmp(booterCommand, "rd") == 0) {
					processRAMDiskCommand(&argPtr, booterParam);
				} else if (strcmp(booterCommand, "norescan") == 0) {
					if (gEnableCDROMRescan) {
						gEnableCDROMRescan = false;
						break;
					}
				} else {
					showHelp();
				}
				key = 0;
				showBootPrompt(nextRow, showPrompt);
				break;
			}
			gBootVolume = menuBVR;
			setRootVolume(menuBVR);
			gBIOSDev = menuBVR->biosdev;
			break;

		case kEscapeKey:
			clearBootArgs();
			break;
		
		case kF2Key:
			
			/*
			 * AutoResolution - Reapply the patch if Graphics Mode was incorrect or EDID Info was insane
			 */
			
			if ((gAutoResolution == TRUE) && map)
			{
				// get the new Graphics Mode key
				processBootOptions();
				
				UInt32 params[4];
				params[3] = 0;
				//Has the target Resolution Changed ?
				int count = getNumberArrayFromProperty(kGraphicsModeKey, params, 4);
				if ( count < 3 )
					getResolution(params);
				
				if ((params[0] != 0) && (params[1] != 0)
				&& (params[0] != map->currentX) && (params[1] != map->currentY))
				{
				
					//Go back to TEXT mode while we change  the mode
					if (bootArgs->Video.v_display == GRAPHICS_MODE)
					{
						CursorState cursorState;
						
						setVideoMode(VGA_TEXT_MODE, 0);
						
						setCursorPosition(0, 0, 0);
						clearScreenRows(0, kScreenLastRow);
						changeCursor( 0, 0, kCursorTypeHidden, &cursorState );
						
						//Reapply patch in case resolution have changed
						
						patchVbios(map, params[0], params[1], params[2], 0, 0);
						
						if (useGUI && (gui.initialised == true))
							initGUI();
						// Make sure all values are set
						if (bootArgs->Video.v_display != GRAPHICS_MODE)
							bootArgs->Video.v_display = GRAPHICS_MODE;
						
						if (!useGUI)
							useGUI = true;
						
						// redraw the background buffer
						drawBackground();
						gui.devicelist.draw = true;
						gui.redraw = true;
						if (!(gBootMode & kBootModeQuiet))
						{
							bool showBootBanner = true;
							
							// Check config file.
							getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->bootConfig); 
							if (showBootBanner)
								// Display banner and show hardware info.
								gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);
								
							// redraw background
							memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);
						}
						
						nextRow = kMenuTopRow;
						showPrompt = true;
						
						if (gDeviceCount)
						{
							showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
							nextRow += min( gDeviceCount, kMenuMaxItems ) + 3;
						}
						
						// Show the boot prompt.
						showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
						showBootPrompt( nextRow, showPrompt );
						
						//this is used to avoid resetting the incorrect mode while quiting the boot menu
						map->hasSwitched = true;
					}
				}
				clearBootArgs();
				key = 0;
			}
			break;

		case kF5Key:
			// New behavior:
			// Clear gBootVolume to restart the loop
			// if the user enabled rescanning the optical drive.
			// Otherwise boot the default boot volume.
			if (gEnableCDROMRescan) {
				gBootVolume = NULL;
				clearBootArgs();
			}
			break;

		case kF10Key:
			gScanSingleDrive = false;
			scanDisks(gBIOSDev, &bvCount);
			gBootVolume = NULL;
			clearBootArgs();
			break;

		case kTabKey:
			// New behavior:
			// Switch between text & graphic interfaces
			// Only Permitted if started in graphics interface
			if (useGUI)
			{
				setVideoMode(VGA_TEXT_MODE, 0);

				setCursorPosition(0, 0, 0);
				clearScreenRows(0, kScreenLastRow);

				// Display banner and show hardware info.
				printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);
				printf(getVBEInfoString());

				clearScreenRows(kMenuTopRow, kMenuTopRow + 2);
				changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);

				nextRow = kMenuTopRow;
				showPrompt = true;

				if (gDeviceCount)
				{
					printf("Use \30\31 keys to select the startup volume.");
					showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);
					nextRow += min(gDeviceCount, kMenuMaxItems) + 3;
				}

				showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
				showBootPrompt(nextRow, showPrompt);
				//changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );
				
				/*
				 * AutoResolution - make sure all values are set
				 */
				
				bootArgs->Video.v_display = VGA_TEXT_MODE;
				useGUI = false;
			}
			else
			{
				gui.redraw = true;
				setVideoMode(GRAPHICS_MODE, 0);
				
				/*
				 * AutoResolution - make sure all values are set
				 */
				bootArgs->Video.v_display = GRAPHICS_MODE;
				useGUI = true;
				
				updateVRAM();
			}
			key = 0;
			break;

		default:
			key = 0;
			break;
		}
	} while (0 == key);

done:
	if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
		clearScreenRows(kMenuTopRow, kScreenLastRow);
		changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
	}
	shouldboot = false;
	gui.menu.draw = false;
	if (menuItems) {
		free(menuItems);
		menuItems = NULL;
	}
	return 0;
}
Пример #10
0
void ThothWindow::changeTab()
{
    ui->tabWidget->setCurrentWidget(ui->decorate_tab);
    emit changeMouseMove(false);
    emit changeCursor(Qt::ArrowCursor);
}
Пример #11
0
void CursorManager::initialize() {
	changeCursor(_cursors[CursorIndex_Idle][_cursorIsPushed]);
	showMouse(true);
}
Пример #12
0
void CruiseEngine::mainLoop() {
	//int32 t_start,t_left;
	//uint32 t_end;
	//int32 q=0;                     /* Dummy */
	int16 mouseX, mouseY;
	int16 mouseButton;

	int enableUser = 0;

	strcpy(nextOverlay, "");
	strcpy(lastOverlay, "");
	strcpy(cmdLine, "");

	currentActiveMenu = -1;
	autoMsg = -1;
	linkedRelation = 0;
	main21 = 0;
	main22 = 0;
	userWait = 0;
	autoTrack = false;

	initAllData();

	playerDontAskQuit = 0;
	int quitValue2 = 1;
	int quitValue = 0;

	if (ConfMan.hasKey("save_slot"))
		loadGameState(ConfMan.getInt("save_slot"));

	do {
		// Handle frame delay
		uint32 currentTick = g_system->getMillis();

		if (!bFastMode) {
			// Delay for the specified amount of time, but still respond to events
			bool skipEvents = false;

			do {
				g_system->delayMillis(10);
				currentTick = g_system->getMillis();

				if (!skipEvents)
					skipEvents = manageEvents();

				if (playerDontAskQuit)
					break;

				_vm->getDebugger()->onFrame();
			} while (currentTick < lastTick + _gameSpeed);
		} else {
			manageEvents();

			if (currentTick >= (lastTickDebug + 10)) {
				lastTickDebug = currentTick;
				_vm->getDebugger()->onFrame();
			}
		}
		if (playerDontAskQuit)
			break;

		lastTick = g_system->getMillis();

		// Handle switchover in game speed after intro
		if (!_speedFlag && canLoadGameStateCurrently()) {
			_speedFlag = true;
			_gameSpeed = GAME_FRAME_DELAY_2;
		}

		// Handle the next frame

//		frames++;
//      t_start=Osystem_GetTicks();

//      readKeyboard();

		bool isUserWait = userWait != 0;
		playerDontAskQuit = processInput();
		if (playerDontAskQuit)
			break;

		if (enableUser) {
			userEnabled = 1;
			enableUser = 0;
		}

		if (userDelay && !userWait) {
			userDelay--;
			continue;
		}

		if (isUserWait & !userWait) {
			// User waiting has ended
			changeScriptParamInList(-1, -1, &procHead, 9999, 0);
			changeScriptParamInList(-1, -1, &relHead, 9999, 0);

			// Disable any mouse click used to end the user wait
			currentMouseButton = 0;
		}

		// FIXME: I suspect that the original game does multiple script executions between game frames; the bug with
		// Raoul appearing when looking at the book is being there are 3 script iterations separation between the
		// scene being changed to the book, and the Raoul actor being frozen/disabled. This loop is a hack to ensure
		// that when a background changes, a few extra script executions are done
		bool bgChanged;
		int numIterations = 1;

		while (numIterations-- > 0) {
			bgChanged = backgroundChanged[masterScreen];
		
			manageScripts(&relHead);
			manageScripts(&procHead);

			removeFinishedScripts(&relHead);
			removeFinishedScripts(&procHead);

			if (!bgChanged && backgroundChanged[masterScreen]) {
				bgChanged = true;
				numIterations += 2;
			}
		}

		processAnimation();

		if (remdo) {
			// ASSERT(0);
			/*    main3 = 0;
			 * var24 = 0;
			 * var23 = 0;
			 *
			 * freeStuff2(); */
		}

		if (cmdLine[0]) {
			ASSERT(0);
			/*        redrawStrings(0,&cmdLine,8);

			        waitForPlayerInput();

			        cmdLine = 0; */
		}

		if (displayOn) {
			if (doFade)
				PCFadeFlag = 0;

			/*if (!PCFadeFlag)*/
			mainDraw(userWait);
			flipScreen();

			if (userEnabled && !userWait && !autoTrack) {
				if (currentActiveMenu == -1) {
					static int16 oldMouseX = -1;
					static int16 oldMouseY = -1;

					getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY);

					if (mouseX != oldMouseX || mouseY != oldMouseY) {
						int objectType;
						int newCursor1;
						int newCursor2;

						oldMouseX = mouseX;
						oldMouseY = mouseY;

						objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2);

						if (objectType == 9) {
							changeCursor(CURSOR_EXIT);
						} else if (objectType != -1) {
							changeCursor(CURSOR_MAGNIFYING_GLASS);
						} else {
							changeCursor(CURSOR_WALK);
						}
					}
				} else {
					changeCursor(CURSOR_NORMAL);
				}
			} else {
				changeCursor(CURSOR_NORMAL);
			}

			if (userWait == 1) {
				// Waiting for press - original wait loop has been integrated into the
				// main event loop
				continue;
			}

			// wait for character to finish auto track
			if (autoTrack) {
				if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, ATP_MOUSE)) {
					if (autoMsg != -1) {
						freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0);

						char* pText = getText(autoMsg, autoOvl);

						if (strlen(pText))
							userWait = 1;
					}

					changeScriptParamInList(-1, -1, &relHead, 9998, 0);
					autoTrack = false;
					enableUser = 1;
				} else {
					userEnabled = false;
				}
			} else if (autoMsg != -1) {
				removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen);
				autoMsg = -1;
			}
		} else {
			// Keep ScummVM being responsive even when displayOn is false
			g_system->updateScreen();
		}

	} while (!playerDontAskQuit && quitValue2 && quitValue != 7);

	// Free data
	removeAllScripts(&relHead);
	removeAllScripts(&procHead);
	resetActorPtr(&actorHead);
	freeOverlayTable();
	closeCnf();
	closeBase();
	resetFileEntryRange(0, NUM_FILE_ENTRIES);
	freeObjectList(&cellHead);
	freeBackgroundIncrustList(&backgroundIncrustHead);
}
Пример #13
0
int CruiseEngine::processInput() {
	int16 mouseX = 0;
	int16 mouseY = 0;
	int16 button = 0;

	/*if (inputSub1keyboad())
	 * {
	 * return 1;
	 * } */

	button = 0;

	if (sysKey != -1) {
		button = sysKey;
		mouseX = sysX;
		mouseY = sysY;
		sysKey = -1;
	} else if (automaticMode == 0) {
		getMouseStatus(&main10, &mouseX, &button, &mouseY);
	}

	if (!button) {
		buttonDown = 0;
	}

	// Check for Exit 'X' key
	if (keyboardCode == Common::KEYCODE_x)
		return 1;

	// Check for Pause 'P' key
	if (keyboardCode == Common::KEYCODE_p) {
		keyboardCode = Common::KEYCODE_INVALID;
		_vm->pauseEngine(true);
		mouseOff();

		bool pausedButtonDown = false;
		while (!_vm->shouldQuit()) {
			manageEvents();
			getMouseStatus(&main10, &mouseX, &button, &mouseY);

			if (button) pausedButtonDown = true;
			else if (pausedButtonDown)
				// Button released, so exit pause
				break;
			else if (keyboardCode != Common::KEYCODE_INVALID)
				break;

			g_system->delayMillis(10);
		}

		if (keyboardCode == Common::KEYCODE_x)
			// Exit the game
			return 1;

		keyboardCode = Common::KEYCODE_INVALID;
		_vm->pauseEngine(false);
		mouseOn();
		return 0;
	}

	// Player Menu - test for both buttons or the F10 key
	if (((button & CRS_MB_BOTH) == CRS_MB_BOTH) || (keyboardCode == Common::KEYCODE_F10)) {
		changeCursor(CURSOR_NORMAL);
		keyboardCode = Common::KEYCODE_INVALID;
		return (playerMenu(mouseX, mouseY));
	}

	if (userWait) {
		// Check for left mouse button click or Space to end user waiting
		if ((keyboardCode == Common::KEYCODE_SPACE) || (button == CRS_MB_LEFT))
			userWait = 0;

		keyboardCode = Common::KEYCODE_INVALID;
		return 0;
	}

	// Handle any changes in game speed
	if (_speedFlag) {
		if ((keyboardCode == Common::KEYCODE_KP_PLUS) && (_gameSpeed >= 30)) {
			_gameSpeed -= 10;
			keyboardCode = Common::KEYCODE_INVALID;
		}
		if ((keyboardCode == Common::KEYCODE_KP_MINUS) && (_gameSpeed <= 200)) {
			_gameSpeed += 10;
			keyboardCode = Common::KEYCODE_INVALID;
		}
	}

	if (!userEnabled) {
		return 0;
	}

	if ((currentActiveMenu != -1) && menuTable[currentActiveMenu]) {
		updateMenuMouse(mouseX, mouseY, menuTable[currentActiveMenu]);
	}

	if (dialogueEnabled) {

		if (menuDown || selectDown || linkedRelation) {
			closeAllMenu();
			menuDown = 0;
			selectDown = 0;
			currentActiveMenu = -1;
			changeCursor(CURSOR_NORMAL);
		}

		if ((menuTable[0] == NULL) && (!buttonDown)) {
			int dialogFound = createDialog(dialogueOvl, dialogueObj, xdial, 0);

			if (menuTable[0]) {
				if (dialogFound) {
					currentActiveMenu = 0;
				} else {
					freeMenu(menuTable[0]);
					menuTable[0] = NULL;
					currentActiveMenu = -1;
				}
			} else {
				menuDown = 0;
			}
		} else {
			if ((button & CRS_MB_LEFT) && (buttonDown == 0)) {
				if (menuTable[0]) {
					callRelation(getSelectedEntryInMenu(menuTable[0]), dialogueObj);

					freeMenu(menuTable[0]);
					menuTable[0] = NULL;

					if (linkedMsgList) {
						ASSERT(0);
						//					freeMsgList(linkedMsgList);
					}

					linkedMsgList = NULL;
					linkedRelation = NULL;

					changeCursor(CURSOR_NORMAL);
					currentActiveMenu = -1;
				}
				buttonDown = 1;
			}
		}

	} else if ((button & CRS_MB_LEFT) && (buttonDown == 0)) {
		// left click
		buttonDown = 1;

		// is there a relation
		if (linkedRelation) {
			// call sub relation when clicking on an object
			if (menuDown == 0) {
				if (menuTable[0]) {
					int objOvl;
					int objIdx;
					int objType;

					objType = findObject(mouseX, mouseY, &objOvl, &objIdx);

					if (objType != -1) {
						callSubRelation(linkedRelation, objOvl, objIdx);
					}
					freeMenu(menuTable[0]);
					menuTable[0] = NULL;
				}

				if (linkedMsgList) {
//					freeMsgList(linkedMsgList);
				}
				linkedMsgList = NULL;
				linkedRelation = NULL;
				changeCursor(CURSOR_NORMAL);
			} else { // call sub relation when clicking in inventory
				if (menuTable[0] && menuTable[1]) {
					menuElementSubStruct * p0 = getSelectedEntryInMenu(menuTable[1]);

					if (p0)
						callSubRelation(linkedRelation, p0->ovlIdx, p0->header);

					closeAllMenu();
					changeCursor(CURSOR_NORMAL);
				}
			}
			selectDown = 0;
			menuDown = 0;
		} else {
			// manage click on object menu
			if (menuDown == 0) {
				// Handle left click on an object
				if (menuTable[0] == 0) {
					int objOvl;
					int objIdx;
					int objType;

					objType = findObject(mouseX, mouseY, &objOvl, &objIdx);

					if (objType != -1) {
						int relation = findRelation(objOvl, objIdx, mouseX, mouseY);
						if (menuTable[0]) {
							if (relation) {
								currentActiveMenu = 0;
								selectDown = 1;
							} else {
								// object has a name but no relation, just move the character
								freeMenu(menuTable[0]);
								menuTable[0] = NULL;

								aniX = mouseX;
								aniY = mouseY;
								animationStart = true;
							}
						} else {
							aniX = mouseX;
							aniY = mouseY;
							animationStart = true;
						}
					} else {
						// No object found, we move the character to the cursor
						aniX = mouseX;
						aniY = mouseY;
						animationStart = true;
					}
				} else {
					// handle click in menu
					if (menuTable[0]) {
						menuElementSubStruct *pMenuElementSub = getSelectedEntryInMenu(menuTable[0]);

						callRelation(pMenuElementSub, -1);

						// if there is a linked relation, close menu
						if (!linkedRelation) {
							freeMenu(menuTable[0]);
							menuTable[0] = NULL;
							changeCursor(CURSOR_NORMAL);
						} else { // else create the message for the linked relation
							char text[80];
							strcpy(text, menuTable[0]->stringPtr);
							strcat(text, ":");
							strcat(text, currentMenuElement->string);
							linkedMsgList = renderText(320, (const char *)text);
							changeCursor(CURSOR_CROSS);
						}
					}

					currentActiveMenu = -1;
					selectDown = 0;
				}
			} else {
				// Handle left click in inventory
				if (processInventory()) {
					currentActiveMenu = 0;
					selectDown = 1;
					menuDown = 0;
				} else {
					currentActiveMenu = -1;
					menuDown = 0;
				}
			}
		}
	} else if ((button & CRS_MB_RIGHT) || (keyboardCode == Common::KEYCODE_F9)) {
		if (buttonDown == 0) {
			keyboardCode = Common::KEYCODE_INVALID;

			// close object menu if there is no linked relation
			if ((linkedRelation == 0) && (menuTable[0])) {
				freeMenu(menuTable[0]);
				menuTable[0] = NULL;
				selectDown = 0;
				menuDown = 0;
				currentActiveMenu = -1;
			}

			if ((!selectDown) && (!menuDown) && (menuTable[1] == NULL)) {
				buildInventory(mouseX, mouseY);

				if (menuTable[1]) {
					currentActiveMenu = 1;
					menuDown = 1;
				} else {
					menuDown = 1;
				}
			}
			buttonDown = 1;
		}
	}

	return 0;
}
Пример #14
0
void loadPackedFileToMem(int fileIdx, uint8 *buffer) {
	changeCursor(CURSOR_DISK);

	_vm->_currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset, SEEK_SET);
	_vm->_currentVolumeFile.read(buffer, volumePtrToFileDescriptor[fileIdx].size);
}
Пример #15
0
int getBootOptions(bool firstRun)
{
	int     i;
	int     key;
	int     nextRow;
	int     timeout;
#if UNUSED
	int     bvCount;
#endif
	BVRef   bvr;
	BVRef   menuBVR;
	bool    showPrompt, newShowPrompt, isCDROM;
    int     optionKey;
	
	// Initialize default menu selection entry.
	menuBVR = selectBootVolume(getBvChain());
	safe_set_env(envgBootVolume, (uint32_t)menuBVR);
	
	if (biosDevIsCDROM((int)get_env(envgBIOSDev))) {
		isCDROM = true;
	} else {
		isCDROM = false;
	}
	
	// Clear command line boot arguments
	clearBootArgs();
	
	// Allow user to override default timeout.
#if UNUSED
	if (multiboot_timeout_set) {
		timeout = multiboot_timeout;
	} else 
#endif
		if (!getIntForKey(kTimeoutKey, &timeout, DEFAULT_BOOT_CONFIG)) {
			/*  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
			 to zero which causes the menu to display immediately.
			 This way, if no partitions can be found, that is the disk is unpartitioned
			 or simply cannot be read) then an empty menu is displayed.
			 If some partitions are found, for example a Windows partition, then
			 these will be displayed in the menu as foreign partitions.
			 */
			if (isCDROM) {
				timeout = kCDBootTimeout;
			} else {
				timeout = get_env(envSysConfigValid) ? kBootTimeout : 0;
			}
		}
	
    long gBootMode = (long)get_env(envgBootMode);
    
	if (timeout < 0) {
		gBootMode |= kBootModeQuiet;
        safe_set_env(envgBootMode,gBootMode);
		
	}
	
	// If the user is holding down a modifier key, enter safe mode.
	if ((readKeyboardShiftFlags() & 0x0F) != 0) {
		
		gBootMode |= kBootModeSafe;
        safe_set_env(envgBootMode,gBootMode);
		
	}
	
	// Checking user pressed keys
	bool f8press = false, spress = false, vpress = false;
	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) {
		gBootMode &= ~kBootModeQuiet;
        safe_set_env(envgBootMode,gBootMode);
		
		timeout = 0;
	}
	// If user typed 'v' or 'V', boot in verbose mode.
	if ((gBootMode & kBootModeQuiet) && firstRun && vpress) {
		addBootArg(kVerboseModeFlag);
	}
	// If user typed 's' or 'S', boot in single user mode.
	if ((gBootMode & kBootModeQuiet) && firstRun && spress) {
		addBootArg(kSingleUserModeFlag);
	}
	
	setCursorPosition(0, 0, 0);
	clearScreenRows(0, kScreenLastRow);
	if (!(gBootMode & kBootModeQuiet)) {
		// Display banner and show hardware info.
        char * bootBanner = (char*)(uint32_t)get_env(envBootBanner);
        
		printf(bootBanner, (int)(get_env(envConvMem) + get_env(envExtMem)) / 1024);       
	}
	changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
	msglog("Scanning device %x...", (uint32_t)get_env(envgBIOSDev));
	
	// When booting from CD, default to hard drive boot when possible. 
	if (isCDROM && firstRun) {
		const char *val;
		char *prompt = NULL;
		char *name = NULL;
		int cnt;
		
		if (getValueForKey(kCDROMPromptKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) {
			prompt = calloc(cnt + 1, sizeof(char));
            if (!prompt) {
                stop("Couldn't allocate memory for the prompt\n"); //TODO: Find a better stategie
                return -1;
            }
			strncat(prompt, val, cnt);
		} else {			
            prompt = calloc(256, sizeof(char));
            if (!prompt) {
                stop("Couldn't allocate memory for the prompt\n"); //TODO: Find a better stategie
                return -1;
            }
            BVRef bvr;
            if (( bvr = ((BVRef)(uint32_t)get_env(envgBootVolume)))) {
                name = calloc(80, sizeof(char));
                if (!name) {
                    stop("Couldn't allocate memory for the device name\n"); //TODO: Find a better stategie
                    return -1;
                }
                getBootVolumeDescription(bvr, name, 79, false);
                
                snprintf(prompt, 256,"Press ENTER to start up from %s, or press any key to enter startup options.", name);
                free(name);
            } else snprintf(prompt, 256,"Press ENTER to start up, or press any key to enter startup options.");
			
		}
		
		if (getIntForKey( kCDROMOptionKey, &optionKey, DEFAULT_BOOT_CONFIG )) {
			// The key specified is a special key.
		} else {
			// Default to F8.
			optionKey = 0x4200;
		}
		
		// If the timeout is zero then it must have been set above due to the
		// early catch of F8 which means the user wants to set boot options
		// which we ought to interpret as meaning he wants to boot the CD.
		if (timeout != 0) {
			key = countdown(prompt, kMenuTopRow, timeout, &optionKey);
		} else {
			key = optionKey;
		}
		
		if (prompt != NULL) {
			free(prompt);
		}
		
		clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );
		
        do {
            // Hit the option key ?
            if (key == optionKey) {
				
                if (key != 0x1C0D) {
                    gBootMode &= ~kBootModeQuiet;
                    safe_set_env(envgBootMode,gBootMode);
                    timeout = 0;
                    break;
                }
                
            } 
            
            key = key & 0xFF;
            
            // Try booting hard disk if user pressed 'h'
            if (biosDevIsCDROM((int)get_env(envgBIOSDev)) && key == 'h') {
                BVRef bvr;
                
                // Look at partitions hosting OS X other than the CD-ROM
                for (bvr = getBvChain(); bvr; bvr=bvr->next) {
                    if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != (int)get_env(envgBIOSDev)) {
						safe_set_env(envgBootVolume, (uint32_t)bvr);
                    }
                }
            }
            goto done;
            
        } while (0);
		
	}
	
	if (get_env(envgBootMode) & kBootModeQuiet) {
		// No input allowed from user.
		goto done;
	}
	
	if (firstRun && timeout > 0 ) {
        
        key = countdown("Press ENTER to start up, or press any key to enter startup options.", kMenuTopRow, timeout, &optionKey);
        
        if (key == 0x1C0D) {
            goto done;
			
        } 
        else if (key == 0)
        {
            // If the user is holding down a modifier key,
            // enter safe mode.     
            
            if ((readKeyboardShiftFlags() & 0x0F) != 0) {
                gBootMode |= kBootModeSafe;
                safe_set_env(envgBootMode,gBootMode);
            }
            goto done;
        }
	}
	int devcnt = (int)get_env(envgDeviceCount);
    
	if (devcnt) {
		// Allocate memory for an array of menu items.
		menuItems = calloc(devcnt,sizeof(MenuItem));
		if (menuItems == NULL) {
			goto done;
		}
		
		// Associate a menu item for each BVRef.
		for (bvr=getBvChain(), i=devcnt-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) {
					selectIndex = i;
				}
				i--;
			}
		}
	}
	
	// Clear screen and hide the blinking cursor.
	clearScreenRows(kMenuTopRow, kMenuTopRow + 2);
	changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);
	
	nextRow = kMenuTopRow;
	/*showPrompt = true;*/
	
	if (devcnt) {
		printf("Use \30\31 keys to select the startup volume.");
		showMenu( menuItems, devcnt, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
		nextRow += min( devcnt, kMenuMaxItems ) + 3;
	}
	
	// Show the boot prompt.
	showPrompt = (devcnt == 0) || (menuBVR->flags & kBVFlagNativeBoot);
	showBootPrompt( nextRow, showPrompt );
	
	do {        
        
		key = getc();
		updateMenu( key, (void **) &menuBVR );
		newShowPrompt = (devcnt == 0) || (menuBVR->flags & kBVFlagNativeBoot);
		
		if (newShowPrompt != showPrompt)
		{
			showPrompt = newShowPrompt;
			showBootPrompt( nextRow, showPrompt );
		}
		
		if (showPrompt)
		{            
			updateBootArgs(key);
		}		
        
		switch (key) {
			case kReturnKey:
				if (*gBootArgs == '?') {
					char * argPtr = gBootArgs;
					
					// Skip the leading "?" character.
					argPtr++;
					getNextArg(&argPtr, booterCommand);
					getNextArg(&argPtr, booterParam);
					
					/*
					 * TODO: this needs to be refactored.
					 */
#if UNUSED
					if (strncmp( booterCommand, "video", sizeof("video") ) == 0)
					{
						printVBEModeInfo();
					}
					else
#endif
						if ( strncmp( booterCommand, "memory", sizeof("memory") ) == 0) 
						{
							printMemoryInfo();
						}
						else if (strncmp(booterCommand, "lspci", sizeof( "lspci")) == 0) 
						{
							lspci();
						} 
						else if (strncmp(booterCommand, "more",  sizeof("more")) == 0) 
						{
							showTextFile(booterParam);
						}
						else if (strncmp(booterCommand, "rd", sizeof("rd")) == 0) 
						{
							if (execute_hook("processRAMDiskCommand", (void*)argPtr, &booterParam, NULL, NULL, NULL, NULL) != EFI_SUCCESS)
								showMessage("ramdisk module not found, please install RamdiskLoader.dylib in /Extra/modules/");
						} 
						else if (strncmp(booterCommand, "norescan", sizeof("norescan")) == 0)
						{
							if (get_env(envgEnableCDROMRescan))
							{
                                safe_set_env(envgEnableCDROMRescan,false);
								break;
							}
						}
						else
						{
							showHelp();
						}
					key = 0;
					showBootPrompt(nextRow, showPrompt);
					break;
				}
				safe_set_env(envgBootVolume, (uint32_t)menuBVR);
				setRootVolume(menuBVR);
                safe_set_env(envgBIOSDev,menuBVR->biosdev);
				break;
				
			case kEscapeKey:
				clearBootArgs();
				break;
                
			case kF5Key:
				// New behavior:
				// Clear gBootVolume to restart the loop
				// if the user enabled rescanning the optical drive.
				// Otherwise boot the default boot volume.
				if (get_env(envgEnableCDROMRescan)) {
					//gBootVolume = NULL;
					safe_set_env(envgBootVolume, (uint32_t)NULL);
					clearBootArgs();
				}
				break;
				
			case kF10Key:
                safe_set_env(envgScanSingleDrive, false);
                
                scanDisks();
                
				//gBootVolume = NULL;
				safe_set_env(envgBootVolume, (uint32_t)NULL);
				
				clearBootArgs();
				break;
                
			default:
				key = 0;
				break;
		}
	} while (0 == key);
	
done:
	if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
		clearScreenRows(kMenuTopRow, kScreenLastRow);
		changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
	}
    safe_set_env(envShouldboot, false);
	
	if (menuItems) {
		free(menuItems);
		menuItems = NULL;
	}
	return 0;
}
Пример #16
0
static int updateMenu( int key, void ** paramPtr )
{
    int moved = 0;
    
    int MenuTop = (int)get_env(envgMenuTop);
    int MenuSelection = (int)get_env(envgMenuSelection);
    int MenuRow = (int)get_env(envgMenuRow);
    int MenuHeight = (int)get_env(envgMenuHeight);
    int MenuBottom = (int)get_env(envgMenuBottom);
    int MenuStart = (int)get_env(envgMenuStart);
    int MenuEnd = (int)get_env(envgMenuEnd);
	
    union {
        struct {
            unsigned int
			selectionUp   : 1,
			selectionDown : 1,
			scrollUp      : 1,
			scrollDown    : 1;
        } f;
        unsigned int w;
    } draw = {{0}};
	
	if ( gMenuItems == NULL )
		return 0;
	
	switch ( key )
	{
		case 0x4800:  // Up Arrow
        {
			if ( MenuSelection != MenuTop )
				draw.f.selectionUp = 1;
			else if ( MenuTop > 0 )
				draw.f.scrollDown = 1;
			break;
        }
		case 0x5000:  // Down Arrow
        {
			if ( MenuSelection != MenuBottom )
				draw.f.selectionDown = 1;
			else if ( MenuBottom < (get_env(envgMenuItemCount) - 1) ) 
				draw.f.scrollUp = 1;
			break;
        }
		default:
			break;
	}
	
    if ( draw.w )
    {        
        if ( draw.f.scrollUp )
        {
            scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, 1);
            MenuTop++;  MenuBottom++;
			MenuStart++; MenuEnd++;
            draw.f.selectionDown = 1;
        }
		
        if ( draw.f.scrollDown )
        {
            scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, -1);
            MenuTop--; MenuBottom--;
            MenuStart--; MenuEnd--;
            draw.f.selectionUp = 1;
        }        
		
        if ( draw.f.selectionUp || draw.f.selectionDown )
        {
			
			CursorState cursorState;
			
			// Set cursor at current position, and clear inverse video.
			changeCursor( 0, MenuRow + MenuSelection - MenuTop, kCursorTypeHidden, &cursorState );
			printMenuItem( &gMenuItems[MenuSelection], 0 );
			
			if ( draw.f.selectionUp )
			{
				MenuSelection--;
				if(( MenuSelection - MenuStart) == -1 )
				{
					MenuStart--;
					MenuEnd--;
				}
				
			} else {
				MenuSelection++;
				if(( MenuSelection - ( MenuEnd - 1) - MenuStart) > 0 )
				{
					MenuStart++;
					MenuEnd++;
				}
			}
			
			moveCursor( 0, MenuRow + MenuSelection - MenuTop );
			printMenuItem( &gMenuItems[MenuSelection], 1 );
			restoreCursor( &cursorState );
			
		}
		
        *paramPtr = gMenuItems[MenuSelection].param;        
        moved = 1;
    }
	
    safe_set_env(envgMenuSelection,MenuSelection);
    safe_set_env(envgMenuTop,MenuTop );
    safe_set_env(envgMenuRow,MenuRow);
    safe_set_env(envgMenuHeight,MenuHeight);
    safe_set_env(envgMenuBottom,MenuBottom);
    safe_set_env(envgMenuStart,MenuStart);
    safe_set_env(envgMenuEnd,MenuEnd);
	
	return moved;
}
Пример #17
0
int
getBootOptions(BOOL firstRun)
{
    int     i;
    int     key;
    int     selectIndex = 0;
    int     bvCount;
    int     nextRow;
    int     timeout;
    BVRef   bvr;
    BVRef   bvChain;
    BVRef   menuBVR;
    BOOL    showPrompt, newShowPrompt, isCDROM;
    MenuItem *  menuItems = NULL;

    if ( diskIsCDROM(gBootVolume) )
        isCDROM = TRUE;
    else
        isCDROM = FALSE;

    // Allow user to override default timeout.

    if ( getIntForKey(kTimeoutKey, &timeout) == NO )
    {
        if ( isCDROM )
            timeout = kCDBootTimeout;
        else
            timeout = kBootTimeout;
    }
    if (timeout < 0) gBootMode |= kBootModeQuiet;

    // If the user is holding down a modifier key,
    // enter safe mode.
    if ( ( readKeyboardShiftFlags() & 0x0F ) != 0 ) {
        gBootMode |= kBootModeSafe;
    }

    // If user typed F8, abort quiet mode,
    // and display the menu.
    if (flushKeyboardBuffer()) {
        gBootMode &= ~kBootModeQuiet;
        timeout = 0;
    }

    clearBootArgs();

    setCursorPosition( 0, 0, 0 );
    clearScreenRows( 0, kScreenLastRow );
    if ( ! ( gBootMode & kBootModeQuiet ) ) {
        // Display banner and show hardware info. 
        printf( bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024 );
        printVBEInfo();
    }

    changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );

    verbose("Scanning device %x...", gBIOSDev);

    // Get a list of bootable volumes on the device.

    bvChain = scanBootVolumes( gBIOSDev, &bvCount );
    gBootVolume = menuBVR = selectBootVolume( bvChain );

    // When booting from CD, default to hard
    // drive boot when possible. 

    if ( isCDROM )
    {
        const char *val;
        char *prompt;
        int cnt;
        int optionKey;

        if (getValueForKey( kCDROMPromptKey, &val, &cnt )) {
            cnt += 1;
            prompt = malloc(cnt);
            strlcpy(prompt, val, cnt);
        } else {
            prompt = "Press any key to start up from CD-ROM, "
                "or press F8 to enter startup options.";
            cnt = 0;
        }

        if (getIntForKey( kCDROMOptionKey, &optionKey )) {
            // The key specified is a special key.
        } else if (getValueForKey( kCDROMOptionKey, &val, &cnt) && cnt >= 1) {
            optionKey = val[0];
        } else {
            // Default to F8.
            optionKey = 0x4200;
        }

        key = countdown(prompt, kMenuTopRow, timeout);
        if (cnt)
            free(prompt);

        clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );

        if (key == 0) {
            // Boot from hard disk.
            // Scan the original device 0x80.

            BVRef hd_bvr = selectBootVolume(scanBootVolumes(0x80, 0));
            if ( hd_bvr->flags & kBVFlagNativeBoot ) {
                gBootVolume = hd_bvr;
                gBIOSDev = hd_bvr->biosdev;
                initKernBootStruct( gBIOSDev );
                goto done;
            }
        } else  {
            if (optionKey < 0x100)
                key = key & 0x5F;
            if (key != optionKey)
                goto done;
        }
        gBootMode &= ~kBootModeQuiet;
        timeout = 0;
    }

    if ( gBootMode & kBootModeQuiet )
    {
        // No input allowed from user.
        goto done;
    }

    if ( firstRun && ( timeout > 0 ) &&
         ( 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 ) {
            gBootMode |= kBootModeSafe;
        }
        goto done;
    }

    if ( bvCount )
    {
        // Allocate memory for an array of menu items.

        menuItems = (MenuItem *) malloc( sizeof(MenuItem) * bvCount );
        if ( menuItems == NULL ) goto done;

        // Associate a menu item for each BVRef.

        for ( bvr = bvChain, i = bvCount - 1, selectIndex = 0;
              bvr; bvr = bvr->next, i-- )
        {
            getBootVolumeDescription( bvr, menuItems[i].name, 80, YES );
            menuItems[i].param = (void *) bvr;
            if ( bvr == menuBVR ) selectIndex = i;
        }
    }

    // Clear screen and hide the blinking cursor.

    clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );
    changeCursor( 0, kMenuTopRow, kCursorTypeHidden, 0 );
    nextRow = kMenuTopRow;
    showPrompt = YES;

    // Show the menu.

    if ( bvCount )
    {
        printf("Use \30\31 keys to select the startup volume.");
        showMenu( menuItems, bvCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
        nextRow += min( bvCount, kMenuMaxItems ) + 3;
    }

    // Show the boot prompt.

    showPrompt = (bvCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
    showBootPrompt( nextRow, showPrompt );

    do {
        key = getc();

        updateMenu( key, (void **) &menuBVR );

        newShowPrompt = (bvCount == 0) ||
                        (menuBVR->flags & kBVFlagNativeBoot);

        if ( newShowPrompt != showPrompt )
        {
            showPrompt = newShowPrompt;
            showBootPrompt( nextRow, showPrompt );
        }
        if ( showPrompt ) updateBootArgs( key );

        switch ( key & kASCIIKeyMask )
        {
            case kReturnKey:
                if ( *gBootArgs == '?' )
                {
                    if ( strcmp( gBootArgs, "?video" ) == 0 ) {
                        printVBEModeInfo();
                    } else if ( strcmp( gBootArgs, "?memory" ) == 0 ) {
                        printMemoryInfo();
                    } else {
                        showHelp();
                    }
                    key = 0;
                    showBootPrompt( nextRow, showPrompt );
                    break;
                }
                gBootVolume = menuBVR;
                break;

            case kEscapeKey:
                clearBootArgs();
                break;

            default:
                key = 0;
        }
    }
    while ( 0 == key );

done:
    firstRun = NO;

    clearScreenRows( kMenuTopRow, kScreenLastRow );
    changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );

    if ( menuItems ) free(menuItems);

    return 0;
}
Пример #18
0
void CursorManager::changeCursor(const Common::String &cursorName) {
	changeCursor(cursorName, _cursorIsPushed);
}
Пример #19
0
bool OS2Factory::init()
{
    PCSZ vlc_name = "VLC Media Player";
    PCSZ vlc_icon = "VLC_ICON";
    PCSZ vlc_class = "SkinWindowClass";

    MorphToPM();

    m_hab = WinInitialize( 0 );

    // save FPU CW
    unsigned saved_cw = _control87( 0, 0 );

    // WinCreateMsgQueue() changes FPU CW but does not restore it
    m_hmq = WinCreateMsgQueue( m_hab, 0 );

    // restore FPU CW
    _control87( saved_cw, MCW_EM | MCW_IC | MCW_RC | MCW_PC );

    if( !WinRegisterClass( m_hab, vlc_class, OS2Factory::OS2Proc,
                           CS_SIZEREDRAW, sizeof( PVOID )))
    {
        msg_Err( getIntf(), "cannot register window class" );
        return false;
    }

    ULONG flFrame = FCF_SYSMENU | FCF_MINBUTTON | FCF_TASKLIST
                    /* | FCF_ICON */;

    m_hParentWindow = WinCreateStdWindow( HWND_DESKTOP,
                                          0,
                                          &flFrame,
                                          vlc_class,
                                          vlc_name,
                                          0,
                                          NULLHANDLE,
                                          0/* ID_VLC_ICON */,
                                          &m_hParentClientWindow );

    if( !m_hParentWindow )
    {
        msg_Err( getIntf(), "cannot create parent window" );
        return false;
    }

    // Store with it a pointer to the interface thread
    WinSetWindowPtr( m_hParentClientWindow, 0, getIntf());

    WinSetWindowPos( m_hParentWindow, HWND_TOP, 0, 0, 0, 0,
                     SWP_ACTIVATE | SWP_ZORDER | SWP_MOVE | SWP_SIZE |
                     SWP_SHOW );

    // Set the mouse pointer to a default arrow
    changeCursor( kDefaultArrow );

    // Initialize the resource path
    char *datadir = config_GetUserDir( VLC_DATA_DIR );
    m_resourcePath.push_back( (string)datadir + "\\skins" );
    free( datadir );
    datadir = config_GetDataDir();
    m_resourcePath.push_back( (string)datadir + "\\skins" );
    m_resourcePath.push_back( (string)datadir + "\\skins2" );
    m_resourcePath.push_back( (string)datadir + "\\share\\skins" );
    m_resourcePath.push_back( (string)datadir + "\\share\\skins2" );
    m_resourcePath.push_back( (string)datadir + "\\vlc\\skins" );
    m_resourcePath.push_back( (string)datadir + "\\vlc\\skins2" );
    free( datadir );

    // All went well
    return true;
}
Пример #20
0
Common::Error loadSavegameData(int saveGameIdx) {
	int lowMemorySave;
	Common::String saveName;
	cellStruct *currentcellHead;

	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
	Common::InSaveFile *f = saveMan->openForLoading(_vm->getSavegameFile(saveGameIdx));

	if (f == NULL) {
		printInfoBlackBox("Savegame not found...");
		waitForPlayerInput();
		return Common::kNoGameDataFoundError;
	}

	printInfoBlackBox("Loading in progress...");

	initVars();
	_vm->sound().stopMusic();

	// Skip over the savegame header
	CruiseSavegameHeader header;
	readSavegameHeader(f, header);
	delete header.thumbnail;

	// Synchronise the remaining data of the savegame
	Common::Serializer s(f, NULL);
	DoSync(s);

	delete f;

	// Post processing

	for (int j = 0; j < 64; j++)
		preloadData[j].ptr = NULL;

	for (int j = 1; j < numOfLoadedOverlay; j++) {
		if (overlayTable[j].alreadyLoaded) {
			overlayTable[j].alreadyLoaded = 0;
			loadOverlay(overlayTable[j].overlayName);

			if (overlayTable[j].alreadyLoaded) {
				ovlDataStruct *ovlData = overlayTable[j].ovlData;

				// overlay BSS

				if (ovlRestoreData[j]._sBssSize) {
					if (ovlData->data4Ptr) {
						MemFree(ovlData->data4Ptr);
					}

					ovlData->data4Ptr = ovlRestoreData[j]._pBss;
					ovlData->sizeOfData4 = ovlRestoreData[j]._sBssSize;
				}

				// overlay object data

				if (ovlRestoreData[j]._sNumObj) {
					if (ovlData->arrayObjVar) {
						MemFree(ovlData->arrayObjVar);
					}

					ovlData->arrayObjVar = ovlRestoreData[j]._pObj;
					ovlData->size9 = ovlRestoreData[j]._sNumObj;
				}

			}
		}
	}

	updateAllScriptsImports();

	lastAni[0] = 0;

	lowMemorySave = lowMemory;

	for (int i = 0; i < NUM_FILE_ENTRIES; i++) {
		if (filesDatabase[i].subData.ptr) {
			int j;
			int k;

			for (j = i + 1; j < NUM_FILE_ENTRIES && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j - i)); j++)
				;

			for (k = i; k < j; k++) {
				if (filesDatabase[k].subData.ptrMask)
					lowMemory = 0;

				filesDatabase[k].subData.ptr = NULL;
				filesDatabase[k].subData.ptrMask = NULL;
			}

			/*if (j < 2) {
				error("Unsupported mono file load");
				//loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
			} else */
			if (strlen(filesDatabase[i].subData.name) > 0) {
				loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i);
			} else {
				filesDatabase[i].subData.ptr = NULL;
				filesDatabase[i].subData.ptrMask = NULL;
			}

			i = j - 1;
			lowMemory = lowMemorySave;
		}
	}

	lastAni[0] = 0;

	currentcellHead = cellHead.next;

	while (currentcellHead) {
		if (currentcellHead->type == 5) {
			uint8 *ptr = mainProc14(currentcellHead->overlay, currentcellHead->idx);

			ASSERT(0);

			if (ptr) {
				ASSERT(0);
				//*(int16 *)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16 *)(currentcellHead->datas+0xE));
			} else {
				ASSERT(0);
				//*(int16 *)(currentcellHead->datas+0x2E) = 0;
			}
		}

		currentcellHead = currentcellHead->next;
	}

	if (strlen(currentCtpName)) {
		loadCtFromSave = 1;
		initCt(currentCtpName);
		loadCtFromSave = 0;
	}
	//prepareFadeOut();
	//gfxModuleData.gfxFunction8();

	for (int j = 0; j < 8; j++) {
		if (strlen((char *)backgroundTable[j].name)) {
			loadBackground(backgroundTable[j].name, j);
		}
	}

	regenerateBackgroundIncrust(&backgroundIncrustHead);

	// to finish

	changeCursor(CURSOR_NORMAL);
	mainDraw(1);
	flipScreen();

	return Common::kNoError;
}
Пример #21
0
int getBootOptions(bool firstRun)
{
	int     i;
	int     key;
	int     nextRow;
	int     timeout;
	int     bvCount;
	BVRef   bvr;
	BVRef   menuBVR;
	bool    showPrompt, newShowPrompt, isCDROM;

	// Initialize default menu selection entry.
	gBootVolume = menuBVR = selectBootVolume(bvChain);

	if (biosDevIsCDROM(gBIOSDev)) {
		isCDROM = true;
	} else {
		isCDROM = false;
	}

	// ensure we're in graphics mode if gui is setup
	if (firstRun && gui.initialised && bootArgs->Video.v_display == VGA_TEXT_MODE)
	{
		setVideoMode(GRAPHICS_MODE, 0);
	}

	// Clear command line boot arguments
	clearBootArgs();

	// Allow user to override default timeout.
	if (multiboot_timeout_set) {
		timeout = multiboot_timeout;
	} else if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->chameleonConfig)) {
		/*  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
		    to zero which causes the menu to display immediately.
		    This way, if no partitions can be found, that is the disk is unpartitioned
		    or simply cannot be read) then an empty menu is displayed.
		    If some partitions are found, for example a Windows partition, then
		    these will be displayed in the menu as foreign partitions.
		 */
		if (isCDROM) {
			timeout = kCDBootTimeout;
		} else {
			timeout = sysConfigValid ? kBootTimeout : 0;
		}
	}

	if (timeout < 0) {
		gBootMode |= kBootModeQuiet;
	}

	// If the user is holding down a modifier key, enter safe mode.
	if ((readKeyboardShiftFlags() & 0x0F) != 0) {
		gBootMode |= kBootModeSafe;
	}

	// Checking user pressed keys
	bool f8press = false, spress = false, vpress = false;
	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) {
		gBootMode &= ~kBootModeQuiet;
		timeout = 0;
	}
	// If user typed 'v' or 'V', boot in verbose mode.
	if ((gBootMode & kBootModeQuiet) && firstRun && vpress) {
		addBootArg(kVerboseModeFlag);
	}
	// If user typed 's' or 'S', boot in single user mode.
	if ((gBootMode & kBootModeQuiet) && firstRun && spress) {
		addBootArg(kSingleUserModeFlag);
	}

	if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
		setCursorPosition(0, 0, 0);
		clearScreenRows(0, kScreenLastRow);
		if (!(gBootMode & kBootModeQuiet)) {
			// Display banner and show hardware info.
			printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);
			printf(getVBEInfoString());
		}
		changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
		verbose("Scanning device %x...", gBIOSDev);
	}

	// When booting from CD, default to hard drive boot when possible. 
	if (isCDROM && firstRun) {
		const char *val;
		char *prompt = NULL;
		char *name = NULL;
		int cnt;
		int optionKey;

		if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->chameleonConfig)) {
			prompt = malloc(cnt + 1);
			strncat(prompt, val, cnt);
		} else {
			name = malloc(80);
			getBootVolumeDescription(gBootVolume, name, 79, false);
			prompt = malloc(256);
			sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
			free(name);
		}

		if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->chameleonConfig )) {
			// The key specified is a special key.
		} else {
			// Default to F8.
			optionKey = 0x4200;
		}

		// If the timeout is zero then it must have been set above due to the
		// early catch of F8 which means the user wants to set boot options
		// which we ought to interpret as meaning he wants to boot the CD.
		if (timeout != 0) {
			key = countdown(prompt, kMenuTopRow, timeout);
		} else {
			key = optionKey;
		}

		if (prompt != NULL) {
			free(prompt);
		}

		clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );

		// Hit the option key ?
		if (key == optionKey) {
			gBootMode &= ~kBootModeQuiet;
			timeout = 0;
		} else {
			key = key & 0xFF;

			// Try booting hard disk if user pressed '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) {
						gBootVolume = bvr;
					}
				}
			}
			goto done;
		}
	}

	if (gBootMode & kBootModeQuiet) {
		// No input allowed from user.
		goto done;
	}

	if (firstRun && timeout > 0 && 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) {
			gBootMode |= kBootModeSafe;
		}
		goto done;
	}

	if (gDeviceCount > 0) {
		// Allocate memory for an array of menu items.
		menuItems = malloc(sizeof(MenuItem) * gDeviceCount);
		if (menuItems == NULL) {
			goto done;
		}

		// Associate a menu item for each BVRef.
		for (bvr=bvChain, i=gDeviceCount-1, selectIndex=-1; 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) {
					selectIndex = i;
				}
				i--;
			}
		}
		// Jief : In case the default partition (returned by selectBootVolume) is not in the menu
		if ( selectIndex == -1 )
		{
			selectIndex = 0;

			// gDeviceCount is actually > 0, so menuItems[selectIndex] exists
			menuBVR = (BVRef)(menuItems[selectIndex].param);
			// what happen is bvChain is empty ?
		}
	}

	if (bootArgs->Video.v_display != VGA_TEXT_MODE) {
		// redraw the background buffer
		gui.logo.draw = true;
		drawBackground();
		gui.devicelist.draw = true;
		gui.redraw = true;
		if (!(gBootMode & kBootModeQuiet)) {
 
			// Check if "Boot Banner"=N switch is present in config file.
			getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->chameleonConfig); 
			if (showBootBanner) {
				// Display banner and show hardware info.
				gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);
			}

			// redraw background
			memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);
		}
	} else {
		// Clear screen and hide the blinking cursor.
		clearScreenRows(kMenuTopRow, kMenuTopRow + 2);
		changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);
	}

	nextRow = kMenuTopRow;
	showPrompt = true;

	if (gDeviceCount) {
		if( bootArgs->Video.v_display == VGA_TEXT_MODE ) {
			printf("Use \30\31 keys to select the startup volume.");
		}
		showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
		nextRow += MIN( gDeviceCount, kMenuMaxItems ) + 3;
	}

	// Show the boot prompt.
	showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
	showBootPrompt( nextRow, showPrompt );
	
	do {
		if (bootArgs->Video.v_display != VGA_TEXT_MODE) {
			// redraw background
			memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
			// reset cursor co-ords
			gui.debug.cursor = pos( gui.screen.width - 160 , 10 );
		}
		key = getchar();
		updateMenu( key, (void **) &menuBVR );
		newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);

		if (newShowPrompt != showPrompt) {
			showPrompt = newShowPrompt;
			showBootPrompt( nextRow, showPrompt );
		}

		if (showPrompt) {
			updateBootArgs(key);
		}

		switch (key) {
		case KEY_ENTER:
			if (gui.menu.draw) { 
				key=0;
				break;
			}
			if (*gBootArgs == '?') {
				char * argPtr = gBootArgs;

				// Skip the leading "?" character.
				argPtr++;
				getNextArg(&argPtr, booterCommand);
				getNextArg(&argPtr, booterParam);

				/*
				* TODO: this needs to be refactored.
				*/
				if (strcmp( booterCommand, "video" ) == 0) {
					if (bootArgs->Video.v_display != VGA_TEXT_MODE) {
						showInfoBox(getVBEInfoString(), getVBEModeInfoString());
					} else {
						printVBEModeInfo();
					}
				} else if ( strcmp( booterCommand, "memory" ) == 0) {
					if (bootArgs->Video.v_display != VGA_TEXT_MODE ) {
						showInfoBox("Memory Map", getMemoryInfoString());
					} else {
						printMemoryInfo();
					}
				} else if (strcmp(booterCommand, "lspci") == 0) {
					lspci();
				} else if (strcmp(booterCommand, "log") == 0) {
			                showTextBuffer(msgbuf, strlen(msgbuf));
				} else if (strcmp(booterCommand, "more") == 0) {
					showTextFile(booterParam);
				} else if (strcmp(booterCommand, "rd") == 0) {
					processRAMDiskCommand(&argPtr, booterParam);
				} else if (strcmp(booterCommand, "norescan") == 0) {
					if (gEnableCDROMRescan) {
						gEnableCDROMRescan = false;
						break;
					}
				} else {
					showHelp();
				}
				key = 0;
				showBootPrompt(nextRow, showPrompt);
				break;
			}
			gBootVolume = menuBVR;
			setRootVolume(menuBVR);
			gBIOSDev = menuBVR->biosdev;
			break;

		case KEY_ESC:
			clearBootArgs();
			break;

		case KEY_F5:
			// New behavior:
			// Clear gBootVolume to restart the loop
			// if the user enabled rescanning the optical drive.
			// Otherwise boot the default boot volume.
			if (gEnableCDROMRescan) {
				gBootVolume = NULL;
				clearBootArgs();
			}
			break;

		case KEY_F10:
			gScanSingleDrive = false;
			scanDisks(gBIOSDev, &bvCount);
			gBootVolume = NULL;
			clearBootArgs();
			break;

		case KEY_TAB:
			// New behavior:
			// Switch between text & graphic interfaces
			// Only Permitted if started in graphics interface
			if (useGUI) {
				if (bootArgs->Video.v_display != VGA_TEXT_MODE) {
					setVideoMode(VGA_TEXT_MODE, 0);

					setCursorPosition(0, 0, 0);
					clearScreenRows(0, kScreenLastRow);

					// Display banner and show hardware info.
					printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);
					printf(getVBEInfoString());

					clearScreenRows(kMenuTopRow, kMenuTopRow + 2);
					changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);

					nextRow = kMenuTopRow;
					showPrompt = true;

					if (gDeviceCount) {
						printf("Use \30\31 keys to select the startup volume.");
						showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);
						nextRow += MIN(gDeviceCount, kMenuMaxItems) + 3;
					}

					showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
					showBootPrompt(nextRow, showPrompt);
					//changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );
				} else {
					gui.redraw = true;
					setVideoMode(GRAPHICS_MODE, 0);
					updateVRAM();
                    			updateGraphicBootPrompt();
				}
			}
			key = 0;
			break;

		default:
			key = 0;
			break;
		}
	} while (0 == key);

done:
	if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
		clearScreenRows(kMenuTopRow, kScreenLastRow);
		changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);
	}
	shouldboot = false;
	gui.menu.draw = false;
	if (menuItems) {
		free(menuItems);
		menuItems = NULL;
	}
	execute_hook("BootOptions", gBootArgs, gBootArgsPtr, NULL, NULL);
	return 0;
}
Пример #22
0
// Release on snapper
long ShutterBug::onReleaseSnapper(FXObject*,FXSelector sel,void*){
  register FXint which=FXSELID(sel)-ID_SNAPPER_0;
  mode=MODE_NONE;
  changeCursor(which,mode);
  return 1;
  }
Пример #23
0
static int updateMenu( int key, void ** paramPtr )
{
    int moved = 0;

    union {
        struct {
            unsigned int
                selectionUp   : 1,
                selectionDown : 1,
                scrollUp      : 1,
                scrollDown    : 1;
        } f;
        unsigned int w;
    } draw = {{0}};

    if ( gMenuItems == NULL )
		return 0;

	if( bootArgs->Video.v_display == GRAPHICS_MODE )
	{
		int res;
		
		// set navigation keys for horizontal layout as defaults
		int previous	= 0x4B00;		// left arrow
		int subsequent	= 0x4D00;		// right arrow
		int menu		= 0x5000;		// down arrow
		
		if ( gui.layout == VerticalLayout )
		{
			// set navigation keys for vertical layout
			previous	= 0x4800;		// up arrow
			subsequent	= 0x5000;		// down arrow
			menu		= 0x4B00;		// right arrow
		} 

		if ( key == previous )
		{
			if ( gMenuSelection > gMenuTop )
				draw.f.selectionUp = 1;
			else if ( gMenuTop > 0 )
				draw.f.scrollDown = 1;
			
		}
		
		else if ( key ==  subsequent )
		{
			if ( gMenuSelection != gMenuBottom)
				draw.f.selectionDown = 1;
			else if ( gMenuBottom < ( gMenuItemCount - 1 ) )
				draw.f.scrollUp = 1;
		}
		
		else if ( key == menu )
		{
			if ( gui.menu.draw )
				updateInfoMenu(key);
			else
				drawInfoMenu();
		}

		else if ( gui.menu.draw )
		{
			res = updateInfoMenu(key);

			if ( res == CLOSE_INFO_MENU )
				gui.menu.draw = false;
			else
			{
				shouldboot = ( res != DO_NOT_BOOT );
				
				if ( shouldboot )
					gui.menu.draw = false;

				switch (res)
				{
					case BOOT_NORMAL:
						gVerboseMode = false;
						gBootMode = kBootModeNormal;
						break;
						
					case BOOT_VERBOSE:
						gVerboseMode = true;
						gBootMode = kBootModeNormal;
						addBootArg(kVerboseModeFlag);
						break;
						
					case BOOT_IGNORECACHE:
						gVerboseMode = false;
						gBootMode = kBootModeNormal;
						addBootArg(kIgnoreCachesFlag);
						break;
						
					case BOOT_SINGLEUSER:
						gVerboseMode = true;
						gBootMode = kBootModeNormal;
						addBootArg(kSingleUserModeFlag);
						break;
				}
				
			}
			
		}	
			
	} else {
		switch ( key )
		{
        	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;
		}
	}

    if ( draw.w )
    {
        if ( draw.f.scrollUp )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);
            gMenuTop++; gMenuBottom++;
			gMenuStart++; gMenuEnd++;
            draw.f.selectionDown = 1;
        }

        if ( draw.f.scrollDown )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);
            gMenuTop--; gMenuBottom--;
            gMenuStart--; gMenuEnd--;
            draw.f.selectionUp = 1;
        }

        if ( draw.f.selectionUp || draw.f.selectionDown )
        {

			CursorState cursorState;

			// Set cursor at current position, and clear inverse video.
	
			if( bootArgs->Video.v_display == VGA_TEXT_MODE )
			{
				changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop, kCursorTypeHidden, &cursorState );
				printMenuItem( &gMenuItems[gMenuSelection], 0 );
			}

			if ( draw.f.selectionUp )
			{
				gMenuSelection--;
				if(( gMenuSelection - gMenuStart) == -1 )
				{
					gMenuStart--;
					gMenuEnd--;
				}
				
			} else {
			gMenuSelection++;
			if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 )
			{
				gMenuStart++;
				gMenuEnd++;
			}
	    }

		if( bootArgs->Video.v_display == VGA_TEXT_MODE )
	    {
			moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );
			printMenuItem( &gMenuItems[gMenuSelection], 1 );
			restoreCursor( &cursorState );

	    } else

			drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);

	}

        *paramPtr = gMenuItems[gMenuSelection].param;        
        moved = 1;
    }

	return moved;
}
Пример #24
0
void CursorManager::setLeftCursor() {
	changeCursor("leftarrow");
}
Пример #25
0
void EventsManager::setCursor2(CursorType cursorId) {
    _cursorId = cursorId;
    _newCursorId = cursorId;
    changeCursor();
}
Пример #26
0
int
getBootOptions(BOOL firstRun)
{
    int     i;
    int     key;
    int     selectIndex = 0;
    int     bvCount;
    int     nextRow;
    int     timeout;
    BVRef   bvr;
    BVRef   bvChain;
    BVRef   menuBVR;
    BOOL    showPrompt, newShowPrompt;
    MenuItem *  menuItems = NULL;

    // Allow user to override default timeout.

    if ( getIntForKey(kTimeoutKey, &timeout) == NO )
    {
        timeout = kBootTimeout;
    }

    // If the user is holding down a shift key,
    // abort quiet mode.
    if ( ( readKeyboardShiftFlags() & 0x0F ) != 0 ) {
        gBootMode &= ~kBootModeQuiet;
    }

    // If user typed F8, abort quiet mode,
    // and display the menu.
    if (flushKeyboardBuffer()) {
        gBootMode &= ~kBootModeQuiet;
        timeout = 0;
    }

    clearBootArgs();

    setCursorPosition( 0, 0, 0 );
    clearScreenRows( 0, kScreenLastRow );
    if ( ! ( gBootMode & kBootModeQuiet ) ) {
        // Display banner and show hardware info. 
        printf( bootBanner, (bootArgs->convmem + bootArgs->extmem) / 1024 );
        printVBEInfo();
    }

    changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );

    verbose("Scanning device %x...", gBIOSDev);

    // Get a list of bootable volumes on the device.

    bvChain = scanBootVolumes( gBIOSDev, &bvCount );
    gBootVolume = menuBVR = selectBootVolume( bvChain );

#if 0
    // When booting from CD (via HD emulation), default to hard
    // drive boot when possible. 

    if ( gBootVolume->part_type == FDISK_BOOTER &&
         gBootVolume->biosdev   == 0x80 )
    {
        // Scan the original device 0x80 that has been displaced
        // by the CD-ROM.

        BVRef hd_bvr = selectBootVolume(scanBootVolumes(0x81, 0));
        if ( hd_bvr->flags & kBVFlagNativeBoot )
        {
            int key = countdown("Press C to start up from CD-ROM.",
                                kMenuTopRow, 5);
            
            if ( (key & 0x5f) != 'c' )
            {
                gBootVolume = hd_bvr;
                gBIOSDev = hd_bvr->biosdev;
                initKernBootStruct( gBIOSDev );
                goto done;
            }
        }
    }
#endif

    if ( gBootMode & kBootModeQuiet )
    {
        // No input allowed from user.
        goto done;
    }

    if ( firstRun && ( timeout > 0 ) &&
         ( countdown("Press any key to enter startup options.",
                     kMenuTopRow, timeout) == 0 ) )
    {
        goto done;
    }

    if ( bvCount )
    {
        // Allocate memory for an array of menu items.

        menuItems = (MenuItem *) malloc( sizeof(MenuItem) * bvCount );
        if ( menuItems == NULL ) goto done;

        // Associate a menu item for each BVRef.

        for ( bvr = bvChain, i = bvCount - 1, selectIndex = 0;
              bvr; bvr = bvr->next, i-- )
        {
            getBootVolumeDescription( bvr, menuItems[i].name, 80, YES );
            menuItems[i].param = (void *) bvr;
            if ( bvr == menuBVR ) selectIndex = i;
        }
    }

    // Clear screen and hide the blinking cursor.

    clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );
    changeCursor( 0, kMenuTopRow, kCursorTypeHidden, 0 );
    nextRow = kMenuTopRow;
    showPrompt = YES;

    // Show the menu.

    if ( bvCount )
    {
        printf("Use \30\31 keys to select the startup volume.");
        showMenu( menuItems, bvCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
        nextRow += min( bvCount, kMenuMaxItems ) + 3;
    }

    // Show the boot prompt.

    showPrompt = (bvCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
    showBootPrompt( nextRow, showPrompt );

    do {
        key = getc();

        updateMenu( key, (void **) &menuBVR );

        newShowPrompt = (bvCount == 0) ||
                        (menuBVR->flags & kBVFlagNativeBoot);

        if ( newShowPrompt != showPrompt )
        {
            showPrompt = newShowPrompt;
            showBootPrompt( nextRow, showPrompt );
        }
        if ( showPrompt ) updateBootArgs( key );

        switch ( key & kASCIIKeyMask )
        {
            case kReturnKey:
                if ( *gBootArgs == '?' )
                {
                    if ( strcmp( gBootArgs, "?video" ) == 0 ) {
                        printVBEModeInfo();
                    } else if ( strcmp( gBootArgs, "?memory" ) == 0 ) {
                        printMemoryInfo();
                    } else {
                        showHelp();
                    }
                    key = 0;
                    showBootPrompt( nextRow, showPrompt );
                    break;
                }
                gBootVolume = menuBVR;
                break;

            case kEscapeKey:
                clearBootArgs();
                break;

            default:
                key = 0;
        }
    }
    while ( 0 == key );

done:
    firstRun = NO;

    clearScreenRows( kMenuTopRow, kScreenLastRow );
    changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );

    if ( menuItems ) free(menuItems);

    return 0;
}