summaryrefslogtreecommitdiff
path: root/src/new_game.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/new_game.c')
-rw-r--r--src/new_game.c168
1 files changed, 168 insertions, 0 deletions
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