diff --git a/asm/party_menu.s b/asm/party_menu.s index 67fdab266..f8b75c036 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -4,1145 +4,6 @@ .syntax unified .text - - thumb_func_start sub_81B0038 -sub_81B0038: @ 81B0038 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r4, [sp, 0x24] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - lsls r2, 24 - lsrs r7, r2, 24 - lsls r3, 24 - lsrs r3, 24 - str r3, [sp] - lsls r4, 24 - lsrs r6, r4, 24 - bl reset_brm - ldr r0, =gUnknown_0203CEC4 - mov r10, r0 - movs r0, 0x8E - lsls r0, 2 - bl Alloc - adds r5, r0, 0 - mov r1, r10 - str r5, [r1] - cmp r5, 0 - bne _081B0088 - ldr r0, [sp, 0x2C] - bl SetMainCallback2 - b _081B0194 - .pool -_081B0088: - ldr r3, =gUnknown_0203CEC8 - movs r1, 0xF - mov r4, r8 - ands r1, r4 - ldrb r2, [r3, 0x8] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x8] - ldr r0, [sp, 0x2C] - str r0, [r3] - movs r4, 0 - strb r7, [r3, 0xB] - lsls r2, r6, 2 - ldrh r1, [r5, 0xA] - movs r0, 0x3 - ands r0, r1 - orrs r0, r2 - strh r0, [r5, 0xA] - ldr r0, [sp, 0x28] - str r0, [r5] - str r4, [r5, 0x4] - ldrb r1, [r5, 0x8] - movs r0, 0xF - negs r0, r0 - ands r0, r1 - strb r0, [r5, 0x8] - mov r1, r10 - ldr r2, [r1] - ldrh r0, [r2, 0x8] - movs r4, 0xFE - lsls r4, 3 - adds r1, r4, 0 - orrs r0, r1 - strh r0, [r2, 0x8] - ldr r0, [r2, 0x8] - movs r1, 0xFE - lsls r1, 10 - orrs r0, r1 - str r0, [r2, 0x8] - adds r6, r3, 0 - mov r5, r8 - cmp r5, 0x4 - bne _081B00F0 - ldrb r0, [r2, 0x8] - movs r1, 0x1 - orrs r0, r1 - b _081B00F8 - .pool -_081B00F0: - ldrb r1, [r2, 0x8] - movs r0, 0x2 - negs r0, r0 - ands r0, r1 -_081B00F8: - strb r0, [r2, 0x8] - mov r0, r9 - cmp r0, 0xFF - beq _081B0114 - movs r0, 0x3 - mov r1, r9 - ands r0, r1 - lsls r0, 4 - ldrb r2, [r6, 0x8] - movs r1, 0x31 - negs r1, r1 - ands r1, r2 - orrs r1, r0 - strb r1, [r6, 0x8] -_081B0114: - movs r2, 0 - ldr r5, =gUnknown_0203CEC4 - movs r4, 0x86 - lsls r4, 2 - movs r3, 0 -_081B011E: - ldr r0, [r5] - lsls r1, r2, 1 - adds r0, r4 - adds r0, r1 - strh r3, [r0] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0xF - bls _081B011E - movs r2, 0 - ldr r4, =gUnknown_0203CEC4 - movs r3, 0xFF -_081B0138: - ldr r0, [r4] - adds r0, 0xC - adds r0, r2 - ldrb r1, [r0] - orrs r1, r3 - strb r1, [r0] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0x2 - bls _081B0138 - ldr r4, [sp] - cmp r4, 0 - bne _081B015C - strb r4, [r6, 0x9] - b _081B017E - .pool -_081B015C: - adds r1, r6, 0 - movs r0, 0x9 - ldrsb r0, [r1, r0] - cmp r0, 0x5 - bgt _081B017A - adds r1, r0, 0 - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - bne _081B017E -_081B017A: - movs r0, 0 - strb r0, [r6, 0x9] -_081B017E: - ldr r2, =gTextFlags - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - bl CalculatePlayerPartyCount - ldr r0, =c2_811EBD0 - bl SetMainCallback2 -_081B0194: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B0038 - - thumb_func_start sub_81B01B0 -sub_81B01B0: @ 81B01B0 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl do_scheduled_bg_tilemap_copies_to_vram - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_81B01B0 - - thumb_func_start sub_81B01CC -sub_81B01CC: @ 81B01CC - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_81B01CC - - thumb_func_start c2_811EBD0 -c2_811EBD0: @ 81B01E0 - push {lr} -_081B01E2: - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081B0206 - bl sub_81B020C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081B0206 - bl sub_81221AC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081B01E2 -_081B0206: - pop {r0} - bx r0 - thumb_func_end c2_811EBD0 - - thumb_func_start sub_81B020C -sub_81B020C: @ 81B020C - push {r4,lr} - sub sp, 0x4 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0x16 - bls _081B0222 - b _081B0498 -_081B0222: - lsls r0, 2 - ldr r1, =_081B0234 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081B0234: - .4byte _081B0290 - .4byte _081B02AC - .4byte _081B02B2 - .4byte _081B02D4 - .4byte _081B02DA - .4byte _081B02EC - .4byte _081B02FE - .4byte _081B0310 - .4byte _081B0338 - .4byte _081B0354 - .4byte _081B0368 - .4byte _081B038C - .4byte _081B03A0 - .4byte _081B03A6 - .4byte _081B03B8 - .4byte _081B03BE - .4byte _081B03E0 - .4byte _081B0400 - .4byte _081B0414 - .4byte _081B0428 - .4byte _081B0430 - .4byte _081B044C - .4byte _081B0474 -_081B0290: - bl SetVBlankHBlankCallbacksToNull - bl ResetVramOamAndBgCntRegs - bl clear_scheduled_bg_copies_to_vram - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B02AC: - bl ScanlineEffect_Stop - b _081B0484 -_081B02B2: - bl ResetPaletteFade - ldr r2, =gPaletteFade - ldrb r0, [r2, 0x8] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x8] - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B02D4: - bl ResetSpriteData - b _081B0484 -_081B02DA: - bl FreeAllSpritePalettes - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B02EC: - bl sub_81221AC - lsls r0, 24 - cmp r0, 0 - beq _081B02F8 - b _081B0484 -_081B02F8: - bl ResetTasks - b _081B0484 -_081B02FE: - bl sub_81B209C - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B0310: - bl sub_81B0550 - lsls r0, 24 - cmp r0, 0 - bne _081B0322 - bl sub_81B04BC - movs r0, 0x1 - b _081B04B2 -_081B0322: - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - movs r1, 0x86 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - b _081B0484 - .pool -_081B0338: - bl sub_81B05C8 - lsls r0, 24 - cmp r0, 0 - bne _081B0344 - b _081B04B0 -_081B0344: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B0354: - ldr r0, =gUnknown_0203CEC8 - ldrb r0, [r0, 0x8] - lsls r0, 26 - lsrs r0, 30 - bl sub_81B239C - b _081B0484 - .pool -_081B0368: - ldr r0, =gUnknown_0203CEC8 - ldrb r0, [r0, 0x8] - lsls r0, 26 - lsrs r0, 30 - bl sub_81B0740 - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - movs r1, 0x86 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - b _081B0484 - .pool -_081B038C: - bl sub_81B5D30 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B03A0: - bl sub_81B6040 - b _081B0484 -_081B03A6: - bl sub_81B6160 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B03B8: - bl LoadMonIconPalettes - b _081B0484 -_081B03BE: - bl party_menu_add_per_mon_objects - lsls r0, 24 - cmp r0, 0 - bne _081B03CA - b _081B04B0 -_081B03CA: - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - movs r1, 0x86 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - b _081B0484 - .pool -_081B03E0: - bl sub_81B0DA0 - lsls r0, 24 - cmp r0, 0 - beq _081B04B0 - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - movs r1, 0x86 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - b _081B0484 - .pool -_081B0400: - bl sub_81B0F28 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B0414: - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - ldrb r0, [r0, 0x8] - lsls r0, 31 - lsrs r0, 31 - bl sub_81B2428 - b _081B0484 - .pool -_081B0428: - movs r0, 0x87 - lsls r0, 3 - adds r1, r2, r0 - b _081B048C -_081B0430: - ldr r4, =gUnknown_0203CEC4 - ldr r0, [r4] - ldr r0, [r0] - movs r1, 0 - bl CreateTask - ldr r0, [r4] - ldrh r0, [r0, 0xA] - lsrs r0, 2 - bl display_pokemon_menu_message - b _081B0484 - .pool -_081B044C: - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - ldr r2, =gPaletteFade - ldrb r1, [r2, 0x8] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2, 0x8] - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - b _081B048C - .pool -_081B0474: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade -_081B0484: - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 -_081B048C: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _081B04B0 - .pool -_081B0498: - ldr r0, =sub_81B01CC - bl SetVBlankCallback - ldr r0, =sub_81B01B0 - bl SetMainCallback2 - movs r0, 0x1 - b _081B04B2 - .pool -_081B04B0: - movs r0, 0 -_081B04B2: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81B020C - - thumb_func_start sub_81B04BC -sub_81B04BC: @ 81B04BC - push {lr} - sub sp, 0x4 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =sub_81B04F8 - movs r1, 0 - bl CreateTask - ldr r0, =sub_81B01CC - bl SetVBlankCallback - ldr r0, =sub_81B01B0 - bl SetMainCallback2 - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B04BC - - thumb_func_start sub_81B04F8 -sub_81B04F8: @ 81B04F8 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081B051C - ldr r0, =gUnknown_0203CEC8 - ldr r0, [r0] - bl SetMainCallback2 - bl sub_81B06F4 - adds r0, r4, 0 - bl DestroyTask -_081B051C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B04F8 - - thumb_func_start reset_brm -reset_brm: @ 81B052C - ldr r0, =gUnknown_0203CEC4 - movs r1, 0 - str r1, [r0] - ldr r0, =gUnknown_0203CEE4 - str r1, [r0] - ldr r0, =gUnknown_0203CEDC - str r1, [r0] - ldr r0, =gUnknown_0203CEE0 - str r1, [r0] - bx lr - .pool - thumb_func_end reset_brm - - thumb_func_start sub_81B0550 -sub_81B0550: @ 81B0550 - push {r4,r5,lr} - ldr r5, =gUnknown_0203CEE4 - movs r4, 0x80 - lsls r4, 4 - adds r0, r4, 0 - bl Alloc - str r0, [r5] - cmp r0, 0 - beq _081B05C0 - movs r1, 0 - adds r2, r4, 0 - bl memset - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_086156B8 - movs r0, 0 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r1, [r5] - movs r0, 0x1 - bl SetBgTilemapBuffer - bl ResetAllBgsCoordinates - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x1 - b _081B05C2 - .pool -_081B05C0: - movs r0, 0 -_081B05C2: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81B0550 - - thumb_func_start sub_81B05C8 -sub_81B05C8: @ 81B05C8 - push {r4,lr} - sub sp, 0x4 - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - movs r1, 0x86 - lsls r1, 2 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x7 - bhi _081B06B0 - lsls r0, 2 - ldr r1, =_081B05F0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081B05F0: - .4byte _081B0610 - .4byte _081B0638 - .4byte _081B0658 - .4byte _081B0684 - .4byte _081B0688 - .4byte _081B068C - .4byte _081B0690 - .4byte _081B0694 -_081B0610: - ldr r4, =gUnknown_0203CEE0 - ldr r0, =gPartyMenuMisc_Gfx - mov r1, sp - bl malloc_and_decompress - adds r1, r0, 0 - str r1, [r4] - ldr r2, [sp] - lsls r2, 16 - lsrs r2, 16 - movs r0, 0x1 - movs r3, 0 - bl LoadBgTiles - b _081B069A - .pool -_081B0638: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _081B06B4 - ldr r0, =gPartyMenuMisc_Tilemap - ldr r1, =gUnknown_0203CEE4 - ldr r1, [r1] - bl LZDecompressWram - b _081B069A - .pool -_081B0658: - ldr r0, =gPartyMenuMisc_Pal - movs r2, 0xB0 - lsls r2, 1 - movs r1, 0 - bl LoadCompressedPalette - ldr r0, =gPlttBufferUnfaded - ldr r4, =gUnknown_0203CEC4 - ldr r1, [r4] - adds r1, 0x18 - movs r2, 0xB0 - bl CpuSet - ldr r1, [r4] - b _081B069E - .pool -_081B0684: - movs r0, 0x4 - b _081B0696 -_081B0688: - movs r0, 0x5 - b _081B0696 -_081B068C: - movs r0, 0x6 - b _081B0696 -_081B0690: - movs r0, 0x7 - b _081B0696 -_081B0694: - movs r0, 0x8 -_081B0696: - bl sub_81B06C0 -_081B069A: - ldr r0, =gUnknown_0203CEC4 - ldr r1, [r0] -_081B069E: - movs r0, 0x86 - lsls r0, 2 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _081B06B4 - .pool -_081B06B0: - movs r0, 0x1 - b _081B06B6 -_081B06B4: - movs r0, 0 -_081B06B6: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81B05C8 - - thumb_func_start sub_81B06C0 -sub_81B06C0: @ 81B06C0 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 28 - ldr r5, =gPlttBufferUnfaded + 0x60 - lsrs r4, 23 - adds r1, r5, 0 - subs r1, 0x60 - adds r1, r4, r1 - adds r0, r5, 0 - movs r2, 0x10 - bl CpuSet - ldr r0, =gPlttBufferFaded - adds r4, r0 - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x10 - bl CpuSet - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B06C0 - - thumb_func_start sub_81B06F4 -sub_81B06F4: @ 81B06F4 - push {lr} - ldr r0, =gUnknown_0203CEC4 - ldr r0, [r0] - cmp r0, 0 - beq _081B0702 - bl Free -_081B0702: - ldr r0, =gUnknown_0203CEE4 - ldr r0, [r0] - cmp r0, 0 - beq _081B070E - bl Free -_081B070E: - ldr r0, =gUnknown_0203CEE0 - ldr r0, [r0] - cmp r0, 0 - beq _081B071A - bl Free -_081B071A: - ldr r0, =gUnknown_0203CEDC - ldr r0, [r0] - cmp r0, 0 - beq _081B0726 - bl Free -_081B0726: - bl FreeAllWindowBuffers - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B06F4 - - thumb_func_start sub_81B0740 -sub_81B0740: @ 81B0740 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r4, =gUnknown_0203CEDC - movs r0, 0x60 - bl Alloc - str r0, [r4] - movs r5, 0 - lsls r0, r7, 1 - adds r0, r7 - lsls r0, 4 - mov r8, r0 - movs r6, 0xFF - mov r9, r4 -_081B0764: - ldr r2, [r4] - lsls r3, r5, 4 - adds r2, r3, r2 - ldr r0, =gUnknown_086156E4 - mov r12, r0 - str r0, [r2] - lsls r0, r5, 3 - ldr r1, =gUnknown_08615704 - adds r0, r1 - add r0, r8 - str r0, [r2, 0x4] - strb r5, [r2, 0x8] - ldr r1, [r4] - adds r1, r3, r1 - ldrb r0, [r1, 0x9] - orrs r0, r6 - strb r0, [r1, 0x9] - ldr r1, [r4] - adds r1, r3, r1 - ldrb r0, [r1, 0xA] - orrs r0, r6 - strb r0, [r1, 0xA] - ldr r1, [r4] - adds r1, r3, r1 - ldrb r0, [r1, 0xB] - orrs r0, r6 - strb r0, [r1, 0xB] - ldr r0, [r4] - adds r3, r0 - ldrb r0, [r3, 0xC] - orrs r0, r6 - strb r0, [r3, 0xC] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x5 - bls _081B0764 - mov r1, r9 - ldr r0, [r1] - mov r1, r12 - subs r1, 0x20 - str r1, [r0] - cmp r7, 0x3 - bne _081B07CC - str r1, [r0, 0x30] - b _081B07D2 - .pool -_081B07CC: - cmp r7, 0 - beq _081B07D2 - str r1, [r0, 0x10] -_081B07D2: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81B0740 - - thumb_func_start sub_81B07E0 -sub_81B07E0: @ 81B07E0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gUnknown_0203CEC8 - ldrb r1, [r0, 0x8] - movs r0, 0xF - ands r0, r1 - cmp r0, 0x5 - bne _081B085C - cmp r5, 0x2 - bls _081B085C - adds r0, r5, 0 - bl sub_81B0CEC - ldr r0, =gUnknown_02022FF8 - subs r1, r5, 0x3 - lsls r1, 5 - adds r1, r0 - ldrh r0, [r1] - cmp r0, 0 - bne _081B0828 - ldr r0, =gUnknown_0203CEDC - lsls r4, r5, 4 - ldr r0, [r0] - adds r0, r4 - movs r1, 0x40 - bl sub_81B2748 - b _081B0836 - .pool -_081B0828: - ldr r0, =gUnknown_0203CEDC - lsls r4, r5, 4 - ldr r0, [r0] - adds r0, r4 - movs r1, 0x8 - bl sub_81B2748 -_081B0836: - adds r5, r4, 0 - ldr r4, =gUnknown_0203CEDC - ldr r0, [r4] - adds r0, r5, r0 - ldrb r0, [r0, 0x8] - movs r1, 0x2 - bl CopyWindowToVram - ldr r0, [r4] - adds r0, r5, r0 - ldrb r0, [r0, 0x8] - bl PutWindowTilemap - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - b _081B093E - .pool -_081B085C: - movs r0, 0x64 - muls r0, r5 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - bne _081B089C - ldr r4, =gUnknown_0203CEDC - ldr r0, [r4] - lsls r5, 4 - adds r0, r5, r0 - ldrb r0, [r0, 0x8] - bl sub_81B2720 - ldr r0, [r4] - adds r0, r5 - movs r1, 0x40 - bl sub_81B2748 - ldr r0, [r4] - adds r0, r5, r0 - ldrb r0, [r0, 0x8] - movs r1, 0x2 - bl CopyWindowToVram - b _081B092C - .pool -_081B089C: - ldr r0, =gUnknown_0203CEC8 - ldrb r0, [r0, 0x8] - movs r1, 0xF - ands r1, r0 - cmp r1, 0x7 - bne _081B08B4 - adds r0, r5, 0 - bl sub_81B0B60 - b _081B08F6 - .pool -_081B08B4: - cmp r1, 0x2 - bne _081B08C0 - adds r0, r5, 0 - bl sub_81B0B08 - b _081B08F6 -_081B08C0: - cmp r1, 0x4 - bne _081B08CC - adds r0, r5, 0 - bl sub_81B0A9C - b _081B08F6 -_081B08CC: - cmp r1, 0xB - bne _081B08D8 - adds r0, r5, 0 - bl sub_81B0B98 - b _081B08F6 -_081B08D8: - cmp r1, 0xC - bne _081B08E4 - adds r0, r5, 0 - bl sub_81B0BC4 - b _081B08F6 -_081B08E4: - adds r0, r5, 0 - bl sub_81B0BFC - lsls r0, 24 - cmp r0, 0 - bne _081B08F6 - adds r0, r5, 0 - bl sub_81B0948 -_081B08F6: - ldr r2, =gUnknown_0203CEC8 - ldrb r1, [r2, 0x8] - movs r0, 0xF - ands r0, r1 - cmp r0, 0x5 - bne _081B0910 - adds r0, r5, 0 - movs r1, 0 - bl sub_81B0FCC - b _081B092A - .pool -_081B0910: - movs r0, 0x9 - ldrsb r0, [r2, r0] - cmp r0, r5 - bne _081B0922 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_81B0FCC - b _081B092A -_081B0922: - adds r0, r5, 0 - movs r1, 0 - bl sub_81B0FCC -_081B092A: - lsls r5, 4 -_081B092C: - ldr r0, =gUnknown_0203CEDC - ldr r0, [r0] - adds r0, r5, r0 - ldrb r0, [r0, 0x8] - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram -_081B093E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B07E0 - - thumb_func_start sub_81B0948 -sub_81B0948: @ 81B0948 - push {r4-r7,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x64 - adds r1, r4, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r7, r1, r0 - adds r0, r7, 0 - movs r1, 0x2D - bl GetMonData - adds r2, r0, 0 - cmp r2, 0 - beq _081B09A0 - ldr r6, =gUnknown_0203CEDC - ldr r0, [r6] - lsls r5, r4, 4 - adds r0, r5, r0 - ldr r2, [r0] - ldrb r0, [r0, 0x8] - movs r1, 0 - str r1, [sp] - movs r1, 0x1 - str r1, [sp, 0x4] - ldr r4, [r2] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl _call_via_r4 - ldr r1, [r6] - adds r1, r5 - adds r0, r7, 0 - movs r2, 0 - bl sub_81B2A70 - b _081B0A02 - .pool -_081B09A0: - ldr r5, =gUnknown_0203CEDC - ldr r0, [r5] - lsls r4, 4 - adds r0, r4, r0 - ldr r1, [r0] - ldrb r0, [r0, 0x8] - str r2, [sp] - str r2, [sp, 0x4] - ldr r6, [r1] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl _call_via_r6 - ldr r1, [r5] - adds r1, r4 - adds r0, r7, 0 - movs r2, 0 - bl sub_81B2A70 - ldr r1, [r5] - adds r1, r4 - adds r0, r7, 0 - movs r2, 0 - bl sub_81B2AC8 - ldr r1, [r5] - adds r1, r4 - adds r0, r7, 0 - movs r2, 0 - bl sub_81B2B8C - ldr r1, [r5] - adds r1, r4 - adds r0, r7, 0 - movs r2, 0 - bl sub_81B2CD4 - ldr r1, [r5] - adds r1, r4 - adds r0, r7, 0 - movs r2, 0 - bl sub_81B2D74 - ldr r1, [r5] - adds r1, r4 - adds r0, r7, 0 - bl sub_81B2E28 -_081B0A02: - add sp, 0x8 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81B0948 thumb_func_start sub_81B0A10 sub_81B0A10: @ 81B0A10 diff --git a/include/battle_main.h b/include/battle_main.h index 5a61b5ef0..18bdde2f1 100644 --- a/include/battle_main.h +++ b/include/battle_main.h @@ -7,6 +7,20 @@ struct TrainerMoney u8 value; }; +struct UnknownPokemonStruct4 +{ + /*0x00*/ u16 species; + /*0x02*/ u16 heldItem; + /*0x04*/ u8 nickname[POKEMON_NAME_LENGTH + 1]; + /*0x0F*/ u8 level; + /*0x10*/ u16 hp; + /*0x12*/ u16 maxhp; + /*0x14*/ u32 status; + /*0x18*/ u32 personality; + /*0x1C*/ u8 gender; + /*0x1D*/ u8 language; +}; + #define TYPE_NAME_LENGTH 6 #define ABILITY_NAME_LENGTH 12 @@ -70,6 +84,8 @@ void RunBattleScriptCommands_PopCallbacksStack(void); void RunBattleScriptCommands(void); bool8 TryRunFromBattle(u8 battlerId); +extern struct UnknownPokemonStruct4 gUnknown_02022FF8[3]; + extern const u8 gTypeEffectiveness[336]; extern const u8 gTypeNames[][TYPE_NAME_LENGTH + 1]; extern const struct TrainerMoney gTrainerMoneyTable[]; diff --git a/include/graphics.h b/include/graphics.h index 4cbee1c34..a7bbc5b68 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -3914,6 +3914,11 @@ extern const u16 gIntro2BrendanNoTurnPal[]; extern const u16 gIntro2FlygonPal[]; extern const u8 gIntro2FlygonGfx[]; +// party menu graphics +extern const u8 gPartyMenuMisc_Gfx[]; +extern const u16 gPartyMenuMisc_Tilemap[]; +extern const u8 gPartyMenuMisc_Pal[]; + // berry pics extern const u8 gBerryPic_Cheri[]; extern const u8 gBerryPalette_Cheri[]; diff --git a/ld_script.txt b/ld_script.txt index 43a556034..9dc6efaa6 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -253,6 +253,7 @@ SECTIONS { src/dynamic_placeholder_text_util.o(.text); src/save_location.o(.text); src/item_icon.o(.text); + src/party_menu.o(.text); asm/party_menu.o(.text); src/battle_tent.o(.text); src/unk_text_util_2.o(.text); diff --git a/src/party_menu.c b/src/party_menu.c new file mode 100755 index 000000000..9b8947465 --- /dev/null +++ b/src/party_menu.c @@ -0,0 +1,521 @@ +#include "global.h" +#include "battle_main.h" +#include "bg.h" +#include "constants/rgb.h" +#include "constants/species.h" +#include "decompress.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "main.h" +#include "malloc.h" +#include "menu.h" +#include "menu_helpers.h" +#include "palette.h" +#include "pokemon.h" +#include "pokemon_icon.h" +#include "scanline_effect.h" +#include "sprite.h" +#include "task.h" +#include "text.h" +#include "window.h" + +struct Unk_Rodata1 { + void (*unk0)(u8, u8, u8, u8, u8, u8); + u32 unk4[7]; +}; + +struct Unk_203CEC4 { + TaskFunc unk0; + void *unk4; + u32 unk8_0:1; + u32 unk8_1:3; + u32 unk8_2:7; + u32 unk9_0:7; + u32 unkA_0:14; + u8 unkC[3]; + u8 fillerF[9]; + u16 unk18[0xB0]; + u8 filler[0xA0]; + s16 unk218[16]; +}; + +struct Unk_203CEC8 { + MainCallback unk0; + u8 filler[4]; + u8 unk8_0:4; + u8 unk8_1:2; + u8 unk8_2:2; + s8 unk9; + u8 unkA; + u8 unkB; +}; + +struct Unk_203CEDC { + struct Unk_Rodata1 *unk0; + u32 *unk4; + u8 unk8; + u8 unk9; + u8 unkA; + u8 unkB; + u8 unkC; +}; + +struct Unk_203CEE4 { + u8 filler[0x800]; +}; + +// BELOW TO BE PUT IN EWRAM + +extern struct Unk_203CEC4 *gUnknown_0203CEC4; +extern struct Unk_203CEC8 gUnknown_0203CEC8; +extern struct Unk_203CEDC *gUnknown_0203CEDC; +extern u8 *gUnknown_0203CEE0; +extern struct Unk_203CEE4 *gUnknown_0203CEE4; + +// ABOVE TO BE PUT IN EWRAM + +// BELOW TO BE CONVERTED TO C + +extern struct BgTemplate gUnknown_086156B8[]; +extern struct Unk_Rodata1 gUnknown_086156C4[2]; +// extern struct Unk_Rodata1 gUnknown_086156E4; +extern u32 gUnknown_08615704[][6][2]; + +// ABOVE TO BE CONVERTED TO C + +void reset_brm(void); +void c2_811EBD0(void); +bool8 sub_81B020C(void); +void sub_81B209C(void); +void sub_81B04BC(void); +bool8 sub_81B0550(void); +bool8 sub_81B05C8(void); +void sub_81B239C(u8); +void sub_81B0740(u8); +void sub_81B5D30(void); +void sub_81B6040(void); +void sub_81B6160(void); +bool8 party_menu_add_per_mon_objects(void); +bool8 sub_81B0DA0(void); +void sub_81B0F28(void); +void sub_81B2428(u8); +void display_pokemon_menu_message(u32); +void sub_81B04F8(u8); +void sub_81B06F4(void); +void sub_81B06C0(u8); +void sub_81B0CEC(u8); +void sub_81B2748(struct Unk_203CEDC *, u8); +void sub_81B2720(u8); +void sub_81B0B60(u8); +void sub_81B0B08(u8); +void sub_81B0A9C(u8); +void sub_81B0B98(u8); +void sub_81B0BC4(u8); +bool8 sub_81B0BFC(u8); +void sub_81B0948(u8); +void sub_81B0FCC(u8, u8); +void sub_81B2A70(struct Pokemon *, struct Unk_203CEDC *, u8); +void sub_81B2AC8(struct Pokemon *, struct Unk_203CEDC *, u8); +void sub_81B2B8C(struct Pokemon *, struct Unk_203CEDC *, u8); +void sub_81B2CD4(struct Pokemon *, struct Unk_203CEDC *, u8); +void sub_81B2D74(struct Pokemon *, struct Unk_203CEDC *, u8); +void sub_81B2E28(struct Pokemon *, struct Unk_203CEDC *); + +void sub_81B0038(u8 a, u8 b, u8 c, u8 d, u8 e, TaskFunc f, MainCallback g) +{ + u16 i; + + reset_brm(); + gUnknown_0203CEC4 = Alloc(sizeof(struct Unk_203CEC4)); + if (gUnknown_0203CEC4 == 0) + { + SetMainCallback2(g); + } + else + { + gUnknown_0203CEC8.unk8_0 = a; + gUnknown_0203CEC8.unk0 = g; + gUnknown_0203CEC8.unkB = c; + gUnknown_0203CEC4->unkA_0 = e; + gUnknown_0203CEC4->unk0 = f; + gUnknown_0203CEC4->unk4 = NULL; + gUnknown_0203CEC4->unk8_1 = 0; + gUnknown_0203CEC4->unk8_2 = 0xFF; + gUnknown_0203CEC4->unk9_0 = 0xFF; + + if (a == 4) + gUnknown_0203CEC4->unk8_0 = TRUE; + else + gUnknown_0203CEC4->unk8_0 = FALSE; + + if (b != 0xFF) + gUnknown_0203CEC8.unk8_1 = b; + + for (i = 0; i <= 15; i++) + gUnknown_0203CEC4->unk218[i] = 0; + for (i = 0; i < 3; i++) + gUnknown_0203CEC4->unkC[i] |= 0xFF; + + if (d == 0) + gUnknown_0203CEC8.unk9 = 0; + else if (gUnknown_0203CEC8.unk9 > 5 || GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_SPECIES) == SPECIES_NONE) + gUnknown_0203CEC8.unk9 = 0; // wut why is this else if? + + gTextFlags.flag_2 = 0; + CalculatePlayerPartyCount(); + SetMainCallback2(c2_811EBD0); + } +} + +void sub_81B01B0(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); +} + +void sub_81B01CC(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void c2_811EBD0(void) +{ + while (TRUE) + { + if (sub_81221EC() == TRUE || sub_81B020C() == TRUE || sub_81221AC() == TRUE) + break; + } +} + +bool8 sub_81B020C(void) +{ + switch (gMain.state) + { + case 0: + SetVBlankHBlankCallbacksToNull(); + ResetVramOamAndBgCntRegs(); + clear_scheduled_bg_copies_to_vram(); + gMain.state++; + break; + case 1: + ScanlineEffect_Stop(); + gMain.state++; + break; + case 2: + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = TRUE; + gMain.state++; + break; + case 3: + ResetSpriteData(); + gMain.state++; + break; + case 4: + FreeAllSpritePalettes(); + gMain.state++; + break; + case 5: + if (!sub_81221AC()) + ResetTasks(); + gMain.state++; + break; + case 6: + sub_81B209C(); + gMain.state++; + break; + case 7: + if (!sub_81B0550()) + { + sub_81B04BC(); + return TRUE; + } + else + { + gUnknown_0203CEC4->unk218[0] = 0; + gMain.state++; + } + break; + case 8: + if (sub_81B05C8()) + gMain.state++; + break; + case 9: + sub_81B239C(gUnknown_0203CEC8.unk8_1); + gMain.state++; + break; + case 10: + sub_81B0740(gUnknown_0203CEC8.unk8_1); + gUnknown_0203CEC4->unk218[0] = 0; + gMain.state++; + break; + case 11: + sub_81B5D30(); + gMain.state++; + break; + case 12: + sub_81B6040(); + gMain.state++; + break; + case 13: + sub_81B6160(); + gMain.state++; + break; + case 14: + LoadMonIconPalettes(); + gMain.state++; + break; + case 15: + if (party_menu_add_per_mon_objects()) + { + gUnknown_0203CEC4->unk218[0] = 0; + gMain.state++; + } + break; + case 16: + if (sub_81B0DA0()) + { + gUnknown_0203CEC4->unk218[0] = 0; + gMain.state++; + } + break; + case 17: + sub_81B0F28(); + gMain.state++; + break; + case 18: + sub_81B2428(gUnknown_0203CEC4->unk8_0); + gMain.state++; + break; + case 19: + gMain.state++; + break; + case 20: + CreateTask(gUnknown_0203CEC4->unk0, 0); + display_pokemon_menu_message(gUnknown_0203CEC4->unkA_0); + gMain.state++; + break; + case 21: + BlendPalettes(0xFFFFFFFF, 16, 0); + gPaletteFade.bufferTransferDisabled = FALSE; + gMain.state++; + break; + case 22: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + gMain.state++; + break; + default: + SetVBlankCallback(sub_81B01CC); + SetMainCallback2(sub_81B01B0); + return TRUE; + } + return FALSE; +} + +void sub_81B04BC(void) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + CreateTask(sub_81B04F8, 0); + SetVBlankCallback(sub_81B01CC); + SetMainCallback2(sub_81B01B0); +} + +void sub_81B04F8(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetMainCallback2(gUnknown_0203CEC8.unk0); + sub_81B06F4(); + DestroyTask(taskId); + } +} + +void reset_brm(void) +{ + gUnknown_0203CEC4 = NULL; + gUnknown_0203CEE4 = NULL; + gUnknown_0203CEDC = NULL; + gUnknown_0203CEE0 = NULL; +} + +bool8 sub_81B0550(void) +{ + gUnknown_0203CEE4 = Alloc(sizeof(struct Unk_203CEE4)); + if (gUnknown_0203CEE4 == NULL) + return FALSE; + memset(gUnknown_0203CEE4, 0, sizeof(struct Unk_203CEE4)); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_086156B8, 3); + SetBgTilemapBuffer(1, gUnknown_0203CEE4); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(1); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + ShowBg(0); + ShowBg(1); + ShowBg(2); + return TRUE; +} + +bool8 sub_81B05C8(void) +{ + int sizeout; + + switch (gUnknown_0203CEC4->unk218[0]) + { + case 0: + gUnknown_0203CEE0 = malloc_and_decompress(gPartyMenuMisc_Gfx, &sizeout); + LoadBgTiles(1, gUnknown_0203CEE0, sizeout, 0); + gUnknown_0203CEC4->unk218[0]++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + LZDecompressWram(gPartyMenuMisc_Tilemap, gUnknown_0203CEE4); + gUnknown_0203CEC4->unk218[0]++; + } + break; + case 2: + LoadCompressedPalette(gPartyMenuMisc_Pal, 0, 0x160); + CpuCopy16(gPlttBufferUnfaded, gUnknown_0203CEC4->unk18, 0x160); + gUnknown_0203CEC4->unk218[0]++; + break; + case 3: + sub_81B06C0(4); + gUnknown_0203CEC4->unk218[0]++; + break; + case 4: + sub_81B06C0(5); + gUnknown_0203CEC4->unk218[0]++; + break; + case 5: + sub_81B06C0(6); + gUnknown_0203CEC4->unk218[0]++; + break; + case 6: + sub_81B06C0(7); + gUnknown_0203CEC4->unk218[0]++; + break; + case 7: + sub_81B06C0(8); + gUnknown_0203CEC4->unk218[0]++; + break; + default: + return TRUE; + } + return FALSE; +} + +void sub_81B06C0(u8 offset) +{ + offset *= 16; + CpuCopy16(&gPlttBufferUnfaded[0x30], &gPlttBufferUnfaded[offset], 32); + CpuCopy16(&gPlttBufferUnfaded[0x30], &gPlttBufferFaded[offset], 32); +} + +void sub_81B06F4(void) +{ + if (gUnknown_0203CEC4) + Free(gUnknown_0203CEC4); + if (gUnknown_0203CEE4) + Free(gUnknown_0203CEE4); + if (gUnknown_0203CEE0) + Free(gUnknown_0203CEE0); + if (gUnknown_0203CEDC) + Free(gUnknown_0203CEDC); + FreeAllWindowBuffers(); +} + +void sub_81B0740(u8 a) +{ + u8 i; + + gUnknown_0203CEDC = Alloc(sizeof(struct Unk_203CEDC[6])); + + for (i = 0; i < 6; i++) + { + gUnknown_0203CEDC[i].unk0 = &gUnknown_086156C4[1]; + gUnknown_0203CEDC[i].unk4 = gUnknown_08615704[a][i]; + gUnknown_0203CEDC[i].unk8 = i; + gUnknown_0203CEDC[i].unk9 |= 0xFF; + gUnknown_0203CEDC[i].unkA |= 0xFF; + gUnknown_0203CEDC[i].unkB |= 0xFF; + gUnknown_0203CEDC[i].unkC |= 0xFF; + } + gUnknown_0203CEDC[0].unk0 = &gUnknown_086156C4[0]; + if (a == 3) + gUnknown_0203CEDC[3].unk0 = &gUnknown_086156C4[0]; + else if (a) + gUnknown_0203CEDC[1].unk0 = &gUnknown_086156C4[0]; +} + +void sub_81B07E0(u8 a) +{ + if (gUnknown_0203CEC8.unk8_0 == 5 && a > 2) + { + sub_81B0CEC(a); + if (gUnknown_02022FF8[a - 3].species == SPECIES_NONE) + sub_81B2748(&gUnknown_0203CEDC[a], 0x40); + else + sub_81B2748(&gUnknown_0203CEDC[a], 8); + CopyWindowToVram(gUnknown_0203CEDC[a].unk8, 2); + PutWindowTilemap(gUnknown_0203CEDC[a].unk8); + schedule_bg_copy_tilemap_to_vram(2); + } + else + { + if (GetMonData(&gPlayerParty[a], MON_DATA_SPECIES) == SPECIES_NONE) + { + sub_81B2720(gUnknown_0203CEDC[a].unk8); + sub_81B2748(&gUnknown_0203CEDC[a], 0x40); + CopyWindowToVram(gUnknown_0203CEDC[a].unk8, 2); + } + else + { + if (gUnknown_0203CEC8.unk8_0 == 7) + sub_81B0B60(a); + else if (gUnknown_0203CEC8.unk8_0 == 2) + sub_81B0B08(a); + else if (gUnknown_0203CEC8.unk8_0 == 4) + sub_81B0A9C(a); + else if (gUnknown_0203CEC8.unk8_0 == 11) + sub_81B0B98(a); + else if (gUnknown_0203CEC8.unk8_0 == 12) + sub_81B0BC4(a); + else if (!sub_81B0BFC(a)) + sub_81B0948(a); + + if (gUnknown_0203CEC8.unk8_0 == 5) + sub_81B0FCC(a, 0); + else if (gUnknown_0203CEC8.unk9 == a) + sub_81B0FCC(a, 1); + else + sub_81B0FCC(a, 0); + } + PutWindowTilemap(gUnknown_0203CEDC[a].unk8); + schedule_bg_copy_tilemap_to_vram(0); + } +} + +void sub_81B0948(u8 a) +{ + if (GetMonData(&gPlayerParty[a], MON_DATA_IS_EGG)) + { + gUnknown_0203CEDC[a].unk0->unk0(gUnknown_0203CEDC[a].unk8, 0, 0, 0, 0, 1); + sub_81B2A70(&gPlayerParty[a], &gUnknown_0203CEDC[a], 0); + } + else + { + gUnknown_0203CEDC[a].unk0->unk0(gUnknown_0203CEDC[a].unk8, 0, 0, 0, 0, 0); + sub_81B2A70(&gPlayerParty[a], &gUnknown_0203CEDC[a], 0); + sub_81B2AC8(&gPlayerParty[a], &gUnknown_0203CEDC[a], 0); + sub_81B2B8C(&gPlayerParty[a], &gUnknown_0203CEDC[a], 0); + sub_81B2CD4(&gPlayerParty[a], &gUnknown_0203CEDC[a], 0); + sub_81B2D74(&gPlayerParty[a], &gUnknown_0203CEDC[a], 0); + sub_81B2E28(&gPlayerParty[a], &gUnknown_0203CEDC[a]); + } +}