diff --git a/BUILDING.md b/BUILDING.md index e1dfea4..8f88785 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -7,6 +7,12 @@ These steps cover: decompressing the ROM, running the recompiler and finally bui ## 1. Building the Bomberman 64 decompilation You will need a decompressed ROM. Build the project at https://github.com/Bomberhackers/bm64 which will generate a decompressed ROM from an existing locally dumped BM64 US ROM. +Place the decompressed ROM in the repository root as: + +```bash +bm64.decomp.us.z64 +``` + ## 2. Clone the Bomberman 64 Recompiled Repository This project makes use of submodules so you will need to clone the repository with the `--recurse-submodules` flag. @@ -26,6 +32,16 @@ For Linux the instructions for Ubuntu are provided, but you can find the equival sudo apt-get install cmake ninja libsdl2-dev libgtk-3-dev lld llvm clang-15 ``` +### macOS +For macOS, install dependencies with Homebrew: + +```bash +brew install cmake ninja sdl2 freetype llvm lld +python3 -m pip install --user macholib +``` + +`macholib` is required by the macOS linker wrapper used by this project. + ### Windows You will need to install [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/). In the setup process you'll need to select the following options and tools for installation: @@ -33,7 +49,7 @@ In the setup process you'll need to select the following options and tools for i - C++ Clang Compiler for Windows - C++ CMake tools for Windows -The other tool necessary will be `make` which can be installe via [Chocolatey](https://chocolatey.org/): +The other tool necessary will be `make` which can be installed via [Chocolatey](https://chocolatey.org/): ```bash choco install make ``` @@ -58,12 +74,14 @@ If you prefer the command line or you're on a Unix platform you can build the pr ```bash cmake -S . -B build-cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -G Ninja -DCMAKE_BUILD_TYPE=Release # or Debug if you want to debug -cmake --build build-cmake --target BM64Recompiled -j$(nproc) --config Release # or Debug +cmake --build build-cmake --target BM64Recompiled --config Release --parallel # or Debug ``` ## 6. Success -VoilĂ ! You should now have a `BM64Recompiled` executable in the build directory! If you used Visual Studio this will be `out/build/x64-[Configuration]` and if you used the provided CMake commands then this will be `build-cmake`. You will need to run the executable out of the root folder of this project or copy the assets folder to the build folder to run it. +VoilĂ ! You should now have a BM64Recompiled executable in the build directory! If you used Visual Studio this will be `out/build/x64-[Configuration]` and if you used the provided CMake commands then this will be `build-cmake`. + +On macOS, the output is `build-cmake/BM64Recompiled.app`. -> [!IMPORTANT] +> [!IMPORTANT] > In the game itself, you should be using a standard ROM, not the decompressed one. diff --git a/CMakeLists.txt b/CMakeLists.txt index c104f86..188c37d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,20 @@ endif() if (APPLE) enable_language(OBJC OBJCXX) + + execute_process( + COMMAND /usr/bin/python3 -c "import macholib" + RESULT_VARIABLE MACHOLIB_IMPORT_RESULT + OUTPUT_QUIET + ERROR_QUIET + ) + if (NOT MACHOLIB_IMPORT_RESULT EQUAL 0) + message(WARNING + "Python package 'macholib' was not found for /usr/bin/python3. " + "The custom macOS linker wrapper at .github/macos/ld64 will fail at link time without it. " + "Install it with: python3 -m pip install --user macholib" + ) + endif() endif() if (CMAKE_SYSTEM_NAME MATCHES "Linux") @@ -61,6 +75,29 @@ SET(RMLUI_TESTS_ENABLED OFF CACHE BOOL "" FORCE) add_subdirectory(${CMAKE_SOURCE_DIR}/lib/RmlUi) target_compile_definitions(rmlui_core PRIVATE LUNASVG_BUILD_STATIC) +# Apply controller pak patch to N64ModernRuntime if not already applied. +# Source: https://github.com/gcsmith/N64ModernRuntime/tree/controller_pak +execute_process( + COMMAND git apply --check ${CMAKE_SOURCE_DIR}/patches/n64modernruntime-controller-pak.patch + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime + RESULT_VARIABLE PATCH_CHECK_RESULT + OUTPUT_QUIET + ERROR_QUIET +) +if (PATCH_CHECK_RESULT EQUAL 0) + execute_process( + COMMAND git apply ${CMAKE_SOURCE_DIR}/patches/n64modernruntime-controller-pak.patch + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime + RESULT_VARIABLE PATCH_APPLY_RESULT + ) + if (NOT PATCH_APPLY_RESULT EQUAL 0) + message(FATAL_ERROR "Failed to apply N64ModernRuntime controller pak patch") + endif() + message(STATUS "Applied N64ModernRuntime controller pak patch") +else() + message(STATUS "N64ModernRuntime controller pak patch already applied (or conflicts exist)") +endif() + add_subdirectory(${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime) target_include_directories(rt64 PRIVATE ${CMAKE_BINARY_DIR}/rt64/src) @@ -113,13 +150,44 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c PROP # Build patches elf if(NOT DEFINED PATCHES_C_COMPILER) - set(PATCHES_C_COMPILER clang) + if (APPLE) + if (EXISTS "/opt/local/bin/clang-mp-18") + set(PATCHES_C_COMPILER "/opt/local/bin/clang-mp-18") + elseif (EXISTS "/opt/homebrew/opt/llvm/bin/clang") + set(PATCHES_C_COMPILER "/opt/homebrew/opt/llvm/bin/clang") + elseif (EXISTS "/usr/local/opt/llvm/bin/clang") + set(PATCHES_C_COMPILER "/usr/local/opt/llvm/bin/clang") + else() + set(PATCHES_C_COMPILER clang) + endif() + else() + set(PATCHES_C_COMPILER clang) + endif() endif() if(NOT DEFINED PATCHES_LD) - set(PATCHES_LD ld.lld) + if (APPLE) + if (EXISTS "/opt/local/bin/ld.lld-mp-18") + set(PATCHES_LD "/opt/local/bin/ld.lld-mp-18") + elseif (EXISTS "/opt/homebrew/opt/lld/bin/ld.lld") + set(PATCHES_LD "/opt/homebrew/opt/lld/bin/ld.lld") + elseif (EXISTS "/opt/homebrew/opt/llvm/bin/ld.lld") + set(PATCHES_LD "/opt/homebrew/opt/llvm/bin/ld.lld") + elseif (EXISTS "/usr/local/opt/lld/bin/ld.lld") + set(PATCHES_LD "/usr/local/opt/lld/bin/ld.lld") + elseif (EXISTS "/usr/local/opt/llvm/bin/ld.lld") + set(PATCHES_LD "/usr/local/opt/llvm/bin/ld.lld") + else() + set(PATCHES_LD ld.lld) + endif() + else() + set(PATCHES_LD ld.lld) + endif() endif() +message(STATUS "PATCHES_C_COMPILER = ${PATCHES_C_COMPILER}") +message(STATUS "PATCHES_LD = ${PATCHES_LD}") + add_custom_target(PatchesBin COMMAND ${CMAKE_COMMAND} -E env CC=${PATCHES_C_COMPILER} LD=${PATCHES_LD} make WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/patches diff --git a/assets/config_menu/controls.rml b/assets/config_menu/controls.rml index 862579d..d7ae5f3 100644 --- a/assets/config_menu/controls.rml +++ b/assets/config_menu/controls.rml @@ -81,6 +81,26 @@
+ +