--- previous/src/change.c 2018/04/24 19:27:39 1.1.1.3 +++ previous/src/change.c 2018/04/24 19:30:00 1.1.1.4 @@ -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,7 +78,8 @@ 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; } @@ -82,6 +89,13 @@ bool Change_DoNeedReset(CNF_PARAMS *curr 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 +109,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 +158,59 @@ 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; + } + } + + /* 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; } } - if (bSCSIdisk_change) { - printf("scsi disk reset\n"); + + /* 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 || + 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,13 +224,12 @@ 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 bReInitEnetEmu = false; + bool bReInitSoundEmu = false; bool bReInitIoMem = false; + bool bReInitScreen = false; bool bScreenModeChange = false; - bool bReInitMidi = false; - bool bFloppyInsert[MAX_FLOPPYDRIVES]; int i; Dprintf("Changes for:\n"); @@ -192,13 +240,35 @@ bool Change_CopyChangedParamsToConfigura 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))) { + 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; + } + + /* Do we need to change Screen configuration? */ + if (!NeedReset && + current->Screen.nMonitorType != changed->Screen.nMonitorType) { + bReInitScreen = true; + } /* Copy details to configuration, * so it can be saved out or set on reset @@ -231,6 +301,24 @@ bool Change_CopyChangedParamsToConfigura 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(); + } + + /* Re-init Screen */ + if (bReInitScreen) { + Dprintf("- Screen<\n"); + Screen_SetFullUpdate(); + } /* Force things associated with screen change */ if (bScreenModeChange)