diff --git a/asm/field_camera.s b/asm/field_camera.s deleted file mode 100644 index 35359f444..000000000 --- a/asm/field_camera.s +++ /dev/null @@ -1,1153 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start move_tilemap_camera_to_upper_left_corner_ -@ void move_tilemap_camera_to_upper_left_corner_(struc_28 *a1) -move_tilemap_camera_to_upper_left_corner_: @ 8089B58 - movs r1, 0 - strb r1, [r0, 0x2] - strb r1, [r0, 0x3] - strb r1, [r0] - strb r1, [r0, 0x1] - movs r1, 0x1 - strb r1, [r0, 0x4] - bx lr - thumb_func_end move_tilemap_camera_to_upper_left_corner_ - - thumb_func_start tilemap_move_something -@ void tilemap_move_something(struct struc_28 *, u8 deltaX, u8 deltaY) -tilemap_move_something: @ 8089B68 - ldrb r3, [r0, 0x2] - adds r3, r1 - strb r3, [r0, 0x2] - ldrb r1, [r0, 0x2] - movs r3, 0x1F - ands r1, r3 - strb r1, [r0, 0x2] - ldrb r1, [r0, 0x3] - adds r1, r2 - strb r1, [r0, 0x3] - ldrb r1, [r0, 0x3] - ands r1, r3 - strb r1, [r0, 0x3] - bx lr - thumb_func_end tilemap_move_something - - thumb_func_start coords8_add -@ void coords8_add(struct coords8 *coords, u8 x, u8 y) -coords8_add: @ 8089B84 - ldrb r3, [r0] - adds r3, r1 - strb r3, [r0] - ldrb r1, [r0, 0x1] - adds r1, r2 - strb r1, [r0, 0x1] - bx lr - thumb_func_end coords8_add - - thumb_func_start move_tilemap_camera_to_upper_left_corner -@ void move_tilemap_camera_to_upper_left_corner() -move_tilemap_camera_to_upper_left_corner: @ 8089B94 - push {lr} - ldr r0, =gUnknown_03000E20 - bl move_tilemap_camera_to_upper_left_corner_ - pop {r0} - bx r0 - .pool - thumb_func_end move_tilemap_camera_to_upper_left_corner - - thumb_func_start FieldUpdateBgTilemapScroll -@ void FieldUpdateBgTilemapScroll() -FieldUpdateBgTilemapScroll: @ 8089BA4 - push {r4,r5,lr} - ldr r1, =gUnknown_03000E20 - ldr r0, =gUnknown_03000E28 - movs r2, 0 - ldrsh r5, [r0, r2] - ldrb r0, [r1] - adds r5, r0 - ldr r0, =gUnknown_03000E2A - movs r2, 0 - ldrsh r4, [r0, r2] - ldrb r1, [r1, 0x1] - adds r4, r1 - adds r4, 0x8 - lsls r5, 16 - lsrs r5, 16 - movs r0, 0x14 - adds r1, r5, 0 - bl SetGpuReg - lsls r4, 16 - lsrs r4, 16 - movs r0, 0x16 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x18 - adds r1, r5, 0 - bl SetGpuReg - movs r0, 0x1A - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x1C - adds r1, r5, 0 - bl SetGpuReg - movs r0, 0x1E - adds r1, r4, 0 - bl SetGpuReg - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end FieldUpdateBgTilemapScroll - - thumb_func_start sub_8089C08 -sub_8089C08: @ 8089C08 - push {r4,lr} - ldr r3, =gUnknown_03000E20 - ldr r2, =gUnknown_03000E28 - ldrh r2, [r2] - ldrb r4, [r3] - adds r2, r4 - strh r2, [r0] - ldr r0, =gUnknown_03000E2A - ldrh r0, [r0] - ldrb r3, [r3, 0x1] - adds r0, r3 - adds r0, 0x8 - strh r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8089C08 - - thumb_func_start DrawWholeMapView -@ void DrawWholeMapView() -DrawWholeMapView: @ 8089C34 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r2, 0 - ldrsh r0, [r1, r2] - movs r2, 0x2 - ldrsh r1, [r1, r2] - ldr r2, =gMapHeader - ldr r2, [r2] - bl DrawWholeMapViewInternal - ldr r1, =gUnknown_03000E20 - movs r0, 0x1 - strb r0, [r1, 0x4] - pop {r0} - bx r0 - .pool - thumb_func_end DrawWholeMapView - - thumb_func_start DrawWholeMapViewInternal -@ void DrawWholeMapViewInternal(s32 x, s32 y, struct mapdata_header *mapGrid) -DrawWholeMapViewInternal: @ 8089C60 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r10, r0 - mov r9, r1 - mov r8, r2 - movs r1, 0 -_08089C74: - ldr r2, =gUnknown_03000E20 - ldrb r0, [r2, 0x3] - adds r0, r1, r0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1F - bls _08089C88 - subs r0, 0x20 - lsls r0, 24 - lsrs r0, 24 -_08089C88: - lsls r6, r0, 5 - movs r4, 0 - adds r7, r1, 0x2 - str r7, [sp] - lsrs r5, r1, 1 -_08089C92: - ldr r1, =gUnknown_03000E20 - ldrb r0, [r1, 0x2] - adds r0, r4, r0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1F - bls _08089CA6 - subs r0, 0x20 - lsls r0, 24 - lsrs r0, 24 -_08089CA6: - adds r1, r6, r0 - lsls r1, 16 - lsrs r1, 16 - lsrs r2, r4, 1 - add r2, r10 - mov r0, r8 - mov r7, r9 - adds r3, r7, r5 - bl DrawMetatileAt - adds r0, r4, 0x2 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1F - bls _08089C92 - ldr r1, [sp] - lsls r0, r1, 24 - lsrs r1, r0, 24 - cmp r1, 0x1F - bls _08089C74 - 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 DrawWholeMapViewInternal - - thumb_func_start RedrawMapSlicesForCameraUpdate -@ void RedrawMapSlicesForCameraUpdate(struct struc_28 *, u8 deltaX, u8 deltaY) -RedrawMapSlicesForCameraUpdate: @ 8089CE4 - push {r4-r7,lr} - adds r5, r0, 0 - adds r6, r1, 0 - adds r7, r2, 0 - ldr r0, =gMapHeader - ldr r4, [r0] - cmp r6, 0 - ble _08089CFC - adds r0, r5, 0 - adds r1, r4, 0 - bl RedrawMapSliceWest -_08089CFC: - cmp r6, 0 - bge _08089D08 - adds r0, r5, 0 - adds r1, r4, 0 - bl RedrawMapSliceEast -_08089D08: - cmp r7, 0 - ble _08089D14 - adds r0, r5, 0 - adds r1, r4, 0 - bl RedrawMapSliceNorth -_08089D14: - cmp r7, 0 - bge _08089D20 - adds r0, r5, 0 - adds r1, r4, 0 - bl RedrawMapSliceSouth -_08089D20: - movs r0, 0x1 - strb r0, [r5, 0x4] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end RedrawMapSlicesForCameraUpdate - - thumb_func_start RedrawMapSliceNorth -@ void RedrawMapSliceNorth(struct struc_28 *, struct mapdata_header *mapGrid) -RedrawMapSliceNorth: @ 8089D30 - push {r4-r7,lr} - adds r5, r0, 0 - adds r7, r1, 0 - ldrb r0, [r5, 0x3] - adds r0, 0x1C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1F - bls _08089D48 - subs r0, 0x20 - lsls r0, 24 - lsrs r0, 24 -_08089D48: - lsls r6, r0, 5 - movs r4, 0 -_08089D4C: - ldrb r0, [r5, 0x2] - adds r0, r4, r0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1F - bls _08089D5E - subs r0, 0x20 - lsls r0, 24 - lsrs r0, 24 -_08089D5E: - adds r1, r6, r0 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =gSaveBlock1Ptr - ldr r3, [r0] - movs r0, 0 - ldrsh r2, [r3, r0] - lsrs r0, r4, 1 - adds r2, r0 - movs r0, 0x2 - ldrsh r3, [r3, r0] - adds r3, 0xE - adds r0, r7, 0 - bl DrawMetatileAt - adds r0, r4, 0x2 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1F - bls _08089D4C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end RedrawMapSliceNorth - - thumb_func_start RedrawMapSliceSouth -@ void RedrawMapSliceSouth(struct struc_28 *, struct mapdata_header *mapGrid) -RedrawMapSliceSouth: @ 8089D90 - push {r4-r7,lr} - adds r5, r0, 0 - adds r7, r1, 0 - ldrb r0, [r5, 0x3] - lsls r6, r0, 5 - movs r4, 0 -_08089D9C: - ldrb r0, [r5, 0x2] - adds r0, r4, r0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1F - bls _08089DAE - subs r0, 0x20 - lsls r0, 24 - lsrs r0, 24 -_08089DAE: - adds r1, r6, r0 - ldr r0, =gSaveBlock1Ptr - ldr r3, [r0] - movs r0, 0 - ldrsh r2, [r3, r0] - lsrs r0, r4, 1 - adds r2, r0 - movs r0, 0x2 - ldrsh r3, [r3, r0] - adds r0, r7, 0 - bl DrawMetatileAt - adds r0, r4, 0x2 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1F - bls _08089D9C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end RedrawMapSliceSouth - - thumb_func_start RedrawMapSliceEast -@ void RedrawMapSliceEast(struct struc_28 *, struct mapdata_header *mapGrid) -RedrawMapSliceEast: @ 8089DDC - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - mov r8, r1 - ldrb r6, [r5, 0x2] - movs r4, 0 -_08089DEA: - ldrb r0, [r5, 0x3] - adds r0, r4, r0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1F - bls _08089DFC - subs r0, 0x20 - lsls r0, 24 - lsrs r0, 24 -_08089DFC: - lsls r1, r0, 5 - adds r1, r6 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r3, 0 - ldrsh r2, [r0, r3] - movs r7, 0x2 - ldrsh r3, [r0, r7] - lsrs r0, r4, 1 - adds r3, r0 - mov r0, r8 - bl DrawMetatileAt - adds r0, r4, 0x2 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1F - bls _08089DEA - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end RedrawMapSliceEast - - thumb_func_start RedrawMapSliceWest -@ void RedrawMapSliceWest(struct struc_28 *, struct mapdata_header *mapGrid) -RedrawMapSliceWest: @ 8089E34 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - mov r8, r1 - ldrb r0, [r6, 0x2] - adds r0, 0x1C - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x1F - bls _08089E52 - adds r0, r5, 0 - subs r0, 0x20 - lsls r0, 24 - lsrs r5, r0, 24 -_08089E52: - movs r4, 0 -_08089E54: - ldrb r0, [r6, 0x3] - adds r0, r4, r0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1F - bls _08089E66 - subs r0, 0x20 - lsls r0, 24 - lsrs r0, 24 -_08089E66: - lsls r1, r0, 5 - adds r1, r5 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r3, 0 - ldrsh r2, [r0, r3] - adds r2, 0xE - movs r7, 0x2 - ldrsh r3, [r0, r7] - lsrs r0, r4, 1 - adds r3, r0 - mov r0, r8 - bl DrawMetatileAt - adds r0, r4, 0x2 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1F - bls _08089E54 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end RedrawMapSliceWest - - thumb_func_start CurrentMapDrawMetatileAt -@ void CurrentMapDrawMetatileAt(u32 x, u32 y) -CurrentMapDrawMetatileAt: @ 8089EA0 - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r6, =gUnknown_03000E20 - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl MapPosToBgTilemapOffset - adds r1, r0, 0 - cmp r1, 0 - blt _08089ECC - ldr r0, =gMapHeader - ldr r0, [r0] - lsls r1, 16 - lsrs r1, 16 - adds r2, r4, 0 - adds r3, r5, 0 - bl DrawMetatileAt - movs r0, 0x1 - strb r0, [r6, 0x4] -_08089ECC: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end CurrentMapDrawMetatileAt - - thumb_func_start DrawDoorMetatileAt -@ void DrawDoorMetatileAt(u32 x, u32 y, u16 *metatile) -DrawDoorMetatileAt: @ 8089EDC - push {r4-r6,lr} - adds r3, r0, 0 - adds r4, r1, 0 - adds r5, r2, 0 - ldr r6, =gUnknown_03000E20 - adds r0, r6, 0 - adds r1, r3, 0 - adds r2, r4, 0 - bl MapPosToBgTilemapOffset - cmp r0, 0 - blt _08089F04 - lsls r2, r0, 16 - lsrs r2, 16 - movs r0, 0x1 - adds r1, r5, 0 - bl DrawMetatile - movs r0, 0x1 - strb r0, [r6, 0x4] -_08089F04: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end DrawDoorMetatileAt - - thumb_func_start DrawMetatileAt -@ void DrawMetatileAt(struct mapdata_header *mapGrid, u16 offset, s32 x, s32 y) -DrawMetatileAt: @ 8089F10 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - adds r6, r2, 0 - adds r7, r3, 0 - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - adds r0, r6, 0 - adds r1, r7, 0 - bl MapGridGetMetatileIdAt - lsls r0, 16 - lsrs r4, r0, 16 - movs r0, 0x80 - lsls r0, 3 - cmp r4, r0 - bls _08089F38 - movs r4, 0 -_08089F38: - ldr r0, =0x000001ff - cmp r4, r0 - bhi _08089F48 - ldr r0, [r5, 0x10] - ldr r5, [r0, 0xC] - b _08089F54 - .pool -_08089F48: - ldr r0, [r5, 0x14] - ldr r5, [r0, 0xC] - ldr r1, =0xfffffe00 - adds r0, r4, r1 - lsls r0, 16 - lsrs r4, r0, 16 -_08089F54: - adds r0, r6, 0 - adds r1, r7, 0 - bl MapGridGetMetatileLayerTypeAt - lsls r0, 24 - lsrs r0, 24 - lsls r1, r4, 4 - adds r1, r5, r1 - mov r2, r8 - bl DrawMetatile - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end DrawMetatileAt - - thumb_func_start DrawMetatile -@ void DrawMetatile(u32 layerType, u16 *metatile, u16 offset) -DrawMetatile: @ 8089F78 - push {r4,lr} - adds r4, r1, 0 - lsls r2, 16 - lsrs r2, 16 - cmp r0, 0x1 - beq _08089FD0 - cmp r0, 0x1 - bgt _08089F8E - cmp r0, 0 - beq _0808A030 - b _0808A082 -_08089F8E: - cmp r0, 0x2 - bne _0808A082 - ldr r0, =gUnknown_03005DA4 - ldr r0, [r0] - lsls r3, r2, 1 - adds r0, r3, r0 - ldrh r1, [r4] - strh r1, [r0] - ldrh r1, [r4, 0x2] - strh r1, [r0, 0x2] - adds r2, r0, 0 - adds r2, 0x40 - ldrh r1, [r4, 0x4] - strh r1, [r2] - adds r0, 0x42 - ldrh r1, [r4, 0x6] - strh r1, [r0] - ldr r0, =gUnknown_03005D9C - ldr r0, [r0] - adds r0, r3, r0 - movs r2, 0 - strh r2, [r0] - strh r2, [r0, 0x2] - adds r1, r0, 0 - adds r1, 0x40 - strh r2, [r1] - adds r0, 0x42 - strh r2, [r0] - b _0808A066 - .pool -_08089FD0: - ldr r0, =gUnknown_03005DA4 - ldr r0, [r0] - lsls r3, r2, 1 - adds r0, r3, r0 - ldrh r1, [r4] - strh r1, [r0] - ldrh r1, [r4, 0x2] - strh r1, [r0, 0x2] - adds r2, r0, 0 - adds r2, 0x40 - ldrh r1, [r4, 0x4] - strh r1, [r2] - adds r0, 0x42 - ldrh r1, [r4, 0x6] - strh r1, [r0] - ldr r0, =gUnknown_03005D9C - ldr r0, [r0] - adds r0, r3, r0 - ldrh r1, [r4, 0x8] - strh r1, [r0] - ldrh r1, [r4, 0xA] - strh r1, [r0, 0x2] - adds r2, r0, 0 - adds r2, 0x40 - ldrh r1, [r4, 0xC] - strh r1, [r2] - adds r0, 0x42 - ldrh r1, [r4, 0xE] - strh r1, [r0] - ldr r0, =gUnknown_03005DA0 - ldr r0, [r0] - adds r3, r0 - movs r1, 0 - strh r1, [r3] - strh r1, [r3, 0x2] - adds r0, r3, 0 - adds r0, 0x40 - strh r1, [r0] - adds r3, 0x42 - strh r1, [r3] - b _0808A082 - .pool -_0808A030: - ldr r0, =gUnknown_03005DA4 - ldr r0, [r0] - lsls r3, r2, 1 - adds r0, r3, r0 - ldr r1, =0x00003014 - adds r2, r1, 0 - strh r2, [r0] - strh r2, [r0, 0x2] - adds r1, r0, 0 - adds r1, 0x40 - strh r2, [r1] - adds r0, 0x42 - strh r2, [r0] - ldr r0, =gUnknown_03005D9C - ldr r0, [r0] - adds r0, r3, r0 - ldrh r1, [r4] - strh r1, [r0] - ldrh r1, [r4, 0x2] - strh r1, [r0, 0x2] - adds r2, r0, 0 - adds r2, 0x40 - ldrh r1, [r4, 0x4] - strh r1, [r2] - adds r0, 0x42 - ldrh r1, [r4, 0x6] - strh r1, [r0] -_0808A066: - ldr r0, =gUnknown_03005DA0 - ldr r0, [r0] - adds r3, r0 - ldrh r0, [r4, 0x8] - strh r0, [r3] - ldrh r0, [r4, 0xA] - strh r0, [r3, 0x2] - adds r1, r3, 0 - adds r1, 0x40 - ldrh r0, [r4, 0xC] - strh r0, [r1] - adds r3, 0x42 - ldrh r0, [r4, 0xE] - strh r0, [r3] -_0808A082: - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x3 - bl schedule_bg_copy_tilemap_to_vram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end DrawMetatile - - thumb_func_start MapPosToBgTilemapOffset -@ u32 MapPosToBgTilemapOffset(struct struc_28 *, u32 x, u32 y) -MapPosToBgTilemapOffset: @ 808A0AC - push {r4,r5,lr} - adds r4, r0, 0 - ldr r0, =gSaveBlock1Ptr - ldr r3, [r0] - movs r5, 0 - ldrsh r0, [r3, r5] - subs r1, r0 - lsls r1, 1 - cmp r1, 0x1F - bhi _0808A0D6 - ldrb r0, [r4, 0x2] - adds r1, r0 - cmp r1, 0x1F - ble _0808A0CA - subs r1, 0x20 -_0808A0CA: - movs r5, 0x2 - ldrsh r0, [r3, r5] - subs r0, r2, r0 - lsls r2, r0, 1 - cmp r2, 0x1F - bls _0808A0E0 -_0808A0D6: - movs r0, 0x1 - negs r0, r0 - b _0808A0EE - .pool -_0808A0E0: - ldrb r0, [r4, 0x3] - adds r2, r0 - cmp r2, 0x1F - ble _0808A0EA - subs r2, 0x20 -_0808A0EA: - lsls r0, r2, 5 - adds r0, r1 -_0808A0EE: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end MapPosToBgTilemapOffset - - thumb_func_start CameraUpdateCallback -@ void CameraUpdateCallback(struct CameraUpdateInfo *info) -CameraUpdateCallback: @ 808A0F4 - push {lr} - adds r3, r0, 0 - ldr r2, [r3, 0x4] - cmp r2, 0 - beq _0808A114 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - movs r2, 0x32 - ldrsh r1, [r0, r2] - str r1, [r3, 0x8] - movs r1, 0x34 - ldrsh r0, [r0, r1] - str r0, [r3, 0xC] -_0808A114: - pop {r0} - bx r0 - .pool - thumb_func_end CameraUpdateCallback - - thumb_func_start ResetCameraUpdateInfo -@ void ResetCameraUpdateInfo() -ResetCameraUpdateInfo: @ 808A11C - ldr r1, =gUnknown_03005DD0 - movs r0, 0 - str r0, [r1, 0x8] - str r0, [r1, 0xC] - str r0, [r1, 0x10] - str r0, [r1, 0x14] - str r0, [r1, 0x4] - str r0, [r1] - bx lr - .pool - thumb_func_end ResetCameraUpdateInfo - - thumb_func_start InitCameraUpdateCallback -@ u8 InitCameraUpdateCallback(u8 followedObjectId) -InitCameraUpdateCallback: @ 808A134 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gUnknown_03005DD0 - ldr r1, [r4, 0x4] - cmp r1, 0 - beq _0808A150 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl DestroySprite -_0808A150: - adds r0, r5, 0 - bl AddCameraObject - lsls r0, 24 - lsrs r0, 24 - str r0, [r4, 0x4] - ldr r0, =CameraUpdateCallback - str r0, [r4] - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end InitCameraUpdateCallback - - thumb_func_start CameraUpdate -@ void CameraUpdate() -CameraUpdate: @ 808A174 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r6, =gUnknown_03005DD0 - ldr r1, [r6] - cmp r1, 0 - beq _0808A188 - adds r0, r6, 0 - bl _call_via_r1 -_0808A188: - ldr r7, [r6, 0x8] - ldr r0, [r6, 0xC] - mov r8, r0 - movs r4, 0 - movs r5, 0 - ldr r1, [r6, 0x10] - ldr r0, [r6, 0x14] - cmp r1, 0 - bne _0808A1A6 - cmp r7, 0 - beq _0808A1A6 - subs r4, 0x1 - cmp r7, 0 - ble _0808A1A6 - movs r4, 0x1 -_0808A1A6: - cmp r0, 0 - bne _0808A1BA - mov r2, r8 - cmp r2, 0 - beq _0808A1BA - movs r5, 0x1 - negs r5, r5 - cmp r2, 0 - ble _0808A1BA - movs r5, 0x1 -_0808A1BA: - cmp r1, 0 - beq _0808A1CC - cmn r1, r7 - bne _0808A1CC - movs r4, 0x1 - negs r4, r4 - cmp r7, 0 - ble _0808A1CC - movs r4, 0x1 -_0808A1CC: - cmp r0, 0 - beq _0808A1E0 - mov r3, r8 - cmn r0, r3 - bne _0808A1E0 - movs r4, 0x1 - negs r4, r4 - cmp r3, 0 - ble _0808A1E0 - movs r4, 0x1 -_0808A1E0: - ldr r2, =gUnknown_03005DD0 - ldr r0, [r2, 0x10] - adds r1, r0, r7 - str r1, [r2, 0x10] - adds r0, r1, 0 - cmp r1, 0 - bge _0808A1F0 - adds r0, 0xF -_0808A1F0: - asrs r0, 4 - lsls r0, 4 - subs r0, r1, r0 - str r0, [r2, 0x10] - ldr r0, [r2, 0x14] - mov r3, r8 - adds r1, r0, r3 - str r1, [r2, 0x14] - adds r0, r1, 0 - cmp r1, 0 - bge _0808A208 - adds r0, 0xF -_0808A208: - asrs r0, 4 - lsls r0, 4 - subs r0, r1, r0 - str r0, [r2, 0x14] - cmp r4, 0 - bne _0808A218 - cmp r5, 0 - beq _0808A24E -_0808A218: - adds r0, r4, 0 - adds r1, r5, 0 - bl CameraMove - adds r0, r4, 0 - adds r1, r5, 0 - bl UpdateFieldObjectsForCameraUpdate - adds r0, r4, 0 - adds r1, r5, 0 - bl RotatingGatePuzzleCameraUpdate - bl ResetBerryTreeSparkleFlags - ldr r6, =gUnknown_03000E20 - lsls r4, 1 - lsls r5, 1 - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl tilemap_move_something - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl RedrawMapSlicesForCameraUpdate -_0808A24E: - ldr r0, =gUnknown_03000E20 - adds r1, r7, 0 - mov r2, r8 - bl coords8_add - ldr r1, =gUnknown_03005DEC - ldrh r0, [r1] - subs r0, r7 - strh r0, [r1] - ldr r1, =gUnknown_03005DE8 - ldrh r0, [r1] - mov r2, r8 - subs r0, r2 - strh r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end CameraUpdate - - thumb_func_start sub_808A284 -sub_808A284: @ 808A284 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl CameraMove - lsls r0, r4, 16 - asrs r0, 16 - lsls r1, r5, 16 - asrs r1, 16 - bl UpdateFieldObjectsForCameraUpdate - bl DrawWholeMapView - ldr r1, =gUnknown_03005DEC - lsls r4, 4 - ldrh r0, [r1] - subs r0, r4 - strh r0, [r1] - ldr r1, =gUnknown_03005DE8 - lsls r5, 4 - ldrh r0, [r1] - subs r0, r5 - strh r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808A284 - - thumb_func_start SetCameraPanningCallback -@ void SetCameraPanningCallback(void ( *callback)()) -SetCameraPanningCallback: @ 808A2C0 - ldr r1, =gUnknown_03000E30 - str r0, [r1] - bx lr - .pool - thumb_func_end SetCameraPanningCallback - - thumb_func_start SetCameraPanning -@ void SetCameraPanning(s16 x, s16 y) -SetCameraPanning: @ 808A2CC - ldr r2, =gUnknown_03000E28 - strh r0, [r2] - ldr r0, =gUnknown_03000E2A - lsls r1, 16 - asrs r1, 16 - adds r1, 0x20 - strh r1, [r0] - bx lr - .pool - thumb_func_end SetCameraPanning - - thumb_func_start InstallCameraPanAheadCallback -@ void InstallCameraPanAheadCallback() -InstallCameraPanAheadCallback: @ 808A2E4 - ldr r1, =gUnknown_03000E30 - ldr r0, =CameraPanningCB_PanAhead - str r0, [r1] - ldr r1, =gUnknown_03000E2C - movs r0, 0 - strb r0, [r1] - ldr r1, =gUnknown_03000E28 - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_03000E2A - movs r0, 0x20 - strh r0, [r1] - bx lr - .pool - thumb_func_end InstallCameraPanAheadCallback - - thumb_func_start UpdateCameraPanning -@ void UpdateCameraPanning() -UpdateCameraPanning: @ 808A314 - push {lr} - ldr r0, =gUnknown_03000E30 - ldr r0, [r0] - cmp r0, 0 - beq _0808A322 - bl _call_via_r0 -_0808A322: - ldr r2, =gSpriteCoordOffsetX - ldr r0, =gUnknown_03005DEC - ldr r1, =gUnknown_03000E28 - ldrh r0, [r0] - ldrh r1, [r1] - subs r0, r1 - strh r0, [r2] - ldr r2, =gSpriteCoordOffsetY - ldr r0, =gUnknown_03005DE8 - ldr r1, =gUnknown_03000E2A - ldrh r0, [r0] - ldrh r1, [r1] - subs r0, r1 - subs r0, 0x8 - strh r0, [r2] - pop {r0} - bx r0 - .pool - thumb_func_end UpdateCameraPanning - - thumb_func_start CameraPanningCB_PanAhead -@ void CameraPanningCB_PanAhead() -CameraPanningCB_PanAhead: @ 808A360 - push {lr} - ldr r0, =gUnknown_02037348 - ldrb r0, [r0] - cmp r0, 0 - bne _0808A374 - bl InstallCameraPanAheadCallback - b _0808A3FC - .pool -_0808A374: - ldr r0, =gPlayerAvatar - ldrb r0, [r0, 0x3] - cmp r0, 0x1 - bne _0808A394 - ldr r0, =gUnknown_03000E2C - ldrb r1, [r0] - movs r2, 0x1 - eors r1, r2 - strb r1, [r0] - cmp r1, 0 - beq _0808A3FC - b _0808A39A - .pool -_0808A394: - ldr r1, =gUnknown_03000E2C - movs r0, 0 - strb r0, [r1] -_0808A39A: - bl player_get_direction_upper_nybble - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808A3C4 - ldr r2, =gUnknown_03000E2A - ldrh r3, [r2] - movs r0, 0 - ldrsh r1, [r2, r0] - movs r0, 0x8 - negs r0, r0 - cmp r1, r0 - ble _0808A3FC - subs r0, r3, 0x2 - b _0808A3FA - .pool -_0808A3C4: - cmp r0, 0x1 - bne _0808A3E0 - ldr r1, =gUnknown_03000E2A - ldrh r2, [r1] - movs r3, 0 - ldrsh r0, [r1, r3] - cmp r0, 0x47 - bgt _0808A3FC - adds r0, r2, 0x2 - strh r0, [r1] - b _0808A3FC - .pool -_0808A3E0: - ldr r2, =gUnknown_03000E2A - ldrh r0, [r2] - movs r3, 0 - ldrsh r1, [r2, r3] - cmp r1, 0x1F - bgt _0808A3F4 - adds r0, 0x2 - b _0808A3FA - .pool -_0808A3F4: - cmp r1, 0x20 - ble _0808A3FC - subs r0, 0x2 -_0808A3FA: - strh r0, [r2] -_0808A3FC: - pop {r0} - bx r0 - thumb_func_end CameraPanningCB_PanAhead - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/field_player_avatar.s b/asm/field_player_avatar.s index cd4f83681..f5acc1e3e 100644 --- a/asm/field_player_avatar.s +++ b/asm/field_player_avatar.s @@ -1071,7 +1071,7 @@ sub_808B164: @ 808B164 adds r0, r6, 0 adds r1, r5, 0 adds r2, r4, 0 - bl sub_80FBFD4 + bl CheckForRotatingGatePuzzleCollisionWithoutAnimation cmp r0, 0 beq _0808B1A2 movs r0, 0x8 diff --git a/asm/mon_markings.s b/asm/mon_markings.s deleted file mode 100644 index dfc375fdf..000000000 --- a/asm/mon_markings.s +++ /dev/null @@ -1,946 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_811F90C -sub_811F90C: @ 811F90C - ldr r1, =gUnknown_0203A124 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_811F90C - - thumb_func_start sub_811F918 -sub_811F918: @ 811F918 - push {lr} - sub sp, 0x4 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x14] - lsrs r0, 3 - bl GetWindowFrameTilesPal - ldr r3, =gUnknown_0203A124 - ldr r2, [r3] - ldr r1, [r0] - str r1, [r2, 0x2C] - ldr r0, [r0, 0x4] - str r0, [r2, 0x30] - ldr r0, =0x000010b4 - adds r2, r0 - movs r1, 0 - strb r1, [r2] - mov r0, sp - strh r1, [r0] - ldr r1, [r3] - adds r1, 0x34 - ldr r2, =0x01000800 - bl CpuSet - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_811F918 - - thumb_func_start sub_811F960 -sub_811F960: @ 811F960 - push {r4-r7,lr} - ldr r0, =gUnknown_0203A124 - ldr r1, [r0] - ldr r2, =0x000010b4 - adds r0, r1, r2 - ldrb r2, [r0] - lsls r0, r2, 8 - adds r0, 0x34 - adds r5, r1, r0 - cmp r2, 0xD - beq _0811FA30 - cmp r2, 0xD - bgt _0811F988 - cmp r2, 0 - beq _0811F98E - b _0811F9D8 - .pool -_0811F988: - cmp r2, 0xE - beq _0811FA7C - b _0811F9D8 -_0811F98E: - ldr r0, [r1, 0x2C] - adds r1, r5, 0 - movs r2, 0x8 - bl CpuFastSet - movs r4, 0 - adds r7, r5, 0 - adds r7, 0xE0 -_0811F99E: - ldr r6, =gUnknown_0203A124 - ldr r0, [r6] - ldr r0, [r0, 0x2C] - adds r0, 0x20 - adds r4, 0x1 - lsls r1, r4, 5 - adds r1, r5, r1 - movs r2, 0x8 - bl CpuFastSet - lsls r4, 16 - lsrs r4, 16 - cmp r4, 0x5 - bls _0811F99E - ldr r0, [r6] - ldr r0, [r0, 0x2C] - adds r0, 0x40 - adds r1, r7, 0 - movs r2, 0x8 - bl CpuFastSet - ldr r1, [r6] - ldr r0, =0x000010b4 - adds r1, r0 - b _0811FA1E - .pool -_0811F9D8: - ldr r0, =gUnknown_0203A124 - ldr r0, [r0] - ldr r0, [r0, 0x2C] - adds r0, 0x60 - adds r1, r5, 0 - movs r2, 0x8 - bl CpuFastSet - movs r4, 0 - adds r7, r5, 0 - adds r7, 0xE0 -_0811F9EE: - ldr r6, =gUnknown_0203A124 - ldr r0, [r6] - ldr r0, [r0, 0x2C] - adds r0, 0x80 - adds r4, 0x1 - lsls r1, r4, 5 - adds r1, r5, r1 - movs r2, 0x8 - bl CpuFastSet - lsls r4, 16 - lsrs r4, 16 - cmp r4, 0x5 - bls _0811F9EE - ldr r0, [r6] - ldr r0, [r0, 0x2C] - adds r0, 0xA0 - adds r1, r7, 0 - movs r2, 0x8 - bl CpuFastSet - ldr r1, [r6] - ldr r2, =0x000010b4 - adds r1, r2 -_0811FA1E: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0811FA88 - .pool -_0811FA30: - ldr r0, [r1, 0x2C] - adds r0, 0xC0 - adds r1, r5, 0 - movs r2, 0x8 - bl CpuFastSet - movs r4, 0 - adds r7, r5, 0 - adds r7, 0xE0 -_0811FA42: - ldr r6, =gUnknown_0203A124 - ldr r0, [r6] - ldr r0, [r0, 0x2C] - adds r0, 0xE0 - adds r4, 0x1 - lsls r1, r4, 5 - adds r1, r5, r1 - movs r2, 0x8 - bl CpuFastSet - lsls r4, 16 - lsrs r4, 16 - cmp r4, 0x5 - bls _0811FA42 - ldr r0, [r6] - ldr r0, [r0, 0x2C] - movs r1, 0x80 - lsls r1, 1 - adds r0, r1 - adds r1, r7, 0 - movs r2, 0x8 - bl CpuFastSet - ldr r1, [r6] - ldr r2, =0x000010b4 - adds r1, r2 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0811FA7C: - movs r0, 0 - b _0811FA8A - .pool -_0811FA88: - movs r0, 0x1 -_0811FA8A: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_811F960 - - thumb_func_start sub_811FA90 -sub_811FA90: @ 811FA90 - push {lr} - bl sub_811F918 -_0811FA96: - bl sub_811F960 - lsls r0, 24 - cmp r0, 0 - bne _0811FA96 - pop {r0} - bx r0 - thumb_func_end sub_811FA90 - - thumb_func_start sub_811FAA4 -sub_811FAA4: @ 811FAA4 - push {r4-r7,lr} - lsls r1, 16 - lsrs r5, r1, 16 - lsls r2, 16 - lsrs r6, r2, 16 - ldr r2, =gUnknown_0203A124 - ldr r3, [r2] - movs r1, 0 - strb r1, [r3, 0x5] - ldr r1, [r2] - strb r0, [r1, 0x4] - movs r3, 0 - adds r7, r2, 0 - adds r4, r7, 0 - movs r2, 0x1 -_0811FAC2: - ldr r0, [r4] - adds r1, r0, 0x6 - adds r1, r3 - ldrb r0, [r0, 0x4] - asrs r0, r3 - ands r0, r2 - strb r0, [r1] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x3 - bls _0811FAC2 - lsls r0, r5, 16 - asrs r0, 16 - lsls r1, r6, 16 - asrs r1, 16 - ldr r3, [r7] - ldrh r2, [r3] - ldrh r3, [r3, 0x2] - bl sub_811FC80 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811FAA4 - - thumb_func_start sub_811FAF8 -sub_811FAF8: @ 811FAF8 - push {r4-r7,lr} - movs r5, 0 - ldr r4, =gUnknown_0203A124 -_0811FAFE: - ldr r0, [r4] - ldrh r0, [r0] - adds r0, r5, r0 - lsls r0, 16 - lsrs r0, 16 - bl FreeSpriteTilesByTag - ldr r0, [r4] - ldrh r0, [r0, 0x2] - adds r0, r5, r0 - lsls r0, 16 - lsrs r0, 16 - bl FreeSpritePaletteByTag - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x1 - bls _0811FAFE - movs r5, 0 - ldr r6, =gUnknown_0203A124 -_0811FB28: - ldr r0, [r6] - lsls r4, r5, 2 - adds r0, 0xC - adds r0, r4 - ldr r0, [r0] - cmp r0, 0 - beq _0811FB9A - bl DestroySprite - ldr r0, [r6] - adds r0, 0xC - adds r0, r4 - movs r1, 0 - str r1, [r0] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x1 - bls _0811FB28 - movs r5, 0 - ldr r6, =gUnknown_0203A124 -_0811FB52: - ldr r0, [r6] - lsls r4, r5, 2 - adds r0, 0x14 - adds r0, r4 - ldr r0, [r0] - cmp r0, 0 - beq _0811FB9A - bl DestroySprite - ldr r0, [r6] - adds r0, 0x14 - adds r0, r4 - movs r7, 0 - str r7, [r0] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x3 - bls _0811FB52 - ldr r4, =gUnknown_0203A124 - ldr r0, [r4] - ldr r0, [r0, 0x24] - cmp r0, 0 - beq _0811FB8A - bl DestroySprite - ldr r0, [r4] - str r7, [r0, 0x24] -_0811FB8A: - ldr r0, [r4] - ldr r0, [r0, 0x28] - cmp r0, 0 - beq _0811FB9A - bl DestroySprite - ldr r0, [r4] - str r7, [r0, 0x28] -_0811FB9A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811FAF8 - - thumb_func_start sub_811FBA4 -sub_811FBA4: @ 811FBA4 - push {r4,r5,lr} - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0 - beq _0811FBDC - movs r0, 0x5 - bl PlaySE - ldr r2, =gUnknown_0203A124 - ldr r1, [r2] - ldrb r0, [r1, 0x5] - subs r0, 0x1 - strb r0, [r1, 0x5] - lsls r0, 24 - cmp r0, 0 - bge _0811FC64 - ldr r1, [r2] - movs r0, 0x5 - strb r0, [r1, 0x5] - b _0811FC64 - .pool -_0811FBDC: - movs r0, 0x80 - ands r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _0811FC0C - movs r0, 0x5 - bl PlaySE - ldr r2, =gUnknown_0203A124 - ldr r1, [r2] - ldrb r0, [r1, 0x5] - adds r0, 0x1 - strb r0, [r1, 0x5] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x5 - ble _0811FC64 - ldr r0, [r2] - strb r5, [r0, 0x5] - b _0811FC64 - .pool -_0811FC0C: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0811FC68 - movs r0, 0x5 - bl PlaySE - ldr r2, =gUnknown_0203A124 - ldr r0, [r2] - movs r1, 0x5 - ldrsb r1, [r0, r1] - cmp r1, 0x4 - beq _0811FC40 - cmp r1, 0x5 - beq _0811FC76 - adds r0, 0x6 - adds r1, r0, r1 - movs r2, 0 - ldrb r0, [r1] - cmp r0, 0 - bne _0811FC62 - movs r2, 0x1 - b _0811FC62 - .pool -_0811FC40: - strb r4, [r0, 0x4] - movs r3, 0 - adds r4, r2, 0 -_0811FC46: - ldr r2, [r4] - adds r0, r2, 0x6 - adds r0, r3 - ldrb r0, [r0] - lsls r0, r3 - ldrb r1, [r2, 0x4] - orrs r0, r1 - strb r0, [r2, 0x4] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x3 - bls _0811FC46 - b _0811FC76 -_0811FC62: - strb r2, [r1] -_0811FC64: - movs r0, 0x1 - b _0811FC78 -_0811FC68: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0811FC64 - movs r0, 0x5 - bl PlaySE -_0811FC76: - movs r0, 0 -_0811FC78: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_811FBA4 - - thumb_func_start sub_811FC80 -sub_811FC80: @ 811FC80 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x50 - mov r8, r0 - mov r9, r1 - adds r5, r2, 0 - adds r6, r3, 0 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r1, 16 - lsrs r1, 16 - mov r9, r1 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 16 - lsrs r6, 16 - ldr r4, =gUnknown_0203A124 - ldr r0, [r4] - adds r0, 0x34 - str r0, [sp, 0x18] - add r1, sp, 0x1C - movs r7, 0 - movs r0, 0x80 - lsls r0, 5 - strh r0, [r1] - mov r0, sp - adds r0, 0x1E - strh r5, [r0] - add r1, sp, 0x20 - ldr r0, =gPokenavConditionMarker_Gfx - str r0, [sp, 0x20] - movs r0, 0xC8 - lsls r0, 2 - strh r0, [r1, 0x4] - adds r0, r5, 0x1 - strh r0, [r1, 0x6] - add r0, sp, 0x28 - movs r1, 0 - movs r2, 0x8 - bl memset - add r2, sp, 0x18 - mov r10, r2 - mov r0, sp - mov r1, r10 - movs r2, 0x18 - bl memcpy - ldr r0, [r4] - ldr r0, [r0, 0x30] - str r0, [sp, 0x30] - add r0, sp, 0x34 - strh r6, [r0] - add r1, sp, 0x38 - ldr r0, =gPokenavConditionMarker_Pal - str r0, [sp, 0x38] - adds r0, r6, 0x1 - strh r0, [r1, 0x4] - add r0, sp, 0x40 - movs r1, 0 - movs r2, 0x8 - bl memset - add r4, sp, 0x30 - mov r0, r10 - adds r1, r4, 0 - movs r2, 0x18 - bl memcpy - strh r5, [r4] - strh r6, [r4, 0x2] - ldr r0, =gUnknown_0859EE7C - str r0, [r4, 0x4] - ldr r0, =gUnknown_0859EF14 - str r0, [r4, 0x8] - str r7, [r4, 0xC] - ldr r0, =gDummySpriteAffineAnimTable - str r0, [r4, 0x10] - ldr r0, =TaskDummy7 - str r0, [r4, 0x14] - mov r0, sp - bl LoadSpriteSheets - mov r0, r10 - bl LoadSpritePalettes - movs r5, 0 - mov r3, r8 - lsls r3, 16 - mov r8, r3 - movs r0, 0x80 - lsls r0, 14 - add r0, r8 - mov r10, r0 - mov r1, r8 - str r1, [sp, 0x48] - mov r2, r9 - lsls r2, 16 - mov r9, r2 - movs r7, 0x80 - lsls r7, 14 - add r7, r9 - mov r3, r9 - str r3, [sp, 0x4C] -_0811FD58: - adds r0, r4, 0 - mov r2, r10 - asrs r1, r2, 16 - asrs r2, r7, 16 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x40 - bne _0811FD70 - b _0811FEFC -_0811FD70: - ldr r6, =gUnknown_0203A124 - ldr r2, [r6] - lsls r0, r5, 2 - adds r2, 0xC - adds r2, r0 - lsls r0, r3, 4 - adds r0, r3 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r2] - lsls r1, r5, 24 - lsrs r1, 24 - bl StartSpriteAnim - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x1 - bls _0811FD58 - ldr r0, [r6] - ldr r1, [r0, 0x10] - ldr r3, [sp, 0x4C] - asrs r0, r3, 16 - adds r0, 0x60 - strh r0, [r1, 0x22] - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - ldrh r0, [r4, 0x2] - adds r0, 0x1 - strh r0, [r4, 0x2] - ldr r0, =gUnknown_0859EEDC - str r0, [r4, 0x8] - ldr r0, =sub_811FF40 - str r0, [r4, 0x14] - ldr r0, =gUnknown_0859EE84 - str r0, [r4, 0x4] - movs r5, 0 - ldr r0, [sp, 0x48] - movs r1, 0x80 - lsls r1, 14 - adds r0, r1 - mov r9, r0 -_0811FDC8: - lsls r2, r5, 4 - adds r2, 0x10 - ldr r3, [sp, 0x4C] - asrs r3, 16 - mov r8, r3 - add r2, r8 - lsls r2, 16 - asrs r2, 16 - adds r0, r4, 0 - mov r3, r9 - asrs r1, r3, 16 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x40 - bne _0811FDEE - b _0811FF0C -_0811FDEE: - ldr r6, =gUnknown_0203A124 - ldr r1, [r6] - lsls r0, r5, 2 - adds r1, 0x14 - adds r1, r0 - lsls r0, r3, 4 - adds r0, r3 - lsls r0, 2 - ldr r7, =gSprites - adds r0, r7 - str r0, [r1] - strh r5, [r0, 0x2E] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x3 - bls _0811FDC8 - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x14] - adds r0, r4, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x40 - beq _0811FEA8 - ldr r0, [r6] - lsls r1, r3, 4 - adds r1, r3 - lsls r1, 2 - adds r1, r7 - str r1, [r0, 0x28] - ldrb r3, [r1, 0x1] - movs r2, 0x3F - adds r0, r2, 0 - ands r0, r3 - strb r0, [r1, 0x1] - ldr r0, [r6] - ldr r1, [r0, 0x28] - ldrb r0, [r1, 0x3] - ands r2, r0 - movs r0, 0x80 - orrs r2, r0 - strb r2, [r1, 0x3] - ldr r0, [r6] - ldr r0, [r0, 0x28] - movs r1, 0x9 - bl StartSpriteAnim - ldr r1, [r6] - ldr r2, [r1, 0x28] - ldr r3, [sp, 0x48] - asrs r0, r3, 16 - adds r0, 0x20 - strh r0, [r2, 0x20] - ldr r2, [r1, 0x28] - mov r0, r8 - adds r0, 0x50 - strh r0, [r2, 0x22] - ldr r0, [r1, 0x28] - movs r1, 0x1 - movs r2, 0x2 - movs r3, 0 - bl CalcCenterToCornerVec - b _0811FEAE - .pool -_0811FEA8: - ldr r1, [r6] - movs r0, 0 - str r0, [r1, 0x28] -_0811FEAE: - ldr r0, =sub_811FF7C - str r0, [r4, 0x14] - ldr r0, [sp, 0x48] - movs r2, 0xC0 - lsls r2, 12 - adds r1, r0, r2 - asrs r1, 16 - adds r0, r4, 0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x40 - beq _0811FF20 - ldr r0, =gUnknown_0203A124 - ldr r2, [r0] - lsls r1, r3, 4 - adds r1, r3 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - str r1, [r2, 0x24] - ldr r3, [sp, 0x4C] - asrs r0, r3, 16 - adds r0, 0x10 - strh r0, [r1, 0x2E] - ldr r0, [r2, 0x24] - movs r1, 0x8 - bl StartSpriteAnim - b _0811FF28 - .pool -_0811FEFC: - ldr r0, =gUnknown_0203A124 - ldr r0, [r0] - lsls r1, r5, 2 - adds r0, 0xC - b _0811FF14 - .pool -_0811FF0C: - ldr r0, =gUnknown_0203A124 - ldr r0, [r0] - lsls r1, r5, 2 - adds r0, 0x14 -_0811FF14: - adds r0, r1 - movs r1, 0 - str r1, [r0] - b _0811FF28 - .pool -_0811FF20: - ldr r0, =gUnknown_0203A124 - ldr r1, [r0] - movs r0, 0 - str r0, [r1, 0x24] -_0811FF28: - add sp, 0x50 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811FC80 - - thumb_func_start TaskDummy7 -TaskDummy7: @ 811FF3C - bx lr - thumb_func_end TaskDummy7 - - thumb_func_start sub_811FF40 -sub_811FF40: @ 811FF40 - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_0203A124 - ldr r0, [r0] - movs r3, 0x2E - ldrsh r1, [r2, r3] - adds r0, 0x6 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _0811FF6C - lsls r1, 1 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - adds r0, r2, 0 - bl StartSpriteAnim - b _0811FF76 - .pool -_0811FF6C: - lsls r1, 25 - lsrs r1, 24 - adds r0, r2, 0 - bl StartSpriteAnim -_0811FF76: - pop {r0} - bx r0 - thumb_func_end sub_811FF40 - - thumb_func_start sub_811FF7C -sub_811FF7C: @ 811FF7C - ldr r1, =gUnknown_0203A124 - ldr r1, [r1] - ldrb r1, [r1, 0x5] - lsls r1, 24 - asrs r1, 24 - lsls r1, 4 - ldrh r2, [r0, 0x2E] - adds r1, r2 - strh r1, [r0, 0x22] - bx lr - .pool - thumb_func_end sub_811FF7C - - thumb_func_start sub_811FF94 -sub_811FF94: @ 811FF94 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 16 - lsrs r1, 16 - cmp r2, 0 - bne _0811FFA4 - ldr r2, =gUnknown_0859E65C -_0811FFA4: - movs r3, 0x10 - bl sub_811FFD4 - pop {r1} - bx r1 - .pool - thumb_func_end sub_811FF94 - - thumb_func_start sub_811FFB4 -sub_811FFB4: @ 811FFB4 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 16 - lsrs r1, 16 - cmp r2, 0 - bne _0811FFC4 - ldr r2, =gUnknown_0859E65C -_0811FFC4: - movs r3, 0x1 - bl sub_811FFD4 - pop {r1} - bx r1 - .pool - thumb_func_end sub_811FFB4 - - thumb_func_start sub_811FFD4 -sub_811FFD4: @ 811FFD4 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x28 - lsls r0, 16 - lsls r1, 16 - lsrs r1, 16 - ldr r4, =gUnknown_0859E67C - str r4, [sp, 0x18] - movs r4, 0x80 - add r5, sp, 0x18 - lsrs r6, r0, 16 - orrs r0, r4 - str r0, [r5, 0x4] - str r2, [sp, 0x20] - ldr r0, =0xffff0000 - mov r8, r0 - add r4, sp, 0x20 - ldr r0, [r4, 0x4] - mov r2, r8 - ands r0, r2 - orrs r0, r1 - str r0, [r4, 0x4] - mov r0, sp - movs r2, 0 - strh r6, [r0] - strh r1, [r0, 0x2] - ldr r0, =gUnknown_0859EF1C - str r0, [sp, 0x4] - ldr r0, =gUnknown_0859EFA4 - str r0, [sp, 0x8] - str r2, [sp, 0xC] - ldr r0, =gDummySpriteAffineAnimTable - str r0, [sp, 0x10] - ldr r0, =TaskDummy7 - str r0, [sp, 0x14] - lsls r3, 23 - lsrs r3, 16 - ldr r0, [r5, 0x4] - mov r1, r8 - ands r0, r1 - orrs r0, r3 - str r0, [r5, 0x4] - adds r0, r5, 0 - bl LoadSpriteSheet - adds r0, r4, 0 - bl LoadSpritePalette - mov r0, sp - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - bne _08120068 - movs r0, 0 - b _08120072 - .pool -_08120068: - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 -_08120072: - add sp, 0x28 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_811FFD4 - - thumb_func_start sub_8120084 -sub_8120084: @ 8120084 - push {lr} - lsls r0, 24 - lsrs r0, 17 - ldr r2, =gUnknown_0859E67C - adds r0, r2 - movs r2, 0x80 - movs r3, 0x10 - bl RequestDma3Copy - pop {r0} - bx r0 - .pool - thumb_func_end sub_8120084 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/rotating_gate.s b/asm/rotating_gate.s deleted file mode 100644 index 9b57dc1b0..000000000 --- a/asm/rotating_gate.s +++ /dev/null @@ -1,1152 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start GetCurrentMapRotatingGatePuzzleType -GetCurrentMapRotatingGatePuzzleType: @ 80FB7E8 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - movs r0, 0x86 - lsls r0, 1 - cmp r1, r0 - bne _080FB800 - movs r0, 0x1 - b _080FB812 - .pool -_080FB800: - ldr r0, =0x0000081d - cmp r1, r0 - beq _080FB810 - movs r0, 0 - b _080FB812 - .pool -_080FB810: - movs r0, 0x2 -_080FB812: - pop {r1} - bx r1 - thumb_func_end GetCurrentMapRotatingGatePuzzleType - - thumb_func_start sub_80FB818 -sub_80FB818: @ 80FB818 - push {r4-r6,lr} - movs r0, 0x80 - lsls r0, 7 - bl GetVarPointer - adds r5, r0, 0 - movs r3, 0 - ldr r4, =gUnknown_0203A048 - ldrb r0, [r4] - cmp r3, r0 - bge _080FB844 - ldr r6, =gUnknown_0203A044 -_080FB830: - adds r2, r5, r3 - ldr r1, [r6] - lsls r0, r3, 3 - adds r0, r1 - ldrb r0, [r0, 0x5] - strb r0, [r2] - adds r3, 0x1 - ldrb r0, [r4] - cmp r3, r0 - blt _080FB830 -_080FB844: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FB818 - - thumb_func_start sub_80FB854 -sub_80FB854: @ 80FB854 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x80 - lsls r0, 7 - bl GetVarPointer - adds r0, r4 - ldrb r0, [r0] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80FB854 - - thumb_func_start sub_80FB870 -sub_80FB870: @ 80FB870 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - movs r0, 0x80 - lsls r0, 7 - bl GetVarPointer - adds r0, r4 - strb r5, [r0] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80FB870 - - thumb_func_start sub_80FB890 -sub_80FB890: @ 80FB890 - push {r4,r5,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r5, 0 - bl sub_80FB854 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r4, 0x1 - bne _080FB8B4 - cmp r1, 0 - beq _080FB8B0 - subs r0, r1, 0x1 - lsls r0, 24 - b _080FB8BE -_080FB8B0: - movs r1, 0x3 - b _080FB8C0 -_080FB8B4: - adds r1, 0x1 - lsls r1, 24 - movs r0, 0xC0 - lsls r0, 18 - ands r0, r1 -_080FB8BE: - lsrs r1, r0, 24 -_080FB8C0: - adds r0, r5, 0 - bl sub_80FB870 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80FB890 - - thumb_func_start sub_80FB8CC -sub_80FB8CC: @ 80FB8CC - push {lr} - bl GetCurrentMapRotatingGatePuzzleType - cmp r0, 0x1 - beq _080FB8E0 - cmp r0, 0x1 - ble _080FB914 - cmp r0, 0x2 - beq _080FB8F8 - b _080FB914 -_080FB8E0: - ldr r1, =gUnknown_0203A044 - ldr r0, =gUnknown_0858E8B0 - str r0, [r1] - ldr r1, =gUnknown_0203A048 - movs r0, 0x8 - b _080FB902 - .pool -_080FB8F8: - ldr r1, =gUnknown_0203A044 - ldr r0, =gUnknown_0858E8F0 - str r0, [r1] - ldr r1, =gUnknown_0203A048 - movs r0, 0xB -_080FB902: - strb r0, [r1] - movs r1, 0 - ldr r3, =gUnknown_0203A038 - movs r2, 0x40 -_080FB90A: - adds r0, r1, r3 - strb r2, [r0] - adds r1, 0x1 - cmp r1, 0xA - bls _080FB90A -_080FB914: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FB8CC - - thumb_func_start sub_80FB928 -sub_80FB928: @ 80FB928 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 16 - lsrs r0, 16 - str r0, [sp] - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldrh r1, [r2] - subs r0, r1, 0x2 - lsls r0, 16 - lsrs r3, r0, 16 - adds r1, 0x11 - lsls r1, 16 - lsrs r1, 16 - mov r9, r1 - ldrh r1, [r2, 0x2] - subs r0, r1, 0x2 - lsls r0, 16 - lsrs r2, r0, 16 - adds r1, 0xE - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - movs r5, 0 - ldr r0, =gUnknown_0203A048 - ldrb r0, [r0] - cmp r5, r0 - bcs _080FB9DA - lsls r0, r2, 16 - asrs r7, r0, 16 - lsls r0, r3, 16 - asrs r6, r0, 16 -_080FB976: - ldr r0, =gUnknown_0203A044 - ldr r0, [r0] - lsls r1, r5, 3 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x7 - lsls r0, 16 - lsrs r2, r0, 16 - ldrh r0, [r1, 0x2] - adds r0, 0x7 - lsls r0, 16 - asrs r1, r0, 16 - cmp r7, r1 - bgt _080FB9CC - mov r3, r8 - lsls r0, r3, 16 - asrs r0, 16 - cmp r0, r1 - blt _080FB9CC - lsls r0, r2, 16 - asrs r1, r0, 16 - cmp r6, r1 - bgt _080FB9CC - mov r2, r9 - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, r1 - blt _080FB9CC - ldr r0, =gUnknown_0203A038 - adds r4, r5, r0 - ldrb r0, [r4] - cmp r0, 0x40 - bne _080FB9CC - ldr r3, [sp] - lsls r1, r3, 16 - mov r0, r10 - lsls r2, r0, 16 - adds r0, r5, 0 - asrs r1, 16 - asrs r2, 16 - bl sub_80FB9FC - strb r0, [r4] -_080FB9CC: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gUnknown_0203A048 - ldrb r0, [r0] - cmp r5, r0 - bcc _080FB976 -_080FB9DA: - 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_80FB928 - - thumb_func_start sub_80FB9FC -sub_80FB9FC: @ 80FB9FC - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x18 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 16 - lsrs r7, r1, 16 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - ldr r0, =gUnknown_0203A044 - lsls r1, r6, 3 - ldr r0, [r0] - adds r4, r0, r1 - ldrb r0, [r4, 0x4] - cmp r0, 0 - beq _080FBA24 - cmp r0, 0x4 - bne _080FBA34 -_080FBA24: - mov r1, sp - ldr r0, =gUnknown_08591FE0 - b _080FBA38 - .pool -_080FBA34: - mov r1, sp - ldr r0, =gUnknown_08591FC8 -_080FBA38: - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - mov r2, sp - ldrb r0, [r4, 0x4] - movs r3, 0x98 - lsls r3, 5 - adds r1, r3, 0 - adds r0, r1 - strh r0, [r2] - mov r0, sp - movs r1, 0 - movs r2, 0 - movs r3, 0x94 - bl CreateSprite - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x40 - beq _080FBAD4 - ldrh r0, [r4] - adds r0, 0x7 - ldrh r1, [r4, 0x2] - adds r1, 0x7 - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - ldr r2, =gSprites - adds r4, r2 - strh r6, [r4, 0x2E] - movs r2, 0x3E - adds r2, r4 - mov r12, r2 - ldrb r2, [r2] - movs r3, 0x2 - orrs r2, r3 - mov r3, r12 - strb r2, [r3] - lsls r0, 16 - asrs r0, 16 - lsls r2, r7, 16 - asrs r2, 16 - adds r0, r2 - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - mov r3, r8 - lsls r2, r3, 16 - asrs r2, 16 - adds r1, r2 - lsls r1, 16 - asrs r1, 16 - adds r2, r4, 0 - adds r2, 0x20 - adds r3, r4, 0 - adds r3, 0x22 - bl sub_8092FF0 - adds r0, r4, 0 - bl sub_80FBB64 - adds r0, r6, 0 - bl sub_80FB854 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAffineAnim - adds r0, r5, 0 - b _080FBAD6 - .pool -_080FBAD4: - movs r0, 0x40 -_080FBAD6: - add sp, 0x18 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80FB9FC - - thumb_func_start sub_80FBAE4 -sub_80FBAE4: @ 80FBAE4 - push {r4-r7,lr} - adds r6, r0, 0 - ldrh r0, [r6, 0x30] - lsls r0, 24 - lsrs r5, r0, 24 - ldrh r0, [r6, 0x32] - lsls r0, 24 - lsrs r4, r0, 24 - adds r7, r4, 0 - adds r0, r6, 0 - bl sub_80FBB64 - cmp r5, 0x1 - bne _080FBB2A - adds r0, r4, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - bl GetPlayerSpeed - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - beq _080FBB1A - adds r0, r4, 0 - adds r0, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 -_080FBB1A: - movs r0, 0x30 - bl PlaySE - adds r0, r6, 0 - adds r1, r4, 0 - bl StartSpriteAffineAnim - b _080FBB58 -_080FBB2A: - cmp r5, 0x2 - bne _080FBB58 - adds r0, r7, 0 - adds r0, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - bl GetPlayerSpeed - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - beq _080FBB4A - adds r0, r4, 0 - adds r0, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 -_080FBB4A: - movs r0, 0x30 - bl PlaySE - adds r0, r6, 0 - adds r1, r4, 0 - bl StartSpriteAffineAnim -_080FBB58: - movs r0, 0 - strh r0, [r6, 0x30] - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80FBAE4 - - thumb_func_start sub_80FBB64 -sub_80FBB64: @ 80FBB64 - push {r4-r6,lr} - mov r12, r0 - mov r4, r12 - adds r4, 0x3E - ldrb r0, [r4] - movs r5, 0x5 - negs r5, r5 - ands r5, r0 - strb r5, [r4] - mov r0, r12 - ldrh r1, [r0, 0x24] - ldrh r2, [r0, 0x20] - adds r1, r2 - adds r0, 0x28 - movs r2, 0 - ldrsb r2, [r0, r2] - ldr r0, =gSpriteCoordOffsetX - adds r2, r1 - ldrh r0, [r0] - adds r2, r0 - lsls r2, 16 - mov r3, r12 - ldrh r1, [r3, 0x26] - ldrh r0, [r3, 0x22] - adds r1, r0 - mov r0, r12 - adds r0, 0x29 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - ldr r3, =gSpriteCoordOffsetY - adds r0, r1 - ldrh r3, [r3] - adds r0, r3 - lsls r0, 16 - movs r3, 0x80 - lsls r3, 15 - adds r1, r2, r3 - lsrs r1, 16 - lsrs r6, r0, 16 - adds r0, r3 - lsrs r3, r0, 16 - asrs r2, 16 - cmp r2, 0xFF - bgt _080FBBCA - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bge _080FBBD2 -_080FBBCA: - movs r1, 0x4 - adds r0, r5, 0 - orrs r0, r1 - strb r0, [r4] -_080FBBD2: - lsls r0, r6, 16 - asrs r0, 16 - cmp r0, 0xAF - bgt _080FBBE6 - lsls r0, r3, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bge _080FBBF2 -_080FBBE6: - mov r0, r12 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_080FBBF2: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FBB64 - - thumb_func_start LoadRotatingGatePics -@ void LoadRotatingGatePics() -LoadRotatingGatePics: @ 80FBC00 - push {lr} - ldr r0, =gUnknown_08591D58 - bl LoadSpriteSheets - pop {r0} - bx r0 - .pool - thumb_func_end LoadRotatingGatePics - - thumb_func_start sub_80FBC10 -sub_80FBC10: @ 80FBC10 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldrh r1, [r2] - subs r0, r1, 0x2 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - adds r1, 0x11 - lsls r1, 16 - lsrs r1, 16 - mov r9, r1 - ldrh r1, [r2, 0x2] - subs r0, r1, 0x2 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - adds r1, 0xE - lsls r1, 16 - lsrs r7, r1, 16 - movs r6, 0 - b _080FBCB6 - .pool -_080FBC48: - ldr r0, =gUnknown_0203A044 - ldr r0, [r0] - lsls r1, r6, 3 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x7 - lsls r0, 16 - lsrs r2, r0, 16 - ldrh r0, [r1, 0x2] - adds r0, 0x7 - lsls r0, 16 - lsrs r3, r0, 16 - ldr r0, =gUnknown_0203A038 - adds r0, r6, r0 - ldrb r0, [r0] - cmp r0, 0x40 - beq _080FBCB4 - lsls r0, r2, 16 - mov r2, r10 - lsls r1, r2, 16 - asrs r2, r0, 16 - cmp r0, r1 - blt _080FBC94 - mov r1, r9 - lsls r0, r1, 16 - asrs r0, 16 - cmp r2, r0 - bgt _080FBC94 - lsls r0, r3, 16 - mov r2, r8 - lsls r1, r2, 16 - asrs r2, r0, 16 - cmp r0, r1 - blt _080FBC94 - lsls r0, r7, 16 - asrs r0, 16 - cmp r2, r0 - ble _080FBCB4 -_080FBC94: - ldr r0, =gUnknown_0203A038 - adds r5, r6, r0 - ldrb r0, [r5] - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite - movs r0, 0x40 - strb r0, [r5] -_080FBCB4: - adds r6, 0x1 -_080FBCB6: - ldr r0, =gUnknown_0203A048 - ldrb r0, [r0] - cmp r6, r0 - blt _080FBC48 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FBC10 - - thumb_func_start sub_80FBCDC -sub_80FBCDC: @ 80FBCDC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - lsls r0, 24 - lsrs r4, r0, 24 - cmp r1, 0x1 - bne _080FBCFC - ldr r0, =gUnknown_08592058 - mov r10, r0 - b _080FBD08 - .pool -_080FBCFC: - cmp r1, 0x2 - beq _080FBD04 -_080FBD00: - movs r0, 0 - b _080FBD98 -_080FBD04: - ldr r1, =gUnknown_08592038 - mov r10, r1 -_080FBD08: - adds r0, r4, 0 - bl sub_80FB854 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - ldr r0, =gUnknown_0203A044 - ldr r1, [r0] - lsls r0, r4, 3 - adds r0, r1 - ldrb r2, [r0, 0x4] - ldrh r1, [r0] - adds r1, 0x7 - ldrh r0, [r0, 0x2] - adds r0, 0x7 - movs r3, 0 - lsls r2, 3 - str r2, [sp, 0x4] - lsls r1, 16 - asrs r1, 16 - mov r9, r1 - lsls r0, 16 - asrs r0, 16 - mov r8, r0 -_080FBD38: - movs r6, 0 - ldr r2, [sp] - adds r7, r2, r3 - lsls r0, r3, 1 - adds r5, r7, 0 - ldr r1, [sp, 0x4] - adds r0, r1 - ldr r2, =gUnknown_08592078 - adds r4, r0, r2 -_080FBD4A: - adds r0, r5, 0 - cmp r5, 0 - bge _080FBD52 - adds r0, r7, 0x3 -_080FBD52: - asrs r0, 2 - lsls r0, 2 - subs r0, r5, r0 - lsls r0, 1 - adds r0, r6 - lsls r0, 24 - lsrs r1, r0, 24 - ldrb r0, [r4] - cmp r0, 0 - beq _080FBD88 - lsls r1, 2 - add r1, r10 - movs r0, 0 - ldrsb r0, [r1, r0] - add r0, r9 - ldrb r1, [r1, 0x1] - lsls r1, 24 - asrs r1, 24 - add r1, r8 - str r3, [sp, 0x8] - bl MapGridIsImpassableAt - lsls r0, 24 - lsrs r0, 24 - ldr r3, [sp, 0x8] - cmp r0, 0x1 - beq _080FBD00 -_080FBD88: - adds r4, 0x1 - adds r6, 0x1 - cmp r6, 0x1 - ble _080FBD4A - adds r3, 0x1 - cmp r3, 0x3 - ble _080FBD38 - movs r0, 0x1 -_080FBD98: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80FBCDC - - thumb_func_start sub_80FBDB4 -sub_80FBDB4: @ 80FBDB4 - push {r4-r6,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - adds r6, r0, 0 - lsls r4, 24 - lsrs r5, r4, 24 - lsrs r4, 25 - movs r0, 0x1 - ands r5, r0 - adds r0, r6, 0 - bl sub_80FB854 - subs r4, r0 - adds r1, r4, 0x4 - adds r0, r1, 0 - cmp r1, 0 - bge _080FBDDA - adds r0, r4, 0x7 -_080FBDDA: - asrs r0, 2 - lsls r0, 2 - subs r0, r1, r0 - ldr r1, =gUnknown_0203A044 - ldr r2, [r1] - lsls r1, r6, 3 - adds r1, r2 - ldrb r1, [r1, 0x4] - ldr r2, =gUnknown_08592078 - lsls r0, 24 - asrs r0, 23 - adds r0, r5 - lsls r1, 3 - adds r0, r1 - adds r0, r2 - ldrb r0, [r0] - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80FBDB4 - - thumb_func_start sub_80FBE08 -sub_80FBE08: @ 80FBE08 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, =gUnknown_0203A038 - adds r2, r3, r0 - ldrb r0, [r2] - cmp r0, 0x40 - beq _080FBE2C - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - strh r1, [r4, 0x30] - adds r0, r3, 0 - bl sub_80FB854 - strh r0, [r4, 0x32] -_080FBE2C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FBE08 - - thumb_func_start sub_80FBE3C -sub_80FBE3C: @ 80FBE3C - push {lr} - lsls r0, 24 - lsrs r0, 24 - adds r3, r0, 0 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - cmp r0, 0x2 - bne _080FBE58 - ldr r3, =gUnknown_08591FF8 - b _080FBE7A - .pool -_080FBE58: - cmp r0, 0x1 - bne _080FBE64 - ldr r3, =gUnknown_08592008 - b _080FBE7A - .pool -_080FBE64: - cmp r0, 0x3 - bne _080FBE70 - ldr r3, =gUnknown_08592018 - b _080FBE7A - .pool -_080FBE70: - cmp r3, 0x4 - beq _080FBE78 - movs r0, 0xFF - b _080FBE88 -_080FBE78: - ldr r3, =gUnknown_08592028 -_080FBE7A: - lsls r0, r2, 16 - lsls r1, 16 - asrs r1, 16 - asrs r0, 14 - adds r0, r1 - adds r0, r3, r0 - ldrb r0, [r0] -_080FBE88: - pop {r1} - bx r1 - .pool - thumb_func_end sub_80FBE3C - - thumb_func_start sub_80FBE90 -sub_80FBE90: @ 80FBE90 - push {lr} - bl GetCurrentMapRotatingGatePuzzleType - cmp r0, 0 - beq _080FBEA2 - bl sub_80FB8CC - bl sub_80FB818 -_080FBEA2: - pop {r0} - bx r0 - thumb_func_end sub_80FBE90 - - thumb_func_start RotatingGatePuzzleCameraUpdate -@ void RotatingGatePuzzleCameraUpdate(s32 deltaX, s32 deltaY) -RotatingGatePuzzleCameraUpdate: @ 80FBEA8 - push {r4,r5,lr} - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 16 - lsrs r5, r1, 16 - bl GetCurrentMapRotatingGatePuzzleType - cmp r0, 0 - beq _080FBECA - lsls r0, r4, 16 - asrs r0, 16 - lsls r1, r5, 16 - asrs r1, 16 - bl sub_80FB928 - bl sub_80FBC10 -_080FBECA: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end RotatingGatePuzzleCameraUpdate - - thumb_func_start RotatingGate_InitPuzzleAndGraphics -RotatingGate_InitPuzzleAndGraphics: @ 80FBED0 - push {lr} - bl GetCurrentMapRotatingGatePuzzleType - cmp r0, 0 - beq _080FBEEA - bl LoadRotatingGatePics - bl sub_80FB8CC - movs r0, 0 - movs r1, 0 - bl sub_80FB928 -_080FBEEA: - pop {r0} - bx r0 - thumb_func_end RotatingGate_InitPuzzleAndGraphics - - thumb_func_start CheckForRotatingGatePuzzleCollision -CheckForRotatingGatePuzzleCollision: @ 80FBEF0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - bl GetCurrentMapRotatingGatePuzzleType - cmp r0, 0 - bne _080FBF24 - b _080FBFC2 -_080FBF12: - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80FBE08 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80FB890 - b _080FBFC2 -_080FBF24: - movs r6, 0 - ldr r0, =gUnknown_0203A048 - ldrb r0, [r0] - cmp r6, r0 - bge _080FBFC2 - lsls r0, r4, 16 - asrs r7, r0, 16 -_080FBF32: - ldr r0, =gUnknown_0203A044 - ldr r1, [r0] - lsls r0, r6, 3 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x7 - ldrh r0, [r0, 0x2] - adds r0, 0x7 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 16 - asrs r4, r1, 16 - subs r0, r4, 0x2 - cmp r0, r7 - bgt _080FBFB8 - adds r0, r4, 0x1 - cmp r7, r0 - bgt _080FBFB8 - lsls r0, r2, 16 - asrs r3, r0, 16 - subs r1, r3, 0x2 - mov r2, r8 - lsls r0, r2, 16 - asrs r2, r0, 16 - cmp r1, r2 - bgt _080FBFB8 - adds r0, r3, 0x1 - cmp r2, r0 - bgt _080FBFB8 - subs r1, r7, r4 - adds r1, 0x2 - subs r2, r3 - adds r2, 0x2 - lsls r1, 16 - asrs r1, 16 - lsls r2, 16 - asrs r2, 16 - mov r0, r9 - bl sub_80FBE3C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _080FBFB8 - lsrs r5, r0, 4 - movs r1, 0xF - ands r1, r0 - lsls r0, r6, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl sub_80FBDB4 - cmp r0, 0 - beq _080FBFB8 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80FBCDC - cmp r0, 0 - bne _080FBF12 - movs r0, 0x1 - b _080FBFC4 - .pool -_080FBFB8: - adds r6, 0x1 - ldr r0, =gUnknown_0203A048 - ldrb r0, [r0] - cmp r6, r0 - blt _080FBF32 -_080FBFC2: - movs r0, 0 -_080FBFC4: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end CheckForRotatingGatePuzzleCollision - - thumb_func_start sub_80FBFD4 -sub_80FBFD4: @ 80FBFD4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - bl GetCurrentMapRotatingGatePuzzleType - cmp r0, 0 - bne _080FBFFA - b _080FC08A -_080FBFF6: - movs r0, 0x1 - b _080FC08C -_080FBFFA: - movs r6, 0 - ldr r0, =gUnknown_0203A048 - ldrb r0, [r0] - cmp r6, r0 - bge _080FC08A - lsls r0, r4, 16 - asrs r7, r0, 16 -_080FC008: - ldr r0, =gUnknown_0203A044 - ldr r1, [r0] - lsls r0, r6, 3 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x7 - ldrh r0, [r0, 0x2] - adds r0, 0x7 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 16 - asrs r4, r1, 16 - subs r0, r4, 0x2 - cmp r0, r7 - bgt _080FC080 - adds r0, r4, 0x1 - cmp r7, r0 - bgt _080FC080 - lsls r0, r2, 16 - asrs r3, r0, 16 - subs r1, r3, 0x2 - mov r2, r8 - lsls r0, r2, 16 - asrs r2, r0, 16 - cmp r1, r2 - bgt _080FC080 - adds r0, r3, 0x1 - cmp r2, r0 - bgt _080FC080 - subs r1, r7, r4 - adds r1, 0x2 - subs r2, r3 - adds r2, 0x2 - lsls r1, 16 - asrs r1, 16 - lsls r2, 16 - asrs r2, 16 - mov r0, r9 - bl sub_80FBE3C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _080FC080 - lsrs r5, r0, 4 - movs r1, 0xF - ands r1, r0 - lsls r0, r6, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl sub_80FBDB4 - cmp r0, 0 - beq _080FC080 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80FBCDC - cmp r0, 0 - beq _080FBFF6 -_080FC080: - adds r6, 0x1 - ldr r0, =gUnknown_0203A048 - ldrb r0, [r0] - cmp r6, r0 - blt _080FC008 -_080FC08A: - movs r0, 0 -_080FC08C: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80FBFD4 - - .align 2, 0 @ Don't pad with nop. diff --git a/data/mon_markings.s b/data/mon_markings.s deleted file mode 100644 index 7d30c0012..000000000 --- a/data/mon_markings.s +++ /dev/null @@ -1,157 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_0859E65C:: @ 859E65C - .incbin "graphics/misc/mon_markings.gbapal" - -gUnknown_0859E67C:: @ 859E67C - .incbin "graphics/misc/mon_markings.4bpp" - -gUnknown_0859EE7C:: @ 859EE7C - .2byte 0, 0xC000, 0, 0 - -gUnknown_0859EE84:: @ 859EE84 - .2byte 0, 0, 0, 0 - -gUnknown_0859EE8C:: @ 859EE8C - .2byte 0, 5, -1, 0 - -gUnknown_0859EE94:: @ 859EE94 - .2byte 1, 5, -1, 0 - -gUnknown_0859EE9C:: @ 859EE9C - .2byte 2, 5, -1, 0 - -gUnknown_0859EEA4:: @ 859EEA4 - .2byte 3, 5, -1, 0 - -gUnknown_0859EEAC:: @ 859EEAC - .2byte 4, 5, -1, 0 - -gUnknown_0859EEB4:: @ 859EEB4 - .2byte 5, 5, -1, 0 - -gUnknown_0859EEBC:: @ 859EEBC - .2byte 6, 5, -1, 0 - -gUnknown_0859EEC4:: @ 859EEC4 - .2byte 7, 5, -1, 0 - -gUnknown_0859EECC:: @ 859EECC - .2byte 8, 5, -1, 0 - -gUnknown_0859EED4:: @ 859EED4 - .2byte 9, 5, -1, 0 - -gUnknown_0859EEDC:: @ 859EEDC - .4byte gUnknown_0859EE8C - .4byte gUnknown_0859EE94 - .4byte gUnknown_0859EE9C - .4byte gUnknown_0859EEA4 - .4byte gUnknown_0859EEAC - .4byte gUnknown_0859EEB4 - .4byte gUnknown_0859EEBC - .4byte gUnknown_0859EEC4 - .4byte gUnknown_0859EECC - .4byte gUnknown_0859EED4 - -gUnknown_0859EF04:: @ 859EF04 - .2byte 0, 5, -1, 0 - -gUnknown_0859EF0C:: @ 859EF0C - .2byte 64, 5, -1, 0 - -gUnknown_0859EF14:: @ 859EF14 - .4byte gUnknown_0859EF04 - .4byte gUnknown_0859EF0C - -gUnknown_0859EF1C:: @ 859EF1C - .2byte 0x4000 - .2byte 0x4000 - .2byte 0 - .2byte 0 - -gUnknown_0859EF24:: @ 859EF24 - obj_image_anim_frame 0, 5 - obj_image_anim_end - -gUnknown_0859EF2C:: @ 859EF2C - obj_image_anim_frame 4, 5 - obj_image_anim_end - -gUnknown_0859EF34:: @ 859EF34 - obj_image_anim_frame 8, 5 - obj_image_anim_end - -gUnknown_0859EF3C:: @ 859EF3C - obj_image_anim_frame 12, 5 - obj_image_anim_end - -gUnknown_0859EF44:: @ 859EF44 - obj_image_anim_frame 16, 5 - obj_image_anim_end - -gUnknown_0859EF4C:: @ 859EF4C - obj_image_anim_frame 20, 5 - obj_image_anim_end - -gUnknown_0859EF54:: @ 859EF54 - obj_image_anim_frame 24, 5 - obj_image_anim_end - -gUnknown_0859EF5C:: @ 859EF5C - obj_image_anim_frame 28, 5 - obj_image_anim_end - -gUnknown_0859EF64:: @ 859EF64 - obj_image_anim_frame 32, 5 - obj_image_anim_end - -gUnknown_0859EF6C:: @ 859EF6C - obj_image_anim_frame 36, 5 - obj_image_anim_end - -gUnknown_0859EF74:: @ 859EF74 - obj_image_anim_frame 40, 5 - obj_image_anim_end - -gUnknown_0859EF7C:: @ 859EF7C - obj_image_anim_frame 44, 5 - obj_image_anim_end - -gUnknown_0859EF84:: @ 859EF84 - obj_image_anim_frame 48, 5 - obj_image_anim_end - -gUnknown_0859EF8C:: @ 859EF8C - obj_image_anim_frame 52, 5 - obj_image_anim_end - -gUnknown_0859EF94:: @ 859EF94 - obj_image_anim_frame 56, 5 - obj_image_anim_end - -gUnknown_0859EF9C:: @ 859EF9C - obj_image_anim_frame 60, 5 - obj_image_anim_end - -gUnknown_0859EFA4:: @ 859EFA4 - .4byte gUnknown_0859EF24 - .4byte gUnknown_0859EF2C - .4byte gUnknown_0859EF34 - .4byte gUnknown_0859EF3C - .4byte gUnknown_0859EF44 - .4byte gUnknown_0859EF4C - .4byte gUnknown_0859EF54 - .4byte gUnknown_0859EF5C - .4byte gUnknown_0859EF64 - .4byte gUnknown_0859EF6C - .4byte gUnknown_0859EF74 - .4byte gUnknown_0859EF7C - .4byte gUnknown_0859EF84 - .4byte gUnknown_0859EF8C - .4byte gUnknown_0859EF94 - .4byte gUnknown_0859EF9C diff --git a/data/rotating_gate.s b/data/rotating_gate.s deleted file mode 100644 index 595cc9917..000000000 --- a/data/rotating_gate.s +++ /dev/null @@ -1,285 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -gUnknown_0858E8B0:: @ 858E8B0 - .2byte 0x0006, 0x0007 - .byte 0x05, 0x01 - - .align 2 - .2byte 0x0009, 0x000f - .byte 0x05, 0x02 - - .align 2 - .2byte 0x0003, 0x0013 - .byte 0x05, 0x01 - - .align 2 - .2byte 0x0002, 0x0006 - .byte 0x04, 0x01 - - .align 2 - .2byte 0x0009, 0x000c - .byte 0x04, 0x00 - - .align 2 - .2byte 0x0006, 0x0017 - .byte 0x04, 0x00 - - .align 2 - .2byte 0x000c, 0x0016 - .byte 0x04, 0x00 - - .align 2 - .2byte 0x0006, 0x0003 - .byte 0x03, 0x02 - - .align 2 -gUnknown_0858E8F0:: @ 858E8F0 - .2byte 0x000e, 0x0005 - .byte 0x04, 0x01 - - .align 2 - .2byte 0x000a, 0x0006 - .byte 0x01, 0x02 - - .align 2 - .2byte 0x0006, 0x0006 - .byte 0x03, 0x01 - - .align 2 - .2byte 0x000e, 0x0008 - .byte 0x04, 0x01 - - .align 2 - .2byte 0x0003, 0x000a - .byte 0x02, 0x03 - - .align 2 - .2byte 0x0009, 0x000e - .byte 0x00, 0x01 - - .align 2 - .2byte 0x0003, 0x000f - .byte 0x06, 0x00 - - .align 2 - .2byte 0x0002, 0x0011 - .byte 0x01, 0x02 - - .align 2 - .2byte 0x000c, 0x0012 - .byte 0x06, 0x03 - - .align 2 - .2byte 0x0005, 0x0012 - .byte 0x03, 0x01 - - .align 2 - .2byte 0x000a, 0x0013 - .byte 0x02, 0x02 - - .align 2 -gUnknown_0858E948:: @ 858E948 - .incbin "graphics/misc/rotating_gate_1.4bpp" - - .align 2 -gUnknown_0858EB48:: @ 858EB48 - .incbin "graphics/misc/rotating_gate_2.4bpp" - - .align 2 -gUnknown_0858F348:: @ 858F348 - .incbin "graphics/misc/rotating_gate_3.4bpp" - - .align 2 -gUnknown_0858FB48:: @ 858FB48 - .incbin "graphics/misc/rotating_gate_4.4bpp" - - .align 2 -gUnknown_08590348:: @ 8590348 - .incbin "graphics/misc/rotating_gate_5.4bpp" - - .align 2 -gUnknown_08590548:: @ 8590548 - .incbin "graphics/misc/rotating_gate_6.4bpp" - - .align 2 -gUnknown_08590D48:: @ 8590D48 - .incbin "graphics/misc/rotating_gate_7.4bpp" - - .align 2 -gUnknown_08591548:: @ 8591548 - .incbin "graphics/misc/rotating_gate_8.4bpp" - - .align 2 -gOamData_8591D48:: @ 8591D48 - .2byte 0x0100, 0xc000, 0x2800 - - .align 2 -gOamData_8591D50:: @ 8591D50 - .2byte 0x0100, 0x8000, 0x2800 - - .align 2 -gUnknown_08591D58:: @ 8591D58 - obj_tiles gUnknown_0858E948, 0x0200, 0x1300 - obj_tiles gUnknown_0858EB48, 0x0800, 0x1301 - obj_tiles gUnknown_0858F348, 0x0800, 0x1302 - obj_tiles gUnknown_0858FB48, 0x0800, 0x1303 - obj_tiles gUnknown_08590348, 0x0200, 0x1304 - obj_tiles gUnknown_08590548, 0x0800, 0x1305 - obj_tiles gUnknown_08590D48, 0x0800, 0x1306 - obj_tiles gUnknown_08591548, 0x0800, 0x1307 - null_obj_tiles - - .align 2 -gSpriteAnim_8591DA0:: @ 8591DA0 - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_8591DA8:: @ 8591DA8 - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_8591DB0:: @ 8591DB0 - .4byte gSpriteAnim_8591DA0 - - .align 2 -gSpriteAnimTable_8591DB4:: @ 8591DB4 - .4byte gSpriteAnim_8591DA8 - - .align 2 -gSpriteAffineAnim_8591DB8:: @ 8591DB8 - .2byte 0x0100, 0x0100, 0x0000, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591DC8:: @ 8591DC8 - .2byte 0x0100, 0x0100, 0x00c0, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591DD8:: @ 8591DD8 - .2byte 0x0100, 0x0100, 0x0080, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591DE8:: @ 8591DE8 - .2byte 0x0100, 0x0100, 0x0040, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591DF8:: @ 8591DF8 - .2byte 0x0100, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x10fc, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591E10:: @ 8591E10 - .2byte 0x0100, 0x0100, 0x00c0, 0x0000, 0x0000, 0x0000, 0x10fc, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591E28:: @ 8591E28 - .2byte 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000, 0x10fc, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591E40:: @ 8591E40 - .2byte 0x0100, 0x0100, 0x0040, 0x0000, 0x0000, 0x0000, 0x10fc, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591E58:: @ 8591E58 - .2byte 0x0100, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x1004, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591E70:: @ 8591E70 - .2byte 0x0100, 0x0100, 0x0040, 0x0000, 0x0000, 0x0000, 0x1004, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591E88:: @ 8591E88 - .2byte 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000, 0x1004, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591EA0:: @ 8591EA0 - .2byte 0x0100, 0x0100, 0x00c0, 0x0000, 0x0000, 0x0000, 0x1004, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591EB8:: @ 8591EB8 - .2byte 0x0100, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x08f8, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591ED0:: @ 8591ED0 - .2byte 0x0100, 0x0100, 0x00c0, 0x0000, 0x0000, 0x0000, 0x08f8, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591EE8:: @ 8591EE8 - .2byte 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000, 0x08f8, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591F00:: @ 8591F00 - .2byte 0x0100, 0x0100, 0x0040, 0x0000, 0x0000, 0x0000, 0x08f8, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591F18:: @ 8591F18 - .2byte 0x0100, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0808, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591F30:: @ 8591F30 - .2byte 0x0100, 0x0100, 0x0040, 0x0000, 0x0000, 0x0000, 0x0808, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591F48:: @ 8591F48 - .2byte 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000, 0x0808, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_8591F60:: @ 8591F60 - .2byte 0x0100, 0x0100, 0x00c0, 0x0000, 0x0000, 0x0000, 0x0808, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnimTable_8591F78:: @ 8591F78 - .4byte gSpriteAffineAnim_8591DB8 - .4byte gSpriteAffineAnim_8591DC8 - .4byte gSpriteAffineAnim_8591DD8 - .4byte gSpriteAffineAnim_8591DE8 - .4byte gSpriteAffineAnim_8591E58 - .4byte gSpriteAffineAnim_8591EA0 - .4byte gSpriteAffineAnim_8591E88 - .4byte gSpriteAffineAnim_8591E70 - .4byte gSpriteAffineAnim_8591DF8 - .4byte gSpriteAffineAnim_8591E10 - .4byte gSpriteAffineAnim_8591E28 - .4byte gSpriteAffineAnim_8591E40 - .4byte gSpriteAffineAnim_8591F18 - .4byte gSpriteAffineAnim_8591F60 - .4byte gSpriteAffineAnim_8591F48 - .4byte gSpriteAffineAnim_8591F30 - .4byte gSpriteAffineAnim_8591EB8 - .4byte gSpriteAffineAnim_8591ED0 - .4byte gSpriteAffineAnim_8591EE8 - .4byte gSpriteAffineAnim_8591F00 - - .align 2 -gUnknown_08591FC8:: @ 8591FC8 - spr_template 0x1300, 0xffff, gOamData_8591D48, gSpriteAnimTable_8591DB0, NULL, gSpriteAffineAnimTable_8591F78, sub_80FBAE4 - - .align 2 -gUnknown_08591FE0:: @ 8591FE0 - spr_template 0x1300, 0xffff, gOamData_8591D50, gSpriteAnimTable_8591DB4, NULL, gSpriteAffineAnimTable_8591F78, sub_80FBAE4 - -gUnknown_08591FF8:: @ 8591FF8 - .byte 0xff, 0xff, 0xff, 0xff, 0x27, 0x26, 0x12, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - -gUnknown_08592008:: @ 8592008 - .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x16, 0x22, 0x23, 0xff, 0xff, 0xff, 0xff - -gUnknown_08592018:: @ 8592018 - .byte 0xff, 0x11, 0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x24, 0xff, 0xff, 0xff, 0x25, 0xff, 0xff - -gUnknown_08592028:: @ 8592028 - .byte 0xff, 0xff, 0x21, 0xff, 0xff, 0xff, 0x20, 0xff, 0xff, 0xff, 0x14, 0xff, 0xff, 0xff, 0x15, 0xff - -gUnknown_08592038:: @ 8592038 - .byte 0x00, 0xff, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xff, 0x00, 0x00 - -gUnknown_08592058:: @ 8592058 - .byte 0xff, 0xff, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00 - -gUnknown_08592078:: @ 8592078 - .byte 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 - .byte 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00 - .byte 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00 - diff --git a/data/scripts/maps/FortreeCity_Gym.inc b/data/scripts/maps/FortreeCity_Gym.inc index 01ce60717..b8b800286 100644 --- a/data/scripts/maps/FortreeCity_Gym.inc +++ b/data/scripts/maps/FortreeCity_Gym.inc @@ -4,7 +4,7 @@ FortreeCity_Gym_MapScripts:: @ 82165AB .byte 0 FortreeCity_Gym_MapScript1_2165B6: @ 82165B6 - special sub_80FBE90 + special RotatingGate_InitPuzzle end FortreeCity_Gym_MapScript2_2165BA: @ 82165BA diff --git a/data/scripts/maps/Route110_TrickHousePuzzle6.inc b/data/scripts/maps/Route110_TrickHousePuzzle6.inc index 6b13cf8cb..0a0e025af 100644 --- a/data/scripts/maps/Route110_TrickHousePuzzle6.inc +++ b/data/scripts/maps/Route110_TrickHousePuzzle6.inc @@ -4,7 +4,7 @@ Route110_TrickHousePuzzle6_MapScripts:: @ 826DDA7 .byte 0 Route110_TrickHousePuzzle6_MapScript1_26DDB2: @ 826DDB2 - special sub_80FBE90 + special RotatingGate_InitPuzzle end Route110_TrickHousePuzzle6_MapScript2_26DDB6: @ 826DDB6 diff --git a/data/specials.inc b/data/specials.inc index 394e4a10e..2290c9d21 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -212,7 +212,7 @@ gSpecials:: @ 81DBA64 def_special SubtractMoneyFromVar0x8005 def_special sub_80F972C def_special sp0C8_whiteout_maybe - def_special sub_80FBE90 + def_special RotatingGate_InitPuzzle def_special RotatingGate_InitPuzzleAndGraphics def_special SetSSTidalFlag def_special ResetSSTidalFlag diff --git a/include/bike.h b/include/bike.h index e625ad438..46b668169 100644 --- a/include/bike.h +++ b/include/bike.h @@ -63,6 +63,10 @@ enum ACRO_TRANS_WHEELIE_LOWERING_MOVING, }; +// Exported RAM declarations +extern bool8 gUnusedBikeCameraAheadPanback; + +// Exported ROM declarations void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys); void Bike_TryAcroBikeHistoryUpdate(u16 newKeys, u16 heldKeys); bool8 RS_IsRunningDisallowed(u8 tile); diff --git a/include/field_camera.h b/include/field_camera.h index 6ff8ce006..fcc19ce9a 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -6,22 +6,19 @@ struct CameraObject { void (*callback)(struct CameraObject *); - u32 unk4; + u32 spriteId; s32 unk8; s32 unkC; s32 x; s32 y; }; -extern struct CameraObject gUnknown_03005DD0; - // Exported RAM declarations - +extern struct CameraObject gUnknown_03005DD0; extern u16 gUnknown_03005DEC; extern u16 gUnknown_03005DE8; // Exported ROM declarations - void DrawWholeMapView(void); void CurrentMapDrawMetatileAt(int x, int y); void sub_8089C08(s16 *a0, s16 *a1); diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 8b7e296dd..8f34d4b93 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -91,6 +91,8 @@ void sub_808F23C(const struct MapObject *mapObject, u8 movementType); void sub_808F208(const struct MapObject *mapObject); void npc_coords_shift_still(struct MapObject *pObject); void FieldObjectMoveDestCoords(struct MapObject *pObject, u32 unk_19, s16 *pInt, s16 *pInt1); +u8 AddCameraObject(u8 linkedSpriteId); +void UpdateFieldObjectsForCameraUpdate(s16 x, s16 y); // Exported data declarations diff --git a/include/fieldmap.h b/include/fieldmap.h index 23654f536..3128e95ce 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -16,5 +16,7 @@ s32 GetMapBorderIdAt(s16, s16); bool32 CanCameraMoveInDirection(u8); u16 GetBehaviorByMetatileId(u16 metatileId); void sav1_camera_get_focus_coords(u16 *x, u16 *y); +u8 MapGridGetMetatileLayerTypeAt(s32 x, s32 y); +u8 CameraMove(s32 deltaX, s32 deltaY); #endif //GUARD_FIELDMAP_H diff --git a/include/graphics.h b/include/graphics.h index 9afcb75ad..1313ddc3a 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2864,4 +2864,8 @@ extern const u8 gBerryPalette_Enigma[]; //credits extern const u8 gCreditsCopyrightEnd_Gfx[]; +//pokenav condition marker +extern const u8 gPokenavConditionMarker_Gfx[]; +extern const u16 gPokenavConditionMarker_Pal[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/mon_markings.h b/include/mon_markings.h new file mode 100644 index 000000000..852e8b4eb --- /dev/null +++ b/include/mon_markings.h @@ -0,0 +1,24 @@ +#ifndef POKEEMERALD_MON_MARKINGS_H +#define POKEEMERALD_MON_MARKINGS_H + +struct PokemonMarkMenu +{ + /*0x0000*/ u16 baseTileTag; + /*0x0002*/ u16 basePaletteTag; + /*0x0004*/ u8 markings; // bit flags + /*0x0005*/ s8 cursorPos; + /*0x0006*/ bool8 markingsArray[4]; + /*0x000A*/ u8 cursorBaseY; + /*0x000B*/ bool8 spriteSheetLoadRequired; + /*0x000C*/ struct Sprite *menuWindowSprites[2]; // upper and lower halves of menu window + /*0x0014*/ struct Sprite *menuMarkingSprites[4]; + /*0x0024*/ struct Sprite *unkSprite; + /*0x0028*/ struct Sprite *menuTextSprite; + /*0x002C*/ const u8 *frameTiles; + /*0x0030*/ const u16 *framePalette; + /*0x0034*/ u8 menuWindowSpriteTiles[0x1000]; + /*0x1034*/ u8 filler1030[0x80]; + /*0x10B4*/ u8 tileLoadState; +}; // 10b8 + +#endif //POKEEMERALD_MON_MARKINGS_H diff --git a/include/overworld.h b/include/overworld.h index 7f0a1795f..cd0f4e60f 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -15,9 +15,15 @@ struct LinkPlayerMapObject u8 mode; }; +// Exported RAM declarations extern struct WarpData gUnknown_020322DC; extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; +extern u16 *gBGTilemapBuffers1; +extern u16 *gBGTilemapBuffers2; +extern u16 *gBGTilemapBuffers3; + +// Exported ROM declarations extern const struct UCoords32 gUnknown_08339D64[]; void DoWhiteOut(void); diff --git a/include/rotating_gate.h b/include/rotating_gate.h new file mode 100644 index 000000000..50a838953 --- /dev/null +++ b/include/rotating_gate.h @@ -0,0 +1,8 @@ +#ifndef GUARD_ROTATING_GATE_H +#define GUARD_ROTATING_GATE_H + +void RotatingGatePuzzleCameraUpdate(s16, s16); +void RotatingGate_InitPuzzleAndGraphics(); +u32 CheckForRotatingGatePuzzleCollision(u8, s16, s16); + +#endif // GUARD_ROTATING_GATE_H diff --git a/include/text_window.h b/include/text_window.h index e6a753fcb..2ac13fab7 100644 --- a/include/text_window.h +++ b/include/text_window.h @@ -5,11 +5,11 @@ struct TilesPal { - const u32 *tiles; + const u8 *tiles; const u16 *pal; }; -extern const u32 gTextWindowFrame1_Gfx[]; +extern const u8 gTextWindowFrame1_Gfx[]; extern const u16 gTextWindowFrame1_Pal[]; const struct TilesPal* GetWindowFrameTilesPal(u8 id); diff --git a/ld_script.txt b/ld_script.txt index 11c82b2d0..2832bcada 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -89,7 +89,7 @@ SECTIONS { src/overworld.o(.text); asm/fieldmap.o(.text); src/metatile_behavior.o(.text); - asm/field_camera.o(.text); + src/field_camera.o(.text); src/field_door.o(.text); asm/field_player_avatar.o(.text); src/field_map_obj.o(.text); @@ -154,14 +154,14 @@ SECTIONS { src/pokemon_size_record.o(.text); asm/fldeff_80F9BCC.o(.text); src/field_special_scene.o(.text); - asm/rotating_gate.o(.text); + src/rotating_gate.o(.text); src/safari_zone.o(.text); asm/contest_link_80FC4F4.o(.text); src/item_use.o(.text); asm/battle_anim_80FE840.o(.text); src/bike.o(.text); asm/easy_chat.o(.text); - asm/mon_markings.o(.text); + src/mon_markings.o(.text); asm/mauville_old_man.o(.text); src/mail.o(.text); asm/menu_helpers.o(.text); @@ -450,12 +450,12 @@ SECTIONS { src/pokemon_size_record.o(.rodata) data/field_effect_misc.o(.rodata); data/field_special_scene.o(.rodata); - data/rotating_gate.o(.rodata); + src/rotating_gate.o(.rodata); data/item_use.o(.rodata); data/battle_anim_80FE840.o(.rodata); src/bike.o(.rodata); data/easy_chat.o(.rodata); - data/mon_markings.o(.rodata); + src/mon_markings.o(.rodata); data/mauville_old_man.o(.rodata); src/mail.o(.rodata); data/menu_helpers.o(.rodata); diff --git a/src/bike.c b/src/bike.c index 64af7c711..782eceb8e 100644 --- a/src/bike.c +++ b/src/bike.c @@ -12,7 +12,6 @@ extern bool8 gBikeCyclingChallenge; extern u8 gBikeCollisions; -extern bool8 gUnknown_02037348; extern u8 sub_8093514(u8 direction); extern u8 sub_808B980(u8 direction); @@ -989,7 +988,7 @@ bool8 player_should_look_direction_be_enforced_upon_movement(void) void GetOnOffBike(u8 transitionFlags) { - gUnknown_02037348 = FALSE; + gUnusedBikeCameraAheadPanback = FALSE; if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) { diff --git a/src/decoration.c b/src/decoration.c index a0855db69..f376c2115 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1305,12 +1305,12 @@ void sub_8128060(u8 taskId) void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor) { - sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.unk4].data[0]; - gUnknown_03005DD0.unk4 = gpu_pal_decompress_alloc_tag_and_upload(data, decor); - gSprites[gUnknown_03005DD0.unk4].oam.priority = 1; - gSprites[gUnknown_03005DD0.unk4].callback = sub_81292D0; - gSprites[gUnknown_03005DD0.unk4].pos1.x = gUnknown_085A7250[data->decoration->shape].x; - gSprites[gUnknown_03005DD0.unk4].pos1.y = gUnknown_085A7250[data->decoration->shape].y; + sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0]; + gUnknown_03005DD0.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor); + gSprites[gUnknown_03005DD0.spriteId].oam.priority = 1; + gSprites[gUnknown_03005DD0.spriteId].callback = sub_81292D0; + gSprites[gUnknown_03005DD0.spriteId].pos1.x = gUnknown_085A7250[data->decoration->shape].x; + gSprites[gUnknown_03005DD0.spriteId].pos1.y = gUnknown_085A7250[data->decoration->shape].y; } void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data) @@ -1332,7 +1332,7 @@ void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphic } gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1; DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]); - sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.unk4; + sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId; } void sub_812826C(u8 taskId) @@ -2251,9 +2251,9 @@ bool8 sub_81299AC(u8 taskId) void SetUpPuttingAwayDecorationPlayerAvatar(void) { player_get_direction_lower_nybble(); - sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.unk4].data[0]; + sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0]; sub_812A39C(); - gUnknown_03005DD0.unk4 = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0); + gUnknown_03005DD0.spriteId = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0); if (gSaveBlock2Ptr->playerGender == MALE) { sDecor_CameraSpriteObjectIdx2 = AddPseudoFieldObject(0xC1, SpriteCallbackDummy, 0x88, 0x48, 0); @@ -2264,7 +2264,7 @@ void SetUpPuttingAwayDecorationPlayerAvatar(void) } gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1; DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]); - sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.unk4; + sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId; gSprites[sDecor_CameraSpriteObjectIdx1].oam.priority = 1; } diff --git a/src/field_camera.c b/src/field_camera.c index 17ced6aa5..f653e0bf1 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -1,9 +1,18 @@ - -// Includes #include "global.h" +#include "berry.h" +#include "bike.h" +#include "field_camera.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "field_map_obj.h" +#include "gpu_regs.h" +#include "menu.h" +#include "overworld.h" +#include "rotating_gate.h" +#include "sprite.h" +#include "text.h" // Static type declarations - struct FieldCameraUnknownStruct { u8 unk0; @@ -13,16 +22,474 @@ struct FieldCameraUnknownStruct bool8 unk4; }; -// Static RAM declarations +// static functions +static void RedrawMapSliceNorth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData); +static void RedrawMapSliceSouth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData); +static void RedrawMapSliceEast(struct FieldCameraUnknownStruct *a, const struct MapData *mapData); +static void RedrawMapSliceWest(struct FieldCameraUnknownStruct *a, const struct MapData *mapData); +static s32 MapPosToBgTilemapOffset(struct FieldCameraUnknownStruct *a, s32 x, s32 y); +static void DrawWholeMapViewInternal(int x, int y, const struct MapData *mapData); +static void DrawMetatileAt(const struct MapData *mapData, u16, int, int); +static void DrawMetatile(s32 a, u16 *b, u16 c); +static void CameraPanningCB_PanAhead(void); -IWRAM_DATA struct FieldCameraUnknownStruct gUnknown_03000E20; -IWRAM_DATA s16 gUnknown_03000E28; -IWRAM_DATA s16 gUnknown_03000E2A; -IWRAM_DATA u8 gUnknown_03000E2C; -IWRAM_DATA void (*gUnknown_03000E30)(void); +// IWRAM bss vars +static IWRAM_DATA struct FieldCameraUnknownStruct gUnknown_03000E20; +static IWRAM_DATA s16 gUnknown_03000E28; +static IWRAM_DATA s16 gUnknown_03000E2A; +static IWRAM_DATA u8 gUnknown_03000E2C; +static IWRAM_DATA void (*gUnknown_03000E30)(void); -// Static ROM declarations +// text +static void move_tilemap_camera_to_upper_left_corner_(struct FieldCameraUnknownStruct *a) +{ + a->unk2 = 0; + a->unk3 = 0; + a->unk0 = 0; + a->unk1 = 0; + a->unk4 = TRUE; +} -// .rodata +static void tilemap_move_something(struct FieldCameraUnknownStruct *a, u32 b, u32 c) +{ + a->unk2 += b; + a->unk2 %= 32; + a->unk3 += c; + a->unk3 %= 32; +} + +static void coords8_add(struct FieldCameraUnknownStruct *a, u32 b, u32 c) +{ + a->unk0 += b; + a->unk1 += c; +} + +void move_tilemap_camera_to_upper_left_corner(void) +{ + move_tilemap_camera_to_upper_left_corner_(&gUnknown_03000E20); +} + +void FieldUpdateBgTilemapScroll(void) +{ + u32 r4, r5; + r5 = gUnknown_03000E20.unk0 + gUnknown_03000E28; + r4 = gUnknown_03000E2A + gUnknown_03000E20.unk1 + 8; + + SetGpuReg(REG_OFFSET_BG1HOFS, r5); + SetGpuReg(REG_OFFSET_BG1VOFS, r4); + SetGpuReg(REG_OFFSET_BG2HOFS, r5); + SetGpuReg(REG_OFFSET_BG2VOFS, r4); + SetGpuReg(REG_OFFSET_BG3HOFS, r5); + SetGpuReg(REG_OFFSET_BG3VOFS, r4); +} + +void sub_8089C08(s16 *a, s16 *b) +{ + *a = gUnknown_03000E20.unk0 + gUnknown_03000E28; + *b = gUnknown_03000E20.unk1 + gUnknown_03000E2A + 8; +} + +void DrawWholeMapView(void) +{ + DrawWholeMapViewInternal(gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y, gMapHeader.mapData); + gUnknown_03000E20.unk4 = TRUE; +} + +static void DrawWholeMapViewInternal(int x, int y, const struct MapData *mapData) +{ + u8 i; + u8 j; + u32 r6; + u8 temp; + + for (i = 0; i < 32; i += 2) + { + temp = gUnknown_03000E20.unk3 + i; + if (temp >= 32) + temp -= 32; + r6 = temp * 32; + for (j = 0; j < 32; j += 2) + { + temp = gUnknown_03000E20.unk2 + j; + if (temp >= 32) + temp -= 32; + DrawMetatileAt(mapData, r6 + temp, x + j / 2, y + i / 2); + } + } +} + +static void RedrawMapSlicesForCameraUpdate(struct FieldCameraUnknownStruct *a, int x, int y) +{ + const struct MapData *mapData = gMapHeader.mapData; + + if (x > 0) + RedrawMapSliceWest(a, mapData); + if (x < 0) + RedrawMapSliceEast(a, mapData); + if (y > 0) + RedrawMapSliceNorth(a, mapData); + if (y < 0) + RedrawMapSliceSouth(a, mapData); + a->unk4 = TRUE; +} + +static void RedrawMapSliceNorth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData) +{ + u8 i; + u8 temp; + u32 r7; + + temp = a->unk3 + 28; + if (temp >= 32) + temp -= 32; + r7 = temp * 32; + for (i = 0; i < 32; i += 2) + { + temp = a->unk2 + i; + if (temp >= 32) + temp -= 32; + DrawMetatileAt(mapData, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y + 14); + } +} + +static void RedrawMapSliceSouth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData) +{ + u8 i; + u8 temp; + u32 r7 = a->unk3 * 32; + + for (i = 0; i < 32; i += 2) + { + temp = a->unk2 + i; + if (temp >= 32) + temp -= 32; + DrawMetatileAt(mapData, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y); + } +} + +static void RedrawMapSliceEast(struct FieldCameraUnknownStruct *a, const struct MapData *mapData) +{ + u8 i; + u8 temp; + u32 r6 = a->unk2; + + for (i = 0; i < 32; i += 2) + { + temp = a->unk3 + i; + if (temp >= 32) + temp -= 32; + DrawMetatileAt(mapData, temp * 32 + r6, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y + i / 2); + } +} + +static void RedrawMapSliceWest(struct FieldCameraUnknownStruct *a, const struct MapData *mapData) +{ + u8 i; + u8 temp; + u8 r5 = a->unk2 + 28; + + if (r5 >= 32) + r5 -= 32; + for (i = 0; i < 32; i += 2) + { + temp = a->unk3 + i; + if (temp >= 32) + temp -= 32; + DrawMetatileAt(mapData, temp * 32 + r5, gSaveBlock1Ptr->pos.x + 14, gSaveBlock1Ptr->pos.y + i / 2); + } +} + +void CurrentMapDrawMetatileAt(int a, int b) +{ + int offset = MapPosToBgTilemapOffset(&gUnknown_03000E20, a, b); + + if (offset >= 0) + { + DrawMetatileAt(gMapHeader.mapData, offset, a, b); + gUnknown_03000E20.unk4 = TRUE; + } +} + +void DrawDoorMetatileAt(int x, int y, u16 *arr) +{ + int offset = MapPosToBgTilemapOffset(&gUnknown_03000E20, x, y); + + if (offset >= 0) + { + DrawMetatile(1, arr, offset); + gUnknown_03000E20.unk4 = TRUE; + } +} + +static void DrawMetatileAt(const struct MapData *mapData, u16 b, int c, int d) +{ + u16 metatileId = MapGridGetMetatileIdAt(c, d); + u16 *metatiles; + + if (metatileId > 1024) + metatileId = 0; + if (metatileId < 512) + metatiles = mapData->primaryTileset->metatiles; + else + { + metatiles = mapData->secondaryTileset->metatiles; + metatileId -= 512; + } + DrawMetatile(MapGridGetMetatileLayerTypeAt(c, d), metatiles + metatileId * 8, b); +} + +static void DrawMetatile(s32 a, u16 *b, u16 c) +{ + switch (a) + { + case 2: + gBGTilemapBuffers3[c] = b[0]; + gBGTilemapBuffers3[c + 1] = b[1]; + gBGTilemapBuffers3[c + 0x20] = b[2]; + gBGTilemapBuffers3[c + 0x21] = b[3]; + + gBGTilemapBuffers1[c] = 0; + gBGTilemapBuffers1[c + 1] = 0; + gBGTilemapBuffers1[c + 0x20] = 0; + gBGTilemapBuffers1[c + 0x21] = 0; + + gBGTilemapBuffers2[c] = b[4]; + gBGTilemapBuffers2[c + 1] = b[5]; + gBGTilemapBuffers2[c + 0x20] = b[6]; + gBGTilemapBuffers2[c + 0x21] = b[7]; + break; + case 1: + gBGTilemapBuffers3[c] = b[0]; + gBGTilemapBuffers3[c + 1] = b[1]; + gBGTilemapBuffers3[c + 0x20] = b[2]; + gBGTilemapBuffers3[c + 0x21] = b[3]; + + gBGTilemapBuffers1[c] = b[4]; + gBGTilemapBuffers1[c + 1] = b[5]; + gBGTilemapBuffers1[c + 0x20] = b[6]; + gBGTilemapBuffers1[c + 0x21] = b[7]; + + gBGTilemapBuffers2[c] = 0; + gBGTilemapBuffers2[c + 1] = 0; + gBGTilemapBuffers2[c + 0x20] = 0; + gBGTilemapBuffers2[c + 0x21] = 0; + break; + case 0: + gBGTilemapBuffers3[c] = 0x3014; + gBGTilemapBuffers3[c + 1] = 0x3014; + gBGTilemapBuffers3[c + 0x20] = 0x3014; + gBGTilemapBuffers3[c + 0x21] = 0x3014; + + gBGTilemapBuffers1[c] = b[0]; + gBGTilemapBuffers1[c + 1] = b[1]; + gBGTilemapBuffers1[c + 0x20] = b[2]; + gBGTilemapBuffers1[c + 0x21] = b[3]; + + gBGTilemapBuffers2[c] = b[4]; + gBGTilemapBuffers2[c + 1] = b[5]; + gBGTilemapBuffers2[c + 0x20] = b[6]; + gBGTilemapBuffers2[c + 0x21] = b[7]; + break; + } + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + schedule_bg_copy_tilemap_to_vram(3); +} + +static s32 MapPosToBgTilemapOffset(struct FieldCameraUnknownStruct *a, s32 x, s32 y) +{ + x -= gSaveBlock1Ptr->pos.x; + x *= 2; + if (x >= 32 || x < 0) + return -1; + x = x + a->unk2; + if (x >= 32) + x -= 32; + + y = (y - gSaveBlock1Ptr->pos.y) * 2; + if (y >= 32 || y < 0) + return -1; + y = y + a->unk3; + if (y >= 32) + y -= 32; + + return y * 32 + x; +} + +static void CameraUpdateCallback(struct CameraObject *a) +{ + if (a->spriteId != 0) + { + a->unk8 = gSprites[a->spriteId].data[2]; + a->unkC = gSprites[a->spriteId].data[3]; + } +} + +void ResetCameraUpdateInfo(void) +{ + gUnknown_03005DD0.unk8 = 0; + gUnknown_03005DD0.unkC = 0; + gUnknown_03005DD0.x = 0; + gUnknown_03005DD0.y = 0; + gUnknown_03005DD0.spriteId = 0; + gUnknown_03005DD0.callback = NULL; +} + +u32 InitCameraUpdateCallback(u8 a) +{ + if (gUnknown_03005DD0.spriteId != 0) + DestroySprite(&gSprites[gUnknown_03005DD0.spriteId]); + gUnknown_03005DD0.spriteId = AddCameraObject(a); + gUnknown_03005DD0.callback = CameraUpdateCallback; + return 0; +} + +void CameraUpdate(void) +{ + int deltaX; + int deltaY; + int r0; + int r1; + int r7; + int r8; + + if (gUnknown_03005DD0.callback != NULL) + gUnknown_03005DD0.callback(&gUnknown_03005DD0); + r7 = gUnknown_03005DD0.unk8; + r8 = gUnknown_03005DD0.unkC; + deltaX = 0; + deltaY = 0; + r1 = gUnknown_03005DD0.x; + r0 = gUnknown_03005DD0.y; + + + if (r1 == 0 && r7 != 0) + { + if (r7 > 0) + deltaX = 1; + else + deltaX = -1; + } + if (r0 == 0 && r8 != 0) + { + if (r8 > 0) + deltaY = 1; + else + deltaY = -1; + } + if (r1 != 0 && r1 == -r7) + { + if (r7 > 0) + deltaX = 1; + else + deltaX = -1; + } + if (r0 != 0 && r0 == -r8) + { + if (r8 > 0) + deltaX = 1; + else + deltaX = -1; + } + + gUnknown_03005DD0.x += r7; + gUnknown_03005DD0.x = gUnknown_03005DD0.x - 16 * (gUnknown_03005DD0.x / 16); + gUnknown_03005DD0.y += r8; + gUnknown_03005DD0.y = gUnknown_03005DD0.y - 16 * (gUnknown_03005DD0.y / 16); + + if (deltaX != 0 || deltaY != 0) + { + CameraMove(deltaX, deltaY); + UpdateFieldObjectsForCameraUpdate(deltaX, deltaY); + RotatingGatePuzzleCameraUpdate(deltaX, deltaY); + ResetBerryTreeSparkleFlags(); + tilemap_move_something(&gUnknown_03000E20, deltaX * 2, deltaY * 2); + RedrawMapSlicesForCameraUpdate(&gUnknown_03000E20, deltaX * 2, deltaY * 2); + } + + coords8_add(&gUnknown_03000E20, r7, r8); + gUnknown_03005DEC -= r7; + gUnknown_03005DE8 -= r8; +} + +void camera_move_and_redraw(int a, int b) //unused +{ + CameraMove(a, b); + UpdateFieldObjectsForCameraUpdate(a, b); + DrawWholeMapView(); + gUnknown_03005DEC -= a * 16; + gUnknown_03005DE8 -= b * 16; +} + +void SetCameraPanningCallback(void (*a)(void)) +{ + gUnknown_03000E30 = a; +} + +void SetCameraPanning(s16 a, s16 b) +{ + gUnknown_03000E28 = a; + gUnknown_03000E2A = b + 32; +} + +void InstallCameraPanAheadCallback(void) +{ + gUnknown_03000E30 = CameraPanningCB_PanAhead; + gUnknown_03000E2C = 0; + gUnknown_03000E28 = 0; + gUnknown_03000E2A = 32; +} + +void UpdateCameraPanning(void) +{ + if (gUnknown_03000E30 != NULL) + gUnknown_03000E30(); + //Update sprite offset of overworld objects + gSpriteCoordOffsetX = gUnknown_03005DEC - gUnknown_03000E28; + gSpriteCoordOffsetY = gUnknown_03005DE8 - gUnknown_03000E2A - 8; +} + +static void CameraPanningCB_PanAhead(void) +{ + u8 var; + + if (gUnusedBikeCameraAheadPanback == FALSE) + { + InstallCameraPanAheadCallback(); + } + else + { + // this code is never reached. + if (gPlayerAvatar.tileTransitionState == T_TILE_TRANSITION) + { + gUnknown_03000E2C ^= 1; + if (gUnknown_03000E2C == 0) + return; + } + else + { + gUnknown_03000E2C = 0; + } + + var = player_get_direction_upper_nybble(); + if (var == 2) + { + if (gUnknown_03000E2A > -8) + gUnknown_03000E2A -= 2; + } + else if (var == 1) + { + if (gUnknown_03000E2A < 72) + gUnknown_03000E2A += 2; + } + else if (gUnknown_03000E2A < 32) + { + gUnknown_03000E2A += 2; + } + else if (gUnknown_03000E2A > 32) + { + gUnknown_03000E2A -= 2; + } + } +} -// .text diff --git a/src/mon_markings.c b/src/mon_markings.c new file mode 100644 index 000000000..147872ab6 --- /dev/null +++ b/src/mon_markings.c @@ -0,0 +1,611 @@ +#include "global.h" +#include "dma3.h" +#include "graphics.h" +#include "main.h" +#include "menu_indicators.h" +#include "mon_markings.h" +#include "constants/songs.h" +#include "sound.h" +#include "sprite.h" +#include "text_window.h" + +#define MENU_TEXT_SPRITE_X_OFFSET 32 + +// static functions +static void sub_811FC80(s16, s16, u16, u16); +static void TaskDummy7(struct Sprite *); +static void sub_811FF40(struct Sprite *); +static void sub_811FF7C(struct Sprite *); +static struct Sprite *sub_811FFD4(u16, u16, const u16 *, u16); + +// .rodata +static const u16 gUnknown_0859E65C[] = INCBIN_U16("graphics/misc/mon_markings.gbapal"); +static const u8 gUnknown_0859E67C[] = INCBIN_U8("graphics/misc/mon_markings.4bpp"); + +static const struct OamData gUnknown_0859EE7C = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const struct OamData gUnknown_0859EE84 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd gUnknown_0859EE8C[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EE94[] = +{ + ANIMCMD_FRAME(1, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EE9C[] = +{ + ANIMCMD_FRAME(2, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EEA4[] = +{ + ANIMCMD_FRAME(3, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EEAC[] = +{ + ANIMCMD_FRAME(4, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EEB4[] = +{ + ANIMCMD_FRAME(5, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EEBC[] = +{ + ANIMCMD_FRAME(6, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EEC4[] = +{ + ANIMCMD_FRAME(7, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EECC[] = +{ + ANIMCMD_FRAME(8, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EED4[] = +{ + ANIMCMD_FRAME(9, 5), + ANIMCMD_END, +}; + +static const union AnimCmd *const gUnknown_0859EEDC[] = +{ + gUnknown_0859EE8C, + gUnknown_0859EE94, + gUnknown_0859EE9C, + gUnknown_0859EEA4, + gUnknown_0859EEAC, + gUnknown_0859EEB4, + gUnknown_0859EEBC, + gUnknown_0859EEC4, + gUnknown_0859EECC, + gUnknown_0859EED4, +}; + +static const union AnimCmd gUnknown_0859EF04[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF0C[] = +{ + ANIMCMD_FRAME(64, 5), + ANIMCMD_END, +}; + +static const union AnimCmd *const gUnknown_0859EF14[] = +{ + gUnknown_0859EF04, + gUnknown_0859EF0C, +}; + +static const struct OamData gUnknown_0859EF1C = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd gUnknown_0859EF24[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF2C[] = +{ + ANIMCMD_FRAME(4, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF34[] = +{ + ANIMCMD_FRAME(8, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF3C[] = +{ + ANIMCMD_FRAME(12, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF44[] = +{ + ANIMCMD_FRAME(16, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF4C[] = +{ + ANIMCMD_FRAME(20, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF54[] = +{ + ANIMCMD_FRAME(24, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF5C[] = +{ + ANIMCMD_FRAME(28, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF64[] = +{ + ANIMCMD_FRAME(32, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF6C[] = +{ + ANIMCMD_FRAME(36, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF74[] = +{ + ANIMCMD_FRAME(40, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF7C[] = +{ + ANIMCMD_FRAME(44, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF84[] = +{ + ANIMCMD_FRAME(48, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF8C[] = +{ + ANIMCMD_FRAME(52, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF94[] = +{ + ANIMCMD_FRAME(56, 5), + ANIMCMD_END, +}; + +static const union AnimCmd gUnknown_0859EF9C[] = +{ + ANIMCMD_FRAME(60, 5), + ANIMCMD_END, +}; + +static const union AnimCmd *const gUnknown_0859EFA4[] = +{ + gUnknown_0859EF24, + gUnknown_0859EF2C, + gUnknown_0859EF34, + gUnknown_0859EF3C, + gUnknown_0859EF44, + gUnknown_0859EF4C, + gUnknown_0859EF54, + gUnknown_0859EF5C, + gUnknown_0859EF64, + gUnknown_0859EF6C, + gUnknown_0859EF74, + gUnknown_0859EF7C, + gUnknown_0859EF84, + gUnknown_0859EF8C, + gUnknown_0859EF94, + gUnknown_0859EF9C, +}; + +static EWRAM_DATA struct PokemonMarkMenu *sMenu = NULL; + +void sub_811F90C(struct PokemonMarkMenu *ptr) +{ + sMenu = ptr; +} + +void sub_811F918(void) +{ + const struct TilesPal *frame = GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType); + sMenu->frameTiles = frame->tiles; + sMenu->framePalette = frame->pal; + sMenu->tileLoadState = 0; + CpuFill16(0, sMenu->menuWindowSpriteTiles, sizeof(sMenu->menuWindowSpriteTiles)); +} + +bool8 sub_811F960(void) +{ + u16 i; + u8 *dest = sMenu->menuWindowSpriteTiles + sMenu->tileLoadState * 0x100; + + switch (sMenu->tileLoadState) + { + case 0: + CpuFastCopy(sMenu->frameTiles, dest, TILE_SIZE_4BPP); + for (i = 0; i < 6; i++) + { + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP); + } + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 2, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP); + sMenu->tileLoadState++; + break; + default: + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 3, dest, TILE_SIZE_4BPP); + for (i = 0; i < 6; i++) + { + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 4, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP); + } + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 5, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP); + sMenu->tileLoadState++; + break; + case 13: + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 6, dest, TILE_SIZE_4BPP); + for (i = 0; i < 6; i++) + { + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 7, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP); + } + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 8, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP); + sMenu->tileLoadState++; + return FALSE; + case 14: + return FALSE; + } + + return TRUE; +} + +void sub_811FA90(void) +{ + sub_811F918(); + while (sub_811F960()); +} + +void sub_811FAA4(u8 markings, s16 x, s16 y) +{ + u16 i; + sMenu->cursorPos = 0; + sMenu->markings = markings; + for (i = 0; i < 4; i++) + sMenu->markingsArray[i] = (sMenu->markings >> i) & 1; + sub_811FC80(x, y, sMenu->baseTileTag, sMenu->basePaletteTag); +} + +void sub_811FAF8(void) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + FreeSpriteTilesByTag(sMenu->baseTileTag + i); + FreeSpritePaletteByTag(sMenu->basePaletteTag + i); + } + for (i = 0; i < 2; i++) + { + if (!sMenu->menuWindowSprites[i]) + return; + DestroySprite(sMenu->menuWindowSprites[i]); + sMenu->menuWindowSprites[i] = NULL; + } + for (i = 0; i < 4; i++) + { + if (!sMenu->menuMarkingSprites[i]) + return; + DestroySprite(sMenu->menuMarkingSprites[i]); + sMenu->menuMarkingSprites[i] = NULL; + } + if (sMenu->unkSprite) + { + DestroySprite(sMenu->unkSprite); + sMenu->unkSprite = NULL; + } + if (sMenu->menuTextSprite) + { + DestroySprite(sMenu->menuTextSprite); + sMenu->menuTextSprite = NULL; + } +} + + +bool8 sub_811FBA4(void) +{ + u16 i; + + if (gMain.newKeys & DPAD_UP) + { + s8 pos; + PlaySE(SE_SELECT); + pos = --sMenu->cursorPos; + if (pos < 0) + sMenu->cursorPos = 5; + return TRUE; + } + + if (gMain.newKeys & DPAD_DOWN) + { + s8 pos; + PlaySE(SE_SELECT); + pos = ++sMenu->cursorPos; + if (pos > 5) + sMenu->cursorPos = 0; + return TRUE; + } + + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + + switch (sMenu->cursorPos) + { + case 4: + sMenu->markings = 0; + for (i = 0; i < 4; i++) + sMenu->markings |= sMenu->markingsArray[i] << i; + return FALSE; + case 5: + return FALSE; + } + + sMenu->markingsArray[sMenu->cursorPos] = !sMenu->markingsArray[sMenu->cursorPos]; + return TRUE; + } + + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + return FALSE; + } + + return TRUE; +} + +static void sub_811FC80(s16 x, s16 y, u16 baseTileTag, u16 basePaletteTag) +{ + u16 i; + u8 spriteId; + + struct SpriteSheet sheets[] = + { + { sMenu->menuWindowSpriteTiles, 0x1000, baseTileTag }, + { gPokenavConditionMarker_Gfx, 0x320, baseTileTag + 1 }, + { NULL, 0 } + }; + + struct SpritePalette palettes[] = + { + { sMenu->framePalette, basePaletteTag }, + { gPokenavConditionMarker_Pal, basePaletteTag + 1}, + { NULL, 0 } + }; + + struct SpriteTemplate sprTemplate = + { + baseTileTag, + basePaletteTag, + &gUnknown_0859EE7C, + gUnknown_0859EF14, + NULL, + gDummySpriteAffineAnimTable, + TaskDummy7, + }; + + LoadSpriteSheets(sheets); + LoadSpritePalettes(palettes); + + for (i = 0; i < 2; i++) + { + spriteId = CreateSprite(&sprTemplate, x + 32, y + 32, 1); + if (spriteId != 64) + { + sMenu->menuWindowSprites[i] = &gSprites[spriteId]; + StartSpriteAnim(&gSprites[spriteId], i); + } + else + { + sMenu->menuWindowSprites[i] = NULL; + return; + } + } + + sMenu->menuWindowSprites[1]->pos1.y = y + 96; + + sprTemplate.tileTag++; + sprTemplate.paletteTag++; + sprTemplate.anims = gUnknown_0859EEDC; + sprTemplate.callback = sub_811FF40; + sprTemplate.oam = &gUnknown_0859EE84; + + for (i = 0; i < 4; i++) + { + spriteId = CreateSprite(&sprTemplate, x + 32, y + 16 + 16 * i, 0); + if (spriteId != 64) + { + sMenu->menuMarkingSprites[i] = &gSprites[spriteId]; + gSprites[spriteId].data[0] = i; + } + else + { + sMenu->menuMarkingSprites[i] = NULL; + return; + } + } + + sprTemplate.callback = SpriteCallbackDummy; + + spriteId = CreateSprite(&sprTemplate, 0, 0, 0); + + if (spriteId != 64) + { + sMenu->menuTextSprite = &gSprites[spriteId]; + sMenu->menuTextSprite->oam.shape = ST_OAM_SQUARE; + sMenu->menuTextSprite->oam.size = 2; + StartSpriteAnim(sMenu->menuTextSprite, 9); + sMenu->menuTextSprite->pos1.x = x + MENU_TEXT_SPRITE_X_OFFSET; + sMenu->menuTextSprite->pos1.y = y + 80; + CalcCenterToCornerVec(sMenu->menuTextSprite, 1, 2, 0); + } + else + { + sMenu->menuTextSprite = NULL; + } + + sprTemplate.callback = sub_811FF7C; + spriteId = CreateSprite(&sprTemplate, x + 12, 0, 0); + if(spriteId != 64) + { + sMenu->unkSprite = &gSprites[spriteId]; + sMenu->unkSprite->data[0] = y + 16; + StartSpriteAnim(sMenu->unkSprite, 8); + } + else + { + sMenu->unkSprite = NULL; + } + +} + +static void TaskDummy7(struct Sprite *sprite) +{ +} + +static void sub_811FF40(struct Sprite *sprite) +{ + if (sMenu->markingsArray[sprite->data[0]]) + StartSpriteAnim(sprite, 2 * sprite->data[0] + 1); + else + StartSpriteAnim(sprite, 2 * sprite->data[0]); +} + +static void sub_811FF7C(struct Sprite *sprite) +{ + sprite->pos1.y = (16 * sMenu->cursorPos) + sprite->data[0]; +} + +struct Sprite *sub_811FF94(u16 tileTag, u16 paletteTag, const u16 *palette) +{ + if (!palette) + palette = gUnknown_0859E65C; + return sub_811FFD4(tileTag, paletteTag, palette, 16); +} + +struct Sprite *sub_811FFB4(u16 tileTag, u16 paletteTag, const u16 *palette) +{ + if (!palette) + palette = gUnknown_0859E65C; + return sub_811FFD4(tileTag, paletteTag, palette, 1); +} + +static struct Sprite *sub_811FFD4(u16 tileTag, u16 paletteTag, const u16 *palette, u16 size) +{ + u8 spriteId; + struct SpriteTemplate sprTemplate; + struct SpriteSheet sheet = { gUnknown_0859E67C, 0x80, tileTag }; + struct SpritePalette sprPalette = { palette, paletteTag }; + + sprTemplate.tileTag = tileTag; + sprTemplate.paletteTag = paletteTag; + sprTemplate.oam = &gUnknown_0859EF1C; + sprTemplate.anims = gUnknown_0859EFA4; + sprTemplate.images = NULL; + sprTemplate.affineAnims = gDummySpriteAffineAnimTable; + sprTemplate.callback = TaskDummy7; + + sheet.size = size * 0x80; + + LoadSpriteSheet(&sheet); + LoadSpritePalette(&sprPalette); + + spriteId = CreateSprite(&sprTemplate, 0, 0, 0); + if (spriteId != 64) + return &gSprites[spriteId]; + else + return NULL; +} + +void sub_8120084(u8 markings, void *dest) +{ + RequestDma3Copy(gUnknown_0859E67C + markings * 0x80, dest, 0x80, 0x10); +} diff --git a/src/overworld.c b/src/overworld.c index 920f6f8f1..532615f27 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -89,9 +89,6 @@ extern const u16 gUnknown_82EC7C4[]; extern u16 gSaveFileStatus; extern u16 gUnknown_03005DA8; -extern u8 *gUnknown_03005DA0; -extern u8 *gUnknown_03005D9C; -extern u8 *gUnknown_03005DA4; extern bool8 (*gUnknown_03005DB0)(void); extern u8 gUnknown_03005DB4; extern u8 gFieldLinkPlayerCount; @@ -1422,12 +1419,12 @@ static void overworld_bg_setup(void) SetBgAttribute(1, BG_CTRL_ATTR_PALETTEMODE, 1); SetBgAttribute(2, BG_CTRL_ATTR_PALETTEMODE, 1); SetBgAttribute(3, BG_CTRL_ATTR_PALETTEMODE, 1); - gUnknown_03005DA0 = AllocZeroed(0x800); - gUnknown_03005D9C = AllocZeroed(0x800); - gUnknown_03005DA4 = AllocZeroed(0x800); - SetBgTilemapBuffer(1, gUnknown_03005DA0); - SetBgTilemapBuffer(2, gUnknown_03005D9C); - SetBgTilemapBuffer(3, gUnknown_03005DA4); + gBGTilemapBuffers2 = AllocZeroed(0x800); + gBGTilemapBuffers1 = AllocZeroed(0x800); + gBGTilemapBuffers3 = AllocZeroed(0x800); + SetBgTilemapBuffer(1, gBGTilemapBuffers2); + SetBgTilemapBuffer(2, gBGTilemapBuffers1); + SetBgTilemapBuffer(3, gBGTilemapBuffers3); sub_81971D0(); } @@ -1435,12 +1432,12 @@ void overworld_free_bg_tilemaps(void) { sub_81BE72C(); sub_81971F4(); - if (gUnknown_03005DA4 != NULL) - FREE_AND_SET_NULL(gUnknown_03005DA4); - if (gUnknown_03005D9C != NULL) - FREE_AND_SET_NULL(gUnknown_03005D9C); - if (gUnknown_03005DA0 != NULL) - FREE_AND_SET_NULL(gUnknown_03005DA0); + if (gBGTilemapBuffers3 != NULL) + FREE_AND_SET_NULL(gBGTilemapBuffers3); + if (gBGTilemapBuffers1 != NULL) + FREE_AND_SET_NULL(gBGTilemapBuffers1); + if (gBGTilemapBuffers2 != NULL) + FREE_AND_SET_NULL(gBGTilemapBuffers2); } static void ResetSafariZoneFlag_(void) diff --git a/src/rotating_gate.c b/src/rotating_gate.c new file mode 100644 index 000000000..db5935fc3 --- /dev/null +++ b/src/rotating_gate.c @@ -0,0 +1,1188 @@ +#include "global.h" +#include "bike.h" +#include "event_data.h" +#include "field_map_obj.h" +#include "constants/maps.h" +#include "constants/songs.h" +#include "sound.h" +#include "sprite.h" + +#define ROTATING_GATE_TILE_TAG 0x1300 +#define ROTATING_GATE_PUZZLE_MAX 12 +#define GATE_ARM_MAX_LENGTH 2 + +#define GATE_ROT(rotationDirection, arm, longArm) \ + ((rotationDirection & 15) << 4) | ((arm & 7) << 1) | (longArm & 1) +#define GATE_ROT_CW(arm, longArm) GATE_ROT(ROTATE_CLOCKWISE, arm, longArm) +#define GATE_ROT_ACW(arm, longArm) GATE_ROT(ROTATE_ANTICLOCKWISE, arm, longArm) +#define GATE_ROT_NONE 255 + +// static functions +static void SpriteCallback_RotatingGate(struct Sprite *sprite); +static u8 RotatingGate_CreateGate(u8 gateId, s16 deltaX, s16 deltaY); +static void RotatingGate_HideGatesOutsideViewport(struct Sprite *sprite); + +// enums +enum +{ + /* + * | + * +-- + */ + GATE_SHAPE_L1, + + /* + * | + * | + * +-- + */ + GATE_SHAPE_L2, + + /* + * | + * +---- + */ + GATE_SHAPE_L3, + + /* + * | + * | + * +---- + */ + GATE_SHAPE_L4, + + /* + * | + * +-- + * | + */ + GATE_SHAPE_T1, + + /* + * | + * | + * +-- + * | + */ + GATE_SHAPE_T2, + + /* + * | + * +---- + * | + */ + GATE_SHAPE_T3, + + /* + * An unused T-shape gate + * | + * +-- + * | + * | + */ + GATE_SHAPE_T4, + + /* + * An unused T-shape gate + * | + * | + * +---- + * | + */ + GATE_SHAPE_UNUSED_T1, + + /* + * An unused T-shape gate + * | + * | + * +-- + * | + * | + */ + GATE_SHAPE_UNUSED_T2, + + /* + * An unused T-shape gate + * | + * +---- + * | + * | + */ + GATE_SHAPE_UNUSED_T3, + + /* + * An unused T-shape gate + * | + * | + * +---- + * | + * | + */ + GATE_SHAPE_UNUSED_T4, +}; + +enum +{ + /* + * 0 degrees (clockwise) + * | + * +-- + * | + */ + GATE_ORIENTATION_0, + + /* + * 90 degress (clockwise) + * --+-- + * | + */ + GATE_ORIENTATION_90, + + /* + * 180 degrees (clockwise) + * | + * --+ + * | + */ + GATE_ORIENTATION_180, + + /* + * 270 degrees (clockwise) + * | + * --+-- + */ + GATE_ORIENTATION_270, + + GATE_ORIENTATION_MAX, +}; + +// Describes the location of the gates "arms" when the gate has not +// been rotated (i.e. rotated 0 degrees) +enum +{ + GATE_ARM_NORTH, + GATE_ARM_EAST, + GATE_ARM_SOUTH, + GATE_ARM_WEST, +}; + +enum +{ + ROTATE_NONE, + ROTATE_ANTICLOCKWISE, + ROTATE_CLOCKWISE, +}; + +enum +{ + PUZZLE_NONE, + PUZZLE_FORTREE_CITY_GYM, + PUZZLE_ROUTE110_TRICK_HOUSE_PUZZLE6, +}; + +// structure +struct RotatingGatePuzzle +{ + s16 x; + s16 y; + u8 shape; + u8 orientation; +}; + +struct Coords8 +{ + s8 deltaX; + s8 deltaY; +}; + +// .rodata +// Fortree +static const struct RotatingGatePuzzle sRotatingGate_FortreePuzzleConfig[] = +{ + { 6, 7, GATE_SHAPE_T2, GATE_ORIENTATION_90}, + { 9, 15, GATE_SHAPE_T2, GATE_ORIENTATION_180}, + { 3, 19, GATE_SHAPE_T2, GATE_ORIENTATION_90}, + { 2, 6, GATE_SHAPE_T1, GATE_ORIENTATION_90}, + { 9, 12, GATE_SHAPE_T1, GATE_ORIENTATION_0}, + { 6, 23, GATE_SHAPE_T1, GATE_ORIENTATION_0}, + {12, 22, GATE_SHAPE_T1, GATE_ORIENTATION_0}, + { 6, 3, GATE_SHAPE_L4, GATE_ORIENTATION_180}, +}; + +// Trickhouse +static const struct RotatingGatePuzzle sRotatingGate_TrickHousePuzzleConfig[] = +{ + {14, 5, GATE_SHAPE_T1, GATE_ORIENTATION_90}, + {10, 6, GATE_SHAPE_L2, GATE_ORIENTATION_180}, + { 6, 6, GATE_SHAPE_L4, GATE_ORIENTATION_90}, + {14, 8, GATE_SHAPE_T1, GATE_ORIENTATION_90}, + { 3, 10, GATE_SHAPE_L3, GATE_ORIENTATION_270}, + { 9, 14, GATE_SHAPE_L1, GATE_ORIENTATION_90}, + { 3, 15, GATE_SHAPE_T3, GATE_ORIENTATION_0}, + { 2, 17, GATE_SHAPE_L2, GATE_ORIENTATION_180}, + {12, 18, GATE_SHAPE_T3, GATE_ORIENTATION_270}, + { 5, 18, GATE_SHAPE_L4, GATE_ORIENTATION_90}, + {10, 19, GATE_SHAPE_L3, GATE_ORIENTATION_180}, +}; + +static const u8 sRotatingGateTiles_1[] = INCBIN_U8("graphics/misc/rotating_gate_1.4bpp"); +static const u8 sRotatingGateTiles_2[] = INCBIN_U8("graphics/misc/rotating_gate_2.4bpp"); +static const u8 sRotatingGateTiles_3[] = INCBIN_U8("graphics/misc/rotating_gate_3.4bpp"); +static const u8 sRotatingGateTiles_4[] = INCBIN_U8("graphics/misc/rotating_gate_4.4bpp"); +static const u8 sRotatingGateTiles_5[] = INCBIN_U8("graphics/misc/rotating_gate_5.4bpp"); +static const u8 sRotatingGateTiles_6[] = INCBIN_U8("graphics/misc/rotating_gate_6.4bpp"); +static const u8 sRotatingGateTiles_7[] = INCBIN_U8("graphics/misc/rotating_gate_7.4bpp"); +static const u8 sRotatingGateTiles_8[] = INCBIN_U8("graphics/misc/rotating_gate_8.4bpp"); + +static const struct OamData sOamData_RotatingGateLarge = +{ + .y = 0, + .affineMode = ST_OAM_AFFINE_NORMAL, + .objMode = 0, + .mosaic = 0, + .bpp = ST_OAM_4BPP, + .shape = ST_OAM_SQUARE, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 2, + .paletteNum = 2, + .affineParam = 0, +}; + +static const struct OamData sOamData_RotatingGateRegular = +{ + .y = 0, + .affineMode = ST_OAM_AFFINE_NORMAL, + .objMode = 0, + .mosaic = 0, + .bpp = ST_OAM_4BPP, + .shape = ST_OAM_SQUARE, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 2, + .paletteNum = 2, + .affineParam = 0, +}; + +static const struct SpriteSheet sRotatingGatesGraphicsTable[] = +{ + {sRotatingGateTiles_1, 0x200, ROTATING_GATE_TILE_TAG + GATE_SHAPE_L1}, + {sRotatingGateTiles_2, 0x800, ROTATING_GATE_TILE_TAG + GATE_SHAPE_L2}, + {sRotatingGateTiles_3, 0x800, ROTATING_GATE_TILE_TAG + GATE_SHAPE_L3}, + {sRotatingGateTiles_4, 0x800, ROTATING_GATE_TILE_TAG + GATE_SHAPE_L4}, + {sRotatingGateTiles_5, 0x200, ROTATING_GATE_TILE_TAG + GATE_SHAPE_T1}, + {sRotatingGateTiles_6, 0x800, ROTATING_GATE_TILE_TAG + GATE_SHAPE_T2}, + {sRotatingGateTiles_7, 0x800, ROTATING_GATE_TILE_TAG + GATE_SHAPE_T3}, + {sRotatingGateTiles_8, 0x800, ROTATING_GATE_TILE_TAG + GATE_SHAPE_T4}, + {NULL}, +}; + +static const union AnimCmd sSpriteAnim_RotatingGateLarge[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END, +}; + +static const union AnimCmd sSpriteAnim_RotatingGateRegular[] = +{ + ANIMCMD_FRAME(0, 0), ANIMCMD_END, +}; + +static const union AnimCmd *const sSpriteAnimTable_RotatingGateLarge[] = +{ + sSpriteAnim_RotatingGateLarge, +}; + +static const union AnimCmd *const sSpriteAnimTable_RotatingGateRegular[] = +{ + sSpriteAnim_RotatingGateRegular, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_Rotated0[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sSpriteAffineAnim_Rotated90[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -64, 0), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sSpriteAffineAnim_Rotated180[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -128, 0), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sSpriteAffineAnim_Rotated270[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 64, 0), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise0to90[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise90to180[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise180to270[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -128, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise270to360[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise360to270[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise270to180[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise180to90[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -128, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise90to0[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 4, 16), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise0to90Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise90to180Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise180to270Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -128, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingClockwise270to360Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise360to270Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise270to180Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise180to90Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -128, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_RotatingAnticlockwise90to0Faster[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, -64, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 8), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_RotatingGate[] = +{ + sSpriteAffineAnim_Rotated0, + sSpriteAffineAnim_Rotated90, + sSpriteAffineAnim_Rotated180, + sSpriteAffineAnim_Rotated270, + sSpriteAffineAnim_RotatingAnticlockwise360to270, + sSpriteAffineAnim_RotatingAnticlockwise90to0, + sSpriteAffineAnim_RotatingAnticlockwise180to90, + sSpriteAffineAnim_RotatingAnticlockwise270to180, + sSpriteAffineAnim_RotatingClockwise0to90, + sSpriteAffineAnim_RotatingClockwise90to180, + sSpriteAffineAnim_RotatingClockwise180to270, + sSpriteAffineAnim_RotatingClockwise270to360, + sSpriteAffineAnim_RotatingAnticlockwise360to270Faster, + sSpriteAffineAnim_RotatingAnticlockwise90to0Faster, + sSpriteAffineAnim_RotatingAnticlockwise180to90Faster, + sSpriteAffineAnim_RotatingAnticlockwise270to180Faster, + sSpriteAffineAnim_RotatingClockwise0to90Faster, + sSpriteAffineAnim_RotatingClockwise90to180Faster, + sSpriteAffineAnim_RotatingClockwise180to270Faster, + sSpriteAffineAnim_RotatingClockwise270to360Faster, +}; + + +static const struct SpriteTemplate sSpriteTemplate_RotatingGateLarge = +{ + .tileTag = ROTATING_GATE_TILE_TAG, + .paletteTag = 0xFFFF, + .oam = &sOamData_RotatingGateLarge, + .anims = sSpriteAnimTable_RotatingGateLarge, + .images = NULL, + .affineAnims = sSpriteAffineAnimTable_RotatingGate, + .callback = SpriteCallback_RotatingGate, +}; + +static const struct SpriteTemplate sSpriteTemplate_RotatingGateRegular = +{ + .tileTag = ROTATING_GATE_TILE_TAG, + .paletteTag = 0xFFFF, + .oam = &sOamData_RotatingGateRegular, + .anims = sSpriteAnimTable_RotatingGateRegular, + .images = NULL, + .affineAnims = sSpriteAffineAnimTable_RotatingGate, + .callback = SpriteCallback_RotatingGate, +}; + +// These structures describe what happens to the gate if you hit it at +// a given coordinate in a 4x4 grid when walking in the specified +// direction. Either the gate does not rotate, or it rotates in the +// given direction. This information is compared against the gate +// "arm" layout to see if there is an arm at the position in order to +// produce the final rotation. +static const u8 sRotatingGate_RotationInfoNorth[4 * 4] = +{ + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, + GATE_ROT_CW(GATE_ARM_WEST, 1), GATE_ROT_CW(GATE_ARM_WEST, 0), GATE_ROT_ACW(GATE_ARM_EAST, 0), GATE_ROT_ACW(GATE_ARM_EAST, 1), + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, +}; + +static const u8 sRotatingGate_RotationInfoSouth[4 * 4] = +{ + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, + GATE_ROT_ACW(GATE_ARM_WEST, 1), GATE_ROT_ACW(GATE_ARM_WEST, 0), GATE_ROT_CW(GATE_ARM_EAST, 0), GATE_ROT_CW(GATE_ARM_EAST, 1), + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_NONE, +}; + +static const u8 sRotatingGate_RotationInfoWest[4 * 4] = +{ + GATE_ROT_NONE, GATE_ROT_ACW(GATE_ARM_NORTH, 1), GATE_ROT_NONE, GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_ACW(GATE_ARM_NORTH, 0), GATE_ROT_NONE, GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_CW(GATE_ARM_SOUTH, 0), GATE_ROT_NONE, GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_CW(GATE_ARM_SOUTH, 1), GATE_ROT_NONE, GATE_ROT_NONE, +}; + +static const u8 sRotatingGate_RotationInfoEast[4 * 4] = +{ + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_CW(GATE_ARM_NORTH, 1), GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_CW(GATE_ARM_NORTH, 0), GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_ACW(GATE_ARM_SOUTH, 0), GATE_ROT_NONE, + GATE_ROT_NONE, GATE_ROT_NONE, GATE_ROT_ACW(GATE_ARM_SOUTH, 1), GATE_ROT_NONE, +}; + +// These tables describe the relative coordinate positions the arms +// must move through in order to be rotated. +static const struct Coords8 sRotatingGate_ArmPositionsClockwiseRotation[] = { + { 0, -1 }, { 1, -2 }, { 0, 0 }, { 1, 0 }, { -1, 0 }, { -1, 1 }, { -1, -1 }, { -2, -1 }, +}; + +static const struct Coords8 sRotatingGate_ArmPositionsAntiClockwiseRotation[] = { + { -1, -1 }, { -1, -2 }, { 0, -1 }, { 1, -1 }, { 0, 0 }, { 0, 1 }, { -1, 0 }, { -2, 0 }, +}; + +// Describes where the gates "arms" are in the order north, east, south, west. +// These are adjusted using the current orientation to perform collision checking +static const u8 sRotatingGate_ArmLayout[][4 * 2] = +{ + // L-shape gates + { + 1, 0, + 1, 0, + 0, 0, + 0, 0, + }, + { + 1, 1, + 1, 0, + 0, 0, + 0, 0, + }, + { + 1, 0, + 1, 1, + 0, 0, + 0, 0, + }, + { + 1, 1, + 1, 1, + 0, 0, + 0, 0, + }, + + // T-shape gates + { + 1, 0, + 1, 0, + 1, 0, + 0, 0, + }, + { + 1, 1, + 1, 0, + 1, 0, + 0, 0, + }, + { + 1, 0, + 1, 1, + 1, 0, + 0, 0, + }, + { + 1, 0, + 1, 0, + 1, 1, + 0, 0, + }, + + // Unused T-shape gates + // These have 2-3 long arms and cannot actually be used anywhere + // since configuration for them is missing from the other tables. + { + 1, 1, + 1, 1, + 1, 0, + 0, 0, + }, + { + 1, 1, + 1, 0, + 1, 1, + 0, 0, + }, + { + 1, 0, + 1, 1, + 1, 1, + 0, 0, + }, + { + 1, 1, + 1, 1, + 1, 1, + 0, 0, + }, +}; + +// ewram +static EWRAM_DATA u8 gRotatingGate_GateSpriteIds[ROTATING_GATE_PUZZLE_MAX] = {0}; +static EWRAM_DATA const struct RotatingGatePuzzle *gRotatingGate_PuzzleConfig = NULL; +static EWRAM_DATA u8 gRotatingGate_PuzzleCount = 0; + +// text +static s32 GetCurrentMapRotatingGatePuzzleType(void) +{ + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(FORTREE_CITY_GYM) && + gSaveBlock1Ptr->location.mapNum == MAP_NUM(FORTREE_CITY_GYM)) + { + return PUZZLE_FORTREE_CITY_GYM; + } + + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE110_TRICK_HOUSE_PUZZLE6) && + gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE110_TRICK_HOUSE_PUZZLE6)) + { + return PUZZLE_ROUTE110_TRICK_HOUSE_PUZZLE6; + } + + return PUZZLE_NONE; +} + +static void RotatingGate_ResetAllGateOrientations(void) +{ + s32 i; + u8 *ptr; + + ptr = (u8 *)GetVarPointer(VAR_0x4000); + + for (i = 0; i < gRotatingGate_PuzzleCount; i++) + { + ptr[i] = gRotatingGate_PuzzleConfig[i].orientation; + } +} + +static s32 RotatingGate_GetGateOrientation(u8 gateId) +{ + return ((u8 *)GetVarPointer(VAR_0x4000))[gateId]; +} + +static void RotatingGate_SetGateOrientation(u8 gateId, u8 orientation) +{ + ((u8 *)GetVarPointer(VAR_0x4000))[gateId] = orientation; +} + +static void RotatingGate_RotateInDirection(u8 gateId, u32 rotationDirection) +{ + u8 orientation = RotatingGate_GetGateOrientation(gateId); + + if (rotationDirection == ROTATE_ANTICLOCKWISE) + { + if (orientation) + orientation--; + else + orientation = GATE_ORIENTATION_270; + } + else + { + orientation = ++orientation % GATE_ORIENTATION_MAX; + } + RotatingGate_SetGateOrientation(gateId, orientation); +} + +static void RotatingGate_LoadPuzzleConfig(void) +{ + s32 puzzleType = GetCurrentMapRotatingGatePuzzleType(); + u32 i; + + switch (puzzleType) + { + case PUZZLE_FORTREE_CITY_GYM: + gRotatingGate_PuzzleConfig = sRotatingGate_FortreePuzzleConfig; + gRotatingGate_PuzzleCount = + sizeof(sRotatingGate_FortreePuzzleConfig) / sizeof(struct RotatingGatePuzzle); + break; + case PUZZLE_ROUTE110_TRICK_HOUSE_PUZZLE6: + gRotatingGate_PuzzleConfig = sRotatingGate_TrickHousePuzzleConfig; + gRotatingGate_PuzzleCount = + sizeof(sRotatingGate_TrickHousePuzzleConfig) / sizeof(struct RotatingGatePuzzle); + break; + case PUZZLE_NONE: + default: + return; + } + + for (i = 0; i < ROTATING_GATE_PUZZLE_MAX - 1; i++) + { + gRotatingGate_GateSpriteIds[i] = MAX_SPRITES; + } +} + +static void RotatingGate_CreateGatesWithinViewport(s16 deltaX, s16 deltaY) +{ + u8 i; + + // Calculate the bounding box of the camera + // Same as RotatingGate_DestroyGatesOutsideViewport + s16 x = gSaveBlock1Ptr->pos.x - 2; + s16 x2 = gSaveBlock1Ptr->pos.x + 0x11; + s16 y = gSaveBlock1Ptr->pos.y - 2; + s16 y2 = gSaveBlock1Ptr->pos.y + 0xe; + + s16 x3, y3; + + for (i = 0; i < gRotatingGate_PuzzleCount; i++) + { + x3 = gRotatingGate_PuzzleConfig[i].x + 7; + y3 = gRotatingGate_PuzzleConfig[i].y + 7; + + if (y <= y3 && y2 >= y3 && x <= x3 && x2 >= x3 && + gRotatingGate_GateSpriteIds[i] == MAX_SPRITES) + { + gRotatingGate_GateSpriteIds[i] = RotatingGate_CreateGate(i, deltaX, deltaY); + } + } +} + +static u8 RotatingGate_CreateGate(u8 gateId, s16 deltaX, s16 deltaY) +{ + struct Sprite *sprite; + struct SpriteTemplate template; + const struct RotatingGatePuzzle *gate; + u8 spriteId; + s16 x, y; + + gate = &gRotatingGate_PuzzleConfig[gateId]; + + if (gate->shape == GATE_SHAPE_L1 || gate->shape == GATE_SHAPE_T1) + template = sSpriteTemplate_RotatingGateRegular; + else + template = sSpriteTemplate_RotatingGateLarge; + + template.tileTag = gate->shape + ROTATING_GATE_TILE_TAG; + + spriteId = CreateSprite(&template, 0, 0, 0x94); + if (spriteId == MAX_SPRITES) + return MAX_SPRITES; + + x = gate->x + 7; + y = gate->y + 7; + + sprite = &gSprites[spriteId]; + sprite->data[0] = gateId; + sprite->coordOffsetEnabled = 1; + + sub_8092FF0(x + deltaX, y + deltaY, &sprite->pos1.x, &sprite->pos1.y); + RotatingGate_HideGatesOutsideViewport(sprite); + StartSpriteAffineAnim(sprite, RotatingGate_GetGateOrientation(gateId)); + + return spriteId; +} + +static void SpriteCallback_RotatingGate(struct Sprite *sprite) +{ + u8 rotationDirection; + u8 orientation; + u8 affineAnimation; + + rotationDirection = sprite->data[1]; + orientation = sprite->data[2]; + + RotatingGate_HideGatesOutsideViewport(sprite); + + if (rotationDirection == ROTATE_ANTICLOCKWISE) + { + affineAnimation = orientation + 4; + + if (GetPlayerSpeed() != 1) + affineAnimation += 8; + + PlaySE(SE_HI_TURUN); + StartSpriteAffineAnim(sprite, affineAnimation); + } + else if (rotationDirection == ROTATE_CLOCKWISE) + { + affineAnimation = orientation + 8; + + if (GetPlayerSpeed() != 1) + affineAnimation += 8; + + PlaySE(SE_HI_TURUN); + StartSpriteAffineAnim(sprite, affineAnimation); + } + + sprite->data[1] = ROTATE_NONE; +} + +static void RotatingGate_HideGatesOutsideViewport(struct Sprite *sprite) +{ + u16 x; + s16 x2; + u16 y; + s16 y2; + + sprite->invisible = FALSE; + x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX; + y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY; + + x2 = x + 0x40; // Dimensions of the rotating gate + y2 = y + 0x40; + + if ((s16)x > DISPLAY_WIDTH + 0x10 - 1 || x2 < -0x10) + { + sprite->invisible = TRUE; + } + + if ((s16)y > DISPLAY_HEIGHT + 0x10 - 1 || y2 < -0x10) + { + sprite->invisible = TRUE; + } +} + +static void LoadRotatingGatePics(void) +{ + LoadSpriteSheets(sRotatingGatesGraphicsTable); +} + +/* +static*/ void RotatingGate_DestroyGatesOutsideViewport(void) +{ + s16 x; + s16 x2; + s16 y; + s16 y2; + s16 xGate; + s16 yGate; + s32 i; + struct Sprite *sprite; + + // Same as RotatingGate_CreateGatesWithinViewport + x = gSaveBlock1Ptr->pos.x - 2; + x2 = gSaveBlock1Ptr->pos.x + 0x11; + y = gSaveBlock1Ptr->pos.y - 2; + y2 = gSaveBlock1Ptr->pos.y + 0xe; + + for (i = 0; i < gRotatingGate_PuzzleCount; i++) + { + xGate = gRotatingGate_PuzzleConfig[i].x + 7; + yGate = gRotatingGate_PuzzleConfig[i].y + 7; + + if (gRotatingGate_GateSpriteIds[i] == MAX_SPRITES) + continue; + + if (xGate < x || xGate > x2 || yGate < y || yGate > y2) + { + sprite = &gSprites[gRotatingGate_GateSpriteIds[i]]; + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + gRotatingGate_GateSpriteIds[i] = MAX_SPRITES; + } + } +} + + +#ifdef NONMATCHING +bool8 MapGridIsImpassableAt(s32, s32); //fool the compiler + +static s32 RotatingGate_CanRotate(u8 gateId, s16 rotationDirection) +{ + const struct Coords8 *armPos; + u8 orientation; + s16 x; + s16 y; + u8 shape; + u32 shape8; + s32 i; + s32 j; + s32 armOrientation; + const u8 *gateArmCollisionData; + u8 armIndex; + + if (rotationDirection == ROTATE_ANTICLOCKWISE) + armPos = sRotatingGate_ArmPositionsAntiClockwiseRotation; + else if (rotationDirection == ROTATE_CLOCKWISE) + armPos = sRotatingGate_ArmPositionsClockwiseRotation; + else + return FALSE; + + orientation = RotatingGate_GetGateOrientation(gateId); + + shape = gRotatingGate_PuzzleConfig[gateId].shape; + x = gRotatingGate_PuzzleConfig[gateId].x + 7; + y = gRotatingGate_PuzzleConfig[gateId].y + 7; + + + // Loop through the gate's "arms" clockwise (north, south, east, west) + for (i = GATE_ARM_NORTH, shape8 = shape* 4*2 ; i <= GATE_ARM_WEST; i++) + { + // Ensure that no part of the arm collides with the map + for (j = 0, armOrientation = orientation + i, gateArmCollisionData = (u8 *)((u32)sRotatingGate_ArmLayout + shape8 + 2*i); j < GATE_ARM_MAX_LENGTH; j++) + { + armIndex = 2 * (armOrientation % 4) + j; + + if (*gateArmCollisionData) + { + if (MapGridIsImpassableAt(x + armPos[armIndex].deltaX, y + armPos[armIndex].deltaY) == TRUE) + return FALSE; + } + gateArmCollisionData++; + } + } + + return TRUE; +} + +#else +ASM_DIRECT +static s32 RotatingGate_CanRotate(u8 a, s16 rotationDirection) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0xC\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + cmp r1, 0x1\n\ + bne _080FBCFC\n\ + ldr r0, =sRotatingGate_ArmPositionsAntiClockwiseRotation\n\ + mov r10, r0\n\ + b _080FBD08\n\ + .pool\n\ +_080FBCFC:\n\ + cmp r1, 0x2\n\ + beq _080FBD04\n\ +_080FBD00:\n\ + movs r0, 0\n\ + b _080FBD98\n\ +_080FBD04:\n\ + ldr r1, =sRotatingGate_ArmPositionsClockwiseRotation\n\ + mov r10, r1\n\ +_080FBD08:\n\ + adds r0, r4, 0\n\ + bl RotatingGate_GetGateOrientation\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp]\n\ + ldr r0, =gRotatingGate_PuzzleConfig\n\ + ldr r1, [r0]\n\ + lsls r0, r4, 3\n\ + adds r0, r1\n\ + ldrb r2, [r0, 0x4]\n\ + ldrh r1, [r0]\n\ + adds r1, 0x7\n\ + ldrh r0, [r0, 0x2]\n\ + adds r0, 0x7\n\ + movs r3, 0\n\ + lsls r2, 3\n\ + str r2, [sp, 0x4]\n\ + lsls r1, 16\n\ + asrs r1, 16\n\ + mov r9, r1\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + mov r8, r0\n\ +_080FBD38:\n\ + movs r6, 0\n\ + ldr r2, [sp]\n\ + adds r7, r2, r3\n\ + lsls r0, r3, 1\n\ + adds r5, r7, 0\n\ + ldr r1, [sp, 0x4]\n\ + adds r0, r1\n\ + ldr r2, =sRotatingGate_ArmLayout\n\ + adds r4, r0, r2\n\ +_080FBD4A:\n\ + adds r0, r5, 0\n\ + cmp r5, 0\n\ + bge _080FBD52\n\ + adds r0, r7, 0x3\n\ +_080FBD52:\n\ + asrs r0, 2\n\ + lsls r0, 2\n\ + subs r0, r5, r0\n\ + lsls r0, 1\n\ + adds r0, r6\n\ + lsls r0, 24\n\ + lsrs r1, r0, 24\n\ + ldrb r0, [r4]\n\ + cmp r0, 0\n\ + beq _080FBD88\n\ + lsls r1, 2\n\ + add r1, r10\n\ + movs r0, 0\n\ + ldrsb r0, [r1, r0]\n\ + add r0, r9\n\ + ldrb r1, [r1, 0x1]\n\ + lsls r1, 24\n\ + asrs r1, 24\n\ + add r1, r8\n\ + str r3, [sp, 0x8]\n\ + bl MapGridIsImpassableAt\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + ldr r3, [sp, 0x8]\n\ + cmp r0, 0x1\n\ + beq _080FBD00\n\ +_080FBD88:\n\ + adds r4, 0x1\n\ + adds r6, 0x1\n\ + cmp r6, 0x1\n\ + ble _080FBD4A\n\ + adds r3, 0x1\n\ + cmp r3, 0x3\n\ + ble _080FBD38\n\ + movs r0, 0x1\n\ +_080FBD98:\n\ + add sp, 0xC\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .pool\n\ +.syntax divided\n"); +} +#endif + +static s32 RotatingGate_HasArm(u8 gateId, u8 armInfo) +{ + s32 isLongArm; + s8 armOrientation; + s32 arm; + s32 shape; + + arm = armInfo >> 1; + isLongArm = armInfo & 1; + + armOrientation = (arm - RotatingGate_GetGateOrientation(gateId) + 4) % 4; + shape = gRotatingGate_PuzzleConfig[gateId].shape; + return sRotatingGate_ArmLayout[shape][armOrientation * 2 + isLongArm]; +} + +static void RotatingGate_TriggerRotationAnimation(u8 gateId, s32 rotationDirection) +{ + struct Sprite *sprite; + + if (gRotatingGate_GateSpriteIds[gateId] != MAX_SPRITES) + { + sprite = &gSprites[gRotatingGate_GateSpriteIds[gateId]]; + sprite->data[1] = rotationDirection; + sprite->data[2] = RotatingGate_GetGateOrientation(gateId); + } +} + +static u8 RotatingGate_GetRotationInfo(u8 direction, s16 x, s16 y) +{ + register const u8 *ptr; + + if (direction == DIR_NORTH) + ptr = sRotatingGate_RotationInfoNorth; + else if (direction == DIR_SOUTH) + ptr = sRotatingGate_RotationInfoSouth; + else if (direction == DIR_WEST) + ptr = sRotatingGate_RotationInfoWest; + else if (direction == DIR_EAST) + ptr = sRotatingGate_RotationInfoEast; + else + return GATE_ROT_NONE; + + return ptr[y * 4 + x]; +} + +void RotatingGate_InitPuzzle(void) +{ + if (GetCurrentMapRotatingGatePuzzleType()) + { + RotatingGate_LoadPuzzleConfig(); + RotatingGate_ResetAllGateOrientations(); + } +} + +void RotatingGatePuzzleCameraUpdate(u16 deltaX, u16 deltaY) +{ + if (GetCurrentMapRotatingGatePuzzleType()) + { + RotatingGate_CreateGatesWithinViewport(deltaX, deltaY); + RotatingGate_DestroyGatesOutsideViewport(); + } +} + +void RotatingGate_InitPuzzleAndGraphics(void) +{ + if (GetCurrentMapRotatingGatePuzzleType()) + { + LoadRotatingGatePics(); + RotatingGate_LoadPuzzleConfig(); + RotatingGate_CreateGatesWithinViewport(0, 0); + } +} + +bool8 CheckForRotatingGatePuzzleCollision(u8 direction, s16 x, s16 y) +{ + s32 i; + + if (!GetCurrentMapRotatingGatePuzzleType()) + return FALSE; + for (i = 0; i < gRotatingGate_PuzzleCount; i++) + { + s16 gateX = gRotatingGate_PuzzleConfig[i].x + 7; + s16 gateY = gRotatingGate_PuzzleConfig[i].y + 7; + + if (gateX - 2 <= x && x <= gateX + 1 && gateY - 2 <= y && y <= gateY + 1) + { + s16 centerX = x - gateX + 2; + s16 centerY = y - gateY + 2; + u8 rotationInfo = RotatingGate_GetRotationInfo(direction, centerX, centerY); + + if (rotationInfo != GATE_ROT_NONE) + { + u8 rotationDirection = ((rotationInfo & 0xF0) >> 4); + u8 armInfo = rotationInfo & 0xF; + + if (RotatingGate_HasArm(i, armInfo)) + { + if (RotatingGate_CanRotate(i, rotationDirection)) + { + RotatingGate_TriggerRotationAnimation(i, rotationDirection); + RotatingGate_RotateInDirection(i, rotationDirection); + return FALSE; + } + return TRUE; + } + } + } + } + return FALSE; +} + +bool8 CheckForRotatingGatePuzzleCollisionWithoutAnimation(u8 direction, s16 x, s16 y) +{ + s32 i; + + if (!GetCurrentMapRotatingGatePuzzleType()) + return FALSE; + for (i = 0; i < gRotatingGate_PuzzleCount; i++) + { + s16 gateX = gRotatingGate_PuzzleConfig[i].x + 7; + s16 gateY = gRotatingGate_PuzzleConfig[i].y + 7; + + if (gateX - 2 <= x && x <= gateX + 1 && gateY - 2 <= y && y <= gateY + 1) + { + s16 centerX = x - gateX + 2; + s16 centerY = y - gateY + 2; + u8 rotationInfo = RotatingGate_GetRotationInfo(direction, centerX, centerY); + + if (rotationInfo != GATE_ROT_NONE) + { + u8 rotationDirection = ((rotationInfo & 0xF0) >> 4); + u8 armInfo = rotationInfo & 0xF; + + if (RotatingGate_HasArm(i, armInfo)) + { + if (!RotatingGate_CanRotate(i, rotationDirection)) + { + return TRUE; + } + } + } + } + } + return FALSE; +} diff --git a/src/text_window.c b/src/text_window.c index 33cd7cffe..c3b9f7197 100644 --- a/src/text_window.c +++ b/src/text_window.c @@ -7,26 +7,26 @@ #include "graphics.h" // const rom data -const u32 gTextWindowFrame1_Gfx[] = INCBIN_U32("graphics/text_window/1.4bpp"); -static const u32 sTextWindowFrame2_Gfx[] = INCBIN_U32("graphics/text_window/2.4bpp"); -static const u32 sTextWindowFrame3_Gfx[] = INCBIN_U32("graphics/text_window/3.4bpp"); -static const u32 sTextWindowFrame4_Gfx[] = INCBIN_U32("graphics/text_window/4.4bpp"); -static const u32 sTextWindowFrame5_Gfx[] = INCBIN_U32("graphics/text_window/5.4bpp"); -static const u32 sTextWindowFrame6_Gfx[] = INCBIN_U32("graphics/text_window/6.4bpp"); -static const u32 sTextWindowFrame7_Gfx[] = INCBIN_U32("graphics/text_window/7.4bpp"); -static const u32 sTextWindowFrame8_Gfx[] = INCBIN_U32("graphics/text_window/8.4bpp"); -static const u32 sTextWindowFrame9_Gfx[] = INCBIN_U32("graphics/text_window/9.4bpp"); -static const u32 sTextWindowFrame10_Gfx[] = INCBIN_U32("graphics/text_window/10.4bpp"); -static const u32 sTextWindowFrame11_Gfx[] = INCBIN_U32("graphics/text_window/11.4bpp"); -static const u32 sTextWindowFrame12_Gfx[] = INCBIN_U32("graphics/text_window/12.4bpp"); -static const u32 sTextWindowFrame13_Gfx[] = INCBIN_U32("graphics/text_window/13.4bpp"); -static const u32 sTextWindowFrame14_Gfx[] = INCBIN_U32("graphics/text_window/14.4bpp"); -static const u32 sTextWindowFrame15_Gfx[] = INCBIN_U32("graphics/text_window/15.4bpp"); -static const u32 sTextWindowFrame16_Gfx[] = INCBIN_U32("graphics/text_window/16.4bpp"); -static const u32 sTextWindowFrame17_Gfx[] = INCBIN_U32("graphics/text_window/17.4bpp"); -static const u32 sTextWindowFrame18_Gfx[] = INCBIN_U32("graphics/text_window/18.4bpp"); -static const u32 sTextWindowFrame19_Gfx[] = INCBIN_U32("graphics/text_window/19.4bpp"); -static const u32 sTextWindowFrame20_Gfx[] = INCBIN_U32("graphics/text_window/20.4bpp"); +const u8 gTextWindowFrame1_Gfx[] = INCBIN_U8("graphics/text_window/1.4bpp"); +static const u8 sTextWindowFrame2_Gfx[] = INCBIN_U8("graphics/text_window/2.4bpp"); +static const u8 sTextWindowFrame3_Gfx[] = INCBIN_U8("graphics/text_window/3.4bpp"); +static const u8 sTextWindowFrame4_Gfx[] = INCBIN_U8("graphics/text_window/4.4bpp"); +static const u8 sTextWindowFrame5_Gfx[] = INCBIN_U8("graphics/text_window/5.4bpp"); +static const u8 sTextWindowFrame6_Gfx[] = INCBIN_U8("graphics/text_window/6.4bpp"); +static const u8 sTextWindowFrame7_Gfx[] = INCBIN_U8("graphics/text_window/7.4bpp"); +static const u8 sTextWindowFrame8_Gfx[] = INCBIN_U8("graphics/text_window/8.4bpp"); +static const u8 sTextWindowFrame9_Gfx[] = INCBIN_U8("graphics/text_window/9.4bpp"); +static const u8 sTextWindowFrame10_Gfx[] = INCBIN_U8("graphics/text_window/10.4bpp"); +static const u8 sTextWindowFrame11_Gfx[] = INCBIN_U8("graphics/text_window/11.4bpp"); +static const u8 sTextWindowFrame12_Gfx[] = INCBIN_U8("graphics/text_window/12.4bpp"); +static const u8 sTextWindowFrame13_Gfx[] = INCBIN_U8("graphics/text_window/13.4bpp"); +static const u8 sTextWindowFrame14_Gfx[] = INCBIN_U8("graphics/text_window/14.4bpp"); +static const u8 sTextWindowFrame15_Gfx[] = INCBIN_U8("graphics/text_window/15.4bpp"); +static const u8 sTextWindowFrame16_Gfx[] = INCBIN_U8("graphics/text_window/16.4bpp"); +static const u8 sTextWindowFrame17_Gfx[] = INCBIN_U8("graphics/text_window/17.4bpp"); +static const u8 sTextWindowFrame18_Gfx[] = INCBIN_U8("graphics/text_window/18.4bpp"); +static const u8 sTextWindowFrame19_Gfx[] = INCBIN_U8("graphics/text_window/19.4bpp"); +static const u8 sTextWindowFrame20_Gfx[] = INCBIN_U8("graphics/text_window/20.4bpp"); const u16 gTextWindowFrame1_Pal[] = INCBIN_U16("graphics/text_window/1.gbapal"); static const u16 sTextWindowFrame2_Pal[] = INCBIN_U16("graphics/text_window/2.gbapal"); diff --git a/sym_common.txt b/sym_common.txt index 6f6a8da32..b0548a84c 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -30,13 +30,13 @@ gPokemonStoragePtr: @ 3005D94 gInGameOpponentsNo: @ 3005D98 .space 0x4 -gUnknown_03005D9C: @ 3005D9C +gBGTilemapBuffers1: @ 3005D9C .space 0x4 -gUnknown_03005DA0: @ 3005DA0 +gBGTilemapBuffers2: @ 3005DA0 .space 0x4 -gUnknown_03005DA4: @ 3005DA4 +gBGTilemapBuffers3: @ 3005DA4 .space 0x4 gUnknown_03005DA8: @ 3005DA8 diff --git a/sym_ewram.txt b/sym_ewram.txt index b7f3ebdf3..9bf04d201 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -222,7 +222,7 @@ gCamera: @ 2037334 gUnknown_02037340: @ 2037340 .space 0x8 -gUnknown_02037348: @ 2037348 +gUnusedBikeCameraAheadPanback: @ 2037348 .space 0x4 gUnknown_0203734C: @ 203734C @@ -522,15 +522,7 @@ gUnknown_0203A018: @ 203A018 gUnknown_0203A034: @ 203A034 .space 0x4 -gUnknown_0203A038: @ 203A038 - .space 0xC - -gUnknown_0203A044: @ 203A044 - .space 0x4 - -gUnknown_0203A048: @ 203A048 - .space 0x4 - + .include "src/rotating_gate.o" .include "src/safari_zone.o" gUnknown_0203A0F4: @ 203A0F4 @@ -556,9 +548,7 @@ gUnknown_0203A11C: @ 203A11C gUnknown_0203A120: @ 203A120 .space 0x4 - -gUnknown_0203A124: @ 203A124 - .space 0x4 + .include "src/mon_markings.o" gUnknown_0203A128: @ 203A128 .space 0x4