Skip to content

Commit 565d6d8

Browse files
committed
update hz display tests
1 parent 07e417a commit 565d6d8

File tree

3 files changed

+63
-12
lines changed

3 files changed

+63
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* Famicom Keyboard support
2525
* MMC3 Support
2626
* MMC5 Support
27+
* Added "negative delay" to the hz display
28+
* Keep hz display enabled when topped out
2729

2830
## [v5 tournament]
2931
* Linecap Menu (from CTM Masters September 2022)

tests/src/hz_display.rs

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ use crate::{input, labels, util};
22
use rusticnes_core::nes::NesState;
33

44
pub fn test() {
5+
test_standard();
6+
test_tspin();
7+
}
8+
9+
fn test_standard() {
510
let mut emu = util::emulator(None);
611

712
for _ in 0..4 {
@@ -33,12 +38,56 @@ pub fn test() {
3338
// make piece fall immediately so emulation takes less time
3439
run_input_string(&mut emu, "D");
3540
// fall 18 rows, then 3 frames before the 10-frame entry delay finishes
36-
util::run_n_vblanks(&mut emu, 18+10-3);
37-
run_input_string(&mut emu, "R.R.R.R.R.");
38-
assert_hz_display(&mut emu, HzSpeed(30, 5), 3, 1, Dir::Right);
39-
// TODO: have tests for -2 and -1 entry delay too.
4041
// each negative entry delay should have its own test because they all
4142
// need to be handled specifically in separate branches
43+
util::run_n_vblanks(&mut emu, 18+10-3);
44+
run_input_string(&mut emu, "R.R.R.R.R.");
45+
assert_hz_display(&mut emu, HzSpeed(30, 5), 3, -3, Dir::Right);
46+
// -2 entry delay
47+
util::run_n_vblanks(&mut emu, 12+10-2);
48+
run_input_string(&mut emu, "LLL..L.L...L.");
49+
assert_hz_display(&mut emu, HzSpeed(20, 3), 3, -2, Dir::Left);
50+
// -1 entry delay
51+
util::run_n_vblanks(&mut emu, 7+12-1);
52+
run_input_string(&mut emu, "RR...R...R...R.R.");
53+
assert_hz_display(&mut emu, HzSpeed(18, 3), 4, -1, Dir::Right);
54+
// -4 entry delay shouldn't show up
55+
util::run_n_vblanks(&mut emu, 2+12-4);
56+
run_input_string(&mut emu, "L.....");
57+
assert_hz_display(&mut emu, HzSpeed(18, 3), 4, -1, Dir::Right);
58+
}
59+
60+
fn test_tspin() {
61+
let mut emu = util::emulator(None);
62+
63+
for _ in 0..4 {
64+
emu.run_until_vblank();
65+
}
66+
67+
let practise_type = labels::get("practiseType") as usize;
68+
let hz_flag = labels::get("hzFlag") as usize;
69+
let game_mode = labels::get("gameMode") as usize;
70+
let main_loop = labels::get("mainLoop");
71+
let level_number = labels::get("levelNumber") as usize;
72+
73+
// set to tspin mode
74+
emu.memory.iram_raw[practise_type] = labels::get("MODE_TSPINS") as _;
75+
// turn on hz display
76+
emu.memory.iram_raw[hz_flag] = 1;
77+
// trick game into thinking it should start an a-type run
78+
emu.memory.iram_raw[level_number] = 29;
79+
emu.memory.iram_raw[game_mode] = 4;
80+
emu.registers.pc = main_loop;
81+
82+
// wait for piece to become active
83+
util::run_n_vblanks(&mut emu, 9);
84+
run_input_string(&mut emu, "DRB");
85+
util::run_n_vblanks(&mut emu, 14);
86+
// lock first tspin
87+
run_input_string(&mut emu, "A");
88+
util::run_n_vblanks(&mut emu, 43);
89+
run_input_string(&mut emu, "LLLL.");
90+
assert_hz_display(&mut emu, HzSpeed(0, 0), 1, -3, Dir::Right);
4291
}
4392

4493
// note:

tests/src/input.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(unused)]
2-
pub const DOWN: u8 = 4u8;
3-
pub const UP: u8 = 8u8;
4-
pub const RIGHT: u8 = 1u8;
5-
pub const LEFT: u8 = 2u8;
6-
pub const B: u8 = 40u8;
7-
pub const A: u8 = 80u8;
8-
pub const SELECT: u8 = 20u8;
9-
pub const START: u8 = 10u8;
2+
pub const DOWN: u8 = 0x4u8;
3+
pub const UP: u8 = 0x8u8;
4+
pub const RIGHT: u8 = 0x1u8;
5+
pub const LEFT: u8 = 0x2u8;
6+
pub const B: u8 = 0x40u8;
7+
pub const A: u8 = 0x80u8;
8+
pub const SELECT: u8 = 0x20u8;
9+
pub const START: u8 = 0x10u8;

0 commit comments

Comments
 (0)