Document field_door code
This commit is contained in:
+3
-3
@@ -490,8 +490,8 @@ _0805A914: .4byte gUnknown_3000E90
|
|||||||
_0805A918: .4byte gMapHeader
|
_0805A918: .4byte gMapHeader
|
||||||
thumb_func_end CurrentMapDrawMetatileAt
|
thumb_func_end CurrentMapDrawMetatileAt
|
||||||
|
|
||||||
thumb_func_start sub_805A91C
|
thumb_func_start DrawDoorMetatileAt
|
||||||
sub_805A91C: @ 805A91C
|
DrawDoorMetatileAt: @ 805A91C
|
||||||
push {r4,r5,lr}
|
push {r4,r5,lr}
|
||||||
adds r3, r0, 0
|
adds r3, r0, 0
|
||||||
adds r4, r1, 0
|
adds r4, r1, 0
|
||||||
@@ -513,7 +513,7 @@ _0805A93E:
|
|||||||
bx r0
|
bx r0
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_0805A944: .4byte gUnknown_3000E90
|
_0805A944: .4byte gUnknown_3000E90
|
||||||
thumb_func_end sub_805A91C
|
thumb_func_end DrawDoorMetatileAt
|
||||||
|
|
||||||
thumb_func_start sub_805A948
|
thumb_func_start sub_805A948
|
||||||
sub_805A948: @ 805A948
|
sub_805A948: @ 805A948
|
||||||
|
|||||||
@@ -1,484 +0,0 @@
|
|||||||
.include "asm/macros.inc"
|
|
||||||
.include "constants/constants.inc"
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
|
|
||||||
.text
|
|
||||||
|
|
||||||
thumb_func_start sub_805B060
|
|
||||||
sub_805B060: @ 805B060
|
|
||||||
push {r4-r6,lr}
|
|
||||||
adds r6, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
adds r4, r2, 0
|
|
||||||
movs r1, 0xA
|
|
||||||
ldrsh r0, [r4, r1]
|
|
||||||
cmp r0, 0
|
|
||||||
bne _0805B086
|
|
||||||
movs r2, 0x8
|
|
||||||
ldrsh r1, [r4, r2]
|
|
||||||
lsls r1, 2
|
|
||||||
adds r1, r5, r1
|
|
||||||
movs r0, 0xC
|
|
||||||
ldrsh r2, [r4, r0]
|
|
||||||
movs r0, 0xE
|
|
||||||
ldrsh r3, [r4, r0]
|
|
||||||
adds r0, r6, 0
|
|
||||||
bl sub_805AF14
|
|
||||||
_0805B086:
|
|
||||||
movs r2, 0xA
|
|
||||||
ldrsh r1, [r4, r2]
|
|
||||||
movs r2, 0x8
|
|
||||||
ldrsh r0, [r4, r2]
|
|
||||||
lsls r0, 2
|
|
||||||
adds r0, r5
|
|
||||||
ldrb r0, [r0]
|
|
||||||
cmp r1, r0
|
|
||||||
bne _0805B0B4
|
|
||||||
movs r0, 0
|
|
||||||
strh r0, [r4, 0xA]
|
|
||||||
ldrh r0, [r4, 0x8]
|
|
||||||
adds r0, 0x1
|
|
||||||
strh r0, [r4, 0x8]
|
|
||||||
movs r1, 0x8
|
|
||||||
ldrsh r0, [r4, r1]
|
|
||||||
lsls r0, 2
|
|
||||||
adds r0, r5
|
|
||||||
ldrb r0, [r0]
|
|
||||||
cmp r0, 0
|
|
||||||
bne _0805B0BA
|
|
||||||
movs r0, 0
|
|
||||||
b _0805B0BC
|
|
||||||
_0805B0B4:
|
|
||||||
ldrh r0, [r4, 0xA]
|
|
||||||
adds r0, 0x1
|
|
||||||
strh r0, [r4, 0xA]
|
|
||||||
_0805B0BA:
|
|
||||||
movs r0, 0x1
|
|
||||||
_0805B0BC:
|
|
||||||
pop {r4-r6}
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end sub_805B060
|
|
||||||
|
|
||||||
thumb_func_start door_find
|
|
||||||
door_find: @ 805B0C4
|
|
||||||
push {lr}
|
|
||||||
adds r2, r0, 0
|
|
||||||
lsls r1, 16
|
|
||||||
lsrs r1, 16
|
|
||||||
b _0805B0DA
|
|
||||||
_0805B0CE:
|
|
||||||
ldrh r0, [r2]
|
|
||||||
cmp r0, r1
|
|
||||||
bne _0805B0D8
|
|
||||||
adds r0, r2, 0
|
|
||||||
b _0805B0E2
|
|
||||||
_0805B0D8:
|
|
||||||
adds r2, 0xC
|
|
||||||
_0805B0DA:
|
|
||||||
ldr r0, [r2, 0x4]
|
|
||||||
cmp r0, 0
|
|
||||||
bne _0805B0CE
|
|
||||||
movs r0, 0
|
|
||||||
_0805B0E2:
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end door_find
|
|
||||||
|
|
||||||
thumb_func_start task_overworld_door_add_if_inactive
|
|
||||||
task_overworld_door_add_if_inactive: @ 805B0E8
|
|
||||||
push {r4-r7,lr}
|
|
||||||
mov r7, r8
|
|
||||||
push {r7}
|
|
||||||
adds r6, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
adds r7, r2, 0
|
|
||||||
mov r8, r3
|
|
||||||
ldr r4, _0805B134 @ =sub_805B028
|
|
||||||
adds r0, r4, 0
|
|
||||||
bl FuncIsActiveTask
|
|
||||||
lsls r0, 24
|
|
||||||
lsrs r0, 24
|
|
||||||
cmp r0, 0x1
|
|
||||||
beq _0805B13C
|
|
||||||
adds r0, r4, 0
|
|
||||||
movs r1, 0x50
|
|
||||||
bl CreateTask
|
|
||||||
lsls r0, 24
|
|
||||||
lsrs r0, 24
|
|
||||||
lsls r1, r0, 2
|
|
||||||
adds r1, r0
|
|
||||||
lsls r1, 3
|
|
||||||
ldr r2, _0805B138 @ =gTasks+0x8
|
|
||||||
adds r1, r2
|
|
||||||
strh r7, [r1, 0xC]
|
|
||||||
mov r2, r8
|
|
||||||
strh r2, [r1, 0xE]
|
|
||||||
strh r5, [r1, 0x2]
|
|
||||||
lsrs r2, r5, 16
|
|
||||||
strh r2, [r1]
|
|
||||||
strh r6, [r1, 0x6]
|
|
||||||
lsrs r2, r6, 16
|
|
||||||
strh r2, [r1, 0x4]
|
|
||||||
lsls r0, 24
|
|
||||||
asrs r0, 24
|
|
||||||
b _0805B140
|
|
||||||
.align 2, 0
|
|
||||||
_0805B134: .4byte sub_805B028
|
|
||||||
_0805B138: .4byte gTasks+0x8
|
|
||||||
_0805B13C:
|
|
||||||
movs r0, 0x1
|
|
||||||
negs r0, r0
|
|
||||||
_0805B140:
|
|
||||||
pop {r3}
|
|
||||||
mov r8, r3
|
|
||||||
pop {r4-r7}
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end task_overworld_door_add_if_inactive
|
|
||||||
|
|
||||||
thumb_func_start DrawClosedDoor
|
|
||||||
DrawClosedDoor: @ 805B14C
|
|
||||||
push {lr}
|
|
||||||
bl sub_805AF54
|
|
||||||
pop {r0}
|
|
||||||
bx r0
|
|
||||||
thumb_func_end DrawClosedDoor
|
|
||||||
|
|
||||||
thumb_func_start sub_805B158
|
|
||||||
sub_805B158: @ 805B158
|
|
||||||
push {r4-r6,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
adds r6, r2, 0
|
|
||||||
adds r0, r5, 0
|
|
||||||
adds r1, r6, 0
|
|
||||||
bl MapGridGetMetatileIdAt
|
|
||||||
adds r1, r0, 0
|
|
||||||
lsls r1, 16
|
|
||||||
lsrs r1, 16
|
|
||||||
adds r0, r4, 0
|
|
||||||
bl door_find
|
|
||||||
adds r4, r0, 0
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B196
|
|
||||||
ldrb r0, [r0, 0x3]
|
|
||||||
ldr r1, _0805B19C @ =gUnknown_835B49C
|
|
||||||
cmp r0, 0
|
|
||||||
bne _0805B184
|
|
||||||
ldr r1, _0805B1A0 @ =gUnknown_835B488
|
|
||||||
_0805B184:
|
|
||||||
adds r0, r1, 0
|
|
||||||
bl sub_805B1A4
|
|
||||||
adds r1, r0, 0
|
|
||||||
adds r0, r4, 0
|
|
||||||
adds r2, r5, 0
|
|
||||||
adds r3, r6, 0
|
|
||||||
bl sub_805AF14
|
|
||||||
_0805B196:
|
|
||||||
pop {r4-r6}
|
|
||||||
pop {r0}
|
|
||||||
bx r0
|
|
||||||
.align 2, 0
|
|
||||||
_0805B19C: .4byte gUnknown_835B49C
|
|
||||||
_0805B1A0: .4byte gUnknown_835B488
|
|
||||||
thumb_func_end sub_805B158
|
|
||||||
|
|
||||||
thumb_func_start sub_805B1A4
|
|
||||||
sub_805B1A4: @ 805B1A4
|
|
||||||
push {lr}
|
|
||||||
adds r1, r0, 0
|
|
||||||
b _0805B1AC
|
|
||||||
_0805B1AA:
|
|
||||||
adds r1, 0x4
|
|
||||||
_0805B1AC:
|
|
||||||
ldrb r0, [r1]
|
|
||||||
cmp r0, 0
|
|
||||||
bne _0805B1AA
|
|
||||||
subs r0, r1, 0x4
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end sub_805B1A4
|
|
||||||
|
|
||||||
thumb_func_start sub_805B1B8
|
|
||||||
sub_805B1B8: @ 805B1B8
|
|
||||||
push {r4-r6,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
adds r6, r2, 0
|
|
||||||
adds r0, r5, 0
|
|
||||||
adds r1, r6, 0
|
|
||||||
bl MapGridGetMetatileIdAt
|
|
||||||
adds r1, r0, 0
|
|
||||||
lsls r1, 16
|
|
||||||
lsrs r1, 16
|
|
||||||
adds r0, r4, 0
|
|
||||||
bl door_find
|
|
||||||
adds r2, r0, 0
|
|
||||||
adds r4, r2, 0
|
|
||||||
cmp r2, 0
|
|
||||||
bne _0805B1E2
|
|
||||||
movs r0, 0x1
|
|
||||||
negs r0, r0
|
|
||||||
b _0805B204
|
|
||||||
_0805B1E2:
|
|
||||||
ldrb r0, [r2, 0x3]
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B1F4
|
|
||||||
ldr r1, _0805B1F0 @ =gUnknown_835B49C
|
|
||||||
adds r0, r2, 0
|
|
||||||
b _0805B1F8
|
|
||||||
.align 2, 0
|
|
||||||
_0805B1F0: .4byte gUnknown_835B49C
|
|
||||||
_0805B1F4:
|
|
||||||
ldr r1, _0805B20C @ =gUnknown_835B488
|
|
||||||
adds r0, r4, 0
|
|
||||||
_0805B1F8:
|
|
||||||
adds r2, r5, 0
|
|
||||||
adds r3, r6, 0
|
|
||||||
bl task_overworld_door_add_if_inactive
|
|
||||||
lsls r0, 24
|
|
||||||
asrs r0, 24
|
|
||||||
_0805B204:
|
|
||||||
pop {r4-r6}
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
.align 2, 0
|
|
||||||
_0805B20C: .4byte gUnknown_835B488
|
|
||||||
thumb_func_end sub_805B1B8
|
|
||||||
|
|
||||||
thumb_func_start sub_805B210
|
|
||||||
sub_805B210: @ 805B210
|
|
||||||
push {r4-r6,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
adds r6, r2, 0
|
|
||||||
adds r0, r5, 0
|
|
||||||
adds r1, r6, 0
|
|
||||||
bl MapGridGetMetatileIdAt
|
|
||||||
adds r1, r0, 0
|
|
||||||
lsls r1, 16
|
|
||||||
lsrs r1, 16
|
|
||||||
adds r0, r4, 0
|
|
||||||
bl door_find
|
|
||||||
adds r2, r0, 0
|
|
||||||
adds r4, r2, 0
|
|
||||||
cmp r2, 0
|
|
||||||
bne _0805B23A
|
|
||||||
movs r0, 0x1
|
|
||||||
negs r0, r0
|
|
||||||
b _0805B25C
|
|
||||||
_0805B23A:
|
|
||||||
ldrb r0, [r2, 0x3]
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B24C
|
|
||||||
ldr r1, _0805B248 @ =gUnknown_835B4C4
|
|
||||||
adds r0, r2, 0
|
|
||||||
b _0805B250
|
|
||||||
.align 2, 0
|
|
||||||
_0805B248: .4byte gUnknown_835B4C4
|
|
||||||
_0805B24C:
|
|
||||||
ldr r1, _0805B264 @ =gUnknown_835B4B0
|
|
||||||
adds r0, r4, 0
|
|
||||||
_0805B250:
|
|
||||||
adds r2, r5, 0
|
|
||||||
adds r3, r6, 0
|
|
||||||
bl task_overworld_door_add_if_inactive
|
|
||||||
lsls r0, 24
|
|
||||||
asrs r0, 24
|
|
||||||
_0805B25C:
|
|
||||||
pop {r4-r6}
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
.align 2, 0
|
|
||||||
_0805B264: .4byte gUnknown_835B4B0
|
|
||||||
thumb_func_end sub_805B210
|
|
||||||
|
|
||||||
thumb_func_start FieldSetDoorOpened
|
|
||||||
FieldSetDoorOpened: @ 805B268
|
|
||||||
push {r4,r5,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
lsls r0, r4, 16
|
|
||||||
asrs r0, 16
|
|
||||||
lsls r1, r5, 16
|
|
||||||
asrs r1, 16
|
|
||||||
bl MapGridGetMetatileBehaviorAt
|
|
||||||
lsls r0, 24
|
|
||||||
lsrs r0, 24
|
|
||||||
bl MetatileBehavior_IsWarpDoor_2
|
|
||||||
lsls r0, 24
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B292
|
|
||||||
ldr r0, _0805B298 @ =gUnknown_835B5D8
|
|
||||||
adds r1, r4, 0
|
|
||||||
adds r2, r5, 0
|
|
||||||
bl sub_805B158
|
|
||||||
_0805B292:
|
|
||||||
pop {r4,r5}
|
|
||||||
pop {r0}
|
|
||||||
bx r0
|
|
||||||
.align 2, 0
|
|
||||||
_0805B298: .4byte gUnknown_835B5D8
|
|
||||||
thumb_func_end FieldSetDoorOpened
|
|
||||||
|
|
||||||
thumb_func_start FieldSetDoorClosed
|
|
||||||
FieldSetDoorClosed: @ 805B29C
|
|
||||||
push {r4,r5,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
lsls r0, r4, 16
|
|
||||||
asrs r0, 16
|
|
||||||
lsls r1, r5, 16
|
|
||||||
asrs r1, 16
|
|
||||||
bl MapGridGetMetatileBehaviorAt
|
|
||||||
lsls r0, 24
|
|
||||||
lsrs r0, 24
|
|
||||||
bl MetatileBehavior_IsWarpDoor_2
|
|
||||||
lsls r0, 24
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B2C6
|
|
||||||
ldr r0, _0805B2CC @ =gUnknown_835B5D8
|
|
||||||
adds r1, r4, 0
|
|
||||||
adds r2, r5, 0
|
|
||||||
bl DrawClosedDoor
|
|
||||||
_0805B2C6:
|
|
||||||
pop {r4,r5}
|
|
||||||
pop {r0}
|
|
||||||
bx r0
|
|
||||||
.align 2, 0
|
|
||||||
_0805B2CC: .4byte gUnknown_835B5D8
|
|
||||||
thumb_func_end FieldSetDoorClosed
|
|
||||||
|
|
||||||
thumb_func_start FieldAnimateDoorClose
|
|
||||||
FieldAnimateDoorClose: @ 805B2D0
|
|
||||||
push {r4,r5,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
lsls r0, r4, 16
|
|
||||||
asrs r0, 16
|
|
||||||
lsls r1, r5, 16
|
|
||||||
asrs r1, 16
|
|
||||||
bl MapGridGetMetatileBehaviorAt
|
|
||||||
lsls r0, 24
|
|
||||||
lsrs r0, 24
|
|
||||||
bl MetatileBehavior_IsWarpDoor_2
|
|
||||||
lsls r0, 24
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B304
|
|
||||||
ldr r0, _0805B300 @ =gUnknown_835B5D8
|
|
||||||
adds r1, r4, 0
|
|
||||||
adds r2, r5, 0
|
|
||||||
bl sub_805B210
|
|
||||||
lsls r0, 24
|
|
||||||
asrs r0, 24
|
|
||||||
b _0805B308
|
|
||||||
.align 2, 0
|
|
||||||
_0805B300: .4byte gUnknown_835B5D8
|
|
||||||
_0805B304:
|
|
||||||
movs r0, 0x1
|
|
||||||
negs r0, r0
|
|
||||||
_0805B308:
|
|
||||||
pop {r4,r5}
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end FieldAnimateDoorClose
|
|
||||||
|
|
||||||
thumb_func_start FieldAnimateDoorOpen
|
|
||||||
FieldAnimateDoorOpen: @ 805B310
|
|
||||||
push {r4,r5,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r5, r1, 0
|
|
||||||
lsls r0, r4, 16
|
|
||||||
asrs r0, 16
|
|
||||||
lsls r1, r5, 16
|
|
||||||
asrs r1, 16
|
|
||||||
bl MapGridGetMetatileBehaviorAt
|
|
||||||
lsls r0, 24
|
|
||||||
lsrs r0, 24
|
|
||||||
bl MetatileBehavior_IsWarpDoor_2
|
|
||||||
lsls r0, 24
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B344
|
|
||||||
ldr r0, _0805B340 @ =gUnknown_835B5D8
|
|
||||||
adds r1, r4, 0
|
|
||||||
adds r2, r5, 0
|
|
||||||
bl sub_805B1B8
|
|
||||||
lsls r0, 24
|
|
||||||
asrs r0, 24
|
|
||||||
b _0805B348
|
|
||||||
.align 2, 0
|
|
||||||
_0805B340: .4byte gUnknown_835B5D8
|
|
||||||
_0805B344:
|
|
||||||
movs r0, 0x1
|
|
||||||
negs r0, r0
|
|
||||||
_0805B348:
|
|
||||||
pop {r4,r5}
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end FieldAnimateDoorOpen
|
|
||||||
|
|
||||||
thumb_func_start FieldIsDoorAnimationRunning
|
|
||||||
FieldIsDoorAnimationRunning: @ 805B350
|
|
||||||
push {lr}
|
|
||||||
ldr r0, _0805B360 @ =sub_805B028
|
|
||||||
bl FuncIsActiveTask
|
|
||||||
lsls r0, 24
|
|
||||||
lsrs r0, 24
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
.align 2, 0
|
|
||||||
_0805B360: .4byte sub_805B028
|
|
||||||
thumb_func_end FieldIsDoorAnimationRunning
|
|
||||||
|
|
||||||
thumb_func_start GetDoorSoundEffect
|
|
||||||
GetDoorSoundEffect: @ 805B364
|
|
||||||
push {lr}
|
|
||||||
adds r3, r0, 0
|
|
||||||
adds r2, r1, 0
|
|
||||||
ldr r0, _0805B37C @ =gUnknown_835B5D8
|
|
||||||
adds r1, r3, 0
|
|
||||||
bl sub_805B388
|
|
||||||
lsls r0, 24
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B380
|
|
||||||
movs r0, 0x12
|
|
||||||
b _0805B382
|
|
||||||
.align 2, 0
|
|
||||||
_0805B37C: .4byte gUnknown_835B5D8
|
|
||||||
_0805B380:
|
|
||||||
movs r0, 0xF1
|
|
||||||
_0805B382:
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end GetDoorSoundEffect
|
|
||||||
|
|
||||||
thumb_func_start sub_805B388
|
|
||||||
sub_805B388: @ 805B388
|
|
||||||
push {r4,lr}
|
|
||||||
adds r4, r0, 0
|
|
||||||
adds r0, r1, 0
|
|
||||||
adds r1, r2, 0
|
|
||||||
bl MapGridGetMetatileIdAt
|
|
||||||
adds r1, r0, 0
|
|
||||||
lsls r1, 16
|
|
||||||
lsrs r1, 16
|
|
||||||
adds r0, r4, 0
|
|
||||||
bl door_find
|
|
||||||
cmp r0, 0
|
|
||||||
beq _0805B3AC
|
|
||||||
ldrb r0, [r0, 0x2]
|
|
||||||
lsls r0, 24
|
|
||||||
asrs r0, 24
|
|
||||||
b _0805B3B0
|
|
||||||
_0805B3AC:
|
|
||||||
movs r0, 0x1
|
|
||||||
negs r0, r0
|
|
||||||
_0805B3B0:
|
|
||||||
pop {r4}
|
|
||||||
pop {r1}
|
|
||||||
bx r1
|
|
||||||
thumb_func_end sub_805B388
|
|
||||||
|
|
||||||
.align 2, 0 @ Don't pad with nop.
|
|
||||||
+5
-5
@@ -247,7 +247,7 @@ gUnknown_835B168:: @ 835B168
|
|||||||
.space 32
|
.space 32
|
||||||
|
|
||||||
.align 2
|
.align 2
|
||||||
gUnknown_835B488:: @ 835B488
|
sDoorAnimFrames_OpenSmall:: @ 835B488
|
||||||
.byte 0x04
|
.byte 0x04
|
||||||
.align 1
|
.align 1
|
||||||
.2byte 0xffff
|
.2byte 0xffff
|
||||||
@@ -264,7 +264,7 @@ gUnknown_835B488:: @ 835B488
|
|||||||
.align 1
|
.align 1
|
||||||
.2byte 0x0000
|
.2byte 0x0000
|
||||||
|
|
||||||
gUnknown_835B49C:: @ 835B49C
|
sDoorAnimFrames_OpenLarge:: @ 835B49C
|
||||||
.byte 0x04
|
.byte 0x04
|
||||||
.align 1
|
.align 1
|
||||||
.2byte 0xffff
|
.2byte 0xffff
|
||||||
@@ -281,7 +281,7 @@ gUnknown_835B49C:: @ 835B49C
|
|||||||
.align 1
|
.align 1
|
||||||
.2byte 0x0000
|
.2byte 0x0000
|
||||||
|
|
||||||
gUnknown_835B4B0:: @ 835B4B0
|
sDoorAnimFrames_CloseSmall:: @ 835B4B0
|
||||||
.byte 0x04
|
.byte 0x04
|
||||||
.align 1
|
.align 1
|
||||||
.2byte 0x0100
|
.2byte 0x0100
|
||||||
@@ -298,7 +298,7 @@ gUnknown_835B4B0:: @ 835B4B0
|
|||||||
.align 1
|
.align 1
|
||||||
.2byte 0x0000
|
.2byte 0x0000
|
||||||
|
|
||||||
gUnknown_835B4C4:: @ 835B4C4
|
sDoorAnimFrames_CloseLarge:: @ 835B4C4
|
||||||
.byte 0x04
|
.byte 0x04
|
||||||
.align 1
|
.align 1
|
||||||
.2byte 0x0200
|
.2byte 0x0200
|
||||||
@@ -411,7 +411,7 @@ gUnknown_835B5C8:: @ 835B5C8
|
|||||||
gUnknown_835B5D0:: @ 835B5D0
|
gUnknown_835B5D0:: @ 835B5D0
|
||||||
.byte 0xb, 0xb, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2
|
.byte 0xb, 0xb, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2
|
||||||
|
|
||||||
gUnknown_835B5D8:: @ 835B5D8
|
sDoorGraphics:: @ 835B5D8
|
||||||
.2byte 0x003d
|
.2byte 0x003d
|
||||||
.byte 0x00, 0x00
|
.byte 0x00, 0x00
|
||||||
.4byte gUnknown_8353088
|
.4byte gUnknown_8353088
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ void sub_805A658(s16 *x, s16 *y);
|
|||||||
void SetCameraPanningCallback(void (*cb)(void));
|
void SetCameraPanningCallback(void (*cb)(void));
|
||||||
void SetCameraPanning(s16 x, s16 y);
|
void SetCameraPanning(s16 x, s16 y);
|
||||||
void InstallCameraPanAheadCallback(void);
|
void InstallCameraPanAheadCallback(void);
|
||||||
void sub_805A91C(int x, int y, const u16 *data);
|
void DrawDoorMetatileAt(int x, int y, const u16 *data);
|
||||||
|
|
||||||
#endif //GUARD_FIELD_CAMERA_H
|
#endif //GUARD_FIELD_CAMERA_H
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
void FieldSetDoorOpened(u32, u32);
|
void FieldSetDoorOpened(int x, int y);
|
||||||
void FieldSetDoorClosed(u32, u32);
|
void FieldSetDoorClosed(int x, int y);
|
||||||
s8 FieldAnimateDoorClose(u32, u32);
|
s8 FieldAnimateDoorClose(int x, int y);
|
||||||
s8 FieldAnimateDoorOpen(u32, u32);
|
s8 FieldAnimateDoorOpen(int x, int y);
|
||||||
bool8 FieldIsDoorAnimationRunning(void);
|
bool8 FieldIsDoorAnimationRunning(void);
|
||||||
u32 GetDoorSoundEffect(u32 x, u32 y);
|
u16 GetDoorSoundEffect(int x, int y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ SECTIONS {
|
|||||||
src/metatile_behavior.o(.text);
|
src/metatile_behavior.o(.text);
|
||||||
asm/field_camera.o(.text);
|
asm/field_camera.o(.text);
|
||||||
src/field_door.o(.text);
|
src/field_door.o(.text);
|
||||||
asm/field_door.o(.text);
|
|
||||||
asm/field_player_avatar.o(.text);
|
asm/field_player_avatar.o(.text);
|
||||||
asm/field_map_obj.o(.text);
|
asm/field_map_obj.o(.text);
|
||||||
asm/field_ground_effect.o(.text);
|
asm/field_ground_effect.o(.text);
|
||||||
|
|||||||
+184
-41
@@ -1,82 +1,87 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "field_camera.h"
|
#include "field_camera.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
#include "fieldmap.h"
|
||||||
|
#include "metatile_behavior.h"
|
||||||
|
#include "constants/songs.h"
|
||||||
|
|
||||||
struct DoorAnimFrame
|
struct DoorAnimFrame
|
||||||
{
|
{
|
||||||
u8 unk_0;
|
u8 duration;
|
||||||
u16 unk_2;
|
u16 tile;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DoorGraphics
|
struct DoorGraphics
|
||||||
{
|
{
|
||||||
u16 unk_0;
|
u16 metatileId;
|
||||||
u8 unk_2;
|
s8 sliding;
|
||||||
u8 unk_3;
|
u8 size;
|
||||||
const u8 * unk_4;
|
const u8 * tiles;
|
||||||
const u8 * unk_8;
|
const u8 * palettes;
|
||||||
};
|
};
|
||||||
|
|
||||||
void sub_805AF54(const struct DoorGraphics * a0, int a1, int a2);
|
static void DrawDoorDefaultImage(const struct DoorGraphics * gfx, int x, int y);
|
||||||
void sub_805AF80(const u8 *a0);
|
static void LoadDoorFrameTiles(const u8 *a0);
|
||||||
void sub_805AF94(const struct DoorGraphics * a0, int a1, int a2, const u8 *a3);
|
static void SetDoorFramePalettes(const struct DoorGraphics * gfx, int x, int y, const u8 *a3);
|
||||||
void sub_805AFE8(u16 *a0, u16 a1, const u8 *a2);
|
static void BufferDoorFrameTilesWithPalettes(u16 *a0, u16 a1, const u8 *a2);
|
||||||
bool32 sub_805B060(const struct DoorGraphics * gfx, const struct DoorAnimFrame * frames, u16 *data);
|
static bool32 PlayDoorAnimationFrame(const struct DoorGraphics * gfx, const struct DoorAnimFrame * frames, s16 *data);
|
||||||
|
static const struct DoorAnimFrame * SeekToEndOfDoorAnim(const struct DoorAnimFrame * frames);
|
||||||
|
static s8 GetDoorOpenType(const struct DoorGraphics * gfx, int x, int y);
|
||||||
|
|
||||||
extern const struct DoorAnimFrame gUnknown_835B488[];
|
extern const struct DoorAnimFrame sDoorAnimFrames_OpenSmall[];
|
||||||
extern const struct DoorAnimFrame gUnknown_835B49C[];
|
extern const struct DoorAnimFrame sDoorAnimFrames_OpenLarge[];
|
||||||
extern const struct DoorAnimFrame gUnknown_835B4B0[];
|
extern const struct DoorAnimFrame sDoorAnimFrames_CloseSmall[];
|
||||||
extern const struct DoorAnimFrame gUnknown_835B4C4[];
|
extern const struct DoorAnimFrame sDoorAnimFrames_CloseLarge[];
|
||||||
extern const struct DoorGraphics gUnknown_835B5D8[];
|
extern const struct DoorGraphics sDoorGraphics[];
|
||||||
|
|
||||||
void sub_805AF14(const struct DoorGraphics * a0, const struct DoorAnimFrame * a1, int a2, int a3)
|
static void UpdateDrawDoorFrame(const struct DoorGraphics * gfx, const struct DoorAnimFrame * frames, int x, int y)
|
||||||
{
|
{
|
||||||
if (a1->unk_2 == 0xFFFF)
|
if (frames->tile == 0xFFFF)
|
||||||
{
|
{
|
||||||
sub_805AF54(a0, a2, a3);
|
DrawDoorDefaultImage(gfx, x, y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sub_805AF80(&a0->unk_4[a1->unk_2]);
|
LoadDoorFrameTiles(&gfx->tiles[frames->tile]);
|
||||||
sub_805AF94(a0, a2, a3, a0->unk_8);
|
SetDoorFramePalettes(gfx, x, y, gfx->palettes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_805AF54(const struct DoorGraphics * a0, int a1, int a2)
|
static void DrawDoorDefaultImage(const struct DoorGraphics * gfx, int x, int y)
|
||||||
{
|
{
|
||||||
if (a0->unk_3 == 0)
|
if (gfx->size == 0)
|
||||||
{
|
{
|
||||||
CurrentMapDrawMetatileAt(a1, a2);
|
CurrentMapDrawMetatileAt(x, y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CurrentMapDrawMetatileAt(a1, a2);
|
CurrentMapDrawMetatileAt(x, y);
|
||||||
CurrentMapDrawMetatileAt(a1, a2 - 1);
|
CurrentMapDrawMetatileAt(x, y - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_805AF80(const u8 *a0)
|
static void LoadDoorFrameTiles(const u8 *a0)
|
||||||
{
|
{
|
||||||
CpuFastCopy(a0, (void *)(BG_VRAM + 0x7F00), 0x100);
|
CpuFastCopy(a0, (void *)(BG_VRAM + 0x7F00), 0x100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_805AF94(const struct DoorGraphics * a0, int a1, int a2, const u8 *a3)
|
static void SetDoorFramePalettes(const struct DoorGraphics * gfx, int x, int y, const u8 *a3)
|
||||||
{
|
{
|
||||||
u16 sp00[8];
|
u16 sp00[8];
|
||||||
if (a0->unk_3 == 0)
|
if (gfx->size == 0)
|
||||||
{
|
{
|
||||||
sub_805AFE8(sp00, 0x3F8, a3);
|
BufferDoorFrameTilesWithPalettes(sp00, 0x3F8, a3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sub_805AFE8(sp00, 0x3F8, a3);
|
BufferDoorFrameTilesWithPalettes(sp00, 0x3F8, a3);
|
||||||
sub_805A91C(a1, a2 - 1, sp00);
|
DrawDoorMetatileAt(x, y - 1, sp00);
|
||||||
sub_805AFE8(sp00, 0x3FC, a3 + 4);
|
BufferDoorFrameTilesWithPalettes(sp00, 0x3FC, a3 + 4);
|
||||||
}
|
}
|
||||||
sub_805A91C(a1, a2, sp00);
|
DrawDoorMetatileAt(x, y, sp00);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_805AFE8(u16 *a0, u16 a1, const u8 *a2)
|
static void BufferDoorFrameTilesWithPalettes(u16 *a0, u16 a1, const u8 *a2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u16 tile;
|
u16 tile;
|
||||||
@@ -92,11 +97,149 @@ void sub_805AFE8(u16 *a0, u16 a1, const u8 *a2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_805B028(u8 taskId)
|
static void Task_AnimateDoor(u8 taskId)
|
||||||
{
|
{
|
||||||
u16 *data = (void *)gTasks[taskId].data;
|
s16 *data = (void *)gTasks[taskId].data;
|
||||||
const struct DoorAnimFrame * frames = (const void *)((data[0] << 16) | data[1]);
|
const struct DoorAnimFrame * frames = (const void *)(((u16)data[0] << 16) | (u16)data[1]);
|
||||||
const struct DoorGraphics * gfx = (const void *)((data[2] << 16) | data[3]);
|
const struct DoorGraphics * gfx = (const void *)(((u16)data[2] << 16) | (u16)data[3]);
|
||||||
if (!sub_805B060(gfx, frames, data))
|
if (!PlayDoorAnimationFrame(gfx, frames, data))
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool32 PlayDoorAnimationFrame(const struct DoorGraphics * gfx, const struct DoorAnimFrame * frames, s16 *data)
|
||||||
|
{
|
||||||
|
if (data[5] == 0)
|
||||||
|
{
|
||||||
|
UpdateDrawDoorFrame(gfx, &frames[data[4]], data[6], data[7]);
|
||||||
|
}
|
||||||
|
if (data[5] == frames[data[4]].duration)
|
||||||
|
{
|
||||||
|
data[5] = 0;
|
||||||
|
data[4]++;
|
||||||
|
if (frames[data[4]].duration == 0)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data[5]++;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct DoorGraphics * door_find(const struct DoorGraphics * gfx, u16 id)
|
||||||
|
{
|
||||||
|
while (gfx->tiles != NULL)
|
||||||
|
{
|
||||||
|
if (gfx->metatileId == id)
|
||||||
|
return gfx;
|
||||||
|
gfx++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static s8 task_overworld_door_add_if_inactive(const struct DoorGraphics * gfx, const struct DoorAnimFrame * frames, int a2, int a3)
|
||||||
|
{
|
||||||
|
u8 taskId;
|
||||||
|
s16 *data;
|
||||||
|
if (FuncIsActiveTask(Task_AnimateDoor) == TRUE)
|
||||||
|
return -1;
|
||||||
|
taskId = CreateTask(Task_AnimateDoor, 80);
|
||||||
|
data = gTasks[taskId].data;
|
||||||
|
data[6] = a2;
|
||||||
|
data[7] = a3;
|
||||||
|
data[1] = (uintptr_t)frames;
|
||||||
|
data[0] = (uintptr_t)frames >> 16;
|
||||||
|
data[3] = (uintptr_t)gfx;
|
||||||
|
data[2] = (uintptr_t)gfx >> 16;
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawClosedDoor(const struct DoorGraphics * gfx, int a1, int a2)
|
||||||
|
{
|
||||||
|
DrawDoorDefaultImage(gfx, a1, a2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawOpenedDoor(const struct DoorGraphics * gfx, int x, int y)
|
||||||
|
{
|
||||||
|
gfx = door_find(gfx, MapGridGetMetatileIdAt(x, y));
|
||||||
|
if (gfx != NULL)
|
||||||
|
{
|
||||||
|
UpdateDrawDoorFrame(gfx, SeekToEndOfDoorAnim(gfx->size == 0 ? sDoorAnimFrames_OpenSmall : sDoorAnimFrames_OpenLarge), x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct DoorAnimFrame * SeekToEndOfDoorAnim(const struct DoorAnimFrame * frames)
|
||||||
|
{
|
||||||
|
while (frames->duration != 0)
|
||||||
|
frames++;
|
||||||
|
return frames - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static s8 AnimateDoorOpenInternal(const struct DoorGraphics * gfx, int x, int y)
|
||||||
|
{
|
||||||
|
gfx = door_find(gfx, MapGridGetMetatileIdAt(x, y));
|
||||||
|
if (gfx == NULL)
|
||||||
|
return -1;
|
||||||
|
else if (gfx->size == 0)
|
||||||
|
return task_overworld_door_add_if_inactive(gfx, sDoorAnimFrames_OpenSmall, x, y);
|
||||||
|
else
|
||||||
|
return task_overworld_door_add_if_inactive(gfx, sDoorAnimFrames_OpenLarge, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static s8 AnimateDoorCloseInternal(const struct DoorGraphics * gfx, int x, int y)
|
||||||
|
{
|
||||||
|
gfx = door_find(gfx, MapGridGetMetatileIdAt(x, y));
|
||||||
|
if (gfx == NULL)
|
||||||
|
return -1;
|
||||||
|
else if (gfx->size == 0)
|
||||||
|
return task_overworld_door_add_if_inactive(gfx, sDoorAnimFrames_CloseSmall, x, y);
|
||||||
|
else
|
||||||
|
return task_overworld_door_add_if_inactive(gfx, sDoorAnimFrames_CloseLarge, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FieldSetDoorOpened(int x, int y)
|
||||||
|
{
|
||||||
|
if (MetatileBehavior_IsWarpDoor_2(MapGridGetMetatileBehaviorAt((s16)x, (s16)y)))
|
||||||
|
DrawOpenedDoor(sDoorGraphics, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FieldSetDoorClosed(int x, int y)
|
||||||
|
{
|
||||||
|
if (MetatileBehavior_IsWarpDoor_2(MapGridGetMetatileBehaviorAt((s16)x, (s16)y)))
|
||||||
|
DrawClosedDoor(sDoorGraphics, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 FieldAnimateDoorClose(int x, int y)
|
||||||
|
{
|
||||||
|
if (!MetatileBehavior_IsWarpDoor_2(MapGridGetMetatileBehaviorAt((s16)x, (s16)y)))
|
||||||
|
return -1;
|
||||||
|
return AnimateDoorCloseInternal(sDoorGraphics, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 FieldAnimateDoorOpen(int x, int y)
|
||||||
|
{
|
||||||
|
if (!MetatileBehavior_IsWarpDoor_2(MapGridGetMetatileBehaviorAt((s16)x, (s16)y)))
|
||||||
|
return -1;
|
||||||
|
return AnimateDoorOpenInternal(sDoorGraphics, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 FieldIsDoorAnimationRunning(void)
|
||||||
|
{
|
||||||
|
return FuncIsActiveTask(Task_AnimateDoor);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 GetDoorSoundEffect(x, y)
|
||||||
|
{
|
||||||
|
if (!GetDoorOpenType(sDoorGraphics, x, y))
|
||||||
|
return MUS_W_DOOR;
|
||||||
|
else
|
||||||
|
return SE_JIDO_DOA;
|
||||||
|
}
|
||||||
|
|
||||||
|
static s8 GetDoorOpenType(const struct DoorGraphics * gfx, int x, int y)
|
||||||
|
{
|
||||||
|
gfx = door_find(gfx, MapGridGetMetatileIdAt(x, y));
|
||||||
|
if (gfx == NULL)
|
||||||
|
return -1;
|
||||||
|
return gfx->sliding;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user