66 if (loopCounter == 0) {
71 if (loopCounter >= -10000000) {
79 if (loopCounter != 0) {
103 if (script->functionTemp[0] == 0) {
107 script->functionTemp[0] -= 1;
108 return !script->functionTemp[0];
119 if (script->functionTemp[0] == 0) {
123 script->functionTemp[0]--;
124 return !script->functionTemp[0];
260 s32 switchBlockValue;
270 }
else if (var != switchBlockValue) {
283 s32 switchBlockValue;
293 }
else if (var == switchBlockValue) {
306 s32 switchBlockValue;
316 }
else if (var <= switchBlockValue) {
329 s32 switchBlockValue;
339 }
else if (var < switchBlockValue) {
352 s32 switchBlockValue;
362 }
else if (var >= switchBlockValue) {
375 s32 switchBlockValue;
385 }
else if (var > switchBlockValue) {
399 s32 switchBlockValue;
411 }
else if ((var <= switchBlockValue) && (switchBlockValue <= var2)) {
439 s32 switchBlockValue;
440 s32 switchBlockState;
448 if (switchBlockState <= 0) {
451 }
else if ((var & switchBlockValue) == 0) {
464 s32 switchBlockValue;
465 s32 switchBlockState;
473 if (switchBlockState == 0) {
476 }
else if (var == switchBlockValue) {
478 }
else if (switchBlockState != -1) {
489 s32 switchBlockValue;
490 s32 switchBlockState;
498 if (switchBlockState == 0) {
501 }
else if (switchBlockState == -2) {
503 }
else if (var == switchBlockValue) {
549 s32 curPtrReadPos = *args++;
586 result = minuend - result;
598 result *= multiplier;
610 result = dividend / result;
622 result = num % result;
646 result = minuend - result;
658 result *= multiplier;
670 result = dividend / result;
894 isInitialCall = FALSE;
896 ret = func(script, isInitialCall);
902 isInitialCall = TRUE;
904 ret = func(script, isInitialCall);
922 for (i = 0; i <
ARRAY_COUNT(script->varTable); i++) {
923 newScript->varTable[i] = script->varTable[i];
949 for (i = 0; i <
ARRAY_COUNT(script->varTable); i++) {
950 newScript->varTable[i] = script->varTable[i];
995 script->varTable[0] = trigger->varTable[0];
996 script->varTable[1] = trigger->varTable[1];
997 script->varTable[2] = trigger->varTable[2];
998 script->
owner2.trigger = trigger;
1015 Bytecode hasInteractPrompt = *args++;
1034 if (triggerOut != 0) {
1115 newScript->varTable[0] = trigger->varTable[0];
1116 newScript->varTable[1] = trigger->varTable[1];
1117 newScript->varTable[2] = trigger->varTable[2];
1118 newScript->
owner2.trigger = trigger;
1123 trigger->
flags &= ~TRIGGER_ACTIVATED;
1135 s32 hasInteractPrompt = *args++;
1167 opcode = *endLine++;
1179 for (i = 0; i <
ARRAY_COUNT(script->varTable); i++) {
1180 newScript->varTable[i] = script->varTable[i];
1204 opcode = *endLine++;
1243 flagBitPos = var % 32;
1249 arrayVal = script->
array[var];
1292 flagBitPos = var % 32;
1296 flagBitPos = var % 32;
1315 tableVar = script->varTable[var];
1352 s32 commandsExecuted = 0;
1360 ASSERT_MSG(commandsExecuted < 10000,
"Script %x is blocking for ages (infinite loop?)", script->
ptrFirstLine);
1371 lines = &lines[nargs];
1705 var = (script->
flagArray[wordIdx] & (1 << bitIdx)) != 0;
1709 var = script->
array[var];
1731 var = (
gMapFlags[wordIdx / 32] & (1 << bitIdx)) != 0;
1737 var = (script->
varFlags[wordIdx / 32] & (1 << bitIdx)) != 0;
1750 var = script->varTable[var];
1857 flagBitPos = var % 32;
1859 script->
flagArray[var / 32] |= 1 << flagBitPos;
1861 script->
flagArray[var / 32] &= ~(1 << flagBitPos);
1866 oldValue = script->
array[var];
1867 script->
array[var] = value;
1899 flagBitPos = var % 32;
1903 gMapFlags[var / 32] &= ~(1 << flagBitPos);
1908 flagBitPos = var % 32;
1910 script->
varFlags[var / 32] |= 1 << flagBitPos;
1912 script->
varFlags[var / 32] &= ~(1 << flagBitPos);
1922 oldValue = script->varTable[var];
1923 script->varTable[var] = value;
1951 var =
gMapFlags[var / 32] & (1 << temp);
1960 var = script->
varFlags[var / 32] & (1 << temp);
1987 oldValue = script->
array[var];
2003 script->
varFlags[var / 32] |= 1 << temp;
2005 script->
varFlags[var / 32] &= ~(1 << temp);
2015 oldValue = script->varTable[var];
2043 s32 nestedIfDepth = 0;
2058 if (nestedIfDepth < 0) {
2073 if (nestedIfDepth == 0) {
2082 s32 nestedIfDepth = 0;
2097 if (nestedIfDepth < 0) {
2130 s32 switchDepth = 1;
2149 if (switchDepth == 0) {
2158 s32 switchDepth = 1;
2177 if (switchDepth == 0) {
2192 if (switchDepth == 1) {
2217 if (loopDepth < 0) {
void * labelPositions[16]
union Evt::@8 owner1
Initially -1.
union Evt::@9 owner2
Initially -1.
ApiStatus(* ApiFunc)(struct Evt *, s32)
#define ASSERT(condition)
@ DEBUG_SCRIPTS_BLOCK_FUNC_DONE
ApiStatus func_802C739C(Evt *script)
ApiStatus evt_handle_OR(Evt *script)
ApiStatus func_802C73B0(Evt *script)
ApiStatus evt_handle_set_int_buffer_ptr(Evt *script)
ApiStatus evt_handle_break_loop(Evt *script)
s32 evt_get_variable_index(Evt *script, s32 var)
Bytecode * evt_skip_if(Evt *script)
ApiStatus evt_handle_AND(Evt *script)
ApiStatus evt_handle_set_float(Evt *script)
s32 evt_get_variable(Evt *script, Bytecode var)
ApiStatus evt_handle_switch_const(Evt *script)
ApiStatus evt_handle_call(Evt *script)
ApiStatus evt_handle_case_greater(Evt *script)
ApiStatus evt_handle_end_thread(Evt *script)
ApiStatus evt_handle_case_equal_OR(Evt *script)
ApiStatus evt_handle_get_3_word(Evt *script)
ApiStatus evt_handle_divideF(Evt *script)
ApiStatus evt_handle_multiply(Evt *script)
ApiStatus evt_handle_switch(Evt *script)
char evtDebugPrintBuffer[0x100]
ApiStatus evt_handle_AND_const(Evt *script)
ApiStatus evt_handle_break_case(Evt *script)
Bytecode * evt_goto_end_case(Evt *script)
ApiStatus evt_handle_jump(Evt *script)
Bytecode * evt_skip_else(Evt *script)
ApiStatus evt_handle_suspend_all(Evt *script)
ApiStatus evt_handle_case_less(Evt *script)
ApiStatus evt_handle_set_timescale(Evt *script)
ApiStatus evt_handle_set_const(Evt *script)
ApiStatus evt_handle_subtract(Evt *script)
ApiStatus evt_handle_if_greater(Evt *script)
ApiStatus evt_handle_exec_wait(Evt *script)
f32 evt_set_float_variable(Evt *script, Bytecode var, f32 value)
ApiStatus evt_handle_set_array(Evt *script)
Bytecode * EvtCallingLine
Bytecode * evt_goto_next_case(Evt *script)
ApiStatus evt_handle_if_less(Evt *script)
ApiStatus evt_handle_case_default(Evt *script)
ApiStatus evt_handle_exec1(Evt *script)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
ApiStatus evt_handle_add(Evt *script)
ApiStatus evt_handle_loop(Evt *script)
ApiStatus evt_handle_return(Evt *script)
Bytecode * evt_goto_end_loop(Evt *script)
ApiStatus evt_handle_mod(Evt *script)
ApiStatus evt_handle_thread(Evt *script)
s32 evt_get_variable_index_alt(s32 var)
s32 evt_trigger_on_activate_lock(Trigger *trigger)
ApiStatus evt_handle_case_equal_AND(Evt *script)
ApiStatus evt_handle_case_range(Evt *script)
Bytecode evt_float_to_fixed_var(f32 value)
ApiStatus evt_handle_goto(Evt *script)
s32 evt_trigger_on_activate_exec_script(Trigger *trigger)
ApiStatus evt_handle_OR_const(Evt *script)
ApiStatus evt_handle_bind(Evt *script)
ApiStatus evt_handle_print_debug_var(Evt *script)
ApiStatus evt_handle_set_var(Evt *script)
ApiStatus evt_handle_get_4_word(Evt *script)
ApiStatus evt_handle_unbind(Evt *script)
ApiStatus evt_handle_bind_lock(Evt *script)
ApiStatus evt_handle_if_not_equal(Evt *script)
ApiStatus evt_handle_get_1_float(Evt *script)
ApiStatus evt_handle_if_less_equal(Evt *script)
ApiStatus evt_handle_end_loop(Evt *script)
ApiStatus evt_handle_debug_log(Evt *script)
ApiStatus func_802C73B8(Evt *script)
s32 evt_execute_next_command(Evt *script)
ApiStatus evt_handle_get_Nth_word(Evt *script)
ApiStatus evt_handle_exec1_get_id(Evt *script)
ApiStatus evt_handle_case_AND(Evt *script)
ApiStatus evt_handle_subtractF(Evt *script)
ApiStatus evt_handle_set_flag_array(Evt *script)
ApiStatus evt_handle_set_float_buffer_ptr(Evt *script)
ApiStatus evt_handle_end_child_thread(Evt *script)
ApiStatus evt_handle_end_case_group(Evt *script)
ApiStatus evt_handle_get_Nth_float(Evt *script)
ApiStatus evt_handle_addF(Evt *script)
ApiStatus evt_handle_get_1_word(Evt *script)
ApiStatus evt_handle_set_priority(Evt *script)
ApiStatus evt_handle_suspend(Evt *script)
ApiStatus evt_handle_get_2_float(Evt *script)
ApiStatus evt_handle_case_less_equal(Evt *script)
ApiStatus evt_handle_get_2_word(Evt *script)
ApiStatus evt_handle_end_switch(Evt *script)
ApiStatus evt_handle_if_greater_equal(Evt *script)
ApiStatus evt_handle_resume_all(Evt *script)
ApiStatus evt_handle_if_equal(Evt *script)
f32 evt_fixed_var_to_float(Bytecode scriptVar)
ApiStatus evt_handle_child_thread(Evt *script)
f32 evt_get_float_variable(Evt *script, Bytecode var)
ApiStatus evt_handle_case_equal(Evt *script)
ApiStatus evt_handle_get_3_float(Evt *script)
ApiStatus evt_handle_does_script_exist(Evt *script)
Bytecode * evt_find_label(Evt *script, s32 arg1)
ApiStatus evt_handle_else(Evt *script)
ApiStatus evt_handle_set_group(Evt *script)
ApiStatus evt_handle_multiplyF(Evt *script)
ApiStatus evt_handle_resume(Evt *script)
ApiStatus evt_handle_if_not_AND(Evt *script)
ApiStatus evt_handle_end_if(Evt *script)
ApiStatus evt_handle_kill(Evt *script)
ApiStatus evt_handle_resume_others(Evt *script)
ApiStatus evt_handle_if_AND(Evt *script)
ApiStatus evt_handle_wait_seconds(Evt *script)
ApiStatus evt_handle_wait(Evt *script)
ApiStatus evt_handle_case_not_equal(Evt *script)
ApiStatus evt_handle_get_4_float(Evt *script)
ApiStatus evt_handle_label(Evt *script)
ApiStatus evt_handle_case_greater_equal(Evt *script)
ApiStatus evt_handle_suspend_others(Evt *script)
ApiStatus evt_handle_allocate_array(Evt *script)
ApiStatus evt_handle_divide(Evt *script)
@ EVT_OP_LOOP
Args: number of repeats (0 = infinite)
@ EVT_OP_EXEC_GET_TID
Args: EvtScript*, container.
@ EVT_OP_MOD
Args: container, expression to divide by.
@ EVT_OP_FBUF_READ2
Args: container.
@ EVT_OP_UNBIND
Unbinds any triggers bound to this script.
@ EVT_OP_ADDF
Args: container, expression to increment by.
@ EVT_OP_FBUF_READ3
Args: container, container.
@ EVT_OP_SET_PRIORITY
Args: priority.
@ EVT_OP_DIVF
Args: container, expression to divide by.
@ EVT_OP_CASE_FLAG
Args: expression to test for.
@ EVT_OP_MULF
Args: container, expression to multiply by.
@ EVT_OP_SUSPEND_OTHERS
Args: group.
@ EVT_OP_SUSPEND_THREAD
Args: ScriptID.
@ EVT_OP_GOTO
Args: index.
@ EVT_OP_EXEC
Args: EvtScript*.
@ EVT_OP_USE_ARRAY
Args: *s32.
@ EVT_OP_MUL
Args: container, expression to multiply by.
@ EVT_OP_END_CASE_GROUP
Ends the case block of EVT_OP_CASE_OR_EQ condition(s).
@ EVT_OP_IF_LE
Args: a, b.
@ EVT_OP_IF_FLAG
Args: a, b.
@ EVT_OP_SET
Args: container, expression.
@ EVT_OP_IF_NE
Args: a, b.
@ EVT_OP_CASE_EQ
Args: expression to test for.
@ EVT_OP_BITWISE_OR_CONST
Args: container, value to bitwise OR with.
@ EVT_OP_USE_FBUF
Identical to USE_BUFFER. Args: f32*.
@ EVT_OP_SETF
Args: container, expression.
@ EVT_OP_CHILD_THREAD
Parallel threads are killed as soon as the parent script returns.
@ EVT_OP_CASE_GE
Args: expression to test for.
@ EVT_OP_IF_GT
Args: a, b.
@ EVT_OP_CASE_OR_EQ
Args: expression to test for.
@ EVT_OP_END_CHILD_THREAD
@ EVT_OP_DEBUG_PRINT_VAR
Args: expression.
@ EVT_OP_BUF_READ3
Args: container, container.
@ EVT_OP_DIV
Integer division. Args: container, expression to divide by.
@ EVT_OP_EXEC_WAIT
Spawns a script and waits for it to return before continuing. Args: EvtScript*.
@ EVT_OP_BUF_READ4
Args: container, container, container.
@ EVT_OP_ADD
Args: container, expression to increment by.
@ EVT_OP_FBUF_READ4
Args: container, container, container.
@ EVT_OP_SET_TIMESCALE
Args: timescale.
@ EVT_OP_USE_BUF
Args: s32*.
@ EVT_OP_USE_FLAGS
Args: *s32.
@ EVT_OP_CASE_RANGE
Args: from, to.
@ EVT_OP_BITWISE_AND_CONST
Args: container, value to bitwise AND with.
@ EVT_OP_SUBF
Args: container, expression to decrement by.
@ EVT_OP_JUMP
Args: EvtScript*.
@ EVT_OP_CASE_AND_EQ
Args: expression to test for.
@ EVT_OP_SWITCH
Args: expression to test against.
@ EVT_OP_CASE_LE
Args: expression to test for.
@ EVT_OP_SUB
Args: container, expression to decrement by.
@ EVT_OP_IF_GE
Args: a, b.
@ EVT_OP_CALL
Args: *function, ...
@ EVT_OP_IF_NOT_FLAG
Args: a, b.
@ EVT_OP_IS_THREAD_RUNNING
Args: ScriptID, container.
@ EVT_OP_IF_LT
Args: a, b.
@ EVT_OP_SWITCH_CONST
Args: value to test against.
@ EVT_OP_CASE_NE
Args: expression to test for.
@ EVT_OP_SET_CONST
Args: container, value.
@ EVT_OP_KILL_THREAD
Args: ScriptID.
@ EVT_OP_LABEL
Args: index.
@ EVT_OP_RESUME_OTHERS
Args: group.
@ EVT_OP_RESUME_THREAD
Args: ScriptID.
@ EVT_OP_BUF_READ2
Args: container.
@ EVT_OP_RESUME_GROUP
Args: group.
@ EVT_OP_BIND_TRIGGER
Args: EvtScript*, trigger flags, s32 target, 1, Trigger*.
@ EVT_OP_BITWISE_AND
Args: container, expression to bitwise AND with.
@ EVT_OP_CASE_GT
Args: expression to test for.
@ EVT_OP_BITWISE_OR
Args: container, expression to bitwise OR with.
@ EVT_OP_SET_GROUP
Args: group.
@ EVT_OP_BIND_PADLOCK
Args: EvtScript*, trigger flags, s32 target, ItemList*, 0, 1.
@ EVT_OP_SUSPEND_GROUP
Args: group.
@ EVT_OP_CASE_LT
Args: expression to test for.
@ EVT_OP_MALLOC_ARRAY
Allocates a new array. Args: length, s32*.
@ EVT_OP_BUF_PEEK
Args: container, container, container, container.
@ EVT_OP_IF_EQ
Args: a, b.
@ EVT_OP_FBUF_PEEK
Args: container, container, container, container.
@ EVT_CMD_RESULT_CONTINUE
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
void suspend_group_others(Evt *script, s32 groupFlags)
void kill_script(Evt *instanceToKill)
void set_script_group(Evt *script, s32 groupFlags)
Evt * start_child_script(Evt *parentScript, EvtScript *source, s32 initialState)
Evt * get_script_by_index(s32 index)
s32 resume_all_group(s32 groupFlags)
s32 suspend_all_script(s32 id)
s32 is_another_trigger_bound(Trigger *, EvtScript *script)
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void resume_group_others(Evt *script, s32 groupFlags)
void kill_script_by_ID(s32 id)
Trigger * create_trigger(TriggerBlueprint *def)
void set_script_timescale(Evt *script, f32 timescale)
void set_script_priority(Evt *script, s32 priority)
s32 resume_all_script(s32 id)
s32 does_script_exist(s32 id)
void delete_trigger(Trigger *toDelete)
Evt * start_script_in_group(EvtScript *source, u8 priority, u8 initialState, u8 groupFlags)
void suspend_all_group(s32 groupFlags)
Evt * restart_script(Evt *script)
void * heap_malloc(s32 size)
Evt * func_802C39F8(Evt *parentScript, Bytecode *nextLine, s32 newState)
ApiStatus DeleteTrigger(Evt *script, b32 isInitialCall)
Removes a trigger previously bound with BindTrigger.
#define EVT_LOCAL_VAR_CUTOFF
Expressions in EVT instructions should be one of the following types:
#define EVT_INDEX_OF_AREA_BYTE(v)
#define EVT_ARRAY_VAR_CUTOFF
#define EVT_MAP_FLAG_CUTOFF
#define EVT_LOCAL_FLAG_CUTOFF
#define EVT_GAME_FLAG_CUTOFF
#define EVT_AREA_BYTE_CUTOFF
#define EVT_INDEX_OF_AREA_FLAG(v)
#define EVT_INDEX_OF_ARRAY_FLAG(v)
#define EVT_INDEX_OF_LOCAL_VAR(v)
#define EVT_INDEX_OF_ARRAY_VAR(v)
#define EVT_INDEX_OF_GAME_BYTE(v)
#define EVT_GAME_BYTE_CUTOFF
#define EVT_FIXED_TO_FLOAT(x)
Progammatically converts Float --> f32.
#define EVT_ARRAY_FLAG_CUTOFF
#define ASSERT_MSG(condition, msg, args...)
#define EVT_INDEX_OF_MAP_FLAG(v)
#define EVT_INDEX_OF_LOCAL_FLAG(v)
#define EVT_AREA_FLAG_CUTOFF
#define EVT_INDEX_OF_MAP_VAR(v)
#define EVT_MAP_VAR_CUTOFF
#define EVT_INDEX_OF_GAME_FLAG(v)
s32(* onActivateFunc)(struct Trigger *)
s32 hasPlayerInteractPrompt
struct Evt * runningScript
GameStatus * gGameStatusPtr
s32 set_global_flag(s32 index)
s32 get_global_flag(s32 index)
s32 set_area_flag(s32 index)
s32 get_global_byte(s32 index)
Get value of saved game byte.
s32 clear_area_flag(s32 index)
s32 get_area_flag(s32 index)
s32 get_area_byte(s32 index)
s8 set_area_byte(s32 index, s32 value)
s32 clear_global_flag(s32 index)
s8 set_global_byte(s32 index, s32 value)
Set value of saved game byte.