Skip to content

Commit 328fbdc

Browse files
committed
faster oam reset
1 parent 1f25585 commit 328fbdc

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/gamemodestate/pause.asm

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ pause:
3838

3939
@pauseSetupPart2:
4040
jsr updateAudioAndWaitForNmi
41-
lda #$FF
42-
ldx #$02
43-
ldy #$02
44-
jsr memset_page
41+
jsr resetOAMStaging
4542

4643
@pauseLoop:
4744
lda qualFlag

src/util/core.asm

100644100755
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ random10:
5050
bpl random10
5151
rts
5252

53+
resetOAMStaging:
54+
; Hide a sprite by moving it down offscreen, by writing any values between #$EF-#$FF here.
55+
; Sprites are never displayed on the first line of the picture, and it is impossible to place
56+
; a sprite partially off the top of the screen.
57+
; https://www.nesdev.org/wiki/PPU_OAM
58+
ldx #$00
59+
lda #$FF
60+
@hideY:
61+
sta oamStaging,x
62+
inx
63+
inx
64+
inx
65+
inx
66+
bne @hideY
67+
rts
68+
69+
5370
; canon is waitForVerticalBlankingInterval
5471
updateAudioWaitForNmiAndResetOamStaging:
5572
jsr updateAudio_jmp
@@ -59,10 +76,7 @@ updateAudioWaitForNmiAndResetOamStaging:
5976
@checkForNmi:
6077
lda verticalBlankingInterval
6178
beq @checkForNmi
62-
lda #$FF
63-
ldx #$02
64-
ldy #$02
65-
jsr memset_page
79+
jsr resetOAMStaging
6680
rts
6781

6882
updateAudioAndWaitForNmi:

0 commit comments

Comments
 (0)