A83: Re: Negative or positive?


[Prev][Next][Index][Thread]

A83: Re: Negative or positive?




When coding assembly, you have to scrap alot of techniques that worked well
for Basic, such as adding a positive or negative number to increment a
value.

just do this...

 ld a,r                ; or insert your favorite random number routine
 and %1                ; 0 or 1
 jr z,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:

    ; end of routine

-harper



Follow-Ups: References: