mirror of
https://github.com/pret/pokefirered.git
synced 2026-05-14 00:01:13 -05:00
Port PSS utility functions
This commit is contained in:
parent
6af8c04d8f
commit
d2b0f36b7d
File diff suppressed because it is too large
Load Diff
22320
asm/pokemon_storage_system_2.s
Normal file
22320
asm/pokemon_storage_system_2.s
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
u8 *GetBoxNamePtr(u8 boxNumber);
|
||||
struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 monPosition);
|
||||
void SetBoxMonNickFromAnyBox(u8 boxId, u8 monPosition, u8 * newNick);
|
||||
void SetBoxMonNickAt(u8 boxId, u8 monPosition, const u8 *newNick);
|
||||
void CompactPartySlots(void);
|
||||
u32 GetBoxMonDataFromAnyBox(u8 boxId, u8 monPosition, u32 request);
|
||||
void sub_808BCB4(u8 boxId, u8 monPosition);
|
||||
u32 GetBoxMonDataAt(u8 boxId, u8 monPosition, s32 request);
|
||||
void ZeroBoxMonAt(u8 boxId, u8 monPosition);
|
||||
void sub_808CE60(void);
|
||||
void ResetPokemonStorageSystem(void);
|
||||
u8 StorageGetCurrentBox(void);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,8 @@ SECTIONS {
|
|||
src/option_menu.o(.text);
|
||||
src/pokedex.o(.text);
|
||||
src/trainer_card.o(.text);
|
||||
asm/pokemon_storage_system.o(.text);
|
||||
src/pokemon_storage_system.o(.text);
|
||||
asm/pokemon_storage_system_2.o(.text);
|
||||
src/pokemon_icon.o(.text);
|
||||
src/script_movement.o(.text);
|
||||
src/fldeff_cut.o(.text);
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ bool8 IsThereRoomInAnyBoxForMorePokemon(void)
|
|||
{
|
||||
for (j = 0; j < IN_BOX_COUNT; j++)
|
||||
{
|
||||
if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SPECIES) == SPECIES_NONE)
|
||||
if (GetBoxMonDataAt(i, j, MON_DATA_SPECIES) == SPECIES_NONE)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1642,7 +1642,7 @@ void ChangeBoxPokemonNickname(void)
|
|||
|
||||
static void ChangeBoxPokemonNickname_CB(void)
|
||||
{
|
||||
SetBoxMonNickFromAnyBox(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2);
|
||||
SetBoxMonNickAt(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2);
|
||||
CB2_ReturnToFieldContinueScriptPlayMapMusic();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3806,7 +3806,7 @@ static bool8 IsPokemonStorageFull(void)
|
|||
|
||||
for (i = 0; i < 14; i++)
|
||||
for (j = 0; j < 30; j++)
|
||||
if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SPECIES) == SPECIES_NONE)
|
||||
if (GetBoxMonDataAt(i, j, MON_DATA_SPECIES) == SPECIES_NONE)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
189
src/pokemon_storage_system.c
Normal file
189
src/pokemon_storage_system.c
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
#include "global.h"
|
||||
#include "gflib.h"
|
||||
#include "pokemon_storage_system.h"
|
||||
#include "constants/species.h"
|
||||
|
||||
enum
|
||||
{
|
||||
WALLPAPER_FOREST,
|
||||
WALLPAPER_CITY,
|
||||
WALLPAPER_DESERT,
|
||||
WALLPAPER_SAVANNA,
|
||||
WALLPAPER_CRAG,
|
||||
WALLPAPER_VOLCANO,
|
||||
WALLPAPER_SNOW,
|
||||
WALLPAPER_CAVE,
|
||||
WALLPAPER_BEACH,
|
||||
WALLPAPER_SEAFLOOR,
|
||||
WALLPAPER_RIVER,
|
||||
WALLPAPER_SKY,
|
||||
WALLPAPER_POLKADOT,
|
||||
WALLPAPER_POKECENTER,
|
||||
WALLPAPER_MACHINE,
|
||||
WALLPAPER_PLAIN,
|
||||
WALLPAPER_COUNT
|
||||
};
|
||||
|
||||
void BackupPokemonStorage(struct PokemonStorage * dest)
|
||||
{
|
||||
*dest = *gPokemonStoragePtr;
|
||||
}
|
||||
|
||||
void RestorePokemonStorage(struct PokemonStorage * src)
|
||||
{
|
||||
*gPokemonStoragePtr = *src;
|
||||
}
|
||||
|
||||
// Functions here are general utility functions.
|
||||
u8 StorageGetCurrentBox(void)
|
||||
{
|
||||
return gPokemonStoragePtr->currentBox;
|
||||
}
|
||||
|
||||
void SetCurrentBox(u8 boxId)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT)
|
||||
gPokemonStoragePtr->currentBox = boxId;
|
||||
}
|
||||
|
||||
u32 GetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, const void *value)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, value);
|
||||
}
|
||||
|
||||
u32 GetCurrentBoxMonData(u8 boxPosition, s32 request)
|
||||
{
|
||||
return GetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request);
|
||||
}
|
||||
|
||||
void SetCurrentBoxMonData(u8 boxPosition, s32 request, const void *value)
|
||||
{
|
||||
SetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request, value);
|
||||
}
|
||||
|
||||
void GetBoxMonNickAt(u8 boxId, u8 boxPosition, u8 *dst)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, dst);
|
||||
else
|
||||
*dst = EOS;
|
||||
}
|
||||
|
||||
void SetBoxMonNickAt(u8 boxId, u8 boxPosition, const u8 *nick)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, nick);
|
||||
}
|
||||
|
||||
u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, dst);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *src)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
gPokemonStoragePtr->boxes[boxId][boxPosition] = *src;
|
||||
}
|
||||
|
||||
void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *dst)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
*dst = gPokemonStoragePtr->boxes[boxId][boxPosition];
|
||||
}
|
||||
|
||||
void CreateBoxMonAt(u8 boxId, u8 boxPosition, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 personality, u8 otIDType, u32 otID)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
{
|
||||
CreateBoxMon(&gPokemonStoragePtr->boxes[boxId][boxPosition],
|
||||
species,
|
||||
level,
|
||||
fixedIV,
|
||||
hasFixedPersonality, personality,
|
||||
otIDType, otID);
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroBoxMonAt(u8 boxId, u8 boxPosition)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
ZeroBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition]);
|
||||
}
|
||||
|
||||
void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
BoxMonToMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], dst);
|
||||
}
|
||||
|
||||
struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 boxPosition)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
||||
return &gPokemonStoragePtr->boxes[boxId][boxPosition];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u8 *GetBoxNamePtr(u8 boxId)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT)
|
||||
return gPokemonStoragePtr->boxNames[boxId];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u8 GetBoxWallpaper(u8 boxId)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT)
|
||||
return gPokemonStoragePtr->boxWallpapers[boxId];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetBoxWallpaper(u8 boxId, u8 wallpaperId)
|
||||
{
|
||||
if (boxId < TOTAL_BOXES_COUNT && wallpaperId < WALLPAPER_COUNT)
|
||||
gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId;
|
||||
}
|
||||
|
||||
s16 sub_808BDE8(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3)
|
||||
{
|
||||
s16 i;
|
||||
s16 adder = -1;
|
||||
|
||||
if (arg3 < 2)
|
||||
adder = 1;
|
||||
|
||||
if (arg3 == 1 || arg3 == 3)
|
||||
{
|
||||
for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder)
|
||||
{
|
||||
if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder)
|
||||
{
|
||||
if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetBoxMonData(&boxMons[i], MON_DATA_IS_EGG))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -752,7 +752,7 @@ void sub_8111438(void)
|
|||
{
|
||||
for (r3 = 0; r3 < 5; r3++)
|
||||
{
|
||||
sub_808BCB4(0, r3);
|
||||
ZeroBoxMonAt(0, r3);
|
||||
}
|
||||
for (r3 = r5; r3 < r9->sanePartyCount; r3++)
|
||||
{
|
||||
|
|
@ -767,9 +767,9 @@ void sub_8111438(void)
|
|||
{
|
||||
for (r6 = 0; r6 < 30; r6++)
|
||||
{
|
||||
if (GetBoxMonDataFromAnyBox(r3, r6, MON_DATA_SANITY_HAS_SPECIES))
|
||||
if (GetBoxMonDataAt(r3, r6, MON_DATA_SANITY_HAS_SPECIES))
|
||||
{
|
||||
sub_808BCB4(r3, r6);
|
||||
ZeroBoxMonAt(r3, r6);
|
||||
r5--;
|
||||
if (r5 == r9->saneBoxesCount)
|
||||
break;
|
||||
|
|
@ -832,7 +832,7 @@ static u16 QuestLog_GetSaneBoxCount(void)
|
|||
{
|
||||
for (j = 0; j < IN_BOX_COUNT; j++)
|
||||
{
|
||||
if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SANITY_HAS_SPECIES))
|
||||
if (GetBoxMonDataAt(i, j, MON_DATA_SANITY_HAS_SPECIES))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user