From d31600e70e53fb252fe67e8c427ecb7498719b86 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Thu, 10 May 2018 03:30:42 -0400 Subject: [PATCH] finish decompiling pokedex --- asm/pokedex.s | 5073 -------------------------------------------- include/global.h | 10 +- include/graphics.h | 5 + include/pokedex.h | 2 +- include/strings.h | 12 + ld_script.txt | 1 - src/pokedex.c | 3293 +++++++++++++++++++++++----- sym_ewram.txt | 12 +- 8 files changed, 2750 insertions(+), 5658 deletions(-) delete mode 100644 asm/pokedex.s diff --git a/asm/pokedex.s b/asm/pokedex.s deleted file mode 100644 index 5dc45c766..000000000 --- a/asm/pokedex.s +++ /dev/null @@ -1,5073 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80BFD0C -sub_80BFD0C: @ 80BFD0C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r0, 0x1 - bl GetBgTilemapBuffer - adds r7, r0, 0 - movs r1, 0 -_080BFD22: - lsls r0, r1, 3 - subs r0, r1 - adds r0, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - movs r3, 0x80 - lsls r3, 7 - cmp r1, r8 - bne _080BFD38 - movs r3, 0x80 - lsls r3, 6 -_080BFD38: - movs r2, 0 - adds r6, r1, 0x1 - ldr r4, =0x00000fff -_080BFD3E: - adds r1, r5, r2 - lsls r1, 1 - adds r1, r7 - ldrh r0, [r1] - ands r0, r4 - orrs r0, r3 - strh r0, [r1] - adds r1, 0x40 - ldrh r0, [r1] - ands r0, r4 - orrs r0, r3 - strh r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x6 - bls _080BFD3E - lsls r0, r6, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bls _080BFD22 - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80BFD0C - - thumb_func_start sub_80BFD7C -sub_80BFD7C: @ 80BFD7C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r0, 0x1 - bl GetBgTilemapBuffer - adds r7, r0, 0 - movs r1, 0 -_080BFD92: - lsls r0, r1, 3 - subs r0, r1 - adds r0, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r1, r8 - beq _080BFDA4 - cmp r1, 0x3 - bne _080BFDAA -_080BFDA4: - movs r3, 0x80 - lsls r3, 6 - b _080BFDAE -_080BFDAA: - movs r3, 0x80 - lsls r3, 7 -_080BFDAE: - movs r2, 0 - adds r5, r1, 0x1 - ldr r4, =0x00000fff -_080BFDB4: - adds r1, r6, r2 - lsls r1, 1 - adds r1, r7 - ldrh r0, [r1] - ands r0, r4 - orrs r0, r3 - strh r0, [r1] - adds r1, 0x40 - ldrh r0, [r1] - ands r0, r4 - orrs r0, r3 - strh r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x6 - bls _080BFDB4 - lsls r0, r5, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bls _080BFD92 - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80BFD7C - - thumb_func_start CreateDexDisplayMonDataTask -CreateDexDisplayMonDataTask: @ 80BFDF4 - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r4, 16 - lsrs r4, 16 - ldr r0, =sub_80BFE38 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r2, 0 - strh r2, [r1, 0x8] - strh r4, [r1, 0xA] - strh r5, [r1, 0x20] - lsrs r5, 16 - strh r5, [r1, 0x22] - strh r6, [r1, 0x24] - lsrs r6, 16 - strh r6, [r1, 0x26] - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end CreateDexDisplayMonDataTask - - thumb_func_start sub_80BFE38 -sub_80BFE38: @ 80BFE38 - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldrh r4, [r0, 0xA] - movs r2, 0x8 - ldrsh r0, [r0, r2] - adds r2, r1, 0 - cmp r0, 0x6 - bhi _080BFE84 - lsls r0, 2 - ldr r1, =_080BFE68 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080BFE68: - .4byte _080BFE84 - .4byte _080BFF0C - .4byte _080BFF78 - .4byte _080BFF82 - .4byte _080BFFA8 - .4byte _080C0000 - .4byte _080C0044 -_080BFE84: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080BFE92 - b _080C0074 -_080BFE92: - ldr r1, =gUnknown_030060B4 - ldr r0, =gMain - ldr r0, [r0, 0xC] - str r0, [r1] - movs r0, 0 - bl SetVBlankCallback - movs r0, 0x80 - lsls r0, 1 - bl sub_80C09B0 - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0856E668 - movs r0, 0 - movs r2, 0x2 - bl InitBgsFromTemplates - movs r4, 0x80 - lsls r4, 4 - adds r0, r4, 0 - bl AllocZeroed - adds r1, r0, 0 - movs r0, 0x3 - bl SetBgTilemapBuffer - adds r0, r4, 0 - bl AllocZeroed - adds r1, r0, 0 - movs r0, 0x2 - bl SetBgTilemapBuffer - ldr r0, =gUnknown_0856E670 - bl InitWindows - bl DeactivateAllTextPrinters - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - movs r1, 0x1 - strh r1, [r0, 0x8] - b _080C0074 - .pool -_080BFF0C: - ldr r1, =gPokedexMenu_Gfx - movs r2, 0x80 - lsls r2, 6 - movs r0, 0 - str r0, [sp] - movs r0, 0x3 - movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree - ldr r1, =gUnknown_08DC3080 - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - movs r0, 0 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - bl PutWindowTilemap - movs r0, 0x1 - bl PutWindowTilemap - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - ldrh r1, [r4, 0xA] - movs r0, 0x1 - bl sub_80C0D30 - movs r0, 0x1 - movs r1, 0x2 - bl CopyWindowToVram - bl ResetPaletteFade - movs r0, 0 - bl sub_80BC844 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080C0074 - .pool -_080BFF78: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r2 - b _080C0038 -_080BFF82: - bl IsNationalPokedexEnabled - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x1 - bl sub_80C020C - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - movs r0, 0x2 - bl CopyBgTilemapBufferToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - b _080C002E -_080BFFA8: - adds r0, r4, 0 - movs r1, 0x30 - movs r2, 0x38 - movs r3, 0 - bl sub_80C0E9C - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gSprites - lsls r1, r4, 4 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - ldrb r2, [r1, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x5] - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r0, =gUnknown_030060B4 - ldr r0, [r0] - bl SetVBlankCallback - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - strh r4, [r0, 0xE] - b _080C0038 - .pool -_080C0000: - 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 r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg -_080C002E: - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 -_080C0038: - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - b _080C0074 - .pool -_080C0044: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _080C0074 - adds r0, r4, 0 - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r0, 16 - movs r1, 0 - bl PlayCry1 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - strh r6, [r0, 0xC] - ldr r1, =sub_80C0088 - str r1, [r0] -_080C0074: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80BFE38 - - thumb_func_start sub_80C0088 -sub_80C0088: @ 80C0088 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _080C00E8 - ldr r0, =0x0000ffff - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r3, =gSprites - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - movs r0, 0xE - ldrsh r2, [r1, r0] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r3, 0x1C - adds r0, r3 - ldr r2, =sub_80C01CC - str r2, [r0] - ldr r0, =blockset_load_palette_to_gpu - str r0, [r1] - b _080C011E - .pool -_080C00E8: - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0xC] - adds r1, 0x1 - strh r1, [r0, 0xC] - movs r0, 0x10 - ands r1, r0 - cmp r1, 0 - beq _080C0114 - ldr r0, =gPokedexText_Pal + 2 - movs r1, 0x31 - movs r2, 0xE - bl LoadPalette - b _080C011E - .pool -_080C0114: - ldr r0, =gPokedexCaughtScreenFade_Pal + 0x2 - movs r1, 0x31 - movs r2, 0xE - bl LoadPalette -_080C011E: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C0088 - - thumb_func_start blockset_load_palette_to_gpu -blockset_load_palette_to_gpu: @ 80C012C - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _080C01BA - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - bl FreeAllWindowBuffers - movs r0, 0x2 - bl GetBgTilemapBuffer - cmp r0, 0 - beq _080C015A - bl Free -_080C015A: - movs r0, 0x3 - bl GetBgTilemapBuffer - cmp r0, 0 - beq _080C0168 - bl Free -_080C0168: - ldr r0, =gTasks - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - adds r4, r0 - ldrh r0, [r4, 0xA] - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r4, 0x22] - lsls r1, 16 - ldrh r2, [r4, 0x20] - orrs r1, r2 - ldrh r2, [r4, 0x26] - lsls r2, 16 - ldrh r3, [r4, 0x24] - orrs r2, r3 - ldr r5, =gSprites - movs r3, 0xE - ldrsh r4, [r4, r3] - lsls r3, r4, 4 - adds r3, r4 - lsls r3, 2 - adds r3, r5 - ldrb r4, [r3, 0x5] - lsrs r4, 4 - bl GetFrontSpritePalFromSpeciesAndPersonality - lsls r4, 4 - movs r2, 0x80 - lsls r2, 1 - adds r1, r2, 0 - orrs r4, r1 - adds r1, r4, 0 - movs r2, 0x20 - bl LoadCompressedPalette - adds r0, r6, 0 - bl DestroyTask -_080C01BA: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end blockset_load_palette_to_gpu - - thumb_func_start sub_80C01CC -sub_80C01CC: @ 80C01CC - push {lr} - adds r1, r0, 0 - ldrh r2, [r1, 0x20] - movs r3, 0x20 - ldrsh r0, [r1, r3] - cmp r0, 0x77 - bgt _080C01DE - adds r0, r2, 0x2 - strh r0, [r1, 0x20] -_080C01DE: - ldrh r2, [r1, 0x20] - movs r3, 0x20 - ldrsh r0, [r1, r3] - cmp r0, 0x78 - ble _080C01EC - subs r0, r2, 0x2 - strh r0, [r1, 0x20] -_080C01EC: - ldrh r2, [r1, 0x22] - movs r3, 0x22 - ldrsh r0, [r1, r3] - cmp r0, 0x4F - bgt _080C01FA - adds r0, r2, 0x1 - strh r0, [r1, 0x22] -_080C01FA: - ldrh r2, [r1, 0x22] - movs r3, 0x22 - ldrsh r0, [r1, r3] - cmp r0, 0x50 - ble _080C0208 - subs r0, r2, 0x1 - strh r0, [r1, 0x22] -_080C0208: - pop {r0} - bx r0 - thumb_func_end sub_80C01CC - - thumb_func_start sub_80C020C -sub_80C020C: @ 80C020C - push {r4-r7,lr} - sub sp, 0x30 - adds r6, r0, 0 - adds r5, r1, 0 - adds r7, r2, 0 - cmp r3, 0 - beq _080C0234 - ldr r4, =gText_PokedexRegistration - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0xF0 - bl GetStringCenterAlignXOffset - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - movs r2, 0 - bl sub_80BE8DC -_080C0234: - cmp r5, 0 - bne _080C024C - lsls r4, r6, 16 - lsrs r0, r4, 16 - bl NationalToHoennOrder - lsls r0, 16 - lsrs r5, r0, 16 - b _080C0250 - .pool -_080C024C: - adds r5, r6, 0 - lsls r4, r6, 16 -_080C0250: - ldr r1, =gText_UnkCtrlF908Clear01 - mov r0, sp - bl StringCopy - adds r1, r5, 0 - movs r2, 0x2 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - mov r0, sp - movs r1, 0x60 - movs r2, 0x19 - bl sub_80BE8DC - lsrs r0, r4, 16 - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - beq _080C028C - movs r0, 0xB - muls r1, r0 - ldr r0, =gSpeciesNames - adds r0, r1, r0 - b _080C028E - .pool -_080C028C: - ldr r0, =sText_TenDashes2 -_080C028E: - movs r1, 0x84 - movs r2, 0x19 - bl sub_80BE8DC - cmp r7, 0 - beq _080C02AC - add r4, sp, 0x10 - adds r0, r6, 0 - adds r1, r4, 0 - bl CopyMonCategoryText - adds r0, r4, 0 - b _080C02AE - .pool -_080C02AC: - ldr r0, =gText_5MarksPokemon -_080C02AE: - movs r1, 0x64 - movs r2, 0x29 - bl sub_80BE8DC - ldr r0, =gText_HTHeight - movs r1, 0x60 - movs r2, 0x39 - bl sub_80BE8DC - ldr r0, =gText_WTWeight - movs r1, 0x60 - movs r2, 0x49 - bl sub_80BE8DC - cmp r7, 0 - beq _080C02FC - ldr r0, =gPokedexEntries - lsls r4, r6, 5 - adds r4, r0 - ldrh r0, [r4, 0xC] - movs r1, 0x81 - movs r2, 0x39 - bl sub_80C0354 - ldrh r0, [r4, 0xE] - movs r1, 0x81 - movs r2, 0x49 - bl sub_80C0460 - b _080C0310 - .pool -_080C02FC: - ldr r0, =gText_UnkHeight - movs r1, 0x81 - movs r2, 0x39 - bl sub_80BE8DC - ldr r0, =gText_UnkWeight - movs r1, 0x81 - movs r2, 0x49 - bl sub_80BE8DC -_080C0310: - cmp r7, 0 - beq _080C032C - ldr r0, =gPokedexEntries - lsls r1, r6, 5 - adds r0, 0x10 - adds r1, r0 - ldr r4, [r1] - b _080C032E - .pool -_080C032C: - ldr r4, =gUnknown_0855D30C -_080C032E: - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0xF0 - bl GetStringCenterAlignXOffset - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - movs r2, 0x5F - bl sub_80BE8DC - add sp, 0x30 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C020C - - thumb_func_start sub_80C0354 -sub_80C0354: @ 80C0354 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - ldr r1, =0x00002710 - muls r0, r1 - movs r1, 0xFE - bl __divsi3 - adds r7, r0, 0 - movs r1, 0xA - bl __umodsi3 - cmp r0, 0x4 - bls _080C0386 - adds r7, 0xA -_080C0386: - adds r0, r7, 0 - movs r1, 0x78 - bl __udivsi3 - adds r6, r0, 0 - lsls r0, r6, 4 - subs r0, r6 - lsls r0, 3 - subs r0, r7, r0 - movs r1, 0xA - bl __udivsi3 - adds r7, r0, 0 - mov r1, sp - movs r0, 0xFC - strb r0, [r1] - adds r1, 0x1 - movs r0, 0x13 - strb r0, [r1] - adds r0, r6, 0 - movs r1, 0xA - bl __udivsi3 - adds r2, r0, 0 - cmp r2, 0 - bne _080C03D4 - mov r1, sp - adds r1, 0x2 - movs r0, 0x12 - strb r0, [r1] - movs r5, 0x4 - adds r1, 0x1 - adds r0, r6, 0 - adds r0, 0xA1 - strb r0, [r1] - b _080C03F4 - .pool -_080C03D4: - mov r1, sp - adds r1, 0x2 - movs r0, 0xC - strb r0, [r1] - adds r1, 0x1 - adds r0, r2, 0 - adds r0, 0xA1 - strb r0, [r1] - movs r5, 0x5 - add r4, sp, 0x4 - adds r0, r6, 0 - movs r1, 0xA - bl __umodsi3 - adds r0, 0xA1 - strb r0, [r4] -_080C03F4: - adds r1, r5, 0 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r2, r5, 0 - add r1, sp - movs r0, 0xB4 - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - mov r0, sp - adds r4, r0, r2 - adds r0, r7, 0 - movs r1, 0xA - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r4] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - mov r1, sp - adds r4, r1, r6 - adds r0, r7, 0 - movs r1, 0xA - bl __umodsi3 - adds r0, 0xA1 - strb r0, [r4] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r1, sp - adds r2, r1, r5 - movs r1, 0xB2 - strb r1, [r2] - mov r2, sp - adds r1, r2, r0 - movs r0, 0xFF - strb r0, [r1] - mov r0, sp - mov r1, r9 - mov r2, r8 - bl sub_80BE8DC - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C0354 - - thumb_func_start sub_80C0460 -sub_80C0460: @ 80C0460 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - lsrs r2, 24 - str r2, [sp, 0x10] - ldr r5, =0x000186a0 - muls r0, r5 - ldr r1, =0x000011b8 - bl __divsi3 - adds r7, r0, 0 - movs r1, 0xA - bl __umodsi3 - cmp r0, 0x4 - bls _080C0494 - adds r7, 0xA -_080C0494: - movs r0, 0 - mov r8, r0 - mov r4, sp - adds r0, r7, 0 - adds r1, r5, 0 - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r4] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xA1 - bne _080C04C0 - movs r6, 0x1 - mov r1, sp - movs r0, 0x77 - strb r0, [r1] - b _080C04C6 - .pool -_080C04C0: - movs r1, 0x1 - mov r8, r1 - movs r6, 0x1 -_080C04C6: - ldr r1, =0x000186a0 - adds r0, r7, 0 - bl __umodsi3 - adds r7, r0, 0 - mov r4, sp - adds r4, 0x1 - ldr r1, =0x00002710 - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r4] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xA1 - bne _080C0504 - mov r2, r8 - cmp r2, 0 - bne _080C0504 - adds r1, r6, 0 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - add r1, sp - movs r0, 0x77 - strb r0, [r1] - b _080C050E - .pool -_080C0504: - movs r3, 0x1 - mov r8, r3 - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_080C050E: - ldr r1, =0x00002710 - adds r0, r7, 0 - bl __umodsi3 - adds r7, r0, 0 - mov r0, sp - adds r4, r0, r6 - movs r1, 0xFA - lsls r1, 2 - adds r0, r7, 0 - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r4] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xA1 - bne _080C054C - mov r1, r8 - cmp r1, 0 - bne _080C054C - adds r1, r6, 0 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - add r1, sp - movs r0, 0x77 - strb r0, [r1] - b _080C0552 - .pool -_080C054C: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_080C0552: - movs r1, 0xFA - lsls r1, 2 - adds r0, r7, 0 - bl __umodsi3 - adds r7, r0, 0 - adds r1, r6, 0 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r5, r6, 0 - mov r2, sp - adds r4, r2, r1 - adds r0, r7, 0 - movs r1, 0x64 - bl __udivsi3 - adds r0, 0xA1 - movs r3, 0 - mov r9, r3 - strb r0, [r4] - adds r0, r7, 0 - movs r1, 0x64 - bl __umodsi3 - adds r7, r0, 0 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r1, r6, 0 - mov r2, sp - adds r0, r2, r5 - movs r3, 0xAD - mov r8, r3 - mov r2, r8 - strb r2, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r5, r6, 0 - mov r3, sp - adds r4, r3, r1 - adds r0, r7, 0 - movs r1, 0xA - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r4] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r1, r6, 0 - mov r2, sp - adds r0, r2, r5 - mov r3, r9 - strb r3, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r2, r6, 0 - add r1, sp - movs r0, 0xE0 - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r3, r6, 0 - mov r0, sp - adds r1, r0, r2 - movs r0, 0xD6 - strb r0, [r1] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - adds r2, r6, 0 - mov r0, sp - adds r1, r0, r3 - movs r0, 0xE7 - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r3, sp - adds r1, r3, r2 - mov r2, r8 - strb r2, [r1] - adds r1, r3, r0 - movs r0, 0xFF - strb r0, [r1] - mov r0, sp - mov r1, r10 - ldr r2, [sp, 0x10] - bl sub_80BE8DC - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C0460 - - thumb_func_start sub_80C0620 -sub_80C0620: @ 80C0620 - lsls r0, 16 - lsrs r0, 11 - ldr r1, =gPokedexEntries - adds r0, r1 - bx lr - .pool - thumb_func_end sub_80C0620 - - thumb_func_start GetPokedexHeightWeight -GetPokedexHeightWeight: @ 80C0630 - push {lr} - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0 - beq _080C0646 - cmp r1, 0x1 - beq _080C0654 - movs r0, 0x1 - b _080C065C -_080C0646: - ldr r0, =gPokedexEntries - lsls r1, r2, 5 - adds r1, r0 - ldrh r0, [r1, 0xC] - b _080C065C - .pool -_080C0654: - ldr r0, =gPokedexEntries - lsls r1, r2, 5 - adds r1, r0 - ldrh r0, [r1, 0xE] -_080C065C: - pop {r1} - bx r1 - .pool - thumb_func_end GetPokedexHeightWeight - - thumb_func_start GetSetPokedexFlag -@ u8 GetSetPokedexFlag(u16 nationalPokedexNum, u8 op) -GetSetPokedexFlag: @ 80C0664 - push {r4-r7,lr} - lsls r0, 16 - lsls r1, 24 - lsrs r2, r1, 24 - adds r3, r2, 0 - ldr r1, =0xffff0000 - adds r0, r1 - lsrs r1, r0, 16 - lsrs r0, 19 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x7 - ands r1, r0 - movs r0, 0x80 - lsls r0, 17 - lsls r0, r1 - lsrs r5, r0, 24 - movs r6, 0 - cmp r2, 0x1 - beq _080C06FC - cmp r2, 0x1 - bgt _080C069C - cmp r2, 0 - beq _080C06AA - b _080C07E8 - .pool -_080C069C: - cmp r3, 0x2 - bne _080C06A2 - b _080C079C -_080C06A2: - cmp r3, 0x3 - bne _080C06A8 - b _080C07D8 -_080C06A8: - b _080C07E8 -_080C06AA: - ldr r1, =gSaveBlock2Ptr - ldr r0, [r1] - adds r0, 0x5C - adds r0, r4 - ldrb r2, [r0] - ands r2, r5 - adds r7, r1, 0 - cmp r2, 0 - bne _080C06BE - b _080C07E8 -_080C06BE: - ldr r0, =gSaveBlock1Ptr - ldr r3, [r0] - ldr r6, =0x00000988 - adds r1, r3, r6 - adds r1, r4 - ldrb r1, [r1] - ands r1, r5 - adds r6, r0, 0 - cmp r2, r1 - bne _080C06E0 - ldr r1, =0x00003b24 - adds r0, r3, r1 - adds r0, r4 - ldrb r0, [r0] - ands r0, r5 - cmp r2, r0 - beq _080C073E -_080C06E0: - ldr r1, [r7] - adds r1, 0x5C - adds r1, r4 - mvns r3, r5 - b _080C076A - .pool -_080C06FC: - ldr r1, =gSaveBlock2Ptr - ldr r3, [r1] - adds r0, r3, 0 - adds r0, 0x28 - adds r0, r4 - ldrb r2, [r0] - ands r2, r5 - adds r7, r1, 0 - cmp r2, 0 - beq _080C07E8 - adds r0, r3, 0 - adds r0, 0x5C - adds r0, r4 - ldrb r0, [r0] - ands r0, r5 - ldr r6, =gSaveBlock1Ptr - cmp r2, r0 - bne _080C0754 - ldr r1, [r6] - ldr r3, =0x00000988 - adds r0, r1, r3 - adds r0, r4 - ldrb r0, [r0] - ands r0, r5 - cmp r2, r0 - bne _080C0754 - ldr r3, =0x00003b24 - adds r0, r1, r3 - adds r0, r4 - ldrb r0, [r0] - ands r0, r5 - cmp r2, r0 - bne _080C0754 -_080C073E: - movs r6, 0x1 - b _080C07E8 - .pool -_080C0754: - ldr r1, [r7] - adds r1, 0x28 - adds r1, r4 - mvns r3, r5 - ldrb r2, [r1] - adds r0, r3, 0 - ands r0, r2 - strb r0, [r1] - ldr r1, [r7] - adds r1, 0x5C - adds r1, r4 -_080C076A: - ldrb r2, [r1] - adds r0, r3, 0 - ands r0, r2 - strb r0, [r1] - ldr r1, [r6] - ldr r0, =0x00000988 - adds r1, r0 - adds r1, r4 - ldrb r2, [r1] - adds r0, r3, 0 - ands r0, r2 - strb r0, [r1] - ldr r0, [r6] - ldr r1, =0x00003b24 - adds r0, r1 - adds r0, r4 - ldrb r1, [r0] - ands r3, r1 - strb r3, [r0] - movs r6, 0 - b _080C07E8 - .pool -_080C079C: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - adds r1, 0x5C - adds r1, r4 - ldrb r2, [r1] - adds r0, r5, 0 - orrs r0, r2 - strb r0, [r1] - ldr r3, =gSaveBlock1Ptr - ldr r1, [r3] - ldr r0, =0x00000988 - adds r1, r0 - adds r1, r4 - ldrb r2, [r1] - adds r0, r5, 0 - orrs r0, r2 - strb r0, [r1] - ldr r1, [r3] - ldr r3, =0x00003b24 - adds r1, r3 - b _080C07DE - .pool -_080C07D8: - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - adds r1, 0x28 -_080C07DE: - adds r1, r4 - ldrb r2, [r1] - adds r0, r5, 0 - orrs r0, r2 - strb r0, [r1] -_080C07E8: - adds r0, r6, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end GetSetPokedexFlag - - thumb_func_start GetNationalPokedexCount -GetNationalPokedexCount: @ 80C07F4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 - movs r0, 0 - ldr r7, =0x00000181 -_080C0800: - cmp r6, 0 - beq _080C0810 - cmp r6, 0x1 - beq _080C081A - adds r4, r0, 0x1 - b _080C0832 - .pool -_080C0810: - adds r4, r0, 0x1 - lsls r0, r4, 16 - lsrs r0, 16 - movs r1, 0 - b _080C0822 -_080C081A: - adds r4, r0, 0x1 - lsls r0, r4, 16 - lsrs r0, 16 - movs r1, 0x1 -_080C0822: - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _080C0832 - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 -_080C0832: - lsls r0, r4, 16 - lsrs r0, 16 - cmp r0, r7 - bls _080C0800 - adds r0, r5, 0 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end GetNationalPokedexCount - - thumb_func_start GetHoennPokedexCount -GetHoennPokedexCount: @ 80C0844 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 - movs r0, 0 -_080C084E: - cmp r6, 0 - beq _080C085A - cmp r6, 0x1 - beq _080C086C - adds r4, r0, 0x1 - b _080C088C -_080C085A: - adds r4, r0, 0x1 - lsls r0, r4, 16 - lsrs r0, 16 - bl HoennToNationalOrder - lsls r0, 16 - lsrs r0, 16 - movs r1, 0 - b _080C087C -_080C086C: - adds r4, r0, 0x1 - lsls r0, r4, 16 - lsrs r0, 16 - bl HoennToNationalOrder - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 -_080C087C: - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _080C088C - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 -_080C088C: - lsls r0, r4, 16 - lsrs r0, 16 - cmp r0, 0xC9 - bls _080C084E - adds r0, r5, 0 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end GetHoennPokedexCount - - thumb_func_start sub_80C089C -sub_80C089C: @ 80C089C - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 - movs r0, 0 -_080C08A6: - cmp r6, 0 - beq _080C08B2 - cmp r6, 0x1 - beq _080C08BC - adds r4, r0, 0x1 - b _080C08D4 -_080C08B2: - adds r4, r0, 0x1 - lsls r0, r4, 16 - lsrs r0, 16 - movs r1, 0 - b _080C08C4 -_080C08BC: - adds r4, r0, 0x1 - lsls r0, r4, 16 - lsrs r0, 16 - movs r1, 0x1 -_080C08C4: - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _080C08D4 - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 -_080C08D4: - lsls r0, r4, 16 - lsrs r0, 16 - cmp r0, 0x96 - bls _080C08A6 - adds r0, r5, 0 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80C089C - - thumb_func_start sub_80C08E4 -sub_80C08E4: @ 80C08E4 - push {r4,lr} - movs r0, 0 -_080C08E8: - adds r0, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - bl HoennToNationalOrder - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - bne _080C0908 - movs r0, 0 - b _080C0910 -_080C0908: - adds r0, r4, 0 - cmp r0, 0xC7 - bls _080C08E8 - movs r0, 0x1 -_080C0910: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80C08E4 - - thumb_func_start sub_80C0918 -sub_80C0918: @ 80C0918 - push {r4,lr} - movs r0, 0 -_080C091C: - adds r0, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - bne _080C0934 - movs r0, 0 - b _080C093C -_080C0934: - adds r0, r4, 0 - cmp r0, 0x95 - bls _080C091C - movs r0, 0x1 -_080C093C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80C0918 - - thumb_func_start sub_80C0944 -sub_80C0944: @ 80C0944 - push {r4,r5,lr} - movs r0, 0 -_080C0948: - adds r0, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _080C0996 - adds r0, r4, 0 - cmp r0, 0x95 - bls _080C0948 - movs r0, 0x97 -_080C0964: - adds r0, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _080C0996 - adds r0, r4, 0 - cmp r0, 0xF7 - bls _080C0964 - movs r0, 0xFB - ldr r5, =0x0000017f -_080C0982: - adds r0, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - bne _080C09A0 -_080C0996: - movs r0, 0 - b _080C09A8 - .pool -_080C09A0: - adds r0, r4, 0 - cmp r0, r5 - bls _080C0982 - movs r0, 0x1 -_080C09A8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80C0944 - - thumb_func_start sub_80C09B0 -sub_80C09B0: @ 80C09B0 - push {r4,r5,lr} - lsls r0, 16 - lsrs r4, r0, 16 - adds r5, r4, 0 - movs r1, 0x80 - lsls r1, 1 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - bne _080C09E2 - movs r0, 0 - bl ClearGpuRegBits - movs r0, 0x8 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg -_080C09E2: - movs r1, 0x80 - lsls r1, 2 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - bne _080C0A0C - movs r0, 0 - bl ClearGpuRegBits - movs r0, 0xA - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg -_080C0A0C: - movs r1, 0x80 - lsls r1, 3 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - bne _080C0A36 - movs r0, 0 - bl ClearGpuRegBits - movs r0, 0xC - movs r1, 0 - bl SetGpuReg - movs r0, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg -_080C0A36: - movs r1, 0x80 - lsls r1, 4 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - bne _080C0A60 - movs r0, 0 - bl ClearGpuRegBits - movs r0, 0xE - movs r1, 0 - bl SetGpuReg - movs r0, 0x1C - movs r1, 0 - bl SetGpuReg - movs r0, 0x1E - movs r1, 0 - bl SetGpuReg -_080C0A60: - movs r1, 0x80 - lsls r1, 5 - ands r5, r1 - cmp r5, 0 - bne _080C0A7E - movs r0, 0 - bl ClearGpuRegBits - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x8 - strb r0, [r1] -_080C0A7E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C09B0 - - thumb_func_start sub_80C0A88 -sub_80C0A88: @ 80C0A88 - push {r4-r6,lr} - sub sp, 0x18 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - add r4, sp, 0x14 - movs r6, 0 - strb r6, [r4] - adds r5, r4, 0 - movs r4, 0xF - strb r4, [r5, 0x1] - movs r4, 0x3 - strb r4, [r5, 0x2] - str r6, [sp] - str r6, [sp, 0x4] - str r5, [sp, 0x8] - subs r4, 0x4 - str r4, [sp, 0xC] - str r1, [sp, 0x10] - movs r1, 0x1 - bl AddTextPrinterParameterized2 - add sp, 0x18 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80C0A88 - - thumb_func_start sub_80C0AC4 -sub_80C0AC4: @ 80C0AC4 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x4 - adds r6, r0, 0 - adds r4, r1, 0 - mov r8, r2 - mov r9, r3 - lsls r6, 24 - lsrs r6, 24 - lsls r4, 16 - lsrs r4, 16 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - mov r0, r9 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - mov r5, sp - adds r0, r4, 0 - movs r1, 0x64 - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r5] - mov r5, sp - adds r0, r4, 0 - movs r1, 0x64 - bl __umodsi3 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r4, 0 - movs r1, 0xA - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r5, 0x1] - mov r5, sp - adds r0, r4, 0 - movs r1, 0xA - bl __umodsi3 - adds r0, 0xA1 - strb r0, [r5, 0x2] - mov r1, sp - movs r0, 0xFF - strb r0, [r1, 0x3] - adds r0, r6, 0 - mov r2, r8 - mov r3, r9 - bl sub_80C0A88 - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80C0AC4 - - thumb_func_start sub_80C0B44 -sub_80C0B44: @ 80C0B44 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, 16 - lsrs r5, r1, 16 - lsls r2, 24 - lsrs r7, r2, 24 - lsls r3, 24 - lsrs r6, r3, 24 - movs r4, 0 - movs r2, 0xFF -_080C0B62: - mov r1, sp - adds r0, r1, r4 - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xA - bls _080C0B62 - adds r0, r5, 0 - bl NationalPokedexNumToSpecies - adds r5, r0, 0 - cmp r5, 0 - beq _080C0BC0 - movs r4, 0 - ldr r2, =gSpeciesNames - movs r0, 0xB - adds r1, r5, 0 - muls r1, r0 - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0xFF - beq _080C0BD4 - adds r3, r2, 0 - adds r2, r1, 0 -_080C0B98: - mov r0, sp - adds r1, r0, r4 - adds r0, r4, r2 - adds r0, r3 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, r2 - adds r0, r3 - ldrb r0, [r0] - cmp r0, 0xFF - beq _080C0BD4 - cmp r4, 0x9 - bls _080C0B98 - b _080C0BD4 - .pool -_080C0BC0: - movs r4, 0 - movs r1, 0xAE -_080C0BC4: - mov r2, sp - adds r0, r2, r4 - strb r1, [r0] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x4 - bls _080C0BC4 -_080C0BD4: - mov r0, r8 - mov r1, sp - adds r2, r7, 0 - adds r3, r6, 0 - bl sub_80C0A88 - adds r0, r4, 0 - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80C0B44 - - thumb_func_start sub_80C0BF0 -sub_80C0BF0: @ 80C0BF0 - push {r4-r7,lr} - sub sp, 0xC - adds r4, r1, 0 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r2, 24 - lsrs r2, 24 - mov r12, r2 - lsls r3, 24 - lsrs r5, r3, 24 - movs r2, 0 - movs r1, 0 -_080C0C08: - mov r3, sp - adds r0, r3, r2 - strb r1, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xA - bls _080C0C08 - movs r3, 0 - ldrb r0, [r4] - cmp r0, 0 - beq _080C0C32 -_080C0C20: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - adds r0, r4, r3 - ldrb r0, [r0] - cmp r0, 0 - beq _080C0C32 - cmp r3, 0xA - bls _080C0C20 -_080C0C32: - movs r2, 0 - cmp r2, r3 - bcs _080C0C52 -_080C0C38: - adds r0, r2, 0 - adds r0, 0xB - subs r0, r3 - mov r7, sp - adds r1, r7, r0 - adds r0, r4, r2 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r3 - bcc _080C0C38 -_080C0C52: - mov r1, sp - movs r0, 0xFF - strb r0, [r1, 0xB] - adds r0, r6, 0 - mov r2, r12 - adds r3, r5, 0 - bl sub_80C0A88 - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C0BF0 - - thumb_func_start sub_80C0C6C -sub_80C0C6C: @ 80C0C6C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 24 - lsrs r7, r2, 24 - lsls r3, 24 - lsrs r6, r3, 24 - movs r5, 0 - movs r1, 0xFA - lsls r1, 2 - adds r0, r4, 0 - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _080C0CA2 - mov r1, sp - movs r0, 0x77 - strb r0, [r1] - b _080C0CAA -_080C0CA2: - mov r1, sp - adds r0, 0xA1 - strb r0, [r1] - movs r5, 0x1 -_080C0CAA: - movs r1, 0xFA - lsls r1, 2 - adds r0, r4, 0 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _080C0CD0 - cmp r5, 0 - bne _080C0CD0 - mov r1, sp - movs r0, 0x77 - b _080C0CD4 -_080C0CD0: - mov r1, sp - adds r0, 0xA1 -_080C0CD4: - strb r0, [r1, 0x1] - mov r5, sp - movs r1, 0xFA - lsls r1, 2 - adds r0, r4, 0 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r4, 0 - movs r1, 0xA - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r5, 0x2] - mov r1, sp - movs r0, 0xAD - strb r0, [r1, 0x3] - mov r5, sp - adds r0, r4, 0 - movs r1, 0xA - bl __umodsi3 - adds r0, 0xA1 - strb r0, [r5, 0x4] - mov r1, sp - movs r0, 0xFF - strb r0, [r1, 0x5] - mov r0, r8 - adds r2, r7, 0 - adds r3, r6, 0 - bl sub_80C0A88 - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C0C6C - - thumb_func_start sub_80C0D30 -sub_80C0D30: @ 80C0D30 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x80 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, 16 - lsrs r1, 16 - ldr r4, =gMonFootprintTable - adds r0, r1, 0 - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r0, 14 - adds r0, r4 - ldr r0, [r0] - mov r12, r0 - movs r5, 0 - movs r1, 0 - movs r7, 0x2 -_080C0D5A: - mov r2, r12 - adds r0, r2, r1 - ldrb r3, [r0] - movs r4, 0 - adds r6, r1, 0x1 -_080C0D64: - lsls r2, r4, 1 - adds r1, r3, 0 - asrs r1, r2 - movs r0, 0x1 - ands r1, r0 - negs r0, r1 - orrs r0, r1 - asrs r1, r0, 31 - ands r1, r7 - adds r0, r7, 0 - lsls r0, r2 - ands r0, r3 - cmp r0, 0 - beq _080C0D84 - movs r0, 0x20 - orrs r1, r0 -_080C0D84: - mov r2, sp - adds r0, r2, r5 - strb r1, [r0] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x3 - bls _080C0D64 - lsls r0, r6, 16 - lsrs r1, r0, 16 - cmp r1, 0x1F - bls _080C0D5A - mov r0, r8 - mov r1, sp - movs r2, 0x80 - movs r3, 0 - bl CopyToWindowPixelBuffer - add sp, 0x80 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C0D30 - - thumb_func_start sub_80C0DC0 -sub_80C0DC0: @ 80C0DC0 - push {r4,lr} - lsls r0, 16 - lsls r1, 16 - lsrs r1, 16 - lsrs r0, 5 - ldr r2, =0x06000232 - adds r3, r0, r2 - movs r4, 0xF0 - lsls r4, 8 - adds r2, r1, r4 - strh r2, [r3] - ldr r2, =0x06000234 - adds r3, r0, r2 - adds r4, 0x1 - adds r2, r1, r4 - strh r2, [r3] - ldr r2, =0x06000272 - adds r3, r0, r2 - adds r4, 0x1 - adds r2, r1, r4 - strh r2, [r3] - ldr r2, =0x06000274 - adds r0, r2 - adds r4, 0x1 - adds r1, r4 - strh r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C0DC0 - - thumb_func_start sub_80C0E0C -sub_80C0E0C: @ 80C0E0C - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - lsls r1, 16 - lsrs r0, r1, 16 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 16 - lsrs r3, 16 - cmp r4, 0x1 - beq _080C0E38 - cmp r4, 0x1 - bgt _080C0E2E - cmp r4, 0 - beq _080C0E40 - b _080C0E60 -_080C0E2E: - cmp r5, 0x2 - beq _080C0E52 - cmp r5, 0x3 - beq _080C0E46 - b _080C0E60 -_080C0E38: - cmp r0, r2 - bls _080C0E60 - subs r0, 0x1 - b _080C0E58 -_080C0E40: - cmp r0, r3 - bcs _080C0E60 - b _080C0E56 -_080C0E46: - cmp r0, r2 - bls _080C0E4E - subs r0, 0x1 - b _080C0E58 -_080C0E4E: - adds r0, r3, 0 - b _080C0E60 -_080C0E52: - cmp r0, r3 - bcs _080C0E5E -_080C0E56: - adds r0, 0x1 -_080C0E58: - lsls r0, 16 - lsrs r0, 16 - b _080C0E60 -_080C0E5E: - adds r0, r2, 0 -_080C0E60: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80C0E0C - - thumb_func_start sub_80C0E68 -sub_80C0E68: @ 80C0E68 - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0xC9 - beq _080C0E88 - movs r0, 0x9A - lsls r0, 1 - cmp r1, r0 - bne _080C0E94 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r0, [r0, 0x20] - b _080C0E96 - .pool -_080C0E88: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r0, [r0, 0x1C] - b _080C0E96 - .pool -_080C0E94: - movs r0, 0 -_080C0E96: - pop {r1} - bx r1 - thumb_func_end sub_80C0E68 - - thumb_func_start sub_80C0E9C -sub_80C0E9C: @ 80C0E9C - push {r4-r6,lr} - sub sp, 0x14 - adds r4, r1, 0 - adds r5, r2, 0 - adds r6, r3, 0 - lsls r0, 16 - lsrs r0, 16 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 16 - lsrs r6, 16 - bl NationalPokedexNumToSpecies - adds r1, r0, 0 - adds r0, r1, 0 - str r1, [sp, 0x10] - bl sub_80C0E68 - adds r2, r0, 0 - lsls r4, 16 - asrs r4, 16 - str r4, [sp] - lsls r5, 16 - asrs r5, 16 - str r5, [sp, 0x4] - lsls r6, 24 - lsrs r6, 24 - str r6, [sp, 0x8] - ldr r0, =0x0000ffff - str r0, [sp, 0xC] - ldr r1, [sp, 0x10] - adds r0, r1, 0 - movs r1, 0x8 - movs r3, 0x1 - bl sub_818D7D8 - lsls r0, 16 - lsrs r0, 16 - add sp, 0x14 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80C0E9C - - thumb_func_start sub_80C0EF8 -sub_80C0EF8: @ 80C0EF8 - push {r4,r5,lr} - sub sp, 0x8 - adds r4, r1, 0 - adds r5, r2, 0 - lsls r0, 16 - lsrs r0, 16 - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - lsls r3, 24 - lsrs r3, 24 - str r3, [sp] - ldr r1, =0x0000ffff - str r1, [sp, 0x4] - movs r1, 0x1 - adds r2, r4, 0 - adds r3, r5, 0 - bl sub_818D8AC - lsls r0, 16 - lsrs r0, 16 - add sp, 0x8 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80C0EF8 - - thumb_func_start sub_80C0F30 -sub_80C0F30: @ 80C0F30 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - ldr r4, [sp, 0x34] - ldr r5, [sp, 0x38] - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r7, r2, 24 - lsls r3, 24 - lsrs r3, 24 - str r3, [sp, 0x4] - lsls r4, 24 - lsrs r4, 24 - str r4, [sp, 0x8] - lsls r5, 24 - lsrs r5, 24 - mov r10, r5 - bl sub_80BC8D4 - movs r5, 0 - movs r6, 0 - ldr r4, =0x00000181 - ldr r3, =gUnknown_02039B4C -_080C0F6A: - ldr r2, [r3] - lsls r0, r5, 2 - adds r1, r2, r0 - ldrb r0, [r1, 0x2] - lsls r0, 31 - cmp r0, 0 - beq _080C0F86 - lsls r0, r6, 2 - adds r0, r2, r0 - ldr r1, [r1] - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_080C0F86: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r4 - bls _080C0F6A - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - adds r1, r6, 0 - strh r6, [r0] - cmp r7, 0xFF - beq _080C103C - movs r5, 0 - lsls r0, r1, 16 - movs r6, 0 - cmp r0, 0 - beq _080C1032 - lsls r7, 2 - ldr r0, =gUnknown_0856ED08 - adds r0, 0x3 - adds r0, r7, r0 - str r0, [sp, 0xC] - ldr r0, =gUnknown_0856ED08 - adds r0, r7 - mov r9, r0 -_080C0FBA: - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - lsls r4, r5, 2 - adds r0, r4 - ldrh r0, [r0] - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r2, r0, 16 - ldr r1, =gSpeciesNames - movs r0, 0xB - muls r0, r2 - adds r0, r1 - ldrb r2, [r0] - adds r3, r2, 0 - mov r0, r9 - ldrb r0, [r0] - cmp r2, r0 - bcc _080C0FF2 - mov r1, r9 - ldrb r0, [r1] - ldr r1, =gUnknown_0856ED08 - adds r1, 0x1 - adds r1, r7, r1 - ldrb r1, [r1] - adds r0, r1 - cmp r2, r0 - blt _080C100A -_080C0FF2: - ldr r0, =gUnknown_0856ED08 - adds r0, 0x2 - adds r0, r7, r0 - ldrb r2, [r0] - cmp r3, r2 - bcc _080C101E - ldrb r1, [r0] - ldr r2, [sp, 0xC] - ldrb r0, [r2] - adds r1, r0 - cmp r3, r1 - bge _080C101E -_080C100A: - ldr r2, =gUnknown_02039B4C - ldr r0, [r2] - lsls r1, r6, 2 - adds r1, r0, r1 - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_080C101E: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - ldrh r0, [r0] - cmp r5, r0 - bcc _080C0FBA -_080C1032: - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - strh r6, [r0] -_080C103C: - ldr r0, [sp, 0x4] - cmp r0, 0xFF - beq _080C10AC - movs r5, 0 - movs r6, 0 - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - ldrh r0, [r0] - cmp r6, r0 - bcs _080C10A2 - adds r7, r1, 0 - ldr r0, =gBaseStats - mov r8, r0 -_080C105A: - ldr r0, [r7] - lsls r4, r5, 2 - adds r0, r4 - ldrh r0, [r0] - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r2, r0, 16 - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - add r0, r8 - ldrb r0, [r0, 0x19] - lsls r0, 25 - lsrs r0, 25 - ldr r1, [sp, 0x4] - cmp r1, r0 - bne _080C1090 - ldr r0, [r7] - lsls r1, r6, 2 - adds r1, r0, r1 - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_080C1090: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, [r7] - ldr r2, =0x0000060c - adds r0, r2 - ldrh r0, [r0] - cmp r5, r0 - bcc _080C105A -_080C10A2: - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - strh r6, [r0] -_080C10AC: - ldr r0, [sp, 0x8] - cmp r0, 0xFF - bne _080C10C2 - mov r1, r10 - cmp r1, 0xFF - bne _080C10BA - b _080C11DE -_080C10BA: - mov r2, r10 - str r2, [sp, 0x8] - movs r0, 0xFF - mov r10, r0 -_080C10C2: - mov r1, r10 - cmp r1, 0xFF - bne _080C1158 - movs r5, 0 - movs r6, 0 - ldr r2, =gUnknown_02039B4C - ldr r0, [r2] - ldr r1, =0x0000060c - adds r0, r1 - ldrh r0, [r0] - cmp r6, r0 - bcs _080C11D4 - adds r3, r2, 0 - mov r7, sp - mov r8, r2 -_080C10E0: - ldr r0, [r3] - lsls r4, r5, 2 - adds r1, r0, r4 - ldrb r0, [r1, 0x2] - lsls r0, 30 - cmp r0, 0 - bge _080C112A - ldrh r0, [r1] - str r3, [sp, 0x10] - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r2, r0, 16 - ldr r1, =gBaseStats - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x6] - strb r1, [r7] - ldrb r0, [r0, 0x7] - strb r0, [r7, 0x1] - ldr r3, [sp, 0x10] - ldr r2, [sp, 0x8] - cmp r1, r2 - beq _080C1118 - cmp r0, r2 - bne _080C112A -_080C1118: - ldr r0, [r3] - lsls r1, r6, 2 - adds r1, r0, r1 - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_080C112A: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - mov r1, r8 - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - ldrh r0, [r0] - cmp r5, r0 - bcc _080C10E0 - b _080C11D4 - .pool -_080C1158: - movs r5, 0 - movs r6, 0 - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - ldrh r0, [r0] - cmp r6, r0 - bcs _080C11D4 - mov r7, sp -_080C116C: - ldr r0, [r1] - lsls r1, r5, 2 - adds r2, r0, r1 - ldrb r0, [r2, 0x2] - lsls r0, 30 - adds r4, r1, 0 - cmp r0, 0 - bge _080C11C0 - ldrh r0, [r2] - bl NationalPokedexNumToSpecies - lsls r0, 16 - lsrs r2, r0, 16 - ldr r1, =gBaseStats - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x6] - strb r1, [r7] - ldrb r0, [r0, 0x7] - strb r0, [r7, 0x1] - ldr r2, [sp, 0x8] - cmp r1, r2 - bne _080C11A2 - cmp r0, r10 - beq _080C11AC -_080C11A2: - cmp r1, r10 - bne _080C11C0 - ldr r1, [sp, 0x8] - cmp r0, r1 - bne _080C11C0 -_080C11AC: - ldr r2, =gUnknown_02039B4C - ldr r0, [r2] - lsls r1, r6, 2 - adds r1, r0, r1 - adds r0, r4 - ldr r0, [r0] - str r0, [r1] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_080C11C0: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - ldrh r0, [r0] - cmp r5, r0 - bcc _080C116C -_080C11D4: - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r0, r2 - strh r6, [r0] -_080C11DE: - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x0000060c - adds r1, r0, r2 - ldrh r0, [r1] - cmp r0, 0 - beq _080C1232 - adds r5, r0, 0 - ldr r0, =0x00000181 - cmp r5, r0 - bhi _080C1232 - ldr r4, =gUnknown_02039B4C - movs r1, 0x2 - negs r1, r1 - mov r10, r1 - movs r2, 0x3 - negs r2, r2 - mov r9, r2 - mov r8, r0 - ldr r0, =0x0000ffff - adds r7, r0, 0 -_080C1208: - ldr r1, [r4] - lsls r3, r5, 2 - adds r1, r3 - ldrh r0, [r1] - orrs r0, r7 - strh r0, [r1] - ldrb r2, [r1, 0x2] - mov r0, r10 - ands r0, r2 - strb r0, [r1, 0x2] - ldr r1, [r4] - adds r1, r3 - ldrb r2, [r1, 0x2] - mov r0, r9 - ands r0, r2 - strb r0, [r1, 0x2] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r8 - bls _080C1208 -_080C1232: - adds r0, r6, 0 - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80C0F30 - - thumb_func_start sub_80C1258 -sub_80C1258: @ 80C1258 - push {lr} - ldr r0, =sub_80C12E0 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80C1258 - - thumb_func_start sub_80C1270 -sub_80C1270: @ 80C1270 - push {r4,r5,lr} - sub sp, 0x18 - adds r5, r1, 0 - adds r3, r2, 0 - add r1, sp, 0x14 - movs r4, 0 - strb r4, [r1] - adds r2, r1, 0 - movs r1, 0xF - strb r1, [r2, 0x1] - movs r1, 0x2 - strb r1, [r2, 0x2] - lsls r5, 24 - lsrs r5, 24 - lsls r3, 24 - lsrs r3, 24 - str r4, [sp] - str r4, [sp, 0x4] - str r2, [sp, 0x8] - subs r1, 0x3 - str r1, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl AddTextPrinterParameterized2 - add sp, 0x18 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80C1270 - - thumb_func_start sub_80C12B0 -sub_80C12B0: @ 80C12B0 - push {r4,r5,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - lsls r2, 16 - lsrs r2, 16 - str r2, [sp] - lsls r3, 16 - lsrs r3, 16 - str r3, [sp, 0x4] - movs r0, 0 - movs r1, 0 - adds r2, r4, 0 - adds r3, r5, 0 - bl FillWindowPixelRect - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80C12B0 - - thumb_func_start sub_80C12E0 -sub_80C12E0: @ 80C12E0 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r3, r1, 0 - cmp r0, 0x4 - bhi _080C1320 - lsls r0, 2 - ldr r1, =_080C130C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080C130C: - .4byte _080C1320 - .4byte _080C1414 - .4byte _080C1480 - .4byte _080C14A0 - .4byte _080C14F0 -_080C1320: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - beq _080C1332 - b _080C1516 -_080C1332: - ldr r0, =gUnknown_02039B4C - ldr r0, [r0] - ldr r1, =0x0000064a - adds r0, r1 - movs r1, 0x2 - strb r1, [r0] - movs r0, 0 - bl sub_80C09B0 - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0856EFF8 - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - movs r4, 0x80 - lsls r4, 4 - adds r0, r4, 0 - bl AllocZeroed - adds r1, r0, 0 - movs r0, 0x3 - bl SetBgTilemapBuffer - adds r0, r4, 0 - bl AllocZeroed - adds r1, r0, 0 - movs r0, 0x2 - bl SetBgTilemapBuffer - adds r0, r4, 0 - bl AllocZeroed - adds r1, r0, 0 - movs r0, 0x1 - bl SetBgTilemapBuffer - adds r0, r4, 0 - bl AllocZeroed - adds r1, r0, 0 - movs r0, 0 - bl SetBgTilemapBuffer - ldr r0, =gUnknown_0856F008 - bl InitWindows - bl DeactivateAllTextPrinters - movs r0, 0 - bl PutWindowTilemap - ldr r1, =gPokedexSearchMenu_Gfx - movs r2, 0x80 - lsls r2, 6 - str r5, [sp] - movs r0, 0x3 - movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree - bl IsNationalPokedexEnabled - cmp r0, 0 - bne _080C13E4 - ldr r1, =gPokedexSearch2_Tilemap - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - b _080C13F0 - .pool -_080C13E4: - ldr r1, =gPokedexSearch1_Tilemap - movs r0, 0x3 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer -_080C13F0: - ldr r0, =gPokedexSearchMenu_Pal + 0x2 - movs r1, 0x1 - movs r2, 0x7E - bl LoadPalette - ldr r0, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r2 - movs r1, 0x1 - strb r1, [r0] - b _080C1516 - .pool -_080C1414: - ldr r0, =gSpriteSheets_0855D26C - bl LoadCompressedObjectPic - ldr r0, =gSpritePalettes_0855D26C - bl LoadSpritePalettes - adds r0, r4, 0 - bl sub_80C2594 - movs r1, 0 - lsls r0, r4, 2 - adds r0, r4 - lsls r2, r0, 3 - ldr r5, =gTasks + 0x8 - movs r3, 0 -_080C1432: - lsls r0, r1, 1 - adds r0, r2 - adds r0, r5 - strh r3, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0xF - bls _080C1432 - adds r0, r4, 0 - bl sub_80C23B8 - movs r0, 0 - bl sub_80C2040 - adds r0, r4, 0 - bl sub_80C20F8 - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - movs r0, 0x2 - bl CopyBgTilemapBufferToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - b _080C14DA - .pool -_080C1480: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _080C14E2 - .pool -_080C14A0: - 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 r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl HideBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg -_080C14DA: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_080C14E2: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _080C1516 - .pool -_080C14F0: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - bne _080C1516 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80C1570 - str r1, [r0] - movs r1, 0x87 - lsls r1, 3 - adds r0, r3, r1 - strb r2, [r0] -_080C1516: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C12E0 - - thumb_func_start sub_80C152C -sub_80C152C: @ 80C152C - push {lr} - bl FreeAllWindowBuffers - movs r0, 0 - bl GetBgTilemapBuffer - cmp r0, 0 - beq _080C1540 - bl Free -_080C1540: - movs r0, 0x1 - bl GetBgTilemapBuffer - cmp r0, 0 - beq _080C154E - bl Free -_080C154E: - movs r0, 0x2 - bl GetBgTilemapBuffer - cmp r0, 0 - beq _080C155C - bl Free -_080C155C: - movs r0, 0x3 - bl GetBgTilemapBuffer - cmp r0, 0 - beq _080C156A - bl Free -_080C156A: - pop {r0} - bx r0 - thumb_func_end sub_80C152C - - thumb_func_start sub_80C1570 -sub_80C1570: @ 80C1570 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gTasks - lsls r5, r4, 2 - adds r5, r4 - lsls r5, 3 - adds r5, r0 - ldrb r0, [r5, 0x8] - bl sub_80C2040 - adds r0, r4, 0 - bl sub_80C20F8 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - ldr r0, =sub_80C15B0 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1570 - - thumb_func_start sub_80C15B0 -sub_80C15B0: @ 80C15B0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080C15E4 - movs r0, 0x3 - bl PlaySE - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80C1D38 - str r0, [r1] - b _080C16BC - .pool -_080C15E4: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080C1640 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r5, r0, r1 - movs r0, 0x8 - ldrsh r4, [r5, r0] - cmp r4, 0x1 - beq _080C161C - cmp r4, 0x1 - bgt _080C160C - cmp r4, 0 - beq _080C1612 - b _080C16BC - .pool -_080C160C: - cmp r4, 0x2 - beq _080C1630 - b _080C16BC -_080C1612: - movs r0, 0x15 - bl PlaySE - strh r4, [r5, 0xA] - b _080C1626 -_080C161C: - movs r0, 0x15 - bl PlaySE - movs r0, 0x4 - strh r0, [r5, 0xA] -_080C1626: - ldr r0, =sub_80C16CC - str r0, [r5] - b _080C16BC - .pool -_080C1630: - movs r0, 0x3 - bl PlaySE - ldr r0, =sub_80C1D38 - str r0, [r5] - b _080C16BC - .pool -_080C1640: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080C167C - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r4, r1, r0 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - ble _080C167C - movs r0, 0x6D - bl PlaySE - ldrh r0, [r4, 0x8] - subs r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r0, 24 - bl sub_80C2040 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram -_080C167C: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080C16BC - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r4, r1, r0 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bgt _080C16BC - movs r0, 0x6D - bl PlaySE - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r0, 24 - bl sub_80C2040 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram -_080C16BC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C15B0 - - thumb_func_start sub_80C16CC -sub_80C16CC: @ 80C16CC - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gTasks - lsls r5, r4, 2 - adds r5, r4 - lsls r5, 3 - adds r5, r0 - ldrb r0, [r5, 0x8] - ldrb r1, [r5, 0xA] - bl sub_80C2064 - adds r0, r4, 0 - bl sub_80C20F8 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - ldr r0, =sub_80C170C - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C16CC - - thumb_func_start sub_80C170C -sub_80C170C: @ 80C170C - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - movs r1, 0x8 - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _080C1740 - bl IsNationalPokedexEnabled - ldr r6, =gUnknown_0856EDB8 - cmp r0, 0 - bne _080C174C - ldr r6, =gUnknown_0856EDF0 - b _080C174C - .pool -_080C1740: - bl IsNationalPokedexEnabled - ldr r6, =gUnknown_0856ED9C - cmp r0, 0 - bne _080C174C - ldr r6, =gUnknown_0856EDD4 -_080C174C: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x2 - ands r0, r1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0 - beq _080C178C - movs r0, 0x17 - bl PlaySE - adds r0, r5, 0 - bl sub_80C23B8 - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80C1570 - str r0, [r1] - b _080C1994 - .pool -_080C178C: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080C1870 - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r6, r1, r0 - movs r2, 0xA - ldrsh r0, [r6, r2] - cmp r0, 0x6 - bne _080C1860 - movs r1, 0x8 - ldrsh r0, [r6, r1] - cmp r0, 0 - beq _080C183C - ldr r1, =gUnknown_02039B52 - movs r0, 0x40 - strb r0, [r1] - ldr r7, =gUnknown_02039B4C - ldr r1, [r7] - ldr r0, =0x0000062a - adds r2, r1, r0 - movs r0, 0x40 - strh r0, [r2] - ldr r0, =gUnknown_02039B50 - strh r3, [r0] - movs r2, 0xC2 - lsls r2, 3 - adds r1, r2 - strh r3, [r1] - adds r0, r5, 0 - movs r1, 0x5 - bl sub_80C2318 - ldr r4, =gSaveBlock2Ptr - ldr r1, [r4] - strb r0, [r1, 0x19] - bl IsNationalPokedexEnabled - cmp r0, 0 - bne _080C17E8 - ldr r1, [r4] - movs r0, 0 - strb r0, [r1, 0x19] -_080C17E8: - ldr r0, [r7] - ldr r1, [r4] - ldrb r1, [r1, 0x19] - ldr r2, =0x00000614 - adds r0, r2 - strh r1, [r0] - adds r0, r5, 0 - movs r1, 0x4 - bl sub_80C2318 - ldr r1, [r4] - strb r0, [r1, 0x18] - ldr r0, [r7] - ldr r1, [r4] - ldrb r1, [r1, 0x18] - movs r2, 0xC3 - lsls r2, 3 - adds r0, r2 - strh r1, [r0] - movs r0, 0x3 - bl PlaySE - ldr r0, =sub_80C1D38 - str r0, [r6] - b _080C1994 - .pool -_080C183C: - ldr r0, =gText_SearchingPleaseWait - bl sub_80C2618 - ldr r0, =sub_80C19A4 - str r0, [r6] - movs r0, 0x70 - bl PlaySE - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - b _080C1994 - .pool -_080C1860: - movs r0, 0x15 - bl PlaySE - ldr r0, =sub_80C1B64 - str r0, [r6] - b _080C1994 - .pool -_080C1870: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080C18B6 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0xA - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0xFF - beq _080C18B6 - movs r0, 0x5 - bl PlaySE - movs r2, 0xA - ldrsh r0, [r4, r2] - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0] - strh r1, [r4, 0xA] - ldrb r0, [r4, 0x8] - bl sub_80C2064 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram -_080C18B6: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080C1900 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0xA - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x1] - cmp r0, 0xFF - beq _080C1900 - movs r0, 0x5 - bl PlaySE - movs r2, 0xA - ldrsh r0, [r4, r2] - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0, 0x1] - strh r1, [r4, 0xA] - ldrb r0, [r4, 0x8] - bl sub_80C2064 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram -_080C1900: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _080C194A - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0xA - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x2] - cmp r0, 0xFF - beq _080C194A - movs r0, 0x5 - bl PlaySE - movs r2, 0xA - ldrsh r0, [r4, r2] - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0, 0x2] - strh r1, [r4, 0xA] - ldrb r0, [r4, 0x8] - bl sub_80C2064 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram -_080C194A: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080C1994 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0xA - ldrsh r0, [r4, r1] - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x3] - cmp r0, 0xFF - beq _080C1994 - movs r0, 0x5 - bl PlaySE - movs r2, 0xA - ldrsh r0, [r4, r2] - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0, 0x3] - strh r1, [r4, 0xA] - ldrb r0, [r4, 0x8] - bl sub_80C2064 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram -_080C1994: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C170C - - thumb_func_start sub_80C19A4 -sub_80C19A4: @ 80C19A4 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - sub sp, 0x8 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - adds r0, r5, 0 - movs r1, 0x5 - bl sub_80C2318 - mov r10, r0 - mov r0, r10 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - adds r0, r5, 0 - movs r1, 0x4 - bl sub_80C2318 - mov r9, r0 - mov r0, r9 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - adds r0, r5, 0 - movs r1, 0 - bl sub_80C2318 - mov r8, r0 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80C2318 - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - adds r0, r5, 0 - movs r1, 0x2 - bl sub_80C2318 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r5, 0 - movs r1, 0x3 - bl sub_80C2318 - lsls r0, 24 - lsrs r0, 24 - str r4, [sp] - str r0, [sp, 0x4] - mov r0, r10 - mov r1, r9 - mov r2, r8 - adds r3, r6, 0 - bl sub_80C0F30 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80C1A4C - str r1, [r0] - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C19A4 - - thumb_func_start sub_80C1A4C -sub_80C1A4C: @ 80C1A4C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl IsSEPlaying - lsls r0, 24 - cmp r0, 0 - bne _080C1AA6 - ldr r0, =gUnknown_02039B4C - ldr r0, [r0] - ldr r1, =0x0000060c - adds r0, r1 - ldrh r0, [r0] - cmp r0, 0 - beq _080C1A84 - movs r0, 0x1F - bl PlaySE - ldr r0, =gText_SearchCompleted - bl sub_80C2618 - b _080C1A90 - .pool -_080C1A84: - movs r0, 0x20 - bl PlaySE - ldr r0, =gUnknown_085E8785 - bl sub_80C2618 -_080C1A90: - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80C1AB8 - str r0, [r1] - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram -_080C1AA6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1A4C - - thumb_func_start sub_80C1AB8 -sub_80C1AB8: @ 80C1AB8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r2, r4, 0 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080C1B54 - ldr r5, =gUnknown_02039B4C - ldr r1, [r5] - ldr r3, =0x0000060c - adds r0, r1, r3 - ldrh r0, [r0] - cmp r0, 0 - beq _080C1B40 - ldr r0, =0x0000064e - adds r1, r0 - movs r0, 0x1 - strb r0, [r1] - adds r0, r4, 0 - movs r1, 0x5 - bl sub_80C2318 - ldr r1, [r5] - lsls r0, 24 - lsrs r0, 24 - ldr r2, =0x00000612 - adds r1, r2 - strh r0, [r1] - adds r0, r4, 0 - movs r1, 0x4 - bl sub_80C2318 - ldr r1, [r5] - lsls r0, 24 - lsrs r0, 24 - ldr r3, =0x00000616 - adds r1, r3 - strh r0, [r1] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80C1D38 - str r1, [r0] - movs r0, 0x3 - bl PlaySE - b _080C1B54 - .pool -_080C1B40: - ldr r0, =gTasks - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_80C16CC - str r0, [r1] - movs r0, 0x17 - bl PlaySE -_080C1B54: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1AB8 - - thumb_func_start sub_80C1B64 -sub_80C1B64: @ 80C1B64 - push {r4-r6,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - movs r0, 0 - bl sub_80C21D4 - ldr r2, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r6, r1, r2 - ldrb r0, [r6, 0xA] - adds r2, 0x8 - adds r1, r2 - ldr r2, =gUnknown_0856EFC8 - lsls r0, 3 - adds r0, r2 - ldrb r4, [r0, 0x4] - lsls r4, 1 - adds r4, r1, r4 - ldrb r0, [r0, 0x5] - lsls r0, 1 - adds r1, r0 - ldrh r0, [r4] - strh r0, [r6, 0x24] - ldrh r0, [r1] - strh r0, [r6, 0x26] - adds r0, r5, 0 - bl sub_80C2294 - ldrh r0, [r4] - bl sub_80C2650 - ldr r0, =sub_80C1BCC - str r0, [r6] - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1B64 - - thumb_func_start sub_80C1BCC -sub_80C1BCC: @ 80C1BCC - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r3, =gTasks - lsls r2, r7, 2 - adds r2, r7 - lsls r2, 3 - adds r5, r2, r3 - ldrb r1, [r5, 0xA] - ldr r0, =gUnknown_0856EFC8 - lsls r1, 3 - adds r1, r0 - ldr r0, [r1] - mov r8, r0 - adds r3, 0x8 - adds r2, r3 - ldrb r0, [r1, 0x4] - lsls r0, 1 - adds r4, r2, r0 - ldrb r0, [r1, 0x5] - lsls r0, 1 - adds r6, r2, r0 - ldrh r0, [r1, 0x6] - subs r0, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - ldr r0, =gMain - mov r12, r0 - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080C1C30 - movs r0, 0x15 - bl PlaySE - bl sub_80C267C - movs r0, 0x1 - bl sub_80C21D4 - b _080C1C50 - .pool -_080C1C30: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080C1C68 - movs r0, 0x17 - bl PlaySE - bl sub_80C267C - movs r0, 0x1 - bl sub_80C21D4 - ldrh r0, [r5, 0x24] - strh r0, [r4] - ldrh r0, [r5, 0x26] - strh r0, [r6] -_080C1C50: - ldr r0, =sub_80C16CC - str r0, [r5] - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - b _080C1D2E - .pool -_080C1C68: - movs r3, 0 - mov r0, r12 - ldrh r1, [r0, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _080C1CCA - ldrh r0, [r4] - cmp r0, 0 - beq _080C1C8E - bl sub_80C2638 - ldrh r0, [r4] - subs r0, 0x1 - strh r0, [r4] - ldrh r0, [r4] - bl sub_80C2650 - b _080C1CAA -_080C1C8E: - ldrh r0, [r6] - cmp r0, 0 - beq _080C1CA6 - subs r0, 0x1 - strh r0, [r6] - adds r0, r7, 0 - bl sub_80C2294 - ldrh r0, [r4] - bl sub_80C2650 - movs r3, 0x1 -_080C1CA6: - cmp r3, 0 - beq _080C1D2E -_080C1CAA: - movs r0, 0x5 - bl PlaySE - ldrh r0, [r4] - ldrh r1, [r6] - adds r0, r1 - lsls r0, 3 - add r0, r8 - ldr r0, [r0] - bl sub_80C2618 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - b _080C1D2E -_080C1CCA: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080C1D2E - ldrh r0, [r4] - cmp r0, 0x4 - bhi _080C1CEE - cmp r0, r2 - bcs _080C1CEE - bl sub_80C2638 - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - ldrh r0, [r4] - bl sub_80C2650 - b _080C1D10 -_080C1CEE: - cmp r2, 0x5 - bls _080C1D0C - ldrh r1, [r6] - subs r0, r2, 0x5 - cmp r1, r0 - bge _080C1D0C - adds r0, r1, 0x1 - strh r0, [r6] - adds r0, r7, 0 - bl sub_80C2294 - movs r0, 0x5 - bl sub_80C2650 - movs r3, 0x1 -_080C1D0C: - cmp r3, 0 - beq _080C1D2E -_080C1D10: - movs r0, 0x5 - bl PlaySE - ldrh r0, [r4] - ldrh r1, [r6] - adds r0, r1 - lsls r0, 3 - add r0, r8 - ldr r0, [r0] - bl sub_80C2618 - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram -_080C1D2E: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C1BCC - - thumb_func_start sub_80C1D38 -sub_80C1D38: @ 80C1D38 - 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, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_80C1D70 - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1D38 - - thumb_func_start sub_80C1D70 -sub_80C1D70: @ 80C1D70 - 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 _080C1D8C - bl sub_80C152C - adds r0, r4, 0 - bl DestroyTask -_080C1D8C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1D70 - - thumb_func_start sub_80C1D98 -sub_80C1D98: @ 80C1D98 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r3, 0 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - lsls r2, 24 - lsrs r5, r2, 24 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x3 - bl GetBgTilemapBuffer - adds r2, r0, 0 - movs r3, 0 - cmp r3, r4 - bcs _080C1DEC - lsls r0, r5, 6 - adds r7, r0, r2 - ldr r5, =0x00000fff - lsls r2, r6, 12 -_080C1DC8: - mov r0, r8 - adds r1, r0, r3 - lsls r1, 1 - adds r1, r7 - ldrh r0, [r1] - ands r0, r5 - orrs r0, r2 - strh r0, [r1] - adds r1, 0x40 - ldrh r0, [r1] - ands r0, r5 - orrs r0, r2 - strh r0, [r1] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, r4 - bcc _080C1DC8 -_080C1DEC: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1D98 - - thumb_func_start sub_80C1DFC -sub_80C1DFC: @ 80C1DFC - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r5, r1, 24 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x1 - ands r5, r0 - ands r2, r0 - lsls r2, 1 - orrs r5, r2 - cmp r4, 0xA - bhi _080C1EE8 - lsls r0, r4, 2 - ldr r1, =_080C1E28 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080C1E28: - .4byte _080C1E54 - .4byte _080C1E54 - .4byte _080C1E54 - .4byte _080C1E64 - .4byte _080C1E64 - .4byte _080C1E7C - .4byte _080C1E7C - .4byte _080C1E64 - .4byte _080C1E64 - .4byte _080C1EA4 - .4byte _080C1E94 -_080C1E54: - ldr r1, =gUnknown_0856ED30 - lsls r0, r4, 3 - adds r0, r1 - ldrb r1, [r0, 0x4] - ldrb r2, [r0, 0x5] - b _080C1EC2 - .pool -_080C1E64: - ldr r2, =gUnknown_0856ED48 - subs r1, r4, 0x3 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - ldrb r2, [r0, 0x5] - ldrb r3, [r0, 0x6] - adds r0, r5, 0 - bl sub_80C1D98 -_080C1E7C: - ldr r2, =gUnknown_0856ED48 - subs r1, r4, 0x3 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x7] - ldrb r2, [r0, 0x8] - ldrb r3, [r0, 0x9] - b _080C1EC4 - .pool -_080C1E94: - ldr r0, =gUnknown_0856ED48 - ldrb r1, [r0, 0x1C] - ldrb r2, [r0, 0x1D] - ldrb r3, [r0, 0x1E] - b _080C1EC4 - .pool -_080C1EA4: - bl IsNationalPokedexEnabled - cmp r0, 0 - bne _080C1ED0 - ldr r2, =gUnknown_0856ED48 - subs r1, r4, 0x3 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - ldrb r2, [r0, 0x5] - subs r2, 0x2 - lsls r2, 24 - lsrs r2, 24 -_080C1EC2: - ldrb r3, [r0, 0x6] -_080C1EC4: - adds r0, r5, 0 - bl sub_80C1D98 - b _080C1EE8 - .pool -_080C1ED0: - ldr r2, =gUnknown_0856ED48 - subs r1, r4, 0x3 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - ldrb r2, [r0, 0x5] - ldrb r3, [r0, 0x6] - adds r0, r5, 0 - bl sub_80C1D98 -_080C1EE8: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C1DFC - - thumb_func_start sub_80C1EF4 -sub_80C1EF4: @ 80C1EF4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - adds r1, r0, 0 - cmp r0, 0x1 - beq _080C1F5E - cmp r0, 0x1 - bgt _080C1F0A - cmp r0, 0 - beq _080C1F10 - b _080C203C -_080C1F0A: - cmp r1, 0x2 - beq _080C1FCE - b _080C203C -_080C1F10: - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x4 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0xA - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x5 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x6 - movs r1, 0x1 - movs r2, 0 - b _080C1FAA -_080C1F5E: - movs r0, 0 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x4 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0xA - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x5 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x6 - movs r1, 0x1 - movs r2, 0x1 -_080C1FAA: - bl sub_80C1DFC - movs r0, 0x7 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x8 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x9 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - b _080C203C -_080C1FCE: - movs r0, 0 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x4 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0xA - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x5 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x6 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x7 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x8 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC - movs r0, 0x9 - movs r1, 0x1 - movs r2, 0x1 - bl sub_80C1DFC -_080C203C: - pop {r0} - bx r0 - thumb_func_end sub_80C1EF4 - - thumb_func_start sub_80C2040 -sub_80C2040: @ 80C2040 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl sub_80C1EF4 - ldr r0, =gUnknown_0856ED30 - lsls r4, 3 - adds r4, r0 - ldr r0, [r4] - bl sub_80C2618 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C2040 - - thumb_func_start sub_80C2064 -sub_80C2064: @ 80C2064 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r4, r1, 24 - bl sub_80C1EF4 - cmp r4, 0x6 - bhi _080C20DE - lsls r0, r4, 2 - ldr r1, =_080C2084 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080C2084: - .4byte _080C20A0 - .4byte _080C20A4 - .4byte _080C20A8 - .4byte _080C20B6 - .4byte _080C20C4 - .4byte _080C20C8 - .4byte _080C20D4 -_080C20A0: - movs r0, 0x3 - b _080C20CA -_080C20A4: - movs r0, 0x4 - b _080C20CA -_080C20A8: - movs r0, 0xA - movs r1, 0 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x5 - b _080C20CA -_080C20B6: - movs r0, 0xA - movs r1, 0 - movs r2, 0 - bl sub_80C1DFC - movs r0, 0x6 - b _080C20CA -_080C20C4: - movs r0, 0x7 - b _080C20CA -_080C20C8: - movs r0, 0x8 -_080C20CA: - movs r1, 0 - movs r2, 0 - bl sub_80C1DFC - b _080C20DE -_080C20D4: - movs r0, 0x9 - movs r1, 0 - movs r2, 0 - bl sub_80C1DFC -_080C20DE: - ldr r0, =gUnknown_0856ED48 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - bl sub_80C2618 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C2064 - - thumb_func_start sub_80C20F8 -sub_80C20F8: @ 80C20F8 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x28 - movs r1, 0x10 - movs r2, 0x60 - movs r3, 0x50 - bl sub_80C12B0 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r5, r0, r1 - ldrh r0, [r5, 0x16] - ldrh r1, [r5, 0x14] - adds r0, r1 - lsls r0, 16 - ldr r1, =gUnknown_0856EE5C - lsrs r0, 13 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x2D - movs r2, 0x11 - bl sub_80C1270 - ldrh r0, [r5, 0x1A] - ldrh r1, [r5, 0x18] - adds r0, r1 - lsls r0, 16 - ldr r1, =gUnknown_0856EEB4 - lsrs r0, 13 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x2D - movs r2, 0x21 - bl sub_80C1270 - ldrh r0, [r5, 0x1E] - ldrh r1, [r5, 0x1C] - adds r0, r1 - lsls r0, 16 - ldr r4, =gUnknown_0856EF14 - lsrs r0, 13 - adds r4, 0x4 - adds r0, r4 - ldr r0, [r0] - movs r1, 0x2D - movs r2, 0x31 - bl sub_80C1270 - ldrh r0, [r5, 0x22] - ldrh r1, [r5, 0x20] - adds r0, r1 - lsls r0, 16 - lsrs r0, 13 - adds r0, r4 - ldr r0, [r0] - movs r1, 0x5D - movs r2, 0x31 - bl sub_80C1270 - ldrh r0, [r5, 0x12] - ldrh r1, [r5, 0x10] - adds r0, r1 - lsls r0, 16 - ldr r1, =gUnknown_0856EE24 - lsrs r0, 13 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x2D - movs r2, 0x41 - bl sub_80C1270 - bl IsNationalPokedexEnabled - cmp r0, 0 - beq _080C21B6 - ldrh r0, [r5, 0xE] - ldrh r5, [r5, 0xC] - adds r0, r5 - lsls r0, 16 - ldr r1, =gUnknown_0856EE0C - lsrs r0, 13 - adds r1, 0x4 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x2D - movs r2, 0x51 - bl sub_80C1270 -_080C21B6: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C20F8 - - thumb_func_start sub_80C21D4 -sub_80C21D4: @ 80C21D4 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x3 - bl GetBgTilemapBuffer - adds r5, r0, 0 - cmp r4, 0 - bne _080C2268 - ldr r1, =0x00000c0b - adds r0, r1, 0 - strh r0, [r5, 0x22] - movs r1, 0x12 - ldr r0, =0x0000080d - adds r2, r0, 0 -_080C21F4: - lsls r0, r1, 1 - adds r0, r5 - strh r2, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x1E - bls _080C21F4 - movs r2, 0x1 - ldr r1, =0x0000040a - adds r6, r1, 0 - movs r4, 0x2 -_080C220C: - lsls r0, r2, 6 - adds r0, r5 - strh r6, [r0, 0x22] - movs r1, 0x12 - adds r3, r2, 0x1 - adds r2, r0, 0 -_080C2218: - lsls r0, r1, 1 - adds r0, r2 - strh r4, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x1E - bls _080C2218 - lsls r0, r3, 16 - lsrs r2, r0, 16 - cmp r2, 0xC - bls _080C220C - ldr r2, =0x00000362 - adds r1, r5, r2 - adds r2, 0xA9 - adds r0, r2, 0 - strh r0, [r1] - movs r1, 0x12 - movs r3, 0xD0 - lsls r3, 2 - movs r2, 0xD -_080C2242: - lsls r0, r1, 1 - adds r0, r5 - adds r0, r3 - strh r2, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x1E - bls _080C2242 - b _080C228C - .pool -_080C2268: - movs r2, 0 - movs r4, 0x4F -_080C226C: - movs r1, 0x11 - lsls r0, r2, 6 - adds r3, r2, 0x1 - adds r2, r0, r5 -_080C2274: - lsls r0, r1, 1 - adds r0, r2 - strh r4, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x1D - bls _080C2274 - lsls r0, r3, 16 - lsrs r2, r0, 16 - cmp r2, 0xD - bls _080C226C -_080C228C: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80C21D4 - - thumb_func_start sub_80C2294 -sub_80C2294: @ 80C2294 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gUnknown_0856EFC8 - ldr r3, =gTasks - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - adds r0, r2, r3 - movs r5, 0xA - ldrsh r1, [r0, r5] - lsls r1, 3 - adds r1, r4 - ldr r6, [r1] - adds r3, 0x8 - adds r2, r3 - ldrb r0, [r1, 0x4] - lsls r0, 1 - adds r0, r2 - mov r8, r0 - ldrb r0, [r1, 0x5] - lsls r0, 1 - adds r7, r2, r0 - bl sub_80C267C - movs r5, 0 - ldrh r4, [r7] - b _080C22F2 - .pool -_080C22D8: - adds r0, r1, r6 - ldr r1, [r0, 0x4] - adds r0, r5, 0 - bl sub_80C2668 - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r5, 0x5 - bhi _080C22FC -_080C22F2: - lsls r1, r4, 3 - adds r0, r1, r6 - ldr r0, [r0, 0x4] - cmp r0, 0 - bne _080C22D8 -_080C22FC: - mov r1, r8 - ldrh r0, [r1] - ldrh r1, [r7] - adds r0, r1 - lsls r0, 3 - adds r0, r6 - ldr r0, [r0] - bl sub_80C2618 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C2294 - - thumb_func_start sub_80C2318 -sub_80C2318: @ 80C2318 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r1, r0 - ldr r2, =gUnknown_0856EFC8 - lsls r0, r3, 3 - adds r0, r2 - ldrb r2, [r0, 0x4] - lsls r2, 1 - adds r2, r1, r2 - ldrb r0, [r0, 0x5] - lsls r0, 1 - adds r1, r0 - ldrh r0, [r1] - ldrh r2, [r2] - adds r0, r2 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r3, 0x5 - bhi _080C237C - lsls r0, r3, 2 - ldr r1, =_080C2364 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080C2364: - .4byte _080C2390 - .4byte _080C239A - .4byte _080C23AA - .4byte _080C23AA - .4byte _080C2388 - .4byte _080C2380 -_080C237C: - movs r0, 0 - b _080C23B0 -_080C2380: - ldr r0, =gUnknown_0856EFAC - b _080C23AC - .pool -_080C2388: - ldr r0, =gUnknown_0856EFAE - b _080C23AC - .pool -_080C2390: - cmp r2, 0 - beq _080C239E - lsls r0, r2, 24 - lsrs r0, 24 - b _080C23B0 -_080C239A: - cmp r2, 0 - bne _080C23A2 -_080C239E: - movs r0, 0xFF - b _080C23B0 -_080C23A2: - subs r0, r2, 0x1 - lsls r0, 24 - lsrs r0, 24 - b _080C23B0 -_080C23AA: - ldr r0, =gUnknown_0856EFB4 -_080C23AC: - adds r0, r2, r0 - ldrb r0, [r0] -_080C23B0: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80C2318 - - thumb_func_start sub_80C23B8 -sub_80C23B8: @ 80C23B8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_02039B4C - ldr r0, [r1] - ldr r2, =0x00000614 - adds r0, r2 - ldrh r0, [r0] - adds r5, r1, 0 - cmp r0, 0 - beq _080C23D2 - cmp r0, 0x1 - beq _080C23E0 -_080C23D2: - movs r3, 0 - b _080C23E2 - .pool -_080C23E0: - movs r3, 0x1 -_080C23E2: - ldr r1, =gTasks - lsls r2, r4, 2 - adds r0, r2, r4 - lsls r0, 3 - adds r0, r1 - strh r3, [r0, 0xC] - ldr r0, [r5] - movs r3, 0xC3 - lsls r3, 3 - adds r0, r3 - ldrh r0, [r0] - adds r5, r1, 0 - cmp r0, 0x5 - bhi _080C2428 - lsls r0, 2 - ldr r1, =_080C2410 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080C2410: - .4byte _080C2428 - .4byte _080C242C - .4byte _080C2430 - .4byte _080C2434 - .4byte _080C2438 - .4byte _080C243C -_080C2428: - movs r3, 0 - b _080C243E -_080C242C: - movs r3, 0x1 - b _080C243E -_080C2430: - movs r3, 0x2 - b _080C243E -_080C2434: - movs r3, 0x3 - b _080C243E -_080C2438: - movs r3, 0x4 - b _080C243E -_080C243C: - movs r3, 0x5 -_080C243E: - adds r0, r2, r4 - lsls r0, 3 - adds r0, r5 - strh r3, [r0, 0x10] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80C23B8 - - thumb_func_start sub_80C244C -sub_80C244C: @ 80C244C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r0, r1, r3 - ldrb r2, [r0, 0xA] - adds r3, 0x8 - adds r1, r3 - ldr r0, =gUnknown_0856EFC8 - lsls r2, 3 - adds r2, r0 - ldrb r0, [r2, 0x5] - lsls r0, 1 - adds r1, r0 - ldrh r0, [r2, 0x6] - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5 - bls _080C248C - ldrh r0, [r1] - cmp r0, 0 - beq _080C248C - movs r0, 0 - b _080C248E - .pool -_080C248C: - movs r0, 0x1 -_080C248E: - pop {r1} - bx r1 - thumb_func_end sub_80C244C - - thumb_func_start sub_80C2494 -sub_80C2494: @ 80C2494 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r0, r1, r3 - ldrb r2, [r0, 0xA] - adds r3, 0x8 - adds r1, r3 - ldr r0, =gUnknown_0856EFC8 - lsls r2, 3 - adds r2, r0 - ldrb r0, [r2, 0x5] - lsls r0, 1 - adds r1, r0 - ldrh r0, [r2, 0x6] - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5 - bls _080C24D8 - ldrh r1, [r1] - subs r0, 0x5 - cmp r1, r0 - bge _080C24D8 - movs r0, 0 - b _080C24DA - .pool -_080C24D8: - movs r0, 0x1 -_080C24DA: - pop {r1} - bx r1 - thumb_func_end sub_80C2494 - - thumb_func_start sub_80C24E0 -sub_80C24E0: @ 80C24E0 - push {r4,lr} - adds r4, r0, 0 - ldr r2, =gTasks - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldr r1, [r0] - ldr r0, =sub_80C1BCC - cmp r1, r0 - bne _080C2580 - movs r1, 0x30 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C2528 - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - bl sub_80C2494 - lsls r0, 24 - cmp r0, 0 - beq _080C2544 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - b _080C2550 - .pool -_080C2528: - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - bl sub_80C244C - lsls r0, 24 - cmp r0, 0 - beq _080C2544 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - b _080C2550 -_080C2544: - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 -_080C2550: - strb r0, [r2] - ldrh r2, [r4, 0x32] - movs r1, 0x30 - ldrsh r0, [r4, r1] - lsls r0, 7 - adds r0, r2, r0 - lsls r0, 24 - ldr r1, =gSineTable - lsrs r0, 23 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bge _080C256E - adds r0, 0x7F -_080C256E: - asrs r0, 7 - strh r0, [r4, 0x26] - adds r0, r2, 0 - adds r0, 0x8 - strh r0, [r4, 0x32] - b _080C258C - .pool -_080C2580: - adds r0, r4, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_080C258C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80C24E0 - - thumb_func_start sub_80C2594 -sub_80C2594: @ 80C2594 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r6, =gUnknown_0855D1AC - adds r0, r6, 0 - movs r1, 0xB8 - movs r2, 0x4 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r0, r1, r4 - movs r2, 0 - strh r5, [r0, 0x2E] - strh r2, [r0, 0x30] - movs r0, 0x1C - adds r0, r4 - mov r9, r0 - add r1, r9 - ldr r0, =sub_80C24E0 - mov r8, r0 - str r0, [r1] - adds r0, r6, 0 - movs r1, 0xB8 - movs r2, 0x6C - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r4, r1, r4 - strh r5, [r4, 0x2E] - movs r0, 0x1 - strh r0, [r4, 0x30] - adds r4, 0x3F - ldrb r0, [r4] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r4] - add r1, r9 - mov r0, r8 - str r0, [r1] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C2594 - - thumb_func_start sub_80C2618 -sub_80C2618: @ 80C2618 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x8 - movs r1, 0x78 - movs r2, 0xE0 - movs r3, 0x20 - bl sub_80C12B0 - adds r0, r4, 0 - movs r1, 0x8 - movs r2, 0x79 - bl sub_80C1270 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80C2618 - - thumb_func_start sub_80C2638 -sub_80C2638: @ 80C2638 - push {lr} - adds r1, r0, 0 - lsls r1, 4 - adds r1, 0x8 - movs r0, 0x90 - movs r2, 0x8 - movs r3, 0x10 - bl sub_80C12B0 - pop {r0} - bx r0 - thumb_func_end sub_80C2638 - - thumb_func_start sub_80C2650 -sub_80C2650: @ 80C2650 - push {lr} - adds r2, r0, 0 - ldr r0, =gText_SelectorArrow - lsls r2, 4 - adds r2, 0x9 - movs r1, 0x90 - bl sub_80C1270 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80C2650 - - thumb_func_start sub_80C2668 -sub_80C2668: @ 80C2668 - push {lr} - adds r2, r0, 0 - adds r0, r1, 0 - lsls r2, 4 - adds r2, 0x9 - movs r1, 0x98 - bl sub_80C1270 - pop {r0} - bx r0 - thumb_func_end sub_80C2668 - - thumb_func_start sub_80C267C -sub_80C267C: @ 80C267C - push {lr} - movs r0, 0x90 - movs r1, 0x8 - movs r2, 0x60 - movs r3, 0x60 - bl sub_80C12B0 - pop {r0} - bx r0 - thumb_func_end sub_80C267C - - .align 2, 0 @ Don't pad with nop. diff --git a/include/global.h b/include/global.h index 37c064e79..18db15ea4 100644 --- a/include/global.h +++ b/include/global.h @@ -171,6 +171,8 @@ struct Time /*0x04*/ s8 seconds; }; +#define DEX_FLAGS_NO ((POKEMON_SLOTS_NUMBER / 8) + ((POKEMON_SLOTS_NUMBER % 8) ? 1 : 0)) + struct Pokedex { /*0x00*/ u8 order; @@ -180,8 +182,8 @@ struct Pokedex /*0x04*/ u32 unownPersonality; // set when you first see Unown /*0x08*/ u32 spindaPersonality; // set when you first see Spinda /*0x0C*/ u32 unknown3; - /*0x10*/ u8 owned[52]; - /*0x44*/ u8 seen[52]; + /*0x10*/ u8 owned[DEX_FLAGS_NO]; + /*0x44*/ u8 seen[DEX_FLAGS_NO]; }; struct PokemonJumpResults // possibly used in the game itself? @@ -657,7 +659,7 @@ struct SaveBlock1 /*0x690*/ struct ItemSlot bagPocket_TMHM[64]; /*0x790*/ struct ItemSlot bagPocket_Berries[46]; /*0x848*/ struct Pokeblock pokeblocks[POKEBLOCKS_COUNT]; - /*0x988*/ u8 seen1[52]; + /*0x988*/ u8 seen1[DEX_FLAGS_NO]; /*0x9BC*/ u16 berryBlenderRecords[3]; /*0x9C2*/ u8 field_9C2[6]; /*0x9C8*/ u16 trainerRematchStepCounter; @@ -713,7 +715,7 @@ struct SaveBlock1 /*0x322C*/ u8 field_322C[1276]; /*0x3728*/ struct RamScript ramScript; /*0x3B14*/ struct RecordMixingGift recordMixingGift; - /*0x3B24*/ u8 seen2[52]; + /*0x3B24*/ u8 seen2[DEX_FLAGS_NO]; /*0x3B58*/ LilycoveLady lilycoveLady; /*0x3B88*/ u8 filler_3B88[0x10]; /*0x3B98*/ struct UnkSaveSubstruct_3b98 unk_3B98[20]; diff --git a/include/graphics.h b/include/graphics.h index 36b337753..4b93606b6 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2667,6 +2667,11 @@ extern const u8 gUnknown_08DC3198[]; extern const u8 gUnknown_08DC2E6C[]; extern const u8 gUnknown_08DC2F5C[]; extern const u8 gUnknown_08DC2FEC[]; +extern const u16 gPokedexCaughtScreenFade_Pal[]; +extern const u8 gPokedexSearchMenu_Gfx[]; +extern const u8 gPokedexSearch2_Tilemap[]; +extern const u8 gPokedexSearch1_Tilemap[]; +extern const u16 gPokedexSearchMenu_Pal[]; // berry tag screen extern const u8 gUnknown_08D9BB44[]; diff --git a/include/pokedex.h b/include/pokedex.h index 19e1162e2..f9e236588 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -2,7 +2,7 @@ #define GUARD_POKEDEX_H void ResetPokedex(void); -void CopyMonCategoryText(u16 species, u8 *dst); +void CopyMonCategoryText(u32 species, u8 *dst); u16 GetPokedexHeightWeight(u16 dexNum, u8 data); u16 GetNationalPokedexCount(u8); u16 GetHoennPokedexCount(u8); diff --git a/include/strings.h b/include/strings.h index c51824225..b8caf80a0 100644 --- a/include/strings.h +++ b/include/strings.h @@ -370,6 +370,18 @@ extern const u8 gText_CantBeUsedOnPkmn[]; extern const u8 gText_CryOf[]; extern const u8 gText_SizeComparedTo[]; +extern const u8 gText_PokedexRegistration[]; +extern const u8 gText_UnkCtrlF908Clear01[]; +extern const u8 sText_TenDashes2[]; +extern const u8 gText_5MarksPokemon[]; +extern const u8 gText_UnkHeight[]; +extern const u8 gText_UnkWeight[]; +extern const u8 gText_HTHeight[]; +extern const u8 gText_WTWeight[]; +extern const u8 gText_SearchingPleaseWait[]; +extern const u8 gText_SearchCompleted[]; +extern const u8 gUnknown_085E8785[]; +extern const u8 gText_SelectorArrow[]; //birch dex rating text extern const u8 gBirchDexRatingText_LessThan10[]; diff --git a/ld_script.txt b/ld_script.txt index 2832bcada..0f47d7396 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -125,7 +125,6 @@ SECTIONS { src/scanline_effect.o(.text); src/option_menu.o(.text); src/pokedex.o(.text); - asm/pokedex.o(.text); asm/trainer_card.o(.text); src/pokemon_storage_system.o(.text); asm/pokemon_storage_system.o(.text); diff --git a/src/pokedex.c b/src/pokedex.c index bef5abbc9..8094f5b5d 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -16,6 +16,7 @@ #include "malloc.h" #include "gpu_regs.h" #include "constants/songs.h" +#include "constants/species.h" #include "constants/rgb.h" #include "overworld.h" #include "menu.h" @@ -29,14 +30,14 @@ #include "m4a.h" #include "international_string_util.h" -extern struct PokedexView *gUnknown_02039B4C; -extern u16 gUnknown_02039B50; -extern u8 gUnknown_02039B52; -extern struct PokedexListItem *gUnknown_02039B54; +static EWRAM_DATA struct PokedexView *gUnknown_02039B4C = NULL; +static EWRAM_DATA u16 gUnknown_02039B50 = 0; +static EWRAM_DATA u8 gUnknown_02039B52 = 0; +static EWRAM_DATA struct PokedexListItem *gUnknown_02039B54 = NULL; -extern u8 gUnknown_030060B0; -extern MainCallback gUnknown_030060B4; -extern u8 gUnknown_030061EC; +u8 gUnknown_030060B0; +MainCallback gUnknown_030060B4; +u8 gUnknown_030061EC; struct PokedexEntry { @@ -51,10 +52,67 @@ struct PokedexEntry /*0x1C*/ u16 trainerOffset; }; /*size = 0x20*/ +struct UnknownStruct2 +{ + const u8 *text1; + const u8 *text2; +}; + +struct UnknownStruct1 +{ + const struct UnknownStruct2 *unk0; + u8 unk4; + u8 unk5; + u16 unk6; +}; + +struct UnknownStruct3 +{ + const u8 *text; + u8 unk4; + u8 unk5; + u8 unk6; +}; + +struct UnknownStruct4 +{ + const u8 *text; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; + u8 unk8; + u8 unk9; +}; + +//TO BE CONVERTED TO C + +extern const u8 gUnknown_0855D30C[]; extern struct BgTemplate gUnknown_0856E630[]; extern struct WindowTemplate gUnknown_0856E640[]; extern const u16 gUnknown_0856E610[16]; extern const struct PokedexEntry gPokedexEntries[]; +extern struct BgTemplate gUnknown_0856E668[]; +extern struct WindowTemplate gUnknown_0856E670[]; +extern const u8 *gMonFootprintTable[]; +extern u8 gUnknown_0856ED08[][4]; +extern struct BgTemplate gUnknown_0856EFF8[]; +extern struct WindowTemplate gUnknown_0856F008[]; +extern const u8 gUnknown_0856ED9C[][4]; +extern const u8 gUnknown_0856EDB8[][4]; +extern const u8 gUnknown_0856EDD4[][4]; +extern const u8 gUnknown_0856EDF0[][4]; +extern const struct UnknownStruct1 gUnknown_0856EFC8[]; +extern const struct UnknownStruct3 gUnknown_0856ED30[]; +extern const struct UnknownStruct4 gUnknown_0856ED48[]; +extern const struct UnknownStruct2 gUnknown_0856EE0C[]; +extern const struct UnknownStruct2 gUnknown_0856EE5C[]; +extern const struct UnknownStruct2 gUnknown_0856EEB4[]; +extern const struct UnknownStruct2 gUnknown_0856EF14[]; +extern const struct UnknownStruct2 gUnknown_0856EE24[]; +extern const u8 gUnknown_0856EFAC[]; +extern const u8 gUnknown_0856EFAE[]; +extern const u8 gUnknown_0856EFB4[]; #define HOENN_DEX_COUNT 202 #define NATIONAL_DEX_COUNT 386 @@ -190,13 +248,44 @@ void sub_80BFCDC(u16); void sub_80BFCF4(u16); void sub_80BFD0C(u8, u16); void sub_80BFD7C(u8, u16); -void sub_80C020C(u16, u8, u8, u8); +void sub_80BFE38(u8); +void sub_80C0088(u8); +void blockset_load_palette_to_gpu(u8); +void sub_80C01CC(struct Sprite *sprite); +void sub_80C020C(u32, u32, u32, u32); +void sub_80C0354(u16, u8, u8); +void sub_80C0460(u16, u8, u8); void sub_80C09B0(u16); -void sub_80C0B44(u8, u16, u8, u8); +u8 sub_80C0B44(u8, u16, u8, u8); void sub_80C0D30(u8, u16); -u8 sub_80C0EF8(u16, u8, u8, u8); +u16 sub_80C0EF8(u16, s16, s16, s8); u16 sub_80C0E0C(u8, u16, u16, u16); u8 sub_80C1258(); +void sub_80C12E0(u8); +void sub_80C1570(u8); +void sub_80C15B0(u8); +void sub_80C16CC(u8); +void sub_80C170C(u8); +void sub_80C19A4(u8); +void sub_80C1A4C(u8); +void sub_80C1AB8(u8); +void sub_80C1B64(u8); +void sub_80C1BCC(u8); +void sub_80C1D38(u8); +void sub_80C1D70(u8); +void sub_80C2040(u8); +void sub_80C2064(u8, u8); +void sub_80C20F8(u8); +void sub_80C21D4(u8); +void sub_80C2294(u8); +u8 sub_80C2318(u8, u8); +void sub_80C23B8(u8); +void sub_80C2594(u8); +void sub_80C2618(const u8*); +void sub_80C2638(u32); +void sub_80C2650(u32); +void sub_80C2668(u32, const u8*); +void sub_80C267C(void); // const rom data #include "data/pokedex_orders.h" @@ -729,8 +818,6 @@ const u8 sText_TenDashes[] = _("----------"); // .text -#define DEX_FLAGS_NO ((POKEMON_SLOTS_NUMBER / 8) + ((POKEMON_SLOTS_NUMBER % 8) ? 1 : 0)) - void ResetPokedex(void) { u16 i; @@ -826,68 +913,68 @@ void sub_80BB534(void) switch (gMain.state) { - case 0: - default: - SetVBlankCallback(NULL); - sub_80C09B0(0); - addr = (u8 *)VRAM; - size = VRAM_SIZE; - while (1) - { - DmaFill16(3, 0, addr, 0x1000); - addr += 0x1000; - size -= 0x1000; - if (size <= 0x1000) + case 0: + default: + SetVBlankCallback(NULL); + sub_80C09B0(0); + addr = (u8 *)VRAM; + size = VRAM_SIZE; + while (1) { - DmaFill16(3, 0, addr, size); - break; + DmaFill16(3, 0, addr, 0x1000); + addr += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaFill16(3, 0, addr, size); + break; + } } - } - DmaClear32(3, OAM, OAM_SIZE); - DmaClear16(3, PLTT, PLTT_SIZE); - gMain.state = 1; - break; - case 1: - ScanlineEffect_Stop(); - ResetTasks(); - ResetSpriteData(); - ResetPaletteFade(); - FreeAllSpritePalettes(); - gReservedSpritePaletteCount = 8; - dp13_810BB8C(); - gMain.state++; - break; - case 2: - gUnknown_02039B4C = AllocZeroed(sizeof(struct PokedexView)); - sub_80BB384(gUnknown_02039B4C); - CreateTask(sub_80BB78C, 0); - gUnknown_02039B4C->dexMode = gSaveBlock2Ptr->pokedex.unknown1; - if (!IsNationalPokedexEnabled()) - gUnknown_02039B4C->dexMode = DEX_MODE_HOENN; - gUnknown_02039B4C->dexOrder = gSaveBlock2Ptr->pokedex.order; - gUnknown_02039B4C->selectedPokemon = gUnknown_02039B50; - gUnknown_02039B4C->unk62C = gUnknown_02039B52; - gUnknown_02039B4C->selectedScreen = 0; - if (!IsNationalPokedexEnabled()) - { - gUnknown_02039B4C->unk61A = GetHoennPokedexCount(0); - gUnknown_02039B4C->unk61C = GetHoennPokedexCount(1); - } - else - { - gUnknown_02039B4C->unk61A = GetNationalPokedexCount(0); - gUnknown_02039B4C->unk61C = GetNationalPokedexCount(1); - } - gUnknown_02039B4C->unk62D = 8; - gMain.state++; - break; - case 3: - EnableInterrupts(1); - SetVBlankCallback(sub_80BB370); - SetMainCallback2(sub_80BB774); - sub_80BC8D4(gUnknown_02039B4C->dexMode, gUnknown_02039B4C->dexOrder); - m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x80); - break; + DmaClear32(3, OAM, OAM_SIZE); + DmaClear16(3, PLTT, PLTT_SIZE); + gMain.state = 1; + break; + case 1: + ScanlineEffect_Stop(); + ResetTasks(); + ResetSpriteData(); + ResetPaletteFade(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + dp13_810BB8C(); + gMain.state++; + break; + case 2: + gUnknown_02039B4C = AllocZeroed(sizeof(struct PokedexView)); + sub_80BB384(gUnknown_02039B4C); + CreateTask(sub_80BB78C, 0); + gUnknown_02039B4C->dexMode = gSaveBlock2Ptr->pokedex.unknown1; + if (!IsNationalPokedexEnabled()) + gUnknown_02039B4C->dexMode = DEX_MODE_HOENN; + gUnknown_02039B4C->dexOrder = gSaveBlock2Ptr->pokedex.order; + gUnknown_02039B4C->selectedPokemon = gUnknown_02039B50; + gUnknown_02039B4C->unk62C = gUnknown_02039B52; + gUnknown_02039B4C->selectedScreen = 0; + if (!IsNationalPokedexEnabled()) + { + gUnknown_02039B4C->unk61A = GetHoennPokedexCount(0); + gUnknown_02039B4C->unk61C = GetHoennPokedexCount(1); + } + else + { + gUnknown_02039B4C->unk61A = GetNationalPokedexCount(0); + gUnknown_02039B4C->unk61C = GetNationalPokedexCount(1); + } + gUnknown_02039B4C->unk62D = 8; + gMain.state++; + break; + case 3: + EnableInterrupts(1); + SetVBlankCallback(sub_80BB370); + SetMainCallback2(sub_80BB774); + sub_80BC8D4(gUnknown_02039B4C->dexMode, gUnknown_02039B4C->dexOrder); + m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x80); + break; } } @@ -1178,33 +1265,33 @@ void sub_80BC0F8(u8 taskId) switch (gUnknown_02039B4C->menuCursorPos) { case 0: //BACK TO LIST - default: - gMain.newKeys |= START_BUTTON; - break; - case 1: //LIST TOP - gUnknown_02039B4C->selectedPokemon = 0; - gUnknown_02039B4C->unk62C = 0x40; - sub_80BDA40(); - sub_80BD2B4(gUnknown_02039B4C->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; - break; - case 2: //LIST BOTTOM - gUnknown_02039B4C->selectedPokemon = gUnknown_02039B4C->pokemonListCount - 1; - gUnknown_02039B4C->unk62C = gUnknown_02039B4C->pokemonListCount * 16 + 0x30; - sub_80BDA40(); - sub_80BD2B4(gUnknown_02039B4C->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; - break; - case 3: //BACK TO POKEDEX - BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BC3DC; - PlaySE(SE_TRACK_DOOR); - break; - case 4: //CLOSE POKEDEX - BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BC47C; - PlaySE(SE_PC_OFF); - break; + default: + gMain.newKeys |= START_BUTTON; + break; + case 1: //LIST TOP + gUnknown_02039B4C->selectedPokemon = 0; + gUnknown_02039B4C->unk62C = 0x40; + sub_80BDA40(); + sub_80BD2B4(gUnknown_02039B4C->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; + break; + case 2: //LIST BOTTOM + gUnknown_02039B4C->selectedPokemon = gUnknown_02039B4C->pokemonListCount - 1; + gUnknown_02039B4C->unk62C = gUnknown_02039B4C->pokemonListCount * 16 + 0x30; + sub_80BDA40(); + sub_80BD2B4(gUnknown_02039B4C->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; + break; + case 3: //BACK TO POKEDEX + BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = sub_80BC3DC; + PlaySE(SE_TRACK_DOOR); + break; + case 4: //CLOSE POKEDEX + BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = sub_80BC47C; + PlaySE(SE_PC_OFF); + break; } } @@ -1286,92 +1373,92 @@ bool8 sub_80BC514(u8 a) { switch (gMain.state) { - case 0: - default: - if (gPaletteFade.active) - return 0; - SetVBlankCallback(NULL); - gUnknown_02039B4C->unk64A = a; - sub_80C09B0(0); - SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_02039B4C->unk62D); - ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gBgTemplates_0855D298, 4); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - 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); - CopyToBgTilemapBuffer(1, gUnknown_08DC2C5C, 0, 0); - CopyToBgTilemapBuffer(3, gUnknown_08DC2DAC, 0, 0); - if (a == 0) - CopyToBgTilemapBuffer(0, gUnknown_08DC2A08, 0, 0x280); - else - CopyToBgTilemapBuffer(0, gUnknown_08DC2B1C, 0, 0x280); - ResetPaletteFade(); - if (a == 0) - gUnknown_02039B4C->unk64C_1 = FALSE; - else - gUnknown_02039B4C->unk64C_1 = TRUE; - sub_80BC844(gUnknown_02039B4C->unk64C_1); - InitWindows(sWindowTemplates_0855D2A8); - DeactivateAllTextPrinters(); - PutWindowTilemap(0); - CopyWindowToVram(0, 3); - gMain.state = 1; - break; - case 1: - ResetSpriteData(); - FreeAllSpritePalettes(); - gReservedSpritePaletteCount = 8; - LoadCompressedObjectPic(&gSpriteSheets_0855D26C[0]); - LoadSpritePalettes(gSpritePalettes_0855D26C); - sub_80BDB7C(a); - gMain.state++; - break; - case 2: - gMain.state++; - break; - case 3: - if (a == 0) - sub_80BC8D4(gUnknown_02039B4C->dexMode, gUnknown_02039B4C->dexOrder); - sub_80BD2B4(gUnknown_02039B4C->selectedPokemon, 0xE); - gUnknown_02039B4C->menuIsOpen = 0; - gUnknown_02039B4C->menuY = 0; - CopyBgTilemapBufferToVram(0); - CopyBgTilemapBufferToVram(1); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); - gMain.state++; - break; - case 4: - BeginNormalPaletteFade(-1, 0, 0x10, 0, RGB_BLACK); - SetVBlankCallback(sub_80BB370); - gMain.state++; - break; - case 5: - SetGpuReg(REG_OFFSET_WININ, 0x3F3F); - SetGpuReg(REG_OFFSET_WINOUT, 0x1D3F); - SetGpuReg(REG_OFFSET_WIN0H, 0); - SetGpuReg(REG_OFFSET_WIN0V, 0); - SetGpuReg(REG_OFFSET_WIN1H, 0); - SetGpuReg(REG_OFFSET_WIN1V, 0); - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_OBJWIN_ON); - ShowBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); - gMain.state++; - break; - case 6: - if (!gPaletteFade.active) - { - gMain.state = 0; - return TRUE; - } - break; + case 0: + default: + if (gPaletteFade.active) + return 0; + SetVBlankCallback(NULL); + gUnknown_02039B4C->unk64A = a; + sub_80C09B0(0); + SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_02039B4C->unk62D); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gBgTemplates_0855D298, 4); + SetBgTilemapBuffer(3, AllocZeroed(0x800)); + 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); + CopyToBgTilemapBuffer(1, gUnknown_08DC2C5C, 0, 0); + CopyToBgTilemapBuffer(3, gUnknown_08DC2DAC, 0, 0); + if (a == 0) + CopyToBgTilemapBuffer(0, gUnknown_08DC2A08, 0, 0x280); + else + CopyToBgTilemapBuffer(0, gUnknown_08DC2B1C, 0, 0x280); + ResetPaletteFade(); + if (a == 0) + gUnknown_02039B4C->unk64C_1 = FALSE; + else + gUnknown_02039B4C->unk64C_1 = TRUE; + sub_80BC844(gUnknown_02039B4C->unk64C_1); + InitWindows(sWindowTemplates_0855D2A8); + DeactivateAllTextPrinters(); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); + gMain.state = 1; + break; + case 1: + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + LoadCompressedObjectPic(&gSpriteSheets_0855D26C[0]); + LoadSpritePalettes(gSpritePalettes_0855D26C); + sub_80BDB7C(a); + gMain.state++; + break; + case 2: + gMain.state++; + break; + case 3: + if (a == 0) + sub_80BC8D4(gUnknown_02039B4C->dexMode, gUnknown_02039B4C->dexOrder); + sub_80BD2B4(gUnknown_02039B4C->selectedPokemon, 0xE); + gUnknown_02039B4C->menuIsOpen = 0; + gUnknown_02039B4C->menuY = 0; + CopyBgTilemapBufferToVram(0); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 4: + BeginNormalPaletteFade(-1, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(sub_80BB370); + gMain.state++; + break; + case 5: + SetGpuReg(REG_OFFSET_WININ, 0x3F3F); + SetGpuReg(REG_OFFSET_WINOUT, 0x1D3F); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WIN1H, 0); + SetGpuReg(REG_OFFSET_WIN1V, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_OBJWIN_ON); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 6: + if (!gPaletteFade.active) + { + gMain.state = 0; + return TRUE; + } + break; } return FALSE; } @@ -1415,134 +1502,134 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) switch (dexMode) { - default: - case DEX_MODE_HOENN: - vars[0] = HOENN_DEX_COUNT; - vars[1] = 1; - break; - case DEX_MODE_NATIONAL: - if (IsNationalPokedexEnabled()) - { - vars[0] = NATIONAL_DEX_COUNT; - vars[1] = 0; - } - else - { + default: + case DEX_MODE_HOENN: vars[0] = HOENN_DEX_COUNT; vars[1] = 1; - } - break; + break; + case DEX_MODE_NATIONAL: + if (IsNationalPokedexEnabled()) + { + vars[0] = NATIONAL_DEX_COUNT; + vars[1] = 0; + } + else + { + vars[0] = HOENN_DEX_COUNT; + vars[1] = 1; + } + break; } switch (sortMode) { - case 0: - if (vars[1]) - { - for (i = 0; i < vars[0]; i++) + case 0: + if (vars[1]) { - vars[2] = HoennToNationalOrder(i + 1); - gUnknown_02039B4C->unk0[i].dexNum = vars[2]; - gUnknown_02039B4C->unk0[i].seen = GetSetPokedexFlag(vars[2], 0); - gUnknown_02039B4C->unk0[i].owned = GetSetPokedexFlag(vars[2], 1); - if (gUnknown_02039B4C->unk0[i].seen) - gUnknown_02039B4C->pokemonListCount = i + 1; - } - } - else - { - bool32 r10; - s16 r5; - - r10 = r5 = i = 0; - for (i = 0; i < vars[0]; i++) - { - vars[2] = i + 1; - if (GetSetPokedexFlag(vars[2], 0)) - r10 = 1; - if (r10) + for (i = 0; i < vars[0]; i++) { - asm(""); //Needed to match for some reason - gUnknown_02039B4C->unk0[r5].dexNum = vars[2]; - gUnknown_02039B4C->unk0[r5].seen = GetSetPokedexFlag(vars[2], 0); - gUnknown_02039B4C->unk0[r5].owned = GetSetPokedexFlag(vars[2], 1); - if (gUnknown_02039B4C->unk0[r5].seen) - gUnknown_02039B4C->pokemonListCount = r5 + 1; - r5++; + vars[2] = HoennToNationalOrder(i + 1); + gUnknown_02039B4C->unk0[i].dexNum = vars[2]; + gUnknown_02039B4C->unk0[i].seen = GetSetPokedexFlag(vars[2], 0); + gUnknown_02039B4C->unk0[i].owned = GetSetPokedexFlag(vars[2], 1); + if (gUnknown_02039B4C->unk0[i].seen) + gUnknown_02039B4C->pokemonListCount = i + 1; } } - } - break; - case 1: - for (i = 0; i < POKEMON_SLOTS_NUMBER - 1; i++) - { - vars[2] = gPokedexOrder_Alphabetical[i]; - - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 0)) + else { - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = GetSetPokedexFlag(vars[2], 1); - gUnknown_02039B4C->pokemonListCount++; - } - } - break; - case 2: - for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) - { - vars[2] = gPokedexOrder_Weight[i]; + bool32 r10; + s16 r5; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) - { - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; - gUnknown_02039B4C->pokemonListCount++; + r10 = r5 = i = 0; + for (i = 0; i < vars[0]; i++) + { + vars[2] = i + 1; + if (GetSetPokedexFlag(vars[2], 0)) + r10 = 1; + if (r10) + { + asm(""); //Needed to match for some reason + gUnknown_02039B4C->unk0[r5].dexNum = vars[2]; + gUnknown_02039B4C->unk0[r5].seen = GetSetPokedexFlag(vars[2], 0); + gUnknown_02039B4C->unk0[r5].owned = GetSetPokedexFlag(vars[2], 1); + if (gUnknown_02039B4C->unk0[r5].seen) + gUnknown_02039B4C->pokemonListCount = r5 + 1; + r5++; + } + } } - } - break; - case 3: - for (i = 0; i < NATIONAL_DEX_COUNT; i++) - { - vars[2] = gPokedexOrder_Weight[i]; + break; + case 1: + for (i = 0; i < POKEMON_SLOTS_NUMBER - 1; i++) + { + vars[2] = gPokedexOrder_Alphabetical[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) - { - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; - gUnknown_02039B4C->pokemonListCount++; + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 0)) + { + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = GetSetPokedexFlag(vars[2], 1); + gUnknown_02039B4C->pokemonListCount++; + } } - } - break; - case 4: - for (i = NATIONAL_DEX_COUNT - 1; i >=0; i--) - { - vars[2] = gPokedexOrder_Height[i]; + break; + case 2: + for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) + { + vars[2] = gPokedexOrder_Weight[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) - { - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; - gUnknown_02039B4C->pokemonListCount++; + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + { + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; + gUnknown_02039B4C->pokemonListCount++; + } } - } - break; - case 5: - for (i = 0; i < NATIONAL_DEX_COUNT; i++) - { - vars[2] = gPokedexOrder_Height[i]; + break; + case 3: + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + vars[2] = gPokedexOrder_Weight[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) - { - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; - gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; - gUnknown_02039B4C->pokemonListCount++; + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + { + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; + gUnknown_02039B4C->pokemonListCount++; + } } - } - break; + break; + case 4: + for (i = NATIONAL_DEX_COUNT - 1; i >=0; i--) + { + vars[2] = gPokedexOrder_Height[i]; + + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + { + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; + gUnknown_02039B4C->pokemonListCount++; + } + } + break; + case 5: + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + vars[2] = gPokedexOrder_Height[i]; + + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + { + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].dexNum = vars[2]; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].seen = 1; + gUnknown_02039B4C->unk0[gUnknown_02039B4C->pokemonListCount].owned = 1; + gUnknown_02039B4C->pokemonListCount++; + } + } + break; } for (i = gUnknown_02039B4C->pokemonListCount; i < NATIONAL_DEX_COUNT; i++) @@ -1571,81 +1658,81 @@ void sub_80BCE84(u8 a, u16 b, u16 c) switch (a) { - case 0: - default: - _b = b - 5; - for (i = 0; i <= 10; i++) - { - if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gUnknown_02039B4C->unk0[_b].dexNum == 0xFFFF) + case 0: + default: + _b = b - 5; + for (i = 0; i <= 10; i++) { - sub_80BD28C(0x11, i * 2, c); - } - else - { - sub_80BD28C(0x11, i * 2, c); - if (gUnknown_02039B4C->unk0[_b].seen) + if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gUnknown_02039B4C->unk0[_b].dexNum == 0xFFFF) { - sub_80BD154(_b, 0x12, i * 2, c); - sub_80BD1F4(gUnknown_02039B4C->unk0[_b].owned, 0x11, i * 2, c); - sub_80BD23C(gUnknown_02039B4C->unk0[_b].dexNum, 0x16, i * 2); + sub_80BD28C(0x11, i * 2, c); } else { - sub_80BD154(_b, 0x12, i * 2, c); - sub_80BD1F4(0, 0x11, i * 2, c); - sub_80BD23C(0, 0x16, i * 2); + sub_80BD28C(0x11, i * 2, c); + if (gUnknown_02039B4C->unk0[_b].seen) + { + sub_80BD154(_b, 0x12, i * 2, c); + sub_80BD1F4(gUnknown_02039B4C->unk0[_b].owned, 0x11, i * 2, c); + sub_80BD23C(gUnknown_02039B4C->unk0[_b].dexNum, 0x16, i * 2); + } + else + { + sub_80BD154(_b, 0x12, i * 2, c); + sub_80BD1F4(0, 0x11, i * 2, c); + sub_80BD23C(0, 0x16, i * 2); + } + } + _b++; + } + break; + case 1: + _b = b - 5; + if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gUnknown_02039B4C->unk0[_b].dexNum == 0xFFFF) + { + sub_80BD28C(0x11, gUnknown_02039B4C->unk630 * 2, c); + } + else + { + sub_80BD28C(0x11, gUnknown_02039B4C->unk630 * 2, c); + if (gUnknown_02039B4C->unk0[_b].seen) + { + sub_80BD154(_b, 0x12, gUnknown_02039B4C->unk630 * 2, c); + sub_80BD1F4(gUnknown_02039B4C->unk0[_b].owned, 0x11, gUnknown_02039B4C->unk630 * 2, c); + sub_80BD23C(gUnknown_02039B4C->unk0[_b].dexNum, 0x16, gUnknown_02039B4C->unk630 * 2); + } + else + { + sub_80BD154(_b, 0x12, gUnknown_02039B4C->unk630 * 2, c); + sub_80BD1F4(0, 0x11, gUnknown_02039B4C->unk630 * 2, c); + sub_80BD23C(0, 0x16, gUnknown_02039B4C->unk630 * 2); } } - _b++; - } - break; - case 1: - _b = b - 5; - if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gUnknown_02039B4C->unk0[_b].dexNum == 0xFFFF) - { - sub_80BD28C(0x11, gUnknown_02039B4C->unk630 * 2, c); - } - else - { - sub_80BD28C(0x11, gUnknown_02039B4C->unk630 * 2, c); - if (gUnknown_02039B4C->unk0[_b].seen) - { - sub_80BD154(_b, 0x12, gUnknown_02039B4C->unk630 * 2, c); - sub_80BD1F4(gUnknown_02039B4C->unk0[_b].owned, 0x11, gUnknown_02039B4C->unk630 * 2, c); - sub_80BD23C(gUnknown_02039B4C->unk0[_b].dexNum, 0x16, gUnknown_02039B4C->unk630 * 2); - } + break; + case 2: + _b = b + 5; + r2 = gUnknown_02039B4C->unk630 + 10; + if (r2 > 15) + r2 -= 16; + if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gUnknown_02039B4C->unk0[_b].dexNum == 0xFFFF) + sub_80BD28C(0x11, r2 * 2, c); else { - sub_80BD154(_b, 0x12, gUnknown_02039B4C->unk630 * 2, c); - sub_80BD1F4(0, 0x11, gUnknown_02039B4C->unk630 * 2, c); - sub_80BD23C(0, 0x16, gUnknown_02039B4C->unk630 * 2); + sub_80BD28C(0x11, r2 * 2, c); + if (gUnknown_02039B4C->unk0[_b].seen) + { + sub_80BD154(_b, 0x12, r2 * 2, c); + sub_80BD1F4(gUnknown_02039B4C->unk0[_b].owned, 0x11, r2 * 2, c); + sub_80BD23C(gUnknown_02039B4C->unk0[_b].dexNum, 0x16, r2 * 2); + } + else + { + sub_80BD154(_b, 0x12, r2 * 2, c); + sub_80BD1F4(0, 0x11, r2 * 2, c); + sub_80BD23C(0, 0x16, r2 * 2); + } } - } - break; - case 2: - _b = b + 5; - r2 = gUnknown_02039B4C->unk630 + 10; - if (r2 > 15) - r2 -= 16; - if (_b < 0 || _b >= NATIONAL_DEX_COUNT || gUnknown_02039B4C->unk0[_b].dexNum == 0xFFFF) - sub_80BD28C(0x11, r2 * 2, c); - else - { - sub_80BD28C(0x11, r2 * 2, c); - if (gUnknown_02039B4C->unk0[_b].seen) - { - sub_80BD154(_b, 0x12, r2 * 2, c); - sub_80BD1F4(gUnknown_02039B4C->unk0[_b].owned, 0x11, r2 * 2, c); - sub_80BD23C(gUnknown_02039B4C->unk0[_b].dexNum, 0x16, r2 * 2); - } - else - { - sub_80BD154(_b, 0x12, r2 * 2, c); - sub_80BD1F4(0, 0x11, r2 * 2, c); - sub_80BD23C(0, 0x16, r2 * 2); - } - } - break; + break; } CopyWindowToVram(0, 2); } @@ -1746,26 +1833,26 @@ bool8 sub_80BD404(u8 a, u8 b, u8 c) gUnknown_02039B4C->unk62E--; switch (a) { - case 1: - for (i = 0; i < 4; i++) - { - if (gUnknown_02039B4C->unk61E[i] != 0xFFFF) - gSprites[gUnknown_02039B4C->unk61E[i]].data[5] += b; - } - foo = 16 * (c - gUnknown_02039B4C->unk62E) / c; - SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_02039B4C->unk62D + gUnknown_02039B4C->unk632 * 16 - foo); - gUnknown_02039B4C->unk62C -= gUnknown_02039B4C->unk628; - break; - case 2: - for (i = 0; i < 4; i++) - { - if (gUnknown_02039B4C->unk61E[i] != 0xFFFF) - gSprites[gUnknown_02039B4C->unk61E[i]].data[5] -= b; - } - foo = 16 * (c - gUnknown_02039B4C->unk62E) / c; - SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_02039B4C->unk62D + gUnknown_02039B4C->unk632 * 16 + foo); - gUnknown_02039B4C->unk62C += gUnknown_02039B4C->unk628; - break; + case 1: + for (i = 0; i < 4; i++) + { + if (gUnknown_02039B4C->unk61E[i] != 0xFFFF) + gSprites[gUnknown_02039B4C->unk61E[i]].data[5] += b; + } + foo = 16 * (c - gUnknown_02039B4C->unk62E) / c; + SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_02039B4C->unk62D + gUnknown_02039B4C->unk632 * 16 - foo); + gUnknown_02039B4C->unk62C -= gUnknown_02039B4C->unk628; + break; + case 2: + for (i = 0; i < 4; i++) + { + if (gUnknown_02039B4C->unk61E[i] != 0xFFFF) + gSprites[gUnknown_02039B4C->unk61E[i]].data[5] -= b; + } + foo = 16 * (c - gUnknown_02039B4C->unk62E) / c; + SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_02039B4C->unk62D + gUnknown_02039B4C->unk632 * 16 + foo); + gUnknown_02039B4C->unk62C += gUnknown_02039B4C->unk628; + break; } return FALSE; } @@ -1784,32 +1871,32 @@ void sub_80BD5A8(u8 a, u16 b) gUnknown_02039B4C->unk632 = gUnknown_02039B4C->unk630; switch (a) { - case 1: - unk = sub_80BDA8C(b - 1); - if (unk != 0xFFFF) - { - spriteId = sub_80BDACC(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_80BE4E0; - gSprites[spriteId].data[5] = -64; - } - if (gUnknown_02039B4C->unk630 > 0) - gUnknown_02039B4C->unk630--; - else - gUnknown_02039B4C->unk630 = 15; - break; - case 2: - unk = sub_80BDA8C(b + 1); - if (unk != 0xFFFF) - { - spriteId = sub_80BDACC(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_80BE4E0; - gSprites[spriteId].data[5] = 0x40; - } - if (gUnknown_02039B4C->unk630 <= 0xE) - gUnknown_02039B4C->unk630++; - else - gUnknown_02039B4C->unk630 = 0; - break; + case 1: + unk = sub_80BDA8C(b - 1); + if (unk != 0xFFFF) + { + spriteId = sub_80BDACC(unk, 0x60, 0x50); + gSprites[spriteId].callback = sub_80BE4E0; + gSprites[spriteId].data[5] = -64; + } + if (gUnknown_02039B4C->unk630 > 0) + gUnknown_02039B4C->unk630--; + else + gUnknown_02039B4C->unk630 = 15; + break; + case 2: + unk = sub_80BDA8C(b + 1); + if (unk != 0xFFFF) + { + spriteId = sub_80BDACC(unk, 0x60, 0x50); + gSprites[spriteId].callback = sub_80BE4E0; + gSprites[spriteId].data[5] = 0x40; + } + if (gUnknown_02039B4C->unk630 <= 0xE) + gUnknown_02039B4C->unk630++; + else + gUnknown_02039B4C->unk630 = 0; + break; } } @@ -2553,14 +2640,14 @@ void sub_80BEDF4(u8 taskId) { if (gTasks[taskId].data[0] != 0) { - BeginNormalPaletteFade(-1, 0, 0, 16, 0); + BeginNormalPaletteFade(-1, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = sub_80BF038; PlaySE(SE_Z_SCROLL); return; } if (gMain.newKeys & B_BUTTON) { - BeginNormalPaletteFade(-1, 0, 0, 16, 0); + BeginNormalPaletteFade(-1, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = sub_80BF070; PlaySE(SE_PC_OFF); return; @@ -2569,36 +2656,36 @@ void sub_80BEDF4(u8 taskId) { switch (gUnknown_02039B4C->selectedScreen) { - case AREA_SCREEN: - BeginNormalPaletteFade(-0x15, 0, 0, 16, 0); - gUnknown_02039B4C->unk64E = 1; - gTasks[taskId].func = sub_80BEFD0; - PlaySE(SE_PIN); - break; - case CRY_SCREEN: - BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); - gUnknown_02039B4C->unk64E = 2; - gTasks[taskId].func = sub_80BEFD0; - PlaySE(SE_PIN); - break; - case SIZE_SCREEN: - if (!gUnknown_02039B54->owned) - { - PlaySE(SE_HAZURE); - } - else - { - BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); - gUnknown_02039B4C->unk64E = 3; + case AREA_SCREEN: + BeginNormalPaletteFade(-0x15, 0, 0, 16, RGB_BLACK); + gUnknown_02039B4C->unk64E = 1; gTasks[taskId].func = sub_80BEFD0; PlaySE(SE_PIN); - } - break; - case CANCEL_SCREEN: - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskId].func = sub_80BF070; - PlaySE(SE_PC_OFF); - break; + break; + case CRY_SCREEN: + BeginNormalPaletteFade(-0x15, 0, 0, 0x10, RGB_BLACK); + gUnknown_02039B4C->unk64E = 2; + gTasks[taskId].func = sub_80BEFD0; + PlaySE(SE_PIN); + break; + case SIZE_SCREEN: + if (!gUnknown_02039B54->owned) + { + PlaySE(SE_HAZURE); + } + else + { + BeginNormalPaletteFade(-0x15, 0, 0, 0x10, RGB_BLACK); + gUnknown_02039B4C->unk64E = 3; + gTasks[taskId].func = sub_80BEFD0; + PlaySE(SE_PIN); + } + break; + case CANCEL_SCREEN: + BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = sub_80BF070; + PlaySE(SE_PC_OFF); + break; } return; } @@ -2707,13 +2794,13 @@ void sub_80BF1EC(u8 taskId) { switch (gUnknown_02039B4C->unk64E) { - case 1: - default: - gTasks[taskId].func = sub_80BEA24; - break; - case 2: - gTasks[taskId].func = sub_80BF250; - break; + case 1: + default: + gTasks[taskId].func = sub_80BEA24; + break; + case 2: + gTasks[taskId].func = sub_80BF250; + break; } } } @@ -2799,7 +2886,7 @@ void sub_80BF250(u8 taskId) } break; case 8: - BeginNormalPaletteFade(-0x15, 0, 0x10, 0, 0); + BeginNormalPaletteFade(-0x15, 0, 0x10, 0, RGB_BLACK); SetVBlankCallback(gUnknown_030060B4); gMain.state++; break; @@ -2841,7 +2928,7 @@ void sub_80BF5CC(u8 taskId) { if (gMain.newKeys & B_BUTTON) { - BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-0x15, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); gUnknown_02039B4C->unk64E = 1; gTasks[taskId].func = sub_80BF790; @@ -2851,7 +2938,7 @@ void sub_80BF5CC(u8 taskId) if ((gMain.newKeys & DPAD_LEFT) || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { - BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-0x15, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); gUnknown_02039B4C->unk64E = 2; gTasks[taskId].func = sub_80BF790; @@ -2867,7 +2954,7 @@ void sub_80BF5CC(u8 taskId) } else { - BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-0x15, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); gUnknown_02039B4C->unk64E = 3; gTasks[taskId].func = sub_80BF790; @@ -2886,16 +2973,16 @@ void sub_80BF790(u8 taskId) sub_818D820(gTasks[taskId].data[4]); switch (gUnknown_02039B4C->unk64E) { - default: - case 1: - gTasks[taskId].func = sub_80BEA24; - break; - case 2: - gTasks[taskId].func = sub_80BF0AC; - break; - case 3: - gTasks[taskId].func = sub_80BF82C; - break; + default: + case 1: + gTasks[taskId].func = sub_80BEA24; + break; + case 2: + gTasks[taskId].func = sub_80BF0AC; + break; + case 3: + gTasks[taskId].func = sub_80BF82C; + break; } } } @@ -2917,95 +3004,95 @@ void sub_80BF82C(u8 taskId) switch (gMain.state) { - default: - case 0: - if (!gPaletteFade.active) - { - gUnknown_02039B4C->unk64A = 7; - gUnknown_030060B4 = gMain.vblankCallback; - SetVBlankCallback(NULL); - sub_80C09B0(0x200); - gUnknown_02039B4C->selectedScreen = SIZE_SCREEN; - gMain.state = 1; - } - break; - case 1: - copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0); - CopyToBgTilemapBuffer(3, gUnknown_08DC2E6C, 0, 0); - FillWindowPixelBuffer(0, 0); - PutWindowTilemap(0); - gMain.state++; - break; - case 2: - sub_80BFCF4(0xD); - sub_80BFD7C(2, 0xD); - sub_80BC844(gUnknown_02039B4C->unk64C_1); - gMain.state++; - break; - case 3: - { - u8 string[0x40]; //I hope this is the correct size - - StringCopy(string, gText_SizeComparedTo); - StringAppend(string, gSaveBlock2Ptr->playerName); - sub_80BE8DC(string, GetStringCenterAlignXOffset(1, string, 0xF0), 0x79); + default: + case 0: + if (!gPaletteFade.active) + { + gUnknown_02039B4C->unk64A = 7; + gUnknown_030060B4 = gMain.vblankCallback; + SetVBlankCallback(NULL); + sub_80C09B0(0x200); + gUnknown_02039B4C->selectedScreen = SIZE_SCREEN; + gMain.state = 1; + } + break; + case 1: + copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + CopyToBgTilemapBuffer(3, gUnknown_08DC2E6C, 0, 0); + FillWindowPixelBuffer(0, 0); + PutWindowTilemap(0); gMain.state++; - } - break; - case 4: - ResetPaletteFade(); - gMain.state++; - break; - case 5: - spriteId = sub_80C0EF8(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), 152, 56, 0); - gSprites[spriteId].oam.affineMode = 1; - gSprites[spriteId].oam.matrixNum = 1; - gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_02039B54->dexNum].trainerOffset; - SetOamMatrix(1, gPokedexEntries[gUnknown_02039B54->dexNum].trainerScale, 0, 0, gPokedexEntries[gUnknown_02039B54->dexNum].trainerScale); - LoadPalette(gUnknown_0856E610, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); - gTasks[taskId].data[5] = spriteId; - gMain.state++; - break; - case 6: - spriteId = sub_80C0E9C(gUnknown_02039B54->dexNum, 88, 56, 1); - gSprites[spriteId].oam.affineMode = 1; - gSprites[spriteId].oam.matrixNum = 2; - gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_02039B54->dexNum].pokemonOffset; - SetOamMatrix(2, gPokedexEntries[gUnknown_02039B54->dexNum].pokemonScale, 0, 0, gPokedexEntries[gUnknown_02039B54->dexNum].pokemonScale); - LoadPalette(gUnknown_0856E610, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); - gTasks[taskId].data[4] = spriteId; - CopyWindowToVram(0, 3); - CopyBgTilemapBufferToVram(1); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); - gMain.state++; - break; - case 7: - BeginNormalPaletteFade(-0x15, 0, 0x10, 0, 0); - SetVBlankCallback(gUnknown_030060B4); - gMain.state++; - break; - case 8: - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - HideBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); - gMain.state++; - break; - case 9: - if (!gPaletteFade.active) - { - gUnknown_02039B4C->unk64E = 0; - gMain.state = 0; - gTasks[taskId].func = sub_80BFBB0; - } - break; + break; + case 2: + sub_80BFCF4(0xD); + sub_80BFD7C(2, 0xD); + sub_80BC844(gUnknown_02039B4C->unk64C_1); + gMain.state++; + break; + case 3: + { + u8 string[0x40]; //I hope this is the correct size + + StringCopy(string, gText_SizeComparedTo); + StringAppend(string, gSaveBlock2Ptr->playerName); + sub_80BE8DC(string, GetStringCenterAlignXOffset(1, string, 0xF0), 0x79); + gMain.state++; + } + break; + case 4: + ResetPaletteFade(); + gMain.state++; + break; + case 5: + spriteId = sub_80C0EF8(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), 152, 56, 0); + gSprites[spriteId].oam.affineMode = 1; + gSprites[spriteId].oam.matrixNum = 1; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_02039B54->dexNum].trainerOffset; + SetOamMatrix(1, gPokedexEntries[gUnknown_02039B54->dexNum].trainerScale, 0, 0, gPokedexEntries[gUnknown_02039B54->dexNum].trainerScale); + LoadPalette(gUnknown_0856E610, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); + gTasks[taskId].data[5] = spriteId; + gMain.state++; + break; + case 6: + spriteId = sub_80C0E9C(gUnknown_02039B54->dexNum, 88, 56, 1); + gSprites[spriteId].oam.affineMode = 1; + gSprites[spriteId].oam.matrixNum = 2; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].pos2.y = gPokedexEntries[gUnknown_02039B54->dexNum].pokemonOffset; + SetOamMatrix(2, gPokedexEntries[gUnknown_02039B54->dexNum].pokemonScale, 0, 0, gPokedexEntries[gUnknown_02039B54->dexNum].pokemonScale); + LoadPalette(gUnknown_0856E610, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); + gTasks[taskId].data[4] = spriteId; + CopyWindowToVram(0, 3); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 7: + BeginNormalPaletteFade(-0x15, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(gUnknown_030060B4); + gMain.state++; + break; + case 8: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + HideBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 9: + if (!gPaletteFade.active) + { + gUnknown_02039B4C->unk64E = 0; + gMain.state = 0; + gTasks[taskId].func = sub_80BFBB0; + } + break; } } @@ -3013,7 +3100,7 @@ void sub_80BFBB0(u8 taskId) { if (gMain.newKeys & B_BUTTON) { - BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-0x15, 0, 0, 0x10, RGB_BLACK); gUnknown_02039B4C->unk64E = 1; gTasks[taskId].func = sub_80BFC78; PlaySE(SE_PC_OFF); @@ -3021,7 +3108,7 @@ void sub_80BFBB0(u8 taskId) else if ((gMain.newKeys & DPAD_LEFT) || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { - BeginNormalPaletteFade(-0x15, 0, 0, 0x10, 0); + BeginNormalPaletteFade(-0x15, 0, 0, 0x10, RGB_BLACK); gUnknown_02039B4C->unk64E = 2; gTasks[taskId].func = sub_80BFC78; PlaySE(SE_Z_PAGE); @@ -3036,13 +3123,13 @@ void sub_80BFC78(u8 taskId) sub_818D8F0(gTasks[taskId].data[5]); switch (gUnknown_02039B4C->unk64E) { - default: - case 1: - gTasks[taskId].func = sub_80BEA24; - break; - case 2: - gTasks[taskId].func = sub_80BF250; - break; + default: + case 1: + gTasks[taskId].func = sub_80BEA24; + break; + case 2: + gTasks[taskId].func = sub_80BF250; + break; } } } @@ -3057,29 +3144,2099 @@ void sub_80BFCF4(u16 a) CopyToBgTilemapBuffer(1, gUnknown_08DC2FEC, 0, 0); } -/* void sub_80BFD0C(u8 a, u16 unused) +#ifdef NONMATCHING +void sub_80BFD0C(u8 a, u16 unused) { u8 i; u8 j; - u16* r7 = GetBgTilemapBuffer(1); - u8 r5; - u16 r3; - + u16* ptr = GetBgTilemapBuffer(1); + for (i = 0; i < 4; i++) { - r5 = i * 7 + 1; + u8 row = (i * 7) + 1; + u16 newPalette = 0x4000; + if (i == a) - r3 = 0x2000; - else - r3 = 0x4000; - + newPalette = 0x2000; + for (j = 0; j < 7; j++) { - u32 r1 = (r5 + j); - - *(r7 + r1) = (*(r7 + r1) & 0xFFF) | r3; - *(r7 + 0x40 + r1) = (*(r7 + 0x40 + r1) & 0xFFF) | r3; + ptr[row + j] = (ptr[row + j] % 0x1000) | newPalette; + ptr[row + j + 0x20] = (ptr[row + j + 0x20] % 0x1000) | newPalette; } } CopyBgTilemapBufferToVram(1); -} */ +} +#else +__attribute__((naked)) +void sub_80BFD0C(u8 a, u16 unused) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + movs r0, 0x1\n\ + bl GetBgTilemapBuffer\n\ + adds r7, r0, 0\n\ + movs r1, 0\n\ +_080BFD22:\n\ + lsls r0, r1, 3\n\ + subs r0, r1\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r3, 0x80\n\ + lsls r3, 7\n\ + cmp r1, r8\n\ + bne _080BFD38\n\ + movs r3, 0x80\n\ + lsls r3, 6\n\ +_080BFD38:\n\ + movs r2, 0\n\ + adds r6, r1, 0x1\n\ + ldr r4, =0x00000fff\n\ +_080BFD3E:\n\ + adds r1, r5, r2\n\ + lsls r1, 1\n\ + adds r1, r7\n\ + ldrh r0, [r1]\n\ + ands r0, r4\n\ + orrs r0, r3\n\ + strh r0, [r1]\n\ + adds r1, 0x40\n\ + ldrh r0, [r1]\n\ + ands r0, r4\n\ + orrs r0, r3\n\ + strh r0, [r1]\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + cmp r2, 0x6\n\ + bls _080BFD3E\n\ + lsls r0, r6, 24\n\ + lsrs r1, r0, 24\n\ + cmp r1, 0x3\n\ + bls _080BFD22\n\ + movs r0, 0x1\n\ + bl CopyBgTilemapBufferToVram\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +#ifdef NONMATCHING +void sub_80BFD7C(u8 a, u16 b) +{ + u8 i; + u8 j; + u16* ptr = GetBgTilemapBuffer(1); + + for (i = 0; i < 4; i++) + { + u8 row = i * 7 + 1; + u32 newPalette; + + if (i == a || i == 3) + newPalette = 0x2000; + else + newPalette = 0x4000; + + for (j = 0; j < 7; j++) + { + ptr[row + j] = (ptr[row + j] % 0x1000) | newPalette; + ptr[row + j + 0x20] = (ptr[row + j + 0x20] % 0x1000) | newPalette; + } + } + CopyBgTilemapBufferToVram(1); +} +#else +__attribute__((naked)) +void sub_80BFD7C(u8 a, u16 b) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + movs r0, 0x1\n\ + bl GetBgTilemapBuffer\n\ + adds r7, r0, 0\n\ + movs r1, 0\n\ +_080BFD92:\n\ + lsls r0, r1, 3\n\ + subs r0, r1\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + cmp r1, r8\n\ + beq _080BFDA4\n\ + cmp r1, 0x3\n\ + bne _080BFDAA\n\ +_080BFDA4:\n\ + movs r3, 0x80\n\ + lsls r3, 6\n\ + b _080BFDAE\n\ +_080BFDAA:\n\ + movs r3, 0x80\n\ + lsls r3, 7\n\ +_080BFDAE:\n\ + movs r2, 0\n\ + adds r5, r1, 0x1\n\ + ldr r4, =0x00000fff\n\ +_080BFDB4:\n\ + adds r1, r6, r2\n\ + lsls r1, 1\n\ + adds r1, r7\n\ + ldrh r0, [r1]\n\ + ands r0, r4\n\ + orrs r0, r3\n\ + strh r0, [r1]\n\ + adds r1, 0x40\n\ + ldrh r0, [r1]\n\ + ands r0, r4\n\ + orrs r0, r3\n\ + strh r0, [r1]\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + cmp r2, 0x6\n\ + bls _080BFDB4\n\ + lsls r0, r5, 24\n\ + lsrs r1, r0, 24\n\ + cmp r1, 0x3\n\ + bls _080BFD92\n\ + movs r0, 0x1\n\ + bl CopyBgTilemapBufferToVram\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 b, u32 c) +{ + u8 taskId = CreateTask(sub_80BFE38, 0); + + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = dexNum; + gTasks[taskId].data[12] = b; + gTasks[taskId].data[13] = b >> 16; + gTasks[taskId].data[14] = c; + gTasks[taskId].data[15] = c >> 16; + return taskId; +} + +void sub_80BFE38(u8 taskId) +{ + u8 spriteId; + u16 dexNum = gTasks[taskId].data[1]; + + switch (gTasks[taskId].data[0]) + { + case 0: + default: + if (!gPaletteFade.active) + { + gUnknown_030060B4 = gMain.vblankCallback; + SetVBlankCallback(NULL); + sub_80C09B0(0x100); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0856E668, 2); + SetBgTilemapBuffer(3, AllocZeroed(0x800)); + SetBgTilemapBuffer(2, AllocZeroed(0x800)); + InitWindows(gUnknown_0856E670); + DeactivateAllTextPrinters(); + gTasks[taskId].data[0] = 1; + } + break; + case 1: + copy_decompressed_tile_data_to_vram_autofree(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + CopyToBgTilemapBuffer(3, gUnknown_08DC3080, 0, 0); + FillWindowPixelBuffer(0, 0); + PutWindowTilemap(0); + PutWindowTilemap(1); + sub_80C0D30(1, gTasks[taskId].data[1]); + CopyWindowToVram(1, 2); + ResetPaletteFade(); + sub_80BC844(0); + gTasks[taskId].data[0]++; + break; + case 2: + gTasks[taskId].data[0]++; + break; + case 3: + sub_80C020C(dexNum, IsNationalPokedexEnabled(), 1, 1); + CopyWindowToVram(0, 3); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gTasks[taskId].data[0]++; + break; + case 4: + spriteId = sub_80C0E9C(dexNum, 0x30, 0x38, 0); + gSprites[spriteId].oam.priority = 0; + BeginNormalPaletteFade(-1, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(gUnknown_030060B4); + gTasks[taskId].data[3] = spriteId; + gTasks[taskId].data[0]++; + break; + case 5: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + ShowBg(2); + ShowBg(3); + gTasks[taskId].data[0]++; + break; + case 6: + if (!gPaletteFade.active) + { + PlayCry1(NationalPokedexNumToSpecies(dexNum), 0); + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_80C0088; + } + break; + } +} + +void sub_80C0088(u8 taskId) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + BeginNormalPaletteFade(0x0000FFFF, 0, 0, 16, RGB_BLACK); + gSprites[gTasks[taskId].data[3]].callback = sub_80C01CC; + gTasks[taskId].func = blockset_load_palette_to_gpu; + } + else if (++gTasks[taskId].data[2] & 0x10) + { + LoadPalette(gPokedexText_Pal + 1, 0x31, 14); + } + else + { + LoadPalette(gPokedexCaughtScreenFade_Pal + 1, 0x31, 14); + } +} + +void blockset_load_palette_to_gpu(u8 taskId) +{ + if (!gPaletteFade.active) + { + u16 species; + u32 otId; + u32 personality; + u8 paletteNum; + const u8 *lzPaletteData; + void *buffer; + + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + FreeAllWindowBuffers(); + buffer = GetBgTilemapBuffer(2); + if (buffer) + Free(buffer); + buffer = GetBgTilemapBuffer(3); + if (buffer) + Free(buffer); + + species = NationalPokedexNumToSpecies(gTasks[taskId].data[1]); + otId = ((u16)gTasks[taskId].data[13] << 16) | (u16)gTasks[taskId].data[12]; + personality = ((u16)gTasks[taskId].data[15] << 16) | (u16)gTasks[taskId].data[14]; + paletteNum = gSprites[gTasks[taskId].data[3]].oam.paletteNum; + lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality); + LoadCompressedPalette(lzPaletteData, 0x100 | paletteNum * 16, 32); + DestroyTask(taskId); + } +} + +void sub_80C01CC(struct Sprite *sprite) +{ + if (sprite->pos1.x < 0x78) + sprite->pos1.x += 2; + if (sprite->pos1.x > 0x78) + sprite->pos1.x -= 2; + + if (sprite->pos1.y < 0x50) + sprite->pos1.y += 1; + if (sprite->pos1.y > 0x50) + sprite->pos1.y -= 1; +} + +void sub_80C020C(u32 num, u32 b, u32 c, u32 d) +{ + u8 str[0x10]; + u8 str2[0x20]; + u16 natNum; + const u8 *text; + const u8 *text2; + const u8 *text3; + + if (d) + sub_80BE8DC(gText_PokedexRegistration, GetStringCenterAlignXOffset(1, gText_PokedexRegistration, 0xF0), 0); + if (b == 0) + b = NationalToHoennOrder(num); + else + b = num; + ConvertIntToDecimalStringN(StringCopy(str, gText_UnkCtrlF908Clear01), b, 2, 3); + sub_80BE8DC(str, 0x60, 0x19); + natNum = NationalPokedexNumToSpecies(num); + if (natNum) + text = gSpeciesNames[natNum]; + else + text = sText_TenDashes2; + sub_80BE8DC(text, 0x84, 0x19); + if (c) + { + CopyMonCategoryText(num, str2); + text2 = str2; + } + else + { + text2 = gText_5MarksPokemon; + } + sub_80BE8DC(text2, 0x64, 0x29); + sub_80BE8DC(gText_HTHeight, 0x60, 0x39); + sub_80BE8DC(gText_WTWeight, 0x60, 0x49); + if (c) + { + sub_80C0354(gPokedexEntries[num].height, 0x81, 0x39); + sub_80C0460(gPokedexEntries[num].weight, 0x81, 0x49); + } + else + { + sub_80BE8DC(gText_UnkHeight, 0x81, 0x39); + sub_80BE8DC(gText_UnkWeight, 0x81, 0x49); + } + if (c) + text3 = gPokedexEntries[num].description; + else + text3 = gUnknown_0855D30C; + sub_80BE8DC(text3, GetStringCenterAlignXOffset(1, text3, 0xF0), 0x5F); +} + +#define CHAR_PRIME (0xB4) +#define CHAR_DOUBLE_PRIME (0xB2) + +void sub_80C0354(u16 height, u8 left, u8 top) +{ + u8 buffer[16]; + u32 inches, feet; + u8 i = 0; + + inches = (height * 10000) / 254; + if (inches % 10 >= 5) + inches += 10; + feet = inches / 120; + inches = (inches - (feet * 120)) / 10; + + buffer[i++] = EXT_CTRL_CODE_BEGIN; + buffer[i++] = 0x13; + if (feet / 10 == 0) + { + buffer[i++] = 18; + buffer[i++] = feet + CHAR_0; + } + else + { + buffer[i++] = 12; + buffer[i++] = feet / 10 + CHAR_0; + buffer[i++] = (feet % 10) + CHAR_0; + } + buffer[i++] = CHAR_PRIME; + buffer[i++] = (inches / 10) + CHAR_0; + buffer[i++] = (inches % 10) + CHAR_0; + buffer[i++] = CHAR_DOUBLE_PRIME; + buffer[i++] = EOS; + sub_80BE8DC(buffer, left, top); +} + +#ifdef NONMATCHING +void sub_80C0460(u16 weight, u8 left, u8 top) +{ + u8 buffer[16]; + u32 lbs; + u8 i = 0; + bool8 output; + + lbs = (weight * 100000) / 4536; + if (lbs % 10 >= 5) + lbs += 10; + output = FALSE; + + buffer[i] = (lbs / 100000) + CHAR_0; + if (buffer[i] == CHAR_0) + { + buffer[i++] = 0x77; + } + else + { + output = TRUE; + i++; + } + + lbs = (lbs % 100000); + buffer[i] = (lbs / 10000) + CHAR_0; + if (buffer[i] == CHAR_0 && output == FALSE) + { + buffer[i++] = 0x77; + } + else + { + output = TRUE; + i++; + } + + lbs = (lbs % 10000); + buffer[i] = (lbs / 1000) + CHAR_0; + if (buffer[i] == CHAR_0 && output == FALSE) + { + buffer[i++] = 0x77; + } + else + { + i++; + } + lbs = (lbs % 1000); + buffer[i++] = (lbs / 100) + CHAR_0; + lbs = (lbs % 100); + buffer[i++] = CHAR_PERIOD; + buffer[i++] = (lbs / 10) + CHAR_0; + buffer[i++] = CHAR_SPACE; + buffer[i++] = CHAR_l; + buffer[i++] = CHAR_b; + buffer[i++] = CHAR_s; + buffer[i++] = CHAR_PERIOD; + buffer[i++] = EOS; + sub_80BE8DC(buffer, left, top); +} +#else +__attribute__((naked)) +void sub_80C0460(u16 weight, u8 left, u8 top) +{ + asm(".syntax 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, 0x14\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r10, r1\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + str r2, [sp, 0x10]\n\ + ldr r5, =0x000186a0\n\ + muls r0, r5\n\ + ldr r1, =0x000011b8\n\ + bl __divsi3\n\ + adds r7, r0, 0\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + cmp r0, 0x4\n\ + bls _080C0494\n\ + adds r7, 0xA\n\ +_080C0494:\n\ + movs r0, 0\n\ + mov r8, r0\n\ + mov r4, sp\n\ + adds r0, r7, 0\n\ + adds r1, r5, 0\n\ + bl __udivsi3\n\ + adds r0, 0xA1\n\ + strb r0, [r4]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0xA1\n\ + bne _080C04C0\n\ + movs r6, 0x1\n\ + mov r1, sp\n\ + movs r0, 0x77\n\ + strb r0, [r1]\n\ + b _080C04C6\n\ + .pool\n\ +_080C04C0:\n\ + movs r1, 0x1\n\ + mov r8, r1\n\ + movs r6, 0x1\n\ +_080C04C6:\n\ + ldr r1, =0x000186a0\n\ + adds r0, r7, 0\n\ + bl __umodsi3\n\ + adds r7, r0, 0\n\ + mov r4, sp\n\ + adds r4, 0x1\n\ + ldr r1, =0x00002710\n\ + bl __udivsi3\n\ + adds r0, 0xA1\n\ + strb r0, [r4]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0xA1\n\ + bne _080C0504\n\ + mov r2, r8\n\ + cmp r2, 0\n\ + bne _080C0504\n\ + adds r1, r6, 0\n\ + adds r0, r1, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + add r1, sp\n\ + movs r0, 0x77\n\ + strb r0, [r1]\n\ + b _080C050E\n\ + .pool\n\ +_080C0504:\n\ + movs r3, 0x1\n\ + mov r8, r3\n\ + adds r0, r6, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ +_080C050E:\n\ + ldr r1, =0x00002710\n\ + adds r0, r7, 0\n\ + bl __umodsi3\n\ + adds r7, r0, 0\n\ + mov r0, sp\n\ + adds r4, r0, r6\n\ + movs r1, 0xFA\n\ + lsls r1, 2\n\ + adds r0, r7, 0\n\ + bl __udivsi3\n\ + adds r0, 0xA1\n\ + strb r0, [r4]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0xA1\n\ + bne _080C054C\n\ + mov r1, r8\n\ + cmp r1, 0\n\ + bne _080C054C\n\ + adds r1, r6, 0\n\ + adds r0, r1, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + add r1, sp\n\ + movs r0, 0x77\n\ + strb r0, [r1]\n\ + b _080C0552\n\ + .pool\n\ +_080C054C:\n\ + adds r0, r6, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ +_080C0552:\n\ + movs r1, 0xFA\n\ + lsls r1, 2\n\ + adds r0, r7, 0\n\ + bl __umodsi3\n\ + adds r7, r0, 0\n\ + adds r1, r6, 0\n\ + adds r0, r1, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r5, r6, 0\n\ + mov r2, sp\n\ + adds r4, r2, r1\n\ + adds r0, r7, 0\n\ + movs r1, 0x64\n\ + bl __udivsi3\n\ + adds r0, 0xA1\n\ + movs r3, 0\n\ + mov r9, r3\n\ + strb r0, [r4]\n\ + adds r0, r7, 0\n\ + movs r1, 0x64\n\ + bl __umodsi3\n\ + adds r7, r0, 0\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r1, r6, 0\n\ + mov r2, sp\n\ + adds r0, r2, r5\n\ + movs r3, 0xAD\n\ + mov r8, r3\n\ + mov r2, r8\n\ + strb r2, [r0]\n\ + adds r0, r1, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r5, r6, 0\n\ + mov r3, sp\n\ + adds r4, r3, r1\n\ + adds r0, r7, 0\n\ + movs r1, 0xA\n\ + bl __udivsi3\n\ + adds r0, 0xA1\n\ + strb r0, [r4]\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r1, r6, 0\n\ + mov r2, sp\n\ + adds r0, r2, r5\n\ + mov r3, r9\n\ + strb r3, [r0]\n\ + adds r0, r1, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r2, r6, 0\n\ + add r1, sp\n\ + movs r0, 0xE0\n\ + strb r0, [r1]\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r3, r6, 0\n\ + mov r0, sp\n\ + adds r1, r0, r2\n\ + movs r0, 0xD6\n\ + strb r0, [r1]\n\ + adds r0, r3, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r2, r6, 0\n\ + mov r0, sp\n\ + adds r1, r0, r3\n\ + movs r0, 0xE7\n\ + strb r0, [r1]\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r3, sp\n\ + adds r1, r3, r2\n\ + mov r2, r8\n\ + strb r2, [r1]\n\ + adds r1, r3, r0\n\ + movs r0, 0xFF\n\ + strb r0, [r1]\n\ + mov r0, sp\n\ + mov r1, r10\n\ + ldr r2, [sp, 0x10]\n\ + bl sub_80BE8DC\n\ + add sp, 0x14\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided\n"); +} +#endif + +const u8 *sub_80C0620(u16 dexNum) +{ + return gPokedexEntries[dexNum].categoryName; +} + +u16 GetPokedexHeightWeight(u16 dexNum, u8 data) +{ + switch (data) + { + case 0: // height + return gPokedexEntries[dexNum].height; + case 1: // weight + return gPokedexEntries[dexNum].weight; + default: + return 1; + } +} + +s8 GetSetPokedexFlag(u16 nationalDexNo, u8 caseID) +{ + u8 index; + u8 bit; + u8 mask; + s8 retVal; + + nationalDexNo--; + index = nationalDexNo / 8; + bit = nationalDexNo % 8; + mask = 1 << bit; + retVal = 0; + switch (caseID) + { + case FLAG_GET_SEEN: + if (gSaveBlock2Ptr->pokedex.seen[index] & mask) + { + if ((gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) + && (gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) + retVal = 1; + else + { + gSaveBlock2Ptr->pokedex.seen[index] &= ~mask; + gSaveBlock1Ptr->seen1[index] &= ~mask; + gSaveBlock1Ptr->seen2[index] &= ~mask; + retVal = 0; + } + } + break; + case FLAG_GET_CAUGHT: + if (gSaveBlock2Ptr->pokedex.owned[index] & mask) + { + if ((gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock2Ptr->pokedex.seen[index] & mask) + && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) + && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) + retVal = 1; + else + { + gSaveBlock2Ptr->pokedex.owned[index] &= ~mask; + gSaveBlock2Ptr->pokedex.seen[index] &= ~mask; + gSaveBlock1Ptr->seen1[index] &= ~mask; + gSaveBlock1Ptr->seen2[index] &= ~mask; + retVal = 0; + } + } + break; + case FLAG_SET_SEEN: + gSaveBlock2Ptr->pokedex.seen[index] |= mask; + gSaveBlock1Ptr->seen1[index] |= mask; + gSaveBlock1Ptr->seen2[index] |= mask; + break; + case FLAG_SET_CAUGHT: + gSaveBlock2Ptr->pokedex.owned[index] |= mask; + break; + } + return retVal; +} + +u16 GetNationalPokedexCount(u8 caseID) +{ + u16 count = 0; + u16 i; + + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + switch (caseID) + { + case FLAG_GET_SEEN: + if (GetSetPokedexFlag(i + 1, FLAG_GET_SEEN)) + count++; + break; + case FLAG_GET_CAUGHT: + if (GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) + count++; + break; + } + } + return count; +} + +u16 GetHoennPokedexCount(u8 caseID) +{ + u16 count = 0; + u16 i; + + for (i = 0; i < 202; i++) + { + switch (caseID) + { + case FLAG_GET_SEEN: + if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_SEEN)) + count++; + break; + case FLAG_GET_CAUGHT: + if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_CAUGHT)) + count++; + break; + } + } + return count; +} + +u16 sub_80C089C(u8 caseID) +{ + u16 count = 0; + u16 i; + + for (i = 0; i < 151; i++) + { + switch (caseID) + { + case FLAG_GET_SEEN: + if (GetSetPokedexFlag(i + 1, FLAG_GET_SEEN)) + count++; + break; + case FLAG_GET_CAUGHT: + if (GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) + count++; + break; + } + } + return count; +} + +bool8 sub_80C08E4(void) +{ + u16 i; + + for (i = 0; i < 200; i++) + { + if (!GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_CAUGHT)) + return FALSE; + } + return TRUE; +} + +bool8 sub_80C0918(void) +{ + u16 i; + + for (i = 0; i < 150; i++) + { + if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) + return FALSE; + } + return TRUE; +} + +u16 sub_80C0944(void) +{ + u16 i; + + for (i = 0; i < 150; i++) + { + if (GetSetPokedexFlag(i + 1, 1) == 0) + return 0; + } + for (i = 151; i < 248; i++) + { + if (GetSetPokedexFlag(i + 1, 1) == 0) + return 0; + } + for (i = 251; i < 384; i++) + { + if (GetSetPokedexFlag(i + 1, 1) == 0) + return 0; + } + return 1; +} + +void sub_80C09B0(u16 a) +{ + if (!(a & 0x100)) + { + ClearGpuRegBits(0, 0x100); + SetGpuReg(REG_OFFSET_BG0CNT, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + } + if (!(a & 0x200)) + { + ClearGpuRegBits(0, 0x200); + SetGpuReg(REG_OFFSET_BG1CNT, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + } + if (!(a & 0x400)) + { + ClearGpuRegBits(0, 0x400); + SetGpuReg(REG_OFFSET_BG2CNT, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + } + if (!(a & 0x800)) + { + ClearGpuRegBits(0, 0x800); + SetGpuReg(REG_OFFSET_BG3CNT, 0); + SetGpuReg(REG_OFFSET_BG3HOFS, 0); + SetGpuReg(REG_OFFSET_BG3VOFS, 0); + } + if (!(a & 0x1000)) + { + ClearGpuRegBits(0, 0x1000); + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + } +} + +void sub_80C0A88(u8 a, const u8 *b, u8 c, u8 d) +{ + u8 sp14[3]; + sp14[0] = 0; + sp14[1] = 15; + sp14[2] = 3; + + AddTextPrinterParameterized2(a, 1, c, d, 0, 0, sp14, -1, b); +} + +void sub_80C0AC4(u8 a, u16 order, u8 b, u8 c) +{ + u8 str[4]; + + str[0] = CHAR_0 + order / 100; + str[1] = CHAR_0 + (order % 100) / 10; + str[2] = CHAR_0 + (order % 100) % 10; + str[3] = EOS; + sub_80C0A88(a, str, b, c); +} + +u8 sub_80C0B44(u8 a, u16 num, u8 b, u8 c) +{ + u8 str[11]; + u8 i; + + for (i = 0; i < 11; i++) + str[i] = EOS; + num = NationalPokedexNumToSpecies(num); + switch (num) + { + default: + for (i = 0; gSpeciesNames[num][i] != EOS && i < 10; i++) + str[i] = gSpeciesNames[num][i]; + break; + case 0: + for (i = 0; i < 5; i++) + str[i] = 0xAE; + break; + } + sub_80C0A88(a, str, b, c); + return i; +} + +void sub_80C0BF0(u8 a, const u8* str, u8 b, u8 c) +{ + u8 str2[11]; + u8 i; + u8 count; + + for (i = 0; i < 11; i++) + str2[i] = CHAR_SPACE; + for (count = 0; str[count] != CHAR_SPACE && count < 11; count++) + ; + for (i = 0; i < count; i++) + str2[11 - count + i] = str[i]; + str2[11] = EOS; + sub_80C0A88(a, str2, b, c); +} + +void sub_80C0C6C(u8 a, u16 b, u8 left, u8 top) +{ + u8 str[6]; + bool8 outputted = FALSE; + u8 result; + + result = b / 1000; + if (result == 0) + { + str[0] = 0x77; + outputted = FALSE; + } + else + { + str[0] = CHAR_0 + result; + outputted = TRUE; + } + + result = (b % 1000) / 100; + if (result == 0 && !outputted) + { + str[1] = 0x77; + outputted = FALSE; + } + else + { + str[1] = CHAR_0 + result; + outputted = TRUE; + } + + str[2] = CHAR_0 + ((b % 1000) % 100) / 10; + str[3] = CHAR_PERIOD; + str[4] = CHAR_0 + ((b % 1000) % 100) % 10; + str[5] = EOS; + sub_80C0A88(a, str, left, top); +} + +void sub_80C0D30(u8 a0, u16 a1) +{ + u8 image[32 * 4]; + const u8 * r12 = gMonFootprintTable[NationalPokedexNumToSpecies(a1)]; + u16 r5 = 0; + u16 i; + u16 j; + + for (i = 0; i < 32; i++) + { + u8 r3 = r12[i]; + for (j = 0; j < 4; j++) + { + u8 value = ((r3 >> (2 * j)) & 1 ? 2 : 0); + if ((2 << (2 * j)) & r3) + value |= 0x20; + image[r5] = value; + r5++; + } + } + CopyToWindowPixelBuffer(a0, image, sizeof(image), 0); +} + +void sub_80C0DC0(u16 a, u16 b) +{ + *(u16 *)(VRAM + a * 0x800 + 0x232) = 0xF000 + b + 0; + *(u16 *)(VRAM + a * 0x800 + 0x234) = 0xF000 + b + 1; + *(u16 *)(VRAM + a * 0x800 + 0x272) = 0xF000 + b + 2; + *(u16 *)(VRAM + a * 0x800 + 0x274) = 0xF000 + b + 3; +} + +u16 sub_80C0E0C(u8 a, u16 b, u16 c, u16 d) +{ + switch (a) + { + case 1: + if (b > c) + b--; + break; + case 0: + if (b < d) + b++; + break; + case 3: + if (b > c) + b--; + else + b = d; + break; + case 2: + if (b < d) + b++; + else + b = c; + break; + } + return b; +} + +u32 sub_80C0E68(u16 a) +{ + if (a == SPECIES_UNOWN || a == SPECIES_SPINDA) + { + if (a == SPECIES_UNOWN) + return gSaveBlock2Ptr->pokedex.unownPersonality; + else + return gSaveBlock2Ptr->pokedex.spindaPersonality; + } + else + { + return 0; + } +} + +u16 sub_80C0E9C(u16 num, s16 a, s16 b, u16 c) +{ + num = NationalPokedexNumToSpecies(num); + return sub_818D7D8(num, 8, sub_80C0E68(num), 1, a, b, c, -1); +} + +u16 sub_80C0EF8(u16 a, s16 b, s16 c, s8 d) +{ + return sub_818D8AC(a, 1, b, c, d, -1); +} + +int sub_80C0F30(u8 a, u8 b, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2) +{ + u16 species; + u16 i; + u16 resultsCount; + u8 types[2]; + + sub_80BC8D4(a, b); + + for (i = 0, resultsCount = 0; i < NATIONAL_DEX_COUNT; i++) + { + if (gUnknown_02039B4C->unk0[i].seen) + { + gUnknown_02039B4C->unk0[resultsCount] = gUnknown_02039B4C->unk0[i]; + resultsCount++; + } + } + gUnknown_02039B4C->pokemonListCount = resultsCount; + + // Search by name + if (abcGroup != 0xFF) + { + for (i = 0, resultsCount = 0; i < gUnknown_02039B4C->pokemonListCount; i++) + { + u8 r3; + + species = NationalPokedexNumToSpecies(gUnknown_02039B4C->unk0[i].dexNum); + r3 = gSpeciesNames[species][0]; + if ((r3 >= gUnknown_0856ED08[abcGroup][0] && r3 < gUnknown_0856ED08[abcGroup][0] + gUnknown_0856ED08[abcGroup][1]) + || (r3 >= gUnknown_0856ED08[abcGroup][2] && r3 < gUnknown_0856ED08[abcGroup][2] + gUnknown_0856ED08[abcGroup][3])) + { + gUnknown_02039B4C->unk0[resultsCount] = gUnknown_02039B4C->unk0[i]; + resultsCount++; + } + } + gUnknown_02039B4C->pokemonListCount = resultsCount; + } + + // Search by body color + if (bodyColor != 0xFF) + { + for (i = 0, resultsCount = 0; i < gUnknown_02039B4C->pokemonListCount; i++) + { + species = NationalPokedexNumToSpecies(gUnknown_02039B4C->unk0[i].dexNum); + + if (bodyColor == gBaseStats[species].bodyColor) + { + gUnknown_02039B4C->unk0[resultsCount] = gUnknown_02039B4C->unk0[i]; + resultsCount++; + } + } + gUnknown_02039B4C->pokemonListCount = resultsCount; + } + + // Search by type + if (type1 != 0xFF || type2 != 0xFF) + { + if (type1 == 0xFF) + { + type1 = type2; + type2 = 0xFF; + } + + if (type2 == 0xFF) + { + for (i = 0, resultsCount = 0; i < gUnknown_02039B4C->pokemonListCount; i++) + { + if (gUnknown_02039B4C->unk0[i].owned) + { + species = NationalPokedexNumToSpecies(gUnknown_02039B4C->unk0[i].dexNum); + + types[0] = gBaseStats[species].type1; + types[1] = gBaseStats[species].type2; + if (types[0] == type1 || types[1] == type1) + { + gUnknown_02039B4C->unk0[resultsCount] = gUnknown_02039B4C->unk0[i]; + resultsCount++; + } + } + } + } + else + { + for (i = 0, resultsCount = 0; i < gUnknown_02039B4C->pokemonListCount; i++) + { + if (gUnknown_02039B4C->unk0[i].owned) + { + species = NationalPokedexNumToSpecies(gUnknown_02039B4C->unk0[i].dexNum); + + types[0] = gBaseStats[species].type1; + types[1] = gBaseStats[species].type2; + if ((types[0] == type1 && types[1] == type2) || (types[0] == type2 && types[1] == type1)) + { + gUnknown_02039B4C->unk0[resultsCount] = gUnknown_02039B4C->unk0[i]; + resultsCount++; + } + } + } + } + gUnknown_02039B4C->pokemonListCount = resultsCount; + } + + if (gUnknown_02039B4C->pokemonListCount != 0) + { + for (i = gUnknown_02039B4C->pokemonListCount; i < NATIONAL_DEX_COUNT; i++) + { + gUnknown_02039B4C->unk0[i].dexNum = 0xFFFF; + gUnknown_02039B4C->unk0[i].seen = FALSE; + gUnknown_02039B4C->unk0[i].owned = FALSE; + + } + } + + return resultsCount; +} + +u8 sub_80C1258(void) +{ + return CreateTask(sub_80C12E0, 0); +} + +void sub_80C1270(const u8 *str, u32 a, u32 b) +{ + u8 sp14[3]; + + sp14[0] = 0; + sp14[1] = 15; + sp14[2] = 2; + AddTextPrinterParameterized2(0, 1, a, b, 0, 0, sp14, -1, str); +} + +void sub_80C12B0(u32 a, u32 b, u32 c, u32 d) +{ + FillWindowPixelRect(0, 0, a, b, c, d); +} + +void sub_80C12E0(u8 taskId) +{ + u16 i; + + switch (gMain.state) + { + default: + case 0: + if (!gPaletteFade.active) + { + gUnknown_02039B4C->unk64A = 2; + sub_80C09B0(0); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0856EFF8, 4); + SetBgTilemapBuffer(3, AllocZeroed(0x800)); + SetBgTilemapBuffer(2, AllocZeroed(0x800)); + SetBgTilemapBuffer(1, AllocZeroed(0x800)); + SetBgTilemapBuffer(0, AllocZeroed(0x800)); + InitWindows(gUnknown_0856F008); + DeactivateAllTextPrinters(); + PutWindowTilemap(0); + copy_decompressed_tile_data_to_vram_autofree(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0); + + if (!IsNationalPokedexEnabled()) + CopyToBgTilemapBuffer(3, gPokedexSearch2_Tilemap, 0, 0); + else + CopyToBgTilemapBuffer(3, gPokedexSearch1_Tilemap, 0, 0); + LoadPalette(gPokedexSearchMenu_Pal + 1, 1, 0x7E); + gMain.state = 1; + } + break; + case 1: + LoadCompressedObjectPic(gSpriteSheets_0855D26C); + LoadSpritePalettes(gSpritePalettes_0855D26C); + sub_80C2594(taskId); + for (i = 0; i < 16; i++) + gTasks[taskId].data[i] = 0; + sub_80C23B8(taskId); + sub_80C2040(0); + sub_80C20F8(taskId); + CopyWindowToVram(0, 3); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 2: + BeginNormalPaletteFade(-1, 0, 16, 0, RGB_BLACK); + gMain.state++; + break; + case 3: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + HideBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 4: + if (!gPaletteFade.active) + { + gTasks[taskId].func = sub_80C1570; + gMain.state = 0; + } + break; + } +} + +void sub_80C152C(void) +{ + void* tilemapBuffer; + + FreeAllWindowBuffers(); + tilemapBuffer = GetBgTilemapBuffer(0); + if (tilemapBuffer) + Free(tilemapBuffer); + tilemapBuffer = GetBgTilemapBuffer(1); + if (tilemapBuffer) + Free(tilemapBuffer); + tilemapBuffer = GetBgTilemapBuffer(2); + if (tilemapBuffer) + Free(tilemapBuffer); + tilemapBuffer = GetBgTilemapBuffer(3); + if (tilemapBuffer) + Free(tilemapBuffer); +} + +void sub_80C1570(u8 taskId) +{ + sub_80C2040(gTasks[taskId].data[0]); + sub_80C20F8(taskId); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + gTasks[taskId].func = sub_80C15B0; +} + +void sub_80C15B0(u8 taskId) +{ + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_PC_OFF); + gTasks[taskId].func = sub_80C1D38; + return; + } + if (gMain.newKeys & A_BUTTON) + { + switch (gTasks[taskId].data[0]) + { + case 0: + PlaySE(SE_PIN); + gTasks[taskId].data[1] = 0; + gTasks[taskId].func = sub_80C16CC; + break; + case 1: + PlaySE(SE_PIN); + gTasks[taskId].data[1] = 4; + gTasks[taskId].func = sub_80C16CC; + break; + case 2: + PlaySE(SE_PC_OFF); + gTasks[taskId].func = sub_80C1D38; + break; + } + return; + } + if ((gMain.newKeys & DPAD_LEFT) && gTasks[taskId].data[0] > 0) + { + PlaySE(SE_Z_PAGE); + gTasks[taskId].data[0]--; + sub_80C2040(gTasks[taskId].data[0]); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + } + if ((gMain.newKeys & DPAD_RIGHT) && gTasks[taskId].data[0] < 2) + { + PlaySE(SE_Z_PAGE); + gTasks[taskId].data[0]++; + sub_80C2040(gTasks[taskId].data[0]); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + } +} + +void sub_80C16CC(u8 taskId) +{ + sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + sub_80C20F8(taskId); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + gTasks[taskId].func = sub_80C170C; +} + +void sub_80C170C(u8 taskId) +{ + const u8 (*r6)[4]; + + if (gTasks[taskId].data[0] != 0) + { + if (!IsNationalPokedexEnabled()) + r6 = gUnknown_0856EDF0; + else + r6 = gUnknown_0856EDB8; + } + else + { + if (!IsNationalPokedexEnabled()) + r6 = gUnknown_0856EDD4; + else + r6 = gUnknown_0856ED9C; + } + + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_BOWA); + sub_80C23B8(taskId); + gTasks[taskId].func = sub_80C1570; + return; + } + if (gMain.newKeys & A_BUTTON) + { + if (gTasks[taskId].data[1] == 6) + { + if (gTasks[taskId].data[0] != 0) + { + gUnknown_02039B52 = 0x40; + gUnknown_02039B4C->unk62A = 0x40; + gUnknown_02039B50 = 0; + gUnknown_02039B4C->unk610 = 0; + gSaveBlock2Ptr->pokedex.unknown1 = sub_80C2318(taskId, 5); + if (!IsNationalPokedexEnabled()) + gSaveBlock2Ptr->pokedex.unknown1 = 0; + gUnknown_02039B4C->unk614 = gSaveBlock2Ptr->pokedex.unknown1; + gSaveBlock2Ptr->pokedex.order = sub_80C2318(taskId, 4); + gUnknown_02039B4C->unk618 = gSaveBlock2Ptr->pokedex.order; + PlaySE(SE_PC_OFF); + gTasks[taskId].func = sub_80C1D38; + } + else + { + sub_80C2618(gText_SearchingPleaseWait); + gTasks[taskId].func = sub_80C19A4; + PlaySE(SE_Z_SEARCH); + CopyWindowToVram(0, 2); + } + } + else + { + PlaySE(SE_PIN); + gTasks[taskId].func = sub_80C1B64; + } + return; + } + + if ((gMain.newKeys & DPAD_LEFT) && r6[gTasks[taskId].data[1]][0] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][0]; + sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + } + if ((gMain.newKeys & DPAD_RIGHT) && r6[gTasks[taskId].data[1]][1] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][1]; + sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + } + if ((gMain.newKeys & DPAD_UP) && r6[gTasks[taskId].data[1]][2] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][2]; + sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + } + if ((gMain.newKeys & DPAD_DOWN) && r6[gTasks[taskId].data[1]][3] != 0xFF) + { + PlaySE(SE_SELECT); + gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][3]; + sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + } +} + +void sub_80C19A4(u8 taskId) +{ + u8 r10 = sub_80C2318(taskId, 5); + u8 r9 = sub_80C2318(taskId, 4); + u8 r8 = sub_80C2318(taskId, 0); + u8 r6 = sub_80C2318(taskId, 1); + u8 r4 = sub_80C2318(taskId, 2); + u8 r0 = sub_80C2318(taskId, 3); + + sub_80C0F30(r10, r9, r8, r6, r4, r0); + gTasks[taskId].func = sub_80C1A4C; +} + +void sub_80C1A4C(u8 taskId) +{ + if (!IsSEPlaying()) + { + if (gUnknown_02039B4C->pokemonListCount != 0) + { + PlaySE(SE_SEIKAI); + sub_80C2618(gText_SearchCompleted); + } + else + { + PlaySE(SE_HAZURE); + sub_80C2618(gUnknown_085E8785); + } + gTasks[taskId].func = sub_80C1AB8; + CopyWindowToVram(0, 2); + } +} + +void sub_80C1AB8(u8 taskId) +{ + if (gMain.newKeys & A_BUTTON) + { + if (gUnknown_02039B4C->pokemonListCount != 0) + { + gUnknown_02039B4C->unk64E = 1; + gUnknown_02039B4C->dexMode = sub_80C2318(taskId, 5); + gUnknown_02039B4C->dexOrder = sub_80C2318(taskId, 4); + gTasks[taskId].func = sub_80C1D38; + PlaySE(SE_PC_OFF); + } + else + { + gTasks[taskId].func = sub_80C16CC; + PlaySE(SE_BOWA); + } + } +} + +void sub_80C1B64(u8 taskId) +{ + u8 r0; + u16 *p1; + u16 *p2; + + sub_80C21D4(0); + r0 = gTasks[taskId].data[1]; + p1 = &gTasks[taskId].data[gUnknown_0856EFC8[r0].unk4]; + p2 = &gTasks[taskId].data[gUnknown_0856EFC8[r0].unk5]; + gTasks[taskId].data[14] = *p1; + gTasks[taskId].data[15] = *p2; + sub_80C2294(taskId); + sub_80C2650(*p1); + gTasks[taskId].func = sub_80C1BCC; + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); +} + +void sub_80C1BCC(u8 taskId) +{ + u8 r1; + const struct UnknownStruct2 *r8; + u16 *p1; + u16 *p2; + u16 r2; + bool8 r3; + + r1 = gTasks[taskId].data[1]; + r8 = gUnknown_0856EFC8[r1].unk0; + p1 = &gTasks[taskId].data[gUnknown_0856EFC8[r1].unk4]; + p2 = &gTasks[taskId].data[gUnknown_0856EFC8[r1].unk5]; + r2 = gUnknown_0856EFC8[r1].unk6 - 1; + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_PIN); + sub_80C267C(); + sub_80C21D4(1); + gTasks[taskId].func = sub_80C16CC; + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + return; + } + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_BOWA); + sub_80C267C(); + sub_80C21D4(1); + *p1 = gTasks[taskId].data[14]; + *p2 = gTasks[taskId].data[15]; + gTasks[taskId].func = sub_80C16CC; + CopyWindowToVram(0, 2); + CopyBgTilemapBufferToVram(3); + return; + } + r3 = FALSE; + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + if (*p1 != 0) + { + sub_80C2638(*p1); + (*p1)--; + sub_80C2650(*p1); + r3 = TRUE; + } + else if (*p2 != 0) + { + (*p2)--; + sub_80C2294(taskId); + sub_80C2650(*p1); + r3 = TRUE; + } + if (r3) + { + PlaySE(SE_SELECT); + sub_80C2618(r8[*p1 + *p2].text1); + CopyWindowToVram(0, 2); + } + return; + } + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (*p1 < 5 && *p1 < r2) + { + sub_80C2638(*p1); + (*p1)++; + sub_80C2650(*p1); + r3 = TRUE; + } + else if (r2 > 5 && *p2 < r2 - 5) + { + (*p2)++; + sub_80C2294(taskId); + sub_80C2650(5); + r3 = TRUE; + } + if (r3) + { + PlaySE(SE_SELECT); + sub_80C2618(r8[*p1 + *p2].text1); + CopyWindowToVram(0, 2); + } + return; + } +} + +void sub_80C1D38(u8 taskId) +{ + BeginNormalPaletteFade(-1, 0, 0, 16, RGB_BLACK); + gTasks[taskId].func = sub_80C1D70; +} + +void sub_80C1D70(u8 taskId) +{ + if (!gPaletteFade.active) + { + sub_80C152C(); + DestroyTask(taskId); + } +} + +#ifdef NONMATCHING +void sub_80C1D98(u8 a, u8 b, u8 c, u8 d) +{ + u16 i; + u16* ptr = GetBgTilemapBuffer(3); + + for (i = 0; i < d; i++) + { + ptr[b + i + (c << 6)] %= 0x1000; + ptr[b + i + (c << 6)] |= a * 4096; + + ptr[b + i + (c << 6) + 32] %= 0x1000; + ptr[b + i + (c << 6) + 32] |= a * 4096; + } +} +#else +__attribute__((naked)) +void sub_80C1D98(u8 a, u8 b, u8 c, u8 d) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + adds r4, r3, 0\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r8, r1\n\ + lsls r2, 24\n\ + lsrs r5, r2, 24\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + movs r0, 0x3\n\ + bl GetBgTilemapBuffer\n\ + adds r2, r0, 0\n\ + movs r3, 0\n\ + cmp r3, r4\n\ + bcs _080C1DEC\n\ + lsls r0, r5, 6\n\ + adds r7, r0, r2\n\ + ldr r5, =0x00000fff\n\ + lsls r2, r6, 12\n\ +_080C1DC8:\n\ + mov r0, r8\n\ + adds r1, r0, r3\n\ + lsls r1, 1\n\ + adds r1, r7\n\ + ldrh r0, [r1]\n\ + ands r0, r5\n\ + orrs r0, r2\n\ + strh r0, [r1]\n\ + adds r1, 0x40\n\ + ldrh r0, [r1]\n\ + ands r0, r5\n\ + orrs r0, r2\n\ + strh r0, [r1]\n\ + adds r0, r3, 0x1\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + cmp r3, r4\n\ + bcc _080C1DC8\n\ +_080C1DEC:\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void sub_80C1DFC(u8 a, u8 b, u8 c) +{ + u8 r5 = (b & 1) | ((c & 1) << 1); + + switch (a) + { + case 0: + case 1: + case 2: + sub_80C1D98(r5, gUnknown_0856ED30[a].unk4, gUnknown_0856ED30[a].unk5, gUnknown_0856ED30[a].unk6); + break; + case 3: + case 4: + case 7: + case 8: + sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk4, gUnknown_0856ED48[a - 3].unk5, gUnknown_0856ED48[a - 3].unk6); + // fall through + case 5: + case 6: + sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk7, gUnknown_0856ED48[a - 3].unk8, gUnknown_0856ED48[a - 3].unk9); + break; + case 10: + sub_80C1D98(r5, gUnknown_0856ED48[2].unk4, gUnknown_0856ED48[2].unk5, gUnknown_0856ED48[2].unk6); + break; + case 9: + if (!IsNationalPokedexEnabled()) + sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk4, gUnknown_0856ED48[a - 3].unk5 - 2, gUnknown_0856ED48[a - 3].unk6); + else + sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk4, gUnknown_0856ED48[a - 3].unk5, gUnknown_0856ED48[a - 3].unk6); + break; + } +} + +void sub_80C1EF4(u8 a) +{ + switch (a) + { + case 0: + sub_80C1DFC(0, 0, 0); + sub_80C1DFC(1, 1, 0); + sub_80C1DFC(2, 1, 0); + sub_80C1DFC(3, 1, 0); + sub_80C1DFC(4, 1, 0); + sub_80C1DFC(10, 1, 0); + sub_80C1DFC(5, 1, 0); + sub_80C1DFC(6, 1, 0); + sub_80C1DFC(7, 1, 0); + sub_80C1DFC(8, 1, 0); + sub_80C1DFC(9, 1, 0); + break; + case 1: + sub_80C1DFC(0, 1, 0); + sub_80C1DFC(1, 0, 0); + sub_80C1DFC(2, 1, 0); + sub_80C1DFC(3, 1, 1); + sub_80C1DFC(4, 1, 1); + sub_80C1DFC(10, 1, 1); + sub_80C1DFC(5, 1, 1); + sub_80C1DFC(6, 1, 1); + sub_80C1DFC(7, 1, 0); + sub_80C1DFC(8, 1, 0); + sub_80C1DFC(9, 1, 0); + break; + case 2: + sub_80C1DFC(0, 1, 0); + sub_80C1DFC(1, 1, 0); + sub_80C1DFC(2, 0, 0); + sub_80C1DFC(3, 1, 1); + sub_80C1DFC(4, 1, 1); + sub_80C1DFC(10, 1, 1); + sub_80C1DFC(5, 1, 1); + sub_80C1DFC(6, 1, 1); + sub_80C1DFC(7, 1, 1); + sub_80C1DFC(8, 1, 1); + sub_80C1DFC(9, 1, 1); + break; + } +} + +void sub_80C2040(u8 a) +{ + sub_80C1EF4(a); + sub_80C2618(gUnknown_0856ED30[a].text); +} + +void sub_80C2064(u8 a, u8 b) +{ + sub_80C1EF4(a); + switch (b) + { + case 0: + sub_80C1DFC(3, 0, 0); + break; + case 1: + sub_80C1DFC(4, 0, 0); + break; + case 2: + sub_80C1DFC(10, 0, 0); + sub_80C1DFC(5, 0, 0); + break; + case 3: + sub_80C1DFC(10, 0, 0); + sub_80C1DFC(6, 0, 0); + break; + case 4: + sub_80C1DFC(7, 0, 0); + break; + case 5: + sub_80C1DFC(8, 0, 0); + break; + case 6: + sub_80C1DFC(9, 0, 0); + break; + } + sub_80C2618(gUnknown_0856ED48[b].text); +} + +void sub_80C20F8(u8 taskId) +{ + u16 var; + + sub_80C12B0(0x28, 0x10, 0x60, 0x50); + + var = gTasks[taskId].data[6] + gTasks[taskId].data[7]; + sub_80C1270(gUnknown_0856EE5C[var].text2, 0x2D, 0x11); + + var = gTasks[taskId].data[8] + gTasks[taskId].data[9]; + sub_80C1270(gUnknown_0856EEB4[var].text2, 0x2D, 0x21); + + var = gTasks[taskId].data[10] + gTasks[taskId].data[11]; + sub_80C1270(gUnknown_0856EF14[var].text2, 0x2D, 0x31); + + var = gTasks[taskId].data[12] + gTasks[taskId].data[13]; + sub_80C1270(gUnknown_0856EF14[var].text2, 0x5D, 0x31); + + var = gTasks[taskId].data[4] + gTasks[taskId].data[5]; + sub_80C1270(gUnknown_0856EE24[var].text2, 0x2D, 0x41); + + if (IsNationalPokedexEnabled()) + { + var = gTasks[taskId].data[2] + gTasks[taskId].data[3]; + sub_80C1270(gUnknown_0856EE0C[var].text2, 0x2D, 0x51); + } +} + +void sub_80C21D4(u8 a) +{ + u16 i; + u16 j; + u16* ptr = GetBgTilemapBuffer(3); + + if (a == 0) + { + *(ptr + 0x11) = 0xC0B; + for (i = 0x12; i < 0x1F; i++) + *(ptr + i) = 0x80D; + for (j = 1; j < 13; j++) + { + *(ptr + 0x11 + j * 32) = 0x40A; + for (i = 0x12; i < 0x1F; i++) + *(ptr + j * 32 + i) = 2; + } + *(ptr + 0x1B1) = 0x40B; + for (i = 0x12; i < 0x1F; i++) + *(ptr + 0x1A0 + i) = 0xD; + } + else + { + for (j = 0; j < 14; j++) + { + for (i = 0x11; i < 0x1E; i++) + { + *(ptr + j * 32 + i) = 0x4F; + } + } + } +} + +void sub_80C2294(u8 taskId) +{ + const struct UnknownStruct2 *r6 = gUnknown_0856EFC8[gTasks[taskId].data[1]].unk0; + const u16 *r8 = &gTasks[taskId].data[gUnknown_0856EFC8[gTasks[taskId].data[1]].unk4]; + const u16 *r7 = &gTasks[taskId].data[gUnknown_0856EFC8[gTasks[taskId].data[1]].unk5]; + u16 i; + u16 j; + + sub_80C267C(); + for (i = 0, j = *r7; i < 6 && r6[j].text2 != NULL; i++, j++) + sub_80C2668(i, r6[j].text2); + sub_80C2618(r6[*r8 + *r7].text1); +} + +u8 sub_80C2318(u8 taskId, u8 b) +{ + const u16 *ptr1 = &gTasks[taskId].data[gUnknown_0856EFC8[b].unk4]; + const u16 *ptr2 = &gTasks[taskId].data[gUnknown_0856EFC8[b].unk5]; + u16 r2 = *ptr1 + *ptr2; + + switch (b) + { + default: + return 0; + case 5: + return gUnknown_0856EFAC[r2]; + case 4: + return gUnknown_0856EFAE[r2]; + case 0: + if (r2 == 0) + return 0xFF; + else + return r2; + case 1: + if (r2 == 0) + return 0xFF; + else + return r2 - 1; + case 2: + case 3: + return gUnknown_0856EFB4[r2]; + } +} + +void sub_80C23B8(u8 taskId) +{ + u16 r3; + + switch (gUnknown_02039B4C->unk614) + { + default: + case 0: + r3 = 0; + break; + case 1: + r3 = 1; + break; + } + gTasks[taskId].data[2] = r3; + + switch (gUnknown_02039B4C->unk618) + { + default: + case 0: + r3 = 0; + break; + case 1: + r3 = 1; + break; + case 2: + r3 = 2; + break; + case 3: + r3 = 3; + break; + case 4: + r3 = 4; + break; + case 5: + r3 = 5; + break; + } + gTasks[taskId].data[4] = r3; +} + +bool8 sub_80C244C(u8 taskId) +{ + u8 val1 = gTasks[taskId].data[1]; + const u16 *ptr = &gTasks[taskId].data[gUnknown_0856EFC8[val1].unk5]; + u16 val2 = gUnknown_0856EFC8[val1].unk6 - 1; + + if (val2 > 5 && *ptr != 0) + return FALSE; + else + return TRUE; +} + +bool8 sub_80C2494(u8 taskId) +{ + u8 val1 = gTasks[taskId].data[1]; + const u16 *ptr = &gTasks[taskId].data[gUnknown_0856EFC8[val1].unk5]; + u16 val2 = gUnknown_0856EFC8[val1].unk6 - 1; + + if (val2 > 5 && *ptr < val2 - 5) + return FALSE; + else + return TRUE; +} + +void sub_80C24E0(struct Sprite *sprite) +{ + if (gTasks[sprite->data[0]].func == sub_80C1BCC) + { + u8 val; + + if (sprite->data[1] != 0) + { + if (sub_80C2494(sprite->data[0])) + sprite->invisible = TRUE; + else + sprite->invisible = FALSE; + } + else + { + if (sub_80C244C(sprite->data[0])) + sprite->invisible = TRUE; + else + sprite->invisible = FALSE; + } + val = sprite->data[2] + sprite->data[1] * 128; + sprite->pos2.y = gSineTable[val] / 128; + sprite->data[2] += 8; + } + else + { + sprite->invisible = TRUE; + } +} + +void sub_80C2594(u8 taskId) +{ + u8 spriteId; + + spriteId = CreateSprite(&gUnknown_0855D1AC, 184, 4, 0); + gSprites[spriteId].data[0] = taskId; + gSprites[spriteId].data[1] = 0; + gSprites[spriteId].callback = sub_80C24E0; + + spriteId = CreateSprite(&gUnknown_0855D1AC, 184, 108, 0); + gSprites[spriteId].data[0] = taskId; + gSprites[spriteId].data[1] = 1; + gSprites[spriteId].vFlip = TRUE; + gSprites[spriteId].callback = sub_80C24E0; +} + +void sub_80C2618(const u8* str) +{ + sub_80C12B0(8, 0x78, 0xE0, 0x20); + sub_80C1270(str, 8, 0x79); +} + +void sub_80C2638(u32 a) +{ + sub_80C12B0(0x90, a * 16 + 8, 8, 16); +} + +void sub_80C2650(u32 a) +{ + sub_80C1270(gText_SelectorArrow, 0x90, a * 16 + 9); +} + +void sub_80C2668(u32 a, const u8* str) +{ + sub_80C1270(str, 0x98, a * 16 + 9); +} + +void sub_80C267C(void) +{ + sub_80C12B0(0x90, 8, 0x60, 0x60); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 9bf04d201..8befc0f3a 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -306,17 +306,7 @@ gFieldEffectArguments: @ 2038C08 .align 2 -gUnknown_02039B4C: @ 2039B4C - .space 0x4 - -gUnknown_02039B50: @ 2039B50 - .space 0x2 - -gUnknown_02039B52: @ 2039B52 - .space 0x2 - -gUnknown_02039B54: @ 2039B54 - .space 0x4 + .include "src/pokedex.o" gUnknown_02039B58: @ 2039B58 .space 0x14