Skip to content

Commit 030f05d

Browse files
committed
test tspin rendering is correct
1 parent 858c105 commit 030f05d

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

tests/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod rng;
1313
mod score;
1414
mod sps;
1515
mod toprow;
16+
mod tspins;
1617

1718
use gumdrop::Options;
1819

@@ -45,6 +46,8 @@ fn main() {
4546
if options.test {
4647
floor::test();
4748
println!(">> floor ✅");
49+
tspins::test();
50+
println!(">> tspins ✅");
4851
toprow::test();
4952
println!(">> top row bug ✅");
5053
score::test();
@@ -125,8 +128,7 @@ fn main() {
125128
emu.run_until_vblank();
126129
}
127130

128-
emu.ppu.render_ntsc(video::WIDTH);
129-
view.update(&emu.ppu.filtered_screen);
131+
view.render(&mut emu);
130132
});
131133
loop {}
132134
}

tests/src/tspins.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use crate::{util, labels, playfield};
2+
3+
pub fn test() {
4+
let mut emu = util::emulator(None);
5+
6+
for _ in 0..4 {
7+
emu.run_until_vblank();
8+
}
9+
10+
let practise_type = labels::get("practiseType") as usize;
11+
let game_mode = labels::get("gameMode") as usize;
12+
let main_loop = labels::get("mainLoop");
13+
let level_number = labels::get("levelNumber") as usize;
14+
15+
16+
emu.memory.iram_raw[practise_type] = labels::get("MODE_TSPINS") as _;
17+
emu.memory.iram_raw[level_number] = 18;
18+
emu.memory.iram_raw[game_mode] = 4;
19+
20+
emu.registers.pc = main_loop;
21+
22+
for _ in 0..10 {
23+
emu.run_until_vblank();
24+
}
25+
26+
let offset = |x, y| x + (y * 256);
27+
28+
// check playfield
29+
assert_eq!(r##"
30+
###### ##
31+
##### ##
32+
###### ###
33+
##########
34+
"##.trim(), playfield::get_str(&emu).trim());
35+
36+
// check pixel is actually rendered
37+
assert_eq!(emu.ppu.screen[offset(96, 176) as usize], 0x30);
38+
}

tests/src/video.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rusticnes_core::nes::NesState;
12
use minifb::{Window, WindowOptions};
23

34
pub const WIDTH: usize = 256;
@@ -24,7 +25,8 @@ impl Video {
2425
}
2526
}
2627

27-
pub fn update(&mut self, screen: &Vec<u32>) {
28-
self.window.update_with_buffer(screen, WIDTH, HEIGHT).unwrap();
28+
pub fn render(&mut self, emu: &mut NesState) {
29+
emu.ppu.render_ntsc(WIDTH);
30+
self.window.update_with_buffer(&emu.ppu.filtered_screen, WIDTH, HEIGHT).unwrap();
2931
}
3032
}

0 commit comments

Comments
 (0)