|
|
@@ -5,6 +5,7 @@ |
|
|
#include "helpers.h" |
|
|
#include "ops/op.h" |
|
|
#include "teletype.h" |
|
|
#include "teletype_io.h" |
|
|
|
|
|
|
|
|
static void op_LAST_get(const void *data, scene_state_t *ss, exec_state_t *es, |
|
|
@@ -25,6 +26,14 @@ static void op_I_get(const void *data, scene_state_t *ss, exec_state_t *es, |
|
|
command_state_t *cs); |
|
|
static void op_I_set(const void *data, scene_state_t *ss, exec_state_t *es, |
|
|
command_state_t *cs); |
|
|
static void op_TIME_get(const void *data, scene_state_t *ss, exec_state_t *es, |
|
|
command_state_t *cs); |
|
|
static void op_TIME_set(const void *data, scene_state_t *ss, exec_state_t *es, |
|
|
command_state_t *cs); |
|
|
static void op_TIME_ACT_get(const void *data, scene_state_t *ss, exec_state_t *es, |
|
|
command_state_t *cs); |
|
|
static void op_TIME_ACT_set(const void *data, scene_state_t *ss, exec_state_t *es, |
|
|
command_state_t *cs); |
|
|
|
|
|
// clang-format off |
|
|
const tele_op_t op_A = MAKE_SIMPLE_VARIABLE_OP(A , variables.a ); |
|
|
@@ -39,8 +48,8 @@ const tele_op_t op_O_MAX = MAKE_SIMPLE_VARIABLE_OP(O.MAX , variables.o_ |
|
|
const tele_op_t op_O_MIN = MAKE_SIMPLE_VARIABLE_OP(O.MIN , variables.o_min ); |
|
|
const tele_op_t op_O_WRAP = MAKE_SIMPLE_VARIABLE_OP(O.WRAP , variables.o_wrap ); |
|
|
const tele_op_t op_T = MAKE_SIMPLE_VARIABLE_OP(T , variables.t ); |
|
|
const tele_op_t op_TIME = MAKE_SIMPLE_VARIABLE_OP(TIME , variables.time ); |
|
|
const tele_op_t op_TIME_ACT = MAKE_SIMPLE_VARIABLE_OP(TIME.ACT , variables.time_act ); |
|
|
const tele_op_t op_TIME = MAKE_GET_SET_OP(TIME, op_TIME_get, op_TIME_set, 0, true); |
|
|
const tele_op_t op_TIME_ACT = MAKE_GET_SET_OP(TIME.ACT, op_TIME_ACT_get, op_TIME_ACT_set, 0, true); |
|
|
const tele_op_t op_LAST = MAKE_GET_OP(LAST , op_LAST_get, 1, true); |
|
|
const tele_op_t op_X = MAKE_SIMPLE_VARIABLE_OP(X , variables.x ); |
|
|
const tele_op_t op_Y = MAKE_SIMPLE_VARIABLE_OP(Y , variables.y ); |
|
|
@@ -52,6 +61,34 @@ const tele_op_t op_O = MAKE_GET_SET_OP(O , op_O_get , op_O_set , 0, |
|
|
const tele_op_t op_I = MAKE_GET_SET_OP(I , op_I_get, op_I_set, 0, true); |
|
|
// clang-format on |
|
|
|
|
|
static void op_TIME_get(const void *NOTUSED(data), scene_state_t *ss, |
|
|
exec_state_t *NOTUSED(es), command_state_t *cs) { |
|
|
int64_t delta = ss->variables.time_act ? |
|
|
tele_get_ticks() - ss->variables.time : ss->variables.time; |
|
|
cs_push(cs, delta & 0x7fff); |
|
|
} |
|
|
|
|
|
static void op_TIME_set(const void *NOTUSED(data), scene_state_t *ss, |
|
|
exec_state_t *NOTUSED(es), command_state_t *cs) { |
|
|
int16_t new_time = cs_pop(cs); |
|
|
ss->variables.time = ss->variables.time_act ? |
|
|
tele_get_ticks() - new_time : new_time; |
|
|
} |
|
|
|
|
|
static void op_TIME_ACT_get(const void *NOTUSED(data), scene_state_t *ss, |
|
|
exec_state_t *NOTUSED(es), command_state_t *cs) { |
|
|
cs_push(cs, ss->variables.time_act ? 1 : 0); |
|
|
} |
|
|
|
|
|
static void op_TIME_ACT_set(const void *NOTUSED(data), scene_state_t *ss, |
|
|
exec_state_t *NOTUSED(es), command_state_t *cs) { |
|
|
int16_t act = cs_pop(cs); |
|
|
if (act && ss->variables.time_act) return; |
|
|
if (!act && !ss->variables.time_act) return; |
|
|
ss->variables.time_act = act ? 1 : 0; |
|
|
ss->variables.time = tele_get_ticks() - ss->variables.time; |
|
|
} |
|
|
|
|
|
static void op_LAST_get(const void *NOTUSED(data), scene_state_t *ss, |
|
|
exec_state_t *NOTUSED(es), command_state_t *cs) { |
|
|
int16_t script_number = cs_pop(cs) - 1; |
|
|
|