diff --git a/AppleWinExpress2019.vcxproj b/AppleWinExpress2019.vcxproj index 657c1223..4d56c86e 100644 --- a/AppleWinExpress2019.vcxproj +++ b/AppleWinExpress2019.vcxproj @@ -104,8 +104,6 @@ - - diff --git a/AppleWinExpress2019.vcxproj.filters b/AppleWinExpress2019.vcxproj.filters index 8fcd1399..2b95d516 100644 --- a/AppleWinExpress2019.vcxproj.filters +++ b/AppleWinExpress2019.vcxproj.filters @@ -522,12 +522,6 @@ Source Files\Emulator - - Source Files\_Headers - - - Source Files\_Headers - Source Files\Video diff --git a/source/Configuration/PageInput.cpp b/source/Configuration/PageInput.cpp index 8417b147..49b4f7c2 100644 --- a/source/Configuration/PageInput.cpp +++ b/source/Configuration/PageInput.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "PageInput.h" #include "PropertySheet.h" -#include "../SaveState_Structs_common.h" #include "../Common.h" #include "../Keyboard.h" #include "../Registry.h" diff --git a/source/Configuration/PageSound.cpp b/source/Configuration/PageSound.cpp index 38c52f32..3838c052 100644 --- a/source/Configuration/PageSound.cpp +++ b/source/Configuration/PageSound.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "PageSound.h" #include "PropertySheet.h" -#include "../SaveState_Structs_common.h" #include "../Common.h" #include "../CardManager.h" #include "../Mockingboard.h" diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index fa09f72a..1ea445e3 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -50,6 +50,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #define DEBUG_ASM_HASH 1 #define ALLOW_INPUT_LOWERCASE 1 +#define MAKE_VERSION(a,b,c,d) ((a<<24) | (b<<16) | (c<<8) | (d)) + // See /docs/Debugger_Changelog.txt for full details const int DEBUGGER_VERSION = MAKE_VERSION(2,9,1,14); @@ -3620,7 +3622,7 @@ bool MemoryDumpCheck (int nArgs, WORD * pAddress_ ) else if (strncmp(g_aArgs[1].sArg, "AY", 2) == 0) // AY8910 { nAddress = (g_aArgs[1].sArg[2] - '0') & 3; - pArg->eDevice = DEV_AY8910; + pArg->eDevice = DEV_AY8913; bUpdate = true; } #ifdef SUPPORT_Z80_EMU diff --git a/source/Debugger/Debug.h b/source/Debugger/Debug.h index 0f95dca4..f7c37fb5 100644 --- a/source/Debugger/Debug.h +++ b/source/Debugger/Debug.h @@ -1,6 +1,5 @@ #pragma once -#include "../SaveState_Structs_v1.h" // For SS_CARD_MOCKINGBOARD #include "../Common.h" #include "Debugger_Types.h" diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index 2ce9b0be..4c72df4e 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -1951,15 +1951,25 @@ void DrawMemory ( int line, int iMemDump ) DEVICE_e eDevice = pMD->eDevice; MemoryView_e iView = pMD->eView; - SS_CARD_MOCKINGBOARD_v1 SS_MB; + MockingboardCard::DEBUGGER_MB_CARD MB; + bool isMockingboardInSlot = false; - if ((eDevice == DEV_SY6522) || (eDevice == DEV_AY8910)) + if ((eDevice == DEV_SY6522) || (eDevice == DEV_AY8913)) { UINT slot = 4 + (nAddr >> 1); // Slot4 or Slot5 if (GetCardMgr().GetMockingboardCardMgr().IsMockingboard(slot)) - dynamic_cast(GetCardMgr().GetRef(slot)).GetSnapshot_v1(&SS_MB); - else // No MB in this slot - SS_MB.Hdr.UnitHdr.hdr.v2.Type = UT_Reserved; + { + dynamic_cast(GetCardMgr().GetRef(slot)).GetSnapshotForDebugger(&MB); + isMockingboardInSlot = true; + for (int i = 0; i < NUM_SUBUNITS_PER_MB; i++) + { + for (int j = 0; j < NUM_AY8913_PER_SUBUNIT; j++) + { + if (!MB.subUnit[i].isAYLatchedAddressValid[j]) + MB.subUnit[i].nAYCurrentRegister[j] = 0xff; + } + } + } } RECT rect = { 0 }; @@ -1984,7 +1994,7 @@ void DrawMemory ( int line, int iMemDump ) // sData = StrFormat("Mem at SY#%d", nAddr); sAddress = StrFormat( "SY#%d", nAddr ); } - else if (eDevice == DEV_AY8910) + else if (eDevice == DEV_AY8913) { // sData = StrFormat("Mem at AY#%d", nAddr); sAddress = StrFormat( "AY#%d", nAddr ); @@ -2027,7 +2037,7 @@ void DrawMemory ( int line, int iMemDump ) nCols = MAX_MEM_VIEW_TXT; } - if (eDevice == DEV_SY6522 || eDevice == DEV_AY8910) + if (eDevice == DEV_SY6522 || eDevice == DEV_AY8913) { iAddress = 0; nCols = 4; @@ -2065,16 +2075,16 @@ void DrawMemory ( int line, int iMemDump ) // else if (eDevice == DEV_SY6522) { - if (SS_MB.Hdr.UnitHdr.hdr.v2.Type == UT_Card) + if (isMockingboardInSlot) { - sText = StrFormat("%02X ", (unsigned)((BYTE*)&SS_MB.Unit[nAddr & 1].RegsSY6522)[iAddress]); - if (SS_MB.Unit[nAddr & 1].bTimer1Active && (iAddress == 4 || iAddress == 5)) // T1C + sText = StrFormat("%02X ", MB.subUnit[nAddr & 1].regsSY6522[iAddress]); + if (MB.subUnit[nAddr & 1].timer1Active && (iAddress == 4 || iAddress == 5)) // T1C { - DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if timer1 active then draw in white + DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if timer1 active then draw in white } - else if (SS_MB.Unit[nAddr & 1].bTimer2Active && (iAddress == 8 || iAddress == 9)) // T2C + else if (MB.subUnit[nAddr & 1].timer2Active && (iAddress == 8 || iAddress == 9)) // T2C { - DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if timer2 active then draw in white + DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if timer2 active then draw in white } else { @@ -2090,17 +2100,17 @@ void DrawMemory ( int line, int iMemDump ) } } else - if (eDevice == DEV_AY8910) + if (eDevice == DEV_AY8913) { - if (SS_MB.Hdr.UnitHdr.hdr.v2.Type == UT_Card) + if (isMockingboardInSlot) { if (iAddress <= 13) - sText = StrFormat("%02X ", (unsigned)SS_MB.Unit[nAddr & 1].RegsAY8910[iAddress]); + sText = StrFormat("%02X ", MB.subUnit[nAddr & 1].regsAY8913[0][iAddress]); // TODO: Support AY2 else sText = "-- "; // regs 14 & 15 aren't supported by AY-3-8913 - if (SS_MB.Unit[nAddr & 1].nAYCurrentRegister == iAddress) + if (MB.subUnit[nAddr & 1].nAYCurrentRegister[0] == iAddress) { - DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if latched address then draw in white + DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if latched address then draw in white } else { diff --git a/source/Debugger/Debugger_Types.h b/source/Debugger/Debugger_Types.h index b4fb659c..7bc4e50e 100644 --- a/source/Debugger/Debugger_Types.h +++ b/source/Debugger/Debugger_Types.h @@ -1175,7 +1175,7 @@ const DisasmData_t* pDisasmData; // If != NULL then bytes are marked up as data DEV_MEMORY, DEV_DISK2 , DEV_SY6522, - DEV_AY8910, + DEV_AY8913, NUM_DEVICES }; diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 2b9eb4a2..f5187391 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -973,38 +973,24 @@ void MockingboardCard::SetVolume(DWORD volume, DWORD volumeMax) //=========================================================================== -#include "SaveState_Structs_v1.h" - -// Called by debugger - Debugger_Display.cpp -void MockingboardCard::GetSnapshot_v1(SS_CARD_MOCKINGBOARD_v1* const pSS) +void MockingboardCard::GetSnapshotForDebugger(DEBUGGER_MB_CARD* const pMBForDebugger) { - pSS->Hdr.UnitHdr.hdr.v2.Length = sizeof(SS_CARD_MOCKINGBOARD_v1); - pSS->Hdr.UnitHdr.hdr.v2.Type = UT_Card; - pSS->Hdr.UnitHdr.hdr.v2.Version = 1; - - pSS->Hdr.Slot = m_slot; - pSS->Hdr.Type = CT_MockingboardC; - - MB_SUBUNIT* pMB = &m_MBSubUnit[0]; - - for (UINT i=0; isy6522.GetRegs((BYTE*)&pSS->Unit[i].RegsSY6522); // continuous 16-byte array + MB_SUBUNIT* pMB = &m_MBSubUnit[i]; - // AY8913 - for (UINT j=0; j<16; j++) + pMB->sy6522.GetRegs(pMBForDebugger->subUnit[i].regsSY6522); // continuous 16-byte array + pMBForDebugger->subUnit[i].timer1Active = pMB->sy6522.IsTimer1Active(); + pMBForDebugger->subUnit[i].timer2Active = pMB->sy6522.IsTimer2Active(); + + for (UINT j = 0; j < NUM_AY8913_PER_SUBUNIT; j++) { - pSS->Unit[i].RegsAY8910[j] = AYReadReg(i, 0, j); // FIXME: also support Phasor's 2nd AY8913 + for (UINT k = 0; k < 16; k++) + pMBForDebugger->subUnit[i].regsAY8913[j][k] = AYReadReg(i, j, k); + + pMBForDebugger->subUnit[i].nAYCurrentRegister[j] = pMB->nAYCurrentRegister[j]; + pMBForDebugger->subUnit[i].isAYLatchedAddressValid[j] = pMB->isAYLatchedAddressValid[j]; } - - memset(&pSS->Unit[i].RegsSSI263, 0, sizeof(SSI263A)); // Not used by debugger - pSS->Unit[i].nAYCurrentRegister = pMB->isAYLatchedAddressValid[0] ? pMB->nAYCurrentRegister[0] : 0xff; - pSS->Unit[i].bTimer1Active = pMB->sy6522.IsTimer1Active(); - pSS->Unit[i].bTimer2Active = pMB->sy6522.IsTimer2Active(); - pSS->Unit[i].bSpeechIrqPending = false; - - pMB++; } } diff --git a/source/Mockingboard.h b/source/Mockingboard.h index f42d20a3..314125c2 100644 --- a/source/Mockingboard.h +++ b/source/Mockingboard.h @@ -49,7 +49,20 @@ public: BYTE GetPCR(BYTE nDevice); bool IsAnyTimer1Active(void); - void GetSnapshot_v1(struct SS_CARD_MOCKINGBOARD_v1* const pSS); + struct DEBUGGER_MB_SUBUNIT + { + BYTE regsSY6522[SY6522::SIZE_6522_REGS]; + bool timer1Active; + bool timer2Active; + BYTE regsAY8913[NUM_AY8913_PER_SUBUNIT][16]; + BYTE nAYCurrentRegister[NUM_AY8913_PER_SUBUNIT]; + bool isAYLatchedAddressValid[NUM_AY8913_PER_SUBUNIT]; + }; + struct DEBUGGER_MB_CARD + { + DEBUGGER_MB_SUBUNIT subUnit[NUM_SUBUNITS_PER_MB]; + }; + void GetSnapshotForDebugger(DEBUGGER_MB_CARD* const pMBForDebugger); static std::string GetSnapshotCardName(void); static std::string GetSnapshotCardNamePhasor(void); @@ -60,13 +73,13 @@ private: struct MB_SUBUNIT { SY6522 sy6522; - AY8913 ay8913[2]; // Phasor has 2x AY per 6522 + AY8913 ay8913[NUM_AY8913_PER_SUBUNIT]; // Phasor has 2x AY per 6522 SSI263 ssi263; BYTE nAY8910Number; - BYTE nAYCurrentRegister[2]; - MockingboardUnitState_e state[2]; // AY's PSG function - bool isAYLatchedAddressValid[2]; - bool isChipSelected[2]; + BYTE nAYCurrentRegister[NUM_AY8913_PER_SUBUNIT]; + MockingboardUnitState_e state[NUM_AY8913_PER_SUBUNIT]; // AY's PSG function + bool isAYLatchedAddressValid[NUM_AY8913_PER_SUBUNIT]; + bool isChipSelected[NUM_AY8913_PER_SUBUNIT]; MB_SUBUNIT(UINT slot) : sy6522(slot), ssi263(slot) { diff --git a/source/SaveState_Structs_common.h b/source/SaveState_Structs_common.h deleted file mode 100644 index 8bc49fdf..00000000 --- a/source/SaveState_Structs_common.h +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once - -// Structs used by save-state file - -// *** DON'T CHANGE ANY STRUCT WITHOUT CONSIDERING BACKWARDS COMPATIBILITY WITH .AWS FORMAT *** - -///////////////////////////////////////////////////////////////////////////////// - -#define MAKE_VERSION(a,b,c,d) ((a<<24) | (b<<16) | (c<<8) | (d)) - -#define AW_SS_TAG 'SSWA' // 'AWSS' = AppleWin SnapShot - -struct SS_FILE_HDR -{ - DWORD dwTag; // "AWSS" - DWORD dwVersion; - DWORD dwChecksum; -}; - -struct SS_UNIT_HDR -{ - union - { - struct - { - DWORD dwLength; // Byte length of this unit struct - DWORD dwVersion; - } v1; - struct - { - DWORD Length; // Byte length of this unit struct - WORD Type; // SS_UNIT_TYPE - WORD Version; // Incrementing value from 1 - } v2; - } hdr; -}; - -enum SS_UNIT_TYPE -{ - UT_Reserved = 0, - UT_Apple2, - UT_Card, - UT_Config, -}; - -const UINT nMemMainSize = 64*1024; -const UINT nMemAuxSize = 64*1024; - -struct SS_CARD_HDR -{ - SS_UNIT_HDR UnitHdr; - DWORD Type; // SS_CARDTYPE - DWORD Slot; // [1..7], 0=Language card, 8=Aux -}; - -///////////////////////////////////////////////////////////////////////////////// - -struct SS_CARD_EMPTY -{ - SS_CARD_HDR Hdr; -}; - -///////////////////////////////////////////////////////////////////////////////// - -struct SY6522A -{ - BYTE ORB; // $00 - Port B - BYTE ORA; // $01 - Port A (with handshaking) - BYTE DDRB; // $02 - Data Direction Register B - BYTE DDRA; // $03 - Data Direction Register A - // - // $04 - Read counter (L) / Write latch (L) - // $05 - Read / Write & initiate count (H) - // $06 - Read / Write & latch (L) - // $07 - Read / Write & latch (H) - // $08 - Read counter (L) / Write latch (L) - // $09 - Read counter (H) / Write latch (H) - USHORT TIMER1_COUNTER; - USHORT TIMER1_LATCH; - USHORT TIMER2_COUNTER; - USHORT TIMER2_LATCH; - int timer1IrqDelay; - int timer2IrqDelay; - // - BYTE SERIAL_SHIFT; // $0A - BYTE ACR; // $0B - Auxiliary Control Register - BYTE PCR; // $0C - Peripheral Control Register - BYTE IFR; // $0D - Interrupt Flag Register - BYTE IER; // $0E - Interrupt Enable Register - BYTE ORA_NO_HS; // $0F - Port A (without handshaking) -}; - -struct SSI263A -{ - BYTE DurationPhoneme; - BYTE Inflection; // I10..I3 - BYTE RateInflection; - BYTE CtrlArtAmp; - BYTE FilterFreq; - // - BYTE CurrentMode; // b7:6=Mode; b0=D7 pin (for IRQ) -}; diff --git a/source/SaveState_Structs_v1.h b/source/SaveState_Structs_v1.h deleted file mode 100644 index 9f5d91be..00000000 --- a/source/SaveState_Structs_v1.h +++ /dev/null @@ -1,147 +0,0 @@ -#pragma once - -#include "DiskDefs.h" -#include "SaveState_Structs_common.h" - -// Structs used by save-state file v1 - -// *** DON'T CHANGE ANY STRUCT WITHOUT CONSIDERING BACKWARDS COMPATIBILITY WITH .AWS FORMAT *** - -///////////////////////////////////////////////////////////////////////////////// - -struct SS_CPU6502 -{ - BYTE A; - BYTE X; - BYTE Y; - BYTE P; - BYTE S; - USHORT PC; - unsigned __int64 nCumulativeCycles; - // IRQ = OR-sum of all interrupt sources -}; - -const UINT uRecvBufferSize = 9; - -struct SS_IO_Comms -{ - DWORD baudrate; - BYTE bytesize; - BYTE commandbyte; - DWORD comminactivity; // If non-zero then COM port open - BYTE controlbyte; - BYTE parity; - BYTE recvbuffer[uRecvBufferSize]; - DWORD recvbytes; - BYTE stopbits; -}; - -struct SS_IO_Joystick -{ - unsigned __int64 nJoyCntrResetCycle; -}; - -struct SS_IO_Keyboard -{ - DWORD keyboardqueries; - BYTE nLastKey; -}; - -struct SS_IO_Speaker -{ - unsigned __int64 nSpkrLastCycle; -}; - -struct SS_IO_Video -{ - bool bAltCharSet; // charoffs - DWORD dwVidMode; -}; - -struct SS_BaseMemory -{ - DWORD dwMemMode; - BOOL bLastWriteRam; - BYTE nMemMain[nMemMainSize]; - BYTE nMemAux[nMemAuxSize]; -}; - -struct SS_APPLE2_Unit -{ - SS_UNIT_HDR UnitHdr; - SS_CPU6502 CPU6502; - SS_IO_Comms Comms; - SS_IO_Joystick Joystick; - SS_IO_Keyboard Keyboard; - SS_IO_Speaker Speaker; - SS_IO_Video Video; - SS_BaseMemory Memory; -}; - -///////////////////////////////////////////////////////////////////////////////// - -struct DISK2_Unit -{ - char szFileName[MAX_PATH]; - int track; - int phase; - int byte; - BOOL writeprotected; - BOOL trackimagedata; - BOOL trackimagedirty; - DWORD spinning; - DWORD writelight; - int nibbles; - BYTE nTrack[NIBBLES_PER_TRACK_NIB]; -}; - -struct SS_CARD_DISK2 -{ - SS_CARD_HDR Hdr; - DISK2_Unit Unit[2]; - WORD phases; - WORD currdrive; - BOOL diskaccessed; - BOOL enhancedisk; - BYTE floppylatch; - BOOL floppymotoron; - BOOL floppywritemode; -}; - -///////////////////////////////////////////////////////////////////////////////// - -struct MB_Unit_v1 -{ - SY6522A RegsSY6522; - BYTE RegsAY8910[16]; - SSI263A RegsSSI263; - BYTE nAYCurrentRegister; - bool bTimer1Active; - bool bTimer2Active; - bool bSpeechIrqPending; -}; - -const UINT MB_UNITS_PER_CARD_v1 = 2; - -struct SS_CARD_MOCKINGBOARD_v1 -{ - SS_CARD_HDR Hdr; - MB_Unit_v1 Unit[MB_UNITS_PER_CARD_v1]; -}; - -///////////////////////////////////////////////////////////////////////////////// - -struct APPLEWIN_SNAPSHOT_v1 -{ - SS_FILE_HDR Hdr; - SS_APPLE2_Unit Apple2Unit; - SS_CARD_EMPTY Empty1; // Slot1 - SS_CARD_EMPTY Empty2; // Slot2 - SS_CARD_EMPTY Empty3; // Slot3 - SS_CARD_MOCKINGBOARD_v1 Mockingboard1; // Slot4 - SS_CARD_MOCKINGBOARD_v1 Mockingboard2; // Slot5 - SS_CARD_DISK2 Disk2; // Slot6 - SS_CARD_EMPTY Empty7; // Slot7 -}; - -const UINT kSnapshotSize_v1 = 145400; // Const size for v1