mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-29 03:34:07 +00:00
Introduce extracted/VERSION, with text extracted there (#1730)
* Introduce assets/_extracted/VERSION, with text extracted there * move to `extracted/text/` * Update gitignore s * rework args for msgenc.py * put mkdir with others, until theyre all moved at once * move 0xFFFC back to being extracted, making it use specific macro `DEFINE_MESSAGE_NES` to handle its special behavior * prettier gitignore * Move messages 0xFFFC, 0xFFFD to committed message_data.h
This commit is contained in:
parent
ca45c543f6
commit
a6f646dc65
13 changed files with 88 additions and 34 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -51,6 +51,7 @@ graphs/
|
||||||
*.fbx
|
*.fbx
|
||||||
!*_custom*
|
!*_custom*
|
||||||
.extracted-assets.json
|
.extracted-assets.json
|
||||||
|
extracted/
|
||||||
|
|
||||||
# Docs
|
# Docs
|
||||||
!docs/tutorial/
|
!docs/tutorial/
|
||||||
|
|
13
Makefile
13
Makefile
|
@ -66,6 +66,7 @@ PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
BUILD_DIR := build/$(VERSION)
|
BUILD_DIR := build/$(VERSION)
|
||||||
EXPECTED_DIR := expected/$(BUILD_DIR)
|
EXPECTED_DIR := expected/$(BUILD_DIR)
|
||||||
BASEROM_DIR := baseroms/$(VERSION)
|
BASEROM_DIR := baseroms/$(VERSION)
|
||||||
|
EXTRACTED_DIR := extracted/$(VERSION)
|
||||||
VENV := .venv
|
VENV := .venv
|
||||||
|
|
||||||
MAKE = make
|
MAKE = make
|
||||||
|
@ -130,7 +131,7 @@ NM := $(MIPS_BINUTILS_PREFIX)nm
|
||||||
|
|
||||||
N64_EMULATOR ?=
|
N64_EMULATOR ?=
|
||||||
|
|
||||||
INC := -Iinclude -Iinclude/libc -Isrc -I$(BUILD_DIR) -I.
|
INC := -Iinclude -Iinclude/libc -Isrc -I$(BUILD_DIR) -I. -I$(EXTRACTED_DIR)
|
||||||
|
|
||||||
# Check code syntax with host compiler
|
# Check code syntax with host compiler
|
||||||
CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces
|
CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces
|
||||||
|
@ -230,7 +231,7 @@ TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),$(BUILD_DIR)/$
|
||||||
$(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),$(BUILD_DIR)/$f) \
|
$(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),$(BUILD_DIR)/$f) \
|
||||||
|
|
||||||
# create build directories
|
# create build directories
|
||||||
$(shell mkdir -p $(BUILD_DIR)/baserom $(BUILD_DIR)/assets/text $(foreach dir,$(SRC_DIRS) $(UNDECOMPILED_DATA_DIRS) $(ASSET_BIN_DIRS),$(BUILD_DIR)/$(dir)))
|
$(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)))
|
||||||
|
|
||||||
ifeq ($(COMPILER),ido)
|
ifeq ($(COMPILER),ido)
|
||||||
$(BUILD_DIR)/src/boot/stackcheck.o: OPTFLAGS := -O2
|
$(BUILD_DIR)/src/boot/stackcheck.o: OPTFLAGS := -O2
|
||||||
|
@ -345,7 +346,7 @@ clean:
|
||||||
|
|
||||||
assetclean:
|
assetclean:
|
||||||
$(RM) -r $(ASSET_BIN_DIRS)
|
$(RM) -r $(ASSET_BIN_DIRS)
|
||||||
$(RM) -r assets/text/*.h
|
$(RM) -r $(EXTRACTED_DIR)
|
||||||
$(RM) -r $(BUILD_DIR)/assets
|
$(RM) -r $(BUILD_DIR)/assets
|
||||||
$(RM) -r .extracted-assets.json
|
$(RM) -r .extracted-assets.json
|
||||||
|
|
||||||
|
@ -367,7 +368,7 @@ setup: venv
|
||||||
# TODO: for now, we only extract assets from the Debug ROM
|
# TODO: for now, we only extract assets from the Debug ROM
|
||||||
ifeq ($(VERSION),gc-eu-mq-dbg)
|
ifeq ($(VERSION),gc-eu-mq-dbg)
|
||||||
$(PYTHON) extract_assets.py -j$(N_THREADS)
|
$(PYTHON) extract_assets.py -j$(N_THREADS)
|
||||||
$(PYTHON) tools/msgdis.py --text-out assets/text/message_data.h --staff-text-out assets/text/message_data_staff.h
|
$(PYTHON) tools/msgdis.py --text-out $(EXTRACTED_DIR)/text/message_data.h --staff-text-out $(EXTRACTED_DIR)/text/message_data_staff.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
disasm:
|
disasm:
|
||||||
|
@ -423,8 +424,8 @@ $(BUILD_DIR)/baserom/%.o: $(BASEROM_SEGMENTS_DIR)/%
|
||||||
$(BUILD_DIR)/data/%.o: data/%.s
|
$(BUILD_DIR)/data/%.o: data/%.s
|
||||||
$(AS) $(ASFLAGS) $< -o $@
|
$(AS) $(ASFLAGS) $< -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/assets/text/%.enc.h: assets/text/%.h assets/text/charmap.txt
|
$(BUILD_DIR)/assets/text/%.enc.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h assets/text/charmap.txt
|
||||||
$(PYTHON) tools/msgenc.py assets/text/charmap.txt $< $@
|
$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py - --output $@ --charmap assets/text/charmap.txt
|
||||||
|
|
||||||
# Dependencies for files including message data headers
|
# Dependencies for files including message data headers
|
||||||
# TODO remove when full header dependencies are used.
|
# TODO remove when full header dependencies are used.
|
||||||
|
|
2
assets/.gitignore
vendored
2
assets/.gitignore
vendored
|
@ -1,7 +1,7 @@
|
||||||
*.bin
|
*.bin
|
||||||
*.c
|
*.c
|
||||||
!text/*.c
|
|
||||||
*.h
|
*.h
|
||||||
|
!text/*.[ch]
|
||||||
*.cfg
|
*.cfg
|
||||||
*.vtx.inc
|
*.vtx.inc
|
||||||
*.dlist.inc
|
*.dlist.inc
|
||||||
|
|
|
@ -5,4 +5,6 @@
|
||||||
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
||||||
const char _message_##textId##_fra[sizeof(fraMessage)] = { fraMessage END };
|
const char _message_##textId##_fra[sizeof(fraMessage)] = { fraMessage END };
|
||||||
|
|
||||||
|
#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage)
|
||||||
|
|
||||||
#include "assets/text/message_data.enc.h"
|
#include "assets/text/message_data.enc.h"
|
||||||
|
|
|
@ -5,4 +5,6 @@
|
||||||
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
||||||
const char _message_##textId##_ger[sizeof(gerMessage)] = { gerMessage END };
|
const char _message_##textId##_ger[sizeof(gerMessage)] = { gerMessage END };
|
||||||
|
|
||||||
|
#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage)
|
||||||
|
|
||||||
#include "assets/text/message_data.enc.h"
|
#include "assets/text/message_data.enc.h"
|
||||||
|
|
16
assets/text/message_data.h
Normal file
16
assets/text/message_data.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include "text/message_data.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following two messages should be kept last and in this order.
|
||||||
|
* Message 0xFFFD must be last to not break the message debugger (see R_MESSAGE_DEBUGGER_TEXTID).
|
||||||
|
* Message 0xFFFC must be immediately before message 0xFFFD to not break Font_LoadOrderedFont.
|
||||||
|
*/
|
||||||
|
DEFINE_MESSAGE_NES(0xFFFC, TEXTBOX_TYPE_BLACK, TEXTBOX_POS_VARIABLE,
|
||||||
|
"0123456789\n"
|
||||||
|
"ABCDEFGHIJKLMN\n"
|
||||||
|
"OPQRSTUVWXYZ\n"
|
||||||
|
"abcdefghijklmn\n"
|
||||||
|
"opqrstuvwxyz\n"
|
||||||
|
" -.\n"
|
||||||
|
)
|
||||||
|
DEFINE_MESSAGE(0xFFFD, TEXTBOX_TYPE_BLACK, TEXTBOX_POS_VARIABLE, "", "", "")
|
1
assets/text/message_data_staff.h
Normal file
1
assets/text/message_data_staff.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "text/message_data_staff.h"
|
|
@ -5,8 +5,6 @@
|
||||||
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
||||||
const char _message_##textId##_nes[sizeof(nesMessage)] = { nesMessage END };
|
const char _message_##textId##_nes[sizeof(nesMessage)] = { nesMessage END };
|
||||||
|
|
||||||
#define DEFINE_MESSAGE_FFFC
|
#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage) DEFINE_MESSAGE(textId, type, yPos, nesMessage, , )
|
||||||
|
|
||||||
#include "assets/text/message_data.enc.h"
|
#include "assets/text/message_data.enc.h"
|
||||||
|
|
||||||
#undef DEFINE_MESSAGE_FFFC
|
|
||||||
|
|
|
@ -48,11 +48,12 @@ You can create a `.vscode/c_cpp_properties.json` file with `C/C++: Edit Configur
|
||||||
],
|
],
|
||||||
"intelliSenseMode": "${default}", // Shouldn't matter
|
"intelliSenseMode": "${default}", // Shouldn't matter
|
||||||
"includePath": [ // Matches makefile's includes
|
"includePath": [ // Matches makefile's includes
|
||||||
"${workspaceFolder}/**",
|
"include",
|
||||||
|
"include/libc",
|
||||||
"src",
|
"src",
|
||||||
"build/gc-eu-mq-dbg",
|
"build/gc-eu-mq-dbg",
|
||||||
"include",
|
".",
|
||||||
"include/libc"
|
"extracted/gc-eu-mq-dbg"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"_LANGUAGE_C", // For gbi.h
|
"_LANGUAGE_C", // For gbi.h
|
||||||
|
|
|
@ -47,9 +47,12 @@ typedef struct {
|
||||||
extern const char _message_##textId##_ger[]; \
|
extern const char _message_##textId##_ger[]; \
|
||||||
extern const char _message_##textId##_fra[];
|
extern const char _message_##textId##_fra[];
|
||||||
|
|
||||||
|
#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage) \
|
||||||
|
extern const char _message_##textId##_nes[];
|
||||||
|
|
||||||
#include "assets/text/message_data.h"
|
#include "assets/text/message_data.h"
|
||||||
extern const char _message_0xFFFC_nes[];
|
|
||||||
|
|
||||||
#undef DEFINE_MESSAGE
|
#undef DEFINE_MESSAGE
|
||||||
|
#undef DEFINE_MESSAGE_NES
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,24 +30,28 @@ u16 sOcarinaSongBitFlags = 0; // ocarina bit flags
|
||||||
MessageTableEntry sNesMessageEntryTable[] = {
|
MessageTableEntry sNesMessageEntryTable[] = {
|
||||||
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) \
|
||||||
{ textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_nes },
|
{ textId, (_SHIFTL(type, 4, 8) | _SHIFTL(yPos, 0, 8)), _message_##textId##_nes },
|
||||||
#define DEFINE_MESSAGE_FFFC
|
#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage) DEFINE_MESSAGE(textId, type, yPos, nesMessage, , )
|
||||||
#include "assets/text/message_data.h"
|
#include "assets/text/message_data.h"
|
||||||
#undef DEFINE_MESSAGE_FFFC
|
|
||||||
#undef DEFINE_MESSAGE
|
#undef DEFINE_MESSAGE
|
||||||
|
#undef DEFINE_MESSAGE_NES
|
||||||
{ 0xFFFF, 0, NULL },
|
{ 0xFFFF, 0, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* sGerMessageEntryTable[] = {
|
const char* sGerMessageEntryTable[] = {
|
||||||
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) _message_##textId##_ger,
|
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) _message_##textId##_ger,
|
||||||
|
#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage)
|
||||||
#include "assets/text/message_data.h"
|
#include "assets/text/message_data.h"
|
||||||
#undef DEFINE_MESSAGE
|
#undef DEFINE_MESSAGE
|
||||||
|
#undef DEFINE_MESSAGE_NES
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* sFraMessageEntryTable[] = {
|
const char* sFraMessageEntryTable[] = {
|
||||||
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) _message_##textId##_fra,
|
#define DEFINE_MESSAGE(textId, type, yPos, nesMessage, gerMessage, fraMessage) _message_##textId##_fra,
|
||||||
|
#define DEFINE_MESSAGE_NES(textId, type, yPos, nesMessage)
|
||||||
#include "assets/text/message_data.h"
|
#include "assets/text/message_data.h"
|
||||||
#undef DEFINE_MESSAGE
|
#undef DEFINE_MESSAGE
|
||||||
|
#undef DEFINE_MESSAGE_NES
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -376,20 +376,26 @@ def extract_all_text(text_out, staff_text_out):
|
||||||
if text_out is not None:
|
if text_out is not None:
|
||||||
out = ""
|
out = ""
|
||||||
for message in dump_all_text():
|
for message in dump_all_text():
|
||||||
if message[0] == 0xFFFF:
|
# Skip 0xFFFC and 0xFFFD because they are committed
|
||||||
|
# Skip 0xFFFF, the last entry
|
||||||
|
if message[0] in {0xFFFC, 0xFFFD, 0xFFFF}:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if message[0] == 0xFFFC:
|
is_nes_message = message[0] == 0xFFFC
|
||||||
out += "#ifdef DEFINE_MESSAGE_FFFC\n"
|
if not is_nes_message:
|
||||||
out += f"DEFINE_MESSAGE(0x{message[0]:04X}, {textbox_type[message[1]]}, {textbox_ypos[message[2]]},"
|
out += "DEFINE_MESSAGE"
|
||||||
|
else:
|
||||||
|
out += "DEFINE_MESSAGE_NES"
|
||||||
|
out += f"(0x{message[0]:04X}, {textbox_type[message[1]]}, {textbox_ypos[message[2]]},"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
out += f"{message[3]}" + ("\n" if message[3] != "" else "") + ","
|
out += f"{message[3]}"
|
||||||
out += "\n" if message[3] != "" else ""
|
if not is_nes_message:
|
||||||
out += f"{message[4]}" + ("\n" if message[4] != "" else "") + ","
|
out += ("\n" if message[3] != "" else "") + ","
|
||||||
out += "\n" if message[4] != "" else ""
|
out += "\n" if message[3] != "" else ""
|
||||||
out += f"{message[5]}\n)"
|
out += f"{message[4]}" + ("\n" if message[4] != "" else "") + ","
|
||||||
if message[0] == 0xFFFC:
|
out += "\n" if message[4] != "" else ""
|
||||||
out += "\n#endif"
|
out += f"{message[5]}"
|
||||||
|
out += "\n)"
|
||||||
out += "\n\n"
|
out += "\n\n"
|
||||||
|
|
||||||
with open(text_out, "w", encoding="utf8") as outfile:
|
with open(text_out, "w", encoding="utf8") as outfile:
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import argparse, ast, re
|
import argparse, ast, re
|
||||||
|
import sys
|
||||||
|
|
||||||
def read_charmap(path):
|
def read_charmap(path):
|
||||||
with open(path) as infile:
|
with open(path) as infile:
|
||||||
|
@ -50,22 +51,40 @@ def convert_text(text, charmap):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Encode message_data_static text headers")
|
parser = argparse.ArgumentParser(description="Encode message_data_static text headers")
|
||||||
parser.add_argument("charmap", help="path to charmap file specifying custom encoding elements")
|
parser.add_argument(
|
||||||
parser.add_argument("input", help="path to file to be encoded")
|
"input",
|
||||||
parser.add_argument("output", help="encoded file")
|
help="path to file to be encoded, or - for stdin",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output",
|
||||||
|
"-o",
|
||||||
|
help="path to write encoded file, or - for stdout",
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--charmap",
|
||||||
|
help="path to charmap file specifying custom encoding elements",
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
charmap = read_charmap(args.charmap)
|
charmap = read_charmap(args.charmap)
|
||||||
|
|
||||||
text = ""
|
text = ""
|
||||||
with open(args.input, "r") as infile:
|
if args.input == "-":
|
||||||
text = infile.read()
|
text = sys.stdin.read()
|
||||||
|
else:
|
||||||
|
with open(args.input, "r") as infile:
|
||||||
|
text = infile.read()
|
||||||
|
|
||||||
text = remove_comments(text)
|
text = remove_comments(text)
|
||||||
text = convert_text(text, charmap)
|
text = convert_text(text, charmap)
|
||||||
|
|
||||||
with open(args.output, "w", encoding="raw_unicode_escape") as outfile:
|
if args.output == "-":
|
||||||
outfile.write(text)
|
sys.stdout.buffer.write(text.encode("raw_unicode_escape"))
|
||||||
|
else:
|
||||||
|
with open(args.output, "w", encoding="raw_unicode_escape") as outfile:
|
||||||
|
outfile.write(text)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue