Merge branch 'master' into tilemap-docs

This commit is contained in:
octorock
2024-01-06 12:26:39 +01:00
226 changed files with 2058 additions and 1984 deletions
+12 -10
View File
@@ -931,8 +931,8 @@ _0800271A:
bne _0800270A
pop {r4, r5, r6, pc}
thumb_func_start sub_08002724
sub_08002724: @ 0x08002724
thumb_func_start UnpackTextNibbles
UnpackTextNibbles: @ 0x08002724
push {r4, r5, lr}
movs r2, #0x10
movs r3, #0xf
@@ -1019,24 +1019,25 @@ _080027E6:
movs r0, #4
bx lr
// almost identical to LinearMoveDirection
// r0 = Entity*
// r1 = speed
// r2 = direction
non_word_aligned_thumb_func_start sub_080027EA
sub_080027EA: @ 0x080027EA
non_word_aligned_thumb_func_start LinearMoveDirectionOLD
LinearMoveDirectionOLD: @ 0x080027EA
push {r4, r5, r6, r7, lr}
movs r3, #0x80
tst r2, r3
bne _08002860
movs r4, #0x2a
ldrh r3, [r0, r4]
ldrh r3, [r0, r4] // collisions
movs r4, #7
tst r2, r4
bne _08002812
push {r0, r1, r2, r3}
adds r0, r2, #0
adds r1, r3, #0
bl sub_08002864
bl CalcCollisionDirectionOLD
adds r4, r0, #0
pop {r0, r1, r2, r3}
cmp r2, r4
@@ -1063,7 +1064,7 @@ _08002812:
_08002834:
adds r4, r0, #0
pop {r0, r1, r2, r3}
ldr r5, [r0, #0x2c]
ldr r5, [r0, #0x2c] // x
adds r5, r5, r4
str r5, [r0, #0x2c]
_0800283E:
@@ -1081,15 +1082,16 @@ _0800283E:
_08002856:
adds r4, r0, #0
pop {r0, r1, r2, r3}
ldr r5, [r0, #0x30]
ldr r5, [r0, #0x30] // y
subs r5, r5, r4
str r5, [r0, #0x30]
_08002860:
adds r1, r6, #0
pop {r4, r5, r6, r7, pc}
thumb_func_start sub_08002864
sub_08002864: @ 0x08002864
// collision related, probably leftover from FS
thumb_func_start CalcCollisionDirectionOLD
CalcCollisionDirectionOLD: @ 0x08002864
adds r2, r0, #0
lsrs r2, r2, #3
cmp r2, #0
+29 -29
View File
@@ -258,17 +258,17 @@ _08004162:
ands r2, r4
pop {r4, pc}
thumb_func_start sub_08004168
sub_08004168: @ 0x08004168
thumb_func_start SnapToTile
SnapToTile: @ 0x08004168
ldr r3, _08004384 @ =0x000FFFFF
ldr r1, _08004388 @ =0x00080000
ldr r2, [r0, #0x2c]
bics r2, r3
adds r2, r2, r1
ldr r2, [r0, #0x2c] // x
bics r2, r3 // align to grid
adds r2, r1 // add half of a tile
str r2, [r0, #0x2c]
ldr r2, [r0, #0x30]
ldr r2, [r0, #0x30] // y
bics r2, r3
adds r2, r2, r1
adds r2, r1
str r2, [r0, #0x30]
bx lr
@@ -348,8 +348,8 @@ sub_080041E8: @ 0x080041E8
subs r0, r0, r2
subs r1, r1, r3
thumb_func_start sub_080041EC
sub_080041EC: @ 0x080041EC
thumb_func_start CalcDistance
CalcDistance: @ 0x080041EC
adds r2, r0, #0
muls r0, r2, r0
adds r3, r1, #0
@@ -621,26 +621,26 @@ _0800439C: .4byte gSpritePtrs
_080043A0: .4byte gSpritePtrs
_080043A4: .4byte gGFXSlots+4
thumb_func_start sub_080043A8
sub_080043A8: @ 0x080043A8
movs r1, #0xb
b _080043B6
thumb_func_start CreateDrownFX
CreateDrownFX: @ 0x080043A8
movs r1, #0xb // FX_WATER_SPLASH
b create_fx
thumb_func_start CreateChestSpawner
CreateChestSpawner: @ 0x080043AC
movs r1, #0xc
b _080043B6
thumb_func_start CreateLavaDrownFX
CreateLavaDrownFX: @ 0x080043AC
movs r1, #0xc // FX_LAVA_SPLASH
b create_fx
thumb_func_start sub_080043B0
sub_080043B0: @ 0x080043AC
movs r1, #0x52
b _080043B6
thumb_func_start CreateSwampDrownFX
CreateSwampDrownFX: @ 0x080043AC
movs r1, #0x52 // FX_GREEN_SPLASH
b create_fx
thumb_func_start CreateItemOnGround
CreateItemOnGround: @ 0x080043B4
movs r1, #0
thumb_func_start CreatePitFallFX
CreatePitFallFX: @ 0x080043B4
movs r1, #0 // FX_FALL_DOWN
_080043B6:
create_fx:
push {r4, lr}
adds r4, r0, #0
movs r0, #0xf
@@ -648,10 +648,10 @@ _080043B6:
bl CreateObject
cmp r0, #0
beq _080043E0 @ Branch if entity could not be created
beq _080043E0
movs r1, #0x48
ldr r1, [r4, r1] @ Unused?
ldr r1, [r4, r1] // load hitbox (unused)
ldrh r3, [r4, #0x2e]
strh r3, [r0, #0x2e]
@@ -664,11 +664,11 @@ _080043B6:
ldrb r3, [r4, #8]
cmp r3, #3 @ Is the spawner an enemy?
cmp r3, #3 // is parent entity an enemy?
bne _080043E0
movs r1, #1
strb r1, [r0, #0xb] @ Set base parameter
strb r1, [r0, #0xb] // copy entity.type2
_080043E0:
adds r0, r4, #0
+62 -47
View File
@@ -5,57 +5,67 @@
.text
thumb_func_start sub_080043E8
sub_080043E8: @ 0x080043E8
.macro hazard_tile tile:req, hazard_type:req
.short \tile
.short \hazard_type
.endm
thumb_func_start GetTileHazardType
GetTileHazardType: @ 0x080043E8
push {r4, lr}
ldrb r1, [r0, #0xc]
cmp r1, #0
beq _08004414
beq no_hazard // action == 0
adds r4, r0, #0
bl sub_08016AD2
bl UpdateCollisionLayer
movs r3, #0x36
ldrsh r2, [r4, r3]
cmp r2, #0
bmi _08004414
cmp r0, #0
beq _08004414
add r3, pc, #0x10
_08004404:
bmi no_hazard // collisionLayer is negative
cmp r0, #0 // are we on a tile?
beq no_hazard
adr r3, hazard_list-4
loop:
adds r3, #4
ldrh r1, [r3]
cmp r1, #0
beq _08004414
beq no_hazard
cmp r0, r1
bne _08004404
bne loop
ldrh r0, [r3, #2]
pop {r4, pc}
_08004414:
no_hazard:
movs r0, #0
pop {r4, pc}
_08004418:
.byte 0x0D, 0x00, 0x01, 0x00, 0x10, 0x00, 0x02, 0x00
.byte 0x11, 0x00, 0x02, 0x00, 0x5A, 0x00, 0x03, 0x00, 0x13, 0x00, 0x04, 0x00, 0x00, 0x00
hazard_list:
hazard_tile 0xD, 0x1
hazard_tile 0x10, 0x2
hazard_tile 0x11, 0x2
hazard_tile 0x5A, 0x3
hazard_tile 0x13, 0x4
.short 0x0000
non_word_aligned_thumb_func_start sub_0800442E
sub_0800442E: @ 0x0800442E
push {r0, lr}
bl sub_080043E8
bl GetTileHazardType
cmp r0, #0
beq _08004448
lsls r0, r0, #2
add r1, pc, #0xC
beq not_hazard
lsls r0, #2
adr r1, _0800444C - 4
ldr r1, [r1, r0]
pop {r0}
bl _call_via_r1
movs r0, #1
pop {pc}
_08004448:
not_hazard:
movs r0, #0
pop {r1, pc}
_0800444C: .4byte CreateItemOnGround
_08004450: .4byte sub_080043A8
_08004454: .4byte CreateChestSpawner
_08004458: .4byte sub_080043B0
_0800444C: .4byte CreatePitFallFX
_08004450: .4byte CreateDrownFX
_08004454: .4byte CreateLavaDrownFX
_08004458: .4byte CreateSwampDrownFX
thumb_func_start sub_0800445C
sub_0800445C: @ 0x0800445C
@@ -67,7 +77,7 @@ sub_0800445C: @ 0x0800445C
ldr r5, _080044D8 @ =gPlayerEntity
adds r0, r4, #0
adds r1, r5, #0
bl sub_08004484
bl CalcCollisionStaticEntity
cmp r0, #0
beq _08004482
ldrb r0, [r5, #0xc]
@@ -80,8 +90,8 @@ _08004480:
_08004482:
pop {r4, r5, pc}
thumb_func_start sub_08004484
sub_08004484: @ 0x08004484
thumb_func_start CalcCollisionStaticEntity
CalcCollisionStaticEntity: @ 0x08004484
ldr r2, _080044DC @ =ram_sub_080B227C
bx r2
@@ -138,35 +148,40 @@ _080044E0: .4byte gUnk_02024048
_080044E4: .4byte gUnk_02021F20
_080044E8: .4byte gPlayerEntity
thumb_func_start sub_080044EC
sub_080044EC: @ 0x080044EC
// BounceUpdate
// assumes initial velocity is set
// r0: entity*
// r1: acceleration
thumb_func_start BounceUpdate
BounceUpdate: @ 0x080044EC
ldr r2, [r0, #0x34]
ldr r3, [r0, #0x20]
subs r2, r2, r3
bpl _080044FE
str r2, [r0, #0x34]
subs r3, r3, r1
str r3, [r0, #0x20]
movs r0, #2
subs r2, r3
bpl grounded // if z is positive, entity is grounded
str r2, [r0, #0x34] // entity.z = entity.z - entity.zVelocity
subs r3, r1
str r3, [r0, #0x20] // entity.zVelocity = entity.zVelocity - acceleration
movs r0, #2 // return 2
bx lr
_080044FE:
grounded:
movs r2, #1
str r2, [r0, #0x34]
subs r3, r3, r1
rsbs r3, r3, #0
lsrs r3, r3, #1
str r2, [r0, #0x34] // entity.z = 1 (note: player cant do certain actions at z!=0)
subs r3, r1
negs r3, r3
lsrs r3, #1
lsrs r1, r3, #2
adds r3, r3, r1
adds r3, r1 // calc next bounce velocity
lsrs r1, r3, #0xc
cmp r1, #0xc
bhs _08004516
movs r2, #0
movs r3, #0
bhs _08004516 // return 1 if bouncing
movs r2, #0 // return 0 if not bouncing
movs r3, #0 // set velocity to 0
_08004516:
str r3, [r0, #0x20]
adds r0, r2, #0
bx lr
// r0 = Entity*
thumb_func_start sub_0800451C
sub_0800451C: @ 0x0800451C
push {r0, lr}
@@ -192,17 +207,17 @@ sub_0800451C: @ 0x0800451C
sub_08004542: @ 0x08004542
movs r1, #0x38
movs r2, #2
strb r2, [r0, r1]
strb r2, [r0, r1] // entity->collisionLayer = 2
movs r2, #0xc0
ldrb r1, [r0, #0x1b]
bics r1, r2
adds r1, #0x40
strb r1, [r0, #0x1b]
strb r1, [r0, #0x1b] // update spriteOrientation
movs r2, #0xc0
ldrb r1, [r0, #0x19]
bics r1, r2
adds r1, #0x40
strb r1, [r0, #0x19]
strb r1, [r0, #0x19] // update spriteRendering
bx lr
non_word_aligned_thumb_func_start ResetCollisionLayer
+16 -15
View File
@@ -5,14 +5,14 @@
.text
@ TODO cannot add this at the end of mapVvvToSurfaceType.c due to alignment?
// TODO cannot add this at the end of mapVvvToSurfaceType.c due to alignment?
.2byte 0
@ TODO unused?
// TODO unused?
gUnk_08007DBE:: @ 08007DBE
.byte 0x42, 0x7b, 0x01, 0x32, 0x42, 0x73, 0x70, 0x47, 0x02, 0x73, 0x00, 0x23, 0x43, 0x73, 0x0b, 0x73
@ seems unused?
// seems unused?
non_word_aligned_thumb_func_start sub_08007DCE
sub_08007DCE:
push {lr}
@@ -20,26 +20,27 @@ sub_08007DCE:
pop {pc}
@ Find the key in the map of u16 to u16
@ r0: value, r1: array of u16*
// Find the key in the map of u16 to u16
// r0: value
// r1: array of u16*
non_word_aligned_thumb_func_start FindValueForKey
FindValueForKey: @ 0x08007DD6
push {lr}
bl sub_08007DE0
adds r0, r3, #0 @ move the found value into r0
bl ActTileConv
adds r0, r3, #0 // move the found value into r0
pop {pc}
thumb_func_start sub_08007DE0
sub_08007DE0: @ 0x08007DE0
thumb_func_start ActTileConv // TODO rename
ActTileConv: @ 0x08007DE0
subs r1, #4
_08007DE2:
adds r1, #4 @ add +4 to r1 at the end of loop
ldrh r3, [r1] @ r3: key
adds r1, #4 // add +4 to r1 at the end of loop
ldrh r3, [r1] // r3: key
cmp r3, #0
beq _08007DF2 @ key == 0 -> end of map
beq _08007DF2 // key == 0 -> end of map
cmp r0, r3
bne _08007DE2 @ r3 == r0 -> found
ldrh r3, [r1, #2] @ r3: value
movs r2, #1 @ r2 = 1
bne _08007DE2 // r3 == r0 -> found
ldrh r3, [r1, #2] // r3: value
movs r2, #1 // r2 = 1
_08007DF2:
bx lr
+8 -8
View File
@@ -71,7 +71,7 @@ _08001230:
ldr r3, _0800135C @ =UpdateAnimationVariableFrames
bx r3
_0800123E:
ldr r3, _08001360 @ =CreateItemOnGround
ldr r3, _08001360 @ =CreatePitFallFX
bx r3
non_word_aligned_thumb_func_start GenericConfused
@@ -105,7 +105,7 @@ GenericConfused: @ 0x08001242
cmp r2, #0x1c
bne _08001282
push {r0}
bl sub_0804AA1C
bl EnemyDetachFX
pop {r0}
_08001282:
ldr r1, _08001364 @ =0x00001800
@@ -155,19 +155,19 @@ _080012BA:
gUnk_080012C8::
.4byte 0x00000000
_080012CC: .4byte sub_08001214
_080012D0: .4byte sub_080043A8
_080012D4: .4byte CreateChestSpawner
_080012D8: .4byte sub_080043B0
_080012D0: .4byte CreateDrownFX
_080012D4: .4byte CreateLavaDrownFX
_080012D8: .4byte CreateSwampDrownFX
thumb_func_start sub_080012DC
sub_080012DC: @ 0x080012DC
push {r4, r5, lr}
adds r4, r0, #0
movs r5, #0x3a
ldrb r1, [r4, r5]
ldrb r1, [r4, r5] // gust jar state
lsrs r1, r1, #3
bhs _08001302
bl sub_080043E8
bl GetTileHazardType
cmp r0, #4
beq _08001302
cmp r0, #0
@@ -241,7 +241,7 @@ _08001352:
.align 2, 0
_08001358: .4byte gEnemyFunctions
_0800135C: .4byte UpdateAnimationVariableFrames
_08001360: .4byte CreateItemOnGround
_08001360: .4byte CreatePitFallFX
_08001364: .4byte 0x00001800
_08001368: .4byte gUnk_080012C8
_0800136C: .4byte gUnk_080012C8
+171 -144
View File
@@ -87,7 +87,7 @@ arm_sub_080B1A0C: @ 0x080B1A0C
ldrb r2, [r0, #0x38]
mov r0, r3
b arm_GetMetaTileTypeByPos
arm_GetMetaTileTypeByEntity:
arm_GetMetaTileTypeByEntity: // GetCell
ldrb r2, [r0, #0x38]
ldrh r1, [r0, #0x32]
ldrh r0, [r0, #0x2e]
@@ -121,8 +121,9 @@ _080B1A64:
ldrh r0, [r1, r0]
bx lr
// entity plus offset to world pixel coordinates and layer
arm_func_start arm_GetVvvRelativeToEntity
arm_GetVvvRelativeToEntity: @ 0x080B1A8C @ entity plus offset to world pixel coordinates and layer
arm_GetVvvRelativeToEntity: @ 0x080B1A8C
ldrh r3, [r0, #0x2e]
add r3, r3, r1
ldrh r1, [r0, #0x32]
@@ -130,7 +131,8 @@ arm_GetVvvRelativeToEntity: @ 0x080B1A8C @ entity plus offset to world pixel coo
ldrb r2, [r0, #0x38]
mov r0, r3
b arm_GetVvvAtWorldCoords
arm_GetVvvAtEntity: @ entity to world pixel coordinates and layer
// entity to world pixel coordinates and layer
arm_GetVvvAtEntity: // GetCellAct
ldrb r2, [r0, #0x38]
ldrh r1, [r0, #0x32]
ldrh r0, [r0, #0x2e]
@@ -156,35 +158,39 @@ arm_GetVvvAtMetaTilePos:
arm_func_start arm_GetCollisionDataRelativeTo
arm_GetCollisionDataRelativeTo: @ 0x080B1AF0
ldrh r3, [r0, #0x2e]
@ r0 = entity*
@ r1 = x
@ r2 = y
ldrh r3, [r0, #0x2e] @ ent.x + x
add r3, r3, r1
ldrh r1, [r0, #0x32]
ldrh r1, [r0, #0x32] @ ent.y + y
add r1, r1, r2
ldrb r2, [r0, #0x38]
ldrb r2, [r0, #0x38] @ ent.layer
mov r0, r3
b arm_GetCollisionDataAtWorldCoords
arm_GetCollisionDataAtEntity:
ldrb r2, [r0, #0x38]
ldrh r1, [r0, #0x32]
ldrh r0, [r0, #0x2e]
arm_GetCollisionDataAtEntity: // GetCellAtt
ldrb r2, [r0, #0x38] @ ent.layer
ldrh r1, [r0, #0x32] @ ent.y
ldrh r0, [r0, #0x2e] @ ent.x
arm_GetCollisionDataAtWorldCoords:
ldr ip, _080B1C28 @ =gRoomControls
ldrh r3, [ip, #6]
sub r0, r0, r3
sub r0, r0, r3 @ ent.x - gRoomControls.origin_x
ldrh r3, [ip, #8]
sub r1, r1, r3
sub r1, r1, r3 @ ent.y - gRoomControls.origin_y
arm_GetCollisionDataAtRoomCoords:
lsl r0, r0, #0x16
lsr r0, r0, #0x1a
lsr r0, r0, #0x1a @ /= 16
lsl r1, r1, #0x16
lsr r1, r1, #0x1a
lsr r1, r1, #0x1a @ /= 16
arm_GetCollisionDataAtRoomTile:
add r0, r0, r1, lsl #6
add r0, r0, r1, lsl #6 @ convert coords to tile index
mov r1, r2
arm_GetCollisionDataAtMetaTilePos:
ldr r2, _080B1C2C @ =gCollisionDataPtrs
ldr r1, [r2, r1, lsl #2]
ldrb r0, [r1, r0]
ldrb r0, [r1, r0] @ load collision tile at my location
bx lr
arm_func_start arm_GetVvvForMetaTileType
@@ -283,77 +289,80 @@ UpdateCollision: @ 0x080B1C54
arm_func_start arm_CollideAll
arm_CollideAll: @ 0x080B1C7C
THIS .req r4
OTHER .req r5
push {r4, r5, r6, r7, r8, sb, sl, lr}
add r0, pc, #0x104 @ =_080B1D8C
ldm r0, {r8, sb, sl}
ldrb sl, [sl]
cmp sl, #0
beq _080B1D84
ldr r8, [r8]
ldr r8, [r8] // load entity
mov r7, r8
_080B1C9C:
ldr r4, [r8, #8]
ldrb r0, [r4, #0x10]
ands r0, r0, #0x80
beq _080B1D78
ldrb r0, [r4, #0x3c]
and r0, r0, #7
next_this:
ldr THIS, [r8, #8]
ldrb r0, [THIS, #0x10]
ands r0, r0, #0x80 // disable collision flag
beq end_check_this
ldrb r0, [THIS, #0x3c] // collisionFlags
and r0, r0, #7 // first 3 bits
mov r1, #1
lsl r6, r1, r0
ldrb r3, [r4, #0x3c]
ldrb r2, [r4, #0x3d]
lsl r6, r1, r0 // 1 << (collisionFlags & 7)
ldrb r3, [THIS, #0x3c]
ldrb r2, [THIS, #0x3d] // iframes
mov ip, sl
_080B1CC8:
next_other: // r4 = this, r5 = other
subs ip, ip, #1
bmi _080B1D78
ldr r5, [sb, ip, lsl #2]
cmp r4, r5
beq _080B1CC8
ldr r0, [r5, #0x3b]
ands r0, r0, r6
beq _080B1CC8
ldrb r0, [r5, #0x10]
bmi end_check_this
ldr OTHER, [sb, ip, lsl #2]
cmp THIS, OTHER
beq next_other
ldr r0, [OTHER, #0x3b] // collisionMask
ands r0, r0, r6 // other.collisionMask & (1 << m)
beq next_other
ldrb r0, [OTHER, #0x10] // disable collision flag
ands r0, r0, #0x80
beq _080B1CC8
ldrb r0, [r4, #0x38]
ldrb r1, [r5, #0x38]
beq next_other
ldrb r0, [THIS, #0x38] // collisionLayer
ldrb r1, [OTHER, #0x38]
ands r0, r0, r1
beq _080B1CC8
ldrb r0, [r5, #0x3c]
beq next_other
ldrb r0, [OTHER, #0x3c] // collisionFlags
orr r0, r0, r3
lsrs r0, r0, #7
lsrs r0, r0, #7 // top
bhs _080B1D20
ldrb r0, [r5, #0x3d]
ldrb r0, [OTHER, #0x3d] // iframes
orrs r0, r0, r2
bne _080B1CC8
bne next_other
_080B1D20:
bl arm_CalcCollision
cmp r0, #0
beq _080B1CC8
ldrb r3, [r4, #0x3c]
ldrb r0, [r4, #0x3d]
ldrb r1, [r4, #0x43]
beq next_other
ldrb r3, [THIS, #0x3c]
ldrb r0, [THIS, #0x3d] // iframes
ldrb r1, [THIS, #0x43] // hitType
orr r2, r0, r1
ldrb r0, [r5, #0x41]
ldrb r0, [OTHER, #0x41] // OTHER processing a collision already?
ands r0, r0, #0x80
bne _080B1D58
str r4, [r5, #0x4c]
ldrb r0, [r4, #0x40]
bne _080B1D58 // branch if set
str THIS, [OTHER, #0x4c] // contactedEntity
ldrb r0, [THIS, #0x40]
orr r0, r0, #0x80
strb r0, [r5, #0x41]
strb r0, [OTHER, #0x41] // contactFlags |= 0x80
_080B1D58:
ldrb r0, [r4, #0x41]
ldrb r0, [THIS, #0x41] // THIS processing a collision already?
ands r0, r0, #0x80
bne _080B1CC8
str r5, [r4, #0x4c]
ldrb r0, [r5, #0x40]
bne next_other
str OTHER, [THIS, #0x4c]
ldrb r0, [OTHER, #0x40]
orr r0, r0, #0x80
strb r0, [r4, #0x41]
b _080B1CC8
_080B1D78:
strb r0, [THIS, #0x41]
b next_other
end_check_this:
ldr r8, [r8, #4]
cmp r8, r7
bne _080B1C9C
bne next_this
_080B1D84:
pop {r4, r5, r6, r7, r8, sb, sl, lr}
bx lr
@@ -363,56 +372,59 @@ _080B1D94: .4byte gCollidableCount
arm_func_start arm_CalcCollision
arm_CalcCollision: @ 0x080B1D98
@ r6 = this, r7 = other
THIS .req r4
OTHER .req r5
BB_THIS .req r6
BB_OTHER .req r7
push {r2, r3, r6, r7, r8, sb, ip, lr}
ldr r6, [r4, #0x48]
ldr r7, [r5, #0x48]
ldrh r0, [r4, #0x2e]
ldrh r1, [r5, #0x2e]
ldr BB_THIS, [THIS, #0x48]
ldr BB_OTHER, [OTHER, #0x48]
ldrh r0, [THIS, #0x2e]
ldrh r1, [OTHER, #0x2e]
sub r0, r0, r1
ldrsb r1, [r6]
ldrsb r1, [BB_THIS]
add r0, r0, r1
ldrsb r1, [r7]
ldrsb r1, [BB_OTHER]
sub r0, r0, r1
ldrb r1, [r6, #6]
ldrb r2, [r7, #6]
ldrb r1, [BB_THIS, #6]
ldrb r2, [BB_OTHER, #6]
add r1, r1, r2
add r2, r0, r1
cmp r2, r1, lsl #1
bhi _080B1F28
ldrh r1, [r4, #0x32]
ldrh r2, [r5, #0x32]
bhi not_overlapping
ldrh r1, [THIS, #0x32]
ldrh r2, [OTHER, #0x32]
sub r1, r1, r2
ldrsb r2, [r6, #1]
ldrsb r2, [BB_THIS, #1]
add r1, r1, r2
ldrsb r2, [r7, #1]
ldrsb r2, [BB_OTHER, #1]
sub r1, r1, r2
ldrb r2, [r6, #7]
ldrb r3, [r7, #7]
ldrb r2, [BB_THIS, #7]
ldrb r3, [BB_OTHER, #7]
add r2, r2, r3
add r3, r1, r2
cmp r3, r2, lsl #1
bhi _080B1F28
bhi not_overlapping
mov r2, #5
mov r3, #5
ldr r8, [r4, #0x3c]
ldr r8, [THIS, #0x3c] // collisionFlags & 0x10
ands r8, r8, #0x10
ldrbne r2, [r6, #8]
ldr r8, [r5, #0x3c]
ldrbne r2, [BB_THIS, #8] // 3d hitbox
ldr r8, [OTHER, #0x3c]
ands r8, r8, #0x10
ldrbne r3, [r7, #8]
ldrbne r3, [BB_OTHER, #8]
add r2, r2, r3
ldrsh r8, [r4, #0x36]
ldrsh sb, [r5, #0x36]
ldrsh r8, [THIS, #0x36] // Z
ldrsh sb, [OTHER, #0x36]
sub r8, r8, sb
add r8, r2, r8
cmp r8, r2, lsl #1
bhi _080B1F28
ldrb r2, [r4, #0x3c]
bhi not_overlapping
ldrb r2, [THIS, #0x3c] // collisionFlags & BBOX_SOLID
and r2, r2, #0x20
lsr r2, r2, #3
ldrb r3, [r5, #0x3c]
ldrb r3, [OTHER, #0x3c]
and r3, r3, #0x20
adds r2, r2, r3, lsr #2
beq _080B1E74
@@ -425,15 +437,15 @@ _080B1E74:
mov ip, #0
bl arm_CalcCollisionDirection
mov r6, r0
ldrb r1, [r5, #0x3f]
ldrb r1, [OTHER, #0x3f] // hitType
mov r0, #0x22
mul r1, r0, r1
ldrb r0, [r4, #0x40]
ldrb r0, [THIS, #0x40] // hurtType
add r0, r0, r1
mov r1, #0xc
mul r2, r0, r1
ldr r1, _080B2014 @ =gCollisionMtx
add r3, r2, r1
add r3, r2, r1 // gCollisionMtx + 12 * (34 * hurtType + hurtType)
mov r1, #0
ldrb r0, [r3]
cmp r0, #0xff
@@ -446,106 +458,120 @@ _080B1E74:
mov lr, pc
bx r7
_080B1ED4:
cmp r0, #0
beq _080B1F20
cmp r0, #2
beq _080B1F1C
ldrb r0, [r4, #0x3c]
cmp r0, #0 // RESULT_NO_COLLISION
beq no_col
cmp r0, #2 // RESULT_COLLISION_WITHOUT_SET
beq col_no_set
// RESULT_COLLISION
ldrb r0, [THIS, #0x3c] // collisionFlags
and r0, r0, #0x80
lsr r0, r0, #5
ldrb r1, [r5, #0x3c]
ldrb r1, [OTHER, #0x3c] // collisionFlags
and r1, r1, #0x80
lsr r1, r1, #4
add r0, r0, r1
add r1, pc, #0xF4 @ =_080B1FFC
ldr r0, [r1, r0]
mov lr, pc
bx r0
bx r0 // jumptable 0 1 2
_080B1F10:
strb r6, [r5, #0x3e]
strb r6, [OTHER, #0x3e]
eor r6, r6, #0x10
strb r6, [r4, #0x3e]
_080B1F1C:
strb r6, [THIS, #0x3e]
col_no_set:
mov r0, #1
_080B1F20:
no_col:
pop {r2, r3, r6, r7, r8, sb, ip, lr}
bx lr
_080B1F28:
not_overlapping:
mov r0, #0
b _080B1F20
b no_col
// BBOX_SOLID THIS
arm_func_start arm_sub_080B1F30
arm_sub_080B1F30: @ 0x080B1F30
ldrh r0, [r4, #0x2e]
ldrh r1, [r5, #0x2e]
ldrh r0, [THIS, #0x2e]
ldrh r1, [OTHER, #0x2e]
sub r0, r0, r1
ldrsb r1, [r7]
ldrsb r1, [BB_OTHER]
sub r0, r0, r1
ldrh r1, [r4, #0x32]
ldrh r2, [r5, #0x32]
ldrh r1, [THIS, #0x32]
ldrh r2, [OTHER, #0x32]
sub r1, r1, r2
ldrsb r2, [r7, #1]
ldrsb r2, [BB_OTHER, #1]
sub r1, r1, r2
bx lr
// BBOX_SOLID OTHER
arm_func_start arm_sub_080B1F5C
arm_sub_080B1F5C: @ 0x080B1F5C
ldrh r0, [r4, #0x2e]
ldrh r1, [r5, #0x2e]
ldrh r0, [THIS, #0x2e]
ldrh r1, [OTHER, #0x2e]
sub r0, r0, r1
ldrsb r1, [r6]
ldrsb r1, [BB_THIS]
add r0, r0, r1
ldrh r1, [r4, #0x32]
ldrh r2, [r5, #0x32]
ldrh r1, [THIS, #0x32]
ldrh r2, [OTHER, #0x32]
sub r1, r1, r2
ldrsb r2, [r6, #1]
ldrsb r2, [BB_THIS, #1]
add r1, r1, r2
bx lr
// BBOX_SOLID BOTH
arm_func_start arm_sub_080B1F88
arm_sub_080B1F88: @ 0x080B1F88
ldrh r0, [r4, #0x2e]
ldrh r1, [r5, #0x2e]
ldrh r0, [THIS, #0x2e]
ldrh r1, [OTHER, #0x2e]
sub r0, r0, r1
ldrh r1, [r4, #0x32]
ldrh r2, [r5, #0x32]
ldrh r1, [THIS, #0x32]
ldrh r2, [OTHER, #0x32]
sub r1, r1, r2
bx lr
// BBOX_REFLECT OTHER
arm_func_start arm_sub_080B1FA4
arm_sub_080B1FA4: @ 0x080B1FA4
ldrb r0, [r5, #0x15]
ldrb r0, [r5, #0x15] // invert direction
eor r0, r0, #0x10
b _080B1FB4
// BBOX_REFLECT THIS
_080B1FB0:
ldrb r0, [r4, #0x15]
ldrb r0, [THIS, #0x15] // direction
_080B1FB4:
sub r1, r0, #8
and r1, r1, #0x1f
sub r1, r6, r1
and r1, r1, #0x1f
sub r1, r0, #8 // turn counterclockwise
and r1, r1, #0x1f // normalize
sub r1, r6, r1 // sub calcDir
and r1, r1, #0x1f // normalize
cmp r1, #0x11
bxlo lr
sub r0, r6, r0
sub r0, r0, #8
and r0, r0, #0x1f
sub r6, r6, r0, lsl #1
bxlo lr // branch if facing to the right
sub r0, r6, r0 // sub calcDir
sub r0, r0, #8 // turn counterclockwise
and r0, r0, #0x1f // normalize
sub r6, r6, r0, lsl #1 // calcDir -= 2 * temp
and r6, r6, #0x1f
bx lr
// BBOX_REFLECT BOTH
arm_func_start arm_sub_080B1FE4
arm_sub_080B1FE4: @ 0x080B1FE4
ldrb r6, [r4, #0x15]
ldrb r6, [THIS, #0x15] // direction
// BBOX_REFLECT NONE, BBOX_SOLID NONE
_080B1FE8:
bx lr
_080B1FEC: .4byte ram_sub_080B1FE8
_080B1FF0: .4byte ram_sub_080B1F30
_080B1FF4: .4byte ram_sub_080B1F5C
_080B1FF8: .4byte ram_sub_080B1F88
_080B1FFC: .4byte ram_sub_080B1FE8
_080B2000: .4byte ram_sub_080B1FB0
_080B2004: .4byte ram_sub_080B1FA4
_080B2008: .4byte ram_sub_080B1FE4
_080B200C: .4byte gCollidableList
_080B2010: .4byte gCollidableCount
_080B2014: .4byte gCollisionMtx
@@ -743,29 +769,30 @@ _080B2270: .4byte gUpdateContext
_080B2274: .4byte gUnk_080026A4
_080B2278: .4byte gUpdateContext
// calculating knockback?
arm_func_start arm_sub_080B227C
arm_sub_080B227C: @ 0x080B227C
push {r4, r5, r6, r7, r8, lr}
ldr r2, [r0, #0x48]
push {r4-r8, lr}
ldr r2, [r0, #0x48] // tgt.hitbox
cmp r2, #0
beq _080B236C
ldr r3, [r1, #0x48]
beq ret_false
ldr r3, [r1, #0x48] // org.hitbox
cmp r3, #0
beq _080B236C
beq ret_false
ldrh r4, [r1, #0x2e]
ldrsb r5, [r3]
add r4, r4, r5
ldrh r5, [r0, #0x2e]
sub r4, r4, r5
ldrsb r5, [r2]
sub r4, r4, r5
sub r4, r4, r5 // temp = (tgt.x + tgt.hitbox.x) - (org.x + org.hitbox.x)
ldrb r5, [r2, #6]
ldrb r6, [r3, #6]
add r5, r5, r6
add r6, r4, r5
add r6, r4, r5 // temp = temp + (tgt.hitbox.width + org.hitbox.width)
lsl r7, r5, #1
cmp r7, r6
blo _080B236C
blo ret_false // not colliding
cmp r4, #0
movpl ip, #8
movmi ip, #0x18
@@ -784,7 +811,7 @@ arm_sub_080B227C: @ 0x080B227C
add r5, r4, r3
lsl r6, r3, #1
cmp r6, r5
blo _080B236C
blo ret_false
cmp r4, #0
movpl r2, #0x10
movmi r2, #0
@@ -794,7 +821,7 @@ arm_sub_080B227C: @ 0x080B227C
movhs r7, r8
movhs r2, ip
cmp r7, #0
beq _080B236C
beq ret_false
cmp r7, #5
movhs r7, #4
mov r0, r1
@@ -803,11 +830,11 @@ arm_sub_080B227C: @ 0x080B227C
mov lr, pc
bx r3
_080B2360:
pop {r4, r5, r6, r7, r8, lr}
pop {r4-r8, lr}
mov r0, #1
bx lr
_080B236C:
pop {r4, r5, r6, r7, r8, lr}
ret_false:
pop {r4-r8, lr}
mov r0, #0
bx lr
.align 2, 0
+80 -80
View File
@@ -26,7 +26,7 @@ sub_0800857C: @ 0x0800857C
_0800859C:
ldrh r1, [r0, #0x24]
ldrb r2, [r0, #0x15]
bl sub_080027EA
bl LinearMoveDirectionOLD
pop {r4 - r7}
mov r8, r4
@@ -57,11 +57,11 @@ sub_080085CC: @ 0x080085CC
ldr r2, _0800888C @ =gPlayerState
ldr r1, _08008890 @ =gUnk_080083FC
movs r3, #0x26
ldrb r3, [r2, r3]
ldrb r3, [r2, r3] // swim_state
orrs r3, r3
beq _080085E6
ldr r2, [r2, #0x30]
movs r3, #0x80
movs r3, #0x80 // flags & PL_MINISH
ands r2, r3
beq _0800861A
ldr r1, _08008894 @ =gUnk_0800839C
@@ -70,12 +70,12 @@ _080085E6:
ldr r1, _08008898 @ =gUnk_0800845C
ldrb r3, [r2, #2]
orrs r3, r3
bne _0800861A
ldr r2, [r2, #0x30]
bne _0800861A // jump_status != 0
ldr r2, [r2, #0x30] // flags & PL_PARACHUTE
ldr r3, _0800889C @ =0x01000000
tst r2, r3
bne _0800861A
movs r3, #0x80
movs r3, #0x80 // // flags & PL_MINISH
ldr r1, _080088A0 @ =gUnk_0800833C
ands r2, r3
bne _0800861A
@@ -83,15 +83,15 @@ _080085E6:
ldr r3, _080088A8 @ =gPlayerState
ldrb r2, [r3, #0x1c]
orrs r2, r2
bne _0800861A
bne _0800861A // gustJarState != 0
ldrb r2, [r3, #5]
orrs r2, r2
bne _0800861A
bne _0800861A // heldObject != 0
ldr r1, _080088AC @ =gUnk_0800851C
movs r2, #0xaa
ldrb r2, [r3, r2]
orrs r2, r2
bne _0800861A
bne _0800861A // attachedBeetleCount != 0
ldr r1, _080088B0 @ =gUnk_080082DC
_0800861A:
mov r11, r1
@@ -169,7 +169,7 @@ _08008684:
_080086AC:
mov r0, r8
movs r2, #0x2a
strh r7, [r0, r2]
strh r7, [r0, r2] // collisions
pop {pc}
thumb_func_start sub_080086B4
@@ -265,17 +265,17 @@ _08008754:
ands r2, r3
pop {pc}
non_word_aligned_thumb_func_start sub_0800875A
sub_0800875A: @ 0x0800875A
non_word_aligned_thumb_func_start DoItemTileInteraction
DoItemTileInteraction: @ 0x0800875A
push {r2, r4, lr}
ldrb r3, [r0, #0x14]
ldrb r3, [r0, #0x14] // item.animationState
movs r2, #6
ands r3, r2
ldr r4, _080088D0 @ =gUnk_08007DF4
ldrsb r2, [r4, r3]
adds r3, #1
ldrsb r3, [r4, r3]
bl sub_08008782
bl DoTileInteractionOffset
pop {r2, r4}
cmp r0, #0
beq _08008780
@@ -288,21 +288,21 @@ sub_0800875A: @ 0x0800875A
_08008780:
pop {pc}
non_word_aligned_thumb_func_start sub_08008782
sub_08008782: @ 0x08008782
non_word_aligned_thumb_func_start DoTileInteractionOffset
DoTileInteractionOffset: @ 0x08008782
push {r4}
ldrh r4, [r0, #0x2e]
adds r2, r2, r4
ldrh r4, [r0, #0x32]
adds r3, r3, r4
pop {r4}
b sub_08008796
b DoTileInteraction
thumb_func_start sub_08008790
sub_08008790: @ 0x08008790
thumb_func_start DoTileInteractionHere
DoTileInteractionHere: @ 0x08008790
ldrh r2, [r0, #0x2e]
ldrh r3, [r0, #0x32]
b sub_08008796
b DoTileInteraction
// r0: Entity*
// r1: tile filter?
@@ -310,8 +310,8 @@ sub_08008790: @ 0x08008790
// r3: y
// Somehow involved in trampling tiles, digging with claws, picking up tiles..
non_word_aligned_thumb_func_start sub_08008796
sub_08008796: @ 0x08008796
non_word_aligned_thumb_func_start DoTileInteraction
DoTileInteraction: @ 0x08008796
push {r4, r5, r6, r7, lr}
push {r2, r3}
ldr r2, _080088D4 @ =gRoomControls
@@ -319,17 +319,17 @@ sub_08008796: @ 0x08008796
movs r2, #1
cmp r2, r3
pop {r2, r3}
beq _080087CE
beq _080087CE_return0
push {r0, r1, r2, r3}
pop {r4, r5, r6, r7}
adds r0, r6, #0
adds r1, r7, #0
movs r2, #0x38
ldrb r2, [r4, r2]
ldrb r2, [r4, r2] // collision layer
bl GetMetaTileTypeByPos
ldr r1, _080088D8 @ =gUnk_080046A4
bl sub_08007DE0
beq _080087CE
bl ActTileConv
beq _080087CE_return0
lsls r1, r3, #3
adds r3, r5, #0
ldr r0, _080088DC @ =gUnk_080047F6
@@ -338,51 +338,51 @@ sub_08008796: @ 0x08008796
lsrs r0, r3
lsrs r0, r0, #1
bhs _080087D2
_080087CE:
_080087CE_return0:
movs r0, #0
pop {r4, r5, r6, r7, pc}
_080087D2:
ldrb r0, [r5, #2]
ldrb r1, [r5, #3]
ldrb r0, [r5, #2] // object id
ldrb r1, [r5, #3] // object type
cmp r0, #0xff
beq _0800883A
beq after_create_obj
cmp r3, #6
beq _0800883A
beq after_create_obj
cmp r3, #0xe
beq _0800883A
beq after_create_obj
cmp r3, #0xa
beq _0800883A
beq after_create_obj
cmp r3, #0xb
beq _0800883A
beq after_create_obj
cmp r3, #0xd
bne _080087F6
cmp r0, #0xf
bne _0800883A
cmp r1, #0x17
bne _0800883A
cmp r0, #0xf // SPECIAL_FX
bne after_create_obj
cmp r1, #0x17 // FX_GRASS_CUT
bne after_create_obj
_080087F6:
movs r2, #0
cmp r0, #0xf
cmp r0, #0xf // SPECIAL_FX
bne _080087FE
movs r2, #0x80
_080087FE:
bl CreateObject
bl CreateObject // r0 = id, r1 = type, r2 = type2
cmp r0, #0
beq _0800883A
ldrb r1, [r5, #2]
beq after_create_obj
ldrb r1, [r5, #2] // object id
cmp r1, #0
beq _08008820
beq no_offset
movs r2, #0xf
adds r1, r6, #0
bics r1, r2
adds r1, #8
strh r1, [r0, #0x2e]
strh r1, [r0, #0x2e] // x
adds r1, r7, #0
bics r1, r2
adds r1, #8
strh r1, [r0, #0x32]
strh r1, [r0, #0x32] // y
b _0800882C
_08008820:
no_offset:
ldrh r1, [r4, #0x2e]
strh r1, [r0, #0x2e]
ldrh r1, [r4, #0x32]
@@ -391,12 +391,12 @@ _08008820:
strh r1, [r1, #0x36]
_0800882C:
movs r3, #0x50
str r4, [r1, r3]
str r4, [r1, r3] // set parent to r4
movs r3, #0x38
ldrb r1, [r4, r3]
ldrb r1, [r4, r3] // copy collision layer from parent
strb r1, [r0, r3]
bl UpdateSpriteForCollisionLayer
_0800883A:
after_create_obj:
ldr r1, _080088E0 @ =gRoomControls
ldrh r0, [r1, #6]
subs r2, r6, r0
@@ -461,22 +461,22 @@ _080088DC: .4byte gUnk_080047F6
_080088E0: .4byte gRoomControls
_080088E4: .4byte 0x00004000
_080088E8: .4byte 0x0000FFFF
_080088EC:
velocities1:
.byte 0, -3, 3, -3
.byte 3, 0, 3, 3
.byte 0, 3, -3, 3
.byte -3, 0, -3, -3
_080088FC:
ice_velocities:
.byte 0, -10, 10, -10
.byte 10, 0, 10, 10
.byte 0, 10, -10, 10
.byte -10, 0, -10, -10
_0800890C:
velocities3:
.byte 0, 6, -6, 0
.byte 0, -6, 6, 0
.byte 19, 18, 18, 16
.byte 16, 17, 17, 19
_0800891C:
reset_vel:
push {r0}
bl ResetPlayerVelocity
pop {r0}
@@ -497,7 +497,7 @@ UpdateIcePlayerVelocity: @ 0x0800892E
_UpdateIcePlayerVelocity:
push {lr}
ldrb r2, [r0, #0x14]
ldrb r2, [r0, #0x14] // animationState
lsrs r2, r2, #1
lsls r2, r2, #3
ldr r1, _08008A68 @ =gPlayerState
@@ -522,20 +522,20 @@ _08008956:
movs r3, #0x80
tst r2, r3
bne _080089C0
_08008960:
ldrb r3, [r1, #5]
_08008960: // r1 = gPlayerState
ldrb r3, [r1, #5] // heldObject
cmp r3, #2
beq _0800891C
beq reset_vel
cmp r3, #1
beq _0800891C
ldr r4, _08008A74 @ =_080088FC
beq reset_vel
ldr r4, _08008A74 @ =ice_velocities
ldrb r3, [r1, #2]
adds r1, r2, #0
orrs r3, r3
orrs r3, r3 // jump_status != 0
beq _08008992
push {r2}
movs r3, #0x14
ldrb r1, [r0, r3]
ldrb r1, [r0, r3] // field_0x14
lsrs r1, r1, #1
lsls r1, r1, #1
lsrs r2, r2, #2
@@ -544,7 +544,7 @@ _08008960:
adds r2, #2
movs r4, #7
ands r2, r4
ldr r4, _08008A78 @ =_080088EC
ldr r4, _08008A78 @ =velocities1
cmp r2, #4
beq _08008992
bhs _080089A8
@@ -557,25 +557,25 @@ _08008992:
ldrsb r2, [r4, r3]
adds r3, #1
ldrsb r3, [r4, r3]
bl sub_08008A46
bl AddPlayerVelocity
b _080089C0
_080089A8:
movs r3, #0x14
ldrb r3, [r0, r3]
lsrs r3, r3, #1
lsls r3, r3, #1
ldr r4, _08008A7C @ =_0800890C
ldr r4, _08008A7C @ =velocities3
adds r4, r4, r3
movs r3, #0
ldrsb r2, [r4, r3]
adds r3, #1
ldrsb r3, [r4, r3]
bl sub_08008A46
bl AddPlayerVelocity
_080089C0:
ldr r1, _08008A80 @ =gPlayerState
movs r4, #0x8c
movs r2, #8
ldrsh r3, [r1, r4]
ldrsh r3, [r1, r4] // vel_x
orrs r3, r3
beq _080089E4
bpl _080089D2
@@ -585,7 +585,7 @@ _080089D2:
push {r0, r1}
adds r1, r3, #0
push {r2}
bl sub_080027EA
bl LinearMoveDirectionOLD
pop {r0}
bl sub_0807A5B8
pop {r0, r1}
@@ -602,7 +602,7 @@ _080089F4:
push {r0, r1}
adds r1, r3, #0
push {r2}
bl sub_080027EA
bl LinearMoveDirectionOLD
pop {r0}
bl sub_0807A5B8
pop {r0, r1}
@@ -646,18 +646,18 @@ _08008A3E:
beq _08008A3A
b _08008A38
non_word_aligned_thumb_func_start sub_08008A46
sub_08008A46: @ 0x08008A46
non_word_aligned_thumb_func_start AddPlayerVelocity
AddPlayerVelocity: @ 0x08008A46
push {lr}
ldr r1, _08008A84 @ =gPlayerState
movs r4, #0x8c
ldrsh r5, [r1, r4]
ldrsh r5, [r1, r4] // vel_x
adds r5, r5, r2
bl sub_08008A88
movs r4, #0x8e
bl ClampPlayerVelocity
movs r4, #0x8e // vel_y
ldrsh r5, [r1, r4]
adds r5, r5, r3
bl sub_08008A88
bl ClampPlayerVelocity
pop {pc}
_08008A60:
eors r3, r3
@@ -667,14 +667,14 @@ _08008A60:
_08008A68: .4byte gPlayerState
_08008A6C: .4byte gPlayerState
_08008A70: .4byte gPlayerState
_08008A74: .4byte _080088FC
_08008A78: .4byte _080088EC
_08008A7C: .4byte _0800890C
_08008A74: .4byte ice_velocities
_08008A78: .4byte velocities1
_08008A7C: .4byte velocities3
_08008A80: .4byte gPlayerState
_08008A84: .4byte gPlayerState
thumb_func_start sub_08008A88
sub_08008A88: @ 0x08008A88
thumb_func_start ClampPlayerVelocity
ClampPlayerVelocity: @ 0x08008A88
orrs r5, r5
bmi _08008A94
ldr r6, _08008B38 @ =0x00000180
@@ -764,7 +764,7 @@ CheckNEastTile: @ 0x08008B02
tst r0, r1
bne _08008B1E
ldr r1, =gMapVvvToSurfaceType
bl sub_08007DE0
bl ActTileConv
movs r2, #1
cmp r3, #1
beq _08008B20
+55 -47
View File
@@ -4,32 +4,33 @@
.syntax unified
.text
.thumb
.macro transition_tile tile:req, src_layer:req dest_layer:req
.short \tile
.byte \src_layer, \dest_layer
.endm
gUnk_08016984:: @ 08016984
.incbin "code_08016984/gUnk_08016984.bin"
.text
non_word_aligned_thumb_func_start GetNextScriptCommandHalfword
GetNextScriptCommandHalfword: @ 0x08016986
GetNextScriptCommandHalfword::
ldrh r0, [r0]
bx lr
non_word_aligned_thumb_func_start GetNextScriptCommandHalfwordAfterCommandMetadata
GetNextScriptCommandHalfwordAfterCommandMetadata: @ 0x0801698A
GetNextScriptCommandHalfwordAfterCommandMetadata::
ldrh r0, [r0, #2]
bx lr
non_word_aligned_thumb_func_start GetNextScriptCommandWord
GetNextScriptCommandWord: @ 0x0801698E
GetNextScriptCommandWord::
ldrh r1, [r0]
ldrh r0, [r0, #2]
lsls r0, r0, #0x10
orrs r0, r1
bx lr
thumb_func_start GetNextScriptCommandWordAfterCommandMetadata
GetNextScriptCommandWordAfterCommandMetadata: @ 0x08016998
GetNextScriptCommandWordAfterCommandMetadata::
ldrh r1, [r0, #2]
ldrh r0, [r0, #4]
lsls r0, r0, #0x10
@@ -37,17 +38,15 @@ GetNextScriptCommandWordAfterCommandMetadata: @ 0x08016998
bx lr
.align 2, 0
gScreenShakeOffsets::
.byte 0x01, 0xFF, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x01, 0x00
.byte 0xFF, 0x01, 0x00, 0x00, 0x02, 0xFF, 0x01, 0xFE, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x01, 0xFF, 0x02
.byte 0x00, 0x00, 0x01, 0x01, 0x02, 0xFF, 0x02, 0xFE, 0xFE, 0x02, 0xFF, 0x03, 0xFD, 0xFF, 0xFE, 0x01
.byte 0x01, 0xFD, 0xFF, 0xFF, 0x03, 0xFE, 0x02, 0x00, 0x00, 0xFF, 0xFE, 0x03, 0xFD, 0x02, 0xFF, 0x00
.byte 0x00, 0xFD, 0x02, 0x00, 0x00, 0xFF, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02
.byte 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00
.byte 0x00, 0x00, 0x01, 0x00
gShakeOffsets::
.byte 1, -1, 0, 1, 1, 0, 0, 1, -1, -1, 1, 0, -1, 1, 0, 0
.byte 2, -1, 1, -2, 0, -1, -1, 0, -1, 1, -1, 2, 0, 0, 1, 1
.byte 2, -1, 2, -2, -2, 2, -1, 3, -3, -1, -2, 1, 1, -3, -1, -1
.byte 3, -2, 2, 0, 0, -1, -2, 3, -3, 2, -1, 0, 0, -3, 2, 0
.byte 0, -1, 0, -2, 0, -1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1
.byte 2, 0, 1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0, 1, 0
thumb_func_start UpdateSpriteForCollisionLayer
UpdateSpriteForCollisionLayer: @ 0x08016A04
UpdateSpriteForCollisionLayer:: @ 0x08016A04
movs r1, #0x38
ldrb r1, [r0, r1]
lsls r1, r1, #1
@@ -69,8 +68,7 @@ UpdateSpriteForCollisionLayer: @ 0x08016A04
_08016A28:
.byte 0x80, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40
thumb_func_start ResolveCollisionLayer
ResolveCollisionLayer: @ 0x08016A30
ResolveCollisionLayer::
push {r4, r5, lr}
adds r4, r0, #0
movs r5, #0x38
@@ -102,41 +100,51 @@ _08016A64:
bl UpdateSpriteForCollisionLayer
pop {r4, r5, pc}
thumb_func_start sub_08016A6C
sub_08016A6C: @ 0x08016A6C
CheckOnLayerTransition::
push {r4, r5, lr}
adds r4, r0, #0
bl GetVvvAtEntity
add r1, pc, #0x38
_08016A76:
adds r1, #4
ldrh r2, [r1]
bl GetVvvAtEntity // tile under me
adr r1, gTransitionTiles-4
loop:
adds r1, #4 // p += 4
ldrh r2, [r1] // *(u16*)(p)
cmp r2, #0
beq _08016A90
beq not_found
cmp r2, r0
bne _08016A76
bne loop // found the tile under me?
movs r2, #0x38
ldrb r3, [r4, r2]
ldrb r5, [r1, #2]
cmp r3, r5
beq _08016A90
ldrb r5, [r1, #3]
strb r5, [r4, r2]
_08016A90:
ldrb r3, [r4, r2] // collision layer
ldrb r5, [r1, #2] // *(u8*)(p + 2)
cmp r3, r5 // am i on the right later?
beq not_found
ldrb r5, [r1, #3] // *(u8*)(p + 3)
strb r5, [r4, r2] // move to a new layer
not_found:
pop {r4, r5, pc}
.align 2, 0
_08016A94:
.byte 0x2A, 0x00, 0x03, 0x03, 0x2D, 0x00, 0x03, 0x03, 0x2B, 0x00, 0x03, 0x03
.byte 0x2C, 0x00, 0x03, 0x03, 0x4C, 0x00, 0x03, 0x03, 0x4E, 0x00, 0x03, 0x03, 0x4D, 0x00, 0x03, 0x03
.byte 0x4F, 0x00, 0x03, 0x03, 0x0A, 0x00, 0x02, 0x01, 0x09, 0x00, 0x02, 0x01, 0x0C, 0x00, 0x01, 0x02
.byte 0x0B, 0x00, 0x01, 0x02, 0x52, 0x00, 0x03, 0x03, 0x27, 0x00, 0x03, 0x03, 0x26, 0x00, 0x03, 0x03
.byte 0x00, 0x00
non_word_aligned_thumb_func_start sub_08016AD2
sub_08016AD2: @ 0x08016AD2
transition_tile 0x2A, 3, 3
transition_tile 0x2D, 3, 3
transition_tile 0x2B, 3, 3
transition_tile 0x2C, 3, 3
transition_tile 0x4C, 3, 3
transition_tile 0x4E, 3, 3
transition_tile 0x4D, 3, 3
transition_tile 0x4F, 3, 3
gTransitionTiles:
transition_tile 0x0A, 2, 1
transition_tile 0x09, 2, 1
transition_tile 0x0C, 1, 2
transition_tile 0x0B, 1, 2
transition_tile 0x52, 3, 3
transition_tile 0x27, 3, 3
transition_tile 0x26, 3, 3
.short 0x0000
UpdateCollisionLayer::
push {r4, lr}
adds r4, r0, #0
bl sub_08016A6C
bl CheckOnLayerTransition
push {r0}
adds r0, r4, #0
bl UpdateSpriteForCollisionLayer
+29 -31
View File
@@ -66,7 +66,7 @@ SetMetaTile: @ r0 = tile type, r1, = tile position, r2 = layer
strh r0, [r5, r6] @ gMapBottom.mapData[metaTilePos] = metaTile
ldr r6, _0800020C @ =0x00004000
cmp r0, r6
blo _0800019A @ jump if metaTile < 0x4000
blo tile_wrong_type @ jump if metaTile < 0x4000
push {r1, r2}
subs r4, r0, r6 @ r4 = metaTile - 0x4000
ldr r3, _08000210 @ =gMapSpecialMetaTileToVvv
@@ -78,12 +78,12 @@ SetMetaTile: @ r0 = tile type, r1, = tile position, r2 = layer
bl SetCollisionData
pop {r0, r1} @ tilepos, layer
push {r0, r1}
bl DeleteLoadedTileEntity @ DeleteLoadedTileEntity(metaTilePos, layer)
bl UnregisterInteractTile @ DeleteLoadedTileEntity(metaTilePos, layer)
adds r0, r7, #0 @ r0 = oldMetaTile
pop {r1, r2}
bl StoreMetaTileForSpecialTile @ StoreMetaTileForSpecialTile(oldMetaTile, metaTilePos, layer)
bl RegisterInteractTile @ StoreMetaTileForSpecialTile(oldMetaTile, metaTilePos, layer)
pop {r4, r5, r6, r7, pc} @ pop pc results in returning to the calling function
_0800019A:
tile_wrong_type:
adds r3, #4 @ r3 = layer * 8 + 4
ldr r4, [r4, r3]
lsls r0, r0, #1 @ r0 = metaTile * 2
@@ -97,7 +97,7 @@ _0800019A:
lsrs r2, r2, #2 @ r2 = layer
bl SetCollisionData
pop {r0, r1}
bl DeleteLoadedTileEntity
bl UnregisterInteractTile
pop {r4, r5, r6, r7, pc}
.align 2, 0
_080001C0: .4byte gMapBottom+0x6004
@@ -141,34 +141,34 @@ _08000220: .4byte gVvvPtrs
_08000224: .4byte gMapDataPtrs
gMapDataPtrs::
.4byte gMapBottom+0x0004 @ layer 0
.4byte BOTTOM_TILEDATA @ layer 0
gMetatileTypesPtrs::
.4byte gMapBottom+0x5004
.4byte gMapBottom+0x0004 @ layer 1
.4byte gMapBottom+0x5004
.4byte gMapTop+0x0004 @ layer 2
.4byte gMapTop+0x5004
.4byte gMapBottom+0x0004 @ layer 3
.4byte gMapBottom+0x5004
.4byte BOTTOM_METATILETYPES
.4byte BOTTOM_TILEDATA @ layer 1
.4byte BOTTOM_METATILETYPES
.4byte TOP_TILEDATA @ layer 2
.4byte TOP_METATILETYPES
.4byte BOTTOM_TILEDATA @ layer 3
.4byte BOTTOM_METATILETYPES
gCollisionDataPtrs::
.4byte gMapBottom+0x2004 @ layer 0
.4byte gMapBottom+0x2004 @ layer 1
.4byte gMapTop+0x2004 @ layer 2
.4byte gMapBottom+0x2004 @ layer 3
.4byte BOTTOM_COLLISIONDATA @ layer 0
.4byte BOTTOM_COLLISIONDATA @ layer 1
.4byte TOP_COLLISIONDATA @ layer 2
.4byte BOTTOM_COLLISIONDATA @ layer 3
gUnk_08000258:: @ mapDataClone and metatileTypes
.4byte gMapBottom+0x3004 @ layer 0
.4byte gMapBottom+0x5004
.4byte gMapBottom+0x3004 @ layer 1
.4byte gMapBottom+0x5004
.4byte gMapTop+0x3004 @ layer 2
.4byte gMapTop+0x5004
.4byte gMapBottom+0x3004 @ layer 3
.4byte gMapBottom+0x5004
.4byte BOTTOM_TILEDATACLONE @ layer 0
.4byte BOTTOM_METATILETYPES
.4byte BOTTOM_TILEDATACLONE @ layer 1
.4byte BOTTOM_METATILETYPES
.4byte TOP_TILEDATACLONE @ layer 2
.4byte TOP_METATILETYPES
.4byte BOTTOM_TILEDATACLONE @ layer 3
.4byte BOTTOM_METATILETYPES
gVvvPtrs:: @ vvv for layers
.4byte gMapBottom+0xb004 @ layer 0
.4byte gMapBottom+0xb004 @ layer 1
.4byte gMapTop+0xb004 @ layer 2
.4byte gMapBottom+0xb004 @ layer 3
.4byte BOTTOM_UNKDATA3 @ layer 0
.4byte BOTTOM_UNKDATA3 @ layer 1
.4byte TOP_UNKDATA3 @ layer 2
.4byte BOTTOM_UNKDATA3 @ layer 3
@ call 0x80B19CC
@ ========
@@ -365,8 +365,6 @@ GetCollisionDataAtRoomTile: @ 0x080002DC
bx r3
@ call 0x080B1B44
@ ========
@ Unused? Doesn't seem to be called by anything in Ghidra.
thumb_func_start GetCollisionDataAtMetaTilePos
GetCollisionDataAtMetaTilePos: @ 0x080002E0
ldr r3, _0800034C @ =ram_GetCollisionDataAtMetaTilePos