Converted all the class 'SC' carts to new RWP scheme.

This commit is contained in:
Stephen Anthony 2018-12-17 20:15:11 -03:30
parent ebe18877f9
commit 4ff613b4e9
7 changed files with 67 additions and 121 deletions

View File

@ -44,16 +44,16 @@ void Cartridge4KSC::install(System& system)
System::PageAccess access(this, System::PA_READ); System::PageAccess access(this, System::PA_READ);
// Set the page accessing method for the RAM writing pages // Set the page accessing method for the RAM writing pages
// Map access to this class, since we need to inspect all accesses to
// check if RWP happens
access.type = System::PA_WRITE; access.type = System::PA_WRITE;
for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE)
{ {
access.directPokeBase = &myRAM[addr & 0x007F];
access.codeAccessBase = &myCodeAccessBase[addr & 0x007F]; access.codeAccessBase = &myCodeAccessBase[addr & 0x007F];
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
} }
// Set the page accessing method for the RAM reading pages // Set the page accessing method for the RAM reading pages
access.directPokeBase = nullptr;
access.type = System::PA_READ; access.type = System::PA_READ;
for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE)
{ {
@ -76,17 +76,15 @@ uInt8 Cartridge4KSC::peek(uInt16 address)
{ {
// The only way we can get to this method is if we attempt to read from // The only way we can get to this method is if we attempt to read from
// the write port (0xF000 - 0xF07F, 128 bytes), in which case an // the write port (0xF000 - 0xF07F, 128 bytes), in which case an
// unwanted write is triggered // unwanted write is potentially triggered
uInt8 value = mySystem->getDataBusState(0xFF); return peekRAM(myRAM[address & 0x007F], address);
}
if(bankLocked()) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
return value; bool Cartridge4KSC::poke(uInt16 address, uInt8 value)
else {
{ pokeRAM(myRAM[address & 0x007F], address, value);
myRAM[address & 0x0FFF] = value; return true;
triggerReadFromWritePort(address);
return value;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -120,6 +120,15 @@ class Cartridge4KSC : public Cartridge
*/ */
uInt8 peek(uInt16 address) override; uInt8 peek(uInt16 address) override;
/**
Change the byte at the specified address to the given value
@param address The address where the value should be stored
@param value The value to be stored at the address
@return True if the poke changed the device address space, else false
*/
bool poke(uInt16 address, uInt8 value) override;
private: private:
// The 4K ROM image of the cartridge // The 4K ROM image of the cartridge
uInt8 myImage[4096]; uInt8 myImage[4096];

View File

@ -47,16 +47,16 @@ void CartridgeBFSC::install(System& system)
System::PageAccess access(this, System::PA_READ); System::PageAccess access(this, System::PA_READ);
// Set the page accessing method for the RAM writing pages // Set the page accessing method for the RAM writing pages
// Map access to this class, since we need to inspect all accesses to
// check if RWP happens
access.type = System::PA_WRITE; access.type = System::PA_WRITE;
for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE)
{ {
access.directPokeBase = &myRAM[addr & 0x007F];
access.codeAccessBase = &myCodeAccessBase[addr & 0x007F]; access.codeAccessBase = &myCodeAccessBase[addr & 0x007F];
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
} }
// Set the page accessing method for the RAM reading pages // Set the page accessing method for the RAM reading pages
access.directPokeBase = nullptr;
access.type = System::PA_READ; access.type = System::PA_READ;
for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE)
{ {
@ -80,36 +80,25 @@ uInt8 CartridgeBFSC::peek(uInt16 address)
bank(address - 0x0F80); bank(address - 0x0F80);
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes) if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{ return peekRAM(myRAM[address], peekAddress);
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
if(bankLocked())
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return value;
}
}
else else
return myImage[myBankOffset + address]; return myImage[myBankOffset + address];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeBFSC::poke(uInt16 address, uInt8) bool CartridgeBFSC::poke(uInt16 address, uInt8 value)
{ {
address &= 0x0FFF; address &= 0x0FFF;
// Switch banks if necessary // Switch banks if necessary
if((address >= 0x0F80) && (address <= 0x0FBF)) if((address >= 0x0F80) && (address <= 0x0FBF))
{
bank(address - 0x0F80); bank(address - 0x0F80);
// NOTE: This does not handle accessing RAM, however, this method
// should never be called for RAM because of the way page accessing
// has been setup
return false; return false;
}
pokeRAM(myRAM[address & 0x007F], address, value);
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -47,16 +47,16 @@ void CartridgeDFSC::install(System& system)
System::PageAccess access(this, System::PA_READ); System::PageAccess access(this, System::PA_READ);
// Set the page accessing method for the RAM writing pages // Set the page accessing method for the RAM writing pages
// Map access to this class, since we need to inspect all accesses to
// check if RWP happens
access.type = System::PA_WRITE; access.type = System::PA_WRITE;
for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE)
{ {
access.directPokeBase = &myRAM[addr & 0x007F];
access.codeAccessBase = &myCodeAccessBase[addr & 0x007F]; access.codeAccessBase = &myCodeAccessBase[addr & 0x007F];
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
} }
// Set the page accessing method for the RAM reading pages // Set the page accessing method for the RAM reading pages
access.directPokeBase = nullptr;
access.type = System::PA_READ; access.type = System::PA_READ;
for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE)
{ {
@ -80,36 +80,25 @@ uInt8 CartridgeDFSC::peek(uInt16 address)
bank(address - 0x0FC0); bank(address - 0x0FC0);
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes) if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{ return peekRAM(myRAM[address], peekAddress);
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
if(bankLocked())
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return value;
}
}
else else
return myImage[myBankOffset + address]; return myImage[myBankOffset + address];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeDFSC::poke(uInt16 address, uInt8) bool CartridgeDFSC::poke(uInt16 address, uInt8 value)
{ {
address &= 0x0FFF; address &= 0x0FFF;
// Switch banks if necessary // Switch banks if necessary
if((address >= 0x0FC0) && (address <= 0x0FDF)) if((address >= 0x0FC0) && (address <= 0x0FDF))
{
bank(address - 0x0FC0); bank(address - 0x0FC0);
// NOTE: This does not handle accessing RAM, however, this method
// should never be called for RAM because of the way page accessing
// has been setup
return false; return false;
}
pokeRAM(myRAM[address & 0x007F], address, value);
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -47,16 +47,16 @@ void CartridgeEFSC::install(System& system)
System::PageAccess access(this, System::PA_READ); System::PageAccess access(this, System::PA_READ);
// Set the page accessing method for the RAM writing pages // Set the page accessing method for the RAM writing pages
// Map access to this class, since we need to inspect all accesses to
// check if RWP happens
access.type = System::PA_WRITE; access.type = System::PA_WRITE;
for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE)
{ {
access.directPokeBase = &myRAM[addr & 0x007F];
access.codeAccessBase = &myCodeAccessBase[addr & 0x007F]; access.codeAccessBase = &myCodeAccessBase[addr & 0x007F];
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
} }
// Set the page accessing method for the RAM reading pages // Set the page accessing method for the RAM reading pages
access.directPokeBase = nullptr;
access.type = System::PA_READ; access.type = System::PA_READ;
for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE)
{ {
@ -80,36 +80,25 @@ uInt8 CartridgeEFSC::peek(uInt16 address)
bank(address - 0x0FE0); bank(address - 0x0FE0);
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes) if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{ return peekRAM(myRAM[address], peekAddress);
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
if(bankLocked())
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return value;
}
}
else else
return myImage[myBankOffset + address]; return myImage[myBankOffset + address];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeEFSC::poke(uInt16 address, uInt8) bool CartridgeEFSC::poke(uInt16 address, uInt8 value)
{ {
address &= 0x0FFF; address &= 0x0FFF;
// Switch banks if necessary // Switch banks if necessary
if((address >= 0x0FE0) && (address <= 0x0FEF)) if((address >= 0x0FE0) && (address <= 0x0FEF))
{
bank(address - 0x0FE0); bank(address - 0x0FE0);
// NOTE: This does not handle accessing RAM, however, this function
// should never be called for RAM because of the way page accessing
// has been setup
return false; return false;
}
pokeRAM(myRAM[address & 0x007F], address, value);
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -47,16 +47,16 @@ void CartridgeF4SC::install(System& system)
System::PageAccess access(this, System::PA_READ); System::PageAccess access(this, System::PA_READ);
// Set the page accessing method for the RAM writing pages // Set the page accessing method for the RAM writing pages
// Map access to this class, since we need to inspect all accesses to
// check if RWP happens
access.type = System::PA_WRITE; access.type = System::PA_WRITE;
for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE)
{ {
access.directPokeBase = &myRAM[addr & 0x007F];
access.codeAccessBase = &myCodeAccessBase[addr & 0x007F]; access.codeAccessBase = &myCodeAccessBase[addr & 0x007F];
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
} }
// Set the page accessing method for the RAM reading pages // Set the page accessing method for the RAM reading pages
access.directPokeBase = nullptr;
access.type = System::PA_READ; access.type = System::PA_READ;
for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE)
{ {
@ -80,39 +80,25 @@ uInt8 CartridgeF4SC::peek(uInt16 address)
bank(address - 0x0FF4); bank(address - 0x0FF4);
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes) if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{ return peekRAM(myRAM[address], peekAddress);
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
if(bankLocked())
return value;
else else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return value;
}
}
// NOTE: This does not handle accessing RAM, however, this function
// should never be called for RAM because of the way page accessing
// has been setup
return myImage[myBankOffset + address]; return myImage[myBankOffset + address];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF4SC::poke(uInt16 address, uInt8) bool CartridgeF4SC::poke(uInt16 address, uInt8 value)
{ {
address &= 0x0FFF; address &= 0x0FFF;
// Switch banks if necessary // Switch banks if necessary
if((address >= 0x0FF4) && (address <= 0x0FFB)) if((address >= 0x0FF4) && (address <= 0x0FFB))
{
bank(address - 0x0FF4); bank(address - 0x0FF4);
// NOTE: This does not handle accessing RAM, however, this function
// should never be called for RAM because of the way page accessing
// has been setup
return false; return false;
}
pokeRAM(myRAM[address & 0x007F], address, value);
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -47,16 +47,16 @@ void CartridgeF6SC::install(System& system)
System::PageAccess access(this, System::PA_READ); System::PageAccess access(this, System::PA_READ);
// Set the page accessing method for the RAM writing pages // Set the page accessing method for the RAM writing pages
// Map access to this class, since we need to inspect all accesses to
// check if RWP happens
access.type = System::PA_WRITE; access.type = System::PA_WRITE;
for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1000; addr < 0x1080; addr += System::PAGE_SIZE)
{ {
access.directPokeBase = &myRAM[addr & 0x007F];
access.codeAccessBase = &myCodeAccessBase[addr & 0x007F]; access.codeAccessBase = &myCodeAccessBase[addr & 0x007F];
mySystem->setPageAccess(addr, access); mySystem->setPageAccess(addr, access);
} }
// Set the page accessing method for the RAM reading pages // Set the page accessing method for the RAM reading pages
access.directPokeBase = nullptr;
access.type = System::PA_READ; access.type = System::PA_READ;
for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE) for(uInt16 addr = 0x1080; addr < 0x1100; addr += System::PAGE_SIZE)
{ {
@ -103,25 +103,13 @@ uInt8 CartridgeF6SC::peek(uInt16 address)
} }
if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes) if(address < 0x0080) // Write port is at 0xF000 - 0xF07F (128 bytes)
{ return peekRAM(myRAM[address], peekAddress);
// Reading from the write port triggers an unwanted write
uInt8 value = mySystem->getDataBusState(0xFF);
if(bankLocked())
return value;
else
{
myRAM[address] = value;
triggerReadFromWritePort(peekAddress);
return value;
}
}
else else
return myImage[myBankOffset + address]; return myImage[myBankOffset + address];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeF6SC::poke(uInt16 address, uInt8) bool CartridgeF6SC::poke(uInt16 address, uInt8 value)
{ {
address &= 0x0FFF; address &= 0x0FFF;
@ -131,31 +119,29 @@ bool CartridgeF6SC::poke(uInt16 address, uInt8)
case 0x0FF6: case 0x0FF6:
// Set the current bank to the first 4k bank // Set the current bank to the first 4k bank
bank(0); bank(0);
break; return false;
case 0x0FF7: case 0x0FF7:
// Set the current bank to the second 4k bank // Set the current bank to the second 4k bank
bank(1); bank(1);
break; return false;
case 0x0FF8: case 0x0FF8:
// Set the current bank to the third 4k bank // Set the current bank to the third 4k bank
bank(2); bank(2);
break; return false;
case 0x0FF9: case 0x0FF9:
// Set the current bank to the forth 4k bank // Set the current bank to the forth 4k bank
bank(3); bank(3);
break; return false;
default: default:
break; break;
} }
// NOTE: This does not handle accessing RAM, however, this function pokeRAM(myRAM[address & 0x007F], address, value);
// should never be called for RAM because of the way page accessing return true;
// has been setup
return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -