Skip to content

Commit

Permalink
twoplayer: Let player 2 disable next piece independently of p1
Browse files Browse the repository at this point in the history
P1 can still disable P2's next piece for Famicom compatibility.
  • Loading branch information
ejona86 committed Mar 21, 2020
1 parent fe9facc commit beb3056
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
21 changes: 21 additions & 0 deletions twoplayer-tetris-PRG.s.diff
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,27 @@
lda #$25
sta player1_lines
sta player2_lines
@@ -1363,16 +1421,16 @@ gameModeState_updateCountersAndNonPlayer
inc player1_fallTimer
inc player2_fallTimer
lda twoPlayerPieceDelayCounter
beq @checkSelectButtonPressed
inc twoPlayerPieceDelayCounter
-@checkSelectButtonPressed:
- lda newlyPressedButtons_player1
- and #$20
+@checkSelectButtonPressed: .import gameModeState_updateCountersAndNonPlayerState_mod
+ jsr gameModeState_updateCountersAndNonPlayerState_mod ; lda newlyPressedButtons_player1
+ nop ; and #$20
beq @ret
lda displayNextPiece
- eor #$01
+ eor #$03
sta displayNextPiece
@ret: inc gameModeState
rts

rotate_tetrimino:
@@ -1559,17 +1617,17 @@ stageSpriteForCurrentPiece:
lda numberOfPlayers
cmp #$01
Expand Down
17 changes: 15 additions & 2 deletions twoplayer.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
; TODO:
; Save another RNG to let the behind player catch up.
; Fix background tetrimino pattern
; Demo can be two-player if second player presses start and then the system goes idle. But demo playing is broken in 2 player
; Allow toggling on garbage?
; Allow second player to disable next piece display (minor)

; Integrations:
; Any way to fit stats on screen? Seems like there's no room.
Expand Down Expand Up @@ -402,9 +400,23 @@ copyOamStagingToOam_mod:

.segment "CODE2"

gameModeState_updateCountersAndNonPlayerState_mod:
.export gameModeState_updateCountersAndNonPlayerState_mod
lda newlyPressedButtons_player2
and #$20
beq @continue
lda displayNextPiece
eor #$02
sta displayNextPiece
@continue:
lda newlyPressedButtons_player1
and #$20
rts

stageSpriteForNextPiece_player1_mod:
.export stageSpriteForNextPiece_player1_mod
lda displayNextPiece
and #$01
bne @ret
lda numberOfPlayers
cmp #$01
Expand Down Expand Up @@ -452,6 +464,7 @@ savePlayer2State_mod:

stageSpriteForNextPiece_player2:
lda displayNextPiece
and #$02
bne @ret
lda #INGAME_LAYOUT_P2_PREVIEW_X
sta spriteXOffset
Expand Down

0 comments on commit beb3056

Please sign in to comment.