diff --git a/CMakeLists.txt b/CMakeLists.txt index d66e5e75..0522654e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,15 @@ set(YAZE_VERSION_MAJOR 0) set(YAZE_VERSION_MINOR 3) set(YAZE_VERSION_PATCH 2) +# Add an option to enable Unity builds for faster compilation +option(YAZE_UNITY_BUILD "Enable Unity (Jumbo) builds" OFF) + +if(YAZE_UNITY_BUILD) + message(STATUS "Unity builds enabled") + set(CMAKE_UNITY_BUILD ON) + set(CMAKE_UNITY_BUILD_BATCH_SIZE 8) +endif() + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/yaze_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h diff --git a/docs/analysis/overworld_implementation_analysis.md b/docs/analysis/overworld_implementation_analysis.md deleted file mode 100644 index 0231aaf8..00000000 --- a/docs/analysis/overworld_implementation_analysis.md +++ /dev/null @@ -1,36 +0,0 @@ -# ZScream vs. yaze Overworld Implementation Analysis - -## Executive Summary - -After conducting a thorough line-by-line analysis of both ZScream (C#) and yaze (C++) overworld implementations, we confirm that the yaze implementation is functionally equivalent and, in some areas, more robust. - -## Key Findings - -### ✅ **Confirmed Correct Implementations** - -#### 1. **Tile32 & Tile16 Expansion Detection** -Both implementations correctly detect expanded map data. yaze's approach is more robust as it checks for both the expansion flag and the ZSCustomOverworld ASM version, while ZScream primarily checks for one or the other. - -#### 2. **Entrance & Hole Coordinate Calculation** -The logic for calculating the x,y world coordinates for entrances and holes (including the `+ 0x400` offset for holes) is identical in both implementations, ensuring perfect compatibility. - -#### 3. **Data Loading (Exits, Items, Sprites)** -- **Exits**: Data is loaded from the same ROM addresses with equivalent byte ordering. -- **Items**: Both correctly detect the ASM version to decide whether to load items from the original or expanded address pointers. -- **Sprites**: Both correctly handle the three separate game states (rain, pre-Agahnim, post-Agahnim) when loading sprites. - -#### 4. **Map Decompression & Sizing** -- Both use equivalent decompression algorithms (`HyruleMagicDecompress` in yaze vs. `ALTTPDecompressOverworld` in ZScream). -- The logic for assigning map sizes (Small, Large, Wide) based on the ROM's size byte is identical. - -### ⚠️ **Key Differences Found** - -- **Entrance Expansion**: yaze has more robust detection for expanded entrance data, which ZScream appears to lack. -- **Error Handling**: yaze uses `absl::Status` for comprehensive error handling, whereas ZScream uses more basic checks. -- **Threading**: Both use multithreading for performance, with yaze using `std::async` and ZScream using background threads. - -### 🎯 **Conclusion** - -The analysis confirms that the yaze C++ overworld implementation correctly and successfully mirrors the ZScream C# logic across all critical functionality. Our integration tests and golden data extraction system provide comprehensive validation of this functional equivalence. - -**Final Assessment: The yaze overworld implementation is correct, robust, and maintains full compatibility with ZScream's overworld editing capabilities, while offering some improvements in expansion detection and error handling.** diff --git a/docs/api/z3ed-resources.yaml b/docs/api/z3ed-resources.yaml deleted file mode 100644 index ea474647..00000000 --- a/docs/api/z3ed-resources.yaml +++ /dev/null @@ -1,304 +0,0 @@ -# Auto-generated resource catalogue -version: "0.1.0" -last_updated: "2025-10-01" -resources: - - name: "rom" - description: "ROM validation, diffing, and snapshot helpers." - actions: - - name: "info" - synopsis: "z3ed rom info --rom " - stability: "stable" - args: - - flag: "--rom" - type: "path" - required: true - description: "Path to ROM file configured via global flag." - effects: - - "Reads ROM from disk and displays basic information (title, size, filename)." - returns: - - field: "title" - type: "string" - description: "ROM internal title from header." - - field: "size" - type: "integer" - description: "ROM file size in bytes." - - field: "filename" - type: "string" - description: "Full path to the ROM file." - - name: "validate" - synopsis: "z3ed rom validate --rom " - stability: "stable" - args: - - flag: "--rom" - type: "path" - required: true - description: "Path to ROM file configured via global flag." - effects: - - "Reads ROM from disk, verifies checksum, and reports header status." - returns: - - field: "report" - type: "object" - description: "Structured validation summary with checksum and header results." - - name: "diff" - synopsis: "z3ed rom diff " - stability: "beta" - args: - - flag: "rom_a" - type: "path" - required: true - description: "Reference ROM path." - - flag: "rom_b" - type: "path" - required: true - description: "Candidate ROM path." - effects: - - "Reads two ROM images, compares bytes, and streams differences to stdout." - returns: - - field: "differences" - type: "integer" - description: "Count of mismatched bytes between ROMs." - - name: "generate-golden" - synopsis: "z3ed rom generate-golden " - stability: "experimental" - args: - - flag: "rom_file" - type: "path" - required: true - description: "Source ROM to snapshot." - - flag: "golden_file" - type: "path" - required: true - description: "Output path for golden image." - effects: - - "Writes out exact ROM image for tooling baselines and diff workflows." - returns: - - field: "artifact" - type: "path" - description: "Absolute path to the generated golden image." - - name: "patch" - description: "Patch authoring and application commands covering BPS and Asar flows." - actions: - - name: "apply" - synopsis: "z3ed patch apply " - stability: "beta" - args: - - flag: "rom_file" - type: "path" - required: true - description: "Source ROM image that will receive the patch." - - flag: "bps_patch" - type: "path" - required: true - description: "BPS patch to apply to the ROM." - effects: - - "Loads ROM from disk, applies a BPS patch, and writes `patched.sfc`." - returns: - - field: "artifact" - type: "path" - description: "Absolute path to the patched ROM image produced on success." - - name: "apply-asar" - synopsis: "z3ed patch apply-asar " - stability: "prototype" - args: - - flag: "patch.asm" - type: "path" - required: true - description: "Assembly patch consumed by the bundled Asar runtime." - - flag: "--rom" - type: "path" - required: false - description: "ROM path supplied via global --rom flag." - effects: - - "Invokes Asar against the active ROM buffer and applies assembled changes." - returns: - - field: "log" - type: "string" - description: "Assembler diagnostics emitted during application." - - name: "create" - synopsis: "z3ed patch create --source --target --out " - stability: "experimental" - args: - - flag: "--source" - type: "path" - required: true - description: "Baseline ROM used when computing the patch." - - flag: "--target" - type: "path" - required: true - description: "Modified ROM to diff against the baseline." - - flag: "--out" - type: "path" - required: true - description: "Output path for the generated BPS patch." - effects: - - "Compares source and target images to synthesize a distributable BPS patch." - returns: - - field: "artifact" - type: "path" - description: "File system path to the generated patch." - - name: "palette" - description: "Palette manipulation commands covering export, import, and color editing." - actions: - - name: "export" - synopsis: "z3ed palette export --group --id --to " - stability: "experimental" - args: - - flag: "--group" - type: "integer" - required: true - description: "Palette group id (0-31)." - - flag: "--id" - type: "integer" - required: true - description: "Palette index inside the group." - - flag: "--to" - type: "path" - required: true - description: "Destination file path for binary export." - effects: - - "Reads ROM palette buffer and writes binary palette data to disk." - returns: [] - - name: "import" - synopsis: "z3ed palette import --group --id --from " - stability: "experimental" - args: - - flag: "--group" - type: "integer" - required: true - description: "Palette group id (0-31)." - - flag: "--id" - type: "integer" - required: true - description: "Palette index inside the group." - - flag: "--from" - type: "path" - required: true - description: "Source binary palette file." - effects: - - "Writes imported palette bytes into ROM buffer and marks project dirty." - returns: [] - - name: "overworld" - description: "Overworld tile inspection and manipulation commands." - actions: - - name: "get-tile" - synopsis: "z3ed overworld get-tile --map --x --y " - stability: "stable" - args: - - flag: "--map" - type: "integer" - required: true - description: "Overworld map identifier (0-63)." - - flag: "--x" - type: "integer" - required: true - description: "Tile x coordinate." - - flag: "--y" - type: "integer" - required: true - description: "Tile y coordinate." - effects: [] - returns: - - field: "tile" - type: "integer" - description: "Tile id located at the supplied coordinates." - - name: "set-tile" - synopsis: "z3ed overworld set-tile --map --x --y --tile " - stability: "experimental" - args: - - flag: "--map" - type: "integer" - required: true - description: "Overworld map identifier (0-63)." - - flag: "--x" - type: "integer" - required: true - description: "Tile x coordinate." - - flag: "--y" - type: "integer" - required: true - description: "Tile y coordinate." - - flag: "--tile" - type: "integer" - required: true - description: "Tile id to write." - effects: - - "Mutates overworld tile map and enqueues render invalidation." - returns: [] - - name: "dungeon" - description: "Dungeon room export and inspection utilities." - actions: - - name: "export" - synopsis: "z3ed dungeon export " - stability: "prototype" - args: - - flag: "room_id" - type: "integer" - required: true - description: "Dungeon room identifier to inspect." - effects: - - "Loads the active ROM via --rom and prints metadata for the requested room." - returns: - - field: "metadata" - type: "object" - description: "Structured room summary including blockset, spriteset, palette, and layout." - - name: "list-objects" - synopsis: "z3ed dungeon list-objects " - stability: "prototype" - args: - - flag: "room_id" - type: "integer" - required: true - description: "Dungeon room identifier whose objects should be listed." - effects: - - "Streams parsed dungeon object records for the requested room to stdout." - returns: - - field: "objects" - type: "array" - description: "Collection of tile object records with ids, coordinates, and layers." - - name: "agent" - description: "Agent workflow helpers including planning, diffing, listing, and schema discovery." - actions: - - name: "describe" - synopsis: "z3ed agent describe --resource " - stability: "prototype" - args: - - flag: "--resource" - type: "string" - required: false - description: "Optional resource name to filter results." - effects: [] - returns: - - field: "schema" - type: "object" - description: "JSON schema describing resource arguments and semantics." - - name: "list" - synopsis: "z3ed agent list" - stability: "prototype" - args: [] - effects: - - "reads" - returns: - - field: "proposals" - type: "array" - description: "List of all proposals with ID, status, prompt, and metadata." - - name: "diff" - synopsis: "z3ed agent diff [--proposal-id ]" - stability: "prototype" - args: - - flag: "--proposal-id" - type: "string" - required: false - description: "Optional proposal ID to view specific proposal. Defaults to latest pending." - effects: - - "reads" - - "readsproposal_registryList of all proposals with ID, status, prompt, and metadata.z3ed agent diff [--proposal-id ]Optional proposal ID to view specific proposal. Defaults to latest pending." - returns: - - field: "diff" - type: "string" - description: "Unified diff showing changes to ROM." - - field: "log" - type: "string" - description: "Execution log of commands run." - - field: "metadata" - type: "object" - description: "Proposal metadata including status and timestamps." diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6837d017..ee6dc00b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,39 +80,326 @@ if(YAZE_BUILD_APP OR YAZE_BUILD_Z3ED) include(cli/agent.cmake) endif() -if(YAZE_USE_MODULAR_BUILD) message(STATUS "Using modular build system") if(YAZE_BUILD_LIB OR YAZE_BUILD_APP OR YAZE_BUILD_Z3ED) - include(app/gfx/gfx.cmake) - include(app/gui/gui.cmake) - include(app/zelda3/zelda3.cmake) - include(app/core/core.cmake) - include(app/editor/editor.cmake) - include(util/util.cmake) + include(app/core/core_library.cmake) include(app/gfx/gfx_library.cmake) include(app/gui/gui_library.cmake) include(app/zelda3/zelda3_library.cmake) + include(app/editor/editor_library.cmake) if(YAZE_BUILD_EMU) include(app/emu/emu_library.cmake) endif() - - include(app/core/core_library.cmake) - include(app/editor/editor_library.cmake) endif() -else() - message(STATUS "Using traditional monolithic build system") -endif() if (YAZE_BUILD_APP) - include(app/app.cmake) + if (APPLE) + add_executable( + yaze + MACOSX_BUNDLE + app/main.cc + # Bundled Resources + ${YAZE_RESOURCE_FILES} + ) + + set(ICON_FILE "${CMAKE_SOURCE_DIR}/assets/yaze.icns") + target_sources(yaze PRIVATE ${ICON_FILE}) + set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + + set_target_properties(yaze PROPERTIES + MACOSX_BUNDLE_ICON_FILE "yaze.icns" + MACOSX_BUNDLE_BUNDLE_NAME "Yaze" + MACOSX_BUNDLE_EXECUTABLE_NAME "yaze" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.scawful.yaze" + MACOSX_BUNDLE_INFO_STRING "Yet Another Zelda3 Editor" + MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}" + MACOSX_BUNDLE_COPYRIGHT "Copyright © 2024 scawful. All rights reserved." + ) + else() + add_executable( + yaze + app/main.cc + ) + + if(WIN32 OR UNIX) + target_sources(yaze PRIVATE ${YAZE_RESOURCE_FILES}) + + if(WIN32) + foreach(ASSET_FILE ${YAZE_RESOURCE_FILES}) + file(RELATIVE_PATH ASSET_REL_PATH "${CMAKE_SOURCE_DIR}/assets" ${ASSET_FILE}) + get_filename_component(ASSET_DIR ${ASSET_REL_PATH} DIRECTORY) + + set_source_files_properties(${ASSET_FILE} + PROPERTIES + VS_DEPLOYMENT_CONTENT 1 + VS_DEPLOYMENT_LOCATION "assets/${ASSET_DIR}" + ) + endforeach() + endif() + endif() + endif() + + target_include_directories( + yaze PUBLIC + ${CMAKE_SOURCE_DIR}/src/lib/ + ${CMAKE_SOURCE_DIR}/src/app/ + ${CMAKE_SOURCE_DIR}/src/lib/asar/src + ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar + ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c + ${CMAKE_SOURCE_DIR}/incl/ + ${CMAKE_SOURCE_DIR}/src/ + ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine + ${CMAKE_SOURCE_DIR}/third_party/httplib + ${SDL2_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${PROJECT_BINARY_DIR} + ) + + target_sources(yaze PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h) + + set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h + PROPERTIES GENERATED TRUE + ) + + source_group(TREE ${CMAKE_CURRENT_BINARY_DIR} + FILES ${CMAKE_CURRENT_BINARY_DIR}/yaze_config.h) + + if(PNG_FOUND) + target_include_directories(yaze PUBLIC ${PNG_INCLUDE_DIRS}) + endif() + + if(YAZE_HAS_NFD) + target_link_libraries(yaze PRIVATE nfd) + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_NFD=1) + else() + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_NFD=0) + endif() + + if(YAZE_USE_MODULAR_BUILD) + set(_yaze_modular_links yaze_editor) + + if(TARGET yaze_agent) + list(APPEND _yaze_modular_links yaze_agent) + endif() + + if(YAZE_BUILD_EMU AND TARGET yaze_emulator) + list(APPEND _yaze_modular_links yaze_emulator) + endif() + + target_link_libraries(yaze PRIVATE ${_yaze_modular_links}) + else() + target_link_libraries(yaze PRIVATE yaze_core) + endif() + + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_POLICY_FRAMEWORK=1) + + if(WIN32) + if(MSVC) + target_link_options(yaze PRIVATE + /STACK:8388608 + /SUBSYSTEM:WINDOWS + /ENTRY:mainCRTStartup + ) + message(STATUS "Configuring yaze as Windows GUI application with main() entry point") + elseif(MINGW OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_options(yaze PRIVATE + -Wl,--stack,8388608 + -Wl,--subsystem,windows + -Wl,-emain + ) + message(STATUS "Configuring yaze as Windows GUI application with main() entry point (MinGW)") + endif() + endif() + + if(YAZE_ENABLE_UI_TESTS) + if(TARGET ImGuiTestEngine) + target_include_directories(yaze PUBLIC ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine) + target_link_libraries(yaze PUBLIC ImGuiTestEngine) + target_compile_definitions(yaze PRIVATE + YAZE_ENABLE_IMGUI_TEST_ENGINE=1 + ${IMGUI_TEST_ENGINE_DEFINITIONS}) + else() + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=0) + endif() + else() + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=0) + endif() + + if(YAZE_BUILD_TESTS AND TARGET gtest) + target_link_libraries(yaze PRIVATE gtest) + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_GTEST=1) + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_TESTING=1) + else() + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_GTEST=0) + target_compile_definitions(yaze PRIVATE YAZE_ENABLE_TESTING=0) + endif() + + if(PNG_FOUND) + target_link_libraries(yaze PUBLIC ${PNG_LIBRARIES}) + endif() + + if (APPLE) + target_link_libraries(yaze PUBLIC ${COCOA_LIBRARY}) + endif() + + if(NOT APPLE) + add_custom_command(TARGET yaze POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + $/assets/font + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/assets/font + $/assets/font + COMMENT "Copying font assets" + ) + + add_custom_command(TARGET yaze POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + $/assets/themes + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/assets/themes + $/assets/themes + COMMENT "Copying theme assets" + ) + + if(EXISTS ${CMAKE_SOURCE_DIR}/assets/layouts) + add_custom_command(TARGET yaze POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + $/assets/layouts + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/assets/layouts + $/assets/layouts + COMMENT "Copying layout assets" + ) + endif() + + if(EXISTS ${CMAKE_SOURCE_DIR}/assets/lib) + add_custom_command(TARGET yaze POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + $/assets/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/assets/lib + $/assets/lib + COMMENT "Copying library assets" + ) + endif() + endif() + + target_sources(yaze PRIVATE + ${CMAKE_SOURCE_DIR}/src/app/core/widget_state_capture.cc + ${CMAKE_SOURCE_DIR}/src/app/core/widget_state_capture.h) + + if(YAZE_WITH_GRPC) + message(STATUS "Adding gRPC ImGuiTestHarness to yaze target") + + target_include_directories(yaze PRIVATE + ${CMAKE_SOURCE_DIR}/third_party/json/include) + target_compile_definitions(yaze PRIVATE YAZE_WITH_JSON) + + if(NOT YAZE_USE_MODULAR_BUILD) + target_add_protobuf(yaze + ${CMAKE_SOURCE_DIR}/src/app/core/proto/imgui_test_harness.proto) + + target_sources(yaze PRIVATE + ${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.cc + ${CMAKE_SOURCE_DIR}/src/app/core/service/imgui_test_harness_service.h + ${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.cc + ${CMAKE_SOURCE_DIR}/src/app/core/service/screenshot_utils.h + ${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.cc + ${CMAKE_SOURCE_DIR}/src/app/core/service/widget_discovery_service.h + ${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.cc + ${CMAKE_SOURCE_DIR}/src/app/core/testing/test_recorder.h + ${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.cc + ${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.h) + endif() + + target_link_libraries(yaze PRIVATE + grpc++ + grpc++_reflection + libprotobuf) + + message(STATUS "✓ gRPC ImGuiTestHarness integrated") + message(STATUS "✓ AI Agent services integrated into yaze GUI") + endif() endif() -# Conditionally build the emulator, but not when gRPC is enabled for app-only testing -# Conditionally build the emulator, but not when gRPC is enabled for app-only testing + if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC) - include(app/emu/emu.cmake) + if (NOT YAZE_MINIMAL_BUILD AND APPLE) + add_executable( + yaze_emu + MACOSX_BUNDLE + app/main.cc + app/rom.cc + app/core/platform/app_delegate.mm + ${YAZE_APP_EMU_SRC} + ${YAZE_APP_CORE_SRC} + ${YAZE_APP_EDITOR_SRC} + ${YAZE_APP_GFX_SRC} + ${YAZE_APP_ZELDA3_SRC} + ${YAZE_UTIL_SRC} + ${YAZE_GUI_SRC} + ${IMGUI_SRC} + cli/service/planning/proposal_registry.cc + cli/service/rom/rom_sandbox_manager.cc + ) + target_link_libraries(yaze_emu PUBLIC ${COCOA_LIBRARY}) + elseif(NOT YAZE_MINIMAL_BUILD) + add_executable( + yaze_emu + app/rom.cc + app/emu/emu.cc + ${YAZE_APP_EMU_SRC} + ${YAZE_APP_CORE_SRC} + ${YAZE_APP_EDITOR_SRC} + ${YAZE_APP_GFX_SRC} + ${YAZE_APP_ZELDA3_SRC} + ${YAZE_UTIL_SRC} + ${YAZE_GUI_SRC} + ${IMGUI_SRC} + cli/service/planning/proposal_registry.cc + cli/service/rom/rom_sandbox_manager.cc + ) + endif() + + if(NOT YAZE_MINIMAL_BUILD) + target_include_directories( + yaze_emu PUBLIC + ${CMAKE_SOURCE_DIR}/src/lib/ + ${CMAKE_SOURCE_DIR}/src/app/ + ${CMAKE_SOURCE_DIR}/src/lib/asar/src + ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar + ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c + ${CMAKE_SOURCE_DIR}/incl/ + ${CMAKE_SOURCE_DIR}/src/ + ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine + ${PNG_INCLUDE_DIRS} + ${SDL2_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${PROJECT_BINARY_DIR} + ) + + target_link_libraries( + yaze_emu PUBLIC + ${ABSL_TARGETS} + ${SDL_TARGETS} + ${PNG_LIBRARIES} + ${CMAKE_DL_LIBS} + ImGui + asar-static + ) + + if(YAZE_ENABLE_UI_TESTS) + target_link_libraries(yaze_emu PUBLIC ImGuiTestEngine) + target_compile_definitions(yaze_emu PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=1) + else() + target_compile_definitions(yaze_emu PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=0) + endif() + endif() endif() if (YAZE_BUILD_Z3ED) include(cli/z3ed.cmake) diff --git a/src/app/app.cmake b/src/app/app.cmake index a9cce7d3..6e7f3fe9 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -1,8 +1,8 @@ -include(app/core/core.cmake) -include(app/editor/editor.cmake) -include(app/gfx/gfx.cmake) -include(app/gui/gui.cmake) -include(app/zelda3/zelda3.cmake) +include(app/core/core_library.cmake) +include(app/editor/editor_library.cmake) +include(app/gfx/gfx_library.cmake) +include(app/gui/gui_library.cmake) +include(app/zelda3/zelda3_library.cmake) if (APPLE) add_executable( diff --git a/src/app/core/core.cmake b/src/app/core/core.cmake deleted file mode 100644 index 06873872..00000000 --- a/src/app/core/core.cmake +++ /dev/null @@ -1,32 +0,0 @@ -set( - YAZE_APP_CORE_SRC - app/core/controller.cc - app/emu/emulator.cc - app/core/project.cc - app/core/window.cc - app/core/asar_wrapper.cc - app/core/widget_state_capture.cc -) - -if (WIN32 OR MINGW OR (UNIX AND NOT APPLE)) - list(APPEND YAZE_APP_CORE_SRC - app/core/platform/font_loader.cc - app/core/platform/file_dialog.cc - ) -endif() - -if(APPLE) - list(APPEND YAZE_APP_CORE_SRC - app/core/platform/file_dialog.cc - app/core/platform/file_dialog.mm - app/core/platform/app_delegate.mm - app/core/platform/font_loader.cc - app/core/platform/font_loader.mm - ) - - find_library(COCOA_LIBRARY Cocoa) - if(NOT COCOA_LIBRARY) - message(FATAL_ERROR "Cocoa not found") - endif() - set(CMAKE_EXE_LINKER_FLAGS "-framework ServiceManagement -framework Foundation -framework Cocoa") -endif() diff --git a/src/app/core/core_library.cmake b/src/app/core/core_library.cmake index 7ea99264..d87fe78d 100644 --- a/src/app/core/core_library.cmake +++ b/src/app/core/core_library.cmake @@ -1,3 +1,36 @@ +set( + YAZE_APP_CORE_SRC + app/core/controller.cc + app/emu/emulator.cc + app/core/project.cc + app/core/window.cc + app/core/asar_wrapper.cc + app/core/widget_state_capture.cc +) + +if (WIN32 OR MINGW OR (UNIX AND NOT APPLE)) + list(APPEND YAZE_APP_CORE_SRC + app/core/platform/font_loader.cc + app/core/platform/file_dialog.cc + ) +endif() + +if(APPLE) + list(APPEND YAZE_APP_CORE_SRC + app/core/platform/file_dialog.cc + app/core/platform/file_dialog.mm + app/core/platform/app_delegate.mm + app/core/platform/font_loader.cc + app/core/platform/font_loader.mm + ) + + find_library(COCOA_LIBRARY Cocoa) + if(NOT COCOA_LIBRARY) + message(FATAL_ERROR "Cocoa not found") + endif() + set(CMAKE_EXE_LINKER_FLAGS "-framework ServiceManagement -framework Foundation -framework Cocoa") +endif() + # ============================================================================== # Yaze Core Library # ============================================================================== diff --git a/src/app/editor/editor.cmake b/src/app/editor/editor.cmake deleted file mode 100644 index 48dd4a69..00000000 --- a/src/app/editor/editor.cmake +++ /dev/null @@ -1,44 +0,0 @@ -set( - YAZE_APP_EDITOR_SRC - app/editor/editor_manager.cc - app/editor/dungeon/dungeon_editor.cc - app/editor/dungeon/dungeon_editor_v2.cc - app/editor/dungeon/dungeon_room_selector.cc - app/editor/dungeon/dungeon_canvas_viewer.cc - app/editor/dungeon/dungeon_object_selector.cc - app/editor/dungeon/dungeon_toolset.cc - app/editor/dungeon/dungeon_object_interaction.cc - app/editor/dungeon/dungeon_renderer.cc - app/editor/dungeon/dungeon_room_loader.cc - app/editor/dungeon/dungeon_usage_tracker.cc - app/editor/overworld/overworld_editor.cc - app/editor/overworld/overworld_editor_manager.cc - app/editor/overworld/scratch_space.cc - app/editor/sprite/sprite_editor.cc - app/editor/music/music_editor.cc - app/editor/message/message_editor.cc - app/editor/message/message_data.cc - app/editor/message/message_preview.cc - app/editor/code/assembly_editor.cc - app/editor/graphics/screen_editor.cc - app/editor/graphics/graphics_editor.cc - app/editor/graphics/palette_editor.cc - app/editor/overworld/tile16_editor.cc - app/editor/overworld/map_properties.cc - app/editor/graphics/gfx_group_editor.cc - app/editor/overworld/entity.cc - app/editor/system/settings_editor.cc - app/editor/system/command_manager.cc - app/editor/system/extension_manager.cc - app/editor/system/shortcut_manager.cc - app/editor/system/popup_manager.cc - app/editor/system/agent_chat_history_codec.cc - app/editor/system/proposal_drawer.cc -) - -if(YAZE_WITH_GRPC) - list(APPEND YAZE_APP_EDITOR_SRC - app/editor/system/agent_chat_widget.cc - app/editor/system/agent_collaboration_coordinator.cc - ) -endif() \ No newline at end of file diff --git a/src/app/editor/editor_library.cmake b/src/app/editor/editor_library.cmake index f6c273eb..4caed2d4 100644 --- a/src/app/editor/editor_library.cmake +++ b/src/app/editor/editor_library.cmake @@ -1,3 +1,48 @@ +set( + YAZE_APP_EDITOR_SRC + app/editor/editor_manager.cc + app/editor/dungeon/dungeon_editor.cc + app/editor/dungeon/dungeon_editor_v2.cc + app/editor/dungeon/dungeon_room_selector.cc + app/editor/dungeon/dungeon_canvas_viewer.cc + app/editor/dungeon/dungeon_object_selector.cc + app/editor/dungeon/dungeon_toolset.cc + app/editor/dungeon/dungeon_object_interaction.cc + app/editor/dungeon/dungeon_renderer.cc + app/editor/dungeon/dungeon_room_loader.cc + app/editor/dungeon/dungeon_usage_tracker.cc + app/editor/overworld/overworld_editor.cc + app/editor/overworld/overworld_editor_manager.cc + app/editor/overworld/scratch_space.cc + app/editor/sprite/sprite_editor.cc + app/editor/music/music_editor.cc + app/editor/message/message_editor.cc + app/editor/message/message_data.cc + app/editor/message/message_preview.cc + app/editor/code/assembly_editor.cc + app/editor/graphics/screen_editor.cc + app/editor/graphics/graphics_editor.cc + app/editor/graphics/palette_editor.cc + app/editor/overworld/tile16_editor.cc + app/editor/overworld/map_properties.cc + app/editor/graphics/gfx_group_editor.cc + app/editor/overworld/entity.cc + app/editor/system/settings_editor.cc + app/editor/system/command_manager.cc + app/editor/system/extension_manager.cc + app/editor/system/shortcut_manager.cc + app/editor/system/popup_manager.cc + app/editor/system/agent_chat_history_codec.cc + app/editor/system/proposal_drawer.cc +) + +if(YAZE_WITH_GRPC) + list(APPEND YAZE_APP_EDITOR_SRC + app/editor/system/agent_chat_widget.cc + app/editor/system/agent_collaboration_coordinator.cc + ) +endif() + # ============================================================================== # Yaze Editor Library # ============================================================================== @@ -18,6 +63,15 @@ add_library(yaze_editor STATIC ${YAZE_APP_EDITOR_SRC}) +target_precompile_headers(yaze_editor PRIVATE + + + + + + +) + target_include_directories(yaze_editor PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/lib diff --git a/src/app/editor/editor_manager.cc b/src/app/editor/editor_manager.cc index 7272447d..db136a0a 100644 --- a/src/app/editor/editor_manager.cc +++ b/src/app/editor/editor_manager.cc @@ -4,6 +4,8 @@ #include #include +#define IMGUI_DEFINE_MATH_OPERATORS + #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" diff --git a/src/app/editor/editor_manager.h b/src/app/editor/editor_manager.h index afde45a8..ccd96249 100644 --- a/src/app/editor/editor_manager.h +++ b/src/app/editor/editor_manager.h @@ -3,6 +3,8 @@ #define IMGUI_DEFINE_MATH_OPERATORS +#include "imgui/imgui.h" + #include #include diff --git a/src/app/gfx/gfx.cmake b/src/app/gfx/gfx.cmake deleted file mode 100644 index 3799c47c..00000000 --- a/src/app/gfx/gfx.cmake +++ /dev/null @@ -1,18 +0,0 @@ -set( - YAZE_APP_GFX_SRC - app/gfx/arena.cc - app/gfx/atlas_renderer.cc - app/gfx/background_buffer.cc - app/gfx/bitmap.cc - app/gfx/compression.cc - app/gfx/memory_pool.cc - app/gfx/performance_dashboard.cc - app/gfx/performance_profiler.cc - app/gfx/scad_format.cc - app/gfx/snes_palette.cc - app/gfx/snes_tile.cc - app/gfx/snes_color.cc - app/gfx/tilemap.cc - app/gfx/graphics_optimizer.cc - app/gfx/bpp_format_manager.cc -) \ No newline at end of file diff --git a/src/app/gfx/gfx_library.cmake b/src/app/gfx/gfx_library.cmake index 9201215d..16906679 100644 --- a/src/app/gfx/gfx_library.cmake +++ b/src/app/gfx/gfx_library.cmake @@ -1,3 +1,22 @@ +set( + YAZE_APP_GFX_SRC + app/gfx/arena.cc + app/gfx/atlas_renderer.cc + app/gfx/background_buffer.cc + app/gfx/bitmap.cc + app/gfx/compression.cc + app/gfx/memory_pool.cc + app/gfx/performance_dashboard.cc + app/gfx/performance_profiler.cc + app/gfx/scad_format.cc + app/gfx/snes_palette.cc + app/gfx/snes_tile.cc + app/gfx/snes_color.cc + app/gfx/tilemap.cc + app/gfx/graphics_optimizer.cc + app/gfx/bpp_format_manager.cc +) + # ============================================================================== # Yaze Graphics Library # ============================================================================== @@ -14,6 +33,12 @@ add_library(yaze_gfx STATIC ${YAZE_APP_GFX_SRC}) +target_precompile_headers(yaze_gfx PRIVATE + + + +) + target_include_directories(yaze_gfx PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/lib diff --git a/src/app/gui/gui.cmake b/src/app/gui/gui.cmake deleted file mode 100644 index 1edadb2f..00000000 --- a/src/app/gui/gui.cmake +++ /dev/null @@ -1,23 +0,0 @@ -set( - YAZE_GUI_SRC - app/gui/modules/asset_browser.cc - app/gui/modules/text_editor.cc - app/gui/widgets/agent_chat_widget.cc - app/gui/canvas.cc - app/gui/canvas_utils.cc - app/gui/enhanced_palette_editor.cc - app/gui/input.cc - app/gui/style.cc - app/gui/color.cc - app/gui/theme_manager.cc - app/gui/background_renderer.cc - app/gui/bpp_format_ui.cc - app/gui/widget_id_registry.cc - app/gui/widget_auto_register.cc - # Canvas system components - app/gui/canvas/canvas_modals.cc - app/gui/canvas/canvas_context_menu.cc - app/gui/canvas/canvas_usage_tracker.cc - app/gui/canvas/canvas_performance_integration.cc - app/gui/canvas/canvas_interaction_handler.cc -) diff --git a/src/app/gui/gui_library.cmake b/src/app/gui/gui_library.cmake index 20d7c83a..5643fca6 100644 --- a/src/app/gui/gui_library.cmake +++ b/src/app/gui/gui_library.cmake @@ -1,3 +1,27 @@ +set( + YAZE_GUI_SRC + app/gui/modules/asset_browser.cc + app/gui/modules/text_editor.cc + app/gui/widgets/agent_chat_widget.cc + app/gui/canvas.cc + app/gui/canvas_utils.cc + app/gui/enhanced_palette_editor.cc + app/gui/input.cc + app/gui/style.cc + app/gui/color.cc + app/gui/theme_manager.cc + app/gui/background_renderer.cc + app/gui/bpp_format_ui.cc + app/gui/widget_id_registry.cc + app/gui/widget_auto_register.cc + # Canvas system components + app/gui/canvas/canvas_modals.cc + app/gui/canvas/canvas_context_menu.cc + app/gui/canvas/canvas_usage_tracker.cc + app/gui/canvas/canvas_performance_integration.cc + app/gui/canvas/canvas_interaction_handler.cc +) + # ============================================================================== # Yaze GUI Library # ============================================================================== @@ -14,6 +38,15 @@ add_library(yaze_gui STATIC ${YAZE_GUI_SRC}) +target_precompile_headers(yaze_gui PRIVATE + + + + + + +) + target_include_directories(yaze_gui PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/lib diff --git a/src/app/test/test.cmake b/src/app/test/test.cmake index b1e8b441..b0cb77e5 100644 --- a/src/app/test/test.cmake +++ b/src/app/test/test.cmake @@ -12,14 +12,20 @@ add_library(yaze_test_support STATIC app/test/test_manager.cc) +target_precompile_headers(yaze_test_support PRIVATE + + + + + +) + target_include_directories(yaze_test_support PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl ${PROJECT_BINARY_DIR} ) -# The test support library needs to link against all the major app libraries -# to be able to test them. target_link_libraries(yaze_test_support PUBLIC yaze_editor yaze_core_lib diff --git a/src/app/zelda3/zelda3.cmake b/src/app/zelda3/zelda3.cmake deleted file mode 100644 index a0581d8d..00000000 --- a/src/app/zelda3/zelda3.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set( - YAZE_APP_ZELDA3_SRC - app/zelda3/hyrule_magic.cc - app/zelda3/zelda3_labels.cc - app/zelda3/overworld/overworld_map.cc - app/zelda3/overworld/overworld.cc - app/zelda3/screen/inventory.cc - app/zelda3/screen/title_screen.cc - app/zelda3/screen/dungeon_map.cc - app/zelda3/sprite/sprite.cc - app/zelda3/sprite/sprite_builder.cc - app/zelda3/music/tracker.cc - app/zelda3/dungeon/room.cc - app/zelda3/dungeon/room_object.cc - app/zelda3/dungeon/object_parser.cc - app/zelda3/dungeon/object_renderer.cc - app/zelda3/dungeon/room_layout.cc - app/zelda3/dungeon/room_diagnostic.cc - app/zelda3/dungeon/room_visual_diagnostic.cc - app/zelda3/dungeon/dungeon_editor_system.cc - app/zelda3/dungeon/dungeon_object_editor.cc -) \ No newline at end of file diff --git a/src/app/zelda3/zelda3_library.cmake b/src/app/zelda3/zelda3_library.cmake index b0f64aa3..6789e51d 100644 --- a/src/app/zelda3/zelda3_library.cmake +++ b/src/app/zelda3/zelda3_library.cmake @@ -1,3 +1,26 @@ +set( + YAZE_APP_ZELDA3_SRC + app/zelda3/hyrule_magic.cc + app/zelda3/zelda3_labels.cc + app/zelda3/overworld/overworld_map.cc + app/zelda3/overworld/overworld.cc + app/zelda3/screen/inventory.cc + app/zelda3/screen/title_screen.cc + app/zelda3/screen/dungeon_map.cc + app/zelda3/sprite/sprite.cc + app/zelda3/sprite/sprite_builder.cc + app/zelda3/music/tracker.cc + app/zelda3/dungeon/room.cc + app/zelda3/dungeon/room_object.cc + app/zelda3/dungeon/object_parser.cc + app/zelda3/dungeon/object_renderer.cc + app/zelda3/dungeon/room_layout.cc + app/zelda3/dungeon/room_diagnostic.cc + app/zelda3/dungeon/room_visual_diagnostic.cc + app/zelda3/dungeon/dungeon_editor_system.cc + app/zelda3/dungeon/dungeon_object_editor.cc +) + # ============================================================================== # Yaze Zelda3 Library # ============================================================================== @@ -13,6 +36,15 @@ add_library(yaze_zelda3 STATIC ${YAZE_APP_ZELDA3_SRC}) +target_precompile_headers(yaze_zelda3 PRIVATE + + + + + + +) + target_include_directories(yaze_zelda3 PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/lib diff --git a/src/util/util.cmake b/src/util/util.cmake index 522b0470..2fdabb7d 100644 --- a/src/util/util.cmake +++ b/src/util/util.cmake @@ -19,6 +19,12 @@ set(YAZE_UTIL_SRC add_library(yaze_util STATIC ${YAZE_UTIL_SRC}) +target_precompile_headers(yaze_util PRIVATE + + + +) + target_include_directories(yaze_util PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl diff --git a/src/yaze_config.h.in b/src/yaze_config.h.in index 511af1a4..55c0bd61 100644 --- a/src/yaze_config.h.in +++ b/src/yaze_config.h.in @@ -2,3 +2,9 @@ #define YAZE_VERSION_MAJOR @yaze_VERSION_MAJOR@ #define YAZE_VERSION_MINOR @yaze_VERSION_MINOR@ #define YAZE_VERSION_PATCH @yaze_VERSION_PATCH@ + +#ifdef __cplusplus +#ifndef IMGUI_DEFINE_MATH_OPERATORS +#define IMGUI_DEFINE_MATH_OPERATORS +#endif +#endif diff --git a/test/integration/editor/editor_integration_test.h b/test/integration/editor/editor_integration_test.h index b06aaa4e..68979107 100644 --- a/test/integration/editor/editor_integration_test.h +++ b/test/integration/editor/editor_integration_test.h @@ -3,6 +3,7 @@ #define IMGUI_DEFINE_MATH_OPERATORS +#include "imgui/imgui.h" #include "app/editor/editor.h" #include "app/rom.h" #include "app/core/controller.h"