Skip to content

Commit

Permalink
Fix the Unknown instruction warning spam
Browse files Browse the repository at this point in the history
That can occur when loading the script before starting the game.
It was caused by shaman shop rando patching too early.
  • Loading branch information
Avasam committed Jul 18, 2024
1 parent 0035fc6 commit edbc3c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
17 changes: 13 additions & 4 deletions Dolphin scripts/Entrance Randomizer/lib/shaman_shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
MAPLESS_SHOP_PRICES = [0x04, 8, 16, 32, 0x00003, 4, 5, 10, 10, 10, 9, 7, 7, 8]
"""Same as `DEFAULT_SHOP_PRICES` but with 4 lowest prices removed."""

SHOP_INITIALIZED_VALUE = 5
"""
The first value of the shaman_shop_struct once initialized.
This represents the number of Canteen upgrades.
"""


class ShopPriceOffset(IntEnum):
ExtraHealth1 = 4
Expand Down Expand Up @@ -48,10 +54,6 @@ class ShopCountOffset(IntEnum):
MysteryItem = ShopPriceOffset.MysteryItem - 4


_shaman_shop_prices = list(DEFAULT_SHOP_PRICES)
_shaman_shop_prices_string = ""


def randint_with_bias(
a: int,
b: int,
Expand Down Expand Up @@ -90,6 +92,10 @@ def randint_with_bias(
raise ValueError(f"Invalid {direction=}.")


_shaman_shop_prices = list(DEFAULT_SHOP_PRICES)
_shaman_shop_prices_string = ""


def randomize_shaman_shop():
global _shaman_shop_prices, _shaman_shop_prices_string
if ADDRESSES.shaman_shop_struct == TODO:
Expand Down Expand Up @@ -166,6 +172,9 @@ def randomize_shaman_shop():


def patch_shaman_shop():
if (memory.read_u32(ADDRESSES.shaman_shop_struct) != SHOP_INITIALIZED_VALUE):
return ""

if CONFIGS.DISABLE_MAPS_IN_SHOP:
for offset in (
ShopCountOffset.JungleNotes,
Expand Down
2 changes: 0 additions & 2 deletions Dolphin scripts/Entrance Randomizer/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ def prevent_transition_softlocks():
and height_offset
):
player_z_addr = follow_pointer_path((ADDRESSES.player_ptr, PlayerPtrOffset.PositionZ))
# memory.write_f32(player_x_addr, memory.read_f32(player_x_addr) + 30)
# memory.write_f32(player_y_addr, memory.read_f32(player_y_addr) + 30)
memory.write_f32(player_z_addr, memory.read_f32(player_z_addr) + height_offset)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the `Unknown instruction` warning spam that can occur when loading the script before starting the game -- by @Avasam

0 comments on commit edbc3c0

Please sign in to comment.