use ScriptOpcode enum instead of macros

This commit is contained in:
Alex Bates 2020-11-08 19:07:10 +00:00
parent c794134d08
commit c13ca4392b
8 changed files with 789 additions and 805 deletions

View File

@ -6,6 +6,99 @@
typedef s32 Bytecode; typedef s32 Bytecode;
typedef s32 ScriptID; typedef s32 ScriptID;
typedef enum ScriptOpcode {
ScriptOpcode_END = 0x01,
ScriptOpcode_RETURN,
ScriptOpcode_LABEL, ///< Args: index
ScriptOpcode_GOTO, ///< Args: index
ScriptOpcode_LOOP, ///< Args: number of repeats (0 = infinite)
ScriptOpcode_END_LOOP,
ScriptOpcode_BREAK_LOOP,
ScriptOpcode_SLEEP_FRAMES,
ScriptOpcode_SLEEP_SECS,
ScriptOpcode_IF_EQ, ///< Args: a, b
ScriptOpcode_IF_NE, ///< Args: a, b
ScriptOpcode_IF_LT, ///< Args: a, b
ScriptOpcode_IF_GT, ///< Args: a, b
ScriptOpcode_IF_LE, ///< Args: a, b
ScriptOpcode_IF_GE, ///< Args: a, b
ScriptOpcode_IF_FLAG, ///< Args: a, b
ScriptOpcode_IF_NOT_FLAG, ///< Args: a, b
ScriptOpcode_ELSE,
ScriptOpcode_END_IF,
ScriptOpcode_MATCH, ///< Args: expression to test against
ScriptOpcode_MATCH_CONST, ///< Args: value to test against
ScriptOpcode_CASE_EQ, ///< Args: expression to test for
ScriptOpcode_CASE_NE, ///< Args: expression to test for
ScriptOpcode_CASE_LT, ///< Args: expression to test for
ScriptOpcode_CASE_GT, ///< Args: expression to test for
ScriptOpcode_CASE_LE, ///< Args: expression to test for
ScriptOpcode_CASE_GE, ///< Args: expression to test for
ScriptOpcode_CASE_ELSE,
ScriptOpcode_CASE_MULTI_EQ, ///< Args: expression to test for
ScriptOpcode_CASE_MULTI_NE, ///< Args: expression to test for
ScriptOpcode_CASE_FLAG, ///< Args: expression to test for
ScriptOpcode_END_CASE_MULTI, ///< Ends the case block of ScriptOpcode_CASE_MULTI_OR_EQ condition(s).
ScriptOpcode_CASE_RANGE, ///< Args: from, to
ScriptOpcode_BREAK_MATCH,
ScriptOpcode_END_MATCH,
ScriptOpcode_SET, ///< Args: container, expression
ScriptOpcode_SET_CONST, ///< Args: container, value
ScriptOpcode_SET_F, ///< Args: container, expression
ScriptOpcode_ADD, ///< Args: container, expression to increment by
ScriptOpcode_SUB, ///< Args: container, expression to decrement by
ScriptOpcode_MUL, ///< Args: container, expression to multiply by
ScriptOpcode_DIV, ///< Integer division. Args: container, expression to divide by
ScriptOpcode_MOD, ///< Args: container, expression to divide by
ScriptOpcode_ADD_F, ///< Args: container, expression to increment by
ScriptOpcode_SUB_F, ///< Args: container, expression to decrement by
ScriptOpcode_MUL_F, ///< Args: container, expression to multiply by
ScriptOpcode_DIV_F, ///< Args: container, expression to divide by
ScriptOpcode_USE_BUFFER, ///< Args: s32*
ScriptOpcode_BUFFER_READ_1, /// Args: container
ScriptOpcode_BUFFER_READ_2, /// Args: container, container
ScriptOpcode_BUFFER_READ_3, /// Args: container, container, container
ScriptOpcode_BUFFER_READ_4, /// Args: container, container, container, container
ScriptOpcode_BUFFER_PEEK, ///< Args: index, container
ScriptOpcode_USE_BUFFER_F, ///< Identical to USE_BUFFER. Args: f32*
ScriptOpcode_BUFFER_READ_1_F, /// Args: container
ScriptOpcode_BUFFER_READ_2_F, /// Args: container, container
ScriptOpcode_BUFFER_READ_3_F, /// Args: container, container, container
ScriptOpcode_BUFFER_READ_4_F, /// Args: container, container, container, container
ScriptOpcode_BUFFER_PEEK_F, ///< Args: index, container
ScriptOpcode_USE_ARRAY, ///< Args: *s32
ScriptOpcode_USE_FLAGS, ///< Args: *s32
ScriptOpcode_NEW_ARRAY, ///< Allocates a new array. Args: length, s32*
ScriptOpcode_AND, ///< Args: container, expression to bitwise AND with
ScriptOpcode_AND_CONST, ///< Args: container, value to bitwise AND with
ScriptOpcode_OR, ///< Args: container, expression to bitwise OR with
ScriptOpcode_OR_CONST, ///< Args: container, value to bitwise OR with
ScriptOpcode_CALL, ///< Args: *function, ...
ScriptOpcode_SPAWN_SCRIPT, ///< Args: Script*
ScriptOpcode_SPAWN_SCRIPT_GET_ID, ///< Args: Script*, container
ScriptOpcode_AWAIT_SCRIPT, ///< Spawns a script and waits for it to return before continuing. Args: Script*
ScriptOpcode_BIND_TRIGGER, ///< Args: Script*, trigger flags, s32 target, 1, Trigger*
ScriptOpcode_UNBIND, ///< Unbinds any triggers bound to this script.
ScriptOpcode_KILL_SCRIPT, ///< Args: ScriptID
ScriptOpcode_JUMP, ///< Args: Script*
ScriptOpcode_SET_PRIORITY, ///< Args: priority
ScriptOpcode_SET_TIMESCALE, ///< Args: timescale
ScriptOpcode_SET_GROUP, ///< Args: group
ScriptOpcode_BIND_PADLOCK, ///< Args: Script*, trigger flags, s32 target, ItemList*, 0, 1
ScriptOpcode_SUSPEND_GROUP, ///< Args: group
ScriptOpcode_RESUME_GROUP, ///< Args: group
ScriptOpcode_SUSPEND_OTHERS, ///< Args: group
ScriptOpcode_RESUME_OTHERS, ///< Args: group
ScriptOpcode_SUSPEND_SCRIPT, ///< Args: ScriptID
ScriptOpcode_RESUME_SCRIPT, ///< Args: ScriptID
ScriptOpcode_SCRIPT_EXISTS, ///< Args: ScriptID, container
ScriptOpcode_SPAWN_THREAD,
ScriptOpcode_END_SPAWN_THREAD,
ScriptOpcode_PARALLEL_THREAD, ///< Parallel threads are killed as soon as the parent script returns.
ScriptOpcode_END_PARALLEL_THREAD,
ScriptOpcode_DEBUG_PRINT = 0x5B, ///< Args: expression
} ScriptOpcode;
#define SI_VAR(v) (v - 30000000) #define SI_VAR(v) (v - 30000000)
#define SI_MAP_VAR(v) (v - 50000000) #define SI_MAP_VAR(v) (v - 50000000)
#define SI_FLAG(v) (v - 70000000) #define SI_FLAG(v) (v - 70000000)
@ -36,111 +129,6 @@ typedef s32 ApiStatus;
/* argc */ (sizeof((Bytecode[]){argv})/sizeof(Bytecode)), \ /* argc */ (sizeof((Bytecode[]){argv})/sizeof(Bytecode)), \
##argv ##argv
#define SI_END() SI_CMD(0x01)
#define SI_RETURN() SI_CMD(0x02)
#define SI_LABEL(i) SI_CMD(0x03, i)
#define SI_GOTO(i) SI_CMD(0x04, i)
#define SI_LOOP(i) SI_CMD(0x05, i)
#define SI_END_LOOP() SI_CMD(0x06)
#define SI_BREAK_LOOP() SI_CMD(0x07)
#define SI_WAIT_FRAMES(i) SI_CMD(0x08, i)
#define SI_WAIT_SECS(i) SI_CMD(0x09, i)
#define SI_IF_EQ(a, b) SI_CMD(0x0A, a, b)
#define SI_IF_NE(a, b) SI_CMD(0x0B, a, b)
#define SI_IF_LT(a, b) SI_CMD(0x0C, a, b)
#define SI_IF_GT(a, b) SI_CMD(0x0D, a, b)
#define SI_IF_LE(a, b) SI_CMD(0x0E, a, b)
#define SI_IF_GE(a, b) SI_CMD(0x0F, a, b)
#define SI_IF_BITS_ON(a, b) SI_CMD(0x10, a, b)
#define SI_IF_BITS_OFF(a, b) SI_CMD(0x11, a, b)
#define SI_ELSE() SI_CMD(0x12)
#define SI_END_IF() SI_CMD(0x13)
#define SI_SWITCH(a) SI_CMD(0x14, a)
#define SI_SWITCH_CONST(a) SI_CMD(0x15, a) // Does not get_variable
#define SI_CASE_EQ(b) SI_CMD(0x16, b)
#define SI_CASE_NE(b) SI_CMD(0x17, b)
#define SI_CASE_LT(b) SI_CMD(0x18, b)
#define SI_CASE_GT(b) SI_CMD(0x19, b)
#define SI_CASE_LE(b) SI_CMD(0x1A, b)
#define SI_CASE_GE(b) SI_CMD(0x1B, b)
#define SI_CASE_DEFAULT() SI_CMD(0x1C)
#define SI_CASE_OR_EQ(b) SI_CMD(0x1D, b)
#define SI_CASE_BITS_ON(b) SI_CMD(0x1F, b)
#define SI_END_MULTI_CASE() SI_CMD(0x20)
#define SI_CASE_RANGE(from, to) SI_CMD(0x21, from, to)
#define SI_BREAK_CASE() SI_CMD(0x22)
#define SI_END_SWITCH() SI_CMD(0x23)
#define SI_SET(varA, varB) SI_CMD(0x24, varA, varB)
#define SI_SET_CONST(var, value) SI_CMD(0x25, var, value) // Does not get_variable
#define SI_ADD(a, b) SI_CMD(0x27, a, b) // +=
#define SI_SUB(a, b) SI_CMD(0x28, a, b) // -=
#define SI_MUL(a, b) SI_CMD(0x29, a, b) // *=
#define SI_DIV(a, b) SI_CMD(0x2A, a, b) // /=
#define SI_MOD(a, b) SI_CMD(0x2B, a, b) // %=
#define SI_SET_F(var, value) SI_CMD(0x26, var, value)
#define SI_ADD_F(a, b) SI_CMD(0x2C, a, b) // +=
#define SI_SUB_F(a, b) SI_CMD(0x2D, a, b) // -=
#define SI_MUL_F(a, b) SI_CMD(0x2E, a, b) // *=
#define SI_DIV_F(a, b) SI_CMD(0x2F, a, b) // /=
// BUF_READ and BUF_READ_F take 1..4 args only
#define SI_USE_BUFFER(buf_ptr) SI_CMD(0x30, buf_ptr)
#define SI_BUF_READ(vars...) SI_CMD( \
0x30 + (sizeof((Bytecode[]){vars})/sizeof(Bytecode)), \
vars)
#define SI_BUF_PEEK(n, var) SI_CMD(0x35, n, var)
#define SI_USE_BUFFER_F(buf_ptr) SI_CMD(0x36, buf_ptr)
#define SI_BUF_READ_F(vars...) SI_CMD( \
0x36 + (sizeof((Bytecode[]){vars})/sizeof(Bytecode)), \
vars)
#define SI_BUF_PEEK_F(n, var) SI_CMD(0x3B, n, var)
#define SI_USE_ARRAY(arrPtr) SI_CMD(0x3C, arrPtr)
#define SI_NEW_ARRAY(len, arrPtr) SI_CMD(0x3D, len, arrPtr)
#define SI_USE_FLAGS(arrPtr) SI_CMD(0x3E, arrPtr)
#define SI_AND(varA, varB) SI_CMD(0x3F, varA, varB) // &=
#define SI_AND_CONST(var, value) SI_CMD(0x40, var, value) // &=
#define SI_OR(varA, varB) SI_CMD(0x41, varA, varB) // |=
#define SI_OR_CONST(var, value) SI_CMD(0x41, var, value) // |=
#define SI_CALL(func, argv...) SI_CMD(0x43, func, ##argv)
#define SI_EXEC(script) SI_CMD(0x44, script)
#define SI_EXEC_GET_ID(script, outScriptID) SI_CMD(0x45, script, outScriptID)
#define SI_EXEC_WAIT(script) SI_CMD(0x46, script)
#define SI_JUMP(script) SI_CMD(0x4A, script)
#define SI_BIND(script, trigger, target, outTriggerPtr) SI_CMD(0x47, script, trigger, target, 1, outTriggerPtr)
#define SI_BIND_PADLOCK(script, trigger, target, itemList) SI_CMD(0x4E, script, trigger, target, itemList, 0, 1)
#define SI_UNBIND_ME() SI_CMD(0x48)
#define SI_PRIORITY(p) SI_CMD(0x4B, p)
#define SI_TIMESCALE(t) SI_CMD(0x4C, t)
#define SI_GROUP(g) SI_CMD(0x4D, g)
#define SI_SUSPEND_GROUP(group) SI_CMD(0x4F, group)
#define SI_RESUME_GROUP(group) SI_CMD(0x50, group)
#define SI_SUSPEND_GROUP_NOT_ME(group) SI_CMD(0x51, group)
#define SI_RESUME_GROUP_NOT_ME(group) SI_CMD(0x52, group)
#define SI_KILL(scriptID) SI_CMD(0x49, scriptID)
#define SI_SUSPEND(scriptID) SI_CMD(0x53, scriptID)
#define SI_RESUME(scriptID) SI_CMD(0x54, scriptID)
#define SI_EXISTS(scriptID) SI_CMD(0x55, scriptID)
#define SI_THREAD() SI_CMD(0x56)
#define SI_END_THREAD() SI_CMD(0x57)
#define SI_CHILD_THREAD() SI_CMD(0x58)
#define SI_END_CHILD_THREAD() SI_CMD(0x59)
#define EXIT_WALK_SCRIPT(walkDistance, exitIdx, map, entryIdx) \ #define EXIT_WALK_SCRIPT(walkDistance, exitIdx, map, entryIdx) \
SCRIPT({ \ SCRIPT({ \
group 0x1B; \ group 0x1B; \

View File

@ -64,8 +64,6 @@ MapConfig M(config) = {
.tattle = MessageID_TATTLE_KMR_03, .tattle = MessageID_TATTLE_KMR_03,
}; };
Script M(script_802406C0) = { Script M(Script_802406C0) = SCRIPT({
SI_CALL(SetMusicTrack, 0, 17, 0, 8), SetMusicTrack(0, 17, 0, 8)
SI_RETURN(), });
SI_END(),
};

View File

@ -1,9 +1,9 @@
#include "kmr_03.h" #include "kmr_03.h"
s32 M(npcGroupList_80241450)[]; s32 M(npcGroupList_80241450)[];
Script M(script_MakeEntities); Script M(MakeEntities);
Script M(script_802422B8); Script M(Script_802422B8);
Script M(script_80242340); Script M(Script_80242340);
ApiStatus func_802401B0_8C8140(ScriptInstance* script, s32 isInitialCall) { ApiStatus func_802401B0_8C8140(ScriptInstance* script, s32 isInitialCall) {
Npc* npc = get_npc_unsafe(0); Npc* npc = get_npc_unsafe(0);
@ -15,7 +15,7 @@ ApiStatus func_802401B0_8C8140(ScriptInstance* script, s32 isInitialCall) {
#include "world/common/UnkPositionFunc.inc.c" #include "world/common/UnkPositionFunc.inc.c"
// 8C8680 // 8C8680
Script M(script_ExitWalk_802406F0) = { Script M(ExitWalk_802406F0) = /*{
SI_GROUP(27), SI_GROUP(27),
SI_CALL(0x802D216C, 60, 0), SI_CALL(0x802D216C, 60, 0),
SI_EXEC(0x80285CF4), SI_EXEC(0x80285CF4),
@ -23,9 +23,9 @@ Script M(script_ExitWalk_802406F0) = {
SI_WAIT_FRAMES(100), SI_WAIT_FRAMES(100),
SI_RETURN(), SI_RETURN(),
SI_END(), SI_END(),
}; };*/EXIT_WALK_SCRIPT(60, 0, "kmr_04", 0);
Script M(script_ExitWalk_8024074C) = { Script M(ExitWalk_8024074C) = /*{
SI_GROUP(27), SI_GROUP(27),
SI_CALL(0x802D216C, 60, 1), SI_CALL(0x802D216C, 60, 1),
SI_EXEC(0x80285CF4), SI_EXEC(0x80285CF4),
@ -33,42 +33,36 @@ Script M(script_ExitWalk_8024074C) = {
SI_WAIT_FRAMES(100), SI_WAIT_FRAMES(100),
SI_RETURN(), SI_RETURN(),
SI_END(), SI_END(),
}; };*/EXIT_WALK_SCRIPT(60, 1, "kmr_05", 0);
Script M(script_802407A8) = { Script M(Script_802407A8) = SCRIPT({
SI_BIND(M(script_ExitWalk_802406F0), 524288, 3, NULL), bind M(ExitWalk_802406F0) to 0x80000 3
SI_BIND(M(script_ExitWalk_8024074C), 524288, 5, NULL), bind M(ExitWalk_8024074C) to 0x80000 5
SI_RETURN(), });
SI_END(),
};
// *INDENT-OFF* Script M(Main) = SCRIPT({
Script M(Main) = { SI_SAVE_VAR(425) = 30
SI_SET(SI_SAVE_VAR(425), 30), SetSpriteShading(-1)
SI_CALL(0x802D9700, -1), SetCamPerspective(0, 3, 25, 16, 4096)
SI_CALL(0x802CA828, 0, 3, 25, 16, 4096), SetCamBGColor(0, 0, 0, 0)
SI_CALL(0x802CAD98, 0, 0, 0, 0), SetCamEnabled(0, 1)
SI_CALL(0x802CA6C0, 0, 1), SetCamLeadPlayer(0, 0)
SI_CALL(0x802CB680, 0, 0), SI_AREA_FLAG(8) = 0
SI_SET(SI_AREA_FLAG(8), 0), MakeNpcs(0, M(npcGroupList_80241450))
SI_CALL(0x80044298, 0, M(npcGroupList_80241450)), ClearDefeatedEnemies()
SI_CALL(0x80045640), await M(MakeEntities)
SI_EXEC_WAIT(M(script_MakeEntities)), await M(Script_802422B8)
SI_EXEC_WAIT(M(script_802422B8)), spawn M(Script_802406C0)
SI_EXEC(M(script_802406C0)), GetEntryID(SI_VAR(0))
SI_CALL(0x802CA460, SI_VAR(0)), if SI_VAR(0) != 2 {
SI_IF_NE(SI_VAR(0), 2), SI_VAR(0) = M(Script_802407A8)
SI_SET(SI_VAR(0), M(script_802407A8)), spawn EnterWalk
SI_EXEC(0x80285960), } else {
SI_ELSE(), spawn M(Script_802407A8)
SI_EXEC(M(script_802407A8)), spawn M(Script_80242340)
SI_EXEC(M(script_80242340)), }
SI_END_IF(), sleep 1
SI_WAIT_FRAMES(1), });
SI_RETURN(),
SI_END(),
};
// *INDENT-ON*
s32 padding[] = {0, 0}; s32 padding[] = {0, 0};
@ -78,159 +72,147 @@ s32 M(npcSettings_80240950)[] = {
0x00000000, 0x00000000, 0x00630010, 0x00000000, 0x00000000, 0x00630010,
}; };
// *INDENT-OFF* Script M(Script_8024097C) = SCRIPT({
Script M(script_8024097C) = { 1:
SI_LABEL(1), if SI_AREA_FLAG(8) == 1 {
SI_IF_EQ(SI_AREA_FLAG(8), 1), 100:
SI_LABEL(100), AwaitPlayerLeave(294, 123, 170)
SI_CALL(0x802D4A5C, 294, 123, 170), EnableNpcAI(0, 0)
SI_CALL(0x80044CF0, 0, 0), DisablePlayerInput(1)
SI_CALL(0x802D0E28, 1), SetNpcSpeed(0, 4.0)
SI_CALL(0x802CE01C, 0, SI_FIXED(4.0f)), SetNpcAnimation(0, 0x9D0003)
SI_CALL(0x802CE0F4, 0, 0x9D0003), func_802401B0_8C8140()
SI_CALL(func_802401B0_8C8140), GetAngleToPlayer(0, SI_VAR(2))
SI_CALL(0x802D4830, 0, SI_VAR(2)), loop SI_VAR(1) {
SI_LOOP(SI_VAR(1)), GetNpcPos(0, SI_VAR(7), SI_VAR(8), SI_VAR(9))
SI_CALL(0x802CF0F4, 0, SI_VAR(7), SI_VAR(8), SI_VAR(9)), AddVectorPolar(SI_VAR(7), SI_VAR(9), 4.0, SI_VAR(2))
SI_CALL(0x802D4B14, SI_VAR(7), SI_VAR(9), SI_FIXED(4.0f), SI_VAR(2)), SetNpcPos(0, SI_VAR(7), SI_VAR(8), SI_VAR(9))
SI_CALL(0x802CDCB0, 0, SI_VAR(7), SI_VAR(8), SI_VAR(9)), sleep 1
SI_WAIT_FRAMES(1), }
SI_END_LOOP(), PlayerFaceNpc(0, 3)
SI_CALL(0x802D1B04, 0, 3), SetPlayerSpeed(3.0)
SI_CALL(0x802D1024, SI_FIXED(3.0f)), PlayerMoveTo(243, 243, 0)
SI_CALL(0x802D1134, 243, 243, 0), SetNpcVar(0, 0, 1)
SI_CALL(0x80045320, 0, 0, 1), EnableNpcAI(0, 1)
SI_CALL(0x80044CF0, 0, 1), DisablePlayerInput(0)
SI_CALL(0x802D0E28, 0), goto 100
SI_GOTO(100), }
SI_END_IF(), sleep 1
SI_WAIT_FRAMES(1), goto 1
SI_GOTO(1), });
SI_RETURN(),
SI_END(),
};
// *INDENT-ON*
// *INDENT-OFF* Script M(NpcAI_80240B50) = SCRIPT({
Script M(script_NpcAI_80240B50) = { 1:
SI_LABEL(1), match SI_SAVE_VAR(0) {
SI_SWITCH(SI_SAVE_VAR(0)), == 0xFFFFFF86 {
SI_CASE_EQ(0xFFFFFF86), 89:
SI_LABEL(89), UnkPositionFunc(0xFFFFFF8A, 86, 0xFFFFFFBA, 0xFFFFFFF1)
SI_CALL(UnkPositionFunc, 0xFFFFFF8A, 86, 0xFFFFFFBA, 0xFFFFFFF1), sleep 1
SI_WAIT_FRAMES(1), if SI_VAR(0) == 0 {
SI_IF_EQ(SI_VAR(0), 0), goto 89
SI_GOTO(89), }
SI_END_IF(), DisablePlayerInput(1)
SI_CALL(0x802D0E28, 1), SetNpcAux(0, 0)
SI_CALL(0x80044DA4, 0, 0), PlaySoundAtNpc(0, 610, 0)
SI_CALL(0x802D01AC, 0, 610, 0), ShowEmote(0, 0, 45, 15, 1, 0, 0, 0, 0)
SI_CALL(0x802D78A0, 0, 0, 45, 15, 1, 0, 0, 0, 0), sleep 15
SI_WAIT_FRAMES(15), NpcFacePlayer(-1, 5)
SI_CALL(0x802CECC8, -1, 5), sleep 10
SI_WAIT_FRAMES(10), SpeakToPlayer(0, 0x9D0008, 0x9D0001, 0, 0xB00A6)
SI_CALL(0x802D02B0, 0, 0x9D0008, 0x9D0001, 0, 0xB00A6), UseSettingsFrom(0, 0xFFFFFF24, 20, 0xFFFFFFB8)
SI_CALL(0x802CB860, 0, 0xFFFFFF24, 20, 0xFFFFFFB8), SetPanTarget(0, 0xFFFFFFEC, 0, 68)
SI_CALL(0x802CBE2C, 0, 0xFFFFFFEC, 0, 68), SetCamPitch(0, 15.0, -8.5)
SI_CALL(0x802CBB48, 0, SI_FIXED(15.0f), SI_FIXED(-8.5f)), SetCamDistance(0, 275)
SI_CALL(0x802CBBE4, 0, 275), SetCamSpeed(0, 1.5)
SI_CALL(0x802CBEF0, 0, SI_FIXED(1.5f)), PanToTarget(0, 0, 1)
SI_CALL(0x802CB79C, 0, 0, 1), spawn {
SI_THREAD(), sleep 20
SI_WAIT_FRAMES(20), SetPlayerSpeed(2.0)
SI_CALL(0x802D1024, SI_FIXED(2.0f)), PlayerMoveTo(0xFFFFFFDA, 68, 0)
SI_CALL(0x802D1134, 0xFFFFFFDA, 68, 0), }
SI_END_THREAD(), GetNpcPos(0, SI_VAR(7), SI_VAR(8), SI_VAR(9))
SI_CALL(0x802CF0F4, 0, SI_VAR(7), SI_VAR(8), SI_VAR(9)), SetNpcSpeed(0, 4.0)
SI_CALL(0x802CE01C, 0, SI_FIXED(4.0f)), SetNpcAnimation(0, 0x9D0003)
SI_CALL(0x802CE0F4, 0, 0x9D0003), NpcMoveTo(0, 0, 70, 0)
SI_CALL(0x802CE22C, 0, 0, 70, 0), SetNpcAnimation(0, 0x9D0001)
SI_CALL(0x802CE0F4, 0, 0x9D0001), InterpNpcYaw(0, 276, 20)
SI_CALL(0x802CEB04, 0, 276, 20), sleep 30
SI_WAIT_FRAMES(30), SpeakToPlayer(0, 0x9D0008, 0x9D0001, 0, 0xB00A7)
SI_CALL(0x802D02B0, 0, 0x9D0008, 0x9D0001, 0, 0xB00A7), sleep 5
SI_WAIT_FRAMES(5), SetPlayerAnimation(0x80007)
SI_CALL(0x802D1084, 0x80007), sleep 30
SI_WAIT_FRAMES(30), SpeakToPlayer(0, 0x9D0008, 0x9D0001, 0, 0xB00A8)
SI_CALL(0x802D02B0, 0, 0x9D0008, 0x9D0001, 0, 0xB00A8), func_80240000_8C7F90(0, 5)
SI_CALL(func_80240000_8C7F90, 0, 5), SI_SAVE_VAR(0) = 0xFFFFFF87
SI_SET(SI_SAVE_VAR(0), 0xFFFFFF87), UseSettingsFrom(0, 0xFFFFFF24, 20, 0xFFFFFFB8)
SI_CALL(0x802CB860, 0, 0xFFFFFF24, 20, 0xFFFFFFB8), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SetPanTarget(0, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CBE2C, 0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SetCamSpeed(0, 3.0)
SI_CALL(0x802CBEF0, 0, SI_FIXED(3.0f)), PanToTarget(0, 0, 1)
SI_CALL(0x802CB79C, 0, 0, 1), WaitForCam(0, 1.0)
SI_CALL(0x802CC354, 0, SI_FIXED(1.0f)), PanToTarget(0, 0, 0)
SI_CALL(0x802CB79C, 0, 0, 0), EnablePartnerAI()
SI_CALL(0x802CF52C), DisablePlayerInput(0)
SI_CALL(0x802D0E28, 0), sleep 1
SI_WAIT_FRAMES(1), }
SI_END_SWITCH(), }
SI_RETURN(), });
SI_END(),
};
// *INDENT-ON*
// *INDENT-OFF* Script M(Hit_80240F64) = SCRIPT({
Script M(script_Hit_80240F64) = { SetNpcAnimation(-1, 0x9D0007)
SI_CALL(0x802CE0F4, -1, 0x9D0007), sleep 10
SI_WAIT_FRAMES(10), SetNpcAnimation(-1, 0x9D0001)
SI_CALL(0x802CE0F4, -1, 0x9D0001), SI_MAP_VAR(0) += 1
SI_ADD(SI_MAP_VAR(0), 1), if SI_MAP_VAR(0) < 3 {
SI_IF_LT(SI_MAP_VAR(0), 3), GetOwnerEncounterTrigger(SI_VAR(0))
SI_CALL(0x80044600, SI_VAR(0)), match SI_VAR(0) {
SI_SWITCH(SI_VAR(0)), == 2 {
SI_CASE_EQ(2), SetNpcVar(0, 0, 1)
SI_CALL(0x80045320, 0, 0, 1), if SI_AREA_FLAG(6) == 1 {
SI_IF_EQ(SI_AREA_FLAG(6), 1), } else {
SI_ELSE(), SI_AREA_FLAG(6) = 1
SI_SET(SI_AREA_FLAG(6), 1), SI_AREA_FLAG(7) = 0
SI_SET(SI_AREA_FLAG(7), 0), }
SI_END_IF(), }
SI_CASE_EQ(4), == 4 {
SI_CALL(0x80045320, 0, 0, 1), SetNpcVar(0, 0, 1)
SI_IF_EQ(SI_AREA_FLAG(7), 1), if SI_AREA_FLAG(7) == 1 {
SI_ELSE(), } else {
SI_SET(SI_AREA_FLAG(6), 0), SI_AREA_FLAG(6) = 0
SI_SET(SI_AREA_FLAG(7), 1), SI_AREA_FLAG(7) = 1
SI_END_IF(), }
SI_END_SWITCH(), }
SI_WAIT_FRAMES(10), }
SI_CALL(0x802CE0F4, -1, 0x9D0003), sleep 10
SI_ELSE(), SetNpcAnimation(-1, 0x9D0003)
SI_WAIT_FRAMES(10), } else {
SI_CALL(0x802CF0F4, 0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), sleep 10
SI_CALL(0x802CDCB0, 0xFFFFFFFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), GetNpcPos(0, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CF060, 0xFFFFFFFC, 512, 1), SetNpcPos(0xFFFFFFFC, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CDCB0, 0, 0, 0xFFFFFC18, 0), SetNpcFlagBits(0xFFFFFFFC, 512, 1)
SI_CALL(0x802CF060, 0, 256, 0), SetNpcPos(0, 0, 0xFFFFFC18, 0)
SI_CALL(0x802CF52C), SetNpcFlagBits(0, 256, 0)
SI_CALL(0x80044DA4, -1, M(script_8024097C)), EnablePartnerAI()
SI_CALL(0x80044A78, -1, M(script_NpcAI_80240B50)), SetNpcAux(-1, M(Script_8024097C))
SI_END_IF(), BindNpcAI(-1, M(NpcAI_80240B50))
SI_RETURN(), }
SI_END(), });
};
// *INDENT-ON*
// *INDENT-OFF* Script M(Init_802411A8) = SCRIPT({
Script M(script_Init_802411A8) = { BindNpcIdle(-1, M(NpcAI_80240B50))
SI_CALL(0x80044BAC, -1, M(script_NpcAI_80240B50)), BindNpcAux(-1, M(Script_8024097C))
SI_CALL(0x80044EB8, -1, M(script_8024097C)), BindNpcHit(-1, M(Hit_80240F64))
SI_CALL(0x80045140, -1, M(script_Hit_80240F64)), match SI_SAVE_VAR(0) {
SI_SWITCH(SI_SAVE_VAR(0)), >= 0xFFFFFF87 {
SI_CASE_GE(0xFFFFFF87), SetNpcFlagBits(-1, 512, 0)
SI_CALL(0x802CF060, -1, 512, 0), SetNpcFlagBits(-1, 8, 1)
SI_CALL(0x802CF060, -1, 8, 1), SetNpcPos(-1, 0, 0xFFFFFC18, 0)
SI_CALL(0x802CDCB0, -1, 0, 0xFFFFFC18, 0), }
SI_END_SWITCH(), }
SI_RETURN(), });
SI_END(),
};
// *INDENT-ON*
s32 M(npcGroup_80241260)[] = { s32 M(npcGroup_80241260)[] = {
0x00000000, M(npcSettings_80240950), 0xC2480000, 0x00000000, 0x42A00000, 0x00400105, M(script_Init_802411A8), 0x00000000, 0x00000000, M(npcSettings_80240950), 0xC2480000, 0x00000000, 0x42A00000, 0x00400105, M(Init_802411A8), 0x00000000,
0x00000000, 0x0000002D, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000002D, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00007FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00007FFF, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
@ -254,59 +236,48 @@ s32 M(npcGroupList_80241450)[] = {
s32 padding2[] = {0, 0}; s32 padding2[] = {0, 0};
// 8C9400 Script M(Script_80241470) = SCRIPT({
Script M(script_80241470) = { ModifyColliderFlags(0, 9, 0x7FFFFE00)
SI_CALL(0x802C9DCC, 0, 9, 0x7FFFFE00), SI_SAVE_VAR(0) = 0xFFFFFF8B
SI_SET(SI_SAVE_VAR(0), 0xFFFFFF8B), });
SI_RETURN(),
SI_END(),
};
Script M(script_802414A8) = { Script M(Script_802414A8) = SCRIPT({
SI_SET(SI_SAVE_FLAG(54), 1), SI_SAVE_FLAG(54) = 1
SI_RETURN(), });
SI_END(),
};
Script M(script_802414C8) = { Script M(Script_802414C8) = SCRIPT({
SI_LABEL(0), 0:
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CAF2C, 0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SetCamTarget(0, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_WAIT_FRAMES(1), sleep 1
SI_GOTO(0), goto 0
SI_RETURN(), });
SI_END(),
};
// *INDENT-OFF* Script M(MakeEntities) = SCRIPT({
Script M(script_MakeEntities) = { if SI_SAVE_VAR(0) < 0xFFFFFF8B {
SI_IF_LT(SI_SAVE_VAR(0), 0xFFFFFF8B), MakeEntity(0x802EA10C, 45, 0, 70, 15, 0x80000000)
SI_CALL(0x80111D38, 0x802EA10C, 45, 0, 70, 15, 0x80000000), AssignScript(M(Script_80241470))
SI_CALL(0x80111FB0, M(script_80241470)), } else {
SI_ELSE(), ModifyColliderFlags(0, 9, 0x7FFFFE00)
SI_CALL(0x802C9DCC, 0, 9, 0x7FFFFE00), }
SI_END_IF(), if SI_SAVE_FLAG(54) == 0 {
SI_IF_EQ(SI_SAVE_FLAG(54), 0), MakeEntity(0x802EA19C, 230, 0, 310, 15, 0x80000000)
SI_CALL(0x80111D38, 0x802EA19C, 230, 0, 310, 15, 0x80000000), AssignScript(M(Script_802414A8))
SI_CALL(0x80111FB0, M(script_802414A8)), }
SI_END_IF(), MakeEntity(0x802EA588, 230, 60, 310, 15, 151, 0x80000000)
SI_CALL(0x80111D38, 0x802EA588, 230, 60, 310, 15, 151, 0x80000000), AssignBlockFlag(SI_SAVE_FLAG(52))
SI_CALL(0x8011206C, SI_SAVE_FLAG(52)), MakeEntity(0x802EA0C4, 230, 50, 0xFFFFFF60, 15, 0x80000000)
SI_CALL(0x80111D38, 0x802EA0C4, 230, 50, 0xFFFFFF60, 15, 0x80000000), MakeEntity(0x802EA0C4, 165, 0, 380, 20, 0x80000000)
SI_CALL(0x80111D38, 0x802EA0C4, 165, 0, 380, 20, 0x80000000), MakeEntity(0x802EA564, 0xFFFFFF56, 0, 370, 43, 343, 0x80000000)
SI_CALL(0x80111D38, 0x802EA564, 0xFFFFFF56, 0, 370, 43, 343, 0x80000000), AssignBlockFlag(SI_SAVE_FLAG(50))
SI_CALL(0x8011206C, SI_SAVE_FLAG(50)), MakeEntity(0x802EAA54, 345, 75, 0xFFFFFF06, 0, 100, 0x80000000)
SI_CALL(0x80111D38, 0x802EAA54, 345, 75, 0xFFFFFF06, 0, 100, 0x80000000), MakeItemEntity(343, 345, 205, 0xFFFFFF06, 17, SI_SAVE_FLAG(56))
SI_CALL(0x802D6CC0, 343, 345, 205, 0xFFFFFF06, 17, SI_SAVE_FLAG(56)), MakeItemEntity(343, 345, 230, 0xFFFFFF06, 17, SI_SAVE_FLAG(57))
SI_CALL(0x802D6CC0, 343, 345, 230, 0xFFFFFF06, 17, SI_SAVE_FLAG(57)), MakeItemEntity(343, 345, 255, 0xFFFFFF06, 17, SI_SAVE_FLAG(58))
SI_CALL(0x802D6CC0, 343, 345, 255, 0xFFFFFF06, 17, SI_SAVE_FLAG(58)), MakeItemEntity(343, 345, 280, 0xFFFFFF06, 17, SI_SAVE_FLAG(59))
SI_CALL(0x802D6CC0, 343, 345, 280, 0xFFFFFF06, 17, SI_SAVE_FLAG(59)), MakeItemEntity(128, 229, 250, 0xFFFFFF64, 17, SI_SAVE_FLAG(49))
SI_CALL(0x802D6CC0, 128, 229, 250, 0xFFFFFF64, 17, SI_SAVE_FLAG(49)), MakeEntity(0x802EAB04, 300, 0, 150, 0, 18, 0x80000000)
SI_CALL(0x80111D38, 0x802EAB04, 300, 0, 150, 0, 18, 0x80000000), AssignPanelFlag(SI_SAVE_FLAG(88))
SI_CALL(0x80112114, SI_SAVE_FLAG(88)), MakeEntity(0x802EA7E0, 130, 60, 0, 0, 0x80000000)
SI_CALL(0x80111D38, 0x802EA7E0, 130, 60, 0, 0, 0x80000000), });
SI_RETURN(),
SI_END(),
};
// *INDENT-ON*

