LZ: tables


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

LZ: tables



I need to know how to set up a table that is 95 bytes long.  I need to be able to place a value at a specific 
element number.  I also need to be able to retrieve the value stored at any element number.


Here is what I have so far:


RandNum = $80E1


Place:
        CALL_(Random)
        ld hl,Table
        ld de,RandNum
        add hl,de
        ld a,1
        ld (hl),a
        ret
;----------------------------------------------------------------------------
;(Random number routine: Returns number between 0 and 95)
Random:
        ld a,r
        cp 96
        jr nc,Random
        cp 0
        jr c,Random
        ld (RandNum),a
        ret


To retrieve a value do I:?


Retrieve:
	ld hl,Table
	ld de,(Element I want to retrieve)
	add hl,de
	ld a,(hl)
	ret




As far as I can see, this should work, but for some reason it doesn't, I'm new so I'm sure it's something 
stupid, but if anyone can help me I'd really appreciate it, thanks


 _
(_
|_)teve
|eterson


vestige@ddt.net