merge pokemon_storage_system files

This commit is contained in:
cawtds 2025-02-15 12:53:42 +01:00
parent 52f9fd0a92
commit f5008263b3
13 changed files with 9323 additions and 9394 deletions

View File

@ -20,27 +20,6 @@ ROWS 0 1 2 3 4 5
24 25 26 27 28 29
*/
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_STARS,
WALLPAPER_POKECENTER,
WALLPAPER_TILES,
WALLPAPER_SIMPLE,
WALLPAPER_COUNT
};
#define MAX_DEFAULT_WALLPAPER WALLPAPER_SAVANNA
struct PokemonStorage
{
@ -65,4 +44,12 @@ u8 StorageGetCurrentBox(void);
void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, u8 *buffer, s32 bytesToBuffer);
u32 CountPartyNonEggMons(void);
void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon * dst);
void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon * src);
void SetCurrentBoxMonData(u8 boxPosition, s32 request, const void *value);
void EnterPokeStorage(u8 boxOption);
u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst);
u32 GetCurrentBoxMonData(u8 boxPosition, s32 request);
#endif // GUARD_POKEMON_STORAGE_SYSTEM_H

View File

@ -1,576 +0,0 @@
#ifndef GUARD_POKEMON_STORAGE_SYSTEM_INTERNAL_H
#define GUARD_POKEMON_STORAGE_SYSTEM_INTERNAL_H
#include "pokemon_storage_system.h"
#include "mon_markings.h"
#include "quest_log.h"
// The maximum number of Pokémon icons that can appear on-screen.
// By default the limit is 40 (though in practice only 37 can be).
#define MAX_MON_ICONS (IN_BOX_COUNT + PARTY_SIZE + 1 >= 40 ? IN_BOX_COUNT + PARTY_SIZE + 1 : 40)
// The maximum number of item icons that can appear on-screen while
// moving held items. 1 in the cursor, and 2 more while switching
// between 2 Pokémon with held items
#define MAX_ITEM_ICONS 3
enum
{
#if OW_PC_MOVE_ORDER <= GEN_3
OPTION_WITHDRAW,
OPTION_DEPOSIT,
OPTION_MOVE_MONS,
#elif OW_PC_MOVE_ORDER >= GEN_4 && OW_PC_MOVE_ORDER <= GEN_6_XY
OPTION_DEPOSIT,
OPTION_WITHDRAW,
OPTION_MOVE_MONS,
#elif OW_PC_MOVE_ORDER >= GEN_7
OPTION_MOVE_MONS,
OPTION_DEPOSIT,
OPTION_WITHDRAW,
#endif
OPTION_MOVE_ITEMS,
OPTION_EXIT,
OPTIONS_COUNT
};
enum
{
MENU_TEXT_CANCEL,
MENU_TEXT_STORE,
MENU_TEXT_WITHDRAW,
MENU_TEXT_MOVE,
MENU_TEXT_SHIFT,
MENU_TEXT_PLACE,
MENU_TEXT_SUMMARY,
MENU_TEXT_RELEASE,
MENU_TEXT_MARK,
MENU_TEXT_JUMP,
MENU_TEXT_WALLPAPER,
MENU_TEXT_NAME,
MENU_TEXT_TAKE,
MENU_TEXT_GIVE,
MENU_TEXT_GIVE2,
MENU_TEXT_SWITCH,
MENU_TEXT_BAG,
MENU_TEXT_INFO,
MENU_TEXT_SCENERY_1,
MENU_TEXT_SCENERY_2,
MENU_TEXT_SCENERY_3,
MENU_TEXT_ETCETERA,
MENU_TEXT_FOREST,
MENU_TEXT_CITY,
MENU_TEXT_DESERT,
MENU_TEXT_SAVANNA,
MENU_TEXT_CRAG,
MENU_TEXT_VOLCANO,
MENU_TEXT_SNOW,
MENU_TEXT_CAVE,
MENU_TEXT_BEACH,
MENU_TEXT_SEAFLOOR,
MENU_TEXT_RIVER,
MENU_TEXT_SKY,
MENU_TEXT_POLKADOT,
MENU_TEXT_POKECENTER,
MENU_TEXT_MACHINE,
MENU_TEXT_SIMPLE,
};
// Return IDs for input handlers
enum {
INPUT_NONE,
INPUT_MOVE_CURSOR,
INPUT_2, // Unused
INPUT_3, // Unused
INPUT_CLOSE_BOX,
INPUT_SHOW_PARTY,
INPUT_HIDE_PARTY,
INPUT_BOX_OPTIONS,
INPUT_IN_MENU,
INPUT_SCROLL_RIGHT,
INPUT_SCROLL_LEFT,
INPUT_DEPOSIT,
INPUT_WITHDRAW,
INPUT_MOVE_MON,
INPUT_SHIFT_MON,
INPUT_PLACE_MON,
INPUT_TAKE_ITEM,
INPUT_GIVE_ITEM,
INPUT_SWITCH_ITEMS,
INPUT_PRESSED_B,
INPUT_MULTIMOVE_START,
INPUT_MULTIMOVE_CHANGE_SELECTION,
INPUT_MULTIMOVE_SINGLE,
INPUT_MULTIMOVE_GRAB_SELECTION,
INPUT_MULTIMOVE_UNABLE,
INPUT_MULTIMOVE_MOVE_MONS,
INPUT_MULTIMOVE_PLACE_MONS,
};
enum
{
RELEASE_MON_NOT_ALLOWED,
RELEASE_MON_ALLOWED,
RELEASE_MON_UNDETERMINED = -1,
};
enum
{
MODE_PARTY,
MODE_BOX,
MODE_MOVE,
};
enum
{
CURSOR_AREA_IN_BOX,
CURSOR_AREA_IN_PARTY,
CURSOR_AREA_BOX_TITLE,
CURSOR_AREA_BUTTONS, // Party Pokemon and Close Box
};
#define CURSOR_AREA_IN_HAND CURSOR_AREA_BOX_TITLE // Alt name for cursor area used by Move Items
// IDs for InitMonPlaceChange
enum
{
CHANGE_GRAB,
CHANGE_PLACE,
CHANGE_SHIFT,
};
// IDs for the main functions for moving multiple Pokémon.
// Given as arguments to MultiMove_SetFunction
enum
{
MULTIMOVE_START,
MULTIMOVE_SINGLE,
MULTIMOVE_CHANGE_SELECTION,
MULTIMOVE_GRAB_SELECTION,
MULTIMOVE_MOVE_MONS,
MULTIMOVE_PLACE_MONS,
};
enum
{
PALTAG_MON_ICON_0 = 56000,
PALTAG_MON_ICON_1, // Used implicitly in CreateMonIconSprite
PALTAG_MON_ICON_2, // Used implicitly in CreateMonIconSprite
PALTAG_3, // Unused
PALTAG_4, // Unused
PALTAG_5, // Unused
PALTAG_DISPLAY_MON,
PALTAG_MISC_1, // Used by cursor in multimove mode, choose box menu popup
PALTAG_MARKING_COMBO,
PALTAG_BOX_TITLE,
PALTAG_MISC_2, // Used by waveforms, cursor in normal mode, cursor shadow, box scroll arrows
PALTAG_ITEM_ICON_0,
PALTAG_ITEM_ICON_1, // Used implicitly in CreateItemIconSprites
PALTAG_ITEM_ICON_2, // Used implicitly in CreateItemIconSprites
PALTAG_MARKING_MENU,
};
enum
{
GFXTAG_CURSOR,
GFXTAG_CURSOR_SHADOW,
GFXTAG_DISPLAY_MON,
GFXTAG_BOX_TITLE,
GFXTAG_BOX_TITLE_ALT,
GFXTAG_WAVEFORM,
GFXTAG_BOX_SCROLL_ARROW,
GFXTAG_ITEM_ICON_0,
GFXTAG_ITEM_ICON_1, // Used implicitly in CreateItemIconSprites
GFXTAG_ITEM_ICON_2, // Used implicitly in CreateItemIconSprites
GFXTAG_CHOOSE_BOX_MENU_CENTER,
GFXTAG_CHOOSE_BOX_MENU_CORNERS, // Used implicitly in LoadChooseBoxMenuGfx
GFXTAG_12, // Unused
GFXTAG_MARKING_MENU,
GFXTAG_14, // Unused
GFXTAG_15, // Unused
GFXTAG_MARKING_COMBO,
GFXTAG_17, // Unused
GFXTAG_MON_ICON,
};
// Special box ids for the choose box menu
#define BOXID_NONE_CHOSEN 200
#define BOXID_CANCELED 201
enum {
CURSOR_ANIM_BOUNCE,
CURSOR_ANIM_STILL,
CURSOR_ANIM_OPEN,
CURSOR_ANIM_FIST,
};
enum
{
RELEASE_ANIM_RELEASE,
RELEASE_ANIM_COME_BACK,
};
// IDs for the item icons affine anims
enum
{
ITEM_ANIM_NONE,
ITEM_ANIM_APPEAR,
ITEM_ANIM_DISAPPEAR,
ITEM_ANIM_PICK_UP,
ITEM_ANIM_PUT_DOWN,
ITEM_ANIM_PUT_AWAY,
ITEM_ANIM_LARGE,
};
struct Wallpaper
{
const u32 *tiles;
const u32 *tileMap;
const u16 *palettes;
};
struct StorageMessage
{
const u8 *text;
u8 format;
};
struct ChooseBoxMenu
{
struct Sprite *menuSprite;
struct Sprite *menuCornerSprites[4];
u32 unused1[3];
struct Sprite *arrowSprites[2];
u8 buffer[0x200]; // passed but not used
u8 strbuf[20];
bool32 loadedPalette;
u16 tileTag;
u16 paletteTag;
u8 curBox;
u8 unused3;
u8 subpriority;
};
struct StorageMenu
{
const u8 *text;
int textId;
};
struct UnkUtilData
{
const u8 *src;
u8 *dest;
u16 size;
u16 unk;
u16 height;
void (*func)(struct UnkUtilData *data);
};
struct UnkUtil
{
struct UnkUtilData *data;
u8 numActive;
u8 max;
};
struct PokeStorageItemIcon
{
struct Sprite *sprite;
u8 *tiles;
u16 palIndex;
u8 cursorArea;
u8 cursorPos;
u8 active;
};
struct PokemonStorageSystemData
{
u8 state;
u8 boxOption;
u8 screenChangeType;
bool8 isReopening;
u8 taskId;
struct UnkUtil unkUtil;
struct UnkUtilData unkUtilData[8];
u16 partyMenuTilemapBuffer[0x108];
u16 partyMenuUnused1; // Never read
u16 partyMenuY;
u8 partyMenuUnused2; // Unused
u8 partyMenuMoveTimer;
u8 showPartyMenuState;
bool8 closeBoxFlashing;
u8 closeBoxFlashTimer;
bool8 closeBoxFlashState;
s16 newCurrBoxId;
u16 bg2_X;
s16 scrollSpeed;
u16 scrollTimer;
u8 wallpaperOffset;
u8 scrollUnused1; // Never read
u8 scrollToBoxIdUnused; // Never read
u16 scrollUnused2; // Never read
s16 scrollDirectionUnused; // Never read.
u16 scrollUnused3; // Never read
u16 scrollUnused4; // Never read
u16 scrollUnused5; // Never read
u16 scrollUnused6; // Never read
u8 filler1[22];
u8 boxTitleTiles[512];
u8 boxTitleUnused[512];
u8 boxTitleCycleId;
u8 wallpaperLoadState; // Written to, but never read.
u8 wallpaperLoadBoxId;
s8 wallpaperLoadDir;
u16 boxTitlePal[16];
u16 boxTitlePalOffset;
u16 boxTitleAltPalOffset;
struct Sprite *curBoxTitleSprites[2];
struct Sprite *nextBoxTitleSprites[2];
struct Sprite *arrowSprites[2];
u32 wallpaperPalBits;
u8 filler2[80]; // Unused
u16 unusedField1; // Never read.
s16 wallpaperSetId;
s16 wallpaperId;
u16 wallpaperTilemap[360];
u8 wallpaperChangeState;
u8 scrollState;
u8 scrollToBoxId;
s8 scrollDirection;
// u8 *wallpaperTiles; // used only in Emerald for Walda
struct Sprite *movingMonSprite;
struct Sprite *partySprites[PARTY_SIZE];
struct Sprite *boxMonsSprites[IN_BOX_COUNT];
struct Sprite **shiftMonSpritePtr;
struct Sprite **releaseMonSpritePtr;
u16 numIconsPerSpecies[MAX_MON_ICONS];
u16 iconSpeciesList[MAX_MON_ICONS];
u16 boxSpecies[IN_BOX_COUNT];
u32 boxPersonalities[IN_BOX_COUNT];
u8 incomingBoxId;
u8 shiftTimer;
u8 numPartySpritesToCompact;
u16 iconScrollDistance;
s16 iconScrollPos;
s16 iconScrollSpeed;
u16 iconScrollNumIncoming;
u8 iconScrollCurColumn;
s8 iconScrollDirection; // Unnecessary duplicate of scrollDirection
u8 iconScrollState;
u8 iconScrollToBoxId; // Unused duplicate of scrollToBoxId
struct WindowTemplate menuWindow;
struct StorageMenu menuItems[7];
u8 menuItemsCount;
u8 menuWidth;
u8 menuUnusedField; // Never read.
u16 menuWindowId;
struct Sprite *cursorSprite;
struct Sprite *cursorShadowSprite;
s32 cursorNewX;
s32 cursorNewY;
u32 cursorSpeedX;
u32 cursorSpeedY;
s16 cursorTargetX;
s16 cursorTargetY;
u16 cursorMoveSteps;
s8 cursorVerticalWrap;
s8 cursorHorizontalWrap;
u8 newCursorArea;
u8 newCursorPosition;
u8 cursorPrevPartyPos;
u8 cursorFlipTimer;
u8 cursorPalNums[2];
const u32 *displayMonPalette;
u32 displayMonPersonality;
u16 displayMonSpecies;
u16 displayMonItemId;
u16 displayUnusedVar;
bool8 setMosaic;
u8 displayMonMarkings;
u8 displayMonLevel;
bool8 displayMonIsEgg;
u8 displayMonNickname[POKEMON_NAME_LENGTH + 1];
u8 displayMonTexts[4][36]; // nickname, species name, gender and level, item name
bool8 (*monPlaceChangeFunc)(void);
u8 monPlaceChangeState;
u8 shiftBoxId;
struct Sprite *markingComboSprite;
struct Sprite *waveformSprites[2];
u16 *markingComboTilesPtr;
struct MonMarkingsMenu markMenu;
struct ChooseBoxMenu chooseBoxMenu;
struct Pokemon movingMon;
struct Pokemon tempMon;
s8 releaseMonStatus;
bool8 releaseMonStatusResolved;
bool8 isSurfMon;
bool8 isDiveMon;
s8 releaseCheckBoxId;
s8 releaseCheckBoxPos;
s8 releaseBoxId;
s8 releaseBoxPos;
u16 releaseCheckState;
u16 restrictedMoveList[3];
u8 summaryLastIndex;
u8 summaryCursorPos;
u8 summaryScreenMode;
union
{
struct Pokemon *mon;
struct BoxPokemon *box;
} summaryMonPtr;
u8 actionText[40];
u8 boxTitleText[40];
u8 releaseMonName[POKEMON_NAME_LENGTH + 1];
u8 itemName[20];
u8 inBoxMovingMode;
u16 multiMoveWindowId;
struct PokeStorageItemIcon itemIcons[MAX_ITEM_ICONS];
u16 movingItemId;
u16 itemInfoWindowOffset;
struct QuestLogEvent_MovedBoxMon questLogData;
u16 unusedField2;
u16 displayMonPalOffset;
u16 *displayMonTilePtr;
struct Sprite *displayMonSprite;
u16 displayMonPalBuffer[0x20];
u8 ALIGNED(4) tileBuffer[MON_PIC_SIZE * MAX_MON_PIC_FRAMES];
u8 ALIGNED(4) itemIconBuffer[0x200];
u8 wallpaperBgTilemapBuffer[0x1000];
u8 menuTilemapBuffer[0x800];
};
extern struct PokemonStorageSystemData *gStorage;
void EnterPokeStorage(u8 boxOption);
u8 GetCurrentBoxOption(void);
struct Sprite *CreateChooseBoxArrows(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority);
void SetBoxWallpaper(u8 boxId, u8 wallpaperId);
void SetCurrentBox(u8 boxId);
void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon * dst);
void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon * src);
void CB2_ExitPokeStorage(void);
void FreeBoxSelectionPopupSpriteGfx(void);
void CreateChooseBoxMenuSprites(u8 curBox);
void DestroyChooseBoxMenuSprites(void);
u8 HandleBoxChooseSelectionInput(void);
void LoadChooseBoxMenuGfx(struct ChooseBoxMenu *menu, u16 tileTag, u16 palTag, u8 subpriority, bool32 loadPal);
void SetCurrentBoxMonData(u8 boxPosition, s32 request, const void *value);
u32 GetCurrentBoxMonData(u8 boxPosition, s32 request);
u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst);
void InitCursor(void);
void InitCursorOnReopen(void);
bool8 UpdateCursorPos(void);
void SetCursorInParty(void);
void SetCursorBoxPosition(u8 cursorBoxPosition);
void ClearSavedCursorPos(void);
void SaveCursorPos(void);
u8 GetSavedCursorPos(void);
void DoTrySetDisplayMonData(void);
void ResetSelectionAfterDeposit(void);
void InitReleaseMon(void);
bool8 TryHideReleaseMon(void);
void TrySetCursorFistAnim(void);
void SaveMovingMon(void);
void LoadSavedMovingMon(void);
void InitSummaryScreenData(void);
void SetSelectionAfterSummaryScreen(void);
void StartCursorAnim(u8 animNum);
u8 GetMovingMonOriginalBoxId(void);
void TryHideItemAtCursor(void);
void TryShowItemAtCursor(void);
bool8 IsMenuLoading(void);
s16 HandleMenuInput(void);
void RemoveMenu(void);
bool8 MultiMove_Init(void);
void MultiMove_Free(void);
void MultiMove_SetFunction(u8 funcId);
bool8 MultiMove_RunFunction(void);
void CreateItemIconSprites(void);
void MoveItemFromCursorToBag(void);
void MoveHeldItemWithPartyMenu(void);
bool8 IsItemIconAnimActive(void);
const u8 *GetMovingItemName(void);
void InitItemInfoWindow(void);
bool8 UpdateItemInfoWindowSlideIn(void);
bool8 UpdateItemInfoWindowSlideOut(void);
void UnkUtil_Init(struct UnkUtil *arg0, struct UnkUtilData *arg1, u32 arg2);
void UnkUtil_Run(void);
void AddMenu(void);
bool8 CanMovePartyMon(void);
bool8 CanPlaceMon(void);
bool8 CanShiftMon(void);
bool8 DoMonPlaceChange(void);
bool8 DoWallpaperGfxChange(void);
u8 GetBoxCursorPosition(void);
u16 GetMovingItem(void);
u8 HandleInput(void);
void InitCanReleaseMonVars(void);
void InitMonPlaceChange(u8 type);
bool8 IsActiveItemMoving(void);
bool8 IsCursorOnCloseBox(void);
bool8 IsMonBeingMoved(void);
void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos);
void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos);
void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos);
void Item_TakeMons(u8 cursorArea, u8 cursorPos);
void PrintItemDescription(void);
void ReleaseMon(void);
s8 RunCanReleaseMon(void);
bool8 ScrollToBox(void);
void SetMonMarkings(u8 markings);
void SetMovingMonPriority(u8 priority);
void SetUpScrollToBox(u8 targetBox);
void SetWallpaperForCurrentBox(u8 wallpaper);
bool8 TryStorePartyMonInBox(u8 boxId);
void InitMenu(void);
void SetMenuText(u8 textId);
void TryLoadItemIconAtPos(u8 cursorArea, u8 cursorPos);
void InitItemIconInCursor(u16 itemId);
u8 GetBoxWallpaper(u8 boxId);
bool8 IsCursorOnBoxTitle(void);
bool8 IsCursorInBox(void);
void InitMonIconFields(void);
struct Sprite *CreateMonIconSprite(u16 species, u32 pid, s16 x, s16 y, u8 priority, u8 subpriority);
void CreatePartyMonsSprites(bool8 species);
void CompactPartySprites(void);
u8 GetNumPartySpritesCompacting(void);
void MovePartySprites(s16 yDelta);
void DestroyAllPartyMonIcons(void);
void DoReleaseMonComeBackAnim(void);
bool8 ResetReleaseMonSpritePtr(void);
void CreateInitBoxTask(u8 boxId);
bool8 IsInitBoxActive(void);
void AnimateBoxScrollArrows(bool8 species);
void CreateMovingMonIcon(void);
void SetShiftMonSpritePtr(u8 boxId, u8 position);
bool8 ShiftMons(void);
void SetMovingMonSprite(u8 cursorArea, u8 cursorPos);
void SetPlacedMonSprite(u8 cursorArea, u8 cursorPos);
void DestroyPartyMonIcon(u8 partyId);
void DestroyMovingMonIcon(void);
s16 GetFirstFreeBoxSpot(u8 boxId);
void CreateBoxMonIconAtPos(u8 boxPosition);
void DoReleaseMonAnim(u8 mode, u8 position);
bool8 TryHideReleaseMonSprite(void);
void DestroyReleaseMonIcon(void);
u8 CountPartyMons(void);
u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore);
s8 GetMenuItemTextId(u8 menuIndex);
bool8 MultiMove_TryMoveGroup(u8 dir);
u8 MultiMove_GetOriginPosition(void);
bool8 MultiMove_CanPlaceSelection(void);
void TryHideItemIconAtPos(u8 cursorArea, u8 cursorPos);
void GetCursorBoxColumnAndRow(u8 *column, u8 *row);
void SetCursorPriorityTo1(void);
void InitMultiMonPlaceChange(bool8 moveCursorUp);
void DestroyBoxMonIconAtPosition(u8 boxPosition);
void SetBoxMonIconObjMode(u8 cursorPos, u8 objMode);
void SetPartyMonIconObjMode(u8 cursorPos, u8 objMode);
#endif //GUARD_POKEMON_STORAGE_SYSTEM_INTERNAL_H

