Skip to content

Commit

Permalink
add bone extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Sep 21, 2023
1 parent 676c8a0 commit e88025b
Show file tree
Hide file tree
Showing 17 changed files with 825 additions and 67 deletions.
62 changes: 62 additions & 0 deletions Debugging/BonePositions/Bones.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.ifndef HEADER_BONES

.macro FunctionBody_PrintFighterBones
backup

# Prepare callback context to keep track of count
li r4, 0
stw r4, BKP_FREE_SPACE_OFFSET(sp)

bl 8f # FN_LogJObjPosition_BLRL
mflr r4
lwz r3, 0x28(r3) # Get Root JObj from Entity
addi r5, sp, BKP_FREE_SPACE_OFFSET
branchl r12, 0x8036f0f0 # HSD_JObjWalkTree

restore
blr

8: # FN_LogJObjPosition_BLRL:
blrl
backup

mr r27, r4 # Ptr to iteration count
mr r28, r3 # Store JObj address

# TEMP: Only print first 3 bones
# lwz r3, 0(r27)
# cmpwi r3, 3
# bgt 9f # FN_LogJObjPosition_EXIT

mr r3, r28
li r4, 0
addi r5, sp, BKP_FREE_SPACE_OFFSET
branchl r12, 0x8000b1cc # GetEntityPosition

lwz r5, frameIndex(r13)
lwz r6, 0(r27)
mr r7, r28
lfs f1, BKP_FREE_SPACE_OFFSET(sp) # Get posX
lfs f2, BKP_FREE_SPACE_OFFSET+4(sp) # Get posY
lfs f3, BKP_FREE_SPACE_OFFSET+8(sp) # Get posZ
logf LOG_LEVEL_WARN, "[%d] [BonePosThrown] Idx: %d (0x%x), Pos: (%f, %f, %f)"
# logf LOG_LEVEL_WARN, "[%d] [BonePosThrown] %f, %f, %f"

# TEMP: Print anim translation
# lfs f1, 0x38(r28)
# lfs f2, 0x3c(r28)
# lfs f3, 0x40(r28)
# logf LOG_LEVEL_WARN, "Anim: (%f, %f, %f)"

# Increment count
lwz r3, 0(r27)
addi r3, r3, 1
stw r3, 0(r27)

9: # FN_LogJObjPosition_EXIT:
restore
blr
.endm

.endif
.set HEADER_BONES, 1
39 changes: 39 additions & 0 deletions Debugging/BonePositions/BonesOnGrabbed.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
################################################################################
# Address: 0x800db040
################################################################################

.include "Common/Common.s"

backup

li r27, 0

LOOP:
# Load linked player entity address
lwz r3, 0x2c(r30) # char data for main fighter
lwz r3, 0x1a58(r3) # linked fighter entity (grabber)
mr r4, r27
branchl r12, 0x80086630 # BoneId -> Jobj Address
mr r28, r3 # Move jobj address to r28
li r4, 0
addi r5, sp, BKP_FREE_SPACE_OFFSET
branchl r12, 0x8000b1cc # GetEntityPosition

lwz r5, frameIndex(r13)
mr r6, r27
lfs f1, 44(r28) # Get scaleX
lfs f2, 48(r28) # Get scaleY
lfs f3, 52(r28) # Get scaleZ
lfs f4, BKP_FREE_SPACE_OFFSET(sp) # Get posX
lfs f5, BKP_FREE_SPACE_OFFSET+4(sp) # Get posY
lfs f6, BKP_FREE_SPACE_OFFSET+8(sp) # Get posZ
logf LOG_LEVEL_WARN, "[%d] [BonePosThrown] Idx: %d, Scale: (%f, %f, %f), Pos: (%f, %f, %f)"

addi r27, r27, 1
cmpwi r27, 89 # Marth bone count
ble LOOP

restore

EXIT:
addi r3, r31, 0 # Replaced
31 changes: 31 additions & 0 deletions Debugging/BonePositions/BonesPostDamage.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
################################################################################
# Address: 0x8006d990
################################################################################

.include "Common/Common.s"
.include "Debugging/BonePositions/Bones.s"

# Only run for P1
lbz r3, 0xC(r30)
cmpwi r3, 0
bne EXIT

backup

# Print the bone 2 translations
lfs f1, 0x2174(r30)
lfs f2, 0x2178(r30)
lfs f3, 0x217C(r30)
logf LOG_LEVEL_WARN, "Bone 2 Anim: (%f, %f, %f)"

