Skip to content

Commit 016c966

Browse files
committed
Align save.h with SA1
1 parent 9db0c7c commit 016c966

File tree

2 files changed

+91
-29
lines changed

2 files changed

+91
-29
lines changed

include/constants/zones.h

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,58 @@
11
#ifndef GUARD_ZONES_H
22
#define GUARD_ZONES_H
33

4-
#define ZONE_1 0
5-
#define ZONE_2 1
6-
#define ZONE_3 2
7-
#define ZONE_4 3
8-
#define ZONE_5 4
9-
#define ZONE_6 5
10-
#define ZONE_7 6
11-
#define ZONE_FINAL 7
4+
#define ZONE_1 0
5+
#define ZONE_2 1
6+
#define ZONE_3 2
7+
#define ZONE_4 3
8+
#define ZONE_5 4
9+
#define ZONE_6 5
10+
#define ZONE_7 6
11+
#define ZONE_FINAL 7
12+
#if (GAME >= GAME_SA2)
1213
#define ZONE_UNUSED 8
14+
#endif
1315

14-
#define ACT_1 0
15-
#define ACT_2 1
16+
#define ACT_1 0
17+
#define ACT_2 1
18+
#if (GAME == GAME_SA1)
19+
#define ACT_BOSS ACT_2
20+
#elif (GAME == GAME_SA2)
1621
#define ACT_BOSS 2
1722
#define ACT_UNUSED 3
23+
#elif (GAME == GAME_SA3)
24+
#define ACT_BOSS 7
25+
#endif
1826

27+
#if (GAME == GAME_SA1)
28+
#define ACT_X_ZONE ACT_1
29+
#define ACT_THE_MOON ACT_2
30+
#elif (GAME == GAME_SA2)
1931
#define ACT_XX_FINAL_ZONE ACT_1
2032
#define ACT_TRUE_AREA_53 ACT_2
33+
#endif
2134

22-
#define NUM_COURSE_ZONES 7
23-
#define ACTS_PER_ZONE 3
35+
#if (GAME == GAME_SA1)
36+
#define NUM_COURSE_ZONES 7
37+
#define NUM_TIME_ATTACK_ZONES 6
38+
#define ACTS_PER_ZONE 2
39+
#elif (GAME == GAME_SA2)
40+
#define NUM_COURSE_ZONES 7
41+
#define NUM_TIME_ATTACK_ZONES NUM_COURSE_ZONES
42+
#define ACTS_PER_ZONE 3
43+
#endif
2444
#define ACT_SLOTS_PER_ZONE (ACTS_PER_ZONE + 1)
2545

2646
#define LEVEL_INDEX(zone, act) ((zone)*ACT_SLOTS_PER_ZONE) + (act)
2747
#define ACT_INDEX(lvl) ((lvl) & (ACT_SLOTS_PER_ZONE - 1))
2848

49+
#if (GAME == GAME_SA1)
50+
#define NUM_LEVEL_IDS_SP 14
51+
#define NUM_LEVEL_IDS_MP 4
52+
#define NUM_LEVEL_IDS 18
53+
#elif (GAME == GAME_SA2)
2954
#define NUM_LEVEL_IDS 34
55+
#endif
3056

3157
#define LEVEL_TO_ZONE(level) ((level) >> 2)
3258
// ((((level) / (ACTS_PER_ZONE + 1)) * 2) | ((level) & 1))

include/game/save.h

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,72 @@
1616

1717
#define TIME_RECORDS_PER_COURSE 3
1818

19+
#if (GAME == GAME_SA1)
20+
typedef u8 PlayerNameChar;
21+
typedef u32 TimeRecord;
22+
#elif (GAME == GAME_SA2)
23+
typedef u16 PlayerNameChar;
24+
typedef u16 TimeRecord;
25+
#endif
26+
27+
#if (GAME == GAME_SA1)
28+
struct TimeRecords {
29+
TimeRecord table[NUM_CHARACTERS][NUM_LEVEL_IDS][TIME_RECORDS_PER_COURSE];
30+
};
31+
1932
struct MultiplayerScore {
2033
u32 playerId;
21-
u16 playerName[MAX_PLAYER_NAME_LENGTH];
22-
23-
bool8 slotFilled;
34+
// TODO/NOTE: Only 6 chars are displayed, but the string is treated 8-char wide
35+
PlayerNameChar playerName[MAX_PLAYER_NAME_LENGTH + 2];
2436

2537
u8 wins;
2638
u8 losses;
2739
u8 draws;
2840
};
2941

42+
#define NUM_TIME_RECORD_ROWS (NUM_CHARACTERS * NUM_LEVEL_IDS * TIME_RECORDS_PER_COURSE)
43+
44+
typedef struct SaveGame {
45+
/* 0x000 */ u8 filler0[0x4];
46+
/* 0x004 */ s32 unk4;
47+
/* 0x008 */ u16 unk8[4];
48+
/* 0x010 */ PlayerNameChar playerName[MAX_PLAYER_NAME_LENGTH];
49+
/* 0x016 */ u8 unk16;
50+
/* 0x017 */ u8 unk17;
51+
/* 0x018 */ u8 unk18;
52+
/* 0x019 */ u8 unk19;
53+
/* 0x01A */ u8 language;
54+
/* 0x01B */ u8 unk1B;
55+
/* 0x01C */ u8 unk1C;
56+
/* 0x020 */ struct TimeRecords timeRecords;
57+
/* 0x2AC */ struct MultiplayerScore multiplayerScores[NUM_MULTIPLAYER_SCORES];
58+
/* 0x420 */ u32 unk420;
59+
/* 0x424 */ u8 filler424[0x4];
60+
/* 0x428 */ u32 score;
61+
/* 0x42C */ u8 filler42C[0x4];
62+
} SaveGame; /* 0x430 */
63+
64+
// NOTE: Not a pointer in SA1!
65+
extern struct SaveGame gLoadedSaveGame;
66+
#elif (GAME == GAME_SA2)
3067
struct TimeRecords {
31-
// TODO: s16?
32-
u16 table[NUM_CHARACTERS][NUM_COURSE_ZONES][ACTS_PER_ZONE][TIME_RECORDS_PER_COURSE];
68+
TimeRecord table[NUM_CHARACTERS][NUM_TIME_ATTACK_ZONES][ACTS_PER_ZONE][TIME_RECORDS_PER_COURSE];
3369
};
3470

35-
#define NUM_TIME_RECORD_ROWS (NUM_COURSE_ZONES * ACTS_PER_ZONE * NUM_CHARACTERS * TIME_RECORDS_PER_COURSE)
71+
#define NUM_TIME_RECORD_ROWS (NUM_TIME_ATTACK_ZONES * ACTS_PER_ZONE * NUM_CHARACTERS * TIME_RECORDS_PER_COURSE)
3672

37-
#if (GAME == GAME_SA1)
38-
struct SaveGame {
39-
/* 0x10 */ u16 playerName[MAX_PLAYER_NAME_LENGTH];
40-
/* 0x1A */ u8 language;
73+
struct MultiplayerScore {
74+
u32 playerId;
75+
PlayerNameChar playerName[MAX_PLAYER_NAME_LENGTH];
4176

42-
/* 0x428 */ u32 score;
43-
}
77+
bool8 slotFilled;
4478

45-
// NOTE: Not a pointer in SA1!
46-
extern struct SaveGame gLoadedSaveGame;
47-
#elif (GAME == GAME_SA2)
48-
struct SaveGame {
79+
u8 wins;
80+
u8 losses;
81+
u8 draws;
82+
};
83+
84+
typedef struct SaveGame {
4985
/* 0x000 */ u32 id;
5086

5187
/* 0x004 */ u8 difficultyLevel;
@@ -76,7 +112,7 @@ struct SaveGame {
76112
/* 0x034 */ struct TimeRecords timeRecords;
77113
/* 0x2AC */ struct MultiplayerScore multiplayerScores[NUM_MULTIPLAYER_SCORES];
78114
/* 0x374 */ u32 score;
79-
};
115+
} SaveGame;
80116

81117
extern struct SaveGame *gLoadedSaveGame;
82118
#endif

0 commit comments

Comments
 (0)