From 387e26fad943ea08a688a93938f3cfa9a1cffe41 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Mon, 22 Jul 2019 00:09:44 +0300 Subject: [PATCH] Add support for BGMode3 (tonc first.gba example now working) Former-commit-id: 52ac773ee2c3542ff3b046c3ea33fde02e804492 --- src/core/gpu.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/gpu.rs b/src/core/gpu.rs index 2da9460..901028a 100644 --- a/src/core/gpu.rs +++ b/src/core/gpu.rs @@ -309,6 +309,16 @@ impl Gpu { } } + fn scanline_mode3(&mut self, bg: u32, sb: &mut SysBus) { + let y = self.current_scanline; + + for x in 0..Self::DISPLAY_WIDTH { + let pixel_index = x + y * Self::DISPLAY_WIDTH; + let pixel_addr = 0x0600_0000 + 2 * (pixel_index as u32); + self.pixeldata[x + y * 512] = sb.read_16(pixel_addr).into(); + } + } + fn scanline_mode4(&mut self, bg: u32, dispcnt: &DisplayControl, sysbus: &mut SysBus) { let page: u32 = match dispcnt.display_frame { 0 => 0x0600_0000, @@ -337,6 +347,9 @@ impl Gpu { } } } + BGMode::BGMode3 => { + self.scanline_mode3(2, sysbus); + } BGMode::BGMode4 => { self.scanline_mode4(2, &dispcnt, sysbus); }