View File

@ -3,181 +3,179 @@
#include "world/common/SomeMatrixOperations.inc.c" #include "world/common/SomeMatrixOperations.inc.c"
// *INDENT-OFF* // *INDENT-OFF*
Script M(script_SearchBush_802417F0) = { Script M(SearchBush_802417F0) = {
SI_USE_BUFFER(SI_VAR(0)), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(0)),
SI_CMD(0x34, 0xFE363C81, 0xFE363C82, 0xFE363C83, 0xFE363C84), SI_CMD(ScriptOpcode_BUFFER_READ_4, SI_VAR(1), SI_VAR(2), SI_VAR(3), SI_VAR(4)),
SI_CALL(0x802D1DFC, SI_VAR(5), SI_VAR(15), SI_VAR(7)), SI_CMD(ScriptOpcode_CALL, GetPlayerPos, SI_VAR(5), SI_VAR(15), SI_VAR(7)),
SI_THREAD(), SI_CMD(ScriptOpcode_SPAWN_THREAD),
SI_SET(SI_FLAG(0), 0), SI_CMD(ScriptOpcode_SET, SI_FLAG(0), 0),
SI_IF_NE(SI_VAR(1), 0), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(1), 0),
SI_LOOP(5), SI_CMD(ScriptOpcode_LOOP, 5),
SI_USE_BUFFER(SI_VAR(1)), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(1)),
SI_CMD(0x31, 0xFE363C82), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(2)),
SI_LOOP(SI_VAR(2)), SI_CMD(ScriptOpcode_LOOP, SI_VAR(2)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CALL(SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1), 1, SI_VAR(15), 0), SI_CMD(ScriptOpcode_CALL, SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1005859375), 1, SI_VAR(15), 0),
SI_IF_EQ(SI_FLAG(0), 0), SI_CMD(ScriptOpcode_IF_EQ, SI_FLAG(0), 0),
SI_SET(SI_FLAG(0), 1), SI_CMD(ScriptOpcode_SET, SI_FLAG(0), 1),
SI_CALL(0x802CA558, SI_VAR(3), 339, 0), SI_CMD(ScriptOpcode_CALL, PlaySoundAtModel, SI_VAR(3), 339, 0),
SI_END_IF(), SI_CMD(ScriptOpcode_END_IF),
SI_END_LOOP(), SI_CMD(ScriptOpcode_END_LOOP),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_USE_BUFFER(SI_VAR(1)), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(1)),
SI_CMD(0x31, 0xFE363C82), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(2)),
SI_LOOP(SI_VAR(2)), SI_CMD(ScriptOpcode_LOOP, SI_VAR(2)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CALL(SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1), -1, SI_VAR(15), 0), SI_CMD(ScriptOpcode_CALL, SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1005859375), -1, SI_VAR(15), 0),
SI_END_LOOP(), SI_CMD(ScriptOpcode_END_LOOP),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_END_LOOP(), SI_CMD(ScriptOpcode_END_LOOP),
SI_USE_BUFFER(SI_VAR(1)), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(1)),
SI_CMD(0x31, 0xFE363C82), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(2)),
SI_LOOP(SI_VAR(2)), SI_CMD(ScriptOpcode_LOOP, SI_VAR(2)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CALL(0x802C8B60, SI_VAR(3), 0, 0, 0), SI_CMD(ScriptOpcode_CALL, TranslateModel, SI_VAR(3), 0, 0, 0),
SI_END_LOOP(), SI_CMD(ScriptOpcode_END_LOOP),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_END_IF(), SI_CMD(ScriptOpcode_END_IF),
SI_END_THREAD(), SI_CMD(ScriptOpcode_END_SPAWN_THREAD),
SI_THREAD(), SI_CMD(ScriptOpcode_SPAWN_THREAD),
SI_IF_NE(SI_VAR(2), 0), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(2), 0),
SI_USE_BUFFER(SI_VAR(2)), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(2)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_LOOP(SI_VAR(3)), SI_CMD(ScriptOpcode_LOOP, SI_VAR(3)),
SI_CMD(0x31, 0xFE363C84), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(4)),
SI_CMD(0x33, 0xFE363C85, 0xFE363C86, 0xFE363C87), SI_CMD(ScriptOpcode_BUFFER_READ_3, SI_VAR(5), SI_VAR(6), SI_VAR(7)),
SI_CMD(0x33, 0xFE363C88, 0xFE363C89, 0xFE363C8A), SI_CMD(ScriptOpcode_BUFFER_READ_3, SI_VAR(8), SI_VAR(9), SI_VAR(10)),
SI_IF_EQ(SI_VAR(10), 0), SI_CMD(ScriptOpcode_IF_EQ, SI_VAR(10), 0),
SI_CALL(0x802D6DC0, SI_VAR(4), SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9)), SI_CMD(ScriptOpcode_CALL, DropItemEntity, SI_VAR(4), SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9)),
SI_ELSE(), SI_CMD(ScriptOpcode_ELSE),
SI_CALL(0x802D593C, SI_VAR(10), SI_VAR(11)), SI_CMD(ScriptOpcode_CALL, GetValueByRef, SI_VAR(10), SI_VAR(11)),
SI_IF_EQ(SI_VAR(11), 0), SI_CMD(ScriptOpcode_IF_EQ, SI_VAR(11), 0),
SI_CALL(0x802D58E0, SI_VAR(10), 1), SI_CMD(ScriptOpcode_CALL, SetValueByRef, SI_VAR(10), 1),
SI_CALL(0x802D6DC0, SI_VAR(4), SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9)), SI_CMD(ScriptOpcode_CALL, DropItemEntity, SI_VAR(4), SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9)),
SI_END_IF(), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_IF),
SI_END_LOOP(), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_IF(), SI_CMD(ScriptOpcode_END_IF),
SI_END_THREAD(), SI_CMD(ScriptOpcode_END_SPAWN_THREAD),
SI_WAIT_FRAMES(15), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 15),
SI_IF_NE(SI_VAR(4), 0), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(4), 0),
SI_EXEC_WAIT(0xFE363C84), SI_CMD(ScriptOpcode_AWAIT_SCRIPT, 0xFE363C84),
SI_END_IF(), SI_CMD(ScriptOpcode_END_IF),
SI_RETURN(), SI_CMD(ScriptOpcode_RETURN),
SI_END(), SI_CMD(ScriptOpcode_END)
}; };
// *INDENT-ON*
// *INDENT-OFF* Script M(ShakeTree_80241B50) = {
Script M(script_ShakeTree_80241B50) = { SI_CMD(ScriptOpcode_SET_TIMESCALE, SI_FIXED(2.0)),
SI_TIMESCALE(SI_FIXED(2.0f)), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(0)),
SI_USE_BUFFER(SI_VAR(0)), SI_CMD(ScriptOpcode_BUFFER_READ_4, SI_VAR(1), SI_VAR(2), SI_VAR(3), SI_VAR(4)),
SI_CMD(0x34, 0xFE363C81, 0xFE363C82, 0xFE363C83, 0xFE363C84), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(5)),
SI_CMD(0x31, 0xFE363C85), SI_CMD(ScriptOpcode_CALL, GetPlayerPos, SI_VAR(6), SI_VAR(15), SI_VAR(8)),
SI_CALL(0x802D1DFC, SI_VAR(6), SI_VAR(15), SI_VAR(8)), SI_CMD(ScriptOpcode_CALL, PlaySound, 357),
SI_CALL(0x802D6150, 357), SI_CMD(ScriptOpcode_CALL, PlaySound, 358),
SI_CALL(0x802D6150, 358), SI_CMD(ScriptOpcode_SPAWN_THREAD),
SI_THREAD(), SI_CMD(ScriptOpcode_SET, SI_FLAG(0), 0),
SI_SET(SI_FLAG(0), 0), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(1), 0),
SI_IF_NE(SI_VAR(1), 0), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_LOOP, 5),
SI_LOOP(5), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(1)),
SI_USE_BUFFER(SI_VAR(1)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(2)),
SI_CMD(0x31, 0xFE363C82), SI_CMD(ScriptOpcode_LOOP, SI_VAR(2)),
SI_LOOP(SI_VAR(2)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_CALL, SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1005859375), SI_FIXED(0.2001953125), SI_VAR(15), 0),
SI_CALL(SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1), SI_FIXED(0.2), SI_VAR(15), 0), SI_CMD(ScriptOpcode_IF_EQ, SI_FLAG(0), 0),
SI_IF_EQ(SI_FLAG(0), 0), SI_CMD(ScriptOpcode_SET, SI_FLAG(0), 1),
SI_SET(SI_FLAG(0), 1), SI_CMD(ScriptOpcode_CALL, PlaySoundAtModel, SI_VAR(3), 358, 0),
SI_CALL(0x802CA558, SI_VAR(3), 358, 0), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(1)),
SI_USE_BUFFER(SI_VAR(1)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(2)),
SI_CMD(0x31, 0xFE363C82), SI_CMD(ScriptOpcode_LOOP, SI_VAR(2)),
SI_LOOP(SI_VAR(2)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_CALL, SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1005859375), SI_FIXED(-0.19921875), SI_VAR(15), 0),
SI_CALL(SomeMatrixOperation2, SI_VAR(3), SI_FIXED(0.1), SI_FIXED(-0.2), SI_VAR(15), 0), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(1)),
SI_USE_BUFFER(SI_VAR(1)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(2)),
SI_CMD(0x31, 0xFE363C82), SI_CMD(ScriptOpcode_LOOP, SI_VAR(2)),
SI_LOOP(SI_VAR(2)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_CALL, TranslateModel, SI_VAR(3), 0, 0, 0),
SI_CALL(0x802C8B60, SI_VAR(3), 0, 0, 0), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_SPAWN_THREAD),
SI_END_THREAD(), SI_CMD(ScriptOpcode_SPAWN_THREAD),
SI_THREAD(), SI_CMD(ScriptOpcode_SET, SI_FLAG(0), 0),
SI_SET(SI_FLAG(0), 0), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(2), 0),
SI_IF_NE(SI_VAR(2), 0), SI_CMD(ScriptOpcode_LOOP, 5),
SI_LOOP(5), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(2)),
SI_USE_BUFFER(SI_VAR(2)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_LOOP, SI_VAR(3)),
SI_LOOP(SI_VAR(3)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(4)),
SI_CMD(0x31, 0xFE363C84), SI_CMD(ScriptOpcode_CALL, SomeMatrixOperation2, SI_VAR(4), SI_FIXED(0.1005859375), SI_FIXED(0.2001953125), SI_VAR(15), 0),
SI_CALL(SomeMatrixOperation2, SI_VAR(4), SI_FIXED(0.1), SI_FIXED(0.2), SI_VAR(15), 0), SI_CMD(ScriptOpcode_IF_EQ, SI_FLAG(0), 0),
SI_IF_EQ(SI_FLAG(0), 0), SI_CMD(ScriptOpcode_SET, SI_FLAG(0), 1),
SI_SET(SI_FLAG(0), 1), SI_CMD(ScriptOpcode_CALL, PlaySoundAtModel, SI_VAR(4), 357, 0),
SI_CALL(0x802CA558, SI_VAR(4), 357, 0), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(2)),
SI_USE_BUFFER(SI_VAR(2)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_LOOP, SI_VAR(3)),
SI_LOOP(SI_VAR(3)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(4)),
SI_CMD(0x31, 0xFE363C84), SI_CMD(ScriptOpcode_CALL, SomeMatrixOperation2, SI_VAR(4), SI_FIXED(0.1005859375), SI_FIXED(-0.19921875), SI_VAR(15), 0),
SI_CALL(SomeMatrixOperation2, SI_VAR(4), SI_FIXED(0.1), SI_FIXED(-0.2), SI_VAR(15), 0), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(2)),
SI_USE_BUFFER(SI_VAR(2)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(3)),
SI_CMD(0x31, 0xFE363C83), SI_CMD(ScriptOpcode_LOOP, SI_VAR(3)),
SI_LOOP(SI_VAR(3)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(4)),
SI_CMD(0x31, 0xFE363C84), SI_CMD(ScriptOpcode_CALL, TranslateModel, SI_VAR(4), 0, 0, 0),
SI_CALL(0x802C8B60, SI_VAR(4), 0, 0, 0), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 1),
SI_WAIT_FRAMES(1), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_SPAWN_THREAD),
SI_END_THREAD(), SI_CMD(ScriptOpcode_SPAWN_THREAD),
SI_THREAD(), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(3), 0),
SI_IF_NE(SI_VAR(3), 0), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(3)),
SI_USE_BUFFER(SI_VAR(3)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(4)),
SI_CMD(0x31, 0xFE363C84), SI_CMD(ScriptOpcode_LOOP, SI_VAR(4)),
SI_LOOP(SI_VAR(4)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(5)),
SI_CMD(0x31, 0xFE363C85), SI_CMD(ScriptOpcode_BUFFER_READ_3, SI_VAR(6), SI_VAR(7), SI_VAR(8)),
SI_CMD(0x33, 0xFE363C86, 0xFE363C87, 0xFE363C88), SI_CMD(ScriptOpcode_BUFFER_READ_3, SI_VAR(9), SI_VAR(10), SI_VAR(11)),
SI_CMD(0x33, 0xFE363C89, 0xFE363C8A, 0xFE363C8B), SI_CMD(ScriptOpcode_IF_EQ, SI_VAR(11), 0),
SI_IF_EQ(SI_VAR(11), 0), SI_CMD(ScriptOpcode_CALL, DropItemEntity, SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9), SI_VAR(10)),
SI_CALL(0x802D6DC0, SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9), SI_VAR(10)), SI_CMD(ScriptOpcode_ELSE),
SI_ELSE(), SI_CMD(ScriptOpcode_CALL, GetValueByRef, SI_VAR(11), SI_VAR(12)),
SI_CALL(0x802D593C, SI_VAR(11), SI_VAR(12)), SI_CMD(ScriptOpcode_IF_EQ, SI_VAR(12), 0),
SI_IF_EQ(SI_VAR(12), 0), SI_CMD(ScriptOpcode_CALL, SetValueByRef, SI_VAR(11), 1),
SI_CALL(0x802D58E0, SI_VAR(11), 1), SI_CMD(ScriptOpcode_CALL, DropItemEntity, SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9), SI_VAR(10)),
SI_CALL(0x802D6DC0, SI_VAR(5), SI_VAR(6), SI_VAR(7), SI_VAR(8), SI_VAR(9), SI_VAR(10)), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_SPAWN_THREAD),
SI_END_THREAD(), SI_CMD(ScriptOpcode_SPAWN_THREAD),
SI_THREAD(), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(4), 0),
SI_IF_NE(SI_VAR(4), 0), SI_CMD(ScriptOpcode_USE_BUFFER, SI_VAR(4)),
SI_USE_BUFFER(SI_VAR(4)), SI_CMD(ScriptOpcode_BUFFER_READ_1, SI_VAR(5)),
SI_CMD(0x31, 0xFE363C85), SI_CMD(ScriptOpcode_LOOP, SI_VAR(5)),
SI_LOOP(SI_VAR(5)), SI_CMD(ScriptOpcode_BUFFER_READ_3, SI_VAR(6), SI_VAR(7), SI_VAR(8)),
SI_CMD(0x33, 0xFE363C86, 0xFE363C87, 0xFE363C88), SI_CMD(ScriptOpcode_CALL, PlayEffect, 20, 0, SI_VAR(6), SI_VAR(7), SI_VAR(8), 100, 0, 0, 0, 0, 0, 0, 0, 0),
SI_CALL(0x802D829C, 20, 0, SI_VAR(6), SI_VAR(7), SI_VAR(8), 100, 0, 0, 0, 0, 0, 0, 0, 0), SI_CMD(ScriptOpcode_END_LOOP),
SI_END_LOOP(), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_END_SPAWN_THREAD),
SI_END_THREAD(), SI_CMD(ScriptOpcode_IF_NE, SI_VAR(5), 0),
SI_IF_NE(SI_VAR(5), 0), SI_CMD(ScriptOpcode_AWAIT_SCRIPT, 0xFE363C85),
SI_EXEC_WAIT(0xFE363C85), SI_CMD(ScriptOpcode_END_IF),
SI_END_IF(), SI_CMD(ScriptOpcode_SLEEP_FRAMES, 15),
SI_WAIT_FRAMES(15), SI_CMD(ScriptOpcode_RETURN),
SI_RETURN(), SI_CMD(ScriptOpcode_END)
SI_END(),
}; };
// *INDENT-ON* // *INDENT-ON*
@ -205,41 +203,36 @@ s32 M(treeEffectVectors_Tree1)[] = {
0x00000002, 0xFFFFFFB0, 0x00000082, 0x00000012, 0x0000001C, 0x00000082, 0x00000027, 0x00000002, 0xFFFFFFB0, 0x00000082, 0x00000012, 0x0000001C, 0x00000082, 0x00000027,
}; };
// *INDENT-OFF* Script M(Tree1_Callback) = SCRIPT({
Script M(script_Tree1_Callback) = { if SI_SAVE_FLAG(53) == 1 {
SI_IF_EQ(SI_SAVE_FLAG(53), 1), return
SI_RETURN(), }
SI_END_IF(), if SI_MAP_FLAG(10) == 1 {
SI_IF_EQ(SI_MAP_FLAG(10), 1), return
SI_RETURN(), }
SI_END_IF(), sleep 10
SI_WAIT_FRAMES(10), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), if SI_VAR(0) < 0xFFFFFFE2 {
SI_IF_LT(SI_VAR(0), 0xFFFFFFE2), MakeItemEntity(138, 0xFFFFFFE9, 100, 35, 13, SI_SAVE_FLAG(53))
SI_CALL(0x802D6CC0, 138, 0xFFFFFFE9, 100, 35, 13, SI_SAVE_FLAG(53)), } else {
SI_ELSE(), MakeItemEntity(138, 0xFFFFFFAB, 100, 16, 13, SI_SAVE_FLAG(53))
SI_CALL(0x802D6CC0, 138, 0xFFFFFFAB, 100, 16, 13, SI_SAVE_FLAG(53)), }
SI_END_IF(), SI_MAP_FLAG(10) = 1
SI_SET(SI_MAP_FLAG(10), 1), });
SI_RETURN(),
SI_END(),
};
// *INDENT-ON*
s32 M(shakeTreeEvent_Tree1)[] = { s32 M(shakeTreeEvent_Tree1)[] = {
M(treeModelList_Tree1_Leaves), M(treeModelList_Tree1_Trunk), 0x00000000, M(treeEffectVectors_Tree1), M(script_Tree1_Callback), M(treeModelList_Tree1_Leaves), M(treeModelList_Tree1_Trunk), 0x00000000, M(treeEffectVectors_Tree1), M(Tree1_Callback),
}; };
s32 M(triggerCoord_802422A8)[] = { s32 M(triggerCoord_802422A8)[] = {
0xC2280000, 0x00000000, 0xC1500000, 0x00000000, 0xC2280000, 0x00000000, 0xC1500000, 0x00000000,
}; };
Script M(script_802422B8) = { Script M(Script_802422B8) = SCRIPT({
SI_SET(SI_VAR(0), M(searchBushEvent_Bush1)), SI_VAR(0) = M(searchBushEvent_Bush1)
SI_BIND(M(script_SearchBush_802417F0), TriggerFlag_WALL_INTERACT, 53, NULL), bind M(SearchBush_802417F0) to TriggerFlag_WALL_INTERACT 53
SI_SET(SI_VAR(0), M(shakeTreeEvent_Tree1)), SI_VAR(0) = M(shakeTreeEvent_Tree1)
SI_BIND(M(script_ShakeTree_80241B50), TriggerFlag_WALL_HAMMER, 52, NULL), bind M(ShakeTree_80241B50) to TriggerFlag_WALL_HAMMER 52
SI_BIND(M(script_ShakeTree_80241B50), TriggerFlag_BOMB, M(triggerCoord_802422A8), NULL), bind M(ShakeTree_80241B50) to TriggerFlag_BOMB M(triggerCoord_802422A8)
SI_RETURN(), });
SI_END(),
};

View File

@ -1,90 +1,86 @@
#include "kmr_03.h" #include "kmr_03.h"
// *INDENT-OFF* Script M(Script_80242340) = SCRIPT({
Script M(script_80242340) = { UseSettingsFrom(0, 0xFFFFFEF2, 20, 0xFFFFFFB0)
SI_CALL(0x802CB860, 0, 0xFFFFFEF2, 20, 0xFFFFFFB0), SetPanTarget(0, 0xFFFFFEF2, 20, 0xFFFFFFB0)
SI_CALL(0x802CBE2C, 0, 0xFFFFFEF2, 20, 0xFFFFFFB0), SetCamDistance(0, 700.0)
SI_CALL(0x802CBBE4, 0, SI_FIXED(700.0f)), SetCamSpeed(0, 90.0)
SI_CALL(0x802CBEF0, 0, SI_FIXED(90.0f)), PanToTarget(0, 0, 1)
SI_CALL(0x802CB79C, 0, 0, 1), if SI_SAVE_VAR(0) >= 0xFFFFFF89 {
SI_IF_GE(SI_SAVE_VAR(0), 0xFFFFFF89), SetPlayerPos(0, 0xFFFFFC18, 0)
SI_CALL(0x802D0EF0, 0, 0xFFFFFC18, 0), DisablePlayerInput(1)
SI_CALL(0x802D0E28, 1), SetPlayerPos(0xFFFFFF20, 20, 0xFFFFFFB0)
SI_CALL(0x802D0EF0, 0xFFFFFF20, 20, 0xFFFFFFB0), SetNpcPos(0xFFFFFFFC, 0xFFFFFF20, 20, 0xFFFFFFB0)
SI_CALL(0x802CDCB0, 0xFFFFFFFC, 0xFFFFFF20, 20, 0xFFFFFFB0), sleep 20
SI_WAIT_FRAMES(20), SetCamSpeed(0, 3.0)
SI_CALL(0x802CBEF0, 0, SI_FIXED(3.0f)), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), UseSettingsFrom(0, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CB860, 0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SetPanTarget(0, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CBE2C, 0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), PanToTarget(0, 0, 1)
SI_CALL(0x802CB79C, 0, 0, 1), WaitForCam(0, 1.0)
SI_CALL(0x802CC354, 0, SI_FIXED(1.0f)), PanToTarget(0, 0, 0)
SI_CALL(0x802CB79C, 0, 0, 0), DisablePlayerInput(0)
SI_CALL(0x802D0E28, 0), return
SI_RETURN(), }
SI_END_IF(), DisablePlayerInput(1)
SI_CALL(0x802D0E28, 1), DisablePlayerPhysics(1)
SI_CALL(0x802D0DE4, 1), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SetPlayerPos(SI_VAR(0), 0xFFFFFC18, SI_VAR(2))
SI_CALL(0x802D0EF0, SI_VAR(0), 0xFFFFFC18, SI_VAR(2)), sleep 30
SI_WAIT_FRAMES(30), SetCamDistance(0, 220)
SI_CALL(0x802CBBE4, 0, 220), SetCamSpeed(0, 1.0)
SI_CALL(0x802CBEF0, 0, SI_FIXED(1.0f)), PanToTarget(0, 0, 1)
SI_CALL(0x802CB79C, 0, 0, 1), WaitForCam(0, 1.0)
SI_CALL(0x802CC354, 0, SI_FIXED(1.0f)), spawn {
SI_THREAD(), sleep 18
SI_WAIT_FRAMES(18), PlaySoundAtPlayer(373, 0)
SI_CALL(0x802D2CD8, 373, 0), sleep 30
SI_WAIT_FRAMES(30), PlaySoundAtPlayer(374, 0)
SI_CALL(0x802D2CD8, 374, 0), sleep 28
SI_WAIT_FRAMES(28), PlaySoundAtPlayer(373, 0)
SI_CALL(0x802D2CD8, 373, 0), }
SI_END_THREAD(), HidePlayerShadow(1)
SI_CALL(0x802D0DA0, 1), SetPlayerAnimation(0x10002)
SI_CALL(0x802D1084, 0x10002), SetPlayerPos(0xFFFFFF20, 120, 0xFFFFFFB0)
SI_CALL(0x802D0EF0, 0xFFFFFF20, 120, 0xFFFFFFB0), InterpPlayerYaw(90, 0)
SI_CALL(0x802D193C, 90, 0), 0:
SI_LABEL(0), sleep 1
SI_WAIT_FRAMES(1), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SI_VAR(1) += 0xFFFFFFFE
SI_ADD(SI_VAR(1), 0xFFFFFFFE), SetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D0EF0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), if SI_VAR(1) > 86 {
SI_IF_GT(SI_VAR(1), 86), goto 0
SI_GOTO(0), }
SI_END_IF(), SetPlayerPos(0xFFFFFECA, 20, 0xFFFFFFB0)
SI_CALL(0x802D0EF0, 0xFFFFFECA, 20, 0xFFFFFFB0), spawn {
SI_THREAD(), sleep 20
SI_WAIT_FRAMES(20), SetPanTarget(0, 0xFFFFFECA, 20, 0xFFFFFFB0)
SI_CALL(0x802CBE2C, 0, 0xFFFFFECA, 20, 0xFFFFFFB0), SetCamSpeed(0, 0.2001953125)
SI_CALL(0x802CBEF0, 0, SI_FIXED(0.2)), PanToTarget(0, 0, 1)
SI_CALL(0x802CB79C, 0, 0, 1), }
SI_END_THREAD(), 0x802D286C(0x2800)
SI_CALL(0x802D286C, 0x2800), 0x802D2520(0x10002, 5, 5, 1, 1, 0)
SI_CALL(0x802D2520, 0x10002, 5, 5, 1, 1, 0), sleep 100
SI_WAIT_FRAMES(100), WaitForCam(0, 1.0)
SI_CALL(0x802CC354, 0, SI_FIXED(1.0f)), 0x802D2520(0x10002, 0, 0, 0, 0, 0)
SI_CALL(0x802D2520, 0x10002, 0, 0, 0, 0, 0), HidePlayerShadow(0)
SI_CALL(0x802D0DA0, 0), SetPlayerAnimation(0x10006)
SI_CALL(0x802D1084, 0x10006), sleep 10
SI_WAIT_FRAMES(10), SetPlayerAnimation(0x10007)
SI_CALL(0x802D1084, 0x10007), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SetPlayerJumpscale(1.0)
SI_CALL(0x802D1054, SI_FIXED(1.0f)), PlayerJump(SI_VAR(0), SI_VAR(1), SI_VAR(2), 10)
SI_CALL(0x802D18E8, SI_VAR(0), SI_VAR(1), SI_VAR(2), 10), SetPlayerAnimation(0x10002)
SI_CALL(0x802D1084, 0x10002), spawn {
SI_THREAD(), SetCamSpeed(0, 3.0)
SI_CALL(0x802CBEF0, 0, SI_FIXED(3.0f)), GetPlayerPos(SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802D1DFC, SI_VAR(0), SI_VAR(1), SI_VAR(2)), UseSettingsFrom(0, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CB860, 0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), SetPanTarget(0, SI_VAR(0), SI_VAR(1), SI_VAR(2))
SI_CALL(0x802CBE2C, 0, SI_VAR(0), SI_VAR(1), SI_VAR(2)), PanToTarget(0, 0, 1)
SI_CALL(0x802CB79C, 0, 0, 1), WaitForCam(0, 1.0)
SI_CALL(0x802CC354, 0, SI_FIXED(1.0f)), PanToTarget(0, 0, 0)
SI_CALL(0x802CB79C, 0, 0, 0), }
SI_END_THREAD(), sleep 30
SI_WAIT_FRAMES(30), DisablePlayerPhysics(0)
SI_CALL(0x802D0DE4, 0), DisablePlayerInput(0)
SI_CALL(0x802D0E28, 0), });
SI_RETURN(),
SI_END(),
};
// *INDENT-ON*

