Skip to content

Commit

Permalink
Added a vanilla-friendly way to check savefile stats
Browse files Browse the repository at this point in the history
  • Loading branch information
LOuroboros committed Nov 3, 2021
1 parent e14210c commit 7690784
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
18 changes: 18 additions & 0 deletions data/event_scripts.s
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions data/specials.inc
Expand Up @@ -535,3 +535,6 @@ gSpecials::
def_special RemoveRecordsWindow
def_special CloseDeptStoreElevatorWindow
def_special TrySetBattleTowerLinkType
def_special CheckSaveBlock1Size
def_special CheckSaveBlock2Size
def_special CheckPokemonStorageSize
25 changes: 25 additions & 0 deletions src/field_specials.c
Expand Up @@ -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);
}

0 comments on commit 7690784

Please sign in to comment.