A83: Re: Random text,
[Prev][Next][Index][Thread]
A83: Re: Random text,
The problem with your code is that you are incrementing DE instead of HL,
however, there is an easier and faster way to accomplish what you are trying
to do. Also, 'cp 0' optimizes to 'or a'. I am assuming that irandom
returns the result in the accumulator.
call irandom
ld d,0
ld e,a
ld hl,answerpointers
add hl,de
add hl,de
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
Now, if you want, you can skip the pointer table, at the expense of taking a
little longer to calculate the address of the text string. This is probably
the method you want to use.
call irandom
ld bc,$fffff
ld hl,answer0
or a
jr z,found
ld d,a
find:
sub a
cpir
inc hl
dec d
jr nz,find
found:
> ld a,(HL)
> ld e,a
> inc de
> ld a,(HL)
> ld h,a
> ld l,e
> ret
References: