RE: LZ: matrices


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

RE: LZ: matrices




 see changes....may help....or not
 
 Brian Greer  <bgreer01@mail.coin.missouri.edu>
> 
> On Sat, 7 Dec 1996, Michael Wyman wrote:
> 
> > On Sat, 7 Dec 1996 15:19:52 -0600 (CST),
> > Will Stokes wrote...
> > >I'm really impacient about learning matrices and even though I mailed one
> > >guy about them I can;t wait days to learn how since I'm going out of town
> > >and wont have internet acces.
> > >	Lets say I have a defined matrix at the bottom of a prog. that
> > >will not be changed but values will be take from it to calculate stuff in
> > >the prog depending on variable. In other words, a 5 by 50 matrix with
> > >preset values. How do i load the value of MATX (refering to 5) and MATY
> > >(refering to  50) posision in matrix into register a? in other words for
> > >values of MATX and MATY how do I load the appropriate value of the matrix
> > >into a? How do I define it at the bottom of the screen? What about memory
> > >allocation, i won;t have to define it at the top will I? It's like sprites
> > >or pictures right? Any help appreciated as I would like the info soon so I
> > >can work on this game and maybe finnish it over the winter break.
> > >			Will Stokes
> > 
> > So you're trying to have the calculator recall values from a 50 row x 5 
> > column matrix, right?  Then define your matrix with .db's with your values 
> > as follows:
> > 
> > <Label>:
> > ;     C1     C2     C3     C4     C5
> > *db value, value, value, value, value ;row 1
> > db value, value, value, value, value ;row 2
> > 
> > etc. until you have all of your values stored.  To recall a value at 
> > (MATX,MATY), have a loop such as follows:
> > 
> > ld   hl, <Label>
> > ld   de, (PROGRAM_ADDR)
> > add  hl, de               ;hl points to begining of row 1 in matrix
> > ld   a, MATY
> > dec  a
> > or   a                    ;If value needed is in row 1, skip loop
> > jr   z, Done_With_Loop

I think you may need to:
inc a
or else you will end up on the wrong row...

> > ld   b, a                 ;b is the counter
> > Row_Loop:
> > add  hl, $05              ;hl points to begining of next row
> 
 I couldn't get this part to compile so you might want to try:
   ld de,$05
   add hl,de
 instead of just 'add hl,$05'  --just at thought
> 
> > djnz Row_Loop
> > Done_With_Loop:
> > dec  hl                   ;because we'll increase it at least once
> > ld   b, MATX
> > Column_Loop:
> > inc  hl
> > djnz Column_Loop
> > ld   a, (hl)              ;acc should now hold the desired value!
> > 
> > I have never tried this before, but I think that it should work.  If it 
> > does, please let me know, and even if it does, please do!
> > 
> > Hope I've helped!
> > Michael Wyman - SeaHorse Software
> > wyma0012@gold.tc.umn.edu
> > 
> > 
> > 
> > 
> 


References: