From 80eb33012fee3918d5c39e1d2677ac3f171172ea Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 7 Jun 2020 18:25:34 +0100 Subject: [PATCH] Fixed an edge case when switching from IIe to II+, and the Mockingboard wasn't visible in memory. . Due to INTCXROM still being set and it not being excluded when in II+ mode. . Fix is to reinit memmode on restart and only check INTCXROM if IIe or above. --- source/Common.h | 7 ++++++- source/Memory.cpp | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/Common.h b/source/Common.h index 6a9b5cc6..f2c6516b 100644 --- a/source/Common.h +++ b/source/Common.h @@ -161,7 +161,7 @@ enum eIRQSRC {IS_6522=0, IS_SPEECH, IS_SSC, IS_MOUSE}; #define APPLECLONE_MASK 0x100 #define IS_APPLE2 ((g_Apple2Type & (APPLE2E_MASK|APPLE2C_MASK)) == 0) -#define IS_APPLE2E() (g_Apple2Type & APPLE2E_MASK) +//#define IS_APPLE2E() (g_Apple2Type & APPLE2E_MASK) // unused #define IS_APPLE2C() (g_Apple2Type & APPLE2C_MASK) #define IS_CLONE() (g_Apple2Type & APPLECLONE_MASK) @@ -218,6 +218,11 @@ inline bool IsApple2PlusOrClone(eApple2Type type) // Apple ][,][+,][J-Plus or cl return (type & (APPLE2E_MASK|APPLE2C_MASK)) == 0; } +inline bool IsAppleIIeOrAbove(eApple2Type type) // Apple //e,Enhanced//e,//c or clone //e,Enhanced//e +{ + return !IsApple2PlusOrClone(type); +} + extern eApple2Type g_Apple2Type; inline bool IsEnhancedIIE(void) { diff --git a/source/Memory.cpp b/source/Memory.cpp index b65dd0e8..4c513f64 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -1499,6 +1499,12 @@ void MemInitialize() CreateLanguageCard(); + // Reinit memmode on a restart (eg. h/w config changes) + if (IsApple2PlusOrClone(GetApple2Type()) && g_CardMgr.QuerySlot(SLOT0) == CT_Empty) + SetMemMode(0); + else + SetMemMode(LanguageCardUnit::kMemModeInitialState); + MemInitializeROM(); MemInitializeCustomROM(); MemInitializeCustomF8ROM(); @@ -1768,7 +1774,7 @@ void MemInitializeIO(void) // Finally remove the cards' ROMs at $Csnn if internal ROM is enabled // . required when restoring saved-state - if (SW_INTCXROM) + if (IsAppleIIeOrAbove(GetApple2Type()) && SW_INTCXROM) IoHandlerCardsOut(); } @@ -2092,7 +2098,7 @@ BYTE __stdcall MemSetPaging(WORD programcounter, WORD address, BYTE write, BYTE bool MemOptimizeForModeChanging(WORD programcounter, WORD address) { - if (IS_APPLE2E()) + if (IsAppleIIeOrAbove(GetApple2Type())) { // IF THE EMULATED PROGRAM HAS JUST UPDATED THE MEMORY WRITE MODE AND IS // ABOUT TO UPDATE THE MEMORY READ MODE, HOLD OFF ON ANY PROCESSING UNTIL