Custom Time Trial Rankings [WhatisLoaf]
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
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 region 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. 
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:
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

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

Custom Top 10:
The source code here only includes 1 entry as an example. My optimisation strategy here was to make the compiled code as short as possible for the worst and most common case being 10 entries. This involved cramming all the data together and adding some extra logic at the bottom to extract the data in the correct way. This does mean that for 1 entry it looks kinda silly of course.
li r4, 0 # 0 means friend rankings which means skipping wfc connection
li r12, 1
stw r12, 0x58 (r3) # change to continental rankings (rankings don't show for some reason when it's a friend ranking)
li r12, X # amount of entries
stw r12, 0x60 (r3) # set amount of times to show
mtctr r12
addi r29, r3, 0x64 # r29-r31 are free to use

mflr r11

bl read_data

.space 4
.long 0xGGGGHHHH # millisecond/minute/second/
.llong 0xIIIIIIIIIIIIIIII # mii data / mii name
.llong 0xIIIIIIIIIIIIIIII # mii name
.llong 0xIIIIIIIIIIIIMMMM # mii name / last 2 bytes of mii data
.long 0xIIIIIIII # mii id
.llong 0xIIIIIIIIIIIIIIII # mii data
.llong 0xIIIIIIIIIIIIIIII # mii data
.llong 0xIIIIIIIIJJJJKKLL # mii data / CRC / flag / wheel

mflr r12

# main loop that loops over all entries
# store time
lwzu r31, 0x04 (r12)
sth r31, 0x05 (r29)
stwu r31, 0x08 (r29)

# secondary loop to move all data per entry
li r30, 13
# skip the mac address of the mii data
cmpwi r30, 6
bne+ store_data
addi r29, r29, 0x04
lwzu r31, 0x04 (r12)
stwu r31, 0x04 (r29)
subic. r30, r30, 1
bne+ loop_2

stw r4, 0x00 (r29) # clear last store
srwi r10, r31, 0x10
stw r10, 0x14 (r29) # store CRC
stb r31, 0x1B (r29) # store wheel
sth r31, 0x24 (r29) # store flag
lhz r31, -0x1A (r12)
sth r31, 0x00 (r29)  # store last 2 bytes of mii data
sth r4, -0x1E (r29) # clear last 2 bytes from temp position
addi r29, r29, 0x28 # set address for next iteration

bdnz+ loop_1

mtlr r11

Code created by: WhatisLoaf
Code credits: Anarion (globe position changer & region changer), Vega (globe position database)
WOW I can't wait to try this out.

Forum Jump:

Users browsing this thread: 1 Guest(s)