1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-11 03:39:59 +00:00
oot/tools/disasm/file_addresses.py

48 lines
1.3 KiB
Python
Raw Normal View History

Set up disassembly for gc-eu-mq (#1613) * Disassemble gc-eu-mq * Add script to report progress with matching * Fix whitespace * Change T|None to typing.Optional[T] * Use typing.List * More type annotations fixes for old Python versions * Fix type errors * More type annotations * Use typing.Iterator * Use $(PYTHON) for disassembly * Don't use grouped targets to support very old Make versions * Docs: suggest checking MM, mention virtualenv, clarify about expected/ * Update sym_info.py Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * Sync functions.txt * Start banned symbol range at 0x10000000 * Also ban symbols from 0xC0000000-0xFFFFFFFF * Unban IPL symbols * Fix first_diff.py * Sync z_collision_check functions.txt * Ban 0xA0 symbols too * Touch .disasm sentinel file * Copy -jN comment in docs * diff.py flags: remove -3, add -s * Update docs/retail_versions.md Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com> * Comment that segments are still from the Debug ROM * Revert "diff.py flags: remove -3, add -s" This reverts commit bfaae66c1d02719e706734be9503e78d2b3f104b. * Apply suggestions from code review Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Remove #ifdef example * Reformat Python files with black * Add copyright notice to new Python files * Add TODOs to Makefile --------- Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
2024-01-28 17:09:03 +00:00
# SPDX-FileCopyrightText: © 2024 ZeldaRET
# SPDX-License-Identifier: CC0-1.0
import csv
from dataclasses import dataclass
from pathlib import Path
from typing import List, Optional
@dataclass
class DmaFile:
name: str
vrom_start: int
vrom_end: int
rom_start: int
rom_end: int
vram_start: int
overlay_dir: Optional[str]
def parse_file_addresses(path: Path) -> List[DmaFile]:
result = []
with open(path) as f:
reader = csv.DictReader(f)
for row in reader:
name = row["name"]
result.append(
DmaFile(
name=row["name"],
vrom_start=int(row["vrom_start"], 16),
vrom_end=int(row["vrom_end"], 16),
rom_start=int(row["rom_start"], 16),
rom_end=int(row["rom_end"], 16),
vram_start=int(row["vram_start"], 16),
overlay_dir=row["overlay_dir"] if row["overlay_dir"] else None,
)
)
return result
def get_z_name_for_overlay(filename: str) -> str:
if filename == "ovl_player_actor":
return "z_player"
elif filename.startswith("ovl_Effect_"):
return "z_eff_" + filename[len("ovl_Effect_") :].lower()
else:
return "z_" + filename[len("ovl_") :].lower()