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:
4441crunchReturn:
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)
5644advanceSides:
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
0 commit comments