Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Original 6502 code:
- -------------------
- GetRand:
- PHY
- LDY #$01
- JSR TickRandom
- DEY
- JSR TickRandom
- PLY
- RTL
- TickRandom:
- LDA $148B
- ASL
- ASL
- SEC
- ADC $148B
- STA $148B
- ASL $148C
- LDA #$20
- BIT $148C
- BCC Label1
- BEQ Label3
- BNE Label2
- Label1: BNE Label3
- Label2: INC $148C
- Label3: LDA $148C
- EOR $148B
- STA $148D,Y
- RTL
- Converted GBz80 code: (with help of GBDev Discord)
- --------------------------------------------------
- Random_:
- ld bc,wRandomState+3
- call TickRandom
- dec bc
- jp TickRandom
- TickRandom:
- ld hl,wRandomState
- ld a,(hl)
- add a,a
- add a,a
- scf
- adc a,(hl)
- ld (hli),a
- sla (hl)
- bit 5,(hl)
- jr nc,.one
- jr z,.three
- jr nz,.two
- .one jr nz,.three
- .two inc (hl)
- .three ld a,(hld)
- xor (hl)
- ld h,b ; ld16 hl,bc
- ld l,c
- ld (hl),a
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement