In the case of 'read from write port', make sure RAM is modified before exception is thrown.

This commit is contained in:
Stephen Anthony 2018-12-07 21:45:28 -03:30
parent abfc01b483
commit 7b4c3dc6b8
17 changed files with 49 additions and 33 deletions

View File

@ -91,8 +91,9 @@ uInt8 Cartridge3E::peek(uInt16 address)
return value;
else
{
myRAM[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value;
return value;
}
}
}

View File

@ -103,12 +103,12 @@ uInt8 Cartridge3EPlus::peek(uInt16 address)
return value;
else
{
triggerReadFromWritePort(peekAddress);
Int32 ramBank = imageBank & BIT_BANK_MASK; // discard irrelevant bits
Int32 offset = ramBank << RAM_BANK_TO_POWER; // base bank address in RAM
offset += (address & BITMASK_RAM_BANK); // + byte offset in RAM bank
return myRAM[offset] = value;
myRAM[offset] = value;
triggerReadFromWritePort(peekAddress);
return value;
}
}

View File

@ -75,7 +75,7 @@ void Cartridge4KSC::install(System& system)
uInt8 Cartridge4KSC::peek(uInt16 address)
{
// The only way we can get to this method is if we attempt to read from
// the write port (0xF000 - 0xF080, 128 bytes), in which case an
// the write port (0xF000 - 0xF07F, 128 bytes), in which case an
// unwanted write is triggered
uInt8 value = mySystem->getDataBusState(0xFF);
@ -83,8 +83,9 @@ uInt8 Cartridge4KSC::peek(uInt16 address)
return value;
else
{
myRAM[address & 0x0FFF] = value;
triggerReadFromWritePort(address);
return myRAM[address & 0x0FFF] = value;
return value;
}
}

View File

@ -79,7 +79,7 @@ uInt8 CartridgeBFSC::peek(uInt16 address)
if((address >= 0x0F80) && (address <= 0x0FBF))
bank(address - 0x0F80);
if(address < 0x0080) // Write port is at 0xF000 - 0xF080 (128 bytes)
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -88,8 +88,9 @@ uInt8 CartridgeBFSC::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else

View File

@ -131,8 +131,9 @@ uInt8 CartridgeCTY::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else if(address < 0x0080) // Read port is at $1040 - $107F (64 bytes)

View File

@ -98,7 +98,7 @@ void CartridgeCV::install(System& system)
uInt8 CartridgeCV::peek(uInt16 address)
{
// The only way we can get to this method is if we attempt to read from
// the write port (0xF400 - 0xF800, 1024 bytes), in which case an
// the write port (0xF400 - 0xF7FF, 1024 bytes), in which case an
// unwanted write is triggered
uInt8 value = mySystem->getDataBusState(0xFF);
@ -106,8 +106,9 @@ uInt8 CartridgeCV::peek(uInt16 address)
return value;
else
{
myRAM[address & 0x03FF] = value;
triggerReadFromWritePort(address);
return myRAM[address & 0x03FF] = value;
return value;
}
}

View File

@ -83,7 +83,7 @@ void CartridgeCVPlus::install(System& system)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeCVPlus::peek(uInt16 address)
{
if((address & 0x0FFF) < 0x0800) // Write port is at 0xF400 - 0xF800 (1024 bytes)
if((address & 0x0FFF) < 0x0800) // Write port is at 0xF400 - 0xF7FF (1024 bytes)
{ // Read port is handled in ::install()
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -92,8 +92,9 @@ uInt8 CartridgeCVPlus::peek(uInt16 address)
return value;
else
{
myRAM[address & 0x03FF] = value;
triggerReadFromWritePort(address);
return myRAM[address & 0x03FF] = value;
return value;
}
}
else

View File

@ -107,12 +107,12 @@ uInt8 CartridgeDASH::peek(uInt16 address)
return value;
else
{
triggerReadFromWritePort(peekAddress);
Int32 ramBank = imageBank & BIT_BANK_MASK; // discard irrelevant bits
Int32 offset = ramBank << RAM_BANK_TO_POWER; // base bank address in RAM
offset += (address & BITMASK_RAM_BANK); // + byte offset in RAM bank
return myRAM[offset] = value;
myRAM[offset] = value;
triggerReadFromWritePort(peekAddress);
return value;
}
}

View File

@ -79,7 +79,7 @@ uInt8 CartridgeDFSC::peek(uInt16 address)
if((address >= 0x0FC0) && (address <= 0x0FDF))
bank(address - 0x0FC0);
if(address < 0x0080) // Write port is at 0xF000 - 0xF080 (128 bytes)
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -88,8 +88,9 @@ uInt8 CartridgeDFSC::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else

View File

@ -79,7 +79,7 @@ uInt8 CartridgeEFSC::peek(uInt16 address)
if((address >= 0x0FE0) && (address <= 0x0FEF))
bank(address - 0x0FE0);
if(address < 0x0080) // Write port is at 0xF000 - 0xF080 (128 bytes)
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -88,8 +88,9 @@ uInt8 CartridgeEFSC::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else

View File

@ -79,7 +79,7 @@ uInt8 CartridgeF4SC::peek(uInt16 address)
if((address >= 0x0FF4) && (address <= 0x0FFB))
bank(address - 0x0FF4);
if(address < 0x0080) // Write port is at 0xF000 - 0xF080 (128 bytes)
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -88,8 +88,9 @@ uInt8 CartridgeF4SC::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}

View File

@ -102,7 +102,7 @@ uInt8 CartridgeF6SC::peek(uInt16 address)
break;
}
if(address < 0x0080) // Write port is at 0xF000 - 0xF080 (128 bytes)
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -111,8 +111,9 @@ uInt8 CartridgeF6SC::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else

View File

@ -92,7 +92,7 @@ uInt8 CartridgeF8SC::peek(uInt16 address)
break;
}
if(address < 0x0080) // Write port is at 0xF000 - 0xF080 (128 bytes)
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -101,8 +101,9 @@ uInt8 CartridgeF8SC::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else

View File

@ -97,7 +97,7 @@ uInt8 CartridgeFA::peek(uInt16 address)
break;
}
if(address < 0x0100) // Write port is at 0xF000 - 0xF100 (256 bytes)
if(address < 0x0100) // Write port is at 0xF000 - 0xF0FF (256 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -106,8 +106,9 @@ uInt8 CartridgeFA::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else

View File

@ -136,7 +136,7 @@ uInt8 CartridgeFA2::peek(uInt16 address)
break;
}
if(address < 0x0100) // Write port is at 0xF000 - 0xF100 (256 bytes)
if(address < 0x0100) // Write port is at 0xF000 - 0xF0FF (256 bytes)
{
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
@ -145,8 +145,9 @@ uInt8 CartridgeFA2::peek(uInt16 address)
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address] = value;
return value;
}
}
else

View File

@ -123,8 +123,9 @@ uInt8 CartridgeMNetwork::peek(uInt16 address)
return value;
else
{
myRAM[address & (BANK_SIZE / 2 - 1)] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address & (BANK_SIZE / 2 - 1)] = value;
return value;
}
}
else if((address >= 0x0800) && (address <= 0x08FF))
@ -136,8 +137,9 @@ uInt8 CartridgeMNetwork::peek(uInt16 address)
return value;
else
{
myRAM[1024 + (myCurrentRAM << 8) + (address & 0x00FF)] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[1024 + (myCurrentRAM << 8) + (address & 0x00FF)] = value;
return value;
}
}
else

View File

@ -117,8 +117,9 @@ uInt8 CartridgeWD::peek(uInt16 address)
return value;
else
{
myRAM[address & 0x003F] = value;
triggerReadFromWritePort(peekAddress);
return myRAM[address & 0x003F] = value;
return value;
}
}
else if(address < 0x0400)