PVcollib  1.5.0
A devkit for ColecoVision
graphics/sprites/animatedsprite/animatedsprite.c
/*---------------------------------------------------------------------------------
animated sprite demo
-- alekmaul
---------------------------------------------------------------------------------*/
#include "animatedsprite.h"
#include "gfxs.h" // to add definition of graphics
//---------------------------------------------------------------------------------
// The NMI routine. Gets called 50 or 60 times per second
// nothing to update for bitmap example
void nmi (void) {
// update sprite display during nmi, if you enable sprites
}
//---------------------------------------------------------------------------------
void main (void) {
u8 xp,yp,idpac,tpo;
u16 pattern;
// Put screen in text mode 2
// Put default char in VRAM and duplicate to all areas
// as we are going to write to line 10, it is in the second area
vdp_setdefaultchar(FNTNORMAL);
vdp_fillvram(0x2000,0xf1,128*8); // Change color (or we will see nothing)
// Put sprite character
vdp_putvram (sprtab,TILpacspritegfx,SZTILpacspritegfx); // sprite characters
// Put sprite in middle of screen with color light yellow, 0 because we have only one pattern (index 0)
xp=8*16;yp=8*12;pattern=0;
idpac=spr_getentry();
spr_set(idpac,xp,yp,11,pattern);
tpo=0;
// enable sprite display
// Wait for nothing :P
while(1) {
if (joypad_1 & PAD_RIGHT) {
if (xp<(256-16)) { xp++; spr_setx(idpac,xp); }
}
if (joypad_1 & PAD_LEFT) {
if (xp>0) { xp--; spr_setx(idpac,xp); }
}
if (joypad_1 & PAD_DOWN) {
if (yp<(192-16)) { yp++; spr_sety(idpac,yp); }
}
if (joypad_1 & PAD_UP) {
if (yp>0) { yp--; spr_sety(idpac,yp); }
}
// manage sprite pattern with little tempo
tpo++;
if (tpo>3) {
tpo=0;
pattern+=4;
if (pattern>4*3) pattern=0;
spr_setpat(idpac,pattern);
}
// Wait Vblank
}
// startup module will issue a soft reboot if it comes here
}