I finally managed to display the sprite with grief in half.
But .... it is creepy curve.
Tile is not correct.
By the way, how can specify the color that would be a video controller is perceived as an alpha channel? (in my case, black color is seen for alpha)
Code:
Code: Select all
#include <genesis.h>
struct genresTiles
{
u16 *pal; //pointer to pal data
u32 *tiles; //pointer to tiles data
u16 width; //width in tiles
u16 height; //height in tiles
u16 compressedSize; //0 in this demo, more coming soon
};
extern struct genresTiles title;
struct genresSprites
{
u16 *pal; //pointer to pal data
u32 *tiles; //pointer to sprites data
u16 width; //width of each sprite in pixels
u16 height; //height of each sprite in pixels
u16 size; //since we use width/height in pixel, useful info on sprite size
//TODO : size is not SGDK compliant, you need to use size>>8
// will be fixed in coming release
};
extern struct genresSprites bat1;
#define TILE1 1
#define SPRITE1 1
int main( )
{
SpriteDef mySprite;
u8 frame = 0;
VDP_resetSprites();
VDP_setPalette(PAL1, title.pal);
VDP_setPalette(PAL2, bat1.pal);
// load tiles in VRAM
// arg0 = tiles data
// arg1 = index for first destination tile
// arg2 = number of tiles to load
// arg3 = use DMA (1) or not (0)
VDP_loadTileData(title.tiles, TILE1, title.width*title.height, 0);
VDP_loadTileData(bat1.tiles, SPRITE1, bat1.width*bat1.height, 0);
VDP_fillTileMapRectInc(BPLAN, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 0, 0, title.width, title.height);
VDP_setSprite(0, 0, 0, bat1.size, TILE_ATTR_FULL(PAL2,1,0,0,TILE1), 1 /* 0 */);
// define the sprite (using a _spritedef to easily make Sonic move later)
// define the sprite (using a _spritedef to easily make Sonic move later)
mySprite.posx = 100;
mySprite.posy = 100;
// mySprite.size = bat1.size>>8;
mySprite.tile_attr = TILE_ATTR_FULL(PAL2,1,0,0,1);
mySprite.link = 0;
// VDP_setSpriteP(0, &mySprite);
while(1)
{
mySprite.posx++;
if( mySprite.posx>250) mySprite.posx=0;
VDP_setSpriteP(0, &mySprite);
VDP_updateSprites();
VDP_waitVSync();
}
return 0;
}
Stef wrote:
The advantage of the new rescomp : it has more integrated with SGDK, you have many advanced methods to draw image and display sprite easily.
the fact that in the examples as a sample used multiple sprites in one bmp-file.
It is quite difficult. Firstly, work with pointers to the display area of bmp-file. Secondly, the complex process of constructing such a texture (so accurately position each sprite in a single file).
Much easier it would be (for a beginner like me), if for each sprite was a separate bmp-file