Skip to content

Commit 150e366

Browse files
committed
MBC1: Remap ROM bank 0 reads in mode 1
1 parent 0d75149 commit 150e366

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/MBC1MemoryRule.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ u8 MBC1MemoryRule::PerformRead(u16 address)
5858
{
5959
switch (address & 0xE000)
6060
{
61+
case 0x0000:
62+
case 0x2000:
63+
{
64+
if (m_iMode == 1)
65+
{
66+
u8* pROM = m_pCartridge->GetTheROM();
67+
int bank0 = (m_HigherRomBankBits << 5) & (m_pCartridge->GetROMBankCount() - 1);
68+
return pROM[(bank0 * 0x4000) + address];
69+
}
70+
return m_pMemory->Retrieve(address);
71+
}
6172
case 0x4000:
6273
case 0x6000:
6374
{
@@ -276,11 +287,19 @@ int MBC1MemoryRule::GetCurrentRomBank1Index()
276287

277288
u8* MBC1MemoryRule::GetRomBank0()
278289
{
290+
if (m_iMode == 1)
291+
{
292+
u8* pROM = m_pCartridge->GetTheROM();
293+
int bank0 = (m_HigherRomBankBits << 5) & (m_pCartridge->GetROMBankCount() - 1);
294+
return pROM + (bank0 * 0x4000);
295+
}
279296
return m_pMemory->GetMemoryMap() + 0x0000;
280297
}
281298

282299
int MBC1MemoryRule::GetCurrentRomBank0Index()
283300
{
301+
if (m_iMode == 1)
302+
return (m_HigherRomBankBits << 5) & (m_pCartridge->GetROMBankCount() - 1);
284303
return 0;
285304
}
286305

0 commit comments

Comments
 (0)