Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .export RNG1_GetByte_Masked
- .export RNG1_GetByte
- .a16
- .i16
- ;---------------------------------------------------------------------
- ; TickRNG
- ;
- ; Advances the state of both RNGs. If any buttons are held down on
- ; either joypad, the RNGs are advanced by 2 ticks. If no buttons are
- ; being held, they are advanced by 1 tick instead.
- ;---------------------------------------------------------------------
- TickRNG:
- php
- rep #$30
- lda a:$02a2
- beq @CheckJoypads
- cmp #1
- beq @CheckJoypads
- jmp @Done
- @CheckJoypads:
- lda z:joy1_held
- ora z:joy2_held
- and #$fff0
- beq @Tick2_RNG1_a
- @Tick1_RNG1_a:
- inc a:rng1index
- bne @Tick1_RNG2_a
- lda a:rng1adder
- inc
- cmp #$0100
- bcc @Tick1_RNG1_b
- lda #0
- @Tick1_RNG1_b:
- sta a:rng1adder
- @Tick1_RNG2_a:
- inc a:rng2index
- bne @Tick2_RNG1_a
- lda a:rng2adder
- inc
- cmp #$0100
- bcc @Tick1_RNG2_b
- lda #0
- @Tick1_RNG2_b:
- sta a:rng2adder
- @Tick2_RNG1_a:
- inc a:rng1index
- bne @Tick2_RNG2_a
- lda a:rng1adder
- inc
- cmp #$0100
- bcc @Tick2_RNG1_b
- lda #0
- @Tick2_RNG1_b:
- sta a:rng1adder
- @Tick2_RNG2_a:
- inc a:rng2index
- bne @Done
- lda a:rng2adder
- inc
- cmp #$0100
- bcc @Tick2_RNG2_b
- lda #0
- @Tick2_RNG2_b:
- sta a:rng2adder
- @Done:
- plp
- rtl
- RNG1_GetByte_Masked:
- jsl RNG1_GetByte
- and a:$0370
- rtl
- ;---------------------------------------------------------------------
- ; RNG1_GetByte
- ;
- ; Returns a random byte generated by RNG1.
- ;---------------------------------------------------------------------
- RNG1_GetByte:
- phx
- php
- rep #$30
- lda a:rng1index
- inc
- and #$07ff ; Mask index to prevent going past the end of the
- ; lookup table
- sta a:rng1index
- tax
- bne @RNG1_GetByte_10
- inc a:rng1adder
- @RNG1_GetByte_10:
- lda f:RNGLookupTable,x
- clc
- adc a:rng1adder
- and #$00ff
- plp
- plx
- rtl
- ;---------------------------------------------------------------------
- ; RNG2_GetByte
- ;
- ; Returns a random byte generated by RNG2.
- ;---------------------------------------------------------------------
- RNG2_GetByte:
- phx
- php
- rep #$30
- lda a:rng2index
- inc
- cmp #$0800 ; Have we reached the end of the lookup table?
- bcc @RNG2_GetByte_10
- inc a:rng2adder
- stz a:rng2index ; Point index to the start of the lookup table
- ldx #0
- bra @RNG2_GetByte_20
- @RNG2_GetByte_10:
- sta a:rng2index
- tax
- @RNG2_GetByte_20:
- lda f:RNGLookupTable,x
- clc
- adc a:rng2adder
- and #$00ff
- plp
- plx
- rtl
- RNGLookupTable:
- .byte $2c,$c5,$05,$24,$b7,$f5,$2a,$ad
- .byte $4f,$22,$de,$70,$97,$c2,$21,$f4
- .byte $c2,$45,$b0,$96,$b1,$e4,$3b,$fd
- .byte $54,$ab,$e5,$c1,$3f,$ca,$fd,$57
- .byte $8b,$18,$fb,$40,$f0,$e8,$be,$72
- .byte $20,$11,$05,$06,$66,$38,$2b,$24
- .byte $7f,$61,$27,$2c,$b9,$b6,$c4,$26
- .byte $4a,$96,$1d,$6c,$f3,$e1,$5b,$96
- .byte $d5,$83,$b3,$a6,$93,$3f,$9a,$75
- .byte $aa,$bd,$4b,$5e,$0d,$d7,$7c,$28
- .byte $04,$20,$5c,$39,$47,$b6,$d0,$fa
- .byte $56,$4a,$ef,$85,$1b,$6d,$bc,$96
- .byte $c3,$1d,$23,$b0,$d9,$90,$36,$8e
- .byte $a5,$3f,$a8,$ce,$c4,$36,$8a,$d9
- .byte $09,$9b,$45,$16,$93,$7e,$d9,$4f
- .byte $2f,$e0,$55,$63,$f0,$06,$96,$2d
- .byte $0c,$ff,$43,$b5,$fa,$73,$09,$96
- .byte $ca,$af,$14,$af,$c4,$ee,$ce,$0e
- .byte $44,$ea,$dc,$19,$d5,$a3,$55,$fe
- .byte $8d,$6f,$45,$5e,$a8,$43,$62,$35
- .byte $68,$40,$0d,$0d,$2c,$81,$8c,$63
- .byte $cf,$24,$86,$59,$44,$97,$c0,$9e
- .byte $6f,$24,$17,$9b,$46,$c0,$bd,$e0
- .byte $28,$10,$b8,$cd,$7d,$bd,$98,$85
- .byte $90,$f9,$78,$0f,$a9,$52,$37,$cf
- .byte $6e,$b6,$f8,$25,$7c,$c8,$d8,$63
- .byte $41,$62,$ef,$f5,$1d,$6b,$89,$cb
- .byte $b9,$da,$a6,$0a,$a7,$0b,$af,$f4
- .byte $3b,$42,$7b,$15,$a8,$7d,$82,$b0
- .byte $5f,$7f,$60,$69,$a4,$19,$8d,$34
- .byte $73,$bb,$5b,$7d,$92,$3c,$31,$99
- .byte $f7,$e6,$06,$6c,$5c,$c6,$21,$5c
- .byte $21,$32,$0f,$76,$62,$9b,$e5,$e0
- .byte $59,$94,$b7,$7f,$f5,$23,$59,$e8
- .byte $bb,$48,$55,$8c,$de,$cc,$2c,$20
- .byte $9a,$4c,$d2,$4b,$d6,$85,$64,$94
- .byte $fa,$e1,$2c,$8a,$0e,$43,$d7,$35
- .byte $14,$10,$f5,$bd,$a6,$7e,$b2,$59
- .byte $d4,$21,$d3,$7b,$38,$b3,$f4,$3a
- .byte $5b,$23,$00,$ff,$4d,$e1,$f1,$74
- .byte $7f,$69,$ca,$aa,$e4,$0e,$d1,$89
- .byte $48,$09,$12,$7d,$f0,$c1,$11,$5e
- .byte $73,$5d,$ce,$a1,$d8,$88,$ff,$be
- .byte $f1,$84,$89,$e1,$f7,$72,$40,$d4
- .byte $67,$df,$e0,$2c,$1c,$93,$4b,$b3
- .byte $ae,$97,$05,$16,$0a,$85,$ee,$cf
- .byte $52,$14,$3e,$55,$f7,$e3,$c6,$83
- .byte $14,$86,$65,$47,$0e,$cf,$c9,$8c
- .byte $6a,$5e,$67,$69,$ef,$6b,$bd,$8a
- .byte $fd,$d3,$c7,$df,$2c,$61,$c0,$84
- .byte $28,$5f,$1b,$f1,$cc,$5e,$c1,$63
- .byte $7d,$41,$8c,$8a,$c9,$90,$03,$74
- .byte $41,$fc,$58,$b9,$94,$2e,$9f,$e8
- .byte $ed,$d4,$51,$32,$8e,$ee,$01,$56
- .byte $ad,$56,$5c,$cc,$8f,$8e,$67,$35
- .byte $e3,$cf,$f5,$02,$61,$4f,$67,$64
- .byte $a3,$d1,$a9,$75,$43,$73,$69,$a4
- .byte $36,$b4,$98,$66,$69,$c4,$27,$1b
- .byte $9a,$10,$fb,$3e,$78,$0e,$32,$d1
- .byte $fe,$46,$9a,$08,$0d,$a1,$6e,$34
- .byte $48,$f6,$52,$f3,$35,$d2,$92,$96
- .byte $91,$88,$97,$d3,$f4,$7a,$ab,$ac
- .byte $a6,$a6,$ee,$9f,$c0,$74,$98,$0f
- .byte $87,$be,$71,$f2,$05,$21,$8d,$bd
- .byte $e9,$83,$4d,$8c,$a1,$e5,$93,$96
- .byte $b6,$6a,$45,$d1,$67,$a8,$05,$e1
- .byte $89,$2f,$2e,$47,$9e,$58,$12,$c7
- .byte $35,$50,$73,$1a,$81,$65,$3f,$d5
- .byte $3d,$8f,$90,$99,$bf,$42,$e4,$7c
- .byte $5b,$72,$99,$b8,$fb,$e8,$ac,$93
- .byte $fc,$c4,$b3,$8e,$4b,$53,$18,$d1
- .byte $c0,$14,$97,$d6,$ba,$05,$fb,$55
- .byte $fc,$33,$15,$71,$c8,$81,$fd,$21
- .byte $3a,$b8,$8c,$e0,$e7,$cf,$1a,$98
- .byte $b6,$7d,$74,$cc,$fe,$fd,$22,$05
- .byte $e0,$21,$d7,$80,$e7,$9a,$38,$16
- .byte $df,$86,$d2,$6b,$f3,$3b,$55,$5b
- .byte $0a,$53,$16,$a1,$63,$f8,$c5,$ca
- .byte $6f,$71,$6b,$59,$ef,$ed,$a7,$3c
- .byte $4e,$90,$29,$6f,$41,$bc,$6f,$ee
- .byte $9d,$a1,$bf,$e1,$78,$07,$66,$03
- .byte $84,$5b,$2f,$54,$a8,$f9,$26,$ff
- .byte $e0,$b9,$8e,$8e,$56,$bc,$20,$4c
- .byte $c1,$78,$87,$fb,$ff,$02,$18,$b7
- .byte $ee,$9b,$d6,$2a,$90,$7e,$a6,$f2
- .byte $5e,$e9,$cf,$4f,$ed,$6a,$b5,$11
- .byte $bf,$6c,$d6,$c1,$6c,$01,$05,$0e
- .byte $f2,$f2,$e7,$7b,$59,$04,$ab,$48
- .byte $8b,$8d,$0e,$9e,$72,$38,$8e,$fe
- .byte $53,$15,$ed,$eb,$6a,$e4,$ea,$d7
- .byte $c7,$a3,$3b,$4b,$68,$55,$ce,$5b
- .byte $98,$15,$41,$49,$87,$5c,$a0,$78
- .byte $2a,$8f,$5e,$95,$56,$cc,$96,$00
- .byte $18,$f6,$82,$81,$57,$ff,$3c,$28
- .byte $ad,$75,$b5,$85,$82,$50,$f3,$09
- .byte $6b,$fa,$8f,$bc,$c2,$a0,$6e,$21
- .byte $86,$b8,$bf,$67,$74,$d3,$35,$d1
- .byte $67,$a5,$86,$67,$ed,$52,$24,$de
- .byte $2b,$fb,$3b,$c5,$f3,$89,$ec,$f2
- .byte $23,$b9,$c7,$2c,$41,$68,$8e,$1a
- .byte $54,$20,$29,$6c,$05,$e4,$e5,$48
- .byte $f7,$39,$f1,$f7,$63,$75,$1b,$d0
- .byte $f8,$4c,$c7,$65,$f2,$98,$30,$ed
- .byte $79,$69,$e3,$f1,$3c,$4d,$78,$3b
- .byte $4e,$e1,$94,$fc,$40,$98,$1c,$3c
- .byte $80,$cb,$bb,$87,$f2,$02,$97,$d6
- .byte $cc,$81,$4f,$bb,$b7,$16,$38,$d1
- .byte $24,$22,$d9,$64,$eb,$e6,$a4,$5c
- .byte $2b,$10,$f7,$6f,$5e,$86,$53,$87
- .byte $bb,$72,$db,$71,$d0,$8e,$10,$c8
- .byte $60,$b2,$cc,$21,$7b,$9b,$7c,$78
- .byte $dc,$fd,$a2,$db,$87,$cc,$8a,$55
- .byte $a3,$c8,$4b,$1d,$95,$47,$02,$00
- .byte $5f,$47,$4b,$0c,$37,$b4,$00,$7e
- .byte $6b,$f6,$35,$ee,$75,$be,$74,$b9
- .byte $5a,$12,$35,$af,$48,$97,$a1,$fe
- .byte $6f,$1f,$89,$5e,$1f,$73,$a1,$7f
- .byte $24,$62,$01,$b0,$5f,$0a,$dd,$d0
- .byte $a6,$65,$84,$7a,$dd,$18,$97,$6c
- .byte $55,$79,$8c,$38,$64,$de,$63,$2f
- .byte $46,$2d,$a6,$8b,$34,$a1,$a7,$dc
- .byte $c3,$da,$f6,$b4,$7f,$28,$21,$96
- .byte $c7,$19,$af,$1d,$eb,$40,$5f,$69
- .byte $85,$48,$9d,$cf,$15,$3a,$46,$c1
- .byte $e0,$0b,$9d,$fa,$0a,$6a,$8d,$ef
- .byte $f2,$c7,$21,$72,$cf,$a7,$42,$a9
- .byte $88,$28,$af,$2f,$d8,$cf,$42,$88
- .byte $a2,$9a,$61,$ca,$92,$42,$c3,$8a
- .byte $f6,$d1,$65,$05,$db,$65,$cc,$90
- .byte $6c,$43,$7c,$41,$87,$1f,$b8,$df
- .byte $a1,$aa,$7c,$08,$db,$5d,$b9,$a1
- .byte $65,$85,$d0,$83,$14,$8f,$51,$63
- .byte $3f,$96,$f5,$02,$df,$2b,$da,$97
- .byte $e6,$63,$fd,$79,$e0,$27,$fd,$11
- .byte $c8,$b8,$0e,$00,$2d,$81,$3c,$8c
- .byte $86,$21,$e2,$50,$d1,$b9,$6a,$25
- .byte $73,$73,$46,$4b,$4c,$53,$2f,$dc
- .byte $1a,$42,$9d,$73,$11,$58,$87,$18
- .byte $b7,$69,$5d,$6f,$05,$d4,$43,$21
- .byte $bb,$88,$8f,$8b,$04,$57,$84,$a6
- .byte $4b,$7f,$51,$37,$5c,$76,$45,$37
- .byte $bf,$f6,$54,$85,$52,$49,$d0,$ca
- .byte $25,$d6,$60,$ad,$9b,$ed,$45,$39
- .byte $be,$cf,$ce,$8b,$e2,$01,$19,$c0
- .byte $7e,$d3,$0b,$1d,$47,$2b,$92,$81
- .byte $8e,$97,$1a,$08,$db,$93,$4e,$01
- .byte $cb,$17,$11,$12,$27,$65,$bb,$aa
- .byte $46,$11,$98,$a8,$a5,$51,$9f,$49
- .byte $c4,$86,$6f,$57,$43,$0b,$8f,$90
- .byte $3e,$3e,$e7,$54,$e5,$cd,$7a,$94
- .byte $60,$43,$66,$f7,$e2,$d3,$1d,$4d
- .byte $0b,$63,$e5,$39,$84,$dc,$8e,$1b
- .byte $d5,$b1,$73,$3c,$8a,$ae,$b4,$3d
- .byte $87,$03,$b2,$c2,$a7,$90,$cb,$5a
- .byte $9c,$73,$57,$b2,$03,$d0,$e3,$fb
- .byte $c6,$e0,$ad,$98,$b7,$3d,$60,$0d
- .byte $6a,$6c,$11,$24,$53,$ab,$79,$61
- .byte $21,$fd,$74,$a8,$5a,$74,$bb,$2d
- .byte $37,$be,$de,$9d,$c2,$f3,$85,$8a
- .byte $2e,$9e,$e8,$1c,$77,$09,$8b,$f6
- .byte $3a,$ce,$3f,$67,$d7,$9b,$56,$d2
- .byte $c5,$45,$26,$60,$35,$10,$c0,$e4
- .byte $ea,$3d,$f2,$0e,$58,$d5,$7b,$d4
- .byte $fc,$b5,$8d,$1d,$fb,$db,$89,$b0
- .byte $fe,$ef,$f6,$5d,$4d,$15,$c2,$6a
- .byte $2a,$f2,$bd,$40,$70,$fd,$53,$57
- .byte $6c,$08,$8a,$5f,$fc,$0e,$3c,$b0
- .byte $e6,$3e,$95,$f3,$7b,$49,$d0,$12
- .byte $6d,$e9,$2d,$5e,$ed,$b2,$37,$00
- .byte $08,$1d,$34,$a2,$43,$d2,$ec,$5e
- .byte $76,$36,$9f,$e6,$e6,$35,$41,$f5
- .byte $a6,$51,$f8,$f7,$30,$eb,$d9,$f4
- .byte $3f,$d1,$de,$c2,$ef,$09,$2b,$6b
- .byte $18,$dd,$82,$dd,$e7,$28,$03,$d1
- .byte $bf,$df,$29,$fd,$4f,$e3,$02,$7d
- .byte $f4,$05,$ae,$7f,$51,$5a,$1b,$2e
- .byte $2c,$c2,$ff,$e1,$8c,$b3,$16,$85
- .byte $11,$4b,$9e,$48,$93,$96,$10,$88
- .byte $ff,$1c,$20,$fb,$6e,$af,$f7,$1f
- .byte $86,$73,$af,$e4,$16,$2e,$10,$98
- .byte $ed,$d2,$89,$14,$fb,$48,$72,$25
- .byte $ab,$7f,$81,$3d,$80,$b5,$8a,$5b
- .byte $ee,$05,$7b,$38,$7b,$32,$97,$b3
- .byte $16,$b2,$f3,$7e,$b7,$fe,$2e,$0a
- .byte $39,$19,$74,$b1,$74,$5f,$b6,$23
- .byte $9f,$90,$23,$13,$e4,$1c,$ea,$22
- .byte $45,$b1,$34,$0b,$ae,$03,$5c,$11
- .byte $5b,$db,$71,$a6,$6d,$63,$ee,$5d
- .byte $c8,$b0,$b8,$12,$30,$91,$59,$57
- .byte $a4,$97,$7c,$22,$f9,$65,$a8,$b5
- .byte $bb,$39,$41,$ce,$40,$bb,$bc,$11
- .byte $0e,$06,$22,$b2,$6f,$f4,$c8,$67
- .byte $53,$af,$4d,$8d,$66,$75,$d4,$99
- .byte $72,$ab,$83,$c2,$f7,$25,$3c,$ed
- .byte $08,$b4,$9b,$d8,$68,$f1,$30,$8b
- .byte $e6,$4a,$fe,$fc,$f6,$4a,$34,$01
- .byte $91,$2d,$2a,$7c,$4e,$a4,$9f,$c1
- .byte $c1,$e5,$31,$4b,$14,$f6,$1e,$a0
- .byte $e5,$3b,$3a,$81,$5f,$3f,$30,$57
- .byte $9b,$bf,$fd,$da,$39,$fd,$a9,$04
- .byte $3a,$43,$48,$35,$21,$b5,$32,$a7
- .byte $4a,$5c,$7f,$15,$8a,$70,$c5,$a7
- .byte $08,$e6,$15,$22,$5c,$3a,$34,$4d
- .byte $e6,$7e,$16,$a6,$70,$a4,$a1,$46
- .byte $07,$08,$9f,$12,$16,$41,$04,$24
- .byte $c4,$29,$63,$78,$91,$2a,$ab,$db
- .byte $2c,$cc,$26,$11,$97,$7c,$b3,$46
- .byte $7d,$9f,$43,$b7,$d3,$d7,$92,$a1
- .byte $af,$95,$27,$6a,$65,$df,$8f,$0e
- .byte $e8,$63,$d5,$cd,$5f,$bd,$46,$13
- .byte $06,$05,$63,$a7,$48,$9d,$26,$18
- .byte $1b,$39,$7a,$65,$9b,$2f,$f5,$eb
- .byte $ea,$01,$d8,$94,$47,$28,$49,$3e
- .byte $6d,$23,$cf,$6a,$2e,$c1,$0f,$26
- .byte $50,$ab,$c5,$3c,$a8,$34,$05,$9c
- .byte $75,$65,$b4,$07,$ff,$44,$42,$fe
- .byte $70,$65,$a9,$ea,$f3,$b4,$ab,$8d
- .byte $0b,$81,$47,$a8,$35,$cd,$7d,$ee
- .byte $c1,$d3,$44,$29,$ee,$da,$c8,$ab
- .byte $45,$3a,$e9,$f7,$37,$ad,$f0,$b1
- .byte $fa,$d9,$94,$c3,$a1,$1a,$2d,$d1
- .byte $7a,$94,$37,$e0,$ad,$79,$0a,$42
- .byte $12,$98,$d8,$c4,$52,$27,$e7,$1b
- .byte $42,$d1,$10,$8c,$7c,$03,$79,$dc
- .byte $3f,$74,$8f,$77,$89,$f3,$46,$e4
- .byte $73,$75,$95,$68,$cd,$5e,$2c,$f9
- .byte $fa,$10,$78,$67,$0d,$b2,$da,$c6
- .byte $24,$42,$23,$1e,$05,$de,$53,$56
- .byte $f8,$4e,$93,$5e,$e4,$d6,$70,$9c
- .byte $ad,$3b,$5a,$9a,$cd,$14,$5c,$ed
- .byte $31,$53,$1d,$68,$56,$13,$18,$82
- .byte $a4,$a4,$18,$05,$0a,$d5,$f7,$f9
- .byte $dc,$81,$97,$d0,$e9,$5c,$21,$d3
- .byte $e0,$ff,$7d,$cc,$e5,$32,$12,$f5
- .byte $6f,$7a,$c0,$21,$65,$e3,$1a,$29
- .byte $79,$10,$e8,$9a,$c4,$80,$dd,$9c
- .byte $a3,$22,$95,$25,$d1,$1c,$d2,$60
- .byte $c5,$d9,$f8,$58,$4e,$51,$c6,$e9
- .byte $6d,$9d,$56,$e9,$73,$ba,$58,$92
- .byte $5b,$9d,$8b,$33,$6a,$78,$7d,$17
- .byte $05,$4c,$83,$b6,$d2,$af,$fb,$1b
- .byte $13,$e0,$c1,$95,$3f,$08,$f0,$a1
- .byte $e2,$d3,$da,$17,$b7,$2f,$4a,$95
- .byte $03,$64,$f9,$29,$34,$55,$4e,$42
- .byte $bb,$15,$5a,$d9,$26,$ad,$14,$dc
- .byte $82,$2c,$d1,$db,$f0,$f0,$07,$f5
- .byte $86,$34,$43,$05,$69,$db,$68,$0a
- .byte $28,$7c,$29,$d4,$5b,$ae,$c9,$f6
- .byte $7c,$95,$12,$e7,$05,$ad,$94,$7a
- .byte $cb,$d6,$20,$82,$9a,$a1,$84,$be
- .byte $12,$da,$88,$0a,$c1,$56,$29,$c9
- .byte $82,$fe,$15,$8d,$16,$1c,$66,$09
- .byte $00,$e5,$a3,$39,$a5,$48,$f5,$cf
- .byte $a5,$f6,$a6,$e1,$74,$b2,$df,$d2
- .byte $3d,$da,$a2,$7e,$f8,$37,$06,$aa
- .byte $ca,$01,$b3,$aa,$9d,$36,$9d,$54
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement