Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array of addresses
#1
I'm trying to make an array of sprite pointers.

The compiler doesn't seem to like

Code:
DIM Sprites(5) AS uInteger => {@sprite1,@sprite2,@sprite3,@sprite4,@sprite5,@sprite6}

And I'm not quite sure why. It reports the error: Initializer expression is not constant. - and I beg to differ. I thought @label WAS a constant?
Reply
#2
britlion Wrote:I'm trying to make an array of sprite pointers.

The compiler doesn't seem to like

Code:
DIM Sprites(5) AS uInteger => {@sprite1,@sprite2,@sprite3,@sprite4,@sprite5,@sprite6}

And I'm not quite sure why. It reports the error: Initializer expression is not constant. - and I beg to differ. I thought @label WAS a constant?
The compiler does not currently support this. Sorry. It's constant, as you say, but hard to know in compiler-time. Think of how will you code this array in asm:
Code:
__Sprites:
...
...
Db _sprite1????
Even the assembler does not support this (yet). There should be a mechanism to make a DB/DW to contain an expression. I will have a look on it, but it will be for version 1.2.7 or newer. 1.2.6 needs to be closed. Only bitwise operations are still pending...
Reply
#3
Understood.

I'm surprised that nobody has put this functionality to do this in standard assemblers for decades, though. I can't be the only person that thinks doing

Code:
for n=0 to frames
putsprite(spriteframes(n))
next n

Or something that's conceptually similar, is a cunning way to do sprite animations..

I suppose, since sprites are of a fixed size, people have always treated them as vectors and calculated the pointers from a base..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)