From dc9b9d5d1034fe0696d80be59e3767d60a7befdd Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 12 Oct 2025 22:01:52 -0400 Subject: [PATCH] move zelda3 directory to src from app --- docs/C2-testing-without-roms.md | 2 +- scripts/build_cleaner.py | 4 +- src/CMakeLists.txt | 2 +- src/app/core/project.cc | 2 +- .../editor/dungeon/dungeon_canvas_viewer.cc | 4 +- .../editor/dungeon/dungeon_canvas_viewer.h | 2 +- src/app/editor/dungeon/dungeon_editor_v2.cc | 2 +- src/app/editor/dungeon/dungeon_editor_v2.h | 4 +- .../dungeon/dungeon_object_interaction.h | 4 +- .../editor/dungeon/dungeon_object_selector.cc | 6 +- .../editor/dungeon/dungeon_object_selector.h | 4 +- src/app/editor/dungeon/dungeon_room_loader.cc | 2 +- src/app/editor/dungeon/dungeon_room_loader.h | 4 +- .../editor/dungeon/dungeon_room_selector.cc | 4 +- .../editor/dungeon/dungeon_room_selector.h | 4 +- .../editor/dungeon/dungeon_usage_tracker.h | 2 +- src/app/editor/dungeon/object_editor_card.h | 2 +- src/app/editor/editor_manager.cc | 2 +- src/app/editor/graphics/graphics_editor.h | 2 +- src/app/editor/graphics/screen_editor.h | 4 +- src/app/editor/music/music_editor.h | 2 +- src/app/editor/overworld/entity.h | 10 +- src/app/editor/overworld/map_properties.cc | 2 +- src/app/editor/overworld/map_properties.h | 2 +- src/app/editor/overworld/overworld_editor.cc | 6 +- src/app/editor/overworld/overworld_editor.h | 764 +++--- .../overworld/overworld_entity_renderer.cc | 2 +- .../overworld/overworld_entity_renderer.h | 4 +- src/app/editor/overworld/scratch_space.cc | 6 +- src/app/editor/overworld/tile16_editor.cc | 2 +- src/app/editor/sprite/sprite_editor.cc | 2 +- src/app/gfx/palette_manager.cc | 9 +- .../dungeon_object_emulator_preview.cc | 4 +- src/app/test/rom_dependent_test_suite.h | 2 +- src/cli/handlers/README.md | 2 +- src/cli/handlers/agent/general_commands.cc | 2 +- src/cli/handlers/game/dungeon.cc | 4 +- src/cli/handlers/game/dungeon_commands.cc | 2 +- src/cli/handlers/game/overworld.cc | 2 +- src/cli/handlers/game/overworld_inspect.cc | 10 +- src/cli/handlers/graphics/sprite_commands.cc | 2 +- src/cli/handlers/rom/mock_rom.cc | 2 +- src/cli/service/agent/agent_pretraining.cc | 2 +- .../planning/tile16_proposal_generator.cc | 2 +- src/yaze.cc | 2 +- src/{app => }/zelda3/common.h | 0 .../zelda3/dungeon/dungeon_editor_system.cc | 0 .../zelda3/dungeon/dungeon_editor_system.h | 6 +- .../zelda3/dungeon/dungeon_object_editor.cc | 0 .../zelda3/dungeon/dungeon_object_editor.h | 4 +- .../zelda3/dungeon/dungeon_rom_addresses.h | 0 src/{app => }/zelda3/dungeon/object_drawer.cc | 0 src/{app => }/zelda3/dungeon/object_drawer.h | 2 +- src/{app => }/zelda3/dungeon/object_parser.cc | 2 +- src/{app => }/zelda3/dungeon/object_parser.h | 0 src/{app => }/zelda3/dungeon/room.cc | 6 +- src/{app => }/zelda3/dungeon/room.h | 8 +- src/{app => }/zelda3/dungeon/room_entrance.h | 0 src/{app => }/zelda3/dungeon/room_layout.cc | 2 +- src/{app => }/zelda3/dungeon/room_layout.h | 2 +- src/{app => }/zelda3/dungeon/room_object.cc | 2 +- src/{app => }/zelda3/dungeon/room_object.h | 2 +- src/{app => }/zelda3/music/tracker.cc | 0 src/{app => }/zelda3/music/tracker.h | 0 src/{app => }/zelda3/overworld/overworld.cc | 4 +- src/{app => }/zelda3/overworld/overworld.h | 10 +- .../zelda3/overworld/overworld_entrance.h | 2 +- .../zelda3/overworld/overworld_exit.h | 2 +- .../zelda3/overworld/overworld_item.h | 2 +- .../zelda3/overworld/overworld_map.cc | 2258 ++++++++--------- .../zelda3/overworld/overworld_map.h | 0 src/{app => }/zelda3/screen/dungeon_map.cc | 0 src/{app => }/zelda3/screen/dungeon_map.h | 0 src/{app => }/zelda3/screen/inventory.cc | 0 src/{app => }/zelda3/screen/inventory.h | 0 src/{app => }/zelda3/screen/title_screen.cc | 0 src/{app => }/zelda3/screen/title_screen.h | 0 src/{app => }/zelda3/sprite/overlord.h | 0 src/{app => }/zelda3/sprite/sprite.cc | 0 src/{app => }/zelda3/sprite/sprite.h | 784 +++--- src/{app => }/zelda3/sprite/sprite_builder.cc | 0 src/{app => }/zelda3/sprite/sprite_builder.h | 0 src/{app => }/zelda3/zelda3_labels.cc | 10 +- src/{app => }/zelda3/zelda3_labels.h | 0 src/{app => }/zelda3/zelda3_library.cmake | 32 +- .../e2e/dungeon_object_rendering_e2e_tests.cc | 4 +- test/e2e/overworld/overworld_e2e_test.cc | 4 +- test/integration/dungeon_editor_test.cc | 4 +- test/integration/dungeon_editor_test.h | 2 +- test/integration/editor/tile16_editor_test.cc | 2 +- .../dungeon_editor_system_integration_test.cc | 6 +- .../zelda3/dungeon_object_rendering_tests.cc | 6 +- .../dungeon_object_rendering_tests_new.cc | 6 +- .../zelda3/dungeon_rendering_test.cc | 8 +- test/integration/zelda3/dungeon_room_test.cc | 2 +- .../zelda3/overworld_integration_test.cc | 4 +- .../zelda3/room_integration_test.cc | 4 +- .../zelda3/sprite_position_test.cc | 4 +- .../zelda3/dungeon/object_rendering_test.cc | 6 +- .../zelda3/dungeon/room_manipulation_test.cc | 4 +- .../dungeon/room_object_encoding_test.cc | 2 +- .../unit/zelda3/object_parser_structs_test.cc | 2 +- test/unit/zelda3/object_parser_test.cc | 2 +- test/unit/zelda3/overworld_test.cc | 4 +- test/unit/zelda3/sprite_builder_test.cc | 2 +- tools/test_helpers/extract_vanilla_values.cc | 4 +- .../overworld_golden_data_extractor.cc | 6 +- tools/test_helpers/rom_patch_utility.cc | 4 +- 108 files changed, 2071 insertions(+), 2072 deletions(-) rename src/{app => }/zelda3/common.h (100%) rename src/{app => }/zelda3/dungeon/dungeon_editor_system.cc (100%) rename src/{app => }/zelda3/dungeon/dungeon_editor_system.h (99%) rename src/{app => }/zelda3/dungeon/dungeon_object_editor.cc (100%) rename src/{app => }/zelda3/dungeon/dungeon_object_editor.h (99%) rename src/{app => }/zelda3/dungeon/dungeon_rom_addresses.h (100%) rename src/{app => }/zelda3/dungeon/object_drawer.cc (100%) rename src/{app => }/zelda3/dungeon/object_drawer.h (99%) rename src/{app => }/zelda3/dungeon/object_parser.cc (99%) rename src/{app => }/zelda3/dungeon/object_parser.h (100%) rename src/{app => }/zelda3/dungeon/room.cc (99%) rename src/{app => }/zelda3/dungeon/room.h (99%) rename src/{app => }/zelda3/dungeon/room_entrance.h (100%) rename src/{app => }/zelda3/dungeon/room_layout.cc (97%) rename src/{app => }/zelda3/dungeon/room_layout.h (94%) rename src/{app => }/zelda3/dungeon/room_object.cc (99%) rename src/{app => }/zelda3/dungeon/room_object.h (99%) rename src/{app => }/zelda3/music/tracker.cc (100%) rename src/{app => }/zelda3/music/tracker.h (100%) rename src/{app => }/zelda3/overworld/overworld.cc (99%) rename src/{app => }/zelda3/overworld/overworld.h (98%) rename src/{app => }/zelda3/overworld/overworld_entrance.h (99%) rename src/{app => }/zelda3/overworld/overworld_exit.h (99%) rename src/{app => }/zelda3/overworld/overworld_item.h (99%) rename src/{app => }/zelda3/overworld/overworld_map.cc (97%) rename src/{app => }/zelda3/overworld/overworld_map.h (100%) rename src/{app => }/zelda3/screen/dungeon_map.cc (100%) rename src/{app => }/zelda3/screen/dungeon_map.h (100%) rename src/{app => }/zelda3/screen/inventory.cc (100%) rename src/{app => }/zelda3/screen/inventory.h (100%) rename src/{app => }/zelda3/screen/title_screen.cc (100%) rename src/{app => }/zelda3/screen/title_screen.h (100%) rename src/{app => }/zelda3/sprite/overlord.h (100%) rename src/{app => }/zelda3/sprite/sprite.cc (100%) rename src/{app => }/zelda3/sprite/sprite.h (95%) rename src/{app => }/zelda3/sprite/sprite_builder.cc (100%) rename src/{app => }/zelda3/sprite/sprite_builder.h (100%) rename src/{app => }/zelda3/zelda3_labels.cc (98%) rename src/{app => }/zelda3/zelda3_labels.h (100%) rename src/{app => }/zelda3/zelda3_library.cmake (72%) diff --git a/docs/C2-testing-without-roms.md b/docs/C2-testing-without-roms.md index 98eb31d5..26e05b3e 100644 --- a/docs/C2-testing-without-roms.md +++ b/docs/C2-testing-without-roms.md @@ -174,7 +174,7 @@ Mock ROM includes all these labels from `zelda3::Zelda3Labels`: | Music Tracks | 64+ | "Title Theme", "Overworld", "Dark World" | | Graphics Sheets | 128+ | "Link Sprites", "Enemy Pack 1" | -See `src/app/zelda3/zelda3_labels.h` for the complete list. +See `src/zelda3/zelda3_labels.h` for the complete list. ## Troubleshooting diff --git a/scripts/build_cleaner.py b/scripts/build_cleaner.py index 842b615b..2609cbf1 100644 --- a/scripts/build_cleaner.py +++ b/scripts/build_cleaner.py @@ -71,8 +71,8 @@ CONFIG: Sequence[CMakeSourceBlock] = ( ), CMakeSourceBlock( variable="YAZE_APP_ZELDA3_SRC", - cmake_path=SOURCE_ROOT / "app/zelda3/zelda3_library.cmake", - directories=(DirectorySpec(SOURCE_ROOT / "app/zelda3"),), + cmake_path=SOURCE_ROOT / "zelda3/zelda3_library.cmake", + directories=(DirectorySpec(SOURCE_ROOT / "zelda3"),), ), CMakeSourceBlock( variable="YAZE_NET_SRC", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 460c2ee3..6b6cd740 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,7 +61,7 @@ include(util/util.cmake) include(app/gfx/gfx_library.cmake) include(app/net/net_library.cmake) include(app/gui/gui_library.cmake) -include(app/zelda3/zelda3_library.cmake) +include(zelda3/zelda3_library.cmake) include(app/core/core_library.cmake) # Include test support library BEFORE yaze_editor so it can link against it diff --git a/src/app/core/project.cc b/src/app/core/project.cc index bb8adf2e..d603fb9c 100644 --- a/src/app/core/project.cc +++ b/src/app/core/project.cc @@ -13,7 +13,7 @@ #include "util/platform_paths.h" #include "app/gui/icons.h" #include "util/log.h" -#include "app/zelda3/zelda3_labels.h" +#include "zelda3/zelda3_labels.h" #include "imgui/imgui.h" #include "yaze_config.h" diff --git a/src/app/editor/dungeon/dungeon_canvas_viewer.cc b/src/app/editor/dungeon/dungeon_canvas_viewer.cc index 1b55b1fe..1a634da7 100644 --- a/src/app/editor/dungeon/dungeon_canvas_viewer.cc +++ b/src/app/editor/dungeon/dungeon_canvas_viewer.cc @@ -5,8 +5,8 @@ #include "app/gfx/snes_palette.h" #include "app/gui/input.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/sprite/sprite.h" #include "imgui/imgui.h" #include "util/log.h" diff --git a/src/app/editor/dungeon/dungeon_canvas_viewer.h b/src/app/editor/dungeon/dungeon_canvas_viewer.h index 29d39cf9..966885b6 100644 --- a/src/app/editor/dungeon/dungeon_canvas_viewer.h +++ b/src/app/editor/dungeon/dungeon_canvas_viewer.h @@ -5,7 +5,7 @@ #include "app/gui/canvas.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room.h" #include "app/gfx/snes_palette.h" #include "dungeon_object_interaction.h" #include "imgui/imgui.h" diff --git a/src/app/editor/dungeon/dungeon_editor_v2.cc b/src/app/editor/dungeon/dungeon_editor_v2.cc index 75b74cea..e6792ae6 100644 --- a/src/app/editor/dungeon/dungeon_editor_v2.cc +++ b/src/app/editor/dungeon/dungeon_editor_v2.cc @@ -6,7 +6,7 @@ #include "absl/strings/str_format.h" #include "app/gfx/arena.h" #include "app/gfx/snes_palette.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room.h" #include "app/gui/icons.h" #include "app/gui/input.h" #include "imgui/imgui.h" diff --git a/src/app/editor/dungeon/dungeon_editor_v2.h b/src/app/editor/dungeon/dungeon_editor_v2.h index 38fedca5..53263691 100644 --- a/src/app/editor/dungeon/dungeon_editor_v2.h +++ b/src/app/editor/dungeon/dungeon_editor_v2.h @@ -15,8 +15,8 @@ #include "dungeon_room_loader.h" #include "object_editor_card.h" #include "app/gui/editor_card_manager.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_entrance.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_entrance.h" #include "app/gui/editor_layout.h" #include "app/gui/widgets/dungeon_object_emulator_preview.h" #include "app/gui/widgets/palette_editor_widget.h" diff --git a/src/app/editor/dungeon/dungeon_object_interaction.h b/src/app/editor/dungeon/dungeon_object_interaction.h index 7e7b5827..ead248ce 100644 --- a/src/app/editor/dungeon/dungeon_object_interaction.h +++ b/src/app/editor/dungeon/dungeon_object_interaction.h @@ -6,8 +6,8 @@ #include "imgui/imgui.h" #include "app/gui/canvas.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace editor { diff --git a/src/app/editor/dungeon/dungeon_object_selector.cc b/src/app/editor/dungeon/dungeon_object_selector.cc index e02730d0..2af5b1f0 100644 --- a/src/app/editor/dungeon/dungeon_object_selector.cc +++ b/src/app/editor/dungeon/dungeon_object_selector.cc @@ -10,9 +10,9 @@ #include "app/gui/canvas.h" #include "app/gui/modules/asset_browser.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/dungeon_editor_system.h" -#include "app/zelda3/dungeon/dungeon_object_editor.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/dungeon_editor_system.h" +#include "zelda3/dungeon/dungeon_object_editor.h" #include "imgui/imgui.h" namespace yaze::editor { diff --git a/src/app/editor/dungeon/dungeon_object_selector.h b/src/app/editor/dungeon/dungeon_object_selector.h index 4a7229cf..6d9a5a9f 100644 --- a/src/app/editor/dungeon/dungeon_object_selector.h +++ b/src/app/editor/dungeon/dungeon_object_selector.h @@ -4,8 +4,8 @@ #include "app/gui/canvas.h" #include "app/rom.h" // object_renderer.h removed - using ObjectDrawer for production rendering -#include "app/zelda3/dungeon/dungeon_object_editor.h" -#include "app/zelda3/dungeon/dungeon_editor_system.h" +#include "zelda3/dungeon/dungeon_object_editor.h" +#include "zelda3/dungeon/dungeon_editor_system.h" #include "app/gfx/snes_palette.h" #include "imgui/imgui.h" diff --git a/src/app/editor/dungeon/dungeon_room_loader.cc b/src/app/editor/dungeon/dungeon_room_loader.cc index c91debfc..8007bdcc 100644 --- a/src/app/editor/dungeon/dungeon_room_loader.cc +++ b/src/app/editor/dungeon/dungeon_room_loader.cc @@ -8,7 +8,7 @@ #include "app/gfx/performance/performance_profiler.h" #include "app/gfx/snes_palette.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room.h" #include "util/log.h" namespace yaze::editor { diff --git a/src/app/editor/dungeon/dungeon_room_loader.h b/src/app/editor/dungeon/dungeon_room_loader.h index 276d1d19..a13b5d54 100644 --- a/src/app/editor/dungeon/dungeon_room_loader.h +++ b/src/app/editor/dungeon/dungeon_room_loader.h @@ -6,8 +6,8 @@ #include "absl/status/status.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_entrance.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_entrance.h" namespace yaze { namespace editor { diff --git a/src/app/editor/dungeon/dungeon_room_selector.cc b/src/app/editor/dungeon/dungeon_room_selector.cc index 3aaa271a..8dcfa581 100644 --- a/src/app/editor/dungeon/dungeon_room_selector.cc +++ b/src/app/editor/dungeon/dungeon_room_selector.cc @@ -1,8 +1,8 @@ #include "dungeon_room_selector.h" #include "app/gui/input.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_entrance.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_entrance.h" #include "imgui/imgui.h" #include "util/hex.h" diff --git a/src/app/editor/dungeon/dungeon_room_selector.h b/src/app/editor/dungeon/dungeon_room_selector.h index 289880a9..ed27ff14 100644 --- a/src/app/editor/dungeon/dungeon_room_selector.h +++ b/src/app/editor/dungeon/dungeon_room_selector.h @@ -4,8 +4,8 @@ #include #include "imgui/imgui.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room_entrance.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_entrance.h" +#include "zelda3/dungeon/room.h" namespace yaze { namespace editor { diff --git a/src/app/editor/dungeon/dungeon_usage_tracker.h b/src/app/editor/dungeon/dungeon_usage_tracker.h index 902f5b05..f1535ae2 100644 --- a/src/app/editor/dungeon/dungeon_usage_tracker.h +++ b/src/app/editor/dungeon/dungeon_usage_tracker.h @@ -2,7 +2,7 @@ #define YAZE_APP_EDITOR_DUNGEON_DUNGEON_USAGE_TRACKER_H #include "absl/container/flat_hash_map.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room.h" namespace yaze { namespace editor { diff --git a/src/app/editor/dungeon/object_editor_card.h b/src/app/editor/dungeon/object_editor_card.h index f2d93364..23ae006a 100644 --- a/src/app/editor/dungeon/object_editor_card.h +++ b/src/app/editor/dungeon/object_editor_card.h @@ -11,7 +11,7 @@ #include "app/gui/editor_layout.h" #include "app/gui/widgets/dungeon_object_emulator_preview.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace editor { diff --git a/src/app/editor/editor_manager.cc b/src/app/editor/editor_manager.cc index 86d02b47..08c63554 100644 --- a/src/app/editor/editor_manager.cc +++ b/src/app/editor/editor_manager.cc @@ -37,7 +37,7 @@ #include "app/gui/theme_manager.h" #include "app/rom.h" #include "app/test/test_manager.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld_map.h" #ifdef YAZE_ENABLE_TESTING #include "app/test/e2e_test_suite.h" #include "app/test/integrated_test_suite.h" diff --git a/src/app/editor/graphics/graphics_editor.h b/src/app/editor/graphics/graphics_editor.h index a6ede3c8..10e20efb 100644 --- a/src/app/editor/graphics/graphics_editor.h +++ b/src/app/editor/graphics/graphics_editor.h @@ -13,7 +13,7 @@ #include "app/gui/editor_layout.h" #include "app/gui/modules/asset_browser.h" #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "imgui/imgui.h" #include "imgui_memory_editor.h" diff --git a/src/app/editor/graphics/screen_editor.h b/src/app/editor/graphics/screen_editor.h index 530f47ba..a5d9cf19 100644 --- a/src/app/editor/graphics/screen_editor.h +++ b/src/app/editor/graphics/screen_editor.h @@ -11,8 +11,8 @@ #include "app/gfx/tilemap.h" #include "app/gui/canvas.h" #include "app/rom.h" -#include "app/zelda3/screen/dungeon_map.h" -#include "app/zelda3/screen/inventory.h" +#include "zelda3/screen/dungeon_map.h" +#include "zelda3/screen/inventory.h" #include "app/gui/editor_layout.h" #include "imgui/imgui.h" diff --git a/src/app/editor/music/music_editor.h b/src/app/editor/music/music_editor.h index 248f15ec..a054aea8 100644 --- a/src/app/editor/music/music_editor.h +++ b/src/app/editor/music/music_editor.h @@ -7,7 +7,7 @@ #include "app/gui/editor_card_manager.h" #include "app/gui/editor_layout.h" #include "app/rom.h" -#include "app/zelda3/music/tracker.h" +#include "zelda3/music/tracker.h" #include "imgui/imgui.h" namespace yaze { diff --git a/src/app/editor/overworld/entity.h b/src/app/editor/overworld/entity.h index 2d1fffb6..7d051f6e 100644 --- a/src/app/editor/overworld/entity.h +++ b/src/app/editor/overworld/entity.h @@ -1,11 +1,11 @@ #ifndef YAZE_APP_EDITOR_OVERWORLD_ENTITY_H #define YAZE_APP_EDITOR_OVERWORLD_ENTITY_H -#include "app/zelda3/common.h" -#include "app/zelda3/overworld/overworld_entrance.h" -#include "app/zelda3/overworld/overworld_exit.h" -#include "app/zelda3/overworld/overworld_item.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/common.h" +#include "zelda3/overworld/overworld_entrance.h" +#include "zelda3/overworld/overworld_exit.h" +#include "zelda3/overworld/overworld_item.h" +#include "zelda3/sprite/sprite.h" #include "imgui/imgui.h" namespace yaze { diff --git a/src/app/editor/overworld/map_properties.cc b/src/app/editor/overworld/map_properties.cc index 8c128850..24f8285c 100644 --- a/src/app/editor/overworld/map_properties.cc +++ b/src/app/editor/overworld/map_properties.cc @@ -7,7 +7,7 @@ #include "app/gui/color.h" #include "app/gui/icons.h" #include "app/gui/input.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld_map.h" #include "imgui/imgui.h" namespace yaze { diff --git a/src/app/editor/overworld/map_properties.h b/src/app/editor/overworld/map_properties.h index 93c5b404..1e4b4387 100644 --- a/src/app/editor/overworld/map_properties.h +++ b/src/app/editor/overworld/map_properties.h @@ -3,7 +3,7 @@ #include -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "app/rom.h" #include "app/gui/canvas.h" diff --git a/src/app/editor/overworld/overworld_editor.cc b/src/app/editor/overworld/overworld_editor.cc index 44279d51..2c825130 100644 --- a/src/app/editor/overworld/overworld_editor.cc +++ b/src/app/editor/overworld/overworld_editor.cc @@ -31,9 +31,9 @@ #include "app/gui/style.h" #include "app/gui/ui_helpers.h" #include "app/rom.h" -#include "app/zelda3/common.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/common.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" #include "imgui/imgui.h" #include "imgui_memory_editor.h" #include "util/file_util.h" diff --git a/src/app/editor/overworld/overworld_editor.h b/src/app/editor/overworld/overworld_editor.h index dba328a5..7e97be81 100644 --- a/src/app/editor/overworld/overworld_editor.h +++ b/src/app/editor/overworld/overworld_editor.h @@ -1,382 +1,382 @@ -#ifndef YAZE_APP_EDITOR_OVERWORLDEDITOR_H -#define YAZE_APP_EDITOR_OVERWORLDEDITOR_H - -#include "absl/status/status.h" -#include "app/editor/editor.h" -#include "app/editor/graphics/gfx_group_editor.h" -#include "app/editor/palette/palette_editor.h" -#include "app/gui/editor_card_manager.h" -#include "app/editor/overworld/tile16_editor.h" -#include "app/editor/overworld/map_properties.h" -#include "app/editor/overworld/overworld_entity_renderer.h" -#include "app/gfx/bitmap.h" -#include "app/gfx/snes_palette.h" -#include "app/gfx/tilemap.h" -#include "app/gui/canvas.h" -#include "app/gui/widgets/tile_selector_widget.h" -#include "app/gui/input.h" -#include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" -#include "imgui/imgui.h" -#include - -namespace yaze { -namespace editor { - -constexpr unsigned int k4BPP = 4; -constexpr unsigned int kByteSize = 3; -constexpr unsigned int kMessageIdSize = 5; -constexpr unsigned int kNumSheetsToLoad = 223; -constexpr unsigned int kOverworldMapSize = 0x200; -constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize * 8, - kOverworldMapSize * 8); -constexpr ImVec2 kCurrentGfxCanvasSize(0x100 + 1, 0x10 * 0x40 + 1); -constexpr ImVec2 kBlocksetCanvasSize(0x100 + 1, 0x4000 + 1); -constexpr ImVec2 kGraphicsBinCanvasSize(0x100 + 1, kNumSheetsToLoad * 0x40 + 1); - -constexpr ImGuiTableFlags kOWMapFlags = - ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | - ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp; - -constexpr absl::string_view kWorldList = - "Light World\0Dark World\0Extra World\0"; - -constexpr absl::string_view kGamePartComboString = "Part 0\0Part 1\0Part 2\0"; - -constexpr absl::string_view kOWMapTable = "#MapSettingsTable"; - -/** - * @class OverworldEditor - * @brief Manipulates the Overworld and OverworldMap data in a Rom. - * - * The `OverworldEditor` class is responsible for managing the editing and - * manipulation of the overworld in a game. The user can drag and drop tiles, - * modify OverworldEntrance, OverworldExit, Sprite, and OverworldItem - * as well as change the gfx and palettes used in each overworld map. - * - * The Overworld itself is a series of bitmap images which exist inside each - * OverworldMap object. The drawing of the overworld is done using the Canvas - * class in conjunction with these underlying Bitmap objects. - * - * Provides access to the GfxGroupEditor and Tile16Editor through popup windows. - * - */ -class OverworldEditor : public Editor, public gfx::GfxContext { - public: - explicit OverworldEditor(Rom* rom) : rom_(rom) { - type_ = EditorType::kOverworld; - gfx_group_editor_.set_rom(rom); - // MapPropertiesSystem will be initialized after maps_bmp_ and canvas are ready - } - - void Initialize(gfx::IRenderer* renderer, Rom* rom); - void Initialize() override; - absl::Status Load() override; - absl::Status Update() final; - absl::Status Undo() override { return absl::UnimplementedError("Undo"); } - absl::Status Redo() override { return absl::UnimplementedError("Redo"); } - absl::Status Cut() override { return absl::UnimplementedError("Cut"); } - absl::Status Copy() override; - absl::Status Paste() override; - absl::Status Find() override { return absl::UnimplementedError("Find"); } - absl::Status Save() override; - absl::Status Clear() override; - zelda3::Overworld& overworld() { return overworld_; } - - /** - * @brief Apply ZSCustomOverworld ASM patch to upgrade ROM version - */ - absl::Status ApplyZSCustomOverworldASM(int target_version); - - /** - * @brief Update ROM version markers and feature flags after ASM patching - */ - absl::Status UpdateROMVersionMarkers(int target_version); - - int jump_to_tab() { return jump_to_tab_; } - int jump_to_tab_ = -1; - - // ROM state methods (from Editor base class) - bool IsRomLoaded() const override { return rom_ && rom_->is_loaded(); } - std::string GetRomStatus() const override { - if (!rom_) return "No ROM loaded"; - if (!rom_->is_loaded()) return "ROM failed to load"; - return absl::StrFormat("ROM loaded: %s", rom_->title()); - } - - // Jump-to functionality - void set_current_map(int map_id) { - if (map_id >= 0 && map_id < zelda3::kNumOverworldMaps) { - current_map_ = map_id; - current_world_ = map_id / 0x40; // Calculate which world the map belongs to - } - } - - /** - * @brief Load the Bitmap objects for each OverworldMap. - * - * Calls the Overworld class to load the image data and palettes from the Rom, - * then renders the area graphics and tile16 blockset Bitmap objects before - * assembling the OverworldMap Bitmap objects. - */ - absl::Status LoadGraphics(); - - private: - void DrawFullscreenCanvas(); - void DrawToolset(); - - void RefreshChildMap(int map_index); - void RefreshOverworldMap(); - void RefreshOverworldMapOnDemand(int map_index); - void RefreshChildMapOnDemand(int map_index); - void RefreshMultiAreaMapsSafely(int map_index, zelda3::OverworldMap* map); - absl::Status RefreshMapPalette(); - void RefreshMapProperties(); - absl::Status RefreshTile16Blockset(); - void ForceRefreshGraphics(int map_index); - void RefreshSiblingMapGraphics(int map_index, bool include_self = false); - - void DrawOverworldMaps(); - void DrawOverworldEdits(); - void RenderUpdatedMapBitmap(const ImVec2& click_position, - const std::vector& tile_data); - - /** - * @brief Check for changes to the overworld map. - * - * This function either draws the tile painter with the current tile16 or - * group of tile16 data with ow_map_canvas_ and DrawOverworldEdits or it - * checks for left mouse button click/drag to select a tile16 or group of - * tile16 data from the overworld map canvas. Similar to ZScream selection. - */ - void CheckForOverworldEdits(); - - /** - * @brief Draw and create the tile16 IDs that are currently selected. - */ - void CheckForSelectRectangle(); - - // Selected tile IDs for rectangle operations (moved from local static) - std::vector selected_tile16_ids_; - - /** - * @brief Check for changes to the overworld map. Calls RefreshOverworldMap - * and RefreshTile16Blockset on the current map if it is modified and is - * actively being edited. - */ - absl::Status CheckForCurrentMap(); - void CheckForMousePan(); - void DrawOverworldCanvas(); - - absl::Status DrawTile16Selector(); - void DrawTile8Selector(); - absl::Status DrawAreaGraphics(); - void UpdateBlocksetSelectorState(); - - absl::Status LoadSpriteGraphics(); - - /** - * @brief Create textures for deferred map bitmaps on demand - * - * This method should be called periodically to create textures for maps - * that are needed but haven't had their textures created yet. This allows - * for smooth loading without blocking the main thread during ROM loading. - */ - void ProcessDeferredTextures(); - - /** - * @brief Ensure a specific map has its texture created - * - * Call this when a map becomes visible or is about to be rendered. - * It will create the texture if it doesn't exist yet. - */ - void EnsureMapTexture(int map_index); - - void DrawOverworldProperties(); - void HandleMapInteraction(); - // SetupOverworldCanvasContextMenu removed (Phase 3B) - now handled by MapPropertiesSystem - - // Canvas pan/zoom helpers (Overworld Refactoring) - void HandleOverworldPan(); - void HandleOverworldZoom(); - void ResetOverworldView(); - void CenterOverworldView(); - - // Canvas Automation API integration (Phase 4) - void SetupCanvasAutomation(); - gui::Canvas* GetOverworldCanvas() { return &ow_map_canvas_; } - - // Tile operations for automation callbacks - bool AutomationSetTile(int x, int y, int tile_id); - int AutomationGetTile(int x, int y); - - /** - * @brief Scroll the blockset canvas to show the current selected tile16 - */ - void ScrollBlocksetCanvasToCurrentTile(); - - // Scratch space canvas methods - absl::Status DrawScratchSpace(); - absl::Status SaveCurrentSelectionToScratch(int slot); - absl::Status LoadScratchToSelection(int slot); - absl::Status ClearScratchSpace(int slot); - void DrawScratchSpaceEdits(); - void DrawScratchSpacePattern(); - void DrawScratchSpaceSelection(); - void UpdateScratchBitmapTile(int tile_x, int tile_y, int tile_id, int slot = -1); - - absl::Status UpdateUsageStats(); - void DrawUsageGrid(); - void DrawDebugWindow(); - - enum class EditingMode { - MOUSE, // Navigation, selection, entity management via context menu - DRAW_TILE // Tile painting mode - }; - - EditingMode current_mode = EditingMode::DRAW_TILE; - EditingMode previous_mode = EditingMode::DRAW_TILE; - - // Entity editing state (managed via context menu now) - enum class EntityEditMode { - NONE, - ENTRANCES, - EXITS, - ITEMS, - SPRITES, - TRANSPORTS, - MUSIC - }; - - EntityEditMode entity_edit_mode_ = EntityEditMode::NONE; - - enum OverworldProperty { - LW_AREA_GFX, - DW_AREA_GFX, - LW_AREA_PAL, - DW_AREA_PAL, - LW_SPR_GFX_PART1, - LW_SPR_GFX_PART2, - DW_SPR_GFX_PART1, - DW_SPR_GFX_PART2, - LW_SPR_PAL_PART1, - LW_SPR_PAL_PART2, - DW_SPR_PAL_PART1, - DW_SPR_PAL_PART2, - }; - - int current_world_ = 0; - int current_map_ = 0; - int current_parent_ = 0; - int current_entrance_id_ = 0; - int current_exit_id_ = 0; - int current_item_id_ = 0; - int current_sprite_id_ = 0; - int current_blockset_ = 0; - int game_state_ = 1; - int current_tile16_ = 0; - int selected_entrance_ = 0; - int selected_usage_map_ = 0xFFFF; - - bool all_gfx_loaded_ = false; - bool map_blockset_loaded_ = false; - bool selected_tile_loaded_ = false; - bool show_tile16_editor_ = false; - bool show_gfx_group_editor_ = false; - bool show_properties_editor_ = false; - bool overworld_canvas_fullscreen_ = false; - bool middle_mouse_dragging_ = false; - bool is_dragging_entity_ = false; - bool dragged_entity_free_movement_ = false; - bool current_map_lock_ = false; - bool show_custom_bg_color_editor_ = false; - bool show_overlay_editor_ = false; - bool use_area_specific_bg_color_ = false; - bool show_map_properties_panel_ = false; - bool show_overlay_preview_ = false; - - // Card visibility states - Start hidden to prevent crash - bool show_overworld_canvas_ = true; - bool show_tile16_selector_ = false; - bool show_tile8_selector_ = false; - bool show_area_gfx_ = false; - bool show_scratch_ = false; - bool show_gfx_groups_ = false; - bool show_usage_stats_ = false; - bool show_v3_settings_ = false; - - // Map properties system for UI organization - std::unique_ptr map_properties_system_; - std::unique_ptr entity_renderer_; - - // Scratch space for large layouts - // Scratch space canvas for tile16 drawing (like a mini overworld) - struct ScratchSpaceSlot { - gfx::Bitmap scratch_bitmap; - std::array, 32> tile_data; // 32x32 grid of tile16 IDs - bool in_use = false; - std::string name = "Empty"; - int width = 16; // Default 16x16 tiles - int height = 16; - // Independent selection system for scratch space - std::vector selected_tiles; - std::vector selected_points; - bool select_rect_active = false; - }; - std::array scratch_spaces_; - int current_scratch_slot_ = 0; - - gfx::Tilemap tile16_blockset_; - - Rom* rom_; - - gfx::IRenderer* renderer_; - Tile16Editor tile16_editor_{rom_, &tile16_blockset_}; - GfxGroupEditor gfx_group_editor_; - PaletteEditor palette_editor_; - - gfx::SnesPalette palette_; - - gfx::Bitmap selected_tile_bmp_; - gfx::Bitmap tile16_blockset_bmp_; - gfx::Bitmap current_gfx_bmp_; - gfx::Bitmap all_gfx_bmp; - - std::array maps_bmp_; - gfx::BitmapTable current_graphics_set_; - std::vector sprite_previews_; - - // Deferred texture creation for performance optimization - // Deferred texture management now handled by gfx::Arena::Get() - - zelda3::Overworld overworld_{rom_}; - zelda3::OverworldBlockset refresh_blockset_; - - zelda3::Sprite current_sprite_; - - zelda3::OverworldEntrance current_entrance_; - zelda3::OverworldExit current_exit_; - zelda3::OverworldItem current_item_; - zelda3::OverworldEntranceTileTypes entrance_tiletypes_ = {}; - - zelda3::GameEntity* current_entity_ = nullptr; - zelda3::GameEntity* dragged_entity_ = nullptr; - - gui::Canvas ow_map_canvas_{"OwMap", kOverworldCanvasSize, - gui::CanvasGridSize::k64x64}; - gui::Canvas current_gfx_canvas_{"CurrentGfx", kCurrentGfxCanvasSize, - gui::CanvasGridSize::k32x32}; - gui::Canvas blockset_canvas_{"OwBlockset", kBlocksetCanvasSize, - gui::CanvasGridSize::k32x32}; - std::unique_ptr blockset_selector_; - gui::Canvas graphics_bin_canvas_{"GraphicsBin", kGraphicsBinCanvasSize, - gui::CanvasGridSize::k16x16}; - gui::Canvas properties_canvas_; - gui::Canvas scratch_canvas_{"ScratchSpace", ImVec2(320, 480), gui::CanvasGridSize::k32x32}; - - absl::Status status_; -}; -} // namespace editor -} // namespace yaze - -#endif +#ifndef YAZE_APP_EDITOR_OVERWORLDEDITOR_H +#define YAZE_APP_EDITOR_OVERWORLDEDITOR_H + +#include "absl/status/status.h" +#include "app/editor/editor.h" +#include "app/editor/graphics/gfx_group_editor.h" +#include "app/editor/palette/palette_editor.h" +#include "app/gui/editor_card_manager.h" +#include "app/editor/overworld/tile16_editor.h" +#include "app/editor/overworld/map_properties.h" +#include "app/editor/overworld/overworld_entity_renderer.h" +#include "app/gfx/bitmap.h" +#include "app/gfx/snes_palette.h" +#include "app/gfx/tilemap.h" +#include "app/gui/canvas.h" +#include "app/gui/widgets/tile_selector_widget.h" +#include "app/gui/input.h" +#include "app/rom.h" +#include "zelda3/overworld/overworld.h" +#include "imgui/imgui.h" +#include + +namespace yaze { +namespace editor { + +constexpr unsigned int k4BPP = 4; +constexpr unsigned int kByteSize = 3; +constexpr unsigned int kMessageIdSize = 5; +constexpr unsigned int kNumSheetsToLoad = 223; +constexpr unsigned int kOverworldMapSize = 0x200; +constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize * 8, + kOverworldMapSize * 8); +constexpr ImVec2 kCurrentGfxCanvasSize(0x100 + 1, 0x10 * 0x40 + 1); +constexpr ImVec2 kBlocksetCanvasSize(0x100 + 1, 0x4000 + 1); +constexpr ImVec2 kGraphicsBinCanvasSize(0x100 + 1, kNumSheetsToLoad * 0x40 + 1); + +constexpr ImGuiTableFlags kOWMapFlags = + ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | + ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp; + +constexpr absl::string_view kWorldList = + "Light World\0Dark World\0Extra World\0"; + +constexpr absl::string_view kGamePartComboString = "Part 0\0Part 1\0Part 2\0"; + +constexpr absl::string_view kOWMapTable = "#MapSettingsTable"; + +/** + * @class OverworldEditor + * @brief Manipulates the Overworld and OverworldMap data in a Rom. + * + * The `OverworldEditor` class is responsible for managing the editing and + * manipulation of the overworld in a game. The user can drag and drop tiles, + * modify OverworldEntrance, OverworldExit, Sprite, and OverworldItem + * as well as change the gfx and palettes used in each overworld map. + * + * The Overworld itself is a series of bitmap images which exist inside each + * OverworldMap object. The drawing of the overworld is done using the Canvas + * class in conjunction with these underlying Bitmap objects. + * + * Provides access to the GfxGroupEditor and Tile16Editor through popup windows. + * + */ +class OverworldEditor : public Editor, public gfx::GfxContext { + public: + explicit OverworldEditor(Rom* rom) : rom_(rom) { + type_ = EditorType::kOverworld; + gfx_group_editor_.set_rom(rom); + // MapPropertiesSystem will be initialized after maps_bmp_ and canvas are ready + } + + void Initialize(gfx::IRenderer* renderer, Rom* rom); + void Initialize() override; + absl::Status Load() override; + absl::Status Update() final; + absl::Status Undo() override { return absl::UnimplementedError("Undo"); } + absl::Status Redo() override { return absl::UnimplementedError("Redo"); } + absl::Status Cut() override { return absl::UnimplementedError("Cut"); } + absl::Status Copy() override; + absl::Status Paste() override; + absl::Status Find() override { return absl::UnimplementedError("Find"); } + absl::Status Save() override; + absl::Status Clear() override; + zelda3::Overworld& overworld() { return overworld_; } + + /** + * @brief Apply ZSCustomOverworld ASM patch to upgrade ROM version + */ + absl::Status ApplyZSCustomOverworldASM(int target_version); + + /** + * @brief Update ROM version markers and feature flags after ASM patching + */ + absl::Status UpdateROMVersionMarkers(int target_version); + + int jump_to_tab() { return jump_to_tab_; } + int jump_to_tab_ = -1; + + // ROM state methods (from Editor base class) + bool IsRomLoaded() const override { return rom_ && rom_->is_loaded(); } + std::string GetRomStatus() const override { + if (!rom_) return "No ROM loaded"; + if (!rom_->is_loaded()) return "ROM failed to load"; + return absl::StrFormat("ROM loaded: %s", rom_->title()); + } + + // Jump-to functionality + void set_current_map(int map_id) { + if (map_id >= 0 && map_id < zelda3::kNumOverworldMaps) { + current_map_ = map_id; + current_world_ = map_id / 0x40; // Calculate which world the map belongs to + } + } + + /** + * @brief Load the Bitmap objects for each OverworldMap. + * + * Calls the Overworld class to load the image data and palettes from the Rom, + * then renders the area graphics and tile16 blockset Bitmap objects before + * assembling the OverworldMap Bitmap objects. + */ + absl::Status LoadGraphics(); + + private: + void DrawFullscreenCanvas(); + void DrawToolset(); + + void RefreshChildMap(int map_index); + void RefreshOverworldMap(); + void RefreshOverworldMapOnDemand(int map_index); + void RefreshChildMapOnDemand(int map_index); + void RefreshMultiAreaMapsSafely(int map_index, zelda3::OverworldMap* map); + absl::Status RefreshMapPalette(); + void RefreshMapProperties(); + absl::Status RefreshTile16Blockset(); + void ForceRefreshGraphics(int map_index); + void RefreshSiblingMapGraphics(int map_index, bool include_self = false); + + void DrawOverworldMaps(); + void DrawOverworldEdits(); + void RenderUpdatedMapBitmap(const ImVec2& click_position, + const std::vector& tile_data); + + /** + * @brief Check for changes to the overworld map. + * + * This function either draws the tile painter with the current tile16 or + * group of tile16 data with ow_map_canvas_ and DrawOverworldEdits or it + * checks for left mouse button click/drag to select a tile16 or group of + * tile16 data from the overworld map canvas. Similar to ZScream selection. + */ + void CheckForOverworldEdits(); + + /** + * @brief Draw and create the tile16 IDs that are currently selected. + */ + void CheckForSelectRectangle(); + + // Selected tile IDs for rectangle operations (moved from local static) + std::vector selected_tile16_ids_; + + /** + * @brief Check for changes to the overworld map. Calls RefreshOverworldMap + * and RefreshTile16Blockset on the current map if it is modified and is + * actively being edited. + */ + absl::Status CheckForCurrentMap(); + void CheckForMousePan(); + void DrawOverworldCanvas(); + + absl::Status DrawTile16Selector(); + void DrawTile8Selector(); + absl::Status DrawAreaGraphics(); + void UpdateBlocksetSelectorState(); + + absl::Status LoadSpriteGraphics(); + + /** + * @brief Create textures for deferred map bitmaps on demand + * + * This method should be called periodically to create textures for maps + * that are needed but haven't had their textures created yet. This allows + * for smooth loading without blocking the main thread during ROM loading. + */ + void ProcessDeferredTextures(); + + /** + * @brief Ensure a specific map has its texture created + * + * Call this when a map becomes visible or is about to be rendered. + * It will create the texture if it doesn't exist yet. + */ + void EnsureMapTexture(int map_index); + + void DrawOverworldProperties(); + void HandleMapInteraction(); + // SetupOverworldCanvasContextMenu removed (Phase 3B) - now handled by MapPropertiesSystem + + // Canvas pan/zoom helpers (Overworld Refactoring) + void HandleOverworldPan(); + void HandleOverworldZoom(); + void ResetOverworldView(); + void CenterOverworldView(); + + // Canvas Automation API integration (Phase 4) + void SetupCanvasAutomation(); + gui::Canvas* GetOverworldCanvas() { return &ow_map_canvas_; } + + // Tile operations for automation callbacks + bool AutomationSetTile(int x, int y, int tile_id); + int AutomationGetTile(int x, int y); + + /** + * @brief Scroll the blockset canvas to show the current selected tile16 + */ + void ScrollBlocksetCanvasToCurrentTile(); + + // Scratch space canvas methods + absl::Status DrawScratchSpace(); + absl::Status SaveCurrentSelectionToScratch(int slot); + absl::Status LoadScratchToSelection(int slot); + absl::Status ClearScratchSpace(int slot); + void DrawScratchSpaceEdits(); + void DrawScratchSpacePattern(); + void DrawScratchSpaceSelection(); + void UpdateScratchBitmapTile(int tile_x, int tile_y, int tile_id, int slot = -1); + + absl::Status UpdateUsageStats(); + void DrawUsageGrid(); + void DrawDebugWindow(); + + enum class EditingMode { + MOUSE, // Navigation, selection, entity management via context menu + DRAW_TILE // Tile painting mode + }; + + EditingMode current_mode = EditingMode::DRAW_TILE; + EditingMode previous_mode = EditingMode::DRAW_TILE; + + // Entity editing state (managed via context menu now) + enum class EntityEditMode { + NONE, + ENTRANCES, + EXITS, + ITEMS, + SPRITES, + TRANSPORTS, + MUSIC + }; + + EntityEditMode entity_edit_mode_ = EntityEditMode::NONE; + + enum OverworldProperty { + LW_AREA_GFX, + DW_AREA_GFX, + LW_AREA_PAL, + DW_AREA_PAL, + LW_SPR_GFX_PART1, + LW_SPR_GFX_PART2, + DW_SPR_GFX_PART1, + DW_SPR_GFX_PART2, + LW_SPR_PAL_PART1, + LW_SPR_PAL_PART2, + DW_SPR_PAL_PART1, + DW_SPR_PAL_PART2, + }; + + int current_world_ = 0; + int current_map_ = 0; + int current_parent_ = 0; + int current_entrance_id_ = 0; + int current_exit_id_ = 0; + int current_item_id_ = 0; + int current_sprite_id_ = 0; + int current_blockset_ = 0; + int game_state_ = 1; + int current_tile16_ = 0; + int selected_entrance_ = 0; + int selected_usage_map_ = 0xFFFF; + + bool all_gfx_loaded_ = false; + bool map_blockset_loaded_ = false; + bool selected_tile_loaded_ = false; + bool show_tile16_editor_ = false; + bool show_gfx_group_editor_ = false; + bool show_properties_editor_ = false; + bool overworld_canvas_fullscreen_ = false; + bool middle_mouse_dragging_ = false; + bool is_dragging_entity_ = false; + bool dragged_entity_free_movement_ = false; + bool current_map_lock_ = false; + bool show_custom_bg_color_editor_ = false; + bool show_overlay_editor_ = false; + bool use_area_specific_bg_color_ = false; + bool show_map_properties_panel_ = false; + bool show_overlay_preview_ = false; + + // Card visibility states - Start hidden to prevent crash + bool show_overworld_canvas_ = true; + bool show_tile16_selector_ = false; + bool show_tile8_selector_ = false; + bool show_area_gfx_ = false; + bool show_scratch_ = false; + bool show_gfx_groups_ = false; + bool show_usage_stats_ = false; + bool show_v3_settings_ = false; + + // Map properties system for UI organization + std::unique_ptr map_properties_system_; + std::unique_ptr entity_renderer_; + + // Scratch space for large layouts + // Scratch space canvas for tile16 drawing (like a mini overworld) + struct ScratchSpaceSlot { + gfx::Bitmap scratch_bitmap; + std::array, 32> tile_data; // 32x32 grid of tile16 IDs + bool in_use = false; + std::string name = "Empty"; + int width = 16; // Default 16x16 tiles + int height = 16; + // Independent selection system for scratch space + std::vector selected_tiles; + std::vector selected_points; + bool select_rect_active = false; + }; + std::array scratch_spaces_; + int current_scratch_slot_ = 0; + + gfx::Tilemap tile16_blockset_; + + Rom* rom_; + + gfx::IRenderer* renderer_; + Tile16Editor tile16_editor_{rom_, &tile16_blockset_}; + GfxGroupEditor gfx_group_editor_; + PaletteEditor palette_editor_; + + gfx::SnesPalette palette_; + + gfx::Bitmap selected_tile_bmp_; + gfx::Bitmap tile16_blockset_bmp_; + gfx::Bitmap current_gfx_bmp_; + gfx::Bitmap all_gfx_bmp; + + std::array maps_bmp_; + gfx::BitmapTable current_graphics_set_; + std::vector sprite_previews_; + + // Deferred texture creation for performance optimization + // Deferred texture management now handled by gfx::Arena::Get() + + zelda3::Overworld overworld_{rom_}; + zelda3::OverworldBlockset refresh_blockset_; + + zelda3::Sprite current_sprite_; + + zelda3::OverworldEntrance current_entrance_; + zelda3::OverworldExit current_exit_; + zelda3::OverworldItem current_item_; + zelda3::OverworldEntranceTileTypes entrance_tiletypes_ = {}; + + zelda3::GameEntity* current_entity_ = nullptr; + zelda3::GameEntity* dragged_entity_ = nullptr; + + gui::Canvas ow_map_canvas_{"OwMap", kOverworldCanvasSize, + gui::CanvasGridSize::k64x64}; + gui::Canvas current_gfx_canvas_{"CurrentGfx", kCurrentGfxCanvasSize, + gui::CanvasGridSize::k32x32}; + gui::Canvas blockset_canvas_{"OwBlockset", kBlocksetCanvasSize, + gui::CanvasGridSize::k32x32}; + std::unique_ptr blockset_selector_; + gui::Canvas graphics_bin_canvas_{"GraphicsBin", kGraphicsBinCanvasSize, + gui::CanvasGridSize::k16x16}; + gui::Canvas properties_canvas_; + gui::Canvas scratch_canvas_{"ScratchSpace", ImVec2(320, 480), gui::CanvasGridSize::k32x32}; + + absl::Status status_; +}; +} // namespace editor +} // namespace yaze + +#endif diff --git a/src/app/editor/overworld/overworld_entity_renderer.cc b/src/app/editor/overworld/overworld_entity_renderer.cc index a2f9d617..a009e2a3 100644 --- a/src/app/editor/overworld/overworld_entity_renderer.cc +++ b/src/app/editor/overworld/overworld_entity_renderer.cc @@ -4,7 +4,7 @@ #include "app/core/features.h" #include "app/editor/overworld/entity.h" #include "app/gui/canvas.h" -#include "app/zelda3/common.h" +#include "zelda3/common.h" #include "util/hex.h" #include "imgui/imgui.h" diff --git a/src/app/editor/overworld/overworld_entity_renderer.h b/src/app/editor/overworld/overworld_entity_renderer.h index b96886c3..e9caf22f 100644 --- a/src/app/editor/overworld/overworld_entity_renderer.h +++ b/src/app/editor/overworld/overworld_entity_renderer.h @@ -5,8 +5,8 @@ #include "app/gfx/bitmap.h" #include "app/gui/canvas.h" -#include "app/zelda3/common.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/common.h" +#include "zelda3/overworld/overworld.h" #include "imgui/imgui.h" namespace yaze { diff --git a/src/app/editor/overworld/scratch_space.cc b/src/app/editor/overworld/scratch_space.cc index dcdbaaa1..ba6e3f19 100644 --- a/src/app/editor/overworld/scratch_space.cc +++ b/src/app/editor/overworld/scratch_space.cc @@ -27,9 +27,9 @@ #include "app/gui/input.h" #include "app/gui/style.h" #include "app/rom.h" -#include "app/zelda3/common.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/common.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" #include "imgui/imgui.h" #include "imgui_memory_editor.h" #include "util/hex.h" diff --git a/src/app/editor/overworld/tile16_editor.cc b/src/app/editor/overworld/tile16_editor.cc index 3b7cc036..6ae97dce 100644 --- a/src/app/editor/overworld/tile16_editor.cc +++ b/src/app/editor/overworld/tile16_editor.cc @@ -12,7 +12,7 @@ #include "app/gui/input.h" #include "app/gui/style.h" #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "imgui/imgui.h" #include "util/hex.h" #include "util/log.h" diff --git a/src/app/editor/sprite/sprite_editor.cc b/src/app/editor/sprite/sprite_editor.cc index 582d578e..133d2fa3 100644 --- a/src/app/editor/sprite/sprite_editor.cc +++ b/src/app/editor/sprite/sprite_editor.cc @@ -7,7 +7,7 @@ #include "app/gfx/arena.h" #include "app/gui/icons.h" #include "app/gui/input.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/sprite/sprite.h" #include "util/hex.h" namespace yaze { diff --git a/src/app/gfx/palette_manager.cc b/src/app/gfx/palette_manager.cc index 0d98080f..34a0154e 100644 --- a/src/app/gfx/palette_manager.cc +++ b/src/app/gfx/palette_manager.cc @@ -252,12 +252,11 @@ absl::Status PaletteManager::SaveGroup(const std::string& group_name) { auto color_it = modified_colors_[group_name].find(palette_idx); if (color_it != modified_colors_[group_name].end()) { for (int color_idx : color_it->second) { - // Calculate ROM address - uint32_t address = - GetPaletteAddress(group_name, palette_idx, color_idx); + // Calculate ROM address using the helper function + uint32_t address = GetPaletteAddress(group_name, palette_idx, color_idx); - // Write color to ROM - RETURN_IF_ERROR(rom_->WriteColor(address, (*palette)[color_idx])); + // Write color to ROM - write the 16-bit SNES color value + rom_->WriteShort(address, (*palette)[color_idx].snes()); } } } diff --git a/src/app/gui/widgets/dungeon_object_emulator_preview.cc b/src/app/gui/widgets/dungeon_object_emulator_preview.cc index 7094c5f7..93deaa22 100644 --- a/src/app/gui/widgets/dungeon_object_emulator_preview.cc +++ b/src/app/gui/widgets/dungeon_object_emulator_preview.cc @@ -1,8 +1,8 @@ #include "app/gui/widgets/dungeon_object_emulator_preview.h" #include "app/gfx/backend/irenderer.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" #include "app/gui/widgets/widget_auto_register.h" #include "app/core/window.h" #include diff --git a/src/app/test/rom_dependent_test_suite.h b/src/app/test/rom_dependent_test_suite.h index d4f6330d..3716f2dd 100644 --- a/src/app/test/rom_dependent_test_suite.h +++ b/src/app/test/rom_dependent_test_suite.h @@ -7,7 +7,7 @@ #include "absl/strings/str_format.h" #include "app/test/test_manager.h" #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "app/editor/overworld/tile16_editor.h" #include "app/gui/icons.h" diff --git a/src/cli/handlers/README.md b/src/cli/handlers/README.md index fafc3c9a..7e621278 100644 --- a/src/cli/handlers/README.md +++ b/src/cli/handlers/README.md @@ -277,7 +277,7 @@ formatter.EndObject(); Command handlers are designed to work alongside the public C API defined in `incl/yaze.h` and `incl/zelda.h`. -- Handlers use internal C++ classes from `app/zelda3/` +- Handlers use internal C++ classes from `zelda3/` - Output structures align with C API data types where possible - Future: C API bridge will expose commands to external applications diff --git a/src/cli/handlers/agent/general_commands.cc b/src/cli/handlers/agent/general_commands.cc index 5fcf9103..4b724fe1 100644 --- a/src/cli/handlers/agent/general_commands.cc +++ b/src/cli/handlers/agent/general_commands.cc @@ -20,7 +20,7 @@ #include "absl/time/time.h" #include "absl/strings/string_view.h" #include "app/core/project.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room.h" #include "cli/handlers/agent/common.h" #include "cli/cli.h" #include "cli/service/ai/ai_service.h" diff --git a/src/cli/handlers/game/dungeon.cc b/src/cli/handlers/game/dungeon.cc index a96d0a7a..7ed0797b 100644 --- a/src/cli/handlers/game/dungeon.cc +++ b/src/cli/handlers/game/dungeon.cc @@ -1,6 +1,6 @@ #include "cli/cli.h" -#include "app/zelda3/dungeon/dungeon_editor_system.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/dungeon_editor_system.h" +#include "zelda3/dungeon/room.h" #include "absl/flags/flag.h" #include "absl/flags/declare.h" diff --git a/src/cli/handlers/game/dungeon_commands.cc b/src/cli/handlers/game/dungeon_commands.cc index 7870d6b6..02aac640 100644 --- a/src/cli/handlers/game/dungeon_commands.cc +++ b/src/cli/handlers/game/dungeon_commands.cc @@ -2,7 +2,7 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_format.h" -#include "app/zelda3/dungeon/dungeon_editor_system.h" +#include "zelda3/dungeon/dungeon_editor_system.h" namespace yaze { namespace cli { diff --git a/src/cli/handlers/game/overworld.cc b/src/cli/handlers/game/overworld.cc index 2f3d7585..c08a46e9 100644 --- a/src/cli/handlers/game/overworld.cc +++ b/src/cli/handlers/game/overworld.cc @@ -1,5 +1,5 @@ #include "cli/cli.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "cli/handlers/game/overworld_inspect.h" #include diff --git a/src/cli/handlers/game/overworld_inspect.cc b/src/cli/handlers/game/overworld_inspect.cc index b9456aa7..7a29a038 100644 --- a/src/cli/handlers/game/overworld_inspect.cc +++ b/src/cli/handlers/game/overworld_inspect.cc @@ -10,11 +10,11 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "app/zelda3/common.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_entrance.h" -#include "app/zelda3/overworld/overworld_exit.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/common.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_entrance.h" +#include "zelda3/overworld/overworld_exit.h" +#include "zelda3/overworld/overworld_map.h" #include "util/macro.h" namespace yaze { diff --git a/src/cli/handlers/graphics/sprite_commands.cc b/src/cli/handlers/graphics/sprite_commands.cc index aa3d081d..e199257f 100644 --- a/src/cli/handlers/graphics/sprite_commands.cc +++ b/src/cli/handlers/graphics/sprite_commands.cc @@ -2,7 +2,7 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_format.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/sprite/sprite.h" namespace yaze { namespace cli { diff --git a/src/cli/handlers/rom/mock_rom.cc b/src/cli/handlers/rom/mock_rom.cc index 67edaba4..b678415e 100644 --- a/src/cli/handlers/rom/mock_rom.cc +++ b/src/cli/handlers/rom/mock_rom.cc @@ -6,7 +6,7 @@ #include "absl/flags/flag.h" #include "absl/strings/str_format.h" #include "app/core/project.h" -#include "app/zelda3/zelda3_labels.h" +#include "zelda3/zelda3_labels.h" ABSL_DECLARE_FLAG(bool, mock_rom); diff --git a/src/cli/service/agent/agent_pretraining.cc b/src/cli/service/agent/agent_pretraining.cc index fffdf4ca..310642db 100644 --- a/src/cli/service/agent/agent_pretraining.cc +++ b/src/cli/service/agent/agent_pretraining.cc @@ -2,7 +2,7 @@ #include "absl/strings/str_format.h" #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" namespace yaze { namespace cli { diff --git a/src/cli/service/planning/tile16_proposal_generator.cc b/src/cli/service/planning/tile16_proposal_generator.cc index 0674437d..0165f154 100644 --- a/src/cli/service/planning/tile16_proposal_generator.cc +++ b/src/cli/service/planning/tile16_proposal_generator.cc @@ -7,7 +7,7 @@ #include "absl/strings/str_split.h" #include "absl/strings/str_cat.h" #include "absl/strings/numbers.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "nlohmann/json.hpp" #include "util/macro.h" diff --git a/src/yaze.cc b/src/yaze.cc index 27d15369..5b409727 100644 --- a/src/yaze.cc +++ b/src/yaze.cc @@ -9,7 +9,7 @@ #include "app/editor/message/message_data.h" #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "yaze_config.h" // Static variables for library state diff --git a/src/app/zelda3/common.h b/src/zelda3/common.h similarity index 100% rename from src/app/zelda3/common.h rename to src/zelda3/common.h diff --git a/src/app/zelda3/dungeon/dungeon_editor_system.cc b/src/zelda3/dungeon/dungeon_editor_system.cc similarity index 100% rename from src/app/zelda3/dungeon/dungeon_editor_system.cc rename to src/zelda3/dungeon/dungeon_editor_system.cc diff --git a/src/app/zelda3/dungeon/dungeon_editor_system.h b/src/zelda3/dungeon/dungeon_editor_system.h similarity index 99% rename from src/app/zelda3/dungeon/dungeon_editor_system.h rename to src/zelda3/dungeon/dungeon_editor_system.h index d9466d88..87a7bc0b 100644 --- a/src/app/zelda3/dungeon/dungeon_editor_system.h +++ b/src/zelda3/dungeon/dungeon_editor_system.h @@ -13,9 +13,9 @@ #include "app/gfx/bitmap.h" #include "app/gfx/snes_palette.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room_object.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/sprite/sprite.h" #include "dungeon_object_editor.h" namespace yaze { diff --git a/src/app/zelda3/dungeon/dungeon_object_editor.cc b/src/zelda3/dungeon/dungeon_object_editor.cc similarity index 100% rename from src/app/zelda3/dungeon/dungeon_object_editor.cc rename to src/zelda3/dungeon/dungeon_object_editor.cc diff --git a/src/app/zelda3/dungeon/dungeon_object_editor.h b/src/zelda3/dungeon/dungeon_object_editor.h similarity index 99% rename from src/app/zelda3/dungeon/dungeon_object_editor.h rename to src/zelda3/dungeon/dungeon_object_editor.h index 62179d15..28d2da22 100644 --- a/src/app/zelda3/dungeon/dungeon_object_editor.h +++ b/src/zelda3/dungeon/dungeon_object_editor.h @@ -13,8 +13,8 @@ #include "app/gfx/bitmap.h" #include "app/gfx/snes_palette.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/dungeon/dungeon_rom_addresses.h b/src/zelda3/dungeon/dungeon_rom_addresses.h similarity index 100% rename from src/app/zelda3/dungeon/dungeon_rom_addresses.h rename to src/zelda3/dungeon/dungeon_rom_addresses.h diff --git a/src/app/zelda3/dungeon/object_drawer.cc b/src/zelda3/dungeon/object_drawer.cc similarity index 100% rename from src/app/zelda3/dungeon/object_drawer.cc rename to src/zelda3/dungeon/object_drawer.cc diff --git a/src/app/zelda3/dungeon/object_drawer.h b/src/zelda3/dungeon/object_drawer.h similarity index 99% rename from src/app/zelda3/dungeon/object_drawer.h rename to src/zelda3/dungeon/object_drawer.h index c683b775..aca6ba8e 100644 --- a/src/app/zelda3/dungeon/object_drawer.h +++ b/src/zelda3/dungeon/object_drawer.h @@ -10,7 +10,7 @@ #include "app/gfx/snes_tile.h" #include "app/gfx/snes_palette.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/dungeon/object_parser.cc b/src/zelda3/dungeon/object_parser.cc similarity index 99% rename from src/app/zelda3/dungeon/object_parser.cc rename to src/zelda3/dungeon/object_parser.cc index 10203714..8409e218 100644 --- a/src/app/zelda3/dungeon/object_parser.cc +++ b/src/zelda3/dungeon/object_parser.cc @@ -4,7 +4,7 @@ #include #include "absl/strings/str_format.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room_object.h" #include "util/log.h" // ROM addresses for object data (PC addresses, not SNES) diff --git a/src/app/zelda3/dungeon/object_parser.h b/src/zelda3/dungeon/object_parser.h similarity index 100% rename from src/app/zelda3/dungeon/object_parser.h rename to src/zelda3/dungeon/object_parser.h diff --git a/src/app/zelda3/dungeon/room.cc b/src/zelda3/dungeon/room.cc similarity index 99% rename from src/app/zelda3/dungeon/room.cc rename to src/zelda3/dungeon/room.cc index 162d9151..f9990ddb 100644 --- a/src/app/zelda3/dungeon/room.cc +++ b/src/zelda3/dungeon/room.cc @@ -10,9 +10,9 @@ #include "app/gfx/snes_palette.h" #include "app/rom.h" #include "app/snes.h" -#include "app/zelda3/dungeon/object_drawer.h" -#include "app/zelda3/dungeon/room_object.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/dungeon/object_drawer.h" +#include "zelda3/dungeon/room_object.h" +#include "zelda3/sprite/sprite.h" #include "util/log.h" namespace yaze { diff --git a/src/app/zelda3/dungeon/room.h b/src/zelda3/dungeon/room.h similarity index 99% rename from src/app/zelda3/dungeon/room.h rename to src/zelda3/dungeon/room.h index 08fe0241..5e044e0d 100644 --- a/src/app/zelda3/dungeon/room.h +++ b/src/zelda3/dungeon/room.h @@ -9,10 +9,10 @@ #include "app/rom.h" #include "app/gfx/background_buffer.h" -#include "app/zelda3/dungeon/dungeon_rom_addresses.h" -#include "app/zelda3/dungeon/room_object.h" -#include "app/zelda3/dungeon/room_layout.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/dungeon/dungeon_rom_addresses.h" +#include "zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room_layout.h" +#include "zelda3/sprite/sprite.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/dungeon/room_entrance.h b/src/zelda3/dungeon/room_entrance.h similarity index 100% rename from src/app/zelda3/dungeon/room_entrance.h rename to src/zelda3/dungeon/room_entrance.h diff --git a/src/app/zelda3/dungeon/room_layout.cc b/src/zelda3/dungeon/room_layout.cc similarity index 97% rename from src/app/zelda3/dungeon/room_layout.cc rename to src/zelda3/dungeon/room_layout.cc index 25d9735b..14345126 100644 --- a/src/app/zelda3/dungeon/room_layout.cc +++ b/src/zelda3/dungeon/room_layout.cc @@ -2,7 +2,7 @@ #include "absl/strings/str_format.h" #include "app/snes.h" -#include "app/zelda3/dungeon/dungeon_rom_addresses.h" +#include "zelda3/dungeon/dungeon_rom_addresses.h" namespace yaze::zelda3 { diff --git a/src/app/zelda3/dungeon/room_layout.h b/src/zelda3/dungeon/room_layout.h similarity index 94% rename from src/app/zelda3/dungeon/room_layout.h rename to src/zelda3/dungeon/room_layout.h index 6d7790d2..26dcc741 100644 --- a/src/app/zelda3/dungeon/room_layout.h +++ b/src/zelda3/dungeon/room_layout.h @@ -6,7 +6,7 @@ #include "absl/status/status.h" #include "absl/status/statusor.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room_object.h" namespace yaze::zelda3 { diff --git a/src/app/zelda3/dungeon/room_object.cc b/src/zelda3/dungeon/room_object.cc similarity index 99% rename from src/app/zelda3/dungeon/room_object.cc rename to src/zelda3/dungeon/room_object.cc index a9f9acf3..49038dab 100644 --- a/src/app/zelda3/dungeon/room_object.cc +++ b/src/zelda3/dungeon/room_object.cc @@ -1,7 +1,7 @@ #include "room_object.h" #include "absl/status/status.h" -#include "app/zelda3/dungeon/object_parser.h" +#include "zelda3/dungeon/object_parser.h" #include "util/log.h" namespace yaze { diff --git a/src/app/zelda3/dungeon/room_object.h b/src/zelda3/dungeon/room_object.h similarity index 99% rename from src/app/zelda3/dungeon/room_object.h rename to src/zelda3/dungeon/room_object.h index 1c9f6639..f7c2af18 100644 --- a/src/app/zelda3/dungeon/room_object.h +++ b/src/zelda3/dungeon/room_object.h @@ -7,7 +7,7 @@ #include "app/gfx/snes_tile.h" #include "app/rom.h" -#include "app/zelda3/dungeon/object_parser.h" +#include "zelda3/dungeon/object_parser.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/music/tracker.cc b/src/zelda3/music/tracker.cc similarity index 100% rename from src/app/zelda3/music/tracker.cc rename to src/zelda3/music/tracker.cc diff --git a/src/app/zelda3/music/tracker.h b/src/zelda3/music/tracker.h similarity index 100% rename from src/app/zelda3/music/tracker.h rename to src/zelda3/music/tracker.h diff --git a/src/app/zelda3/overworld/overworld.cc b/src/zelda3/overworld/overworld.cc similarity index 99% rename from src/app/zelda3/overworld/overworld.cc rename to src/zelda3/overworld/overworld.cc index ea6ed2aa..d9dbd823 100644 --- a/src/app/zelda3/overworld/overworld.cc +++ b/src/zelda3/overworld/overworld.cc @@ -15,8 +15,8 @@ #include "app/gfx/snes_tile.h" #include "app/rom.h" #include "app/snes.h" -#include "app/zelda3/overworld/overworld_entrance.h" -#include "app/zelda3/overworld/overworld_exit.h" +#include "zelda3/overworld/overworld_entrance.h" +#include "zelda3/overworld/overworld_exit.h" #include "util/hex.h" #include "util/log.h" #include "util/macro.h" diff --git a/src/app/zelda3/overworld/overworld.h b/src/zelda3/overworld/overworld.h similarity index 98% rename from src/app/zelda3/overworld/overworld.h rename to src/zelda3/overworld/overworld.h index 462e5aef..6eb72aac 100644 --- a/src/app/zelda3/overworld/overworld.h +++ b/src/zelda3/overworld/overworld.h @@ -8,11 +8,11 @@ #include "absl/status/status.h" #include "app/gfx/snes_tile.h" #include "app/rom.h" -#include "app/zelda3/overworld/overworld_entrance.h" -#include "app/zelda3/overworld/overworld_exit.h" -#include "app/zelda3/overworld/overworld_item.h" -#include "app/zelda3/overworld/overworld_map.h" -#include "app/zelda3/sprite/sprite.h" +#include "zelda3/overworld/overworld_entrance.h" +#include "zelda3/overworld/overworld_exit.h" +#include "zelda3/overworld/overworld_item.h" +#include "zelda3/overworld/overworld_map.h" +#include "zelda3/sprite/sprite.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/overworld/overworld_entrance.h b/src/zelda3/overworld/overworld_entrance.h similarity index 99% rename from src/app/zelda3/overworld/overworld_entrance.h rename to src/zelda3/overworld/overworld_entrance.h index 719d7185..1a6227a8 100644 --- a/src/app/zelda3/overworld/overworld_entrance.h +++ b/src/zelda3/overworld/overworld_entrance.h @@ -4,7 +4,7 @@ #include #include "app/rom.h" -#include "app/zelda3/common.h" +#include "zelda3/common.h" #include "util/macro.h" namespace yaze { diff --git a/src/app/zelda3/overworld/overworld_exit.h b/src/zelda3/overworld/overworld_exit.h similarity index 99% rename from src/app/zelda3/overworld/overworld_exit.h rename to src/zelda3/overworld/overworld_exit.h index 22c04cc3..9ed4b774 100644 --- a/src/app/zelda3/overworld/overworld_exit.h +++ b/src/zelda3/overworld/overworld_exit.h @@ -4,7 +4,7 @@ #include #include -#include "app/zelda3/common.h" +#include "zelda3/common.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/overworld/overworld_item.h b/src/zelda3/overworld/overworld_item.h similarity index 99% rename from src/app/zelda3/overworld/overworld_item.h rename to src/zelda3/overworld/overworld_item.h index c546c8a4..b62e8fe7 100644 --- a/src/app/zelda3/overworld/overworld_item.h +++ b/src/zelda3/overworld/overworld_item.h @@ -8,7 +8,7 @@ #include #include -#include "app/zelda3/common.h" +#include "zelda3/common.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/overworld/overworld_map.cc b/src/zelda3/overworld/overworld_map.cc similarity index 97% rename from src/app/zelda3/overworld/overworld_map.cc rename to src/zelda3/overworld/overworld_map.cc index 01ebde9a..378027d4 100644 --- a/src/app/zelda3/overworld/overworld_map.cc +++ b/src/zelda3/overworld/overworld_map.cc @@ -1,1129 +1,1129 @@ -#include "overworld_map.h" - -#include -#include -#include -#include - -#include "app/core/features.h" -#include "app/gfx/snes_color.h" -#include "app/gfx/snes_tile.h" -#include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" - -namespace yaze { -namespace zelda3 { - -OverworldMap::OverworldMap(int index, Rom* rom) - : index_(index), parent_(index), rom_(rom) { - LoadAreaInfo(); - // Load parent ID from ROM data if available (for custom ASM versions) - uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; - if (asm_version != 0xFF && asm_version >= 0x03) { - // For v3+, parent ID is stored in expanded table - parent_ = (*rom_)[kOverworldMapParentIdExpanded + index_]; - } - - if (asm_version != 0xFF) { - if (asm_version == 0x03) { - LoadCustomOverworldData(); - } else { - SetupCustomTileset(asm_version); - } - } else if (core::FeatureFlags::get().overworld.kLoadCustomOverworld) { - // Pure vanilla ROM but flag enabled - set up custom data manually - LoadCustomOverworldData(); - } - // For pure vanilla ROMs, LoadAreaInfo already handles everything -} - -absl::Status OverworldMap::BuildMap(int count, int game_state, int world, - std::vector& tiles16, - OverworldBlockset& world_blockset) { - game_state_ = game_state; - world_ = world; - uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; - - // For large maps in vanilla ROMs, we need to handle special world graphics - // This ensures proper rendering of special overworld areas like Zora's Domain - if (large_map_ && asm_version == 0xFF) { - if (parent_ != index_ && !initialized_) { - if (index_ >= kSpecialWorldMapIdStart && index_ <= 0x8A && - index_ != 0x88) { - // Most special world areas use the special graphics group - area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + - (parent_ - kSpecialWorldMapIdStart)]; - area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; - } else if (index_ == 0x88) { - // Triforce room has special hardcoded values - area_graphics_ = 0x51; - area_palette_ = 0x00; - } else { - // Fallback to standard area graphics - area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; - area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; - } - - initialized_ = true; - } - } - - LoadAreaGraphics(); - RETURN_IF_ERROR(BuildTileset()) - RETURN_IF_ERROR(BuildTiles16Gfx(tiles16, count)) - RETURN_IF_ERROR(LoadPalette()); - RETURN_IF_ERROR(LoadOverlay()); - RETURN_IF_ERROR(BuildBitmap(world_blockset)) - built_ = true; - return absl::OkStatus(); -} - -void OverworldMap::LoadAreaInfo() { - uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; - - // ZSCustomOverworld ASM Version System: - // 0x00-0x02: Legacy versions with limited features - // 0x03: Current version with full area size expansion and custom data support - // 0xFF: Pure vanilla ROM (no ASM applied) - - // Load message ID and area size based on ASM version - if (asm_version < 3 || asm_version == 0xFF) { - // v2 and vanilla: use original message table - message_id_ = (*rom_)[kOverworldMessageIds + (parent_ * 2)] | - ((*rom_)[kOverworldMessageIds + (parent_ * 2) + 1] << 8); - - // Load area size for v2/vanilla - if (index_ < 0x80) { - // For LW and DW, check the screen size byte - // Note: v2 had a bug where large/small values were swapped - uint8_t size_byte = (*rom_)[kOverworldScreenSize + (index_ & 0x3F)]; - switch (size_byte) { - case 0: - area_size_ = AreaSizeEnum::LargeArea; - break; - case 1: - default: - area_size_ = AreaSizeEnum::SmallArea; - break; - case 2: - area_size_ = AreaSizeEnum::WideArea; - break; - case 3: - area_size_ = AreaSizeEnum::TallArea; - break; - } - } else { - // For SW, use hardcoded values for v2 compatibility - // Zora's Domain areas (0x81, 0x82, 0x89, 0x8A) are large areas - area_size_ = - (index_ == 0x81 || index_ == 0x82 || index_ == 0x89 || index_ == 0x8A) - ? AreaSizeEnum::LargeArea - : AreaSizeEnum::SmallArea; - } - } else { - // v3: use expanded message table and area size table - // All area sizes are now stored in the expanded table, supporting all size types - message_id_ = - (*rom_)[kOverworldMessagesExpanded + (parent_ * 2)] | - ((*rom_)[kOverworldMessagesExpanded + (parent_ * 2) + 1] << 8); - area_size_ = - static_cast((*rom_)[kOverworldScreenSize + index_]); - } - - // Update large_map_ based on area size - large_map_ = (area_size_ == AreaSizeEnum::LargeArea); - - // Load area-specific data based on index range - if (index_ < kDarkWorldMapIdStart) { - // Light World (LW) areas - sprite_graphics_[0] = (*rom_)[kOverworldSpriteset + parent_]; - sprite_graphics_[1] = - (*rom_)[kOverworldSpriteset + parent_ + kDarkWorldMapIdStart]; - sprite_graphics_[2] = - (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; - - area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; - area_palette_ = (*rom_)[kOverworldPalettesScreenToSetNew + parent_]; - - sprite_palette_[0] = (*rom_)[kOverworldSpritePaletteIds + parent_]; - sprite_palette_[1] = - (*rom_)[kOverworldSpritePaletteIds + parent_ + kDarkWorldMapIdStart]; - sprite_palette_[2] = - (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; - - area_music_[0] = (*rom_)[kOverworldMusicBeginning + parent_]; - area_music_[1] = (*rom_)[kOverworldMusicZelda + parent_]; - area_music_[2] = (*rom_)[kOverworldMusicMasterSword + parent_]; - area_music_[3] = (*rom_)[kOverworldMusicAgahnim + parent_]; - - // For v2/vanilla, use original palette table - if (asm_version < 3 || asm_version == 0xFF) { - area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; - } - } else if (index_ < kSpecialWorldMapIdStart) { - // Dark World (DW) areas - sprite_graphics_[0] = - (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; - sprite_graphics_[1] = - (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; - sprite_graphics_[2] = - (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; - - area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; - area_palette_ = (*rom_)[kOverworldPalettesScreenToSetNew + parent_]; - - sprite_palette_[0] = - (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; - sprite_palette_[1] = - (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; - sprite_palette_[2] = - (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; - - area_music_[0] = - (*rom_)[kOverworldMusicDarkWorld + (parent_ - kDarkWorldMapIdStart)]; - - // For v2/vanilla, use original palette table - if (asm_version < 3 || asm_version == 0xFF) { - area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; - } - } else { - // Special World (SW) areas (index >= 0x80) - // Message ID already loaded above based on ASM version - - // For v3, use expanded sprite tables with full customization support - if (asm_version >= 3 && asm_version != 0xFF) { - sprite_graphics_[0] = - (*rom_)[kOverworldSpecialSpriteGfxGroupExpandedTemp + parent_ - - kSpecialWorldMapIdStart]; - sprite_graphics_[1] = - (*rom_)[kOverworldSpecialSpriteGfxGroupExpandedTemp + parent_ - - kSpecialWorldMapIdStart]; - sprite_graphics_[2] = - (*rom_)[kOverworldSpecialSpriteGfxGroupExpandedTemp + parent_ - - kSpecialWorldMapIdStart]; - - sprite_palette_[0] = (*rom_)[kOverworldSpecialSpritePaletteExpandedTemp + - parent_ - kSpecialWorldMapIdStart]; - sprite_palette_[1] = (*rom_)[kOverworldSpecialSpritePaletteExpandedTemp + - parent_ - kSpecialWorldMapIdStart]; - sprite_palette_[2] = (*rom_)[kOverworldSpecialSpritePaletteExpandedTemp + - parent_ - kSpecialWorldMapIdStart]; - } else { - // For v2/vanilla, use original sprite tables - sprite_graphics_[0] = (*rom_)[kOverworldSpecialGfxGroup + parent_ - - kSpecialWorldMapIdStart]; - sprite_graphics_[1] = (*rom_)[kOverworldSpecialGfxGroup + parent_ - - kSpecialWorldMapIdStart]; - sprite_graphics_[2] = (*rom_)[kOverworldSpecialGfxGroup + parent_ - - kSpecialWorldMapIdStart]; - - sprite_palette_[0] = (*rom_)[kOverworldSpecialPalGroup + parent_ - - kSpecialWorldMapIdStart]; - sprite_palette_[1] = (*rom_)[kOverworldSpecialPalGroup + parent_ - - kSpecialWorldMapIdStart]; - sprite_palette_[2] = (*rom_)[kOverworldSpecialPalGroup + parent_ - - kSpecialWorldMapIdStart]; - } - - area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; - area_palette_ = (*rom_)[kOverworldPalettesScreenToSetNew + parent_]; - - // For v2/vanilla, use original palette table and handle special cases - // These hardcoded cases are needed for vanilla compatibility - if (asm_version < 3 || asm_version == 0xFF) { - area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; - - // Handle special world area cases based on ZScream documentation - if (index_ == 0x88 || index_ == 0x93) { - // Triforce room - special graphics and palette - area_graphics_ = 0x51; - area_palette_ = 0x00; - } else if (index_ == 0x80) { - // Master Sword area - use special graphics group - area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + - (parent_ - kSpecialWorldMapIdStart)]; - area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; - } else if (index_ == 0x81 || index_ == 0x82 || index_ == 0x89 || - index_ == 0x8A) { - // Zora's Domain areas - use special sprite graphics and area graphics - // Note: These are the large area maps that were causing crashes - sprite_graphics_[0] = 0x0E; - sprite_graphics_[1] = 0x0E; - sprite_graphics_[2] = 0x0E; - - area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + - (parent_ - kSpecialWorldMapIdStart)]; - area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; - } else if (index_ == 0x94) { - // Make this the same GFX as the true master sword area - area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + - (0x80 - kSpecialWorldMapIdStart)]; - area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; - } else if (index_ == 0x95) { - // Make this the same GFX as the LW death mountain areas - area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x03]; - area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x03]; - } else if (index_ == 0x96) { - // Make this the same GFX as the pyramid areas - area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x5B]; - area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x5B]; - } else if (index_ == 0x9C) { - // Make this the same GFX as the DW death mountain areas - area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x43]; - area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x43]; - } else { - // Default case - use basic graphics - area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x00]; - area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x00]; - } - } - } -} - -void OverworldMap::LoadCustomOverworldData() { - // Set the main palette values based on ZScream logic - if (index_ < 0x40 || index_ == 0x95) { // LW - main_palette_ = 0; - } else if ((index_ >= 0x40 && index_ < 0x80) || index_ == 0x96) { // DW - main_palette_ = 1; - } else if (index_ >= 0x80 && index_ < 0xA0) { // SW - main_palette_ = 0; - } - - if (index_ == 0x03 || index_ == 0x05 || - index_ == 0x07) { // LW Death Mountain - main_palette_ = 2; - } else if (index_ == 0x43 || index_ == 0x45 || - index_ == 0x47) { // DW Death Mountain - main_palette_ = 3; - } else if (index_ == 0x88 || index_ == 0x93) { // Triforce room - main_palette_ = 4; - } - - // Set the mosaic values based on ZScream logic - switch (index_) { - case 0x00: // Leaving Skull Woods / Lost Woods - case 0x40: - mosaic_expanded_ = {false, true, false, true}; - break; - case 0x02: // Going into Skull woods / Lost Woods west - case 0x0A: - case 0x42: - case 0x4A: - mosaic_expanded_ = {false, false, true, false}; - break; - case 0x0F: // Going into Zora's Domain North - case 0x10: // Going into Skull Woods / Lost Woods North - case 0x11: - case 0x50: - case 0x51: - mosaic_expanded_ = {true, false, false, false}; - break; - case 0x80: // Leaving Zora's Domain, the Master Sword area, and the - // Triforce area - case 0x81: - case 0x88: - mosaic_expanded_ = {false, true, false, false}; - break; - default: - mosaic_expanded_ = {false, false, false, false}; - break; - } - - // Set up world index for GFX groups - int index_world = 0x20; - if (parent_ >= kDarkWorldMapIdStart && - parent_ < kSpecialWorldMapIdStart) { // DW - index_world = 0x21; - } else if (parent_ == 0x88 || parent_ == 0x93) { // Triforce room - index_world = 0x24; - } - - const auto overworld_gfx_groups2 = - rom_->version_constants().kOverworldGfxGroups2; - - // Main Blocksets - for (int i = 0; i < 8; i++) { - custom_gfx_ids_[i] = - (uint8_t)(*rom_)[overworld_gfx_groups2 + (index_world * 8) + i]; - } - - const auto overworldgfxGroups = - rom_->version_constants().kOverworldGfxGroups1; - - // Replace the variable tiles with the variable ones - uint8_t temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4)]; - if (temp != 0) { - custom_gfx_ids_[3] = temp; - } else { - custom_gfx_ids_[3] = 0xFF; - } - - temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 1]; - if (temp != 0) { - custom_gfx_ids_[4] = temp; - } else { - custom_gfx_ids_[4] = 0xFF; - } - - temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 2]; - if (temp != 0) { - custom_gfx_ids_[5] = temp; - } else { - custom_gfx_ids_[5] = 0xFF; - } - - temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 3]; - if (temp != 0) { - custom_gfx_ids_[6] = temp; - } else { - custom_gfx_ids_[6] = 0xFF; - } - - // Set the animated GFX values - if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07 || index_ == 0x43 || - index_ == 0x45 || index_ == 0x47 || index_ == 0x95) { - animated_gfx_ = 0x59; - } else { - animated_gfx_ = 0x5B; - } - - // Set the subscreen overlay values - subscreen_overlay_ = 0x00FF; - - if (index_ == 0x00 || index_ == 0x01 || index_ == 0x08 || index_ == 0x09 || - index_ == 0x40 || index_ == 0x41 || index_ == 0x48 || - index_ == 0x49) { // Add fog 2 to the lost woods and skull woods - subscreen_overlay_ = 0x009D; - } else if (index_ == 0x03 || index_ == 0x04 || index_ == 0x0B || - index_ == 0x0C || index_ == 0x05 || index_ == 0x06 || - index_ == 0x0D || index_ == 0x0E || - index_ == 0x07) { // Add the sky BG to LW death mountain - subscreen_overlay_ = 0x0095; - } else if (index_ == 0x43 || index_ == 0x44 || index_ == 0x4B || - index_ == 0x4C || index_ == 0x45 || index_ == 0x46 || - index_ == 0x4D || index_ == 0x4E || - index_ == 0x47) { // Add the lava to DW death mountain - subscreen_overlay_ = 0x009C; - } else if (index_ == 0x5B || index_ == 0x5C || index_ == 0x63 || - index_ == 0x64) { // TODO: Might need this one too "index == 0x1B" - // but for now I don't think so - subscreen_overlay_ = 0x0096; - } else if (index_ == 0x80) { // Add fog 1 to the master sword area - subscreen_overlay_ = 0x0097; - } else if (index_ == - 0x88) { // Add the triforce room curtains to the triforce room - subscreen_overlay_ = 0x0093; - } -} - -void OverworldMap::SetupCustomTileset(uint8_t asm_version) { - // Load custom palette and mosaic settings - main_palette_ = (*rom_)[OverworldCustomMainPaletteArray + index_]; - mosaic_ = (*rom_)[OverworldCustomMosaicArray + index_] != 0x00; - - uint8_t mosaicByte = (*rom_)[OverworldCustomMosaicArray + index_]; - mosaic_expanded_ = {(mosaicByte & 0x08) != 0x00, (mosaicByte & 0x04) != 0x00, - (mosaicByte & 0x02) != 0x00, (mosaicByte & 0x01) != 0x00}; - - // Load area size for v3 - if (asm_version >= 3 && asm_version != 0xFF) { - uint8_t size_byte = (*rom_)[kOverworldScreenSize + index_]; - area_size_ = static_cast(size_byte); - large_map_ = (area_size_ == AreaSizeEnum::LargeArea); - } - - // Load custom GFX groups based on ASM version - if (asm_version >= 0x01 && asm_version != 0xFF) { - // Load from custom GFX group array - for (int i = 0; i < 8; i++) { - custom_gfx_ids_[i] = - (*rom_)[OverworldCustomTileGFXGroupArray + (index_ * 8) + i]; - } - animated_gfx_ = (*rom_)[OverworldCustomAnimatedGFXArray + index_]; - } else { - // Fallback to vanilla logic for ROMs without custom ASM - int index_world = 0x20; - if (parent_ >= kDarkWorldMapIdStart && - parent_ < kSpecialWorldMapIdStart) { // DW - index_world = 0x21; - } else if (parent_ == 0x88 || parent_ == 0x93) { // Triforce room - index_world = 0x24; - } - - // Main Blocksets - for (int i = 0; i < 8; i++) { - custom_gfx_ids_[i] = - (uint8_t)(*rom_)[rom_->version_constants().kOverworldGfxGroups2 + - (index_world * 8) + i]; - } - - const auto overworldgfxGroups = - rom_->version_constants().kOverworldGfxGroups1; - - // Replace the variable tiles with the variable ones - // If the variable is 00 set it to 0xFF which is the new "don't load - // anything" value - uint8_t temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4)]; - if (temp != 0x00) { - custom_gfx_ids_[3] = temp; - } else { - custom_gfx_ids_[3] = 0xFF; - } - - temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 1]; - if (temp != 0x00) { - custom_gfx_ids_[4] = temp; - } else { - custom_gfx_ids_[4] = 0xFF; - } - - temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 2]; - if (temp != 0x00) { - custom_gfx_ids_[5] = temp; - } else { - custom_gfx_ids_[5] = 0xFF; - } - - temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 3]; - if (temp != 0x00) { - custom_gfx_ids_[6] = temp; - } else { - custom_gfx_ids_[6] = 0xFF; - } - - // Set the animated GFX values - if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07 || index_ == 0x43 || - index_ == 0x45 || index_ == 0x47) { - animated_gfx_ = 0x59; - } else { - animated_gfx_ = 0x5B; - } - } - - // Load subscreen overlay - subscreen_overlay_ = - (*rom_)[OverworldCustomSubscreenOverlayArray + (index_ * 2)]; -} - -void OverworldMap::LoadMainBlocksetId() { - if (parent_ < kDarkWorldMapIdStart) { - main_gfx_id_ = 0x20; - } else if (parent_ >= kDarkWorldMapIdStart && - parent_ < kSpecialWorldMapIdStart) { - main_gfx_id_ = 0x21; - } else if (parent_ >= kSpecialWorldMapIdStart) { - // Special world maps - use appropriate graphics ID based on the specific map - if (parent_ == 0x88) { - main_gfx_id_ = 0x24; - } else { - // Default special world graphics ID - main_gfx_id_ = 0x20; - } - } -} - -void OverworldMap::LoadSpritesBlocksets() { - int static_graphics_base = 0x73; - static_graphics_[8] = static_graphics_base + 0x00; - static_graphics_[9] = static_graphics_base + 0x01; - static_graphics_[10] = static_graphics_base + 0x06; - static_graphics_[11] = static_graphics_base + 0x07; - - for (int i = 0; i < 4; i++) { - static_graphics_[12 + i] = - ((*rom_)[rom_->version_constants().kSpriteBlocksetPointer + - (sprite_graphics_[game_state_] * 4) + i] + - static_graphics_base); - } -} - -void OverworldMap::LoadMainBlocksets() { - for (int i = 0; i < 8; i++) { - static_graphics_[i] = - (*rom_)[rom_->version_constants().kOverworldGfxGroups2 + - (main_gfx_id_ * 8) + i]; - } -} - -// For animating water tiles on the overworld map. -// We want to swap out static_graphics_[07] with the next sheet -// Usually it is 5A, so we make it 5B instead. -// There is a middle frame which contains tiles from the bottom half -// of the 5A sheet, so this will need some special manipulation to make work -// during the BuildBitmap step (or a new one specifically for animating). -void OverworldMap::DrawAnimatedTiles() { - if (static_graphics_[7] == 0x5B) { - static_graphics_[7] = 0x5A; - } else { - if (static_graphics_[7] == 0x59) { - static_graphics_[7] = 0x58; - } - static_graphics_[7] = 0x5B; - } -} - -void OverworldMap::LoadAreaGraphicsBlocksets() { - for (int i = 0; i < 4; i++) { - uint8_t value = (*rom_)[rom_->version_constants().kOverworldGfxGroups1 + - (area_graphics_ * 4) + i]; - if (value != 0) { - static_graphics_[3 + i] = value; - } - } -} - -// TODO: Change the conditions for death mountain gfx -// JaredBrian: This is how ZS did it, but in 3.0.4 I changed it to just check -// for 03, 05, 07, and the DW ones as that's how it would appear in-game if -// you were to make area 03 not a large area anymore for example, so you might -// want to do the same. -void OverworldMap::LoadDeathMountainGFX() { - static_graphics_[7] = (((parent_ >= 0x03 && parent_ <= 0x07) || - (parent_ >= 0x0B && parent_ <= 0x0E)) || - ((parent_ >= 0x43 && parent_ <= 0x47) || - (parent_ >= 0x4B && parent_ <= 0x4E))) - ? 0x59 - : 0x5B; -} - -void OverworldMap::LoadAreaGraphics() { - LoadMainBlocksetId(); - LoadSpritesBlocksets(); - LoadMainBlocksets(); - LoadAreaGraphicsBlocksets(); - LoadDeathMountainGFX(); -} - -namespace palette_internal { - -absl::Status SetColorsPalette(Rom& rom, int index, gfx::SnesPalette& current, - gfx::SnesPalette main, gfx::SnesPalette animated, - gfx::SnesPalette aux1, gfx::SnesPalette aux2, - gfx::SnesPalette hud, gfx::SnesColor bgrcolor, - gfx::SnesPalette spr, gfx::SnesPalette spr2) { - // Palettes infos, color 0 of a palette is always transparent (the arrays - // contains 7 colors width wide) There is 16 color per line so 16*Y - - // Left side of the palette - Main, Animated - std::array new_palette = {}; - - // Main Palette, Location 0,2 : 35 colors [7x5] - int k = 0; - for (int y = 2; y < 7; y++) { - for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = main[k]; - k++; - } - } - - // Animated Palette, Location 0,7 : 7colors - for (int x = 1; x < 8; x++) { - new_palette[(16 * 7) + (x)] = animated[(x - 1)]; - } - - // Right side of the palette - Aux1, Aux2 - - // Aux1 Palette, Location 8,2 : 21 colors [7x3] - k = 0; - for (int y = 2; y < 5; y++) { - for (int x = 9; x < 16; x++) { - new_palette[x + (16 * y)] = aux1[k]; - k++; - } - } - - // Aux2 Palette, Location 8,5 : 21 colors [7x3] - k = 0; - for (int y = 5; y < 8; y++) { - for (int x = 9; x < 16; x++) { - new_palette[x + (16 * y)] = aux2[k]; - k++; - } - } - - // Hud Palette, Location 0,0 : 32 colors [16x2] - for (int i = 0; i < 32; i++) { - new_palette[i] = hud[i]; - } - - // Hardcoded grass color (that might change to become invisible instead) - for (int i = 0; i < 8; i++) { - new_palette[(i * 16)] = bgrcolor; - new_palette[(i * 16) + 8] = bgrcolor; - } - - // Sprite Palettes - k = 0; - for (int y = 8; y < 9; y++) { - for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = rom.palette_group().sprites_aux1[1][k]; - k++; - } - } - - // Sprite Palettes - k = 0; - for (int y = 8; y < 9; y++) { - for (int x = 9; x < 16; x++) { - new_palette[x + (16 * y)] = rom.palette_group().sprites_aux3[0][k]; - k++; - } - } - - // Sprite Palettes - k = 0; - for (int y = 9; y < 13; y++) { - for (int x = 1; x < 16; x++) { - new_palette[x + (16 * y)] = rom.palette_group().global_sprites[0][k]; - k++; - } - } - - // Sprite Palettes - k = 0; - for (int y = 13; y < 14; y++) { - for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = spr[k]; - k++; - } - } - - // Sprite Palettes - k = 0; - for (int y = 14; y < 15; y++) { - for (int x = 1; x < 8; x++) { - new_palette[x + (16 * y)] = spr2[k]; - k++; - } - } - - // Sprite Palettes - k = 0; - for (int y = 15; y < 16; y++) { - for (int x = 1; x < 16; x++) { - new_palette[x + (16 * y)] = rom.palette_group().armors[0][k]; - k++; - } - } - - for (int i = 0; i < 256; i++) { - current[i] = new_palette[i]; - current[(i / 16) * 16].set_transparent(true); - } - - current.set_size(256); - return absl::OkStatus(); -} -} // namespace palette_internal - -absl::StatusOr OverworldMap::GetPalette( - const gfx::PaletteGroup& palette_group, int index, int previous_index, - int limit) { - if (index == 255) { - index = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + - (previous_index * 4)]; - } - if (index >= limit) { - index = limit - 1; - } - return palette_group[index]; -} - -absl::Status OverworldMap::LoadPalette() { - uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; - - int previous_pal_id = 0; - int previous_spr_pal_id = 0; - - if (index_ > 0) { - // Load previous palette ID based on ASM version - if (asm_version < 3 || asm_version == 0xFF) { - previous_pal_id = (*rom_)[kOverworldMapPaletteIds + parent_ - 1]; - } else { - // v3 uses expanded palette table - previous_pal_id = (*rom_)[kOverworldPalettesScreenToSetNew + parent_ - 1]; - } - - previous_spr_pal_id = (*rom_)[kOverworldSpritePaletteIds + parent_ - 1]; - } - - area_palette_ = std::min((int)area_palette_, 0xA3); - - uint8_t pal0 = 0; - uint8_t pal1 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + - (area_palette_ * 4)]; - uint8_t pal2 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + - (area_palette_ * 4) + 1]; - uint8_t pal3 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + - (area_palette_ * 4) + 2]; - uint8_t pal4 = (*rom_)[kOverworldSpritePaletteGroup + - (sprite_palette_[game_state_] * 2)]; - uint8_t pal5 = (*rom_)[kOverworldSpritePaletteGroup + - (sprite_palette_[game_state_] * 2) + 1]; - - auto grass_pal_group = rom_->palette_group().grass; - auto bgr = grass_pal_group[0][0]; - - // Handle 0xFF palette references (use previous palette) - if (pal1 == 0xFF) { - pal1 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + - (previous_pal_id * 4)]; - } - - if (pal2 == 0xFF) { - pal2 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + - (previous_pal_id * 4) + 1]; - } - - if (pal3 == 0xFF) { - pal3 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + - (previous_pal_id * 4) + 2]; - } - - auto ow_aux_pal_group = rom_->palette_group().overworld_aux; - ASSIGN_OR_RETURN(gfx::SnesPalette aux1, - GetPalette(ow_aux_pal_group, pal1, previous_pal_id, 20)); - ASSIGN_OR_RETURN(gfx::SnesPalette aux2, - GetPalette(ow_aux_pal_group, pal2, previous_pal_id, 20)); - - // Set background color based on world type and area-specific settings - bool use_area_specific_bg = - (*rom_)[OverworldCustomAreaSpecificBGEnabled] != 0x00; - if (use_area_specific_bg) { - // Use area-specific background color from custom array - area_specific_bg_color_ = - (*rom_)[OverworldCustomAreaSpecificBGPalette + (parent_ * 2)] | - ((*rom_)[OverworldCustomAreaSpecificBGPalette + (parent_ * 2) + 1] - << 8); - // Convert 15-bit SNES color to palette color - bgr = gfx::SnesColor(area_specific_bg_color_); - } else { - // Use default world-based background colors - if (parent_ < kDarkWorldMapIdStart) { - bgr = grass_pal_group[0][0]; // LW - } else if (parent_ >= kDarkWorldMapIdStart && - parent_ < kSpecialWorldMapIdStart) { - bgr = grass_pal_group[0][1]; // DW - } else if (parent_ >= 128 && parent_ < kNumOverworldMaps) { - bgr = grass_pal_group[0][2]; // SW - } - } - - // Use main palette from the overworld map data (matches ZScream logic) - pal0 = main_palette_; - - auto ow_main_pal_group = rom_->palette_group().overworld_main; - ASSIGN_OR_RETURN(gfx::SnesPalette main, - GetPalette(ow_main_pal_group, pal0, previous_pal_id, 255)); - auto ow_animated_pal_group = rom_->palette_group().overworld_animated; - ASSIGN_OR_RETURN(gfx::SnesPalette animated, - GetPalette(ow_animated_pal_group, std::min((int)pal3, 13), - previous_pal_id, 14)); - - auto hud_pal_group = rom_->palette_group().hud; - gfx::SnesPalette hud = hud_pal_group[0]; - - // Handle 0xFF sprite palette references (use previous sprite palette) - if (pal4 == 0xFF) { - pal4 = (*rom_)[kOverworldSpritePaletteGroup + (previous_spr_pal_id * 2)]; - } - - if (pal4 == 0xFF) { - pal4 = 0; // Fallback to 0 if still 0xFF - } - - if (pal5 == 0xFF) { - pal5 = - (*rom_)[kOverworldSpritePaletteGroup + (previous_spr_pal_id * 2) + 1]; - } - - if (pal5 == 0xFF) { - pal5 = 0; // Fallback to 0 if still 0xFF - } - - ASSIGN_OR_RETURN(gfx::SnesPalette spr, - GetPalette(rom_->palette_group().sprites_aux3, pal4, - previous_spr_pal_id, 24)); - ASSIGN_OR_RETURN(gfx::SnesPalette spr2, - GetPalette(rom_->palette_group().sprites_aux3, pal5, - previous_spr_pal_id, 24)); - - RETURN_IF_ERROR(palette_internal::SetColorsPalette( - *rom_, parent_, current_palette_, main, animated, aux1, aux2, hud, bgr, - spr, spr2)); - - if (palettesets_.count(area_palette_) == 0) { - palettesets_[area_palette_] = gfx::Paletteset{ - main, animated, aux1, aux2, bgr, hud, spr, spr2, current_palette_}; - } - - return absl::OkStatus(); -} - -absl::Status OverworldMap::LoadOverlay() { - uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; - - // Load overlays based on ROM version - if (asm_version == 0xFF) { - // Vanilla ROM - load overlay from overlay pointers - return LoadVanillaOverlayData(); - } else { - // Custom overworld ROM - use overlay from custom data - overlay_id_ = subscreen_overlay_; - has_overlay_ = (overlay_id_ != 0x00FF); - overlay_data_.clear(); - return absl::OkStatus(); - } -} - -absl::Status OverworldMap::LoadVanillaOverlayData() { - - // Load vanilla overlay for this map (interactive overlays for revealing holes/changing elements) - int address = (kOverlayPointersBank << 16) + - ((*rom_)[kOverlayPointers + (index_ * 2) + 1] << 8) + - (*rom_)[kOverlayPointers + (index_ * 2)]; - - // Convert SNES address to PC address - address = ((address & 0x7F0000) >> 1) | (address & 0x7FFF); - - // Check if custom overlay code is present - if ((*rom_)[kOverlayData1] == 0x6B) { - // Use custom overlay data pointer - address = ((*rom_)[kOverlayData2 + 2 + (index_ * 3)] << 16) + - ((*rom_)[kOverlayData2 + 1 + (index_ * 3)] << 8) + - (*rom_)[kOverlayData2 + (index_ * 3)]; - address = ((address & 0x7F0000) >> 1) | (address & 0x7FFF); - } - - // Validate address - if (address >= rom_->size()) { - has_overlay_ = false; - overlay_id_ = 0; - overlay_data_.clear(); - return absl::OkStatus(); - } - - // Parse overlay data (interactive overlays) - overlay_data_.clear(); - uint8_t b = (*rom_)[address]; - - // Parse overlay commands until we hit END (0x60) - while (b != 0x60 && address < rom_->size()) { - overlay_data_.push_back(b); - - // Handle different overlay commands - switch (b) { - case 0xA9: // LDA #$ - if (address + 2 < rom_->size()) { - overlay_data_.push_back((*rom_)[address + 1]); - overlay_data_.push_back((*rom_)[address + 2]); - address += 3; - } else { - address++; - } - break; - case 0xA2: // LDX #$ - if (address + 2 < rom_->size()) { - overlay_data_.push_back((*rom_)[address + 1]); - overlay_data_.push_back((*rom_)[address + 2]); - address += 3; - } else { - address++; - } - break; - case 0x8D: // STA $xxxx - if (address + 3 < rom_->size()) { - overlay_data_.push_back((*rom_)[address + 1]); - overlay_data_.push_back((*rom_)[address + 2]); - overlay_data_.push_back((*rom_)[address + 3]); - address += 4; - } else { - address++; - } - break; - case 0x9D: // STA $xxxx,x - if (address + 3 < rom_->size()) { - overlay_data_.push_back((*rom_)[address + 1]); - overlay_data_.push_back((*rom_)[address + 2]); - overlay_data_.push_back((*rom_)[address + 3]); - address += 4; - } else { - address++; - } - break; - case 0x8F: // STA $xxxxxx - if (address + 4 < rom_->size()) { - overlay_data_.push_back((*rom_)[address + 1]); - overlay_data_.push_back((*rom_)[address + 2]); - overlay_data_.push_back((*rom_)[address + 3]); - overlay_data_.push_back((*rom_)[address + 4]); - address += 5; - } else { - address++; - } - break; - case 0x1A: // INC A - address++; - break; - case 0x4C: // JMP - if (address + 3 < rom_->size()) { - overlay_data_.push_back((*rom_)[address + 1]); - overlay_data_.push_back((*rom_)[address + 2]); - overlay_data_.push_back((*rom_)[address + 3]); - address += 4; - } else { - address++; - } - break; - default: - address++; - break; - } - - if (address < rom_->size()) { - b = (*rom_)[address]; - } else { - break; - } - } - - // Add the END command if we found it - if (b == 0x60) { - overlay_data_.push_back(0x60); - } - - // Set overlay ID based on map index (simplified) - overlay_id_ = index_; - has_overlay_ = !overlay_data_.empty(); - - return absl::OkStatus(); -} - -void OverworldMap::ProcessGraphicsBuffer(int index, int static_graphics_offset, - int size, uint8_t* all_gfx) { - // Ensure we don't go out of bounds - int max_offset = static_graphics_offset * size + size; - if (max_offset > rom_->graphics_buffer().size()) { - // Fill with zeros if out of bounds - for (int i = 0; i < size; i++) { - current_gfx_[(index * size) + i] = 0x00; - } - return; - } - - for (int i = 0; i < size; i++) { - auto byte = all_gfx[i + (static_graphics_offset * size)]; - switch (index) { - case 0: - case 3: - case 4: - case 5: - byte += 0x88; - break; - } - current_gfx_[(index * size) + i] = byte; - } -} - -absl::Status OverworldMap::BuildTileset() { - if (current_gfx_.size() == 0) - current_gfx_.resize(0x10000, 0x00); - - // Process the 8 main graphics sheets (slots 0-7) - for (int i = 0; i < 8; i++) { - if (static_graphics_[i] != 0) { - ProcessGraphicsBuffer(i, static_graphics_[i], 0x1000, - rom_->graphics_buffer().data()); - } - } - - // Process sprite graphics (slots 8-15) - for (int i = 8; i < 16; i++) { - if (static_graphics_[i] != 0) { - ProcessGraphicsBuffer(i, static_graphics_[i], 0x1000, - rom_->graphics_buffer().data()); - } - } - - // Process animated graphics if available (slot 16) - if (static_graphics_[16] != 0) { - ProcessGraphicsBuffer(7, static_graphics_[16], 0x1000, - rom_->graphics_buffer().data()); - } - - return absl::OkStatus(); -} - -absl::Status OverworldMap::BuildTiles16Gfx(std::vector& tiles16, - int count) { - if (current_blockset_.size() == 0) - current_blockset_.resize(0x100000, 0x00); - - const int offsets[] = {0x00, 0x08, 0x400, 0x408}; - auto yy = 0; - auto xx = 0; - - for (auto i = 0; i < count; i++) { - for (auto tile = 0; tile < 0x04; tile++) { - gfx::TileInfo info = tiles16[i].tiles_info[tile]; - int offset = offsets[tile]; - for (auto y = 0; y < 0x08; ++y) { - for (auto x = 0; x < 0x08; ++x) { - int mx = x; - int my = y; - - if (info.horizontal_mirror_ != 0) { - mx = 0x07 - x; - } - - if (info.vertical_mirror_ != 0) { - my = 0x07 - y; - } - - int xpos = ((info.id_ % 0x10) * 0x08); - int ypos = (((info.id_ / 0x10)) * 0x400); - int source = ypos + xpos + (x + (y * 0x80)); - - auto destination = xx + yy + offset + (mx + (my * 0x80)); - current_blockset_[destination] = - (current_gfx_[source] & 0x0F) + (info.palette_ * 0x10); - } - } - } - - xx += 0x10; - if (xx >= 0x80) { - yy += 0x800; - xx = 0; - } - } - - return absl::OkStatus(); -} - -absl::Status OverworldMap::BuildBitmap(OverworldBlockset& world_blockset) { - if (bitmap_data_.size() != 0) { - bitmap_data_.clear(); - } - bitmap_data_.reserve(0x40000); - for (int i = 0; i < 0x40000; i++) { - bitmap_data_.push_back(0x00); - } - - int superY = ((index_ - (world_ * 0x40)) / 0x08); - int superX = index_ - (world_ * 0x40) - (superY * 0x08); - - for (int y = 0; y < 0x20; y++) { - for (int x = 0; x < 0x20; x++) { - auto xt = x + (superX * 0x20); - auto yt = y + (superY * 0x20); - gfx::CopyTile8bpp16((x * 0x10), (y * 0x10), world_blockset[xt][yt], - bitmap_data_, current_blockset_); - } - } - return absl::OkStatus(); -} - -} // namespace zelda3 -} // namespace yaze +#include "overworld_map.h" + +#include +#include +#include +#include + +#include "app/core/features.h" +#include "app/gfx/snes_color.h" +#include "app/gfx/snes_tile.h" +#include "app/rom.h" +#include "zelda3/overworld/overworld.h" + +namespace yaze { +namespace zelda3 { + +OverworldMap::OverworldMap(int index, Rom* rom) + : index_(index), parent_(index), rom_(rom) { + LoadAreaInfo(); + // Load parent ID from ROM data if available (for custom ASM versions) + uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; + if (asm_version != 0xFF && asm_version >= 0x03) { + // For v3+, parent ID is stored in expanded table + parent_ = (*rom_)[kOverworldMapParentIdExpanded + index_]; + } + + if (asm_version != 0xFF) { + if (asm_version == 0x03) { + LoadCustomOverworldData(); + } else { + SetupCustomTileset(asm_version); + } + } else if (core::FeatureFlags::get().overworld.kLoadCustomOverworld) { + // Pure vanilla ROM but flag enabled - set up custom data manually + LoadCustomOverworldData(); + } + // For pure vanilla ROMs, LoadAreaInfo already handles everything +} + +absl::Status OverworldMap::BuildMap(int count, int game_state, int world, + std::vector& tiles16, + OverworldBlockset& world_blockset) { + game_state_ = game_state; + world_ = world; + uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; + + // For large maps in vanilla ROMs, we need to handle special world graphics + // This ensures proper rendering of special overworld areas like Zora's Domain + if (large_map_ && asm_version == 0xFF) { + if (parent_ != index_ && !initialized_) { + if (index_ >= kSpecialWorldMapIdStart && index_ <= 0x8A && + index_ != 0x88) { + // Most special world areas use the special graphics group + area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + + (parent_ - kSpecialWorldMapIdStart)]; + area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; + } else if (index_ == 0x88) { + // Triforce room has special hardcoded values + area_graphics_ = 0x51; + area_palette_ = 0x00; + } else { + // Fallback to standard area graphics + area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; + area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; + } + + initialized_ = true; + } + } + + LoadAreaGraphics(); + RETURN_IF_ERROR(BuildTileset()) + RETURN_IF_ERROR(BuildTiles16Gfx(tiles16, count)) + RETURN_IF_ERROR(LoadPalette()); + RETURN_IF_ERROR(LoadOverlay()); + RETURN_IF_ERROR(BuildBitmap(world_blockset)) + built_ = true; + return absl::OkStatus(); +} + +void OverworldMap::LoadAreaInfo() { + uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; + + // ZSCustomOverworld ASM Version System: + // 0x00-0x02: Legacy versions with limited features + // 0x03: Current version with full area size expansion and custom data support + // 0xFF: Pure vanilla ROM (no ASM applied) + + // Load message ID and area size based on ASM version + if (asm_version < 3 || asm_version == 0xFF) { + // v2 and vanilla: use original message table + message_id_ = (*rom_)[kOverworldMessageIds + (parent_ * 2)] | + ((*rom_)[kOverworldMessageIds + (parent_ * 2) + 1] << 8); + + // Load area size for v2/vanilla + if (index_ < 0x80) { + // For LW and DW, check the screen size byte + // Note: v2 had a bug where large/small values were swapped + uint8_t size_byte = (*rom_)[kOverworldScreenSize + (index_ & 0x3F)]; + switch (size_byte) { + case 0: + area_size_ = AreaSizeEnum::LargeArea; + break; + case 1: + default: + area_size_ = AreaSizeEnum::SmallArea; + break; + case 2: + area_size_ = AreaSizeEnum::WideArea; + break; + case 3: + area_size_ = AreaSizeEnum::TallArea; + break; + } + } else { + // For SW, use hardcoded values for v2 compatibility + // Zora's Domain areas (0x81, 0x82, 0x89, 0x8A) are large areas + area_size_ = + (index_ == 0x81 || index_ == 0x82 || index_ == 0x89 || index_ == 0x8A) + ? AreaSizeEnum::LargeArea + : AreaSizeEnum::SmallArea; + } + } else { + // v3: use expanded message table and area size table + // All area sizes are now stored in the expanded table, supporting all size types + message_id_ = + (*rom_)[kOverworldMessagesExpanded + (parent_ * 2)] | + ((*rom_)[kOverworldMessagesExpanded + (parent_ * 2) + 1] << 8); + area_size_ = + static_cast((*rom_)[kOverworldScreenSize + index_]); + } + + // Update large_map_ based on area size + large_map_ = (area_size_ == AreaSizeEnum::LargeArea); + + // Load area-specific data based on index range + if (index_ < kDarkWorldMapIdStart) { + // Light World (LW) areas + sprite_graphics_[0] = (*rom_)[kOverworldSpriteset + parent_]; + sprite_graphics_[1] = + (*rom_)[kOverworldSpriteset + parent_ + kDarkWorldMapIdStart]; + sprite_graphics_[2] = + (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; + + area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; + area_palette_ = (*rom_)[kOverworldPalettesScreenToSetNew + parent_]; + + sprite_palette_[0] = (*rom_)[kOverworldSpritePaletteIds + parent_]; + sprite_palette_[1] = + (*rom_)[kOverworldSpritePaletteIds + parent_ + kDarkWorldMapIdStart]; + sprite_palette_[2] = + (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; + + area_music_[0] = (*rom_)[kOverworldMusicBeginning + parent_]; + area_music_[1] = (*rom_)[kOverworldMusicZelda + parent_]; + area_music_[2] = (*rom_)[kOverworldMusicMasterSword + parent_]; + area_music_[3] = (*rom_)[kOverworldMusicAgahnim + parent_]; + + // For v2/vanilla, use original palette table + if (asm_version < 3 || asm_version == 0xFF) { + area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; + } + } else if (index_ < kSpecialWorldMapIdStart) { + // Dark World (DW) areas + sprite_graphics_[0] = + (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; + sprite_graphics_[1] = + (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; + sprite_graphics_[2] = + (*rom_)[kOverworldSpriteset + parent_ + kSpecialWorldMapIdStart]; + + area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; + area_palette_ = (*rom_)[kOverworldPalettesScreenToSetNew + parent_]; + + sprite_palette_[0] = + (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; + sprite_palette_[1] = + (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; + sprite_palette_[2] = + (*rom_)[kOverworldSpritePaletteIds + parent_ + kSpecialWorldMapIdStart]; + + area_music_[0] = + (*rom_)[kOverworldMusicDarkWorld + (parent_ - kDarkWorldMapIdStart)]; + + // For v2/vanilla, use original palette table + if (asm_version < 3 || asm_version == 0xFF) { + area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; + } + } else { + // Special World (SW) areas (index >= 0x80) + // Message ID already loaded above based on ASM version + + // For v3, use expanded sprite tables with full customization support + if (asm_version >= 3 && asm_version != 0xFF) { + sprite_graphics_[0] = + (*rom_)[kOverworldSpecialSpriteGfxGroupExpandedTemp + parent_ - + kSpecialWorldMapIdStart]; + sprite_graphics_[1] = + (*rom_)[kOverworldSpecialSpriteGfxGroupExpandedTemp + parent_ - + kSpecialWorldMapIdStart]; + sprite_graphics_[2] = + (*rom_)[kOverworldSpecialSpriteGfxGroupExpandedTemp + parent_ - + kSpecialWorldMapIdStart]; + + sprite_palette_[0] = (*rom_)[kOverworldSpecialSpritePaletteExpandedTemp + + parent_ - kSpecialWorldMapIdStart]; + sprite_palette_[1] = (*rom_)[kOverworldSpecialSpritePaletteExpandedTemp + + parent_ - kSpecialWorldMapIdStart]; + sprite_palette_[2] = (*rom_)[kOverworldSpecialSpritePaletteExpandedTemp + + parent_ - kSpecialWorldMapIdStart]; + } else { + // For v2/vanilla, use original sprite tables + sprite_graphics_[0] = (*rom_)[kOverworldSpecialGfxGroup + parent_ - + kSpecialWorldMapIdStart]; + sprite_graphics_[1] = (*rom_)[kOverworldSpecialGfxGroup + parent_ - + kSpecialWorldMapIdStart]; + sprite_graphics_[2] = (*rom_)[kOverworldSpecialGfxGroup + parent_ - + kSpecialWorldMapIdStart]; + + sprite_palette_[0] = (*rom_)[kOverworldSpecialPalGroup + parent_ - + kSpecialWorldMapIdStart]; + sprite_palette_[1] = (*rom_)[kOverworldSpecialPalGroup + parent_ - + kSpecialWorldMapIdStart]; + sprite_palette_[2] = (*rom_)[kOverworldSpecialPalGroup + parent_ - + kSpecialWorldMapIdStart]; + } + + area_graphics_ = (*rom_)[kAreaGfxIdPtr + parent_]; + area_palette_ = (*rom_)[kOverworldPalettesScreenToSetNew + parent_]; + + // For v2/vanilla, use original palette table and handle special cases + // These hardcoded cases are needed for vanilla compatibility + if (asm_version < 3 || asm_version == 0xFF) { + area_palette_ = (*rom_)[kOverworldMapPaletteIds + parent_]; + + // Handle special world area cases based on ZScream documentation + if (index_ == 0x88 || index_ == 0x93) { + // Triforce room - special graphics and palette + area_graphics_ = 0x51; + area_palette_ = 0x00; + } else if (index_ == 0x80) { + // Master Sword area - use special graphics group + area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + + (parent_ - kSpecialWorldMapIdStart)]; + area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; + } else if (index_ == 0x81 || index_ == 0x82 || index_ == 0x89 || + index_ == 0x8A) { + // Zora's Domain areas - use special sprite graphics and area graphics + // Note: These are the large area maps that were causing crashes + sprite_graphics_[0] = 0x0E; + sprite_graphics_[1] = 0x0E; + sprite_graphics_[2] = 0x0E; + + area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + + (parent_ - kSpecialWorldMapIdStart)]; + area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; + } else if (index_ == 0x94) { + // Make this the same GFX as the true master sword area + area_graphics_ = (*rom_)[kOverworldSpecialGfxGroup + + (0x80 - kSpecialWorldMapIdStart)]; + area_palette_ = (*rom_)[kOverworldSpecialPalGroup + 1]; + } else if (index_ == 0x95) { + // Make this the same GFX as the LW death mountain areas + area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x03]; + area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x03]; + } else if (index_ == 0x96) { + // Make this the same GFX as the pyramid areas + area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x5B]; + area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x5B]; + } else if (index_ == 0x9C) { + // Make this the same GFX as the DW death mountain areas + area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x43]; + area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x43]; + } else { + // Default case - use basic graphics + area_graphics_ = (*rom_)[kAreaGfxIdPtr + 0x00]; + area_palette_ = (*rom_)[kOverworldMapPaletteIds + 0x00]; + } + } + } +} + +void OverworldMap::LoadCustomOverworldData() { + // Set the main palette values based on ZScream logic + if (index_ < 0x40 || index_ == 0x95) { // LW + main_palette_ = 0; + } else if ((index_ >= 0x40 && index_ < 0x80) || index_ == 0x96) { // DW + main_palette_ = 1; + } else if (index_ >= 0x80 && index_ < 0xA0) { // SW + main_palette_ = 0; + } + + if (index_ == 0x03 || index_ == 0x05 || + index_ == 0x07) { // LW Death Mountain + main_palette_ = 2; + } else if (index_ == 0x43 || index_ == 0x45 || + index_ == 0x47) { // DW Death Mountain + main_palette_ = 3; + } else if (index_ == 0x88 || index_ == 0x93) { // Triforce room + main_palette_ = 4; + } + + // Set the mosaic values based on ZScream logic + switch (index_) { + case 0x00: // Leaving Skull Woods / Lost Woods + case 0x40: + mosaic_expanded_ = {false, true, false, true}; + break; + case 0x02: // Going into Skull woods / Lost Woods west + case 0x0A: + case 0x42: + case 0x4A: + mosaic_expanded_ = {false, false, true, false}; + break; + case 0x0F: // Going into Zora's Domain North + case 0x10: // Going into Skull Woods / Lost Woods North + case 0x11: + case 0x50: + case 0x51: + mosaic_expanded_ = {true, false, false, false}; + break; + case 0x80: // Leaving Zora's Domain, the Master Sword area, and the + // Triforce area + case 0x81: + case 0x88: + mosaic_expanded_ = {false, true, false, false}; + break; + default: + mosaic_expanded_ = {false, false, false, false}; + break; + } + + // Set up world index for GFX groups + int index_world = 0x20; + if (parent_ >= kDarkWorldMapIdStart && + parent_ < kSpecialWorldMapIdStart) { // DW + index_world = 0x21; + } else if (parent_ == 0x88 || parent_ == 0x93) { // Triforce room + index_world = 0x24; + } + + const auto overworld_gfx_groups2 = + rom_->version_constants().kOverworldGfxGroups2; + + // Main Blocksets + for (int i = 0; i < 8; i++) { + custom_gfx_ids_[i] = + (uint8_t)(*rom_)[overworld_gfx_groups2 + (index_world * 8) + i]; + } + + const auto overworldgfxGroups = + rom_->version_constants().kOverworldGfxGroups1; + + // Replace the variable tiles with the variable ones + uint8_t temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4)]; + if (temp != 0) { + custom_gfx_ids_[3] = temp; + } else { + custom_gfx_ids_[3] = 0xFF; + } + + temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 1]; + if (temp != 0) { + custom_gfx_ids_[4] = temp; + } else { + custom_gfx_ids_[4] = 0xFF; + } + + temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 2]; + if (temp != 0) { + custom_gfx_ids_[5] = temp; + } else { + custom_gfx_ids_[5] = 0xFF; + } + + temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 3]; + if (temp != 0) { + custom_gfx_ids_[6] = temp; + } else { + custom_gfx_ids_[6] = 0xFF; + } + + // Set the animated GFX values + if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07 || index_ == 0x43 || + index_ == 0x45 || index_ == 0x47 || index_ == 0x95) { + animated_gfx_ = 0x59; + } else { + animated_gfx_ = 0x5B; + } + + // Set the subscreen overlay values + subscreen_overlay_ = 0x00FF; + + if (index_ == 0x00 || index_ == 0x01 || index_ == 0x08 || index_ == 0x09 || + index_ == 0x40 || index_ == 0x41 || index_ == 0x48 || + index_ == 0x49) { // Add fog 2 to the lost woods and skull woods + subscreen_overlay_ = 0x009D; + } else if (index_ == 0x03 || index_ == 0x04 || index_ == 0x0B || + index_ == 0x0C || index_ == 0x05 || index_ == 0x06 || + index_ == 0x0D || index_ == 0x0E || + index_ == 0x07) { // Add the sky BG to LW death mountain + subscreen_overlay_ = 0x0095; + } else if (index_ == 0x43 || index_ == 0x44 || index_ == 0x4B || + index_ == 0x4C || index_ == 0x45 || index_ == 0x46 || + index_ == 0x4D || index_ == 0x4E || + index_ == 0x47) { // Add the lava to DW death mountain + subscreen_overlay_ = 0x009C; + } else if (index_ == 0x5B || index_ == 0x5C || index_ == 0x63 || + index_ == 0x64) { // TODO: Might need this one too "index == 0x1B" + // but for now I don't think so + subscreen_overlay_ = 0x0096; + } else if (index_ == 0x80) { // Add fog 1 to the master sword area + subscreen_overlay_ = 0x0097; + } else if (index_ == + 0x88) { // Add the triforce room curtains to the triforce room + subscreen_overlay_ = 0x0093; + } +} + +void OverworldMap::SetupCustomTileset(uint8_t asm_version) { + // Load custom palette and mosaic settings + main_palette_ = (*rom_)[OverworldCustomMainPaletteArray + index_]; + mosaic_ = (*rom_)[OverworldCustomMosaicArray + index_] != 0x00; + + uint8_t mosaicByte = (*rom_)[OverworldCustomMosaicArray + index_]; + mosaic_expanded_ = {(mosaicByte & 0x08) != 0x00, (mosaicByte & 0x04) != 0x00, + (mosaicByte & 0x02) != 0x00, (mosaicByte & 0x01) != 0x00}; + + // Load area size for v3 + if (asm_version >= 3 && asm_version != 0xFF) { + uint8_t size_byte = (*rom_)[kOverworldScreenSize + index_]; + area_size_ = static_cast(size_byte); + large_map_ = (area_size_ == AreaSizeEnum::LargeArea); + } + + // Load custom GFX groups based on ASM version + if (asm_version >= 0x01 && asm_version != 0xFF) { + // Load from custom GFX group array + for (int i = 0; i < 8; i++) { + custom_gfx_ids_[i] = + (*rom_)[OverworldCustomTileGFXGroupArray + (index_ * 8) + i]; + } + animated_gfx_ = (*rom_)[OverworldCustomAnimatedGFXArray + index_]; + } else { + // Fallback to vanilla logic for ROMs without custom ASM + int index_world = 0x20; + if (parent_ >= kDarkWorldMapIdStart && + parent_ < kSpecialWorldMapIdStart) { // DW + index_world = 0x21; + } else if (parent_ == 0x88 || parent_ == 0x93) { // Triforce room + index_world = 0x24; + } + + // Main Blocksets + for (int i = 0; i < 8; i++) { + custom_gfx_ids_[i] = + (uint8_t)(*rom_)[rom_->version_constants().kOverworldGfxGroups2 + + (index_world * 8) + i]; + } + + const auto overworldgfxGroups = + rom_->version_constants().kOverworldGfxGroups1; + + // Replace the variable tiles with the variable ones + // If the variable is 00 set it to 0xFF which is the new "don't load + // anything" value + uint8_t temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4)]; + if (temp != 0x00) { + custom_gfx_ids_[3] = temp; + } else { + custom_gfx_ids_[3] = 0xFF; + } + + temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 1]; + if (temp != 0x00) { + custom_gfx_ids_[4] = temp; + } else { + custom_gfx_ids_[4] = 0xFF; + } + + temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 2]; + if (temp != 0x00) { + custom_gfx_ids_[5] = temp; + } else { + custom_gfx_ids_[5] = 0xFF; + } + + temp = (*rom_)[overworldgfxGroups + (area_graphics_ * 4) + 3]; + if (temp != 0x00) { + custom_gfx_ids_[6] = temp; + } else { + custom_gfx_ids_[6] = 0xFF; + } + + // Set the animated GFX values + if (index_ == 0x03 || index_ == 0x05 || index_ == 0x07 || index_ == 0x43 || + index_ == 0x45 || index_ == 0x47) { + animated_gfx_ = 0x59; + } else { + animated_gfx_ = 0x5B; + } + } + + // Load subscreen overlay + subscreen_overlay_ = + (*rom_)[OverworldCustomSubscreenOverlayArray + (index_ * 2)]; +} + +void OverworldMap::LoadMainBlocksetId() { + if (parent_ < kDarkWorldMapIdStart) { + main_gfx_id_ = 0x20; + } else if (parent_ >= kDarkWorldMapIdStart && + parent_ < kSpecialWorldMapIdStart) { + main_gfx_id_ = 0x21; + } else if (parent_ >= kSpecialWorldMapIdStart) { + // Special world maps - use appropriate graphics ID based on the specific map + if (parent_ == 0x88) { + main_gfx_id_ = 0x24; + } else { + // Default special world graphics ID + main_gfx_id_ = 0x20; + } + } +} + +void OverworldMap::LoadSpritesBlocksets() { + int static_graphics_base = 0x73; + static_graphics_[8] = static_graphics_base + 0x00; + static_graphics_[9] = static_graphics_base + 0x01; + static_graphics_[10] = static_graphics_base + 0x06; + static_graphics_[11] = static_graphics_base + 0x07; + + for (int i = 0; i < 4; i++) { + static_graphics_[12 + i] = + ((*rom_)[rom_->version_constants().kSpriteBlocksetPointer + + (sprite_graphics_[game_state_] * 4) + i] + + static_graphics_base); + } +} + +void OverworldMap::LoadMainBlocksets() { + for (int i = 0; i < 8; i++) { + static_graphics_[i] = + (*rom_)[rom_->version_constants().kOverworldGfxGroups2 + + (main_gfx_id_ * 8) + i]; + } +} + +// For animating water tiles on the overworld map. +// We want to swap out static_graphics_[07] with the next sheet +// Usually it is 5A, so we make it 5B instead. +// There is a middle frame which contains tiles from the bottom half +// of the 5A sheet, so this will need some special manipulation to make work +// during the BuildBitmap step (or a new one specifically for animating). +void OverworldMap::DrawAnimatedTiles() { + if (static_graphics_[7] == 0x5B) { + static_graphics_[7] = 0x5A; + } else { + if (static_graphics_[7] == 0x59) { + static_graphics_[7] = 0x58; + } + static_graphics_[7] = 0x5B; + } +} + +void OverworldMap::LoadAreaGraphicsBlocksets() { + for (int i = 0; i < 4; i++) { + uint8_t value = (*rom_)[rom_->version_constants().kOverworldGfxGroups1 + + (area_graphics_ * 4) + i]; + if (value != 0) { + static_graphics_[3 + i] = value; + } + } +} + +// TODO: Change the conditions for death mountain gfx +// JaredBrian: This is how ZS did it, but in 3.0.4 I changed it to just check +// for 03, 05, 07, and the DW ones as that's how it would appear in-game if +// you were to make area 03 not a large area anymore for example, so you might +// want to do the same. +void OverworldMap::LoadDeathMountainGFX() { + static_graphics_[7] = (((parent_ >= 0x03 && parent_ <= 0x07) || + (parent_ >= 0x0B && parent_ <= 0x0E)) || + ((parent_ >= 0x43 && parent_ <= 0x47) || + (parent_ >= 0x4B && parent_ <= 0x4E))) + ? 0x59 + : 0x5B; +} + +void OverworldMap::LoadAreaGraphics() { + LoadMainBlocksetId(); + LoadSpritesBlocksets(); + LoadMainBlocksets(); + LoadAreaGraphicsBlocksets(); + LoadDeathMountainGFX(); +} + +namespace palette_internal { + +absl::Status SetColorsPalette(Rom& rom, int index, gfx::SnesPalette& current, + gfx::SnesPalette main, gfx::SnesPalette animated, + gfx::SnesPalette aux1, gfx::SnesPalette aux2, + gfx::SnesPalette hud, gfx::SnesColor bgrcolor, + gfx::SnesPalette spr, gfx::SnesPalette spr2) { + // Palettes infos, color 0 of a palette is always transparent (the arrays + // contains 7 colors width wide) There is 16 color per line so 16*Y + + // Left side of the palette - Main, Animated + std::array new_palette = {}; + + // Main Palette, Location 0,2 : 35 colors [7x5] + int k = 0; + for (int y = 2; y < 7; y++) { + for (int x = 1; x < 8; x++) { + new_palette[x + (16 * y)] = main[k]; + k++; + } + } + + // Animated Palette, Location 0,7 : 7colors + for (int x = 1; x < 8; x++) { + new_palette[(16 * 7) + (x)] = animated[(x - 1)]; + } + + // Right side of the palette - Aux1, Aux2 + + // Aux1 Palette, Location 8,2 : 21 colors [7x3] + k = 0; + for (int y = 2; y < 5; y++) { + for (int x = 9; x < 16; x++) { + new_palette[x + (16 * y)] = aux1[k]; + k++; + } + } + + // Aux2 Palette, Location 8,5 : 21 colors [7x3] + k = 0; + for (int y = 5; y < 8; y++) { + for (int x = 9; x < 16; x++) { + new_palette[x + (16 * y)] = aux2[k]; + k++; + } + } + + // Hud Palette, Location 0,0 : 32 colors [16x2] + for (int i = 0; i < 32; i++) { + new_palette[i] = hud[i]; + } + + // Hardcoded grass color (that might change to become invisible instead) + for (int i = 0; i < 8; i++) { + new_palette[(i * 16)] = bgrcolor; + new_palette[(i * 16) + 8] = bgrcolor; + } + + // Sprite Palettes + k = 0; + for (int y = 8; y < 9; y++) { + for (int x = 1; x < 8; x++) { + new_palette[x + (16 * y)] = rom.palette_group().sprites_aux1[1][k]; + k++; + } + } + + // Sprite Palettes + k = 0; + for (int y = 8; y < 9; y++) { + for (int x = 9; x < 16; x++) { + new_palette[x + (16 * y)] = rom.palette_group().sprites_aux3[0][k]; + k++; + } + } + + // Sprite Palettes + k = 0; + for (int y = 9; y < 13; y++) { + for (int x = 1; x < 16; x++) { + new_palette[x + (16 * y)] = rom.palette_group().global_sprites[0][k]; + k++; + } + } + + // Sprite Palettes + k = 0; + for (int y = 13; y < 14; y++) { + for (int x = 1; x < 8; x++) { + new_palette[x + (16 * y)] = spr[k]; + k++; + } + } + + // Sprite Palettes + k = 0; + for (int y = 14; y < 15; y++) { + for (int x = 1; x < 8; x++) { + new_palette[x + (16 * y)] = spr2[k]; + k++; + } + } + + // Sprite Palettes + k = 0; + for (int y = 15; y < 16; y++) { + for (int x = 1; x < 16; x++) { + new_palette[x + (16 * y)] = rom.palette_group().armors[0][k]; + k++; + } + } + + for (int i = 0; i < 256; i++) { + current[i] = new_palette[i]; + current[(i / 16) * 16].set_transparent(true); + } + + current.set_size(256); + return absl::OkStatus(); +} +} // namespace palette_internal + +absl::StatusOr OverworldMap::GetPalette( + const gfx::PaletteGroup& palette_group, int index, int previous_index, + int limit) { + if (index == 255) { + index = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + + (previous_index * 4)]; + } + if (index >= limit) { + index = limit - 1; + } + return palette_group[index]; +} + +absl::Status OverworldMap::LoadPalette() { + uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; + + int previous_pal_id = 0; + int previous_spr_pal_id = 0; + + if (index_ > 0) { + // Load previous palette ID based on ASM version + if (asm_version < 3 || asm_version == 0xFF) { + previous_pal_id = (*rom_)[kOverworldMapPaletteIds + parent_ - 1]; + } else { + // v3 uses expanded palette table + previous_pal_id = (*rom_)[kOverworldPalettesScreenToSetNew + parent_ - 1]; + } + + previous_spr_pal_id = (*rom_)[kOverworldSpritePaletteIds + parent_ - 1]; + } + + area_palette_ = std::min((int)area_palette_, 0xA3); + + uint8_t pal0 = 0; + uint8_t pal1 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + + (area_palette_ * 4)]; + uint8_t pal2 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + + (area_palette_ * 4) + 1]; + uint8_t pal3 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + + (area_palette_ * 4) + 2]; + uint8_t pal4 = (*rom_)[kOverworldSpritePaletteGroup + + (sprite_palette_[game_state_] * 2)]; + uint8_t pal5 = (*rom_)[kOverworldSpritePaletteGroup + + (sprite_palette_[game_state_] * 2) + 1]; + + auto grass_pal_group = rom_->palette_group().grass; + auto bgr = grass_pal_group[0][0]; + + // Handle 0xFF palette references (use previous palette) + if (pal1 == 0xFF) { + pal1 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + + (previous_pal_id * 4)]; + } + + if (pal2 == 0xFF) { + pal2 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + + (previous_pal_id * 4) + 1]; + } + + if (pal3 == 0xFF) { + pal3 = (*rom_)[rom_->version_constants().kOverworldMapPaletteGroup + + (previous_pal_id * 4) + 2]; + } + + auto ow_aux_pal_group = rom_->palette_group().overworld_aux; + ASSIGN_OR_RETURN(gfx::SnesPalette aux1, + GetPalette(ow_aux_pal_group, pal1, previous_pal_id, 20)); + ASSIGN_OR_RETURN(gfx::SnesPalette aux2, + GetPalette(ow_aux_pal_group, pal2, previous_pal_id, 20)); + + // Set background color based on world type and area-specific settings + bool use_area_specific_bg = + (*rom_)[OverworldCustomAreaSpecificBGEnabled] != 0x00; + if (use_area_specific_bg) { + // Use area-specific background color from custom array + area_specific_bg_color_ = + (*rom_)[OverworldCustomAreaSpecificBGPalette + (parent_ * 2)] | + ((*rom_)[OverworldCustomAreaSpecificBGPalette + (parent_ * 2) + 1] + << 8); + // Convert 15-bit SNES color to palette color + bgr = gfx::SnesColor(area_specific_bg_color_); + } else { + // Use default world-based background colors + if (parent_ < kDarkWorldMapIdStart) { + bgr = grass_pal_group[0][0]; // LW + } else if (parent_ >= kDarkWorldMapIdStart && + parent_ < kSpecialWorldMapIdStart) { + bgr = grass_pal_group[0][1]; // DW + } else if (parent_ >= 128 && parent_ < kNumOverworldMaps) { + bgr = grass_pal_group[0][2]; // SW + } + } + + // Use main palette from the overworld map data (matches ZScream logic) + pal0 = main_palette_; + + auto ow_main_pal_group = rom_->palette_group().overworld_main; + ASSIGN_OR_RETURN(gfx::SnesPalette main, + GetPalette(ow_main_pal_group, pal0, previous_pal_id, 255)); + auto ow_animated_pal_group = rom_->palette_group().overworld_animated; + ASSIGN_OR_RETURN(gfx::SnesPalette animated, + GetPalette(ow_animated_pal_group, std::min((int)pal3, 13), + previous_pal_id, 14)); + + auto hud_pal_group = rom_->palette_group().hud; + gfx::SnesPalette hud = hud_pal_group[0]; + + // Handle 0xFF sprite palette references (use previous sprite palette) + if (pal4 == 0xFF) { + pal4 = (*rom_)[kOverworldSpritePaletteGroup + (previous_spr_pal_id * 2)]; + } + + if (pal4 == 0xFF) { + pal4 = 0; // Fallback to 0 if still 0xFF + } + + if (pal5 == 0xFF) { + pal5 = + (*rom_)[kOverworldSpritePaletteGroup + (previous_spr_pal_id * 2) + 1]; + } + + if (pal5 == 0xFF) { + pal5 = 0; // Fallback to 0 if still 0xFF + } + + ASSIGN_OR_RETURN(gfx::SnesPalette spr, + GetPalette(rom_->palette_group().sprites_aux3, pal4, + previous_spr_pal_id, 24)); + ASSIGN_OR_RETURN(gfx::SnesPalette spr2, + GetPalette(rom_->palette_group().sprites_aux3, pal5, + previous_spr_pal_id, 24)); + + RETURN_IF_ERROR(palette_internal::SetColorsPalette( + *rom_, parent_, current_palette_, main, animated, aux1, aux2, hud, bgr, + spr, spr2)); + + if (palettesets_.count(area_palette_) == 0) { + palettesets_[area_palette_] = gfx::Paletteset{ + main, animated, aux1, aux2, bgr, hud, spr, spr2, current_palette_}; + } + + return absl::OkStatus(); +} + +absl::Status OverworldMap::LoadOverlay() { + uint8_t asm_version = (*rom_)[OverworldCustomASMHasBeenApplied]; + + // Load overlays based on ROM version + if (asm_version == 0xFF) { + // Vanilla ROM - load overlay from overlay pointers + return LoadVanillaOverlayData(); + } else { + // Custom overworld ROM - use overlay from custom data + overlay_id_ = subscreen_overlay_; + has_overlay_ = (overlay_id_ != 0x00FF); + overlay_data_.clear(); + return absl::OkStatus(); + } +} + +absl::Status OverworldMap::LoadVanillaOverlayData() { + + // Load vanilla overlay for this map (interactive overlays for revealing holes/changing elements) + int address = (kOverlayPointersBank << 16) + + ((*rom_)[kOverlayPointers + (index_ * 2) + 1] << 8) + + (*rom_)[kOverlayPointers + (index_ * 2)]; + + // Convert SNES address to PC address + address = ((address & 0x7F0000) >> 1) | (address & 0x7FFF); + + // Check if custom overlay code is present + if ((*rom_)[kOverlayData1] == 0x6B) { + // Use custom overlay data pointer + address = ((*rom_)[kOverlayData2 + 2 + (index_ * 3)] << 16) + + ((*rom_)[kOverlayData2 + 1 + (index_ * 3)] << 8) + + (*rom_)[kOverlayData2 + (index_ * 3)]; + address = ((address & 0x7F0000) >> 1) | (address & 0x7FFF); + } + + // Validate address + if (address >= rom_->size()) { + has_overlay_ = false; + overlay_id_ = 0; + overlay_data_.clear(); + return absl::OkStatus(); + } + + // Parse overlay data (interactive overlays) + overlay_data_.clear(); + uint8_t b = (*rom_)[address]; + + // Parse overlay commands until we hit END (0x60) + while (b != 0x60 && address < rom_->size()) { + overlay_data_.push_back(b); + + // Handle different overlay commands + switch (b) { + case 0xA9: // LDA #$ + if (address + 2 < rom_->size()) { + overlay_data_.push_back((*rom_)[address + 1]); + overlay_data_.push_back((*rom_)[address + 2]); + address += 3; + } else { + address++; + } + break; + case 0xA2: // LDX #$ + if (address + 2 < rom_->size()) { + overlay_data_.push_back((*rom_)[address + 1]); + overlay_data_.push_back((*rom_)[address + 2]); + address += 3; + } else { + address++; + } + break; + case 0x8D: // STA $xxxx + if (address + 3 < rom_->size()) { + overlay_data_.push_back((*rom_)[address + 1]); + overlay_data_.push_back((*rom_)[address + 2]); + overlay_data_.push_back((*rom_)[address + 3]); + address += 4; + } else { + address++; + } + break; + case 0x9D: // STA $xxxx,x + if (address + 3 < rom_->size()) { + overlay_data_.push_back((*rom_)[address + 1]); + overlay_data_.push_back((*rom_)[address + 2]); + overlay_data_.push_back((*rom_)[address + 3]); + address += 4; + } else { + address++; + } + break; + case 0x8F: // STA $xxxxxx + if (address + 4 < rom_->size()) { + overlay_data_.push_back((*rom_)[address + 1]); + overlay_data_.push_back((*rom_)[address + 2]); + overlay_data_.push_back((*rom_)[address + 3]); + overlay_data_.push_back((*rom_)[address + 4]); + address += 5; + } else { + address++; + } + break; + case 0x1A: // INC A + address++; + break; + case 0x4C: // JMP + if (address + 3 < rom_->size()) { + overlay_data_.push_back((*rom_)[address + 1]); + overlay_data_.push_back((*rom_)[address + 2]); + overlay_data_.push_back((*rom_)[address + 3]); + address += 4; + } else { + address++; + } + break; + default: + address++; + break; + } + + if (address < rom_->size()) { + b = (*rom_)[address]; + } else { + break; + } + } + + // Add the END command if we found it + if (b == 0x60) { + overlay_data_.push_back(0x60); + } + + // Set overlay ID based on map index (simplified) + overlay_id_ = index_; + has_overlay_ = !overlay_data_.empty(); + + return absl::OkStatus(); +} + +void OverworldMap::ProcessGraphicsBuffer(int index, int static_graphics_offset, + int size, uint8_t* all_gfx) { + // Ensure we don't go out of bounds + int max_offset = static_graphics_offset * size + size; + if (max_offset > rom_->graphics_buffer().size()) { + // Fill with zeros if out of bounds + for (int i = 0; i < size; i++) { + current_gfx_[(index * size) + i] = 0x00; + } + return; + } + + for (int i = 0; i < size; i++) { + auto byte = all_gfx[i + (static_graphics_offset * size)]; + switch (index) { + case 0: + case 3: + case 4: + case 5: + byte += 0x88; + break; + } + current_gfx_[(index * size) + i] = byte; + } +} + +absl::Status OverworldMap::BuildTileset() { + if (current_gfx_.size() == 0) + current_gfx_.resize(0x10000, 0x00); + + // Process the 8 main graphics sheets (slots 0-7) + for (int i = 0; i < 8; i++) { + if (static_graphics_[i] != 0) { + ProcessGraphicsBuffer(i, static_graphics_[i], 0x1000, + rom_->graphics_buffer().data()); + } + } + + // Process sprite graphics (slots 8-15) + for (int i = 8; i < 16; i++) { + if (static_graphics_[i] != 0) { + ProcessGraphicsBuffer(i, static_graphics_[i], 0x1000, + rom_->graphics_buffer().data()); + } + } + + // Process animated graphics if available (slot 16) + if (static_graphics_[16] != 0) { + ProcessGraphicsBuffer(7, static_graphics_[16], 0x1000, + rom_->graphics_buffer().data()); + } + + return absl::OkStatus(); +} + +absl::Status OverworldMap::BuildTiles16Gfx(std::vector& tiles16, + int count) { + if (current_blockset_.size() == 0) + current_blockset_.resize(0x100000, 0x00); + + const int offsets[] = {0x00, 0x08, 0x400, 0x408}; + auto yy = 0; + auto xx = 0; + + for (auto i = 0; i < count; i++) { + for (auto tile = 0; tile < 0x04; tile++) { + gfx::TileInfo info = tiles16[i].tiles_info[tile]; + int offset = offsets[tile]; + for (auto y = 0; y < 0x08; ++y) { + for (auto x = 0; x < 0x08; ++x) { + int mx = x; + int my = y; + + if (info.horizontal_mirror_ != 0) { + mx = 0x07 - x; + } + + if (info.vertical_mirror_ != 0) { + my = 0x07 - y; + } + + int xpos = ((info.id_ % 0x10) * 0x08); + int ypos = (((info.id_ / 0x10)) * 0x400); + int source = ypos + xpos + (x + (y * 0x80)); + + auto destination = xx + yy + offset + (mx + (my * 0x80)); + current_blockset_[destination] = + (current_gfx_[source] & 0x0F) + (info.palette_ * 0x10); + } + } + } + + xx += 0x10; + if (xx >= 0x80) { + yy += 0x800; + xx = 0; + } + } + + return absl::OkStatus(); +} + +absl::Status OverworldMap::BuildBitmap(OverworldBlockset& world_blockset) { + if (bitmap_data_.size() != 0) { + bitmap_data_.clear(); + } + bitmap_data_.reserve(0x40000); + for (int i = 0; i < 0x40000; i++) { + bitmap_data_.push_back(0x00); + } + + int superY = ((index_ - (world_ * 0x40)) / 0x08); + int superX = index_ - (world_ * 0x40) - (superY * 0x08); + + for (int y = 0; y < 0x20; y++) { + for (int x = 0; x < 0x20; x++) { + auto xt = x + (superX * 0x20); + auto yt = y + (superY * 0x20); + gfx::CopyTile8bpp16((x * 0x10), (y * 0x10), world_blockset[xt][yt], + bitmap_data_, current_blockset_); + } + } + return absl::OkStatus(); +} + +} // namespace zelda3 +} // namespace yaze diff --git a/src/app/zelda3/overworld/overworld_map.h b/src/zelda3/overworld/overworld_map.h similarity index 100% rename from src/app/zelda3/overworld/overworld_map.h rename to src/zelda3/overworld/overworld_map.h diff --git a/src/app/zelda3/screen/dungeon_map.cc b/src/zelda3/screen/dungeon_map.cc similarity index 100% rename from src/app/zelda3/screen/dungeon_map.cc rename to src/zelda3/screen/dungeon_map.cc diff --git a/src/app/zelda3/screen/dungeon_map.h b/src/zelda3/screen/dungeon_map.h similarity index 100% rename from src/app/zelda3/screen/dungeon_map.h rename to src/zelda3/screen/dungeon_map.h diff --git a/src/app/zelda3/screen/inventory.cc b/src/zelda3/screen/inventory.cc similarity index 100% rename from src/app/zelda3/screen/inventory.cc rename to src/zelda3/screen/inventory.cc diff --git a/src/app/zelda3/screen/inventory.h b/src/zelda3/screen/inventory.h similarity index 100% rename from src/app/zelda3/screen/inventory.h rename to src/zelda3/screen/inventory.h diff --git a/src/app/zelda3/screen/title_screen.cc b/src/zelda3/screen/title_screen.cc similarity index 100% rename from src/app/zelda3/screen/title_screen.cc rename to src/zelda3/screen/title_screen.cc diff --git a/src/app/zelda3/screen/title_screen.h b/src/zelda3/screen/title_screen.h similarity index 100% rename from src/app/zelda3/screen/title_screen.h rename to src/zelda3/screen/title_screen.h diff --git a/src/app/zelda3/sprite/overlord.h b/src/zelda3/sprite/overlord.h similarity index 100% rename from src/app/zelda3/sprite/overlord.h rename to src/zelda3/sprite/overlord.h diff --git a/src/app/zelda3/sprite/sprite.cc b/src/zelda3/sprite/sprite.cc similarity index 100% rename from src/app/zelda3/sprite/sprite.cc rename to src/zelda3/sprite/sprite.cc diff --git a/src/app/zelda3/sprite/sprite.h b/src/zelda3/sprite/sprite.h similarity index 95% rename from src/app/zelda3/sprite/sprite.h rename to src/zelda3/sprite/sprite.h index 7e99a954..c987d743 100644 --- a/src/app/zelda3/sprite/sprite.h +++ b/src/zelda3/sprite/sprite.h @@ -1,392 +1,392 @@ -#ifndef YAZE_APP_ZELDA3_SPRITE_H -#define YAZE_APP_ZELDA3_SPRITE_H - -#include - -#include -#include -#include - -#include "app/zelda3/common.h" -#include "app/zelda3/sprite/overlord.h" - -namespace yaze { -namespace zelda3 { - -static const std::string kSpriteDefaultNames[]{ - "00 Raven", - "01 Vulture", - "02 Flying Stalfos Head", - "03 No Pointer (Empty", - "04 Pull Switch (good", - "05 Pull Switch (unused", - "06 Pull Switch (bad", - "07 Pull Switch (unused", - "08 Octorock (one way", - "09 Moldorm (Boss", - "0A Octorock (four way", - "0B Chicken", - "0C Octorock (?", - "0D Buzzblock", - "0E Snapdragon", - "0F Octoballoon", - "10 Octoballon Hatchlings", - "11 Hinox", - "12 Moblin", - "13 Mini Helmasaure", - "14 Gargoyle's Domain Gate", - "15 Antifairy", - "16 Sahasrahla / Aginah", - "17 Bush Hoarder", - "18 Mini Moldorm", - "19 Poe", - "1A Dwarves", - "1B Arrow in wall", - "1C Statue", - "1D Weathervane", - "1E Crystal Switch", - "1F Bug-Catching Kid", - "20 Sluggula", - "21 Push Switch", - "22 Ropa", - "23 Red Bari", - "24 Blue Bari", - "25 Talking Tree", - "26 Hardhat Beetle", - "27 Deadrock", - "28 Storytellers", - "29 Blind Hideout attendant", - "2A Sweeping Lady", - "2B Storytellers", - "2C Lumberjacks", - "2D Telepathic Stones", - "2E Multipurpose Sprite", - "2F Race Npc", - "30 Person?", - "31 Fortune Teller", - "32 Angry Brothers", - "33 Pull for items", - "34 Scared Girl", - "35 Innkeeper", - "36 Witch", - "37 Waterfall", - "38 Arrow Target", - "39 Average Middle", - "3A Half Magic Bat", - "3B Dash Item", - "3C Village Kid", - "3D Signs? Chicken lady also showed up / Scared ladies outside houses.", - "3E Rock Hoarder", - "3F Tutorial Soldier", - "40 Lightning Lock", - "41 Blue Sword Soldier / Used by guards to detect player", - "42 Green Sword Soldier", - "43 Red Spear Soldier", - "44 Assault Sword Soldier", - "45 Green Spear Soldier", - "46 Blue Archer", - "47 Green Archer", - "48 Red Javelin Soldier", - "49 Red Javelin Soldier 2", - "4A Red Bomb Soldiers", - "4B Green Soldier Recruits", - "4C Geldman", - "4D Rabbit", - "4E Popo", - "4F Popo 2", - "50 Cannon Balls", - "51 Armos", - "52 Giant Zora", - "53 Armos Knights (Boss", - "54 Lanmolas (Boss", - "55 Fireball Zora", - "56 Walking Zora", - "57 Desert Palace Barriers", - "58 Crab", - "59 Bird", - "5A Squirrel", - "5B Spark (Left to Right", - "5C Spark (Right to Left", - "5D Roller (vertical moving", - "5E Roller (vertical moving", - "5F Roller", - "60 Roller (horizontal moving", - "61 Beamos", - "62 Master Sword", - "63 Devalant (Non", - "64 Devalant (Shooter", - "65 Shooting Gallery Proprietor", - "66 Moving Cannon Ball Shooters (Right", - "67 Moving Cannon Ball Shooters (Left", - "68 Moving Cannon Ball Shooters (Down", - "69 Moving Cannon Ball Shooters (Up", - "6A Ball N' Chain Trooper", - "6B Cannon Soldier", - "6C Mirror Portal", - "6D Rat", - "6E Rope", - "6F Keese", - "70 Helmasaur King Fireball", - "71 Leever", - "72 Activator for the ponds (where you throw in items", - "73 Uncle / Priest", - "74 Running Man", - "75 Bottle Salesman", - "76 Princess Zelda", - "77 Antifairy (Alternate", - "78 Village Elder", - "79 Bee", - "7A Agahnim", - "7B Agahnim Energy Ball", - "7C Hyu", - "7D Big Spike Trap", - "7E Guruguru Bar (Clockwise", - "7F Guruguru Bar (Counter Clockwise", - "80 Winder", - "81 Water Tektite", - "82 Antifairy Circle", - "83 Green Eyegore", - "84 Red Eyegore", - "85 Yellow Stalfos", - "86 Kodongos", - "87 Flames", - "88 Mothula (Boss", - "89 Mothula's Beam", - "8A Spike Trap", - "8B Gibdo", - "8C Arrghus (Boss", - "8D Arrghus spawn", - "8E Terrorpin", - "8F Slime", - "90 Wallmaster", - "91 Stalfos Knight", - "92 Helmasaur King", - "93 Bumper", - "94 Swimmers", - "95 Eye Laser (Right", - "96 Eye Laser (Left", - "97 Eye Laser (Down", - "98 Eye Laser (Up", - "99 Pengator", - "9A Kyameron", - "9B Wizzrobe", - "9C Tadpoles", - "9D Tadpoles", - "9E Ostrich (Haunted Grove", - "9F Flute", - "A0 Birds (Haunted Grove", - "A1 Freezor", - "A2 Kholdstare (Boss", - "A3 Kholdstare's Shell", - "A4 Falling Ice", - "A5 Zazak Fireball", - "A6 Red Zazak", - "A7 Stalfos", - "A8 Bomber Flying Creatures from Darkworld", - "A9 Bomber Flying Creatures from Darkworld", - "AA Pikit", - "AB Maiden", - "AC Apple", - "AD Lost Old Man", - "AE Down Pipe", - "AF Up Pipe", - "B0 Right Pip", - "B1 Left Pipe", - "B2 Good bee again?", - "B3 Hylian Inscription", - "B4 Thief?s chest (not the one that follows you", - "B5 Bomb Salesman", - "B6 Kiki", - "B7 Maiden following you in Blind Dungeon", - "B8 Monologue Testing Sprite", - "B9 Feuding Friends on Death Mountain", - "BA Whirlpool", - "BB Salesman / chestgame guy / 300 rupee giver guy / Chest game thief", - "BC Drunk in the inn", - "BD Vitreous (Large Eyeball", - "BE Vitreous (Small Eyeball", - "BF Vitreous' Lightning", - "C0 Monster in Lake of Ill Omen / Quake Medallion", - "C1 Agahnim teleporting Zelda to dark world", - "C2 Boulders", - "C3 Gibo", - "C4 Thief", - "C5 Medusa", - "C6 Four Way Fireball Spitters (spit when you use your sword", - "C7 Hokku", - "C8 Big Fairy who heals you", - "C9 Tektite", - "CA Chain Chomp", - "CB Trinexx", - "CC Another part of trinexx", - "CD Yet another part of trinexx", - "CE Blind The Thief (Boss)", - "CF Swamola", - "D0 Lynel", - "D1 Bunny Beam", - "D2 Flopping fish", - "D3 Stal", - "D4 Landmine", - "D5 Digging Game Proprietor", - "D6 Ganon", - "D7 Copy of Ganon", - "D8 Heart", - "D9 Green Rupee", - "DA Blue Rupee", - "DB Red Rupee", - "DC Bomb Refill (1)", - "DD Bomb Refill (4)", - "DE Bomb Refill (8)", - "DF Small Magic Refill", - "E0 Full Magic Refill", - "E1 Arrow Refill (5)", - "E2 Arrow Refill (10)", - "E3 Fairy", - "E4 Key", - "E5 Big Key", - "E6 Shield", - "E7 Mushroom", - "E8 Fake Master Sword", - "E9 Magic Shop dude / His items", - "EA Heart Container", - "EB Heart Piece", - "EC Bushes", - "ED Cane Of Somaria Platform", - "EE Mantle", - "EF Cane of Somaria Platform (Unused)", - "F0 Cane of Somaria Platform (Unused)", - "F1 Cane of Somaria Platform (Unused)", - "F2 Medallion Tablet", - "F3", - "F4 Falling Rocks", - "F5", - "F6", - "F7", - "F8", - "F9", - "FA", - "FB", - "FC", - "FD", - "FE", - "FF", -}; - -/** - * @class Sprite - * @brief A class for managing sprites in the overworld and underworld. - */ -class Sprite : public GameEntity { - public: - Sprite() = default; - Sprite(const std::vector& src, uint8_t overworld_map_id, uint8_t id, - uint8_t x, uint8_t y, int map_x, int map_y) - : map_id_(static_cast(overworld_map_id)), - id_(id), - nx_(x), - ny_(y), - map_x_(map_x), - map_y_(map_y), - current_gfx_(src) { - entity_type_ = zelda3::GameEntity::EntityType::kSprite; - entity_id_ = id; - x_ = map_x_; - y_ = map_y_; - overworld_ = true; - name_ = kSpriteDefaultNames[id]; - preview_gfx_.resize(64 * 64, 0xFF); - } - - Sprite(uint8_t id, uint8_t x, uint8_t y, uint8_t subtype, uint8_t layer) - : id_(id), nx_(x), ny_(y), subtype_(subtype), layer_(layer) { - x_ = x; - y_ = y; - name_ = kSpriteDefaultNames[id]; - if (((subtype & 0x07) == 0x07) && id > 0 && id <= 0x1A) { - name_ = kOverlordNames[id - 1]; - overlord_ = 1; - } - } - - void InitSprite(const std::vector& src, uint8_t overworld_map_id, - uint8_t id, uint8_t x, uint8_t y, int map_x, int map_y) { - current_gfx_ = src; - overworld_ = true; - map_id_ = static_cast(overworld_map_id); - id_ = id; - entity_type_ = zelda3::GameEntity::EntityType::kSprite; - entity_id_ = id; - x_ = map_x_; - y_ = map_y_; - nx_ = x; - ny_ = y; - name_ = kSpriteDefaultNames[id]; - map_x_ = map_x; - map_y_ = map_y; - preview_gfx_.resize(64 * 64, 0xFF); - } - - void Draw(); - void DrawSpriteTile(int x, int y, int srcx, int srcy, int pal, - bool mirror_x = false, bool mirror_y = false, - int sizex = 2, int sizey = 2); - - void UpdateMapProperties(uint16_t map_id) override; - void UpdateCoordinates(int map_x, int map_y); - - auto preview_graphics() const { return &preview_gfx_; } - auto id() const { return id_; } - auto set_id(uint8_t id) { id_ = id; } - auto x() const { return x_; } - auto y() const { return y_; } - auto nx() const { return nx_; } - auto ny() const { return ny_; } - auto map_id() const { return map_id_; } - auto map_x() const { return map_x_; } - auto map_y() const { return map_y_; } - auto game_state() const { return game_state_; } - - auto layer() const { return layer_; } - auto subtype() const { return subtype_; } - - auto width() const { return width_; } - auto height() const { return height_; } - auto name() { return name_; } - auto deleted() const { return deleted_; } - auto set_deleted(bool deleted) { deleted_ = deleted; } - auto set_key_drop(int key) { key_drop_ = key; } - - private: - uint8_t map_id_; - uint8_t game_state_; - uint8_t id_; - uint8_t nx_; - uint8_t ny_; - uint8_t overlord_ = 0; - uint8_t lower_x_ = 32; - uint8_t lower_y_ = 32; - uint8_t higher_x_ = 0; - uint8_t higher_y_ = 0; - - int width_ = 16; - int height_ = 16; - int map_x_ = 0; - int map_y_ = 0; - int layer_ = 0; - int subtype_ = 0; - int key_drop_ = 0; - - bool deleted_ = false; - bool overworld_; - - std::string name_; - std::vector preview_gfx_; - std::vector current_gfx_; - - SDL_Rect bounding_box_; -}; - -} // namespace zelda3 -} // namespace yaze - -#endif +#ifndef YAZE_APP_ZELDA3_SPRITE_H +#define YAZE_APP_ZELDA3_SPRITE_H + +#include + +#include +#include +#include + +#include "zelda3/common.h" +#include "zelda3/sprite/overlord.h" + +namespace yaze { +namespace zelda3 { + +static const std::string kSpriteDefaultNames[]{ + "00 Raven", + "01 Vulture", + "02 Flying Stalfos Head", + "03 No Pointer (Empty", + "04 Pull Switch (good", + "05 Pull Switch (unused", + "06 Pull Switch (bad", + "07 Pull Switch (unused", + "08 Octorock (one way", + "09 Moldorm (Boss", + "0A Octorock (four way", + "0B Chicken", + "0C Octorock (?", + "0D Buzzblock", + "0E Snapdragon", + "0F Octoballoon", + "10 Octoballon Hatchlings", + "11 Hinox", + "12 Moblin", + "13 Mini Helmasaure", + "14 Gargoyle's Domain Gate", + "15 Antifairy", + "16 Sahasrahla / Aginah", + "17 Bush Hoarder", + "18 Mini Moldorm", + "19 Poe", + "1A Dwarves", + "1B Arrow in wall", + "1C Statue", + "1D Weathervane", + "1E Crystal Switch", + "1F Bug-Catching Kid", + "20 Sluggula", + "21 Push Switch", + "22 Ropa", + "23 Red Bari", + "24 Blue Bari", + "25 Talking Tree", + "26 Hardhat Beetle", + "27 Deadrock", + "28 Storytellers", + "29 Blind Hideout attendant", + "2A Sweeping Lady", + "2B Storytellers", + "2C Lumberjacks", + "2D Telepathic Stones", + "2E Multipurpose Sprite", + "2F Race Npc", + "30 Person?", + "31 Fortune Teller", + "32 Angry Brothers", + "33 Pull for items", + "34 Scared Girl", + "35 Innkeeper", + "36 Witch", + "37 Waterfall", + "38 Arrow Target", + "39 Average Middle", + "3A Half Magic Bat", + "3B Dash Item", + "3C Village Kid", + "3D Signs? Chicken lady also showed up / Scared ladies outside houses.", + "3E Rock Hoarder", + "3F Tutorial Soldier", + "40 Lightning Lock", + "41 Blue Sword Soldier / Used by guards to detect player", + "42 Green Sword Soldier", + "43 Red Spear Soldier", + "44 Assault Sword Soldier", + "45 Green Spear Soldier", + "46 Blue Archer", + "47 Green Archer", + "48 Red Javelin Soldier", + "49 Red Javelin Soldier 2", + "4A Red Bomb Soldiers", + "4B Green Soldier Recruits", + "4C Geldman", + "4D Rabbit", + "4E Popo", + "4F Popo 2", + "50 Cannon Balls", + "51 Armos", + "52 Giant Zora", + "53 Armos Knights (Boss", + "54 Lanmolas (Boss", + "55 Fireball Zora", + "56 Walking Zora", + "57 Desert Palace Barriers", + "58 Crab", + "59 Bird", + "5A Squirrel", + "5B Spark (Left to Right", + "5C Spark (Right to Left", + "5D Roller (vertical moving", + "5E Roller (vertical moving", + "5F Roller", + "60 Roller (horizontal moving", + "61 Beamos", + "62 Master Sword", + "63 Devalant (Non", + "64 Devalant (Shooter", + "65 Shooting Gallery Proprietor", + "66 Moving Cannon Ball Shooters (Right", + "67 Moving Cannon Ball Shooters (Left", + "68 Moving Cannon Ball Shooters (Down", + "69 Moving Cannon Ball Shooters (Up", + "6A Ball N' Chain Trooper", + "6B Cannon Soldier", + "6C Mirror Portal", + "6D Rat", + "6E Rope", + "6F Keese", + "70 Helmasaur King Fireball", + "71 Leever", + "72 Activator for the ponds (where you throw in items", + "73 Uncle / Priest", + "74 Running Man", + "75 Bottle Salesman", + "76 Princess Zelda", + "77 Antifairy (Alternate", + "78 Village Elder", + "79 Bee", + "7A Agahnim", + "7B Agahnim Energy Ball", + "7C Hyu", + "7D Big Spike Trap", + "7E Guruguru Bar (Clockwise", + "7F Guruguru Bar (Counter Clockwise", + "80 Winder", + "81 Water Tektite", + "82 Antifairy Circle", + "83 Green Eyegore", + "84 Red Eyegore", + "85 Yellow Stalfos", + "86 Kodongos", + "87 Flames", + "88 Mothula (Boss", + "89 Mothula's Beam", + "8A Spike Trap", + "8B Gibdo", + "8C Arrghus (Boss", + "8D Arrghus spawn", + "8E Terrorpin", + "8F Slime", + "90 Wallmaster", + "91 Stalfos Knight", + "92 Helmasaur King", + "93 Bumper", + "94 Swimmers", + "95 Eye Laser (Right", + "96 Eye Laser (Left", + "97 Eye Laser (Down", + "98 Eye Laser (Up", + "99 Pengator", + "9A Kyameron", + "9B Wizzrobe", + "9C Tadpoles", + "9D Tadpoles", + "9E Ostrich (Haunted Grove", + "9F Flute", + "A0 Birds (Haunted Grove", + "A1 Freezor", + "A2 Kholdstare (Boss", + "A3 Kholdstare's Shell", + "A4 Falling Ice", + "A5 Zazak Fireball", + "A6 Red Zazak", + "A7 Stalfos", + "A8 Bomber Flying Creatures from Darkworld", + "A9 Bomber Flying Creatures from Darkworld", + "AA Pikit", + "AB Maiden", + "AC Apple", + "AD Lost Old Man", + "AE Down Pipe", + "AF Up Pipe", + "B0 Right Pip", + "B1 Left Pipe", + "B2 Good bee again?", + "B3 Hylian Inscription", + "B4 Thief?s chest (not the one that follows you", + "B5 Bomb Salesman", + "B6 Kiki", + "B7 Maiden following you in Blind Dungeon", + "B8 Monologue Testing Sprite", + "B9 Feuding Friends on Death Mountain", + "BA Whirlpool", + "BB Salesman / chestgame guy / 300 rupee giver guy / Chest game thief", + "BC Drunk in the inn", + "BD Vitreous (Large Eyeball", + "BE Vitreous (Small Eyeball", + "BF Vitreous' Lightning", + "C0 Monster in Lake of Ill Omen / Quake Medallion", + "C1 Agahnim teleporting Zelda to dark world", + "C2 Boulders", + "C3 Gibo", + "C4 Thief", + "C5 Medusa", + "C6 Four Way Fireball Spitters (spit when you use your sword", + "C7 Hokku", + "C8 Big Fairy who heals you", + "C9 Tektite", + "CA Chain Chomp", + "CB Trinexx", + "CC Another part of trinexx", + "CD Yet another part of trinexx", + "CE Blind The Thief (Boss)", + "CF Swamola", + "D0 Lynel", + "D1 Bunny Beam", + "D2 Flopping fish", + "D3 Stal", + "D4 Landmine", + "D5 Digging Game Proprietor", + "D6 Ganon", + "D7 Copy of Ganon", + "D8 Heart", + "D9 Green Rupee", + "DA Blue Rupee", + "DB Red Rupee", + "DC Bomb Refill (1)", + "DD Bomb Refill (4)", + "DE Bomb Refill (8)", + "DF Small Magic Refill", + "E0 Full Magic Refill", + "E1 Arrow Refill (5)", + "E2 Arrow Refill (10)", + "E3 Fairy", + "E4 Key", + "E5 Big Key", + "E6 Shield", + "E7 Mushroom", + "E8 Fake Master Sword", + "E9 Magic Shop dude / His items", + "EA Heart Container", + "EB Heart Piece", + "EC Bushes", + "ED Cane Of Somaria Platform", + "EE Mantle", + "EF Cane of Somaria Platform (Unused)", + "F0 Cane of Somaria Platform (Unused)", + "F1 Cane of Somaria Platform (Unused)", + "F2 Medallion Tablet", + "F3", + "F4 Falling Rocks", + "F5", + "F6", + "F7", + "F8", + "F9", + "FA", + "FB", + "FC", + "FD", + "FE", + "FF", +}; + +/** + * @class Sprite + * @brief A class for managing sprites in the overworld and underworld. + */ +class Sprite : public GameEntity { + public: + Sprite() = default; + Sprite(const std::vector& src, uint8_t overworld_map_id, uint8_t id, + uint8_t x, uint8_t y, int map_x, int map_y) + : map_id_(static_cast(overworld_map_id)), + id_(id), + nx_(x), + ny_(y), + map_x_(map_x), + map_y_(map_y), + current_gfx_(src) { + entity_type_ = zelda3::GameEntity::EntityType::kSprite; + entity_id_ = id; + x_ = map_x_; + y_ = map_y_; + overworld_ = true; + name_ = kSpriteDefaultNames[id]; + preview_gfx_.resize(64 * 64, 0xFF); + } + + Sprite(uint8_t id, uint8_t x, uint8_t y, uint8_t subtype, uint8_t layer) + : id_(id), nx_(x), ny_(y), subtype_(subtype), layer_(layer) { + x_ = x; + y_ = y; + name_ = kSpriteDefaultNames[id]; + if (((subtype & 0x07) == 0x07) && id > 0 && id <= 0x1A) { + name_ = kOverlordNames[id - 1]; + overlord_ = 1; + } + } + + void InitSprite(const std::vector& src, uint8_t overworld_map_id, + uint8_t id, uint8_t x, uint8_t y, int map_x, int map_y) { + current_gfx_ = src; + overworld_ = true; + map_id_ = static_cast(overworld_map_id); + id_ = id; + entity_type_ = zelda3::GameEntity::EntityType::kSprite; + entity_id_ = id; + x_ = map_x_; + y_ = map_y_; + nx_ = x; + ny_ = y; + name_ = kSpriteDefaultNames[id]; + map_x_ = map_x; + map_y_ = map_y; + preview_gfx_.resize(64 * 64, 0xFF); + } + + void Draw(); + void DrawSpriteTile(int x, int y, int srcx, int srcy, int pal, + bool mirror_x = false, bool mirror_y = false, + int sizex = 2, int sizey = 2); + + void UpdateMapProperties(uint16_t map_id) override; + void UpdateCoordinates(int map_x, int map_y); + + auto preview_graphics() const { return &preview_gfx_; } + auto id() const { return id_; } + auto set_id(uint8_t id) { id_ = id; } + auto x() const { return x_; } + auto y() const { return y_; } + auto nx() const { return nx_; } + auto ny() const { return ny_; } + auto map_id() const { return map_id_; } + auto map_x() const { return map_x_; } + auto map_y() const { return map_y_; } + auto game_state() const { return game_state_; } + + auto layer() const { return layer_; } + auto subtype() const { return subtype_; } + + auto width() const { return width_; } + auto height() const { return height_; } + auto name() { return name_; } + auto deleted() const { return deleted_; } + auto set_deleted(bool deleted) { deleted_ = deleted; } + auto set_key_drop(int key) { key_drop_ = key; } + + private: + uint8_t map_id_; + uint8_t game_state_; + uint8_t id_; + uint8_t nx_; + uint8_t ny_; + uint8_t overlord_ = 0; + uint8_t lower_x_ = 32; + uint8_t lower_y_ = 32; + uint8_t higher_x_ = 0; + uint8_t higher_y_ = 0; + + int width_ = 16; + int height_ = 16; + int map_x_ = 0; + int map_y_ = 0; + int layer_ = 0; + int subtype_ = 0; + int key_drop_ = 0; + + bool deleted_ = false; + bool overworld_; + + std::string name_; + std::vector preview_gfx_; + std::vector current_gfx_; + + SDL_Rect bounding_box_; +}; + +} // namespace zelda3 +} // namespace yaze + +#endif diff --git a/src/app/zelda3/sprite/sprite_builder.cc b/src/zelda3/sprite/sprite_builder.cc similarity index 100% rename from src/app/zelda3/sprite/sprite_builder.cc rename to src/zelda3/sprite/sprite_builder.cc diff --git a/src/app/zelda3/sprite/sprite_builder.h b/src/zelda3/sprite/sprite_builder.h similarity index 100% rename from src/app/zelda3/sprite/sprite_builder.h rename to src/zelda3/sprite/sprite_builder.h diff --git a/src/app/zelda3/zelda3_labels.cc b/src/zelda3/zelda3_labels.cc similarity index 98% rename from src/app/zelda3/zelda3_labels.cc rename to src/zelda3/zelda3_labels.cc index ecd6ae69..63b806fe 100644 --- a/src/app/zelda3/zelda3_labels.cc +++ b/src/zelda3/zelda3_labels.cc @@ -1,9 +1,9 @@ -#include "app/zelda3/zelda3_labels.h" +#include "zelda3/zelda3_labels.h" -#include "app/zelda3/common.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/sprite/sprite.h" -#include "app/zelda3/sprite/overlord.h" +#include "zelda3/common.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/sprite/sprite.h" +#include "zelda3/sprite/overlord.h" namespace yaze { namespace zelda3 { diff --git a/src/app/zelda3/zelda3_labels.h b/src/zelda3/zelda3_labels.h similarity index 100% rename from src/app/zelda3/zelda3_labels.h rename to src/zelda3/zelda3_labels.h diff --git a/src/app/zelda3/zelda3_library.cmake b/src/zelda3/zelda3_library.cmake similarity index 72% rename from src/app/zelda3/zelda3_library.cmake rename to src/zelda3/zelda3_library.cmake index fe8cb9f5..e7a130ce 100644 --- a/src/app/zelda3/zelda3_library.cmake +++ b/src/zelda3/zelda3_library.cmake @@ -1,21 +1,21 @@ set( YAZE_APP_ZELDA3_SRC - app/zelda3/dungeon/dungeon_editor_system.cc - app/zelda3/dungeon/dungeon_object_editor.cc - app/zelda3/dungeon/object_drawer.cc - app/zelda3/dungeon/object_parser.cc - app/zelda3/dungeon/room.cc - app/zelda3/dungeon/room_layout.cc - app/zelda3/dungeon/room_object.cc - app/zelda3/music/tracker.cc - app/zelda3/overworld/overworld.cc - app/zelda3/overworld/overworld_map.cc - app/zelda3/screen/dungeon_map.cc - app/zelda3/screen/inventory.cc - app/zelda3/screen/title_screen.cc - app/zelda3/sprite/sprite.cc - app/zelda3/sprite/sprite_builder.cc - app/zelda3/zelda3_labels.cc + zelda3/dungeon/dungeon_editor_system.cc + zelda3/dungeon/dungeon_object_editor.cc + zelda3/dungeon/object_drawer.cc + zelda3/dungeon/object_parser.cc + zelda3/dungeon/room.cc + zelda3/dungeon/room_layout.cc + zelda3/dungeon/room_object.cc + zelda3/music/tracker.cc + zelda3/overworld/overworld.cc + zelda3/overworld/overworld_map.cc + zelda3/screen/dungeon_map.cc + zelda3/screen/inventory.cc + zelda3/screen/title_screen.cc + zelda3/sprite/sprite.cc + zelda3/sprite/sprite_builder.cc + zelda3/zelda3_labels.cc ) # ============================================================================== diff --git a/test/e2e/dungeon_object_rendering_e2e_tests.cc b/test/e2e/dungeon_object_rendering_e2e_tests.cc index df524b07..e4eebfa1 100644 --- a/test/e2e/dungeon_object_rendering_e2e_tests.cc +++ b/test/e2e/dungeon_object_rendering_e2e_tests.cc @@ -60,8 +60,8 @@ #include "app/core/window.h" #include "app/editor/dungeon/dungeon_editor_v2.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" #include "test_utils.h" namespace yaze { diff --git a/test/e2e/overworld/overworld_e2e_test.cc b/test/e2e/overworld/overworld_e2e_test.cc index cba5ae7c..62b2b6c8 100644 --- a/test/e2e/overworld/overworld_e2e_test.cc +++ b/test/e2e/overworld/overworld_e2e_test.cc @@ -5,8 +5,8 @@ #include #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" #include "testing.h" namespace yaze { diff --git a/test/integration/dungeon_editor_test.cc b/test/integration/dungeon_editor_test.cc index 2d2c0b12..18401d26 100644 --- a/test/integration/dungeon_editor_test.cc +++ b/test/integration/dungeon_editor_test.cc @@ -1,7 +1,7 @@ #include "integration/dungeon_editor_test.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace test { diff --git a/test/integration/dungeon_editor_test.h b/test/integration/dungeon_editor_test.h index 185692a5..a9259c4b 100644 --- a/test/integration/dungeon_editor_test.h +++ b/test/integration/dungeon_editor_test.h @@ -6,7 +6,7 @@ #include "app/editor/dungeon/dungeon_editor_v2.h" #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room.h" #include "gtest/gtest.h" namespace yaze { diff --git a/test/integration/editor/tile16_editor_test.cc b/test/integration/editor/tile16_editor_test.cc index f2a711fc..f7294413 100644 --- a/test/integration/editor/tile16_editor_test.cc +++ b/test/integration/editor/tile16_editor_test.cc @@ -10,7 +10,7 @@ #include "app/gfx/backend/sdl2_renderer.h" #include "app/gfx/bitmap.h" #include "app/gfx/tilemap.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld.h" #include "app/core/window.h" namespace yaze { diff --git a/test/integration/zelda3/dungeon_editor_system_integration_test.cc b/test/integration/zelda3/dungeon_editor_system_integration_test.cc index 89983971..940dd5ba 100644 --- a/test/integration/zelda3/dungeon_editor_system_integration_test.cc +++ b/test/integration/zelda3/dungeon_editor_system_integration_test.cc @@ -5,9 +5,9 @@ #include #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/dungeon_editor_system.h" -#include "app/zelda3/dungeon/dungeon_object_editor.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/dungeon_editor_system.h" +#include "zelda3/dungeon/dungeon_object_editor.h" namespace yaze { namespace zelda3 { diff --git a/test/integration/zelda3/dungeon_object_rendering_tests.cc b/test/integration/zelda3/dungeon_object_rendering_tests.cc index 38f94322..c5d8d8a3 100644 --- a/test/integration/zelda3/dungeon_object_rendering_tests.cc +++ b/test/integration/zelda3/dungeon_object_rendering_tests.cc @@ -6,9 +6,9 @@ #define IMGUI_DEFINE_MATH_OPERATORS #endif -#include "app/zelda3/dungeon/object_drawer.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/object_drawer.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" #include #include diff --git a/test/integration/zelda3/dungeon_object_rendering_tests_new.cc b/test/integration/zelda3/dungeon_object_rendering_tests_new.cc index 3b2b1ac0..8f1ed5d5 100644 --- a/test/integration/zelda3/dungeon_object_rendering_tests_new.cc +++ b/test/integration/zelda3/dungeon_object_rendering_tests_new.cc @@ -2,9 +2,9 @@ // Updated for DungeonEditorV2 architecture - uses ObjectDrawer (production system) // instead of the obsolete ObjectRenderer -#include "app/zelda3/dungeon/object_drawer.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/object_drawer.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" #include #include diff --git a/test/integration/zelda3/dungeon_rendering_test.cc b/test/integration/zelda3/dungeon_rendering_test.cc index 1060a6d5..fbc02917 100644 --- a/test/integration/zelda3/dungeon_rendering_test.cc +++ b/test/integration/zelda3/dungeon_rendering_test.cc @@ -4,10 +4,10 @@ #include "app/gfx/background_buffer.h" #include "app/gfx/snes_palette.h" #include "app/rom.h" -#include "app/zelda3/dungeon/object_drawer.h" -#include "app/zelda3/dungeon/object_parser.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/object_drawer.h" +#include "zelda3/dungeon/object_parser.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace zelda3 { diff --git a/test/integration/zelda3/dungeon_room_test.cc b/test/integration/zelda3/dungeon_room_test.cc index 5fef31ff..237e8ade 100644 --- a/test/integration/zelda3/dungeon_room_test.cc +++ b/test/integration/zelda3/dungeon_room_test.cc @@ -2,7 +2,7 @@ #include #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" +#include "zelda3/dungeon/room.h" namespace yaze { namespace test { diff --git a/test/integration/zelda3/overworld_integration_test.cc b/test/integration/zelda3/overworld_integration_test.cc index 21dbaa94..395e9fdd 100644 --- a/test/integration/zelda3/overworld_integration_test.cc +++ b/test/integration/zelda3/overworld_integration_test.cc @@ -5,8 +5,8 @@ #include #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" #include "testing.h" namespace yaze { diff --git a/test/integration/zelda3/room_integration_test.cc b/test/integration/zelda3/room_integration_test.cc index 9e9234b1..cde6c62d 100644 --- a/test/integration/zelda3/room_integration_test.cc +++ b/test/integration/zelda3/room_integration_test.cc @@ -5,8 +5,8 @@ #include #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" // Helper function for SNES to PC address conversion inline int SnesToPc(int addr) { diff --git a/test/integration/zelda3/sprite_position_test.cc b/test/integration/zelda3/sprite_position_test.cc index 7eef003d..e6a1e332 100644 --- a/test/integration/zelda3/sprite_position_test.cc +++ b/test/integration/zelda3/sprite_position_test.cc @@ -5,8 +5,8 @@ #include #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" namespace yaze { namespace zelda3 { diff --git a/test/unit/zelda3/dungeon/object_rendering_test.cc b/test/unit/zelda3/dungeon/object_rendering_test.cc index e29e1fa0..cd25881c 100644 --- a/test/unit/zelda3/dungeon/object_rendering_test.cc +++ b/test/unit/zelda3/dungeon/object_rendering_test.cc @@ -4,9 +4,9 @@ #include "app/gfx/background_buffer.h" #include "app/gfx/snes_palette.h" #include "app/rom.h" -#include "app/zelda3/dungeon/object_drawer.h" -#include "app/zelda3/dungeon/object_parser.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/object_drawer.h" +#include "zelda3/dungeon/object_parser.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace zelda3 { diff --git a/test/unit/zelda3/dungeon/room_manipulation_test.cc b/test/unit/zelda3/dungeon/room_manipulation_test.cc index 7e37d3b4..802b38ca 100644 --- a/test/unit/zelda3/dungeon/room_manipulation_test.cc +++ b/test/unit/zelda3/dungeon/room_manipulation_test.cc @@ -2,8 +2,8 @@ #include #include "app/rom.h" -#include "app/zelda3/dungeon/room.h" -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room.h" +#include "zelda3/dungeon/room_object.h" namespace yaze { namespace zelda3 { diff --git a/test/unit/zelda3/dungeon/room_object_encoding_test.cc b/test/unit/zelda3/dungeon/room_object_encoding_test.cc index 534c8d32..14f59d43 100644 --- a/test/unit/zelda3/dungeon/room_object_encoding_test.cc +++ b/test/unit/zelda3/dungeon/room_object_encoding_test.cc @@ -5,7 +5,7 @@ // correctly for all three object types (Type1, Type2, Type3) based on // ZScream's proven implementation. -#include "app/zelda3/dungeon/room_object.h" +#include "zelda3/dungeon/room_object.h" #include diff --git a/test/unit/zelda3/object_parser_structs_test.cc b/test/unit/zelda3/object_parser_structs_test.cc index ba48ab80..d31775c8 100644 --- a/test/unit/zelda3/object_parser_structs_test.cc +++ b/test/unit/zelda3/object_parser_structs_test.cc @@ -1,4 +1,4 @@ -#include "app/zelda3/dungeon/object_parser.h" +#include "zelda3/dungeon/object_parser.h" #include "gtest/gtest.h" diff --git a/test/unit/zelda3/object_parser_test.cc b/test/unit/zelda3/object_parser_test.cc index 2e292cdf..18dd9d3c 100644 --- a/test/unit/zelda3/object_parser_test.cc +++ b/test/unit/zelda3/object_parser_test.cc @@ -1,4 +1,4 @@ -#include "app/zelda3/dungeon/object_parser.h" +#include "zelda3/dungeon/object_parser.h" #include #include diff --git a/test/unit/zelda3/overworld_test.cc b/test/unit/zelda3/overworld_test.cc index 0cdb46f5..67f3114e 100644 --- a/test/unit/zelda3/overworld_test.cc +++ b/test/unit/zelda3/overworld_test.cc @@ -2,8 +2,8 @@ #include #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" namespace yaze { namespace zelda3 { diff --git a/test/unit/zelda3/sprite_builder_test.cc b/test/unit/zelda3/sprite_builder_test.cc index 56d2fcf8..edf51d9b 100644 --- a/test/unit/zelda3/sprite_builder_test.cc +++ b/test/unit/zelda3/sprite_builder_test.cc @@ -1,4 +1,4 @@ -#include "app/zelda3/sprite/sprite_builder.h" +#include "zelda3/sprite/sprite_builder.h" #include #include diff --git a/tools/test_helpers/extract_vanilla_values.cc b/tools/test_helpers/extract_vanilla_values.cc index a5a3241f..e0673125 100644 --- a/tools/test_helpers/extract_vanilla_values.cc +++ b/tools/test_helpers/extract_vanilla_values.cc @@ -4,8 +4,8 @@ #include #include "app/rom.h" -#include "app/zelda3/overworld/overworld_map.h" -#include "app/zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld.h" using namespace yaze::zelda3; using namespace yaze; diff --git a/tools/test_helpers/overworld_golden_data_extractor.cc b/tools/test_helpers/overworld_golden_data_extractor.cc index 0e831657..c0ea4836 100644 --- a/tools/test_helpers/overworld_golden_data_extractor.cc +++ b/tools/test_helpers/overworld_golden_data_extractor.cc @@ -7,8 +7,8 @@ #include #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" using namespace yaze::zelda3; using namespace yaze; @@ -95,7 +95,7 @@ class OverworldGoldenDataExtractor { out << "#include " << std::endl; out << "#include " << std::endl; out << "#include " << std::endl; - out << "#include \"app/zelda3/overworld/overworld_map.h\"" << std::endl; + out << "#include \"zelda3/overworld/overworld_map.h\"" << std::endl; out << std::endl; out << "namespace yaze {" << std::endl; out << "namespace test {" << std::endl; diff --git a/tools/test_helpers/rom_patch_utility.cc b/tools/test_helpers/rom_patch_utility.cc index 48fdbc71..c87bac7b 100644 --- a/tools/test_helpers/rom_patch_utility.cc +++ b/tools/test_helpers/rom_patch_utility.cc @@ -5,8 +5,8 @@ #include #include "app/rom.h" -#include "app/zelda3/overworld/overworld.h" -#include "app/zelda3/overworld/overworld_map.h" +#include "zelda3/overworld/overworld.h" +#include "zelda3/overworld/overworld_map.h" using namespace yaze::zelda3; using namespace yaze;