====== Ghost Data ====== Both the ghost data that can be saved on the controller memory pack and the staff course ghost data takes the same format as described here. The ghost data saved to the memory pack is MIO0 compressed. ===== Ghost Data Format ===== 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) | ===== Staff Course Ghosts ===== 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) | 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 from ROM to RAM. ===== References ===== * http://origami64.net/showthread.php?tid=47&pid=3698#pid3698 * https://github.com/SeanSullivan86/MK64