Skip to content

Commit

Permalink
twoplayer: Avoid shifting large amounts of code in render_mode_play_a…
Browse files Browse the repository at this point in the history
…nd_demo

This avoids collisions with taus where it modifies the stats rendering.

Unfortunately, this adds 6 cycles to rendering, which will probably
exceed our budget at higher play levels. I don't want to deal with that
at the moment; I don't think anyone will notice, and it really deserves
a test anyway.
  • Loading branch information
ejona86 committed Apr 26, 2020
1 parent 0e32721 commit dd82293
Showing 1 changed file with 38 additions and 36 deletions.
74 changes: 38 additions & 36 deletions twoplayer-tetris-PRG.s.diff
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
.byte $00,$7B,$02,$00,$00,$7B,$02,$08
.byte $08,$7B,$02,$00,$08,$7B,$02,$08
.byte $FF
@@ -2369,20 +2452,38 @@ render_mode_play_and_demo:
@@ -2369,20 +2452,42 @@ render_mode_play_and_demo:
lda #$00
sta player1_vramRow
jmp @renderPlayer2Playfield
Expand Down Expand Up @@ -407,13 +407,17 @@
+ .import copyPlayfieldRowToVRAM4
+ jsr copyPlayfieldRowToVRAM4
+ stx player1_vramRow
+ jmp @renderPlayer2Playfield
+ .repeat 12
+ nop
+ .endrepeat
+.endif
@renderPlayer2Playfield:
lda numberOfPlayers
cmp #$02
bne @renderLines
lda player2_playState
@@ -2410,20 +2511,34 @@ @renderPlayer2Playfield:
@@ -2410,20 +2515,38 @@ @renderPlayer2Playfield:
lda #$00
sta player2_vramRow
jmp @renderLines
Expand Down Expand Up @@ -442,13 +446,17 @@
+ lda #$01
+ jsr copyPlayfieldRowToVRAM4
+ stx player2_vramRow
+ jmp @renderLines
+ .repeat 12
+ nop
+ .endrepeat
+.endif
@renderLines:
lda outOfDateRenderFlags
and #$01
beq @renderLevel
lda numberOfPlayers
@@ -2441,36 +2556,36 @@ @renderLines:
@@ -2441,36 +2564,36 @@ @renderLines:
and #$FE
sta outOfDateRenderFlags
jmp @renderLevel
Expand Down Expand Up @@ -492,7 +500,7 @@
sta generalCounter
lda #$22
sta PPUADDR
@@ -2481,12 +2596,17 @@ @renderLevel:
@@ -2481,12 +2604,17 @@ @renderLevel:
jsr updatePaletteForLevel
lda outOfDateRenderFlags
and #$FD
Expand All @@ -512,7 +520,7 @@
and #$04
beq @renderStats
lda #$21
@@ -2534,13 +2654,14 @@ @renderTetrisFlashAndSound:
@@ -2534,13 +2662,14 @@ @renderTetrisFlashAndSound:
lda #$3F
sta PPUADDR
lda #$0E
Expand All @@ -530,7 +538,7 @@
bne @setPaletteColor
ldx #$30
lda frameCounter
@@ -2549,17 +2670,28 @@ @renderTetrisFlashAndSound:
@@ -2549,17 +2678,22 @@ @renderTetrisFlashAndSound:
lda #$09
sta soundEffectSlot1Init
@setPaletteColor:
Expand All @@ -550,19 +558,13 @@
+ nop
+ nop
+ nop
+
+.if FASTROWTOVRAM = 2
+.repeat 2*15
+ nop
+.endrepeat
+.endif
+
pieceToPpuStatAddr:
.dbyt $2186,$21C6,$2206,$2246
.dbyt $2286,$22C6,$2306
levelDisplayTable:
.byte $00,$01,$02,$03,$04,$05,$06,$07
@@ -2569,63 +2701,74 @@ levelDisplayTable:
@@ -2569,63 +2703,74 @@ levelDisplayTable:
multBy10Table:
.byte $00,$0A,$14,$1E,$28,$32,$3C,$46
.byte $50,$5A,$64,$6E,$78,$82,$8C,$96
Expand Down Expand Up @@ -656,7 +658,7 @@
sta PPUADDR
@copyRow:
ldx #$0A
@@ -2649,15 +2792,15 @@ updateLineClearingAnimation:
@@ -2649,15 +2794,15 @@ updateLineClearingAnimation:
bne @ret
lda #$00
sta generalCounter3
Expand All @@ -676,7 +678,7 @@
cmp #$01
bne @twoPlayers
lda generalCounter
@@ -2670,22 +2813,22 @@ @twoPlayers:
@@ -2670,22 +2815,22 @@ @twoPlayers:
lda playfieldAddr+1
cmp #$04
bne @player2
Expand All @@ -703,7 +705,7 @@
ldx rowY
lda leftColumns,x
clc
@@ -2719,45 +2862,47 @@ leftColumns:
@@ -2719,45 +2864,47 @@ leftColumns:
rightColumns:
.byte $05,$06,$07,$08,$09
; Set Background palette 2 and Sprite palette 2
Expand Down Expand Up @@ -763,7 +765,7 @@
.dbyt $0F30,$2112,$0F30,$291A
.dbyt $0F30,$2414,$0F30,$2A12
.dbyt $0F30,$2B15,$0F30,$222B
@@ -2784,11 +2929,12 @@ @ret: rts
@@ -2784,11 +2931,12 @@ @ret: rts

playState_spawnNextTetrimino:
lda vramRow
Expand All @@ -777,7 +779,7 @@
lda twoPlayerPieceDelayCounter
cmp #$00
bne @twoPlayerPieceDelay
@@ -2813,79 +2959,89 @@ @notDelaying:
@@ -2813,79 +2961,89 @@ @notDelaying:
sta tetriminoY
lda #$01
sta playState
Expand Down Expand Up @@ -883,7 +885,7 @@
tetriminoTypeFromOrientation:
.byte $00,$00,$00,$00,$01,$01,$01,$01
.byte $02,$02,$03,$04,$04,$05,$05,$05
@@ -3045,12 +3201,15 @@ @checkForStartButton:
@@ -3045,12 +3203,15 @@ @checkForStartButton:
lda newlyPressedButtons_player1
cmp #$10
bne @ret2
Expand All @@ -901,7 +903,7 @@
playState_checkForCompletedRows:
lda vramRow
cmp #$20
@@ -3145,11 +3304,12 @@ @ret: rts
@@ -3145,11 +3306,12 @@ @ret: rts

playState_receiveGarbage:
lda numberOfPlayers
Expand All @@ -915,7 +917,7 @@
cmp #$20
bmi L9B52
lda multBy10Table,y
@@ -3171,11 +3331,11 @@ L9B31: cpx garbageHole
@@ -3171,11 +3333,11 @@ L9B31: cpx garbageHole
beq @garbageEmptySpace
lda #$78
jmp @placeGarbage
Expand All @@ -928,7 +930,7 @@
inx
cpx #$0A
bne L9B45
@@ -3359,26 +3519,39 @@ L9C75: lda score+2
@@ -3359,26 +3521,39 @@ L9C75: lda score+2
clc
adc #$06
sta score+2
Expand Down Expand Up @@ -969,7 +971,7 @@
.word $1200
updatePlayfield:
ldx tetriminoY
@@ -3406,11 +3579,12 @@ gameModeState_handleGameOver:
@@ -3406,11 +3581,12 @@ gameModeState_handleGameOver:
sta generalCounter2
lda player2_playState
cmp #$00
Expand All @@ -983,7 +985,7 @@
lda #$09
sta gameModeState
rts
@@ -3455,23 +3629,31 @@ @checkForBlockInRow:
@@ -3455,23 +3631,31 @@ @checkForBlockInRow:
bne @foundBlockInRow
iny
dex
Expand Down Expand Up @@ -1020,7 +1022,7 @@
adc #$04
tax
lda musicSelectionTable,x
@@ -3487,19 +3669,19 @@ pollControllerButtons:
@@ -3487,19 +3671,19 @@ pollControllerButtons:

