mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-15 06:06:04 +00:00
Hacks for building nes_font_static and nes_message_data_static with gc-eu-mq (#1721)
* Hack nes_font_static and nes_message_data_static * Make hardcoded config a bit more consistent * Put debug ROM first * Reword comment * Move nes_font_static hack to spec * Restore extracted/gc-eu-mq
This commit is contained in:
parent
feb64e6ad8
commit
0407594107
3 changed files with 44 additions and 17 deletions
6
Makefile
6
Makefile
|
@ -67,10 +67,6 @@ BUILD_DIR := build/$(VERSION)
|
|||
EXPECTED_DIR := expected/$(BUILD_DIR)
|
||||
BASEROM_DIR := baseroms/$(VERSION)
|
||||
EXTRACTED_DIR := extracted/$(VERSION)
|
||||
ifeq ($(VERSION),gc-eu-mq)
|
||||
# TODO: for now, we only extract assets from the Debug ROM (see setup rule)
|
||||
EXTRACTED_DIR := extracted/gc-eu-mq-dbg
|
||||
endif
|
||||
VENV := .venv
|
||||
|
||||
MAKE = make
|
||||
|
@ -369,10 +365,10 @@ setup: venv
|
|||
$(MAKE) -C tools
|
||||
$(PYTHON) tools/decompress_baserom.py $(VERSION)
|
||||
$(PYTHON) tools/extract_baserom.py $(BASEROM_DIR)/baserom-decompressed.z64 -o $(BASEROM_SEGMENTS_DIR) --dmadata-start `cat $(BASEROM_DIR)/dmadata_start.txt` --dmadata-names $(BASEROM_DIR)/dmadata_names.txt
|
||||
$(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
|
||||
ifeq ($(VERSION),gc-eu-mq-dbg)
|
||||
$(PYTHON) extract_assets.py -j$(N_THREADS)
|
||||
$(PYTHON) tools/msgdis.py --text-out $(EXTRACTED_DIR)/text/message_data.h --staff-text-out $(EXTRACTED_DIR)/text/message_data_staff.h
|
||||
endif
|
||||
|
||||
disasm:
|
||||
|
|
5
spec
5
spec
|
@ -256,7 +256,12 @@ endseg
|
|||
beginseg
|
||||
name "nes_font_static"
|
||||
romalign 0x1000
|
||||
#if OOT_DEBUG
|
||||
include "$(BUILD_DIR)/assets/textures/nes_font_static/nes_font_static.o"
|
||||
#else
|
||||
// TODO: Remove this hack once assets are extracted from gc-eu-mq
|
||||
include "$(BUILD_DIR)/baserom/nes_font_static.o"
|
||||
#endif
|
||||
number 10
|
||||
endseg
|
||||
|
||||
|
|
|
@ -259,12 +259,14 @@ textbox_ypos = {
|
|||
3: "TEXTBOX_POS_BOTTOM",
|
||||
}
|
||||
|
||||
# message entry tables vrom addresses
|
||||
nes_message_entry_table_addr = 0x00BC24C0
|
||||
ger_message_entry_table_addr = 0x00BC66E8
|
||||
fra_message_entry_table_addr = 0x00BC87F8
|
||||
staff_message_entry_table_addr = 0x00BCA908
|
||||
staff_message_entry_table_addr_end = 0x00BCAA90
|
||||
# Global variables for baserom version and message entry table vrom addresses,
|
||||
# set based on command line arguments in main()
|
||||
version = None
|
||||
nes_message_entry_table_addr = None
|
||||
ger_message_entry_table_addr = None
|
||||
fra_message_entry_table_addr = None
|
||||
staff_message_entry_table_addr = None
|
||||
staff_message_entry_table_addr_end = None
|
||||
|
||||
nes_message_entry_table = []
|
||||
ger_message_entry_table = []
|
||||
|
@ -283,7 +285,7 @@ def read_tables():
|
|||
global staff_message_entry_table
|
||||
|
||||
baserom = None
|
||||
with open("baseroms/gc-eu-mq-dbg/baserom-decompressed.z64","rb") as infile:
|
||||
with open(f"baseroms/{version}/baserom-decompressed.z64","rb") as infile:
|
||||
baserom = infile.read()
|
||||
|
||||
nes_message_entry_table = as_message_table_entry(baserom[nes_message_entry_table_addr:ger_message_entry_table_addr])
|
||||
|
@ -327,7 +329,7 @@ def dump_all_text():
|
|||
nes_offset = segmented_to_physical(entry[3])
|
||||
nes_length = next_entry[3] - entry[3]
|
||||
nes_text = ""
|
||||
with open("baseroms/gc-eu-mq-dbg/segments/nes_message_data_static","rb") as infile:
|
||||
with open(f"baseroms/{version}/segments/nes_message_data_static","rb") as infile:
|
||||
infile.seek(nes_offset)
|
||||
nes_text = fixup_message(decode(infile.read(nes_length), entry[1]).replace("\x00","",-1))
|
||||
|
||||
|
@ -338,13 +340,13 @@ def dump_all_text():
|
|||
next_entry = combined_message_entry_table[i+2]
|
||||
ger_offset = segmented_to_physical(entry[4])
|
||||
ger_length = next_entry[4] - entry[4]
|
||||
with open("baseroms/gc-eu-mq-dbg/segments/ger_message_data_static","rb") as infile:
|
||||
with open(f"baseroms/{version}/segments/ger_message_data_static","rb") as infile:
|
||||
infile.seek(ger_offset)
|
||||
ger_text = fixup_message(decode(infile.read(ger_length), entry[1]).replace("\x00","",-1))
|
||||
|
||||
fra_offset = segmented_to_physical(entry[5])
|
||||
fra_length = next_entry[5] - entry[5]
|
||||
with open("baseroms/gc-eu-mq-dbg/segments/fra_message_data_static","rb") as infile:
|
||||
with open(f"baseroms/{version}/segments/fra_message_data_static","rb") as infile:
|
||||
infile.seek(fra_offset)
|
||||
fra_text = fixup_message(decode(infile.read(fra_length), entry[1]).replace("\x00","",-1))
|
||||
|
||||
|
@ -353,7 +355,7 @@ def dump_all_text():
|
|||
return messages
|
||||
|
||||
def dump_staff_text():
|
||||
staff_message_data_static_size = path.getsize("baseroms/gc-eu-mq-dbg/segments/staff_message_data_static")
|
||||
staff_message_data_static_size = path.getsize(f"baseroms/{version}/segments/staff_message_data_static")
|
||||
# text id, ypos, type, staff
|
||||
messages = []
|
||||
for i,entry in enumerate(staff_message_entry_table,0):
|
||||
|
@ -362,7 +364,7 @@ def dump_staff_text():
|
|||
staff_offset = segmented_to_physical(entry[3])
|
||||
# hacky way to ensure the staff message entry table is read all the way to the end
|
||||
staff_length = (staff_message_data_static_size if entry[0] == 0x052F else segmented_to_physical(next_entry[3])) - segmented_to_physical(entry[3])
|
||||
with open("baseroms/gc-eu-mq-dbg/segments/staff_message_data_static","rb") as infile:
|
||||
with open(f"baseroms/{version}/segments/staff_message_data_static","rb") as infile:
|
||||
infile.seek(staff_offset)
|
||||
messages.append((entry[0], entry[1], entry[2], fixup_message(decode(infile.read(staff_length), entry[1]).replace("\x00","",-1))))
|
||||
else:
|
||||
|
@ -414,9 +416,17 @@ def extract_all_text(text_out, staff_text_out):
|
|||
|
||||
|
||||
def main():
|
||||
global version
|
||||
global nes_message_entry_table_addr
|
||||
global ger_message_entry_table_addr
|
||||
global fra_message_entry_table_addr
|
||||
global staff_message_entry_table_addr
|
||||
global staff_message_entry_table_addr_end
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Extract text from the baserom into .h files"
|
||||
)
|
||||
parser.add_argument("--oot-version", help="OOT version", default="gc-eu-mq-dbg", choices=["gc-eu-mq", "gc-eu-mq-dbg"])
|
||||
parser.add_argument("--text-out", help="Path to output .h file for text")
|
||||
parser.add_argument(
|
||||
"--staff-text-out", help="Path to output .h file for staff text"
|
||||
|
@ -426,6 +436,22 @@ def main():
|
|||
if not (args.text_out or args.staff_text_out):
|
||||
parser.error("No output file requested")
|
||||
|
||||
version = args.oot_version
|
||||
if version == "gc-eu-mq-dbg":
|
||||
nes_message_entry_table_addr = 0x00BC24C0
|
||||
ger_message_entry_table_addr = 0x00BC66E8
|
||||
fra_message_entry_table_addr = 0x00BC87F8
|
||||
staff_message_entry_table_addr = 0x00BCA908
|
||||
staff_message_entry_table_addr_end = 0x00BCAA90
|
||||
elif version == "gc-eu-mq":
|
||||
nes_message_entry_table_addr = 0x00B7E8F0
|
||||
ger_message_entry_table_addr = 0x00B82B18
|
||||
fra_message_entry_table_addr = 0x00B84C28
|
||||
staff_message_entry_table_addr = 0x00B86D38
|
||||
staff_message_entry_table_addr_end = 0x00B86EC0
|
||||
else:
|
||||
parser.error("Unsupported OOT version")
|
||||
|
||||
extract_all_text(args.text_out, args.staff_text_out)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue