For the complete documentation index, see llms.txt. This page is also available as Markdown.

Timing without blocking loops

Use state plus elapsed button timing or a countdown advanced by the runtime cycle source available under your approved API boundary. Do not spin in a loop waiting for real time:

timing-without-blocking.gpc
enum { TIMER_IDLE, TIMER_WAIT_RELEASE };
int timer_state;

main {
    if(timer_state == TIMER_IDLE) {
        if(event_press(PS5_CROSS)) timer_state = TIMER_WAIT_RELEASE;
    } else if(timer_state == TIMER_WAIT_RELEASE) {
        if(event_release(PS5_CROSS)) timer_state = TIMER_IDLE;
    }
}

For elapsed-time accumulation, add get_rtime() each cycle rather than assuming a fixed loop interval. This remains correct when vm_tctrl changes the next iteration timing.

Last updated