Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/mars_patcher/auto_generated_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ class MarsschemaTankincrements(typ.TypedDict):
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."""
Expand Down
26 changes: 13 additions & 13 deletions src/mars_patcher/constants/reserved_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class ReservedConstants:
PATCHER_FREE_SPACE_ADDR = 0x7D0000
PATCHER_FREE_SPACE_END = PATCHER_FREE_SPACE_ADDR + 0x20000
MINOR_LOCS_TABLE_ADDR = 0x7FF000
MAJOR_LOCS_POINTER_ADDR = 0x7FF01C
TANK_INC_ADDR = 0x7FF046
TOTAL_METROID_COUNT_ADDR = 0x7FF04C
REQUIRED_METROID_COUNT_ADDR = 0x7FF04D
STARTING_LOCATION_ADDR = 0x7FF04E
CREDITS_END_DELAY_ADDR = 0x7FF056 # TODO: Is this meant to be changed?
CREDITS_SCROLL_SPEED_ADDR = 0x7FF058 # TODO: Ditto
HINT_SECURITY_LEVELS_ADDR = 0x7FF059 # TODO: ???
ENVIRONMENTAL_HARZARD_DAMAGE_ADDR = 0x7FF065 # TODO: Implement this
MISSILE_LIMIT_ADDR = 0x7FF06A
MINOR_LOCS_ARRAY_ADDR = 0x7FF06C
ROOM_NAMES_TABLE_ADDR = 0x7FF070
REVEAL_HIDDEN_TILES_ADDR = 0x7FF08C
MINOR_LOCS_ARRAY_ADDR = 0x7FF004
MAJOR_LOCS_POINTER_ADDR = 0x7FF008
TANK_INC_ADDR = 0x7FF00C
TOTAL_METROID_COUNT_ADDR = 0x7FF010
REQUIRED_METROID_COUNT_ADDR = 0x7FF010
STARTING_LOCATION_ADDR = 0x7FF014
CREDITS_END_DELAY_ADDR = 0x7FF018 # TODO: Is this meant to be changed?
CREDITS_SCROLL_SPEED_ADDR = 0x7FF018 # + 2 TODO: Ditto
Comment on lines +20 to +24
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metroid and Credits Information was bundled into 1 pointer with data following each other sequentially. I almost would have preferred individual pointers so we are not doing arbitrary math, but I left the ASM side up to @zarakava so I worked with what he had presented.

HINT_SECURITY_LEVELS_ADDR = 0x7FF01C # TODO: ???
ENVIRONMENTAL_HARZARD_DAMAGE_ADDR = 0x7FF020 # TODO: Implement this
MISSILE_LIMIT_ADDR = 0x7FF024
ROOM_NAMES_TABLE_ADDR = 0x7FF028
REVEAL_HIDDEN_TILES_ADDR = 0x7FF02C
14 changes: 14 additions & 0 deletions src/mars_patcher/data/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,20 @@
"minimum": -100,
"maximum": 100,
"default": 2
},
"MissileData": {
"type": "integer",
"description": "How much ammo Missile Launcher Data provides when collected.",
"minimum": 0,
"maximum": 1000,
"default": 10
},
"PowerBombData": {
"type": "integer",
"description": "How much ammo Power Bomb Data provides when collected.",
"minimum": 0,
"maximum": 100,
"default": 10
}
},
"required": [
Expand Down
14 changes: 8 additions & 6 deletions src/mars_patcher/item_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def write_items(self) -> None:
# - An array right after that contains the index where this room starts in
# the big item array
# - A big array of all items and their attributes.
area_addr = MINOR_LOCS_TABLE_ADDR + (min_loc.area * 4)
area_addr = rom.read_ptr(MINOR_LOCS_TABLE_ADDR) + (min_loc.area * 4)
rooms_list_addr = rom.read_ptr(area_addr)
room_entry_addr = self._binary_search_rooms_array(rooms_list_addr, min_loc.room)
assert room_entry_addr != -1
Expand Down Expand Up @@ -192,7 +192,7 @@ def write_items(self) -> None:
else: # Set ID to Auto Message
rom.write_8(addr + 1, AUTO_MESSAGE_ID)
# Write total metroid count
rom.write_8(TOTAL_METROID_COUNT_ADDR, total_metroids)
rom.write_8(rom.read_ptr(TOTAL_METROID_COUNT_ADDR), total_metroids)

def write_custom_message(
self,
Expand Down Expand Up @@ -228,10 +228,12 @@ def write_custom_message(

# TODO: Move these?
def set_required_metroid_count(rom: Rom, count: int) -> None:
rom.write_8(REQUIRED_METROID_COUNT_ADDR, count)
rom.write_8(rom.read_ptr(REQUIRED_METROID_COUNT_ADDR) + 1, count)


def set_tank_increments(rom: Rom, data: MarsschemaTankincrements) -> None:
rom.write_16(TANK_INC_ADDR, data["MissileTank"])
rom.write_16(TANK_INC_ADDR + 2, data["EnergyTank"])
rom.write_16(TANK_INC_ADDR + 4, data["PowerBombTank"])
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"])
rom.write_16(rom.read_ptr(TANK_INC_ADDR) + 6, data["MissileData"])
rom.write_16(rom.read_ptr(TANK_INC_ADDR) + 8, data["PowerBombData"])
4 changes: 2 additions & 2 deletions src/mars_patcher/misc_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def disable_sound_effects(rom: Rom) -> None:


def change_missile_limit(rom: Rom, limit: int) -> None:
rom.write_8(ReservedConstants.MISSILE_LIMIT_ADDR, limit)
rom.write_8(rom.read_ptr(ReservedConstants.MISSILE_LIMIT_ADDR), limit)


def apply_unexplored_map(rom: Rom) -> None:
Expand All @@ -88,7 +88,7 @@ def apply_anti_softlock_edits(rom: Rom) -> None:


def apply_reveal_hidden_tiles(rom: Rom) -> None:
rom.write_8(ReservedConstants.REVEAL_HIDDEN_TILES_ADDR, 1)
rom.write_8(rom.read_ptr(ReservedConstants.REVEAL_HIDDEN_TILES_ADDR), 1)


def apply_reveal_unexplored_doors(rom: Rom) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/mars_patcher/navigation_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ def apply_hint_security(
default_lock_name = "OPEN"
for location, offset in NavigationText.NAV_ROOM_ENUMS.items():
rom.write_8(
ReservedConstants.HINT_SECURITY_LEVELS_ADDR + offset.value,
rom.read_ptr(ReservedConstants.HINT_SECURITY_LEVELS_ADDR) + offset.value,
NavStationLockType[locks.get(location, default_lock_name)].value,
)
2 changes: 1 addition & 1 deletion src/mars_patcher/room_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def write_room_names(rom: Rom, data: list[MarsschemaRoomnamesItem]) -> None:
seen_rooms.add((area_id, room_id))

# Find room name table by indexing at ROOM_NAMES_TABLE_ADDR
area_addr = ROOM_NAMES_TABLE_ADDR + (area_id * 4)
area_addr = rom.read_ptr(ROOM_NAMES_TABLE_ADDR) + (area_id * 4)
area_room_name_addr = rom.read_ptr(area_addr)

# Find specific room by indexing by the room_id
Expand Down
11 changes: 6 additions & 5 deletions src/mars_patcher/starting.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def set_starting_location(rom: Rom, data: MarsschemaStartinglocation) -> None:
x_pos = data["BlockX"] * 64 + 31
y_pos = data["BlockY"] * 64 + 63
# Write to rom
rom.write_8(STARTING_LOC_ADDR, area)
rom.write_8(STARTING_LOC_ADDR + 1, room)
rom.write_8(STARTING_LOC_ADDR + 2, door)
rom.write_16(STARTING_LOC_ADDR + 4, x_pos)
rom.write_16(STARTING_LOC_ADDR + 6, y_pos)
starting_location = rom.read_ptr(STARTING_LOC_ADDR)
rom.write_8(starting_location, area)
rom.write_8(starting_location + 1, room)
rom.write_8(starting_location + 2, door)
rom.write_16(starting_location + 4, x_pos)
rom.write_16(starting_location + 6, y_pos)


def find_door_in_room(rom: Rom, area: int, room: int) -> int:
Expand Down