From 1472f25bad23cab20eeae40af5742061f303210e Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 13 Oct 2019 15:48:07 +0100 Subject: [PATCH] Save-state: show an error MsgBox if old HDD v1 save-state and PC is in $Cnss HDD firmware --- bin/History.txt | 3 ++- source/Harddisk.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/History.txt b/bin/History.txt index 3918bdff..8a88ba16 100644 --- a/bin/History.txt +++ b/bin/History.txt @@ -16,7 +16,7 @@ Tom Charlesworth - -clock-multiplier , where value is a [0.5-3.9] base-clock multiplier (ie. same as the Config UI's slider) - -model . [Change #666] Debugger: support showing video v,h and cycle count. - - videoinfo to configure display. + - added debugger command: videoinfo to configure display. - added auto-run of DebuggerAutoRun.txt on AppleWin initial start-up. . [Bug #700] Fixed ProDOS8 2.5.0 alpha6: - support INC $C08B (and similar) to set LC to write mode - 65C02 only. @@ -29,6 +29,7 @@ Tom Charlesworth - added '-s1 empty', '-s3 empty' and '-s6 empty' too. . [Bug #404] a2audit.dsk 1.06 now working. (See #700) . [Bug #319] SmartPort return address was wrong when crossing page (fix to slot-7 HDD's firmware). + - NB. Old save-states where the 6502's PC is in the old firmware now can't be loaded. (AppleWin will show an error) . [PR #687] Replace char * with std::string. diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index ea65d70e..6f861ea1 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "StdAfx.h" #include "Applewin.h" +#include "CPU.h" #include "DiskImage.h" // ImageError_e, Disk_Status_e #include "DiskImageHelper.h" #include "Frame.h" @@ -711,6 +712,10 @@ bool HD_ImageSwap(void) //=========================================================================== +// Unit version history: +// 2: Updated $Csnn firmware to fix GH#319 +static const UINT kUNIT_VERSION = 2; + #define SS_YAML_VALUE_CARD_HDD "Generic HDD" #define SS_YAML_KEY_CURRENT_UNIT "Current Unit" @@ -757,7 +762,7 @@ void HD_SaveSnapshot(YamlSaveHelper& yamlSaveHelper) if (!HD_CardIsEnabled()) return; - YamlSaveHelper::Slot slot(yamlSaveHelper, HD_GetSnapshotCardName(), g_uSlot, 1); + YamlSaveHelper::Slot slot(yamlSaveHelper, HD_GetSnapshotCardName(), g_uSlot, kUNIT_VERSION); YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE); yamlSaveHelper.Save("%s: %d # b7=unit\n", SS_YAML_KEY_CURRENT_UNIT, g_nHD_UnitNum); @@ -836,9 +841,12 @@ bool HD_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version, co if (slot != 7) // fixme throw std::string("Card: wrong slot"); - if (version != 1) + if (version < 1 || version > kUNIT_VERSION) throw std::string("Card: wrong version"); + if (version == 1 && (regs.pc >> 8) == (0xC0|slot)) + throw std::string("HDD card: 6502 is running old HDD firmware"); + g_nHD_UnitNum = yamlLoadHelper.LoadUint(SS_YAML_KEY_CURRENT_UNIT); // b7=unit g_nHD_Command = yamlLoadHelper.LoadUint(SS_YAML_KEY_COMMAND);