papermario/src/code_e92d0_len_5da0.c

1040 lines
29 KiB
C
Raw Normal View History

2020-08-04 08:49:11 +02:00
#include "common.h"
f32 fixed_var_to_float(s32 scriptVar) {
2020-08-14 17:18:05 +02:00
if (scriptVar <= -220000000) {
2020-08-18 11:30:36 +02:00
return (scriptVar + 230000000) * (1 / 1024.0f);
2020-08-14 17:18:05 +02:00
}
return scriptVar;
}
2020-08-04 08:49:11 +02:00
s32 float_to_fixed_var(f32 value) {
return (s32)(value * 1024.0f) - 230000000;
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_return(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
kill_script(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_FINISH;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_label(ScriptInstance* script) {
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_goto(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
script->ptrNextLine = si_goto_label(script, get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
ApiStatus si_handle_Loop(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
s32 loopDepth = ++script->loopDepth;
ASSERT(loopDepth < 8);
script->loopStartTable[loopDepth] = thisPos;
script->loopCounterTable[loopDepth] = var;
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_end_loop);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_break_loop(ScriptInstance* script) {
2020-08-17 14:09:19 +02:00
ASSERT(script->loopDepth >= 0);
2020-08-14 17:18:05 +02:00
script->ptrNextLine = si_goto_end_loop(script);
script->loopDepth -= 1;
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
ApiStatus si_handle_wait(ScriptInstance* script) {
Bytecode* ptrReadPos = script->ptrReadPos;
if (!script->blocked) {
script->functionTemp[0] = get_variable(script, *ptrReadPos);
script->blocked = 1;
}
if (script->functionTemp[0]) {
2020-08-24 06:18:10 +02:00
s32 todo = 1; // val can be anything
2020-08-22 05:04:10 +02:00
if (todo) {
script->functionTemp[0] -= 1;
}
return !script->functionTemp[0];
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
ApiStatus si_handle_wait_seconds(ScriptInstance* script) {
Bytecode* ptrReadPos = script->ptrReadPos;
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
if (!script->blocked) {
script->functionTemp[0] = get_float_variable(script, *ptrReadPos) * 30.0f + 0.5;
script->blocked = 1;
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
if (script->functionTemp[0]) {
2020-08-24 06:18:10 +02:00
s32 todo = 1; // val can be anything
2020-08-22 05:04:10 +02:00
if (todo) {
script->functionTemp[0] -= 1;
}
return !script->functionTemp[0];
}
return ApiStatus_DONE2;
}
ApiStatus si_handle_if_equal(ScriptInstance* script) {
2020-08-24 03:23:37 +02:00
Bytecode* thisPos = script->ptrReadPos;
2020-08-22 05:04:10 +02:00
if (get_variable(script, *thisPos++) != get_variable(script, *thisPos++)) {
script->ptrNextLine = si_skip_if(script);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
}
ApiStatus si_handle_if_not_equal(ScriptInstance* script) {
2020-08-24 03:23:37 +02:00
Bytecode* thisPos = script->ptrReadPos;
2020-08-22 05:04:10 +02:00
if (get_variable(script, *thisPos++) == get_variable(script, *thisPos++)) {
script->ptrNextLine = si_skip_if(script);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
ApiStatus si_handle_if_less(ScriptInstance* script) {
2020-08-24 03:23:37 +02:00
Bytecode* thisPos = script->ptrReadPos;
2020-08-22 05:04:10 +02:00
if (get_variable(script, *thisPos++) >= get_variable(script, *thisPos++)) {
script->ptrNextLine = si_skip_if(script);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
ApiStatus si_handle_if_greater(ScriptInstance* script) {
2020-08-24 03:23:37 +02:00
Bytecode* thisPos = script->ptrReadPos;
2020-08-22 05:04:10 +02:00
if (get_variable(script, *thisPos++) <= get_variable(script, *thisPos++)) {
script->ptrNextLine = si_skip_if(script);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
ApiStatus si_handle_if_less_equal(ScriptInstance* script) {
2020-08-24 03:23:37 +02:00
Bytecode* thisPos = script->ptrReadPos;
2020-08-22 05:04:10 +02:00
if (get_variable(script, *thisPos++) > get_variable(script, *thisPos++)) {
script->ptrNextLine = si_skip_if(script);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
ApiStatus si_handle_if_greater_equal(ScriptInstance* script) {
2020-08-24 03:23:37 +02:00
Bytecode* thisPos = script->ptrReadPos;
2020-08-22 05:04:10 +02:00
if (get_variable(script, *thisPos++) < get_variable(script, *thisPos++)) {
script->ptrNextLine = si_skip_if(script);
return ApiStatus_DONE2;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_if_AND(ScriptInstance* script) {
2020-08-19 04:36:21 +02:00
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
if ((get_variable(script, var) & *thisPos) == 0) {
2020-08-14 17:18:05 +02:00
script->ptrNextLine = si_skip_if(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_if_not_AND(ScriptInstance* script) {
2020-08-19 04:36:21 +02:00
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
2020-08-14 17:18:05 +02:00
2020-08-19 04:36:21 +02:00
if ((get_variable(script, var) & *thisPos) != 0) {
2020-08-14 17:18:05 +02:00
script->ptrNextLine = si_skip_if(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_else(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
script->ptrNextLine = si_skip_else(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_end_if(ScriptInstance* script) {
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-17 19:16:13 +02:00
ApiStatus si_handle_switch(ScriptInstance* script) {
Bytecode value = get_variable(script, *script->ptrReadPos);
s32 switchDepth = ++script->switchDepth;
2020-08-04 08:49:11 +02:00
2020-08-17 14:09:19 +02:00
ASSERT(switchDepth < 8);
2020-08-19 02:55:56 +02:00
script->switchBlockValue[switchDepth] = value;
script->switchBlockState[switchDepth] = 1;
2020-08-16 05:19:00 +02:00
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
}
2020-08-17 19:16:13 +02:00
ApiStatus si_handle_switch_const(ScriptInstance* script) {
2020-08-19 04:36:21 +02:00
Bytecode* thisPos = *script->ptrReadPos;
s32 switchDepth = ++script->switchDepth;
2020-08-17 14:09:19 +02:00
ASSERT(switchDepth < 8);
2020-08-19 04:36:21 +02:00
script->switchBlockValue[switchDepth] = thisPos;
script->switchBlockState[switchDepth] = 1;
2020-08-17 19:16:13 +02:00
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_equal);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_not_equal);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_less);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_less_equal);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_greater);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_greater_equal);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_range);
2020-08-04 08:49:11 +02:00
2020-09-18 03:28:34 +02:00
ApiStatus si_handle_case_default(ScriptInstance* script) {
s32 switchDepth = script->switchDepth;
ASSERT(switchDepth >= 0);
if (script->switchBlockState[switchDepth] > 0) {
script->switchBlockState[switchDepth] = 0;
} else {
script->ptrNextLine = si_goto_end_case(script);
}
return ApiStatus_DONE2;
do {} while (0); // Necessary to match
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_AND);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_equal_OR);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_case_equal_AND);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_end_case_group);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_break_case(ScriptInstance* script) {
2020-08-17 14:09:19 +02:00
ASSERT(script->switchDepth >= 0);
2020-08-14 17:18:05 +02:00
script->ptrNextLine = si_goto_end_case(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_end_switch(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
s32 switchDepth = script->switchDepth;
2020-08-19 02:55:56 +02:00
2020-08-17 14:09:19 +02:00
ASSERT(switchDepth >= 0);
2020-08-04 08:49:11 +02:00
2020-08-17 19:27:37 +02:00
script->switchBlockState[switchDepth] = 0;
2020-08-14 17:18:05 +02:00
script->switchDepth -= 1;
2020-08-04 08:49:11 +02:00
2020-08-17 19:16:13 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_var(ScriptInstance* script) {
2020-08-19 04:36:21 +02:00
Bytecode* thisPos = script->ptrReadPos;
s32 curPtrReadPos = thisPos[0];
2020-08-14 17:18:05 +02:00
2020-08-19 04:36:21 +02:00
set_variable(script, curPtrReadPos, get_variable(script, thisPos[1]));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_const(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
set_variable(script, *script->ptrReadPos, script->ptrReadPos[1]);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_float(ScriptInstance* script) {
2020-08-19 04:36:21 +02:00
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
2020-08-14 17:18:05 +02:00
2020-08-19 04:36:21 +02:00
set_float_variable(script, var, get_float_variable(script, *thisPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
ApiStatus si_handle_add(ScriptInstance* script) {
2020-08-22 05:04:10 +02:00
Bytecode* thisPos = script->ptrReadPos;
2020-08-24 06:16:43 +02:00
Bytecode var = *thisPos++;
s32 result = get_variable(script, *thisPos++);
s32 addend = get_variable(script, var);
result += addend;
set_variable(script, var, result);
return ApiStatus_DONE2;
}
ApiStatus si_handle_subtract(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
s32 result = get_variable(script, *thisPos++);
s32 minuend = get_variable(script, var);
result = minuend - result;
set_variable(script, var, result);
return ApiStatus_DONE2;
}
ApiStatus si_handle_multiply(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
s32 result = get_variable(script, *thisPos++);
s32 multiplier = get_variable(script, var);
result *= multiplier;
set_variable(script, var, result);
return ApiStatus_DONE2;
}
ApiStatus si_handle_divide(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
s32 result = get_variable(script, *thisPos++);
s32 dividend = get_variable(script, var);
result = dividend / result;
set_variable(script, var, result);
return ApiStatus_DONE2;
}
2020-08-22 05:04:10 +02:00
2020-08-24 06:16:43 +02:00
ApiStatus si_handle_mod(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
s32 result = get_variable(script, *thisPos++) + 0.5;
s32 num = get_variable(script, var) + 0.5;
result = num % result;
set_variable(script, var, result);
2020-08-22 05:04:10 +02:00
return ApiStatus_DONE2;
2020-08-24 06:16:43 +02:00
}
ApiStatus si_handle_addF(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
f32 result = get_float_variable(script, *thisPos++);
f32 addend = get_float_variable(script, var);
result += addend;
set_float_variable(script, var, result);
return ApiStatus_DONE2;
}
ApiStatus si_handle_subtractF(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
f32 result = get_float_variable(script, *thisPos++);
f32 minuend = get_float_variable(script, var);
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
result = minuend - result;
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
set_float_variable(script, var, result);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
ApiStatus si_handle_multiplyF(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
f32 result = get_float_variable(script, *thisPos++);
f32 multiplier = get_float_variable(script, var);
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
result *= multiplier;
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
set_float_variable(script, var, result);
return ApiStatus_DONE2;
}
ApiStatus si_handle_divideF(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var = *thisPos++;
f32 result = get_float_variable(script, *thisPos++);
f32 dividend = get_float_variable(script, var);
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
result = dividend / result;
2020-08-04 08:49:11 +02:00
2020-08-24 06:16:43 +02:00
set_float_variable(script, var, result);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_int_buffer_ptr(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
script->buffer = get_variable(script, *script->ptrReadPos);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_float_buffer_ptr(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
script->buffer = get_variable(script, *script->ptrReadPos);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_get_1_word(ScriptInstance* script) {
2020-08-19 04:36:21 +02:00
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
var = *thisPos++;
set_variable(script, var, *script->buffer++);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
ApiStatus si_handle_get_2_word(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
Bytecode var2;
var = *thisPos++;
set_variable(script, var, *script->buffer++);
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
var2 = *thisPos++;
set_variable(script, var2, *script->buffer++);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
ApiStatus si_handle_get_3_word(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
Bytecode var2;
Bytecode var3;
var = *thisPos++;
set_variable(script, var, *script->buffer++);
var2 = *thisPos++;
set_variable(script, var2, *script->buffer++);
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
var3 = *thisPos++;
set_variable(script, var3, *script->buffer++);
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
return ApiStatus_DONE2;
}
ApiStatus si_handle_get_4_word(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
Bytecode var2;
Bytecode var3;
Bytecode var4;
var = *thisPos++;
set_variable(script, var, *script->buffer++);
var2 = *thisPos++;
set_variable(script, var2, *script->buffer++);
var3 = *thisPos++;
set_variable(script, var3, *script->buffer++);
var4 = *thisPos++;
set_variable(script, var4, *script->buffer++);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_get_Nth_word(ScriptInstance* script) {
2020-08-19 04:36:21 +02:00
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
var = *thisPos++;
set_variable(script, var, script->buffer[get_variable(script, *thisPos)]);
2020-08-14 17:18:05 +02:00
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
ApiStatus si_handle_get_1_float(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
var = *thisPos++;
set_float_variable(script, var, get_float_variable(script, *script->buffer++));
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
ApiStatus si_handle_get_2_float(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
Bytecode var2;
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
var = *thisPos++;
set_float_variable(script, var, get_float_variable(script, *script->buffer++));
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
var2 = *thisPos++;
set_float_variable(script, var2, get_float_variable(script, *script->buffer++));
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
return ApiStatus_DONE2;
}
ApiStatus si_handle_get_3_float(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
Bytecode var2;
Bytecode var3;
var = *thisPos++;
set_float_variable(script, var, get_float_variable(script, *script->buffer++));
var2 = *thisPos++;
set_float_variable(script, var2, get_float_variable(script, *script->buffer++));
var3 = *thisPos++;
set_float_variable(script, var3, get_float_variable(script, *script->buffer++));
2020-08-14 17:18:05 +02:00
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
ApiStatus si_handle_get_4_float(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
Bytecode var2;
Bytecode var3;
Bytecode var4;
var = *thisPos++;
set_float_variable(script, var, get_float_variable(script, *script->buffer++));
var2 = *thisPos++;
set_float_variable(script, var2, get_float_variable(script, *script->buffer++));
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
var3 = *thisPos++;
set_float_variable(script, var3, get_float_variable(script, *script->buffer++));
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
var4 = *thisPos++;
set_float_variable(script, var4, get_float_variable(script, *script->buffer++));
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-19 04:36:21 +02:00
ApiStatus si_handle_get_Nth_float(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var;
var = *thisPos++;
set_float_variable(script, var, script->buffer[get_variable(script, *thisPos)]);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_array(ScriptInstance* script) {
2020-08-19 02:23:52 +02:00
script->array = (s32*)get_variable(script, *script->ptrReadPos);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_flag_array(ScriptInstance* script) {
2020-08-19 02:23:52 +02:00
script->flagArray = (s32*)get_variable(script, *script->ptrReadPos);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-27 00:54:55 +02:00
ApiStatus si_handle_allocate_array(ScriptInstance* script) {
Bytecode* thisPos = script->ptrReadPos;
s32 size = get_variable(script, *thisPos++);
Bytecode var = *thisPos++;
script->array = heap_malloc(size * 4);
set_variable(script, var, script->array);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_AND);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_AND_const(ScriptInstance* script) {
Bytecode* ptrReadPos = script->ptrReadPos;
2020-08-27 00:54:55 +02:00
// todo improve
2020-08-19 02:21:04 +02:00
s32 constant = ptrReadPos[0]; // NOLINT
s32 var = ptrReadPos[0];
constant = ptrReadPos[1];
2020-08-14 17:18:05 +02:00
2020-08-19 02:21:04 +02:00
set_variable(script, var, constant & get_variable(script, var));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_OR);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_OR_const(ScriptInstance* script) {
Bytecode* ptrReadPos = script->ptrReadPos;
2020-08-27 00:54:55 +02:00
// todo improve
2020-08-19 02:21:04 +02:00
s32 constant = ptrReadPos[0]; // NOLINT
s32 var = ptrReadPos[0];
2020-08-14 17:18:05 +02:00
2020-08-19 02:21:04 +02:00
constant = ptrReadPos[1];
set_variable(script, var, constant | get_variable(script, var));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_call);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_exec1);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_exec2);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_exec_wait(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
start_child_script(script, get_variable(script, *script->ptrReadPos), 0);
script->currentOpcode = 0;
return 0xFF;
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_jump(ScriptInstance* script) {
2020-08-19 02:23:52 +02:00
script->ptrFirstLine = (Bytecode*)get_variable(script, *script->ptrReadPos);
2020-08-14 17:18:05 +02:00
restart_script(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-09-06 17:53:48 +02:00
s32 INCLUDE_ASM("code_e92d0_len_5da0", _bound_script_trigger_handler, Trigger* trigger);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_bind);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus DeleteTrigger(ScriptInstance* script, s32 isInitialCall) {
2020-08-14 17:18:05 +02:00
delete_trigger(get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_unbind(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
delete_trigger(script->ownerID);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_kill(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
kill_script_by_ID(get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_priority(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
set_script_priority(script, get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_timescale(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
set_script_timescale(script, get_float_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_set_group(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
set_script_group(script, get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_suspend_all(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
suspend_all_group(get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_resume_all(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
resume_all_group(get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_suspend_others(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
suspend_group_others(script, get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_resume_others(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
resume_group_others(script, get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_suspend(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
suspend_all_script(get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_resume(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
resume_all_script(get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
ApiStatus INCLUDE_ASM("code_e92d0_len_5da0", si_handle_does_script_exist);
2020-08-04 08:49:11 +02:00
ApiStatus INCLUDE_ASM("code_e92d0_len_5da0", si_handle_bind_lock);
2020-08-04 08:49:11 +02:00
ApiStatus INCLUDE_ASM("code_e92d0_len_5da0", si_handle_thread);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_end_thread(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
kill_script(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_FINISH;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
ApiStatus INCLUDE_ASM("code_e92d0_len_5da0", si_handle_child_thread);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus si_handle_end_child_thread(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
kill_script(script);
2020-08-16 08:55:51 +02:00
return ApiStatus_BLOCK;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus func_802C6E14(ScriptInstance* script) {
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
ApiStatus INCLUDE_ASM("code_e92d0_len_5da0", si_handle_print_debug_var);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus func_802C739C(ScriptInstance* script) {
2020-08-19 02:23:52 +02:00
script->ptrSavedPosition = (Bytecode*)*script->ptrReadPos;
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-16 08:55:51 +02:00
ApiStatus func_802C73B0(ScriptInstance* script) {
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 07:13:03 +02:00
s32 func_802C73B8(ScriptInstance* script) {
2020-08-14 17:18:05 +02:00
s32 i;
2020-08-04 08:49:11 +02:00
2020-08-15 04:55:19 +02:00
for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) {
2020-08-14 17:18:05 +02:00
if (script == get_script_by_index(i)) {
break;
}
}
2020-08-19 04:36:21 +02:00
2020-08-14 17:18:05 +02:00
return 1;
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_execute_next_command);
2020-08-04 08:49:11 +02:00
2020-09-19 17:16:02 +02:00
// TODO: consider renaming to si_get_variable
2020-09-20 02:13:52 +02:00
#ifdef NON_MATCHING
s32 get_variable(ScriptInstance* script, Bytecode var) {
2020-09-19 17:16:02 +02:00
s32 abs_value;
s32 word_index;
s32 bit_index;
if (var <= -270000000) {
return var;
} else if (var <= -250000000) {
return var;
} else if (var <= -220000000) {
return (s32) fixed_var_to_float(var);
} else if (var <= -200000000) {
var += 210000000;
word_index = var / 32;
bit_index = var % 32;
return (script->flagArray[word_index] & (1 << bit_index)) != 0;
} else if (var <= -180000000) {
var += 190000000;
var = script->array[var];
return (var > -270000000 && var < -220000000) ? (s32) fixed_var_to_float(var) : var;
} else if (var <= -160000000) {
return get_global_byte(var + 170000000);
} else if (var <= -140000000) {
return get_area_byte(var + 150000000);
} else if (var <= -120000000) {
return get_global_flag(var + 130000000);
} else if (var <= -100000000) {
return get_area_flag(var + 110000000);
} else if (var <= -80000000) {
s32 avar = var + 90000000;
word_index = avar / 32;
bit_index = avar % 32;
return (gMapFlags[word_index] & (1 << bit_index)) != 0;
} else if (var <= -60000000) {
var += 70000000;
word_index = var / 32;
bit_index = var % 32;
return (script->varFlags[word_index] & (1 << bit_index)) != 0;
} else if (var <= -40000000) {
var += 50000000;
var = gMapVars[var];
return (var > -270000000 && var < -220000000) ? (s32) fixed_var_to_float(var) : var;
} else if (var <= -20000000) {
var += 30000000;
var = script->varTable[var];
return (var > -270000000 && var < -220000000) ? (s32) fixed_var_to_float(var) : var;
} else {
return var;
}
2020-09-20 02:13:52 +02:00
}
#else
s32 INCLUDE_ASM("code_e92d0_len_5da0", get_variable, ScriptInstance* script, Bytecode var);
#endif
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", get_variable_index);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", get_variable_index_alt);
2020-08-04 08:49:11 +02:00
s32 INCLUDE_ASM("code_e92d0_len_5da0", set_variable, ScriptInstance* script, Bytecode var, s32 value);
2020-08-04 08:49:11 +02:00
f32 INCLUDE_ASM("code_e92d0_len_5da0", get_float_variable, ScriptInstance* script, Bytecode var);
2020-08-04 08:49:11 +02:00
f32 INCLUDE_ASM("code_e92d0_len_5da0", set_float_variable, ScriptInstance* script, Bytecode var, f32 value);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_goto_label);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_skip_if);
2020-09-18 03:28:34 +02:00
// Matching but needs rodata support
/*Bytecode* si_skip_if(ScriptInstance* script) {
s32 nestedIfDepth = 0;
Bytecode* pos = script->ptrNextLine;
Bytecode opcode;
s32 nargs;
do {
opcode = *pos++;
nargs = *pos++;
pos += nargs;
switch(opcode) {
case 1:
PANIC();
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 19:
nestedIfDepth--;
if (nestedIfDepth < 0) {
return pos;
}
break;
case 17:
nestedIfDepth++;
break;
case 18:
if (nestedIfDepth == 0) {
return pos;
}
break;
}
} while(1);
}*/
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_skip_else);
2020-09-18 03:28:34 +02:00
// Matching but needs rodata support
/*Bytecode* si_skip_else(ScriptInstance* script) {
s32 nestedIfDepth = 0;
Bytecode* pos = script->ptrNextLine;
Bytecode opcode;
s32 nargs;
do {
opcode = *pos++;
nargs = *pos++;
pos += nargs;
switch(opcode) {
case 1:
PANIC();
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 19:
nestedIfDepth--;
if (nestedIfDepth < 0) {
return pos;
}
break;
case 17:
nestedIfDepth++;
break;
2020-09-18 03:34:13 +02:00
2020-09-18 03:28:34 +02:00
}
} while(1);
}*/
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_goto_end_case);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_goto_next_case);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", si_goto_end_loop);
2020-08-04 08:49:11 +02:00
2020-09-18 03:28:34 +02:00
// Ethan: I think this is the start of a new file
INCLUDE_API_ASM("code_e92d0_len_5da0", TranslateModel);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", RotateModel);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", ScaleModel);
2020-08-04 08:49:11 +02:00
2020-09-18 07:51:36 +02:00
ApiStatus GetModelIndex(ScriptInstance* script, s32 isInitialCall) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode modelID = get_variable(script, *thisPos++);
Bytecode index = *thisPos++;
set_variable(script, index, get_model_list_index_from_tree_index(modelID));
return ApiStatus_DONE2;
}
ApiStatus func_802C8EE4(ScriptInstance* script, s32 isInitialCall) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode modelID = get_variable(script, *thisPos++);
Model* model = get_model_from_list_index(get_model_list_index_from_tree_index(modelID));
model->flags &= ~0x400;
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus CloneModel(ScriptInstance* script, s32 isInitialCall) {
Bytecode* thisPos = script->ptrReadPos;
2020-08-22 05:04:10 +02:00
Bytecode srcModelID = get_variable(script, *thisPos++);
Bytecode newModelID = get_variable(script, *thisPos++);
2020-08-10 09:42:50 +02:00
clone_model(srcModelID, newModelID);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-10 09:42:50 +02:00
}
2020-08-04 08:49:11 +02:00
2020-09-19 17:16:02 +02:00
ApiStatus GetModelCenter(ScriptInstance* script, s32 isInitialCall) {
Bytecode* thisPos = script->ptrReadPos;
f32 centerX;
f32 centerY;
f32 centerZ;
f32 sizeX;
f32 sizeY;
f32 sizeZ;
2020-09-19 17:17:53 +02:00
get_model_center_and_size(get_variable(script, *thisPos++) & 0xFFFF, &centerX, &centerY, &centerZ, &sizeX, &sizeY,
&sizeZ);
2020-09-19 17:16:02 +02:00
script->varTable[0] = centerX;
script->varTable[1] = centerY;
script->varTable[2] = centerZ;
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", SetTexPanner);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", SetModelFlag10);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", EnableTexPanning);
2020-08-04 08:49:11 +02:00
2020-09-19 17:16:02 +02:00
ApiStatus EnableModel(ScriptInstance* script, s32 isInitialCall) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode treeIndex = get_variable(script, *thisPos++);
s32 listIndex = get_model_list_index_from_tree_index(treeIndex);
Bytecode flag = get_variable(script, *thisPos++);
Model* model = get_model_from_list_index(listIndex);
if (flag != 0) {
model->flags &= ~0x2;
} else {
model->flags |= 0x2;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-08-22 05:04:10 +02:00
ApiStatus SetGroupEnabled(ScriptInstance* script, s32 isInitialCall) {
Bytecode* thisPos = script->ptrReadPos;
Bytecode var1 = get_variable(script, *thisPos++);
Bytecode var2 = get_variable(script, *thisPos++);
func_8011B7C0(var1, 2, var2);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", SetTexPanOffset);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", SetModelFlags);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", func_802C95A0);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", TranslateGroup);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", RotateGroup);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", ScaleGroup);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", EnableGroup);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", modify_collider_family_flags);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", ModifyColliderFlags);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", ResetFromLava);
2020-08-04 08:49:11 +02:00
2020-08-27 00:54:55 +02:00
ApiStatus GetColliderCenter(ScriptInstance* script, s32 initialCall) {
f32 x;
f32 y;
f32 z;
get_collider_center(get_variable(script, *script->ptrReadPos), &x, &y, &z);
script->varTable[0] = x;
script->varTable[1] = y;
script->varTable[2] = z;
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", ParentColliderToModel);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus UpdateColliderTransform(ScriptInstance* script, s32 isInitialCall) {
2020-08-10 09:42:50 +02:00
update_collider_transform(get_variable(script, *script->ptrReadPos));
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-10 09:42:50 +02:00
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", func_802CA1B8);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_e92d0_len_5da0", goto_map);
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus GotoMap(ScriptInstance* script, s32 isInitialCall) {
2020-08-10 07:03:56 +02:00
goto_map(script, 0);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE1;
2020-08-10 07:03:56 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus GotoMapSpecial(ScriptInstance* script, s32 isInitialCall) {
2020-08-10 07:03:56 +02:00
goto_map(script, 1);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE1;
2020-08-10 07:03:56 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus GotoMapByID(ScriptInstance* script, s32 isInitialCall) {
2020-08-10 07:03:56 +02:00
goto_map(script, 2);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE1;
2020-08-10 07:03:56 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus GetEntryID(ScriptInstance* script, s32 isInitialCall) {
2020-08-14 17:18:05 +02:00
set_variable(script, *script->ptrReadPos, (*gGameStatusPtr)->entryID);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-10 09:42:50 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus GetMapID(ScriptInstance* script, s32 isInitialCall) {
2020-08-14 17:18:05 +02:00
set_variable(script, *script->ptrReadPos, (*gGameStatusPtr)->mapID);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-10 09:42:50 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus GetLoadType(ScriptInstance* script, s32 isInitialCall) {
2020-08-14 17:18:05 +02:00
set_variable(script, *script->ptrReadPos, (*gGameStatusPtr)->loadType != 0);
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-14 17:18:05 +02:00
}
2020-08-04 08:49:11 +02:00
2020-09-18 03:28:34 +02:00
ApiStatus SetRenderMode(ScriptInstance* script, s32 isInitialCall) {
Bytecode* thisPos = script->ptrReadPos;
s32 treeIndex = get_variable(script, *thisPos++);
s8 renderMode = get_variable(script, *thisPos++);
get_model_from_list_index(get_model_list_index_from_tree_index(treeIndex))->renderMode = renderMode;
2020-09-18 03:34:13 +02:00
2020-09-18 03:28:34 +02:00
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", PlaySoundAtModel);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_e92d0_len_5da0", PlaySoundAtCollider);