Re: LZ: Lookup Tables


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

Re: LZ: Lookup Tables



Steve Peterson wrote:


> example:
>                 .db     (x,y),1
>                 .db     (x,y),2
> I need to be able to say:  I need the coordinates of point labled "1" and store "x" in b and store "y" in c.
> Understand what I'm getting at?
> 
> http://www.geocities.com/SiliconValley/Park/2636


Something like this perhaps:


GetCoordinates:    ; IN: a - coord  OUT: b,c - coordinates
 ld hl,CoordTable
 ld de,(PROGRAM_ADDR)
 add hl,de
 ld d,0
 ld e,a
 sla e       ; Multiply by two
 add hl,de
 ld b,(hl)
 inc hl
 ld c,(hl)
 ret


CoordTable:
 .db 5,7     ; 0
 .db 9,3     ; 1
 .db 8,12    ; 2
 


The first coordinate is 0, not 1 though.


<pre>
-- 
Real name: Jimmy Mårdell
Email....: mailto:mja@algonet.se
IRC-name.: Yarin
WWW......: http://www.algonet.se/~mja


"Strap me down with disillusion 
  Tie me up in lifelines
   Nothing stops my thoughts from breeding
    Nothing's stopping my mind" - Leather Strip
</pre>


References: