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?
Get Pixel Color on MO6
Modérateurs : Papy.G, fneck, Carl
-
- Messages : 7987
- Inscription : 18 sept. 2010 12:08
- Localisation : Brest et parfois les Flandres
Re: Get Pixel Color on MO6
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 ?
Samuel.
A500 Vampire V2+ ^8^, A1200 (030@50mhz/fpu/64mb/cf 8go),
A500 GVP530(MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.Démos
A500 Vampire V2+ ^8^, A1200 (030@50mhz/fpu/64mb/cf 8go),
A500 GVP530(MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.Démos
Re: Get Pixel Color on MO6
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:
Can i use this approach instead of pointing to fixed addresses or i'm risking to trash some memory?
If i write:
Code : Tout sélectionner
ADR = VARPTR(MYASSET)
FOR I = ADR TO ADR+NUMBYTES
READ A$: POKE I, VAL("&H"+A$)
NEXT
-
- Messages : 7987
- Inscription : 18 sept. 2010 12:08
- Localisation : Brest et parfois les Flandres
Re: Get Pixel Color on MO6
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.
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.
Samuel.
A500 Vampire V2+ ^8^, A1200 (030@50mhz/fpu/64mb/cf 8go),
A500 GVP530(MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.Démos
A500 Vampire V2+ ^8^, A1200 (030@50mhz/fpu/64mb/cf 8go),
A500 GVP530(MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.Démos