getting different results for address in LONG (answered)
ericball
Posts: 774
For my sprite driver the sprite table format is addr[noparse][[/noparse]16]:xpos[noparse][[/noparse]8]:ypos[noparse][[/noparse]8] (lsb) (all 0 for unused)
The following SPIN code works:
sprite_tab.BYTE[noparse][[/noparse]0] := Constant((240-8)/2) ' ypos, sprite[noparse][[/noparse]0]
sprite_tab.BYTE[noparse][[/noparse]1] := Constant((240-8)/2) ' xpos, sprite[noparse][[/noparse]0]
sprite_tab.WORD[noparse][[/noparse]1] := @sprite
But trying to do the same in the DAT section the address is wrong:
DAT
sprite_tab···········LONG··· @sprite<<16+((240-8)/2)<<8+((240-8)/2)
sprite················· BYTE··· 00, 00, 00, 05, 05, 00, 00, 00
Based on the output, instead of @sprite, I'm getting @sprite-??
Post Edited (ericball) : 4/7/2009 7:25:09 PM GMT
The following SPIN code works:
sprite_tab.BYTE[noparse][[/noparse]0] := Constant((240-8)/2) ' ypos, sprite[noparse][[/noparse]0]
sprite_tab.BYTE[noparse][[/noparse]1] := Constant((240-8)/2) ' xpos, sprite[noparse][[/noparse]0]
sprite_tab.WORD[noparse][[/noparse]1] := @sprite
But trying to do the same in the DAT section the address is wrong:
DAT
sprite_tab···········LONG··· @sprite<<16+((240-8)/2)<<8+((240-8)/2)
sprite················· BYTE··· 00, 00, 00, 05, 05, 00, 00, 00
Based on the output, instead of @sprite, I'm getting @sprite-??
Post Edited (ericball) : 4/7/2009 7:25:09 PM GMT
Comments
sprite is LONG aligned (because it's after a LONG), thus the low 2 bits should be zero. What I can't figure out is why "sprite_tab.WORD := @sprite" gives a different result from "sprite_tab LONG @sprite<<16".
Although, isn't DAT statically addressed? I know VARs are dynamic and per object, but I thought DATs weren't per-object.
Anyway, I guess I will have to revise my code so the @sprite is done at runtime. A minor annoyance.