diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2021-10-24 13:21:52 +0200 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2021-10-24 13:21:52 +0200 |
| commit | a924f2821bc2eb29fa5fa6300de93d22df98c702 (patch) | |
| tree | bd711a4430435cfe5b757aad12e38cf20757811c /tools | |
| parent | fdfd43d0d31feeda3082227bcfae7d32abc663f6 (diff) | |
Extract exit lists
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/asset_extractor/asset_extractor.py | 4 | ||||
| -rw-r--r-- | tools/asset_extractor/assets/exit_list.py | 41 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tools/asset_extractor/asset_extractor.py b/tools/asset_extractor/asset_extractor.py index 35e4404a..241dadc8 100644 --- a/tools/asset_extractor/asset_extractor.py +++ b/tools/asset_extractor/asset_extractor.py @@ -11,6 +11,7 @@ from assets.fixed_type_gfx import FixedTypeGfx from assets.frame_obj_lists import FrameObjLists from assets.extra_frame_offsets import ExtraFrameOffsets from assets.animation import Animation +from assets.exit_list import ExitList verbose = False @@ -130,6 +131,9 @@ def extract_assets(variant, assets_folder): elif mode == 'animation': animation = Animation(path, start, size, options) animation.extract_binary(baserom) + elif mode == 'exit_list': + exit_list = ExitList(path, start, size, options) + exit_list.extract_binary(baserom) elif mode != '': print(f'Asset type {mode} not yet implemented') diff --git a/tools/asset_extractor/assets/exit_list.py b/tools/asset_extractor/assets/exit_list.py new file mode 100644 index 00000000..471fd61c --- /dev/null +++ b/tools/asset_extractor/assets/exit_list.py @@ -0,0 +1,41 @@ +from assets.base import BaseAsset, Reader + +class ExitList(BaseAsset): + def __init__(self, path: str, addr: int, size: int, options: any) -> None: + super().__init__(path, addr, size, options) + + def extract_binary(self, rom: bytearray) -> None: + reader = Reader(rom[self.addr:self.addr+self.size]) + + lines = [] + + while reader.cursor < self.size: + transition_type = reader.read_u16() + x_pos = reader.read_u16() + y_pos = reader.read_u16() + dest_x = reader.read_u16() + dest_y = reader.read_u16() + screen_edge = reader.read_u8() + dest_area = reader.read_u8() + dest_room = reader.read_u8() + unknown_2 = reader.read_u8() + unknown_3 = reader.read_u8() + unknown_4 = reader.read_u8() + unknown_5 = reader.read_u16() + padding_1 = reader.read_u16() + if transition_type == 0xffff: + lines.append(f'\t.2byte 0xffff, 0, 0, 0,0,0,0,0,0,0 @ terminator\n') + break + lines.append(f'\t.2byte {transition_type} @ transition_type\n') + lines.append(f'\t.2byte {x_pos}, {y_pos} @ pos\n') + lines.append(f'\t.2byte {dest_x}, {dest_y} @ dest\n') + lines.append(f'\t.byte {screen_edge} @ screen edge\n') + lines.append(f'\t.byte {dest_area} @ screen edge\n') + lines.append(f'\t.byte {dest_room} @ screen edge\n') + lines.append(f'\t.byte {unknown_2}, {unknown_3}, {unknown_4} @ unknown\n') + lines.append(f'\t.2byte {unknown_5}, {padding_1} @ unknown\n') + + assert(self.path.endswith('.bin')) + path = self.path[0:-4] + '.s' + with open(path, 'w') as file: + file.writelines(lines)
\ No newline at end of file |
