Rearrange Pokemon storage source files
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#ifndef GUARD_BOX_PARTY_POKEMON_DROPDOWN_H
|
#ifndef GUARD_TILEMAP_UTIL_H
|
||||||
#define GUARD_BOX_PARTY_POKEMON_DROPDOWN_H
|
#define GUARD_TILEMAP_UTIL_H
|
||||||
|
|
||||||
void TilemapUtil_Init(u8 numTilemapIds);
|
void TilemapUtil_Init(u8 numTilemapIds);
|
||||||
void TilemapUtil_Free(void);
|
void TilemapUtil_Free(void);
|
||||||
@@ -9,4 +9,4 @@ void TilemapUtil_SetRect(u8 tilemapId, u16 x, u16 y, u16 width, u16 height);
|
|||||||
void TilemapUtil_Move(u8 tilemapId, u8 mode, s8 param);
|
void TilemapUtil_Move(u8 tilemapId, u8 mode, s8 param);
|
||||||
void TilemapUtil_Update(u8 tilemapId);
|
void TilemapUtil_Update(u8 tilemapId);
|
||||||
|
|
||||||
#endif //GUARD_BOX_PARTY_POKEMON_DROPDOWN_H
|
#endif //GUARD_TILEMAP_UTIL_H
|
||||||
+12
-16
@@ -130,13 +130,11 @@ SECTIONS {
|
|||||||
src/pokedex.o(.text);
|
src/pokedex.o(.text);
|
||||||
src/trainer_card.o(.text);
|
src/trainer_card.o(.text);
|
||||||
src/pokemon_storage_system.o(.text);
|
src/pokemon_storage_system.o(.text);
|
||||||
src/pokemon_storage_system_2.o(.text);
|
src/pokemon_storage_system_menu.o(.text);
|
||||||
src/pokemon_storage_system_3.o(.text);
|
src/pokemon_storage_system_tasks.o(.text);
|
||||||
src/pokemon_storage_system_4.o(.text);
|
src/pokemon_storage_system_graphics.o(.text);
|
||||||
src/pokemon_storage_system_5.o(.text);
|
src/pokemon_storage_system_data.o(.text);
|
||||||
src/pokemon_storage_system_6.o(.text);
|
src/pokemon_storage_system_misc.o(.text);
|
||||||
src/pokemon_storage_system_7.o(.text);
|
|
||||||
src/pokemon_storage_system_8.o(.text);
|
|
||||||
src/pokemon_icon.o(.text);
|
src/pokemon_icon.o(.text);
|
||||||
src/script_movement.o(.text);
|
src/script_movement.o(.text);
|
||||||
src/fldeff_cut.o(.text);
|
src/fldeff_cut.o(.text);
|
||||||
@@ -228,7 +226,7 @@ SECTIONS {
|
|||||||
src/evolution_graphics.o(.text);
|
src/evolution_graphics.o(.text);
|
||||||
src/fldeff_teleport.o(.text);
|
src/fldeff_teleport.o(.text);
|
||||||
src/new_menu_helpers.o(.text);
|
src/new_menu_helpers.o(.text);
|
||||||
src/box_party_pokemon_dropdown.o(.text);
|
src/tilemap_util.o(.text);
|
||||||
src/save_menu_util.o(.text);
|
src/save_menu_util.o(.text);
|
||||||
src/map_preview_screen.o(.text);
|
src/map_preview_screen.o(.text);
|
||||||
src/link_rfu_2.o(.text);
|
src/link_rfu_2.o(.text);
|
||||||
@@ -452,13 +450,11 @@ SECTIONS {
|
|||||||
src/field_effect.o(.rodata);
|
src/field_effect.o(.rodata);
|
||||||
src/option_menu.o(.rodata);
|
src/option_menu.o(.rodata);
|
||||||
src/trainer_card.o(.rodata);
|
src/trainer_card.o(.rodata);
|
||||||
src/pokemon_storage_system_2.o(.rodata);
|
src/pokemon_storage_system_menu.o(.rodata);
|
||||||
src/pokemon_storage_system_3.o(.rodata);
|
src/pokemon_storage_system_tasks.o(.rodata);
|
||||||
src/pokemon_storage_system_4.o(.rodata);
|
src/pokemon_storage_system_graphics.o(.rodata);
|
||||||
src/pokemon_storage_system_5.o(.rodata);
|
src/pokemon_storage_system_data.o(.rodata);
|
||||||
src/pokemon_storage_system_6.o(.rodata);
|
src/pokemon_storage_system_misc.o(.rodata);
|
||||||
src/pokemon_storage_system_7.o(.rodata);
|
|
||||||
src/pokemon_storage_system_8.o(.rodata);
|
|
||||||
src/pokemon_icon.o(.rodata);
|
src/pokemon_icon.o(.rodata);
|
||||||
src/fldeff_cut.o(.rodata);
|
src/fldeff_cut.o(.rodata);
|
||||||
src/map_name_popup.o(.rodata);
|
src/map_name_popup.o(.rodata);
|
||||||
@@ -524,7 +520,7 @@ SECTIONS {
|
|||||||
src/clear_save_data_screen.o(.rodata);
|
src/clear_save_data_screen.o(.rodata);
|
||||||
src/evolution_graphics.o(.rodata);
|
src/evolution_graphics.o(.rodata);
|
||||||
src/new_menu_helpers.o(.rodata);
|
src/new_menu_helpers.o(.rodata);
|
||||||
src/box_party_pokemon_dropdown.o(.rodata);
|
src/tilemap_util.o(.rodata);
|
||||||
src/map_preview_screen.o(.rodata);
|
src/map_preview_screen.o(.rodata);
|
||||||
src/link_rfu_2.o(.rodata);
|
src/link_rfu_2.o(.rodata);
|
||||||
src/link_rfu_3.o(.rodata);
|
src/link_rfu_3.o(.rodata);
|
||||||
|
|||||||
@@ -1,147 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
#include "gflib.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "new_menu_helpers.h"
|
|
||||||
#include "pokemon_storage_system_internal.h"
|
|
||||||
#include "strings.h"
|
|
||||||
#include "constants/songs.h"
|
|
||||||
|
|
||||||
void InitMenu(void)
|
|
||||||
{
|
|
||||||
gStorage->menuItemsCount = 0;
|
|
||||||
gStorage->menuWidth = 0;
|
|
||||||
gStorage->menuWindow.bg = 0;
|
|
||||||
gStorage->menuWindow.paletteNum = 15;
|
|
||||||
gStorage->menuWindow.baseBlock = 92;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const u8 *const sMenuTexts[] = {
|
|
||||||
[MENU_TEXT_CANCEL] = gPCText_Cancel,
|
|
||||||
[MENU_TEXT_STORE] = gPCText_Store,
|
|
||||||
[MENU_TEXT_WITHDRAW] = gPCText_Withdraw,
|
|
||||||
[MENU_TEXT_MOVE] = gPCText_Move,
|
|
||||||
[MENU_TEXT_SHIFT] = gPCText_Shift,
|
|
||||||
[MENU_TEXT_PLACE] = gPCText_Place,
|
|
||||||
[MENU_TEXT_SUMMARY] = gPCText_Summary,
|
|
||||||
[MENU_TEXT_RELEASE] = gPCText_Release,
|
|
||||||
[MENU_TEXT_MARK] = gPCText_Mark,
|
|
||||||
[MENU_TEXT_JUMP] = gPCText_Jump,
|
|
||||||
[MENU_TEXT_WALLPAPER] = gPCText_Wallpaper,
|
|
||||||
[MENU_TEXT_NAME] = gPCText_Name,
|
|
||||||
[MENU_TEXT_TAKE] = gPCText_Take,
|
|
||||||
[MENU_TEXT_GIVE] = gPCText_Give,
|
|
||||||
[MENU_TEXT_GIVE2] = gPCText_Give,
|
|
||||||
[MENU_TEXT_SWITCH] = gPCText_Switch,
|
|
||||||
[MENU_TEXT_BAG] = gPCText_Bag,
|
|
||||||
[MENU_TEXT_INFO] = gPCText_Info,
|
|
||||||
[MENU_TEXT_SCENERY_1] = gPCText_Scenery1,
|
|
||||||
[MENU_TEXT_SCENERY_2] = gPCText_Scenery2,
|
|
||||||
[MENU_TEXT_SCENERY_3] = gPCText_Scenery3,
|
|
||||||
[MENU_TEXT_ETCETERA] = gPCText_Etcetera,
|
|
||||||
[MENU_TEXT_FOREST] = gPCText_Forest,
|
|
||||||
[MENU_TEXT_CITY] = gPCText_City,
|
|
||||||
[MENU_TEXT_DESERT] = gPCText_Desert,
|
|
||||||
[MENU_TEXT_SAVANNA] = gPCText_Savanna,
|
|
||||||
[MENU_TEXT_CRAG] = gPCText_Crag,
|
|
||||||
[MENU_TEXT_VOLCANO] = gPCText_Volcano,
|
|
||||||
[MENU_TEXT_SNOW] = gPCText_Snow,
|
|
||||||
[MENU_TEXT_CAVE] = gPCText_Cave,
|
|
||||||
[MENU_TEXT_BEACH] = gPCText_Beach,
|
|
||||||
[MENU_TEXT_SEAFLOOR] = gPCText_Seafloor,
|
|
||||||
[MENU_TEXT_RIVER] = gPCText_River,
|
|
||||||
[MENU_TEXT_SKY] = gPCText_Sky,
|
|
||||||
[MENU_TEXT_POLKADOT] = gPCText_PolkaDot,
|
|
||||||
[MENU_TEXT_POKECENTER] = gPCText_Pokecenter,
|
|
||||||
[MENU_TEXT_MACHINE] = gPCText_Machine,
|
|
||||||
[MENU_TEXT_SIMPLE] = gPCText_Simple,
|
|
||||||
};
|
|
||||||
|
|
||||||
void SetMenuText(u8 textId)
|
|
||||||
{
|
|
||||||
if (gStorage->menuItemsCount < ARRAY_COUNT(gStorage->menuItems))
|
|
||||||
{
|
|
||||||
u8 len;
|
|
||||||
struct StorageMenu *menu = &gStorage->menuItems[gStorage->menuItemsCount];
|
|
||||||
|
|
||||||
menu->text = sMenuTexts[textId];
|
|
||||||
menu->textId = textId;
|
|
||||||
len = StringLength(menu->text);
|
|
||||||
if (len > gStorage->menuWidth)
|
|
||||||
gStorage->menuWidth = len;
|
|
||||||
|
|
||||||
gStorage->menuItemsCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s8 GetMenuItemTextId(u8 menuIndex)
|
|
||||||
{
|
|
||||||
if (menuIndex >= gStorage->menuItemsCount)
|
|
||||||
return MENU_B_PRESSED;
|
|
||||||
else
|
|
||||||
return gStorage->menuItems[menuIndex].textId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddMenu(void)
|
|
||||||
{
|
|
||||||
gStorage->menuWindow.width = gStorage->menuWidth + 2;
|
|
||||||
gStorage->menuWindow.height = 2 * gStorage->menuItemsCount;
|
|
||||||
gStorage->menuWindow.tilemapLeft = 29 - gStorage->menuWindow.width;
|
|
||||||
gStorage->menuWindow.tilemapTop = 15 - gStorage->menuWindow.height;
|
|
||||||
gStorage->menuWindowId = AddWindow(&gStorage->menuWindow);
|
|
||||||
ClearWindowTilemap(gStorage->menuWindowId);
|
|
||||||
DrawStdFrameWithCustomTileAndPalette(gStorage->menuWindowId, FALSE, 11, 14);
|
|
||||||
PrintTextArray(gStorage->menuWindowId, FONT_1, 8, 2, 16, gStorage->menuItemsCount, (void *)gStorage->menuItems);
|
|
||||||
Menu_InitCursor(gStorage->menuWindowId, FONT_1, 0, 2, 16, gStorage->menuItemsCount, 0);
|
|
||||||
ScheduleBgCopyTilemapToVram(0);
|
|
||||||
gStorage->menuUnusedField = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool8 IsMenuLoading(void)
|
|
||||||
{
|
|
||||||
// Possibly stubbed out debug code?
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
s16 HandleMenuInput(void)
|
|
||||||
{
|
|
||||||
s32 input = MENU_NOTHING_CHOSEN;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (JOY_NEW(A_BUTTON))
|
|
||||||
{
|
|
||||||
input = Menu_GetCursorPos();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (JOY_NEW(B_BUTTON))
|
|
||||||
{
|
|
||||||
PlaySE(SE_SELECT);
|
|
||||||
input = MENU_B_PRESSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JOY_NEW(DPAD_UP))
|
|
||||||
{
|
|
||||||
PlaySE(SE_SELECT);
|
|
||||||
Menu_MoveCursor(-1);
|
|
||||||
}
|
|
||||||
else if (JOY_NEW(DPAD_DOWN))
|
|
||||||
{
|
|
||||||
PlaySE(SE_SELECT);
|
|
||||||
Menu_MoveCursor(1);
|
|
||||||
}
|
|
||||||
} while (FALSE);
|
|
||||||
|
|
||||||
if (input != MENU_NOTHING_CHOSEN)
|
|
||||||
RemoveMenu();
|
|
||||||
|
|
||||||
if (input >= 0)
|
|
||||||
input = gStorage->menuItems[input].textId;
|
|
||||||
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveMenu(void)
|
|
||||||
{
|
|
||||||
ClearStdWindowAndFrameToTransparent(gStorage->menuWindowId, TRUE);
|
|
||||||
RemoveWindow(gStorage->menuWindowId);
|
|
||||||
}
|
|
||||||
@@ -1,566 +0,0 @@
|
|||||||
#include <stdlib.h> // to declare abs
|
|
||||||
#include "global.h"
|
|
||||||
#include "gflib.h"
|
|
||||||
#include "pokemon_icon.h"
|
|
||||||
#include "pokemon_storage_system_internal.h"
|
|
||||||
#include "text_window.h"
|
|
||||||
|
|
||||||
static EWRAM_DATA struct
|
|
||||||
{
|
|
||||||
u8 funcId;
|
|
||||||
u8 state;
|
|
||||||
u8 fromColumn;
|
|
||||||
u8 fromRow;
|
|
||||||
u8 toColumn;
|
|
||||||
u8 toRow;
|
|
||||||
u8 cursorColumn;
|
|
||||||
u8 cursorRow;
|
|
||||||
u8 minColumn;
|
|
||||||
u8 minRow;
|
|
||||||
u8 columnsTotal;
|
|
||||||
u8 rowsTotal;
|
|
||||||
u16 bgX;
|
|
||||||
u16 bgY;
|
|
||||||
u16 bgMoveSteps;
|
|
||||||
struct BoxPokemon boxMons[IN_BOX_COUNT];
|
|
||||||
} *sMultiMove = NULL;
|
|
||||||
|
|
||||||
static bool8 MultiMove_Function_Start(void);
|
|
||||||
static bool8 MultiMove_Function_Single(void);
|
|
||||||
static bool8 MultiMove_Function_ChangeSelection(void);
|
|
||||||
static bool8 MultiMove_Function_GrabSelection(void);
|
|
||||||
static bool8 MultiMove_Function_MoveMons(void);
|
|
||||||
static bool8 MultiMove_Function_PlaceMons(void);
|
|
||||||
static void MultiMove_UpdateSelectedIcons(void);
|
|
||||||
static void MultiMove_SelectColumn(u8 column, u8 minRow, u8 maxRow);
|
|
||||||
static void MultiMove_SelectRow(u8 row, u8 minColumn, u8 maxColumn);
|
|
||||||
static void MultiMove_DeselectColumn(u8 arg0, u8 minRow, u8 maxRow);
|
|
||||||
static void MultiMove_DeselectRow(u8 row, u8 minColumn, u8 maxColumn);
|
|
||||||
static void MultiMove_SetIconToBg(u8 x, u8 y);
|
|
||||||
static void MultiMove_ClearIconFromBg(u8 x, u8 y);
|
|
||||||
static void MultiMove_InitBg(u16 bgX, u16 bgY, u16 duration);
|
|
||||||
static u8 MultiMove_UpdateBg(void);
|
|
||||||
static void MultiMove_GetMonsFromSelection(void);
|
|
||||||
static void MultiMove_RemoveMonsFromBox(void);
|
|
||||||
static void MultiMove_CreatePlacedMonIcons(void);
|
|
||||||
static void MultiMove_SetPlacedMonData(void);
|
|
||||||
static void MultiMove_ResetBg(void);
|
|
||||||
|
|
||||||
static const struct WindowTemplate sWindowTemplate_MultiMove = {
|
|
||||||
.bg = 0,
|
|
||||||
.tilemapLeft = 10,
|
|
||||||
.tilemapTop = 3,
|
|
||||||
.width = 20,
|
|
||||||
.height = 18,
|
|
||||||
.paletteNum = 9,
|
|
||||||
.baseBlock = 0x00a
|
|
||||||
};
|
|
||||||
|
|
||||||
bool8 MultiMove_Init(void)
|
|
||||||
{
|
|
||||||
sMultiMove = Alloc(sizeof(*sMultiMove));
|
|
||||||
if (sMultiMove != NULL)
|
|
||||||
{
|
|
||||||
gStorage->multiMoveWindowId = AddWindow8Bit(&sWindowTemplate_MultiMove);
|
|
||||||
if (gStorage->multiMoveWindowId != WINDOW_NONE)
|
|
||||||
{
|
|
||||||
FillWindowPixelBuffer(gStorage->multiMoveWindowId, PIXEL_FILL(0));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiMove_Free(void)
|
|
||||||
{
|
|
||||||
if (sMultiMove != NULL)
|
|
||||||
Free(sMultiMove);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiMove_SetFunction(u8 funcId)
|
|
||||||
{
|
|
||||||
sMultiMove->funcId = funcId;
|
|
||||||
sMultiMove->state = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool8 MultiMove_RunFunction(void)
|
|
||||||
{
|
|
||||||
switch (sMultiMove->funcId)
|
|
||||||
{
|
|
||||||
case MULTIMOVE_START:
|
|
||||||
return MultiMove_Function_Start();
|
|
||||||
case MULTIMOVE_SINGLE:
|
|
||||||
return MultiMove_Function_Single();
|
|
||||||
case MULTIMOVE_CHANGE_SELECTION:
|
|
||||||
return MultiMove_Function_ChangeSelection();
|
|
||||||
case MULTIMOVE_GRAB_SELECTION:
|
|
||||||
return MultiMove_Function_GrabSelection();
|
|
||||||
case MULTIMOVE_MOVE_MONS:
|
|
||||||
return MultiMove_Function_MoveMons();
|
|
||||||
case MULTIMOVE_PLACE_MONS:
|
|
||||||
return MultiMove_Function_PlaceMons();
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool8 MultiMove_Function_Start(void)
|
|
||||||
{
|
|
||||||
switch (sMultiMove->state)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
HideBg(0);
|
|
||||||
LoadMonIconPalettesAt(0x80);
|
|
||||||
sMultiMove->state++;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
GetCursorBoxColumnAndRow(&sMultiMove->fromColumn, &sMultiMove->fromRow);
|
|
||||||
sMultiMove->toColumn = sMultiMove->fromColumn;
|
|
||||||
sMultiMove->toRow = sMultiMove->fromRow;
|
|
||||||
ChangeBgX(0, -1024, BG_COORD_SET);
|
|
||||||
ChangeBgY(0, -1024, BG_COORD_SET);
|
|
||||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
|
|
||||||
FillWindowPixelBuffer8Bit(gStorage->multiMoveWindowId, PIXEL_FILL(0));
|
|
||||||
MultiMove_SetIconToBg(sMultiMove->fromColumn, sMultiMove->fromRow);
|
|
||||||
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
|
|
||||||
PutWindowTilemap(gStorage->multiMoveWindowId);
|
|
||||||
CopyWindowToVram8Bit(gStorage->multiMoveWindowId, COPYWIN_FULL);
|
|
||||||
BlendPalettes(0x3F00, 8, RGB_WHITE);
|
|
||||||
StartCursorAnim(CURSOR_ANIM_OPEN);
|
|
||||||
SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
|
||||||
sMultiMove->state++;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (!IsDma3ManagerBusyWithBgCopy())
|
|
||||||
{
|
|
||||||
ShowBg(0);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool8 MultiMove_Function_Single(void)
|
|
||||||
{
|
|
||||||
switch (sMultiMove->state)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
HideBg(0);
|
|
||||||
sMultiMove->state++;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
MultiMove_ResetBg();
|
|
||||||
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
|
||||||
sMultiMove->state++;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (!IsDma3ManagerBusyWithBgCopy())
|
|
||||||
{
|
|
||||||
SetCursorPriorityTo1();
|
|
||||||
LoadPalette(stdpal_get(3), 0xD0, 0x20);
|
|
||||||
ShowBg(0);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool8 MultiMove_Function_ChangeSelection(void)
|
|
||||||
{
|
|
||||||
switch (sMultiMove->state)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
if (!UpdateCursorPos())
|
|
||||||
{
|
|
||||||
GetCursorBoxColumnAndRow(&sMultiMove->cursorColumn, &sMultiMove->cursorRow);
|
|
||||||
MultiMove_UpdateSelectedIcons();
|
|
||||||
sMultiMove->toColumn = sMultiMove->cursorColumn;
|
|
||||||
sMultiMove->toRow = sMultiMove->cursorRow;
|
|
||||||
CopyWindowToVram8Bit(gStorage->multiMoveWindowId, COPYWIN_GFX);
|
|
||||||
sMultiMove->state++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
return IsDma3ManagerBusyWithBgCopy();
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool8 MultiMove_Function_GrabSelection(void)
|
|
||||||
{
|
|
||||||
u8 movingBg, movingMon;
|
|
||||||
|
|
||||||
switch (sMultiMove->state)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
MultiMove_GetMonsFromSelection();
|
|
||||||
MultiMove_RemoveMonsFromBox();
|
|
||||||
InitMultiMonPlaceChange(FALSE);
|
|
||||||
sMultiMove->state++;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (!DoMonPlaceChange())
|
|
||||||
{
|
|
||||||
StartCursorAnim(CURSOR_ANIM_FIST);
|
|
||||||
MultiMove_InitBg(0, 256, 8);
|
|
||||||
InitMultiMonPlaceChange(TRUE);
|
|
||||||
sMultiMove->state++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
movingBg = MultiMove_UpdateBg();
|
|
||||||
movingMon = DoMonPlaceChange();
|
|
||||||
if (!movingBg && !movingMon)
|
|
||||||
return FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool8 MultiMove_Function_MoveMons(void)
|
|
||||||
{
|
|
||||||
u8 movingCursor = UpdateCursorPos();
|
|
||||||
u8 movingBg = MultiMove_UpdateBg();
|
|
||||||
|
|
||||||
if (!movingCursor && !movingBg)
|
|
||||||
return FALSE;
|
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool8 MultiMove_Function_PlaceMons(void)
|
|
||||||
{
|
|
||||||
switch (sMultiMove->state)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
MultiMove_SetPlacedMonData();
|
|
||||||
MultiMove_InitBg(0, -256, 8);
|
|
||||||
InitMultiMonPlaceChange(FALSE);
|
|
||||||
sMultiMove->state++;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (!DoMonPlaceChange() && !MultiMove_UpdateBg())
|
|
||||||
{
|
|
||||||
MultiMove_CreatePlacedMonIcons();
|
|
||||||
StartCursorAnim(CURSOR_ANIM_OPEN);
|
|
||||||
InitMultiMonPlaceChange(TRUE);
|
|
||||||
HideBg(0);
|
|
||||||
sMultiMove->state++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (!DoMonPlaceChange())
|
|
||||||
{
|
|
||||||
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
|
||||||
MultiMove_ResetBg();
|
|
||||||
sMultiMove->state++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (!IsDma3ManagerBusyWithBgCopy())
|
|
||||||
{
|
|
||||||
LoadPalette(stdpal_get(3), 0xD0, 0x20);
|
|
||||||
SetCursorPriorityTo1();
|
|
||||||
ShowBg(0);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool8 MultiMove_TryMoveGroup(u8 dir)
|
|
||||||
{
|
|
||||||
switch (dir)
|
|
||||||
{
|
|
||||||
case 0: // up
|
|
||||||
if (sMultiMove->minRow == 0)
|
|
||||||
return FALSE;
|
|
||||||
sMultiMove->minRow--;
|
|
||||||
MultiMove_InitBg(0, 1024, 6);
|
|
||||||
break;
|
|
||||||
case 1: // down
|
|
||||||
if (sMultiMove->minRow + sMultiMove->rowsTotal >= 5)
|
|
||||||
return FALSE;
|
|
||||||
sMultiMove->minRow++;
|
|
||||||
MultiMove_InitBg(0, -1024, 6);
|
|
||||||
break;
|
|
||||||
case 2: // left
|
|
||||||
if (sMultiMove->minColumn == 0)
|
|
||||||
return FALSE;
|
|
||||||
sMultiMove->minColumn--;
|
|
||||||
MultiMove_InitBg(1024, 0, 6);
|
|
||||||
break;
|
|
||||||
case 3: // right
|
|
||||||
if (sMultiMove->minColumn + sMultiMove->columnsTotal > 5)
|
|
||||||
return FALSE;
|
|
||||||
sMultiMove->minColumn++;
|
|
||||||
MultiMove_InitBg(-1024, 0, 6);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_UpdateSelectedIcons(void)
|
|
||||||
{
|
|
||||||
s16 columnChange = (abs(sMultiMove->fromColumn - sMultiMove->cursorColumn)) - (abs(sMultiMove->fromColumn - sMultiMove->toColumn));
|
|
||||||
s16 rowChange = (abs(sMultiMove->fromRow - sMultiMove->cursorRow)) - (abs(sMultiMove->fromRow - sMultiMove->toRow));
|
|
||||||
|
|
||||||
if (columnChange > 0)
|
|
||||||
MultiMove_SelectColumn(sMultiMove->cursorColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
|
||||||
|
|
||||||
if (columnChange < 0)
|
|
||||||
{
|
|
||||||
MultiMove_DeselectColumn(sMultiMove->toColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
|
||||||
MultiMove_SelectColumn(sMultiMove->cursorColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rowChange > 0)
|
|
||||||
MultiMove_SelectRow(sMultiMove->cursorRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
|
||||||
|
|
||||||
if (rowChange < 0)
|
|
||||||
{
|
|
||||||
MultiMove_DeselectRow(sMultiMove->toRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
|
||||||
MultiMove_SelectRow(sMultiMove->cursorRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_SelectColumn(u8 column, u8 minRow, u8 maxRow)
|
|
||||||
{
|
|
||||||
u8 tmp = minRow;
|
|
||||||
|
|
||||||
if (minRow > maxRow)
|
|
||||||
{
|
|
||||||
minRow = maxRow;
|
|
||||||
maxRow = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (minRow <= maxRow)
|
|
||||||
MultiMove_SetIconToBg(column, minRow++);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_SelectRow(u8 row, u8 minColumn, u8 maxColumn)
|
|
||||||
{
|
|
||||||
u8 tmp = minColumn;
|
|
||||||
|
|
||||||
if (minColumn > maxColumn)
|
|
||||||
{
|
|
||||||
minColumn = maxColumn;
|
|
||||||
maxColumn = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (minColumn <= maxColumn)
|
|
||||||
MultiMove_SetIconToBg(minColumn++, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_DeselectColumn(u8 column, u8 minRow, u8 maxRow)
|
|
||||||
{
|
|
||||||
u8 tmp = minRow;
|
|
||||||
|
|
||||||
if (minRow > maxRow)
|
|
||||||
{
|
|
||||||
minRow = maxRow;
|
|
||||||
maxRow = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (minRow <= maxRow)
|
|
||||||
MultiMove_ClearIconFromBg(column, minRow++);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_DeselectRow(u8 row, u8 minColumn, u8 maxColumn)
|
|
||||||
{
|
|
||||||
u8 tmp = minColumn;
|
|
||||||
|
|
||||||
if (minColumn > maxColumn)
|
|
||||||
{
|
|
||||||
minColumn = maxColumn;
|
|
||||||
maxColumn = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (minColumn <= maxColumn)
|
|
||||||
MultiMove_ClearIconFromBg(minColumn++, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_SetIconToBg(u8 x, u8 y)
|
|
||||||
{
|
|
||||||
u8 position = x + (IN_BOX_COLUMNS * y);
|
|
||||||
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
|
||||||
u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY);
|
|
||||||
|
|
||||||
if (species != SPECIES_NONE)
|
|
||||||
{
|
|
||||||
const u8 *iconGfx = GetMonIconPtr(species, personality, 1);
|
|
||||||
u8 palNum = GetValidMonIconPalIndex(species) + 8;
|
|
||||||
BlitBitmapRectToWindow4BitTo8Bit(gStorage->multiMoveWindowId, iconGfx, 0, 0, 32, 32, 24 * x, 24 * y, 32, 32, palNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_ClearIconFromBg(u8 x, u8 y)
|
|
||||||
{
|
|
||||||
u8 position = x + (IN_BOX_COLUMNS * y);
|
|
||||||
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
|
||||||
|
|
||||||
if (species != SPECIES_NONE)
|
|
||||||
FillWindowPixelRect8Bit(gStorage->multiMoveWindowId, PIXEL_FILL(0), 24 * x, 24 * y, 32, 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_InitBg(u16 bgX, u16 bgY, u16 duration)
|
|
||||||
{
|
|
||||||
sMultiMove->bgX = bgX;
|
|
||||||
sMultiMove->bgY = bgY;
|
|
||||||
sMultiMove->bgMoveSteps = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
static u8 MultiMove_UpdateBg(void)
|
|
||||||
{
|
|
||||||
if (sMultiMove->bgMoveSteps != 0)
|
|
||||||
{
|
|
||||||
ChangeBgX(0, sMultiMove->bgX, BG_COORD_ADD);
|
|
||||||
ChangeBgY(0, sMultiMove->bgY, BG_COORD_ADD);
|
|
||||||
sMultiMove->bgMoveSteps--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sMultiMove->bgMoveSteps;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_GetMonsFromSelection(void)
|
|
||||||
{
|
|
||||||
s32 i, j;
|
|
||||||
s32 columnCount, rowCount;
|
|
||||||
u8 boxId;
|
|
||||||
u8 monArrayId;
|
|
||||||
|
|
||||||
sMultiMove->minColumn = min(sMultiMove->fromColumn, sMultiMove->toColumn);
|
|
||||||
sMultiMove->minRow = min(sMultiMove->fromRow, sMultiMove->toRow);
|
|
||||||
sMultiMove->columnsTotal = abs(sMultiMove->fromColumn - sMultiMove->toColumn) + 1;
|
|
||||||
sMultiMove->rowsTotal = abs(sMultiMove->fromRow - sMultiMove->toRow) + 1;
|
|
||||||
boxId = StorageGetCurrentBox();
|
|
||||||
monArrayId = 0;
|
|
||||||
columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
||||||
rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
|
||||||
for (i = sMultiMove->minRow; i < rowCount; i++)
|
|
||||||
{
|
|
||||||
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
||||||
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
|
||||||
{
|
|
||||||
struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition);
|
|
||||||
// UB: possible null dereference
|
|
||||||
#ifdef UBFIX
|
|
||||||
if (boxMon != NULL)
|
|
||||||
sMultiMove->boxMons[monArrayId] = *boxMon;
|
|
||||||
#else
|
|
||||||
sMultiMove->boxMons[monArrayId] = *boxMon;
|
|
||||||
#endif
|
|
||||||
monArrayId++;
|
|
||||||
boxPosition++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_RemoveMonsFromBox(void)
|
|
||||||
{
|
|
||||||
s32 i, j;
|
|
||||||
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
||||||
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
|
||||||
u8 boxId = StorageGetCurrentBox();
|
|
||||||
|
|
||||||
for (i = sMultiMove->minRow; i < rowCount; i++)
|
|
||||||
{
|
|
||||||
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
||||||
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
|
||||||
{
|
|
||||||
DestroyBoxMonIconAtPosition(boxPosition);
|
|
||||||
ZeroBoxMonAt(boxId, boxPosition);
|
|
||||||
boxPosition++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_CreatePlacedMonIcons(void)
|
|
||||||
{
|
|
||||||
s32 i, j;
|
|
||||||
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
||||||
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
|
||||||
u8 monArrayId = 0;
|
|
||||||
|
|
||||||
for (i = sMultiMove->minRow; i < rowCount; i++)
|
|
||||||
{
|
|
||||||
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
||||||
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
|
||||||
{
|
|
||||||
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
|
||||||
CreateBoxMonIconAtPos(boxPosition);
|
|
||||||
monArrayId++;
|
|
||||||
boxPosition++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_SetPlacedMonData(void)
|
|
||||||
{
|
|
||||||
s32 i, j;
|
|
||||||
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
||||||
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
|
||||||
u8 boxId = StorageGetCurrentBox();
|
|
||||||
u8 monArrayId = 0;
|
|
||||||
|
|
||||||
for (i = sMultiMove->minRow; i < rowCount; i++)
|
|
||||||
{
|
|
||||||
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
||||||
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
|
||||||
{
|
|
||||||
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
|
||||||
SetBoxMonAt(boxId, boxPosition, &sMultiMove->boxMons[monArrayId]);
|
|
||||||
boxPosition++;
|
|
||||||
monArrayId++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MultiMove_ResetBg(void)
|
|
||||||
{
|
|
||||||
ChangeBgX(0, 0, BG_COORD_SET);
|
|
||||||
ChangeBgY(0, 0, BG_COORD_SET);
|
|
||||||
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0);
|
|
||||||
ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
|
||||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
|
|
||||||
CopyBgTilemapBufferToVram(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 MultiMove_GetOriginPosition(void)
|
|
||||||
{
|
|
||||||
return (IN_BOX_COLUMNS * sMultiMove->fromRow) + sMultiMove->fromColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool8 MultiMove_CanPlaceSelection(void)
|
|
||||||
{
|
|
||||||
s32 i, j;
|
|
||||||
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
||||||
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
|
||||||
u8 monArrayId = 0;
|
|
||||||
|
|
||||||
for (i = sMultiMove->minRow; i < rowCount; i++)
|
|
||||||
{
|
|
||||||
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
||||||
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
|
||||||
{
|
|
||||||
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)
|
|
||||||
&& GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
monArrayId++;
|
|
||||||
boxPosition++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
@@ -3,11 +3,14 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "mail_data.h"
|
#include "mail_data.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "new_menu_helpers.h"
|
||||||
#include "pokemon_storage_system_internal.h"
|
#include "pokemon_storage_system_internal.h"
|
||||||
#include "pokemon_summary_screen.h"
|
#include "pokemon_summary_screen.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "constants/items.h"
|
#include "constants/items.h"
|
||||||
#include "constants/moves.h"
|
#include "constants/moves.h"
|
||||||
|
#include "constants/songs.h"
|
||||||
|
|
||||||
static EWRAM_DATA struct Pokemon sMonBeingCarried = {};
|
static EWRAM_DATA struct Pokemon sMonBeingCarried = {};
|
||||||
static EWRAM_DATA s8 sCursorArea = 0;
|
static EWRAM_DATA s8 sCursorArea = 0;
|
||||||
@@ -2020,3 +2023,143 @@ void TryShowItemAtCursor(void)
|
|||||||
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
||||||
TryLoadItemIconAtPos(CURSOR_AREA_IN_BOX, sCursorPosition);
|
TryLoadItemIconAtPos(CURSOR_AREA_IN_BOX, sCursorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const u8 *const sMenuTexts[] = {
|
||||||
|
[MENU_TEXT_CANCEL] = gPCText_Cancel,
|
||||||
|
[MENU_TEXT_STORE] = gPCText_Store,
|
||||||
|
[MENU_TEXT_WITHDRAW] = gPCText_Withdraw,
|
||||||
|
[MENU_TEXT_MOVE] = gPCText_Move,
|
||||||
|
[MENU_TEXT_SHIFT] = gPCText_Shift,
|
||||||
|
[MENU_TEXT_PLACE] = gPCText_Place,
|
||||||
|
[MENU_TEXT_SUMMARY] = gPCText_Summary,
|
||||||
|
[MENU_TEXT_RELEASE] = gPCText_Release,
|
||||||
|
[MENU_TEXT_MARK] = gPCText_Mark,
|
||||||
|
[MENU_TEXT_JUMP] = gPCText_Jump,
|
||||||
|
[MENU_TEXT_WALLPAPER] = gPCText_Wallpaper,
|
||||||
|
[MENU_TEXT_NAME] = gPCText_Name,
|
||||||
|
[MENU_TEXT_TAKE] = gPCText_Take,
|
||||||
|
[MENU_TEXT_GIVE] = gPCText_Give,
|
||||||
|
[MENU_TEXT_GIVE2] = gPCText_Give,
|
||||||
|
[MENU_TEXT_SWITCH] = gPCText_Switch,
|
||||||
|
[MENU_TEXT_BAG] = gPCText_Bag,
|
||||||
|
[MENU_TEXT_INFO] = gPCText_Info,
|
||||||
|
[MENU_TEXT_SCENERY_1] = gPCText_Scenery1,
|
||||||
|
[MENU_TEXT_SCENERY_2] = gPCText_Scenery2,
|
||||||
|
[MENU_TEXT_SCENERY_3] = gPCText_Scenery3,
|
||||||
|
[MENU_TEXT_ETCETERA] = gPCText_Etcetera,
|
||||||
|
[MENU_TEXT_FOREST] = gPCText_Forest,
|
||||||
|
[MENU_TEXT_CITY] = gPCText_City,
|
||||||
|
[MENU_TEXT_DESERT] = gPCText_Desert,
|
||||||
|
[MENU_TEXT_SAVANNA] = gPCText_Savanna,
|
||||||
|
[MENU_TEXT_CRAG] = gPCText_Crag,
|
||||||
|
[MENU_TEXT_VOLCANO] = gPCText_Volcano,
|
||||||
|
[MENU_TEXT_SNOW] = gPCText_Snow,
|
||||||
|
[MENU_TEXT_CAVE] = gPCText_Cave,
|
||||||
|
[MENU_TEXT_BEACH] = gPCText_Beach,
|
||||||
|
[MENU_TEXT_SEAFLOOR] = gPCText_Seafloor,
|
||||||
|
[MENU_TEXT_RIVER] = gPCText_River,
|
||||||
|
[MENU_TEXT_SKY] = gPCText_Sky,
|
||||||
|
[MENU_TEXT_POLKADOT] = gPCText_PolkaDot,
|
||||||
|
[MENU_TEXT_POKECENTER] = gPCText_Pokecenter,
|
||||||
|
[MENU_TEXT_MACHINE] = gPCText_Machine,
|
||||||
|
[MENU_TEXT_SIMPLE] = gPCText_Simple,
|
||||||
|
};
|
||||||
|
|
||||||
|
void InitMenu(void)
|
||||||
|
{
|
||||||
|
gStorage->menuItemsCount = 0;
|
||||||
|
gStorage->menuWidth = 0;
|
||||||
|
gStorage->menuWindow.bg = 0;
|
||||||
|
gStorage->menuWindow.paletteNum = 15;
|
||||||
|
gStorage->menuWindow.baseBlock = 92;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMenuText(u8 textId)
|
||||||
|
{
|
||||||
|
if (gStorage->menuItemsCount < ARRAY_COUNT(gStorage->menuItems))
|
||||||
|
{
|
||||||
|
u8 len;
|
||||||
|
struct StorageMenu *menu = &gStorage->menuItems[gStorage->menuItemsCount];
|
||||||
|
|
||||||
|
menu->text = sMenuTexts[textId];
|
||||||
|
menu->textId = textId;
|
||||||
|
len = StringLength(menu->text);
|
||||||
|
if (len > gStorage->menuWidth)
|
||||||
|
gStorage->menuWidth = len;
|
||||||
|
|
||||||
|
gStorage->menuItemsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 GetMenuItemTextId(u8 menuIndex)
|
||||||
|
{
|
||||||
|
if (menuIndex >= gStorage->menuItemsCount)
|
||||||
|
return MENU_B_PRESSED;
|
||||||
|
else
|
||||||
|
return gStorage->menuItems[menuIndex].textId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddMenu(void)
|
||||||
|
{
|
||||||
|
gStorage->menuWindow.width = gStorage->menuWidth + 2;
|
||||||
|
gStorage->menuWindow.height = 2 * gStorage->menuItemsCount;
|
||||||
|
gStorage->menuWindow.tilemapLeft = 29 - gStorage->menuWindow.width;
|
||||||
|
gStorage->menuWindow.tilemapTop = 15 - gStorage->menuWindow.height;
|
||||||
|
gStorage->menuWindowId = AddWindow(&gStorage->menuWindow);
|
||||||
|
ClearWindowTilemap(gStorage->menuWindowId);
|
||||||
|
DrawStdFrameWithCustomTileAndPalette(gStorage->menuWindowId, FALSE, 11, 14);
|
||||||
|
PrintTextArray(gStorage->menuWindowId, FONT_1, 8, 2, 16, gStorage->menuItemsCount, (void *)gStorage->menuItems);
|
||||||
|
Menu_InitCursor(gStorage->menuWindowId, FONT_1, 0, 2, 16, gStorage->menuItemsCount, 0);
|
||||||
|
ScheduleBgCopyTilemapToVram(0);
|
||||||
|
gStorage->menuUnusedField = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 IsMenuLoading(void)
|
||||||
|
{
|
||||||
|
// Possibly stubbed out debug code?
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
s16 HandleMenuInput(void)
|
||||||
|
{
|
||||||
|
s32 input = MENU_NOTHING_CHOSEN;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (JOY_NEW(A_BUTTON))
|
||||||
|
{
|
||||||
|
input = Menu_GetCursorPos();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (JOY_NEW(B_BUTTON))
|
||||||
|
{
|
||||||
|
PlaySE(SE_SELECT);
|
||||||
|
input = MENU_B_PRESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JOY_NEW(DPAD_UP))
|
||||||
|
{
|
||||||
|
PlaySE(SE_SELECT);
|
||||||
|
Menu_MoveCursor(-1);
|
||||||
|
}
|
||||||
|
else if (JOY_NEW(DPAD_DOWN))
|
||||||
|
{
|
||||||
|
PlaySE(SE_SELECT);
|
||||||
|
Menu_MoveCursor(1);
|
||||||
|
}
|
||||||
|
} while (FALSE);
|
||||||
|
|
||||||
|
if (input != MENU_NOTHING_CHOSEN)
|
||||||
|
RemoveMenu();
|
||||||
|
|
||||||
|
if (input >= 0)
|
||||||
|
input = gStorage->menuItems[input].textId;
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveMenu(void)
|
||||||
|
{
|
||||||
|
ClearStdWindowAndFrameToTransparent(gStorage->menuWindowId, TRUE);
|
||||||
|
RemoveWindow(gStorage->menuWindowId);
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <stdlib.h> // to declare abs
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "gflib.h"
|
#include "gflib.h"
|
||||||
#include "decompress.h"
|
#include "decompress.h"
|
||||||
@@ -5,10 +6,572 @@
|
|||||||
#include "item_menu_icons.h"
|
#include "item_menu_icons.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "new_menu_helpers.h"
|
#include "new_menu_helpers.h"
|
||||||
|
#include "pokemon_icon.h"
|
||||||
#include "pokemon_storage_system_internal.h"
|
#include "pokemon_storage_system_internal.h"
|
||||||
|
#include "text_window.h"
|
||||||
#include "trig.h"
|
#include "trig.h"
|
||||||
#include "constants/items.h"
|
#include "constants/items.h"
|
||||||
|
|
||||||
|
static EWRAM_DATA struct
|
||||||
|
{
|
||||||
|
u8 funcId;
|
||||||
|
u8 state;
|
||||||
|
u8 fromColumn;
|
||||||
|
u8 fromRow;
|
||||||
|
u8 toColumn;
|
||||||
|
u8 toRow;
|
||||||
|
u8 cursorColumn;
|
||||||
|
u8 cursorRow;
|
||||||
|
u8 minColumn;
|
||||||
|
u8 minRow;
|
||||||
|
u8 columnsTotal;
|
||||||
|
u8 rowsTotal;
|
||||||
|
u16 bgX;
|
||||||
|
u16 bgY;
|
||||||
|
u16 bgMoveSteps;
|
||||||
|
struct BoxPokemon boxMons[IN_BOX_COUNT];
|
||||||
|
} *sMultiMove = NULL;
|
||||||
|
|
||||||
|
static bool8 MultiMove_Function_Start(void);
|
||||||
|
static bool8 MultiMove_Function_Single(void);
|
||||||
|
static bool8 MultiMove_Function_ChangeSelection(void);
|
||||||
|
static bool8 MultiMove_Function_GrabSelection(void);
|
||||||
|
static bool8 MultiMove_Function_MoveMons(void);
|
||||||
|
static bool8 MultiMove_Function_PlaceMons(void);
|
||||||
|
static void MultiMove_UpdateSelectedIcons(void);
|
||||||
|
static void MultiMove_SelectColumn(u8 column, u8 minRow, u8 maxRow);
|
||||||
|
static void MultiMove_SelectRow(u8 row, u8 minColumn, u8 maxColumn);
|
||||||
|
static void MultiMove_DeselectColumn(u8 arg0, u8 minRow, u8 maxRow);
|
||||||
|
static void MultiMove_DeselectRow(u8 row, u8 minColumn, u8 maxColumn);
|
||||||
|
static void MultiMove_SetIconToBg(u8 x, u8 y);
|
||||||
|
static void MultiMove_ClearIconFromBg(u8 x, u8 y);
|
||||||
|
static void MultiMove_InitBg(u16 bgX, u16 bgY, u16 duration);
|
||||||
|
static u8 MultiMove_UpdateBg(void);
|
||||||
|
static void MultiMove_GetMonsFromSelection(void);
|
||||||
|
static void MultiMove_RemoveMonsFromBox(void);
|
||||||
|
static void MultiMove_CreatePlacedMonIcons(void);
|
||||||
|
static void MultiMove_SetPlacedMonData(void);
|
||||||
|
static void MultiMove_ResetBg(void);
|
||||||
|
|
||||||
|
static const struct WindowTemplate sWindowTemplate_MultiMove = {
|
||||||
|
.bg = 0,
|
||||||
|
.tilemapLeft = 10,
|
||||||
|
.tilemapTop = 3,
|
||||||
|
.width = 20,
|
||||||
|
.height = 18,
|
||||||
|
.paletteNum = 9,
|
||||||
|
.baseBlock = 0x00a
|
||||||
|
};
|
||||||
|
|
||||||
|
bool8 MultiMove_Init(void)
|
||||||
|
{
|
||||||
|
sMultiMove = Alloc(sizeof(*sMultiMove));
|
||||||
|
if (sMultiMove != NULL)
|
||||||
|
{
|
||||||
|
gStorage->multiMoveWindowId = AddWindow8Bit(&sWindowTemplate_MultiMove);
|
||||||
|
if (gStorage->multiMoveWindowId != WINDOW_NONE)
|
||||||
|
{
|
||||||
|
FillWindowPixelBuffer(gStorage->multiMoveWindowId, PIXEL_FILL(0));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiMove_Free(void)
|
||||||
|
{
|
||||||
|
if (sMultiMove != NULL)
|
||||||
|
Free(sMultiMove);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiMove_SetFunction(u8 funcId)
|
||||||
|
{
|
||||||
|
sMultiMove->funcId = funcId;
|
||||||
|
sMultiMove->state = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 MultiMove_RunFunction(void)
|
||||||
|
{
|
||||||
|
switch (sMultiMove->funcId)
|
||||||
|
{
|
||||||
|
case MULTIMOVE_START:
|
||||||
|
return MultiMove_Function_Start();
|
||||||
|
case MULTIMOVE_SINGLE:
|
||||||
|
return MultiMove_Function_Single();
|
||||||
|
case MULTIMOVE_CHANGE_SELECTION:
|
||||||
|
return MultiMove_Function_ChangeSelection();
|
||||||
|
case MULTIMOVE_GRAB_SELECTION:
|
||||||
|
return MultiMove_Function_GrabSelection();
|
||||||
|
case MULTIMOVE_MOVE_MONS:
|
||||||
|
return MultiMove_Function_MoveMons();
|
||||||
|
case MULTIMOVE_PLACE_MONS:
|
||||||
|
return MultiMove_Function_PlaceMons();
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool8 MultiMove_Function_Start(void)
|
||||||
|
{
|
||||||
|
switch (sMultiMove->state)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
HideBg(0);
|
||||||
|
LoadMonIconPalettesAt(0x80);
|
||||||
|
sMultiMove->state++;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
GetCursorBoxColumnAndRow(&sMultiMove->fromColumn, &sMultiMove->fromRow);
|
||||||
|
sMultiMove->toColumn = sMultiMove->fromColumn;
|
||||||
|
sMultiMove->toRow = sMultiMove->fromRow;
|
||||||
|
ChangeBgX(0, -1024, BG_COORD_SET);
|
||||||
|
ChangeBgY(0, -1024, BG_COORD_SET);
|
||||||
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
|
||||||
|
FillWindowPixelBuffer8Bit(gStorage->multiMoveWindowId, PIXEL_FILL(0));
|
||||||
|
MultiMove_SetIconToBg(sMultiMove->fromColumn, sMultiMove->fromRow);
|
||||||
|
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
|
||||||
|
PutWindowTilemap(gStorage->multiMoveWindowId);
|
||||||
|
CopyWindowToVram8Bit(gStorage->multiMoveWindowId, COPYWIN_FULL);
|
||||||
|
BlendPalettes(0x3F00, 8, RGB_WHITE);
|
||||||
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
||||||
|
SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
||||||
|
sMultiMove->state++;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (!IsDma3ManagerBusyWithBgCopy())
|
||||||
|
{
|
||||||
|
ShowBg(0);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool8 MultiMove_Function_Single(void)
|
||||||
|
{
|
||||||
|
switch (sMultiMove->state)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
HideBg(0);
|
||||||
|
sMultiMove->state++;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
MultiMove_ResetBg();
|
||||||
|
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
||||||
|
sMultiMove->state++;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (!IsDma3ManagerBusyWithBgCopy())
|
||||||
|
{
|
||||||
|
SetCursorPriorityTo1();
|
||||||
|
LoadPalette(stdpal_get(3), 0xD0, 0x20);
|
||||||
|
ShowBg(0);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool8 MultiMove_Function_ChangeSelection(void)
|
||||||
|
{
|
||||||
|
switch (sMultiMove->state)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
if (!UpdateCursorPos())
|
||||||
|
{
|
||||||
|
GetCursorBoxColumnAndRow(&sMultiMove->cursorColumn, &sMultiMove->cursorRow);
|
||||||
|
MultiMove_UpdateSelectedIcons();
|
||||||
|
sMultiMove->toColumn = sMultiMove->cursorColumn;
|
||||||
|
sMultiMove->toRow = sMultiMove->cursorRow;
|
||||||
|
CopyWindowToVram8Bit(gStorage->multiMoveWindowId, COPYWIN_GFX);
|
||||||
|
sMultiMove->state++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
return IsDma3ManagerBusyWithBgCopy();
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool8 MultiMove_Function_GrabSelection(void)
|
||||||
|
{
|
||||||
|
u8 movingBg, movingMon;
|
||||||
|
|
||||||
|
switch (sMultiMove->state)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
MultiMove_GetMonsFromSelection();
|
||||||
|
MultiMove_RemoveMonsFromBox();
|
||||||
|
InitMultiMonPlaceChange(FALSE);
|
||||||
|
sMultiMove->state++;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (!DoMonPlaceChange())
|
||||||
|
{
|
||||||
|
StartCursorAnim(CURSOR_ANIM_FIST);
|
||||||
|
MultiMove_InitBg(0, 256, 8);
|
||||||
|
InitMultiMonPlaceChange(TRUE);
|
||||||
|
sMultiMove->state++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
movingBg = MultiMove_UpdateBg();
|
||||||
|
movingMon = DoMonPlaceChange();
|
||||||
|
if (!movingBg && !movingMon)
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool8 MultiMove_Function_MoveMons(void)
|
||||||
|
{
|
||||||
|
u8 movingCursor = UpdateCursorPos();
|
||||||
|
u8 movingBg = MultiMove_UpdateBg();
|
||||||
|
|
||||||
|
if (!movingCursor && !movingBg)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool8 MultiMove_Function_PlaceMons(void)
|
||||||
|
{
|
||||||
|
switch (sMultiMove->state)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
MultiMove_SetPlacedMonData();
|
||||||
|
MultiMove_InitBg(0, -256, 8);
|
||||||
|
InitMultiMonPlaceChange(FALSE);
|
||||||
|
sMultiMove->state++;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (!DoMonPlaceChange() && !MultiMove_UpdateBg())
|
||||||
|
{
|
||||||
|
MultiMove_CreatePlacedMonIcons();
|
||||||
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
||||||
|
InitMultiMonPlaceChange(TRUE);
|
||||||
|
HideBg(0);
|
||||||
|
sMultiMove->state++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (!DoMonPlaceChange())
|
||||||
|
{
|
||||||
|
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
||||||
|
MultiMove_ResetBg();
|
||||||
|
sMultiMove->state++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (!IsDma3ManagerBusyWithBgCopy())
|
||||||
|
{
|
||||||
|
LoadPalette(stdpal_get(3), 0xD0, 0x20);
|
||||||
|
SetCursorPriorityTo1();
|
||||||
|
ShowBg(0);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 MultiMove_TryMoveGroup(u8 dir)
|
||||||
|
{
|
||||||
|
switch (dir)
|
||||||
|
{
|
||||||
|
case 0: // up
|
||||||
|
if (sMultiMove->minRow == 0)
|
||||||
|
return FALSE;
|
||||||
|
sMultiMove->minRow--;
|
||||||
|
MultiMove_InitBg(0, 1024, 6);
|
||||||
|
break;
|
||||||
|
case 1: // down
|
||||||
|
if (sMultiMove->minRow + sMultiMove->rowsTotal >= 5)
|
||||||
|
return FALSE;
|
||||||
|
sMultiMove->minRow++;
|
||||||
|
MultiMove_InitBg(0, -1024, 6);
|
||||||
|
break;
|
||||||
|
case 2: // left
|
||||||
|
if (sMultiMove->minColumn == 0)
|
||||||
|
return FALSE;
|
||||||
|
sMultiMove->minColumn--;
|
||||||
|
MultiMove_InitBg(1024, 0, 6);
|
||||||
|
break;
|
||||||
|
case 3: // right
|
||||||
|
if (sMultiMove->minColumn + sMultiMove->columnsTotal > 5)
|
||||||
|
return FALSE;
|
||||||
|
sMultiMove->minColumn++;
|
||||||
|
MultiMove_InitBg(-1024, 0, 6);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_UpdateSelectedIcons(void)
|
||||||
|
{
|
||||||
|
s16 columnChange = (abs(sMultiMove->fromColumn - sMultiMove->cursorColumn)) - (abs(sMultiMove->fromColumn - sMultiMove->toColumn));
|
||||||
|
s16 rowChange = (abs(sMultiMove->fromRow - sMultiMove->cursorRow)) - (abs(sMultiMove->fromRow - sMultiMove->toRow));
|
||||||
|
|
||||||
|
if (columnChange > 0)
|
||||||
|
MultiMove_SelectColumn(sMultiMove->cursorColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
||||||
|
|
||||||
|
if (columnChange < 0)
|
||||||
|
{
|
||||||
|
MultiMove_DeselectColumn(sMultiMove->toColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
||||||
|
MultiMove_SelectColumn(sMultiMove->cursorColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowChange > 0)
|
||||||
|
MultiMove_SelectRow(sMultiMove->cursorRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
||||||
|
|
||||||
|
if (rowChange < 0)
|
||||||
|
{
|
||||||
|
MultiMove_DeselectRow(sMultiMove->toRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
||||||
|
MultiMove_SelectRow(sMultiMove->cursorRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_SelectColumn(u8 column, u8 minRow, u8 maxRow)
|
||||||
|
{
|
||||||
|
u8 tmp = minRow;
|
||||||
|
|
||||||
|
if (minRow > maxRow)
|
||||||
|
{
|
||||||
|
minRow = maxRow;
|
||||||
|
maxRow = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (minRow <= maxRow)
|
||||||
|
MultiMove_SetIconToBg(column, minRow++);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_SelectRow(u8 row, u8 minColumn, u8 maxColumn)
|
||||||
|
{
|
||||||
|
u8 tmp = minColumn;
|
||||||
|
|
||||||
|
if (minColumn > maxColumn)
|
||||||
|
{
|
||||||
|
minColumn = maxColumn;
|
||||||
|
maxColumn = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (minColumn <= maxColumn)
|
||||||
|
MultiMove_SetIconToBg(minColumn++, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_DeselectColumn(u8 column, u8 minRow, u8 maxRow)
|
||||||
|
{
|
||||||
|
u8 tmp = minRow;
|
||||||
|
|
||||||
|
if (minRow > maxRow)
|
||||||
|
{
|
||||||
|
minRow = maxRow;
|
||||||
|
maxRow = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (minRow <= maxRow)
|
||||||
|
MultiMove_ClearIconFromBg(column, minRow++);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_DeselectRow(u8 row, u8 minColumn, u8 maxColumn)
|
||||||
|
{
|
||||||
|
u8 tmp = minColumn;
|
||||||
|
|
||||||
|
if (minColumn > maxColumn)
|
||||||
|
{
|
||||||
|
minColumn = maxColumn;
|
||||||
|
maxColumn = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (minColumn <= maxColumn)
|
||||||
|
MultiMove_ClearIconFromBg(minColumn++, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_SetIconToBg(u8 x, u8 y)
|
||||||
|
{
|
||||||
|
u8 position = x + (IN_BOX_COLUMNS * y);
|
||||||
|
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
||||||
|
u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY);
|
||||||
|
|
||||||
|
if (species != SPECIES_NONE)
|
||||||
|
{
|
||||||
|
const u8 *iconGfx = GetMonIconPtr(species, personality, 1);
|
||||||
|
u8 palNum = GetValidMonIconPalIndex(species) + 8;
|
||||||
|
BlitBitmapRectToWindow4BitTo8Bit(gStorage->multiMoveWindowId, iconGfx, 0, 0, 32, 32, 24 * x, 24 * y, 32, 32, palNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_ClearIconFromBg(u8 x, u8 y)
|
||||||
|
{
|
||||||
|
u8 position = x + (IN_BOX_COLUMNS * y);
|
||||||
|
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
||||||
|
|
||||||
|
if (species != SPECIES_NONE)
|
||||||
|
FillWindowPixelRect8Bit(gStorage->multiMoveWindowId, PIXEL_FILL(0), 24 * x, 24 * y, 32, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_InitBg(u16 bgX, u16 bgY, u16 duration)
|
||||||
|
{
|
||||||
|
sMultiMove->bgX = bgX;
|
||||||
|
sMultiMove->bgY = bgY;
|
||||||
|
sMultiMove->bgMoveSteps = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u8 MultiMove_UpdateBg(void)
|
||||||
|
{
|
||||||
|
if (sMultiMove->bgMoveSteps != 0)
|
||||||
|
{
|
||||||
|
ChangeBgX(0, sMultiMove->bgX, BG_COORD_ADD);
|
||||||
|
ChangeBgY(0, sMultiMove->bgY, BG_COORD_ADD);
|
||||||
|
sMultiMove->bgMoveSteps--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sMultiMove->bgMoveSteps;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_GetMonsFromSelection(void)
|
||||||
|
{
|
||||||
|
s32 i, j;
|
||||||
|
s32 columnCount, rowCount;
|
||||||
|
u8 boxId;
|
||||||
|
u8 monArrayId;
|
||||||
|
|
||||||
|
sMultiMove->minColumn = min(sMultiMove->fromColumn, sMultiMove->toColumn);
|
||||||
|
sMultiMove->minRow = min(sMultiMove->fromRow, sMultiMove->toRow);
|
||||||
|
sMultiMove->columnsTotal = abs(sMultiMove->fromColumn - sMultiMove->toColumn) + 1;
|
||||||
|
sMultiMove->rowsTotal = abs(sMultiMove->fromRow - sMultiMove->toRow) + 1;
|
||||||
|
boxId = StorageGetCurrentBox();
|
||||||
|
monArrayId = 0;
|
||||||
|
columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
||||||
|
rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
||||||
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
||||||
|
{
|
||||||
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
||||||
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
||||||
|
{
|
||||||
|
struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition);
|
||||||
|
// UB: possible null dereference
|
||||||
|
#ifdef UBFIX
|
||||||
|
if (boxMon != NULL)
|
||||||
|
sMultiMove->boxMons[monArrayId] = *boxMon;
|
||||||
|
#else
|
||||||
|
sMultiMove->boxMons[monArrayId] = *boxMon;
|
||||||
|
#endif
|
||||||
|
monArrayId++;
|
||||||
|
boxPosition++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_RemoveMonsFromBox(void)
|
||||||
|
{
|
||||||
|
s32 i, j;
|
||||||
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
||||||
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
||||||
|
u8 boxId = StorageGetCurrentBox();
|
||||||
|
|
||||||
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
||||||
|
{
|
||||||
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
||||||
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
||||||
|
{
|
||||||
|
DestroyBoxMonIconAtPosition(boxPosition);
|
||||||
|
ZeroBoxMonAt(boxId, boxPosition);
|
||||||
|
boxPosition++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_CreatePlacedMonIcons(void)
|
||||||
|
{
|
||||||
|
s32 i, j;
|
||||||
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
||||||
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
||||||
|
u8 monArrayId = 0;
|
||||||
|
|
||||||
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
||||||
|
{
|
||||||
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
||||||
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
||||||
|
{
|
||||||
|
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
||||||
|
CreateBoxMonIconAtPos(boxPosition);
|
||||||
|
monArrayId++;
|
||||||
|
boxPosition++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_SetPlacedMonData(void)
|
||||||
|
{
|
||||||
|
s32 i, j;
|
||||||
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
||||||
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
||||||
|
u8 boxId = StorageGetCurrentBox();
|
||||||
|
u8 monArrayId = 0;
|
||||||
|
|
||||||
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
||||||
|
{
|
||||||
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
||||||
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
||||||
|
{
|
||||||
|
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
||||||
|
SetBoxMonAt(boxId, boxPosition, &sMultiMove->boxMons[monArrayId]);
|
||||||
|
boxPosition++;
|
||||||
|
monArrayId++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MultiMove_ResetBg(void)
|
||||||
|
{
|
||||||
|
ChangeBgX(0, 0, BG_COORD_SET);
|
||||||
|
ChangeBgY(0, 0, BG_COORD_SET);
|
||||||
|
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0);
|
||||||
|
ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
||||||
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
|
||||||
|
CopyBgTilemapBufferToVram(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 MultiMove_GetOriginPosition(void)
|
||||||
|
{
|
||||||
|
return (IN_BOX_COLUMNS * sMultiMove->fromRow) + sMultiMove->fromColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 MultiMove_CanPlaceSelection(void)
|
||||||
|
{
|
||||||
|
s32 i, j;
|
||||||
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
||||||
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
||||||
|
u8 monArrayId = 0;
|
||||||
|
|
||||||
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
||||||
|
{
|
||||||
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
||||||
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
||||||
|
{
|
||||||
|
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)
|
||||||
|
&& GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
monArrayId++;
|
||||||
|
boxPosition++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// IDs for the item icon sprite callbacks
|
// IDs for the item icon sprite callbacks
|
||||||
enum {
|
enum {
|
||||||
ITEM_CB_WAIT_ANIM,
|
ITEM_CB_WAIT_ANIM,
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "gflib.h"
|
#include "gflib.h"
|
||||||
#include "box_party_pokemon_dropdown.h"
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "decompress.h"
|
#include "decompress.h"
|
||||||
#include "dynamic_placeholder_text_util.h"
|
#include "dynamic_placeholder_text_util.h"
|
||||||
@@ -21,6 +20,7 @@
|
|||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "text_window.h"
|
#include "text_window.h"
|
||||||
|
#include "tilemap_util.h"
|
||||||
#include "trig.h"
|
#include "trig.h"
|
||||||
#include "constants/items.h"
|
#include "constants/items.h"
|
||||||
#include "constants/help_system.h"
|
#include "constants/help_system.h"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "bg.h"
|
#include "bg.h"
|
||||||
#include "box_party_pokemon_dropdown.h"
|
#include "tilemap_util.h"
|
||||||
#include "malloc.h"
|
#include "malloc.h"
|
||||||
|
|
||||||
// Handles 3 particular tilemaps ("PKMN Data" text, party menu, close box
|
// Handles 3 particular tilemaps ("PKMN Data" text, party menu, close box
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
.include "src/tileset_anims.o"
|
.include "src/tileset_anims.o"
|
||||||
.include "src/sound.o"
|
.include "src/sound.o"
|
||||||
.include "src/field_effect.o"
|
.include "src/field_effect.o"
|
||||||
.include "src/pokemon_storage_system_8.o"
|
.include "src/pokemon_storage_system_misc.o"
|
||||||
.include "src/easy_chat.o"
|
.include "src/easy_chat.o"
|
||||||
.include "src/link_rfu_2.o"
|
.include "src/link_rfu_2.o"
|
||||||
.include "src/link_rfu_3.o"
|
.include "src/link_rfu_3.o"
|
||||||
|
|||||||
+5
-6
@@ -38,11 +38,10 @@
|
|||||||
.include "src/scanline_effect.o"
|
.include "src/scanline_effect.o"
|
||||||
.include "src/option_menu.o"
|
.include "src/option_menu.o"
|
||||||
.include "src/trainer_card.o"
|
.include "src/trainer_card.o"
|
||||||
.include "src/pokemon_storage_system_2.o"
|
.include "src/pokemon_storage_system_menu.o"
|
||||||
.include "src/pokemon_storage_system_3.o"
|
.include "src/pokemon_storage_system_tasks.o"
|
||||||
.include "src/pokemon_storage_system_5.o"
|
.include "src/pokemon_storage_system_data.o"
|
||||||
.include "src/pokemon_storage_system_7.o"
|
.include "src/pokemon_storage_system_misc.o"
|
||||||
.include "src/pokemon_storage_system_8.o"
|
|
||||||
.include "src/script_movement.o"
|
.include "src/script_movement.o"
|
||||||
.include "src/fldeff_cut.o"
|
.include "src/fldeff_cut.o"
|
||||||
.include "src/item_menu_icons.o"
|
.include "src/item_menu_icons.o"
|
||||||
@@ -84,7 +83,7 @@
|
|||||||
.include "src/save_failed_screen.o"
|
.include "src/save_failed_screen.o"
|
||||||
.include "src/clear_save_data_screen.o"
|
.include "src/clear_save_data_screen.o"
|
||||||
.include "src/new_menu_helpers.o"
|
.include "src/new_menu_helpers.o"
|
||||||
.include "src/box_party_pokemon_dropdown.o"
|
.include "src/tilemap_util.o"
|
||||||
.include "src/map_preview_screen.o"
|
.include "src/map_preview_screen.o"
|
||||||
.include "src/link_rfu_2.o"
|
.include "src/link_rfu_2.o"
|
||||||
.include "src/link_rfu_3.o"
|
.include "src/link_rfu_3.o"
|
||||||
|
|||||||
Reference in New Issue
Block a user