From e4a84faabf3f4e2f005e55a88babce7e8ae49c58 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 10:49:52 -0500 Subject: through unref_sub_8095C60 --- src/field/choose_party.c | 3 +- src/field/field_effect.c | 1 + src/pokemon/pokemon_storage_system.c | 88 ++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/field/choose_party.c b/src/field/choose_party.c index d278eda4a..52763b911 100644 --- a/src/field/choose_party.c +++ b/src/field/choose_party.c @@ -1,5 +1,5 @@ #include "global.h" -#include "decoration.h" +#include "event_data.h" #include "field_fadetransition.h" #include "main.h" #include "menu.h" @@ -7,6 +7,7 @@ #include "palette.h" #include "party_menu.h" #include "pokemon_menu.h" +#include "field_weather.h" #include "pokemon.h" #include "pokemon_summary_screen.h" #include "overworld.h" diff --git a/src/field/field_effect.c b/src/field/field_effect.c index 1e2aaa4ed..1fe238901 100644 --- a/src/field/field_effect.c +++ b/src/field/field_effect.c @@ -25,6 +25,7 @@ #include "field_map_obj.h" #include "util.h" #include "field_effect_helpers.h" +#include "pokemon_storage_system.h" #define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))} diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 4a68b846a..2ea7161cf 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -2,6 +2,7 @@ #include "pokemon_storage_system.h" #include "menu.h" #include "string_util.h" +#include "event_data.h" #include "ewram.h" struct StorageAction { @@ -13,6 +14,93 @@ extern const struct StorageAction gUnknown_083B6DF4[]; EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; +u8 sub_8095ADC(u8 boxId) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < 30; i++) + { + if (GetBoxMonData(gPokemonStorage.boxes[boxId] + i, MON_DATA_SPECIES) != 0) + count++; + } + return count; +} + +s16 sub_8095B24(u8 boxId) +{ + u16 i; + + for (i = 0; i < 30; i++) + { + if (GetBoxMonData(gPokemonStorage.boxes[boxId] + i, MON_DATA_SPECIES) == 0) + return i; + } + return -1; +} + +u8 GetNumValidDaycarePartyMons(void) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + struct Pokemon *pokemon = gPlayerParty + i; + if (GetMonData(pokemon, MON_DATA_SPECIES) != 0 && !GetMonData(pokemon, MON_DATA_IS_EGG)) + count++; + } + return count; +} + +u8 CountAlivePartyMonsExceptOne(u8 toSkip) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (i != toSkip) + { + struct Pokemon *pokemon = gPlayerParty + i; + if (GetMonData(pokemon, MON_DATA_SPECIES) != 0 && !GetMonData(pokemon, MON_DATA_IS_EGG) && GetMonData(pokemon, MON_DATA_HP) != 0) + count++; + } + } + return count; +} + +u8 CountAlivePartyMonsExceptSelectedOne(void) +{ + return CountAlivePartyMonsExceptOne(gSpecialVar_0x8004); +} + +u8 StorageSystemGetPartySize(void) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(gPlayerParty + i, MON_DATA_SPECIES) != 0) + count++; + } + return count; +} + +u8 *unref_sub_8095C60(u8 *dest, const u8 *src, u16 pad) +{ + u8 *_dest = StringCopy(dest, src); + while (_dest < dest + pad) + { + *_dest++ = CHAR_SPACE; + } + *_dest = EOS; + return _dest; +} + +asm(".section .text.8098898"); + void sub_8098898(u8 index) { u8 *ptr; -- cgit v1.2.3 From 6ce6e18fd50951ec784f5534f0bcb929aadd24d6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 11:05:39 -0500 Subject: sub_8095C8C --- src/pokemon/pokemon_storage_system.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 2ea7161cf..3c029b0aa 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -99,6 +99,21 @@ u8 *unref_sub_8095C60(u8 *dest, const u8 *src, u16 pad) return _dest; } +void sub_8095C8C(u16 *dest, u16 dest_left, u16 dest_top, u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) +{ + u16 i; + + dest_width *= 2; + dest += dest_top * 0x20 + dest_left; + src += src_top * src_width + src_left; + for (i = 0; i < dest_height; i++) + { + CpuCopy16(src, dest, dest_width); + dest += 0x20; + src += src_width; + } +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 4db981200c1d011c370a45d123c31b397b7d62cc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 11:54:46 -0500 Subject: nonmatching unref_sub_8095D08 --- src/pokemon/pokemon_storage_system.c | 138 ++++++++++++++++++++++++++++++++++- 1 file changed, 137 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 3c029b0aa..5cb61f365 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -99,7 +99,7 @@ u8 *unref_sub_8095C60(u8 *dest, const u8 *src, u16 pad) return _dest; } -void sub_8095C8C(u16 *dest, u16 dest_left, u16 dest_top, u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) +void sub_8095C8C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) { u16 i; @@ -114,6 +114,142 @@ void sub_8095C8C(u16 *dest, u16 dest_left, u16 dest_top, u16 *src, u16 src_left, } } +#ifdef NONMATCHING +void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) +{ + u16 i; + + dest += dest_top * 0x20 + dest_left; + width *= 2; + for (i = 0; i < height; dest += 0x20, i++) + { + void *_dest = dest; + size_t _size = width; + if (_size <= 0x1000) + { + DmaFill16(3, 0, _dest, _size); + } + else + { + while (1) + { + DmaFill16(3, 0, _dest, 0x1000); + _dest += 0x1000; + _size -= 0x1000; + if (_size <= 0x1000) + { + DmaFill16(3, 0, _dest, _size); + break; + } + } + } + } +} +#else +__attribute__((naked)) void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tsub sp, 0x8\n" + "\tadds r4, r0, 0\n" + "\tldr r0, [sp, 0x28]\n" + "\tlsls r1, 16\n" + "\tlsrs r1, 16\n" + "\tlsls r2, 16\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tmov r10, r0\n" + "\tlsrs r2, 11\n" + "\tadds r2, r1\n" + "\tlsls r2, 1\n" + "\tadds r4, r2\n" + "\tlsls r3, 17\n" + "\tlsrs r0, r3, 16\n" + "\tstr r0, [sp, 0x4]\n" + "\tmovs r0, 0\n" + "\tcmp r0, r10\n" + "\tbcs _08095DB2\n" + "\tmovs r6, 0x80\n" + "\tlsls r6, 5\n" + "\tmov r5, sp\n" + "\tldr r7, _08095D74 @ =0x040000d4\n" + "\tlsrs r3, 17\n" + "\tmov r9, r3\n" + "\tmov r1, r9\n" + "\tmovs r2, 0x81\n" + "\tlsls r2, 24\n" + "\torrs r1, r2\n" + "\tmov r9, r1\n" + "_08095D4E:\n" + "\tadds r3, r4, 0\n" + "\tldr r2, [sp, 0x4]\n" + "\tmovs r1, 0x40\n" + "\tadds r1, r4\n" + "\tmov r8, r1\n" + "\tadds r0, 0x1\n" + "\tmov r12, r0\n" + "\tcmp r2, r6\n" + "\tbhi _08095D78\n" + "\tmovs r0, 0\n" + "\tstrh r0, [r5]\n" + "\tmov r2, sp\n" + "\tstr r2, [r7]\n" + "\tstr r4, [r7, 0x4]\n" + "\tmov r0, r9\n" + "\tstr r0, [r7, 0x8]\n" + "\tldr r0, [r7, 0x8]\n" + "\tb _08095DA6\n" + "\t.align 2, 0\n" + "_08095D74: .4byte 0x040000d4\n" + "_08095D78:\n" + "\tmovs r4, 0\n" + "\tstrh r4, [r5]\n" + "\tldr r1, _08095DC4 @ =0x040000d4\n" + "\tmov r0, sp\n" + "\tstr r0, [r1]\n" + "\tstr r3, [r1, 0x4]\n" + "\tldr r0, _08095DC8 @ =0x81000800\n" + "\tstr r0, [r1, 0x8]\n" + "\tldr r0, [r1, 0x8]\n" + "\tadds r3, r6\n" + "\tsubs r2, r6\n" + "\tcmp r2, r6\n" + "\tbhi _08095D78\n" + "\tstrh r4, [r5]\n" + "\tmov r0, sp\n" + "\tstr r0, [r1]\n" + "\tstr r3, [r1, 0x4]\n" + "\tlsrs r0, r2, 1\n" + "\tmovs r2, 0x81\n" + "\tlsls r2, 24\n" + "\torrs r0, r2\n" + "\tstr r0, [r1, 0x8]\n" + "\tldr r0, [r1, 0x8]\n" + "_08095DA6:\n" + "\tmov r4, r8\n" + "\tmov r1, r12\n" + "\tlsls r0, r1, 16\n" + "\tlsrs r0, 16\n" + "\tcmp r0, r10\n" + "\tbcc _08095D4E\n" + "_08095DB2:\n" + "\tadd sp, 0x8\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_08095DC4: .4byte 0x040000d4\n" + "_08095DC8: .4byte 0x81000800"); +} +#endif + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From a7e900e31b472385fda5fab48fc3c76212a0e0c2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 12:47:00 -0500 Subject: StorageSystemGetNextMonIndex --- src/pokemon/pokemon_storage_system.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 5cb61f365..745a27bf6 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -250,6 +250,37 @@ __attribute__((naked)) void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest } #endif +s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode) +{ + s16 i; + s16 direction; + if (mode == 0 || mode == 2) + { + direction = 1; + } + else + { + direction = -1; + } + if (mode == 2 || mode == 3) + { + for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction) + { + if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0) + return i; + } + } + else + { + for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction) + { + if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0 && !GetBoxMonData(box + i, MON_DATA_IS_EGG)) + return i; + } + } + return -1; +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From d19de32aba198ac2e5691cab088b3d84cd390b39 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 15:16:51 -0500 Subject: through Task_PokemonStorageSystem --- src/pokemon/pokemon_storage_system.c | 124 ++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 745a27bf6..a5a3bdcd8 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -1,17 +1,32 @@ #include "global.h" -#include "pokemon_storage_system.h" +#include "palette.h" +#include "field_weather.h" #include "menu.h" +#include "main.h" +#include "strings.h" #include "string_util.h" #include "event_data.h" #include "ewram.h" +#include "script.h" +#include "pokemon_storage_system.h" struct StorageAction { u8 *text; u8 format; }; +struct ReverseMenuAction { + u32 unk0; + u8 *text; +}; + +void StorageSystemCreatePrimaryMenu(u8 whichMenu); +void task_intro_29(u8 whichMenu); + extern const struct StorageAction gUnknown_083B6DF4[]; +extern const struct ReverseMenuAction gUnknown_083B600C[]; + EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; u8 sub_8095ADC(u8 boxId) @@ -281,6 +296,113 @@ s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx return -1; } +void StorageSystemClearMessageWindow(void) +{ + MenuFillWindowRectWithBlankTile(2, 15, 27, 18); +} + +void Task_PokemonStorageSystem(u8 taskId) +{ + struct Task *task = gTasks + taskId; + switch (task->data[0]) + { + case 0: + StorageSystemCreatePrimaryMenu(task->data[1]); + MenuDisplayMessageBox(); + MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + task->data[0]++; + break; + case 1: + if (sub_807D770()) + { + task->data[0]++; + } + break; + case 2: + task->data[2] = ProcessMenuInput(); + switch(task->data[2]) + { + case -2: + task->data[3] = task->data[1]; + if (gMain.newKeys & DPAD_UP && --task->data[3] < 0) + task->data[3] = 3; + + if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 3) + task->data[3] = 0; + if (task->data[1] != task->data[3]) + { + task->data[1] = task->data[3]; + StorageSystemClearMessageWindow(); + MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + } + break; + case -1: + case 3: + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 13, 9); + ScriptContext2_Disable(); + EnableBothScriptContexts(); + DestroyTask(taskId); + break; + default: + if (task->data[2] == 0 && StorageSystemGetPartySize() == PARTY_SIZE) + { + StorageSystemClearMessageWindow(); + MenuPrint(gPCText_PartyFull2, 2, 15); + task->data[0] = 3; + } + else if (task->data[2] == 1 && StorageSystemGetPartySize() == 1) + { + StorageSystemClearMessageWindow(); + MenuPrint(gPCText_OnlyOne, 2, 15); + task->data[0] = 3; + } + else + { + fade_screen(1, 0); + task->data[0] = 4; + } + break; + } + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + StorageSystemClearMessageWindow(); + MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + task->data[0] = 2; + } + else if (gMain.newKeys & DPAD_UP) + { + if (--task->data[1] < 0) + task->data[1] = 3; + MoveMenuCursor(-1); + task->data[1] = GetMenuCursorPos(); + StorageSystemClearMessageWindow(); + MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + task->data[0] = 2; + } + else if (gMain.newKeys & DPAD_DOWN) + { + if (++task->data[1] > 3) + task->data[1] = 0; + MoveMenuCursor(1); + task->data[1] = GetMenuCursorPos(); + StorageSystemClearMessageWindow(); + MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + task->data[0] = 2; + } + break; + case 4: + if (!gPaletteFade.active) + { + task_intro_29(task->data[2]); + DestroyTask(taskId); + } + break; + } +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 666654ff6dcec5916a7eac8425a5ddaae3be1a0e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 16:04:53 -0500 Subject: through ResetPokemonStorageSystem --- src/pokemon/pokemon_storage_system.c | 65 +++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index a5a3bdcd8..8f0753a2d 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -1,6 +1,8 @@ #include "global.h" #include "palette.h" #include "field_weather.h" +#include "overworld.h" +#include "field_fadetransition.h" #include "menu.h" #include "main.h" #include "strings.h" @@ -20,14 +22,21 @@ struct ReverseMenuAction { u8 *text; }; +struct PokemonStorageSystemData { + u8 filler_0000[5]; + u8 unk_0005; +}; + +const struct PokemonStorageSystemData *gUnknown_083B6DB4; + void StorageSystemCreatePrimaryMenu(u8 whichMenu); void task_intro_29(u8 whichMenu); extern const struct StorageAction gUnknown_083B6DF4[]; - extern const struct ReverseMenuAction gUnknown_083B600C[]; EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; +EWRAM_DATA u8 gUnknown_02038474; u8 sub_8095ADC(u8 boxId) { @@ -403,6 +412,60 @@ void Task_PokemonStorageSystem(u8 taskId) } } +void ShowPokemonStorageSystem(void) +{ + u8 taskId = CreateTask(Task_PokemonStorageSystem, 80); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + ScriptContext2_Enable(); +} + +void sub_8096130(void) +{ + u8 taskId = CreateTask(Task_PokemonStorageSystem, 80); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = gUnknown_02038474; + pal_fill_black(); +} + +void StorageSystemCreatePrimaryMenu(u8 a0) +{ + MenuDrawTextWindow(0, 0, 13, 9); + PrintMenuItems(1, 1, 4, (const struct MenuAction *)gUnknown_083B600C); + InitMenu(0, 1, 1, 4, a0, 12); +} + +void sub_80961A8(void) +{ + gUnknown_02038474 = gUnknown_083B6DB4->unk_0005; + gFieldCallback = sub_8096130; + SetMainCallback2(c2_exit_to_overworld_2_switch); +} + +void ResetPokemonStorageSystem(void) +{ + u16 boxId; + u16 boxMon; + + gPokemonStorage.currentBox = 0; + for (boxId = 0; boxId < 14; boxId++) + { + for (boxMon = 0; boxMon < 30; boxMon++) + { + ZeroBoxMonData(gPokemonStorage.boxes[boxId] + boxMon); + } + } + for (boxId = 0; boxId < 14; boxId++) + { + u8 *dest = StringCopy(gPokemonStorage.boxNames[boxId], gPCText_BOX); + ConvertIntToDecimalStringN(dest, boxId + 1, STR_CONV_MODE_LEFT_ALIGN, 2); + } + for (boxId = 0; boxId < 14; boxId++) + { + gPokemonStorage.wallpaper[boxId] = boxId & 0x03; + } +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 92577647185e885298bfe3e4159f702730bdf310 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 16:40:49 -0500 Subject: sub_8096264 --- src/pokemon/pokemon_storage_system.c | 97 +++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 8f0753a2d..bc43616a9 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -17,9 +17,9 @@ struct StorageAction { u8 format; }; -struct ReverseMenuAction { - u32 unk0; - u8 *text; +struct PSS_MenuStringPtrs { + const u8 *text; + const u8 *desc; }; struct PokemonStorageSystemData { @@ -27,16 +27,71 @@ struct PokemonStorageSystemData { u8 unk_0005; }; -const struct PokemonStorageSystemData *gUnknown_083B6DB4; +struct UnkPSSStruct_2002370 { + u8 filler_0000[0x23e]; + u8 unk_023e; + u16 unk_0240; + u16 unk_0242; +}; void StorageSystemCreatePrimaryMenu(u8 whichMenu); void task_intro_29(u8 whichMenu); +const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { + {PCText_WithdrawPoke, PCText_MovePokeToParty}, + {PCText_DepositPoke, PCText_StorePokeInBox}, + {PCText_MovePoke, PCText_OrganizeBoxesParty}, + {PCText_SeeYa, PCText_ReturnToPrevMenu} +}; + +const union AnimCmd gSpriteAnim_83B602C[] = { + ANIMCMD_FRAME( 0, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83B6034[] = { + ANIMCMD_FRAME( 4, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83B603C[] = { + ANIMCMD_FRAME( 6, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83B6044[] = { + ANIMCMD_FRAME(10, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83B604C[] = { + gSpriteAnim_83B602C, + gSpriteAnim_83B6034, + gSpriteAnim_83B603C, + gSpriteAnim_83B6044 +}; + +const union AffineAnimCmd gSpriteAffineAnim_83B605C[] = { + AFFINEANIMCMD_FRAME(0xe0, 0xe0, 0, 0), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gSpriteAffineAnimTable_83B606C[] = { + gSpriteAffineAnim_83B605C +}; + +const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/pokemon_storage/box_selection_popup.gbapal"); + +const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp"); + +const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); + extern const struct StorageAction gUnknown_083B6DF4[]; -extern const struct ReverseMenuAction gUnknown_083B600C[]; +extern const struct PokemonStorageSystemData *gUnknown_083B6DB4; EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; EWRAM_DATA u8 gUnknown_02038474; +EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478; u8 sub_8095ADC(u8 boxId) { @@ -318,7 +373,7 @@ void Task_PokemonStorageSystem(u8 taskId) case 0: StorageSystemCreatePrimaryMenu(task->data[1]); MenuDisplayMessageBox(); - MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0]++; break; case 1: @@ -342,7 +397,7 @@ void Task_PokemonStorageSystem(u8 taskId) { task->data[1] = task->data[3]; StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); } break; case -1: @@ -378,7 +433,7 @@ void Task_PokemonStorageSystem(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0] = 2; } else if (gMain.newKeys & DPAD_UP) @@ -388,7 +443,7 @@ void Task_PokemonStorageSystem(u8 taskId) MoveMenuCursor(-1); task->data[1] = GetMenuCursorPos(); StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0] = 2; } else if (gMain.newKeys & DPAD_DOWN) @@ -398,7 +453,7 @@ void Task_PokemonStorageSystem(u8 taskId) MoveMenuCursor(1); task->data[1] = GetMenuCursorPos(); StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].text, 2, 15); + MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0] = 2; } break; @@ -428,11 +483,11 @@ void sub_8096130(void) pal_fill_black(); } -void StorageSystemCreatePrimaryMenu(u8 a0) +void StorageSystemCreatePrimaryMenu(u8 whichMenu) { MenuDrawTextWindow(0, 0, 13, 9); PrintMenuItems(1, 1, 4, (const struct MenuAction *)gUnknown_083B600C); - InitMenu(0, 1, 1, 4, a0, 12); + InitMenu(0, 1, 1, 4, whichMenu, 12); } void sub_80961A8(void) @@ -466,6 +521,24 @@ void ResetPokemonStorageSystem(void) } } +void sub_8096264(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3) +{ + struct SpritePalette palette = { + gBoxSelectionPopupPalette, palTag + }; + struct SpriteSheet sheets[] = { + {gBoxSelectionPopupCenterTiles, 0x800, tileTag}, + {gBoxSelectionPopupSidesTiles, 0x180, tileTag + 1}, + {} + }; + LoadSpritePalette(&palette); + LoadSpriteSheets(sheets); + gUnknown_02038478 = a0; + a0->unk_0240 = tileTag; + a0->unk_0242 = palTag; + a0->unk_023e = a3; +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From aa023a5cb52c7b7a4cb2e23aadcd7db4bf0b3483 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 22:21:05 -0500 Subject: through sub_80963D0 --- src/pokemon/pokemon_storage_system.c | 113 ++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index bc43616a9..37414f32b 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -1,5 +1,7 @@ #include "global.h" #include "palette.h" +#include "constants/songs.h" +#include "sound.h" #include "field_weather.h" #include "overworld.h" #include "field_fadetransition.h" @@ -28,7 +30,13 @@ struct PokemonStorageSystemData { }; struct UnkPSSStruct_2002370 { - u8 filler_0000[0x23e]; + struct Sprite *unk_0000; + struct Sprite *unk_0004[4]; + u32 unk_0014[3]; + struct Sprite *unk_0020[2]; + u8 filler_0028[0x214]; + u8 unk_023c; + u8 unk_023d; u8 unk_023e; u16 unk_0240; u16 unk_0242; @@ -36,6 +44,13 @@ struct UnkPSSStruct_2002370 { void StorageSystemCreatePrimaryMenu(u8 whichMenu); void task_intro_29(u8 whichMenu); +void sub_80963D0(u8 a0); +void sub_809658C(void); +void sub_80965F8(void); +void sub_809662C(void); +void sub_809665C(void); +void sub_8096784(struct Sprite *sprite); +struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { {PCText_WithdrawPoke, PCText_MovePokeToParty}, @@ -539,6 +554,102 @@ void sub_8096264(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3 a0->unk_023e = a3; } +void sub_8096310(void) +{ + FreeSpritePaletteByTag(gUnknown_02038478->unk_0242); + FreeSpriteTilesByTag(gUnknown_02038478->unk_0240); + FreeSpriteTilesByTag(gUnknown_02038478->unk_0240 + 1); +} + +void sub_809634C(u8 a0) +{ + sub_80963D0(a0); +} + +void sub_809635C(void) +{ + sub_809658C(); +} + +u8 sub_8096368(void) +{ + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + return 201; + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + return gUnknown_02038478->unk_023c; + } + if (gMain.newKeys & DPAD_LEFT) + { + PlaySE(SE_SELECT); + sub_809662C(); + } + else if (gMain.newKeys & DPAD_RIGHT) + { + PlaySE(SE_SELECT); + sub_80965F8(); + } + return 200; +} + +void sub_80963D0(u8 a0) +{ + u16 i; + u8 spriteId; + struct SpriteTemplate template; + struct OamData oamData = {}; + oamData.size = 3; + oamData.paletteNum = 1; + template = (struct SpriteTemplate){ + 0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy + }; + + gUnknown_02038478->unk_023c = a0; + template.tileTag = gUnknown_02038478->unk_0240; + template.paletteTag = gUnknown_02038478->unk_0242; + + spriteId = CreateSprite(&template, 0xa0, 0x60, 0); + gUnknown_02038478->unk_0000 = gSprites + spriteId; + + oamData.shape = ST_OAM_V_RECTANGLE; + oamData.size = 1; + template.tileTag = gUnknown_02038478->unk_0240 + 1; + template.anims = gSpriteAnimTable_83B604C; + for (i = 0; i < 4; i++) + { + u16 r5; + spriteId = CreateSprite(&template, 0x7c, 0x50, gUnknown_02038478->unk_023e); + gUnknown_02038478->unk_0004[i] = gSprites + spriteId; + r5 = 0; + if (i & 2) + { + gUnknown_02038478->unk_0004[i]->pos1.x = 0xc4; + r5 = 2; + } + if (i & 1) + { + gUnknown_02038478->unk_0004[i]->pos1.y = 0x70; + gUnknown_02038478->unk_0004[i]->oam.size = 0; + r5++; + } + StartSpriteAnim(gUnknown_02038478->unk_0004[i], r5); + } + for (i = 0; i < 2; i++) + { + gUnknown_02038478->unk_0020[i] = sub_809A9A0(72 * i + 0x7c, 0x58, i, 0, gUnknown_02038478->unk_023e); + if (gUnknown_02038478->unk_0020[i]) + { + gUnknown_02038478->unk_0020[i]->data[0] = (i == 0 ? -1 : 1); + gUnknown_02038478->unk_0020[i]->callback = sub_8096784; + } + } + sub_809665C(); +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 92fa7570b99d216f75becbd362a124a12cc1dcde Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jan 2018 18:44:14 -0500 Subject: through task_intro_29 --- src/pokemon/pokemon_storage_system.c | 125 ++++++++++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 37414f32b..30c0f2b67 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -35,7 +35,7 @@ struct UnkPSSStruct_2002370 { u32 unk_0014[3]; struct Sprite *unk_0020[2]; u8 filler_0028[0x214]; - u8 unk_023c; + u8 curBox; u8 unk_023d; u8 unk_023e; u16 unk_0240; @@ -43,13 +43,15 @@ struct UnkPSSStruct_2002370 { }; void StorageSystemCreatePrimaryMenu(u8 whichMenu); -void task_intro_29(u8 whichMenu); -void sub_80963D0(u8 a0); +void sub_80963D0(u8 curBox); void sub_809658C(void); void sub_80965F8(void); void sub_809662C(void); void sub_809665C(void); +void sub_80966F4(const u8 *sourceString, u16 x, u16 y); void sub_8096784(struct Sprite *sprite); +void task_intro_29(u8 whichMenu); +void sub_8096884(void); struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { @@ -103,12 +105,15 @@ const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/bo extern const struct StorageAction gUnknown_083B6DF4[]; extern const struct PokemonStorageSystemData *gUnknown_083B6DB4; +extern u8 *const gUnknown_083B6DB8; EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; EWRAM_DATA u8 gUnknown_02038474; EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478; +EWRAM_DATA u8 gUnknown_0203847C; +EWRAM_DATA u8 gUnknown_0203847D; -u8 sub_8095ADC(u8 boxId) +static u8 CountPokemonInBoxN(u8 boxId) { u16 i; u16 count; @@ -121,7 +126,7 @@ u8 sub_8095ADC(u8 boxId) return count; } -s16 sub_8095B24(u8 boxId) +s16 GetIndexOfFirstEmptySpaceInBoxN(u8 boxId) { u16 i; @@ -561,9 +566,9 @@ void sub_8096310(void) FreeSpriteTilesByTag(gUnknown_02038478->unk_0240 + 1); } -void sub_809634C(u8 a0) +void sub_809634C(u8 curBox) { - sub_80963D0(a0); + sub_80963D0(curBox); } void sub_809635C(void) @@ -581,7 +586,7 @@ u8 sub_8096368(void) if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - return gUnknown_02038478->unk_023c; + return gUnknown_02038478->curBox; } if (gMain.newKeys & DPAD_LEFT) { @@ -596,7 +601,7 @@ u8 sub_8096368(void) return 200; } -void sub_80963D0(u8 a0) +void sub_80963D0(u8 curBox) { u16 i; u8 spriteId; @@ -608,11 +613,11 @@ void sub_80963D0(u8 a0) 0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy }; - gUnknown_02038478->unk_023c = a0; + gUnknown_02038478->curBox = curBox; template.tileTag = gUnknown_02038478->unk_0240; template.paletteTag = gUnknown_02038478->unk_0242; - spriteId = CreateSprite(&template, 0xa0, 0x60, 0); + spriteId = CreateSprite(&template, 0xA0, 0x60, 0); gUnknown_02038478->unk_0000 = gSprites + spriteId; oamData.shape = ST_OAM_V_RECTANGLE; @@ -650,6 +655,104 @@ void sub_80963D0(u8 a0) sub_809665C(); } +void sub_809658C(void) +{ + u16 i; + if (gUnknown_02038478->unk_0000) + { + DestroySprite(gUnknown_02038478->unk_0000); + gUnknown_02038478->unk_0000 = NULL; + } + for (i = 0; i < 4; i++) + { + if (gUnknown_02038478->unk_0004[i]) + { + DestroySprite(gUnknown_02038478->unk_0004[i]); + gUnknown_02038478->unk_0004[i] = NULL; + } + } + for (i = 0; i < 2; i++) + { + if (gUnknown_02038478->unk_0020[i]) + DestroySprite(gUnknown_02038478->unk_0020[i]); + } +} + +void sub_80965F8(void) +{ + if (++gUnknown_02038478->curBox > 13) + gUnknown_02038478->curBox = 0; + sub_809665C(); +} + +void sub_809662C(void) +{ + gUnknown_02038478->curBox = (gUnknown_02038478->curBox == 0 ? 13 : gUnknown_02038478->curBox - 1); + sub_809665C(); +} + +void sub_809665C(void) +{ + u8 nPokemonInBox = CountPokemonInBoxN(gUnknown_02038478->curBox); + u8 *stringVar = gStringVar1; + + stringVar[0] = EXT_CTRL_CODE_BEGIN; + stringVar[1] = 0x04; // EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW + stringVar[2] = 0x0F; // TEXT_COLOR_WHITE2 + stringVar[3] = 0x01; // TEXT_COLOR_DARK_GREY + stringVar[4] = 0x0E; // TEXT_COLOR_LIGHT_BLUE + stringVar += 5; + + stringVar = StringCopy(stringVar, gPokemonStorage.boxNames[gUnknown_02038478->curBox]); + + stringVar[0] = CHAR_NEWLINE; + stringVar[1] = EXT_CTRL_CODE_BEGIN; + stringVar[2] = 0x11; // EXT_CTRL_CODE_CLEAR + if (nPokemonInBox < 10) + stringVar[3] = 0x28; + else + stringVar[3] = 0x22; + stringVar += 4; + + stringVar = ConvertIntToDecimalString(stringVar, nPokemonInBox); + + stringVar[0] = CHAR_SLASH; + stringVar[1] = CHAR_0 + 3; + stringVar[2] = CHAR_0 + 0; + stringVar[3] = EOS; + sub_80966F4(gStringVar1, 0, 1); +} + +void sub_80966F4(const u8 *sourceString, u16 x, u16 y) +{ + u16 *vdest = (u16 *)(BG_CHAR_ADDR(4) + (GetSpriteTileStartByTag(gUnknown_02038478->unk_0240) * 32) + y * 256 + x * 32); + u8 *tileBuff = gUnknown_083B6DB8; + DmaFill16(3, 0x1111, tileBuff, 0x400); + sub_8004E3C(&gWindowConfig_81E6D38, tileBuff, sourceString); + DmaCopy16(3, tileBuff, vdest, 0x400); +} + +void sub_8096784(struct Sprite *sprite) +{ + if (++sprite->data[1] > 3) + { + sprite->data[1] = 0; + sprite->pos2.x += sprite->data[0]; + if (++sprite->data[2] > 5) + { + sprite->data[2] = 0; + sprite->pos2.x = 0; + } + } +} + +void task_intro_29(u8 whichMenu) +{ + gUnknown_0203847D = whichMenu; + ePokemonStorageSystem.unk_0005 = whichMenu; + SetMainCallback2(sub_8096884); +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From b9ad9b3ad547b200e66b293169acbbfe4f50f76d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jan 2018 19:20:15 -0500 Subject: through sub_8096874 --- src/engine/naming_screen.c | 2 -- src/field/use_pokeblock.c | 1 - src/pokemon/pokemon_storage_system.c | 47 ++++++++++++++++++++++++++++++++++++ src/pokenav_before.c | 5 +--- 4 files changed, 48 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/engine/naming_screen.c b/src/engine/naming_screen.c index 440504d5a..6f34fd678 100644 --- a/src/engine/naming_screen.c +++ b/src/engine/naming_screen.c @@ -26,8 +26,6 @@ #define COLUMN_COUNT 10 #endif -extern u16 gKeyRepeatStartDelay; - extern u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality); const u8 gSpriteImage_83CE094[] = INCBIN_U8("graphics/naming_screen/pc_icon/0.4bpp"); diff --git a/src/field/use_pokeblock.c b/src/field/use_pokeblock.c index 7253ac901..354193c14 100644 --- a/src/field/use_pokeblock.c +++ b/src/field/use_pokeblock.c @@ -104,7 +104,6 @@ static EWRAM_DATA struct Pokeblock *gUnknown_0203930C = NULL; EWRAM_DATA u8 gPokeblockMonID = 0; EWRAM_DATA s16 gPokeblockGain = 0; -extern u16 gKeyRepeatStartDelay; extern u16 gSpecialVar_ItemId; // FIXME: remove after merge of #349 Pokeblock static void launch_c3_walk_stairs_and_run_once(void (*const)(void)); diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 30c0f2b67..9e559354b 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -24,9 +24,17 @@ struct PSS_MenuStringPtrs { const u8 *desc; }; +struct UnkStruct_2000020 { + struct UnkStruct_2000020 *unk_00; + u8 unk_04; + u8 unk_05; +}; + struct PokemonStorageSystemData { u8 filler_0000[5]; u8 unk_0005; + u8 filler_0006[26]; + struct UnkStruct_2000020 unk_0020[100]; // refine size later }; struct UnkPSSStruct_2002370 { @@ -53,6 +61,8 @@ void sub_8096784(struct Sprite *sprite); void task_intro_29(u8 whichMenu); void sub_8096884(void); struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); +void sub_809B0D4(void); +void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 * a1, u8 a2); const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { {PCText_WithdrawPoke, PCText_MovePokeToParty}, @@ -112,6 +122,7 @@ EWRAM_DATA u8 gUnknown_02038474; EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478; EWRAM_DATA u8 gUnknown_0203847C; EWRAM_DATA u8 gUnknown_0203847D; +EWRAM_DATA u8 gUnknown_0203847E; static u8 CountPokemonInBoxN(u8 boxId) { @@ -753,6 +764,42 @@ void task_intro_29(u8 whichMenu) SetMainCallback2(sub_8096884); } +void sub_80967DC(void) +{ + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2VOFS = 0; + REG_BG2HOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; +} + +void sub_8096804(void) +{ + ResetPaletteFade(); + ResetSpriteData(); + FreeSpriteTileRanges(); + FreeAllSpritePalettes(); + ResetTasks(); + gReservedSpriteTileCount = 0x280; + sub_809CFDC(ePokemonStorageSystem.unk_0020, ePokemonStorageSystem.unk_0020 + 1, 8); + gKeyRepeatStartDelay = 20; +} + +void sub_8096848(void) +{ + sub_809B0D4(); + gUnknown_0203847C = (ePokemonStorageSystem.unk_0005 == 1 ? 1 : 0); + gUnknown_0203847E = 0; +} + +void sub_8096874(void) +{ + REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { diff --git a/src/pokenav_before.c b/src/pokenav_before.c index 7693cba7d..53f17b211 100644 --- a/src/pokenav_before.c +++ b/src/pokenav_before.c @@ -294,9 +294,6 @@ extern void sub_80F5BF0(); extern void sub_80F6F64(); extern void sub_80F19FC(); -extern u16 gKeyRepeatStartDelay; - - void sub_80EBA5C() { switch (gMain.state) { default: @@ -378,7 +375,7 @@ void sub_80EBC10() { u16 i; u16 *var1; - gKeyRepeatStartDelay = 0x14; + gKeyRepeatStartDelay = 20; ewram0_10.playerPartyCount = CalculatePlayerPartyCount(); ewram0_10.var6ddc = 0; ewram0_10.var9344 = 0; -- cgit v1.2.3 From bfeaa80fcd9409645325c2f7ae94850f970fbb58 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jan 2018 19:47:59 -0500 Subject: through sub_8096884 --- src/pokemon/mon_markings.c | 20 +--------- src/pokemon/pokemon_storage_system.c | 74 +++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/pokemon/mon_markings.c b/src/pokemon/mon_markings.c index b4144ea34..d27719c4a 100644 --- a/src/pokemon/mon_markings.c +++ b/src/pokemon/mon_markings.c @@ -5,6 +5,7 @@ #include "constants/songs.h" #include "sound.h" #include "sprite.h" +#include "mon_markings.h" #ifdef GERMAN #define MENU_TEXT_SPRITE_X_OFFSET 24 @@ -12,25 +13,6 @@ #define MENU_TEXT_SPRITE_X_OFFSET 32 #endif -struct PokemonMarkMenu -{ - /*0x0000*/ u16 baseTileTag; - /*0x0002*/ u16 basePaletteTag; - /*0x0004*/ u8 markings; // bit flags - /*0x0005*/ s8 cursorPos; - /*0x0006*/ bool8 markingsArray[4]; - /*0x000A*/ u8 cursorBaseY; - /*0x000B*/ bool8 spriteSheetLoadRequired; - /*0x000C*/ struct Sprite *menuWindowSprites[2]; // upper and lower halves of menu window - /*0x0014*/ struct Sprite *menuMarkingSprites[4]; - /*0x0024*/ struct Sprite *menuTextSprite; - /*0x0028*/ const u8 *frameTiles; - /*0x002C*/ const u16 *framePalette; - /*0x0030*/ u8 menuWindowSpriteTiles[0x1000]; - /*0x1030*/ u8 filler1030[0x80]; - /*0x10B0*/ u8 tileLoadState; -}; - extern u8 gPokenavConditionMenuMisc_Gfx[]; extern u16 gUnknown_08E966B8[]; diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 9e559354b..91d56a4b9 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -3,6 +3,7 @@ #include "constants/songs.h" #include "sound.h" #include "field_weather.h" +#include "mon_markings.h" #include "overworld.h" #include "field_fadetransition.h" #include "menu.h" @@ -34,7 +35,9 @@ struct PokemonStorageSystemData { u8 filler_0000[5]; u8 unk_0005; u8 filler_0006[26]; - struct UnkStruct_2000020 unk_0020[100]; // refine size later + struct UnkStruct_2000020 unk_0020[595]; // refine size later + u8 filler_12b8[4]; + struct PokemonMarkMenu unk_12bc; }; struct UnkPSSStruct_2002370 { @@ -60,6 +63,16 @@ void sub_80966F4(const u8 *sourceString, u16 x, u16 y); void sub_8096784(struct Sprite *sprite); void task_intro_29(u8 whichMenu); void sub_8096884(void); +void sub_8096AFC(void); +void sub_8096B38(void); +void sub_8096BE0(void (*func)(void)); +void sub_8096BF0(void); +void sub_8097DE0(void); +void sub_8097E70(void); +void sub_8098400(void); +void sub_8099BF8(u8 a0); +void sub_8098B48(void); +void sub_809AA24(void); struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); void sub_809B0D4(void); void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 * a1, u8 a2); @@ -800,6 +813,65 @@ void sub_8096874(void) REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; } +void sub_8096884(void) +{ + switch (gMain.state) + { + case 0: + SetVBlankCallback(NULL); + REG_DISPCNT = 0; + sub_8096804(); + gMain.state++; + break; + case 1: + SetUpWindowConfig(&gWindowConfig_81E6D00); + gMain.state++; + break; + case 2: + InitMenuWindow(&gWindowConfig_81E6D00); + MenuZeroFillScreen(); + gMain.state++; + break; + case 3: + sub_80967DC(); + sub_8096848(); + gMain.state++; + break; + case 4: + sub_8098B48(); + sub_809AA24(); + gMain.state++; + break; + case 5: + sub_8097DE0(); + gMain.state++; + break; + case 6: + sub_8097E70(); + gMain.state++; + break; + case 7: + sub_8098400(); + gMain.state++; + break; + case 8: + sub_8099BF8(gPokemonStorage.currentBox); + ePokemonStorageSystem.unk_12bc.baseTileTag = 0x000a; + ePokemonStorageSystem.unk_12bc.basePaletteTag = 0xdacb; + sub_80F727C(&ePokemonStorageSystem.unk_12bc); + sub_80F7404(); + gMain.state++; + break; + case 9: + sub_8096874(); + sub_8096BE0(sub_8096BF0); + SetMainCallback2(sub_8096B38); + SetVBlankCallback(sub_8096AFC); + gMain.state++; + break; + } +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 0947fdf167bff7fe67e1344fea8b287fc59a6cd2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jan 2018 21:27:40 -0500 Subject: sub_80969A0 --- src/pokemon/pokemon_storage_system.c | 97 +++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 91d56a4b9..2b36f5d71 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -67,15 +67,19 @@ void sub_8096AFC(void); void sub_8096B38(void); void sub_8096BE0(void (*func)(void)); void sub_8096BF0(void); +void sub_8096C68(void); void sub_8097DE0(void); void sub_8097E70(void); void sub_8098400(void); void sub_8099BF8(u8 a0); void sub_8098B48(void); -void sub_809AA24(void); struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); +void sub_809AA24(void); +void sub_809AA98(void); void sub_809B0D4(void); -void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 * a1, u8 a2); +void sub_809BBC0(void); +void sub_809BD14(void); +void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { {PCText_WithdrawPoke, PCText_MovePokeToParty}, @@ -131,11 +135,23 @@ extern const struct PokemonStorageSystemData *gUnknown_083B6DB4; extern u8 *const gUnknown_083B6DB8; EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; -EWRAM_DATA u8 gUnknown_02038474; -EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478; -EWRAM_DATA u8 gUnknown_0203847C; -EWRAM_DATA u8 gUnknown_0203847D; -EWRAM_DATA u8 gUnknown_0203847E; +EWRAM_DATA u8 gUnknown_02038470[3] = {}; +EWRAM_DATA u8 gUnknown_02038473 = 0; +EWRAM_DATA u8 gUnknown_02038474 = 0; +EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478 = NULL; +EWRAM_DATA u8 gUnknown_0203847C = 0; +EWRAM_DATA u8 gUnknown_0203847D = 0; +EWRAM_DATA u8 gUnknown_0203847E = 0; +EWRAM_DATA u8 gUnknown_0203847F = 0; +EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; +EWRAM_DATA u8 gUnknown_020384E4 = 0; +EWRAM_DATA u8 gUnknown_020384E5 = 0; +EWRAM_DATA u8 gUnknown_020384E6 = 0; +EWRAM_DATA u8 gUnknown_020384E7 = 0; +EWRAM_DATA u8 gUnknown_020384E8 = 0; +EWRAM_DATA u8 gUnknown_020384E9 = 0; +EWRAM_DATA u16 gUnknown_020384EA = 0; +EWRAM_DATA u32 gUnknown_020384EC = 0; static u8 CountPokemonInBoxN(u8 boxId) { @@ -872,6 +888,73 @@ void sub_8096884(void) } } +void sub_80969A0(void) +{ + switch (gMain.state) + { + case 0: + SetVBlankCallback(NULL); + REG_DISPCNT = 0x0000; + ePokemonStorageSystem.unk_0005 = gUnknown_0203847D; + sub_8096804(); + if (gUnknown_0203847F == 1) + sub_809BBC0(); + if (gUnknown_0203847F == 0) + sub_809BD14(); + gMain.state++; + break; + case 1: + SetUpWindowConfig(&gWindowConfig_81E6D00); + gMain.state++; + break; + case 2: + InitMenuWindow(&gWindowConfig_81E6D00); + MenuZeroFillScreen(); + gMain.state++; + break; + case 3: + sub_80967DC(); + gMain.state++; + break; + case 4: + sub_8098B48(); + sub_809AA98(); + gMain.state++; + break; + case 5: + sub_8097DE0(); + gMain.state++; + break; + case 6: + sub_8097E70(); + gMain.state++; + break; + case 7: + sub_8098400(); + gMain.state++; + break; + case 8: + sub_8099BF8(gPokemonStorage.currentBox); + ePokemonStorageSystem.unk_12bc.baseTileTag = 0x000a; + ePokemonStorageSystem.unk_12bc.basePaletteTag = 0xdacb; + sub_80F727C(&ePokemonStorageSystem.unk_12bc); + sub_80F7404(); + gMain.state++; + break; + case 9: + BeginNormalPaletteFade(0xffffffff, 0, 16, 0, 0); + SetVBlankCallback(sub_8096AFC); + gMain.state++; + break; + case 10: + sub_8096874(); + sub_8096BE0(sub_8096C68); + SetMainCallback2(sub_8096B38); + gMain.state++; + break; + } +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From ceebbe19918520c65ed9bdcd79d4ae5fbb669d88 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jan 2018 22:03:21 -0500 Subject: through sub_8096BE0 --- src/pokemon/pokemon_storage_system.c | 74 +++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 2b36f5d71..f09d9b302 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -13,6 +13,8 @@ #include "event_data.h" #include "ewram.h" #include "script.h" +#include "pokemon_summary_screen.h" +#include "naming_screen.h" #include "pokemon_storage_system.h" struct StorageAction { @@ -31,15 +33,6 @@ struct UnkStruct_2000020 { u8 unk_05; }; -struct PokemonStorageSystemData { - u8 filler_0000[5]; - u8 unk_0005; - u8 filler_0006[26]; - struct UnkStruct_2000020 unk_0020[595]; // refine size later - u8 filler_12b8[4]; - struct PokemonMarkMenu unk_12bc; -}; - struct UnkPSSStruct_2002370 { struct Sprite *unk_0000; struct Sprite *unk_0004[4]; @@ -51,6 +44,27 @@ struct UnkPSSStruct_2002370 { u8 unk_023e; u16 unk_0240; u16 unk_0242; +}; // 0244 + +struct PokemonStorageSystemData { + void (*unk_0000)(void); + u8 unk_0004; + u8 unk_0005; + u8 unk_0006; + u16 unk_0008; + u16 unk_000a; + u8 filler_000c[20]; + struct UnkStruct_2000020 unk_0020[274]; // refine size later + u8 filler_08b0[4]; + u16 unk_08b4; + u8 filler_08b6[0xa06]; + struct PokemonMarkMenu unk_12bc; + struct UnkPSSStruct_2002370 unk_2370; + u8 filler_25b4[0xd8]; + u8 unk_268c; + u8 unk_268d; + u8 unk_268e; + struct Pokemon *unk_2690; }; void StorageSystemCreatePrimaryMenu(u8 whichMenu); @@ -69,8 +83,10 @@ void sub_8096BE0(void (*func)(void)); void sub_8096BF0(void); void sub_8096C68(void); void sub_8097DE0(void); +void sub_8097E44(void); void sub_8097E70(void); void sub_8098400(void); +void sub_8098734(void); void sub_8099BF8(u8 a0); void sub_8098B48(void); struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); @@ -80,6 +96,7 @@ void sub_809B0D4(void); void sub_809BBC0(void); void sub_809BD14(void); void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); +void sub_809CFF0(void); const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { {PCText_WithdrawPoke, PCText_MovePokeToParty}, @@ -955,6 +972,45 @@ void sub_80969A0(void) } } +void sub_8096AFC(void) +{ + REG_BG2HOFS = ePokemonStorageSystem.unk_08b4; + REG_BG3HOFS = ePokemonStorageSystem.unk_000a; + REG_BG3VOFS = ePokemonStorageSystem.unk_0008; + LoadOam(); + ProcessSpriteCopyRequests(); + sub_809CFF0(); + TransferPlttBuffer(); +} + +void sub_8096B38(void) +{ + ePokemonStorageSystem.unk_0000(); + sub_8097E44(); + sub_8098734(); + AnimateSprites(); + BuildOamBuffer(); +} + +void sub_8096B5C(void) +{ + switch (ePokemonStorageSystem.unk_0006) + { + case 0: + ShowPokemonSummaryScreen(ePokemonStorageSystem.unk_2690, ePokemonStorageSystem.unk_268d, ePokemonStorageSystem.unk_268c, sub_80969A0, ePokemonStorageSystem.unk_268e); + break; + case 1: + DoNamingScreen(1, gPokemonStorage.boxNames[gPokemonStorage.currentBox], 0, 0, 0, sub_80969A0); + break; + } +} + +void sub_8096BE0(void (*func)(void)) +{ + ePokemonStorageSystem.unk_0000 = func; + ePokemonStorageSystem.unk_0004 = 0; +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 02fea36a2e43523c9e9401897ac2fdbeb37ed3d4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jan 2018 22:25:16 -0500 Subject: through sub_8096C68 --- src/field/pc_screen_effect.c | 17 +++-------------- src/pokemon/pokemon_storage_system.c | 35 ++++++++++++++++++++++++++++++++++- src/scene/hall_of_fame.c | 4 ++-- 3 files changed, 39 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/field/pc_screen_effect.c b/src/field/pc_screen_effect.c index 364fca0aa..dda569ea4 100644 --- a/src/field/pc_screen_effect.c +++ b/src/field/pc_screen_effect.c @@ -2,18 +2,7 @@ #include "main.h" #include "palette.h" #include "sprite.h" - -struct UnkStruct -{ - /*0x00*/ u16 tileTag; - /*0x02*/ u16 paletteTag; - /*0x04*/ u16 unk04; - /*0x06*/ u16 unk06; - /*0x08*/ u16 unk08; - /*0x0A*/ u16 unk0A; - /*0x0C*/ s16 unk0C; - /*0x10*/ u32 selectedPalettes; -}; +#include "pc_screen_effect.h" void sub_80C603C(void); void sub_80C6078(void); @@ -30,7 +19,7 @@ extern const u16 gUnknownPal_083D18EC[16]; extern const u8 gUnknownGfx_083D190C[128]; -extern struct UnkStruct *gUnknown_020387EC; +extern struct PCScreenEffectStruct *gUnknown_020387EC; const struct SpriteSheet gUnknown_083D1898 = { gUnknownGfx_083D190C, sizeof(gUnknownGfx_083D190C), 0 }; @@ -58,7 +47,7 @@ const struct SpriteTemplate gSpriteTemplate_83D18C0 = sub_80C6130, }; -void sub_80C5CD4(struct UnkStruct *unkStruct) +void sub_80C5CD4(struct PCScreenEffectStruct *unkStruct) { u16 i; diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index f09d9b302..d6119476c 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -14,6 +14,7 @@ #include "ewram.h" #include "script.h" #include "pokemon_summary_screen.h" +#include "pc_screen_effect.h" #include "naming_screen.h" #include "pokemon_storage_system.h" @@ -53,7 +54,7 @@ struct PokemonStorageSystemData { u8 unk_0006; u16 unk_0008; u16 unk_000a; - u8 filler_000c[20]; + struct PCScreenEffectStruct unk_000c; struct UnkStruct_2000020 unk_0020[274]; // refine size later u8 filler_08b0[4]; u16 unk_08b4; @@ -82,6 +83,7 @@ void sub_8096B38(void); void sub_8096BE0(void (*func)(void)); void sub_8096BF0(void); void sub_8096C68(void); +void sub_8096C84(void); void sub_8097DE0(void); void sub_8097E44(void); void sub_8097E70(void); @@ -1011,6 +1013,37 @@ void sub_8096BE0(void (*func)(void)) ePokemonStorageSystem.unk_0004 = 0; } +void sub_8096BF0(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + BlendPalettes(0xffffffff, 16, 0); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + PlaySE(SE_PC_LOGON); + ePokemonStorageSystem.unk_000c.tileTag = 14; + ePokemonStorageSystem.unk_000c.paletteTag = 0xdad0; + ePokemonStorageSystem.unk_000c.unk04 = 0; + ePokemonStorageSystem.unk_000c.unk06 = 0; + sub_80C5CD4(&ePokemonStorageSystem.unk_000c); + BlendPalettes(0xffffffff, 0, 0); + ePokemonStorageSystem.unk_0004++; + break; + case 2: + if (sub_80C5DCC()) + sub_8096BE0(sub_8096C84); + break; + } +} + +void sub_8096C68(void) +{ + if (!UpdatePaletteFade()) + sub_8096BE0(sub_8096C84); +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { diff --git a/src/scene/hall_of_fame.c b/src/scene/hall_of_fame.c index 1751ee99c..812c28137 100644 --- a/src/scene/hall_of_fame.c +++ b/src/scene/hall_of_fame.c @@ -17,6 +17,7 @@ #include "decompress.h" #include "random.h" #include "trig.h" +#include "pc_screen_effect.h" #include "ewram.h" static EWRAM_DATA u32 sUnknown_0203931C = 0; @@ -89,7 +90,6 @@ static bool8 sub_81438C4(void); // functions from different files void sub_81439D0(void); -void sub_80C5CD4(void*); // ? void sub_80C5E38(void*); // ? bool8 sub_80C5DCC(void); bool8 sub_80C5F98(void); @@ -811,7 +811,7 @@ void sub_81428CC(void) fameMons = eHallOfFameMons1; fameMons->mons[0] = sDummyFameMon; - sub_80C5CD4(fameMons); + sub_80C5CD4((struct PCScreenEffectStruct *)fameMons); gMain.state++; } break; -- cgit v1.2.3 From fd42bcc78ce229d13afc26af4c6d2dd0187b871d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jan 2018 23:46:05 -0500 Subject: sub_8096C84 --- src/pokemon/pokemon_storage_system.c | 220 +++++++++++++++++++++++++++++++++-- 1 file changed, 209 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index d6119476c..b0a317cd9 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -5,6 +5,7 @@ #include "field_weather.h" #include "mon_markings.h" #include "overworld.h" +#include "mail_data.h" #include "field_fadetransition.h" #include "menu.h" #include "main.h" @@ -56,9 +57,14 @@ struct PokemonStorageSystemData { u16 unk_000a; struct PCScreenEffectStruct unk_000c; struct UnkStruct_2000020 unk_0020[274]; // refine size later - u8 filler_08b0[4]; + u8 filler_08b0[2]; + s16 unk_08b2; u16 unk_08b4; - u8 filler_08b6[0xa06]; + u8 filler_08b6[0x93c]; + u16 unk_11f2; + u8 filler_11f4[2]; + u8 unk_11f6; + u8 filler_11f7[0xc5]; struct PokemonMarkMenu unk_12bc; struct UnkPSSStruct_2002370 unk_2370; u8 filler_25b4[0xd8]; @@ -80,23 +86,48 @@ void task_intro_29(u8 whichMenu); void sub_8096884(void); void sub_8096AFC(void); void sub_8096B38(void); -void sub_8096BE0(void (*func)(void)); +void SetPSSCallback(void (*func)(void)); void sub_8096BF0(void); void sub_8096C68(void); void sub_8096C84(void); +void sub_8097004(void); +void sub_8097078(void); +void sub_80972A8(void); +void sub_80972FC(void); +void c3_0808DC50(void); +void sub_8097390(void); +void sub_809746C(void); +void sub_809789C(void); +void sub_8097BA0(void); +void sub_8097CC0(void); +void BoxSetMosaic(void); +void sub_80986E8(void); +void sub_8098710(void); +void sub_8098A5C(void); +void sub_809B440(void); +void sub_8096FC8(void); void sub_8097DE0(void); void sub_8097E44(void); void sub_8097E70(void); void sub_8098400(void); void sub_8098734(void); -void sub_8099BF8(u8 a0); +void sub_8098898(u8 index); void sub_8098B48(void); +void sub_8099BF8(u8 a0); +void sub_8099C70(u8 whichBox); +bool8 sub_8099D34(void); struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); void sub_809AA24(void); void sub_809AA98(void); +bool8 sub_809AC00(void); void sub_809B0D4(void); void sub_809BBC0(void); void sub_809BD14(void); +bool8 sub_809BE80(void); +bool8 sub_809BEBC(void); +bool8 sub_809BF20(void); +bool8 sub_809BF48(void); +u8 sub_809CA40(void); void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); void sub_809CFF0(void); @@ -150,7 +181,7 @@ const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/b const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); extern const struct StorageAction gUnknown_083B6DF4[]; -extern const struct PokemonStorageSystemData *gUnknown_083B6DB4; +extern const struct PokemonStorageSystemData *gPokemonStorageSystemPtr; extern u8 *const gUnknown_083B6DB8; EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; @@ -571,7 +602,7 @@ void StorageSystemCreatePrimaryMenu(u8 whichMenu) void sub_80961A8(void) { - gUnknown_02038474 = gUnknown_083B6DB4->unk_0005; + gUnknown_02038474 = gPokemonStorageSystemPtr->unk_0005; gFieldCallback = sub_8096130; SetMainCallback2(c2_exit_to_overworld_2_switch); } @@ -899,7 +930,7 @@ void sub_8096884(void) break; case 9: sub_8096874(); - sub_8096BE0(sub_8096BF0); + SetPSSCallback(sub_8096BF0); SetMainCallback2(sub_8096B38); SetVBlankCallback(sub_8096AFC); gMain.state++; @@ -967,7 +998,7 @@ void sub_80969A0(void) break; case 10: sub_8096874(); - sub_8096BE0(sub_8096C68); + SetPSSCallback(sub_8096C68); SetMainCallback2(sub_8096B38); gMain.state++; break; @@ -1007,7 +1038,7 @@ void sub_8096B5C(void) } } -void sub_8096BE0(void (*func)(void)) +void SetPSSCallback(void (*func)(void)) { ePokemonStorageSystem.unk_0000 = func; ePokemonStorageSystem.unk_0004 = 0; @@ -1033,7 +1064,7 @@ void sub_8096BF0(void) break; case 2: if (sub_80C5DCC()) - sub_8096BE0(sub_8096C84); + SetPSSCallback(sub_8096C84); break; } } @@ -1041,7 +1072,174 @@ void sub_8096BF0(void) void sub_8096C68(void) { if (!UpdatePaletteFade()) - sub_8096BE0(sub_8096C84); + SetPSSCallback(sub_8096C84); +} + +void sub_8096C84(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + switch (sub_809CA40()) + { + case 1: + PlaySE(SE_SELECT); + ePokemonStorageSystem.unk_0004 = 1; + break; + case 5: + if (ePokemonStorageSystem.unk_0005 != 2) + { + sub_8098898(16); + ePokemonStorageSystem.unk_0004 = 3; + } + else + { + sub_809B0D4(); + SetPSSCallback(sub_8096FC8); + } + break; + case 6: + if (ePokemonStorageSystem.unk_0005 == 2) + { + if (sub_809BF20() && ItemIsMail(ePokemonStorageSystem.unk_11f2)) + { + ePokemonStorageSystem.unk_0004 = 5; + } + else + { + SetPSSCallback(sub_8097004); + } + } + break; + case 4: + SetPSSCallback(sub_8097BA0); + break; + case 16: + SetPSSCallback(sub_8097CC0); + break; + case 7: + PlaySE(SE_SELECT); + SetPSSCallback(sub_809789C); + break; + case 8: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097078); + break; + case 9: + PlaySE(SE_SELECT); + ePokemonStorageSystem.unk_08b2 = gPokemonStorage.currentBox + 1; + if (ePokemonStorageSystem.unk_08b2 > 13) + ePokemonStorageSystem.unk_08b2 = 0; + sub_8099C70(ePokemonStorageSystem.unk_08b2); + ePokemonStorageSystem.unk_0004 = 2; + break; + case 10: + PlaySE(SE_SELECT); + ePokemonStorageSystem.unk_08b2 = gPokemonStorage.currentBox - 1; + if (ePokemonStorageSystem.unk_08b2 < 0) + ePokemonStorageSystem.unk_08b2 = 13; + sub_8099C70(ePokemonStorageSystem.unk_08b2); + ePokemonStorageSystem.unk_0004 = 2; + break; + case 11: + if (!sub_809BE80()) + { + if (ItemIsMail(ePokemonStorageSystem.unk_11f2)) + { + ePokemonStorageSystem.unk_0004 = 5; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_809746C); + } + } + else + { + ePokemonStorageSystem.unk_0004 = 4; + } + break; + case 13: + if (sub_809BE80()) + { + ePokemonStorageSystem.unk_0004 = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_80972A8); + } + break; + case 14: + if (!sub_809BEBC()) + { + ePokemonStorageSystem.unk_0004 = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(c3_0808DC50); + } + break; + case 12: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097390); + break; + case 15: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80972FC); + break; + } + break; + case 1: + if (!sub_809AC00()) + { + if (sub_809BF48()) + sub_80986E8(); + else + sub_8098710(); + if (ePokemonStorageSystem.unk_11f6) + BoxSetMosaic(); + ePokemonStorageSystem.unk_0004 = 0; + } + break; + case 2: + if (!sub_8099D34()) + { + gPokemonStorage.currentBox = ePokemonStorageSystem.unk_08b2; + if (!gUnknown_0203847C && !sub_809BF20()) + { + sub_809B440(); + BoxSetMosaic(); + } + ePokemonStorageSystem.unk_0004 = 0; + } + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + ePokemonStorageSystem.unk_0004 = 0; + } + break; + case 4: + PlaySE(SE_HAZURE); + sub_8098898(13); + ePokemonStorageSystem.unk_0004 = 6; + break; + case 5: + PlaySE(SE_HAZURE); + sub_8098898(22); + ePokemonStorageSystem.unk_0004 = 6; + break; + case 6: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + } } asm(".section .text.8098898"); -- cgit v1.2.3 From 56c2c7ef00396c53a8bc859141b46fa488bb42fa Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 13:39:22 -0700 Subject: through sub_8097078 --- src/pokemon/pokemon_storage_system.c | 190 +++++++++++++++++++++++++++++++++-- 1 file changed, 183 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index b0a317cd9..feed68e50 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -64,7 +64,9 @@ struct PokemonStorageSystemData { u16 unk_11f2; u8 filler_11f4[2]; u8 unk_11f6; - u8 filler_11f7[0xc5]; + u8 filler_11f7[2]; + u8 unk_11f9; + u8 filler_11fa[0xc2]; struct PokemonMarkMenu unk_12bc; struct UnkPSSStruct_2002370 unk_2370; u8 filler_25b4[0xd8]; @@ -90,6 +92,7 @@ void SetPSSCallback(void (*func)(void)); void sub_8096BF0(void); void sub_8096C68(void); void sub_8096C84(void); +void sub_8096FC8(void); void sub_8097004(void); void sub_8097078(void); void sub_80972A8(void); @@ -97,21 +100,26 @@ void sub_80972FC(void); void c3_0808DC50(void); void sub_8097390(void); void sub_809746C(void); +void sub_8097594(void); +void sub_8097788(void); +void sub_80977E4(void); void sub_809789C(void); void sub_8097BA0(void); void sub_8097CC0(void); -void BoxSetMosaic(void); -void sub_80986E8(void); -void sub_8098710(void); -void sub_8098A5C(void); -void sub_809B440(void); -void sub_8096FC8(void); void sub_8097DE0(void); void sub_8097E44(void); void sub_8097E70(void); +void BoxSetMosaic(void); void sub_8098400(void); +void add_to_c3_somehow(void); +bool8 sub_80985CC(void); +void sub_80986E8(void); +void sub_8098710(void); void sub_8098734(void); +void sub_809880C(void); +bool8 sub_8098830(void); void sub_8098898(u8 index); +void sub_8098A5C(void); void sub_8098B48(void); void sub_8099BF8(u8 a0); void sub_8099C70(u8 whichBox); @@ -120,7 +128,10 @@ struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); void sub_809AA24(void); void sub_809AA98(void); bool8 sub_809AC00(void); +void sub_809B0C0(u8 a0); void sub_809B0D4(void); +u8 sub_809B0F4(void); +void sub_809B440(void); void sub_809BBC0(void); void sub_809BD14(void); bool8 sub_809BE80(void); @@ -128,6 +139,8 @@ bool8 sub_809BEBC(void); bool8 sub_809BF20(void); bool8 sub_809BF48(void); u8 sub_809CA40(void); +void sub_809CE84(void); +s16 sub_809CF30(void); void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); void sub_809CFF0(void); @@ -1242,6 +1255,169 @@ void sub_8096C84(void) } } +void sub_8096FC8(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_809880C(); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!sub_8098830()) + SetPSSCallback(sub_8096C84); + break; + } +} + +void sub_8097004(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + PlaySE(SE_SELECT); + add_to_c3_somehow(); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!sub_80985CC()) + { + sub_809B0C0(sub_809B0F4()); + ePokemonStorageSystem.unk_0004++; + } + break; + case 2: + if (!sub_809AC00()) + { + if (ePokemonStorageSystem.unk_11f6) + BoxSetMosaic(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097078(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_8098898(4); + sub_809CE84(); + ePokemonStorageSystem.unk_0004 = 1; + break; + case 1: + switch (sub_809CF30()) + { + case -1: + case 0: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 3: + if (sub_809BE80()) + { + ePokemonStorageSystem.unk_0004 = 2; + } + else + { + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_80972A8); + } + break; + case 5: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_80972FC); + break; + case 4: + if (!sub_809BEBC()) + { + ePokemonStorageSystem.unk_0004 = 2; + } + else + { + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(c3_0808DC50); + } + break; + case 2: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_8097390); + break; + case 1: + if (sub_809BE80()) + { + ePokemonStorageSystem.unk_0004 = 2; + } + else if (ItemIsMail(ePokemonStorageSystem.unk_11f2)) + { + ePokemonStorageSystem.unk_0004 = 3; + } + else + { + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_809746C); + } + break; + case 7: + if (sub_809BE80()) + { + ePokemonStorageSystem.unk_0004 = 2; + } + else if (ePokemonStorageSystem.unk_11f9) + { + ePokemonStorageSystem.unk_0004 = 4; + } + else if (ItemIsMail(ePokemonStorageSystem.unk_11f2)) + { + ePokemonStorageSystem.unk_0004 = 3; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097594); + } + break; + case 6: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097788); + break; + case 8: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80977E4); + break; + } + break; + case 2: + PlaySE(SE_HAZURE); + sub_8098898(13); + ePokemonStorageSystem.unk_0004 = 5; + break; + case 4: + PlaySE(SE_HAZURE); + sub_8098898(17); + ePokemonStorageSystem.unk_0004 = 5; + break; + case 3: + PlaySE(SE_HAZURE); + sub_8098898(22); + ePokemonStorageSystem.unk_0004 = 5; + break; + case 5: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 673d64c35b21ebb8f3c6fc8b547c7f736fa4f593 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 13:53:24 -0700 Subject: through sub_8097390 --- src/pokemon/pokemon_storage_system.c | 114 +++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index feed68e50..6f51b823e 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -103,6 +103,7 @@ void sub_809746C(void); void sub_8097594(void); void sub_8097788(void); void sub_80977E4(void); +void sub_8097858(void); void sub_809789C(void); void sub_8097BA0(void); void sub_8097CC0(void); @@ -116,10 +117,13 @@ bool8 sub_80985CC(void); void sub_80986E8(void); void sub_8098710(void); void sub_8098734(void); +void sub_80987DC(void); void sub_809880C(void); bool8 sub_8098830(void); void sub_8098898(u8 index); void sub_8098A5C(void); +void sub_809B100(u8 a0); +bool8 sub_809B130(void); void sub_8098B48(void); void sub_8099BF8(u8 a0); void sub_8099C70(u8 whichBox); @@ -130,6 +134,7 @@ void sub_809AA98(void); bool8 sub_809AC00(void); void sub_809B0C0(u8 a0); void sub_809B0D4(void); +void sub_809B0E0(void); u8 sub_809B0F4(void); void sub_809B440(void); void sub_809BBC0(void); @@ -1418,6 +1423,115 @@ void sub_8097078(void) } } +void sub_80972A8(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_809B100(0); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!sub_809B130()) + { + if (gUnknown_0203847C) + SetPSSCallback(sub_8097858); + else + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_80972FC(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_809B100(1); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!sub_809B130()) + { + if (gUnknown_0203847C) + SetPSSCallback(sub_8097858); + else + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void c3_0808DC50(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_809B100(2); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!sub_809B130()) + { + BoxSetMosaic(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097390(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + if (CalculatePlayerPartyCount() == 6) + { + sub_8098898(14); + ePokemonStorageSystem.unk_0004 = 1; + } + else + { + sub_809B0E0(); + sub_809B100(0); + ePokemonStorageSystem.unk_0004 = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + case 2: + if (!sub_809B130()) + { + sub_809880C(); + ePokemonStorageSystem.unk_0004++; + } + break; + case 3: + if (!sub_8098830()) + { + sub_809B100(1); + ePokemonStorageSystem.unk_0004++; + } + break; + case 4: + if (!sub_809B130()) + { + sub_80987DC(); + ePokemonStorageSystem.unk_0004++; + } + break; + case 5: + SetPSSCallback(sub_8097004); + break; + } +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { -- cgit v1.2.3 From 78df16e7989be5142ed0d1fd01c4ece6483f0571 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 14:57:26 -0700 Subject: Through sub_809746C; enums for PC storage actions --- src/pokemon/pokemon_storage_system.c | 182 +++++++++++++++++++++++++++-------- 1 file changed, 144 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 6f51b823e..916dc411a 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -19,6 +19,42 @@ #include "naming_screen.h" #include "pokemon_storage_system.h" +enum { + PC_TEXT_EXIT_BOX, + PC_TEXT_WHAT_YOU_DO, + PC_TEXT_PICK_A_THEME, + PC_TEXT_PICK_A_WALLPAPER, + PC_TEXT_IS_SELECTED, + PC_TEXT_JUMP_TO_WHICH_BOX, + PC_TEXT_DEPOSIT_IN_WHICH_BOX, + PC_TEXT_WAS_DEPOSITED, + PC_TEXT_BOX_IS_FULL, + PC_TEXT_RELEASE_POKE, + PC_TEXT_WAS_RELEASED, + PC_TEXT_BYE_BYE, + PC_TEXT_MARK_POKE, + PC_TEXT_LAST_POKE, + PC_TEXT_PARTY_FULL, + PC_TEXT_HOLDING_POKE, + PC_TEXT_WHICH_ONE_WILL_TAKE, + PC_TEXT_CANT_RELEASE_EGG, + PC_TEXT_CONTINUE_BOX, + PC_TEXT_CAME_BACK, + PC_TEXT_WORRIED, + PC_TEXT_SURPRISE, + PC_TEXT_PLEASE_REMOVE_MAIL +}; + +enum { + PC_TEXT_FMT_NORMAL, + PC_TEXT_FMT_MON_NAME, + PC_TEXT_FMT_UNK_02, + PC_TEXT_FMT_UNK_03, + PC_TEXT_FMT_MON_NAME_2, + PC_TEXT_FMT_UNK_05, + PC_TEXT_FMT_MON_NAME_AFTER_EXCL_MARK +}; + struct StorageAction { u8 *text; u8 format; @@ -66,7 +102,7 @@ struct PokemonStorageSystemData { u8 unk_11f6; u8 filler_11f7[2]; u8 unk_11f9; - u8 filler_11fa[0xc2]; + u8 unk_11fa[0xc2]; struct PokemonMarkMenu unk_12bc; struct UnkPSSStruct_2002370 unk_2370; u8 filler_25b4[0xd8]; @@ -74,6 +110,9 @@ struct PokemonStorageSystemData { u8 unk_268d; u8 unk_268e; struct Pokemon *unk_2690; + u8 unk_2694[18]; + u8 unk_26a6[62]; + u8 unk_26e4[80]; }; void StorageSystemCreatePrimaryMenu(u8 whichMenu); @@ -120,11 +159,13 @@ void sub_8098734(void); void sub_80987DC(void); void sub_809880C(void); bool8 sub_8098830(void); -void sub_8098898(u8 index); +void PrintStorageActionText(u8 index); void sub_8098A5C(void); void sub_809B100(u8 a0); bool8 sub_809B130(void); void sub_8098B48(void); +void sub_8099310(void); +bool8 sub_8099374(void); void sub_8099BF8(u8 a0); void sub_8099C70(u8 whichBox); bool8 sub_8099D34(void); @@ -137,6 +178,8 @@ void sub_809B0D4(void); void sub_809B0E0(void); u8 sub_809B0F4(void); void sub_809B440(void); +bool8 sub_809B62C(u8); +void sub_809B6BC(void); void sub_809BBC0(void); void sub_809BD14(void); bool8 sub_809BE80(void); @@ -198,7 +241,7 @@ const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/b const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); -extern const struct StorageAction gUnknown_083B6DF4[]; +extern const struct StorageAction gPCStorageActionTexts[]; extern const struct PokemonStorageSystemData *gPokemonStorageSystemPtr; extern u8 *const gUnknown_083B6DB8; @@ -1107,7 +1150,7 @@ void sub_8096C84(void) case 5: if (ePokemonStorageSystem.unk_0005 != 2) { - sub_8098898(16); + PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); ePokemonStorageSystem.unk_0004 = 3; } else @@ -1242,12 +1285,12 @@ void sub_8096C84(void) break; case 4: PlaySE(SE_HAZURE); - sub_8098898(13); + PrintStorageActionText(PC_TEXT_LAST_POKE); ePokemonStorageSystem.unk_0004 = 6; break; case 5: PlaySE(SE_HAZURE); - sub_8098898(22); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); ePokemonStorageSystem.unk_0004 = 6; break; case 6: @@ -1307,7 +1350,7 @@ void sub_8097078(void) switch (ePokemonStorageSystem.unk_0004) { case 0: - sub_8098898(4); + PrintStorageActionText(PC_TEXT_IS_SELECTED); sub_809CE84(); ePokemonStorageSystem.unk_0004 = 1; break; @@ -1400,17 +1443,17 @@ void sub_8097078(void) break; case 2: PlaySE(SE_HAZURE); - sub_8098898(13); + PrintStorageActionText(PC_TEXT_LAST_POKE); ePokemonStorageSystem.unk_0004 = 5; break; case 4: PlaySE(SE_HAZURE); - sub_8098898(17); + PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG); ePokemonStorageSystem.unk_0004 = 5; break; case 3: PlaySE(SE_HAZURE); - sub_8098898(22); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); ePokemonStorageSystem.unk_0004 = 5; break; case 5: @@ -1488,7 +1531,7 @@ void sub_8097390(void) case 0: if (CalculatePlayerPartyCount() == 6) { - sub_8098898(14); + PrintStorageActionText(PC_TEXT_PARTY_FULL); ePokemonStorageSystem.unk_0004 = 1; } else @@ -1532,83 +1575,146 @@ void sub_8097390(void) } } +void sub_809746C(void) +{ + u8 r4; + + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + sub_8096264(&ePokemonStorageSystem.unk_2370, 0x0007, 0xdaca, 3); + sub_809634C(gUnknown_0203847E); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + r4 = sub_8096368(); + if (r4 == 200); + else if (r4 == 201) + { + sub_8098A5C(); + sub_809635C(); + sub_8096310(); + SetPSSCallback(sub_8096C84); + } + else + { + if (sub_809B62C(r4)) + { + sub_8098A5C(); + sub_809635C(); + sub_8096310(); + ePokemonStorageSystem.unk_0004 = 2; + } + else + { + PrintStorageActionText(PC_TEXT_BOX_IS_FULL); + ePokemonStorageSystem.unk_0004 = 4; + } + gUnknown_0203847E = r4; + } + break; + case 2: + party_compaction(); + sub_8099310(); + ePokemonStorageSystem.unk_0004++; + break; + case 3: + if (!sub_8099374()) + { + sub_809B6BC(); + BoxSetMosaic(); + sub_80987DC(); + SetPSSCallback(sub_8096C84); + } + break; + case 4: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + ePokemonStorageSystem.unk_0004 = 1; + } + break; + } +} + asm(".section .text.8098898"); -void sub_8098898(u8 index) { +void PrintStorageActionText(u8 index) { u8 *ptr; MenuDrawTextWindow(10, 16, 29, 19); - switch (gUnknown_083B6DF4[index].format) + switch (gPCStorageActionTexts[index].format) { - case 2: - ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); - ptr = StringCopy(ptr, gUnk20011fa); + case PC_TEXT_FMT_UNK_02: + ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr, ePokemonStorageSystem.unk_11fa); break; - case 5: - ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); - ptr = StringCopy(ptr, gUnk20026e4); + case PC_TEXT_FMT_UNK_05: + ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr, ePokemonStorageSystem.unk_26e4); break; - case 1: + case PC_TEXT_FMT_MON_NAME: // {var} + " is selected." - ptr = StringCopy(gUnk2002694, gUnk20011fa); - ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ePokemonStorageSystem.unk_2694, ePokemonStorageSystem.unk_11fa); + ptr = StringCopy(ptr, gPCStorageActionTexts[index].text); break; - case 4: + case PC_TEXT_FMT_MON_NAME_2: // {var} + " was released." - ptr = StringCopy(gUnk2002694, gUnk20026e4); + ptr = StringCopy(ePokemonStorageSystem.unk_2694, ePokemonStorageSystem.unk_26e4); #if ENGLISH - ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr, gPCStorageActionTexts[index].text); #elif GERMAN - ptr = de_sub_8073174(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = de_sub_8073174(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); #endif break; - case 3: + case PC_TEXT_FMT_UNK_03: { u8 *stringLength; u8 *text; - text = gUnknown_083B6DF4[index].text; + text = gPCStorageActionTexts[index].text; stringLength = &text[StringLength(text)] + 1; - ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); - ptr = StringCopy(ptr, gUnk20011fa); + ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr, ePokemonStorageSystem.unk_11fa); ptr = StringCopy(ptr, stringLength); } break; - case 6: + case PC_TEXT_FMT_MON_NAME_AFTER_EXCL_MARK: // "Bye-bye, ".substr(0, -1) + {var} + "Bye-bye, !".substr(-1, 1) { u8 *stringLength; u8 *text; - text = gUnknown_083B6DF4[index].text; + text = gPCStorageActionTexts[index].text; stringLength = &text[StringLength(text)] - 1; - ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); - ptr = StringCopy(ptr - 1, gUnk20026e4); + ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr - 1, ePokemonStorageSystem.unk_26e4); ptr = StringCopy(ptr, stringLength); } break; - case 0: + case PC_TEXT_FMT_NORMAL: default: - ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); break; } - while (ptr < gUnk20026A6) + while (ptr < ePokemonStorageSystem.unk_26a6) { ptr[0] = CHAR_SPACE; ptr++; } ptr[0] = EOS; - MenuPrint(gUnk2002694, 11, 17); + MenuPrint(ePokemonStorageSystem.unk_2694, 11, 17); } -- cgit v1.2.3 From 882bf5c3cf945927b3049eb8675bf1964d8706e8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 15:22:37 -0700 Subject: sub_8097594 --- src/pokemon/pokemon_storage_system.c | 144 ++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 916dc411a..9e18dadb5 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -158,14 +158,16 @@ void sub_8098710(void); void sub_8098734(void); void sub_80987DC(void); void sub_809880C(void); +void sub_809801C(void); bool8 sub_8098830(void); void PrintStorageActionText(u8 index); +void sub_8098A38(u8); void sub_8098A5C(void); -void sub_809B100(u8 a0); -bool8 sub_809B130(void); void sub_8098B48(void); void sub_8099310(void); bool8 sub_8099374(void); +void sub_8099958(void); +bool8 sub_8099990(void); void sub_8099BF8(u8 a0); void sub_8099C70(u8 whichBox); bool8 sub_8099D34(void); @@ -177,9 +179,17 @@ void sub_809B0C0(u8 a0); void sub_809B0D4(void); void sub_809B0E0(void); u8 sub_809B0F4(void); +void sub_809B100(u8 a0); +bool8 sub_809B130(void); void sub_809B440(void); bool8 sub_809B62C(u8); void sub_809B6BC(void); +void sub_809B6DC(void); +bool8 sub_809B734(void); +void sub_809B760(void); +void sub_809B7AC(void); +void sub_809B7D4(void); +s8 sub_809B960(void); void sub_809BBC0(void); void sub_809BD14(void); bool8 sub_809BE80(void); @@ -1638,6 +1648,136 @@ void sub_809746C(void) } } +void sub_8097594(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_RELEASE_POKE); + sub_8098A38(1); + ePokemonStorageSystem.unk_0004++; + // fallthrough + case 1: + switch (ProcessMenuInputNoWrap()) + { + case -1: + case 1: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 0: + sub_8098A5C(); + sub_809B7D4(); + sub_809B6DC(); + ePokemonStorageSystem.unk_0004++; + break; + } + break; + case 2: + sub_809B960(); + if (!sub_809B734()) + { + while (1) + { + s8 r0 = sub_809B960(); + if (r0 == 1) + { + ePokemonStorageSystem.unk_0004++; + break; + } + if (r0 == 0) + { + ePokemonStorageSystem.unk_0004 = 8; + break; + } + } + } + break; + case 3: + sub_809B760(); + sub_809801C(); + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + ePokemonStorageSystem.unk_0004++; + break; + case 4: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_BYE_BYE); + ePokemonStorageSystem.unk_0004++; + } + break; + case 5: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8098A5C(); + if (gUnknown_0203847C) + { + party_compaction(); + sub_8099310(); + ePokemonStorageSystem.unk_0004++; + } + else + { + ePokemonStorageSystem.unk_0004 = 7; + } + } + break; + case 6: + if (!sub_8099374()) + { + sub_809B440(); + BoxSetMosaic(); + sub_80987DC(); + ePokemonStorageSystem.unk_0004++; + } + break; + case 7: + SetPSSCallback(sub_8096C84); + break; + case 8: + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + ePokemonStorageSystem.unk_0004++; + break; + case 9: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_SURPRISE); + ePokemonStorageSystem.unk_0004++; + } + break; + case 10: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8098A5C(); + sub_8099958(); + ePokemonStorageSystem.unk_0004++; + } + break; + case 11: + if (!sub_8099990()) + { + sub_809B7AC(); + PrintStorageActionText(PC_TEXT_CAME_BACK); + ePokemonStorageSystem.unk_0004++; + } + break; + case 12: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_WORRIED); + ePokemonStorageSystem.unk_0004++; + } + break; + case 13: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + asm(".section .text.8098898"); void PrintStorageActionText(u8 index) { -- cgit v1.2.3 From 660fa0c0f38a684eda6c117958447deacac88820 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 15:37:05 -0700 Subject: through sub_8097858 --- src/pokemon/pokemon_storage_system.c | 67 +++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 9e18dadb5..8b0893c73 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -100,7 +100,8 @@ struct PokemonStorageSystemData { u16 unk_11f2; u8 filler_11f4[2]; u8 unk_11f6; - u8 filler_11f7[2]; + u8 unk_11f7; + u8 unk_11f8; u8 unk_11f9; u8 unk_11fa[0xc2]; struct PokemonMarkMenu unk_12bc; @@ -191,7 +192,9 @@ void sub_809B7AC(void); void sub_809B7D4(void); s8 sub_809B960(void); void sub_809BBC0(void); +void sub_809BC18(void); void sub_809BD14(void); +void sub_809BDD8(u8 markings); bool8 sub_809BE80(void); bool8 sub_809BEBC(void); bool8 sub_809BF20(void); @@ -1778,6 +1781,68 @@ void sub_8097594(void) } } +void sub_8097788(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_809BC18(); + BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!UpdatePaletteFade()) + { + gUnknown_0203847F = 0; + ePokemonStorageSystem.unk_0006 = 0; + SetMainCallback2(sub_8096B5C); + } + break; + } +} + +void sub_80977E4(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_MARK_POKE); + ePokemonStorageSystem.unk_12bc.markings = ePokemonStorageSystem.unk_11f7; + sub_80F7418(ePokemonStorageSystem.unk_11f7, 0xb0, 0x10); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!sub_80F7500()) + { + sub_80F7470(); + sub_8098A5C(); + sub_809BDD8(ePokemonStorageSystem.unk_12bc.markings); + sub_809801C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097858(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + party_compaction(); + sub_8099310(); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!sub_8099374()) + { + sub_80987DC(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + asm(".section .text.8098898"); void PrintStorageActionText(u8 index) { -- cgit v1.2.3 From 2fe1da46d9dda22fbe2184a53f71d5e2b8f03aba Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 21:33:51 -0500 Subject: through sub_8097974 --- src/pokemon/pokemon_storage_system.c | 108 ++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 8b0893c73..0f2350df2 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -96,7 +96,10 @@ struct PokemonStorageSystemData { u8 filler_08b0[2]; s16 unk_08b2; u16 unk_08b4; - u8 filler_08b6[0x93c]; + u8 filler_08b6[0x4a8]; + s16 unk_0d5e; + s16 unk_0d60; + u8 filler_0d62[0x490]; u16 unk_11f2; u8 filler_11f4[2]; u8 unk_11f6; @@ -145,12 +148,16 @@ void sub_8097788(void); void sub_80977E4(void); void sub_8097858(void); void sub_809789C(void); +void sub_8097974(void); +void sub_8097A64(void); +void sub_8097B44(void); void sub_8097BA0(void); void sub_8097CC0(void); void sub_8097DE0(void); void sub_8097E44(void); void sub_8097E70(void); void BoxSetMosaic(void); +void sub_809801C(void); void sub_8098400(void); void add_to_c3_somehow(void); bool8 sub_80985CC(void); @@ -159,11 +166,12 @@ void sub_8098710(void); void sub_8098734(void); void sub_80987DC(void); void sub_809880C(void); -void sub_809801C(void); bool8 sub_8098830(void); void PrintStorageActionText(u8 index); void sub_8098A38(u8); void sub_8098A5C(void); +void sub_8098A80(void); +void sub_8098AA8(u8 a0); void sub_8098B48(void); void sub_8099310(void); bool8 sub_8099374(void); @@ -172,6 +180,9 @@ bool8 sub_8099990(void); void sub_8099BF8(u8 a0); void sub_8099C70(u8 whichBox); bool8 sub_8099D34(void); +void sub_8099DCC(u8 a0); +bool8 sub_8099E08(void); +void sub_809A860(u8 a0); struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); void sub_809AA24(void); void sub_809AA98(void); @@ -1843,6 +1854,99 @@ void sub_8097858(void) } } +void sub_809789C(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); + sub_809CE84(); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + switch (sub_809CF30()) + { + case -1: + case 0: + sub_809A860(1); + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 11: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097B44); + break; + case 10: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_8097974); + break; + case 9: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_8097A64); + break; + } + break; + } +} + +void sub_8097974(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_8098A80(); + PrintStorageActionText(PC_TEXT_PICK_A_THEME); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + ePokemonStorageSystem.unk_0d5e = sub_809CF30(); + switch (ePokemonStorageSystem.unk_0d5e) + { + case -1: + sub_809A860(1); + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 12 ... 15: + PlaySE(SE_SELECT); + ePokemonStorageSystem.unk_0d5e -= 12; + sub_8098AA8(ePokemonStorageSystem.unk_0d5e); + PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); + ePokemonStorageSystem.unk_0004++; + break; + } + break; + case 2: + ePokemonStorageSystem.unk_0d60 = sub_809CF30(); + switch (ePokemonStorageSystem.unk_0d60) + { + case -1: + sub_8098A5C(); + ePokemonStorageSystem.unk_0004 = 0; + break; + case -2: + break; + default: + PlaySE(SE_SELECT); + sub_8098A5C(); + ePokemonStorageSystem.unk_0d60 -= 16; + sub_8099DCC(ePokemonStorageSystem.unk_0d60); + ePokemonStorageSystem.unk_0004++; + break; + } + break; + case 3: + if (!sub_8099E08()) + { + sub_809A860(1); + SetPSSCallback(sub_8096C84); + } + break; + } +} + asm(".section .text.8098898"); void PrintStorageActionText(u8 index) { -- cgit v1.2.3 From e2ff8b73c7e17777be8c4065a93e8727768bb914 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 22:05:43 -0500 Subject: through sub_8097BA0; fix calls to pc_screen_effect from scene/hall_of_fame --- src/pokemon/pokemon_storage_system.c | 130 ++++++++++++++++++++++++++++++++++- src/scene/hall_of_fame.c | 35 ++++------ 2 files changed, 140 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 0f2350df2..daae82df6 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -177,6 +177,7 @@ void sub_8099310(void); bool8 sub_8099374(void); void sub_8099958(void); bool8 sub_8099990(void); +void sub_809BB90(void); void sub_8099BF8(u8 a0); void sub_8099C70(u8 whichBox); bool8 sub_8099D34(void); @@ -670,7 +671,7 @@ void ShowPokemonStorageSystem(void) ScriptContext2_Enable(); } -void sub_8096130(void) +void FieldCB_ReturnToOverworld(void) { u8 taskId = CreateTask(Task_PokemonStorageSystem, 80); gTasks[taskId].data[0] = 0; @@ -688,7 +689,7 @@ void StorageSystemCreatePrimaryMenu(u8 whichMenu) void sub_80961A8(void) { gUnknown_02038474 = gPokemonStorageSystemPtr->unk_0005; - gFieldCallback = sub_8096130; + gFieldCallback = FieldCB_ReturnToOverworld; SetMainCallback2(c2_exit_to_overworld_2_switch); } @@ -1947,6 +1948,131 @@ void sub_8097974(void) } } +void sub_8097A64(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); + sub_8096264(&ePokemonStorageSystem.unk_2370, 0x0007, 0xdaca, 3); + sub_809634C(gPokemonStorage.currentBox); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + ePokemonStorageSystem.unk_08b2 = sub_8096368(); + switch (ePokemonStorageSystem.unk_08b2) + { + case 200: + break; + default: + sub_8098A5C(); + sub_809635C(); + sub_8096310(); + if (ePokemonStorageSystem.unk_08b2 == 201 || ePokemonStorageSystem.unk_08b2 == gPokemonStorage.currentBox) + { + sub_809A860(1); + SetPSSCallback(sub_8096C84); + } + else + { + ePokemonStorageSystem.unk_0004++; + } + break; + } + break; + case 2: + sub_8099C70(ePokemonStorageSystem.unk_08b2); + ePokemonStorageSystem.unk_0004++; + break; + case 3: + if (!sub_8099D34()) + { + gPokemonStorage.currentBox = ePokemonStorageSystem.unk_08b2; + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097B44(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + sub_809BB90(); + BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0); + ePokemonStorageSystem.unk_0004++; + break; + case 1: + if (!UpdatePaletteFade()) + { + gUnknown_0203847F = 1; + ePokemonStorageSystem.unk_0006 = 1; + SetMainCallback2(sub_8096B5C); + } + break; + } +} + +void sub_8097BA0(void) +{ + switch (ePokemonStorageSystem.unk_0004) + { + case 0: + if (sub_809BF20()) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + ePokemonStorageSystem.unk_0004 = 1; + } + else + { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_EXIT_BOX); + sub_8098A38(0); + ePokemonStorageSystem.unk_0004 = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + case 2: + switch (ProcessMenuInputNoWrap()) + { + case 1: + case -1: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 0: + PlaySE(SE_PC_OFF); + sub_8098A5C(); + ePokemonStorageSystem.unk_0004++; + break; + } + break; + case 3: + ePokemonStorageSystem.unk_000c.tileTag = 0x000e; + ePokemonStorageSystem.unk_000c.paletteTag = 0xdad0; + ePokemonStorageSystem.unk_000c.unk04 = 20; + ePokemonStorageSystem.unk_000c.unk06 = 0; + sub_80C5E38(&ePokemonStorageSystem.unk_000c); + ePokemonStorageSystem.unk_0004++; + break; + case 4: + if (sub_80C5F98()) + { + gPlayerPartyCount = CalculatePlayerPartyCount(); + SetMainCallback2(sub_80961A8); + } + break; + } +} + asm(".section .text.8098898"); void PrintStorageActionText(u8 index) { diff --git a/src/scene/hall_of_fame.c b/src/scene/hall_of_fame.c index 812c28137..ef5e6f873 100644 --- a/src/scene/hall_of_fame.c +++ b/src/scene/hall_of_fame.c @@ -90,11 +90,7 @@ static bool8 sub_81438C4(void); // functions from different files void sub_81439D0(void); -void sub_80C5E38(void*); // ? -bool8 sub_80C5DCC(void); -bool8 sub_80C5F98(void); void ReturnFromHallOfFamePC(void); -u16 SpeciesToPokedexNum(u16 species); void remove_some_task(void); // data and gfx @@ -130,9 +126,10 @@ static const s16 sHallOfFame_MonsHalfTeamPositions[3][4] = {-41, 214, 184, 64} }; -static const struct HallofFameMon sDummyFameMon = +static const struct PCScreenEffectStruct sDummyFameMon = { - 0x3EA03EA, 0, 0, 0, {0} + .tileTag = 0x3ea, + .paletteTag = 0x3ea }; static const u8 sUnused2[6] = {2, 1, 3, 6, 4, 5}; @@ -800,20 +797,15 @@ void sub_81428CC(void) } break; case 3: - { - struct HallofFameMons* fameMons; - - REG_BLDCNT = 0; - REG_BLDALPHA = 0; - REG_BLDY = 0; - sub_81435B8(); + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + REG_BLDY = 0; + sub_81435B8(); - fameMons = eHallOfFameMons1; - fameMons->mons[0] = sDummyFameMon; + eHOFPCScreenEffect = sDummyFameMon; - sub_80C5CD4((struct PCScreenEffectStruct *)fameMons); - gMain.state++; - } + sub_80C5CD4(&eHOFPCScreenEffect); + gMain.state++; break; case 4: AnimateSprites(); @@ -1022,12 +1014,9 @@ static void sub_8142DF4(u8 taskID) static void sub_8142F78(u8 taskID) { - struct HallofFameMons* fameMons; - CpuSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x200); - fameMons = eHallOfFameMons1; - fameMons->mons[0] = sDummyFameMon; - sub_80C5E38(fameMons); + eHOFPCScreenEffect = sDummyFameMon; + sub_80C5E38(&eHOFPCScreenEffect); gTasks[taskID].func = sub_8142FCC; } -- cgit v1.2.3 From ca2fbbad15daa12858d01eb87ab17a8d41eeffa5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 8 Jan 2018 22:25:48 -0500 Subject: sDummyPCScreenEffect --> sPCScreenEffectTemplate --- src/scene/hall_of_fame.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/scene/hall_of_fame.c b/src/scene/hall_of_fame.c index ef5e6f873..4740c086d 100644 --- a/src/scene/hall_of_fame.c +++ b/src/scene/hall_of_fame.c @@ -126,8 +126,7 @@ static const s16 sHallOfFame_MonsHalfTeamPositions[3][4] = {-41, 214, 184, 64} }; -static const struct PCScreenEffectStruct sDummyFameMon = -{ +static const struct PCScreenEffectStruct sPCScreenEffectTemplate = { .tileTag = 0x3ea, .paletteTag = 0x3ea }; @@ -802,7 +801,7 @@ void sub_81428CC(void) REG_BLDY = 0; sub_81435B8(); - eHOFPCScreenEffect = sDummyFameMon; + eHOFPCScreenEffect = sPCScreenEffectTemplate; sub_80C5CD4(&eHOFPCScreenEffect); gMain.state++; @@ -1015,7 +1014,7 @@ static void sub_8142DF4(u8 taskID) static void sub_8142F78(u8 taskID) { CpuSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x200); - eHOFPCScreenEffect = sDummyFameMon; + eHOFPCScreenEffect = sPCScreenEffectTemplate; sub_80C5E38(&eHOFPCScreenEffect); gTasks[taskID].func = sub_8142FCC; } -- cgit v1.2.3 From 7b7f11119ac386e51910b957f855eade7e40381b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 00:15:28 -0500 Subject: through sub_8097DE0 --- src/pokemon/pokemon_storage_system.c | 109 +++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index daae82df6..5fd43cfb8 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -89,6 +89,7 @@ struct PokemonStorageSystemData { u8 unk_0004; u8 unk_0005; u8 unk_0006; + u8 unk_0007; u16 unk_0008; u16 unk_000a; struct PCScreenEffectStruct unk_000c; @@ -266,6 +267,51 @@ const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/b const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); +const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.gbapal"); + +const u16 gPokemonStorageScrollingBGTile[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.4bpp"); + +const u8 gPokemonStorageScrollingBGTilemap[] = INCBIN_U8("graphics/pokemon_storage/scrolling_bg_map.bin.lz"); + +const u16 sUnknownTilemap[] = { + 0x1281, + 0x1282, + 0x1283, + 0x1284, + 0x1285, + 0x1286, + 0x1287, + 0x1288, + 0x128C, + 0x128D, + 0x128E, + 0x128F, + 0x1290, + 0x1291, + 0x1292, + 0x1293, + 0x0281, + 0x0282, + 0x0283, + 0x0284, + 0x0285, + 0x0286, + 0x0287, + 0x0288, + 0x028C, + 0x028D, + 0x028E, + 0x028F, + 0x0290, + 0x0291, + 0x0292, + 0x0293, + 0x12AD, + 0x12AE, + 0x12A8, + 0x12A8 +}; + extern const struct StorageAction gPCStorageActionTexts[]; extern const struct PokemonStorageSystemData *gPokemonStorageSystemPtr; extern u8 *const gUnknown_083B6DB8; @@ -2073,6 +2119,69 @@ void sub_8097BA0(void) } } +void sub_8097CC0(void) { + switch (ePokemonStorageSystem.unk_0004) { + case 0: + if (sub_809BF20()) { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + ePokemonStorageSystem.unk_0004 = 1; + } + else { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_CONTINUE_BOX); + sub_8098A38(0); + ePokemonStorageSystem.unk_0004 = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + case 2: + switch (ProcessMenuInputNoWrap()) { + case 0: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case -1: + case 1: + PlaySE(SE_PC_OFF); + sub_8098A5C(); + ePokemonStorageSystem.unk_0004++; + break; + } + break; + case 3: + ePokemonStorageSystem.unk_000c.tileTag = 0x000e; + ePokemonStorageSystem.unk_000c.paletteTag = 0xdad0; + ePokemonStorageSystem.unk_000c.unk04 = 20; + ePokemonStorageSystem.unk_000c.unk06 = 0; + sub_80C5E38(&ePokemonStorageSystem.unk_000c); + ePokemonStorageSystem.unk_0004++; + break; + case 4: + if (sub_80C5F98()) { + gPlayerPartyCount = CalculatePlayerPartyCount(); + SetMainCallback2(sub_80961A8); + } + break; + } +} + +void sub_8097DE0(void) +{ + ePokemonStorageSystem.unk_0007 = 0; + ePokemonStorageSystem.unk_0008 = 0; + ePokemonStorageSystem.unk_000a = 0; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(30); + DmaCopy16Defvars(3, gPokemonStorageScrollingBGTile, BG_SCREEN_ADDR(28), sizeof gPokemonStorageScrollingBGTile); + LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, BG_SCREEN_ADDR(30)); + LoadPalette(gPokemonStorageScrollingBGPalette, 0xd0, 0x10); +} + asm(".section .text.8098898"); void PrintStorageActionText(u8 index) { -- cgit v1.2.3 From 6503d0fee3d9423640f563745692af35f7298c8b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 10:09:55 -0500 Subject: through sub_8097E70; split PSS in 3 --- src/pokemon/pokemon_storage_system.c | 1553 ------------------------------- src/pokemon/pokemon_storage_system_2.c | 1566 ++++++++++++++++++++++++++++++++ src/pokemon/pokemon_storage_system_3.c | 16 + src/pokemon/pokemon_summary_screen.c | 29 +- src/pokenav_before.c | 1 - 5 files changed, 1596 insertions(+), 1569 deletions(-) create mode 100644 src/pokemon/pokemon_storage_system_2.c create mode 100644 src/pokemon/pokemon_storage_system_3.c (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 5fd43cfb8..c91e45d7a 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -3,123 +3,16 @@ #include "constants/songs.h" #include "sound.h" #include "field_weather.h" -#include "mon_markings.h" #include "overworld.h" -#include "mail_data.h" #include "field_fadetransition.h" #include "menu.h" #include "main.h" #include "strings.h" #include "string_util.h" #include "event_data.h" -#include "ewram.h" #include "script.h" -#include "pokemon_summary_screen.h" -#include "pc_screen_effect.h" -#include "naming_screen.h" #include "pokemon_storage_system.h" -enum { - PC_TEXT_EXIT_BOX, - PC_TEXT_WHAT_YOU_DO, - PC_TEXT_PICK_A_THEME, - PC_TEXT_PICK_A_WALLPAPER, - PC_TEXT_IS_SELECTED, - PC_TEXT_JUMP_TO_WHICH_BOX, - PC_TEXT_DEPOSIT_IN_WHICH_BOX, - PC_TEXT_WAS_DEPOSITED, - PC_TEXT_BOX_IS_FULL, - PC_TEXT_RELEASE_POKE, - PC_TEXT_WAS_RELEASED, - PC_TEXT_BYE_BYE, - PC_TEXT_MARK_POKE, - PC_TEXT_LAST_POKE, - PC_TEXT_PARTY_FULL, - PC_TEXT_HOLDING_POKE, - PC_TEXT_WHICH_ONE_WILL_TAKE, - PC_TEXT_CANT_RELEASE_EGG, - PC_TEXT_CONTINUE_BOX, - PC_TEXT_CAME_BACK, - PC_TEXT_WORRIED, - PC_TEXT_SURPRISE, - PC_TEXT_PLEASE_REMOVE_MAIL -}; - -enum { - PC_TEXT_FMT_NORMAL, - PC_TEXT_FMT_MON_NAME, - PC_TEXT_FMT_UNK_02, - PC_TEXT_FMT_UNK_03, - PC_TEXT_FMT_MON_NAME_2, - PC_TEXT_FMT_UNK_05, - PC_TEXT_FMT_MON_NAME_AFTER_EXCL_MARK -}; - -struct StorageAction { - u8 *text; - u8 format; -}; - -struct PSS_MenuStringPtrs { - const u8 *text; - const u8 *desc; -}; - -struct UnkStruct_2000020 { - struct UnkStruct_2000020 *unk_00; - u8 unk_04; - u8 unk_05; -}; - -struct UnkPSSStruct_2002370 { - struct Sprite *unk_0000; - struct Sprite *unk_0004[4]; - u32 unk_0014[3]; - struct Sprite *unk_0020[2]; - u8 filler_0028[0x214]; - u8 curBox; - u8 unk_023d; - u8 unk_023e; - u16 unk_0240; - u16 unk_0242; -}; // 0244 - -struct PokemonStorageSystemData { - void (*unk_0000)(void); - u8 unk_0004; - u8 unk_0005; - u8 unk_0006; - u8 unk_0007; - u16 unk_0008; - u16 unk_000a; - struct PCScreenEffectStruct unk_000c; - struct UnkStruct_2000020 unk_0020[274]; // refine size later - u8 filler_08b0[2]; - s16 unk_08b2; - u16 unk_08b4; - u8 filler_08b6[0x4a8]; - s16 unk_0d5e; - s16 unk_0d60; - u8 filler_0d62[0x490]; - u16 unk_11f2; - u8 filler_11f4[2]; - u8 unk_11f6; - u8 unk_11f7; - u8 unk_11f8; - u8 unk_11f9; - u8 unk_11fa[0xc2]; - struct PokemonMarkMenu unk_12bc; - struct UnkPSSStruct_2002370 unk_2370; - u8 filler_25b4[0xd8]; - u8 unk_268c; - u8 unk_268d; - u8 unk_268e; - struct Pokemon *unk_2690; - u8 unk_2694[18]; - u8 unk_26a6[62]; - u8 unk_26e4[80]; -}; - void StorageSystemCreatePrimaryMenu(u8 whichMenu); void sub_80963D0(u8 curBox); void sub_809658C(void); @@ -128,95 +21,6 @@ void sub_809662C(void); void sub_809665C(void); void sub_80966F4(const u8 *sourceString, u16 x, u16 y); void sub_8096784(struct Sprite *sprite); -void task_intro_29(u8 whichMenu); -void sub_8096884(void); -void sub_8096AFC(void); -void sub_8096B38(void); -void SetPSSCallback(void (*func)(void)); -void sub_8096BF0(void); -void sub_8096C68(void); -void sub_8096C84(void); -void sub_8096FC8(void); -void sub_8097004(void); -void sub_8097078(void); -void sub_80972A8(void); -void sub_80972FC(void); -void c3_0808DC50(void); -void sub_8097390(void); -void sub_809746C(void); -void sub_8097594(void); -void sub_8097788(void); -void sub_80977E4(void); -void sub_8097858(void); -void sub_809789C(void); -void sub_8097974(void); -void sub_8097A64(void); -void sub_8097B44(void); -void sub_8097BA0(void); -void sub_8097CC0(void); -void sub_8097DE0(void); -void sub_8097E44(void); -void sub_8097E70(void); -void BoxSetMosaic(void); -void sub_809801C(void); -void sub_8098400(void); -void add_to_c3_somehow(void); -bool8 sub_80985CC(void); -void sub_80986E8(void); -void sub_8098710(void); -void sub_8098734(void); -void sub_80987DC(void); -void sub_809880C(void); -bool8 sub_8098830(void); -void PrintStorageActionText(u8 index); -void sub_8098A38(u8); -void sub_8098A5C(void); -void sub_8098A80(void); -void sub_8098AA8(u8 a0); -void sub_8098B48(void); -void sub_8099310(void); -bool8 sub_8099374(void); -void sub_8099958(void); -bool8 sub_8099990(void); -void sub_809BB90(void); -void sub_8099BF8(u8 a0); -void sub_8099C70(u8 whichBox); -bool8 sub_8099D34(void); -void sub_8099DCC(u8 a0); -bool8 sub_8099E08(void); -void sub_809A860(u8 a0); -struct Sprite *sub_809A9A0(u16 a0, u16 a1, u8 a2, u8 a3, u8 a4); -void sub_809AA24(void); -void sub_809AA98(void); -bool8 sub_809AC00(void); -void sub_809B0C0(u8 a0); -void sub_809B0D4(void); -void sub_809B0E0(void); -u8 sub_809B0F4(void); -void sub_809B100(u8 a0); -bool8 sub_809B130(void); -void sub_809B440(void); -bool8 sub_809B62C(u8); -void sub_809B6BC(void); -void sub_809B6DC(void); -bool8 sub_809B734(void); -void sub_809B760(void); -void sub_809B7AC(void); -void sub_809B7D4(void); -s8 sub_809B960(void); -void sub_809BBC0(void); -void sub_809BC18(void); -void sub_809BD14(void); -void sub_809BDD8(u8 markings); -bool8 sub_809BE80(void); -bool8 sub_809BEBC(void); -bool8 sub_809BF20(void); -bool8 sub_809BF48(void); -u8 sub_809CA40(void); -void sub_809CE84(void); -s16 sub_809CF30(void); -void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); -void sub_809CFF0(void); const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { {PCText_WithdrawPoke, PCText_MovePokeToParty}, @@ -267,73 +71,11 @@ const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/b const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); -const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.gbapal"); - -const u16 gPokemonStorageScrollingBGTile[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.4bpp"); - -const u8 gPokemonStorageScrollingBGTilemap[] = INCBIN_U8("graphics/pokemon_storage/scrolling_bg_map.bin.lz"); - -const u16 sUnknownTilemap[] = { - 0x1281, - 0x1282, - 0x1283, - 0x1284, - 0x1285, - 0x1286, - 0x1287, - 0x1288, - 0x128C, - 0x128D, - 0x128E, - 0x128F, - 0x1290, - 0x1291, - 0x1292, - 0x1293, - 0x0281, - 0x0282, - 0x0283, - 0x0284, - 0x0285, - 0x0286, - 0x0287, - 0x0288, - 0x028C, - 0x028D, - 0x028E, - 0x028F, - 0x0290, - 0x0291, - 0x0292, - 0x0293, - 0x12AD, - 0x12AE, - 0x12A8, - 0x12A8 -}; - -extern const struct StorageAction gPCStorageActionTexts[]; -extern const struct PokemonStorageSystemData *gPokemonStorageSystemPtr; -extern u8 *const gUnknown_083B6DB8; - EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; EWRAM_DATA u8 gUnknown_02038470[3] = {}; EWRAM_DATA u8 gUnknown_02038473 = 0; EWRAM_DATA u8 gUnknown_02038474 = 0; EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478 = NULL; -EWRAM_DATA u8 gUnknown_0203847C = 0; -EWRAM_DATA u8 gUnknown_0203847D = 0; -EWRAM_DATA u8 gUnknown_0203847E = 0; -EWRAM_DATA u8 gUnknown_0203847F = 0; -EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; -EWRAM_DATA u8 gUnknown_020384E4 = 0; -EWRAM_DATA u8 gUnknown_020384E5 = 0; -EWRAM_DATA u8 gUnknown_020384E6 = 0; -EWRAM_DATA u8 gUnknown_020384E7 = 0; -EWRAM_DATA u8 gUnknown_020384E8 = 0; -EWRAM_DATA u8 gUnknown_020384E9 = 0; -EWRAM_DATA u16 gUnknown_020384EA = 0; -EWRAM_DATA u32 gUnknown_020384EC = 0; static u8 CountPokemonInBoxN(u8 boxId) { @@ -967,1298 +709,3 @@ void sub_8096784(struct Sprite *sprite) } } } - -void task_intro_29(u8 whichMenu) -{ - gUnknown_0203847D = whichMenu; - ePokemonStorageSystem.unk_0005 = whichMenu; - SetMainCallback2(sub_8096884); -} - -void sub_80967DC(void) -{ - REG_BG0HOFS = 0; - REG_BG0VOFS = 0; - REG_BG1HOFS = 0; - REG_BG1VOFS = 0; - REG_BG2VOFS = 0; - REG_BG2HOFS = 0; - REG_BG3HOFS = 0; - REG_BG3VOFS = 0; -} - -void sub_8096804(void) -{ - ResetPaletteFade(); - ResetSpriteData(); - FreeSpriteTileRanges(); - FreeAllSpritePalettes(); - ResetTasks(); - gReservedSpriteTileCount = 0x280; - sub_809CFDC(ePokemonStorageSystem.unk_0020, ePokemonStorageSystem.unk_0020 + 1, 8); - gKeyRepeatStartDelay = 20; -} - -void sub_8096848(void) -{ - sub_809B0D4(); - gUnknown_0203847C = (ePokemonStorageSystem.unk_0005 == 1 ? 1 : 0); - gUnknown_0203847E = 0; -} - -void sub_8096874(void) -{ - REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; -} - -void sub_8096884(void) -{ - switch (gMain.state) - { - case 0: - SetVBlankCallback(NULL); - REG_DISPCNT = 0; - sub_8096804(); - gMain.state++; - break; - case 1: - SetUpWindowConfig(&gWindowConfig_81E6D00); - gMain.state++; - break; - case 2: - InitMenuWindow(&gWindowConfig_81E6D00); - MenuZeroFillScreen(); - gMain.state++; - break; - case 3: - sub_80967DC(); - sub_8096848(); - gMain.state++; - break; - case 4: - sub_8098B48(); - sub_809AA24(); - gMain.state++; - break; - case 5: - sub_8097DE0(); - gMain.state++; - break; - case 6: - sub_8097E70(); - gMain.state++; - break; - case 7: - sub_8098400(); - gMain.state++; - break; - case 8: - sub_8099BF8(gPokemonStorage.currentBox); - ePokemonStorageSystem.unk_12bc.baseTileTag = 0x000a; - ePokemonStorageSystem.unk_12bc.basePaletteTag = 0xdacb; - sub_80F727C(&ePokemonStorageSystem.unk_12bc); - sub_80F7404(); - gMain.state++; - break; - case 9: - sub_8096874(); - SetPSSCallback(sub_8096BF0); - SetMainCallback2(sub_8096B38); - SetVBlankCallback(sub_8096AFC); - gMain.state++; - break; - } -} - -void sub_80969A0(void) -{ - switch (gMain.state) - { - case 0: - SetVBlankCallback(NULL); - REG_DISPCNT = 0x0000; - ePokemonStorageSystem.unk_0005 = gUnknown_0203847D; - sub_8096804(); - if (gUnknown_0203847F == 1) - sub_809BBC0(); - if (gUnknown_0203847F == 0) - sub_809BD14(); - gMain.state++; - break; - case 1: - SetUpWindowConfig(&gWindowConfig_81E6D00); - gMain.state++; - break; - case 2: - InitMenuWindow(&gWindowConfig_81E6D00); - MenuZeroFillScreen(); - gMain.state++; - break; - case 3: - sub_80967DC(); - gMain.state++; - break; - case 4: - sub_8098B48(); - sub_809AA98(); - gMain.state++; - break; - case 5: - sub_8097DE0(); - gMain.state++; - break; - case 6: - sub_8097E70(); - gMain.state++; - break; - case 7: - sub_8098400(); - gMain.state++; - break; - case 8: - sub_8099BF8(gPokemonStorage.currentBox); - ePokemonStorageSystem.unk_12bc.baseTileTag = 0x000a; - ePokemonStorageSystem.unk_12bc.basePaletteTag = 0xdacb; - sub_80F727C(&ePokemonStorageSystem.unk_12bc); - sub_80F7404(); - gMain.state++; - break; - case 9: - BeginNormalPaletteFade(0xffffffff, 0, 16, 0, 0); - SetVBlankCallback(sub_8096AFC); - gMain.state++; - break; - case 10: - sub_8096874(); - SetPSSCallback(sub_8096C68); - SetMainCallback2(sub_8096B38); - gMain.state++; - break; - } -} - -void sub_8096AFC(void) -{ - REG_BG2HOFS = ePokemonStorageSystem.unk_08b4; - REG_BG3HOFS = ePokemonStorageSystem.unk_000a; - REG_BG3VOFS = ePokemonStorageSystem.unk_0008; - LoadOam(); - ProcessSpriteCopyRequests(); - sub_809CFF0(); - TransferPlttBuffer(); -} - -void sub_8096B38(void) -{ - ePokemonStorageSystem.unk_0000(); - sub_8097E44(); - sub_8098734(); - AnimateSprites(); - BuildOamBuffer(); -} - -void sub_8096B5C(void) -{ - switch (ePokemonStorageSystem.unk_0006) - { - case 0: - ShowPokemonSummaryScreen(ePokemonStorageSystem.unk_2690, ePokemonStorageSystem.unk_268d, ePokemonStorageSystem.unk_268c, sub_80969A0, ePokemonStorageSystem.unk_268e); - break; - case 1: - DoNamingScreen(1, gPokemonStorage.boxNames[gPokemonStorage.currentBox], 0, 0, 0, sub_80969A0); - break; - } -} - -void SetPSSCallback(void (*func)(void)) -{ - ePokemonStorageSystem.unk_0000 = func; - ePokemonStorageSystem.unk_0004 = 0; -} - -void sub_8096BF0(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - BlendPalettes(0xffffffff, 16, 0); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - PlaySE(SE_PC_LOGON); - ePokemonStorageSystem.unk_000c.tileTag = 14; - ePokemonStorageSystem.unk_000c.paletteTag = 0xdad0; - ePokemonStorageSystem.unk_000c.unk04 = 0; - ePokemonStorageSystem.unk_000c.unk06 = 0; - sub_80C5CD4(&ePokemonStorageSystem.unk_000c); - BlendPalettes(0xffffffff, 0, 0); - ePokemonStorageSystem.unk_0004++; - break; - case 2: - if (sub_80C5DCC()) - SetPSSCallback(sub_8096C84); - break; - } -} - -void sub_8096C68(void) -{ - if (!UpdatePaletteFade()) - SetPSSCallback(sub_8096C84); -} - -void sub_8096C84(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - switch (sub_809CA40()) - { - case 1: - PlaySE(SE_SELECT); - ePokemonStorageSystem.unk_0004 = 1; - break; - case 5: - if (ePokemonStorageSystem.unk_0005 != 2) - { - PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); - ePokemonStorageSystem.unk_0004 = 3; - } - else - { - sub_809B0D4(); - SetPSSCallback(sub_8096FC8); - } - break; - case 6: - if (ePokemonStorageSystem.unk_0005 == 2) - { - if (sub_809BF20() && ItemIsMail(ePokemonStorageSystem.unk_11f2)) - { - ePokemonStorageSystem.unk_0004 = 5; - } - else - { - SetPSSCallback(sub_8097004); - } - } - break; - case 4: - SetPSSCallback(sub_8097BA0); - break; - case 16: - SetPSSCallback(sub_8097CC0); - break; - case 7: - PlaySE(SE_SELECT); - SetPSSCallback(sub_809789C); - break; - case 8: - PlaySE(SE_SELECT); - SetPSSCallback(sub_8097078); - break; - case 9: - PlaySE(SE_SELECT); - ePokemonStorageSystem.unk_08b2 = gPokemonStorage.currentBox + 1; - if (ePokemonStorageSystem.unk_08b2 > 13) - ePokemonStorageSystem.unk_08b2 = 0; - sub_8099C70(ePokemonStorageSystem.unk_08b2); - ePokemonStorageSystem.unk_0004 = 2; - break; - case 10: - PlaySE(SE_SELECT); - ePokemonStorageSystem.unk_08b2 = gPokemonStorage.currentBox - 1; - if (ePokemonStorageSystem.unk_08b2 < 0) - ePokemonStorageSystem.unk_08b2 = 13; - sub_8099C70(ePokemonStorageSystem.unk_08b2); - ePokemonStorageSystem.unk_0004 = 2; - break; - case 11: - if (!sub_809BE80()) - { - if (ItemIsMail(ePokemonStorageSystem.unk_11f2)) - { - ePokemonStorageSystem.unk_0004 = 5; - } - else - { - PlaySE(SE_SELECT); - SetPSSCallback(sub_809746C); - } - } - else - { - ePokemonStorageSystem.unk_0004 = 4; - } - break; - case 13: - if (sub_809BE80()) - { - ePokemonStorageSystem.unk_0004 = 4; - } - else - { - PlaySE(SE_SELECT); - SetPSSCallback(sub_80972A8); - } - break; - case 14: - if (!sub_809BEBC()) - { - ePokemonStorageSystem.unk_0004 = 4; - } - else - { - PlaySE(SE_SELECT); - SetPSSCallback(c3_0808DC50); - } - break; - case 12: - PlaySE(SE_SELECT); - SetPSSCallback(sub_8097390); - break; - case 15: - PlaySE(SE_SELECT); - SetPSSCallback(sub_80972FC); - break; - } - break; - case 1: - if (!sub_809AC00()) - { - if (sub_809BF48()) - sub_80986E8(); - else - sub_8098710(); - if (ePokemonStorageSystem.unk_11f6) - BoxSetMosaic(); - ePokemonStorageSystem.unk_0004 = 0; - } - break; - case 2: - if (!sub_8099D34()) - { - gPokemonStorage.currentBox = ePokemonStorageSystem.unk_08b2; - if (!gUnknown_0203847C && !sub_809BF20()) - { - sub_809B440(); - BoxSetMosaic(); - } - ePokemonStorageSystem.unk_0004 = 0; - } - break; - case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) - { - sub_8098A5C(); - ePokemonStorageSystem.unk_0004 = 0; - } - break; - case 4: - PlaySE(SE_HAZURE); - PrintStorageActionText(PC_TEXT_LAST_POKE); - ePokemonStorageSystem.unk_0004 = 6; - break; - case 5: - PlaySE(SE_HAZURE); - PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); - ePokemonStorageSystem.unk_0004 = 6; - break; - case 6: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) - { - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_8096FC8(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - sub_809880C(); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!sub_8098830()) - SetPSSCallback(sub_8096C84); - break; - } -} - -void sub_8097004(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - PlaySE(SE_SELECT); - add_to_c3_somehow(); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!sub_80985CC()) - { - sub_809B0C0(sub_809B0F4()); - ePokemonStorageSystem.unk_0004++; - } - break; - case 2: - if (!sub_809AC00()) - { - if (ePokemonStorageSystem.unk_11f6) - BoxSetMosaic(); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_8097078(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - PrintStorageActionText(PC_TEXT_IS_SELECTED); - sub_809CE84(); - ePokemonStorageSystem.unk_0004 = 1; - break; - case 1: - switch (sub_809CF30()) - { - case -1: - case 0: - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - break; - case 3: - if (sub_809BE80()) - { - ePokemonStorageSystem.unk_0004 = 2; - } - else - { - PlaySE(SE_SELECT); - sub_8098A5C(); - SetPSSCallback(sub_80972A8); - } - break; - case 5: - PlaySE(SE_SELECT); - sub_8098A5C(); - SetPSSCallback(sub_80972FC); - break; - case 4: - if (!sub_809BEBC()) - { - ePokemonStorageSystem.unk_0004 = 2; - } - else - { - PlaySE(SE_SELECT); - sub_8098A5C(); - SetPSSCallback(c3_0808DC50); - } - break; - case 2: - PlaySE(SE_SELECT); - sub_8098A5C(); - SetPSSCallback(sub_8097390); - break; - case 1: - if (sub_809BE80()) - { - ePokemonStorageSystem.unk_0004 = 2; - } - else if (ItemIsMail(ePokemonStorageSystem.unk_11f2)) - { - ePokemonStorageSystem.unk_0004 = 3; - } - else - { - PlaySE(SE_SELECT); - sub_8098A5C(); - SetPSSCallback(sub_809746C); - } - break; - case 7: - if (sub_809BE80()) - { - ePokemonStorageSystem.unk_0004 = 2; - } - else if (ePokemonStorageSystem.unk_11f9) - { - ePokemonStorageSystem.unk_0004 = 4; - } - else if (ItemIsMail(ePokemonStorageSystem.unk_11f2)) - { - ePokemonStorageSystem.unk_0004 = 3; - } - else - { - PlaySE(SE_SELECT); - SetPSSCallback(sub_8097594); - } - break; - case 6: - PlaySE(SE_SELECT); - SetPSSCallback(sub_8097788); - break; - case 8: - PlaySE(SE_SELECT); - SetPSSCallback(sub_80977E4); - break; - } - break; - case 2: - PlaySE(SE_HAZURE); - PrintStorageActionText(PC_TEXT_LAST_POKE); - ePokemonStorageSystem.unk_0004 = 5; - break; - case 4: - PlaySE(SE_HAZURE); - PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG); - ePokemonStorageSystem.unk_0004 = 5; - break; - case 3: - PlaySE(SE_HAZURE); - PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); - ePokemonStorageSystem.unk_0004 = 5; - break; - case 5: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) - { - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_80972A8(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - sub_809B100(0); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!sub_809B130()) - { - if (gUnknown_0203847C) - SetPSSCallback(sub_8097858); - else - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_80972FC(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - sub_809B100(1); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!sub_809B130()) - { - if (gUnknown_0203847C) - SetPSSCallback(sub_8097858); - else - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void c3_0808DC50(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - sub_809B100(2); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!sub_809B130()) - { - BoxSetMosaic(); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_8097390(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - if (CalculatePlayerPartyCount() == 6) - { - PrintStorageActionText(PC_TEXT_PARTY_FULL); - ePokemonStorageSystem.unk_0004 = 1; - } - else - { - sub_809B0E0(); - sub_809B100(0); - ePokemonStorageSystem.unk_0004 = 2; - } - break; - case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) - { - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - } - break; - case 2: - if (!sub_809B130()) - { - sub_809880C(); - ePokemonStorageSystem.unk_0004++; - } - break; - case 3: - if (!sub_8098830()) - { - sub_809B100(1); - ePokemonStorageSystem.unk_0004++; - } - break; - case 4: - if (!sub_809B130()) - { - sub_80987DC(); - ePokemonStorageSystem.unk_0004++; - } - break; - case 5: - SetPSSCallback(sub_8097004); - break; - } -} - -void sub_809746C(void) -{ - u8 r4; - - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - sub_8096264(&ePokemonStorageSystem.unk_2370, 0x0007, 0xdaca, 3); - sub_809634C(gUnknown_0203847E); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - r4 = sub_8096368(); - if (r4 == 200); - else if (r4 == 201) - { - sub_8098A5C(); - sub_809635C(); - sub_8096310(); - SetPSSCallback(sub_8096C84); - } - else - { - if (sub_809B62C(r4)) - { - sub_8098A5C(); - sub_809635C(); - sub_8096310(); - ePokemonStorageSystem.unk_0004 = 2; - } - else - { - PrintStorageActionText(PC_TEXT_BOX_IS_FULL); - ePokemonStorageSystem.unk_0004 = 4; - } - gUnknown_0203847E = r4; - } - break; - case 2: - party_compaction(); - sub_8099310(); - ePokemonStorageSystem.unk_0004++; - break; - case 3: - if (!sub_8099374()) - { - sub_809B6BC(); - BoxSetMosaic(); - sub_80987DC(); - SetPSSCallback(sub_8096C84); - } - break; - case 4: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - { - PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - ePokemonStorageSystem.unk_0004 = 1; - } - break; - } -} - -void sub_8097594(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - PrintStorageActionText(PC_TEXT_RELEASE_POKE); - sub_8098A38(1); - ePokemonStorageSystem.unk_0004++; - // fallthrough - case 1: - switch (ProcessMenuInputNoWrap()) - { - case -1: - case 1: - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - break; - case 0: - sub_8098A5C(); - sub_809B7D4(); - sub_809B6DC(); - ePokemonStorageSystem.unk_0004++; - break; - } - break; - case 2: - sub_809B960(); - if (!sub_809B734()) - { - while (1) - { - s8 r0 = sub_809B960(); - if (r0 == 1) - { - ePokemonStorageSystem.unk_0004++; - break; - } - if (r0 == 0) - { - ePokemonStorageSystem.unk_0004 = 8; - break; - } - } - } - break; - case 3: - sub_809B760(); - sub_809801C(); - PrintStorageActionText(PC_TEXT_WAS_RELEASED); - ePokemonStorageSystem.unk_0004++; - break; - case 4: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - { - PrintStorageActionText(PC_TEXT_BYE_BYE); - ePokemonStorageSystem.unk_0004++; - } - break; - case 5: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - { - sub_8098A5C(); - if (gUnknown_0203847C) - { - party_compaction(); - sub_8099310(); - ePokemonStorageSystem.unk_0004++; - } - else - { - ePokemonStorageSystem.unk_0004 = 7; - } - } - break; - case 6: - if (!sub_8099374()) - { - sub_809B440(); - BoxSetMosaic(); - sub_80987DC(); - ePokemonStorageSystem.unk_0004++; - } - break; - case 7: - SetPSSCallback(sub_8096C84); - break; - case 8: - PrintStorageActionText(PC_TEXT_WAS_RELEASED); - ePokemonStorageSystem.unk_0004++; - break; - case 9: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - { - PrintStorageActionText(PC_TEXT_SURPRISE); - ePokemonStorageSystem.unk_0004++; - } - break; - case 10: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - { - sub_8098A5C(); - sub_8099958(); - ePokemonStorageSystem.unk_0004++; - } - break; - case 11: - if (!sub_8099990()) - { - sub_809B7AC(); - PrintStorageActionText(PC_TEXT_CAME_BACK); - ePokemonStorageSystem.unk_0004++; - } - break; - case 12: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - { - PrintStorageActionText(PC_TEXT_WORRIED); - ePokemonStorageSystem.unk_0004++; - } - break; - case 13: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - { - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_8097788(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - sub_809BC18(); - BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!UpdatePaletteFade()) - { - gUnknown_0203847F = 0; - ePokemonStorageSystem.unk_0006 = 0; - SetMainCallback2(sub_8096B5C); - } - break; - } -} - -void sub_80977E4(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - PrintStorageActionText(PC_TEXT_MARK_POKE); - ePokemonStorageSystem.unk_12bc.markings = ePokemonStorageSystem.unk_11f7; - sub_80F7418(ePokemonStorageSystem.unk_11f7, 0xb0, 0x10); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!sub_80F7500()) - { - sub_80F7470(); - sub_8098A5C(); - sub_809BDD8(ePokemonStorageSystem.unk_12bc.markings); - sub_809801C(); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_8097858(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - party_compaction(); - sub_8099310(); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!sub_8099374()) - { - sub_80987DC(); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_809789C(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); - sub_809CE84(); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - switch (sub_809CF30()) - { - case -1: - case 0: - sub_809A860(1); - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - break; - case 11: - PlaySE(SE_SELECT); - SetPSSCallback(sub_8097B44); - break; - case 10: - PlaySE(SE_SELECT); - sub_8098A5C(); - SetPSSCallback(sub_8097974); - break; - case 9: - PlaySE(SE_SELECT); - sub_8098A5C(); - SetPSSCallback(sub_8097A64); - break; - } - break; - } -} - -void sub_8097974(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - sub_8098A80(); - PrintStorageActionText(PC_TEXT_PICK_A_THEME); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - ePokemonStorageSystem.unk_0d5e = sub_809CF30(); - switch (ePokemonStorageSystem.unk_0d5e) - { - case -1: - sub_809A860(1); - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - break; - case 12 ... 15: - PlaySE(SE_SELECT); - ePokemonStorageSystem.unk_0d5e -= 12; - sub_8098AA8(ePokemonStorageSystem.unk_0d5e); - PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); - ePokemonStorageSystem.unk_0004++; - break; - } - break; - case 2: - ePokemonStorageSystem.unk_0d60 = sub_809CF30(); - switch (ePokemonStorageSystem.unk_0d60) - { - case -1: - sub_8098A5C(); - ePokemonStorageSystem.unk_0004 = 0; - break; - case -2: - break; - default: - PlaySE(SE_SELECT); - sub_8098A5C(); - ePokemonStorageSystem.unk_0d60 -= 16; - sub_8099DCC(ePokemonStorageSystem.unk_0d60); - ePokemonStorageSystem.unk_0004++; - break; - } - break; - case 3: - if (!sub_8099E08()) - { - sub_809A860(1); - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_8097A64(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); - sub_8096264(&ePokemonStorageSystem.unk_2370, 0x0007, 0xdaca, 3); - sub_809634C(gPokemonStorage.currentBox); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - ePokemonStorageSystem.unk_08b2 = sub_8096368(); - switch (ePokemonStorageSystem.unk_08b2) - { - case 200: - break; - default: - sub_8098A5C(); - sub_809635C(); - sub_8096310(); - if (ePokemonStorageSystem.unk_08b2 == 201 || ePokemonStorageSystem.unk_08b2 == gPokemonStorage.currentBox) - { - sub_809A860(1); - SetPSSCallback(sub_8096C84); - } - else - { - ePokemonStorageSystem.unk_0004++; - } - break; - } - break; - case 2: - sub_8099C70(ePokemonStorageSystem.unk_08b2); - ePokemonStorageSystem.unk_0004++; - break; - case 3: - if (!sub_8099D34()) - { - gPokemonStorage.currentBox = ePokemonStorageSystem.unk_08b2; - SetPSSCallback(sub_8096C84); - } - break; - } -} - -void sub_8097B44(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - sub_809BB90(); - BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0); - ePokemonStorageSystem.unk_0004++; - break; - case 1: - if (!UpdatePaletteFade()) - { - gUnknown_0203847F = 1; - ePokemonStorageSystem.unk_0006 = 1; - SetMainCallback2(sub_8096B5C); - } - break; - } -} - -void sub_8097BA0(void) -{ - switch (ePokemonStorageSystem.unk_0004) - { - case 0: - if (sub_809BF20()) - { - PlaySE(SE_HAZURE); - PrintStorageActionText(PC_TEXT_HOLDING_POKE); - ePokemonStorageSystem.unk_0004 = 1; - } - else - { - PlaySE(SE_SELECT); - PrintStorageActionText(PC_TEXT_EXIT_BOX); - sub_8098A38(0); - ePokemonStorageSystem.unk_0004 = 2; - } - break; - case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) - { - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - } - break; - case 2: - switch (ProcessMenuInputNoWrap()) - { - case 1: - case -1: - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - break; - case 0: - PlaySE(SE_PC_OFF); - sub_8098A5C(); - ePokemonStorageSystem.unk_0004++; - break; - } - break; - case 3: - ePokemonStorageSystem.unk_000c.tileTag = 0x000e; - ePokemonStorageSystem.unk_000c.paletteTag = 0xdad0; - ePokemonStorageSystem.unk_000c.unk04 = 20; - ePokemonStorageSystem.unk_000c.unk06 = 0; - sub_80C5E38(&ePokemonStorageSystem.unk_000c); - ePokemonStorageSystem.unk_0004++; - break; - case 4: - if (sub_80C5F98()) - { - gPlayerPartyCount = CalculatePlayerPartyCount(); - SetMainCallback2(sub_80961A8); - } - break; - } -} - -void sub_8097CC0(void) { - switch (ePokemonStorageSystem.unk_0004) { - case 0: - if (sub_809BF20()) { - PlaySE(SE_HAZURE); - PrintStorageActionText(PC_TEXT_HOLDING_POKE); - ePokemonStorageSystem.unk_0004 = 1; - } - else { - PlaySE(SE_SELECT); - PrintStorageActionText(PC_TEXT_CONTINUE_BOX); - sub_8098A38(0); - ePokemonStorageSystem.unk_0004 = 2; - } - break; - case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - } - break; - case 2: - switch (ProcessMenuInputNoWrap()) { - case 0: - sub_8098A5C(); - SetPSSCallback(sub_8096C84); - break; - case -1: - case 1: - PlaySE(SE_PC_OFF); - sub_8098A5C(); - ePokemonStorageSystem.unk_0004++; - break; - } - break; - case 3: - ePokemonStorageSystem.unk_000c.tileTag = 0x000e; - ePokemonStorageSystem.unk_000c.paletteTag = 0xdad0; - ePokemonStorageSystem.unk_000c.unk04 = 20; - ePokemonStorageSystem.unk_000c.unk06 = 0; - sub_80C5E38(&ePokemonStorageSystem.unk_000c); - ePokemonStorageSystem.unk_0004++; - break; - case 4: - if (sub_80C5F98()) { - gPlayerPartyCount = CalculatePlayerPartyCount(); - SetMainCallback2(sub_80961A8); - } - break; - } -} - -void sub_8097DE0(void) -{ - ePokemonStorageSystem.unk_0007 = 0; - ePokemonStorageSystem.unk_0008 = 0; - ePokemonStorageSystem.unk_000a = 0; - REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(30); - DmaCopy16Defvars(3, gPokemonStorageScrollingBGTile, BG_SCREEN_ADDR(28), sizeof gPokemonStorageScrollingBGTile); - LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, BG_SCREEN_ADDR(30)); - LoadPalette(gPokemonStorageScrollingBGPalette, 0xd0, 0x10); -} - -asm(".section .text.8098898"); - -void PrintStorageActionText(u8 index) { - u8 *ptr; - - MenuDrawTextWindow(10, 16, 29, 19); - - switch (gPCStorageActionTexts[index].format) - { - - case PC_TEXT_FMT_UNK_02: - ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); - ptr = StringCopy(ptr, ePokemonStorageSystem.unk_11fa); - break; - - case PC_TEXT_FMT_UNK_05: - ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); - ptr = StringCopy(ptr, ePokemonStorageSystem.unk_26e4); - break; - - case PC_TEXT_FMT_MON_NAME: - // {var} + " is selected." - ptr = StringCopy(ePokemonStorageSystem.unk_2694, ePokemonStorageSystem.unk_11fa); - ptr = StringCopy(ptr, gPCStorageActionTexts[index].text); - break; - - case PC_TEXT_FMT_MON_NAME_2: - // {var} + " was released." - ptr = StringCopy(ePokemonStorageSystem.unk_2694, ePokemonStorageSystem.unk_26e4); -#if ENGLISH - ptr = StringCopy(ptr, gPCStorageActionTexts[index].text); -#elif GERMAN - ptr = de_sub_8073174(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); -#endif - break; - - case PC_TEXT_FMT_UNK_03: - { - u8 *stringLength; - u8 *text; - - text = gPCStorageActionTexts[index].text; - stringLength = &text[StringLength(text)] + 1; - - ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); - ptr = StringCopy(ptr, ePokemonStorageSystem.unk_11fa); - ptr = StringCopy(ptr, stringLength); - } - break; - - case PC_TEXT_FMT_MON_NAME_AFTER_EXCL_MARK: - // "Bye-bye, ".substr(0, -1) + {var} + "Bye-bye, !".substr(-1, 1) - { - u8 *stringLength; - u8 *text; - - text = gPCStorageActionTexts[index].text; - stringLength = &text[StringLength(text)] - 1; - - ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); - ptr = StringCopy(ptr - 1, ePokemonStorageSystem.unk_26e4); - ptr = StringCopy(ptr, stringLength); - } - break; - - case PC_TEXT_FMT_NORMAL: - default: - ptr = StringCopy(ePokemonStorageSystem.unk_2694, gPCStorageActionTexts[index].text); - break; - } - - while (ptr < ePokemonStorageSystem.unk_26a6) - { - ptr[0] = CHAR_SPACE; - ptr++; - } - - ptr[0] = EOS; - MenuPrint(ePokemonStorageSystem.unk_2694, 11, 17); -} diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c new file mode 100644 index 000000000..5c72d02e9 --- /dev/null +++ b/src/pokemon/pokemon_storage_system_2.c @@ -0,0 +1,1566 @@ + +// Includes +#include "global.h" +#include "constants/songs.h" +#include "sound.h" +#include "ewram.h" +#include "task.h" +#include "main.h" +#include "palette.h" +#include "menu.h" +#include "graphics.h" +#include "strings.h" +#include "string_util.h" +#include "pokemon_summary_screen.h" +#include "mail_data.h" +#include "naming_screen.h" +#include "pokemon_storage_system.h" + +// Static type declarations + +// Static RAM declarations + +EWRAM_DATA u8 gUnknown_0203847C = 0; +EWRAM_DATA u8 gUnknown_0203847D = 0; +EWRAM_DATA u8 gUnknown_0203847E = 0; +EWRAM_DATA u8 gUnknown_0203847F = 0; +EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; +EWRAM_DATA u8 gUnknown_020384E4 = 0; +EWRAM_DATA u8 gUnknown_020384E5 = 0; +EWRAM_DATA u8 gUnknown_020384E6 = 0; +EWRAM_DATA u8 gUnknown_020384E7 = 0; +EWRAM_DATA u8 gUnknown_020384E8 = 0; +EWRAM_DATA u8 gUnknown_020384E9 = 0; +EWRAM_DATA u16 gUnknown_020384EA = 0; +EWRAM_DATA u32 gUnknown_020384EC = 0; + +// Static ROM declarations + +void sub_8096884(void); +void sub_8096AFC(void); +void sub_8096B38(void); +void SetPSSCallback(void (*func)(void)); +void sub_8096BF0(void); +void sub_8096C68(void); +void sub_8096C84(void); +void sub_8096FC8(void); +void sub_8097004(void); +void sub_8097078(void); +void sub_80972A8(void); +void sub_80972FC(void); +void c3_0808DC50(void); +void sub_8097390(void); +void sub_809746C(void); +void sub_8097594(void); +void sub_8097788(void); +void sub_80977E4(void); +void sub_8097858(void); +void sub_809789C(void); +void sub_8097974(void); +void sub_8097A64(void); +void sub_8097B44(void); +void sub_8097BA0(void); +void sub_8097CC0(void); +void sub_8097DE0(void); +void sub_8097E44(void); +void sub_8097E70(void); +void sub_8097F58(void); +void sub_8097FB8(void); +void BoxSetMosaic(void); +void sub_809801C(void); +void sub_80980D4(void); +void sub_8098400(void); +void add_to_c3_somehow(void); +bool8 sub_80985CC(void); +void sub_80986E8(void); +void sub_8098710(void); +void sub_8098734(void); +void sub_80987DC(void); +void sub_809880C(void); +bool8 sub_8098830(void); +void PrintStorageActionText(u8 index); +void sub_8098A38(u8); +void sub_8098A5C(void); +void sub_8098A80(void); +void sub_8098AA8(u8 a0); +void sub_8098B48(void); +void sub_8099310(void); +bool8 sub_8099374(void); +void sub_8099958(void); +bool8 sub_8099990(void); +void sub_809BB90(void); +void sub_8099BF8(u8 a0); +void sub_8099C70(u8 whichBox); +bool8 sub_8099D34(void); +void sub_8099DCC(u8 a0); +bool8 sub_8099E08(void); +void sub_809A860(u8 a0); +void sub_809AA24(void); +void sub_809AA98(void); +bool8 sub_809AC00(void); +void sub_809B0C0(u8 a0); +void sub_809B0D4(void); +void sub_809B0E0(void); +u8 sub_809B0F4(void); +void sub_809B100(u8 a0); +bool8 sub_809B130(void); +void sub_809B440(void); +bool8 sub_809B62C(u8); +void sub_809B6BC(void); +void sub_809B6DC(void); +bool8 sub_809B734(void); +void sub_809B760(void); +void sub_809B7AC(void); +void sub_809B7D4(void); +s8 sub_809B960(void); +void sub_809BBC0(void); +void sub_809BC18(void); +void sub_809BD14(void); +void sub_809BDD8(u8 markings); +bool8 sub_809BE80(void); +bool8 sub_809BEBC(void); +bool8 sub_809BF20(void); +bool8 sub_809BF48(void); +u8 sub_809CA40(void); +void sub_809CE84(void); +s16 sub_809CF30(void); +void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); +void sub_809CFF0(void); +void sub_809D034(void *dest, u16 dLeft, u16 dTop, const void *src, u16 sLeft, u16 sTop, u16 width, u16 height); + +// .rodata + +const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.gbapal"); + +const u16 gPokemonStorageScrollingBGTile[] = INCBIN_U16("graphics/pokemon_storage/scrolling_bg.4bpp"); + +const u8 gPokemonStorageScrollingBGTilemap[] = INCBIN_U8("graphics/pokemon_storage/scrolling_bg_map.bin.lz"); + +const u16 sUnknownTilemap[] = { + 0x1281, + 0x1282, + 0x1283, + 0x1284, + 0x1285, + 0x1286, + 0x1287, + 0x1288, + 0x128C, + 0x128D, + 0x128E, + 0x128F, + 0x1290, + 0x1291, + 0x1292, + 0x1293, + 0x0281, + 0x0282, + 0x0283, + 0x0284, + 0x0285, + 0x0286, + 0x0287, + 0x0288, + 0x028C, + 0x028D, + 0x028E, + 0x028F, + 0x0290, + 0x0291, + 0x0292, + 0x0293, + 0x12AD, + 0x12AE, + 0x12A8, + 0x12A8 +}; + +const u16 WaveformPalette[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal"); + +const u8 WaveformTiles[] = INCBIN_U8("graphics/pokemon_storage/waveform.4bpp"); + +const u16 gUnknown_083B6D74[] = INCBIN_U16("graphics/pokemon_storage/83B6D74.gbapal"); + +const u16 gUnknown_083B6D94[] = INCBIN_U16("graphics/pokemon_storage/83B6D94.gbapal"); + +struct PokemonStorageSystemData *const gPokemonStorageSystemPtr = &ePokemonStorageSystem; + +u8 *const gUnknown_083B6DB8 = gTileBuffer; + +const struct SpritePalette gWaveformSpritePalette = { + WaveformPalette, 0xdacd +}; + +const struct SpriteSheet gWaveformSpriteSheet = { + WaveformTiles, 0x1c0, 0x0005 +}; + +const struct SpriteSheet gUnknown_083B6DCC = { + ePokemonStorageSystem.unk_2784, 0x800, 0x0002 +}; + +const struct SpritePalette gUnknown_083B6DD4 = { + ePokemonStorageSystem.unk_2704, 0xdac7 +}; + +const struct OamData gOamData_83B6EAC; + +const struct SpriteTemplate gSpriteTemplate_83B6DDC = { + 0x0002, 0xdac7, &gOamData_83B6EAC, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy +}; + +const struct StorageAction gPCStorageActionTexts[] = { + {PCText_ExitBox, 0}, + {PCText_WhatYouDo, 0}, + {PCText_PickATheme, 0}, + {PCText_PickAWallpaper, 0}, + {PCText_IsSelected, 1}, + {PCText_JumpToWhichBox, 0}, + {PCText_DepositInWhichBox, 0}, + {PCText_WasDeposited, 1}, + {PCText_BoxIsFull, 0}, + {PCText_ReleasePoke, 0}, + {PCText_WasReleased, 4}, + {PCText_ByeBye, 6}, + {PCText_MarkPoke, 0}, + {PCText_LastPoke, 0}, + {PCText_PartyFull, 0}, + {PCText_HoldingPoke, 0}, + {PCText_WhichOneWillTake, 0}, + {PCText_CantReleaseEgg, 0}, + {PCText_ContinueBox, 0}, + {PCText_CameBack, 1}, + {PCText_Worried, 0}, + {PCText_Surprise, 0}, + {PCText_PleaseRemoveMail, 0} +}; + +// .text + + +void task_intro_29(u8 whichMenu) +{ + gUnknown_0203847D = whichMenu; + gPokemonStorageSystemPtr->unk_0005 = whichMenu; + SetMainCallback2(sub_8096884); +} + +void sub_80967DC(void) +{ + REG_BG0HOFS = 0; + REG_BG0VOFS = 0; + REG_BG1HOFS = 0; + REG_BG1VOFS = 0; + REG_BG2VOFS = 0; + REG_BG2HOFS = 0; + REG_BG3HOFS = 0; + REG_BG3VOFS = 0; +} + +void sub_8096804(void) +{ + ResetPaletteFade(); + ResetSpriteData(); + FreeSpriteTileRanges(); + FreeAllSpritePalettes(); + ResetTasks(); + gReservedSpriteTileCount = 0x280; + sub_809CFDC(gPokemonStorageSystemPtr->unk_0020, gPokemonStorageSystemPtr->unk_0020 + 1, 8); + gKeyRepeatStartDelay = 20; +} + +void sub_8096848(void) +{ + sub_809B0D4(); + gUnknown_0203847C = (gPokemonStorageSystemPtr->unk_0005 == 1 ? 1 : 0); + gUnknown_0203847E = 0; +} + +void sub_8096874(void) +{ + REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; +} + +void sub_8096884(void) +{ + switch (gMain.state) + { + case 0: + SetVBlankCallback(NULL); + REG_DISPCNT = 0; + sub_8096804(); + gMain.state++; + break; + case 1: + SetUpWindowConfig(&gWindowConfig_81E6D00); + gMain.state++; + break; + case 2: + InitMenuWindow(&gWindowConfig_81E6D00); + MenuZeroFillScreen(); + gMain.state++; + break; + case 3: + sub_80967DC(); + sub_8096848(); + gMain.state++; + break; + case 4: + sub_8098B48(); + sub_809AA24(); + gMain.state++; + break; + case 5: + sub_8097DE0(); + gMain.state++; + break; + case 6: + sub_8097E70(); + gMain.state++; + break; + case 7: + sub_8098400(); + gMain.state++; + break; + case 8: + sub_8099BF8(gPokemonStorage.currentBox); + gPokemonStorageSystemPtr->unk_12bc.baseTileTag = 0x000a; + gPokemonStorageSystemPtr->unk_12bc.basePaletteTag = 0xdacb; + sub_80F727C(&gPokemonStorageSystemPtr->unk_12bc); + sub_80F7404(); + gMain.state++; + break; + case 9: + sub_8096874(); + SetPSSCallback(sub_8096BF0); + SetMainCallback2(sub_8096B38); + SetVBlankCallback(sub_8096AFC); + gMain.state++; + break; + } +} + +void sub_80969A0(void) +{ + switch (gMain.state) + { + case 0: + SetVBlankCallback(NULL); + REG_DISPCNT = 0x0000; + gPokemonStorageSystemPtr->unk_0005 = gUnknown_0203847D; + sub_8096804(); + if (gUnknown_0203847F == 1) + sub_809BBC0(); + if (gUnknown_0203847F == 0) + sub_809BD14(); + gMain.state++; + break; + case 1: + SetUpWindowConfig(&gWindowConfig_81E6D00); + gMain.state++; + break; + case 2: + InitMenuWindow(&gWindowConfig_81E6D00); + MenuZeroFillScreen(); + gMain.state++; + break; + case 3: + sub_80967DC(); + gMain.state++; + break; + case 4: + sub_8098B48(); + sub_809AA98(); + gMain.state++; + break; + case 5: + sub_8097DE0(); + gMain.state++; + break; + case 6: + sub_8097E70(); + gMain.state++; + break; + case 7: + sub_8098400(); + gMain.state++; + break; + case 8: + sub_8099BF8(gPokemonStorage.currentBox); + gPokemonStorageSystemPtr->unk_12bc.baseTileTag = 0x000a; + gPokemonStorageSystemPtr->unk_12bc.basePaletteTag = 0xdacb; + sub_80F727C(&gPokemonStorageSystemPtr->unk_12bc); + sub_80F7404(); + gMain.state++; + break; + case 9: + BeginNormalPaletteFade(0xffffffff, 0, 16, 0, 0); + SetVBlankCallback(sub_8096AFC); + gMain.state++; + break; + case 10: + sub_8096874(); + SetPSSCallback(sub_8096C68); + SetMainCallback2(sub_8096B38); + gMain.state++; + break; + } +} + +void sub_8096AFC(void) +{ + REG_BG2HOFS = gPokemonStorageSystemPtr->unk_08b4; + REG_BG3HOFS = gPokemonStorageSystemPtr->unk_000a; + REG_BG3VOFS = gPokemonStorageSystemPtr->unk_0008; + LoadOam(); + ProcessSpriteCopyRequests(); + sub_809CFF0(); + TransferPlttBuffer(); +} + +void sub_8096B38(void) +{ + gPokemonStorageSystemPtr->unk_0000(); + sub_8097E44(); + sub_8098734(); + AnimateSprites(); + BuildOamBuffer(); +} + +void sub_8096B5C(void) +{ + switch (gPokemonStorageSystemPtr->unk_0006) + { + case 0: + ShowPokemonSummaryScreen(gPokemonStorageSystemPtr->unk_2690, gPokemonStorageSystemPtr->unk_268d, gPokemonStorageSystemPtr->unk_268c, sub_80969A0, gPokemonStorageSystemPtr->unk_268e); + break; + case 1: + DoNamingScreen(1, gPokemonStorage.boxNames[gPokemonStorage.currentBox], 0, 0, 0, sub_80969A0); + break; + } +} + +void SetPSSCallback(void (*func)(void)) +{ + gPokemonStorageSystemPtr->unk_0000 = func; + gPokemonStorageSystemPtr->unk_0004 = 0; +} + +void sub_8096BF0(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + BlendPalettes(0xffffffff, 16, 0); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + PlaySE(SE_PC_LOGON); + gPokemonStorageSystemPtr->unk_000c.tileTag = 14; + gPokemonStorageSystemPtr->unk_000c.paletteTag = 0xdad0; + gPokemonStorageSystemPtr->unk_000c.unk04 = 0; + gPokemonStorageSystemPtr->unk_000c.unk06 = 0; + sub_80C5CD4(&gPokemonStorageSystemPtr->unk_000c); + BlendPalettes(0xffffffff, 0, 0); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 2: + if (sub_80C5DCC()) + SetPSSCallback(sub_8096C84); + break; + } +} + +void sub_8096C68(void) +{ + if (!UpdatePaletteFade()) + SetPSSCallback(sub_8096C84); +} + +void sub_8096C84(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + switch (sub_809CA40()) + { + case 1: + PlaySE(SE_SELECT); + gPokemonStorageSystemPtr->unk_0004 = 1; + break; + case 5: + if (gPokemonStorageSystemPtr->unk_0005 != 2) + { + PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); + gPokemonStorageSystemPtr->unk_0004 = 3; + } + else + { + sub_809B0D4(); + SetPSSCallback(sub_8096FC8); + } + break; + case 6: + if (gPokemonStorageSystemPtr->unk_0005 == 2) + { + if (sub_809BF20() && ItemIsMail(gPokemonStorageSystemPtr->unk_11f2)) + { + gPokemonStorageSystemPtr->unk_0004 = 5; + } + else + { + SetPSSCallback(sub_8097004); + } + } + break; + case 4: + SetPSSCallback(sub_8097BA0); + break; + case 16: + SetPSSCallback(sub_8097CC0); + break; + case 7: + PlaySE(SE_SELECT); + SetPSSCallback(sub_809789C); + break; + case 8: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097078); + break; + case 9: + PlaySE(SE_SELECT); + gPokemonStorageSystemPtr->unk_08b2 = gPokemonStorage.currentBox + 1; + if (gPokemonStorageSystemPtr->unk_08b2 > 13) + gPokemonStorageSystemPtr->unk_08b2 = 0; + sub_8099C70(gPokemonStorageSystemPtr->unk_08b2); + gPokemonStorageSystemPtr->unk_0004 = 2; + break; + case 10: + PlaySE(SE_SELECT); + gPokemonStorageSystemPtr->unk_08b2 = gPokemonStorage.currentBox - 1; + if (gPokemonStorageSystemPtr->unk_08b2 < 0) + gPokemonStorageSystemPtr->unk_08b2 = 13; + sub_8099C70(gPokemonStorageSystemPtr->unk_08b2); + gPokemonStorageSystemPtr->unk_0004 = 2; + break; + case 11: + if (!sub_809BE80()) + { + if (ItemIsMail(gPokemonStorageSystemPtr->unk_11f2)) + { + gPokemonStorageSystemPtr->unk_0004 = 5; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_809746C); + } + } + else + { + gPokemonStorageSystemPtr->unk_0004 = 4; + } + break; + case 13: + if (sub_809BE80()) + { + gPokemonStorageSystemPtr->unk_0004 = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_80972A8); + } + break; + case 14: + if (!sub_809BEBC()) + { + gPokemonStorageSystemPtr->unk_0004 = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(c3_0808DC50); + } + break; + case 12: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097390); + break; + case 15: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80972FC); + break; + } + break; + case 1: + if (!sub_809AC00()) + { + if (sub_809BF48()) + sub_80986E8(); + else + sub_8098710(); + if (gPokemonStorageSystemPtr->unk_11f6) + BoxSetMosaic(); + gPokemonStorageSystemPtr->unk_0004 = 0; + } + break; + case 2: + if (!sub_8099D34()) + { + gPokemonStorage.currentBox = gPokemonStorageSystemPtr->unk_08b2; + if (!gUnknown_0203847C && !sub_809BF20()) + { + sub_809B440(); + BoxSetMosaic(); + } + gPokemonStorageSystemPtr->unk_0004 = 0; + } + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + gPokemonStorageSystemPtr->unk_0004 = 0; + } + break; + case 4: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_LAST_POKE); + gPokemonStorageSystemPtr->unk_0004 = 6; + break; + case 5: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); + gPokemonStorageSystemPtr->unk_0004 = 6; + break; + case 6: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8096FC8(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + sub_809880C(); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!sub_8098830()) + SetPSSCallback(sub_8096C84); + break; + } +} + +void sub_8097004(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + PlaySE(SE_SELECT); + add_to_c3_somehow(); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!sub_80985CC()) + { + sub_809B0C0(sub_809B0F4()); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 2: + if (!sub_809AC00()) + { + if (gPokemonStorageSystemPtr->unk_11f6) + BoxSetMosaic(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097078(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_IS_SELECTED); + sub_809CE84(); + gPokemonStorageSystemPtr->unk_0004 = 1; + break; + case 1: + switch (sub_809CF30()) + { + case -1: + case 0: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 3: + if (sub_809BE80()) + { + gPokemonStorageSystemPtr->unk_0004 = 2; + } + else + { + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_80972A8); + } + break; + case 5: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_80972FC); + break; + case 4: + if (!sub_809BEBC()) + { + gPokemonStorageSystemPtr->unk_0004 = 2; + } + else + { + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(c3_0808DC50); + } + break; + case 2: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_8097390); + break; + case 1: + if (sub_809BE80()) + { + gPokemonStorageSystemPtr->unk_0004 = 2; + } + else if (ItemIsMail(gPokemonStorageSystemPtr->unk_11f2)) + { + gPokemonStorageSystemPtr->unk_0004 = 3; + } + else + { + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_809746C); + } + break; + case 7: + if (sub_809BE80()) + { + gPokemonStorageSystemPtr->unk_0004 = 2; + } + else if (gPokemonStorageSystemPtr->unk_11f9) + { + gPokemonStorageSystemPtr->unk_0004 = 4; + } + else if (ItemIsMail(gPokemonStorageSystemPtr->unk_11f2)) + { + gPokemonStorageSystemPtr->unk_0004 = 3; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097594); + } + break; + case 6: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097788); + break; + case 8: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80977E4); + break; + } + break; + case 2: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_LAST_POKE); + gPokemonStorageSystemPtr->unk_0004 = 5; + break; + case 4: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG); + gPokemonStorageSystemPtr->unk_0004 = 5; + break; + case 3: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); + gPokemonStorageSystemPtr->unk_0004 = 5; + break; + case 5: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_80972A8(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + sub_809B100(0); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!sub_809B130()) + { + if (gUnknown_0203847C) + SetPSSCallback(sub_8097858); + else + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_80972FC(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + sub_809B100(1); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!sub_809B130()) + { + if (gUnknown_0203847C) + SetPSSCallback(sub_8097858); + else + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void c3_0808DC50(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + sub_809B100(2); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!sub_809B130()) + { + BoxSetMosaic(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097390(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + if (CalculatePlayerPartyCount() == 6) + { + PrintStorageActionText(PC_TEXT_PARTY_FULL); + gPokemonStorageSystemPtr->unk_0004 = 1; + } + else + { + sub_809B0E0(); + sub_809B100(0); + gPokemonStorageSystemPtr->unk_0004 = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + case 2: + if (!sub_809B130()) + { + sub_809880C(); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 3: + if (!sub_8098830()) + { + sub_809B100(1); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 4: + if (!sub_809B130()) + { + sub_80987DC(); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 5: + SetPSSCallback(sub_8097004); + break; + } +} + +void sub_809746C(void) +{ + u8 r4; + + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + sub_8096264(&gPokemonStorageSystemPtr->unk_2370, 0x0007, 0xdaca, 3); + sub_809634C(gUnknown_0203847E); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + r4 = sub_8096368(); + if (r4 == 200); + else if (r4 == 201) + { + sub_8098A5C(); + sub_809635C(); + sub_8096310(); + SetPSSCallback(sub_8096C84); + } + else + { + if (sub_809B62C(r4)) + { + sub_8098A5C(); + sub_809635C(); + sub_8096310(); + gPokemonStorageSystemPtr->unk_0004 = 2; + } + else + { + PrintStorageActionText(PC_TEXT_BOX_IS_FULL); + gPokemonStorageSystemPtr->unk_0004 = 4; + } + gUnknown_0203847E = r4; + } + break; + case 2: + party_compaction(); + sub_8099310(); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 3: + if (!sub_8099374()) + { + sub_809B6BC(); + BoxSetMosaic(); + sub_80987DC(); + SetPSSCallback(sub_8096C84); + } + break; + case 4: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + gPokemonStorageSystemPtr->unk_0004 = 1; + } + break; + } +} + +void sub_8097594(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_RELEASE_POKE); + sub_8098A38(1); + gPokemonStorageSystemPtr->unk_0004++; + // fallthrough + case 1: + switch (ProcessMenuInputNoWrap()) + { + case -1: + case 1: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 0: + sub_8098A5C(); + sub_809B7D4(); + sub_809B6DC(); + gPokemonStorageSystemPtr->unk_0004++; + break; + } + break; + case 2: + sub_809B960(); + if (!sub_809B734()) + { + while (1) + { + s8 r0 = sub_809B960(); + if (r0 == 1) + { + gPokemonStorageSystemPtr->unk_0004++; + break; + } + if (r0 == 0) + { + gPokemonStorageSystemPtr->unk_0004 = 8; + break; + } + } + } + break; + case 3: + sub_809B760(); + sub_809801C(); + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 4: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_BYE_BYE); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 5: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8098A5C(); + if (gUnknown_0203847C) + { + party_compaction(); + sub_8099310(); + gPokemonStorageSystemPtr->unk_0004++; + } + else + { + gPokemonStorageSystemPtr->unk_0004 = 7; + } + } + break; + case 6: + if (!sub_8099374()) + { + sub_809B440(); + BoxSetMosaic(); + sub_80987DC(); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 7: + SetPSSCallback(sub_8096C84); + break; + case 8: + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 9: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_SURPRISE); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 10: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8098A5C(); + sub_8099958(); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 11: + if (!sub_8099990()) + { + sub_809B7AC(); + PrintStorageActionText(PC_TEXT_CAME_BACK); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 12: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PrintStorageActionText(PC_TEXT_WORRIED); + gPokemonStorageSystemPtr->unk_0004++; + } + break; + case 13: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097788(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + sub_809BC18(); + BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!UpdatePaletteFade()) + { + gUnknown_0203847F = 0; + gPokemonStorageSystemPtr->unk_0006 = 0; + SetMainCallback2(sub_8096B5C); + } + break; + } +} + +void sub_80977E4(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_MARK_POKE); + gPokemonStorageSystemPtr->unk_12bc.markings = gPokemonStorageSystemPtr->unk_11f7; + sub_80F7418(gPokemonStorageSystemPtr->unk_11f7, 0xb0, 0x10); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!sub_80F7500()) + { + sub_80F7470(); + sub_8098A5C(); + sub_809BDD8(gPokemonStorageSystemPtr->unk_12bc.markings); + sub_809801C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097858(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + party_compaction(); + sub_8099310(); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!sub_8099374()) + { + sub_80987DC(); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_809789C(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); + sub_809CE84(); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + switch (sub_809CF30()) + { + case -1: + case 0: + sub_809A860(1); + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 11: + PlaySE(SE_SELECT); + SetPSSCallback(sub_8097B44); + break; + case 10: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_8097974); + break; + case 9: + PlaySE(SE_SELECT); + sub_8098A5C(); + SetPSSCallback(sub_8097A64); + break; + } + break; + } +} + +void sub_8097974(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + sub_8098A80(); + PrintStorageActionText(PC_TEXT_PICK_A_THEME); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + gPokemonStorageSystemPtr->unk_0d5e = sub_809CF30(); + switch (gPokemonStorageSystemPtr->unk_0d5e) + { + case -1: + sub_809A860(1); + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 12 ... 15: + PlaySE(SE_SELECT); + gPokemonStorageSystemPtr->unk_0d5e -= 12; + sub_8098AA8(gPokemonStorageSystemPtr->unk_0d5e); + PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); + gPokemonStorageSystemPtr->unk_0004++; + break; + } + break; + case 2: + gPokemonStorageSystemPtr->unk_0d60 = sub_809CF30(); + switch (gPokemonStorageSystemPtr->unk_0d60) + { + case -1: + sub_8098A5C(); + gPokemonStorageSystemPtr->unk_0004 = 0; + break; + case -2: + break; + default: + PlaySE(SE_SELECT); + sub_8098A5C(); + gPokemonStorageSystemPtr->unk_0d60 -= 16; + sub_8099DCC(gPokemonStorageSystemPtr->unk_0d60); + gPokemonStorageSystemPtr->unk_0004++; + break; + } + break; + case 3: + if (!sub_8099E08()) + { + sub_809A860(1); + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097A64(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); + sub_8096264(&gPokemonStorageSystemPtr->unk_2370, 0x0007, 0xdaca, 3); + sub_809634C(gPokemonStorage.currentBox); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + gPokemonStorageSystemPtr->unk_08b2 = sub_8096368(); + switch (gPokemonStorageSystemPtr->unk_08b2) + { + case 200: + break; + default: + sub_8098A5C(); + sub_809635C(); + sub_8096310(); + if (gPokemonStorageSystemPtr->unk_08b2 == 201 || gPokemonStorageSystemPtr->unk_08b2 == gPokemonStorage.currentBox) + { + sub_809A860(1); + SetPSSCallback(sub_8096C84); + } + else + { + gPokemonStorageSystemPtr->unk_0004++; + } + break; + } + break; + case 2: + sub_8099C70(gPokemonStorageSystemPtr->unk_08b2); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 3: + if (!sub_8099D34()) + { + gPokemonStorage.currentBox = gPokemonStorageSystemPtr->unk_08b2; + SetPSSCallback(sub_8096C84); + } + break; + } +} + +void sub_8097B44(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + sub_809BB90(); + BeginNormalPaletteFade(0xffffffff, 0, 0, 16, 0); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 1: + if (!UpdatePaletteFade()) + { + gUnknown_0203847F = 1; + gPokemonStorageSystemPtr->unk_0006 = 1; + SetMainCallback2(sub_8096B5C); + } + break; + } +} + +void sub_8097BA0(void) +{ + switch (gPokemonStorageSystemPtr->unk_0004) + { + case 0: + if (sub_809BF20()) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + gPokemonStorageSystemPtr->unk_0004 = 1; + } + else + { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_EXIT_BOX); + sub_8098A38(0); + gPokemonStorageSystemPtr->unk_0004 = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + case 2: + switch (ProcessMenuInputNoWrap()) + { + case 1: + case -1: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case 0: + PlaySE(SE_PC_OFF); + sub_8098A5C(); + gPokemonStorageSystemPtr->unk_0004++; + break; + } + break; + case 3: + gPokemonStorageSystemPtr->unk_000c.tileTag = 0x000e; + gPokemonStorageSystemPtr->unk_000c.paletteTag = 0xdad0; + gPokemonStorageSystemPtr->unk_000c.unk04 = 20; + gPokemonStorageSystemPtr->unk_000c.unk06 = 0; + sub_80C5E38(&gPokemonStorageSystemPtr->unk_000c); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 4: + if (sub_80C5F98()) + { + gPlayerPartyCount = CalculatePlayerPartyCount(); + SetMainCallback2(sub_80961A8); + } + break; + } +} + +void sub_8097CC0(void) { + switch (gPokemonStorageSystemPtr->unk_0004) { + case 0: + if (sub_809BF20()) { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + gPokemonStorageSystemPtr->unk_0004 = 1; + } + else { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_CONTINUE_BOX); + sub_8098A38(0); + gPokemonStorageSystemPtr->unk_0004 = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + case 2: + switch (ProcessMenuInputNoWrap()) { + case 0: + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + break; + case -1: + case 1: + PlaySE(SE_PC_OFF); + sub_8098A5C(); + gPokemonStorageSystemPtr->unk_0004++; + break; + } + break; + case 3: + gPokemonStorageSystemPtr->unk_000c.tileTag = 0x000e; + gPokemonStorageSystemPtr->unk_000c.paletteTag = 0xdad0; + gPokemonStorageSystemPtr->unk_000c.unk04 = 20; + gPokemonStorageSystemPtr->unk_000c.unk06 = 0; + sub_80C5E38(&gPokemonStorageSystemPtr->unk_000c); + gPokemonStorageSystemPtr->unk_0004++; + break; + case 4: + if (sub_80C5F98()) { + gPlayerPartyCount = CalculatePlayerPartyCount(); + SetMainCallback2(sub_80961A8); + } + break; + } +} + +void sub_8097DE0(void) +{ + gPokemonStorageSystemPtr->unk_0007 = 0; + gPokemonStorageSystemPtr->unk_0008 = 0; + gPokemonStorageSystemPtr->unk_000a = 0; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(30); + DmaCopy16Defvars(3, gPokemonStorageScrollingBGTile, BG_SCREEN_ADDR(28), sizeof gPokemonStorageScrollingBGTile); + LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, BG_SCREEN_ADDR(30)); + LoadPalette(gPokemonStorageScrollingBGPalette, 0xd0, 0x10); +} + +void sub_8097E44(void) +{ + if (++gPokemonStorageSystemPtr->unk_0007 >= 2) + { + gPokemonStorageSystemPtr->unk_0007 = 0; + gPokemonStorageSystemPtr->unk_0008--; + gPokemonStorageSystemPtr->unk_000a++; + } +} + +void sub_8097E70(void) +{ + LZ77UnCompVram(gPSSMenuHeader_Gfx, BG_SCREEN_ADDR(10)); + LZ77UnCompWram(gPSSMenuHeader_Tilemap, gUnknown_02039760); + sub_809D034(BG_SCREEN_ADDR(15), 0, 0, gUnknown_02039760, 0, 0, 10, 20); + LoadPalette(gPSSMenu1_Pal, 0x10, 0x20); + LoadPalette(gPSSMenu2_Pal, 0x00, 0x20); + LoadPalette(gUnknown_083B6D74, 0xB0, 0x20); + LoadPalette(gUnknown_083B6D94, 0xC0, 0x20); + LoadPalette(gUnknownPalette_81E6692 + 1, 0xF1, 0x02); + LoadPalette(gUnknownPalette_81E6692 + 1, 0xF2, 0x02); + LoadPalette(gUnknownPalette_81E6692 + 5, 0xF3, 0x02); + LoadPalette(gUnknownPalette_81E6692 + 12, 0xF4, 0x04); + LoadPalette(gUnknownPalette_81E6692 + 10, 0xF6, 0x04); + LoadPalette(gUnknownPalette_81E6692 + 2, 0xFF, 0x02); + LoadSpritePalette(&gWaveformSpritePalette); + sub_80980D4(); + sub_8097F58(); + sub_8097FB8(); + sub_809801C(); +} + +asm(".section .text.8098898"); + +void PrintStorageActionText(u8 index) { + u8 *ptr; + + MenuDrawTextWindow(10, 16, 29, 19); + + switch (gPCStorageActionTexts[index].format) + { + + case PC_TEXT_FMT_UNK_02: + ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr, gPokemonStorageSystemPtr->unk_11fa); + break; + + case PC_TEXT_FMT_UNK_05: + ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr, gPokemonStorageSystemPtr->unk_26e4); + break; + + case PC_TEXT_FMT_MON_NAME: + // {var} + " is selected." + ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPokemonStorageSystemPtr->unk_11fa); + ptr = StringCopy(ptr, gPCStorageActionTexts[index].text); + break; + + case PC_TEXT_FMT_MON_NAME_2: + // {var} + " was released." + ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPokemonStorageSystemPtr->unk_26e4); +#if ENGLISH + ptr = StringCopy(ptr, gPCStorageActionTexts[index].text); +#elif GERMAN + ptr = de_sub_8073174(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text); +#endif + break; + + case PC_TEXT_FMT_UNK_03: + { + const u8 *stringLength; + const u8 *text; + + text = gPCStorageActionTexts[index].text; + stringLength = &text[StringLength(text)] + 1; + + ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr, gPokemonStorageSystemPtr->unk_11fa); + ptr = StringCopy(ptr, stringLength); + } + break; + + case PC_TEXT_FMT_MON_NAME_AFTER_EXCL_MARK: + // "Bye-bye, ".substr(0, -1) + {var} + "Bye-bye, !".substr(-1, 1) + { + const u8 *stringLength; + const u8 *text; + + text = gPCStorageActionTexts[index].text; + stringLength = &text[StringLength(text)] - 1; + + ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text); + ptr = StringCopy(ptr - 1, gPokemonStorageSystemPtr->unk_26e4); + ptr = StringCopy(ptr, stringLength); + } + break; + + case PC_TEXT_FMT_NORMAL: + default: + ptr = StringCopy(gPokemonStorageSystemPtr->unk_2694, gPCStorageActionTexts[index].text); + break; + } + + while (ptr < gPokemonStorageSystemPtr->unk_26a6) + { + ptr[0] = CHAR_SPACE; + ptr++; + } + + ptr[0] = EOS; + MenuPrint(gPokemonStorageSystemPtr->unk_2694, 11, 17); +} diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c new file mode 100644 index 000000000..9e0052b89 --- /dev/null +++ b/src/pokemon/pokemon_storage_system_3.c @@ -0,0 +1,16 @@ + +// Includes +#include "global.h" +#include "pokemon_storage_system.h" + +// Static type declarations + +// Static RAM declarations + +EWRAM_DATA u16 gUnknown_02039760[0x600] = {}; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/pokemon/pokemon_summary_screen.c b/src/pokemon/pokemon_summary_screen.c index 9563bc08f..fb8363569 100644 --- a/src/pokemon/pokemon_summary_screen.c +++ b/src/pokemon/pokemon_summary_screen.c @@ -146,7 +146,6 @@ extern const u8 gUnknown_08E74E88[]; extern const u8 gUnknown_08E73508[]; extern const u8 gStatusScreen_Gfx[]; extern const u8 gFontDefaultPalette[]; -extern const u8 gUnknownPalette_81E6692[]; extern const u8 gAbilityNames[][13]; extern const u8 * const gAbilityDescriptions[]; extern const u8 * const gContestEffectStrings[]; @@ -940,21 +939,21 @@ static bool8 LoadPokemonSummaryScreenGraphics(void) static void sub_809E044(void) { - LoadPalette(&gUnknownPalette_81E6692[28], 129, 2); - LoadPalette(&gUnknownPalette_81E6692[30], 136, 2); - LoadPalette(&gUnknownPalette_81E6692[28], 143, 2); - LoadPalette(&gUnknownPalette_81E6692[30], 137, 2); - LoadPalette(&gUnknownPalette_81E6692[12], 209, 4); - LoadPalette(&gUnknownPalette_81E6692[20], 211, 4); - LoadPalette(&gUnknownPalette_81E6692[28], 213, 4); - LoadPalette(&gUnknownPalette_81E6692[12], 215, 4); - LoadPalette(&gUnknownPalette_81E6692[8], 217, 4); - LoadPalette(&gUnknownPalette_81E6692[16], 219, 4); - LoadPalette(&gUnknownPalette_81E6692[4], 221, 2); - LoadPalette(&gUnknownPalette_81E6692[6], 222, 2); - LoadPalette(&gUnknownPalette_81E6692[2], 223, 2); + LoadPalette(gUnknownPalette_81E6692 + 14, 129, 2); + LoadPalette(gUnknownPalette_81E6692 + 15, 136, 2); + LoadPalette(gUnknownPalette_81E6692 + 14, 143, 2); + LoadPalette(gUnknownPalette_81E6692 + 15, 137, 2); + LoadPalette(gUnknownPalette_81E6692 + 6, 209, 4); + LoadPalette(gUnknownPalette_81E6692 + 10, 211, 4); + LoadPalette(gUnknownPalette_81E6692 + 14, 213, 4); + LoadPalette(gUnknownPalette_81E6692 + 6, 215, 4); + LoadPalette(gUnknownPalette_81E6692 + 4, 217, 4); + LoadPalette(gUnknownPalette_81E6692 + 8, 219, 4); + LoadPalette(gUnknownPalette_81E6692 + 2, 221, 2); + LoadPalette(gUnknownPalette_81E6692 + 3, 222, 2); + LoadPalette(gUnknownPalette_81E6692 + 1, 223, 2); LoadPalette(gFontDefaultPalette, 240, 32); - LoadPalette(&gUnknownPalette_81E6692[6], 249, 2); + LoadPalette(gUnknownPalette_81E6692 + 3, 249, 2); } static void SummaryScreenExit(u8 taskId) diff --git a/src/pokenav_before.c b/src/pokenav_before.c index 8a67390ad..ee5bdb1cb 100644 --- a/src/pokenav_before.c +++ b/src/pokenav_before.c @@ -102,7 +102,6 @@ extern const u16 gPokenavConditionSearch2_Pal[]; extern const u8 gUnknown_083E0334[]; extern const u16 gUnknown_083E02B4[]; extern const u8 gPokenavConditionSearch2_Gfx[]; -extern const u8 gUnknownPalette_81E6692[]; extern const u8 gUnknown_083E0254[]; extern const u8 gUnknown_08E9FEB4[]; extern const u8 gUnknown_083E01AC[]; -- cgit v1.2.3 From 4facfe910285787778666eeee747b4c1c7201d98 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 14:43:24 -0500 Subject: through sub_80980D4 (nonmatching) --- src/pokemon/pokemon_storage_system_2.c | 321 ++++++++++++++++++++++++++++----- 1 file changed, 276 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index 5c72d02e9..f8ae1c013 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -66,9 +66,13 @@ void sub_8097E44(void); void sub_8097E70(void); void sub_8097F58(void); void sub_8097FB8(void); -void BoxSetMosaic(void); void sub_809801C(void); +void BoxSetMosaic(void); +void sub_8098090(struct Sprite *sprite); void sub_80980D4(void); +void sub_80981F0(u16 species, u32 pid); +void sub_80982B4(void); +void sub_8098350(void); void sub_8098400(void); void add_to_c3_somehow(void); bool8 sub_80985CC(void); @@ -191,50 +195,6 @@ const struct SpritePalette gWaveformSpritePalette = { WaveformPalette, 0xdacd }; -const struct SpriteSheet gWaveformSpriteSheet = { - WaveformTiles, 0x1c0, 0x0005 -}; - -const struct SpriteSheet gUnknown_083B6DCC = { - ePokemonStorageSystem.unk_2784, 0x800, 0x0002 -}; - -const struct SpritePalette gUnknown_083B6DD4 = { - ePokemonStorageSystem.unk_2704, 0xdac7 -}; - -const struct OamData gOamData_83B6EAC; - -const struct SpriteTemplate gSpriteTemplate_83B6DDC = { - 0x0002, 0xdac7, &gOamData_83B6EAC, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy -}; - -const struct StorageAction gPCStorageActionTexts[] = { - {PCText_ExitBox, 0}, - {PCText_WhatYouDo, 0}, - {PCText_PickATheme, 0}, - {PCText_PickAWallpaper, 0}, - {PCText_IsSelected, 1}, - {PCText_JumpToWhichBox, 0}, - {PCText_DepositInWhichBox, 0}, - {PCText_WasDeposited, 1}, - {PCText_BoxIsFull, 0}, - {PCText_ReleasePoke, 0}, - {PCText_WasReleased, 4}, - {PCText_ByeBye, 6}, - {PCText_MarkPoke, 0}, - {PCText_LastPoke, 0}, - {PCText_PartyFull, 0}, - {PCText_HoldingPoke, 0}, - {PCText_WhichOneWillTake, 0}, - {PCText_CantReleaseEgg, 0}, - {PCText_ContinueBox, 0}, - {PCText_CameBack, 1}, - {PCText_Worried, 0}, - {PCText_Surprise, 0}, - {PCText_PleaseRemoveMail, 0} -}; - // .text @@ -1484,6 +1444,249 @@ void sub_8097E70(void) sub_809801C(); } +void sub_8097F58(void) +{ + gPokemonStorageSystemPtr->unk_12ac = sub_80F7940(0x000d, 0xdace, 0); + gPokemonStorageSystemPtr->unk_12ac->oam.priority = 0; + gPokemonStorageSystemPtr->unk_12ac->subpriority = 1; + gPokemonStorageSystemPtr->unk_12ac->pos1.x = 0x28; + gPokemonStorageSystemPtr->unk_12ac->pos1.y = 0x95; + gPokemonStorageSystemPtr->unk_12b8 = BG_CHAR_ADDR(4) + 32 * GetSpriteTileStartByTag(0x000d); +} + +const struct SpriteTemplate gSpriteTemplate_83B6EFC; + +void sub_8097FB8(void) +{ + u16 i; + struct SpriteSheet sheet = {WaveformTiles, 0x1c0, 0x0005}; + + LoadSpriteSheet(&sheet); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gSpriteTemplate_83B6EFC, i * 63 + 8, 9, 2); + gPokemonStorageSystemPtr->unk_12b0[i] = gSprites + spriteId; + } +} + +void sub_809801C(void) +{ + sub_80981F0(gPokemonStorageSystemPtr->unk_11f0, gPokemonStorageSystemPtr->unk_11ec); + sub_80982B4(); + sub_8098350(); +} + +void BoxSetMosaic(void) +{ + sub_809801C(); + if (gPokemonStorageSystemPtr->unk_2700) + { + gPokemonStorageSystemPtr->unk_2700->oam.mosaic = TRUE; + gPokemonStorageSystemPtr->unk_2700->data[0] = 10; + gPokemonStorageSystemPtr->unk_2700->data[1] = 1; + gPokemonStorageSystemPtr->unk_2700->callback = sub_8098090; + REG_MOSAIC = (gPokemonStorageSystemPtr->unk_2700->data[0] << 12) | (gPokemonStorageSystemPtr->unk_2700->data[0] << 8); + } +} + +void sub_8098090(struct Sprite *sprite) +{ + sprite->data[0] -= sprite->data[1]; + if (sprite->data[0] < 0) + sprite->data[0] = 0; + REG_MOSAIC = (sprite->data[0] << 12) | (sprite->data[0] << 8); + if (sprite->data[0] == 0) + { + sprite->oam.mosaic = FALSE; + sprite->callback = SpriteCallbackDummy; + } +} + +// sub_80980D4 + +const struct OamData gOamData_83B6EAC; + +#ifdef NONMATCHING +void sub_80980D4(void) +{ + u16 i; + u16 tileStart; + u8 palSlot; + u8 spriteId; + struct SpriteSheet sheet = {gPokemonStorageSystemPtr->unk_2784, 0x800, 0x0002}; + struct SpritePalette palette = {gPokemonStorageSystemPtr->unk_2704, 0xdac7}; + struct SpriteTemplate template = { + 0x0002, 0xdac7, &gOamData_83B6EAC, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy + }; + + for (i = 0; i < 0x800; i++) + gPokemonStorageSystemPtr->unk_2784[i] = 0; + for (i = 0; i < 0x10; i++) + gPokemonStorageSystemPtr->unk_2704[i] = 0; + + gPokemonStorageSystemPtr->unk_2700 = NULL; + if ((tileStart = LoadSpriteSheet(&sheet)) != 0 + && (palSlot = LoadSpritePalette(&palette)) != 0xff + && (spriteId = CreateSprite(&template, 0x28, 0x30, 0)) != MAX_SPRITES) + { + // FIXME this gets compiled as a separate block between the palSlot check and the spriteId check + gPokemonStorageSystemPtr->unk_2700 = gSprites + spriteId; + gPokemonStorageSystemPtr->unk_26fa = palSlot * 16 + 0x100; + gPokemonStorageSystemPtr->unk_26fc = BG_CHAR_ADDR(4) + tileStart * 32; + } + + if (gPokemonStorageSystemPtr->unk_2700 == NULL) + { + FreeSpriteTilesByTag(0x0002); + FreeSpritePaletteByTag(0xdac7); + } +} +#else + +const struct SpriteSheet gUnknown_083B6DCC = {ePokemonStorageSystem.unk_2784, 0x800, 0x0002}; +const struct SpritePalette gUnknown_083B6DD4 = {ePokemonStorageSystem.unk_2704, 0xdac7}; +const struct SpriteTemplate gSpriteTemplate_83B6DDC = { + 0x0002, 0xdac7, &gOamData_83B6EAC, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy +}; + +__attribute__((naked)) void sub_80980D4(void) +{ + asm_unified("\tpush {r4,r5,lr}\n" + "\tsub sp, 0x28\n" + "\tldr r0, _08098150 @ =gUnknown_083B6DCC\n" + "\tldr r1, [r0, 0x4]\n" + "\tldr r0, [r0]\n" + "\tstr r0, [sp, 0x18]\n" + "\tstr r1, [sp, 0x1C]\n" + "\tldr r0, _08098154 @ =gUnknown_083B6DD4\n" + "\tldr r1, [r0, 0x4]\n" + "\tldr r0, [r0]\n" + "\tstr r0, [sp, 0x20]\n" + "\tstr r1, [sp, 0x24]\n" + "\tmov r1, sp\n" + "\tldr r0, _08098158 @ =gSpriteTemplate_83B6DDC\n" + "\tldm r0!, {r2-r4}\n" + "\tstm r1!, {r2-r4}\n" + "\tldm r0!, {r2-r4}\n" + "\tstm r1!, {r2-r4}\n" + "\tmovs r1, 0\n" + "\tadd r5, sp, 0x18\n" + "\tldr r4, _0809815C @ =gSharedMem + 0x2784\n" + "\tmovs r3, 0\n" + "\tldr r2, _08098160 @ =0x000007ff\n" + "_08098102:\n" + "\tadds r0, r1, r4\n" + "\tstrb r3, [r0]\n" + "\tadds r0, r1, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r1, r0, 16\n" + "\tcmp r1, r2\n" + "\tbls _08098102\n" + "\tmovs r1, 0\n" + "\tldr r3, _08098164 @ =gSharedMem + 0x2704\n" + "\tmovs r2, 0\n" + "_08098116:\n" + "\tlsls r0, r1, 1\n" + "\tadds r0, r3\n" + "\tstrh r2, [r0]\n" + "\tadds r0, r1, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r1, r0, 16\n" + "\tcmp r1, 0xF\n" + "\tbls _08098116\n" + "\tldr r0, _08098168 @ =gSharedMem\n" + "\tmovs r1, 0x9C\n" + "\tlsls r1, 6\n" + "\tadds r0, r1\n" + "\tmovs r1, 0\n" + "\tstr r1, [r0]\n" + "\tadds r0, r5, 0\n" + "\tbl LoadSpriteSheet\n" + "\tlsls r0, 16\n" + "\tlsrs r5, r0, 16\n" + "\tcmp r5, 0\n" + "\tbeq _080981C4\n" + "\tadd r0, sp, 0x20\n" + "\tbl LoadSpritePalette\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tcmp r4, 0xFF\n" + "\tbeq _080981C4\n" + "\tb _080981B0\n" + "\t.align 2, 0\n" + "_08098150: .4byte gUnknown_083B6DCC\n" + "_08098154: .4byte gUnknown_083B6DD4\n" + "_08098158: .4byte gSpriteTemplate_83B6DDC\n" + "_0809815C: .4byte gSharedMem + 0x2784\n" + "_08098160: .4byte 0x000007ff\n" + "_08098164: .4byte gSharedMem + 0x2704\n" + "_08098168: .4byte gSharedMem\n" + "_0809816C:\n" + "\tldr r2, _0809819C @ =gSharedMem\n" + "\tmovs r0, 0x9C\n" + "\tlsls r0, 6\n" + "\tadds r3, r2, r0\n" + "\tlsls r0, r1, 4\n" + "\tadds r0, r1\n" + "\tlsls r0, 2\n" + "\tldr r1, _080981A0 @ =gSprites\n" + "\tadds r0, r1\n" + "\tstr r0, [r3]\n" + "\tlsls r0, r4, 4\n" + "\tmovs r1, 0x80\n" + "\tlsls r1, 1\n" + "\tadds r0, r1\n" + "\tldr r3, _080981A4 @ =0x000026fa\n" + "\tadds r1, r2, r3\n" + "\tstrh r0, [r1]\n" + "\tldr r4, _080981A8 @ =0x000026fc\n" + "\tadds r2, r4\n" + "\tlsls r0, r5, 5\n" + "\tldr r1, _080981AC @ =0x06010000\n" + "\tadds r0, r1\n" + "\tstr r0, [r2]\n" + "\tb _080981C4\n" + "\t.align 2, 0\n" + "_0809819C: .4byte gSharedMem\n" + "_080981A0: .4byte gSprites\n" + "_080981A4: .4byte 0x000026fa\n" + "_080981A8: .4byte 0x000026fc\n" + "_080981AC: .4byte 0x06010000\n" + "_080981B0:\n" + "\tmov r0, sp\n" + "\tmovs r1, 0x28\n" + "\tmovs r2, 0x30\n" + "\tmovs r3, 0\n" + "\tbl CreateSprite\n" + "\tlsls r0, 24\n" + "\tlsrs r1, r0, 24\n" + "\tcmp r1, 0x40\n" + "\tbne _0809816C\n" + "_080981C4:\n" + "\tldr r0, _080981E8 @ =gSharedMem\n" + "\tmovs r2, 0x9C\n" + "\tlsls r2, 6\n" + "\tadds r0, r2\n" + "\tldr r0, [r0]\n" + "\tcmp r0, 0\n" + "\tbne _080981DE\n" + "\tmovs r0, 0x2\n" + "\tbl FreeSpriteTilesByTag\n" + "\tldr r0, _080981EC @ =0x0000dac7\n" + "\tbl FreeSpritePaletteByTag\n" + "_080981DE:\n" + "\tadd sp, 0x28\n" + "\tpop {r4,r5}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_080981E8: .4byte gSharedMem\n" + "_080981EC: .4byte 0x0000dac7"); +} +#endif + +extern const struct StorageAction gPCStorageActionTexts[]; + asm(".section .text.8098898"); void PrintStorageActionText(u8 index) { @@ -1564,3 +1767,31 @@ void PrintStorageActionText(u8 index) { ptr[0] = EOS; MenuPrint(gPokemonStorageSystemPtr->unk_2694, 11, 17); } + +// FIXME: move this back + +const struct StorageAction gPCStorageActionTexts[] = { + {PCText_ExitBox, 0}, + {PCText_WhatYouDo, 0}, + {PCText_PickATheme, 0}, + {PCText_PickAWallpaper, 0}, + {PCText_IsSelected, 1}, + {PCText_JumpToWhichBox, 0}, + {PCText_DepositInWhichBox, 0}, + {PCText_WasDeposited, 1}, + {PCText_BoxIsFull, 0}, + {PCText_ReleasePoke, 0}, + {PCText_WasReleased, 4}, + {PCText_ByeBye, 6}, + {PCText_MarkPoke, 0}, + {PCText_LastPoke, 0}, + {PCText_PartyFull, 0}, + {PCText_HoldingPoke, 0}, + {PCText_WhichOneWillTake, 0}, + {PCText_CantReleaseEgg, 0}, + {PCText_ContinueBox, 0}, + {PCText_CameBack, 1}, + {PCText_Worried, 0}, + {PCText_Surprise, 0}, + {PCText_PleaseRemoveMail, 0} +}; -- cgit v1.2.3 From ebae5167939d1a10a2a37324063bb4f70c43a4ea Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 17:29:50 -0500 Subject: through sub_8098350 --- src/pokemon/pokemon_storage_system_2.c | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index f8ae1c013..7f97d7681 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -1,7 +1,10 @@ // Includes #include "global.h" +#include "decompress.h" #include "constants/songs.h" +#include "constants/species.h" +#include "data2.h" #include "sound.h" #include "ewram.h" #include "task.h" @@ -1685,6 +1688,61 @@ __attribute__((naked)) void sub_80980D4(void) } #endif +void sub_80981F0(u16 species, u32 pid) +{ + if (gPokemonStorageSystemPtr->unk_2700) + { + if (species != SPECIES_NONE) + { + HandleLoadSpecialPokePic(gMonFrontPicTable + species, gMonFrontPicCoords[species].coords, 1, (intptr_t)gPokemonStorageSystemPtr->unk_4784, gPokemonStorageSystemPtr->unk_2784, species, pid); + LZ77UnCompWram(gPokemonStorageSystemPtr->unk_11e8, gPokemonStorageSystemPtr->unk_2704); + CpuCopy32(gPokemonStorageSystemPtr->unk_2784, gPokemonStorageSystemPtr->unk_26fc, 0x800); + LoadPalette(gPokemonStorageSystemPtr->unk_2704, gPokemonStorageSystemPtr->unk_26fa, 0x20); + gPokemonStorageSystemPtr->unk_2700->invisible = FALSE; + } + else + { + gPokemonStorageSystemPtr->unk_2700->invisible = TRUE; + } + } +} + +void sub_80982B4(void) +{ + if (gPokemonStorageSystemPtr->unk_11f0) + { + sub_80F7A10(gPokemonStorageSystemPtr->unk_11f7, gPokemonStorageSystemPtr->unk_12b8); + gPokemonStorageSystemPtr->unk_12ac->invisible = FALSE; + } + else + { + gPokemonStorageSystemPtr->unk_12ac->invisible = TRUE; + } + MenuZeroFillWindowRect(0, 11, 9, 17); + MenuPrint(gPokemonStorageSystemPtr->unk_127a, 1, 16); + MenuPrint(gPokemonStorageSystemPtr->unk_120f, 1, 11); + MenuPrint(gPokemonStorageSystemPtr->unk_1234, 0, 13); + MenuPrint(gPokemonStorageSystemPtr->unk_1259, 1, 15); +} + +void sub_8098350(void) +{ + u16 i; + + if (gPokemonStorageSystemPtr->unk_11f0) + { + sub_809D034(BG_SCREEN_ADDR(15), 1, 0, gUnknown_02039760, 1, 0, 8, 2); + for (i = 0; i < 2; i++) + StartSpriteAnimIfDifferent(gPokemonStorageSystemPtr->unk_12b0[i], i * 2 + 1); + } + else + { + sub_809D034(BG_SCREEN_ADDR(15), 1, 0, gUnknown_02039760, 10, 0, 8, 2); + for (i = 0; i < 2; i++) + StartSpriteAnim(gPokemonStorageSystemPtr->unk_12b0[i], i * 2); + } +} + extern const struct StorageAction gPCStorageActionTexts[]; asm(".section .text.8098898"); -- cgit v1.2.3 From 2eb10c6f2d16729dde12b0fd26cac3f45b85a557 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 20:18:46 -0500 Subject: close swiss cheese in pokemon_storage_system_2.c --- src/pokemon/pokemon_storage_system_2.c | 282 +++++++++++++++++++++++++++++---- 1 file changed, 255 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index 7f97d7681..ff6f1f587 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -78,6 +78,9 @@ void sub_80982B4(void); void sub_8098350(void); void sub_8098400(void); void add_to_c3_somehow(void); +void sub_8098780(void); +void sub_8098690(bool8 flag); +void sub_8099200(u8 a0); bool8 sub_80985CC(void); void sub_80986E8(void); void sub_8098710(void); @@ -93,6 +96,8 @@ void sub_8098AA8(u8 a0); void sub_8098B48(void); void sub_8099310(void); bool8 sub_8099374(void); +void sub_80994A8(s16 a0); +void sub_809954C(void); void sub_8099958(void); bool8 sub_8099990(void); void sub_809BB90(void); @@ -109,6 +114,7 @@ void sub_809B0C0(u8 a0); void sub_809B0D4(void); void sub_809B0E0(void); u8 sub_809B0F4(void); +void sub_809B068(void); void sub_809B100(u8 a0); bool8 sub_809B130(void); void sub_809B440(void); @@ -134,6 +140,8 @@ s16 sub_809CF30(void); void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); void sub_809CFF0(void); void sub_809D034(void *dest, u16 dLeft, u16 dTop, const void *src, u16 sLeft, u16 sTop, u16 width, u16 height); +void sub_809D104(void *dest, u16 dLeft, u16 dTop, const void *src, u16 sLeft, u16 sTop, u16 width, u16 height); +void sub_809D16C(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height); // .rodata @@ -1743,9 +1751,192 @@ void sub_8098350(void) } } -extern const struct StorageAction gPCStorageActionTexts[]; +void sub_8098400(void) +{ + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(15); + LZ77UnCompVram(gPSSMenuMisc_Gfx, BG_SCREEN_ADDR(13)); + LZ77UnCompWram(gPSSMenuMisc_Tilemap, gPokemonStorageSystemPtr->unk_00a8); + LoadPalette(gPSSMenu3_Pal, 0x20, 0x20); + LoadPalette(gPSSMenu4_Pal, 0x30, 0x20); + DmaClear16(3, BG_SCREEN_ADDR(15), 0x800); + sub_8098780(); + if (gUnknown_0203847C) + { + sub_8098690(TRUE); + sub_8099200(1); + sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, 0, 12, 22); + } + else + { + sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, 20, 12, 2); + sub_8098690(TRUE); + } + gPokemonStorageSystemPtr->unk_08af = 0; +} + +void sub_80984E8(void) +{ + gPokemonStorageSystemPtr->unk_08a8 = 20; + gPokemonStorageSystemPtr->unk_08aa = 2; + gPokemonStorageSystemPtr->unk_08ad = 0; + sub_8099200(0); +} + +bool8 sub_8098520(void) +{ + if (gPokemonStorageSystemPtr->unk_08ad == 20) + return FALSE; + gPokemonStorageSystemPtr->unk_08a8--; + gPokemonStorageSystemPtr->unk_08aa++; + sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, gPokemonStorageSystemPtr->unk_08a8, 12, gPokemonStorageSystemPtr->unk_08aa); + sub_80994A8(8); + if (++gPokemonStorageSystemPtr->unk_08ad == 20) + { + gUnknown_0203847C = 1; + return FALSE; + } + return TRUE; +} + +void add_to_c3_somehow(void) +{ + gPokemonStorageSystemPtr->unk_08a8 = 0; + gPokemonStorageSystemPtr->unk_08aa = 22; + gPokemonStorageSystemPtr->unk_08ad = 0; +} + +bool8 sub_80985CC(void) +{ + if (gPokemonStorageSystemPtr->unk_08ad == 20) + return FALSE; + gPokemonStorageSystemPtr->unk_08a8++; + gPokemonStorageSystemPtr->unk_08aa--; + sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, gPokemonStorageSystemPtr->unk_08a8, 12, gPokemonStorageSystemPtr->unk_08aa); + sub_809D16C(BG_SCREEN_ADDR(15), 10, gPokemonStorageSystemPtr->unk_08aa, 12, 1); + sub_80994A8(-8); + if (++gPokemonStorageSystemPtr->unk_08ad == 20) + { + gUnknown_0203847C = 0; + sub_809954C(); + party_compaction(); + sub_809D034(BG_SCREEN_ADDR(15), 21, 0, gPokemonStorageSystemPtr->unk_00a8, 12, 0, 1, 2); + return FALSE; + } + return TRUE; +} + +void sub_8098690(bool8 flag) +{ + if (flag) + sub_809D034(BG_SCREEN_ADDR(15), 21, 0, gPokemonStorageSystemPtr->unk_00a8, 12, 0, 9, 2); + else + sub_809D034(BG_SCREEN_ADDR(15), 21, 0, gPokemonStorageSystemPtr->unk_00a8, 12, 2, 9, 2); +} + +void sub_80986E8(void) +{ + gPokemonStorageSystemPtr->unk_08af = 1; + gPokemonStorageSystemPtr->unk_08b0 = 30; + gPokemonStorageSystemPtr->unk_08b1 = 1; +} + +void sub_8098710(void) +{ + if (gPokemonStorageSystemPtr->unk_08af) + { + gPokemonStorageSystemPtr->unk_08af = 0; + sub_8098690(TRUE); + } +} + +void sub_8098734(void) +{ + if (gPokemonStorageSystemPtr->unk_08af && ++gPokemonStorageSystemPtr->unk_08b0 > 30) + { + gPokemonStorageSystemPtr->unk_08b0 = 0; + gPokemonStorageSystemPtr->unk_08b1 = gPokemonStorageSystemPtr->unk_08b1 ? FALSE : TRUE; + sub_8098690(gPokemonStorageSystemPtr->unk_08b1); + } +} + +void sub_8098780(void) +{ + int i; + + for (i = 1; i < PARTY_SIZE; i++) + { + u16 r1; + bool32 r0 = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); + if (r0) + r0 = TRUE; + r1 = r0 ? 12 : 16; + sub_809D104(gPokemonStorageSystemPtr->unk_00a8, 7, (i - 1) * 3 + 1, gPokemonStorageSystemPtr->unk_00a8, r1, 4, 4, 3); + } +} + +void sub_80987DC(void) +{ + sub_8098780(); + sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, 0, 12, 22); +} + +void sub_809880C(void) +{ + gPokemonStorageSystemPtr->unk_08ae = 0; + PlaySE(SE_WIN_OPEN); + sub_80984E8(); +} + +bool8 sub_8098830(void) +{ + switch (gPokemonStorageSystemPtr->unk_08ae) + { + case 0: + if (!sub_8098520()) + { + sub_809B068(); + gPokemonStorageSystemPtr->unk_08ae++; + } + break; + case 1: + if (!sub_809AC00()) + { + if (gPokemonStorageSystemPtr->unk_11f6) + BoxSetMosaic(); + gPokemonStorageSystemPtr->unk_08ae++; + } + break; + case 2: + return FALSE; + } + return TRUE; +} -asm(".section .text.8098898"); +const struct StorageAction gPCStorageActionTexts[] = { + {PCText_ExitBox, 0}, + {PCText_WhatYouDo, 0}, + {PCText_PickATheme, 0}, + {PCText_PickAWallpaper, 0}, + {PCText_IsSelected, 1}, + {PCText_JumpToWhichBox, 0}, + {PCText_DepositInWhichBox, 0}, + {PCText_WasDeposited, 1}, + {PCText_BoxIsFull, 0}, + {PCText_ReleasePoke, 0}, + {PCText_WasReleased, 4}, + {PCText_ByeBye, 6}, + {PCText_MarkPoke, 0}, + {PCText_LastPoke, 0}, + {PCText_PartyFull, 0}, + {PCText_HoldingPoke, 0}, + {PCText_WhichOneWillTake, 0}, + {PCText_CantReleaseEgg, 0}, + {PCText_ContinueBox, 0}, + {PCText_CameBack, 1}, + {PCText_Worried, 0}, + {PCText_Surprise, 0}, + {PCText_PleaseRemoveMail, 0} +}; void PrintStorageActionText(u8 index) { u8 *ptr; @@ -1826,30 +2017,67 @@ void PrintStorageActionText(u8 index) { MenuPrint(gPokemonStorageSystemPtr->unk_2694, 11, 17); } -// FIXME: move this back +const struct OamData gOamData_83B6EAC = { + .size = 3 +}; -const struct StorageAction gPCStorageActionTexts[] = { - {PCText_ExitBox, 0}, - {PCText_WhatYouDo, 0}, - {PCText_PickATheme, 0}, - {PCText_PickAWallpaper, 0}, - {PCText_IsSelected, 1}, - {PCText_JumpToWhichBox, 0}, - {PCText_DepositInWhichBox, 0}, - {PCText_WasDeposited, 1}, - {PCText_BoxIsFull, 0}, - {PCText_ReleasePoke, 0}, - {PCText_WasReleased, 4}, - {PCText_ByeBye, 6}, - {PCText_MarkPoke, 0}, - {PCText_LastPoke, 0}, - {PCText_PartyFull, 0}, - {PCText_HoldingPoke, 0}, - {PCText_WhichOneWillTake, 0}, - {PCText_CantReleaseEgg, 0}, - {PCText_ContinueBox, 0}, - {PCText_CameBack, 1}, - {PCText_Worried, 0}, - {PCText_Surprise, 0}, - {PCText_PleaseRemoveMail, 0} +const struct OamData gOamData_83B6EB4 = { + .shape = ST_OAM_H_RECTANGLE +}; + +const union AnimCmd gSpriteAnim_83B6EBC[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83B6EC4[] = { + ANIMCMD_FRAME(2, 8), + ANIMCMD_FRAME(4, 8), + ANIMCMD_FRAME(6, 8), + ANIMCMD_JUMP(0) +}; + +const union AnimCmd gSpriteAnim_83B6ED4[] = { + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83B6EDC[] = { + ANIMCMD_FRAME(10, 8), + ANIMCMD_FRAME( 4, 8), + ANIMCMD_FRAME(12, 8), + ANIMCMD_JUMP(0) +}; + +const union AnimCmd *const gSpriteAnimTable_83B6EEC[] = { + gSpriteAnim_83B6EBC, + gSpriteAnim_83B6EC4, + gSpriteAnim_83B6ED4, + gSpriteAnim_83B6EDC +}; + +const struct SpriteTemplate gSpriteTemplate_83B6EFC = { + 0x0005, + 0xdacd, + &gOamData_83B6EB4, + gSpriteAnimTable_83B6EEC, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +const struct OamData gOamData_83B6F2C; + +const struct SpriteTemplate gSpriteTemplate_83B6F14 = { + 0x000f, + 0xdac0, + &gOamData_83B6F2C, + gDummySpriteAnimTable, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +const struct OamData gOamData_83B6F2C = { + .size = 2 }; -- cgit v1.2.3 From f361bbd3e63a0b342ddfbd4c4c8d9e5a7536d2cc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 20:30:32 -0500 Subject: finish pokemon_storage_system_2.c --- src/pokemon/pokemon_storage_system_2.c | 107 ++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index ff6f1f587..474f16323 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -89,59 +89,10 @@ void sub_80987DC(void); void sub_809880C(void); bool8 sub_8098830(void); void PrintStorageActionText(u8 index); -void sub_8098A38(u8); +void sub_8098A38(s8); void sub_8098A5C(void); void sub_8098A80(void); void sub_8098AA8(u8 a0); -void sub_8098B48(void); -void sub_8099310(void); -bool8 sub_8099374(void); -void sub_80994A8(s16 a0); -void sub_809954C(void); -void sub_8099958(void); -bool8 sub_8099990(void); -void sub_809BB90(void); -void sub_8099BF8(u8 a0); -void sub_8099C70(u8 whichBox); -bool8 sub_8099D34(void); -void sub_8099DCC(u8 a0); -bool8 sub_8099E08(void); -void sub_809A860(u8 a0); -void sub_809AA24(void); -void sub_809AA98(void); -bool8 sub_809AC00(void); -void sub_809B0C0(u8 a0); -void sub_809B0D4(void); -void sub_809B0E0(void); -u8 sub_809B0F4(void); -void sub_809B068(void); -void sub_809B100(u8 a0); -bool8 sub_809B130(void); -void sub_809B440(void); -bool8 sub_809B62C(u8); -void sub_809B6BC(void); -void sub_809B6DC(void); -bool8 sub_809B734(void); -void sub_809B760(void); -void sub_809B7AC(void); -void sub_809B7D4(void); -s8 sub_809B960(void); -void sub_809BBC0(void); -void sub_809BC18(void); -void sub_809BD14(void); -void sub_809BDD8(u8 markings); -bool8 sub_809BE80(void); -bool8 sub_809BEBC(void); -bool8 sub_809BF20(void); -bool8 sub_809BF48(void); -u8 sub_809CA40(void); -void sub_809CE84(void); -s16 sub_809CF30(void); -void sub_809CFDC(struct UnkStruct_2000020 *a0, struct UnkStruct_2000020 *a1, u8 a2); -void sub_809CFF0(void); -void sub_809D034(void *dest, u16 dLeft, u16 dTop, const void *src, u16 sLeft, u16 sTop, u16 width, u16 height); -void sub_809D104(void *dest, u16 dLeft, u16 dTop, const void *src, u16 sLeft, u16 sTop, u16 width, u16 height); -void sub_809D16C(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height); // .rodata @@ -2081,3 +2032,59 @@ const struct SpriteTemplate gSpriteTemplate_83B6F14 = { const struct OamData gOamData_83B6F2C = { .size = 2 }; + +void sub_8098A38(s8 a0) +{ + DisplayYesNoMenu(23, 10, 0); + MoveMenuCursor(a0); +} + +void sub_8098A5C(void) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(10, 16, 29, 19); + MenuZeroFillWindowRect(23, 10, 29, 15); +} + +void sub_8098A80(void) +{ + sub_809CDCC(); + sub_809CDEC(12); + sub_809CDEC(13); + sub_809CDEC(14); + sub_809CDEC(15); + sub_809CE84(); +} + +void sub_8098AA8(u8 a0) +{ + sub_809CDCC(); + switch (a0) + { + case 0: + sub_809CDEC(16); + sub_809CDEC(17); + sub_809CDEC(18); + sub_809CDEC(19); + break; + case 1: + sub_809CDEC(20); + sub_809CDEC(21); + sub_809CDEC(22); + sub_809CDEC(23); + break; + case 2: + sub_809CDEC(24); + sub_809CDEC(25); + sub_809CDEC(26); + sub_809CDEC(27); + break; + case 3: + sub_809CDEC(28); + sub_809CDEC(29); + sub_809CDEC(30); + sub_809CDEC(31); + break; + } + sub_809CE84(); +} -- cgit v1.2.3 From c4244f5bec27741c18a12611f245df5572b11d8b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 21:18:42 -0500 Subject: through sub_8098BF0 --- src/pokemon/pokemon_storage_system.c | 14 ++++----- src/pokemon/pokemon_storage_system_2.c | 27 ------------------ src/pokemon/pokemon_storage_system_3.c | 52 ++++++++++++++++++++++++++++++++-- src/pokemon/pokemon_storage_system_4.c | 23 +++++++++++++++ src/pokemon/pokemon_storage_system_5.c | 16 +++++++++++ 5 files changed, 96 insertions(+), 36 deletions(-) create mode 100644 src/pokemon/pokemon_storage_system_4.c create mode 100644 src/pokemon/pokemon_storage_system_5.c (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index c91e45d7a..aebd13498 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -22,6 +22,12 @@ void sub_809665C(void); void sub_80966F4(const u8 *sourceString, u16 x, u16 y); void sub_8096784(struct Sprite *sprite); +EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; +EWRAM_DATA u8 gUnknown_02038470[3] = {}; +EWRAM_DATA u8 gUnknown_02038473 = 0; +EWRAM_DATA u8 gUnknown_02038474 = 0; +EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478 = NULL; + const struct PSS_MenuStringPtrs gUnknown_083B600C[] = { {PCText_WithdrawPoke, PCText_MovePokeToParty}, {PCText_DepositPoke, PCText_StorePokeInBox}, @@ -71,13 +77,7 @@ const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/b const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); -EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; -EWRAM_DATA u8 gUnknown_02038470[3] = {}; -EWRAM_DATA u8 gUnknown_02038473 = 0; -EWRAM_DATA u8 gUnknown_02038474 = 0; -EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_02038478 = NULL; - -static u8 CountPokemonInBoxN(u8 boxId) +u8 CountPokemonInBoxN(u8 boxId) { u16 i; u16 count; diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index 474f16323..2947562d0 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -27,15 +27,6 @@ EWRAM_DATA u8 gUnknown_0203847C = 0; EWRAM_DATA u8 gUnknown_0203847D = 0; EWRAM_DATA u8 gUnknown_0203847E = 0; EWRAM_DATA u8 gUnknown_0203847F = 0; -EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; -EWRAM_DATA u8 gUnknown_020384E4 = 0; -EWRAM_DATA u8 gUnknown_020384E5 = 0; -EWRAM_DATA u8 gUnknown_020384E6 = 0; -EWRAM_DATA u8 gUnknown_020384E7 = 0; -EWRAM_DATA u8 gUnknown_020384E8 = 0; -EWRAM_DATA u8 gUnknown_020384E9 = 0; -EWRAM_DATA u16 gUnknown_020384EA = 0; -EWRAM_DATA u32 gUnknown_020384EC = 0; // Static ROM declarations @@ -80,7 +71,6 @@ void sub_8098400(void); void add_to_c3_somehow(void); void sub_8098780(void); void sub_8098690(bool8 flag); -void sub_8099200(u8 a0); bool8 sub_80985CC(void); void sub_80986E8(void); void sub_8098710(void); @@ -159,7 +149,6 @@ const struct SpritePalette gWaveformSpritePalette = { // .text - void task_intro_29(u8 whichMenu) { gUnknown_0203847D = whichMenu; @@ -2017,22 +2006,6 @@ const struct SpriteTemplate gSpriteTemplate_83B6EFC = { SpriteCallbackDummy }; -const struct OamData gOamData_83B6F2C; - -const struct SpriteTemplate gSpriteTemplate_83B6F14 = { - 0x000f, - 0xdac0, - &gOamData_83B6F2C, - gDummySpriteAnimTable, - NULL, - gDummySpriteAffineAnimTable, - SpriteCallbackDummy -}; - -const struct OamData gOamData_83B6F2C = { - .size = 2 -}; - void sub_8098A38(s8 a0) { DisplayYesNoMenu(23, 10, 0); diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index 9e0052b89..eff542756 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -1,16 +1,64 @@ // Includes #include "global.h" +#include "sprite.h" +#include "pokemon_icon.h" #include "pokemon_storage_system.h" // Static type declarations // Static RAM declarations -EWRAM_DATA u16 gUnknown_02039760[0x600] = {}; - // Static ROM declarations +void sub_80999C4(struct Sprite *sprite); +struct Sprite *sub_8099AFC(u16 species, u32 personality, u16 a2, u16 a3, u8 a4, u8 a5); + // .rodata +const struct OamData gOamData_83B6F2C; + +const struct SpriteTemplate gSpriteTemplate_83B6F14 = { + 0x000f, + 0xdac0, + &gOamData_83B6F2C, + gDummySpriteAnimTable, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +const struct OamData gOamData_83B6F2C = { + .size = 2 +}; + // .text + +u8 get_preferred_box(void) +{ + return gPokemonStorage.currentBox; +} + +void sub_8098B48(void) +{ + u16 i; + + sub_809D51C(); + for (i = 0; i < 40; i++) + gPokemonStorageSystemPtr->unk_10d0[i] = 0; + for (i = 0; i < 40; i++) + gPokemonStorageSystemPtr->unk_1120[i] = 0; + for (i = 0; i < 6; i++) + gPokemonStorageSystemPtr->unk_1038[i] = 0; + for (i = 0; i < 30; i++) + gPokemonStorageSystemPtr->unk_1050[i] = 0; + gPokemonStorageSystemPtr->unk_1034 = NULL; + gPokemonStorageSystemPtr->unk_0d5c = 0; +} + +void sub_8098BF0(void) +{ + u32 personality = GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_PERSONALITY); + gPokemonStorageSystemPtr->unk_1034 = sub_8099AFC(GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_SPECIES2), personality, 0, 0, 1, 7); + gPokemonStorageSystemPtr->unk_1034->callback = sub_80999C4; +} diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c new file mode 100644 index 000000000..f7a008db2 --- /dev/null +++ b/src/pokemon/pokemon_storage_system_4.c @@ -0,0 +1,23 @@ + +// Includes +#include "global.h" +#include "pokemon_storage_system.h" + +// Static type declarations + +// Static RAM declarations + +EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; +EWRAM_DATA u8 gUnknown_020384E4 = 0; +EWRAM_DATA u8 gUnknown_020384E5 = 0; +EWRAM_DATA u8 gUnknown_020384E6 = 0; +EWRAM_DATA u8 gUnknown_020384E7 = 0; +EWRAM_DATA u8 gUnknown_020384E8 = 0; +EWRAM_DATA u8 gUnknown_020384E9 = 0; +EWRAM_DATA u16 gUnknown_020384EA = 0; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/pokemon/pokemon_storage_system_5.c b/src/pokemon/pokemon_storage_system_5.c new file mode 100644 index 000000000..f809439ff --- /dev/null +++ b/src/pokemon/pokemon_storage_system_5.c @@ -0,0 +1,16 @@ + +// Includes +#include "global.h" +#include "pokemon_storage_system.h" + +// Static type declarations + +// Static RAM declarations + +EWRAM_DATA u32 gUnknown_020384EC = 0; + +// Static ROM declarations + +// .rodata + +// .text -- cgit v1.2.3 From 7cdd2b2a42a96135949e399d1fa3a00c5f56ae67 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 22:08:11 -0500 Subject: through sub_8098E68 --- src/pokemon/pokemon_storage_system_2.c | 4 +- src/pokemon/pokemon_storage_system_3.c | 89 ++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index 2947562d0..dbb1cf992 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -217,7 +217,7 @@ void sub_8096884(void) gMain.state++; break; case 4: - sub_8098B48(); + ResetPSSMonIconSprites(); sub_809AA24(); gMain.state++; break; @@ -280,7 +280,7 @@ void sub_80969A0(void) gMain.state++; break; case 4: - sub_8098B48(); + ResetPSSMonIconSprites(); sub_809AA98(); gMain.state++; break; diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index eff542756..e1ccd107f 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -1,6 +1,7 @@ // Includes #include "global.h" +#include "constants/species.h" #include "sprite.h" #include "pokemon_icon.h" #include "pokemon_storage_system.h" @@ -11,8 +12,9 @@ // Static ROM declarations +void sub_8098E68(struct Sprite *sprite); void sub_80999C4(struct Sprite *sprite); -struct Sprite *sub_8099AFC(u16 species, u32 personality, u16 a2, u16 a3, u8 a4, u8 a5); +struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 a2, s16 a3, u8 a4, u8 a5); // .rodata @@ -39,7 +41,7 @@ u8 get_preferred_box(void) return gPokemonStorage.currentBox; } -void sub_8098B48(void) +void ResetPSSMonIconSprites(void) { u16 i; @@ -49,9 +51,9 @@ void sub_8098B48(void) for (i = 0; i < 40; i++) gPokemonStorageSystemPtr->unk_1120[i] = 0; for (i = 0; i < 6; i++) - gPokemonStorageSystemPtr->unk_1038[i] = 0; + gPokemonStorageSystemPtr->unk_1038[i] = NULL; for (i = 0; i < 30; i++) - gPokemonStorageSystemPtr->unk_1050[i] = 0; + gPokemonStorageSystemPtr->unk_1050[i] = NULL; gPokemonStorageSystemPtr->unk_1034 = NULL; gPokemonStorageSystemPtr->unk_0d5c = 0; } @@ -59,6 +61,83 @@ void sub_8098B48(void) void sub_8098BF0(void) { u32 personality = GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_PERSONALITY); - gPokemonStorageSystemPtr->unk_1034 = sub_8099AFC(GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_SPECIES2), personality, 0, 0, 1, 7); + gPokemonStorageSystemPtr->unk_1034 = PSS_SpawnMonIconSprite(GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_SPECIES2), personality, 0, 0, 1, 7); gPokemonStorageSystemPtr->unk_1034->callback = sub_80999C4; } + +void SpawnBoxIconSprites(u8 boxId) +{ + struct BoxPokemon *box = gPokemonStorage.boxes[boxId]; + u16 i; + u16 k = 0; + for (i = 0; i < 5; i++) + { + u16 j; + for (j = 0; j < 6; j++) + { + u16 species = GetBoxMonData(box, MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + gPokemonStorageSystemPtr->unk_1050[k] = PSS_SpawnMonIconSprite(species, GetBoxMonData(box, MON_DATA_PERSONALITY), 24 * j + 0x64, 24 * i + 0x2c, 2, 18 - j); + else + gPokemonStorageSystemPtr->unk_1050[k] = NULL; + box++; + k++; + } + } +} + +void sub_8098D20(u8 monId) +{ + struct BoxPokemon *mon = gPokemonStorage.boxes[get_preferred_box()] + monId; + u16 species = GetBoxMonData(mon, MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + { + s16 x = 24 * (monId % 6) + 0x64; + s16 y = 24 * (monId / 6) + 0x2c; + gPokemonStorageSystemPtr->unk_1050[monId] = PSS_SpawnMonIconSprite(species, GetBoxMonData(mon, MON_DATA_PERSONALITY), x, y, 2, 18 - (monId % 6)); + } +} + +void sub_8098DE0(s16 a0) +{ + u16 monId; + for (monId = 0; monId < 30; monId++) + { + if (gPokemonStorageSystemPtr->unk_1050[monId]) + { + gPokemonStorageSystemPtr->unk_1050[monId]->data[2] = a0; + gPokemonStorageSystemPtr->unk_1050[monId]->data[4] = 1; + gPokemonStorageSystemPtr->unk_1050[monId]->callback = sub_8098E68; + } + } +} + +void sub_8098E24(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + sprite->data[1]--; + sprite->pos1.x += sprite->data[2]; + } + else + { + gPokemonStorageSystemPtr->unk_1178--; + sprite->pos1.x = sprite->data[3]; + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_8098E68(struct Sprite *sprite) +{ + if (sprite->data[4] != 0) + { + sprite->data[4]--; + } + else + { + sprite->pos1.x += sprite->data[2]; + sprite->data[5] = sprite->pos1.x + sprite->pos2.x; + if (sprite->data[5] < 0x45 || sprite->data[5] > 0xfb) + sprite->callback = SpriteCallbackDummy; + } +} -- cgit v1.2.3 From 4ae149b93441ffce560f3b7018842bc4c5d39326 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 22:52:37 -0500 Subject: through sub_8098EE0 --- src/pokemon/pokemon_storage_system_3.c | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index e1ccd107f..77d85de65 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -15,6 +15,7 @@ void sub_8098E68(struct Sprite *sprite); void sub_80999C4(struct Sprite *sprite); struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 a2, s16 a3, u8 a4, u8 a5); +void sub_8099BE0(struct Sprite *sprite); // .rodata @@ -141,3 +142,54 @@ void sub_8098E68(struct Sprite *sprite) sprite->callback = SpriteCallbackDummy; } } + +void sub_8098EA0(u8 col) +{ + u16 i; + + for (i = 0; i < 5; i++) + { + if (gPokemonStorageSystemPtr->unk_1050[col]) + { + sub_8099BE0(gPokemonStorageSystemPtr->unk_1050[col]); + gPokemonStorageSystemPtr->unk_1050[col] = NULL; + } + col += 6; + } +} + +u8 sub_8098EE0(u8 a0, u16 a1, s16 a2) +{ + u16 i; + u16 x; + u16 y; + u8 count; + u8 x1; + u16 sp1c; + + y = 0x2c; + x = 24 * a0 + 0x64; + sp1c = x - (a1 + 1) * a2; + x1 = 18 - a0; + count = 0; + + for (i = 0; i < 5; i++) + { + u16 species = GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + a0, MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + { + gPokemonStorageSystemPtr->unk_1050[a0] = PSS_SpawnMonIconSprite(species, GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + a0, MON_DATA_PERSONALITY), sp1c, y, 2, x1); + if (gPokemonStorageSystemPtr->unk_1050[a0]) + { + gPokemonStorageSystemPtr->unk_1050[a0]->data[1] = a1; + gPokemonStorageSystemPtr->unk_1050[a0]->data[2] = a2; + gPokemonStorageSystemPtr->unk_1050[a0]->data[3] = x; + gPokemonStorageSystemPtr->unk_1050[a0]->callback = sub_8098E24; + count++; + } + } + a0 += 6; + y += 24; + } + return count; +} -- cgit v1.2.3 From cb28e3a679841c01191f19cb7e7f0da28f0bf160 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 9 Jan 2018 23:05:21 -0500 Subject: sub_809900C --- src/pokemon/pokemon_storage_system_3.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index 77d85de65..af050d324 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -193,3 +193,19 @@ u8 sub_8098EE0(u8 a0, u16 a1, s16 a2) } return count; } + +void sub_809900C(u8 a0, s8 a1) +{ + gPokemonStorageSystemPtr->unk_117c = 0; + gPokemonStorageSystemPtr->unk_117d = a0; + gPokemonStorageSystemPtr->unk_117b = a1; + gPokemonStorageSystemPtr->unk_1172 = 32; + gPokemonStorageSystemPtr->unk_1176 = -6 * a1; + gPokemonStorageSystemPtr->unk_1178 = 0; + if (a1 > 0) + gPokemonStorageSystemPtr->unk_117a = 0; + else + gPokemonStorageSystemPtr->unk_117a = 5; + gPokemonStorageSystemPtr->unk_1174 = 24 * gPokemonStorageSystemPtr->unk_117a + 0x64; + sub_8098DE0(gPokemonStorageSystemPtr->unk_1176); +} -- cgit v1.2.3 From e0726bf8d6af39f287c65ad22ce192988e8468bb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 10 Jan 2018 20:20:16 -0500 Subject: through sub_8099374 --- src/pokemon/pokemon_storage_system_2.c | 4 +- src/pokemon/pokemon_storage_system_3.c | 101 +++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index dbb1cf992..a158b29a9 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -1703,7 +1703,7 @@ void sub_8098400(void) if (gUnknown_0203847C) { sub_8098690(TRUE); - sub_8099200(1); + sub_8099200(TRUE); sub_809D034(BG_SCREEN_ADDR(15), 10, 0, gPokemonStorageSystemPtr->unk_00a8, 0, 0, 12, 22); } else @@ -1719,7 +1719,7 @@ void sub_80984E8(void) gPokemonStorageSystemPtr->unk_08a8 = 20; gPokemonStorageSystemPtr->unk_08aa = 2; gPokemonStorageSystemPtr->unk_08ad = 0; - sub_8099200(0); + sub_8099200(FALSE); } bool8 sub_8098520(void) diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index af050d324..230e9445b 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -13,6 +13,7 @@ // Static ROM declarations void sub_8098E68(struct Sprite *sprite); +void sub_8099388(struct Sprite *sprite, u16 a0); void sub_80999C4(struct Sprite *sprite); struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 a2, s16 a3, u8 a4, u8 a5); void sub_8099BE0(struct Sprite *sprite); @@ -209,3 +210,103 @@ void sub_809900C(u8 a0, s8 a1) gPokemonStorageSystemPtr->unk_1174 = 24 * gPokemonStorageSystemPtr->unk_117a + 0x64; sub_8098DE0(gPokemonStorageSystemPtr->unk_1176); } + +bool8 sub_80990AC(void) +{ + if (gPokemonStorageSystemPtr->unk_1172) + gPokemonStorageSystemPtr->unk_1172--; + switch (gPokemonStorageSystemPtr->unk_117c) + { + case 0: + gPokemonStorageSystemPtr->unk_1174 += gPokemonStorageSystemPtr->unk_1176; + if (gPokemonStorageSystemPtr->unk_1174 < 0x41 || gPokemonStorageSystemPtr->unk_1174 > 0xfb) + { + sub_8098EA0(gPokemonStorageSystemPtr->unk_117a); + gPokemonStorageSystemPtr->unk_1174 += 24 * gPokemonStorageSystemPtr->unk_117b; + gPokemonStorageSystemPtr->unk_117c++; + } + break; + case 1: + gPokemonStorageSystemPtr->unk_1174 += gPokemonStorageSystemPtr->unk_1176; + gPokemonStorageSystemPtr->unk_1178 += sub_8098EE0(gPokemonStorageSystemPtr->unk_117a, gPokemonStorageSystemPtr->unk_1172, gPokemonStorageSystemPtr->unk_1176); + if ((gPokemonStorageSystemPtr->unk_117b > 0 && gPokemonStorageSystemPtr->unk_117a == 5) || (gPokemonStorageSystemPtr->unk_117b < 0 && gPokemonStorageSystemPtr->unk_117a == 0)) + { + gPokemonStorageSystemPtr->unk_117c++; + } + else + { + gPokemonStorageSystemPtr->unk_117a += gPokemonStorageSystemPtr->unk_117b; + gPokemonStorageSystemPtr->unk_117c = 0; + } + break; + case 2: + if (gPokemonStorageSystemPtr->unk_1178 == 0) + { + gPokemonStorageSystemPtr->unk_1172++; + return FALSE; + } + break; + default: + return FALSE; + } + return TRUE; +} + +void sub_8099200(bool8 a0) +{ + u16 count; + u16 i; + u16 species = GetMonData(gPlayerParty + 0, MON_DATA_SPECIES2); + u32 personality = GetMonData(gPlayerParty + 0, MON_DATA_PERSONALITY); + gPokemonStorageSystemPtr->unk_1038[0] = PSS_SpawnMonIconSprite(species, personality, 0x68, 0x40, 1, 11); + count = 1; + for (i = 1; i < PARTY_SIZE; i++) + { + species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + { + personality = GetMonData(gPlayerParty + i, MON_DATA_PERSONALITY); + gPokemonStorageSystemPtr->unk_1038[i] = PSS_SpawnMonIconSprite(species, personality, 0x98, (i - 1) * 24 + 0x10, 1, 11); + count++; + } + else + { + gPokemonStorageSystemPtr->unk_1038[i] = NULL; + } + } + if (!a0) + { + for (i = 0; i < count; i++) + { + // this routine assumes party_compaction has been called + gPokemonStorageSystemPtr->unk_1038[i]->pos1.y -= 0xa0; + gPokemonStorageSystemPtr->unk_1038[i]->invisible = TRUE; + } + } +} + +void sub_8099310(void) +{ + u16 i; + u16 count; + + gPokemonStorageSystemPtr->unk_1171 = 0; + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (gPokemonStorageSystemPtr->unk_1038[i]) + { + if (i != count) + { + sub_8099388(gPokemonStorageSystemPtr->unk_1038[i], count); + gPokemonStorageSystemPtr->unk_1038[i] = NULL; + gPokemonStorageSystemPtr->unk_1171++; + } + count++; + } + } +} + +u8 sub_8099374(void) +{ + return gPokemonStorageSystemPtr->unk_1171; +} -- cgit v1.2.3 From e44c0f897d2d02f153d5adf139be3bac25e1ee93 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 10 Jan 2018 21:33:54 -0500 Subject: through sub_809960C --- src/pokemon/pokemon_storage_system_3.c | 145 ++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index 230e9445b..28b9e2655 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -13,7 +13,8 @@ // Static ROM declarations void sub_8098E68(struct Sprite *sprite); -void sub_8099388(struct Sprite *sprite, u16 a0); +void sub_8099388(struct Sprite *sprite, u16 a1); +void sub_80993F4(struct Sprite *sprite); void sub_80999C4(struct Sprite *sprite); struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 a2, s16 a3, u8 a4, u8 a5); void sub_8099BE0(struct Sprite *sprite); @@ -310,3 +311,145 @@ u8 sub_8099374(void) { return gPokemonStorageSystemPtr->unk_1171; } + +void sub_8099388(struct Sprite *sprite, u16 a1) +{ + s16 r3; + s16 r4; + + sprite->data[1] = a1; + if (a1 == 0) + { + r3 = 0x68; + r4 = 0x40; + } + else + { + r3 = 0x98; + r4 = 24 * (a1 - 1) + 0x10; + } + sprite->data[2] = sprite->pos1.x << 3; + sprite->data[3] = sprite->pos1.y << 3; + sprite->data[4] = (r3 * 8 - sprite->data[2]) / 8; + sprite->data[5] = (r4 * 8 - sprite->data[3]) / 8; + sprite->data[6] = 8; + sprite->callback = sub_80993F4; +} + +void sub_80993F4(struct Sprite *sprite) +{ + if (sprite->data[6]) + { + sprite->data[2] += sprite->data[4]; + sprite->data[3] += sprite->data[5]; + sprite->pos1.x = sprite->data[2] >> 3; + sprite->pos1.y = sprite->data[3] >> 3; + sprite->data[6]--; + } + else + { + if (sprite->data[1] == 0) + { + sprite->pos1.x = 0x68; + sprite->pos1.y = 0x40; + } + else + { + sprite->pos1.x = 0x98; + sprite->pos1.y = (sprite->data[1] - 1) * 24 + 0x10; + } + sprite->callback = SpriteCallbackDummy; + gPokemonStorageSystemPtr->unk_1038[sprite->data[1]] = sprite; + gPokemonStorageSystemPtr->unk_1171--; + } +} + +void sub_8099480(void) +{ + if (gPokemonStorageSystemPtr->unk_1034) + { + sub_8099BE0(gPokemonStorageSystemPtr->unk_1034); + gPokemonStorageSystemPtr->unk_1034 = NULL; + } +} + +void sub_80994A8(s16 y) +{ + u16 i; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (gPokemonStorageSystemPtr->unk_1038[i]) + { + s16 yy; + gPokemonStorageSystemPtr->unk_1038[i]->pos1.y += y; + yy = gPokemonStorageSystemPtr->unk_1038[i]->pos1.y + gPokemonStorageSystemPtr->unk_1038[i]->pos2.y + gPokemonStorageSystemPtr->unk_1038[i]->centerToCornerVecY; + if (yy < -0x10 || yy > 0xb0) + gPokemonStorageSystemPtr->unk_1038[i]->invisible = TRUE; + else + gPokemonStorageSystemPtr->unk_1038[i]->invisible = FALSE; + } + } +} + +void sub_8099520(u8 a0) +{ + if (gPokemonStorageSystemPtr->unk_1038[a0]) + { + sub_8099BE0(gPokemonStorageSystemPtr->unk_1038[a0]); + gPokemonStorageSystemPtr->unk_1038[a0] = NULL; + } +} + +void sub_809954C(void) +{ + u16 i; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (gPokemonStorageSystemPtr->unk_1038[i]) + { + sub_8099BE0(gPokemonStorageSystemPtr->unk_1038[i]); + gPokemonStorageSystemPtr->unk_1038[i] = NULL; + } + } +} + +void sub_8099584(u8 a0, u8 a1) +{ + if (a0 == 0) + { + gPokemonStorageSystemPtr->unk_1034 = gPokemonStorageSystemPtr->unk_1038[a1]; + gPokemonStorageSystemPtr->unk_1038[a1] = NULL; + } + else if (a0 == 1) + { + gPokemonStorageSystemPtr->unk_1034 = gPokemonStorageSystemPtr->unk_1050[a1]; + gPokemonStorageSystemPtr->unk_1050[a1] = NULL; + } + else + { + return; + } + gPokemonStorageSystemPtr->unk_1034->callback = sub_80999C4; + gPokemonStorageSystemPtr->unk_1034->oam.priority = 1; + gPokemonStorageSystemPtr->unk_1034->subpriority = 7; +} + +void sub_809960C(u8 a0, u8 a1) +{ + if (a0 == 14) + { + gPokemonStorageSystemPtr->unk_1038[a1] = gPokemonStorageSystemPtr->unk_1034; + gPokemonStorageSystemPtr->unk_1038[a1]->oam.priority = 1; + gPokemonStorageSystemPtr->unk_1038[a1]->subpriority = 11; + } + else + { + gPokemonStorageSystemPtr->unk_1050[a1] = gPokemonStorageSystemPtr->unk_1034; + gPokemonStorageSystemPtr->unk_1050[a1]->oam.priority = 2; + gPokemonStorageSystemPtr->unk_1050[a1]->subpriority = 18 - (a1 % 6); + } + gPokemonStorageSystemPtr->unk_1034->callback = SpriteCallbackDummy; + gPokemonStorageSystemPtr->unk_1034 = NULL; +} -- cgit v1.2.3 From d6464c7c40f5ac1b9da557d5990e2b7e83997720 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 10 Jan 2018 21:53:25 -0500 Subject: through sub_809971C --- src/pokemon/pokemon_storage_system_3.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index 28b9e2655..7f5c84b49 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -3,6 +3,7 @@ #include "global.h" #include "constants/species.h" #include "sprite.h" +#include "trig.h" #include "pokemon_icon.h" #include "pokemon_storage_system.h" @@ -453,3 +454,43 @@ void sub_809960C(u8 a0, u8 a1) gPokemonStorageSystemPtr->unk_1034->callback = SpriteCallbackDummy; gPokemonStorageSystemPtr->unk_1034 = NULL; } + +void sub_80996B0(u8 a0, u8 a1) +{ + if (a0 == 14) + gPokemonStorageSystemPtr->unk_10c8 = gPokemonStorageSystemPtr->unk_1038 + a1; + else + gPokemonStorageSystemPtr->unk_10c8 = gPokemonStorageSystemPtr->unk_1050 + a1; + gPokemonStorageSystemPtr->unk_1034->callback = SpriteCallbackDummy; + gPokemonStorageSystemPtr->unk_1170 = 0; +} + +bool8 sub_809971C(void) +{ + if (gPokemonStorageSystemPtr->unk_1170 == 16) + return FALSE; + gPokemonStorageSystemPtr->unk_1170++; + if (gPokemonStorageSystemPtr->unk_1170 & 1) + { + (*gPokemonStorageSystemPtr->unk_10c8)->pos1.y--; + gPokemonStorageSystemPtr->unk_1034->pos1.y++; + } + (*gPokemonStorageSystemPtr->unk_10c8)->pos2.x = gSineTable[gPokemonStorageSystemPtr->unk_1170 * 8] / 16; + gPokemonStorageSystemPtr->unk_1034->pos2.x = -(gSineTable[gPokemonStorageSystemPtr->unk_1170 * 8] / 16); + if (gPokemonStorageSystemPtr->unk_1170 == 8) + { + gPokemonStorageSystemPtr->unk_1034->oam.priority = (*gPokemonStorageSystemPtr->unk_10c8)->oam.priority; + gPokemonStorageSystemPtr->unk_1034->subpriority = (*gPokemonStorageSystemPtr->unk_10c8)->subpriority; + (*gPokemonStorageSystemPtr->unk_10c8)->oam.priority = 1; + (*gPokemonStorageSystemPtr->unk_10c8)->subpriority = 7; + } + if (gPokemonStorageSystemPtr->unk_1170 == 16) + { + struct Sprite *sprite = gPokemonStorageSystemPtr->unk_1034; + gPokemonStorageSystemPtr->unk_1034 = *(gPokemonStorageSystemPtr->unk_10c8); + (*gPokemonStorageSystemPtr->unk_10c8) = sprite; + gPokemonStorageSystemPtr->unk_1034->callback = sub_80999C4; + (*gPokemonStorageSystemPtr->unk_10c8)->callback = SpriteCallbackDummy; + } + return TRUE; +} -- cgit v1.2.3 From a1ccd03edd90601759a04f223c9558181a657728 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 10 Jan 2018 22:08:58 -0500 Subject: Refine struct at 02000028 --- src/pokemon/pokemon_storage_system_2.c | 2 +- src/pokemon/pokemon_storage_system_5.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index a158b29a9..e5466ea70 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -176,7 +176,7 @@ void sub_8096804(void) FreeAllSpritePalettes(); ResetTasks(); gReservedSpriteTileCount = 0x280; - sub_809CFDC(gPokemonStorageSystemPtr->unk_0020, gPokemonStorageSystemPtr->unk_0020 + 1, 8); + sub_809CFDC(&gPokemonStorageSystemPtr->unk_0020, gPokemonStorageSystemPtr->unk_0028, 8); gKeyRepeatStartDelay = 20; } diff --git a/src/pokemon/pokemon_storage_system_5.c b/src/pokemon/pokemon_storage_system_5.c index f809439ff..b7c3d42f5 100644 --- a/src/pokemon/pokemon_storage_system_5.c +++ b/src/pokemon/pokemon_storage_system_5.c @@ -7,7 +7,7 @@ // Static RAM declarations -EWRAM_DATA u32 gUnknown_020384EC = 0; +EWRAM_DATA struct UnkStruct_2000020 *gUnknown_020384EC = NULL; // Static ROM declarations -- cgit v1.2.3 From 7a65953ccc2313db6de0ec061220b1a5f8751b36 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 12 Jan 2018 08:53:01 -0500 Subject: through sub_80999C4 --- src/pokemon/pokemon_storage_system_3.c | 86 ++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index 7f5c84b49..2af88e8cd 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -494,3 +494,89 @@ bool8 sub_809971C(void) } return TRUE; } + +const union AffineAnimCmd gSpriteAffineAnim_83B6F34[] = { + AFFINEANIMCMD_FRAME(-2, -2, 0, 120), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gSpriteAffineAnim_83B6F44[] = { + AFFINEANIMCMD_FRAME(16, 16, 0, 0), + AFFINEANIMCMD_FRAME(16, 16, 0, 15), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gSpriteAffineAnimTable_83B6F5C[] = { + gSpriteAffineAnim_83B6F34, + gSpriteAffineAnim_83B6F44 +}; + +void sub_809981C(u8 mode, u8 idx) +{ + switch (mode) + { + case 0: + gPokemonStorageSystemPtr->unk_10cc = gPokemonStorageSystemPtr->unk_1038 + idx; + break; + case 1: + gPokemonStorageSystemPtr->unk_10cc = gPokemonStorageSystemPtr->unk_1050 + idx; + break; + case 2: + gPokemonStorageSystemPtr->unk_10cc = &gPokemonStorageSystemPtr->unk_1034; + break; + default: + return; + } + if (*gPokemonStorageSystemPtr->unk_10cc) + { + InitSpriteAffineAnim(*gPokemonStorageSystemPtr->unk_10cc); + (*gPokemonStorageSystemPtr->unk_10cc)->oam.affineMode = ST_OAM_AFFINE_NORMAL; + (*gPokemonStorageSystemPtr->unk_10cc)->affineAnims = gSpriteAffineAnimTable_83B6F5C; + StartSpriteAffineAnim(*gPokemonStorageSystemPtr->unk_10cc, 0); + } +} + +bool8 sub_80998D8(void) +{ + if (*gPokemonStorageSystemPtr->unk_10cc == NULL || (*gPokemonStorageSystemPtr->unk_10cc)->invisible) + return FALSE; + if ((*gPokemonStorageSystemPtr->unk_10cc)->affineAnimEnded) + { + (*gPokemonStorageSystemPtr->unk_10cc)->invisible = TRUE; + } + return TRUE; +} + +void sub_8099920(void) +{ + if (*gPokemonStorageSystemPtr->unk_10cc) + { + FreeOamMatrix((*gPokemonStorageSystemPtr->unk_10cc)->oam.matrixNum); + sub_8099BE0(*gPokemonStorageSystemPtr->unk_10cc); + *gPokemonStorageSystemPtr->unk_10cc = NULL; + } +} + +void sub_8099958(void) +{ + if (*gPokemonStorageSystemPtr->unk_10cc) + { + (*gPokemonStorageSystemPtr->unk_10cc)->invisible = FALSE; + StartSpriteAffineAnim(*gPokemonStorageSystemPtr->unk_10cc, 1); + } +} + +bool8 sub_8099990(void) +{ + if (gPokemonStorageSystemPtr->unk_10cc == NULL) + return FALSE; + if ((*gPokemonStorageSystemPtr->unk_10cc)->affineAnimEnded) + gPokemonStorageSystemPtr->unk_10cc = NULL; + return TRUE; +} + +void sub_80999C4(struct Sprite *sprite) +{ + sprite->pos1.x = gPokemonStorageSystemPtr->unk_11c0->pos1.x; + sprite->pos1.y = gPokemonStorageSystemPtr->unk_11c0->pos1.y + gPokemonStorageSystemPtr->unk_11c0->pos2.y + 4; +} -- cgit v1.2.3 From 12ec094b4b3641cf33fc1cf45634090e067c70b6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 12 Jan 2018 09:46:31 -0500 Subject: Remaining functions and data in pss3 --- src/pokemon/pokemon_storage_system_3.c | 131 +++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index 2af88e8cd..9d4b88b5d 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -24,20 +24,6 @@ void sub_8099BE0(struct Sprite *sprite); const struct OamData gOamData_83B6F2C; -const struct SpriteTemplate gSpriteTemplate_83B6F14 = { - 0x000f, - 0xdac0, - &gOamData_83B6F2C, - gDummySpriteAnimTable, - NULL, - gDummySpriteAffineAnimTable, - SpriteCallbackDummy -}; - -const struct OamData gOamData_83B6F2C = { - .size = 2 -}; - // .text u8 get_preferred_box(void) @@ -495,21 +481,7 @@ bool8 sub_809971C(void) return TRUE; } -const union AffineAnimCmd gSpriteAffineAnim_83B6F34[] = { - AFFINEANIMCMD_FRAME(-2, -2, 0, 120), - AFFINEANIMCMD_END -}; - -const union AffineAnimCmd gSpriteAffineAnim_83B6F44[] = { - AFFINEANIMCMD_FRAME(16, 16, 0, 0), - AFFINEANIMCMD_FRAME(16, 16, 0, 15), - AFFINEANIMCMD_END -}; - -const union AffineAnimCmd *const gSpriteAffineAnimTable_83B6F5C[] = { - gSpriteAffineAnim_83B6F34, - gSpriteAffineAnim_83B6F44 -}; +const union AffineAnimCmd *const gSpriteAffineAnimTable_83B6F5C[]; void sub_809981C(u8 mode, u8 idx) { @@ -580,3 +552,104 @@ void sub_80999C4(struct Sprite *sprite) sprite->pos1.x = gPokemonStorageSystemPtr->unk_11c0->pos1.x; sprite->pos1.y = gPokemonStorageSystemPtr->unk_11c0->pos1.y + gPokemonStorageSystemPtr->unk_11c0->pos2.y + 4; } + +u16 sub_80999E8(u16 a0) +{ + u16 i; + u16 retval; + + for (i = 0; i < 40; i++) + { + if (gPokemonStorageSystemPtr->unk_1120[i] == a0) + break; + } + if (i == 40) + { + for (i = 0; i < 40; i++) + { + if (gPokemonStorageSystemPtr->unk_1120[i] == 0) + break; + } + } + if (i != 40) + { + gPokemonStorageSystemPtr->unk_1120[i] = a0; + gPokemonStorageSystemPtr->unk_10d0[i]++; + retval = i * 16; + CpuCopy32(gMonIconTable[a0], BG_CHAR_ADDR(4) + 32 * retval, 0x200); + return retval; + } + return -1; +} + +void sub_8099AAC(u16 a0) +{ + u16 i; + + for (i = 0; i < 40; i++) + { + if (gPokemonStorageSystemPtr->unk_1120[i] == a0) + { + if (--gPokemonStorageSystemPtr->unk_10d0[i] == 0) + gPokemonStorageSystemPtr->unk_1120[i] = 0; + break; + } + } +} + +struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 priority, u8 subpriority) +{ + struct SpriteTemplate template = { + 0x000f, + 0xdac0, + &gOamData_83B6F2C, + gDummySpriteAnimTable, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy + }; + u16 tileNum; + u8 spriteId; + + species = mon_icon_convert_unown_species_id(species, personality); + template.paletteTag = 0xdac0 + gMonIconPaletteIndices[species]; + tileNum = sub_80999E8(species); + if (tileNum == 0xFFFF) + return NULL; + spriteId = CreateSprite(&template, x, y, subpriority); + if (spriteId == MAX_SPRITES) + { + sub_8099AAC(species); + return NULL; + } + gSprites[spriteId].oam.tileNum = tileNum; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = species; + return gSprites + spriteId; +} + +void sub_8099BE0(struct Sprite *sprite) +{ + sub_8099AAC(sprite->data[0]); + DestroySprite(sprite); +} + +const struct OamData gOamData_83B6F2C = { + .size = 2 +}; + +const union AffineAnimCmd gSpriteAffineAnim_83B6F34[] = { + AFFINEANIMCMD_FRAME(-2, -2, 0, 120), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gSpriteAffineAnim_83B6F44[] = { + AFFINEANIMCMD_FRAME(16, 16, 0, 0), + AFFINEANIMCMD_FRAME(16, 16, 0, 15), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gSpriteAffineAnimTable_83B6F5C[] = { + gSpriteAffineAnim_83B6F34, + gSpriteAffineAnim_83B6F44 +}; -- cgit v1.2.3 From 3b8f6133865af6ede3628f3df8dd71648b43b3bc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 12 Jan 2018 09:57:20 -0500 Subject: some renaming in pss3 --- src/pokemon/pokemon_storage_system_2.c | 6 +-- src/pokemon/pokemon_storage_system_3.c | 78 +++++++++++++++++----------------- 2 files changed, 42 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index e5466ea70..f5eaa2166 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -872,7 +872,7 @@ void sub_809746C(void) gPokemonStorageSystemPtr->unk_0004++; break; case 3: - if (!sub_8099374()) + if (sub_8099374() == 0) { sub_809B6BC(); BoxSetMosaic(); @@ -965,7 +965,7 @@ void sub_8097594(void) } break; case 6: - if (!sub_8099374()) + if (sub_8099374() == 0) { sub_809B440(); BoxSetMosaic(); @@ -1073,7 +1073,7 @@ void sub_8097858(void) gPokemonStorageSystemPtr->unk_0004++; break; case 1: - if (!sub_8099374()) + if (sub_8099374() == 0) { sub_80987DC(); SetPSSCallback(sub_8096C84); diff --git a/src/pokemon/pokemon_storage_system_3.c b/src/pokemon/pokemon_storage_system_3.c index 9d4b88b5d..da26c6fc5 100644 --- a/src/pokemon/pokemon_storage_system_3.c +++ b/src/pokemon/pokemon_storage_system_3.c @@ -13,12 +13,12 @@ // Static ROM declarations -void sub_8098E68(struct Sprite *sprite); -void sub_8099388(struct Sprite *sprite, u16 a1); -void sub_80993F4(struct Sprite *sprite); -void sub_80999C4(struct Sprite *sprite); -struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 a2, s16 a3, u8 a4, u8 a5); -void sub_8099BE0(struct Sprite *sprite); +static void sub_8098E68(struct Sprite *sprite); +static void sub_8099388(struct Sprite *sprite, u16 a1); +static void sub_80993F4(struct Sprite *sprite); +static void sub_80999C4(struct Sprite *sprite); +static struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 priority, u8 subpriority); +static void PSS_DestroyMonIconSprite(struct Sprite *sprite); // .rodata @@ -88,7 +88,7 @@ void sub_8098D20(u8 monId) } } -void sub_8098DE0(s16 a0) +static void sub_8098DE0(s16 a0) { u16 monId; for (monId = 0; monId < 30; monId++) @@ -102,7 +102,7 @@ void sub_8098DE0(s16 a0) } } -void sub_8098E24(struct Sprite *sprite) +static void sub_8098E24(struct Sprite *sprite) { if (sprite->data[1] != 0) { @@ -117,7 +117,7 @@ void sub_8098E24(struct Sprite *sprite) } } -void sub_8098E68(struct Sprite *sprite) +static void sub_8098E68(struct Sprite *sprite) { if (sprite->data[4] != 0) { @@ -132,7 +132,7 @@ void sub_8098E68(struct Sprite *sprite) } } -void sub_8098EA0(u8 col) +static void sub_8098EA0(u8 col) { u16 i; @@ -140,44 +140,44 @@ void sub_8098EA0(u8 col) { if (gPokemonStorageSystemPtr->unk_1050[col]) { - sub_8099BE0(gPokemonStorageSystemPtr->unk_1050[col]); + PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1050[col]); gPokemonStorageSystemPtr->unk_1050[col] = NULL; } col += 6; } } -u8 sub_8098EE0(u8 a0, u16 a1, s16 a2) +static u8 sub_8098EE0(u8 col, u16 a1, s16 a2) { u16 i; u16 x; u16 y; u8 count; u8 x1; - u16 sp1c; + u16 curX; y = 0x2c; - x = 24 * a0 + 0x64; - sp1c = x - (a1 + 1) * a2; - x1 = 18 - a0; + x = 24 * col + 0x64; + curX = x - (a1 + 1) * a2; + x1 = 18 - col; count = 0; for (i = 0; i < 5; i++) { - u16 species = GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + a0, MON_DATA_SPECIES2); + u16 species = GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + col, MON_DATA_SPECIES2); if (species != SPECIES_NONE) { - gPokemonStorageSystemPtr->unk_1050[a0] = PSS_SpawnMonIconSprite(species, GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + a0, MON_DATA_PERSONALITY), sp1c, y, 2, x1); - if (gPokemonStorageSystemPtr->unk_1050[a0]) + gPokemonStorageSystemPtr->unk_1050[col] = PSS_SpawnMonIconSprite(species, GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_117d] + col, MON_DATA_PERSONALITY), curX, y, 2, x1); + if (gPokemonStorageSystemPtr->unk_1050[col]) { - gPokemonStorageSystemPtr->unk_1050[a0]->data[1] = a1; - gPokemonStorageSystemPtr->unk_1050[a0]->data[2] = a2; - gPokemonStorageSystemPtr->unk_1050[a0]->data[3] = x; - gPokemonStorageSystemPtr->unk_1050[a0]->callback = sub_8098E24; + gPokemonStorageSystemPtr->unk_1050[col]->data[1] = a1; + gPokemonStorageSystemPtr->unk_1050[col]->data[2] = a2; + gPokemonStorageSystemPtr->unk_1050[col]->data[3] = x; + gPokemonStorageSystemPtr->unk_1050[col]->callback = sub_8098E24; count++; } } - a0 += 6; + col += 6; y += 24; } return count; @@ -299,7 +299,7 @@ u8 sub_8099374(void) return gPokemonStorageSystemPtr->unk_1171; } -void sub_8099388(struct Sprite *sprite, u16 a1) +static void sub_8099388(struct Sprite *sprite, u16 a1) { s16 r3; s16 r4; @@ -323,7 +323,7 @@ void sub_8099388(struct Sprite *sprite, u16 a1) sprite->callback = sub_80993F4; } -void sub_80993F4(struct Sprite *sprite) +static void sub_80993F4(struct Sprite *sprite) { if (sprite->data[6]) { @@ -355,7 +355,7 @@ void sub_8099480(void) { if (gPokemonStorageSystemPtr->unk_1034) { - sub_8099BE0(gPokemonStorageSystemPtr->unk_1034); + PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1034); gPokemonStorageSystemPtr->unk_1034 = NULL; } } @@ -383,7 +383,7 @@ void sub_8099520(u8 a0) { if (gPokemonStorageSystemPtr->unk_1038[a0]) { - sub_8099BE0(gPokemonStorageSystemPtr->unk_1038[a0]); + PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1038[a0]); gPokemonStorageSystemPtr->unk_1038[a0] = NULL; } } @@ -396,7 +396,7 @@ void sub_809954C(void) { if (gPokemonStorageSystemPtr->unk_1038[i]) { - sub_8099BE0(gPokemonStorageSystemPtr->unk_1038[i]); + PSS_DestroyMonIconSprite(gPokemonStorageSystemPtr->unk_1038[i]); gPokemonStorageSystemPtr->unk_1038[i] = NULL; } } @@ -524,7 +524,7 @@ void sub_8099920(void) if (*gPokemonStorageSystemPtr->unk_10cc) { FreeOamMatrix((*gPokemonStorageSystemPtr->unk_10cc)->oam.matrixNum); - sub_8099BE0(*gPokemonStorageSystemPtr->unk_10cc); + PSS_DestroyMonIconSprite(*gPokemonStorageSystemPtr->unk_10cc); *gPokemonStorageSystemPtr->unk_10cc = NULL; } } @@ -547,13 +547,13 @@ bool8 sub_8099990(void) return TRUE; } -void sub_80999C4(struct Sprite *sprite) +static void sub_80999C4(struct Sprite *sprite) { sprite->pos1.x = gPokemonStorageSystemPtr->unk_11c0->pos1.x; sprite->pos1.y = gPokemonStorageSystemPtr->unk_11c0->pos1.y + gPokemonStorageSystemPtr->unk_11c0->pos2.y + 4; } -u16 sub_80999E8(u16 a0) +static u16 PSS_LoadSpeciesIconGfx(u16 a0) { u16 i; u16 retval; @@ -579,10 +579,10 @@ u16 sub_80999E8(u16 a0) CpuCopy32(gMonIconTable[a0], BG_CHAR_ADDR(4) + 32 * retval, 0x200); return retval; } - return -1; + return 0xFFFF; } -void sub_8099AAC(u16 a0) +static void PSS_ForgetSpeciesIcon(u16 a0) { u16 i; @@ -597,7 +597,7 @@ void sub_8099AAC(u16 a0) } } -struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 priority, u8 subpriority) +static struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 priority, u8 subpriority) { struct SpriteTemplate template = { 0x000f, @@ -613,13 +613,13 @@ struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y species = mon_icon_convert_unown_species_id(species, personality); template.paletteTag = 0xdac0 + gMonIconPaletteIndices[species]; - tileNum = sub_80999E8(species); + tileNum = PSS_LoadSpeciesIconGfx(species); if (tileNum == 0xFFFF) return NULL; spriteId = CreateSprite(&template, x, y, subpriority); if (spriteId == MAX_SPRITES) { - sub_8099AAC(species); + PSS_ForgetSpeciesIcon(species); return NULL; } gSprites[spriteId].oam.tileNum = tileNum; @@ -628,9 +628,9 @@ struct Sprite *PSS_SpawnMonIconSprite(u16 species, u32 personality, s16 x, s16 y return gSprites + spriteId; } -void sub_8099BE0(struct Sprite *sprite) +static void PSS_DestroyMonIconSprite(struct Sprite *sprite) { - sub_8099AAC(sprite->data[0]); + PSS_ForgetSpeciesIcon(sprite->data[0]); DestroySprite(sprite); } -- cgit v1.2.3 From f37add5cfb4bb369ec096d91f62915ee4f88a1d7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 12 Jan 2018 12:13:35 -0500 Subject: through sub_8099D90 --- src/pokemon/pokemon_storage_system_4.c | 71 ++++++++++++++++++++++++++++++++++ src/pokemon/pokemon_storage_system_6.c | 14 +++++++ 2 files changed, 85 insertions(+) create mode 100644 src/pokemon/pokemon_storage_system_6.c (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index f7a008db2..697292d5c 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -18,6 +18,77 @@ EWRAM_DATA u16 gUnknown_020384EA = 0; // Static ROM declarations +void sub_809900C(u8 boxId, s8 a1); +s8 sub_8099D90(u8 boxId); +void sub_8099EB0(u8 boxId, s8 a1); +void sub_809A23C(u8 boxId); +void sub_809A3D0(u8 boxId, s8 a1); +void sub_809A598(void); +void sub_809A6DC(void); +void sub_809A774(s8 a0); +void sub_809A810(void); + // .rodata // .text + +void sub_8099BF8(u8 boxId) +{ + gPokemonStorageSystemPtr->unk_08ba = 0; + gPokemonStorageSystemPtr->unk_08b4 = 0; + DmaFill32(3, 0, BG_SCREEN_ADDR(26), 0x1000); + sub_8099EB0(boxId, 0); + sub_809A23C(boxId); + sub_809A6DC(); + SpawnBoxIconSprites(boxId); + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_TXT512x256; +} + +void sub_8099C70(u8 whichBox) +{ + s8 r4 = sub_8099D90(whichBox); + sub_8099EB0(whichBox, r4); + gPokemonStorageSystemPtr->unk_08b6 = r4 * 6; + gPokemonStorageSystemPtr->unk_08b8 = 0x20; + gPokemonStorageSystemPtr->unk_08bb = whichBox; + gPokemonStorageSystemPtr->unk_08bc = r4 > 0 ? 0 : 5; + gPokemonStorageSystemPtr->unk_08be = r4; + gPokemonStorageSystemPtr->unk_08c0 = r4 > 0 ? 0x108 : 0x38; + gPokemonStorageSystemPtr->unk_08c2 = r4 > 0 ? 0 : 5; + gPokemonStorageSystemPtr->unk_08c4 = r4; + gPokemonStorageSystemPtr->unk_08c6 = 0; + gPokemonStorageSystemPtr->unk_08c8 = 2; + sub_809900C(whichBox, r4); + sub_809A3D0(whichBox, r4); + sub_809A774(r4); +} + +bool8 sub_8099D34(void) +{ + bool8 retVal = sub_80990AC(); + if (gPokemonStorageSystemPtr->unk_08b8 != 0) + { + gPokemonStorageSystemPtr->unk_08b4 += gPokemonStorageSystemPtr->unk_08b6; + gPokemonStorageSystemPtr->unk_08b4 &= 0x1ff; + if (--gPokemonStorageSystemPtr->unk_08b8 == 0) + { + sub_809A598(); + sub_809A810(); + } + return TRUE; + } + return retVal; +} + +s8 sub_8099D90(u8 boxId) +{ + u8 curBox = get_preferred_box(); + u8 i; + + for (i = 0; curBox != boxId; i++) + { + if (++curBox >= 14) + curBox = 0; + } + return i <= 6 ? 1 : -1; +} diff --git a/src/pokemon/pokemon_storage_system_6.c b/src/pokemon/pokemon_storage_system_6.c new file mode 100644 index 000000000..a781c1ed2 --- /dev/null +++ b/src/pokemon/pokemon_storage_system_6.c @@ -0,0 +1,14 @@ + +// Includes +#include "global.h" +#include "pokemon_storage_system.h" + +// Static type declarations + +// Static RAM declarations + +// Static ROM declarations + +// .rodata + +// .text -- cgit v1.2.3 From 8c2c8ed3a9e377382a0ac645053e4b7b4ab41c4e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 12 Jan 2018 12:50:59 -0500 Subject: match unref_sub_8095D08 --- src/pokemon/pokemon_storage_system.c | 149 ++++++----------------------------- 1 file changed, 22 insertions(+), 127 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 80081c963..c02fdfb3a 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -177,7 +177,27 @@ void sub_8095C8C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src } } -#ifdef NONMATCHING +#define MAX_DMA_BLOCK_SIZE 0x1000 +#define Dma3FillLarge_(value, dest, size, bit) \ +{ \ + void *_dest = dest; \ + u32 _size = size; \ + while (1) \ + { \ + if (_size <= MAX_DMA_BLOCK_SIZE) \ + { \ + DmaFill##bit(3, value, _dest, _size); \ + break; \ + } \ + DmaFill##bit(3, value, _dest, MAX_DMA_BLOCK_SIZE); \ + _dest += MAX_DMA_BLOCK_SIZE; \ + _size -= MAX_DMA_BLOCK_SIZE; \ + } \ +} + +#define Dma3FillLarge16_(value, dest, size) Dma3FillLarge_(value, dest, size, 16) +#define Dma3FillLarge32_(value, dest, size) Dma3FillLarge_(value, dest, size, 32) + void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) { u16 i; @@ -185,133 +205,8 @@ void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 he dest += dest_top * 0x20 + dest_left; width *= 2; for (i = 0; i < height; dest += 0x20, i++) - { - void *_dest = dest; - size_t _size = width; - if (_size <= 0x1000) - { - DmaFill16(3, 0, _dest, _size); - } - else - { - while (1) - { - DmaFill16(3, 0, _dest, 0x1000); - _dest += 0x1000; - _size -= 0x1000; - if (_size <= 0x1000) - { - DmaFill16(3, 0, _dest, _size); - break; - } - } - } - } -} -#else -__attribute__((naked)) void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) -{ - asm_unified("\tpush {r4-r7,lr}\n" - "\tmov r7, r10\n" - "\tmov r6, r9\n" - "\tmov r5, r8\n" - "\tpush {r5-r7}\n" - "\tsub sp, 0x8\n" - "\tadds r4, r0, 0\n" - "\tldr r0, [sp, 0x28]\n" - "\tlsls r1, 16\n" - "\tlsrs r1, 16\n" - "\tlsls r2, 16\n" - "\tlsls r0, 16\n" - "\tlsrs r0, 16\n" - "\tmov r10, r0\n" - "\tlsrs r2, 11\n" - "\tadds r2, r1\n" - "\tlsls r2, 1\n" - "\tadds r4, r2\n" - "\tlsls r3, 17\n" - "\tlsrs r0, r3, 16\n" - "\tstr r0, [sp, 0x4]\n" - "\tmovs r0, 0\n" - "\tcmp r0, r10\n" - "\tbcs _08095DB2\n" - "\tmovs r6, 0x80\n" - "\tlsls r6, 5\n" - "\tmov r5, sp\n" - "\tldr r7, _08095D74 @ =0x040000d4\n" - "\tlsrs r3, 17\n" - "\tmov r9, r3\n" - "\tmov r1, r9\n" - "\tmovs r2, 0x81\n" - "\tlsls r2, 24\n" - "\torrs r1, r2\n" - "\tmov r9, r1\n" - "_08095D4E:\n" - "\tadds r3, r4, 0\n" - "\tldr r2, [sp, 0x4]\n" - "\tmovs r1, 0x40\n" - "\tadds r1, r4\n" - "\tmov r8, r1\n" - "\tadds r0, 0x1\n" - "\tmov r12, r0\n" - "\tcmp r2, r6\n" - "\tbhi _08095D78\n" - "\tmovs r0, 0\n" - "\tstrh r0, [r5]\n" - "\tmov r2, sp\n" - "\tstr r2, [r7]\n" - "\tstr r4, [r7, 0x4]\n" - "\tmov r0, r9\n" - "\tstr r0, [r7, 0x8]\n" - "\tldr r0, [r7, 0x8]\n" - "\tb _08095DA6\n" - "\t.align 2, 0\n" - "_08095D74: .4byte 0x040000d4\n" - "_08095D78:\n" - "\tmovs r4, 0\n" - "\tstrh r4, [r5]\n" - "\tldr r1, _08095DC4 @ =0x040000d4\n" - "\tmov r0, sp\n" - "\tstr r0, [r1]\n" - "\tstr r3, [r1, 0x4]\n" - "\tldr r0, _08095DC8 @ =0x81000800\n" - "\tstr r0, [r1, 0x8]\n" - "\tldr r0, [r1, 0x8]\n" - "\tadds r3, r6\n" - "\tsubs r2, r6\n" - "\tcmp r2, r6\n" - "\tbhi _08095D78\n" - "\tstrh r4, [r5]\n" - "\tmov r0, sp\n" - "\tstr r0, [r1]\n" - "\tstr r3, [r1, 0x4]\n" - "\tlsrs r0, r2, 1\n" - "\tmovs r2, 0x81\n" - "\tlsls r2, 24\n" - "\torrs r0, r2\n" - "\tstr r0, [r1, 0x8]\n" - "\tldr r0, [r1, 0x8]\n" - "_08095DA6:\n" - "\tmov r4, r8\n" - "\tmov r1, r12\n" - "\tlsls r0, r1, 16\n" - "\tlsrs r0, 16\n" - "\tcmp r0, r10\n" - "\tbcc _08095D4E\n" - "_08095DB2:\n" - "\tadd sp, 0x8\n" - "\tpop {r3-r5}\n" - "\tmov r8, r3\n" - "\tmov r9, r4\n" - "\tmov r10, r5\n" - "\tpop {r4-r7}\n" - "\tpop {r0}\n" - "\tbx r0\n" - "\t.align 2, 0\n" - "_08095DC4: .4byte 0x040000d4\n" - "_08095DC8: .4byte 0x81000800"); + Dma3FillLarge16_(0, dest, width); } -#endif s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode) { -- cgit v1.2.3 From aadd5c8ac07ef5967d8e2cf58fbdd04f79d5b82a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 12 Jan 2018 13:41:32 -0500 Subject: through sub_8099EB0 and relevant data --- src/pokemon/pokemon_storage_system_4.c | 233 ++++++++++++++++++++++++++++++++- 1 file changed, 232 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 697292d5c..8982ce461 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -1,6 +1,7 @@ // Includes #include "global.h" +#include "palette.h" #include "pokemon_storage_system.h" // Static type declarations @@ -16,14 +17,24 @@ EWRAM_DATA u8 gUnknown_020384E8 = 0; EWRAM_DATA u8 gUnknown_020384E9 = 0; EWRAM_DATA u16 gUnknown_020384EA = 0; +struct WallpaperTable { + const u8 *tiles; + u32 size; + const u8 *tileMap; + const u16 *palettes; +}; + // Static ROM declarations void sub_809900C(u8 boxId, s8 a1); s8 sub_8099D90(u8 boxId); void sub_8099EB0(u8 boxId, s8 a1); +void sub_8099F58(u16 *vdest, const u16 *src, s8 a2, u8 a3); +void sub_809A14C(u16 *vdest); void sub_809A23C(u8 boxId); void sub_809A3D0(u8 boxId, s8 a1); void sub_809A598(void); +void sub_809A654(void); void sub_809A6DC(void); void sub_809A774(s8 a0); void sub_809A810(void); @@ -34,7 +45,7 @@ void sub_809A810(void); void sub_8099BF8(u8 boxId) { - gPokemonStorageSystemPtr->unk_08ba = 0; + gPokemonStorageSystemPtr->unk_08ba = FALSE; gPokemonStorageSystemPtr->unk_08b4 = 0; DmaFill32(3, 0, BG_SCREEN_ADDR(26), 0x1000); sub_8099EB0(boxId, 0); @@ -92,3 +103,223 @@ s8 sub_8099D90(u8 boxId) } return i <= 6 ? 1 : -1; } + +void sub_8099DCC(u8 wallpaperId) +{ + u8 curBox = get_preferred_box(); + gPokemonStorage.wallpaper[curBox] = wallpaperId; + gPokemonStorageSystemPtr->unk_1032 = 0; +} + +bool8 sub_8099E08(void) +{ + switch (gPokemonStorageSystemPtr->unk_1032) + { + case 0: + BeginNormalPaletteFade(gPokemonStorageSystemPtr->unk_0d08, 1, 0, 0x10, 0xffff); + gPokemonStorageSystemPtr->unk_1032++; + break; + case 1: + if (!UpdatePaletteFade()) + { + u8 curBox = get_preferred_box(); + sub_8099EB0(curBox, 0); + sub_809A654(); + BeginNormalPaletteFade(gPokemonStorageSystemPtr->unk_0d08, 1, 0x10, 0, 0xffff); + gPokemonStorageSystemPtr->unk_1032++; + } + break; + case 2: + if (!UpdatePaletteFade()) + gPokemonStorageSystemPtr->unk_1032++; + break; + case 3: + return FALSE; + } + return TRUE; +} + +const u16 gWallpaperPalettes_Forest[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Forest_2[] = INCBIN_U16("graphics/pokemon_storage/forest_frame.gbapal"); +const u16 gWallpaperPalettes_Forest_2_3[] = INCBIN_U16("graphics/pokemon_storage/forest_bg.gbapal"); + +const u8 gWallpaperTiles_Forest[] = INCBIN_U8("graphics/pokemon_storage/forest.4bpp.lz"); + +const u8 gWallpaperTilemap_Forest[] = INCBIN_U8("graphics/pokemon_storage/forest.bin.lz"); + +const u16 gWallpaperPalettes_City[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_City_2[] = INCBIN_U16("graphics/pokemon_storage/city_frame.gbapal"); +const u16 gWallpaperPalettes_City_2_3[] = INCBIN_U16("graphics/pokemon_storage/city_bg.gbapal"); + +const u8 gWallpaperTiles_City[] = INCBIN_U8("graphics/pokemon_storage/city.4bpp.lz"); + +const u8 gWallpaperTilemap_City[] = INCBIN_U8("graphics/pokemon_storage/city.bin.lz"); + +const u16 gWallpaperPalettes_Desert[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Desert_2[] = INCBIN_U16("graphics/pokemon_storage/desert_frame.gbapal"); +const u16 gWallpaperPalettes_Desert_2_3[] = INCBIN_U16("graphics/pokemon_storage/desert_bg.gbapal"); + +const u8 gWallpaperTiles_Desert[] = INCBIN_U8("graphics/pokemon_storage/desert.4bpp.lz"); + +const u8 gWallpaperTilemap_Desert[] = INCBIN_U8("graphics/pokemon_storage/desert.bin.lz"); + +const u16 gWallpaperPalettes_Savanna[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Savanna_2[] = INCBIN_U16("graphics/pokemon_storage/savanna_frame.gbapal"); +const u16 gWallpaperPalettes_Savanna_2_3[] = INCBIN_U16("graphics/pokemon_storage/savanna_bg.gbapal"); + +const u8 gWallpaperTiles_Savanna[] = INCBIN_U8("graphics/pokemon_storage/savanna.4bpp.lz"); + +const u8 gWallpaperTilemap_Savanna[] = INCBIN_U8("graphics/pokemon_storage/savanna.bin.lz"); + +const u16 gWallpaperPalettes_Crag[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Crag_2[] = INCBIN_U16("graphics/pokemon_storage/crag_frame.gbapal"); +const u16 gWallpaperPalettes_Crag_2_3[] = INCBIN_U16("graphics/pokemon_storage/crag_bg.gbapal"); + +const u8 gWallpaperTiles_Crag[] = INCBIN_U8("graphics/pokemon_storage/crag.4bpp.lz"); + +const u8 gWallpaperTilemap_Crag[] = INCBIN_U8("graphics/pokemon_storage/crag.bin.lz"); + +const u16 gWallpaperPalettes_Volcano[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Volcano_2[] = INCBIN_U16("graphics/pokemon_storage/volcano_frame.gbapal"); +const u16 gWallpaperPalettes_Volcano_2_3[] = INCBIN_U16("graphics/pokemon_storage/volcano_bg.gbapal"); + +const u8 gWallpaperTiles_Volcano[] = INCBIN_U8("graphics/pokemon_storage/volcano.4bpp.lz"); +const u32 filler_83b871c = 0; // needed to match but otherwise garbage + +const u8 gWallpaperTilemap_Volcano[] = INCBIN_U8("graphics/pokemon_storage/volcano.bin.lz"); + +const u16 gWallpaperPalettes_Snow[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Snow_2[] = INCBIN_U16("graphics/pokemon_storage/snow_frame.gbapal"); +const u16 gWallpaperPalettes_Snow_2_3[] = INCBIN_U16("graphics/pokemon_storage/snow_bg.gbapal"); + +const u8 gWallpaperTiles_Snow[] = INCBIN_U8("graphics/pokemon_storage/snow.4bpp.lz"); + +const u8 gWallpaperTilemap_Snow[] = INCBIN_U8("graphics/pokemon_storage/snow.bin.lz"); + +const u16 gWallpaperPalettes_Cave[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Cave_2[] = INCBIN_U16("graphics/pokemon_storage/cave_frame.gbapal"); +const u16 gWallpaperPalettes_Cave_2_3[] = INCBIN_U16("graphics/pokemon_storage/cave_bg.gbapal"); + +const u8 gWallpaperTiles_Cave[] = INCBIN_U8("graphics/pokemon_storage/cave.4bpp.lz"); + +const u8 gWallpaperTilemap_Cave[] = INCBIN_U8("graphics/pokemon_storage/cave.bin.lz"); + +const u16 gWallpaperPalettes_Beach[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Beach_2[] = INCBIN_U16("graphics/pokemon_storage/beach_frame.gbapal"); +const u16 gWallpaperPalettes_Beach_2_3[] = INCBIN_U16("graphics/pokemon_storage/beach_bg.gbapal"); + +const u8 gWallpaperTiles_Beach[] = INCBIN_U8("graphics/pokemon_storage/beach.4bpp.lz"); + +const u8 gWallpaperTilemap_Beach[] = INCBIN_U8("graphics/pokemon_storage/beach.bin.lz"); + +const u16 gWallpaperPalettes_Seafloor[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Seafloor_2[] = INCBIN_U16("graphics/pokemon_storage/seafloor_frame.gbapal"); +const u16 gWallpaperPalettes_Seafloor_2_3[] = INCBIN_U16("graphics/pokemon_storage/seafloor_bg.gbapal"); + +const u8 gWallpaperTiles_Seafloor[] = INCBIN_U8("graphics/pokemon_storage/seafloor.4bpp.lz"); + +const u8 gWallpaperTilemap_Seafloor[] = INCBIN_U8("graphics/pokemon_storage/seafloor.bin.lz"); + +const u16 gWallpaperPalettes_River[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_River_2[] = INCBIN_U16("graphics/pokemon_storage/river_frame.gbapal"); +const u16 gWallpaperPalettes_River_2_3[] = INCBIN_U16("graphics/pokemon_storage/river_bg.gbapal"); + +const u8 gWallpaperTiles_River[] = INCBIN_U8("graphics/pokemon_storage/river.4bpp.lz"); + +const u8 gWallpaperTilemap_River[] = INCBIN_U8("graphics/pokemon_storage/river.bin.lz"); + +const u16 gWallpaperPalettes_Sky[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); +const u16 gWallpaperPalettes_Sky_2[] = INCBIN_U16("graphics/pokemon_storage/sky_frame.gbapal"); +const u16 gWallpaperPalettes_Sky_2_3[] = INCBIN_U16("graphics/pokemon_storage/sky_bg.gbapal"); + +const u8 gWallpaperTiles_Sky[] = INCBIN_U8("graphics/pokemon_storage/sky.4bpp.lz"); + +const u8 gWallpaperTilemap_Sky[] = INCBIN_U8("graphics/pokemon_storage/sky.bin.lz"); + +const u16 gWallpaperPalettes_Polkadot[] = INCBIN_U16("graphics/pokemon_storage/box_bg2.gbapal"); +const u16 gWallpaperPalettes_Polkadot_2[] = INCBIN_U16("graphics/pokemon_storage/polkadot_frame.gbapal"); +const u16 gWallpaperPalettes_Polkadot_2_3[] = INCBIN_U16("graphics/pokemon_storage/polkadot_bg.gbapal"); + +const u8 gWallpaperTiles_Polkadot[] = INCBIN_U8("graphics/pokemon_storage/polkadot.4bpp.lz"); + +const u8 gWallpaperTilemap_Polkadot[] = INCBIN_U8("graphics/pokemon_storage/polkadot.bin.lz"); + +const u16 gWallpaperPalettes_Pokecenter[] = INCBIN_U16("graphics/pokemon_storage/box_bg2.gbapal"); +const u16 gWallpaperPalettes_Pokecenter_2[] = INCBIN_U16("graphics/pokemon_storage/pokecenter_frame.gbapal"); +const u16 gWallpaperPalettes_Pokecenter_2_3[] = INCBIN_U16("graphics/pokemon_storage/pokecenter_bg.gbapal"); + +const u8 gWallpaperTiles_Pokecenter[] = INCBIN_U8("graphics/pokemon_storage/pokecenter.4bpp.lz"); + +const u8 gWallpaperTilemap_Pokecenter[] = INCBIN_U8("graphics/pokemon_storage/pokecenter.bin.lz"); + +const u16 gWallpaperPalettes_Machine[] = INCBIN_U16("graphics/pokemon_storage/box_bg3.gbapal"); +const u16 gWallpaperPalettes_Machine_2[] = INCBIN_U16("graphics/pokemon_storage/machine_frame.gbapal"); +const u16 gWallpaperPalettes_Machine_2_3[] = INCBIN_U16("graphics/pokemon_storage/machine_bg.gbapal"); + +const u8 gWallpaperTiles_Machine[] = INCBIN_U8("graphics/pokemon_storage/machine.4bpp.lz"); + +const u8 gWallpaperTilemap_Machine[] = INCBIN_U8("graphics/pokemon_storage/machine.bin.lz"); + +const u16 gWallpaperPalettes_Plain[] = INCBIN_U16("graphics/pokemon_storage/box_bg4.gbapal"); +const u16 gWallpaperPalettes_Plain_2[] = INCBIN_U16("graphics/pokemon_storage/plain_frame.gbapal"); +const u16 gWallpaperPalettes_Plain_2_3[] = INCBIN_U16("graphics/pokemon_storage/plain_bg.gbapal"); + +const u8 gWallpaperTiles_Plain[] = INCBIN_U8("graphics/pokemon_storage/plain.4bpp.lz"); + +const u8 gWallpaperTilemap_Plain[] = INCBIN_U8("graphics/pokemon_storage/plain.bin.lz"); + +const u16 gUnknown_083BAEF8[] = INCBIN_U16("graphics/unused/tilemap_3BAEF8.bin"); + +const u16 gUnknown_083BB0A8[][2] = { + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF} +}; + +const struct WallpaperTable gWallpaperTable[] = { + {gWallpaperTiles_Forest, 0x3D0, gWallpaperTilemap_Forest, gWallpaperPalettes_Forest}, // Forest + {gWallpaperTiles_City, 0x208, gWallpaperTilemap_City, gWallpaperPalettes_City}, // City + {gWallpaperTiles_Desert, 0x2EC, gWallpaperTilemap_Desert, gWallpaperPalettes_Desert}, // Desert + {gWallpaperTiles_Savanna, 0x220, gWallpaperTilemap_Savanna, gWallpaperPalettes_Savanna}, // Savanna + {gWallpaperTiles_Crag, 0x350, gWallpaperTilemap_Crag, gWallpaperPalettes_Crag}, // Crag + {gWallpaperTiles_Volcano, 0x334, gWallpaperTilemap_Volcano, gWallpaperPalettes_Volcano}, // Volcano + {gWallpaperTiles_Snow, 0x2B8, gWallpaperTilemap_Snow, gWallpaperPalettes_Snow}, // Snow + {gWallpaperTiles_Cave, 0x344, gWallpaperTilemap_Cave, gWallpaperPalettes_Cave}, // Cave + {gWallpaperTiles_Beach, 0x384, gWallpaperTilemap_Beach, gWallpaperPalettes_Beach}, // Beach + {gWallpaperTiles_Seafloor, 0x2B4, gWallpaperTilemap_Seafloor, gWallpaperPalettes_Seafloor}, // Seafloor + {gWallpaperTiles_River, 0x294, gWallpaperTilemap_River, gWallpaperPalettes_River}, // River + {gWallpaperTiles_Sky, 0x298, gWallpaperTilemap_Sky, gWallpaperPalettes_Sky}, // Sky + {gWallpaperTiles_Polkadot, 0x1FC, gWallpaperTilemap_Polkadot, gWallpaperPalettes_Polkadot}, // Polkadot + {gWallpaperTiles_Pokecenter, 0x3A4, gWallpaperTilemap_Pokecenter, gWallpaperPalettes_Pokecenter}, // Pokecenter + {gWallpaperTiles_Machine, 0x2F0, gWallpaperTilemap_Machine, gWallpaperPalettes_Machine}, // Machine + {gWallpaperTiles_Plain, 0xFC, gWallpaperTilemap_Plain, gWallpaperPalettes_Plain} // Plain +}; + +void sub_8099EB0(u8 boxId, s8 a1) +{ + const struct WallpaperTable *wallpaperTable; + + if (a1) + { + gPokemonStorageSystemPtr->unk_08ba = gPokemonStorageSystemPtr->unk_08ba ? FALSE : TRUE; + sub_809A14C(BG_SCREEN_ADDR(26)); + } + wallpaperTable = gWallpaperTable +gPokemonStorage.wallpaper[boxId]; + LoadPalette(wallpaperTable->palettes, gPokemonStorageSystemPtr->unk_08ba * 0x30 + 0x40, 0x60); + LZ77UnCompWram(wallpaperTable->tileMap, gPokemonStorageSystemPtr->unk_0d62); + sub_8099F58(BG_SCREEN_ADDR(26), gPokemonStorageSystemPtr->unk_0d62, a1, gPokemonStorageSystemPtr->unk_08ba); + LZ77UnCompVram(wallpaperTable->tiles, BG_CHAR_ADDR(2) + (gPokemonStorageSystemPtr->unk_08ba << 13)); +} -- cgit v1.2.3 From e9c74d2472bc322b9d60f1b7033268efbd0bd159 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 13 Jan 2018 13:02:57 -0500 Subject: nonmatching sub_8099F58 --- src/pokemon/pokemon_storage_system_4.c | 350 +++++++++++++++++++++++++++++++++ 1 file changed, 350 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 8982ce461..9f19814a5 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -323,3 +323,353 @@ void sub_8099EB0(u8 boxId, s8 a1) sub_8099F58(BG_SCREEN_ADDR(26), gPokemonStorageSystemPtr->unk_0d62, a1, gPokemonStorageSystemPtr->unk_08ba); LZ77UnCompVram(wallpaperTable->tiles, BG_CHAR_ADDR(2) + (gPokemonStorageSystemPtr->unk_08ba << 13)); } + +#ifdef NONMATCHING +void sub_8099F58(u16 *vdest, const u16 *src, s8 a2, u8 a3) +{ + s16 r6; + s16 r3; + u16 sp0 = a3 << 8; + u16 sp4 = (a3 * 3 + 4) << 12; + u16 *r4; + u16 *r7; + u16 i; + u16 j; + s16 sp8 = ((gPokemonStorageSystemPtr->unk_08b4 >> 3) + 10 + a2 * 24) & 0x3f; + if (sp8 < 13) + { + r6 = 20; + r3 = 0; + r4 = vdest + sp8 + 0x40; + r7 = NULL; + } + else if (sp8 < 32) + { + r6 = 32 - sp8; + r3 = 20 - r6; + r4 = vdest + sp8 + 0x40; + r7 = vdest + 0x440; + } + else if (sp8 < 45) + { + r6 = 20; + r3 = 0; + r4 = vdest + sp8 + 0x420; + r7 = NULL; + } + else + { + r6 = 64 - sp8; + r3 = 20 - r6; + r4 = vdest + sp8 + 0x420; + r7 = vdest + 0x40; + } + for (i = 0; i < 18; i++) + { + for (j = 0; j < r6; j++) + { + u16 tile = ((*src & 0xfff) + sp0) | ((*src & 0xf000) + sp4); + r4[j] = tile; + src++; + } + for (j = 0; j < r3; j++) + { + u16 tile = ((*src & 0xfff) + sp0) | ((*src & 0xf000) + sp4); + r7[j] = tile; + src++; + } + r4 += 0x20; + r7 += 0x20; + } + if (a2) + { + s16 r4_2; + u16 *r2; + if (a2 > 0) + r4_2 = (sp8 + 20) & 0x3f; + else + r4_2 = (sp8 - 4) & 0x3f; + r2 = r4_2 < 0x20 ? vdest + r4_2 + 0x40 : vdest + r4_2 + 0x420; + for (i = 0; i < 4; i++) + { + for (j = 0; j < 18; j++) + { + *r2 = 0; + r2 += 0x20; + } + r4_2++; + r4_2 &= 0x3f; + r2 = r4_2 < 0x20 ? vdest + r4_2 + 0x40 : vdest + r4_2 + 0x420; + } + } +} +#else +__attribute__((naked)) void sub_8099F58(u16 *vdest, const u16 *src, s8 a2, u8 a3) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tsub sp, 0x20\n" + "\tmov r9, r0\n" + "\tadds r5, r1, 0\n" + "\tlsls r2, 24\n" + "\tlsls r3, 24\n" + "\tlsrs r3, 24\n" + "\tlsls r0, r3, 8\n" + "\tstr r0, [sp]\n" + "\tlsls r0, r3, 1\n" + "\tadds r0, r3\n" + "\tadds r0, 0x4\n" + "\tlsls r0, 28\n" + "\tlsrs r0, 16\n" + "\tstr r0, [sp, 0x4]\n" + "\tldr r0, _08099FB8 @ =gPokemonStorageSystemPtr\n" + "\tldr r0, [r0]\n" + "\tldr r1, _08099FBC @ =0x000008b4\n" + "\tadds r0, r1\n" + "\tldrh r1, [r0]\n" + "\tlsrs r1, 3\n" + "\tadds r1, 0xA\n" + "\tlsrs r0, r2, 24\n" + "\tmov r8, r0\n" + "\tasrs r2, 24\n" + "\tlsls r0, r2, 1\n" + "\tadds r0, r2\n" + "\tlsls r0, 3\n" + "\tadds r1, r0\n" + "\tmovs r0, 0x3F\n" + "\tands r1, r0\n" + "\tstr r1, [sp, 0x8]\n" + "\tadds r2, r1, 0\n" + "\tcmp r2, 0xC\n" + "\tbgt _08099FC0\n" + "\tmovs r6, 0x14\n" + "\tmovs r3, 0\n" + "\tlsls r0, r2, 1\n" + "\tadds r0, 0x80\n" + "\tmov r1, r9\n" + "\tadds r4, r1, r0\n" + "\tmovs r7, 0\n" + "\tb _0809A020\n" + "\t.align 2, 0\n" + "_08099FB8: .4byte gPokemonStorageSystemPtr\n" + "_08099FBC: .4byte 0x000008b4\n" + "_08099FC0:\n" + "\tcmp r2, 0x1F\n" + "\tbgt _08099FE6\n" + "\tmovs r0, 0x20\n" + "\tsubs r0, r2\n" + "\tlsls r0, 16\n" + "\tmovs r1, 0x14\n" + "\tlsrs r6, r0, 16\n" + "\tasrs r0, 16\n" + "\tsubs r1, r0\n" + "\tlsls r1, 16\n" + "\tlsrs r3, r1, 16\n" + "\tlsls r0, r2, 1\n" + "\tadds r0, 0x80\n" + "\tmov r2, r9\n" + "\tadds r4, r2, r0\n" + "\tmovs r7, 0x88\n" + "\tlsls r7, 4\n" + "\tadd r7, r9\n" + "\tb _0809A020\n" + "_08099FE6:\n" + "\tcmp r2, 0x2C\n" + "\tbgt _08099FFE\n" + "\tmovs r6, 0x14\n" + "\tmovs r3, 0\n" + "\tlsls r0, r2, 1\n" + "\tmovs r1, 0x84\n" + "\tlsls r1, 4\n" + "\tadds r0, r1\n" + "\tmov r2, r9\n" + "\tadds r4, r2, r0\n" + "\tmovs r7, 0\n" + "\tb _0809A020\n" + "_08099FFE:\n" + "\tmovs r0, 0x40\n" + "\tsubs r0, r2\n" + "\tlsls r0, 16\n" + "\tmovs r1, 0x14\n" + "\tlsrs r6, r0, 16\n" + "\tasrs r0, 16\n" + "\tsubs r1, r0\n" + "\tlsls r1, 16\n" + "\tlsrs r3, r1, 16\n" + "\tlsls r0, r2, 1\n" + "\tmovs r1, 0x84\n" + "\tlsls r1, 4\n" + "\tadds r0, r1\n" + "\tmov r2, r9\n" + "\tadds r4, r2, r0\n" + "\tmov r7, r9\n" + "\tadds r7, 0x80\n" + "_0809A020:\n" + "\tmovs r1, 0\n" + "\tmov r0, r8\n" + "\tlsls r0, 24\n" + "\tstr r0, [sp, 0x14]\n" + "\tlsls r0, r6, 16\n" + "\tasrs r0, 16\n" + "\tmov r8, r0\n" + "\tlsls r3, 16\n" + "\tstr r3, [sp, 0xC]\n" + "\tasrs r2, r3, 16\n" + "\tstr r2, [sp, 0x10]\n" + "_0809A036:\n" + "\tmovs r3, 0\n" + "\tadds r0, r4, 0\n" + "\tadds r0, 0x40\n" + "\tstr r0, [sp, 0x18]\n" + "\tadds r2, r7, 0\n" + "\tadds r2, 0x40\n" + "\tstr r2, [sp, 0x1C]\n" + "\tadds r1, 0x1\n" + "\tmov r10, r1\n" + "\tcmp r3, r8\n" + "\tbge _0809A07A\n" + "\tldr r0, _0809A0D4 @ =0x00000fff\n" + "\tmov r12, r0\n" + "\tmovs r6, 0xF0\n" + "\tlsls r6, 8\n" + "_0809A054:\n" + "\tldrh r2, [r5]\n" + "\tmov r0, r12\n" + "\tands r0, r2\n" + "\tldr r1, [sp]\n" + "\tadds r0, r1, r0\n" + "\tadds r1, r6, 0\n" + "\tands r1, r2\n" + "\tldr r2, [sp, 0x4]\n" + "\tadds r1, r2, r1\n" + "\torrs r1, r0\n" + "\tlsls r0, r3, 1\n" + "\tadds r0, r4\n" + "\tstrh r1, [r0]\n" + "\tadds r5, 0x2\n" + "\tadds r0, r3, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r3, r0, 16\n" + "\tcmp r3, r8\n" + "\tblt _0809A054\n" + "_0809A07A:\n" + "\tmovs r3, 0\n" + "\tldr r0, [sp, 0x10]\n" + "\tcmp r3, r0\n" + "\tbge _0809A0B4\n" + "\tldr r1, _0809A0D4 @ =0x00000fff\n" + "\tmov r12, r1\n" + "\tmovs r6, 0xF0\n" + "\tlsls r6, 8\n" + "\tldr r2, [sp, 0xC]\n" + "\tasrs r4, r2, 16\n" + "_0809A08E:\n" + "\tldrh r2, [r5]\n" + "\tmov r0, r12\n" + "\tands r0, r2\n" + "\tldr r1, [sp]\n" + "\tadds r0, r1, r0\n" + "\tadds r1, r6, 0\n" + "\tands r1, r2\n" + "\tldr r2, [sp, 0x4]\n" + "\tadds r1, r2, r1\n" + "\torrs r1, r0\n" + "\tlsls r0, r3, 1\n" + "\tadds r0, r7\n" + "\tstrh r1, [r0]\n" + "\tadds r5, 0x2\n" + "\tadds r0, r3, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r3, r0, 16\n" + "\tcmp r3, r4\n" + "\tblt _0809A08E\n" + "_0809A0B4:\n" + "\tldr r4, [sp, 0x18]\n" + "\tldr r7, [sp, 0x1C]\n" + "\tmov r1, r10\n" + "\tlsls r0, r1, 16\n" + "\tlsrs r1, r0, 16\n" + "\tcmp r1, 0x11\n" + "\tbls _0809A036\n" + "\tldr r0, [sp, 0x14]\n" + "\tasrs r2, r0, 24\n" + "\tcmp r2, 0\n" + "\tbeq _0809A13A\n" + "\tcmp r2, 0\n" + "\tble _0809A0D8\n" + "\tldr r1, [sp, 0x8]\n" + "\tadds r1, 0x14\n" + "\tb _0809A0DC\n" + "\t.align 2, 0\n" + "_0809A0D4: .4byte 0x00000fff\n" + "_0809A0D8:\n" + "\tldr r1, [sp, 0x8]\n" + "\tsubs r1, 0x4\n" + "_0809A0DC:\n" + "\tmovs r0, 0x3F\n" + "\tands r1, r0\n" + "\tadds r4, r1, 0\n" + "\tadds r0, r4, 0\n" + "\tcmp r0, 0x1F\n" + "\tbgt _0809A0EE\n" + "\tlsls r0, 1\n" + "\tadds r0, 0x80\n" + "\tb _0809A0F6\n" + "_0809A0EE:\n" + "\tlsls r0, 1\n" + "\tmovs r2, 0x84\n" + "\tlsls r2, 4\n" + "\tadds r0, r2\n" + "_0809A0F6:\n" + "\tmov r1, r9\n" + "\tadds r2, r1, r0\n" + "\tmovs r3, 0\n" + "\tmovs r6, 0\n" + "_0809A0FE:\n" + "\tmovs r1, 0\n" + "\tadds r5, r3, 0x1\n" + "\tlsls r3, r4, 16\n" + "_0809A104:\n" + "\tstrh r6, [r2]\n" + "\tadds r2, 0x40\n" + "\tadds r0, r1, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r1, r0, 16\n" + "\tcmp r1, 0x11\n" + "\tbls _0809A104\n" + "\tasrs r0, r3, 16\n" + "\tadds r4, r0, 0x1\n" + "\tmovs r0, 0x3F\n" + "\tands r4, r0\n" + "\tadds r0, r4, 0\n" + "\tcmp r0, 0x1F\n" + "\tbgt _0809A126\n" + "\tlsls r0, 1\n" + "\tadds r0, 0x80\n" + "\tb _0809A12E\n" + "_0809A126:\n" + "\tlsls r0, 1\n" + "\tmovs r2, 0x84\n" + "\tlsls r2, 4\n" + "\tadds r0, r2\n" + "_0809A12E:\n" + "\tmov r1, r9\n" + "\tadds r2, r1, r0\n" + "\tlsls r0, r5, 16\n" + "\tlsrs r3, r0, 16\n" + "\tcmp r3, 0x3\n" + "\tbls _0809A0FE\n" + "_0809A13A:\n" + "\tadd sp, 0x20\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0"); +} +#endif -- cgit v1.2.3 From a5721ffd736f30d424da8aede5c52071365f3850 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 13 Jan 2018 16:40:15 -0500 Subject: nonmatching sub_809A14C --- src/pokemon/pokemon_storage_system_4.c | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 9f19814a5..1ccaa01f1 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -673,3 +673,87 @@ __attribute__((naked)) void sub_8099F58(u16 *vdest, const u16 *src, s8 a2, u8 a3 "\tbx r0"); } #endif + +#ifdef NONMATCHING +void sub_809A14C(u16 *vdest) +{ + u16 *r2; + u16 i; + int r3 = ((gPokemonStorageSystemPtr->unk_08b4 >> 3) + 30) & 0x3f; + r2 = vdest + (r3 < 0x20 ? r3 + 0x260 : r3 + 0x640); + for (i = 0; i < 0x2b; i++) + { + *r2++ = 0; + r3++; + r3 &= 0x3f; + if (r3 == 0) + r2 -= 0x420; + if (r3 == 0x20) + r2 += 0x3e0; + } +} +#else +__attribute__((naked)) void sub_809A14C(u16 *vdest) +{ + asm_unified("\tpush {r4-r6,lr}\n" + "\tadds r2, r0, 0\n" + "\tldr r0, _0809A174 @ =gPokemonStorageSystemPtr\n" + "\tldr r0, [r0]\n" + "\tldr r1, _0809A178 @ =0x000008b4\n" + "\tadds r0, r1\n" + "\tldrh r0, [r0]\n" + "\tlsrs r0, 3\n" + "\tadds r3, r0, 0\n" + "\tadds r3, 0x1E\n" + "\tmovs r0, 0x3F\n" + "\tands r3, r0\n" + "\tadds r0, r3, 0\n" + "\tcmp r0, 0x1F\n" + "\tbgt _0809A17C\n" + "\tlsls r0, 1\n" + "\tmovs r6, 0x98\n" + "\tlsls r6, 3\n" + "\tadds r0, r6\n" + "\tb _0809A184\n" + "\t.align 2, 0\n" + "_0809A174: .4byte gPokemonStorageSystemPtr\n" + "_0809A178: .4byte 0x000008b4\n" + "_0809A17C:\n" + "\tlsls r0, 1\n" + "\tmovs r1, 0xC8\n" + "\tlsls r1, 4\n" + "\tadds r0, r1\n" + "_0809A184:\n" + "\tadds r2, r0\n" + "\tmovs r0, 0\n" + "\tmovs r5, 0\n" + "\tmovs r4, 0x3F\n" + "_0809A18C:\n" + "\tstrh r5, [r2]\n" + "\tadds r2, 0x2\n" + "\tadds r3, 0x1\n" + "\tands r3, r4\n" + "\tadds r1, r3, 0\n" + "\tcmp r1, 0\n" + "\tbne _0809A19E\n" + "\tldr r6, _0809A1B8 @ =0xfffff7c0\n" + "\tadds r2, r6\n" + "_0809A19E:\n" + "\tcmp r1, 0x20\n" + "\tbne _0809A1A8\n" + "\tmovs r1, 0xF8\n" + "\tlsls r1, 3\n" + "\tadds r2, r1\n" + "_0809A1A8:\n" + "\tadds r0, 0x1\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tcmp r0, 0x2B\n" + "\tbls _0809A18C\n" + "\tpop {r4-r6}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_0809A1B8: .4byte 0xfffff7c0"); +} +#endif -- cgit v1.2.3 From daa0a98ee0129be1797274de318a35df30d39020 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 13 Jan 2018 20:07:32 -0500 Subject: through sub_809A23C --- src/pokemon/pokemon_storage_system_4.c | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 1ccaa01f1..836a3433f 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -2,6 +2,8 @@ // Includes #include "global.h" #include "palette.h" +#include "text.h" +#include "menu.h" #include "pokemon_storage_system.h" // Static type declarations @@ -35,6 +37,7 @@ void sub_809A23C(u8 boxId); void sub_809A3D0(u8 boxId, s8 a1); void sub_809A598(void); void sub_809A654(void); +s16 sub_809A6D0(u8 width); void sub_809A6DC(void); void sub_809A774(s8 a0); void sub_809A810(void); @@ -757,3 +760,90 @@ __attribute__((naked)) void sub_809A14C(u16 *vdest) "_0809A1B8: .4byte 0xfffff7c0"); } #endif + +void sub_809A1BC(const u8 *a0, const u8 *text) +{ + u8 *r5 = gUnknown_083B6DB8; + DmaClear16(3, r5, 0x200); + Text_InitWindow8004E3C(&gWindowTemplate_81E6D38, r5, text); + DmaCopy16(3, r5 + 0x000, a0 + 0x000, 0x80); + DmaCopy16(3, r5 + 0x100, a0 + 0x080, 0x80); + DmaCopy16(3, r5 + 0x080, a0 + 0x100, 0x80); + DmaCopy16(3, r5 + 0x180, a0 + 0x180, 0x80); +} + +const struct SpriteTemplate gSpriteTemplate_83BB2B8; + +void sub_809A23C(u8 boxId) +{ + u8 tagIdx; + s16 r6; + u16 i; + + struct SpriteSheet spriteSheet = {gPokemonStorageSystemPtr->unk_08ca, 0x200, 3}; + struct SpritePalette palettes[] = { + {gPokemonStorageSystemPtr->unk_0ccc, 0xdac8}, + {gPokemonStorageSystemPtr->unk_0ccc, 0xdac9}, + {} + }; + + u16 wallpaper = gPokemonStorage.wallpaper[boxId]; + gPokemonStorageSystemPtr->unk_0ccc[14] = gUnknown_083BB0A8[wallpaper][0]; + gPokemonStorageSystemPtr->unk_0ccc[15] = gUnknown_083BB0A8[wallpaper][1]; + LoadSpritePalettes(palettes); + gPokemonStorageSystemPtr->unk_0d08 = 0x3f0; + tagIdx = IndexOfSpritePaletteTag(0xdac8); + gPokemonStorageSystemPtr->unk_0cec = 0x10e + 16 * tagIdx; + gPokemonStorageSystemPtr->unk_0d08 |= 0x10000 << tagIdx; + tagIdx = IndexOfSpritePaletteTag(0xdac9); + gPokemonStorageSystemPtr->unk_0cee = 0x10e + 16 * tagIdx; + gPokemonStorageSystemPtr->unk_0d08 |= 0x10000 << tagIdx; + sub_809A1BC(gPokemonStorageSystemPtr->unk_08ca, gPokemonStorage.boxNames[boxId]); + LoadSpriteSheet(&spriteSheet); + r6 = sub_809A6D0(sub_8072CA4(gPokemonStorage.boxNames[boxId])); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gSpriteTemplate_83BB2B8, r6 + i * 32, 0x1c, 23); + gPokemonStorageSystemPtr->unk_0cf0[i] = gSprites + spriteId; + StartSpriteAnim(gPokemonStorageSystemPtr->unk_0cf0[i], i); + } + gPokemonStorageSystemPtr->unk_0cca = 0; +} + + +const u16 PCPal_Arrow[] = INCBIN_U16("graphics/pokemon_storage/arrow.gbapal"); +const u8 PCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp"); + +const struct SpriteSheet gUnknown_083BB288 = {PCGfx_Arrow, 0x80, 6}; +const struct SpritePalette gUnknown_083BB290 = {PCPal_Arrow, 0xdacf}; + +const struct OamData gOamData_83BB298 = { + .shape = ST_OAM_H_RECTANGLE, + .size = 2, + .priority = 2 +}; + +const union AnimCmd gSpriteAnim_83BB2A0[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83BB2A8[] = { + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83BB2B0[] = { + gSpriteAnim_83BB2A0, + gSpriteAnim_83BB2A8 +}; + +const struct SpriteTemplate gSpriteTemplate_83BB2B8 = { + 3, + 0xdac8, + &gOamData_83BB298, + gSpriteAnimTable_83BB2B0, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; -- cgit v1.2.3 From e8daaa0f3ef2d97f7afe378494f33037f5bc8ee9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 14 Jan 2018 18:21:22 -0500 Subject: sub_809A3D0 --- src/pokemon/pokemon_storage_system_4.c | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 836a3433f..b0378a254 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -36,11 +36,14 @@ void sub_809A14C(u16 *vdest); void sub_809A23C(u8 boxId); void sub_809A3D0(u8 boxId, s8 a1); void sub_809A598(void); +void sub_809A5E8(struct Sprite *sprite); +void sub_809A61C(struct Sprite *sprite); void sub_809A654(void); s16 sub_809A6D0(u8 width); void sub_809A6DC(void); void sub_809A774(s8 a0); void sub_809A810(void); +void sub_809A8C8(struct Sprite *sprite); // .rodata @@ -810,6 +813,47 @@ void sub_809A23C(u8 boxId) gPokemonStorageSystemPtr->unk_0cca = 0; } +void sub_809A3D0(u8 boxId, s8 a1) +{ + u16 r8; + s16 x; + s16 x2; + u16 i; + struct SpriteSheet spriteSheet = {gPokemonStorageSystemPtr->unk_08ca, 0x200, 3}; + struct SpriteTemplate template = gSpriteTemplate_83BB2B8; + + gPokemonStorageSystemPtr->unk_0cca = gPokemonStorageSystemPtr->unk_0cca ? FALSE : TRUE; + if (gPokemonStorageSystemPtr->unk_0cca == 0) + { + spriteSheet.tag = 3; + r8 = gPokemonStorageSystemPtr->unk_0cec; + } + else + { + spriteSheet.tag = 4; + r8 = gPokemonStorageSystemPtr->unk_0cec; + template.tileTag = 4; + template.paletteTag = 0xdac9; + } + sub_809A1BC(gPokemonStorageSystemPtr->unk_08ca, gPokemonStorage.boxNames[boxId]); + LoadSpriteSheet(&spriteSheet); + LoadPalette(gUnknown_083BB0A8[gPokemonStorage.wallpaper[boxId]], r8, 0x04); + x = sub_809A6D0(sub_8072CA4(gPokemonStorage.boxNames[boxId])); + x2 = x + a1 * 192; + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&template, i * 32 + x2, 0x1c, 23); + gPokemonStorageSystemPtr->unk_0cf8[i] = gSprites + spriteId; + gPokemonStorageSystemPtr->unk_0cf8[i]->data[0] = (-a1) * 6; + gPokemonStorageSystemPtr->unk_0cf8[i]->data[1] = i * 32 + x; + gPokemonStorageSystemPtr->unk_0cf8[i]->data[2] = 1; + gPokemonStorageSystemPtr->unk_0cf8[i]->callback = sub_809A5E8; + StartSpriteAnim(gPokemonStorageSystemPtr->unk_0cf8[i], i); + gPokemonStorageSystemPtr->unk_0cf0[i]->data[0] = (-a1) * 6; + gPokemonStorageSystemPtr->unk_0cf0[i]->data[1] = 1; + gPokemonStorageSystemPtr->unk_0cf0[i]->callback = sub_809A61C; + } +} const u16 PCPal_Arrow[] = INCBIN_U16("graphics/pokemon_storage/arrow.gbapal"); const u8 PCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp"); -- cgit v1.2.3 From f33a73ed931885507b1a5f199044d85255078bc2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 14 Jan 2018 18:37:27 -0500 Subject: through sub_809A6D0 --- src/pokemon/pokemon_storage_system_4.c | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index b0378a254..b48b20d5c 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -891,3 +891,49 @@ const struct SpriteTemplate gSpriteTemplate_83BB2B8 = { gDummySpriteAffineAnimTable, SpriteCallbackDummy }; + +void sub_809A598(void) +{ + if (gPokemonStorageSystemPtr->unk_0cca == 0) + FreeSpriteTilesByTag(4); + else + FreeSpriteTilesByTag(3); + gPokemonStorageSystemPtr->unk_0cf0[0] = gPokemonStorageSystemPtr->unk_0cf8[0]; + gPokemonStorageSystemPtr->unk_0cf0[1] = gPokemonStorageSystemPtr->unk_0cf8[1]; +} + +void sub_809A5E8(struct Sprite *sprite) +{ + if (sprite->data[2]) + sprite->data[2]--; + else if ((sprite->pos1.x += sprite->data[0]) == sprite->data[1]) + sprite->callback = SpriteCallbackDummy; +} + +void sub_809A61C(struct Sprite *sprite) +{ + if (sprite->data[1]) + sprite->data[1]--; + else + { + sprite->pos1.x += sprite->data[0]; + sprite->data[2] = sprite->pos1.x + sprite->pos2.x; + if (sprite->data[2] < 0x40 || sprite->data[2] > 0x100) + DestroySprite(sprite); + } +} + +void sub_809A654(void) +{ + u8 boxId = get_preferred_box(); + u8 wallpaperId = gPokemonStorage.wallpaper[boxId]; + if (gPokemonStorageSystemPtr->unk_0cca == 0) + CpuCopy16(gUnknown_083BB0A8[wallpaperId], gPlttBufferUnfaded + gPokemonStorageSystemPtr->unk_0cec, 4); + else + CpuCopy16(gUnknown_083BB0A8[wallpaperId], gPlttBufferUnfaded + gPokemonStorageSystemPtr->unk_0cee, 4); +} + +s16 sub_809A6D0(u8 width) +{ + return 0xb0 - width / 2; +} -- cgit v1.2.3 From 5fcd1184d8a189887e44559edb12417717afca5b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 14 Jan 2018 19:10:31 -0500 Subject: through sub_809A860 --- src/pokemon/pokemon_storage_system_2.c | 8 +- src/pokemon/pokemon_storage_system_4.c | 384 +++++++++++++++++++++------------ 2 files changed, 253 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index 290fa120a..4657ed158 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -1096,7 +1096,7 @@ void sub_809789C(void) { case -1: case 0: - sub_809A860(1); + sub_809A860(TRUE); sub_8098A5C(); SetPSSCallback(sub_8096C84); break; @@ -1133,7 +1133,7 @@ void sub_8097974(void) switch (gPokemonStorageSystemPtr->unk_0d5e) { case -1: - sub_809A860(1); + sub_809A860(TRUE); sub_8098A5C(); SetPSSCallback(sub_8096C84); break; @@ -1168,7 +1168,7 @@ void sub_8097974(void) case 3: if (!sub_8099E08()) { - sub_809A860(1); + sub_809A860(TRUE); SetPSSCallback(sub_8096C84); } break; @@ -1197,7 +1197,7 @@ void sub_8097A64(void) sub_8096310(); if (gPokemonStorageSystemPtr->unk_08b2 == 201 || gPokemonStorageSystemPtr->unk_08b2 == gPokemonStorage.currentBox) { - sub_809A860(1); + sub_809A860(TRUE); SetPSSCallback(sub_8096C84); } else diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index b48b20d5c..b40cc916c 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -44,107 +44,10 @@ void sub_809A6DC(void); void sub_809A774(s8 a0); void sub_809A810(void); void sub_809A8C8(struct Sprite *sprite); +bool8 sub_809BF2C(void); // .rodata -// .text - -void sub_8099BF8(u8 boxId) -{ - gPokemonStorageSystemPtr->unk_08ba = FALSE; - gPokemonStorageSystemPtr->unk_08b4 = 0; - DmaFill32(3, 0, BG_SCREEN_ADDR(26), 0x1000); - sub_8099EB0(boxId, 0); - sub_809A23C(boxId); - sub_809A6DC(); - SpawnBoxIconSprites(boxId); - REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_TXT512x256; -} - -void sub_8099C70(u8 whichBox) -{ - s8 r4 = sub_8099D90(whichBox); - sub_8099EB0(whichBox, r4); - gPokemonStorageSystemPtr->unk_08b6 = r4 * 6; - gPokemonStorageSystemPtr->unk_08b8 = 0x20; - gPokemonStorageSystemPtr->unk_08bb = whichBox; - gPokemonStorageSystemPtr->unk_08bc = r4 > 0 ? 0 : 5; - gPokemonStorageSystemPtr->unk_08be = r4; - gPokemonStorageSystemPtr->unk_08c0 = r4 > 0 ? 0x108 : 0x38; - gPokemonStorageSystemPtr->unk_08c2 = r4 > 0 ? 0 : 5; - gPokemonStorageSystemPtr->unk_08c4 = r4; - gPokemonStorageSystemPtr->unk_08c6 = 0; - gPokemonStorageSystemPtr->unk_08c8 = 2; - sub_809900C(whichBox, r4); - sub_809A3D0(whichBox, r4); - sub_809A774(r4); -} - -bool8 sub_8099D34(void) -{ - bool8 retVal = sub_80990AC(); - if (gPokemonStorageSystemPtr->unk_08b8 != 0) - { - gPokemonStorageSystemPtr->unk_08b4 += gPokemonStorageSystemPtr->unk_08b6; - gPokemonStorageSystemPtr->unk_08b4 &= 0x1ff; - if (--gPokemonStorageSystemPtr->unk_08b8 == 0) - { - sub_809A598(); - sub_809A810(); - } - return TRUE; - } - return retVal; -} - -s8 sub_8099D90(u8 boxId) -{ - u8 curBox = get_preferred_box(); - u8 i; - - for (i = 0; curBox != boxId; i++) - { - if (++curBox >= 14) - curBox = 0; - } - return i <= 6 ? 1 : -1; -} - -void sub_8099DCC(u8 wallpaperId) -{ - u8 curBox = get_preferred_box(); - gPokemonStorage.wallpaper[curBox] = wallpaperId; - gPokemonStorageSystemPtr->unk_1032 = 0; -} - -bool8 sub_8099E08(void) -{ - switch (gPokemonStorageSystemPtr->unk_1032) - { - case 0: - BeginNormalPaletteFade(gPokemonStorageSystemPtr->unk_0d08, 1, 0, 0x10, 0xffff); - gPokemonStorageSystemPtr->unk_1032++; - break; - case 1: - if (!UpdatePaletteFade()) - { - u8 curBox = get_preferred_box(); - sub_8099EB0(curBox, 0); - sub_809A654(); - BeginNormalPaletteFade(gPokemonStorageSystemPtr->unk_0d08, 1, 0x10, 0, 0xffff); - gPokemonStorageSystemPtr->unk_1032++; - } - break; - case 2: - if (!UpdatePaletteFade()) - gPokemonStorageSystemPtr->unk_1032++; - break; - case 3: - return FALSE; - } - return TRUE; -} - const u16 gWallpaperPalettes_Forest[] = INCBIN_U16("graphics/pokemon_storage/box_bg1.gbapal"); const u16 gWallpaperPalettes_Forest_2[] = INCBIN_U16("graphics/pokemon_storage/forest_frame.gbapal"); const u16 gWallpaperPalettes_Forest_2_3[] = INCBIN_U16("graphics/pokemon_storage/forest_bg.gbapal"); @@ -314,6 +217,171 @@ const struct WallpaperTable gWallpaperTable[] = { {gWallpaperTiles_Plain, 0xFC, gWallpaperTilemap_Plain, gWallpaperPalettes_Plain} // Plain }; +const u16 PCPal_Arrow[] = INCBIN_U16("graphics/pokemon_storage/arrow.gbapal"); +const u8 PCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp"); + +const struct SpriteSheet gUnknown_083BB288 = {PCGfx_Arrow, 0x80, 6}; +const struct SpritePalette gUnknown_083BB290 = {PCPal_Arrow, 0xdacf}; + +const struct OamData gOamData_83BB298 = { + .shape = ST_OAM_H_RECTANGLE, + .size = 2, + .priority = 2 +}; + +const union AnimCmd gSpriteAnim_83BB2A0[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83BB2A8[] = { + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83BB2B0[] = { + gSpriteAnim_83BB2A0, + gSpriteAnim_83BB2A8 +}; + +const struct SpriteTemplate gSpriteTemplate_83BB2B8 = { + 3, + 0xdac8, + &gOamData_83BB298, + gSpriteAnimTable_83BB2B0, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +const struct OamData gOamData_83BB2D0 = { + .shape = ST_OAM_V_RECTANGLE, + .priority = 2 +}; + +const union AnimCmd gSpriteAnim_83BB2D8[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83BB2E0[] = { + ANIMCMD_FRAME(2, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83BB2E8[] = { + gSpriteAnim_83BB2D8, + gSpriteAnim_83BB2E0 +}; + +const struct SpriteTemplate gSpriteTemplate_83BB2F0 = { + 6, + 0xdacf, + &gOamData_83BB2D0, + gSpriteAnimTable_83BB2E8, + NULL, + gDummySpriteAffineAnimTable, + sub_809A8C8 +}; + +// .text + +void sub_8099BF8(u8 boxId) +{ + gPokemonStorageSystemPtr->unk_08ba = FALSE; + gPokemonStorageSystemPtr->unk_08b4 = 0; + DmaFill32(3, 0, BG_SCREEN_ADDR(26), 0x1000); + sub_8099EB0(boxId, 0); + sub_809A23C(boxId); + sub_809A6DC(); + SpawnBoxIconSprites(boxId); + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_TXT512x256; +} + +void sub_8099C70(u8 whichBox) +{ + s8 r4 = sub_8099D90(whichBox); + sub_8099EB0(whichBox, r4); + gPokemonStorageSystemPtr->unk_08b6 = r4 * 6; + gPokemonStorageSystemPtr->unk_08b8 = 0x20; + gPokemonStorageSystemPtr->unk_08bb = whichBox; + gPokemonStorageSystemPtr->unk_08bc = r4 > 0 ? 0 : 5; + gPokemonStorageSystemPtr->unk_08be = r4; + gPokemonStorageSystemPtr->unk_08c0 = r4 > 0 ? 0x108 : 0x38; + gPokemonStorageSystemPtr->unk_08c2 = r4 > 0 ? 0 : 5; + gPokemonStorageSystemPtr->unk_08c4 = r4; + gPokemonStorageSystemPtr->unk_08c6 = 0; + gPokemonStorageSystemPtr->unk_08c8 = 2; + sub_809900C(whichBox, r4); + sub_809A3D0(whichBox, r4); + sub_809A774(r4); +} + +bool8 sub_8099D34(void) +{ + bool8 retVal = sub_80990AC(); + if (gPokemonStorageSystemPtr->unk_08b8 != 0) + { + gPokemonStorageSystemPtr->unk_08b4 += gPokemonStorageSystemPtr->unk_08b6; + gPokemonStorageSystemPtr->unk_08b4 &= 0x1ff; + if (--gPokemonStorageSystemPtr->unk_08b8 == 0) + { + sub_809A598(); + sub_809A810(); + } + return TRUE; + } + return retVal; +} + +s8 sub_8099D90(u8 boxId) +{ + u8 curBox = get_preferred_box(); + u8 i; + + for (i = 0; curBox != boxId; i++) + { + if (++curBox >= 14) + curBox = 0; + } + return i <= 6 ? 1 : -1; +} + +void sub_8099DCC(u8 wallpaperId) +{ + u8 curBox = get_preferred_box(); + gPokemonStorage.wallpaper[curBox] = wallpaperId; + gPokemonStorageSystemPtr->unk_1032 = 0; +} + +bool8 sub_8099E08(void) +{ + switch (gPokemonStorageSystemPtr->unk_1032) + { + case 0: + BeginNormalPaletteFade(gPokemonStorageSystemPtr->unk_0d08, 1, 0, 0x10, 0xffff); + gPokemonStorageSystemPtr->unk_1032++; + break; + case 1: + if (!UpdatePaletteFade()) + { + u8 curBox = get_preferred_box(); + sub_8099EB0(curBox, 0); + sub_809A654(); + BeginNormalPaletteFade(gPokemonStorageSystemPtr->unk_0d08, 1, 0x10, 0, 0xffff); + gPokemonStorageSystemPtr->unk_1032++; + } + break; + case 2: + if (!UpdatePaletteFade()) + gPokemonStorageSystemPtr->unk_1032++; + break; + case 3: + return FALSE; + } + return TRUE; +} + void sub_8099EB0(u8 boxId, s8 a1) { const struct WallpaperTable *wallpaperTable; @@ -855,43 +923,6 @@ void sub_809A3D0(u8 boxId, s8 a1) } } -const u16 PCPal_Arrow[] = INCBIN_U16("graphics/pokemon_storage/arrow.gbapal"); -const u8 PCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp"); - -const struct SpriteSheet gUnknown_083BB288 = {PCGfx_Arrow, 0x80, 6}; -const struct SpritePalette gUnknown_083BB290 = {PCPal_Arrow, 0xdacf}; - -const struct OamData gOamData_83BB298 = { - .shape = ST_OAM_H_RECTANGLE, - .size = 2, - .priority = 2 -}; - -const union AnimCmd gSpriteAnim_83BB2A0[] = { - ANIMCMD_FRAME(0, 5), - ANIMCMD_END -}; - -const union AnimCmd gSpriteAnim_83BB2A8[] = { - ANIMCMD_FRAME(8, 5), - ANIMCMD_END -}; - -const union AnimCmd *const gSpriteAnimTable_83BB2B0[] = { - gSpriteAnim_83BB2A0, - gSpriteAnim_83BB2A8 -}; - -const struct SpriteTemplate gSpriteTemplate_83BB2B8 = { - 3, - 0xdac8, - &gOamData_83BB298, - gSpriteAnimTable_83BB2B0, - NULL, - gDummySpriteAffineAnimTable, - SpriteCallbackDummy -}; - void sub_809A598(void) { if (gPokemonStorageSystemPtr->unk_0cca == 0) @@ -937,3 +968,86 @@ s16 sub_809A6D0(u8 width) { return 0xb0 - width / 2; } + +void sub_809A6DC(void) +{ + u16 i; + + LoadSpriteSheet(&gUnknown_083BB288); + LoadSpritePalette(&gUnknown_083BB290); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gSpriteTemplate_83BB2F0, 0x5c + i * 0x88, 0x1c, 21); + if (spriteId != MAX_SPRITES) + { + struct Sprite *sprite = gSprites + spriteId; + StartSpriteAnim(sprite, i); + sprite->data[3] = (i == 0) ? -1 : 1; + gPokemonStorageSystemPtr->unk_0d00[i] = sprite; + } + } + if (sub_809BF2C()) + sub_809A860(TRUE); +} + +void sub_809A774(s8 a0) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + gPokemonStorageSystemPtr->unk_0d00[i]->pos2.x = 0; + gPokemonStorageSystemPtr->unk_0d00[i]->data[0] = 2; + } + if (a0 < 0) + { + gPokemonStorageSystemPtr->unk_0d00[0]->data[1] = 29; + gPokemonStorageSystemPtr->unk_0d00[1]->data[1] = 5; + gPokemonStorageSystemPtr->unk_0d00[0]->data[2] = 0x48; + gPokemonStorageSystemPtr->unk_0d00[1]->data[2] = 0x48; + } + else + { + gPokemonStorageSystemPtr->unk_0d00[0]->data[1] = 5; + gPokemonStorageSystemPtr->unk_0d00[1]->data[1] = 29; + gPokemonStorageSystemPtr->unk_0d00[0]->data[2] = 0xF8; + gPokemonStorageSystemPtr->unk_0d00[1]->data[2] = 0xF8; + } + gPokemonStorageSystemPtr->unk_0d00[0]->data[7] = 0; + gPokemonStorageSystemPtr->unk_0d00[1]->data[7] = 1; +} + +void sub_809A810(void) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + gPokemonStorageSystemPtr->unk_0d00[i]->pos1.x = 0x88 * i + 0x5c; + gPokemonStorageSystemPtr->unk_0d00[i]->pos2.x = 0; + gPokemonStorageSystemPtr->unk_0d00[i]->invisible = FALSE; + } + sub_809A860(TRUE); +} + +void sub_809A860(bool8 a0) +{ + u16 i; + if (a0) + { + for (i = 0; i < 2; i++) + { + gPokemonStorageSystemPtr->unk_0d00[i]->data[0] = 1; + gPokemonStorageSystemPtr->unk_0d00[i]->data[1] = 0; + gPokemonStorageSystemPtr->unk_0d00[i]->data[2] = 0; + gPokemonStorageSystemPtr->unk_0d00[i]->data[4] = 0; + } + } + else + { + for (i = 0; i < 2; i++) + { + gPokemonStorageSystemPtr->unk_0d00[i]->data[0] = 0; + } + } +} -- cgit v1.2.3 From d8091a8fadb1089cbc090772bbb2fbcbab633357 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 14 Jan 2018 21:01:43 -0500 Subject: through sub_809AA98 --- src/pokemon/pokemon_storage_system_4.c | 94 +++++++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index b40cc916c..63d94b5a1 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -8,6 +8,13 @@ // Static type declarations +struct WallpaperTable { + const u8 *tiles; + u32 size; + const u8 *tileMap; + const u16 *palettes; +}; + // Static RAM declarations EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; @@ -19,13 +26,6 @@ EWRAM_DATA u8 gUnknown_020384E8 = 0; EWRAM_DATA u8 gUnknown_020384E9 = 0; EWRAM_DATA u16 gUnknown_020384EA = 0; -struct WallpaperTable { - const u8 *tiles; - u32 size; - const u8 *tileMap; - const u16 *palettes; -}; - // Static ROM declarations void sub_809900C(u8 boxId, s8 a1); @@ -45,6 +45,9 @@ void sub_809A774(s8 a0); void sub_809A810(void); void sub_809A8C8(struct Sprite *sprite); bool8 sub_809BF2C(void); +void sub_809BF74(void); +void sub_809C028(void); +void sub_809CC04(void); // .rodata @@ -1051,3 +1054,80 @@ void sub_809A860(bool8 a0) } } } + +void sub_809A8C8(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->pos2.x = 0; + break; + case 1: + if (++sprite->data[1] > 3) + { + sprite->data[1] = 0; + sprite->pos2.x += sprite->data[3]; + if (++sprite->data[2] > 5) + { + sprite->data[2] = 0; + sprite->pos2.x = 0; + } + } + break; + case 2: + sprite->data[0] = 3; + break; + case 3: + sprite->pos1.x -= gPokemonStorageSystemPtr->unk_08b6; + if (sprite->pos1.x < 0x49 || sprite->pos1.x > 0xf7) + sprite->invisible = TRUE; + if (--sprite->data[1] == 0) + { + sprite->pos1.x = sprite->data[2]; + sprite->invisible = FALSE; + sprite->data[0] = 4; + } + break; + case 4: + sprite->pos1.x -= gPokemonStorageSystemPtr->unk_08b6; + break; + } +} + +struct Sprite *sub_809A9A0(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) +{ + u8 spriteId = CreateSprite(&gSpriteTemplate_83BB2F0, x, y, subpriority); + if (spriteId == MAX_SPRITES) + return NULL; + animId %= 2; + StartSpriteAnim(gSprites + spriteId, animId); + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].callback = SpriteCallbackDummy; + return gSprites + spriteId; +} + +void sub_809AA24(void) +{ + if (gPokemonStorageSystemPtr->unk_0005 != 1) + gUnknown_020384E4 = 0; + else + gUnknown_020384E4 = 1; + gUnknown_020384E5 = 0; + gUnknown_020384E6 = 0; + gUnknown_020384E7 = 0; + gUnknown_020384E8 = 0; + gUnknown_020384E9 = 0; + sub_809B0D4(); + sub_809CC04(); + gPokemonStorageSystemPtr->unk_11e2 = 1; + sub_809BF74(); +} + +void sub_809AA98(void) +{ + sub_809CC04(); + sub_809C028(); + gPokemonStorageSystemPtr->unk_11e2 = 1; + if (gUnknown_020384E6) + sub_8098BF0(); +} -- cgit v1.2.3 From 1288b752480e5d301c9ea9cff6d1efc737d6c5cc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 14 Jan 2018 21:25:25 -0500 Subject: through sub_809AB8C --- src/pokemon/pokemon_storage_system_4.c | 58 ++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 63d94b5a1..6d44b8ae8 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -1,6 +1,7 @@ // Includes #include "global.h" +#include "constants/species.h" #include "palette.h" #include "text.h" #include "menu.h" @@ -18,8 +19,8 @@ struct WallpaperTable { // Static RAM declarations EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; -EWRAM_DATA u8 gUnknown_020384E4 = 0; -EWRAM_DATA u8 gUnknown_020384E5 = 0; +EWRAM_DATA s8 gUnknown_020384E4 = 0; +EWRAM_DATA s8 gUnknown_020384E5 = 0; EWRAM_DATA u8 gUnknown_020384E6 = 0; EWRAM_DATA u8 gUnknown_020384E7 = 0; EWRAM_DATA u8 gUnknown_020384E8 = 0; @@ -1131,3 +1132,56 @@ void sub_809AA98(void) if (gUnknown_020384E6) sub_8098BF0(); } + +void sub_809AACC(u8 a0, u8 a1, u16 *a2, u16 *a3) +{ + switch (a0) + { + case 0: + *a2 = (a1 % 6) * 24 + 100; + *a3 = (a1 / 6) * 24 + 32; + break; + case 1: + if (a1 == 0) + { + *a2 = 0x68; + *a3 = 0x34; + } + else if (a1 == 6) + { + *a2 = 0x98; + *a3 = 0x84; + } + else + { + *a2 = 0x98; + *a3 = (a1 - 1) * 24 + 4; + } + break; + case 2: + *a2 = 0xa2; + *a3 = 0x0c; + break; + case 3: + *a3 = gUnknown_020384E6 ? 8 : 14; + *a2 = a1 * 0x58 + 0x78; + break; + case 4: + *a2 = 0xa0; + *a3 = 0x60; + break; + } +} + +u16 sub_809AB8C(void) +{ + switch (gUnknown_020384E4) + { + case 1: + return GetMonData(gPlayerParty + gUnknown_020384E5, MON_DATA_SPECIES); + case 0: + return GetBoxMonData(gPokemonStorage.boxes[get_preferred_box()] + gUnknown_020384E5, MON_DATA_SPECIES); + default: + return SPECIES_NONE; + } +} -- cgit v1.2.3 From 68528382d5d8a17c5d6d65f1566a9ba7c807e14a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 15:10:56 -0500 Subject: through sub_809AF18 --- src/pokemon/pokemon_storage_system_4.c | 121 +++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 6d44b8ae8..06c2eeff5 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -44,6 +44,7 @@ s16 sub_809A6D0(u8 width); void sub_809A6DC(void); void sub_809A774(s8 a0); void sub_809A810(void); +void sub_809AFB8(void); void sub_809A8C8(struct Sprite *sprite); bool8 sub_809BF2C(void); void sub_809BF74(void); @@ -1185,3 +1186,123 @@ u16 sub_809AB8C(void) return SPECIES_NONE; } } + +bool8 sub_809AC00(void) +{ + s16 tmp; + if (gPokemonStorageSystemPtr->unk_11dc == 0) + return FALSE; + if (--gPokemonStorageSystemPtr->unk_11dc) + { + gPokemonStorageSystemPtr->unk_11c8 += gPokemonStorageSystemPtr->unk_11d0; + gPokemonStorageSystemPtr->unk_11cc += gPokemonStorageSystemPtr->unk_11d4; + gPokemonStorageSystemPtr->unk_11c0->pos1.x = gPokemonStorageSystemPtr->unk_11c8 >> 8; + gPokemonStorageSystemPtr->unk_11c0->pos1.y = gPokemonStorageSystemPtr->unk_11cc >> 8; + if (gPokemonStorageSystemPtr->unk_11c0->pos1.x > 0x100) + { + tmp = gPokemonStorageSystemPtr->unk_11c0->pos1.x - 0x100; + gPokemonStorageSystemPtr->unk_11c0->pos1.x = tmp + 0x40; + } + if (gPokemonStorageSystemPtr->unk_11c0->pos1.x < 0x40) + { + tmp = 0x40 - gPokemonStorageSystemPtr->unk_11c0->pos1.x; + gPokemonStorageSystemPtr->unk_11c0->pos1.x = 0x100 - tmp; + } + if (gPokemonStorageSystemPtr->unk_11c0->pos1.y > 0xb0) + { + tmp = gPokemonStorageSystemPtr->unk_11c0->pos1.y - 0xb0; + gPokemonStorageSystemPtr->unk_11c0->pos1.y = tmp - 0x10; + } + if (gPokemonStorageSystemPtr->unk_11c0->pos1.y < -0x10) + { + tmp = -0x10 - gPokemonStorageSystemPtr->unk_11c0->pos1.y; + gPokemonStorageSystemPtr->unk_11c0->pos1.y = 0xb0 - tmp; + } + if (gPokemonStorageSystemPtr->unk_11e3 && --gPokemonStorageSystemPtr->unk_11e3 == 0) + gPokemonStorageSystemPtr->unk_11c0->vFlip = gPokemonStorageSystemPtr->unk_11c0->vFlip ? FALSE : TRUE; + } + else + { + gPokemonStorageSystemPtr->unk_11c0->pos1.x = gPokemonStorageSystemPtr->unk_11d8; + gPokemonStorageSystemPtr->unk_11c0->pos1.y = gPokemonStorageSystemPtr->unk_11da; + sub_809AFB8(); + } + return TRUE; +} + +void sub_809AD3C(u8 a0, u8 a1) +{ + u16 x; + u16 y; + + sub_809AACC(a0, a1, &x, &y); + gPokemonStorageSystemPtr->unk_11e0 = a0; + gPokemonStorageSystemPtr->unk_11e1 = a1; + gPokemonStorageSystemPtr->unk_11d8 = x; + gPokemonStorageSystemPtr->unk_11da = y; +} + +void sub_809AD94(void) +{ + int r7; + int r0; + + if (gPokemonStorageSystemPtr->unk_11de || gPokemonStorageSystemPtr->unk_11df) + gPokemonStorageSystemPtr->unk_11dc = 12; + else + gPokemonStorageSystemPtr->unk_11dc = 6; + if (gPokemonStorageSystemPtr->unk_11e3) + gPokemonStorageSystemPtr->unk_11e3 = gPokemonStorageSystemPtr->unk_11dc >> 1; + switch (gPokemonStorageSystemPtr->unk_11de) + { + default: + r7 = gPokemonStorageSystemPtr->unk_11da - gPokemonStorageSystemPtr->unk_11c0->pos1.y; + break; + case -1: + r7 = gPokemonStorageSystemPtr->unk_11da - 0xc0 - gPokemonStorageSystemPtr->unk_11c0->pos1.y; + break; + case 1: + r7 = gPokemonStorageSystemPtr->unk_11da + 0xc0 - gPokemonStorageSystemPtr->unk_11c0->pos1.y; + break; + } + switch (gPokemonStorageSystemPtr->unk_11df) + { + default: + r0 = gPokemonStorageSystemPtr->unk_11d8 - gPokemonStorageSystemPtr->unk_11c0->pos1.x; + break; + case -1: + r0 = gPokemonStorageSystemPtr->unk_11d8 - 0xc0 - gPokemonStorageSystemPtr->unk_11c0->pos1.x; + break; + case 1: + r0 = gPokemonStorageSystemPtr->unk_11d8 + 0xc0 - gPokemonStorageSystemPtr->unk_11c0->pos1.x; + break; + } + r7 <<= 8; + r0 <<= 8; + gPokemonStorageSystemPtr->unk_11d0 = r0 / gPokemonStorageSystemPtr->unk_11dc; + gPokemonStorageSystemPtr->unk_11d4 = r7 / gPokemonStorageSystemPtr->unk_11dc; + gPokemonStorageSystemPtr->unk_11c8 = gPokemonStorageSystemPtr->unk_11c0->pos1.x << 8; + gPokemonStorageSystemPtr->unk_11cc = gPokemonStorageSystemPtr->unk_11c0->pos1.y << 8; +} + +void sub_809AF18(u8 a0, u8 a1) +{ + sub_809AD3C(a0, a1); + sub_809AD94(); + if (gUnknown_020384E6 == 0) + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 1); + if (a0 == 1 && gUnknown_020384E4 != 1) + { + gPokemonStorageSystemPtr->unk_11e2 = a0; + gPokemonStorageSystemPtr->unk_11c4->invisible = TRUE; + } + switch (a0) + { + case 0: + break; + case 1 ... 3: + gPokemonStorageSystemPtr->unk_11c4->invisible = TRUE; + gPokemonStorageSystemPtr->unk_11c4->oam.priority = 1; + break; + } +} -- cgit v1.2.3 From 650f85e7db8ea123256d661a7db59c9325115130 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 15:46:17 -0500 Subject: through sub_809B130 --- src/pokemon/pokemon_storage_system_4.c | 85 +++++++++++++++++++++++++++++++++- src/pokemon/pokemon_storage_system_6.c | 14 ------ 2 files changed, 84 insertions(+), 15 deletions(-) delete mode 100644 src/pokemon/pokemon_storage_system_6.c (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 06c2eeff5..2f2091259 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -25,7 +25,7 @@ EWRAM_DATA u8 gUnknown_020384E6 = 0; EWRAM_DATA u8 gUnknown_020384E7 = 0; EWRAM_DATA u8 gUnknown_020384E8 = 0; EWRAM_DATA u8 gUnknown_020384E9 = 0; -EWRAM_DATA u16 gUnknown_020384EA = 0; +EWRAM_DATA u8 gUnknown_020384EA = 0; // Static ROM declarations @@ -46,6 +46,9 @@ void sub_809A774(s8 a0); void sub_809A810(void); void sub_809AFB8(void); void sub_809A8C8(struct Sprite *sprite); +bool8 sub_809B150(void); +bool8 sub_809B1D8(void); +bool8 sub_809B24C(void); bool8 sub_809BF2C(void); void sub_809BF74(void); void sub_809C028(void); @@ -289,6 +292,16 @@ const struct SpriteTemplate gSpriteTemplate_83BB2F0 = { sub_809A8C8 }; +const u16 HandCursorPalette[] = INCBIN_U16("graphics/pokemon_storage/hand_cursor_pal.bin"); +const u16 HandCursorAltPalette[] = INCBIN_U16("graphics/pokemon_storage/hand_cursor_alt_pal.bin"); +const u8 HandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor.4bpp"); +const u8 HandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp"); + +bool8 (*const gUnknown_083BBBC8[])(void) = { + sub_809B150, + sub_809B1D8, + sub_809B24C +}; // .text void sub_8099BF8(u8 boxId) @@ -1306,3 +1319,73 @@ void sub_809AF18(u8 a0, u8 a1) break; } } + +void sub_809AFB8(void) +{ + gUnknown_020384E4 = gPokemonStorageSystemPtr->unk_11e0; + gUnknown_020384E5 = gPokemonStorageSystemPtr->unk_11e1; + if (gUnknown_020384E6 == 0) + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 0); + sub_809BF74(); + switch (gUnknown_020384E4) + { + case 2: + sub_809A860(TRUE); + break; + case 1: + gPokemonStorageSystemPtr->unk_11c4->subpriority = 12; + break; + case 0: + gPokemonStorageSystemPtr->unk_11c4->oam.priority = 2; + gPokemonStorageSystemPtr->unk_11c4->subpriority = 20; + gPokemonStorageSystemPtr->unk_11c4->invisible = FALSE; + break; + } +} + +void sub_809B068(void) +{ + u8 partyCount; + if (gUnknown_020384E6 == 0) + partyCount = 0; + else + { + partyCount = CalculatePlayerPartyCount(); + if (partyCount > PARTY_SIZE - 1) + partyCount = PARTY_SIZE - 1; + } + if (gPokemonStorageSystemPtr->unk_11c0->vFlip) + gPokemonStorageSystemPtr->unk_11e3 = 1; + sub_809AF18(1, partyCount); +} + +void sub_809B0C0(u8 a0) +{ + sub_809AF18(0, a0); +} + +void sub_809B0D4(void) +{ + gUnknown_020384EA = 0; +} + +void sub_809B0E0(void) +{ + gUnknown_020384EA = gUnknown_020384E5; +} + +u8 sub_809B0F4(void) +{ + return gUnknown_020384EA; +} + +void sub_809B100(u8 a0) +{ + gPokemonStorageSystemPtr->unk_12a4 = gUnknown_083BBBC8[a0]; + gPokemonStorageSystemPtr->unk_12a8 = 0; +} + +bool8 sub_809B130(void) +{ + return gPokemonStorageSystemPtr->unk_12a4(); +} diff --git a/src/pokemon/pokemon_storage_system_6.c b/src/pokemon/pokemon_storage_system_6.c deleted file mode 100644 index a781c1ed2..000000000 --- a/src/pokemon/pokemon_storage_system_6.c +++ /dev/null @@ -1,14 +0,0 @@ - -// Includes -#include "global.h" -#include "pokemon_storage_system.h" - -// Static type declarations - -// Static RAM declarations - -// Static ROM declarations - -// .rodata - -// .text -- cgit v1.2.3 From 66fe535e7f5f0466c15f5f82dd1c2823fc6110cf Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 16:16:25 -0500 Subject: through sub_809B24C --- src/pokemon/pokemon_storage_system_4.c | 92 ++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 2f2091259..9e4865910 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -49,6 +49,11 @@ void sub_809A8C8(struct Sprite *sprite); bool8 sub_809B150(void); bool8 sub_809B1D8(void); bool8 sub_809B24C(void); +bool8 sub_809B324(void); +bool8 sub_809B358(void); +void sub_809B384(void); +void sub_809B3E0(void); +void diegohint1(u8 a0, u8 a1); bool8 sub_809BF2C(void); void sub_809BF74(void); void sub_809C028(void); @@ -1389,3 +1394,90 @@ bool8 sub_809B130(void) { return gPokemonStorageSystemPtr->unk_12a4(); } + +bool8 sub_809B150(void) +{ + switch (gPokemonStorageSystemPtr->unk_12a8) + { + case 0: + if (gUnknown_020384E6) + return FALSE; + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 2); + gPokemonStorageSystemPtr->unk_12a8++; + break; + case 1: + if (!sub_809B324()) + { + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 3); + sub_809B384(); + gPokemonStorageSystemPtr->unk_12a8++; + } + break; + case 2: + if (!sub_809B358()) + gPokemonStorageSystemPtr->unk_12a8++; + break; + case 3: + return FALSE; + } + return TRUE; +} + +bool8 sub_809B1D8(void) +{ + switch (gPokemonStorageSystemPtr->unk_12a8) + { + case 0: + if (!sub_809B324()) + { + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 2); + sub_809B3E0(); + gPokemonStorageSystemPtr->unk_12a8++; + } + break; + case 1: + if (!sub_809B358()) + { + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 0); + gPokemonStorageSystemPtr->unk_12a8++; + } + break; + case 2: + return FALSE; + } + return TRUE; +} + +bool8 sub_809B24C(void) +{ + switch (gPokemonStorageSystemPtr->unk_12a8) + { + case 0: + switch (gUnknown_020384E4) + { + case 1: + gPokemonStorageSystemPtr->unk_12a9 = 14; + break; + case 0: + gPokemonStorageSystemPtr->unk_12a9 = get_preferred_box(); + break; + default: + return FALSE; + } + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 2); + sub_80996B0(gPokemonStorageSystemPtr->unk_12a9, gUnknown_020384E5); + gPokemonStorageSystemPtr->unk_12a8++; + break; + case 1: + if (!sub_809971C()) + { + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 3); + diegohint1(gPokemonStorageSystemPtr->unk_12a9, gUnknown_020384E5); + gPokemonStorageSystemPtr->unk_12a8++; + } + break; + case 2: + return FALSE; + } + return TRUE; +} -- cgit v1.2.3 From e3238abc63ac7e939ccdc58e555a9dcdc66f3525 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 16:54:02 -0500 Subject: through sub_809B44C --- src/pokemon/pokemon_storage_system_4.c | 86 ++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 9e4865910..1127927bf 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -53,6 +53,9 @@ bool8 sub_809B324(void); bool8 sub_809B358(void); void sub_809B384(void); void sub_809B3E0(void); +void sub_809B44C(u8 a0, u8 a1); +void diegohint2(u8 a0, u8 a1); +void sub_809B548(u8 a0, u8 a1); void diegohint1(u8 a0, u8 a1); bool8 sub_809BF2C(void); void sub_809BF74(void); @@ -1481,3 +1484,86 @@ bool8 sub_809B24C(void) } return TRUE; } + +bool8 sub_809B324(void) +{ + switch (gPokemonStorageSystemPtr->unk_11c0->pos2.y) + { + default: + gPokemonStorageSystemPtr->unk_11c0->pos2.y++; + break; + case 0: + gPokemonStorageSystemPtr->unk_11c0->pos2.y++; + break; + case 8: + return FALSE; + } + return TRUE; +} + +bool8 sub_809B358(void) +{ + switch (gPokemonStorageSystemPtr->unk_11c0->pos2.y) + { + case 0: + return FALSE; + default: + gPokemonStorageSystemPtr->unk_11c0->pos2.y--; + break; + } + return TRUE; +} + +void sub_809B384(void) +{ + switch (gUnknown_020384E4) + { + case 1: + sub_809B44C(14, gUnknown_020384E5); + sub_8099584(0, gUnknown_020384E5); + break; + case 0: + sub_809B44C(get_preferred_box(), gUnknown_020384E5); + sub_8099584(1, gUnknown_020384E5); + break; + default: + return; + } + gUnknown_020384E6 = 1; +} + +void sub_809B3E0(void) +{ + u8 boxId; + switch (gUnknown_020384E4) + { + case 1: + diegohint2(14, gUnknown_020384E5); + sub_809960C(14, gUnknown_020384E5); + break; + case 0: + boxId = get_preferred_box(); + diegohint2(boxId, gUnknown_020384E5); + sub_809960C(boxId, gUnknown_020384E5); + break; + default: + return; + } + gUnknown_020384E6 = 0; +} + +void sub_809B440(void) +{ + sub_809BF74(); +} + +void sub_809B44C(u8 a0, u8 a1) +{ + if (a0 == 14) + gPokemonStorageSystemPtr->unk_25b4 = gPlayerParty[gUnknown_020384E5]; + else + sub_803B4B4(gPokemonStorage.boxes[a0], &gPokemonStorageSystemPtr->unk_25b4); + sub_809B548(a0, a1); + gUnknown_020384E7 = a0; + gUnknown_020384E8 = a1; +} -- cgit v1.2.3 From 08a108f432325d6501f3c6473a6d43265af0d5b7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 17:14:39 -0500 Subject: through diegohint1 --- src/field/daycare.c | 2 +- src/pokemon/pokemon_1.c | 2 +- src/pokemon/pokemon_storage_system_4.c | 37 +++++++++++++++++++++++++++++++++- src/pokemon/pokemon_summary_screen.c | 2 +- 4 files changed, 39 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/field/daycare.c b/src/field/daycare.c index 36dd7ec03..2f0c7281e 100644 --- a/src/field/daycare.c +++ b/src/field/daycare.c @@ -205,7 +205,7 @@ static u16 TakeSelectedPokemonFromDaycare(struct DayCare * daycare, u8 slot) GetBoxMonNick(&daycare->mons[slot], gStringVar1); species = GetBoxMonData(&daycare->mons[slot], MON_DATA_SPECIES); - sub_803B4B4(&daycare->mons[slot], &pokemon); + ExpandBoxMon(&daycare->mons[slot], &pokemon); if (GetMonData(&pokemon, MON_DATA_LEVEL) != MAX_LEVEL) { diff --git a/src/pokemon/pokemon_1.c b/src/pokemon/pokemon_1.c index 0242e7444..06a088046 100644 --- a/src/pokemon/pokemon_1.c +++ b/src/pokemon/pokemon_1.c @@ -524,7 +524,7 @@ void CalculateMonStats(struct Pokemon *mon) SetMonData(mon, MON_DATA_HP, ¤tHP); } -void sub_803B4B4(const struct BoxPokemon *src, struct Pokemon *dest) +void ExpandBoxMon(const struct BoxPokemon *src, struct Pokemon *dest) { u32 value = 0; dest->box = *src; diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 1127927bf..73d71fa0e 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -60,6 +60,7 @@ void diegohint1(u8 a0, u8 a1); bool8 sub_809BF2C(void); void sub_809BF74(void); void sub_809C028(void); +void sub_809C04C(struct Pokemon *pokemon, u8 a1); void sub_809CC04(void); // .rodata @@ -1562,8 +1563,42 @@ void sub_809B44C(u8 a0, u8 a1) if (a0 == 14) gPokemonStorageSystemPtr->unk_25b4 = gPlayerParty[gUnknown_020384E5]; else - sub_803B4B4(gPokemonStorage.boxes[a0], &gPokemonStorageSystemPtr->unk_25b4); + ExpandBoxMon(gPokemonStorage.boxes[a0] + a1, &gPokemonStorageSystemPtr->unk_25b4); sub_809B548(a0, a1); gUnknown_020384E7 = a0; gUnknown_020384E8 = a1; } + +void diegohint2(u8 a0, u8 a1) +{ + if (a0 == 14) + { + gPlayerParty[a1] = gPokemonStorageSystemPtr->unk_25b4; + } + else + { + BoxMonRestorePP(&gPokemonStorageSystemPtr->unk_25b4.box); + gPokemonStorage.boxes[a0][a1] = gPokemonStorageSystemPtr->unk_25b4.box; + } +} + +void sub_809B548(u8 a0, u8 a1) +{ + if (a0 == 14) + ZeroMonData(gPlayerParty + a1); + else + ZeroBoxMonData(gPokemonStorage.boxes[a0] + a1); +} + +void diegohint1(u8 a0, u8 a1) +{ + if (a0 == 14) + gPokemonStorageSystemPtr->unk_2618 = gPlayerParty[a1]; + else + ExpandBoxMon(gPokemonStorage.boxes[a0] + a1, &gPokemonStorageSystemPtr->unk_2618); + diegohint2(a0, a1); + gPokemonStorageSystemPtr->unk_25b4 = gPokemonStorageSystemPtr->unk_2618; + sub_809C04C(&gPokemonStorageSystemPtr->unk_25b4, 0); + gUnknown_020384E7 = a0; + gUnknown_020384E8 = a1; +} diff --git a/src/pokemon/pokemon_summary_screen.c b/src/pokemon/pokemon_summary_screen.c index ce83ad070..dce65898c 100644 --- a/src/pokemon/pokemon_summary_screen.c +++ b/src/pokemon/pokemon_summary_screen.c @@ -2253,7 +2253,7 @@ static void sub_809F678(struct Pokemon *mon) else { struct BoxPokemon *mons = pssData.monList.boxMons; - sub_803B4B4(&mons[pssData.monIndex], mon); + ExpandBoxMon(&mons[pssData.monIndex], mon); } } -- cgit v1.2.3 From 7b45766d0765d42d7326a7f6cdb21a54d386117e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 19:32:02 -0500 Subject: through sub_809B7D4 --- src/pokemon/pokemon_2.c | 3 +- src/pokemon/pokemon_storage_system_4.c | 119 +++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_2.c b/src/pokemon/pokemon_2.c index b941ed2ab..7fd1aa7b2 100644 --- a/src/pokemon/pokemon_2.c +++ b/src/pokemon/pokemon_2.c @@ -1,5 +1,6 @@ #include "global.h" #include "constants/hold_effects.h" +#include "constants/moves.h" #include "battle.h" #include "battle_util.h" #include "data2.h" @@ -569,7 +570,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) u16 *moves = (u16 *)data; s32 i = 0; - while (moves[i] != 355) + while (moves[i] != NUM_MOVES) { u16 move = moves[i]; if (substruct1->moves[0] == move diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 73d71fa0e..a0a6fa145 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -1,8 +1,10 @@ // Includes #include "global.h" +#include "constants/moves.h" #include "constants/species.h" #include "palette.h" +#include "string_util.h" #include "text.h" #include "menu.h" #include "pokemon_storage_system.h" @@ -1602,3 +1604,120 @@ void diegohint1(u8 a0, u8 a1) gUnknown_020384E7 = a0; gUnknown_020384E8 = a1; } + +bool8 sub_809B62C(u8 boxId) +{ + s16 monIdx = GetIndexOfFirstEmptySpaceInBoxN(boxId); + if (monIdx == -1) + return FALSE; + if (gUnknown_020384E6) + { + diegohint2(boxId, monIdx); + sub_8099480(); + gUnknown_020384E6 = 0; + } + else + { + sub_809B44C(14, gUnknown_020384E5); + diegohint2(boxId, monIdx); + sub_8099520(gUnknown_020384E5); + } + if (boxId == get_preferred_box()) + sub_8098D20(monIdx); + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 1); + return TRUE; +} + +void sub_809B6BC(void) +{ + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 0); + sub_809BF74(); +} + +void sub_809B6DC(void) +{ + u8 mode; + + if (gUnknown_020384E6) + mode = 2; + else if (gUnknown_020384E4 == 1) + mode = 0; + else + mode = 1; + sub_809981C(mode, gUnknown_020384E5); + StringCopy(gPokemonStorageSystemPtr->unk_26e4, gPokemonStorageSystemPtr->unk_11fa); +} + +bool8 sub_809B734(void) +{ + if (!sub_80998D8()) + { + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 0); + return FALSE; + } + return TRUE; +} + +void sub_809B760(void) +{ + sub_8099920(); + if (gUnknown_020384E6) + gUnknown_020384E6 = 0; + else + { + u8 boxId; + if (gUnknown_020384E4 == 1) + boxId = 14; + else + boxId = get_preferred_box(); + sub_809B548(boxId, gUnknown_020384E5); + } + sub_809BF74(); +} + +void sub_809B7AC(void) +{ + if (gUnknown_020384E6) + StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 3); +} + +void sub_809B7D4(void) +{ + u16 knownMoves; + if (gUnknown_020384E6) + { + gPokemonStorageSystemPtr->unk_2618 = gPokemonStorageSystemPtr->unk_25b4; + gPokemonStorageSystemPtr->unk_2682 = -1; + gPokemonStorageSystemPtr->unk_2683 = -1; + } + else + { + if (gUnknown_020384E4 == 1) + { + gPokemonStorageSystemPtr->unk_2618 = gPlayerParty[gUnknown_020384E5]; + gPokemonStorageSystemPtr->unk_2682 = 14; + } + else + { + ExpandBoxMon(gPokemonStorage.boxes[gPokemonStorage.currentBox] + gUnknown_020384E5, &gPokemonStorageSystemPtr->unk_2618); + gPokemonStorageSystemPtr->unk_2682 = gPokemonStorage.currentBox; + } + gPokemonStorageSystemPtr->unk_2683 = gUnknown_020384E5; + } + gPokemonStorageSystemPtr->unk_267e = 0; + gPokemonStorageSystemPtr->unk_267f = 0; + gPokemonStorageSystemPtr->unk_2686[0] = MOVE_SURF; + gPokemonStorageSystemPtr->unk_2686[1] = MOVE_DIVE; + gPokemonStorageSystemPtr->unk_2686[2] = NUM_MOVES; + knownMoves = GetMonData(&gPokemonStorageSystemPtr->unk_2618, MON_DATA_KNOWN_MOVES, gPokemonStorageSystemPtr->unk_2686); + gPokemonStorageSystemPtr->unk_267e = knownMoves & 1; + gPokemonStorageSystemPtr->unk_267f = (knownMoves >> 1) & 1; + if (gPokemonStorageSystemPtr->unk_267e || gPokemonStorageSystemPtr->unk_267f) + gPokemonStorageSystemPtr->unk_267d = 0; + else + { + gPokemonStorageSystemPtr->unk_267d = 1; + gPokemonStorageSystemPtr->unk_267c = 1; + } + gPokemonStorageSystemPtr->unk_2684 = 0; +} -- cgit v1.2.3 From 7a2eef97c35e4672bd17bfca86a6ea19d22a3eba Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 20:34:56 -0500 Subject: sub_809B960 --- src/pokemon/pokemon_storage_system_4.c | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index a0a6fa145..2469d42b1 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -1721,3 +1721,68 @@ void sub_809B7D4(void) } gPokemonStorageSystemPtr->unk_2684 = 0; } + +s8 sub_809B960(void) +{ + u16 i; + u16 knownMoves; + + if (gPokemonStorageSystemPtr->unk_267d) + return gPokemonStorageSystemPtr->unk_267c; + switch (gPokemonStorageSystemPtr->unk_2684) + { + case 0: + for (i = 0; i < PARTY_SIZE; i++) + { + if (gPokemonStorageSystemPtr->unk_2682 != 14 || gPokemonStorageSystemPtr->unk_2683 != i) + { + knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, gPokemonStorageSystemPtr->unk_2686); + if (knownMoves & 1) + gPokemonStorageSystemPtr->unk_267e = 0; + if (knownMoves & 2) + gPokemonStorageSystemPtr->unk_267f = 0; + } + } + if (gPokemonStorageSystemPtr->unk_267e == 0 && gPokemonStorageSystemPtr->unk_267f == 0) + { + gPokemonStorageSystemPtr->unk_267d = 1; + gPokemonStorageSystemPtr->unk_267c = 1; + } + else + { + gPokemonStorageSystemPtr->unk_2680 = 0; + gPokemonStorageSystemPtr->unk_2681 = 0; + gPokemonStorageSystemPtr->unk_2684++; + } + break; + case 1: + for (i = 0; i < 5; i++) + { + knownMoves = GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_2680] + gPokemonStorageSystemPtr->unk_2681, MON_DATA_KNOWN_MOVES, gPokemonStorageSystemPtr->unk_2686); + if (knownMoves && (gPokemonStorageSystemPtr->unk_2682 != gPokemonStorageSystemPtr->unk_2680 || gPokemonStorageSystemPtr->unk_2683 != gPokemonStorageSystemPtr->unk_2681)) + { + if (knownMoves & 1) + gPokemonStorageSystemPtr->unk_267e = 0; + if (knownMoves & 2) + gPokemonStorageSystemPtr->unk_267f = 0; + } + if (++gPokemonStorageSystemPtr->unk_2681 >= 30) + { + gPokemonStorageSystemPtr->unk_2681 = 0; + if (++gPokemonStorageSystemPtr->unk_2680 >= 14) + { + gPokemonStorageSystemPtr->unk_267d = 1; + gPokemonStorageSystemPtr->unk_267c = 0; + break; + } + } + } + if (gPokemonStorageSystemPtr->unk_267e == 0 && gPokemonStorageSystemPtr->unk_267f == 0) + { + gPokemonStorageSystemPtr->unk_267d = 1; + gPokemonStorageSystemPtr->unk_267c = 1; + } + break; + } + return -1; +} -- cgit v1.2.3 From 102515325993caef0d57082cd7d8db69335b665b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 21:11:01 -0500 Subject: through party_compaction --- src/pokemon/pokemon_storage_system_2.c | 2 +- src/pokemon/pokemon_storage_system_4.c | 75 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index 4657ed158..512bde5db 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -343,7 +343,7 @@ void sub_8096B5C(void) switch (gPokemonStorageSystemPtr->unk_0006) { case 0: - ShowPokemonSummaryScreen(gPokemonStorageSystemPtr->unk_2690, gPokemonStorageSystemPtr->unk_268d, gPokemonStorageSystemPtr->unk_268c, sub_80969A0, gPokemonStorageSystemPtr->unk_268e); + ShowPokemonSummaryScreen(gPokemonStorageSystemPtr->unk_2690.pokemon, gPokemonStorageSystemPtr->unk_268d, gPokemonStorageSystemPtr->unk_268c, sub_80969A0, gPokemonStorageSystemPtr->unk_268e); break; case 1: DoNamingScreen(1, gPokemonStorage.boxNames[gPokemonStorage.currentBox], 0, 0, 0, sub_80969A0); diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 2469d42b1..40de7d634 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -1,12 +1,14 @@ // Includes #include "global.h" +#include "ewram.h" #include "constants/moves.h" #include "constants/species.h" #include "palette.h" #include "string_util.h" #include "text.h" #include "menu.h" +#include "pokemon_summary_screen.h" #include "pokemon_storage_system.h" // Static type declarations @@ -1786,3 +1788,76 @@ s8 sub_809B960(void) } return -1; } + +void sub_809BB90(void) +{ + if (gUnknown_020384E6) + gUnknown_02038480 = gPokemonStorageSystemPtr->unk_25b4; +} + +void sub_809BBC0(void) +{ + if (gUnknown_020384E6) + { + if (gUnknown_020384E7 == 14) + gPokemonStorageSystemPtr->unk_25b4 = gUnknown_02038480; + else + gPokemonStorageSystemPtr->unk_25b4.box = gUnknown_02038480.box; + } +} + +void sub_809BC18(void) +{ + if (gUnknown_020384E6) + { + sub_809BB90(); + gPokemonStorageSystemPtr->unk_2690.pokemon = &gUnknown_02038480; + gPokemonStorageSystemPtr->unk_268d = 0; + gPokemonStorageSystemPtr->unk_268c = 0; + gPokemonStorageSystemPtr->unk_268e = 0; + } + else if (gUnknown_020384E4 == 1) + { + gPokemonStorageSystemPtr->unk_2690.pokemon = gPlayerParty; + gPokemonStorageSystemPtr->unk_268d = gUnknown_020384E5; + gPokemonStorageSystemPtr->unk_268c = StorageSystemGetPartySize() - 1; + gPokemonStorageSystemPtr->unk_268e = 0; + } + else + { + gPokemonStorageSystemPtr->unk_2690.box = gPokemonStorage.boxes[gPokemonStorage.currentBox]; + gPokemonStorageSystemPtr->unk_268d = gUnknown_020384E5; + gPokemonStorageSystemPtr->unk_268c = 30 - 1; + gPokemonStorageSystemPtr->unk_268e = 5; + } +} + +void sub_809BD14(void) +{ + if (gUnknown_020384E6) + sub_809BBC0(); + else + gUnknown_020384E5 = pssData.monIndex; +} + +s16 party_compaction(void) +{ + s16 retVal = -1; + u16 i; + u16 last; + + for (i = 0, last = 0; i < PARTY_SIZE; i++) + { + if ((u16)GetMonData(gPlayerParty + i, MON_DATA_SPECIES) != SPECIES_NONE) + { + if (i != last) + gPlayerParty[last] = gPlayerParty[i]; + last++; + } + else if (retVal == -1) + retVal = i; + } + for (; last < PARTY_SIZE; last++) + ZeroMonData(gPlayerParty + last); + return retVal; +} -- cgit v1.2.3 From 40d8fee1d0badb81120cad7a5aabfd8f5b0031d8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 21:59:56 -0500 Subject: through sub_809BF48 --- src/pokemon/pokemon_storage_system_4.c | 68 +++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 40de7d634..96e237d4f 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -25,7 +25,7 @@ struct WallpaperTable { EWRAM_DATA struct Pokemon gUnknown_02038480 = {}; EWRAM_DATA s8 gUnknown_020384E4 = 0; EWRAM_DATA s8 gUnknown_020384E5 = 0; -EWRAM_DATA u8 gUnknown_020384E6 = 0; +EWRAM_DATA bool8 gUnknown_020384E6 = FALSE; EWRAM_DATA u8 gUnknown_020384E7 = 0; EWRAM_DATA u8 gUnknown_020384E8 = 0; EWRAM_DATA u8 gUnknown_020384E9 = 0; @@ -1141,7 +1141,7 @@ void sub_809AA24(void) else gUnknown_020384E4 = 1; gUnknown_020384E5 = 0; - gUnknown_020384E6 = 0; + gUnknown_020384E6 = FALSE; gUnknown_020384E7 = 0; gUnknown_020384E8 = 0; gUnknown_020384E9 = 0; @@ -1315,7 +1315,7 @@ void sub_809AF18(u8 a0, u8 a1) { sub_809AD3C(a0, a1); sub_809AD94(); - if (gUnknown_020384E6 == 0) + if (!gUnknown_020384E6) StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 1); if (a0 == 1 && gUnknown_020384E4 != 1) { @@ -1337,7 +1337,7 @@ void sub_809AFB8(void) { gUnknown_020384E4 = gPokemonStorageSystemPtr->unk_11e0; gUnknown_020384E5 = gPokemonStorageSystemPtr->unk_11e1; - if (gUnknown_020384E6 == 0) + if (!gUnknown_020384E6) StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 0); sub_809BF74(); switch (gUnknown_020384E4) @@ -1359,7 +1359,7 @@ void sub_809AFB8(void) void sub_809B068(void) { u8 partyCount; - if (gUnknown_020384E6 == 0) + if (!gUnknown_020384E6) partyCount = 0; else { @@ -1534,7 +1534,7 @@ void sub_809B384(void) default: return; } - gUnknown_020384E6 = 1; + gUnknown_020384E6 = TRUE; } void sub_809B3E0(void) @@ -1554,7 +1554,7 @@ void sub_809B3E0(void) default: return; } - gUnknown_020384E6 = 0; + gUnknown_020384E6 = FALSE; } void sub_809B440(void) @@ -1616,7 +1616,7 @@ bool8 sub_809B62C(u8 boxId) { diegohint2(boxId, monIdx); sub_8099480(); - gUnknown_020384E6 = 0; + gUnknown_020384E6 = FALSE; } else { @@ -1664,7 +1664,7 @@ void sub_809B760(void) { sub_8099920(); if (gUnknown_020384E6) - gUnknown_020384E6 = 0; + gUnknown_020384E6 = FALSE; else { u8 boxId; @@ -1861,3 +1861,53 @@ s16 party_compaction(void) ZeroMonData(gPlayerParty + last); return retVal; } + +void sub_809BDD8(u8 markings) +{ + gPokemonStorageSystemPtr->unk_11f7 = markings; + if (gUnknown_020384E6) + SetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_MARKINGS, &markings); + else + { + if (gUnknown_020384E4 == 1) + SetMonData(gPlayerParty + gUnknown_020384E5, MON_DATA_MARKINGS, &markings); + if (gUnknown_020384E4 == 0) + SetBoxMonData(gPokemonStorage.boxes[get_preferred_box()] + gUnknown_020384E5, MON_DATA_MARKINGS, &markings); + } +} + +bool8 sub_809BE80(void) +{ + if (gUnknown_020384E4 == 1 && !gUnknown_020384E6 && CountAlivePartyMonsExceptOne(gUnknown_020384E5) == 0) + return TRUE; + return FALSE; +} + +bool8 sub_809BEBC(void) +{ + if (gUnknown_020384E6) + { + if (gUnknown_020384E4 == 1 && CountAlivePartyMonsExceptOne(gUnknown_020384E5) == 0) + { + if (gPokemonStorageSystemPtr->unk_11f9 || GetMonData(&gPokemonStorageSystemPtr->unk_25b4, MON_DATA_HP) == 0) + return FALSE; + } + return TRUE; + } + return FALSE; +} + +bool8 sub_809BF20(void) +{ + return gUnknown_020384E6; +} + +bool8 sub_809BF2C(void) +{ + return gUnknown_020384E4 == 2 ? TRUE : FALSE; +} + +bool8 sub_809BF48(void) +{ + return (gUnknown_020384E4 == 3 && gUnknown_020384E5 == 1) ? TRUE : FALSE; +} -- cgit v1.2.3 From 470c09225f4c058831c2226195af413204f5f03c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 22:08:46 -0500 Subject: through sub_809C028 --- src/pokemon/pokemon_storage_system_4.c | 37 ++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 96e237d4f..ada4b43bd 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -64,7 +64,7 @@ void diegohint1(u8 a0, u8 a1); bool8 sub_809BF2C(void); void sub_809BF74(void); void sub_809C028(void); -void sub_809C04C(struct Pokemon *pokemon, u8 a1); +void sub_809C04C(struct BoxPokemon *pokemon, u8 a1); void sub_809CC04(void); // .rodata @@ -1602,7 +1602,7 @@ void diegohint1(u8 a0, u8 a1) ExpandBoxMon(gPokemonStorage.boxes[a0] + a1, &gPokemonStorageSystemPtr->unk_2618); diegohint2(a0, a1); gPokemonStorageSystemPtr->unk_25b4 = gPokemonStorageSystemPtr->unk_2618; - sub_809C04C(&gPokemonStorageSystemPtr->unk_25b4, 0); + sub_809C04C(&gPokemonStorageSystemPtr->unk_25b4.box, 0); gUnknown_020384E7 = a0; gUnknown_020384E8 = a1; } @@ -1911,3 +1911,36 @@ bool8 sub_809BF48(void) { return (gUnknown_020384E4 == 3 && gUnknown_020384E5 == 1) ? TRUE : FALSE; } + +void sub_809BF74(void) +{ + gPokemonStorageSystemPtr->unk_11f6 = gUnknown_020384E6 ? 0 : 1; + if (!gUnknown_020384E6) + { + switch (gUnknown_020384E4) + { + case 1: + if (gUnknown_020384E5 < PARTY_SIZE) + { + sub_809C04C(&gPlayerParty[gUnknown_020384E5].box, 0); + break; + } + // fallthrough + case 2: + case 3: + sub_809C04C(NULL, 2); + break; + case 0: + sub_809C04C(gPokemonStorage.boxes[get_preferred_box()] + gUnknown_020384E5, 1); + break; + } + } +} + +void sub_809C028(void) +{ + if (gUnknown_020384E6) + sub_809C04C(&gUnknown_02038480.box, 0); + else + sub_809BF74(); +} -- cgit v1.2.3 From c4bae7a571f5aea6785e108089e904f9dad67701 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 15 Jan 2018 22:45:08 -0500 Subject: sub_809C04C --- src/pokemon/pokemon_storage_system_4.c | 163 ++++++++++++++++++++++++++++++++- 1 file changed, 160 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index ada4b43bd..eb5a6cb0b 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -2,12 +2,14 @@ // Includes #include "global.h" #include "ewram.h" +#include "data2.h" #include "constants/moves.h" #include "constants/species.h" #include "palette.h" #include "string_util.h" #include "text.h" #include "menu.h" +#include "item.h" #include "pokemon_summary_screen.h" #include "pokemon_storage_system.h" @@ -64,7 +66,7 @@ void diegohint1(u8 a0, u8 a1); bool8 sub_809BF2C(void); void sub_809BF74(void); void sub_809C028(void); -void sub_809C04C(struct BoxPokemon *pokemon, u8 a1); +void sub_809C04C(void *pokemon, u8 a1); void sub_809CC04(void); // .rodata @@ -1602,7 +1604,7 @@ void diegohint1(u8 a0, u8 a1) ExpandBoxMon(gPokemonStorage.boxes[a0] + a1, &gPokemonStorageSystemPtr->unk_2618); diegohint2(a0, a1); gPokemonStorageSystemPtr->unk_25b4 = gPokemonStorageSystemPtr->unk_2618; - sub_809C04C(&gPokemonStorageSystemPtr->unk_25b4.box, 0); + sub_809C04C(&gPokemonStorageSystemPtr->unk_25b4, 0); gUnknown_020384E7 = a0; gUnknown_020384E8 = a1; } @@ -1922,7 +1924,7 @@ void sub_809BF74(void) case 1: if (gUnknown_020384E5 < PARTY_SIZE) { - sub_809C04C(&gPlayerParty[gUnknown_020384E5].box, 0); + sub_809C04C(gPlayerParty + gUnknown_020384E5, 0); break; } // fallthrough @@ -1944,3 +1946,158 @@ void sub_809C028(void) else sub_809BF74(); } + +void sub_809C04C(void *pokemon, u8 a1) +{ + u8 *buf; + u16 gender = MON_MALE; + gPokemonStorageSystemPtr->unk_11f2 = 0; + if (a1 == 0) + { + struct Pokemon *pkmn = (struct Pokemon *)pokemon; + gPokemonStorageSystemPtr->unk_11f0 = GetMonData(pokemon, MON_DATA_SPECIES2); + if (gPokemonStorageSystemPtr->unk_11f0 != SPECIES_NONE) + { + gPokemonStorageSystemPtr->unk_11f9 = GetMonData(pkmn, MON_DATA_IS_EGG); + GetMonData(pkmn, MON_DATA_NICKNAME, gPokemonStorageSystemPtr->unk_11fa); + StringGetEnd10(gPokemonStorageSystemPtr->unk_11fa); + gPokemonStorageSystemPtr->unk_11f8 = GetMonData(pkmn, MON_DATA_LEVEL); + gPokemonStorageSystemPtr->unk_11f7 = GetMonData(pkmn, MON_DATA_MARKINGS); + gPokemonStorageSystemPtr->unk_11ec = GetMonData(pkmn, MON_DATA_PERSONALITY); + gPokemonStorageSystemPtr->unk_11e8 = GetMonSpritePal(pkmn); + gender = GetMonGender(pkmn); + gPokemonStorageSystemPtr->unk_11f2 = GetMonData(pkmn, MON_DATA_HELD_ITEM); + } + } + else if (a1 == 1) + { + struct BoxPokemon *boxmon = (struct BoxPokemon *)pokemon; + gPokemonStorageSystemPtr->unk_11f0 = GetBoxMonData(pokemon, MON_DATA_SPECIES2); + if (gPokemonStorageSystemPtr->unk_11f0 != SPECIES_NONE) + { + u32 otId = GetBoxMonData(boxmon, MON_DATA_OT_ID); + gPokemonStorageSystemPtr->unk_11f9 = GetBoxMonData(boxmon, MON_DATA_IS_EGG); + GetBoxMonData(boxmon, MON_DATA_NICKNAME, gPokemonStorageSystemPtr->unk_11fa); + StringGetEnd10(gPokemonStorageSystemPtr->unk_11fa); + gPokemonStorageSystemPtr->unk_11f8 = GetLevelFromBoxMonExp(boxmon); + gPokemonStorageSystemPtr->unk_11f7 = GetBoxMonData(boxmon, MON_DATA_MARKINGS); + gPokemonStorageSystemPtr->unk_11ec = GetBoxMonData(boxmon, MON_DATA_PERSONALITY); + gPokemonStorageSystemPtr->unk_11e8 = GetMonSpritePalFromOtIdPersonality(gPokemonStorageSystemPtr->unk_11f0, otId, gPokemonStorageSystemPtr->unk_11ec); + gender = GetGenderFromSpeciesAndPersonality(gPokemonStorageSystemPtr->unk_11f0, gPokemonStorageSystemPtr->unk_11ec); + gPokemonStorageSystemPtr->unk_11f2 = GetBoxMonData(boxmon, MON_DATA_HELD_ITEM); + } + } + else + { + gPokemonStorageSystemPtr->unk_11f0 = SPECIES_NONE; + } + if (gPokemonStorageSystemPtr->unk_11f0 == SPECIES_NONE) + { + gPokemonStorageSystemPtr->unk_11fa[0] = EOS; + gPokemonStorageSystemPtr->unk_120f[0] = EOS; + gPokemonStorageSystemPtr->unk_1234[0] = EOS; + gPokemonStorageSystemPtr->unk_1259[0] = EOS; + gPokemonStorageSystemPtr->unk_127a[0] = EOS; + } + else if (gPokemonStorageSystemPtr->unk_11f9) + { + buf = gPokemonStorageSystemPtr->unk_120f; + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x04; // COLOR_HIGHLIGHT_SHADOW + buf[2] = 0x0F; // WHITE2 + buf[3] = 0x00; // TRANSPARENT + buf[4] = 0x01; // DARK_GREY + buf = gPokemonStorageSystemPtr->unk_120f + 5; + buf = StringCopy(buf, gPokemonStorageSystemPtr->unk_11fa); + gPokemonStorageSystemPtr->unk_1234[0] = EOS; + gPokemonStorageSystemPtr->unk_1259[0] = EOS; + gPokemonStorageSystemPtr->unk_127a[0] = EOS; + } + else + { + if (gPokemonStorageSystemPtr->unk_11f0 == SPECIES_NIDORAN_M || gPokemonStorageSystemPtr->unk_11f0 == SPECIES_NIDORAN_F) + gender = MON_GENDERLESS; + buf = gPokemonStorageSystemPtr->unk_120f; + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x04; // COLOR_HIGHLIGHT_SHADOW + buf[2] = 0x0F; // WHITE2 + buf[3] = 0x00; // TRANSPARENT + buf[4] = 0x01; // DARK_GREY + buf = gPokemonStorageSystemPtr->unk_120f + 5; + buf = StringCopy(buf, gPokemonStorageSystemPtr->unk_11fa); + buf = gPokemonStorageSystemPtr->unk_1234; + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x04; // COLOR_HIGHLIGHT_SHADOW + buf[2] = 0x0F; // WHITE2 + buf[3] = 0x00; // TRANSPARENT + buf[4] = 0x01; // DARK_GREY + buf[5] = EXT_CTRL_CODE_BEGIN; + buf[6] = 0x13; // CLEAR_TO + buf[7] = 7; + buf[8] = CHAR_SLASH; + buf = gPokemonStorageSystemPtr->unk_1234 + 9; + buf = StringCopy(buf, gSpeciesNames[gPokemonStorageSystemPtr->unk_11f0]); + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x13; // CLEAR_TO + buf[2] = 0x50; + buf[3] = EOS; + buf = gPokemonStorageSystemPtr->unk_1259; + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x04; // COLOR_HIGHLIGHT_SHADOW + buf[2] = 0x0F; // WHITE2 + buf[3] = 0x00; // TRANSPARENT + buf[4] = 0x01; // DARK_GREY + buf[5] = EXT_CTRL_CODE_BEGIN; + buf[6] = 0x13; // CLEAR_TO + buf[7] = 8; + buf = gPokemonStorageSystemPtr->unk_1259 + 8; + buf[0] = 0x34; // LV + buf = gPokemonStorageSystemPtr->unk_1259 + 9; + buf = sub_8072C14(buf, gPokemonStorageSystemPtr->unk_11f8, 0x22, STR_CONV_MODE_RIGHT_ALIGN); + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x11; // CLEAR + buf[2] = 8; + buf += 3; + switch (gender) + { + case MON_MALE: + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x04; // COLOR_HIGHLIGHT_SHADOW + buf[2] = 0x04; // BLUE + buf[3] = 0x00; // TRANSPARENT + buf[4] = 0x05; // YELLOW + buf[5] = CHAR_MALE; + buf += 6; + break; + case MON_FEMALE: + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x04; // COLOR_HIGHLIGHT_SHADOW + buf[2] = 0x06; // CYAN + buf[3] = 0x00; // TRANSPARENT + buf[4] = 0x07; // MAGENTA + buf[5] = CHAR_FEMALE; + buf += 6; + break; + } + buf[0] = EOS; + buf = gPokemonStorageSystemPtr->unk_127a; + if (gPokemonStorageSystemPtr->unk_11f2) + { + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x04; // COLOR_HIGHLIGHT_SHADOW + buf[2] = 0x0F; // WHITE2 + buf[3] = 0x00; // TRANSPARENT + buf[4] = 0x01; // DARK_GREY + buf = gPokemonStorageSystemPtr->unk_127a + 5; + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x06; // size + buf[2] = 0x04; + buf = gPokemonStorageSystemPtr->unk_127a + 8; + buf = StringCopy(buf, ItemId_GetItem(gPokemonStorageSystemPtr->unk_11f2)->name); + buf[0] = EXT_CTRL_CODE_BEGIN; + buf[1] = 0x07; // UNKNOWN_7; + buf += 2; + } + buf[0] = EOS; + } +} -- cgit v1.2.3 From 5ffd006acfe8ad12e88fa53a93a55b6f59e77779 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 21 Jan 2018 19:33:08 -0500 Subject: nonmatching sub_809C464 --- src/pokemon/pokemon_storage_system_4.c | 378 +++++++++++++++++++++++++++++++++ 1 file changed, 378 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index eb5a6cb0b..c02ca878d 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -67,7 +67,10 @@ bool8 sub_809BF2C(void); void sub_809BF74(void); void sub_809C028(void); void sub_809C04C(void *pokemon, u8 a1); +bool8 sub_809CAB0(void); void sub_809CC04(void); +void sub_809CD88(void); +s8 sub_809CE4C(u8 a0); // .rodata @@ -2101,3 +2104,378 @@ void sub_809C04C(void *pokemon, u8 a1) buf[0] = EOS; } } + +#ifdef NONMATCHING +u8 sub_809C464(void) +{ + u8 r9; + s8 r8 = gUnknown_020384E4; + s8 r4 = gUnknown_020384E5; + gPokemonStorageSystemPtr->unk_11de = 0; + gPokemonStorageSystemPtr->unk_11df = 0; + gPokemonStorageSystemPtr->unk_11e3 = 0; + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + r9 = 1; + if (gUnknown_020384E5 >= 6) + { + r4 -= 6; + } + else + { + r8 = 2; + r4 = 0; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + r9 = 1; + r4 += 6; + if (r4 >= 30) + { + r8 = 3; + r4 -= 30; + r4 /= 3; + gPokemonStorageSystemPtr->unk_11de = 1; + gPokemonStorageSystemPtr->unk_11e3 = 1; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + r9 = 1; + if (gUnknown_020384E5 % 6) + r4--; + else + { + gPokemonStorageSystemPtr->unk_11df = -1; + r4 += 5; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + r9 = 1; + if ((gUnknown_020384E5 + 1) % 6) + r4++; + else + { + gPokemonStorageSystemPtr->unk_11df = 1; + r4 -= 5; + } + } + else if (gMain.newKeys & START_BUTTON) + { + r9 = 1; + r8 = 2; + r4 = 0; + } + else + { + if ((gMain.newKeys & A_BUTTON) && sub_809CAB0()) + { + if (gUnknown_020384E9 == 0) + return 8; + switch (sub_809CE4C(0)) + { + case 1: + return 11; + case 2: + return 12; + case 3: + return 13; + case 4: + return 14; + case 5: + return 15; + } + } + if (gMain.newKeys & B_BUTTON) + return 16; + if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + { + if (gMain.heldKeys & L_BUTTON) + return 10; + if (gMain.heldKeys & R_BUTTON) + return 9; + } + if (gMain.newKeys & SELECT_BUTTON) + { + sub_809CD88(); + return 0; + } + r9 = 0; + } + if (r9) + sub_809AF18(r8, r4); + return r9; +} +#else +__attribute__((naked)) u8 sub_809C464(void) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r9\n" + "\tmov r6, r8\n" + "\tpush {r6,r7}\n" + "\tldr r0, _0809C4D8 @ =gUnknown_020384E4\n" + "\tldrb r0, [r0]\n" + "\tmov r8, r0\n" + "\tldr r2, _0809C4DC @ =gUnknown_020384E5\n" + "\tldrb r4, [r2]\n" + "\tldr r0, _0809C4E0 @ =gPokemonStorageSystemPtr\n" + "\tldr r1, [r0]\n" + "\tldr r0, _0809C4E4 @ =0x000011de\n" + "\tadds r7, r1, r0\n" + "\tmovs r0, 0\n" + "\tstrb r0, [r7]\n" + "\tldr r3, _0809C4E8 @ =0x000011df\n" + "\tadds r5, r1, r3\n" + "\tstrb r0, [r5]\n" + "\tadds r3, 0x4\n" + "\tadds r6, r1, r3\n" + "\tstrb r0, [r6]\n" + "\tldr r0, _0809C4EC @ =gMain\n" + "\tmov r12, r0\n" + "\tldrh r1, [r0, 0x30]\n" + "\tmovs r0, 0x40\n" + "\tands r0, r1\n" + "\tadds r3, r2, 0\n" + "\tcmp r0, 0\n" + "\tbeq _0809C4A0\n" + "\tb _0809C62A\n" + "_0809C4A0:\n" + "\tmovs r0, 0x80\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C4F0\n" + "\tmovs r1, 0x1\n" + "\tmov r9, r1\n" + "\tlsls r0, r4, 24\n" + "\tmovs r3, 0xC0\n" + "\tlsls r3, 19\n" + "\tadds r0, r3\n" + "\tlsrs r4, r0, 24\n" + "\tasrs r0, 24\n" + "\tcmp r0, 0x1D\n" + "\tbgt _0809C4BE\n" + "\tb _0809C648\n" + "_0809C4BE:\n" + "\tmovs r1, 0x3\n" + "\tmov r8, r1\n" + "\tsubs r0, 0x1E\n" + "\tlsls r0, 24\n" + "\tasrs r0, 24\n" + "\tbl __divsi3\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tmov r3, r9\n" + "\tstrb r3, [r7]\n" + "\tstrb r3, [r6]\n" + "\tb _0809C648\n" + "\t.align 2, 0\n" + "_0809C4D8: .4byte gUnknown_020384E4\n" + "_0809C4DC: .4byte gUnknown_020384E5\n" + "_0809C4E0: .4byte gPokemonStorageSystemPtr\n" + "_0809C4E4: .4byte 0x000011de\n" + "_0809C4E8: .4byte 0x000011df\n" + "_0809C4EC: .4byte gMain\n" + "_0809C4F0:\n" + "\tmovs r0, 0x20\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C524\n" + "\tmovs r0, 0x1\n" + "\tmov r9, r0\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r3, r0]\n" + "\tmovs r1, 0x6\n" + "\tbl __modsi3\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _0809C514\n" + "\tlsls r0, r4, 24\n" + "\tmovs r1, 0xFF\n" + "\tlsls r1, 24\n" + "\tb _0809C63C\n" + "_0809C514:\n" + "\tmovs r0, 0xFF\n" + "\tstrb r0, [r5]\n" + "\tlsls r0, r4, 24\n" + "\tmovs r3, 0xA0\n" + "\tlsls r3, 19\n" + "\tadds r0, r3\n" + "\tlsrs r4, r0, 24\n" + "\tb _0809C648\n" + "_0809C524:\n" + "\tmovs r0, 0x10\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C554\n" + "\tmovs r0, 0x1\n" + "\tmov r9, r0\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r3, r0]\n" + "\tadds r0, 0x1\n" + "\tmovs r1, 0x6\n" + "\tbl __modsi3\n" + "\tcmp r0, 0\n" + "\tbeq _0809C548\n" + "\tlsls r0, r4, 24\n" + "\tmovs r1, 0x80\n" + "\tlsls r1, 17\n" + "\tb _0809C63C\n" + "_0809C548:\n" + "\tmov r3, r9\n" + "\tstrb r3, [r5]\n" + "\tlsls r0, r4, 24\n" + "\tmovs r1, 0xFB\n" + "\tlsls r1, 24\n" + "\tb _0809C63C\n" + "_0809C554:\n" + "\tmov r3, r12\n" + "\tldrh r1, [r3, 0x2E]\n" + "\tmovs r0, 0x8\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C56A\n" + "\tmovs r0, 0x1\n" + "\tmov r9, r0\n" + "\tmovs r1, 0x2\n" + "\tmov r8, r1\n" + "\tb _0809C646\n" + "_0809C56A:\n" + "\tmovs r0, 0x1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C5D4\n" + "\tbl sub_809CAB0\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _0809C5D4\n" + "\tldr r0, _0809C588 @ =gUnknown_020384E9\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0\n" + "\tbne _0809C58C\n" + "\tmovs r0, 0x8\n" + "\tb _0809C658\n" + "\t.align 2, 0\n" + "_0809C588: .4byte gUnknown_020384E9\n" + "_0809C58C:\n" + "\tmovs r0, 0\n" + "\tbl sub_809CE4C\n" + "\tsubs r0, 0x1\n" + "\tlsls r0, 24\n" + "\tasrs r0, 24\n" + "\tcmp r0, 0x4\n" + "\tbhi _0809C5D4\n" + "\tlsls r0, 2\n" + "\tldr r1, _0809C5A8 @ =_0809C5AC\n" + "\tadds r0, r1\n" + "\tldr r0, [r0]\n" + "\tmov pc, r0\n" + "\t.align 2, 0\n" + "_0809C5A8: .4byte _0809C5AC\n" + "\t.align 2, 0\n" + "_0809C5AC:\n" + "\t.4byte _0809C5C0\n" + "\t.4byte _0809C5C4\n" + "\t.4byte _0809C5C8\n" + "\t.4byte _0809C5CC\n" + "\t.4byte _0809C5D0\n" + "_0809C5C0:\n" + "\tmovs r0, 0xB\n" + "\tb _0809C658\n" + "_0809C5C4:\n" + "\tmovs r0, 0xC\n" + "\tb _0809C658\n" + "_0809C5C8:\n" + "\tmovs r0, 0xD\n" + "\tb _0809C658\n" + "_0809C5CC:\n" + "\tmovs r0, 0xE\n" + "\tb _0809C658\n" + "_0809C5D0:\n" + "\tmovs r0, 0xF\n" + "\tb _0809C658\n" + "_0809C5D4:\n" + "\tldr r2, _0809C5E4 @ =gMain\n" + "\tldrh r1, [r2, 0x2E]\n" + "\tmovs r0, 0x2\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C5E8\n" + "\tmovs r0, 0x10\n" + "\tb _0809C658\n" + "\t.align 2, 0\n" + "_0809C5E4: .4byte gMain\n" + "_0809C5E8:\n" + "\tldr r0, _0809C600 @ =gSaveBlock2\n" + "\tldrb r0, [r0, 0x13]\n" + "\tcmp r0, 0x1\n" + "\tbne _0809C612\n" + "\tldrh r1, [r2, 0x2C]\n" + "\tmovs r0, 0x80\n" + "\tlsls r0, 2\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C604\n" + "\tmovs r0, 0xA\n" + "\tb _0809C658\n" + "\t.align 2, 0\n" + "_0809C600: .4byte gSaveBlock2\n" + "_0809C604:\n" + "\tmovs r0, 0x80\n" + "\tlsls r0, 1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C612\n" + "\tmovs r0, 0x9\n" + "\tb _0809C658\n" + "_0809C612:\n" + "\tldrh r1, [r2, 0x2E]\n" + "\tmovs r0, 0x4\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C624\n" + "\tbl sub_809CD88\n" + "\tmovs r0, 0\n" + "\tb _0809C658\n" + "_0809C624:\n" + "\tmovs r3, 0\n" + "\tmov r9, r3\n" + "\tb _0809C656\n" + "_0809C62A:\n" + "\tmovs r0, 0x1\n" + "\tmov r9, r0\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r2, r0]\n" + "\tcmp r0, 0x5\n" + "\tble _0809C642\n" + "\tlsls r0, r4, 24\n" + "\tmovs r1, 0xFA\n" + "\tlsls r1, 24\n" + "_0809C63C:\n" + "\tadds r0, r1\n" + "\tlsrs r4, r0, 24\n" + "\tb _0809C648\n" + "_0809C642:\n" + "\tmovs r3, 0x2\n" + "\tmov r8, r3\n" + "_0809C646:\n" + "\tmovs r4, 0\n" + "_0809C648:\n" + "\tmov r0, r9\n" + "\tcmp r0, 0\n" + "\tbeq _0809C656\n" + "\tmov r0, r8\n" + "\tadds r1, r4, 0\n" + "\tbl sub_809AF18\n" + "_0809C656:\n" + "\tmov r0, r9\n" + "_0809C658:\n" + "\tpop {r3,r4}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1"); +} +#endif -- cgit v1.2.3 From 9cfd6fed81b77b4f3aca8ad7b4c2641672cc234b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 21 Jan 2018 21:04:43 -0500 Subject: Create stub files to hold ewram symbols --- src/field/pokedex_area_screen.c | 20 ++++++++++++++++++++ src/field/pokenav.c | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/field/pokedex_area_screen.c create mode 100644 src/field/pokenav.c (limited to 'src') diff --git a/src/field/pokedex_area_screen.c b/src/field/pokedex_area_screen.c new file mode 100644 index 000000000..67ca276c4 --- /dev/null +++ b/src/field/pokedex_area_screen.c @@ -0,0 +1,20 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +EWRAM_DATA u16 gUnknown_02039260 = 0; +EWRAM_DATA u16 gUnknown_02039262 = 0; +EWRAM_DATA u16 gUnknown_02039264 = 0; +EWRAM_DATA u16 gUnknown_02039266 = 0; +EWRAM_DATA u16 gUnknown_02039268 = 0; +EWRAM_DATA u16 gUnknown_0203926A = 0; + +// Static ROM declarations + +// .rodata + +// .text diff --git a/src/field/pokenav.c b/src/field/pokenav.c new file mode 100644 index 000000000..f57a98df6 --- /dev/null +++ b/src/field/pokenav.c @@ -0,0 +1,16 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +EWRAM_DATA u8 gUnknown_020388B0[4] = {}; +EWRAM_DATA u16 gUnknown_020388B4 = 0; + +// Static ROM declarations + +// .rodata + +// .text -- cgit v1.2.3 From cc1767cbc116d26d954d50c6e7642138f012540c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 21 Jan 2018 21:49:43 -0500 Subject: nonmatching sub_809C664 --- src/pokemon/pokemon_storage_system_4.c | 363 +++++++++++++++++++++++++++++++++ 1 file changed, 363 insertions(+) (limited to 'src') diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index c02ca878d..1cc9f7e3b 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -2479,3 +2479,366 @@ __attribute__((naked)) u8 sub_809C464(void) "\tbx r1"); } #endif + +#ifdef NONMATCHING +u8 sub_809C664(void) +{ + s8 r10 = gUnknown_020384E4; + s8 r4 = gUnknown_020384E5; + u8 r8; + u8 r9; + + gPokemonStorageSystemPtr->unk_11df = 0; + gPokemonStorageSystemPtr->unk_11de = 0; + gPokemonStorageSystemPtr->unk_11e3 = 0; + r9 = FALSE; + r8 = 0; + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + if (--r4 < 0) + r4 = 6; + if (r4 != gUnknown_020384E5) + r8 = 1; + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (++r4 > 6) + r4 = 0; + if (r4 != gUnknown_020384E5) + r8 = 1; + } + else if ((gMain.newAndRepeatedKeys & DPAD_LEFT) && gUnknown_020384E5) + { + r8 = 1; + gPokemonStorageSystemPtr->unk_11e2 = gUnknown_020384E5; + r4 = 0; + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + if (gUnknown_020384E5 == 0) + { + r8 = 1; + r4 = gPokemonStorageSystemPtr->unk_11e2; + } + else + { + r8 = 6; + r10 = 0; + r4 = 0; + } + } + else + { + if (gMain.newKeys & A_BUTTON) + { + if (gUnknown_020384E5 == 6) + { + if (gPokemonStorageSystemPtr->unk_0005 == 1) + return 4; + r9 = TRUE; + } + else if (sub_809CAB0()) + { + if (gUnknown_020384E9 == 0) + return 8; + switch (sub_809CE4C(0)) + { + case 1: + return 11; + case 2: + return 12; + case 3: + return 13; + case 4: + return 14; + case 5: + return 15; + } + } + } + if (gMain.newKeys & B_BUTTON) + { + if (gPokemonStorageSystemPtr->unk_0005 == 1) + return 16; + r9 = TRUE; + } + if (!r9) + { + r8 = 6; + r10 = 0; + r4 = 0; + } + else if (gMain.newKeys & SELECT_BUTTON) + { + sub_809CD88(); + return 0; + } + } + if (r8) + sub_809AF18(r10, r4); + return r8; +} +#else +__attribute__((naked)) u8 sub_809C664(void) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tldr r0, _0809C6D8 @ =gUnknown_020384E4\n" + "\tldrb r0, [r0]\n" + "\tmov r10, r0\n" + "\tldr r7, _0809C6DC @ =gUnknown_020384E5\n" + "\tldrb r4, [r7]\n" + "\tldr r2, _0809C6E0 @ =gPokemonStorageSystemPtr\n" + "\tldr r5, [r2]\n" + "\tldr r1, _0809C6E4 @ =0x000011df\n" + "\tadds r0, r5, r1\n" + "\tmovs r1, 0\n" + "\tstrb r1, [r0]\n" + "\tldr r3, _0809C6E8 @ =0x000011de\n" + "\tadds r0, r5, r3\n" + "\tstrb r1, [r0]\n" + "\tadds r3, 0x5\n" + "\tadds r0, r5, r3\n" + "\tstrb r1, [r0]\n" + "\tmov r9, r1\n" + "\tmov r8, r1\n" + "\tldr r1, _0809C6EC @ =gMain\n" + "\tldrh r3, [r1, 0x30]\n" + "\tmovs r0, 0x40\n" + "\tands r0, r3\n" + "\tadds r6, r7, 0\n" + "\tmov r12, r2\n" + "\tadds r2, r1, 0\n" + "\tcmp r0, 0\n" + "\tbeq _0809C6A8\n" + "\tb _0809C81C\n" + "_0809C6A8:\n" + "\tmovs r0, 0x80\n" + "\tands r0, r3\n" + "\tcmp r0, 0\n" + "\tbeq _0809C6F0\n" + "\tlsls r0, r4, 24\n" + "\tmovs r1, 0x80\n" + "\tlsls r1, 17\n" + "\tadds r0, r1\n" + "\tlsrs r4, r0, 24\n" + "\tasrs r0, 24\n" + "\tcmp r0, 0x6\n" + "\tble _0809C6C2\n" + "\tmovs r4, 0\n" + "_0809C6C2:\n" + "\tlsls r0, r4, 24\n" + "\tasrs r0, 24\n" + "\tmovs r1, 0\n" + "\tldrsb r1, [r6, r1]\n" + "\tcmp r0, r1\n" + "\tbne _0809C6D0\n" + "\tb _0809C83C\n" + "_0809C6D0:\n" + "\tmovs r2, 0x1\n" + "\tmov r8, r2\n" + "\tb _0809C842\n" + "\t.align 2, 0\n" + "_0809C6D8: .4byte gUnknown_020384E4\n" + "_0809C6DC: .4byte gUnknown_020384E5\n" + "_0809C6E0: .4byte gPokemonStorageSystemPtr\n" + "_0809C6E4: .4byte 0x000011df\n" + "_0809C6E8: .4byte 0x000011de\n" + "_0809C6EC: .4byte gMain\n" + "_0809C6F0:\n" + "\tmovs r0, 0x20\n" + "\tands r0, r3\n" + "\tcmp r0, 0\n" + "\tbeq _0809C714\n" + "\tldrb r1, [r6]\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r6, r0]\n" + "\tcmp r0, 0\n" + "\tbeq _0809C714\n" + "\tmovs r3, 0x1\n" + "\tmov r8, r3\n" + "\tldr r2, _0809C710 @ =0x000011e2\n" + "\tadds r0, r5, r2\n" + "\tstrb r1, [r0]\n" + "\tmovs r4, 0\n" + "\tb _0809C83C\n" + "\t.align 2, 0\n" + "_0809C710: .4byte 0x000011e2\n" + "_0809C714:\n" + "\tldrh r1, [r2, 0x30]\n" + "\tmovs r0, 0x10\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C748\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r6, r0]\n" + "\tcmp r0, 0\n" + "\tbne _0809C73C\n" + "\tmovs r3, 0x1\n" + "\tmov r8, r3\n" + "\tmov r1, r12\n" + "\tldr r0, [r1]\n" + "\tldr r2, _0809C738 @ =0x000011e2\n" + "\tadds r0, r2\n" + "\tldrb r4, [r0]\n" + "\tb _0809C83C\n" + "\t.align 2, 0\n" + "_0809C738: .4byte 0x000011e2\n" + "_0809C73C:\n" + "\tmovs r3, 0x6\n" + "\tmov r8, r3\n" + "\tmovs r0, 0\n" + "\tmov r10, r0\n" + "\tmovs r4, 0\n" + "\tb _0809C83C\n" + "_0809C748:\n" + "\tldrh r1, [r2, 0x2E]\n" + "\tmovs r0, 0x1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C7D0\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r6, r0]\n" + "\tcmp r0, 0x6\n" + "\tbne _0809C76E\n" + "\tmov r1, r12\n" + "\tldr r0, [r1]\n" + "\tldrb r0, [r0, 0x5]\n" + "\tcmp r0, 0x1\n" + "\tbne _0809C768\n" + "\tmovs r0, 0x4\n" + "\tb _0809C84C\n" + "_0809C768:\n" + "\tmovs r2, 0x1\n" + "\tmov r9, r2\n" + "\tb _0809C7D0\n" + "_0809C76E:\n" + "\tbl sub_809CAB0\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _0809C7D0\n" + "\tldr r0, _0809C784 @ =gUnknown_020384E9\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0\n" + "\tbne _0809C788\n" + "\tmovs r0, 0x8\n" + "\tb _0809C84C\n" + "\t.align 2, 0\n" + "_0809C784: .4byte gUnknown_020384E9\n" + "_0809C788:\n" + "\tmovs r0, 0\n" + "\tbl sub_809CE4C\n" + "\tsubs r0, 0x1\n" + "\tlsls r0, 24\n" + "\tasrs r0, 24\n" + "\tcmp r0, 0x4\n" + "\tbhi _0809C7D0\n" + "\tlsls r0, 2\n" + "\tldr r1, _0809C7A4 @ =_0809C7A8\n" + "\tadds r0, r1\n" + "\tldr r0, [r0]\n" + "\tmov pc, r0\n" + "\t.align 2, 0\n" + "_0809C7A4: .4byte _0809C7A8\n" + "\t.align 2, 0\n" + "_0809C7A8:\n" + "\t.4byte _0809C7BC\n" + "\t.4byte _0809C7C0\n" + "\t.4byte _0809C7C4\n" + "\t.4byte _0809C7C8\n" + "\t.4byte _0809C7CC\n" + "_0809C7BC:\n" + "\tmovs r0, 0xB\n" + "\tb _0809C84C\n" + "_0809C7C0:\n" + "\tmovs r0, 0xC\n" + "\tb _0809C84C\n" + "_0809C7C4:\n" + "\tmovs r0, 0xD\n" + "\tb _0809C84C\n" + "_0809C7C8:\n" + "\tmovs r0, 0xE\n" + "\tb _0809C84C\n" + "_0809C7CC:\n" + "\tmovs r0, 0xF\n" + "\tb _0809C84C\n" + "_0809C7D0:\n" + "\tldr r2, _0809C7EC @ =gMain\n" + "\tldrh r1, [r2, 0x2E]\n" + "\tmovs r0, 0x2\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C7F8\n" + "\tldr r0, _0809C7F0 @ =gPokemonStorageSystemPtr\n" + "\tldr r0, [r0]\n" + "\tldrb r0, [r0, 0x5]\n" + "\tcmp r0, 0x1\n" + "\tbne _0809C7F4\n" + "\tmovs r0, 0x10\n" + "\tb _0809C84C\n" + "\t.align 2, 0\n" + "_0809C7EC: .4byte gMain\n" + "_0809C7F0: .4byte gPokemonStorageSystemPtr\n" + "_0809C7F4:\n" + "\tmovs r3, 0x1\n" + "\tmov r9, r3\n" + "_0809C7F8:\n" + "\tmov r0, r9\n" + "\tcmp r0, 0\n" + "\tbeq _0809C80A\n" + "\tmovs r1, 0x6\n" + "\tmov r8, r1\n" + "\tmovs r2, 0\n" + "\tmov r10, r2\n" + "\tmovs r4, 0\n" + "\tb _0809C83C\n" + "_0809C80A:\n" + "\tldrh r1, [r2, 0x2E]\n" + "\tmovs r0, 0x4\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0809C83C\n" + "\tbl sub_809CD88\n" + "\tmovs r0, 0\n" + "\tb _0809C84C\n" + "_0809C81C:\n" + "\tlsls r0, r4, 24\n" + "\tmovs r3, 0xFF\n" + "\tlsls r3, 24\n" + "\tadds r0, r3\n" + "\tlsrs r4, r0, 24\n" + "\tcmp r0, 0\n" + "\tbge _0809C82C\n" + "\tmovs r4, 0x6\n" + "_0809C82C:\n" + "\tlsls r0, r4, 24\n" + "\tasrs r0, 24\n" + "\tmovs r1, 0\n" + "\tldrsb r1, [r7, r1]\n" + "\tcmp r0, r1\n" + "\tbeq _0809C83C\n" + "\tmovs r0, 0x1\n" + "\tmov r8, r0\n" + "_0809C83C:\n" + "\tmov r1, r8\n" + "\tcmp r1, 0\n" + "\tbeq _0809C84A\n" + "_0809C842:\n" + "\tmov r0, r10\n" + "\tadds r1, r4, 0\n" + "\tbl sub_809AF18\n" + "_0809C84A:\n" + "\tmov r0, r8\n" + "_0809C84C:\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1"); +} +#endif -- cgit v1.2.3