Start decompile player_pc

This commit is contained in:
KDSKardabox 2018-03-12 13:56:20 +05:30
parent 29e51811f4
commit e7cf8e5c17
15 changed files with 2075 additions and 1291 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1788,7 +1788,7 @@ EventScript_271DBC:: @ 8271DBC
EventScript_271DF9:: @ 8271DF9
playse SE_PC_LOGIN
msgbox gUnknown_082726C2, 4
special sub_816AE98
special PlayerPC
waitstate
goto EventScript_271DAC
end

View File

@ -5,36 +5,36 @@
.section .rodata
.align 2
gUnknown_085DFEA4:: @ 85DFEA4
gPCText_OptionDescList:: @ 85DFEA4
.4byte gText_TakeOutItemsFromPC
.4byte gText_StoreItemsInPC
.4byte gText_ThrowAwayItemsInPC
.4byte gText_GoBackPrevMenu
.align 2
gUnknown_085DFEB4:: @ 85DFEB4
.4byte gText_ItemStorage, task_pc_itemstorage
.4byte gText_Mailbox, sub_816B0A8
.4byte gText_Decoration, sub_816B138
.4byte gText_TurnOff, sub_816B148
sPlayerPCMenuActions:: @ 85DFEB4
.4byte gText_ItemStorage, PlayerPC_ItemStorage
.4byte gText_Mailbox, PlayerPC_Mailbox
.4byte gText_Decoration, PlayerPC_Decoration
.4byte gText_TurnOff, PlayerPC_TurnOff
.align 2
gUnknown_085DFED4:: @ 85DFED4
gBedroomPC_OptionOrder:: @ 85DFED4
.byte 0x00, 0x01, 0x02, 0x03
.align 2
gUnknown_085DFED8:: @ 85DFED8
gPlayerPC_OptionOrder:: @ 85DFED8
.byte 0x00, 0x01, 0x03, 0x00
.align 2
gUnknown_085DFEDC:: @ 85DFEDC
.4byte gText_WithdrawItem, sub_816B398
.4byte gText_DepositItem, sub_816B2C8
.4byte gText_TossItem, sub_816B3E4
.4byte gText_Cancel, sub_816B4A4
gPCText_ItemPCOptionsText:: @ 85DFEDC
.4byte gText_WithdrawItem, ItemStorage_Withdraw
.4byte gText_DepositItem, ItemStorage_Deposit
.4byte gText_TossItem, ItemStorage_Toss
.4byte gText_Cancel, ItemStorage_Exit
.align 2
gUnknown_085DFEFC:: @ 85DFEFC
gNewGamePCItems:: @ 85DFEFC
.2byte ITEM_POTION, 0x0001
.2byte 0x0000, 0x0000

View File

@ -259,7 +259,7 @@ LittlerootTown_BrendansHouse_2F_EventScript_1F8626:: @ 81F8626
special DoPCTurnOnEffect
playse SE_PC_ON
msgbox gUnknown_08272D87, 4
special sub_816AE58
special BedroomPC
waitstate
releaseall
end

View File

@ -320,7 +320,7 @@ LittlerootTown_MaysHouse_2F_EventScript_1F9576:: @ 81F9576
special DoPCTurnOnEffect
playse SE_PC_ON
msgbox gUnknown_08272D87, 4
special sub_816AE58
special BedroomPC
waitstate
releaseall
end

View File

@ -260,8 +260,8 @@ gSpecials:: @ 81DBA64
def_special ValidateEReaderTrainer
def_special sub_8139228
def_special sub_80F94E8
def_special sub_816AE58
def_special sub_816AE98
def_special BedroomPC
def_special PlayerPC
def_special FieldShowRegionMap
def_special sub_807E73C
def_special sub_807EA10

View File

@ -387,4 +387,8 @@ extern const u8 FieryPath_EventScript_2908FD[];
extern const u8 EventScript_290CAE[];
extern const u8 EventScript_2926F8[];
//player pc
extern const u8 LittlerootTown_BrendansHouse_2F_EventScript_1F863F[];
extern const u8 LittlerootTown_MaysHouse_2F_EventScript_1F958F[];
#endif //GUARD_EVENT_SCRIPTS_H

View File

@ -20,6 +20,7 @@ extern struct BagStruct gUnknown_0203CE58;
extern u16 gSpecialVar_ItemId;
// Exported ROM declarations
void sub_81AAC14(void);
void sub_81AAC50(void);
void sub_81AAC70(void);
void bag_menu_mail_related(void);

View File

@ -53,6 +53,7 @@ struct WindowTemplate sub_8198A50(u8, u8, u8, u8, u8, u8, u16);
void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos);
void copy_decompressed_tile_data_to_vram_autofree(u8 bgId, const void *src, int size, u16 offset, u8 mode);
s8 ProcessMenuInputNoWrap_(void);
s8 ProcessMenuInput_other(void);
void do_scheduled_bg_tilemap_copies_to_vram(void);
void clear_scheduled_bg_copies_to_vram(void);
void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str);

View File

@ -1,13 +1,86 @@
#ifndef GUARD_PLAYER_PC_H
#define GUARD_PLAYER_PC_H
// local task defines
#define PAGE_INDEX data[0]
#define ITEMS_ABOVE_TOP data[1]
#define NUM_ITEMS data[1]
#define NUM_QUANTITY_ROLLER data[3]
#define NUM_PAGE_ITEMS data[4]
// not used
#define CURRENT_ITEM_STORAGE_MENU data[3]
// not used
#define SWAP_ITEM_INDEX data[8]
#define SWITCH_MODE_ACTIVE data[9]
// this is potentially an ewram access occuring in high ewram. TODO: investigate this further.
#define NEW_GAME_PC_ITEMS(i, type) ((u16)((u16 *)gNewGamePCItems + type)[i * 2])
// defined and used in the above macro
enum
{
PC_ITEM_ID,
PC_QUANTITY
};
// player PC menu options
enum
{
PLAYERPC_MENU_ITEMSTORAGE,
PLAYERPC_MENU_MAILBOX,
PLAYERPC_MENU_DECORATION,
PLAYERPC_MENU_TURNOFF
};
// item storage menus
enum
{
ITEMPC_MENU_WITHDRAW,
ITEMPC_MENU_DEPOSIT,
ITEMPC_MENU_TOSS,
ITEMPC_MENU_EXIT
};
// mailbox mail options
enum
{
MAILBOX_READ,
MAILBOX_MOVE_TO_BAG,
MAILBOX_GIVE,
MAILBOX_CANCEL,
};
// special item description handlers
enum
{
ITEMPC_SWITCH_WHICH_ITEM = 0xFFF7,
ITEMPC_OKAY_TO_THROW_AWAY,
ITEMPC_TOO_IMPORTANT,
ITEMPC_NO_MORE_ROOM,
ITEMPC_THREW_AWAY_ITEM,
ITEMPC_HOW_MANY_TO_TOSS,
ITEMPC_WITHDREW_THING,
ITEMPC_HOW_MANY_TO_WITHDRAW,
ITEMPC_GO_BACK_TO_PREV
};
struct MailboxStruct
{
u16 cursorPos;
u16 itemsAbove;
u8 pageItems;
u8 count;
u8 unk6[6];
u8 unkC[4];
};
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void sub_816B060(u8 taskId);
void ReshowPlayerPC(u8 taskId);
void sub_816B31C(void);
#endif //GUARD_PLAYER_PC_H

View File

@ -372,4 +372,8 @@ extern const u8 gBirchDexRatingText_LessThan190[];
extern const u8 gBirchDexRatingText_LessThan200[];
extern const u8 gBirchDexRatingText_DexCompleted[];
//player menu text
extern const u8 gText_WhatWouldYouLike[];
extern const u8 gText_NoMailHere[];
#endif //GUARD_STRINGS_H

View File

@ -217,6 +217,7 @@ SECTIONS {
src/use_pokeblock.o(.text);
asm/use_pokeblock.o(.text);
src/battle_controller_wally.o(.text);
src/player_pc.o(.text);
asm/player_pc.o(.text);
src/intro.o(.text);
src/reset_save_heap.o(.text);

View File

@ -562,7 +562,7 @@ void SecretBasePC_Cancel(u8 taskId)
}
else
{
sub_816B060(taskId);
ReshowPlayerPC(taskId);
}
}

702
src/player_pc.c Normal file
View File

@ -0,0 +1,702 @@
#include "global.h"
#include "constants/songs.h"
#include "decoration.h"
#include "event_scripts.h"
#include "field_fadetransition.h"
#include "field_screen.h"
#include "field_weather.h"
#include "international_string_util.h"
#include "item.h"
#include "item_menu.h"
#include "constants/items.h"
#include "mail.h"
#include "main.h"
#include "menu.h"
#include "menu_helpers.h"
#include "overworld.h"
#include "palette.h"
#include "player_pc.h"
#include "script.h"
#include "sound.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "window.h"
static EWRAM_DATA u8 *gPcItemMenuOptionOrder = NULL;
static EWRAM_DATA u8 gPcItemMenuOptionsNum = 0;
extern struct MailboxStruct gUnknown_0203BCB8;
#define eMailboxInfo gUnknown_0203BCB8
struct Struct203BCC4
{
u8 filler[0x668];
u32 unk668;
u8 filler2[4];
};
extern struct Struct203BCC4 *gUnknown_0203BCC4;
/*static*/void InitPlayerPCMenu(u8 taskId);
/*static*/void PlayerPCProcessMenuInput(u8 taskId);
/*static*/void InitItemStorageMenu(u8 taskId, u8 var);
/*static*/ void ItemStorageMenuPrint(const u8 *);
/*static*/ void ItemStorageMenuProcessInput(u8 taskId);
/*
static void ItemStorage_ProcessInput(u8);
*/
/*static*/ void ItemStorage_SetItemAndMailCount(u8);
/*
static void ItemStorage_DoItemAction(u8);
static void ItemStorage_GoBackToPlayerPCMenu(u8);
static void ItemStorage_HandleQuantityRolling(u8);
static void ItemStorage_DoItemWithdraw(u8);
static void ItemStorage_DoItemToss(u8);
static void ItemStorage_HandleRemoveItem(u8);
static void ItemStorage_WaitPressHandleResumeProcessInput(u8);
*/
/*static*/ void ItemStorage_HandleReturnToProcessInput(u8);
/*
static void ItemStorage_HandleResumeProcessInput(u8);
static void ItemStorage_DoItemSwap(u8, bool8);
static void ItemStorage_DrawItemList(u8);
static void ItemStorage_PrintItemPcResponse(u16);
static void ItemStorage_DrawBothListAndDescription(u8);
static void ItemStorage_GoBackToItemPCMenu(u8, u8);
static void ItemStorage_LoadPalette(void);
*/
/*static*/ u8 GetMailboxMailCount(void);
/*static*/ void Mailbox_UpdateMailList(void);
/*static*/ void Mailbox_DrawMailboxMenu(u8);
/*static*/ void Mailbox_ProcessInput(u8);
/*
static void Mailbox_CloseScrollIndicators(void);
static void Mailbox_PrintWhatToDoWithPlayerMailText(u8);
static void Mailbox_TurnOff(u8);
static void Mailbox_PrintMailOptions(u8);
static void Mailbox_MailOptionsProcessInput(u8);
static void Mailbox_FadeAndReadMail(u8);
static void Mailbox_ReturnToFieldFromReadMail(void);
static void Mailbox_DrawYesNoBeforeMove(u8);
static void Mailbox_DoGiveMailPokeMenu(u8);
static void Mailbox_NoPokemonForMail(u8);
static void Mailbox_Cancel(u8);
static void Mailbox_DrawMailMenuAndDoProcessInput(u8);
*/
/*static*/ void PlayerPC_ItemStorage(u8 taskId);
/*static*/ void PlayerPC_Mailbox(u8 taskId);
/*static*/ void PlayerPC_Decoration(u8 var);
/*static*/ void PlayerPC_TurnOff(u8 taskId);
/*
static void ItemStorage_Withdraw(u8);
static void ItemStorage_Deposit(u8);
static void ItemStorage_Toss(u8);
*/
/*static*/ void ItemStorage_Exit(u8);
/*
static void ItemStorage_ResumeInputFromYesToss(u8);
static void ItemStorage_ResumeInputFromNoToss(u8);
static void Mailbox_DoMailMoveToBag(u8);
static void Mailbox_ReturnToInputAfterNo(u8);
static void Mailbox_DoMailRead(u8);
static void Mailbox_MoveToBag(u8);
static void Mailbox_Give(u8);
static void Mailbox_Cancel(u8);
*/
extern const u8 *const gPCText_OptionDescList[];
/*
static const u8 *const gPCText_OptionDescList[] =
{
PCText_TakeOutItems,
PCText_StoreItems,
PCText_ThrowAwayItems,
gMenuText_GoBackToPrev
};
*/
/*static*/ extern const struct MenuAction sPlayerPCMenuActions[];/* =
{
{ SecretBaseText_ItemStorage, PlayerPC_ItemStorage },
{ gPCText_Mailbox, PlayerPC_Mailbox },
{ SecretBaseText_Decoration, PlayerPC_Decoration },
{ SecretBaseText_TurnOff, PlayerPC_TurnOff }
};
*/
/*static*/ extern u8 gBedroomPC_OptionOrder[];/* =
{
PLAYERPC_MENU_ITEMSTORAGE,
PLAYERPC_MENU_MAILBOX,
PLAYERPC_MENU_DECORATION,
PLAYERPC_MENU_TURNOFF
};
*/
/*static*/ extern u8 gPlayerPC_OptionOrder[];/* =
{
PLAYERPC_MENU_ITEMSTORAGE,
PLAYERPC_MENU_MAILBOX,
PLAYERPC_MENU_TURNOFF
};
*/
extern const struct MenuAction gPCText_ItemPCOptionsText[];
/*
static const struct MenuAction2 gPCText_ItemPCOptionsText[] =
{
{ PCText_WithdrawItem, ItemStorage_Withdraw },
{ PCText_DepositItem, ItemStorage_Deposit },
{ PCText_TossItem, ItemStorage_Toss },
{ gUnknownText_Exit, ItemStorage_Exit }
};
static const struct YesNoFuncTable ResumeFromTossYesNoFuncList[] = // ResumeFromTossYesNoFuncList
{
ItemStorage_ResumeInputFromYesToss,
ItemStorage_ResumeInputFromNoToss
};
static const struct YesNoFuncTable ResumeFromWithdrawYesNoFuncList[] = // ResumeFromWithdrawYesNoFuncList
{
Mailbox_DoMailMoveToBag,
Mailbox_ReturnToInputAfterNo
};
*/
// the use of this struct is meant to be an ItemSlot struct, but NewGameInitPCItems refuses to match without a weird pointer access.
/*static*/ extern const struct ItemSlot gNewGamePCItems[];/* =
{
{ ITEM_POTION, 1 },
{ ITEM_NONE, 0 }
};
static const struct MenuAction2 gMailboxMailOptions[] =
{
{ OtherText_Read, Mailbox_DoMailRead },
{ gOtherText_MoveToBag, Mailbox_MoveToBag },
{ OtherText_Give, Mailbox_Give },
{ gOtherText_CancelNoTerminator, Mailbox_Cancel }
};
static const u8 gNonSelectedItemFormattedText[] = _("{STR_VAR_1}{CLEAR_TO 80}");
static const u8 gSelectedItemFormattedText[] = _("{COLOR RED}{STR_VAR_1}{CLEAR_TO 80}");
static const u8 gNonSelectedItemQuantityFormatText[] = _("{STR_VAR_1}");
static const u8 gSelectedItemQuantityFormatText[] = _("{COLOR RED}{STR_VAR_1}");
static const u8 gUnknown_08406330[] = _("{CLEAR_TO 32}");
*/
extern const struct WindowTemplate gUnknown_085DFF24[3];
/*
extern u8 *gUnknown_02039314;
extern struct MenuAction gUnknown_08406298[];
extern u8 gUnknown_084062B8[];
extern u8 gUnknown_084062BC[];
extern u8 gUnknown_0840632A[];
extern u8 gUnknown_08406327[];
extern u8 gUnknown_0840631E[];
extern u8 gUnknown_08406318[];
extern u8 gUnknown_030007B4;
extern u8 unk_201FE00[];
extern u8 gUnknown_08152850;
extern u8 gUnknown_08152C75;
extern u32 gUnknown_08406288[];
extern const struct MenuAction gUnknown_084062C0[];
extern const struct YesNoFuncTable gUnknown_084062E0;
*/
void NewGameInitPCItems(void)
{
u8 i;
// because Game Freak don't know how to use a struct or a 2d array
for(i = 0, ClearItemSlots(gSaveBlock1Ptr->pcItems, ARRAY_COUNT(gSaveBlock1Ptr->pcItems)); NEW_GAME_PC_ITEMS(i, PC_ITEM_ID) && NEW_GAME_PC_ITEMS(i, PC_QUANTITY) &&
AddPCItem(NEW_GAME_PC_ITEMS(i, PC_ITEM_ID), NEW_GAME_PC_ITEMS(i, PC_QUANTITY)) == TRUE; i++);
}
void BedroomPC(void)
{
gPcItemMenuOptionOrder = gBedroomPC_OptionOrder;
gPcItemMenuOptionsNum = 4;
DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gText_WhatWouldYouLike, InitPlayerPCMenu);
}
void PlayerPC(void)
{
gPcItemMenuOptionOrder = gPlayerPC_OptionOrder;
gPcItemMenuOptionsNum = 3;
DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gText_WhatWouldYouLike, InitPlayerPCMenu);
}
/*static*/ void InitPlayerPCMenu(u8 taskId)
{
u16 *data;
struct WindowTemplate windowTemplate;
data = gTasks[taskId].data;
if(gPcItemMenuOptionsNum == 3)
windowTemplate = gUnknown_085DFF24[0];
else
windowTemplate = gUnknown_085DFF24[1];
windowTemplate.width = sub_81DB3D8(sPlayerPCMenuActions, gPcItemMenuOptionOrder, gPcItemMenuOptionsNum);
data[4] = AddWindow(&windowTemplate);
SetStandardWindowBorderStyle(data[4], 0);
sub_81995E4(data[4], gPcItemMenuOptionsNum, sPlayerPCMenuActions, gPcItemMenuOptionOrder);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], gPcItemMenuOptionsNum, 0);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = PlayerPCProcessMenuInput;
}
/*static*/ void PlayerPCProcessMenuInput(u8 taskId)
{
u16 *data;
s8 inputOptionId;
data = gTasks[taskId].data;
if(gPcItemMenuOptionsNum > 3)
inputOptionId = ProcessMenuInput();
else
inputOptionId = ProcessMenuInputNoWrapAround();
switch(inputOptionId)
{
case -2:
break;
case -1:
PlaySE(SE_SELECT);
sub_8198070(data[4], FALSE);
ClearWindowTilemap(data[4]);
RemoveWindow(data[4]);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = PlayerPC_TurnOff;
break;
default:
sub_8198070(data[4], FALSE);
ClearWindowTilemap(data[4]);
RemoveWindow(data[4]);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = sPlayerPCMenuActions[gPcItemMenuOptionOrder[inputOptionId]].func.void_u8;
break;
}
}
void ReshowPlayerPC(u8 var)
{
DisplayItemMessageOnField(var, gText_WhatWouldYouLike, InitPlayerPCMenu);
}
/*static*/ void PlayerPC_ItemStorage(u8 taskId)
{
InitItemStorageMenu(taskId, ITEMPC_MENU_WITHDRAW);
gTasks[taskId].func = ItemStorageMenuProcessInput;
}
bool8 sub_81D1C44(u8);
/*static*/ void PlayerPC_Mailbox(u8 taskId)
{
eMailboxInfo.count = GetMailboxMailCount();
if (eMailboxInfo.count == 0)
DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC);
else
{
eMailboxInfo.cursorPos = 0;
eMailboxInfo.itemsAbove = 0;
eMailboxInfo.unk6[3] = 0xFF;
Mailbox_UpdateMailList();
ItemStorage_SetItemAndMailCount(taskId);
if(sub_81D1C44(eMailboxInfo.count) == TRUE)
{
sub_8197434(0, 0);
Mailbox_DrawMailboxMenu(taskId);
gTasks[taskId].func = Mailbox_ProcessInput;
}
else
DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC);
}
}
void sub_8126B2C(u8);
/*static*/ void PlayerPC_Decoration(u8 var)
{
sub_8126B2C(var); //DoPlayerPCDecoration(var);
}
/*static*/ void PlayerPC_TurnOff(u8 taskId)
{
if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling.
{
if (gSaveBlock2Ptr->playerGender == MALE)
ScriptContext1_SetupScript(LittlerootTown_BrendansHouse_2F_EventScript_1F863F);
else
ScriptContext1_SetupScript(LittlerootTown_MaysHouse_2F_EventScript_1F958F);
}
else
{
EnableBothScriptContexts();
}
DestroyTask(taskId);
}
void ItemStorageMenuPrint(const u8*);
void InitItemStorageMenu(u8 taskId, u8 var)
{
u16 *data;
struct WindowTemplate windowTemplate;
data = gTasks[taskId].data;
windowTemplate = gUnknown_085DFF24[2];
windowTemplate.width = GetMaxWidthInMenuTable(gPCText_ItemPCOptionsText, 4);
data[4] = AddWindow(&windowTemplate);
SetStandardWindowBorderStyle(data[4], 0);
PrintMenuTable(data[4], 4, gPCText_ItemPCOptionsText);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], 4, var);
schedule_bg_copy_tilemap_to_vram(0);
ItemStorageMenuPrint(gPCText_OptionDescList[var]);
}
/*static*/ void ItemStorageMenuPrint(const u8 *textPtr)
{
NewMenuHelpers_DrawDialogueFrame(0, 0);
PrintTextOnWindow(0, 1, textPtr, 0, 1, 0, 0);
}
/*static*/ void ItemStorageMenuProcessInput(u8 var)
{
s8 r5;
s8 r2;
s8 inputOptionId;
r5 = GetMenuCursorPos();
inputOptionId = ProcessMenuInput();
r2 = GetMenuCursorPos();
switch(inputOptionId)
{
case -2:
if (r5 != r2)
ItemStorageMenuPrint(gPCText_OptionDescList[r2]);
break;
case -1:
PlaySE(SE_SELECT);
ItemStorage_Exit(var);
break;
default:
PlaySE(SE_SELECT);
gPCText_ItemPCOptionsText[inputOptionId].func.void_u8(var);
break;
}
}
void Task_ItemStorage_Deposit(u8 taskId);
/*static*/ void ItemStorage_Deposit(u8 taskId)
{
gTasks[taskId].func = Task_ItemStorage_Deposit;
FadeScreen(1, 0);
}
/*static*/ void Task_ItemStorage_Deposit(u8 taskId)
{
if (!gPaletteFade.active)
{
overworld_free_bg_tilemaps();
sub_81AAC14();
DestroyTask(taskId);
}
}
void mapldr_080EBC0C(void);
void (*gFieldCallback)(void);
void sub_816B31C(void)
{
gFieldCallback = mapldr_080EBC0C;
SetMainCallback2(CB2_ReturnToField);
}
void mapldr_080EBC0C(void)
{
sub_81973A4();
NewMenuHelpers_DrawDialogueFrame(0, 1);
InitItemStorageMenu(CreateTask(ItemStorage_HandleReturnToProcessInput, 0), 1);
pal_fill_black();
}
/*static*/ void ItemStorage_HandleReturnToProcessInput(u8 taskId)
{
if (sub_80ABDFC() == TRUE)
gTasks[taskId].func = ItemStorageMenuProcessInput;
}
u8 sub_80D6CE4(); //count of items
void sub_816B4DC(u8 taskId);
void sub_816B430(u8 taskId, bool8 toss);
extern const u8 gText_NoItems[];
/*static*/ void ItemStorage_Withdraw(u8 taskId)
{
s16 *data = gTasks[taskId].data;
NUM_ITEMS = sub_80D6CE4();
if (NUM_ITEMS != 0)
sub_816B430(taskId, FALSE);
else
{
sub_816B4DC(taskId);
DisplayItemMessageOnField(taskId, gText_NoItems, PlayerPC_ItemStorage);
}
}
/*static*/ void ItemStorage_Toss(u8 taskId)
{
s16 *data = gTasks[taskId].data;
NUM_ITEMS = sub_80D6CE4();
if (NUM_ITEMS != 0)
sub_816B430(taskId, TRUE);
else
{
sub_816B4DC(taskId);
DisplayItemMessageOnField(taskId, gText_NoItems, PlayerPC_ItemStorage);
}
}
void sub_816BC14(void);
void gpu_pal_allocator_reset__manage_upper_four(void);
void sub_816C158(u8 taskId);
/*static*/ void sub_816B430(u8 taskId, bool8 toss)
{
u16 *data = gTasks[taskId].data;
data[3] = toss;
sub_816B4DC(taskId);
eMailboxInfo.cursorPos = 0;
eMailboxInfo.itemsAbove = 0;
eMailboxInfo.unk6[3] = 0xFF;
ItemStorage_SetItemAndMailCount(taskId);
sub_816BC14();
gpu_pal_allocator_reset__manage_upper_four();
LoadListMenuArrowsGfx();
sub_8122344(&(gUnknown_0203BCC4->unk668), 7);
sub_8197434(0,0);
gTasks[taskId].func = sub_816C158;
}
/*static*/ void ItemStorage_Exit(u8 taskId)
{
sub_816B4DC(taskId);
ReshowPlayerPC(taskId);
}
/*static*/ void ItemStorage_SetItemAndMailCount(u8 taskId)
{
if (eMailboxInfo.count > 7)
eMailboxInfo.pageItems = 8;
else
eMailboxInfo.pageItems = eMailboxInfo.count + 1;
}
/*static*/ void sub_816B4DC(u8 taskId)
{
u16 *data = gTasks[taskId].data;
sub_8198070(data[4], FALSE);
ClearWindowTilemap(data[4]);
RemoveWindow(data[4]);
schedule_bg_copy_tilemap_to_vram(0);
}
/*static*/ u8 GetMailboxMailCount(void)
{
u8 i, j;
for(i = 0, j = 6; j < 16; j++)
if(gSaveBlock1Ptr->mail[j].itemId != 0)
i++;
return i;
}
/*static*/ void Mailbox_UpdateMailList(void)
{
struct MailStruct mailBuffer;
u8 i, j;
for (i=6; i<15; i++)
{
for (j=i+1; j<16; j++)
{
if (gSaveBlock1Ptr->mail[i].itemId == 0)
{
mailBuffer = gSaveBlock1Ptr->mail[i];
gSaveBlock1Ptr->mail[i] = gSaveBlock1Ptr->mail[j];
gSaveBlock1Ptr->mail[j] = mailBuffer;
}
}
}
}
extern const u8 gText_Mailbox[];
u8 sub_81D1C84(u8);
u8 sub_81D1DC0(struct MailboxStruct *);
void sub_81D1E90(struct MailboxStruct *);
/*static*/ void Mailbox_DrawMailboxMenu(u8 taskId)
{
u8 windowId;
windowId = sub_81D1C84(0);
sub_81D1C84(1);
PrintTextOnWindow(windowId, 1, gText_Mailbox, GetStringCenterAlignXOffset(1, gText_Mailbox, 0x40), 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].data[5] = sub_81D1DC0(&eMailboxInfo);
sub_81D1E90(&eMailboxInfo);
}
u32 ListMenuHandleInputGetItemId(u8);
void sub_81AE860(u8, void *, void *);
void sub_81AE6C8(u8, void *, void *);
void sub_816B798(u8);
void RemoveScrollIndicatorArrowPair(u8);
void sub_81D1D04(u8);
void sub_816B730(u8);
/*static*/ void Mailbox_ProcessInput(u8 taskId)
{
u16 *data = gTasks[taskId].data;
s32 inputOptionId;
if(!gPaletteFade.active)
{
inputOptionId = ListMenuHandleInputGetItemId(data[5]);
sub_81AE860(data[5], &(eMailboxInfo.itemsAbove), &eMailboxInfo);
switch(inputOptionId)
{
case -1:
break;
case -2:
PlaySE(SE_SELECT);
RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]);
sub_816B798(taskId);
break;
default:
PlaySE(SE_SELECT);
sub_81D1D04(0);
sub_81D1D04(1);
sub_81AE6C8(data[5], &(eMailboxInfo.itemsAbove), &eMailboxInfo);
schedule_bg_copy_tilemap_to_vram(0);
RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]);
gTasks[taskId].func = sub_816B730;
break;
}
}
}
void sub_81DB554(u8 *, u8);
void sub_816B7DC(u8);
extern const u8 gText_WhatToDoWithVar1sMail[];
/*static*/ void sub_816B730(u8 taskId)//Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId)
{
StringCopy(gStringVar1, gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos].playerName);
sub_81DB554(gStringVar1, 0);
StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithVar1sMail);
DisplayItemMessageOnField(taskId, gStringVar4, sub_816B7DC);
}
void sub_81D1EC0(void);
/*static*/ void sub_816B798(u8 taskId)//Mailbox_ReturnToPlayerPC(u8 taskId)
{
s16 *data = gTasks[taskId].data;
sub_81D1D04(0);
sub_81D1D04(1);
sub_81AE6C8(data[5], NULL, NULL);
schedule_bg_copy_tilemap_to_vram(0);
sub_81D1EC0();
ReshowPlayerPC(taskId);
}
extern const struct MenuAction gUnknown_085DFF04[];
void sub_816B82C(u8 taskId);
void sub_816B7DC(u8 taskId)
{
u8 r4 = sub_81D1C84(2);
PrintMenuTable(r4, 4, gUnknown_085DFF04);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = sub_816B82C;
}
void sub_816BBD4(u8 taskId);
void sub_816B82C(u8 taskId)
{
s8 inputOptionId = ProcessMenuInput_other();
switch(inputOptionId)
{
case -2:
break;
case -1:
PlaySE(SE_SELECT);
sub_816BBD4(taskId);
break;
default:
PlaySE(SE_SELECT);
gUnknown_085DFF04[inputOptionId].func.void_u8(taskId);
break;
}
}
void sub_816B8A4(u8 taskId);
void sub_816B878(u8 taskId)
{
FadeScreen(1, 0);
gTasks[taskId].func = sub_816B8A4;
}
void sub_816B900();
void sub_816B8A4(u8 taskId)
{
if(!gPaletteFade.active)
{
sub_81D1EC0();
overworld_free_bg_tilemaps();
ReadMail(&(gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]), sub_816B900, TRUE);
DestroyTask(taskId);
}
}
void pal_fill_for_maplights_or_black();
void sub_816B900()
{
gFieldCallback = pal_fill_for_maplights_or_black;
SetMainCallback2(CB2_ReturnToField);
}

View File

@ -805,12 +805,7 @@ gUnknown_0203BC8C: @ 203BC8C
.space 0x4
.include "src/use_pokeblock.o"
gUnknown_0203BCB0: @ 203BCB0
.space 0x4
gUnknown_0203BCB4: @ 203BCB4
.space 0x4
.include "src/player_pc.o"
gUnknown_0203BCB8: @ 203BCB8
.space 0x2