From 559a236b14fc52f7592830371b488c4cd1514391 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 31 May 2015 22:53:53 +0100 Subject: [PATCH] Save-state: . On save: append .aws if missing . Added Pravets.cpp/h (for this clone's specific stuff) --- AppleWinExpress2012.vcxproj | 6 ++- AppleWinExpress2012.vcxproj.filters | 9 ++++ AppleWinExpress2013.vcxproj | 4 +- AppleWinExpress2013.vcxproj.filters | 9 ++++ ApplewinExpress9.00.vcproj | 12 +++++ source/Applewin.cpp | 3 -- source/Applewin.h | 3 -- source/Configuration/PropertySheetHelper.cpp | 9 ++-- source/Disk.cpp | 4 +- source/Frame.cpp | 7 +++ source/Keyboard.cpp | 1 + source/Memory.cpp | 30 +++++------- source/Pravets.cpp | 48 ++++++++++++++++++++ source/Pravets.h | 7 +++ source/SaveState.cpp | 34 ++++++-------- source/SaveState_Structs_v2.h | 4 ++ source/SerialComms.cpp | 12 +---- source/SerialComms.h | 4 +- source/Tape.cpp | 1 + 19 files changed, 140 insertions(+), 67 deletions(-) create mode 100644 source/Pravets.cpp create mode 100644 source/Pravets.h diff --git a/AppleWinExpress2012.vcxproj b/AppleWinExpress2012.vcxproj index 9058a6f0..42ba5edb 100644 --- a/AppleWinExpress2012.vcxproj +++ b/AppleWinExpress2012.vcxproj @@ -59,6 +59,7 @@ + @@ -74,6 +75,7 @@ + @@ -94,7 +96,6 @@ - @@ -136,6 +137,7 @@ + @@ -149,6 +151,7 @@ + @@ -187,7 +190,6 @@ NotUsing NotUsing - diff --git a/AppleWinExpress2012.vcxproj.filters b/AppleWinExpress2012.vcxproj.filters index 16d275cb..81d4fde5 100644 --- a/AppleWinExpress2012.vcxproj.filters +++ b/AppleWinExpress2012.vcxproj.filters @@ -30,6 +30,9 @@ {9b13bfc1-31ab-4f55-bb69-b8620ebdc2be} + + {15b450e4-f89f-4d80-9c44-48b32f33f3e3} + {9bcc8097-f610-4843-bd76-a313aa54fbb0} @@ -291,6 +294,9 @@ Source Files\Debugger + + Source Files\Model + @@ -484,6 +490,9 @@ Source Files\Uthernet + + Source Files\Model + diff --git a/AppleWinExpress2013.vcxproj b/AppleWinExpress2013.vcxproj index 87520852..076e57da 100644 --- a/AppleWinExpress2013.vcxproj +++ b/AppleWinExpress2013.vcxproj @@ -75,6 +75,7 @@ + @@ -106,7 +107,7 @@ - + @@ -150,6 +151,7 @@ + diff --git a/AppleWinExpress2013.vcxproj.filters b/AppleWinExpress2013.vcxproj.filters index 2551d0ed..9530e86b 100644 --- a/AppleWinExpress2013.vcxproj.filters +++ b/AppleWinExpress2013.vcxproj.filters @@ -169,6 +169,9 @@ Source Files\Debugger + + Source Files\Model + @@ -417,6 +420,9 @@ Source Files\Disk + + Source Files\Model + @@ -638,6 +644,9 @@ {b5c6889e-727d-4339-96c8-e4284e1d6e0f} + + {15b450e4-f89f-4d80-9c44-48b32f33f3e3} + diff --git a/ApplewinExpress9.00.vcproj b/ApplewinExpress9.00.vcproj index 3973237d..c879979c 100644 --- a/ApplewinExpress9.00.vcproj +++ b/ApplewinExpress9.00.vcproj @@ -955,6 +955,18 @@ > + + + + + + Hdr.Slot = g_uSlot; pSS->Hdr.Type = CT_Disk2; - pSS->Phases = phases; + pSS->Phases = phases; pSS->CurrDrive = currdrive; pSS->DiskAccessed = diskaccessed; pSS->EnhanceDisk = enhancedisk; diff --git a/source/Frame.cpp b/source/Frame.cpp index 84cc1d45..98e8cf9b 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -41,6 +41,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Mockingboard.h" #include "MouseInterface.h" #include "ParallelPrinter.h" +#include "Pravets.h" #include "Registry.h" #include "SaveState.h" #include "SerialComms.h" @@ -1992,12 +1993,15 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { } //=========================================================================== + +// todo: consolidate CtrlReset() and ResetMachineState() void ResetMachineState () { DiskReset(); // Set floppymotoron=0 g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted MemReset(); + PravetsReset(); DiskBoot(); VideoResetState(); sg_SSC.CommReset(); @@ -2016,12 +2020,15 @@ void ResetMachineState () //=========================================================================== + +// todo: consolidate CtrlReset() and ResetMachineState() void CtrlReset() { // Ctrl+Reset - TODO: This is a terrible place for this code! if (!IS_APPLE2) MemResetPaging(); + PravetsReset(); DiskReset(); KeybReset(); if (!IS_APPLE2) diff --git a/source/Keyboard.cpp b/source/Keyboard.cpp index e3e3e2d1..b217e356 100644 --- a/source/Keyboard.cpp +++ b/source/Keyboard.cpp @@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "AppleWin.h" #include "Frame.h" #include "Keyboard.h" +#include "Pravets.h" #include "Tape.h" static bool g_bKeybBufferEnable = false; diff --git a/source/Memory.cpp b/source/Memory.cpp index ac88869a..0aa4e490 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -200,7 +200,6 @@ static LPBYTE RWpages[kMaxExMemoryBanks]; // pointers to RW memory banks #endif BYTE __stdcall IO_Annunciator(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles); -void UpdatePaging(BOOL initialize); //============================================================================= @@ -811,6 +810,16 @@ static void SetMemMode(const DWORD uNewMemMode) //=========================================================================== +static void ResetPaging(BOOL initialize); +static void UpdatePaging(BOOL initialize); + +// Call by: +// . CtrlReset() Soft-reset (Ctrl+Reset) +void MemResetPaging() +{ + ResetPaging(0); // Initialize=0 +} + static void ResetPaging(BOOL initialize) { lastwriteram = 0; @@ -1330,7 +1339,8 @@ inline DWORD getRandomTime() // Called by: // . MemInitialize() // . ResetMachineState() eg. Power-cycle ('Apple-Go' button) -// . Snapshot_LoadState() +// . Snapshot_LoadState_v1() +// . Snapshot_LoadState_v2() void MemReset() { // INITIALIZE THE PAGING TABLES @@ -1485,22 +1495,6 @@ void MemReset() //=========================================================================== -// Call by: -// . Soft-reset (Ctrl+Reset) -// . Snapshot_LoadState() -void MemResetPaging() -{ - ResetPaging(0); // Initialize=0 - if (g_Apple2Type == A2TYPE_PRAVETS8A) - { - P8CAPS_ON = false; - TapeWrite (0, 0, 0, 0 ,0); - FrameRefreshStatus(DRAW_LEDS); - } -} - -//=========================================================================== - BYTE MemReadFloatingBus(const ULONG uExecutedCycles) { return*(LPBYTE)(mem + VideoGetScannerAddress(NULL, uExecutedCycles)); diff --git a/source/Pravets.cpp b/source/Pravets.cpp new file mode 100644 index 00000000..296cf4f7 --- /dev/null +++ b/source/Pravets.cpp @@ -0,0 +1,48 @@ +/* +AppleWin : An Apple //e emulator for Windows + +Copyright (C) 1994-1996, Michael O'Brien +Copyright (C) 1999-2001, Oliver Schmidt +Copyright (C) 2002-2005, Tom Charlesworth +Copyright (C) 2006-2015, Tom Charlesworth, Michael Pohoreski + +AppleWin is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +AppleWin is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with AppleWin; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* Description: Pravets - Apple II clone + * + * Author: Various + */ + +#include "StdAfx.h" + +#include "AppleWin.h" +#include "Frame.h" +#include "Keyboard.h" +#include "Tape.h" + +//Pravets 8A/C variables +bool P8CAPS_ON = false; +bool P8Shift = false; + +void PravetsReset(void) +{ + if (g_Apple2Type == A2TYPE_PRAVETS8A) + { + P8CAPS_ON = false; + TapeWrite(0, 0, 0, 0 ,0); + FrameRefreshStatus(DRAW_LEDS); + } +} diff --git a/source/Pravets.h b/source/Pravets.h new file mode 100644 index 00000000..801d1804 --- /dev/null +++ b/source/Pravets.h @@ -0,0 +1,7 @@ +#pragma once + +//Pravets 8A/C only variables +extern bool P8CAPS_ON; +extern bool P8Shift; + +void PravetsReset(void); diff --git a/source/SaveState.cpp b/source/SaveState.cpp index 1018b755..fde5f19a 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -4,7 +4,7 @@ AppleWin : An Apple //e emulator for Windows Copyright (C) 1994-1996, Michael O'Brien Copyright (C) 1999-2001, Oliver Schmidt Copyright (C) 2002-2005, Tom Charlesworth -Copyright (C) 2006-2007, Tom Charlesworth, Michael Pohoreski +Copyright (C) 2006-2015, Tom Charlesworth, Michael Pohoreski AppleWin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,8 +41,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Mockingboard.h" #include "MouseInterface.h" #include "ParallelPrinter.h" +#include "Pravets.h" #include "SerialComms.h" #include "Speaker.h" +#include "Speech.h" #include "Video.h" #include "z80emu.h" @@ -161,10 +163,6 @@ static void Snapshot_LoadState_v1() // .aws v1.0.0.1, up to (and including) Appl // // Reset all sub-systems MemReset(); - - if (!IS_APPLE2) - MemResetPaging(); - DiskReset(); KeybReset(); VideoResetState(); @@ -221,8 +219,8 @@ static void Snapshot_LoadState_v1() // .aws v1.0.0.1, up to (and including) Appl //----------------------------------------------------------------------------- -HANDLE m_hFile = INVALID_HANDLE_VALUE; -CConfigNeedingRestart m_ConfigNew; +static HANDLE m_hFile = INVALID_HANDLE_VALUE; +static CConfigNeedingRestart m_ConfigNew; static void Snapshot_LoadState_FileHdr(SS_FILE_HDR& Hdr) { @@ -267,10 +265,6 @@ static void Snapshot_LoadState_FileHdr(SS_FILE_HDR& Hdr) } } -#define UNIT_APPLE2_VER 1 -#define UNIT_CARD_VER 1 -#define UNIT_CONFIG_VER 1 - static void LoadUnitApple2(DWORD Length, DWORD Version) { if (Version != UNIT_APPLE2_VER) @@ -434,6 +428,7 @@ static void LoadUnitCard(DWORD Length, DWORD Version) } } +#if 0 static void LoadUnitConfig(DWORD Length, DWORD Version) { SS_APPLEWIN_CONFIG Cfg; @@ -460,6 +455,7 @@ static void LoadUnitConfig(DWORD Length, DWORD Version) // todo: //m_ConfigNew.m_bEnhanceDisk; } +#endif static void Snapshot_LoadState_v2(DWORD dwVersion) { @@ -480,16 +476,14 @@ static void Snapshot_LoadState_v2(DWORD dwVersion) m_ConfigNew.m_SlotAux = CT_Empty; MemReset(); - - // fixme: Apple type may change - assume ths can be removed? - if (!IS_APPLE2) - MemResetPaging(); - // fixme-end - + PravetsReset(); DiskReset(); KeybReset(); VideoResetState(); MB_Reset(); +#ifdef USE_SPEECH_API + g_Speech.Reset(); +#endif sg_Mouse.Uninitialize(); sg_Mouse.Reset(); HD_SetEnabled(false); @@ -518,9 +512,11 @@ static void Snapshot_LoadState_v2(DWORD dwVersion) case UT_Card: LoadUnitCard(UnitHdr.hdr.v2.Length, UnitHdr.hdr.v2.Version); break; +#if 0 case UT_Config: LoadUnitConfig(UnitHdr.hdr.v2.Length, UnitHdr.hdr.v2.Version); break; +#endif default: // Log then skip unsupported unit type break; @@ -541,8 +537,6 @@ static void Snapshot_LoadState_v2(DWORD dwVersion) MemInitializeIO(); MemUpdatePaging(TRUE); - - //PostMessage(g_hFrameWindow, WM_USER_RESTART, 0, 0); // No, as this power-cycles VM (undoing all the new state just loaded) } catch(std::string szMessage) { @@ -584,8 +578,6 @@ void Snapshot_SaveState() { try { - // todo: append '.aws' if missing - m_hFile = CreateFile( g_strSaveStatePathname.c_str(), GENERIC_WRITE, 0, diff --git a/source/SaveState_Structs_v2.h b/source/SaveState_Structs_v2.h index 3102047f..22a0eb2c 100644 --- a/source/SaveState_Structs_v2.h +++ b/source/SaveState_Structs_v2.h @@ -8,6 +8,10 @@ ///////////////////////////////////////////////////////////////////////////////// +#define UNIT_APPLE2_VER 1 +#define UNIT_CARD_VER 1 +#define UNIT_CONFIG_VER 1 + struct SS_CPU6502_v2 { BYTE A; diff --git a/source/SerialComms.cpp b/source/SerialComms.cpp index ec91f4af..041a9fca 100644 --- a/source/SerialComms.cpp +++ b/source/SerialComms.cpp @@ -1348,11 +1348,7 @@ struct SS_CARD_SSC SSC_Unit Unit; }; -// Post: -// 0 = No card -// >0 = Card saved OK from slot n -// -1 = File error -int CSuperSerialCard::GetSnapshot(const HANDLE hFile) +void CSuperSerialCard::GetSnapshot(const HANDLE hFile) { SS_CARD_SSC CardSuperSerial; @@ -1391,11 +1387,9 @@ int CSuperSerialCard::GetSnapshot(const HANDLE hFile) if(!bRes || (dwBytesWritten != CardSuperSerial.Hdr.UnitHdr.hdr.v2.Length)) throw std::string("Save error: SSC"); - - return m_uSlot; } -int CSuperSerialCard::SetSnapshot(const HANDLE hFile) +void CSuperSerialCard::SetSnapshot(const HANDLE hFile) { SS_CARD_SSC CardSuperSerial; @@ -1434,6 +1428,4 @@ int CSuperSerialCard::SetSnapshot(const HANDLE hFile) m_vbTxIrqPending = Unit.vbTxIrqPending; m_vbRxIrqPending = Unit.vbRxIrqPending; m_bWrittenTx = Unit.bWrittenTx; - - return 0; } diff --git a/source/SerialComms.h b/source/SerialComms.h index 7be33799..4c5d9859 100644 --- a/source/SerialComms.h +++ b/source/SerialComms.h @@ -34,8 +34,8 @@ public: void CommSetSerialPort(HWND hWindow, DWORD dwNewSerialPortItem); void CommUpdate(DWORD); void SetSnapshot_v1(const DWORD baudrate, const BYTE bytesize, const BYTE commandbyte, const DWORD comminactivity, const BYTE controlbyte, const BYTE parity, const BYTE stopbits); - int GetSnapshot(const HANDLE hFile); - int SetSnapshot(const HANDLE hFile); + void GetSnapshot(const HANDLE hFile); + void SetSnapshot(const HANDLE hFile); char* GetSerialPortChoices(); DWORD GetSerialPort() { return m_dwSerialPortItem; } // Drop-down list item diff --git a/source/Tape.cpp b/source/Tape.cpp index 0aef7f03..065f31f4 100644 --- a/source/Tape.cpp +++ b/source/Tape.cpp @@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "AppleWin.h" #include "Keyboard.h" #include "Memory.h" +#include "Pravets.h" static bool g_CapsLockAllowed = false;