Get Pixel Color on MO6

Cette catégorie traite de développements récents pour nos vieilles machines, applications, jeux ou démos... Amis programmeurs, c'est ici que vous pourrez enfin devenir célèbres!

Modérateurs : Papy.G, fneck, Carl

Garland
Messages : 17
Enregistré le : 25 oct. 2018 19:40

Re: Get Pixel Color on MO6

Message par Garland » 12 juin 2019 14:25

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?

__sam__
Messages : 4622
Enregistré le : 18 sept. 2010 12:08
Localisation : Brest et parfois les Flandres

Re: Get Pixel Color on MO6

Message par __sam__ » 12 juin 2019 19:24

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+, A1200(030@50mhz/fpu/64mb/cf 8go),
GVP530 (MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.

Garland
Messages : 17
Enregistré le : 25 oct. 2018 19:40

Re: Get Pixel Color on MO6

Message par Garland » 18 juin 2019 13:02

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.

Image

If i write:

Code : Tout sélectionner

ADR = VARPTR(MYASSET)
FOR I = ADR TO ADR+NUMBYTES
READ A$: POKE I, VAL("&H"+A$)
NEXT
Can i use this approach instead of pointing to fixed addresses or i'm risking to trash some memory?

__sam__
Messages : 4622
Enregistré le : 18 sept. 2010 12:08
Localisation : Brest et parfois les Flandres

Re: Get Pixel Color on MO6

Message par __sam__ » 18 juin 2019 13:32

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.
Samuel.
A500 Vampire V2+, A1200(030@50mhz/fpu/64mb/cf 8go),
GVP530 (MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.

Répondre