Code: Select all
// i assume you use WaitVsync(1), so the fps is set to 60, so set the counter to 60
#define FPS_SEC 60
unsigned int counter_one_sec = FPS_SEC; //the actual counter variable
int main(){
ClearVram();
while(1) {
WaitVsync(1); //needed for the counter to work properly
if (counter_one_sec < 1) {
//do the stuff you like every second
//reset the value on the counter, it is advisable to keep it in here to re-run it every second
//use this elsewhere in your code to actually create an alarm that goes off 1 second after the event happened
counter_one_sec = FPS_SEC;
}
//decrease the value by 1 if it's more than 0
if (counter_one_sec > 0)
counter_one_sec--;
}
}
}