View File

@ -1386,16 +1386,6 @@ extern const u8 gText_PkmnsNickname[];
extern const u8 gText_RivalsName[];
// pokemon_storage_system
extern const u8 gText_WithdrawPokemon[];
extern const u8 gText_WithdrawMonDescription[];
extern const u8 gText_DepositPokemon[];
extern const u8 gText_DepositMonDescription[];
extern const u8 gText_MovePokemon[];
extern const u8 gText_MoveMonDescription[];
extern const u8 gText_MoveItems[];
extern const u8 gText_MoveItemsDescription[];
extern const u8 gText_SeeYa[];
extern const u8 gText_SeeYaDescription[];
extern const u8 gText_PartyFull[];
extern const u8 gText_JustOnePkmn[];
extern const u8 gText_Box[];

View File

@ -1,12 +0,0 @@
#ifndef GUARD_TILEMAP_UTIL_H
#define GUARD_TILEMAP_UTIL_H
void TilemapUtil_Init(u8 numTilemapIds);
void TilemapUtil_Free(void);
void TilemapUtil_SetTilemap(u8 tilemapId, u8 bg, const void *tilemap, u16 width, u16 height);
void TilemapUtil_SetPos(u8 tilemapId, u16 destX, u16 destY);
void TilemapUtil_SetRect(u8 tilemapId, u16 x, u16 y, u16 width, u16 height);
void TilemapUtil_Move(u8 tilemapId, u8 mode, s8 param);
void TilemapUtil_Update(u8 tilemapId);
#endif //GUARD_TILEMAP_UTIL_H

128
src/data/wallpapers.h Normal file
View File

@ -0,0 +1,128 @@
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_STARS,
WALLPAPER_POKECENTER,
WALLPAPER_TILES,
WALLPAPER_SIMPLE,
WALLPAPER_COUNT
};
#define MAX_DEFAULT_WALLPAPER WALLPAPER_SAVANNA
static const u16 sWallpaperPalettes_Forest[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/forest/tiles.gbapal");
static const u32 sWallpaperTiles_Forest[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/forest/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Forest[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/forest/tilemap.bin.lz");
static const u16 sWallpaperPalettes_City[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/city/tiles.gbapal");
static const u32 sWallpaperTiles_City[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/city/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_City[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/city/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Desert[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/desert/tiles.gbapal");
static const u32 sWallpaperTiles_Desert[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/desert/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Desert[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/desert/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Savanna[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/savanna/tiles.gbapal");
static const u32 sWallpaperTiles_Savanna[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/savanna/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Savanna[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/savanna/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Crag[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/crag/tiles.gbapal");
static const u32 sWallpaperTiles_Crag[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/crag/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Crag[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/crag/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Volcano[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/volcano/tiles.gbapal");
static const u32 sWallpaperTiles_Volcano[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/volcano/tiles.4bpp.lz");
static const u8 sUnusedSpace1[4] = {};
static const u32 sWallpaperTilemap_Volcano[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/volcano/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Snow[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/snow/tiles.gbapal");
static const u32 sWallpaperTiles_Snow[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/snow/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Snow[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/snow/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Cave[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/cave/tiles.gbapal");
static const u32 sWallpaperTiles_Cave[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/cave/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Cave[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/cave/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Beach[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/beach/tiles.gbapal");
static const u32 sWallpaperTiles_Beach[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/beach/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Beach[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/beach/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Seafloor[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/seafloor/tiles.gbapal");
static const u32 sWallpaperTiles_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/seafloor/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/seafloor/tilemap.bin.lz");
static const u16 sWallpaperPalettes_River[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/river/tiles.gbapal");
static const u32 sWallpaperTiles_River[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/river/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_River[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/river/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Sky[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/sky/tiles.gbapal");
static const u32 sWallpaperTiles_Sky[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/sky/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Sky[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/sky/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Stars[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/stars/tiles.gbapal");
static const u8 sUnusedSpace2[32] = {};
static const u32 sWallpaperTiles_Stars[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/stars/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Stars[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/stars/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Pokecenter[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/pokecenter/tiles.gbapal");
static const u32 sWallpaperTiles_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/pokecenter/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/pokecenter/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Tiles[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/tiles/tiles.gbapal");
static const u32 sWallpaperTiles_Tiles[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/tiles/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Tiles[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/tiles/tilemap.bin.lz");
static const u16 sWallpaperPalettes_Simple[] = INCBIN_U16("graphics/pokemon_storage/wallpapers/simple/tiles.gbapal");
static const u32 sWallpaperTiles_Simple[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/simple/tiles.4bpp.lz");
static const u32 sWallpaperTilemap_Simple[] = INCBIN_U32("graphics/pokemon_storage/wallpapers/simple/tilemap.bin.lz");
// Shadow color, text color
static const u16 sBoxTitleColors[][2] = {
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE},
{RGB( 7, 7, 7), RGB_WHITE}
};
static const struct Wallpaper sWallpapers[] = {
{sWallpaperTiles_Forest, sWallpaperTilemap_Forest, sWallpaperPalettes_Forest },
{sWallpaperTiles_City, sWallpaperTilemap_City, sWallpaperPalettes_City },
{sWallpaperTiles_Desert, sWallpaperTilemap_Desert, sWallpaperPalettes_Desert },
{sWallpaperTiles_Savanna, sWallpaperTilemap_Savanna, sWallpaperPalettes_Savanna },
{sWallpaperTiles_Crag, sWallpaperTilemap_Crag, sWallpaperPalettes_Crag },
{sWallpaperTiles_Volcano, sWallpaperTilemap_Volcano, sWallpaperPalettes_Volcano },
{sWallpaperTiles_Snow, sWallpaperTilemap_Snow, sWallpaperPalettes_Snow },
{sWallpaperTiles_Cave, sWallpaperTilemap_Cave, sWallpaperPalettes_Cave },
{sWallpaperTiles_Beach, sWallpaperTilemap_Beach, sWallpaperPalettes_Beach },
{sWallpaperTiles_Seafloor, sWallpaperTilemap_Seafloor, sWallpaperPalettes_Seafloor },
{sWallpaperTiles_River, sWallpaperTilemap_River, sWallpaperPalettes_River },
{sWallpaperTiles_Sky, sWallpaperTilemap_Sky, sWallpaperPalettes_Sky },
{sWallpaperTiles_Stars, sWallpaperTilemap_Stars, sWallpaperPalettes_Stars },
{sWallpaperTiles_Pokecenter, sWallpaperTilemap_Pokecenter, sWallpaperPalettes_Pokecenter},
{sWallpaperTiles_Tiles, sWallpaperTilemap_Tiles, sWallpaperPalettes_Tiles },
{sWallpaperTiles_Simple, sWallpaperTilemap_Simple, sWallpaperPalettes_Simple },
};
static const u16 sBoxScrollArrow_Gfx[] = INCBIN_U16("graphics/pokemon_storage/box_scroll_arrow.4bpp");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,621 +0,0 @@
#include "global.h"
#include "gflib.h"
#include "event_data.h"
#include "field_fadetransition.h"
#include "field_weather.h"
#include "help_system.h"
#include "menu.h"
#include "overworld.h"
#include "pokemon_storage_system_internal.h"
#include "script.h"
#include "strings.h"
#include "task.h"
#include "constants/songs.h"
#include "constants/field_weather.h"
#include "constants/help_system.h"
static EWRAM_DATA u8 sPreviousBoxOption = 0;
static EWRAM_DATA struct ChooseBoxMenu *sChooseBoxMenu = NULL;
static void CreatePCMainMenu(u8 whichMenu, s16 *windowIdPtr);
static void ChooseBoxMenu_CreateSprites(u8 curBox);
static void ChooseBoxMenu_DestroySprites(void);
static void ChooseBoxMenu_MoveRight(void);
static void ChooseBoxMenu_MoveLeft(void);
static void ChooseBoxMenu_PrintBoxNameAndCount(void);
static void ChooseBoxMenu_PrintTextToSprite(const u8 *a0, u16 x, u16 y);
static void SpriteCB_ChooseBoxArrow(struct Sprite *sprite);
static const u16 sChooseBoxMenu_Pal[];
static const u8 sChooseBoxMenuCenter_Gfx[];
static const u8 sChooseBoxMenuCorners_Gfx[];
struct {
const u8 *text;
const u8 *desc;
} static const sMainMenuTexts[OPTIONS_COUNT] = {
[OPTION_WITHDRAW] = {gText_WithdrawPokemon, gText_WithdrawMonDescription},
[OPTION_DEPOSIT] = {gText_DepositPokemon, gText_DepositMonDescription},
[OPTION_MOVE_MONS] = {gText_MovePokemon, gText_MoveMonDescription},
[OPTION_MOVE_ITEMS] = {gText_MoveItems, gText_MoveItemsDescription},
[OPTION_EXIT] = {gText_SeeYa, gText_SeeYaDescription}
};
void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, u8 *unused, s32 bytesToBuffer)
{
s32 i, tileBytesToBuffer, remainingBytes;
u16 windowId;
u8 txtColor[3];
u8 *tileData1, *tileData2;
struct WindowTemplate winTemplate = {0};
winTemplate.width = 24;
winTemplate.height = 2;
windowId = AddWindow(&winTemplate);
FillWindowPixelBuffer(windowId, PIXEL_FILL(zero2));
tileData1 = (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA);
tileData2 = (winTemplate.width * TILE_SIZE_4BPP) + tileData1;
if (!zero1)
txtColor[0] = TEXT_COLOR_TRANSPARENT;
else
txtColor[0] = zero2;
txtColor[1] = TEXT_DYNAMIC_COLOR_6;
txtColor[2] = TEXT_DYNAMIC_COLOR_5;
AddTextPrinterParameterized4(windowId, FONT_NORMAL_COPY_1, 0, 2, 0, 0, txtColor, -1, string);
tileBytesToBuffer = bytesToBuffer;
if (tileBytesToBuffer > 6)
tileBytesToBuffer = 6;
remainingBytes = bytesToBuffer - 6;
if (tileBytesToBuffer > 0)
{
for (i = tileBytesToBuffer; i != 0; i--)
{
CpuCopy16(tileData1, dst, 0x80);
CpuCopy16(tileData2, dst + 0x80, 0x80);
tileData1 += 0x80;
tileData2 += 0x80;
dst += 0x100;
}
}
// Never used. bytesToBuffer is always passed <= 6, so remainingBytes is always <= 0 here
if (remainingBytes > 0)
CpuFill16((zero2 << 4) | zero2, dst, (u32)(remainingBytes) * 0x100);
RemoveWindow(windowId);
}
static void PrintStringToBufferCopyNow(const u8 *string, void *dst, u16 offset, u8 bgColor, u8 fgColor, u8 shadowColor, u8 *unused)
{
u32 var;
u8 windowId;
u8 txtColor[3];
u8 *tileData1, *tileData2;
struct WindowTemplate winTemplate = {0};
winTemplate.width = StringLength_Multibyte(string);
winTemplate.height = 2;
var = winTemplate.width * 32;
windowId = AddWindow(&winTemplate);
FillWindowPixelBuffer(windowId, PIXEL_FILL(bgColor));
tileData1 = (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA);
tileData2 = (winTemplate.width * 32) + tileData1;
txtColor[0] = bgColor;
txtColor[1] = fgColor;
txtColor[2] = shadowColor;
AddTextPrinterParameterized4(windowId, FONT_NORMAL_COPY_1, 0, 2, 0, 0, txtColor, -1, string);
CpuCopy16(tileData1, dst, var);
CpuCopy16(tileData2, dst + offset, var);
RemoveWindow(windowId);
}
static u8 CountMonsInBox(u8 boxId)
{
u16 i, count;
for (i = 0, count = 0; i < IN_BOX_COUNT; i++)
{
if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE)
count++;
}
return count;
}
s16 GetFirstFreeBoxSpot(u8 boxId)
{
u16 i;
for (i = 0; i < IN_BOX_COUNT; i++)
{
if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE)
return i;
}
return -1; // all spots are taken
}
u32 CountPartyNonEggMons(void)
{
u32 i, count;
for (i = 0, count = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
count++;
}
return count;
}
u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore)
{
u16 i, count;
for (i = 0, count = 0; i < PARTY_SIZE; i++)
{
if (i != slotToIgnore
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
count++;
}
return count;
}
u16 CountPartyAliveNonEggMons_IgnoreVar0x8004Slot(void)
{
return CountPartyAliveNonEggMonsExcept(gSpecialVar_0x8004);
}
u8 CountPartyMons(void)
{
u16 i, count;
for (i = 0, count = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE)
count++;
}
return count;
}
enum {
STATE_LOAD,
STATE_FADE_IN,
STATE_HANDLE_INPUT,
STATE_ERROR_MSG,
STATE_ENTER_PC,
};
#define tState data[0]
#define tSelectedOption data[1]
#define tInput data[2]
#define tNextOption data[3]
#define tWindowId data[15]
static void Task_PCMainMenu(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->tState)
{
case STATE_LOAD:
SetHelpContext(HELPCONTEXT_BILLS_PC);
CreatePCMainMenu(task->tSelectedOption, &task->tWindowId);
LoadMessageBoxAndBorderGfx();
DrawDialogueFrame(0, FALSE);
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, TEXT_SKIP_DRAW, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
CopyWindowToVram(0, COPYWIN_FULL);
CopyWindowToVram(task->tWindowId, COPYWIN_FULL);
task->tState++;
break;
case STATE_FADE_IN:
if (IsWeatherNotFadingIn())
task->tState++;
break;
case STATE_HANDLE_INPUT:
task->tInput = Menu_ProcessInput();
switch(task->tInput)
{
case MENU_NOTHING_CHOSEN:
task->tNextOption = task->tSelectedOption;
if (JOY_NEW(DPAD_UP) && --task->tNextOption < 0)
task->tNextOption = OPTIONS_COUNT - 1;
if (JOY_NEW(DPAD_DOWN) && ++task->tNextOption > OPTIONS_COUNT - 1)
task->tNextOption = 0;
if (task->tSelectedOption != task->tNextOption)
{
task->tSelectedOption = task->tNextOption;
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
}
break;
case MENU_B_PRESSED:
case OPTION_EXIT:
ClearStdWindowAndFrame(0, TRUE);
ClearStdWindowAndFrame(task->tWindowId, TRUE);
UnlockPlayerFieldControls();
ScriptContext_Enable();
DestroyTask(taskId);
break;
default:
if (task->tInput == OPTION_WITHDRAW && CountPartyMons() == PARTY_SIZE)
{
// Can't withdraw
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, FONT_NORMAL, gText_PartyFull, 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
task->tState = STATE_ERROR_MSG;
}
else if (task->tInput == OPTION_DEPOSIT && CountPartyMons() == 1)
{
// Can't deposit
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, FONT_NORMAL, gText_JustOnePkmn, 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
task->tState = STATE_ERROR_MSG;
}
else
{
// Enter PC
FadeScreen(FADE_TO_BLACK, 0);
task->tState = STATE_ENTER_PC;
}
break;
}
break;
case STATE_ERROR_MSG:
// Printed "can't do PC option message"
// Wait for new input after message
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
task->tState = STATE_HANDLE_INPUT;
}
else if (JOY_NEW(DPAD_UP))
{
if (--task->tSelectedOption < 0)
task->tSelectedOption = 4;
Menu_MoveCursor(-1);
task->tSelectedOption = Menu_GetCursorPos();
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
task->tState = STATE_HANDLE_INPUT;
}
else if (JOY_NEW(DPAD_DOWN))
{
if (++task->tSelectedOption > 3)
task->tSelectedOption = 0;
Menu_MoveCursor(1);
task->tSelectedOption = Menu_GetCursorPos();
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
task->tState = STATE_HANDLE_INPUT;
}
break;
case STATE_ENTER_PC:
if (!gPaletteFade.active)
{
CleanupOverworldWindowsAndTilemaps();
EnterPokeStorage(task->tInput);
DestroyTask(taskId);
}
break;
}
}
void ShowPokemonStorageSystemPC(void)
{
u8 taskId = CreateTask(Task_PCMainMenu, 80);
gTasks[taskId].tState = STATE_LOAD;
gTasks[taskId].tSelectedOption = 0;
LockPlayerFieldControls();
}
static void FieldTask_ReturnToPcMenu(void)
{
u8 taskId;
MainCallback vblankCb = gMain.vblankCallback;
SetVBlankCallback(NULL);
taskId = CreateTask(Task_PCMainMenu, 80);
gTasks[taskId].tState = STATE_LOAD;
gTasks[taskId].tSelectedOption = sPreviousBoxOption;
Task_PCMainMenu(taskId);
SetVBlankCallback(vblankCb);
FadeInFromBlack();
}
static const struct WindowTemplate sWindowTemplate_MainMenu = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
.width = 17,
.height = 10,
.paletteNum = 15,
.baseBlock = 0x001
};
static void CreatePCMainMenu(u8 whichMenu, s16 *windowIdPtr)
{
s16 windowId = AddWindow(&sWindowTemplate_MainMenu);
DrawStdWindowFrame(windowId, FALSE);
PrintMenuActionTextsAtPos(windowId, FONT_NORMAL, GetMenuCursorDimensionByFont(FONT_NORMAL, 0), 2, 16, ARRAY_COUNT(sMainMenuTexts), (void *)sMainMenuTexts);
InitMenuNormal(windowId, FONT_NORMAL, 0, 2, 16, ARRAY_COUNT(sMainMenuTexts), whichMenu);
*windowIdPtr = windowId;
}
void CB2_ExitPokeStorage(void)
{
sPreviousBoxOption = GetCurrentBoxOption();
gFieldCallback = FieldTask_ReturnToPcMenu;
SetMainCallback2(CB2_ReturnToField);
}
void ResetPokemonStorageSystem(void)
{
u16 boxId, boxPosition;
SetCurrentBox(0);
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
{
for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++)
ZeroBoxMonAt(boxId, boxPosition);
}
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
{
u8 *dest = StringCopy(GetBoxNamePtr(boxId), gText_Box);
ConvertIntToDecimalStringN(dest, boxId + 1, STR_CONV_MODE_LEFT_ALIGN, 2);
}
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
SetBoxWallpaper(boxId, boxId % (MAX_DEFAULT_WALLPAPER + 1));
}
void LoadChooseBoxMenuGfx(struct ChooseBoxMenu *menu, u16 tileTag, u16 palTag, u8 subpriority, bool32 loadPal)
{
struct SpritePalette palette = {
sChooseBoxMenu_Pal, palTag
};
struct SpriteSheet sheets[] = {
{sChooseBoxMenuCenter_Gfx, 0x800, tileTag},
{sChooseBoxMenuCorners_Gfx, 0x180, tileTag + 1},
{}
};
if (loadPal) // Always false
LoadSpritePalette(&palette);
LoadSpriteSheets(sheets);
sChooseBoxMenu = menu;
menu->tileTag = tileTag;
menu->paletteTag = palTag;
menu->subpriority = subpriority;
menu->loadedPalette = loadPal;
}
void FreeBoxSelectionPopupSpriteGfx(void)
{
if (sChooseBoxMenu->loadedPalette)
FreeSpritePaletteByTag(sChooseBoxMenu->paletteTag);
FreeSpriteTilesByTag(sChooseBoxMenu->tileTag);
FreeSpriteTilesByTag(sChooseBoxMenu->tileTag + 1);
}
void CreateChooseBoxMenuSprites(u8 curBox)
{
ChooseBoxMenu_CreateSprites(curBox);
}
void DestroyChooseBoxMenuSprites(void)
{
ChooseBoxMenu_DestroySprites();
}
u8 HandleBoxChooseSelectionInput(void)
{
if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
return BOXID_CANCELED;
}
if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
return sChooseBoxMenu->curBox;
}
if (JOY_NEW(DPAD_LEFT))
{
PlaySE(SE_SELECT);
ChooseBoxMenu_MoveLeft();
}
else if (JOY_NEW(DPAD_RIGHT))
{
PlaySE(SE_SELECT);
ChooseBoxMenu_MoveRight();
}
return BOXID_NONE_CHOSEN;
}
static const union AnimCmd sAnim_ChooseBoxMenu_TopLeft[] = {
ANIMCMD_FRAME( 0, 5),
ANIMCMD_END
};
static const union AnimCmd sAnim_ChooseBoxMenu_BottomLeft[] = {
ANIMCMD_FRAME( 4, 5),
ANIMCMD_END
};
static const union AnimCmd sAnim_ChooseBoxMenu_TopRight[] = {
ANIMCMD_FRAME( 6, 5),
ANIMCMD_END
};
static const union AnimCmd sAnim_ChooseBoxMenu_BottomRight[] = {
ANIMCMD_FRAME(10, 5),
ANIMCMD_END
};
static const union AnimCmd *const sAnims_ChooseBoxMenu[] = {
sAnim_ChooseBoxMenu_TopLeft,
sAnim_ChooseBoxMenu_BottomLeft,
sAnim_ChooseBoxMenu_TopRight,
sAnim_ChooseBoxMenu_BottomRight,
};
static const union AffineAnimCmd sAffineAnim_ChooseBoxMenu[] = {
AFFINEANIMCMD_FRAME(224, 224, 0, 0),
AFFINEANIMCMD_END
};
// Unused
static const union AffineAnimCmd *const sAffineAnims_ChooseBoxMenu[] = {
sAffineAnim_ChooseBoxMenu
};
static void ChooseBoxMenu_CreateSprites(u8 curBox)
{
u16 i;
u8 spriteId;
struct SpriteTemplate template;
struct OamData oamData = {};
oamData.size = SPRITE_SIZE(64x64);
oamData.paletteNum = 1;
template = (struct SpriteTemplate){
0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
};
{
const u8 sText_OutOf30[] = _("/30");
sChooseBoxMenu->curBox = curBox;
template.tileTag = sChooseBoxMenu->tileTag;
template.paletteTag = sChooseBoxMenu->paletteTag;
spriteId = CreateSprite(&template, 160, 96, 0);
sChooseBoxMenu->menuSprite = gSprites + spriteId;
oamData.shape = SPRITE_SHAPE(8x32);
oamData.size = SPRITE_SIZE(8x32);
template.tileTag = sChooseBoxMenu->tileTag + 1;
template.anims = sAnims_ChooseBoxMenu;
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->menuCornerSprites); i++)
{
// corner sprites are created in order of top left, bottom left, top right, bottom right
u16 animNum;
spriteId = CreateSprite(&template, 124, 80, sChooseBoxMenu->subpriority); // place at top left
sChooseBoxMenu->menuCornerSprites[i] = &gSprites[spriteId];
animNum = 0;
if (i & 2)
{
sChooseBoxMenu->menuCornerSprites[i]->x = 196; // move to bottom
animNum = 2;
}
if (i & 1)
{
sChooseBoxMenu->menuCornerSprites[i]->y = 112; // move to right
sChooseBoxMenu->menuCornerSprites[i]->oam.size = SPRITE_SIZE(8x16);
animNum++;
}
StartSpriteAnim(sChooseBoxMenu->menuCornerSprites[i], animNum);
}
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->arrowSprites); i++)
{
sChooseBoxMenu->arrowSprites[i] = CreateChooseBoxArrows(72 * i + 124, 88, i, 0, sChooseBoxMenu->subpriority);
if (sChooseBoxMenu->arrowSprites[i])
{
sChooseBoxMenu->arrowSprites[i]->data[0] = (i == 0 ? -1 : 1);
sChooseBoxMenu->arrowSprites[i]->callback = SpriteCB_ChooseBoxArrow;
}
}
ChooseBoxMenu_PrintBoxNameAndCount();
ChooseBoxMenu_PrintTextToSprite(sText_OutOf30, 5, 3);
}
}
static void ChooseBoxMenu_DestroySprites(void)
{
u16 i;
if (sChooseBoxMenu->menuSprite)
{
DestroySprite(sChooseBoxMenu->menuSprite);
sChooseBoxMenu->menuSprite = NULL;
}
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->menuCornerSprites); i++)
{
if (sChooseBoxMenu->menuCornerSprites[i])
{
DestroySprite(sChooseBoxMenu->menuCornerSprites[i]);
sChooseBoxMenu->menuCornerSprites[i] = NULL;
}
}
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->arrowSprites); i++)
{
if (sChooseBoxMenu->arrowSprites[i])
DestroySprite(sChooseBoxMenu->arrowSprites[i]);
}
}
static void ChooseBoxMenu_MoveRight(void)
{
if (++sChooseBoxMenu->curBox >= TOTAL_BOXES_COUNT)
sChooseBoxMenu->curBox = 0;
ChooseBoxMenu_PrintBoxNameAndCount();
}
static void ChooseBoxMenu_MoveLeft(void)
{
sChooseBoxMenu->curBox = (sChooseBoxMenu->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : sChooseBoxMenu->curBox - 1);
ChooseBoxMenu_PrintBoxNameAndCount();
}
static void ChooseBoxMenu_PrintBoxNameAndCount(void)
{
u8 numMonInBox = CountMonsInBox(sChooseBoxMenu->curBox);
u8 *boxName = StringCopy(sChooseBoxMenu->strbuf, GetBoxNamePtr(sChooseBoxMenu->curBox));
while (boxName < sChooseBoxMenu->strbuf + BOX_NAME_LENGTH)
*boxName++ = CHAR_SPACE;
*boxName = EOS;
ChooseBoxMenu_PrintTextToSprite(sChooseBoxMenu->strbuf, 0, 1);
ConvertIntToDecimalStringN(sChooseBoxMenu->strbuf, numMonInBox, STR_CONV_MODE_RIGHT_ALIGN, 2);
ChooseBoxMenu_PrintTextToSprite(sChooseBoxMenu->strbuf, 3, 3);
}
static void ChooseBoxMenu_PrintTextToSprite(const u8 *str, u16 x, u16 y)
{
void *dst = (void *)(OBJ_VRAM0 + GetSpriteTileStartByTag(sChooseBoxMenu->tileTag) * 32 + 256 * y + 32 * x);
PrintStringToBufferCopyNow(str, dst, 0x100, TEXT_COLOR_RED, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5, sChooseBoxMenu->buffer);
}
static void SpriteCB_ChooseBoxArrow(struct Sprite *sprite)
{
if (++sprite->data[1] > 3)
{
sprite->data[1] = 0;
sprite->x2 += sprite->data[0];
if (++sprite->data[2] > 5)
{
sprite->data[2] = 0;
sprite->x2 = 0;
}
}
}
// Unused, since LoadChooseBoxMenuGfx is always called with `loadPal` as false
static const u16 sChooseBoxMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/unused_choose_box_menu.gbapal");
static const u8 sChooseBoxMenuCenter_Gfx[] = INCBIN_U8("graphics/pokemon_storage/choose_box_menu_center.4bpp");
static const u8 sChooseBoxMenuCorners_Gfx[] = INCBIN_U8("graphics/pokemon_storage/choose_box_menu_corners.4bpp");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -682,16 +682,6 @@ const u8 gPCText_Pokecenter[] = _("POKéCENTER");
const u8 gPCText_Machine[] = _("TILES");
const u8 gPCText_Simple[] = _("SIMPLE");
const u8 gText_PC_WhatWouldYouLikeToDo[] = _("なにを しますか?");
const u8 gText_WithdrawPokemon[] = _("WITHDRAW POKéMON");
const u8 gText_DepositPokemon[] = _("DEPOSIT POKéMON");
const u8 gText_MovePokemon[] = _("MOVE POKéMON");
const u8 gText_MoveItems[] = _("MOVE ITEMS");
const u8 gText_SeeYa[] = _("SEE YA!");
const u8 gText_WithdrawMonDescription[] = _("You can withdraw a POKéMON if you\nhave any in a BOX.");
const u8 gText_DepositMonDescription[] = _("You can deposit your party\nPOKéMON in any BOX.");
const u8 gText_MoveMonDescription[] = _("You can move POKéMON that are\nstored in any BOX.");
const u8 gText_MoveItemsDescription[] = _("You can move items held by any\nPOKéMON in a BOX or your party.");
const u8 gText_SeeYaDescription[] = _("See you later!");
const u8 gText_JustOnePkmn[] = _("Can't deposit the last POKéMON!");
const u8 gText_PartyFull[] = _("Can't take any more POKéMON.");
const u8 gText_Box[] = _("BOX");

View File

@ -1,238 +0,0 @@
#include "global.h"
#include "bg.h"
#include "tilemap_util.h"
#include "malloc.h"
// Handles 3 particular tilemaps ("PKMN Data" text, party menu, close box
// button) used for Pokémon Storage System in a somewhat unusual way.
// For example, while the cursor is on the Close Box button it flashes between
// two states alternately. Both these states are their own part of the same
// tilemap that's always present. The utility shifts the tilemap up and down
// to show/hide the states, and limits the view with a rectangle that only
// reveals one at a time.
struct TilemapUtil_RectData
{
s16 x;
s16 y;
u16 width;
u16 height;
s16 destX;
s16 destY;
};
struct TilemapUtil
{
struct TilemapUtil_RectData prev; // Only read in unused function
struct TilemapUtil_RectData cur;
const void *savedTilemap; // Only written in unused function
const void *tilemap;
u16 altWidth; // Never read
u16 altHeight; // Never read
u16 width;
u16 height;
u16 rowSize; // Never read
u8 tileSize;
u8 bg;
bool8 active; // Only read in unused function
};
static EWRAM_DATA struct TilemapUtil *sTilemapUtil = NULL;
static EWRAM_DATA u16 sNumTilemapUtilIds = 0;
static void TilemapUtil_DrawPrev(u8 tilemapId);
static void TilemapUtil_Draw(u8 tilemapId);
static const struct {
u16 width;
u16 height;
} sTilemapDimensions[2][4] = {
{
{ 256, 256},
{ 512, 256},
{ 256, 512},
{ 512, 512}
}, {
{ 128, 128},
{ 256, 256},
{ 512, 512},
{1024, 1024}
}
};
void TilemapUtil_Init(u8 numTilemapIds)
{
u16 i;
sTilemapUtil = Alloc(numTilemapIds * sizeof(struct TilemapUtil));
sNumTilemapUtilIds = sTilemapUtil == NULL ? 0 : numTilemapIds;
for (i = 0; i < sNumTilemapUtilIds; i++)
{
sTilemapUtil[i].savedTilemap = NULL;
sTilemapUtil[i].active = FALSE;
}
}
void TilemapUtil_Free(void)
{
Free(sTilemapUtil);
}
// Unused
void TilemapUtil_UpdateAll(void)
{
int i;
for (i = 0; i < sNumTilemapUtilIds; i++)
{
if (sTilemapUtil[i].active == TRUE)
TilemapUtil_Update(i);
}
}
void TilemapUtil_SetTilemap(u8 tilemapId, u8 bg, const void *tilemap, u16 width, u16 height)
{
u16 screenSize;
u16 bgType;
if (tilemapId < sNumTilemapUtilIds)
{
sTilemapUtil[tilemapId].savedTilemap = NULL;
sTilemapUtil[tilemapId].tilemap = tilemap;
sTilemapUtil[tilemapId].bg = bg;
sTilemapUtil[tilemapId].width = width;
sTilemapUtil[tilemapId].height = height;
screenSize = GetBgAttribute(bg, BG_ATTR_SCREENSIZE);
bgType = GetBgAttribute(bg, BG_ATTR_TYPE);
sTilemapUtil[tilemapId].altWidth = sTilemapDimensions[bgType][screenSize].width;
sTilemapUtil[tilemapId].altHeight = sTilemapDimensions[bgType][screenSize].height;
if (bgType != 0)
sTilemapUtil[tilemapId].tileSize = 1;
else
sTilemapUtil[tilemapId].tileSize = 2;
sTilemapUtil[tilemapId].rowSize = width * sTilemapUtil[tilemapId].tileSize;
sTilemapUtil[tilemapId].cur.width = width;
sTilemapUtil[tilemapId].cur.height = height;
sTilemapUtil[tilemapId].cur.x = 0;
sTilemapUtil[tilemapId].cur.y = 0;
sTilemapUtil[tilemapId].cur.destX = 0;
sTilemapUtil[tilemapId].cur.destY = 0;
sTilemapUtil[tilemapId].prev = sTilemapUtil[tilemapId].cur;
sTilemapUtil[tilemapId].active = TRUE;
}
}
// Unused
void TilemapUtil_SetSavedMap(u8 tilemapId, const void *tilemap)
{
if (tilemapId < sNumTilemapUtilIds)
{
sTilemapUtil[tilemapId].savedTilemap = tilemap;
sTilemapUtil[tilemapId].active = TRUE;
}
}
void TilemapUtil_SetPos(u8 tilemapId, u16 destX, u16 destY)
{
if (tilemapId < sNumTilemapUtilIds)
{
sTilemapUtil[tilemapId].cur.destX = destX;
sTilemapUtil[tilemapId].cur.destY = destY;
sTilemapUtil[tilemapId].active = TRUE;
}
}
void TilemapUtil_SetRect(u8 tilemapId, u16 x, u16 y, u16 width, u16 height)
{
if (tilemapId < sNumTilemapUtilIds)
{
sTilemapUtil[tilemapId].cur.x = x;
sTilemapUtil[tilemapId].cur.y = y;
sTilemapUtil[tilemapId].cur.width = width;
sTilemapUtil[tilemapId].cur.height = height;
sTilemapUtil[tilemapId].active = TRUE;
}
}
void TilemapUtil_Move(u8 tilemapId, u8 mode, s8 param)
{
if (tilemapId < sNumTilemapUtilIds)
{
switch (mode)
{
case 0:
sTilemapUtil[tilemapId].cur.destX += param;
sTilemapUtil[tilemapId].cur.width -= param;
break;
case 1:
sTilemapUtil[tilemapId].cur.x += param;
sTilemapUtil[tilemapId].cur.width += param;
break;
case 2:
sTilemapUtil[tilemapId].cur.destY += param;
sTilemapUtil[tilemapId].cur.height -= param;
break;
case 3: // this is the only mode ever used
sTilemapUtil[tilemapId].cur.y -= param;
sTilemapUtil[tilemapId].cur.height += param;
break;
case 4:
sTilemapUtil[tilemapId].cur.destX += param;
break;
case 5:
sTilemapUtil[tilemapId].cur.destY += param;
break;
}
sTilemapUtil[tilemapId].active = TRUE;
}
}
void TilemapUtil_Update(u8 tilemapId)
{
if (tilemapId < sNumTilemapUtilIds)
{
if (sTilemapUtil[tilemapId].savedTilemap != NULL) // Always false
TilemapUtil_DrawPrev(tilemapId);
TilemapUtil_Draw(tilemapId);
sTilemapUtil[tilemapId].prev = sTilemapUtil[tilemapId].cur;
}
}
// Never called, see TilemapUtil_Update
static void TilemapUtil_DrawPrev(u8 tilemapId)
{
int i;
int rowSize = sTilemapUtil[tilemapId].tileSize * sTilemapUtil[tilemapId].altWidth;
const void *tiles = sTilemapUtil[tilemapId].savedTilemap
+ rowSize * sTilemapUtil[tilemapId].prev.destY
+ sTilemapUtil[tilemapId].prev.destX * sTilemapUtil[tilemapId].tileSize;
for (i = 0; i < sTilemapUtil[tilemapId].prev.height; i++)
{
CopyToBgTilemapBufferRect(sTilemapUtil[tilemapId].bg,
tiles,
sTilemapUtil[tilemapId].prev.destX,
sTilemapUtil[tilemapId].prev.destY + i,
sTilemapUtil[tilemapId].prev.width,
1);
tiles += rowSize;
}
}
static void TilemapUtil_Draw(u8 tilemapId)
{
int i;
int rowSize = sTilemapUtil[tilemapId].tileSize * sTilemapUtil[tilemapId].width;
const void *tiles = sTilemapUtil[tilemapId].tilemap
+ rowSize * sTilemapUtil[tilemapId].cur.y
+ sTilemapUtil[tilemapId].cur.x * sTilemapUtil[tilemapId].tileSize;
for (i = 0; i < sTilemapUtil[tilemapId].cur.height; i++)
{
CopyToBgTilemapBufferRect(sTilemapUtil[tilemapId].bg,
tiles,
sTilemapUtil[tilemapId].cur.destX,
sTilemapUtil[tilemapId].cur.destY + i,
sTilemapUtil[tilemapId].cur.width,
1);
tiles += rowSize;
}
}