summaryrefslogtreecommitdiff
path: root/include/save_data.h
blob: 2f16ad1f1c7acf0c0ea1a799e8b624a29c3ebb53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef SAVE_DATA_H
#define SAVE_DATA_H

#include <common_structs.h>

typedef struct {
    // 6 little endian 3-byte records.
    // When converted to big endian the bottom 5 nibbles can be interpreted as the centisecond count for that record.
    // The top nibble is the character ID of the charcter used to set that record
    // The first 5 records are the top 5 3-lap records
    // The 6th record is the best 1-lap record
    u8 records[6][3];
    // It's unknown what these bytes are used for
    // Byte 1 might be an indicator that there is a ghost available for that course
    u8 unknownBytes[5];
    u8 checksum;
} CourseTimeTrialRecords; // size = 0x18

typedef struct {
    // Each cup is made up of 4 courses
    CourseTimeTrialRecords courseRecords[4];
} CupTimeTrialRecords; // size = 0x60

typedef struct {
    // There are 4 cups total
    CupTimeTrialRecords cupRecords[4];
} AllCourseTimeTrialRecords; // size = 0x180

typedef struct {
    // Records 0 through 3 are for the first cup's courses
    // Records 4 through 7 are for the second cup's courses
    u8 bestThreelaps[8][3];
    u8 bestSinglelaps[8][3];
    // It's unknown what these bytes are used for
    u8 unknownBytes[8];
} OnlyBestTimeTrialRecords; // size = 0x38

typedef struct {
    // GP Points scored for each CC mode
    // 1st place is 3 points, 2nd is 2, etc.
    // Lowest dibit is the Mushroom Cup, 2nd dibit is the Flower Cup, etc
    u8 grandPrixPoints[4];
    u8 soundMode;
} SaveInfo;

typedef struct {
    SaveInfo saveInfo;
    // It's unknown what the first byte is used for
    u8 checksum[3];
} Stuff; // size = 0x8

typedef struct {
    /* 0x000 */ AllCourseTimeTrialRecords allCourseTimeTrialRecords;
    /* 0x180 */ Stuff main;
    /**
     * For some reason there's 2 entries covering 4 cups
     * Instead of 4 entries, one per cup. Or even just one big entry for all 4 cups
     * Its also unknown why these are here when they're identical to the values found
     * in allCourseTimeTrialRecords
     **/
    /* 0x188 */ OnlyBestTimeTrialRecords onlyBestTimeTrialRecords[2];
    /**
     * If checksum[1] or checksum[2] does not match their expected value,
     * the grandPrixPoints and soundMode are reset. Then if the backup data's
     * checksums are valid, copy the backup data to the main data.
     **/
    /* 0x1F8 */ Stuff backup;
} SaveData; // size = 0x200

extern SaveData gSaveData;

#endif