Skip to content

Commit

Permalink
gba: improve VRAM mirroring in bitmap background modes (ares-emulator…
Browse files Browse the repository at this point in the history
…#1475)

Blocks accesses to the mirrored region at VRAM addresses 0x18000 to
0x1bfff when in background modes 3-5, as described
[here](https://github.com/nba-emu/hw-test/tree/master/ppu/vram-mirror).
  • Loading branch information
png183 authored May 3, 2024
1 parent f94e053 commit cfda608
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ares/gba/ppu/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ auto PPU::readVRAM_BG(u32 mode, n32 address) -> n32 {
}

auto PPU::readVRAM(u32 mode, n32 address) -> n32 {
address &= 0x1ffff;
if(Background::IO::mode >= 3 && address < 0x1c000 && address >= 0x18000) return 0;

address &= (address & 0x10000) ? 0x17fff : 0x0ffff;

if(mode & Word) {
Expand All @@ -22,6 +25,9 @@ auto PPU::readVRAM(u32 mode, n32 address) -> n32 {
}

auto PPU::writeVRAM(u32 mode, n32 address, n32 word) -> void {
address &= 0x1ffff;
if(Background::IO::mode >= 3 && address < 0x1c000 && address >= 0x18000) return;

address &= (address & 0x10000) ? 0x17fff : 0x0ffff;

if(mode & Word) {
Expand Down

0 comments on commit cfda608

Please sign in to comment.