diff --git a/source/Disk.cpp b/source/Disk.cpp index 357e9ee2..96a029a7 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -1206,7 +1206,7 @@ static void DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit) yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK, g_aFloppyDisk[unit].track); yamlSaveHelper.SaveUint(SS_YAML_KEY_PHASE, g_aFloppyDisk[unit].phase); yamlSaveHelper.SaveHex16(SS_YAML_KEY_BYTE, g_aFloppyDisk[unit].byte); - yamlSaveHelper.SaveUint(SS_YAML_KEY_WRITE_PROTECTED, g_aFloppyDisk[unit].bWriteProtected); + yamlSaveHelper.SaveBool(SS_YAML_KEY_WRITE_PROTECTED, g_aFloppyDisk[unit].bWriteProtected); yamlSaveHelper.SaveUint(SS_YAML_KEY_SPINNING, g_aFloppyDisk[unit].spinning); yamlSaveHelper.SaveUint(SS_YAML_KEY_WRITE_LIGHT, g_aFloppyDisk[unit].writelight); yamlSaveHelper.SaveHex16(SS_YAML_KEY_NIBBLES, g_aFloppyDisk[unit].nibbles); @@ -1227,11 +1227,11 @@ void DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE); yamlSaveHelper.SaveHex4(SS_YAML_KEY_PHASES, phases); yamlSaveHelper.SaveUint(SS_YAML_KEY_CURRENT_DRIVE, currdrive); - yamlSaveHelper.SaveUint(SS_YAML_KEY_DISK_ACCESSED, diskaccessed); - yamlSaveHelper.SaveUint(SS_YAML_KEY_ENHANCE_DISK, enhancedisk); + yamlSaveHelper.SaveBool(SS_YAML_KEY_DISK_ACCESSED, diskaccessed == TRUE); + yamlSaveHelper.SaveBool(SS_YAML_KEY_ENHANCE_DISK, enhancedisk == TRUE); yamlSaveHelper.SaveHex8(SS_YAML_KEY_FLOPPY_LATCH, floppylatch); - yamlSaveHelper.SaveUint(SS_YAML_KEY_FLOPPY_MOTOR_ON, floppymotoron); - yamlSaveHelper.SaveUint(SS_YAML_KEY_FLOPPY_WRITE_MODE, floppywritemode); + yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_MOTOR_ON, floppymotoron == TRUE); + yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_WRITE_MODE, floppywritemode == TRUE); DiskSaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_1); DiskSaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_2); @@ -1277,7 +1277,7 @@ static void DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit) g_aFloppyDisk[unit].track = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK); g_aFloppyDisk[unit].phase = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASE); g_aFloppyDisk[unit].byte = yamlLoadHelper.LoadUint(SS_YAML_KEY_BYTE); - yamlLoadHelper.LoadUint(SS_YAML_KEY_WRITE_PROTECTED); // Consume + yamlLoadHelper.LoadBool(SS_YAML_KEY_WRITE_PROTECTED); // Consume g_aFloppyDisk[unit].spinning = yamlLoadHelper.LoadUint(SS_YAML_KEY_SPINNING); g_aFloppyDisk[unit].writelight = yamlLoadHelper.LoadUint(SS_YAML_KEY_WRITE_LIGHT); g_aFloppyDisk[unit].nibbles = yamlLoadHelper.LoadUint(SS_YAML_KEY_NIBBLES); @@ -1325,11 +1325,11 @@ bool DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT vers phases = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASES); currdrive = yamlLoadHelper.LoadUint(SS_YAML_KEY_CURRENT_DRIVE); - diskaccessed = yamlLoadHelper.LoadUint(SS_YAML_KEY_DISK_ACCESSED); - enhancedisk = yamlLoadHelper.LoadUint(SS_YAML_KEY_ENHANCE_DISK); + diskaccessed = yamlLoadHelper.LoadBool(SS_YAML_KEY_DISK_ACCESSED); + enhancedisk = yamlLoadHelper.LoadBool(SS_YAML_KEY_ENHANCE_DISK); floppylatch = yamlLoadHelper.LoadUint(SS_YAML_KEY_FLOPPY_LATCH); - floppymotoron = yamlLoadHelper.LoadUint(SS_YAML_KEY_FLOPPY_MOTOR_ON); - floppywritemode = yamlLoadHelper.LoadUint(SS_YAML_KEY_FLOPPY_WRITE_MODE); + floppymotoron = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_MOTOR_ON); + floppywritemode = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_WRITE_MODE); // Eject all disks first in case Drive-2 contains disk to be inserted into Drive-1 for(UINT i=0; iSpeechChip); yamlSaveHelper.SaveHex4(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister); - yamlSaveHelper.Save("%s: %d # Not supported\n", SS_YAML_KEY_TIMER1_IRQ, 0); - yamlSaveHelper.Save("%s: %d # Not supported\n", SS_YAML_KEY_TIMER2_IRQ, 0); - yamlSaveHelper.Save("%s: %d # Not supported\n", SS_YAML_KEY_SPEECH_IRQ, 0); + yamlSaveHelper.Save("%s: %s # Not supported\n", SS_YAML_KEY_TIMER1_IRQ, "false"); + yamlSaveHelper.Save("%s: %s # Not supported\n", SS_YAML_KEY_TIMER2_IRQ, "false"); + yamlSaveHelper.Save("%s: %s # Not supported\n", SS_YAML_KEY_SPEECH_IRQ, "false"); nDeviceNum++; pMB++; @@ -2063,9 +2063,9 @@ bool MB_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version) LoadSnapshotSSI263(yamlLoadHelper, pMB->SpeechChip); pMB->nAYCurrentRegister = yamlLoadHelper.LoadUint(SS_YAML_KEY_AY_CURR_REG); - yamlLoadHelper.LoadUint(SS_YAML_KEY_TIMER1_IRQ); // Consume - yamlLoadHelper.LoadUint(SS_YAML_KEY_TIMER2_IRQ); // Consume - yamlLoadHelper.LoadUint(SS_YAML_KEY_SPEECH_IRQ); // Consume + yamlLoadHelper.LoadBool(SS_YAML_KEY_TIMER1_IRQ); // Consume + yamlLoadHelper.LoadBool(SS_YAML_KEY_TIMER2_IRQ); // Consume + yamlLoadHelper.LoadBool(SS_YAML_KEY_SPEECH_IRQ); // Consume yamlLoadHelper.PopMap(); @@ -2127,9 +2127,9 @@ void Phasor_SaveSnapshot(YamlSaveHelper& yamlSaveHelper, const UINT uSlot) SaveSnapshotSSI263(yamlSaveHelper, pMB->SpeechChip); yamlSaveHelper.SaveHex4(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister); - yamlSaveHelper.Save("%s: %d # Not supported\n", SS_YAML_KEY_TIMER1_IRQ, 0); - yamlSaveHelper.Save("%s: %d # Not supported\n", SS_YAML_KEY_TIMER2_IRQ, 0); - yamlSaveHelper.Save("%s: %d # Not supported\n", SS_YAML_KEY_SPEECH_IRQ, 0); + yamlSaveHelper.Save("%s: %s # Not supported\n", SS_YAML_KEY_TIMER1_IRQ, "false"); + yamlSaveHelper.Save("%s: %s # Not supported\n", SS_YAML_KEY_TIMER2_IRQ, "false"); + yamlSaveHelper.Save("%s: %s # Not supported\n", SS_YAML_KEY_SPEECH_IRQ, "false"); nDeviceNum += 2; pMB++; @@ -2168,9 +2168,9 @@ bool Phasor_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version LoadSnapshotSSI263(yamlLoadHelper, pMB->SpeechChip); pMB->nAYCurrentRegister = yamlLoadHelper.LoadUint(SS_YAML_KEY_AY_CURR_REG); - yamlLoadHelper.LoadUint(SS_YAML_KEY_TIMER1_IRQ); // Consume - yamlLoadHelper.LoadUint(SS_YAML_KEY_TIMER2_IRQ); // Consume - yamlLoadHelper.LoadUint(SS_YAML_KEY_SPEECH_IRQ); // Consume + yamlLoadHelper.LoadBool(SS_YAML_KEY_TIMER1_IRQ); // Consume + yamlLoadHelper.LoadBool(SS_YAML_KEY_TIMER2_IRQ); // Consume + yamlLoadHelper.LoadBool(SS_YAML_KEY_SPEECH_IRQ); // Consume yamlLoadHelper.PopMap(); diff --git a/source/ParallelPrinter.cpp b/source/ParallelPrinter.cpp index f295c958..f17609db 100644 --- a/source/ParallelPrinter.cpp +++ b/source/ParallelPrinter.cpp @@ -282,7 +282,7 @@ void Printer_SaveSnapshot(class YamlSaveHelper& yamlSaveHelper) yamlSaveHelper.SaveUint(SS_YAML_KEY_INACTIVITY, inactivity); yamlSaveHelper.SaveUint(SS_YAML_KEY_IDLELIMIT, g_PrinterIdleLimit); yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, g_szPrintFilename); - yamlSaveHelper.SaveUint(SS_YAML_KEY_FILEOPEN, (file != NULL) ? 1 : 0); + yamlSaveHelper.SaveBool(SS_YAML_KEY_FILEOPEN, (file != NULL) ? true : false); yamlSaveHelper.SaveBool(SS_YAML_KEY_DUMPTOPRINTER, g_bDumpToPrinter); yamlSaveHelper.SaveBool(SS_YAML_KEY_CONVERTENCODING, g_bConvertEncoding); yamlSaveHelper.SaveBool(SS_YAML_KEY_FILTERUNPRINTABLE, g_bFilterUnprintable); diff --git a/source/Video.cpp b/source/Video.cpp index e391ae0c..02d3720e 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -2963,7 +2963,7 @@ static std::string VideoGetSnapshotStructName(void) void VideoSaveSnapshot(YamlSaveHelper& yamlSaveHelper) { YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", VideoGetSnapshotStructName().c_str()); - yamlSaveHelper.SaveUint(SS_YAML_KEY_ALTCHARSET, g_nAltCharSetOffset ? 1 : 0); + yamlSaveHelper.SaveBool(SS_YAML_KEY_ALTCHARSET, g_nAltCharSetOffset ? true : false); yamlSaveHelper.SaveHex32(SS_YAML_KEY_VIDEOMODE, g_uVideoMode); yamlSaveHelper.SaveUint(SS_YAML_KEY_CYCLESTHISFRAME, g_dwCyclesThisFrame); } @@ -2973,7 +2973,7 @@ void VideoLoadSnapshot(YamlLoadHelper& yamlLoadHelper) if (!yamlLoadHelper.GetSubMap(VideoGetSnapshotStructName())) return; - g_nAltCharSetOffset = yamlLoadHelper.LoadUint(SS_YAML_KEY_ALTCHARSET) ? 256 : 0; + g_nAltCharSetOffset = yamlLoadHelper.LoadBool(SS_YAML_KEY_ALTCHARSET) ? 256 : 0; g_uVideoMode = yamlLoadHelper.LoadUint(SS_YAML_KEY_VIDEOMODE); g_dwCyclesThisFrame = yamlLoadHelper.LoadUint(SS_YAML_KEY_CYCLESTHISFRAME); diff --git a/source/YamlHelper.cpp b/source/YamlHelper.cpp index 4a415f3b..bc304b6d 100644 --- a/source/YamlHelper.cpp +++ b/source/YamlHelper.cpp @@ -313,7 +313,14 @@ UINT64 YamlLoadHelper::LoadUint64(const std::string key) bool YamlLoadHelper::LoadBool(const std::string key) { - return LoadUint(key) ? true : false; + bool bFound; + std::string value = m_yamlHelper.GetMapValue(*m_pMapYaml, key, bFound); + if (value == "true") + return true; + else if (value == "false") + return false; + m_bDoGetMapRemainder = false; + throw std::string(m_currentMapName + ": Missing: " + key); } std::string YamlLoadHelper::LoadString_NoThrow(const std::string& key, bool& bFound) @@ -393,7 +400,7 @@ void YamlSaveHelper::SaveHex64(const char* key, UINT64 value) void YamlSaveHelper::SaveBool(const char* key, bool value) { - SaveUint(key, value ? 1 : 0); + Save("%s: %s\n", key, value ? "true" : "false"); } void YamlSaveHelper::SaveString(const char* key, const char* value) @@ -401,8 +408,12 @@ void YamlSaveHelper::SaveString(const char* key, const char* value) Save("%s: %s\n", key, (value[0] != 0) ? value : "\"\""); } +// Pre: uMemSize must be multiple of 8 void YamlSaveHelper::SaveMemory(const LPBYTE pMemBase, const UINT uMemSize) { + if (uMemSize & 7) + throw std::string("Memory: size must be multiple of 8"); + const UINT kIndent = m_indent; const UINT kStride = 64;