I create one function for start my routine, I pass my variables in the function:
Code: Select all
void initVarsAndGraphicsForLevel(fix32 initX, fix32 initY, Image imageBg0, Image imageBg1, SpriteDefinition spriteDef){
////////////////////////////////////////
// initialize my vars here
...
////////////////////////////////////////
u16 palette[64];
u16 ind;
// disable interrupt when accessing VDP
SYS_disableInts();
// initialization
VDP_setScreenWidth320();
// init sprites engine
SPR_init(256);
// load background
ind = TILE_USERINDEX;
VDP_drawImageEx(BPLAN, &imageBg1, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
ind += imageBg0.tileset->numTile;
VDP_drawImageEx(APLAN, &imageBg0, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
ind += imageBg1.tileset->numTile;
// VDP process done, we can re enable interrupts
SYS_enableInts();
// init sprite
SPR_initSprite(&sprites[0], &spriteDef, fix32ToInt(engineSpr_hero_X), fix32ToInt(engineSpr_hero_Y), TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
SPR_setAnim(&sprites[0], 2);
// prepare palettes
memcpy(&palette[0], imageBg1.palette->data, 16 * 2);
memcpy(&palette[16], imageBg0.palette->data, 16 * 2);
memcpy(&palette[32], spriteDef.palette->data, 16 * 2);
// fade in (disable interrupts because of the passive fade in)
SYS_disableInts();
VDP_fadeIn(0, (3 * 16) - 1, palette, 20, FALSE);
SYS_enableInts();
}
You can see below another codes.
In the gxf.h is:
Code: Select all
#ifndef _GFX_H_
#define _GFX_H_
extern const Image bgb_image;
extern const Image bga_image;
extern const SpriteDefinition heroSprites;
#endif // _GFX_H_
Code: Select all
int main(){
initVarsAndGraphicsForLevel(0, 0, bgb_image, bga_image, heroSprites);
while(1){
movingInLevel(JOY_readJoypad(JOY_1));
}
return (0);
}
Anyone have any idea what I'm doing wrong?