sverx / devkitSMS

development kit and libraries for SEGA Master System / SEGA Game Gear / SEGA SG-1000 / SEGA SC-3000 homebrew programming using C language (and the SDCC compiler)
224 stars 34 forks source link

Tile Id Offset Meta Sprite Feature Request #65

Closed xfixium closed 3 months ago

xfixium commented 4 months ago

I don't know if this has been implemented yet, or exists. Say a metasprite has been defined eg:

// Frame 0 of multi framed sprite, for entity with loads of states, but tiles may be located differently for each instance: const unsigned char sprite_00[] = { 0, 0, 0, 8, 0, 2, 16, 0, 4, 0, 16, 6, 8, 16, 8, 16, 16, 10, 0, 32, 12, 8, 32, 14, METASPRITE_END };

Is there a way to offset the tile id, so that the tile id starts with the array tile id + offset?

Sort of like: SMS_addMetaSprite(x, y, [offset], sprite_00);

Where [offset] would be applied to the defined tile id for each sprite.

sverx commented 4 months ago

Quite recently in fact I hacked in something along that line, but you need to recompile the library adding the METASPRITE_DELTA_TILES define to the compilation. Then the offset can be stored into the MetaSpriteBaseTile variable (unsigned char) and the SMS_addMetaSprite function will then work the way you expect. You can see this in the code here.

xfixium commented 4 months ago

Oh very nice, that should do it!