begin script disassembly

This commit is contained in:
Alex Bates 2020-10-19 22:58:57 +01:00
parent 4d530df425
commit f9a667bc7d
No known key found for this signature in database
GPG Key ID: 5E11C2DB78877706
15 changed files with 1313 additions and 37 deletions

View File

@ -7,10 +7,10 @@ BUILD_DIR = build
WORLD_AREAS := area_dgb area_arn area_dro area_end area_flo area_gv area_hos area_isk area_iwa area_jan area_kgr area_kkj area_kmr area_kpa area_kzn area_mac area_mgm area_mim area_nok area_obk area_omo area_osr area_pra area_sam area_sbk area_tik area_trd area_tst
SRC_DIRS := src src/os src/os/nusys $(foreach area,$(WORLD_AREAS),src/world/$(area))
SRC_DIRS := $(shell find src -type d)
ASM_DIRS := asm asm/os
INCLUDE_DIRS := include include/PR src
DATA_DIRS := bin bin/world $(foreach area,$(WORLD_AREAS),bin/world/$(area))
DATA_DIRS := $(shell find bin -type d -not -name Yay0)
YAY0_DIRS := bin/Yay0
ASSETS_FS_DIRS := assets/fs

View File

@ -1,16 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_80240000_8EB360
/* 8EB360 80240000 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 8EB364 80240004 AFB00010 */ sw $s0, 0x10($sp)
/* 8EB368 80240008 0080802D */ daddu $s0, $a0, $zero
/* 8EB36C 8024000C AFBF0014 */ sw $ra, 0x14($sp)
/* 8EB370 80240010 0C00FB5A */ jal get_enemy_safe
/* 8EB374 80240014 0000202D */ daddu $a0, $zero, $zero
/* 8EB378 80240018 AE020084 */ sw $v0, 0x84($s0)
/* 8EB37C 8024001C 8FBF0014 */ lw $ra, 0x14($sp)
/* 8EB380 80240020 8FB00010 */ lw $s0, 0x10($sp)
/* 8EB384 80240024 24020002 */ addiu $v0, $zero, 2
/* 8EB388 80240028 03E00008 */ jr $ra
/* 8EB38C 8024002C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1547,4 +1547,29 @@ typedef struct SaveData {
/* 0x1304 */ char unk_1304[0x7C];
} SaveData; // size = 0x1380
typedef struct MapHeader {
/* 0x00 */ char unk_00[0x10];
/* 0x10 */ Bytecode* mainScript;
/* 0x14 */ f32* 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
} MapHeader; // size = 0x40
typedef struct NpcAISettings {
/* 0x00 */ f32 moveSpeed;
/* 0x04 */ s32 moveTime;
/* 0x08 */ s32 waitTime;
/* 0x0C */ f32 alertRadius;
/* 0x10 */ f32 unk_10;
/* 0x14 */ s32 unk_14;
/* 0x18 */ f32 chaseSpeed;
/* 0x1C */ s32 unk_1C; // chase turn step?
/* 0x20 */ s32 unk_20;
/* 0x24 */ f32 chaseRadius;
/* 0x28 */ f32 unk_28;
/* 0x2C */ s32 unk_2C; // bool
} NpcAISettings; // size = 0x30
#endif

View File

@ -1259,18 +1259,18 @@ typedef s32 NpcId;
#define NpcId_PARTNER 0xFFFFFFFC
typedef UNK_TYPE TriggerFlag;
#define TriggerFlag_FLOOR_TOUCH 0x00000080
#define TriggerFlag_FLOOR_ABOVE 0x00080000
#define TriggerFlag_FLOOR_PRESS_A 0x00000800
#define TriggerFlag_FLOOR_JUMP 0x00000200
#define TriggerFlag_WALL_TOUCH 0x00000400
#define TriggerFlag_WALL_PUSH 0x00000040
#define TriggerFlag_WALL_PRESS_A 0x00000100
#define TriggerFlag_WALL_HAMMER 0x00001000
#define TriggerFlag_CEILING_TOUCH 0x00040000
#define TriggerFlag_POINT_BOMB 0x00100000
#define TriggerFlag_GAME_FLAG_SET 0x00010000
#define TriggerFlag_AREA_FLAG_SET 0x00020000
#define TriggerFlag_FLOOR_TOUCH 0x00000080
#define TriggerFlag_FLOOR_ABOVE 0x00080000
#define TriggerFlag_FLOOR_INTERACT 0x00000800
#define TriggerFlag_FLOOR_JUMP 0x00000200
#define TriggerFlag_WALL_TOUCH 0x00000400
#define TriggerFlag_WALL_PUSH 0x00000040
#define TriggerFlag_WALL_INTERACT 0x00000100
#define TriggerFlag_WALL_HAMMER 0x00001000
#define TriggerFlag_CEILING_TOUCH 0x00040000
#define TriggerFlag_BOMB 0x00100000
#define TriggerFlag_SAVE_FLAG_SET 0x00010000
#define TriggerFlag_AREA_FLAG_SET 0x00020000
typedef UNK_TYPE Button;
#define Button_A 0x00008000

334
include/script_api/battle.h Normal file
View File

