From eac1e5d4f1e06a6e9a37f3d567a8ddc35e98273d Mon Sep 17 00:00:00 2001 From: biosp4rk <37962487+biosp4rk@users.noreply.github.com> Date: Mon, 8 Sep 2025 11:13:22 -0700 Subject: [PATCH] Use auto gen types from mf directory --- src/mars_patcher/auto_generated_types.py | 647 ----------------------- src/mars_patcher/common_types.py | 2 +- src/mars_patcher/connections.py | 16 +- src/mars_patcher/credits.py | 6 +- src/mars_patcher/door_locks.py | 6 +- src/mars_patcher/item_patcher.py | 4 +- src/mars_patcher/locations.py | 4 +- src/mars_patcher/navigation_text.py | 6 +- src/mars_patcher/random_palettes.py | 18 +- src/mars_patcher/room_names.py | 4 +- src/mars_patcher/starting.py | 9 +- src/mars_patcher/titlescreen_text.py | 8 +- 12 files changed, 43 insertions(+), 687 deletions(-) delete mode 100644 src/mars_patcher/auto_generated_types.py diff --git a/src/mars_patcher/auto_generated_types.py b/src/mars_patcher/auto_generated_types.py deleted file mode 100644 index d97fd23..0000000 --- a/src/mars_patcher/auto_generated_types.py +++ /dev/null @@ -1,647 +0,0 @@ -# This file is generated. Manual changes will be lost -# fmt: off -# ruff: noqa -# mypy: disable-error-code="misc" -from __future__ import annotations - -import typing_extensions as typ - - -# Definitions -Seed: typ.TypeAlias = typ.Annotated[int, '0 <= value <= 2147483647'] -Typeu4: typ.TypeAlias = typ.Annotated[int, '0 <= value <= 15'] -Typeu5: typ.TypeAlias = typ.Annotated[int, '0 <= value <= 31'] -Typeu8: typ.TypeAlias = typ.Annotated[int, '0 <= value <= 255'] -Typeu10: typ.TypeAlias = typ.Annotated[int, '0 <= value <= 1023'] -Areaid: typ.TypeAlias = typ.Annotated[int, '0 <= value <= 6'] -Areaidkey = typ.Literal[ - '0', - '1', - '2', - '3', - '4', - '5', - '6' -] -Minimapidkey = typ.Literal[ - '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10' -] -Sectorid: typ.TypeAlias = typ.Annotated[int, '1 <= value <= 6'] -Shortcutsectorlist: typ.TypeAlias = typ.Annotated[list[Sectorid], 'len() == 6'] -Huerotation: typ.TypeAlias = typ.Annotated[int, '0 <= value <= 360'] -Validsources = typ.Literal[ - 'MainDeckData', - 'Arachnus', - 'ChargeCoreX', - 'Level1', - 'TroData', - 'Zazabi', - 'Serris', - 'Level2', - 'PyrData', - 'MegaX', - 'Level3', - 'ArcData1', - 'WideCoreX', - 'ArcData2', - 'Yakuza', - 'Nettori', - 'Nightmare', - 'Level4', - 'AqaData', - 'WaveCoreX', - 'Ridley', - 'Boiler', - 'Animals', - 'AuxiliaryPower' -] -Validitems = typ.Literal[ - 'None', - 'Level0', - 'Missiles', - 'MorphBall', - 'ChargeBeam', - 'Level1', - 'Bombs', - 'HiJump', - 'SpeedBooster', - 'Level2', - 'SuperMissiles', - 'VariaSuit', - 'Level3', - 'IceMissiles', - 'WideBeam', - 'PowerBombs', - 'SpaceJump', - 'PlasmaBeam', - 'GravitySuit', - 'Level4', - 'DiffusionMissiles', - 'WaveBeam', - 'ScrewAttack', - 'IceBeam', - 'MissileTank', - 'EnergyTank', - 'PowerBombTank', - 'IceTrap', - 'InfantMetroid' -] -Validitemsprites = typ.Literal[ - 'Empty', - 'Missiles', - 'Level0', - 'MorphBall', - 'ChargeBeam', - 'Level1', - 'Bombs', - 'HiJump', - 'SpeedBooster', - 'Level2', - 'SuperMissiles', - 'VariaSuit', - 'Level3', - 'IceMissiles', - 'WideBeam', - 'PowerBombs', - 'SpaceJump', - 'PlasmaBeam', - 'GravitySuit', - 'Level4', - 'DiffusionMissiles', - 'WaveBeam', - 'ScrewAttack', - 'IceBeam', - 'MissileTank', - 'EnergyTank', - 'PowerBombTank', - 'Anonymous', - 'ShinyMissileTank', - 'ShinyPowerBombTank', - 'InfantMetroid' -] -Validabilities = typ.Literal[ - 'Missiles', - 'MorphBall', - 'ChargeBeam', - 'Bombs', - 'HiJump', - 'SpeedBooster', - 'SuperMissiles', - 'VariaSuit', - 'IceMissiles', - 'WideBeam', - 'PowerBombs', - 'SpaceJump', - 'PlasmaBeam', - 'GravitySuit', - 'DiffusionMissiles', - 'WaveBeam', - 'ScrewAttack', - 'IceBeam' -] -Validelevatortops = typ.Literal[ - 'OperationsDeckTop', - 'MainHubToSector1', - 'MainHubToSector2', - 'MainHubToSector3', - 'MainHubToSector4', - 'MainHubToSector5', - 'MainHubToSector6', - 'MainHubTop', - 'HabitationDeckTop', - 'Sector1ToRestrictedLab' -] -Validelevatorbottoms = typ.Literal[ - 'OperationsDeckBottom', - 'MainHubBottom', - 'RestrictedLabToSector1', - 'HabitationDeckBottom', - 'Sector1ToMainHub', - 'Sector2ToMainHub', - 'Sector3ToMainHub', - 'Sector4ToMainHub', - 'Sector5ToMainHub', - 'Sector6ToMainHub' -] -Validlanguages = typ.Literal[ - 'JapaneseKanji', - 'JapaneseHiragana', - 'English', - 'German', - 'French', - 'Italian', - 'Spanish' -] -Messagelanguages: typ.TypeAlias = dict[Validlanguages, str] - -class Itemmessages(typ.TypedDict, total=False): - Kind: typ.Required[Itemmessageskind] - Languages: Messagelanguages - Centered: bool = True - MessageID: typ.Annotated[int, '0 <= value <= 56'] - """The Message ID, will display one of the predefined messages in the ROM""" - -Itemmessageskind = typ.Literal[ - 'CustomMessage', - 'MessageID' -] -Jingle = typ.Literal[ - 'Minor', - 'Major' -] - -class BlocklayerItem(typ.TypedDict, total=False): - X: Typeu8 - """The X position in the room that should get edited.""" - - Y: Typeu8 - """The Y position in the room that should get edited.""" - - Value: Typeu10 - """The value that should be used to edit the room. For backgrounds, this is calculated via `((Row-1) * ColumnsInTileset) + (Column-1)`.""" - -Blocklayer: typ.TypeAlias = typ.Annotated[list[BlocklayerItem], 'Unique items'] -Hintlocks = typ.Literal[ - 'OPEN', - 'LOCKED', - 'GREY', - 'BLUE', - 'GREEN', - 'YELLOW', - 'RED' -] - -# Schema entries - -class MarsschemaLocationsMajorlocationsItem(typ.TypedDict): - Source: Validsources - """Valid major locations.""" - - Item: Validitems - """Valid items for shuffling.""" - - ItemMessages: typ.NotRequired[Itemmessages] - Jingle: Jingle - -class MarsschemaLocationsMinorlocationsItem(typ.TypedDict): - Area: Areaid - """The area ID where this item is located.""" - - Room: Typeu8 - """The room ID where this item is located.""" - - BlockX: Typeu8 - """The X-coordinate in the room where this item is located.""" - - BlockY: Typeu8 - """The Y-coordinate in the room where this item is located.""" - - Item: Validitems - """Valid items for shuffling.""" - - ItemSprite: typ.NotRequired[Validitemsprites] - """Valid graphics for minor location items.""" - - ItemMessages: typ.NotRequired[Itemmessages] - Jingle: Jingle - -class MarsschemaLocations(typ.TypedDict): - """Specifies how the item locations in the game should be changed.""" - - MajorLocations: typ.Annotated[list[MarsschemaLocationsMajorlocationsItem], 'len() == 23', 'Unique items'] - """Specifies how the major item locations should be changed. A major item location is a location where an item is obtained by defeating a boss or interacting with a device.""" - - MinorLocations: typ.Annotated[list[MarsschemaLocationsMinorlocationsItem], 'len() == 103', 'Unique items'] - """Specifies how the minor item locations should be changed. A minor item location is a location where an item is obtained by touching a tank block.""" - - -class MarsschemaStartinglocation(typ.TypedDict): - """The location the player should spawn at the start of the game.""" - - Area: Areaid - """The area ID of the starting location.""" - - Room: Typeu8 - """The room ID of the starting location.""" - - BlockX: Typeu8 - """The X-coordinate in the room where the player should spawn. If the room contains a save station, then this value will not be taken into consideration.""" - - BlockY: Typeu8 - """The Y-coordinate in the room where the player should spawn. If the room contains a save station, then this value will not be taken into consideration.""" - -MarsschemaStartingitemsSecuritylevelsItem = typ.Literal[ - 0, - 1, - 2, - 3, - 4 -] - -class MarsschemaStartingitems(typ.TypedDict, total=False): - Energy: typ.Annotated[int, '1 <= value <= 2099'] = 99 - """How much energy the player should start with on a new save file.""" - - Missiles: typ.Annotated[int, '0 <= value <= 999'] = 10 - """How many missiles the player should start with on a new save file (the amount unlocked by collecting missile data).""" - - PowerBombs: typ.Annotated[int, '0 <= value <= 99'] = 10 - """How many power bombs the player should start with on a new save file (the amount unlocked by collecting power bomb data).""" - - Abilities: typ.Annotated[list[Validabilities], 'Unique items'] = [] - """Which abilities the player should start with on a new save file.""" - - SecurityLevels: typ.Annotated[list[MarsschemaStartingitemsSecuritylevelsItem], 'Unique items'] = [0] - """Which security levels will be unlocked from the start.""" - - DownloadedMaps: typ.Annotated[list[Areaid], 'Unique items'] = [] - """Which area maps will be downloaded from the start.""" - - -class MarsschemaTankincrements(typ.TypedDict): - """How much ammo/health tanks provide when collected.""" - - MissileTank: typ.Annotated[int, '-1000 <= value <= 1000'] = 5 - """How much ammo missile tanks provide when collected.""" - - EnergyTank: typ.Annotated[int, '-2100 <= value <= 2100'] = 100 - """How much health energy tanks provide when collected.""" - - PowerBombTank: typ.Annotated[int, '-100 <= value <= 100'] = 2 - """How much ammo power bomb tanks provide when collected.""" - - MissileData: typ.NotRequired[typ.Annotated[int, '0 <= value <= 1000']] = 10 - """How much ammo Missile Launcher Data provides when collected.""" - - PowerBombData: typ.NotRequired[typ.Annotated[int, '0 <= value <= 100']] = 10 - """How much ammo Power Bomb Data provides when collected.""" - - -class MarsschemaElevatorconnections(typ.TypedDict): - """Defines the elevator that each elevator connects to.""" - - ElevatorTops: typ.Annotated[dict[Validelevatortops, Validelevatorbottoms], 'len() >= 10'] - """Defines the bottom elevator that each top elevator connects to.""" - - ElevatorBottoms: typ.Annotated[dict[Validelevatorbottoms, Validelevatortops], 'len() >= 10'] - """Defines the top elevator that each bottom elevator connects to.""" - - -class MarsschemaSectorshortcuts(typ.TypedDict): - """Defines the sector that each sector shortcut connects to.""" - - LeftAreas: Shortcutsectorlist - """Destination areas on the left side of sectors.""" - - RightAreas: Shortcutsectorlist - """Destination areas on the right side of sectors""" - -MarsschemaDoorlocksItemLocktype = typ.Literal[ - 'Open', - 'Level0', - 'Level1', - 'Level2', - 'Level3', - 'Level4', - 'Locked' -] - -class MarsschemaDoorlocksItem(typ.TypedDict): - Area: Areaid - """The area ID where this door is located.""" - - Door: Typeu8 - """The door ID of this door.""" - - LockType: MarsschemaDoorlocksItemLocktype - """The type of cover on the hatch.""" - -MarsschemaPalettesRandomizeKey = typ.Literal[ - 'Tilesets', - 'Enemies', - 'Samus', - 'Beams' -] - -@typ.final -class MarsschemaPalettesRandomize(typ.TypedDict, total=False): - """The range to use for rotating palette hues.""" - - HueMin: Huerotation = None - """The minimum value to use for rotating palette hues. If not specified, the patcher will randomly generate one.""" - - HueMax: Huerotation = None - """The maximum value to use for rotating palette hues. If not specified, the patcher will randomly generate one.""" - - -MarsschemaPalettesColorspace = typ.Literal[ - 'HSV', - 'Oklab' -] - -@typ.final -class MarsschemaPalettes(typ.TypedDict, total=False): - """Properties for randomized in-game palettes.""" - - Seed: Seed = None - """A number used to initialize the random number generator for palettes. If not specified, the patcher will randomly generate one.""" - - Randomize: typ.Required[dict[MarsschemaPalettesRandomizeKey, MarsschemaPalettesRandomize]] - """What kind of palettes should be randomized.""" - - ColorSpace: MarsschemaPalettesColorspace = 'Oklab' - """The color space to use for rotating palette hues.""" - - Symmetric: bool = True - """Randomly rotates hues in the positive or negative direction true.""" - - -class MarsschemaNavigationtextNavigationterminals(typ.TypedDict, total=False): - """Assigns each navigation room a specific text.""" - - MainDeckWest: str - """Specifies what text should appear at the west Navigation Terminal in Main Deck.""" - - MainDeckEast: str - """Specifies what text should appear at the east Navigation Terminal in Main Deck.""" - - OperationsDeck: str - """Specifies what text should appear at the Navigation Terminal in Operations Deck.""" - - Sector1Entrance: str - """Specifies what text should appear at the Navigation Terminal in Sector 1.""" - - Sector2Entrance: str - """Specifies what text should appear at the Navigation Terminal in Sector 2.""" - - Sector3Entrance: str - """Specifies what text should appear at the Navigation Terminal in Sector 3.""" - - Sector4Entrance: str - """Specifies what text should appear at the Navigation Terminal in Sector 4.""" - - Sector5Entrance: str - """Specifies what text should appear at the Navigation Terminal in Sector 5.""" - - Sector6Entrance: str - """Specifies what text should appear at the Navigation Terminal in Sector 6.""" - - AuxiliaryPower: str - """Specifies what text should appear at the Navigation Terminal near the Auxiliary Power Station.""" - - RestrictedLabs: str - """Specifies what text should appear at the Navigation Terminal in the Restricted Labs.""" - - -class MarsschemaNavigationtextShiptext(typ.TypedDict, total=False): - """Assigns the ship specific text.""" - - InitialText: str - """Specifies what text should appear at the initial ship communication.""" - - ConfirmText: str - """Specifies what text should appear at the ship after confirming 'No' on subsequent ship communications.""" - - -@typ.final -class MarsschemaNavigationtext(typ.TypedDict, total=False): - """Specifies text for a specific language.""" - - NavigationTerminals: MarsschemaNavigationtextNavigationterminals - """Assigns each navigation room a specific text.""" - - ShipText: MarsschemaNavigationtextShiptext - """Assigns the ship specific text.""" - - - -class MarsschemaTitletextItem(typ.TypedDict, total=False): - Text: typ.Annotated[str, '/^[ -~]{0,30}$/'] - """The ASCII text for this line""" - - LineNum: typ.Annotated[int, '0 <= value <= 14'] -MarsschemaCreditstextItemLinetype = typ.Literal[ - 'Blank', - 'Blue', - 'Red', - 'White1', - 'White2' -] - -class MarsschemaCreditstextItem(typ.TypedDict, total=False): - LineType: typ.Required[MarsschemaCreditstextItemLinetype] - """The color and line height of the text (or blank).""" - - Text: typ.Annotated[str, '/^[ -~]{0,34}$/'] - """The ASCII text for this line.""" - - BlankLines: Typeu8 = 0 - """Inserts the provided number of blank lines after the text line.""" - - Centered: bool = True - """Centers the text horizontally when true.""" - -MarsschemaNavstationlocksKey = typ.Literal[ - 'MainDeckWest', - 'MainDeckEast', - 'OperationsDeck', - 'RestrictedLabs', - 'AuxiliaryPower', - 'Sector1Entrance', - 'Sector2Entrance', - 'Sector3Entrance', - 'Sector4Entrance', - 'Sector5Entrance', - 'Sector6Entrance' -] - - -@typ.final -class MarsschemaLeveledits(typ.TypedDict, total=False): - """Specifies the Room ID.""" - - BG1: Blocklayer - """The BG1 layer that should be edited.""" - - BG2: Blocklayer - """The BG2 layer that should be edited.""" - - Clipdata: Blocklayer - """The Clipdata layer that should be edited.""" - - - - -class MarsschemaMinimapeditsItem(typ.TypedDict, total=False): - X: Typeu5 - """The X position in the minimap that should get edited.""" - - Y: Typeu5 - """The Y position in the minimap that should get edited.""" - - Tile: Typeu10 - """The tile value that should be used to edit the minimap.""" - - Palette: Typeu4 - """The palette row to use for the tile.""" - - HFlip: bool = False - """Whether the tile should be horizontally flipped or not.""" - - VFlip: bool = False - """Whether the tile should be vertically flipped or not.""" - - - -class MarsschemaRoomnamesItem(typ.TypedDict): - Area: Areaid - """The area ID where this room is located.""" - - Room: Typeu8 = 3 - """The room ID.""" - - Name: typ.Annotated[str, 'len() <= 112'] - """Specifies what text should appear for this room. Two lines are available, with an absolute maximum of 56 characters per line, if all characters used are small. Text will auto-wrap if the next word doesn't fit on the line. If the text is too long, it will be truncated. Use - to force a line break. If not provided, will display 'Unknown Room'.""" - - -class Marsschema(typ.TypedDict, total=False): - """ - Metroid Fusion patching schema - - A json schema describing the input for patching Metroid Fusion via mars_patcher. - """ - - SeedHash: typ.Required[typ.Annotated[str, '/^[0-9A-Z]{8}$/']] - """A seed hash that will be displayed on the file select screen.""" - - Locations: typ.Required[MarsschemaLocations] - """Specifies how the item locations in the game should be changed.""" - - RequiredMetroidCount: typ.Required[typ.Annotated[int, '0 <= value <= 20']] - """The number of infant Metroids that must be collected to beat the game.""" - - StartingLocation: MarsschemaStartinglocation - """The location the player should spawn at the start of the game.""" - - StartingItems: MarsschemaStartingitems = None - TankIncrements: MarsschemaTankincrements = None - """How much ammo/health tanks provide when collected.""" - - ElevatorConnections: MarsschemaElevatorconnections - """Defines the elevator that each elevator connects to.""" - - SectorShortcuts: MarsschemaSectorshortcuts - """Defines the sector that each sector shortcut connects to.""" - - DoorLocks: list[MarsschemaDoorlocksItem] - """List of all lockable doors and their lock type.""" - - Palettes: MarsschemaPalettes = None - """Properties for randomized in-game palettes.""" - - NavigationText: dict[Validlanguages, MarsschemaNavigationtext] = None - """Specifies text to be displayed at navigation rooms and the ship.""" - - TitleText: list[MarsschemaTitletextItem] = None - """Lines of ascii text to write to the title screen.""" - - CreditsText: list[MarsschemaCreditstextItem] - """Lines of text to insert into the credits.""" - - NavStationLocks: dict[MarsschemaNavstationlocksKey, Hintlocks] - """Sets the required Security Levels for accessing Navigation Terminals.""" - - DisableDemos: bool = False - """Disables title screen demos when true.""" - - SkipDoorTransitions: bool = False - """Makes all door transitions instant when true.""" - - StereoDefault: bool = True - """Forces stereo sound by default when true.""" - - DisableMusic: bool = False - """Disables all music tracks when true.""" - - DisableSoundEffects: bool = False - """Disables all sound effects when true.""" - - MissileLimit: Typeu8 = 3 - """Changes how many missiles can be on-screen at a time. The vanilla game has it set to 2, the randomizer changes it to 3 by default. Zero Mission uses 4.""" - - UnexploredMap: bool = False - """When enabled, starts you with a map where all unexplored items and non-visited tiles have a gray background. This is different from the downloaded map stations where there, the full tile is gray.""" - - PowerBombsWithoutBombs: bool = False - """When enabled, lets you use Power Bombs without needing to collect Bomb Data.""" - - AccessibilityPatches: bool = False - """Whether to apply patches for better accessibility.""" - - LevelEdits: dict[Areaidkey, dict[str, MarsschemaLeveledits]] - """Specifies room edits that should be done. These will be applied last.""" - - MinimapEdits: dict[Minimapidkey, list[MarsschemaMinimapeditsItem]] - """Specifies minimap edits that should be done.""" - - HideDoorsOnMinimap: bool = False - """When enabled, hides doors on the minimap. This is automatically enabled when the 'DoorLocks' field is provided.""" - - RoomNames: typ.Annotated[list[MarsschemaRoomnamesItem], 'Unique items'] - """Specifies a name to be displayed when the A Button is pressed on the pause menu.""" - - RevealHiddenTiles: bool = False - """When enabled, reveals normally hidden blocks that are breakable by upgrades. Hidden pickup tanks are not revealed regardless of this setting.""" - -MarsSchema: typ.TypeAlias = Marsschema diff --git a/src/mars_patcher/common_types.py b/src/mars_patcher/common_types.py index 823298b..7f39fdd 100644 --- a/src/mars_patcher/common_types.py +++ b/src/mars_patcher/common_types.py @@ -1,6 +1,6 @@ from typing import Annotated, TypeAlias -from mars_patcher.auto_generated_types import Areaid, Typeu8 +from mars_patcher.mf.auto_generated_types import Areaid, Typeu8 AreaId: TypeAlias = Areaid RoomId: TypeAlias = Typeu8 diff --git a/src/mars_patcher/connections.py b/src/mars_patcher/connections.py index 6115894..b4c1c3a 100644 --- a/src/mars_patcher/connections.py +++ b/src/mars_patcher/connections.py @@ -1,12 +1,6 @@ from collections.abc import Sequence import mars_patcher.constants.game_data as gd -from mars_patcher.auto_generated_types import ( - MarsschemaElevatorconnections, - MarsschemaSectorshortcuts, - Validelevatorbottoms, - Validelevatortops, -) from mars_patcher.constants.main_hub_numbers import ( MAIN_HUB_CENTER_ROOM, MAIN_HUB_CENTER_SMALL_NUM_COORDS_1, @@ -21,6 +15,12 @@ MAIN_HUB_TILEMAP_ADDR, ) from mars_patcher.data import get_data_path +from mars_patcher.mf.auto_generated_types import ( + MarsschemamfElevatorconnections, + MarsschemamfSectorshortcuts, + Validelevatorbottoms, + Validelevatortops, +) from mars_patcher.minimap import Minimap from mars_patcher.rom import Game, Rom from mars_patcher.room_entry import BlockLayer, RoomEntry @@ -74,7 +74,7 @@ def __init__(self, rom: Rom): self.area_conns_addr = gd.area_connections(rom) self.area_conns_count = gd.area_connections_count(rom) - def set_elevator_connections(self, data: MarsschemaElevatorconnections) -> None: + def set_elevator_connections(self, data: MarsschemamfElevatorconnections) -> None: # Repoint area connections data size = self.area_conns_count * 3 # Reserve space for 8 more area connections @@ -97,7 +97,7 @@ def set_elevator_connections(self, data: MarsschemaElevatorconnections) -> None: # Remove area numbers from Main Deck minimap self.remove_main_deck_minimap_area_nums() - def set_shortcut_connections(self, data: MarsschemaSectorshortcuts) -> None: + def set_shortcut_connections(self, data: MarsschemamfSectorshortcuts) -> None: for i, dst_area in enumerate(data["LeftAreas"]): self.connect_shortcuts(i + 1, dst_area, True) for i, dst_area in enumerate(data["RightAreas"]): diff --git a/src/mars_patcher/credits.py b/src/mars_patcher/credits.py index 1095705..a357d24 100644 --- a/src/mars_patcher/credits.py +++ b/src/mars_patcher/credits.py @@ -1,4 +1,3 @@ -from mars_patcher.auto_generated_types import MarsschemaCreditstextItem from mars_patcher.constants.credits_lines import ( FUSION_STAFF_LINES, LINE_TYPE_HEIGHTS, @@ -8,6 +7,7 @@ TEXT_LINE_TYPES, LineType, ) +from mars_patcher.mf.auto_generated_types import MarsschemamfCreditstextItem from mars_patcher.rom import Rom CREDITS_ADDR = 0x74B0B0 @@ -38,7 +38,7 @@ def __init__( self.centered = centered @classmethod - def from_json(cls, data: MarsschemaCreditstextItem) -> "CreditsLine": + def from_json(cls, data: MarsschemamfCreditstextItem) -> "CreditsLine": line_type = cls.LINE_TYPE_ENUMS[data["LineType"]] blank_lines = data.get("BlankLines", 0) text = data.get("Text") @@ -46,7 +46,7 @@ def from_json(cls, data: MarsschemaCreditstextItem) -> "CreditsLine": return CreditsLine(line_type, blank_lines, text, centered) -def write_credits(rom: Rom, data: list[MarsschemaCreditstextItem]) -> None: +def write_credits(rom: Rom, data: list[MarsschemamfCreditstextItem]) -> None: writer = CreditsWriter(rom) # Write MARS credits lines = [CreditsLine(*line) for line in MARS_CREDITS] diff --git a/src/mars_patcher/door_locks.py b/src/mars_patcher/door_locks.py index fecf624..2f9a1b0 100644 --- a/src/mars_patcher/door_locks.py +++ b/src/mars_patcher/door_locks.py @@ -3,7 +3,6 @@ from enum import Enum from typing import Annotated, TypedDict -from mars_patcher.auto_generated_types import MarsschemaDoorlocksItem from mars_patcher.common_types import AreaId, AreaRoomPair, RoomId from mars_patcher.constants.game_data import ( area_doors_ptrs, @@ -16,6 +15,7 @@ ColoredDoor, Edge, ) +from mars_patcher.mf.auto_generated_types import MarsschemamfDoorlocksItem from mars_patcher.minimap import Minimap from mars_patcher.rom import Rom from mars_patcher.room_entry import BlockLayer, RoomEntry @@ -85,7 +85,7 @@ class MinimapLockChanges(TypedDict, total=False): # TODO: # - Optimize by only loading rooms that contain doors to modify # - Split into more than one function for readability -def set_door_locks(rom: Rom, data: list[MarsschemaDoorlocksItem]) -> None: +def set_door_locks(rom: Rom, data: list[MarsschemamfDoorlocksItem]) -> None: door_locks = parse_door_lock_data(data) # Go through all doors in game in order @@ -235,7 +235,7 @@ def factory() -> dict: change_minimap_tiles(rom, minimap_changes) -def parse_door_lock_data(data: list[MarsschemaDoorlocksItem]) -> dict[AreaRoomPair, HatchLock]: +def parse_door_lock_data(data: list[MarsschemamfDoorlocksItem]) -> dict[AreaRoomPair, HatchLock]: """Returns a dictionary of `(AreaID, RoomID): HatchLock` from the input data.""" door_locks: dict[AreaRoomPair, HatchLock] = {} for entry in data: diff --git a/src/mars_patcher/item_patcher.py b/src/mars_patcher/item_patcher.py index 1236c1a..55e3c56 100644 --- a/src/mars_patcher/item_patcher.py +++ b/src/mars_patcher/item_patcher.py @@ -1,4 +1,3 @@ -from mars_patcher.auto_generated_types import MarsschemaTankincrements from mars_patcher.constants.reserved_space import ReservedConstants from mars_patcher.locations import ( ItemMessages, @@ -7,6 +6,7 @@ ItemType, LocationSettings, ) +from mars_patcher.mf.auto_generated_types import MarsschemamfTankincrements from mars_patcher.rom import Rom from mars_patcher.room_entry import RoomEntry from mars_patcher.text import Language, MessageType, encode_text @@ -235,7 +235,7 @@ def set_required_metroid_count(rom: Rom, count: int) -> None: rom.write_8(rom.read_ptr(REQUIRED_METROID_COUNT_ADDR) + 1, count) -def set_tank_increments(rom: Rom, data: MarsschemaTankincrements) -> None: +def set_tank_increments(rom: Rom, data: MarsschemamfTankincrements) -> None: rom.write_16(rom.read_ptr(TANK_INC_ADDR), data["MissileTank"]) rom.write_16(rom.read_ptr(TANK_INC_ADDR) + 2, data["EnergyTank"]) rom.write_16(rom.read_ptr(TANK_INC_ADDR) + 4, data["PowerBombTank"]) diff --git a/src/mars_patcher/locations.py b/src/mars_patcher/locations.py index 65f652c..4e3a261 100644 --- a/src/mars_patcher/locations.py +++ b/src/mars_patcher/locations.py @@ -38,7 +38,7 @@ from mars_patcher.text import Language if TYPE_CHECKING: - from mars_patcher.auto_generated_types import Itemmessages, MarsschemaLocations + from mars_patcher.mf.auto_generated_types import Itemmessages, MarsschemamfLocations class Location: @@ -172,7 +172,7 @@ def initialize(cls) -> LocationSettings: return LocationSettings(major_locs, minor_locs) - def set_assignments(self, data: MarsschemaLocations) -> None: + def set_assignments(self, data: MarsschemamfLocations) -> None: for maj_loc_entry in data[KEY_MAJOR_LOCS]: # Get source and item source = SOURCE_ENUMS[maj_loc_entry[KEY_SOURCE]] diff --git a/src/mars_patcher/navigation_text.py b/src/mars_patcher/navigation_text.py index de8250a..749954f 100644 --- a/src/mars_patcher/navigation_text.py +++ b/src/mars_patcher/navigation_text.py @@ -9,7 +9,7 @@ from mars_patcher.text import Language, MessageType, encode_text if TYPE_CHECKING: - from mars_patcher.auto_generated_types import Hintlocks, MarsschemaNavstationlocksKey + from mars_patcher.mf.auto_generated_types import Hintlocks, MarsschemamfNavstationlocksKey from mars_patcher.rom import Rom @@ -55,7 +55,7 @@ class NavigationText: "Spanish": Language.SPANISH, } - NAV_ROOM_ENUMS: dict[MarsschemaNavstationlocksKey, NavRoom] = { + NAV_ROOM_ENUMS: dict[MarsschemamfNavstationlocksKey, NavRoom] = { "MainDeckWest": NavRoom.MAIN_DECK_WEST, "MainDeckEast": NavRoom.MAIN_DECK_EAST, "OperationsDeck": NavRoom.OPERATIONS_DECK, @@ -123,7 +123,7 @@ def write(self, rom: Rom) -> None: @classmethod def apply_hint_security( - cls, rom: Rom, locks: dict[MarsschemaNavstationlocksKey, Hintlocks] + cls, rom: Rom, locks: dict[MarsschemamfNavstationlocksKey, Hintlocks] ) -> None: """ Applies an optional security level requirement to use Navigation Stations diff --git a/src/mars_patcher/random_palettes.py b/src/mars_patcher/random_palettes.py index 2df5aff..0f9373c 100644 --- a/src/mars_patcher/random_palettes.py +++ b/src/mars_patcher/random_palettes.py @@ -2,11 +2,6 @@ from enum import Enum import mars_patcher.constants.game_data as gd -from mars_patcher.auto_generated_types import ( - MarsschemaPalettes, - MarsschemaPalettesColorspace, - MarsschemaPalettesRandomize, -) from mars_patcher.constants.palettes import ( ENEMY_GROUPS, EXCLUDED_ENEMIES, @@ -14,6 +9,11 @@ NETTORI_EXTRA_PALS, TILESET_ANIM_PALS, ) +from mars_patcher.mf.auto_generated_types import ( + MarsschemamfPalettes, + MarsschemamfPalettesColorspace, + MarsschemamfPalettesRandomize, +) from mars_patcher.palette import ColorChange, Palette, SineWave from mars_patcher.rom import Game, Rom @@ -37,18 +37,18 @@ def __init__( self, seed: int, pal_types: dict[PaletteType, tuple[int, int]], # TODO: change this tuple(int, int) - color_space: MarsschemaPalettesColorspace, + color_space: MarsschemamfPalettesColorspace, symmetric: bool, extra_variation: bool, ): self.seed = seed self.pal_types = pal_types - self.color_space: MarsschemaPalettesColorspace = color_space + self.color_space: MarsschemamfPalettesColorspace = color_space self.symmetric = symmetric self.extra_variation = extra_variation @classmethod - def from_json(cls, data: MarsschemaPalettes) -> "PaletteSettings": + def from_json(cls, data: MarsschemamfPalettes) -> "PaletteSettings": seed = data.get("Seed", random.randint(0, 2**31 - 1)) random.seed(seed) pal_types = {} @@ -62,7 +62,7 @@ def from_json(cls, data: MarsschemaPalettes) -> "PaletteSettings": return cls(seed, pal_types, color_space, symmetric, True) @classmethod - def get_hue_range(cls, data: MarsschemaPalettesRandomize) -> tuple[int, int]: + def get_hue_range(cls, data: MarsschemamfPalettesRandomize) -> tuple[int, int]: hue_min = data.get("HueMin") hue_max = data.get("HueMax") if hue_min is None or hue_max is None: diff --git a/src/mars_patcher/room_names.py b/src/mars_patcher/room_names.py index a6f057e..7cf1403 100644 --- a/src/mars_patcher/room_names.py +++ b/src/mars_patcher/room_names.py @@ -1,5 +1,5 @@ -from mars_patcher.auto_generated_types import Areaid, MarsschemaRoomnamesItem, Typeu8 from mars_patcher.constants.reserved_space import ReservedConstants +from mars_patcher.mf.auto_generated_types import Areaid, MarsschemamfRoomnamesItem, Typeu8 from mars_patcher.rom import Rom from mars_patcher.text import MessageType, encode_text @@ -11,7 +11,7 @@ # - A list that contains pointers to area room names # - Area Room names are indexed by room id. This means some entries # are never used, but this allows for easy lookup -def write_room_names(rom: Rom, data: list[MarsschemaRoomnamesItem]) -> None: +def write_room_names(rom: Rom, data: list[MarsschemamfRoomnamesItem]) -> None: seen_rooms: set[tuple[Areaid, Typeu8]] = set() for room_name_entry in data: area_id = room_name_entry["Area"] diff --git a/src/mars_patcher/starting.py b/src/mars_patcher/starting.py index 872f71d..94b6135 100644 --- a/src/mars_patcher/starting.py +++ b/src/mars_patcher/starting.py @@ -1,7 +1,10 @@ -from mars_patcher.auto_generated_types import MarsschemaStartingitems, MarsschemaStartinglocation from mars_patcher.constants.game_data import area_doors_ptrs, spriteset_ptrs, starting_equipment from mars_patcher.constants.items import BEAM_FLAGS, MISSILE_BOMB_FLAGS, SUIT_MISC_FLAGS from mars_patcher.constants.reserved_space import ReservedConstants +from mars_patcher.mf.auto_generated_types import ( + MarsschemamfStartingitems, + MarsschemamfStartinglocation, +) from mars_patcher.rom import Rom from mars_patcher.room_entry import RoomEntry @@ -9,7 +12,7 @@ STARTING_LOC_ADDR = ReservedConstants.STARTING_LOCATION_ADDR -def set_starting_location(rom: Rom, data: MarsschemaStartinglocation) -> None: +def set_starting_location(rom: Rom, data: MarsschemamfStartinglocation) -> None: area = data["Area"] room = data["Room"] # Don't do anything for area 0 room 0 @@ -82,7 +85,7 @@ def find_save_pad_position(rom: Rom, area: int, room: int) -> tuple[int, int] | return None -def set_starting_items(rom: Rom, data: MarsschemaStartingitems) -> None: +def set_starting_items(rom: Rom, data: MarsschemamfStartingitems) -> None: def get_ability_flags(ability_flags: dict[str, int]) -> int: status = 0 for ability, flag in ability_flags.items(): diff --git a/src/mars_patcher/titlescreen_text.py b/src/mars_patcher/titlescreen_text.py index 3c686fb..0595c65 100644 --- a/src/mars_patcher/titlescreen_text.py +++ b/src/mars_patcher/titlescreen_text.py @@ -1,5 +1,5 @@ -from mars_patcher.auto_generated_types import MarsschemaTitletextItem from mars_patcher.constants.reserved_space import ReservedConstants +from mars_patcher.mf.auto_generated_types import MarsschemamfTitletextItem from mars_patcher.rom import Rom TITLE_TEXT_POINTER_ADDR = ReservedConstants.TITLESCREEN_TEXT_POINTERS_POINTER_ADDR @@ -13,13 +13,13 @@ def __init__(self, text: str | None = None, line_num: int | None = None): self.text = text @classmethod - def from_json(cls, data: MarsschemaTitletextItem) -> "TitleScreenText": + def from_json(cls, data: MarsschemamfTitletextItem) -> "TitleScreenText": text = data.get("Text", None) line_num = data.get("LineNum", None) return TitleScreenText(text, line_num) -def write_title_text(rom: Rom, lines: list[MarsschemaTitletextItem]) -> None: +def write_title_text(rom: Rom, lines: list[MarsschemamfTitletextItem]) -> None: if len(lines) > MAX_LINES: raise ValueError("Maximum number of title-screen lines exceeded.") @@ -27,7 +27,7 @@ def write_title_text(rom: Rom, lines: list[MarsschemaTitletextItem]) -> None: write_title_text_line(rom, line) -def write_title_text_line(rom: Rom, line: MarsschemaTitletextItem) -> None: +def write_title_text_line(rom: Rom, line: MarsschemamfTitletextItem) -> None: if len(line["Text"]) > 30: raise ValueError(f'String for title-screen text exceeds 30 characters.\n"{line["Text"]}"') text_pointers = rom.read_ptr(ReservedConstants.TITLESCREEN_TEXT_POINTERS_POINTER_ADDR)