From 0148e389738d857d473a54d612115cd51fbb8606 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 28 Nov 2018 10:14:32 -0600 Subject: [PATCH] Decompile pokedex_cry_screen.c (#406) --- asm/pokedex_cry_screen.s | 1010 ---------------------------------- data/pokedex_cry_screen.s | 110 ---- graphics/pokedex/85B8BF0.pal | 19 - graphics/pokedex/85B8C10.png | Bin 0 -> 135 bytes include/main.h | 2 +- include/pokedex_cry_screen.h | 2 +- ld_script.txt | 4 +- src/main.c | 2 +- src/pokedex.c | 6 +- src/pokedex_cry_screen.c | 511 +++++++++++++++++ sym_common.txt | 2 +- sym_ewram.txt | 10 +- 12 files changed, 521 insertions(+), 1157 deletions(-) delete mode 100644 asm/pokedex_cry_screen.s delete mode 100644 data/pokedex_cry_screen.s delete mode 100644 graphics/pokedex/85B8BF0.pal create mode 100755 graphics/pokedex/85B8C10.png create mode 100755 src/pokedex_cry_screen.c diff --git a/asm/pokedex_cry_screen.s b/asm/pokedex_cry_screen.s deleted file mode 100644 index 846b20881..000000000 --- a/asm/pokedex_cry_screen.s +++ /dev/null @@ -1,1010 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8145354 -sub_8145354: @ 8145354 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - lsls r1, 24 - lsrs r7, r1, 24 - movs r0, 0 - mov r8, r0 - ldr r0, =gUnknown_030061EC - ldrb r0, [r0] - cmp r0, 0x1 - beq _081453F8 - cmp r0, 0x1 - bgt _0814537C - cmp r0, 0 - beq _08145382 - b _0814544A - .pool -_0814537C: - cmp r0, 0x2 - beq _08145434 - b _0814544A -_08145382: - ldr r5, =gUnknown_0203AB90 - ldr r0, [r5] - cmp r0, 0 - bne _0814539E - movs r0, 0x1C - bl AllocZeroed - str r0, [r5] - ldr r4, =gUnknown_0203AB94 - adds r0, r7, 0 - movs r1, 0x7 - bl GetWindowAttribute - str r0, [r4] -_0814539E: - ldr r1, [r5] - ldrh r0, [r6] - movs r2, 0 - strh r0, [r1, 0x14] - ldrb r0, [r6, 0x5] - strb r0, [r1, 0x16] - ldr r0, [r5] - strb r2, [r0, 0x1A] - ldr r0, [r5] - strb r2, [r0, 0x1B] - ldr r0, [r5] - strb r2, [r0, 0x10] - ldr r1, [r5] - movs r0, 0x1C - strb r0, [r1, 0x12] - ldr r0, [r5] - strb r2, [r0, 0x11] - ldrb r1, [r6, 0x4] - lsls r1, 19 - negs r1, r1 - asrs r1, 16 - adds r0, r7, 0 - movs r2, 0x1 - bl sub_8145824 - movs r4, 0 -_081453D2: - adds r0, r7, 0 - ldr r1, =gUnknown_085B8C10 - movs r2, 0x20 - adds r3, r4, 0 - bl CopyToWindowPixelBuffer - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xDF - bls _081453D2 - b _08145420 - .pool -_081453F8: - movs r4, 0 - ldr r1, =gUnknown_0203AB90 - ldr r0, [r1] - ldrb r0, [r0, 0x16] - lsls r0, 3 - cmp r8, r0 - bge _08145420 - adds r5, r1, 0 -_08145408: - adds r0, r4, 0 - movs r1, 0 - bl sub_81456A8 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, [r5] - ldrb r0, [r0, 0x16] - lsls r0, 3 - cmp r4, r0 - blt _08145408 -_08145420: - ldr r1, =gUnknown_030061EC - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0814544A - .pool -_08145434: - adds r0, r7, 0 - bl sub_8145814 - ldr r0, =gUnknown_085B8BF0 - ldrb r1, [r6, 0x3] - lsls r1, 4 - movs r2, 0x20 - bl LoadPalette - movs r0, 0x1 - mov r8, r0 -_0814544A: - mov r0, r8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8145354 - - thumb_func_start sub_814545C -sub_814545C: @ 814545C - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl sub_8145814 - adds r0, r4, 0 - bl sub_8145648 - ldr r2, =gUnknown_0203AB90 - ldr r1, [r2] - ldrb r0, [r1, 0x1B] - cmp r0, 0 - beq _0814547E - subs r0, 0x1 - strb r0, [r1, 0x1B] -_0814547E: - ldr r1, [r2] - ldrb r0, [r1, 0x1A] - cmp r0, 0 - beq _081454A4 - subs r0, 0x1 - strb r0, [r1, 0x1A] - ldr r1, [r2] - ldrb r0, [r1, 0x1A] - cmp r0, 0 - bne _081454A4 - ldrh r0, [r1, 0x18] - bl sub_8145588 - bl sub_814560C - b _0814552A - .pool -_081454A4: - ldr r5, =gUnknown_0203AB90 - ldr r0, [r5] - ldrb r0, [r0, 0x10] - cmp r0, 0 - bne _081454B8 - bl sub_814560C - b _0814552A - .pool -_081454B8: - cmp r0, 0x1 - bne _081454C2 - bl sub_81455A8 - b _081454E6 -_081454C2: - cmp r0, 0x8 - bls _081454E6 - bl IsCryPlaying - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _081454DC - bl sub_814560C - ldr r0, [r5] - strb r4, [r0, 0x10] - b _0814552A -_081454DC: - bl sub_81455A8 - ldr r1, [r5] - movs r0, 0x1 - strb r0, [r1, 0x10] -_081454E6: - ldr r5, =gUnknown_0203AB90 - ldr r1, [r5] - ldrb r4, [r1, 0x10] - subs r4, 0x1 - lsls r4, 25 - lsrs r4, 24 - ldrb r0, [r1, 0x16] - lsls r0, 3 - ldrb r2, [r1, 0x11] - adds r0, r2 - subs r0, 0x2 - lsls r0, 24 - lsrs r0, 24 - adds r1, r4 - ldrb r1, [r1] - bl sub_81456A8 - ldr r1, [r5] - ldrb r0, [r1, 0x16] - lsls r0, 3 - ldrb r2, [r1, 0x11] - adds r0, r2 - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - adds r4, 0x1 - adds r1, r4 - ldrb r1, [r1] - bl sub_81456A8 - ldr r1, [r5] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] -_0814552A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_814545C - - thumb_func_start sub_8145534 -sub_8145534: @ 8145534 - push {r4-r6,lr} - lsls r0, 16 - lsrs r4, r0, 16 - adds r5, r4, 0 - ldr r0, =gMPlayInfo_BGM - ldr r0, [r0, 0x4] - cmp r0, 0 - bge _08145582 - ldr r6, =gUnknown_0203AB90 - ldr r1, [r6] - ldrb r0, [r1, 0x1A] - cmp r0, 0 - bne _08145582 - ldrb r0, [r1, 0x1B] - cmp r0, 0 - bne _08145582 - movs r0, 0x4 - strb r0, [r1, 0x1B] - bl IsCryPlaying - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0814557C - bl StopCry - ldr r1, [r6] - strh r4, [r1, 0x18] - movs r0, 0x2 - strb r0, [r1, 0x1A] - b _08145582 - .pool -_0814557C: - adds r0, r5, 0 - bl sub_8145588 -_08145582: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8145534 - - thumb_func_start sub_8145588 -sub_8145588: @ 8145588 - push {lr} - lsls r0, 16 - lsrs r0, 16 - movs r1, 0 - movs r2, 0x7D - movs r3, 0xA - bl PlayCry2 - ldr r0, =gUnknown_0203AB90 - ldr r1, [r0] - movs r0, 0x1 - strb r0, [r1, 0x10] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8145588 - - thumb_func_start sub_81455A8 -sub_81455A8: @ 81455A8 - push {r4,lr} - ldr r3, =gPcmDmaCounter - movs r0, 0 - ldrsb r0, [r3, r0] - cmp r0, 0x1 - bgt _081455C0 - ldr r0, =gSoundInfo + 0x350 - b _081455D8 - .pool -_081455C0: - ldr r2, =gSoundInfo - ldrb r1, [r2, 0xB] - movs r0, 0 - ldrsb r0, [r3, r0] - subs r0, 0x1 - subs r1, r0 - ldr r0, [r2, 0x10] - muls r0, r1 - movs r1, 0xD4 - lsls r1, 2 - adds r2, r1 - adds r0, r2 -_081455D8: - movs r1, 0xC6 - lsls r1, 3 - adds r3, r0, r1 - movs r2, 0 - ldr r4, =gUnknown_0203AB90 -_081455E2: - ldr r1, [r4] - adds r1, r2 - lsls r0, r2, 1 - adds r0, r3 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - lsls r0, 1 - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xF - bls _081455E2 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81455A8 - - thumb_func_start sub_814560C -sub_814560C: @ 814560C - push {r4,lr} - ldr r4, =gUnknown_0203AB90 - ldr r1, [r4] - ldrb r0, [r1, 0x16] - lsls r0, 3 - ldrb r1, [r1, 0x11] - adds r0, r1 - subs r0, 0x2 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl sub_81456A8 - ldr r1, [r4] - ldrb r0, [r1, 0x16] - lsls r0, 3 - ldrb r1, [r1, 0x11] - adds r0, r1 - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl sub_81456A8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_814560C - - thumb_func_start sub_8145648 -sub_8145648: @ 8145648 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r4, =gUnknown_0203AB90 - ldr r0, [r4] - ldrb r1, [r0, 0x11] - adds r0, r6, 0 - movs r2, 0 - bl sub_8145824 - ldr r1, [r4] - ldrb r0, [r1, 0x11] - adds r0, 0x2 - strb r0, [r1, 0x11] - ldr r1, [r4] - ldrb r0, [r1, 0x11] - lsrs r0, 3 - ldrb r1, [r1, 0x16] - adds r1, r0, r1 - adds r2, r1, 0x1 - adds r0, r2, 0 - asrs r0, 5 - lsls r0, 5 - subs r0, r2, r0 - lsls r0, 16 - lsrs r5, r0, 16 - movs r4, 0 -_0814567E: - lsls r3, r4, 5 - adds r3, r5, r3 - lsls r3, 16 - lsrs r3, 16 - adds r0, r6, 0 - ldr r1, =gUnknown_085B8C10 - movs r2, 0x20 - bl CopyToWindowPixelBuffer - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x6 - bls _0814567E - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8145648 - - thumb_func_start sub_81456A8 -sub_81456A8: @ 81456A8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - lsls r7, r0, 24 - lsrs r4, r7, 24 - lsls r1, 24 - movs r0, 0xFE - lsls r0, 23 - adds r1, r0 - lsrs r1, 16 - adds r0, r1, 0 - bl __floatsidf - ldr r3, _08145768 - ldr r2, _08145764 - bl __divdf3 - bl __fixunsdfsi - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x37 - bls _081456DE - movs r5, 0x37 -_081456DE: - str r5, [sp] - movs r6, 0x1 - ands r6, r4 - ldr r0, _0814576C - ldr r1, [r0] - lsrs r7, 27 - mov r8, r7 - ldr r0, _08145770 - ldrb r1, [r1, 0x12] - cmp r5, r1 - bls _08145780 - ldr r3, _08145774 - adds r0, r6, r0 - ldrb r0, [r0] - mov r9, r0 - movs r7, 0x7 - ands r7, r4 -_08145700: - lsls r1, r5, 1 - lsls r0, r7, 3 - adds r0, r7 - lsls r0, 4 - adds r1, r0 - ldr r2, _08145778 - adds r1, r2 - mov r4, r8 - lsls r0, r4, 5 - ldrh r1, [r1] - adds r0, r1 - lsls r0, 16 - lsrs r2, r0, 16 - ldr r1, [r3] - adds r1, r2 - ldrb r0, [r1] - mov r4, r9 - ands r0, r4 - strb r0, [r1] - ldr r4, [r3] - adds r4, r2 - adds r0, r5, 0 - movs r1, 0x3 - str r3, [sp, 0x4] - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 - subs r0, 0x1 - movs r1, 0xF - ands r0, r1 - lsls r1, r6, 4 - adds r0, r1 - ldr r1, _0814577C - adds r0, r1 - ldrb r1, [r4] - ldrb r0, [r0] - orrs r1, r0 - strb r1, [r4] - subs r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, _0814576C - ldr r0, [r2] - ldr r3, [sp, 0x4] - ldrb r0, [r0, 0x12] - cmp r5, r0 - bhi _08145700 - b _081457EA - .align 2, 0 -_08145764: .4byte 0x40920000 -_08145768: .4byte 0x00000000 -_0814576C: .4byte gUnknown_0203AB90 -_08145770: .4byte gUnknown_085B8C30 -_08145774: .4byte gUnknown_0203AB94 -_08145778: .4byte gUnknown_085B8770 -_0814577C: .4byte gUnknown_085B8C32 -_08145780: - lsls r3, r6, 4 - mov r10, r3 - ldr r7, _08145804 - adds r0, r6, r0 - ldrb r0, [r0] - mov r9, r0 - movs r6, 0x7 - ands r6, r4 -_08145790: - lsls r1, r5, 1 - lsls r0, r6, 3 - adds r0, r6 - lsls r0, 4 - adds r1, r0 - ldr r4, _08145808 - adds r1, r4 - mov r2, r8 - lsls r0, r2, 5 - ldrh r1, [r1] - adds r0, r1 - lsls r0, 16 - lsrs r2, r0, 16 - ldr r1, [r7] - adds r1, r2 - ldrb r0, [r1] - mov r3, r9 - ands r0, r3 - strb r0, [r1] - ldr r4, [r7] - adds r4, r2 - adds r0, r5, 0 - movs r1, 0x3 - bl __udivsi3 - lsls r0, 24 - lsrs r0, 24 - subs r0, 0x1 - movs r1, 0xF - ands r0, r1 - add r0, r10 - ldr r1, _0814580C - adds r0, r1 - ldrb r1, [r4] - ldrb r0, [r0] - orrs r1, r0 - strb r1, [r4] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, _08145810 - ldr r0, [r2] - ldrb r0, [r0, 0x12] - cmp r5, r0 - bcc _08145790 -_081457EA: - ldr r3, _08145810 - ldr r0, [r3] - mov r4, sp - ldrb r4, [r4] - strb r4, [r0, 0x12] - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08145804: .4byte gUnknown_0203AB94 -_08145808: .4byte gUnknown_085B8770 -_0814580C: .4byte gUnknown_085B8C32 -_08145810: .4byte gUnknown_0203AB90 - thumb_func_end sub_81456A8 - - thumb_func_start sub_8145814 -sub_8145814: @ 8145814 - push {lr} - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - bl CopyWindowToVram - pop {r0} - bx r0 - thumb_func_end sub_8145814 - - thumb_func_start sub_8145824 -sub_8145824: @ 8145824 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 24 - cmp r2, 0 - bne _08145848 - movs r1, 0 - bl GetWindowAttribute - lsls r0, 24 - lsrs r0, 24 - lsls r1, r4, 16 - asrs r1, 8 - movs r2, 0 - bl ChangeBgX -_08145848: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8145824 - - thumb_func_start sub_8145850 -sub_8145850: @ 8145850 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r0, 0 - lsls r1, 24 - lsrs r7, r1, 24 - movs r0, 0 - mov r8, r0 - ldr r6, =gUnknown_030061EC - ldrb r0, [r6] - cmp r0, 0 - beq _08145874 - cmp r0, 0x1 - beq _081458B0 - b _081458F8 - .pool -_08145874: - ldr r5, =gUnknown_0203AB98 - ldr r0, [r5] - cmp r0, 0 - bne _08145884 - movs r0, 0x8 - bl AllocZeroed - str r0, [r5] -_08145884: - ldr r1, =gUnknown_085B8438 - adds r0, r7, 0 - movs r2, 0 - movs r3, 0 - bl CopyToWindowPixelBuffer - ldr r0, =gUnknown_085B8418 - ldrb r1, [r4, 0x3] - lsls r1, 4 - movs r2, 0x20 - bl LoadPalette - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - b _081458F8 - .pool -_081458B0: - ldr r0, =gCryMeterNeedleSpriteSheets - bl LoadSpriteSheets - ldr r0, =gCryMeterNeedleSpritePalettes - bl LoadSpritePalettes - ldr r0, =gUnknown_085B8C68 - ldrb r1, [r4, 0x4] - lsls r1, 19 - movs r2, 0xA0 - lsls r2, 14 - adds r1, r2 - asrs r1, 16 - ldrb r2, [r4, 0x5] - lsls r2, 19 - movs r3, 0xE0 - lsls r3, 14 - adds r2, r3 - asrs r2, 16 - movs r3, 0x1 - bl CreateSprite - ldr r2, =gUnknown_0203AB98 - ldr r3, [r2] - lsls r0, 24 - lsrs r0, 24 - movs r4, 0 - strh r0, [r3, 0x4] - movs r1, 0x20 - strb r1, [r3] - ldr r0, [r2] - strb r1, [r0, 0x1] - ldr r0, [r2] - strb r4, [r0, 0x2] - movs r0, 0x1 - mov r8, r0 -_081458F8: - mov r0, r8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8145850 - - thumb_func_start sub_8145914 -sub_8145914: @ 8145914 - push {r4-r6,lr} - ldr r4, =gSprites - ldr r6, =gUnknown_0203AB98 - ldr r0, [r6] - ldrh r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x5] - lsrs r0, 4 - bl GetSpritePaletteTagByPaletteNum - lsls r0, 16 - lsrs r0, 16 - bl FreeSpritePaletteByTag - ldr r0, [r6] - ldrh r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - ldr r4, =gUnknown_0203AB90 - ldr r0, [r4] - bl Free - movs r5, 0 - str r5, [r4] - ldr r0, [r6] - bl Free - str r5, [r6] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8145914 - - thumb_func_start sub_814596C -sub_814596C: @ 814596C - push {r4-r7,lr} - sub sp, 0x14 - adds r7, r0, 0 - ldr r3, =gSprites - ldr r4, =gUnknown_0203AB98 - ldr r0, [r4] - ldrh r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrb r2, [r0, 0x1] - movs r1, 0x4 - negs r1, r1 - ands r1, r2 - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0, 0x1] - ldr r2, [r4] - ldrh r1, [r2, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - movs r1, 0 - strh r1, [r0, 0x6] - ldr r0, =gUnknown_0203AB90 - ldr r0, [r0] - ldrb r1, [r0, 0x10] - cmp r1, 0x2 - beq _081459E8 - cmp r1, 0x2 - bgt _081459C0 - cmp r1, 0 - beq _081459C6 - b _08145A2E - .pool -_081459C0: - cmp r1, 0x6 - beq _08145A20 - b _08145A2E -_081459C6: - movs r0, 0x20 - strb r0, [r2, 0x1] - ldr r1, [r4] - movs r0, 0 - ldrsb r0, [r1, r0] - cmp r0, 0 - ble _081459E2 - ldrb r0, [r1, 0x2] - add r4, sp, 0xC - cmp r0, 0x1 - beq _08145A30 - subs r0, 0x1 - strb r0, [r1, 0x2] - b _08145A30 -_081459E2: - movs r0, 0x5 - strb r0, [r1, 0x2] - b _08145A2E -_081459E8: - movs r3, 0 - movs r2, 0 - add r4, sp, 0xC - adds r5, r0, 0 -_081459F0: - lsls r1, r3, 24 - asrs r1, 24 - adds r0, r5, r2 - ldrb r0, [r0] - cmp r1, r0 - bge _081459FE - adds r3, r0, 0 -_081459FE: - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0xF - bls _081459F0 - lsls r0, r3, 24 - asrs r0, 24 - movs r1, 0xD0 - muls r0, r1 - cmp r0, 0 - bge _08145A16 - adds r0, 0xFF -_08145A16: - lsls r0, 16 - asrs r0, 24 - bl sub_8145B24 - b _08145A30 -_08145A20: - ldrb r1, [r0, 0xA] - movs r0, 0xD0 - muls r0, r1 - lsls r0, 16 - asrs r0, 24 - bl sub_8145B24 -_08145A2E: - add r4, sp, 0xC -_08145A30: - ldr r0, =gUnknown_0203AB98 - ldr r2, [r0] - ldrb r5, [r2] - movs r1, 0 - ldrsb r1, [r2, r1] - movs r3, 0x1 - ldrsb r3, [r2, r3] - adds r6, r0, 0 - cmp r1, r3 - beq _08145A82 - cmp r1, r3 - bge _08145A64 - ldrb r0, [r2, 0x2] - adds r0, r5, r0 - strb r0, [r2] - ldr r2, [r6] - movs r1, 0 - ldrsb r1, [r2, r1] - ldrb r3, [r2, 0x1] - movs r0, 0x1 - ldrsb r0, [r2, r0] - cmp r1, r0 - ble _08145A82 - b _08145A7A - .pool -_08145A64: - ldrb r0, [r2, 0x2] - subs r0, r5, r0 - strb r0, [r2] - ldr r2, [r6] - movs r1, 0 - ldrsb r1, [r2, r1] - ldrb r3, [r2, 0x1] - movs r0, 0x1 - ldrsb r0, [r2, r0] - cmp r1, r0 - bge _08145A82 -_08145A7A: - strb r3, [r2] - ldr r1, [r6] - movs r0, 0 - strb r0, [r1, 0x1] -_08145A82: - ldr r2, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r2 - movs r1, 0x80 - lsls r1, 1 - orrs r0, r1 - ldr r1, =0x0000ffff - ands r0, r1 - movs r1, 0x80 - lsls r1, 17 - orrs r0, r1 - str r0, [sp, 0x4] - ldr r0, [r6] - movs r1, 0 - ldrsb r1, [r0, r1] - lsls r1, 24 - lsrs r1, 16 - ldr r0, [sp, 0x8] - ands r0, r2 - orrs r0, r1 - str r0, [sp, 0x8] - add r0, sp, 0x4 - adds r1, r4, 0 - movs r2, 0x1 - movs r3, 0x2 - bl ObjAffineSet - add r0, sp, 0xC - ldrh r1, [r0] - ldrh r2, [r4, 0x2] - ldrh r3, [r4, 0x4] - ldrh r0, [r4, 0x6] - str r0, [sp] - movs r0, 0 - bl SetOamMatrix - ldr r2, =gSineTable - ldr r0, [r6] - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - adds r0, 0x7F - movs r1, 0xFF - ands r0, r1 - lsls r1, r0, 1 - adds r1, r2 - adds r0, 0x40 - lsls r0, 1 - adds r0, r2 - ldrh r2, [r0] - movs r0, 0 - ldrsh r1, [r1, r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - cmp r0, 0 - bge _08145AF6 - adds r0, 0xFF -_08145AF6: - asrs r0, 8 - strh r0, [r7, 0x24] - lsls r1, r2, 16 - asrs r1, 16 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - cmp r0, 0 - bge _08145B0A - adds r0, 0xFF -_08145B0A: - asrs r0, 8 - strh r0, [r7, 0x26] - add sp, 0x14 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_814596C - - thumb_func_start sub_8145B24 -sub_8145B24: @ 8145B24 - push {lr} - lsls r0, 24 - asrs r0, 24 - movs r1, 0x20 - subs r2, r1, r0 - movs r0, 0xFF - ands r2, r0 - adds r0, r2, 0 - subs r0, 0x21 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xBE - bhi _08145B40 - movs r2, 0xE0 -_08145B40: - ldr r1, =gUnknown_0203AB98 - ldr r0, [r1] - strb r2, [r0, 0x1] - ldr r1, [r1] - movs r0, 0x5 - strb r0, [r1, 0x2] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8145B24 - - .align 2, 0 @ Don't pad with nop. diff --git a/data/pokedex_cry_screen.s b/data/pokedex_cry_screen.s deleted file mode 100644 index 4b84c3ece..000000000 --- a/data/pokedex_cry_screen.s +++ /dev/null @@ -1,110 +0,0 @@ - - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -CryMeterNeedlePalette: @ 85B7B58 - .incbin "graphics/pokedex/cry_meter_needle.gbapal" - - .align 2 -CryMeterNeedleTiles: @ 85B7B78 - .incbin "graphics/pokedex/cry_meter_needle.4bpp" - - .align 1 -gUnknown_085B8378:: @ 85B8378 - .incbin "graphics/pokedex/cry_meter_map.bin" - - .align 1 -gUnknown_085B8418:: @ 85B8418 - .incbin "graphics/pokedex/cry_meter.gbapal" - - .align 2 -gUnknown_085B8438:: @ 85B8438 - .incbin "graphics/pokedex/cry_meter.4bpp.lz" - - .align 1 -gUnknown_085B8770:: @ 85B8770 - .2byte 0x0,0x4,0x8,0xC,0x10,0x14,0x18,0x1C,0x400,0x404,0x408,0x40C,0x410,0x414,0x418,0x41C,0x800,0x804,0x808,0x80C,0x810,0x814,0x818,0x81C,0xC00,0xC04,0xC08,0xC0C,0xC10,0xC14,0xC18,0xC1C,0x1000,0x1004,0x1008,0x100C,0x1010,0x1014,0x1018,0x101C,0x1400,0x1404,0x1408,0x140C,0x1410,0x1414,0x1418,0x141C,0x1800,0x1804,0x1808,0x180C,0x1810,0x1814,0x1818,0x181C,0x1C00,0x1C04,0x1C08,0x1C0C,0x1C10,0x1C14,0x1C18,0x1C1C,0x2000,0x2004,0x2008,0x200C,0x2010,0x2014,0x2018,0x201C - .2byte 0x0,0x4,0x8,0xC,0x10,0x14,0x18,0x1C,0x400,0x404,0x408,0x40C,0x410,0x414,0x418,0x41C,0x800,0x804,0x808,0x80C,0x810,0x814,0x818,0x81C,0xC00,0xC04,0xC08,0xC0C,0xC10,0xC14,0xC18,0xC1C,0x1000,0x1004,0x1008,0x100C,0x1010,0x1014,0x1018,0x101C,0x1400,0x1404,0x1408,0x140C,0x1410,0x1414,0x1418,0x141C,0x1800,0x1804,0x1808,0x180C,0x1810,0x1814,0x1818,0x181C,0x1C00,0x1C04,0x1C08,0x1C0C,0x1C10,0x1C14,0x1C18,0x1C1C,0x2000,0x2004,0x2008,0x200C,0x2010,0x2014,0x2018,0x201C - .2byte 0x1,0x5,0x9,0xD,0x11,0x15,0x19,0x1D,0x401,0x405,0x409,0x40D,0x411,0x415,0x419,0x41D,0x801,0x805,0x809,0x80D,0x811,0x815,0x819,0x81D,0xC01,0xC05,0xC09,0xC0D,0xC11,0xC15,0xC19,0xC1D,0x1001,0x1005,0x1009,0x100D,0x1011,0x1015,0x1019,0x101D,0x1401,0x1405,0x1409,0x140D,0x1411,0x1415,0x1419,0x141D,0x1801,0x1805,0x1809,0x180D,0x1811,0x1815,0x1819,0x181D,0x1C01,0x1C05,0x1C09,0x1C0D,0x1C11,0x1C15,0x1C19,0x1C1D,0x2001,0x2005,0x2009,0x200D,0x2011,0x2015,0x2019,0x201D - .2byte 0x1,0x5,0x9,0xD,0x11,0x15,0x19,0x1D,0x401,0x405,0x409,0x40D,0x411,0x415,0x419,0x41D,0x801,0x805,0x809,0x80D,0x811,0x815,0x819,0x81D,0xC01,0xC05,0xC09,0xC0D,0xC11,0xC15,0xC19,0xC1D,0x1001,0x1005,0x1009,0x100D,0x1011,0x1015,0x1019,0x101D,0x1401,0x1405,0x1409,0x140D,0x1411,0x1415,0x1419,0x141D,0x1801,0x1805,0x1809,0x180D,0x1811,0x1815,0x1819,0x181D,0x1C01,0x1C05,0x1C09,0x1C0D,0x1C11,0x1C15,0x1C19,0x1C1D,0x2001,0x2005,0x2009,0x200D,0x2011,0x2015,0x2019,0x201D - .2byte 0x2,0x6,0xA,0xE,0x12,0x16,0x1A,0x1E,0x402,0x406,0x40A,0x40E,0x412,0x416,0x41A,0x41E,0x802,0x806,0x80A,0x80E,0x812,0x816,0x81A,0x81E,0xC02,0xC06,0xC0A,0xC0E,0xC12,0xC16,0xC1A,0xC1E,0x1002,0x1006,0x100A,0x100E,0x1012,0x1016,0x101A,0x101E,0x1402,0x1406,0x140A,0x140E,0x1412,0x1416,0x141A,0x141E,0x1802,0x1806,0x180A,0x180E,0x1812,0x1816,0x181A,0x181E,0x1C02,0x1C06,0x1C0A,0x1C0E,0x1C12,0x1C16,0x1C1A,0x1C1E,0x2002,0x2006,0x200A,0x200E,0x2012,0x2016,0x201A,0x201E - .2byte 0x2,0x6,0xA,0xE,0x12,0x16,0x1A,0x1E,0x402,0x406,0x40A,0x40E,0x412,0x416,0x41A,0x41E,0x802,0x806,0x80A,0x80E,0x812,0x816,0x81A,0x81E,0xC02,0xC06,0xC0A,0xC0E,0xC12,0xC16,0xC1A,0xC1E,0x1002,0x1006,0x100A,0x100E,0x1012,0x1016,0x101A,0x101E,0x1402,0x1406,0x140A,0x140E,0x1412,0x1416,0x141A,0x141E,0x1802,0x1806,0x180A,0x180E,0x1812,0x1816,0x181A,0x181E,0x1C02,0x1C06,0x1C0A,0x1C0E,0x1C12,0x1C16,0x1C1A,0x1C1E,0x2002,0x2006,0x200A,0x200E,0x2012,0x2016,0x201A,0x201E - .2byte 0x3,0x7,0xB,0xF,0x13,0x17,0x1B,0x1F,0x403,0x407,0x40B,0x40F,0x413,0x417,0x41B,0x41F,0x803,0x807,0x80B,0x80F,0x813,0x817,0x81B,0x81F,0xC03,0xC07,0xC0B,0xC0F,0xC13,0xC17,0xC1B,0xC1F,0x1003,0x1007,0x100B,0x100F,0x1013,0x1017,0x101B,0x101F,0x1403,0x1407,0x140B,0x140F,0x1413,0x1417,0x141B,0x141F,0x1803,0x1807,0x180B,0x180F,0x1813,0x1817,0x181B,0x181F,0x1C03,0x1C07,0x1C0B,0x1C0F,0x1C13,0x1C17,0x1C1B,0x1C1F,0x2003,0x2007,0x200B,0x200F,0x2013,0x2017,0x201B,0x201F - .2byte 0x3,0x7,0xB,0xF,0x13,0x17,0x1B,0x1F,0x403,0x407,0x40B,0x40F,0x413,0x417,0x41B,0x41F,0x803,0x807,0x80B,0x80F,0x813,0x817,0x81B,0x81F,0xC03,0xC07,0xC0B,0xC0F,0xC13,0xC17,0xC1B,0xC1F,0x1003,0x1007,0x100B,0x100F,0x1013,0x1017,0x101B,0x101F,0x1403,0x1407,0x140B,0x140F,0x1413,0x1417,0x141B,0x141F,0x1803,0x1807,0x180B,0x180F,0x1813,0x1817,0x181B,0x181F,0x1C03,0x1C07,0x1C0B,0x1C0F,0x1C13,0x1C17,0x1C1B,0x1C1F,0x2003,0x2007,0x200B,0x200F,0x2013,0x2017,0x201B,0x201F - - .align 1 -gUnknown_085B8BF0:: @ 85B8BF0 - .incbin "graphics/pokedex/85B8BF0.gbapal" - -gUnknown_085B8C10:: @ 85B8C10 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x22 - .byte 0x22 - .byte 0x22 - .byte 0x22 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x22 - .byte 0x22 - .byte 0x22 - .byte 0x22 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x22 - .byte 0x22 - .byte 0x22 - .byte 0x22 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x11 - .byte 0x22 - .byte 0x22 - .byte 0x22 - .byte 0x22 - -gUnknown_085B8C30:: @ 85B8C30 - .byte 0xF0, 0x0F - -gUnknown_085B8C32:: @ 85B8C32 - .byte 0x0F,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,0x08,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F - .byte 0xF0,0xE0,0xD0,0xC0,0xB0,0xA0,0x90,0x80,0x80,0x90,0xA0,0xB0,0xC0,0xD0,0xE0,0xF0 - - .align 2 -gSpriteAnim_85B8C54:: @ 85B8C54 - obj_image_anim_frame 0, 30 - obj_image_anim_end - - .align 2 -gSpriteAnimTable_85B8C5C:: @ 85B8C5C - .4byte gSpriteAnim_85B8C54 - - .align 2 -gOamData_85B8C60:: @ 85B8C60 - .2byte 0x01A0 - .2byte 0xC000 - .2byte 0x0400 - - .align 2 -gUnknown_085B8C68:: @ 85B8C68 - spr_template 8192, 8192, gOamData_85B8C60, gSpriteAnimTable_85B8C5C, NULL, gDummySpriteAffineAnimTable, sub_814596C - - .align 2 -gCryMeterNeedleSpriteSheets:: @ 85B8C80 - obj_tiles CryMeterNeedleTiles, 0x800, 8192 - null_obj_tiles - - .align 2 -gCryMeterNeedleSpritePalettes:: @ 85B8C90 - obj_pal CryMeterNeedlePalette, 8192 - null_obj_pal diff --git a/graphics/pokedex/85B8BF0.pal b/graphics/pokedex/85B8BF0.pal deleted file mode 100644 index 969c38cbd..000000000 --- a/graphics/pokedex/85B8BF0.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 0 0 -0 0 148 -0 131 131 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -148 148 255 -156 156 255 -172 172 255 -189 189 255 -205 205 255 -222 222 255 -238 238 255 -255 255 255 diff --git a/graphics/pokedex/85B8C10.png b/graphics/pokedex/85B8C10.png new file mode 100755 index 0000000000000000000000000000000000000000..ef52a4138391ea65975c06f4ae92f20df7809d1a GIT binary patch literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^93afX3?$7I7w-U41_3@Hu0WcBVG2WYGnj!OrcC)i zXU_jMYyR)u`~U3O|M%|wfA{V`5HRgo`3k5?$kW9!gkxs101FeFszSnn(@YGu4$OuJ SWnN2x%dexNum, 48, 56, 0); gSprites[gTasks[taskId].data[4]].oam.priority = 0; - gUnknown_030061EC = 0; + gDexCryScreenState = 0; gMain.state++; break; case 6: @@ -3247,7 +3247,7 @@ void sub_80BF250(u8 taskId) if (sub_8145354(&sp4, 2) != 0) { gMain.state++; - gUnknown_030061EC = 0; + gDexCryScreenState = 0; } } break; diff --git a/src/pokedex_cry_screen.c b/src/pokedex_cry_screen.c new file mode 100755 index 000000000..f3eeeed07 --- /dev/null +++ b/src/pokedex_cry_screen.c @@ -0,0 +1,511 @@ +#include "global.h" +#include "bg.h" +#include "m4a.h" +#include "main.h" +#include "malloc.h" +#include "palette.h" +#include "pokedex_cry_screen.h" +#include "sound.h" +#include "trig.h" +#include "window.h" + +struct PokedexCryVolumeMeter { + s8 unk0; + s8 unk1; + u8 unk2; + u16 needleSpriteId; +}; + +struct PokedexCryScreen +{ + u8 unk0[16]; + u8 unk10; + u8 unk11; + u8 unk12; + u16 unk14; + u8 unk16; + u16 species; + u8 unk1A; + u8 unk1B; +}; + +static void sub_8145588(u16); +static void sub_81455A8(void); +static void sub_814560C(void); +static void sub_8145648(u8); +static void sub_81456A8(u8, u8); +static void sub_8145814(u8); +static void sub_8145824(u8, s16, u8); +static void sub_814596C(struct Sprite *); +static void sub_8145B24(s8); + +extern u8 gDexCryScreenState; +static EWRAM_DATA struct PokedexCryScreen *sDexCryScreen = NULL; +static EWRAM_DATA u8 *sCryWaveformWindowTiledata = NULL; +static EWRAM_DATA struct PokedexCryVolumeMeter *sCryVolumeMeter = NULL; + +const u16 CryMeterNeedlePalette[] = INCBIN_U16("graphics/pokedex/cry_meter_needle.gbapal"); +const u8 CryMeterNeedleTiles[] = INCBIN_U8("graphics/pokedex/cry_meter_needle.4bpp"); + +const u16 gUnknown_085B8378[] = INCBIN_U16("graphics/pokedex/cry_meter_map.bin"); +const u16 gUnknown_085B8418[] = INCBIN_U16("graphics/pokedex/cry_meter.gbapal"); +const u8 gUnknown_085B8438[] = INCBIN_U8("graphics/pokedex/cry_meter.4bpp.lz"); + +const u16 gUnknown_085B8770[][72] = { + { + 0x0000, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C, + 0x0400, 0x0404, 0x0408, 0x040C, 0x0410, 0x0414, 0x0418, 0x041C, + 0x0800, 0x0804, 0x0808, 0x080C, 0x0810, 0x0814, 0x0818, 0x081C, + 0x0C00, 0x0C04, 0x0C08, 0x0C0C, 0x0C10, 0x0C14, 0x0C18, 0x0C1C, + 0x1000, 0x1004, 0x1008, 0x100C, 0x1010, 0x1014, 0x1018, 0x101C, + 0x1400, 0x1404, 0x1408, 0x140C, 0x1410, 0x1414, 0x1418, 0x141C, + 0x1800, 0x1804, 0x1808, 0x180C, 0x1810, 0x1814, 0x1818, 0x181C, + 0x1C00, 0x1C04, 0x1C08, 0x1C0C, 0x1C10, 0x1C14, 0x1C18, 0x1C1C, + 0x2000, 0x2004, 0x2008, 0x200C, 0x2010, 0x2014, 0x2018, 0x201C + }, { + 0x0000, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C, + 0x0400, 0x0404, 0x0408, 0x040C, 0x0410, 0x0414, 0x0418, 0x041C, + 0x0800, 0x0804, 0x0808, 0x080C, 0x0810, 0x0814, 0x0818, 0x081C, + 0x0C00, 0x0C04, 0x0C08, 0x0C0C, 0x0C10, 0x0C14, 0x0C18, 0x0C1C, + 0x1000, 0x1004, 0x1008, 0x100C, 0x1010, 0x1014, 0x1018, 0x101C, + 0x1400, 0x1404, 0x1408, 0x140C, 0x1410, 0x1414, 0x1418, 0x141C, + 0x1800, 0x1804, 0x1808, 0x180C, 0x1810, 0x1814, 0x1818, 0x181C, + 0x1C00, 0x1C04, 0x1C08, 0x1C0C, 0x1C10, 0x1C14, 0x1C18, 0x1C1C, + 0x2000, 0x2004, 0x2008, 0x200C, 0x2010, 0x2014, 0x2018, 0x201C + }, { + 0x0001, 0x0005, 0x0009, 0x000D, 0x0011, 0x0015, 0x0019, 0x001D, + 0x0401, 0x0405, 0x0409, 0x040D, 0x0411, 0x0415, 0x0419, 0x041D, + 0x0801, 0x0805, 0x0809, 0x080D, 0x0811, 0x0815, 0x0819, 0x081D, + 0x0C01, 0x0C05, 0x0C09, 0x0C0D, 0x0C11, 0x0C15, 0x0C19, 0x0C1D, + 0x1001, 0x1005, 0x1009, 0x100D, 0x1011, 0x1015, 0x1019, 0x101D, + 0x1401, 0x1405, 0x1409, 0x140D, 0x1411, 0x1415, 0x1419, 0x141D, + 0x1801, 0x1805, 0x1809, 0x180D, 0x1811, 0x1815, 0x1819, 0x181D, + 0x1C01, 0x1C05, 0x1C09, 0x1C0D, 0x1C11, 0x1C15, 0x1C19, 0x1C1D, + 0x2001, 0x2005, 0x2009, 0x200D, 0x2011, 0x2015, 0x2019, 0x201D + }, { + 0x0001, 0x0005, 0x0009, 0x000D, 0x0011, 0x0015, 0x0019, 0x001D, + 0x0401, 0x0405, 0x0409, 0x040D, 0x0411, 0x0415, 0x0419, 0x041D, + 0x0801, 0x0805, 0x0809, 0x080D, 0x0811, 0x0815, 0x0819, 0x081D, + 0x0C01, 0x0C05, 0x0C09, 0x0C0D, 0x0C11, 0x0C15, 0x0C19, 0x0C1D, + 0x1001, 0x1005, 0x1009, 0x100D, 0x1011, 0x1015, 0x1019, 0x101D, + 0x1401, 0x1405, 0x1409, 0x140D, 0x1411, 0x1415, 0x1419, 0x141D, + 0x1801, 0x1805, 0x1809, 0x180D, 0x1811, 0x1815, 0x1819, 0x181D, + 0x1C01, 0x1C05, 0x1C09, 0x1C0D, 0x1C11, 0x1C15, 0x1C19, 0x1C1D, + 0x2001, 0x2005, 0x2009, 0x200D, 0x2011, 0x2015, 0x2019, 0x201D + }, { + 0x0002, 0x0006, 0x000A, 0x000E, 0x0012, 0x0016, 0x001A, 0x001E, + 0x0402, 0x0406, 0x040A, 0x040E, 0x0412, 0x0416, 0x041A, 0x041E, + 0x0802, 0x0806, 0x080A, 0x080E, 0x0812, 0x0816, 0x081A, 0x081E, + 0x0C02, 0x0C06, 0x0C0A, 0x0C0E, 0x0C12, 0x0C16, 0x0C1A, 0x0C1E, + 0x1002, 0x1006, 0x100A, 0x100E, 0x1012, 0x1016, 0x101A, 0x101E, + 0x1402, 0x1406, 0x140A, 0x140E, 0x1412, 0x1416, 0x141A, 0x141E, + 0x1802, 0x1806, 0x180A, 0x180E, 0x1812, 0x1816, 0x181A, 0x181E, + 0x1C02, 0x1C06, 0x1C0A, 0x1C0E, 0x1C12, 0x1C16, 0x1C1A, 0x1C1E, + 0x2002, 0x2006, 0x200A, 0x200E, 0x2012, 0x2016, 0x201A, 0x201E + }, { + 0x0002, 0x0006, 0x000A, 0x000E, 0x0012, 0x0016, 0x001A, 0x001E, + 0x0402, 0x0406, 0x040A, 0x040E, 0x0412, 0x0416, 0x041A, 0x041E, + 0x0802, 0x0806, 0x080A, 0x080E, 0x0812, 0x0816, 0x081A, 0x081E, + 0x0C02, 0x0C06, 0x0C0A, 0x0C0E, 0x0C12, 0x0C16, 0x0C1A, 0x0C1E, + 0x1002, 0x1006, 0x100A, 0x100E, 0x1012, 0x1016, 0x101A, 0x101E, + 0x1402, 0x1406, 0x140A, 0x140E, 0x1412, 0x1416, 0x141A, 0x141E, + 0x1802, 0x1806, 0x180A, 0x180E, 0x1812, 0x1816, 0x181A, 0x181E, + 0x1C02, 0x1C06, 0x1C0A, 0x1C0E, 0x1C12, 0x1C16, 0x1C1A, 0x1C1E, + 0x2002, 0x2006, 0x200A, 0x200E, 0x2012, 0x2016, 0x201A, 0x201E + }, { + 0x0003, 0x0007, 0x000B, 0x000F, 0x0013, 0x0017, 0x001B, 0x001F, + 0x0403, 0x0407, 0x040B, 0x040F, 0x0413, 0x0417, 0x041B, 0x041F, + 0x0803, 0x0807, 0x080B, 0x080F, 0x0813, 0x0817, 0x081B, 0x081F, + 0x0C03, 0x0C07, 0x0C0B, 0x0C0F, 0x0C13, 0x0C17, 0x0C1B, 0x0C1F, + 0x1003, 0x1007, 0x100B, 0x100F, 0x1013, 0x1017, 0x101B, 0x101F, + 0x1403, 0x1407, 0x140B, 0x140F, 0x1413, 0x1417, 0x141B, 0x141F, + 0x1803, 0x1807, 0x180B, 0x180F, 0x1813, 0x1817, 0x181B, 0x181F, + 0x1C03, 0x1C07, 0x1C0B, 0x1C0F, 0x1C13, 0x1C17, 0x1C1B, 0x1C1F, + 0x2003, 0x2007, 0x200B, 0x200F, 0x2013, 0x2017, 0x201B, 0x201F + }, { + 0x0003, 0x0007, 0x000B, 0x000F, 0x0013, 0x0017, 0x001B, 0x001F, + 0x0403, 0x0407, 0x040B, 0x040F, 0x0413, 0x0417, 0x041B, 0x041F, + 0x0803, 0x0807, 0x080B, 0x080F, 0x0813, 0x0817, 0x081B, 0x081F, + 0x0C03, 0x0C07, 0x0C0B, 0x0C0F, 0x0C13, 0x0C17, 0x0C1B, 0x0C1F, + 0x1003, 0x1007, 0x100B, 0x100F, 0x1013, 0x1017, 0x101B, 0x101F, + 0x1403, 0x1407, 0x140B, 0x140F, 0x1413, 0x1417, 0x141B, 0x141F, + 0x1803, 0x1807, 0x180B, 0x180F, 0x1813, 0x1817, 0x181B, 0x181F, + 0x1C03, 0x1C07, 0x1C0B, 0x1C0F, 0x1C13, 0x1C17, 0x1C1B, 0x1C1F, + 0x2003, 0x2007, 0x200B, 0x200F, 0x2013, 0x2017, 0x201B, 0x201F + } +}; + +const u16 gUnknown_085B8BF0[] = INCBIN_U16("graphics/pokedex/85B8C10.gbapal"); +const u8 gUnknown_085B8C10[] = INCBIN_U8("graphics/pokedex/85B8C10.4bpp"); + +const u8 gUnknown_085B8C30[] = {0xF0, 0x0F}; +const u8 gUnknown_085B8C32[][16] = { + { + 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F + }, { + 0xF0, 0xE0, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80, + 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0 + } +}; + +const union AnimCmd gSpriteAnim_85B8C54[] = { + ANIMCMD_FRAME(0, 30), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_85B8C5C[] = { + gSpriteAnim_85B8C54 +}; + +const struct OamData gOamData_85B8C60 = { + .y = 160, + .affineMode = ST_OAM_AFFINE_NORMAL, + .size = 3, + .priority = 1 +}; + +const struct SpriteTemplate gUnknown_085B8C68 = { + 0x2000, + 0x2000, + &gOamData_85B8C60, + gSpriteAnimTable_85B8C5C, + NULL, + gDummySpriteAffineAnimTable, + sub_814596C +}; + +const struct SpriteSheet gCryMeterNeedleSpriteSheets[] = { + {CryMeterNeedleTiles, 0x800, 0x2000}, + {} +}; + +const struct SpritePalette gCryMeterNeedleSpritePalettes[] = { + {CryMeterNeedlePalette, 0x2000}, + {} +}; + +bool8 sub_8145354(struct CryRelatedStruct *arg0, u8 windowId) +{ + u8 i; + u8 retVal = FALSE; + + switch (gDexCryScreenState) + { + case 0: + if (!sDexCryScreen) + { + sDexCryScreen = AllocZeroed(sizeof(*sDexCryScreen)); + sCryWaveformWindowTiledata = (u8*)GetWindowAttribute(windowId, WINDOW_TILE_DATA); + } + + sDexCryScreen->unk14 = arg0->unk0; + sDexCryScreen->unk16 = arg0->yPos; + sDexCryScreen->unk1A = 0; + sDexCryScreen->unk1B = 0; + sDexCryScreen->unk10 = 0; + sDexCryScreen->unk12 = 28; + sDexCryScreen->unk11 = 0; + sub_8145824(windowId, -8 * arg0->xPos, 1); + for (i = 0; i < 224; i++) + CopyToWindowPixelBuffer(windowId, gUnknown_085B8C10, TILE_SIZE_4BPP, i); + + gDexCryScreenState++; + break; + case 1: + for (i = 0; i < sDexCryScreen->unk16 * 8; i++) + sub_81456A8(i, 0); + + gDexCryScreenState++; + break; + case 2: + sub_8145814(windowId); + LoadPalette(gUnknown_085B8BF0, arg0->paletteNo * 16, 32); + retVal = TRUE; + break; + } + + return retVal; +} + +void sub_814545C(u8 windowId) +{ + u8 var0; + + sub_8145814(windowId); + sub_8145648(windowId); + if (sDexCryScreen->unk1B) + sDexCryScreen->unk1B--; + + if (sDexCryScreen->unk1A) + { + sDexCryScreen->unk1A--; + if (!sDexCryScreen->unk1A) + { + sub_8145588(sDexCryScreen->species); + sub_814560C(); + return; + } + } + + if (sDexCryScreen->unk10 == 0) + { + sub_814560C(); + return; + } + + if (sDexCryScreen->unk10 == 1) + { + sub_81455A8(); + } + else if (sDexCryScreen->unk10 > 8) + { + if (!IsCryPlaying()) + { + sub_814560C(); + sDexCryScreen->unk10 = 0; + return; + } + + sub_81455A8(); + sDexCryScreen->unk10 = 1; + } + + var0 = 2 * (sDexCryScreen->unk10 - 1); + sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, sDexCryScreen->unk0[var0]); + sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, sDexCryScreen->unk0[var0 + 1]); + sDexCryScreen->unk10++; +} + +void sub_8145534(u16 species) +{ + if (gMPlayInfo_BGM.status & MUSICPLAYER_STATUS_PAUSE && !sDexCryScreen->unk1A) + { + if (!sDexCryScreen->unk1B) + { + sDexCryScreen->unk1B = 4; + if (IsCryPlaying() == TRUE) + { + StopCry(); + sDexCryScreen->species = species; + sDexCryScreen->unk1A = 2; + } + else + { + sub_8145588(species); + } + } + } +} + +static void sub_8145588(u16 species) +{ + PlayCry2(species, 0, 0x7d, 10); + sDexCryScreen->unk10 = 1; +} + +static void sub_81455A8(void) +{ + u8 i; + s8 *baseBuffer; + s8 *buffer; + + if (gPcmDmaCounter < 2) + baseBuffer = gSoundInfo.pcmBuffer; + else + baseBuffer = gSoundInfo.pcmBuffer + (gSoundInfo.pcmDmaPeriod + 1 - gPcmDmaCounter) * gSoundInfo.pcmSamplesPerVBlank; + + buffer = baseBuffer + 0x630; + for (i = 0; i < 16; i++) + sDexCryScreen->unk0[i] = buffer[i * 2] * 2; +} + +static void sub_814560C(void) +{ + sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, 0); + sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, 0); +} + +static void sub_8145648(u8 windowId) +{ + u8 i; + u16 offset; + + sub_8145824(windowId, sDexCryScreen->unk11, 0); + sDexCryScreen->unk11 += 2; + offset = (sDexCryScreen->unk11 / 8 + sDexCryScreen->unk16 + 1) % 32; + for (i = 0; i < 7; i++) + CopyToWindowPixelBuffer(windowId, gUnknown_085B8C10, TILE_SIZE_4BPP, offset + (i * TILE_SIZE_4BPP)); +} + +static void sub_81456A8(u8 a0, u8 a1) +{ + u8 sp0; + u8 r6; + u8 r8; + u16 offset; + u16 r1; + u8 i; + + r1 = (a1 + 127) * 256; + i = r1 / 1152.0; + if (i > 55) + i = 55; + sp0 = i; + r6 = a0 & 1; + if (i > sDexCryScreen->unk12) + { + do + { + offset = gUnknown_085B8770[a0 & 0x7][i] + (a0 / 8) * TILE_SIZE_4BPP; + sCryWaveformWindowTiledata[offset] &= gUnknown_085B8C30[r6]; + sCryWaveformWindowTiledata[offset] |= gUnknown_085B8C32[r6][((i / 3) - 1) & 0x0F]; + i--; + } while (i > sDexCryScreen->unk12); + } + else + { + do + { + offset = gUnknown_085B8770[a0 & 0x7][i] + (a0 / 8) * TILE_SIZE_4BPP; + sCryWaveformWindowTiledata[offset] &= gUnknown_085B8C30[r6]; + sCryWaveformWindowTiledata[offset] |= gUnknown_085B8C32[r6][((i / 3) - 1) & 0x0F]; + i++; + } while (i < sDexCryScreen->unk12); + } + + sDexCryScreen->unk12 = sp0; +} + +static void sub_8145814(u8 windowId) +{ + CopyWindowToVram(windowId, 2); +} + +static void sub_8145824(u8 windowId, s16 arg1, u8 arg2) +{ + if (!arg2) + { + u8 bg = GetWindowAttribute(windowId, WINDOW_BG); + ChangeBgX(bg, arg1 << 8, 0); + } +} + +bool8 sub_8145850(struct CryRelatedStruct *arg0, u8 windowId) +{ + int retVal = FALSE; + + switch (gDexCryScreenState) + { + case 0: + if (!sCryVolumeMeter) + sCryVolumeMeter = AllocZeroed(sizeof(*sCryVolumeMeter)); + + CopyToWindowPixelBuffer(windowId, gUnknown_085B8438, 0, 0); + LoadPalette(gUnknown_085B8418, arg0->paletteNo * 16, 32); + gDexCryScreenState++; + break; + case 1: + LoadSpriteSheets(gCryMeterNeedleSpriteSheets); + LoadSpritePalettes(gCryMeterNeedleSpritePalettes); + sCryVolumeMeter->needleSpriteId = CreateSprite(&gUnknown_085B8C68, 40 + arg0->xPos * 8, 56 + arg0->yPos * 8, 1); + sCryVolumeMeter->unk0 = 0x20; + sCryVolumeMeter->unk1 = 0x20; + sCryVolumeMeter->unk2 = 0; + retVal = TRUE; + break; + } + + return retVal; +} + +void sub_8145914(void) +{ + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[sCryVolumeMeter->needleSpriteId].oam.paletteNum)); + DestroySprite(gSprites + sCryVolumeMeter->needleSpriteId); + FREE_AND_SET_NULL(sDexCryScreen); + FREE_AND_SET_NULL(sCryVolumeMeter); +} + +static void sub_814596C(struct Sprite *sprite) +{ + u16 i; + s8 r3; + s16 x; + s16 y; + struct ObjAffineSrcData affine; + struct OamMatrix matrix; + u8 *var0; + + gSprites[sCryVolumeMeter->needleSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[sCryVolumeMeter->needleSpriteId].oam.affineParam = 0; + switch (sDexCryScreen->unk10) + { + case 0: + sCryVolumeMeter->unk1 = 0x20; + if (sCryVolumeMeter->unk0 > 0) + { + if (sCryVolumeMeter->unk2 != 1) + sCryVolumeMeter->unk2--; + } + else + sCryVolumeMeter->unk2 = 5; + break; + case 2: + r3 = 0; + for (i = 0; i < 16; i++) + { + if (r3 < sDexCryScreen->unk0[i]) + r3 = sDexCryScreen->unk0[i]; + } + sub_8145B24(r3 * 0xd0 / 0x100); + break; + case 6: + var0 = &sDexCryScreen->unk0[10]; + sub_8145B24(*var0 * 0xd0 / 0x100); + break; + } + + if (sCryVolumeMeter->unk0 == sCryVolumeMeter->unk1) + { + // empty block + } + else if (sCryVolumeMeter->unk0 < sCryVolumeMeter->unk1) + { + sCryVolumeMeter->unk0 += sCryVolumeMeter->unk2; + if (sCryVolumeMeter->unk0 > sCryVolumeMeter->unk1) + { + sCryVolumeMeter->unk0 = sCryVolumeMeter->unk1; + sCryVolumeMeter->unk1 = 0; + } + } + else + { + sCryVolumeMeter->unk0 -= sCryVolumeMeter->unk2; + if (sCryVolumeMeter->unk0 < sCryVolumeMeter->unk1) + { + sCryVolumeMeter->unk0 = sCryVolumeMeter->unk1; + sCryVolumeMeter->unk1 = 0; + } + } + + affine.xScale = 0x100; + affine.yScale = 0x100; + affine.rotation = sCryVolumeMeter->unk0 * 256; + ObjAffineSet(&affine, &matrix, 1, 2); + SetOamMatrix(0, matrix.a, matrix.b, matrix.c, matrix.d); + x = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF)]; + y = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF) + 0x40]; + sprite->pos2.x = x * 24 / 256; + sprite->pos2.y = y * 24 / 256; +} + +static void sub_8145B24(s8 a0) +{ + u16 r2 = (0x20 - a0) & 0xff; + if (r2 > 0x20 && r2 < 0xe0) + r2 = 0xe0; + + sCryVolumeMeter->unk1 = r2; + sCryVolumeMeter->unk2 = 5; +} diff --git a/sym_common.txt b/sym_common.txt index fd04883b7..20d87f877 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -71,7 +71,7 @@ gUnknown_030061C4: @ 30061C4 gCB2_AfterEvolution: @ 30061E8 .space 0x4 -gUnknown_030061EC: @ 30061EC +gDexCryScreenState: @ 30061EC .space 0x4 .include "save.o" diff --git a/sym_ewram.txt b/sym_ewram.txt index ba06a3dc1..1cfb54156 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -365,15 +365,7 @@ gUnknown_0203AB88: @ 203AB88 gUnknown_0203AB8C: @ 203AB8C .space 0x4 -gUnknown_0203AB90: @ 203AB90 - .space 0x4 - -gUnknown_0203AB94: @ 203AB94 - .space 0x4 - -gUnknown_0203AB98: @ 203AB98 - .space 0x4 - + .include "src/pokedex_cry_screen.o" .include "src/coins.o" .include "src/battle_transition.o" .include "src/battle_message.o"