From ae1eaab79c78bc66ace4775b33c8ce124955cf04 Mon Sep 17 00:00:00 2001 From: DorfDork Date: Tue, 18 Aug 2020 06:55:51 -0500 Subject: [PATCH] Added LEGACY_RES Flag --- Makefile | 77 ++++++++------------------------------------------ tools/mkzip.py | 31 ++++++++++++-------- 2 files changed, 31 insertions(+), 77 deletions(-) diff --git a/Makefile b/Makefile index 12c74cd..5dcc4d2 100644 --- a/Makefile +++ b/Makefile @@ -43,9 +43,7 @@ TEXTURE_FIX ?= 0 # Enable extended options menu by default EXT_OPTIONS_MENU ?= 1 # Disable text-based save-files by default -TEXTSAVES ?= 0 -# Load resources from external files -EXTERNAL_DATA ?= 0 +TEXTSAVES ?= 1 # Enable Discord Rich Presence DISCORDRPC ?= 0 @@ -65,8 +63,7 @@ AUDIO_API ?= SDL2 # Controller backends (can have multiple, space separated): SDL2 CONTROLLER_API ?= SDL2 -# Misc settings for EXTERNAL_DATA - +LEGACY_RES ?= 0 BASEDIR ?= res # Automatic settings for PC port(s) @@ -412,7 +409,7 @@ RPC_LIBS := ifeq ($(DISCORDRPC),1) ifeq ($(WINDOWS_BUILD),1) RPC_LIBS := lib/discord/libdiscord-rpc.dll - else ifeq ($(OSX_BUILD),1) + else ifeq ($(OSX_BUILD),1) # needs testing RPC_LIBS := lib/discord/libdiscord-rpc.dylib else @@ -595,14 +592,14 @@ ifeq ($(LEGACY_GL),1) CFLAGS += -DLEGACY_GL endif +# TODO: Remove -DEXTERNAL_DATA + # Load external textures -ifeq ($(EXTERNAL_DATA),1) - CC_CHECK += -DEXTERNAL_DATA -DFS_BASEDIR="\"$(BASEDIR)\"" - CFLAGS += -DEXTERNAL_DATA -DFS_BASEDIR="\"$(BASEDIR)\"" - # tell skyconv to write names instead of actual texture data and save the split tiles so we can use them later - SKYTILE_DIR := $(BUILD_DIR)/textures/skybox_tiles - SKYCONV_ARGS := --store-names --write-tiles "$(SKYTILE_DIR)" -endif +CC_CHECK += -DEXTERNAL_DATA -DFS_BASEDIR="\"$(BASEDIR)\"" +CFLAGS += -DEXTERNAL_DATA -DFS_BASEDIR="\"$(BASEDIR)\"" +# tell skyconv to write names instead of actual texture data and save the split tiles so we can use them later +SKYTILE_DIR := $(BUILD_DIR)/textures/skybox_tiles +SKYCONV_ARGS := --store-names --write-tiles "$(SKYTILE_DIR)" ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) @@ -670,8 +667,6 @@ else CP := cp endif -ifeq ($(EXTERNAL_DATA),1) - BASEPACK_PATH := $(BUILD_DIR)/$(BASEDIR)/ BASEPACK_LST := $(BUILD_DIR)/basepack.lst @@ -696,9 +691,7 @@ $(BASEPACK_LST): $(EXE) # prepares the resource ZIP with base data $(BASEPACK_PATH): $(BASEPACK_LST) - @$(PYTHON) $(TOOLS_DIR)/mkzip.py $(BASEPACK_LST) $(BASEPACK_PATH) - -endif + @$(PYTHON) $(TOOLS_DIR)/mkzip.py $(BASEPACK_LST) $(BASEPACK_PATH) $(LEGACY_RES) clean: $(RM) -r $(BUILD_DIR_BASE) @@ -797,42 +790,6 @@ ifeq ($(DISCORDRPC),1) endif endif -################################################################ -# TEXTURE GENERATION # -################################################################ - -# RGBA32, RGBA16, IA16, IA8, IA4, IA1, I8, I4 - -ifeq ($(EXTERNAL_DATA),1) - -$(BUILD_DIR)/%: %.png - $(ZEROTERM) "$(patsubst %.png,%,$^)" > $@ - -else - -$(BUILD_DIR)/%: %.png - $(N64GRAPHICS) -i $@ -g $< -f $(lastword $(subst ., ,$@)) - -endif - -$(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/% %.png - hexdump -v -e '1/1 "0x%X,"' $< > $@ - echo >> $@ - -ifeq ($(EXTERNAL_DATA),0) - -# Color Index CI8 -$(BUILD_DIR)/%.ci8: %.ci8.png - $(N64GRAPHICS_CI) -i $@ -g $< -f ci8 - -# Color Index CI4 -$(BUILD_DIR)/%.ci4: %.ci4.png - $(N64GRAPHICS_CI) -i $@ -g $< -f ci4 - -endif - -################################################################ - # compressed segment generation # PC Area @@ -875,19 +832,9 @@ $(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o $(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s $(AS) $(ASFLAGS) -o $@ $< -ifeq ($(EXTERNAL_DATA),1) - $(SOUND_BIN_DIR)/%.inc.c: $(SOUND_BIN_DIR)/% $(ZEROTERM) "$(patsubst $(BUILD_DIR)/%,%,$^)" | hexdump -v -e '1/1 "0x%X,"' > $@ -else - -$(SOUND_BIN_DIR)/%.inc.c: $(SOUND_BIN_DIR)/% - hexdump -v -e '1/1 "0x%X,"' $< > $@ - echo >> $@ - -endif - $(SOUND_BIN_DIR)/sound_data.o: $(SOUND_BIN_DIR)/sound_data.ctl.inc.c $(SOUND_BIN_DIR)/sound_data.tbl.inc.c $(SOUND_BIN_DIR)/sequences.bin.inc.c $(SOUND_BIN_DIR)/bank_sets.inc.c $(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h @@ -985,4 +932,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 \ No newline at end of file diff --git a/tools/mkzip.py b/tools/mkzip.py index ffe0153..7359bc8 100644 --- a/tools/mkzip.py +++ b/tools/mkzip.py @@ -14,8 +14,8 @@ def md5(fname): hash_md5.update(chunk) return hash_md5.hexdigest() -if len(sys.argv) < 3: - print('usage: mkzip ') +if len(sys.argv) < 4: + print('usage: mkzip ') sys.exit(1) lst = [] @@ -26,13 +26,20 @@ with open(sys.argv[1], 'r') as f: continue tok = line.split() lst.append((tok[0], tok[1])) - - for (fname, aname) in lst: - path = os.path.join(sys.argv[2], aname) - old_md5 = md5(fname); - if not os.path.exists(path) or os.path.exists(path) and old_md5 != md5(path): - os.makedirs(os.path.dirname(path), exist_ok=True) - copyfile(fname, path) - print("Copying: " + path) - else: - print("Skipping: " + path + " - MD5: "+md5(fname)) + if not sys.argv[3] or not sys.argv[3] == "1": + for (fname, aname) in lst: + path = os.path.join(sys.argv[2], aname) + old_md5 = md5(fname) + if not os.path.exists(path) or os.path.exists(path) and old_md5 != md5(path): + os.makedirs(os.path.dirname(path), exist_ok=True) + copyfile(fname, path) + print("Copying: " + path) + else: + print("Skipping: " + path + " - MD5: "+md5(fname)) + else: + zipPath = os.path.join(sys.argv[2], "awesome-legacy.zip") + print("Using Legacy System") + with zipfile.ZipFile(zipPath, 'w', allowZip64=False) as zipf: + for (fname, aname) in lst: + zipf.write(fname, arcname=aname) + print("Legacy - Copying: " + aname) \ No newline at end of file