summaryrefslogtreecommitdiff
path: root/asm/src
diff options
context:
space:
mode:
authortheo3 <arisstephenson2@gmail.com>2023-12-31 21:24:07 -0800
committertheo3 <arisstephenson2@gmail.com>2023-12-31 21:26:12 -0800
commitdcc596ed8763efd9f71ce9a669cb67a1849d7c2b (patch)
tree108145ce0ee3172e48ac6529d9d49da53e9719b9 /asm/src
parent48fdf9d8277d2bd2e071cb30fc6284c58645e343 (diff)
define collisions
Diffstat (limited to 'asm/src')
-rw-r--r--asm/src/intr.s248
1 files changed, 134 insertions, 114 deletions
diff --git a/asm/src/intr.s b/asm/src/intr.s
index c2dab21d..86ec0618 100644
--- a/asm/src/intr.s
+++ b/asm/src/intr.s
@@ -286,77 +286,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
@@ -366,56 +369,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
@@ -428,10 +434,10 @@ _080B1E74:
mov ip, #0
bl arm_CalcCollisionDirection
mov r6, r0
- ldrb r1, [r5, #0x3f] // hitType
+ ldrb r1, [OTHER, #0x3f] // hitType
mov r0, #0x22
mul r1, r0, r1
- ldrb r0, [r4, #0x40] // hurtType
+ ldrb r0, [THIS, #0x40] // hurtType
add r0, r0, r1
mov r1, #0xc
mul r2, r0, r1
@@ -449,106 +455,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