Skip to content

Commit 8f9ec36

Browse files
committed
test floor itself
1 parent d47635f commit 8f9ec36

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

tests/src/floor.rs

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,59 @@ use crate::{util, labels, playfield};
22

33
pub fn test() {
44
test_floor();
5+
test_floor_linecap();
56
test_floor0();
67
}
78

89
fn test_floor() {
9-
// check rows aren't pulled from the top in linecap floor mode
10+
let mut emu = util::emulator(None);
11+
12+
for _ in 0..3 {
13+
emu.run_until_vblank();
14+
}
15+
16+
let practise_type = labels::get("practiseType") as usize;
17+
let game_mode = labels::get("gameMode") as usize;
18+
let main_loop = labels::get("mainLoop");
19+
let level_number = labels::get("levelNumber") as usize;
20+
21+
// load floor 4
22+
23+
emu.memory.iram_raw[practise_type] = labels::get("MODE_FLOOR") as _;
24+
emu.memory.iram_raw[level_number] = 18;
25+
emu.memory.iram_raw[game_mode] = 4;
26+
emu.memory.iram_raw[labels::get("floorModifier") as usize] = 4;
27+
28+
emu.registers.pc = main_loop;
29+
30+
for _ in 0..10 {
31+
emu.run_until_vblank();
32+
}
33+
34+
// check floor is height 4
35+
36+
for i in 0..160 {
37+
assert_eq!(emu.memory.iram_raw[i + labels::get("playfield") as usize], 0xEF);
38+
}
39+
40+
for i in 160..200 {
41+
assert_ne!(emu.memory.iram_raw[i + labels::get("playfield") as usize], 0xEF);
42+
}
43+
44+
emu.memory.iram_raw[labels::get("currentPiece") as usize] = 0x12;
45+
emu.memory.iram_raw[labels::get("tetriminoX") as usize] = 0x5;
46+
emu.memory.iram_raw[labels::get("tetriminoY") as usize] = 0x0f;
47+
emu.memory.iram_raw[labels::get("autorepeatY") as usize] = 0;
1048

49+
for _ in 0..20 {
50+
emu.run_until_vblank();
51+
}
52+
53+
// check flat line doesnt burn anything
54+
assert_ne!(playfield::get(&mut emu, 0, 19), 0xEF);
55+
}
56+
57+
fn test_floor_linecap() {
1158
let mut emu = util::emulator(None);
1259

1360
for _ in 0..3 {
@@ -54,6 +101,7 @@ fn test_floor() {
54101
}
55102
}
56103

104+
// check rows aren't pulled from the top in linecap floor mode
57105
for i in 0..40 {
58106
assert_eq!(emu.memory.iram_raw[i + labels::get("playfield") as usize], 0xEF);
59107
}
@@ -65,8 +113,6 @@ fn test_floor() {
65113
}
66114

67115
fn test_floor0() {
68-
// check floor 0 doesnt burn lines
69-
70116
let mut emu = util::emulator(None);
71117

72118
for _ in 0..3 {
@@ -108,5 +154,6 @@ fn test_floor0() {
108154
emu.run_until_vblank();
109155
}
110156

157+
// check floor 0 doesnt burn lines
111158
assert_ne!(playfield::get(&mut emu, 0, 19), 0xEF);
112159
}

0 commit comments

Comments
 (0)