Using output_time to synchronize inputs to game

GPC2 script programming for Titan Two. Code examples, questions, requests.

Using output_time to synchronize inputs to game

Postby Clipstaed » Sun Mar 10, 2024 1:41 pm

At https://www.consoletuner.com/wiki/index.php?id=t2:output_time it says, "This time information can help synchronize inputs, combos and macros with the game frame rate." Can anyone give a simple example that shows this synchronization idea?

I am having trouble with getting a combo to work well on a NTSC console, but I don't know how to use output_time to improve it. Right now I am trying to use:

Code: Select all
#define frames(a) ((int16)(round(16.68335 * (fix32)a)))
wait(frames(1));

to space button presses out by console frames instead of milliseconds, but it doesn't seem to help.
User avatar
Clipstaed
Corporal
Corporal
 
Posts: 4
Joined: Sun Mar 10, 2024 1:18 pm

Re: Using output_time to synchronize inputs to game

Postby Clipstaed » Thu Mar 14, 2024 12:06 pm

Does someone know something about this? The problem is that the example from the documentation page does not seem to work:

Code: Select all
main {
    if(get_val(BUTTON_2)) {
        if(output_time() == 0) {
            macro_run("Example.gmk");
        }
    }
}


I think what output_time() is supposed to mean is "how much time has gone since console polled for input?" I can see how this can be useful to synchronize with a console which polls for input aligned with a game framerate (though why the game framerate would be the same to the console poll rate is another mystery.)

But this idea can't seem to be experimented because most of the time when you press the button, nothing happens. Rather than "wait until output_time() is 0 so we are always aligned, then go!", it seems to ask "is output_time() at 0? no? i guess just do nothing, haha" and most inputs are ignored.

get_actual(), get_val(), is_active(), check_active(), event_active() all seem to have the same result. Most inputs are ignored because output_time() is not 0, though rarely everything aligns and the input can happen.

How can it be correctly used?
User avatar
Clipstaed
Corporal
Corporal
 
Posts: 4
Joined: Sun Mar 10, 2024 1:18 pm

Re: Using output_time to synchronize inputs to game

Postby Scachi » Thu Mar 14, 2024 3:56 pm

Hold down the button until the macro starts or add a flag on event_active to start it and reset the flag when output_time is 0.

Untested code:
Code: Select all
bool start;
 
main {
    if(event_active(BUTTON_2)) start = TRUE;
 
    if (start && output_time() == 0) {
        start = FALSE;
        macro_run("Example.gmk");
    }
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 190 guests