@demoGameMode:
lda demo_recording
Expand All @@ -1044,7 +1046,7 @@
lda (demoButtonsAddr,x)
sta generalCounter
jsr demoButtonsTable_indexIncr
@@ -3840,11 +4022,11 @@ L9FE9: ldy #$00
@@ -3840,11 +4024,11 @@ L9FE9: ldy #$00
sty PPUSCROLL
sty PPUSCROLL
rts
Expand All @@ -1057,7 +1059,7 @@
jmp LA085

L9FFB: jsr bulkCopyToPpu
@@ -3937,11 +4119,11 @@ byteToBcdTable:
@@ -3937,11 +4121,11 @@ byteToBcdTable:
.byte $16,$17,$18,$19,$20,$21,$22,$23
.byte $24,$25,$26,$27,$28,$29,$30,$31
.byte $32,$33,$34,$35,$36,$37,$38,$39
Expand All @@ -1070,7 +1072,7 @@
sta highScoreEntryRawPos
lda gameType
beq @compareWithPos
@@ -3953,26 +4135,26 @@ @compareWithPos:
@@ -3953,26 +4137,26 @@ @compareWithPos:
asl a
clc
adc generalCounter2
Expand Down Expand Up @@ -1100,7 +1102,7 @@
@tooSmall:
inc highScoreEntryRawPos
lda highScoreEntryRawPos
@@ -4015,22 +4197,22 @@ @clearNameLetter:
@@ -4015,22 +4199,22 @@ @clearNameLetter:
inx
dey
bne @clearNameLetter
Expand Down Expand Up @@ -1134,7 +1136,7 @@
; reg a: start byte to copy
copyHighScoreNameToNextIndex:
sta generalCounter
@@ -4093,11 +4275,11 @@ copyHighScoreLevelToNextIndex:
@@ -4093,11 +4277,11 @@ copyHighScoreLevelToNextIndex:
tax
@xAdjustedForGameType:
lda highScoreLevels,x
Expand All @@ -1147,7 +1149,7 @@
highScoreIndexToHighScoreScoresOffset:
.byte $00,$03,$06,$09,$0C,$0F,$12,$15
highScoreEntryScreen:
@@ -4127,11 +4309,11 @@ highScoreEntryScreen:
@@ -4127,11 +4311,11 @@ highScoreEntryScreen:
adc gameType
sta PPUDATA
jsr showHighScores
Expand All @@ -1160,7 +1162,7 @@
jsr updateAudioWaitForNmiAndResetOamStaging
lda highScoreEntryRawPos
asl a
@@ -4160,20 +4342,20 @@ @renderFrame:
@@ -4160,20 +4344,20 @@ @renderFrame:
and #$03
bne @flickerStateSelected_checkForStartPressed
lda #$02
Expand All @@ -1185,7 +1187,7 @@
lda #$01
sta soundEffectSlot1Init
inc highScoreEntryNameOffsetForLetter
@@ -4181,22 +4363,22 @@ @checkForAOrRightPressed:
@@ -4181,22 +4365,22 @@ @checkForAOrRightPressed:
cmp #$06
bmi @checkForBOrLeftPressed
lda #$00
Expand All @@ -1210,7 +1212,7 @@
lda frameCounter
and #$07
bne @checkForUpPressed
@@ -4204,24 +4386,24 @@ @checkForDownPressed:
@@ -4204,24 +4388,24 @@ @checkForDownPressed:
sta soundEffectSlot1Init
lda highScoreEntryNameOffsetForRow
sta generalCounter
Expand Down Expand Up @@ -1239,7 +1241,7 @@
lda frameCounter
and #$07
bne @waitForVBlank
@@ -4308,15 +4490,15 @@ gameModeState_startButtonHandling:
@@ -4308,15 +4492,15 @@ gameModeState_startButtonHandling:

@checkIfInGame:
lda renderMode
Expand All @@ -1259,7 +1261,7 @@
lda player1_playState
cmp #$0A
bne @pause
@@ -4339,12 +4521,12 @@ @pauseLoop:
@@ -4339,12 +4523,12 @@ @pauseLoop:
lda #$77
sta spriteYOffset
lda #$05
Expand Down

0 comments on commit dd82293

Please sign in to comment.