Refactor: Rename IORead_Cxxx() to IO_Cxxx(), and use for writes too. Re-enable support for writes to NSC (which was accidently removed at 5470feb).

This commit is contained in:
tomcw 2017-05-21 22:06:37 +01:00
parent 12eed08bea
commit 64dd4c22c2
3 changed files with 27 additions and 24 deletions

View File

@ -542,7 +542,7 @@ static bool IsCardInSlot(const UINT uSlot);
// . Reset: Access to $CFFF or an MMU reset
//
BYTE __stdcall IORead_Cxxx(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCyclesLeft)
static BYTE __stdcall IO_Cxxx(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCyclesLeft)
{
if (address == 0xCFFF)
{
@ -628,9 +628,17 @@ BYTE __stdcall IORead_Cxxx(WORD programcounter, WORD address, BYTE write, BYTE v
if (IsPotentialNoSlotClockAccess(address))
{
int data = 0;
if (g_NoSlotClock.Read(address, data))
return (BYTE) data;
if (!write)
{
int data = 0;
if (g_NoSlotClock.Read(address, data))
return (BYTE) data;
}
else
{
g_NoSlotClock.Write(address);
return 0;
}
}
if (!IS_APPLE2 && !SW_SLOTCXROM)
@ -679,11 +687,6 @@ BYTE __stdcall IORead_Cxxx(WORD programcounter, WORD address, BYTE write, BYTE v
return mem[address];
}
BYTE __stdcall IOWrite_Cxxx(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCyclesLeft)
{
return IORead_Cxxx(programcounter, address, write, value, nCyclesLeft); // GH#392
}
//===========================================================================
static struct SlotInfo
@ -713,8 +716,8 @@ static void InitIoHandlers()
for (; i<256; i++) // C10x..CFFx
{
IORead[i] = IORead_Cxxx;
IOWrite[i] = IOWrite_Cxxx;
IORead[i] = IO_Cxxx;
IOWrite[i] = IO_Cxxx;
}
//
@ -722,8 +725,8 @@ static void InitIoHandlers()
for (i=0; i<NUM_SLOTS; i++)
{
g_SlotInfo[i].bHasCard = false;
g_SlotInfo[i].IOReadCx = IORead_Cxxx;
g_SlotInfo[i].IOWriteCx = IOWrite_Cxxx;
g_SlotInfo[i].IOReadCx = IO_Cxxx;
g_SlotInfo[i].IOWriteCx = IO_Cxxx;
ExpansionRom[i] = NULL;
}
}
@ -740,8 +743,8 @@ void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, io
if (uSlot == 0) // Don't trash C0xx handlers
return;
if (IOReadCx == NULL) IOReadCx = IORead_Cxxx;
if (IOWriteCx == NULL) IOWriteCx = IOWrite_Cxxx;
if (IOReadCx == NULL) IOReadCx = IO_Cxxx;
if (IOWriteCx == NULL) IOWriteCx = IO_Cxxx;
for (UINT i=0; i<16; i++)
{
@ -766,8 +769,8 @@ static void IoHandlerCardsOut(void)
{
for (UINT i=0; i<16; i++)
{
IORead[uSlot*16+i] = IORead_Cxxx;
IOWrite[uSlot*16+i] = IOWrite_Cxxx;
IORead[uSlot*16+i] = IO_Cxxx;
IOWrite[uSlot*16+i] = IO_Cxxx;
}
}
}
@ -784,8 +787,8 @@ static void IoHandlerCardsIn(void)
if (uSlot == 3 && !SW_SLOTC3ROM)
{
// From UTAIIe:5-28: If INTCXROM==0 (SLOTCXROM==1) && SLOTC3ROM==0 Then $C300-C3FF is internal ROM
ioreadcx = IORead_Cxxx;
iowritecx = IOWrite_Cxxx;
ioreadcx = IO_Cxxx;
iowritecx = IO_Cxxx;
}
for (UINT i=0; i<16; i++)

View File

@ -1449,13 +1449,13 @@ static BYTE __stdcall MB_Read(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULO
#ifdef _DEBUG
if(!IS_APPLE2 && !MemCheckSLOTCXROM())
{
_ASSERT(0); // Card ROM disabled, so IORead_Cxxx() returns the internal ROM
_ASSERT(0); // Card ROM disabled, so IO_Cxxx() returns the internal ROM
return mem[nAddr];
}
if(g_SoundcardType == CT_Empty)
{
_ASSERT(0); // Card unplugged, so IORead_Cxxx() returns the floating bus
_ASSERT(0); // Card unplugged, so IO_Cxxx() returns the floating bus
return MemReadFloatingBus(nCyclesLeft);
}
#endif
@ -1512,13 +1512,13 @@ static BYTE __stdcall MB_Write(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, UL
#ifdef _DEBUG
if(!IS_APPLE2 && !MemCheckSLOTCXROM())
{
_ASSERT(0); // Card ROM disabled, so IORead_Cxxx() returns the internal ROM
_ASSERT(0); // Card ROM disabled, so IO_Cxxx() returns the internal ROM
return 0;
}
if(g_SoundcardType == CT_Empty)
{
_ASSERT(0); // Card unplugged, so IORead_Cxxx() returns the floating bus
_ASSERT(0); // Card unplugged, so IO_Cxxx() returns the floating bus
return 0;
}
#endif

View File

@ -1517,7 +1517,7 @@ static BYTE __stdcall TfeIoCxxx (WORD programcounter, WORD address, BYTE write,
// 0 1 N (internal ROM)
if (! (MemCheckSLOTCXROM() && MemCheckSLOTC3ROM()) )
{
_ASSERT(0); // Card ROM disabled, so IORead_Cxxx() returns the internal ROM
_ASSERT(0); // Card ROM disabled, so IO_Cxxx() returns the internal ROM
}
}
#endif