Skip to content

Commit 0defd5b

Browse files
committed
add failing garbage4 test
1 parent 5a390c3 commit 0defd5b

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

tests/src/garbage.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
use crate::{util, labels, playfield, video};
2+
3+
pub fn test_garbage4_crash() {
4+
let mut emu = util::emulator(None);
5+
let mut view = video::Video::new();
6+
7+
let main_loop = labels::get("mainLoop");
8+
let practise_type = labels::get("practiseType") as usize;
9+
let game_mode = labels::get("gameMode") as usize;
10+
let level_number = labels::get("levelNumber") as usize;
11+
let gmod = labels::get("garbageModifier") as usize;
12+
let mode = labels::get("MODE_GARBAGE") as u8;
13+
14+
// spend a few frames bootstrapping
15+
for _ in 0..3 {
16+
emu.run_until_vblank();
17+
}
18+
19+
emu.memory.iram_raw[practise_type] = mode;
20+
emu.memory.iram_raw[game_mode] = 4;
21+
emu.memory.iram_raw[level_number] = 18;
22+
emu.memory.iram_raw[gmod] = 4;
23+
emu.registers.pc = main_loop;
24+
25+
for _ in 0..11 {
26+
emu.run_until_vblank();
27+
}
28+
29+
emu.memory.iram_raw[labels::get("currentPiece") as usize] = 0x11;
30+
emu.memory.iram_raw[labels::get("tetriminoX") as usize] = 0x5;
31+
emu.memory.iram_raw[labels::get("tetriminoY") as usize] = 0x0;
32+
emu.memory.iram_raw[labels::get("vramRow") as usize] = 0;
33+
emu.memory.iram_raw[labels::get("autorepeatY") as usize] = 0;
34+
emu.memory.iram_raw[labels::get("rng_seed") as usize] = 0xBE;
35+
emu.memory.iram_raw[(labels::get("rng_seed") as usize) + 1] = 0x83;
36+
37+
playfield::set_str(&mut emu, r##"
38+
##### ###
39+
##### ###
40+
###### ###
41+
###### ###
42+
##########
43+
##########
44+
##########
45+
##########
46+
##########
47+
##########
48+
##########
49+
##########
50+
##########
51+
##########
52+
##########
53+
##########
54+
##########
55+
##########
56+
##########
57+
##########"##);
58+
59+
for _ in 0..40 {
60+
emu.run_until_vblank();
61+
view.render(&mut emu);
62+
}
63+
64+
assert_ne!(emu.cpu.opcode, 18);
65+
}

tests/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod video;
88

99
mod drought;
1010
mod floor;
11+
mod garbage;
1112
mod pushdown;
1213
mod rng;
1314
mod score;
@@ -44,6 +45,8 @@ fn main() {
4445

4546
// run tests
4647
if options.test {
48+
// garbage::test_garbage4_crash();
49+
// println!(">> garbage4 ✅");
4750
floor::test();
4851
println!(">> floor ✅");
4952
tspins::test();
@@ -72,9 +75,9 @@ fn main() {
7275
let mut blocks = sps::SPS::new();
7376

7477
blocks.set_input((
75-
((options.sps_seed >> 16) & 0xFF) as u8,
76-
((options.sps_seed >> 8) & 0xFF) as u8,
77-
(options.sps_seed & 0xFF) as u8,
78+
((options.sps_seed >> 16) & 0xFF) as u8,
79+
((options.sps_seed >> 8) & 0xFF) as u8,
80+
(options.sps_seed & 0xFF) as u8,
7881
));
7982

8083
for _ in 0..options.sps_qty {

0 commit comments

Comments
 (0)