In
RAGE1, the tool that converts graphic sprite data to C data arrays (
datagen.pl), also generates the sprite initialization function (which is a trivial function with initialization code for all defined sprites).
Since all these numbers are known at code generation time, the generated code only contains constants, and so it avoids any calculation at runtime.
In fact, RAGE1 intends to automatically generate as much static data as possible, even with interrelated pointers, so that the amount of code for runtime calculations/initializations is minimized. I'd love to have some better documentation to even statically generate the full SP1 sprite structs, instead of having to generate code to call
sp1_AddSpr,
sp1_AddCol, etc.
If you build the RAGE1 demo game, you can check file
generated/game_data.c to see what I'm talking about:
Code: Select all
void init_screen_sprite_tables(void) {
struct sp1_ss *s; // temporary storage
// Screen 'Screen01' - Sprite initialization
map[0].sprite_data.num_sprites = 3;
// Sprite 'Ghost01'
map[0].sprite_data.sprites[0].sprite = s = sp1_CreateSpr(SP1_DRAW_MASK2LB, SP1_TYPE_2BYTE, 3, 0, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2, 0, 48, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2RB, 0, 0, 0);
SET_SPRITE_FLAG( map[0].sprite_data.sprites[0], F_SPRITE_ACTIVE );
// End of Sprite 'Ghost01'
// Sprite 'GhostPNG'
map[0].sprite_data.sprites[1].sprite = s = sp1_CreateSpr(SP1_DRAW_MASK2LB, SP1_TYPE_2BYTE, 3, 0, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2, 0, 48, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2RB, 0, 0, 0);
SET_SPRITE_FLAG( map[0].sprite_data.sprites[1], F_SPRITE_ACTIVE );
// End of Sprite 'GhostPNG'
// Sprite 'GhostPNG'
map[0].sprite_data.sprites[2].sprite = s = sp1_CreateSpr(SP1_DRAW_MASK2LB, SP1_TYPE_2BYTE, 3, 0, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2, 0, 48, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2RB, 0, 0, 0);
SET_SPRITE_FLAG( map[0].sprite_data.sprites[2], F_SPRITE_ACTIVE );
// End of Sprite 'GhostPNG'
// Screen 'Screen01' - End of Sprite initialization
// Screen 'Screen02' - Sprite initialization
map[1].sprite_data.num_sprites = 1;
// Sprite 'GhostPNG'
map[1].sprite_data.sprites[0].sprite = s = sp1_CreateSpr(SP1_DRAW_MASK2LB, SP1_TYPE_2BYTE, 3, 0, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2, 0, 48, 0 );
sp1_AddColSpr(s, SP1_DRAW_MASK2RB, 0, 0, 0);
SET_SPRITE_FLAG( map[1].sprite_data.sprites[0], F_SPRITE_ACTIVE );
// End of Sprite 'GhostPNG'
// Screen 'Screen02' - End of Sprite initialization
}