Bump ZAPDTR & OTRExporter.

Changes to use o2r by default
Changes to the new player animation format

# Conflicts:
#	OTRExporter
#	ZAPDTR
#	soh/soh/OTRGlobals.cpp
#	soh/src/code/z_skelanime.c
This commit is contained in:
louist103 2025-03-30 18:34:53 -04:00
commit 603403025b
10 changed files with 75 additions and 74 deletions

1
.gitignore vendored
View file

@ -412,6 +412,7 @@ ReleaseObj/*
.tags
tags
*.otr
*.o2r
*.sav
shipofharkinian.ini
shipofharkinian.json

View file

@ -174,7 +174,7 @@ set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
install(PROGRAMS "${CMAKE_BINARY_DIR}/linux/soh.sh" DESTINATION . COMPONENT appimage)
install(FILES "${CMAKE_BINARY_DIR}/soh/soh.otr" DESTINATION . COMPONENT ship)
install(FILES "${CMAKE_BINARY_DIR}/soh/soh.o2r" DESTINATION . COMPONENT ship)
install(TARGETS ZAPD DESTINATION ./assets/extractor COMPONENT extractor)
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)
@ -198,18 +198,18 @@ find_package(Python3 COMPONENTS Interpreter)
# Target to generate OTRs
add_custom_target(
ExtractAssets
COMMAND ${CMAKE_COMMAND} -E rm -f oot.otr oot-mq.otr soh.otr
COMMAND ${CMAKE_COMMAND} -E rm -f oot.o2r oot-mq.o2r soh.o2r
# copy LUS default shaders into assets/custom
COMMAND ${CMAKE_COMMAND} -E rm -r -f ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic/Fast3D/shaders/ ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --xml-root ../soh/assets/xml --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}"
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --xml-root ../soh/assets/xml --custom-otr-file soh.o2r "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}"
COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$<TARGET_FILE_DIR:ZAPD>" -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
COMMENT "Running asset extraction..."
DEPENDS ZAPD
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr oot-mq.otr ${CMAKE_SOURCE_DIR}/oot-mq.otr ${CMAKE_SOURCE_DIR}/soh.otr
BYPRODUCTS oot.o2r ${CMAKE_SOURCE_DIR}/oot.o2r oot-mq.o2r ${CMAKE_SOURCE_DIR}/oot-mq.o2r ${CMAKE_SOURCE_DIR}/soh.o2r
)
# Target to generate headers
@ -221,19 +221,19 @@ add_custom_target(
DEPENDS ZAPD
)
# Target to generate only soh.otr
# Target to generate only soh.o2r
add_custom_target(
GenerateSohOtr
COMMAND ${CMAKE_COMMAND} -E rm -f soh.otr
COMMAND ${CMAKE_COMMAND} -E rm -f soh.o2r
# copy LUS default shaders into assets/custom
COMMAND ${CMAKE_COMMAND} -E rm -r -f ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic/Fast3D/shaders/ ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}"
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom --custom-otr-file soh.o2r "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}"
COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$<TARGET_FILE_DIR:ZAPD>" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DONLYSOHOTR=On -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
COMMENT "Generating soh.otr..."
COMMENT "Generating soh.o2r..."
DEPENDS ZAPD
)

@ -1 +1 @@
Subproject commit 41052efcdf8df8e67517cc93da8975fcd4e14af9
Subproject commit 35dbf63b4e70a21744ce6ecf9dff7db266b4f2d5

2
ZAPDTR

@ -1 +1 @@
Subproject commit 2aeababbfb81b00d34673406453e8e8e2deaa27b
Subproject commit c3ee03cfe3072fc01df256d365115a1f3ccaf012

View file

@ -1,37 +1,37 @@
message(STATUS "Copying otr files...")
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${SOURCE_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${BINARY_DIR}/soh/)
message(STATUS "Copied oot.otr")
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot.o2r)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.o2r ${SOURCE_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.o2r ${BINARY_DIR}/soh/)
message(STATUS "Copied oot.o2r")
endif()
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${SOURCE_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${BINARY_DIR}/soh/)
message(STATUS "Copied oot-mq.otr")
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.o2r)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.o2r ${SOURCE_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.o2r ${BINARY_DIR}/soh/)
message(STATUS "Copied oot-mq.o2r")
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}/soh/)
message(STATUS "Copied soh.otr")
if(EXISTS ${SOURCE_DIR}/OTRExporter/soh.o2r)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.o2r ${SOURCE_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.o2r ${BINARY_DIR}/soh/)
message(STATUS "Copied soh.o2r")
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/oot.otr)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${TARGET_DIR})
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot.o2r)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.o2r ${TARGET_DIR})
endif()
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${TARGET_DIR})
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.o2r)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.o2r ${TARGET_DIR})
endif()
if(EXISTS ${SOURCE_DIR}/OTRExporter/soh.otr)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.otr ${TARGET_DIR})
if(EXISTS ${SOURCE_DIR}/OTRExporter/soh.o2r)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.o2r ${TARGET_DIR})
endif()
endif()
if(NOT ONLYSOHOTR AND (NOT EXISTS ${SOURCE_DIR}/oot.otr AND NOT EXISTS ${SOURCE_DIR}/oot-mq.otr))
if(NOT ONLYSOHOTR AND (NOT EXISTS ${SOURCE_DIR}/oot.o2r AND NOT EXISTS ${SOURCE_DIR}/oot-mq.o2r))
message(FATAL_ERROR "Failed to copy. No OTR files found.")
endif()
if(NOT EXISTS ${SOURCE_DIR}/soh.otr)
if(NOT EXISTS ${SOURCE_DIR}/soh.o2r)
message(FATAL_ERROR "Failed to copy. No soh OTR found.")
endif()

View file

@ -709,7 +709,7 @@ endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
INSTALL(FILES $<TARGET_PDB_FILE:soh> DESTINATION ./debug COMPONENT ship)
INSTALL(FILES ${CMAKE_BINARY_DIR}/soh/soh.otr DESTINATION . COMPONENT ship)
INSTALL(FILES ${CMAKE_BINARY_DIR}/soh/soh.o2r DESTINATION . COMPONENT ship)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@ -723,7 +723,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/macosx/Info.plist.in ${CMAKE_BINARY_DIR}/macosx/Info.plist @ONLY)
INSTALL(TARGETS soh DESTINATION ../MacOS COMPONENT ship)
INSTALL(FILES ${CMAKE_BINARY_DIR}/gamecontrollerdb.txt DESTINATION ../MacOS COMPONENT ship)
INSTALL(FILES ${CMAKE_BINARY_DIR}/soh/soh.otr DESTINATION ../Resources COMPONENT ship)
INSTALL(FILES ${CMAKE_BINARY_DIR}/soh/soh.o2r DESTINATION ../Resources COMPONENT ship)
elseif(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "NintendoSwitch|CafeOS")
INSTALL(FILES ${CMAKE_BINARY_DIR}/gamecontrollerdb.txt DESTINATION . COMPONENT ship)
endif()

View file

@ -615,7 +615,7 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) {
char portVersion[18]; // 5 digits for int16_max (x3) + separators + terminator
std::array<const char*, argc> argv;
const char* version = GetZapdVerStr();
const char* otrFile = IsMasterQuest() ? "oot-mq.otr" : "oot.otr";
const char* otrFile = IsMasterQuest() ? "oot-mq.o2r" : "oot.o2r";
std::string romPath = std::filesystem::absolute(mCurrentRomPath).string();
installPath = std::filesystem::absolute(installPath).string();

View file

@ -263,15 +263,15 @@ const char* constCameraStrings[] = {
OTRGlobals::OTRGlobals() {
std::vector<std::string> OTRFiles;
std::string mqPath = Ship::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName);
std::string mqPath = Ship::Context::LocateFileAcrossAppDirs("oot-mq.o2r", appShortName);
if (std::filesystem::exists(mqPath)) {
OTRFiles.push_back(mqPath);
}
std::string ootPath = Ship::Context::LocateFileAcrossAppDirs("oot.otr", appShortName);
std::string ootPath = Ship::Context::LocateFileAcrossAppDirs("oot.o2r", appShortName);
if (std::filesystem::exists(ootPath)) {
OTRFiles.push_back(ootPath);
}
std::string sohOtrPath = Ship::Context::GetPathRelativeToAppBundle("soh.otr");
std::string sohOtrPath = Ship::Context::GetPathRelativeToAppBundle("soh.o2r");
if (std::filesystem::exists(sohOtrPath)) {
OTRFiles.push_back(sohOtrPath);
}
@ -945,7 +945,7 @@ OTRVersion ReadPortVersionFromOTR(std::string otrPath) {
OTRVersion version = {};
// Use a temporary archive instance to load the otr and read the version file
auto archive = std::make_shared<Ship::OtrArchive>(otrPath);
auto archive = std::make_shared<Ship::O2rArchive>(otrPath);
if (archive->Open()) {
auto t = archive->LoadFile("portVersion");
if (t != nullptr && t->IsLoaded) {
@ -963,7 +963,7 @@ OTRVersion ReadPortVersionFromOTR(std::string otrPath) {
return version;
}
// Check that a soh.otr exists and matches the version of soh running
// Check that a soh.o2r exists and matches the version of soh running
// Otherwise show a message and exit
void CheckSoHOTRVersion(std::string otrPath) {
std::string msg;
@ -972,20 +972,20 @@ void CheckSoHOTRVersion(std::string otrPath) {
msg = "\x1b[4;2HPlease re-extract it from the download."
"\x1b[6;2HPress the Home button to exit...";
#elif defined(__WIIU__)
msg = "Please extract the soh.otr from the Ship of Harkinian download\nto your folder.\n\nPress and hold the power "
msg = "Please extract the soh.o2r from the Ship of Harkinian download\nto your folder.\n\nPress and hold the power "
"button to shutdown...";
#else
msg = "Please extract the soh.otr from the Ship of Harkinian download to your folder.\n\nExiting...";
msg = "Please extract the soh.o2r from the Ship of Harkinian download to your folder.\n\nExiting...";
#endif
if (!std::filesystem::exists(otrPath)) {
#if not defined(__SWITCH__) && not defined(__WIIU__)
Extractor::ShowErrorBox("soh.otr file is missing", msg.c_str());
Extractor::ShowErrorBox("soh.o2r file is missing", msg.c_str());
exit(1);
#elif defined(__SWITCH__)
Ship::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou are missing the soh.otr file." + msg).c_str());
Ship::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou are missing the soh.o2r file." + msg).c_str());
#elif defined(__WIIU__)
OSFatal(("You are missing the soh.otr file\n\n" + msg).c_str());
OSFatal(("You are missing the soh.o2r file\n\n" + msg).c_str());
#endif
}
@ -994,12 +994,12 @@ void CheckSoHOTRVersion(std::string otrPath) {
if (otrVersion.major != gBuildVersionMajor || otrVersion.minor != gBuildVersionMinor ||
otrVersion.patch != gBuildVersionPatch) {
#if not defined(__SWITCH__) && not defined(__WIIU__)
Extractor::ShowErrorBox("soh.otr file version does not match", msg.c_str());
Extractor::ShowErrorBox("soh.o2r file version does not match", msg.c_str());
exit(1);
#elif defined(__SWITCH__)
Ship::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou have an old soh.otr file." + msg).c_str());
Ship::Switch::PrintErrorMessageToScreen(("\x1b[2;2HYou have an old soh.o2r file." + msg).c_str());
#elif defined(__WIIU__)
OSFatal(("You have an old soh.otr file\n\n" + msg).c_str());
OSFatal(("You have an old soh.o2r file\n\n" + msg).c_str());
#endif
}
}
@ -1151,10 +1151,13 @@ extern "C" void InitOTR() {
CheckAndCreateModFolder();
#endif
CheckSoHOTRVersion(Ship::Context::GetPathRelativeToAppBundle("soh.otr"));
CheckSoHOTRVersion(Ship::Context::GetPathRelativeToAppBundle("soh.o2r"));
const bool ootO2RExists = std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot-mq.o2r", appShortName)) ||
std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot.o2r", appShortName));
const bool ootOTRExists = std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName)) ||
std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot.otr", appShortName));
if (!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName)) &&
!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("oot.otr", appShortName))) {
if (!ootOTRExists && !ootO2RExists) {
#if not defined(__SWITCH__) && not defined(__WIIU__)
std::string installPath = Ship::Context::GetAppBundlePath();
@ -1200,8 +1203,8 @@ extern "C" void InitOTR() {
#endif
}
DetectOTRVersion("oot.otr", false);
DetectOTRVersion("oot-mq.otr", true);
DetectOTRVersion("oot.o2r", false);
DetectOTRVersion("oot-mq.o2r", true);
OTRGlobals::Instance = new OTRGlobals();
CustomMessageManager::Instance = new CustomMessageManager();

View file

@ -1,6 +1,7 @@
#include "soh/resource/importer/AnimationFactory.h"
#include "soh/resource/type/Animation.h"
#include "spdlog/spdlog.h"
#include "Context.h"
namespace SOH {
std::shared_ptr<Ship::IResource>
@ -80,7 +81,11 @@ ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr<Ship::File> file,
animation->animationData.linkAnimationHeader.common.frameCount = reader->ReadInt16();
// Read the segment pointer (always 32 bit, doesn't adjust for system pointer size)
animation->animationData.linkAnimationHeader.segment = (void*)reader->ReadUInt32();
std::string path = reader->ReadString();
const auto animData = std::static_pointer_cast<Animation>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str()));
animation->animationData.linkAnimationHeader.segment = animData->GetPointer();
} else if (animType == AnimationType::Legacy) {
SPDLOG_DEBUG("BEYTAH ANIMATION?!");
}

View file

@ -899,33 +899,25 @@ void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animati
if (ResourceMgr_OTRSigCheck(animation) != 0)
animation = ResourceMgr_LoadAnimByName(animation);
LinkAnimationHeader* linkAnimHeader = SEGMENTED_TO_VIRTUAL(animation);
LinkAnimationHeader* playerAnimHeader = animation;
Vec3s* ram = frameTable;
osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1);
char animPath[2048];
snprintf(animPath, sizeof(animPath), "misc/link_animetion/gPlayerAnimData_%06X",
(((uintptr_t)linkAnimHeader->segment - 0x07000000)));
// osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1);
//
// char animPath[2048];
//
// snprintf(animPath, sizeof(animPath), "misc/link_animetion/gPlayerAnimData_%06X",
// (((uintptr_t)linkAnimHeader->segmentVoid - 0x07000000)));
//
// printf("Streaming %s, seg = %08X\n", animPath, linkAnimHeader->segment);
s16* animData = ResourceMgr_LoadPlayerAnimByName(animPath);
s16* animData = /* ResourceMgr_LoadPlayerAnimByName*/ (animation->segment);
// 2S2H [Port] sometimes a HESS can set a negative frame value from a negative playback speed. When converted to
// a signed value this will cause a crash due to copying way much data.
if (frame < 0) {
frame = 0;
}
memcpy(ram, (uintptr_t)animData + (((sizeof(Vec3s) * limbCount + 2) * frame)), sizeof(Vec3s) * limbCount + 2);
/*u32* ramPtr = (u32*)ram;
for (int i = 0; i < 1024; i++)
{
ramPtr[i] = i * 7;
}*/
// DmaMgr_SendRequest2(&entry->data.load.req, ram,
// LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame)),
// sizeof(Vec3s) * limbCount + 2, 0, &entry->data.load.msgQueue, NULL, __FILE__,
//__LINE__);
}
}