View File

@ -5,4 +5,4 @@
ApiStatus func_80240000_8C7F90(ScriptInstance* script, s32 isInitialCall); ApiStatus func_80240000_8C7F90(ScriptInstance* script, s32 isInitialCall);
Script M(Main); Script M(Main);
Script M(script_802406C0); Script M(Script_802406C0);

View File

@ -5,7 +5,7 @@ from lark import Lark, exceptions, Tree, Transformer, Visitor, v_args, Token
from lark.visitors import Discard from lark.visitors import Discard
import traceback import traceback
DEBUG_OUTPUT = None DEBUG_OUTPUT = "debug.i"
def eprint(*args, **kwargs): def eprint(*args, **kwargs):
print(*args, file=stderr, **kwargs) print(*args, file=stderr, **kwargs)
@ -64,7 +64,7 @@ script_parser = Lark(r"""
| "spawn" block -> spawn_block_stmt | "spawn" block -> spawn_block_stmt
| "parallel" block -> parallel_block_stmt | "parallel" block -> parallel_block_stmt
call: CNAME "(" [expr ("," expr)* [","]] ")" call: (CNAME | HEX_INT) "(" [expr ("," expr)* [","]] ")"
if_stmt: "if" expr cond_op expr block ["else" block] if_stmt: "if" expr cond_op expr block ["else" block]
@ -102,7 +102,7 @@ script_parser = Lark(r"""
?expr: c_const_expr ?expr: c_const_expr
| ESCAPED_STRING | ESCAPED_STRING
| SIGNED_INT | SIGNED_INT
| DECIMAL | SIGNED_DECIMAL
| HEX_INT | HEX_INT
| CNAME | CNAME
@ -131,6 +131,7 @@ script_parser = Lark(r"""
%import common.HEXDIGIT %import common.HEXDIGIT
%import common.ESCAPED_STRING %import common.ESCAPED_STRING
SIGNED_DECIMAL: ["+"|"-"] DECIMAL
HEX_INT: ["+"|"-"] "0x" HEXDIGIT+ HEX_INT: ["+"|"-"] "0x" HEXDIGIT+
LINE_COMMENT: "//" /[^\n]*/ NEWLINE LINE_COMMENT: "//" /[^\n]*/ NEWLINE
@ -190,18 +191,18 @@ class CmdCtx():
class RootCtx(CmdCtx): class RootCtx(CmdCtx):
def break_opcode(self, meta): def break_opcode(self, meta):
return 0x01 return "ScriptOpcode_END"
class IfCtx(CmdCtx): class IfCtx(CmdCtx):
pass pass
class MatchCtx(CmdCtx): class MatchCtx(CmdCtx):
def break_opcode(self, meta): def break_opcode(self, meta):
return 0x22 return "ScriptOpcode_BREAK_MATCH"
class LoopCtx(CmdCtx): class LoopCtx(CmdCtx):
def break_opcode(self, meta): def break_opcode(self, meta):
return 0x07 return "ScriptOpcode_BREAK_LOOP"
class LoopUntilCtx(CmdCtx): class LoopUntilCtx(CmdCtx):
def break_opcode(self, meta): def break_opcode(self, meta):
@ -282,7 +283,7 @@ class Compile(Transformer):
def c_const_expr(self, tree): def c_const_expr(self, tree):
return f"(Bytecode){tree.children[0]}" return f"(Bytecode){tree.children[0]}"
def DECIMAL(self, v): def SIGNED_DECIMAL(self, v):
# fixed-point # fixed-point
return int((float(v) * 1024) - 230000000) return int((float(v) * 1024) - 230000000)
@ -307,22 +308,32 @@ class Compile(Transformer):
def call(self, tree): def call(self, tree):
# TODO: type checking etc # TODO: type checking etc
return Cmd(0x43, *tree.children, meta=tree.meta) return Cmd("ScriptOpcode_CALL", *tree.children, meta=tree.meta)
def if_stmt(self, tree): def if_stmt(self, tree):
a, op, b, block = tree.children if len(tree.children) == 4: # no else
for cmd in block: a, op, b, block = tree.children
if isinstance(cmd, BaseCmd): for cmd in block:
cmd.add_context(IfCtx()) if isinstance(cmd, BaseCmd):
return [ Cmd(op["if"], a, b, meta=tree.meta), *block, Cmd(0x13) ] cmd.add_context(IfCtx())
return [ Cmd(op["if"], a, b, meta=tree.meta), *block, Cmd("ScriptOpcode_END_IF") ]
else:
a, op, b, block, else_block = tree.children
for cmd in block:
if isinstance(cmd, BaseCmd):
cmd.add_context(IfCtx())
for cmd in else_block:
if isinstance(cmd, BaseCmd):
cmd.add_context(IfCtx())
return [ Cmd(op["if"], a, b, meta=tree.meta), *block, Cmd("ScriptOpcode_ELSE"), *else_block, Cmd("ScriptOpcode_END_IF") ]
def cond_op_eq(self, tree): return { "if": 0x0A, "case": 0x16 } def cond_op_eq(self, tree): return { "if": "ScriptOpcode_IF_EQ", "case": "ScriptOpcode_CASE_EQ" }
def cond_op_ne(self, tree): return { "if": 0x0B, "case": 0x17 } def cond_op_ne(self, tree): return { "if": "ScriptOpcode_IF_NE", "case": "ScriptOpcode_CASE_NE" }
def cond_op_lt(self, tree): return { "if": 0x0C, "case": 0x18 } def cond_op_lt(self, tree): return { "if": "ScriptOpcode_IF_LT", "case": "ScriptOpcode_CASE_LT" }
def cond_op_gt(self, tree): return { "if": 0x0D, "case": 0x19 } def cond_op_gt(self, tree): return { "if": "ScriptOpcode_IF_GT", "case": "ScriptOpcode_CASE_GT" }
def cond_op_le(self, tree): return { "if": 0x0E, "case": 0x1A } def cond_op_le(self, tree): return { "if": "ScriptOpcode_IF_LE", "case": "ScriptOpcode_CASE_LE" }
def cond_op_ge(self, tree): return { "if": 0x0F, "case": 0x1B } def cond_op_ge(self, tree): return { "if": "ScriptOpcode_IF_GE", "case": "ScriptOpcode_CASE_GE" }
def cond_op_flag(self, tree): return { "if": 0x10, "case": 0x1F } def cond_op_flag(self, tree): return { "if": "ScriptOpcode_IF_FLAG", "case": "ScriptOpcode_CASE_FLAG" }
def match_stmt(self, tree): def match_stmt(self, tree):
expr = tree.children[0] expr = tree.children[0]
@ -331,7 +342,6 @@ class Compile(Transformer):
for node in tree.children[1:]: for node in tree.children[1:]:
if type(node) is list: if type(node) is list:
for el in node: for el in node:
eprint(el)
if type(el) is list: if type(el) is list:
cases += el cases += el
else: else:
@ -344,13 +354,13 @@ class Compile(Transformer):
raise Exception(f"uncompiled match case: {cmd}") raise Exception(f"uncompiled match case: {cmd}")
return [ return [
Cmd(0x14, expr, meta=tree.meta), Cmd("ScriptOpcode_MATCH", expr, meta=tree.meta),
*cases, *cases,
Cmd(0x24), Cmd("ScriptOpcode_END_MATCH"),
] ]
def match_const_stmt(self, tree): def match_const_stmt(self, tree):
commands = self.match_stmt(tree) commands = self.match_stmt(tree)
commands[0].opcode = 0x15 commands[0].opcode = "ScriptOpcode_MATCH_CONST"
return commands return commands
def match_cases(self, tree): def match_cases(self, tree):
if len(tree.children) == 1: if len(tree.children) == 1:
@ -359,27 +369,27 @@ class Compile(Transformer):
return [tree.children[0], *tree.children[2]] return [tree.children[0], *tree.children[2]]
def case_else(self, tree): def case_else(self, tree):
return [Cmd(0x1C), *tree.children[0]] return [Cmd("ScriptOpcode_ELSE"), *tree.children[0]]
def case_op(self, tree): def case_op(self, tree):
if len(tree.children) == 4: if len(tree.children) == 4:
op, expr, multi_case, block = tree.children op, expr, multi_case, block = tree.children
return [Cmd(op["case"], expr), *multi_case, *block, Cmd(0x20)] return [Cmd(op["case"], expr), *multi_case, *block, Cmd("ScriptOpcode_END_CASE_MULTI")]
else: else:
op, expr, block = tree.children op, expr, block = tree.children
return [Cmd(op["case"], expr), *block] return [Cmd(op["case"], expr), *block]
def case_range(self, tree): def case_range(self, tree):
if len(tree.children) == 4: if len(tree.children) == 4:
a, b, multi_case, block = tree.children a, b, multi_case, block = tree.children
return [Cmd(0x21, a, b), *multi_case, *block, Cmd(0x20)] return [Cmd("ScriptOpcode_CASE_RANGE", a, b), *multi_case, *block, Cmd("ScriptOpcode_END_CASE_MULTI")]
else: else:
a, b, block = tree.children a, b, block = tree.children
return [Cmd(0x21, a, b), *block] return [Cmd("ScriptOpcode_CASE_RANGE", a, b), *block]
def case_multi(self, tree): def case_multi(self, tree):
multi_case, block = tree.children multi_case, block = tree.children
return [*multi_case, *block, Cmd(0x20)] return [*multi_case, *block, Cmd("ScriptOpcode_END_CASE_MULTI")]
def multi_case(self, tree): def multi_case(self, tree):
return [Cmd(0x1D, expr) for expr in tree.children] return [Cmd("ScriptOpcode_CASE_MULTI_EQ", expr) for expr in tree.children]
def loop_stmt(self, tree): def loop_stmt(self, tree):
expr = tree.children.pop(0) if len(tree.children) > 1 else 0 expr = tree.children.pop(0) if len(tree.children) > 1 else 0
@ -389,7 +399,7 @@ class Compile(Transformer):
if isinstance(cmd, BaseCmd): if isinstance(cmd, BaseCmd):
cmd.add_context(LoopCtx()) cmd.add_context(LoopCtx())
return [ Cmd(0x05, expr, meta=tree.meta), *block, Cmd(0x06) ] return [ Cmd("ScriptOpcode_LOOP", expr, meta=tree.meta), *block, Cmd("ScriptOpcode_END_LOOP") ]
# loop..until pseudoinstruction # loop..until pseudoinstruction
def loop_until_stmt(self, tree): def loop_until_stmt(self, tree):
@ -402,21 +412,21 @@ class Compile(Transformer):
label = self.alloc.gen_label() label = self.alloc.gen_label()
return [ return [
Cmd(0x03, label, meta=tree.meta), # label: Cmd("ScriptOpcode_LABEL", label, meta=tree.meta),
*block, *block,
Cmd(op["if"], a, b, meta=tree.meta), # if a op b Cmd(op["if"], a, b, meta=tree.meta),
Cmd(0x04, label, meta=tree.meta), # goto label Cmd("ScriptOpcode_GOTO", label, meta=tree.meta),
Cmd(0x13, meta=tree.meta), # end if Cmd("ScriptOpcode_END_IF", meta=tree.meta),
] ]
def return_stmt(self, tree): def return_stmt(self, tree):
return Cmd(0x02, meta=tree.meta) return Cmd("ScriptOpcode_RETURN", meta=tree.meta)
def break_stmt(self, tree): def break_stmt(self, tree):
return BreakCmd(meta=tree.meta) return BreakCmd(meta=tree.meta)
def set_group(self, tree): def set_group(self, tree):
return Cmd(0x4D, tree.children[0], meta=tree.meta) return Cmd("ScriptOpcode_SET_GROUP", tree.children[0], meta=tree.meta)
def suspend_stmt(self, tree): def suspend_stmt(self, tree):
commands = [] commands = []
@ -442,44 +452,44 @@ class Compile(Transformer):
def control_type_group(self, tree): def control_type_group(self, tree):
return { return {
"__control_type__": "group", "__control_type__": "group",
"suspend": 0x4F, "suspend": "ScriptOpcode_SUSPEND_GROUP",
"resume": 0x50, "resume": "ScriptOpcode_RESUME_GROUP",
} }
def control_type_others(self, tree): def control_type_others(self, tree):
return { return {
"__control_type__": "others", "__control_type__": "others",
"suspend": 0x51, "suspend": "ScriptOpcode_SUSPEND_OTHERS",
"resume": 0x52, "resume": "ScriptOpcode_RESUME_OTHERS",
} }
def control_type_script(self, tree): def control_type_script(self, tree):
return { return {
"__control_type__": "script", "__control_type__": "script",
"suspend": 0x53, "suspend": "ScriptOpcode_SUSPEND_SCRIPT",
"resume": 0x54, "resume": "ScriptOpcode_RESUME_SCRIPT",
"kill": 0x49, "kill": "ScriptOpcode_KILL_SCRIPT",
} }
def sleep_stmt(self, tree): def sleep_stmt(self, tree):
return Cmd(0x08, tree.children[0], meta=tree.meta) return Cmd("ScriptOpcode_SLEEP_FRAMES", tree.children[0], meta=tree.meta)
def sleep_secs_stmt(self, tree): def sleep_secs_stmt(self, tree):
return Cmd(0x09, tree.children[0], meta=tree.meta) return Cmd("ScriptOpcode_SLEEP_SECS", tree.children[0], meta=tree.meta)
def bind_stmt(self, tree): def bind_stmt(self, tree):
script, trigger, target = tree.children script, trigger, target = tree.children
return Cmd(0x47, script, trigger, target, 1, 0, meta=tree.meta) return Cmd("ScriptOpcode_BIND_TRIGGER", script, trigger, target, 1, 0, meta=tree.meta)
def bind_set_stmt(self, tree): def bind_set_stmt(self, tree):
ret, script, trigger, target = tree.children ret, script, trigger, target = tree.children
return Cmd(0x47, script, trigger, target, 1, ret, meta=tree.meta) return Cmd("ScriptOpcode_BIND_TRIGGER", script, trigger, target, 1, ret, meta=tree.meta)
def unbind_stmt(self, tree): def unbind_stmt(self, tree):
return Cmd(0x48, meta=tree.meta) return Cmd("ScriptOpcode_UNBIND", meta=tree.meta)
def spawn_stmt(self, tree): def spawn_stmt(self, tree):
return Cmd(0x44, tree.children[0], meta=tree.meta) return Cmd("ScriptOpcode_SPAWN_SCRIPT", tree.children[0], meta=tree.meta)
def spawn_set_stmt(self, tree): def spawn_set_stmt(self, tree):
lhs, script = tree.children lhs, script = tree.children
return Cmd(0x45, script, lhs, meta=tree.meta) return Cmd("ScriptOpcode_SPAWN_SCRIPT_GET_ID", script, lhs, meta=tree.meta)
def await_stmt(self, tree): def await_stmt(self, tree):
return Cmd(0x46, tree.children[0], meta=tree.meta) return Cmd("ScriptOpcode_AWAIT_SCRIPT", tree.children[0], meta=tree.meta)
def set_stmt(self, tree): def set_stmt(self, tree):
lhs, opcodes, rhs = tree.children lhs, opcodes, rhs = tree.children
@ -507,56 +517,56 @@ class Compile(Transformer):
def set_op_eq(self, tree): def set_op_eq(self, tree):
return { return {
"__op__": "=", "__op__": "=",
"int": 0x24, "int": "ScriptOpcode_SET",
"const": 0x25, "const": "ScriptOpcode_SET_CONST",
"float": 0x26, "float": "ScriptOpcode_SET_F",
} }
def set_op_add(self, tree): def set_op_add(self, tree):
return { return {
"__op__": "+", "__op__": "+",
"int": 0x27, "int": "ScriptOpcode_ADD",
"float": 0x2C, "float": "ScriptOpcode_ADD_F",
} }
def set_op_sub(self, tree): def set_op_sub(self, tree):
return { return {
"__op__": "-", "__op__": "-",
"int": 0x28, "int": "ScriptOpcode_SUB",
"float": 0x2D, "float": "ScriptOpcode_SUB_F",
} }
def set_op_mul(self, tree): def set_op_mul(self, tree):
return { return {
"__op__": "*", "__op__": "*",
"int": 0x29, "int": "ScriptOpcode_MUL",
"float": 0x2E, "float": "ScriptOpcode_MUL_F",
} }
def set_op_div(self, tree): def set_op_div(self, tree):
return { return {
"__op__": "/", "__op__": "/",
"int": 0x2A, "int": "ScriptOpcode_DIV",
"float": 0x2F, "float": "ScriptOpcode_DIV_F",
} }
def set_op_mod(self, tree): def set_op_mod(self, tree):
return { return {
"__op__": "%", "__op__": "%",
"int": 0x2B, "int": "ScriptOpcode_MOD",
} }
def set_op_and(self, tree): def set_op_and(self, tree):
return { return {
"__op__": "&", "__op__": "&",
"int": 0x3F, "int": "ScriptOpcode_AND",
"const": 0x41, "const": "ScriptOpcode_AND_CONST",
} }
def set_op_or(self, tree): def set_op_or(self, tree):
return { return {
"__op__": "|", "__op__": "|",
"int": 0x40, "int": "ScriptOpcode_OR",
"const": 0x42, "const": "ScriptOpcode_OR_CONST",
} }
def label_decl(self, tree): def label_decl(self, tree):
if len(tree.children) == 1: if len(tree.children) == 1:
label = tree.children[0] label = tree.children[0]
return Cmd(0x03, label, meta=tree.meta) return Cmd("ScriptOpcode_LABEL", label, meta=tree.meta)
else: else:
label, cmd_or_block = tree.children label, cmd_or_block = tree.children
@ -568,12 +578,12 @@ class Compile(Transformer):
cmd.add_context(LabelCtx(label)) cmd.add_context(LabelCtx(label))
return [ return [
Cmd(0x03, label, meta=tree.meta), Cmd("ScriptOpcode_LABEL", label, meta=tree.meta),
*cmd_or_block *cmd_or_block
] ]
def label_goto(self, tree): def label_goto(self, tree):
label = tree.children[0] label = tree.children[0]
return Cmd(0x04, label, meta=tree.meta) return Cmd("ScriptOpcode_GOTO", label, meta=tree.meta)
def label(self, tree): def label(self, tree):
name = tree.children[0] name = tree.children[0]
if name in self.alloc.labels: if name in self.alloc.labels:
@ -591,13 +601,13 @@ class Compile(Transformer):
for cmd in block: for cmd in block:
if isinstance(cmd, BaseCmd): if isinstance(cmd, BaseCmd):
cmd.add_context(SpawnCtx()) cmd.add_context(SpawnCtx())
return [ Cmd(0x56, meta=tree.meta), *block, Cmd(0x57) ] return [ Cmd("ScriptOpcode_SPAWN_THREAD", meta=tree.meta), *block, Cmd("ScriptOpcode_END_SPAWN_THREAD") ]
def parallel_block_stmt(self, tree): def parallel_block_stmt(self, tree):
block, = tree.children block, = tree.children
for cmd in block: for cmd in block:
if isinstance(cmd, BaseCmd): if isinstance(cmd, BaseCmd):
cmd.add_context(ParallelCtx()) cmd.add_context(ParallelCtx())
return [ Cmd(0x58, meta=tree.meta), *block, Cmd(0x59) ] return [ Cmd("ScriptOpcode_PARALLEL_THREAD", meta=tree.meta), *block, Cmd("ScriptOpcode_END_PARALLEL_THREAD") ]
def compile_script(s): def compile_script(s):
tree = script_parser.parse(s) tree = script_parser.parse(s)
@ -607,8 +617,8 @@ def compile_script(s):
commands = Compile().transform(tree) commands = Compile().transform(tree)
# add RETURN END if no explicit END (top-level `break') was given # add RETURN END if no explicit END (top-level `break') was given
if next((cmd for cmd in commands if cmd.opcode() == 0x01), None) == None: if next((cmd for cmd in commands if cmd.opcode() == "ScriptOpcode_END"), None) == None:
commands += (Cmd(0x02), Cmd(0x01)) commands += (Cmd("ScriptOpcode_RETURN"), Cmd("ScriptOpcode_END"))
return commands return commands

View File

@ -136,14 +136,14 @@ class ScriptDisassembler:
if trigger == 0x00010000: trigger = "TriggerFlag_SAVE_FLAG_SET" if trigger == 0x00010000: trigger = "TriggerFlag_SAVE_FLAG_SET"
if trigger == 0x00020000: trigger = "TriggerFlag_AREA_FLAG_SET" if trigger == 0x00020000: trigger = "TriggerFlag_AREA_FLAG_SET"
if trigger == 0x00100000: trigger = "TriggerFlag_BOMB" if trigger == 0x00100000: trigger = "TriggerFlag_BOMB"
return trigger return f"0x{trigger:X}" if type(trigger) is int else trigger
def read_word(self): def read_word(self):
return int.from_bytes(self.bytes.read(4), byteorder="big") return int.from_bytes(self.bytes.read(4), byteorder="big")
def disassemble_command(self, opcode, argc, argv): def disassemble_command(self, opcode, argc, argv):
if opcode == 0x01: if opcode == 0x01:
self.write_line("SI_END(),") self.write_line("SI_CMD(ScriptOpcode_END)")
self.indent -= 1 self.indent -= 1
if self.indent_used: if self.indent_used:
@ -156,167 +156,195 @@ class ScriptDisassembler:
self.write_line("};") self.write_line("};")
self.done = True self.done = True
elif opcode == 0x02: self.write_line(f"SI_RETURN(),") elif opcode == 0x02: self.write_line(f"SI_CMD(ScriptOpcode_RETURN),")
elif opcode == 0x03: self.write_line(f"SI_LABEL({self.var(argv[0])}),") elif opcode == 0x03: self.write_line(f"SI_CMD(ScriptOpcode_LABEL, {self.var(argv[0])}),")
elif opcode == 0x04: self.write_line(f"SI_GOTO({self.var(argv[0])}),") elif opcode == 0x04: self.write_line(f"SI_CMD(ScriptOpcode_GOTO, {self.var(argv[0])}),")
elif opcode == 0x05: elif opcode == 0x05:
self.write_line(f"SI_LOOP({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_LOOP, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x06: elif opcode == 0x06:
self.indent -= 1 self.indent -= 1
self.write_line("SI_END_LOOP(),") self.write_line("SI_CMD(ScriptOpcode_END_LOOP),")
elif opcode == 0x07: self.write_line(f"SI_BREAK_LOOP(),") elif opcode == 0x07: self.write_line(f"SI_CMD(ScriptOpcode_BREAK_LOOP),")
elif opcode == 0x08: self.write_line(f"SI_WAIT_FRAMES({self.var(argv[0])}),") elif opcode == 0x08: self.write_line(f"SI_CMD(ScriptOpcode_SLEEP_FRAMES, {self.var(argv[0])}),")
elif opcode == 0x09: self.write_line(f"SI_WAIT_SECS({self.var(argv[0])}),") elif opcode == 0x09: self.write_line(f"SI_CMD(ScriptOpcode_SLEEP_SECS, {self.var(argv[0])}),")
elif opcode == 0x0A: elif opcode == 0x0A:
self.write_line(f"SI_IF_EQ({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_EQ, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x0B: elif opcode == 0x0B:
self.write_line(f"SI_IF_NE({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_NE, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x0C: elif opcode == 0x0C:
self.write_line(f"SI_IF_LT({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_LT, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x0D: elif opcode == 0x0D:
self.write_line(f"SI_IF_GT({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_GT, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x0E: elif opcode == 0x0E:
self.write_line(f"SI_IF_LE({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_LE, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x0F: elif opcode == 0x0F:
self.write_line(f"SI_IF_GE({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_GE, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x10: elif opcode == 0x10:
self.write_line(f"SI_IF_BITS_ON({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_FLAG, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x11: elif opcode == 0x11:
self.write_line(f"SI_IF_BITS_OFF({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_IF_NOT_FLAG, ({self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x12: elif opcode == 0x12:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_ELSE(),") self.write_line(f"SI_CMD(ScriptOpcode_ELSE),")
self.indent += 1 self.indent += 1
elif opcode == 0x13: elif opcode == 0x13:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_END_IF(),") self.write_line(f"SI_CMD(ScriptOpcode_END_IF),")
elif opcode == 0x14: elif opcode == 0x14:
self.write_line(f"SI_SWITCH({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_MATCH, {self.var(argv[0])}),")
self.indent += 2 self.indent += 2
elif opcode == 0x15: elif opcode == 0x15:
self.write_line(f"SI_SWITCH_CONST(0x{argv[0]:X}),") self.write_line(f"SI_CMD(ScriptOpcode_MATCH_CONST, 0x{argv[0]:X}),")
self.indent += 2 self.indent += 2
elif opcode == 0x16: elif opcode == 0x16:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_EQ({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_EQ, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x17: elif opcode == 0x17:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_NE({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_NE, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x18: elif opcode == 0x18:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_LT({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_LT, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x19: elif opcode == 0x19:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_GT({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_GT, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x1A: elif opcode == 0x1A:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_LE({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_LE, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x1B: elif opcode == 0x1B:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_GE({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_GE, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x1C: elif opcode == 0x1C:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_DEFAULT(),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_ELSE),")
self.indent += 1 self.indent += 1
elif opcode == 0x1D: elif opcode == 0x1D:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_OR_EQ({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_MULTI_EQ, {self.var(argv[0])}),")
self.indent += 1
elif opcode == 0x1E:
self.indent -= 1
self.write_line(f"SI_CMD(ScriptOpcode_CASE_MULTI_NE, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
# opcode 0x1E?
elif opcode == 0x1F: elif opcode == 0x1F:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_BITS_ON({self.var(argv[0])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_FLAG, {self.var(argv[0])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x20: elif opcode == 0x20:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_END_MULTI_CASE(),") self.write_line(f"SI_CMD(ScriptOpcode_END_CASE_MULTI),")
self.indent += 1 self.indent += 1
elif opcode == 0x21: elif opcode == 0x21:
self.indent -= 1 self.indent -= 1
self.write_line(f"SI_CASE_RANGE({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD(ScriptOpcode_CASE_RANGE, {self.var(argv[0])}, {self.var(argv[1])}),")
self.indent += 1 self.indent += 1
elif opcode == 0x22: self.write_line(f"SI_BREAK_CASE(),") elif opcode == 0x22: self.write_line(f"SI_CMD(ScriptOpcode_BREAK_CASE),")
elif opcode == 0x23: elif opcode == 0x23:
self.indent -= 2 self.indent -= 2
self.write_line(f"SI_END_SWITCH(),") self.write_line(f"SI_CMD(ScriptOpcode_END_MATCH),")
elif opcode == 0x24: self.write_line(f"SI_SET({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x24: self.write_line(f"SI_CMD(ScriptOpcode_SET, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x25: self.write_line(f"SI_SET_CONST({self.var(argv[0])}, 0x{argv[1]:X}),") elif opcode == 0x25: self.write_line(f"SI_CMD(ScriptOpcode_SET_CONST, {self.var(argv[0])}, 0x{argv[1]:X}),")
elif opcode == 0x26: self.write_line(f"SI_SET_F({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x26: self.write_line(f"SI_CMD(ScriptOpcode_SET_F, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x27: self.write_line(f"SI_ADD({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x27: self.write_line(f"SI_CMD(ScriptOpcode_ADD, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x28: self.write_line(f"SI_SUB({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x28: self.write_line(f"SI_CMD(ScriptOpcode_SUB, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x29: self.write_line(f"SI_MUL({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x29: self.write_line(f"SI_CMD(ScriptOpcode_MUL, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x2A: self.write_line(f"SI_DIV({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x2A: self.write_line(f"SI_CMD(ScriptOpcode_DIV, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x2B: self.write_line(f"SI_MOD({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x2B: self.write_line(f"SI_CMD(ScriptOpcode_MOD, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x2C: self.write_line(f"SI_ADD_F({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x2C: self.write_line(f"SI_CMD(ScriptOpcode_ADD_F, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x2D: self.write_line(f"SI_SUB_F({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x2D: self.write_line(f"SI_CMD(ScriptOpcode_SUB_F, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x2E: self.write_line(f"SI_MUL_F({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x2E: self.write_line(f"SI_CMD(ScriptOpcode_MUL_F, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x2F: self.write_line(f"SI_DIV_F({self.var(argv[0])}, {self.var(argv[1])}),") elif opcode == 0x2F: self.write_line(f"SI_CMD(ScriptOpcode_DIV_F, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x30: self.write_line(f"SI_USE_BUFFER({self.var(argv[0])}),") elif opcode == 0x30: self.write_line(f"SI_CMD(ScriptOpcode_USE_BUFFER, {self.var(argv[0])}),")
# TODO: SI_BUF commands elif opcode == 0x31:
elif opcode == 0x3C: self.write_line(f"SI_USE_ARRAY({self.var(argv[0])}),") args = ["ScriptOpcode_BUFFER_READ_1",*map(self.var, argv)]
elif opcode == 0x3D: self.write_line(f"SI_NEW_ARRAY({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x3E: self.write_line(f"SI_USE_FLAGS({self.var(argv[0])}),") elif opcode == 0x32:
elif opcode == 0x3F: self.write_line(f"SI_AND({self.var(argv[0])}, {self.var(argv[1])}),") args = ["ScriptOpcode_BUFFER_READ_2",*map(self.var, argv)]
elif opcode == 0x40: self.write_line(f"SI_OR({self.var(argv[0])}, {self.var(argv[1])}),") self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x41: self.write_line(f"SI_AND_CONST({self.var(argv[0])}, 0x{argv[1]:X})") elif opcode == 0x33:
elif opcode == 0x42: self.write_line(f"SI_OR_CONST({self.var(argv[0])}, 0x{argv[1]:X})") args = ["ScriptOpcode_BUFFER_READ_3",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x34:
args = ["ScriptOpcode_BUFFER_READ_4",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x35:
args = ["ScriptOpcode_BUFFER_PEEK",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x36: self.write_line(f"SI_CMD(ScriptOpcode_USE_BUFFER_f, {self.var(argv[0])}),")
elif opcode == 0x37:
args = ["ScriptOpcode_BUFFER_READ_1_F",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x38:
args = ["ScriptOpcode_BUFFER_READ_2_F",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x39:
args = ["ScriptOpcode_BUFFER_READ_3_F",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x3A:
args = ["ScriptOpcode_BUFFER_READ_4_F",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x3B:
args = ["ScriptOpcode_BUFFER_PEEK_F",*map(self.var, argv)]
self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x3C: self.write_line(f"SI_CMD(ScriptOpcode_USE_ARRAY, {self.var(argv[0])}),")
elif opcode == 0x3D: self.write_line(f"SI_CMD(ScriptOpcode_NEW_ARRAY, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x3E: self.write_line(f"SI_CMD(ScriptOpcode_USE_FLAGS, {self.var(argv[0])}),")
elif opcode == 0x3F: self.write_line(f"SI_CMD(ScriptOpcode_AND, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x40: self.write_line(f"SI_CMD(ScriptOpcode_OR, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x41: self.write_line(f"SI_CMD(ScriptOpcode_AND_CONST, {self.var(argv[0])}, 0x{argv[1]:X})")
elif opcode == 0x42: self.write_line(f"SI_CMD(ScriptOpcode_OR_CONST, {self.var(argv[0])}, 0x{argv[1]:X})")
elif opcode == 0x43: elif opcode == 0x43:
argv_str = "" args = ["ScriptOpcode_CALL", self.addr_ref(argv[0]), *map(self.var, argv[1:])]
for arg in argv[1:]: self.write_line(f"SI_CMD({', '.join(args)}),")
argv_str += ", " elif opcode == 0x44: self.write_line(f"SI_CMD(ScriptOpcode_SPAWN, {self.addr_ref(argv[0])}),")
argv_str += self.var(arg) elif opcode == 0x45: self.write_line(f"SI_CMD(ScriptOpcode_SPAWN_GET_ID, {self.addr_ref(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x46: self.write_line(f"SI_CMD(ScriptOpcode_AWAIT_SCRIPT, {self.addr_ref(argv[0])}),")
self.write_line(f"SI_CALL({self.addr_ref(argv[0])}{argv_str}),")
elif opcode == 0x44: self.write_line(f"SI_EXEC({self.addr_ref(argv[0])}),")
elif opcode == 0x45: self.write_line(f"SI_EXEC_GET_ID({self.addr_ref(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x46: self.write_line(f"SI_EXEC_WAIT({self.addr_ref(argv[0])}),")
elif opcode == 0x47: elif opcode == 0x47:
assert argv[3] == 1 args = ["ScriptOpcode_BIND_TRIGGER", self.addr_ref(argv[0]), self.trigger(argv[1]), *map(self.var, argv[2:])]
self.write_line(f"SI_BIND({self.addr_ref(argv[0])}, {self.trigger(argv[1])}, {self.var(argv[2])}, {'NULL' if argv[4] == 0 else self.var(argv[4])}),") self.write_line(f"SI_CMD({', '.join(args)}),")
elif opcode == 0x48: self.write_line(f"SI_UNBIND_ME(),") elif opcode == 0x48: self.write_line(f"SI_CMD(ScriptOpcode_UNBIND),")
elif opcode == 0x49: self.write_line(f"SI_KILL({self.var(argv[0])}),") elif opcode == 0x49: self.write_line(f"SI_CMD(ScriptOpcode_KILL_SCRIPT, {self.var(argv[0])}),")
elif opcode == 0x4A: self.write_line(f"SI_JUMP({self.var(argv[0])}),") elif opcode == 0x4A: self.write_line(f"SI_CMD(ScriptOpcode_JUMP, {self.var(argv[0])}),")
elif opcode == 0x4B: self.write_line(f"SI_PRIORITY({self.var(argv[0])}),") elif opcode == 0x4B: self.write_line(f"SI_CMD(ScriptOpcode_SET_PRIORITY, {self.var(argv[0])}),")
elif opcode == 0x4C: self.write_line(f"SI_TIMESCALE({self.var(argv[0])}),") elif opcode == 0x4C: self.write_line(f"SI_CMD(ScriptOpcode_SET_TIMESCALE, {self.var(argv[0])}),")
elif opcode == 0x4D: self.write_line(f"SI_GROUP({self.var(argv[0])}),") elif opcode == 0x4D: self.write_line(f"SI_CMD(ScriptOpcode_SET_GROUP, {self.var(argv[0])}),")
elif opcode == 0x4E: elif opcode == 0x4E:
assert argv[4] == 0 args = ["ScriptOpcode_BIND_TRIGGER", self.addr_ref(argv[0]), self.trigger(argv[1]), *map(self.var, argv[2:])]
assert argv[5] == 1 self.write_line(f"SI_CMD({', '.join(args)}),")
self.write_line(f"SI_BIND_PADLOCK({self.addr_ref(argv[0])}, {self.trigger(argv[1])}, {self.var(argv[2])}, {self.var(argv[3])}),") elif opcode == 0x4F: self.write_line(f"SI_CMD(ScriptOpcode_SUSPEND_GROUP, {self.var(argv[0])}),")
elif opcode == 0x4F: self.write_line(f"SI_SUSPEND_GROUP({self.var(argv[0])}),") elif opcode == 0x50: self.write_line(f"SI_CMD(ScriptOpcode_RESUME_GROUP, {self.var(argv[0])}),")
elif opcode == 0x50: self.write_line(f"SI_RESUME_GROUP({self.var(argv[0])}),") elif opcode == 0x51: self.write_line(f"SI_CMD(ScriptOpcode_SUSPEND_OTHERS, {self.var(argv[0])}),")
elif opcode == 0x51: self.write_line(f"SI_SUSPEND_GROUP_NOT_ME({self.var(argv[0])}),") elif opcode == 0x52: self.write_line(f"SI_CMD(ScriptOpcode_RESUME_OTHERS, {self.var(argv[0])}),")
elif opcode == 0x52: self.write_line(f"SI_RESUME_GROUP_NOT_ME({self.var(argv[0])}),") elif opcode == 0x53: self.write_line(f"SI_CMD(ScriptOpcode_SUSPEND_SCRIPT, {self.var(argv[0])}),")
elif opcode == 0x53: self.write_line(f"SI_SUSPEND({self.var(argv[0])}),") elif opcode == 0x54: self.write_line(f"SI_CMD(ScriptOpcode_RESUME_SCRIPT, {self.var(argv[0])}),")
elif opcode == 0x54: self.write_line(f"SI_RESUME({self.var(argv[0])}),") elif opcode == 0x55: self.write_line(f"SI_CMD(ScriptOpcode_SCRIPT_EXISTS, {self.var(argv[0])}, {self.var(argv[1])}),")
elif opcode == 0x55: self.write_line(f"SI_EXISTS({self.var(argv[0])}),")
elif opcode == 0x56: elif opcode == 0x56:
self.write_line("SI_THREAD(),") self.write_line("SI_CMD(ScriptOpcode_SPAWN_THREAD),")
self.indent += 1 self.indent += 1
elif opcode == 0x57: elif opcode == 0x57:
self.indent -= 1 self.indent -= 1
self.write_line("SI_END_THREAD(),") self.write_line("SI_CMD(ScriptOpcode_END_SPAWN_THREAD),")
elif opcode == 0x58: elif opcode == 0x58:
self.write_line("SI_CHILD_THREAD(),") self.write_line("SI_CMD(ScriptOpcode_PARALLEL_THREAD),")
self.indent += 1 self.indent += 1
elif opcode == 0x59: elif opcode == 0x59:
self.indent -= 1 self.indent -= 1
self.write_line("SI_END_CHILD_THREAD(),") self.write_line("SI_CMD(ScriptOpcode_END_PARALLEL_THREAD),")
else: else:
# unknown opcode # unknown opcode
argv_str = "" argv_str = ""