// react to joypad presses
while(1)
{
waitVSync();
countdown++;
if (countdown>60){
countdown=0;
imgNew++;
}
// copy current index
imgNew = imgCurrent;
if (!(PADREG & PAD_RIGHT)) imgNew++;
if (!(PADREG & PAD_LEFT)) imgNew--;
// wrap around if neccesary
imgNew = (imgNew+imgCount) %imgCount;
// copy image
if (imgNew != imgCurrent)
{
copyImage(pScreen, imageinfo.list->start[imgNew]);
imgCurrent = imgNew;
// wait keyDelay frames
for(keyDelayCount = keyDelay; keyDelayCount > 0; keyDelayCount--)
{
// next time use shorter delay
keyDelay = KEYREPEATDELAY;
waitVSync();
// both keys are released ?
if ((PADREG & PAD_RIGHT) && (PADREG & PAD_LEFT))
{
// use initial delay
keyDelay = KEYWAITDELAY;
// break from loop
break;
}
}
countdown=0;
}
}
}Something like this-ish maybe a little bit? Note that I've shuffled things around a bit, so copy all of the code as is.
You also need to declare the countdown variable (or technically countup) somewhere near the start of the function. This is where all the other variables are defined.
int countdown;The time taken waited between each frame image is controlled by "if (countdown>60){". 60 here means 60 frames, which is one second.
