Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-In OTR Extraction #22

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
78 changes: 52 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use")

# Add a custom module path to locate additional CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(YAML_CPP_STATIC_DEFINE ON)
add_compile_definitions(YAML_CPP_STATIC_DEFINE)

if (WIN32)
include(cmake/automate-vcpkg.cmake)
set(VCPKG_TRIPLET x64-windows-static)
set(VCPKG_TARGET_TRIPLET x64-windows-static)
vcpkg_bootstrap()
vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 glew glfw3 nlohmann-json tinyxml2 spdlog)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/config.yml)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/config.yml" "${CMAKE_BINARY_DIR}/config.yml")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/assets/" "${CMAKE_BINARY_DIR}/assets/")
endif()
endif()

if (MSVC)
Expand Down Expand Up @@ -233,8 +239,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
">"
"INCLUDE_GAME_PRINTF;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
"_UNICODE;"
"_CRT_SECURE_NO_WARNINGS;"
"_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;"
)
Expand All @@ -252,11 +257,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
"INCLUDE_GAME_PRINTF;"
"WIN32;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
"_UNICODE;"
"_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;"
)
endif()
add_compile_definitions(STORMLIB_NO_AUTO_LINK)
set(STORMLIB_NO_AUTO_LINK ON)
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
Expand Down Expand Up @@ -321,16 +327,55 @@ endif()

target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}")

include(ExternalProject)
ExternalProject_Add(TorchExternal
PREFIX TorchExternal
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/TorchExternal
)
ExternalProject_Get_Property(TorchExternal install_dir)
set(TORCH_EXECUTABLE ${install_dir}/src/TorchExternal-build/$<CONFIGURATION>/torch)
add_custom_target(
ExtractAssetHeaders
DEPENDS TorchExternal
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64
)
add_custom_target(
GeneratePortOtr
DEPENDS TorchExternal
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} pack port starship.otr
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr"
)
add_custom_target(
ExtractAssets
DEPENDS TorchExternal
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64
COMMAND ${TORCH_EXECUTABLE} pack port starship.otr
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr"
)

option(USE_STANDALONE "Build as a standalone executable" OFF)
option(BUILD_STORMLIB "Build with StormLib support" OFF)

option(BUILD_SM64 "Build with Super Mario 64 support" OFF)
option(BUILD_MK64 "Build with Mario Kart 64 support" OFF)
add_subdirectory(tools/Torch)
target_link_libraries(${PROJECT_NAME} PRIVATE torch)

if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch")

nx_generate_nacp(Lylat.nacp
nx_generate_nacp(Starship.nacp
NAME "${PROJECT_NAME}"
AUTHOR "${PROJECT_TEAM}"
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
)

nx_create_nro(${PROJECT_NAME}
NACP Lylat.nacp
NACP Starship.nacp
)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.nro DESTINATION . COMPONENT ${PROJECT_NAME})
Expand Down Expand Up @@ -526,23 +571,4 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
-Wl,-export-dynamic
)
endif()
endif()

include(ExternalProject)
ExternalProject_Add(Torch
PREFIX Torch
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch
)
ExternalProject_Get_Property(Torch install_dir)
set(TORCH_EXECUTABLE ${install_dir}/src/Torch-build/$<CONFIGURATION>/torch)
add_custom_target(
ExtractAssets
DEPENDS Torch
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64
COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64
COMMAND ${TORCH_EXECUTABLE} pack port starship.otr
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr"
)
endif()
23 changes: 22 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Supported Star Fox 64 Versions: US, JP

09f0d105f476b00efa5303a3ebc42e60a7753b7a:
name: Star Fox 64 (U) (V1.1) (Compressed)
preprocess:
decompress_mio0:
method: mio0-comptool
type: decompress
target: f7475fb11e7e6830f82883412638e8390791ab87
restart: true

f7475fb11e7e6830f82883412638e8390791ab87:
name: Star Fox 64 (U) (V1.1)
path: assets/yaml/us/rev1
Expand Down Expand Up @@ -37,4 +46,16 @@ d064229a32cc05ab85e2381ce07744eb3ffaf530:
- include/sf64mesg.h
- include/sf64audio_external.h
- include/sf64event.h
- include/sf64player.h
- include/sf64player.h

5f658e88ffa9de23cba6986a8fd3d3a90d7b4340:
name: F-ZERO X US REV 0 (v1.0)
path: test-yml
config:
gbi: F3DEX2
sort: OFFSET
logging: ERROR
output:
code: src/assets
headers: include/assets
modding: src/assets
Loading