--- previous/src/change.c 2018/04/24 19:25:10 1.1 +++ previous/src/change.c 2018/04/24 19:27:39 1.1.1.3 @@ -25,7 +25,14 @@ const char Change_fileid[] = "Hatari cha #include "statusbar.h" #include "video.h" #include "hatari-glue.h" +#include "scsi.h" +#define DEBUG 1 +#if DEBUG +#define Dprintf(a) printf(a) +#else +#define Dprintf(a) +#endif /*-----------------------------------------------------------------------*/ /** @@ -34,7 +41,130 @@ const char Change_fileid[] = "Hatari cha */ bool Change_DoNeedReset(CNF_PARAMS *current, CNF_PARAMS *changed) { - return true; + /* Did we change ROM file? */ + if (current->System.nMachineType == NEXT_CUBE030 && strcmp(current->Rom.szRom030FileName, changed->Rom.szRom030FileName)) { + printf("rom030 reset\n"); + return true; + } + if (current->System.nMachineType == NEXT_CUBE040 || current->System.nMachineType == NEXT_STATION) { + if (!current->System.bTurbo && strcmp(current->Rom.szRom040FileName, changed->Rom.szRom040FileName)) { + printf("rom040 reset\n"); + return true; + } + if (current->System.bTurbo && strcmp(current->Rom.szRomTurboFileName, changed->Rom.szRomTurboFileName)) { + printf("romturbo reset\n"); + return true; + } + } + + /* Did we change machine type? */ + if (current->System.nMachineType != changed->System.nMachineType) { + printf("machine type reset\n"); + return true; + } + if (current->System.bColor != changed->System.bColor) { + printf("machine type reset (color)\n"); + return true; + } + if (current->System.bTurbo != changed->System.bTurbo) { + printf("machine type reset (turbo)\n"); + return true; + } + + /* Did we change CPU type? */ + if (current->System.nCpuLevel != changed->System.nCpuLevel) { + printf("cpu type reset\n"); + return true; + } + + /* Did we change FPU type? */ + if (current->System.n_FPUType != changed->System.n_FPUType) { + printf("fpu type reset\n"); + return true; + } + + /* Did we change SCSI controller? */ + if (current->System.nSCSI != changed->System.nSCSI) { + printf("scsi controller reset\n"); + return true; + } + + /* Did we change RTC chip? */ + if (current->System.nRTC != changed->System.nRTC) { + printf("rtc chip reset\n"); + return true; + } + + /* Did we change ADB emulation? */ + if (current->System.bADB != changed->System.bADB) { + printf("adb reset\n"); + return true; + } + + /* Did we change memory size? */ + int i; + for (i = 0; i < 4; i++) { + if (current->Memory.nMemoryBankSize[i] != changed->Memory.nMemoryBankSize[i]) { + printf("memory size reset\n"); + return true; + } + } + + /* Did we change boot options? */ + if (current->Boot.nBootDevice != changed->Boot.nBootDevice) { + printf("boot options reset\n"); + return true; + } + if (current->Boot.bEnableDRAMTest != changed->Boot.bEnableDRAMTest) { + printf("boot options reset\n"); + return true; + } + if (current->Boot.bEnablePot != changed->Boot.bEnablePot) { + printf("boot options reset\n"); + return true; + } + if (current->Boot.bEnableSoundTest != changed->Boot.bEnableSoundTest) { + printf("boot options reset\n"); + return true; + } + if (current->Boot.bEnableSCSITest != changed->Boot.bEnableSCSITest) { + printf("boot options reset\n"); + return true; + } + if (current->Boot.bLoopPot != changed->Boot.bLoopPot) { + printf("boot options reset\n"); + return true; + } + if (current->Boot.bVerbose != changed->Boot.bVerbose) { + printf("boot options reset\n"); + return true; + } + if (current->Boot.bExtendedPot != changed->Boot.bExtendedPot) { + printf("boot options reset\n"); + return true; + } + + /* Did we change SCSI disk? */ + int target; + bool bSCSIdisk_change = false; + for (target = 0; target < ESP_MAX_DEVS; target++) { + if (!current->SCSI.target[target].bCDROM || !(current->SCSI.target[target].bCDROM == changed->SCSI.target[target].bCDROM)) { + if ((current->SCSI.target[target].bAttached || current->SCSI.target[target].bAttached != changed->SCSI.target[target].bAttached)) { + if (strcmp(current->SCSI.target[target].szImageName, changed->SCSI.target[target].szImageName)) { + bSCSIdisk_change = true; + break; + } + } + } + } + if (bSCSIdisk_change) { + printf("scsi disk reset\n"); + return true; + } + + /* Else no reset is required */ + printf("No Reset needed!\n"); + return false; } @@ -42,11 +172,11 @@ bool Change_DoNeedReset(CNF_PARAMS *curr /** * Copy details back to configuration and perform reset. */ -void Change_CopyChangedParamsToConfiguration(CNF_PARAMS *current, CNF_PARAMS *changed, bool bForceReset) +bool Change_CopyChangedParamsToConfiguration(CNF_PARAMS *current, CNF_PARAMS *changed, bool bForceReset) { bool NeedReset; bool bReInitGemdosDrive = false; - bool bReInitAcsiEmu = false; + bool bReInitSCSIEmu = false; bool bReInitIDEEmu = false; bool bReInitIoMem = false; bool bScreenModeChange = false; @@ -54,12 +184,21 @@ void Change_CopyChangedParamsToConfigura bool bFloppyInsert[MAX_FLOPPYDRIVES]; 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? */ + int target; + for (target = 0; target < ESP_MAX_DEVS; target++) { + if (!NeedReset && (current->SCSI.target[target].bAttached != changed->SCSI.target[target].bAttached || strcmp(current->SCSI.target[target].szImageName, changed->SCSI.target[target].szImageName))) { + bReInitSCSIEmu = true; + break; + } + } /* Copy details to configuration, * so it can be saved out or set on reset @@ -71,25 +210,45 @@ void Change_CopyChangedParamsToConfigura /* 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(); + } /* Force things associated with screen change */ if (bScreenModeChange) { + Dprintf("- screenmode<\n"); Screen_ModeChanged(); } /* Do we need to perform reset? */ if (NeedReset) { - Reset_Cold(); + 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 */ @@ -100,6 +259,8 @@ void Change_CopyChangedParamsToConfigura /* update statusbar info (CPU, MHz, mem etc) */ Statusbar_UpdateInfo(); + Dprintf("done.\n"); + return true; } @@ -122,7 +283,7 @@ static bool Change_Options(int argc, con /* Check if reset is required and ask user if he really wants to continue */ if (bOK && Change_DoNeedReset(¤t, &ConfigureParams) - && current.Log.nAlertDlgLogLevel >= LOG_WARN) { + && current.Log.nAlertDlgLogLevel > LOG_FATAL) { bOK = DlgAlert_Query("The emulated system must be " "reset to apply these changes. " "Apply changes now and reset " @@ -130,7 +291,11 @@ static bool Change_Options(int argc, con } /* Copy details to configuration */ if (bOK) { - Change_CopyChangedParamsToConfiguration(¤t, &ConfigureParams, false); + if (!Change_CopyChangedParamsToConfiguration(¤t, &ConfigureParams, false)) { + ConfigureParams = current; + DlgAlert_Notice("Return to old parameters..."); + Reset_Cold(); + } } else { ConfigureParams = current; }