Skip to content

Commit 9312571

Browse files
committed
remove ram dependency
1 parent 062f5aa commit 9312571

File tree

4 files changed

+39
-28
lines changed

4 files changed

+39
-28
lines changed

src/modes/crunch.asm

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,22 @@
1616
; E - 3 left 2 right
1717
; F - 3 left 3 right
1818

19-
advanceGameCrunch:
20-
; initialize vars
21-
lda crunchModifier
22-
lsr
23-
lsr
24-
sta crunchLeftColumns
25-
lda crunchModifier
26-
and #$03
27-
clc
28-
adc crunchLeftColumns ; carry still clear
29-
eor #$FF
30-
adc #$0B ; 10 + 1 to get two's complement. result is playable column count
31-
sta crunchClearColumns
19+
; defined in playstate/completedrows.asm:
20+
; crunchLeftColumns = generalCounter3
21+
; crunchClearColumns = generalCounter4
3222

23+
advanceGameCrunch:
24+
; populate vars
25+
jsr unpackCrunchModifier
3326
; initialize playfield row 19 to 0
3427
lda #$13
3528
sta generalCounter
3629
@nextRow:
37-
jsr advanceSidesInit
30+
ldy generalCounter
31+
lda multBy10Table,y
32+
; playfieldAddr ends restored to 0 as top row is done last
33+
sta playfieldAddr
34+
jsr advanceSidesContinue
3835
dec generalCounter
3936
bpl @nextRow
4037

@@ -44,16 +41,13 @@ advanceGameCrunch:
4441
crunchReturn:
4542
rts
4643

47-
; for init only. row determined by generalCounter
48-
; playfieldAddr ends restored to 0 as top row is done last
49-
advanceSidesInit:
50-
ldy generalCounter
51-
lda multBy10Table,y
52-
sta playfieldAddr
53-
54-
; after init, only top row is drawn. using (playfieldAddr),y defaults to top row
55-
; as playfieldAddr is 0 when this is called (and most of the time)
5644
advanceSides:
45+
; called in playState_checkForCompletedRows
46+
; after init, only top row is drawn. using (playfieldAddr),y defaults to top row
47+
; as playfieldAddr is 0 when this is called (and most of the time)
48+
jsr unpackCrunchModifier
49+
50+
advanceSidesContinue:
5751
ldy #$00
5852
lda #BLOCK_TILES
5953

@@ -80,3 +74,18 @@ advanceSides:
8074
sta (playfieldAddr),y
8175
iny
8276
bne @rightLoop ; unconditional
77+
78+
unpackCrunchModifier:
79+
; initialize vars
80+
lda crunchModifier
81+
lsr
82+
lsr
83+
sta crunchLeftColumns ; generalCounter3
84+
lda crunchModifier
85+
and #$03
86+
clc
87+
adc crunchLeftColumns ; carry still clear
88+
eor #$FF
89+
adc #$0B ; 10 + 1 to get two's complement. result is playable column count
90+
sta crunchClearColumns ; generalCounter4
91+
rts

src/playstate/completedrows.asm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
crunchLeftColumns := generalCounter3
2+
crunchClearColumns := generalCounter4
13
activeFloorMode := generalCounter5
24

35
playState_checkForCompletedRows:

src/playstate/util.asm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ updateMusicSpeed:
8888
bne @notCrunch
8989

9090
; start at first clear column and repeat only for playable columns
91+
jsr unpackCrunchModifier
92+
tya
9193
clc
92-
adc crunchLeftColumns ; accumulator is still 50, offset with left columns
94+
adc crunchLeftColumns ; offset y with left column count (generalCounter3)
9395
tay
94-
ldx crunchClearColumns
96+
ldx crunchClearColumns ; generalCounter4
9597
bne @checkForBlockInRow ; unconditional, expected range 4 - 10
9698

9799
@notCrunch:

src/ram.asm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,8 @@ dasOnlyShiftDisabled: .res 1 ; $63A
220220
invisibleFlag: .res 1 ; $63B ; 0 for normal mode, non-zero for Invisible playfield rendering. Reset on game init and game over.
221221
currentFloor: .res 1 ; $63C floorModifier is copied here at game init. Set to 0 otherwise and incremented when linecap floor.
222222
mapperId: .res 1 ; $63D ; For INES_MAPPER 1000 (autodetect). 0 = CNROM. 1 = MMC1.
223-
crunchLeftColumns: .res 1
224-
crunchClearColumns: .res 1 ; playable column count
225223

226-
.res $35
224+
.res $37
227225

228226
.if KEYBOARD
229227
newlyPressedKeys: .res 1 ; $0675

0 commit comments

Comments
 (0)