Merge pull request #84 from nanaian/scripts

Script disassembly, match kmr_12
This commit is contained in:
Ethan Roseman 2020-10-20 13:50:04 -04:00 committed by GitHub
commit ac244f4220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1719 additions and 166 deletions

View File

@ -10,4 +10,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: ./coverage.py --fail-matched-undeleted --fail-unincluded
- run: ./coverage.py --fail-matched-undeleted --fail-unincluded --skip-sizes

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

@ -80,17 +80,19 @@ if __name__ == "__main__":
print("--fail-unincluded exit with error code 2 if unincluded assembly files exist")
print("--delete-matched delete matched function(s) from asm/nonmatchings/ without asking")
print("--delete-unincluded delete unincluded, unmatched assembly files")
print("--skip-sizes don't attempt to read build/papermario.map to determine sizes")
exit()
total = len(matched) + len(non_matched)
print(f"{len(matched)}+{len(partial_matched)} / {total} functions ({(len(matched) / total) * 100:.2f}%)")
function_sizes = parse_map_file()
size_matched = sum(function_sizes.get(f, 0) for f in matched)
size_partial_matched = sum(function_sizes.get(f, 0) for f in partial_matched)
size_non_matched = sum(function_sizes.get(f, 0) for f in non_matched)
size_total = size_matched + size_non_matched
print(f"{size_matched}+{size_partial_matched} / {size_total} bytes ({(size_matched / size_total) * 100:.2f}%)")
if not "--skip-sizes":
function_sizes = parse_map_file()
size_matched = sum(function_sizes.get(f, 0) for f in matched)
size_partial_matched = sum(function_sizes.get(f, 0) for f in partial_matched)
size_non_matched = sum(function_sizes.get(f, 0) for f in non_matched)
size_total = size_matched + size_non_matched
print(f"{size_matched}+{size_partial_matched} / {size_total} bytes ({(size_matched / size_total) * 100:.2f}%)")
if len(matched_but_undeleted_asm) > 0:
print(f"The following functions have been matched but still exist in asm/nonmatchings/: {' '.join(matched_but_undeleted_asm)}")

View File

@ -9,5 +9,6 @@
#include "macros.h"
#include "enums.h"
#include "si.h"
#include "messages.h"
#endif

View File