@ -0,0 +1,334 @@
#ifndef _SCRIPT_API_BATTLE_H_
#define _SCRIPT_API_BATTLE_H_
#include "common_structs.h"
#include "si.h"
#include "script_api/common.h"
ApiStatus EnablePartnerBlur(ScriptInstance* script, s32 isInitialCall);
ApiStatus DisablePartnerBlur(ScriptInstance* script, s32 isInitialCall);
ApiStatus UseCamPreset(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleCamTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleCamOffsetZ(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddBattleCamOffsetZ(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleCamYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus BattleCamTargetActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus MoveBattleCamOver(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleCamZoom(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddBattleCamZoom(ScriptInstance* script, s32 isInitialCall);
ApiStatus FreezeBattleCam(ScriptInstance* script, s32 isInitialCall);
ApiStatus close_action_command_instruction_popup(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowMessageBox(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowVariableMessageBox(ScriptInstance* script, s32 isInitialCall);
ApiStatus IsMessageBoxDisplayed(ScriptInstance* script, s32 isInitialCall);
ApiStatus WaitForMessageBoxDone(ScriptInstance* script, s32 isInitialCall);
ApiStatus ForceCloseMessageBox(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetMessageBoxDuration(ScriptInstance* script, s32 isInitialCall);
ApiStatus ItemDamageEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus ItemAfflictEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus ItemCheckHit(ScriptInstance* script, s32 isInitialCall);
ApiStatus ActorSpeak(ScriptInstance* script, s32 isInitialCall);
ApiStatus EndActorSpeech(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowBattleChoice(ScriptInstance* script, s32 isInitialCall);
ApiStatus OverrideBattleDmaDest(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadBattleDmaData(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAtActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAtPart(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetForegroundModelsVisibleUnchecked(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetForegroundModelsVisible(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeStatusField(ScriptInstance* script, s32 isInitialCall);
ApiStatus MultiplyByActorScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus MultiplyVec2ByActorScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus MultiplyVec3ByActorScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus ApplyShrinkFromOwner(ScriptInstance* script, s32 isInitialCall);
ApiStatus StartRumble(ScriptInstance* script, s32 isInitialCall);
ApiStatus HasMerleeCastsLeft(ScriptInstance* script, s32 isInitialCall);
ApiStatus FXRecoverHP(ScriptInstance* script, s32 isInitialCall);
ApiStatus FXRecoverFP(ScriptInstance* script, s32 isInitialCall);
ApiStatus IncrementPlayerHP(ScriptInstance* script, s32 isInitialCall);
ApiStatus IncrementPlayerFP(ScriptInstance* script, s32 isInitialCall);
ApiStatus create_actor(ScriptInstance* script, s32 isInitialCall);
ApiStatus StartRumbleWithParams(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadItemScript(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadFreeItemScript(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadMoveScript(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadActionCommand(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActionSuccess(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActionSuccess(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActionSuccessCopy(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetBlockResult(ScriptInstance* script, s32 isInitialCall);
ApiStatus CloseActionCommandInfo(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadBattleSection(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetBattlePhase(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetLastElement(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetGoalToHome(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetIdleGoalToHome(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetGoalToIndex(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetIndexFromPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetIndexFromHome(ScriptInstance* script, s32 isInitialCall);
ApiStatus CountPlayerTargets(ScriptInstance* script, s32 isInitialCall);
ApiStatus ForceHomePos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetHomePos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetGoalToTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartGoalToTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetGoalToFirstTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetGoalPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetIdleGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddGoalPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetGoalPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetIdleGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetHomePos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetEnemyTargetOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetAnimationRate(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorJumpGravity(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorIdleJumpGravity(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorSpeed(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorIdleSpeed(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartJumpGravity(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartMoveSpeed(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetJumpAnimations(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddActorPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorDispOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartDispOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartDispOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddPartDispOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddActorVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartMovementVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartMovementVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddPartMovementVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorRotation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorRotationOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorRotation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartRotation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartRotationOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartRotation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorScaleModifier(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetBattleFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetBattleFlags2(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleFlagBits2(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartTargetFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartTargetFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartTargetFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartEventFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartEventBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartEventFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus HPBarToHome(ScriptInstance* script, s32 isInitialCall);
ApiStatus HPBarToCurrent(ScriptInstance* script, s32 isInitialCall);
ApiStatus SummonEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetOwnerID(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetOwnerID(ScriptInstance* script, s32 isInitialCall);
ApiStatus ActorExists(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleInputMask(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleInputButtons(ScriptInstance* script, s32 isInitialCall);
ApiStatus CheckButtonPress(ScriptInstance* script, s32 isInitialCall);
ApiStatus CheckButtonHeld(ScriptInstance* script, s32 isInitialCall);
ApiStatus CheckButtonDown(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetBattleState(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerCreateTargetList(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnemyCreateTargetList(ScriptInstance* script, s32 isInitialCall);
ApiStatus InitTargetIterator(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetOwnerTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus ChooseNextTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetTargetListLength(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetOwnerTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPlayerActorID(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetDistanceToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddActorDecoration(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveActorDecoration(ScriptInstance* script, s32 isInitialCall);
ApiStatus ModifyActorDecoration(ScriptInstance* script, s32 isInitialCall);
ApiStatus UseIdleAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetStatusFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemovePlayerBuffs(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartAlpha(ScriptInstance* script, s32 isInitialCall);
ApiStatus CreatePartShadow(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemovePartShadow(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetBattleVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus ResetAllActorSounds(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorSounds(ScriptInstance* script, s32 isInitialCall);
ApiStatus ResetActorSounds(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartSounds(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorType(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowShockEffect(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorAttackBoost(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorDefenseBoost(ScriptInstance* script, s32 isInitialCall);
ApiStatus BoostAttack(ScriptInstance* script, s32 isInitialCall);
ApiStatus BoostDefense(ScriptInstance* script, s32 isInitialCall);
ApiStatus VanishActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus ElectrifyActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus HealActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus WaitForBuffDone(ScriptInstance* script, s32 isInitialCall);
ApiStatus CopyBuffs(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetMenuSelection(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerFallToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerLandJump(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerRunToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus CancelablePlayerRunToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPlayerHP(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerDamageEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerPowerBounceEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerTestEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus DispatchDamagePlayerEvent(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnablePlayerBlur(ScriptInstance* script, s32 isInitialCall);
ApiStatus DidActionSucceed(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindTakeTurn(ScriptInstance* script, s32 isInitialCall);
ApiStatus PauseTakeTurn(ScriptInstance* script, s32 isInitialCall);
ApiStatus ResumeTakeTurn(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindIdle(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableIdleScript(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindHandleEvent(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindNextTurn(ScriptInstance* script, s32 isInitialCall);
ApiStatus JumpToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus IdleJumpToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus JumpWithBounce(ScriptInstance* script, s32 isInitialCall);
ApiStatus LandJump(ScriptInstance* script, s32 isInitialCall);
ApiStatus FallToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus RunToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus IdleRunToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus JumpPartTo(ScriptInstance* script, s32 isInitialCall);
ApiStatus FallPartTo(ScriptInstance* script, s32 isInitialCall);
ApiStatus LandJumpPart(ScriptInstance* script, s32 isInitialCall);
ApiStatus RunPartTo(ScriptInstance* script, s32 isInitialCall);
ApiStatus FlyToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus IdleFlyToGoal(ScriptInstance* script, s32 isInitialCall);
ApiStatus FlyPartTo(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetLastEvent(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetTargetActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetEnemyHP(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorHP(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetEnemyMaxHP(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus DropStarPoints(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetDefenseTable(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetStatusTable(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetIdleAnimations(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnemyDamageTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnemyFollowupAfflictTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnemyTestTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus DispatchDamageEvent(ScriptInstance* script, s32 isInitialCall);
ApiStatus DispatchEvent(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetTargetOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableActorBlur(ScriptInstance* script, s32 isInitialCall);
ApiStatus AfflictActor(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetEncounterState(ScriptInstance* script, s32 isInitialCall);
ApiStatus YieldTurn(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetActorSize(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorSize(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPartSize(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetOriginalActorType(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCurrentActorType(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetLastDamage(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableActorGlow(ScriptInstance* script, s32 isInitialCall);
ApiStatus WasStatusInflicted(ScriptInstance* script, s32 isInitialCall);
ApiStatus CopyStatusEffects(ScriptInstance* script, s32 isInitialCall);
ApiStatus ClearStatusEffects(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeOwnerTargetIndex(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetActorLevel(ScriptInstance* script, s32 isInitialCall);
ApiStatus PartnerDamageEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus PartnerAfflictEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus PartnerPowerBounceEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus PartnerTestEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus DeletePartner(ScriptInstance* script, s32 isInitialCall);
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[];
#endif

269
include/script_api/common.h Normal file
View File

@ -0,0 +1,269 @@
#ifndef _SCRIPT_API_COMMON_H_
#define _SCRIPT_API_COMMON_H_
#include "common_structs.h"
#include "si.h"
ApiStatus FadeBackgroundToBlack(ScriptInstance* script, s32 isInitialCall);
ApiStatus UnfadeBackgroundFromBlack(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamLookAtObjVector(ScriptInstance* script, s32 isInitialCall);
ApiStatus HasMerleeCasts(ScriptInstance* script, s32 isInitialCall);
ApiStatus OnDefeatEnemy(ScriptInstance* script, s32 isInitialCall);
ApiStatus OnFleeBattleDrops(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetEncounterStatusFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadDemoBattle(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveNpc(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveEncounter(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetBattleOutcome(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetOwnerEncounterTrigger(ScriptInstance* script, s32 isInitialCall);
ApiStatus DoNpcDefeat(ScriptInstance* script, s32 isInitialCall);
ApiStatus StartBattle(ScriptInstance* script, s32 isInitialCall);
ApiStatus StartBattleWith(ScriptInstance* script, s32 isInitialCall);
ApiStatus StartBossBattle(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetBattleMusic(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindNpcAI(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindNpcIdle(ScriptInstance* script, s32 isInitialCall);
ApiStatus RestartNpcAI(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableNpcAI(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcAux(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindNpcAux(ScriptInstance* script, s32 isInitialCall);
ApiStatus RestartNpcAux(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableNpcAux(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindNpcInteract(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindNpcHit(ScriptInstance* script, s32 isInitialCall);
ApiStatus BindNpcDefeat(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetSelfVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetSelfVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetNpcVar(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetSelfRotation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetSelfEnemyFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetSelfEnemyFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetSelfNpcID(ScriptInstance* script, s32 isInitialCall);
ApiStatus ClearDefeatedEnemies(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetEnemyFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetSelfAnimationFromTable(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowCoinCounter(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeEntity(ScriptInstance* script, s32 isInitialCall);
ApiStatus AssignScript(ScriptInstance* script, s32 isInitialCall);
ApiStatus AssignAreaFlag(ScriptInstance* script, s32 isInitialCall);
ApiStatus AssignFlag(ScriptInstance* script, s32 isInitialCall);
ApiStatus AssignBlockFlag(ScriptInstance* script, s32 isInitialCall);
ApiStatus AssignPanelFlag(ScriptInstance* script, s32 isInitialCall);
ApiStatus AssignCrateFlag(ScriptInstance* script, s32 isInitialCall);
ApiStatus DeleteTrigger(ScriptInstance* script, s32 isInitialCall);
ApiStatus TranslateModel(ScriptInstance* script, s32 isInitialCall);
ApiStatus RotateModel(ScriptInstance* script, s32 isInitialCall);
ApiStatus ScaleModel(ScriptInstance* script, s32 isInitialCall);
ApiStatus CloneModel(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetModelIndex(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetModelCenter(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetTexPanner(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetModelFlag10(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableTexPanning(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableModel(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetGroupEnabled(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetTexPanOffset(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetModelFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus TranslateGroup(ScriptInstance* script, s32 isInitialCall);
ApiStatus RotateGroup(ScriptInstance* script, s32 isInitialCall);
ApiStatus ScaleGroup(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableGroup(ScriptInstance* script, s32 isInitialCall);
ApiStatus ModifyColliderFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetColliderCenter(ScriptInstance* script, s32 isInitialCall);
ApiStatus ParentColliderToModel(ScriptInstance* script, s32 isInitialCall);
ApiStatus UpdateColliderTransform(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetZoneEnabled(ScriptInstance* script, s32 isInitialCall);
ApiStatus GotoMap(ScriptInstance* script, s32 isInitialCall);
ApiStatus GotoMapSpecial(ScriptInstance* script, s32 isInitialCall);
ApiStatus GotoMapByID(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetEntryID(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetMapID(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetLoadType(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetRenderMode(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAtModel(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAtCollider(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamEnabled(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamFlag80(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamPerspective(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamViewport(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamBGColor(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShakeCam(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamLeadPlayer(ScriptInstance* script, s32 isInitialCall);
ApiStatus PanToTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus UseSettingsFrom(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadSettings(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamType(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamPitch(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamDistance(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamPosA(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamPosB(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamPosC(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPanTarget(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamSpeed(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamType(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamPitch(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamDistance(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamPosA(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamPosB(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamPosC(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCamPosition(ScriptInstance* script, s32 isInitialCall);
ApiStatus WaitForCam(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetCamProperties(ScriptInstance* script, s32 isInitialCall);
ApiStatus AdjustCam(ScriptInstance* script, s32 isInitialCall);
ApiStatus ResetCam(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadModelAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayModelAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus ChangeModelAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus DeleteNpc(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetNpcPointer(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcRotation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcScale(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcCollisionSize(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcSpeed(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcJumpscale(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetNpcAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus NpcMoveTo(ScriptInstance* script, s32 isInitialCall);
ApiStatus NpcJump0(ScriptInstance* script, s32 isInitialCall);
ApiStatus NpcJump1(ScriptInstance* script, s32 isInitialCall);
ApiStatus NpcFlyTo(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetNpcYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus InterpNpcYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus NpcFacePlayer(ScriptInstance* script, s32 isInitialCall);
ApiStatus NpcFaceNpc(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetNpcPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableNpcShadow(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableNpcBlur(ScriptInstance* script, s32 isInitialCall);
ApiStatus ClearPartnerMoveHistory(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPartnerPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus DisablePartnerAI(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnablePartnerAI(ScriptInstance* script, s32 isInitialCall);
ApiStatus BringPartnerOut(ScriptInstance* script, s32 isInitialCall);
ApiStatus PutPartnerAway(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCurrentPartnerID(ScriptInstance* script, s32 isInitialCall);
ApiStatus IsCurrentPartnerFlying(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetNpcEffect(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAtNpc(ScriptInstance* script, s32 isInitialCall);
ApiStatus SpeakToPlayer(ScriptInstance* script, s32 isInitialCall);
ApiStatus EndSpeech(ScriptInstance* script, s32 isInitialCall);
ApiStatus ContinueSpeech(ScriptInstance* script, s32 isInitialCall);
ApiStatus SpeakToNpc(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowMessageAtScreenPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowMessageAtWorldPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus CloseMessage(ScriptInstance* script, s32 isInitialCall);
ApiStatus SwitchMessage(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowChoice(ScriptInstance* script, s32 isInitialCall);
ApiStatus CloseChoice(ScriptInstance* script, s32 isInitialCall);
ApiStatus CancelMessage(ScriptInstance* script, s32 isInitialCall);
ApiStatus CancelMessageAndBlock(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetMessageImages(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetMessageString(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetMessageValue(ScriptInstance* script, s32 isInitialCall);
ApiStatus HidePlayerShadow(ScriptInstance* script, s32 isInitialCall);
ApiStatus DisablePlayerPhysics(ScriptInstance* script, s32 isInitialCall);
ApiStatus DisablePlayerInput(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPlayerPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPlayerCollisionSize(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPlayerSpeed(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPlayerJumpscale(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPlayerAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPlayerActionState(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerMoveTo(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerJump(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerJump1(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerJump2(ScriptInstance* script, s32 isInitialCall);
ApiStatus InterpPlayerYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayerFaceNpc(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPlayerTargetYaw(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPlayerFlagBits(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPlayerActionState(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPlayerPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPlayerAnimation(ScriptInstance* script, s32 isInitialCall);
ApiStatus FullyRestoreHPandFP(ScriptInstance* script, s32 isInitialCall);
ApiStatus FullyRestoreSP(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnablePartner(ScriptInstance* script, s32 isInitialCall);
ApiStatus DisablePartner(ScriptInstance* script, s32 isInitialCall);
ApiStatus UseEntryHeading(ScriptInstance* script, s32 isInitialCall);
ApiStatus UseExitHeading(ScriptInstance* script, s32 isInitialCall);
ApiStatus DisablePulseStone(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetCurrentPartner(ScriptInstance* script, s32 isInitialCall);
ApiStatus Disable8bitMario(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAtPlayer(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeLerp(ScriptInstance* script, s32 isInitialCall);
ApiStatus UpdateLerp(ScriptInstance* script, s32 isInitialCall);
ApiStatus RandInt(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetAngleBetweenNPCs(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetAngleToNPC(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetAngleToPlayer(ScriptInstance* script, s32 isInitialCall);
ApiStatus AwaitPlayerApproach(ScriptInstance* script, s32 isInitialCall);
ApiStatus IsPlayerWithin(ScriptInstance* script, s32 isInitialCall);
ApiStatus AwaitPlayerLeave(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddVectorPolar(ScriptInstance* script, s32 isInitialCall);
ApiStatus LoadPath(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetNextPathPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetDist2D(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetValueByRef(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetValueByRef(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableStatusMenu(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowStatusMenu(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetGameMode(ScriptInstance* script, s32 isInitialCall);
ApiStatus ClampAngleInt(ScriptInstance* script, s32 isInitialCall);
ApiStatus ClampAngleFloat(ScriptInstance* script, s32 isInitialCall);
ApiStatus FadeOutMusic(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetMusicTrack(ScriptInstance* script, s32 isInitialCall);
ApiStatus FadeInMusic(ScriptInstance* script, s32 isInitialCall);
ApiStatus ClearAmbientSounds(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayAmbientSounds(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySound(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAt(ScriptInstance* script, s32 isInitialCall);
ApiStatus StopSound(ScriptInstance* script, s32 isInitialCall);
ApiStatus UseDoorSounds(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlaySoundAtF(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveKeyItemAt(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveItemAt(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddKeyItem(ScriptInstance* script, s32 isInitialCall);
ApiStatus HasKeyItem(ScriptInstance* script, s32 isInitialCall);
ApiStatus FindKeyItem(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddItem(ScriptInstance* script, s32 isInitialCall);
ApiStatus FindItem(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveItem(ScriptInstance* script, s32 isInitialCall);
ApiStatus CountFortessKeys(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveFortressKeys(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeItemEntity(ScriptInstance* script, s32 isInitialCall);
ApiStatus DropItemEntity(ScriptInstance* script, s32 isInitialCall);
ApiStatus DropItemEntityB(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveItemEntity(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddBadge(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveBadge(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetItemPos(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetItemFlags(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddCoin(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddStarPoints(ScriptInstance* script, s32 isInitialCall);
ApiStatus AddStarPieces(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetItemPower(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowGotItem(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowEmote(ScriptInstance* script, s32 isInitialCall);
ApiStatus ShowSleepBubble(ScriptInstance* script, s32 isInitialCall);
ApiStatus RemoveEffect(ScriptInstance* script, s32 isInitialCall);
ApiStatus PlayEffect(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetSpriteShading(ScriptInstance* script, s32 isInitialCall);
ApiStatus EnableSpriteShading(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetDemoState(ScriptInstance* script, s32 isInitialCall);
ApiStatus DemoPressButton(ScriptInstance* script, s32 isInitialCall);
ApiStatus DemoReleaseButton(ScriptInstance* script, s32 isInitialCall);
ApiStatus DemoSetButtons(ScriptInstance* script, s32 isInitialCall);
ApiStatus DemoJoystickRadial(ScriptInstance* script, s32 isInitialCall);
ApiStatus DemoJoystickXY(ScriptInstance* script, s32 isInitialCall);
ApiStatus func_802CFE2C(ScriptInstance* script, s32 isInitialCall);
ApiStatus func_802CFD30(ScriptInstance* script, s32 isInitialCall);
extern Bytecode* ShakeCam1;
extern Bytecode* ShakeCamX;
#endif

33
include/script_api/map.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef _SCRIPT_API_MAP_H_
#define _SCRIPT_API_MAP_H_
#include "common_structs.h"
#include "si.h"
#include "script_api/common.h"
ApiStatus MakeNpcs(ScriptInstance* script, s32 isInitialCall);
ApiStatus DoBasicAI(ScriptInstance* script, s32 isInitialCall);
ApiStatus ResetFromLava(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeShop(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeShopOwner(ScriptInstance* script, s32 isInitialCall);
ApiStatus MakeDoorAdvanced(ScriptInstance* script, s32 isInitialCall);
ApiStatus CheckActionState(ScriptInstance* script, s32 isInitialCall);
ApiStatus CreatePushBlockGrid(ScriptInstance* script, s32 isInitialCall);
ApiStatus SetPushBlock(ScriptInstance* script, s32 isInitialCall);
ApiStatus GetPushBlock(ScriptInstance* script, s32 isInitialCall);
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[];
#endif

View File

@ -3,7 +3,17 @@
#include "ultra64.h"
#define SI_VAR_0 0xFE363C80
#define SI_VAR(v) (v - 30000000)
#define SI_MAP_VAR(v) (v - 50000000)
#define SI_FLAG(v) (v - 70000000)
#define SI_MAP_FLAG(v) (v - 90000000)
#define SI_AREA_FLAG(v) (v - 110000000)
#define SI_SAVE_FLAG(v) (v - 130000000)
#define SI_AREA_VAR(v) (v - 150000000)
#define SI_SAVE_VAR(v) (v - 170000000)
#define SI_ARRAY(v) (v - 190000000)
#define SI_ARRAY_FLAG(v) (v - 210000000)
#define SI_FIXED(v) ((s32)(v * 1024.0f) - 230000000) // See float_to_fixed_var
/* Return type of si_execute_next_command */
#define SI_CONTINUE 0 /* Continue to next command */
@ -18,4 +28,125 @@ typedef s32 ApiStatus;
#define ApiStatus_REPEAT 3 /* Call again immediately */
#define ApiStatus_FINISH 255 /* Corresponds to SI_FINISH */
#define SI_CMD(opcode, argv...) \
opcode, \
/* argc */ (sizeof((Bytecode[]){argv})/sizeof(Bytecode)), \
##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, 1, i)
#define SI_WAIT_SECS(i) SI_CMD(0x09, 1, 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, 0)
#define SI_END_IF() SI_CMD(0x13, 0)
#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 GEN_EXIT_WALK_SCRIPT(name, walkDistance, exitIdx, map, entryIdx) \
Bytecode name[] = { \
SI_GROUP(0x1B), \
SI_CALL(&UseExitHeading, walkDistance, exitIdx), \
SI_EXEC(&ExitWalk), \
SI_CALL(&GotoMap, map, entryIdx), \
SI_WAIT_FRAMES(100), \
SI_RETURN(), \
SI_END(), \
};
#endif

View File

@ -119,7 +119,7 @@ ApiStatus IsPlayerWithin(ScriptInstance* script, s32 isInitialCall) {
s32* distanceRequired = &script->functionTemp[2];
f32 distance;
Bytecode outVar = SI_VAR_0;
Bytecode outVar = SI_VAR(0);
if (isInitialCall) {
*targetX = get_variable(script, *ptrReadPos++);

View File

@ -1,3 +0,0 @@
#include "common.h"
INCLUDE_ASM(s32, "world/area_kmr/kmr_12", func_80240000_8EB360);

View File

@ -0,0 +1,161 @@
#include "common.h"
#include "script_api/map.h"
Bytecode kmr_12_play_music[];
Bytecode make_entities[];
Bytecode read_sign[];
GEN_EXIT_WALK_SCRIPT(exit_west, 60, 0, "kmr_07", 1);
GEN_EXIT_WALK_SCRIPT(exit_east, 60, 1, "kmr_11", 0);
Bytecode bind_exits[] = {
SI_BIND(&exit_west, TriggerFlag_FLOOR_ABOVE, 0 /* deili1 */, NULL),
SI_BIND(&exit_east, TriggerFlag_FLOOR_ABOVE, 3 /* deili2 */, NULL),
SI_RETURN(),
SI_END(),
};
Bytecode kmr_12_main[] = {
SI_SET(SI_SAVE_VAR(425), 31),
SI_CALL(&SetSpriteShading, -1),
SI_CALL(&SetCamPerspective, 0, 3, 25, 16, 4096),
SI_CALL(&SetCamBGColor, 0, 0, 0, 0),
SI_CALL(&SetCamEnabled, 0, 1),
SI_CALL(&MakeNpcs, 0, 0x802409A8),
SI_EXEC_WAIT(&make_entities),
SI_EXEC(&kmr_12_play_music),
SI_SET(SI_VAR(0), bind_exits),
SI_EXEC(&EnterWalk),
SI_WAIT_FRAMES(1),
SI_BIND(read_sign, TriggerFlag_WALL_INTERACT, 10, NULL),
SI_RETURN(),
SI_END(),
};
NpcAISettings goomba_ai_settings = {
1.5f,
30,
30,
130.0f,
0.0f,
1,
2.5f,
180,
3,
150.0f,
0.0f,
TRUE
};
Bytecode goomba_ai[] = {
SI_CALL(&DoBasicAI, &goomba_ai_settings),
SI_RETURN(),
SI_END(),
};
StaticNpcSettings goomba_npc_settings = {
.radius = 20,
.height = 23,
.aiScript = &goomba_ai,
.hitScript = (Bytecode*)0x80077F70,
.defeatScript = (Bytecode*)0x8007809C,
};
ApiStatus get_goomba_ref(ScriptInstance* script, s32 isInitialCall) {
script->varTable[0] = get_enemy_safe(0);
return ApiStatus_DONE2;
}
Bytecode read_sign[] = { // *INDENT-OFF*
SI_GROUP(0),
// "Eat a Mushroom to regain your energy!"
SI_SUSPEND_GROUP(1),
SI_CALL(&DisablePlayerInput, TRUE),
SI_CALL(&ShowMessageAtScreenPos, 0x1D0167, 160, 40),
SI_RESUME_GROUP(1),
SI_SET(SI_FLAG(0), FALSE),
SI_CALL(&get_goomba_ref),
SI_IF_NE(SI_VAR(0), FALSE),
SI_CALL(&GetNpcVar, 0, 0, SI_VAR(0)),
SI_IF_EQ(SI_VAR(0), FALSE),
// Trigger Goomba to peel off
SI_CALL(&SetNpcVar, 0, 0, TRUE),
SI_SET(SI_FLAG(0), TRUE),
SI_WAIT_FRAMES(10),
SI_END_IF(),
SI_END_IF(),
SI_CALL(&DisablePlayerInput, FALSE),
SI_IF_EQ(SI_FLAG(0), TRUE),
SI_UNBIND_ME(),
SI_END_IF(),
SI_END(),
SI_RETURN(), // Whoops!
}; // *INDENT-ON*
Bytecode goomba_idle[] = { // *INDENT-OFF*
SI_WAIT_FRAMES(1),
SI_CALL(&SetSelfVar, 0, FALSE),
SI_CALL(&SetNpcAnimation, NpcId_SELF, 0x26000D),
SI_CALL(&EnableNpcShadow, NpcId_SELF, 0),
SI_CALL(&SetSelfEnemyFlagBits, 32, 1),
// Wait until read_sign sets NPC var 0
SI_LABEL(0),
SI_CALL(&GetSelfVar, 0, SI_VAR(0)),
SI_WAIT_FRAMES(1),
SI_IF_EQ(SI_VAR(0), TRUE),
SI_GOTO(0),
SI_END_IF(),
// Peel and jump off the sign
SI_CALL(&SetNpcFlagBits, NpcId_SELF, 0x240000, 1),
SI_WAIT_FRAMES(3),
SI_SET_F(SI_VAR(0), SI_FIXED(0.0f)),
SI_LOOP(9),
SI_ADD_F(SI_VAR(0), SI_FIXED(10.0f)),
SI_CALL(&SetNpcRotation, NpcId_SELF, 0, SI_VAR(0), 0),
SI_WAIT_FRAMES(1),
SI_END_LOOP(),
SI_CALL(&SetNpcAnimation, NpcId_SELF, 0x260000),
SI_LOOP(9),
SI_ADD_F(SI_VAR(0), SI_FIXED(10.0f)),
SI_CALL(&SetNpcRotation, NpcId_SELF, 0, SI_VAR(0), 0),
SI_WAIT_FRAMES(1),
SI_END_LOOP(),
SI_CALL(&SetNpcAnimation, NpcId_SELF, 0x260007),
SI_WAIT_FRAMES(20),
SI_CALL(&SetNpcAnimation, NpcId_SELF, 0x260001),
SI_CALL(&PlaySoundAtNpc, NpcId_SELF, 248, 0),
SI_CALL(&func_802CFE2C, NpcId_SELF, 8192),
SI_CALL(&func_802CFD30, NpcId_SELF, 5, 6, 1, 1, 0),
SI_WAIT_FRAMES(12),
SI_WAIT_FRAMES(5),
SI_CALL(&PlaySoundAtNpc, NpcId_SELF, 812, 0),
SI_CALL(&EnableNpcShadow, NpcId_SELF, 1),
SI_CALL(&SetNpcJumpscale, NpcId_SELF, SI_FIXED(0.6005859375f)),
SI_CALL(&NpcJump0, NpcId_SELF, 0xFFFFFFDD, 0, 30, 23),
SI_CALL(&func_802CFD30, NpcId_SELF, 0, 0, 0, 0, 0),
SI_CALL(&InterpNpcYaw, NpcId_SELF, 90, 0),
SI_CALL(&SetNpcFlagBits, NpcId_SELF, 0x240000, 0),
SI_CALL(&SetSelfEnemyFlagBits, 32, 0),
SI_CALL(&SetSelfEnemyFlagBits, 0x40000000, 1),
// We're done jumping off; the player can read the sign again
SI_BIND(read_sign, TriggerFlag_WALL_INTERACT, 10, NULL),
// Behave like a normal enemy from now on
SI_CALL(&BindNpcAI, NpcId_SELF, &goomba_ai),
SI_RETURN(),
SI_END(),
}; // *INDENT-ON*
Bytecode goomba_init[] = {
SI_CALL(&BindNpcIdle, NpcId_SELF, &goomba_idle),
SI_RETURN(),
SI_END(),
};

View File

@ -0,0 +1,22 @@
#include "common.h"
#include "script_api/map.h"
Bytecode kmr_12_main[];
f32 entryList[][4] = {
{ -126.0f, 0.0f, 12.0f, 90.0f }, // west, towards Red/Blue Goomba miniboss room
{ 471.0f, 0.0f, 12.0f, 270.0f }, // east, towards Goomba King's Fortress
};
MapHeader header = {
.mainScript = &kmr_12_main,
.entryList = entryList,
.background = 0x80200000,
.tattle = 0x00190040,
};
Bytecode kmr_12_play_music[] = {
SI_CALL(&SetMusicTrack, 0, Song_PLEASANT_PATH, 0, 8),
SI_RETURN(),
SI_END(),
};

314
tools/disasm_script.py Executable file
View File

@ -0,0 +1,314 @@
#! /usr/bin/python3
import sys
_star_rod_lib = None
def star_rod_lib():
global _star_rod_lib
if not _star_rod_lib:
_star_rod_lib = {}
from pathlib import Path
from os import path
import re
LIB_LINE_RE = re.compile(r"\s+:\s+")
NAME_RE = re.compile(r"({[^}]*})?\s*([a-zA-Z0-9_]+)")
for filename in Path(path.dirname(__file__), "star-rod", "database").rglob("*.lib"):
with open(filename, "r") as file:
for line in file.readlines():
parts = LIB_LINE_RE.split(line)
if len(parts) >= 3:
try:
kind = parts[0]
vaddr = int(parts[1].split(", ")[0], 16)
if name := NAME_RE.match(parts[2]):
name = name.group(2)
_star_rod_lib[vaddr] = name
"""
if "map" in str(filename):
if kind == "api":
print(f"ApiStatus {name}(ScriptInstance* script, s32 isInitialCall);")
elif kind == "scr":
print(f"extern Bytecode {name}[];")
"""
except:
pass
return _star_rod_lib
def addr_ref(addr):
func_name = star_rod_lib().get(addr)
if func_name:
func_name = "&" + func_name
else:
func_name = f"0x{addr:08X}"
return func_name
def disassemble(bytes, indent = 0):
out = ""
prefix = ""
indent += 1
indent_used = False
def write_line(line):
nonlocal out, indent, indent_used
if indent < 0: indent = 0
if indent > 1: indent_used = True
out += " " * indent
out += line
out += "\n"
def prefix_line(line):
nonlocal prefix
prefix += line
prefix += "\n"
def var(arg):
v = arg - 2**32 # convert to s32
if v > -250000000:
if v <= -220000000: return f"SI_FIXED({(v + 230000000) / 1024}f)"
elif v <= -200000000: return f"SI_ARRAY_FLAG({v + 210000000})"
elif v <= -180000000: return f"SI_ARRAY({v + 190000000})"
elif v <= -160000000: return f"SI_SAVE_VAR({v + 170000000})"
elif v <= -140000000: return f"SI_AREA_VAR({v + 150000000})"
elif v <= -120000000: return f"SI_SAVE_FLAG({v + 130000000})"
elif v <= -100000000: return f"SI_AREA_FLAG({v + 110000000})"
elif v <= -80000000: return f"SI_MAP_FLAG({v + 90000000})"
elif v <= -60000000: return f"SI_FLAG({v + 70000000})"
elif v <= -40000000: return f"SI_MAP_VAR({v + 50000000})"
elif v <= -20000000: return f"SI_VAR({v + 30000000})"
if arg == 0xFFFFFFFF:
return "-1"
elif ((arg & 0xFF000000) == 0x80000000) or arg > 10000:
return f"0x{arg:X}"
else:
return f"{arg}"
def trigger(trigger):
if trigger == 0x00000080: trigger = "TriggerFlag_FLOOR_TOUCH"
if trigger == 0x00800000: trigger = "TriggerFlag_FLOOR_ABOVE"
if trigger == 0x00000800: trigger = "TriggerFlag_FLOOR_INTERACT"
if trigger == 0x00000200: trigger = "TriggerFlag_FLOOR_JUMP"
if trigger == 0x00000400: trigger = "TriggerFlag_WALL_TOUCH"
if trigger == 0x00000040: trigger = "TriggerFlag_WALL_PUSH"
if trigger == 0x00000100: trigger = "TriggerFlag_WALL_INTERACT"
if trigger == 0x00001000: trigger = "TriggerFlag_WALL_HAMMER"
if trigger == 0x00040000: trigger = "TriggerFlag_CEILING_TOUCH"
if trigger == 0x00010000: trigger = "TriggerFlag_SAVE_FLAG_SET"
if trigger == 0x00020000: trigger = "TriggerFlag_AREA_FLAG_SET"
if trigger == 0x00100000: trigger = "TriggerFlag_BOMB"
return trigger
def read_word():
return int.from_bytes(bytes.read(4), byteorder="big")
while True:
opcode = read_word()
argc = read_word()
argv = []
for i in range(0, argc):
argv.append(read_word())
if opcode == 0x01:
write_line("SI_END(),")
indent -= 1
if indent_used:
prefix_line("Bytecode script[] = { // *INDENT-OFF*")
write_line("}; // *INDENT-ON*")
else:
prefix_line("Bytecode script[] = {")
write_line("};")
return prefix + out
elif opcode == 0x02: write_line(f"SI_RETURN(),")
elif opcode == 0x03: write_line(f"SI_LABEL({var(argv[0])}),")
elif opcode == 0x04: write_line(f"SI_GOTO({var(argv[0])}),")
elif opcode == 0x05:
write_line(f"SI_LOOP({var(argv[0])}),")
indent += 1
elif opcode == 0x06:
indent -= 1
write_line("SI_END_LOOP(),")
elif opcode == 0x07: write_line(f"SI_BREAK_LOOP(),")
elif opcode == 0x08: write_line(f"SI_WAIT_FRAMES({var(argv[0])}),")
elif opcode == 0x09: write_line(f"SI_WAIT_SECS({var(argv[0])}),")
elif opcode == 0x0A:
write_line(f"SI_IF_EQ({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x0B:
write_line(f"SI_IF_NE({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x0C:
write_line(f"SI_IF_LT({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x0D:
write_line(f"SI_IF_GT({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x0E:
write_line(f"SI_IF_LE({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x0F:
write_line(f"SI_IF_GE({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x10:
write_line(f"SI_IF_BITS_ON({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x11:
write_line(f"SI_IF_BITS_OFF({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x12: write_line(f"SI_ELSE(),")
elif opcode == 0x13:
indent -= 1
write_line(f"SI_END_IF(),")
elif opcode == 0x14:
write_line(f"SI_SWITCH({var(argv[0])}),")
indent += 1
elif opcode == 0x15:
write_line(f"SI_SWITCH_CONST(0x{argv[0]:X}),")
indent += 2
elif opcode == 0x16:
indent -= 1
write_line(f"SI_CASE_EQ({var(argv[0])}),")
indent += 1
elif opcode == 0x17:
indent -= 1
write_line(f"SI_CASE_NE({var(argv[0])}),")
indent += 1
elif opcode == 0x18:
indent -= 1
write_line(f"SI_CASE_LT({var(argv[0])}),")
indent += 1
elif opcode == 0x19:
indent -= 1
write_line(f"SI_CASE_GT({var(argv[0])}),")
indent += 1
elif opcode == 0x1A:
indent -= 1
write_line(f"SI_CASE_LE({var(argv[0])}),")
indent += 1
elif opcode == 0x1B:
indent -= 1
write_line(f"SI_CASE_GE({var(argv[0])}),")
indent += 1
elif opcode == 0x1C:
indent -= 1
write_line(f"SI_CASE_DEFAULT({var(argv[0])}),")
indent += 1
elif opcode == 0x1D:
indent -= 1
write_line(f"SI_CASE_OR_EQ({var(argv[0])}),")
indent += 1
# opcode 0x1E?
elif opcode == 0x1F:
indent -= 1
write_line(f"SI_CASE_BITS_ON({var(argv[0])}),")
indent += 1
elif opcode == 0x20:
indent -= 1
write_line(f"SI_END_MULTI_CASE(),")
indent += 1
elif opcode == 0x21:
indent -= 1
write_line(f"SI_CASE_RANGE({var(argv[0])}, {var(argv[1])}),")
indent += 1
elif opcode == 0x22: write_line(f"SI_BREAK_CASE(),")
elif opcode == 0x23:
indent -= 2
write_line(f"SI_END_SWITCH(),")
elif opcode == 0x24: write_line(f"SI_SET({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x25: write_line(f"SI_SET_CONST({var(argv[0])}, 0x{argv[1]:X}),")
elif opcode == 0x26: write_line(f"SI_SET_F({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x27: write_line(f"SI_ADD({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x28: write_line(f"SI_SUB({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x29: write_line(f"SI_MUL({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x2A: write_line(f"SI_DIV({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x2B: write_line(f"SI_MOD({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x2C: write_line(f"SI_ADD_F({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x2D: write_line(f"SI_SUB_F({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x2E: write_line(f"SI_MUL_F({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x2F: write_line(f"SI_DIV_F({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x30: write_line(f"SI_USE_BUFFER({var(argv[0])}),")
# TODO: SI_BUF commands
elif opcode == 0x3C: write_line(f"SI_USE_ARRAY({var(argv[0])}),")
elif opcode == 0x3D: write_line(f"SI_NEW_ARRAY({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x3E: write_line(f"SI_USE_FLAGS({var(argv[0])}),")
elif opcode == 0x3F: write_line(f"SI_AND({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x40: write_line(f"SI_OR({var(argv[0])}, {var(argv[1])}),")
elif opcode == 0x41: write_line(f"SI_AND_CONST({var(argv[0])}, 0x{argv[1]:X})")
elif opcode == 0x42: write_line(f"SI_OR_CONST({var(argv[0])}, 0x{argv[1]:X})")
elif opcode == 0x43:
argv_str = ""
for arg in argv[1:]:
argv_str += ", "
argv_str += var(arg)
write_line(f"SI_CALL({addr_ref(argv[0])}{argv_str}),")
elif opcode == 0x44: write_line(f"SI_EXEC({addr_ref(argv[0])}),")
elif opcode == 0x45: write_line(f"SI_EXEC_GET_ID({addr_ref(argv[0])}, {var(argv[1])}),")
elif opcode == 0x46: write_line(f"SI_EXEC_WAIT({addr_ref(argv[0])}),")
elif opcode == 0x47:
if argv[3] != 1:
raise "BIND argv[3] != 1"
write_line(f"SI_BIND({addr_ref(argv[0])}, {trigger(argv[1])}, {var(argv[2])}, {'NULL' if argv[4] == 0 else var(argv[4])}),")
elif opcode == 0x48: write_line(f"SI_UNBIND_ME(),")
elif opcode == 0x49: write_line(f"SI_KILL({var(argv[0])}),")
elif opcode == 0x4A: write_line(f"SI_JUMP({var(argv[0])}),")
elif opcode == 0x4B: write_line(f"SI_PRIORITY({var(argv[0])}),")
elif opcode == 0x4C: write_line(f"SI_TIMESCALE({var(argv[0])}),")
elif opcode == 0x4D: write_line(f"SI_GROUP({var(argv[0])}),")
elif opcode == 0x4E:
if argv[4] != 0:
raise "BIND_PADLOCK argv[4] != NULL"
if argv[5] != 0:
raise "BIND_PADLOCK argv[5] != 1"
write_line(f"SI_BIND_PADLOCK({addr_ref(argv[0])}, {trigger(argv[1])}, {var(argv[2])}, {var(argv[3])}),")
elif opcode == 0x4F: write_line(f"SI_SUSPEND_GROUP({var(argv[0])}),")
elif opcode == 0x50: write_line(f"SI_RESUME_GROUP({var(argv[0])}),")
elif opcode == 0x51: write_line(f"SI_SUSPEND_GROUP_NOT_ME({var(argv[0])}),")
elif opcode == 0x52: write_line(f"SI_RESUME_GROUP_NOT_ME({var(argv[0])}),")
elif opcode == 0x53: write_line(f"SI_SUSPEND({var(argv[0])}),")
elif opcode == 0x54: write_line(f"SI_RESUME({var(argv[0])}),")
elif opcode == 0x55: write_line(f"SI_EXISTS({var(argv[0])}),")
elif opcode == 0x56:
write_line("SI_THREAD(),")
indent += 1
elif opcode == 0x57:
indent -= 1
write_line("SI_END_THREAD(),")
elif opcode == 0x58:
write_line("SI_CHILD_THREAD(),")
indent += 1
elif opcode == 0x59:
indent -= 1
write_line("SI_END_CHILD_THREAD(),")
else:
# unknown opcode
argv_str = ""
for arg in argv:
argv_str += ", "
argv_str += f"0x{arg:X}"
write_line(f"SI_CMD(0x{opcode:02X}{argv_str}),")
raise "Reached end of data before END command"
if __name__ == "__main__":
if len(sys.argv) <= 1:
print("usage: ./disasm_script.py <file> [offset]")
exit()
file = sys.argv[1]
offset = eval(sys.argv[2]) if len(sys.argv) >= 3 else 0
with open(file, "rb") as f:
f.seek(offset)
print(disassemble(f), end="")

View File

@ -1151,8 +1151,11 @@ segments:
start: 0x8EB360
vram: 0x80240000
files:
- [0x8EB360, "c", "world/area_kmr/kmr_12"]
- [0x8EB390, "bin", "world/area_kmr/kmr_12_data"]
- [0x8EB360, "c", "world/area_kmr/kmr_12/events"]
- [0x8EB390, ".data", "world/area_kmr/kmr_12/header"]
- [0x8EB360, "c", "world/area_kmr/kmr_12/events"]
- [0x8EB360, ".data", "world/area_kmr/kmr_12/events"]
- [0x8EBE10, ".rodata", "world/area_kmr/kmr_12/events"]
- name: world/area_kmr/kmr_20
type: code
start: 0x8EBE20

View File

@ -227,6 +227,9 @@ gEffectTable = 0x8007F214;
gPauseMenuStrings = 0x8026F778;
EnterWalk = 0x80285960;
ExitWalk = 0x80285CF4;
MarioEnterStage = 0x80284A40;
PeachEnterStage = 0x80284D04;
HandleEvent_Player = 0x802852D4;