--- previous/src/change.c 2018/04/24 19:27:39 1.1.1.3 +++ previous/src/change.c 2018/04/24 19:31:27 1.1.1.5 @@ -26,6 +26,10 @@ const char Change_fileid[] = "Hatari cha #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 @@ -41,6 +45,8 @@ 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"); @@ -72,16 +78,30 @@ bool Change_DoNeedReset(CNF_PARAMS *curr } /* Did we change CPU type? */ - if (current->System.nCpuLevel != changed->System.nCpuLevel) { + 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) { @@ -95,14 +115,13 @@ bool Change_DoNeedReset(CNF_PARAMS *curr return true; } - /* Did we change ADB emulation? */ - if (current->System.bADB != changed->System.bADB) { - printf("adb reset\n"); + /* Did we change NBIC emulation? */ + if (current->System.bNBIC != changed->System.bNBIC) { + printf("nbic 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"); @@ -145,23 +164,65 @@ bool Change_DoNeedReset(CNF_PARAMS *curr } /* 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; - } - } - } + 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 (bSCSIdisk_change) { + 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; @@ -175,14 +236,9 @@ bool Change_DoNeedReset(CNF_PARAMS *curr bool Change_CopyChangedParamsToConfiguration(CNF_PARAMS *current, CNF_PARAMS *changed, bool bForceReset) { bool NeedReset; - bool bReInitGemdosDrive = false; - bool bReInitSCSIEmu = 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? */ @@ -191,13 +247,23 @@ bool Change_CopyChangedParamsToConfigura 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; - } + /* 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, @@ -211,27 +277,18 @@ bool 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 Ethernet? */ + if (bReInitEnetEmu) { + Dprintf("- Ethernet<\n"); + Ethernet_Reset(false); } - - /* 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 Sound? */ + if (bReInitSoundEmu) { + Dprintf("- Sound<\n"); + Sound_Reset(); } - + /* Force things associated with screen change */ if (bScreenModeChange) { @@ -242,13 +299,16 @@ bool Change_CopyChangedParamsToConfigura /* Do we need to perform reset? */ if (NeedReset) { - const char *err_msg; + /* Check if all necessary files exist */ + Dialog_CheckFiles(); + if (bQuitProgram) + { + SDL_Quit(); + exit(-2); + } + Dprintf("- reset\n"); - err_msg=Reset_Cold(); -// if (err_msg!=NULL) { -// DlgAlert_Notice(err_msg); -// return false; -// } + Reset_Cold(); } /* Go into/return from full screen if flagged */