Re: A85: Matix
[Prev][Next][Index][Thread]
Re: A85: Matix
Why don't you just use a matrix in the TEXT_MEM? You won't have to
worry about checksums if you do this. All you have to do is copy the
matrix from your program body into TEXT_MEM using the ldir
instruction. then when you want to access the matrix, you will never
even have to add PROGRAM_ADDR (since you are using Zshell). That is
the easiest way to do it.
TXTMTRX = TEXT_MEM+X ;64 bytes for matrix
;X is an integer after the previous
;variable
NEXTVAR = TEXT_MEM+X+N ;make sure next variable doesn't
;start for N bytes, where N is the
;number of bytes of your matrix
Your matrix is defined at the bottom:
;this matrix is 64 bytes, so N would be 64 bytes in this case
Matrix:
.db 0,1,0,1,0,1,0,1
.db 1,0,1,0,1,0,1,0
.db 0,1,0,1,0,1,0,1
.db 1,0,1,0,1,0,1,0
.db 0,1,0,1,0,1,0,1
.db 1,0,1,0,1,0,1,0
.db 0,1,0,1,0,1,0,1
.db 1,0,1,0,1,0,1,0
In your code, you have a function:
CopyMatrixToTEXT:
ld bc,N ;N would be 64 in this example
ld de,TXTMTRX
ld hl,Matrix
ldir
ret
Now in your code, where before you would have called the function like
Andreas wrote below with:
ld de,(PROGRAM_ADDR)
ld hl,Matrix
add hl,de
ex de,hl ;matrix location in de
ld a,(XPOS)
ld b,a ;x pos in b
ld a,(YPOS)
ld c,a ;y pos in c
CALL_(EssFunction)
You would now call it as such:
ld de,TXTMTRX ;matrix location in de
ld a,(XPOS)
ld b,a ;x pos in b
ld a,(YPOS)
ld c,a ;y pos in c
CALL_(EssFunction)
-mike pearce
On Sun, 07 Sep 1997 18:39:02 -0500, you wrote:
>I tried that and then put lh (hl),a and it didn't work andgave me a bad
>checksum! Here is how I'm calling my matrix, if this matters, and I
>have the number I want stored in A! but nothing is working! Does
>anyone know why or ahve they run across this?
>
>John
>
>Ess Andreas wrote:
>>
>> B = x coordinate
>> C = y coordinate
>> DE = addr of your matrix-like gameboard
>>
>> ld H, 0
>> ld L, C
>> add HL, HL
>> add HL, HL
>> add HL, HL ;you have an 8x8 matrix, right?
>> ld C, B
>> ld B, 0
>> add HL, BC
>> add HL, DE
>>
>> Now you can perform ld A, (HL), ld (HL), A etc. etc.
>> Andreas
>
References: