From 2c111fd98cae78a054c3703d7aa238fb54d50d39 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 17 Jun 2024 13:48:18 +0200 Subject: [PATCH] Add ovni_mark_set() to the API Allows emitting a single event to change the value of the mark channel. The mark type must be defined as single without the MARK_FLAG_STACK flag. --- include/ovni.h.in | 1 + src/emu/ovni/mark.c | 2 ++ src/emu/ovni/setup.c | 1 + src/rt/ovni.c | 11 +++++++++++ 4 files changed, 15 insertions(+) diff --git a/include/ovni.h.in b/include/ovni.h.in index 067e97f..6844855 100644 --- a/include/ovni.h.in +++ b/include/ovni.h.in @@ -150,6 +150,7 @@ void ovni_mark_type(int32_t type, long flags, const char *title); void ovni_mark_label(int32_t type, int64_t value, const char *label); void ovni_mark_push(int32_t type, int64_t value); void ovni_mark_pop(int32_t type, int64_t value); +void ovni_mark_set(int32_t type, int64_t value); #ifdef __cplusplus } diff --git a/src/emu/ovni/mark.c b/src/emu/ovni/mark.c index 792011f..89d6c68 100644 --- a/src/emu/ovni/mark.c +++ b/src/emu/ovni/mark.c @@ -478,6 +478,8 @@ mark_event(struct emu *emu) return chan_push(ch, value_int64(value)); case ']': return chan_pop(ch, value_int64(value)); + case '=': + return chan_set(ch, value_int64(value)); default: err("unknown mark event value %c", emu->ev->v); return -1; diff --git a/src/emu/ovni/setup.c b/src/emu/ovni/setup.c index 7e56f26..32b1980 100644 --- a/src/emu/ovni/setup.c +++ b/src/emu/ovni/setup.c @@ -40,6 +40,7 @@ static struct ev_decl model_evlist[] = { { "OM[(i64 value, i32 type)", "push mark with value %{value} from type %{type}" }, { "OM](i64 value, i32 type)", "pop mark with value %{value} from type %{type}" }, + { "OM=(i64 value, i32 type)", "set mark with value %{value} from type %{type}" }, { NULL, NULL }, }; diff --git a/src/rt/ovni.c b/src/rt/ovni.c index cab83eb..d36c87f 100644 --- a/src/rt/ovni.c +++ b/src/rt/ovni.c @@ -1154,3 +1154,14 @@ ovni_mark_pop(int32_t type, int64_t value) ovni_payload_add(&ev, (uint8_t *) &type, sizeof(type)); ovni_ev_add(&ev); } + +void +ovni_mark_set(int32_t type, int64_t value) +{ + struct ovni_ev ev = {0}; + ovni_ev_set_clock(&ev, ovni_clock_now()); + ovni_ev_set_mcv(&ev, "OM="); + ovni_payload_add(&ev, (uint8_t *) &value, sizeof(value)); + ovni_payload_add(&ev, (uint8_t *) &type, sizeof(type)); + ovni_ev_add(&ev); +}