Page 2 sur 2

Re: Get Pixel Color on MO6

Posté : 12 juin 2019 14:25
par Garland
ADR = VARPTR(L%) ' get LSB address '2A6D 2AAC
POKE &H433D, ADR@256 ' integer division to get MSB of address
POKE &H433E, ADR AND 255 ' bit mask to get LSB of address

Sometimes this code doesn't put $XXXX but #$XXXX (wrote as immediate) in the address, i see it on debugger.

If the code has to put $2A6D for instance, i see it in the debugger as #$2A6D , not $2A6D.

Then the USR fails because #$XXXX is not $XXXX. Do you guess why this could happen?

Re: Get Pixel Color on MO6

Posté : 12 juin 2019 19:24
par __sam__
Having #$XXXX is an error. It should not happen. It is likely that your asm-code is being trashed while in use. This raises the question: did you protect your asm-code from being trashed by the basic interpreter with the CLEAR command in the very beginning of the basic program ?

Re: Get Pixel Color on MO6

Posté : 18 juin 2019 13:02
par Garland
Sorry for being late but i was away for a few days.. Yes, i'm protecting the code with CLEAR and i was trying to understand where to store my assets in memory.


If i write:

Code : Tout sélectionner

Can i use this approach instead of pointing to fixed addresses or i'm risking to trash some memory?

Re: Get Pixel Color on MO6

Posté : 18 juin 2019 13:32
par __sam__
Your variable only occupy few bytes. I think this is not enough to store a whole binary code.

The correct way is to use the basic CLEAR command to reserve a portion of memory. For instance you can reserve from $5000 to $5FFF (~4kb of non swappable bank) using: CLEAR ,&H4FFF (use one less that your first reserved byte). Basic will not use that memory area to store variables, stacks etc. Your code is safe there.

Notice: Inferring from TO 8/9 machines, I assume this for MO6 as well: to reserve in swappable banks, you should use "BANK n:CLEAR ,,,&Hxxxx" with xxxx between $6000 and $9FFF and n a bank number. It'll reserve from $xxxx+1 to $9FFF in banks #n, #n+1, #n+2, .. #max. Then before calling EXEC or USR, ensure you are presently in the correct bank (i.e. do "BANK n" before EXEC) or it'll crash.