From bbc0da892f0db65f23833820b99f499de23a0ce1 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Fri, 23 Sep 2016 19:26:57 -0700 Subject: [PATCH] decompile map object and field message box code --- asm/rom4.s | 1588 +-------------------------------------- data/data2.s | 2 +- ewram_syms.txt | 8 + include/fieldmap.h | 67 +- include/global.h | 6 + include/sprite.h | 7 + iwram_syms.txt | 2 + ld_script.txt | 3 + src/field_message_box.c | 153 ++++ src/map_obj_80643A4.c | 324 ++++++++ src/map_obj_lock.c | 125 +++ src/sprite.c | 2 - 12 files changed, 698 insertions(+), 1589 deletions(-) create mode 100644 src/field_message_box.c create mode 100644 src/map_obj_80643A4.c create mode 100644 src/map_obj_lock.c diff --git a/asm/rom4.s b/asm/rom4.s index 90882d660..0580d04bd 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -29847,7 +29847,7 @@ MoveCoords: @ 80602D4 pop {r0} bx r0 .align 2, 0 -_080602F4: .4byte gUnknown_083756A4 +_080602F4: .4byte gDirectionToVector thumb_func_end MoveCoords thumb_func_start unref_sub_80602F8 @@ -29871,7 +29871,7 @@ unref_sub_80602F8: @ 80602F8 pop {r0} bx r0 .align 2, 0 -_0806031C: .4byte gUnknown_083756A4 +_0806031C: .4byte gDirectionToVector thumb_func_end unref_sub_80602F8 thumb_func_start sub_8060320 @@ -29930,7 +29930,7 @@ _0806037C: pop {r0} bx r0 .align 2, 0 -_08060384: .4byte gUnknown_083756A4 +_08060384: .4byte gDirectionToVector thumb_func_end sub_8060320 thumb_func_start sub_8060388 @@ -39029,1586 +39029,4 @@ _0806439C: bx r0 thumb_func_end DoGroundEffects_OnFinishStep - thumb_func_start sub_80643A4 -sub_80643A4: @ 80643A4 - push {r4,r5,lr} - adds r5, r0, 0 - ldrh r1, [r5] - movs r0, 0xA0 - lsls r0, 1 - ands r0, r1 - cmp r0, 0 - bne _0806442C - ldrb r0, [r5, 0x1] - movs r4, 0x1 - orrs r0, r4 - strb r0, [r5, 0x1] - ldr r3, _08064428 - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x2C - ldrb r1, [r0] - lsls r1, 25 - lsrs r1, 31 - lsls r1, 7 - ldrb r2, [r5, 0x2] - movs r0, 0x7F - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x2] - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x2C - ldrb r1, [r0] - lsrs r1, 7 - ands r1, r4 - ldrb r2, [r5, 0x3] - movs r0, 0x2 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x3] - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x2C - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x2C - ldrb r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strb r1, [r0] - movs r0, 0 - b _0806442E - .align 2, 0 -_08064428: .4byte 0x02020004 -_0806442C: - movs r0, 0x1 -_0806442E: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80643A4 - - thumb_func_start player_bitmagic -player_bitmagic: @ 8064434 - push {r4,r5,lr} - movs r4, 0 - ldr r5, _08064468 -_0806443A: - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - adds r1, r0, r5 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _08064458 - ldr r0, _0806446C - ldrb r0, [r0, 0x5] - cmp r4, r0 - beq _08064458 - adds r0, r1, 0 - bl sub_80643A4 -_08064458: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _0806443A - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08064468: .4byte 0x030048a0 -_0806446C: .4byte 0x0202e858 - thumb_func_end player_bitmagic - - thumb_func_start sub_8064470 -sub_8064470: @ 8064470 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r6, _080644AC -_0806447A: - cmp r4, r5 - beq _0806449C - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - adds r1, r0, r6 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _0806449C - ldr r0, _080644B0 - ldrb r0, [r0, 0x5] - cmp r4, r0 - beq _0806449C - adds r0, r1, 0 - bl sub_80643A4 -_0806449C: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _0806447A - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080644AC: .4byte 0x030048a0 -_080644B0: .4byte 0x0202e858 - thumb_func_end sub_8064470 - - thumb_func_start npc_sync_anim_pause_bits -npc_sync_anim_pause_bits: @ 80644B4 - push {r4,r5,lr} - adds r5, r0, 0 - ldrh r2, [r5] - ldr r1, _08064514 - adds r0, r1, 0 - ands r0, r2 - cmp r0, r1 - bne _0806450C - ldrb r1, [r5, 0x1] - movs r0, 0x2 - negs r0, r0 - ands r0, r1 - strb r0, [r5, 0x1] - ldr r4, _08064518 - ldrb r0, [r5, 0x4] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r2, [r5, 0x2] - adds r1, 0x2C - lsrs r2, 7 - lsls r2, 6 - ldrb r3, [r1] - movs r0, 0x41 - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1] - ldrb r0, [r5, 0x4] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r4 - ldrb r1, [r5, 0x3] - lsls r1, 31 - lsrs r1, 31 - adds r2, 0x2C - lsls r1, 7 - ldrb r3, [r2] - movs r0, 0x7F - ands r0, r3 - orrs r0, r1 - strb r0, [r2] -_0806450C: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08064514: .4byte 0x00000101 -_08064518: .4byte 0x02020004 - thumb_func_end npc_sync_anim_pause_bits - - thumb_func_start sub_806451C -sub_806451C: @ 806451C - push {r4,r5,lr} - movs r4, 0 - ldr r5, _08064548 -_08064522: - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - adds r1, r0, r5 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _08064538 - adds r0, r1, 0 - bl npc_sync_anim_pause_bits -_08064538: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _08064522 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08064548: .4byte 0x030048a0 - thumb_func_end sub_806451C - - thumb_func_start little_step -little_step: @ 806454C - lsls r1, 24 - ldr r2, _08064568 - lsrs r1, 22 - adds r1, r2 - ldrh r2, [r1] - ldrh r3, [r0, 0x20] - adds r2, r3 - strh r2, [r0, 0x20] - ldrh r1, [r1, 0x2] - ldrh r2, [r0, 0x22] - adds r1, r2 - strh r1, [r0, 0x22] - bx lr - .align 2, 0 -_08064568: .4byte gUnknown_083756A4 - thumb_func_end little_step - - thumb_func_start sub_806456C -sub_806456C: @ 806456C - lsls r1, 24 - ldr r2, _0806458C - lsrs r1, 22 - adds r1, r2 - ldrh r2, [r1] - lsls r2, 1 - ldrh r3, [r0, 0x20] - adds r2, r3 - strh r2, [r0, 0x20] - ldrh r1, [r1, 0x2] - lsls r1, 1 - ldrh r2, [r0, 0x22] - adds r1, r2 - strh r1, [r0, 0x22] - bx lr - .align 2, 0 -_0806458C: .4byte gUnknown_083756A4 - thumb_func_end sub_806456C - - thumb_func_start sub_8064590 -sub_8064590: @ 8064590 - lsls r1, 24 - ldr r2, _080645B4 - lsrs r1, 22 - adds r1, r2 - ldrh r2, [r1] - lsls r3, r2, 1 - adds r2, r3 - ldrh r3, [r0, 0x20] - adds r2, r3 - strh r2, [r0, 0x20] - ldrh r1, [r1, 0x2] - lsls r2, r1, 1 - adds r1, r2 - ldrh r2, [r0, 0x22] - adds r1, r2 - strh r1, [r0, 0x22] - bx lr - .align 2, 0 -_080645B4: .4byte gUnknown_083756A4 - thumb_func_end sub_8064590 - - thumb_func_start sub_80645B8 -sub_80645B8: @ 80645B8 - lsls r1, 24 - ldr r2, _080645D8 - lsrs r1, 22 - adds r1, r2 - ldrh r2, [r1] - lsls r2, 2 - ldrh r3, [r0, 0x20] - adds r2, r3 - strh r2, [r0, 0x20] - ldrh r1, [r1, 0x2] - lsls r1, 2 - ldrh r2, [r0, 0x22] - adds r1, r2 - strh r1, [r0, 0x22] - bx lr - .align 2, 0 -_080645D8: .4byte gUnknown_083756A4 - thumb_func_end sub_80645B8 - - thumb_func_start sub_80645DC -sub_80645DC: @ 80645DC - lsls r1, 24 - ldr r2, _080645FC - lsrs r1, 22 - adds r1, r2 - ldrh r2, [r1] - lsls r2, 3 - ldrh r3, [r0, 0x20] - adds r2, r3 - strh r2, [r0, 0x20] - ldrh r1, [r1, 0x2] - lsls r1, 3 - ldrh r2, [r0, 0x22] - adds r1, r2 - strh r1, [r0, 0x22] - bx lr - .align 2, 0 -_080645FC: .4byte gUnknown_083756A4 - thumb_func_end sub_80645DC - - thumb_func_start oamt_npc_ministep_reset -oamt_npc_ministep_reset: @ 8064600 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - movs r3, 0 - strh r1, [r0, 0x34] - strh r2, [r0, 0x36] - strh r3, [r0, 0x38] - bx lr - thumb_func_end oamt_npc_ministep_reset - - thumb_func_start obj_npc_ministep -obj_npc_ministep: @ 8064614 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, _0806466C - movs r0, 0x36 - ldrsh r2, [r4, r0] - lsls r0, r2, 1 - adds r0, r5 - movs r3, 0x38 - ldrsh r1, [r4, r3] - movs r3, 0 - ldrsh r0, [r0, r3] - cmp r1, r0 - bge _08064674 - ldr r1, _08064670 - lsls r0, r2, 2 - adds r0, r1 - movs r1, 0x38 - ldrsh r2, [r4, r1] - ldr r0, [r0] - lsls r2, 2 - adds r2, r0 - ldrh r1, [r4, 0x34] - lsls r1, 24 - lsrs r1, 24 - ldr r2, [r2] - adds r0, r4, 0 - bl _call_via_r2 - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] - movs r2, 0x36 - ldrsh r1, [r4, r2] - lsls r1, 1 - adds r1, r5 - lsls r0, 16 - asrs r0, 16 - movs r3, 0 - ldrsh r1, [r1, r3] - cmp r0, r1 - blt _08064674 - movs r0, 0x1 - b _08064676 - .align 2, 0 -_0806466C: .4byte gUnknown_08376194 -_08064670: .4byte gUnknown_08376180 -_08064674: - movs r0, 0 -_08064676: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end obj_npc_ministep - - thumb_func_start sub_806467C -sub_806467C: @ 806467C - lsls r1, 24 - lsrs r1, 24 - movs r2, 0 - strh r1, [r0, 0x34] - strh r2, [r0, 0x36] - strh r2, [r0, 0x38] - bx lr - thumb_func_end sub_806467C - - thumb_func_start sub_806468C -sub_806468C: @ 806468C - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x36] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080646AC - ldrh r1, [r4, 0x34] - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl little_step - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] -_080646AC: - ldrh r0, [r4, 0x36] - adds r0, 0x1 - strh r0, [r4, 0x36] - movs r1, 0x38 - ldrsh r0, [r4, r1] - cmp r0, 0xF - bgt _080646BE - movs r0, 0 - b _080646C0 -_080646BE: - movs r0, 0x1 -_080646C0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_806468C - - thumb_func_start sub_80646C8 -sub_80646C8: @ 80646C8 - lsls r1, 24 - ldr r2, _080646E0 - lsrs r1, 22 - adds r1, r2 - lsls r0, 16 - asrs r0, 16 - ldr r1, [r1] - adds r1, r0 - movs r0, 0 - ldrsb r0, [r1, r0] - bx lr - .align 2, 0 -_080646E0: .4byte gUnknown_083761D0 - thumb_func_end sub_80646C8 - - thumb_func_start sub_80646E4 -sub_80646E4: @ 80646E4 - push {r4,lr} - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - movs r4, 0 - strh r1, [r0, 0x34] - strh r2, [r0, 0x36] - strh r3, [r0, 0x38] - strh r4, [r0, 0x3A] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80646E4 - - thumb_func_start sub_8064704 -sub_8064704: @ 8064704 - push {r4-r6,lr} - sub sp, 0xC - adds r4, r0, 0 - ldr r1, _08064784 - mov r0, sp - movs r2, 0x6 - bl memcpy - add r5, sp, 0x8 - ldr r1, _08064788 - adds r0, r5, 0 - movs r2, 0x3 - bl memcpy - movs r6, 0 - movs r1, 0x36 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _08064736 - ldrh r1, [r4, 0x34] - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl little_step -_08064736: - movs r2, 0x3A - ldrsh r0, [r4, r2] - movs r2, 0x36 - ldrsh r1, [r4, r2] - adds r1, r5, r1 - ldrb r1, [r1] - asrs r0, r1 - ldrh r1, [r4, 0x38] - lsls r1, 24 - lsrs r1, 24 - bl sub_80646C8 - strh r0, [r4, 0x26] - ldrh r1, [r4, 0x3A] - adds r1, 0x1 - strh r1, [r4, 0x3A] - movs r2, 0x36 - ldrsh r0, [r4, r2] - lsls r0, 1 - add r0, sp - ldrh r0, [r0] - lsls r0, 16 - asrs r2, r0, 16 - lsls r1, 16 - asrs r1, 16 - asrs r0, 17 - cmp r1, r0 - bne _08064770 - movs r6, 0x1 -_08064770: - cmp r1, r2 - blt _0806477A - movs r0, 0 - strh r0, [r4, 0x26] - movs r6, 0xFF -_0806477A: - adds r0, r6, 0 - add sp, 0xC - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_08064784: .4byte gUnknown_083761DC -_08064788: .4byte gUnknown_083761E2 - thumb_func_end sub_8064704 - - thumb_func_start sub_806478C -sub_806478C: @ 806478C - push {r4-r6,lr} - sub sp, 0xC - adds r5, r0, 0 - ldr r1, _08064818 - mov r0, sp - movs r2, 0x6 - bl memcpy - add r4, sp, 0x8 - ldr r1, _0806481C - adds r0, r4, 0 - movs r2, 0x3 - bl memcpy - movs r6, 0 - movs r1, 0x36 - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _080647C8 - ldrh r1, [r5, 0x3A] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080647C8 - ldrh r1, [r5, 0x34] - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl little_step -_080647C8: - movs r2, 0x3A - ldrsh r0, [r5, r2] - movs r2, 0x36 - ldrsh r1, [r5, r2] - adds r1, r4, r1 - ldrb r1, [r1] - asrs r0, r1 - ldrh r1, [r5, 0x38] - lsls r1, 24 - lsrs r1, 24 - bl sub_80646C8 - strh r0, [r5, 0x26] - ldrh r1, [r5, 0x3A] - adds r1, 0x1 - strh r1, [r5, 0x3A] - movs r2, 0x36 - ldrsh r0, [r5, r2] - lsls r0, 1 - add r0, sp - ldrh r0, [r0] - lsls r0, 16 - asrs r2, r0, 16 - lsls r1, 16 - asrs r1, 16 - asrs r0, 17 - cmp r1, r0 - bne _08064802 - movs r6, 0x1 -_08064802: - cmp r1, r2 - blt _0806480C - movs r0, 0 - strh r0, [r5, 0x26] - movs r6, 0xFF -_0806480C: - adds r0, r6, 0 - add sp, 0xC - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_08064818: .4byte gUnknown_083761E6 -_0806481C: .4byte gUnknown_083761EC - thumb_func_end sub_806478C - - thumb_func_start sub_8064820 -sub_8064820: @ 8064820 - strh r1, [r0, 0x34] - bx lr - thumb_func_end sub_8064820 - - thumb_func_start sub_8064824 -sub_8064824: @ 8064824 - push {lr} - ldrh r1, [r0, 0x34] - subs r1, 0x1 - strh r1, [r0, 0x34] - lsls r1, 16 - cmp r1, 0 - beq _08064836 - movs r0, 0 - b _08064838 -_08064836: - movs r0, 0x1 -_08064838: - pop {r1} - bx r1 - thumb_func_end sub_8064824 - - thumb_func_start obj_anim_image_set_and_seek -obj_anim_image_set_and_seek: @ 806483C - push {r4,lr} - lsls r2, 24 - lsrs r2, 24 - adds r3, r0, 0 - adds r3, 0x2A - strb r1, [r3] - adds r4, r0, 0 - adds r4, 0x2C - ldrb r3, [r4] - movs r1, 0x41 - negs r1, r1 - ands r1, r3 - strb r1, [r4] - adds r1, r2, 0 - bl SeekSpriteAnim - pop {r4} - pop {r0} - bx r0 - thumb_func_end obj_anim_image_set_and_seek - - thumb_func_start sub_8064864 -sub_8064864: @ 8064864 - push {lr} - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _08064876 - movs r0, 0 - b _08064878 -_08064876: - movs r0, 0x1 -_08064878: - pop {r1} - bx r1 - thumb_func_end sub_8064864 - - thumb_func_start sub_806487C -sub_806487C: @ 806487C - push {r4-r6,lr} - mov r12, r0 - lsls r1, 24 - lsrs r1, 24 - mov r3, r12 - adds r3, 0x3E - movs r0, 0x1 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080648E4 - mov r0, r12 - ldrh r1, [r0, 0x24] - ldrh r2, [r0, 0x20] - adds r1, r2 - mov r4, r12 - adds r4, 0x28 - movs r0, 0 - ldrsb r0, [r4, r0] - ldr r2, _080648DC - adds r0, r1 - ldrh r2, [r2] - adds r0, r2 - lsls r0, 16 - lsrs r6, r0, 16 - mov r0, r12 - ldrh r1, [r0, 0x26] - ldrh r2, [r0, 0x22] - adds r1, r2 - subs r3, 0x15 - movs r0, 0 - ldrsb r0, [r3, r0] - ldr r2, _080648E0 - adds r0, r1 - ldrh r2, [r2] - adds r0, r2 - lsls r0, 16 - lsrs r5, r0, 16 - adds r2, r3, 0 - b _08064912 - .align 2, 0 -_080648DC: .4byte 0x030024d0 -_080648E0: .4byte 0x030027e0 -_080648E4: - mov r0, r12 - ldrh r1, [r0, 0x24] - ldrh r2, [r0, 0x20] - adds r1, r2 - mov r3, r12 - adds r3, 0x28 - movs r0, 0 - ldrsb r0, [r3, r0] - adds r0, r1 - lsls r0, 16 - lsrs r6, r0, 16 - mov r0, r12 - ldrh r1, [r0, 0x26] - ldrh r2, [r0, 0x22] - adds r1, r2 - mov r2, r12 - adds r2, 0x29 - movs r0, 0 - ldrsb r0, [r2, r0] - adds r0, r1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r4, r3, 0 -_08064912: - ldrb r0, [r4] - lsls r0, 24 - asrs r0, 25 - subs r0, r6, r0 - lsls r0, 16 - lsrs r3, r0, 16 - ldrb r0, [r2] - lsls r0, 24 - asrs r0, 25 - subs r0, r5, r0 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r0, r6, 16 - asrs r0, 16 - cmp r0, 0xFF - bgt _0806493E - lsls r0, r3, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bge _0806494A -_0806493E: - mov r4, r12 - adds r4, 0x3E - ldrb r0, [r4] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4] -_0806494A: - lsls r0, r5, 16 - asrs r0, 16 - cmp r0, 0xAF - bgt _0806495E - lsls r0, r2, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bge _0806496A -_0806495E: - mov r0, r12 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_0806496A: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_806487C - - thumb_func_start sub_8064970 -sub_8064970: @ 8064970 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x30] - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - movs r2, 0x1 - bl SetObjectSubpriorityByZCoord - adds r0, r4, 0 - movs r1, 0 - bl sub_806487C - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8064970 - - thumb_func_start sub_8064990 -sub_8064990: @ 8064990 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - movs r2, 0 - ldr r6, _080649DC -_0806499E: - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r4, r0, r6 - adds r0, r4, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080649E4 - ldr r1, [r4, 0x1C] - ldr r0, _080649E0 - cmp r1, r0 - bne _080649E4 - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - bne _080649E4 - adds r0, r3, 0 - bl FieldObjectDirectionToImageAnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim - b _080649EE - .align 2, 0 -_080649DC: .4byte 0x02020004 -_080649E0: .4byte sub_8064970 -_080649E4: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3F - bls _0806499E -_080649EE: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8064990 - - thumb_func_start oe_exec_and_other_stuff -oe_exec_and_other_stuff: @ 80649F4 - push {r4,lr} - adds r4, r0, 0 - adds r0, r1, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, _08064A18 - adds r2, r1, 0x4 - adds r3, r1, 0 - adds r3, 0x8 - bl FieldObjectGetLocalIdAndMap - adds r0, r4, 0 - bl FieldEffectStart - pop {r4} - pop {r1} - bx r1 - .align 2, 0 -_08064A18: .4byte 0x0202ff84 - thumb_func_end oe_exec_and_other_stuff - - thumb_func_start DoShadowFieldEffect -DoShadowFieldEffect: @ 8064A1C - push {lr} - adds r1, r0, 0 - ldrb r2, [r1, 0x2] - lsls r0, r2, 25 - cmp r0, 0 - blt _08064A34 - movs r0, 0x40 - orrs r0, r2 - strb r0, [r1, 0x2] - movs r0, 0x3 - bl oe_exec_and_other_stuff -_08064A34: - pop {r0} - bx r0 - thumb_func_end DoShadowFieldEffect - - thumb_func_start DoRippleFieldEffect -DoRippleFieldEffect: @ 8064A38 - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x5] - bl GetFieldObjectGraphicsInfo - ldr r2, _08064A70 - movs r3, 0x20 - ldrsh r1, [r4, r3] - str r1, [r2] - movs r3, 0x22 - ldrsh r1, [r4, r3] - ldrh r0, [r0, 0xA] - lsls r0, 16 - asrs r0, 17 - adds r1, r0 - subs r1, 0x2 - str r1, [r2, 0x4] - movs r0, 0x97 - str r0, [r2, 0x8] - movs r0, 0x3 - str r0, [r2, 0xC] - movs r0, 0x5 - bl FieldEffectStart - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08064A70: .4byte 0x0202ff84 - thumb_func_end DoRippleFieldEffect - - thumb_func_start sub_8064A74 -sub_8064A74: @ 8064A74 - push {lr} - ldr r1, _08064A90 - movs r0, 0 - strb r0, [r1] - ldr r0, _08064A94 - ldrh r0, [r0] - bl SetMessageBoxBaseTileNum - ldr r0, _08064A98 - ldr r1, _08064A9C - bl InitWindowFromConfig - pop {r0} - bx r0 - .align 2, 0 -_08064A90: .4byte 0x030005a8 -_08064A94: .4byte 0x0202e9d2 -_08064A98: .4byte 0x0202e87c -_08064A9C: .4byte gWindowConfig_81E6CE4 - thumb_func_end sub_8064A74 - - thumb_func_start sub_8064AA0 -sub_8064AA0: @ 8064AA0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, _08064AC4 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08064ADC - cmp r0, 0x1 - bgt _08064AC8 - cmp r0, 0 - beq _08064ACE - b _08064B28 - .align 2, 0 -_08064AC4: .4byte 0x03004b20 -_08064AC8: - cmp r0, 0x2 - beq _08064AF0 - b _08064B28 -_08064ACE: - ldr r0, _08064AD8 - bl LoadMessageBoxTiles - b _08064AE2 - .align 2, 0 -_08064AD8: .4byte 0x0202e87c -_08064ADC: - ldr r0, _08064AEC - bl DrawStandardMessageBox -_08064AE2: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08064B28 - .align 2, 0 -_08064AEC: .4byte 0x0202e87c -_08064AF0: - ldr r0, _08064B00 - ldrb r0, [r0] - cmp r0, 0x2 - beq _08064B04 - cmp r0, 0x3 - beq _08064B10 - b _08064B1C - .align 2, 0 -_08064B00: .4byte 0x030005a8 -_08064B04: - ldr r0, _08064B0C - bl sub_80035AC - b _08064B16 - .align 2, 0 -_08064B0C: .4byte 0x0202e87c -_08064B10: - ldr r0, _08064B30 - bl sub_8003778 -_08064B16: - lsls r0, 24 - cmp r0, 0 - beq _08064B28 -_08064B1C: - ldr r1, _08064B34 - movs r0, 0 - strb r0, [r1] - adds r0, r5, 0 - bl DestroyTask -_08064B28: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08064B30: .4byte 0x0202e87c -_08064B34: .4byte 0x030005a8 - thumb_func_end sub_8064AA0 - - thumb_func_start task_add_textbox -task_add_textbox: @ 8064B38 - push {lr} - ldr r0, _08064B48 - movs r1, 0x50 - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08064B48: .4byte sub_8064AA0 - thumb_func_end task_add_textbox - - thumb_func_start task_del_textbox -task_del_textbox: @ 8064B4C - push {lr} - ldr r0, _08064B64 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _08064B60 - bl DestroyTask -_08064B60: - pop {r0} - bx r0 - .align 2, 0 -_08064B64: .4byte sub_8064AA0 - thumb_func_end task_del_textbox - - thumb_func_start box_related_two__2 -box_related_two__2: @ 8064B68 - push {r4,lr} - adds r1, r0, 0 - ldr r4, _08064B84 - ldrb r0, [r4] - cmp r0, 0 - bne _08064B88 - adds r0, r1, 0 - bl textbox_fdecode_auto_and_task_add - movs r0, 0x2 - strb r0, [r4] - movs r0, 0x1 - b _08064B8A - .align 2, 0 -_08064B84: .4byte 0x030005a8 -_08064B88: - movs r0, 0 -_08064B8A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end box_related_two__2 - - thumb_func_start box_related_two__3 -box_related_two__3: @ 8064B90 - push {lr} - adds r1, r0, 0 - ldr r2, _08064BAC - ldrb r0, [r2] - cmp r0, 0 - bne _08064BB0 - movs r0, 0x3 - strb r0, [r2] - adds r0, r1, 0 - bl textbox_fdecode_auto_and_task_add - movs r0, 0x1 - b _08064BB2 - .align 2, 0 -_08064BAC: .4byte 0x030005a8 -_08064BB0: - movs r0, 0 -_08064BB2: - pop {r1} - bx r1 - thumb_func_end box_related_two__3 - - thumb_func_start unref_sub_8064BB8 -unref_sub_8064BB8: @ 8064BB8 - push {lr} - ldr r2, _08064BCC - movs r1, 0x3 - strb r1, [r2] - bl textbox_fdecode_auto_and_task_add - movs r0, 0x1 - pop {r1} - bx r1 - .align 2, 0 -_08064BCC: .4byte 0x030005a8 - thumb_func_end unref_sub_8064BB8 - - thumb_func_start unref_sub_8064BD0 -unref_sub_8064BD0: @ 8064BD0 - push {lr} - ldr r1, _08064BE8 - ldrb r0, [r1] - cmp r0, 0 - bne _08064BEC - movs r0, 0x2 - strb r0, [r1] - bl textbox_auto_and_task_add - movs r0, 0x1 - b _08064BEE - .align 2, 0 -_08064BE8: .4byte 0x030005a8 -_08064BEC: - movs r0, 0 -_08064BEE: - pop {r1} - bx r1 - thumb_func_end unref_sub_8064BD0 - - thumb_func_start textbox_fdecode_auto_and_task_add -textbox_fdecode_auto_and_task_add: @ 8064BF4 - push {r4,lr} - sub sp, 0x4 - adds r1, r0, 0 - ldr r4, _08064C20 - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r0, _08064C24 - ldr r1, _08064C28 - ldrh r2, [r1] - movs r1, 0xF - str r1, [sp] - adds r1, r4, 0 - movs r3, 0x2 - bl sub_8002EB0 - bl task_add_textbox - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08064C20: .4byte 0x020234cc -_08064C24: .4byte 0x0202e87c -_08064C28: .4byte 0x0202e9ce - thumb_func_end textbox_fdecode_auto_and_task_add - - thumb_func_start textbox_auto_and_task_add -textbox_auto_and_task_add: @ 8064C2C - push {lr} - sub sp, 0x4 - ldr r0, _08064C4C - ldr r1, _08064C50 - ldr r2, _08064C54 - ldrh r2, [r2] - movs r3, 0xF - str r3, [sp] - movs r3, 0x2 - bl sub_8002EB0 - bl task_add_textbox - add sp, 0x4 - pop {r0} - bx r0 - .align 2, 0 -_08064C4C: .4byte 0x0202e87c -_08064C50: .4byte 0x020234cc -_08064C54: .4byte 0x0202e9ce - thumb_func_end textbox_auto_and_task_add - - thumb_func_start textbox_close -textbox_close: @ 8064C58 - push {lr} - bl task_del_textbox - ldr r0, _08064C70 - bl sub_806536C - ldr r1, _08064C74 - movs r0, 0 - strb r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_08064C70: .4byte 0x0202e87c -_08064C74: .4byte 0x030005a8 - thumb_func_end textbox_close - - thumb_func_start textbox_any_visible -textbox_any_visible: @ 8064C78 - ldr r0, _08064C80 - ldrb r0, [r0] - bx lr - .align 2, 0 -_08064C80: .4byte 0x030005a8 - thumb_func_end textbox_any_visible - - thumb_func_start sub_8064C84 -sub_8064C84: @ 8064C84 - push {lr} - ldr r0, _08064C94 - ldrb r0, [r0] - cmp r0, 0 - beq _08064C98 - movs r0, 0 - b _08064C9A - .align 2, 0 -_08064C94: .4byte 0x030005a8 -_08064C98: - movs r0, 0x1 -_08064C9A: - pop {r1} - bx r1 - thumb_func_end sub_8064C84 - - thumb_func_start unref_sub_8064CA0 -unref_sub_8064CA0: @ 8064CA0 - push {lr} - bl task_del_textbox - ldr r0, _08064CB8 - bl DrawStandardMessageBox - ldr r1, _08064CBC - movs r0, 0 - strb r0, [r1] - pop {r0} - bx r0 - .align 2, 0 -_08064CB8: .4byte 0x0202e87c -_08064CBC: .4byte 0x030005a8 - thumb_func_end unref_sub_8064CA0 - - thumb_func_start walkrun_is_standing_still -walkrun_is_standing_still: @ 8064CC0 - push {lr} - ldr r0, _08064CD0 - ldrb r0, [r0, 0x3] - cmp r0, 0x1 - beq _08064CD4 - movs r0, 0x1 - b _08064CD6 - .align 2, 0 -_08064CD0: .4byte 0x0202e858 -_08064CD4: - movs r0, 0 -_08064CD6: - pop {r1} - bx r1 - thumb_func_end walkrun_is_standing_still - - thumb_func_start sub_8064CDC -sub_8064CDC: @ 8064CDC - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl walkrun_is_standing_still - lsls r0, 24 - cmp r0, 0 - beq _08064CF6 - bl sub_80594C0 - adds r0, r4, 0 - bl DestroyTask -_08064CF6: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8064CDC - - thumb_func_start sub_8064CFC -sub_8064CFC: @ 8064CFC - push {lr} - ldr r0, _08064D14 - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - bne _08064D18 - bl sub_80597F4 - movs r0, 0x1 - b _08064D1A - .align 2, 0 -_08064D14: .4byte sub_8064CDC -_08064D18: - movs r0, 0 -_08064D1A: - pop {r1} - bx r1 - thumb_func_end sub_8064CFC - - thumb_func_start sub_8064D20 -sub_8064D20: @ 8064D20 - push {lr} - bl player_bitmagic - ldr r0, _08064D34 - movs r1, 0x50 - bl CreateTask - pop {r0} - bx r0 - .align 2, 0 -_08064D34: .4byte sub_8064CDC - thumb_func_end sub_8064D20 - - thumb_func_start sub_8064D38 -sub_8064D38: @ 8064D38 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, _08064DA8 - adds r5, r0, r1 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08064D62 - bl walkrun_is_standing_still - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bne _08064D62 - bl sub_80594C0 - strh r4, [r5, 0x8] -_08064D62: - movs r1, 0xA - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08064D8A - ldr r2, _08064DAC - ldr r0, _08064DB0 - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - ldrb r0, [r1] - lsls r0, 30 - cmp r0, 0 - blt _08064D8A - adds r0, r1, 0 - bl sub_80643A4 - movs r0, 0x1 - strh r0, [r5, 0xA] -_08064D8A: - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _08064DA0 - movs r1, 0xA - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _08064DA0 - adds r0, r6, 0 - bl DestroyTask -_08064DA0: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_08064DA8: .4byte 0x03004b20 -_08064DAC: .4byte 0x030048a0 -_08064DB0: .4byte 0x03004ae0 - thumb_func_end sub_8064D38 - - thumb_func_start sub_8064DB4 -sub_8064DB4: @ 8064DB4 - push {lr} - ldr r0, _08064DCC - bl FuncIsActiveTask - lsls r0, 24 - cmp r0, 0 - bne _08064DD0 - bl sub_80597F4 - movs r0, 0x1 - b _08064DD2 - .align 2, 0 -_08064DCC: .4byte sub_8064D38 -_08064DD0: - movs r0, 0 -_08064DD2: - pop {r1} - bx r1 - thumb_func_end sub_8064DB4 - - thumb_func_start sub_8064DD8 -sub_8064DD8: @ 8064DD8 - push {r4,r5,lr} - ldr r4, _08064E1C - ldrb r0, [r4] - bl sub_8064470 - ldr r0, _08064E20 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, _08064E24 - ldrb r1, [r4] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - ldrb r0, [r1] - lsls r0, 30 - cmp r0, 0 - blt _08064E16 - adds r0, r1, 0 - bl sub_80643A4 - ldr r0, _08064E28 - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - movs r0, 0x1 - strh r0, [r1, 0xA] -_08064E16: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08064E1C: .4byte 0x03004ae0 -_08064E20: .4byte sub_8064D38 -_08064E24: .4byte 0x030048a0 -_08064E28: .4byte 0x03004b20 - thumb_func_end sub_8064DD8 - - thumb_func_start sub_8064E2C -sub_8064E2C: @ 8064E2C - push {lr} - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, _08064E58 - adds r0, r1 - bl FieldObjectClearAnimIfSpecialAnimFinished - bl sub_80A2178 - bl sub_806451C - pop {r0} - bx r0 - .align 2, 0 -_08064E58: .4byte 0x030048a0 - thumb_func_end sub_8064E2C - - thumb_func_start unref_sub_8064E5C -unref_sub_8064E5C: @ 8064E5C - push {r4,lr} - ldr r4, _08064EA4 - ldr r0, _08064EA8 - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r4 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _08064E7A - adds r0, r1, 0 - bl FieldObjectClearAnimIfSpecialAnimFinished -_08064E7A: - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetFieldObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl FieldObjectClearAnimIfSpecialAnimFinished - bl sub_80A2178 - bl sub_806451C - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08064EA4: .4byte 0x030048a0 -_08064EA8: .4byte 0x03004ae0 - thumb_func_end unref_sub_8064E5C - - thumb_func_start sub_8064EAC -sub_8064EAC: @ 8064EAC - push {lr} - ldr r0, _08064EC8 - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, _08064ECC - adds r0, r1 - ldr r1, _08064ED0 - ldrb r1, [r1] - bl FieldObjectFaceOppositeDirection - pop {r0} - bx r0 - .align 2, 0 -_08064EC8: .4byte 0x03004ae0 -_08064ECC: .4byte 0x030048a0 -_08064ED0: .4byte 0x0202e8e0 - thumb_func_end sub_8064EAC - - thumb_func_start sub_8064ED4 -sub_8064ED4: @ 8064ED4 - push {lr} - ldr r0, _08064EEC - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, _08064EF0 - adds r0, r1 - bl FieldObjectClearAnimIfSpecialAnimActive - pop {r0} - bx r0 - .align 2, 0 -_08064EEC: .4byte 0x03004ae0 -_08064EF0: .4byte 0x030048a0 - thumb_func_end sub_8064ED4 - .align 2, 0 @ Don't pad with nop. diff --git a/data/data2.s b/data/data2.s index 0f92d4ab9..e9b973db2 100644 --- a/data/data2.s +++ b/data/data2.s @@ -5777,7 +5777,7 @@ gUnknown_08375694:: @ 8375694 .4byte MetatileBehavior_IsWestBlocked .align 1 -gUnknown_083756A4:: @ 83756A4 +gDirectionToVector:: @ 83756A4 .2byte 0, 0 .2byte 0, 1 .2byte 0, -1 diff --git a/ewram_syms.txt b/ewram_syms.txt index 695eb594f..bf91d795a 100644 --- a/ewram_syms.txt +++ b/ewram_syms.txt @@ -37,6 +37,10 @@ gSaveBlock1 = 0x2025734; gMapHeader = 0x202E828; +gPlayerAvatar = 0x202E858; + +unk_202E87C = 0x202E87C; + gUnknown_0202E8AC = 0x202E8AC; gUnknown_0202E8B0 = 0x202E8B0; gUnknown_0202E8B4 = 0x202E8B4; @@ -49,8 +53,10 @@ gUnknown_0202E8C6 = 0x202E8C6; gUnknown_0202E8C8 = 0x202E8C8; gUnknown_0202E8CC = 0x202E8CC; gScriptResult = 0x202E8DC; +gUnknown_0202E8E0 = 0x202E8E0; gMenuWindow = 0x202E908; +word_202E9D2 = 0x202E9D2; gMenuWindowPtr = 0x202E9C8; gMenuMultistepInitState = 0x202E9CC; gMenuTextTileOffset = 0x202E9CE; @@ -68,6 +74,8 @@ gPaletteFade = 0x202F388; word_202FF5E = 0x202FF5E; gUnknown_0202FF84 = 0x202FF84; +gUnknown_0202FF88 = 0x202FF88; +gUnknown_0202FF8C = 0x202FF8C; gPokemonStorage = 0x20300A0; diff --git a/include/fieldmap.h b/include/fieldmap.h index 09ad2ae07..503b4b931 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -35,11 +35,76 @@ struct MapHeader struct MapObject { u32 active:1; - u8 filler[0x20]; + u32 mapobj_bit_1:1; + u32 mapobj_bit_2:1; + u32 mapobj_bit_3:1; + u32 mapobj_bit_4:1; + u32 mapobj_bit_5:1; + u32 mapobj_bit_6:1; + u32 mapobj_bit_7:1; + u32 mapobj_bit_8:1; + u32 mapobj_bit_9:1; + u32 mapobj_bit_10:1; + u32 mapobj_bit_11:1; + u32 mapobj_bit_12:1; + u32 mapobj_bit_13:1; + u32 mapobj_bit_14:1; + u32 mapobj_bit_15:1; + u32 mapobj_bit_16:1; + u32 mapobj_bit_17:1; + u32 mapobj_bit_18:1; + u32 mapobj_bit_19:1; + u32 mapobj_bit_20:1; + u32 mapobj_bit_21:1; + u32 mapobj_bit_22:1; + u32 mapobj_bit_23:1; + u32 mapobj_bit_24:1; + u32 mapobj_bit_25:1; + u32 mapobj_bit_26:1; + u32 mapobj_bit_27:1; + u32 mapobj_bit_28:1; + u32 mapobj_bit_29:1; + u32 mapobj_bit_30:1; + u32 mapobj_bit_31:1; + u8 spriteId; + u8 graphicsId; + u8 filler[0x1E]; +}; + +struct MapObjectGraphicsInfo +{ + u16 tileTag; + u16 paletteTag1; + u16 paletteTag2; + u16 size; + s16 width; + s16 height; + u8 paletteSlot:4; + u8 shadowSize:2; + u8 inanimate:1; + u8 disableReflectionPaletteLoad:1; + u8 tracks; + struct OamData *oam; + struct SubspriteTable *subspriteTables; + union AnimCmd **anims; + struct SpriteFrameImage *images; + union AffineAnimCmd **affineAnims; +}; + +struct PlayerAvatar +{ + u8 bitfield; + u8 bike; + u8 running2; + u8 running1; + u8 spriteId; + u8 mapObjectId; + // TODO: rest of struct }; extern struct MapObject gMapObjects[]; extern u8 gSelectedMapObject; extern struct MapHeader gMapHeader; +extern struct PlayerAvatar gPlayerAvatar; #endif // GUARD_FIELDMAP_H diff --git a/include/global.h b/include/global.h index 3acdd5c62..437f87ecb 100644 --- a/include/global.h +++ b/include/global.h @@ -52,6 +52,12 @@ struct Coords16 s16 y; }; +struct UCoords16 +{ + u16 x; + u16 y; +}; + struct SecretBaseRecord { u8 sbr_field_0; // ID? diff --git a/include/sprite.h b/include/sprite.h index 9b800a9ea..fe55d18e8 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -1,6 +1,8 @@ #ifndef GUARD_SPRITE_H #define GUARD_SPRITE_H +#define MAX_SPRITES 64 + struct SpriteSheet { u8 *data; @@ -183,6 +185,11 @@ struct Sprite u8 subpriority; }; +extern s16 gSpriteCoordOffsetX; +extern s16 gSpriteCoordOffsetY; + +extern struct Sprite gSprites[]; + void ResetSpriteData(void); void AnimateSprites(void); void BuildOamBuffer(void); diff --git a/iwram_syms.txt b/iwram_syms.txt index 6cb0e63b9..6cc38d974 100644 --- a/iwram_syms.txt +++ b/iwram_syms.txt @@ -2,6 +2,8 @@ gPlayTimeCounterState = 0x300057C; +byte_30005A8 = 0x30005A8; + sScriptContext1Status = 0x30005B0; sScriptContext1 = 0x30005B8; sScriptContext2 = 0x3000630; diff --git a/ld_script.txt b/ld_script.txt index 0f55dc809..c7c1c9e4d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -87,6 +87,9 @@ SECTIONS { asm/rom_8040EB4.o(.text); src/play_time.o(.text); asm/rom4.o(.text); + src/map_obj_80643A4.o(.text); + src/field_message_box.o(.text); + src/map_obj_lock.o(.text); src/text_window.o(.text); src/script.o(.text); src/scrcmd.o(.text); diff --git a/src/field_message_box.c b/src/field_message_box.c new file mode 100644 index 000000000..34670f956 --- /dev/null +++ b/src/field_message_box.c @@ -0,0 +1,153 @@ +#include "global.h" +#include "text.h" +#include "text_window.h" +#include "task.h" +#include "string_util.h" + +extern struct Window unk_202E87C; +extern u16 word_202E9D2; + +extern u16 gMenuTextTileOffset; + +extern u8 byte_30005A8; + +void textbox_fdecode_auto_and_task_add(u8 *); +void textbox_auto_and_task_add(void); + +void sub_8064A74(void) +{ + byte_30005A8 = 0; + SetMessageBoxBaseTileNum(word_202E9D2); + InitWindowFromConfig(&unk_202E87C, (struct WindowConfig *)&gWindowConfig_81E6CE4); +} + +void sub_8064AA0(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) + { + case 0: + LoadMessageBoxTiles(&unk_202E87C); + task->data[0]++; + break; + case 1: + DrawStandardMessageBox(&unk_202E87C); + task->data[0]++; + break; + case 2: + switch (byte_30005A8) + { + case 2: + if (!sub_80035AC(&unk_202E87C)) + return; + break; + case 3: + if (!sub_8003778(&unk_202E87C)) + return; + break; + } + byte_30005A8 = 0; + DestroyTask(taskId); + } +} + +void task_add_textbox(void) +{ + CreateTask(sub_8064AA0, 80); +} + +void task_del_textbox() +{ + u8 taskId = FindTaskIdByFunc(sub_8064AA0); + if (taskId != 0xFF) + DestroyTask(taskId); +} + +bool8 box_related_two__2(u8 *a1) +{ + if (byte_30005A8) + { + return FALSE; + } + else + { + textbox_fdecode_auto_and_task_add(a1); + byte_30005A8 = 2; + return TRUE; + } +} + +bool8 box_related_two__3(u8 *a1) +{ + if (byte_30005A8) + { + return FALSE; + } + else + { + byte_30005A8 = 3; + textbox_fdecode_auto_and_task_add(a1); + return TRUE; + } +} + +bool8 unref_sub_8064BB8(u8 *a1) +{ + byte_30005A8 = 3; + textbox_fdecode_auto_and_task_add(a1); + return TRUE; +} + +bool8 unref_sub_8064BD0(u8 *a1) +{ + if (byte_30005A8) + { + return FALSE; + } + else + { + byte_30005A8 = 2; + textbox_auto_and_task_add(); + return TRUE; + } +} + +void textbox_fdecode_auto_and_task_add(u8 *a1) +{ + StringExpandPlaceholders(gStringVar4, a1); + sub_8002EB0(&unk_202E87C, gStringVar4, gMenuTextTileOffset, 2, 15); + task_add_textbox(); +} + +void textbox_auto_and_task_add(void) +{ + sub_8002EB0(&unk_202E87C, gStringVar4, gMenuTextTileOffset, 2, 15); + task_add_textbox(); +} + +void textbox_close() +{ + task_del_textbox(); + sub_806536C(&unk_202E87C); + byte_30005A8 = 0; +} + +u8 textbox_any_visible() +{ + return byte_30005A8; +} + +bool8 sub_8064C84() +{ + if (byte_30005A8 == 0) + return TRUE; + else + return FALSE; +} + +void unref_sub_8064CA0() +{ + task_del_textbox(); + DrawStandardMessageBox(&unk_202E87C); + byte_30005A8 = 0; +} diff --git a/src/map_obj_80643A4.c b/src/map_obj_80643A4.c new file mode 100644 index 000000000..8e2faf268 --- /dev/null +++ b/src/map_obj_80643A4.c @@ -0,0 +1,324 @@ +#include "global.h" +#include "sprite.h" +#include "fieldmap.h" + +extern void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); +extern u8 FieldObjectDirectionToImageAnimId(u8); +extern u32 FieldEffectStart(u8); +extern void FieldObjectGetLocalIdAndMap(struct MapObject *, u8 *, u8 *, u8 *); +extern struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); + +typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 dir); + +extern u32 gUnknown_0202FF84[]; + +extern struct UCoords16 gDirectionToVector[]; +extern s16 gUnknown_08376194[]; +extern SpriteStepFunc *gUnknown_08376180[]; +extern s8 *gUnknown_083761D0[]; +extern s16 gUnknown_083761DC[]; +extern u8 gUnknown_083761E2[]; +extern s16 gUnknown_083761E6[]; +extern u8 gUnknown_083761EC[]; + +bool8 sub_80643A4(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6 || mapObject->mapobj_bit_8) + { + return TRUE; + } + else + { + mapObject->mapobj_bit_8 = 1; + mapObject->mapobj_bit_23 = gSprites[mapObject->spriteId].animPaused; + mapObject->mapobj_bit_24 = gSprites[mapObject->spriteId].affineAnimPaused; + gSprites[mapObject->spriteId].animPaused = 1; + gSprites[mapObject->spriteId].affineAnimPaused = 1; + return FALSE; + } +} + +void player_bitmagic() +{ + u8 i; + for (i = 0; i < 16; i++) + if (gMapObjects[i].active && i != gPlayerAvatar.mapObjectId) + sub_80643A4(&gMapObjects[i]); +} + +void sub_8064470(u8 a1) +{ + u8 i; + for (i = 0; i < 16; i++) + if (i != a1 && gMapObjects[i].active && i != gPlayerAvatar.mapObjectId) + sub_80643A4(&gMapObjects[i]); +} + +void npc_sync_anim_pause_bits(struct MapObject *mapObject) +{ + if (mapObject->active && mapObject->mapobj_bit_8) + { + mapObject->mapobj_bit_8 = 0; + gSprites[mapObject->spriteId].animPaused = mapObject->mapobj_bit_23; + gSprites[mapObject->spriteId].affineAnimPaused = mapObject->mapobj_bit_24; + } +} + +void sub_806451C(void) +{ + u8 i; + for (i = 0; i < 16; i++) + if (gMapObjects[i].active) + npc_sync_anim_pause_bits(&gMapObjects[i]); +} + +void little_step(struct Sprite *sprite, u8 dir) +{ + sprite->pos1.x += gDirectionToVector[dir].x; + sprite->pos1.y += gDirectionToVector[dir].y; +} + +void sub_806456C(struct Sprite *sprite, u8 dir) +{ + sprite->pos1.x += 2 * gDirectionToVector[dir].x; + sprite->pos1.y += 2 * gDirectionToVector[dir].y; +} + +void sub_8064590(struct Sprite *sprite, u8 dir) +{ + sprite->pos1.x += 2 * gDirectionToVector[dir].x + gDirectionToVector[dir].x; + sprite->pos1.y += 2 * gDirectionToVector[dir].y + gDirectionToVector[dir].y; +} + +void sub_80645B8(struct Sprite *sprite, u8 dir) +{ + sprite->pos1.x += 4 * gDirectionToVector[dir].x; + sprite->pos1.y += 4 * gDirectionToVector[dir].y; +} + +void sub_80645DC(struct Sprite *sprite, u8 dir) +{ + sprite->pos1.x += 8 * gDirectionToVector[dir].x; + sprite->pos1.y += 8 * gDirectionToVector[dir].y; +} + +void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3) +{ + sprite->data3 = a2; + sprite->data4 = a3; + sprite->data5 = 0; +} + +bool8 obj_npc_ministep(struct Sprite *sprite) +{ + if (sprite->data5 >= gUnknown_08376194[sprite->data4]) + return FALSE; + + gUnknown_08376180[sprite->data4][sprite->data5](sprite, sprite->data3); + + sprite->data5++; + + if (sprite->data5 < gUnknown_08376194[sprite->data4]) + return FALSE; + + return TRUE; +} + +void sub_806467C(struct Sprite *sprite, u8 a2) +{ + sprite->data3 = a2; + sprite->data4 = 0; + sprite->data5 = 0; +} + +bool8 sub_806468C(struct Sprite *sprite) +{ + if (!(sprite->data4 & 1)) + { + little_step(sprite, sprite->data3); + sprite->data5++; + } + + sprite->data4++; + + if (sprite->data5 > 15) + return TRUE; + else + return FALSE; +} + +s16 sub_80646C8(s16 a1, u8 a2) +{ + return gUnknown_083761D0[a2][a1]; +} + +void sub_80646E4(struct Sprite *sprite, u8 a2, u8 a3, u8 a4) +{ + sprite->data3 = a2; + sprite->data4 = a3; + sprite->data5 = a4; + sprite->data6 = 0; +} + +u8 sub_8064704(struct Sprite *sprite) +{ + u8 v2; + s16 v5[3]; + u8 v6[3]; + + memcpy(v5, gUnknown_083761DC, 6); + memcpy(v6, gUnknown_083761E2, 3); + + v2 = 0; + + if (sprite->data4) + little_step(sprite, sprite->data3); + + sprite->pos2.y = sub_80646C8(sprite->data6 >> v6[sprite->data4], sprite->data5); + + sprite->data6++; + + if (sprite->data6 == (v5[sprite->data4] >> 1)) + v2 = 1; + + if (sprite->data6 >= v5[sprite->data4]) + { + sprite->pos2.y = 0; + v2 = -1; + } + + return v2; +} + +u8 sub_806478C(struct Sprite *sprite) +{ + u8 v2; + s16 v5[3]; + u8 v6[3]; + + memcpy(v5, gUnknown_083761E6, 6); + memcpy(v6, gUnknown_083761EC, 3); + + v2 = 0; + + if (sprite->data4 && !(sprite->data6 & 1)) + little_step(sprite, sprite->data3); + + sprite->pos2.y = sub_80646C8(sprite->data6 >> v6[sprite->data4], sprite->data5); + + sprite->data6++; + + if (sprite->data6 == (v5[sprite->data4] >> 1)) + v2 = 1; + + if (sprite->data6 >= v5[sprite->data4]) + { + sprite->pos2.y = 0; + v2 = -1; + } + + return v2; +} + +void sub_8064820(struct Sprite *sprite, u16 a2) +{ + sprite->data3 = a2; +} + +bool8 sub_8064824(struct Sprite *sprite) +{ + sprite->data3--; + + if (sprite->data3 == 0) + return TRUE; + else + return FALSE; +} + +void obj_anim_image_set_and_seek(struct Sprite *sprite, u8 a2, u8 a3) +{ + sprite->animNum = a2; + sprite->animPaused = 0 ; + SeekSpriteAnim(sprite, a3); +} + +bool8 sub_8064864(struct Sprite *sprite) +{ + if (sprite->animEnded) + return TRUE; + else + return FALSE; +} + +void sub_806487C(struct Sprite *sprite, bool8 invisible) +{ + u16 x, y; + s16 x2, y2; + + sprite->invisible = invisible; + + if (sprite->coordOffsetEnabled) + { + x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX; + y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY; + } + else + { + x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX; + y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY; + } + + x2 = x - (sprite->centerToCornerVecX >> 1); + y2 = y - (sprite->centerToCornerVecY >> 1); + + if ((s16)x > 255 || x2 < -16) + sprite->invisible = 1; + if ((s16)y > 175 || y2 < -16) + sprite->invisible = 1; +} + +void sub_8064970(struct Sprite *sprite) +{ + SetObjectSubpriorityByZCoord(sprite->data1, sprite, 1); + sub_806487C(sprite, 0); +} + +void sub_8064990(u8 a1, u8 dir) +{ + u8 i; + for (i = 0; i < MAX_SPRITES; i++) + { + struct Sprite *sprite = &gSprites[i]; + if (sprite->inUse && sprite->callback == sub_8064970 && (u8)sprite->data0 == a1) + { + u8 animNum = FieldObjectDirectionToImageAnimId(dir); + StartSpriteAnim(sprite, animNum); + break; + } + } +} + +u32 oe_exec_and_other_stuff(u8 fieldEffectId, struct MapObject *mapObject) +{ + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gUnknown_0202FF84[0], (u8 *)&gUnknown_0202FF84[1], (u8 *)&gUnknown_0202FF84[2]); + return FieldEffectStart(fieldEffectId); +} + +void DoShadowFieldEffect(struct MapObject *mapObject) +{ + if (!mapObject->mapobj_bit_22) + { + mapObject->mapobj_bit_22 = 1; + oe_exec_and_other_stuff(3, mapObject); + } +} + +void DoRippleFieldEffect(struct MapObject *mapObject, struct Sprite *sprite) +{ + struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + gUnknown_0202FF84[0] = sprite->pos1.x; + gUnknown_0202FF84[1] = sprite->pos1.y + (gfxInfo->height >> 1) - 2; + gUnknown_0202FF84[2] = 151; + gUnknown_0202FF84[3] = 3; + FieldEffectStart(5); +} diff --git a/src/map_obj_lock.c b/src/map_obj_lock.c new file mode 100644 index 000000000..d4115418b --- /dev/null +++ b/src/map_obj_lock.c @@ -0,0 +1,125 @@ +#include "global.h" +#include "task.h" +#include "fieldmap.h" + +extern void sub_80594C0(void); +extern void sub_80597F4(void); +extern void player_bitmagic(void); +extern void sub_80643A4(struct MapObject *); +extern void sub_8064470(u8); +extern u8 GetFieldObjectIdByLocalIdAndMap(u8, u8, u8); +extern u8 FieldObjectClearAnimIfSpecialAnimFinished(void *); +extern void sub_80A2178(void); +extern void sub_806451C(void); +extern u8 FieldObjectFaceOppositeDirection(void *, u8); + +extern u16 gUnknown_0202E8E0; + +bool8 walkrun_is_standing_still(void) +{ + if (gPlayerAvatar.running1 == 1) + return FALSE; + else + return TRUE; +} + +void sub_8064CDC(u8 taskId) +{ + if (walkrun_is_standing_still()) + { + sub_80594C0(); + DestroyTask(taskId); + } +} + +bool8 sub_8064CFC(void) +{ + if (FuncIsActiveTask(sub_8064CDC)) + { + return FALSE; + } + else + { + sub_80597F4(); + return TRUE; + } +} + +void sub_8064D20(void) +{ + player_bitmagic(); + CreateTask(sub_8064CDC, 80); +} + +void sub_8064D38(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (!task->data[0] && walkrun_is_standing_still() == TRUE) + { + sub_80594C0(); + task->data[0] = 1; + } + if (!task->data[1] && !gMapObjects[gSelectedMapObject].mapobj_bit_1) + { + sub_80643A4(&gMapObjects[gSelectedMapObject]); + task->data[1] = 1; + } + if (task->data[0] && task->data[1]) + DestroyTask(taskId); +} + +bool8 sub_8064DB4(void) +{ + if (FuncIsActiveTask(sub_8064D38)) + { + return FALSE; + } + else + { + sub_80597F4(); + return TRUE; + } +} + +void sub_8064DD8(void) +{ + u8 taskId; + sub_8064470(gSelectedMapObject); + taskId = CreateTask(sub_8064D38, 80); + if (!gMapObjects[gSelectedMapObject].mapobj_bit_1) + { + sub_80643A4(&gMapObjects[gSelectedMapObject]); + gTasks[taskId].data[1] = 1; + } +} + +void sub_8064E2C(void) +{ + u8 objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]); + sub_80A2178(); + sub_806451C(); +} + +void unref_sub_8064E5C(void) +{ + u8 objectId; + + if (gMapObjects[gSelectedMapObject].active) + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[gSelectedMapObject]); + objectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[objectId]); + sub_80A2178(); + sub_806451C(); +} + +void sub_8064EAC(void) +{ + FieldObjectFaceOppositeDirection(&gMapObjects[gSelectedMapObject], gUnknown_0202E8E0); +} + +void sub_8064ED4(void) +{ + FieldObjectClearAnimIfSpecialAnimActive(&gMapObjects[gSelectedMapObject]); +} diff --git a/src/sprite.c b/src/sprite.c index b96f264a3..9072a487e 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -2,8 +2,6 @@ #include "main.h" #include "sprite.h" -#define MAX_SPRITES 64 - #define MAX_SPRITE_COPY_REQUESTS 64 #define OAM_MATRIX_COUNT 32