Allow setting manual clock for emu events

This commit is contained in:
Rodrigo Arias 2024-11-06 11:33:50 +01:00
parent 31e8802803
commit 73b19ca1c4
2 changed files with 14 additions and 1 deletions

View File

@ -6,10 +6,17 @@
int first_clock_set = 0; int first_clock_set = 0;
int64_t first_clock; /* First clock */ int64_t first_clock; /* First clock */
int64_t last_clock; /* Clock from the last event */ int64_t last_clock; /* Clock from the last event */
int64_t next_clock = -1; /* Clock for the next event */
int64_t get_clock(void) int64_t get_clock(void)
{ {
last_clock = (int64_t) ovni_clock_now(); if (next_clock >= 0) {
last_clock = next_clock;
next_clock = -1;
} else {
last_clock = (int64_t) ovni_clock_now();
}
if (first_clock_set == 0) { if (first_clock_set == 0) {
first_clock = last_clock; first_clock = last_clock;
first_clock_set = 1; first_clock_set = 1;
@ -18,6 +25,11 @@ int64_t get_clock(void)
return last_clock; return last_clock;
} }
void set_clock(int64_t t)
{
next_clock = t;
}
int64_t get_delta(void) int64_t get_delta(void)
{ {
return last_clock - first_clock; return last_clock - first_clock;

View File

@ -17,6 +17,7 @@ extern int64_t first_clock;
extern int64_t last_clock; extern int64_t last_clock;
int64_t get_clock(void); int64_t get_clock(void);
void set_clock(int64_t t);
int64_t get_delta(void); int64_t get_delta(void);
#define INSTR_0ARG(name, mcv) \ #define INSTR_0ARG(name, mcv) \