Skip to content

Commit b2fc0aa

Browse files
Merge pull request #105 from zohassadar/linecap_check
linecap floor logic occurs when levelups possible
2 parents 68f5c8f + 3141007 commit b2fc0aa

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

src/modes/floor.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ drawFloor:
99
; x10
1010
lda multBy10Table, x
1111
tax
12-
; draw block tiles ($7B)
13-
lda #BLOCK_TILES
12+
; draw block tiles+3 ($7E)
13+
lda #BLOCK_TILES+3
1414
@loop:
1515
sta playfield+$46,X
1616
inx

src/playstate/completedrows.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ playState_checkForCompletedRows:
102102
tax
103103
ldy multBy10Table,x
104104
ldx #$0A
105-
lda #BLOCK_TILES
105+
lda #BLOCK_TILES+3
106106
@drawFloorSurface:
107107
sta playfield,y
108108
iny

src/playstate/updatestats.asm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
; y reg tracks lines crossing multiple of 10 from @linesCleared until addPoints
2+
13
playState_updateLinesAndStatistics:
24
jsr updateMusicSpeed
35
lda completedLines
46
bne @linesCleared
57
jmp addPoints
68

79
@linesCleared:
10+
ldy #$00
811
tax
912
dec lineClearStatsByType-1,x
1013
bpl @noCarry
@@ -75,6 +78,7 @@ checkLevelUp:
7578
and #$0F
7679
bne @lineLoop
7780

81+
iny ; used by floorcap check below
7882
lda practiseType
7983
cmp #MODE_TAPQTY
8084
beq @lineLoop
@@ -115,7 +119,7 @@ checkLevelUp:
115119
lda crashState
116120
ora #$08
117121
sta crashState
118-
lda #$06 ; checked in floor linecap stuff, just below
122+
lda #$06
119123
sta soundEffectSlot1Init
120124
lda renderFlags
121125
ora #RENDER_LEVEL
@@ -167,10 +171,9 @@ checkLinecap: ; set linecapState
167171
lda linecapState
168172
cmp #LINECAP_FLOOR
169173
bne @floorLinecapEnd
170-
; check level up sound is happening
171-
lda soundEffectSlot1Init
172-
cmp #6
173-
bne @floorLinecapEnd
174+
; check level up was possible
175+
tya
176+
beq @floorLinecapEnd
174177
lda #$A
175178
sta garbageHole
176179
lda #1

tests/src/floor.rs

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

33
pub fn test() {
44
test_floor();
5-
test_floor_linecap();
5+
test_floor_linecap("MODE_TRANSITION",0);
6+
test_floor_linecap("MODE_TETRIS",1);
67
test_floor0();
78
}
89

@@ -54,7 +55,7 @@ fn test_floor() {
5455
assert_ne!(playfield::get(&mut emu, 0, 19), 0xEF);
5556
}
5657

57-
fn test_floor_linecap() {
58+
fn test_floor_linecap(mode: &str, linecap_when: u8) {
5859
let mut emu = util::emulator(None);
5960

6061
for _ in 0..3 { emu.run_until_vblank(); }
@@ -64,12 +65,15 @@ fn test_floor_linecap() {
6465
let main_loop = labels::get("mainLoop");
6566
let level_number = labels::get("levelNumber") as usize;
6667

67-
emu.memory.iram_raw[practise_type] = labels::get("MODE_TRANSITION") as _;
68+
emu.memory.iram_raw[practise_type] = labels::get(mode) as _;
6869
emu.memory.iram_raw[level_number] = 19;
6970
emu.memory.iram_raw[game_mode] = 4;
7071

7172
emu.memory.iram_raw[labels::get("linecapFlag") as usize] = 1;
73+
emu.memory.iram_raw[labels::get("linecapWhen") as usize] = linecap_when;
7274
emu.memory.iram_raw[labels::get("linecapHow") as usize] = labels::get("LINECAP_FLOOR") as u8 - 1;
75+
emu.memory.iram_raw[labels::get("linecapLines") as usize] = 0x10;
76+
emu.memory.iram_raw[labels::get("linecapLines") as usize + 1] = 0;
7377
emu.memory.iram_raw[labels::get("linecapLevel") as usize] = 20;
7478

7579
emu.registers.pc = main_loop;

0 commit comments

Comments
 (0)