update si types

This commit is contained in:
Alex Bates 2020-10-20 07:33:40 +01:00
parent a9310efa85
commit 99ac1cf053
No known key found for this signature in database
GPG Key ID: 5E11C2DB78877706
12 changed files with 136 additions and 125 deletions

View File

@ -201,7 +201,7 @@ typedef struct Trigger {
/* 0x28 */ char unk_28[8];
/* 0x30 */ u8 unk_30;
/* 0x31 */ char unk_31[3];
/* 0x34 */ s32 runningScriptID;
/* 0x34 */ ScriptID runningScriptID;
} Trigger; // size = 0x38
typedef struct ScriptInstance {
@ -232,7 +232,7 @@ typedef struct ScriptInstance {
/* 0x138 */ s32* buffer;
/* 0x13C */ s32* array;
/* 0x140 */ s32* flagArray;
/* 0x144 */ s32 uniqueID;
/* 0x144 */ ScriptID id;
/* 0x148 */ struct Enemy* ownerActorID; /* controller*, battle ID, trigger* */
/* 0x14C */ u32 ownerID; /* can be an npcID, a triggerID, a trigger ptr */
/* 0x150 */ f32 timeScale;
@ -525,9 +525,9 @@ typedef struct BattleStatus {
/* 0x0B4 */ UNK_FUN_PTR(preUpdateCallback);
/* 0x0B8 */ char unk_B8[4];
/* 0x0BC */ struct ScriptInstance* controlScript; /* control handed over to this when changing partners */
/* 0x0C0 */ s32 controlScriptID;
/* 0x0C0 */ ScriptID controlScriptID;
/* 0x0C4 */ struct ScriptInstance* camMovementScript;
/* 0x0C8 */ s32 camMovementScriptID;
/* 0x0C8 */ ScriptID camMovementScriptID;
/* 0x0CC */ char unk_CC[12];
/* 0x0D8 */ struct Actor* playerActor;
/* 0x0DC */ struct Actor* partnerActor;
@ -848,7 +848,7 @@ typedef struct GameStatus {
/* 0x068 */ s16 demoButtonInput;
/* 0x06A */ s8 demoStickX;
/* 0x06B */ s8 demoStickY;
/* 0x06C */ s32 mainScriptID;
/* 0x06C */ ScriptID mainScriptID;
/* 0x070 */ s8 isBattle;
/* 0x071 */ s8 demoState; /* (0 = not demo, 1 = map demo, 2 = demo map changing) */
/* 0x072 */ u8 nextDemoScene; /* which part of the demo to play next */
@ -1220,10 +1220,10 @@ typedef struct Actor {
/* 0x1D4 */ struct ScriptInstance* takeTurnScript;
/* 0x1D8 */ struct ScriptInstance* onHitScript;
/* 0x1DC */ struct ScriptInstance* onTurnChangeScript;
/* 0x1E0 */ s32 idleScriptID;
/* 0x1E4 */ s32 takeTurnID;
/* 0x1E8 */ s32 onHitID;
/* 0x1EC */ s32 onTurnChangeID;
/* 0x1E0 */ ScriptID idleScriptID;
/* 0x1E4 */ ScriptID takeTurnID;
/* 0x1E8 */ ScriptID onHitID;
/* 0x1EC */ ScriptID onTurnChangeID;
/* 0x1F0 */ u8 lastEventType;
/* 0x1F1 */ u8 turnPriority;
/* 0x1F2 */ u8 enemyIndex; /* actorID = this | 200 */

View File

@ -13,12 +13,15 @@ typedef Vec4f EntryList[];
typedef struct MapHeader {
/* 0x00 */ char unk_00[0x10];
/* 0x10 */ Bytecode* main;
/* 0x10 */ Script* main;
/* 0x14 */ EntryList* entryList;
/* 0x18 */ s32 entryCount;
/* 0x1C */ char unk_1C[0x1C];
/* 0x38 */ s32 background; // 0x80200000 if there is one, 0 otherwise
/* 0x3C */ UNK_FUN_PTR(tattle); // or string id
/* 0x38 */ BackgroundHeader* background;
/* 0x3C */ union {
MessageID msgID;
UNK_FUN_PTR(get);
} tattle;
} MapHeader; // size = 0x40
typedef struct NpcAISettings {
@ -36,21 +39,21 @@ typedef struct NpcAISettings {
/* 0x2C */ s32 unk_2C; // bool
} NpcAISettings; // size = 0x30
typedef struct StaticNpcSettings {
typedef struct NpcSettings {
/* 0x00 */ char unk_00[4];
/* 0x04 */ s16 height;
/* 0x06 */ s16 radius;
/* 0x08 */ UNK_PTR otherAI;
/* 0x0C */ Bytecode* interactScript;
/* 0x10 */ Bytecode* aiScript;
/* 0x14 */ Bytecode* hitScript;
/* 0x18 */ Bytecode* auxScript;
/* 0x1C */ Bytecode* defeatScript;
/* 0x0C */ Script* onInteract;
/* 0x10 */ Script* ai;
/* 0x14 */ Script* onHit;
/* 0x18 */ Script* aux;
/* 0x1C */ Script* onDefeat;
/* 0x20 */ s32 flags;
/* 0x24 */ char unk_24[4];
/* 0x28 */ s16 level;
/* 0x2A */ s16 unk_2A;
} StaticNpcSettings; // size = 0x2C
} NpcSettings; // size = 0x2C
typedef struct ItemDrop {
/* 0x00 */ ItemId item;
@ -120,7 +123,7 @@ typedef struct StatDrop {
typedef struct StaticNPC {
/* 0x000 */ NpcId id;
/* 0x004 */ StaticNpcSettings* settings;
/* 0x004 */ NpcSettings* settings;
/* 0x008 */ Vec3f pos;
/* 0x014 */ s32 flags;
/* 0x018 */ Bytecode* init;
@ -138,7 +141,7 @@ typedef struct StaticNPC {
/* 0x1A0 */ s32 animations[16];
/* 0x1E0 */ char unk_1E0[8];
/* 0x1E8 */ UNK_PTR extraAnimations;
/* 0x1EC */ s32 tattle;
/* 0x1EC */ MessageID tattle;
} StaticNpc; // size = 0x1F0
typedef struct Enemy {
@ -151,7 +154,7 @@ typedef struct Enemy {
/* 0x0A */ s16 spawnPos[3];
/* 0x10 */ Vec3s unk_10;
/* 0x16 */ char unk_16[2];
/* 0x18 */ struct StaticNpcSettings* npcSettings;
/* 0x18 */ struct NpcSettings* npcSettings;
/* 0x1C */ Bytecode* initBytecode;
/* 0x20 */ Bytecode* interactBytecode;
/* 0x24 */ Bytecode* aiBytecode;
@ -164,12 +167,12 @@ typedef struct Enemy {
/* 0x40 */ struct ScriptInstance* hitScript;
/* 0x44 */ struct ScriptInstance* auxScript;
/* 0x48 */ struct ScriptInstance* defeatScript;
/* 0x4C */ s32 initScriptID;
/* 0x50 */ s32 interactScriptID;
/* 0x54 */ s32 aiScriptID;
/* 0x58 */ s32 hitScriptID;
/* 0x5C */ s32 auxScriptID;
/* 0x60 */ s32 defeatScriptID;
/* 0x4C */ ScriptID initScriptID;
/* 0x50 */ ScriptID interactScriptID;
/* 0x54 */ ScriptID aiScriptID;
/* 0x58 */ ScriptID hitScriptID;
/* 0x5C */ ScriptID auxScriptID;
/* 0x60 */ ScriptID defeatScriptID;
/* 0x64 */ char unk_64[8];
/* 0x6C */ s32 varTable[16];
/* 0xAC */ char unk_AC[9];

View File

@ -259,76 +259,76 @@ ApiStatus GetDamageIntensity(ScriptInstance* script, s32 isInitialCall);
ApiStatus ActorAddMovePos(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadStarPowerScript(ScriptInstance* script, s32 isInitialCall);
extern Bytecode PlayerScriptDispatcher[];
extern Bytecode PeachScriptDispatcher[];
extern Bytecode ExecutePlayerAction[];
extern Bytecode ExecutePeachAction[];
extern Bytecode HandleEvent_Player[];
extern Bytecode BtlPutPartnerAway[];
extern Bytecode BtlBringPartnerOut[];
extern Bytecode MarioEnterStage[];
extern Bytecode PeachEnterStage[];
extern Bytecode PlayerFirstStrike[];
extern Bytecode StartDefend[];
extern Bytecode RunAwayStart[];
extern Bytecode RunAwayFail[];
extern Bytecode RunAwayReset[];
extern Bytecode PlayEatFX[];
extern Bytecode PlayDrinkFX[];
extern Bytecode UseLifeShroom[];
extern Bytecode MerleeRunOut[];
extern Bytecode MerleeAttackBonus[];
extern Bytecode MerleeDefenseBonus[];
extern Bytecode MerleeExpBonus[];
extern Bytecode PlayerHappy[];
extern Bytecode DoDizzyAttack[];
extern Bytecode RegainAbility[];
extern Bytecode UseMystery[];
extern Bytecode DoSleepHit[];
extern Bytecode DoDizzyHit[];
extern Bytecode DoParalyzeHit[];
extern Bytecode DoPoisonHit[];
extern Bytecode DoStopHit[];
extern Bytecode DoFreezeHit[];
extern Bytecode DoShinkHit[];
extern Bytecode ForceNextTarget[];
extern Bytecode DoNormalHit[];
extern Bytecode DoBurnHit[];
extern Bytecode DoShockHit[];
extern Bytecode DoImmune[];
extern Bytecode DoDeath[];
extern Bytecode Collapse[];
extern Bytecode DoScareAway[];
extern Bytecode DoSpinSmashHit[];
extern Bytecode DoJumpBack[];
extern Bytecode DoReturnHome[];
extern Bytecode DoRecover[];
extern Bytecode DoAirLift[];
extern Bytecode DoBlowAway[];
extern Bytecode Rumble_1[];
extern Bytecode Rumble_2[];
extern Bytecode Rumble_3[];
extern Bytecode Rumble_4[];
extern Bytecode Rumble_5[];
extern Bytecode Rumble_6[];
extern Bytecode Rumble_7[];
extern Bytecode Rumble_Unused_1[];
extern Bytecode Rumble_Unused_2[];
extern Bytecode Rumble_Unused_3[];
extern Bytecode Rumble_Unused_4[];
extern Bytecode CamPreset_A[];
extern Bytecode CamPreset_B[];
extern Bytecode CamPreset_C[];
extern Bytecode CamPreset_D[];
extern Bytecode CamPreset_E[];
extern Bytecode CamPreset_F[];
extern Bytecode CamPreset_G[];
extern Bytecode CamPreset_H[];
extern Bytecode CamPreset_I[];
extern Bytecode CamPreset_J[];
extern Bytecode CamPreset_K[];
extern Bytecode CamPreset_L[];
extern Bytecode CamPreset_M[];
extern Bytecode CamPreset_N[];
extern Script PlayerScriptDispatcher;
extern Script PeachScriptDispatcher;
extern Script ExecutePlayerAction;
extern Script ExecutePeachAction;
extern Script HandleEvent_Player;
extern Script BtlPutPartnerAway;
extern Script BtlBringPartnerOut;
extern Script MarioEnterStage;
extern Script PeachEnterStage;
extern Script PlayerFirstStrike;
extern Script StartDefend;
extern Script RunAwayStart;
extern Script RunAwayFail;
extern Script RunAwayReset;
extern Script PlayEatFX;
extern Script PlayDrinkFX;
extern Script UseLifeShroom;
extern Script MerleeRunOut;
extern Script MerleeAttackBonus;
extern Script MerleeDefenseBonus;
extern Script MerleeExpBonus;
extern Script PlayerHappy;
extern Script DoDizzyAttack;
extern Script RegainAbility;
extern Script UseMystery;
extern Script DoSleepHit;
extern Script DoDizzyHit;
extern Script DoParalyzeHit;
extern Script DoPoisonHit;
extern Script DoStopHit;
extern Script DoFreezeHit;
extern Script DoShinkHit;
extern Script ForceNextTarget;
extern Script DoNormalHit;
extern Script DoBurnHit;
extern Script DoShockHit;
extern Script DoImmune;
extern Script DoDeath;
extern Script Collapse;
extern Script DoScareAway;
extern Script DoSpinSmashHit;
extern Script DoJumpBack;
extern Script DoReturnHome;
extern Script DoRecover;
extern Script DoAirLift;
extern Script DoBlowAway;
extern Script Rumble_1;
extern Script Rumble_2;
extern Script Rumble_3;
extern Script Rumble_4;
extern Script Rumble_5;
extern Script Rumble_6;
extern Script Rumble_7;
extern Script Rumble_Unused_1;
extern Script Rumble_Unused_2;
extern Script Rumble_Unused_3;
extern Script Rumble_Unused_4;
extern Script CamPreset_A;
extern Script CamPreset_B;
extern Script CamPreset_C;
extern Script CamPreset_D;
extern Script CamPreset_E;
extern Script CamPreset_F;
extern Script CamPreset_G;
extern Script CamPreset_H;
extern Script CamPreset_I;
extern Script CamPreset_J;
extern Script CamPreset_K;
extern Script CamPreset_L;
extern Script CamPreset_M;
extern Script CamPreset_N;
#endif

View File

@ -267,7 +267,10 @@ ApiStatus func_802CFD30(ScriptInstance* script, s32 isInitialCall);
ApiStatus func_800441F0(ScriptInstance* script, s32 isInitialCall);
ApiStatus func_802D5830(ScriptInstance* script, s32 isInitialCall);
extern Bytecode* ShakeCam1;
extern Bytecode* ShakeCamX;
extern Script ShakeCam1;
extern Script ShakeCamX;
extern Script EnemyNpcHit;
extern Script EnemyNpcDefeat;
#endif

View File

@ -20,14 +20,14 @@ ApiStatus GetGridIndexFromPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPushBlockFallEffect(ScriptInstance* script, s32 isInitialCall);
ApiStatus TeleportPartnerToPlayer(ScriptInstance* script, s32 isInitialCall);
extern Bytecode EnterWalk[];
extern Bytecode EnterWalkShort[];
extern Bytecode EnterSavePoint[];
extern Bytecode ExitWalk[];
extern Bytecode ExitSingleDoor[];
extern Bytecode EnterSingleDoor[];
extern Bytecode ExitDoubleDoor[];
extern Bytecode EnterDoubleDoor[];
extern Script EnterWalk;
extern Script EnterWalkShort;
extern Script EnterSavePoint;
extern Script ExitWalk;
extern Script ExitSingleDoor;
extern Script EnterSingleDoor;
extern Script ExitDoubleDoor;
extern Script EnterDoubleDoor;
#endif

View File

@ -3,6 +3,9 @@
#include "ultra64.h"
typedef s32 Bytecode;
typedef s32 ScriptID;
#define SI_VAR(v) (v - 30000000)
#define SI_MAP_VAR(v) (v - 50000000)
#define SI_FLAG(v) (v - 70000000)
@ -147,6 +150,6 @@ typedef s32 ApiStatus;
SI_WAIT_FRAMES(100), \
SI_RETURN(), \
SI_END(), \
};
}
#endif

View File

@ -10,6 +10,4 @@
#define UNK_FUN_PTR(name) void(*name)(void)
#define UNK_ARGS
typedef s32 Bytecode;
#endif

View File

@ -8,15 +8,15 @@ s32 si_goto_end_case(ScriptInstance* script);
s32 si_goto_next_case(ScriptInstance* script);
s32 get_variable_index(ScriptInstance* script, s32 var);
f32 fixed_var_to_float(s32 scriptVar) {
f32 fixed_var_to_float(Bytecode scriptVar) {
if (scriptVar <= -220000000) {
return (scriptVar + 230000000) * (1 / 1024.0f);
return (scriptVar + 230000000) / 1024.0f;
} else {
return scriptVar;
}
}
s32 float_to_fixed_var(f32 value) {
Bytecode float_to_fixed_var(f32 value) {
return (s32)(value * 1024.0f) - 230000000;
}
@ -130,7 +130,6 @@ ApiStatus si_handle_if_equal(ScriptInstance* script) {
return ApiStatus_DONE2;
}
ApiStatus si_handle_if_not_equal(ScriptInstance* script) {
Bytecode* args = script->ptrReadPos;
@ -907,7 +906,7 @@ ApiStatus si_handle_exec2(ScriptInstance* script) {
newScript->array = script->array;
newScript->flagArray = script->flagArray;
set_variable(script, arg2, newScript->uniqueID);
set_variable(script, arg2, newScript->id);
return ApiStatus_DONE2;
}
@ -936,7 +935,7 @@ s32 _bound_script_trigger_handler(Trigger* trigger) {
script = start_script(scriptStart, trigger->priority, 0x20);
trigger->runningScript = script;
trigger->runningScriptID = script->uniqueID;
trigger->runningScriptID = script->id;
script->varTable[0] = trigger->scriptVars[0];
script->varTable[1] = trigger->scriptVars[1];
script->varTable[2] = trigger->scriptVars[2];
@ -1045,7 +1044,7 @@ ApiStatus si_handle_resume(ScriptInstance* script) {
ApiStatus si_handle_does_script_exist(ScriptInstance* script) {
Bytecode* args = script->ptrReadPos;
Bytecode scriptID = get_variable(script, *args++);
ScriptID scriptID = get_variable(script, *args++);
Bytecode var2 = *args++;
set_variable(script, var2, does_script_exist(scriptID));
@ -1056,7 +1055,7 @@ void si_standard_trigger_executor(Trigger* trigger) {
if (trigger->runningScript == NULL) {
ScriptInstance* newScript = start_script(trigger->scriptStart, trigger->priority, 0x20);
trigger->runningScript = newScript;
trigger->runningScriptID = newScript->uniqueID;
trigger->runningScriptID = newScript->id;
newScript->varTable[0] = trigger->scriptVars[0];
newScript->varTable[1] = trigger->scriptVars[1];
newScript->varTable[2] = trigger->scriptVars[2];

View File

@ -52,12 +52,12 @@ static Script goomba_ai = {
SI_END(),
};
static StaticNpcSettings goomba_npc_settings = {
static NpcSettings goomba_npc_settings = {
.height = 20,
.radius = 23,
.aiScript = &goomba_ai,
.hitScript = (Bytecode*)0x80077F70,
.defeatScript = (Bytecode*)0x8007809C,
.ai = &goomba_ai,
.onHit = EnemyNpcHit,
.onDefeat = EnemyNpcDefeat,
.level = 5,
};

View File

@ -9,7 +9,7 @@ MapHeader header = {
.main = kmr_12_main,
.entryList = entryList,
.entryCount = ENTRY_COUNT(entryList),
.background = 0x80200000,
.background = &gBackgroundImage,
.tattle = MessageID_TATTLE_KMR_12,
};

View File

@ -1894,3 +1894,5 @@ gSpeakingActorIdleAnim;0x8029FA70
gSpeakingActor;0x8029FA74
gSpeakingActorPart;0x8029FA7C
EnterWalk;0x80285960
EnemyNpcHit;0x80077F70
EnemyNpcDefeat;0x8007809C

View File

@ -257,3 +257,6 @@ DoSpinSmashHit = 0x8029B998;
DoStopHit = 0x80294650;
ShakeCam1 = 0x802D9CB0;
ShakeCamX = 0x802D9CE8;
EnemyNpcHit = 0x80077F70;
EnemyNpcDefeat = 0x8007809C;