A89: Using a 2 dimensional array to put sprites


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

A89: Using a 2 dimensional array to put sprites




How can l sort of use "indirection" to put a sprite at a location?  Realize
that part of the code would not work because l had to make it up, but l'll try
to explain what l'm doing.  table is a 50x50 array.  d1 is the row, d2 the
col.

lea     table(PC),a0  ; Let A0 point at the table
 mulu    #100,d1       ; One row is 100 bytes (50 words). We must use
                       ; MULU to get the right offset. If each row was
                       ; 128 bytes, we could have shifted instead (faster).
 adda    d1,a0         ; Add the rowoffset to the pointer
 lsl.w   #1,d2         ; Multiplicate the column with 2 (same reason as above)
 move.w  0(a0,d2),d0   ; Get the word and store it in d0 (l wrote this
comment!)

Now: let's say that d0 equals 00000001 (which in my SimTown game l might want
to be the code for a road tile).  l know that my label for the sprite can't
start with a number, but l don't want to:
cmp d0,00000001
beq road_tile
cmp d0,00000002
beq clear_land
lnstead, l want to somehow jump to what d0 equals.  so when d0 equals 00000001
l want to somehow convert that value into a label it can jump to.
l've been asking a lot of questions lately, but by the help l've received (by
maybe 2-3 people out of the hundred or so on the list) l've been able to learn
some details.
Thank you in advance
--TurboSoft