Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions include/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct ScriptContext
u8 stackDepth;
u8 mode;
u8 comparisonResult;
u8 (*nativePtr)(void);
bool8 (*nativePtr)(void);
const u8 *scriptPtr;
const u8 *stack[20];
ScrCmdFunc *cmdTable;
Expand Down Expand Up @@ -41,19 +41,15 @@ void ScriptContext_SetupScript(const u8 *ptr);
void ScriptContext_Stop(void);
void ScriptContext_Enable(void);
void RunScriptImmediately(const u8 *ptr);
u8 *MapHeaderGetScriptTable(u8 tag);
void MapHeaderRunScriptType(u8 tag);
u8 *MapHeaderCheckScriptTable(u8 tag);
void RunOnLoadMapScript(void);
void RunOnTransitionMapScript(void);
void RunOnResumeMapScript(void);
void RunOnReturnToFieldMapScript(void);
void RunOnDiveWarpMapScript(void);
bool8 TryRunOnFrameMapScript(void);
void TryRunOnWarpIntoMapScript(void);
u32 CalculateRamScriptChecksum(void);
void ClearRamScript(void);
bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId);
bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 localId);
const u8 *GetRamScript(u8 objectId, const u8 *script);
bool32 ValidateSavedRamScript(void);
u8 *GetSavedRamScriptIfValid(void);
Expand Down
11 changes: 6 additions & 5 deletions src/mystery_event_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
extern ScrCmdFunc gMysteryEventScriptCmdTable[];
extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[];

// 0x1 in English FRLG, 0x2 in English RS, 0x4 in German RS
#define LANGUAGE_MASK 0x1
Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused about this one. Is it definitely a language value if it changes between versions with the same language?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused about this one. Is it definitely a language value if it changes between versions with the same language?

right, that can't be... should I rename it to UNK_ME_MASK_1 or something?


// 0x1 in FireRed, 0x2 in LeafGreen, 0x80 in Ruby, 0x100 in Sapphire
#define VERSION_MASK (1 << 9)

Expand All @@ -27,16 +30,14 @@ extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[];
#define mStatus data[2]
#define mValid data[3]

EWRAM_DATA static struct ScriptContext sMysteryEventScriptContext = {0};
static EWRAM_DATA struct ScriptContext sMysteryEventScriptContext = {0};

static bool32 CheckCompatibility(u16 unk0, u32 unk1, u16 unk2, u32 version)
{
// 0x1 in English FRLG, 0x2 in English RS, 0x4 in German RS
if (!(unk0 & 0x1))
if (!(unk0 & LANGUAGE_MASK))
return FALSE;

// Same as above
if (!(unk1 & 0x1))
if (!(unk1 & LANGUAGE_MASK))
return FALSE;

// 0x1 in FRLG, 0x4 in RS
Expand Down
16 changes: 7 additions & 9 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void RunScriptImmediately(const u8 *ptr)
while (RunScriptCommand(&sImmediateScriptContext) == TRUE);
}

u8 *MapHeaderGetScriptTable(u8 tag)
static u8 *MapHeaderGetScriptTable(u8 tag)
{
const u8 *mapScripts = gMapHeader.mapScripts;

Expand All @@ -289,14 +289,14 @@ u8 *MapHeaderGetScriptTable(u8 tag)
}
}

void MapHeaderRunScriptType(u8 tag)
static void MapHeaderRunScriptType(u8 tag)
{
u8 *ptr = MapHeaderGetScriptTable(tag);
if (ptr)
RunScriptImmediately(ptr);
}

u8 *MapHeaderCheckScriptTable(u8 tag)
static u8 *MapHeaderCheckScriptTable(u8 tag)
{
u8 *ptr = MapHeaderGetScriptTable(tag);

Expand Down Expand Up @@ -368,7 +368,7 @@ void TryRunOnWarpIntoMapScript(void)
RunScriptImmediately(ptr);
}

u32 CalculateRamScriptChecksum(void)
static u32 CalculateRamScriptChecksum(void)
{
return CalcCRC16WithTable((u8 *)(&gSaveBlock1Ptr->ramScript.data), sizeof(gSaveBlock1Ptr->ramScript.data));
}
Expand Down Expand Up @@ -413,11 +413,9 @@ const u8 *GetRamScript(u8 localId, const u8 *script)
ClearRamScript();
return script;
}
else
{
gRamScriptRetAddr = script;
return scriptData->script;
}

gRamScriptRetAddr = script;
return scriptData->script;
}

#define NO_OBJECT LOCALID_PLAYER
Expand Down