feat(video): capture scanlines and prepare sprites one row ahead

Add cycle40 preparation, deferred diagnostics, HBlank capture, VBlank presentation, and affine history tests.
This commit is contained in:
0xrsydn 2026-10-05 12:55:35 +07:00
commit 52c77193cb
9 changed files with 1376 additions and 0 deletions

38
tests/scanlines.rs Normal file
View file

@ -0,0 +1,38 @@
use gba_rust::{
cpu::Cpu,
display::{CYCLES_PER_FRAME, CYCLES_PER_LINE, HBLANK_START, VBLANK_START},
dma::DMA_BASE,
input::{Button, Buttons},
io::*,
machine::{Machine, StepKind},
memory::{Memory, OAM_START as OAM, PALETTE_START as PAL, ROM_START, VRAM_START as VRAM},
raster_demo::{RasterDemo, RASTER_STATE, RASTER_TABLE},
video::{rgb555_to_rgb888 as rgb, Framebuffer, VideoError, HEIGHT, WIDTH},
};
#[path = "scanlines/capture.rs"]
mod capture;
#[path = "scanlines/machine.rs"]
mod machine;
#[path = "scanlines/rendering.rs"]
mod rendering;
fn memory() -> Memory {
let mut m = Memory::new(vec![]).unwrap();
m.set_scanline_rendering(true);
m
}
fn present(m: &Memory) -> Framebuffer {
let mut f = Framebuffer::default();
assert!(m.present_frame(&mut f).unwrap());
f
}
fn at(f: &Framebuffer, x: usize, y: usize) -> u32 {
f.pixels()[y * WIDTH + x]
}
fn word_rom(code: &[u32]) -> Vec<u8> {
code.iter().flat_map(|v| v.to_le_bytes()).collect()
}