NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_mj2d_data.hpp
Go to the documentation of this file.
1#pragma once
2#include <types.h>
5
6#define SAVE_VERSION 14
7#define SAVE_SUB_VERSION 0
8
9class dSaveMng_c;
10
16 public:
18
19 void initialize();
20
23 u16 getFreeModePlayCount(int world, int level) const;
24
27 void setFreeModePlayCount(int world, int level, u16 count);
28
31 u16 getCoinBattlePlayCount(int world, int level) const;
32
35 void setCoinBattlePlayCount(int world, int level, u16 count);
36
39 void setMultiModeCompletion(int world);
40
43 bool getMultiModeCompletion(int world) const;
44
45private:
47 void versionUpdate();
48 void setSelectFileNo(s8 file);
49
50 char mMagic[4];
51 u8 mVersion[2];
54
57 u16 mFreeModePlayCount[WORLD_COUNT][STAGE_COUNT];
58
61 u16 mCoinBattlePlayCount[WORLD_COUNT][STAGE_COUNT];
62
68
70
74 static char sSaveMagic[4];
75
76 friend class dSaveMng_c;
77};
78
84public:
85
92 GOAL_NORMAL = 0x10,
93 GOAL_SECRET = 0x20,
94 GOAL_MASK = GOAL_NORMAL | GOAL_SECRET,
97 SUPER_GUIDE_GOAL_MASK = SUPER_GUIDE_GOAL_NORMAL | SUPER_GUIDE_GOAL_SECRET
98 };
99
102 WORLD_UNLOCKED = 0x1
103 };
104
109 GOAL_ALL = 0x4,
110 COIN_ALL = 0x8,
114 };
115
119 TOAD_HOUSE_NONE,
120 TOAD_HOUSE_YELLOW,
121 TOAD_HOUSE_RED,
122 TOAD_HOUSE_GREEN,
123 TOAD_HOUSE_YELLOW_R,
124 TOAD_HOUSE_RED_R,
125 TOAD_HOUSE_GREEN_R
126 };
127
129 dMj2dGame_c();
130
133
134 void initialize();
135
136 void setPlrID(int player, int character);
137 int getPlrID(int player) const;
138
139 void setPlrMode(int player, u8 powerup);
140 int getPlrMode(int player) const;
141
142 void setRest(int player, u8 lives);
143 int getRest(int player) const;
144
147 void setCreateItem(int player, u8 flag);
148
151 int getCreateItem(int player) const;
152
153 void setCoin(int player, s8 coins);
154 s8 getCoin(int player) const;
155
156 void setScore(ulong score);
157 int getScore() const;
158
159 void setStaffCreditHighScore(u16 score);
160 int getStaffCreditHighScore() const;
161
163 void onOtehonMenuOpenFlag(int movie);
164
166 bool isOtehonMenuOpenFlag(int movie) const;
167
170 void setCollectCoin(int world, int level, u8 coins);
171
173 int getTotalWorldCollectCoin(int world);
174
176 u8 isCollectCoin(int world, int level, int coin) const;
177
179 void setStartKinokoKind(int world, u8 type);
180
182 int getStartKinokoKind(int world) const;
183
191 void setDeathCount(int world, int level, bool isSwitchPressed, u8 count);
192
200 int getDeathCount(int world, int level, bool isSwitchPressed) const;
201
202 void setContinue(int player, s8 continues);
203 s8 getContinue(int player) const;
204
205 void setStockItem(int item, s8 count);
206 inline s8 getStockItem(int item) { return mStockItemCount[item]; }; // [why was this inlined?]
207
209 u8 isWorldDataFlag(int world, u8 flag) const;
210
212 void onWorldDataFlag(int world, u8 flag);
213
215 void offWorldDataFlag(int world, u8 flag);
216
218 bool isCourseDataFlag(int world, int level, ulong flag) const;
219
221 void onCourseDataFlag(int world, int level, ulong flag);
222
224 void offCourseDataFlag(int world, int level, ulong flag);
225
227 int getCourseDataFlag(int world, int level) const;
228
230 void setCSEnemyRevivalCnt(int world, int enemy, int count);
231
233 u8 getCSEnemyRevivalCnt(int world, int enemy) const;
234
236 void setCSEnemySceneNo(int world, int enemy, u8 subworld);
237
239 u8 getCSEnemySceneNo(int world, int enemy) const;
240
242 void setCSEnemyPosIndex(int world, int enemy, u8 node);
243
245 u8 getCSEnemyPosIndex(int world, int enemy) const;
246
250 void setCSEnemyWalkDir(int world, int enemy, u8 direction);
251
253 u8 getCSEnemyWalkDir(int world, int enemy) const;
254
256 void setKinopioCourseNo(int world, int level);
257 u8 getKinopioCourseNo(int world) const;
258
259 void setIbaraNow(int ibaraNow);
260 u8 getIbaraNow() const;
261
262private:
264 void versionUpdate();
265
267 void setSwitchDeathCount(u8 count);
268
270 int getSwitchDeathCount() const;
271
272 u8 mVersion[2];
273
275
279
283
286
287 u8 mStockItemCount[POWERUP_COUNT];
288
290 u8 mStartKinokoType[WORLD_COUNT];
291
292 u8 mPlayerContinue[PLAYER_COUNT];
293 s8 mPlayerCoin[PLAYER_COUNT];
294 u8 mPlayerLife[PLAYER_COUNT];
295 u8 mPlayerCreateItem[PLAYER_COUNT];
296 u8 mPlayerCharacter[PLAYER_COUNT];
297 u8 mPlayerPowerup[PLAYER_COUNT];
298
299 u8 mWorldCompletion[WORLD_COUNT];
301
304 u32 mScore;
305
307 u32 mStageCompletion[WORLD_COUNT][STAGE_COUNT];
309 u8 mKinopioCourseNo[WORLD_COUNT];
310
314
317 u8 mDeathCount[WORLD_COUNT][STAGE_COUNT];
319
320 u8 pad[0x13]; // [Aligns the data to 32]
322
325 static const u32 sDefaultCharacters[4];
326
327 friend class dSaveMng_c;
328};
Save slot data holder.
u8 getCSEnemyPosIndex(int world, int enemy) const
Gets the path node for the given map enemy.
GAME_COMPLETION_e
The overall completion status of the save slot.
@ FINAL_BOSS_BEATEN
The final boss was beaten.
@ COIN_ALL
All the Star Coins in the regular worlds were obtained.
@ GAME_COMPLETED
All the above objectives were completed.
@ SUPER_GUIDE_TRIGGERED
The player died at least SUPER_GUIDE_DEATH_COUNT times in a single stage.
@ GOAL_ALL
All levels were completed.
@ COIN_ALL_SPECIAL
All the Star Coins in the special worlds were obtained.
@ SAVE_EMPTY
The save file is empty.
int getSwitchDeathCount() const
Gets the death count for World 3-4 for the worldmap switch-enabled variant.
s8 getContinue(int player) const
Gets player 's continue count.
u8 mIbaraNow
The worldmap vine reshuffle counter.
u32 mStageCompletion[WORLD_COUNT][STAGE_COUNT]
The completion flags for each level. See COURSE_COMPLETION_e.
WORLD_COMPLETION_e
The completion status of each world.
int getStartKinokoKind(int world) const
Gets the starting Toad House type in the given world. See START_KINOKO_KIND_e.
void offCourseDataFlag(int world, int level, ulong flag)
Unsets the completion flag(s) for the given world/level. See COURSE_COMPLETION_e.
u16 mUnknown64
[Unused].
u8 mSwitchOn
The status of the worldmap switch.
void setScore(ulong score)
Sets the score.
u8 mEnemySceneNo[WORLD_COUNT][AMBUSH_ENEMY_COUNT]
The subworld number for each map enemy.
void setSwitchDeathCount(u8 count)
Sets the death count for World 3-4 for the worldmap switch-enabled variant.
void setStockItem(int item, s8 count)
Sets the inventory amount for the given item.
u8 mPlayerContinue[PLAYER_COUNT]
The continue count for each player.
void setCSEnemySceneNo(int world, int enemy, u8 subworld)
Sets the subworld number for the given map enemy.
bool mOtehonMenuOpen[HINT_MOVIE_COUNT]
The hint movie bought status for each movie.
u8 getCSEnemySceneNo(int world, int enemy) const
Gets the subworld number for the given map enemy.
u16 mStaffRollHighScore
The staff credits high score.
u8 mPlayerCreateItem[PLAYER_COUNT]
The Star Power flag for each player. See PLAYER_CREATE_ITEM_e.
u8 getCSEnemyWalkDir(int world, int enemy) const
Gets the path direction for the given map enemy.
void setContinue(int player, s8 continues)
Sets player 's continue count.
void setPlrID(int player, int character)
Sets player 's character. See PLAYER_CHARACTER_e.
u8 mEnemyRevivalCount[WORLD_COUNT][AMBUSH_ENEMY_COUNT]
The revival counter for each map enemy.
void initialize()
Initializes the slot data.
u8 mPlayerPowerup[PLAYER_COUNT]
The powerup for each player. See PLAYER_POWERUP_e.
void onCourseDataFlag(int world, int level, ulong flag)
Sets the completion flag(s) for the given world/level. See COURSE_COMPLETION_e.
START_KINOKO_KIND_e
The Toad House types at the start node of each world.
u8 getCSEnemyRevivalCnt(int world, int enemy) const
Gets the revival counter for the given map enemy.
void setRest(int player, u8 lives)
Sets player 's life count.
int getRest(int player) const
Gets player 's life count.
void setStaffCreditHighScore(u16 score)
Sets the staff credit high score.
u32 mScore
The regular score.
u8 isWorldDataFlag(int world, u8 flag) const
Checks if the completion flag(s) for the given world is set. See WORLD_COMPLETION_e.
void setDeathCount(int world, int level, bool isSwitchPressed, u8 count)
Sets the death count in a specific stage.
u8 mStockItemCount[POWERUP_COUNT]
The inventory amount for each item.
u8 mDeathCount[WORLD_COUNT][STAGE_COUNT]
The death count for each level.
void setIbaraNow(int ibaraNow)
Sets the worldmap vine reshuffle counter.
void setCSEnemyPosIndex(int world, int enemy, u8 node)
Sets the path node for the given map enemy.
void setStartKinokoKind(int world, u8 type)
Sets the starting Toad House type in the given world. See START_KINOKO_KIND_e.
u8 mCurrentPathNode
The path node the player is currently on.
u8 mGameCompletion
The overall completion of the save slot. See GAME_COMPLETION_e.
u8 mEnemyWalkDir[WORLD_COUNT][AMBUSH_ENEMY_COUNT]
The movement direction for each map enemy.
int getCourseDataFlag(int world, int level) const
Gets all the completion flags for the given world/level. See COURSE_COMPLETION_e.
COURSE_COMPLETION_e
The completion status of each level.
@ SUPER_GUIDE_GOAL_NORMAL
The regular exit was cleared with the Super Guide.
@ GOAL_NORMAL
The regular exit was cleared.
@ GOAL_SECRET
The secret exit was cleared.
@ COIN1_COLLECTED
The first Star Coin was obtained.
@ COIN3_COLLECTED
The third Star Coin was obtained.
@ SUPER_GUIDE_GOAL_SECRET
The secret exit was cleared with the Super Guide.
@ COIN2_COLLECTED
The second Star Coin was obtained.
int getDeathCount(int world, int level, bool isSwitchPressed) const
Gets the death count in a specific stage.
void setPlrMode(int player, u8 powerup)
Sets player 's powerup. See PLAYER_POWERUP_e.
void setCSEnemyRevivalCnt(int world, int enemy, int count)
Sets the revival counter for the given map enemy.
int getScore() const
Gets the score.
u8 isCollectCoin(int world, int level, int coin) const
Checks if the given Star Coin has been obtained in the given world/level.
u32 mChecksum
The CRC32 checksum of the above data.
int getPlrID(int player) const
Gets player 's character. See PLAYER_CHARACTER_e.
void setCreateItem(int player, u8 flag)
Sets player 's createItem flag. See PLAYER_CREATE_ITEM_e.
u8 mPlayerCharacter[PLAYER_COUNT]
The character for each player. See PLAYER_CHARACTER_e.
void setCollectCoin(int world, int level, u8 coins)
Sets the obtained Star Coin(s) for the given world/level. See COURSE_COMPLETION_e.
u8 mPlayerLife[PLAYER_COUNT]
The life count for each player.
void versionUpdate()
Checks that the save data version matches the current one and clears the slot if not.
bool isCourseDataFlag(int world, int level, ulong flag) const
Checks if the completion flag for the given world/level is set. See COURSE_COMPLETION_e.
void offWorldDataFlag(int world, u8 flag)
Unsets the specified flag(s) for the given world. See WORLD_COMPLETION_e.
int getPlrMode(int player) const
Gets player 's powerup. See PLAYER_POWERUP_e.
u8 mUnknown8
[Unused].
u8 mDeathCountSwitch
The death count for the worldmap switch variant of World 3-4. See mDeathCount.
u8 mCurrentSubWorld
The subworld the player is currently in.
void onOtehonMenuOpenFlag(int movie)
Sets the given hint movie as bought.
bool isOtehonMenuOpenFlag(int movie) const
Checks if the given hint movie was bought.
~dMj2dGame_c()
Deletes the holder.
void onWorldDataFlag(int world, u8 flag)
Sets the specified flag(s) for the given world. See WORLD_COMPLETION_e.
void setKinopioCourseNo(int world, int level)
Sets the Toad rescue level for the given world.
u8 mCurrentWorld
The world the player is currently in.
u8 mEnemyPosIndex[WORLD_COUNT][AMBUSH_ENEMY_COUNT]
The path node for each map enemy.
u8 mKinopioCourseNo[WORLD_COUNT]
The Toad Rescue level for each world.
u8 mWorldCompletion[WORLD_COUNT]
The completion flags for each world. See WORLD_COMPLETION_e.
s8 mPlayerCoin[PLAYER_COUNT]
The coin count for each player.
void setCoin(int player, s8 coins)
Sets player 's coin count.
dMj2dGame_c()
Constructs the holder.
u8 mStartKinokoType[WORLD_COUNT]
The starting Toad House type for each world. See START_KINOKO_KIND_e.
u8 mVersion[2]
The save data version and subversion. See SAVE_VERSION and SAVE_SUB_VERSION.
int getTotalWorldCollectCoin(int world)
Gets the obtainable Star Coin count for the given world.
int getCreateItem(int player) const
Gets player 's createItem flag. See PLAYER_CREATE_ITEM_e.
u8 getKinopioCourseNo(int world) const
Gets the Toad rescue level for the given world.
static const u32 sDefaultCharacters[4]
The default character for each player.
s8 getCoin(int player) const
Gets player 's coin count.
void setCSEnemyWalkDir(int world, int enemy, u8 direction)
Sets the path direction for the given map enemy.
int getStaffCreditHighScore() const
Gets the staff credit high score.
u8 getIbaraNow() const
Gets the worldmap vine reshuffle counter.
Save data header holder.
bool getMultiModeCompletion(int world) const
Checks if the given world is unlocked in extra modes.
u16 mExtraModesUnlockedWorlds
The worlds unlocked in Extra Modes.
u16 mCoinBattlePlayCount[WORLD_COUNT][STAGE_COUNT]
The play count of each level in Coin Battle.
u8 mUnknown7
[Unused]. [Most likely declared as padding].
void setMultiModeCompletion(int world)
Unlocks the given world in extra modes.
char mMagic[4]
The savegame magic.
void initialize()
Initializes the header data.
dMj2dHeader_c()
Constructs the holder.
void versionUpdate()
Checks that the save data version matches the current one and clears the slot if not.
u16 getCoinBattlePlayCount(int world, int level) const
Gets the Coin Battle play count for the given world/level. See mCoinBattlePlayCount.
void setSelectFileNo(s8 file)
Sets the last used save data slot.
void setCoinBattlePlayCount(int world, int level, u16 count)
Sets the Coin Battle play count for the given world/level. See mCoinBattlePlayCount.
u32 mChecksum
The CRC32 checksum of the above data (excluding mMagic).
u8 mVersion[2]
The save data version and subversion. See SAVE_VERSION and SAVE_SUB_VERSION.
u8 mLastSelectedFile
The last selected save data slot.
static char sSaveMagic[4]
The expected savegame magic.
void setFreeModePlayCount(int world, int level, u16 count)
Sets the Free Mode play count for the given world/level. See mFreeModePlayCount.
u16 mFreeModePlayCount[WORLD_COUNT][STAGE_COUNT]
The play count of each level in Free Mode.
u16 mUnknown69A
[Unused]. [Most likely declared as padding].
u16 getFreeModePlayCount(int world, int level) const
Gets the Free Mode play count for the given world/level. See mFreeModePlayCount.
#define HINT_MOVIE_COUNT
The total hint movie count.
#define AMBUSH_ENEMY_COUNT
The maximum amount of ambush enemies per world map.