2017-09-07 19:45:32 +02:00
|
|
|
#ifndef GUARD_SCRIPT_H
|
|
|
|
#define GUARD_SCRIPT_H
|
|
|
|
|
|
|
|
struct ScriptContext;
|
|
|
|
|
|
|
|
typedef bool8 (*ScrCmdFunc)(struct ScriptContext *);
|
|
|
|
typedef u8 Script[];
|
|
|
|
|
|
|
|
struct ScriptContext
|
|
|
|
{
|
|
|
|
u8 stackDepth;
|
|
|
|
u8 mode;
|
|
|
|
u8 comparisonResult;
|
|
|
|
u8 (*nativePtr)(void);
|
|
|
|
const u8 *scriptPtr;
|
|
|
|
const u8 *stack[20];
|
|
|
|
ScrCmdFunc *cmdTable;
|
|
|
|
ScrCmdFunc *cmdTableEnd;
|
|
|
|
u32 data[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ScriptReadByte(ctx) (*(ctx->scriptPtr++))
|
|
|
|
|
|
|
|
void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd);
|
|
|
|
u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr);
|
2017-09-10 23:05:23 +02:00
|
|
|
void SetupNativeScript(struct ScriptContext *ctx, bool8 (*ptr)(void));
|
2017-09-07 19:45:32 +02:00
|
|
|
void StopScript(struct ScriptContext *ctx);
|
2017-09-10 23:05:23 +02:00
|
|
|
bool8 RunScriptCommand(struct ScriptContext *ctx);
|
2017-10-12 21:36:26 +02:00
|
|
|
void ScriptJump(struct ScriptContext *ctx, const u8 *ptr);
|
|
|
|
void ScriptCall(struct ScriptContext *ctx, const u8 *ptr);
|
2017-09-07 19:45:32 +02:00
|
|
|
void ScriptReturn(struct ScriptContext *ctx);
|
|
|
|
u16 ScriptReadHalfword(struct ScriptContext *ctx);
|
|
|
|
u32 ScriptReadWord(struct ScriptContext *ctx);
|
2022-08-15 21:18:12 +02:00
|
|
|
void LockPlayerFieldControls(void);
|
|
|
|
void UnlockPlayerFieldControls(void);
|
|
|
|
bool8 ArePlayerFieldControlsLocked(void);
|
|
|
|
void ScriptContext_Init(void);
|
|
|
|
bool8 ScriptContext_IsEnabled(void);
|
|
|
|
bool8 ScriptContext_RunScript(void);
|
|
|
|
void ScriptContext_SetupScript(const u8 *ptr);
|
|
|
|
void ScriptContext_Stop(void);
|
|
|
|
void ScriptContext_Enable(void);
|
|
|
|
void RunScriptImmediately(const u8 *ptr);
|
2019-02-22 08:23:46 +01:00
|
|
|
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);
|
2017-09-07 19:45:32 +02:00
|
|
|
u32 CalculateRamScriptChecksum(void);
|
|
|
|
void ClearRamScript(void);
|
2018-10-17 04:47:08 +02:00
|
|
|
bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId);
|
|
|
|
const u8 *GetRamScript(u8 objectId, const u8 *script);
|
2019-04-02 19:57:03 +02:00
|
|
|
bool32 ValidateSavedRamScript(void);
|
|
|
|
u8 *GetSavedRamScriptIfValid(void);
|
2019-11-21 04:55:44 +01:00
|
|
|
void InitRamScript_NoObjectEvent(u8 *script, u16 scriptSize);
|
2017-09-07 19:45:32 +02:00
|
|
|
|
2019-03-02 09:18:08 +01:00
|
|
|
// srccmd.h
|
2019-11-01 08:41:55 +01:00
|
|
|
void SetMovingNpcId(u16 npcId);
|
2019-03-02 09:18:08 +01:00
|
|
|
|
2017-09-07 19:45:32 +02:00
|
|
|
#endif // GUARD_SCRIPT_H
|