diff --git a/asm/pokedex_area_screen.s b/asm/pokedex_area_screen.s deleted file mode 100644 index 579788e14..000000000 --- a/asm/pokedex_area_screen.s +++ /dev/null @@ -1,1892 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_813CA54 -sub_813CA54: @ 813CA54 - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - movs r1, 0x8A - lsls r1, 1 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - bx lr - .pool - thumb_func_end sub_813CA54 - - thumb_func_start sub_813CA68 -sub_813CA68: @ 813CA68 - push {lr} - sub sp, 0x4 - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - movs r1, 0x8A - lsls r1, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r0, 0x4 - bhi _0813CB20 - lsls r0, 2 - ldr r1, =_0813CA90 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0813CA90: - .4byte _0813CAA4 - .4byte _0813CAB4 - .4byte _0813CABA - .4byte _0813CAEC - .4byte _0813CB10 -_0813CAA4: - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - ldrh r0, [r0, 0xE] - bl sub_813CB40 - b _0813CB24 - .pool -_0813CAB4: - bl sub_813CF0C - b _0813CB24 -_0813CABA: - ldr r1, =gUnknown_085B3DB4 - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gUnknown_0203AB7C - ldr r1, [r0] - movs r0, 0x8B - lsls r0, 1 - adds r1, r0 - movs r2, 0xA0 - lsls r2, 3 - movs r0, 0x2 - movs r3, 0 - bl LoadBgTilemap - b _0813CB24 - .pool -_0813CAEC: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _0813CB34 - ldr r0, =gUnknown_085B3D94 - ldr r1, =gPlttBufferUnfaded + 0x140 - ldr r2, =0x04000008 - bl CpuSet - b _0813CB24 - .pool -_0813CB10: - ldr r1, =0xfffff800 - movs r0, 0x2 - movs r2, 0 - bl ChangeBgY - b _0813CB24 - .pool -_0813CB20: - movs r0, 0 - b _0813CB36 -_0813CB24: - ldr r0, =gUnknown_0203AB7C - ldr r1, [r0] - movs r0, 0x8A - lsls r0, 1 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_0813CB34: - movs r0, 0x1 -_0813CB36: - add sp, 0x4 - pop {r1} - bx r1 - .pool - thumb_func_end sub_813CA68 - - thumb_func_start sub_813CB40 -sub_813CB40: @ 813CB40 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 16 - lsrs r7, r0, 16 - ldr r5, =gUnknown_0203AB7C - ldr r0, [r5] - ldr r1, =0x000006e2 - adds r0, r1 - movs r4, 0 - strh r4, [r0] - ldr r0, =0x0000403e - bl VarGet - ldr r1, [r5] - ldr r2, =0x000006e4 - adds r1, r2 - strh r0, [r1] - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x8 - bls _0813CB70 - strh r4, [r1] -_0813CB70: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r3, =0x000031dc - adds r0, r3 - ldrh r1, [r0, 0x8] - cmp r7, r1 - bne _0813CB80 - b _0813CCB8 -_0813CB80: - ldr r1, [r5] - movs r2, 0x88 - lsls r2, 1 - adds r0, r1, r2 - strh r4, [r0] - movs r3, 0x89 - lsls r3, 1 - adds r0, r1, r3 - strh r4, [r0] - movs r6, 0 - ldr r1, =gUnknown_085B3EE8 -_0813CB96: - lsls r0, r6, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r0, r7 - bne _0813CBA2 - b _0813CCF8 -_0813CBA2: - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0 - beq _0813CB96 - movs r6, 0 - ldr r4, =gUnknown_085B3EF0 - ldrh r0, [r4] - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _0813CC44 - mov r8, r4 - adds r5, r4, 0x4 - mov r9, r1 -_0813CBC0: - lsls r0, r6, 1 - adds r1, r0, r6 - lsls r2, r1, 1 - mov r3, r8 - adds r1, r2, r3 - adds r3, r0, 0 - ldrh r1, [r1] - cmp r7, r1 - bne _0813CC2E - adds r0, r4, 0x2 - adds r0, r2, r0 - ldrh r0, [r0] - cmp r0, 0x18 - beq _0813CC1A - cmp r0, 0x18 - bgt _0813CC08 - cmp r0, 0 - beq _0813CC0E - b _0813CC2E - .pool -_0813CC08: - cmp r0, 0x1A - beq _0813CC1A - b _0813CC2E -_0813CC0E: - adds r0, r2, r5 - ldrh r1, [r0] - movs r0, 0 - bl sub_813CD04 - b _0813CC2E -_0813CC1A: - adds r1, r3, r6 - lsls r1, 1 - mov r0, r8 - adds r0, 0x2 - adds r0, r1, r0 - ldrh r0, [r0] - adds r1, r5 - ldrh r1, [r1] - bl sub_813CD64 -_0813CC2E: - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r4, =gUnknown_085B3EF0 - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 1 - adds r0, r4 - ldrh r0, [r0] - cmp r0, r9 - bne _0813CBC0 -_0813CC44: - movs r6, 0 - ldr r1, =gWildMonHeaders - ldrb r0, [r1] - cmp r0, 0xFF - beq _0813CCF8 -_0813CC4E: - lsls r4, r6, 2 - adds r0, r4, r6 - lsls r0, 2 - adds r5, r0, r1 - adds r0, r5, 0 - adds r1, r7, 0 - bl sub_813CE48 - lsls r0, 24 - cmp r0, 0 - beq _0813CC9C - ldrb r0, [r5] - cmp r0, 0x18 - beq _0813CC8C - cmp r0, 0x18 - bgt _0813CC7C - cmp r0, 0 - beq _0813CC82 - b _0813CC9C - .pool -_0813CC7C: - cmp r0, 0x1A - beq _0813CC8C - b _0813CC9C -_0813CC82: - ldrb r1, [r5, 0x1] - movs r0, 0 - bl sub_813CD04 - b _0813CC9C -_0813CC8C: - ldr r0, =gWildMonHeaders - adds r1, r4, r6 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1] - ldrb r1, [r1, 0x1] - bl sub_813CD64 -_0813CC9C: - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r1, =gWildMonHeaders - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0xFF - bne _0813CC4E - b _0813CCF8 - .pool -_0813CCB8: - ldr r2, [r5] - movs r3, 0x89 - lsls r3, 1 - adds r1, r2, r3 - strh r4, [r1] - ldrb r1, [r0, 0x13] - cmp r1, 0 - beq _0813CCF0 - adds r0, r2, 0 - adds r0, 0x10 - adds r1, r2, 0 - adds r1, 0x11 - bl GetRoamerLocation - ldr r1, [r5] - ldrb r0, [r1, 0x10] - ldrb r1, [r1, 0x11] - bl Overworld_GetMapHeaderByGroupAndId - ldr r1, [r5] - ldrb r0, [r0, 0x14] - strh r0, [r1, 0x12] - movs r0, 0x88 - lsls r0, 1 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1] - b _0813CCF8 -_0813CCF0: - movs r3, 0x88 - lsls r3, 1 - adds r0, r2, r3 - strh r1, [r0] -_0813CCF8: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_813CB40 - - thumb_func_start sub_813CD04 -sub_813CD04: @ 813CD04 - push {r4,r5,lr} - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 16 - lsrs r3, r1, 16 - ldr r4, =gUnknown_0203AB7C - ldr r2, [r4] - movs r0, 0x88 - lsls r0, 1 - adds r1, r2, r0 - ldrh r0, [r1] - cmp r0, 0x3F - bhi _0813CD58 - lsls r0, 2 - adds r0, r2, r0 - strb r5, [r0, 0x10] - ldr r1, [r4] - movs r2, 0x88 - lsls r2, 1 - adds r0, r1, r2 - ldrh r0, [r0] - lsls r0, 2 - adds r1, r0 - strb r3, [r1, 0x11] - adds r0, r5, 0 - adds r1, r3, 0 - bl Overworld_GetMapHeaderByGroupAndId - ldrb r0, [r0, 0x14] - bl CorrectSpecialMapSecId - ldr r2, [r4] - movs r1, 0x88 - lsls r1, 1 - adds r3, r2, r1 - ldrh r1, [r3] - lsls r1, 2 - adds r2, r1 - strh r0, [r2, 0x12] - ldrh r0, [r3] - adds r0, 0x1 - strh r0, [r3] -_0813CD58: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813CD04 - - thumb_func_start sub_813CD64 -sub_813CD64: @ 813CD64 - push {r4-r7,lr} - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - movs r3, 0x89 - lsls r3, 1 - adds r0, r3 - ldrh r0, [r0] - cmp r0, 0x1F - bhi _0813CE22 - lsls r0, r2, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - bl sub_813CE34 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0xD4 - bhi _0813CE22 - movs r3, 0 - ldr r0, =gUnknown_085B3EEA -_0813CD96: - ldrh r4, [r0] - cmp r5, r4 - beq _0813CE22 - adds r0, 0x2 - adds r3, 0x1 - cmp r3, 0x2 - bls _0813CD96 - ldr r1, =gUnknown_085B3EFC - ldrh r0, [r1] - cmp r0, 0xD5 - beq _0813CDD2 - adds r4, r1, 0 - adds r7, r4, 0 - movs r6, 0 -_0813CDB2: - ldrh r0, [r4] - cmp r5, r0 - bne _0813CDC8 - adds r0, r7, 0x2 - adds r0, r6, r0 - ldrh r0, [r0] - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0813CE22 -_0813CDC8: - adds r4, 0x4 - adds r6, 0x4 - ldrh r0, [r4] - cmp r0, 0xD5 - bne _0813CDB2 -_0813CDD2: - movs r3, 0 - ldr r0, =gUnknown_0203AB7C - ldr r2, [r0] - movs r4, 0x89 - lsls r4, 1 - adds r1, r2, r4 - ldrh r4, [r1] - adds r1, r0, 0 - cmp r3, r4 - bge _0813CE02 - movs r6, 0xC4 - lsls r6, 3 - adds r0, r2, r6 - ldrh r0, [r0] - cmp r0, r5 - beq _0813CE02 - adds r2, r6 -_0813CDF4: - adds r2, 0x2 - adds r3, 0x1 - cmp r3, r4 - bge _0813CE02 - ldrh r0, [r2] - cmp r0, r5 - bne _0813CDF4 -_0813CE02: - ldr r1, [r1] - movs r0, 0x89 - lsls r0, 1 - adds r2, r1, r0 - ldrh r4, [r2] - cmp r3, r4 - bne _0813CE22 - lsls r0, r3, 1 - movs r6, 0xC4 - lsls r6, 3 - adds r1, r6 - adds r1, r0 - strh r5, [r1] - ldrh r0, [r2] - adds r0, 0x1 - strh r0, [r2] -_0813CE22: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813CD64 - - thumb_func_start sub_813CE34 -sub_813CE34: @ 813CE34 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - bl Overworld_GetMapHeaderByGroupAndId - ldrb r0, [r0, 0x14] - pop {r1} - bx r1 - thumb_func_end sub_813CE34 - - thumb_func_start sub_813CE48 -sub_813CE48: @ 813CE48 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r5, r1, 16 - ldrb r0, [r4] - ldrb r1, [r4, 0x1] - bl sub_813CE34 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xD2 - bne _0813CE7C - ldr r0, =gUnknown_0203AB7C - ldr r2, [r0] - ldr r0, =0x000006e2 - adds r1, r2, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - ldrh r1, [r1] - ldr r0, =0x000006e4 - adds r2, r0 - ldrh r0, [r2] - adds r0, 0x1 - cmp r1, r0 - bne _0813CEBC -_0813CE7C: - ldr r0, [r4, 0x4] - adds r1, r5, 0 - movs r2, 0xC - bl sub_813CED4 - lsls r0, 24 - cmp r0, 0 - bne _0813CECC - ldr r0, [r4, 0x8] - adds r1, r5, 0 - movs r2, 0x5 - bl sub_813CED4 - lsls r0, 24 - cmp r0, 0 - bne _0813CECC - ldr r0, [r4, 0x10] - adds r1, r5, 0 - movs r2, 0xC - bl sub_813CED4 - lsls r0, 24 - cmp r0, 0 - bne _0813CECC - ldr r0, [r4, 0xC] - adds r1, r5, 0 - movs r2, 0x5 - bl sub_813CED4 - lsls r0, 24 - cmp r0, 0 - bne _0813CECC -_0813CEBC: - movs r0, 0 - b _0813CECE - .pool -_0813CECC: - movs r0, 0x1 -_0813CECE: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_813CE48 - - thumb_func_start sub_813CED4 -sub_813CED4: @ 813CED4 - push {r4,lr} - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r2, 16 - cmp r0, 0 - beq _0813CF02 - movs r3, 0 - cmp r3, r2 - bcs _0813CF02 - ldr r1, [r0, 0x4] -_0813CEEA: - lsls r0, r3, 2 - adds r0, r1 - ldrh r0, [r0, 0x2] - cmp r0, r4 - bne _0813CEF8 - movs r0, 0x1 - b _0813CF04 -_0813CEF8: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, r2 - bcc _0813CEEA -_0813CF02: - movs r0, 0 -_0813CF04: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_813CED4 - - thumb_func_start sub_813CF0C -sub_813CF0C: @ 813CF0C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - movs r4, 0 - ldr r2, =gUnknown_0203AB7C - adds r7, r2, 0 - movs r6, 0x8B - lsls r6, 1 - movs r5, 0 - ldr r3, =0x0000027f -_0813CF26: - ldr r0, [r7] - lsls r1, r4, 1 - adds r0, r6 - adds r0, r1 - strh r5, [r0] - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, r3 - bls _0813CF26 - movs r4, 0 - ldr r0, [r2] - movs r1, 0x88 - lsls r1, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r4, r0 - bcs _0813CFB2 - adds r3, r2, 0 -_0813CF4C: - movs r5, 0 - movs r6, 0 - adds r2, r4, 0x1 - mov r8, r2 - lsls r4, 2 - mov r9, r4 -_0813CF58: - movs r4, 0 -_0813CF5A: - adds r0, r4, 0 - adds r1, r6, 0 - str r3, [sp] - bl GetRegionMapSectionIdAt - ldr r3, [sp] - ldr r2, [r3] - mov r7, r9 - adds r1, r2, r7 - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r1, 0x12] - cmp r0, r1 - bne _0813CF84 - lsls r0, r5, 1 - movs r7, 0x8B - lsls r7, 1 - adds r1, r2, r7 - adds r1, r0 - ldr r0, =0x0000ffff - strh r0, [r1] -_0813CF84: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x1F - bls _0813CF5A - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0x13 - bls _0813CF58 - mov r1, r8 - lsls r0, r1, 16 - lsrs r4, r0, 16 - ldr r0, [r3] - movs r2, 0x88 - lsls r2, 1 - adds r0, r2 - ldrh r0, [r0] - cmp r4, r0 - bcc _0813CF4C -_0813CFB2: - movs r5, 0 - movs r6, 0 - ldr r7, =gUnknown_0203AB7C - mov r12, r7 - movs r7, 0x8B - lsls r7, 1 - ldr r3, =0x0000ffff -_0813CFC0: - movs r4, 0 - adds r1, r6, 0x1 - mov r9, r1 -_0813CFC6: - mov r2, r12 - ldr r0, [r2] - lsls r1, r5, 1 - adds r2, r0, r7 - adds r1, r2, r1 - ldrh r0, [r1] - adds r1, r5, 0x1 - mov r8, r1 - cmp r0, r3 - bne _0813D0D2 - cmp r4, 0 - beq _0813CFF0 - subs r0, r5, 0x1 - lsls r0, 1 - adds r1, r2, r0 - ldrh r2, [r1] - cmp r2, r3 - beq _0813CFF0 - movs r0, 0x2 - orrs r0, r2 - strh r0, [r1] -_0813CFF0: - adds r2, r5, 0x1 - mov r8, r2 - cmp r4, 0x1F - beq _0813D00E - mov r1, r12 - ldr r0, [r1] - lsls r1, r2, 1 - adds r0, r7 - adds r2, r0, r1 - ldrh r1, [r2] - cmp r1, r3 - beq _0813D00E - movs r0, 0x1 - orrs r0, r1 - strh r0, [r2] -_0813D00E: - cmp r6, 0 - beq _0813D02C - mov r2, r12 - ldr r1, [r2] - adds r0, r5, 0 - subs r0, 0x20 - lsls r0, 1 - adds r1, r7 - adds r1, r0 - ldrh r2, [r1] - cmp r2, r3 - beq _0813D02C - movs r0, 0x8 - orrs r0, r2 - strh r0, [r1] -_0813D02C: - cmp r6, 0x13 - beq _0813D04A - mov r0, r12 - ldr r1, [r0] - adds r0, r5, 0 - adds r0, 0x20 - lsls r0, 1 - adds r1, r7 - adds r1, r0 - ldrh r2, [r1] - cmp r2, r3 - beq _0813D04A - movs r0, 0x4 - orrs r0, r2 - strh r0, [r1] -_0813D04A: - cmp r4, 0 - beq _0813D06C - cmp r6, 0 - beq _0813D06C - mov r2, r12 - ldr r1, [r2] - adds r0, r5, 0 - subs r0, 0x21 - lsls r0, 1 - adds r1, r7 - adds r1, r0 - ldrh r2, [r1] - cmp r2, r3 - beq _0813D06C - movs r0, 0x10 - orrs r0, r2 - strh r0, [r1] -_0813D06C: - cmp r4, 0x1F - beq _0813D08E - cmp r6, 0 - beq _0813D08E - mov r0, r12 - ldr r1, [r0] - adds r0, r5, 0 - subs r0, 0x1F - lsls r0, 1 - adds r1, r7 - adds r1, r0 - ldrh r2, [r1] - cmp r2, r3 - beq _0813D08E - movs r0, 0x40 - orrs r0, r2 - strh r0, [r1] -_0813D08E: - cmp r4, 0 - beq _0813D0B0 - cmp r6, 0x13 - beq _0813D0B0 - mov r2, r12 - ldr r1, [r2] - adds r0, r5, 0 - adds r0, 0x1F - lsls r0, 1 - adds r1, r7 - adds r1, r0 - ldrh r2, [r1] - cmp r2, r3 - beq _0813D0B0 - movs r0, 0x20 - orrs r0, r2 - strh r0, [r1] -_0813D0B0: - cmp r4, 0x1F - beq _0813D0D2 - cmp r6, 0x13 - beq _0813D0D2 - mov r0, r12 - ldr r1, [r0] - adds r0, r5, 0 - adds r0, 0x21 - lsls r0, 1 - adds r1, r7 - adds r1, r0 - ldrh r2, [r1] - cmp r2, r3 - beq _0813D0D2 - movs r0, 0x80 - orrs r0, r2 - strh r0, [r1] -_0813D0D2: - mov r1, r8 - lsls r0, r1, 16 - lsrs r5, r0, 16 - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x1F - bhi _0813D0E4 - b _0813CFC6 -_0813D0E4: - mov r2, r9 - lsls r0, r2, 16 - lsrs r6, r0, 16 - cmp r6, 0x13 - bhi _0813D0F0 - b _0813CFC0 -_0813D0F0: - movs r4, 0 - ldr r6, =gUnknown_0203AB7C - movs r5, 0x8B - lsls r5, 1 - ldr r7, =0x0000ffff - mov r12, r7 - movs r0, 0xA0 - lsls r0, 8 - mov r9, r0 - ldr r7, =0x0000a010 - ldr r1, =0x0000ffcf - mov r8, r1 -_0813D108: - ldr r0, [r6] - lsls r3, r4, 1 - adds r0, r5 - adds r2, r0, r3 - ldrh r1, [r2] - adds r0, r1, 0 - cmp r0, r12 - bne _0813D130 - strh r7, [r2] - b _0813D198 - .pool -_0813D130: - cmp r0, 0 - beq _0813D198 - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0813D142 - mov r0, r8 - ands r0, r1 - strh r0, [r2] -_0813D142: - ldr r0, [r6] - adds r0, r5 - adds r2, r0, r3 - ldrh r1, [r2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0813D158 - ldr r0, =0x0000ff3f - ands r0, r1 - strh r0, [r2] -_0813D158: - ldr r0, [r6] - adds r0, r5 - adds r2, r0, r3 - ldrh r1, [r2] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _0813D16E - ldr r0, =0x0000ffaf - ands r0, r1 - strh r0, [r2] -_0813D16E: - ldr r0, [r6] - adds r0, r5 - adds r2, r0, r3 - ldrh r1, [r2] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0813D184 - ldr r0, =0x0000ff5f - ands r0, r1 - strh r0, [r2] -_0813D184: - ldr r1, [r6] - adds r1, r5 - adds r1, r3 - ldr r2, =gUnknown_085B3F18 - ldrh r0, [r1] - adds r0, r2 - ldrb r0, [r0] - mov r2, r9 - orrs r0, r2 - strh r0, [r1] -_0813D198: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x0000027f - cmp r4, r0 - bls _0813D108 - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813CF0C - - thumb_func_start sub_813D1C8 -sub_813D1C8: @ 813D1C8 - push {lr} - ldr r1, =gUnknown_0203AB7C - ldr r2, [r1] - movs r3, 0x89 - lsls r3, 1 - adds r0, r2, r3 - ldrh r0, [r0] - adds r3, r1, 0 - cmp r0, 0 - beq _0813D1FC - movs r1, 0x88 - lsls r1, 1 - adds r0, r2, r1 - ldrh r0, [r0] - cmp r0, 0 - bne _0813D1FC - ldr r0, =0x0000061e - adds r1, r2, r0 - movs r0, 0x1 - strb r0, [r1] - b _0813D206 - .pool -_0813D1FC: - ldr r0, [r3] - ldr r1, =0x0000061e - adds r0, r1 - movs r1, 0 - strb r1, [r0] -_0813D206: - ldr r1, [r3] - ldr r2, =0x00000616 - adds r0, r1, r2 - movs r2, 0 - strh r2, [r0] - movs r3, 0xC3 - lsls r3, 3 - adds r0, r1, r3 - strh r2, [r0] - adds r3, 0x2 - adds r0, r1, r3 - strh r2, [r0] - ldr r0, =0x0000061c - adds r2, r1, r0 - movs r0, 0x40 - strh r0, [r2] - ldr r2, =0x0000061f - adds r1, r2 - movs r0, 0x1 - strb r0, [r1] - ldr r1, =0x00003f44 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - bl sub_813D25C - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D1C8 - - thumb_func_start sub_813D25C -sub_813D25C: @ 813D25C - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gUnknown_0203AB7C - ldr r2, [r0] - ldr r3, =0x0000061e - adds r1, r2, r3 - ldrb r1, [r1] - adds r7, r0, 0 - cmp r1, 0 - bne _0813D32A - ldr r0, =0x00000616 - adds r1, r2, r0 - ldrh r0, [r1] - cmp r0, 0 - bne _0813D324 - movs r1, 0xC3 - lsls r1, 3 - adds r0, r2, r1 - ldrh r1, [r0] - adds r1, 0x1 - strh r1, [r0] - movs r0, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0813D2A4 - subs r3, 0x4 - adds r0, r2, r3 - b _0813D2A8 - .pool -_0813D2A4: - ldr r1, =0x0000061c - adds r0, r2, r1 -_0813D2A8: - ldrh r1, [r0] - adds r1, 0x4 - movs r2, 0x7F - ands r1, r2 - strh r1, [r0] - ldr r3, =gSineTable - ldr r1, [r7] - ldr r2, =0x0000061a - adds r0, r1, r2 - ldrh r0, [r0] - lsls r0, 1 - adds r0, r3 - ldrh r2, [r0] - lsls r2, 16 - asrs r2, 20 - lsls r2, 16 - ldr r0, =0x0000061c - adds r1, r0 - ldrh r0, [r1] - lsls r0, 1 - adds r0, r3 - ldrh r1, [r0] - lsls r1, 16 - asrs r1, 20 - lsls r1, 24 - orrs r1, r2 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - ldr r1, [r7] - ldr r2, =0x00000616 - adds r0, r1, r2 - movs r3, 0 - strh r3, [r0] - movs r0, 0xC3 - lsls r0, 3 - adds r2, r1, r0 - ldrh r0, [r2] - cmp r0, 0x40 - bne _0813D3C6 - strh r3, [r2] - movs r2, 0x89 - lsls r2, 1 - adds r0, r1, r2 - ldrh r0, [r0] - cmp r0, 0 - beq _0813D3C6 - ldr r3, =0x0000061e - adds r1, r3 - movs r0, 0x1 - b _0813D3C4 - .pool -_0813D324: - subs r0, 0x1 - strh r0, [r1] - b _0813D3C6 -_0813D32A: - ldr r0, =0x00000616 - adds r1, r2, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xC - bls _0813D3C6 - movs r0, 0 - strh r0, [r1] - ldr r3, =0x0000061f - adds r1, r2, r3 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - movs r4, 0 - ldr r0, [r7] - movs r6, 0x89 - lsls r6, 1 - adds r0, r6 - ldrh r0, [r0] - cmp r4, r0 - bcs _0813D3A0 - adds r5, r7, 0 - movs r0, 0x1 - mov r12, r0 - movs r1, 0x5 - negs r1, r1 - mov r8, r1 -_0813D366: - ldr r1, [r5] - lsls r2, r4, 2 - movs r3, 0xCC - lsls r3, 3 - adds r0, r1, r3 - adds r0, r2 - ldr r3, [r0] - ldr r0, =0x0000061f - adds r1, r0 - ldrb r0, [r1] - movs r1, 0x1 - adds r3, 0x3E - ands r1, r0 - mov r2, r12 - ands r1, r2 - lsls r1, 2 - ldrb r2, [r3] - mov r0, r8 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, [r5] - adds r0, r6 - ldrh r0, [r0] - cmp r4, r0 - bcc _0813D366 -_0813D3A0: - ldr r0, [r7] - ldr r3, =0x0000061f - adds r1, r0, r3 - ldrb r0, [r1] - cmp r0, 0x4 - bls _0813D3C6 - movs r0, 0x1 - strb r0, [r1] - ldr r1, [r7] - movs r2, 0x88 - lsls r2, 1 - adds r0, r1, r2 - ldrh r0, [r0] - cmp r0, 0 - beq _0813D3C6 - subs r3, 0x1 - adds r1, r3 - movs r0, 0 -_0813D3C4: - strb r0, [r1] -_0813D3C6: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D25C - - thumb_func_start sub_813D3D8 -sub_813D3D8: @ 813D3D8 - push {r4-r6,lr} - adds r4, r0, 0 - adds r6, r1, 0 - lsls r4, 16 - lsrs r4, 16 - ldr r5, =gUnknown_0203AB7C - ldr r0, =0x000015bc - bl AllocZeroed - str r0, [r5] - movs r1, 0 - movs r5, 0 - strh r4, [r0, 0xE] - movs r2, 0xDD - lsls r2, 3 - adds r0, r2 - str r6, [r0] - strb r1, [r6] - ldr r0, =sub_813D42C - 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 - strh r5, [r1, 0x8] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D3D8 - - thumb_func_start sub_813D42C -sub_813D42C: @ 813D42C - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r2, 0x8 - ldrsh r0, [r0, r2] - adds r2, r1, 0 - cmp r0, 0xB - bls _0813D44A - b _0813D584 -_0813D44A: - lsls r0, 2 - ldr r1, =_0813D45C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0813D45C: - .4byte _0813D48C - .4byte _0813D4A8 - .4byte _0813D4D4 - .4byte _0813D4E6 - .4byte _0813D4EC - .4byte _0813D4F8 - .4byte _0813D520 - .4byte _0813D526 - .4byte _0813D52C - .4byte _0813D532 - .4byte _0813D544 - .4byte _0813D56C -_0813D48C: - bl ResetSpriteData - bl FreeAllSpritePalettes - movs r0, 0x3 - bl HideBg - movs r0, 0x2 - bl HideBg - movs r0, 0 - bl HideBg - b _0813D584 -_0813D4A8: - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0x3 - bl SetBgAttribute - ldr r0, =gUnknown_085B4018 - bl sub_81C4D70 - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - movs r1, 0xF7 - lsls r1, 4 - adds r0, r1 - movs r1, 0 - movs r2, 0x10 - bl StringFill - b _0813D584 - .pool -_0813D4D4: - bl sub_81C4E90 - cmp r0, 0x1 - beq _0813D594 - movs r0, 0x8 - negs r0, r0 - bl sub_81C4ED0 - b _0813D584 -_0813D4E6: - bl sub_813CA54 - b _0813D584 -_0813D4EC: - bl sub_813CA68 - lsls r0, 24 - cmp r0, 0 - bne _0813D594 - b _0813D584 -_0813D4F8: - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - ldr r2, =0x000006ec - adds r0, r2 - bl sub_8122D88 - movs r0, 0x1 - movs r1, 0x1 - bl CreateRegionMapPlayerIcon - movs r1, 0x8 - negs r1, r1 - movs r0, 0 - bl PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs - b _0813D584 - .pool -_0813D520: - bl sub_813D6D0 - b _0813D584 -_0813D526: - bl sub_813D8A8 - b _0813D584 -_0813D52C: - bl sub_813D8E8 - b _0813D584 -_0813D532: - movs r0, 0x15 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - b _0813D584 -_0813D544: - ldr r1, =0x00003f41 - movs r0, 0x50 - bl SetGpuReg - bl sub_813D1C8 - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0 - bl SetGpuRegBits - b _0813D584 - .pool -_0813D56C: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r2 - ldr r1, =sub_813D5A0 - str r1, [r0] - movs r1, 0 - strh r1, [r0, 0x8] - b _0813D594 - .pool -_0813D584: - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_0813D594: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D42C - - thumb_func_start sub_813D5A0 -sub_813D5A0: @ 813D5A0 - push {r4-r7,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - bl sub_813D25C - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r6, r0, r1 - movs r0, 0x8 - ldrsh r1, [r6, r0] - cmp r1, 0x1 - beq _0813D5F8 - cmp r1, 0x1 - bgt _0813D5CC - cmp r1, 0 - beq _0813D5E2 - b _0813D5D4 - .pool -_0813D5CC: - cmp r1, 0x2 - beq _0813D640 - cmp r1, 0x3 - beq _0813D652 -_0813D5D4: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - movs r0, 0 - strh r0, [r1, 0x8] -_0813D5E2: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0813D6A8 - b _0813D698 - .pool -_0813D5F8: - ldr r0, =gMain - ldrh r2, [r0, 0x2E] - movs r3, 0x2 - adds r0, r3, 0 - ands r0, r2 - cmp r0, 0 - beq _0813D614 - strh r1, [r6, 0xA] - movs r0, 0x3 - bl PlaySE - b _0813D698 - .pool -_0813D614: - movs r0, 0x10 - ands r0, r2 - cmp r0, 0 - bne _0813D630 - movs r0, 0x80 - lsls r0, 1 - ands r0, r2 - cmp r0, 0 - beq _0813D6A8 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x13] - cmp r0, 0x1 - bne _0813D6A8 -_0813D630: - strh r3, [r6, 0xA] - movs r0, 0x6D - bl PlaySE - b _0813D698 - .pool -_0813D640: - movs r0, 0x15 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _0813D698 -_0813D652: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0 - bne _0813D6A8 - bl sub_813D824 - ldr r4, =gUnknown_0203AB7C - ldr r0, [r4] - movs r1, 0xDD - lsls r1, 3 - adds r0, r1 - ldr r1, [r0] - ldrh r0, [r6, 0xA] - strb r0, [r1] - bl sub_813D6B4 - adds r0, r5, 0 - bl DestroyTask - bl sub_81C4EB4 - ldr r0, [r4] - bl Free - str r7, [r4] - b _0813D6A8 - .pool -_0813D698: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_0813D6A8: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D5A0 - - thumb_func_start sub_813D6B4 -sub_813D6B4: @ 813D6B4 - push {lr} - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x3 - movs r1, 0x4 - movs r2, 0 - bl SetBgAttribute - pop {r0} - bx r0 - thumb_func_end sub_813D6B4 - - thumb_func_start sub_813D6D0 -sub_813D6D0: @ 813D6D0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gUnknown_085B401C - bl LoadSpriteSheet - ldr r0, =gUnknown_085B4024 - bl LoadSpritePalette - ldr r0, =gUnknown_03001204 - movs r1, 0 - strh r1, [r0] - ldr r2, =gUnknown_03001200 - strh r1, [r2] - ldr r1, =gUnknown_0203AB7C - ldr r0, [r1] - movs r3, 0x89 - lsls r3, 1 - adds r0, r3 - ldrh r0, [r0] - cmp r0, 0 - beq _0813D7D8 - ldr r5, =gUnknown_03001202 - mov r10, r1 - adds r7, r2, 0 - ldr r0, =gUnknown_030011FC - mov r9, r0 - ldr r6, =gRegionMapEntries - ldr r1, =gUnknown_030011FE - mov r8, r1 -_0813D710: - mov r2, r10 - ldr r1, [r2] - movs r3, 0 - ldrsh r0, [r7, r3] - lsls r0, 1 - movs r2, 0xC4 - lsls r2, 3 - adds r1, r2 - adds r1, r0 - ldrh r0, [r1] - strh r0, [r5] - movs r3, 0 - ldrsh r0, [r5, r3] - lsls r0, 3 - adds r0, r6 - ldrb r1, [r0] - adds r1, 0x1 - lsls r1, 3 - adds r1, 0x4 - mov r0, r9 - strh r1, [r0] - movs r2, 0 - ldrsh r0, [r5, r2] - lsls r0, 3 - adds r0, r6 - ldrb r2, [r0, 0x1] - lsls r2, 3 - adds r2, 0x1C - mov r3, r8 - strh r2, [r3] - movs r3, 0 - ldrsh r0, [r5, r3] - lsls r0, 3 - adds r0, r6 - ldrb r0, [r0, 0x2] - subs r0, 0x1 - lsls r0, 2 - adds r1, r0 - mov r0, r9 - strh r1, [r0] - movs r1, 0 - ldrsh r0, [r5, r1] - lsls r0, 3 - adds r0, r6 - ldrb r0, [r0, 0x3] - subs r0, 0x1 - lsls r0, 2 - adds r2, r0 - mov r3, r8 - strh r2, [r3] - mov r0, r9 - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r3, r0] - ldr r0, =gUnknown_085B4034 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _0813D7BE - ldr r0, =gSprites - lsls r2, r1, 4 - adds r2, r1 - lsls r2, 2 - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r3] - mov r1, r10 - ldr r3, [r1] - ldr r4, =gUnknown_03001204 - ldrh r1, [r4] - adds r0, r1, 0x1 - strh r0, [r4] - lsls r1, 16 - asrs r1, 14 - movs r0, 0xCC - lsls r0, 3 - adds r3, r0 - adds r3, r1 - str r2, [r3] -_0813D7BE: - ldrh r0, [r7] - adds r0, 0x1 - strh r0, [r7] - movs r2, 0 - ldrsh r1, [r7, r2] - mov r3, r10 - ldr r0, [r3] - movs r2, 0x89 - lsls r2, 1 - adds r0, r2 - ldrh r0, [r0] - cmp r1, r0 - blt _0813D710 -_0813D7D8: - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - ldr r1, =gUnknown_03001204 - ldrh r1, [r1] - movs r3, 0xDC - lsls r3, 3 - adds r0, r3 - strh r1, [r0] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D6D0 - - thumb_func_start sub_813D824 -sub_813D824: @ 813D824 - push {r4,r5,lr} - movs r0, 0x2 - bl FreeSpriteTilesByTag - movs r0, 0x2 - bl FreeSpritePaletteByTag - movs r4, 0 - ldr r1, =gUnknown_0203AB7C - ldr r0, [r1] - movs r2, 0xDC - lsls r2, 3 - adds r0, r2 - ldrh r0, [r0] - cmp r4, r0 - bcs _0813D86C - adds r5, r1, 0 -_0813D846: - ldr r0, [r5] - lsls r1, r4, 2 - movs r2, 0xCC - lsls r2, 3 - adds r0, r2 - adds r0, r1 - ldr r0, [r0] - bl DestroySprite - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, [r5] - movs r1, 0xDC - lsls r1, 3 - adds r0, r1 - ldrh r0, [r0] - cmp r4, r0 - bcc _0813D846 -_0813D86C: - movs r0, 0x3 - bl FreeSpriteTilesByTag - movs r0, 0x3 - bl FreeSpritePaletteByTag - movs r4, 0 -_0813D87A: - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - lsls r1, r4, 2 - movs r2, 0xFB - lsls r2, 4 - adds r0, r2 - adds r0, r1 - ldr r0, [r0] - cmp r0, 0 - beq _0813D892 - bl DestroySprite -_0813D892: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x2 - bls _0813D87A - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D824 - - thumb_func_start sub_813D8A8 -sub_813D8A8: @ 813D8A8 - push {lr} - sub sp, 0x8 - ldr r0, =gUnknown_0203AB7C - ldr r1, [r0] - ldr r0, =0x00000fbc - adds r1, r0 - str r1, [sp] - ldr r0, =0x00030600 - str r0, [sp, 0x4] - ldr r0, =gPokedexAreaScreenAreaUnknown_Gfx - bl LZ77UnCompWram - mov r0, sp - bl LoadSpriteSheet - ldr r0, =gUnknown_085B40EC - bl LoadSpritePalette - add sp, 0x8 - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D8A8 - - thumb_func_start sub_813D8E8 -sub_813D8E8: @ 813D8E8 - push {r4-r6,lr} - ldr r1, =gUnknown_0203AB7C - ldr r0, [r1] - movs r2, 0x88 - lsls r2, 1 - adds r0, r2 - ldr r0, [r0] - cmp r0, 0 - beq _0813D920 - movs r4, 0 - adds r5, r1, 0 - movs r3, 0xFB - lsls r3, 4 - movs r2, 0 -_0813D904: - ldr r0, [r5] - lsls r1, r4, 2 - adds r0, r3 - adds r0, r1 - str r2, [r0] - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x2 - bls _0813D904 - b _0813D9A4 - .pool -_0813D920: - movs r4, 0 - ldr r5, =gSprites -_0813D924: - lsls r1, r4, 21 - movs r6, 0xA0 - lsls r6, 16 - adds r1, r6 - asrs r1, 16 - ldr r0, =gSpriteTemplate_85B40FC - movs r2, 0x8C - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _0813D988 - lsls r3, r0, 4 - adds r3, r0 - lsls r3, 2 - adds r3, r5 - ldrh r2, [r3, 0x4] - lsls r0, r2, 22 - lsrs r0, 22 - lsls r1, r4, 4 - adds r0, r1 - ldr r6, =0x000003ff - adds r1, r6, 0 - ands r0, r1 - ldr r6, =0xfffffc00 - adds r1, r6, 0 - ands r2, r1 - orrs r2, r0 - strh r2, [r3, 0x4] - ldr r0, =gUnknown_0203AB7C - ldr r0, [r0] - lsls r1, r4, 2 - movs r2, 0xFB - lsls r2, 4 - adds r0, r2 - adds r0, r1 - str r3, [r0] - b _0813D99A - .pool -_0813D988: - ldr r0, =gUnknown_0203AB7C - ldr r1, [r0] - lsls r0, r4, 2 - movs r6, 0xFB - lsls r6, 4 - adds r1, r6 - adds r1, r0 - movs r0, 0 - str r0, [r1] -_0813D99A: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x2 - bls _0813D924 -_0813D9A4: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813D8E8 - - .align 2, 0 @ Don't pad with nop. diff --git a/data/pokedex_area_screen.s b/data/pokedex_area_screen.s deleted file mode 100644 index 77d17a047..000000000 --- a/data/pokedex_area_screen.s +++ /dev/null @@ -1,92 +0,0 @@ -#include "constants/flags.h" -#include "constants/region_map_sections.h" -#include "constants/species.h" - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -gUnknown_085B3D94:: @ 85B3D94 - .incbin "graphics/pokedex/area_glow.gbapal" - - .align 2 -gUnknown_085B3DB4:: @ 85B3DB4 - .incbin "graphics/pokedex/area_glow.4bpp.lz" - - .align 1 -gUnknown_085B3EE8:: @ 85B3EE8 - .2byte 0x0168 - - .align 1 -gUnknown_085B3EEA:: @ 85B3EEA - .2byte MAPSEC_MARINE_CAVE, MAPSEC_UNDERWATER_MARINE_CAVE, MAPSEC_TERRA_CAVE - - .align 1 -gUnknown_085B3EF0:: @ 85B3EF0 - .2byte SPECIES_FEEBAS, 0x0000, 0x0022 - .2byte SPECIES_EGG, 0x0000, 0x0000 - - .align 1 -gUnknown_085B3EFC:: @ 85B3EFC - .2byte MAPSEC_SKY_PILLAR, FLAG_LANDMARK_SKY_PILLAR - .2byte MAPSEC_SEAFLOOR_CAVERN, FLAG_LANDMARK_SEAFLOOR_CAVERN - .2byte MAPSEC_ALTERING_CAVE_2, FLAG_LANDMARK_ALTERING_CAVE - .2byte MAPSEC_MIRAGE_TOWER, FLAG_LANDMARK_MIRAGE_TOWER - .2byte MAPSEC_DESERT_UNDERPASS, FLAG_LANDMARK_DESERT_UNDERPASS - .2byte MAPSEC_ARTISAN_CAVE, FLAG_0x8DF - .2byte MAPSEC_NONE, 0x0000 - -gUnknown_085B3F18:: @ 85B3F18 - .byte 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x11, 0x20, 0x02, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - .byte 0x12, 0x21, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x13, 0x22, 0x02, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - .byte 0x14, 0x01, 0x23, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x15, 0x20, 0x23, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - .byte 0x16, 0x21, 0x23, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x17, 0x22, 0x23, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - .byte 0x18, 0x01, 0x24, 0x03, 0x04, 0x05, 0x06, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x19, 0x20, 0x24, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - .byte 0x1a, 0x21, 0x24, 0x03, 0x04, 0x05, 0x06, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x1b, 0x22, 0x24, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - .byte 0x1c, 0x01, 0x25, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x1d, 0x20, 0x25, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - .byte 0x1e, 0x21, 0x25, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x1f, 0x22, 0x25, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - - .align 2 -gUnknown_085B4018:: @ 85B4018 - .4byte 0x00002003 - - .align 2 -gUnknown_085B401C:: @ 85B401C - obj_tiles AreaMarkerTiles, 0x0080, 0x0002 - - .align 2 -gUnknown_085B4024:: @ 85B4024 - obj_pal AreaMarkerPalette, 0x0002 - - .align 2 -gUnknown_085B402C:: @ 85B402C - .2byte 0x0000 - .2byte 0x4000 - .2byte 0x0400 - - .align 2 -gUnknown_085B4034:: @ 85B4034 - spr_template 0x0002, 0x0002, gUnknown_085B402C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -AreaMarkerPalette:: @ 85B404C - .incbin "graphics/pokedex/area_marker.gbapal" - - .align 2 -AreaMarkerTiles:: @ 85B406C - .incbin "graphics/pokedex/area_marker.4bpp" - - .align 2 -gUnknown_085B40EC:: @ 85B40EC - obj_pal gPokedexAreaScreenAreaUnknown_Pal, 0x0003 - - .align 2 -gOamData_85B40F4:: @ 85B40F4 - .2byte 0x0000 - .2byte 0x8000 - .2byte 0x0400 - - .align 2 -gSpriteTemplate_85B40FC:: @ 85B40FC - spr_template 0x0003, 0x0003, gOamData_85B40F4, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy diff --git a/include/graphics.h b/include/graphics.h index 0620ea551..18ff8c693 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4736,4 +4736,8 @@ extern const u32 gSlotMachineReelTime_Gfx[]; extern const u32 gUnknown_08D8D410[]; extern const u32 gUnknown_08D8D58C[]; +// Pokedex Area Screen +extern const u32 gPokedexAreaScreenAreaUnknown_Gfx[]; +extern const u16 gPokedexAreaScreenAreaUnknown_Pal[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/pokedex_area_screen.h b/include/pokedex_area_screen.h index 2fb5ade51..027d3e4a7 100755 --- a/include/pokedex_area_screen.h +++ b/include/pokedex_area_screen.h @@ -1,6 +1,6 @@ #ifndef GUARD_POKEDEX_AREA_SCREEN_H #define GUARD_POKEDEX_AREA_SCREEN_H -void sub_813D3D8(u16, u8*); +void ShowPokedexAreaScreen(u16, u8*); #endif // GUARD_POKEDEX_AREA_SCREEN_H diff --git a/include/region_map.h b/include/region_map.h index 6339f7a88..0c82232cf 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -78,6 +78,15 @@ struct RegionMap { /*0x284*/ u8 cursorLargeImage[0x600]; }; // size = 0x884 +struct RegionMapLocation +{ + u8 x; + u8 y; + u8 width; + u8 height; + const u8 *name; +}; + // Exported RAM declarations // Exported ROM declarations @@ -95,5 +104,10 @@ u8 *GetMapName(u8 *, u16, u16); bool32 sub_8124668(u8 mapSecId); u8 *sub_81245DC(u8 *dest, u16 mapSecId); u8 *sub_8124610(u8 *dest, u16 mapSecId); +u16 CorrectSpecialMapSecId(u16 mapSecId); +void sub_8122D88(struct RegionMap *regionMap); +void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y); + +extern const struct RegionMapLocation gRegionMapEntries[]; #endif //GUARD_REGION_MAP_H diff --git a/include/unk_pokedex_area_screen_helper.h b/include/unk_pokedex_area_screen_helper.h new file mode 100755 index 000000000..45beed70e --- /dev/null +++ b/include/unk_pokedex_area_screen_helper.h @@ -0,0 +1,17 @@ +#ifndef GUARD_UNK_POKEDEX_AREA_SCREEN_HELPER_H +#define GUARD_UNK_POKEDEX_AREA_SCREEN_HELPER_H + +struct UnkStruct_1C4D70 +{ + u32 bg:2; + u32 unk2:8; + u32 unk10:2; + u32 unk12:20; +}; + +void sub_81C4D70(const struct UnkStruct_1C4D70 *); +bool32 sub_81C4E90(void); +void sub_81C4ED0(u32); +void sub_81C4EB4(void); + +#endif // GUARD_UNK_POKEDEX_AREA_SCREEN_HELPER_H diff --git a/ld_script.txt b/ld_script.txt index 31a9c3aac..df26da50d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -203,7 +203,7 @@ SECTIONS { src/hof_pc.o(.text); src/field_specials.o(.text); src/battle_records.o(.text); - asm/pokedex_area_screen.o(.text); + src/pokedex_area_screen.o(.text); src/evolution_scene.o(.text); asm/roulette.o(.text); src/pokedex_cry_screen.o(.text); @@ -519,7 +519,7 @@ SECTIONS { src/time_events.o(.rodata); src/field_specials.o(.rodata); src/battle_records.o(.rodata); - data/pokedex_area_screen.o(.rodata); + src/pokedex_area_screen.o(.rodata); src/evolution_scene.o(.rodata); data/roulette.o(.rodata); src/pokedex_cry_screen.o(.rodata); diff --git a/src/pokedex.c b/src/pokedex.c index 3d06a0417..e234c355f 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -3156,7 +3156,7 @@ void sub_80BF0AC(u8 taskId) gMain.state++; break; case 2: - sub_813D3D8(NationalPokedexNumToSpecies(gUnknown_02039B54->dexNum), &gUnknown_02039B4C->unk64E); + ShowPokedexAreaScreen(NationalPokedexNumToSpecies(gUnknown_02039B54->dexNum), &gUnknown_02039B4C->unk64E); SetVBlankCallback(gUnknown_030060B4); gUnknown_02039B4C->unk64E = 0; gMain.state = 0; diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c new file mode 100755 index 000000000..843812723 --- /dev/null +++ b/src/pokedex_area_screen.c @@ -0,0 +1,720 @@ +#include "global.h" +#include "bg.h" +#include "event_data.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "main.h" +#include "malloc.h" +#include "menu.h" +#include "overworld.h" +#include "palette.h" +#include "pokedex_area_screen.h" +#include "region_map.h" +#include "roamer.h" +#include "sound.h" +#include "string_util.h" +#include "trig.h" +#include "unk_pokedex_area_screen_helper.h" +#include "wild_encounter.h" +#include "constants/maps.h" +#include "constants/region_map_sections.h" +#include "constants/rgb.h" +#include "constants/songs.h" +#include "constants/species.h" +#include "constants/vars.h" + +struct PokeDexAreaScreenMapIdentity +{ + u8 mapGroup; + u8 mapNum; + u16 regionMapSectionId; +}; + +struct PokeDexAreaScreen +{ + /*0x000*/ void (*callback)(void); // unused + /*0x004*/ MainCallback prev; // unused + /*0x008*/ MainCallback next; // unused + /*0x00C*/ u16 state; // unused + /*0x00E*/ u16 species; + /*0x010*/ struct PokeDexAreaScreenMapIdentity overworldAreasWithMons[0x40]; + /*0x110*/ u16 numOverworldAreas; + /*0x112*/ u16 numSpecialAreas; + /*0x114*/ u16 drawAreaGlowState; + /*0x116*/ u16 areaGlowTilemap[0x280]; + /*0x616*/ u16 areaShadeOrMarkerFrameCounter; + /*0x618*/ u16 areaShadeFrameCounter; + /*0x61A*/ u16 areaShadeBldArgLo; + /*0x61C*/ u16 areaShadeBldArgHi; + /*0x61E*/ u8 whichMarkersFlashing; + /*0x61F*/ u8 specialMarkerCycleCounter; + /*0x620*/ u16 specialAreaRegionMapSectionIds[0x20]; + /*0x660*/ struct Sprite *areaMarkerSprites[0x20]; + /*0x6E0*/ u16 numAreaMarkerSprites; + /*0x6E2*/ u16 unk6E2; + /*0x6E4*/ u16 unk6E4; + /*0x6E8*/ u8 *errno; + /*0x6EC*/ struct RegionMap regionMap; + /*0xF70*/ u8 charBuffer[0x40]; + /*0xFB0*/ struct Sprite * areaUnknownSprites[3]; + /*0xFBC*/ u8 areaUnknownGraphicsBuffer[0x600]; +}; + +static EWRAM_DATA struct PokeDexAreaScreen *sPokedexAreaScreen = NULL; + +static void FindMapsWithMon(u16); +static void BuildAreaGlowTilemap(void); +static void SetAreaHasMon(u16, u16); +static void SetSpecialMapHasMon(u16, u16); +static u16 GetRegionMapSectionId(u8, u8); +static bool8 MapHasMon(const struct WildPokemonHeader *, u16); +static bool8 MonListHasMon(const struct WildPokemonInfo *, u16, u16); +static void DoAreaGlow(void); +static void Task_PokedexAreaScreen_0(u8); +static void CreateAreaMarkerSprites(void); +static void LoadAreaUnknownGraphics(void); +static void CreateAreaUnknownSprites(void); +static void Task_PokedexAreaScreen_1(u8); +static void sub_813D6B4(void); +static void DestroyAreaMarkerSprites(void); + +static const u32 sAreaGlow_Pal[] = INCBIN_U32("graphics/pokedex/area_glow.gbapal"); +static const u32 sAreaGlow_Gfx[] = INCBIN_U32("graphics/pokedex/area_glow.4bpp.lz"); + +static const u16 sSpeciesHiddenFromAreaScreen[] = { SPECIES_WYNAUT }; + +static const u16 sMovingRegionMapSections[3] = { MAPSEC_MARINE_CAVE, MAPSEC_UNDERWATER_MARINE_CAVE, MAPSEC_TERRA_CAVE }; + +static const u16 sFeebasData[][3] = { + {SPECIES_FEEBAS, MAP_GROUP(ROUTE119), MAP_NUM(ROUTE119)}, + {NUM_SPECIES} +}; + +static const u16 sLandmarkData[][2] = { + {MAPSEC_SKY_PILLAR, FLAG_LANDMARK_SKY_PILLAR}, + {MAPSEC_SEAFLOOR_CAVERN, FLAG_LANDMARK_SEAFLOOR_CAVERN}, + {MAPSEC_ALTERING_CAVE_2, FLAG_LANDMARK_ALTERING_CAVE}, + {MAPSEC_MIRAGE_TOWER, FLAG_LANDMARK_MIRAGE_TOWER}, + {MAPSEC_DESERT_UNDERPASS, FLAG_LANDMARK_DESERT_UNDERPASS}, + {MAPSEC_ARTISAN_CAVE, FLAG_0x8DF}, + {MAPSEC_NONE} +}; + +static const u8 sAreaGlowTilemapMapping[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x11, 0x20, 0x02, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x12, 0x21, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x13, 0x22, 0x02, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x14, 0x01, 0x23, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x15, 0x20, 0x23, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x16, 0x21, 0x23, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x17, 0x22, 0x23, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x2a, 0x2e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x18, 0x01, 0x24, 0x03, 0x04, 0x05, 0x06, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x19, 0x20, 0x24, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x1a, 0x21, 0x24, 0x03, 0x04, 0x05, 0x06, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x1b, 0x22, 0x24, 0x03, 0x27, 0x2d, 0x06, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x1c, 0x01, 0x25, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x1d, 0x20, 0x25, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x29, 0x09, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x1e, 0x21, 0x25, 0x03, 0x26, 0x05, 0x2c, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x1f, 0x22, 0x25, 0x03, 0x28, 0x2d, 0x2c, 0x07, 0x2b, 0x2e, 0x2f, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, +}; + +static const struct UnkStruct_1C4D70 sUnknown_085B4018 = { + .bg = 3, + .unk2 = 0, + .unk10 = 0, + .unk12 = 2, +}; + +static const u8 sAreaMarkerTiles[]; +static const struct SpriteSheet sAreaMarkerSpriteSheet = { + sAreaMarkerTiles, 0x80, 2 +}; + +static const u16 sAreaMarkerPalette[]; +static const struct SpritePalette sAreaMarkerSpritePalette = { + sAreaMarkerPalette, 2 +}; + +static const struct OamData sAreaMarkerOamData = { + .size = 1, + .priority = 1 +}; + +static const struct SpriteTemplate sAreaMarkerSpriteTemplate = { + 2, + 2, + &sAreaMarkerOamData, + gDummySpriteAnimTable, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +static const u16 sAreaMarkerPalette[] = INCBIN_U16("graphics/pokedex/area_marker.gbapal"); +static const u8 sAreaMarkerTiles[] = INCBIN_U8("graphics/pokedex/area_marker.4bpp"); + +static const struct SpritePalette sAreaUnknownSpritePalette = { + gPokedexAreaScreenAreaUnknown_Pal, 3 +}; + +static const struct OamData sAreaUnknownOamData = { + .size = 2, + .priority = 1 +}; + +static const struct SpriteTemplate sAreaUnknownSpriteTemplate = { + 3, + 3, + &sAreaUnknownOamData, + gDummySpriteAnimTable, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +static void ResetDrawAreaGlowState(void) +{ + sPokedexAreaScreen->drawAreaGlowState = 0; +} + +static bool8 DrawAreaGlow(void) +{ + switch (sPokedexAreaScreen->drawAreaGlowState) + { + case 0: + FindMapsWithMon(sPokedexAreaScreen->species); + break; + case 1: + BuildAreaGlowTilemap(); + break; + case 2: + decompress_and_copy_tile_data_to_vram(2, sAreaGlow_Gfx, 0, 0, 0); + LoadBgTilemap(2, sPokedexAreaScreen->areaGlowTilemap, 0x500, 0); + break; + case 3: + if (!free_temp_tile_data_buffers_if_possible()) + { + CpuCopy32(sAreaGlow_Pal, gPlttBufferUnfaded + 0xA0, 0x20); + sPokedexAreaScreen->drawAreaGlowState++; + } + return TRUE; + case 4: + ChangeBgY(2, -0x800, 0); + break; + default: + return FALSE; + } + + sPokedexAreaScreen->drawAreaGlowState++; + return TRUE; +} + +static void FindMapsWithMon(u16 species) +{ + u16 i; + struct Roamer *roamer; + + sPokedexAreaScreen->unk6E2 = 0; + sPokedexAreaScreen->unk6E4 = VarGet(VAR_ALTERING_CAVE_WILD_SET); + if (sPokedexAreaScreen->unk6E4 > 8) + sPokedexAreaScreen->unk6E4 = 0; + + roamer = &gSaveBlock1Ptr->roamer; + if (species != roamer->species) + { + sPokedexAreaScreen->numOverworldAreas = 0; + sPokedexAreaScreen->numSpecialAreas = 0; + for (i = 0; i < ARRAY_COUNT(sSpeciesHiddenFromAreaScreen); i++) + { + if (sSpeciesHiddenFromAreaScreen[i] == species) + return; + } + + for (i = 0; sFeebasData[i][0] != NUM_SPECIES; i++) + { + if (species == sFeebasData[i][0]) + { + switch (sFeebasData[i][1]) + { + case MAP_GROUP(PETALBURG_CITY): + SetAreaHasMon(sFeebasData[i][1], sFeebasData[i][2]); + break; + case MAP_GROUP(METEOR_FALLS_1F_1R): + case MAP_GROUP(SAFARI_ZONE_NORTHWEST): + SetSpecialMapHasMon(sFeebasData[i][1], sFeebasData[i][2]); + break; + } + } + } + + for (i = 0; gWildMonHeaders[i].mapGroup != 0xFF; i++) + { + if (MapHasMon(gWildMonHeaders + i, species)) + { + switch (gWildMonHeaders[i].mapGroup) + { + case MAP_GROUP(PETALBURG_CITY): + SetAreaHasMon(gWildMonHeaders[i].mapGroup, gWildMonHeaders[i].mapNum); + break; + case MAP_GROUP(METEOR_FALLS_1F_1R): + case MAP_GROUP(SAFARI_ZONE_NORTHWEST): + SetSpecialMapHasMon(gWildMonHeaders[i].mapGroup, gWildMonHeaders[i].mapNum); + break; + } + } + } + } + else + { + sPokedexAreaScreen->numSpecialAreas = 0; + if (roamer->active) + { + GetRoamerLocation(&sPokedexAreaScreen->overworldAreasWithMons[0].mapGroup, &sPokedexAreaScreen->overworldAreasWithMons[0].mapNum); + sPokedexAreaScreen->overworldAreasWithMons[0].regionMapSectionId = Overworld_GetMapHeaderByGroupAndId(sPokedexAreaScreen->overworldAreasWithMons[0].mapGroup, sPokedexAreaScreen->overworldAreasWithMons[0].mapNum)->regionMapSectionId; + sPokedexAreaScreen->numOverworldAreas = 1; + } + else + { + sPokedexAreaScreen->numOverworldAreas = 0; + } + } +} + +static void SetAreaHasMon(u16 mapGroup, u16 mapNum) +{ + if (sPokedexAreaScreen->numOverworldAreas < 0x40) + { + sPokedexAreaScreen->overworldAreasWithMons[sPokedexAreaScreen->numOverworldAreas].mapGroup = mapGroup; + sPokedexAreaScreen->overworldAreasWithMons[sPokedexAreaScreen->numOverworldAreas].mapNum = mapNum; + sPokedexAreaScreen->overworldAreasWithMons[sPokedexAreaScreen->numOverworldAreas].regionMapSectionId = CorrectSpecialMapSecId(Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->regionMapSectionId); + sPokedexAreaScreen->numOverworldAreas++; + } +} + +static void SetSpecialMapHasMon(u16 mapGroup, u16 mapNum) +{ + int i; + + if (sPokedexAreaScreen->numSpecialAreas < 0x20) + { + u16 regionMapSectionId = GetRegionMapSectionId(mapGroup, mapNum); + if (regionMapSectionId < MAPSEC_NONE) + { + for (i = 0; i < ARRAY_COUNT(sMovingRegionMapSections); i++) + { + if (regionMapSectionId == sMovingRegionMapSections[i]) + return; + } + + for (i = 0; sLandmarkData[i][0] != MAPSEC_NONE; i++) + { + if (regionMapSectionId == sLandmarkData[i][0] && !FlagGet(sLandmarkData[i][1])) + return; + } + + for (i = 0; i < sPokedexAreaScreen->numSpecialAreas; i++) + { + if (sPokedexAreaScreen->specialAreaRegionMapSectionIds[i] == regionMapSectionId) + break; + } + + if (i == sPokedexAreaScreen->numSpecialAreas) + { + sPokedexAreaScreen->specialAreaRegionMapSectionIds[i] = regionMapSectionId; + sPokedexAreaScreen->numSpecialAreas++; + } + } + } +} + +static u16 GetRegionMapSectionId(u8 mapGroup, u8 mapNum) +{ + return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->regionMapSectionId; +} + +static bool8 MapHasMon(const struct WildPokemonHeader *info, u16 species) +{ + if (GetRegionMapSectionId(info->mapGroup, info->mapNum) == MAPSEC_ALTERING_CAVE_2) + { + sPokedexAreaScreen->unk6E2++; + if (sPokedexAreaScreen->unk6E2 != sPokedexAreaScreen->unk6E4 + 1) + return FALSE; + } + + if (MonListHasMon(info->landMonsInfo, species, 12)) + return TRUE; + if (MonListHasMon(info->waterMonsInfo, species, 5)) + return TRUE; + if (MonListHasMon(info->fishingMonsInfo, species, 12)) + return TRUE; + if (MonListHasMon(info->rockSmashMonsInfo, species, 5)) + return TRUE; + return FALSE; +} + +static bool8 MonListHasMon(const struct WildPokemonInfo *info, u16 species, u16 size) +{ + u16 i; + if (info != NULL) + { + for (i = 0; i < size; i++) + { + if (info->wildPokemon[i].species == species) + return TRUE; + } + } + return FALSE; +} + +static void BuildAreaGlowTilemap(void) +{ + u16 i, y, x, j; + u16 val; + + for (i = 0; i < 0x280; i++) + sPokedexAreaScreen->areaGlowTilemap[i] = 0; + + for (i = 0; i < sPokedexAreaScreen->numOverworldAreas; i++) + { + j = 0; + for (y = 0; y < 20; y++) + { + for (x = 0; x < 32; x++) + { + if (GetRegionMapSectionIdAt(x, y) == sPokedexAreaScreen->overworldAreasWithMons[i].regionMapSectionId) + sPokedexAreaScreen->areaGlowTilemap[j] = 0xFFFF; + + j++; + } + } + } + + j = 0; + for (y = 0; y < 20; y++) + { + for (x = 0; x < 32; x++) + { + if (sPokedexAreaScreen->areaGlowTilemap[j] == 0xFFFF) + { + if (x != 0 && sPokedexAreaScreen->areaGlowTilemap[j - 1] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j - 1] |= 0x02; + if (x != 31 && sPokedexAreaScreen->areaGlowTilemap[j + 1] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j + 1] |= 0x01; + if (y != 0 && sPokedexAreaScreen->areaGlowTilemap[j - 32] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j - 32] |= 0x08; + if (y != 19 && sPokedexAreaScreen->areaGlowTilemap[j + 32] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j + 32] |= 0x04; + if (x != 0 && y != 0 && sPokedexAreaScreen->areaGlowTilemap[j - 33] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j - 33] |= 0x10; + if (x != 31 && y != 0 && sPokedexAreaScreen->areaGlowTilemap[j - 31] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j - 31] |= 0x40; + if (x != 0 && y != 19 && sPokedexAreaScreen->areaGlowTilemap[j + 31] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j + 31] |= 0x20; + if (x != 31 && y != 19 && sPokedexAreaScreen->areaGlowTilemap[j + 33] != 0xFFFF) + sPokedexAreaScreen->areaGlowTilemap[j + 33] |= 0x80; + } + + j++; + } + } + + for (i = 0; i < 0x280; i++) + { + if (sPokedexAreaScreen->areaGlowTilemap[i] == 0xFFFF) + { + sPokedexAreaScreen->areaGlowTilemap[i] = 0x10; + sPokedexAreaScreen->areaGlowTilemap[i] |= 0xA000; + } + else if (sPokedexAreaScreen->areaGlowTilemap[i]) + { + if (sPokedexAreaScreen->areaGlowTilemap[i] & 0x02) + sPokedexAreaScreen->areaGlowTilemap[i] &= 0xFFCF; + if (sPokedexAreaScreen->areaGlowTilemap[i] & 0x01) + sPokedexAreaScreen->areaGlowTilemap[i] &= 0xFF3F; + if (sPokedexAreaScreen->areaGlowTilemap[i] & 0x08) + sPokedexAreaScreen->areaGlowTilemap[i] &= 0xFFAF; + if (sPokedexAreaScreen->areaGlowTilemap[i] & 0x04) + sPokedexAreaScreen->areaGlowTilemap[i] &= 0xFF5F; + + sPokedexAreaScreen->areaGlowTilemap[i] = sAreaGlowTilemapMapping[sPokedexAreaScreen->areaGlowTilemap[i]]; + sPokedexAreaScreen->areaGlowTilemap[i] |= 0xA000; + } + } +} + +static void StartAreaGlow(void) +{ + if (sPokedexAreaScreen->numSpecialAreas && sPokedexAreaScreen->numOverworldAreas == 0) + sPokedexAreaScreen->whichMarkersFlashing = 1; + else + sPokedexAreaScreen->whichMarkersFlashing = 0; + + sPokedexAreaScreen->areaShadeOrMarkerFrameCounter = 0; + sPokedexAreaScreen->areaShadeFrameCounter = 0; + sPokedexAreaScreen->areaShadeBldArgLo = 0; + sPokedexAreaScreen->areaShadeBldArgHi = 0x40; + sPokedexAreaScreen->specialMarkerCycleCounter = 1; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + DoAreaGlow(); +} + +static void DoAreaGlow(void) +{ + u16 x, y; + u16 i; + + if (sPokedexAreaScreen->whichMarkersFlashing == 0) + { + if (sPokedexAreaScreen->areaShadeOrMarkerFrameCounter == 0) + { + sPokedexAreaScreen->areaShadeFrameCounter++; + if (sPokedexAreaScreen->areaShadeFrameCounter & 1) + sPokedexAreaScreen->areaShadeBldArgLo = (sPokedexAreaScreen->areaShadeBldArgLo + 4) & 0x7f; + else + sPokedexAreaScreen->areaShadeBldArgHi = (sPokedexAreaScreen->areaShadeBldArgHi + 4) & 0x7f; + + x = gSineTable[sPokedexAreaScreen->areaShadeBldArgLo] >> 4; + y = gSineTable[sPokedexAreaScreen->areaShadeBldArgHi] >> 4; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(x, y)); + sPokedexAreaScreen->areaShadeOrMarkerFrameCounter = 0; + if (sPokedexAreaScreen->areaShadeFrameCounter == 0x40) + { + sPokedexAreaScreen->areaShadeFrameCounter = 0; + if (sPokedexAreaScreen->numSpecialAreas != 0) + sPokedexAreaScreen->whichMarkersFlashing = 1; + } + } + else + sPokedexAreaScreen->areaShadeOrMarkerFrameCounter--; + } + else + { + sPokedexAreaScreen->areaShadeOrMarkerFrameCounter++; + if (sPokedexAreaScreen->areaShadeOrMarkerFrameCounter > 12) + { + sPokedexAreaScreen->areaShadeOrMarkerFrameCounter = 0; + sPokedexAreaScreen->specialMarkerCycleCounter++; + for (i = 0; i < sPokedexAreaScreen->numSpecialAreas; i++) + sPokedexAreaScreen->areaMarkerSprites[i]->invisible = sPokedexAreaScreen->specialMarkerCycleCounter & 1; + + if (sPokedexAreaScreen->specialMarkerCycleCounter > 4) + { + sPokedexAreaScreen->specialMarkerCycleCounter = 1; + if (sPokedexAreaScreen->numOverworldAreas != 0) + sPokedexAreaScreen->whichMarkersFlashing = 0; + } + } + } +} + +void ShowPokedexAreaScreen(u16 species, u8 *errno) +{ + u8 taskId; + + sPokedexAreaScreen = AllocZeroed(sizeof(*sPokedexAreaScreen)); + sPokedexAreaScreen->species = species; + sPokedexAreaScreen->errno = errno; + errno[0] = 0; + taskId = CreateTask(Task_PokedexAreaScreen_0, 0); + gTasks[taskId].data[0] = 0; +} + +static void Task_PokedexAreaScreen_0(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + case 0: + ResetSpriteData(); + FreeAllSpritePalettes(); + HideBg(3); + HideBg(2); + HideBg(0); + break; + case 1: + SetBgAttribute(3, BG_CTRL_ATTR_VISIBLE, 3); + sub_81C4D70(&sUnknown_085B4018); + StringFill(sPokedexAreaScreen->charBuffer, CHAR_SPACE, 16); + break; + case 2: + if (sub_81C4E90() == TRUE) + return; + sub_81C4ED0(-8); + break; + case 3: + ResetDrawAreaGlowState(); + break; + case 4: + if (DrawAreaGlow()) + return; + break; + case 5: + sub_8122D88(&sPokedexAreaScreen->regionMap); + CreateRegionMapPlayerIcon(1, 1); + PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(0, -8); + break; + case 6: + CreateAreaMarkerSprites(); + break; + case 7: + LoadAreaUnknownGraphics(); + break; + case 8: + CreateAreaUnknownSprites(); + break; + case 9: + BeginNormalPaletteFade(0xFFFFFFEB, 0, 16, 0, RGB(0, 0, 0)); + break; + case 10: + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG0 | BLDCNT_TGT2_ALL); + StartAreaGlow(); + ShowBg(2); + ShowBg(3); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON); + break; + case 11: + gTasks[taskId].func = Task_PokedexAreaScreen_1; + gTasks[taskId].data[0] = 0; + return; + } + + gTasks[taskId].data[0]++; +} + +static void Task_PokedexAreaScreen_1(u8 taskId) +{ + DoAreaGlow(); + switch (gTasks[taskId].data[0]) + { + default: + gTasks[taskId].data[0] = 0; + // fall through + case 0: + if (gPaletteFade.active) + return; + break; + case 1: + if (gMain.newKeys & B_BUTTON) + { + gTasks[taskId].data[1] = 1; + PlaySE(SE_PC_OFF); + } + else if (gMain.newKeys & DPAD_RIGHT || (gMain.newKeys & R_BUTTON && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + { + gTasks[taskId].data[1] = 2; + PlaySE(SE_Z_PAGE); + } + else + return; + break; + case 2: + BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB(0, 0, 0)); + break; + case 3: + if (gPaletteFade.active) + return; + DestroyAreaMarkerSprites(); + sPokedexAreaScreen->errno[0] = gTasks[taskId].data[1]; + sub_813D6B4(); + DestroyTask(taskId); + sub_81C4EB4(); + FREE_AND_SET_NULL(sPokedexAreaScreen); + return; + } + + gTasks[taskId].data[0]++; +} + +static void sub_813D6B4(void) +{ + SetBgAttribute(3, BG_CTRL_ATTR_VISIBLE, 0); + SetBgAttribute(3, BG_CTRL_ATTR_SCREENSIZE, 0); +} + +static void CreateAreaMarkerSprites(void) +{ + u8 spriteId; + static IWRAM_DATA s16 x; + static IWRAM_DATA s16 y; + static IWRAM_DATA s16 i; + static IWRAM_DATA s16 mapSecId; + static IWRAM_DATA s16 numSprites; + + LoadSpriteSheet(&sAreaMarkerSpriteSheet); + LoadSpritePalette(&sAreaMarkerSpritePalette); + numSprites = 0; + for (i = 0; i < sPokedexAreaScreen->numSpecialAreas; i++) + { + mapSecId = sPokedexAreaScreen->specialAreaRegionMapSectionIds[i]; + x = 8 * (gRegionMapEntries[mapSecId].x + 1) + 4; + y = 8 * (gRegionMapEntries[mapSecId].y) + 28; + x += 4 * (gRegionMapEntries[mapSecId].width - 1); + y += 4 * (gRegionMapEntries[mapSecId].height - 1); + spriteId = CreateSprite(&sAreaMarkerSpriteTemplate, x, y, 0); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].invisible = TRUE; + sPokedexAreaScreen->areaMarkerSprites[numSprites++] = &gSprites[spriteId]; + } + } + + sPokedexAreaScreen->numAreaMarkerSprites = numSprites; +} + +static void DestroyAreaMarkerSprites(void) +{ + u16 i; + FreeSpriteTilesByTag(2); + FreeSpritePaletteByTag(2); + for (i = 0; i < sPokedexAreaScreen->numAreaMarkerSprites; i++) + DestroySprite(sPokedexAreaScreen->areaMarkerSprites[i]); + + FreeSpriteTilesByTag(3); + FreeSpritePaletteByTag(3); + for (i = 0; i < 3; i++) + { + if (sPokedexAreaScreen->areaUnknownSprites[i]) + DestroySprite(sPokedexAreaScreen->areaUnknownSprites[i]); + } +} + +static void LoadAreaUnknownGraphics(void) +{ + struct SpriteSheet spriteSheet = { + .data = sPokedexAreaScreen->areaUnknownGraphicsBuffer, + .size = 0x600, + .tag = 3, + }; + LZ77UnCompWram(gPokedexAreaScreenAreaUnknown_Gfx, sPokedexAreaScreen->areaUnknownGraphicsBuffer); + LoadSpriteSheet(&spriteSheet); + LoadSpritePalette(&sAreaUnknownSpritePalette); +} + +static void CreateAreaUnknownSprites(void) +{ + u16 i; + u8 spriteId; + + if (sPokedexAreaScreen->numOverworldAreas || sPokedexAreaScreen->numSpecialAreas) + { + for (i = 0; i < 3; i++) + sPokedexAreaScreen->areaUnknownSprites[i] = NULL; + } + else + { + for (i = 0; i < 3; i++) + { + spriteId = CreateSprite(&sAreaUnknownSpriteTemplate, i * 32 + 0xa0, 0x8c, 0); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].oam.tileNum += i * 16; + sPokedexAreaScreen->areaUnknownSprites[i] = gSprites + spriteId; + } + else + { + sPokedexAreaScreen->areaUnknownSprites[i] = NULL; + } + } + } +} diff --git a/src/region_map.c b/src/region_map.c index c5bcd424b..262a7d020 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -34,15 +34,6 @@ // Static type declarations -struct RegionMapLocation -{ - u8 x; - u8 y; - u8 width; - u8 height; - const u8 *name; -}; - // Static RAM declarations static EWRAM_DATA struct RegionMap *gRegionMap = NULL; diff --git a/src/unk_pokedex_area_screen_helper.c b/src/unk_pokedex_area_screen_helper.c index 9e97321df..6b88069bb 100644 --- a/src/unk_pokedex_area_screen_helper.c +++ b/src/unk_pokedex_area_screen_helper.c @@ -4,6 +4,7 @@ #include "bg.h" #include "malloc.h" #include "palette.h" +#include "unk_pokedex_area_screen_helper.h" EWRAM_DATA u8 *gUnknown_0203CF28 = NULL; @@ -13,15 +14,7 @@ static const u32 gUnknown_0861DEF4[] = INCBIN_U32("graphics/interface/region_map static const u32 gUnknown_0861E208[] = INCBIN_U32("graphics/interface/region_map_affine.8bpp.lz"); static const u32 gUnknown_0861EF64[] = INCBIN_U32("graphics/interface/region_map_affine.bin.lz"); -struct UnkStruct_1C4D70 -{ - u32 bg:2; - u32 unk2:8; - u32 unk10:2; - u32 unk12:20; -}; - -void sub_81C4D70(struct UnkStruct_1C4D70 *template) +void sub_81C4D70(const struct UnkStruct_1C4D70 *template) { u8 unk; gUnknown_0203CF28 = Alloc(4); diff --git a/sym_bss.txt b/sym_bss.txt index 7c1161528..d006e1364 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -34,24 +34,7 @@ .include "src/slot_machine.o" .include "src/contest_painting.o" .include "src/starter_choose.o" - - .align 0x2 - -gUnknown_030011FC: @ 30011FC - .space 0x2 - -gUnknown_030011FE: @ 30011FE - .space 0x2 - -gUnknown_03001200: @ 3001200 - .space 0x2 - -gUnknown_03001202: @ 3001202 - .space 0x2 - -gUnknown_03001204: @ 3001204 - .space 0x4 - + .include "src/pokedex_area_screen.o" .include "src/battle_transition.o" .include "src/pokemon_animation.o" .include "src/recorded_battle.o" diff --git a/sym_ewram.txt b/sym_ewram.txt index 1cfb54156..4830343e8 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -353,10 +353,7 @@ gPlayerFacingPosition: @ 203AB40 .include "src/pokeblock.o" .include "src/field_specials.o" .include "src/battle_records.o" - -gUnknown_0203AB7C: @ 203AB7C - .space 0x4 - + .include "src/pokedex_area_screen.o" .include "src/evolution_scene.o" gUnknown_0203AB88: @ 203AB88