![]() |
Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
|
#include <ultra64.h>
#include "sm64.h"
#include "game.h"
#include "main.h"
#include "engine/math_util.h"
#include "area.h"
#include "level_update.h"
#include "save_file.h"
#include "sound_init.h"
Macros | |
#define | MENU_DATA_MAGIC 0x4849 |
#define | SAVE_FILE_MAGIC 0x4441 |
Functions | |
STATIC_ASSERT (sizeof(struct SaveBuffer)==EEPROM_SIZE, "eeprom buffer size must match") | |
STATIC_ASSERT (ARRAY_COUNT(gLevelToCourseNumTable)==LEVEL_COUNT - 1, "change this array if you are adding levels") | |
static void | no_op (void) |
static s32 | read_eeprom_data (void *buffer, s32 size) |
Read from EEPROM to a given address. More... | |
static s32 | write_eeprom_data (void *buffer, s32 size) |
Write data to EEPROM. More... | |
static s32 | calc_checksum (u8 *data, s32 size) |
Sum the bytes in data to data + size - 2. More... | |
static s32 | verify_save_block_signature (void *buffer, s32 size, u16 magic) |
Verify the signature at the end of the block to check if the data is valid. More... | |
static void | add_save_block_signature (void *buffer, s32 size, u16 magic) |
Write a signature at the end of the block to make sure the data is valid. More... | |
static void | restore_main_menu_data (s32 srcSlot) |
Copy main menu data from one backup slot to the other slot. More... | |
static void | save_main_menu_data (void) |
static void | wipe_main_menu_data (void) |
static s32 | get_coin_score_age (s32 fileIndex, s32 courseIndex) |
static void | set_coin_score_age (s32 fileIndex, s32 courseIndex, s32 age) |
static void | touch_coin_score_age (s32 fileIndex, s32 courseIndex) |
Mark a coin score for a save file as the newest out of all save files. More... | |
static void | touch_high_score_ages (s32 fileIndex) |
Mark all coin scores for a save file as new. More... | |
static void | restore_save_file_data (s32 fileIndex, s32 srcSlot) |
Copy save file data from one backup slot to the other slot. More... | |
void | save_file_do_save (s32 fileIndex) |
void | save_file_erase (s32 fileIndex) |
void | save_file_copy (s32 srcFileIndex, s32 destFileIndex) |
void | save_file_load_all (void) |
void | save_file_reload (void) |
Reload the current save file from its backup copy, which is effectively a a cached copy of what has been written to EEPROM. More... | |
void | save_file_collect_star_or_key (s16 coinScore, s16 starIndex) |
Update the current save file after collecting a star or a key. More... | |
s32 | save_file_exists (s32 fileIndex) |
u32 | save_file_get_max_coin_score (s32 courseIndex) |
Get the maximum coin score across all files for a course. More... | |
s32 | save_file_get_course_star_count (s32 fileIndex, s32 courseIndex) |
s32 | save_file_get_total_star_count (s32 fileIndex, s32 minCourse, s32 maxCourse) |
void | save_file_set_flags (s32 flags) |
void | save_file_clear_flags (s32 flags) |
s32 | save_file_get_flags (void) |
s32 | save_file_get_star_flags (s32 fileIndex, s32 courseIndex) |
Return the bitset of obtained stars in the specified course. More... | |
void | save_file_set_star_flags (s32 fileIndex, s32 courseIndex, s32 starFlags) |
Add to the bitset of obtained stars in the specified course. More... | |
s32 | save_file_get_course_coin_score (s32 fileIndex, s32 courseIndex) |
s32 | save_file_is_cannon_unlocked (void) |
Return TRUE if the cannon is unlocked in the current course. More... | |
void | save_file_set_cannon_unlocked (void) |
Sets the cannon status to unlocked in the current course. More... | |
void | save_file_set_cap_pos (s16 x, s16 y, s16 z) |
s32 | save_file_get_cap_pos (Vec3s capPos) |
void | save_file_set_sound_mode (u16 mode) |
u16 | save_file_get_sound_mode (void) |
void | save_file_move_cap_to_default_location (void) |
void | disable_warp_checkpoint (void) |
void | check_if_should_set_warp_checkpoint (struct WarpNode *warpNode) |
Checks the upper bit of the WarpNode->destLevel byte to see if the game should set a warp checkpoint. More... | |
s32 | check_warp_checkpoint (struct WarpNode *warpNode) |
Checks to see if a checkpoint is properly active or not. More... | |
#define MENU_DATA_MAGIC 0x4849 |
#define SAVE_FILE_MAGIC 0x4441 |
Write a signature at the end of the block to make sure the data is valid.
Sum the bytes in data to data + size - 2.
The last two bytes are ignored because that is where the checksum is stored.
Checks the upper bit of the WarpNode->destLevel byte to see if the game should set a warp checkpoint.
Read from EEPROM to a given address.
The EEPROM address is computed using the offset of the destination address from gSaveBuffer. Try at most 4 times, and return 0 on success. On failure, return the status returned from osEepromLongRead. It also returns 0 if EEPROM isn't loaded correctly in the system.
Copy main menu data from one backup slot to the other slot.
Copy save file data from one backup slot to the other slot.
Update the current save file after collecting a star or a key.
If coin score is greater than the current high score, update it.
Compares the coin score as a 16 bit value, but only writes the 8 bit
Get the maximum coin score across all files for a course.
The lower 16 bits of the returned value are the score, and the upper 16 bits are the file number of the save file with this score.
Return the bitset of obtained stars in the specified course.
If course is -1, return the bitset of obtained castle secret stars.
Return TRUE if the cannon is unlocked in the current course.
Reload the current save file from its backup copy, which is effectively a a cached copy of what has been written to EEPROM.
This is used after getting a game over.
Sets the cannon status to unlocked in the current course.
Add to the bitset of obtained stars in the specified course.
If course is -1, add ot the bitset of obtained castle secret stars.
STATIC_ASSERT | ( | sizeof(struct SaveBuffer) | = =EEPROM_SIZE , |
"eeprom buffer size must match" | |||
) |
STATIC_ASSERT | ( | ARRAY_COUNT(gLevelToCourseNumTable) | = =LEVEL_COUNT - 1 , |
"change this array if you are adding levels" | |||
) |
Mark a coin score for a save file as the newest out of all save files.
Mark all coin scores for a save file as new.
Verify the signature at the end of the block to check if the data is valid.
Write data to EEPROM.
The EEPROM address is computed using the offset of the source address from gSaveBuffer. Try at most 4 times, and return 0 on success. On failure, return the status returned from osEepromLongWrite. Unlike read_eeprom_data, return 1 if EEPROM isn't loaded.
u8 gCurrCourseStarFlags = 0 |
u8 gGotFileCoinHiScore = 0 |
u8 gLastCompletedCourseNum = 0 |
u8 gLastCompletedStarNum = 0 |
s8 gLevelToCourseNumTable[] |
s8 gMainMenuDataModified |
struct SaveBuffer gSaveBuffer |
s8 gSaveFileModified |
u8 gSpecialTripleJump = 0 |
struct WarpCheckpoint gWarpCheckpoint |
s8 sUnusedGotGlobalCoinHiScore = 0 |