I have some information about the format and storage of ghost data and staff ghosts. Both the ghost data that can be saved on the controller memory pack and the staff ghost data takes the same format as described below, with exception that the memory pack one is MIO0 compressed. The storage format is 4-bytes per entry, defined by:
[BB] [FF] [YY] [XX]
Field | Description |
BB | Button state: 0x80 = A 0x40 = B 0x20 = Z 0x10 = R Bits 0-3 are unknown |
FF | # Frames controller in this state - 1 |
YY | Analog stick Y (signed byte) |
XX | Analog stick X (signed byte) |
There doesn't seem to be any termination sequence in the memory pack saved data, but the staff ghost data always ends with
00 00 00 00
SeanSullivan86's MK64 ghost data project was a great help in decoding these values.
The staff ghost data for Luigi, Mario, and Royal Raceways are stored in ROM at the locations in the table below. These data DMA'd to RAM at 0x802D2B80, although it always copies 0x4000 bytes even though they are each less than 0x2000 bytes long.
Track | ROM Offset | Seg. Addr. | Length | Time |
Luigi Raceway | 0x63F11C | 0x0F4F9CAC | 0x1058 | 0x2BC1 (1'52"00) |
Mario Raceway | 0x63E280 | 0x0F4F8E10 | 0x0E9C | 0x2329 (1'30"00) |
Royal Raceway | 0x640174 | 0x0F4FAD04 | 0x1DCC | 0x3E81 (2'40"00) |
As an example, I took a silly run on Luigi's Raceway with Luigi and saved it to memory pack, MIO0 decompressed it and copied it over the entries at
0x63F11C
. Luigi course ghost is pretty good at spin hopping:
This means that we could probably collect a few memory pack ghost saves from the Luigi, Mario, and Royal Raceways in krom's 1500cc and replace the staff ghost data with them. Although, we still need to figure out how to scale back the boosts before the jump on Royal Raceway first.
Edit: The offsets for these tables and the minimum times are hard-coded in the assembly. The function at 80005040 looks at the current course and if 0, 7, or 8 (Mario, Royal, Luigi) it compares the course record time and if less than max, assigns values to RAM. The function at 80004EF0 performs the actual DMA copy of the staff course ghost data then.
Wiki article:
https://wiki.origami64.net/mario_kart_64/ghost_data