LZ: Question with programming


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

LZ: Question with programming



I am thinking of using a matrix-style level system for a new game...

This is the code I figured would do the job; could anyone inform if this
would work, as I just broke my link yesterday by popping off the cable, and
I don't have time lately between school and work to make a new one yet.

My thanks in advance.

-----------------------------BEGIN SNIPPET------------------------------------

The Matrix would be like this:

Matrix1:
        .db 6, 6, 6, 6, 6, 6
        .db 6, 6, 6, 6, 6, 6
                ...
        .db 6, 6, 6, 6, 6, 6

For a total of 12 rows of 6 wide, containing values 0, 1, 2, 3, 4, 5, or 6.

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.

-------------------------------END SNIPPET----------------------------------

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: