Skip to content

Commit 3748cd0

Browse files
committed
implemented confetti, lag frames, bad lines/level updates
1 parent 0ccaa38 commit 3748cd0

File tree

5 files changed

+164
-17
lines changed

5 files changed

+164
-17
lines changed

src/nmi/nmi.asm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ nmi: pha
2727
lda #$01
2828
sta verticalBlankingInterval
2929
jsr pollControllerButtons
30+
lda #$00
31+
sta lagFlag ; clear flag after lag frame achieved
3032
.if KEYBOARD
3133
; Read Family BASIC Keyboard
3234
jsr pollKeyboard

src/nmi/render_mode_play_and_demo.asm

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ render_mode_play_and_demo:
1919
lda outOfDateRenderFlags
2020
and #$01
2121
beq @renderLevel
22-
22+
23+
ldx #lines_old-lines
24+
lda lagFlag
25+
and #$02
26+
bne @doLinesRender
27+
ldx #$00
28+
@doLinesRender:
2329
lda #$20
2430
sta PPUADDR
2531
lda #$73
2632
sta PPUADDR
27-
lda lines+1
33+
lda lines+1,x
2834
sta PPUDATA
29-
lda lines
35+
lda lines,x
3036
jsr twoDigsToPPU
3137
jmp @doneRenderingLines
3238

@@ -54,7 +60,13 @@ render_mode_play_and_demo:
5460
sta PPUADDR
5561
lda #$B9
5662
sta PPUADDR
57-
lda levelNumber
63+
ldx #level_old-levelNumber
64+
lda lagFlag
65+
and #$01
66+
bne @doLevelRender
67+
ldx #$00
68+
@doLevelRender:
69+
lda levelNumber,x
5870
jsr renderByteBCD
5971
jmp @renderLevelEnd
6072

@@ -300,7 +312,13 @@ rightColumns:
300312
.byte $05,$06,$07,$08,$09
301313
; Set Background palette 2 and Sprite palette 2
302314
updatePaletteForLevel:
303-
lda levelNumber
315+
ldx #level_old-levelNumber
316+
lda lagFlag
317+
and #$01
318+
bne @loadLevelNumber
319+
ldx #$00
320+
@loadLevelNumber:
321+
lda levelNumber,x
304322
@mod10: cmp #$0A
305323
bmi @copyPalettes ; bcc fixes the colour bug
306324
sec

src/playstate/updatestats.asm

Lines changed: 131 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ playState_updateLinesAndStatistics:
5353
@notTypeB:
5454

5555
ldx completedLines
56+
lda lines
57+
sta lines_old
58+
lda lines+1
59+
sta lines_old+1
5660
incrementLines:
5761
inc lines
5862
lda lines
5963
and #$0F
6064
cmp #$0A
6165
bmi checkLevelUp
62-
lda crashFlag
63-
ora #$01
64-
sta crashFlag
66+
inc crashFlag
6567
lda lines
6668
clc
6769
adc #$06
@@ -112,6 +114,8 @@ checkLevelUp:
112114
bpl @lineLoop
113115

114116
@nextLevel:
117+
lda levelNumber
118+
sta level_old
115119
inc levelNumber
116120
lda crashFlag
117121
ora #$08
@@ -688,6 +692,11 @@ testCrash:
688692
adc #$00
689693
sta cycleCount
690694
;crash should occur on cycle count results 29739-29744, 29750-29768 = $742B-7430, $7436-7448
695+
;confettiA should occur on cycle count when switch1 = 29768+75 = 29843-30192
696+
;level lag is +195 from line lag
697+
;level lag to RTS is +70 rts +6 jsr +6 +41 to beginning of confettiA = 123 = 30315+ line lag
698+
;line lag = 30510+
699+
;confettiB = 30765-31193
691700
cmp #$74 ;high byte of cycle count is already loaded
692701
bne @nextSwitch
693702
lda cycleCount+1
@@ -697,26 +706,104 @@ testCrash:
697706
bcs @continue
698707
lda #$F0
699708
sta crashFlag
700-
bne @crashGraphics
709+
jmp @crashGraphics
701710
@continue:
702711
cmp #$36
703712
bcc @nextSwitch
704713
cmp #$49
705714
bcs @nextSwitch
706715
lda #$F0
707716
sta crashFlag
708-
bne @crashGraphics
717+
jmp @crashGraphics
709718

710719
@nextSwitch:
711720
lda switchTable-2,x ; adding cycles to advance to next switch routine
712721
sta allegroIndex
713722
dex
714-
bne @loop
715-
723+
bne @loop
724+
;562 has been added to the cycle count
725+
;confettiA at 30405-30754 76C5-7822
726+
lda displayNextPiece
727+
beq @nextOn
728+
lda cycleCount+1 ; add 394 cycles for nextbox if not added earlier
729+
adc #$8A
730+
sta cycleCount+1
731+
lda cycleCount
732+
adc #$01 ; high byte of 18A
733+
sta cycleCount
734+
bne @nextCheck
735+
@nextOn:
736+
lda cycleCount
737+
cmp #$76
738+
bcc @allegroClear
739+
bne @not76
740+
lda cycleCount+1
741+
cmp #$C5
742+
bcc @allegroClear
743+
bcs @confettiA
744+
@not76: cmp #$78
745+
bcc @confettiA
746+
bne @nextCheck
747+
lda cycleCount+1
748+
cmp #$23
749+
bcs @nextCheck
750+
@confettiA:
751+
lda #$E0
752+
sta crashFlag
753+
jmp confettiHandler
754+
@nextCheck:
755+
;levellag at 30877 789D
756+
lda cycleCount
757+
cmp #$78
758+
bcc @allegroClear
759+
bne @levelLag
760+
lda cycleCount+1
761+
cmp #$9D
762+
bcc @allegroClear
763+
@levelLag:
764+
lda #$01
765+
sta lagFlag
766+
;linelag at 31072 7960
767+
lda cycleCount
768+
cmp #$79
769+
bcc @allegroClear
770+
bne @lineLag
771+
lda cycleCount+1
772+
cmp #$60
773+
bcc @allegroClear
774+
@lineLag:
775+
lda #$03
776+
sta lagFlag
777+
;confettiB at 31327-31755 7A5F-7C0B
778+
lda cycleCount
779+
cmp #$7A
780+
bcc @allegroClear
781+
bne @not7A
782+
lda cycleCount+1
783+
cmp #$5F
784+
bcc @allegroClear
785+
bcs @confettiB
786+
@not7A: cmp #$7C
787+
bcc @confettiB
788+
bne @allegroClear
789+
lda cycleCount+1
790+
cmp #$0C
791+
bcs @allegroClear
792+
@confettiB:
793+
lda #$D0
794+
sta crashFlag
795+
jmp confettiHandler
716796
@allegroClear:
717797
lda #$00
718798
sta allegroIndex
719-
rts
799+
lda lagFlag
800+
beq @noLag
801+
lda #$00
802+
sta verticalBlankingInterval
803+
@checkForNmi:
804+
lda verticalBlankingInterval
805+
beq @checkForNmi
806+
@noLag: rts
720807
@crashGraphics:
721808
lda #$00
722809
sta allegroIndex
@@ -742,4 +829,39 @@ factorTable:
742829
sumTable:
743830
.byte $E1, $1C, $38, $54, $80 ; tetris is 4*28+16 = 128
744831
switchTable:
745-
.byte $3C, $77, $3C, $65, $3C, $66, $3C;60 119 60 101 60 102 60 gets read in reverse
832+
.byte $3C, $77, $3C, $65, $3C, $66, $3C;60 119 60 101 60 102 60 gets read in reverse
833+
confettiHandler:
834+
lda crashFlag ;E0 = confetti exits if [framecounter = 255 && controller != BDLR] or controller = AS
835+
cmp #$E0
836+
bne @infiniteConfetti
837+
lda heldButtons_player1
838+
and #$A0 ; A, Select
839+
bne @endConfetti
840+
lda frameCounter
841+
cmp #$FF
842+
bne @drawConfetti
843+
lda heldButtons_player1
844+
and #$47 ; B, Down, Left, Right
845+
beq @endConfetti
846+
@drawConfetti:
847+
sta spriteYOffset
848+
lda #$A8
849+
sta spriteXOffset
850+
lda #$19
851+
sta spriteIndexInOamContentLookup
852+
jsr stringSpriteAlignRight
853+
lda #$00
854+
sta verticalBlankingInterval
855+
@checkForNmi:
856+
lda verticalBlankingInterval
857+
beq @checkForNmi
858+
jmp confettiHandler
859+
@infiniteConfetti:
860+
lda heldButtons_player1
861+
adc #$80
862+
cmp #$80
863+
beq @drawConfetti
864+
@endConfetti:
865+
lda #$00
866+
sta allegroIndex
867+
rts

src/ram.asm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pointerAddrB: .res 2 ; $001D ; used in harddrop
2323
allegroIndex: .res 1 ; $001F for crash
2424
wasAllegro: .res 1 ; $0020 for crash
2525
startParity: .res 1 ; $0021 for crash
26-
.res $11
26+
lagFlag: .res 1 ; $0022 for lagged lines & score
27+
.res $10
2728

2829
verticalBlankingInterval: .res 1 ; $0033
2930
set_seed: .res 3 ; $0034 ; rng_seed, rng_seed+1, spawnCount
@@ -55,7 +56,8 @@ garbageHole: .res 1 ; $0059 ; Position of hole in receive
5556
garbageDelay: .res 1 ; $005A
5657
pieceTileModifier: .res 1 ; $005B ; above $80 - use a single one, below - use an offset
5758
curtainRow: .res 1 ; $5C
58-
.res 3
59+
lines_old: .res 2 ; $5D-E ; used for delayed draw at high levels
60+
level_old: .res 1 ; $5F
5961

6062
mathRAM: .res $12
6163
binary32 := mathRAM+$0

src/util/strings.asm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ stringLookup:
9595
.byte stringShown-stringLookup ;16
9696
.byte stringTopout-stringLookup
9797
.byte stringCrash-stringLookup
98+
.byte stringConfetti-stringLookup ;19
9899
stringClassic:
99100
.byte $7,'C','L','A','S','S','I','C'
100101
stringLetters:
@@ -146,4 +147,6 @@ stringShown:
146147
stringTopout:
147148
.byte $6,'T','O','P','O','U','T'
148149
stringCrash:
149-
.byte $5,'C','R','A','S','H'
150+
.byte $5,'C','R','A','S','H'
151+
stringConfetti:
152+
.byte $8,'C','O','N','F','E','T','T','I'

0 commit comments

Comments
 (0)