Callnative functions take ScriptContext argument (#3294)

This commit is contained in:
Martin Griffin 2023-09-11 07:58:57 +01:00 committed by GitHub
commit 327fda776a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View File

@ -1807,7 +1807,7 @@ static void DebugAction_Util_PoisonMons(u8 taskId)
PlaySE(SE_FIELD_POISON); PlaySE(SE_FIELD_POISON);
} }
void CheckSaveBlock1Size(void) void CheckSaveBlock1Size(struct ScriptContext *ctx)
{ {
u32 currSb1Size = sizeof(struct SaveBlock1); u32 currSb1Size = sizeof(struct SaveBlock1);
u32 maxSb1Size = SECTOR_DATA_SIZE * (SECTOR_ID_SAVEBLOCK1_END - SECTOR_ID_SAVEBLOCK1_START + 1); u32 maxSb1Size = SECTOR_DATA_SIZE * (SECTOR_ID_SAVEBLOCK1_END - SECTOR_ID_SAVEBLOCK1_START + 1);
@ -1815,7 +1815,7 @@ void CheckSaveBlock1Size(void)
ConvertIntToDecimalStringN(gStringVar2, maxSb1Size, STR_CONV_MODE_LEFT_ALIGN, 6); ConvertIntToDecimalStringN(gStringVar2, maxSb1Size, STR_CONV_MODE_LEFT_ALIGN, 6);
} }
void CheckSaveBlock2Size(void) void CheckSaveBlock2Size(struct ScriptContext *ctx)
{ {
u32 currSb2Size = (sizeof(struct SaveBlock2)); u32 currSb2Size = (sizeof(struct SaveBlock2));
u32 maxSb2Size = SECTOR_DATA_SIZE; u32 maxSb2Size = SECTOR_DATA_SIZE;
@ -1823,7 +1823,7 @@ void CheckSaveBlock2Size(void)
ConvertIntToDecimalStringN(gStringVar2, maxSb2Size, STR_CONV_MODE_LEFT_ALIGN, 6); ConvertIntToDecimalStringN(gStringVar2, maxSb2Size, STR_CONV_MODE_LEFT_ALIGN, 6);
} }
void CheckPokemonStorageSize(void) void CheckPokemonStorageSize(struct ScriptContext *ctx)
{ {
u32 currPkmnStorageSize = sizeof(struct PokemonStorage); u32 currPkmnStorageSize = sizeof(struct PokemonStorage);
u32 maxPkmnStorageSize = SECTOR_DATA_SIZE * (SECTOR_ID_PKMN_STORAGE_END - SECTOR_ID_PKMN_STORAGE_START + 1); u32 maxPkmnStorageSize = SECTOR_DATA_SIZE * (SECTOR_ID_PKMN_STORAGE_END - SECTOR_ID_PKMN_STORAGE_START + 1);

View File

@ -914,7 +914,7 @@ static void Task_UseRepel(u8 taskId)
DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage); DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage);
} }
} }
void HandleUseExpiredRepel(void) void HandleUseExpiredRepel(struct ScriptContext *ctx)
{ {
#if VAR_LAST_REPEL_LURE_USED != 0 #if VAR_LAST_REPEL_LURE_USED != 0
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(VAR_LAST_REPEL_LURE_USED))); VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(VAR_LAST_REPEL_LURE_USED)));
@ -959,7 +959,7 @@ static void Task_UseLure(u8 taskId)
} }
} }
void HandleUseExpiredLure(void) void HandleUseExpiredLure(struct ScriptContext *ctx)
{ {
#if VAR_LAST_REPEL_LURE_USED != 0 #if VAR_LAST_REPEL_LURE_USED != 0
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(VAR_LAST_REPEL_LURE_USED)) | REPEL_LURE_MASK); VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(VarGet(VAR_LAST_REPEL_LURE_USED)) | REPEL_LURE_MASK);

View File

@ -51,7 +51,7 @@
#include "constants/event_objects.h" #include "constants/event_objects.h"
typedef u16 (*SpecialFunc)(void); typedef u16 (*SpecialFunc)(void);
typedef void (*NativeFunc)(void); typedef void (*NativeFunc)(struct ScriptContext *ctx);
EWRAM_DATA const u8 *gRamScriptRetAddr = NULL; EWRAM_DATA const u8 *gRamScriptRetAddr = NULL;
static EWRAM_DATA u32 sAddressOffset = 0; // For relative addressing in vgoto etc., used by saved scripts (e.g. Mystery Event) static EWRAM_DATA u32 sAddressOffset = 0; // For relative addressing in vgoto etc., used by saved scripts (e.g. Mystery Event)
@ -136,7 +136,7 @@ bool8 ScrCmd_callnative(struct ScriptContext *ctx)
{ {
NativeFunc func = (NativeFunc)ScriptReadWord(ctx); NativeFunc func = (NativeFunc)ScriptReadWord(ctx);
func(); func(ctx);
return FALSE; return FALSE;
} }

View File

@ -118,7 +118,7 @@ static void DrawMultichoiceMenu(u8 left, u8 top, u8 multichoiceId, bool8 ignoreB
} }
#if I_REPEL_LURE_MENU == TRUE #if I_REPEL_LURE_MENU == TRUE
void TryDrawRepelMenu(void) void TryDrawRepelMenu(struct ScriptContext *ctx)
{ {
static const u16 repelItems[] = {ITEM_REPEL, ITEM_SUPER_REPEL, ITEM_MAX_REPEL}; static const u16 repelItems[] = {ITEM_REPEL, ITEM_SUPER_REPEL, ITEM_MAX_REPEL};
struct MenuAction menuItems[ARRAY_COUNT(repelItems) + 1] = {NULL}; struct MenuAction menuItems[ARRAY_COUNT(repelItems) + 1] = {NULL};
@ -144,7 +144,7 @@ void TryDrawRepelMenu(void)
gSpecialVar_Result = (count > 1); gSpecialVar_Result = (count > 1);
} }
void HandleRepelMenuChoice(void) void HandleRepelMenuChoice(struct ScriptContext *ctx)
{ {
gSpecialVar_0x8004 = VarGet(VAR_0x8004 + gSpecialVar_Result); // Get item Id; gSpecialVar_0x8004 = VarGet(VAR_0x8004 + gSpecialVar_Result); // Get item Id;
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_0x8004)); VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_0x8004));
@ -153,7 +153,7 @@ void HandleRepelMenuChoice(void)
#endif #endif
} }
void TryDrawLureMenu(void) void TryDrawLureMenu(struct ScriptContext *ctx)
{ {
static const u16 lureItems[] = {ITEM_LURE, ITEM_SUPER_LURE, ITEM_MAX_LURE}; static const u16 lureItems[] = {ITEM_LURE, ITEM_SUPER_LURE, ITEM_MAX_LURE};
struct MenuAction menuItems[ARRAY_COUNT(lureItems) + 1] = {NULL}; struct MenuAction menuItems[ARRAY_COUNT(lureItems) + 1] = {NULL};
@ -180,7 +180,7 @@ void TryDrawLureMenu(void)
gSpecialVar_Result = (count > 1); gSpecialVar_Result = (count > 1);
} }
void HandleLureMenuChoice(void) void HandleLureMenuChoice(struct ScriptContext *ctx)
{ {
gSpecialVar_0x8004 = VarGet(VAR_0x8004 + gSpecialVar_Result); // Get item Id; gSpecialVar_0x8004 = VarGet(VAR_0x8004 + gSpecialVar_Result); // Get item Id;
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_0x8004) | REPEL_LURE_MASK); VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_0x8004) | REPEL_LURE_MASK);