Re: A83: A problem with matrices


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

Re: A83: A problem with matrices



 

the homonerdicus wrote:

I think you're still better off to do them in a .db format....
The simple code of the calls to _puttomat and the inc take more space.
I tried using the matrices for a different prog a while ago and let me tell
you that it is really not worth it if you are working with integers ( N| )..

what you are trying to do would look like this...

level_one:
.db 0,0,2,0,0
.db 0,0,2,0,0
.db 0,2,2,2,0
.db 0,0,2,0,0
.db 0,0,1,0,0   ; all of this is 25 bytes !

You can then acces the matrice in the following manner...

#DEFINE row2 5       ;those don't go in to the 83p file
#DEFINE row3 10     ;they are just aids....
#DEFINE row4 15
#DEFINE row5 20

#DEFINE el2 1
#DEFINE el3 2
#DEFINE el4 3
#DEFINE el5 4

to acces level_one[2,3]

you have to do (if it is a number beween 0 and 255)
                         (it it is larger you have to use .dw)

ld a,5
ld (level_one+row2+el3),a
          and
ld a,(level_one+row2+el3)

if later on you don't know which level you are in ...it will happen.. you
can use the ix register and do the offsets with it)

glad I could help...

An advice from me.... stay away fro ROM calls as much as possible.

homonerdicus
 

Thanx for the help. Now that I look at it, something like that would really save memory and eliminate the need for external data files. I don't understand how you came up with the variables you used to offset level_one, or why you load 5 into (level_one+row2+el3) to access (2,3). Is 5 a default value, or does it change depending on what element I'm trying to access? BTW, how would I use ix to determine what level I'm in? (I don't know a whole lote about the index registers yet)
 

--
Pizza of Hut
http://www.antishrine.sacone.com/
 


Follow-Ups: References: