mirror of
https://github.com/pret/pmd-red.git
synced 2026-04-24 23:17:03 -05:00
Refactor ground_script, part 1
This commit is contained in:
parent
94f0f6c711
commit
1cb9938d83
|
|
@ -1,86 +1,134 @@
|
|||
#ifndef GUARD_GROUND_SCRIPT_H
|
||||
#define GUARD_GROUND_SCRIPT_H
|
||||
|
||||
typedef struct GroundScript_ExecutePP_3
|
||||
{
|
||||
// size: 0xC
|
||||
u8 *scriptPointer;
|
||||
s16 scriptType;
|
||||
s16 unk6;
|
||||
u8 unk8;
|
||||
} GroundScript_ExecutePP_3;
|
||||
#include "structs/str_position.h"
|
||||
|
||||
typedef struct __attribute__((packed)) GroundScript_ExecutePP_1_sub
|
||||
typedef struct ScriptCommand {
|
||||
// size: 0x10
|
||||
/* 0x0 */ u8 op;
|
||||
/* 0x1 */ u8 argByte;
|
||||
/* 0x2 */ s16 argShort;
|
||||
/* 0x4 */ s32 arg1;
|
||||
/* 0x8 */ s32 arg2;
|
||||
/* 0xC */ u8* argPtr;
|
||||
} ScriptCommand;
|
||||
|
||||
typedef struct ScriptInfoSmall
|
||||
{
|
||||
// size: 0xC (3 padding)
|
||||
/* 0x0 */ ScriptCommand *ptr;
|
||||
/* 0x4 */ s16 state;
|
||||
/* 0x6 */ s16 group;
|
||||
/* 0x8 */ u8 sector;
|
||||
} ScriptInfoSmall;
|
||||
|
||||
typedef struct ScriptInfo
|
||||
{
|
||||
// size: 0xC (1 padding)
|
||||
/* 0x0 */ ScriptCommand *ptr;
|
||||
/* 0x4 */ ScriptCommand *ptr2;
|
||||
/* 0x8 */ s16 group;
|
||||
/* 0xA */ u8 sector;
|
||||
} ScriptInfo;
|
||||
|
||||
typedef union ScriptUnion832 {
|
||||
u32 raw;
|
||||
u8 arr[4];
|
||||
} ScriptUnion832;
|
||||
|
||||
typedef union ScriptUnion1632 {
|
||||
u32 raw;
|
||||
u16 arr[2];
|
||||
} ScriptUnion1632;
|
||||
|
||||
typedef struct ScriptData
|
||||
{
|
||||
// size: 0x60
|
||||
/* 0x0 */ s16 scriptType;
|
||||
/* 0x2 */ s16 unk2;
|
||||
/* 0x4 */ u8 *scriptPointer1;
|
||||
/* 0x8 */ u8 *scriptPointer2;
|
||||
/* 0xC */ u16 unkC;
|
||||
/* 0xE */ u8 unkE;
|
||||
/* 0xF */ u8 fillF;
|
||||
/* 0x10 */ u32 unk10;
|
||||
/* 0x14 */ u8 *unk14;
|
||||
/* 0x18 */ u8 fill18[0x22 - 0x18];
|
||||
/* 0x00 */ s16 state;
|
||||
/* 0x02 */ s16 savedState;
|
||||
/* 0x04 */ ScriptInfo script;
|
||||
// padding
|
||||
/* 0x10 */ ScriptInfo savedScript;
|
||||
// padding
|
||||
/* 0x1C */ ScriptCommand *curPtr;
|
||||
/* 0x20 */ u8 curScriptOp;
|
||||
// padding
|
||||
/* 0x22 */ u16 unk22;
|
||||
/* 0x24 */ u16 unk24;
|
||||
/* 0x26 */ u32 unk26;
|
||||
u8 fill50[0x60 - 0x2A];
|
||||
} GroundScript_ExecutePP_1_sub;
|
||||
/* 0x26 */ s8 unk26;
|
||||
// padding
|
||||
/* 0x28 */ s16 branchDiscriminant;
|
||||
/* 0x2A */ s16 unk2A;
|
||||
/* 0x2C */ s16 unk2C;
|
||||
// padding
|
||||
/* 0x30 */ s32 unk30;
|
||||
/* 0x34 */ Position32 pos1;
|
||||
/* 0x3C */ Position32 pos2;
|
||||
/* 0x44 */ u8 unk44[4];
|
||||
/* 0x48 */ s32 unk48;
|
||||
/* 0x4C */ u8 unk4C;
|
||||
/* 0x4D */ u8 unk4D;
|
||||
// padding
|
||||
// ultimately accessed as ldrb, doesn't work as array of u32-sized structs, needs union
|
||||
/* 0x50 */ ScriptUnion832 unk50[4];
|
||||
} ScriptData;
|
||||
|
||||
// Needed for sub_809D568, possibly could be merged with GroundScript_ExecutePP_1_sub?
|
||||
typedef struct GroundScript_ExecutePP_1_sub_not_packed
|
||||
typedef struct CallbackData
|
||||
{
|
||||
// size: 0x60
|
||||
/* 0x0 */ s16 scriptType;
|
||||
/* 0x2 */ s16 unk2;
|
||||
/* 0x4 */ u8 *scriptPointer1;
|
||||
/* 0x8 */ u8 *scriptPointer2;
|
||||
/* 0xC */ u16 unkC;
|
||||
/* 0xE */ u8 unkE;
|
||||
/* 0xF */ u8 fillF;
|
||||
/* 0x10 */ u32 unk10;
|
||||
/* 0x14 */ u8 *unk14;
|
||||
/* 0x18 */ u8 fill18[2];
|
||||
/* 0x1C */ u32 unk1C;
|
||||
/* 0x20 */ u8 unk20;
|
||||
/* 0x22 */ u16 unk22;
|
||||
/* 0x24 */ u16 unk24;
|
||||
/* 0x26 */ u8 unk26;
|
||||
/* 0x28 */ u16 unk28;
|
||||
/* 0x2A */ u16 unk2A;
|
||||
/* 0x2C */ u16 unk2C;
|
||||
/* 0x2E */ u16 unk2E;
|
||||
/* 0x30 */ u32 unk30;
|
||||
u8 fill34[0x1C];
|
||||
u32 unk5C[4];
|
||||
} GroundScript_ExecutePP_1_sub_not_packed;
|
||||
// size: 0x54
|
||||
/* 0x00 */ u16 maybeId;
|
||||
// padding
|
||||
// (almost?) all callbacks take the parentObject as first parameter
|
||||
/* 0x04 */ s16 (*func04)(void*); // id related
|
||||
/* 0x08 */ u32 (*func08)();
|
||||
/* 0x0C */ u32 (*func0C)();
|
||||
/* 0x10 */ u32 (*func10)();
|
||||
/* 0x14 */ u32 (*func14)();
|
||||
/* 0x18 */ u32 (*func18)();
|
||||
/* 0x1C */ u32 (*func1C)();
|
||||
/* 0x20 */ u32 (*func20)();
|
||||
/* 0x24 */ u32 (*func24)();
|
||||
/* 0x28 */ u32 (*func28)();
|
||||
/* 0x2C */ u32 (*func2C)();
|
||||
/* 0x30 */ u32 (*func30)();
|
||||
/* 0x34 */ u32 (*func34)();
|
||||
/* 0x38 */ u32 (*func38)();
|
||||
/* 0x3C */ u32 (*func3C)();
|
||||
/* 0x40 */ u32 (*func40)();
|
||||
/* 0x44 */ u32 (*func44)();
|
||||
/* 0x48 */ u32 (*func48)();
|
||||
/* 0x4C */ u32 (*func4C)();
|
||||
/* 0x50 */ u32 (*func50)();
|
||||
} CallbackData;
|
||||
|
||||
typedef void (*Callback)(u32, void *);
|
||||
typedef struct GroundScript_ExecutePP_1_sub2
|
||||
typedef struct Action
|
||||
{
|
||||
Callback callbacks[10]; // IDK the size..
|
||||
} GroundScript_ExecutePP_1_sub2;
|
||||
// size: 0xE4
|
||||
/* 0x00 */ struct CallbackData *callbacks;
|
||||
/* 0x04 */ void *parentObject; // struct GroundObject *
|
||||
/* 0x08 */ s16 unk8[2]; // id?
|
||||
/* 0x0C */ ScriptUnion1632 unkC;
|
||||
/* 0x10 */ u16 group;
|
||||
/* 0x12 */ u8 sector;
|
||||
// padding
|
||||
/* 0x14 */ ScriptCommand *predefinedScripts[4];
|
||||
/* 0x24 */ ScriptData scriptData;
|
||||
/* 0x84 */ ScriptData scriptData2;
|
||||
} Action;
|
||||
|
||||
// size: 0x110
|
||||
typedef struct GroundScript_ExecutePP_1
|
||||
// Only used when accessing gGroundMapAction (3001B6C), basically everything else just uses Action
|
||||
// probably worth moving to ground_map.h together with the main GroundMap struct
|
||||
// oh well, TODO later I guess
|
||||
typedef struct GroundMapAction
|
||||
{
|
||||
GroundScript_ExecutePP_1_sub2 *unk0;
|
||||
u32 unk4;
|
||||
u16 unk8;
|
||||
u32 unkC;
|
||||
u16 unk10;
|
||||
u8 unk12;
|
||||
u8 *unk14[4];
|
||||
GroundScript_ExecutePP_1_sub unk24;
|
||||
GroundScript_ExecutePP_1_sub unk84;
|
||||
u16 unkE4;
|
||||
u8 fillE8[0x110 - 0xE8];
|
||||
} GroundScript_ExecutePP_1;
|
||||
// size: 0x110
|
||||
/* 0x00 */ Action action;
|
||||
/* 0xE4 */ u16 groundMapId;
|
||||
/* .... */ u8 fillE8[0x110 - 0xE6];
|
||||
} GroundMapAction;
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
bool8 GroundScript_ExecutePP(GroundScript_ExecutePP_1 *, s32 *, GroundScript_ExecutePP_3 *, const DebugLocation *unused);
|
||||
bool8 GroundScript_ExecutePP(Action *, s32 *, ScriptInfoSmall *, const DebugLocation *unused);
|
||||
|
||||
#endif // GUARD_GROUND_SCRIPT_H
|
||||
|
|
|
|||
|
|
@ -442,44 +442,44 @@ s32 sub_809D52C(void *a0)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void sub_809D568(GroundScript_ExecutePP_1_sub_not_packed *a0)
|
||||
void sub_809D568(ScriptData *a0)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
a0->scriptType = -1;
|
||||
a0->unk2 = 0;
|
||||
a0->scriptPointer2 = 0;
|
||||
a0->scriptPointer1 = 0;
|
||||
a0->unk14 = 0;
|
||||
a0->unk10 = 0;
|
||||
a0->unk20 = 0;
|
||||
a0->unk1C = 0;
|
||||
a0->state = -1;
|
||||
a0->savedState = 0;
|
||||
a0->script.ptr2 = 0;
|
||||
a0->script.ptr = 0;
|
||||
a0->savedScript.ptr2 = 0;
|
||||
a0->savedScript.ptr = 0;
|
||||
a0->curScriptOp = 0;
|
||||
a0->curPtr = 0;
|
||||
a0->unk22 = -1;
|
||||
a0->unk24 = 0;
|
||||
a0->unk26 = 0xFF;
|
||||
a0->unk28 = 0;
|
||||
a0->branchDiscriminant = 0;
|
||||
a0->unk2A = 0;
|
||||
a0->unk2C = 0;
|
||||
a0->unk30 = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
a0->unk5C[i] = 0;
|
||||
a0->unk50[i].raw = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_809D5B8(GroundScript_ExecutePP_1 *a0)
|
||||
void sub_809D5B8(Action *a0)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
a0->unk0 = 0;
|
||||
a0->unk4 = 0;
|
||||
a0->unk10 = -1;
|
||||
a0->unk12 = 0xFF;
|
||||
a0->callbacks = NULL;
|
||||
a0->parentObject = NULL;
|
||||
a0->group = -1;
|
||||
a0->sector = 0xFF;
|
||||
sub_809D520(&a0->unkC);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
a0->unk14[i] = 0;
|
||||
a0->predefinedScripts[i] = NULL;
|
||||
}
|
||||
|
||||
sub_809D568((void *) &a0->unk24); // Casting to void* because packed/not packed
|
||||
sub_809D568((void *) &a0->unk84); // Casting to void* because packed/not packed
|
||||
sub_809D568(&a0->scriptData);
|
||||
sub_809D568(&a0->scriptData2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "ground_script.h"
|
||||
#include "memory.h"
|
||||
|
||||
IWRAM_DATA GroundScript_ExecutePP_1 *gUnknown_3001B6C = {0};
|
||||
IWRAM_DATA GroundMapAction *gUnknown_3001B6C = {0};
|
||||
IWRAM_DATA unkStruct_3001B70 *gUnknown_3001B70 = {0};
|
||||
|
||||
extern const u8 gUnknown_811736C[];
|
||||
|
|
@ -15,14 +15,14 @@ extern const DebugLocation gUnknown_8117538[];
|
|||
extern void sub_809D600(void *, const u8 *, u32, u32, u32);
|
||||
extern void sub_809D648(void *);
|
||||
extern void sub_80A2D00(unkStruct_3001B70 *);
|
||||
extern void sub_809D754(GroundScript_ExecutePP_1 *, const DebugLocation *);
|
||||
extern void sub_809D754(GroundMapAction *, const DebugLocation *);
|
||||
extern void sub_80A2D68(unkStruct_3001B70 *);
|
||||
extern void sub_80A2D88(unkStruct_3001B70 *);
|
||||
|
||||
void sub_80A4A7C(void)
|
||||
{
|
||||
gUnknown_3001B6C = MemoryAlloc(sizeof(GroundScript_ExecutePP_1), 6);
|
||||
gUnknown_3001B6C->unkE4 = -1;
|
||||
gUnknown_3001B6C = MemoryAlloc(sizeof(GroundMapAction), 6);
|
||||
gUnknown_3001B6C->groundMapId = -1;
|
||||
sub_809D600(gUnknown_3001B6C, gUnknown_811736C, 0, -1, -1);
|
||||
sub_80A5E8C(0);
|
||||
GroundMap_Reset();
|
||||
|
|
@ -66,4 +66,4 @@ void sub_80A4B54(void)
|
|||
sub_80A2D88(gUnknown_3001B70);
|
||||
|
||||
nullsub_122();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "ground_map_1.h"
|
||||
#include "ground_script.h"
|
||||
|
||||
extern GroundScript_ExecutePP_1 *gUnknown_3001B6C;
|
||||
extern GroundMapAction *gUnknown_3001B6C;
|
||||
|
||||
extern const u8 gUnknown_8117594[];
|
||||
extern const u8 gUnknown_81175EC[];
|
||||
|
|
@ -14,20 +14,20 @@ extern const u8 gUnknown_8117650[];
|
|||
extern const DebugLocation gUnknown_8117698;
|
||||
extern const unkStruct_811BAF4 gUnknown_811BAF4[10];
|
||||
|
||||
extern void GroundMap_GetStationScript(GroundScript_ExecutePP_3 *, s16, u32, u32);
|
||||
extern void GroundMap_GetStationScript(ScriptInfoSmall *, s16, u32, u32);
|
||||
|
||||
extern u8 sub_809D678(void *);
|
||||
extern void sub_809D710(u8 *, GroundScript_ExecutePP_3 *, s32);
|
||||
extern void sub_809D710(u8 *, ScriptInfoSmall *, s32);
|
||||
extern bool8 sub_809D968(void *, s32);
|
||||
|
||||
static void sub_80A4BE8(GroundScript_ExecutePP_3 *script, s16 r1)
|
||||
static void sub_80A4BE8(ScriptInfoSmall *script, s16 r1)
|
||||
{
|
||||
GroundMap_GetStationScript(script, r1, 0, 0);
|
||||
}
|
||||
|
||||
void GroundMap_ExecuteEvent(s16 scriptIndex, u32 param_2)
|
||||
{
|
||||
GroundScript_ExecutePP_3 script;
|
||||
ScriptInfoSmall script;
|
||||
s32 index_s32;
|
||||
u8 iVar2;
|
||||
|
||||
|
|
@ -37,14 +37,14 @@ void GroundMap_ExecuteEvent(s16 scriptIndex, u32 param_2)
|
|||
Log(0,gUnknown_8117594, index_s32, iVar2); // "GroundMap ExecuteEvent %3d %d
|
||||
sub_809D710(NULL, &script, index_s32);
|
||||
if (iVar2 != 0)
|
||||
script.scriptType = 5;
|
||||
script.state = 5;
|
||||
|
||||
GroundScript_ExecutePP(gUnknown_3001B6C, 0, &script, &gUnknown_81175E0);
|
||||
GroundScript_ExecutePP(&gUnknown_3001B6C->action, 0, &script, &gUnknown_81175E0);
|
||||
}
|
||||
|
||||
void GroundMap_ExecuteStation(s16 param_1, s16 param_2, s8 param_3, u32 param_4)
|
||||
{
|
||||
GroundScript_ExecutePP_3 script;
|
||||
ScriptInfoSmall script;
|
||||
s32 iVar1;
|
||||
s32 iVar2;
|
||||
s32 iVar3;
|
||||
|
|
@ -58,35 +58,35 @@ void GroundMap_ExecuteStation(s16 param_1, s16 param_2, s8 param_3, u32 param_4)
|
|||
Log(0, gUnknown_81175EC, iVar1, iVar2, iVar3, iVar4); // GroundMap ExecuteStation %3d %3d %3d %d
|
||||
GroundMap_GetStationScript(&script, iVar1, iVar2, iVar3);
|
||||
if (iVar4 != 0)
|
||||
script.scriptType = 5;
|
||||
script.state = 5;
|
||||
|
||||
GroundScript_ExecutePP(gUnknown_3001B6C, 0, &script, &gUnknown_8117644);
|
||||
GroundScript_ExecutePP(&gUnknown_3001B6C->action, 0, &script, &gUnknown_8117644);
|
||||
}
|
||||
|
||||
void GroundMap_ExecuteEnter(s16 param_1)
|
||||
{
|
||||
GroundScript_ExecutePP_3 script;
|
||||
ScriptInfoSmall script;
|
||||
s32 iVar1;
|
||||
|
||||
iVar1 = param_1;
|
||||
|
||||
Log(0, gUnknown_8117650, iVar1); // GroundMap ExecuteEnter %3d
|
||||
sub_80A4BE8(&script, iVar1);
|
||||
script.scriptType = 2;
|
||||
script.unk6 = 0;
|
||||
script.unk8 = 0;
|
||||
GroundScript_ExecutePP(gUnknown_3001B6C, 0, &script, &gUnknown_8117698);
|
||||
script.state = 2;
|
||||
script.group = 0;
|
||||
script.sector = 0;
|
||||
GroundScript_ExecutePP(&gUnknown_3001B6C->action, 0, &script, &gUnknown_8117698);
|
||||
}
|
||||
|
||||
UNUSED static u8 sub_80A4D14(void)
|
||||
{
|
||||
return sub_809D678(gUnknown_3001B6C);
|
||||
return sub_809D678(&gUnknown_3001B6C->action);
|
||||
}
|
||||
|
||||
bool8 sub_80A4D2C(s16 param_1)
|
||||
{
|
||||
s32 iVar1 = param_1;
|
||||
return sub_809D968(gUnknown_3001B6C, iVar1);
|
||||
return sub_809D968(&gUnknown_3001B6C->action, iVar1);
|
||||
}
|
||||
|
||||
bool8 sub_80A4D48(s16 index)
|
||||
|
|
@ -95,4 +95,4 @@ bool8 sub_80A4D48(s16 index)
|
|||
if (gUnknown_811BAF4[index].unk0 == 5) return FALSE;
|
||||
if (gUnknown_811BAF4[index].unk0 != 8) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,155 +22,155 @@ extern u8 sub_80AC378(void);
|
|||
extern u8 sub_80AD290(void);
|
||||
extern u8 sub_80A8B74(void);
|
||||
extern u8 sub_809A750(void);
|
||||
extern u8 *sub_80A2460(GroundScript_ExecutePP_1 *param_1, u32);
|
||||
extern ScriptCommand *sub_80A2460(Action *param_1, u32);
|
||||
void FatalError(u32 *, const char *, ...) __attribute__((noreturn));
|
||||
|
||||
typedef struct FunctionScript
|
||||
{
|
||||
u32 unk0;
|
||||
u8 *funcName;
|
||||
u8 *script;
|
||||
ScriptCommand *script;
|
||||
} FunctionScript;
|
||||
|
||||
extern FunctionScript gFunctionScriptTable[];
|
||||
|
||||
void sub_809D6D8(GroundScript_ExecutePP_1 *param_1, s16 index, u8 *param_3)
|
||||
void sub_809D6D8(Action *param_1, s16 index, ScriptCommand *param_3)
|
||||
{
|
||||
param_1->unk14[index] = param_3;
|
||||
param_1->predefinedScripts[index] = param_3;
|
||||
}
|
||||
|
||||
bool8 sub_809D6E4(GroundScript_ExecutePP_1 *param_1, GroundScript_ExecutePP_3 *script, s16 _index)
|
||||
bool8 sub_809D6E4(Action *param_1, ScriptInfoSmall *script, s16 _index)
|
||||
{
|
||||
u8 *scriptPtr;
|
||||
ScriptCommand *scriptPtr;
|
||||
s32 index = _index;
|
||||
|
||||
scriptPtr = param_1->unk14[index];
|
||||
script->scriptPointer = scriptPtr;
|
||||
script->scriptType = index;
|
||||
script->unk6 = param_1->unk10;
|
||||
script->unk8 = param_1->unk12;
|
||||
scriptPtr = param_1->predefinedScripts[index];
|
||||
script->ptr = scriptPtr;
|
||||
script->state = index;
|
||||
script->group = param_1->group;
|
||||
script->sector = param_1->sector;
|
||||
return scriptPtr != NULL;
|
||||
}
|
||||
|
||||
void sub_809D710(GroundScript_ExecutePP_1 *param_1, GroundScript_ExecutePP_3 *script, s16 index)
|
||||
void sub_809D710(Action *param_1, ScriptInfoSmall *script, s16 index)
|
||||
{
|
||||
s32 index_s32 = index;
|
||||
script->scriptPointer = gFunctionScriptTable[index_s32].script;
|
||||
script->scriptType = 2;
|
||||
script->ptr = gFunctionScriptTable[index_s32].script;
|
||||
script->state = 2;
|
||||
if (param_1 != NULL) {
|
||||
script->unk6 = param_1->unk10;
|
||||
script->unk8 = param_1->unk12;
|
||||
script->group = param_1->group;
|
||||
script->sector = param_1->sector;
|
||||
}
|
||||
else {
|
||||
script->unk6 = -1;
|
||||
script->unk8 = -1;
|
||||
script->group = -1;
|
||||
script->sector = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_809D754(GroundScript_ExecutePP_1 *param_1, DebugLocation *unused)
|
||||
bool8 sub_809D754(Action *param_1, DebugLocation *unused)
|
||||
{
|
||||
sub_809D568(¶m_1->unk24);
|
||||
sub_809D568(¶m_1->unk84);
|
||||
sub_809D568(¶m_1->scriptData);
|
||||
sub_809D568(¶m_1->scriptData2);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_809D770(GroundScript_ExecutePP_1 *param_1, DebugLocation *unused)
|
||||
bool8 sub_809D770(Action *param_1, DebugLocation *unused)
|
||||
{
|
||||
sub_809D568(¶m_1->unk24);
|
||||
sub_809D568(¶m_1->unk84);
|
||||
param_1->unk24.unk2 = 4;
|
||||
sub_809D568(¶m_1->scriptData);
|
||||
sub_809D568(¶m_1->scriptData2);
|
||||
param_1->scriptData.savedState = 4;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 GroundScript_ExecutePP(GroundScript_ExecutePP_1 *param_1, s32 *param_2, GroundScript_ExecutePP_3 *param_3, const DebugLocation *unused)
|
||||
bool8 GroundScript_ExecutePP(Action *action, s32 *param_2, ScriptInfoSmall *param_3, const DebugLocation *unused)
|
||||
{
|
||||
if ((param_3 == NULL) || (param_3->scriptPointer == NULL)) {
|
||||
if ((param_3 == NULL) || (param_3->ptr == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
switch(param_3->scriptType) {
|
||||
switch(param_3->state) {
|
||||
case 2:
|
||||
case 3:
|
||||
if (param_1->unk24.scriptType == 1) {
|
||||
param_1->unk84 = param_1->unk24;
|
||||
if (action->scriptData.state == 1) {
|
||||
action->scriptData2 = action->scriptData;
|
||||
break;
|
||||
}
|
||||
if (param_1->unk24.scriptType == 5) {
|
||||
sub_809D568(¶m_1->unk84);
|
||||
if (action->scriptData.state == 5) {
|
||||
sub_809D568(&action->scriptData2);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (param_1->unk24.scriptType != 2) {
|
||||
// "execute script type error B"
|
||||
if (action->scriptData.state != 2) {
|
||||
// "execute script type error B" at ../ground/ground_script.c:688
|
||||
FatalError(&gUnknown_8116538, gUnknown_8116544);
|
||||
}
|
||||
if (param_1->unk84.scriptType != -1) {
|
||||
// "execute script type error C"
|
||||
if (action->scriptData2.state != -1) {
|
||||
// "execute script type error C" at ../ground/ground_script.c:689
|
||||
FatalError(&gUnknown_8116560, gUnknown_811656C);
|
||||
}
|
||||
param_1->unk84 = param_1->unk24;
|
||||
action->scriptData2 = action->scriptData;
|
||||
break;
|
||||
case 0:
|
||||
if (param_1->unk24.scriptType != 1) goto _0809D84A;
|
||||
param_1->unk84 = param_1->unk24;
|
||||
if (action->scriptData.state != 1) goto _0809D84A;
|
||||
action->scriptData2 = action->scriptData;
|
||||
break;
|
||||
case 1:
|
||||
_0809D84A:
|
||||
sub_809D568(¶m_1->unk84);
|
||||
sub_809D568(&action->scriptData2);
|
||||
break;
|
||||
default:
|
||||
// "execute script type error %d"
|
||||
FatalError(&gUnknown_8116588, gUnknown_8116594, param_3->scriptType);
|
||||
// "execute script type error %d" at ../ground/ground_script.c:708
|
||||
FatalError(&gUnknown_8116588, gUnknown_8116594, param_3->state);
|
||||
}
|
||||
sub_809D568(¶m_1->unk24);
|
||||
sub_809D568(&action->scriptData);
|
||||
if (param_2 != NULL) {
|
||||
param_1->unkC = param_2[0];
|
||||
action->unkC.raw = param_2[0];
|
||||
}
|
||||
else {
|
||||
sub_809D520(¶m_1->unkC);
|
||||
sub_809D520(&action->unkC);
|
||||
}
|
||||
param_1->unk24.scriptType = param_3->scriptType;
|
||||
param_1->unk24.unk2 = 3;
|
||||
param_1->unk24.unkC = param_3->unk6;
|
||||
param_1->unk24.unkE = param_3->unk8;
|
||||
param_1->unk24.scriptPointer1 = param_3->scriptPointer;
|
||||
param_1->unk24.scriptPointer2 = param_3->scriptPointer;
|
||||
param_1->unk24.unk10 = 0;
|
||||
param_1->unk24.unk14 = NULL;
|
||||
action->scriptData.state = param_3->state;
|
||||
action->scriptData.savedState = 3;
|
||||
action->scriptData.script.group = param_3->group;
|
||||
action->scriptData.script.sector = param_3->sector;
|
||||
action->scriptData.script.ptr = param_3->ptr;
|
||||
action->scriptData.script.ptr2 = param_3->ptr;
|
||||
action->scriptData.savedScript.ptr = 0;
|
||||
action->scriptData.savedScript.ptr2 = NULL;
|
||||
|
||||
if (param_1->unk0->callbacks[5] != 0) {
|
||||
param_1->unk0->callbacks[5](param_1->unk4, ¶m_1->unk24.unk26);
|
||||
if (action->callbacks->func14 != 0) {
|
||||
action->callbacks->func14(action->parentObject, &action->scriptData.unk26);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_809D8C0(GroundScript_ExecutePP_1 *param_1, s32 *param_2, s16 index, DebugLocation *debug)
|
||||
bool8 sub_809D8C0(Action *param_1, s32 *param_2, s16 index, DebugLocation *debug)
|
||||
{
|
||||
GroundScript_ExecutePP_3 auStack28;
|
||||
ScriptInfoSmall auStack28;
|
||||
|
||||
sub_809D6E4(param_1,&auStack28,index);
|
||||
return GroundScript_ExecutePP(param_1, param_2, &auStack28, debug);
|
||||
}
|
||||
|
||||
u8 sub_809D8EC(GroundScript_ExecutePP_1 *param_1, s16 param_2)
|
||||
u8 sub_809D8EC(Action *param_1, s16 param_2)
|
||||
{
|
||||
s32 param_2_s32;
|
||||
|
||||
param_2_s32 = param_2;
|
||||
|
||||
if ((param_2 == 0) && (sub_809A750() == 0)) {
|
||||
param_1->unk24.scriptPointer1 = sub_80A2460(param_1, 0);
|
||||
param_1->scriptData.script.ptr = sub_80A2460(param_1, 0);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
param_1->unk24.unk22 = param_2_s32;
|
||||
param_1->unk24.unk2 = 2;
|
||||
param_1->scriptData.unk22 = param_2_s32;
|
||||
param_1->scriptData.savedState = 2;
|
||||
gUnknown_2039A36 = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool8 GroundScript_Cancel(GroundScript_ExecutePP_1 *r0)
|
||||
bool8 GroundScript_Cancel(Action *r0)
|
||||
{
|
||||
// NOTE: Will always return TRUE
|
||||
return sub_809D770(r0, &gUnknown_81165C8);
|
||||
|
|
@ -186,7 +186,7 @@ u8 sub_809D940(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool8 sub_809D968(GroundScript_ExecutePP_1 *param_1, s16 param_2)
|
||||
bool8 sub_809D968(Action *param_1, s16 param_2)
|
||||
{
|
||||
s16 sVar1;
|
||||
s16 sVar2;
|
||||
|
|
@ -195,14 +195,14 @@ bool8 sub_809D968(GroundScript_ExecutePP_1 *param_1, s16 param_2)
|
|||
s32 param_2_s16 = param_2;
|
||||
|
||||
ret = FALSE;
|
||||
sVar1 = param_1->unk24.unk22;
|
||||
sVar1 = param_1->scriptData.unk22;
|
||||
if ((sVar1 != -1) && (sVar1 == param_2_s16)) {
|
||||
param_1->unk24.unk22 = -1;
|
||||
param_1->scriptData.unk22 = -1;
|
||||
ret = TRUE;
|
||||
}
|
||||
sVar2 = param_1->unk84.unk22;
|
||||
sVar2 = param_1->scriptData2.unk22;
|
||||
if ((sVar2 != -1) && (sVar2 == param_2_s16)) {
|
||||
param_1->unk84.unk22 = -1;
|
||||
param_1->scriptData2.unk22 = -1;
|
||||
ret = TRUE;
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -224,7 +224,7 @@ void sub_809D9E0(s16 index, s32 r1)
|
|||
gUnknown_2039A36 = 1;
|
||||
}
|
||||
|
||||
bool8 sub_809DA08(GroundScript_ExecutePP_1 *param_1, s16 index, u32 param_3)
|
||||
bool8 sub_809DA08(Action *param_1, s16 index, u32 param_3)
|
||||
{
|
||||
s32 index_s32;
|
||||
|
||||
|
|
@ -234,14 +234,14 @@ bool8 sub_809DA08(GroundScript_ExecutePP_1 *param_1, s16 index, u32 param_3)
|
|||
if (sub_809A750() == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
param_1->unk24.unk22 = index_s32;
|
||||
param_1->scriptData.unk22 = index_s32;
|
||||
}
|
||||
else {
|
||||
param_1->unk24.unk22 = index_s32 | 0x80;
|
||||
param_1->scriptData.unk22 = index_s32 | 0x80;
|
||||
gUnknown_2039A38[index_s32] = 1;
|
||||
gUnknown_2039AC0[index_s32] = 1;
|
||||
}
|
||||
param_1->unk24.unk2 = 2;
|
||||
param_1->scriptData.savedState = 2;
|
||||
gUnknown_2039A36 = 1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user