a few random functions

This commit is contained in:
Ethan Roseman 2020-08-10 01:03:56 -04:00
parent 57e77e1cb1
commit 5ebdd6bd40
17 changed files with 169 additions and 194 deletions

View File

@ -1,18 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel GetOwnerEncountered
/* 01FA00 80044600 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 01FA04 80044604 AFBF0010 */ sw $ra, 0x10($sp)
/* 01FA08 80044608 8C82000C */ lw $v0, 0xc($a0)
/* 01FA0C 8004460C 8C830148 */ lw $v1, 0x148($a0)
/* 01FA10 80044610 8C450000 */ lw $a1, ($v0)
/* 01FA14 80044614 0C0B2026 */ jal set_variable
/* 01FA18 80044618 80660005 */ lb $a2, 5($v1)
/* 01FA1C 8004461C 8FBF0010 */ lw $ra, 0x10($sp)
/* 01FA20 80044620 24020002 */ addiu $v0, $zero, 2
/* 01FA24 80044624 03E00008 */ jr $ra
/* 01FA28 80044628 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,18 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel GetSelfNpcID
/* 020A14 80045614 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 020A18 80045618 AFBF0010 */ sw $ra, 0x10($sp)
/* 020A1C 8004561C 8C82000C */ lw $v0, 0xc($a0)
/* 020A20 80045620 8C830148 */ lw $v1, 0x148($a0)
/* 020A24 80045624 8C450000 */ lw $a1, ($v0)
/* 020A28 80045628 0C0B2026 */ jal set_variable
/* 020A2C 8004562C 84660008 */ lh $a2, 8($v1)
/* 020A30 80045630 8FBF0010 */ lw $ra, 0x10($sp)
/* 020A34 80045634 24020002 */ addiu $v0, $zero, 2
/* 020A38 80045638 03E00008 */ jr $ra
/* 020A3C 8004563C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,21 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel LoadDemoBattle
/* 01F664 80044264 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 01F668 80044268 AFBF0010 */ sw $ra, 0x10($sp)
/* 01F66C 8004426C 8C82000C */ lw $v0, 0xc($a0)
/* 01F670 80044270 0C0B1EAF */ jal get_variable
/* 01F674 80044274 8C450000 */ lw $a1, ($v0)
/* 01F678 80044278 0C01CB85 */ jal load_demo_battle
/* 01F67C 8004427C 0040202D */ daddu $a0, $v0, $zero
/* 01F680 80044280 8FBF0010 */ lw $ra, 0x10($sp)
/* 01F684 80044284 24020002 */ addiu $v0, $zero, 2
/* 01F688 80044288 03E00008 */ jr $ra
/* 01F68C 8004428C 27BD0018 */ addiu $sp, $sp, 0x18
/* 01F690 80044290 03E00008 */ jr $ra
/* 01F694 80044294 24020002 */ addiu $v0, $zero, 2

View File

@ -1,13 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel SetSelfEnemyFlags
/* 02090C 8004550C 8C82000C */ lw $v0, 0xc($a0)
/* 020910 80045510 8C830148 */ lw $v1, 0x148($a0)
/* 020914 80045514 8C420000 */ lw $v0, ($v0)
/* 020918 80045518 AC620000 */ sw $v0, ($v1)
/* 02091C 8004551C 03E00008 */ jr $ra
/* 020920 80045520 24020002 */ addiu $v0, $zero, 2

View File

@ -1,15 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel StartBattle
/* 01FC40 80044840 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 01FC44 80044844 AFBF0010 */ sw $ra, 0x10($sp)
/* 01FC48 80044848 0C0111AD */ jal start_battle
/* 01FC4C 8004484C 2405FFFF */ addiu $a1, $zero, -1
/* 01FC50 80044850 8FBF0010 */ lw $ra, 0x10($sp)
/* 01FC54 80044854 24020001 */ addiu $v0, $zero, 1
/* 01FC58 80044858 03E00008 */ jr $ra
/* 01FC5C 8004485C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,22 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel StartBattleWith
/* 01FC60 80044860 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 01FC64 80044864 AFB00010 */ sw $s0, 0x10($sp)
/* 01FC68 80044868 0080802D */ daddu $s0, $a0, $zero
/* 01FC6C 8004486C AFBF0014 */ sw $ra, 0x14($sp)
/* 01FC70 80044870 8E02000C */ lw $v0, 0xc($s0)
/* 01FC74 80044874 0C0B1EAF */ jal get_variable
/* 01FC78 80044878 8C450000 */ lw $a1, ($v0)
/* 01FC7C 8004487C 0200202D */ daddu $a0, $s0, $zero
/* 01FC80 80044880 0C0111AD */ jal start_battle
/* 01FC84 80044884 0040282D */ daddu $a1, $v0, $zero
/* 01FC88 80044888 8FBF0014 */ lw $ra, 0x14($sp)
/* 01FC8C 8004488C 8FB00010 */ lw $s0, 0x10($sp)
/* 01FC90 80044890 24020001 */ addiu $v0, $zero, 1
/* 01FC94 80044894 03E00008 */ jr $ra
/* 01FC98 80044898 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,16 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel func_800F52BC
/* 08E76C 800F52BC 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 08E770 800F52C0 AFBF0010 */ sw $ra, 0x10($sp)
/* 08E774 800F52C4 0C03C684 */ jal func_800F1A10
/* 08E778 800F52C8 00000000 */ nop
/* 08E77C 800F52CC 8FBF0010 */ lw $ra, 0x10($sp)
/* 08E780 800F52D0 03E00008 */ jr $ra
/* 08E784 800F52D4 27BD0018 */ addiu $sp, $sp, 0x18
/* 08E788 800F52D8 00000000 */ nop
/* 08E78C 800F52DC 00000000 */ nop

View File

@ -1,15 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel GotoMap
/* 0EEDB0 802CA400 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0EEDB4 802CA404 AFBF0010 */ sw $ra, 0x10($sp)
/* 0EEDB8 802CA408 0C0B28C1 */ jal goto_map
/* 0EEDBC 802CA40C 0000282D */ daddu $a1, $zero, $zero
/* 0EEDC0 802CA410 8FBF0010 */ lw $ra, 0x10($sp)
/* 0EEDC4 802CA414 24020001 */ addiu $v0, $zero, 1
/* 0EEDC8 802CA418 03E00008 */ jr $ra
/* 0EEDCC 802CA41C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,15 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel GotoMapByID
/* 0EEDF0 802CA440 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0EEDF4 802CA444 AFBF0010 */ sw $ra, 0x10($sp)
/* 0EEDF8 802CA448 0C0B28C1 */ jal goto_map
/* 0EEDFC 802CA44C 24050002 */ addiu $a1, $zero, 2
/* 0EEE00 802CA450 8FBF0010 */ lw $ra, 0x10($sp)
/* 0EEE04 802CA454 24020001 */ addiu $v0, $zero, 1
/* 0EEE08 802CA458 03E00008 */ jr $ra
/* 0EEE0C 802CA45C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,15 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "include/macro.inc"
glabel GotoMapSpecial
/* 0EEDD0 802CA420 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0EEDD4 802CA424 AFBF0010 */ sw $ra, 0x10($sp)
/* 0EEDD8 802CA428 0C0B28C1 */ jal goto_map
/* 0EEDDC 802CA42C 24050001 */ addiu $a1, $zero, 1
/* 0EEDE0 802CA430 8FBF0010 */ lw $ra, 0x10($sp)
/* 0EEDE4 802CA434 24020001 */ addiu $v0, $zero, 1
/* 0EEDE8 802CA438 03E00008 */ jr $ra
/* 0EEDEC 802CA43C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -189,8 +189,118 @@ typedef struct {
} ui_status; // size = 0x70
typedef struct {
/* 0x00 */ char unk_00[0xC];
/* 0x0C */ s32* ptrReadPos;
} ScriptContext;
/* 0x00 */ char unk_00[0x4];
/* 0x04 */ s16 height;
/* 0x06 */ s16 radius;
/* 0x08 */ void* otherAI; //?
/* 0x0C */ s32* interactScript;
/* 0x10 */ s32* aiScript;
/* 0x14 */ s32* hitScript;
/* 0x18 */ s32* auxScript;
/* 0x1C */ s32* defeatScript;
/* 0x20 */ s32 flags;
/* 0x24 */ char unk_24[0x4];
/* 0x28 */ s16 level;
/* 0x2A */ s16 unkFlags;
} StaticNpcSettings; // size = 0x2C
typedef enum {
Hammer=4,
Jump=2,
Normal=1,
Partner=6,
Spin=3,
} eEncounterTrigger;
typedef struct {
/* 0x00 */ s32 flags;
/* 0x04 */ s8 encounterIndex;
/* 0x05 */ s8 encountered; // eEncounterTrigger
/* 0x06 */ s8 scriptGroup; /* scripts launched for this npc controller will be assigned this group */
/* 0x07 */ s8 unk_07;
/* 0x08 */ s16 npcID;
/* 0x0A */ s16 spawnPos[3];
/* 0x10 */ s16 unk_10[3];
/* 0x16 */ char unk_16[0x2];
/* 0x18 */ struct StaticNpcSettings* npcSettings;
/* 0x1C */ s32* initBytecode;
/* 0x20 */ s32* interactBytecode;
/* 0x24 */ s32* aiBytecode;
/* 0x28 */ s32* hitBytecode;
/* 0x2C */ s32* auxBytecode;
/* 0x30 */ s32* defeatBytecode;
/* 0x34 */ struct script_context* initScript;
/* 0x38 */ struct script_context* interactScript;
/* 0x3C */ struct script_context* aiScript;
/* 0x40 */ struct script_context* hitScript;
/* 0x44 */ struct script_context* auxScript;
/* 0x48 */ struct script_context* defeatScript;
/* 0x4C */ s32 initScriptID;
/* 0x50 */ s32 interactScriptID;
/* 0x54 */ s32 aiScriptID;
/* 0x58 */ s32 hitScriptID;
/* 0x5C */ s32 auxScriptID;
/* 0x60 */ s32 defeatScriptID;
/* 0x64 */ void* unk_64;
/* 0x68 */ char unk_68[0x4];
/* 0x6C */ s32 varTable[16];
/* 0xAC */ s8 unk_AC;
/* 0xAD */ char unk_AD[0x3];
/* 0xB0 */ s32* unk_B0; /* might be flags of some sort */
/* 0xB4 */ s8 unk_B4;
/* 0xB5 */ s8 unk_B5;
/* 0xB6 */ char unk_B6[0x2];
/* 0xB8 */ s32 unkSettings24;
/* 0xBC */ s32 unk_BC;
/* 0xC0 */ s32 unk_C0;
/* 0xC4 */ s32 unk_C4;
/* 0xC8 */ char unk_C8[0x4];
/* 0xCC */ s32* animList;
/* 0xD0 */ s32* territoryData;
/* 0xD4 */ s32* dropTables;
/* 0xD8 */ u32 tattleString;
/* 0xDC */ s32 unk_DC;
/* 0xE0 */ s16 unk_E0;
/* 0xE2 */ char unk_E2[0xE];
} enemy; // size = 0xF0
typedef struct {
/* 0x000 */ s8 state;
/* 0x001 */ s8 currentArgc;
/* 0x002 */ s8 currentOpcode;
/* 0x003 */ s8 priority;
/* 0x004 */ s8 groupFlags;
/* 0x005 */ s8 blocked; /* 1 = blocking */
/* 0x006 */ s8 loopDepth; /* how many nested loops we are in, >= 8 hangs forever */
/* 0x007 */ s8 switchDepth; /* how many nested switches we are in, max = 8 */
/* 0x008 */ s32* ptrNextLine;
/* 0x00C */ s32* ptrReadPos;
/* 0x010 */ s8 labelIndices[16];
/* 0x020 */ s32* labelPositions[16];
/* 0x060 */ s32 deleted; /* set to zero in KillScript when malloc'd */
/* 0x064 */ struct script_context* blockingParent; /* parent? */
/* 0x068 */ struct script_context* childScript;
/* 0x06C */ struct script_context* parentScript; /* brother? */
/* 0x070 */ s32 functionTemp[4];
/* 0x080 */ void* callFunction;
/* 0x084 */ u32 varTable[16];
/* 0x0C4 */ s32 varFlags[3];
/* 0x0D0 */ s32 loopStartTable[8];
/* 0x0F0 */ s32 loopCounterTable[8];
/* 0x110 */ s8 switchBlockState[8];
/* 0x118 */ s32 switchBlockValue[8];
/* 0x138 */ void* buffer;
/* 0x13C */ void* array;
/* 0x140 */ void* flagArray;
/* 0x144 */ s32 uniqueID;
/* 0x148 */ enemy* ownerActorID; /* controller*, battle ID, trigger* */
/* 0x14C */ u32 ownerID; /* can be an npcID, a triggerID, a trigger ptr */
/* 0x150 */ f32 timeScale;
/* 0x154 */ f32 frameCounter;
/* 0x158 */ s32 unk_158;
/* 0x15C */ s32* ptrFirstLine;
/* 0x160 */ s32* ptrSavedPosition;
/* 0x164 */ s32* ptrCurrentLine;
} script_context; // size = 0x168;
#endif