@ -5,6 +5,7 @@
#include "ultra64.h"
#include "types.h"
#include "si.h"
#include "enums.h"
struct ScriptInstance;
@ -27,6 +28,13 @@ typedef struct Vec3s {
/* 0x04 */ s16 z;
} Vec3s; // size = 0x06
typedef struct Vec4f {
/* 0x00 */ f32 x;
/* 0x04 */ f32 y;
/* 0x08 */ f32 z;
/* 0x0C */ f32 yaw;
} Vec4f; // size = 0x10
typedef struct Matrix4f {
/* 0x00 */ f32 mtx[4][4];
} Matrix4f; // size = 0x40
@ -193,70 +201,9 @@ 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 Enemy {
/* 0x00 */ s32 flags;
/* 0x04 */ u8 encounterIndex;
/* 0x05 */ s8 encountered;
/* 0x06 */ u8 scriptGroup; /* scripts launched for this npc controller will be assigned this group */
/* 0x07 */ s8 unk_07;
/* 0x08 */ s16 npcID;
/* 0x0A */ s16 spawnPos[3];
/* 0x10 */ Vec3s unk_10;
/* 0x16 */ char unk_16[2];
/* 0x18 */ struct StaticNpcSettings* npcSettings;
/* 0x1C */ Bytecode* initBytecode;
/* 0x20 */ Bytecode* interactBytecode;
/* 0x24 */ Bytecode* aiBytecode;
/* 0x28 */ Bytecode* hitBytecode;
/* 0x2C */ Bytecode* auxBytecode;
/* 0x30 */ Bytecode* defeatBytecode;
/* 0x34 */ struct ScriptInstance* initScript;
/* 0x38 */ struct ScriptInstance* interactScript;
/* 0x3C */ struct ScriptInstance* aiScript;
/* 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;
/* 0x64 */ char unk_64[8];
/* 0x6C */ s32 varTable[16];
/* 0xAC */ char unk_AC[9];
/* 0xB5 */ s8 unk_B5;
/* 0xB6 */ char unk_B6[2];
/* 0xB8 */ s32 unkSettings24;
/* 0xBC */ char unk_BC[8];
/* 0xC4 */ s32 unk_C4;
/* 0xC8 */ s32 unk_C8;
/* 0xCC */ s32* animList;
/* 0xD0 */ UNK_PTR territoryData;
/* 0xD4 */ s16* dropTables;
/* 0xD8 */ u32 tattleString;
/* 0xDC */ char unk_DC[20];
} Enemy; // size = 0xF0
typedef struct StaticNpcSettings {
/* 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;
/* 0x20 */ s32 flags;
/* 0x24 */ char unk_24[4];
/* 0x28 */ s16 level;
/* 0x2A */ s16 unkFlags;
} StaticNpcSettings; // size = 0x2C
typedef struct ScriptInstance {
/* 0x000 */ u8 state;
/* 0x001 */ u8 currentArgc;
@ -285,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;
@ -347,27 +294,6 @@ typedef struct MusicPlayer {
/* 0x18 */ char unk_18[24];
} MusicPlayer; // size = 0x30
typedef struct StaticNpc {
/* 0x000 */ s32 ID;
/* 0x004 */ struct StaticNpcSettings* npcSettings;
/* 0x008 */ s32 spawnPos[3];
/* 0x014 */ s32 flags;
/* 0x018 */ Bytecode* initScript;
/* 0x01C */ char unk_1C[8];
/* 0x024 */ s32 spawnYaw;
/* 0x028 */ s16 itemDrops[25];
/* 0x05A */ s16 heartDrops[32];
/* 0x09A */ s16 flowerDrops[32];
/* 0x0DA */ s16 minCoinBonus;
/* 0x0DC */ s16 maxCoinBonus;
/* 0x0DE */ char unk_DE[2];
/* 0x0E0 */ s32 movementData[48];
/* 0x1A0 */ s32 animations[16];
/* 0x1E0 */ char unk_1E0[8];
/* 0x1E8 */ UNK_PTR extraAnimations;
/* 0x1EC */ s32 tattle;
} StaticNpc; // size = 0x1F0
typedef struct MenuIcon {
/* 0x00 */ u32 flags;
/* 0x04 */ u32* readPos;
@ -438,7 +364,6 @@ typedef struct UiStatus {
/* 0x68 */ s32 iconIndex13;
/* 0x6C */ s8 unk_6C[4];
} UiStatus; // size = 0x70
typedef struct Collider {
/* 0x00 */ s32 flags;
/* 0x04 */ s16 nextSibling;
@ -600,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;
@ -923,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 */
@ -1295,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

@ -554,7 +554,7 @@ typedef UNK_TYPE Cam;
#define Cam_TATTLE 0x00000002
#define Cam_CAM3 0x00000003
typedef UNK_TYPE ItemId;
typedef s16 ItemId;
#define ItemId_JUMP 0x00000001
#define ItemId_SPIN_JUMP 0x00000002
#define ItemId_TORNADO_JUMP 0x00000003
@ -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

View File

@ -87,8 +87,6 @@ Npc* get_npc_unsafe(NpcId npcId);
Npc* resolve_npc(ScriptInstance* script, NpcId npcIdOrPtr);
void set_npc_yaw(Npc* npcPtr, f32 angle);
Enemy* get_enemy(NpcId npcId);
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by);
f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz);
void add_vec2D_polar(f32* x, f32* y, f32 r, f32 theta);

View File

@ -45,4 +45,7 @@
#define SQ(x) (x*x)
// Fixed-point short literal
#define F16(f) (s16)(f * 327.67f)
#endif

206
include/map.h Normal file
View File

@ -0,0 +1,206 @@
#ifndef _MAP_H_
#define _MAP_H_
#include "common_structs.h"
#include "enums.h"
#include "script_api/map.h"
// TODO: consider moving Npc here
#define ENTRY_COUNT(entryList) (sizeof(entryList) / sizeof(Vec4f))
typedef Vec4f EntryList[];
typedef struct MapConfig {
/* 0x00 */ char unk_00[0x10];
/* 0x10 */ Script* main;
/* 0x14 */ EntryList* entryList;
/* 0x18 */ s32 entryCount;
/* 0x1C */ char unk_1C[0x1C];
/* 0x38 */ BackgroundHeader* background;
/* 0x3C */ union {
MessageID msgID;
UNK_FUN_PTR(get);
} tattle;
} MapConfig; // 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
typedef struct NpcSettings {
/* 0x00 */ char unk_00[4];
/* 0x04 */ s16 height;
/* 0x06 */ s16 radius;
/* 0x08 */ UNK_PTR otherAI;
/* 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;
} NpcSettings; // size = 0x2C
typedef struct ItemDrop {
/* 0x00 */ ItemId item;
/* 0x02 */ s16 weight;
/* 0x04 */ s16 unk_08;
} ItemDrop; // size = 0x06
typedef struct StatDrop {
// NOTE: these %s are F16
/* 0x00 */ s16 hpCutoff; // % of max HP/FP
/* 0x02 */ s16 generalChance; // %
/* 0x04 */ s16 attempts;
/* 0x06 */ s16 chancePerAttempt; // %
} StatDrop; // size = 0x08
#define NO_DROPS { F16(100), F16(0), 0, F16(0) }
#define STANDARD_HEART_DROPS(attempts) { \
{ F16(20), F16(70), attempts, F16(50) }, \
{ F16(30), F16(60), attempts, F16(50) }, \
{ F16(50), F16(50), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(30) }, \
}
#define GENEROUS_HEART_DROPS(attempts) { \
{ F16(20), F16(80), attempts, F16(50) } \
{ F16(30), F16(70), attempts, F16(50) } \
{ F16(50), F16(60), attempts, F16(40) } \
{ F16(80), F16(50), attempts, F16(40) } \
{ F16(100), F16(40), attempts, F16(30) }, \
}
#define GENEROUS_WHEN_LOW_HEART_DROPS(attempts) { \
{ F16(20), F16(80), attempts, F16(60) }, \
{ F16(30), F16(70), attempts, F16(50) }, \
{ F16(50), F16(60), attempts, F16(50) }, \
{ F16(80), F16(50), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(30) }, \
}
#define STANDARD_FLOWER_DROPS(attempts) { \
{ F16(20), F16(50), attempts, F16(40) }, \
{ F16(30), F16(40), attempts, F16(40) }, \
{ F16(50), F16(40), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(40) }, \
}
#define GENEROUS_WHEN_LOW_FLOWER_DROPS(attempts) { \
{ F16(20), F16(70), attempts, F16(50) }, \
{ F16(30), F16(60), attempts, F16(50) }, \
{ F16(50), F16(50), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(40) }, \
}
#define REDUCED_FLOWER_DROPS(attempts) { \
{ F16(20), F16(40), attempts, F16(40) }, \
{ F16(30), F16(40), attempts, F16(40) }, \
{ F16(50), F16(40), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(40) }, \
}
#define ANIMATION(sprite, palette, anim) (sprite << 16) + (palette << 8) + anim
#define OVERRIDE_MOVEMENT_SPEED(speed) (speed * 32767)
#define NO_OVERRIDE_MOVEMENT_SPEED OVERRIDE_MOVEMENT_SPEED(-1)
typedef struct StaticNPC {
/* 0x000 */ NpcId id;
/* 0x004 */ NpcSettings* settings;
/* 0x008 */ Vec3f pos;
/* 0x014 */ s32 flags;
/* 0x018 */ Bytecode* init;
/* 0x01C */ char unk_1C[8];
/* 0x024 */ s32 yaw;
/* 0x028 */ s8 dropFlags;
/* 0x029 */ s8 itemDropChance; // %
/* 0x02A */ ItemDrop itemDrops[8];
/* 0x05A */ StatDrop heartDrops[8];
/* 0x09A */ StatDrop flowerDrops[8];
/* 0x0DA */ s16 minCoinBonus;
/* 0x0DC */ s16 maxCoinBonus;
/* 0x0DE */ char unk_DE[2];
/* 0x0E0 */ s32 movement[48]; // TODO: type
/* 0x1A0 */ s32 animations[16];
/* 0x1E0 */ char unk_1E0[8];
/* 0x1E8 */ UNK_PTR extraAnimations;
/* 0x1EC */ MessageID tattle;
} StaticNpc; // size = 0x1F0
typedef struct Enemy {
/* 0x00 */ s32 flags;
/* 0x04 */ u8 encounterIndex;
/* 0x05 */ s8 encountered;
/* 0x06 */ u8 scriptGroup; /* scripts launched for this npc controller will be assigned this group */
/* 0x07 */ s8 unk_07;
/* 0x08 */ s16 npcID;
/* 0x0A */ s16 spawnPos[3];
/* 0x10 */ Vec3s unk_10;
/* 0x16 */ char unk_16[2];
/* 0x18 */ struct NpcSettings* npcSettings;
/* 0x1C */ Bytecode* initBytecode;
/* 0x20 */ Bytecode* interactBytecode;
/* 0x24 */ Bytecode* aiBytecode;
/* 0x28 */ Bytecode* hitBytecode;
/* 0x2C */ Bytecode* auxBytecode;
/* 0x30 */ Bytecode* defeatBytecode;
/* 0x34 */ struct ScriptInstance* initScript;
/* 0x38 */ struct ScriptInstance* interactScript;
/* 0x3C */ struct ScriptInstance* aiScript;
/* 0x40 */ struct ScriptInstance* hitScript;
/* 0x44 */ struct ScriptInstance* auxScript;
/* 0x48 */ struct ScriptInstance* defeatScript;
/* 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];
/* 0xB5 */ s8 unk_B5;
/* 0xB6 */ char unk_B6[2];
/* 0xB8 */ s32 unkSettings24;
/* 0xBC */ char unk_BC[8];
/* 0xC4 */ s32 unk_C4;
/* 0xC8 */ s32 unk_C8;
/* 0xCC */ s32* animList;
/* 0xD0 */ UNK_PTR territoryData;
/* 0xD4 */ s16* dropTables;
/* 0xD8 */ u32 tattleString;
/* 0xDC */ char unk_DC[20];
} Enemy; // size = 0xF0
typedef struct {
/* 0x00 */ s32 npcCount;
/* 0x04 */ StaticNpc* npcs;
/* 0x08 */ FormationID formationID;
} NpcGroupList[]; // size = 0x0C
#define NPC_GROUP(npcs, formationID) { sizeof(npcs) / sizeof(StaticNpc), &npcs, formationID }
#define NPC_GROUP_LIST_END() { 0, 0, 0 }
Enemy* get_enemy(NpcId npcId);
#endif

