Example #1
0
File: change.c Project: juddy/PrEV
/**
 * Change given Hatari options
 * Return false if parsing failed, true otherwise
 */
static bool Change_Options(int argc, const char *argv[])
{
	bool bOK;
	CNF_PARAMS current;

	Main_PauseEmulation(false);

	/* get configuration changes */
	current = ConfigureParams;
	ConfigureParams.Screen.bFullScreen = bInFullScreen;
	bOK = Opt_ParseParameters(argc, argv);

	/* Check if reset is required and ask user if he really wants to continue */
	if (bOK && Change_DoNeedReset(&current, &ConfigureParams)
	    && current.Log.nAlertDlgLogLevel > LOG_FATAL) {
		bOK = DlgAlert_Query("The emulated system must be "
				     "reset to apply these changes. "
				     "Apply changes now and reset "
				     "the emulator?");
	}
	/* Copy details to configuration */
	if (bOK) {
		if (!Change_CopyChangedParamsToConfiguration(&current, &ConfigureParams, false)) {
			ConfigureParams = current;
			DlgAlert_Notice("Return to old parameters...");
			Reset_Cold();
		}
	} else {
		ConfigureParams = current;
	}

	Main_UnPauseEmulation();
	return bOK;
}
Example #2
0
/**
 * Open Property sheet Options dialog.
 * 
 * We keep all our configuration details in a structure called
 * 'ConfigureParams'. When we open our dialog we make a backup
 * of this structure. When the user finally clicks on 'OK',
 * we can compare and makes the necessary changes.
 * 
 * Return true if user chooses OK, or false if cancel!
 */
bool Dialog_DoProperty(void)
{
	bool bOKDialog;  /* Did user 'OK' dialog? */
	bool bForceReset;
	bool bLoadedSnapshot;
	CNF_PARAMS current;

	Main_PauseEmulation(true);
	bForceReset = false;

	/* Copy details (this is so can restore if 'Cancel' dialog) */
	current = ConfigureParams;
	ConfigureParams.Screen.bFullScreen = bInFullScreen;
	bOKDialog = Dialog_MainDlg(&bForceReset, &bLoadedSnapshot);

	/* If a memory snapshot has been loaded, no further changes are required */
	if (bLoadedSnapshot)
	{
		Main_UnPauseEmulation();
		return true;
	}

	/* Check if reset is required and ask user if he really wants to continue then */
	if (bOKDialog && !bForceReset
	    && Change_DoNeedReset(&current, &ConfigureParams)
	    && ConfigureParams.Log.nAlertDlgLogLevel > LOG_FATAL) {
		bOKDialog = DlgAlert_Query("The emulated system must be "
		                           "reset to apply these changes. "
		                           "Apply changes now and reset "
		                           "the emulator?");
	}

	/* Copy details to configuration */
	if (bOKDialog) {
		Change_CopyChangedParamsToConfiguration(&current, &ConfigureParams, bForceReset);
	} else {
		ConfigureParams = current;
	}

	Main_UnPauseEmulation();
    
	if (bQuitProgram)
		Main_RequestQuit();
 
	return bOKDialog;
}
Example #3
0
File: change.c Project: juddy/PrEV
/**
 * Copy details back to configuration and perform reset.
 */
bool Change_CopyChangedParamsToConfiguration(CNF_PARAMS *current, CNF_PARAMS *changed, bool bForceReset)
{
	bool NeedReset;
	bool bReInitSCSIEmu = false;
	bool bReInitEnetEmu = false;
    bool bReInitSoundEmu = false;
	bool bReInitIoMem = false;
	bool bScreenModeChange = false;
	int i;

	Dprintf("Changes for:\n");
	/* Do we need to warn user that changes will only take effect after reset? */
	if (bForceReset)
		NeedReset = bForceReset;
	else
		NeedReset = Change_DoNeedReset(current, changed);
    
    /* Do we need to change SCSI disks? */
    for (i = 0; i < ESP_MAX_DEVS; i++) {
        if (!NeedReset &&
            (current->SCSI.target[i].bDiskInserted != changed->SCSI.target[i].bDiskInserted ||
             current->SCSI.target[i].bWriteProtected != changed->SCSI.target[i].bWriteProtected ||
             strcmp(current->SCSI.target[i].szImageName, changed->SCSI.target[i].szImageName))) {
            bReInitSCSIEmu = true;
            break;
        }
    }
    
    /* Note: MO and floppy disk insert/eject called from GUI */
    
    /* Do we need to change Ethernet connection? */
    if (!NeedReset && current->Ethernet.bEthernetConnected != changed->Ethernet.bEthernetConnected) {
        bReInitEnetEmu = true;
    }
    
    /* Do we need to change Sound configuration? */
    if (!NeedReset &&
        (current->Sound.bEnableSound != changed->Sound.bEnableSound ||
         current->Sound.bEnableMicrophone != changed->Sound.bEnableMicrophone)) {
        bReInitSoundEmu = true;
    }

	/* Copy details to configuration,
	 * so it can be saved out or set on reset
	 */
	if (changed != &ConfigureParams)
	{
		ConfigureParams = *changed;
	}

	/* Copy details to global, if we reset copy them all */
	Configuration_Apply(NeedReset);
    
    /* Check if all necessary files exist */
    Dialog_CheckFiles();
    if (bQuitProgram)
    {
        SDL_Quit();
        exit(-2);
    }

	/* Re-init IO memory map? */
	if (bReInitIoMem)
	{
		Dprintf("- IO mem<\n");
		IoMem_Init();
	}
    
    /* Re-init SCSI disks? */
    if (bReInitSCSIEmu) {
        Dprintf("- SCSI disks<\n");
        SCSI_Reset();
    }
    
    /* Re-init Ethernet? */
    if (bReInitEnetEmu) {
        Dprintf("- Ethernet<\n");
        Ethernet_Reset(false);
    }
    
    /* Re-init Sound? */
    if (bReInitSoundEmu) {
        Dprintf("- Sound<\n");
        Sound_Reset();
    }

	/* Force things associated with screen change */
	if (bScreenModeChange)
	{
		Dprintf("- screenmode<\n");
		Screen_ModeChanged();
	}

	/* Do we need to perform reset? */
	if (NeedReset)
	{
		const char *err_msg;
		Dprintf("- reset\n");
		err_msg=Reset_Cold();
//		if (err_msg!=NULL) {
//			DlgAlert_Notice(err_msg);
//			return false;
//		}
	}

	/* Go into/return from full screen if flagged */
	if (!bInFullScreen && ConfigureParams.Screen.bFullScreen)
		Screen_EnterFullScreen();
	else if (bInFullScreen && !ConfigureParams.Screen.bFullScreen)
		Screen_ReturnFromFullScreen();

	/* update statusbar info (CPU, MHz, mem etc) */
	Statusbar_UpdateInfo();
	Dprintf("done.\n");
	return true;
}