Re: A82: How do the good programmers do it?


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

Re: A82: How do the good programmers do it?



ilya winham <ilyamojo@geocities.com> writes:
>
>How do I use byte matrices. (Matrixone: .db 0,0,0,0
>                                        .db 0,0,0,0
>                                        .db 0,0,0,0 <--correct?
>Using a matrix like that one how do I store values, read values, and 
>perform if statements on it?

Store:

	ld A, 1
	ld (Matrixone + [ROW*4] + [COL] ), A

Read:
	ld (Matrixone + [ROW*4] + [COL] ), A
	
Logic:
	ld (Matrixone + [ROW*4] + [COL] ), A
	or A
	jr z, Label

Explanation:

	When you set aside memory using .db, it's actually stored as just
a long line of 0's. So your 4x4 matrix is really just 16 0's. Setting it
up that way just makes it easier to read as a 4x4 matrix. This is the
reason for the [ROW*4]. Get it? This is really a simple concept. Oh, and
one last thing, 0 is the first row, not 1. ;) Still have questions? Ask
away!
	
		-Scoobie




Follow-Ups: References: