mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-09-29 21:56:12 +00:00
Save-state: alloc extra 64K banks for RamWorks card if needed
This commit is contained in:
parent
498f01edde
commit
f114a9b8fe
@ -46,7 +46,6 @@ public:
|
|||||||
void sound_frame( void );
|
void sound_frame( void );
|
||||||
BYTE* GetAYRegsPtr( void ) { return &sound_ay_registers[0]; }
|
BYTE* GetAYRegsPtr( void ) { return &sound_ay_registers[0]; }
|
||||||
static void SetCLK( double CLK ) { m_fCurrentCLK_AY8910 = CLK; }
|
static void SetCLK( double CLK ) { m_fCurrentCLK_AY8910 = CLK; }
|
||||||
void ClearAYChangeCount( void ) { ay_change_count = 0; }
|
|
||||||
UINT GetSnapshot(const HANDLE hFile);
|
UINT GetSnapshot(const HANDLE hFile);
|
||||||
UINT SetSnapshot(const HANDLE hFile);
|
UINT SetSnapshot(const HANDLE hFile);
|
||||||
|
|
||||||
|
@ -807,8 +807,8 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
|
|||||||
lpCmdLine = GetCurrArg(lpNextArg);
|
lpCmdLine = GetCurrArg(lpNextArg);
|
||||||
lpNextArg = GetNextArg(lpNextArg);
|
lpNextArg = GetNextArg(lpNextArg);
|
||||||
g_uMaxExPages = atoi(lpCmdLine);
|
g_uMaxExPages = atoi(lpCmdLine);
|
||||||
if (g_uMaxExPages > 127)
|
if (g_uMaxExPages > kMaxExMemoryBanks)
|
||||||
g_uMaxExPages = 128;
|
g_uMaxExPages = kMaxExMemoryBanks;
|
||||||
else if (g_uMaxExPages < 1)
|
else if (g_uMaxExPages < 1)
|
||||||
g_uMaxExPages = 1;
|
g_uMaxExPages = 1;
|
||||||
}
|
}
|
||||||
|
@ -194,9 +194,9 @@ static BOOL Pravets8charmode = 0;
|
|||||||
static CNoSlotClock g_NoSlotClock;
|
static CNoSlotClock g_NoSlotClock;
|
||||||
|
|
||||||
#ifdef RAMWORKS
|
#ifdef RAMWORKS
|
||||||
UINT g_uMaxExPages = 1; // user requested ram pages
|
UINT g_uMaxExPages = 1; // user requested ram pages (default to 1 aux bank: so total = 128KB)
|
||||||
UINT g_uActiveBank = 0; // 0 = memaux
|
UINT g_uActiveBank = 0; // 0 = aux 64K for: //e extended 80 Col card, or //c
|
||||||
static LPBYTE RWpages[128]; // pointers to RW memory banks
|
static LPBYTE RWpages[kMaxExMemoryBanks]; // pointers to RW memory banks
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BYTE __stdcall IO_Annunciator(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles);
|
BYTE __stdcall IO_Annunciator(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles);
|
||||||
@ -1024,7 +1024,7 @@ static LPBYTE MemGetPtrBANK1(const WORD offset, const LPBYTE pMemBase)
|
|||||||
if ((offset & 0xF000) != 0xC000) // Requesting RAM at physical addr $Cxxx (ie. 4K RAM BANK1)
|
if ((offset & 0xF000) != 0xC000) // Requesting RAM at physical addr $Cxxx (ie. 4K RAM BANK1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// fixme: Need to extend for RAMWORKS / RWpages (when pMemBase == memaux)
|
// NB. This works for memaux when set to any RWpages[] value, ie. RamWork III "just works"
|
||||||
const BYTE bank1page = (offset >> 8) & 0xF;
|
const BYTE bank1page = (offset >> 8) & 0xF;
|
||||||
return (memshadow[0xD0+bank1page] == pMemBase+(0xC0+bank1page)*256)
|
return (memshadow[0xD0+bank1page] == pMemBase+(0xC0+bank1page)*256)
|
||||||
? mem+offset+0x1000 // Return ptr to $Dxxx address - 'mem' has (a potentially dirty) 4K RAM BANK1 mapped in at $D000
|
? mem+offset+0x1000 // Return ptr to $Dxxx address - 'mem' has (a potentially dirty) 4K RAM BANK1 mapped in at $D000
|
||||||
@ -1734,8 +1734,8 @@ void MemSetSnapshot(const SS_BaseMemory_v2& Memory)
|
|||||||
struct SS_CARD_80COL_AUX_MEMORY
|
struct SS_CARD_80COL_AUX_MEMORY
|
||||||
{
|
{
|
||||||
SS_CARD_HDR Hdr;
|
SS_CARD_HDR Hdr;
|
||||||
UINT NumBanks;
|
UINT NumAuxBanks; // [0,1..127] 0=no aux mem, 1=128K system, etc
|
||||||
UINT ActiveBank;
|
UINT ActiveAuxBank; // [ 0..126] 0=memaux
|
||||||
BYTE MemAux[0];
|
BYTE MemAux[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1764,8 +1764,8 @@ void MemGetSnapshotAux(const HANDLE hFile)
|
|||||||
g_uMaxExPages == 1 ? CT_Extended80Col :
|
g_uMaxExPages == 1 ? CT_Extended80Col :
|
||||||
CT_RamWorksIII;
|
CT_RamWorksIII;
|
||||||
|
|
||||||
pSS->ActiveBank = g_uActiveBank;
|
pSS->ActiveAuxBank = g_uActiveBank;
|
||||||
pSS->NumBanks = g_uMaxExPages;
|
pSS->NumAuxBanks = g_uMaxExPages;
|
||||||
|
|
||||||
for(UINT uBank = 1; uBank <= g_uMaxExPages; uBank++)
|
for(UINT uBank = 1; uBank <= g_uMaxExPages; uBank++)
|
||||||
{
|
{
|
||||||
@ -1814,17 +1814,23 @@ void MemSetSnapshotAux(const HANDLE hFile)
|
|||||||
if (Card.Hdr.UnitHdr.hdr.v2.Length < sizeof(SS_CARD_80COL_AUX_MEMORY))
|
if (Card.Hdr.UnitHdr.hdr.v2.Length < sizeof(SS_CARD_80COL_AUX_MEMORY))
|
||||||
throw std::string("Card: unit size mismatch");
|
throw std::string("Card: unit size mismatch");
|
||||||
|
|
||||||
g_uActiveBank = Card.ActiveBank;
|
if (Card.NumAuxBanks > kMaxExMemoryBanks)
|
||||||
g_uMaxExPages = Card.NumBanks;
|
throw std::string("Card: file corrupt");
|
||||||
|
|
||||||
|
if (Card.ActiveAuxBank >= Card.NumAuxBanks)
|
||||||
|
throw std::string("Card: file corrupt");
|
||||||
|
|
||||||
|
g_uActiveBank = Card.ActiveAuxBank;
|
||||||
|
g_uMaxExPages = Card.NumAuxBanks;
|
||||||
|
|
||||||
for(UINT uBank = 1; uBank <= g_uMaxExPages; uBank++)
|
for(UINT uBank = 1; uBank <= g_uMaxExPages; uBank++)
|
||||||
{
|
{
|
||||||
LPBYTE pBank = MemGetBankPtr(uBank);
|
LPBYTE pBank = MemGetBankPtr(uBank);
|
||||||
if (!pBank)
|
if (!pBank)
|
||||||
{
|
{
|
||||||
// todo: alloc
|
pBank = RWpages[uBank-1] = (LPBYTE) VirtualAlloc(NULL,_6502_MEM_END+1,MEM_COMMIT,PAGE_READWRITE);
|
||||||
_ASSERT(pBank);
|
if (!pBank)
|
||||||
break;
|
throw std::string("Card: mem alloc failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
bRes = ReadFile( hFile,
|
bRes = ReadFile( hFile,
|
||||||
|
@ -32,6 +32,7 @@ extern LPBYTE mem;
|
|||||||
extern LPBYTE memdirty;
|
extern LPBYTE memdirty;
|
||||||
|
|
||||||
#ifdef RAMWORKS
|
#ifdef RAMWORKS
|
||||||
|
const UINT kMaxExMemoryBanks = 127; // 127 * aux mem(64K) + main mem(64K) = 8MB
|
||||||
extern UINT g_uMaxExPages; // user requested ram pages (from cmd line)
|
extern UINT g_uMaxExPages; // user requested ram pages (from cmd line)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1000,7 +1000,7 @@ static DWORD WINAPI SSI263Thread(LPVOID lpParameter)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Warning! Data-race!
|
// Warning! Data-race! [FIXME]
|
||||||
// . SSI263Thread() can asynchronously set /g_nCurrentActivePhoneme/ to -1
|
// . SSI263Thread() can asynchronously set /g_nCurrentActivePhoneme/ to -1
|
||||||
// . I have seen it on a call to Play(0,0,0)
|
// . I have seen it on a call to Play(0,0,0)
|
||||||
// . eg. could occur between [1] and [2]
|
// . eg. could occur between [1] and [2]
|
||||||
|
Loading…
Reference in New Issue
Block a user