mirror of https://github.com/sm64pc/sm64pc.git
Makefile clean and removed binary save-file
This commit is contained in:
parent
b9f8197d67
commit
1ad8751eeb
164
Makefile
164
Makefile
|
@ -16,8 +16,6 @@ DEBUG ?= 0
|
|||
VERSION ?= us
|
||||
# Graphics microcode used
|
||||
GRUCODE ?= f3dex2e
|
||||
# If COMPARE is 1, check the output sha1sum when building 'all'
|
||||
COMPARE ?= 1
|
||||
# If NON_MATCHING is 1, define the NON_MATCHING and AVOID_UB macros when building (recommended)
|
||||
NON_MATCHING ?= 1
|
||||
|
||||
|
@ -42,13 +40,10 @@ NODRAWINGDISTANCE ?= 0
|
|||
TEXTURE_FIX ?= 0
|
||||
# Enable extended options menu by default
|
||||
EXT_OPTIONS_MENU ?= 1
|
||||
# Disable text-based save-files by default
|
||||
TEXTSAVES ?= 1
|
||||
# Enable Discord Rich Presence
|
||||
DISCORDRPC ?= 0
|
||||
|
||||
# Various workarounds for weird toolchains
|
||||
|
||||
NO_BZERO_BCOPY ?= 0
|
||||
NO_LDIV ?= 0
|
||||
|
||||
|
@ -107,27 +102,7 @@ ifneq ($(TARGET_BITS),0)
|
|||
endif
|
||||
|
||||
# Release (version) flag defs
|
||||
|
||||
ifeq ($(VERSION),jp)
|
||||
VERSION_DEF := VERSION_JP
|
||||
else
|
||||
ifeq ($(VERSION),us)
|
||||
VERSION_DEF := VERSION_US
|
||||
else
|
||||
ifeq ($(VERSION),eu)
|
||||
VERSION_DEF := VERSION_EU
|
||||
else
|
||||
ifeq ($(VERSION),sh)
|
||||
$(warning Building SH is experimental and is prone to breaking. Try at your own risk.)
|
||||
VERSION_DEF := VERSION_SH
|
||||
# TODO: GET RID OF THIS!!! We should mandate assets for Shindou like EU but we dont have the addresses extracted yet so we'll just pretend you have everything extracted for now.
|
||||
NOEXTRACT := 1
|
||||
else
|
||||
$(error unknown version "$(VERSION)")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
VERSION_DEF := VERSION_US
|
||||
|
||||
TARGET := sm64.$(VERSION)
|
||||
VERSION_CFLAGS := -D$(VERSION_DEF) -D_LANGUAGE_C
|
||||
|
@ -143,41 +118,8 @@ ifeq ($(shell git rev-parse --abbrev-ref HEAD),nightly)
|
|||
VERSION_CFLAGS += -DNIGHTLY
|
||||
endif
|
||||
|
||||
# Microcode
|
||||
|
||||
ifeq ($(GRUCODE),f3dex) # Fast3DEX
|
||||
GRUCODE_DEF := F3DEX_GBI
|
||||
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1
|
||||
TARGET := $(TARGET).f3dex
|
||||
COMPARE := 0
|
||||
else
|
||||
ifeq ($(GRUCODE),f3dex2) # Fast3DEX2
|
||||
GRUCODE_DEF := F3DEX_GBI_2
|
||||
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1
|
||||
TARGET := $(TARGET).f3dex2
|
||||
COMPARE := 0
|
||||
else
|
||||
ifeq ($(GRUCODE),f3dex2e) # Fast3DEX2 Extended (PC default)
|
||||
GRUCODE_DEF := F3DEX_GBI_2E
|
||||
TARGET := $(TARGET).f3dex2e
|
||||
COMPARE := 0
|
||||
else
|
||||
ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H (Shindou)
|
||||
GRUCODE_DEF := F3D_NEW
|
||||
TARGET := $(TARGET).f3d_new
|
||||
COMPARE := 0
|
||||
else
|
||||
ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
|
||||
$(warning Fast3DZEX is experimental. Try at your own risk.)
|
||||
GRUCODE_DEF := F3DEX_GBI_2
|
||||
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1
|
||||
TARGET := $(TARGET).f3dzex
|
||||
COMPARE := 0
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
GRUCODE_DEF := F3DEX_GBI_2E
|
||||
TARGET := $(TARGET).f3dex2e
|
||||
|
||||
GRUCODE_CFLAGS := -D$(GRUCODE_DEF)
|
||||
GRUCODE_ASFLAGS := $(GRUCODE_ASFLAGS) --defsym $(GRUCODE_DEF)=1
|
||||
|
@ -194,7 +136,6 @@ ifeq ($(OSX_BUILD),1) # Modify GFX & SDL2 for OSX GL
|
|||
endif
|
||||
|
||||
VERSION_ASFLAGS := --defsym AVOID_UB=1
|
||||
COMPARE := 0
|
||||
|
||||
ifeq ($(TARGET_WEB),1)
|
||||
VERSION_CFLAGS := $(VERSION_CFLAGS) -DTARGET_WEB -DUSE_GLES
|
||||
|
@ -283,7 +224,6 @@ LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
|
|||
|
||||
# Hi, I'm a PC
|
||||
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets src/pc src/pc/gfx src/pc/audio src/pc/controller src/pc/fs src/pc/fs/packtypes
|
||||
ASM_DIRS :=
|
||||
|
||||
ifeq ($(DISCORDRPC),1)
|
||||
SRC_DIRS += src/pc/discord
|
||||
|
@ -344,9 +284,6 @@ ifeq ($(TARGET_RPI),1)
|
|||
endif
|
||||
endif
|
||||
|
||||
# File dependencies and variables for specific files
|
||||
include Makefile.split
|
||||
|
||||
# Source code files
|
||||
LEVEL_C_FILES := $(wildcard levels/*/leveldata.c) $(wildcard levels/*/script.c) $(wildcard levels/*/geo.c)
|
||||
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C_FILES)
|
||||
|
@ -354,8 +291,7 @@ CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
|
|||
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
|
||||
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
|
||||
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c \
|
||||
$(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png)))))
|
||||
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c
|
||||
|
||||
ULTRA_C_FILES := \
|
||||
alBnkfNew.c \
|
||||
|
@ -374,19 +310,11 @@ ULTRA_C_FILES := $(addprefix lib/src/,$(ULTRA_C_FILES))
|
|||
|
||||
# "If we're not N64, use the above"
|
||||
|
||||
ifeq ($(VERSION),sh)
|
||||
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
|
||||
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/jp/*.m64) \
|
||||
$(wildcard sound/sequences/*.m64) \
|
||||
$(foreach file,$(wildcard sound/sequences/jp/*.s),$(BUILD_DIR)/$(file:.s=.m64)) \
|
||||
$(foreach file,$(wildcard sound/sequences/*.s),$(BUILD_DIR)/$(file:.s=.m64))
|
||||
else
|
||||
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
|
||||
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/$(VERSION)/*.m64) \
|
||||
$(wildcard sound/sequences/*.m64) \
|
||||
$(foreach file,$(wildcard sound/sequences/$(VERSION)/*.s),$(BUILD_DIR)/$(file:.s=.m64)) \
|
||||
$(foreach file,$(wildcard sound/sequences/*.s),$(BUILD_DIR)/$(file:.s=.m64))
|
||||
endif
|
||||
|
||||
SOUND_SAMPLE_DIRS := $(wildcard sound/samples/*)
|
||||
SOUND_SAMPLE_AIFFS := $(foreach dir,$(SOUND_SAMPLE_DIRS),$(wildcard $(dir)/*.aiff))
|
||||
|
@ -545,11 +473,6 @@ ifeq ($(BETTERCAMERA),1)
|
|||
EXT_OPTIONS_MENU := 1
|
||||
endif
|
||||
|
||||
ifeq ($(TEXTSAVES),1)
|
||||
CC_CHECK += -DTEXTSAVES
|
||||
CFLAGS += -DTEXTSAVES
|
||||
endif
|
||||
|
||||
# Check for no drawing distance option
|
||||
ifeq ($(NODRAWINGDISTANCE),1)
|
||||
CC_CHECK += -DNODRAWINGDISTANCE
|
||||
|
@ -645,10 +568,6 @@ AIFF_EXTRACT_CODEBOOK = $(TOOLS_DIR)/aiff_extract_codebook
|
|||
VADPCM_ENC = $(TOOLS_DIR)/vadpcm_enc
|
||||
EXTRACT_DATA_FOR_MIO = $(TOOLS_DIR)/extract_data_for_mio
|
||||
SKYCONV = $(TOOLS_DIR)/skyconv
|
||||
EMULATOR = mupen64plus
|
||||
EMU_FLAGS = --noosd
|
||||
LOADER = loader64
|
||||
LOADER_FLAGS = -vwf
|
||||
SHA1SUM = sha1sum
|
||||
ZEROTERM = $(PYTHON) $(TOOLS_DIR)/zeroterm.py
|
||||
|
||||
|
@ -703,12 +622,6 @@ distclean:
|
|||
$(RM) -r $(BUILD_DIR_BASE)
|
||||
./extract_assets.py --clean
|
||||
|
||||
test: $(ROM)
|
||||
$(EMULATOR) $(EMU_FLAGS) $<
|
||||
|
||||
load: $(ROM)
|
||||
$(LOADER) $(LOADER_FLAGS) $<
|
||||
|
||||
$(BUILD_DIR)/$(RPC_LIBS):
|
||||
@$(CP) -f $(RPC_LIBS) $(BUILD_DIR)
|
||||
|
||||
|
@ -731,30 +644,10 @@ $(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in
|
|||
$(BUILD_DIR)/include/text_options_strings.h: include/text_options_strings.h.in
|
||||
$(TEXTCONV) charmap.txt $< $@
|
||||
|
||||
ifeq ($(VERSION),eu)
|
||||
TEXT_DIRS := text/de text/us text/fr
|
||||
|
||||
# EU encoded text inserted into individual segment 0x19 files,
|
||||
# and course data also duplicated in leveldata.c
|
||||
$(BUILD_DIR)/bin/eu/translation_en.o: $(BUILD_DIR)/text/us/define_text.inc.c
|
||||
$(BUILD_DIR)/bin/eu/translation_de.o: $(BUILD_DIR)/text/de/define_text.inc.c
|
||||
$(BUILD_DIR)/bin/eu/translation_fr.o: $(BUILD_DIR)/text/fr/define_text.inc.c
|
||||
$(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/us/define_courses.inc.c
|
||||
$(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/de/define_courses.inc.c
|
||||
$(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/fr/define_courses.inc.c
|
||||
|
||||
else
|
||||
ifeq ($(VERSION),sh)
|
||||
TEXT_DIRS := text/jp
|
||||
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/jp/define_text.inc.c
|
||||
|
||||
else
|
||||
TEXT_DIRS := text/$(VERSION)
|
||||
|
||||
# non-EU encoded text inserted into segment 0x02
|
||||
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/$(VERSION)/define_text.inc.c
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h
|
||||
$(CPP) $(VERSION_CFLAGS) $< -o - -I text/$*/ | $(TEXTCONV) charmap.txt - $@
|
||||
|
@ -771,16 +664,6 @@ DUMMY != mkdir -p $(ALL_DIRS)
|
|||
$(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h
|
||||
$(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_options_strings.h
|
||||
|
||||
ifeq ($(VERSION),eu)
|
||||
$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||
$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||
$(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||
$(BUILD_DIR)/src/game/options_menu.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||
O_FILES += $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||
ifeq ($(DISCORDRPC),1)
|
||||
$(BUILD_DIR)/src/pc/discord/discordrpc.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||
endif
|
||||
else
|
||||
$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h
|
||||
$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h
|
||||
$(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h
|
||||
|
@ -788,8 +671,6 @@ $(BUILD_DIR)/src/game/options_menu.o: $(BUILD_DIR)/include/text_strings.h
|
|||
ifeq ($(DISCORDRPC),1)
|
||||
$(BUILD_DIR)/src/pc/discord/discordrpc.o: $(BUILD_DIR)/include/text_strings.h
|
||||
endif
|
||||
endif
|
||||
|
||||
# compressed segment generation
|
||||
|
||||
# PC Area
|
||||
|
@ -815,13 +696,8 @@ $(SOUND_BIN_DIR)/sound_data.ctl: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_
|
|||
$(SOUND_BIN_DIR)/sound_data.tbl: $(SOUND_BIN_DIR)/sound_data.ctl
|
||||
@true
|
||||
|
||||
ifeq ($(VERSION),sh)
|
||||
$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/jp/ $(SOUND_SEQUENCE_FILES) $(ENDIAN_BITWIDTH)
|
||||
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) $$(cat $(ENDIAN_BITWIDTH))
|
||||
else
|
||||
$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES) $(ENDIAN_BITWIDTH)
|
||||
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) $$(cat $(ENDIAN_BITWIDTH))
|
||||
endif
|
||||
|
||||
$(SOUND_BIN_DIR)/bank_sets: $(SOUND_BIN_DIR)/sequences.bin
|
||||
@true
|
||||
|
@ -865,37 +741,12 @@ $(BUILD_DIR)/lib/src/string.o: OPT_FLAGS := -O2
|
|||
$(BUILD_DIR)/lib/src/gu%.o: OPT_FLAGS := -O3
|
||||
$(BUILD_DIR)/lib/src/al%.o: OPT_FLAGS := -O3
|
||||
|
||||
ifeq ($(VERSION),eu)
|
||||
$(BUILD_DIR)/lib/src/_Litob.o: OPT_FLAGS := -O3
|
||||
$(BUILD_DIR)/lib/src/_Ldtob.o: OPT_FLAGS := -O3
|
||||
$(BUILD_DIR)/lib/src/_Printf.o: OPT_FLAGS := -O3
|
||||
$(BUILD_DIR)/lib/src/sprintf.o: OPT_FLAGS := -O3
|
||||
|
||||
# enable loop unrolling except for external.c (external.c might also have used
|
||||
# unrolling, but it makes one loop harder to match)
|
||||
$(BUILD_DIR)/src/audio/%.o: OPT_FLAGS := -O2
|
||||
$(BUILD_DIR)/src/audio/load.o: OPT_FLAGS := -O2
|
||||
$(BUILD_DIR)/src/audio/external.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
|
||||
else
|
||||
|
||||
# The source-to-source optimizer copt is enabled for audio. This makes it use
|
||||
# acpp, which needs -Wp,-+ to handle C++-style comments.
|
||||
$(BUILD_DIR)/src/audio/effects.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0 -sopt,-inline=sequence_channel_process_sound,-scalaroptimize=1 -Wp,-+
|
||||
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -O2 -sopt,-scalaroptimize=1 -Wp,-+
|
||||
#$(BUILD_DIR)/src/audio/seqplayer.o: OPT_FLAGS := -O2 -sopt,-inline_manual,-scalaroptimize=1 -Wp,-+ #-Wo,-v,-bb,-l,seqplayer_list.txt
|
||||
|
||||
# Add a target for build/eu/src/audio/*.copt to make it easier to see debug
|
||||
$(BUILD_DIR)/src/audio/%.acpp: src/audio/%.c
|
||||
$(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/acpp $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(MATCH_CFLAGS) $(GRUCODE_CFLAGS) -D__sgi -+ $< > $@
|
||||
|
||||
$(BUILD_DIR)/src/audio/seqplayer.copt: $(BUILD_DIR)/src/audio/seqplayer.acpp
|
||||
$(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/copt -signed -I=$< -CMP=$@ -cp=i -scalaroptimize=1 -inline_manual
|
||||
|
||||
$(BUILD_DIR)/src/audio/%.copt: $(BUILD_DIR)/src/audio/%.acpp
|
||||
$(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/copt -signed -I=$< -CMP=$@ -cp=i -scalaroptimize=1
|
||||
|
||||
endif
|
||||
|
||||
# Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes.
|
||||
$(GLOBAL_ASM_O_FILES): $(GLOBAL_ASM_DEP).$(NON_MATCHING)
|
||||
$(GLOBAL_ASM_DEP).$(NON_MATCHING):
|
||||
|
@ -910,7 +761,6 @@ $(BUILD_DIR)/%.o: %.c
|
|||
@$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
|
||||
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
|
||||
@$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
@ -918,12 +768,10 @@ $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
|
|||
$(BUILD_DIR)/%.o: %.s
|
||||
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
|
||||
|
||||
|
||||
|
||||
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS)
|
||||
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
|
||||
|
||||
.PHONY: all clean distclean default diff test load libultra res
|
||||
.PHONY: all clean distclean default diff libultra res
|
||||
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
|
@ -932,4 +780,4 @@ MAKEFLAGS += --no-builtin-rules
|
|||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|
||||
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|
|
@ -45,12 +45,8 @@ s8 gLevelToCourseNumTable[] = {
|
|||
STATIC_ASSERT(ARRAY_COUNT(gLevelToCourseNumTable) == LEVEL_COUNT - 1,
|
||||
"change this array if you are adding levels");
|
||||
|
||||
#ifdef TEXTSAVES
|
||||
|
||||
#include "text_save.inc.h"
|
||||
|
||||
#endif
|
||||
|
||||
// This was probably used to set progress to 100% for debugging, but
|
||||
// it was removed from the release ROM.
|
||||
static void stub_save_file_1(void) {
|
||||
|
@ -345,31 +341,12 @@ void save_file_do_save(s32 fileIndex) {
|
|||
if (fileIndex < 0 || fileIndex >= NUM_SAVE_FILES)
|
||||
return;
|
||||
|
||||
if (gSaveFileModified)
|
||||
#ifdef TEXTSAVES
|
||||
{
|
||||
if (gSaveFileModified) {
|
||||
// Write to text file
|
||||
write_text_save(fileIndex);
|
||||
gSaveFileModified = FALSE;
|
||||
gMainMenuDataModified = FALSE;
|
||||
}
|
||||
#else
|
||||
{
|
||||
// Compute checksum
|
||||
add_save_block_signature(&gSaveBuffer.files[fileIndex][0],
|
||||
sizeof(gSaveBuffer.files[fileIndex][0]), SAVE_FILE_MAGIC);
|
||||
|
||||
// Copy to backup slot
|
||||
bcopy(&gSaveBuffer.files[fileIndex][0], &gSaveBuffer.files[fileIndex][1],
|
||||
sizeof(gSaveBuffer.files[fileIndex][1]));
|
||||
|
||||
// Write to EEPROM
|
||||
write_eeprom_savefile(fileIndex, 0, 2);
|
||||
|
||||
gSaveFileModified = FALSE;
|
||||
}
|
||||
save_main_menu_data();
|
||||
#endif
|
||||
}
|
||||
|
||||
void save_file_erase(s32 fileIndex) {
|
||||
|
@ -404,51 +381,11 @@ void save_file_load_all(void) {
|
|||
|
||||
bzero(&gSaveBuffer, sizeof(gSaveBuffer));
|
||||
|
||||
#ifdef TEXTSAVES
|
||||
for (file = 0; file < NUM_SAVE_FILES; file++) {
|
||||
read_text_save(file);
|
||||
}
|
||||
gSaveFileModified = TRUE;
|
||||
gMainMenuDataModified = TRUE;
|
||||
#else
|
||||
s32 validSlots;
|
||||
read_eeprom_data(&gSaveBuffer, sizeof(gSaveBuffer));
|
||||
|
||||
if (save_file_need_bswap(&gSaveBuffer))
|
||||
save_file_bswap(&gSaveBuffer);
|
||||
|
||||
// Verify the main menu data and create a backup copy if only one of the slots is valid.
|
||||
validSlots = verify_save_block_signature(&gSaveBuffer.menuData[0], sizeof(gSaveBuffer.menuData[0]), MENU_DATA_MAGIC);
|
||||
validSlots |= verify_save_block_signature(&gSaveBuffer.menuData[1], sizeof(gSaveBuffer.menuData[1]),MENU_DATA_MAGIC) << 1;
|
||||
switch (validSlots) {
|
||||
case 0: // Neither copy is correct
|
||||
wipe_main_menu_data();
|
||||
break;
|
||||
case 1: // Slot 0 is correct and slot 1 is incorrect
|
||||
restore_main_menu_data(0);
|
||||
break;
|
||||
case 2: // Slot 1 is correct and slot 0 is incorrect
|
||||
restore_main_menu_data(1);
|
||||
break;
|
||||
}
|
||||
|
||||
for (file = 0; file < NUM_SAVE_FILES; file++) {
|
||||
// Verify the save file and create a backup copy if only one of the slots is valid.
|
||||
validSlots = verify_save_block_signature(&gSaveBuffer.files[file][0], sizeof(gSaveBuffer.files[file][0]), SAVE_FILE_MAGIC);
|
||||
validSlots |= verify_save_block_signature(&gSaveBuffer.files[file][1], sizeof(gSaveBuffer.files[file][1]), SAVE_FILE_MAGIC) << 1;
|
||||
switch (validSlots) {
|
||||
case 0: // Neither copy is correct
|
||||
save_file_erase(file);
|
||||
break;
|
||||
case 1: // Slot 0 is correct and slot 1 is incorrect
|
||||
restore_save_file_data(file, 0);
|
||||
break;
|
||||
case 2: // Slot 1 is correct and slot 0 is incorrect
|
||||
restore_save_file_data(file, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // TEXTSAVES
|
||||
stub_save_file_1();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue