Skip to content

Commit

Permalink
Merge pull request #143 from Yanis42/decomp_update_3
Browse files Browse the repository at this point in the history
Merge decomp/main
  • Loading branch information
Yanis002 authored Jul 29, 2024
2 parents 4412521 + b4e82bc commit c0d126a
Show file tree
Hide file tree
Showing 350 changed files with 34,503 additions and 5,420 deletions.
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"OOT_DEBUG=1", // If targeting a debug version
"ENABLE_HACKEROOT=1",
"RELEASE_ROM=0",
"COMPRESS_YAZ=1"
"COMPRESS_YAZ=1",
"OOT_PAL=1"
],
"cStandard": "gnu11",
"cppStandard": "${default}" // Only ZAPD uses C++, so doesn't really matter
Expand Down
86 changes: 51 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ SHELL = /bin/bash
COMPILER := gcc

# Target game version. Currently only the following version is supported:
# gc-eu GameCube Europe/PAL
# gc-eu-mq GameCube Europe/PAL Master Quest
# gc-eu-mq-dbg GameCube Europe/PAL Master Quest Debug
# hackeroot-mq HackerOoT, based on gc-eu-mq-dbg (default)
#
# The following versions are work-in-progress and not yet matching:
# gc-eu GameCube Europe/PAL
# gc-us GameCube US
#
# Note: choosing hackeroot-mq will enable HackerOoT features,
# if another version is chosen, this repo will be like
Expand Down Expand Up @@ -83,20 +84,25 @@ else
endif

# Version-specific settings
ifeq ($(VERSION),gc-eu)
ifeq ($(VERSION),gc-us)
DEBUG := 0
COMPARE := 0
CPP_DEFINES += -DOOT_NTSC=1 -DOOT_PAL=0 -DOOT_MQ=0
else ifeq ($(VERSION),gc-eu)
DEBUG := 0
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=0
HACKEROOT := 0
else ifeq ($(VERSION),gc-eu-mq)
DEBUG := 0
CPP_DEFINES += -DOOT_MQ
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=1
HACKEROOT := 0
else ifeq ($(VERSION),gc-eu-mq-dbg)
DEBUG := 1
CPP_DEFINES += -DOOT_MQ
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=1
HACKEROOT := 0
else ifeq ($(VERSION),hackeroot-mq)
DEBUG := 1
CPP_DEFINES += -DOOT_MQ
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=1
HACKEROOT := 1
else
$(error Unsupported version $(VERSION))
Expand Down Expand Up @@ -278,22 +284,28 @@ ifeq ($(COMPILER),gcc)
SRC_DIRS := $(shell find src -type d)
endif

ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*" -not -path "assets/text")
ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml))
# create extracted directories
$(shell mkdir -p $(EXTRACTED_DIR) $(EXTRACTED_DIR)/assets $(EXTRACTED_DIR)/text)

# create extracted directories
$(shell mkdir -p $(EXTRACTED_DIR) $(EXTRACTED_DIR)/assets $(EXTRACTED_DIR)/text)

ASSET_BIN_DIRS := $(shell find $(EXTRACTED_DIR)/assets -type d)
ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin))
ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_XML:.xml=.c),$f) \
$(foreach f,$(ASSET_FILES_BIN:.bin=.bin.inc.c),$(BUILD_DIR)/$f) \
ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_BIN:.bin=.bin.inc.c),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \
$(foreach f,$(wildcard assets/text/*.c),$(BUILD_DIR)/$(f:.c=.o))

UNDECOMPILED_DATA_DIRS := $(shell find data -type d)

BASEROM_BIN_FILES := $(wildcard $(EXTRACTED_DIR)/baserom/*)

# source files
C_FILES := $(filter-out %.inc.c,$(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS),$(wildcard $(dir)/*.c)))
SRC_C_FILES := $(filter-out %.inc.c,$(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)))
ASSET_C_FILES := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.c)))
S_FILES := $(foreach dir,$(SRC_DIRS) $(UNDECOMPILED_DATA_DIRS),$(wildcard $(dir)/*.s))
O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \
$(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \
$(foreach f,$(SRC_C_FILES:.c=.o),$(BUILD_DIR)/$f) \
$(foreach f,$(ASSET_C_FILES:.c=.o),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \
$(foreach f,$(BASEROM_BIN_FILES),$(BUILD_DIR)/baserom/$(notdir $f).o)
UCODE_PATCHES := $(wildcard F3DEX3/*.bps)
UCODE_FILES := $(foreach f,$(UCODE_PATCHES:.bps=),$f)
Expand All @@ -308,11 +320,11 @@ DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d)

TEXTURE_FILES_PNG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.png))
TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg))
TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),$(BUILD_DIR)/$f) \
$(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),$(BUILD_DIR)/$f) \
TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) \
$(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%))

# create build directories
$(shell mkdir -p $(BUILD_DIR)/baserom $(EXTRACTED_DIR)/text $(BUILD_DIR)/assets/text $(foreach dir,$(SRC_DIRS) $(UNDECOMPILED_DATA_DIRS) $(ASSET_BIN_DIRS),$(BUILD_DIR)/$(dir)))
$(shell mkdir -p $(BUILD_DIR)/baserom $(BUILD_DIR)/assets/text $(foreach dir,$(SRC_DIRS) $(UNDECOMPILED_DATA_DIRS),$(BUILD_DIR)/$(dir)) $(foreach dir,$(ASSET_BIN_DIRS),$(dir:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)))

ifeq ($(COMPILER),gcc)
# Note that if adding additional assets directories for modding reasons these flags must also be used there
Expand Down Expand Up @@ -363,7 +375,7 @@ all: rom

rom:
$(call print,Building the rom...)
$(V)python3 tools/mod_assets.py
$(V)python3 tools/mod_assets.py --oot-version $(VERSION)
$(V)$(MAKE) $(ROM)

compress:
Expand Down Expand Up @@ -402,13 +414,10 @@ clean:
$(call print,Success!)

assetclean:
$(V)$(RM) -r $(ASSET_BIN_DIRS)
$(V)$(RM) -r $(EXTRACTED_DIR)
$(V)$(RM) -r $(BUILD_DIR)/assets
$(V)$(RM) -r .extracted-assets.json
$(call print,Success!)

distclean: assetclean
distclean:
$(V)$(RM) -r extracted/
$(V)$(RM) -r build/
$(V)$(MAKE) -C tools distclean
Expand All @@ -431,11 +440,8 @@ setup: venv
$(V)$(PYTHON) tools/decompress_baserom.py $(VERSION)
$(call print,Decompressing baserom: Done!)
$(V)$(PYTHON) tools/extract_baserom.py $(BASEROM_DIR)/baserom-decompressed.z64 --oot-version $(VERSION) -o $(EXTRACTED_DIR)/baserom
$(V)$(PYTHON) tools/msgdis.py --oot-version $(VERSION) --text-out $(EXTRACTED_DIR)/text/message_data.h --staff-text-out $(EXTRACTED_DIR)/text/message_data_staff.h
# TODO: for now, we only extract assets from the Debug ROM
ifneq ($(VERSION),gc-eu-mq)
$(V)$(PYTHON) extract_assets.py -j$(N_THREADS) -v $(VERSION)
endif
$(V)$(PYTHON) tools/msgdis.py $(VERSION)
$(V)$(PYTHON) extract_assets.py -v $(VERSION) -j$(N_THREADS)
$(call print,Extracting files: Done!)
ifeq ($(VERSION),hackeroot-mq)
# TODO: proper fix (for .s files)
Expand Down Expand Up @@ -540,19 +546,29 @@ $(BUILD_DIR)/data/%.o: data/%.s
$(call print,Assembling:,$<,$@)
$(V)$(AS) $(ASFLAGS) $< -o $@

$(BUILD_DIR)/assets/text/%.enc.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h assets/text/charmap.txt
$(BUILD_DIR)/assets/text/%.enc.jpn.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h assets/text/charmap.txt
$(call print,Encoding:,$<,$@)
$(V)$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py --encoding jpn --charmap assets/text/charmap.txt - $@

$(BUILD_DIR)/assets/text/%.enc.nes.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h assets/text/charmap.txt
$(call print,Encoding:,$<,$@)
$(V)$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py - --output $@ --charmap assets/text/charmap.txt
$(V)$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py --encoding nes --charmap assets/text/charmap.txt - $@

# Dependencies for files including message data headers
# TODO remove when full header dependencies are used.
$(BUILD_DIR)/assets/text/fra_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.h
$(BUILD_DIR)/assets/text/ger_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.h
$(BUILD_DIR)/assets/text/nes_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.h
$(BUILD_DIR)/assets/text/staff_message_data_static.o: $(BUILD_DIR)/assets/text/message_data_staff.enc.h
$(BUILD_DIR)/src/code/z_message_PAL.o: $(BUILD_DIR)/assets/text/message_data.enc.h $(BUILD_DIR)/assets/text/message_data_staff.enc.h
$(BUILD_DIR)/assets/text/jpn_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.jpn.h
$(BUILD_DIR)/assets/text/nes_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/ger_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/fra_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/staff_message_data_static.o: $(BUILD_DIR)/assets/text/message_data_staff.enc.nes.h
$(BUILD_DIR)/src/code/z_message.o: assets/text/message_data.h assets/text/message_data_staff.h

$(BUILD_DIR)/assets/text/%.o: assets/text/%.c
$(call print,Compiling:,$<,$@)
$(V)$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
$(V)$(OBJCOPY) -O binary -j.rodata $@ $@.bin

$(BUILD_DIR)/assets/%.o: assets/%.c
$(BUILD_DIR)/assets/%.o: $(EXTRACTED_DIR)/assets/%.c
$(call print,Compiling:,$<,$@)
$(V)$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
$(V)$(OBJCOPY) -O binary $@ $@.bin
Expand Down Expand Up @@ -609,13 +625,13 @@ $(BUILD_DIR)/src/overlays/%_reloc.o: $(BUILD_DIR)/$(SPEC)
$(V)$(FADO) $$(tools/reloc_prereq $< $(notdir $*)) -n $(notdir $*) -o $(@:.o=.s) -M $(@:.o=.d)
$(V)$(AS) $(ASFLAGS) $(@:.o=.s) -o $@

$(BUILD_DIR)/%.inc.c: %.png
$(BUILD_DIR)/assets/%.inc.c: $(EXTRACTED_DIR)/assets/%.png
$(V)$(ZAPD) btex -eh -tt $(subst .,,$(suffix $*)) -i $< -o $@

$(BUILD_DIR)/assets/%.bin.inc.c: assets/%.bin
$(BUILD_DIR)/assets/%.bin.inc.c: $(EXTRACTED_DIR)/assets/%.bin
$(V)$(ZAPD) bblb -eh -i $< -o $@

$(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg
$(BUILD_DIR)/assets/%.jpg.inc.c: $(EXTRACTED_DIR)/assets/%.jpg
$(V)$(ZAPD) bren -eh -i $< -o $@

F3DEX3/f3dzex2.code:
Expand Down
7 changes: 0 additions & 7 deletions assets/.gitignore

This file was deleted.

100 changes: 54 additions & 46 deletions assets/text/charmap.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
# Determines how certain text sequences should be encoded. The text sequence is
# converted to either the first or second tuple element based on whether the
# target encoding is the "wide" encoding. The first element is for the non-wide
# encoding, used for all languages besides JP, while the second element is for
# the wide encoding, used for JP.
{
'\n' : 0x01,
'\n' : (0x01, 0x000A),

'‾' : 0x7F,
'À' : 0x80,
'î' : 0x81,
'Â' : 0x82,
'Ä' : 0x83,
'Ç' : 0x84,
'È' : 0x85,
'É' : 0x86,
'Ê' : 0x87,
'Ë' : 0x88,
'Ï' : 0x89,
'Ô' : 0x8A,
'Ö' : 0x8B,
'Ù' : 0x8C,
'Û' : 0x8D,
'Ü' : 0x8E,
'ß' : 0x8F,
'à' : 0x90,
'á' : 0x91,
'â' : 0x92,
'ä' : 0x93,
'ç' : 0x94,
'è' : 0x95,
'é' : 0x96,
'ê' : 0x97,
'ë' : 0x98,
'ï' : 0x99,
'ô' : 0x9A,
'ö' : 0x9B,
'ù' : 0x9C,
'û' : 0x9D,
'ü' : 0x9E,
'[A]' : (0x9F, 0x839F),
'[B]' : (0xA0, 0x83A0),
'[C]' : (0xA1, 0x83A1),
'[L]' : (0xA2, 0x83A2),
'[R]' : (0xA3, 0x83A3),
'[Z]' : (0xA4, 0x83A4),
'[C-Up]' : (0xA5, 0x83A5),
'[C-Down]' : (0xA6, 0x83A6),
'[C-Left]' : (0xA7, 0x83A7),
'[C-Right]' : (0xA8, 0x83A8),
'▼' : (0xA9, 0x83A9),
'[Control-Pad]' : (0xAA, 0x83AA),
'[D-Pad]' : (0xAB, None),

'[A]' : 0x9F,
'[B]' : 0xA0,
'[C]' : 0xA1,
'[L]' : 0xA2,
'[R]' : 0xA3,
'[Z]' : 0xA4,
'[C-Up]' : 0xA5,
'[C-Down]' : 0xA6,
'[C-Left]' : 0xA7,
'[C-Right]' : 0xA8,
'▼' : 0xA9,
'[Control-Pad]' : 0xAA,
'[D-Pad]' : 0xAB,
# Possibly from a SHIFT-JIS extension, python doesn't have builtin support
'┯' : (None, 0x86D3),

'‾' : (0x7F, None),
'À' : (0x80, None),
'î' : (0x81, None),
'Â' : (0x82, None),
'Ä' : (0x83, None),
'Ç' : (0x84, None),
'È' : (0x85, None),
'É' : (0x86, None),
'Ê' : (0x87, None),
'Ë' : (0x88, None),
'Ï' : (0x89, None),
'Ô' : (0x8A, None),
'Ö' : (0x8B, None),
'Ù' : (0x8C, None),
'Û' : (0x8D, None),
'Ü' : (0x8E, None),
'ß' : (0x8F, None),
'à' : (0x90, None),
'á' : (0x91, None),
'â' : (0x92, None),
'ä' : (0x93, None),
'ç' : (0x94, None),
'è' : (0x95, None),
'é' : (0x96, None),
'ê' : (0x97, None),
'ë' : (0x98, None),
'ï' : (0x99, None),
'ô' : (0x9A, None),
'ö' : (0x9B, None),
'ù' : (0x9C, None),
'û' : (0x9D, None),
'ü' : (0x9E, None),
}
15 changes: 11 additions & 4 deletions assets/text/fra_message_data_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

#include "message_data_fmt.h"

#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
const char _message_##textId##_fra[sizeof(fraMessage)] = { fraMessage END };
#define DEFINE_MESSAGE(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
const char _message_##textId##_fra[] = fraMessage;

#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage)
#define DEFINE_MESSAGE_NES(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Present */ const char _message_##textId##_fra[] = fraMessage;
#define DEFINE_MESSAGE_JPN(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Not Present */

#include "assets/text/message_data.enc.h"
// Font Message
#define DEFINE_MESSAGE_FFFC(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Not Present */

#include "assets/text/message_data.enc.nes.h"
15 changes: 11 additions & 4 deletions assets/text/ger_message_data_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

#include "message_data_fmt.h"

#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
const char _message_##textId##_ger[sizeof(gerMessage)] = { gerMessage END };
#define DEFINE_MESSAGE(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
const char _message_##textId##_ger[] = gerMessage;

#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage)
#define DEFINE_MESSAGE_NES(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Present */ const char _message_##textId##_ger[] = gerMessage;
#define DEFINE_MESSAGE_JPN(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Not Present */

#include "assets/text/message_data.enc.h"
// Font Message
#define DEFINE_MESSAGE_FFFC(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Not Present */

#include "assets/text/message_data.enc.nes.h"
17 changes: 17 additions & 0 deletions assets/text/jpn_message_data_static.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#define MESSAGE_DATA_STATIC
#define MESSAGE_WCHAR
#include "message_data_fmt.h"

#define DEFINE_MESSAGE(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
const char _message_##textId##_jpn[] = jpnMessage;

#define DEFINE_MESSAGE_NES(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Not Present */
#define DEFINE_MESSAGE_JPN(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Present */ const char _message_##textId##_jpn[] = jpnMessage;

// Font Message
#define DEFINE_MESSAGE_FFFC(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Present */ const char _message_##textId##_jpn[] = jpnMessage;

#include "assets/text/message_data.enc.jpn.h"
Loading

0 comments on commit c0d126a

Please sign in to comment.