View File

@ -6,8 +6,8 @@
void osCleanupThread(void);
s32 get_variable(ScriptContext* script, s32 pos);
f32 get_float_variable(ScriptContext* script, s32 pos);
s32 get_variable(script_context* script, s32 pos);
f32 get_float_variable(script_context* script, s32 pos);
f32 sin_deg(f32 x);
f32 cos_deg(f32 x);

View File

@ -2,7 +2,15 @@
INCLUDE_ASM(code_1f580_len_1940, SetEncounterStatusFlags);
INCLUDE_ASM(code_1f580_len_1940, LoadDemoBattle);
s32 LoadDemoBattle(script_context* script) {
load_demo_battle(get_variable(script, *script->ptrReadPos));
return 2;
}
// ???
s32 func_80044290(script_context* script) {
return 2;
}
INCLUDE_ASM(code_1f580_len_1940, MakeNpcs);
@ -12,15 +20,24 @@ INCLUDE_ASM(code_1f580_len_1940, RemoveEncounter);
INCLUDE_ASM(code_1f580_len_1940, GetBattleOutcome);
INCLUDE_ASM(code_1f580_len_1940, GetOwnerEncountered);
s32 GetOwnerEncountered(script_context* script) {
set_variable(script, *script->ptrReadPos, script->ownerActorID->encountered);
return 2;
}
INCLUDE_ASM(code_1f580_len_1940, DoNpcDefeat);
INCLUDE_ASM(code_1f580_len_1940, start_battle);
INCLUDE_ASM(code_1f580_len_1940, StartBattle);
s32 StartBattle(script_context* script) {
start_battle(script, -1);
return 1;
}
INCLUDE_ASM(code_1f580_len_1940, StartBattleWith);
s32 StartBattleWith(script_context* script) {
start_battle(script, get_variable(script, *script->ptrReadPos));
return 1;
}
INCLUDE_ASM(code_1f580_len_1940, StartBossBattle);
@ -58,11 +75,17 @@ INCLUDE_ASM(code_1f580_len_1940, GetNpcVar);
INCLUDE_ASM(code_1f580_len_1940, SetSelfRotation);
INCLUDE_ASM(code_1f580_len_1940, SetSelfEnemyFlags);
s32 SetSelfEnemyFlags(script_context* script) {
script->ownerActorID->flags = *script->ptrReadPos;
return 2;
}
INCLUDE_ASM(code_1f580_len_1940, SetSelfEnemyFlagBits);
INCLUDE_ASM(code_1f580_len_1940, GetSelfNpcID);
s32 GetSelfNpcID(script_context* script) {
set_variable(script, *script->ptrReadPos, script->ownerActorID->npcID);
return 2;
}
INCLUDE_ASM(code_1f580_len_1940, ClearDefeatedEnemies);

View File

@ -283,7 +283,7 @@ void func_800E96C8(void) {
}
}
s32 ShowCoinCounter(ScriptContext* script) {
s32 ShowCoinCounter(script_context* script) {
if (get_variable(script, *script->ptrReadPos)) {
show_coin_counter();
} else {

View File

@ -16,5 +16,6 @@ INCLUDE_ASM(code_8a860_len_3f30, func_800F4FC4);
INCLUDE_ASM(code_8a860_len_3f30, func_800F513C);
INCLUDE_ASM(code_8a860_len_3f30, func_800F52BC);
void func_800F52BC(void) {
func_800F1A10();
}

View File

@ -198,7 +198,7 @@ INCLUDE_ASM(code_e92d0_len_5da0, si_execute_next_command);
INCLUDE_ASM(code_e92d0_len_5da0, si_handle_end);
s32 INCLUDE_ASM(code_e92d0_len_5da0, get_variable, ScriptContext* script, s32 pos);
s32 INCLUDE_ASM(code_e92d0_len_5da0, get_variable, script_context* script, s32 pos);
INCLUDE_ASM(code_e92d0_len_5da0, get_variable_index);
@ -206,7 +206,7 @@ INCLUDE_ASM(code_e92d0_len_5da0, get_variable_index_alt);
INCLUDE_ASM(code_e92d0_len_5da0, set_variable);
f32 INCLUDE_ASM(code_e92d0_len_5da0, get_float_variable, ScriptContext* script, s32 pos);
f32 INCLUDE_ASM(code_e92d0_len_5da0, get_float_variable, script_context* script, s32 pos);
INCLUDE_ASM(code_e92d0_len_5da0, set_float_variable);
@ -274,11 +274,20 @@ INCLUDE_ASM(code_e92d0_len_5da0, func_802CA1B8);
INCLUDE_ASM(code_e92d0_len_5da0, goto_map);
INCLUDE_ASM(code_e92d0_len_5da0, GotoMap);
s32 GotoMap(script_context* script) {
goto_map(script, 0);
return 1;
}
INCLUDE_ASM(code_e92d0_len_5da0, GotoMapSpecial);
s32 GotoMapSpecial(script_context* script) {
goto_map(script, 1);
return 1;
}
INCLUDE_ASM(code_e92d0_len_5da0, GotoMapByID);
s32 GotoMapByID(script_context* script) {
goto_map(script, 2);
return 1;
}
INCLUDE_ASM(code_e92d0_len_5da0, GetEntryID);

View File

@ -2,7 +2,7 @@
INCLUDE_ASM(code_fe0b0_len_5a0, SetSpriteShading);
s32 EnableSpriteShading(ScriptContext* script) {
s32 EnableSpriteShading(script_context* script) {
if (get_variable(script, *script->ptrReadPos) != 0) {
*D_80151328 |= 1;
} else {
@ -11,27 +11,27 @@ s32 EnableSpriteShading(ScriptContext* script) {
return 2;
}
s32 getDemoState(ScriptContext* script) {
s32 getDemoState(script_context* script) {
set_variable(script, *script->ptrReadPos, (*gGameStatusPtr)->demoState);
return 2;
}
s32 DemoPressButton(ScriptContext* script) {
s32 DemoPressButton(script_context* script) {
(*gGameStatusPtr)->demoButtonInput |= get_variable(script, *script->ptrReadPos);
return 2;
}
s32 DemoReleaseButton(ScriptContext* script) {
s32 DemoReleaseButton(script_context* script) {
(*gGameStatusPtr)->demoButtonInput &= ~get_variable(script, *script->ptrReadPos);
return 2;
}
s32 DemoSetButtons(ScriptContext* script) {
s32 DemoSetButtons(script_context* script) {
(*gGameStatusPtr)->demoButtonInput = get_variable(script, *script->ptrReadPos);
return 2;
}
s32 DemoJoystickRadial(ScriptContext* script) {
s32 DemoJoystickRadial(script_context* script) {
f32 a;
f32 b;
s32* thisPos = script->ptrReadPos;
@ -45,7 +45,7 @@ s32 DemoJoystickRadial(ScriptContext* script) {
return 2;
}
s32 DemoJoystickXY(ScriptContext* script) {
s32 DemoJoystickXY(script_context* script) {
f32 a;
f32 b;
s32* thisPos = script->ptrReadPos;