Skip to content

Commit

Permalink
desync: freeze deadupfall physics position
Browse files Browse the repository at this point in the history
Normally, the fighter's position is centered with the camera by directly
updating the model's position with respect to the camera's view matrix.

However, it also updates the fighter's physics position. This becomes a
problem when screen shake is disabled on one client, as it will cause
the physics position of the fighter being screen ko'd to differ slightly.
This only seems to matter in the case of Ice Climbers, because Nana uses
Popo's physics position to determine her next action.
  • Loading branch information
UnclePunch committed Dec 16, 2021
1 parent 5b90483 commit bdfef2c
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Online/Core/FreezeDeadUpFallPhysics/InitHitVelocity.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
################################################################################
# Address: 0x800d4c1c
################################################################################

.include "Common/Common.s"
.include "Online/Online.s"

# orig instruction
stw r0, 0x2344 (r31)

# init custom velocity
lfs f0, 0x0030 (r30) # y velocity
stfs f0, 0x2348 (r31)
lfs f0, 0x003C (r30) # z velocity
stfs f0, 0x234C (r31)

# zero original velocity
li r3,0
stw r3, 0x80 (r31)
stw r3, 0x84 (r31)
stw r3, 0x88 (r31)

Exit:
45 changes: 45 additions & 0 deletions Online/Core/FreezeDeadUpFallPhysics/UpdateFallVelocity.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
################################################################################
# Address: 0x800d4d68
################################################################################
.include "Common/Common.s"
.include "Online/Online.s"

/*
During DeadUpFall, after the fighter hits the screen

0x2348 = previously used variable, now storing Y velocity
0x234C = previously used variable, now storing Z velocity
0x2350 = position vector
0x235c = temp velocity vector (contents cleared when leaving function so cant use this across frames)
*/

# orig instruction
lfs f1, 0x0034 (r30) # gravity
lfs f2, 0x0038 (r30) # terminal velocity
lfs f3, 0x2348 (r31) # curr Y velocity

# subtract gravity
fsub f3, f3, f1
fneg f2, f2 # negate terminal velocity
fcmpo cr0, f3, f2 # limit velocity
bgt StoreVelocity
# use terminal velocity
fmr f3, f2
StoreVelocity:
stfs f3, 0x2348 (r31)

UpdateVector:
# update Y position
lfs f1, 0x2360 (r31) # y component of temp velocity
lfs f2, 0x2348 (r31) # curr Y velocity
fadds f1,f1,f2
stfs f1, 0x2360 (r31) # y component of temp velocity
# update Z position
lfs f1, 0x234C (r31) # curr Z velocity
lfs f2, 0x2364 (r31) # Z component of temp velocity
fadds f1,f1,f2
stfs f1, 0x2364 (r31) # Z component of temp velocity


Exit:
branch r12,0x800d4d84
40 changes: 40 additions & 0 deletions Online/Core/FreezeDeadUpFallPhysics/UpdateModelPos.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
################################################################################
# Address: 0x80080e80
################################################################################
.include "Common/Common.s"
.include "Online/Online.s"

/*
The fighter's position is centered with the camera by directly
updating the model's position with respect to the camera's view matrix.

However, it also updates the fighter's physics position. This becomes a
problem when screen shake is disabled on one client, as it will cause
the physics position of the fighter being screen ko'd to differ slightly.
This only seems to matter in the case of Ice Climbers, because Nana uses
Popo's physics position to determine her next action.
*/

backup

# update camera mtx and return mtx ptr?
branchl r12,0x800310b8
# get inverted viewing mtx ptr
branchl r12,0x80369808

# mult with position vector
addi r4, r30, 0x2350 # position vector
addi r5, sp, 0x80 # output to temp vector on stack
branchl r12,0x80342aa8

# update model position
lwz r3, 0x80(sp) # vector X
stw r3, 0x38(31) # model X
lwz r3, 0x84(sp) # vector Y
stw r3, 0x3c(31) # model Y
lwz r3, 0x88(sp) # vector Z
stw r3, 0x40(31) # model Z

Exit:
restore
branch r12,0x80080ee4
36 changes: 36 additions & 0 deletions Output/Netplay/GALE01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,42 @@ BA810008 800100B4
800100B4 382100B0
7C0803A6 7FC3F378
60000000 00000000
C20D4C1C 00000005 #Online/Core/FreezeDeadUpFallPhysics/InitHitVelocity.asm
901F2344 C01E0030
D01F2348 C01E003C
D01F234C 38600000
907F0080 907F0084
907F0088 00000000
C20D4D68 0000000B #Online/Core/FreezeDeadUpFallPhysics/UpdateFallVelocity.asm
C03E0034 C05E0038
C07F2348 FC630828
FC401050 FC031040
41810008 FC601090
D07F2348 C03F2360
C05F2348 EC21102A
D03F2360 C03F234C
C05F2364 EC21102A
D03F2364 3D80800D
618C4D84 7D8903A6
4E800420 00000000
C2080E80 00000011 #Online/Core/FreezeDeadUpFallPhysics/UpdateModelPos.asm
7C0802A6 90010004
9421FF50 BE810008
3D808003 618C10B8
7D8903A6 4E800421
3D808036 618C9808
7D8903A6 4E800421
389E2350 38A10080
3D808034 618C2AA8
7D8903A6 4E800421
80610080 907F0038
80610084 907F003C
80610088 907F0040
BA810008 800100B4
382100B0 7C0803A6
3D808008 618C0EE4
7D8903A6 4E800420
60000000 00000000
04019260 48000034 #Online/Core/Hacks/ForceNoDiskCrash.asm
C2376304 0000000B #Online/Core/Hacks/ForceNoVideoAssert.asm
48000031 7C6802A6
Expand Down
36 changes: 36 additions & 0 deletions Output/Netplay/GALJ01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,42 @@ BA810008 800100B4
800100B4 382100B0
7C0803A6 7FC3F378
60000000 00000000
C20D4C1C 00000005 #Online/Core/FreezeDeadUpFallPhysics/InitHitVelocity.asm
901F2344 C01E0030
D01F2348 C01E003C
D01F234C 38600000
907F0080 907F0084
907F0088 00000000
C20D4D68 0000000B #Online/Core/FreezeDeadUpFallPhysics/UpdateFallVelocity.asm
C03E0034 C05E0038
C07F2348 FC630828
FC401050 FC031040
41810008 FC601090
D07F2348 C03F2360
C05F2348 EC21102A
D03F2360 C03F234C
C05F2364 EC21102A
D03F2364 3D80800D
618C4D84 7D8903A6
4E800420 00000000
C2080E80 00000011 #Online/Core/FreezeDeadUpFallPhysics/UpdateModelPos.asm
7C0802A6 90010004
9421FF50 BE810008
3D808003 618C10B8
7D8903A6 4E800421
3D808036 618C9808
7D8903A6 4E800421
389E2350 38A10080
3D808034 618C2AA8
7D8903A6 4E800421
80610080 907F0038
80610084 907F003C
80610088 907F0040
BA810008 800100B4
382100B0 7C0803A6
3D808008 618C0EE4
7D8903A6 4E800420
60000000 00000000
04019260 48000034 #Online/Core/Hacks/ForceNoDiskCrash.asm
C2376304 0000000B #Online/Core/Hacks/ForceNoVideoAssert.asm
48000031 7C6802A6
Expand Down

0 comments on commit bdfef2c

Please sign in to comment.