Enhanced Start Line (LE-CODE replica) [Kazuki]
#1
This code will fix the Start Line Bug and support Second KTPT like LE-CODE.It doesn't change anything on regular tracks.
Fishdom Island and MP9 Toad Road are good tracks for testing.
This code uses vector of 0x81683220~0x81683223. Make sure no other codes use that vector.

(NTSC-U)
C27E11E8 0000000C
3d80809c 818c8f28
818c0004 818c0000
a14c000a 816c0010
7d6b5214 7d8c5a14
a16c0004 2c0b0002
41800018 a16c003c
280bffff 4082000c
398c0024 48000008
398c0008 c04c0000
c00c0008 818c0010
3d608168 918b3220
d043019c 60000000
C27E1208 0000000C
3d808168 c02c3220
3d808000 898c5f27
3d40809b 2c0c00ec
614bd728 41820024
2c0c0010 614bc788
41820018 2c0c0054
3d60809a 616bbd68
41820008 614b8f68
816b0000 816b0b90
2c0b0001 40a20008
fc200850 d02301ac
60000000 00000000


(PAL)
C27EAA94 0000000C
3d80809c 818cd6e8
818c0004 818c0000
a14c000a 816c0010
7d6b5214 7d8c5a14
a16c0004 2c0b0002
41800018 a16c003c
280bffff 4082000c
398c0024 48000008
398c0008 c04c0000
c00c0008 818c0010
3d608168 918b3220
d043019c 60000000
C27EAAB4 0000000C
3d808168 c02c3220
3d808000 898c5f27
3d40809b 2c0c00ec
614bd728 41820024
2c0c0010 614bc788
41820018 2c0c0054
3d60809a 616bbd68
41820008 614b8f68
816b0000 816b0b90
2c0b0001 40a20008
fc200850 d02301ac
60000000 00000000


(NTSC-J)
c27ea100 0000000c
3d80809c 818cc748
818c0004 818c0000
a14c000a 816c0010
7d6b5214 7d8c5a14
a16c0004 2c0b0002
41800018 a16c003c
280bffff 4082000c
398c0024 48000008
398c0008 c04c0000
c00c0008 818c0010
3d608168 918b3220
d043019c 60000000
c27ea120 0000000c
3d808168 c02c3220
3d808000 898c5f27
3d40809b 2c0c00ec
614bd728 41820024
2c0c0010 614bc788
41820018 2c0c0054
3d60809a 616bbd68
41820008 614b8f68
816b0000 816b0b90
2c0b0001 40a20008
fc200850 d02301ac
60000000 00000000


(NTSC-K)
C27D8E54 0000000C
3d80809c 818cbd28
818c0004 818c0000
a14c000a 816c0010
7d6b5214 7d8c5a14
a16c0004 2c0b0002
41800018 a16c003c
280bffff 4082000c
398c0024 48000008
398c0008 c04c0000
c00c0008 818c0010
3d608168 918b3220
d043019c 60000000
C27D8E74 0000000C
3d808168 c02c3220
3d808000 898c5f27
3d40809b 2c0c00ec
614bd728 41820024
2c0c0010 614bc788
41820018 2c0c0054
3d60809a 616bbd68
41820008 614b8f68
816b0000 816b0b90
2c0b0001 40a20008
fc200850 d02301ac
60000000 00000000


Code credits: JoshuaMK (CC Tracker), MrBean35000vr (kmp_pointer)

Code:
#Source


#First ASM

#inject at 0x807E11E8 (NTSC-U)
#inject at 0x807EAA94 (PAL)
#inject at 0x807EA100 (NTSC-J)
#inject at 0x807D8E54 (NTSC-K)

.set roty_save,0x81683220

.set region, 'J' #Fill in E, P, J, or K within the quotes for your region when Compiling! Lowercase letters can also be used.

.if    (region == 'E' || region == 'e') # RMCE
    .set kmp_pointer, 0x809B8F28
.elseif (region == 'P' || region == 'p') # RMCP
    .set kmp_pointer, 0x809BD6E8
.elseif (region == 'J' || region == 'j') # RMCJ
    .set kmp_pointer, 0x809BC748
.elseif (region == 'K' || region == 'k') # RMCK
    .set kmp_pointer, 0x809BBD28
.else # Invalid Region
    .abort
.endif

lis r12,kmp_pointer@ha
lwz r12,kmp_pointer@l(r12)
lwz r12,4(r12)
lwz r12,0(r12) #r12 = KMP addr
lhz r10,0xA(r12) #r10 = length of KMP header
lwz r11,0x10(r12) #r11 = KTPT offset
add r11,r11,r10
add r12,r12,r11 #r12 = KTPT addr
lhz r11,4(r12) #check the number of KTPT entries
cmpwi r11,2
blt entry_first
lhz r11,0x3C(r12)
cmplwi r11,0xFFFF #check player index
bne entry_first
addi r12,r12,0x24
b entry_decided
entry_first:
addi r12,r12,8
entry_decided:
lfs f2,0 (r12) #start line X position
lfs f0,8 (r12) #Z position
lwz r12,0x10(r12) #Y rotation
lis r11,roty_save@h
stw r12,roty_save@l(r11)
stfs f2,0x19C (r3) #default instruction

#Second ASM

#inject at 0x807E1208 (NTSC-U)
#inject at 0x807EAAB4 (PAL)
#inject at 0x807EA120 (NTSC-J)
#inject at 0x807D8E74 (NTSC-K)

.set roty_save,0x81683220
lis r12,roty_save@h
lfs f1,roty_save@l(r12)
#The following code is almost a copy of JoshuaMK's "CC Tracker". It checks if it is a mirror or not.
lis r12,0x8000
lbz r12,0x5F27(r12)
lis r10,0x809B
cmpwi r12,236
ori r11,r10,55080
beq- branch1
cmpwi r12,16
ori r11,r10,51080
beq- branch1
cmpwi r12,84
lis r11,-32614
ori r11,r11,48488
beq- branch1
ori r11,r10,36712
branch1:
lwz r11,0(r11)
lwz r11,0xB90(r11)
cmpwi r11,1
bne+ skip_mirror
fneg f1,f1 #If it is a mirror, reverse the Y rotation.
skip_mirror:
stfs f1,0x1AC (r3) #default instruction
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)