mr r3, r31 # fighter entitity
bl FN_PrintFighterBones

restore
b EXIT

FN_PrintFighterBones:
FunctionBody_PrintFighterBones

EXIT:
lmw r25, 0x0034 (sp) # replaced
20 changes: 20 additions & 0 deletions Debugging/BonePositions/BonesPreDetach.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
################################################################################
# Address: 0x800ddf94
################################################################################

.include "Common/Common.s"
.include "Debugging/BonePositions/Bones.s"

backup

lwz r3, 0(r27) # fighter entitity
bl FN_PrintFighterBones

restore
b EXIT

FN_PrintFighterBones:
FunctionBody_PrintFighterBones

EXIT:
addi r3, r27, 0
26 changes: 26 additions & 0 deletions Debugging/BonePositions/BonesPreThrowRelease.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
################################################################################
# Address: 0x800de1ac
################################################################################

.include "Common/Common.s"
.include "Debugging/BonePositions/Bones.s"

backup

# Print the bone 2 translations
lfs f1, 0x2174(r27)
lfs f2, 0x2178(r27)
lfs f3, 0x217C(r27)
logf LOG_LEVEL_WARN, "Bone 2 Anim: (%f, %f, %f)"

lwz r3, 0(r27) # fighter entitity
bl FN_PrintFighterBones

restore
b EXIT

FN_PrintFighterBones:
FunctionBody_PrintFighterBones

EXIT:
mr r3, r27 # replaced
49 changes: 49 additions & 0 deletions Debugging/HitboxHurtbox/LogCollision.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
################################################################################
# Address: 0x80008210
################################################################################

.include "Common/Common.s"

# Call replaced function, this function returns 1 if the hitbox collides with the hurtbox
branchl r12, 0x80006e58 # Hitbox_CalculateHitboxCollisionWithHurtbox

# r30 -> hitboxData
# r31 -> hurtboxData

# Log out position information before worrying about the collision
addi r12, r30, 0x4c # hitboxData->base
lfs f1, 0(r12)
lfs f2, 4(r12)
lfs f3, 8(r12)
addi r12, r30, 0x58 # hitboxData->tip
lfs f4, 0(r12)
lfs f5, 4(r12)
lfs f6, 8(r12)
logf LOG_LEVEL_WARN, "[HitboxCheck] Base: (%f, %f, %f) Tip: (%f, %f, %f)"

addi r12, r31, 0x28 # hurtboxData->base
lfs f1, 0(r12)
lfs f2, 4(r12)
lfs f3, 8(r12)
addi r12, r31, 0x34 # hurtboxData->tip
lfs f4, 0(r12)
lfs f5, 4(r12)
lfs f6, 8(r12)
lwz r5, 64(r31) # hurtboxData->boneId
logf LOG_LEVEL_WARN, "[HurtboxCheck] Bone: %d Base: (%f, %f, %f) Tip: (%f, %f, %f)"

cmpwi r3, 0
beq EXIT

lwz r5, 64(r31) # hurtboxData->boneId
logf LOG_LEVEL_NOTICE, "Hitbox P? (Id ?) -> Hurtbox P? (Bone %d) | HitboxBone: ?"

lwz r5, 8(r30) # hitboxData->damage
lwz r6, 32(r30) # hitboxData->angle
lfs f1, 28(r30) # hitboxData->size
lfs f2, 16(r30) # hitboxData->x
lfs f3, 20(r30) # hitboxData->y
lfs f4, 24(r30) # hitboxData->z
logf LOG_LEVEL_NOTICE, "HitboxDetails. Damage: %d, Angle: %d, Size: %f, Offset: (%f, %f, %f)"

EXIT:
17 changes: 17 additions & 0 deletions Debugging/HitboxHurtbox/LogDamage.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
################################################################################
# Address: 0x8008e258
################################################################################

.include "Common/Common.s"

lfs f1, 0x186C(r29) # Damage?
fmr f2, f30 # Damage. TODO: Truncate/Cast?
fmr f3, f28
fmr f4, f29
logf LOG_LEVEL_NOTICE, "Damage details. Damage: %f, Stun: %f, KB: %f, Angle: %f, Direction: ?"

mr r5, r31
logf LOG_LEVEL_NOTICE, "Damage animation: 0x%X"

# Replaced codeline
mr r3, r24
Loading

0 comments on commit e88025b

Please sign in to comment.