Direct Memory Acces: Forced Downcasting?
RedNifre
Posts: 84
I try to implement a little palette swap trick and I have troubles undestanding why the compiler tells me I have to downcast to byte-access.
This is the DAT-Section:
I want to replace the first entry with entry number 7. Therefore I wrote this code:
The compiler moans that I'm trying to cast to a higher access-type. When I ommit the ".LONG" it gets down to bytes. Why is that the case and what should I do about it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hydra in a LEGO NES:
http://forums.parallax.com/showthread.php?p=654788
This is the DAT-Section:
DAT 'Grafik-Kram palette_map long $02_5B_07_5B 'change me! long $AD_AC_9B_9A long $07_5C_5B_02 long $7E_8D_6D_7C long $07_fC_fB_02 long $07_FC_5B_02 long $7E_6D_6C_02 long $3E_6C_04_02 '7 long $3E_CD_04_02 '8
I want to replace the first entry with entry number 7. Therefore I wrote this code:
palette_map.LONG[noparse][[/noparse]0] := palette_map.LONG[noparse][[/noparse]7]
The compiler moans that I'm trying to cast to a higher access-type. When I ommit the ".LONG" it gets down to bytes. Why is that the case and what should I do about it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hydra in a LEGO NES:
http://forums.parallax.com/showthread.php?p=654788
Comments
palette_map long
or joining the first entry to the palette_map line eg
palette_map long $02_5B_07_5B 'change me!
that should help, as unless a long or byte or word is on the label line, it doesn't know what the data type is, and as your error shows, presumes bytes.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hydra in a LEGO NES:
http://forums.parallax.com/showthread.php?p=654788
Andre'
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hydra in a LEGO NES:
http://forums.parallax.com/showthread.php?p=654788
Then 3 bytes will be wasted and bytes[noparse][[/noparse]8] would return 5.
So, doing something like bytes.WORD could imho easily return $302.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hydra in a LEGO NES:
http://forums.parallax.com/showthread.php?p=654788
True, but LONGs need to be LONG aligned (multiple of 4 bytes).
Words need to be WORD aligned (multiple of 2).
[noparse]:)[/noparse]
Make sure you pad your data if needed for alignment.