1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 22:44:30 +00:00

Create Macros for Cutscene Data (#63)

* Added additional (potentially unused) fields to macros, now builds OK

* Ran formatter, attempted better macro formatting

* Formatted unknown fields as hex, further cleanups

* Rename and prefix macros, use command base macros, format cutscenes with indents

* Move command macros into a new file and include it globally

* Generate cutscene command macros for Bg_Toki_Swd, Cleanups

* Rename CS_TEXTBOX commands to CS_TEXT, fix typo ic command_macros_base.h

* Introduce CS_CMD_CONTINUE and CS_CMD_STOP

* Remove apparently redundant arguments in certain commands, include the values in the macros directly

* Re-add cutscene terminator destination enum values to example cutscene data

* Format what should be floats as hex, Change actorAnim to actorAction

* Allow floating-point representation of values in cutscene data (asm-processor hack)

* Include cutscene commands only where necessary, documentation fixes

* Rename actor actions to npc actions, separate player action from npc actions

* Remove PlayerActionIDs for now as relevant information on it is not yet decompiled

* Generate cutscene data for en_ru1, remove apparent redundancies in CS_LIGHTING and CS_PLAY/STOP/FADE_BGM commands, relax static requirement in asm-processor CutsceneData float conversion
This commit is contained in:
Tharo 2020-05-20 12:37:28 +01:00 committed by GitHub
parent 2bccbe7679
commit 43dfaa7518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1538 additions and 506 deletions

View file

@ -7,6 +7,7 @@ import sys
import re
import os
from collections import namedtuple
from io import StringIO
MAX_FN_SIZE = 100
@ -660,6 +661,9 @@ class GlobalAsmBlock:
})
return src, fn
def repl_float_hex(m):
return str(struct.unpack(">I", struct.pack(">f", float(m.group(0).strip().rstrip("f"))))[0])
def parse_source(f, opt, framepointer, input_enc, output_enc, print_source=None):
if opt in ['O2', 'O1']:
if framepointer:
@ -688,6 +692,7 @@ def parse_source(f, opt, framepointer, input_enc, output_enc, print_source=None)
state = GlobalState(min_instr_count, skip_instr_count)
global_asm = None
is_cutscene_data = False
asm_functions = []
output_lines = []
@ -724,15 +729,34 @@ def parse_source(f, opt, framepointer, input_enc, output_enc, print_source=None)
output_lines[-1] = ''.join(src)
asm_functions.append(fn)
global_asm = None
elif ((line.startswith('#include "')) and line.endswith('" EARLY')):
fpath = os.path.dirname(f.name)
fname = line[line.index(' ') + 2 : -7]
include_src = StringIO()
with open(fpath + os.path.sep + fname, encoding=input_enc) as include_file:
parse_source(include_file, opt, framepointer, input_enc, output_enc, include_src)
output_lines[-1] = include_src.getvalue()
include_src.write('#line ' + str(line_no) + '\n')
include_src.close()
else:
if re.compile(r"(CutsceneData (.|\n)*\[\] = {)").search(line) is not None:
is_cutscene_data = True
elif line.endswith("};"):
is_cutscene_data = False
if is_cutscene_data:
raw_line = re.sub(re.compile(r"[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f"), repl_float_hex, raw_line)
output_lines[-1] = raw_line
if print_source:
for line in output_lines:
print_source.write(line.encode(output_enc) + b'\n')
print_source.flush()
if print_source != sys.stdout.buffer:
print_source.close()
if isinstance(print_source, StringIO):
for line in output_lines:
print_source.write(line + '\n')
else:
for line in output_lines:
print_source.write(line.encode(output_enc) + b'\n')
print_source.flush()
if print_source != sys.stdout.buffer:
print_source.close()
return asm_functions