Skip to content

Commit d4a2dc1

Browse files
committed
Optimize rng: -3 cycles -2 bytes
1 parent f06dace commit d4a2dc1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/util/core.asm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ generateNextPseudorandomNumber:
250250
lsr
251251
ror tmp1,x
252252
ror tmp2,x
253-
lda #$00
254-
adc oneThirdPRNG
255-
cmp #$03
256-
bne @not3
257-
lda #$00
258-
@not3: sta oneThirdPRNG
253+
lda oneThirdPRNG
254+
sbc #$00
255+
bpl @noReset
256+
lda #$2
257+
@noReset:
258+
sta oneThirdPRNG
259259
rts
260260

261261
; canon is initializeOAM

0 commit comments

Comments
 (0)