From 2898fcd54e2a8bcec9e632283ff68316adbaced6 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 4 Jul 2025 13:12:53 -0400 Subject: [PATCH 1/9] Sync coins with pokeplatinum --- asm/include/overlay_01_021EDAFC.inc | 2 +- asm/overlay_01_021EDAFC.s | 2 +- include/coins.h | 54 +++++++++++++++++------------ src/bag_view.c | 2 +- src/coins.c | 16 ++++++--- src/overlay_22.c | 14 ++++---- src/player_data.c | 2 +- src/voltorb_flip/voltorb_flip.c | 14 ++++---- 8 files changed, 60 insertions(+), 46 deletions(-) diff --git a/asm/include/overlay_01_021EDAFC.inc b/asm/include/overlay_01_021EDAFC.inc index 2bb670fdd..dd2e23843 100644 --- a/asm/include/overlay_01_021EDAFC.inc +++ b/asm/include/overlay_01_021EDAFC.inc @@ -44,7 +44,7 @@ .public Save_PlayerData_GetProfile .public Save_PlayerData_GetCoinsAddr .public PlayerProfile_GetMoney -.public CheckCoins +.public Coins_GetValue .public FrontierData_BattlePointAction .public Save_FrontierData_Get .public SaveData_GetPhoneCallPersistentState diff --git a/asm/overlay_01_021EDAFC.s b/asm/overlay_01_021EDAFC.s index 0828c5e85..93a13821b 100644 --- a/asm/overlay_01_021EDAFC.s +++ b/asm/overlay_01_021EDAFC.s @@ -2354,7 +2354,7 @@ _021EECBA: add r4, r0, #0 ldr r0, [r5, #0xc] bl Save_PlayerData_GetCoinsAddr - bl CheckCoins + bl Coins_GetValue add r2, r0, #0 b _021EED04 _021EECD2: diff --git a/include/coins.h b/include/coins.h index e26c1c110..1c6c9d675 100644 --- a/include/coins.h +++ b/include/coins.h @@ -6,44 +6,52 @@ #define MAX_COINS 50000 /* - * void InitCoins(u16 *coins) - * * Initialize the player's coin case * - * @param coins: Pointer to coin case amount + * @param coins: Pointer to coin case amount */ -void InitCoins(u16 *coins); +void Coins_Init(u16 *coins); /* - * u16 CheckCoins(u16* coins) - * * Gets the amount of coins owned * - * @param coins: Pointer to coin case amount + * @param coins: Pointer to coin case amount * * @returns: The amount of coins owned */ -u16 CheckCoins(u16 *coins); +u16 Coins_GetValue(u16 *coins); /* - * BOOL GiveCoins(u16* coins, u16 amount) - * BOOL CanGiveCoins(u16* coins, u16 amount) - * BOOL TakeCoins(u16* coins, u16 amount) + * Adds an amount of coins. It will fail if the + * coin case would overflow. * - * GiveCoins adds an amount of coins. It will fail if the - * coin case would overflow. - * CanGiveCoins follows the same logic but does not modify - * the coin case, instead only reports success or failure. - * TakeCoins deducts the amount of coins. It will fail if - * the coin case would underflow. - * - * @param coins: Pointer to coin case amount - * @param amount: Number of coins to adjust by + * @param coins: Pointer to coin case amount + * @param amount: Number of coins to add * * @returns: TRUE if success, otherwise FALSE */ -BOOL GiveCoins(u16 *coins, u16 amount); -BOOL CanGiveCoins(u16 *coins, u16 amount); -BOOL TakeCoins(u16 *coins, u16 amount); +BOOL Coins_Add(u16 *coins, u16 amount); + +/* + * Checks if a certain amount of coins can be + * added to the coin case without making it overflow. + * + * @param coins: Pointer to coin case amount + * @param amount: Number of coins to add + * + * @returns: TRUE if success, otherwise FALSE + */ +BOOL Coins_CanAdd(u16 *coins, u16 amount); + +/* + * Subtracts an amount of coins. It will fail if the + * coin case would overflow. + * + * @param coins: Pointer to coin case amount + * @param amount: Number of coins to subtract + * + * @returns: TRUE if success, otherwise FALSE + */ +BOOL Coins_Remove(u16 *coins, u16 amount); #endif // POKEHEARTGOLD_COINS_H diff --git a/src/bag_view.c b/src/bag_view.c index a20e5f8ca..deabd6c3f 100644 --- a/src/bag_view.c +++ b/src/bag_view.c @@ -90,7 +90,7 @@ u8 sub_0207791C(BagView *bagView) { } static u16 GetCoinCount(SaveData *saveData) { - return CheckCoins(Save_PlayerData_GetCoinsAddr(saveData)); + return Coins_GetValue(Save_PlayerData_GetCoinsAddr(saveData)); } static u32 GetSealCount(SaveData *saveData) { diff --git a/src/coins.c b/src/coins.c index 28b6a7b9f..f793a5d7b 100644 --- a/src/coins.c +++ b/src/coins.c @@ -2,20 +2,24 @@ #include "global.h" -void InitCoins(u16 *coins) { +void Coins_Init(u16 *coins) +{ *coins = 0; } -u16 CheckCoins(u16 *coins) { +u16 Coins_GetValue(u16 *coins) +{ return *coins; } -BOOL GiveCoins(u16 *coins, u16 amount) { +BOOL Coins_Add(u16 *coins, u16 amount) +{ if (*coins >= MAX_COINS) { return FALSE; } *coins += amount; + if (*coins > MAX_COINS) { *coins = MAX_COINS; } @@ -23,11 +27,13 @@ BOOL GiveCoins(u16 *coins, u16 amount) { return TRUE; } -BOOL CanGiveCoins(u16 *coins, u16 amount) { +BOOL Coins_CanAdd(u16 *coins, u16 amount) +{ return (u32)(amount + *coins) <= MAX_COINS; } -BOOL TakeCoins(u16 *coins, u16 amount) { +BOOL Coins_Remove(u16 *coins, u16 amount) +{ if (*coins < amount) { return FALSE; } diff --git a/src/overlay_22.c b/src/overlay_22.c index 872f5e9d0..4d0b207a0 100644 --- a/src/overlay_22.c +++ b/src/overlay_22.c @@ -33,28 +33,28 @@ BOOL ScrCmd_118(ScriptContext *ctx) { BOOL ScrCmd_GetCoinAmount(ScriptContext *ctx) { u16 *ptr = ScriptGetVarPointer(ctx); - *ptr = CheckCoins(Save_PlayerData_GetCoinsAddr(ctx->fieldSystem->saveData)); + *ptr = Coins_GetValue(Save_PlayerData_GetCoinsAddr(ctx->fieldSystem->saveData)); return FALSE; } BOOL ScrCmd_GiveCoins(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 amount = ScriptGetVar(ctx); - GiveCoins(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); + Coins_Add(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); return FALSE; } BOOL ScrCmd_TakeCoins(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 amount = ScriptGetVar(ctx); - TakeCoins(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); + Coins_Remove(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); return FALSE; } BOOL ScrCmd_569(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 *ptr = ScriptGetVarPointer(ctx); - TakeCoins(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), *ptr); + Coins_Remove(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), *ptr); return FALSE; } @@ -62,7 +62,7 @@ BOOL ScrCmd_CheckCoinsImmediate(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 *ptr = ScriptGetVarPointer(ctx); u32 amount = ScriptReadWord(ctx); - u16 coins = CheckCoins(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData)); + u16 coins = Coins_GetValue(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData)); if (coins < amount) { *ptr = FALSE; } else { @@ -75,7 +75,7 @@ BOOL ScrCmd_CheckCoinsVar(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 *resultPtr = ScriptGetVarPointer(ctx); u16 *amountPtr = ScriptGetVarPointer(ctx); - u16 coins = CheckCoins(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData)); + u16 coins = Coins_GetValue(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData)); if (coins < *amountPtr) { *resultPtr = FALSE; } else { @@ -88,7 +88,7 @@ BOOL ScrCmd_CheckGiveCoins(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 *ptr = ScriptGetVarPointer(ctx); u16 amount = ScriptGetVar(ctx); - *ptr = CanGiveCoins(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); + *ptr = Coins_CanAdd(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); return FALSE; } diff --git a/src/player_data.c b/src/player_data.c index 88f13992e..09f392c00 100644 --- a/src/player_data.c +++ b/src/player_data.c @@ -11,7 +11,7 @@ void Save_PlayerData_Init(PLAYERDATA *player) { Options_Init(&player->options); PlayerProfile_Init(&player->profile); - InitCoins(&player->coins); + Coins_Init(&player->coins); InitIGT(&player->igt); } diff --git a/src/voltorb_flip/voltorb_flip.c b/src/voltorb_flip/voltorb_flip.c index 34b19d9ed..a16813da3 100644 --- a/src/voltorb_flip/voltorb_flip.c +++ b/src/voltorb_flip/voltorb_flip.c @@ -160,7 +160,7 @@ static void RenderCoinPayoutScreen(VoltorbFlipAppWork *work) { GfGfxLoader_LoadScrnDataFromOpenNarc(work->narc, NARC_voltorb_flip_voltorb_flip_00000006_bin, work->bgConfig, GF_BG_LYR_SUB_0, 0, 0, 1, work->heapId); int payout = GamePayout(work->game); - u16 coins = (u32)CheckCoins(work->coins); + u16 coins = (u32)Coins_GetValue(work->coins); PrintCoins(work, COIN_DISPLAY_PAYOUT, payout); PrintCoins(work, COIN_DISPLAY_TOTAL, coins); @@ -271,7 +271,7 @@ static BOOL ov122_021E5B5C(WorkflowEngine *workflow, VoltorbFlipAppWork *work) { } BOOL ov122_021E5BA8(WorkflowEngine *workflow, VoltorbFlipAppWork *work) { - u32 coins = CheckCoins(work->coins); + u32 coins = Coins_GetValue(work->coins); if (coins >= 50000) { // "You’ve gathered 50,000 Coins. You cannot gather..." PrintTextWindow(work, msg_0039_00014, 1); @@ -778,7 +778,7 @@ BOOL ov122_021E6594(WorkflowEngine *workflow, VoltorbFlipAppWork *work) { ov122_021E8E40(work->unk240); int payout = GamePayout(work->game); - u16 coins = (u32)CheckCoins(work->coins); + u16 coins = (u32)Coins_GetValue(work->coins); PrintCoins(work, COIN_DISPLAY_PAYOUT, payout); PrintCoins(work, COIN_DISPLAY_TOTAL, coins); @@ -1026,12 +1026,12 @@ static BOOL AddCoinsToPayout(VoltorbFlipAppWork *work) { static BOOL AwardPayoutToPlayer(VoltorbFlipAppWork *work) { BOOL payoutDeducted; // only TRUE for incremental deduction - u16 coins = (u32)CheckCoins(work->coins); + u16 coins = (u32)Coins_GetValue(work->coins); u16 payout = GamePayout(work->game); if (System_GetTouchNew() || gSystem.newKeys != 0 || coins >= 50000) { DeductFromPayout(work->game, (u8)payout); - GiveCoins(work->coins, payout); + Coins_Add(work->coins, payout); int newTotal = coins + payout; if (newTotal > 50000) { @@ -1046,7 +1046,7 @@ static BOOL AwardPayoutToPlayer(VoltorbFlipAppWork *work) { } if (payoutDeducted) { - GiveCoins(work->coins, 1); + Coins_Add(work->coins, 1); PrintCoins(work, COIN_DISPLAY_PAYOUT, (u16)(payout - 1)); PrintCoins(work, COIN_DISPLAY_TOTAL, (u16)(coins + 1)); if (payout % 4 == 0) { @@ -1981,7 +1981,7 @@ static void ov122_021E8094(OverlayManager *man) { ov122_021E73FC(work); ov122_021E6B38(work); - u16 coins = (u32)CheckCoins(work->coins); + u16 coins = (u32)Coins_GetValue(work->coins); PrintCoins(work, COIN_DISPLAY_TOTAL, coins); ov122_021E7AEC(work); ov122_021E7BD4(work); From 8ee7d3a8f813c03cdd21eb1c64c687b64b7d595f Mon Sep 17 00:00:00 2001 From: ellieplayswow <164806095+ellieplayswow@users.noreply.github.com> Date: Thu, 17 Jul 2025 19:05:13 +0100 Subject: [PATCH 2/9] pokemon: metGender -> otGender --- include/battle/battle.h | 2 +- include/constants/pokemon.h | 2 +- include/pokemon_types_def.h | 2 +- src/battle/overlay_12_0224E4FC.c | 10 +++++----- src/get_egg.c | 6 +++--- src/npc_trade.c | 2 +- src/pokemon.c | 12 ++++++------ src/scrcmd_mystery_gift.c | 2 +- src/trainer_memo.c | 2 +- src/unk_0206D494.c | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/battle/battle.h b/include/battle/battle.h index 9269ed327..54bc74a07 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -258,7 +258,7 @@ typedef struct BattleMon { u8 unk78; u8 msgFlag; u8 gender : 4; - u8 metGender : 4; + u8 otGender : 4; u8 ball; u32 moveEffectFlags; u32 moveEffectFlagsTemp; diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 9c883eacb..beb116aa2 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -315,7 +315,7 @@ #define MON_DATA_POKERUS 154 #define MON_DATA_POKEBALL 155 #define MON_DATA_MET_LEVEL 156 -#define MON_DATA_MET_GENDER 157 +#define MON_DATA_OT_GENDER 157 #define MON_DATA_ENCOUNTER_TYPE 158 // HGSS #define MON_DATA_RESERVED_159 159 #define MON_DATA_STATUS 160 diff --git a/include/pokemon_types_def.h b/include/pokemon_types_def.h index 74f9ec291..a2f762209 100644 --- a/include/pokemon_types_def.h +++ b/include/pokemon_types_def.h @@ -104,7 +104,7 @@ typedef struct { /* 0x1A */ u8 pokerus; /* 0x1B */ u8 pokeball; /* 0x1C */ u8 metLevel : 7; - u8 metGender : 1; + u8 otGender : 1; /* 0x1D */ u8 encounterType; /* 0x1E */ u8 HGSS_Pokeball; /* 0x1F */ s8 mood; diff --git a/src/battle/overlay_12_0224E4FC.c b/src/battle/overlay_12_0224E4FC.c index fd74f36e7..3e357a1a9 100644 --- a/src/battle/overlay_12_0224E4FC.c +++ b/src/battle/overlay_12_0224E4FC.c @@ -118,7 +118,7 @@ void BattleSystem_GetBattleMon(BattleSystem *bsys, BattleContext *ctx, int battl ctx->battleMons[battlerId].exp = GetMonData(mon, MON_DATA_EXPERIENCE, NULL); ctx->battleMons[battlerId].personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); ctx->battleMons[battlerId].otid = GetMonData(mon, MON_DATA_OTID, NULL); - ctx->battleMons[battlerId].metGender = GetMonData(mon, MON_DATA_MET_GENDER, NULL); + ctx->battleMons[battlerId].otGender = GetMonData(mon, MON_DATA_OT_GENDER, NULL); ctx->battleMons[battlerId].ball = BattleSystem_GetMonBall(bsys, mon); @@ -394,7 +394,7 @@ int GetBattlerVar(BattleContext *ctx, int battlerId, u32 id, void *data) { case BMON_DATA_MSG_FLAG: return mon->msgFlag; case BMON_DATA_OT_GENDER: - return mon->metGender; + return mon->otGender; case BMON_DATA_MOVE_EFFECT: return mon->moveEffectFlags; case BMON_DATA_MOVE_EFFECT_TEMP: @@ -638,7 +638,7 @@ void SetBattlerVar(BattleContext *ctx, int battlerId, u32 id, void *data) { mon->msgFlag = *data8; break; case BMON_DATA_OT_GENDER: - mon->metGender = *data8; + mon->otGender = *data8; break; case BMON_DATA_MOVE_EFFECT: mon->moveEffectFlags = *data32; @@ -5253,7 +5253,7 @@ BOOL ov12_02256854(BattleSystem *bsys, BattleContext *ctx) { u32 gender = PlayerProfile_GetTrainerGender(profile); const u16 *name = PlayerProfile_GetNamePtr(profile); - if (trainerId == ctx->battleMons[ctx->battlerIdAttacker].otid && gender == ctx->battleMons[ctx->battlerIdAttacker].metGender && !StringNotEqualN(name, &ctx->battleMons[ctx->battlerIdAttacker].otName[0], PLAYER_NAME_LENGTH)) { + if (trainerId == ctx->battleMons[ctx->battlerIdAttacker].otid && gender == ctx->battleMons[ctx->battlerIdAttacker].otGender && !StringNotEqualN(name, &ctx->battleMons[ctx->battlerIdAttacker].otName[0], PLAYER_NAME_LENGTH)) { return TRUE; } @@ -5269,7 +5269,7 @@ BOOL ov12_022568B0(BattleSystem *bsys, Pokemon *mon) { GetMonData(mon, MON_DATA_OT_NAME, otName); - if (trainerId == GetMonData(mon, MON_DATA_OTID, NULL) && gender == GetMonData(mon, MON_DATA_MET_GENDER, NULL) && !StringNotEqualN(name, otName, PLAYER_NAME_LENGTH)) { + if (trainerId == GetMonData(mon, MON_DATA_OTID, NULL) && gender == GetMonData(mon, MON_DATA_OT_GENDER, NULL) && !StringNotEqualN(name, otName, PLAYER_NAME_LENGTH)) { return TRUE; } diff --git a/src/get_egg.c b/src/get_egg.c index 7dc558dbc..5e4f4e79e 100644 --- a/src/get_egg.c +++ b/src/get_egg.c @@ -657,7 +657,7 @@ void SetEggStats(Pokemon *mon, int species, u8 metLocation, PlayerProfile *profi name = PlayerProfile_GetPlayerName_NewString(profile, HEAP_ID_32); SetMonData(mon, MON_DATA_OT_NAME_2, name); SetMonData(mon, MON_DATA_OTID, &otId); - SetMonData(mon, MON_DATA_MET_GENDER, &gender); + SetMonData(mon, MON_DATA_OT_GENDER, &gender); String_Delete(name); } MonSetTrainerMemo(mon, profile, trainerMemoStrat, eggLocation, HEAP_ID_DEFAULT); @@ -1045,7 +1045,7 @@ static void sub_0206D038(Pokemon *mon, HeapID heapId) { pokerus = GetMonData(mon, MON_DATA_POKERUS, NULL); fateful = GetMonData(mon, MON_DATA_FATEFUL_ENCOUNTER, NULL); GetMonData(mon, MON_DATA_OT_NAME_2, string); - otGender = GetMonData(mon, MON_DATA_MET_GENDER, NULL); + otGender = GetMonData(mon, MON_DATA_OT_GENDER, NULL); otId = GetMonData(mon, MON_DATA_OTID, NULL); form = GetMonData(mon, MON_DATA_FORM, NULL); if (species == SPECIES_MANAPHY && GetMonData(mon, MON_DATA_EGG_MET_LOCATION, NULL) == sub_02017FE4(MAPSECTYPE_EXTERNAL, 1)) { @@ -1071,7 +1071,7 @@ static void sub_0206D038(Pokemon *mon, HeapID heapId) { SetMonData(tmpMon, MON_DATA_POKERUS, &pokerus); SetMonData(tmpMon, MON_DATA_FATEFUL_ENCOUNTER, &fateful); SetMonData(tmpMon, MON_DATA_OT_NAME_2, string); - SetMonData(tmpMon, MON_DATA_MET_GENDER, &otGender); + SetMonData(tmpMon, MON_DATA_OT_GENDER, &otGender); SetMonData(tmpMon, MON_DATA_OTID, &otId); SetMonData(tmpMon, MON_DATA_FORM, &form); metLoc = GetMonData(mon, MON_DATA_EGG_MET_LOCATION, NULL); diff --git a/src/npc_trade.c b/src/npc_trade.c index 914972be9..ece9b424e 100644 --- a/src/npc_trade.c +++ b/src/npc_trade.c @@ -223,7 +223,7 @@ static void _CreateTradeMon(Pokemon *mon, NPCTrade *trade_dat, u32 level, NpcTra SetMonData(mon, MON_DATA_OT_NAME_2, name); String_Delete(name); - SetMonData(mon, MON_DATA_MET_GENDER, &trade_dat->gender); + SetMonData(mon, MON_DATA_OT_GENDER, &trade_dat->gender); SetMonData(mon, MON_DATA_GAME_LANGUAGE, &trade_dat->language); mapsec = MapHeader_GetMapSec(mapno); diff --git a/src/pokemon.c b/src/pokemon.c index 3006c21bd..c49e5c029 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -840,8 +840,8 @@ static u32 GetBoxMonDataInternal(BoxPokemon *boxMon, int attr, void *dest) { case MON_DATA_MET_LEVEL: ret = blockD->metLevel; break; - case MON_DATA_MET_GENDER: - ret = blockD->metGender; + case MON_DATA_OT_GENDER: + ret = blockD->otGender; break; case MON_DATA_ENCOUNTER_TYPE: ret = blockD->encounterType; @@ -1308,8 +1308,8 @@ static void SetBoxMonDataInternal(BoxPokemon *boxMon, int attr, const void *valu case MON_DATA_MET_LEVEL: blockD->metLevel = VALUE(u8); break; - case MON_DATA_MET_GENDER: - blockD->metGender = VALUE(u8); + case MON_DATA_OT_GENDER: + blockD->otGender = VALUE(u8); break; case MON_DATA_ENCOUNTER_TYPE: blockD->encounterType = VALUE(u8); @@ -1676,7 +1676,7 @@ static void AddBoxMonDataInternal(BoxPokemon *boxMon, int attr, int value) { case MON_DATA_POKERUS: case MON_DATA_POKEBALL: case MON_DATA_MET_LEVEL: - case MON_DATA_MET_GENDER: + case MON_DATA_OT_GENDER: case MON_DATA_ENCOUNTER_TYPE: case MON_DATA_RESERVED_159: case MON_DATA_STATUS: @@ -4115,7 +4115,7 @@ BOOL BoxmonBelongsToPlayer(BoxPokemon *boxMon, PlayerProfile *profile, HeapID he u32 myId = PlayerProfile_GetTrainerID(profile); u32 otId = GetBoxMonData(boxMon, MON_DATA_OTID, NULL); u32 myGender = PlayerProfile_GetTrainerGender(profile); - u32 otGender = GetBoxMonData(boxMon, MON_DATA_MET_GENDER, NULL); + u32 otGender = GetBoxMonData(boxMon, MON_DATA_OT_GENDER, NULL); String *r7 = PlayerProfile_GetPlayerName_NewString(profile, heapId); String *r6 = String_New(PLAYER_NAME_LENGTH + 1, heapId); BOOL ret = FALSE; diff --git a/src/scrcmd_mystery_gift.c b/src/scrcmd_mystery_gift.c index a26edf9f5..89050b6e4 100644 --- a/src/scrcmd_mystery_gift.c +++ b/src/scrcmd_mystery_gift.c @@ -292,7 +292,7 @@ static void MGGive_Mon(FieldSystem *fieldSys, MysteryGiftData *unused) { CopyPokemonToPokemon(pokemon, tmpPokemon); SetMonData(tmpPokemon, MON_DATA_OT_NAME_2, playerName); SetMonData(tmpPokemon, MON_DATA_OTID, &trainerId); - SetMonData(tmpPokemon, MON_DATA_MET_GENDER, &gender); + SetMonData(tmpPokemon, MON_DATA_OT_GENDER, &gender); pokemon = tmpPokemon; String_Delete(playerName); } diff --git a/src/trainer_memo.c b/src/trainer_memo.c index ad6790475..c8bf30f51 100644 --- a/src/trainer_memo.c +++ b/src/trainer_memo.c @@ -799,7 +799,7 @@ static void BoxMon_SetOriginalTrainerData(BoxPokemon *boxMon, PlayerProfile *pro String *name = PlayerProfile_GetPlayerName_NewString(profile, heapId); SetBoxMonData(boxMon, MON_DATA_OTID, &otId); - SetBoxMonData(boxMon, MON_DATA_MET_GENDER, &gender); + SetBoxMonData(boxMon, MON_DATA_OT_GENDER, &gender); SetBoxMonData(boxMon, MON_DATA_OT_NAME_2, name); String_Delete(name); diff --git a/src/unk_0206D494.c b/src/unk_0206D494.c index 303c9b039..c690dffcd 100644 --- a/src/unk_0206D494.c +++ b/src/unk_0206D494.c @@ -293,7 +293,7 @@ BOOL MonIsFromTogepiEgg(Pokemon *mon, SaveData *saveData) { if (word != PlayerProfile_GetTrainerID(profile)) { return FALSE; } - u8 byte = GetMonData(mon, MON_DATA_MET_GENDER, NULL); + u8 byte = GetMonData(mon, MON_DATA_OT_GENDER, NULL); if (byte != PlayerProfile_GetTrainerGender(profile)) { return FALSE; } @@ -337,7 +337,7 @@ static BOOL MonIsInGameTradePokeInternal(Pokemon *mon, NPCTrade *trade, NpcTrade if (pid != trade->pid) { return FALSE; } - u8 gender = GetMonData(mon, MON_DATA_MET_GENDER, NULL); + u8 gender = GetMonData(mon, MON_DATA_OT_GENDER, NULL); if (gender != trade->gender) { return FALSE; } From 20f6ea6b576de741f3c3a300917d035abaffdfcf Mon Sep 17 00:00:00 2001 From: ellieplayswow <164806095+ellieplayswow@users.noreply.github.com> Date: Thu, 17 Jul 2025 19:06:49 +0100 Subject: [PATCH 3/9] padding --- include/constants/pokemon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index beb116aa2..2bda57810 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -315,7 +315,7 @@ #define MON_DATA_POKERUS 154 #define MON_DATA_POKEBALL 155 #define MON_DATA_MET_LEVEL 156 -#define MON_DATA_OT_GENDER 157 +#define MON_DATA_OT_GENDER 157 #define MON_DATA_ENCOUNTER_TYPE 158 // HGSS #define MON_DATA_RESERVED_159 159 #define MON_DATA_STATUS 160 From eb698393faddb9fd593a57421a4fe69abb5da5c8 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Mon, 21 Jul 2025 14:31:54 -0400 Subject: [PATCH 4/9] Brace style + Subtract --- include/coins.h | 2 +- src/coins.c | 15 +++++---------- src/overlay_22.c | 4 ++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/include/coins.h b/include/coins.h index 1c6c9d675..5c20ced39 100644 --- a/include/coins.h +++ b/include/coins.h @@ -52,6 +52,6 @@ BOOL Coins_CanAdd(u16 *coins, u16 amount); * * @returns: TRUE if success, otherwise FALSE */ -BOOL Coins_Remove(u16 *coins, u16 amount); +BOOL Coins_Subtract(u16 *coins, u16 amount); #endif // POKEHEARTGOLD_COINS_H diff --git a/src/coins.c b/src/coins.c index f793a5d7b..daca3484d 100644 --- a/src/coins.c +++ b/src/coins.c @@ -2,18 +2,15 @@ #include "global.h" -void Coins_Init(u16 *coins) -{ +void Coins_Init(u16 *coins) { *coins = 0; } -u16 Coins_GetValue(u16 *coins) -{ +u16 Coins_GetValue(u16 *coins) { return *coins; } -BOOL Coins_Add(u16 *coins, u16 amount) -{ +BOOL Coins_Add(u16 *coins, u16 amount) { if (*coins >= MAX_COINS) { return FALSE; } @@ -27,13 +24,11 @@ BOOL Coins_Add(u16 *coins, u16 amount) return TRUE; } -BOOL Coins_CanAdd(u16 *coins, u16 amount) -{ +BOOL Coins_CanAdd(u16 *coins, u16 amount) { return (u32)(amount + *coins) <= MAX_COINS; } -BOOL Coins_Remove(u16 *coins, u16 amount) -{ +BOOL Coins_Subtract(u16 *coins, u16 amount) { if (*coins < amount) { return FALSE; } diff --git a/src/overlay_22.c b/src/overlay_22.c index 4d0b207a0..c1c9f0b2a 100644 --- a/src/overlay_22.c +++ b/src/overlay_22.c @@ -47,14 +47,14 @@ BOOL ScrCmd_GiveCoins(ScriptContext *ctx) { BOOL ScrCmd_TakeCoins(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 amount = ScriptGetVar(ctx); - Coins_Remove(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); + Coins_Subtract(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), amount); return FALSE; } BOOL ScrCmd_569(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; u16 *ptr = ScriptGetVarPointer(ctx); - Coins_Remove(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), *ptr); + Coins_Subtract(Save_PlayerData_GetCoinsAddr(fieldSystem->saveData), *ptr); return FALSE; } From 6b9707208bc70721d4c70e83625d284be27cc8e6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 3 Aug 2025 19:36:39 -0400 Subject: [PATCH 5/9] Make it possible to set trpoke forms --- files/poketool/trainer/trpoke.json.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/poketool/trainer/trpoke.json.txt b/files/poketool/trainer/trpoke.json.txt index deba602c9..c4cf185e0 100644 --- a/files/poketool/trainer/trpoke.json.txt +++ b/files/poketool/trainer/trpoke.json.txt @@ -15,7 +15,7 @@ gTrainerPoke_{{ i }}: .byte {{ poke.difficulty }} .byte {{ poke.genderOverride }} | ({{ poke.abilityOverride }} << 4) .short {{ poke.level }} - .short {{ poke.species }}{% if existsIn(poke, "item") %} + .short {{ poke.species }}{% if existsIn(poke, "form") %} | ({{ poke.form }} << 10){% endif %}{% if existsIn(poke, "item") %} .short {{ poke.item }}{% endif %}{% if existsIn(poke, "moves") %}{% for move in poke.moves %} .short {{ move }}{% endfor %}{% for k in range(4 - length(poke.moves)) %} .short MOVE_NONE{% endfor %}{% endif %} From e7bcc8d7091a345e53476b7ca6cccade3421fb9c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 15 Aug 2025 22:44:41 -0400 Subject: [PATCH 6/9] try to make filesystem depend on arm9 sdk --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c018258d..179d48306 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ sub: ; @$(MAKE) -C sub ROMSPEC := rom.rsf MAKEROM_FLAGS := $(DEFINES) -$(ALL_OBJS): files_for_compile +$(ALL_GAME_OBJS): files_for_compile $(ELF): files_for_compile libsyscall libsyscall: files_for_compile @@ -90,7 +90,9 @@ FX_CONST_H := $(WORK_DIR)/lib/include/nitro/fx/fx_const.h PROJECT_CLEAN_TARGETS += $(FX_CONST_H) $(FX_CONST_H): $(MKFXCONST) $(TOOLSDIR)/gen_fx_consts/fx_const.csv $(MKFXCONST) $@ + sdk: $(FX_CONST_H) +sdk9: $(ALL_LIB_OBJS) $(WORK_DIR)/include/global.h: $(FX_CONST_H) ; # Convenience targets From 29a7b510ee672fad1ddee35e40ca439630e4ca5f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Aug 2025 11:58:36 -0400 Subject: [PATCH 7/9] Enfore lib objs depend on FX_CONST_H --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 179d48306..7542b7189 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ PROJECT_CLEAN_TARGETS += $(FX_CONST_H) $(FX_CONST_H): $(MKFXCONST) $(TOOLSDIR)/gen_fx_consts/fx_const.csv $(MKFXCONST) $@ -sdk: $(FX_CONST_H) +$(ALL_LIB_OBJS): $(FX_CONST_H) sdk9: $(ALL_LIB_OBJS) $(WORK_DIR)/include/global.h: $(FX_CONST_H) ; From 353291625867db3f72bbb8b2d336e55e755157cc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Aug 2025 12:12:53 -0400 Subject: [PATCH 8/9] Untrack autogenned mmodel bins --- files/data/mmodel/mmodel/mmodel_00000280.bin | Bin 68 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000281.bin | Bin 132 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000282.bin | Bin 100 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000283.bin | Bin 20 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000284.bin | Bin 32 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000285.bin | Bin 20 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000286.bin | Bin 68 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000287.bin | Bin 36 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000288.bin | Bin 72 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000289.bin | Bin 52 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000290.bin | Bin 12 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000291.bin | Bin 52 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000292.bin | Bin 40 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000293.bin | Bin 36 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000294.bin | Bin 68 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000295.bin | Bin 56 -> 0 bytes files/data/mmodel/mmodel/mmodel_00000296.bin | Bin 56 -> 0 bytes 17 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 files/data/mmodel/mmodel/mmodel_00000280.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000281.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000282.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000283.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000284.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000285.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000286.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000287.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000288.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000289.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000290.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000291.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000292.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000293.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000294.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000295.bin delete mode 100644 files/data/mmodel/mmodel/mmodel_00000296.bin diff --git a/files/data/mmodel/mmodel/mmodel_00000280.bin b/files/data/mmodel/mmodel/mmodel_00000280.bin deleted file mode 100644 index 5edb326f519ed47a1e822c58566259b882732924..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 68 zcmWe&009;T4h9|u0R|BU2?iMk1qKxc4F(+s0|pZY3kDko1`bXxZXRAfenuu{7FITP Iuoff&0AY{@LuoZX+ E00@~0(EtDd diff --git a/files/data/mmodel/mmodel/mmodel_00000282.bin b/files/data/mmodel/mmodel/mmodel_00000282.bin deleted file mode 100644 index 2a23be6eda89472ee2d49e0c640fe91342507298..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 100 zcmb1O009;T4h9|u0R|BU2?iMk1qKxc4F(+s0|pZY3kDko2L=}g4+bBG0EQ5T2!2?jX^6$UK^21X`EW)@Z!uoRF001%P@#Q*>R diff --git a/files/data/mmodel/mmodel/mmodel_00000288.bin b/files/data/mmodel/mmodel/mmodel_00000288.bin deleted file mode 100644 index 5cc4f97de903ebc623c99eafb41692e2240ed41e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 72 zcmWe+009;T4h9|u0R|BU2?iMk1qKxc4F(+s0|pZY3kDko2L=XCE^Z!PK7Ij4CT12^ LHg*oME@T1#bqE5w diff --git a/files/data/mmodel/mmodel/mmodel_00000289.bin b/files/data/mmodel/mmodel/mmodel_00000289.bin deleted file mode 100644 index bf286ae4d2b836cea83ce36f42db6a56aed4f23b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 52 vcmd;K009;T4h9|u0R|BU2?iMk1qKxc4F(;cFe@872PYRdBNH=N8I%A3DGmWw diff --git a/files/data/mmodel/mmodel/mmodel_00000290.bin b/files/data/mmodel/mmodel/mmodel_00000290.bin deleted file mode 100644 index 428be0d81e3f0831dcf6ff8d671a6d05b0814abc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12 QcmZQ#009;T21W)3002J#2mk;8 diff --git a/files/data/mmodel/mmodel/mmodel_00000291.bin b/files/data/mmodel/mmodel/mmodel_00000291.bin deleted file mode 100644 index f4441114b8859e20d4dddc733afde61cdfaa18cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 52 vcmd;K009;T4h9|u0R|BUQ3go{Sq4Q0RR&F2?jX^6$UK^0|qk&8wMu^4+cMm5QZoQ21W)(CT1pP7FHHkHg-04 Iuoff&0D~L@82|tP diff --git a/files/data/mmodel/mmodel/mmodel_00000295.bin b/files/data/mmodel/mmodel/mmodel_00000295.bin deleted file mode 100644 index 6b7c15f3e1b0402a94c900c203f0310d5e42823f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 56 wcmd;O00A}z9tHsh5e5kcIR+I5H3kg^F9sh5KL!RyCT128!OG0S2383p078cW@&Et; diff --git a/files/data/mmodel/mmodel/mmodel_00000296.bin b/files/data/mmodel/mmodel/mmodel_00000296.bin deleted file mode 100644 index 6b7c15f3e1b0402a94c900c203f0310d5e42823f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 56 wcmd;O00A}z9tHsh5e5kcIR+I5H3kg^F9sh5KL!RyCT128!OG0S2383p078cW@&Et; From abab3c5919d9c3e2cdc495fd4deef3b85fa126df Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sun, 17 Aug 2025 11:05:05 -0700 Subject: [PATCH 9/9] Fix: add -lm to gen_fx_consts Makefile --- tools/gen_fx_consts/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen_fx_consts/Makefile b/tools/gen_fx_consts/Makefile index 9c9d3f4ef..1770743fc 100644 --- a/tools/gen_fx_consts/Makefile +++ b/tools/gen_fx_consts/Makefile @@ -17,7 +17,7 @@ all: $(prog) clean: ; $(RM) -r $(DEPDIR) $(OBJS) $(prog) $(prog).exe $(prog): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -lm -o $@ $^ $(OBJS): %.o: %.c $(OBJS): %.o: %.c $(DEPDIR)/%.d | $(DEPDIR)