Not yet victory, but likely not too far.
My sprite is displayed, I can move it but... only the first tile appears (whereas it's a 2x2 tiles sprite). I checked, and the 4 tiles are loaded in VRAM.
Here's where my sprite is defined (sorry for the weird names, it's software generated) :
Code: Select all
#include <genesis.h>
u16 const pal_sprites[16] = {
0xDB9, 0x000, 0xEEE, 0x8D4, 0x38D, 0x000, 0x000, 0x000,
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000
};
Palette palette_sprites = {
0, // index
16, // size
pal_sprites // color data
};
u32 const down_0_tiledata_00[32] = {
0x44444333,
0x44443333,
0x44443223,
0x44433222,
0x44432212,
0x44432212,
0x44432244,
0x44334444,
0x44333444,
0x43333222,
0x43333222,
0x33343222,
0x44442222,
0x44442222,
0x44444442,
0x44444444,
0x33444444,
0x33344444,
0x22344444,
0x22234444,
0x12234444,
0x12234444,
0x42333344,
0x44433334,
0x44333333,
0x22233444,
0x22223444,
0x22222444,
0x22222444,
0x22244444,
0x24444444,
0x44444444
};
TileSet down_0_tileset_00 = {
COMPRESSION_NONE, // compression
4, // number of tiles
down_0_tiledata_00 // tiledata
};
FrameSprite down_0_fsprite_00 = {
// VDPSprite
{
0, // y pos
SPRITE_SIZE(2, 2), // size_link (2x2 tiles here)
TILE_ATTR_FULL(FALSE, PAL0, FALSE, FALSE, 0), // tile attributs
0 // x pos
},
// TileSet*
&down_0_tileset_00
} ;
FrameSprite* down_0_sprites[] = {
&down_0_fsprite_00
};
AnimationFrame down_0 = {
1, // number of sprites
&down_0_sprites, // sprite array
0, // number of collision
NULL, // collision array
16, // width of current animation frame in pixel
16, // height of current animation frame in pixel
COLLISION_TYPE_NONE, // collision type
1, // time to keep this frame in number of frame
};
AnimationFrame* down_frames[] = {
&down_0
};
u8* down_seqframes[] = {0} ;
Animation down = {
1, // number of frames
&down_frames, // frames composing the animation
1, // animation sequence length
&down_seqframes, // animation sequence,
-1, // loop (-1 if no loop)
};
Animation* gurin_animations[] = {
&down
};
SpriteDefinition gurin_sprite = {
&palette_sprites, // palette (NULL because manually handled)
1, // number of animations
&gurin_animations, // animations
};
The main code (just a copy/paste/delete from sample/sprite to simplify) :
Code: Select all
#include <genesis.h>
#include "gurin.h"
#define ANIM_STAND 0
#define ANIM_UP 1
#define ANIM_DOWN 2
#define ANIM_LEFT 3
#define ANIM_RIGHT 4
// forward
static void updatePhysic();
static void updateAnim();
// sprites structure
Sprite sprites[1];
u16 posx;
u16 posy;
u16 movx;
u16 movy;
int main()
{
// disable interrupt when accessing VDP
SYS_disableInts();
// initialization
VDP_setScreenWidth320();
// init sprites engine
SPR_init(256);
// VDP process done, we can re enable interrupts
SYS_enableInts();
posx = 160;
posy = 160;
movx = 1;
movy = 0;
// init sprite
SPR_initSprite(&sprites[0],
&gurin_sprite,
posx,
posy,
TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
SPR_update(sprites, 1);
// prepare palettes
//memcpy(&palette[0], palette_sprites, 16 * 2);
VDP_setPaletteColors(0, pal_sprites, 16);
while(TRUE)
{
updatePhysic();
updateAnim();
// update sprites (only one to update here)
SPR_update(sprites, 1);
VDP_waitVSync();
}
return 0;
}
static void updatePhysic()
{
// set sprite position
posx++ ;
SPR_setPosition(&sprites[0],
posx,
posy);
}
static void updateAnim()
{
SPR_setAttribut(&sprites[0], TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
}
Note : yes, I know it's kinda stupid to use the sprite engine for a Sprite that is made of only one FrameSprite, but that's only a test.