From e88025b6269714f12d1190beec4f228ee15fe099 Mon Sep 17 00:00:00 2001 From: Jas Laferriere Date: Thu, 21 Sep 2023 04:40:06 -0400 Subject: [PATCH] add bone extraction --- Debugging/BonePositions/Bones.s | 62 ++++++ Debugging/BonePositions/BonesOnGrabbed.s | 39 ++++ Debugging/BonePositions/BonesPostDamage.asm | 31 +++ Debugging/BonePositions/BonesPreDetach.s | 20 ++ .../BonePositions/BonesPreThrowRelease.s | 26 +++ Debugging/HitboxHurtbox/LogCollision.s | 49 +++++ Debugging/HitboxHurtbox/LogDamage.s | 17 ++ External/Balance/Core/Character DAT Patcher.s | 191 ++++++++++++++++++ Output/Netplay/GALE01r2.ini | 94 ++++++--- Output/Netplay/GALJ01r2.ini | 94 ++++++--- Output/Playback/GALE01r2.ini | 86 ++++++++ Output/Playback/GALJ01r2.ini | 86 ++++++++ Recording/Recording.s | 8 +- Recording/SendFrameStart.s | 5 + Recording/SendGameInfo.asm | 6 + Recording/SendGamePostFrame.asm | 61 ++++++ playback.json | 17 ++ 17 files changed, 825 insertions(+), 67 deletions(-) create mode 100644 Debugging/BonePositions/Bones.s create mode 100644 Debugging/BonePositions/BonesOnGrabbed.s create mode 100644 Debugging/BonePositions/BonesPostDamage.asm create mode 100644 Debugging/BonePositions/BonesPreDetach.s create mode 100644 Debugging/BonePositions/BonesPreThrowRelease.s create mode 100644 Debugging/HitboxHurtbox/LogCollision.s create mode 100644 Debugging/HitboxHurtbox/LogDamage.s create mode 100644 External/Balance/Core/Character DAT Patcher.s diff --git a/Debugging/BonePositions/Bones.s b/Debugging/BonePositions/Bones.s new file mode 100644 index 00000000..549d4edc --- /dev/null +++ b/Debugging/BonePositions/Bones.s @@ -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 diff --git a/Debugging/BonePositions/BonesOnGrabbed.s b/Debugging/BonePositions/BonesOnGrabbed.s new file mode 100644 index 00000000..96216262 --- /dev/null +++ b/Debugging/BonePositions/BonesOnGrabbed.s @@ -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 \ No newline at end of file diff --git a/Debugging/BonePositions/BonesPostDamage.asm b/Debugging/BonePositions/BonesPostDamage.asm new file mode 100644 index 00000000..dc5bd629 --- /dev/null +++ b/Debugging/BonePositions/BonesPostDamage.asm @@ -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 \ No newline at end of file diff --git a/Debugging/BonePositions/BonesPreDetach.s b/Debugging/BonePositions/BonesPreDetach.s new file mode 100644 index 00000000..481b7607 --- /dev/null +++ b/Debugging/BonePositions/BonesPreDetach.s @@ -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 \ No newline at end of file diff --git a/Debugging/BonePositions/BonesPreThrowRelease.s b/Debugging/BonePositions/BonesPreThrowRelease.s new file mode 100644 index 00000000..fa51c1a4 --- /dev/null +++ b/Debugging/BonePositions/BonesPreThrowRelease.s @@ -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 \ No newline at end of file diff --git a/Debugging/HitboxHurtbox/LogCollision.s b/Debugging/HitboxHurtbox/LogCollision.s new file mode 100644 index 00000000..d1a4519e --- /dev/null +++ b/Debugging/HitboxHurtbox/LogCollision.s @@ -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: \ No newline at end of file diff --git a/Debugging/HitboxHurtbox/LogDamage.s b/Debugging/HitboxHurtbox/LogDamage.s new file mode 100644 index 00000000..c2522af6 --- /dev/null +++ b/Debugging/HitboxHurtbox/LogDamage.s @@ -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 \ No newline at end of file diff --git a/External/Balance/Core/Character DAT Patcher.s b/External/Balance/Core/Character DAT Patcher.s new file mode 100644 index 00000000..d80e9fd1 --- /dev/null +++ b/External/Balance/Core/Character DAT Patcher.s @@ -0,0 +1,191 @@ +################################################################################ +# Address: 80068f30 +################################################################################ +.include "Common/Common.s" + +backup + +lwz r31,0x10C(r30) +lwz r31,0x8(r31) +subi r31,r31,0x20 +lwz r3,0x0(r29) #get character internal ID +cmpwi r3,0x1b #check if master hand, crazy hand, wireframes, giga or sandbag +bge exit #exit if so + +bl SkipTable +bl diffMario +bl diffFox +bl diffCaptain +bl diffDK +bl diffKirby +bl diffBowser +bl diffLink +bl diffSheik +bl diffNess +bl diffPeach +bl diffPopo +bl diffNana +bl diffPikachu +bl diffSamus +bl diffYoshi +bl diffJigglypuff +bl diffMewtwo +bl diffLuigi +bl diffMarth +bl diffZelda +bl diffYLink +bl diffDoc +bl diffFalco +bl diffPichu +bl diffGaW +bl diffGanon +bl diffRoy + +SkipTable: +mflr r4 #Jump Table Start in r4 +mulli r3,r3,0x4 #Each Pointer is 0x4 Long +add r4,r4,r3 #Get Event's Pointer Address +lwz r5,0x0(r4) #Get bl Instruction +rlwinm r5,r5,0,6,29 #Mask Bits 6-29 (the offset) +add r5,r4,r5 #Gets Address in r4 + +################ +## Patch Loop ## +################ + +continue: +patchLoop: +lwz r3,0x0(r5) +lwz r4,0x4(r5) + +cmpwi r3,0xFF +beq endPatchLoop + +add r3,r3,r31 +stw r4,0x0(r3) +addi r5,r5,0x8 +b patchLoop + +endPatchLoop: +b exit + + +################# +## DIFF TABLES ## +################# +diffMario: + +.long 0x000000FF + +diffFox: + +.long 0x000000FF + +diffCaptain: + +.long 0x000000FF + +diffDK: + +.long 0x000000FF + +diffKirby: + +.long 0x000000FF + +diffBowser: + +.long 0x000000FF + +diffLink: + +.long 0x000000FF + +diffSheik: + +.long 0x000000FF + +diffNess: + +.long 0x000000FF + +diffPeach: + +.long 0x000000FF + +diffPopo: + +.long 0x000000FF + +diffNana: + +.long 0x000000FF + + +diffPikachu: + +.long 0x000000FF + +diffSamus: + +.long 0x000000FF + +diffYoshi: + +.long 0x000000FF + +diffJigglypuff: + +.long 0x00003914 +.long 0x00000003 # Number of Jumps +.long 0x000000FF + +diffMewtwo: + +.long 0x000000FF + +diffLuigi: + +.long 0x000000FF + +diffMarth: + +.long 0x000000FF + +diffZelda: + +.long 0x000000FF + +diffYLink: + +.long 0x000000FF + +diffDoc: + +.long 0x000000FF + +diffFalco: + +.long 0x000000FF + +diffPichu: + +.long 0x000000FF + +diffGaW: + +.long 0x000000FF + +diffGanon: + +.long 0x000000FF + +diffRoy: + +.long 0x000000FF + +exit: +restore + +original: +lis r3, 0x803C diff --git a/Output/Netplay/GALE01r2.ini b/Output/Netplay/GALE01r2.ini index 62972ab1..77c2d215 100644 --- a/Output/Netplay/GALE01r2.ini +++ b/Output/Netplay/GALE01r2.ini @@ -635,19 +635,19 @@ C216D884 00000030 #Recording/SendGameEnd.asm BA8100B0 800100E4 382100E0 7C0803A6 819F2514 00000000 -C216E74C 0000010A #Recording/SendGameInfo.asm +C216E74C 0000010F #Recording/SendGameInfo.asm 7C0802A6 90010004 9421FF20 BE8100B0 3D808000 618C5604 7D8903A6 4E800421 -2C030000 41820814 +2C030000 4182083C 38600005 3D808037 618CF1E4 7D8903A6 4E800421 7C7B1B78 936DB64C 38800005 3D808000 618CC160 7D8903A6 4E800421 -38600770 3D808037 +386034A0 3D808037 618CF1E4 7D8903A6 4E800421 7C7E1B78 93DB0000 38600000 @@ -657,7 +657,7 @@ C216E74C 0000010A #Recording/SendGameInfo.asm 3D808000 618C55FC 7D8903A6 4E800421 7C7C1B78 38600035 -987E0000 3860001C +987E0000 3860001F 987E0001 38600036 987E0002 386002F8 B07E0003 38600037 @@ -676,16 +676,18 @@ B07E0015 3860003D 987E0017 B39E0018 38600010 987E001A 38600204 B07E001B -38600036 987E001D -3C600310 60630000 -907E001E 387E0022 +38600060 987E001D +386005A5 B07E001E +38600036 987E0020 +3C600310 606300FF +907E0021 387E0025 7FE4FB78 38A00138 3D808000 618C31F4 7D8903A6 4E800421 -387E0062 3880001C +387E0065 3880001C 3D808000 618CC160 7D8903A6 4E800421 -387E0022 3AA30060 +387E0025 3AA30060 3A800000 1ED40024 7ED6AA14 88760001 2C030000 40820034 @@ -696,7 +698,7 @@ B07E0015 3860003D 546005EF 4182000C 38600013 98760000 3A940001 2C140004 -4180FFB4 387E0022 +4180FFB4 387E0025 3AA30060 3A800000 1ED40024 7ED6AA14 88760001 2C030000 @@ -708,14 +710,14 @@ B07E0015 3860003D 98760003 3A940001 2C140004 4180FFBC 3C60804D 80635F90 -907E015A 3A82F228 -3AA00000 3ADE015E +907E015D 3A82F228 +3AA00000 3ADE0161 1EF50008 38600001 7C76B92E 3AF70004 7C76B92E 3AB50001 2C150004 4180FFE4 3A800000 3ABF0060 -3AFE017E 1F140010 +3AFE0181 1F140010 7F18BA14 1ED40024 7ED6AA14 88760001 2C030000 40820040 @@ -731,10 +733,10 @@ B07E0015 3860003D 618CC160 7D8903A6 4E800421 3A940001 2C140004 4180FF88 -8862F234 987E01BE -8862F23C 987E01BF +8862F234 987E01C1 +8862F23C 987E01C2 3C608048 80639D30 -5463443E B07E01C0 +5463443E B07E01C3 3B200000 3C608048 80639D30 5463443E 2C030208 4082017C @@ -742,7 +744,7 @@ B07E0015 3860003D 618C5610 7D8903A6 4E800421 7C791B78 3A800000 3ABF0060 -3AFE01C2 3B590034 +3AFE01C5 3B590034 1C74001F 7F03BA14 1ED40024 7ED6AA14 88760001 2C030000 @@ -756,7 +758,7 @@ B07E0015 3860003D 7D8903A6 4E800421 3A940001 2C140004 4180FFA0 3A800000 -3ABF0060 3AFE023E +3ABF0060 3AFE0241 3B5900CF 1C74000A 7F03BA14 1ED40024 7ED6AA14 88760001 @@ -771,7 +773,7 @@ B07E0015 3860003D 4E800421 3A940001 2C140004 4180FFA0 3A800000 3ABF0060 -3AFE0266 3B5900F7 +3AFE0269 3B5900F7 1C74001D 7F03BA14 1ED40024 7ED6AA14 88760001 2C030000 @@ -785,28 +787,28 @@ B07E0015 3860003D 7D8903A6 4E800421 3A940001 2C140004 4180FFA0 4800001C -387E01C2 38800118 +387E01C5 38800118 3D808000 618CC160 7D8903A6 4E800421 3D808000 618CADF4 7D8903A6 4E800421 -987E02DA 2C190000 -41820044 387E02DB +987E02DD 2C190000 +41820044 387E02DE 38990394 38A00033 3D808000 618C31F4 7D8903A6 4E800421 3C60803D 6063AD40 80630000 81830088 -A06C0001 907E030E -886C0006 907E0312 -4800001C 387E02DB +A06C0001 907E0311 +886C0006 907E0315 +4800001C 387E02DE 3880003B 3D808000 618CC160 7D8903A6 4E800421 2C190000 41820018 7F23CB78 3D808037 618CF1B0 7D8903A6 4E800421 -7FC3F378 38800316 +7FC3F378 38800319 38A00001 3D808000 618C55F0 7D8903A6 4E800421 38600205 @@ -840,12 +842,15 @@ B0750201 38600000 48000021 7C8802A6 38A00000 3D808038 618CFD54 7D8903A6 -4E800421 48000070 +4E800421 48000088 4E800021 7C0802A6 90010004 9421FF20 BE8100B0 806DB64C 83A30000 838DB650 -7FBDE214 3860003A +7FBDE214 7FA3EB78 +388034A0 3D808000 +618CC160 7D8903A6 +4E800421 3860003A 987D0000 806DB654 907D0001 3C60804D 80635F90 907D0005 @@ -902,14 +907,14 @@ A07C0DA8 B07F002B BA8100B0 800100E4 382100E0 7C0803A6 3C608017 00000000 -C206DA34 00000038 #Recording/SendGamePostFrame.asm +C206DA34 00000051 #Recording/SendGamePostFrame.asm 7C0802A6 90010004 9421FF20 BE8100B0 3D808000 618C5604 7D8903A6 4E800421 -2C030000 41820180 +2C030000 41820248 887F221F 546306F7 -40820174 8B7F000C +4082023C 8B7F000C 806DB64C 83A30000 838DB650 7FBDE214 38600038 987D0000 @@ -955,7 +960,32 @@ B07D0030 887F1968 A07F18EC B07D0051 A07F2088 B07D0053 838DB650 3B9C0055 -938DB650 BA8100B0 +938DB650 806DB64C +83A30000 7C9DE214 +38600060 98640000 +806DB654 90640001 +9B640005 387C0006 +906DB650 3B9C05A6 +4800002D 7C8802A6 +807F0000 80630028 +38A00000 3D808036 +618CF0F0 7D8903A6 +4E800421 938DB650 +48000074 4E800021 +7C0802A6 90010004 +9421FF20 BE8100B0 +38800000 38A10008 +3D808000 618CB1CC +7D8903A6 4E800421 +838DB650 806DB64C +83A30000 7C9DE214 +80610008 90640000 +8061000C 90640004 +80610010 90640008 +3B9C000C 938DB650 +BA8100B0 800100E4 +382100E0 7C0803A6 +4E800020 BA8100B0 800100E4 382100E0 7C0803A6 8001001C 60000000 00000000 diff --git a/Output/Netplay/GALJ01r2.ini b/Output/Netplay/GALJ01r2.ini index d4f4dfa2..5cd4e21e 100644 --- a/Output/Netplay/GALJ01r2.ini +++ b/Output/Netplay/GALJ01r2.ini @@ -634,19 +634,19 @@ C216D884 00000030 #Recording/SendGameEnd.asm BA8100B0 800100E4 382100E0 7C0803A6 819F2514 00000000 -C216E74C 0000010A #Recording/SendGameInfo.asm +C216E74C 0000010F #Recording/SendGameInfo.asm 7C0802A6 90010004 9421FF20 BE8100B0 3D808000 618C5604 7D8903A6 4E800421 -2C030000 41820814 +2C030000 4182083C 38600005 3D808037 618CF1E4 7D8903A6 4E800421 7C7B1B78 936DB64C 38800005 3D808000 618CC160 7D8903A6 4E800421 -38600770 3D808037 +386034A0 3D808037 618CF1E4 7D8903A6 4E800421 7C7E1B78 93DB0000 38600000 @@ -656,7 +656,7 @@ C216E74C 0000010A #Recording/SendGameInfo.asm 3D808000 618C55FC 7D8903A6 4E800421 7C7C1B78 38600035 -987E0000 3860001C +987E0000 3860001F 987E0001 38600036 987E0002 386002F8 B07E0003 38600037 @@ -675,16 +675,18 @@ B07E0015 3860003D 987E0017 B39E0018 38600010 987E001A 38600204 B07E001B -38600036 987E001D -3C600310 60630000 -907E001E 387E0022 +38600060 987E001D +386005A5 B07E001E +38600036 987E0020 +3C600310 606300FF +907E0021 387E0025 7FE4FB78 38A00138 3D808000 618C31F4 7D8903A6 4E800421 -387E0062 3880001C +387E0065 3880001C 3D808000 618CC160 7D8903A6 4E800421 -387E0022 3AA30060 +387E0025 3AA30060 3A800000 1ED40024 7ED6AA14 88760001 2C030000 40820034 @@ -695,7 +697,7 @@ B07E0015 3860003D 546005EF 4182000C 38600013 98760000 3A940001 2C140004 -4180FFB4 387E0022 +4180FFB4 387E0025 3AA30060 3A800000 1ED40024 7ED6AA14 88760001 2C030000 @@ -707,14 +709,14 @@ B07E0015 3860003D 98760003 3A940001 2C140004 4180FFBC 3C60804D 80635F90 -907E015A 3A82F228 -3AA00000 3ADE015E +907E015D 3A82F228 +3AA00000 3ADE0161 1EF50008 38600001 7C76B92E 3AF70004 7C76B92E 3AB50001 2C150004 4180FFE4 3A800000 3ABF0060 -3AFE017E 1F140010 +3AFE0181 1F140010 7F18BA14 1ED40024 7ED6AA14 88760001 2C030000 40820040 @@ -730,10 +732,10 @@ B07E0015 3860003D 618CC160 7D8903A6 4E800421 3A940001 2C140004 4180FF88 -8862F234 987E01BE -8862F23C 987E01BF +8862F234 987E01C1 +8862F23C 987E01C2 3C608048 80639D30 -5463443E B07E01C0 +5463443E B07E01C3 3B200000 3C608048 80639D30 5463443E 2C030208 4082017C @@ -741,7 +743,7 @@ B07E0015 3860003D 618C5610 7D8903A6 4E800421 7C791B78 3A800000 3ABF0060 -3AFE01C2 3B590034 +3AFE01C5 3B590034 1C74001F 7F03BA14 1ED40024 7ED6AA14 88760001 2C030000 @@ -755,7 +757,7 @@ B07E0015 3860003D 7D8903A6 4E800421 3A940001 2C140004 4180FFA0 3A800000 -3ABF0060 3AFE023E +3ABF0060 3AFE0241 3B5900CF 1C74000A 7F03BA14 1ED40024 7ED6AA14 88760001 @@ -770,7 +772,7 @@ B07E0015 3860003D 4E800421 3A940001 2C140004 4180FFA0 3A800000 3ABF0060 -3AFE0266 3B5900F7 +3AFE0269 3B5900F7 1C74001D 7F03BA14 1ED40024 7ED6AA14 88760001 2C030000 @@ -784,28 +786,28 @@ B07E0015 3860003D 7D8903A6 4E800421 3A940001 2C140004 4180FFA0 4800001C -387E01C2 38800118 +387E01C5 38800118 3D808000 618CC160 7D8903A6 4E800421 3D808000 618CADF4 7D8903A6 4E800421 -987E02DA 2C190000 -41820044 387E02DB +987E02DD 2C190000 +41820044 387E02DE 38990394 38A00033 3D808000 618C31F4 7D8903A6 4E800421 3C60803D 6063AD40 80630000 81830088 -A06C0001 907E030E -886C0006 907E0312 -4800001C 387E02DB +A06C0001 907E0311 +886C0006 907E0315 +4800001C 387E02DE 3880003B 3D808000 618CC160 7D8903A6 4E800421 2C190000 41820018 7F23CB78 3D808037 618CF1B0 7D8903A6 4E800421 -7FC3F378 38800316 +7FC3F378 38800319 38A00001 3D808000 618C55F0 7D8903A6 4E800421 38600205 @@ -839,12 +841,15 @@ B0750201 38600000 48000021 7C8802A6 38A00000 3D808038 618CFD54 7D8903A6 -4E800421 48000070 +4E800421 48000088 4E800021 7C0802A6 90010004 9421FF20 BE8100B0 806DB64C 83A30000 838DB650 -7FBDE214 3860003A +7FBDE214 7FA3EB78 +388034A0 3D808000 +618CC160 7D8903A6 +4E800421 3860003A 987D0000 806DB654 907D0001 3C60804D 80635F90 907D0005 @@ -901,14 +906,14 @@ A07C0DA8 B07F002B BA8100B0 800100E4 382100E0 7C0803A6 3C608017 00000000 -C206DA34 00000038 #Recording/SendGamePostFrame.asm +C206DA34 00000051 #Recording/SendGamePostFrame.asm 7C0802A6 90010004 9421FF20 BE8100B0 3D808000 618C5604 7D8903A6 4E800421 -2C030000 41820180 +2C030000 41820248 887F221F 546306F7 -40820174 8B7F000C +4082023C 8B7F000C 806DB64C 83A30000 838DB650 7FBDE214 38600038 987D0000 @@ -954,7 +959,32 @@ B07D0030 887F1968 A07F18EC B07D0051 A07F2088 B07D0053 838DB650 3B9C0055 -938DB650 BA8100B0 +938DB650 806DB64C +83A30000 7C9DE214 +38600060 98640000 +806DB654 90640001 +9B640005 387C0006 +906DB650 3B9C05A6 +4800002D 7C8802A6 +807F0000 80630028 +38A00000 3D808036 +618CF0F0 7D8903A6 +4E800421 938DB650 +48000074 4E800021 +7C0802A6 90010004 +9421FF20 BE8100B0 +38800000 38A10008 +3D808000 618CB1CC +7D8903A6 4E800421 +838DB650 806DB64C +83A30000 7C9DE214 +80610008 90640000 +8061000C 90640004 +80610010 90640008 +3B9C000C 938DB650 +BA8100B0 800100E4 +382100E0 7C0803A6 +4E800020 BA8100B0 800100E4 382100E0 7C0803A6 8001001C 60000000 00000000 diff --git a/Output/Playback/GALE01r2.ini b/Output/Playback/GALE01r2.ini index bad30343..516a8348 100644 --- a/Output/Playback/GALE01r2.ini +++ b/Output/Playback/GALE01r2.ini @@ -1148,3 +1148,89 @@ C21CBB90 00000005 #Lagless FoD 04390838 60000000 041CD250 60000000 041CCDCC 480000B4 + +$Debugging: Print Bones [Fizzi] +*Prints bone positions +C206D990 00000052 #Debugging/BonePositions/BonesPostDamage.asm +887E000C 2C030000 +4082027C 7C0802A6 +90010004 9421FF20 +BE8100B0 C03E2174 +C05E2178 C07E217C +48000024 4E800021 +426F6E65 20322041 +6E696D3A 20282566 +2C202566 2C202566 +29000000 7C0802A6 +90010004 9421FF00 +BC610008 60000000 +60000000 60000000 +60000000 60000000 +60000000 806DAFC4 +38630003 4BFFFFB1 +7C8802A6 4CC63242 +3D808032 618C3CF4 +7D8903A6 4E800421 +806DAFC4 388000D0 +98830000 38800000 +98830001 38800003 +98830002 38800080 +38A00001 3D808000 +618C55F0 7D8903A6 +4E800421 B8610008 +80010104 38210100 +7C0803A6 7FE3FB78 +48000019 BA8100B0 +800100E4 382100E0 +7C0803A6 48000190 +7C0802A6 90010004 +9421FF20 BE8100B0 +38800000 90810008 +48000035 7C8802A6 +80630028 38A10008 +3D808036 618CF0F0 +7D8903A6 4E800421 +BA8100B0 800100E4 +382100E0 7C0803A6 +4E800020 4E800021 +7C0802A6 90010004 +9421FF20 BE8100B0 +7C9B2378 7C7C1B78 +7F83E378 38800000 +38A10008 3D808000 +618CB1CC 7D8903A6 +4E800421 80ADB654 +80DB0000 7F87E378 +C0210008 C041000C +C0610010 48000040 +4E800021 5B25645D +205B426F 6E65506F +73546872 6F776E5D +20496478 3A202564 +20283078 2578292C +20506F73 3A202825 +662C2025 662C2025 +66290000 7C0802A6 +90010004 9421FF00 +BC610008 60000000 +60000000 60000000 +60000000 60000000 +60000000 806DAFC4 +38630003 4BFFFF95 +7C8802A6 4CC63242 +3D808032 618C3CF4 +7D8903A6 4E800421 +806DAFC4 388000D0 +98830000 38800000 +98830001 38800003 +98830002 38800080 +38A00001 3D808000 +618C55F0 7D8903A6 +4E800421 B8610008 +80010104 38210100 +7C0803A6 807B0000 +38630001 907B0000 +BA8100B0 800100E4 +382100E0 7C0803A6 +4E800020 BB210034 +60000000 00000000 diff --git a/Output/Playback/GALJ01r2.ini b/Output/Playback/GALJ01r2.ini index d3d3f783..483357ad 100644 --- a/Output/Playback/GALJ01r2.ini +++ b/Output/Playback/GALJ01r2.ini @@ -1147,3 +1147,89 @@ C21CBB90 00000005 #Lagless FoD 04390838 60000000 041CD250 60000000 041CCDCC 480000B4 + +$Debugging: Print Bones [Fizzi] +*Prints bone positions +C206D990 00000052 #Debugging/BonePositions/BonesPostDamage.asm +887E000C 2C030000 +4082027C 7C0802A6 +90010004 9421FF20 +BE8100B0 C03E2174 +C05E2178 C07E217C +48000024 4E800021 +426F6E65 20322041 +6E696D3A 20282566 +2C202566 2C202566 +29000000 7C0802A6 +90010004 9421FF00 +BC610008 60000000 +60000000 60000000 +60000000 60000000 +60000000 806DAFC4 +38630003 4BFFFFB1 +7C8802A6 4CC63242 +3D808032 618C3CF4 +7D8903A6 4E800421 +806DAFC4 388000D0 +98830000 38800000 +98830001 38800003 +98830002 38800080 +38A00001 3D808000 +618C55F0 7D8903A6 +4E800421 B8610008 +80010104 38210100 +7C0803A6 7FE3FB78 +48000019 BA8100B0 +800100E4 382100E0 +7C0803A6 48000190 +7C0802A6 90010004 +9421FF20 BE8100B0 +38800000 90810008 +48000035 7C8802A6 +80630028 38A10008 +3D808036 618CF0F0 +7D8903A6 4E800421 +BA8100B0 800100E4 +382100E0 7C0803A6 +4E800020 4E800021 +7C0802A6 90010004 +9421FF20 BE8100B0 +7C9B2378 7C7C1B78 +7F83E378 38800000 +38A10008 3D808000 +618CB1CC 7D8903A6 +4E800421 80ADB654 +80DB0000 7F87E378 +C0210008 C041000C +C0610010 48000040 +4E800021 5B25645D +205B426F 6E65506F +73546872 6F776E5D +20496478 3A202564 +20283078 2578292C +20506F73 3A202825 +662C2025 662C2025 +66290000 7C0802A6 +90010004 9421FF00 +BC610008 60000000 +60000000 60000000 +60000000 60000000 +60000000 806DAFC4 +38630003 4BFFFF95 +7C8802A6 4CC63242 +3D808032 618C3CF4 +7D8903A6 4E800421 +806DAFC4 388000D0 +98830000 38800000 +98830001 38800003 +98830002 38800080 +38A00001 3D808000 +618C55F0 7D8903A6 +4E800421 B8610008 +80010104 38210100 +7C0803A6 807B0000 +38630001 907B0000 +BA8100B0 800100E4 +382100E0 7C0803A6 +4E800020 BB210034 +60000000 00000000 diff --git a/Recording/Recording.s b/Recording/Recording.s index 494aa713..d8bbac87 100644 --- a/Recording/Recording.s +++ b/Recording/Recording.s @@ -22,7 +22,8 @@ .set CMD_ITEM, 0x3B .set CMD_FRAME_BOOKEND, 0x3C .set CMD_GAME_END, 0x39 -.set COMMAND_COUNT, 10 # number of possible commands +.set CMD_BONES, 0x60 +.set COMMAND_COUNT, 11 # number of possible commands ################################################################################ # Payload lengths @@ -36,6 +37,7 @@ .set GAME_FRAME_BOOKEND_PAYLOAD_LENGTH, 8 # byte count .set GAME_END_PAYLOAD_LENGTH, GAME_END_TXB_SIZE - 1 # byte count .set SPLIT_MESSAGE_PAYLOAD_LENGTH, 516 # byte count +.set BONES_PAYLOAD_LENGTH, (120 * 12) + 5 # byte count. hopefully nobody ever has more than 120 bones. each bone has X, Y, Z .set SPLIT_MESSAGE_INTERNAL_DATA_LEN, 512 @@ -57,7 +59,7 @@ .set SUPPORTED_PORTS, 4 .set MAX_CHARACTERS, SUPPORTED_PORTS * 2 # ICs .set TOTAL_FRAME_START_LEN, GAME_FRAME_START_PAYLOAD_LENGTH + 1 -.set TOTAL_CHAR_FRAME_LEN, MAX_CHARACTERS * (GAME_PRE_FRAME_PAYLOAD_LENGTH + 1) + MAX_CHARACTERS * (GAME_POST_FRAME_PAYLOAD_LENGTH + 1) +.set TOTAL_CHAR_FRAME_LEN, MAX_CHARACTERS * (GAME_PRE_FRAME_PAYLOAD_LENGTH + 1) + MAX_CHARACTERS * (GAME_POST_FRAME_PAYLOAD_LENGTH + 1) + MAX_CHARACTERS * (BONES_PAYLOAD_LENGTH + 1) .set TOTAL_ITEM_LEN, MAX_ITEMS * (GAME_ITEM_INFO_PAYLOAD_LENGTH + 1) .set TOTAL_FRAME_BOOKEND_LEN, GAME_FRAME_BOOKEND_PAYLOAD_LENGTH + 1 .set TOTAL_GAME_END_LEN, GAME_END_PAYLOAD_LENGTH + 1 @@ -66,7 +68,7 @@ # build version number. Each byte is one digit # any change in command data should result in a minor version change # current version: 3.16.0 -.set CURRENT_VERSION,0x03100000 +.set CURRENT_VERSION,0x031000FF ################################################################################ # Static Function Locations diff --git a/Recording/SendFrameStart.s b/Recording/SendFrameStart.s index e0eeedb8..7bd4b057 100644 --- a/Recording/SendFrameStart.s +++ b/Recording/SendFrameStart.s @@ -45,6 +45,11 @@ backup lwz REG_BufferOffset,bufferOffset(r13) add REG_Buffer,REG_Buffer,REG_BufferOffset +# zero out the buffer + mr r3, REG_Buffer + li r4, FULL_FRAME_DATA_BUF_LENGTH + branchl r12, Zero_AreaLength + # initial RNG command byte li r3, CMD_INITIAL_RNG stb r3,0x0(REG_Buffer) diff --git a/Recording/SendGameInfo.asm b/Recording/SendGameInfo.asm index 7e645817..30e40df0 100644 --- a/Recording/SendGameInfo.asm +++ b/Recording/SendGameInfo.asm @@ -122,6 +122,12 @@ backup li r3, SPLIT_MESSAGE_PAYLOAD_LENGTH sth r3, CommandSizesStart+0x1B(REG_Buffer) +# bone extract message command + li r3, CMD_BONES + stb r3, CommandSizesStart+0x1D(REG_Buffer) + li r3, BONES_PAYLOAD_LENGTH + sth r3, CommandSizesStart+0x1E(REG_Buffer) + #------------- BEGIN GAME INFO COMMAND ------------- # game information message type .set GameInfoCommandStart, (CommandSizesStart + CommandSizesLength) diff --git a/Recording/SendGamePostFrame.asm b/Recording/SendGamePostFrame.asm index 9accd4c9..d2978c3b 100644 --- a/Recording/SendGamePostFrame.asm +++ b/Recording/SendGamePostFrame.asm @@ -165,6 +165,67 @@ backup addi REG_BufferOffset,REG_BufferOffset,(GAME_POST_FRAME_PAYLOAD_LENGTH+1) stw REG_BufferOffset,bufferOffset(r13) +################################################################################ +# Extract bone positions +################################################################################ + +# First let's write the command and player index +lwz r3, primaryDataBuffer(r13) +lwz REG_Buffer, RDB_TXB_ADDRESS(r3) +add r4, REG_Buffer, REG_BufferOffset # Write position +li r3, CMD_BONES +stb r3, 0x0(r4) # Write command +lwz r3, frameIndex(r13) +stw r3, 0x1(r4) # Write frame index +stb REG_PlayerSlot, 0x5(r4) # Write player index + +# Increment the buffer offset to skip past the command, frame index, and player index +addi r3, REG_BufferOffset, 0x6 +stw r3, bufferOffset(r13) + +# We are going to overwrite the offset after saving all the bones. This will make sure we reserved the fixed length for bones +addi REG_BufferOffset, REG_BufferOffset, (BONES_PAYLOAD_LENGTH+1) + +bl FN_StoreBonePos_BLRL +mflr r4 +lwz r3, 0x0(REG_PlayerData) # Get Entity from CharData +lwz r3, 0x28(r3) # Get Root JObj from Entity +li r5, 0 # no context +branchl r12, 0x8036f0f0 # HSD_JObjWalkTree + +# Update the write offset. The padding should all be zero'd because the whole buffer is zero'd in SendFrameStart +stw REG_BufferOffset, bufferOffset(r13) + +b Injection_Exit + +FN_StoreBonePos_BLRL: +blrl +backup + +# Do this first because r3 is already set to the JObj ptr +li r4, 0 +addi r5, sp, BKP_FREE_SPACE_OFFSET +branchl r12, 0x8000b1cc # GetEntityPosition + +lwz REG_BufferOffset,bufferOffset(r13) +lwz r3, primaryDataBuffer(r13) +lwz REG_Buffer, RDB_TXB_ADDRESS(r3) +add r4, REG_Buffer, REG_BufferOffset # Write position + +lwz r3, BKP_FREE_SPACE_OFFSET(sp) # Get posX +stw r3, 0x0(r4) +lwz r3, BKP_FREE_SPACE_OFFSET+4(sp) # Get posY +stw r3, 0x4(r4) +lwz r3, BKP_FREE_SPACE_OFFSET+8(sp) # Get posZ +stw r3, 0x8(r4) + +# Update the write offset for the next bone +addi REG_BufferOffset, REG_BufferOffset, 0xC +stw REG_BufferOffset, bufferOffset(r13) + +restore +blr + Injection_Exit: restore lwz r0, 0x001C (sp) diff --git a/playback.json b/playback.json index 0adf8a71..7873c055 100644 --- a/playback.json +++ b/playback.json @@ -280,6 +280,23 @@ "annotation": "Lagless FoD" } ] + }, + { + "name": "Debugging: Print Bones", + "authors": [ + "Fizzi" + ], + "description": [ + "Prints bone positions" + ], + "build": [ + { + "type": "injectFolder", + "sourceFolder": "Debugging/BonePositions", + "isRecursive": true, + "annotation": "Print Bones" + } + ] } ] } \ No newline at end of file