From 0de38858f641934699ce934e2bdb3dc1495baec9 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Fri, 16 Jun 2017 17:46:13 -0500 Subject: [PATCH 1/7] decompile sub_8121E10 - sub_8122838 --- asm/choose_party.s | 1304 ----------------------------- include/battle_party_menu.h | 14 - include/global.h | 5 +- include/party_menu.h | 42 + ld_script.txt | 2 + src/battle_party_menu.c | 26 +- src/choose_party.c | 583 +++++++++++++ src/party_menu.c | 17 +- src/script_pokemon_util_80F99CC.c | 3 + 9 files changed, 637 insertions(+), 1359 deletions(-) create mode 100644 include/party_menu.h create mode 100644 src/choose_party.c diff --git a/asm/choose_party.s b/asm/choose_party.s index f1a03cda3..0846a25f4 100644 --- a/asm/choose_party.s +++ b/asm/choose_party.s @@ -6,1310 +6,6 @@ .text - thumb_func_start sub_8121E10 -sub_8121E10: @ 8121E10 - push {lr} - bl sub_8121E58 - ldr r0, _08121E2C @ =0x0201b000 - ldr r1, _08121E30 @ =0x00000263 - adds r0, r1 - movs r1, 0 - strb r1, [r0] - movs r0, 0x4 - bl OpenPartyMenu - pop {r0} - bx r0 - .align 2, 0 -_08121E2C: .4byte 0x0201b000 -_08121E30: .4byte 0x00000263 - thumb_func_end sub_8121E10 - - thumb_func_start sub_8121E34 -sub_8121E34: @ 8121E34 - push {lr} - bl sub_8121E58 - ldr r0, _08121E50 @ =0x0201b000 - ldr r1, _08121E54 @ =0x00000263 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - movs r0, 0x4 - movs r1, 0 - bl OpenPartyMenu - pop {r0} - bx r0 - .align 2, 0 -_08121E50: .4byte 0x0201b000 -_08121E54: .4byte 0x00000263 - thumb_func_end sub_8121E34 - - thumb_func_start sub_8121E58 -sub_8121E58: @ 8121E58 - push {lr} - movs r1, 0 - ldr r3, _08121E74 @ =gSelectedOrderFromParty - movs r2, 0 -_08121E60: - adds r0, r1, r3 - strb r2, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x2 - bls _08121E60 - pop {r0} - bx r0 - .align 2, 0 -_08121E74: .4byte gSelectedOrderFromParty - thumb_func_end sub_8121E58 - - thumb_func_start sub_8121E78 -sub_8121E78: @ 8121E78 - push {r4-r6,lr} - ldr r1, _08121E98 @ =0x0201b000 - movs r2, 0x99 - lsls r2, 2 - adds r0, r1, r2 - movs r2, 0 - ldrsh r0, [r0, r2] - adds r4, r1, 0 - cmp r0, 0x7 - bls _08121E8E - b _08122026 -_08121E8E: - lsls r0, 2 - ldr r1, _08121E9C @ =_08121EA0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08121E98: .4byte 0x0201b000 -_08121E9C: .4byte _08121EA0 - .align 2, 0 -_08121EA0: - .4byte _08121EC0 - .4byte _08121F00 - .4byte _08121F14 - .4byte _08121F28 - .4byte _08121F54 - .4byte _08121F68 - .4byte _08121F6E - .4byte _08121FF8 -_08121EC0: - ldr r0, _08121EE8 @ =0x00000266 - adds r5, r4, r0 - movs r1, 0 - ldrsh r3, [r5, r1] - ldr r0, _08121EEC @ =gPlayerPartyCount - ldrb r0, [r0] - cmp r3, r0 - bge _08121EF4 - movs r2, 0x98 - lsls r2, 2 - adds r0, r4, r2 - ldrb r0, [r0] - ldrb r1, [r5] - movs r2, 0x64 - muls r2, r3 - ldr r3, _08121EF0 @ =gPlayerParty - adds r2, r3 - bl TryCreatePartyMenuMonIcon - b _08122020 - .align 2, 0 -_08121EE8: .4byte 0x00000266 -_08121EEC: .4byte gPlayerPartyCount -_08121EF0: .4byte gPlayerParty -_08121EF4: - movs r0, 0 - strh r0, [r5] - movs r0, 0x99 - lsls r0, 2 - adds r1, r4, r0 - b _08121FE8 -_08121F00: - bl LoadHeldItemIconGraphics - ldr r1, _08121F10 @ =0x0201b000 - movs r2, 0x99 - lsls r2, 2 - adds r1, r2 - b _08121FE8 - .align 2, 0 -_08121F10: .4byte 0x0201b000 -_08121F14: - movs r1, 0x98 - lsls r1, 2 - adds r0, r4, r1 - ldrb r0, [r0] - bl CreateHeldItemIcons_806DC34 - movs r2, 0x99 - lsls r2, 2 - adds r1, r4, r2 - b _08121FE8 -_08121F28: - movs r1, 0x98 - lsls r1, 2 - adds r0, r4, r1 - ldrb r0, [r0] - ldr r2, _08121F50 @ =0x00000266 - adds r5, r4, r2 - ldrb r1, [r5] - bl sub_806BD58 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122020 - movs r0, 0 - strh r0, [r5] - movs r0, 0x99 - lsls r0, 2 - adds r1, r4, r0 - b _08121FE8 - .align 2, 0 -_08121F50: .4byte 0x00000266 -_08121F54: - bl PartyMenuPrintMonsLevelOrStatus - ldr r1, _08121F64 @ =0x0201b000 - movs r2, 0x99 - lsls r2, 2 - adds r1, r2 - b _08121FE8 - .align 2, 0 -_08121F64: .4byte 0x0201b000 -_08121F68: - bl PrintPartyMenuMonNicknames - b _08121FE0 -_08121F6E: - movs r5, 0 - b _08121FD8 -_08121F72: - movs r4, 0 - adds r6, r5, 0x1 - b _08121F7E -_08121F78: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_08121F7E: - cmp r4, 0x2 - bhi _08121FA0 - ldr r0, _08121FC4 @ =gSelectedOrderFromParty - adds r0, r4, r0 - ldrb r0, [r0] - cmp r0, r6 - bne _08121F78 - lsls r1, r4, 3 - subs r1, r4 - lsls r1, 25 - movs r2, 0xE0 - lsls r2, 21 - adds r1, r2 - lsrs r1, 24 - adds r0, r5, 0 - bl sub_806BC3C -_08121FA0: - cmp r4, 0x3 - bne _08121FD4 - movs r0, 0x64 - muls r0, r5 - ldr r1, _08121FC8 @ =gPlayerParty - adds r0, r1 - bl sub_8122030 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08121FCC - adds r0, r5, 0 - movs r1, 0x70 - bl sub_806BC3C - b _08121FD4 - .align 2, 0 -_08121FC4: .4byte gSelectedOrderFromParty -_08121FC8: .4byte gPlayerParty -_08121FCC: - adds r0, r5, 0 - movs r1, 0x7E - bl sub_806BC3C -_08121FD4: - lsls r0, r6, 24 - lsrs r5, r0, 24 -_08121FD8: - ldr r0, _08121FF0 @ =gPlayerPartyCount - ldrb r0, [r0] - cmp r5, r0 - bcc _08121F72 -_08121FE0: - ldr r1, _08121FF4 @ =0x0201b000 - movs r0, 0x99 - lsls r0, 2 - adds r1, r0 -_08121FE8: - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _08122026 - .align 2, 0 -_08121FF0: .4byte gPlayerPartyCount -_08121FF4: .4byte 0x0201b000 -_08121FF8: - ldr r1, _0812201C @ =0x00000266 - adds r5, r4, r1 - ldrb r0, [r5] - bl sub_806B58C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122020 - movs r1, 0 - strh r1, [r5] - movs r2, 0x99 - lsls r2, 2 - adds r0, r4, r2 - strh r1, [r0] - movs r0, 0x1 - b _08122028 - .align 2, 0 -_0812201C: .4byte 0x00000266 -_08122020: - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] -_08122026: - movs r0, 0 -_08122028: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8121E78 - - thumb_func_start sub_8122030 -sub_8122030: @ 8122030 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _0812207C - ldr r0, _08122058 @ =0x0201b000 - ldr r1, _0812205C @ =0x00000263 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _08122060 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _0812207C - b _081220B6 - .align 2, 0 -_08122058: .4byte 0x0201b000 -_0812205C: .4byte 0x00000263 -_08122060: - ldr r0, _08122080 @ =gSaveBlock2 - ldr r1, _08122084 @ =0x00000554 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08122088 - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - cmp r0, 0x32 - bls _08122088 -_0812207C: - movs r0, 0 - b _081220B8 - .align 2, 0 -_08122080: .4byte gSaveBlock2 -_08122084: .4byte 0x00000554 -_08122088: - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r3, r0, 16 - ldr r1, _081220C0 @ =gBattleTowerBanlist - movs r0, 0 - lsls r0, 1 - adds r2, r0, r1 - ldrh r0, [r2] - ldr r1, _081220C4 @ =0x0000ffff - cmp r0, r1 - beq _081220B6 - adds r4, r1, 0 - adds r1, r2, 0 -_081220A8: - ldrh r0, [r1] - cmp r0, r3 - beq _0812207C - adds r1, 0x2 - ldrh r0, [r1] - cmp r0, r4 - bne _081220A8 -_081220B6: - movs r0, 0x1 -_081220B8: - pop {r4} - pop {r1} - bx r1 - .align 2, 0 -_081220C0: .4byte gBattleTowerBanlist -_081220C4: .4byte 0x0000ffff - thumb_func_end sub_8122030 - - thumb_func_start sub_81220C8 -sub_81220C8: @ 81220C8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r1, _081220EC @ =0x0201b000 - ldr r2, _081220F0 @ =0x00000263 - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0 - beq _081221A2 - ldr r0, _081220F4 @ =gSelectedOrderFromParty - ldrb r0, [r0, 0x2] - cmp r0, 0 - bne _08122100 - movs r0, 0x11 - b _081221A4 - .align 2, 0 -_081220EC: .4byte 0x0201b000 -_081220F0: .4byte 0x00000263 -_081220F4: .4byte gSelectedOrderFromParty -_081220F8: - movs r0, 0x12 - b _081221A4 -_081220FC: - movs r0, 0x13 - b _081221A4 -_08122100: - movs r5, 0 -_08122102: - ldr r4, _081221B4 @ =gSelectedOrderFromParty - adds r4, r5, r4 - ldrb r0, [r4] - movs r1, 0x64 - muls r0, r1 - ldr r2, _081221B8 @ =gUnknown_030042FC - adds r0, r2 - movs r1, 0xB - bl GetMonData - ldr r1, _081221BC @ =0x0201b000 - ldr r2, _081221C0 @ =0x00000282 - adds r6, r1, r2 - strh r0, [r6] - ldrb r0, [r4] - movs r1, 0x64 - muls r0, r1 - ldr r2, _081221B8 @ =gUnknown_030042FC - adds r0, r2 - movs r1, 0xC - bl GetMonData - ldr r1, _081221C4 @ =0x0201b280 - strh r0, [r1] - adds r1, r5, 0x1 - lsls r0, r1, 24 - lsrs r5, r0, 24 - mov r10, r1 - cmp r5, 0x2 - bhi _08122198 - ldr r2, _081221C8 @ =0xfffffd7e - adds r2, r6 - mov r9, r2 - movs r0, 0x64 - mov r8, r0 - ldr r7, _081221B8 @ =gUnknown_030042FC -_0812214A: - ldr r0, _081221C0 @ =0x00000282 - add r0, r9 - movs r1, 0 - ldrsh r4, [r0, r1] - ldr r0, _081221B4 @ =gSelectedOrderFromParty - adds r6, r5, r0 - ldrb r0, [r6] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0xB - bl GetMonData - cmp r4, r0 - beq _081220F8 - movs r1, 0xA0 - lsls r1, 2 - add r1, r9 - movs r2, 0 - ldrsh r0, [r1, r2] - cmp r0, 0 - beq _0812218E - adds r4, r0, 0 - ldrb r0, [r6] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r7 - movs r1, 0xC - bl GetMonData - cmp r4, r0 - beq _081220FC -_0812218E: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x2 - bls _0812214A -_08122198: - mov r2, r10 - lsls r0, r2, 24 - lsrs r5, r0, 24 - cmp r5, 0x1 - bls _08122102 -_081221A2: - movs r0, 0xFF -_081221A4: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_081221B4: .4byte gSelectedOrderFromParty -_081221B8: .4byte gUnknown_030042FC -_081221BC: .4byte 0x0201b000 -_081221C0: .4byte 0x00000282 -_081221C4: .4byte 0x0201b280 -_081221C8: .4byte 0xfffffd7e - thumb_func_end sub_81220C8 - - thumb_func_start sub_81221CC -sub_81221CC: @ 81221CC - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - movs r1, 0 - ldr r3, _081221E4 @ =gSelectedOrderFromParty -_081221D6: - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, r2 - bne _081221E8 - movs r0, 0x1 - b _081221F4 - .align 2, 0 -_081221E4: .4byte gSelectedOrderFromParty -_081221E8: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x2 - bls _081221D6 - movs r0, 0 -_081221F4: - pop {r1} - bx r1 - thumb_func_end sub_81221CC - - thumb_func_start sub_81221F8 -sub_81221F8: @ 81221F8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x5 - movs r1, 0x1 - bl sub_806D538 - ldr r5, _08122248 @ =gLastFieldPokeMenuOpened - ldrb r1, [r5] - movs r0, 0x64 - muls r0, r1 - ldr r1, _0812224C @ =gPlayerParty - adds r0, r1 - bl sub_8122030 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122284 - ldrb r0, [r5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - bl sub_81221CC - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x1 - bne _0812225C - ldr r1, _08122250 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - strh r2, [r0, 0x10] - ldr r1, _08122254 @ =gUnknown_084017D8 - ldr r2, _08122258 @ =gUnknown_084017B0 - movs r0, 0x1 - b _08122270 - .align 2, 0 -_08122248: .4byte gLastFieldPokeMenuOpened -_0812224C: .4byte gPlayerParty -_08122250: .4byte gTasks -_08122254: .4byte gUnknown_084017D8 -_08122258: .4byte gUnknown_084017B0 -_0812225C: - ldr r1, _08122278 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0 - strh r1, [r0, 0x10] - ldr r1, _0812227C @ =gUnknown_084017D8 - ldr r2, _08122280 @ =gUnknown_084017B0 - movs r0, 0 -_08122270: - movs r3, 0 - bl sub_806E750 - b _0812229E - .align 2, 0 -_08122278: .4byte gTasks -_0812227C: .4byte gUnknown_084017D8 -_08122280: .4byte gUnknown_084017B0 -_08122284: - ldr r1, _081222A4 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0x2 - strh r1, [r0, 0x10] - ldr r1, _081222A8 @ =gUnknown_084017D8 - ldr r2, _081222AC @ =gUnknown_084017B0 - movs r0, 0x2 - movs r3, 0 - bl sub_806E750 -_0812229E: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_081222A4: .4byte gTasks -_081222A8: .4byte gUnknown_084017D8 -_081222AC: .4byte gUnknown_084017B0 - thumb_func_end sub_81221F8 - - thumb_func_start sub_81222B0 -sub_81222B0: @ 81222B0 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _081222DC @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _0812237C - adds r0, r4, 0 - bl sub_806BE38 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - beq _081222E0 - cmp r0, 0x2 - beq _08122354 - b _0812237C - .align 2, 0 -_081222DC: .4byte gPaletteFade -_081222E0: - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl sub_806CA38 - ldr r1, _08122320 @ =gLastFieldPokeMenuOpened - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x6 - beq _08122334 - ldrb r1, [r1] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08122324 @ =gPlayerParty - adds r0, r1 - ldr r1, _08122328 @ =gStringVar1 - bl GetMonNickname - adds r0, r4, 0 - bl sub_81221F8 - ldr r1, _0812232C @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122330 @ =sub_812238C - str r1, [r0] - b _08122342 - .align 2, 0 -_08122320: .4byte gLastFieldPokeMenuOpened -_08122324: .4byte gPlayerParty -_08122328: .4byte gStringVar1 -_0812232C: .4byte gTasks -_08122330: .4byte sub_812238C -_08122334: - ldr r0, _0812234C @ =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, _08122350 @ =sub_81224A8 - str r0, [r1] -_08122342: - adds r0, r4, 0 - bl sub_808B5B4 - b _0812237C - .align 2, 0 -_0812234C: .4byte gTasks -_08122350: .4byte sub_81224A8 -_08122354: - movs r0, 0x5 - bl PlaySE - bl sub_8121E58 - movs r0, 0x1 - negs r0, r0 - str r5, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, _08122384 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122388 @ =sub_8122450 - str r1, [r0] -_0812237C: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08122384: .4byte gTasks -_08122388: .4byte sub_8122450 - thumb_func_end sub_81222B0 - - thumb_func_start sub_812238C -sub_812238C: @ 812238C - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - adds r4, r7, 0 - ldr r0, _081223C8 @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r3, 0x80 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _0812244A - ldr r2, _081223CC @ =gMain - ldrh r1, [r2, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081223D0 - bl GetMenuCursorPos - lsls r0, 24 - cmp r0, 0 - beq _0812244A - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - bl MoveMenuCursor - b _0812244A - .align 2, 0 -_081223C8: .4byte gPaletteFade -_081223CC: .4byte gMain -_081223D0: - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _081223F2 - bl GetMenuCursorPos - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - beq _0812244A - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - bl MoveMenuCursor - b _0812244A -_081223F2: - ldrh r1, [r2, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0812243C - movs r0, 0x5 - bl PlaySE - ldr r1, _08122430 @ =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldrb r4, [r0, 0x10] - ldr r5, _08122434 @ =gUnknown_084017D8 - ldr r6, _08122438 @ =gUnknown_084017B0 - bl GetMenuCursorPos - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - bl PartyMenuGetPopupMenuFunc - adds r1, r0, 0 - adds r0, r7, 0 - bl _call_via_r1 - b _0812244A - .align 2, 0 -_08122430: .4byte gTasks -_08122434: .4byte gUnknown_084017D8 -_08122438: .4byte gUnknown_084017B0 -_0812243C: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0812244A - adds r0, r4, 0 - bl sub_8122838 -_0812244A: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_812238C - - thumb_func_start sub_8122450 -sub_8122450: @ 8122450 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _08122478 @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08122470 - ldr r0, _0812247C @ =gMain - ldr r0, [r0, 0x8] - bl SetMainCallback2 - adds r0, r4, 0 - bl DestroyTask -_08122470: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08122478: .4byte gPaletteFade -_0812247C: .4byte gMain - thumb_func_end sub_8122450 - - thumb_func_start sub_8122480 -sub_8122480: @ 8122480 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, _081224A4 @ =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0812249A - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081224A0 -_0812249A: - adds r0, r2, 0 - bl sub_8122838 -_081224A0: - pop {r0} - bx r0 - .align 2, 0 -_081224A4: .4byte gMain - thumb_func_end sub_8122480 - - thumb_func_start sub_81224A8 -sub_81224A8: @ 81224A8 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - bl sub_81220C8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _081224D0 - movs r1, 0 - bl sub_806D538 - ldr r0, _081224CC @ =gTasks - lsls r1, r4, 2 - adds r1, r4 - b _08122518 - .align 2, 0 -_081224CC: .4byte gTasks -_081224D0: - ldr r0, _081224F8 @ =gSelectedOrderFromParty - ldrb r0, [r0] - cmp r0, 0 - beq _08122504 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, _081224FC @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122500 @ =sub_8122450 - str r1, [r0] - b _08122520 - .align 2, 0 -_081224F8: .4byte gSelectedOrderFromParty -_081224FC: .4byte gTasks -_08122500: .4byte sub_8122450 -_08122504: - movs r0, 0x20 - bl PlaySE - movs r0, 0xE - movs r1, 0 - bl sub_806D538 - ldr r0, _08122528 @ =gTasks - lsls r1, r5, 2 - adds r1, r5 -_08122518: - lsls r1, 3 - adds r1, r0 - ldr r0, _0812252C @ =sub_8122480 - str r0, [r1] -_08122520: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08122528: .4byte gTasks -_0812252C: .4byte sub_8122480 - thumb_func_end sub_81224A8 - - thumb_func_start sub_8122530 -sub_8122530: @ 8122530 - push {r4,r5,lr} - ldr r5, _08122578 @ =0x0201b260 - ldr r4, _0812257C @ =gUnknown_020384F0 -_08122536: - bl sub_806B124 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122590 - ldrb r0, [r5] - ldrb r1, [r4] - bl sub_806C994 - ldrb r0, [r5] - movs r1, 0 - bl sub_806C658 - ldrb r1, [r4] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08122580 @ =gPlayerParty - adds r0, r1 - ldr r1, _08122584 @ =gStringVar1 - bl GetMonNickname - ldr r1, _08122588 @ =gLastFieldPokeMenuOpened - ldrb r0, [r4] - strb r0, [r1] - ldrb r0, [r5] - bl sub_81221F8 - ldr r0, _0812258C @ =sub_806AEDC - bl SetMainCallback2 - b _0812259C - .align 2, 0 -_08122578: .4byte 0x0201b260 -_0812257C: .4byte gUnknown_020384F0 -_08122580: .4byte gPlayerParty -_08122584: .4byte gStringVar1 -_08122588: .4byte gLastFieldPokeMenuOpened -_0812258C: .4byte sub_806AEDC -_08122590: - bl sub_80F9344 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122536 -_0812259C: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8122530 - - thumb_func_start sub_81225A4 -sub_81225A4: @ 81225A4 - push {lr} - ldr r2, _081225C8 @ =gPaletteFade - ldrb r0, [r2, 0x8] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x8] - ldr r2, _081225CC @ =sub_812238C - movs r0, 0x4 - movs r1, 0xFF - movs r3, 0x5 - bl sub_806AF4C - ldr r0, _081225D0 @ =sub_8122530 - bl SetMainCallback2 - pop {r0} - bx r0 - .align 2, 0 -_081225C8: .4byte gPaletteFade -_081225CC: .4byte sub_812238C -_081225D0: .4byte sub_8122530 - thumb_func_end sub_81225A4 - - thumb_func_start sub_81225D4 -sub_81225D4: @ 81225D4 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, _0812263C @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _08122632 - ldr r2, _08122640 @ =gSprites - ldr r1, _08122644 @ =gTasks - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0xE] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r4, [r0, 0x2E] - lsls r4, 24 - lsrs r4, 24 - adds r0, r3, 0 - bl DestroyTask - ldr r0, _08122648 @ =0x0201b000 - ldr r1, _0812264C @ =0x00000262 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - ldr r0, _08122650 @ =gPlayerParty - ldr r1, _08122654 @ =gPlayerPartyCount - ldrb r2, [r1] - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldr r3, _08122658 @ =sub_81225A4 - str r5, [sp] - adds r1, r4, 0 - bl ShowPokemonSummaryScreen -_08122632: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_0812263C: .4byte gPaletteFade -_08122640: .4byte gSprites -_08122644: .4byte gTasks -_08122648: .4byte 0x0201b000 -_0812264C: .4byte 0x00000262 -_08122650: .4byte gPlayerParty -_08122654: .4byte gPlayerPartyCount -_08122658: .4byte sub_81225A4 - thumb_func_end sub_81225D4 - - thumb_func_start sub_812265C -sub_812265C: @ 812265C - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, _0812268C @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122690 @ =sub_81225D4 - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0812268C: .4byte gTasks -_08122690: .4byte sub_81225D4 - thumb_func_end sub_812265C - - thumb_func_start sub_8122694 -sub_8122694: @ 8122694 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r3, _081226D4 @ =gSelectedOrderFromParty - ldr r2, _081226D8 @ =gLastFieldPokeMenuOpened -_081226A0: - adds r1, r4, r3 - ldrb r0, [r1] - cmp r0, 0 - bne _081226DC - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r1] - ldrb r0, [r2] - lsls r1, r4, 3 - subs r1, r4 - lsls r1, 25 - movs r2, 0xE0 - lsls r2, 21 - adds r1, r2 - lsrs r1, 24 - bl sub_806BC3C - cmp r4, 0x2 - bne _081226CC - adds r0, r5, 0 - bl sub_806C890 -_081226CC: - adds r0, r5, 0 - bl sub_8122838 - b _08122716 - .align 2, 0 -_081226D4: .4byte gSelectedOrderFromParty -_081226D8: .4byte gLastFieldPokeMenuOpened -_081226DC: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x2 - bls _081226A0 - movs r0, 0x20 - bl PlaySE - movs r0, 0x14 - movs r1, 0xA - movs r2, 0x1D - movs r3, 0x13 - bl MenuZeroFillWindowRect - bl HandleDestroyMenuCursors - bl sub_806D5A4 - ldr r0, _0812271C @ =gOtherText_NoMoreThreePoke - movs r1, 0x1 - bl sub_806E834 - ldr r1, _08122720 @ =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122724 @ =sub_8122728 - str r1, [r0] -_08122716: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_0812271C: .4byte gOtherText_NoMoreThreePoke -_08122720: .4byte gTasks -_08122724: .4byte sub_8122728 - thumb_func_end sub_8122694 - - thumb_func_start sub_8122728 -sub_8122728: @ 8122728 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _08122768 @ =gUnknown_0202E8F6 - ldrb r0, [r0] - cmp r0, 0x1 - beq _08122760 - ldr r0, _0812276C @ =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0812274A - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08122760 -_0812274A: - movs r0, 0 - movs r1, 0xE - movs r2, 0x1D - movs r3, 0x13 - bl MenuZeroFillWindowRect - bl HandleDestroyMenuCursors - adds r0, r4, 0 - bl sub_8122838 -_08122760: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08122768: .4byte gUnknown_0202E8F6 -_0812276C: .4byte gMain - thumb_func_end sub_8122728 - - thumb_func_start sub_8122770 -sub_8122770: @ 8122770 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r4, 0 - ldr r5, _08122798 @ =gLastFieldPokeMenuOpened - ldr r3, _0812279C @ =gSelectedOrderFromParty -_0812277C: - adds r2, r4, r3 - ldrb r1, [r2] - ldrb r0, [r5] - adds r0, 0x1 - cmp r1, r0 - bne _081227B4 - movs r1, 0 - strb r1, [r2] - cmp r4, 0 - beq _081227A0 - cmp r4, 0x1 - beq _081227AC - b _081227BE - .align 2, 0 -_08122798: .4byte gLastFieldPokeMenuOpened -_0812279C: .4byte gSelectedOrderFromParty -_081227A0: - ldrb r0, [r3, 0x1] - strb r0, [r3] - ldrb r0, [r3, 0x2] - strb r0, [r3, 0x1] - strb r4, [r3, 0x2] - b _081227BE -_081227AC: - ldrb r0, [r3, 0x2] - strb r0, [r3, 0x1] - strb r1, [r3, 0x2] - b _081227BE -_081227B4: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x2 - bls _0812277C -_081227BE: - ldrb r0, [r5] - movs r1, 0x70 - bl sub_806BC3C - ldr r4, _081227F8 @ =gSelectedOrderFromParty - ldrb r0, [r4] - cmp r0, 0 - beq _081227DA - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1C - bl sub_806BC3C -_081227DA: - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _081227EC - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2A - bl sub_806BC3C -_081227EC: - adds r0, r6, 0 - bl sub_8122838 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_081227F8: .4byte gSelectedOrderFromParty - thumb_func_end sub_8122770 - - thumb_func_start sub_81227FC -sub_81227FC: @ 81227FC - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x14 - movs r1, 0xA - movs r2, 0x1D - movs r3, 0x13 - bl MenuZeroFillWindowRect - bl HandleDestroyMenuCursors - movs r0, 0 - movs r1, 0 - bl sub_806D538 - ldr r1, _08122830 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122834 @ =sub_81222B0 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08122830: .4byte gTasks -_08122834: .4byte sub_81222B0 - thumb_func_end sub_81227FC - - thumb_func_start sub_8122838 -sub_8122838: @ 8122838 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl sub_81227FC - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8122838 - thumb_func_start sub_8122854 sub_8122854: @ 8122854 push {r4,lr} diff --git a/include/battle_party_menu.h b/include/battle_party_menu.h index 11752296b..a7d46a462 100644 --- a/include/battle_party_menu.h +++ b/include/battle_party_menu.h @@ -3,19 +3,6 @@ #include "task.h" -// TODO: Unify all of the 0x0201B000 structs -struct Struct201B000 -{ - u8 filler0[0x259]; - u8 unk259; - u8 filler25A[6]; - u8 unk260; - u8 filler261[1]; - u8 unk262; - s16 unk264; - s16 unk266; -}; - struct PartyMenuItem { const u8 *text; @@ -34,6 +21,5 @@ extern u8 unk_2000000[]; void SetUpBattlePokemonMenu(u8); #define EWRAM_1609D unk_2000000[0x1609D] -#define EWRAM_1B000 (*(struct Struct201B000 *)(unk_2000000 + 0x1B000)) #endif diff --git a/include/global.h b/include/global.h index 0e7c43437..433169c21 100755 --- a/include/global.h +++ b/include/global.h @@ -610,10 +610,11 @@ struct Pokedex struct SaveBlock2_Sub { - /*0x0000, 0x00A4*/ u8 filler_000[0x3D8]; + /*0x0000, 0x00A8*/ u8 filler_000[0x3D8]; /*0x03D8, 0x0480*/ u16 var_480; /*0x03DA, 0x0482*/ u16 var_482; - /*0x03DC, 0x0484*/ u8 filler_3DC[0xD1]; + /*0x03DC, 0x0484*/ u8 filler_3DC[0xD0]; + /*0x04AC, 0x0554*/ u8 var_4AC; /*0x04AD, 0x0555*/ u8 var_4AD; /*0x04AE, 0x0556*/ u8 var_4AE; /*0x04AF, 0x0557*/ u8 var_4AF; diff --git a/include/party_menu.h b/include/party_menu.h new file mode 100644 index 000000000..a3e3422b1 --- /dev/null +++ b/include/party_menu.h @@ -0,0 +1,42 @@ +#ifndef GUARD_PARTY_MENU_H +#define GUARD_PARTY_MENU_H + +// TODO: Unify these two structs + +#define DATA_COUNT (6) +struct Unk201B000 +{ + //u8 filler0[0x260]; + struct Pokemon unk0[6]; + u8 filler258[1]; + u8 unk259; + u8 filler25A[6]; + u8 unk260; + u8 unk261; + u8 unk262; + u8 unk263; + s16 unk264[DATA_COUNT * 2]; // This may be a union + u8 filler27C[2]; + s16 unk27E; + s16 unk280; + s16 unk282; +}; + +struct Struct201B000 +{ + u8 filler0[0x259]; + u8 unk259; + u8 filler25A[6]; + u8 unk260; + u8 filler261[1]; + u8 unk262; + s16 unk264; + s16 unk266; +}; + +extern u8 ewram[]; +#define ewram1B000 (*(struct Unk201B000 *)(ewram + 0x1B000)) +#define ewram1B000_alt (*(struct Struct201B000 *)(ewram + 0x1B000)) +#define EWRAM_1B000 ewram1B000_alt + +#endif // GUARD_PARTY_MENU_H diff --git a/ld_script.txt b/ld_script.txt index b20e05223..8614e7fa1 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -231,6 +231,7 @@ SECTIONS { asm/battle_transition.o(.text); src/battle_811DA74.o(.text); asm/battle_message.o(.text); + src/choose_party.o(.text); asm/choose_party.o(.text); asm/cable_car.o(.text); asm/roulette_util.o(.text); @@ -388,6 +389,7 @@ SECTIONS { data/pokemon_menu.o(.rodata); data/option_menu.o(.rodata); src/pokedex.o(.rodata); + src/trainer_card.o(.rodata); data/trainer_card.o(.rodata); src/battle_party_menu.o(.rodata); data/pokemon_storage_system.o(.rodata); diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index 7b4eb0258..c2183e6bb 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -4,6 +4,7 @@ #include "main.h" #include "menu.h" #include "palette.h" +#include "party_menu.h" #include "pokemon.h" #include "songs.h" #include "sound.h" @@ -12,28 +13,7 @@ #include "task.h" #include "text.h" -#define DATA_COUNT (6) - extern u8 ewram[]; - -struct Unk201B000 -{ - //u8 filler0[0x260]; - struct Pokemon unk0[6]; - u8 filler258[1]; - u8 unk259; - u8 filler25A[6]; - u8 unk260; - u8 unk261; - u8 filler262[2]; - s16 unk264[DATA_COUNT * 2]; // This may be a union - u8 filler27C[2]; - s16 unk27E; - s16 unk280; - s16 unk282; -}; - -#define ewram1B000 (*(struct Unk201B000 *)(ewram + 0x1B000)) #define UNK_201606C_ARRAY (ewram + 0x1606C) // lazy define but whatever. extern u8 IsLinkDoubleBattle(void); @@ -61,7 +41,7 @@ extern void sub_806C994(); extern void sub_806BF74(); extern void sub_806AEDC(void); extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); -extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(u8), int); +extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); extern void sub_806E7D0(u8, const struct PartyPopupMenu *); extern u8 *sub_8040D08(); extern void sub_8040B8C(void); @@ -589,7 +569,7 @@ static void Task_8095330(u8 taskId) } } -static void Task_809535C(u8 taskId) +static void Task_809535C(void) { gPaletteFade.bufferTransferDisabled = TRUE; sub_806AF4C(1, 0xFF, SetUpBattlePokemonMenu, 5); diff --git a/src/choose_party.c b/src/choose_party.c new file mode 100644 index 000000000..b3c4d77d2 --- /dev/null +++ b/src/choose_party.c @@ -0,0 +1,583 @@ +#include "global.h" +#include "asm.h" +#include "menu.h" +#include "palette.h" +#include "party_menu.h" +#include "pokemon.h" +#include "songs.h" +#include "sound.h" +#include "strings.h" +#include "task.h" +#include "text.h" + +extern u8 gSelectedOrderFromParty[]; +extern u8 gPlayerPartyCount; +extern u8 gLastFieldPokeMenuOpened; +extern u8 gUnknown_020384F0; +extern u8 gUnknown_0202E8F6; +extern struct Pokemon gUnknown_030042FC[]; + +extern const u16 gBattleTowerBanlist[]; +extern const struct PartyMenuItem gUnknown_084017B0[]; +extern const struct PartyPopupMenu gUnknown_084017D8[]; + +extern void OpenPartyMenu(); +extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); +extern void LoadHeldItemIconGraphics(void); +extern void CreateHeldItemIcons_806DC34(); +extern u8 sub_806BD58(u8, u8); +extern void PartyMenuPrintMonsLevelOrStatus(void); +extern void PrintPartyMenuMonNicknames(void); +extern void sub_806BC3C(u8, u8); +extern u8 sub_806B58C(u8); +extern void sub_806D538(); +extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); +extern u16 sub_806BE38(); +extern u8 sub_806CA38(); +extern void sub_808B5B4(); +extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); +extern u8 sub_806B124(); +extern void sub_806C994(); +extern void sub_806C658(); +extern void sub_806AEDC(void); +extern void sub_806AF4C(); +extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); +extern void sub_806C890(); +extern void sub_806D5A4(); + +void sub_8121E58(void); +bool8 sub_8122030(struct Pokemon *); +void sub_812238C(u8); +void sub_8122450(u8); +void sub_81224A8(u8); +void sub_8122728(u8); +void sub_8122838(u8); + +void sub_8121E10(void) +{ + sub_8121E58(); + ewram1B000.unk263 = 0; + OpenPartyMenu(4, 0); +} + +void sub_8121E34(void) +{ + sub_8121E58(); + ewram1B000.unk263 = 1; + OpenPartyMenu(4, 0); +} + +void sub_8121E58(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + gSelectedOrderFromParty[i] = 0; +} + +//0x99 << 2 = 0x264 +//0x98 << 2 = 0x260 + +bool8 sub_8121E78(void) +{ + u8 i; + + switch (ewram1B000_alt.unk264) + { + case 0: + if (ewram1B000_alt.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(ewram1B000_alt.unk260, ewram1B000_alt.unk266, &gPlayerParty[ewram1B000_alt.unk266]); + ewram1B000_alt.unk266++; + } + else + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + if (sub_806BD58(ewram1B000_alt.unk260, ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + else + { + ewram1B000_alt.unk266++; + } + break; + case 4: + PartyMenuPrintMonsLevelOrStatus(); + ewram1B000_alt.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + ewram1B000_alt.unk264++; + break; + case 6: + for (i = 0; i < gPlayerPartyCount; i++) + { + u8 j; + + for (j = 0; j < 3; j++) + { + if (gSelectedOrderFromParty[j] == i + 1) + { + sub_806BC3C(i, j * 14 + 0x1C); + break; + } + } + if (j == 3) + { + if (sub_8122030(&gPlayerParty[i]) == TRUE) + sub_806BC3C(i, 0x70); + else + sub_806BC3C(i, 0x7E); + } + } + ewram1B000_alt.unk264++; + break; + case 7: + if (sub_806B58C(ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264 = 0; + return TRUE; + } + else + { + ewram1B000_alt.unk266++; + } + break; + } + return FALSE; +} + +#ifdef NONMATCHING +bool8 sub_8122030(struct Pokemon *pkmn) +{ + u16 r3; + s32 i; + + if (GetMonData(pkmn, MON_DATA_IS_EGG)) + return FALSE; + + if (ewram1B000.unk263 == 0) + { + if (GetMonData(pkmn, MON_DATA_HP) == 0) + return FALSE; + else + return TRUE; + } + + if ((gSaveBlock2.filler_A8.var_4AC & 1) == 0 + && GetMonData(pkmn, MON_DATA_LEVEL) > 50) + return FALSE; + + r3 = GetMonData(pkmn, MON_DATA_SPECIES); + // Can't stop the compiler from optimizing out the first index + for (i = 0; gBattleTowerBanlist[i] != 0xFFFF; i++) + { + if (gBattleTowerBanlist[i] == r3) + return FALSE; + } + return TRUE; +} +#else +__attribute__((naked)) +bool8 sub_8122030(struct Pokemon *pkmn) +{ + asm_unified( + "push {r4,lr}\n\ + adds r4, r0, 0\n\ + movs r1, 0x2D\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _0812207C\n\ + ldr r0, _08122058 @ =0x0201b000\n\ + ldr r1, _0812205C @ =0x00000263\n\ + adds r0, r1\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + bne _08122060\n\ + adds r0, r4, 0\n\ + movs r1, 0x39\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _0812207C\n\ + b _081220B6\n\ + .align 2, 0\n\ +_08122058: .4byte 0x0201b000\n\ +_0812205C: .4byte 0x00000263\n\ +_08122060:\n\ + ldr r0, _08122080 @ =gSaveBlock2\n\ + ldr r1, _08122084 @ =0x00000554\n\ + adds r0, r1\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08122088\n\ + adds r0, r4, 0\n\ + movs r1, 0x38\n\ + bl GetMonData\n\ + cmp r0, 0x32\n\ + bls _08122088\n\ +_0812207C:\n\ + movs r0, 0\n\ + b _081220B8\n\ + .align 2, 0\n\ +_08122080: .4byte gSaveBlock2\n\ +_08122084: .4byte 0x00000554\n\ +_08122088:\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + ldr r1, _081220C0 @ =gBattleTowerBanlist\n\ + movs r0, 0\n\ + lsls r0, 1\n\ + adds r2, r0, r1\n\ + ldrh r0, [r2]\n\ + ldr r1, _081220C4 @ =0x0000ffff\n\ + cmp r0, r1\n\ + beq _081220B6\n\ + adds r4, r1, 0\n\ + adds r1, r2, 0\n\ +_081220A8:\n\ + ldrh r0, [r1]\n\ + cmp r0, r3\n\ + beq _0812207C\n\ + adds r1, 0x2\n\ + ldrh r0, [r1]\n\ + cmp r0, r4\n\ + bne _081220A8\n\ +_081220B6:\n\ + movs r0, 0x1\n\ +_081220B8:\n\ + pop {r4}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_081220C0: .4byte gBattleTowerBanlist\n\ +_081220C4: .4byte 0x0000ffff\n" + ); +} +#endif + +u8 sub_81220C8(void) +{ + u8 i; + + if (ewram1B000.unk263 == 0) + return 0xFF; + if (gSelectedOrderFromParty[2] == 0) + return 0x11; + for (i = 0; i < 2; i++) + { + u8 j; + + ewram1B000.unk282 = GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[i]], MON_DATA_SPECIES); + ewram1B000.unk280 = GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[i]], MON_DATA_HELD_ITEM); + for (j = i + 1; j < 3; j++) + { + if (ewram1B000.unk282 == GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[j]], MON_DATA_SPECIES)) + return 0x12; + if (ewram1B000.unk280 != 0 && ewram1B000.unk280 == GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[j]], MON_DATA_HELD_ITEM)) + return 0x13; + } + } + return 0xFF; +} + +bool8 sub_81221CC(u8 a) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == a) + return TRUE; + } + return FALSE; +} + +void sub_81221F8(u8 taskId) +{ + sub_806D538(5, 1); + if (sub_8122030(&gPlayerParty[gLastFieldPokeMenuOpened]) == TRUE) + { + if (sub_81221CC(gLastFieldPokeMenuOpened + 1) == TRUE) + { + gTasks[taskId].data[4] = 1; + sub_806E750(1, gUnknown_084017D8, gUnknown_084017B0, 0); + } + else + { + gTasks[taskId].data[4] = 0; + sub_806E750(0, gUnknown_084017D8, gUnknown_084017B0, 0); + } + } + else + { + gTasks[taskId].data[4] = 2; + sub_806E750(2, gUnknown_084017D8, gUnknown_084017B0, 0); + } +} + +void sub_81222B0(u8 taskId) +{ + if (!gPaletteFade.active) + { + switch (sub_806BE38(taskId)) + { + case 1: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = sub_806CA38(taskId); + if (gLastFieldPokeMenuOpened != 6) + { + GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); + sub_81221F8(taskId); + gTasks[taskId].func = sub_812238C; + } + else + { + gTasks[taskId].func = sub_81224A8; + } + sub_808B5B4(taskId); + break; + case 2: + PlaySE(SE_SELECT); + sub_8121E58(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + break; + } + } +} + +// Handle input +void sub_812238C(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & 0x40) + { + if (GetMenuCursorPos() != 0) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + return; + } + if (gMain.newAndRepeatedKeys & 0x80) + { + if (GetMenuCursorPos() != 3) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + return; + } + if (gMain.newKeys & A_BUTTON) + { + TaskFunc popupMenuFunc; + + PlaySE(SE_SELECT); + popupMenuFunc = PartyMenuGetPopupMenuFunc( + gTasks[taskId].data[4], + gUnknown_084017D8, + gUnknown_084017B0, + GetMenuCursorPos()); + popupMenuFunc(taskId); + return; + } + if (gMain.newKeys & B_BUTTON) + { + sub_8122838(taskId); + return; + } + } +} + +// Return from menu? +void sub_8122450(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetMainCallback2(gMain.savedCallback); + DestroyTask(taskId); + } +} + +// Wait for A or B press +void sub_8122480(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + sub_8122838(taskId); +} + +void sub_81224A8(u8 taskId) +{ + u8 val = sub_81220C8(); + + if (val != 0xFF) + { + sub_806D538(val, 0); + gTasks[taskId].func = sub_8122480; + } + else + { + if (gSelectedOrderFromParty[0] != 0) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + } + else + { + PlaySE(SE_HAZURE); + sub_806D538(14, 0); + gTasks[taskId].func = sub_8122480; + } + } +} + +// CB2 for menu? +void sub_8122530(void) +{ + while (1) + { + if (sub_806B124() == 1) + { + sub_806C994(ewram1B000.unk260, gUnknown_020384F0); + sub_806C658(ewram1B000.unk260, 0); + GetMonNickname(&gPlayerParty[gUnknown_020384F0], gStringVar1); + gLastFieldPokeMenuOpened = gUnknown_020384F0; + sub_81221F8(ewram1B000.unk260); + SetMainCallback2(sub_806AEDC); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +void sub_81225A4(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + sub_806AF4C(4, 0xFF, sub_812238C, 5); + SetMainCallback2(sub_8122530); +} + +// Wait for fade, then show summary screen +void sub_81225D4(u8 taskId) +{ + if (!gPaletteFade.active) + { + u8 r4 = gSprites[gTasks[taskId].data[3] >> 8].data0; + + DestroyTask(taskId); + ewram1B000.unk262 = 1; + ShowPokemonSummaryScreen(gPlayerParty, r4, gPlayerPartyCount - 1, sub_81225A4, 0); + } +} + +// Summary callback? +void sub_812265C(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_81225D4; +} + +void sub_8122694(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == 0) + { + gSelectedOrderFromParty[i] = gLastFieldPokeMenuOpened + 1; + sub_806BC3C(gLastFieldPokeMenuOpened, i * 14 + 0x1C); + if (i == 2) + sub_806C890(taskId); + sub_8122838(taskId); + return; + } + } + PlaySE(SE_HAZURE); + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D5A4(); + sub_806E834(gOtherText_NoMoreThreePoke, 1); + gTasks[taskId].func = sub_8122728; +} + +void sub_8122728(u8 taskId) +{ + if (gUnknown_0202E8F6 == 1) + return; + + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + MenuZeroFillWindowRect(0, 14, 29, 19); + HandleDestroyMenuCursors(); + sub_8122838(taskId); + } +} + +void sub_8122770(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == gLastFieldPokeMenuOpened + 1) + { + gSelectedOrderFromParty[i] = 0; + switch (i) + { + case 0: + gSelectedOrderFromParty[0] = gSelectedOrderFromParty[1]; + gSelectedOrderFromParty[1] = gSelectedOrderFromParty[2]; + gSelectedOrderFromParty[2] = 0; + break; + case 1: + gSelectedOrderFromParty[1] = gSelectedOrderFromParty[2]; + gSelectedOrderFromParty[2] = 0; + break; + } + break; // exit loop + } + } + sub_806BC3C(gLastFieldPokeMenuOpened, 0x70); + if (gSelectedOrderFromParty[0] != 0) + sub_806BC3C(gSelectedOrderFromParty[0] - 1, 0x1C); + if (gSelectedOrderFromParty[1] != 0) + sub_806BC3C(gSelectedOrderFromParty[1] - 1, 0x2A); + sub_8122838(taskId); +} + +void sub_81227FC(u8 taskId) +{ + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D538(0, 0); + gTasks[taskId].func = sub_81222B0; +} + +void sub_8122838(u8 taskId) +{ + PlaySE(SE_SELECT); + sub_81227FC(taskId); +} diff --git a/src/party_menu.c b/src/party_menu.c index ad0007695..27630a366 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -15,8 +15,7 @@ #include "item.h" #include "battle_interface.h" #include "species.h" - -#define DATA_COUNT (6) +#include "party_menu.h" struct Unk2001000 { @@ -25,19 +24,6 @@ struct Unk2001000 u8 unk2; }; -struct Unk201B000 -{ - u8 filler0[0x260]; - u8 unk260; - u8 unk261; - u8 filler262[2]; - s16 unk264[DATA_COUNT * 2]; // This may be a union - u8 filler27C[2]; - s16 unk27E; - s16 unk280; - s16 unk282; -}; - struct Unk201C000 { /*0x00*/ struct Pokemon *pokemon; @@ -66,7 +52,6 @@ struct UnknownStruct5 extern u8 ewram[]; #define ewram01000 (*(struct Unk2001000 *)(ewram + 0x01000)) -#define ewram1B000 (*(struct Unk201B000 *)(ewram + 0x1B000)) #define ewram1C000 (*(struct Unk201C000 *)(ewram + 0x1C000)) #define ewram1F000 (*(struct Unk201F000 *)(ewram + 0x1F000)) diff --git a/src/script_pokemon_util_80F99CC.c b/src/script_pokemon_util_80F99CC.c index ee140187f..cb15871e5 100644 --- a/src/script_pokemon_util_80F99CC.c +++ b/src/script_pokemon_util_80F99CC.c @@ -2,6 +2,7 @@ #include "asm.h" #include "battle_party_menu.h" #include "data2.h" +#include "party_menu.h" #include "palette.h" #include "pokemon.h" #include "rom4.h" @@ -12,6 +13,8 @@ #include "task.h" #include "text.h" + + extern u8 gPlayerPartyCount; extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; From 6dca429862b60ce2e332893839698c880a8bd5e7 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Fri, 16 Jun 2017 18:28:59 -0500 Subject: [PATCH 2/7] decompile sub_8122854 - sub_81229B8 --- asm/choose_party.s | 252 --------------------------------------------- src/choose_party.c | 116 ++++++++++++++++++++- 2 files changed, 113 insertions(+), 255 deletions(-) diff --git a/asm/choose_party.s b/asm/choose_party.s index 0846a25f4..322b1b34a 100644 --- a/asm/choose_party.s +++ b/asm/choose_party.s @@ -6,258 +6,6 @@ .text - thumb_func_start sub_8122854 -sub_8122854: @ 8122854 - push {r4,lr} - ldr r1, _08122874 @ =0x0201b000 - movs r2, 0x99 - lsls r2, 2 - adds r0, r1, r2 - movs r2, 0 - ldrsh r0, [r0, r2] - adds r4, r1, 0 - cmp r0, 0x4 - bhi _081228E0 - lsls r0, 2 - ldr r1, _08122878 @ =_0812287C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08122874: .4byte 0x0201b000 -_08122878: .4byte _0812287C - .align 2, 0 -_0812287C: - .4byte _08122890 - .4byte _081228A4 - .4byte _081228AA - .4byte _081228BE - .4byte _081228D8 -_08122890: - movs r1, 0x98 - lsls r1, 2 - adds r0, r4, r1 - ldrb r0, [r0] - bl sub_81228E8 - movs r2, 0x99 - lsls r2, 2 - adds r1, r4, r2 - b _081228CA -_081228A4: - bl LoadHeldItemIconGraphics - b _081228C2 -_081228AA: - movs r1, 0x98 - lsls r1, 2 - adds r0, r4, r1 - ldrb r0, [r0] - bl sub_8122950 - movs r2, 0x99 - lsls r2, 2 - adds r1, r4, r2 - b _081228CA -_081228BE: - bl sub_81229B8 -_081228C2: - ldr r1, _081228D4 @ =0x0201b000 - movs r0, 0x99 - lsls r0, 2 - adds r1, r0 -_081228CA: - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _081228E0 - .align 2, 0 -_081228D4: .4byte 0x0201b000 -_081228D8: - bl sub_806B908 - movs r0, 0x1 - b _081228E2 -_081228E0: - movs r0, 0 -_081228E2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8122854 - - thumb_func_start sub_81228E8 -sub_81228E8: @ 81228E8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 -_081228F0: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, _08122948 @ =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08122912 - adds r0, r6, 0 - adds r1, r5, 0 - movs r2, 0x3 - adds r3, r4, 0 - bl CreatePartyMenuMonIcon -_08122912: - ldr r0, _0812294C @ =gUnknown_02023A00 - lsls r1, r5, 5 - adds r3, r1, r0 - ldrh r0, [r3] - cmp r0, 0 - beq _08122936 - adds r4, r5, 0x3 - lsls r4, 24 - lsrs r4, 24 - adds r0, r6, 0 - adds r1, r4, 0 - movs r2, 0x3 - bl CreateMonIcon_806D99C - adds r0, r6, 0 - adds r1, r4, 0 - bl sub_806D50C -_08122936: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x2 - bls _081228F0 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_08122948: .4byte gPlayerParty -_0812294C: .4byte gUnknown_02023A00 - thumb_func_end sub_81228E8 - - thumb_func_start sub_8122950 -sub_8122950: @ 8122950 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 -_08122958: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, _081229B0 @ =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08122984 - adds r0, r4, 0 - movs r1, 0xC - bl GetMonData - adds r2, r0, 0 - lsls r2, 16 - lsrs r2, 16 - adds r0, r6, 0 - adds r1, r5, 0 - bl CreateHeldItemIcon_806DCD4 -_08122984: - ldr r0, _081229B4 @ =gUnknown_02023A00 - lsls r1, r5, 5 - adds r2, r1, r0 - ldrh r0, [r2] - cmp r0, 0 - beq _0812299E - adds r1, r5, 0x3 - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r2, 0x2] - adds r0, r6, 0 - bl CreateHeldItemIcon_806DCD4 -_0812299E: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x2 - bls _08122958 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_081229B0: .4byte gPlayerParty -_081229B4: .4byte gUnknown_02023A00 - thumb_func_end sub_8122950 - - thumb_func_start sub_81229B8 -sub_81229B8: @ 81229B8 - push {r4-r7,lr} - movs r5, 0 - movs r7, 0x64 - ldr r6, _08122A00 @ =gPlayerParty -_081229C0: - adds r0, r5, 0 - muls r0, r7 - adds r4, r0, r6 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08122A36 - adds r0, r5, 0 - movs r1, 0x3 - adds r2, r4, 0 - bl PartyMenuPrintHP - adds r0, r4, 0 - bl GetMonStatusAndPokerus - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08122A04 - cmp r0, 0x6 - beq _08122A04 - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r5, 0 - movs r1, 0x3 - bl PartyMenuPutStatusTilemap - b _08122A12 - .align 2, 0 -_08122A00: .4byte gPlayerParty -_08122A04: - adds r2, r5, 0 - muls r2, r7 - adds r2, r6 - adds r0, r5, 0 - movs r1, 0x3 - bl PartyMenuPrintLevel -_08122A12: - adds r4, r5, 0 - muls r4, r7 - adds r4, r6 - adds r0, r5, 0 - movs r1, 0x3 - adds r2, r4, 0 - bl PartyMenuPutNicknameTilemap - adds r0, r5, 0 - movs r1, 0x3 - adds r2, r4, 0 - bl PrintPartyMenuMonNickname - adds r0, r5, 0 - movs r1, 0x3 - adds r2, r4, 0 - bl PartyMenuDrawHPBar -_08122A36: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x2 - bls _081229C0 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81229B8 - thumb_func_start sub_8122A48 sub_8122A48: @ 8122A48 push {r4-r6,lr} diff --git a/src/choose_party.c b/src/choose_party.c index b3c4d77d2..b08812573 100644 --- a/src/choose_party.c +++ b/src/choose_party.c @@ -10,10 +10,25 @@ #include "task.h" #include "text.h" +struct UnknownPokemonStruct2 +{ + /*0x00*/ u16 species; + /*0x02*/ u16 heldItem; + /*0x04*/ u8 nickname[11]; + /*0x0F*/ u8 level; + /*0x10*/ u16 hp; + /*0x12*/ u16 maxhp; + /*0x14*/ u32 status; + /*0x18*/ u32 personality; + /*0x1C*/ u8 gender; + /*0x1D*/ u8 language; +}; + extern u8 gSelectedOrderFromParty[]; extern u8 gPlayerPartyCount; extern u8 gLastFieldPokeMenuOpened; extern u8 gUnknown_020384F0; +extern struct UnknownPokemonStruct2 gUnknown_02023A00[]; extern u8 gUnknown_0202E8F6; extern struct Pokemon gUnknown_030042FC[]; @@ -44,6 +59,18 @@ extern void sub_806AF4C(); extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); extern void sub_806C890(); extern void sub_806D5A4(); +extern void sub_806B908(void); +extern void CreateMonIcon_806D99C(int, u8, int, struct UnknownPokemonStruct2 *); +extern void sub_806D50C(int, u8); +extern void CreatePartyMenuMonIcon(); +extern void CreateHeldItemIcon_806DCD4(int, u8, int); +extern u8 GetMonStatusAndPokerus(); +extern void PartyMenuPrintHP(); +extern void PartyMenuPutStatusTilemap(int, int, u8); +extern void PartyMenuPrintLevel(); +extern void PartyMenuPutNicknameTilemap(); +extern void PrintPartyMenuMonNickname(); +extern void PartyMenuDrawHPBar(); void sub_8121E58(void); bool8 sub_8122030(struct Pokemon *); @@ -52,6 +79,9 @@ void sub_8122450(u8); void sub_81224A8(u8); void sub_8122728(u8); void sub_8122838(u8); +void sub_81228E8(u8); +void sub_8122950(u8); +void sub_81229B8(void); void sub_8121E10(void) { @@ -75,9 +105,6 @@ void sub_8121E58(void) gSelectedOrderFromParty[i] = 0; } -//0x99 << 2 = 0x264 -//0x98 << 2 = 0x260 - bool8 sub_8121E78(void) { u8 i; @@ -581,3 +608,86 @@ void sub_8122838(u8 taskId) PlaySE(SE_SELECT); sub_81227FC(taskId); } + +bool8 sub_8122854(void) +{ + switch (ewram1B000_alt.unk264) + { + case 0: + sub_81228E8(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + sub_8122950(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + sub_81229B8(); + ewram1B000_alt.unk264++; + break; + case 4: + sub_806B908(); + return TRUE; + } + return FALSE; +} + +void sub_81228E8(u8 a) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + CreatePartyMenuMonIcon(a, i, 3, &gPlayerParty[i]); + if (gUnknown_02023A00[i].species != 0) + { + CreateMonIcon_806D99C(a, i + 3, 3, &gUnknown_02023A00[i]); + sub_806D50C(a, i + 3); + } + } +} + +void sub_8122950(u8 a) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + { + u16 item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + + CreateHeldItemIcon_806DCD4(a, i, item); + } + if (gUnknown_02023A00[i].species != 0) + CreateHeldItemIcon_806DCD4(a, i + 3, gUnknown_02023A00[i].heldItem); + } +} + +void sub_81229B8(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + { + u8 status; + + PartyMenuPrintHP(i, 3, &gPlayerParty[i]); + status = GetMonStatusAndPokerus(&gPlayerParty[i]); + if (status != 0 && status != 6) + PartyMenuPutStatusTilemap(i, 3, status - 1); + else + PartyMenuPrintLevel(i, 3, &gPlayerParty[i]); + PartyMenuPutNicknameTilemap(i, 3, &gPlayerParty[i]); + PrintPartyMenuMonNickname(i, 3, &gPlayerParty[i]); + PartyMenuDrawHPBar(i, 3, &gPlayerParty[i]); + } + } +} From c56305607a1bad264b89d07b7539eff3fe010e0d Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Fri, 16 Jun 2017 18:29:19 -0500 Subject: [PATCH 3/7] whitespace --- src/choose_party.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/choose_party.c b/src/choose_party.c index b08812573..e5005ca63 100644 --- a/src/choose_party.c +++ b/src/choose_party.c @@ -639,7 +639,7 @@ bool8 sub_8122854(void) void sub_81228E8(u8 a) { u8 i; - + for (i = 0; i < 3; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) @@ -655,13 +655,13 @@ void sub_81228E8(u8 a) void sub_8122950(u8 a) { u8 i; - + for (i = 0; i < 3; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) { u16 item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); - + CreateHeldItemIcon_806DCD4(a, i, item); } if (gUnknown_02023A00[i].species != 0) @@ -672,13 +672,13 @@ void sub_8122950(u8 a) void sub_81229B8(void) { u8 i; - + for (i = 0; i < 3; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) { u8 status; - + PartyMenuPrintHP(i, 3, &gPlayerParty[i]); status = GetMonStatusAndPokerus(&gPlayerParty[i]); if (status != 0 && status != 6) From 14b1a94d7266cc24447d34145decf818e930e747 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 17 Jun 2017 21:38:01 -0500 Subject: [PATCH 4/7] finish decompiling choose_party --- asm/choose_party.s | 953 ------------------------------- include/battle_party_menu.h | 18 +- include/pokemon_summary_screen.h | 2 +- include/songs.h | 20 +- ld_script.txt | 1 - src/battle_party_menu.c | 1 - src/choose_party.c | 337 ++++++++++- 7 files changed, 346 insertions(+), 986 deletions(-) delete mode 100644 asm/choose_party.s diff --git a/asm/choose_party.s b/asm/choose_party.s deleted file mode 100644 index 322b1b34a..000000000 --- a/asm/choose_party.s +++ /dev/null @@ -1,953 +0,0 @@ - .include "constants/gba_constants.inc" - .include "constants/species_constants.inc" - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_8122A48 -sub_8122A48: @ 8122A48 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, _08122AA0 @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08122A98 - ldr r0, _08122AA4 @ =gTasks - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - adds r4, r0 - movs r0, 0x1E - strh r0, [r4, 0x8] - ldr r5, _08122AA8 @ =gUnknown_02023A00 - ldrh r1, [r5] - adds r0, r6, 0 - movs r2, 0 - bl sub_806D4AC - ldrh r1, [r5, 0x20] - adds r0, r6, 0 - movs r2, 0x1 - bl sub_806D4AC - adds r5, 0x40 - ldrh r1, [r5] - adds r0, r6, 0 - movs r2, 0x2 - bl sub_806D4AC - ldr r0, _08122AAC @ =sub_8122AB8 - str r0, [r4] - ldr r0, _08122AB0 @ =0x0201b000 - ldr r1, _08122AB4 @ =0x00000261 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] -_08122A98: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_08122AA0: .4byte gPaletteFade -_08122AA4: .4byte gTasks -_08122AA8: .4byte gUnknown_02023A00 -_08122AAC: .4byte sub_8122AB8 -_08122AB0: .4byte 0x0201b000 -_08122AB4: .4byte 0x00000261 - thumb_func_end sub_8122A48 - - thumb_func_start sub_8122AB8 -sub_8122AB8: @ 8122AB8 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, _08122AFC @ =gUnknown_02023A00 - ldrh r1, [r0, 0x20] - adds r0, 0x40 - ldrh r2, [r0] - adds r0, r4, 0 - bl sub_806D3B4 - ldr r1, _08122B00 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r1 - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _08122AF4 - ldr r0, _08122B04 @ =sub_8122B10 - str r0, [r1] - ldr r0, _08122B08 @ =0x0201b000 - ldr r1, _08122B0C @ =0x00000261 - adds r0, r1 - movs r1, 0x2 - strb r1, [r0] - movs r0, 0x78 - bl PlaySE -_08122AF4: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08122AFC: .4byte gUnknown_02023A00 -_08122B00: .4byte gTasks -_08122B04: .4byte sub_8122B10 -_08122B08: .4byte 0x0201b000 -_08122B0C: .4byte 0x00000261 - thumb_func_end sub_8122AB8 - - thumb_func_start sub_8122B10 -sub_8122B10: @ 8122B10 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - movs r0, 0 - mov r8, r0 - ldr r1, _08122B5C @ =gUnknown_02023A00 - mov r10, r1 - ldr r2, _08122B60 @ =gStringVar1 - mov r9, r2 -_08122B2E: - mov r1, r8 - lsls r0, r1, 5 - mov r2, r10 - adds r6, r0, r2 - ldrh r1, [r6] - adds r7, r0, 0 - cmp r1, 0 - beq _08122BDA - mov r4, r8 - adds r4, 0x3 - lsls r0, r4, 24 - lsrs r5, r0, 24 - ldrh r2, [r6, 0x10] - ldrh r3, [r6, 0x12] - adds r0, r5, 0 - movs r1, 0x3 - bl PartyMenuDoPrintHP - ldrh r0, [r6, 0x10] - cmp r0, 0 - bne _08122B64 - movs r2, 0x7 - b _08122B76 - .align 2, 0 -_08122B5C: .4byte gUnknown_02023A00 -_08122B60: .4byte gStringVar1 -_08122B64: - ldr r1, _08122B88 @ =gUnknown_02023A14 - adds r0, r7, r1 - ldr r0, [r0] - bl pokemon_ailments_get_primary - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - beq _08122B8C -_08122B76: - lsls r0, r4, 24 - lsrs r0, 24 - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r1, 0x3 - bl PartyMenuPutStatusTilemap - b _08122B96 - .align 2, 0 -_08122B88: .4byte gUnknown_02023A14 -_08122B8C: - ldrb r2, [r6, 0xF] - adds r0, r5, 0 - movs r1, 0x3 - bl PartyMenuDoPrintLevel -_08122B96: - mov r2, r10 - adds r6, r7, r2 - ldrh r0, [r6] - ldrb r1, [r6, 0x1C] - lsls r4, 24 - lsrs r4, 24 - ldr r2, _08122C0C @ =gUnknown_02023A04 - adds r5, r7, r2 - str r5, [sp] - movs r2, 0x3 - adds r3, r4, 0 - bl PartyMenuDoPutNicknameTilemap - mov r0, r9 - adds r1, r5, 0 - bl StringCopy - mov r0, r9 - bl StringGetEnd10 - mov r0, r9 - bl SanitizeNameString - adds r0, r4, 0 - movs r1, 0x3 - mov r2, r9 - bl box_print - ldrh r2, [r6, 0x10] - ldrh r3, [r6, 0x12] - adds r0, r4, 0 - movs r1, 0x3 - bl PartyMenuDoDrawHPBar -_08122BDA: - mov r0, r8 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - cmp r0, 0x2 - bls _08122B2E - ldr r1, _08122C10 @ =gTasks - ldr r2, [sp, 0x4] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122C14 @ =sub_8122C18 - str r1, [r0] - movs r1, 0 - strh r1, [r0, 0x8] - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08122C0C: .4byte gUnknown_02023A04 -_08122C10: .4byte gTasks -_08122C14: .4byte sub_8122C18 - thumb_func_end sub_8122B10 - - thumb_func_start sub_8122C18 -sub_8122C18: @ 8122C18 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - ldr r2, _08122C58 @ =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 16 - movs r1, 0x80 - lsls r1, 17 - cmp r0, r1 - bne _08122C4E - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, _08122C5C @ =sub_8122450 - str r0, [r4] -_08122C4E: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08122C58: .4byte gTasks -_08122C5C: .4byte sub_8122450 - thumb_func_end sub_8122C18 - - thumb_func_start unref_sub_8122C60 -unref_sub_8122C60: @ 8122C60 - push {r4,r5,lr} - ldr r1, _08122C80 @ =0x0201b000 - movs r2, 0x99 - lsls r2, 2 - adds r0, r1, r2 - movs r2, 0 - ldrsh r0, [r0, r2] - adds r4, r1, 0 - cmp r0, 0x7 - bls _08122C76 - b _08122D8A -_08122C76: - lsls r0, 2 - ldr r1, _08122C84 @ =_08122C88 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08122C80: .4byte 0x0201b000 -_08122C84: .4byte _08122C88 - .align 2, 0 -_08122C88: - .4byte _08122CA8 - .4byte _08122CE8 - .4byte _08122CEE - .4byte _08122D02 - .4byte _08122D2C - .4byte _08122D32 - .4byte _08122D44 - .4byte _08122D5C -_08122CA8: - ldr r0, _08122CD0 @ =0x00000266 - adds r5, r4, r0 - movs r1, 0 - ldrsh r3, [r5, r1] - ldr r0, _08122CD4 @ =gPlayerPartyCount - ldrb r0, [r0] - cmp r3, r0 - bge _08122CDC - movs r2, 0x98 - lsls r2, 2 - adds r0, r4, r2 - ldrb r0, [r0] - ldrb r1, [r5] - movs r2, 0x64 - muls r2, r3 - ldr r3, _08122CD8 @ =gPlayerParty - adds r2, r3 - bl TryCreatePartyMenuMonIcon - b _08122D84 - .align 2, 0 -_08122CD0: .4byte 0x00000266 -_08122CD4: .4byte gPlayerPartyCount -_08122CD8: .4byte gPlayerParty -_08122CDC: - movs r0, 0 - strh r0, [r5] - movs r0, 0x99 - lsls r0, 2 - adds r1, r4, r0 - b _08122D50 -_08122CE8: - bl LoadHeldItemIconGraphics - b _08122D48 -_08122CEE: - movs r1, 0x98 - lsls r1, 2 - adds r0, r4, r1 - ldrb r0, [r0] - bl CreateHeldItemIcons_806DC34 - movs r2, 0x99 - lsls r2, 2 - adds r1, r4, r2 - b _08122D50 -_08122D02: - movs r1, 0x98 - lsls r1, 2 - adds r0, r4, r1 - ldrb r0, [r0] - ldr r2, _08122D28 @ =0x00000266 - adds r5, r4, r2 - ldrb r1, [r5] - bl sub_806BD58 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122D84 - movs r0, 0 - strh r0, [r5] - movs r0, 0x99 - lsls r0, 2 - adds r1, r4, r0 - b _08122D50 - .align 2, 0 -_08122D28: .4byte 0x00000266 -_08122D2C: - bl PartyMenuPrintMonsLevelOrStatus - b _08122D48 -_08122D32: - bl PrintPartyMenuMonNicknames - ldr r1, _08122D40 @ =0x0201b000 - movs r0, 0x99 - lsls r0, 2 - adds r1, r0 - b _08122D50 - .align 2, 0 -_08122D40: .4byte 0x0201b000 -_08122D44: - bl sub_806BCE8 -_08122D48: - ldr r1, _08122D58 @ =0x0201b000 - movs r2, 0x99 - lsls r2, 2 - adds r1, r2 -_08122D50: - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _08122D8A - .align 2, 0 -_08122D58: .4byte 0x0201b000 -_08122D5C: - ldr r0, _08122D80 @ =0x00000266 - adds r5, r4, r0 - ldrb r0, [r5] - bl sub_806B58C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122D84 - movs r1, 0 - strh r1, [r5] - movs r2, 0x99 - lsls r2, 2 - adds r0, r4, r2 - strh r1, [r0] - movs r0, 0x1 - b _08122D8C - .align 2, 0 -_08122D80: .4byte 0x00000266 -_08122D84: - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] -_08122D8A: - movs r0, 0 -_08122D8C: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end unref_sub_8122C60 - - thumb_func_start sub_8122D94 -sub_8122D94: @ 8122D94 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _08122DCC @ =gLastFieldPokeMenuOpened - ldrb r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08122DD0 @ =gPlayerParty - adds r0, r1 - movs r1, 0x2D - bl GetMonData - adds r2, r0, 0 - cmp r2, 0 - bne _08122DE0 - ldr r1, _08122DD4 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - strh r2, [r0, 0x10] - ldr r1, _08122DD8 @ =gUnknown_08401810 - ldr r2, _08122DDC @ =gUnknown_084017F0 - movs r0, 0 - movs r3, 0 - bl sub_806E750 - b _08122DFA - .align 2, 0 -_08122DCC: .4byte gLastFieldPokeMenuOpened -_08122DD0: .4byte gPlayerParty -_08122DD4: .4byte gTasks -_08122DD8: .4byte gUnknown_08401810 -_08122DDC: .4byte gUnknown_084017F0 -_08122DE0: - ldr r1, _08122E00 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0x1 - strh r1, [r0, 0x10] - ldr r1, _08122E04 @ =gUnknown_08401810 - ldr r2, _08122E08 @ =gUnknown_084017F0 - movs r0, 0x1 - movs r3, 0 - bl sub_806E750 -_08122DFA: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08122E00: .4byte gTasks -_08122E04: .4byte gUnknown_08401810 -_08122E08: .4byte gUnknown_084017F0 - thumb_func_end sub_8122D94 - - thumb_func_start sub_8122E0C -sub_8122E0C: @ 8122E0C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _08122E34 @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08122E9C - adds r0, r4, 0 - bl sub_806BD80 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - beq _08122E38 - cmp r0, 0x2 - beq _08122E84 - b _08122E9C - .align 2, 0 -_08122E34: .4byte gPaletteFade -_08122E38: - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl sub_806CA38 - ldr r1, _08122E70 @ =gLastFieldPokeMenuOpened - strb r0, [r1] - ldrb r1, [r1] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08122E74 @ =gPlayerParty - adds r0, r1 - ldr r1, _08122E78 @ =gStringVar1 - bl GetMonNickname - adds r0, r4, 0 - bl sub_8122D94 - ldr r1, _08122E7C @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _08122E80 @ =sub_8122EAC - str r1, [r0] - b _08122E9C - .align 2, 0 -_08122E70: .4byte gLastFieldPokeMenuOpened -_08122E74: .4byte gPlayerParty -_08122E78: .4byte gStringVar1 -_08122E7C: .4byte gTasks -_08122E80: .4byte sub_8122EAC -_08122E84: - movs r0, 0x5 - bl PlaySE - ldr r1, _08122EA4 @ =gLastFieldPokeMenuOpened - movs r0, 0xFF - strb r0, [r1] - ldr r1, _08122EA8 @ =gSpecialVar_0x8004 - movs r0, 0xFF - strh r0, [r1] - adds r0, r4, 0 - bl sub_8123138 -_08122E9C: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08122EA4: .4byte gLastFieldPokeMenuOpened -_08122EA8: .4byte gSpecialVar_0x8004 - thumb_func_end sub_8122E0C - - thumb_func_start sub_8122EAC -sub_8122EAC: @ 8122EAC - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - adds r4, r7, 0 - ldr r0, _08122EE8 @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r3, 0x80 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _08122F6A - ldr r2, _08122EEC @ =gMain - ldrh r1, [r2, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08122EF0 - bl GetMenuCursorPos - lsls r0, 24 - cmp r0, 0 - beq _08122F6A - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - bl MoveMenuCursor - b _08122F6A - .align 2, 0 -_08122EE8: .4byte gPaletteFade -_08122EEC: .4byte gMain -_08122EF0: - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08122F12 - bl GetMenuCursorPos - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - beq _08122F6A - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - bl MoveMenuCursor - b _08122F6A -_08122F12: - ldrh r1, [r2, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08122F5C - movs r0, 0x5 - bl PlaySE - ldr r1, _08122F50 @ =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldrb r4, [r0, 0x10] - ldr r5, _08122F54 @ =gUnknown_08401810 - ldr r6, _08122F58 @ =gUnknown_084017F0 - bl GetMenuCursorPos - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - bl PartyMenuGetPopupMenuFunc - adds r1, r0, 0 - adds r0, r7, 0 - bl _call_via_r1 - b _08122F6A - .align 2, 0 -_08122F50: .4byte gTasks -_08122F54: .4byte gUnknown_08401810 -_08122F58: .4byte gUnknown_084017F0 -_08122F5C: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08122F6A - adds r0, r4, 0 - bl sub_81230F4 -_08122F6A: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8122EAC - - thumb_func_start sub_8122F70 -sub_8122F70: @ 8122F70 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, _08122F88 @ =gSpecialVar_0x8004 - ldr r1, _08122F8C @ =gLastFieldPokeMenuOpened - ldrb r1, [r1] - strh r1, [r2] - bl sub_8123138 - pop {r0} - bx r0 - .align 2, 0 -_08122F88: .4byte gSpecialVar_0x8004 -_08122F8C: .4byte gLastFieldPokeMenuOpened - thumb_func_end sub_8122F70 - - thumb_func_start sub_8122F90 -sub_8122F90: @ 8122F90 - push {r4,r5,lr} - ldr r5, _08122FD8 @ =0x0201b260 - ldr r4, _08122FDC @ =gUnknown_020384F0 -_08122F96: - bl sub_806B124 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122FF0 - ldrb r0, [r5] - ldrb r1, [r4] - bl sub_806C994 - ldrb r0, [r5] - movs r1, 0 - bl sub_806BF74 - ldrb r1, [r4] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08122FE0 @ =gPlayerParty - adds r0, r1 - ldr r1, _08122FE4 @ =gStringVar1 - bl GetMonNickname - ldr r1, _08122FE8 @ =gLastFieldPokeMenuOpened - ldrb r0, [r4] - strb r0, [r1] - ldrb r0, [r5] - bl sub_8122D94 - ldr r0, _08122FEC @ =sub_806AEDC - bl SetMainCallback2 - b _08122FFC - .align 2, 0 -_08122FD8: .4byte 0x0201b260 -_08122FDC: .4byte gUnknown_020384F0 -_08122FE0: .4byte gPlayerParty -_08122FE4: .4byte gStringVar1 -_08122FE8: .4byte gLastFieldPokeMenuOpened -_08122FEC: .4byte sub_806AEDC -_08122FF0: - bl sub_80F9344 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08122F96 -_08122FFC: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8122F90 - - thumb_func_start sub_8123004 -sub_8123004: @ 8123004 - push {lr} - ldr r2, _08123028 @ =gPaletteFade - ldrb r0, [r2, 0x8] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x8] - ldr r2, _0812302C @ =sub_8122EAC - movs r0, 0x6 - movs r1, 0xFF - movs r3, 0x5 - bl sub_806AF4C - ldr r0, _08123030 @ =sub_8122F90 - bl SetMainCallback2 - pop {r0} - bx r0 - .align 2, 0 -_08123028: .4byte gPaletteFade -_0812302C: .4byte sub_8122EAC -_08123030: .4byte sub_8122F90 - thumb_func_end sub_8123004 - - thumb_func_start sub_8123034 -sub_8123034: @ 8123034 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, _0812309C @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _08123092 - ldr r2, _081230A0 @ =gSprites - ldr r1, _081230A4 @ =gTasks - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0xE] - lsls r1, 16 - asrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r4, [r0, 0x2E] - lsls r4, 24 - lsrs r4, 24 - adds r0, r3, 0 - bl DestroyTask - ldr r0, _081230A8 @ =0x0201b000 - ldr r1, _081230AC @ =0x00000262 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - ldr r0, _081230B0 @ =gPlayerParty - ldr r1, _081230B4 @ =gPlayerPartyCount - ldrb r2, [r1] - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldr r3, _081230B8 @ =sub_8123004 - str r5, [sp] - adds r1, r4, 0 - bl ShowPokemonSummaryScreen -_08123092: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_0812309C: .4byte gPaletteFade -_081230A0: .4byte gSprites -_081230A4: .4byte gTasks -_081230A8: .4byte 0x0201b000 -_081230AC: .4byte 0x00000262 -_081230B0: .4byte gPlayerParty -_081230B4: .4byte gPlayerPartyCount -_081230B8: .4byte sub_8123004 - thumb_func_end sub_8123034 - - thumb_func_start sub_81230BC -sub_81230BC: @ 81230BC - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, _081230EC @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _081230F0 @ =sub_8123034 - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_081230EC: .4byte gTasks -_081230F0: .4byte sub_8123034 - thumb_func_end sub_81230BC - - thumb_func_start sub_81230F4 -sub_81230F4: @ 81230F4 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x5 - bl PlaySE - movs r0, 0x14 - movs r1, 0xA - movs r2, 0x1D - movs r3, 0x13 - bl MenuZeroFillWindowRect - bl HandleDestroyMenuCursors - movs r0, 0xF - movs r1, 0 - bl sub_806D538 - ldr r1, _08123130 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _08123134 @ =sub_8122E0C - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08123130: .4byte gTasks -_08123134: .4byte sub_8122E0C - thumb_func_end sub_81230F4 - - thumb_func_start sub_8123138 -sub_8123138: @ 8123138 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, _08123168 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, _0812316C @ =sub_8123170 - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08123168: .4byte gTasks -_0812316C: .4byte sub_8123170 - thumb_func_end sub_8123138 - - thumb_func_start sub_8123170 -sub_8123170: @ 8123170 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _0812319C @ =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08123194 - ldr r0, _081231A0 @ =gFieldCallback - ldr r1, _081231A4 @ =sub_81231AC - str r1, [r0] - ldr r0, _081231A8 @ =c2_exit_to_overworld_2_switch - bl SetMainCallback2 - adds r0, r4, 0 - bl DestroyTask -_08123194: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0812319C: .4byte gPaletteFade -_081231A0: .4byte gFieldCallback -_081231A4: .4byte sub_81231AC -_081231A8: .4byte c2_exit_to_overworld_2_switch - thumb_func_end sub_8123170 - - thumb_func_start sub_81231AC -sub_81231AC: @ 81231AC - push {lr} - bl pal_fill_black - ldr r0, _081231C0 @ =sub_81231C4 - movs r1, 0xA - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_081231C0: .4byte sub_81231C4 - thumb_func_end sub_81231AC - - thumb_func_start sub_81231C4 -sub_81231C4: @ 81231C4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_807D770 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081231E4 - adds r0, r4, 0 - bl DestroyTask - bl ScriptContext2_Disable - bl EnableBothScriptContexts -_081231E4: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81231C4 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/battle_party_menu.h b/include/battle_party_menu.h index a7d46a462..71bd2cf51 100644 --- a/include/battle_party_menu.h +++ b/include/battle_party_menu.h @@ -1,25 +1,9 @@ #ifndef GUARD_BATTLE_PARTY_MENU_H #define GUARD_BATTLE_PARTY_MENU_H -#include "task.h" - -struct PartyMenuItem -{ - const u8 *text; - TaskFunc func; -}; - -struct PartyPopupMenu -{ - u8 unk0; - u8 unk1; - const u8 *unk4; -}; - extern u8 unk_2000000[]; +#define EWRAM_1609D unk_2000000[0x1609D] void SetUpBattlePokemonMenu(u8); -#define EWRAM_1609D unk_2000000[0x1609D] - #endif diff --git a/include/pokemon_summary_screen.h b/include/pokemon_summary_screen.h index 3f7ed8fad..71259c887 100644 --- a/include/pokemon_summary_screen.h +++ b/include/pokemon_summary_screen.h @@ -3,7 +3,7 @@ extern const u8 *const gNatureNames[]; -void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(u8), int); +void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); void sub_809D9F0(struct Pokemon *party, u8, u8, void *, u32); void sub_809D9F0(struct Pokemon *, u8, u8, void *, u32); u8 sub_809FA30(void); diff --git a/include/songs.h b/include/songs.h index 72d28a355..ab055becf 100644 --- a/include/songs.h +++ b/include/songs.h @@ -121,16 +121,16 @@ enum /*0x73*/ SE_TB_KON, /*0x74*/ SE_TB_KARA, /*0x75*/ SE_BIDORO, - SE_W085, - SE_W085B, - SE_W231, - SE_W171, - SE_W233, - SE_W233B, - SE_W145, - SE_W145B, - SE_W145C, - SE_W240, + /*0x76*/ SE_W085, + /*0x77*/ SE_W085B, + /*0x78*/ SE_W231, + /*0x79*/ SE_W171, + /*0x7A*/ SE_W233, + /*0x7B*/ SE_W233B, + /*0x7C*/ SE_W145, + /*0x7D*/ SE_W145B, + /*0x7E*/ SE_W145C, + /*0x7F*/ SE_W240, SE_W015, SE_W081, SE_W081B, diff --git a/ld_script.txt b/ld_script.txt index 8614e7fa1..bb1878069 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -232,7 +232,6 @@ SECTIONS { src/battle_811DA74.o(.text); asm/battle_message.o(.text); src/choose_party.o(.text); - asm/choose_party.o(.text); asm/cable_car.o(.text); asm/roulette_util.o(.text); asm/cable_car_util.o(.text); diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index 074ebbce0..0fbe2b0e3 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -46,7 +46,6 @@ extern void sub_806C994(); extern void sub_806BF74(); extern void sub_806AEDC(void); extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); -extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); extern void sub_806E7D0(u8, const struct PartyPopupMenu *); extern u8 *sub_8040D08(); extern void sub_8040B8C(void); diff --git a/src/choose_party.c b/src/choose_party.c index e5005ca63..f8ee61d66 100644 --- a/src/choose_party.c +++ b/src/choose_party.c @@ -1,12 +1,19 @@ #include "global.h" -#include "asm.h" +#include "decoration.h" +#include "field_fadetransition.h" +#include "main.h" #include "menu.h" +#include "name_string_util.h" #include "palette.h" #include "party_menu.h" #include "pokemon.h" +#include "pokemon_summary_screen.h" +#include "rom4.h" +#include "script.h" #include "songs.h" #include "sound.h" #include "strings.h" +#include "string_util.h" #include "task.h" #include "text.h" @@ -35,6 +42,8 @@ extern struct Pokemon gUnknown_030042FC[]; extern const u16 gBattleTowerBanlist[]; extern const struct PartyMenuItem gUnknown_084017B0[]; extern const struct PartyPopupMenu gUnknown_084017D8[]; +extern const struct PartyMenuItem gUnknown_084017F0[]; +extern const struct PartyPopupMenu gUnknown_08401810[]; extern void OpenPartyMenu(); extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); @@ -46,7 +55,6 @@ extern void PrintPartyMenuMonNicknames(void); extern void sub_806BC3C(u8, u8); extern u8 sub_806B58C(u8); extern void sub_806D538(); -extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); extern u16 sub_806BE38(); extern u8 sub_806CA38(); extern void sub_808B5B4(); @@ -66,11 +74,22 @@ extern void CreatePartyMenuMonIcon(); extern void CreateHeldItemIcon_806DCD4(int, u8, int); extern u8 GetMonStatusAndPokerus(); extern void PartyMenuPrintHP(); -extern void PartyMenuPutStatusTilemap(int, int, u8); +extern void PartyMenuPutStatusTilemap(u8, int, u8); extern void PartyMenuPrintLevel(); extern void PartyMenuPutNicknameTilemap(); extern void PrintPartyMenuMonNickname(); extern void PartyMenuDrawHPBar(); +extern bool8 sub_80F9344(void); +extern void sub_806D4AC(); +extern void sub_806D3B4(); +extern void PartyMenuDoPrintLevel(u8, u8, u8); +extern void PartyMenuDoDrawHPBar(u8, u8, u16, u16); +extern void PartyMenuDoPutNicknameTilemap(u16, u8, u8, u8, const u8 *); +extern void box_print(u8, int, const u8 *); +extern void sub_806BCE8(void); +extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); +extern u16 sub_806BD80(); +extern void sub_806BF74(); void sub_8121E58(void); bool8 sub_8122030(struct Pokemon *); @@ -82,6 +101,14 @@ void sub_8122838(u8); void sub_81228E8(u8); void sub_8122950(u8); void sub_81229B8(void); +void sub_8122AB8(u8); +void sub_8122B10(u8); +void sub_8122C18(u8); +void sub_8122EAC(u8); +void sub_81230F4(u8); +void sub_8123138(u8); +void sub_8123170(u8); +void sub_81231AC(void); void sub_8121E10(void) { @@ -691,3 +718,307 @@ void sub_81229B8(void) } } } + +void sub_8122A48(u8 taskId) +{ + if (!gPaletteFade.active) + { + gTasks[taskId].data[0] = 30; + sub_806D4AC(taskId, gUnknown_02023A00[0].species, 0); + sub_806D4AC(taskId, gUnknown_02023A00[1].species, 1); + sub_806D4AC(taskId, gUnknown_02023A00[2].species, 2); + gTasks[taskId].func = sub_8122AB8; + ewram1B000.unk261 = 1; + } +} + +void sub_8122AB8(u8 taskId) +{ + sub_806D3B4(taskId, gUnknown_02023A00[1].species, gUnknown_02023A00[2].species); + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].func = sub_8122B10; + ewram1B000.unk261 = 2; + PlaySE(SE_W231); + } +} + +void sub_8122B10(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02023A00[i].species != 0) + { + u8 r2; + + PartyMenuDoPrintHP(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); + if (gUnknown_02023A00[i].hp == 0) + r2 = 7; + else + r2 = pokemon_ailments_get_primary(gUnknown_02023A00[i].status); + if (r2 != 0) + PartyMenuPutStatusTilemap(i + 3, 3, r2 - 1); + else + PartyMenuDoPrintLevel(i + 3, 3, gUnknown_02023A00[i].level); + PartyMenuDoPutNicknameTilemap(gUnknown_02023A00[i].species, gUnknown_02023A00[i].gender, 3, i + 3, gUnknown_02023A00[i].nickname); + StringCopy(gStringVar1, gUnknown_02023A00[i].nickname); + StringGetEnd10(gStringVar1); + SanitizeNameString(gStringVar1); + box_print(i + 3, 3, gStringVar1); + PartyMenuDoDrawHPBar(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); + } + } + gTasks[taskId].func = sub_8122C18; + gTasks[taskId].data[0] = 0; +} + +void sub_8122C18(u8 taskId) +{ + gTasks[taskId].data[0]++; + if (gTasks[taskId].data[0] == 256) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + } +} + +// Exactly the same as sub_8121E78 except for case 6 +bool8 unref_sub_8122C60(void) +{ + switch (ewram1B000_alt.unk264) + { + case 0: + if (ewram1B000_alt.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(ewram1B000_alt.unk260, ewram1B000_alt.unk266, &gPlayerParty[ewram1B000_alt.unk266]); + ewram1B000_alt.unk266++; + } + else + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + if (sub_806BD58(ewram1B000_alt.unk260, ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + else + { + ewram1B000_alt.unk266++; + } + break; + case 4: + PartyMenuPrintMonsLevelOrStatus(); + ewram1B000_alt.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + ewram1B000_alt.unk264++; + break; + case 6: + sub_806BCE8(); + ewram1B000_alt.unk264++; + break; + case 7: + if (sub_806B58C(ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264 = 0; + return TRUE; + } + else + { + ewram1B000_alt.unk266++; + } + break; + } + return FALSE; +} + +void sub_8122D94(u8 taskId) +{ + if (!GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_IS_EGG)) + { + gTasks[taskId].data[4] = 0; + sub_806E750(0, gUnknown_08401810, gUnknown_084017F0, 0); + } + else + { + gTasks[taskId].data[4] = 1; + sub_806E750(1, gUnknown_08401810, gUnknown_084017F0, 0); + } +} + +void sub_8122E0C(u8 taskId) +{ + if (!gPaletteFade.active) + { + switch (sub_806BD80(taskId)) + { + case 1: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = sub_806CA38(taskId); + GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); + sub_8122D94(taskId); + gTasks[taskId].func = sub_8122EAC; + break; + case 2: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = 0xFF; + gSpecialVar_0x8004 = 0xFF; + sub_8123138(taskId); + break; + } + } +} + +void sub_8122EAC(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & 0x40) + { + if (GetMenuCursorPos() != 0) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + return; + } + if (gMain.newAndRepeatedKeys & 0x80) + { + if (GetMenuCursorPos() != 3) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + return; + } + if (gMain.newKeys & A_BUTTON) + { + TaskFunc popupMenuFunc; + + PlaySE(SE_SELECT); + popupMenuFunc = PartyMenuGetPopupMenuFunc( + gTasks[taskId].data[4], + gUnknown_08401810, + gUnknown_084017F0, + GetMenuCursorPos()); + popupMenuFunc(taskId); + return; + } + if (gMain.newKeys & B_BUTTON) + { + sub_81230F4(taskId); + return; + } + } +} + +void sub_8122F70(u8 taskId) +{ + gSpecialVar_0x8004 = gLastFieldPokeMenuOpened; + sub_8123138(taskId); +} + +void sub_8122F90(void) +{ + while (1) + { + if (sub_806B124() == 1) + { + sub_806C994(ewram1B000.unk260, gUnknown_020384F0); + sub_806BF74(ewram1B000.unk260, 0); + GetMonNickname(&gPlayerParty[gUnknown_020384F0], gStringVar1); + gLastFieldPokeMenuOpened = gUnknown_020384F0; + sub_8122D94(ewram1B000.unk260); + SetMainCallback2(sub_806AEDC); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +void sub_8123004(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + sub_806AF4C(6, 0xFF, sub_8122EAC, 5); + SetMainCallback2(sub_8122F90); +} + +void sub_8123034(u8 taskId) +{ + if (!gPaletteFade.active) + { + u8 r4 = gSprites[gTasks[taskId].data[3] >> 8].data0; + + DestroyTask(taskId); + ewram1B000.unk262 = 1; + ShowPokemonSummaryScreen(gPlayerParty, r4, gPlayerPartyCount - 1, sub_8123004, 0); + } +} + +void sub_81230BC(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8123034; +} + +void sub_81230F4(u8 taskId) +{ + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D538(15, 0); + gTasks[taskId].func = sub_8122E0C; +} + +void sub_8123138(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8123170; +} + +void sub_8123170(u8 taskId) +{ + if (!gPaletteFade.active) + { + gFieldCallback = sub_81231AC; + SetMainCallback2(c2_exit_to_overworld_2_switch); + DestroyTask(taskId); + } +} + +// Do these last two functions really belong in here? + +void sub_81231C4(u8); + +void sub_81231AC(void) +{ + pal_fill_black(); + CreateTask(sub_81231C4, 10); +} + +void sub_81231C4(u8 taskId) +{ + if (sub_807D770() == TRUE) + { + DestroyTask(taskId); + ScriptContext2_Disable(); + EnableBothScriptContexts(); + } +} From 420d4b386446fa5af9189d8361497032f5db73ee Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 17 Jun 2017 22:33:09 -0500 Subject: [PATCH 5/7] integrate data --- data/choose_party.s | 56 ------------ ld_script.txt | 2 +- src/choose_party.c | 217 +++++++++++++++++++++++++++----------------- 3 files changed, 133 insertions(+), 142 deletions(-) delete mode 100644 data/choose_party.s diff --git a/data/choose_party.s b/data/choose_party.s deleted file mode 100644 index 348f9e385..000000000 --- a/data/choose_party.s +++ /dev/null @@ -1,56 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -gUnknown_084017B0:: @ 84017B0 - .4byte OtherText_Summary, sub_812265C - .4byte OtherText_Enter2, sub_8122694 - .4byte OtherText_NoEntry, sub_8122770 - .4byte gUnknownText_Exit, sub_8122838 - -gUnknown_084017D0:: @ 84017D0 - .byte 1, 0, 3 - -gUnknown_084017D3: @ 84017D3 - .byte 2, 0, 3 - -gUnknown_084017D6: @ 84017D6 - .byte 0, 3 - - .align 2 -gUnknown_084017D8:: @ 84017D8 - .byte 3, 9 - .space 2 - .4byte gUnknown_084017D0 - - .byte 3, 9 - .space 2 - .4byte gUnknown_084017D3 - - .byte 2, 9 - .space 2 - .4byte gUnknown_084017D6 - - .align 2 -gUnknown_084017F0:: @ 84017F0 - .4byte OtherText_Store, sub_8122F70 - .4byte OtherText_Summary, sub_81230BC - .4byte gUnknownText_Exit, sub_81230F4 - -gUnknown_08401808:: @ 8401808 - .byte 0, 1, 2 - -gUnknown_0840180B:: @ 840180B - .byte 1, 2 - - .align 2 -gUnknown_08401810:: @ 8401810 - .byte 3, 9 - .space 2 - .4byte gUnknown_08401808 - - .byte 2, 9 - .space 2 - .4byte gUnknown_0840180B diff --git a/ld_script.txt b/ld_script.txt index bb1878069..f0cc111cf 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -448,7 +448,7 @@ SECTIONS { data/battle_transition.o(.rodata); data/battle_811DA74.o(.rodata); data/battle_message.o(.rodata); - data/choose_party.o(.rodata); + src/choose_party.o(.rodata); data/cable_car.o(.rodata); src/save.o(.rodata); data/field_effect_helpers.o(.rodata); diff --git a/src/choose_party.c b/src/choose_party.c index f8ee61d66..63e9c8477 100644 --- a/src/choose_party.c +++ b/src/choose_party.c @@ -38,12 +38,7 @@ extern u8 gUnknown_020384F0; extern struct UnknownPokemonStruct2 gUnknown_02023A00[]; extern u8 gUnknown_0202E8F6; extern struct Pokemon gUnknown_030042FC[]; - extern const u16 gBattleTowerBanlist[]; -extern const struct PartyMenuItem gUnknown_084017B0[]; -extern const struct PartyPopupMenu gUnknown_084017D8[]; -extern const struct PartyMenuItem gUnknown_084017F0[]; -extern const struct PartyPopupMenu gUnknown_08401810[]; extern void OpenPartyMenu(); extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); @@ -91,40 +86,39 @@ extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMen extern u16 sub_806BD80(); extern void sub_806BF74(); -void sub_8121E58(void); -bool8 sub_8122030(struct Pokemon *); -void sub_812238C(u8); -void sub_8122450(u8); -void sub_81224A8(u8); -void sub_8122728(u8); -void sub_8122838(u8); -void sub_81228E8(u8); -void sub_8122950(u8); -void sub_81229B8(void); -void sub_8122AB8(u8); -void sub_8122B10(u8); -void sub_8122C18(u8); -void sub_8122EAC(u8); -void sub_81230F4(u8); +static void ClearPartySelection(void); +static bool8 IsMonAllowedInBattleTower(struct Pokemon *); +static void sub_812238C(u8); +static void sub_8122450(u8); +static void sub_81224A8(u8); +static void sub_8122728(u8); +static void BattleTowerEntryMenuCallback_Exit(u8); +static void sub_81228E8(u8); +static void sub_8122950(u8); +static void sub_81229B8(void); +static void sub_8122AB8(u8); +static void sub_8122B10(u8); +static void sub_8122C18(u8); +static void Task_DaycareStorageMenu8122EAC(u8); void sub_8123138(u8); -void sub_8123170(u8); -void sub_81231AC(void); +static void sub_8123170(u8); +static void sub_81231AC(void); void sub_8121E10(void) { - sub_8121E58(); + ClearPartySelection(); ewram1B000.unk263 = 0; OpenPartyMenu(4, 0); } void sub_8121E34(void) { - sub_8121E58(); + ClearPartySelection(); ewram1B000.unk263 = 1; OpenPartyMenu(4, 0); } -void sub_8121E58(void) +static void ClearPartySelection(void) { u8 i; @@ -192,7 +186,7 @@ bool8 sub_8121E78(void) } if (j == 3) { - if (sub_8122030(&gPlayerParty[i]) == TRUE) + if (IsMonAllowedInBattleTower(&gPlayerParty[i]) == TRUE) sub_806BC3C(i, 0x70); else sub_806BC3C(i, 0x7E); @@ -217,7 +211,7 @@ bool8 sub_8121E78(void) } #ifdef NONMATCHING -bool8 sub_8122030(struct Pokemon *pkmn) +static bool8 IsMonAllowedInBattleTower(struct Pokemon *pkmn) { u16 r3; s32 i; @@ -248,7 +242,7 @@ bool8 sub_8122030(struct Pokemon *pkmn) } #else __attribute__((naked)) -bool8 sub_8122030(struct Pokemon *pkmn) +static bool8 IsMonAllowedInBattleTower(struct Pokemon *pkmn) { asm_unified( "push {r4,lr}\n\ @@ -329,7 +323,7 @@ _081220C4: .4byte 0x0000ffff\n" } #endif -u8 sub_81220C8(void) +static u8 sub_81220C8(void) { u8 i; @@ -354,38 +348,67 @@ u8 sub_81220C8(void) return 0xFF; } -bool8 sub_81221CC(u8 a) +//------------------------------------------------------------------------------ +// Battle Tower Entry Menu +//------------------------------------------------------------------------------ + +static void BattleTowerEntryMenuCallback_Summary(u8); +static void BattleTowerEntryMenuCallback_Enter(u8); +static void BattleTowerEntryMenuCallback_NoEntry(u8); +static void BattleTowerEntryMenuCallback_Exit(u8); + +static const struct PartyMenuItem sBattleTowerEntryMenuItems[] = +{ + {OtherText_Summary, BattleTowerEntryMenuCallback_Summary}, + {OtherText_Enter2, BattleTowerEntryMenuCallback_Enter}, + {OtherText_NoEntry, BattleTowerEntryMenuCallback_NoEntry}, + {gUnknownText_Exit, BattleTowerEntryMenuCallback_Exit}, +}; + +static const u8 gUnknown_084017D0[] = {1, 0, 3}; +static const u8 gUnknown_084017D3[] = {2, 0, 3}; +static const u8 gUnknown_084017D6[] = {0, 3}; + +static const struct PartyPopupMenu sBattleTowerEntryMenu[] = +{ + {ARRAY_COUNT(gUnknown_084017D0), 9, gUnknown_084017D0}, + {ARRAY_COUNT(gUnknown_084017D3), 9, gUnknown_084017D3}, + {ARRAY_COUNT(gUnknown_084017D6), 9, gUnknown_084017D6}, +}; + + +static bool8 IsPartyMemberAlreadySelected(u8 partyMember) { u8 i; for (i = 0; i < 3; i++) { - if (gSelectedOrderFromParty[i] == a) + if (gSelectedOrderFromParty[i] == partyMember) return TRUE; } return FALSE; } -void sub_81221F8(u8 taskId) +static void sub_81221F8(u8 taskId) { sub_806D538(5, 1); - if (sub_8122030(&gPlayerParty[gLastFieldPokeMenuOpened]) == TRUE) + if (IsMonAllowedInBattleTower(&gPlayerParty[gLastFieldPokeMenuOpened]) == TRUE) { - if (sub_81221CC(gLastFieldPokeMenuOpened + 1) == TRUE) + if (IsPartyMemberAlreadySelected(gLastFieldPokeMenuOpened + 1) == TRUE) { gTasks[taskId].data[4] = 1; - sub_806E750(1, gUnknown_084017D8, gUnknown_084017B0, 0); + sub_806E750(1, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); } else { gTasks[taskId].data[4] = 0; - sub_806E750(0, gUnknown_084017D8, gUnknown_084017B0, 0); + sub_806E750(0, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); } } else { gTasks[taskId].data[4] = 2; - sub_806E750(2, gUnknown_084017D8, gUnknown_084017B0, 0); + sub_806E750(2, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); } } @@ -412,7 +435,7 @@ void sub_81222B0(u8 taskId) break; case 2: PlaySE(SE_SELECT); - sub_8121E58(); + ClearPartySelection(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); gTasks[taskId].func = sub_8122450; break; @@ -421,7 +444,7 @@ void sub_81222B0(u8 taskId) } // Handle input -void sub_812238C(u8 taskId) +static void sub_812238C(u8 taskId) { if (!gPaletteFade.active) { @@ -450,22 +473,22 @@ void sub_812238C(u8 taskId) PlaySE(SE_SELECT); popupMenuFunc = PartyMenuGetPopupMenuFunc( gTasks[taskId].data[4], - gUnknown_084017D8, - gUnknown_084017B0, + sBattleTowerEntryMenu, + sBattleTowerEntryMenuItems, GetMenuCursorPos()); popupMenuFunc(taskId); return; } if (gMain.newKeys & B_BUTTON) { - sub_8122838(taskId); + BattleTowerEntryMenuCallback_Exit(taskId); return; } } } // Return from menu? -void sub_8122450(u8 taskId) +static void sub_8122450(u8 taskId) { if (!gPaletteFade.active) { @@ -475,13 +498,13 @@ void sub_8122450(u8 taskId) } // Wait for A or B press -void sub_8122480(u8 taskId) +static void sub_8122480(u8 taskId) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) - sub_8122838(taskId); + BattleTowerEntryMenuCallback_Exit(taskId); } -void sub_81224A8(u8 taskId) +static void sub_81224A8(u8 taskId) { u8 val = sub_81220C8(); @@ -507,7 +530,7 @@ void sub_81224A8(u8 taskId) } // CB2 for menu? -void sub_8122530(void) +static void sub_8122530(void) { while (1) { @@ -526,7 +549,7 @@ void sub_8122530(void) } } -void sub_81225A4(void) +static void sub_81225A4(void) { gPaletteFade.bufferTransferDisabled = TRUE; sub_806AF4C(4, 0xFF, sub_812238C, 5); @@ -534,7 +557,7 @@ void sub_81225A4(void) } // Wait for fade, then show summary screen -void sub_81225D4(u8 taskId) +static void sub_81225D4(u8 taskId) { if (!gPaletteFade.active) { @@ -547,13 +570,13 @@ void sub_81225D4(u8 taskId) } // Summary callback? -void sub_812265C(u8 taskId) +static void BattleTowerEntryMenuCallback_Summary(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); gTasks[taskId].func = sub_81225D4; } -void sub_8122694(u8 taskId) +static void BattleTowerEntryMenuCallback_Enter(u8 taskId) { u8 i; @@ -565,7 +588,7 @@ void sub_8122694(u8 taskId) sub_806BC3C(gLastFieldPokeMenuOpened, i * 14 + 0x1C); if (i == 2) sub_806C890(taskId); - sub_8122838(taskId); + BattleTowerEntryMenuCallback_Exit(taskId); return; } } @@ -577,7 +600,7 @@ void sub_8122694(u8 taskId) gTasks[taskId].func = sub_8122728; } -void sub_8122728(u8 taskId) +static void sub_8122728(u8 taskId) { if (gUnknown_0202E8F6 == 1) return; @@ -586,11 +609,11 @@ void sub_8122728(u8 taskId) { MenuZeroFillWindowRect(0, 14, 29, 19); HandleDestroyMenuCursors(); - sub_8122838(taskId); + BattleTowerEntryMenuCallback_Exit(taskId); } } -void sub_8122770(u8 taskId) +static void BattleTowerEntryMenuCallback_NoEntry(u8 taskId) { u8 i; @@ -619,10 +642,10 @@ void sub_8122770(u8 taskId) sub_806BC3C(gSelectedOrderFromParty[0] - 1, 0x1C); if (gSelectedOrderFromParty[1] != 0) sub_806BC3C(gSelectedOrderFromParty[1] - 1, 0x2A); - sub_8122838(taskId); + BattleTowerEntryMenuCallback_Exit(taskId); } -void sub_81227FC(u8 taskId) +static void sub_81227FC(u8 taskId) { MenuZeroFillWindowRect(20, 10, 29, 19); HandleDestroyMenuCursors(); @@ -630,7 +653,7 @@ void sub_81227FC(u8 taskId) gTasks[taskId].func = sub_81222B0; } -void sub_8122838(u8 taskId) +static void BattleTowerEntryMenuCallback_Exit(u8 taskId) { PlaySE(SE_SELECT); sub_81227FC(taskId); @@ -663,7 +686,7 @@ bool8 sub_8122854(void) return FALSE; } -void sub_81228E8(u8 a) +static void sub_81228E8(u8 a) { u8 i; @@ -679,7 +702,7 @@ void sub_81228E8(u8 a) } } -void sub_8122950(u8 a) +static void sub_8122950(u8 a) { u8 i; @@ -696,7 +719,7 @@ void sub_8122950(u8 a) } } -void sub_81229B8(void) +static void sub_81229B8(void) { u8 i; @@ -732,7 +755,7 @@ void sub_8122A48(u8 taskId) } } -void sub_8122AB8(u8 taskId) +static void sub_8122AB8(u8 taskId) { sub_806D3B4(taskId, gUnknown_02023A00[1].species, gUnknown_02023A00[2].species); if (gTasks[taskId].data[0] == 0) @@ -743,16 +766,16 @@ void sub_8122AB8(u8 taskId) } } -void sub_8122B10(u8 taskId) +static void sub_8122B10(u8 taskId) { u8 i; - + for (i = 0; i < 3; i++) { if (gUnknown_02023A00[i].species != 0) { u8 r2; - + PartyMenuDoPrintHP(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); if (gUnknown_02023A00[i].hp == 0) r2 = 7; @@ -774,7 +797,7 @@ void sub_8122B10(u8 taskId) gTasks[taskId].data[0] = 0; } -void sub_8122C18(u8 taskId) +static void sub_8122C18(u8 taskId) { gTasks[taskId].data[0]++; if (gTasks[taskId].data[0] == 256) @@ -848,17 +871,41 @@ bool8 unref_sub_8122C60(void) return FALSE; } -void sub_8122D94(u8 taskId) +//------------------------------------------------------------------------------ +// Daycare Pokemon Storage Menu +//------------------------------------------------------------------------------ + +static void DaycareStorageMenuCallback_Store(u8); +static void DaycareStorageMenuCallback_Summary(u8); +static void DaycareStorageMenuCallback_Exit(u8); + +static const struct PartyMenuItem sDaycareStorageMenuItems[] = +{ + {OtherText_Store, DaycareStorageMenuCallback_Store}, + {OtherText_Summary, DaycareStorageMenuCallback_Summary}, + {gUnknownText_Exit, DaycareStorageMenuCallback_Exit}, +}; + +static const u8 gUnknown_08401808[] = {0, 1, 2}; +static const u8 gUnknown_0840180B[] = {1, 2}; + +static const struct PartyPopupMenu sDaycareStorageMenus[] = +{ + {ARRAY_COUNT(gUnknown_08401808), 9, gUnknown_08401808}, + {ARRAY_COUNT(gUnknown_0840180B), 9, gUnknown_0840180B}, +}; + +static void sub_8122D94(u8 taskId) { if (!GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_IS_EGG)) { gTasks[taskId].data[4] = 0; - sub_806E750(0, gUnknown_08401810, gUnknown_084017F0, 0); + sub_806E750(0, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); } else { gTasks[taskId].data[4] = 1; - sub_806E750(1, gUnknown_08401810, gUnknown_084017F0, 0); + sub_806E750(1, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); } } @@ -873,7 +920,7 @@ void sub_8122E0C(u8 taskId) gLastFieldPokeMenuOpened = sub_806CA38(taskId); GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); sub_8122D94(taskId); - gTasks[taskId].func = sub_8122EAC; + gTasks[taskId].func = Task_DaycareStorageMenu8122EAC; break; case 2: PlaySE(SE_SELECT); @@ -885,7 +932,7 @@ void sub_8122E0C(u8 taskId) } } -void sub_8122EAC(u8 taskId) +static void Task_DaycareStorageMenu8122EAC(u8 taskId) { if (!gPaletteFade.active) { @@ -914,27 +961,27 @@ void sub_8122EAC(u8 taskId) PlaySE(SE_SELECT); popupMenuFunc = PartyMenuGetPopupMenuFunc( gTasks[taskId].data[4], - gUnknown_08401810, - gUnknown_084017F0, + sDaycareStorageMenus, + sDaycareStorageMenuItems, GetMenuCursorPos()); popupMenuFunc(taskId); return; } if (gMain.newKeys & B_BUTTON) { - sub_81230F4(taskId); + DaycareStorageMenuCallback_Exit(taskId); return; } } } -void sub_8122F70(u8 taskId) +static void DaycareStorageMenuCallback_Store(u8 taskId) { gSpecialVar_0x8004 = gLastFieldPokeMenuOpened; sub_8123138(taskId); } -void sub_8122F90(void) +static void sub_8122F90(void) { while (1) { @@ -953,32 +1000,32 @@ void sub_8122F90(void) } } -void sub_8123004(void) +static void sub_8123004(void) { gPaletteFade.bufferTransferDisabled = TRUE; - sub_806AF4C(6, 0xFF, sub_8122EAC, 5); + sub_806AF4C(6, 0xFF, Task_DaycareStorageMenu8122EAC, 5); SetMainCallback2(sub_8122F90); } -void sub_8123034(u8 taskId) +static void sub_8123034(u8 taskId) { if (!gPaletteFade.active) { u8 r4 = gSprites[gTasks[taskId].data[3] >> 8].data0; - + DestroyTask(taskId); ewram1B000.unk262 = 1; ShowPokemonSummaryScreen(gPlayerParty, r4, gPlayerPartyCount - 1, sub_8123004, 0); } } -void sub_81230BC(u8 taskId) +static void DaycareStorageMenuCallback_Summary(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); gTasks[taskId].func = sub_8123034; } -void sub_81230F4(u8 taskId) +static void DaycareStorageMenuCallback_Exit(u8 taskId) { PlaySE(SE_SELECT); MenuZeroFillWindowRect(20, 10, 29, 19); @@ -993,7 +1040,7 @@ void sub_8123138(u8 taskId) gTasks[taskId].func = sub_8123170; } -void sub_8123170(u8 taskId) +static void sub_8123170(u8 taskId) { if (!gPaletteFade.active) { @@ -1005,7 +1052,7 @@ void sub_8123170(u8 taskId) // Do these last two functions really belong in here? -void sub_81231C4(u8); +static void sub_81231C4(u8); void sub_81231AC(void) { @@ -1013,7 +1060,7 @@ void sub_81231AC(void) CreateTask(sub_81231C4, 10); } -void sub_81231C4(u8 taskId) +static void sub_81231C4(u8 taskId) { if (sub_807D770() == TRUE) { From 87bd7f4484dcccd2f87791d9c4654b52216675ca Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 17 Jun 2017 22:55:11 -0500 Subject: [PATCH 6/7] add functions to header --- include/choose_party.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/choose_party.h b/include/choose_party.h index 1e575a355..e31aa3c02 100644 --- a/include/choose_party.h +++ b/include/choose_party.h @@ -3,6 +3,11 @@ void sub_8121E10(void); void sub_8121E34(void); -void sub_8123138(u8); +bool8 sub_8121E78(void); +void sub_81222B0(u8 taskId); +bool8 sub_8122854(void); +void sub_8122A48(u8 taskId); +void sub_8122E0C(u8 taskId); +void sub_8123138(u8 taskId); #endif // GUARD_CHOOSE_PARTY_H From 2f31720f6b58f0d929adb3cf69f257f30621c03c Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Mon, 19 Jun 2017 23:57:27 -0500 Subject: [PATCH 7/7] revert gBufferedMoves to gSelectedOrderFromParty --- asm/battle_message.s | 26 +++++++++++++------------- asm/battle_tower.s | 8 ++++---- src/script_pokemon_util_80C4BF0.c | 10 +++++----- sym_ewram.txt | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/asm/battle_message.s b/asm/battle_message.s index 414213737..badbf2b7d 100644 --- a/asm/battle_message.s +++ b/asm/battle_message.s @@ -16,7 +16,7 @@ BufferStringBattle: @ 8120AA8 lsls r0, 16 lsrs r7, r0, 16 movs r6, 0 - ldr r5, _08120B70 @ =gBufferedMoves + ldr r5, _08120B70 @ =gSelectedOrderFromParty ldr r4, _08120B74 @ =gActiveBank ldrb r1, [r4] lsls r1, 9 @@ -73,7 +73,7 @@ _08120B10: movs r2, 0 ldr r0, _08120B9C @ =gBattleTextBuff1 mov r8, r0 - ldr r3, _08120B70 @ =gBufferedMoves + ldr r3, _08120B70 @ =gSelectedOrderFromParty ldr r1, _08120BA4 @ =gBattleTextBuff2 mov r12, r1 ldr r5, _08120BA8 @ =gBattleTextBuff3 @@ -111,7 +111,7 @@ _08120B64: ldr r0, [r0] mov pc, r0 .align 2, 0 -_08120B70: .4byte gBufferedMoves +_08120B70: .4byte gSelectedOrderFromParty _08120B74: .4byte gActiveBank _08120B78: .4byte gUnknown_02023A64 _08120B7C: .4byte gLastUsedItem @@ -414,7 +414,7 @@ _08120DE4: .4byte gUnknown_08400622 _08120DE8: mov r0, r10 bl sub_8121D1C - ldr r0, _08120E14 @ =gBufferedMoves + ldr r0, _08120E14 @ =gSelectedOrderFromParty ldr r2, [r0] ldrh r1, [r2] movs r0, 0xB1 @@ -433,7 +433,7 @@ _08120DE8: bl StringCopy b _08120E38 .align 2, 0 -_08120E14: .4byte gBufferedMoves +_08120E14: .4byte gSelectedOrderFromParty _08120E18: .4byte gBattleTextBuff2 _08120E1C: .4byte gUnknown_08401674 _08120E20: .4byte 0x02000000 @@ -1368,7 +1368,7 @@ _081215E8: .align 2, 0 _081215F4: .4byte gBattlePartyID _081215F8: - ldr r0, _08121610 @ =gBufferedMoves + ldr r0, _08121610 @ =gSelectedOrderFromParty ldr r2, [r0] ldrh r1, [r2] movs r0, 0xB1 @@ -1380,14 +1380,14 @@ _081215F8: adds r0, r2 b _08121634 .align 2, 0 -_08121610: .4byte gBufferedMoves +_08121610: .4byte gSelectedOrderFromParty _08121614: .4byte 0x02000000 _08121618: .4byte 0x000160a0 _0812161C: ldrh r1, [r2] b _08121652 _08121620: - ldr r0, _08121640 @ =gBufferedMoves + ldr r0, _08121640 @ =gSelectedOrderFromParty ldr r2, [r0] ldrh r1, [r2, 0x2] movs r0, 0xB1 @@ -1404,7 +1404,7 @@ _08121634: adds r4, r0, r1 b _081219E6 .align 2, 0 -_08121640: .4byte gBufferedMoves +_08121640: .4byte gSelectedOrderFromParty _08121644: .4byte 0x02000000 _08121648: .4byte 0x000160a0 _0812164C: .4byte gUnknown_08401674 @@ -2274,7 +2274,7 @@ sub_8121D1C: @ 8121D1C push {r4,r5,lr} adds r4, r0, 0 movs r2, 0 - ldr r5, _08121D50 @ =gBufferedMoves + ldr r5, _08121D50 @ =gSelectedOrderFromParty ldr r3, _08121D54 @ =gUnknown_084016BC _08121D26: cmp r2, 0x4 @@ -2299,7 +2299,7 @@ _08121D3C: bl StringCopy b _08121D68 .align 2, 0 -_08121D50: .4byte gBufferedMoves +_08121D50: .4byte gSelectedOrderFromParty _08121D54: .4byte gUnknown_084016BC _08121D58: .4byte gUnknown_08400E5E _08121D5C: @@ -2329,7 +2329,7 @@ _08121D7E: cmp r0, 0xFF bne _08121D7C ldr r1, _08121DB4 @ =gUnknown_084016BC - ldr r5, _08121DB8 @ =gBufferedMoves + ldr r5, _08121DB8 @ =gSelectedOrderFromParty movs r0, 0 lsls r0, 1 adds r2, r0, r1 @@ -2356,7 +2356,7 @@ _08121DA8: mov pc, r0 .align 2, 0 _08121DB4: .4byte gUnknown_084016BC -_08121DB8: .4byte gBufferedMoves +_08121DB8: .4byte gSelectedOrderFromParty _08121DBC: .4byte _08121DC0 .align 2, 0 _08121DC0: diff --git a/asm/battle_tower.s b/asm/battle_tower.s index ee8e18198..a8305b2b1 100644 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -2324,7 +2324,7 @@ _08135750: .4byte 0x00000564 _08135754: movs r2, 0 ldr r4, _0813576C @ =gSaveBlock2 + 0x565 - ldr r3, _08135770 @ =gBufferedMoves + ldr r3, _08135770 @ =gSelectedOrderFromParty _0813575A: adds r0, r2, r4 adds r1, r2, r3 @@ -2336,7 +2336,7 @@ _0813575A: b _0813589A .align 2, 0 _0813576C: .4byte gSaveBlock2 + 0x565 -_08135770: .4byte gBufferedMoves +_08135770: .4byte gSelectedOrderFromParty _08135774: ldr r3, _081357C0 @ =0x00000564 adds r0, r5, r3 @@ -2665,7 +2665,7 @@ _08135A10: .4byte 0x00000554 sub_8135A14: @ 8135A14 push {r4,lr} movs r2, 0 - ldr r4, _08135A34 @ =gBufferedMoves + ldr r4, _08135A34 @ =gSelectedOrderFromParty ldr r3, _08135A38 @ =gSaveBlock2 + 0x565 _08135A1C: adds r0, r2, r4 @@ -2680,7 +2680,7 @@ _08135A1C: pop {r0} bx r0 .align 2, 0 -_08135A34: .4byte gBufferedMoves +_08135A34: .4byte gSelectedOrderFromParty _08135A38: .4byte gSaveBlock2 + 0x565 thumb_func_end sub_8135A14 diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index fb72be527..c8171db52 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -31,7 +31,7 @@ extern struct SpriteTemplate gUnknown_02024E8C; extern u8 gContestPlayerMonIndex; extern u8 gIsLinkContest; extern u8 gPlayerPartyCount; -extern u8 gBufferedMoves[]; +extern u8 gSelectedOrderFromParty[]; extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; @@ -648,7 +648,7 @@ void sub_80C5568(void) void sub_80C5580(void) { - u8 var = gBufferedMoves[0]; + u8 var = gSelectedOrderFromParty[0]; switch(var) { @@ -671,7 +671,7 @@ void ChooseBattleTowerPlayerParty(void) void SetBattleTowerPlayerParty(void) { - u8 var = gBufferedMoves[0]; + u8 var = gSelectedOrderFromParty[0]; switch(var) { @@ -697,8 +697,8 @@ void ReducePlayerPartyToThree(void) // copy the selected pokemon according to the order. for(i = 0; i < 3; i++) - if(gBufferedMoves[i]) // as long as the order keeps going (did the player select 1 mon? 2? 3?), do not stop - party[i] = gPlayerParty[gBufferedMoves[i] - 1]; // index is 0 based, not literal + if(gSelectedOrderFromParty[i]) // as long as the order keeps going (did the player select 1 mon? 2? 3?), do not stop + party[i] = gPlayerParty[gSelectedOrderFromParty[i] - 1]; // index is 0 based, not literal // delete the last 3 pokemon CpuFill32(0, gPlayerParty, sizeof gPlayerParty); diff --git a/sym_ewram.txt b/sym_ewram.txt index 9f810eba7..42b0982ab 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -928,7 +928,7 @@ gUnknown_0203926A: @ 203926A gAbilitiesPerBank: @ 203926C .space 0x4 -gBufferedMoves: @ 2039270 +gSelectedOrderFromParty: @ 2039270 .space 0x4 gUnknown_02039274: @ 2039274