From e63b453ea40a1ec5c083275b8f5a6ccdabc2bc5d Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Wed, 15 Dec 2021 11:49:37 -0500 Subject: [PATCH 01/15] Allow for starting with dungeon maps or compasses --- randomizers/items.py | 1 - wwr_ui/inventory.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/randomizers/items.py b/randomizers/items.py index d12c23a2..a89c4975 100644 --- a/randomizers/items.py +++ b/randomizers/items.py @@ -295,7 +295,6 @@ def randomize_dungeon_items(self): if item_name.endswith(" Dungeon Map") or item_name.endswith(" Compass") ] - assert len(other_dungeon_items_to_place) > 0 for item_name in other_dungeon_items_to_place: place_dungeon_item(self, item_name) diff --git a/wwr_ui/inventory.py b/wwr_ui/inventory.py index f980431b..6b484f23 100644 --- a/wwr_ui/inventory.py +++ b/wwr_ui/inventory.py @@ -30,6 +30,16 @@ "Empty Bottle", "Magic Meter Upgrade", ] + +DUNGEON_NONPROGRESS_ITEMS = \ + ["DRC Dungeon Map", "DRC Compass"] + \ + ["FW Dungeon Map", "FW Compass"] + \ + ["TotG Dungeon Map", "TotG Compass"] + \ + ["FF Dungeon Map", "FF Compass"] + \ + ["ET Dungeon Map", "ET Compass"] + \ + ["WT Dungeon Map", "WT Compass"] + +REGULAR_ITEMS = REGULAR_ITEMS + DUNGEON_NONPROGRESS_ITEMS REGULAR_ITEMS.sort() PROGRESSIVE_ITEMS = \ From 21f7b633b34e04c57f9d7d87c480dff1891c6f19 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Thu, 13 Jan 2022 18:50:11 -0500 Subject: [PATCH 02/15] Code cleanup * Remove unused imports * Remove most unused local variables * Simplify some code slightly --- asm/disassemble.py | 1 - asm/patcher.py | 2 +- asm/patches/invert_camera_x_axis.asm | 2 +- customizer.py | 4 ++-- randomizer.py | 3 --- randomizers/enemies.py | 1 - randomizers/items.py | 1 - tweaks.py | 8 ++------ wwlib/bmg.py | 3 --- wwlib/charts.py | 3 --- wwlib/events.py | 4 ++-- wwlib/gcm.py | 2 +- wwlib/j3d.py | 3 +-- wwlib/stage_searcher.py | 1 - wwlib/texture_utils.py | 14 ++++++-------- wwr_ui/randomizer_window.py | 11 ++--------- 16 files changed, 18 insertions(+), 45 deletions(-) diff --git a/asm/disassemble.py b/asm/disassemble.py index 58d4d575..e44458ec 100644 --- a/asm/disassemble.py +++ b/asm/disassemble.py @@ -1,7 +1,6 @@ from subprocess import call from subprocess import DEVNULL -import tempfile import os import re from io import BytesIO diff --git a/asm/patcher.py b/asm/patcher.py index 9bc603ff..d3fe5812 100644 --- a/asm/patcher.py +++ b/asm/patcher.py @@ -5,7 +5,7 @@ from fs_helpers import * from wwrando_paths import ASM_PATH -from wwlib.rel import REL, RELSection, RELRelocation, RELRelocationType +from wwlib.rel import RELRelocation, RELRelocationType ORIGINAL_FREE_SPACE_RAM_ADDRESS = 0x803FCFA8 ORIGINAL_DOL_SIZE = 0x3A52C0 diff --git a/asm/patches/invert_camera_x_axis.asm b/asm/patches/invert_camera_x_axis.asm index 86f03369..8799291c 100644 --- a/asm/patches/invert_camera_x_axis.asm +++ b/asm/patches/invert_camera_x_axis.asm @@ -1,7 +1,7 @@ ; Inverts camera horizontal movement. .open "sys/main.dol" -.org 0x80162488 ; In updatePad__9dCamera_cFv +.org 0x80162488 ; In dCamera_c::updatePad(void) b invert_camera_horizontal_axis ; Read the C-stick's horizontal axis and negate the value in order to invert the camera's movement. .org @NextFreeSpace diff --git a/customizer.py b/customizer.py index 96dc6082..7b91547e 100644 --- a/customizer.py +++ b/customizer.py @@ -95,7 +95,7 @@ def get_model_metadata(custom_model_name): for custom_color_name, hex_color in value.items(): try: value[custom_color_name] = parse_hex_color(hex_color, use_old_color_format) - except InvalidColorError as e: + except InvalidColorError: error_message = "Custom color \"%s\" has an invalid base color specified in metadata.txt: \"%s\"" % (custom_color_name, repr(hex_color)) return { "error_message": error_message, @@ -121,7 +121,7 @@ def get_model_metadata(custom_model_name): for custom_color_name, hex_color in preset.items(): try: preset[custom_color_name] = parse_hex_color(hex_color, use_old_color_format) - except InvalidColorError as e: + except InvalidColorError: error_message = "Color preset \"%s\"'s color \"%s\" has an invalid base color specified in metadata.txt: \"%s\"" % (preset_name, custom_color_name, repr(hex_color)) return { "error_message": error_message, diff --git a/randomizer.py b/randomizer.py index b3d8c699..3ed51ab5 100644 --- a/randomizer.py +++ b/randomizer.py @@ -1,8 +1,5 @@ import os -from io import BytesIO -import shutil -from pathlib import Path import re from random import Random from collections import OrderedDict diff --git a/randomizers/enemies.py b/randomizers/enemies.py index a7b93de0..e46f90f9 100644 --- a/randomizers/enemies.py +++ b/randomizers/enemies.py @@ -197,7 +197,6 @@ def randomize_enemy_groups_for_stage(self, stage_folder, enemy_locations): enemy_pool_for_stage = decide_on_enemy_pool_for_stage(self, stage_folder, enemy_locations) for enemy_group in enemy_locations: room_attempts = 0 - room_failures = 0 max_room_attempts = MAX_RANDOMIZATION_REDOS_PER_ROOM if stage_folder == "sea": max_room_attempts *= 5 # Give sea rooms more attempts to compensate for the lack of stage attempts. diff --git a/randomizers/items.py b/randomizers/items.py index d12c23a2..8d024ce6 100644 --- a/randomizers/items.py +++ b/randomizers/items.py @@ -4,7 +4,6 @@ from collections import OrderedDict from fs_helpers import * -import tweaks def randomize_items(self): print("Randomizing items...") diff --git a/tweaks.py b/tweaks.py index 93dfe78d..5e292497 100644 --- a/tweaks.py +++ b/tweaks.py @@ -1,6 +1,5 @@ import re -import yaml import os from io import BytesIO from collections import namedtuple @@ -12,8 +11,7 @@ from fs_helpers import * from asm import patcher from wwlib import texture_utils -from wwlib.rarc import RARC -from wwlib.rel import REL, RELSection, RELRelocation, RELRelocationType +from wwlib.rel import REL from wwrando_paths import ASSETS_PATH, ASM_PATH, SEEDGEN_PATH import customizer @@ -1127,7 +1125,6 @@ def add_pirate_ship_to_windfall(self): # Add a custom event where Aryll notices if the player got trapped in the chest room after the timer ran out and opens the door for them. event = event_list.add_event("AryllOpensDoor") - new_event_index_in_event_list = event_list.events.index(event) camera = event.add_actor("CAMERA") camera.staff_type = 2 @@ -1499,7 +1496,7 @@ def shorten_auction_intro_event(self): wind_shrine_event = event_list.events_by_name["AUCTION_START"] camera = next(actor for actor in wind_shrine_event.actors if actor.name == "CAMERA") - pre_pan_delay = camera.actions[2] + #pre_pan_delay = camera.actions[2] pan_action = camera.actions[3] post_pan_delay = camera.actions[4] @@ -1548,7 +1545,6 @@ def update_starting_gear(self): if len(starting_gear) > MAXIMUM_ADDITIONAL_STARTING_ITEMS: raise Exception("Tried to start with more starting items than the maximum number that was allocated") starting_gear_array_address = self.main_custom_symbols["starting_gear"] - normal_items = 0 for i in range(len(starting_gear)): item_id = self.item_name_to_id[starting_gear[i]] self.dol.write_data(write_u8, starting_gear_array_address+i, item_id) diff --git a/wwlib/bmg.py b/wwlib/bmg.py index b0ef547f..f31d3eee 100644 --- a/wwlib/bmg.py +++ b/wwlib/bmg.py @@ -1,5 +1,4 @@ -import os from io import BytesIO import re @@ -247,8 +246,6 @@ def read_string(self): self.encoded_string_length = byte_offset - initial_byte_offset def write_string(self): - data = self.data - is_escaped_char = False index_in_str = 0 bytes_to_write = [] diff --git a/wwlib/charts.py b/wwlib/charts.py index 7660c669..0b5a3127 100644 --- a/wwlib/charts.py +++ b/wwlib/charts.py @@ -1,7 +1,4 @@ -import os -from io import BytesIO - from fs_helpers import * class ChartList: diff --git a/wwlib/events.py b/wwlib/events.py index 73e033f5..961bf416 100644 --- a/wwlib/events.py +++ b/wwlib/events.py @@ -1,8 +1,8 @@ -from fs_helpers import * -from io import BytesIO from collections import OrderedDict +from fs_helpers import * + class EventList: TOTAL_NUM_FLAGS = 0x2800 diff --git a/wwlib/gcm.py b/wwlib/gcm.py index a234fb3d..d052f36f 100644 --- a/wwlib/gcm.py +++ b/wwlib/gcm.py @@ -210,7 +210,7 @@ def export_disc_to_iso_with_changed_files(self, output_file_path): self.output_iso.close() self.output_iso = None yield("Done", -1) - except Exception as e: + except Exception: print("Error writing GCM, removing failed ISO.") self.output_iso.close() self.output_iso = None diff --git a/wwlib/j3d.py b/wwlib/j3d.py index 06bfab5e..2de3f312 100644 --- a/wwlib/j3d.py +++ b/wwlib/j3d.py @@ -1,5 +1,4 @@ -import os from enum import Enum from io import BytesIO from collections import OrderedDict @@ -171,7 +170,7 @@ def read_string_table(self, string_table_offset): strings = [] offset = string_table_offset + 4 for i in range(num_strings): - string_hash = read_u16(self.data, offset+0x00) + #string_hash = read_u16(self.data, offset+0x00) string_data_offset = read_u16(self.data, offset+0x02) string = read_str_until_null_character(self.data, string_table_offset + string_data_offset) diff --git a/wwlib/stage_searcher.py b/wwlib/stage_searcher.py index 063f9752..1f4e69ac 100644 --- a/wwlib/stage_searcher.py +++ b/wwlib/stage_searcher.py @@ -759,7 +759,6 @@ def search_all_bmds(self): # Sort the file names for determinism. And use natural sorting so the room numbers are in order. all_filenames.sort(key=lambda filename: split_string_for_natural_sort(filename)) - seen_cam_behavior_vals = [] for arc_path in all_filenames: if not arc_path.endswith(".arc"): continue diff --git a/wwlib/texture_utils.py b/wwlib/texture_utils.py index 1464970d..d6d22f69 100644 --- a/wwlib/texture_utils.py +++ b/wwlib/texture_utils.py @@ -843,10 +843,6 @@ def encode_image(image, image_format, palette_format, mipmap_count=1): encoded_colors, colors_to_color_indexes = generate_new_palettes_from_image(image, image_format, palette_format) - block_width = BLOCK_WIDTHS[image_format] - block_height = BLOCK_HEIGHTS[image_format] - block_data_size = BLOCK_DATA_SIZES[image_format] - new_image_data = BytesIO() mipmap_image = image mipmap_width = image_width @@ -860,7 +856,6 @@ def encode_image(image, image_format, palette_format, mipmap_count=1): mipmap_image_data = encode_mipmap_image( mipmap_image, image_format, colors_to_color_indexes, - block_width, block_height, mipmap_width, mipmap_height ) @@ -871,12 +866,15 @@ def encode_image(image, image_format, palette_format, mipmap_count=1): return (new_image_data, new_palette_data, encoded_colors) -def encode_mipmap_image(image, image_format, colors_to_color_indexes, block_width, block_height, image_width, image_height): +def encode_mipmap_image(image, image_format, colors_to_color_indexes, image_width, image_height): pixels = image.load() offset_in_image_data = 0 block_x = 0 block_y = 0 mipmap_image_data = BytesIO() + block_width = BLOCK_WIDTHS[image_format] + block_height = BLOCK_HEIGHTS[image_format] + block_data_size = BLOCK_DATA_SIZES[image_format] while block_y < image_height: block_data = encode_image_to_block( image_format, @@ -884,11 +882,11 @@ def encode_mipmap_image(image, image_format, colors_to_color_indexes, block_widt block_x, block_y, block_width, block_height, image_width, image_height ) - assert len(block_data) == BLOCK_DATA_SIZES[image_format] + assert len(block_data) == block_data_size write_bytes(mipmap_image_data, offset_in_image_data, block_data) - offset_in_image_data += BLOCK_DATA_SIZES[image_format] + offset_in_image_data += block_data_size block_x += BLOCK_WIDTHS[image_format] if block_x >= image_width: block_x = 0 diff --git a/wwr_ui/randomizer_window.py b/wwr_ui/randomizer_window.py index a3520d0f..8a1eff32 100644 --- a/wwr_ui/randomizer_window.py +++ b/wwr_ui/randomizer_window.py @@ -13,6 +13,7 @@ from collections import OrderedDict import os +import yaml import traceback import string import struct @@ -22,12 +23,6 @@ import zipfile import shutil -import yaml -try: - from yaml import CDumper as Dumper -except ImportError: - from yaml import Dumper - from randomizer import Randomizer, VERSION, TooFewProgressionLocationsError, InvalidCleanISOError from wwrando_paths import SETTINGS_PATH, ASSETS_PATH, SEEDGEN_PATH, IS_RUNNING_FROM_SOURCE, CUSTOM_MODELS_PATH import customizer @@ -750,7 +745,6 @@ def update_color_presets_list(self, reload_colors=True): prev_selected_preset_type = self.get_option_value("custom_color_preset") # Remove everything except "Default" and "Custom". - indexes_to_remove = [] for i in reversed(range(self.ui.custom_color_preset.count())): if self.ui.custom_color_preset.itemText(i) in ["Default", "Custom"]: continue @@ -914,7 +908,6 @@ def reload_custom_model(self, update_preview=True): self.ui.disable_custom_player_items.show() def reload_colors(self, update_preview=True): - preset_name = self.get_option_value("custom_color_preset") for color_name in self.get_default_custom_colors_for_current_model(): color = self.get_color(color_name) self.set_color("custom_color_" + color_name, color, update_preview=False, save_color_as_custom=False) @@ -1363,7 +1356,7 @@ def install_custom_model_zip(self): ) self.update_custom_player_model_list() self.set_option_value("custom_player_model", model_dir_list[0].name) - except zipfile.BadZipfile as e: + except zipfile.BadZipfile: stack_trace = traceback.format_exc() print(stack_trace) QMessageBox.critical( From b3bbcfc667fd566b4950553f775dbe91088979f5 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 14 Jan 2022 17:08:15 -0500 Subject: [PATCH 03/15] Actions: Attempt to make seed/release key handling less fragile Using environment variables should avoid the issue of echo not handling newlines in the github secrets properly. Also should fix the possibility of the secret being leaked to the log on error. --- .github/workflows/python-app.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 44ee5e48..c526cda8 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -16,9 +16,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: Add seed key - run: echo "${{ secrets.SEED_KEY }}" > keys/seed_key.py + run: echo "%SEED_KEY%" > keys/seed_key.py + env: + SEED_KEY: ${{ secrets.SEED_KEY }} - name: Add release key - run: echo ${{ secrets.RELEASE_KEY }} > keys/build_key.txt + run: echo "%RELEASE_KEY%" > keys/build_key.txt + env: + RELEASE_KEY: ${{ secrets.RELEASE_KEY }} - name: Set up Python 3.9 uses: actions/setup-python@v2 with: @@ -60,9 +64,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: Add seed key - run: echo "${{ secrets.SEED_KEY }}" > keys/seed_key.py + run: echo "$SEED_KEY" > keys/seed_key.py + env: + SEED_KEY: ${{ secrets.SEED_KEY }} - name: Add release key - run: echo ${{ secrets.RELEASE_KEY }} > keys/build_key.txt + run: echo "$RELEASE_KEY" > keys/build_key.txt + env: + RELEASE_KEY: ${{ secrets.RELEASE_KEY }} - name: Set up Miniconda with Python 3.9 uses: goanpeca/setup-miniconda@v1 with: @@ -107,9 +115,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: Add seed key - run: echo "${{ secrets.SEED_KEY }}" > keys/seed_key.py + run: echo "$SEED_KEY" > keys/seed_key.py + env: + SEED_KEY: ${{ secrets.SEED_KEY }} - name: Add release key - run: echo ${{ secrets.RELEASE_KEY }} > keys/build_key.txt + run: echo "$RELEASE_KEY" > keys/build_key.txt + env: + RELEASE_KEY: ${{ secrets.RELEASE_KEY }} - name: Set up Python 3.9 uses: actions/setup-python@v2 with: From d94a3704d157da6e1544be962d2a0375da82718b Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 14 Jan 2022 17:14:54 -0500 Subject: [PATCH 04/15] Actions: Fix powershell command format --- .github/workflows/python-app.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index c526cda8..1cfba4d4 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -16,11 +16,11 @@ jobs: steps: - uses: actions/checkout@v2 - name: Add seed key - run: echo "%SEED_KEY%" > keys/seed_key.py + run: echo "$env:SEED_KEY" > keys/seed_key.py env: SEED_KEY: ${{ secrets.SEED_KEY }} - name: Add release key - run: echo "%RELEASE_KEY%" > keys/build_key.txt + run: echo "$env:RELEASE_KEY" > keys/build_key.txt env: RELEASE_KEY: ${{ secrets.RELEASE_KEY }} - name: Set up Python 3.9 From 854930eb01e0881030c6e4fe9a5154594f017a0a Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 14 Jan 2022 18:01:34 -0500 Subject: [PATCH 05/15] Actions: Fix conda environment not being updated to Python 3.9 --- .github/workflows/python-app.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 1cfba4d4..d5d9aadc 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -78,8 +78,8 @@ jobs: architecture: ${{ matrix.architecture }} miniconda-version: latest - run: | - conda create -qyf -n py38 python=3.9 wheel -c anaconda - conda activate py38 + conda create -qyf -n py39 python=3.9 wheel -c anaconda + conda activate py39 shell: bash -l {0} - name: Install dependencies run: | From b0dc0fdc7b9ef6aebda1cab0d5e5a3b27074788f Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 14 Jan 2022 18:49:33 -0500 Subject: [PATCH 06/15] Actions: Auto update conda --- .github/workflows/python-app.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index d5d9aadc..750457cf 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -77,6 +77,7 @@ jobs: python-version: 3.9 architecture: ${{ matrix.architecture }} miniconda-version: latest + auto-update-conda: true - run: | conda create -qyf -n py39 python=3.9 wheel -c anaconda conda activate py39 From eb1a1bd7d8b1984827b4931c829ab52441369351 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 14 Jan 2022 19:57:06 -0500 Subject: [PATCH 07/15] Fix generated seed keys still being too simple The integer divison between two very large numbers would usually result in a 1, so the other keys after the first didn't affect much. Switching to multiplication instead should make it a bit more difficult to extract the seed key. --- keys/generate_keys.bat | 2 +- keys/generate_keys.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keys/generate_keys.bat b/keys/generate_keys.bat index 64d3a4a9..3837403c 100644 --- a/keys/generate_keys.bat +++ b/keys/generate_keys.bat @@ -14,6 +14,6 @@ py -3.9 generate_key.py > temp_key set /p key_4= < temp_key del temp_key -echo SEED_KEY=str(0X%key_1%-(0X%key_2%+0X%key_3%)//0X%key_4%) > seed_key.py +echo SEED_KEY=str(0X%key_1%-(0X%key_2%+0X%key_3%)*0X%key_4%) > seed_key.py py -3.9 generate_key.py 8 > build_key.txt diff --git a/keys/generate_keys.sh b/keys/generate_keys.sh index a14951b0..802b1a0e 100644 --- a/keys/generate_keys.sh +++ b/keys/generate_keys.sh @@ -14,6 +14,6 @@ python generate_key.py > temp_key key_4= < temp_key rm temp_key -echo SEED_KEY=str(0X%key_1%-(0X%key_2%+0X%key_3%)//0X%key_4%) > seed_key.py +echo SEED_KEY=str(0X%key_1%-(0X%key_2%+0X%key_3%)*0X%key_4%) > seed_key.py python generate_key.py 8 > build_key.txt From 6d3a7fa15718e7da3616660eef5e011609154180 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 14 Jan 2022 22:14:37 -0500 Subject: [PATCH 08/15] Fix label name in new redead param patch --- asm/custom_symbols.txt | 2 +- asm/patch_diffs/add_new_enemy_rando_params_diff.txt | 2 +- asm/patches/add_new_enemy_rando_params.asm | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/asm/custom_symbols.txt b/asm/custom_symbols.txt index 0d1ea6e8..51cf1094 100644 --- a/asm/custom_symbols.txt +++ b/asm/custom_symbols.txt @@ -91,7 +91,7 @@ sys/main.dol: test_room_room_index: 0x800531E7 test_room_override_layer_num: 0x800531EB files/rels/d_a_rd.rel: - redead_check_spawn_switch: 0x61E4 + redead_check_disable_spawn_switch: 0x61E4 redead_set_death_switch: 0x621C files/rels/d_a_npc_bs1.rel: set_shop_item_in_bait_bag_slot_sold_out: 0x61F0 diff --git a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt index bede0468..55ecbcba 100644 --- a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt +++ b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt @@ -18,7 +18,7 @@ files/rels/d_a_rd.rel: Offset: 0x1C, Type: R_PPC_REL24}] 0x4874: Data: [0x48, 0x00, 0x00, 0x00] - Relocations: [{SymbolName: redead_check_spawn_switch, Offset: 0x00, Type: R_PPC_REL24}] + Relocations: [{SymbolName: redead_check_disable_spawn_switch, Offset: 0x00, Type: R_PPC_REL24}] 0x1FBC: Data: [0x48, 0x00, 0x00, 0x00] Relocations: [{SymbolName: redead_set_death_switch, Offset: 0x00, Type: R_PPC_REL24}] diff --git a/asm/patches/add_new_enemy_rando_params.asm b/asm/patches/add_new_enemy_rando_params.asm index a8ae585c..2365a401 100644 --- a/asm/patches/add_new_enemy_rando_params.asm +++ b/asm/patches/add_new_enemy_rando_params.asm @@ -7,15 +7,15 @@ .open "files/rels/d_a_rd.rel" ; ReDead .org 0x4874 ; In daRd_c::_create(void) - b redead_check_spawn_switch + b redead_check_disable_spawn_switch .org @NextFreeSpace -.global redead_check_spawn_switch -redead_check_spawn_switch: +.global redead_check_disable_spawn_switch +redead_check_disable_spawn_switch: lwz r4, 0xB0 (r30) ; Parameters bitfield rlwinm r4, r4, 16, 24, 31 ; Extract byte 0x00FF0000 from the parameters (unused in vanilla) cmplwi r4, 0xFF - beq redead_check_spawn_switch_return ; Return if the switch parameter is null + beq redead_check_disable_spawn_switch_return ; Return if the switch parameter is null ; Store the disable spawn on death switch to the ReDead's enemyice's death switch. ; This is necessary so that the enemy_ice function knows what switch to set when the enemy dies to Light Arrows. @@ -27,10 +27,10 @@ redead_check_spawn_switch: bl isSwitch__10dSv_info_cFii cmpwi r3, 0 - beq redead_check_spawn_switch_return + beq redead_check_disable_spawn_switch_return b 0x4890 ; Return to where the ReDead will cancel its initialization and despawn itself -redead_check_spawn_switch_return: +redead_check_disable_spawn_switch_return: mr r3, r30 ; Replace line we overwrote to jump here b 0x4878 ; Return to where the ReDead will continue its initialization as normal From b42874e441cd521c1b284fef7e8e214e02745999 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 14 Jan 2022 23:40:52 -0500 Subject: [PATCH 09/15] Enemy rando: Add a "Disable spawn on death switch" for Peahats --- asm/custom_symbols.txt | 3 + .../add_new_enemy_rando_params_diff.txt | 25 ++++++++ asm/patches/add_new_enemy_rando_params.asm | 64 +++++++++++++++++++ data/actor_parameters.txt | 4 ++ data/enemy_types.txt | 2 +- 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/asm/custom_symbols.txt b/asm/custom_symbols.txt index 51cf1094..094e0cfd 100644 --- a/asm/custom_symbols.txt +++ b/asm/custom_symbols.txt @@ -93,6 +93,9 @@ sys/main.dol: files/rels/d_a_rd.rel: redead_check_disable_spawn_switch: 0x61E4 redead_set_death_switch: 0x621C +files/rels/d_a_ph.rel: + peahat_check_disable_spawn_switch: 0x7F70 + peahat_set_death_switch: 0x7FB8 files/rels/d_a_npc_bs1.rel: set_shop_item_in_bait_bag_slot_sold_out: 0x61F0 check_shop_item_in_bait_bag_slot_sold_out: 0x6220 diff --git a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt index 55ecbcba..3e049f5e 100644 --- a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt +++ b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt @@ -22,3 +22,28 @@ files/rels/d_a_rd.rel: 0x1FBC: Data: [0x48, 0x00, 0x00, 0x00] Relocations: [{SymbolName: redead_set_death_switch, Offset: 0x00, Type: R_PPC_REL24}] +files/rels/d_a_ph.rel: + 0x7F70: + Data: [0xA8, 0x9D, 0x02, 0x0C, 0x54, 0x84, 0x06, 0x3E, 0x28, 0x04, 0x00, 0xFF, + 0x41, 0x82, 0x00, 0x34, 0x28, 0x04, 0x00, 0x00, 0x41, 0x82, 0x00, 0x2C, 0x98, + 0x9D, 0x0B, 0x49, 0x38, 0x00, 0x00, 0x00, 0xB0, 0x1D, 0x02, 0x0C, 0x3C, 0x60, + 0x00, 0x00, 0x38, 0x63, 0x00, 0x00, 0x88, 0xBD, 0x02, 0x0A, 0x48, 0x00, 0x00, + 0x01, 0x2C, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00, 0x08, 0x4B, 0xFF, 0xE9, 0x20, + 0x7F, 0xA3, 0xEB, 0x78, 0x4B, 0xFF, 0xE9, 0x00] + Relocations: [{SymbolName: g_dComIfG_gameInfo, Offset: 0x26, Type: R_PPC_ADDR16_HA}, + {SymbolName: g_dComIfG_gameInfo, Offset: 0x2A, Type: R_PPC_ADDR16_LO}, {SymbolName: isSwitch__10dSv_info_cFii, + Offset: 0x30, Type: R_PPC_REL24}] + 0x7FB8: + Data: [0x88, 0x9E, 0x0B, 0x49, 0x28, 0x04, 0x00, 0xFF, 0x41, 0x82, 0x00, 0x1C, + 0x28, 0x04, 0x00, 0x00, 0x41, 0x82, 0x00, 0x14, 0x3C, 0x60, 0x00, 0x00, 0x38, + 0x63, 0x00, 0x00, 0x88, 0xBE, 0x02, 0x0A, 0x48, 0x00, 0x00, 0x01, 0x7F, 0xC3, + 0xF3, 0x78, 0x4B, 0xFF, 0xC1, 0x3C] + Relocations: [{SymbolName: g_dComIfG_gameInfo, Offset: 0x16, Type: R_PPC_ADDR16_HA}, + {SymbolName: g_dComIfG_gameInfo, Offset: 0x1A, Type: R_PPC_ADDR16_LO}, {SymbolName: onSwitch__10dSv_info_cFii, + Offset: 0x20, Type: R_PPC_REL24}] + 0x68B0: + Data: [0x48, 0x00, 0x00, 0x00] + Relocations: [{SymbolName: peahat_check_disable_spawn_switch, Offset: 0x00, Type: R_PPC_REL24}] + 0x4118: + Data: [0x48, 0x00, 0x00, 0x00] + Relocations: [{SymbolName: peahat_set_death_switch, Offset: 0x00, Type: R_PPC_REL24}] diff --git a/asm/patches/add_new_enemy_rando_params.asm b/asm/patches/add_new_enemy_rando_params.asm index 2365a401..00e64178 100644 --- a/asm/patches/add_new_enemy_rando_params.asm +++ b/asm/patches/add_new_enemy_rando_params.asm @@ -55,3 +55,67 @@ redead_set_death_switch_return: b 0x1FC0 ; Return .close + + + + +; Give Peahats a new "Disable spawn on death switch" parameter (x_rot & 0x00FF). +.open "files/rels/d_a_ph.rel" ; Peahats and Seahats + +.org 0x68B0 ; In daPH_Create(fopAc_ac_c *) + b peahat_check_disable_spawn_switch + +.org @NextFreeSpace +.global peahat_check_disable_spawn_switch +peahat_check_disable_spawn_switch: + lha r4, 0x20C (r29) ; X rotation + rlwinm r4, r4, 0, 24, 31 ; Extract byte 0x000000FF from the X rotation (unused in vanilla) + cmplwi r4, 0xFF + beq peahat_check_disable_spawn_switch_return ; Return if the switch parameter is null + cmplwi r4, 0x00 + beq peahat_check_disable_spawn_switch_return ; Return if the switch parameter is zero + + ; Store the disable spawn on death switch to the Peahat's enemyice's death switch. + ; This is necessary so that the enemy_ice function knows what switch to set when the enemy dies to Light Arrows. + ; Also, we use this to store the switch even for non-enemyice-related deaths, as the X rotation field is used for rotation. + stb r4, 0xB49 (r29) ; The enemyice is at 998 in the Peahat struct, and the switch is at 1B1 in the enemyice struct. + + ; Zero out the X rotation field, as this will be used by the Peahat for rotation when executing. + li r0, 0 + sth r0, 0x20C (r29) + + lis r3, g_dComIfG_gameInfo@ha + addi r3, r3, g_dComIfG_gameInfo@l + lbz r5, 0x20A (r29) ; Current room number + bl isSwitch__10dSv_info_cFii + + cmpwi r3, 0 + beq peahat_check_disable_spawn_switch_return + b 0x68CC ; Return to where the Peahat will cancel its initialization and despawn itself + +peahat_check_disable_spawn_switch_return: + mr r3, r29 ; Replace line we overwrote to jump here + b 0x68B4 ; Return to where the Peahat will continue its initialization as normal + +.org 0x4118 ; In dead_item(ph_class *) + b peahat_set_death_switch + +.org @NextFreeSpace +.global peahat_set_death_switch +peahat_set_death_switch: + lbz r4, 0xB49 (r30) ; Load the death switch from the enemyice struct (998 + 1B1) + cmplwi r4, 0xFF + beq peahat_set_death_switch_return ; Return if the switch parameter is null + cmplwi r4, 0x00 + beq peahat_set_death_switch_return ; Return if the switch parameter is zero + + lis r3, g_dComIfG_gameInfo@ha + addi r3, r3, g_dComIfG_gameInfo@l + lbz r5, 0x20A (r30) ; Current room number + bl onSwitch__10dSv_info_cFii + +peahat_set_death_switch_return: + mr r3, r30 ; Replace line we overwrote to jump here + b 0x411C ; Return + +.close diff --git a/data/actor_parameters.txt b/data/actor_parameters.txt index 24124257..5b0d6ac9 100644 --- a/data/actor_parameters.txt +++ b/data/actor_parameters.txt @@ -2523,6 +2523,10 @@ d_a_ph: vertical_range: Bitfield name: params Mask: 0x00FF0000 + # The below disable_spawn_on_death_switch parameter is added by the randomizer. + disable_spawn_on_death_switch: + Bitfield name: x_rot + Mask: 0x00FF d_a_pirate_flag: {} diff --git a/data/enemy_types.txt b/data/enemy_types.txt index 67002c78..c9f0ef9b 100644 --- a/data/enemy_types.txt +++ b/data/enemy_types.txt @@ -183,7 +183,7 @@ Memory used by first one: 14688 Memory used by subequent ones: 10208 Enable spawn switch param name: null - Death switch param name: null + Death switch param name: disable_spawn_on_death_switch Path param name: null Allow near pits: True # TODO CHECK Can be killed with thrown objects: Yes # TODO CHECK From 5f9614c1183b55744f4f7e57e16e297116bc5c5b Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 15 Jan 2022 17:54:34 -0500 Subject: [PATCH 10/15] Fix improper alignment after custom REL name --- asm/custom_symbols.txt | 6 ++--- asm/patch_diffs/custom_data_diff.txt | 4 ++-- asm/patch_diffs/misc_rando_features_diff.txt | 24 ++++++++++---------- asm/patches/custom_data.asm | 1 + 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/asm/custom_symbols.txt b/asm/custom_symbols.txt index 094e0cfd..3707efa6 100644 --- a/asm/custom_symbols.txt +++ b/asm/custom_symbols.txt @@ -3,9 +3,9 @@ sys/main.dol: ballad_of_gales_warp_table: 0x803FCFB0 ballad_of_gales_warp_float_bank: 0x803FCFF8 custom_DynamicNameTable: 0x803FD050 - custom_l_objectName: 0x803FD066 - custom_DMC: 0x803FD072 - custom_l_objectName_end: 0x803FD072 + custom_l_objectName: 0x803FD068 + custom_DMC: 0x803FD074 + custom_l_objectName_end: 0x803FD074 init_save_with_tweaks: 0x803FD850 init_starting_gear: 0x803FDBD4 num_triforce_shards_to_start_with: 0x803FDC1C diff --git a/asm/patch_diffs/custom_data_diff.txt b/asm/patch_diffs/custom_data_diff.txt index f13deda8..7ecafa05 100644 --- a/asm/patch_diffs/custom_data_diff.txt +++ b/asm/patch_diffs/custom_data_diff.txt @@ -14,8 +14,8 @@ sys/main.dol: 0x00, 0x00, 0x43, 0x11, 0x00, 0x00, 0xC2, 0xA0, 0x00, 0x00, 0x42, 0xAC, 0x00, 0x00, 0xC3, 0x41, 0x00, 0x00, 0x3F, 0xCC, 0xCC, 0xCD, 0x3F, 0x40, 0x00, 0x00, 0x01, 0xF6, 0x00, 0x00, 0x80, 0x3F, 0xD0, 0x58, 0x64, 0x5F, 0x61, 0x5F, 0x73, - 0x77, 0x69, 0x74, 0x63, 0x68, 0x5F, 0x6F, 0x70, 0x00, 0x53, 0x77, 0x4F, 0x70, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xF6, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x69, 0x74, 0x63, 0x68, 0x5F, 0x6F, 0x70, 0x00, 0x00, 0x00, 0x53, 0x77, + 0x4F, 0x70, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF6, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/asm/patch_diffs/misc_rando_features_diff.txt b/asm/patch_diffs/misc_rando_features_diff.txt index c18f2a6e..bb4991c0 100644 --- a/asm/patch_diffs/misc_rando_features_diff.txt +++ b/asm/patch_diffs/misc_rando_features_diff.txt @@ -73,11 +73,11 @@ sys/main.dol: 0x803FEBB4: Data: [0x28, 0x1E, 0x03, 0x39, 0x41, 0x82, 0x00, 0x10, 0x28, 0x1C, 0x03, 0x3A, 0x40, 0x80, 0x00, 0x14, 0x41, 0x80, 0x00, 0x0C, 0x3F, 0xE0, 0x80, 0x40, 0x3B, - 0xFF, 0xD0, 0x66, 0x4B, 0xC4, 0x29, 0x9C, 0x38, 0x60, 0x00, 0x00, 0x4B, 0xC4, + 0xFF, 0xD0, 0x68, 0x4B, 0xC4, 0x29, 0x9C, 0x38, 0x60, 0x00, 0x00, 0x4B, 0xC4, 0x29, 0xC4] 0x803FEBDC: - Data: [0x3C, 0xE0, 0x80, 0x40, 0x38, 0xE7, 0xD0, 0x72, 0x7C, 0x06, 0x38, 0x00, - 0x41, 0x82, 0x00, 0x18, 0x3C, 0xC0, 0x80, 0x40, 0x38, 0xC6, 0xD0, 0x66, 0x38, + Data: [0x3C, 0xE0, 0x80, 0x40, 0x38, 0xE7, 0xD0, 0x74, 0x7C, 0x06, 0x38, 0x00, + 0x41, 0x82, 0x00, 0x18, 0x3C, 0xC0, 0x80, 0x40, 0x38, 0xC6, 0xD0, 0x68, 0x38, 0x00, 0x00, 0x01, 0x7C, 0x09, 0x03, 0xA6, 0x4B, 0xC4, 0x29, 0xD4, 0x3C, 0x60, 0x80, 0x35, 0x4B, 0xC4, 0x29, 0xFC] 0x803FEC08: @@ -132,23 +132,23 @@ sys/main.dol: 0x800415FC: Data: [0x48, 0x3B, 0xD5, 0xE0] 0x80022818: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x80022898: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x800228EC: - Data: [0x3C, 0x60, 0x80, 0x40, 0x3B, 0x03, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x3B, 0x03, 0xD0, 0x74] 0x80022930: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x80022958: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x80022990: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x80022A40: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x80022B24: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x80022C30: - Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x72] + Data: [0x3C, 0x60, 0x80, 0x40, 0x38, 0x63, 0xD0, 0x74] 0x80022850: Data: [0x28, 0x00, 0x01, 0xF7] 0x80022944: diff --git a/asm/patches/custom_data.asm b/asm/patches/custom_data.asm index e15ade70..7e2eaf07 100644 --- a/asm/patches/custom_data.asm +++ b/asm/patches/custom_data.asm @@ -58,6 +58,7 @@ custom_DynamicNameTable: custom_DynamicNameTable_switch_op_rel_name: .string "d_a_switch_op" + .align 2 ; Align to the next 4 bytes ; This is a list of custom actor names, to add on to the vanilla l_objectName list. .global custom_l_objectName From 180876de47d19207c6bf5e1ad38117d04479727e Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 15 Jan 2022 18:02:05 -0500 Subject: [PATCH 11/15] Fix Peahat X rot not being zeroed out if the switch param was 0xFF --- asm/patch_diffs/add_new_enemy_rando_params_diff.txt | 6 +++--- asm/patches/add_new_enemy_rando_params.asm | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt index 3e049f5e..e8b8d167 100644 --- a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt +++ b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt @@ -24,9 +24,9 @@ files/rels/d_a_rd.rel: Relocations: [{SymbolName: redead_set_death_switch, Offset: 0x00, Type: R_PPC_REL24}] files/rels/d_a_ph.rel: 0x7F70: - Data: [0xA8, 0x9D, 0x02, 0x0C, 0x54, 0x84, 0x06, 0x3E, 0x28, 0x04, 0x00, 0xFF, - 0x41, 0x82, 0x00, 0x34, 0x28, 0x04, 0x00, 0x00, 0x41, 0x82, 0x00, 0x2C, 0x98, - 0x9D, 0x0B, 0x49, 0x38, 0x00, 0x00, 0x00, 0xB0, 0x1D, 0x02, 0x0C, 0x3C, 0x60, + Data: [0xA8, 0x9D, 0x02, 0x0C, 0x54, 0x84, 0x06, 0x3E, 0x38, 0x00, 0x00, 0x00, + 0xB0, 0x1D, 0x02, 0x0C, 0x28, 0x04, 0x00, 0xFF, 0x41, 0x82, 0x00, 0x2C, 0x28, + 0x04, 0x00, 0x00, 0x41, 0x82, 0x00, 0x24, 0x98, 0x9D, 0x0B, 0x49, 0x3C, 0x60, 0x00, 0x00, 0x38, 0x63, 0x00, 0x00, 0x88, 0xBD, 0x02, 0x0A, 0x48, 0x00, 0x00, 0x01, 0x2C, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00, 0x08, 0x4B, 0xFF, 0xE9, 0x20, 0x7F, 0xA3, 0xEB, 0x78, 0x4B, 0xFF, 0xE9, 0x00] diff --git a/asm/patches/add_new_enemy_rando_params.asm b/asm/patches/add_new_enemy_rando_params.asm index 00e64178..f05dce63 100644 --- a/asm/patches/add_new_enemy_rando_params.asm +++ b/asm/patches/add_new_enemy_rando_params.asm @@ -69,7 +69,12 @@ redead_set_death_switch_return: .global peahat_check_disable_spawn_switch peahat_check_disable_spawn_switch: lha r4, 0x20C (r29) ; X rotation - rlwinm r4, r4, 0, 24, 31 ; Extract byte 0x000000FF from the X rotation (unused in vanilla) + rlwinm r4, r4, 0, 24, 31 ; Extract byte 0x00FF from the X rotation (unused in vanilla) + + ; Zero out the X rotation field, as this will be used by the Peahat for rotation when executing. + li r0, 0 + sth r0, 0x20C (r29) + cmplwi r4, 0xFF beq peahat_check_disable_spawn_switch_return ; Return if the switch parameter is null cmplwi r4, 0x00 @@ -80,10 +85,6 @@ peahat_check_disable_spawn_switch: ; Also, we use this to store the switch even for non-enemyice-related deaths, as the X rotation field is used for rotation. stb r4, 0xB49 (r29) ; The enemyice is at 998 in the Peahat struct, and the switch is at 1B1 in the enemyice struct. - ; Zero out the X rotation field, as this will be used by the Peahat for rotation when executing. - li r0, 0 - sth r0, 0x20C (r29) - lis r3, g_dComIfG_gameInfo@ha addi r3, r3, g_dComIfG_gameInfo@l lbz r5, 0x20A (r29) ; Current room number From c710eabba38d8d0db8a0bbd46597884c622f860f Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 15 Jan 2022 23:56:03 -0500 Subject: [PATCH 12/15] Enemy rando: Add an "Enable spawn switch" for Peahats --- asm/custom_symbols.txt | 2 + .../add_new_enemy_rando_params_diff.txt | 22 ++++++ asm/patches/add_new_enemy_rando_params.asm | 69 +++++++++++++++++++ data/actor_parameters.txt | 7 +- data/enemy_types.txt | 2 +- 5 files changed, 99 insertions(+), 3 deletions(-) diff --git a/asm/custom_symbols.txt b/asm/custom_symbols.txt index 3707efa6..98c0a85d 100644 --- a/asm/custom_symbols.txt +++ b/asm/custom_symbols.txt @@ -96,6 +96,8 @@ files/rels/d_a_rd.rel: files/rels/d_a_ph.rel: peahat_check_disable_spawn_switch: 0x7F70 peahat_set_death_switch: 0x7FB8 + peahat_check_enable_spawn_switch: 0x7FE4 + peahat_check_enable_spawn_switch_for_draw: 0x803C files/rels/d_a_npc_bs1.rel: set_shop_item_in_bait_bag_slot_sold_out: 0x61F0 check_shop_item_in_bait_bag_slot_sold_out: 0x6220 diff --git a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt index e8b8d167..293c36a7 100644 --- a/asm/patch_diffs/add_new_enemy_rando_params_diff.txt +++ b/asm/patch_diffs/add_new_enemy_rando_params_diff.txt @@ -41,9 +41,31 @@ files/rels/d_a_ph.rel: Relocations: [{SymbolName: g_dComIfG_gameInfo, Offset: 0x16, Type: R_PPC_ADDR16_HA}, {SymbolName: g_dComIfG_gameInfo, Offset: 0x1A, Type: R_PPC_ADDR16_LO}, {SymbolName: onSwitch__10dSv_info_cFii, Offset: 0x20, Type: R_PPC_REL24}] + 0x7FE4: + Data: [0x80, 0x9E, 0x00, 0xB0, 0x54, 0x84, 0x46, 0x3E, 0x28, 0x04, 0x00, 0xFF, + 0x41, 0x82, 0x00, 0x30, 0x28, 0x04, 0x00, 0x00, 0x41, 0x82, 0x00, 0x28, 0x3C, + 0x60, 0x00, 0x00, 0x38, 0x63, 0x00, 0x00, 0x88, 0xBE, 0x02, 0x0A, 0x48, 0x00, + 0x00, 0x01, 0x2C, 0x03, 0x00, 0x00, 0x40, 0x82, 0x00, 0x10, 0x38, 0x00, 0x00, + 0x00, 0x90, 0x1E, 0x02, 0x80, 0x4B, 0xFF, 0xE2, 0x40, 0x38, 0x00, 0x00, 0x04, + 0x90, 0x1E, 0x02, 0x80, 0x80, 0x9E, 0x00, 0xB0, 0x64, 0x84, 0xFF, 0x00, 0x90, + 0x9E, 0x00, 0xB0, 0xC0, 0x1E, 0x02, 0xC0, 0x4B, 0xFF, 0xDA, 0xF8] + Relocations: [{SymbolName: g_dComIfG_gameInfo, Offset: 0x1A, Type: R_PPC_ADDR16_HA}, + {SymbolName: g_dComIfG_gameInfo, Offset: 0x1E, Type: R_PPC_ADDR16_LO}, {SymbolName: isSwitch__10dSv_info_cFii, + Offset: 0x24, Type: R_PPC_REL24}] + 0x803C: + Data: [0x80, 0x9F, 0x00, 0xB0, 0x54, 0x84, 0x46, 0x3E, 0x28, 0x04, 0x00, 0xFF, + 0x41, 0x82, 0x00, 0x10, 0x28, 0x04, 0x00, 0x00, 0x41, 0x82, 0x00, 0x08, 0x4B, + 0xFF, 0x84, 0x68, 0x80, 0x7F, 0x02, 0xBC, 0x4B, 0xFF, 0x83, 0x00] 0x68B0: Data: [0x48, 0x00, 0x00, 0x00] Relocations: [{SymbolName: peahat_check_disable_spawn_switch, Offset: 0x00, Type: R_PPC_REL24}] 0x4118: Data: [0x48, 0x00, 0x00, 0x00] Relocations: [{SymbolName: peahat_set_death_switch, Offset: 0x00, Type: R_PPC_REL24}] + 0x5B2C: + Data: [0x48, 0x00, 0x00, 0x00] + Relocations: [{SymbolName: peahat_check_enable_spawn_switch, Offset: 0x00, Type: R_PPC_REL24}] + 0x358: + Data: [0x48, 0x00, 0x00, 0x00] + Relocations: [{SymbolName: peahat_check_enable_spawn_switch_for_draw, Offset: 0x00, + Type: R_PPC_REL24}] diff --git a/asm/patches/add_new_enemy_rando_params.asm b/asm/patches/add_new_enemy_rando_params.asm index f05dce63..da9abb88 100644 --- a/asm/patches/add_new_enemy_rando_params.asm +++ b/asm/patches/add_new_enemy_rando_params.asm @@ -120,3 +120,72 @@ peahat_set_death_switch_return: b 0x411C ; Return .close + + + + +; Give Peahats a new "Enable spawn switch" parameter (params & 0xFF000000). +.open "files/rels/d_a_ph.rel" ; Peahats and Seahats + +.org 0x5B2C ; In daPH_Execute(ph_class *) + b peahat_check_enable_spawn_switch + +.org @NextFreeSpace +.global peahat_check_enable_spawn_switch +peahat_check_enable_spawn_switch: + lwz r4, 0xB0 (r30) ; Parameters bitfield + rlwinm r4, r4, 8, 24, 31 ; Extract byte 0xFF000000 from the parameters (unused in vanilla) + cmplwi r4, 0xFF + beq peahat_check_enable_spawn_switch_return ; Return if the switch parameter is null + cmplwi r4, 0x00 + beq peahat_check_enable_spawn_switch_return ; Return if the switch parameter is zero + + lis r3, g_dComIfG_gameInfo@ha + addi r3, r3, g_dComIfG_gameInfo@l + lbz r5, 0x20A (r30) ; Current room number + bl isSwitch__10dSv_info_cFii + + cmpwi r3, 0 + bne peahat_check_enable_spawn_switch_return + + ; Clear the actor's attention flags. This removes the lockon target and enemy music. + li r0, 0 + stw r0, 0x280 (r30) + + b 0x625C ; Return to where the Peahat will skip the rest of its execute code for this frame + +peahat_check_enable_spawn_switch_return: + ; Set the actor's attention flags to 4 (LockOn_Enemy). + li r0, 4 + stw r0, 0x280 (r30) + + ; Set the switch parameter to 0xFF so that the draw function knows the actor should be enabled now. + lwz r4, 0xB0 (r30) ; Parameters bitfield + oris r4, r4, 0xFF00 ; OR with 0xFF000000 + stw r4, 0xB0 (r30) + + lfs f0, 0x2C0 (r30) ; Replace line we overwrote to jump here + b 0x5B30 ; Return + +.org 0x358 ; daPH_Draw(ph_class *) + b peahat_check_enable_spawn_switch_for_draw + +.org @NextFreeSpace +.global peahat_check_enable_spawn_switch_for_draw +peahat_check_enable_spawn_switch_for_draw: + lwz r4, 0xB0 (r31) ; Parameters bitfield + rlwinm r4, r4, 8, 24, 31 ; Extract byte 0xFF000000 from the parameters (unused in vanilla) + cmplwi r4, 0xFF + beq peahat_check_enable_spawn_switch_for_draw_return ; Return if the switch parameter is null + cmplwi r4, 0x00 + beq peahat_check_enable_spawn_switch_for_draw_return ; Return if the switch parameter is zero + + ; We don't need to check the switch here because the execute function will have set it to 0xFF once the switch is set. + + b 0x4BC ; Return to where the Peahat will skip the rest of its draw code for this frame + +peahat_check_enable_spawn_switch_for_draw_return: + lwz r3, 0x2BC (r31) ; Replace line we overwrote to jump here + b 0x35C ; Return + +.close diff --git a/data/actor_parameters.txt b/data/actor_parameters.txt index 5b0d6ac9..ac572a95 100644 --- a/data/actor_parameters.txt +++ b/data/actor_parameters.txt @@ -2523,10 +2523,13 @@ d_a_ph: vertical_range: Bitfield name: params Mask: 0x00FF0000 - # The below disable_spawn_on_death_switch parameter is added by the randomizer. + # The below parameters are added by the randomizer. disable_spawn_on_death_switch: Bitfield name: x_rot Mask: 0x00FF + enable_spawn_switch: + Bitfield name: params + Mask: 0xFF000000 d_a_pirate_flag: {} @@ -2599,7 +2602,7 @@ d_a_rd: enable_spawn_switch: Bitfield name: params Mask: 0xFF000000 - # The below disable_spawn_on_death_switch parameter is added by the randomizer. + # The below parameter is added by the randomizer. disable_spawn_on_death_switch: Bitfield name: params Mask: 0x00FF0000 diff --git a/data/enemy_types.txt b/data/enemy_types.txt index c9f0ef9b..a4d41be3 100644 --- a/data/enemy_types.txt +++ b/data/enemy_types.txt @@ -182,7 +182,7 @@ Placement categories: [Air, Ceiling] Memory used by first one: 14688 Memory used by subequent ones: 10208 - Enable spawn switch param name: null + Enable spawn switch param name: enable_spawn_switch Death switch param name: disable_spawn_on_death_switch Path param name: null Allow near pits: True # TODO CHECK From d916ca549726157a30dfab86abf0823dcc1528f1 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 17 Jan 2022 14:45:08 -0500 Subject: [PATCH 13/15] Assembler: Fix error after .including a self-contained asm patch that ends in a .close --- asm/assemble.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/asm/assemble.py b/asm/assemble.py index e3797eff..62ecb35b 100644 --- a/asm/assemble.py +++ b/asm/assemble.py @@ -293,12 +293,18 @@ def try_apply_local_relocation(bin_name, elf_relocation, elf_symbol): if line[0] == ";": # Comment continue - raise Exception("Found code when no file was open") + if line == ".section \".text\"": + # Ignore the failsafe section reset after an include + continue + raise Exception("Found code when no file was open:\n%s" % line) if most_recent_org_offset is None: if line[0] == ";": # Comment continue - raise Exception("Found code before any .org directive") + if line == ".section \".text\"": + # Ignore the failsafe section reset after an include + continue + raise Exception("Found code before any .org directive:\n%s" % line) code_chunks[patch_name][most_recent_file_path][most_recent_org_offset] += line + "\n" From 905d3d1203856120626024d6178363ddce1ae9d4 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 17 Jan 2022 17:14:56 -0500 Subject: [PATCH 14/15] Switch to $$ instead of : to denote REL symbols Colons cannot appear in ASM symbol names. ASM symbol names can have periods, but then C identifiers can't have that. Both ASM and C can have dollar signs in symbols, but some vanilla symbols already had a dollar sign in them. Therefore we go with a double dollar sign. --- asm/patcher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/asm/patcher.py b/asm/patcher.py index d3fe5812..ee2d562c 100644 --- a/asm/patcher.py +++ b/asm/patcher.py @@ -196,11 +196,11 @@ def add_relocations_to_rel(self, file_path, rel_section_index, offset_into_secti rel_relocation.section_num_to_relocate_against = other_rel_section_index rel_relocation.symbol_address = relative_offset - elif ":" in symbol_name: + elif "$$" in symbol_name: # Vanilla symbol located in a REL. - # We use a colon to signify rel_name:symbol_name. + # We use double dollar signs to denote rel_name$$symbol_name. # (This is because we don't necessarily know for sure that the REL is calling a function inside of itself, it's possible to call a function in another REL.) - rel_name, symbol_name = symbol_name.split(":", 1) + rel_name, symbol_name = symbol_name.split("$$", 1) other_rel = self.get_rel("files/rels/%s.rel" % rel_name) other_rel_symbols = self.get_symbol_map("files/maps/%s.map" % rel_name) From fbc9d443fb43a634496af6863f00936ef8be302b Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 5 Feb 2022 18:16:15 -0500 Subject: [PATCH 15/15] Code style --- wwr_ui/inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wwr_ui/inventory.py b/wwr_ui/inventory.py index 6b484f23..b2125517 100644 --- a/wwr_ui/inventory.py +++ b/wwr_ui/inventory.py @@ -39,7 +39,7 @@ ["ET Dungeon Map", "ET Compass"] + \ ["WT Dungeon Map", "WT Compass"] -REGULAR_ITEMS = REGULAR_ITEMS + DUNGEON_NONPROGRESS_ITEMS +REGULAR_ITEMS += DUNGEON_NONPROGRESS_ITEMS REGULAR_ITEMS.sort() PROGRESSIVE_ITEMS = \