Add comment for the reason that reset doesn't affect memmode & videomode for II and II+ models.

Add accessor for memmode, make static and replace extern refs with GetMemMode().
This commit is contained in:
tomcw 2018-03-19 18:49:08 -07:00
parent 8dcc5d50ca
commit d7de4908cd
4 changed files with 28 additions and 14 deletions

View File

@ -2794,7 +2794,7 @@ void _DrawTriStateSoftSwitch( RECT & rect, int nAddress, int iDisplay, int iActi
else // Main Memory is active, or Bank # is not active else // Main Memory is active, or Bank # is not active
{ {
RECT temp = rect; RECT temp = rect;
int iBank = (memmode & MF_BANK2) int iBank = (GetMemMode() & MF_BANK2)
? 2 ? 2
: 1 : 1
; ;
@ -2858,9 +2858,9 @@ void _DrawSoftSwitchLanguageCardBank( RECT & rect, int iBankDisplay, int bg_defa
// 0 = RAM // 0 = RAM
// 1 = Bank 1 // 1 = Bank 1
// 2 = Bank 2 // 2 = Bank 2
bool bBankWritable = (memmode & MF_WRITERAM) ? 1 : 0; bool bBankWritable = (GetMemMode() & MF_WRITERAM) ? 1 : 0;
int iBankActive = (memmode & MF_HIGHRAM) int iBankActive = (GetMemMode() & MF_HIGHRAM)
? (memmode & MF_BANK2) ? (GetMemMode() & MF_BANK2)
? 2 ? 2
: 1 : 1
: 0 : 0
@ -2959,8 +2959,8 @@ void _DrawSoftSwitchMainAuxBanks( RECT & rect, int bg_default = BG_INFO )
int dx = 7 * w; int dx = 7 * w;
int nAddress = 0xC002; int nAddress = 0xC002;
bool bMainRead = (memmode & MF_AUXREAD) ? true : false; bool bMainRead = (GetMemMode() & MF_AUXREAD) ? true : false;
bool bAuxWrite = (memmode & MF_AUXWRITE) ? true : false; bool bAuxWrite = (GetMemMode() & MF_AUXWRITE) ? true : false;
temp.right = rect.left + dx; temp.right = rect.left + dx;
_DrawSoftSwitch( temp, nAddress, !bMainRead, "R", "m", "x", NULL, BG_DATA_2 ); _DrawSoftSwitch( temp, nAddress, !bMainRead, "R", "m", "x", NULL, BG_DATA_2 );

View File

@ -2174,19 +2174,27 @@ void ResetMachineState ()
//=========================================================================== //===========================================================================
/*
* In comments, UTAII is an abbreviation for a reference to "Understanding the Apple II" by James Sather
*/
// todo: consolidate CtrlReset() and ResetMachineState() // todo: consolidate CtrlReset() and ResetMachineState()
// Ctrl+Reset - TODO: This is a terrible place for this code! Should be in AppleWin.cpp
void CtrlReset() void CtrlReset()
{ {
// Ctrl+Reset - TODO: This is a terrible place for this code! if (!IS_APPLE2)
if (!IS_APPLE2) // TODO: Why not for A][ & A][+ too? {
// For A][ & A][+, reset doesn't reset the LC switches (UTAII:5-29)
MemResetPaging(); MemResetPaging();
// For A][ & A][+, reset doesn't reset the video mode (UTAII:4-4)
VideoResetState(); // Switch Alternate char set off
}
PravetsReset(); PravetsReset();
DiskReset(); DiskReset();
HD_Reset(); HD_Reset();
KeybReset(); KeybReset();
if (!IS_APPLE2) // TODO: Why not for A][ & A][+ too?
VideoResetState(); // Switch Alternate char set off
sg_SSC.CommReset(); sg_SSC.CommReset();
MB_Reset(); MB_Reset();
sg_Mouse.Reset(); // Deassert any pending IRQs - GH#514 sg_Mouse.Reset(); // Deassert any pending IRQs - GH#514

View File

@ -178,7 +178,8 @@ static LPBYTE memimage = NULL;
static LPBYTE pCxRomInternal = NULL; static LPBYTE pCxRomInternal = NULL;
static LPBYTE pCxRomPeripheral = NULL; static LPBYTE pCxRomPeripheral = NULL;
DWORD memmode = MF_BANK2 | MF_SLOTCXROM | MF_WRITERAM; // 2.9.0.4 now global as Debugger needs access for LC status info in DrawSoftSwitches() static const DWORD kMemModeInitialState = MF_BANK2 | MF_SLOTCXROM | MF_WRITERAM;
static DWORD memmode = kMemModeInitialState;
static BOOL modechanging = 0; // An Optimisation: means delay calling UpdatePaging() for 1 instruction static BOOL modechanging = 0; // An Optimisation: means delay calling UpdatePaging() for 1 instruction
static BOOL Pravets8charmode = 0; static BOOL Pravets8charmode = 0;
@ -824,6 +825,11 @@ static void BackMainImage(void)
//=========================================================================== //===========================================================================
DWORD GetMemMode(void)
{
return memmode;
}
static void SetMemMode(const DWORD uNewMemMode) static void SetMemMode(const DWORD uNewMemMode)
{ {
#if defined(_DEBUG) && 0 #if defined(_DEBUG) && 0
@ -860,7 +866,7 @@ static void ResetPaging(BOOL initialize);
static void UpdatePaging(BOOL initialize); static void UpdatePaging(BOOL initialize);
// Call by: // Call by:
// . CtrlReset() Soft-reset (Ctrl+Reset) // . CtrlReset() Soft-reset (Ctrl+Reset) for //e
void MemResetPaging() void MemResetPaging()
{ {
ResetPaging(0); // Initialize=0 ResetPaging(0); // Initialize=0
@ -869,7 +875,7 @@ void MemResetPaging()
static void ResetPaging(BOOL initialize) static void ResetPaging(BOOL initialize)
{ {
g_bLastWriteRam = 0; g_bLastWriteRam = 0;
SetMemMode(MF_BANK2 | MF_SLOTCXROM | MF_WRITERAM); SetMemMode(kMemModeInitialState);
UpdatePaging(initialize); UpdatePaging(initialize);
} }

View File

@ -56,7 +56,6 @@ extern iofunction IOWrite[256];
extern LPBYTE memwrite[0x100]; extern LPBYTE memwrite[0x100];
extern LPBYTE mem; extern LPBYTE mem;
extern LPBYTE memdirty; extern LPBYTE memdirty;
extern DWORD memmode;
#ifdef RAMWORKS #ifdef RAMWORKS
const UINT kMaxExMemoryBanks = 127; // 127 * aux mem(64K) + main mem(64K) = 8MB const UINT kMaxExMemoryBanks = 127; // 127 * aux mem(64K) + main mem(64K) = 8MB
@ -78,6 +77,7 @@ LPBYTE MemGetAuxPtr(const WORD);
LPBYTE MemGetMainPtr(const WORD); LPBYTE MemGetMainPtr(const WORD);
LPBYTE MemGetBankPtr(const UINT nBank); LPBYTE MemGetBankPtr(const UINT nBank);
LPBYTE MemGetCxRomPeripheral(); LPBYTE MemGetCxRomPeripheral();
DWORD GetMemMode(void);
bool MemIsAddrCodeMemory(const USHORT addr); bool MemIsAddrCodeMemory(const USHORT addr);
void MemInitialize (); void MemInitialize ();
void MemInitializeROM(void); void MemInitializeROM(void);