Skip to content

Commit

Permalink
twoplayer: Fix allegro fighting and resume music after death
Browse files Browse the repository at this point in the history
  • Loading branch information
ejona86 committed Oct 10, 2019
1 parent a754a69 commit f90a571
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 7 deletions.
65 changes: 60 additions & 5 deletions twoplayer-tetris-PRG.s.diff
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,25 @@
tetriminoTypeFromOrientation:
.byte $00,$00,$00,$00,$01,$01,$01,$01
.byte $02,$02,$03,$04,$04,$05,$05,$05
@@ -3128,11 +3190,12 @@ @ret: rts
@@ -3028,12 +3090,15 @@ @checkForStartButton:
lda newlyPressedButtons_player1
cmp #$10
bne @ret2
@exitGame:
lda #$00
- sta playState
- sta newlyPressedButtons_player1
+ ;sta playState
+ ;sta newlyPressedButtons_player1
+ .import playState_updateGameOverCurtain_curtainFinished_mod
+ jsr playState_updateGameOverCurtain_curtainFinished_mod
+ nop
@ret2: rts

playState_checkForCompletedRows:
lda vramRow
cmp #$20
@@ -3128,11 +3193,12 @@ @ret: rts

playState_receiveGarbage:
lda numberOfPlayers
Expand All @@ -590,7 +608,7 @@
cmp #$20
bmi L9B52
lda multBy10Table,y
@@ -3154,11 +3217,11 @@ L9B31: cpx garbageHole
@@ -3154,11 +3220,11 @@ L9B31: cpx garbageHole
beq @garbageEmptySpace
lda #$78
jmp @placeGarbage
Expand All @@ -603,7 +621,7 @@
inx
cpx #$0A
bne L9B45
@@ -3389,11 +3452,12 @@ gameModeState_handleGameOver:
@@ -3389,11 +3455,12 @@ gameModeState_handleGameOver:
sta generalCounter2
lda player2_playState
cmp #$00
Expand All @@ -617,7 +635,44 @@
lda #$09
sta gameModeState
rts
@@ -3823,11 +3887,11 @@ L9FE9: ldy #$00
@@ -3438,23 +3505,31 @@ @checkForBlockInRow:
bne @foundBlockInRow
iny
dex
bne @checkForBlockInRow
lda allegro
- beq @ret
- lda #$00
- sta allegro
+ ;beq @ret
+ ;lda #$00
+ ;sta allegro
+ .import updateMusicSpeed_noBlockInRow_mod
+ jsr updateMusicSpeed_noBlockInRow_mod
+ bne @ret
+ nop
ldx musicType
lda musicSelectionTable,x
jsr setMusicTrack
jmp @ret

@foundBlockInRow:
lda allegro
+ ;bne @ret
+ ;lda #$FF
+ ;sta allegro
+ .import updateMusicSpeed_foundBlockInRow_mod
+ jsr updateMusicSpeed_foundBlockInRow_mod
bne @ret
- lda #$FF
- sta allegro
+ nop
lda musicType
clc
adc #$04
tax
lda musicSelectionTable,x
@@ -3823,11 +3898,11 @@ L9FE9: ldy #$00
sty PPUSCROLL
sty PPUSCROLL
rts
Expand All @@ -630,7 +685,7 @@
jmp LA085

L9FFB: jsr bulkCopyToPpu
@@ -6204,17 +6268,17 @@ dmc1: .byte $6D,$6E,$6F,$5F,$3C,$33,
@@ -6204,17 +6279,17 @@ dmc1: .byte $6D,$6E,$6F,$5F,$3C,$33,
.byte $87,$78,$84,$7A,$77,$87,$78,$84
.byte $7A,$67,$87,$77,$87,$77,$72,$83
.byte $80,$81,$77,$67,$82,$79,$7A,$67
Expand Down
69 changes: 67 additions & 2 deletions twoplayer.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
; "current player" as the palette value.

; TODO:
; Music speed fights between whoever locked the last piece
; Save another RNG to let the behind player catch up.
; Handle end-game. If one player dies, if the player behind in score is still playing, they can keep playing. Unclear if score should be the only way. People may care about lines, or some other such. Need to think about it more. If let both players go to end, then may want to let 2nd player enter high score
; Fix background tetrimino pattern
Expand Down Expand Up @@ -559,7 +558,6 @@ gameModeState_handleGameOver_mod:
@twoPlayers:
lda player1_playState
ora player2_playState
cmp #$00
beq @gameOver
; put known data in a, to avoid it from matching "cmp gameModeState" in
; @mainLoop. In 1 player mode, numberOfPlayers will be in a.
Expand All @@ -569,3 +567,70 @@ gameModeState_handleGameOver_mod:

@gameOver:
jmp gameModeState_handleGameOver


updateMusicSpeed_noBlockInRow_mod:
.export updateMusicSpeed_noBlockInRow_mod
tax
and activePlayer
eor allegro
sta allegro
txa
cmp activePlayer
rts

updateMusicSpeed_foundBlockInRow_mod:
.export updateMusicSpeed_foundBlockInRow_mod
tax
ora activePlayer
sta allegro
txa
cmp #$00
rts

playState_updateGameOverCurtain_curtainFinished_mod:
.export playState_updateGameOverCurtain_curtainFinished_mod
sta playState
sta newlyPressedButtons_player1

lda numberOfPlayers
cmp #$02
bne @ret

; playState has not yet been copied to player*_playState
lda activePlayer
cmp #$01
bne @playerTwoActive
lda player2_playState
beq @ret
bne @resumeMusic
@playerTwoActive:
lda player1_playState
beq @ret

@resumeMusic:
jsr updateMusicSpeed_playerDied

@ret:
rts

updateMusicSpeed_playerDied:
lda allegro
and activePlayer
eor allegro
sta allegro
bne @fast

ldx musicType
lda musicSelectionTable,x
jsr setMusicTrack
rts

@fast:
lda musicType
clc
adc #$04
tax
lda musicSelectionTable,x
jsr setMusicTrack
rts

0 comments on commit f90a571

Please sign in to comment.