Re: LZ: Question with programming
[Prev][Next][Index][Thread]
Re: LZ: Question with programming
On Wed, 11 Dec 1996, Dines Justesen wrote:
> Ryan Myers wrote:
>
> > This would be the code to retrieve a value at row x, column y - assuming that
> > the first value in the matrix is row 0 col 0 and the last row 11 col 5. Row
> > is given in B and Column in A.
> >
> > GetValue:
> > mul b, 6
> > add a, b
> > ld hl, a
> > add hl, Matrix1
> > ld a, (hl)
> > ret
> >
> > This should ( I hope ) retrieve the value of row b, column a in A. A simple
> > modification would be made to write the value of new blocks from C to the
> > address in HL.
> There are some problems with your code. Why not put the coloum in b and
> the row in a. If you do that, try something like this
>
> push af ;Multiply a by 6
> add a ;
> pop hl ;
> add h ;
> add a ;
> add b ;add coloum
> ld h,0 ;ld offset into hl
> ld l,a
> ld de,PROGRAM_START ;Add offset to your program
> add hl,de
> ld de,Matrix1 ;Add offset from program start to matrix
> add hl,de
> ld a,(hl) ; Get value into a
> ret
>
> There might by some errors, but something like this should work.
> Hope this helps.
I would rather keep row in B and column in A - keeps the code smaller and
faster. Speed and code size are my primary concerns - any optimization I
can do early on is good.
Basically, that was my main problem ( not adding the PROGRAM_START value
). Other than that, to my understanding my original code with the
PROGRAM_START code should work. Besides, what I did with the rest of the
program is hard code a level into it, and that already uses B as the row
and A as the column, so it's easier this way.
Thanks,
> --
> _______________________________________
>
> Dines Justesen
> Email: dines@post1.com or
> c958362@student.dtu.dk
> WWW : http://www.gbar.dtu.dk/~c958362/
> _______________________________________
>
Ryan J. Myers ----> rmyers@teleport.com <----
Portland, Oregon ( US ) ----> http://www.teleport.com/~rmyers/ <----
"Nolite tes bastardes carborundum." - Margaret Atwood
"C> REALITY.SYS is corrupt, reboot universe? (Y|N)" - Anonymous
Follow-Ups:
References: