mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-23 13:09:56 +00:00
Document more script var stuff
This commit is contained in:
parent
036cd9b999
commit
439a43e82c
@ -471,8 +471,8 @@ gUnknown_80B71A0: @ 80B71A0
|
||||
.string "{COLOR_1 GREEN_2}START{END_COLOR_TEXT_1}\0"
|
||||
.align 2,0
|
||||
|
||||
.global gUnknown_80B71E4
|
||||
gUnknown_80B71E4: @ 80B71E4
|
||||
.global gGroundEnterLookupTable
|
||||
gGroundEnterLookupTable: @ 80B71E4
|
||||
@ [struct unkEventStruct]
|
||||
.2byte 105, 1
|
||||
.2byte 106, 2
|
||||
|
@ -1,39 +1,63 @@
|
||||
#ifndef GUARD_EVENT_FLAG_H
|
||||
#define GUARD_EVENT_FLAG_H
|
||||
|
||||
// size: 0x8
|
||||
struct UnkEventStruct
|
||||
{
|
||||
/* 0x0 */ s16 *unk0;
|
||||
/* 0x4 */ u8 *unk4;
|
||||
// size: 0x10
|
||||
struct ScriptVarInfo {
|
||||
s16 type;
|
||||
s16 unk2;
|
||||
s16 bufOffset;
|
||||
s16 bitOffset;
|
||||
s16 arrayLen;
|
||||
s16 defaultValue;
|
||||
char *name;
|
||||
};
|
||||
|
||||
void GetScriptVarScenario(s32 param_1,u32 *param_2,u32 *param_3);
|
||||
void ScenarioCalc(s16 param_1, s32 param_2, s32 param_3);
|
||||
// size: 0x8
|
||||
struct ScriptVarPtr
|
||||
{
|
||||
/* 0x0 */ struct ScriptVarInfo *info;
|
||||
/* 0x4 */ u8 *ptr;
|
||||
};
|
||||
|
||||
// event_flag.s
|
||||
|
||||
void ThoroughlyResetScriptVars(void);
|
||||
void ResetScriptVarArray(u8 *localVarBuf, s16 varId);
|
||||
void ClearScriptVarArray(u8 *localVarBuf, s16 varId);
|
||||
void GetScriptVarRef(struct ScriptVarPtr *out, u8 *localVarBuf, s32 varId);
|
||||
s32 GetScriptVarValue(u8 *localVarBuf, s32 varId);
|
||||
s32 GetScriptVarArrayValue(u8 *localVarBuf, s32 varId, u16 idx);
|
||||
void SetScriptVarValue(u8 *localVarBuf, s32 varId, s32 val);
|
||||
void SetScriptVarArrayValue(u8 *localVarBuf, s32 varId, u16 idx, s32 val);
|
||||
s32 GetScriptVarArraySum(u8 *localVarBuf, s16 varId);
|
||||
void GetScriptVarScenario(s32 varId,u32 *outMain,u32 *outSub);
|
||||
void ScenarioCalc(s16 varId, s32 param_2, s32 param_3);
|
||||
bool8 ScriptVarScenarioBefore(s16 param_1, u32 param_2, s32 param_3);
|
||||
bool8 ScriptVarScenarioEqual(s16 param_1, u32 param_2, s32 param_3);
|
||||
bool8 ScriptVarScenarioAfter(s16 param_1, u32 param_2, s32 param_3);
|
||||
void sub_8001D88(void);
|
||||
u32 _FlagCalc(s32 param_1, s32 param_2, u32 operation);
|
||||
u8 _FlagJudge(s32 param_1, s32 param_2, u32 operation);
|
||||
bool8 _FlagJudge(s32 param_1, s32 param_2, u32 operation);
|
||||
u32 FlagCalc(s32 r0, s32 r1, u32 operation);
|
||||
void UpdateScriptVarWithImmediate(u32 param_1, s16 param_2, s32 param_3, u32 operation);
|
||||
void UpdateScriptVarWithVar(u32 param_1, s16 param_2, s16 param_3, u32 operation);
|
||||
u8 FlagJudge(s32 r0, s32 r1, u32 operation);
|
||||
u8 sub_80022F8(u32 param_1, s16 param_2, s32 param_3, u32 operation);
|
||||
u8 sub_8002318(u32 param_1, s16 param_2, s16 param_3, u32 operation);
|
||||
void UpdateScriptVarWithImmediate(u8 *localVarBuf, s16 varId, s32 val, u32 operation);
|
||||
void UpdateScriptVarWithVar(u8 *localVarBuf, s16 dstVarId, s16 srcVarId, u32 operation);
|
||||
bool8 FlagJudge(s32 r0, s32 r1, u32 operation);
|
||||
bool8 sub_80022F8(u8 *param_1, s16 param_2, s32 param_3, u32 operation);
|
||||
bool8 sub_8002318(u8 *param_1, s16 param_2, s16 param_3, u32 operation);
|
||||
bool8 sub_80023E4(u32 param_1);
|
||||
u8 sub_8002658(s16 param_1);
|
||||
s16 sub_8002694(u8 param_1);
|
||||
bool8 sub_80026CC(s16 r0);
|
||||
void sub_80026E8(s16 r0);
|
||||
void sub_80026E8(s16 r0, bool8 r1);
|
||||
bool8 sub_8002700(void *r0);
|
||||
bool8 sub_8002718(u8 *r0);
|
||||
void sub_8002758(s32 r0);
|
||||
u8 sub_800276C(void);
|
||||
|
||||
// event_flag.s
|
||||
extern void ClearScriptVarArray(u32, u32);
|
||||
extern u32 GetScriptVarValue(u32, u32);
|
||||
// .rodata
|
||||
extern struct ScriptVarInfo gScriptVarInfo[];
|
||||
|
||||
// EWRAM
|
||||
extern u8 gScriptVarBuffer[0x400];
|
||||
|
||||
#endif // GUARD_EVENT_FLAG_H
|
||||
|
@ -31,11 +31,6 @@ typedef struct ScriptInfo
|
||||
/* 0xA */ s8 sector;
|
||||
} ScriptInfo;
|
||||
|
||||
typedef union ScriptUnion832 {
|
||||
s32 raw;
|
||||
s8 arr[4];
|
||||
} ScriptUnion832;
|
||||
|
||||
typedef union ScriptUnion1632 {
|
||||
s32 raw;
|
||||
s16 arr[2];
|
||||
@ -70,7 +65,10 @@ typedef struct ScriptData
|
||||
/* 0x4D */ u8 unk4D;
|
||||
// padding
|
||||
// ultimately accessed as ldrb, doesn't work as array of u32-sized structs, needs union
|
||||
/* 0x50 */ ScriptUnion832 unk50[4];
|
||||
/* 0x50 */ union {
|
||||
u8 buf[16];
|
||||
u32 val[4];
|
||||
} localVars;
|
||||
} ScriptData;
|
||||
|
||||
typedef struct CallbackData
|
||||
|
2
renames.sed
Normal file
2
renames.sed
Normal file
@ -0,0 +1,2 @@
|
||||
s/gGroundEnterLookupTable/gGroundEnterLookupTable/g
|
||||
|
24
src/code.c
24
src/code.c
@ -36,22 +36,6 @@ void nullsub_3(s32 a0, s32 a1)
|
||||
/// TODO merge with event_flag
|
||||
/////////////////////////////////
|
||||
|
||||
extern u8 gScriptVarBuffer[0x400];
|
||||
|
||||
struct unkStruct_80B7394
|
||||
{
|
||||
s16 unk0;
|
||||
s16 unk2;
|
||||
s16 unk4;
|
||||
s16 unk6;
|
||||
s16 unk8;
|
||||
s16 unkA;
|
||||
u8 *text;
|
||||
};
|
||||
|
||||
extern struct unkStruct_80B7394 gScriptVarInfo[];
|
||||
extern void SetScriptVarArrayValue(u32, s32, u32, s32);
|
||||
extern void SetScriptVarValue(u32, u32, u32);
|
||||
extern void sub_80972F4(void);
|
||||
extern void nullsub_128(void);
|
||||
|
||||
@ -60,7 +44,7 @@ void ThoroughlyResetScriptVars(void)
|
||||
s32 iVar1;
|
||||
s32 iVar3;
|
||||
u16 uVar2;
|
||||
struct unkStruct_80B7394 *puVar1;
|
||||
struct ScriptVarInfo *puVar1;
|
||||
|
||||
for(iVar3 = 0; iVar3 < 0x400; iVar3++)
|
||||
{
|
||||
@ -70,9 +54,9 @@ void ThoroughlyResetScriptVars(void)
|
||||
for(iVar1 = 0; iVar1 < 0x51; iVar1 = (iVar1 + 1) * 0x10000 >> 0x10)
|
||||
{
|
||||
puVar1 = &gScriptVarInfo[iVar1];
|
||||
if (((puVar1->unk0 != 0) && ((puVar1->unk0 != 8)))) {
|
||||
for (uVar2 = 0; uVar2 < puVar1->unk8; uVar2++) {
|
||||
SetScriptVarArrayValue(0, iVar1, uVar2, puVar1->unkA);
|
||||
if (((puVar1->type != 0) && ((puVar1->type != 8)))) {
|
||||
for (uVar2 = 0; uVar2 < puVar1->arrayLen; uVar2++) {
|
||||
SetScriptVarArrayValue(0, iVar1, uVar2, puVar1->defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,6 @@
|
||||
extern void NDS_LoadOverlay_GroundMain(void);
|
||||
extern void sub_8014144(void);
|
||||
extern void sub_800DAAC(void);
|
||||
extern void ThoroughlyResetScriptVars(void);
|
||||
extern void xxx_script_related_8001334(u32);
|
||||
extern void LoadTitleScreen(void);
|
||||
extern void sub_80095CC(u32, u32);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "code_8098BDC.h"
|
||||
#include "common_strings.h"
|
||||
#include "constants/colors.h"
|
||||
#include "event_flag.h"
|
||||
#include "input.h"
|
||||
#include "items.h"
|
||||
#include "kecleon_bros4.h"
|
||||
@ -24,10 +25,6 @@ static EWRAM_DATA_2 unkStruct_203B234 *sUnknown_203B234 = {0};
|
||||
|
||||
#include "data/code_801B60C.h" // 80DBA58
|
||||
|
||||
// event_flag.s
|
||||
extern u32 GetScriptVarArrayValue(u32, u32, u16);
|
||||
extern void SetScriptVarArrayValue(u32, u32, u32, u32);
|
||||
|
||||
static void sub_801B748(u32);
|
||||
static void sub_801B760(void);
|
||||
static void sub_801B874(void);
|
||||
@ -492,4 +489,4 @@ static void sub_801BEC8(void)
|
||||
|
||||
if (!sub_80144A4(&temp))
|
||||
sub_801B748(sUnknown_203B234->fallbackState);
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,7 @@
|
||||
ALIGNED(4) const u8 gDummyScenarioText[] = _("{COLOR_1 YELLOW_3}Scenario try dummy{END_COLOR_TEXT_1}");
|
||||
ALIGNED(4) const u8 gBlankMission[] = _("{COLOR_1 RED_2}???{END_COLOR_TEXT_1}");
|
||||
|
||||
extern void SetScriptVarArrayValue(u8, u8, u16, s32);
|
||||
extern u32 GetScriptVarArrayValue(u32, u32, u16);
|
||||
extern void GeneratePelipperJobs(void);
|
||||
extern void SetScriptVarValue(u8, u8, u32);
|
||||
|
||||
void sub_80972F4(void)
|
||||
{
|
||||
|
@ -9,9 +9,6 @@ ALIGNED(4) const char gMeetNinetalesText[] = "Meet Ninetales.";
|
||||
ALIGNED(4) const char gAvoidCaptureText[] = "Avoid capture.";
|
||||
ALIGNED(4) const char gFinalScenarioText[] = _("Defeat the final Pokémon.");
|
||||
|
||||
extern void SetScriptVarArrayValue(u8, u8, u16, s32);
|
||||
extern u32 GetScriptVarArrayValue(u32, u32, u16);
|
||||
extern void SetScriptVarValue(u8, u8, u32);
|
||||
|
||||
bool8 sub_8097504(s16 mazeIndex)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "items.h"
|
||||
#include "memory.h"
|
||||
#include "game_options.h"
|
||||
#include "event_flag.h"
|
||||
#include "ground_main.h"
|
||||
#include "code_80A26CC.h"
|
||||
|
||||
@ -49,11 +50,6 @@ void nullsub_114();
|
||||
void nullsub_115();
|
||||
void nullsub_116();
|
||||
|
||||
// Event_flag.h
|
||||
u8 sub_8002658(s16);
|
||||
s16 GetScriptVarValue(u32, u32);
|
||||
extern void ClearScriptVarArray(u32, u32);
|
||||
|
||||
void sub_809C5C4(void)
|
||||
{
|
||||
gUnknown_3001B68 = MemoryAlloc(sizeof(struct unkStruct_3001B68), 6);
|
||||
@ -276,7 +272,7 @@ void sub_809C770(s16 param_1, s16 param_2)
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
iVar5 = GetScriptVarValue(0,0x13);
|
||||
iVar5 = (s16)GetScriptVarValue(0,0x13);
|
||||
break;
|
||||
|
||||
}
|
||||
|
110
src/event_flag.c
110
src/event_flag.c
@ -16,14 +16,14 @@
|
||||
|
||||
extern u8 gScriptVarBuffer[0x400];
|
||||
|
||||
struct unkEventStruct
|
||||
struct GroundEventTableEntry
|
||||
{
|
||||
// size: 0x4
|
||||
s16 unk0;
|
||||
u8 unk2; // Seems like friend area number
|
||||
s16 groundEnterId;
|
||||
u8 value; // Seems like friend area number
|
||||
};
|
||||
|
||||
extern struct unkEventStruct gUnknown_80B71E4[58];
|
||||
extern struct GroundEventTableEntry gGroundEnterLookupTable[58];
|
||||
|
||||
struct unkStruct_80B6D90
|
||||
{
|
||||
@ -45,84 +45,84 @@ extern u8 gUnknown_80B7388[];
|
||||
|
||||
void FatalError(DebugLocation *, const char *, ...) __attribute__((noreturn));
|
||||
extern bool8 HasCompletedAllMazes(void);
|
||||
extern void GetScriptVarRef(struct UnkEventStruct *r0, u32 r1, u32 r2);
|
||||
extern u8 sub_8002658(s16);
|
||||
extern void SetScriptVarValue(u32, u32, u32);
|
||||
extern void sub_809733C(u32, u32);
|
||||
extern void sub_80973A8(u32, u32);
|
||||
extern void SetScriptVarArrayValue(u32, s32, u32, s32);
|
||||
extern s32 GetScriptVarArrayValue(u32, s32, u16);
|
||||
|
||||
|
||||
// code_80972F4.h (read comment)
|
||||
extern bool8 RescueScenarioConquered(s16);
|
||||
|
||||
u8 *GetScriptVarPointer(s16 param_1)
|
||||
// unused
|
||||
u8 *GetScriptVarPointer(s16 varId)
|
||||
{
|
||||
struct UnkEventStruct local_1c;
|
||||
struct ScriptVarPtr local_1c;
|
||||
|
||||
GetScriptVarRef(&local_1c,0,param_1);
|
||||
return local_1c.unk4;
|
||||
GetScriptVarRef(&local_1c,0,varId);
|
||||
return local_1c.ptr;
|
||||
}
|
||||
|
||||
s16 GetScriptVarArrayLength(s16 param_1)
|
||||
// unused
|
||||
s16 GetScriptVarArrayLength(s16 varId)
|
||||
{
|
||||
struct UnkEventStruct local_1c;
|
||||
struct ScriptVarPtr local_1c;
|
||||
|
||||
GetScriptVarRef(&local_1c,0,param_1);
|
||||
return local_1c.unk0[4];
|
||||
GetScriptVarRef(&local_1c,0,varId);
|
||||
return local_1c.info->arrayLen;
|
||||
}
|
||||
|
||||
s32 GetScriptVarArraySum(s32 param_1, s16 param_2)
|
||||
s32 GetScriptVarArraySum(u8 *localVarBuf, s16 varId)
|
||||
{
|
||||
s32 counter;
|
||||
s32 total;
|
||||
struct UnkEventStruct local_1c;
|
||||
s32 param_2_s32;
|
||||
struct ScriptVarPtr local_1c;
|
||||
s32 varId_s32;
|
||||
|
||||
param_2_s32 = param_2;
|
||||
varId_s32 = varId;
|
||||
|
||||
total = 0;
|
||||
GetScriptVarRef(&local_1c, 0, param_2_s32);
|
||||
for(counter = 0; counter < local_1c.unk0[4]; counter++)
|
||||
GetScriptVarRef(&local_1c, 0, varId_s32);
|
||||
for(counter = 0; counter < local_1c.info->arrayLen; counter++)
|
||||
{
|
||||
total += GetScriptVarArrayValue(param_1, param_2_s32, counter);
|
||||
total += GetScriptVarArrayValue(localVarBuf, varId_s32, counter);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
void GetScriptVarString(s16 param_1, u8 *param_2, s32 param_3)
|
||||
// unused
|
||||
void GetScriptVarString(s16 varId, u8 *buf, s32 maxLen)
|
||||
{
|
||||
u8 *r1;
|
||||
s32 r2;
|
||||
u8 r0;
|
||||
struct UnkEventStruct local_10;
|
||||
struct ScriptVarPtr local_10;
|
||||
|
||||
GetScriptVarRef(&local_10,0,param_1);
|
||||
for (r1 = local_10.unk4, r2 = 0; r2 < param_3; r2++) {
|
||||
GetScriptVarRef(&local_10,0,varId);
|
||||
for (r1 = local_10.ptr, r2 = 0; r2 < maxLen; r2++) {
|
||||
r0 = *r1;
|
||||
if (*r1++ == 0) break;
|
||||
*param_2 = r0;
|
||||
param_2++;
|
||||
*buf = r0;
|
||||
buf++;
|
||||
}
|
||||
*param_2 = 0;
|
||||
*buf = 0;
|
||||
}
|
||||
|
||||
void ScriptVarStringPopFirstChar(s16 param_1,u32 param_2,s32 param_3)
|
||||
// unused
|
||||
void ScriptVarStringPopFirstChar(s16 varId,u32 param_2,s32 maxLen)
|
||||
{
|
||||
u8 *r1;
|
||||
s32 r2;
|
||||
u8 r0;
|
||||
struct UnkEventStruct local_10;
|
||||
struct ScriptVarPtr local_10;
|
||||
|
||||
GetScriptVarRef(&local_10,0,param_1);
|
||||
for (r1 = local_10.unk4, r2 = 0; r2 < param_3; r1++, r2++) {
|
||||
GetScriptVarRef(&local_10,0,varId);
|
||||
for (r1 = local_10.ptr, r2 = 0; r2 < maxLen; r1++, r2++) {
|
||||
r0 = *r1;
|
||||
if (*r1++ == 0) break;
|
||||
*r1 = r0;
|
||||
}
|
||||
if (r2 < local_10.unk0[4]) {
|
||||
for(; r2 < local_10.unk0[4]; r1++, r2++)
|
||||
if (r2 < local_10.info->arrayLen) {
|
||||
for(; r2 < local_10.info->arrayLen; r1++, r2++)
|
||||
{
|
||||
*r1 = 0;
|
||||
}
|
||||
@ -353,7 +353,7 @@ u32 _FlagCalc(s32 param_1, s32 param_2, u32 operation)
|
||||
}
|
||||
}
|
||||
|
||||
u8 _FlagJudge(s32 param_1, s32 param_2, u32 operation)
|
||||
bool8 _FlagJudge(s32 param_1, s32 param_2, u32 operation)
|
||||
{
|
||||
switch(operation) {
|
||||
case 0:
|
||||
@ -388,7 +388,7 @@ u32 FlagCalc(s32 r0, s32 r1, u32 operation)
|
||||
return _FlagCalc(r0, r1, operation);
|
||||
}
|
||||
|
||||
void UpdateScriptVarWithImmediate(u32 param_1, s16 param_2, s32 param_3, u32 operation)
|
||||
void UpdateScriptVarWithImmediate(u8 *param_1, s16 param_2, s32 param_3, u32 operation)
|
||||
{
|
||||
u32 uVar1;
|
||||
u32 uVar3;
|
||||
@ -398,7 +398,7 @@ void UpdateScriptVarWithImmediate(u32 param_1, s16 param_2, s32 param_3, u32 ope
|
||||
SetScriptVarValue(param_1,param_2,uVar3);
|
||||
}
|
||||
|
||||
void UpdateScriptVarWithVar(u32 param_1, s16 param_2, s16 param_3, u32 operation)
|
||||
void UpdateScriptVarWithVar(u8 *param_1, s16 param_2, s16 param_3, u32 operation)
|
||||
{
|
||||
s32 uVar1;
|
||||
s32 uVar2;
|
||||
@ -414,12 +414,12 @@ void UpdateScriptVarWithVar(u32 param_1, s16 param_2, s16 param_3, u32 operation
|
||||
SetScriptVarValue(param_1,param_2_s32,uVar3);
|
||||
}
|
||||
|
||||
u8 FlagJudge(s32 r0, s32 r1, u32 operation)
|
||||
bool8 FlagJudge(s32 r0, s32 r1, u32 operation)
|
||||
{
|
||||
return _FlagJudge(r0, r1, operation);
|
||||
}
|
||||
|
||||
u8 sub_80022F8(u32 param_1, s16 param_2, s32 param_3, u32 operation)
|
||||
bool8 sub_80022F8(u8 *param_1, s16 param_2, s32 param_3, u32 operation)
|
||||
{
|
||||
s32 uVar1;
|
||||
|
||||
@ -427,7 +427,7 @@ u8 sub_80022F8(u32 param_1, s16 param_2, s32 param_3, u32 operation)
|
||||
return _FlagJudge(uVar1,param_3,operation);
|
||||
}
|
||||
|
||||
u8 sub_8002318(u32 param_1, s16 param_2, s16 param_3, u32 operation)
|
||||
bool8 sub_8002318(u8 *param_1, s16 param_2, s16 param_3, u32 operation)
|
||||
{
|
||||
s32 uVar1;
|
||||
s32 uVar2;
|
||||
@ -440,6 +440,7 @@ u8 sub_8002318(u32 param_1, s16 param_2, s16 param_3, u32 operation)
|
||||
return _FlagJudge(uVar1,uVar2,operation);
|
||||
}
|
||||
|
||||
// unused
|
||||
s32 sub_8002354(u32 param_1)
|
||||
{
|
||||
if (param_1 < 0x3b) {
|
||||
@ -450,6 +451,7 @@ s32 sub_8002354(u32 param_1)
|
||||
}
|
||||
}
|
||||
|
||||
// unused
|
||||
u8 *sub_8002374(u32 param_1)
|
||||
{
|
||||
if (param_1 < 0x3b) {
|
||||
@ -559,19 +561,19 @@ u8 sub_8002658(s16 param_1)
|
||||
{
|
||||
short sVar1;
|
||||
s32 param_1_s32;
|
||||
struct unkEventStruct *ptr;
|
||||
struct GroundEventTableEntry *ptr;
|
||||
|
||||
param_1_s32 = param_1;
|
||||
|
||||
ptr = gUnknown_80B71E4;
|
||||
sVar1 = gUnknown_80B71E4[0].unk0;
|
||||
ptr = gGroundEnterLookupTable;
|
||||
sVar1 = gGroundEnterLookupTable[0].groundEnterId;
|
||||
if (sVar1 != -1) {
|
||||
do {
|
||||
if (sVar1 == param_1_s32) {
|
||||
return ptr->unk2;
|
||||
return ptr->value;
|
||||
}
|
||||
ptr++;
|
||||
sVar1 = ptr->unk0;
|
||||
sVar1 = ptr->groundEnterId;
|
||||
} while (sVar1 != -1);
|
||||
}
|
||||
return 0;
|
||||
@ -580,11 +582,11 @@ u8 sub_8002658(s16 param_1)
|
||||
s16 sub_8002694(u8 param_1)
|
||||
{
|
||||
|
||||
struct unkEventStruct *puVar2 = gUnknown_80B71E4;
|
||||
struct GroundEventTableEntry *puVar2 = gGroundEnterLookupTable;
|
||||
|
||||
while (puVar2->unk0 != -1) {
|
||||
if (puVar2->unk2 == param_1) {
|
||||
return puVar2->unk0;
|
||||
while (puVar2->groundEnterId != -1) {
|
||||
if (puVar2->value == param_1) {
|
||||
return puVar2->groundEnterId;
|
||||
}
|
||||
puVar2++;
|
||||
}
|
||||
@ -597,7 +599,7 @@ bool8 sub_80026CC(s16 r0)
|
||||
return GetFriendAreaStatus(sub_8002658(r0));
|
||||
}
|
||||
|
||||
void sub_80026E8(s16 r0)
|
||||
void sub_80026E8(s16 r0, bool8 r1)
|
||||
{
|
||||
UnlockFriendArea(sub_8002658(r0));
|
||||
}
|
||||
@ -610,10 +612,10 @@ bool8 sub_8002700(void *r0)
|
||||
|
||||
bool8 sub_8002718(u8 *r0)
|
||||
{
|
||||
struct UnkEventStruct temp;
|
||||
struct ScriptVarPtr temp;
|
||||
GetScriptVarRef(&temp, 0, 0);
|
||||
MemoryCopy8(gScriptVarBuffer, r0, 0x400);
|
||||
if (temp.unk0[5] != *(u32 *)temp.unk4)
|
||||
if (temp.info->defaultValue != *(u32 *)temp.ptr)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
@ -48,10 +48,7 @@ extern void GroundLives_Action();
|
||||
extern void GroundObject_Action();
|
||||
extern void GroundEffect_Action();
|
||||
|
||||
extern s32 GetScriptVarArrayValue(u8, u8, u8);
|
||||
extern void sub_809CB8C();
|
||||
extern void SetScriptVarValue(u8, u8, u32);
|
||||
extern void SetScriptVarArrayValue(u8, u8, u8, s32);
|
||||
extern void sub_8098CC8();
|
||||
extern void GeneratePelipperJobs();
|
||||
extern void sub_80961B4();
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "memory.h"
|
||||
#include "debug.h"
|
||||
#include "event_flag.h"
|
||||
#include "ground_map.h"
|
||||
#include "ground_map_2.h"
|
||||
|
||||
@ -15,7 +16,6 @@ extern const u8 gGroundWeatherSelect[];
|
||||
extern const s32 gUnknown_81177BC[];
|
||||
|
||||
extern void sub_80A3BB0(unkStruct_3001B70 *, u32);
|
||||
extern void SetScriptVarValue(u8, u8, u32);
|
||||
extern void sub_80A2D00(unkStruct_3001B70 *);
|
||||
extern void sub_80A2B40(unkStruct_3001B70 *, const u8 *);
|
||||
extern void sub_80A2FBC(unkStruct_3001B70 *, u32);
|
||||
@ -256,4 +256,4 @@ static void sub_80A62D0(void)
|
||||
{
|
||||
if (gUnknown_3001B74->unk2 != 0)
|
||||
sub_80A49E8(gUnknown_3001B78);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ void InitScriptData(ScriptData *a0)
|
||||
a0->unk2C = 0;
|
||||
a0->unk30 = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
a0->unk50[i].raw = 0;
|
||||
a0->localVars.val[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "debug.h"
|
||||
#include "event_flag.h"
|
||||
#include "ground_link.h"
|
||||
#include "ground_script.h"
|
||||
#include "ground_sprite.h"
|
||||
@ -70,27 +71,6 @@ void FatalError(void* loc, char* fmt, ...) __attribute__((noreturn));
|
||||
|
||||
// Beware of the declarations without specified arguments, returning u32 or s32, these were quickly hacked in to get the code to compile and link
|
||||
// The return values are almost certainly NOT correct and will need to be rechecked when moving to header files
|
||||
u32 FlagCalc();
|
||||
u32 FlagJudge();
|
||||
s32 GetScriptVarValue(ScriptUnion832*, s32);
|
||||
void ResetScriptVarArray(u8*, s16);
|
||||
void ClearScriptVarArray(u8*, s16);
|
||||
u32 GetScriptVarArrayValue(ScriptUnion832*, s16, u16);
|
||||
void SetScriptVarValue(s32, s32, s32);
|
||||
void SetScriptVarArrayValue(u8*, s16, u32, s32);
|
||||
u32 GetScriptVarArraySum();
|
||||
void GetScriptVarScenario(s16, s32*, s32*);
|
||||
u32 ScenarioCalc(s16, s32, s32);
|
||||
u32 ScriptVarScenarioBefore();
|
||||
u32 ScriptVarScenarioEqual();
|
||||
u32 ScriptVarScenarioAfter();
|
||||
void UpdateScriptVarWithImmediate(u8*, s16, s32, u8);
|
||||
void UpdateScriptVarWithVar(u8*, s16, s32, u8);
|
||||
u32 sub_80022F8();
|
||||
u32 sub_8002318();
|
||||
u32 sub_80023E4();
|
||||
u32 sub_80026CC();
|
||||
void sub_80026E8(s16, bool8);
|
||||
char sub_8002984(s32, u8);
|
||||
u32 VecDirection8Radial();
|
||||
u32 SizedDeltaDirection4();
|
||||
@ -1456,23 +1436,23 @@ s32 ExecuteScriptCommand(Action *action) {
|
||||
return 2;
|
||||
}
|
||||
case 0xa4: {
|
||||
ResetScriptVarArray(scriptData->unk50[0].arr, curCmd.argShort);
|
||||
ResetScriptVarArray(scriptData->localVars.buf, curCmd.argShort);
|
||||
break;
|
||||
}
|
||||
case 0xa5: {
|
||||
ClearScriptVarArray(scriptData->unk50[0].arr, curCmd.argShort);
|
||||
ClearScriptVarArray(scriptData->localVars.buf, curCmd.argShort);
|
||||
break;
|
||||
}
|
||||
case 0xa6: {
|
||||
UpdateScriptVarWithImmediate(scriptData->unk50[0].arr, curCmd.argShort, curCmd.arg1, curCmd.argByte);
|
||||
UpdateScriptVarWithImmediate(scriptData->localVars.buf, curCmd.argShort, curCmd.arg1, curCmd.argByte);
|
||||
break;
|
||||
}
|
||||
case 0xa7: {
|
||||
UpdateScriptVarWithVar(scriptData->unk50[0].arr, curCmd.argShort, (s16)curCmd.arg1, curCmd.argByte);
|
||||
UpdateScriptVarWithVar(scriptData->localVars.buf, curCmd.argShort, (s16)curCmd.arg1, curCmd.argByte);
|
||||
break;
|
||||
}
|
||||
case 0xa8: {
|
||||
SetScriptVarArrayValue(scriptData->unk50[0].arr, curCmd.argShort, (u16)curCmd.arg1, curCmd.arg2);
|
||||
SetScriptVarArrayValue(scriptData->localVars.buf, curCmd.argShort, (u16)curCmd.arg1, curCmd.arg2);
|
||||
break;
|
||||
}
|
||||
case 0xa9: {
|
||||
@ -1525,25 +1505,25 @@ s32 ExecuteScriptCommand(Action *action) {
|
||||
break;
|
||||
}
|
||||
case 0xb4: {
|
||||
if ((s8)sub_80022F8(scriptData->unk50, (s16)curCmd.arg1, curCmd.arg2, (u8)curCmd.argByte)) {
|
||||
if ((s8)sub_80022F8(scriptData->localVars.buf, (s16)curCmd.arg1, curCmd.arg2, (u8)curCmd.argByte)) {
|
||||
scriptData->script.ptr = FindLabel(action, curCmd.argShort);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xb5: {
|
||||
if ((s8)sub_8002318(scriptData->unk50, (s16)curCmd.arg1, (s16)curCmd.arg2, (u8)curCmd.argByte)) {
|
||||
if ((s8)sub_8002318(scriptData->localVars.buf, (s16)curCmd.arg1, (s16)curCmd.arg2, (u8)curCmd.argByte)) {
|
||||
scriptData->script.ptr = FindLabel(action, curCmd.argShort);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xb6: {
|
||||
if (GetScriptVarArrayValue(scriptData->unk50, (s16)curCmd.arg1, (u16)curCmd.arg2)) {
|
||||
if (GetScriptVarArrayValue(scriptData->localVars.buf, (s16)curCmd.arg1, (u16)curCmd.arg2)) {
|
||||
scriptData->script.ptr = FindLabel(action, curCmd.argShort);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xb7: {
|
||||
if ((s8)FlagJudge(GetScriptVarArraySum(scriptData->unk50, (s16)curCmd.arg1), curCmd.arg2, (u8)curCmd.argByte)) {
|
||||
if ((s8)FlagJudge(GetScriptVarArraySum(scriptData->localVars.buf, (s16)curCmd.arg1), curCmd.arg2, (u8)curCmd.argByte)) {
|
||||
scriptData->script.ptr = FindLabel(action, curCmd.argShort);
|
||||
}
|
||||
break;
|
||||
@ -1609,20 +1589,20 @@ s32 ExecuteScriptCommand(Action *action) {
|
||||
Position32 pos, pos2, pos3;
|
||||
switch (curCmd.op) {
|
||||
case 0xc0: {
|
||||
val = GetScriptVarValue(scriptData->unk50, curCmd.argShort);
|
||||
val = GetScriptVarValue(scriptData->localVars.buf, curCmd.argShort);
|
||||
break;
|
||||
}
|
||||
case 0xc1: {
|
||||
val = FlagCalc(
|
||||
GetScriptVarValue(scriptData->unk50, curCmd.argShort),
|
||||
GetScriptVarValue(scriptData->localVars.buf, curCmd.argShort),
|
||||
curCmd.arg1,
|
||||
(u8)curCmd.argByte);
|
||||
break;
|
||||
}
|
||||
case 0xc2: {
|
||||
val = FlagCalc(
|
||||
GetScriptVarValue(scriptData->unk50, curCmd.argShort),
|
||||
GetScriptVarValue(scriptData->unk50, (s16)curCmd.arg1),
|
||||
GetScriptVarValue(scriptData->localVars.buf, curCmd.argShort),
|
||||
GetScriptVarValue(scriptData->localVars.buf, (s16)curCmd.arg1),
|
||||
(u8)curCmd.argByte);
|
||||
break;
|
||||
}
|
||||
@ -1704,7 +1684,7 @@ s32 ExecuteScriptCommand(Action *action) {
|
||||
break;
|
||||
}
|
||||
case 0xcf: {
|
||||
scriptData->branchDiscriminant = GetScriptVarValue(scriptData->unk50, curCmd.argShort);
|
||||
scriptData->branchDiscriminant = GetScriptVarValue(scriptData->localVars.buf, curCmd.argShort);
|
||||
while (scriptData->script.ptr->op == 0xd0) {
|
||||
if (scriptData->script.ptr->argShort == scriptData->branchDiscriminant)
|
||||
return 2;
|
||||
@ -1722,7 +1702,7 @@ s32 ExecuteScriptCommand(Action *action) {
|
||||
scriptData->branchDiscriminant = 0;
|
||||
switch(curCmd.op) {
|
||||
case 0xd6: case 0xd7: case 0xd8: {
|
||||
s32 disc = GetScriptVarValue(scriptData->unk50, (s16)curCmd.arg2);
|
||||
s32 disc = GetScriptVarValue(scriptData->localVars.buf, (s16)curCmd.arg2);
|
||||
for (; scriptData->script.ptr->op == 0xd0; scriptData->script.ptr++, scriptData->branchDiscriminant++) {
|
||||
if (scriptData->script.ptr->argShort == disc)
|
||||
out = scriptData->script.ptr->argPtr;
|
||||
@ -1833,7 +1813,7 @@ s32 ExecuteScriptCommand(Action *action) {
|
||||
break;
|
||||
}
|
||||
case 0xec: {
|
||||
gUnknown_2039A34 = GetAdjustedGroundMap((s16)GetScriptVarValue(scriptData->unk50, curCmd.argShort));
|
||||
gUnknown_2039A34 = GetAdjustedGroundMap((s16)GetScriptVarValue(scriptData->localVars.buf, curCmd.argShort));
|
||||
GroundCancelAllEntities();
|
||||
GroundMap_ExecuteEnter(gUnknown_2039A34);
|
||||
break;
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "debug.h"
|
||||
#include "global.h"
|
||||
#include "event_flag.h"
|
||||
#include "ground_map_1.h"
|
||||
#include "ground_script.h"
|
||||
|
||||
s32 GetScriptVarValue(ScriptUnion832*, s32);
|
||||
u8 FlagJudge(s32 r0, s32 r1, u32 operation);
|
||||
|
||||
extern u8 gAnyScriptLocked;
|
||||
extern u8 gScriptLocks[];
|
||||
extern u32 gUnlockBranchLabels[];
|
||||
@ -102,7 +100,7 @@ ScriptCommand *ResolveJump(Action *action, s32 r1)
|
||||
}
|
||||
else if (script.op == 0xCE)
|
||||
{
|
||||
temp = GetScriptVarValue(action->scriptData.unk50, (s16)script.arg1);
|
||||
temp = GetScriptVarValue(action->scriptData.localVars.buf, (s16)script.arg1);
|
||||
if(FlagJudge(r1, temp, script.argByte))
|
||||
return FindLabel(action, script.argShort);
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ extern u32 sub_80954CC(void* a, s32 b);
|
||||
extern u32 sub_8095624(u8 *, u32);
|
||||
extern u32 RestoreMailInfo(void* a, s32 b);
|
||||
extern u32 SaveMailInfo(u8 *, u32);
|
||||
extern void ThoroughlyResetScriptVars(void);
|
||||
extern void sub_80958E4(u32 *a, u32 b);
|
||||
extern void sub_80972F4(void);
|
||||
extern void sub_80974E8(void);
|
||||
|
Loading…
Reference in New Issue
Block a user