diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 11f215a83..d2700fff0 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -8,1384 +8,6 @@ - - thumb_func_start GetDomeTrainerMonIvs -GetDomeTrainerMonIvs: @ 8190168 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - cmp r0, 0x63 - bls _0819019A - movs r1, 0x6 - cmp r0, 0x77 - bls _0819019A - movs r1, 0x9 - cmp r0, 0x8B - bls _0819019A - movs r1, 0xC - cmp r0, 0x9F - bls _0819019A - movs r1, 0xF - cmp r0, 0xB3 - bls _0819019A - movs r1, 0x12 - cmp r0, 0xC7 - bls _0819019A - movs r1, 0x1F - cmp r0, 0xDB - bhi _0819019A - movs r1, 0x15 -_0819019A: - adds r0, r1, 0 - pop {r1} - bx r1 - thumb_func_end GetDomeTrainerMonIvs - - thumb_func_start sub_81901A0 -sub_81901A0: @ 81901A0 - push {r4-r7,lr} - adds r3, r0, 0 - adds r2, r1, 0 - movs r5, 0 - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldr r4, =0x00000d24 - adds r1, r4 - ldrh r1, [r1] - lsls r1, 22 - lsrs r1, 22 - mov r12, r0 - ldr r6, =gUnknown_0860D10C - cmp r1, r2 - beq _081901D8 - mov r7, r12 -_081901C0: - adds r5, 0x1 - cmp r5, 0xF - bgt _081901D8 - ldr r0, [r7] - lsls r1, r5, 2 - adds r0, r1 - adds r0, r4 - ldrh r0, [r0] - lsls r0, 22 - lsrs r0, 22 - cmp r0, r2 - bne _081901C0 -_081901D8: - cmp r3, 0 - beq _0819026C - cmp r3, 0x3 - bne _081901FC - lsls r0, r5, 2 - adds r1, r0, 0x3 - adds r1, r6 - ldrb r1, [r1] - adds r4, r1, 0 - adds r4, 0x8 - b _08190206 - .pool -_081901FC: - lsls r0, r5, 2 - adds r1, r3, r0 - adds r1, r6 - ldrb r1, [r1] - adds r4, r1, 0x4 -_08190206: - adds r0, r3, r0 - adds r0, r6 - ldrb r2, [r0] - cmp r2, r4 - bge _08190256 - ldr r1, =gUnknown_0860D14C - adds r0, r2, r1 - ldrb r3, [r0] - adds r6, r1, 0 - cmp r3, r5 - beq _08190234 - mov r1, r12 - ldr r0, [r1] - lsls r1, r3, 2 - adds r0, r1 - ldr r3, =0x00000d25 - adds r0, r3 - b _0819024E - .pool -_08190234: - adds r2, 0x1 - cmp r2, r4 - bge _08190256 - adds r0, r2, r6 - ldrb r1, [r0] - cmp r1, r5 - beq _08190234 - mov r3, r12 - ldr r0, [r3] - lsls r1, 2 - adds r0, r1 - ldr r1, =0x00000d25 - adds r0, r1 -_0819024E: - ldrb r0, [r0] - lsls r0, 29 - cmp r0, 0 - blt _08190234 -_08190256: - cmp r2, r4 - beq _08190286 - ldr r0, =gUnknown_0860D14C - adds r0, r2, r0 - ldrb r0, [r0] - b _08190292 - .pool -_0819026C: - mov r3, r12 - ldr r1, [r3] - lsls r0, r5, 2 - adds r0, r6 - ldrb r2, [r0] - lsls r0, r2, 2 - adds r1, r0 - ldr r0, =0x00000d25 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 29 - cmp r0, 0 - bge _08190290 -_08190286: - movs r0, 0xFF - b _08190292 - .pool -_08190290: - adds r0, r2, 0 -_08190292: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81901A0 - - thumb_func_start sub_8190298 -sub_8190298: @ 8190298 - push {lr} - bl sub_81902AC - ldr r1, =gTrainerBattleOpponent_A - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8190298 - - thumb_func_start sub_81902AC -sub_81902AC: @ 81902AC - push {r4,lr} - ldr r0, =gSaveBlock2Ptr - ldr r4, [r0] - ldr r1, =0x00000cb2 - adds r0, r4, r1 - ldrh r0, [r0] - ldr r1, =0x000003ff - bl sub_81901A0 - lsls r0, 2 - adds r4, r0 - ldr r0, =0x00000d24 - adds r4, r0 - ldrh r0, [r4] - lsls r0, 22 - lsrs r0, 22 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81902AC - - thumb_func_start sub_81902E4 -sub_81902E4: @ 81902E4 - push {lr} - ldr r0, =gTrainerBattleOpponent_A - ldrh r0, [r0] - movs r1, 0 - bl sub_8162614 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81902E4 - - thumb_func_start sub_81902F8 -sub_81902F8: @ 81902F8 - push {r4,lr} - ldr r4, =gSaveBlock2Ptr - ldr r0, [r4] - ldr r1, =gSpecialVar_0x8005 - ldrh r1, [r1] - ldr r2, =0x00000ca8 - adds r0, r2 - strb r1, [r0] - movs r0, 0x80 - lsls r0, 7 - movs r1, 0 - bl VarSet - ldr r1, [r4] - ldr r0, =0x00000ca9 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] - bl sub_81A4C30 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81902F8 - - thumb_func_start sub_819033C -sub_819033C: @ 819033C - push {r4,r5,lr} - ldr r5, =gSaveBlock2Ptr - ldr r0, [r5] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r4, [r0] - lsls r4, 30 - lsrs r4, 30 - ldr r0, =0x000040ce - bl VarGet - lsls r0, 24 - ldr r1, [r5] - lsls r4, 1 - lsrs r0, 22 - adds r4, r0 - ldr r3, =0x00000d0c - adds r1, r3 - adds r1, r4 - ldrh r0, [r1] - ldr r2, =0x000003e6 - cmp r0, r2 - bhi _0819036E - adds r0, 0x1 - strh r0, [r1] -_0819036E: - ldr r0, [r5] - ldr r1, =0x00000d1c - adds r0, r1 - adds r1, r0, r4 - ldrh r0, [r1] - cmp r0, r2 - bhi _08190380 - adds r0, 0x1 - strh r0, [r1] -_08190380: - ldr r0, [r5] - adds r1, r0, r3 - adds r1, r4 - ldr r2, =0x00000d14 - adds r0, r2 - adds r0, r4 - ldrh r1, [r1] - ldrh r2, [r0] - cmp r1, r2 - bls _08190396 - strh r1, [r0] -_08190396: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819033C - - thumb_func_start sub_81903B8 -sub_81903B8: @ 81903B8 - push {r4,r5,lr} - ldr r0, =sub_8190400 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - movs r5, 0 - strh r5, [r4, 0x8] - bl sub_81902AC - lsls r0, 16 - lsrs r0, 16 - bl TrainerIdToTournamentId - strh r0, [r4, 0xA] - strh r5, [r4, 0xC] - strh r5, [r4, 0xE] - ldr r0, =sub_8194B54 - bl SetMainCallback2 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81903B8 - - thumb_func_start sub_8190400 -sub_8190400: @ 8190400 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r10 - lsls r0, 3 - adds r6, r0, r1 - movs r0, 0xA - ldrsh r5, [r6, r0] - movs r2, 0xC - ldrsh r1, [r6, r2] - mov r9, r1 - movs r0, 0xE - ldrsh r7, [r6, r0] - movs r1, 0x8 - ldrsh r4, [r6, r1] - cmp r4, 0x1 - beq _08190508 - cmp r4, 0x1 - bgt _08190440 - cmp r4, 0 - beq _0819044E - b _08190772 - .pool -_08190440: - cmp r4, 0x2 - bne _08190446 - b _08190570 -_08190446: - cmp r4, 0x3 - bne _0819044C - b _08190634 -_0819044C: - b _08190772 -_0819044E: - movs r0, 0 - bl SetHBlankCallback - movs r0, 0 - bl SetVBlankCallback - movs r0, 0x1 - bl EnableInterrupts - str r4, [sp, 0x4] - movs r1, 0xC0 - lsls r1, 19 - ldr r2, =0x05006000 - add r0, sp, 0x4 - bl CpuSet - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0860CE84 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r0, =gUnknown_0860CEB4 - bl InitWindows - bl DeactivateAllTextPrinters - ldr r0, =gBattle_BG0_X - strh r4, [r0] - ldr r0, =gBattle_BG0_Y - strh r4, [r0] - ldr r0, =gBattle_BG1_X - strh r4, [r0] - ldr r0, =gBattle_BG1_Y - strh r4, [r0] - ldr r0, =gBattle_BG3_X - strh r4, [r0] - ldr r0, =gBattle_BG3_Y - strh r4, [r0] - mov r2, r9 - cmp r2, 0x2 - bne _081904DC - ldr r0, =gBattle_BG2_X - strh r4, [r0] - ldr r0, =gBattle_BG2_Y - strh r4, [r0] - b _081904E6 - .pool -_081904DC: - ldr r0, =gBattle_BG2_X - strh r4, [r0] - ldr r1, =gBattle_BG2_Y - movs r0, 0xA0 - strh r0, [r1] -_081904E6: - ldr r0, =gTasks - mov r2, r10 - lsls r1, r2, 2 - add r1, r10 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _08190772 - .pool -_08190508: - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4C - movs r1, 0 - bl SetGpuReg - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x42 - movs r1, 0 - bl SetGpuReg - movs r0, 0x46 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x3F - bl SetGpuReg - bl ResetPaletteFade - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x4 - strb r0, [r1] - b _08190602 - .pool -_08190570: - ldr r1, =gUnknown_08D83D50 - movs r5, 0x80 - lsls r5, 6 - movs r7, 0 - str r7, [sp] - movs r0, 0x2 - adds r2, r5, 0 - movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree - ldr r1, =gUnknown_08D84970 - movs r4, 0x1 - str r4, [sp] - movs r0, 0x2 - adds r2, r5, 0 - movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree - ldr r1, =gUnknown_08D84F00 - movs r2, 0x80 - lsls r2, 4 - str r4, [sp] - movs r0, 0x3 - movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree - ldr r0, =gUnknown_0860CF50 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_08D85358 - movs r4, 0x80 - lsls r4, 2 - movs r1, 0 - adds r2, r4, 0 - bl LoadCompressedPalette - ldr r0, =gUnknown_08D85444 - movs r1, 0x80 - lsls r1, 1 - adds r2, r4, 0 - bl LoadCompressedPalette - ldr r0, =gUnknown_08D85600 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadCompressedPalette - mov r0, r9 - cmp r0, 0x2 - bne _081905DE - ldr r0, =gUnknown_08D854C8 - movs r1, 0x50 - movs r2, 0x20 - bl LoadCompressedPalette -_081905DE: - str r7, [sp, 0x8] - add r0, sp, 0x8 - ldr r1, =gPlttBufferFaded - ldr r2, =0x05000100 - bl CpuSet - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg -_08190602: - ldrh r0, [r6, 0x8] - adds r0, 0x1 - strh r0, [r6, 0x8] - b _08190772 - .pool -_08190634: - ldr r0, =sub_8194B70 - bl SetVBlankCallback - ldr r4, =gUnknown_0203CD78 - movs r0, 0x14 - bl AllocZeroed - str r0, [r4] - movs r6, 0 - lsls r5, 24 - movs r2, 0xFF -_0819064A: - ldr r1, [r4] - adds r1, r6 - ldrb r0, [r1] - orrs r0, r2 - strb r0, [r1] - adds r6, 0x1 - cmp r6, 0xF - ble _0819064A - bl LoadMonIconPalettes - ldr r0, =sub_8190CD4 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - movs r1, 0 - strh r1, [r0, 0x8] - strh r1, [r0, 0xC] - mov r1, r9 - strh r1, [r0, 0xE] - strh r7, [r0, 0x10] - mov r2, r9 - cmp r2, 0x2 - bne _081906A8 - lsrs r1, r5, 24 - movs r0, 0 - bl sub_819314C - ldr r0, =gUnknown_0203CD78 - ldr r1, [r0] - movs r0, 0x1 - strb r0, [r1, 0x10] - b _081906B0 - .pool -_081906A8: - lsrs r1, r5, 24 - movs r0, 0 - bl sub_81924E0 -_081906B0: - movs r1, 0xFA - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - mov r0, r9 - cmp r0, 0 - beq _0819076C - ldr r5, =gUnknown_0860D068 - adds r0, r5, 0 - movs r1, 0x78 - movs r2, 0x4 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r7, r0, 24 - lsls r4, r7, 4 - adds r4, r7 - lsls r4, 2 - ldr r1, =gSprites - mov r8, r1 - add r4, r8 - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAnim - strh r6, [r4, 0x2E] - adds r0, r5, 0 - movs r1, 0x78 - movs r2, 0x9C - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r7, r0, 24 - lsls r4, r7, 4 - adds r4, r7 - lsls r4, 2 - add r4, r8 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim - strh r6, [r4, 0x2E] - ldr r5, =gUnknown_0860D050 - adds r0, r5, 0 - movs r1, 0x6 - movs r2, 0x50 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 4 - adds r0, r7 - lsls r0, 2 - mov r2, r8 - adds r4, r0, r2 - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAnim - strh r6, [r4, 0x2E] - movs r0, 0 - strh r0, [r4, 0x30] - mov r1, r9 - cmp r1, 0x1 - bne _08190746 - adds r0, r4, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_08190746: - adds r0, r5, 0 - movs r1, 0xEA - movs r2, 0x50 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r7, r0, 24 - lsls r4, r7, 4 - adds r4, r7 - lsls r4, 2 - add r4, r8 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim - strh r6, [r4, 0x2E] - movs r0, 0x1 - strh r0, [r4, 0x30] -_0819076C: - mov r0, r10 - bl DestroyTask -_08190772: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8190400 - - thumb_func_start sub_8190790 -sub_8190790: @ 8190790 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x22] - adds r1, r0, 0x4 - strh r1, [r2, 0x22] - movs r3, 0x2E - ldrsh r0, [r2, r3] - cmp r0, 0 - beq _081907D4 - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x20 - negs r1, r1 - cmp r0, r1 - blt _081907BC - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r3] -_081907BC: - ldrh r0, [r2, 0x30] - adds r0, 0x1 - strh r0, [r2, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - bne _081907F0 - ldr r0, =SpriteCallbackDummy - str r0, [r2, 0x1C] - b _081907F0 - .pool -_081907D4: - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0xBF - ble _081907F0 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r3, 0x32 - ldrsh r1, [r2, r3] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldrh r0, [r2, 0x34] - bl sub_818D8F0 -_081907F0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8190790 - - thumb_func_start sub_81907F8 -sub_81907F8: @ 81907F8 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x22] - subs r1, r0, 0x4 - strh r1, [r2, 0x22] - movs r3, 0x2E - ldrsh r0, [r2, r3] - cmp r0, 0 - beq _08190838 - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0xC0 - bgt _08190820 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r3] -_08190820: - ldrh r0, [r2, 0x30] - adds r0, 0x1 - strh r0, [r2, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - bne _08190858 - ldr r0, =SpriteCallbackDummy - str r0, [r2, 0x1C] - b _08190858 - .pool -_08190838: - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x20 - negs r1, r1 - cmp r0, r1 - bgt _08190858 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r3, 0x32 - ldrsh r1, [r2, r3] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldrh r0, [r2, 0x34] - bl sub_818D8F0 -_08190858: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81907F8 - - thumb_func_start sub_8190860 -sub_8190860: @ 8190860 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x20] - adds r1, r0, 0x4 - strh r1, [r2, 0x20] - movs r3, 0x2E - ldrsh r0, [r2, r3] - cmp r0, 0 - beq _081908A4 - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x20 - negs r1, r1 - cmp r0, r1 - blt _0819088C - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r3] -_0819088C: - ldrh r0, [r2, 0x30] - adds r0, 0x1 - strh r0, [r2, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x40 - bne _081908C0 - ldr r0, =SpriteCallbackDummy - str r0, [r2, 0x1C] - b _081908C0 - .pool -_081908A4: - lsls r1, 16 - ldr r0, =0x010f0000 - cmp r1, r0 - ble _081908C0 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r3, 0x32 - ldrsh r1, [r2, r3] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldrh r0, [r2, 0x34] - bl sub_818D8F0 -_081908C0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8190860 - - thumb_func_start sub_81908CC -sub_81908CC: @ 81908CC - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x20] - subs r1, r0, 0x4 - strh r1, [r2, 0x20] - movs r3, 0x2E - ldrsh r0, [r2, r3] - cmp r0, 0 - beq _08190910 - lsls r1, 16 - movs r0, 0x88 - lsls r0, 17 - cmp r1, r0 - bgt _081908F6 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r3] -_081908F6: - ldrh r0, [r2, 0x30] - adds r0, 0x1 - strh r0, [r2, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x40 - bne _08190930 - ldr r0, =SpriteCallbackDummy - str r0, [r2, 0x1C] - b _08190930 - .pool -_08190910: - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x20 - negs r1, r1 - cmp r0, r1 - bgt _08190930 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r3, 0x32 - ldrsh r1, [r2, r3] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldrh r0, [r2, 0x34] - bl sub_818D8F0 -_08190930: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81908CC - - thumb_func_start sub_8190938 -sub_8190938: @ 8190938 - push {lr} - adds r1, r0, 0 - movs r2, 0x34 - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _0819094A - adds r0, r1, 0 - bl UpdateMonIconFrame -_0819094A: - pop {r0} - bx r0 - thumb_func_end sub_8190938 - - thumb_func_start sub_8190950 -sub_8190950: @ 8190950 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x34 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08190962 - adds r0, r4, 0 - bl UpdateMonIconFrame -_08190962: - ldrh r0, [r4, 0x22] - adds r1, r0, 0x4 - strh r1, [r4, 0x22] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _081909A4 - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - blt _0819098A - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_0819098A: - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - bne _081909C0 - ldr r0, =sub_8190938 - str r0, [r4, 0x1C] - b _081909C0 - .pool -_081909A4: - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0xAF - ble _081909C0 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r2, 0x32 - ldrsh r1, [r4, r2] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - adds r0, r4, 0 - bl sub_80D2EF8 -_081909C0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8190950 - - thumb_func_start sub_81909CC -sub_81909CC: @ 81909CC - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x34 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081909DE - adds r0, r4, 0 - bl UpdateMonIconFrame -_081909DE: - ldrh r0, [r4, 0x22] - subs r1, r0, 0x4 - strh r1, [r4, 0x22] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08190A1C - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0xB0 - bgt _08190A02 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_08190A02: - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - bne _08190A3C - ldr r0, =sub_8190938 - str r0, [r4, 0x1C] - b _08190A3C - .pool -_08190A1C: - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bgt _08190A3C - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r2, 0x32 - ldrsh r1, [r4, r2] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - adds r0, r4, 0 - bl sub_80D2EF8 -_08190A3C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81909CC - - thumb_func_start sub_8190A48 -sub_8190A48: @ 8190A48 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x34 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08190A5A - adds r0, r4, 0 - bl UpdateMonIconFrame -_08190A5A: - ldrh r0, [r4, 0x20] - adds r1, r0, 0x4 - strh r1, [r4, 0x20] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08190A9C - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - blt _08190A82 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_08190A82: - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x40 - bne _08190AB8 - ldr r0, =sub_8190938 - str r0, [r4, 0x1C] - b _08190AB8 - .pool -_08190A9C: - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, 0xFF - ble _08190AB8 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r2, 0x32 - ldrsh r1, [r4, r2] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - adds r0, r4, 0 - bl sub_80D2EF8 -_08190AB8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8190A48 - - thumb_func_start sub_8190AC4 -sub_8190AC4: @ 8190AC4 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x34 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08190AD6 - adds r0, r4, 0 - bl UpdateMonIconFrame -_08190AD6: - ldrh r0, [r4, 0x20] - subs r1, r0, 0x4 - strh r1, [r4, 0x20] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08190B14 - lsls r1, 16 - movs r0, 0x80 - lsls r0, 17 - cmp r1, r0 - bgt _08190AFC - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_08190AFC: - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x40 - bne _08190B34 - ldr r0, =sub_8190938 - str r0, [r4, 0x1C] - b _08190B34 - .pool -_08190B14: - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bgt _08190B34 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - movs r2, 0x32 - ldrsh r1, [r4, r2] - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - adds r0, r4, 0 - bl sub_80D2EF8 -_08190B34: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8190AC4 - - thumb_func_start sub_8190B40 -sub_8190B40: @ 8190B40 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r3, r0, 0 - movs r0, 0x2E - ldrsh r6, [r3, r0] - ldr r2, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r4, r0, r2 - movs r7, 0x10 - ldrsh r1, [r4, r7] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0xA - ldrsh r0, [r0, r1] - ldr r1, =gUnknown_0860D080 - adds r0, r1 - ldrb r0, [r0] - mov r10, r0 - ldr r1, =gSaveBlock2Ptr - ldr r5, [r1] - ldr r7, =0x00000cb2 - adds r0, r5, r7 - ldrh r0, [r0] - mov r12, r0 - movs r7, 0xE - ldrsh r0, [r4, r7] - mov r9, r2 - mov r8, r1 - cmp r0, 0x1 - bne _08190C0C - movs r1, 0x30 - ldrsh r0, [r3, r1] - cmp r0, 0 - beq _08190BFC - mov r2, r10 - lsls r0, r2, 2 - adds r1, r5, r0 - ldr r7, =0x00000d25 - adds r1, r7 - ldrb r2, [r1] - lsls r1, r2, 29 - adds r4, r0, 0 - cmp r1, 0 - bge _08190BB6 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldrb r1, [r0, 0x10] - subs r1, 0x1 - lsls r0, r2, 27 - lsrs r0, 30 - cmp r1, r0 - blt _08190C32 -_08190BB6: - mov r1, r8 - ldr r0, [r1] - adds r0, r4 - ldr r2, =0x00000d25 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 29 - cmp r0, 0 - blt _08190BD4 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - subs r0, 0x1 - cmp r0, r12 - blt _08190C32 -_08190BD4: - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - add r0, r9 - movs r7, 0x8 - ldrsh r0, [r0, r7] - b _08190C4C - .pool -_08190BFC: - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - cmp r0, 0 - bne _08190C32 - b _08190C48 - .pool -_08190C0C: - movs r2, 0x30 - ldrsh r0, [r3, r2] - cmp r0, 0 - beq _08190C28 - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - cmp r0, 0x1 - bls _08190C32 - movs r7, 0x8 - ldrsh r0, [r4, r7] - b _08190C4C - .pool -_08190C28: - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - cmp r0, 0 - beq _08190C48 -_08190C32: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - b _08190C5C - .pool -_08190C48: - movs r1, 0x8 - ldrsh r0, [r4, r1] -_08190C4C: - cmp r0, 0x2 - bne _08190C5C - adds r0, r3, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_08190C5C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8190B40 - - thumb_func_start sub_8190C6C -sub_8190C6C: @ 8190C6C - push {lr} - adds r3, r0, 0 - movs r0, 0x2E - ldrsh r1, [r3, r0] - ldr r2, =gTasks - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r1, r0, r2 - movs r2, 0xE - ldrsh r0, [r1, r2] - cmp r0, 0x1 - bne _08190C9C - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - cmp r0, 0 - bne _08190CA6 - b _08190CC0 - .pool -_08190C9C: - ldr r0, =gUnknown_0203CD78 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - cmp r0, 0x1 - beq _08190CC0 -_08190CA6: - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0x2 - bne _08190CCE - adds r0, r3, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - b _08190CCE - .pool -_08190CC0: - adds r2, r3, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_08190CCE: - pop {r0} - bx r0 - thumb_func_end sub_8190C6C - thumb_func_start sub_8190CD4 sub_8190CD4: @ 8190CD4 push {r4-r7,lr} @@ -7719,26 +6341,26 @@ _0819438C: movs r0, 0x1 adds r2, r5, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r1, =gUnknown_08D834FC str r6, [sp] movs r0, 0x2 adds r2, r5, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r1, =gUnknown_08D83B2C movs r4, 0x1 str r4, [sp] movs r0, 0x2 adds r2, r5, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r1, =gUnknown_08D83C3C str r4, [sp] movs r0, 0x3 adds r2, r5, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r0, =gUnknown_08D85358 movs r4, 0x80 lsls r4, 2 diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 276267043..768311639 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -2706,7 +2706,7 @@ _0811C044: movs r0, 0x3 movs r2, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r1, =gEasyChatWindow_Tilemap movs r0, 0x3 movs r2, 0 @@ -2732,7 +2732,7 @@ _0811C090: movs r0, 0x1 movs r2, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap movs r0, 0x1 bl CopyBgTilemapBufferToVram b _0811C124 diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index 2633db13f..2a14d1e9f 100644 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -3805,7 +3805,7 @@ sub_80C9FEC: @ 80C9FEC movs r0, 0x3 movs r2, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r0, =gUnknown_08572174 ldr r1, =0x0600f800 bl LZ77UnCompVram @@ -3844,7 +3844,7 @@ sub_80CA044: @ 80CA044 movs r0, 0x1 movs r2, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r0, =gUnknown_085722A0 ldr r5, =gUnknown_02039D08 ldr r1, [r5] diff --git a/asm/rom_8011DC0.s b/asm/rom_8011DC0.s index 306e2892d..01f29e0a5 100644 --- a/asm/rom_8011DC0.s +++ b/asm/rom_8011DC0.s @@ -7909,7 +7909,7 @@ bgid_upload_textbox_1: @ 8019938 lsls r2, 1 movs r3, 0 str r3, [sp] - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap add sp, 0x4 pop {r0} bx r0 @@ -9386,7 +9386,7 @@ sub_801A43C: @ 801A43C movs r0, 0x1 movs r2, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r1, =gWirelessInfoScreenTilemap movs r0, 0x1 movs r2, 0 diff --git a/asm/trade.s b/asm/trade.s index 19dfd5ff9..3267fa950 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -7609,7 +7609,7 @@ sub_807B170: @ 807B170 mov r1, r10 movs r2, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap ldr r0, =gBattleTextboxTilemap mov r8, r0 ldr r4, =gDecompressionBuffer @@ -7633,7 +7633,7 @@ sub_807B170: @ 807B170 mov r1, r10 movs r2, 0 movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree + bl DecompressAndLoadBgGfxUsingHeap mov r0, r8 adds r1, r4, 0 bl LZDecompressWram diff --git a/include/global.h b/include/global.h index 5b78fc4c0..4bfa6194d 100644 --- a/include/global.h +++ b/include/global.h @@ -393,19 +393,8 @@ struct BattleFrontier /*0xD0A*/ u8 field_D0A; /*0xD0B*/ u8 field_D0B; /*0xD0C*/ u16 field_D0C[2][2]; - /*0xD14*/ u16 field_D14[2]; - /*0xD18*/ u8 field_D18; - /*0xD19*/ u8 field_D19; - /*0xD1A*/ u8 field_D1A; - /*0xD1B*/ u8 field_D1B; - /*0xD1C*/ u8 field_D1C; - /*0xD1D*/ u8 field_D1D; - /*0xD1E*/ u8 field_D1E; - /*0xD1F*/ u8 field_D1F; - /*0xD20*/ u8 field_D20; - /*0xD21*/ u8 field_D21; - /*0xD22*/ u8 field_D22; - /*0xD23*/ u8 field_D23; + /*0xD14*/ u16 field_D14[2][2]; + /*0xD1C*/ u16 field_D1C[2][2]; /*0xD24*/ struct BattleDomeTrainer domeTrainers[DOME_TOURNAMENT_TRAINERS_COUNT]; /*0xD64*/ u16 domeMonId[DOME_TOURNAMENT_TRAINERS_COUNT][3]; /*0xDC8*/ u16 field_DC8[2]; diff --git a/include/menu.h b/include/menu.h index 5dfd99c64..627374758 100644 --- a/include/menu.h +++ b/include/menu.h @@ -53,7 +53,7 @@ void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size, bool8 free_temp_tile_data_buffers_if_possible(void); struct WindowTemplate CreateWindowTemplate(u8, u8, u8, u8, u8, u8, u16); void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos); -void copy_decompressed_tile_data_to_vram_autofree(u8 bgId, const void *src, int size, u16 offset, u8 mode); +void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, int size, u16 offset, u8 mode); s8 Menu_ProcessInputNoWrap_(void); s8 ProcessMenuInput_other(void); void do_scheduled_bg_tilemap_copies_to_vram(void); diff --git a/src/battle_frontier_1.c b/src/battle_frontier_1.c index 04faad6cd..d217bfa60 100644 --- a/src/battle_frontier_1.c +++ b/src/battle_frontier_1.c @@ -9,6 +9,16 @@ #include "malloc.h" #include "string_util.h" #include "random.h" +#include "task.h" +#include "main.h" +#include "gpu_regs.h" +#include "text.h" +#include "bg.h" +#include "window.h" +#include "palette.h" +#include "decompress.h" +#include "menu.h" +#include "pokemon_icon.h" #include "constants/species.h" #include "constants/moves.h" #include "constants/trainers.h" @@ -23,6 +33,12 @@ struct Unknown_0203BC8C_Struct u8 nature; }; +struct Unknown_0203CD78_Struct +{ + u8 arr[16]; + u8 unk_11; +}; + extern struct Unknown_0203BC8C_Struct *gFacilityTrainerMons; extern void sub_81B8558(void); @@ -32,10 +48,22 @@ extern u16 sub_8163524(u16); extern u8 GetFrontierEnemyMonLevel(void); extern void sub_8195898(u8 *dst, u16 trainerId); extern u16 sub_81A5060(u8, u8); +extern void sub_8162614(u16, u8); +extern void sub_81A4C30(void); +extern u16 sub_818D8F0(u16); extern u8 gUnknown_0203CEF8[]; extern u32 gUnknown_0203CD70; extern u32 gUnknown_0203CD74; +extern u16 gBattle_BG0_X; +extern u16 gBattle_BG0_Y; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG1_Y; +extern u16 gBattle_BG2_X; +extern u16 gBattle_BG2_Y; +extern u16 gBattle_BG3_X; +extern u16 gBattle_BG3_Y; +extern struct Unknown_0203CD78_Struct *gUnknown_0203CD78; extern void (* const gUnknown_0860D090[])(void); extern const u32 gUnknown_0860D0EC[][2]; @@ -52,6 +80,13 @@ s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1); s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1); s32 sub_818FFC0(s32 move, s32 species, s32 arg2); s32 sub_818FEB4(s32 *arr, bool8 arg1); +u16 sub_81902AC(void); +void sub_8190400(u8 taskId); +void sub_8190CD4(u8 taskId); +void sub_8194B54(void); +void sub_8194B70(void); +void sub_819314C(u8, u8); +void sub_81924E0(u8, u8); // code void sub_818E9AC(void) @@ -62,14 +97,14 @@ void sub_818E9AC(void) void sub_818E9CC(void) { u32 lvlMode = gSaveBlock2Ptr->frontier.chosenLvl; - u32 id = VarGet(VAR_0x40CE); + u32 battleMode = VarGet(VAR_0x40CE); gSaveBlock2Ptr->frontier.field_CA8 = 0; gSaveBlock2Ptr->frontier.field_CB2 = 0; gSaveBlock2Ptr->frontier.field_CA9_a = 0; gSaveBlock2Ptr->frontier.field_CA9_b = 0; - if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[id][lvlMode])) - gSaveBlock2Ptr->frontier.field_D0C[id][lvlMode] = 0; + if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[battleMode][lvlMode])) + gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] = 0; saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); gTrainerBattleOpponent_A = 0; @@ -78,15 +113,15 @@ void sub_818E9CC(void) void sub_818EA84(void) { u32 lvlMode = gSaveBlock2Ptr->frontier.chosenLvl; - u32 id = VarGet(VAR_0x40CE); + u32 battleMode = VarGet(VAR_0x40CE); switch (gSpecialVar_0x8005) { case 0: - gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D0C[id][lvlMode]; + gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode]; break; case 1: - gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[id][lvlMode]) != 0); + gSpecialVar_Result = ((gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[battleMode][lvlMode]) != 0); break; case 2: gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_D08_0; @@ -146,18 +181,18 @@ void sub_818EA84(void) void sub_818ED28(void) { u32 lvlMode = gSaveBlock2Ptr->frontier.chosenLvl; - u32 id = VarGet(VAR_0x40CE); + u32 battleMode = VarGet(VAR_0x40CE); switch (gSpecialVar_0x8005) { case 0: - gSaveBlock2Ptr->frontier.field_D0C[id][lvlMode] = gSpecialVar_0x8006; + gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] = gSpecialVar_0x8006; break; case 1: if (gSpecialVar_0x8006) - gSaveBlock2Ptr->frontier.field_CDC |= gUnknown_0860D0EC[id][lvlMode]; + gSaveBlock2Ptr->frontier.field_CDC |= gUnknown_0860D0EC[battleMode][lvlMode]; else - gSaveBlock2Ptr->frontier.field_CDC &= gUnknown_0860D0FC[id][lvlMode]; + gSaveBlock2Ptr->frontier.field_CDC &= gUnknown_0860D0FC[battleMode][lvlMode]; break; case 2: gSaveBlock2Ptr->frontier.field_D08_0 = gSpecialVar_0x8006; @@ -1267,7 +1302,7 @@ void CreateDomeMon(u8 monPartyId, u16 tournamentTrainerId, u8 tournamentMonId, u { s32 i; u8 happiness = 0xFF; - u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // UB: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3. + u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3. u8 level = GetFrontierEnemyMonLevel(); CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[monPartyId], gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].species, @@ -1466,6 +1501,8 @@ s32 sub_818FEB4(s32 *arr, bool8 arg1) return bits; } +// Functionally equivalent, while loop is impossible to match. +#ifdef NONMATCHING s32 sub_818FFC0(s32 move, s32 species, s32 arg2) { s32 type1, type2, ability, moveType; @@ -1583,3 +1620,756 @@ s32 sub_818FFC0(s32 move, s32 species, s32 arg2) return typePower; } +#else +NAKED +s32 sub_818FFC0(s32 move, s32 species, s32 arg2) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x8\n\ + adds r3, r0, 0\n\ + adds r4, r1, 0\n\ + str r2, [sp]\n\ + movs r6, 0\n\ + movs r2, 0x14\n\ + cmp r3, 0\n\ + beq _0818FFF0\n\ + ldr r0, =0x0000ffff\n\ + cmp r3, r0\n\ + beq _0818FFF0\n\ + ldr r0, =gBattleMoves\n\ + lsls r1, r3, 1\n\ + adds r1, r3\n\ + lsls r1, 2\n\ + adds r3, r1, r0\n\ + ldrb r0, [r3, 0x1]\n\ + cmp r0, 0\n\ + bne _0818FFFC\n\ +_0818FFF0:\n\ + movs r0, 0\n\ + b _08190156\n\ + .pool\n\ +_0818FFFC:\n\ + ldr r1, =gBaseStats\n\ + lsls r0, r4, 3\n\ + subs r0, r4\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r1, [r0, 0x6]\n\ + mov r10, r1\n\ + ldrb r1, [r0, 0x7]\n\ + mov r9, r1\n\ + ldrb r0, [r0, 0x16]\n\ + mov r8, r0\n\ + ldrb r3, [r3, 0x2]\n\ + str r3, [sp, 0x4]\n\ + cmp r0, 0x1A\n\ + bne _0819002C\n\ + cmp r3, 0x4\n\ + bne _0819002C\n\ + ldr r0, [sp]\n\ + cmp r0, 0x1\n\ + bne _081900AA\n\ + movs r2, 0x8\n\ + b _081900A4\n\ + .pool\n\ +_0819002C:\n\ + ldr r0, =gTypeEffectiveness\n\ + adds r1, r6, r0\n\ + ldrb r0, [r1]\n\ + ldr r7, =gTypeEffectiveness\n\ + cmp r0, 0xFF\n\ + beq _081900A4\n\ + adds r4, r1, 0\n\ +_0819003A:\n\ + ldrb r0, [r4]\n\ + cmp r0, 0xFE\n\ + beq _08190096\n\ + ldrb r0, [r4]\n\ + ldr r1, [sp, 0x4]\n\ + cmp r0, r1\n\ + bne _08190096\n\ + ldrb r0, [r4, 0x1]\n\ + adds r5, r6, 0x1\n\ + cmp r0, r10\n\ + bne _0819006C\n\ + adds r1, r6, 0x2\n\ + mov r0, r8\n\ + cmp r0, 0x19\n\ + bne _0819005E\n\ + ldrb r0, [r4, 0x2]\n\ + cmp r0, 0x28\n\ + bne _0819006C\n\ +_0819005E:\n\ + adds r0, r1, r7\n\ + ldrb r0, [r0]\n\ + muls r0, r2\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + adds r2, r0, 0\n\ +_0819006C:\n\ + adds r0, r5, r7\n\ + ldrb r0, [r0]\n\ + cmp r0, r9\n\ + bne _08190096\n\ + cmp r10, r9\n\ + beq _08190096\n\ + adds r1, r6, 0x2\n\ + mov r0, r8\n\ + cmp r0, 0x19\n\ + bne _08190088\n\ + adds r0, r1, r7\n\ + ldrb r0, [r0]\n\ + cmp r0, 0x28\n\ + bne _08190096\n\ +_08190088:\n\ + adds r0, r1, r7\n\ + ldrb r0, [r0]\n\ + muls r0, r2\n\ + movs r1, 0xA\n\ + bl __divsi3\n\ + adds r2, r0, 0\n\ +_08190096:\n\ + adds r4, 0x3\n\ + adds r6, 0x3\n\ + ldr r1, =gTypeEffectiveness\n\ + adds r0, r6, r1\n\ + ldrb r0, [r0]\n\ + cmp r0, 0xFF\n\ + bne _0819003A\n\ +_081900A4:\n\ + ldr r0, [sp]\n\ + cmp r0, 0x1\n\ + beq _081900E0\n\ +_081900AA:\n\ + ldr r1, [sp]\n\ + cmp r1, 0x1\n\ + bgt _081900BC\n\ + cmp r1, 0\n\ + beq _081900C4\n\ + b _08190154\n\ + .pool\n\ +_081900BC:\n\ + ldr r0, [sp]\n\ + cmp r0, 0x2\n\ + beq _08190114\n\ + b _08190154\n\ +_081900C4:\n\ + cmp r2, 0xA\n\ + beq _08190146\n\ + cmp r2, 0xA\n\ + ble _08190146\n\ + cmp r2, 0x28\n\ + beq _0819014A\n\ + cmp r2, 0x28\n\ + bgt _081900DA\n\ + cmp r2, 0x14\n\ + beq _08190104\n\ + b _08190146\n\ +_081900DA:\n\ + cmp r2, 0x50\n\ + bne _08190146\n\ + b _08190100\n\ +_081900E0:\n\ + cmp r2, 0xA\n\ + beq _08190104\n\ + cmp r2, 0xA\n\ + bgt _081900F2\n\ + cmp r2, 0\n\ + beq _08190100\n\ + cmp r2, 0x5\n\ + beq _0819014A\n\ + b _08190146\n\ +_081900F2:\n\ + cmp r2, 0x28\n\ + beq _08190108\n\ + cmp r2, 0x28\n\ + ble _08190146\n\ + cmp r2, 0x50\n\ + beq _0819010E\n\ + b _08190146\n\ +_08190100:\n\ + movs r2, 0x8\n\ + b _08190154\n\ +_08190104:\n\ + movs r2, 0x2\n\ + b _08190154\n\ +_08190108:\n\ + movs r2, 0x2\n\ + negs r2, r2\n\ + b _08190154\n\ +_0819010E:\n\ + movs r2, 0x4\n\ + negs r2, r2\n\ + b _08190154\n\ +_08190114:\n\ + cmp r2, 0xA\n\ + beq _08190146\n\ + cmp r2, 0xA\n\ + bgt _08190126\n\ + cmp r2, 0\n\ + beq _0819013A\n\ + cmp r2, 0x5\n\ + beq _08190140\n\ + b _08190146\n\ +_08190126:\n\ + cmp r2, 0x28\n\ + beq _0819014E\n\ + cmp r2, 0x28\n\ + bgt _08190134\n\ + cmp r2, 0x14\n\ + beq _0819014A\n\ + b _08190146\n\ +_08190134:\n\ + cmp r2, 0x50\n\ + beq _08190152\n\ + b _08190146\n\ +_0819013A:\n\ + movs r2, 0x10\n\ + negs r2, r2\n\ + b _08190154\n\ +_08190140:\n\ + movs r2, 0x8\n\ + negs r2, r2\n\ + b _08190154\n\ +_08190146:\n\ + movs r2, 0\n\ + b _08190154\n\ +_0819014A:\n\ + movs r2, 0x4\n\ + b _08190154\n\ +_0819014E:\n\ + movs r2, 0xC\n\ + b _08190154\n\ +_08190152:\n\ + movs r2, 0x14\n\ +_08190154:\n\ + adds r0, r2, 0\n\ +_08190156:\n\ + add sp, 0x8\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + "); +} +#endif // NONMATCHING + +u8 GetDomeTrainerMonIvs(u16 trainerId) +{ + u8 fixedIv; + if (trainerId <= 99) + fixedIv = 3; + else if (trainerId <= 119) + fixedIv = 6; + else if (trainerId <= 139) + fixedIv = 9; + else if (trainerId <= 159) + fixedIv = 12; + else if (trainerId <= 179) + fixedIv = 15; + else if (trainerId <= 199) + fixedIv = 18; + else if (trainerId <= 219) + fixedIv = 21; + else + fixedIv = 31; + + return fixedIv; +} + +extern const u8 gUnknown_0860D10C[][4]; +extern const u8 gUnknown_0860D14C[]; + +s32 sub_81901A0(s32 arg0, s32 trainerId) +{ + s32 i, j, val; + + for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++) + { + if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == trainerId) + break; + } + + if (arg0 != 0) + { + if (arg0 == 3) + val = gUnknown_0860D10C[i][arg0] + 8; + else + val = gUnknown_0860D10C[i][arg0] + 4; + + for (j = gUnknown_0860D10C[i][arg0]; j < val; j++) + { + if (gUnknown_0860D14C[j] != i && !gSaveBlock2Ptr->frontier.domeTrainers[gUnknown_0860D14C[j]].unk1) + break; + } + + if (j != val) + return gUnknown_0860D14C[j]; + else + return 0xFF; + } + else + { + if (!gSaveBlock2Ptr->frontier.domeTrainers[gUnknown_0860D10C[i][0]].unk1) + return gUnknown_0860D10C[i][0]; + else + return 0xFF; + } +} + +void sub_8190298(void) +{ + gTrainerBattleOpponent_A = sub_81902AC(); +} + +u16 sub_81902AC(void) +{ + return gSaveBlock2Ptr->frontier.domeTrainers[sub_81901A0(gSaveBlock2Ptr->frontier.field_CB2, 0x3FF)].trainerId; +} + +void sub_81902E4(void) +{ + sub_8162614(gTrainerBattleOpponent_A, 0); +} + +void sub_81902F8(void) +{ + gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005; + VarSet(VAR_TEMP_0, 0); + gSaveBlock2Ptr->frontier.field_CA9_a = 1; + sub_81A4C30(); +} + +void sub_819033C(void) +{ + u8 lvlMode = gSaveBlock2Ptr->frontier.chosenLvl; + u8 battleMode = VarGet(VAR_0x40CE); + + if (gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] < 999) + gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode]++; + if (gSaveBlock2Ptr->frontier.field_D1C[battleMode][lvlMode] < 999) + gSaveBlock2Ptr->frontier.field_D1C[battleMode][lvlMode]++; + + if (gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode] > gSaveBlock2Ptr->frontier.field_D14[battleMode][lvlMode]) + gSaveBlock2Ptr->frontier.field_D14[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.field_D0C[battleMode][lvlMode]; +} + +void sub_81903B8(void) +{ + u8 taskId = CreateTask(sub_8190400, 0); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = TrainerIdToTournamentId(sub_81902AC()); + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + + SetMainCallback2(sub_8194B54); +} + +extern const struct BgTemplate gUnknown_0860CE84[4]; +extern const struct WindowTemplate gUnknown_0860CEB4[]; +extern const u8 gUnknown_08D83D50[]; +extern const u8 gUnknown_08D84970[]; +extern const u8 gUnknown_08D84F00[]; +extern const u8 gUnknown_08D85444[]; +extern const u8 gUnknown_08D85358[]; +extern const u8 gUnknown_08D85600[]; +extern const u8 gUnknown_08D854C8[]; +extern const struct CompressedSpriteSheet gUnknown_0860CF50; +extern const struct SpriteTemplate gUnknown_0860D068; +extern const struct SpriteTemplate gUnknown_0860D050; + +void sub_8190400(u8 taskId) +{ + s32 i; + s32 r5 = gTasks[taskId].data[1]; + s32 r9 = gTasks[taskId].data[2]; + s32 r7 = gTasks[taskId].data[3]; + + switch (gTasks[taskId].data[0]) + { + case 0: + SetHBlankCallback(NULL); + SetVBlankCallback(NULL); + EnableInterrupts(INTR_FLAG_VBLANK); + CpuFill32(0, (void *)VRAM, VRAM_SIZE); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0860CE84, ARRAY_COUNT(gUnknown_0860CE84)); + InitWindows(gUnknown_0860CEB4); + DeactivateAllTextPrinters(); + gBattle_BG0_X = 0; + gBattle_BG0_Y = 0; + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + if (r9 == 2) + gBattle_BG2_X = 0, gBattle_BG2_Y = 0; + else + gBattle_BG2_X = 0, gBattle_BG2_Y = 160; + + gTasks[taskId].data[0]++; + break; + case 1: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_MOSAIC, 0); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WIN1H, 0); + SetGpuReg(REG_OFFSET_WIN1V, 0); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR); + ResetPaletteFade(); + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 4; + gTasks[taskId].data[0]++; + break; + case 2: + DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D83D50, 0x2000, 0, 0); + DecompressAndLoadBgGfxUsingHeap(2, gUnknown_08D84970, 0x2000, 0, 1); + DecompressAndLoadBgGfxUsingHeap(3, gUnknown_08D84F00, 0x800, 0, 1); + LoadCompressedObjectPic(&gUnknown_0860CF50); + LoadCompressedPalette(gUnknown_08D85358, 0, 0x200); + LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200); + LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20); + if (r9 == 2) + LoadCompressedPalette(gUnknown_08D854C8, 0x50, 0x20); + CpuFill32(0, gPlttBufferFaded, 0x400); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gTasks[taskId].data[0]++; + break; + case 3: + SetVBlankCallback(sub_8194B70); + gUnknown_0203CD78 = AllocZeroed(sizeof(*gUnknown_0203CD78)); + for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++) + gUnknown_0203CD78->arr[i] |= 0xFF; + LoadMonIconPalettes(); + i = CreateTask(sub_8190CD4, 0); + gTasks[i].data[0] = 0; + gTasks[i].data[2] = 0; + gTasks[i].data[3] = r9; + gTasks[i].data[4] = r7; + if (r9 == 2) + { + sub_819314C(0, r5); + gUnknown_0203CD78->arr[16] = 1; + } + else + { + sub_81924E0(0, r5); + } + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP); + if (r9 != 0) + { + r7 = CreateSprite(&gUnknown_0860D068, 120, 4, 0); + StartSpriteAnim(&gSprites[r7], 0); + gSprites[r7].data[0] = i; + + r7 = CreateSprite(&gUnknown_0860D068, 120, 156, 0); + StartSpriteAnim(&gSprites[r7], 1); + gSprites[r7].data[0] = i; + + r7 = CreateSprite(&gUnknown_0860D050, 6, 80, 0); + StartSpriteAnim(&gSprites[r7], 0); + gSprites[r7].data[0] = i; + gSprites[r7].data[1] = 0; + if (r9 == 1) + gSprites[r7].invisible = 1; + + r7 = CreateSprite(&gUnknown_0860D050, 234, 80, 0); + StartSpriteAnim(&gSprites[r7], 1); + gSprites[r7].data[0] = i; + gSprites[r7].data[1] = 1; + } + DestroyTask(taskId); + break; + } +} + +void sub_8190790(struct Sprite *sprite) +{ + sprite->pos1.y += 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.y >= -32) + sprite->invisible = 0; + if (++sprite->data[1] == 40) + sprite->callback = SpriteCallbackDummy; + } + else + { + if (sprite->pos1.y >= 192) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_818D8F0(sprite->data[3]); + } + } +} + +void sub_81907F8(struct Sprite *sprite) +{ + sprite->pos1.y -= 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.y <= 192) + sprite->invisible = 0; + if (++sprite->data[1] == 40) + sprite->callback = SpriteCallbackDummy; + } + else + { + if (sprite->pos1.y <= -32) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_818D8F0(sprite->data[3]); + } + } +} + +void sub_8190860(struct Sprite *sprite) +{ + sprite->pos1.x += 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.x >= -32) + sprite->invisible = 0; + if (++sprite->data[1] == 64) + sprite->callback = SpriteCallbackDummy; + } + else + { + if (sprite->pos1.x >= 272) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_818D8F0(sprite->data[3]); + } + } +} + +void sub_81908CC(struct Sprite *sprite) +{ + sprite->pos1.x -= 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.x <= 272) + sprite->invisible = 0; + if (++sprite->data[1] == 64) + sprite->callback = SpriteCallbackDummy; + } + else + { + if (sprite->pos1.x <= -32) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_818D8F0(sprite->data[3]); + } + } +} + +void sub_8190938(struct Sprite *sprite) +{ + if (!sprite->data[3]) + UpdateMonIconFrame(sprite); +} + +void sub_8190950(struct Sprite *sprite) +{ + if (!sprite->data[3]) + UpdateMonIconFrame(sprite); + sprite->pos1.y += 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.y >= -16) + sprite->invisible = 0; + if (++sprite->data[1] == 40) + sprite->callback = sub_8190938; + } + else + { + if (sprite->pos1.y >= 176) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_80D2EF8(sprite); + } + } +} + +void sub_81909CC(struct Sprite *sprite) +{ + if (!sprite->data[3]) + UpdateMonIconFrame(sprite); + sprite->pos1.y -= 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.y <= 176) + sprite->invisible = 0; + if (++sprite->data[1] == 40) + sprite->callback = sub_8190938; + } + else + { + if (sprite->pos1.y <= -16) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_80D2EF8(sprite); + } + } +} + +void sub_8190A48(struct Sprite *sprite) +{ + if (!sprite->data[3]) + UpdateMonIconFrame(sprite); + sprite->pos1.x += 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.x >= -16) + sprite->invisible = 0; + if (++sprite->data[1] == 64) + sprite->callback = sub_8190938; + } + else + { + if (sprite->pos1.x >= 256) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_80D2EF8(sprite); + } + } +} + +void sub_8190AC4(struct Sprite *sprite) +{ + if (!sprite->data[3]) + UpdateMonIconFrame(sprite); + sprite->pos1.x -= 4; + if (sprite->data[0] != 0) + { + if (sprite->pos1.x <= 256) + sprite->invisible = 0; + if (++sprite->data[1] == 64) + sprite->callback = sub_8190938; + } + else + { + if (sprite->pos1.x <= -16) + { + gUnknown_0203CD78->arr[sprite->data[2]] = 0xFF; + sub_80D2EF8(sprite); + } + } +} + +extern const u8 gUnknown_0860D080[]; + +void sub_8190B40(struct Sprite *sprite) +{ + s32 taskId1 = sprite->data[0]; + s32 arrId = gTasks[gTasks[taskId1].data[4]].data[1]; + s32 tournmanetTrainerId = gUnknown_0860D080[arrId]; + s32 r12 = gSaveBlock2Ptr->frontier.field_CB2; + + if (gTasks[taskId1].data[3] == 1) + { + if (sprite->data[1]) + { + if ((gSaveBlock2Ptr->frontier.domeTrainers[tournmanetTrainerId].unk1 + && gUnknown_0203CD78->arr[16] - 1 < gSaveBlock2Ptr->frontier.domeTrainers[tournmanetTrainerId].unk2)) + { + sprite->invisible = 0; + } + else if (!gSaveBlock2Ptr->frontier.domeTrainers[tournmanetTrainerId].unk1 + && gUnknown_0203CD78->arr[16] - 1 < r12) + { + sprite->invisible = 0; + } + else + { + if (gTasks[taskId1].data[0] == 2) + sprite->invisible = 1; + } + } + else + { + if (gUnknown_0203CD78->arr[16] != 0) + { + sprite->invisible = 0; + } + else + { + if (gTasks[taskId1].data[0] == 2) + sprite->invisible = 1; + } + } + } + else + { + if (sprite->data[1]) + { + if (gUnknown_0203CD78->arr[16] > 1) + { + if (gTasks[taskId1].data[0] == 2) + sprite->invisible = 1; + } + else + { + sprite->invisible = 0; + } + } + else + { + if (gUnknown_0203CD78->arr[16] != 0) + { + sprite->invisible = 0; + } + else + { + if (gTasks[taskId1].data[0] == 2) + sprite->invisible = 1; + } + } + } +} + +void sub_8190C6C(struct Sprite *sprite) +{ + s32 taskId1 = sprite->data[0]; + + if (gTasks[taskId1].data[3] == 1) + { + if (gUnknown_0203CD78->arr[16] != 0) + { + if (gTasks[taskId1].data[0] == 2) + sprite->invisible = 1; + } + else + { + sprite->invisible = 0; + } + } + else + { + if (gUnknown_0203CD78->arr[16] != 1) + { + if (gTasks[taskId1].data[0] == 2) + sprite->invisible = 1; + } + else + { + sprite->invisible = 0; + } + } +} diff --git a/src/egg_hatch.c b/src/egg_hatch.c index ab0cd92a2..1c626cc86 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -512,7 +512,7 @@ static void CB2_EggHatch_0(void) gMain.state++; break; case 2: - copy_decompressed_tile_data_to_vram_autofree(0, gBattleTextboxTiles, 0, 0, 0); + DecompressAndLoadBgGfxUsingHeap(0, gBattleTextboxTiles, 0, 0, 0); CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0); LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20); gMain.state++; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 7960d6cba..ae15e79fe 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -1484,7 +1484,7 @@ static void InitMovingBackgroundTask(bool8 isLink) LoadPalette(sUnknown_085B51E4, 0xA0, 0x20); - copy_decompressed_tile_data_to_vram_autofree(1, sUnknown_085B4134, FALSE, 0, 0); + DecompressAndLoadBgGfxUsingHeap(1, sUnknown_085B4134, FALSE, 0, 0); CopyToBgTilemapBuffer(1, sUnknown_085B482C, 0, 0); CopyToBgTilemapBuffer(outerBgId, sUnknown_085B4D10, 0, 0); CopyBgTilemapBufferToVram(1); diff --git a/src/fieldmap.c b/src/fieldmap.c index f57c4b48f..8d1988686 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -951,7 +951,7 @@ void copy_tileset_patterns_to_vram2(struct Tileset const *tileset, u16 numTiles, if (!tileset->isCompressed) LoadBgTiles(2, tileset->tiles, numTiles * 32, offset); else - copy_decompressed_tile_data_to_vram_autofree(2, tileset->tiles, numTiles * 32, offset, 0); + DecompressAndLoadBgGfxUsingHeap(2, tileset->tiles, numTiles * 32, offset, 0); } } diff --git a/src/link.c b/src/link.c index b729f86eb..457e44a01 100644 --- a/src/link.c +++ b/src/link.c @@ -1679,7 +1679,7 @@ void CB2_LinkError(void) static void sub_800B080(void) { LoadBgTiles(0, g2BlankTilesGfx, 0x20, 0); - copy_decompressed_tile_data_to_vram_autofree(1, gWirelessLinkDisplayGfx, FALSE, 0, 0); + DecompressAndLoadBgGfxUsingHeap(1, gWirelessLinkDisplayGfx, FALSE, 0, 0); CopyToBgTilemapBuffer(1, gWirelessLinkDisplayTilemap, 0, 0); CopyBgTilemapBufferToVram(1); LoadPalette(gWirelessLinkDisplayPal, 0, 0x20); diff --git a/src/menu.c b/src/menu.c index eda9513ba..8a4b4fce5 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1801,7 +1801,7 @@ void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size, return NULL; } -void copy_decompressed_tile_data_to_vram_autofree(u8 bgId, const void *src, int size, u16 offset, u8 mode) +void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, int size, u16 offset, u8 mode) { int sizeOut; void *ptr = malloc_and_decompress(src, &sizeOut); diff --git a/src/pokedex.c b/src/pokedex.c index 0d73a9fe1..2a0033306 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1377,7 +1377,7 @@ bool8 sub_80BC514(u8 a) SetBgTilemapBuffer(2, AllocZeroed(0x800)); SetBgTilemapBuffer(1, AllocZeroed(0x800)); SetBgTilemapBuffer(0, AllocZeroed(0x800)); - copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(1, gUnknown_08DC2C5C, 0, 0); CopyToBgTilemapBuffer(3, gUnknown_08DC2DAC, 0, 0); if (a == 0) @@ -2518,7 +2518,7 @@ void sub_80BEA24(u8 taskId) } break; case 1: - copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gUnknown_08DC3080, 0, 0); FillWindowPixelBuffer(0, 0); PutWindowTilemap(0); @@ -2813,7 +2813,7 @@ void sub_80BF250(u8 taskId) } break; case 1: - copy_decompressed_tile_data_to_vram_autofree(3, &gPokedexMenu_Gfx, 0x2000, 0, 0); + DecompressAndLoadBgGfxUsingHeap(3, &gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, &gUnknown_08DC3198, 0, 0); FillWindowPixelBuffer(0, 0); PutWindowTilemap(0); @@ -3007,7 +3007,7 @@ void sub_80BF82C(u8 taskId) } break; case 1: - copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gUnknown_08DC2E6C, 0, 0); FillWindowPixelBuffer(0, 0); PutWindowTilemap(0); @@ -3354,7 +3354,7 @@ void sub_80BFE38(u8 taskId) } break; case 1: - copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gUnknown_08DC3080, 0, 0); FillWindowPixelBuffer(0, 0); PutWindowTilemap(0); @@ -4397,7 +4397,7 @@ void sub_80C12E0(u8 taskId) InitWindows(gUnknown_0856F008); DeactivateAllTextPrinters(); PutWindowTilemap(0); - copy_decompressed_tile_data_to_vram_autofree(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0); + DecompressAndLoadBgGfxUsingHeap(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0); if (!IsNationalPokedexEnabled()) CopyToBgTilemapBuffer(3, gPokedexSearch2_Tilemap, 0, 0);