Latest source in post #5
Here's a rewritten source where I was able to reduce the compiled code by 4 lines by removing the Mii Creator Name + CRC off the end of the Mii data, plus backing up necessary registers in the negative space of the stack frame, and using lmw+stwm to transfer most of the data. Because the Mii Data is altered, you need my Bypass Mii CRC code - https://mkwii.com/showthread.php?tid=1572 As long as the end user also runs that code, then you don't need the Java CRC-CCITT function on your website anymore.
This rewritten source has only been tested with 1 time entry, but it should work with any amount of time entries.
I included a small symbol map of the Time Entry packet if anybody wants to know on what goes where specifically for each entry.
This code is so awesome. Awesome work Loaf!
Here's a rewritten source where I was able to reduce the compiled code by 4 lines by removing the Mii Creator Name + CRC off the end of the Mii data, plus backing up necessary registers in the negative space of the stack frame, and using lmw+stwm to transfer most of the data. Because the Mii Data is altered, you need my Bypass Mii CRC code - https://mkwii.com/showthread.php?tid=1572 As long as the end user also runs that code, then you don't need the Java CRC-CCITT function on your website anymore.
This rewritten source has only been tested with 1 time entry, but it should work with any amount of time entries.
I included a small symbol map of the Time Entry packet if anybody wants to know on what goes where specifically for each entry.
This code is so awesome. Awesome work Loaf!
Code:
#Code creator: WhatIsLoaf
#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), 0x38 amount of space for all the mii data that will be transferred
stmw r18, -0x38 (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) # change to continental rankings (rankings don't show for some reason when it's a friend ranking)
#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 point where the first data needs to be written to (start of Time Entry packet)
addi r11, r3, 0x0068
#Make Mii Data Table
bl read_data
#Note: Garbage values used so source can compile, fill in all values accordingly
.short 0xAAAA #Millisecond
.byte 0xBB #Minute
.byte 0xCC #Second
.llong 0xDDDDDDDDDDDDDDDD #Start of Mii Data
.llong 0xDDDDDDDDDDDDDDDD
.llong 0xDDDDDDDDDDDDDDDD
.llong 0xDDDDDDDDDDDDDDDD
.llong 0xDDDDDDDDDDDDDDDD
.llong 0xDDDDDDDDDDDDDDDD
.llong 0xDDDDDDDDDDDDEEFF #End of Mii Data (does NOT include Creator Name or CRC), then Flag/Country Byte, then Wheel Byte
!!!FYI: For adding more time entries, simply follow the data template above, and append it accordingly!!!
read_data:
mflr r12
#Loop, based on amount of entries
loop:
#Store Time to proper spots in the Time Entry Packet
lwz r18, 0 (r12)
sth r18, 0x1 (r11)
stw r18, 0x4 (r11)
#Copy-paste Mii Data to its spot in the Time Entry Packet
lmw r18, 0x4 (r12)
stmw r18, 0x8 (r11) #This will cause the halfword of flag and wheel bytes to put into part of the mii data where the creator name goes, but it doesn't matter as long as you use the Bypass Mii Data CRC16 Check code.
#Load Flag+Wheel Halfword, store Wheel byte, store Flag byte
lhz r18, 0x3A (r12)
stb r18, 0x57 (r11) #Wheel; 0 = Yes, 1 = No
sth r18, 0x60 (r11) #Flag; use 0xFF to disable flag, State ID is overwritten but it doesn't matter as that data isn't shown for time rankings
#Increment r12 & r11 for next Time Entry (if applicable)
addi r12, r12, 0x3C
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, -0x38 (sp)