--- previous/src/change.c 2018/04/24 19:25:10 1.1 +++ previous/src/change.c 2018/04/24 19:31:27 1.1.1.5 @@ -25,7 +25,18 @@ const char Change_fileid[] = "Hatari cha #include "statusbar.h" #include "video.h" #include "hatari-glue.h" - +#include "scsi.h" +#include "mo.h" +#include "floppy.h" +#include "ethernet.h" +#include "snd.h" + +#define DEBUG 1 +#if DEBUG +#define Dprintf(a) printf(a) +#else +#define Dprintf(a) +#endif /*-----------------------------------------------------------------------*/ /** @@ -34,7 +45,187 @@ const char Change_fileid[] = "Hatari cha */ bool Change_DoNeedReset(CNF_PARAMS *current, CNF_PARAMS *changed) { + int i; + + /* 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) || + (current->System.nCpuFreq != changed->System.nCpuFreq)) { + printf("cpu type reset\n"); + return true; + } + + /* Did we change the realtime flag? */ + if(current->System.bRealtime != changed->System.bRealtime) { + printf("realtime flag 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 DSP type or memory? */ + if ((current->System.nDSPType != changed->System.nDSPType) || + (current->System.bDSPMemoryExpansion != changed->System.bDSPMemoryExpansion)) { + printf("dsp 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 NBIC emulation? */ + if (current->System.bNBIC != changed->System.bNBIC) { + printf("nbic reset\n"); + return true; + } + + /* Did we change memory size? */ + 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? */ + for (i = 0; i < ESP_MAX_DEVS; i++) { + if (current->SCSI.target[i].nDeviceType != changed->SCSI.target[i].nDeviceType || + (current->SCSI.target[i].nDeviceType==DEVTYPE_HARDDISK && + (current->SCSI.target[i].bWriteProtected != changed->SCSI.target[i].bWriteProtected || + strcmp(current->SCSI.target[i].szImageName, changed->SCSI.target[i].szImageName)))) { + printf("scsi disk reset\n"); + return true; + } + } + if(current->SCSI.nWriteProtection != changed->SCSI.nWriteProtection) { + printf("scsi disk reset\n"); + return true; + } + + /* Did we change MO drive? */ + for (i = 0; i < MO_MAX_DRIVES; i++) { + if (current->MO.drive[i].bDriveConnected != changed->MO.drive[i].bDriveConnected) { + printf("mo drive reset\n"); + return true; + } + } + + /* Did we change floppy drive? */ + for (i = 0; i < FLP_MAX_DRIVES; i++) { + if (current->Floppy.drive[i].bDriveConnected != changed->Floppy.drive[i].bDriveConnected) { + printf("floppy drive reset\n"); + return true; + } + } + + /* Did we change printer? */ + if (current->Printer.bPrinterConnected != changed->Printer.bPrinterConnected) { + printf("printer reset\n"); + return true; + } + + /* Did we change NeXTdimension? */ + if (current->Dimension.bEnabled != changed->Dimension.bEnabled || + current->Dimension.bI860Thread != changed->Dimension.bI860Thread || + current->Dimension.bMainDisplay != changed->Dimension.bMainDisplay || + strcmp(current->Dimension.szRomFileName, changed->Dimension.szRomFileName)) { + printf("dimension reset\n"); return true; + } + for (i = 0; i < 4; i++) { + if (current->Dimension.nMemoryBankSize[i] != changed->Dimension.nMemoryBankSize[i]) { + printf("dimension memory size reset\n"); + return true; + } + } + + /* Did we change monitor count? */ + if (current->Screen.nMonitorType != changed->Screen.nMonitorType && + (current->Screen.nMonitorType == MONITOR_TYPE_DUAL || + changed->Screen.nMonitorType == MONITOR_TYPE_DUAL)) { + printf("monitor reset\n"); + return true; + } + + /* Else no reset is required */ + printf("No Reset needed!\n"); + return false; } @@ -42,24 +233,38 @@ 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 bReInitIDEEmu = false; - bool bReInitIoMem = false; + bool bReInitEnetEmu = false; + bool bReInitSoundEmu = false; bool bScreenModeChange = false; - bool bReInitMidi = false; - 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); - + + /* Note: SCSI, 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; + } + + /* Do we need to change Screen configuration? */ + if (!NeedReset && + current->Screen.nMonitorType != changed->Screen.nMonitorType) { + } /* Copy details to configuration, * so it can be saved out or set on reset @@ -71,24 +276,38 @@ void Change_CopyChangedParamsToConfigura /* Copy details to global, if we reset copy them all */ Configuration_Apply(NeedReset); - - - /* Re-init IO memory map? */ - if (bReInitIoMem) - { - IoMem_Init(); - } - - + + /* 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) { + /* Check if all necessary files exist */ + Dialog_CheckFiles(); + if (bQuitProgram) + { + SDL_Quit(); + exit(-2); + } + + Dprintf("- reset\n"); Reset_Cold(); } @@ -100,6 +319,8 @@ void Change_CopyChangedParamsToConfigura /* update statusbar info (CPU, MHz, mem etc) */ Statusbar_UpdateInfo(); + Dprintf("done.\n"); + return true; } @@ -122,7 +343,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 +351,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; }