11-10-2020, 09:48 PM
To my surprise, saving/loading brake drifting ghosts was already working. So I started working on CTGP compatibility.
For unknown reasons, braking input sequences are delayed by one frame in the stock game. And since brake drifting was implemented the same way as braking, it way delayed too. But CTGP doesn't do that and handles brake drifting like other inputs. I updated the code above to align with CTGP (only patch 5 had to be changed).
Another difference is that CTGP not only multiplies speed, but also boost acceleration, and standard acceleration, but not drift acceleration (they are separate vehicle/character stats). It also caps max boost speed differently than 150cc. I made a code that reproduces this behavior.
NTSC-U:
048b13b8 40900000
04575600 60000000
c25745fc 00000006
807d0000 80630004
80630004 54630739
40820014 3c603fc0
907d0030 c01d0030
ec200072 d03d0030
60000000 00000000
PAL:
048b5c78 40900000
0457be64 60000000
c257ae60 00000006
807d0000 80630004
80630004 54630739
40820014 3c603fc0
907d0030 c01d0030
ec200072 d03d0030
60000000 00000000
Patch 1: set the boost acceleration to 4.5 (instead of 3.0)
# replace at 808b13b8 (NTSC-U)
# replace at 808b5c78 (PAL)
40900000
Patch 2: remove a branch to always use the same (smaller) speed cap while boosting
# replace at 80575600 (NTSC-U)
# replace at 8057be64 (PAL)
nop
Patch 3: multiply the non-boost acceleration by 1.5 if the player is not drifting
# inject at 805745fc (NTSC-U)
# inject at 8057ae60 (PAL)
lwz r3, 0x0 (r29)
lwz r3, 0x4 (r3)
lwz r3, 0x4 (r3)
rlwinm. r3, r3, 0, 28, 28
bne end
lis r3, 0x3fc0
stw r3, 0x30 (r29)
lfs f0, 0x30 (r29)
fmuls f1, f0, f1
end:
stfs f1, 0x30 (r29)
With this, it is now possible to replay CTGP 200cc ghosts on some tracks like rGV2 and rMC3 with at least millisecond accuracy, but other tracks like TF and rWS are more problematic, even when seemingly not using fast falling. In particular there is a value separate from acceleration that's added to the speed the next few frames after landing, and of course it's sometimes different on CTGP.
For unknown reasons, braking input sequences are delayed by one frame in the stock game. And since brake drifting was implemented the same way as braking, it way delayed too. But CTGP doesn't do that and handles brake drifting like other inputs. I updated the code above to align with CTGP (only patch 5 had to be changed).
Another difference is that CTGP not only multiplies speed, but also boost acceleration, and standard acceleration, but not drift acceleration (they are separate vehicle/character stats). It also caps max boost speed differently than 150cc. I made a code that reproduces this behavior.
NTSC-U:
048b13b8 40900000
04575600 60000000
c25745fc 00000006
807d0000 80630004
80630004 54630739
40820014 3c603fc0
907d0030 c01d0030
ec200072 d03d0030
60000000 00000000
PAL:
048b5c78 40900000
0457be64 60000000
c257ae60 00000006
807d0000 80630004
80630004 54630739
40820014 3c603fc0
907d0030 c01d0030
ec200072 d03d0030
60000000 00000000
Patch 1: set the boost acceleration to 4.5 (instead of 3.0)
# replace at 808b13b8 (NTSC-U)
# replace at 808b5c78 (PAL)
40900000
Patch 2: remove a branch to always use the same (smaller) speed cap while boosting
# replace at 80575600 (NTSC-U)
# replace at 8057be64 (PAL)
nop
Patch 3: multiply the non-boost acceleration by 1.5 if the player is not drifting
# inject at 805745fc (NTSC-U)
# inject at 8057ae60 (PAL)
lwz r3, 0x0 (r29)
lwz r3, 0x4 (r3)
lwz r3, 0x4 (r3)
rlwinm. r3, r3, 0, 28, 28
bne end
lis r3, 0x3fc0
stw r3, 0x30 (r29)
lfs f0, 0x30 (r29)
fmuls f1, f0, f1
end:
stfs f1, 0x30 (r29)
With this, it is now possible to replay CTGP 200cc ghosts on some tracks like rGV2 and rMC3 with at least millisecond accuracy, but other tracks like TF and rWS are more problematic, even when seemingly not using fast falling. In particular there is a value separate from acceleration that's added to the speed the next few frames after landing, and of course it's sometimes different on CTGP.