--- previous/src/change.c 2018/04/24 19:25:38 1.1.1.2 +++ previous/src/change.c 2018/04/24 19:27:39 1.1.1.3 @@ -25,8 +25,9 @@ const char Change_fileid[] = "Hatari cha #include "statusbar.h" #include "video.h" #include "hatari-glue.h" +#include "scsi.h" -#define DEBUG 0 +#define DEBUG 1 #if DEBUG #define Dprintf(a) printf(a) #else @@ -40,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; } @@ -48,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; @@ -66,7 +190,15 @@ void Change_CopyChangedParamsToConfigura 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 @@ -78,7 +210,14 @@ 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) @@ -86,7 +225,12 @@ void Change_CopyChangedParamsToConfigura 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) @@ -98,8 +242,13 @@ void Change_CopyChangedParamsToConfigura /* Do we need to perform reset? */ if (NeedReset) { + const char *err_msg; Dprintf("- reset\n"); - Reset_Cold(); + err_msg=Reset_Cold(); +// if (err_msg!=NULL) { +// DlgAlert_Notice(err_msg); +// return false; +// } } /* Go into/return from full screen if flagged */ @@ -111,6 +260,7 @@ void Change_CopyChangedParamsToConfigura /* update statusbar info (CPU, MHz, mem etc) */ Statusbar_UpdateInfo(); Dprintf("done.\n"); + return true; } @@ -141,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; }