Save-state:

. On save: append .aws if missing
. Added Pravets.cpp/h (for this clone's specific stuff)
This commit is contained in:
tomcw 2015-05-31 22:53:53 +01:00
parent 9ceb95372f
commit 559a236b14
19 changed files with 140 additions and 67 deletions

View File

@ -59,6 +59,7 @@
<ClInclude Include="source\Debugger\Debugger_Range.h" />
<ClInclude Include="source\Debugger\Debugger_Symbols.h" />
<ClInclude Include="source\Debugger\Debugger_Types.h" />
<ClInclude Include="source\Debugger\Util_MemoryTextFile.h" />
<ClInclude Include="source\Debugger\Util_Text.h" />
<ClInclude Include="source\Disk.h" />
<ClInclude Include="source\DiskDefs.h" />
@ -74,6 +75,7 @@
<ClInclude Include="source\MouseInterface.h" />
<ClInclude Include="source\NoSlotClock.h" />
<ClInclude Include="source\ParallelPrinter.h" />
<ClInclude Include="source\Pravets.h" />
<ClInclude Include="source\Registry.h" />
<ClInclude Include="source\Riff.h" />
<ClInclude Include="source\SaveState.h" />
@ -94,7 +96,6 @@
<ClInclude Include="source\Tfe\Tfearch.h" />
<ClInclude Include="source\Tfe\Tfesupp.h" />
<ClInclude Include="source\Tfe\Uilib.h" />
<ClInclude Include="source\Debugger\Util_MemoryTextFile.h" />
<ClInclude Include="source\Video.h" />
<ClInclude Include="source\z80emu.h" />
<ClInclude Include="source\Z80VICE\daa.h" />
@ -136,6 +137,7 @@
<ClCompile Include="source\Debugger\Debugger_Parser.cpp" />
<ClCompile Include="source\Debugger\Debugger_Range.cpp" />
<ClCompile Include="source\Debugger\Debugger_Symbols.cpp" />
<ClCompile Include="source\Debugger\Util_MemoryTextFile.cpp" />
<ClCompile Include="source\Disk.cpp" />
<ClCompile Include="source\DiskImage.cpp" />
<ClCompile Include="source\DiskImageHelper.cpp" />
@ -149,6 +151,7 @@
<ClCompile Include="source\MouseInterface.cpp" />
<ClCompile Include="source\NoSlotClock.cpp" />
<ClCompile Include="source\ParallelPrinter.cpp" />
<ClCompile Include="source\Pravets.cpp" />
<ClCompile Include="source\Registry.cpp" />
<ClCompile Include="source\Riff.cpp" />
<ClCompile Include="source\SaveState.cpp" />
@ -187,7 +190,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release NoDX|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\Debugger\Util_MemoryTextFile.cpp" />
<ClCompile Include="source\Video.cpp" />
<ClCompile Include="source\z80emu.cpp" />
<ClCompile Include="source\Z80VICE\daa.cpp">

View File

@ -30,6 +30,9 @@
<Filter Include="Source Files\Emulator">
<UniqueIdentifier>{9b13bfc1-31ab-4f55-bb69-b8620ebdc2be}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Model">
<UniqueIdentifier>{15b450e4-f89f-4d80-9c44-48b32f33f3e3}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Uthernet">
<UniqueIdentifier>{9bcc8097-f610-4843-bd76-a313aa54fbb0}</UniqueIdentifier>
</Filter>
@ -291,6 +294,9 @@
<ClInclude Include="source\Debugger\Util_Text.h">
<Filter>Source Files\Debugger</Filter>
</ClInclude>
<ClInclude Include="source\Pravets.h">
<Filter>Source Files\Model</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="docs\CodingConventions.txt">
@ -484,6 +490,9 @@
<ClCompile Include="source\Tfe\Uilib.cpp">
<Filter>Source Files\Uthernet</Filter>
</ClCompile>
<ClCompile Include="source\Pravets.cpp">
<Filter>Source Files\Model</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="source\CPU\cpu_general.inl">

View File

@ -75,6 +75,7 @@
<ClInclude Include="source\MouseInterface.h" />
<ClInclude Include="source\NoSlotClock.h" />
<ClInclude Include="source\ParallelPrinter.h" />
<ClInclude Include="source\Pravets.h" />
<ClInclude Include="source\Registry.h" />
<ClInclude Include="source\Riff.h" />
<ClInclude Include="source\SaveState.h" />
@ -106,7 +107,7 @@
<Text Include="docs\CodingConventions.txt" />
<Text Include="docs\Debugger_Changelog.txt" />
<Text Include="docs\FAQ.txt" />
<Text Include="docs\History.txt" />
<Text Include="bin\History.txt" />
<Text Include="docs\ToDo.txt" />
<Text Include="docs\Video_Cleanup.txt" />
<Text Include="docs\Wishlist.txt" />
@ -150,6 +151,7 @@
<ClCompile Include="source\MouseInterface.cpp" />
<ClCompile Include="source\NoSlotClock.cpp" />
<ClCompile Include="source\ParallelPrinter.cpp" />
<ClCompile Include="source\Pravets.cpp" />
<ClCompile Include="source\Registry.cpp" />
<ClCompile Include="source\Riff.cpp" />
<ClCompile Include="source\SaveState.cpp" />

View File

@ -169,6 +169,9 @@
<ClCompile Include="source\Debugger\Util_MemoryTextFile.cpp">
<Filter>Source Files\Debugger</Filter>
</ClCompile>
<ClCompile Include="source\Pravets.cpp">
<Filter>Source Files\Model</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\Applewin.h">
@ -417,6 +420,9 @@
<ClInclude Include="source\DiskDefs.h">
<Filter>Source Files\Disk</Filter>
</ClInclude>
<ClInclude Include="source\Pravets.h">
<Filter>Source Files\Model</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="resource\Applewin.bmp">
@ -638,6 +644,9 @@
<Filter Include="Resource Files">
<UniqueIdentifier>{b5c6889e-727d-4339-96c8-e4284e1d6e0f}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Model">
<UniqueIdentifier>{15b450e4-f89f-4d80-9c44-48b32f33f3e3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource\Applewin.rc">

View File

@ -955,6 +955,18 @@
>
</File>
</Filter>
<Filter
Name="Model"
>
<File
RelativePath=".\source\Pravets.cpp"
>
</File>
<File
RelativePath=".\source\Pravets.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Docs"

View File

@ -64,9 +64,6 @@ eApple2Type g_Apple2Type = A2TYPE_APPLE2EENHANCED;
bool g_bFullSpeed = false;
//Pravets 8A/C variables
bool P8CAPS_ON = false;
bool P8Shift = false;
//=================================================
// Win32

View File

@ -15,9 +15,6 @@ extern eApple2Type g_Apple2Type;
extern bool g_bFullSpeed;
//Pravets 8A/C only variables
extern bool P8CAPS_ON;
extern bool P8Shift;
//===========================================
// Win32

View File

@ -242,18 +242,17 @@ int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bo
if(nRes)
{
strcpy(m_szSSNewFilename, &szFilename[ofn.nFileOffset]);
if (bSave) // Only for saving (allow loading of any file for backwards compatibility)
{
// Append .aws if it's not there
const char szAWS_EXT[] = ".aws";
const UINT uStrLenFile = strlen(m_szSSNewFilename);
const UINT uStrLenFile = strlen(&szFilename[ofn.nFileOffset]);
const UINT uStrLenExt = strlen(szAWS_EXT);
if ((uStrLenFile <= uStrLenExt) || (strcmp(&m_szSSNewFilename[uStrLenFile-uStrLenExt], szAWS_EXT) != 0))
strcpy(&m_szSSNewFilename[uStrLenFile], szAWS_EXT);
if ((uStrLenFile <= uStrLenExt) || (strcmp(&szFilename[ofn.nFileOffset+uStrLenFile-uStrLenExt], szAWS_EXT) != 0))
strcpy(&szFilename[ofn.nFileOffset+uStrLenFile], szAWS_EXT);
}
strcpy(m_szSSNewFilename, &szFilename[ofn.nFileOffset]);
strcpy(m_szSSNewPathname, szFilename);
szFilename[ofn.nFileOffset] = 0;

View File

@ -1178,7 +1178,7 @@ struct SS_CARD_DISK2_v2
{
SS_CARD_HDR Hdr;
DISK2_Unit_v2 Unit[2];
WORD Phases;
WORD Phases;
WORD CurrDrive;
BOOL DiskAccessed;
BOOL EnhanceDisk;
@ -1200,7 +1200,7 @@ void DiskGetSnapshot(const HANDLE hFile)
pSS->Hdr.Slot = g_uSlot;
pSS->Hdr.Type = CT_Disk2;
pSS->Phases = phases;
pSS->Phases = phases;
pSS->CurrDrive = currdrive;
pSS->DiskAccessed = diskaccessed;
pSS->EnhanceDisk = enhancedisk;

View File

@ -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)

View File

@ -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;

View File

@ -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));

48
source/Pravets.cpp Normal file
View File

@ -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);
}
}

7
source/Pravets.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
//Pravets 8A/C only variables
extern bool P8CAPS_ON;
extern bool P8Shift;
void PravetsReset(void);

View File

@ -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,

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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;