MKDS MT charging [vabold, Gaberboo]
#1
PAL
c2578088 00000002
b3df0254 9bdf00ca
60000000 00000000
0657ee50 00000080
a80300fc 2c000003
4c800020 80830000
80840004 80040014
54000739 4c820020
3ca0808b c0040088
c0255ccc fc400850
80a300cc 2c85ffff
ff010040 ff820040
41860010 41990020
4d9d0020 4800000c
419c0014 4d980020
38000001 980300ca
4e800020 88a300ca
2c050000 4d820020
a8a300fc 38a50001
b0a300fc 4bffffe0
NTSC-U
c2571824 00000002
b3df0254 9bdf00ca
60000000 00000000
065785ec 00000080
a80300fc 2c000003
4c800020 80830000
80840004 80040014
54000739 4c820020
3ca0808b c0040088
c025140c fc400850
80a300cc 2c85ffff
ff010040 ff820040
41860010 41990020
4d9d0020 4800000c
419c0014 4d980020
38000001 980300ca
4e800020 88a300ca
2c050000 4d820020
a8a300fc 38a50001
b0a300fc 4bffffe0
NTSC-J
c2577a08 00000002
b3df0254 9bdf00ca
60000000 00000000
0657ee50 00000080
a80300fc 2c000003
4c800020 80830000
80840004 80040014
54000739 4c820020
3ca0808b c0040088
c0254e2c fc400850
80a300cc 2c85ffff
ff010040 ff820040
41860010 41990020
4d9d0020 4800000c
419c0014 4d980020
38000001 980300ca
4e800020 88a300ca
2c050000 4d820020
a8a300fc 38a50001
b0a300fc 4bffffe0
NTSC-K
c25660e0 00000002
b3df0254 9bdf00ca
60000000 00000000
0656cea8 00000080
a80300fc 2c000003
4c800020 80830000
80840004 80040014
54000739 4c820020
3ca0808a c0040088
c0254144 fc400850
80a300cc 2c85ffff
ff010040 ff820040
41860010 41990020
4d9d0020 4800000c
419c0014 4d980020
38000001 980300ca
4e800020 88a300ca
2c050000 4d820020
a8a300fc 38a50001
b0a300fc 4bffffe0

Code:
# inject at 0x80578088 (PAL)
# inject at 0x80571824 (NTSC-U)
# inject at 0x80577a08 (NTSC-J)
# inject at 0x805660e0 (NTSC-K)

sth       r30, 0x254(r31)
stb       r30, 0xCA(r31) # set our fields to a predictable value

# replace at 8057ee50 (PAL)
# replace at 805785ec (NTSC-U)
# replace at 8057e7d0 (NTSC-J)
# replace at 8056cea8 (NTSC-K)

.set region, 'P'

.if (region == 'P')
    .set STICK_CHARGE_THRESHOLD, 0x808b5ccc
.elseif (region == 'E')
    .set STICK_CHARGE_THRESHOLD, 0x808b140c
.elseif (region == 'J')
    .set STICK_CHARGE_THRESHOLD, 0x808b4e2c
.elseif (region == 'K')
    .set STICK_CHARGE_THRESHOLD, 0x808a4144
.else
    .err
.endif
# r0 = 0
# r3 = KartMove
# r4 = KartState
# f0 = KartState::stickX
# f1 = STICK_CHARGE_THRESHOLD
# f2 = -STICK_CHARGE_THRESHOLD
# cr1 = KartMove::hopStickX compared to -1
# cr6 = f1 compared to f0
# cr7 = f2 compared to f0

# exit if SMT is already charged
lha r0, 0xfc (r3)
cmpwi r0, 0x3
bgelr

# exit if player is remote
lwz r4, 0x0 (r3)
lwz r4, 0x4 (r4)
lwz r0, 0x14 (r4)
rlwinm. r0, r0, 0x0, 0x1c, 0x1c
bnelr
# r0 is always zero after this point

# load important variables, check directions
lis r5, STICK_CHARGE_THRESHOLD@ha
lfs f0, 0x88 (r4)
lfs f1, STICK_CHARGE_THRESHOLD@l (r5)
fneg f2, f1
lwz r5, 0xcc (r3)
cmpwi cr1, r5, -0x1
fcmpo cr6, f1, f0
fcmpo cr7, f2, f0
beq cr1,calcLeft

calcRight:
bgt cr6, calcDriftState
bgtlr cr7
b applyOpposite

calcLeft:
blt cr7, calcDriftState
bltlr cr6

# if the stick is in the opposite threshold, set field 0xca of KartMove to true
applyOpposite:
li r0, 1
setAndReturn:
stb r0, 0xca (r3)
blr

# if the stick has been in the opposite threshold and is in the correct threshold, update drift state
calcDriftState:
lbz r5, 0xca (r3)
cmpwi r5, 0
beqlr
lha r5, 0xfc (r3)
addi r5, r5, 0x1
sth r5, 0xfc (r3)
# r0 = 0
b setAndReturn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)