From 97491a4ab37f624810ee0af5a20f89f6879b12bf Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 8 Feb 2024 20:06:06 +0100 Subject: [PATCH] Add PPU mode 5 and 6 --- src/snes/ppu/render.rs | 41 ++++++++++++++++++++++++++++++++++++----- src/snes/ppu/state.rs | 9 +++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/snes/ppu/render.rs b/src/snes/ppu/render.rs index 89a5538..e6f8cee 100644 --- a/src/snes/ppu/render.rs +++ b/src/snes/ppu/render.rs @@ -416,6 +416,41 @@ impl PPUState { // BG2 tiles with priority 0 self.render_scanline_bglayer(scanline, 1, &mut state, false); } + 5 => { + // 2 layers, bg1: 4bpp (16 colors) + // bg2: 2bpp (4 colors) + // Sprites with priority 3 + self.render_scanline_sprites(scanline, &mut state, 3); + // BG1 tiles with priority 1 + self.render_scanline_bglayer(scanline, 0, &mut state, true); + // Sprites with priority 2 + self.render_scanline_sprites(scanline, &mut state, 2); + // BG2 tiles with priority 1 + self.render_scanline_bglayer(scanline, 1, &mut state, true); + // Sprites with priority 1 + self.render_scanline_sprites(scanline, &mut state, 1); + // BG1 tiles with priority 0 + self.render_scanline_bglayer(scanline, 0, &mut state, false); + // Sprites with priority 0 + self.render_scanline_sprites(scanline, &mut state, 0); + // BG2 tiles with priority 0 + self.render_scanline_bglayer(scanline, 1, &mut state, false); + } + 6 => { + // 1 layer, bg1: 4bpp (16 colors) + // Sprites with priority 3 + self.render_scanline_sprites(scanline, &mut state, 3); + // BG1 tiles with priority 1 + self.render_scanline_bglayer(scanline, 0, &mut state, true); + // Sprites with priority 2 + self.render_scanline_sprites(scanline, &mut state, 2); + // Sprites with priority 1 + self.render_scanline_sprites(scanline, &mut state, 1); + // BG1 tiles with priority 0 + self.render_scanline_bglayer(scanline, 0, &mut state, false); + // Sprites with priority 0 + self.render_scanline_sprites(scanline, &mut state, 0); + } 7 => { // TODO extbg // Sprites with priority 3 @@ -429,11 +464,7 @@ impl PPUState { // Sprites with priority 0 self.render_scanline_sprites(scanline, &mut state, 0); } - _ => println!( - "TODO unimplemented PPU mode {} at scanline {}", - self.get_screen_mode(), - scanline - ), + _ => unreachable!(), } state diff --git a/src/snes/ppu/state.rs b/src/snes/ppu/state.rs index 746c714..f8c846a 100644 --- a/src/snes/ppu/state.rs +++ b/src/snes/ppu/state.rs @@ -370,6 +370,15 @@ impl PPUState { 1 => BPP::Two, _ => unreachable!(), }, + 5 => match bg { + 0 => BPP::Four, + 1 => BPP::Two, + _ => unreachable!(), + }, + 6 => match bg { + 0 => BPP::Four, + _ => unreachable!(), + }, _ => todo!(), } }