From 982b52653a4eb1f8818427bfb63fa791c9cee707 Mon Sep 17 00:00:00 2001 From: Archez Date: Tue, 9 Jan 2024 21:48:45 -0500 Subject: [PATCH] Support builtin extraction and CMake target extraction (#9) * Support builtin extraction and CMake target extraction * bump submodules * add enum data --- CMakeLists.txt | 20 +- OTRExporter | 2 +- ZAPDTR | 2 +- copy-existing-otrs.cmake | 29 ++ mm/2s2h/Extractor/Extract.cpp | 14 +- mm/CMakeLists.txt | 14 +- mm/assets/extractor/Config.xml | 8 + mm/assets/extractor/EnumData.xml | 718 +++++++++++++++++++++++++++++++ 8 files changed, 781 insertions(+), 26 deletions(-) create mode 100644 copy-existing-otrs.cmake create mode 100644 mm/assets/extractor/Config.xml create mode 100644 mm/assets/extractor/EnumData.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index f2a7731b7..c622dd43f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,18 +109,18 @@ set_property(TARGET mm PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon. #install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/extractor/" DESTINATION ./assets/extractor COMPONENT extractor) #install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/xml/" DESTINATION ./assets/extractor/xmls COMPONENT extractor) #install(DIRECTORY "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/filelists/" DESTINATION ./assets/extractor/filelists COMPONENT extractor) -#install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT extractor) -#install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT extractor) -#install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT extractor) +#install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_MM.txt" DESTINATION ./assets/extractor/symbols COMPONENT extractor) +#install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_MM.txt" DESTINATION ./assets/extractor/symbols COMPONENT extractor) +#install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_MM.txt" DESTINATION ./assets/extractor/symbols COMPONENT extractor) #endif() if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/extractor/" DESTINATION ./assets/extractor COMPONENT 2s2h) install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/xml/" DESTINATION ./assets/extractor/xmls COMPONENT 2s2h) install(DIRECTORY "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/filelists/" DESTINATION ./assets/extractor/filelists COMPONENT 2s2h) -install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT 2s2h) -install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT 2s2h) -install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT 2s2h) +install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_MM.txt" DESTINATION ./assets/extractor/symbols COMPONENT 2s2h) +install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_MM.txt" DESTINATION ./assets/extractor/symbols COMPONENT 2s2h) +install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_MM.txt" DESTINATION ./assets/extractor/symbols COMPONENT 2s2h) endif() find_package(Python3 COMPONENTS Interpreter) @@ -129,7 +129,7 @@ find_package(Python3 COMPONENTS Interpreter) add_custom_target( ExtractAssets # CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions - COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f oot.otr oot-mq.otr soh.otr + COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f mm.otr soh.otr COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter @@ -195,9 +195,9 @@ set(PROGRAM_PERMISSIONS_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECU install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/extractor/" DESTINATION ./assets/extractor) install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/xml/" DESTINATION ./assets/extractor/xmls) install(DIRECTORY "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/filelists/" DESTINATION ./assets/extractor/filelists) -install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols) -install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols) -install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols) +install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_MM.txt" DESTINATION ./assets/extractor/symbols) +install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_MM.txt" DESTINATION ./assets/extractor/symbols) +install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_MM.txt" DESTINATION ./assets/extractor/symbols) install(DIRECTORY ${CMAKE_BINARY_DIR}/assets DESTINATION . diff --git a/OTRExporter b/OTRExporter index 2f420e42d..222c65c3a 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit 2f420e42dcaa7a24ceb429be1ef2047f7ebd91bc +Subproject commit 222c65c3a9cda19b11e89e11fe99c6b39ad54216 diff --git a/ZAPDTR b/ZAPDTR index f30b7de36..51917d817 160000 --- a/ZAPDTR +++ b/ZAPDTR @@ -1 +1 @@ -Subproject commit f30b7de367aceb8d3d09d12f4880bf4bd75972dd +Subproject commit 51917d817a5828c075ec1e31eac4205e9b456ea7 diff --git a/copy-existing-otrs.cmake b/copy-existing-otrs.cmake new file mode 100644 index 000000000..3f18f36ca --- /dev/null +++ b/copy-existing-otrs.cmake @@ -0,0 +1,29 @@ +message(STATUS "Copying otr files...") + +if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/mm.otr) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.otr ${SOURCE_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.otr ${BINARY_DIR}/mm/) + message(STATUS "Copied mm.otr") +endif() +if(EXISTS ${SOURCE_DIR}/OTRExporter/soh.otr) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.otr ${SOURCE_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.otr ${BINARY_DIR}/mm/) + message(STATUS "Copied soh.otr") +endif() + +# Additionally for Windows, copy the otrs to the target dir, side by side with soh.exe +if(SYSTEM_NAME MATCHES "Windows") + if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/mm.otr) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.otr ${TARGET_DIR}) + endif() + if(EXISTS ${SOURCE_DIR}/OTRExporter/soh.otr) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.otr ${TARGET_DIR}) + endif() +endif() + +if(NOT ONLYSOHOTR AND (NOT EXISTS ${SOURCE_DIR}/mm.otr)) + message(FATAL_ERROR "Failed to copy. No OTR files found.") +endif() +if(NOT EXISTS ${SOURCE_DIR}/soh.otr) + message(FATAL_ERROR "Failed to copy. No soh OTR found.") +endif() diff --git a/mm/2s2h/Extractor/Extract.cpp b/mm/2s2h/Extractor/Extract.cpp index ae3e325fb..c2eb096db 100644 --- a/mm/2s2h/Extractor/Extract.cpp +++ b/mm/2s2h/Extractor/Extract.cpp @@ -57,10 +57,11 @@ static constexpr uint32_t OOT_PAL_GC_DBG2 = 0x87121EFE; // 03-13-2002 build static constexpr uint32_t OOT_PAL_GC_MQ_DBG = 0x917D18F6; static constexpr uint32_t OOT_PAL_10 = 0xB044B569; static constexpr uint32_t OOT_PAL_11 = 0xB2055FBD; + static constexpr uint32_t MM_US_10 = 0x5354631C; static const std::unordered_map verMap = { - { MM_US_10, "U.S 1.0" }, + { MM_US_10, "US 1.0" }, //{ OOT_PAL_GC, "PAL Gamecube" }, //{ OOT_PAL_MQ, "PAL MQ" }, //{ OOT_PAL_GC_DBG1, "PAL Debug 1" }, @@ -72,7 +73,7 @@ static const std::unordered_map verMap = { // TODO only check the first 54MB of the rom. static constexpr std::array goodCrcs = { - + 0x96F49400, // MM US 1.0 32MB //0xfa8c0555, // MQ DBG 64MB (Original overdump) //0x8652ac4c, // MQ DBG 64MB //0x5B8A1EB7, // MQ DBG 64MB (Empty overdump) @@ -538,8 +539,8 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { char xmlPath[1024]; char confPath[1024]; std::array argv; - const char* version = GetZapdVerStr(); - const char* otrFile = IsMasterQuest() ? "oot-mq.otr" : "oot.otr"; + // const char* version = GetZapdVerStr(); + const char* otrFile = "mm.otr"; std::string romPath = std::filesystem::absolute(mCurrentRomPath).string(); installPath = std::filesystem::absolute(installPath).string(); @@ -556,8 +557,8 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { std::filesystem::current_path(tempdir); - snprintf(xmlPath, 1024, "assets/extractor/xmls/%s", version); - snprintf(confPath, 1024, "assets/extractor/Config_%s.xml", version); + snprintf(xmlPath, 1024, "assets/extractor/xmls"); + snprintf(confPath, 1024, "assets/extractor/Config.xml"); argv[0] = "ZAPD"; argv[1] = "ed"; @@ -600,4 +601,3 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { return 0; } - diff --git a/mm/CMakeLists.txt b/mm/CMakeLists.txt index c50fd207c..3e69f685c 100644 --- a/mm/CMakeLists.txt +++ b/mm/CMakeLists.txt @@ -681,13 +681,13 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS") TARGET ${PROJECT_NAME} POST_BUILD COMMENT "Copying asset xmls..." - #COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/mm/assets/extractor $/assets/extractor - #COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/mm/assets/xml $/assets/extractor/xmls - #COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/filelists $/assets/extractor/filelists - #COMMAND ${CMAKE_COMMAND} -E make_directory $/assets/extractor/symbols - #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_MM.txt $/assets/extractor/symbols - #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_MM.txt $/assets/extractor/symbols - #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_MM.txt $/assets/extractor/symbols + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/mm/assets/extractor $/assets/extractor + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/mm/assets/xml $/assets/extractor/xmls + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/filelists $/assets/extractor/filelists + COMMAND ${CMAKE_COMMAND} -E make_directory $/assets/extractor/symbols + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_MM.txt $/assets/extractor/symbols + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_MM.txt $/assets/extractor/symbols + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_MM.txt $/assets/extractor/symbols ) endif() ################################################################################ diff --git a/mm/assets/extractor/Config.xml b/mm/assets/extractor/Config.xml new file mode 100644 index 000000000..78261bc13 --- /dev/null +++ b/mm/assets/extractor/Config.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/mm/assets/extractor/EnumData.xml b/mm/assets/extractor/EnumData.xml new file mode 100644 index 000000000..2ade5b346 --- /dev/null +++ b/mm/assets/extractor/EnumData.xml @@ -0,0 +1,718 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +