Skip to content

Commit a34f09f

Browse files
committed
fix hz display for L+U or R+D etc
1 parent 66fb5d1 commit a34f09f

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Block Tool pieces wrap around
1515
* Always Next Box removed
1616
* 0001 seeds are ignored
17+
* Hz display correctly counts taps with Up and Down
18+
* Keep Hz display enabled when topped out
1719
* Floor no longer gobbled up by top line clear
1820
* Floor 0 has original no-burns behaviour again
1921
* [Fixed ingame score display at 8/9 million with Classic Scoring](https://www.youtube.com/watch?v=fYdXky2i5AE)
@@ -24,7 +26,6 @@
2426
* Fixed crashes in garbage mode 4
2527
* Fixed line clearing happening on pause
2628
* Fixed PAL colours
27-
* Keep hz display enabled when topped out
2829
* Famicom Keyboard support
2930
* Autodetect MMC1/CNROM
3031
* NROM Support

src/modes/hz.asm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ hzControl: ; called in playState_playerControlsActiveTetrimino, gameTypeLoopCont
3737

3838
; detect inputs
3939
lda newlyPressedButtons_player1
40-
and #BUTTON_DPAD
40+
and #BUTTON_LEFT+BUTTON_RIGHT
4141
cmp #BUTTON_LEFT
4242
beq hzTap
43-
lda newlyPressedButtons_player1
44-
and #BUTTON_DPAD
43+
and #BUTTON_LEFT+BUTTON_RIGHT
4544
cmp #BUTTON_RIGHT
4645
beq hzTap
4746

@@ -193,11 +192,11 @@ checkNegativeDelay:
193192
lda hzSpawnDelay
194193
bne @ret
195194
lda newlyPressedButtons_player1
196-
and #BUTTON_DPAD
195+
and #BUTTON_LEFT+BUTTON_RIGHT
197196
cmp #BUTTON_LEFT
198197
beq @setDelay
199198
lda newlyPressedButtons_player1
200-
and #BUTTON_DPAD
199+
and #BUTTON_LEFT+BUTTON_RIGHT
201200
cmp #BUTTON_RIGHT
202201
beq @setDelay
203202
rts

tests/src/hz_display.rs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,30 @@ pub fn test() {
77
}
88

99
fn test_standard() {
10-
let mut emu = util::emulator(None);
10+
let boot = || {
11+
let mut emu = util::emulator(None);
1112

12-
util::run_n_vblanks(&mut emu, 4);
13+
util::run_n_vblanks(&mut emu, 4);
1314

14-
let hz_flag = labels::get("hzFlag") as usize;
15-
let game_mode = labels::get("gameMode") as usize;
16-
let main_loop = labels::get("mainLoop");
17-
let level_number = labels::get("levelNumber") as usize;
15+
let hz_flag = labels::get("hzFlag") as usize;
16+
let game_mode = labels::get("gameMode") as usize;
17+
let main_loop = labels::get("mainLoop");
18+
let level_number = labels::get("levelNumber") as usize;
1819

19-
// turn on hz display
20-
emu.memory.iram_raw[hz_flag] = 1;
21-
// trick game into thinking it should start an a-type run
22-
emu.memory.iram_raw[level_number] = 29;
23-
emu.memory.iram_raw[game_mode] = 4;
24-
emu.registers.pc = main_loop;
20+
// turn on hz display
21+
emu.memory.iram_raw[hz_flag] = 1;
22+
// trick game into thinking it should start an a-type run
23+
emu.memory.iram_raw[level_number] = 29;
24+
emu.memory.iram_raw[game_mode] = 4;
25+
emu.registers.pc = main_loop;
2526

26-
// wait for piece to become active
27-
util::run_n_vblanks(&mut emu, 5);
27+
// wait for piece to become active
28+
util::run_n_vblanks(&mut emu, 5);
29+
30+
emu
31+
};
32+
33+
let mut emu = boot();
2834
// test left input sequence with delay of 5
2935
run_input_string(&mut emu, ".....L.L..L.L.");
3036
assert_hz_display(&mut emu, HzSpeed(25, 75), 4, 5, Dir::Left);
@@ -53,6 +59,21 @@ fn test_standard() {
5359
util::run_n_vblanks(&mut emu, 2+12-4);
5460
run_input_string(&mut emu, "L.....");
5561
assert_hz_display(&mut emu, HzSpeed(18, 3), 4, -1, Dir::Right);
62+
63+
// check L+U etc is counted as a tap
64+
let mut emu = boot();
65+
{
66+
use crate::input::*;
67+
run_input_string(&mut emu, "LB.L.LL.");
68+
util::set_controller_raw(&mut emu, LEFT + UP);
69+
emu.run_until_vblank();
70+
emu.run_until_vblank();
71+
run_input_string(&mut emu, ".");
72+
util::set_controller_raw(&mut emu, LEFT + UP);
73+
emu.run_until_vblank();
74+
emu.run_until_vblank();
75+
}
76+
assert_hz_display(&mut emu, HzSpeed(21, 85), 5, 0, Dir::Left);
5677
}
5778

5879
fn test_tspin() {

0 commit comments

Comments
 (0)