diff options
-rw-r--r-- | asm/field_control_avatar.s | 8 | ||||
-rw-r--r-- | asm/field_effect_helpers.s | 8 | ||||
-rw-r--r-- | asm/field_map_obj.s | 4 | ||||
-rw-r--r-- | asm/fieldmap.s | 718 | ||||
-rw-r--r-- | asm/overworld.s | 12 | ||||
-rw-r--r-- | data/data.s | 2 | ||||
-rw-r--r-- | include/fieldmap.h | 2 | ||||
-rw-r--r-- | include/menu.h | 1 | ||||
-rw-r--r-- | include/new_menu_helpers.h | 1 | ||||
-rw-r--r-- | include/overworld.h | 3 | ||||
-rw-r--r-- | include/palette.h | 2 | ||||
-rw-r--r-- | include/quest_log.h | 1 | ||||
-rw-r--r-- | src/fieldmap.c | 255 | ||||
-rw-r--r-- | sym_ewram.txt | 2 |
14 files changed, 281 insertions, 738 deletions
diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 39055b8e9..d1d1a6812 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -884,7 +884,7 @@ sub_806CF38: @ 806CF38 ldrh r1, [r4, 0x2] b _0806CF7E _0806CF60: - ldr r1, _0806CFA4 @ =gUnknown_826D2D8 + ldr r1, _0806CFA4 @ =gDirectionToVectors lsls r2, r6, 3 adds r0, r2, r1 ldr r3, [r0] @@ -919,7 +919,7 @@ _0806CF9E: movs r0, 0 b _0806CFDE .align 2, 0 -_0806CFA4: .4byte gUnknown_826D2D8 +_0806CFA4: .4byte gDirectionToVectors _0806CFA8: .4byte gMapObjects _0806CFAC: movs r4, 0 @@ -994,7 +994,7 @@ _0806D02A: lsrs r0, 24 cmp r0, 0x1 bne _0806D092 - ldr r1, _0806D09C @ =gUnknown_826D2D8 + ldr r1, _0806D09C @ =gDirectionToVectors mov r0, r8 lsls r2, r0, 3 adds r0, r2, r1 @@ -1042,7 +1042,7 @@ _0806D092: b _0806D0C8 .align 2, 0 _0806D098: .4byte gMapObjects -_0806D09C: .4byte gUnknown_826D2D8 +_0806D09C: .4byte gDirectionToVectors _0806D0A0: ldr r0, _0806D0D4 @ =gSelectedEventObject strb r5, [r0] diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index ed746de25..be79c3b21 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -845,7 +845,7 @@ unc_grass_normal: @ 80DB3EC lsrs r4, r0, 8 lsls r0, 24 lsrs r7, r0, 24 - ldr r3, _080DB498 @ =gUnknown_2036E18 + ldr r3, _080DB498 @ =gCamera ldrb r1, [r3] movs r0, 0x1 ands r0, r1 @@ -921,7 +921,7 @@ _080DB48C: bl FieldEffectStop b _080DB4E4 .align 2, 0 -_080DB498: .4byte gUnknown_2036E18 +_080DB498: .4byte gCamera _080DB49C: .4byte gSaveBlock1Ptr _080DB4A0: mov r0, sp @@ -1196,7 +1196,7 @@ unc_grass_tall: @ 80DB69C lsrs r7, r0, 8 lsls r0, 24 lsrs r6, r0, 24 - ldr r3, _080DB748 @ =gUnknown_2036E18 + ldr r3, _080DB748 @ =gCamera ldrb r1, [r3] movs r0, 0x1 ands r0, r1 @@ -1272,7 +1272,7 @@ _080DB73C: bl FieldEffectStop b _080DB786 .align 2, 0 -_080DB748: .4byte gUnknown_2036E18 +_080DB748: .4byte gCamera _080DB74C: .4byte gSaveBlock1Ptr _080DB750: mov r0, sp diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a3d15255e..ef1c75939 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -3516,7 +3516,7 @@ npc_coords_shift_still: @ 805F818 thumb_func_start UpdateFieldObjectCoordsForCameraUpdate UpdateFieldObjectCoordsForCameraUpdate: @ 805F82C push {r4,r5,lr} - ldr r2, _0805F88C @ =gUnknown_2036E18 + ldr r2, _0805F88C @ =gCamera ldrb r1, [r2] movs r0, 0x1 ands r0, r1 @@ -3566,7 +3566,7 @@ _0805F884: pop {r0} bx r0 .align 2, 0 -_0805F88C: .4byte gUnknown_2036E18 +_0805F88C: .4byte gCamera _0805F890: .4byte gMapObjects thumb_func_end UpdateFieldObjectCoordsForCameraUpdate diff --git a/asm/fieldmap.s b/asm/fieldmap.s index f8d2eed4f..f5793b7a4 100644 --- a/asm/fieldmap.s +++ b/asm/fieldmap.s @@ -3,724 +3,6 @@ .syntax unified - .text - - thumb_func_start GetPostCameraMoveMapBorderId -GetPostCameraMoveMapBorderId: @ 805943C - push {r4,lr} - adds r3, r1, 0 - ldr r1, _08059460 @ =gSaveBlock1Ptr - ldr r1, [r1] - movs r4, 0 - ldrsh r2, [r1, r4] - adds r0, 0x7 - adds r2, r0 - movs r0, 0x2 - ldrsh r1, [r1, r0] - adds r3, 0x7 - adds r1, r3 - adds r0, r2, 0 - bl GetMapBorderIdAt - pop {r4} - pop {r1} - bx r1 - .align 2, 0 -_08059460: .4byte gSaveBlock1Ptr - thumb_func_end GetPostCameraMoveMapBorderId - - thumb_func_start CanCameraMoveInDirection -CanCameraMoveInDirection: @ 8059464 - push {r4,r5,lr} - ldr r1, _0805949C @ =gSaveBlock1Ptr - ldr r4, [r1] - movs r1, 0 - ldrsh r3, [r4, r1] - ldr r2, _080594A0 @ =gUnknown_826D2D8 - lsls r0, 3 - adds r1, r0, r2 - ldr r1, [r1] - adds r1, 0x7 - adds r3, r1 - movs r5, 0x2 - ldrsh r1, [r4, r5] - adds r2, 0x4 - adds r0, r2 - ldr r0, [r0] - adds r0, 0x7 - adds r1, r0 - adds r0, r3, 0 - bl GetMapBorderIdAt - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - beq _080594A4 - movs r0, 0x1 - b _080594A6 - .align 2, 0 -_0805949C: .4byte gSaveBlock1Ptr -_080594A0: .4byte gUnknown_826D2D8 -_080594A4: - movs r0, 0 -_080594A6: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end CanCameraMoveInDirection - - thumb_func_start sub_80594AC -sub_80594AC: @ 80594AC - push {r4-r7,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r6, r2, 0 - adds r7, r3, 0 - bl mapconnection_get_mapheader - adds r3, r0, 0 - cmp r4, 0x2 - beq _08059514 - cmp r4, 0x2 - bgt _080594CA - cmp r4, 0x1 - beq _08059500 - b _08059526 -_080594CA: - cmp r4, 0x3 - beq _080594E8 - cmp r4, 0x4 - bne _08059526 - ldr r0, _080594E4 @ =gSaveBlock1Ptr - ldr r1, [r0] - negs r0, r6 - strh r0, [r1] - ldr r2, [r5, 0x4] - ldrh r0, [r1, 0x2] - subs r0, r2 - b _08059524 - .align 2, 0 -_080594E4: .4byte gSaveBlock1Ptr -_080594E8: - ldr r0, _080594FC @ =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, [r3] - ldr r0, [r0] - strh r0, [r1] - ldr r2, [r5, 0x4] - ldrh r0, [r1, 0x2] - subs r0, r2 - b _08059524 - .align 2, 0 -_080594FC: .4byte gSaveBlock1Ptr -_08059500: - ldr r0, _08059510 @ =gSaveBlock1Ptr - ldr r1, [r0] - ldr r2, [r5, 0x4] - ldrh r0, [r1] - subs r0, r2 - strh r0, [r1] - negs r0, r7 - b _08059524 - .align 2, 0 -_08059510: .4byte gSaveBlock1Ptr -_08059514: - ldr r0, _0805952C @ =gSaveBlock1Ptr - ldr r1, [r0] - ldr r2, [r5, 0x4] - ldrh r0, [r1] - subs r0, r2 - strh r0, [r1] - ldr r0, [r3] - ldr r0, [r0, 0x4] -_08059524: - strh r0, [r1, 0x2] -_08059526: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_0805952C: .4byte gSaveBlock1Ptr - thumb_func_end sub_80594AC - - thumb_func_start CameraMove -CameraMove: @ 8059530 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r10, r0 - mov r9, r1 - ldr r1, _08059570 @ =gUnknown_2036E18 - ldrb r0, [r1] - movs r1, 0x2 - negs r1, r1 - ands r1, r0 - ldr r2, _08059570 @ =gUnknown_2036E18 - strb r1, [r2] - mov r0, r10 - mov r1, r9 - bl GetPostCameraMoveMapBorderId - adds r7, r0, 0 - adds r0, r7, 0x1 - cmp r0, 0x1 - bhi _08059578 - ldr r0, _08059574 @ =gSaveBlock1Ptr - ldr r1, [r0] - ldrh r0, [r1] - add r0, r10 - strh r0, [r1] - ldrh r0, [r1, 0x2] - add r0, r9 - strh r0, [r1, 0x2] - b _080595E2 - .align 2, 0 -_08059570: .4byte gUnknown_2036E18 -_08059574: .4byte gSaveBlock1Ptr -_08059578: - bl save_serialize_map - ldr r1, _080595F8 @ =gSaveBlock1Ptr - ldr r0, [r1] - movs r2, 0 - ldrsh r5, [r0, r2] - movs r1, 0x2 - ldrsh r6, [r0, r1] - lsls r2, r7, 24 - lsrs r2, 24 - mov r8, r2 - mov r0, r8 - adds r1, r5, 0 - adds r2, r6, 0 - bl sub_8059600 - adds r4, r0, 0 - adds r1, r7, 0 - mov r2, r10 - mov r3, r9 - bl sub_80594AC - ldrb r0, [r4, 0x8] - ldrb r1, [r4, 0x9] - bl sub_8055864 - ldr r1, _080595FC @ =gUnknown_2036E18 - ldrb r0, [r1] - movs r1, 0x1 - orrs r0, r1 - ldr r2, _080595FC @ =gUnknown_2036E18 - strb r0, [r2] - ldr r0, _080595F8 @ =gSaveBlock1Ptr - ldr r1, [r0] - movs r2, 0 - ldrsh r0, [r1, r2] - subs r5, r0 - ldr r0, _080595FC @ =gUnknown_2036E18 - str r5, [r0, 0x4] - movs r2, 0x2 - ldrsh r0, [r1, r2] - subs r6, r0 - ldr r0, _080595FC @ =gUnknown_2036E18 - str r6, [r0, 0x8] - ldrh r0, [r1] - add r0, r10 - strh r0, [r1] - ldrh r0, [r1, 0x2] - add r0, r9 - strh r0, [r1, 0x2] - mov r0, r8 - bl sub_8059250 -_080595E2: - ldr r0, _080595FC @ =gUnknown_2036E18 - ldrb r0, [r0] - lsls r0, 31 - lsrs r0, 31 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_080595F8: .4byte gSaveBlock1Ptr -_080595FC: .4byte gUnknown_2036E18 - thumb_func_end CameraMove - - thumb_func_start sub_8059600 -sub_8059600: @ 8059600 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - mov r9, r1 - mov r8, r2 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, _0805963C @ =gMapHeader - ldr r0, [r0, 0xC] - ldr r7, [r0] - ldr r4, [r0, 0x4] - movs r5, 0 - cmp r5, r7 - bge _08059648 -_0805961E: - ldrb r0, [r4] - cmp r0, r6 - bne _08059640 - adds r0, r6, 0 - mov r1, r9 - mov r2, r8 - adds r3, r4, 0 - bl sub_8059658 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08059640 - adds r0, r4, 0 - b _0805964A - .align 2, 0 -_0805963C: .4byte gMapHeader -_08059640: - adds r5, 0x1 - adds r4, 0xC - cmp r5, r7 - blt _0805961E -_08059648: - movs r0, 0 -_0805964A: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8059600 - - thumb_func_start sub_8059658 -sub_8059658: @ 8059658 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r1, 0 - mov r8, r2 - adds r5, r3, 0 - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - adds r0, r5, 0 - bl mapconnection_get_mapheader - adds r2, r0, 0 - cmp r4, 0x1 - blt _080596B0 - cmp r4, 0x2 - bgt _08059690 - ldr r0, _0805968C @ =gMapHeader - ldr r0, [r0] - ldr r1, [r0] - ldr r0, [r2] - ldr r2, [r0] - ldr r3, [r5, 0x4] - adds r0, r7, 0 - b _080596A2 - .align 2, 0 -_0805968C: .4byte gMapHeader -_08059690: - cmp r6, 0x4 - bgt _080596B0 - ldr r0, _080596AC @ =gMapHeader - ldr r0, [r0] - ldr r1, [r0, 0x4] - ldr r0, [r2] - ldr r2, [r0, 0x4] - ldr r3, [r5, 0x4] - mov r0, r8 -_080596A2: - bl sub_80596BC - lsls r0, 24 - lsrs r0, 24 - b _080596B2 - .align 2, 0 -_080596AC: .4byte gMapHeader -_080596B0: - movs r0, 0 -_080596B2: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8059658 - - thumb_func_start sub_80596BC -sub_80596BC: @ 80596BC - push {r4,lr} - adds r4, r0, 0 - adds r0, r2, 0 - adds r2, r3, 0 - cmp r3, 0 - bge _080596CA - movs r3, 0 -_080596CA: - adds r2, r0, r2 - cmp r2, r1 - bge _080596D2 - adds r1, r2, 0 -_080596D2: - cmp r3, r4 - bgt _080596DE - cmp r4, r1 - bgt _080596DE - movs r0, 0x1 - b _080596E0 -_080596DE: - movs r0, 0 -_080596E0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80596BC - - thumb_func_start sub_80596E8 -sub_80596E8: @ 80596E8 - push {lr} - cmp r0, 0 - blt _080596F6 - cmp r0, r1 - bge _080596F6 - movs r0, 0x1 - b _080596F8 -_080596F6: - movs r0, 0 -_080596F8: - pop {r1} - bx r1 - thumb_func_end sub_80596E8 - - thumb_func_start sub_80596FC -sub_80596FC: @ 80596FC - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - bl mapconnection_get_mapheader - adds r1, r0, 0 - ldrb r0, [r4] - cmp r0, 0x1 - blt _08059734 - cmp r0, 0x2 - bgt _08059722 - ldr r0, [r4, 0x4] - subs r0, r5, r0 - ldr r1, [r1] - ldr r1, [r1] - bl sub_80596E8 - b _08059736 -_08059722: - cmp r0, 0x4 - bgt _08059734 - ldr r0, [r4, 0x4] - subs r0, r6, r0 - ldr r1, [r1] - ldr r1, [r1, 0x4] - bl sub_80596E8 - b _08059736 -_08059734: - movs r0, 0 -_08059736: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80596FC - - thumb_func_start sub_805973C -sub_805973C: @ 805973C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r1, 16 - lsrs r1, 16 - ldr r2, _0805975C @ =gMapHeader - ldr r0, [r2, 0xC] - cmp r0, 0 - bne _08059764 - b _080597DA - .align 2, 0 -_0805975C: .4byte gMapHeader -_08059760: - adds r0, r4, 0 - b _080597DC -_08059764: - ldr r7, [r0] - ldr r4, [r0, 0x4] - movs r6, 0 - cmp r6, r7 - bge _080597DA - lsls r0, r1, 16 - asrs r5, r0, 16 - mov r9, r2 - mov r1, r8 - lsls r0, r1, 16 - asrs r0, 16 - mov r10, r0 -_0805977C: - ldrb r1, [r4] - adds r3, r1, 0 - subs r0, r1, 0x5 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _080597D2 - cmp r1, 0x2 - bne _08059792 - cmp r5, 0x6 - bgt _080597D2 -_08059792: - cmp r1, 0x1 - bne _080597A2 - mov r2, r9 - ldr r0, [r2] - ldr r0, [r0, 0x4] - adds r0, 0x7 - cmp r5, r0 - blt _080597D2 -_080597A2: - mov r0, r8 - lsls r2, r0, 16 - cmp r1, 0x3 - bne _080597B0 - mov r1, r10 - cmp r1, 0x6 - bgt _080597D2 -_080597B0: - cmp r3, 0x4 - bne _080597C2 - asrs r1, r2, 16 - mov r3, r9 - ldr r0, [r3] - ldr r0, [r0] - adds r0, 0x7 - cmp r1, r0 - blt _080597D2 -_080597C2: - asrs r1, r2, 16 - subs r1, 0x7 - adds r0, r4, 0 - subs r2, r5, 0x7 - bl sub_80596FC - cmp r0, 0x1 - beq _08059760 -_080597D2: - adds r6, 0x1 - adds r4, 0xC - cmp r6, r7 - blt _0805977C -_080597DA: - movs r0, 0 -_080597DC: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_805973C - - thumb_func_start sub_80597EC -sub_80597EC: @ 80597EC - lsls r0, 16 - lsrs r0, 16 - lsls r1, 16 - lsrs r1, 16 - ldr r2, _08059804 @ =gSaveBlock1Ptr - ldr r2, [r2] - subs r0, 0x7 - strh r0, [r2] - subs r1, 0x7 - strh r1, [r2, 0x2] - bx lr - .align 2, 0 -_08059804: .4byte gSaveBlock1Ptr - thumb_func_end sub_80597EC - - thumb_func_start sav1_camera_get_focus_coords -sav1_camera_get_focus_coords: @ 8059808 - ldr r2, _0805981C @ =gSaveBlock1Ptr - ldr r3, [r2] - ldrh r2, [r3] - adds r2, 0x7 - strh r2, [r0] - ldrh r0, [r3, 0x2] - adds r0, 0x7 - strh r0, [r1] - bx lr - .align 2, 0 -_0805981C: .4byte gSaveBlock1Ptr - thumb_func_end sav1_camera_get_focus_coords - - thumb_func_start SetCameraCoords -SetCameraCoords: @ 8059820 - ldr r2, _0805982C @ =gSaveBlock1Ptr - ldr r2, [r2] - strh r0, [r2] - strh r1, [r2, 0x2] - bx lr - .align 2, 0 -_0805982C: .4byte gSaveBlock1Ptr - thumb_func_end SetCameraCoords - - thumb_func_start GetCameraCoords -GetCameraCoords: @ 8059830 - ldr r2, _08059840 @ =gSaveBlock1Ptr - ldr r3, [r2] - ldrh r2, [r3] - strh r2, [r0] - ldrh r0, [r3, 0x2] - strh r0, [r1] - bx lr - .align 2, 0 -_08059840: .4byte gSaveBlock1Ptr - thumb_func_end GetCameraCoords - - thumb_func_start copy_tileset_patterns_to_vram -copy_tileset_patterns_to_vram: @ 8059844 - push {r4-r7,lr} - sub sp, 0x4 - adds r3, r0, 0 - lsls r1, 16 - lsrs r4, r1, 16 - adds r6, r4, 0 - lsls r2, 16 - lsrs r5, r2, 16 - adds r7, r5, 0 - cmp r3, 0 - beq _08059880 - ldrb r0, [r3] - cmp r0, 0 - bne _08059870 - ldr r1, [r3, 0x4] - lsls r2, r4, 21 - lsrs r2, 16 - movs r0, 0x2 - adds r3, r5, 0 - bl LoadBgTiles - b _08059880 -_08059870: - ldr r1, [r3, 0x4] - lsls r2, r6, 5 - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - adds r3, r7, 0 - bl sub_80F68F0 -_08059880: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end copy_tileset_patterns_to_vram - - thumb_func_start copy_tileset_patterns_to_vram2 -copy_tileset_patterns_to_vram2: @ 8059888 - push {r4-r7,lr} - sub sp, 0x4 - adds r3, r0, 0 - lsls r1, 16 - lsrs r4, r1, 16 - adds r6, r4, 0 - lsls r2, 16 - lsrs r5, r2, 16 - adds r7, r5, 0 - cmp r3, 0 - beq _080598C4 - ldrb r0, [r3] - cmp r0, 0 - bne _080598B4 - ldr r1, [r3, 0x4] - lsls r2, r4, 21 - lsrs r2, 16 - movs r0, 0x2 - adds r3, r5, 0 - bl LoadBgTiles - b _080598C4 -_080598B4: - ldr r1, [r3, 0x4] - lsls r2, r6, 5 - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - adds r3, r7, 0 - bl sub_80F69E8 -_080598C4: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end copy_tileset_patterns_to_vram2 - - thumb_func_start sub_80598CC -sub_80598CC: @ 80598CC - push {r4,r5,lr} - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 16 - lsrs r5, r1, 16 - ldr r0, _080598EC @ =gUnknown_2036E28 - ldrb r0, [r0] - cmp r0, 0x1 - beq _080598F0 - cmp r0, 0x1 - ble _0805993A - cmp r0, 0x2 - beq _08059904 - cmp r0, 0x3 - beq _08059918 - b _0805993A - .align 2, 0 -_080598EC: .4byte gUnknown_2036E28 -_080598F0: - lsls r4, 1 - ldr r0, _08059900 @ =gPlttBufferUnfaded - adds r0, r4, r0 - adds r1, r5, 0 - bl TintPalette_GrayScale - b _0805992C - .align 2, 0 -_08059900: .4byte gPlttBufferUnfaded -_08059904: - lsls r4, 1 - ldr r0, _08059914 @ =gPlttBufferUnfaded - adds r0, r4, r0 - adds r1, r5, 0 - bl TintPalette_SepiaTone - b _0805992C - .align 2, 0 -_08059914: .4byte gPlttBufferUnfaded -_08059918: - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8111F38 - lsls r4, 1 - ldr r0, _08059940 @ =gPlttBufferUnfaded - adds r0, r4, r0 - adds r1, r5, 0 - bl TintPalette_GrayScale -_0805992C: - ldr r0, _08059940 @ =gPlttBufferUnfaded - adds r0, r4, r0 - ldr r1, _08059944 @ =gPlttBufferFaded - adds r1, r4, r1 - adds r2, r5, 0 - bl CpuSet -_0805993A: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08059940: .4byte gPlttBufferUnfaded -_08059944: .4byte gPlttBufferFaded - thumb_func_end sub_80598CC - thumb_func_start sub_8059948 sub_8059948: @ 8059948 push {r4-r6,lr} diff --git a/asm/overworld.s b/asm/overworld.s index a24fe7740..ad3b8820d 100644 --- a/asm/overworld.s +++ b/asm/overworld.s @@ -4690,7 +4690,7 @@ mli4_mapscripts_and_other: @ 805709C adds r4, 0x2 mov r0, sp adds r1, r4, 0 - bl sav1_camera_get_focus_coords + bl GetCameraFocusCoords bl sub_8055A6C adds r5, r0, 0 mov r0, sp @@ -4792,7 +4792,7 @@ sub_8057178: @ 8057178 adds r4, 0x2 mov r0, sp adds r1, r4, 0 - bl sav1_camera_get_focus_coords + bl GetCameraFocusCoords mov r2, sp ldr r0, _080571A4 @ =gUnknown_300502C ldrb r1, [r0] @@ -4801,7 +4801,7 @@ sub_8057178: @ 8057178 lsls r0, 16 lsrs r0, 16 ldrh r1, [r4] - bl sub_80597EC + bl SetCameraFocusCoords add sp, 0x4 pop {r4} pop {r0} @@ -4820,7 +4820,7 @@ sub_80571A8: @ 80571A8 adds r4, 0x2 mov r0, sp adds r1, r4, 0 - bl sav1_camera_get_focus_coords + bl GetCameraFocusCoords mov r3, sp mov r2, sp ldr r0, _08057224 @ =gUnknown_300502C @@ -6748,7 +6748,7 @@ _08058074: ldr r1, [r4, 0x8] str r0, [sp] str r1, [sp, 0x4] - ldr r3, _080580E4 @ =gUnknown_826D2D8 + ldr r3, _080580E4 @ =gDirectionToVectors ldrb r0, [r4, 0x3] lsls r0, 3 adds r0, r3 @@ -6801,7 +6801,7 @@ _080580E0: ldr r0, _080580F8 @ =gUnknown_81BB9A3 b _08058122 .align 2, 0 -_080580E4: .4byte gUnknown_826D2D8 +_080580E4: .4byte gDirectionToVectors _080580E8: .4byte 0xffff0000 _080580EC: .4byte 0x0000ffff _080580F0: .4byte 0xffffff00 diff --git a/data/data.s b/data/data.s index ea8705f46..dd692cb33 100644 --- a/data/data.s +++ b/data/data.s @@ -908,7 +908,7 @@ gUnknown_826D29E:: @ 826D29E gUnknown_826D2B0:: @ 826D2B0 .incbin "baserom.gba", 0x26D2B0, 0x28 -gUnknown_826D2D8:: @ 826D2D8 +gDirectionToVectors:: @ 826D2D8 .incbin "baserom.gba", 0x26D2D8, 0x48 gUnknown_826D320:: @ 826D320 diff --git a/include/fieldmap.h b/include/fieldmap.h index 016baf153..1ce83ee38 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -23,7 +23,7 @@ void MapGridSetMetatileEntryAt(int, int, u16); void GetCameraCoords(u16*, u16*); bool8 MapGridIsImpassableAt(s32, s32); s32 GetMapBorderIdAt(s32, s32); -bool32 CanCameraMoveInDirection(u8); +bool32 CanCameraMoveInDirection(s32); u32 GetBehaviorByMetatileIdAndMapData(struct MapData *mapData, u16 metatile, u8 attr); #endif //GUARD_FIELDMAP_H diff --git a/include/menu.h b/include/menu.h index b932693f7..b5078df5e 100644 --- a/include/menu.h +++ b/include/menu.h @@ -37,5 +37,6 @@ void clear_scheduled_bg_copies_to_vram(void); void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str); void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a2, u16 a3); void sub_810F4D8(u8 windowId, bool32 someBool); +void *sub_80F68F0(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); #endif // GUARD_MENU_H diff --git a/include/new_menu_helpers.h b/include/new_menu_helpers.h index ce8e8d697..32b46b552 100644 --- a/include/new_menu_helpers.h +++ b/include/new_menu_helpers.h @@ -22,5 +22,6 @@ void sub_80F6EE4(u8 windowId, bool8 transfer); void sub_80F7974(const u8 *); u8 GetStartMenuWindowId(void); void sub_80F7998(void); +void sub_80F69E8(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); #endif // GUARD_NEW_MENU_HELPERS_H diff --git a/include/overworld.h b/include/overworld.h index fbea3a4d9..b32d9cf48 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -24,6 +24,8 @@ struct UCoords32 u32 x, y; }; +extern struct UCoords32 gDirectionToVectors[]; + extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; extern MainCallback gFieldCallback; @@ -96,5 +98,6 @@ extern u8 gUnknown_2036E28; extern bool8 (* gUnknown_3005024)(void); void SetLastHealLocationWarp(u8 healLocaionId); +void sub_8055864(u8 mapGroup, u8 mapNum); #endif //GUARD_ROM4_H diff --git a/include/palette.h b/include/palette.h index 3af0d5d7b..31c8ffefe 100644 --- a/include/palette.h +++ b/include/palette.h @@ -70,6 +70,8 @@ void BeginHardwarePaletteFade(u8, u8, u8, u8, u8); void BlendPalettes(u32, u8, u16); void BlendPalettesUnfaded(u32, u8, u16); void sub_80716F8(const u16 *, u16 *, u16, u8); +void TintPalette_GrayScale(u16 *, u16); +void TintPalette_SepiaTone(u16 *, u16); extern struct PaletteFadeControl gPaletteFade; diff --git a/include/quest_log.h b/include/quest_log.h index 31220b86c..7f4bafada 100644 --- a/include/quest_log.h +++ b/include/quest_log.h @@ -24,6 +24,7 @@ void sub_8113550(u16, const u16 *); void sub_8115748(u16); u8 sub_8112CAC(void); bool8 sub_81119D4(void (*func)(void)); +void sub_8111F38(u16, u16); extern u8 gUnknown_203ADFA; diff --git a/src/fieldmap.c b/src/fieldmap.c index 06385ff35..559506829 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -1,6 +1,11 @@ #include "global.h" +#include "bg.h" +#include "palette.h" #include "overworld.h" #include "script.h" +#include "menu.h" +#include "new_menu_helpers.h" +#include "quest_log.h" #include "fieldmap.h" struct ConnectionFlags @@ -19,6 +24,9 @@ void fillNorthConnection(struct MapHeader const *mapHeader, struct MapHeader con void fillWestConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset); void fillEastConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset); void LoadSavedMapView(void); +struct MapConnection *sub_8059600(u8 direction, s32 x, s32 y); +bool8 sub_8059658(u8 direction, s32 x, s32 y, struct MapConnection *connection); +bool8 sub_80596BC(s32 x, s32 src_width, s32 dest_width, s32 offset); struct BackupMapData VMap; EWRAM_DATA u16 gBackupMapData[VIRTUAL_MAP_SIZE] = {}; @@ -395,7 +403,9 @@ union Block block; \ }) -#define MapGridGetTileAt(x, y) ((x >= 0 && x < VMap.Xsize && y >= 0 && y < VMap.Ysize) ? VMap.map[x + VMap.Xsize * y] : MapGridGetBorderTileAt2(x, y)) +#define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < VMap.Xsize && y >= 0 && y < VMap.Ysize) + +#define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? VMap.map[x + VMap.Xsize * y] : MapGridGetBorderTileAt2(x, y)) u8 MapGridGetZCoordAt(s32 x, s32 y) { @@ -679,3 +689,246 @@ s32 GetMapBorderIdAt(s32 x, s32 y) return 0; } + +s32 GetPostCameraMoveMapBorderId(s32 x, s32 y) +{ + return GetMapBorderIdAt(7 + gSaveBlock1Ptr->pos.x + x, 7 + gSaveBlock1Ptr->pos.y + y); +} + +bool32 CanCameraMoveInDirection(s32 direction) +{ + s32 x, y; + + x = gSaveBlock1Ptr->pos.x + 7 + gDirectionToVectors[direction].x; + y = gSaveBlock1Ptr->pos.y + 7 + gDirectionToVectors[direction].y; + if (GetMapBorderIdAt(x, y) == -1) + { + return FALSE; + } + return TRUE; +} + +void sub_80594AC(struct MapConnection *connection, int direction, s32 x, s32 y) +{ + struct MapHeader const *mapHeader; + mapHeader = mapconnection_get_mapheader(connection); + switch (direction) + { + case CONNECTION_EAST: + gSaveBlock1Ptr->pos.x = -x; + gSaveBlock1Ptr->pos.y -= connection->offset; + break; + case CONNECTION_WEST: + gSaveBlock1Ptr->pos.x = mapHeader->mapData->width; + gSaveBlock1Ptr->pos.y -= connection->offset; + break; + case CONNECTION_SOUTH: + gSaveBlock1Ptr->pos.x -= connection->offset; + gSaveBlock1Ptr->pos.y = -y; + break; + case CONNECTION_NORTH: + gSaveBlock1Ptr->pos.x -= connection->offset; + gSaveBlock1Ptr->pos.y = mapHeader->mapData->height; + break; + } +} + +bool8 CameraMove(s32 x, s32 y) +{ + u32 direction; + struct MapConnection *connection; + s32 old_x, old_y; + gCamera.active = FALSE; + direction = GetPostCameraMoveMapBorderId(x, y); + if (direction + 1 <= 1) + { + gSaveBlock1Ptr->pos.x += x; + gSaveBlock1Ptr->pos.y += y; + } + else + { + save_serialize_map(); + old_x = gSaveBlock1Ptr->pos.x; + old_y = gSaveBlock1Ptr->pos.y; + connection = sub_8059600(direction, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y); + sub_80594AC(connection, direction, x, y); + sub_8055864(connection->mapGroup, connection->mapNum); + gCamera.active = TRUE; + gCamera.x = old_x - gSaveBlock1Ptr->pos.x; + gCamera.y = old_y - gSaveBlock1Ptr->pos.y; + gSaveBlock1Ptr->pos.x += x; + gSaveBlock1Ptr->pos.y += y; + sub_8059250(direction); + } + return gCamera.active; +} + +struct MapConnection *sub_8059600(u8 direction, s32 x, s32 y) +{ + s32 count; + struct MapConnection *connection; + s32 i; + count = gMapHeader.connections->count; + connection = gMapHeader.connections->connections; + for (i = 0; i < count; i++, connection++) + { + if (connection->direction == direction && sub_8059658(direction, x, y, connection) == TRUE) + return connection; + } + return NULL; + +} + +bool8 sub_8059658(u8 direction, s32 x, s32 y, struct MapConnection *connection) +{ + struct MapHeader const *mapHeader; + mapHeader = mapconnection_get_mapheader(connection); + switch (direction) + { + case CONNECTION_SOUTH: + case CONNECTION_NORTH: + return sub_80596BC(x, gMapHeader.mapData->width, mapHeader->mapData->width, connection->offset); + case CONNECTION_WEST: + case CONNECTION_EAST: + return sub_80596BC(y, gMapHeader.mapData->height, mapHeader->mapData->height, connection->offset); + } + return FALSE; +} + +bool8 sub_80596BC(s32 x, s32 src_width, s32 dest_width, s32 offset) +{ + s32 offset2 = max(offset, 0); + + if (dest_width + offset < src_width) + src_width = dest_width + offset; + + if (offset2 <= x && x <= src_width) + return TRUE; + + return FALSE; +} + +bool32 sub_80596E8(s32 x, s32 width) +{ + if (x >= 0 && x < width) + return TRUE; + + return FALSE; +} + +s32 sub_80596FC(struct MapConnection *connection, s32 x, s32 y) +{ + struct MapHeader const *mapHeader; + mapHeader = mapconnection_get_mapheader(connection); + switch (connection->direction) + { + case CONNECTION_SOUTH: + case CONNECTION_NORTH: + return sub_80596E8(x - connection->offset, mapHeader->mapData->width); + case CONNECTION_WEST: + case CONNECTION_EAST: + return sub_80596E8(y - connection->offset, mapHeader->mapData->height); + } + return FALSE; +} + +struct MapConnection *sub_805973C(s16 x, s16 y) +{ + s32 count; + struct MapConnection *connection; + s32 i; + u8 direction; + if (!gMapHeader.connections) + { + return NULL; + } + else + { + count = gMapHeader.connections->count; + connection = gMapHeader.connections->connections; + for (i = 0; i < count; i++, connection++) + { + direction = connection->direction; + if ((direction == CONNECTION_DIVE || direction == CONNECTION_EMERGE) + || (direction == CONNECTION_NORTH && y > 6) + || (direction == CONNECTION_SOUTH && y < gMapHeader.mapData->height + 7) + || (direction == CONNECTION_WEST && x > 6) + || (direction == CONNECTION_EAST && x < gMapHeader.mapData->width + 7)) + { + continue; + } + if (sub_80596FC(connection, x - 7, y - 7) == TRUE) + { + return connection; + } + } + } + return NULL; +} + +void SetCameraFocusCoords(u16 x, u16 y) +{ + gSaveBlock1Ptr->pos.x = x - 7; + gSaveBlock1Ptr->pos.y = y - 7; +} + +void GetCameraFocusCoords(u16 *x, u16 *y) +{ + *x = gSaveBlock1Ptr->pos.x + 7; + *y = gSaveBlock1Ptr->pos.y + 7; +} + +void SetCameraCoords(u16 x, u16 y) +{ + gSaveBlock1Ptr->pos.x = x; + gSaveBlock1Ptr->pos.y = y; +} + +void GetCameraCoords(u16 *x, u16 *y) +{ + *x = gSaveBlock1Ptr->pos.x; + *y = gSaveBlock1Ptr->pos.y; +} +void copy_tileset_patterns_to_vram(struct Tileset const *tileset, u16 numTiles, u16 offset) +{ + if (tileset) + { + if (!tileset->isCompressed) + LoadBgTiles(2, tileset->tiles, numTiles * 32, offset); + else + sub_80F68F0(2, tileset->tiles, numTiles * 32, offset, 0); + } +} + +void copy_tileset_patterns_to_vram2(struct Tileset const *tileset, u16 numTiles, u16 offset) +{ + if (tileset) + { + if (!tileset->isCompressed) + LoadBgTiles(2, tileset->tiles, numTiles * 32, offset); + else + sub_80F69E8(2, tileset->tiles, numTiles * 32, offset, 0); + } +} + +void sub_80598CC(u16 a0, u16 a1) +{ + switch (gUnknown_2036E28) + { + case 0: + return; + case 1: + TintPalette_GrayScale(gPlttBufferUnfaded + a0, a1); + break; + case 2: + TintPalette_SepiaTone(gPlttBufferUnfaded + a0, a1); + break; + case 3: + sub_8111F38(a0, a1); + TintPalette_GrayScale(gPlttBufferUnfaded + a0, a1); + break; + default: + return; + } + CpuCopy16(gPlttBufferUnfaded + a0, gPlttBufferFaded + a0, a1 * sizeof(u16)); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index d108b01f3..82d492d61 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -599,7 +599,7 @@ gBackupMapData: @ 2031DFC gMapHeader: @ 2036DFC .space 0x1C -gUnknown_2036E18: @ 2036E18 +gCamera: @ 2036E18 .space 0xC gMapConnectionFlags: @ 2036E24 |