Re: LZ: Question with programming


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

Re: LZ: Question with programming



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.
-- 
_______________________________________

Dines Justesen
Email: dines@post1.com or
       c958362@student.dtu.dk
WWW  : http://www.gbar.dtu.dk/~c958362/
_______________________________________


Follow-Ups: References: