Re: A83: A problem with matrices


[Prev][Index][Thread]

Re: A83: A problem with matrices





I wrote :
> > 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)

what I meant was that if you write your code with the #define macros ..  it 
would only work for that specific level and therefore you would have to make 
new code for all your levels .

You can eliminate this by making a routine which takes an adress (of the 
level) as an argument and then uses ix+offset to acces the data.

                  ex:
main:
...
ld ix,level_one                          ; the adress of the level
call load_level
...

load_level:                                 ; input ix
                             ;now ix points to your matrice

;now ix has a value of an adress ... you don't want the adress ... you ;want 
what that adress contains ... so you have to use () which ;means  "give me 
the data that is at ix"

ld a,(level_one+row2+el3)
;is the same as
ld a,(ix+row2+el3)
...
...
ret

Why ix ? Because
ld a,(hl+row2)  is illegal


glad I could help 2.

chao

PS:
 > > ld a,5
> > ld (level_one+row2+el3),a
this was a different example in which I load 5 in to level_one[2,3]




>From: Pizza of Hut <pizzaofhut@geocities.com>
>Reply-To: assembly-83@lists.ticalc.org
>To: assembly-83@lists.ticalc.org
>Subject: Re: A83: A problem with matrices
>Date: Thu, 29 Jul 1999 18:59:37 -0500
>
>
>
>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/
>


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com