RamWorks III - 16MB support (#478, PR #1369)

. Allow up to 256 x 64KiB banks
. Persist aux slot's mem card's "Number of Banks" to Registry
. LoadConfiguration() now restores aux card from Registry - don't need to pass cmd line each time
. Update help docs
This commit is contained in:
TomCh
2025-01-19 18:16:53 +00:00
committed by GitHub
parent d6c1654e97
commit 02b6bbdbb5
9 changed files with 90 additions and 40 deletions
+6 -2
View File
@@ -87,8 +87,12 @@
Set the number of blocks returned by a ProDOS status call. Use -harddisknumblocks 32767 to have the same autoexpanding behavior as older AppleWin versions.<br><br>
-no-nsc<br>
Remove the No-Slot clock (NSC).<br><br>
-r &lt;number of pages&gt;<br>
Emulate a RamWorks III card with 1 to 127 pages (each page is 64K, giving a max of 8MB) in the auxiliary slot in an Apple //e machine.<br><br>
-aux &lt;empty|std80|ext80|rw3&gt;<br>
Remove ('empty') or insert 80-Column('std80'), Extended 80-Column('ext80') or RamWorks III('rw3') card into auxiliary slot in Apple //e.<br>
NB. 'rw3' will default to 8128KiB (127 banks of 64K) unless overriden by -r switch.<br><br>
-r &lt;number of banks&gt;<br>
Emulate a RamWorks III card with 1 to 256 banks (each bank is 64K, giving a max of 16MB) in the auxiliary slot in an Apple //e machine.<br>
(Implicitly inserts a RamWorks III card into the aux slot.)<br><br>
-load-state &lt;savestate&gt;<br>
Load a save-state file (and auto power-on the Apple II).<br>
NB. This takes precedent over the -d1, -d2, -s#d#, -h1, -h2, s0-7, -model and -r switches.<br><br>
+9 -2
View File
@@ -219,10 +219,17 @@ void CardManager::InsertAuxInternal(SS_CARDTYPE type)
RemoveAux(); // creates a new EmptyCard
}
void CardManager::InsertAux(SS_CARDTYPE type)
void CardManager::InsertAux(SS_CARDTYPE type, bool updateRegistry/*=true*/)
{
InsertAuxInternal(type);
RegSetConfigSlotNewCardType(SLOT_AUX, type);
if (updateRegistry)
{
if (type != CT_RamWorksIII)
SetRamWorksMemorySize(1, false); // 1x 64K bank for Empty/80Col/Extended80Col cards
RegSetConfigSlotNewCardType(SLOT_AUX, type);
SetRegistryAuxNumberOfBanks();
}
}
void CardManager::RemoveAuxInternal()
+1 -1
View File
@@ -45,7 +45,7 @@ public:
return m_slot[slot];
}
void InsertAux(SS_CARDTYPE type);
void InsertAux(SS_CARDTYPE type, bool updateRegistry = true);
void RemoveAux(void);
SS_CARDTYPE QueryAux(void) { return m_aux->QueryType(); }
Card* GetObjAux(void) { _ASSERT(0); return m_aux; } // ASSERT because this is a DummyCard
+6 -4
View File
@@ -316,6 +316,8 @@ bool ProcessCmdLine(LPSTR lpCmdLine)
else if (strcmp(lpCmdLine, "rw3") == 0)
{
g_cmdLine.auxSlotInsert = CT_RamWorksIII;
if (!g_cmdLine.uRamWorksExPages)
g_cmdLine.uRamWorksExPages = kMaxExMemoryBanksRealRW3; // default to ~8MB (ie. the max for the real RW3 card)
}
else
{
@@ -410,16 +412,16 @@ bool ProcessCmdLine(LPSTR lpCmdLine)
g_nMemoryClearType = NUM_MIP - 1;
}
#ifdef RAMWORKS
else if (strcmp(lpCmdLine, "-r") == 0) // RamWorks size [1..127]
else if (strcmp(lpCmdLine, "-r") == 0) // RamWorks size [1..256]
{
lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg);
g_cmdLine.uRamWorksExPages = atoi(lpCmdLine);
if (g_cmdLine.uRamWorksExPages > kMaxExMemoryBanks)
g_cmdLine.uRamWorksExPages = kMaxExMemoryBanks;
else
if (g_cmdLine.uRamWorksExPages < 1)
g_cmdLine.uRamWorksExPages = 1;
else if (g_cmdLine.uRamWorksExPages < 1)
g_cmdLine.uRamWorksExPages = 1; // 1x64KB (aux mem)
g_cmdLine.auxSlotInsert = CT_RamWorksIII; // Insert RW3 into aux slot
}
#endif
else if (strcmp(lpCmdLine, "-f8rom") == 0) // Use custom 2K ROM at [$F800..$FFFF]
+1
View File
@@ -114,6 +114,7 @@ enum AppMode_e
#define REGVALUE_SLOT4 "Slot 4" // GH#977: Deprecated from 1.30.4
#define REGVALUE_SLOT5 "Slot 5" // GH#977: Deprecated from 1.30.4
#define REGVALUE_VERSION "Version"
#define REGVALUE_AUX_NUM_BANKS "Number of Banks"
#define REG_CONFIG_SLOT_AUX "Slot Auxiliary"
#define REG_CONFIG_SLOT "Slot "
#define REGVALUE_CARD_TYPE "Card type"
+32 -18
View File
@@ -43,6 +43,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "NTSC.h"
#include "NoSlotClock.h"
#include "Pravets.h"
#include "Registry.h"
#include "Speaker.h"
#include "Tape.h"
#include "RGBMonitor.h"
@@ -258,8 +259,8 @@ LPBYTE memVidHD = NULL; // For Apple II/II+ writes to aux mem (on VidHD card).
static CNoSlotClock* g_NoSlotClock = new CNoSlotClock;
#ifdef RAMWORKS
static UINT g_uMaxExPages = 1; // user requested ram pages (default to 1 aux bank: so total = 128KB)
static UINT g_uActiveBank = 0; // 0 = aux 64K for: //e extended 80 Col card, or //c -- ALSO RAMWORKS
static UINT g_uMaxExBanks = 1; // user requested ram banks (default to 1 aux bank: so total = 128KB)
static UINT g_uActiveBank = 0; // 0 = aux 64K for: //e extended 80 Col card, or //c -- also RamWorks III aux card
static LPBYTE RWpages[kMaxExMemoryBanks]; // pointers to RW memory banks
#endif
@@ -312,7 +313,7 @@ static void SetExpansionMemTypeDefault(void)
}
// Called from SetExpansionMemTypeDefault(), MemLoadSnapshotAux(), SaveState.cpp_ParseSlots(), cmd-line switch
void SetExpansionMemType(const SS_CARDTYPE type)
void SetExpansionMemType(const SS_CARDTYPE type, bool updateRegistry/*=true*/)
{
SS_CARDTYPE newSlot0Card;
SS_CARDTYPE newSlotAuxCard;
@@ -367,7 +368,7 @@ void SetExpansionMemType(const SS_CARDTYPE type)
}
GetCardMgr().Insert(SLOT0, newSlot0Card);
GetCardMgr().InsertAux(newSlotAuxCard);
GetCardMgr().InsertAux(newSlotAuxCard, updateRegistry);
}
void CreateLanguageCard(void)
@@ -403,9 +404,22 @@ SS_CARDTYPE GetCurrentExpansionMemType(void)
//
void SetRamWorksMemorySize(UINT pages)
void SetRamWorksMemorySize(UINT banks, bool updateRegistry/*=true*/)
{
g_uMaxExPages = pages;
_ASSERT(banks <= kMaxExMemoryBanks);
if (banks > kMaxExMemoryBanks)
banks = kMaxExMemoryBanks;
g_uMaxExBanks = banks;
if (updateRegistry)
SetRegistryAuxNumberOfBanks();
}
void SetRegistryAuxNumberOfBanks(void)
{
std::string regSection = RegGetConfigSlotSection(SLOT_AUX);
RegSaveValue(regSection.c_str(), REGVALUE_AUX_NUM_BANKS, TRUE, g_uMaxExBanks);
}
UINT GetRamWorksActiveBank(void)
@@ -1616,7 +1630,7 @@ LPBYTE MemGetBankPtr(const UINT nBank, const bool isSaveSnapshotOrDebugging/*=tr
BackMainImage(); // Flush any dirty pages to back-buffer
#ifdef RAMWORKS
if (nBank > g_uMaxExPages)
if (nBank > g_uMaxExBanks)
return NULL;
if (nBank == 0)
@@ -1849,11 +1863,11 @@ void MemInitialize()
#ifdef RAMWORKS
if (GetCardMgr().QueryAux() == CT_RamWorksIII)
{
// allocate memory for RAMWorks III - up to 8MB
// allocate memory for RamWorks III - up to 16MB
g_uActiveBank = 0;
UINT i = 1;
while ((i < g_uMaxExPages) && (RWpages[i] = ALIGNED_ALLOC(_6502_MEM_LEN)))
while ((i < g_uMaxExBanks) && (RWpages[i] = ALIGNED_ALLOC(_6502_MEM_LEN)))
i++;
while (i < kMaxExMemoryBanks)
RWpages[i++] = NULL;
@@ -2377,7 +2391,7 @@ BYTE __stdcall MemSetPaging(WORD programcounter, WORD address, BYTE write, BYTE
#ifdef RAMWORKS
case 0x71: // extended memory aux page number
case 0x73: // Ramworks III set aux page number
if ((value < g_uMaxExPages) && RWpages[value])
if ((value < g_uMaxExBanks) && RWpages[value])
{
g_uActiveBank = value;
memaux = RWpages[g_uActiveBank];
@@ -2775,7 +2789,7 @@ void MemSaveSnapshotAux(YamlSaveHelper& yamlSaveHelper)
if (IS_APPLE2C())
{
_ASSERT(g_uMaxExPages == 1);
_ASSERT(g_uMaxExBanks == 1);
}
yamlSaveHelper.UnitHdr(MemGetSnapshotUnitAuxSlotName(), kUNIT_AUXSLOT_VER);
@@ -2812,10 +2826,10 @@ void MemSaveSnapshotAux(YamlSaveHelper& yamlSaveHelper)
{
YamlSaveHelper::Label cardState(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE);
yamlSaveHelper.Save("%s: 0x%02X # [0,1..7F] 0=no aux mem, 1=128K system, etc\n", SS_YAML_KEY_NUMAUXBANKS, g_uMaxExPages);
yamlSaveHelper.Save("%s: 0x%02X # [ 0..7E] 0=memaux\n", SS_YAML_KEY_ACTIVEAUXBANK, g_uActiveBank);
yamlSaveHelper.Save("%s: 0x%03X # [0,1..100] 0=no aux mem, 1=128K system, etc\n", SS_YAML_KEY_NUMAUXBANKS, g_uMaxExBanks);
yamlSaveHelper.Save("%s: 0x%02X # [ 0..FF] 0=memaux\n", SS_YAML_KEY_ACTIVEAUXBANK, g_uActiveBank);
for(UINT bank = 1; bank <= g_uMaxExPages; bank++)
for(UINT bank = 1; bank <= g_uMaxExBanks; bank++)
{
MemSaveSnapshotMemory(yamlSaveHelper, false, bank);
}
@@ -2827,7 +2841,7 @@ void MemSaveSnapshotAux(YamlSaveHelper& yamlSaveHelper)
static SS_CARDTYPE MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, const std::string& card)
{
g_uMaxExPages = 1; // Must be at least 1 (for aux mem) - regardless of Apple2 type!
g_uMaxExBanks = 1; // Must be at least 1 (for aux mem) - regardless of Apple2 type!
g_uActiveBank = 0;
_ASSERT(MemGetBankPtr(1, false)); // Ensure there is always aux mem (eg. for CT_80Col or CT_VidHD)
@@ -2878,16 +2892,16 @@ static SS_CARDTYPE MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, cons
}
else // cardType == CT_RamWorksIII
{
if (numAuxBanks < 2 || numAuxBanks > 0x7F || (activeAuxBank + 1) > numAuxBanks)
if (numAuxBanks < 2 || numAuxBanks > kMaxExMemoryBanks || (activeAuxBank + 1) > numAuxBanks)
throw std::runtime_error(SS_YAML_KEY_UNIT ": AuxSlot: Bad aux slot card state");
}
g_uMaxExPages = numAuxBanks;
g_uMaxExBanks = numAuxBanks;
g_uActiveBank = activeAuxBank;
//
for (UINT bank = 1; bank <= g_uMaxExPages; bank++)
for (UINT bank = 1; bank <= g_uMaxExBanks; bank++)
{
LPBYTE pBank = MemGetBankPtr(bank, false);
if (!pBank)
+5 -3
View File
@@ -51,7 +51,8 @@ extern LPBYTE memdirty;
extern LPBYTE memVidHD;
#ifdef RAMWORKS
const UINT kMaxExMemoryBanks = 127; // 127 * aux mem(64K) + main mem(64K) = 8MB
const UINT kMaxExMemoryBanks = 256; // 256 * aux mem(64K) + main mem(64K) = 16MB + 64K
const UINT kMaxExMemoryBanksRealRW3 = 127; // Real RW3 was limited to 127x64MB, so ~8MB in total
#endif
void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, iofunction IOReadCx, iofunction IOWriteCx, LPVOID lpSlotParameter, BYTE* pExpansionRom);
@@ -103,11 +104,12 @@ BYTE __stdcall MemSetPaging(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExec
BYTE __stdcall IO_F8xx(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles);
void SetExpansionMemType(const SS_CARDTYPE type);
void SetExpansionMemType(const SS_CARDTYPE type, bool updateRegistry=true);
SS_CARDTYPE GetCurrentExpansionMemType(void);
void SetRamWorksMemorySize(UINT pages);
void SetRamWorksMemorySize(UINT banks, bool updateRegistry=true);
UINT GetRamWorksActiveBank(void);
void SetMemMainLanguageCard(LPBYTE ptr, UINT slot, bool bMemMain=false);
void SetRegistryAuxNumberOfBanks(void);
LPBYTE GetCxRomPeripheral(void);
+17
View File
@@ -269,6 +269,23 @@ void LoadConfiguration(bool loadImages)
}
}
// Aux slot
{
std::string regSection = RegGetConfigSlotSection(SLOT_AUX);
if (RegLoadValue(regSection.c_str(), REGVALUE_CARD_TYPE, TRUE, &dwTmp))
{
SS_CARDTYPE type = (SS_CARDTYPE)dwTmp;
const bool noUpdateRegistry = false;
GetCardMgr().InsertAux(type, noUpdateRegistry);
SetExpansionMemType(type, noUpdateRegistry);
RegLoadValue(regSection.c_str(), REGVALUE_AUX_NUM_BANKS, TRUE, &dwTmp, kMaxExMemoryBanksRealRW3);
SetRamWorksMemorySize(dwTmp, noUpdateRegistry);
}
}
//
// Load save-state pathname *before* inserting any harddisk/disk images (for both init & reinit cases)
+13 -10
View File
@@ -708,15 +708,6 @@ static void RepeatInitialization(void)
g_cmdLine.clockMultiplier = 0.0;
// Apply the memory expansion switches after loading the Apple II machine type
#ifdef RAMWORKS
if (g_cmdLine.uRamWorksExPages)
{
SetRamWorksMemorySize(g_cmdLine.uRamWorksExPages);
if (!g_cmdLine.auxSlotEmpty)
SetExpansionMemType(CT_RamWorksIII);
g_cmdLine.uRamWorksExPages = 0; // Don't reapply after a restart
}
#endif
if (g_cmdLine.uSaturnBanks)
{
Saturn128K::SetSaturnMemorySize(g_cmdLine.uSaturnBanks); // Set number of banks before constructing Saturn card
@@ -829,6 +820,18 @@ static void RepeatInitialization(void)
// Aux slot
#ifdef RAMWORKS
if (g_cmdLine.uRamWorksExPages)
{
if (!g_cmdLine.auxSlotEmpty)
{
SetRamWorksMemorySize(g_cmdLine.uRamWorksExPages);
_ASSERT(g_cmdLine.auxSlotInsert == CT_RamWorksIII); // Implicitly set when using cmd line "-r banks"
}
g_cmdLine.uRamWorksExPages = 0; // Don't reapply after a restart
}
#endif
if (g_cmdLine.auxSlotEmpty)
{
GetCardMgr().RemoveAux();
@@ -836,7 +839,7 @@ static void RepeatInitialization(void)
}
else if (g_cmdLine.auxSlotInsert != CT_Empty)
{
if (GetCardMgr().QueryAux() != g_cmdLine.auxSlotInsert) // Ignore if already got this card type in aux slot
if (GetCardMgr().QueryAux() != g_cmdLine.auxSlotInsert) // Ignore if already got this card type in aux slot, ie. via LoadConfiguration()
{
GetCardMgr().InsertAux(g_cmdLine.auxSlotInsert);
SetExpansionMemType(g_cmdLine.auxSlotInsert);