From 769078498da120a259bf903ea942200bb34b867d Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 3 Nov 2021 16:54:59 -0300 Subject: [PATCH] Added a vanilla-friendly way to check savefile stats --- data/event_scripts.s | 18 ++++++++++++++++++ data/specials.inc | 3 +++ src/field_specials.c | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/data/event_scripts.s b/data/event_scripts.s index bbf25c93cfa0..dbf386c49ea9 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1005,6 +1005,24 @@ Common_EventScript_LegendaryFlewAway:: release end +EventScript_CheckSavefileSizes:: + special CheckSaveBlock1Size + msgbox CheckSavefileSizes_Text_SaveBlock1, MSGBOX_NPC + special CheckSaveBlock2Size + msgbox CheckSavefileSizes_Text_SaveBlock2, MSGBOX_NPC + special CheckPokemonStorageSize + msgbox CheckSavefileSizes_Text_PokemonStorage, MSGBOX_NPC + end + +CheckSavefileSizes_Text_SaveBlock1:: + .string "SaveBlock1 size: {STR_VAR_1}/{STR_VAR_2}$" + +CheckSavefileSizes_Text_SaveBlock2:: + .string "SaveBlock2 size: {STR_VAR_1}/{STR_VAR_2}$" + +CheckSavefileSizes_Text_PokemonStorage:: + .string "{PKMN}Storage size: {STR_VAR_1}/{STR_VAR_2}$" + .include "data/scripts/pc_transfer.inc" .include "data/scripts/questionnaire.inc" .include "data/scripts/abnormal_weather.inc" diff --git a/data/specials.inc b/data/specials.inc index a863b6e13705..67664aff9850 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -535,3 +535,6 @@ gSpecials:: def_special RemoveRecordsWindow def_special CloseDeptStoreElevatorWindow def_special TrySetBattleTowerLinkType + def_special CheckSaveBlock1Size + def_special CheckSaveBlock2Size + def_special CheckPokemonStorageSize diff --git a/src/field_specials.c b/src/field_specials.c index c859401622a4..bf8322c91091 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -4362,3 +4362,28 @@ u8 Script_TryGainNewFanFromCounter(void) { return TryGainNewFanFromCounter(gSpecialVar_0x8004); } + +#include "save.h" // <-- SECTOR_DATA_SIZE is defined there. +void CheckSaveBlock1Size(void) +{ + u32 currSb1Size = (sizeof(struct SaveBlock1)); + u32 maxSb1Size = (SECTOR_DATA_SIZE * 4); + ConvertIntToDecimalStringN(gStringVar1, currSb1Size, STR_CONV_MODE_LEFT_ALIGN, 6); + ConvertIntToDecimalStringN(gStringVar2, maxSb1Size, STR_CONV_MODE_LEFT_ALIGN, 6); +} + +void CheckSaveBlock2Size(void) +{ + u32 currSb2Size = (sizeof(struct SaveBlock2)); + u32 maxSb2Size = SECTOR_DATA_SIZE; + ConvertIntToDecimalStringN(gStringVar1, currSb2Size, STR_CONV_MODE_LEFT_ALIGN, 6); + ConvertIntToDecimalStringN(gStringVar2, maxSb2Size, STR_CONV_MODE_LEFT_ALIGN, 6); +} + +void CheckPokemonStorageSize(void) +{ + u32 currPkmnStorageSize = (sizeof(struct PokemonStorage)); + u32 maxPkmnStorageSize = (SECTOR_DATA_SIZE * 9); + ConvertIntToDecimalStringN(gStringVar1, currPkmnStorageSize, STR_CONV_MODE_LEFT_ALIGN, 6); + ConvertIntToDecimalStringN(gStringVar2, maxPkmnStorageSize, STR_CONV_MODE_LEFT_ALIGN, 6); +}