Skip to content

Commit

Permalink
Use some of the extra GBC WRAM as cache if not a GBC game
Browse files Browse the repository at this point in the history
  • Loading branch information
Daft-Freak committed Oct 22, 2021
1 parent 7eca7a9 commit 1853a58
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/DMGMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void DMGMemory::reset()
// reset cache
for(auto it = cachedROMBanks.begin(); it != cachedROMBanks.end();)
{
// remove cart ram, will re-add later if possible
if(it->ptr == cartRam || it->ptr == cartRam + 0x4000)
// remove cart ram/wram, will re-add later if possible
if(it->ptr == cartRam || it->ptr == cartRam + 0x4000 || it->ptr == wram + 0x4000)
{
it = cachedROMBanks.erase(it);
continue;
Expand Down Expand Up @@ -190,6 +190,9 @@ void DMGMemory::reset()
if(cartRamSize <= 0x4000)
cachedROMBanks.emplace_back(ROMCacheEntry{cartRam + 0x4000, 0});

if(!(cartROMBank0[0x143] & 0x80))// CGB flag
cachedROMBanks.emplace_back(ROMCacheEntry{wram + 0x4000, 0}); // spare WRAM (really 0x6000)

mbcRAMEnabled = false;
mbcROMBank = 1;
mbcRAMBank = 0;
Expand Down

0 comments on commit 1853a58

Please sign in to comment.