diff --git a/fast64_internal/sm64/animation/classes.py b/fast64_internal/sm64/animation/classes.py index 85b79ccb6..b348829a4 100644 --- a/fast64_internal/sm64/animation/classes.py +++ b/fast64_internal/sm64/animation/classes.py @@ -6,7 +6,6 @@ from ...utility import PluginError, decodeSegmentedAddr, is_bit_active from ..sm64_constants import MAX_U16 -from ..sm64_utility import SM64_ShortArray from .utility import RomReading, eval_num_from_str from .c_parser import Initialization, ParsedValue @@ -652,6 +651,34 @@ def table_to_c(self, generate_enums: bool): return text_data.getvalue() +class SM64_ShortArray: + def __init__(self, name, signed): + self.name = name + self.data = [] + self.signed = signed + + def to_binary(self): + data = bytearray(0) + for short in self.data: + data += short.to_bytes(2, "big", signed=True) + return data + + def to_c(self): + data = StringIO() + data.write(f"static const {'s' if self.signed else 'u'}16 {self.name}[] = {{\n\t") + + wrap_counter = 0 + for short in self.data: + u_short = int.from_bytes(short.to_bytes(2, "big", signed=True), "big", signed=False) + data.write(f"0x{format(u_short, '04X')}, ") + wrap_counter += 1 + if wrap_counter > 8: + data.write("\n\t") + wrap_counter = 0 + data.write("\n};\n") + return data.getvalue() + + def create_tables(anims_data: list[SM64_AnimData], values_name: str = None): """Can generate multiple indices table with only one value table, which improves compression""" """This feature is used in table exports""" diff --git a/fast64_internal/sm64/sm64_utility.py b/fast64_internal/sm64/sm64_utility.py index bdc6b8864..ee7a83f31 100644 --- a/fast64_internal/sm64/sm64_utility.py +++ b/fast64_internal/sm64/sm64_utility.py @@ -59,31 +59,3 @@ def check_expanded(filepath: str): raise PluginError( f"ROM at {filepath} is too small.\nYou may be using an unexpanded ROM.\nYou can expand a ROM by opening it in SM64 Editor or ROM Manager." ) - - -class SM64_ShortArray: - def __init__(self, name, signed): - self.name = name - self.data = [] - self.signed = signed - - def to_binary(self): - data = bytearray(0) - for short in self.data: - data += short.to_bytes(2, "big", signed=True) - return data - - def to_c(self): - data = StringIO() - data.write(f"static const {'s' if self.signed else 'u'}16 {self.name}[] = {{\n\t") - - wrap_counter = 0 - for short in self.data: - u_short = int.from_bytes(short.to_bytes(2, "big", signed=True), "big", signed=False) - data.write(f"0x{format(u_short, '04X')}, ") - wrap_counter += 1 - if wrap_counter > 8: - data.write("\n\t") - wrap_counter = 0 - data.write("\n};\n") - return data.getvalue()