Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lcg16777213:
- ;;Expects ADL mode
- ;;x=11875x+137 mod (2^24-3)
- ;;Returns HL
- #IF smc == 0
- ld hl,(seed24)
- #ELSE
- seed24 = $+1
- ld hl,10101
- #ENDIF
- ;multiply seed by 95, first
- xor a \ ld d,a
- add hl,hl \ rla
- add hl,hl \ rla
- add hl,hl \ rla
- add hl,hl \ rla
- add hl,hl \ rla
- ld e,a
- push hl
- add hl,hl \ rla
- add hl,hl \ rla
- ld bc,(seed24)
- sbc hl,bc
- sbc a,d
- or a
- pop bc
- sbc hl,bc
- sbc a,e
- ;AHL * 125
- ;=AHL*128-AHL*2-AHL
- ld e,a
- push de \ push hl
- add hl,hl \ rla
- ld e,a
- push de \ push hl
- add hl,hl \ rla \ rl d
- add hl,hl \ rla \ rl d
- add hl,hl \ rla \ rl d
- add hl,hl \ rla \ rl d
- add hl,hl \ rla \ rl d
- add hl,hl \ rla \ rl d
- ld e,a
- pop bc \ sbc hl,bc \ ex de,hl \ pop bc \ sbc hl,bc \ ex de,hl
- pop bc \ sbc hl,bc \ ex de,hl \ pop bc \ sbc hl,bc \ ex de,hl
- ;add 37
- ld c,137
- add hl,bc
- ld c,b
- ex de,hl
- adc hl,de
- ex de,hl
- ;mod 2^16-3
- ex de,hl
- ld b,h
- ld c,l
- add hl,hl
- add hl,bc
- ex de,hl
- sbc hl,de \ jr nc,$+5 \ dec hl \ dec hl \ dec hl
- ld (seed24),hl
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement