fix(video): ignore enable bits for backgrounds a mode lacks
DISPCNT enable bits for BG3 in Mode 1, BG0/BG1 in Mode 2, and every background but BG2 in Modes 3-5 failed the whole frame with UnsupportedLayers, and the window turned that into a stopped session. Hardware has no such backgrounds and ignores the bits, so the renderer now masks them. The error variant is removed. Prohibited OBJ mode 3 and shape 3 stay diagnostics: their hardware output is not established here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HhfHfHEuzv2AUTd6erW1gU
This commit is contained in:
parent
258fbff2fa
commit
0ef2719c6b
5 changed files with 31 additions and 36 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use gba_core::{
|
||||
io::{BG2CNT, BG2PA, BG2X, BG2Y, DISPCNT, GREENSWAP},
|
||||
memory::{Memory, OAM_START as OAM, PALETTE_START as PAL, VRAM_START as VRAM},
|
||||
video::{rgb555_to_rgb888, Framebuffer, VideoError, WIDTH},
|
||||
video::{rgb555_to_rgb888, Framebuffer, WIDTH},
|
||||
};
|
||||
|
||||
fn setup(mode: u16) -> Memory {
|
||||
|
|
@ -423,20 +423,18 @@ fn cpu_bitmap_controls_pan_rotate_zoom_force_page_and_reset() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_bitmap_layers_leave_frame_unchanged() {
|
||||
fn absent_bitmap_layer_bits_are_ignored() {
|
||||
for mode in [4, 5] {
|
||||
let mut m = setup(mode);
|
||||
m.write16(VRAM + 0xa000, 0x0201).unwrap(); // Visible on the selected second page.
|
||||
m.write16(DISPCNT, 0x410 | mode).unwrap();
|
||||
let expected = frame(&m);
|
||||
let mut f = Framebuffer::default();
|
||||
f.clear(0x001f);
|
||||
for extra in [0x100, 0x200, 0x800] {
|
||||
let control = 0x410 | mode | extra;
|
||||
m.write16(DISPCNT, control).unwrap();
|
||||
assert_eq!(
|
||||
m.render_frame(&mut f),
|
||||
Err(VideoError::UnsupportedLayers(control))
|
||||
);
|
||||
m.write16(DISPCNT, 0x410 | mode | extra).unwrap();
|
||||
m.render_frame(&mut f).unwrap();
|
||||
assert_eq!(f.pixels(), expected.pixels());
|
||||
}
|
||||
assert!(f.pixels().iter().all(|&p| p == 0xff0000));
|
||||
assert_eq!(m.cycles(), 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue