Re: A86: matrices


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

Re: A86: matrices




In the case of an asm matrix, you just can just have a bunch of bytes;

array:
	.db 0,0,0,0,0,0,0,0
	.db 0,0,0,0,0,0,0,0
	.db 0,0,0,0,0,0,0,0
	.db 0,0,0,0,0,0,0,0
	.db 0,0,0,0,0,0,0,0
	.db 0,0,0,0,0,0,0,0
	.db 0,0,0,0,0,0,0,0
	.db 0,0,0,0,0,0,0,0

This would be an 8x8 matrix. You have to write a routine to read the array.
This is one I wrote a while ago (actually, I think maybe someone helped me
with it...I can't remember). It may not be great, but it works for my
purposes.


;*****************************
; Read Array
; Input DE = x,y of cell
; Output A = cell state
; 29 bytes, 194 T's (w/o ret)
;*****************************
Read_Array:
 push bc			;save registers
 push de			;.
 push hl			;.
 ld hl,array			;locate array
 ld a,e			;load Y coord
 cp 0				;check if it's row 0
 jr z, RA_no_row_change	;if so, don't move down
 push de			;save DE
 ld b,a			;times to run loop (rows)
RA_loop:
  ld de,(Awidth)		;get array width (change if the array size changes)
  add hl,de			;move down Y
  djnz RA_loop
 pop de			;recover DE
RA_no_row_change:
 ld e,d			;load X coord into E
 ld d,0			;clear D
 add hl, de			;add X coord to hl
 ld a,(hl)			;load state of X,Y into A
 pop hl			;recover registers
 pop de			;.
 pop bc			;.
 ret

Awidth:
	.db 8


If you want a real good explanation, i think 86 Central has something on
tilemaps which would cover this. (ti86.acz.org)

Hope this helps,
Dave


At 08:00 PM 5/14/99 EDT, you wrote:
>
>okay, newbie question.  what the heck is a matrix? i've know they exist, and 
>i know that peopple use them but i dont have a clue what for.
>
>-=-=1414=-=-
>
>
>



References: