From ae328389b311496a3bcdb6431c220d98abcbf867 Mon Sep 17 00:00:00 2001 From: Ignacio Sanchez Gines <863613+drhelius@users.noreply.github.com> Date: Thu, 28 Dec 2023 22:33:56 +0100 Subject: [PATCH] Activision Cart support. Fixes #45 --- platforms/desktop-shared/emu.cpp | 3 +++ src/Memory_inline.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/platforms/desktop-shared/emu.cpp b/platforms/desktop-shared/emu.cpp index 80a039b..9ae2393 100644 --- a/platforms/desktop-shared/emu.cpp +++ b/platforms/desktop-shared/emu.cpp @@ -358,6 +358,9 @@ static const char* get_mapper(Cartridge::CartridgeTypes type) case Cartridge::CartridgeMegaCart: return "MegaCart"; break; + case Cartridge::CartridgeActivisionCart: + return "Activision"; + break; case Cartridge::CartridgeNotSupported: return "Not Supported"; break; diff --git a/src/Memory_inline.h b/src/Memory_inline.h index ae163de..426bd29 100644 --- a/src/Memory_inline.h +++ b/src/Memory_inline.h @@ -67,6 +67,21 @@ inline u8 Memory::Read(u16 address) return pRom[(address & 0x3FFF) + m_RomBankAddress]; } } + else if (m_pCartridge->GetType() == Cartridge::CartridgeActivisionCart) + { + if (address < 0xC000) + { + return pRom[address & 0x3FFF]; + } + else + { + if (address >= 0xFF80) + { + Log("--> ** EEPROM read: %X %X", address); + } + return pRom[(address & 0x3FFF) + m_RomBankAddress]; + } + } else { if (address >= (romSize + 0x8000)) @@ -131,6 +146,23 @@ inline void Memory::Write(u16 address, u8 value) m_RomBank = address & (m_pCartridge->GetROMBankCount() - 1); m_RomBankAddress = m_RomBank << 14; } + else if ((m_pCartridge->GetType() == Cartridge::CartridgeActivisionCart) && (address >= 0xFF90)) + { + if ((address == 0xFF90) || (address == 0xFFA0) || (address == 0xFFB0)) + { + m_RomBank = (address >> 4) & (m_pCartridge->GetROMBankCount() - 1); + m_RomBankAddress = m_RomBank << 14; + } + + if (address == 0xFFC0) + Log("--> ** EEPROM write SCL=0: %X %X", address, value); + if (address == 0xFFD0) + Log("--> ** EEPROM write SCL=1: %X %X", address, value); + if (address == 0xFFE0) + Log("--> ** EEPROM write SDA=0: %X %X", address, value); + if (address == 0xFFF0) + Log("--> ** EEPROM write SDA=1: %X %X", address, value); + } else { Log("--> ** Attempting to write on ROM: %X %X", address, value);