Corrected for use with the latest EightBit library.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-06-17 21:08:01 +01:00
parent 757d8f3c32
commit 53461e712f
2 changed files with 8 additions and 12 deletions

View File

@ -59,8 +59,8 @@ namespace EightBit {
int runVerticalBlankLines();
protected:
virtual uint8_t& reference(uint16_t address, bool& rom);
virtual uint8_t reference(uint16_t address, bool& rom) const;
virtual uint8_t& reference(uint16_t address);
virtual uint8_t reference(uint16_t address) const;
private:
LR35902 m_cpu;

View File

@ -149,9 +149,8 @@ void EightBit::GameBoy::Bus::validateCartridgeType() {
}
}
uint8_t EightBit::GameBoy::Bus::reference(uint16_t address, bool& rom) const {
uint8_t EightBit::GameBoy::Bus::reference(uint16_t address) const {
rom = true;
if ((address < 0x100) && IO().bootRomEnabled())
return m_bootRom.reference(address);
if ((address < 0x4000) && gameRomEnabled())
@ -159,11 +158,10 @@ uint8_t EightBit::GameBoy::Bus::reference(uint16_t address, bool& rom) const {
if ((address < 0x8000) && gameRomEnabled())
return m_gameRomBanks[m_romBank].reference(address - 0x4000);
rom = false;
if (address < 0xa000)
return VRAM().reference(address - 0x8000);
if (address < 0xc000)
return m_ramBanks.size() == 0 ? rom = true, 0xff : m_ramBanks[m_ramBank].reference(address - 0xa000);
return m_ramBanks.size() == 0 ? 0xff : m_ramBanks[m_ramBank].reference(address - 0xa000);
if (address < 0xe000)
return m_lowInternalRam.reference(address - 0xc000);
if (address < 0xfe00)
@ -171,15 +169,14 @@ uint8_t EightBit::GameBoy::Bus::reference(uint16_t address, bool& rom) const {
if (address < 0xfea0)
return OAMRAM().reference(address - 0xfe00);
if (address < IoRegisters::BASE)
return rom = true, 0xff;
return 0xff;
if (address < 0xff80)
return IO().reference(address - IoRegisters::BASE);
return m_highInternalRam.reference(address - 0xff80);
}
uint8_t& EightBit::GameBoy::Bus::reference(uint16_t address, bool& rom) {
uint8_t& EightBit::GameBoy::Bus::reference(uint16_t address) {
rom = true;
if ((address < 0x100) && IO().bootRomEnabled())
return DATA() = m_bootRom.reference(address);
if ((address < 0x4000) && gameRomEnabled())
@ -187,11 +184,10 @@ uint8_t& EightBit::GameBoy::Bus::reference(uint16_t address, bool& rom) {
if ((address < 0x8000) && gameRomEnabled())
return DATA() = m_gameRomBanks[m_romBank].reference(address - 0x4000);
rom = false;
if (address < 0xa000)
return VRAM().reference(address - 0x8000);
if (address < 0xc000)
return m_ramBanks.size() == 0 ? rom = true, DATA() = 0xff : m_ramBanks[m_ramBank].reference(address - 0xa000);
return m_ramBanks.size() == 0 ? DATA() = 0xff : m_ramBanks[m_ramBank].reference(address - 0xa000);
if (address < 0xe000)
return m_lowInternalRam.reference(address - 0xc000);
if (address < 0xfe00)
@ -199,7 +195,7 @@ uint8_t& EightBit::GameBoy::Bus::reference(uint16_t address, bool& rom) {
if (address < 0xfea0)
return OAMRAM().reference(address - 0xfe00);
if (address < IoRegisters::BASE)
return rom = true, DATA() = 0xff;
return DATA() = 0xff;
if (address < 0xff80)
return IO().reference(address - IoRegisters::BASE);
return m_highInternalRam.reference(address - 0xff80);