Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port over OoT's new text pipeline #1685

Merged
merged 4 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ setup-audio:

assets:
$(PYTHON) tools/extract_assets.py $(EXTRACTED_DIR)/baserom assets -j$(N_THREADS) -Z Wno-hardcoded-pointer -v $(VERSION)
$(PYTHON) tools/text/msgdis.py $(EXTRACTED_DIR)/baserom assets/text -v $(VERSION)
$(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml

## Assembly generation
Expand Down Expand Up @@ -510,6 +511,11 @@ $(BUILD_DIR)/src/dmadata/dmadata.o: $(BUILD_DIR)/dmadata/dmadata_table_spec.h
$(BUILD_DIR)/%.o: %.s
$(CPP) $(CPPFLAGS) $(IINC) $< | $(AS) $(ASFLAGS) $(IINC) $(ENDIAN) -o $@

$(BUILD_DIR)/assets/text/%.o: assets/text/%.c
# Preprocess text with modern cpp for varargs macros
$(CPP) -undef -D_LANGUAGE_C -D__sgi $(CPPFLAGS) $(IINC) $< -o $(@:.o=.c)
$(CC) -c $(CFLAGS) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $(@:.o=.c)

$(BUILD_DIR)/assets/%.o: assets/%.c
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $@ $<
$(OBJCOPY_BIN)
Expand All @@ -522,15 +528,15 @@ $(BUILD_DIR)/%.yar.o: $(BUILD_DIR)/%.o
$(BUILD_DIR)/baserom/%.o: $(EXTRACTED_DIR)/baserom/%
$(OBJCOPY) -I binary -O elf32-big $< $@

$(BUILD_DIR)/assets/text/message_data.enc.h: assets/text/message_data.h
$(PYTHON) tools/msg/nes/msgencNES.py -o $@ $<
$(BUILD_DIR)/assets/text/message_data.enc.h: assets/text/message_data.h assets/text/charmap.txt
$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/text/msgenc.py --encoding nes --charmap assets/text/charmap.txt - $@

$(BUILD_DIR)/assets/text/staff_message_data.enc.h: assets/text/staff_message_data.h
$(PYTHON) tools/msg/staff/msgencStaff.py -o $@ $<
$(BUILD_DIR)/assets/text/message_data_staff.enc.h: assets/text/message_data_staff.h assets/text/charmap.txt
$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/text/msgenc.py --encoding credits --charmap assets/text/charmap.txt - $@

$(BUILD_DIR)/assets/text/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/staff_message_data.enc.h
$(BUILD_DIR)/src/code/z_message.o: $(BUILD_DIR)/assets/text/message_data.enc.h $(BUILD_DIR)/assets/text/staff_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.o: $(BUILD_DIR)/assets/text/message_data.enc.h $(BUILD_DIR)/assets/text/message_data_staff.enc.h

$(BUILD_DIR)/src/overlays/%_reloc.o: $(BUILD_DIR)/$(SPEC)
$(FADO) $$(tools/buildtools/reloc_prereq $< $(*F)) -n $(*F) -o $(@:.o=.s) -M $(@:.o=.d)
Expand Down
21 changes: 21 additions & 0 deletions assets/text/charmap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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, the third element is for encoding credits.
hensldm marked this conversation as resolved.
Show resolved Hide resolved
{
'\n' : (0x11, 0x000A, 0x01),

'[A]' : (0xB0, 0x839F, None),
'[B]' : (0xB1, 0x83A0, None),
'[C]' : (0xB2, 0x83A1, None),
'[L]' : (0xB3, 0x83A2, None),
'[R]' : (0xB4, 0x83A3, None),
'[Z]' : (0xB5, 0x83A4, None),
'[C-Up]' : (0xB6, 0x83A5, None),
'[C-Down]' : (0xB7, 0x83A6, None),
'[C-Left]' : (0xB8, 0x83A7, None),
'[C-Right]' : (0xB9, 0x83A8, None),
'▼' : (0xBA, 0x83A9, None),
'[Control-Pad]' : (0xBB, 0x83AA, None),
}
4 changes: 2 additions & 2 deletions assets/text/message_data_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "message_data_fmt_nes.h"

#define DEFINE_MESSAGE(textId, typePos, msg) \
const char _message_##textId[sizeof(msg)] = { msg CMD_END };
#define DEFINE_MESSAGE(textId, type, pos, msg) \
const char _message_##textId[] = msg;

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

Expand Down
6 changes: 3 additions & 3 deletions assets/text/staff_message_data_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "message_data_fmt_staff.h"

#define DEFINE_MESSAGE(textId, typePos, msg) \
const char _message_##textId##_staff[sizeof(msg)] = { msg CMD_END };
#define DEFINE_MESSAGE(textId, type, pos, msg) \
const char _message_##textId##_staff[] = msg;

#include "assets/text/staff_message_data.enc.h"
#include "assets/text/message_data_staff.enc.h"

#undef DEFINE_MESSAGE
Loading