Custom Time Trial Rankings [WhatisLoaf]
#1
Custom Time Trial Rankings [WhatisLoaf]

Hey everyone, this code will allow you to create fully custom time trial rankings in the Mario Kart channel.
Since there is a lot of data to fill in I'm not going to post the code here as it changes heavily based on what you fill in.
Instead I've made a tool that generates these codes which you can find at tt-rec.com
I know this is kind of unorthodox but this is the only way to not make it a nightmare to use.
This is my first time making a code for mkw so feel free to give feedback on what can be improved.

I've ported to all regions but only tested PAL and NTSC-U, I suspect the other regions should be fine though.

The code includes Anarion's globe position changer and region changer. For the preprogrammed globe position I used Vega's extensive database of globe positions.
Vega's CRC bypass code is also used which means not having to deal with checksums.
Besides that there are 2 codes: A title changer (that is displayed above the rankings) and the code that fills in the entire top 10, below is the source code for both:

Custom Rankings Title:
Code:
#Address Ports
#NTSC-U = 805C12AC
#PAL = 805CDDCC
#NTSC-J = 805CD6A8
#NTSC-K = 805BBD8C

mflr r11

bl set_address

# the entire string is placed in and can vary in length
# it's important to include 0000 at the end to terminate the string
.long XXXXXXXX

set_address:
cmpwi r14, 0x1776 # message ID for continental rankings title
bne- function_end
mflr r3 # replace the address with our address
stw r3, 0x20(sp)
function_end:
or r3, r21, r21
mtlr r11

Custom Top 10:
The source code here only includes 1 entry as an example. Big thanks to Vega for providing a more easy to read version of the code and shortening it by a few lines.
Code:
#Time Entry Packet Symbol Map
#0x1 (halfword) Milliseconds
#0x4 (word) Minutes, Seconds, then Milliseconds
#0x8 thru 0x53 Entire Mii Data including its CRC16 checksum; 0x4C in size
#0x57 (byte) Controller; 0 - Wheel, 1 - Wiichuck, 2 - Classic, 3 - GCN; useful if you wanna display wheel icon
#0x60 (byte) Country Code, use 0xFF to disable flag or use a country code that normally doesn't have a flag
#0x61 (byte) State Code (location within country), editing this is useless for this code
#0x62 (halfword) Location Code (location within state, this was never implemented/finalized in mkwii); useless to edit

#Address Ports
#NTSC-U = 806414CC
#PAL = 8060BFAC
#NTSC-J = 8060B720
#NTSC-K = 805FA3CC

#Backup Global Variable Registers (r18 thru r31), 0x34 amount of space
stmw r18, -0x34 (sp) #No function calls in code, safe to do

#FYI: LR is already backed up in r0

#Set r4 as 0 (friend rankings) to skip WFC connect
li r4, 0 #Default instruction not needed as r4's value is now set

#Change Byte in memory back to 1 (Regionals); Friend Rankings won't show for some reason
li r12, 1
stw r12, 0x58 (r3)

#Set Amount of Entries (1 thru 10)
li r12, 1 #1 used just for compilation, !!!adjust this for how many time entries will be used in the code!!!
stw r12, 0x60 (r3) # set amount of times to show
mtctr r12

#Set r11 to points to where the first data needs to be written to
addi r11, r3, 0x0068

#Make Mii Data Table
bl read_data

.short 0xDDDD #Millisecond
.byte 0xEE #Minute
.byte 0xEE #Second

#Mii Data from 0x00 to 0x1b
.llong 0xFFFFFFFFFFFFFFFF
.llong 0xFFFFFFFFFFFFFFFF
.llong 0xFFFFFFFFFFFFFFFF
.long 0xFFFFFFFF
#Mii Data from 0x20 to 0x31
.llong 0xFFFFFFFFFFFFFFFF
.llong 0xFFFFFFFFFFFFFFFF
.long 0xFFFFFFFF
.short 0xFFFF

.byte 0xEE #Flag (Country code) Value, use 0xFF to disable flag
.byte 0xEE #Wheel/Not-Wheel Value; 0 = Wheel & 1 = No Wheel

#!!!For more than one entry, add in another set of the data from the template just above!!!

read_data:
mflr r12

#Loop, based on amount of entries
loop:

#Load all data from current time entry to r24 thru r31
lmw r18, 0 (r12)

#Store Time to proper spots in the Time Entry Packet
sth r18, 0x1 (r11)
stw r18, 0x4 (r11)

#Copy-paste first half of Mii Data to its spot in the Time Entry Packet
stmw r19, 0x8 (r11)

#Copy-paste second half of Mii Data to its spot in the Time Entry Packet
stmw r26, 0x28 (r11)

#Store Wheel Bit Value, Store Flag Byte value
stb r31, 0x57 (r11) #Wheel; 0 = Yes, 1 = No
sth r31, 0x60 (r11) #Flag; use 0xFF to disable flag

#Increment r12 & r11 for next Time Entry (if applicable)
addi r12, r12, 0x38
addi r11, r11, 0x68

#Decrement Loop
bdnz+ loop

#Restore LR, already backed up in r0 before code was executed
mtlr r0

#Restore Global Variable Registers (r18 thru r31)
lmw r18, -0x34 (sp)

Code created by: WhatisLoaf
Code credits: Anarion (globe position changer & region changer), Vega (globe position database, CRC Bypass Code)
Reply


Messages In This Thread
Custom Time Trial Rankings [WhatisLoaf] - by WhatisLoaf - 06-23-2020, 08:02 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)