From d84e9bed58db84bbb7db568c366bfa803be87139 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 6 Oct 2019 00:48:48 -0700 Subject: Decompile/port new_game --- src/berry_powder.c | 10 ++-- src/mevent.c | 2 +- src/new_game.c | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/scrcmd.c | 14 ++--- src/seagallop.c | 2 +- 5 files changed, 182 insertions(+), 14 deletions(-) create mode 100644 src/new_game.c (limited to 'src') diff --git a/src/berry_powder.c b/src/berry_powder.c index 9b3bbc17f..ad824b24b 100644 --- a/src/berry_powder.c +++ b/src/berry_powder.c @@ -16,7 +16,7 @@ u32 sub_815EE3C(u32 * a0) return *a0 ^ gSaveBlock2Ptr->encryptionKey; } -void sub_815EE54(u32 * a0, u32 a1) +void SetBerryPowder(u32 * a0, u32 a1) { *a0 = gSaveBlock2Ptr->encryptionKey ^ a1; } @@ -48,12 +48,12 @@ bool8 sub_815EEE0(u32 a0) u32 amount = sub_815EE3C(ptr) + a0; if (amount > 99999) { - sub_815EE54(ptr, 99999); + SetBerryPowder(ptr, 99999); return FALSE; } else { - sub_815EE54(ptr, amount); + SetBerryPowder(ptr, amount); return TRUE; } } @@ -66,7 +66,7 @@ bool8 sub_815EF20(u32 a0) else { u32 amount = sub_815EE3C(ptr); - sub_815EE54(ptr, amount - a0); + SetBerryPowder(ptr, amount - a0); return TRUE; } } @@ -79,7 +79,7 @@ bool8 sub_815EF5C(void) else { u32 amount = sub_815EE3C(ptr); - sub_815EE54(ptr, amount - gSpecialVar_0x8004); + SetBerryPowder(ptr, amount - gSpecialVar_0x8004); return TRUE; } } diff --git a/src/mevent.c b/src/mevent.c index d0d7f59aa..b03f1ffe9 100644 --- a/src/mevent.c +++ b/src/mevent.c @@ -769,7 +769,7 @@ void sub_81442CC(struct MEventStruct_Unk1442CC * data) data->unk_14 = 0; for (i = 0; i < 4; i++) data->unk_16[i] = gSaveBlock1Ptr->unk_3120.unk_338[i]; - CopyUnalignedWord(data->unk_4C, gSaveBlock2Ptr->playerTrainerId); + CopyTrainerId(data->unk_4C, gSaveBlock2Ptr->playerTrainerId); StringCopy(data->unk_45, gSaveBlock2Ptr->playerName); for (i = 0; i < 6; i++) data->unk_50[i] = gSaveBlock1Ptr->unk2CA0[i]; diff --git a/src/new_game.c b/src/new_game.c new file mode 100644 index 000000000..d3463f80b --- /dev/null +++ b/src/new_game.c @@ -0,0 +1,168 @@ +#include "global.h" +#include "new_game.h" +#include "random.h" +#include "main.h" +#include "overworld.h" +#include "constants/maps.h" +#include "load_save.h" +#include "item_menu.h" +#include "tm_case.h" +#include "berry_pouch.h" +#include "quest_log.h" +#include "wild_encounter.h" +#include "event_data.h" +#include "string_util.h" +#include "mail_data.h" +#include "play_time.h" +#include "money.h" +#include "battle_records.h" +#include "pokemon_size_record.h" +#include "pokemon_storage_system.h" +#include "roamer.h" +#include "item.h" +#include "player_pc.h" +#include "berry.h" +#include "easy_chat.h" +#include "union_room_chat.h" +#include "mevent.h" +#include "trainer_tower.h" +#include "script.h" +#include "berry_powder.h" +#include "pokemon_jump.h" + +extern const u8 EventScript_ResetAllMapFlags[]; + +// this file's functions +void ResetMiniGamesResults(void); + +// EWRAM vars +EWRAM_DATA bool8 gDifferentSaveFile = FALSE; + +void SetTrainerId(u32 trainerId, u8 *dst) +{ + dst[0] = trainerId; + dst[1] = trainerId >> 8; + dst[2] = trainerId >> 16; + dst[3] = trainerId >> 24; +} + +void CopyTrainerId(u8 *dst, u8 *src) +{ + s32 i; + for (i = 0; i < 4; i++) + dst[i] = src[i]; +} + +/*static*/ void InitPlayerTrainerId(void) +{ + u32 trainerId = (Random() << 0x10) | GetGeneratedTrainerIdLower(); + SetTrainerId(trainerId, gSaveBlock2Ptr->playerTrainerId); +} + +/*static*/ void SetDefaultOptions(void) +{ + gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID; + gSaveBlock2Ptr->optionsWindowFrameType = 0; + gSaveBlock2Ptr->optionsSound = OPTIONS_SOUND_MONO; + gSaveBlock2Ptr->optionsBattleStyle = OPTIONS_BATTLE_STYLE_SHIFT; + gSaveBlock2Ptr->optionsBattleSceneOff = FALSE; + gSaveBlock2Ptr->regionMapZoom = FALSE; + gSaveBlock2Ptr->optionsButtonMode = OPTIONS_BUTTON_MODE_NORMAL; +} + +/*static*/ void ClearPokedexFlags(void) +{ + memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned)); + memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen)); +} + +/*static*/ void sub_80549D4(void) +{ + CpuFill32(0, &gSaveBlock2Ptr->field_B0, (u32) &gSaveBlock2Ptr->mapView - (u32) &gSaveBlock2Ptr->field_B0); +} + +/*static*/ void WarpToPlayersRoom(void) +{ + SetWarpDestination(MAP_GROUP(PALLET_TOWN_PLAYERS_HOUSE_2F), MAP_NUM(PALLET_TOWN_PLAYERS_HOUSE_2F), -1, 6, 6); + WarpIntoMap(); +} + +void Sav2_ClearSetDefault(void) +{ + ClearSav2(); + SetDefaultOptions(); +} + +void ResetMenuAndMonGlobals(void) +{ + gDifferentSaveFile = 0; + ZeroPlayerPartyMons(); + ZeroEnemyPartyMons(); + sub_81089BC(); + ResetTMCaseCursorPos(); + BerryPouch_CursorResetToTop(); + sub_811089C(); + sub_8083214(Random()); + sub_806E6FC(); +} + +void NewGameInitData(void) +{ + u8 rivalName[PLAYER_NAME_LENGTH]; + StringCopy(rivalName, gSaveBlock1Ptr->rivalName); + gDifferentSaveFile = 1; + gSaveBlock2Ptr->encryptionKey = 0; + ZeroPlayerPartyMons(); + ZeroEnemyPartyMons(); + sub_80549D4(); + ClearSav1(); + ClearMailData(); + gSaveBlock2Ptr->specialSaveWarpFlags = 0; + gSaveBlock2Ptr->field_A8 = 0; + gSaveBlock2Ptr->field_AC = 1; + gSaveBlock2Ptr->field_AD = 0; + InitPlayerTrainerId(); + PlayTimeCounter_Reset(); + ClearPokedexFlags(); + sub_806E0D0(); + ResetFameChecker(); + SetMoney(&gSaveBlock1Ptr->money, 3000); + sub_8054E68(); + InitLinkBattleRecords(); + sub_80A0904(); + sub_80A0958(); + sub_806E190(); + gPlayerPartyCount = 0; + ZeroPlayerPartyMons(); + sub_808C7E0(); + ClearRoamerData(); + gSaveBlock1Ptr->registeredItem = 0; + ClearItemSlotsInAllBagPockets(); + sub_80EB658(); + sub_809C794(); + sub_80BDD34(); + sub_8113044(); + copy_strings_to_sav1(); + ResetMiniGamesResults(); + sub_8143D24(); + sub_815D838(); + WarpToPlayersRoom(); + ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags); + StringCopy(gSaveBlock1Ptr->rivalName, rivalName); + sub_815EE0C(); +} + +/*static*/ void ResetMiniGamesResults(void) +{ + CpuFill16(0, &gSaveBlock2Ptr->berryCrush, sizeof(struct BerryCrush)); + SetBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount, 0); + ResetPokeJumpResults(); + CpuFill16(0, &gSaveBlock2Ptr->berryPick, sizeof(struct BerryPickingResults)); +} + + + + + + + \ No newline at end of file diff --git a/src/scrcmd.c b/src/scrcmd.c index bcf8c231d..85059691f 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -733,7 +733,7 @@ bool8 ScrCmd_warp(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); DoWarp(); ResetInitialPlayerAvatarState(); return TRUE; @@ -747,7 +747,7 @@ bool8 ScrCmd_warpsilent(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); DoDiveWarp(); ResetInitialPlayerAvatarState(); return TRUE; @@ -761,7 +761,7 @@ bool8 ScrCmd_warpdoor(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); DoDoorWarp(); ResetInitialPlayerAvatarState(); return TRUE; @@ -778,7 +778,7 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx) if (mapGroup == 0xFF && mapNum == 0xFF) SetWarpDestinationToFixedHoleWarp(x - 7, y - 7); else - Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7); + SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7); DoFallWarp(); ResetInitialPlayerAvatarState(); return TRUE; @@ -792,7 +792,7 @@ bool8 ScrCmd_warpteleport(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_807E59C(); ResetInitialPlayerAvatarState(); return TRUE; @@ -806,7 +806,7 @@ bool8 ScrCmd_warpteleport2(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_805DAE4(GetPlayerFacingDirection()); sub_807E500(); ResetInitialPlayerAvatarState(); @@ -821,7 +821,7 @@ bool8 ScrCmd_setwarp(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); return FALSE; } diff --git a/src/seagallop.c b/src/seagallop.c index e3333ef32..5374f7bac 100644 --- a/src/seagallop.c +++ b/src/seagallop.c @@ -319,7 +319,7 @@ static void Task_SeaGallop_3(void) gSpecialVar_0x8006 = 0; warpInfo = sSeaGallopSpawnTable[gSpecialVar_0x8006]; - Overworld_SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]); + SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]); PlayRainStoppingSoundEffect(); PlaySE(SE_KAIDAN); gFieldCallback = sub_807DF64; -- cgit v1.2.3 From d4ba74fb34c78a6f80e5e51ac3ccc295191e7128 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 6 Oct 2019 09:13:15 -0700 Subject: Fix formatting. --- src/new_game.c | 99 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/new_game.c b/src/new_game.c index d3463f80b..72780c810 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -33,7 +33,7 @@ extern const u8 EventScript_ResetAllMapFlags[]; // this file's functions -void ResetMiniGamesResults(void); +static void ResetMiniGamesResults(void); // EWRAM vars EWRAM_DATA bool8 gDifferentSaveFile = FALSE; @@ -53,13 +53,13 @@ void CopyTrainerId(u8 *dst, u8 *src) dst[i] = src[i]; } -/*static*/ void InitPlayerTrainerId(void) +static void InitPlayerTrainerId(void) { u32 trainerId = (Random() << 0x10) | GetGeneratedTrainerIdLower(); SetTrainerId(trainerId, gSaveBlock2Ptr->playerTrainerId); } -/*static*/ void SetDefaultOptions(void) +static void SetDefaultOptions(void) { gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID; gSaveBlock2Ptr->optionsWindowFrameType = 0; @@ -67,21 +67,21 @@ void CopyTrainerId(u8 *dst, u8 *src) gSaveBlock2Ptr->optionsBattleStyle = OPTIONS_BATTLE_STYLE_SHIFT; gSaveBlock2Ptr->optionsBattleSceneOff = FALSE; gSaveBlock2Ptr->regionMapZoom = FALSE; - gSaveBlock2Ptr->optionsButtonMode = OPTIONS_BUTTON_MODE_NORMAL; + gSaveBlock2Ptr->optionsButtonMode = OPTIONS_BUTTON_MODE_NORMAL; } -/*static*/ void ClearPokedexFlags(void) +static void ClearPokedexFlags(void) { memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned)); memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen)); } -/*static*/ void sub_80549D4(void) +static void sub_80549D4(void) { CpuFill32(0, &gSaveBlock2Ptr->field_B0, (u32) &gSaveBlock2Ptr->mapView - (u32) &gSaveBlock2Ptr->field_B0); } -/*static*/ void WarpToPlayersRoom(void) +static void WarpToPlayersRoom(void) { SetWarpDestination(MAP_GROUP(PALLET_TOWN_PLAYERS_HOUSE_2F), MAP_NUM(PALLET_TOWN_PLAYERS_HOUSE_2F), -1, 6, 6); WarpIntoMap(); @@ -96,73 +96,68 @@ void Sav2_ClearSetDefault(void) void ResetMenuAndMonGlobals(void) { gDifferentSaveFile = 0; - ZeroPlayerPartyMons(); + ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); - sub_81089BC(); + sub_81089BC(); ResetTMCaseCursorPos(); BerryPouch_CursorResetToTop(); sub_811089C(); sub_8083214(Random()); - sub_806E6FC(); + sub_806E6FC(); } void NewGameInitData(void) { - u8 rivalName[PLAYER_NAME_LENGTH]; - StringCopy(rivalName, gSaveBlock1Ptr->rivalName); - gDifferentSaveFile = 1; - gSaveBlock2Ptr->encryptionKey = 0; - ZeroPlayerPartyMons(); + u8 rivalName[PLAYER_NAME_LENGTH]; + + StringCopy(rivalName, gSaveBlock1Ptr->rivalName); + gDifferentSaveFile = 1; + gSaveBlock2Ptr->encryptionKey = 0; + ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); sub_80549D4(); ClearSav1(); ClearMailData(); - gSaveBlock2Ptr->specialSaveWarpFlags = 0; + gSaveBlock2Ptr->specialSaveWarpFlags = 0; gSaveBlock2Ptr->field_A8 = 0; - gSaveBlock2Ptr->field_AC = 1; - gSaveBlock2Ptr->field_AD = 0; - InitPlayerTrainerId(); + gSaveBlock2Ptr->field_AC = 1; + gSaveBlock2Ptr->field_AD = 0; + InitPlayerTrainerId(); PlayTimeCounter_Reset(); ClearPokedexFlags(); - sub_806E0D0(); - ResetFameChecker(); - SetMoney(&gSaveBlock1Ptr->money, 3000); - sub_8054E68(); - InitLinkBattleRecords(); - sub_80A0904(); - sub_80A0958(); - sub_806E190(); - gPlayerPartyCount = 0; + sub_806E0D0(); + ResetFameChecker(); + SetMoney(&gSaveBlock1Ptr->money, 3000); + sub_8054E68(); + InitLinkBattleRecords(); + sub_80A0904(); + sub_80A0958(); + sub_806E190(); + gPlayerPartyCount = 0; ZeroPlayerPartyMons(); - sub_808C7E0(); - ClearRoamerData(); - gSaveBlock1Ptr->registeredItem = 0; - ClearItemSlotsInAllBagPockets(); - sub_80EB658(); - sub_809C794(); - sub_80BDD34(); - sub_8113044(); - copy_strings_to_sav1(); - ResetMiniGamesResults(); - sub_8143D24(); - sub_815D838(); - WarpToPlayersRoom(); - ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags); - StringCopy(gSaveBlock1Ptr->rivalName, rivalName); - sub_815EE0C(); + sub_808C7E0(); + ClearRoamerData(); + gSaveBlock1Ptr->registeredItem = 0; + ClearItemSlotsInAllBagPockets(); + sub_80EB658(); + sub_809C794(); + sub_80BDD34(); + sub_8113044(); + copy_strings_to_sav1(); + ResetMiniGamesResults(); + sub_8143D24(); + sub_815D838(); + WarpToPlayersRoom(); + ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags); + StringCopy(gSaveBlock1Ptr->rivalName, rivalName); + sub_815EE0C(); } -/*static*/ void ResetMiniGamesResults(void) +static void ResetMiniGamesResults(void) { CpuFill16(0, &gSaveBlock2Ptr->berryCrush, sizeof(struct BerryCrush)); SetBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount, 0); ResetPokeJumpResults(); CpuFill16(0, &gSaveBlock2Ptr->berryPick, sizeof(struct BerryPickingResults)); } - - - - - - - \ No newline at end of file + \ No newline at end of file -- cgit v1.2.3 From 0873084a5d143c4e7eab682f7d27a3255ed281b7 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 6 Oct 2019 13:06:13 -0700 Subject: Sync some function names with pokeemerald. --- src/battle_records.c | 12 ++++++------ src/item.c | 2 +- src/new_game.c | 16 ++++++++-------- src/quest_log.c | 2 +- src/trainer_tower.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/battle_records.c b/src/battle_records.c index 3c2032641..38889ca67 100644 --- a/src/battle_records.c +++ b/src/battle_records.c @@ -279,7 +279,7 @@ static void ResetBGPos(void) ChangeBgY(3, 0, 0); } -static void InitLinkBattleRecord(struct LinkBattleRecord * record) +static void ClearLinkBattleRecord(struct LinkBattleRecord *record) { CpuFill16(0, record, sizeof(*record)); record->name[0] = EOS; @@ -289,12 +289,12 @@ static void InitLinkBattleRecord(struct LinkBattleRecord * record) record->draws = 0; } -static void InitLinkBattleRecords_(struct LinkBattleRecords * records) +static void ClearLinkBattleRecords(struct LinkBattleRecords *records) { s32 i; for (i = 0; i < LINK_B_RECORDS_COUNT; i++) - InitLinkBattleRecord(&records->entries[i]); + ClearLinkBattleRecord(&records->entries[i]); SetGameStat(GAME_STAT_LINK_BATTLE_WINS, 0); SetGameStat(GAME_STAT_LINK_BATTLE_LOSSES, 0); SetGameStat(GAME_STAT_LINK_BATTLE_DRAWS, 0); @@ -404,7 +404,7 @@ static void AddOpponentLinkBattleRecord(struct LinkBattleRecords * records, cons { i = LINK_B_RECORDS_COUNT - 1; record = &records->entries[LINK_B_RECORDS_COUNT - 1]; - InitLinkBattleRecord(record); + ClearLinkBattleRecord(record); StringCopyN(record->name, namebuf, OT_NAME_LENGTH); record->trainerId = trainerId; } @@ -412,9 +412,9 @@ static void AddOpponentLinkBattleRecord(struct LinkBattleRecords * records, cons SortLinkBattleRecords(records); } -void InitLinkBattleRecords(void) +void ClearPlayerLinkBattleRecords(void) { - InitLinkBattleRecords_(&gSaveBlock2Ptr->linkBattleRecords); + ClearLinkBattleRecords(&gSaveBlock2Ptr->linkBattleRecords); } static void IncTrainerCardWinCount(s32 battlerId) diff --git a/src/item.c b/src/item.c index 3f33f464d..42dfd334e 100644 --- a/src/item.c +++ b/src/item.c @@ -326,7 +326,7 @@ void ClearPCItemSlots(void) } } -void ClearItemSlotsInAllBagPockets(void) +void ClearBag(void) { u16 i; diff --git a/src/new_game.c b/src/new_game.c index 72780c810..3b10d7ddd 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -125,23 +125,23 @@ void NewGameInitData(void) InitPlayerTrainerId(); PlayTimeCounter_Reset(); ClearPokedexFlags(); - sub_806E0D0(); + InitEventData(); ResetFameChecker(); SetMoney(&gSaveBlock1Ptr->money, 3000); - sub_8054E68(); - InitLinkBattleRecords(); + ResetGameStats(); + ClearPlayerLinkBattleRecords(); sub_80A0904(); sub_80A0958(); sub_806E190(); gPlayerPartyCount = 0; ZeroPlayerPartyMons(); - sub_808C7E0(); + ResetPokemonStorageSystem(); ClearRoamerData(); gSaveBlock1Ptr->registeredItem = 0; - ClearItemSlotsInAllBagPockets(); - sub_80EB658(); + ClearBag(); + NewGameInitPCItems(); sub_809C794(); - sub_80BDD34(); + InitEasyChatPhrases(); sub_8113044(); copy_strings_to_sav1(); ResetMiniGamesResults(); @@ -150,7 +150,7 @@ void NewGameInitData(void) WarpToPlayersRoom(); ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags); StringCopy(gSaveBlock1Ptr->rivalName, rivalName); - sub_815EE0C(); + ResetTrainerTowerResults(); } static void ResetMiniGamesResults(void) diff --git a/src/quest_log.c b/src/quest_log.c index 8b9ee9395..065b42cef 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -986,7 +986,7 @@ void sub_8111368(void) { gUnknown_203ADFA = 2; sub_806E6FC(); - ClearItemSlotsInAllBagPockets(); + ClearBag(); ClearPCItemSlots(); if (sub_8110AC8() == 1) { diff --git a/src/trainer_tower.c b/src/trainer_tower.c index da3cf6dda..17f6b9e09 100644 --- a/src/trainer_tower.c +++ b/src/trainer_tower.c @@ -1458,7 +1458,7 @@ void sub_815EDF4(u32 * counter, u32 value) *counter = value ^ gSaveBlock2Ptr->encryptionKey; } -void sub_815EE0C(void) +void ResetTrainerTowerResults(void) { s32 i; -- cgit v1.2.3 From 52d40061ecdb2b47da10083c0359e06df5470eb1 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Sun, 6 Oct 2019 14:47:08 -0700 Subject: Resolve review suggestions. --- src/berry_powder.c | 14 +++++++------- src/mevent.c | 2 +- src/mevent_server.c | 2 +- src/mystery_event_script.c | 2 +- src/new_game.c | 10 ++++------ 5 files changed, 14 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/berry_powder.c b/src/berry_powder.c index ad824b24b..992e82522 100644 --- a/src/berry_powder.c +++ b/src/berry_powder.c @@ -11,7 +11,7 @@ EWRAM_DATA u8 gUnknown_203F464 = 0; -u32 sub_815EE3C(u32 * a0) +u32 DecryptBerryPowder(u32 * a0) { return *a0 ^ gSaveBlock2Ptr->encryptionKey; } @@ -28,7 +28,7 @@ void sub_815EE6C(u32 a0) bool8 sub_815EE88(u32 a0) { - if (sub_815EE3C(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < a0) + if (DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < a0) return FALSE; else return TRUE; @@ -36,7 +36,7 @@ bool8 sub_815EE88(u32 a0) bool8 sub_815EEB0(void) { - if (sub_815EE3C(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < gSpecialVar_0x8004) + if (DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < gSpecialVar_0x8004) return FALSE; else return TRUE; @@ -45,7 +45,7 @@ bool8 sub_815EEB0(void) bool8 sub_815EEE0(u32 a0) { u32 * ptr = &gSaveBlock2Ptr->berryCrush.berryPowderAmount; - u32 amount = sub_815EE3C(ptr) + a0; + u32 amount = DecryptBerryPowder(ptr) + a0; if (amount > 99999) { SetBerryPowder(ptr, 99999); @@ -65,7 +65,7 @@ bool8 sub_815EF20(u32 a0) return FALSE; else { - u32 amount = sub_815EE3C(ptr); + u32 amount = DecryptBerryPowder(ptr); SetBerryPowder(ptr, amount - a0); return TRUE; } @@ -78,7 +78,7 @@ bool8 sub_815EF5C(void) return FALSE; else { - u32 amount = sub_815EE3C(ptr); + u32 amount = DecryptBerryPowder(ptr); SetBerryPowder(ptr, amount - gSpecialVar_0x8004); return TRUE; } @@ -86,7 +86,7 @@ bool8 sub_815EF5C(void) u32 GetBerryPowder(void) { - return sub_815EE3C(&gSaveBlock2Ptr->berryCrush.berryPowderAmount); + return DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount); } void sub_815EFBC(u8 windowId, u32 powder, u8 x, u8 y, u8 speed) diff --git a/src/mevent.c b/src/mevent.c index b03f1ffe9..78880c228 100644 --- a/src/mevent.c +++ b/src/mevent.c @@ -588,7 +588,7 @@ void DestroyWonderCard(void) ClearRamScript(); sub_806E2D0(); sub_806E370(); - sub_80E7524(gSaveBlock2Ptr->unk_4A0); + sub_80E7524(gSaveBlock2Ptr->unk_B0.field_3F0); } bool32 sub_8143F68(const struct MEventBuffer_32E0_Sub * data) diff --git a/src/mevent_server.c b/src/mevent_server.c index 1c2dc4ced..4e2b7280d 100644 --- a/src/mevent_server.c +++ b/src/mevent_server.c @@ -226,7 +226,7 @@ static u32 ish_mainseq_4(struct mevent_client * svr) sub_8069EA4(svr->recvBuffer, 1000); break; case 18: - memcpy(gSaveBlock2Ptr->unk_4A0, svr->recvBuffer, 0xbc); + memcpy(gSaveBlock2Ptr->unk_B0.field_3F0, svr->recvBuffer, 0xbc); ValidateEReaderTrainer(); break; case 21: diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index 70566ca58..89df1ee34 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -281,7 +281,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx) bool8 MEScrCmd_addtrainer(struct ScriptContext *ctx) { u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]; - memcpy(gSaveBlock2Ptr->unk_4A0, (void *)data, 0xBC); + memcpy(gSaveBlock2Ptr->unk_B0.field_3F0, (void *)data, 0xBC); ValidateEReaderTrainer(); StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNewTrainer); ctx->data[2] = 2; diff --git a/src/new_game.c b/src/new_game.c index 3b10d7ddd..58deac9b9 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -29,8 +29,7 @@ #include "script.h" #include "berry_powder.h" #include "pokemon_jump.h" - -extern const u8 EventScript_ResetAllMapFlags[]; +#include "event_scripts.h" // this file's functions static void ResetMiniGamesResults(void); @@ -78,7 +77,7 @@ static void ClearPokedexFlags(void) static void sub_80549D4(void) { - CpuFill32(0, &gSaveBlock2Ptr->field_B0, (u32) &gSaveBlock2Ptr->mapView - (u32) &gSaveBlock2Ptr->field_B0); + CpuFill32(0, &gSaveBlock2Ptr->unk_B0, sizeof(gSaveBlock2Ptr->unk_B0)); } static void WarpToPlayersRoom(void) @@ -95,7 +94,7 @@ void Sav2_ClearSetDefault(void) void ResetMenuAndMonGlobals(void) { - gDifferentSaveFile = 0; + gDifferentSaveFile = FALSE; ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); sub_81089BC(); @@ -111,7 +110,7 @@ void NewGameInitData(void) u8 rivalName[PLAYER_NAME_LENGTH]; StringCopy(rivalName, gSaveBlock1Ptr->rivalName); - gDifferentSaveFile = 1; + gDifferentSaveFile = TRUE; gSaveBlock2Ptr->encryptionKey = 0; ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); @@ -160,4 +159,3 @@ static void ResetMiniGamesResults(void) ResetPokeJumpResults(); CpuFill16(0, &gSaveBlock2Ptr->berryPick, sizeof(struct BerryPickingResults)); } - \ No newline at end of file -- cgit v1.2.3