Re: A83: Re: Negative or positive?
[Prev][Next][Index][Thread]
Re: A83: Re: Negative or positive?
;**********
;*original*
;**********
; always works
ld a,r ; or insert your favorite random number routine
rra
jr nc,increaseSpeed ; move right if A=1
ld a,(speed)
dec a
cp 6
jr z,skipChangeSpeed ; dont change speed
ld (speed),a
jr skipChangeSpeed ; dont want to increase it either
increaseSpeed:
ld a,(speed)
inc a
cp 90
jr z,skipChangeSpeed ; dont change speed
ld (speed),a
skipChangeSpeed:
;*****************************
;*Done using negative numbers*
;*****************************
; half the time it is skipped. (on r = 1 and r = 3)
ld a,r
and %11 ; 0 to 3
jr z,skipIT ; throw out 3
dec a ; -1 to 1
ld b,a
ld a,(speed)
add a,b
cp 6
jr c,skipIT
cp 90
jr nc,skipIT
ld (speed),a
skipIT:
References: