Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Data Structures | Macros | Functions | Variables
save_file.h File Reference
#include "types.h"
#include "area.h"

Go to the source code of this file.

Data Structures

struct  SaveBlockSignature
 
struct  SaveFile
 
struct  MainMenuSaveData
 
struct  SaveBuffer
 
struct  WarpCheckpoint
 

Macros

#define EEPROM_SIZE   0x200
 
#define NUM_SAVE_FILES   4
 
#define SUBTRAHEND   6
 
#define SAVE_FLAG_FILE_EXISTS   /* 0x000001 */ (1 << 0)
 
#define SAVE_FLAG_HAVE_WING_CAP   /* 0x000002 */ (1 << 1)
 
#define SAVE_FLAG_HAVE_METAL_CAP   /* 0x000004 */ (1 << 2)
 
#define SAVE_FLAG_HAVE_VANISH_CAP   /* 0x000008 */ (1 << 3)
 
#define SAVE_FLAG_HAVE_KEY_1   /* 0x000010 */ (1 << 4)
 
#define SAVE_FLAG_HAVE_KEY_2   /* 0x000020 */ (1 << 5)
 
#define SAVE_FLAG_UNLOCKED_BASEMENT_DOOR   /* 0x000040 */ (1 << 6)
 
#define SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR   /* 0x000080 */ (1 << 7)
 
#define SAVE_FLAG_DDD_MOVED_BACK   /* 0x000100 */ (1 << 8)
 
#define SAVE_FLAG_MOAT_DRAINED   /* 0x000200 */ (1 << 9)
 
#define SAVE_FLAG_UNLOCKED_PSS_DOOR   /* 0x000400 */ (1 << 10)
 
#define SAVE_FLAG_UNLOCKED_WF_DOOR   /* 0x000800 */ (1 << 11)
 
#define SAVE_FLAG_UNLOCKED_CCM_DOOR   /* 0x001000 */ (1 << 12)
 
#define SAVE_FLAG_UNLOCKED_JRB_DOOR   /* 0x002000 */ (1 << 13)
 
#define SAVE_FLAG_UNLOCKED_BITDW_DOOR   /* 0x004000 */ (1 << 14)
 
#define SAVE_FLAG_UNLOCKED_BITFS_DOOR   /* 0x008000 */ (1 << 15)
 
#define SAVE_FLAG_CAP_ON_GROUND   /* 0x010000 */ (1 << 16)
 
#define SAVE_FLAG_CAP_ON_KLEPTO   /* 0x020000 */ (1 << 17)
 
#define SAVE_FLAG_CAP_ON_UKIKI   /* 0x040000 */ (1 << 18)
 
#define SAVE_FLAG_CAP_ON_MR_BLIZZARD   /* 0x080000 */ (1 << 19)
 
#define SAVE_FLAG_UNLOCKED_50_STAR_DOOR   /* 0x100000 */ (1 << 20)
 

Functions

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 *a)
 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 *a)
 Checks to see if a checkpoint is properly active or not. More...
 

Variables

u8 gLastCompletedCourseNum
 
u8 gLastCompletedStarNum
 
s8 sUnusedGotGlobalCoinHiScore
 
u8 gGotFileCoinHiScore
 
u8 gCurrCourseStarFlags
 
u8 gSpecialTripleJump
 
s8 gLevelToCourseNumTable []
 
struct WarpCheckpoint gWarpCheckpoint
 
s8 gMainMenuDataModified
 
s8 gSaveFileModified
 

Macro Definition Documentation

◆ EEPROM_SIZE

#define EEPROM_SIZE   0x200

◆ NUM_SAVE_FILES

#define NUM_SAVE_FILES   4

◆ SAVE_FLAG_CAP_ON_GROUND

#define SAVE_FLAG_CAP_ON_GROUND   /* 0x010000 */ (1 << 16)

◆ SAVE_FLAG_CAP_ON_KLEPTO

#define SAVE_FLAG_CAP_ON_KLEPTO   /* 0x020000 */ (1 << 17)

◆ SAVE_FLAG_CAP_ON_MR_BLIZZARD

#define SAVE_FLAG_CAP_ON_MR_BLIZZARD   /* 0x080000 */ (1 << 19)

◆ SAVE_FLAG_CAP_ON_UKIKI

#define SAVE_FLAG_CAP_ON_UKIKI   /* 0x040000 */ (1 << 18)

◆ SAVE_FLAG_DDD_MOVED_BACK

#define SAVE_FLAG_DDD_MOVED_BACK   /* 0x000100 */ (1 << 8)

◆ SAVE_FLAG_FILE_EXISTS

#define SAVE_FLAG_FILE_EXISTS   /* 0x000001 */ (1 << 0)

◆ SAVE_FLAG_HAVE_KEY_1

#define SAVE_FLAG_HAVE_KEY_1   /* 0x000010 */ (1 << 4)

◆ SAVE_FLAG_HAVE_KEY_2

#define SAVE_FLAG_HAVE_KEY_2   /* 0x000020 */ (1 << 5)

◆ SAVE_FLAG_HAVE_METAL_CAP

#define SAVE_FLAG_HAVE_METAL_CAP   /* 0x000004 */ (1 << 2)

◆ SAVE_FLAG_HAVE_VANISH_CAP

#define SAVE_FLAG_HAVE_VANISH_CAP   /* 0x000008 */ (1 << 3)

◆ SAVE_FLAG_HAVE_WING_CAP

#define SAVE_FLAG_HAVE_WING_CAP   /* 0x000002 */ (1 << 1)

◆ SAVE_FLAG_MOAT_DRAINED

#define SAVE_FLAG_MOAT_DRAINED   /* 0x000200 */ (1 << 9)

◆ SAVE_FLAG_UNLOCKED_50_STAR_DOOR

#define SAVE_FLAG_UNLOCKED_50_STAR_DOOR   /* 0x100000 */ (1 << 20)

◆ SAVE_FLAG_UNLOCKED_BASEMENT_DOOR

#define SAVE_FLAG_UNLOCKED_BASEMENT_DOOR   /* 0x000040 */ (1 << 6)

◆ SAVE_FLAG_UNLOCKED_BITDW_DOOR

#define SAVE_FLAG_UNLOCKED_BITDW_DOOR   /* 0x004000 */ (1 << 14)

◆ SAVE_FLAG_UNLOCKED_BITFS_DOOR

#define SAVE_FLAG_UNLOCKED_BITFS_DOOR   /* 0x008000 */ (1 << 15)

◆ SAVE_FLAG_UNLOCKED_CCM_DOOR

#define SAVE_FLAG_UNLOCKED_CCM_DOOR   /* 0x001000 */ (1 << 12)

◆ SAVE_FLAG_UNLOCKED_JRB_DOOR

#define SAVE_FLAG_UNLOCKED_JRB_DOOR   /* 0x002000 */ (1 << 13)

◆ SAVE_FLAG_UNLOCKED_PSS_DOOR

#define SAVE_FLAG_UNLOCKED_PSS_DOOR   /* 0x000400 */ (1 << 10)

◆ SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR

#define SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR   /* 0x000080 */ (1 << 7)

◆ SAVE_FLAG_UNLOCKED_WF_DOOR

#define SAVE_FLAG_UNLOCKED_WF_DOOR   /* 0x000800 */ (1 << 11)

◆ SUBTRAHEND

#define SUBTRAHEND   6

Function Documentation

◆ check_if_should_set_warp_checkpoint()

void check_if_should_set_warp_checkpoint ( struct WarpNode a)

Checks the upper bit of the WarpNode->destLevel byte to see if the game should set a warp checkpoint.

◆ check_warp_checkpoint()

s32 check_warp_checkpoint ( struct WarpNode warpNode)

Checks to see if a checkpoint is properly active or not.

This will also update the level, area, and destination node of the input WarpNode. returns TRUE if input WarpNode was updated, and FALSE if not.

◆ disable_warp_checkpoint()

void disable_warp_checkpoint ( void  )

◆ save_file_clear_flags()

void save_file_clear_flags ( s32  flags)

◆ save_file_collect_star_or_key()

void save_file_collect_star_or_key ( s16  coinScore,
s16  starIndex 
)

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

◆ save_file_copy()

void save_file_copy ( s32  srcFileIndex,
s32  destFileIndex 
)

◆ save_file_do_save()

void save_file_do_save ( s32  fileIndex)

◆ save_file_erase()

void save_file_erase ( s32  fileIndex)

◆ save_file_exists()

s32 save_file_exists ( s32  fileIndex)

◆ save_file_get_cap_pos()

s32 save_file_get_cap_pos ( Vec3s  capPos)

◆ save_file_get_course_coin_score()

s32 save_file_get_course_coin_score ( s32  fileIndex,
s32  courseIndex 
)

◆ save_file_get_course_star_count()

s32 save_file_get_course_star_count ( s32  fileIndex,
s32  courseIndex 
)

◆ save_file_get_flags()

s32 save_file_get_flags ( void  )

◆ save_file_get_max_coin_score()

u32 save_file_get_max_coin_score ( s32  courseIndex)

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.

◆ save_file_get_sound_mode()

u16 save_file_get_sound_mode ( void  )

◆ save_file_get_star_flags()

s32 save_file_get_star_flags ( s32  fileIndex,
s32  courseIndex 
)

Return the bitset of obtained stars in the specified course.

If course is -1, return the bitset of obtained castle secret stars.

◆ save_file_get_total_star_count()

s32 save_file_get_total_star_count ( s32  fileIndex,
s32  minCourse,
s32  maxCourse 
)

◆ save_file_is_cannon_unlocked()

s32 save_file_is_cannon_unlocked ( void  )

Return TRUE if the cannon is unlocked in the current course.

◆ save_file_load_all()

void save_file_load_all ( void  )

◆ save_file_move_cap_to_default_location()

void save_file_move_cap_to_default_location ( void  )

◆ save_file_reload()

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.

This is used after getting a game over.

◆ save_file_set_cannon_unlocked()

void save_file_set_cannon_unlocked ( void  )

Sets the cannon status to unlocked in the current course.

◆ save_file_set_cap_pos()

void save_file_set_cap_pos ( s16  x,
s16  y,
s16  z 
)

◆ save_file_set_flags()

void save_file_set_flags ( s32  flags)

◆ save_file_set_sound_mode()

void save_file_set_sound_mode ( u16  mode)

◆ save_file_set_star_flags()

void save_file_set_star_flags ( s32  fileIndex,
s32  courseIndex,
s32  starFlags 
)

Add to the bitset of obtained stars in the specified course.

If course is -1, add ot the bitset of obtained castle secret stars.

Variable Documentation

◆ gCurrCourseStarFlags

u8 gCurrCourseStarFlags

◆ gGotFileCoinHiScore

u8 gGotFileCoinHiScore

◆ gLastCompletedCourseNum

u8 gLastCompletedCourseNum

◆ gLastCompletedStarNum

u8 gLastCompletedStarNum

◆ gLevelToCourseNumTable

s8 gLevelToCourseNumTable[]

◆ gMainMenuDataModified

s8 gMainMenuDataModified

◆ gSaveFileModified

s8 gSaveFileModified

◆ gSpecialTripleJump

u8 gSpecialTripleJump

◆ gWarpCheckpoint

struct WarpCheckpoint gWarpCheckpoint

◆ sUnusedGotGlobalCoinHiScore

s8 sUnusedGotGlobalCoinHiScore