65
include/messages.h Normal file
View File

@ -0,0 +1,65 @@
#ifndef _MESSAGES_H_
#define _MESSAGES_H_
#include "types.h"
typedef s32 MessageID;
#define MESSAGE_ID(section, index) ((section << 0x10) + index)
// 00 Introduction
// 01 Postgame Celebration
// 02 Toad Town Gate Sector
// 03 Toad Town Castle Sector
// 04 Toad Town Bridge Sector
// 05 Toad Town Train Sector
// 06 Toad Town Warehouse Sector
// 07 Toad Town Docks Sector
// 08 Minigames
// 09 Castle Grounds
// 0A Shooting Star Summit
// 0B Chapter 0
// 0C Chapter 1
// 0D Chapter 2
// 0E Chapter 3
// 0F Chapter 4
// 10 Chapter 5
// 11 Chapter 6
// 12 Chapter 7
// 13 Bowser's Castle
// 14 Peach Segments
// 15 Koopa Koot Favors
// 16 Russ T Advice
// 17 News Bulletin
// 18 Gossip Bulletin
// 19 Map Tattles
#define MessageID_TATTLE_KMR_12 MESSAGE_ID(0x19, 0x40)
// 1A NPC Tattles
// 1B Entity Tattles
// 1C Enemy Tattles
// 1D Menus I
#define MessageID_SIGN_MUSHROOM_GOOMBA_TRAP MESSAGE_ID(0x1D, 0x167)
#define MessageID_SIGN_GOOMBA_KINGS_FORTRESS_AHEAD MESSAGE_ID(0x1D, 0x168)
// 1E Choices
// 1F Menus II
// 20 Party Letters + Luigi's Diary
// 21 Advice Fortunes
// 22 Treasure Fortunes
// 23 Item Descriptions I
// 24 Item Descriptions II
// 25 Item Descriptions III
// 26 Item Names
// 27 Shop Messages
// 28 Partner Descriptions
// 29 Enemy Names
// 2A Mario Moves
// 2B Partner Moves
// 2C Quiz Questions
// 2D Quiz Options
// 2E Credits
#endif

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 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

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

@ -0,0 +1,276 @@
#ifndef _SCRIPT_API_COMMON_H_
#define _SCRIPT_API_COMMON_H_
#include "common_structs.h"
#include "si.h"
typedef Bytecode Script[];
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);
ApiStatus func_800441F0(ScriptInstance* script, s32 isInitialCall);
ApiStatus func_802D5830(ScriptInstance* script, s32 isInitialCall);
extern Script ShakeCam1;
extern Script ShakeCamX;
extern Script EnemyNpcHit;
extern Script EnemyNpcDefeat;
#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 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,7 +3,20 @@
#include "ultra64.h"
#define SI_VAR_0 0xFE363C80
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)
#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 +31,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, 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) \
{ \
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

@ -10,6 +10,7 @@
#define UNK_FUN_PTR(name) void(*name)(void)
#define UNK_ARGS
typedef s32 Bytecode;
typedef s32 FormationID;
#define FORMATION_ID(section, stage, index) (section << 16) + (stage << 8) + index
#endif

View File

@ -1,4 +1,5 @@
#include "common.h"
#include "map.h"
void NOP_npc_callback(void) {
}

View File

@ -1,4 +1,5 @@
#include "common.h"
#include "map.h"
ApiStatus SetEncounterStatusFlags(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
@ -71,7 +72,7 @@ ApiStatus DoNpcDefeat(ScriptInstance* script, s32 isInitialCall) {
temp_s1->currentAnim = owner->animList[6];
newScript = start_script(&SCRIPT_NpcDefeat, 10, 0);
owner->defeatScript = newScript;
owner->defeatScriptID = newScript->uniqueID;
owner->defeatScriptID = newScript->id;
newScript->ownerActorID = owner;
newScript->ownerID = owner->npcID;
newScript->groupFlags = owner->scriptGroup;
@ -147,7 +148,7 @@ ApiStatus RestartNpcAI(ScriptInstance* script, s32 isInitialCall) {
npc->unk_C8 = 100;
newScript = start_script(npc->aiBytecode, 10, 0);
npc->aiScript = newScript;
npc->aiScriptID = newScript->uniqueID;
npc->aiScriptID = newScript->id;
newScript->ownerActorID = npc;
newScript->ownerID = script->ownerID;
newScript->groupFlags = groupFlags;
@ -221,7 +222,7 @@ ApiStatus RestartNpcAux(ScriptInstance* script, s32 isInitialCall) {
newScript = start_script(npc->auxBytecode, 10, 0);
npc->auxScript = newScript;
npc->auxScriptID = newScript->uniqueID;
npc->auxScriptID = newScript->id;
newScript->ownerActorID = npc;
newScript->ownerID = npcId;
newScript->groupFlags = groupFlags;
@ -501,7 +502,7 @@ ApiStatus func_80045838(ScriptInstance* script, s32 isInitialCall) {
}
ApiStatus func_800458CC(ScriptInstance* script, s32 isInitialCall) {
set_variable(script, *script->ptrReadPos, script->ownerActorID->npcSettings->unkFlags & 8);
set_variable(script, *script->ptrReadPos, script->ownerActorID->npcSettings->unk_2A & 8);
return ApiStatus_DONE2;
}

View File

@ -23,7 +23,7 @@ void sort_scripts(void) {
if (curScript != NULL) {
if (curScript->state != 0) {
scriptIndexList[numValidScripts] = i;
scriptIdList[numValidScripts] = curScript->uniqueID;
scriptIdList[numValidScripts] = curScript->id;
numValidScripts++;
}
}
@ -189,7 +189,7 @@ ScriptInstance* start_script(Bytecode* initialLine, s32 priority, s32 initialSta
newScript->blockingParent = NULL;
newScript->childScript = NULL;
newScript->parentScript = NULL;
newScript->uniqueID = gStaticScriptCounter++;
newScript->id = gStaticScriptCounter++;
newScript->ownerActorID = -1;
newScript->ownerID = -1;
newScript->loopDepth = -1;
@ -215,7 +215,7 @@ ScriptInstance* start_script(Bytecode* initialLine, s32 priority, s32 initialSta
if ((D_802D9CA4 != 0) && ((newScript->state & 0x20) != 0)) {
scriptListCount = gScriptListCount++;
gScriptIndexList[scriptListCount] = curScriptIndex;
gScriptIdList[scriptListCount] = newScript->uniqueID;
gScriptIdList[scriptListCount] = newScript->id;
}
func_802C3390(newScript);
{
@ -260,7 +260,7 @@ ScriptInstance* start_script_in_group(Bytecode* initialLine, u8 priority, s32 in
newScript->blockingParent = NULL;
newScript->childScript = NULL;
newScript->parentScript = NULL;
newScript->uniqueID = gStaticScriptCounter++;
newScript->id = gStaticScriptCounter++;
newScript->ownerActorID = -1;
newScript->ownerID = -1;
newScript->loopDepth = -1;
@ -286,7 +286,7 @@ ScriptInstance* start_script_in_group(Bytecode* initialLine, u8 priority, s32 in
if ((D_802D9CA4 != 0) && ((newScript->state & 0x20) != 0)) {
scriptListCount = gScriptListCount++;
gScriptIndexList[scriptListCount] = curScriptIndex;
gScriptIdList[scriptListCount] = newScript->uniqueID;
gScriptIdList[scriptListCount] = newScript->id;
}
func_802C3390(newScript);
@ -333,7 +333,7 @@ ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine,
child->parentScript = parentScript;
child->childScript = NULL;
child->priority = parentScript->priority;
child->uniqueID = gStaticScriptCounter++;
child->id = gStaticScriptCounter++;
child->ownerActorID = parentScript->ownerActorID;
child->ownerID = parentScript->ownerID;
child->loopDepth = -1;
@ -360,7 +360,7 @@ ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine,
if (D_802D9CA4 != 0) {
scriptListCount = gScriptListCount++;
gScriptIndexList[scriptListCount] = curScriptIndex;
gScriptIdList[scriptListCount] = child->uniqueID;
gScriptIdList[scriptListCount] = child->id;
}
temp6 = &gStaticScriptCounter;
@ -502,7 +502,7 @@ void kill_script_by_ID(s32 id) {
for (i = 0; i < MAX_SCRIPTS; i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
kill_script(scriptContextPtr);
}
}
@ -527,7 +527,7 @@ s32 does_script_exist(s32 id) {
for (i = 0; i < MAX_SCRIPTS; i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
return 1;
}
}
@ -638,7 +638,7 @@ s32 suspend_all_script(s32 id) {
for (i = 0; i < MAX_SCRIPTS; i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
suspend_group_script(scriptContextPtr, 0xEF);
}
}
@ -650,7 +650,7 @@ s32 resume_all_script(s32 id) {
for (i = 0; i < MAX_SCRIPTS; i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
resume_group_script(scriptContextPtr, 0xEF);
}
}
@ -662,7 +662,7 @@ void suspend_group_script_index(s32 id, s32 groupFlags) {
for (i = 0; i < MAX_SCRIPTS; i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
suspend_group_script(scriptContextPtr, groupFlags);
}
}
@ -674,7 +674,7 @@ void resume_group_script_index(s32 id, s32 groupFlags) {
for (i = 0; i < MAX_SCRIPTS; i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
resume_group_script(scriptContextPtr, groupFlags);
}
}
@ -739,7 +739,7 @@ ScriptInstance* get_script_by_id(s32 id) {
for (i = 0; i < MAX_SCRIPTS; i++) {
if ((*gCurrentScriptListPtr)[i] != NULL) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr->uniqueID == id) {
if (scriptContextPtr->id == id) {
return scriptContextPtr;
}
}

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

@ -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

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

View File

@ -0,0 +1,238 @@
#include "kmr_12.h"
static Script make_entities;
static Script read_west_sign;
static NpcGroupList npc_groups;
static Script exit_west = EXIT_WALK_SCRIPT(60, 0, "kmr_07", 1);
static Script exit_east = EXIT_WALK_SCRIPT(60, 1, "kmr_11", 0);
static Script 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(),
};
Script 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, npc_groups),
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_west_sign, TriggerFlag_WALL_INTERACT, 10, NULL),
SI_RETURN(),
SI_END(),
};
static NpcAISettings goomba_ai_settings = {
.moveSpeed = 1.5f,
.moveTime = 30,
.waitTime = 30,
.alertRadius = 130.0f,
.unk_10 = 0.0f,
.unk_14 = 1,
.chaseSpeed = 2.5f,
.unk_1C = 180,
.unk_20 = 3,
.chaseRadius = 150.0f,
.unk_28 = 0.0f,
.unk_2C = TRUE,
};
static Script goomba_ai = {
SI_CALL(DoBasicAI, &goomba_ai_settings),
SI_RETURN(),
SI_END(),
};
static NpcSettings goomba_npc_settings = {
.height = 20,
.radius = 23,
.ai = &goomba_ai,
.onHit = EnemyNpcHit,
.onDefeat = EnemyNpcDefeat,
.level = 5,
};
// *INDENT-OFF*
/// @bug The RETURN command is after the END command, so this script will never terminate.
static Script read_west_sign = {
SI_GROUP(0),
// "Eat a Mushroom to regain your energy!"
SI_SUSPEND_GROUP(1),
SI_CALL(DisablePlayerInput, TRUE),
SI_CALL(ShowMessageAtScreenPos, MessageID_SIGN_MUSHROOM_GOOMBA_TRAP, 160, 40),
SI_RESUME_GROUP(1),
SI_SET(SI_FLAG(0), FALSE),
SI_CALL(kmr_12_get_goomba_ref),
SI_IF_NE(SI_VAR(0), FALSE),
SI_CALL(GetNpcVar, NpcId_GOOMBA, 0, SI_VAR(0)),
SI_IF_EQ(SI_VAR(0), FALSE),
// Trigger Goomba to peel off
SI_CALL(SetNpcVar, NpcId_GOOMBA, 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(),
};
static Script goomba_idle = {
SI_WAIT_FRAMES(1),
SI_CALL(SetSelfVar, 0, FALSE),
SI_CALL(SetNpcAnimation, NpcId_SELF, ANIMATION(SpriteId_GOOMBA, 0, 13)),
SI_CALL(EnableNpcShadow, NpcId_SELF, FALSE),
SI_CALL(SetSelfEnemyFlagBits, 0x00000020, TRUE),
// 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), FALSE),
SI_GOTO(0),
SI_END_IF(),
// Peel and jump off the sign
SI_CALL(SetNpcFlagBits, NpcId_SELF, 0x00240000, TRUE),
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, ANIMATION(SpriteId_GOOMBA, 0, 0)),
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, ANIMATION(SpriteId_GOOMBA, 0, 7)),
SI_WAIT_FRAMES(20),
SI_CALL(SetNpcAnimation, NpcId_SELF, ANIMATION(SpriteId_GOOMBA, 0, 1)),
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, TRUE),
SI_CALL(SetNpcJumpscale, NpcId_SELF, SI_FIXED(0.6005859375f)),
SI_CALL(NpcJump0, NpcId_SELF, -35, 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, 0x00240000, FALSE),
SI_CALL(SetSelfEnemyFlagBits, 0x00000020, FALSE),
SI_CALL(SetSelfEnemyFlagBits, 0x40000000, TRUE),
// We're done jumping off; the player can read the sign again
SI_BIND(read_west_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(),
};
static Script goomba_init = {
SI_CALL(BindNpcIdle, NpcId_SELF, &goomba_idle),
SI_RETURN(),
SI_END(),
};
// *INDENT-ON*
static StaticNpc goomba_npc = {
.id = NpcId_GOOMBA,
.settings = &goomba_npc_settings,
.pos = { -33.0f, 30.0f, -25.0f },
.flags = 0x00000C00,
.init = goomba_init,
.yaw = 90,
.dropFlags = 0x80,
.itemDropChance = 5,
.itemDrops = { { ItemId_MUSHROOM, 10 } },
.heartDrops = GENEROUS_WHEN_LOW_HEART_DROPS(2),
.flowerDrops = GENEROUS_WHEN_LOW_FLOWER_DROPS(2),
.movement = {
// Wander
/* center x, y, z */ -33, 0, 30,
/* size x, z */ 40, 20,
/* speed */ NO_OVERRIDE_MOVEMENT_SPEED,
/* box? */ TRUE,
// Detect
/* center x, y, z */ 200, 0, 0,
/* size x, z */ 400, 60,
/* box? */ TRUE,
/* flying? */ TRUE,
},
.animations = {
ANIMATION(SpriteId_GOOMBA, 0, 1),
ANIMATION(SpriteId_GOOMBA, 0, 2),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 1),
ANIMATION(SpriteId_GOOMBA, 0, 1),
ANIMATION(SpriteId_GOOMBA, 0, 5),
ANIMATION(SpriteId_GOOMBA, 0, 5),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
ANIMATION(SpriteId_GOOMBA, 0, 3),
},
};
static NpcGroupList npc_groups = {
NPC_GROUP(goomba_npc, FORMATION_ID(1, 0, 3)),
NPC_GROUP_LIST_END(),
};
// *INDENT-OFF*
static Script read_east_sign = {
SI_CALL(func_800441F0, SI_VAR(0)),
SI_IF_EQ(SI_VAR(0), 1),
SI_RETURN(),
SI_END_IF(),
SI_GROUP(0),
SI_CALL(func_802D5830, 1),
SI_CALL(DisablePlayerInput, 1),
SI_CALL(ShowMessageAtScreenPos, MessageID_SIGN_GOOMBA_KINGS_FORTRESS_AHEAD, 160, 40),
SI_CALL(DisablePlayerInput, 0),
SI_CALL(func_802D5830, 0),
SI_RETURN(),
SI_END(),
};
static Script make_entities = {
SI_CALL(MakeEntity, 0x802EAFDC, 436, 0, -42, 0, 0x80000000),
SI_CALL(AssignScript, &read_east_sign),
SI_RETURN(),
SI_END(),
};
// *INDENT-ON*

View File

@ -0,0 +1,25 @@
#include "kmr_12.h"
static EntryList entryList = {
{ -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
};
MapConfig config = {
.main = kmr_12_main,
.entryList = entryList,
.entryCount = ENTRY_COUNT(entryList),
.background = &gBackgroundImage,
.tattle = MessageID_TATTLE_KMR_12,
};
Script kmr_12_play_music = {
SI_CALL(SetMusicTrack, 0, Song_PLEASANT_PATH, 0, 8),
SI_RETURN(),
SI_END(),
};
ApiStatus kmr_12_get_goomba_ref(ScriptInstance* script, s32 isInitialCall) {
script->varTable[0] = get_enemy_safe(NpcId_GOOMBA);
return ApiStatus_DONE2;
}

View File

@ -0,0 +1,8 @@
#include "common.h"
#include "map.h"
#define NpcId_GOOMBA 0
Script kmr_12_main;
Script kmr_12_play_music;
ApiStatus kmr_12_get_goomba_ref(ScriptInstance* script, s32 isInitialCall);

311
tools/disasm_script.py Executable file
View File

@ -0,0 +1,311 @@
#! /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 Script {name};")
"""
except:
pass
return _star_rod_lib
def addr_ref(addr):
return star_rod_lib().get(addr, f"0x{addr:08X}")
def disassemble(bytes, indent = 0, script_name = "script"):
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("// *INDENT-OFF*")
prefix_line(f"Script {script_name} = {{")
write_line("};")
write_line("// *INDENT-ON*")
else:
prefix_line(f"Script {script_name} = {{")
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,10 @@ 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/header"]
- [0x8EB390, ".data", "world/area_kmr/kmr_12/header"]
- [0x8EB420, ".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

@ -1893,3 +1893,6 @@ gSpeakingActorTalkAnim;0x8029FA6C
gSpeakingActorIdleAnim;0x8029FA70
gSpeakingActor;0x8029FA74
gSpeakingActorPart;0x8029FA7C
EnterWalk;0x80285960
EnemyNpcHit;0x80077F70
EnemyNpcDefeat;0x8007809C

View File

@ -227,6 +227,9 @@ gEffectTable = 0x8007F214;
gPauseMenuStrings = 0x8026F778;
EnterWalk = 0x80285960;
ExitWalk = 0x80285CF4;
MarioEnterStage = 0x80284A40;
PeachEnterStage = 0x80284D04;
HandleEvent_Player = 0x802852D4;
@ -254,3 +257,6 @@ DoSpinSmashHit = 0x8029B998;
DoStopHit = 0x80294650;
ShakeCam1 = 0x802D9CB0;
ShakeCamX = 0x802D9CE8;
EnemyNpcHit = 0x80077F70;
EnemyNpcDefeat = 0x8007809C;