From 72532c9eee8ce32d5486c6702065d52aa3fd1802 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 22 Dec 2018 17:32:21 +0100 Subject: [PATCH 1/3] Match and clean up party_menu.c --- src/party_menu.c | 3229 +++++++++++++++++----------------------------- 1 file changed, 1206 insertions(+), 2023 deletions(-) diff --git a/src/party_menu.c b/src/party_menu.c index f9977fb89..4edfe04c5 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -458,7 +458,7 @@ void sub_81B97DC(struct Pokemon*, u8, u8); void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 e, TaskFunc task, MainCallback callback) { u16 i; - + reset_brm(); gUnknown_0203CEC4 = Alloc(sizeof(struct Struct203CEC4)); if (gUnknown_0203CEC4 == NULL) @@ -476,25 +476,25 @@ void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 e, TaskFunc task, MainCallback cal gUnknown_0203CEC4->unk8_1 = 0; gUnknown_0203CEC4->unk8_2 = 0xFF; gUnknown_0203CEC4->unk9_0 = 0xFF; - + if (a == 4) gUnknown_0203CEC4->unk8_0 = TRUE; else gUnknown_0203CEC4->unk8_0 = FALSE; - + if (b != 0xFF) gUnknown_0203CEC8.mode = b; - + for (i = 0; i <= 15; i++) gUnknown_0203CEC4->data[i] = 0; for (i = 0; i < 3; i++) gUnknown_0203CEC4->unkC[i] |= 0xFF; - + if (d == 0) gUnknown_0203CEC8.unk9 = 0; else if (gUnknown_0203CEC8.unk9 > 5 || GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES) == SPECIES_NONE) gUnknown_0203CEC8.unk9 = 0; // wut why is this else if? - + gTextFlags.autoScroll = 0; CalculatePlayerPartyCount(); SetMainCallback2(PartyMenuInitCallback); @@ -530,122 +530,122 @@ bool8 PartyMenuSetup(void) { switch (gMain.state) { - case 0: - SetVBlankHBlankCallbacksToNull(); - ResetVramOamAndBgCntRegs(); - clear_scheduled_bg_copies_to_vram(); - gMain.state++; - break; - case 1: - ScanlineEffect_Stop(); - gMain.state++; - break; - case 2: - ResetPaletteFade(); - gPaletteFade.bufferTransferDisabled = TRUE; - gMain.state++; - break; - case 3: - ResetSpriteData(); - gMain.state++; - break; - case 4: - FreeAllSpritePalettes(); - gMain.state++; - break; - case 5: - if (!sub_81221AC()) - ResetTasks(); - gMain.state++; - break; - case 6: - sub_81B209C(); - gMain.state++; - break; - case 7: - if (!AllocPartyMenuBg()) - { - PartyMenuExit(); - return TRUE; - } - else - { - gUnknown_0203CEC4->data[0] = 0; - gMain.state++; - } - break; - case 8: - if (AllocPartyMiscGfx()) - gMain.state++; - break; - case 9: - sub_81B239C(gUnknown_0203CEC8.mode); - gMain.state++; - break; - case 10: - PartyMenuInitHelperStructs(gUnknown_0203CEC8.mode); + case 0: + SetVBlankHBlankCallbacksToNull(); + ResetVramOamAndBgCntRegs(); + clear_scheduled_bg_copies_to_vram(); + gMain.state++; + break; + case 1: + ScanlineEffect_Stop(); + gMain.state++; + break; + case 2: + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = TRUE; + gMain.state++; + break; + case 3: + ResetSpriteData(); + gMain.state++; + break; + case 4: + FreeAllSpritePalettes(); + gMain.state++; + break; + case 5: + if (!sub_81221AC()) + ResetTasks(); + gMain.state++; + break; + case 6: + sub_81B209C(); + gMain.state++; + break; + case 7: + if (!AllocPartyMenuBg()) + { + PartyMenuExit(); + return TRUE; + } + else + { gUnknown_0203CEC4->data[0] = 0; gMain.state++; - break; - case 11: - LoadHeldItemIcons(); + } + break; + case 8: + if (AllocPartyMiscGfx()) gMain.state++; - break; - case 12: - LoadPartyMenuPokeballGfx(); + break; + case 9: + sub_81B239C(gUnknown_0203CEC8.mode); + gMain.state++; + break; + case 10: + PartyMenuInitHelperStructs(gUnknown_0203CEC8.mode); + gUnknown_0203CEC4->data[0] = 0; + gMain.state++; + break; + case 11: + LoadHeldItemIcons(); + gMain.state++; + break; + case 12: + LoadPartyMenuPokeballGfx(); + gMain.state++; + break; + case 13: + LoadPartyMenuAilmentGfx(); + gMain.state++; + break; + case 14: + LoadMonIconPalettes(); + gMain.state++; + break; + case 15: + if (party_menu_add_per_mon_objects()) + { + gUnknown_0203CEC4->data[0] = 0; gMain.state++; - break; - case 13: - LoadPartyMenuAilmentGfx(); + } + break; + case 16: + if (RenderPartyMenuBoxes()) + { + gUnknown_0203CEC4->data[0] = 0; gMain.state++; - break; - case 14: - LoadMonIconPalettes(); - gMain.state++; - break; - case 15: - if (party_menu_add_per_mon_objects()) - { - gUnknown_0203CEC4->data[0] = 0; - gMain.state++; - } - break; - case 16: - if (RenderPartyMenuBoxes()) - { - gUnknown_0203CEC4->data[0] = 0; - gMain.state++; - } - break; - case 17: - sub_81B0F28(); - gMain.state++; - break; - case 18: - sub_81B2428(gUnknown_0203CEC4->unk8_0); - gMain.state++; - break; - case 19: - gMain.state++; - break; - case 20: - CreateTask(gUnknown_0203CEC4->unk0, 0); - display_pokemon_menu_message(gUnknown_0203CEC4->unkA_0); - gMain.state++; - break; - case 21: - BlendPalettes(0xFFFFFFFF, 16, 0); - gPaletteFade.bufferTransferDisabled = FALSE; - gMain.state++; - break; - case 22: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - gMain.state++; - break; - default: - SetVBlankCallback(PartyMenuVBlankCallback); - SetMainCallback2(PartyMenuCallback); - return TRUE; + } + break; + case 17: + sub_81B0F28(); + gMain.state++; + break; + case 18: + sub_81B2428(gUnknown_0203CEC4->unk8_0); + gMain.state++; + break; + case 19: + gMain.state++; + break; + case 20: + CreateTask(gUnknown_0203CEC4->unk0, 0); + display_pokemon_menu_message(gUnknown_0203CEC4->unkA_0); + gMain.state++; + break; + case 21: + BlendPalettes(0xFFFFFFFF, 16, 0); + gPaletteFade.bufferTransferDisabled = FALSE; + gMain.state++; + break; + case 22: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + gMain.state++; + break; + default: + SetVBlankCallback(PartyMenuVBlankCallback); + SetMainCallback2(PartyMenuCallback); + return TRUE; } return FALSE; } @@ -698,48 +698,48 @@ bool8 AllocPartyMenuBg(void) bool8 AllocPartyMiscGfx(void) { int sizeout; - + switch (gUnknown_0203CEC4->data[0]) { - case 0: - gUnknown_0203CEE0 = malloc_and_decompress(gPartyMenuMisc_Gfx, &sizeout); - LoadBgTiles(1, gUnknown_0203CEE0, sizeout, 0); + case 0: + gUnknown_0203CEE0 = malloc_and_decompress(gPartyMenuMisc_Gfx, &sizeout); + LoadBgTiles(1, gUnknown_0203CEE0, sizeout, 0); + gUnknown_0203CEC4->data[0]++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + LZDecompressWram(gPartyMenuMisc_Tilemap, gUnknown_0203CEE4); gUnknown_0203CEC4->data[0]++; - break; - case 1: - if (!IsDma3ManagerBusyWithBgCopy()) - { - LZDecompressWram(gPartyMenuMisc_Tilemap, gUnknown_0203CEE4); - gUnknown_0203CEC4->data[0]++; - } - break; - case 2: - LoadCompressedPalette(gPartyMenuMisc_Pal, 0, 0x160); - CpuCopy16(gPlttBufferUnfaded, gUnknown_0203CEC4->palBuffer, 0x160); - gUnknown_0203CEC4->data[0]++; - break; - case 3: - PartyPaletteBufferCopy(4); - gUnknown_0203CEC4->data[0]++; - break; - case 4: - PartyPaletteBufferCopy(5); - gUnknown_0203CEC4->data[0]++; - break; - case 5: - PartyPaletteBufferCopy(6); - gUnknown_0203CEC4->data[0]++; - break; - case 6: - PartyPaletteBufferCopy(7); - gUnknown_0203CEC4->data[0]++; - break; - case 7: - PartyPaletteBufferCopy(8); - gUnknown_0203CEC4->data[0]++; - break; - default: - return TRUE; + } + break; + case 2: + LoadCompressedPalette(gPartyMenuMisc_Pal, 0, 0x160); + CpuCopy16(gPlttBufferUnfaded, gUnknown_0203CEC4->palBuffer, 0x160); + gUnknown_0203CEC4->data[0]++; + break; + case 3: + PartyPaletteBufferCopy(4); + gUnknown_0203CEC4->data[0]++; + break; + case 4: + PartyPaletteBufferCopy(5); + gUnknown_0203CEC4->data[0]++; + break; + case 5: + PartyPaletteBufferCopy(6); + gUnknown_0203CEC4->data[0]++; + break; + case 6: + PartyPaletteBufferCopy(7); + gUnknown_0203CEC4->data[0]++; + break; + case 7: + PartyPaletteBufferCopy(8); + gUnknown_0203CEC4->data[0]++; + break; + default: + return TRUE; } return FALSE; } @@ -767,9 +767,9 @@ void FreePartyPointers(void) void PartyMenuInitHelperStructs(u8 a) { u8 i; - + gUnknown_0203CEDC = Alloc(sizeof(struct Struct203CEDC[PARTY_SIZE])); - + for (i = 0; i < PARTY_SIZE; i++) { gUnknown_0203CEDC[i].unk0 = &gUnknown_086156C4[1]; @@ -822,7 +822,7 @@ void RenderPartyMenuBox(u8 slot) DisplayPartyPokemonSelectHeldItemRelated(slot); else if (!sub_81B0BFC(slot)) DisplayPartyPokemonData(slot); - + if (gUnknown_0203CEC8.unk8_0 == 5) sub_81B0FCC(slot, 0); else if (gUnknown_0203CEC8.unk9 == slot) @@ -857,7 +857,7 @@ void DisplayPartyPokemonData(u8 slot) void DisplayPartyPokemonSelectData(u8 slot, u8 stringID) { struct Pokemon *mon = &gPlayerParty[slot]; - + gUnknown_0203CEDC[slot].unk0->unk0(gUnknown_0203CEDC[slot].windowId, 0, 0, 0, 0, 1); DisplayPartyPokemonNickname(mon, &gUnknown_0203CEDC[slot], 0); if (!GetMonData(mon, MON_DATA_IS_EGG)) @@ -873,7 +873,7 @@ void DisplayPartyPokemonSelectForBattle(u8 slot) u8 i; struct Pokemon *mon = &gPlayerParty[slot]; u8 *ptr = gSelectedOrderFromParty; - + if (!GetBattleEntryEligibility(mon)) { DisplayPartyPokemonSelectData(slot, 7); @@ -897,15 +897,15 @@ void DisplayPartyPokemonSelectForContest(u8 slot) { switch (sub_80DAE0C(&gPlayerParty[slot])) { - case 0: - case 3: - case 4: - DisplayPartyPokemonSelectData(slot, 7); - break; - case 1: - case 2: - DisplayPartyPokemonSelectData(slot, 6); - break; + case 0: + case 3: + case 4: + DisplayPartyPokemonSelectData(slot, 7); + break; + case 1: + case 2: + DisplayPartyPokemonSelectData(slot, 6); + break; } } @@ -937,7 +937,7 @@ bool8 sub_81B0BFC(u8 slot) { struct Pokemon *currentPokemon = &gPlayerParty[slot]; u16 item = gSpecialVar_ItemId; - + if (gUnknown_0203CEC8.unkB == 12) { gSpecialVar_Result = FALSE; @@ -947,19 +947,19 @@ bool8 sub_81B0BFC(u8 slot) { if (gUnknown_0203CEC8.unkB != 3) return FALSE; - + switch (CheckIfItemIsTMHMOrEvolutionStone(item)) { - default: + default: + return FALSE; + case 1: + DisplayPartyPokemonSelectToTeachMove(slot, item, 0); + break; + case 2: + if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, 3, item) != SPECIES_NONE) return FALSE; - case 1: - DisplayPartyPokemonSelectToTeachMove(slot, item, 0); - break; - case 2: - if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, 3, item) != SPECIES_NONE) - return FALSE; - DisplayPartyPokemonSelectData(slot, 0); - break; + DisplayPartyPokemonSelectData(slot, 0); + break; } } return TRUE; @@ -969,16 +969,16 @@ void DisplayPartyPokemonSelectToTeachMove(u8 slot, u16 item, u8 tutor) { switch (CanPartyPokemonLearnTMTutor(&gPlayerParty[slot], item, tutor)) { - case CANNOT_LEARN_MOVE: - case CANNOT_LEARN_MOVE_IS_EGG: - DisplayPartyPokemonSelectData(slot, 9); - break; - case ALREADY_KNOWS_MOVE: - DisplayPartyPokemonSelectData(slot, 10); - break; - default: - DisplayPartyPokemonSelectData(slot, 8); - break; + case CANNOT_LEARN_MOVE: + case CANNOT_LEARN_MOVE_IS_EGG: + DisplayPartyPokemonSelectData(slot, 9); + break; + case ALREADY_KNOWS_MOVE: + DisplayPartyPokemonSelectData(slot, 10); + break; + default: + DisplayPartyPokemonSelectData(slot, 8); + break; } } @@ -986,7 +986,7 @@ void sub_81B0CEC(u8 slot) { struct Struct203CEDC *structPtr = &gUnknown_0203CEDC[slot]; u8 actualSlot = slot - 3; - + if (gUnknown_02022FF8[actualSlot].species == SPECIES_NONE) { sub_81B2720(structPtr->windowId); @@ -1022,12 +1022,12 @@ u8* GetPartyMiscGraphicsTile(u16 tileId) void party_menu_add_per_mon_objects_internal(u8 slot) { u8 actualSlot; - + if (gUnknown_0203CEC8.unk8_0 == 5 && slot > 2) { u8 status; actualSlot = slot - 3; - + if (gUnknown_02022FF8[actualSlot].species != SPECIES_NONE) { party_menu_link_mon_icon_anim(gUnknown_02022FF8[actualSlot].species, gUnknown_02022FF8[actualSlot].personality, &gUnknown_0203CEDC[slot], 0, 0); @@ -1082,42 +1082,42 @@ void sub_81B0F28(void) void sub_81B0FCC(u8 slot, u8 b) { u8 spriteId; - + switch (slot) { - default: - if (GetMonData(&gPlayerParty[slot], MON_DATA_SPECIES) != SPECIES_NONE) - { - UpdateSelectedPartyBox(&gUnknown_0203CEDC[slot], GetPartyBoxPalBitfield(slot, b)); - AnimateSelectedPartyIcon(gUnknown_0203CEDC[slot].unk9, b); - sub_81B5F98(gUnknown_0203CEDC[slot].unkB, b); - } - return; - case 6: + default: + if (GetMonData(&gPlayerParty[slot], MON_DATA_SPECIES) != SPECIES_NONE) + { + UpdateSelectedPartyBox(&gUnknown_0203CEDC[slot], GetPartyBoxPalBitfield(slot, b)); + AnimateSelectedPartyIcon(gUnknown_0203CEDC[slot].unk9, b); + sub_81B5F98(gUnknown_0203CEDC[slot].unkB, b); + } + return; + case 6: + if (b == 0) + sub_8199C30(1, 23, 16, 7, 2, 1); + else + sub_8199C30(1, 23, 16, 7, 2, 2); + spriteId = gUnknown_0203CEC4->unk8_2; + break; + case 7: + if (!gUnknown_0203CEC4->unk8_0) + { if (b == 0) - sub_8199C30(1, 23, 16, 7, 2, 1); + sub_8199C30(1, 23, 17, 7, 2, 1); else - sub_8199C30(1, 23, 16, 7, 2, 2); - spriteId = gUnknown_0203CEC4->unk8_2; - break; - case 7: - if (!gUnknown_0203CEC4->unk8_0) - { - if (b == 0) - sub_8199C30(1, 23, 17, 7, 2, 1); - else - sub_8199C30(1, 23, 17, 7, 2, 2); - } - else if (b == 0) - { - sub_8199C30(1, 23, 18, 7, 2, 1); - } - else - { - sub_8199C30(1, 23, 18, 7, 2, 2); - } - spriteId = gUnknown_0203CEC4->unk9_0; - break; + sub_8199C30(1, 23, 17, 7, 2, 2); + } + else if (b == 0) + { + sub_8199C30(1, 23, 18, 7, 2, 1); + } + else + { + sub_8199C30(1, 23, 18, 7, 2, 2); + } + spriteId = gUnknown_0203CEC4->unk9_0; + break; } sub_81B5F98(spriteId, b); schedule_bg_copy_tilemap_to_vram(1); @@ -1141,7 +1141,7 @@ u8 GetPartyBoxPalBitfield(u8 slot, u8 b) } if (gUnknown_0203CEC8.unkB == 10 && slot == gUnknown_0203CEC8.unk9 ) returnVar |= 32; - + return returnVar; } @@ -1149,10 +1149,10 @@ bool8 PartyBoxPal_ParnterOrDisqualifiedInArena(u8 slot) { if (gUnknown_0203CEC8.mode == 2 && (slot == 1 || slot == 4 || slot == 5)) return TRUE; - + if (slot < 3 && (gBattleTypeFlags & BATTLE_TYPE_ARENA) && gMain.inBattle && (gBattleStruct->arenaLostPlayerMons >> sub_81B8F38(slot) & 1)) return TRUE; - + return FALSE; } @@ -1165,19 +1165,20 @@ void sub_81B120C(void) bool8 IsMultiBattle(void) { - if ((gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI)) == (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI) && gMain.inBattle) + if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattleTypeFlags & BATTLE_TYPE_TRAINER && gMain.inBattle) return TRUE; - return FALSE; + else + return FALSE; } void sub_81B1288(struct Pokemon *partySlot, struct Pokemon *pokemon) { struct Pokemon *temp = Alloc(sizeof(struct Pokemon)); - + *temp = *partySlot; *partySlot = *pokemon; *pokemon = *temp; - + Free(temp); } @@ -1193,12 +1194,12 @@ void c3_0811FAB4(u8 taskId) { if (gUnknown_0203CEC8.unk8_0 == 1) sub_81B9080(); - + if (gUnknown_0203CEC4->exitCallback != NULL) SetMainCallback2(gUnknown_0203CEC4->exitCallback); else SetMainCallback2(gUnknown_0203CEC8.exitCallback); - + ResetSpriteData(); FreePartyPointers(); DestroyTask(taskId); @@ -1220,21 +1221,22 @@ void sub_81B1370(u8 taskId) if (!gPaletteFade.active && sub_81221EC() != TRUE) { s8 *ptr = sub_81B13EC(); - + switch (PartyMenuButtonHandler(ptr)) { - case 1: - sub_81B140C(taskId, ptr); - break; - case 2: - sub_81B15D0(taskId, ptr); - break; - case 8: - if (gUnknown_0203CEC4->unk8_0) - { - PlaySE(SE_SELECT); - sub_81B4F88(); - } + case 1: + sub_81B140C(taskId, ptr); + break; + case 2: + sub_81B15D0(taskId, ptr); + break; + case 8: + if (gUnknown_0203CEC4->unk8_0) + { + PlaySE(SE_SELECT); + sub_81B4F88(); + } + break; } } } @@ -1256,68 +1258,68 @@ void sub_81B140C(u8 taskId, s8 *ptr) { switch (gUnknown_0203CEC8.unkB - 3) { - case 7: - if (sub_81B15A4((u8*)ptr)) - { - sub_81B302C(&gUnknown_0203CEC4->unkC[1]); - sub_81615A8(taskId); - } - break; - case 0: - if (sub_81B15A4((u8*)ptr)) - { - if (gUnknown_0203CEC8.unk8_0 == 1) - gUnknown_0203CEC4->exitCallback = sub_81B9140; - - sub_81B302C(&gUnknown_0203CEC4->unkC[1]); - gUnknown_03006328(taskId, sub_81B6794); - } - break; - case 9: - if (sub_81B15A4((u8*)ptr)) - { - PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->unkC[1]); - sub_81B7E4C(taskId); - } - break; - case 4: - if (sub_81B15A4((u8*)ptr)) - { - PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->unkC[1]); - sub_81B8474(taskId); - } - break; - case 2: - case 3: - if (sub_81B15A4((u8*)ptr)) - { - PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->unkC[1]); - sub_81B7FAC(taskId); - } - break; - case 5: + case 7: + if (sub_81B15A4((u8*)ptr)) + { + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + sub_81615A8(taskId); + } + break; + case 0: + if (sub_81B15A4((u8*)ptr)) + { + if (gUnknown_0203CEC8.unk8_0 == 1) + gUnknown_0203CEC4->exitCallback = sub_81B9140; + + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + gUnknown_03006328(taskId, sub_81B6794); + } + break; + case 9: + if (sub_81B15A4((u8*)ptr)) + { PlaySE(SE_SELECT); - sub_81B3938(taskId); - break; - case 8: + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + sub_81B7E4C(taskId); + } + break; + case 4: + if (sub_81B15A4((u8*)ptr)) + { PlaySE(SE_SELECT); - sub_81B12C0(taskId); - break; - case 10: - if (sub_81B15A4((u8*)ptr)) - { - sub_81B21AC(taskId, (u8)*ptr); - } - break; - default: - case 1: - case 6: + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + sub_81B8474(taskId); + } + break; + case 2: + case 3: + if (sub_81B15A4((u8*)ptr)) + { PlaySE(SE_SELECT); - sub_81B36FC(taskId); - break; + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); + sub_81B7FAC(taskId); + } + break; + case 5: + PlaySE(SE_SELECT); + sub_81B3938(taskId); + break; + case 8: + PlaySE(SE_SELECT); + sub_81B12C0(taskId); + break; + case 10: + if (sub_81B15A4((u8*)ptr)) + { + sub_81B21AC(taskId, (u8)*ptr); + } + break; + default: + case 1: + case 6: + PlaySE(SE_SELECT); + sub_81B36FC(taskId); + break; } } } @@ -1336,44 +1338,44 @@ void sub_81B15D0(u8 taskId, s8 *ptr) { switch (gUnknown_0203CEC8.unkB) { - case 1: - PlaySE(SE_HAZURE); - break; - case 8: - case 10: - PlaySE(SE_SELECT); - sub_81B407C(taskId); - break; - case 13: - PlaySE(SE_SELECT); - sub_81B2210(taskId); - break; - default: - PlaySE(SE_SELECT); - if (sub_81B1660(taskId) != TRUE) - { - if (!sub_81221AC()) - gSpecialVar_0x8004 = 7; - gUnknown_0203CEE8 = 0; - *ptr = 7; - sub_81B12C0(taskId); - } - break; + case 1: + PlaySE(SE_HAZURE); + break; + case 8: + case 10: + PlaySE(SE_SELECT); + sub_81B407C(taskId); + break; + case 13: + PlaySE(SE_SELECT); + sub_81B2210(taskId); + break; + default: + PlaySE(SE_SELECT); + if (sub_81B1660(taskId) != TRUE) + { + if (!sub_81221AC()) + gSpecialVar_0x8004 = 7; + gUnknown_0203CEE8 = 0; + *ptr = 7; + sub_81B12C0(taskId); + } + break; } -} +} bool8 sub_81B1660(u8 taskId) { const u8* stringPtr = NULL; - + if (gUnknown_0203CEC8.unk8_0 == 2) stringPtr = gText_CancelParticipation; else if (gUnknown_0203CEC8.unk8_0 == 4) stringPtr = sub_81B88BC(); - + if (stringPtr == NULL) return FALSE; - + sub_81B302C(&gUnknown_0203CEC4->unkC[1]); StringExpandPlaceholders(gStringVar4, stringPtr); sub_81B1B5C(gStringVar4, 1); @@ -1394,78 +1396,79 @@ void sub_81B1708(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - gUnknown_0203CEE8 = 0; - gUnknown_0203CEC8.unk9 = 7; - sub_81B8558(); - sub_81B12C0(taskId); - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - sub_81B1C1C(taskId); - break; + case 0: + gUnknown_0203CEE8 = 0; + gUnknown_0203CEC8.unk9 = 7; + sub_81B8558(); + sub_81B12C0(taskId); + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + sub_81B1C1C(taskId); + break; } } u16 PartyMenuButtonHandler(s8 *ptr) { s8 movementDir; - + switch (gMain.newAndRepeatedKeys) { - case DPAD_UP: + case DPAD_UP: + movementDir = -1; + break; + case DPAD_DOWN: + movementDir = 1; + break; + case DPAD_LEFT: + movementDir = -2; + break; + case DPAD_RIGHT: + movementDir = 2; + break; + default: + switch (sub_812210C()) + { + case 1: movementDir = -1; break; - case DPAD_DOWN: + case 2: movementDir = 1; break; - case DPAD_LEFT: - movementDir = -2; - break; - case DPAD_RIGHT: - movementDir = 2; - break; default: - switch (sub_812210C()) - { - case 1: - movementDir = -1; - break; - case 2: - movementDir = 1; - break; - default: - movementDir = 0; - break; - } + movementDir = 0; + break; + } + break; } - + if (gMain.newKeys & START_BUTTON) return 8; - + if (movementDir) { UpdateCurrentPartySelection(ptr, movementDir); return 0; } - + if ((gMain.newKeys & A_BUTTON) && *ptr == 7) return 2; - + return gMain.newKeys & (A_BUTTON | B_BUTTON); } -#ifdef NONMATCHING void UpdateCurrentPartySelection(s8 *ptr, s8 movementDir) { s8 slot = *ptr; - - if (gUnknown_0203CEC8.mode == 0) + u8 mode = gUnknown_0203CEC8.mode; + + if (mode == 0) SetNewPartySelectTarget1(ptr, movementDir); else SetNewPartySelectTarget2(ptr, movementDir); - + if (*ptr != slot) { PlaySE(SE_SELECT); @@ -1473,588 +1476,166 @@ void UpdateCurrentPartySelection(s8 *ptr, s8 movementDir) sub_81B0FCC(*ptr, 1); } } -#else -NAKED -void UpdateCurrentPartySelection(s8 *ptr, s8 b) -{ - asm_unified("push {r4,r5,lr}\n\ - adds r5, r0, 0\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - ldrb r4, [r5]\n\ - ldr r0, =gUnknown_0203CEC8\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 26\n\ - lsrs r0, 30\n\ - cmp r0, 0\n\ - bne _081B1820\n\ - lsls r1, 24\n\ - asrs r1, 24\n\ - adds r0, r5, 0\n\ - bl SetNewPartySelectTarget1\n\ - b _081B182A\n\ - .pool\n\ -_081B1820:\n\ - lsls r1, 24\n\ - asrs r1, 24\n\ - adds r0, r5, 0\n\ - bl SetNewPartySelectTarget2\n\ -_081B182A:\n\ - movs r1, 0\n\ - ldrsb r1, [r5, r1]\n\ - lsls r4, 24\n\ - asrs r0, r4, 24\n\ - cmp r1, r0\n\ - beq _081B184C\n\ - movs r0, 0x5\n\ - bl PlaySE\n\ - lsrs r0, r4, 24\n\ - movs r1, 0\n\ - bl sub_81B0FCC\n\ - ldrb r0, [r5]\n\ - movs r1, 0x1\n\ - bl sub_81B0FCC\n\ -_081B184C:\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n"); -} -#endif -#ifdef NONMATCHING void SetNewPartySelectTarget1(s8 *ptr, s8 b) { - u8 r0r2; - switch (b) { - case -1: - r0r2 = *ptr; - if (*ptr == 0) - { - *ptr = 7; - } - else if (*ptr == 6) - { + case -1: + if (*ptr == 0) + { + *ptr = 7; + } + else if (*ptr == 6) + { + *ptr = gPlayerPartyCount - 1; + } + else if (*ptr == 7) + { + if (gUnknown_0203CEC4->unk8_0) + *ptr = 6; + else *ptr = gPlayerPartyCount - 1; - } - else if (*ptr == 7) + } + else + { + (*ptr)--; + } + break; + case 1: + if (*ptr == 7) + { + *ptr = 0; + } + else + { + if (*ptr == gPlayerPartyCount - 1) { if (gUnknown_0203CEC4->unk8_0) *ptr = 6; else - *ptr = gPlayerPartyCount - 1; + *ptr = 7; } else { - *ptr = r0r2 - 1; - } - break; - case 1: - r0r2 = *ptr; - if (*ptr != 7) - { - if ((u32)*ptr == gPlayerPartyCount - 1) - { - if (gUnknown_0203CEC4->unk8_0) - *ptr = 6; - else - *ptr = 7; - } - else - { - *ptr = r0r2 + 1; - } + (*ptr)++; } + } + break; + case 2: + if (gPlayerPartyCount != 1 && *ptr == 0) + { + if (gUnknown_0203CEC4->unk8_1 == 0) + *ptr = 1; else - { - *ptr = 0; - } - break; - case 2: - if (gPlayerPartyCount != 1 && *ptr == 0) - { - if (gUnknown_0203CEC4->unk8_1 == 0) - *ptr = 1; - else - *ptr = gUnknown_0203CEC4->unk8_1; - } - break; - case -2: - if (*ptr != 0 && *ptr != 6 && *ptr != 7) - { - gUnknown_0203CEC4->unk8_1 = *ptr; - *ptr = 0; - } - break; + *ptr = gUnknown_0203CEC4->unk8_1; + } + break; + case -2: + if (*ptr != 0 && *ptr != 6 && *ptr != 7) + { + gUnknown_0203CEC4->unk8_1 = *ptr; + *ptr = 0; + } + break; } } -#else -NAKED -void SetNewPartySelectTarget1(s8 *ptr, s8 b) -{ - asm_unified("push {r4,lr}\n\ - adds r4, r0, 0\n\ - lsls r1, 24\n\ - asrs r1, 24\n\ - movs r0, 0x1\n\ - negs r0, r0\n\ - cmp r1, r0\n\ - beq _081B187A\n\ - cmp r1, r0\n\ - bgt _081B1870\n\ - subs r0, 0x1\n\ - cmp r1, r0\n\ - beq _081B1924\n\ - b _081B1952\n\ -_081B1870:\n\ - cmp r1, 0x1\n\ - beq _081B18C0\n\ - cmp r1, 0x2\n\ - beq _081B18F8\n\ - b _081B1952\n\ -_081B187A:\n\ - ldrb r0, [r4]\n\ - movs r1, 0\n\ - ldrsb r1, [r4, r1]\n\ - cmp r1, 0\n\ - bne _081B1888\n\ - movs r0, 0x7\n\ - b _081B1950\n\ -_081B1888:\n\ - cmp r1, 0x6\n\ - bne _081B1898\n\ - ldr r0, =gPlayerPartyCount\n\ - ldrb r0, [r0]\n\ - subs r0, 0x1\n\ - b _081B1950\n\ - .pool\n\ -_081B1898:\n\ - cmp r1, 0x7\n\ - bne _081B18BC\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 31\n\ - cmp r0, 0\n\ - beq _081B18B0\n\ - movs r0, 0x6\n\ - b _081B1950\n\ - .pool\n\ -_081B18B0:\n\ - ldr r0, =gPlayerPartyCount\n\ - ldrb r0, [r0]\n\ - subs r0, 0x1\n\ - b _081B1950\n\ - .pool\n\ -_081B18BC:\n\ - subs r0, 0x1\n\ - b _081B1950\n\ -_081B18C0:\n\ - ldrb r2, [r4]\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - cmp r0, 0x7\n\ - beq _081B194E\n\ - movs r1, 0\n\ - ldrsb r1, [r4, r1]\n\ - ldr r0, =gPlayerPartyCount\n\ - ldrb r0, [r0]\n\ - subs r0, 0x1\n\ - cmp r1, r0\n\ - bne _081B18F4\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 31\n\ - cmp r0, 0\n\ - beq _081B18F0\n\ - movs r0, 0x6\n\ - b _081B1950\n\ - .pool\n\ -_081B18F0:\n\ - movs r0, 0x7\n\ - b _081B1950\n\ -_081B18F4:\n\ - adds r0, r2, 0x1\n\ - b _081B1950\n\ -_081B18F8:\n\ - ldr r0, =gPlayerPartyCount\n\ - ldrb r0, [r0]\n\ - cmp r0, 0x1\n\ - beq _081B1952\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - cmp r0, 0\n\ - bne _081B1952\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 28\n\ - lsrs r0, 29\n\ - cmp r0, 0\n\ - bne _081B1950\n\ - movs r0, 0x1\n\ - b _081B1950\n\ - .pool\n\ -_081B1924:\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - cmp r0, 0\n\ - beq _081B1952\n\ - cmp r0, 0x6\n\ - beq _081B1952\n\ - cmp r0, 0x7\n\ - beq _081B1952\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r3, [r0]\n\ - movs r1, 0\n\ - ldrsb r1, [r4, r1]\n\ - movs r0, 0x7\n\ - ands r1, r0\n\ - lsls r1, 1\n\ - ldrb r2, [r3, 0x8]\n\ - movs r0, 0xF\n\ - negs r0, r0\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3, 0x8]\n\ -_081B194E:\n\ - movs r0, 0\n\ -_081B1950:\n\ - strb r0, [r4]\n\ -_081B1952:\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif -#ifdef NONMATCHING void SetNewPartySelectTarget2(s8 *ptr, s8 b) { - u8 unk; s8 unk2 = b; - u8 unk3; - + switch (b) { - case -1: - unk = *ptr; - if (*ptr == 0) + case -1: + if (*ptr == 0) + { + *ptr = 7; + break; + } + else if (*ptr == 6) + { + *ptr = gPlayerPartyCount - 1; + break; + } + else if (*ptr == 7) + { + if (gUnknown_0203CEC4->unk8_0) { - *ptr = 7; + *ptr = 6; + break; } - else if (*ptr == 6) - { - *ptr = gPlayerPartyCount - 1; - } - else if (*ptr == 7) + (*ptr)--; + } + unk2 = sub_81B1B00(*ptr, unk2); + if (unk2 != -1) + *ptr = unk2; + break; + case 1: + if (*ptr == 6) + { + *ptr = 7; + } + else if (*ptr == 7) + { + *ptr = 0; + } + else + { + unk2 = sub_81B1B00(*ptr, 1); + if (unk2 == -1) { if (gUnknown_0203CEC4->unk8_0) - { *ptr = 6; - } else - { - *ptr = unk - 1; - unk2 = sub_81B1B00(*ptr, unk2); - if (unk2 != -1) - *ptr = unk2; - } + *ptr = 7; } else { - unk2 = sub_81B1B00(*ptr, unk2); - if (unk2 != -1) - *ptr = unk2; + *ptr = unk2; } - break; - case 1: - if (*ptr == 6) + } + break; + case 2: + if (*ptr == 0) + { + if (gUnknown_0203CEC4->unk8_1 == 3) { - *ptr = 7; + if (GetMonData(&gPlayerParty[3], MON_DATA_SPECIES) != SPECIES_NONE) + *ptr = 3; } - else if (*ptr == 7) + else if (GetMonData(&gPlayerParty[2], MON_DATA_SPECIES) != SPECIES_NONE) { - *ptr = 0; + *ptr = 2; } - else + } + else if (*ptr == 1) + { + if (gUnknown_0203CEC4->unk8_1 == 5) { - unk2 = sub_81B1B00(*ptr, 1); - if (unk2 == -1) - { - if (gUnknown_0203CEC4->unk8_0) - *ptr = 6; - else - *ptr = 7; - } - else - { - *ptr = unk2; - } + if (GetMonData(&gPlayerParty[5], MON_DATA_SPECIES) != SPECIES_NONE) + *ptr = 5; } - break; - case 2: - if (*ptr == 0) + else if (GetMonData(&gPlayerParty[4], MON_DATA_SPECIES) != SPECIES_NONE) { - if (gUnknown_0203CEC4->unk8_1 == 3) - { - if (GetMonData(&gPlayerParty[3], MON_DATA_SPECIES) != SPECIES_NONE) - *ptr = 3; - } - else if (GetMonData(&gPlayerParty[2], MON_DATA_SPECIES) != SPECIES_NONE) - { - *ptr = 2; - } + *ptr = 4; } - else if (*ptr == 1) - { - if (gUnknown_0203CEC4->unk8_1 == 5) - { - if (GetMonData(&gPlayerParty[5], MON_DATA_SPECIES) != SPECIES_NONE) - *ptr = 5; - } - else if (GetMonData(&gPlayerParty[4], MON_DATA_SPECIES) != SPECIES_NONE) - { - *ptr = 4; - } - } - break; - case -2: - unk3 = *ptr - 2; - if (unk3 <= 1) - { - gUnknown_0203CEC4->unk8_1 = *ptr; - *ptr = 0; - } - else - { - unk3 = *ptr - 4; - if (unk3 <= 1) - { - gUnknown_0203CEC4->unk8_1 = *ptr; - *ptr = 1; - } - } - break; + } + break; + case -2: + if (*ptr == 2 || *ptr == 3) + { + gUnknown_0203CEC4->unk8_1 = *ptr; + *ptr = 0; + } + else if (*ptr == 4 || *ptr == 5) + { + gUnknown_0203CEC4->unk8_1 = *ptr; + *ptr = 1; + } + break; } } -#else -NAKED -void SetNewPartySelectTarget2(s8 *ptr, s8 b) -{ - asm_unified("push {r4-r6,lr}\n\ - adds r4, r0, 0\n\ - lsls r1, 24\n\ - lsrs r2, r1, 24\n\ - asrs r5, r1, 24\n\ - movs r6, 0x1\n\ - negs r6, r6\n\ - cmp r5, r6\n\ - beq _081B1988\n\ - cmp r5, r6\n\ - bgt _081B197E\n\ - movs r0, 0x2\n\ - negs r0, r0\n\ - cmp r5, r0\n\ - bne _081B197C\n\ - b _081B1A9C\n\ -_081B197C:\n\ - b _081B1AF4\n\ -_081B197E:\n\ - cmp r5, 0x1\n\ - beq _081B19E4\n\ - cmp r5, 0x2\n\ - beq _081B1A24\n\ - b _081B1AF4\n\ -_081B1988:\n\ - ldrb r1, [r4]\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - cmp r0, 0\n\ - bne _081B1996\n\ - movs r0, 0x7\n\ - b _081B1AF2\n\ -_081B1996:\n\ - cmp r0, 0x6\n\ - bne _081B19A8\n\ - ldr r0, =gPlayerPartyCount\n\ - ldrb r0, [r0]\n\ - subs r0, 0x1\n\ - b _081B1AF2\n\ - .pool\n\ -_081B19A8:\n\ - cmp r0, 0x7\n\ - bne _081B19C4\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 31\n\ - cmp r0, 0\n\ - beq _081B19C0\n\ - movs r0, 0x6\n\ - b _081B1AF2\n\ - .pool\n\ -_081B19C0:\n\ - subs r0, r1, 0x1\n\ - strb r0, [r4]\n\ -_081B19C4:\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - lsls r1, r2, 24\n\ - asrs r1, 24\n\ - bl sub_81B1B00\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - asrs r0, 24\n\ - movs r1, 0x1\n\ - negs r1, r1\n\ - cmp r0, r1\n\ - bne _081B19E0\n\ - b _081B1AF4\n\ -_081B19E0:\n\ - strb r2, [r4]\n\ - b _081B1AF4\n\ -_081B19E4:\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - cmp r0, 0x6\n\ - bne _081B19F0\n\ - movs r0, 0x7\n\ - b _081B1AF2\n\ -_081B19F0:\n\ - cmp r0, 0x7\n\ - bne _081B19F8\n\ - movs r0, 0\n\ - b _081B1AF2\n\ -_081B19F8:\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - movs r1, 0x1\n\ - bl sub_81B1B00\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - asrs r0, 24\n\ - cmp r0, r6\n\ - bne _081B19E0\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 31\n\ - cmp r0, 0\n\ - beq _081B1A20\n\ - movs r0, 0x6\n\ - b _081B1AF2\n\ - .pool\n\ -_081B1A20:\n\ - movs r0, 0x7\n\ - b _081B1AF2\n\ -_081B1A24:\n\ - movs r0, 0\n\ - ldrsb r0, [r4, r0]\n\ - cmp r0, 0\n\ - bne _081B1A5C\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 28\n\ - lsrs r6, r0, 29\n\ - cmp r6, 0x3\n\ - bne _081B1A54\n\ - ldr r0, =gPlayerParty + 300\n\ - movs r1, 0xB\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _081B1AF4\n\ - strb r6, [r4]\n\ - b _081B1AF4\n\ - .pool\n\ -_081B1A54:\n\ - ldr r0, =gPlayerParty + 200\n\ - b _081B1A70\n\ - .pool\n\ -_081B1A5C:\n\ - cmp r0, 0x1\n\ - bne _081B1AF4\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x8]\n\ - lsls r0, 28\n\ - lsrs r5, r0, 29\n\ - cmp r5, 0x5\n\ - bne _081B1A88\n\ - ldr r0, =gPlayerParty + 500\n\ -_081B1A70:\n\ - movs r1, 0xB\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _081B1AF4\n\ - strb r5, [r4]\n\ - b _081B1AF4\n\ - .pool\n\ -_081B1A88:\n\ - ldr r0, =gPlayerParty + 400\n\ - movs r1, 0xB\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _081B1AF4\n\ - movs r0, 0x4\n\ - b _081B1AF2\n\ - .pool\n\ -_081B1A9C:\n\ - ldrb r1, [r4]\n\ - subs r0, r1, 0x2\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - bhi _081B1ACC\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r3, [r0]\n\ - movs r1, 0\n\ - ldrsb r1, [r4, r1]\n\ - movs r0, 0x7\n\ - ands r1, r0\n\ - lsls r1, 1\n\ - ldrb r2, [r3, 0x8]\n\ - movs r0, 0xF\n\ - negs r0, r0\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3, 0x8]\n\ - movs r0, 0\n\ - b _081B1AF2\n\ - .pool\n\ -_081B1ACC:\n\ - subs r0, r1, 0x4\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - bhi _081B1AF4\n\ - ldr r0, =gUnknown_0203CEC4\n\ - ldr r3, [r0]\n\ - movs r1, 0\n\ - ldrsb r1, [r4, r1]\n\ - movs r0, 0x7\n\ - ands r1, r0\n\ - lsls r1, 1\n\ - ldrb r2, [r3, 0x8]\n\ - movs r0, 0xF\n\ - negs r0, r0\n\ - ands r0, r2\n\ - orrs r0, r1\n\ - strb r0, [r3, 0x8]\n\ - movs r0, 0x1\n\ -_081B1AF2:\n\ - strb r0, [r4]\n\ -_081B1AF4:\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif s8 sub_81B1B00(s8 a, s8 b) { @@ -2077,7 +1658,7 @@ u8* GetMonNickname(struct Pokemon *mon, u8 *dest) u8 sub_81B1B5C(const u8* str, u8 b) { u8 taskId; - + sub_81B3300(str); taskId = CreateTask(sub_81B1B8C, 1); gTasks[taskId].data[0] = b; @@ -2168,7 +1749,7 @@ void sub_81B1D68(u16 item, u16 item2, u8 c) void sub_81B1DB8(struct Pokemon *mon, u16 item) { u8 itemBytes[2]; - + if (ItemIsMail(item) == TRUE) { if (GiveMailToMon(mon, item) == 0xFF) @@ -2182,12 +1763,12 @@ void sub_81B1DB8(struct Pokemon *mon, u16 item) u8 sub_81B1E00(struct Pokemon* mon) { u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); - + if (item == ITEM_NONE) return 0; if (AddBagItem(item, 1) == FALSE) return 1; - + item = ITEM_NONE; SetMonData(mon, MON_DATA_HELD_ITEM, &item); return 2; @@ -2201,7 +1782,7 @@ void pokemon_item_not_removed(u16 itemUnused) void sub_81B1E60(u8 taskId) { s16 *data = gTasks[taskId].data; - + data[0] += data[2]; data[3]--; SetMonData(&gPlayerParty[data[4]], MON_DATA_HP, &data[0]); @@ -2219,7 +1800,7 @@ void sub_81B1F18(u8 taskId, u8 slot, s8 c, s16 HPDifference, TaskFunc func) { struct Pokemon *mon = &gPlayerParty[slot]; s16 *data = gTasks[taskId].data; - + data[0] = GetMonData(mon, MON_DATA_HP); data[1] = GetMonData(mon, MON_DATA_MAX_HP); data[2] = c; @@ -2232,7 +1813,7 @@ void sub_81B1F18(u8 taskId, u8 slot, s8 c, s16 HPDifference, TaskFunc func) void sub_81B1FA8(u8 taskId, u8 b, u32 hp) { s16 *data = gTasks[taskId].data; - + switch (b) // only case 0 is used { case 0: @@ -2275,7 +1856,7 @@ u8 pokemon_ailments_get_primary(u32 status) u8 sub_81B205C(struct Pokemon *mon) { u8 ailment; - + if (GetMonData(mon, MON_DATA_HP) == 0) return AILMENT_FNT; ailment = pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS)); @@ -2289,11 +1870,11 @@ u8 sub_81B205C(struct Pokemon *mon) void sub_81B209C(void) { u16 *ptr; - + if (gUnknown_0203CEC8.unk8_0 == 11) { u8 i; - + ptr = &gUnknown_0203CEC8.unkE; gUnknown_0203CEC8.unkE = 0; if (gSpecialVar_0x8005 == 0) @@ -2369,22 +1950,22 @@ void sub_81B227C(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - gSpecialVar_0x8004 = 7; - sub_81B12C0(taskId); - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - gTasks[taskId].func = sub_81B1C1C; - break; + case 0: + gSpecialVar_0x8004 = 7; + sub_81B12C0(taskId); + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + gTasks[taskId].func = sub_81B1C1C; + break; } } u8 CanPartyPokemonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor) { u16 move; - + if (GetMonData(mon, MON_DATA_IS_EGG)) return CANNOT_LEARN_MOVE_IS_EGG; if (item >= ITEM_TM01_FOCUS_PUNCH) @@ -2403,7 +1984,7 @@ u8 CanPartyPokemonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor) { move = sub_81B2360(tutor); } - + if (pokemon_has_move(mon, move) == TRUE) return ALREADY_KNOWS_MOVE; return CAN_LEARN_MOVE; @@ -2424,21 +2005,21 @@ bool8 sub_81B2370(u16 species, u8 tutor) void sub_81B239C(u8 a) { u8 i; - + switch (a) { - case 0: - InitWindows(gUnknown_08615810); - break; - case 1: - InitWindows(gUnknown_08615850); - break; - case 2: - InitWindows(gUnknown_08615890); - break; - default: - InitWindows(gUnknown_086158D0); - break; + case 0: + InitWindows(gUnknown_08615810); + break; + case 1: + InitWindows(gUnknown_08615850); + break; + case 2: + InitWindows(gUnknown_08615890); + break; + default: + InitWindows(gUnknown_086158D0); + break; } DeactivateAllTextPrinters(); for (i = 0; i < PARTY_SIZE; i++) @@ -2454,7 +2035,7 @@ void sub_81B2428(bool8 a) u8 windowId; u8 offset; u8 mainOffset; - + if (gUnknown_0203CEC8.unk8_0 != 5) { if (a == TRUE) @@ -2499,7 +2080,7 @@ void BlitBitmapToPartyWindow(u8 windowId, u8 *b, u8 c, u8 x, u8 y, u8 width, u8 { u8 *pixels = AllocZeroed(height * width * 32); u8 i, j; - + if (pixels != NULL) { for (i = 0; i < height; i++) @@ -2546,7 +2127,7 @@ void sub_81B2720(u8 windowId) void UpdateSelectedPartyBox(struct Struct203CEDC *ptr, u8 bitfield) { u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16; - + if (bitfield & 0x40) { LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AF1[0]), gUnknown_08615AC0[0] + palNum, 2); @@ -2674,7 +2255,7 @@ void DisplayPartyPokemonBarDetail(u8 windowId, const u8 *str, u8 color, u8 *alig void DisplayPartyPokemonNickname(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c) { u8 nickname[POKEMON_NAME_LENGTH + 1]; - + if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { if (c == 1) @@ -2710,7 +2291,7 @@ void DisplayPartyPokemonLevel(u8 level, struct Struct203CEDC *ptr) void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c) { u8 nickname[POKEMON_NAME_LENGTH + 1]; - + if (c == 1) ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk4[8] >> 3, (ptr->unk0->unk4[9] >> 3) + 1, ptr->unk0->unk4[10] >> 3, ptr->unk0->unk4[11] >> 3, 0); GetMonNickname(mon, nickname); @@ -2720,23 +2301,23 @@ void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *mon, struct Struct203 void DisplayPartyPokemonGender(u8 gender, u16 species, u8 *nickname, struct Struct203CEDC *ptr) { u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16; - + if (species == SPECIES_NONE) return; if ((species == SPECIES_NIDORAN_M || species == SPECIES_NIDORAN_F) && StringCompare(nickname, gSpeciesNames[species]) == 0) return; switch (gender) { - case MON_MALE: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC3[0]), gUnknown_08615AB6[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC3[1]), gUnknown_08615AB6[1] + palNum, 2); - DisplayPartyPokemonBarDetail(ptr->windowId, gText_MaleSymbol, 2, &ptr->unk0->unk4[8]); - break; - case MON_FEMALE: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC5[0]), gUnknown_08615AB6[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC5[1]), gUnknown_08615AB6[1] + palNum, 2); - DisplayPartyPokemonBarDetail(ptr->windowId, gText_FemaleSymbol, 2, &ptr->unk0->unk4[8]); - break; + case MON_MALE: + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC3[0]), gUnknown_08615AB6[0] + palNum, 2); + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC3[1]), gUnknown_08615AB6[1] + palNum, 2); + DisplayPartyPokemonBarDetail(ptr->windowId, gText_MaleSymbol, 2, &ptr->unk0->unk4[8]); + break; + case MON_FEMALE: + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC5[0]), gUnknown_08615AB6[0] + palNum, 2); + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC5[1]), gUnknown_08615AB6[1] + palNum, 2); + DisplayPartyPokemonBarDetail(ptr->windowId, gText_FemaleSymbol, 2, &ptr->unk0->unk4[8]); + break; } } @@ -2754,10 +2335,10 @@ void DisplayPartyPokemonHPCheck(struct Pokemon *mon, struct Struct203CEDC *ptr, void DisplayPartyPokemonHP(u16 hp, struct Struct203CEDC *ptr) { u8 *strOut = ConvertIntToDecimalStringN(gStringVar1, hp, 1, 3); - + strOut[0] = CHAR_SLASH; strOut[1] = EOS; - + DisplayPartyPokemonBarDetail(ptr->windowId, gStringVar1, 0, &ptr->unk0->unk4[12]); } @@ -2790,24 +2371,24 @@ void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct Struct203CEDC *ptr) { u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16; u8 hpFraction; - + switch (GetHPBarLevel(hp, maxhp)) { - case HP_BAR_GREEN: - case HP_BAR_FULL: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC7[0]), gUnknown_08615AB8[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC7[1]), gUnknown_08615AB8[1] + palNum, 2); - break; - case HP_BAR_YELLOW: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC9[0]), gUnknown_08615AB8[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC9[1]), gUnknown_08615AB8[1] + palNum, 2); - break; - default: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACB[0]), gUnknown_08615AB8[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACB[1]), gUnknown_08615AB8[1] + palNum, 2); - break; + case HP_BAR_GREEN: + case HP_BAR_FULL: + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC7[0]), gUnknown_08615AB8[0] + palNum, 2); + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC7[1]), gUnknown_08615AB8[1] + palNum, 2); + break; + case HP_BAR_YELLOW: + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC9[0]), gUnknown_08615AB8[0] + palNum, 2); + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC9[1]), gUnknown_08615AB8[1] + palNum, 2); + break; + default: + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACB[0]), gUnknown_08615AB8[0] + palNum, 2); + LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACB[1]), gUnknown_08615AB8[1] + palNum, 2); + break; } - + hpFraction = GetScaledHPFraction(hp, maxhp, ptr->unk0->unk4[22]); FillWindowPixelRect(ptr->windowId, gUnknown_08615AB8[1], ptr->unk0->unk4[20], ptr->unk0->unk4[21], hpFraction, 1); FillWindowPixelRect(ptr->windowId, gUnknown_08615AB8[0], ptr->unk0->unk4[20], ptr->unk0->unk4[21] + 1, hpFraction, 2); @@ -2819,87 +2400,17 @@ void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct Struct203CEDC *ptr) CopyWindowToVram(ptr->windowId, 2); } -#ifdef NONMATCHING void DisplayPartyPokemonOtherText(u8 stringID, struct Struct203CEDC *ptr, u8 c) { if (c != 0) { - int unk = ((ptr->unk0->unk1C & 7) + ptr->unk0->unk1E + 7) / 8; - int unk2 = ((ptr->unk0->unk1D & 7) + ptr->unk0->unk1F + 7) / 8; + int unk = ((ptr->unk0->unk1C % 8) + ptr->unk0->unk1E + 7) / 8; + int unk2 = ((ptr->unk0->unk1D % 8) + ptr->unk0->unk1F + 7) / 8; ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk1C >> 3, ptr->unk0->unk1D >> 3, unk, unk2, 1); } if (c != 2) AddTextPrinterParameterized3(ptr->windowId, 1, ptr->unk0->unk1C, ptr->unk0->unk1D, gUnknown_086157FC[0], 0, gUnknown_08615B60[stringID]); } -#else -NAKED -void DisplayPartyPokemonOtherText(u8 stringID, struct Struct203CEDC *ptr, u8 c) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - sub sp, 0xC\n\ - adds r6, r1, 0\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - lsls r2, 24\n\ - lsrs r7, r2, 24\n\ - cmp r7, 0\n\ - beq _081B2FF2\n\ - ldr r5, [r6]\n\ - ldrb r1, [r5, 0x1C]\n\ - movs r4, 0x7\n\ - adds r0, r1, 0\n\ - ands r0, r4\n\ - ldrb r2, [r5, 0x1E]\n\ - adds r0, r2\n\ - adds r3, r0, 0x7\n\ - asrs r3, 3\n\ - ldrb r2, [r5, 0x1D]\n\ - adds r0, r2, 0\n\ - ands r0, r4\n\ - ldrb r4, [r5, 0x1F]\n\ - adds r0, r4\n\ - adds r4, r0, 0x7\n\ - ldrb r0, [r6, 0x8]\n\ - lsrs r1, 3\n\ - lsrs r2, 3\n\ - lsrs r4, 3\n\ - str r4, [sp]\n\ - movs r4, 0x1\n\ - str r4, [sp, 0x4]\n\ - ldr r4, [r5]\n\ - bl _call_via_r4\n\ -_081B2FF2:\n\ - cmp r7, 0x2\n\ - beq _081B3018\n\ - ldrb r0, [r6, 0x8]\n\ - ldr r1, [r6]\n\ - ldrb r2, [r1, 0x1C]\n\ - ldrb r3, [r1, 0x1D]\n\ - ldr r1, =gUnknown_086157FC\n\ - str r1, [sp]\n\ - movs r1, 0\n\ - str r1, [sp, 0x4]\n\ - ldr r4, =gUnknown_08615B60\n\ - mov r5, r8\n\ - lsls r1, r5, 2\n\ - adds r1, r4\n\ - ldr r1, [r1]\n\ - str r1, [sp, 0x8]\n\ - movs r1, 0x1\n\ - bl AddTextPrinterParameterized3\n\ -_081B3018:\n\ - add sp, 0xC\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif void sub_81B302C(u8 *ptr) { @@ -2915,33 +2426,33 @@ void sub_81B302C(u8 *ptr) void display_pokemon_menu_message(u32 stringID) { u8 *windowPtr = &gUnknown_0203CEC4->unkC[1]; - + if (*windowPtr != 0xFF) sub_81B302C(windowPtr); - + if (stringID != 0x7F) { switch (stringID) { - case 21: - *windowPtr = AddWindow(&gUnknown_08615928); - break; - case 24: - *windowPtr = AddWindow(&gUnknown_08615930); - break; - case 25: - *windowPtr = AddWindow(&gUnknown_08615938); - break; - case 22: - case 23: - *windowPtr = AddWindow(&gUnknown_08615940); - break; - case 26: - *windowPtr = AddWindow(&gUnknown_08615948); - break; - default: - *windowPtr = AddWindow(&gUnknown_08615920); - break; + case 21: + *windowPtr = AddWindow(&gUnknown_08615928); + break; + case 24: + *windowPtr = AddWindow(&gUnknown_08615930); + break; + case 25: + *windowPtr = AddWindow(&gUnknown_08615938); + break; + case 22: + case 23: + *windowPtr = AddWindow(&gUnknown_08615940); + break; + case 26: + *windowPtr = AddWindow(&gUnknown_08615948); + break; + default: + *windowPtr = AddWindow(&gUnknown_08615920); + break; } if (stringID == 0) { @@ -2962,10 +2473,10 @@ bool8 sub_81B314C(void) struct Pokemon *party = gPlayerParty; u8 i; u8 j = 0; - + if (gUnknown_0203CEC8.unkB == 1) return TRUE; - + for (i = 0; i < 6; i++) { if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE && (GetMonData(&party[i], MON_DATA_HP) != 0 || GetMonData(&party[i], MON_DATA_IS_EGG))) @@ -2982,39 +2493,39 @@ u8 sub_81B31B0(u8 a) u8 cursorDimension; u8 fontAttribute; u8 i; - + switch (a) { - case 0: - SetWindowTemplateFields(&window, 2, 19, 19 - (gUnknown_0203CEC4->unk17 * 2), 10, gUnknown_0203CEC4->unk17 * 2, 14, 0x2E9); - break; - case 1: - window = gUnknown_08615950; - break; - case 2: - window = gUnknown_08615958; - break; - default: - window = gUnknown_08615960; - break; + case 0: + SetWindowTemplateFields(&window, 2, 19, 19 - (gUnknown_0203CEC4->unk17 * 2), 10, gUnknown_0203CEC4->unk17 * 2, 14, 0x2E9); + break; + case 1: + window = gUnknown_08615950; + break; + case 2: + window = gUnknown_08615958; + break; + default: + window = gUnknown_08615960; + break; } - + gUnknown_0203CEC4->unkC[0] = AddWindow(&window); SetWindowBorderStyle(gUnknown_0203CEC4->unkC[0], FALSE, 0x4F, 13); if (a == 3) return gUnknown_0203CEC4->unkC[0]; cursorDimension = GetMenuCursorDimensionByFont(1, 0); fontAttribute = GetFontAttribute(1, 2); - + for (i = 0; i < gUnknown_0203CEC4->unk17; i++) { u8 unk = (gUnknown_0203CEC4->unkF[i] > 18) ? 4 : 3; AddTextPrinterParameterized4(gUnknown_0203CEC4->unkC[0], 1, cursorDimension, (i * 16) + 1, fontAttribute, 0, gUnknown_086157FC[unk], 0, gUnknown_08615C08[gUnknown_0203CEC4->unkF[i]].textPtr); } - + InitMenuInUpperLeftCorner(gUnknown_0203CEC4->unkC[0], gUnknown_0203CEC4->unk17, 0, 1); schedule_bg_copy_tilemap_to_vram(2); - + return gUnknown_0203CEC4->unkC[0]; } @@ -3046,7 +2557,7 @@ void sub_81B3394(void) void sub_81B33B4(struct Pokemon *mons, u8 a, u8 b) { u8 i; - + if (b == 0) { sub_81B3414(mons, a); @@ -3062,7 +2573,7 @@ void sub_81B33B4(struct Pokemon *mons, u8 a, u8 b) void sub_81B3414(struct Pokemon *mons, u8 a) { u8 i, j; - + gUnknown_0203CEC4->unk17 = 0; AppendToList(gUnknown_0203CEC4->unkF, &gUnknown_0203CEC4->unk17, 0); for (i = 0; i < MAX_MON_MOVES; i++) @@ -3091,50 +2602,50 @@ void sub_81B3414(struct Pokemon *mons, u8 a) u8 sub_81B353C(struct Pokemon *mon) { u32 returnVar; - + switch (gUnknown_0203CEC8.unk8_0) { + case 0: + if (InMultiBattleRoom() == TRUE || GetMonData(mon, MON_DATA_IS_EGG)) + returnVar = 1; + else + returnVar = 0; + break; + case 1: + returnVar = sub_81B8A2C(mon); + break; + case 4: + switch (sub_81B856C(gUnknown_0203CEC8.unk9)) + { + default: + returnVar = 7; + break; case 0: - if (InMultiBattleRoom() == TRUE || GetMonData(mon, MON_DATA_IS_EGG)) - returnVar = 1; - else - returnVar = 0; + returnVar = 4; break; case 1: - returnVar = sub_81B8A2C(mon); - break; - case 4: - switch (sub_81B856C(gUnknown_0203CEC8.unk9)) - { - default: - returnVar = 7; - break; - case 0: - returnVar = 4; - break; - case 1: - returnVar = 5; - break; - } - break; - case 6: - returnVar = (GetMonData(mon, MON_DATA_IS_EGG)) ? 7 : 6; - break; - case 8: - returnVar = 10; - break; - case 9: - returnVar = 11; - break; - case 10: - returnVar = 12; - break; - case 12: - returnVar = 13; - break; - default: - returnVar = 0; + returnVar = 5; break; + } + break; + case 6: + returnVar = (GetMonData(mon, MON_DATA_IS_EGG)) ? 7 : 6; + break; + case 8: + returnVar = 10; + break; + case 9: + returnVar = 11; + break; + case 10: + returnVar = 12; + break; + case 12: + returnVar = 13; + break; + default: + returnVar = 0; + break; } return returnVar; } @@ -3143,7 +2654,7 @@ bool8 sub_81B3608(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 item; - + GetMonNickname(mon, gStringVar1); sub_81B302C(&gUnknown_0203CEC4->unkC[1]); if (gUnknown_0203CEC8.unk8_0 != 12) @@ -3187,7 +2698,7 @@ void sub_81B3730(u8 taskId) { s16 *data; s8 input; - + if (gPaletteFade.active == FALSE && sub_81221EC() != TRUE) { data = gTasks[taskId].data; @@ -3256,7 +2767,7 @@ void sub_81B3938(u8 taskId) { s16 *data = gTasks[taskId].data; u8 windowIds[2]; - + if (gUnknown_0203CEC8.unkA == gUnknown_0203CEC8.unk9) { sub_81B407C(taskId); @@ -3297,20 +2808,18 @@ void sub_81B3938(u8 taskId) } } -#ifdef NONMATCHING bool8 sub_81B3AD8(s16 a, s16 b, u8 *c, u8 *d, u8 *e) { - - if ((a + b) < 0 || a > 31) - { + if ((a + b) < 0) return FALSE; - } + if (a > 31) + return FALSE; + if (a < 0) { - *c = -a; + *c = a * -1; *d = 0; - *e = a + b; - return TRUE; + *e = b + a; } else { @@ -3320,78 +2829,15 @@ bool8 sub_81B3AD8(s16 a, s16 b, u8 *c, u8 *d, u8 *e) *e = 32 - a; else *e = b; - return TRUE; - } + } + return TRUE; } -#else -NAKED -bool8 sub_81B3AD8(s16 a, s16 b, u8 *c, u8 *d, u8 *e) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - adds r6, r2, 0\n\ - mov r12, r3\n\ - ldr r7, [sp, 0x18]\n\ - lsls r0, 16\n\ - lsrs r3, r0, 16\n\ - adds r5, r3, 0\n\ - lsls r1, 16\n\ - lsrs r2, r1, 16\n\ - mov r8, r2\n\ - lsls r0, r3, 16\n\ - asrs r1, r0, 16\n\ - lsls r0, r2, 16\n\ - asrs r0, 16\n\ - adds r4, r1, r0\n\ - cmp r4, 0\n\ - blt _081B3B02\n\ - cmp r1, 0x1F\n\ - ble _081B3B06\n\ -_081B3B02:\n\ - movs r0, 0\n\ - b _081B3B34\n\ -_081B3B06:\n\ - cmp r1, 0\n\ - bge _081B3B1A\n\ - negs r0, r1\n\ - strb r0, [r6]\n\ - movs r0, 0\n\ - mov r1, r12\n\ - strb r0, [r1]\n\ - adds r0, r2, r3\n\ - strb r0, [r7]\n\ - b _081B3B32\n\ -_081B3B1A:\n\ - movs r0, 0\n\ - strb r0, [r6]\n\ - mov r0, r12\n\ - strb r5, [r0]\n\ - cmp r4, 0x1F\n\ - ble _081B3B2E\n\ - movs r0, 0x20\n\ - subs r0, r5\n\ - strb r0, [r7]\n\ - b _081B3B32\n\ -_081B3B2E:\n\ - mov r1, r8\n\ - strb r1, [r7]\n\ -_081B3B32:\n\ - movs r0, 0x1\n\ -_081B3B34:\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n"); -} -#endif void sub_81B3B40(const void *rectSrc, s16 a, s16 b, s16 c, s16 d, s16 e) { u8 f, g, h; - + if (sub_81B3AD8(a, c, &f, &g, &h)) { FillBgTilemapBufferRect_Palette0(0, 0, g, b, h, d); @@ -3411,7 +2857,7 @@ void sub_81B3C0C(struct Struct203CEDC *ptr, s16 a) void sub_81B3C60(u8 taskId) { s16 *data = gTasks[taskId].data; - + if (data[10] != 0) sub_81B3C0C(&gUnknown_0203CEDC[gUnknown_0203CEC8.unk9], data[10]); if (data[11] != 0) @@ -3421,7 +2867,7 @@ void sub_81B3C60(u8 taskId) void sub_81B3CC0(u8 taskId) { s16 *data = gTasks[taskId].data; - + if (data[10] != 0) sub_81B3B40(gUnknown_0203CEF0, data[0] + data[8], data[1], data[2], data[3], data[10]); if (data[11] != 0) @@ -3433,7 +2879,7 @@ void sub_81B3D48(u8 taskId) { s16 *data = gTasks[taskId].data; u16 tilemapRelatedMaybe[2]; - + sub_81B3CC0(taskId); sub_81B3C60(taskId); data[8] += data[10]; @@ -3460,7 +2906,7 @@ void sub_81B3D48(u8 taskId) void sub_81B3E60(u8 taskId) { s16 *data = gTasks[taskId].data; - + sub_81B3CC0(taskId); sub_81B3C60(taskId); if (data[10] == 0 && data[11] == 0) @@ -3487,7 +2933,7 @@ void oamt_swap_pos(u8 *spriteIdPtr1, u8 *spriteIdPtr2) { u8 spriteIdBuffer = *spriteIdPtr1; u16 xBuffer1, yBuffer1, xBuffer2, yBuffer2; - + *spriteIdPtr1 = *spriteIdPtr2; *spriteIdPtr2 = spriteIdBuffer; xBuffer1 = gSprites[*spriteIdPtr1].pos1.x; @@ -3501,7 +2947,7 @@ void oamt_swap_pos(u8 *spriteIdPtr1, u8 *spriteIdPtr2) gSprites[*spriteIdPtr2].pos1.x = xBuffer1; gSprites[*spriteIdPtr2].pos1.y = yBuffer1; gSprites[*spriteIdPtr2].pos2.x = xBuffer2; - gSprites[*spriteIdPtr2].pos2.y = yBuffer2; + gSprites[*spriteIdPtr2].pos2.y = yBuffer2; } void swap_pokemon_and_oams(void) @@ -3509,7 +2955,7 @@ void swap_pokemon_and_oams(void) struct Struct203CEDC *structPtrs[2]; struct Pokemon *mon1, *mon2; struct Pokemon *monBuffer; - + structPtrs[0] = &gUnknown_0203CEDC[gUnknown_0203CEC8.unk9]; structPtrs[1] = &gUnknown_0203CEDC[gUnknown_0203CEC8.unkA]; mon1 = &gPlayerParty[gUnknown_0203CEC8.unk9]; @@ -3604,7 +3050,7 @@ void c2_8123744(void) void sub_81B42D0(u8 taskId) { u16 item; - + if (!gPaletteFade.active) { item = gSpecialVar_ItemId; @@ -3637,32 +3083,32 @@ void sub_81B43DC(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - RemoveBagItem(gSpecialVar_ItemId, 1); - if (AddBagItem(gUnknown_0203CEFC, 1) == FALSE) - { - AddBagItem(gSpecialVar_ItemId, 1); - pokemon_item_not_removed(gUnknown_0203CEFC); - sub_81B1B5C(gStringVar4, 0); - gTasks[taskId].func = sub_81B1C1C; - } - else if (ItemIsMail(gSpecialVar_ItemId)) - { - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], gSpecialVar_ItemId); - gTasks[taskId].func = sub_81B44FC; - } - else - { - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], gSpecialVar_ItemId); - sub_81B1D68(gSpecialVar_ItemId, gUnknown_0203CEFC, 1); - gTasks[taskId].func = sub_81B469C; - } - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: + case 0: + RemoveBagItem(gSpecialVar_ItemId, 1); + if (AddBagItem(gUnknown_0203CEFC, 1) == FALSE) + { + AddBagItem(gSpecialVar_ItemId, 1); + pokemon_item_not_removed(gUnknown_0203CEFC); + sub_81B1B5C(gStringVar4, 0); gTasks[taskId].func = sub_81B1C1C; - break; + } + else if (ItemIsMail(gSpecialVar_ItemId)) + { + sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], gSpecialVar_ItemId); + gTasks[taskId].func = sub_81B44FC; + } + else + { + sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], gSpecialVar_ItemId); + sub_81B1D68(gSpecialVar_ItemId, gUnknown_0203CEFC, 1); + gTasks[taskId].func = sub_81B469C; + } + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + gTasks[taskId].func = sub_81B1C1C; + break; } } @@ -3678,7 +3124,7 @@ void sub_81B44FC(u8 taskId) void sub_81B452C(void) { u8 mail = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_MAIL); - + sub_811A20C(4, gSaveBlock1Ptr->mail[mail].words, sub_81B4578, 3); } @@ -3686,7 +3132,7 @@ void sub_81B4578(void) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); - + if (gSpecialVar_Result == FALSE) { TakeMailFromMon(mon); @@ -3716,7 +3162,7 @@ void sub_81B4624(u8 taskId) void sub_81B469C(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; - + if (sub_81B1BD4() != TRUE) { sub_81B5C94(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.unk9]); @@ -3735,24 +3181,24 @@ void sub_81B4724(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); - + PlaySE(SE_SELECT); sub_81B302C(&gUnknown_0203CEC4->unkC[0]); sub_81B302C(&gUnknown_0203CEC4->unkC[1]); switch (sub_81B1E00(mon)) { - case 0: - GetMonNickname(mon, gStringVar1); - StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); - sub_81B1B5C(gStringVar4, 1); - break; - case 1: - pokemon_item_not_removed(item); - sub_81B1B5C(gStringVar4, 1); - break; - default: - sub_81B1CD0(mon, item, 1); - break; + case 0: + GetMonNickname(mon, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); + sub_81B1B5C(gStringVar4, 1); + break; + case 1: + pokemon_item_not_removed(item); + sub_81B1B5C(gStringVar4, 1); + break; + default: + sub_81B1CD0(mon, item, 1); + break; } schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B469C; @@ -3762,7 +3208,7 @@ void sub_81B47E0(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); - + PlaySE(SE_SELECT); sub_81B302C(&gUnknown_0203CEC4->unkC[0]); sub_81B302C(&gUnknown_0203CEC4->unkC[1]); @@ -3794,20 +3240,20 @@ void sub_81B48A8(u8 taskId) void sub_81B48DC(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; - + switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - CopyItemName(GetMonData(mon, MON_DATA_HELD_ITEM), gStringVar1); - StringExpandPlaceholders(gStringVar4, gText_ItemThrownAway); - sub_81B1B5C(gStringVar4, 0); - gTasks[taskId].func = sub_81B4988; - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - gTasks[taskId].func = sub_81B1C1C; - break; + case 0: + CopyItemName(GetMonData(mon, MON_DATA_HELD_ITEM), gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_ItemThrownAway); + sub_81B1B5C(gStringVar4, 0); + gTasks[taskId].func = sub_81B4988; + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + gTasks[taskId].func = sub_81B1C1C; + break; } } @@ -3815,7 +3261,7 @@ void sub_81B4988(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 itemClear; - + if (sub_81B1BD4() != TRUE) { itemClear = ITEM_NONE; @@ -3878,24 +3324,24 @@ void sub_81B4BA0(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - if (TakeMailFromMon2(&gPlayerParty[gUnknown_0203CEC8.unk9]) != 0xFF) - { - sub_81B1B5C(gText_MailSentToPC, 0); - gTasks[taskId].func = sub_81B469C; - } - else - { - sub_81B1B5C(gText_PCMailboxFull, 0); - gTasks[taskId].func = sub_81B1C1C; - } - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - sub_81B1B5C(gText_MailMessageWillBeLost, 1); - gTasks[taskId].func = sub_81B4C60; - break; + case 0: + if (TakeMailFromMon2(&gPlayerParty[gUnknown_0203CEC8.unk9]) != 0xFF) + { + sub_81B1B5C(gText_MailSentToPC, 0); + gTasks[taskId].func = sub_81B469C; + } + else + { + sub_81B1B5C(gText_PCMailboxFull, 0); + gTasks[taskId].func = sub_81B1C1C; + } + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + sub_81B1B5C(gText_MailMessageWillBeLost, 1); + gTasks[taskId].func = sub_81B4C60; + break; } } @@ -3911,36 +3357,36 @@ void sub_81B4C60(u8 taskId) void sub_81B4C94(u8 taskId) { u16 item; - + switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - item = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_HELD_ITEM); - if (AddBagItem(item, 1) == TRUE) - { - TakeMailFromMon(&gPlayerParty[gUnknown_0203CEC8.unk9]); - sub_81B1B5C(gText_MailTakenFromPkmn, 0); - gTasks[taskId].func = sub_81B469C; - } - else - { - pokemon_item_not_removed(item); - sub_81B1B5C(gStringVar4, 0); - gTasks[taskId].func = sub_81B1C1C; - } - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: + case 0: + item = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_HELD_ITEM); + if (AddBagItem(item, 1) == TRUE) + { + TakeMailFromMon(&gPlayerParty[gUnknown_0203CEC8.unk9]); + sub_81B1B5C(gText_MailTakenFromPkmn, 0); + gTasks[taskId].func = sub_81B469C; + } + else + { + pokemon_item_not_removed(item); + sub_81B1B5C(gStringVar4, 0); gTasks[taskId].func = sub_81B1C1C; - break; + } + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + gTasks[taskId].func = sub_81B1C1C; + break; } } void sub_81B4D78(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; - + PlaySE(SE_SELECT); sub_81B302C(&gUnknown_0203CEC4->unkC[0]); sub_81B302C(&gUnknown_0203CEC4->unkC[1]); @@ -3980,7 +3426,7 @@ void sub_81B4E8C(u8 taskId) { u8 unk; u8 i; - + sub_81B302C(&gUnknown_0203CEC4->unkC[0]); sub_81B302C(&gUnknown_0203CEC4->unkC[1]); unk = sub_81B8830(); @@ -4016,7 +3462,7 @@ void sub_81B4FA8(u8 taskId) { u8 unk; u8 i, j; - + PlaySE(SE_SELECT); sub_81B302C(&gUnknown_0203CEC4->unkC[0]); sub_81B302C(&gUnknown_0203CEC4->unkC[1]); @@ -4052,19 +3498,19 @@ void sub_81B50C8(u8 taskId) u16 species2 = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES); u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_OBEDIENCE); - + switch (sub_807A8D0(*(u32 *)sub_800F7DC() /* dirty cast, probably needs to be changed */, species2, species, obedience)) { - case 1: - StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); - break; - case 2: - StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow); - break; - default: - PlaySE(SE_SELECT); - sub_81B12C0(taskId); - return; + case 1: + StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); + break; + case 2: + StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow); + break; + default: + PlaySE(SE_SELECT); + sub_81B12C0(taskId); + return; } PlaySE(SE_HAZURE); sub_81B302C(&gUnknown_0203CEC4->unkC[0]); @@ -4080,7 +3526,7 @@ void brm_trade_1(u8 taskId) u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES); u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_OBEDIENCE); u32 stringId = sub_807A7E0(*(u32 *)sub_800F7DC() /* dirty cast, probably needs to be changed */, *(u32 *)&gUnknown_02022C38 /* dirty cast, probably needs to be changed */, species2, gUnknown_02022C3C, gUnknown_02022C3E, species, obedience); - + if (stringId != 0) { StringExpandPlaceholders(gStringVar4, gUnknown_08615E0C[stringId - 1]); @@ -4104,22 +3550,22 @@ void sub_81B52E4(u8 taskId) sub_81B302C(&gUnknown_0203CEC4->unkC[1]); switch (sub_807A918(gPlayerParty, gUnknown_0203CEC8.unk9)) { - case 1: - StringExpandPlaceholders(gStringVar4, gText_OnlyPkmnForBattle); - break; - case 2: - StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); - break; - case 3: - StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow); - break; - default: - PlaySE(SE_SELECT); - GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.unk9], gStringVar1); - StringExpandPlaceholders(gStringVar4, gJPText_PutVar1IntoSpinner); - sub_81B1B5C(gStringVar4, 1); - gTasks[taskId].func = sub_81B53FC; - return; + case 1: + StringExpandPlaceholders(gStringVar4, gText_OnlyPkmnForBattle); + break; + case 2: + StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); + break; + case 3: + StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow); + break; + default: + PlaySE(SE_SELECT); + GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.unk9], gStringVar1); + StringExpandPlaceholders(gStringVar4, gJPText_PutVar1IntoSpinner); + sub_81B1B5C(gStringVar4, 1); + gTasks[taskId].func = sub_81B53FC; + return; } PlaySE(SE_HAZURE); StringAppend(gStringVar4, gText_PauseUntilPress); @@ -4140,23 +3586,22 @@ void sub_81B5430(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - sub_81B12C0(taskId); - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - sub_81B1C1C(taskId); - break; + case 0: + sub_81B12C0(taskId); + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + sub_81B1C1C(taskId); + break; } } void sub_81B5470(u8 taskId) { u8 fieldMove = gUnknown_0203CEC4->unkF[GetMenuCursorPos()] - 19; - struct MapHeader const *mapHeader; - u8 fieldMove2; - + const struct MapHeader *mapHeader; + PlaySE(SE_SELECT); if (gUnknown_08615D9C[fieldMove].fieldMoveFunc != NULL) { @@ -4164,8 +3609,7 @@ void sub_81B5470(u8 taskId) sub_81B302C(&gUnknown_0203CEC4->unkC[1]); if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) { - fieldMove2 = fieldMove - 11; - if (fieldMove2 <= 1) + if (fieldMove == 11 || fieldMove == 12) display_pokemon_menu_message(13); else display_pokemon_menu_message(gUnknown_08615D9C[fieldMove].msgID); @@ -4180,49 +3624,49 @@ void sub_81B5470(u8 taskId) } else if (gUnknown_08615D9C[fieldMove].fieldMoveFunc() == TRUE) { - switch (fieldMove - 5) + switch (fieldMove) { - case 6: - case 7: - sub_8161560(taskId); - break; - case 3: - mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum); - sub_81245DC(gStringVar1, mapHeader->regionMapSectionId); - StringExpandPlaceholders(gStringVar4, gText_ReturnToHealingSpot); - sub_81B5674(taskId); - gUnknown_0203CEC4->data[0] = fieldMove; - break; - case 4: - mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum); - sub_81245DC(gStringVar1, mapHeader->regionMapSectionId); - StringExpandPlaceholders(gStringVar4, gText_EscapeFromHere); - sub_81B5674(taskId); - gUnknown_0203CEC4->data[0] = fieldMove; - break; - case 0: - gUnknown_0203CEC8.exitCallback = MCB2_FlyMap; - sub_81B12C0(taskId); - break; - default: - gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; - sub_81B12C0(taskId); - break; + case 11: + case 12: + sub_8161560(taskId); + break; + case 8: + mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum); + sub_81245DC(gStringVar1, mapHeader->regionMapSectionId); + StringExpandPlaceholders(gStringVar4, gText_ReturnToHealingSpot); + sub_81B5674(taskId); + gUnknown_0203CEC4->data[0] = fieldMove; + break; + case 9: + mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum); + sub_81245DC(gStringVar1, mapHeader->regionMapSectionId); + StringExpandPlaceholders(gStringVar4, gText_EscapeFromHere); + sub_81B5674(taskId); + gUnknown_0203CEC4->data[0] = fieldMove; + break; + case 5: + gUnknown_0203CEC8.exitCallback = MCB2_FlyMap; + sub_81B12C0(taskId); + break; + default: + gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; + sub_81B12C0(taskId); + break; } } else { switch (fieldMove) { - case 4: - sub_81B5864(); - break; - case 1: - sub_81B57DC(); - break; - default: - display_pokemon_menu_message(gUnknown_08615D9C[fieldMove].msgID); - break; + case 4: + sub_81B5864(); + break; + case 1: + sub_81B57DC(); + break; + default: + display_pokemon_menu_message(gUnknown_08615D9C[fieldMove].msgID); + break; } gTasks[taskId].func = task_brm_cancel_1_on_keypad_a_or_b; } @@ -4249,17 +3693,17 @@ void sub_81B56D8(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; - sub_81B12C0(taskId); - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - gFieldCallback2 = NULL; - gPostMenuFieldCallback = NULL; - sub_81B1C1C(taskId); - break; + case 0: + gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; + sub_81B12C0(taskId); + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + gFieldCallback2 = NULL; + gPostMenuFieldCallback = NULL; + sub_81B1C1C(taskId); + break; } } @@ -4345,7 +3789,7 @@ void hm2_waterfall(void) bool8 hm_prepare_waterfall(void) { s16 x, y; - + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); if (MetatileBehavior_IsWaterfall(MapGridGetMetatileBehaviorAt(x, y)) == TRUE && IsPlayerSurfingNorth() == TRUE) { @@ -4378,7 +3822,7 @@ void party_menu_icon_anim(struct Pokemon *mon, struct Struct203CEDC *ptr, u32 a) { u32 bit = 1; u16 species2; - + if (IsMultiBattle() == TRUE && gMain.inBattle) bit = (gUnknown_08616020[a] ^ bit) ? 1 : 0; species2 = GetMonData(mon, MON_DATA_SPECIES2); @@ -4399,21 +3843,21 @@ void sub_81B5A8C(u8 spriteId, u16 hp, u16 maxhp) { switch (GetHPBarLevel(hp, maxhp)) { - case HP_BAR_FULL: - sub_80D32C8(&gSprites[spriteId], 0); - break; - case HP_BAR_GREEN: - sub_80D32C8(&gSprites[spriteId], 1); - break; - case HP_BAR_YELLOW: - sub_80D32C8(&gSprites[spriteId], 2); - break; - case HP_BAR_RED: - sub_80D32C8(&gSprites[spriteId], 3); - break; - default: - sub_80D32C8(&gSprites[spriteId], 4); - break; + case HP_BAR_FULL: + sub_80D32C8(&gSprites[spriteId], 0); + break; + case HP_BAR_GREEN: + sub_80D32C8(&gSprites[spriteId], 1); + break; + case HP_BAR_YELLOW: + sub_80D32C8(&gSprites[spriteId], 2); + break; + case HP_BAR_RED: + sub_80D32C8(&gSprites[spriteId], 3); + break; + default: + sub_80D32C8(&gSprites[spriteId], 4); + break; } } @@ -4423,7 +3867,7 @@ void sub_81B5B38(u8 spriteId, struct Pokemon *mon) } void AnimateSelectedPartyIcon(u8 spriteId, u8 a) -{ +{ gSprites[spriteId].data[0] = 0; if (a == 0) { @@ -4450,7 +3894,7 @@ void AnimateSelectedPartyIcon(u8 spriteId, u8 a) void UpdatePartyMonIconFrameAndBounce(struct Sprite *sprite) { u8 unk = UpdateMonIconFrame(sprite); - + if (unk != 0) { if (unk & 1) @@ -4515,25 +3959,25 @@ void sub_81B5D4C(u8 *a, u8 *b, u8 c) { u16 i; u16 item; - + switch (c) { - case 0: - for (i = 0; i < a[0]; i++) - { - item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); - if (item != ITEM_NONE) - sub_81B5DF0(b[i], ItemIsMail(item)); - } - break; - case 1: - for (i = 0; i < a[1]; i++) - { - item = GetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM); - if (item != ITEM_NONE) - sub_81B5DF0(b[i + 6], ItemIsMail(item)); - } - break; + case 0: + for (i = 0; i < a[0]; i++) + { + item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + if (item != ITEM_NONE) + sub_81B5DF0(b[i], ItemIsMail(item)); + } + break; + case 1: + for (i = 0; i < a[1]; i++) + { + item = GetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM); + if (item != ITEM_NONE) + sub_81B5DF0(b[i + 6], ItemIsMail(item)); + } + break; } } @@ -4541,7 +3985,7 @@ void sub_81B5DF0(u8 spriteId, u8 isMail) { u8 subpriority = gSprites[spriteId].subpriority; u8 newSpriteId = CreateSprite(&gSpriteTemplate_8615EC0, 250, 170, subpriority - 1); - + gSprites[newSpriteId].pos2.x = 4; gSprites[newSpriteId].pos2.y = 10; gSprites[newSpriteId].callback = sub_81B5E74; @@ -4553,7 +3997,7 @@ void sub_81B5DF0(u8 spriteId, u8 isMail) void sub_81B5E74(struct Sprite *sprite) { u8 otherSpriteId = sprite->data[7]; - + if (gSprites[otherSpriteId].invisible) { sprite->invisible = TRUE; @@ -4584,7 +4028,7 @@ void party_menu_link_mon_pokeball_object(u16 species, struct Struct203CEDC *ptr) u8 sub_81B5F34(u8 x, u8 y) { u8 spriteId = CreateSprite(&gSpriteTemplate_8615F08, x, y, 8); - + gSprites[spriteId].oam.priority = 2; return spriteId; } @@ -4652,14 +4096,14 @@ void party_menu_update_status_condition_object(u8 status, struct Struct203CEDC * { switch (status) { - case AILMENT_NONE: - case AILMENT_PKRS: - gSprites[ptr->unkC].invisible = TRUE; - break; - default: - StartSpriteAnim(&gSprites[ptr->unkC], status - 1); - gSprites[ptr->unkC].invisible = FALSE; - break; + case AILMENT_NONE: + case AILMENT_PKRS: + gSprites[ptr->unkC].invisible = TRUE; + break; + default: + StartSpriteAnim(&gSprites[ptr->unkC], status - 1); + gSprites[ptr->unkC].invisible = FALSE; + break; } } @@ -4677,7 +4121,7 @@ void sub_81B617C(void) u8 i; u8 msgIDMaybe; register TaskFunc task asm("r0"); - + if (gMain.inBattle) { inBattle = TRUE; @@ -4731,7 +4175,7 @@ void sub_81B6280(u8 taskId) bool8 IsHPRecoveryItem(u16 item) { const u8 *effect; - + if (item == ITEM_ENIGMA_BERRY) effect = gSaveBlock1Ptr->enigmaBerry.itemEffect; else @@ -4743,66 +4187,66 @@ bool8 IsHPRecoveryItem(u16 item) void GetMedicineItemEffectMessage(u16 item) { - switch (GetItemEffectType(item) - 3) + switch (GetItemEffectType(item)) { - case 0: - StringExpandPlaceholders(gStringVar4, gText_PkmnCuredOfPoison); - break; - case 1: - StringExpandPlaceholders(gStringVar4, gText_PkmnWokeUp2); - break; - case 2: - StringExpandPlaceholders(gStringVar4, gText_PkmnBurnHealed); - break; - case 3: - StringExpandPlaceholders(gStringVar4, gText_PkmnThawedOut); - break; - case 4: - StringExpandPlaceholders(gStringVar4, gText_PkmnCuredOfParalysis); - break; - case 5: - StringExpandPlaceholders(gStringVar4, gText_PkmnSnappedOutOfConfusion); - break; - case 6: - StringExpandPlaceholders(gStringVar4, gText_PkmnGotOverInfatuation); - break; - case 8: - StringExpandPlaceholders(gStringVar4, gText_PkmnBecameHealthy); - break; - case 10: - StringCopy(gStringVar2, gText_HP3); - StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); - break; - case 9: - StringCopy(gStringVar2, gText_Attack3); - StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); - break; - case 14: - StringCopy(gStringVar2, gText_Defense3); - StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); - break; - case 13: - StringCopy(gStringVar2, gText_Speed2); - StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); - break; - case 11: - StringCopy(gStringVar2, gText_SpAtk3); - StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); - break; - case 12: - StringCopy(gStringVar2, gText_SpDef3); - StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); - break; - case 16: - case 17: - StringExpandPlaceholders(gStringVar4, gText_MovesPPIncreased); - break; - case 18: - StringExpandPlaceholders(gStringVar4, gText_PPWasRestored); - break; - default: - StringExpandPlaceholders(gStringVar4, gText_WontHaveEffect); - break; + case 3: + StringExpandPlaceholders(gStringVar4, gText_PkmnCuredOfPoison); + break; + case 4: + StringExpandPlaceholders(gStringVar4, gText_PkmnWokeUp2); + break; + case 5: + StringExpandPlaceholders(gStringVar4, gText_PkmnBurnHealed); + break; + case 6: + StringExpandPlaceholders(gStringVar4, gText_PkmnThawedOut); + break; + case 7: + StringExpandPlaceholders(gStringVar4, gText_PkmnCuredOfParalysis); + break; + case 8: + StringExpandPlaceholders(gStringVar4, gText_PkmnSnappedOutOfConfusion); + break; + case 9: + StringExpandPlaceholders(gStringVar4, gText_PkmnGotOverInfatuation); + break; + case 11: + StringExpandPlaceholders(gStringVar4, gText_PkmnBecameHealthy); + break; + case 13: + StringCopy(gStringVar2, gText_HP3); + StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); + break; + case 12: + StringCopy(gStringVar2, gText_Attack3); + StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); + break; + case 17: + StringCopy(gStringVar2, gText_Defense3); + StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); + break; + case 16: + StringCopy(gStringVar2, gText_Speed2); + StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); + break; + case 14: + StringCopy(gStringVar2, gText_SpAtk3); + StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); + break; + case 15: + StringCopy(gStringVar2, gText_SpDef3); + StringExpandPlaceholders(gStringVar4, gText_PkmnBaseVar2StatIncreased); + break; + case 19: + case 20: + StringExpandPlaceholders(gStringVar4, gText_MovesPPIncreased); + break; + case 21: + StringExpandPlaceholders(gStringVar4, gText_PPWasRestored); + break; + default: + StringExpandPlaceholders(gStringVar4, gText_WontHaveEffect); + break; } } @@ -4821,7 +4265,7 @@ bool8 IsBlueYellowRedFlute(u16 item) } bool8 ExecuteTableBasedItemEffect__(u8 partyMonIndex, u16 item, u8 monMoveIndex) -{ +{ if (gMain.inBattle) return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, sub_81B8F38(partyMonIndex), monMoveIndex); else @@ -4834,7 +4278,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 item = gSpecialVar_ItemId; bool8 canHeal; - + if (UsingHPEVItemOnShedinja(mon, item)) { canHeal = IsHPRecoveryItem(item); @@ -4921,7 +4365,7 @@ void sub_81B67C8(u8 taskId, TaskFunc task) bool8 cannotUseEffect = ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.unk9, item, 0); u16 newFriendship = GetMonData(mon, MON_DATA_FRIENDSHIP); u16 newRelevantEV = sub_81B691C(mon, effectType); - + if (cannotUseEffect || (friendship == newFriendship && relevantEV == newRelevantEV)) { gUnknown_0203CEE8 = 0; @@ -4958,20 +4402,20 @@ u16 sub_81B691C(struct Pokemon *mon, u8 effectType) { switch (effectType) { - case 13: - if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_SHEDINJA) - return GetMonData(mon, MON_DATA_HP_EV); - break; - case 12: - return GetMonData(mon, MON_DATA_ATK_EV); - case 17: - return GetMonData(mon, MON_DATA_DEF_EV); - case 16: - return GetMonData(mon, MON_DATA_SPEED_EV); - case 14: - return GetMonData(mon, MON_DATA_SPATK_EV); - case 15: - return GetMonData(mon, MON_DATA_SPDEF_EV); + case 13: + if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_SHEDINJA) + return GetMonData(mon, MON_DATA_HP_EV); + break; + case 12: + return GetMonData(mon, MON_DATA_ATK_EV); + case 17: + return GetMonData(mon, MON_DATA_DEF_EV); + case 16: + return GetMonData(mon, MON_DATA_SPEED_EV); + case 14: + return GetMonData(mon, MON_DATA_SPATK_EV); + case 15: + return GetMonData(mon, MON_DATA_SPDEF_EV); } return 0; } @@ -4980,24 +4424,24 @@ void option_menu_get_string(u8 effectType, u8 *dest) { switch (effectType) { - case 13: - StringCopy(dest, gText_HP3); - break; - case 12: - StringCopy(dest, gText_Attack3); - break; - case 17: - StringCopy(dest, gText_Defense3); - break; - case 16: - StringCopy(dest, gText_Speed2); - break; - case 14: - StringCopy(dest, gText_SpAtk3); - break; - case 15: - StringCopy(dest, gText_SpDef3); - break; + case 13: + StringCopy(dest, gText_HP3); + break; + case 12: + StringCopy(dest, gText_Attack3); + break; + case 17: + StringCopy(dest, gText_Defense3); + break; + case 16: + StringCopy(dest, gText_Speed2); + break; + case 14: + StringCopy(dest, gText_SpAtk3); + break; + case 15: + StringCopy(dest, gText_SpDef3); + break; } } @@ -5008,7 +4452,7 @@ void sub_81B6A10(u8 slot) u8 fontId = 1; u8 windowId = sub_81B31B0(3); u16 move; - + for (i = 0; i < MAX_MON_MOVES; i++) { move = GetMonData(&gPlayerParty[slot], MON_DATA_MOVE1 + i); @@ -5023,7 +4467,7 @@ void sub_81B6A10(u8 slot) void ether_effect_related_3(u8 taskId) { s8 input = Menu_ProcessInput(); - + if (input != MENU_NOTHING_CHOSEN) { if (input == MENU_B_PRESSED) @@ -5043,7 +4487,7 @@ void dp05_ether(u8 taskId, TaskFunc unused) { const u8 *effect; u16 item = gSpecialVar_ItemId; - + if (item == ITEM_ENIGMA_BERRY) effect = gSaveBlock1Ptr->enigmaBerry.itemEffect; else @@ -5084,7 +4528,7 @@ void ether_effect_related(u8 taskId) u16 item = gSpecialVar_ItemId; struct Struct203CEC8 *ptr = &gUnknown_0203CEC8; struct Pokemon *mon; - + if (ExecuteTableBasedItemEffect__(ptr->unk9, item, *moveslot)) { gUnknown_0203CEE8 = 0; @@ -5125,7 +4569,7 @@ u16 ItemIdToBattleMoveId(u16 item) bool8 sub_81B6D14(u16 move) { u8 i; - + for (i = 0; i < NUM_HIDDEN_MACHINES; i++) { if (gUnknown_08616040[i + NUM_TECHNICAL_MACHINES] == move) @@ -5137,7 +4581,7 @@ bool8 sub_81B6D14(u16 move) bool8 pokemon_has_move(struct Pokemon *mon, u16 move) { u8 i; - + for (i = 0; i < MAX_MON_MOVES; i++) { if (GetMonData(mon, MON_DATA_MOVE1 + i) == move) @@ -5166,7 +4610,7 @@ void sub_81B6DC4(u8 taskId, TaskFunc unused) struct Pokemon *mon; s16 *move; u16 item; - + PlaySE(SE_SELECT); mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; move = &gUnknown_0203CEC8.unkE; @@ -5177,12 +4621,12 @@ void sub_81B6DC4(u8 taskId, TaskFunc unused) move[1] = 0; switch (CanPartyPokemonLearnTMTutor(mon, item, 0)) { - case CANNOT_LEARN_MOVE: - sub_81B6D98(taskId, gText_PkmnCantLearnMove); - return; - case ALREADY_KNOWS_MOVE: - sub_81B6D98(taskId, gText_PkmnAlreadyKnows); - return; + case CANNOT_LEARN_MOVE: + sub_81B6D98(taskId, gText_PkmnCantLearnMove); + return; + case ALREADY_KNOWS_MOVE: + sub_81B6D98(taskId, gText_PkmnAlreadyKnows); + return; } if (GiveMoveToMon(mon, move[0]) != 0xFFFF) { @@ -5200,7 +4644,7 @@ void sub_81B6EB4(u8 taskId) struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; s16 *move = &gUnknown_0203CEC8.unkE; u16 item = gSpecialVar_ItemId; - + if (move[1] == 0) { AdjustFriendship(mon, 4); @@ -5231,7 +4675,7 @@ void sub_81B6F98(u8 taskId) if (gUnknown_0203CEC8.unk10 == 1) sub_81B77AC(taskId); else - { + { if (gUnknown_0203CEC8.unk10 == 2) gSpecialVar_Result = TRUE; sub_81B12C0(taskId); @@ -5252,15 +4696,15 @@ void sub_81B7028(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - sub_81B1B5C(gText_WhichMoveToForget, 1); - gTasks[taskId].func = sub_81B7088; - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - sub_81B7230(taskId); - break; + case 0: + sub_81B1B5C(gText_WhichMoveToForget, 1); + gTasks[taskId].func = sub_81B7088; + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + sub_81B7230(taskId); + break; } } @@ -5298,7 +4742,7 @@ void sub_81B7154(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 move = GetMonData(mon, MON_DATA_MOVE1 + sub_81C1B94()); - + GetMonNickname(mon, gStringVar1); StringCopy(gStringVar2, gMoveNames[move]); sub_81B6D74(gText_12PoofForgotMove); @@ -5309,7 +4753,7 @@ void sub_81B71D4(u8 taskId) { struct Pokemon *mon; u16 move; - + if (sub_81B1BD4() != TRUE) { mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; @@ -5341,33 +4785,33 @@ void sub_81B7294(u8 taskId) void sub_81B72C8(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; - + switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - GetMonNickname(mon, gStringVar1); - StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); - StringExpandPlaceholders(gStringVar4, gText_MoveNotLearned); - sub_81B1B5C(gStringVar4, 1); - if (gUnknown_0203CEC8.unk10 == 1) - { - gTasks[taskId].func = sub_81B73E4; - } - else - { - if (gUnknown_0203CEC8.unk10 == 2) - gSpecialVar_Result = FALSE; - gTasks[taskId].func = sub_81B6794; - } - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: - GetMonNickname(mon, gStringVar1); - StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); - sub_81B6D74(gText_PkmnNeedsToReplaceMove); - gTasks[taskId].func = sub_81B6FF4; - break; + case 0: + GetMonNickname(mon, gStringVar1); + StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); + StringExpandPlaceholders(gStringVar4, gText_MoveNotLearned); + sub_81B1B5C(gStringVar4, 1); + if (gUnknown_0203CEC8.unk10 == 1) + { + gTasks[taskId].func = sub_81B73E4; + } + else + { + if (gUnknown_0203CEC8.unk10 == 2) + gSpecialVar_Result = FALSE; + gTasks[taskId].func = sub_81B6794; + } + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + GetMonNickname(mon, gStringVar1); + StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); + sub_81B6D74(gText_PkmnNeedsToReplaceMove); + gTasks[taskId].func = sub_81B6FF4; + break; } } @@ -5384,7 +4828,7 @@ void dp05_rare_candy(u8 taskId, TaskFunc task) s16 *arrayPtr = ptr->data; u16 *itemPtr = &gSpecialVar_ItemId; bool8 cannotUseEffect; - + if (GetMonData(mon, MON_DATA_LEVEL) != MAX_LEVEL) { sub_81B79A0(mon, arrayPtr); @@ -5454,7 +4898,7 @@ void sub_81B7634(u8 taskId) void sub_81B767C(u8 taskId) { s16 *arrayPtr = gUnknown_0203CEC4->data; - + arrayPtr[12] = sub_81B3364(); sub_81D3640(arrayPtr[12], arrayPtr, &arrayPtr[6], 1, 2, 3); CopyWindowToVram(arrayPtr[12], 2); @@ -5464,7 +4908,7 @@ void sub_81B767C(u8 taskId) void sub_81B76C8(u8 taskIdUnused) { s16 *arrayPtr = gUnknown_0203CEC4->data; - + sub_81D3784(arrayPtr[12], &arrayPtr[6], 1, 2, 3); CopyWindowToVram(arrayPtr[12], 2); schedule_bg_copy_tilemap_to_vram(2); @@ -5473,7 +4917,7 @@ void sub_81B76C8(u8 taskIdUnused) void sub_81B7704(u8 taskId) { u16 result; - + if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) { sub_81B3394(); @@ -5481,28 +4925,6 @@ void sub_81B7704(u8 taskId) gUnknown_0203CEC8.unk10 = 1; switch (result) { - case 0: - sub_81B7810(taskId); - break; - case 0xFFFF: - sub_81B787C(taskId); - break; - case 0xFFFE: - gTasks[taskId].func = sub_81B77AC; - break; - default: - sub_81B7910(taskId, result); - break; - } - } -} - -void sub_81B77AC(u8 taskId) -{ - u16 result = MonTryLearningNewMove(&gPlayerParty[gUnknown_0203CEC8.unk9], 0); - - switch (result) - { case 0: sub_81B7810(taskId); break; @@ -5510,10 +4932,32 @@ void sub_81B77AC(u8 taskId) sub_81B787C(taskId); break; case 0xFFFE: - return; + gTasks[taskId].func = sub_81B77AC; + break; default: sub_81B7910(taskId, result); break; + } + } +} + +void sub_81B77AC(u8 taskId) +{ + u16 result = MonTryLearningNewMove(&gPlayerParty[gUnknown_0203CEC8.unk9], 0); + + switch (result) + { + case 0: + sub_81B7810(taskId); + break; + case 0xFFFF: + sub_81B787C(taskId); + break; + case 0xFFFE: + return; + default: + sub_81B7910(taskId, result); + break; } } @@ -5521,7 +4965,7 @@ void sub_81B7810(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 targetSpecies = GetEvolutionTargetSpecies(mon, 0, 0); - + if (targetSpecies != SPECIES_NONE) { FreePartyPointers(); @@ -5575,26 +5019,24 @@ void sub_81B79E8(u8 taskId, TaskFunc unused) sub_81B7A28(taskId); } -#ifdef NONMATCHING void sub_81B7A28(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 hp; - - if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) - { - hp = GetMonData(mon, MON_DATA_HP); - if (ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.unk9, gSpecialVar_ItemId, 0)) - { - gTasks[taskId].func = task_sacred_ash_party_loop; - return; - } - } - else + + if (GetMonData(mon, MON_DATA_SPECIES) == SPECIES_NONE) { gTasks[taskId].func = task_sacred_ash_party_loop; return; } + + hp = GetMonData(mon, MON_DATA_HP); + if (ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.unk9, gSpecialVar_ItemId, 0)) + { + gTasks[taskId].func = task_sacred_ash_party_loop; + return; + } + PlaySE(SE_KAIFUKU); party_menu_get_status_condition_and_update_object(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.unk9]); if (gSprites[gUnknown_0203CEDC[gUnknown_0203CEC8.unk9].unkC].invisible) @@ -5606,131 +5048,6 @@ void sub_81B7A28(u8 taskId) gUnknown_0203CEC4->data[0] = 1; gUnknown_0203CEC4->data[1] = 1; } -#else -NAKED -void sub_81B7A28(u8 taskId) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - sub sp, 0x4\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - mov r8, r4\n\ - ldr r6, =gUnknown_0203CEC8\n\ - movs r1, 0x9\n\ - ldrsb r1, [r6, r1]\n\ - movs r0, 0x64\n\ - muls r1, r0\n\ - ldr r0, =gPlayerParty\n\ - adds r5, r1, r0\n\ - adds r0, r5, 0\n\ - movs r1, 0xB\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _081B7A6E\n\ - adds r0, r5, 0\n\ - movs r1, 0x39\n\ - bl GetMonData\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - ldrb r0, [r6, 0x9]\n\ - ldr r1, =gSpecialVar_ItemId\n\ - ldrh r1, [r1]\n\ - movs r2, 0\n\ - bl ExecuteTableBasedItemEffect__\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - beq _081B7A94\n\ -_081B7A6E:\n\ - ldr r0, =gTasks\n\ - lsls r1, r4, 2\n\ - adds r1, r4\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - ldr r0, =task_sacred_ash_party_loop\n\ - str r0, [r1]\n\ - b _081B7B2A\n\ - .pool\n\ -_081B7A94:\n\ - movs r0, 0x1\n\ - bl PlaySE\n\ - ldr r4, =gUnknown_0203CEDC\n\ - movs r0, 0x9\n\ - ldrsb r0, [r6, r0]\n\ - lsls r0, 4\n\ - ldr r1, [r4]\n\ - adds r1, r0\n\ - adds r0, r5, 0\n\ - bl party_menu_get_status_condition_and_update_object\n\ - ldr r2, =gSprites\n\ - movs r0, 0x9\n\ - ldrsb r0, [r6, r0]\n\ - ldr r1, [r4]\n\ - lsls r0, 4\n\ - adds r3, r0, r1\n\ - ldrb r1, [r3, 0xC]\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r0, r2\n\ - adds r0, 0x3E\n\ - ldrb r0, [r0]\n\ - lsls r0, 29\n\ - cmp r0, 0\n\ - bge _081B7AD6\n\ - adds r0, r5, 0\n\ - adds r1, r3, 0\n\ - movs r2, 0x1\n\ - bl DisplayPartyPokemonLevelCheck\n\ -_081B7AD6:\n\ - ldr r4, =gUnknown_0203CEC4\n\ - ldr r0, [r4]\n\ - movs r1, 0x87\n\ - lsls r1, 2\n\ - adds r0, r1\n\ - ldrb r0, [r0]\n\ - movs r1, 0\n\ - bl sub_81B0FCC\n\ - ldrb r0, [r6, 0x9]\n\ - movs r1, 0x1\n\ - bl sub_81B0FCC\n\ - adds r0, r5, 0\n\ - movs r1, 0x39\n\ - bl GetMonData\n\ - adds r3, r0, 0\n\ - subs r3, r7\n\ - lsls r3, 16\n\ - asrs r3, 16\n\ - ldrb r1, [r6, 0x9]\n\ - ldr r0, =sub_81B7C10\n\ - str r0, [sp]\n\ - mov r0, r8\n\ - movs r2, 0x1\n\ - bl sub_81B1F18\n\ - mov r0, r8\n\ - movs r1, 0\n\ - adds r2, r7, 0\n\ - bl sub_81B1FA8\n\ - ldr r0, [r4]\n\ - movs r2, 0x86\n\ - lsls r2, 2\n\ - adds r1, r0, r2\n\ - movs r2, 0x1\n\ - strh r2, [r1]\n\ - ldr r1, =0x0000021a\n\ - adds r0, r1\n\ - strh r2, [r0]\n\ -_081B7B2A:\n\ - add sp, 0x4\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); -} -#endif void task_sacred_ash_party_loop(u8 taskId) { @@ -5945,7 +5262,7 @@ void sub_81B7E4C(u8 taskId) { struct Pokemon *mon; s16 *move; - + if (!gPaletteFade.active) { mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; @@ -5956,19 +5273,19 @@ void sub_81B7E4C(u8 taskId) move[1] = 2; switch (CanPartyPokemonLearnTMTutor(mon, 0, gSpecialVar_0x8005)) { - case CANNOT_LEARN_MOVE: - sub_81B6D98(taskId, gText_PkmnCantLearnMove); + case CANNOT_LEARN_MOVE: + sub_81B6D98(taskId, gText_PkmnCantLearnMove); + return; + case ALREADY_KNOWS_MOVE: + sub_81B6D98(taskId, gText_PkmnAlreadyKnows); + return; + default: + if (GiveMoveToMon(mon, gUnknown_0203CEC8.unkE) != 0xFFFF) + { + sub_81B6EB4(taskId); return; - case ALREADY_KNOWS_MOVE: - sub_81B6D98(taskId, gText_PkmnAlreadyKnows); - return; - default: - if (GiveMoveToMon(mon, gUnknown_0203CEC8.unkE) != 0xFFFF) - { - sub_81B6EB4(taskId); - return; - } - break; + } + break; } sub_81B6D74(gText_PkmnNeedsToReplaceMove); gTasks[taskId].func = sub_81B6FF4; @@ -6022,7 +5339,7 @@ void sub_81B8044(u8 taskId) void sub_81B8088(u8 taskId) { u16 item; - + if (!gPaletteFade.active) { item = gUnknown_0203CEC8.unkC; @@ -6036,7 +5353,7 @@ void sub_81B8088(u8 taskId) void sub_81B8104(u8 taskId) { s8 slot = gUnknown_0203CEC8.unk9; - + if (sub_81B1BD4() != TRUE) { sub_81B5C94(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]); @@ -6047,7 +5364,7 @@ void sub_81B8104(u8 taskId) void sub_81B814C(void) { u8 mail; - + sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], gUnknown_0203CEC8.unkC); mail = GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_MAIL); sub_811A20C(4, gSaveBlock1Ptr->mail[mail].words, sub_81B81A8, 3); @@ -6057,7 +5374,7 @@ void sub_81B81A8(void) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); - + if (gSpecialVar_Result == FALSE) { TakeMailFromMon(mon); @@ -6096,36 +5413,36 @@ void sub_81B82A0(u8 taskId) void sub_81B82D4(u8 taskId) { u16 item; - + switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - item = gUnknown_0203CEC8.unkC; - sub_81B83F0(item); - if (AddBagItem(gUnknown_0203CEFC, 1) == FALSE) - { - sub_81B841C(item); - pokemon_item_not_removed(gUnknown_0203CEFC); - sub_81B1B5C(gStringVar4, 0); - gTasks[taskId].func = sub_81B8104; - } - else if (ItemIsMail(item)) - { - gUnknown_0203CEC4->exitCallback = sub_81B814C; - sub_81B12C0(taskId); - } - else - { - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], item); - sub_81B1D68(item, gUnknown_0203CEFC, 1); - gTasks[taskId].func = sub_81B8104; - } - break; - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - case 1: + case 0: + item = gUnknown_0203CEC8.unkC; + sub_81B83F0(item); + if (AddBagItem(gUnknown_0203CEFC, 1) == FALSE) + { + sub_81B841C(item); + pokemon_item_not_removed(gUnknown_0203CEFC); + sub_81B1B5C(gStringVar4, 0); gTasks[taskId].func = sub_81B8104; - break; + } + else if (ItemIsMail(item)) + { + gUnknown_0203CEC4->exitCallback = sub_81B814C; + sub_81B12C0(taskId); + } + else + { + sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.unk9], item); + sub_81B1D68(item, gUnknown_0203CEFC, 1); + gTasks[taskId].func = sub_81B8104; + } + break; + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + case 1: + gTasks[taskId].func = sub_81B8104; + break; } } @@ -6161,7 +5478,7 @@ void sub_81B8474(u8 taskId) { struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.unk9]; struct MailStruct *mail; - + gUnknown_0203CEE8 = 0; mail = &gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]; if (GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE) @@ -6203,211 +5520,77 @@ bool8 GetBattleEntryEligibility(struct Pokemon *mon) { u16 i = 0; u16 species; - - if (GetMonData(mon, MON_DATA_IS_EGG) || GetMonData(mon, MON_DATA_LEVEL) > sub_81B8888() || - (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) && - gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) && - GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE)) + + if (GetMonData(mon, MON_DATA_IS_EGG) + || GetMonData(mon, MON_DATA_LEVEL) > sub_81B8888() + || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) + && GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE)) + { return FALSE; + } + switch (VarGet(VAR_FRONTIER_FACILITY)) // oddly the specific cases are beyond 6, turns out case 9 is apparently related to link battles { - case 9: - if (GetMonData(mon, MON_DATA_HP) != 0) - return TRUE; - return FALSE; - case 8: - return TRUE; - default: - species = GetMonData(mon, MON_DATA_SPECIES); - for (; gFrontierBannedSpecies[i] != 0xFFFF; i++) - { - if (gFrontierBannedSpecies[i] == species) - return FALSE; - } + case 9: + if (GetMonData(mon, MON_DATA_HP) != 0) return TRUE; + return FALSE; + case 8: + return TRUE; + default: + species = GetMonData(mon, MON_DATA_SPECIES); + for (; gFrontierBannedSpecies[i] != 0xFFFF; i++) + { + if (gFrontierBannedSpecies[i] == species) + return FALSE; + } + return TRUE; } } -#ifdef NONMATCHING u8 sub_81B865C(void) { - u8 unk = sub_81B885C(); u8 unk2; u8 i, j; - u16 species; - u16 item; - u8 facilityNum; - - if (gSelectedOrderFromParty[unk - 1] == 0) + u8 facility; + struct Pokemon *party = gPlayerParty; + u8 unk = sub_81B885C(); + u8 *order = gSelectedOrderFromParty; + + if (order[unk - 1] == 0) { if (unk == 1) return 14; ConvertIntToDecimalStringN(gStringVar1, unk, 0, 1); return 17; } - facilityNum = VarGet(VAR_FRONTIER_FACILITY); - if (facilityNum != 8 && facilityNum != 9) + + facility = VarGet(VAR_FRONTIER_FACILITY); + if (facility == 8 || facility == 9) + return 0xFF; + + unk2 = sub_81B8830(); + for (i = 0; i < unk2 - 1; i++) { - unk2 = sub_81B8830(); - for (i = 0; i < (unk2 - 1); i++) + u16 species = GetMonData(&party[order[i] - 1], MON_DATA_SPECIES); + u16 item = GetMonData(&party[order[i] - 1], MON_DATA_HELD_ITEM); + for (j = i + 1; j < unk2; j++) { - species = GetMonData(&gPlayerParty[gSelectedOrderFromParty[i - 1]], MON_DATA_SPECIES); - item = GetMonData(&gPlayerParty[gSelectedOrderFromParty[i - 1]], MON_DATA_HELD_ITEM); - for (j = i + 1; j < unk2; j++) - { - if (species == GetMonData(&gPlayerParty[gSelectedOrderFromParty[j - 1]], MON_DATA_SPECIES)) - return 18; - if (item != ITEM_NONE && item == GetMonData(&gPlayerParty[gSelectedOrderFromParty[j - 1]], MON_DATA_HELD_ITEM)) - return 19; - } + if (species == GetMonData(&party[order[j] - 1], MON_DATA_SPECIES)) + return 18; + if (item != ITEM_NONE && item == GetMonData(&party[order[j] - 1], MON_DATA_HELD_ITEM)) + return 19; } } + return 0xFF; } -#else -NAKED -u8 sub_81B865C(void) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - bl sub_81B885C\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - adds r1, r2, 0\n\ - ldr r3, =gSelectedOrderFromParty\n\ - adds r0, r2, r3\n\ - subs r0, 0x1\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - bne _081B869C\n\ - cmp r2, 0x1\n\ - bne _081B8688\n\ - movs r0, 0xE\n\ - b _081B8758\n\ - .pool\n\ -_081B8688:\n\ - ldr r0, =gStringVar1\n\ - movs r2, 0\n\ - movs r3, 0x1\n\ - bl ConvertIntToDecimalStringN\n\ - movs r0, 0x11\n\ - b _081B8758\n\ - .pool\n\ -_081B869C:\n\ - ldr r0, =0x000040cf\n\ - bl VarGet\n\ - lsls r0, 24\n\ - movs r1, 0xF8\n\ - lsls r1, 24\n\ - adds r0, r1\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - bhi _081B86C0\n\ - b _081B8756\n\ - .pool\n\ -_081B86B8:\n\ - movs r0, 0x12\n\ - b _081B8758\n\ -_081B86BC:\n\ - movs r0, 0x13\n\ - b _081B8758\n\ -_081B86C0:\n\ - bl sub_81B8830\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - movs r5, 0\n\ - b _081B8750\n\ -_081B86CE:\n\ - ldr r3, =gSelectedOrderFromParty\n\ - adds r4, r3, r5\n\ - ldrb r0, [r4]\n\ - movs r1, 0x64\n\ - muls r0, r1\n\ - subs r0, 0x64\n\ - ldr r3, =gPlayerParty\n\ - adds r0, r3, r0\n\ - movs r1, 0xB\n\ - bl GetMonData\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r10, r0\n\ - ldrb r0, [r4]\n\ - movs r1, 0x64\n\ - muls r0, r1\n\ - subs r0, 0x64\n\ - ldr r3, =gPlayerParty\n\ - adds r0, r3, r0\n\ - movs r1, 0xC\n\ - bl GetMonData\n\ - lsls r0, 16\n\ - lsrs r6, r0, 16\n\ - adds r1, r5, 0x1\n\ - lsls r0, r1, 24\n\ - lsrs r4, r0, 24\n\ - mov r9, r1\n\ - cmp r4, r8\n\ - bcs _081B8748\n\ - movs r7, 0x64\n\ -_081B870E:\n\ - ldr r0, =gSelectedOrderFromParty\n\ - adds r5, r0, r4\n\ - ldrb r0, [r5]\n\ - muls r0, r7\n\ - subs r0, 0x64\n\ - ldr r1, =gPlayerParty\n\ - adds r0, r1, r0\n\ - movs r1, 0xB\n\ - bl GetMonData\n\ - cmp r10, r0\n\ - beq _081B86B8\n\ - cmp r6, 0\n\ - beq _081B873E\n\ - ldrb r0, [r5]\n\ - muls r0, r7\n\ - subs r0, 0x64\n\ - ldr r3, =gPlayerParty\n\ - adds r0, r3, r0\n\ - movs r1, 0xC\n\ - bl GetMonData\n\ - cmp r6, r0\n\ - beq _081B86BC\n\ -_081B873E:\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, r8\n\ - bcc _081B870E\n\ -_081B8748:\n\ - mov r1, r9\n\ - lsls r0, r1, 24\n\ - lsrs r5, r0, 24\n\ - mov r0, r8\n\ -_081B8750:\n\ - subs r0, 0x1\n\ - cmp r5, r0\n\ - blt _081B86CE\n\ -_081B8756:\n\ - movs r0, 0xFF\n\ -_081B8758:\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .pool\n"); -} -#endif bool8 sub_81B8770(u8 slot) { u8 i; - + for (i = 0; i < 4; i++) { if (gSelectedOrderFromParty[i] == slot) @@ -6419,7 +5602,7 @@ bool8 sub_81B8770(u8 slot) void sub_81B879C(u8 taskId) { u8 msgID = sub_81B865C(); - + if (msgID != 0xFF) { PlaySE(SE_HAZURE); @@ -6447,12 +5630,12 @@ u8 sub_81B8830(void) { switch (VarGet(VAR_FRONTIER_FACILITY)) { - case 9: - return 3; - case 8: - return 2; - default: - return gSpecialVar_0x8005; + case 9: + return 3; + case 8: + return 2; + default: + return gSpecialVar_0x8005; } } @@ -6460,12 +5643,12 @@ u8 sub_81B885C(void) { switch (VarGet(VAR_FRONTIER_FACILITY)) { - case 9: - return 1; - case 8: - return 2; - default: - return gSpecialVar_0x8005; + case 9: + return 1; + case 8: + return 2; + default: + return gSpecialVar_0x8005; } } @@ -6473,21 +5656,21 @@ u8 sub_81B8888(void) { switch (VarGet(VAR_FRONTIER_FACILITY)) { - case 9: - return 100; - case 8: - return 30; - default: - if (gSpecialVar_0x8004 == 0) - return 50; - return 100; + case 9: + return 100; + case 8: + return 30; + default: + if (gSpecialVar_0x8004 == 0) + return 50; + return 100; } } const u8* sub_81B88BC(void) { u8 facilityNum = VarGet(VAR_FRONTIER_FACILITY); - + if (!(facilityNum != 8 && facilityNum != 9)) return gText_CancelBattle; if (facilityNum == FRONTIER_FACILITY_DOME && gSpecialVar_0x8005 == 2) @@ -6551,7 +5734,7 @@ bool8 sub_81B8A7C(void) u8 newSlot; u8 i; u8 neededToMatch; - + if (IsMultiBattle() == TRUE && (slot == 1 || slot == 4 || slot == 5)) { StringCopy(gStringVar1, GetTrainerPartnerName()); @@ -6613,7 +5796,7 @@ void sub_81B8C88(u8 *ptr, bool8 multiplayerFlag) { u8 partyIndexes[6]; int i, j; - + if (IsMultiBattle() == TRUE) { if (multiplayerFlag) @@ -6672,7 +5855,7 @@ void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerPosition) int i, j; u8 leftBattler; u8 rightBattler; - + if (GetBattlerSide(battlerPosition) == B_SIDE_PLAYER) { leftBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); @@ -6737,7 +5920,7 @@ void sub_81B8E80(u8 battlerPosition, u8 unk, u8 arrayIndex) int i, j; u8 *battleStructRelated; u8 possiblePartyIndexBuffer; - + if (IsMultiBattle()) { battleStructRelated = gBattleStruct->field_60[battlerPosition]; @@ -6771,7 +5954,7 @@ u8 sub_81B8F38(u8 slot) { u8 modResult = slot & 1; u8 retVal; - + slot /= 2; if (modResult != 0) retVal = gUnknown_0203CF00[slot] & 0xF; @@ -6783,7 +5966,7 @@ u8 sub_81B8F38(u8 slot) void sub_81B8F6C(u8 slot, u8 setVal) { bool32 modResult = slot & 1; - + slot /= 2; if (modResult != 0) gUnknown_0203CF00[slot] = (gUnknown_0203CF00[slot] & 0xF0) | setVal; @@ -6801,7 +5984,7 @@ void sub_81B8FB0(u8 slot, u8 slot2) u8 pokemon_order_func(u8 slot) { u8 i, j; - + for (j = i = 0; i < 3; j++, i++) { if ((gUnknown_0203CF00[i] >> 4) != slot) @@ -6822,7 +6005,7 @@ void pokemon_change_order(void) { struct Pokemon *partyBuffer = Alloc(sizeof(gPlayerParty)); u8 i; - + memcpy(partyBuffer, gPlayerParty, sizeof(gPlayerParty)); for (i = 0; i < PARTY_SIZE; i++) memcpy(&gPlayerParty[pokemon_order_func(i)], &partyBuffer[i], sizeof(struct Pokemon)); @@ -6833,7 +6016,7 @@ void sub_81B9080(void) { struct Pokemon *partyBuffer = Alloc(sizeof(gPlayerParty)); u8 i; - + memcpy(partyBuffer, gPlayerParty, sizeof(gPlayerParty)); for (i = 0; i < PARTY_SIZE; i++) memcpy(&gPlayerParty[sub_81B8F38(i)], &partyBuffer[i], sizeof(struct Pokemon)); @@ -6845,7 +6028,7 @@ void sub_81B90D0(void) u8 i; struct Pokemon *mon; u8 leadVal; - + for (i = 1; i < PARTY_SIZE; i++) { mon = &gPlayerParty[sub_81B8F38(i)]; @@ -6881,7 +6064,7 @@ void sub_81B91B4(u8 taskId) { s16 *data = gTasks[taskId].data; u8 i; - + if (!gPaletteFade.active) { data[0] -= 8; @@ -6902,7 +6085,7 @@ void sub_81B91B4(u8 taskId) void sub_81B9240(u8 taskId) { s16 *data = gTasks[taskId].data; - + if (++data[0] == 0x100) sub_81B12C0(taskId); } @@ -6917,7 +6100,7 @@ void sub_81B9294(u8 taskId) { s16 *data = gTasks[taskId].data; u8 i; - + for (i = 3; i < PARTY_SIZE; i++) { if (gUnknown_02022FF8[i - 3].species != SPECIES_NONE) @@ -7043,7 +6226,7 @@ void sub_81B9588(void) void sub_81B95E0(void) { u8 i; - + gSpecialVar_Result = FALSE; for (i = 0; i < 3; i++) { @@ -7081,7 +6264,7 @@ void sub_81B968C(void) void sub_81B96D0(void) { u8 i; - + gSpecialVar_Result = 0; for (i = 0; i < MAX_MON_MOVES; i++) { @@ -7094,7 +6277,7 @@ void sub_81B9718(void) { struct Pokemon *mon = &gPlayerParty[gSpecialVar_0x8004]; u16 move = GetMonData(mon, MON_DATA_MOVE1 + gSpecialVar_0x8005); - + GetMonNickname(mon, gStringVar1); StringCopy(gStringVar2, gMoveNames[move]); } @@ -7102,7 +6285,7 @@ void sub_81B9718(void) void sub_81B9770(void) { u16 i; - + SetMonMoveSlot(&gPlayerParty[gSpecialVar_0x8004], MOVE_NONE, gSpecialVar_0x8005); RemoveMonPPBonus(&gPlayerParty[gSpecialVar_0x8004], gSpecialVar_0x8005); for (i = gSpecialVar_0x8005; i < MAX_MON_MOVES - 1; i++) @@ -7142,7 +6325,7 @@ void sub_81B9918(void) { u16 move; u32 i, j; - + gSpecialVar_Result = FALSE; move = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_MOVE1 + gSpecialVar_0x8005); if (move == MOVE_SURF) From 8fcb3f71c72c6545c0de987b2c0846eef5cd1dfb Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 22 Dec 2018 18:52:05 +0100 Subject: [PATCH 2/3] Match electric c --- src/electric.c | 241 ++++--------------------------------------------- 1 file changed, 20 insertions(+), 221 deletions(-) diff --git a/src/electric.c b/src/electric.c index ed495fa59..1b3dae90e 100644 --- a/src/electric.c +++ b/src/electric.c @@ -462,7 +462,7 @@ static void sub_810A1A8(struct Sprite *sprite) sprite->pos1.x -= gBattleAnimArgs[0]; else sprite->pos1.x += gBattleAnimArgs[0]; - + sprite->pos1.y += gBattleAnimArgs[1]; sprite->callback = sub_810A1F8; } @@ -479,7 +479,7 @@ static void sub_810A214(struct Sprite *sprite) sprite->pos1.x -= gBattleAnimArgs[0]; else sprite->pos1.x += gBattleAnimArgs[0]; - + sprite->callback = sub_810A258; } @@ -493,7 +493,7 @@ static void sub_810A274(struct Sprite *sprite) { sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); - + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) { sprite->pos1.x -= gBattleAnimArgs[0]; @@ -615,7 +615,7 @@ static void sub_810A5BC(struct Sprite *sprite) { if (IsContest() || GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) gBattleAnimArgs[1] = -gBattleAnimArgs[1]; - + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[1]; sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[2]; sprite->data[3] = gBattleAnimArgs[0]; @@ -686,17 +686,16 @@ void sub_810A7DC(u8 taskId) gTasks[taskId].func = sub_810A834; } -#ifdef NONMATCHING // couldn't get the proper tail merging in the "CreateSprite" switch cases.(ported from ruby) static void sub_810A834(u8 taskId) { u16 r8; + u16 r2; s16 r12; - s16 r2; u8 spriteId = 0; u8 r7 = 0; u8 sp = gTasks[taskId].data[2]; - s16 r4 = gTasks[taskId].data[0]; - s16 r6 = gTasks[taskId].data[1]; + s16 x = gTasks[taskId].data[0]; + s16 y = gTasks[taskId].data[1]; if (!gTasks[taskId].data[2]) { @@ -714,27 +713,31 @@ static void sub_810A834(u8 taskId) switch (gTasks[taskId].data[10]) { case 0: - r8 += r2 * 0; - spriteId = CreateSprite(&gUnknown_08595828, r4, r6 + (r12 * 1), 2); + r12 *= 1; + spriteId = CreateSprite(&gUnknown_08595828, x, y + r12, 2); r7++; break; case 2: + r12 *= 2; r8 += r2; - spriteId = CreateSprite(&gUnknown_08595828, r4, r6 + (r12 * 2), 2); + spriteId = CreateSprite(&gUnknown_08595828, x, y + r12, 2); r7++; break; case 4: + r12 *= 3; r8 += r2 * 2; - spriteId = CreateSprite(&gUnknown_08595828, r4, r6 + (r12 * 3), 2); + spriteId = CreateSprite(&gUnknown_08595828, x, y + r12, 2); r7++; break; case 6: + r12 *= 4; r8 += r2 * 3; - spriteId = CreateSprite(&gUnknown_08595828, r4, r6 + (r12 * 4), 2); + spriteId = CreateSprite(&gUnknown_08595828, x, y + r12, 2); r7++; break; case 8: - spriteId = CreateSprite(&gUnknown_08595828, r4, r6 + (r12 * 5), 2); + r12 *= 5; + spriteId = CreateSprite(&gUnknown_08595828, x, y + r12, 2); r7++; break; case 10: @@ -751,211 +754,6 @@ static void sub_810A834(u8 taskId) gTasks[taskId].data[10]++; } -#else -NAKED -static void sub_810A834(u8 taskId) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x4\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r9, r0\n\ - movs r5, 0\n\ - movs r7, 0\n\ - ldr r1, =gTasks\n\ - lsls r0, 2\n\ - add r0, r9\n\ - lsls r0, 3\n\ - adds r0, r1\n\ - ldrb r2, [r0, 0xC]\n\ - str r2, [sp]\n\ - ldrh r4, [r0, 0x8]\n\ - ldrh r6, [r0, 0xA]\n\ - movs r3, 0xC\n\ - ldrsh r0, [r0, r3]\n\ - mov r10, r1\n\ - cmp r0, 0\n\ - bne _0810A878\n\ - movs r0, 0\n\ - mov r8, r0\n\ - movs r2, 0x1\n\ - movs r1, 0x10\n\ - mov r12, r1\n\ - b _0810A882\n\ - .pool\n\ -_0810A878:\n\ - movs r2, 0x10\n\ - mov r12, r2\n\ - movs r3, 0x8\n\ - mov r8, r3\n\ - movs r2, 0x4\n\ -_0810A882:\n\ - mov r0, r9\n\ - lsls r1, r0, 2\n\ - adds r0, r1, r0\n\ - lsls r0, 3\n\ - add r0, r10\n\ - movs r3, 0x1C\n\ - ldrsh r0, [r0, r3]\n\ - mov r10, r1\n\ - cmp r0, 0xA\n\ - bhi _0810A978\n\ - lsls r0, 2\n\ - ldr r1, =_0810A8A4\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_0810A8A4:\n\ - .4byte _0810A8D0\n\ - .4byte _0810A978\n\ - .4byte _0810A8E4\n\ - .4byte _0810A978\n\ - .4byte _0810A904\n\ - .4byte _0810A978\n\ - .4byte _0810A91A\n\ - .4byte _0810A978\n\ - .4byte _0810A93C\n\ - .4byte _0810A978\n\ - .4byte _0810A970\n\ -_0810A8D0:\n\ - ldr r0, =gUnknown_08595828\n\ - lsls r1, r4, 16\n\ - asrs r1, 16\n\ - lsls r2, r6, 16\n\ - asrs r2, 16\n\ - mov r4, r12\n\ - lsls r3, r4, 16\n\ - b _0810A952\n\ - .pool\n\ -_0810A8E4:\n\ - mov r0, r12\n\ - lsls r3, r0, 17\n\ - mov r1, r8\n\ - adds r0, r1, r2\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r8, r0\n\ - ldr r0, =gUnknown_08595828\n\ - lsls r1, r4, 16\n\ - asrs r1, 16\n\ - lsls r2, r6, 16\n\ - asrs r2, 16\n\ - b _0810A952\n\ - .pool\n\ -_0810A904:\n\ - mov r3, r12\n\ - lsls r0, r3, 16\n\ - asrs r0, 16\n\ - lsls r3, r0, 1\n\ - adds r3, r0\n\ - lsls r0, r2, 1\n\ - add r0, r8\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r8, r0\n\ - b _0810A946\n\ -_0810A91A:\n\ - mov r0, r12\n\ - lsls r3, r0, 18\n\ - lsls r0, r2, 1\n\ - adds r0, r2\n\ - add r0, r8\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - mov r8, r0\n\ - ldr r0, =gUnknown_08595828\n\ - lsls r1, r4, 16\n\ - asrs r1, 16\n\ - lsls r2, r6, 16\n\ - asrs r2, 16\n\ - b _0810A952\n\ - .pool\n\ -_0810A93C:\n\ - mov r1, r12\n\ - lsls r0, r1, 16\n\ - asrs r0, 16\n\ - lsls r3, r0, 2\n\ - adds r3, r0\n\ -_0810A946:\n\ - ldr r0, =gUnknown_08595828\n\ - lsls r1, r4, 16\n\ - asrs r1, 16\n\ - lsls r2, r6, 16\n\ - asrs r2, 16\n\ - lsls r3, 16\n\ -_0810A952:\n\ - asrs r3, 16\n\ - adds r2, r3\n\ - lsls r2, 16\n\ - asrs r2, 16\n\ - movs r3, 0x2\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - adds r0, r7, 0x1\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - b _0810A978\n\ - .pool\n\ -_0810A970:\n\ - mov r0, r9\n\ - bl DestroyAnimVisualTask\n\ - b _0810A9BC\n\ -_0810A978:\n\ - cmp r7, 0\n\ - beq _0810A9AC\n\ - ldr r4, =gSprites\n\ - lsls r3, r5, 4\n\ - adds r3, r5\n\ - lsls r3, 2\n\ - adds r0, r3, r4\n\ - ldrh r5, [r0, 0x4]\n\ - lsls r2, r5, 22\n\ - lsrs r2, 22\n\ - add r2, r8\n\ - ldr r6, =0x000003ff\n\ - adds r1, r6, 0\n\ - ands r2, r1\n\ - ldr r1, =0xfffffc00\n\ - ands r1, r5\n\ - orrs r1, r2\n\ - strh r1, [r0, 0x4]\n\ - mov r1, sp\n\ - ldrh r1, [r1]\n\ - strh r1, [r0, 0x2E]\n\ - adds r4, 0x1C\n\ - adds r3, r4\n\ - ldr r1, [r3]\n\ - bl _call_via_r1\n\ -_0810A9AC:\n\ - ldr r0, =gTasks\n\ - mov r1, r10\n\ - add r1, r9\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - ldrh r0, [r1, 0x1C]\n\ - adds r0, 0x1\n\ - strh r0, [r1, 0x1C]\n\ -_0810A9BC:\n\ - add sp, 0x4\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - "); -} -#endif static void sub_810A9DC(struct Sprite *sprite) { @@ -1002,7 +800,7 @@ void sub_810AAFC(u8 taskId) { struct Task *task = &gTasks[taskId]; - if (!gBattleAnimArgs[0]) + if (!gBattleAnimArgs[0]) { task->data[14] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); task->data[15] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); @@ -1188,7 +986,7 @@ void sub_810AE5C(u8 taskId) } else task->data[0]++; - + } break; case 2: @@ -1334,6 +1132,7 @@ static void sub_810B23C(struct Sprite *sprite) case 1: if (sprite->affineAnimEnded) DestroySpriteAndMatrix(sprite); + break; } } From 6dffa6d17c35fe13f5878bd7bbf8a3fe1054c20c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 22 Dec 2018 19:33:45 +0100 Subject: [PATCH 3/3] Match and clean up fldeff misc --- include/event_object_movement.h | 2 + include/event_scripts.h | 5 + include/fldeff_misc.h | 41 ++- src/fldeff_misc.c | 456 +++++++++----------------------- 4 files changed, 153 insertions(+), 351 deletions(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index cc45f1531..4d0c21f98 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -59,6 +59,8 @@ struct LockedAnimEventObjects }; extern const struct SpriteFrameImage gEventObjectPicTable_PechaBerryTree[]; +extern const struct OamData gEventObjectBaseOam_32x8; +extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; extern const u8 gReflectionEffectPaletteMap[]; void ResetEventObjects(void); diff --git a/include/event_scripts.h b/include/event_scripts.h index 2661494d3..3dcb7f929 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -579,4 +579,9 @@ extern const u8 BattleFrontier_BattlePyramidEmptySquare_EventScript_252C88[]; extern const u8 BattleFrontier_BattlePyramidEmptySquare_EventScript_252C4F[]; extern const u8 BattleFrontier_BattlePyramidEmptySquare_EventScript_252C6A[]; +// fldeff misc +extern const u8 EventScript_275A86[]; +extern const u8 EventScript_275ADF[]; +extern const u8 EventScript_275B38[]; + #endif // GUARD_EVENT_SCRIPTS_H diff --git a/include/fldeff_misc.h b/include/fldeff_misc.h index 954ecbb5c..fc2f1b3e3 100644 --- a/include/fldeff_misc.h +++ b/include/fldeff_misc.h @@ -1,24 +1,37 @@ #ifndef GUARD_FLDEFF_MISC_H #define GUARD_FLDEFF_MISC_H -void PopSecretBaseBalloon(s16 id, s16 x, s16 y); +void sub_80F9BCC(u16 a0, u16 a1, u8 a2); +void sub_80F9BF4(u16 a0, u16 a1, u8 a2); +bool8 sub_80F9C1C(void); +bool8 sub_80F9C30(void); +bool8 SetUpFieldMove_SecretPower(void); +bool8 FldEff_UseSecretPowerCave(void); +bool8 FldEff_SecretPowerCave(void); +bool8 FldEff_UseSecretPowerTree(void); +bool8 FldEff_SecretPowerTree(void); +bool8 FldEff_UseSecretPowerShrub(void); +bool8 FldEff_SecretPowerShrub(void); +bool8 FldEff_SecretBasePCTurnOn(void); +void DoSecretBasePCTurnOffEffect(void); +void PopSecretBaseBalloon(s16 metatileId, s16 x, s16 y); +bool8 FldEff_NopA6FC(void); +bool8 FldEff_NopA700(void); void ShatterSecretBaseBreakableDoor(s16 x, s16 y); -u8 CreateRecordMixingSprite(void); -void DestroyRecordMixingSprite(void); -void FldEffPoison_Start(void); void PlaySecretBaseMusicNoteMatSound(s16 metatileId); void DoSecretBaseGlitterMatSparkle(void); -bool8 sub_80FADE4(u16, u8); - -extern struct MapPosition gPlayerFacingPosition; -extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; - -extern u8 EventScript_275A86[]; -extern u8 EventScript_275ADF[]; -extern u8 EventScript_275B38[]; - -extern const struct OamData gEventObjectBaseOam_32x8; +bool8 FldEff_SandPillar(void); +void GetShieldToyTVDecorationInfo(void); +bool8 sub_80FADE4(u16 arg0, u8 arg1); +void FldEffPoison_Start(void); +bool32 FldEffPoison_IsActive(void); +void DoWateringBerryTreeAnim(void); +u8 CreateRecordMixingSprite(void); +void DestroyRecordMixingSprite(void); +const struct SpritePalette gFieldEffectObjectPaletteInfo7; +const struct SpritePalette gFieldEffectObjectPaletteInfo8; +const struct SpritePalette gFieldEffectObjectPaletteInfo9; extern const u16 gTilesetPalettes_SecretBase[][16]; #endif //GUARD_FLDEFF_MISC_H diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c index 79f0a8ede..d9fe38197 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -11,8 +11,10 @@ #include "field_effect.h" #include "field_camera.h" #include "field_player_avatar.h" +#include "fldeff_misc.h" #include "secret_base.h" #include "event_data.h" +#include "event_scripts.h" #include "event_object_movement.h" #include "metatile_behavior.h" #include "string_util.h" @@ -20,70 +22,71 @@ #include "constants/metatile_behaviors.h" #include "constants/songs.h" #include "constants/vars.h" -#include "fldeff_misc.h" -void sub_80F9C90(u8); -void sub_80F9DFC(u8); +extern struct MapPosition gPlayerFacingPosition; -void Task_SecretBasePCTurnOn(u8); +static void sub_80F9C90(u8); +static void sub_80F9DFC(u8); -void Task_PopSecretBaseBalloon(u8); -void DoBalloonSoundEffect(s16); +static void Task_SecretBasePCTurnOn(u8); -void Task_WateringBerryTreeAnim_1(u8); -void Task_WateringBerryTreeAnim_2(u8); -void Task_WateringBerryTreeAnim_3(u8); +static void Task_PopSecretBaseBalloon(u8); +static void DoBalloonSoundEffect(s16); -void sub_80F9C44(TaskFunc, u16, u16, u8); +static void Task_WateringBerryTreeAnim_1(u8); +static void Task_WateringBerryTreeAnim_2(u8); +static void Task_WateringBerryTreeAnim_3(u8); -void FieldCallback_SecretBaseCave(void); +static void sub_80F9C44(TaskFunc, u16, u16, u8); + +static void FieldCallback_SecretBaseCave(void); static void CaveEntranceSpriteCallback1(struct Sprite *); static void CaveEntranceSpriteCallback2(struct Sprite *); static void CaveEntranceSpriteCallbackEnd(struct Sprite *); static void StartSecretBaseCaveFieldEffect(void); -void FieldCallback_SecretBaseTree(void); +static void FieldCallback_SecretBaseTree(void); static void TreeEntranceSpriteCallback1(struct Sprite *); static void TreeEntranceSpriteCallback2(struct Sprite *); static void TreeEntranceSpriteCallbackEnd(struct Sprite *); static void StartSecretBaseTreeFieldEffect(void); -void FieldCallback_SecretBaseShrub(void); +static void FieldCallback_SecretBaseShrub(void); static void ShrubEntranceSpriteCallback1(struct Sprite *); static void ShrubEntranceSpriteCallback2(struct Sprite *); static void ShrubEntranceSpriteCallbackEnd(struct Sprite *); static void StartSecretBaseShrubFieldEffect(void); -void SpriteCB_SandPillar_0(struct Sprite *); -void SpriteCB_SandPillar_1(struct Sprite *); -void SpriteCB_SandPillar_2(struct Sprite *); +static void SpriteCB_SandPillar_0(struct Sprite *); +static void SpriteCB_SandPillar_1(struct Sprite *); +static void SpriteCB_SandPillar_2(struct Sprite *); -const u8 gSpriteImage_858D978[] = INCBIN_U8("graphics/unknown/858E588/0.4bpp"); -const u8 gSpriteImage_858D9F8[] = INCBIN_U8("graphics/unknown/858E588/1.4bpp"); -const u8 gSpriteImage_858DA78[] = INCBIN_U8("graphics/unknown/858E588/2.4bpp"); -const u8 gSpriteImage_858DAF8[] = INCBIN_U8("graphics/unknown/858E588/3.4bpp"); -const u8 gSpriteImage_858DB78[] = INCBIN_U8("graphics/unknown/858E588/4.4bpp"); +static const u8 gSpriteImage_858D978[] = INCBIN_U8("graphics/unknown/858E588/0.4bpp"); +static const u8 gSpriteImage_858D9F8[] = INCBIN_U8("graphics/unknown/858E588/1.4bpp"); +static const u8 gSpriteImage_858DA78[] = INCBIN_U8("graphics/unknown/858E588/2.4bpp"); +static const u8 gSpriteImage_858DAF8[] = INCBIN_U8("graphics/unknown/858E588/3.4bpp"); +static const u8 gSpriteImage_858DB78[] = INCBIN_U8("graphics/unknown/858E588/4.4bpp"); -const u8 gUnusedEmptySpace_858DBF8[32] = {0}; +static const u8 gUnusedEmptySpace_858DBF8[32] = {0}; -const u16 gFieldEffectObjectPalette7[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_07.gbapal"); -const u8 gSpriteImage_858DC38[] = INCBIN_U8("graphics/unknown/858E5D8/0.4bpp"); -const u8 gSpriteImage_858DCB8[] = INCBIN_U8("graphics/unknown/858E5D8/1.4bpp"); -const u8 gSpriteImage_858DD38[] = INCBIN_U8("graphics/unknown/858E5D8/2.4bpp"); -const u8 gSpriteImage_858DDB8[] = INCBIN_U8("graphics/unknown/858E5D8/3.4bpp"); -const u8 gSpriteImage_858DE38[] = INCBIN_U8("graphics/unknown/858E5D8/4.4bpp"); -const u8 gSpriteImage_858DEB8[] = INCBIN_U8("graphics/unknown/858E5B0/0.4bpp"); -const u8 gSpriteImage_858DF38[] = INCBIN_U8("graphics/unknown/858E5B0/1.4bpp"); -const u8 gSpriteImage_858DFB8[] = INCBIN_U8("graphics/unknown/858E5B0/2.4bpp"); -const u8 gSpriteImage_858E038[] = INCBIN_U8("graphics/unknown/858E5B0/3.4bpp"); -const u8 gSpriteImage_858E0B8[] = INCBIN_U8("graphics/unknown/858E5B0/4.4bpp"); -const u8 gSpriteImage_858E138[] = INCBIN_U8("graphics/unknown/858E5B0/5.4bpp"); -const u16 gFieldEffectObjectPalette8[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_08.gbapal"); -const u8 gSpriteImage_858E1D8[] = INCBIN_U8("graphics/unknown/858E674/0.4bpp"); -const u8 gSpriteImage_858E2D8[] = INCBIN_U8("graphics/unknown/858E674/1.4bpp"); -const u8 gSpriteImage_858E3D8[] = INCBIN_U8("graphics/unknown/858E674/2.4bpp"); +static const u16 gFieldEffectObjectPalette7[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_07.gbapal"); +static const u8 gSpriteImage_858DC38[] = INCBIN_U8("graphics/unknown/858E5D8/0.4bpp"); +static const u8 gSpriteImage_858DCB8[] = INCBIN_U8("graphics/unknown/858E5D8/1.4bpp"); +static const u8 gSpriteImage_858DD38[] = INCBIN_U8("graphics/unknown/858E5D8/2.4bpp"); +static const u8 gSpriteImage_858DDB8[] = INCBIN_U8("graphics/unknown/858E5D8/3.4bpp"); +static const u8 gSpriteImage_858DE38[] = INCBIN_U8("graphics/unknown/858E5D8/4.4bpp"); +static const u8 gSpriteImage_858DEB8[] = INCBIN_U8("graphics/unknown/858E5B0/0.4bpp"); +static const u8 gSpriteImage_858DF38[] = INCBIN_U8("graphics/unknown/858E5B0/1.4bpp"); +static const u8 gSpriteImage_858DFB8[] = INCBIN_U8("graphics/unknown/858E5B0/2.4bpp"); +static const u8 gSpriteImage_858E038[] = INCBIN_U8("graphics/unknown/858E5B0/3.4bpp"); +static const u8 gSpriteImage_858E0B8[] = INCBIN_U8("graphics/unknown/858E5B0/4.4bpp"); +static const u8 gSpriteImage_858E138[] = INCBIN_U8("graphics/unknown/858E5B0/5.4bpp"); +static const u16 gFieldEffectObjectPalette8[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_08.gbapal"); +static const u8 gSpriteImage_858E1D8[] = INCBIN_U8("graphics/unknown/858E674/0.4bpp"); +static const u8 gSpriteImage_858E2D8[] = INCBIN_U8("graphics/unknown/858E674/1.4bpp"); +static const u8 gSpriteImage_858E3D8[] = INCBIN_U8("graphics/unknown/858E674/2.4bpp"); -const struct OamData gOamData_858E4D8 = +static const struct OamData gOamData_858E4D8 = { .y = 0, .x = 0, @@ -95,7 +98,7 @@ const struct OamData gOamData_858E4D8 = .priority = 2, }; -const union AnimCmd gSpriteAnim_858E4E0[] = +static const union AnimCmd gSpriteAnim_858E4E0[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(1, 8), @@ -105,7 +108,7 @@ const union AnimCmd gSpriteAnim_858E4E0[] = ANIMCMD_END, }; -const union AnimCmd gSpriteAnim_858E4F8[] = +static const union AnimCmd gSpriteAnim_858E4F8[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(1, 8), @@ -115,7 +118,7 @@ const union AnimCmd gSpriteAnim_858E4F8[] = ANIMCMD_END, }; -const union AnimCmd gSpriteAnim_858E510[] = +static const union AnimCmd gSpriteAnim_858E510[] = { ANIMCMD_FRAME(4, 8), ANIMCMD_FRAME(3, 8), @@ -125,7 +128,7 @@ const union AnimCmd gSpriteAnim_858E510[] = ANIMCMD_END, }; -const union AnimCmd gSpriteAnim_858E528[] = +static const union AnimCmd gSpriteAnim_858E528[] = { ANIMCMD_FRAME(0, 8, .hFlip = TRUE), ANIMCMD_FRAME(1, 8, .hFlip = TRUE), @@ -135,7 +138,7 @@ const union AnimCmd gSpriteAnim_858E528[] = ANIMCMD_END, }; -const union AnimCmd gSpriteAnim_858E540[] = +static const union AnimCmd gSpriteAnim_858E540[] = { ANIMCMD_FRAME(4, 8, .hFlip = TRUE), ANIMCMD_FRAME(3, 8, .hFlip = TRUE), @@ -145,7 +148,7 @@ const union AnimCmd gSpriteAnim_858E540[] = ANIMCMD_END, }; -const union AnimCmd gSpriteAnim_858E558[] = +static const union AnimCmd gSpriteAnim_858E558[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(1, 8), @@ -155,12 +158,12 @@ const union AnimCmd gSpriteAnim_858E558[] = ANIMCMD_END, }; -const union AnimCmd *const gSpriteAnimTable_858E570[] = +static const union AnimCmd *const gSpriteAnimTable_858E570[] = { gSpriteAnim_858E4E0, }; -const union AnimCmd *const gSpriteAnimTable_858E574[] = +static const union AnimCmd *const gSpriteAnimTable_858E574[] = { gSpriteAnim_858E4F8, gSpriteAnim_858E510, @@ -168,12 +171,12 @@ const union AnimCmd *const gSpriteAnimTable_858E574[] = gSpriteAnim_858E540, }; -const union AnimCmd *const gSpriteAnimTable_858E584[] = +static const union AnimCmd *const gSpriteAnimTable_858E584[] = { gSpriteAnim_858E558, }; -const struct SpriteFrameImage gUnknown_858E588[] = +static const struct SpriteFrameImage gUnknown_858E588[] = { {gSpriteImage_858D978, 0x80}, {gSpriteImage_858D9F8, 0x80}, @@ -182,7 +185,7 @@ const struct SpriteFrameImage gUnknown_858E588[] = {gSpriteImage_858DB78, 0x80}, }; -const struct SpriteFrameImage gUnknown_858E5B0[] = +static const struct SpriteFrameImage gUnknown_858E5B0[] = { {gSpriteImage_858DEB8, 0x80}, {gSpriteImage_858DF38, 0x80}, @@ -191,7 +194,7 @@ const struct SpriteFrameImage gUnknown_858E5B0[] = {gSpriteImage_858E0B8, 0x80}, }; -const struct SpriteFrameImage gUnknown_858E5D8[] = +static const struct SpriteFrameImage gUnknown_858E5D8[] = { {gSpriteImage_858DC38, 0x80}, {gSpriteImage_858DCB8, 0x80}, @@ -200,7 +203,7 @@ const struct SpriteFrameImage gUnknown_858E5D8[] = {gSpriteImage_858DE38, 0x80}, }; -const struct SpriteTemplate gUnknown_0858E600 = +static const struct SpriteTemplate gUnknown_0858E600 = { .tileTag = 0xFFFF, .paletteTag = 0x1003, @@ -211,7 +214,7 @@ const struct SpriteTemplate gUnknown_0858E600 = .callback = CaveEntranceSpriteCallback1, }; -const struct SpriteTemplate gUnknown_0858E618 = +static const struct SpriteTemplate gUnknown_0858E618 = { .tileTag = 0xFFFF, .paletteTag = 0x1008, @@ -222,7 +225,7 @@ const struct SpriteTemplate gUnknown_0858E618 = .callback = TreeEntranceSpriteCallback1, }; -const struct SpriteTemplate gUnknown_0858E630 = +static const struct SpriteTemplate gUnknown_0858E630 = { .tileTag = 0xFFFF, .paletteTag = 0x1008, @@ -236,7 +239,7 @@ const struct SpriteTemplate gUnknown_0858E630 = const struct SpritePalette gFieldEffectObjectPaletteInfo7 = {gFieldEffectObjectPalette7, 0x1003}; const struct SpritePalette gFieldEffectObjectPaletteInfo8 = {gFieldEffectObjectPalette8, 0x1008}; -const struct OamData gOamData_858E658 = +static const struct OamData gOamData_858E658 = { .x = 0, .y = 0, @@ -248,7 +251,7 @@ const struct OamData gOamData_858E658 = .priority = 2, }; -const union AnimCmd gSpriteAnim_858E660[] = +static const union AnimCmd gSpriteAnim_858E660[] = { ANIMCMD_FRAME(0, 6), ANIMCMD_FRAME(1, 6), @@ -256,19 +259,19 @@ const union AnimCmd gSpriteAnim_858E660[] = ANIMCMD_END, }; -const union AnimCmd *const gSpriteAnimTable_858E670[] = +static const union AnimCmd *const gSpriteAnimTable_858E670[] = { gSpriteAnim_858E660, }; -const struct SpriteFrameImage gUnknown_0858E674[] = +static const struct SpriteFrameImage gUnknown_0858E674[] = { {gSpriteImage_858E1D8, 0x100}, {gSpriteImage_858E2D8, 0x100}, {gSpriteImage_858E3D8, 0x100}, }; -const struct SpriteTemplate gUnknown_0858E68C = +static const struct SpriteTemplate gUnknown_0858E68C = { .tileTag = 0xFFFF, .paletteTag = 0x100E, @@ -340,7 +343,7 @@ bool8 sub_80F9C30(void) return FuncIsActiveTask(sub_80F9DFC); } -void sub_80F9C44(void (*taskfunc) (u8), u16 a1, u16 a2, u8 a3) +static void sub_80F9C44(void (*taskfunc) (u8), u16 a1, u16 a2, u8 a3) { u8 taskId = CreateTask(taskfunc, a3); @@ -350,12 +353,11 @@ void sub_80F9C44(void (*taskfunc) (u8), u16 a1, u16 a2, u8 a3) gTasks[taskId].func(taskId); } -#ifdef NONMATCHING -void sub_80F9C90(u8 taskId) +static void sub_80F9C90(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch(task->data[0]) + switch (task->data[0]) { case 0: task->data[3] = 0x78; @@ -365,7 +367,7 @@ void sub_80F9C90(u8 taskId) SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[5], task->data[6])); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); SetGpuReg(REG_OFFSET_WININ, 0x3F); SetGpuReg(REG_OFFSET_WINOUT, 0); @@ -400,7 +402,7 @@ void sub_80F9C90(u8 taskId) task->data[5] -= task->data[2]; task->data[6] += task->data[2]; - if (task->data[5] < 1 || task->data[2] > 0x9F) + if (task->data[5] < 1 || task->data[6] > 0x9F) { task->data[5] = 0; task->data[6] = 0xA0; @@ -416,189 +418,10 @@ void sub_80F9C90(u8 taskId) DestroyTask(taskId); return; } - task->data[0] += 1; + task->data[0]++; } -#else -NAKED -void sub_80F9C90(u8 taskId) -{ - asm_unified("\tpush {r4,r5,lr}\n" - "\tlsls r0, 24\n" - "\tlsrs r5, r0, 24\n" - "\tlsls r0, r5, 2\n" - "\tadds r0, r5\n" - "\tlsls r0, 3\n" - "\tldr r1, =gTasks\n" - "\tadds r4, r0, r1\n" - "\tmovs r1, 0x8\n" - "\tldrsh r0, [r4, r1]\n" - "\tcmp r0, 0x1\n" - "\tbeq _080F9D10\n" - "\tcmp r0, 0x1\n" - "\tbgt _080F9CB8\n" - "\tcmp r0, 0\n" - "\tbeq _080F9CC2\n" - "\tb _080F9DDE\n" - "\t.pool\n" - "_080F9CB8:\n" - "\tcmp r0, 0x2\n" - "\tbeq _080F9D32\n" - "\tcmp r0, 0x3\n" - "\tbeq _080F9D94\n" - "\tb _080F9DDE\n" - "_080F9CC2:\n" - "\tmovs r0, 0x78\n" - "\tstrh r0, [r4, 0xE]\n" - "\tstrh r0, [r4, 0x10]\n" - "\tmovs r0, 0x50\n" - "\tstrh r0, [r4, 0x12]\n" - "\tmovs r0, 0x51\n" - "\tstrh r0, [r4, 0x14]\n" - "\tmovs r1, 0x80\n" - "\tlsls r1, 6\n" - "\tmovs r0, 0\n" - "\tbl SetGpuRegBits\n" - "\tldrh r1, [r4, 0xE]\n" - "\tlsls r1, 8\n" - "\tldrh r0, [r4, 0x10]\n" - "\torrs r1, r0\n" - "\tlsls r1, 16\n" - "\tlsrs r1, 16\n" - "\tmovs r0, 0x40\n" - "\tbl SetGpuReg\n" - "\tldrh r1, [r4, 0x12]\n" - "\tlsls r1, 8\n" - "\tldrh r0, [r4, 0x14]\n" - "\torrs r1, r0\n" - "\tlsls r1, 16\n" - "\tlsrs r1, 16\n" - "\tmovs r0, 0x44\n" - "\tbl SetGpuReg\n" - "\tmovs r0, 0x48\n" - "\tmovs r1, 0x3F\n" - "\tbl SetGpuReg\n" - "\tmovs r0, 0x4A\n" - "\tmovs r1, 0\n" - "\tbl SetGpuReg\n" - "\tb _080F9DEE\n" - "_080F9D10:\n" - "\tmovs r0, 0x50\n" - "\tbl GetGpuReg\n" - "\tstrh r0, [r4, 0x16]\n" - "\tmovs r0, 0x54\n" - "\tbl GetGpuReg\n" - "\tstrh r0, [r4, 0x18]\n" - "\tmovs r0, 0x50\n" - "\tmovs r1, 0xBF\n" - "\tbl SetGpuReg\n" - "\tmovs r0, 0x54\n" - "\tmovs r1, 0x10\n" - "\tbl SetGpuReg\n" - "\tb _080F9DEE\n" - "_080F9D32:\n" - "\tldrh r0, [r4, 0xE]\n" - "\tldrh r1, [r4, 0xA]\n" - "\tsubs r0, r1\n" - "\tmovs r5, 0\n" - "\tstrh r0, [r4, 0xE]\n" - "\tldrh r2, [r4, 0x10]\n" - "\tadds r1, r2\n" - "\tstrh r1, [r4, 0x10]\n" - "\tlsls r0, 16\n" - "\tcmp r0, 0\n" - "\tble _080F9D50\n" - "\tlsls r0, r1, 16\n" - "\tasrs r0, 16\n" - "\tcmp r0, 0xEF\n" - "\tble _080F9D76\n" - "_080F9D50:\n" - "\tstrh r5, [r4, 0xE]\n" - "\tmovs r0, 0xF0\n" - "\tstrh r0, [r4, 0x10]\n" - "\tmovs r0, 0x54\n" - "\tmovs r1, 0\n" - "\tbl SetGpuReg\n" - "\tldrh r1, [r4, 0x16]\n" - "\tmovs r0, 0x50\n" - "\tbl SetGpuReg\n" - "\tmovs r0, 0x1\n" - "\tnegs r0, r0\n" - "\tmovs r1, 0\n" - "\tmovs r2, 0\n" - "\tbl BlendPalettes\n" - "\tldr r0, =gPlttBufferFaded\n" - "\tstrh r5, [r0]\n" - "_080F9D76:\n" - "\tldrh r1, [r4, 0xE]\n" - "\tlsls r1, 8\n" - "\tldrh r0, [r4, 0x10]\n" - "\torrs r1, r0\n" - "\tlsls r1, 16\n" - "\tlsrs r1, 16\n" - "\tmovs r0, 0x40\n" - "\tbl SetGpuReg\n" - "\tmovs r1, 0xE\n" - "\tldrsh r0, [r4, r1]\n" - "\tb _080F9DD8\n" - "\t.pool\n" - "_080F9D94:\n" - "\tldrh r0, [r4, 0x12]\n" - "\tldrh r1, [r4, 0xC]\n" - "\tsubs r0, r1\n" - "\tstrh r0, [r4, 0x12]\n" - "\tldrh r2, [r4, 0x14]\n" - "\tadds r1, r2\n" - "\tstrh r1, [r4, 0x14]\n" - "\tlsls r0, 16\n" - "\tcmp r0, 0\n" - "\tble _080F9DB0\n" - "\tlsls r0, r1, 16\n" - "\tasrs r0, 16\n" - "\tcmp r0, 0x9F\n" - "\tble _080F9DC2\n" - "_080F9DB0:\n" - "\tmovs r0, 0\n" - "\tstrh r0, [r4, 0x12]\n" - "\tmovs r0, 0xA0\n" - "\tstrh r0, [r4, 0x14]\n" - "\tmovs r1, 0x80\n" - "\tlsls r1, 6\n" - "\tmovs r0, 0\n" - "\tbl ClearGpuRegBits\n" - "_080F9DC2:\n" - "\tldrh r1, [r4, 0x12]\n" - "\tlsls r1, 8\n" - "\tldrh r0, [r4, 0x14]\n" - "\torrs r1, r0\n" - "\tlsls r1, 16\n" - "\tlsrs r1, 16\n" - "\tmovs r0, 0x44\n" - "\tbl SetGpuReg\n" - "\tmovs r1, 0x12\n" - "\tldrsh r0, [r4, r1]\n" - "_080F9DD8:\n" - "\tcmp r0, 0\n" - "\tbne _080F9DF4\n" - "\tb _080F9DEE\n" - "_080F9DDE:\n" - "\tldrh r1, [r4, 0x16]\n" - "\tmovs r0, 0x50\n" - "\tbl SetGpuReg\n" - "\tadds r0, r5, 0\n" - "\tbl DestroyTask\n" - "\tb _080F9DF4\n" - "_080F9DEE:\n" - "\tldrh r0, [r4, 0x8]\n" - "\tadds r0, 0x1\n" - "\tstrh r0, [r4, 0x8]\n" - "_080F9DF4:\n" - "\tpop {r4,r5}\n" - "\tpop {r0}\n" - "\tbx r0"); -} -#endif -void sub_80F9DFC(u8 taskId) +static void sub_80F9DFC(u8 taskId) { struct Task *task = &gTasks[taskId]; @@ -660,16 +483,16 @@ void sub_80F9DFC(u8 taskId) DestroyTask(taskId); return; } - task->data[0] += 1; + task->data[0]++; } -void SetCurrentSecretBase(void) +static void SetCurrentSecretBase(void) { sub_80E9608(&gPlayerFacingPosition, gMapHeader.events); sub_80E8B6C(); } -void AdjustSecretPowerSpritePixelOffsets(void) +static void AdjustSecretPowerSpritePixelOffsets(void) { if (gPlayerAvatar.flags & 0x6) { @@ -756,7 +579,7 @@ bool8 SetUpFieldMove_SecretPower(void) return FALSE; } -void FieldCallback_SecretBaseCave(void) +static void FieldCallback_SecretBaseCave(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); ScriptContext1_SetupScript(EventScript_275A86); @@ -818,7 +641,7 @@ static void CaveEntranceSpriteCallbackEnd(struct Sprite *sprite) EnableBothScriptContexts(); } -void FieldCallback_SecretBaseTree(void) +static void FieldCallback_SecretBaseTree(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); ScriptContext1_SetupScript(EventScript_275ADF); @@ -892,7 +715,7 @@ static void TreeEntranceSpriteCallbackEnd(struct Sprite *sprite) EnableBothScriptContexts(); } -void FieldCallback_SecretBaseShrub(void) +static void FieldCallback_SecretBaseShrub(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); ScriptContext1_SetupScript(EventScript_275B38); @@ -956,7 +779,7 @@ static void ShrubEntranceSpriteCallbackEnd(struct Sprite *sprite) EnableBothScriptContexts(); } -u32 FldEff_SecretBasePCTurnOn(void) +bool8 FldEff_SecretBasePCTurnOn(void) { s16 x, y; u8 taskId; @@ -968,10 +791,10 @@ u32 FldEff_SecretBasePCTurnOn(void) gTasks[taskId].data[1] = y; gTasks[taskId].data[2] = 0; - return 0; + return FALSE; } -void Task_SecretBasePCTurnOn(u8 taskId) +static void Task_SecretBasePCTurnOn(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -1025,7 +848,7 @@ void PopSecretBaseBalloon(s16 metatileId, s16 x, s16 y) gTasks[taskId].data[4] = 1; } -void Task_PopSecretBaseBalloon(u8 taskId) +static void Task_PopSecretBaseBalloon(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -1049,7 +872,7 @@ void Task_PopSecretBaseBalloon(u8 taskId) } } -void DoBalloonSoundEffect(s16 metatileId) +static void DoBalloonSoundEffect(s16 metatileId) { switch (metatileId) { @@ -1078,7 +901,7 @@ bool8 FldEff_NopA700(void) return FALSE; } -void DoSecretBaseBreakableDoorEffect(s16 x, s16 y) +static void DoSecretBaseBreakableDoorEffect(s16 x, s16 y) { PlaySE(SE_TOY_KABE); MapGridSetMetatileIdAt(x, y, 630); @@ -1087,7 +910,7 @@ void DoSecretBaseBreakableDoorEffect(s16 x, s16 y) CurrentMapDrawMetatileAt(x, y - 1); } -void Task_ShatterSecretBaseBreakableDoor(u8 taskId) +static void Task_ShatterSecretBaseBreakableDoor(u8 taskId) { if (gTasks[taskId].data[0] == 7) { @@ -1118,7 +941,7 @@ void ShatterSecretBaseBreakableDoor(s16 x, s16 y) } #define tMetatileID data[0] -void Task_SecretBaseMusicNoteMatSound(u8 taskId) +static void Task_SecretBaseMusicNoteMatSound(u8 taskId) { if (gTasks[taskId].data[1] == 7) { @@ -1167,7 +990,7 @@ void PlaySecretBaseMusicNoteMatSound(s16 metatileId) } #undef tMetatileID -void SpriteCB_GlitterMatSparkle(struct Sprite *sprite) +static void SpriteCB_GlitterMatSparkle(struct Sprite *sprite) { sprite->data[0]++; @@ -1222,30 +1045,30 @@ bool8 FldEff_SandPillar(void) gSprites[gPlayerAvatar.spriteId].oam.x + 8, gSprites[gPlayerAvatar.spriteId].oam.y, 148); - + break; - + case DIR_WEST: CreateSprite(&gUnknown_0858E68C, gSprites[gPlayerAvatar.spriteId].oam.x - 8, gSprites[gPlayerAvatar.spriteId].oam.y + 16, 148); - + break; - + case DIR_EAST: CreateSprite(&gUnknown_0858E68C, gSprites[gPlayerAvatar.spriteId].oam.x + 24, gSprites[gPlayerAvatar.spriteId].oam.y + 16, 148); - + break; } return FALSE; } -void SpriteCB_SandPillar_0(struct Sprite *sprite) +static void SpriteCB_SandPillar_0(struct Sprite *sprite) { PlaySE(SE_W088); @@ -1253,16 +1076,16 @@ void SpriteCB_SandPillar_0(struct Sprite *sprite) MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, 3586); else MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, 644); - + MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6], 522); CurrentMapDrawMetatileAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1); CurrentMapDrawMetatileAt(gFieldEffectArguments[5], gFieldEffectArguments[6]); - + sprite->data[0] = 0; sprite->callback = SpriteCB_SandPillar_1; } -void SpriteCB_SandPillar_1(struct Sprite *sprite) +static void SpriteCB_SandPillar_1(struct Sprite *sprite) { if (sprite->data[0] < 18) { @@ -1277,7 +1100,7 @@ void SpriteCB_SandPillar_1(struct Sprite *sprite) } } -void SpriteCB_SandPillar_2(struct Sprite *sprite) +static void SpriteCB_SandPillar_2(struct Sprite *sprite) { FieldEffectStop(sprite, FLDEFF_SAND_PILLAR); EnableBothScriptContexts(); @@ -1343,71 +1166,30 @@ void GetShieldToyTVDecorationInfo(void) } } -#ifdef NONMATCHING bool8 sub_80FADE4(u16 arg0, u8 arg1) { - if (CurrentMapIsSecretBase()) + if (!CurrentMapIsSecretBase()) + return FALSE; + + if (!arg1) { - if (arg1 == 0) - { - if ((u16)(arg0 + 0xfffffd7b) <= 1 || (arg0 == 0x237)) - return TRUE; - } - else - { - if (arg0 == 0x28d || arg0 == 0x23f) - return TRUE; - } + if (arg0 == 0x285 || arg0 == 0x286) + return TRUE; + if (arg0 == 0x237) + return TRUE; } + else + { + if (arg0 == 0x28d) + return TRUE; + if (arg0 == 0x23F) + return TRUE; + } + return FALSE; } -#else -NAKED -bool8 sub_80FADE4(u16 arg0, u8 arg1) -{ - asm_unified("\tpush {r4-r6,lr}\n" - "\tlsls r0, 16\n" - "\tlsrs r4, r0, 16\n" - "\tadds r6, r4, 0\n" - "\tlsls r1, 24\n" - "\tlsrs r5, r1, 24\n" - "\tbl CurrentMapIsSecretBase\n" - "\tlsls r0, 24\n" - "\tcmp r0, 0\n" - "\tbeq _080FAE28\n" - "\tcmp r5, 0\n" - "\tbne _080FAE1C\n" - "\tldr r1, =0xfffffd7b\n" - "\tadds r0, r4, r1\n" - "\tlsls r0, 16\n" - "\tlsrs r0, 16\n" - "\tcmp r0, 0x1\n" - "\tbls _080FAE10\n" - "\tldr r0, =0x00000237\n" - "\tcmp r4, r0\n" - "\tbne _080FAE28\n" - "_080FAE10:\n" - "\tmovs r0, 0x1\n" - "\tb _080FAE2A\n" - "\t.pool\n" - "_080FAE1C:\n" - "\tldr r0, =0x0000028d\n" - "\tcmp r4, r0\n" - "\tbeq _080FAE10\n" - "\tldr r0, =0x0000023f\n" - "\tcmp r6, r0\n" - "\tbeq _080FAE10\n" - "_080FAE28:\n" - "\tmovs r0, 0\n" - "_080FAE2A:\n" - "\tpop {r4-r6}\n" - "\tpop {r1}\n" - "\tbx r1\n" - "\t.pool"); -} -#endif -void Task_FieldPoisonEffect(u8 taskId) +static void Task_FieldPoisonEffect(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -1441,15 +1223,15 @@ bool32 FldEffPoison_IsActive(void) return FuncIsActiveTask(Task_FieldPoisonEffect); } -void Task_WateringBerryTreeAnim_0(u8 taskId) +static void Task_WateringBerryTreeAnim_0(u8 taskId) { gTasks[taskId].func = Task_WateringBerryTreeAnim_1; } -void Task_WateringBerryTreeAnim_1(u8 taskId) +static void Task_WateringBerryTreeAnim_1(u8 taskId) { struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId]; - + if (!EventObjectIsMovementOverridden(playerEventObj) || EventObjectClearHeldMovementIfFinished(playerEventObj)) { @@ -1459,23 +1241,23 @@ void Task_WateringBerryTreeAnim_1(u8 taskId) } } -void Task_WateringBerryTreeAnim_2(u8 taskId) +static void Task_WateringBerryTreeAnim_2(u8 taskId) { struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId]; - + if (EventObjectClearHeldMovementIfFinished(playerEventObj)) { s16 value = gTasks[taskId].data[1]++; - + if (value < 10) EventObjectSetHeldMovement(playerEventObj, GetWalkInPlaceNormalMovementAction(GetPlayerFacingDirection())); - + else gTasks[taskId].func = Task_WateringBerryTreeAnim_3; } } -void Task_WateringBerryTreeAnim_3(u8 taskId) +static void Task_WateringBerryTreeAnim_3(u8 taskId) { SetPlayerAvatarTransitionFlags(sub_808BCD0()); DestroyTask(taskId);