Skip to content

Commit

Permalink
Add PPU mode 5 and 6
Browse files Browse the repository at this point in the history
  • Loading branch information
twvd committed Feb 8, 2024
1 parent cc1b69b commit 97491a4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/snes/ppu/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/snes/ppu/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
}
}
Expand Down

0 comments on commit 97491a4

Please sign in to comment.