diff --git a/.gitignore b/.gitignore index fafae443d..03468a05c 100644 --- a/.gitignore +++ b/.gitignore @@ -279,7 +279,7 @@ ClientBin/ *.publishsettings orleans.codegen.cs -# Including strong name files can present a security risk +# Including strong name files can present a security risk # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk @@ -375,7 +375,7 @@ __pycache__/ # OpenCover UI analysis results OpenCover/ -# Azure Stream Analytics local run output +# Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log @@ -384,7 +384,7 @@ ASALocalRun/ # NVidia Nsight GPU debugger configuration file *.nvuser -# MFractors (Xamarin productivity tool) working folder +# MFractors (Xamarin productivity tool) working folder .mfractor/ *.out @@ -395,6 +395,7 @@ ExporterTest/ExporterTest.a ZAPDUtils/ZAPDUtils.a .vscode/ build/ +external/ ZAPDUtils/build/ ZAPD/BuildInfo.h diff --git a/BUILDING.md b/BUILDING.md index 82c26bff4..d37d7c0d6 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,5 +1,7 @@ # Building Ship of Harkinian +## Windows + 1. Install [Python](https://www.python.org/ftp/python/3.10.2/python-3.10.2-amd64.exe) 2. Install [Visual Studio 2022 Community Edition](https://visualstudio.microsoft.com/vs/community/) 2b. In the Visual Studio Installer, install `MSVC v142 - VS 2019 C++`. @@ -7,7 +9,7 @@ 5. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice. 6. Run `OTRExporter/OTRExporter.sln`. 7. Switch the solution to `Release x64`. - 8. Build the solution. + 8. Build the solution. 9. Launching `OTRExporter/extract_assets.py` will generate an `oot.otr` archive file in `OTRExporter/oot.otr`. 10. Run `soh/soh.sln` 11. Switch the solution to `Release x86`. @@ -15,7 +17,36 @@ 13. Copy the `OTRExporter/oot.otr` archive file to `soh/Release`. 14. Launch `soh.exe`. -## Compatible Roms +## Linux + +```bash +# Clone the repo +git clone git@github.com:HarbourMasters/ShipWright.git +cd ShipWright +# Copy the baserom to the OTRExporter folder +cp OTRExporter +# Build the docker image +sudo docker build . -t soh +# Run the docker image with the working directory mounted to /soh +sudo docker run --rm -it -v $(pwd):/soh soh /bin/bash +``` +Inside the Docker container: +```bash +# Clone and build StormLib +git clone https://github.com/ladislav-zezula/StormLib external/StormLib +cmake -B external/StormLib/build -S external/StormLib +cmake --build external/StormLib/build +cp external/StormLib/build/libstorm.a external +cp /usr/local/lib/libGLEW.a external + +cd soh +# Extract the assets/Compile the exporter/Run the exporter +make setup -j$(nproc) +# Compile the code +make -j $(nproc) +``` + +# Compatible Roms ``` OOT_PAL_GC checksum 0x09465AC3 OOT_PAL_GC_DBG1 checksum 0x871E1C92 (debug non-master quest) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e981cf573 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ + + +FROM ubuntu:21.04 as build + +ENV LANG C.UTF-8 +ARG DEBIAN_FRONTEND=noninteractive + +RUN dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + binutils:i386 \ + gcc-10:i386 \ + g++-10:i386 \ + python3.10 \ + python \ + make \ + cmake \ + git \ + lld \ + libsdl2-dev:i386 \ + zlib1g-dev:i386 \ + libbz2-dev:i386 \ + libpng-dev:i386 \ + libgles2-mesa-dev && \ + ln -sf /usr/bin/python3.10 /usr/bin/python3 && \ + ln -s /usr/bin/gcc-10 /usr/bin/gcc && \ + ln -s /usr/bin/gcc-10 /usr/bin/cc && \ + ln -s /usr/bin/g++-10 /usr/bin/g++ && \ + ln -s /usr/bin/g++-10 /usr/bin/c++ + +RUN git clone https://github.com/Perlmint/glew-cmake.git && \ + cmake glew-cmake && \ + make -j$(nproc) && \ + make install ARCH64=false + +RUN mkdir /soh +WORKDIR /soh diff --git a/Jenkinsfile b/Jenkinsfile index fa68703b2..7f1132bae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,29 +1,26 @@ pipeline { - - environment { - MSBUILD='C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Msbuild\\Current\\Bin\\msbuild.exe' - CONFIG='Release' - OTRPLATFORM='x64' - PLATFORM='x86' - ZIP='C:\\Program Files\\7-Zip\\7z.exe' - PYTHON='C:\\Users\\jenkins\\AppData\\Local\\Programs\\Python\\Python310\\python.exe' - TOOLSET='v142' - EMAILTO='' - } - - agent { - label 'SoH-Builders' - } - + agent none + options { timestamps() - timeout(time: 15, unit: 'MINUTES') skipDefaultCheckout(true) } - + stages { - - stage ('Checkout') { + stage ('Build Windows') { + environment { + MSBUILD='C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Msbuild\\Current\\Bin\\msbuild.exe' + CONFIG='Release' + OTRPLATFORM='x64' + PLATFORM='x86' + ZIP='C:\\Program Files\\7-Zip\\7z.exe' + PYTHON='C:\\Users\\jenkins\\AppData\\Local\\Programs\\Python\\Python310\\python.exe' + CMAKE='C:\\Program Files\\CMake\\bin\\cmake.exe' + TOOLSET='v142' + } + agent { + label "SoH-Builders" + } steps { checkout([ $class: 'GitSCM', @@ -32,68 +29,89 @@ pipeline { extensions: scm.extensions, userRemoteConfigs: scm.userRemoteConfigs ]) + + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + bat """ + + "${env.MSBUILD}" ".\\OTRExporter\\OTRExporter.sln" -t:build -p:Configuration=${env.CONFIG};Platform=${env.OTRPLATFORM};PlatformToolset=${env.TOOLSET};RestorePackagesConfig=true /restore /nodeReuse:false /m + + xcopy "..\\..\\ZELOOTD.z64" "OTRExporter\\" + + cd "OTRExporter" + "${env.PYTHON}" ".\\extract_assets.py" + cd "..\\" + + "${env.MSBUILD}" ".\\soh\\soh.sln" -t:build -p:Configuration=${env.CONFIG};Platform=${env.PLATFORM};PlatformToolset=${env.TOOLSET} /nodeReuse:false /m + + cd OTRGui + mkdir build + cd build + + "${env.CMAKE}" .. + "${env.CMAKE}" --build . --config Release + + cd "..\\..\\" + + move "soh\\Release\\soh.exe" ".\\" + move "OTRGui\\build\\assets" ".\\" + move ".\\OTRExporter\\x64\\Release\\ZAPD.exe" ".\\assets\\extractor\\" + move ".\\OTRGui\\build\\Release\\OTRGui.exe" ".\\" + rename README.md readme.txt + + "${env.ZIP}" a soh.7z soh.exe OTRGui.exe assets readme.txt + + """ + archiveArtifacts artifacts: 'soh.7z', followSymlinks: false, onlyIfSuccessful: true + } + } + post { + always { + step([$class: 'WsCleanup']) // Clean workspace + } } } - - stage ('Build OTRExporter') { + stage ('Build Linux') { + agent { + label "SoH-Linux-Builders" + } steps { - bat """ - - "${env.MSBUILD}" ".\\OTRExporter\\OTRExporter.sln" -t:restore,build -p:Configuration=${env.CONFIG};Platform=${env.OTRPLATFORM};PlatformToolset=${env.TOOLSET};RestorePackagesConfig=true /nodeReuse:false - - """ + checkout([ + $class: 'GitSCM', + branches: scm.branches, + doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, + extensions: scm.extensions, + userRemoteConfigs: scm.userRemoteConfigs + ]) + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + sh ''' + + cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 + docker build . -t soh + docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash + cp ../../buildsoh.bash soh + docker exec sohcont soh/buildsoh.bash + + mkdir build + mv soh/soh.elf build/ + mv OTRGui/build/OTRGui build/ + mv OTRGui/build/assets build/ + mv ZAPDTR/ZAPD.out build/assets/extractor/ + mv README.md build/readme.txt + cd build + + 7z a soh-linux.7z soh.elf OTRGui assets readme.txt + mv soh-linux.7z ../ + + ''' + } + sh 'sudo docker container stop sohcont' + archiveArtifacts artifacts: 'soh-linux.7z', followSymlinks: false, onlyIfSuccessful: true } - } - - stage ('Extract assets') { - steps { - bat """ - - xcopy "..\\..\\ZELOOTD.z64" "OTRExporter\\" - - cd "OTRExporter" - "${env.PYTHON}" ".\\extract_assets.py" - cd "${env.WORKSPACE}" - - """ + post { + always { + step([$class: 'WsCleanup']) // Clean workspace + } } } - - stage ('Build SoH') { - steps { - bat """ - - "${env.MSBUILD}" ".\\soh\\soh.sln" -t:build -p:Configuration=${env.CONFIG};Platform=${env.PLATFORM};PlatformToolset=${env.TOOLSET} /nodeReuse:false - - """ - } - } - - stage ('Archive artifacts') { - steps { - bat """ - - "${env.ZIP}" a "soh.zip" ".\\soh\\Release\\soh.exe" - - """ - - archiveArtifacts allowEmptyArchive: false, - artifacts: 'soh.zip', - caseSensitive: true, - defaultExcludes: true, - fingerprint: false, - onlyIfSuccessful: true - } - } - } - - post { - always { - step([$class: 'Mailer', - notifyEveryUnstableBuild: true, - recipients: "${env.EMAILTO}", - sendToIndividuals: false]) - step([$class: 'WsCleanup']) // Clean workspace - } } } diff --git a/OTRExporter/OTRExporter/AnimationExporter.cpp b/OTRExporter/OTRExporter/AnimationExporter.cpp index 4f031b8a8..74fa8a7e6 100644 --- a/OTRExporter/OTRExporter/AnimationExporter.cpp +++ b/OTRExporter/OTRExporter/AnimationExporter.cpp @@ -49,12 +49,12 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary writer->Write((uint32_t)normalAnim->rotationValues.size()); - for (int i = 0; i < normalAnim->rotationValues.size(); i++) + for (size_t i = 0; i < normalAnim->rotationValues.size(); i++) writer->Write(normalAnim->rotationValues[i]); writer->Write((uint32_t)normalAnim->rotationIndices.size()); - for (int i = 0; i < normalAnim->rotationIndices.size(); i++) + for (size_t i = 0; i < normalAnim->rotationIndices.size(); i++) { writer->Write(normalAnim->rotationIndices[i].x); writer->Write(normalAnim->rotationIndices[i].y); diff --git a/OTRExporter/OTRExporter/ArrayExporter.cpp b/OTRExporter/OTRExporter/ArrayExporter.cpp index 2ddfd7b10..f83bfd87d 100644 --- a/OTRExporter/OTRExporter/ArrayExporter.cpp +++ b/OTRExporter/OTRExporter/ArrayExporter.cpp @@ -10,7 +10,7 @@ void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWrit writer->Write((uint32_t)arr->resList[0]->GetResourceType()); writer->Write((uint32_t)arr->arrayCnt); - for (int i = 0; i < arr->arrayCnt; i++) + for (size_t i = 0; i < arr->arrayCnt; i++) { if (arr->resList[i]->GetResourceType() == ZResourceType::Vertex) { @@ -32,7 +32,7 @@ void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWrit writer->Write((uint32_t)vec->scalarType); writer->Write((uint32_t)vec->dimensions); - for (int k = 0; k < vec->dimensions; k++) + for (size_t k = 0; k < vec->dimensions; k++) { // OTRTODO: Duplicate code here. Cleanup at a later date... switch (vec->scalarType) @@ -62,6 +62,8 @@ void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWrit writer->Write(vec->scalars[k].scalarData.u64); break; // OTRTODO: ADD OTHER TYPES + default: + break; } } } @@ -98,6 +100,8 @@ void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWrit writer->Write(scal->scalarData.u64); break; // OTRTODO: ADD OTHER TYPES + default: + break; } } } diff --git a/OTRExporter/OTRExporter/CutsceneExporter.cpp b/OTRExporter/OTRExporter/CutsceneExporter.cpp index 7cbf7f175..b52d73d8b 100644 --- a/OTRExporter/OTRExporter/CutsceneExporter.cpp +++ b/OTRExporter/OTRExporter/CutsceneExporter.cpp @@ -29,7 +29,7 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) { writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(CMD_F(e->viewAngle)); + writer->Write(e->viewAngle); writer->Write(CMD_HH(e->posX, e->posY)); writer->Write(CMD_HH(e->posZ, e->unused)); } @@ -46,7 +46,7 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) { writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(CMD_F(e->viewAngle)); + writer->Write(e->viewAngle); writer->Write(CMD_HH(e->posX, e->posY)); writer->Write(CMD_HH(e->posZ, e->unused)); } @@ -105,7 +105,7 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) { writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(CMD_F(e->viewAngle)); + writer->Write(e->viewAngle); writer->Write(CMD_HH(e->posX, e->posY)); writer->Write(CMD_HH(e->posZ, e->unused)); } @@ -122,7 +122,7 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) { writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(CMD_F(e->viewAngle)); + writer->Write(e->viewAngle); writer->Write(CMD_HH(e->posX, e->posY)); writer->Write(CMD_HH(e->posZ, e->unused)); } diff --git a/OTRExporter/OTRExporter/DisplayListExporter.cpp b/OTRExporter/OTRExporter/DisplayListExporter.cpp index 1fe7cb44a..d03a06333 100644 --- a/OTRExporter/OTRExporter/DisplayListExporter.cpp +++ b/OTRExporter/OTRExporter/DisplayListExporter.cpp @@ -29,20 +29,6 @@ Ab1, Ad1)) \ } -typedef int32_t Mtx_t[4][4]; - -typedef union Mtx -{ - //_Alignas(8) - Mtx_t m; - int32_t l[16]; - struct - { - int16_t i[16]; - uint16_t f[16]; - }; -} Mtx; - #define gsSPBranchLessZraw2(dl, vtx, zval) \ { _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ (unsigned int)(zval), } @@ -71,7 +57,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina // DEBUG: Write in a marker Declaration* dbgDecl = dList->parent->GetDeclaration(dList->GetRawDataIndex()); - std::string dbgName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dbgDecl->varName.c_str()); + std::string dbgName = StringHelper::Sprintf("%s/%s", GetParentFolderName(res).c_str(), dbgDecl->varName.c_str()); uint64_t hash = CRC64(dbgName.c_str()); writer->Write((uint32_t)(G_MARKER << 24)); writer->Write((uint32_t)0xBEEFBEEF); @@ -81,7 +67,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina auto dlStart = std::chrono::steady_clock::now(); //for (auto data : dList->instructions) - for (int dataIdx = 0; dataIdx < dList->instructions.size(); dataIdx++) + for (size_t dataIdx = 0; dataIdx < dList->instructions.size(); dataIdx++) { auto data = dList->instructions[dataIdx]; uint32_t word0 = 0; @@ -216,7 +202,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina pp ^= G_MTX_PUSH; - mm = (mm & 0x0FFFFFFF) + 0xF0000000; + mm = (mm & 0x0FFFFFFF) + 1; Gfx value = gsSPMatrix(mm, pp); word0 = value.words.w0; @@ -243,7 +229,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina if (mtxDecl != nullptr) { - std::string vName = StringHelper::Sprintf("%s\\%s", (GetParentFolderName(res).c_str()), mtxDecl->varName.c_str()); + std::string vName = StringHelper::Sprintf("%s/%s", (GetParentFolderName(res).c_str()), mtxDecl->varName.c_str()); uint64_t hash = CRC64(vName.c_str()); @@ -347,7 +333,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina if (dListDecl != nullptr) { - std::string vName = StringHelper::Sprintf("%s\\%s", (GetParentFolderName(res).c_str()), dListDecl->varName.c_str()); + std::string vName = StringHelper::Sprintf("%s/%s", (GetParentFolderName(res).c_str()), dListDecl->varName.c_str()); uint64_t hash = CRC64(vName.c_str()); @@ -370,7 +356,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); - if (files.find(fName) == files.end() && !File::Exists("Extract\\" + fName)) + if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) { MemoryStream* dlStream = new MemoryStream(); BinaryWriter dlWriter = BinaryWriter(dlStream); @@ -383,7 +369,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina #endif if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - File::WriteAllBytes("Extract\\" + fName, dlStream->ToVector()); + File::WriteAllBytes("Extract/" + fName, dlStream->ToVector()); else files[fName] = dlStream->ToVector(); @@ -411,7 +397,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina Gfx value; - u32 dListVal = (data & 0x0FFFFFFF) + 0xF0000000; + u32 dListVal = (data & 0x0FFFFFFF) + 1; if (pp != 0) value = gsSPBranchList(dListVal); @@ -444,7 +430,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina if (dListDecl != nullptr) { - std::string vName = StringHelper::Sprintf("%s\\%s", (GetParentFolderName(res).c_str()), dListDecl->varName.c_str()); + std::string vName = StringHelper::Sprintf("%s/%s", (GetParentFolderName(res).c_str()), dListDecl->varName.c_str()); uint64_t hash = CRC64(vName.c_str()); @@ -467,7 +453,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); - if (files.find(fName) == files.end() && !File::Exists("Extract\\" + fName)) + if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) { MemoryStream* dlStream = new MemoryStream(); BinaryWriter dlWriter = BinaryWriter(dlStream); @@ -475,7 +461,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina Save(dList->otherDLists[i], outPath, &dlWriter); if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - File::WriteAllBytes("Extract\\" + fName, dlStream->ToVector()); + File::WriteAllBytes("Extract/" + fName, dlStream->ToVector()); else files[fName] = dlStream->ToVector(); } @@ -533,7 +519,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina int32_t bb = ((data & 0x0000FF0000000000ULL) >> 40) / 2; int32_t cc = ((data & 0x000000FF00000000ULL) >> 32) / 2; int32_t dd = ((data & 0x000000000000FFULL)) / 2; - + Gfx test = gsSP1Quadrangle(aa, bb, cc, dd, 0); word0 = test.words.w0; word1 = test.words.w1; @@ -689,7 +675,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina uint32_t fmt = (__ & 0xE0) >> 5; uint32_t siz = (__ & 0x18) >> 3; - Gfx value = gsDPSetTextureImage(fmt, siz, www + 1, (seg & 0x0FFFFFFF) + 0xF0000000); + Gfx value = gsDPSetTextureImage(fmt, siz, www + 1, (seg & 0x0FFFFFFF) + 1); word0 = value.words.w0; word1 = value.words.w1; @@ -721,7 +707,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina ZFile* assocFile = Globals::Instance->GetSegment(GETSEGNUM(seg), res->parent->workerID); std::string assocFileName = assocFile->GetName(); std::string fName = ""; - + if (GETSEGNUM(seg) == SEGMENT_SCENE || GETSEGNUM(seg) == SEGMENT_ROOM) fName = GetPathToRes(res, texName.c_str()); else @@ -753,7 +739,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina Gfx value = gsSPVertex(data & 0xFFFFFFFF, nn, ((aa >> 1) - nn)); word0 = value.words.w0; - word1 = value.words.w1 | 0xF0000000; + word1 = value.words.w1 | 1; } else { @@ -790,7 +776,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina word0 = hash >> 32; word1 = hash & 0xFFFFFFFF; - if (files.find(fName) == files.end() && !File::Exists("Extract\\" + fName)) + if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) { // Write vertices to file MemoryStream* vtxStream = new MemoryStream(); @@ -800,7 +786,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina auto split = StringHelper::Split(vtxDecl->text, "\n"); - for (int i = 0; i < split.size(); i++) + for (size_t i = 0; i < split.size(); i++) { std::string line = split[i]; @@ -842,7 +828,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina } if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - File::WriteAllBytes("Extract\\" + fName, vtxStream->ToVector()); + File::WriteAllBytes("Extract/" + fName, vtxStream->ToVector()); else files[fName] = vtxStream->ToVector(); @@ -858,7 +844,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina } break; } - + writer->Write(word0); writer->Write(word1); } @@ -872,7 +858,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina std::string OTRExporter_DisplayList::GetPathToRes(ZResource* res, std::string varName) { std::string prefix = GetPrefix(res); - std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), varName.c_str()); + std::string fName = StringHelper::Sprintf("%s/%s", GetParentFolderName(res).c_str(), varName.c_str()); return fName; } @@ -886,7 +872,7 @@ std::string OTRExporter_DisplayList::GetParentFolderName(ZResource* res) { auto split = StringHelper::Split(oName, "_"); oName = ""; - for (int i = 0; i < split.size() - 1; i++) + for (size_t i = 0; i < split.size() - 1; i++) oName += split[i] + "_"; oName += "scene"; @@ -897,7 +883,7 @@ std::string OTRExporter_DisplayList::GetParentFolderName(ZResource* res) } if (prefix != "") - oName = prefix + "\\" + oName; + oName = prefix + "/" + oName; return oName; } diff --git a/OTRExporter/OTRExporter/Main.cpp b/OTRExporter/OTRExporter/Main.cpp index a58f94ae3..2ed9cb427 100644 --- a/OTRExporter/OTRExporter/Main.cpp +++ b/OTRExporter/OTRExporter/Main.cpp @@ -52,7 +52,7 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM for (auto item : lst) { auto fileData = File::ReadAllBytes(item); - otrArchive->AddFile(StringHelper::Split(item, "Extract\\")[1], (uintptr_t)fileData.data(), fileData.size()); + otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); } } } @@ -76,7 +76,7 @@ static void ExporterProgramEnd() for (auto item : lst) { auto fileData = File::ReadAllBytes(item); - otrArchive->AddFile(StringHelper::Split(item, "Extract\\")[1], (uintptr_t)fileData.data(), fileData.size()); + otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); } otrArchive->AddFile("Audiobank", (uintptr_t)Globals::Instance->GetBaseromFile("Audiobank").data(), Globals::Instance->GetBaseromFile("Audiobank").size()); @@ -117,7 +117,7 @@ static void ExporterFileBegin(ZFile* file) static void ExporterFileEnd(ZFile* file) { - int bp = 0; + // delete fileWriter; } static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer) @@ -140,7 +140,7 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer) { auto split = StringHelper::Split(oName, "_"); oName = ""; - for (int i = 0; i < split.size() - 1; i++) + for (size_t i = 0; i < split.size() - 1; i++) oName += split[i] + "_"; oName += "scene"; @@ -153,14 +153,14 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer) std::string fName = ""; if (prefix != "") - fName = StringHelper::Sprintf("%s\\%s\\%s", prefix.c_str(), oName.c_str(), rName.c_str()); + fName = StringHelper::Sprintf("%s/%s/%s", prefix.c_str(), oName.c_str(), rName.c_str()); else - fName = StringHelper::Sprintf("%s\\%s", oName.c_str(), rName.c_str()); + fName = StringHelper::Sprintf("%s/%s", oName.c_str(), rName.c_str()); if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) files[fName] = strem->ToVector(); else - File::WriteAllBytes("Extract\\" + fName, strem->ToVector()); + File::WriteAllBytes("Extract/" + fName, strem->ToVector()); } auto end = std::chrono::steady_clock::now(); diff --git a/OTRExporter/OTRExporter/Makefile b/OTRExporter/OTRExporter/Makefile index 1c4e61bf2..954b183a3 100644 --- a/OTRExporter/OTRExporter/Makefile +++ b/OTRExporter/OTRExporter/Makefile @@ -39,13 +39,13 @@ D_FILES := $(O_FILES:%.o=%.d) LIB := OTRExporter.a INC_DIRS := $(addprefix -I, \ - ../../ZAPD/ZAPD \ - ../../ZAPD/lib/tinyxml2 \ - ../../ZAPD/lib/libgfxd \ - ../../ZAPD/ZAPDUtils \ - ../../OtrLib/otrlib \ - ../../OtrLib/otrlib/Lib/spdlog/include \ - ../../OtrLib/otrlib/Lib/Fast3D/U64 \ + ../../ZAPDTR/ZAPD \ + ../../ZAPDTR/lib/tinyxml2 \ + ../../ZAPDTR/lib/libgfxd \ + ../../ZAPDTR/ZAPDUtils \ + ../../libultraship/libultraship \ + ../../libultraship/libultraship/Lib/spdlog/include \ + ../../libultraship/libultraship/Lib/Fast3D/U64 \ ) # create build directories diff --git a/OTRExporter/OTRExporter/PathExporter.cpp b/OTRExporter/OTRExporter/PathExporter.cpp index de15789ab..75f6b723f 100644 --- a/OTRExporter/OTRExporter/PathExporter.cpp +++ b/OTRExporter/OTRExporter/PathExporter.cpp @@ -9,11 +9,11 @@ void OTRExporter_Path::Save(ZResource* res, const fs::path& outPath, BinaryWrite writer->Write((uint32_t)path->pathways.size()); - for (int k = 0; k < path->pathways.size(); k++) + for (size_t k = 0; k < path->pathways.size(); k++) { writer->Write((uint32_t)path->pathways[k].points.size()); - for (int i = 0; i < path->pathways[k].points.size(); i++) + for (size_t i = 0; i < path->pathways[k].points.size(); i++) { writer->Write(path->pathways[k].points[i].scalars[0].scalarData.s16); writer->Write(path->pathways[k].points[i].scalars[1].scalarData.s16); diff --git a/OTRExporter/OTRExporter/RoomExporter.cpp b/OTRExporter/OTRExporter/RoomExporter.cpp index 5b7ce4323..9a5704bbc 100644 --- a/OTRExporter/OTRExporter/RoomExporter.cpp +++ b/OTRExporter/OTRExporter/RoomExporter.cpp @@ -46,7 +46,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite for (size_t i = 0; i < room->commands.size(); i++) { ZRoomCommand* cmd = room->commands[i]; - + writer->Write((uint32_t)cmd->cmdID); switch (cmd->cmdID) @@ -172,7 +172,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite writer->Write((uint32_t)cmdCsCam->points.size()); - for (int i = 0; i < cmdCsCam->points.size(); i++) + for (size_t i = 0; i < cmdCsCam->points.size(); i++) { writer->Write(cmdCsCam->points[i].scalars[0].scalarData.s16); writer->Write(cmdCsCam->points[i].scalars[1].scalarData.s16); @@ -183,7 +183,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite case RoomCommand::SetMesh: { SetMesh* cmdMesh = (SetMesh*)cmd; - + writer->Write((uint8_t)cmdMesh->data); // 0x01 writer->Write(cmdMesh->meshHeaderType); @@ -207,12 +207,12 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite Declaration* dListDeclXlu = poly->parent->GetDeclaration(GETSEGOFFSET(test->xlu)); if (test->opa != 0) - writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str())); + writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str())); else writer->Write(""); - + if (test->xlu != 0) - writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclXlu->varName.c_str())); + writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclXlu->varName.c_str())); else writer->Write(""); @@ -228,7 +228,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite Declaration* bgDecl = poly->parent->GetDeclarationRanged(GETSEGOFFSET(poly->multiList[i].source)); writer->Write(OTRExporter_DisplayList::GetPathToRes(poly->multiList[i].sourceBackground, bgDecl->varName)); - + writer->Write(poly->multiList[i].unk_0C); writer->Write(poly->multiList[i].tlut); writer->Write(poly->multiList[i].width); @@ -338,7 +338,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite for (size_t i = 0;i < cmdRoom->romfile->numRooms; i++) { - //std::string roomName = StringHelper::Sprintf("%s\\%s_room_%i", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i); + //std::string roomName = StringHelper::Sprintf("%s/%s_room_%i", (StringHelper::Split(room->GetName(), "_")[0] + "_scene").c_str(), StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i); std::string roomName = OTRExporter_DisplayList::GetPathToRes(room, StringHelper::Sprintf("%s_room_%i", StringHelper::Split(room->GetName(), "_scene")[0].c_str(), i)); writer->Write(roomName); writer->Write(cmdRoom->romfile->rooms[i].virtualAddressStart); @@ -383,7 +383,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite uint32_t baseStreamEnd = writer->GetStream().get()->GetLength(); writer->Write((uint32_t)cmdStartPos->actors.size()); // 0x01 - + for (const ActorSpawnEntry& entry : cmdStartPos->actors) { writer->Write(entry.actorNum); @@ -441,7 +441,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite case RoomCommand::SetCutscenes: { SetCutscenes* cmdSetCutscenes = (SetCutscenes*)cmd; - + std::string listName; Globals::Instance->GetSegmentedPtrName(cmdSetCutscenes->cmdArg2, room->parent, "CutsceneData", listName, res->parent->workerID); std::string fName = OTRExporter_DisplayList::GetPathToRes(room, listName); @@ -452,9 +452,9 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite BinaryWriter csWriter = BinaryWriter(csStream); OTRExporter_Cutscene cs; cs.Save(cmdSetCutscenes->cutscenes[0], "", &csWriter); - + if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - File::WriteAllBytes("Extract\\" + fName, csStream->ToVector()); + File::WriteAllBytes("Extract/" + fName, csStream->ToVector()); else files[fName] = csStream->ToVector(); @@ -468,7 +468,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite writer->Write((uint32_t)cmdSetPathways->pathwayList.pathways.size()); - for (int i = 0; i < cmdSetPathways->pathwayList.pathways.size(); i++) + for (size_t i = 0; i < cmdSetPathways->pathwayList.pathways.size(); i++) { Declaration* decl = room->parent->GetDeclaration(GETSEGOFFSET(cmdSetPathways->pathwayList.pathways[i].listSegmentAddress)); //std::string path = StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), decl->varName.c_str()); @@ -481,7 +481,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite pathExp.Save(&cmdSetPathways->pathwayList, outPath, &pathWriter); if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - File::WriteAllBytes("Extract\\" + path, pathStream->ToVector()); + File::WriteAllBytes("Extract/" + path, pathStream->ToVector()); else files[path] = pathStream->ToVector(); @@ -514,12 +514,12 @@ void OTRExporter_Room::WritePolyDList(BinaryWriter* writer, ZRoom* room, Polygon writer->Write(dlist->unk_06); [[fallthrough]]; default: - //writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str())); + //writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(res).c_str(), dListDeclOpa->varName.c_str())); if (dlist->opaDList != nullptr) { auto opaDecl = room->parent->GetDeclaration(GETSEGOFFSET(dlist->opaDList->GetRawDataIndex())); - writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), opaDecl->varName.c_str())); + writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), opaDecl->varName.c_str())); } else writer->Write(""); @@ -527,7 +527,7 @@ void OTRExporter_Room::WritePolyDList(BinaryWriter* writer, ZRoom* room, Polygon if (dlist->xluDList != nullptr) { auto xluDecl = room->parent->GetDeclaration(GETSEGOFFSET(dlist->xluDList->GetRawDataIndex())); - writer->Write(StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), xluDecl->varName.c_str())); + writer->Write(StringHelper::Sprintf("%s/%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), xluDecl->varName.c_str())); } else writer->Write(""); diff --git a/OTRExporter/OTRExporter/TextExporter.cpp b/OTRExporter/OTRExporter/TextExporter.cpp index 19bc0ced1..5819b9b33 100644 --- a/OTRExporter/OTRExporter/TextExporter.cpp +++ b/OTRExporter/OTRExporter/TextExporter.cpp @@ -8,8 +8,8 @@ void OTRExporter_Text::Save(ZResource* res, const fs::path& outPath, BinaryWrite WriteHeader(txt, outPath, writer, Ship::ResourceType::Text); writer->Write((uint32_t)txt->messages.size()); - - for (int i = 0; i < txt->messages.size(); i++) + + for (size_t i = 0; i < txt->messages.size(); i++) { writer->Write(txt->messages[i].id); writer->Write(txt->messages[i].textboxType); diff --git a/OTRExporter/OTRExporter/VersionInfo.cpp b/OTRExporter/OTRExporter/VersionInfo.cpp index 9b684d22b..0a2004673 100644 --- a/OTRExporter/OTRExporter/VersionInfo.cpp +++ b/OTRExporter/OTRExporter/VersionInfo.cpp @@ -5,21 +5,23 @@ std::map resourceVersions; void InitVersionInfo() { - resourceVersions[Ship::ResourceType::Animation] = 0; - resourceVersions[Ship::ResourceType::Model] = 0; - resourceVersions[Ship::ResourceType::Texture] = 0; - resourceVersions[Ship::ResourceType::Material] = 0; - resourceVersions[Ship::ResourceType::PlayerAnimation] = 0; - resourceVersions[Ship::ResourceType::DisplayList] = 0; - resourceVersions[Ship::ResourceType::Room] = 0; - resourceVersions[Ship::ResourceType::CollisionHeader] = 0; - resourceVersions[Ship::ResourceType::Skeleton] = 0; - resourceVersions[Ship::ResourceType::SkeletonLimb] = 0; - resourceVersions[Ship::ResourceType::Matrix] = 0; - resourceVersions[Ship::ResourceType::Path] = 0; - resourceVersions[Ship::ResourceType::Vertex] = 0; - resourceVersions[Ship::ResourceType::Cutscene] = 0; - resourceVersions[Ship::ResourceType::Array] = 0; - resourceVersions[Ship::ResourceType::Text] = 0; - resourceVersions[Ship::ResourceType::Blob] = 0; + resourceVersions = { + { Ship::ResourceType::Animation, 0 }, + { Ship::ResourceType::Model, 0 }, + { Ship::ResourceType::Texture, 0 }, + { Ship::ResourceType::Material, 0 }, + { Ship::ResourceType::PlayerAnimation, 0 }, + { Ship::ResourceType::DisplayList, 0 }, + { Ship::ResourceType::Room, 0 }, + { Ship::ResourceType::CollisionHeader, 0 }, + { Ship::ResourceType::Skeleton, 0 }, + { Ship::ResourceType::SkeletonLimb, 0 }, + { Ship::ResourceType::Matrix, 0 }, + { Ship::ResourceType::Path, 0 }, + { Ship::ResourceType::Vertex, 0 }, + { Ship::ResourceType::Cutscene, 0 }, + { Ship::ResourceType::Array, 0 }, + { Ship::ResourceType::Text, 0 }, + { Ship::ResourceType::Blob, 0 }, + }; } \ No newline at end of file diff --git a/OTRExporter/assets/ship_of_harkinian/fonts/Fipps-Regular.otf b/OTRExporter/assets/ship_of_harkinian/fonts/Fipps-Regular.otf new file mode 100644 index 000000000..9334dad59 Binary files /dev/null and b/OTRExporter/assets/ship_of_harkinian/fonts/Fipps-Regular.otf differ diff --git a/OTRExporter/assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf b/OTRExporter/assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf new file mode 100644 index 000000000..2442affbf Binary files /dev/null and b/OTRExporter/assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf differ diff --git a/OTRExporter/extract_assets.py b/OTRExporter/extract_assets.py index e33b65f0e..67b4ca6e4 100755 --- a/OTRExporter/extract_assets.py +++ b/OTRExporter/extract_assets.py @@ -1,51 +1,15 @@ #!/usr/bin/env python3 -# How to use: -# Place a rom in this directory then run the script. -# If you are using multiple roms, the script will let you choose one. -# To choose with a commandline argument: -# Python3 extract_assets.py -# Invalid input results in the first rom being selected - -import json, os, signal, time, sys, shutil, glob -from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError -from enum import Enum +import os, sys, shutil import shutil - -romVer = "..\\soh\\baserom_non_mq.z64" -roms = []; -checksums = ["", "", ""]; - -class Checksums(Enum): - OOT_NTSC_10 = "EC7011B7" - OOT_NTSC_11 = "D43DA81F" - OOT_NTSC_12 = "693BA2AE" - OOT_PAL_10 = "B044B569" - OOT_PAL_11 = "B2055FBD" - OOT_NTSC_JP_GC_CE = "F7F52DB8" - OOT_NTSC_JP_GC = "F611F4BA" - OOT_NTSC_US_GC = "F3DD35BA" - OOT_PAL_GC = "09465AC3" - OOT_NTSC_JP_MQ = "F43B45BA" - OOT_NTSC_US_MQ = "F034001A" - OOT_PAL_MQ = "1D4136F3" - OOT_PAL_GC_DBG1 = "871E1C92" - OOT_PAL_GC_DBG2 = "87121EFE" - OOT_PAL_GC_MQ_DBG = "917D18F6" - OOT_IQUE_TW = "3D81FB3E" - OOT_IQUE_CN = "B1E1E07B" - OOT_UNKNOWN = "FFFFFFFF" - -CompatibleChecksums = [ - Checksums.OOT_PAL_GC, - Checksums.OOT_PAL_GC_DBG1 -] +from rom_info import Z64Rom +import rom_chooser def BuildOTR(xmlPath, rom): shutil.copytree("assets", "Extract/assets") - execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out" - execStr += " ed -i %s -b %s -fl CFG\\filelists -o placeholder -osf placeholder -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, rom) + execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out" + execStr += " ed -i %s -b %s -fl CFG/filelists -o placeholder -osf placeholder -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, rom) print(execStr) exitValue = os.system(execStr) @@ -55,95 +19,14 @@ def BuildOTR(xmlPath, rom): print("Aborting...", file=os.sys.stderr) print("\n") -def checkChecksum(rom): - r = open(rom, "rb") - r.seek(16) - bytes = r.read(4).hex().upper() - r.close() - - for checksum in Checksums: - if (checksum.value == bytes): - - for compat in CompatibleChecksums: - if (checksum.name == compat.name): - print("Compatible rom found!") - return checksum - print("Valid oot rom found. However, not compatible with SoH.") - print("Compatible roms:") - for compat in CompatibleChecksums: - print(compat.name+" | 0x"+compat.value) - sys.exit(1) - - print("Wrong rom! No valid checksum found") - sys.exit(1) - def main(): - - romToUse = ""; - - for file in glob.glob("*.z64"): - roms.append(file) - - if not (roms): - print("Error: No roms located, place one in the OTRExporter directory", file=os.sys.stderr) - sys.exit(1) - - if (len(roms) > 1): - - # If commandline args exist - if (len(sys.argv) > 1): - try: - if ((int(sys.argv[1]) - 1) < 1): - romToUse = roms[0] - - elif ((int(sys.argv[1]) - 1) > len(roms)): - romToUse = roms[len(roms) - 1] - - else: - romToUse = roms[int(sys.argv[1]) - 1] - except: - romToUse = roms[0] - - # No commandline args, select rom using user input - else: - - print(str(len(roms))+" roms found, please select one by pressing 1-"+str(len(roms))) - - count = 1 - for list in range(len(roms)): - print(str(count)+". "+roms[list]) - count += 1 - - while(1): - try: - selection = int(input()) - except: - print("Bad input. Try again with the number keys.") - continue - - if (selection < 1 or selection > len(roms)): - print("Bad input. Try again.") - continue - - else: break - - romToUse = roms[selection - 1] - - else: - romToUse = roms[0] - - match checkChecksum(romToUse): - case Checksums.OOT_PAL_GC: - xmlVer = "GC_NMQ_PAL_F" - case Checksums.OOT_PAL_GC_DBG1: - xmlVer = "GC_NMQ_D" - case _: # default case - xmlVer = "GC_MQ_D" + rom_path = rom_chooser.chooseROM() + rom = Z64Rom(rom_path) if (os.path.exists("Extract")): shutil.rmtree("Extract") - - BuildOTR("..\\soh\\assets\\xml\\" + xmlVer + "\\", romToUse) + + BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path) if __name__ == "__main__": main() diff --git a/OTRExporter/extract_assets_old.py b/OTRExporter/extract_assets_old.py deleted file mode 100644 index 2922bbf06..000000000 --- a/OTRExporter/extract_assets_old.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python3 - -import argparse, json, os, signal, time, sys, shutil -from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError -import shutil - -def SignalHandler(sig, frame): - print(f'Signal {sig} received. Aborting...') - mainAbort.set() - # Don't exit immediately to update the extracted assets file. - -def BuildOTR(): - shutil.copyfile("baserom/Audiobank", "Extract/Audiobank") - shutil.copyfile("baserom/Audioseq", "Extract/Audioseq") - shutil.copyfile("baserom/Audiotable", "Extract/Audiotable") - - shutil.copytree("assets", "Extract/assets") - - execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out" - - execStr += " botr -se OTR" - - print(execStr) - exitValue = os.system(execStr) - if exitValue != 0: - print("\n") - print("Error when building the OTR file...", file=os.sys.stderr) - print("Aborting...", file=os.sys.stderr) - print("\n") - -def ExtractFile(xmlPath, outputPath, outputSourcePath): - execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out" - execStr += " e -eh -i %s -b baserom/ -o %s -osf %s -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, outputPath, outputSourcePath) - - if "overlays" in xmlPath: - execStr += " --static" - - print(execStr) - exitValue = os.system(execStr) - #exitValue = 0 - if exitValue != 0: - print("\n") - print("Error when extracting from file " + xmlPath, file=os.sys.stderr) - print("Aborting...", file=os.sys.stderr) - print("\n") - -def ExtractFunc(fullPath): - *pathList, xmlName = fullPath.split(os.sep) - objectName = os.path.splitext(xmlName)[0] - - outPath = os.path.join("..\\soh\\assets\\", *pathList[5:], objectName) - os.makedirs(outPath, exist_ok=True) - outSourcePath = outPath - - ExtractFile(fullPath, outPath, outSourcePath) - -def initializeWorker(abort, test): - global globalAbort - globalAbort = abort - - -def main(): - parser = argparse.ArgumentParser(description="baserom asset extractor") - parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep") - parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones.", action="store_true") - parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true") - parser.add_argument("-v", "--version", help="Sets game version.") - args = parser.parse_args() - - global mainAbort - mainAbort = Event() - manager = Manager() - signal.signal(signal.SIGINT, SignalHandler) - - extractedAssetsTracker = manager.dict() - - xmlVer = "GC_NMQ_D" - - if (args.version == "gc_pal_nmpq"): - xmlVer = "GC_NMQ_PAL_F" - elif (args.version == "dbg_mq"): - xmlVer = "GC_MQ_D" - - asset_path = args.single - if asset_path is not None: - fullPath = os.path.join("..\\soh\\assets", "xml", asset_path + ".xml") - if not os.path.exists(fullPath): - print(f"Error. File {fullPath} doesn't exists.", file=os.sys.stderr) - exit(1) - - ExtractFunc(fullPath) - else: - extract_text_path = "assets/text/message_data.h" - if os.path.isfile(extract_text_path): - extract_text_path = None - extract_staff_text_path = "assets/text/message_data_staff.h" - if os.path.isfile(extract_staff_text_path): - extract_staff_text_path = None - - xmlFiles = [] - for currentPath, _, files in os.walk(os.path.join("..\\soh\\assets\\xml\\", xmlVer)): - for file in files: - fullPath = os.path.join(currentPath, file) - if file.endswith(".xml"): - xmlFiles.append(fullPath) - - try: - numCores = 2 - print("Extracting assets with " + str(numCores) + " CPU cores.") - with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, 0)) as p: - p.map(ExtractFunc, xmlFiles) - except Exception as e: - print("Warning: Multiprocessing exception ocurred.", file=os.sys.stderr) - print("Disabling mutliprocessing.", file=os.sys.stderr) - - initializeWorker(mainAbort, 0) - for singlePath in xmlFiles: - ExtractFunc(singlePath) - - - BuildOTR() - shutil.rmtree("Extract") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/OTRExporter/extract_baserom.py b/OTRExporter/extract_baserom.py new file mode 100644 index 000000000..f387df57a --- /dev/null +++ b/OTRExporter/extract_baserom.py @@ -0,0 +1,53 @@ +#!/usr/bin/python3 + +import os +import sys +import struct +from multiprocessing import Pool, cpu_count +from rom_info import Z64Rom +import rom_chooser + + +rom = None + +def initialize_worker(input_rom): + global rom + rom = input_rom + +def ExtractFunc(i): + + dma_file = rom.getDmaEntryByIndex(i) + dma_data = rom.readDmaEntry(dma_file) + + filename = '../soh/baserom/' + rom.version.file_table[i] + print('extracting ' + filename + " (0x%08X, 0x%08X)" % (dma_file.virtStart, dma_file.virtEnd)) + + try: + with open(filename, 'wb') as f: + f.write(dma_data) + except IOError: + print('failed to write file ' + filename) + + # TODO: handle this better + if dma_file.compressed: + os.system('tools/yaz0 -d ' + filename + ' ' + filename) + +##################################################################### + +def main(): + try: + os.mkdir('../soh/baserom') + except: + pass + + rom_path = rom_chooser.chooseROM() + input_rom = Z64Rom(rom_path) + + # extract files + num_cores = cpu_count() + print("Extracting baserom with " + str(num_cores) + " CPU cores.") + with Pool(num_cores, initialize_worker, (input_rom,)) as p: + p.map(ExtractFunc, range(len(input_rom.version.file_table))) + +if __name__ == "__main__": + main() diff --git a/OTRExporter/extract_baserom_debug.py b/OTRExporter/extract_baserom_debug.py deleted file mode 100644 index a3eb83a8f..000000000 --- a/OTRExporter/extract_baserom_debug.py +++ /dev/null @@ -1,1608 +0,0 @@ -#!/usr/bin/python3 - -import os -import sys -import struct -from multiprocessing import Pool, cpu_count - - -ROM_FILE_NAME = 'baserom_non_mq.z64' -FILE_TABLE_OFFSET = 0x12F70 - -FILE_NAMES = [ - 'makerom', - 'boot', - 'dmadata', - 'Audiobank', - 'Audioseq', - 'Audiotable', - 'link_animetion', - 'icon_item_static', - 'icon_item_24_static', - 'icon_item_field_static', - 'icon_item_dungeon_static', - 'icon_item_gameover_static', - 'icon_item_nes_static', - 'icon_item_ger_static', - 'icon_item_fra_static', - 'item_name_static', - 'map_name_static', - 'do_action_static', - 'message_static', - 'message_texture_static', - 'nes_font_static', - 'nes_message_data_static', - 'ger_message_data_static', - 'fra_message_data_static', - 'staff_message_data_static', - 'map_grand_static', - 'map_i_static', - 'map_48x85_static', - 'code', - 'ovl_title', - 'ovl_select', - 'ovl_opening', - 'ovl_file_choose', - 'ovl_kaleido_scope', - 'ovl_player_actor', - 'ovl_map_mark_data', - 'ovl_En_Test', - 'ovl_Arms_Hook', - 'ovl_Arrow_Fire', - 'ovl_Arrow_Ice', - 'ovl_Arrow_Light', - 'ovl_Bg_Bdan_Objects', - 'ovl_Bg_Bdan_Switch', - 'ovl_Bg_Bom_Guard', - 'ovl_Bg_Bombwall', - 'ovl_Bg_Bowl_Wall', - 'ovl_Bg_Breakwall', - 'ovl_Bg_Ddan_Jd', - 'ovl_Bg_Ddan_Kd', - 'ovl_Bg_Dodoago', - 'ovl_Bg_Dy_Yoseizo', - 'ovl_Bg_Ganon_Otyuka', - 'ovl_Bg_Gate_Shutter', - 'ovl_Bg_Gjyo_Bridge', - 'ovl_Bg_Gnd_Darkmeiro', - 'ovl_Bg_Gnd_Firemeiro', - 'ovl_Bg_Gnd_Iceblock', - 'ovl_Bg_Gnd_Nisekabe', - 'ovl_Bg_Gnd_Soulmeiro', - 'ovl_Bg_Haka', - 'ovl_Bg_Haka_Gate', - 'ovl_Bg_Haka_Huta', - 'ovl_Bg_Haka_Megane', - 'ovl_Bg_Haka_MeganeBG', - 'ovl_Bg_Haka_Sgami', - 'ovl_Bg_Haka_Ship', - 'ovl_Bg_Haka_Trap', - 'ovl_Bg_Haka_Tubo', - 'ovl_Bg_Haka_Water', - 'ovl_Bg_Haka_Zou', - 'ovl_Bg_Heavy_Block', - 'ovl_Bg_Hidan_Curtain', - 'ovl_Bg_Hidan_Dalm', - 'ovl_Bg_Hidan_Firewall', - 'ovl_Bg_Hidan_Fslift', - 'ovl_Bg_Hidan_Fwbig', - 'ovl_Bg_Hidan_Hamstep', - 'ovl_Bg_Hidan_Hrock', - 'ovl_Bg_Hidan_Kousi', - 'ovl_Bg_Hidan_Kowarerukabe', - 'ovl_Bg_Hidan_Rock', - 'ovl_Bg_Hidan_Rsekizou', - 'ovl_Bg_Hidan_Sekizou', - 'ovl_Bg_Hidan_Sima', - 'ovl_Bg_Hidan_Syoku', - 'ovl_Bg_Ice_Objects', - 'ovl_Bg_Ice_Shelter', - 'ovl_Bg_Ice_Shutter', - 'ovl_Bg_Ice_Turara', - 'ovl_Bg_Ingate', - 'ovl_Bg_Jya_1flift', - 'ovl_Bg_Jya_Amishutter', - 'ovl_Bg_Jya_Bigmirror', - 'ovl_Bg_Jya_Block', - 'ovl_Bg_Jya_Bombchuiwa', - 'ovl_Bg_Jya_Bombiwa', - 'ovl_Bg_Jya_Cobra', - 'ovl_Bg_Jya_Goroiwa', - 'ovl_Bg_Jya_Haheniron', - 'ovl_Bg_Jya_Ironobj', - 'ovl_Bg_Jya_Kanaami', - 'ovl_Bg_Jya_Lift', - 'ovl_Bg_Jya_Megami', - 'ovl_Bg_Jya_Zurerukabe', - 'ovl_Bg_Menkuri_Eye', - 'ovl_Bg_Menkuri_Kaiten', - 'ovl_Bg_Menkuri_Nisekabe', - 'ovl_Bg_Mizu_Bwall', - 'ovl_Bg_Mizu_Movebg', - 'ovl_Bg_Mizu_Shutter', - 'ovl_Bg_Mizu_Uzu', - 'ovl_Bg_Mizu_Water', - 'ovl_Bg_Mjin', - 'ovl_Bg_Mori_Bigst', - 'ovl_Bg_Mori_Elevator', - 'ovl_Bg_Mori_Hashigo', - 'ovl_Bg_Mori_Hashira4', - 'ovl_Bg_Mori_Hineri', - 'ovl_Bg_Mori_Idomizu', - 'ovl_Bg_Mori_Kaitenkabe', - 'ovl_Bg_Mori_Rakkatenjo', - 'ovl_Bg_Po_Event', - 'ovl_Bg_Po_Syokudai', - 'ovl_Bg_Pushbox', - 'ovl_Bg_Relay_Objects', - 'ovl_Bg_Spot00_Break', - 'ovl_Bg_Spot00_Hanebasi', - 'ovl_Bg_Spot01_Fusya', - 'ovl_Bg_Spot01_Idohashira', - 'ovl_Bg_Spot01_Idomizu', - 'ovl_Bg_Spot01_Idosoko', - 'ovl_Bg_Spot01_Objects2', - 'ovl_Bg_Spot02_Objects', - 'ovl_Bg_Spot03_Taki', - 'ovl_Bg_Spot05_Soko', - 'ovl_Bg_Spot06_Objects', - 'ovl_Bg_Spot07_Taki', - 'ovl_Bg_Spot08_Bakudankabe', - 'ovl_Bg_Spot08_Iceblock', - 'ovl_Bg_Spot09_Obj', - 'ovl_Bg_Spot11_Bakudankabe', - 'ovl_Bg_Spot11_Oasis', - 'ovl_Bg_Spot12_Gate', - 'ovl_Bg_Spot12_Saku', - 'ovl_Bg_Spot15_Rrbox', - 'ovl_Bg_Spot15_Saku', - 'ovl_Bg_Spot16_Bombstone', - 'ovl_Bg_Spot16_Doughnut', - 'ovl_Bg_Spot17_Bakudankabe', - 'ovl_Bg_Spot17_Funen', - 'ovl_Bg_Spot18_Basket', - 'ovl_Bg_Spot18_Futa', - 'ovl_Bg_Spot18_Obj', - 'ovl_Bg_Spot18_Shutter', - 'ovl_Bg_Sst_Floor', - 'ovl_Bg_Toki_Hikari', - 'ovl_Bg_Toki_Swd', - 'ovl_Bg_Treemouth', - 'ovl_Bg_Umajump', - 'ovl_Bg_Vb_Sima', - 'ovl_Bg_Ydan_Hasi', - 'ovl_Bg_Ydan_Maruta', - 'ovl_Bg_Ydan_Sp', - 'ovl_Bg_Zg', - 'ovl_Boss_Dodongo', - 'ovl_Boss_Fd', - 'ovl_Boss_Fd2', - 'ovl_Boss_Ganon', - 'ovl_Boss_Ganon2', - 'ovl_Boss_Ganondrof', - 'ovl_Boss_Goma', - 'ovl_Boss_Mo', - 'ovl_Boss_Sst', - 'ovl_Boss_Tw', - 'ovl_Boss_Va', - 'ovl_Demo_6K', - 'ovl_Demo_Du', - 'ovl_Demo_Ec', - 'ovl_Demo_Effect', - 'ovl_Demo_Ext', - 'ovl_Demo_Geff', - 'ovl_Demo_Gj', - 'ovl_Demo_Go', - 'ovl_Demo_Gt', - 'ovl_Demo_Ik', - 'ovl_Demo_Im', - 'ovl_Demo_Kankyo', - 'ovl_Demo_Kekkai', - 'ovl_Demo_Sa', - 'ovl_Demo_Shd', - 'ovl_Demo_Tre_Lgt', - 'ovl_Door_Ana', - 'ovl_Door_Gerudo', - 'ovl_Door_Killer', - 'ovl_Door_Shutter', - 'ovl_Door_Toki', - 'ovl_Door_Warp1', - 'ovl_Efc_Erupc', - 'ovl_Eff_Dust', - 'ovl_Effect_Ss_Blast', - 'ovl_Effect_Ss_Bomb', - 'ovl_Effect_Ss_Bomb2', - 'ovl_Effect_Ss_Bubble', - 'ovl_Effect_Ss_D_Fire', - 'ovl_Effect_Ss_Dead_Db', - 'ovl_Effect_Ss_Dead_Dd', - 'ovl_Effect_Ss_Dead_Ds', - 'ovl_Effect_Ss_Dead_Sound', - 'ovl_Effect_Ss_Dt_Bubble', - 'ovl_Effect_Ss_Dust', - 'ovl_Effect_Ss_En_Fire', - 'ovl_Effect_Ss_En_Ice', - 'ovl_Effect_Ss_Extra', - 'ovl_Effect_Ss_Fcircle', - 'ovl_Effect_Ss_Fhg_Flash', - 'ovl_Effect_Ss_Fire_Tail', - 'ovl_Effect_Ss_G_Fire', - 'ovl_Effect_Ss_G_Magma', - 'ovl_Effect_Ss_G_Magma2', - 'ovl_Effect_Ss_G_Ripple', - 'ovl_Effect_Ss_G_Spk', - 'ovl_Effect_Ss_G_Splash', - 'ovl_Effect_Ss_Hahen', - 'ovl_Effect_Ss_HitMark', - 'ovl_Effect_Ss_Ice_Piece', - 'ovl_Effect_Ss_Ice_Smoke', - 'ovl_Effect_Ss_K_Fire', - 'ovl_Effect_Ss_Kakera', - 'ovl_Effect_Ss_KiraKira', - 'ovl_Effect_Ss_Lightning', - 'ovl_Effect_Ss_Sibuki', - 'ovl_Effect_Ss_Sibuki2', - 'ovl_Effect_Ss_Solder_Srch_Ball', - 'ovl_Effect_Ss_Stick', - 'ovl_Effect_Ss_Stone1', - 'ovl_Elf_Msg', - 'ovl_Elf_Msg2', - 'ovl_En_Am', - 'ovl_En_Ani', - 'ovl_En_Anubice', - 'ovl_En_Anubice_Fire', - 'ovl_En_Anubice_Tag', - 'ovl_En_Arow_Trap', - 'ovl_En_Arrow', - 'ovl_En_Attack_Niw', - 'ovl_En_Ba', - 'ovl_En_Bb', - 'ovl_En_Bdfire', - 'ovl_En_Bigokuta', - 'ovl_En_Bili', - 'ovl_En_Bird', - 'ovl_En_Blkobj', - 'ovl_En_Bom', - 'ovl_En_Bom_Bowl_Man', - 'ovl_En_Bom_Bowl_Pit', - 'ovl_En_Bom_Chu', - 'ovl_En_Bombf', - 'ovl_En_Boom', - 'ovl_En_Box', - 'ovl_En_Brob', - 'ovl_En_Bubble', - 'ovl_En_Butte', - 'ovl_En_Bw', - 'ovl_En_Bx', - 'ovl_En_Changer', - 'ovl_En_Clear_Tag', - 'ovl_En_Cow', - 'ovl_En_Crow', - 'ovl_En_Cs', - 'ovl_En_Daiku', - 'ovl_En_Daiku_Kakariko', - 'ovl_En_Dekubaba', - 'ovl_En_Dekunuts', - 'ovl_En_Dh', - 'ovl_En_Dha', - 'ovl_En_Diving_Game', - 'ovl_En_Dns', - 'ovl_En_Dnt_Demo', - 'ovl_En_Dnt_Jiji', - 'ovl_En_Dnt_Nomal', - 'ovl_En_Dodojr', - 'ovl_En_Dodongo', - 'ovl_En_Dog', - 'ovl_En_Door', - 'ovl_En_Ds', - 'ovl_En_Du', - 'ovl_En_Dy_Extra', - 'ovl_En_Eg', - 'ovl_En_Eiyer', - 'ovl_En_Elf', - 'ovl_En_Encount1', - 'ovl_En_Encount2', - 'ovl_En_Ex_Item', - 'ovl_En_Ex_Ruppy', - 'ovl_En_Fd', - 'ovl_En_Fd_Fire', - 'ovl_En_Fhg_Fire', - 'ovl_En_Fire_Rock', - 'ovl_En_Firefly', - 'ovl_En_Fish', - 'ovl_En_Floormas', - 'ovl_En_Fr', - 'ovl_En_Fu', - 'ovl_En_Fw', - 'ovl_En_Fz', - 'ovl_En_G_Switch', - 'ovl_En_Ganon_Mant', - 'ovl_En_Ganon_Organ', - 'ovl_En_Gb', - 'ovl_En_Ge1', - 'ovl_En_Ge2', - 'ovl_En_Ge3', - 'ovl_En_GeldB', - 'ovl_En_GirlA', - 'ovl_En_Gm', - 'ovl_En_Go', - 'ovl_En_Go2', - 'ovl_En_Goma', - 'ovl_En_Goroiwa', - 'ovl_En_Gs', - 'ovl_En_Guest', - 'ovl_En_Hata', - 'ovl_En_Heishi1', - 'ovl_En_Heishi2', - 'ovl_En_Heishi3', - 'ovl_En_Heishi4', - 'ovl_En_Hintnuts', - 'ovl_En_Holl', - 'ovl_En_Honotrap', - 'ovl_En_Horse', - 'ovl_En_Horse_Game_Check', - 'ovl_En_Horse_Ganon', - 'ovl_En_Horse_Link_Child', - 'ovl_En_Horse_Normal', - 'ovl_En_Horse_Zelda', - 'ovl_En_Hs', - 'ovl_En_Hs2', - 'ovl_En_Hy', - 'ovl_En_Ice_Hono', - 'ovl_En_Ik', - 'ovl_En_In', - 'ovl_En_Insect', - 'ovl_En_Ishi', - 'ovl_En_It', - 'ovl_En_Jj', - 'ovl_En_Js', - 'ovl_En_Jsjutan', - 'ovl_En_Kakasi', - 'ovl_En_Kakasi2', - 'ovl_En_Kakasi3', - 'ovl_En_Kanban', - 'ovl_En_Karebaba', - 'ovl_En_Ko', - 'ovl_En_Kusa', - 'ovl_En_Kz', - 'ovl_En_Light', - 'ovl_En_Lightbox', - 'ovl_En_M_Fire1', - 'ovl_En_M_Thunder', - 'ovl_En_Ma1', - 'ovl_En_Ma2', - 'ovl_En_Ma3', - 'ovl_En_Mag', - 'ovl_En_Mb', - 'ovl_En_Md', - 'ovl_En_Mk', - 'ovl_En_Mm', - 'ovl_En_Mm2', - 'ovl_En_Ms', - 'ovl_En_Mu', - 'ovl_En_Nb', - 'ovl_En_Niw', - 'ovl_En_Niw_Girl', - 'ovl_En_Niw_Lady', - 'ovl_En_Nutsball', - 'ovl_En_Nwc', - 'ovl_En_Ny', - 'ovl_En_OE2', - 'ovl_En_Okarina_Effect', - 'ovl_En_Okarina_Tag', - 'ovl_En_Okuta', - 'ovl_En_Ossan', - 'ovl_En_Owl', - 'ovl_En_Part', - 'ovl_En_Peehat', - 'ovl_En_Po_Desert', - 'ovl_En_Po_Field', - 'ovl_En_Po_Relay', - 'ovl_En_Po_Sisters', - 'ovl_En_Poh', - 'ovl_En_Pu_box', - 'ovl_En_Rd', - 'ovl_En_Reeba', - 'ovl_En_River_Sound', - 'ovl_En_Rl', - 'ovl_En_Rr', - 'ovl_En_Ru1', - 'ovl_En_Ru2', - 'ovl_En_Sa', - 'ovl_En_Sb', - 'ovl_En_Scene_Change', - 'ovl_En_Sda', - 'ovl_En_Shopnuts', - 'ovl_En_Si', - 'ovl_En_Siofuki', - 'ovl_En_Skb', - 'ovl_En_Skj', - 'ovl_En_Skjneedle', - 'ovl_En_Ssh', - 'ovl_En_St', - 'ovl_En_Sth', - 'ovl_En_Stream', - 'ovl_En_Sw', - 'ovl_En_Syateki_Itm', - 'ovl_En_Syateki_Man', - 'ovl_En_Syateki_Niw', - 'ovl_En_Ta', - 'ovl_En_Takara_Man', - 'ovl_En_Tana', - 'ovl_En_Tg', - 'ovl_En_Tite', - 'ovl_En_Tk', - 'ovl_En_Torch', - 'ovl_En_Torch2', - 'ovl_En_Toryo', - 'ovl_En_Tp', - 'ovl_En_Tr', - 'ovl_En_Trap', - 'ovl_En_Tubo_Trap', - 'ovl_En_Vali', - 'ovl_En_Vase', - 'ovl_En_Vb_Ball', - 'ovl_En_Viewer', - 'ovl_En_Vm', - 'ovl_En_Wall_Tubo', - 'ovl_En_Wallmas', - 'ovl_En_Weather_Tag', - 'ovl_En_Weiyer', - 'ovl_En_Wf', - 'ovl_En_Wonder_Item', - 'ovl_En_Wonder_Talk', - 'ovl_En_Wonder_Talk2', - 'ovl_En_Wood02', - 'ovl_En_Xc', - 'ovl_En_Yabusame_Mark', - 'ovl_En_Yukabyun', - 'ovl_En_Zf', - 'ovl_En_Zl1', - 'ovl_En_Zl2', - 'ovl_En_Zl3', - 'ovl_En_Zl4', - 'ovl_En_Zo', - 'ovl_En_fHG', - 'ovl_End_Title', - 'ovl_Fishing', - 'ovl_Item_B_Heart', - 'ovl_Item_Etcetera', - 'ovl_Item_Inbox', - 'ovl_Item_Ocarina', - 'ovl_Item_Shield', - 'ovl_Magic_Dark', - 'ovl_Magic_Fire', - 'ovl_Magic_Wind', - 'ovl_Mir_Ray', - 'ovl_Obj_Bean', - 'ovl_Obj_Blockstop', - 'ovl_Obj_Bombiwa', - 'ovl_Obj_Comb', - 'ovl_Obj_Dekujr', - 'ovl_Obj_Elevator', - 'ovl_Obj_Hamishi', - 'ovl_Obj_Hana', - 'ovl_Obj_Hsblock', - 'ovl_Obj_Ice_Poly', - 'ovl_Obj_Kibako', - 'ovl_Obj_Kibako2', - 'ovl_Obj_Lift', - 'ovl_Obj_Lightswitch', - 'ovl_Obj_Makekinsuta', - 'ovl_Obj_Makeoshihiki', - 'ovl_Obj_Mure', - 'ovl_Obj_Mure2', - 'ovl_Obj_Mure3', - 'ovl_Obj_Oshihiki', - 'ovl_Obj_Roomtimer', - 'ovl_Obj_Switch', - 'ovl_Obj_Syokudai', - 'ovl_Obj_Timeblock', - 'ovl_Obj_Tsubo', - 'ovl_Obj_Warp2block', - 'ovl_Object_Kankyo', - 'ovl_Oceff_Spot', - 'ovl_Oceff_Storm', - 'ovl_Oceff_Wipe', - 'ovl_Oceff_Wipe2', - 'ovl_Oceff_Wipe3', - 'ovl_Oceff_Wipe4', - 'ovl_Shot_Sun', - 'gameplay_keep', - 'gameplay_field_keep', - 'gameplay_dangeon_keep', - 'gameplay_object_exchange_static', - 'object_link_boy', - 'object_link_child', - 'object_box', - 'object_human', - 'object_okuta', - 'object_poh', - 'object_wallmaster', - 'object_dy_obj', - 'object_firefly', - 'object_dodongo', - 'object_fire', - 'object_niw', - 'object_tite', - 'object_reeba', - 'object_peehat', - 'object_kingdodongo', - 'object_horse', - 'object_zf', - 'object_goma', - 'object_zl1', - 'object_gol', - 'object_bubble', - 'object_dodojr', - 'object_torch2', - 'object_bl', - 'object_tp', - 'object_oA1', - 'object_st', - 'object_bw', - 'object_ei', - 'object_horse_normal', - 'object_oB1', - 'object_o_anime', - 'object_spot04_objects', - 'object_ddan_objects', - 'object_hidan_objects', - 'object_horse_ganon', - 'object_oA2', - 'object_spot00_objects', - 'object_mb', - 'object_bombf', - 'object_sk2', - 'object_oE1', - 'object_oE_anime', - 'object_oE2', - 'object_ydan_objects', - 'object_gnd', - 'object_am', - 'object_dekubaba', - 'object_oA3', - 'object_oA4', - 'object_oA5', - 'object_oA6', - 'object_oA7', - 'object_jj', - 'object_oA8', - 'object_oA9', - 'object_oB2', - 'object_oB3', - 'object_oB4', - 'object_horse_zelda', - 'object_opening_demo1', - 'object_warp1', - 'object_b_heart', - 'object_dekunuts', - 'object_oE3', - 'object_oE4', - 'object_menkuri_objects', - 'object_oE5', - 'object_oE6', - 'object_oE7', - 'object_oE8', - 'object_oE9', - 'object_oE10', - 'object_oE11', - 'object_oE12', - 'object_vali', - 'object_oA10', - 'object_oA11', - 'object_mizu_objects', - 'object_fhg', - 'object_ossan', - 'object_mori_hineri1', - 'object_Bb', - 'object_toki_objects', - 'object_yukabyun', - 'object_zl2', - 'object_mjin', - 'object_mjin_flash', - 'object_mjin_dark', - 'object_mjin_flame', - 'object_mjin_ice', - 'object_mjin_soul', - 'object_mjin_wind', - 'object_mjin_oka', - 'object_haka_objects', - 'object_spot06_objects', - 'object_ice_objects', - 'object_relay_objects', - 'object_mori_hineri1a', - 'object_mori_hineri2', - 'object_mori_hineri2a', - 'object_mori_objects', - 'object_mori_tex', - 'object_spot08_obj', - 'object_warp2', - 'object_hata', - 'object_bird', - 'object_wood02', - 'object_lightbox', - 'object_pu_box', - 'object_trap', - 'object_vase', - 'object_im', - 'object_ta', - 'object_tk', - 'object_xc', - 'object_vm', - 'object_bv', - 'object_hakach_objects', - 'object_efc_crystal_light', - 'object_efc_fire_ball', - 'object_efc_flash', - 'object_efc_lgt_shower', - 'object_efc_star_field', - 'object_god_lgt', - 'object_light_ring', - 'object_triforce_spot', - 'object_medal', - 'object_bdan_objects', - 'object_sd', - 'object_rd', - 'object_po_sisters', - 'object_heavy_object', - 'object_gndd', - 'object_fd', - 'object_du', - 'object_fw', - 'object_horse_link_child', - 'object_spot02_objects', - 'object_haka', - 'object_ru1', - 'object_syokudai', - 'object_fd2', - 'object_dh', - 'object_rl', - 'object_efc_tw', - 'object_demo_tre_lgt', - 'object_gi_key', - 'object_mir_ray', - 'object_brob', - 'object_gi_jewel', - 'object_spot09_obj', - 'object_spot18_obj', - 'object_bdoor', - 'object_spot17_obj', - 'object_shop_dungen', - 'object_nb', - 'object_mo', - 'object_sb', - 'object_gi_melody', - 'object_gi_heart', - 'object_gi_compass', - 'object_gi_bosskey', - 'object_gi_medal', - 'object_gi_nuts', - 'object_sa', - 'object_gi_hearts', - 'object_gi_arrowcase', - 'object_gi_bombpouch', - 'object_in', - 'object_tr', - 'object_spot16_obj', - 'object_oE1s', - 'object_oE4s', - 'object_os_anime', - 'object_gi_bottle', - 'object_gi_stick', - 'object_gi_map', - 'object_oF1d_map', - 'object_ru2', - 'object_gi_shield_1', - 'object_dekujr', - 'object_gi_magicpot', - 'object_gi_bomb_1', - 'object_oF1s', - 'object_ma2', - 'object_gi_purse', - 'object_hni', - 'object_tw', - 'object_rr', - 'object_bxa', - 'object_anubice', - 'object_gi_gerudo', - 'object_gi_arrow', - 'object_gi_bomb_2', - 'object_gi_egg', - 'object_gi_scale', - 'object_gi_shield_2', - 'object_gi_hookshot', - 'object_gi_ocarina', - 'object_gi_milk', - 'object_ma1', - 'object_ganon', - 'object_sst', - 'object_ny', - 'object_fr', - 'object_gi_pachinko', - 'object_gi_boomerang', - 'object_gi_bow', - 'object_gi_glasses', - 'object_gi_liquid', - 'object_ani', - 'object_demo_6k', - 'object_gi_shield_3', - 'object_gi_letter', - 'object_spot15_obj', - 'object_jya_obj', - 'object_gi_clothes', - 'object_gi_bean', - 'object_gi_fish', - 'object_gi_saw', - 'object_gi_hammer', - 'object_gi_grass', - 'object_gi_longsword', - 'object_spot01_objects', - 'object_md', - 'object_km1', - 'object_kw1', - 'object_zo', - 'object_kz', - 'object_umajump', - 'object_masterkokiri', - 'object_masterkokirihead', - 'object_mastergolon', - 'object_masterzoora', - 'object_aob', - 'object_ik', - 'object_ahg', - 'object_cne', - 'object_gi_niwatori', - 'object_skj', - 'object_gi_bottle_letter', - 'object_bji', - 'object_bba', - 'object_gi_ocarina_0', - 'object_ds', - 'object_ane', - 'object_boj', - 'object_spot03_object', - 'object_spot07_object', - 'object_fz', - 'object_bob', - 'object_ge1', - 'object_yabusame_point', - 'object_gi_boots_2', - 'object_gi_seed', - 'object_gnd_magic', - 'object_d_elevator', - 'object_d_hsblock', - 'object_d_lift', - 'object_mamenoki', - 'object_goroiwa', - 'object_toryo', - 'object_daiku', - 'object_nwc', - 'object_blkobj', - 'object_gm', - 'object_ms', - 'object_hs', - 'object_ingate', - 'object_lightswitch', - 'object_kusa', - 'object_tsubo', - 'object_gi_gloves', - 'object_gi_coin', - 'object_kanban', - 'object_gjyo_objects', - 'object_owl', - 'object_mk', - 'object_fu', - 'object_gi_ki_tan_mask', - 'object_gi_redead_mask', - 'object_gi_skj_mask', - 'object_gi_rabit_mask', - 'object_gi_truth_mask', - 'object_ganon_objects', - 'object_siofuki', - 'object_stream', - 'object_mm', - 'object_fa', - 'object_os', - 'object_gi_eye_lotion', - 'object_gi_powder', - 'object_gi_mushroom', - 'object_gi_ticketstone', - 'object_gi_brokensword', - 'object_js', - 'object_cs', - 'object_gi_prescription', - 'object_gi_bracelet', - 'object_gi_soldout', - 'object_gi_frog', - 'object_mag', - 'object_door_gerudo', - 'object_gt', - 'object_efc_erupc', - 'object_zl2_anime1', - 'object_zl2_anime2', - 'object_gi_golonmask', - 'object_gi_zoramask', - 'object_gi_gerudomask', - 'object_ganon2', - 'object_ka', - 'object_ts', - 'object_zg', - 'object_gi_hoverboots', - 'object_gi_m_arrow', - 'object_ds2', - 'object_ec', - 'object_fish', - 'object_gi_sutaru', - 'object_gi_goddess', - 'object_ssh', - 'object_bigokuta', - 'object_bg', - 'object_spot05_objects', - 'object_spot12_obj', - 'object_bombiwa', - 'object_hintnuts', - 'object_rs', - 'object_spot00_break', - 'object_gla', - 'object_shopnuts', - 'object_geldb', - 'object_gr', - 'object_dog', - 'object_jya_iron', - 'object_jya_door', - 'object_spot01_objects2', - 'object_spot11_obj', - 'object_kibako2', - 'object_dns', - 'object_dnk', - 'object_gi_fire', - 'object_gi_insect', - 'object_gi_butterfly', - 'object_gi_ghost', - 'object_gi_soul', - 'object_bowl', - 'object_po_field', - 'object_demo_kekkai', - 'object_efc_doughnut', - 'object_gi_dekupouch', - 'object_ganon_anime1', - 'object_ganon_anime2', - 'object_ganon_anime3', - 'object_gi_rupy', - 'object_spot01_matoya', - 'object_spot01_matoyab', - 'object_po_composer', - 'object_mu', - 'object_wf', - 'object_skb', - 'object_gj', - 'object_geff', - 'object_haka_door', - 'object_gs', - 'object_ps', - 'object_bwall', - 'object_crow', - 'object_cow', - 'object_cob', - 'object_gi_sword_1', - 'object_door_killer', - 'object_ouke_haka', - 'object_timeblock', - 'object_zl4', - 'g_pn_01', - 'g_pn_02', - 'g_pn_03', - 'g_pn_04', - 'g_pn_05', - 'g_pn_06', - 'g_pn_07', - 'g_pn_08', - 'g_pn_09', - 'g_pn_10', - 'g_pn_11', - 'g_pn_12', - 'g_pn_13', - 'g_pn_14', - 'g_pn_15', - 'g_pn_16', - 'g_pn_17', - 'g_pn_18', - 'g_pn_19', - 'g_pn_20', - 'g_pn_21', - 'g_pn_22', - 'g_pn_23', - 'g_pn_24', - 'g_pn_25', - 'g_pn_26', - 'g_pn_27', - 'g_pn_28', - 'g_pn_29', - 'g_pn_30', - 'g_pn_31', - 'g_pn_32', - 'g_pn_33', - 'g_pn_34', - 'g_pn_35', - 'g_pn_36', - 'g_pn_37', - 'g_pn_38', - 'g_pn_39', - 'g_pn_40', - 'g_pn_41', - 'g_pn_42', - 'g_pn_43', - 'g_pn_44', - 'g_pn_45', - 'g_pn_46', - 'g_pn_47', - 'g_pn_48', - 'g_pn_49', - 'g_pn_50', - 'g_pn_51', - 'g_pn_52', - 'g_pn_53', - 'g_pn_54', - 'g_pn_55', - 'g_pn_56', - 'g_pn_57', - 'z_select_static', - 'nintendo_rogo_static', - 'title_static', - 'parameter_static', - 'vr_fine0_static', - 'vr_fine0_pal_static', - 'vr_fine1_static', - 'vr_fine1_pal_static', - 'vr_fine2_static', - 'vr_fine2_pal_static', - 'vr_fine3_static', - 'vr_fine3_pal_static', - 'vr_cloud0_static', - 'vr_cloud0_pal_static', - 'vr_cloud1_static', - 'vr_cloud1_pal_static', - 'vr_cloud2_static', - 'vr_cloud2_pal_static', - 'vr_cloud3_static', - 'vr_cloud3_pal_static', - 'vr_holy0_static', - 'vr_holy0_pal_static', - 'vr_holy1_static', - 'vr_holy1_pal_static', - 'vr_MDVR_static', - 'vr_MDVR_pal_static', - 'vr_MNVR_static', - 'vr_MNVR_pal_static', - 'vr_RUVR_static', - 'vr_RUVR_pal_static', - 'vr_LHVR_static', - 'vr_LHVR_pal_static', - 'vr_KHVR_static', - 'vr_KHVR_pal_static', - 'vr_K3VR_static', - 'vr_K3VR_pal_static', - 'vr_K4VR_static', - 'vr_K4VR_pal_static', - 'vr_K5VR_static', - 'vr_K5VR_pal_static', - 'vr_SP1a_static', - 'vr_SP1a_pal_static', - 'vr_MLVR_static', - 'vr_MLVR_pal_static', - 'vr_KKRVR_static', - 'vr_KKRVR_pal_static', - 'vr_KR3VR_static', - 'vr_KR3VR_pal_static', - 'vr_IPVR_static', - 'vr_IPVR_pal_static', - 'vr_KSVR_static', - 'vr_KSVR_pal_static', - 'vr_GLVR_static', - 'vr_GLVR_pal_static', - 'vr_ZRVR_static', - 'vr_ZRVR_pal_static', - 'vr_DGVR_static', - 'vr_DGVR_pal_static', - 'vr_ALVR_static', - 'vr_ALVR_pal_static', - 'vr_NSVR_static', - 'vr_NSVR_pal_static', - 'vr_LBVR_static', - 'vr_LBVR_pal_static', - 'vr_TTVR_static', - 'vr_TTVR_pal_static', - 'vr_FCVR_static', - 'vr_FCVR_pal_static', - 'elf_message_field', - 'elf_message_ydan', - 'syotes_scene', - 'syotes_room_0', - 'syotes2_scene', - 'syotes2_room_0', - 'depth_test_scene', - 'depth_test_room_0', - 'spot00_scene', - 'spot00_room_0', - 'spot01_scene', - 'spot01_room_0', - 'spot02_scene', - 'spot02_room_0', - 'spot02_room_1', - 'spot03_scene', - 'spot03_room_0', - 'spot03_room_1', - 'spot04_scene', - 'spot04_room_0', - 'spot04_room_1', - 'spot04_room_2', - 'spot05_scene', - 'spot05_room_0', - 'spot06_scene', - 'spot06_room_0', - 'spot07_scene', - 'spot07_room_0', - 'spot07_room_1', - 'spot08_scene', - 'spot08_room_0', - 'spot09_scene', - 'spot09_room_0', - 'spot10_scene', - 'spot10_room_0', - 'spot10_room_1', - 'spot10_room_2', - 'spot10_room_3', - 'spot10_room_4', - 'spot10_room_5', - 'spot10_room_6', - 'spot10_room_7', - 'spot10_room_8', - 'spot10_room_9', - 'spot11_scene', - 'spot11_room_0', - 'spot12_scene', - 'spot12_room_0', - 'spot12_room_1', - 'spot13_scene', - 'spot13_room_0', - 'spot13_room_1', - 'spot15_scene', - 'spot15_room_0', - 'spot16_scene', - 'spot16_room_0', - 'spot17_scene', - 'spot17_room_0', - 'spot17_room_1', - 'spot18_scene', - 'spot18_room_0', - 'spot18_room_1', - 'spot18_room_2', - 'spot18_room_3', - 'ydan_scene', - 'ydan_room_0', - 'ydan_room_1', - 'ydan_room_2', - 'ydan_room_3', - 'ydan_room_4', - 'ydan_room_5', - 'ydan_room_6', - 'ydan_room_7', - 'ydan_room_8', - 'ydan_room_9', - 'ydan_room_10', - 'ydan_room_11', - 'ddan_scene', - 'ddan_room_0', - 'ddan_room_1', - 'ddan_room_2', - 'ddan_room_3', - 'ddan_room_4', - 'ddan_room_5', - 'ddan_room_6', - 'ddan_room_7', - 'ddan_room_8', - 'ddan_room_9', - 'ddan_room_10', - 'ddan_room_11', - 'ddan_room_12', - 'ddan_room_13', - 'ddan_room_14', - 'ddan_room_15', - 'ddan_room_16', - 'bdan_scene', - 'bdan_room_0', - 'bdan_room_1', - 'bdan_room_2', - 'bdan_room_3', - 'bdan_room_4', - 'bdan_room_5', - 'bdan_room_6', - 'bdan_room_7', - 'bdan_room_8', - 'bdan_room_9', - 'bdan_room_10', - 'bdan_room_11', - 'bdan_room_12', - 'bdan_room_13', - 'bdan_room_14', - 'bdan_room_15', - 'Bmori1_scene', - 'Bmori1_room_0', - 'Bmori1_room_1', - 'Bmori1_room_2', - 'Bmori1_room_3', - 'Bmori1_room_4', - 'Bmori1_room_5', - 'Bmori1_room_6', - 'Bmori1_room_7', - 'Bmori1_room_8', - 'Bmori1_room_9', - 'Bmori1_room_10', - 'Bmori1_room_11', - 'Bmori1_room_12', - 'Bmori1_room_13', - 'Bmori1_room_14', - 'Bmori1_room_15', - 'Bmori1_room_16', - 'Bmori1_room_17', - 'Bmori1_room_18', - 'Bmori1_room_19', - 'Bmori1_room_20', - 'Bmori1_room_21', - 'Bmori1_room_22', - 'HIDAN_scene', - 'HIDAN_room_0', - 'HIDAN_room_1', - 'HIDAN_room_2', - 'HIDAN_room_3', - 'HIDAN_room_4', - 'HIDAN_room_5', - 'HIDAN_room_6', - 'HIDAN_room_7', - 'HIDAN_room_8', - 'HIDAN_room_9', - 'HIDAN_room_10', - 'HIDAN_room_11', - 'HIDAN_room_12', - 'HIDAN_room_13', - 'HIDAN_room_14', - 'HIDAN_room_15', - 'HIDAN_room_16', - 'HIDAN_room_17', - 'HIDAN_room_18', - 'HIDAN_room_19', - 'HIDAN_room_20', - 'HIDAN_room_21', - 'HIDAN_room_22', - 'HIDAN_room_23', - 'HIDAN_room_24', - 'HIDAN_room_25', - 'HIDAN_room_26', - 'MIZUsin_scene', - 'MIZUsin_room_0', - 'MIZUsin_room_1', - 'MIZUsin_room_2', - 'MIZUsin_room_3', - 'MIZUsin_room_4', - 'MIZUsin_room_5', - 'MIZUsin_room_6', - 'MIZUsin_room_7', - 'MIZUsin_room_8', - 'MIZUsin_room_9', - 'MIZUsin_room_10', - 'MIZUsin_room_11', - 'MIZUsin_room_12', - 'MIZUsin_room_13', - 'MIZUsin_room_14', - 'MIZUsin_room_15', - 'MIZUsin_room_16', - 'MIZUsin_room_17', - 'MIZUsin_room_18', - 'MIZUsin_room_19', - 'MIZUsin_room_20', - 'MIZUsin_room_21', - 'MIZUsin_room_22', - 'jyasinzou_scene', - 'jyasinzou_room_0', - 'jyasinzou_room_1', - 'jyasinzou_room_2', - 'jyasinzou_room_3', - 'jyasinzou_room_4', - 'jyasinzou_room_5', - 'jyasinzou_room_6', - 'jyasinzou_room_7', - 'jyasinzou_room_8', - 'jyasinzou_room_9', - 'jyasinzou_room_10', - 'jyasinzou_room_11', - 'jyasinzou_room_12', - 'jyasinzou_room_13', - 'jyasinzou_room_14', - 'jyasinzou_room_15', - 'jyasinzou_room_16', - 'jyasinzou_room_17', - 'jyasinzou_room_18', - 'jyasinzou_room_19', - 'jyasinzou_room_20', - 'jyasinzou_room_21', - 'jyasinzou_room_22', - 'jyasinzou_room_23', - 'jyasinzou_room_24', - 'jyasinzou_room_25', - 'jyasinzou_room_26', - 'jyasinzou_room_27', - 'jyasinzou_room_28', - 'HAKAdan_scene', - 'HAKAdan_room_0', - 'HAKAdan_room_1', - 'HAKAdan_room_2', - 'HAKAdan_room_3', - 'HAKAdan_room_4', - 'HAKAdan_room_5', - 'HAKAdan_room_6', - 'HAKAdan_room_7', - 'HAKAdan_room_8', - 'HAKAdan_room_9', - 'HAKAdan_room_10', - 'HAKAdan_room_11', - 'HAKAdan_room_12', - 'HAKAdan_room_13', - 'HAKAdan_room_14', - 'HAKAdan_room_15', - 'HAKAdan_room_16', - 'HAKAdan_room_17', - 'HAKAdan_room_18', - 'HAKAdan_room_19', - 'HAKAdan_room_20', - 'HAKAdan_room_21', - 'HAKAdan_room_22', - 'HAKAdanCH_scene', - 'HAKAdanCH_room_0', - 'HAKAdanCH_room_1', - 'HAKAdanCH_room_2', - 'HAKAdanCH_room_3', - 'HAKAdanCH_room_4', - 'HAKAdanCH_room_5', - 'HAKAdanCH_room_6', - 'ice_doukutu_scene', - 'ice_doukutu_room_0', - 'ice_doukutu_room_1', - 'ice_doukutu_room_2', - 'ice_doukutu_room_3', - 'ice_doukutu_room_4', - 'ice_doukutu_room_5', - 'ice_doukutu_room_6', - 'ice_doukutu_room_7', - 'ice_doukutu_room_8', - 'ice_doukutu_room_9', - 'ice_doukutu_room_10', - 'ice_doukutu_room_11', - 'men_scene', - 'men_room_0', - 'men_room_1', - 'men_room_2', - 'men_room_3', - 'men_room_4', - 'men_room_5', - 'men_room_6', - 'men_room_7', - 'men_room_8', - 'men_room_9', - 'men_room_10', - 'ganontika_scene', - 'ganontika_room_0', - 'ganontika_room_1', - 'ganontika_room_2', - 'ganontika_room_3', - 'ganontika_room_4', - 'ganontika_room_5', - 'ganontika_room_6', - 'ganontika_room_7', - 'ganontika_room_8', - 'ganontika_room_9', - 'ganontika_room_10', - 'ganontika_room_11', - 'ganontika_room_12', - 'ganontika_room_13', - 'ganontika_room_14', - 'ganontika_room_15', - 'ganontika_room_16', - 'ganontika_room_17', - 'ganontika_room_18', - 'ganontika_room_19', - 'market_day_scene', - 'market_day_room_0', - 'market_night_scene', - 'market_night_room_0', - 'testroom_scene', - 'testroom_room_0', - 'testroom_room_1', - 'testroom_room_2', - 'testroom_room_3', - 'testroom_room_4', - 'kenjyanoma_scene', - 'kenjyanoma_room_0', - 'tokinoma_scene', - 'tokinoma_room_0', - 'tokinoma_room_1', - 'sutaru_scene', - 'sutaru_room_0', - 'link_home_scene', - 'link_home_room_0', - 'kokiri_shop_scene', - 'kokiri_shop_room_0', - 'kokiri_home_scene', - 'kokiri_home_room_0', - 'kakusiana_scene', - 'kakusiana_room_0', - 'kakusiana_room_1', - 'kakusiana_room_2', - 'kakusiana_room_3', - 'kakusiana_room_4', - 'kakusiana_room_5', - 'kakusiana_room_6', - 'kakusiana_room_7', - 'kakusiana_room_8', - 'kakusiana_room_9', - 'kakusiana_room_10', - 'kakusiana_room_11', - 'kakusiana_room_12', - 'kakusiana_room_13', - 'entra_scene', - 'entra_room_0', - 'moribossroom_scene', - 'moribossroom_room_0', - 'moribossroom_room_1', - 'syatekijyou_scene', - 'syatekijyou_room_0', - 'shop1_scene', - 'shop1_room_0', - 'hairal_niwa_scene', - 'hairal_niwa_room_0', - 'ganon_tou_scene', - 'ganon_tou_room_0', - 'sasatest_scene', - 'sasatest_room_0', - 'market_alley_scene', - 'market_alley_room_0', - 'spot20_scene', - 'spot20_room_0', - 'market_ruins_scene', - 'market_ruins_room_0', - 'entra_n_scene', - 'entra_n_room_0', - 'enrui_scene', - 'enrui_room_0', - 'market_alley_n_scene', - 'market_alley_n_room_0', - 'hiral_demo_scene', - 'hiral_demo_room_0', - 'kokiri_home3_scene', - 'kokiri_home3_room_0', - 'malon_stable_scene', - 'malon_stable_room_0', - 'kakariko_scene', - 'kakariko_room_0', - 'bdan_boss_scene', - 'bdan_boss_room_0', - 'bdan_boss_room_1', - 'FIRE_bs_scene', - 'FIRE_bs_room_0', - 'FIRE_bs_room_1', - 'hut_scene', - 'hut_room_0', - 'daiyousei_izumi_scene', - 'daiyousei_izumi_room_0', - 'hakaana_scene', - 'hakaana_room_0', - 'yousei_izumi_tate_scene', - 'yousei_izumi_tate_room_0', - 'yousei_izumi_yoko_scene', - 'yousei_izumi_yoko_room_0', - 'golon_scene', - 'golon_room_0', - 'zoora_scene', - 'zoora_room_0', - 'drag_scene', - 'drag_room_0', - 'alley_shop_scene', - 'alley_shop_room_0', - 'night_shop_scene', - 'night_shop_room_0', - 'impa_scene', - 'impa_room_0', - 'labo_scene', - 'labo_room_0', - 'tent_scene', - 'tent_room_0', - 'nakaniwa_scene', - 'nakaniwa_room_0', - 'ddan_boss_scene', - 'ddan_boss_room_0', - 'ddan_boss_room_1', - 'ydan_boss_scene', - 'ydan_boss_room_0', - 'ydan_boss_room_1', - 'HAKAdan_bs_scene', - 'HAKAdan_bs_room_0', - 'HAKAdan_bs_room_1', - 'MIZUsin_bs_scene', - 'MIZUsin_bs_room_0', - 'MIZUsin_bs_room_1', - 'ganon_scene', - 'ganon_room_0', - 'ganon_room_1', - 'ganon_room_2', - 'ganon_room_3', - 'ganon_room_4', - 'ganon_room_5', - 'ganon_room_6', - 'ganon_room_7', - 'ganon_room_8', - 'ganon_room_9', - 'ganon_boss_scene', - 'ganon_boss_room_0', - 'jyasinboss_scene', - 'jyasinboss_room_0', - 'jyasinboss_room_1', - 'jyasinboss_room_2', - 'jyasinboss_room_3', - 'kokiri_home4_scene', - 'kokiri_home4_room_0', - 'kokiri_home5_scene', - 'kokiri_home5_room_0', - 'ganon_final_scene', - 'ganon_final_room_0', - 'kakariko3_scene', - 'kakariko3_room_0', - 'hairal_niwa2_scene', - 'hairal_niwa2_room_0', - 'hakasitarelay_scene', - 'hakasitarelay_room_0', - 'hakasitarelay_room_1', - 'hakasitarelay_room_2', - 'hakasitarelay_room_3', - 'hakasitarelay_room_4', - 'hakasitarelay_room_5', - 'hakasitarelay_room_6', - 'shrine_scene', - 'shrine_room_0', - 'turibori_scene', - 'turibori_room_0', - 'shrine_n_scene', - 'shrine_n_room_0', - 'shrine_r_scene', - 'shrine_r_room_0', - 'hakaana2_scene', - 'hakaana2_room_0', - 'gerudoway_scene', - 'gerudoway_room_0', - 'gerudoway_room_1', - 'gerudoway_room_2', - 'gerudoway_room_3', - 'gerudoway_room_4', - 'gerudoway_room_5', - 'hairal_niwa_n_scene', - 'hairal_niwa_n_room_0', - 'bowling_scene', - 'bowling_room_0', - 'hakaana_ouke_scene', - 'hakaana_ouke_room_0', - 'hakaana_ouke_room_1', - 'hakaana_ouke_room_2', - 'hylia_labo_scene', - 'hylia_labo_room_0', - 'souko_scene', - 'souko_room_0', - 'souko_room_1', - 'souko_room_2', - 'miharigoya_scene', - 'miharigoya_room_0', - 'mahouya_scene', - 'mahouya_room_0', - 'takaraya_scene', - 'takaraya_room_0', - 'takaraya_room_1', - 'takaraya_room_2', - 'takaraya_room_3', - 'takaraya_room_4', - 'takaraya_room_5', - 'takaraya_room_6', - 'ganon_sonogo_scene', - 'ganon_sonogo_room_0', - 'ganon_sonogo_room_1', - 'ganon_sonogo_room_2', - 'ganon_sonogo_room_3', - 'ganon_sonogo_room_4', - 'ganon_demo_scene', - 'ganon_demo_room_0', - 'besitu_scene', - 'besitu_room_0', - 'face_shop_scene', - 'face_shop_room_0', - 'kinsuta_scene', - 'kinsuta_room_0', - 'ganontikasonogo_scene', - 'ganontikasonogo_room_0', - 'ganontikasonogo_room_1', - 'test01_scene', - 'test01_room_0', - 'bump_texture_static', - 'anime_model_1_static', - 'anime_model_2_static', - 'anime_model_3_static', - 'anime_model_4_static', - 'anime_model_5_static', - 'anime_model_6_static', - 'anime_texture_1_static', - 'anime_texture_2_static', - 'anime_texture_3_static', - 'anime_texture_4_static', - 'anime_texture_5_static', - 'anime_texture_6_static', - 'softsprite_matrix_static', -] - -romData = None - - -def initialize_worker(rom_data): - global romData - romData = rom_data - -def read_uint32_be(offset): - return struct.unpack('>I', romData[offset:offset+4])[0] - -def write_output_file(name, offset, size): - try: - with open(name, 'wb') as f: - f.write(romData[offset:offset+size]) - except IOError: - print('failed to write file ' + name) - -def ExtractFunc(i): - filename = 'baserom/' + FILE_NAMES[i] - entryOffset = FILE_TABLE_OFFSET + 16 * i - - virtStart = read_uint32_be(entryOffset + 0) - virtEnd = read_uint32_be(entryOffset + 4) - physStart = read_uint32_be(entryOffset + 8) - physEnd = read_uint32_be(entryOffset + 12) - - if physEnd == 0: # uncompressed - compressed = False - size = virtEnd - virtStart - else: # compressed - compressed = True - size = physEnd - physStart - - print('extracting ' + filename + " (0x%08X, 0x%08X)" % (virtStart, virtEnd)) - write_output_file(filename, physStart, size) - if compressed: - os.system('tools/yaz0 -d ' + filename + ' ' + filename) - -##################################################################### - -def main(): - try: - os.mkdir('baserom') - except: - pass - - # read baserom data - try: - with open(ROM_FILE_NAME, 'rb') as f: - rom_data = f.read() - except IOError: - print('failed to read ' + ROM_FILE_NAME) - sys.exit(1) - - # extract files - num_cores = cpu_count() - print("Extracting baserom with " + str(num_cores) + " CPU cores.") - with Pool(num_cores, initialize_worker, (rom_data,)) as p: - p.map(ExtractFunc, range(len(FILE_NAMES))) - -if __name__ == "__main__": - main() diff --git a/OTRExporter/extract_baserom_gc.py b/OTRExporter/extract_baserom_gc.py deleted file mode 100644 index 0bc324f81..000000000 --- a/OTRExporter/extract_baserom_gc.py +++ /dev/null @@ -1,1586 +0,0 @@ -#!/usr/bin/python3 - -import os -import sys -import struct -from multiprocessing import Pool, cpu_count - - -ROM_FILE_NAME = 'zlp_f.n64' -FILE_TABLE_OFFSET = 0x7170 - -FILE_NAMES = [ - 'makerom', - 'boot', - 'dmadata', - 'Audiobank', - 'Audioseq', - 'Audiotable', - 'link_animetion', - 'icon_item_static', - 'icon_item_24_static', - 'icon_item_field_static', - 'icon_item_dungeon_static', - 'icon_item_gameover_static', - 'icon_item_nes_static', - 'icon_item_ger_static', - 'icon_item_fra_static', - 'item_name_static', - 'map_name_static', - 'do_action_static', - 'message_static', - 'message_texture_static', - 'nes_font_static', - 'nes_message_data_static', - 'ger_message_data_static', - 'fra_message_data_static', - 'staff_message_data_static', - 'map_grand_static', - 'map_48x85_static', - 'map_i_static', - 'code', - 'ovl_title', - 'ovl_select', - 'ovl_opening', - 'ovl_file_choose', - 'ovl_kaleido_scope', - 'ovl_player_actor', - 'ovl_map_mark_data', - 'ovl_En_Test', - 'ovl_Arms_Hook', - 'ovl_Arrow_Fire', - 'ovl_Arrow_Ice', - 'ovl_Arrow_Light', - 'ovl_Bg_Bdan_Objects', - 'ovl_Bg_Bdan_Switch', - 'ovl_Bg_Bom_Guard', - 'ovl_Bg_Bombwall', - 'ovl_Bg_Bowl_Wall', - 'ovl_Bg_Breakwall', - 'ovl_Bg_Ddan_Jd', - 'ovl_Bg_Ddan_Kd', - 'ovl_Bg_Dodoago', - 'ovl_Bg_Dy_Yoseizo', - 'ovl_Bg_Ganon_Otyuka', - 'ovl_Bg_Gate_Shutter', - 'ovl_Bg_Gjyo_Bridge', - 'ovl_Bg_Gnd_Darkmeiro', - 'ovl_Bg_Gnd_Firemeiro', - 'ovl_Bg_Gnd_Iceblock', - 'ovl_Bg_Gnd_Nisekabe', - 'ovl_Bg_Gnd_Soulmeiro', - 'ovl_Bg_Haka', - 'ovl_Bg_Haka_Gate', - 'ovl_Bg_Haka_Huta', - 'ovl_Bg_Haka_Megane', - 'ovl_Bg_Haka_MeganeBG', - 'ovl_Bg_Haka_Sgami', - 'ovl_Bg_Haka_Ship', - 'ovl_Bg_Haka_Trap', - 'ovl_Bg_Haka_Tubo', - 'ovl_Bg_Haka_Water', - 'ovl_Bg_Haka_Zou', - 'ovl_Bg_Heavy_Block', - 'ovl_Bg_Hidan_Curtain', - 'ovl_Bg_Hidan_Dalm', - 'ovl_Bg_Hidan_Firewall', - 'ovl_Bg_Hidan_Fslift', - 'ovl_Bg_Hidan_Fwbig', - 'ovl_Bg_Hidan_Hamstep', - 'ovl_Bg_Hidan_Hrock', - 'ovl_Bg_Hidan_Kousi', - 'ovl_Bg_Hidan_Kowarerukabe', - 'ovl_Bg_Hidan_Rock', - 'ovl_Bg_Hidan_Rsekizou', - 'ovl_Bg_Hidan_Sekizou', - 'ovl_Bg_Hidan_Sima', - 'ovl_Bg_Hidan_Syoku', - 'ovl_Bg_Ice_Objects', - 'ovl_Bg_Ice_Shelter', - 'ovl_Bg_Ice_Shutter', - 'ovl_Bg_Ice_Turara', - 'ovl_Bg_Ingate', - 'ovl_Bg_Jya_1flift', - 'ovl_Bg_Jya_Amishutter', - 'ovl_Bg_Jya_Bigmirror', - 'ovl_Bg_Jya_Block', - 'ovl_Bg_Jya_Bombchuiwa', - 'ovl_Bg_Jya_Bombiwa', - 'ovl_Bg_Jya_Cobra', - 'ovl_Bg_Jya_Goroiwa', - 'ovl_Bg_Jya_Haheniron', - 'ovl_Bg_Jya_Ironobj', - 'ovl_Bg_Jya_Kanaami', - 'ovl_Bg_Jya_Lift', - 'ovl_Bg_Jya_Megami', - 'ovl_Bg_Jya_Zurerukabe', - 'ovl_Bg_Menkuri_Eye', - 'ovl_Bg_Menkuri_Kaiten', - 'ovl_Bg_Menkuri_Nisekabe', - 'ovl_Bg_Mizu_Bwall', - 'ovl_Bg_Mizu_Movebg', - 'ovl_Bg_Mizu_Shutter', - 'ovl_Bg_Mizu_Uzu', - 'ovl_Bg_Mizu_Water', - 'ovl_Bg_Mjin', - 'ovl_Bg_Mori_Bigst', - 'ovl_Bg_Mori_Elevator', - 'ovl_Bg_Mori_Hashigo', - 'ovl_Bg_Mori_Hashira4', - 'ovl_Bg_Mori_Hineri', - 'ovl_Bg_Mori_Idomizu', - 'ovl_Bg_Mori_Kaitenkabe', - 'ovl_Bg_Mori_Rakkatenjo', - 'ovl_Bg_Po_Event', - 'ovl_Bg_Po_Syokudai', - 'ovl_Bg_Pushbox', - 'ovl_Bg_Relay_Objects', - 'ovl_Bg_Spot00_Break', - 'ovl_Bg_Spot00_Hanebasi', - 'ovl_Bg_Spot01_Fusya', - 'ovl_Bg_Spot01_Idohashira', - 'ovl_Bg_Spot01_Idomizu', - 'ovl_Bg_Spot01_Idosoko', - 'ovl_Bg_Spot01_Objects2', - 'ovl_Bg_Spot02_Objects', - 'ovl_Bg_Spot03_Taki', - 'ovl_Bg_Spot05_Soko', - 'ovl_Bg_Spot06_Objects', - 'ovl_Bg_Spot07_Taki', - 'ovl_Bg_Spot08_Bakudankabe', - 'ovl_Bg_Spot08_Iceblock', - 'ovl_Bg_Spot09_Obj', - 'ovl_Bg_Spot11_Bakudankabe', - 'ovl_Bg_Spot11_Oasis', - 'ovl_Bg_Spot12_Gate', - 'ovl_Bg_Spot12_Saku', - 'ovl_Bg_Spot15_Rrbox', - 'ovl_Bg_Spot15_Saku', - 'ovl_Bg_Spot16_Bombstone', - 'ovl_Bg_Spot16_Doughnut', - 'ovl_Bg_Spot17_Bakudankabe', - 'ovl_Bg_Spot17_Funen', - 'ovl_Bg_Spot18_Basket', - 'ovl_Bg_Spot18_Futa', - 'ovl_Bg_Spot18_Obj', - 'ovl_Bg_Spot18_Shutter', - 'ovl_Bg_Sst_Floor', - 'ovl_Bg_Toki_Hikari', - 'ovl_Bg_Toki_Swd', - 'ovl_Bg_Treemouth', - 'ovl_Bg_Umajump', - 'ovl_Bg_Vb_Sima', - 'ovl_Bg_Ydan_Hasi', - 'ovl_Bg_Ydan_Maruta', - 'ovl_Bg_Ydan_Sp', - 'ovl_Bg_Zg', - 'ovl_Boss_Dodongo', - 'ovl_Boss_Fd', - 'ovl_Boss_Fd2', - 'ovl_Boss_Ganon', - 'ovl_Boss_Ganon2', - 'ovl_Boss_Ganondrof', - 'ovl_Boss_Goma', - 'ovl_Boss_Mo', - 'ovl_Boss_Sst', - 'ovl_Boss_Tw', - 'ovl_Boss_Va', - 'ovl_Demo_6K', - 'ovl_Demo_Du', - 'ovl_Demo_Ec', - 'ovl_Demo_Effect', - 'ovl_Demo_Ext', - 'ovl_Demo_Geff', - 'ovl_Demo_Gj', - 'ovl_Demo_Go', - 'ovl_Demo_Gt', - 'ovl_Demo_Ik', - 'ovl_Demo_Im', - 'ovl_Demo_Kankyo', - 'ovl_Demo_Kekkai', - 'ovl_Demo_Sa', - 'ovl_Demo_Shd', - 'ovl_Demo_Tre_Lgt', - 'ovl_Door_Ana', - 'ovl_Door_Gerudo', - 'ovl_Door_Killer', - 'ovl_Door_Shutter', - 'ovl_Door_Toki', - 'ovl_Door_Warp1', - 'ovl_Efc_Erupc', - 'ovl_Eff_Dust', - 'ovl_Effect_Ss_Blast', - 'ovl_Effect_Ss_Bomb', - 'ovl_Effect_Ss_Bomb2', - 'ovl_Effect_Ss_Bubble', - 'ovl_Effect_Ss_D_Fire', - 'ovl_Effect_Ss_Dead_Db', - 'ovl_Effect_Ss_Dead_Dd', - 'ovl_Effect_Ss_Dead_Ds', - 'ovl_Effect_Ss_Dead_Sound', - 'ovl_Effect_Ss_Dt_Bubble', - 'ovl_Effect_Ss_Dust', - 'ovl_Effect_Ss_En_Fire', - 'ovl_Effect_Ss_En_Ice', - 'ovl_Effect_Ss_Extra', - 'ovl_Effect_Ss_Fcircle', - 'ovl_Effect_Ss_Fhg_Flash', - 'ovl_Effect_Ss_Fire_Tail', - 'ovl_Effect_Ss_G_Fire', - 'ovl_Effect_Ss_G_Magma', - 'ovl_Effect_Ss_G_Magma2', - 'ovl_Effect_Ss_G_Ripple', - 'ovl_Effect_Ss_G_Spk', - 'ovl_Effect_Ss_G_Splash', - 'ovl_Effect_Ss_Hahen', - 'ovl_Effect_Ss_HitMark', - 'ovl_Effect_Ss_Ice_Piece', - 'ovl_Effect_Ss_Ice_Smoke', - 'ovl_Effect_Ss_K_Fire', - 'ovl_Effect_Ss_Kakera', - 'ovl_Effect_Ss_KiraKira', - 'ovl_Effect_Ss_Lightning', - 'ovl_Effect_Ss_Sibuki', - 'ovl_Effect_Ss_Sibuki2', - 'ovl_Effect_Ss_Solder_Srch_Ball', - 'ovl_Effect_Ss_Stick', - 'ovl_Effect_Ss_Stone1', - 'ovl_Elf_Msg', - 'ovl_Elf_Msg2', - 'ovl_En_Am', - 'ovl_En_Ani', - 'ovl_En_Anubice', - 'ovl_En_Anubice_Fire', - 'ovl_En_Anubice_Tag', - 'ovl_En_Arow_Trap', - 'ovl_En_Arrow', - 'ovl_En_Attack_Niw', - 'ovl_En_Ba', - 'ovl_En_Bb', - 'ovl_En_Bdfire', - 'ovl_En_Bigokuta', - 'ovl_En_Bili', - 'ovl_En_Bird', - 'ovl_En_Blkobj', - 'ovl_En_Bom', - 'ovl_En_Bom_Bowl_Man', - 'ovl_En_Bom_Bowl_Pit', - 'ovl_En_Bom_Chu', - 'ovl_En_Bombf', - 'ovl_En_Boom', - 'ovl_En_Box', - 'ovl_En_Brob', - 'ovl_En_Bubble', - 'ovl_En_Butte', - 'ovl_En_Bw', - 'ovl_En_Bx', - 'ovl_En_Changer', - 'ovl_En_Clear_Tag', - 'ovl_En_Cow', - 'ovl_En_Crow', - 'ovl_En_Cs', - 'ovl_En_Daiku', - 'ovl_En_Daiku_Kakariko', - 'ovl_En_Dekubaba', - 'ovl_En_Dekunuts', - 'ovl_En_Dh', - 'ovl_En_Dha', - 'ovl_En_Diving_Game', - 'ovl_En_Dns', - 'ovl_En_Dnt_Demo', - 'ovl_En_Dnt_Jiji', - 'ovl_En_Dnt_Nomal', - 'ovl_En_Dodojr', - 'ovl_En_Dodongo', - 'ovl_En_Dog', - 'ovl_En_Door', - 'ovl_En_Ds', - 'ovl_En_Du', - 'ovl_En_Dy_Extra', - 'ovl_En_Eg', - 'ovl_En_Eiyer', - 'ovl_En_Elf', - 'ovl_En_Encount1', - 'ovl_En_Encount2', - 'ovl_En_Ex_Item', - 'ovl_En_Ex_Ruppy', - 'ovl_En_Fd', - 'ovl_En_Fd_Fire', - 'ovl_En_Fhg_Fire', - 'ovl_En_Fire_Rock', - 'ovl_En_Firefly', - 'ovl_En_Fish', - 'ovl_En_Floormas', - 'ovl_En_Fr', - 'ovl_En_Fu', - 'ovl_En_Fw', - 'ovl_En_Fz', - 'ovl_En_G_Switch', - 'ovl_En_Ganon_Mant', - 'ovl_En_Ganon_Organ', - 'ovl_En_Gb', - 'ovl_En_Ge1', - 'ovl_En_Ge2', - 'ovl_En_Ge3', - 'ovl_En_GeldB', - 'ovl_En_GirlA', - 'ovl_En_Gm', - 'ovl_En_Go', - 'ovl_En_Go2', - 'ovl_En_Goma', - 'ovl_En_Goroiwa', - 'ovl_En_Gs', - 'ovl_En_Guest', - 'ovl_En_Hata', - 'ovl_En_Heishi1', - 'ovl_En_Heishi2', - 'ovl_En_Heishi3', - 'ovl_En_Heishi4', - 'ovl_En_Hintnuts', - 'ovl_En_Holl', - 'ovl_En_Honotrap', - 'ovl_En_Horse', - 'ovl_En_Horse_Game_Check', - 'ovl_En_Horse_Ganon', - 'ovl_En_Horse_Link_Child', - 'ovl_En_Horse_Normal', - 'ovl_En_Horse_Zelda', - 'ovl_En_Hs', - 'ovl_En_Hs2', - 'ovl_En_Hy', - 'ovl_En_Ice_Hono', - 'ovl_En_Ik', - 'ovl_En_In', - 'ovl_En_Insect', - 'ovl_En_Ishi', - 'ovl_En_It', - 'ovl_En_Jj', - 'ovl_En_Js', - 'ovl_En_Jsjutan', - 'ovl_En_Kakasi', - 'ovl_En_Kakasi2', - 'ovl_En_Kakasi3', - 'ovl_En_Kanban', - 'ovl_En_Karebaba', - 'ovl_En_Ko', - 'ovl_En_Kusa', - 'ovl_En_Kz', - 'ovl_En_Light', - 'ovl_En_Lightbox', - 'ovl_En_M_Fire1', - 'ovl_En_M_Thunder', - 'ovl_En_Ma1', - 'ovl_En_Ma2', - 'ovl_En_Ma3', - 'ovl_En_Mag', - 'ovl_En_Mb', - 'ovl_En_Md', - 'ovl_En_Mk', - 'ovl_En_Mm', - 'ovl_En_Mm2', - 'ovl_En_Ms', - 'ovl_En_Mu', - 'ovl_En_Nb', - 'ovl_En_Niw', - 'ovl_En_Niw_Girl', - 'ovl_En_Niw_Lady', - 'ovl_En_Nutsball', - 'ovl_En_Nwc', - 'ovl_En_Ny', - 'ovl_En_OE2', - 'ovl_En_Okarina_Effect', - 'ovl_En_Okarina_Tag', - 'ovl_En_Okuta', - 'ovl_En_Ossan', - 'ovl_En_Owl', - 'ovl_En_Part', - 'ovl_En_Peehat', - 'ovl_En_Po_Desert', - 'ovl_En_Po_Field', - 'ovl_En_Po_Relay', - 'ovl_En_Po_Sisters', - 'ovl_En_Poh', - 'ovl_En_Pu_box', - 'ovl_En_Rd', - 'ovl_En_Reeba', - 'ovl_En_River_Sound', - 'ovl_En_Rl', - 'ovl_En_Rr', - 'ovl_En_Ru1', - 'ovl_En_Ru2', - 'ovl_En_Sa', - 'ovl_En_Sb', - 'ovl_En_Scene_Change', - 'ovl_En_Sda', - 'ovl_En_Shopnuts', - 'ovl_En_Si', - 'ovl_En_Siofuki', - 'ovl_En_Skb', - 'ovl_En_Skj', - 'ovl_En_Skjneedle', - 'ovl_En_Ssh', - 'ovl_En_St', - 'ovl_En_Sth', - 'ovl_En_Stream', - 'ovl_En_Sw', - 'ovl_En_Syateki_Itm', - 'ovl_En_Syateki_Man', - 'ovl_En_Syateki_Niw', - 'ovl_En_Ta', - 'ovl_En_Takara_Man', - 'ovl_En_Tana', - 'ovl_En_Tg', - 'ovl_En_Tite', - 'ovl_En_Tk', - 'ovl_En_Torch', - 'ovl_En_Torch2', - 'ovl_En_Toryo', - 'ovl_En_Tp', - 'ovl_En_Tr', - 'ovl_En_Trap', - 'ovl_En_Tubo_Trap', - 'ovl_En_Vali', - 'ovl_En_Vase', - 'ovl_En_Vb_Ball', - 'ovl_En_Viewer', - 'ovl_En_Vm', - 'ovl_En_Wall_Tubo', - 'ovl_En_Wallmas', - 'ovl_En_Weather_Tag', - 'ovl_En_Weiyer', - 'ovl_En_Wf', - 'ovl_En_Wonder_Item', - 'ovl_En_Wonder_Talk', - 'ovl_En_Wonder_Talk2', - 'ovl_En_Wood02', - 'ovl_En_Xc', - 'ovl_En_Yabusame_Mark', - 'ovl_En_Yukabyun', - 'ovl_En_Zf', - 'ovl_En_Zl1', - 'ovl_En_Zl2', - 'ovl_En_Zl3', - 'ovl_En_Zl4', - 'ovl_En_Zo', - 'ovl_En_fHG', - 'ovl_End_Title', - 'ovl_Fishing', - 'ovl_Item_B_Heart', - 'ovl_Item_Etcetera', - 'ovl_Item_Inbox', - 'ovl_Item_Ocarina', - 'ovl_Item_Shield', - 'ovl_Magic_Dark', - 'ovl_Magic_Fire', - 'ovl_Magic_Wind', - 'ovl_Mir_Ray', - 'ovl_Obj_Bean', - 'ovl_Obj_Blockstop', - 'ovl_Obj_Bombiwa', - 'ovl_Obj_Comb', - 'ovl_Obj_Dekujr', - 'ovl_Obj_Elevator', - 'ovl_Obj_Hamishi', - 'ovl_Obj_Hana', - 'ovl_Obj_Hsblock', - 'ovl_Obj_Ice_Poly', - 'ovl_Obj_Kibako', - 'ovl_Obj_Kibako2', - 'ovl_Obj_Lift', - 'ovl_Obj_Lightswitch', - 'ovl_Obj_Makekinsuta', - 'ovl_Obj_Makeoshihiki', - 'ovl_Obj_Mure', - 'ovl_Obj_Mure2', - 'ovl_Obj_Mure3', - 'ovl_Obj_Oshihiki', - 'ovl_Obj_Roomtimer', - 'ovl_Obj_Switch', - 'ovl_Obj_Syokudai', - 'ovl_Obj_Timeblock', - 'ovl_Obj_Tsubo', - 'ovl_Obj_Warp2block', - 'ovl_Object_Kankyo', - 'ovl_Oceff_Spot', - 'ovl_Oceff_Storm', - 'ovl_Oceff_Wipe', - 'ovl_Oceff_Wipe2', - 'ovl_Oceff_Wipe3', - 'ovl_Oceff_Wipe4', - 'ovl_Shot_Sun', - 'gameplay_keep', - 'gameplay_field_keep', - 'gameplay_dangeon_keep', - 'gameplay_object_exchange_static', - 'object_link_boy', - 'object_link_child', - 'object_box', - 'object_human', - 'object_okuta', - 'object_poh', - 'object_wallmaster', - 'object_dy_obj', - 'object_firefly', - 'object_dodongo', - 'object_fire', - 'object_niw', - 'object_tite', - 'object_reeba', - 'object_peehat', - 'object_kingdodongo', - 'object_horse', - 'object_zf', - 'object_goma', - 'object_zl1', - 'object_gol', - 'object_bubble', - 'object_dodojr', - 'object_torch2', - 'object_bl', - 'object_tp', - 'object_oA1', - 'object_st', - 'object_bw', - 'object_ei', - 'object_horse_normal', - 'object_oB1', - 'object_o_anime', - 'object_spot04_objects', - 'object_ddan_objects', - 'object_hidan_objects', - 'object_horse_ganon', - 'object_oA2', - 'object_spot00_objects', - 'object_mb', - 'object_bombf', - 'object_sk2', - 'object_oE1', - 'object_oE_anime', - 'object_oE2', - 'object_ydan_objects', - 'object_gnd', - 'object_am', - 'object_dekubaba', - 'object_oA3', - 'object_oA4', - 'object_oA5', - 'object_oA6', - 'object_oA7', - 'object_jj', - 'object_oA8', - 'object_oA9', - 'object_oB2', - 'object_oB3', - 'object_oB4', - 'object_horse_zelda', - 'object_opening_demo1', - 'object_warp1', - 'object_b_heart', - 'object_dekunuts', - 'object_oE3', - 'object_oE4', - 'object_menkuri_objects', - 'object_oE5', - 'object_oE6', - 'object_oE7', - 'object_oE8', - 'object_oE9', - 'object_oE10', - 'object_oE11', - 'object_oE12', - 'object_vali', - 'object_oA10', - 'object_oA11', - 'object_mizu_objects', - 'object_fhg', - 'object_ossan', - 'object_mori_hineri1', - 'object_Bb', - 'object_toki_objects', - 'object_yukabyun', - 'object_zl2', - 'object_mjin', - 'object_mjin_flash', - 'object_mjin_dark', - 'object_mjin_flame', - 'object_mjin_ice', - 'object_mjin_soul', - 'object_mjin_wind', - 'object_mjin_oka', - 'object_haka_objects', - 'object_spot06_objects', - 'object_ice_objects', - 'object_relay_objects', - 'object_mori_hineri1a', - 'object_mori_hineri2', - 'object_mori_hineri2a', - 'object_mori_objects', - 'object_mori_tex', - 'object_spot08_obj', - 'object_warp2', - 'object_hata', - 'object_bird', - 'object_wood02', - 'object_lightbox', - 'object_pu_box', - 'object_trap', - 'object_vase', - 'object_im', - 'object_ta', - 'object_tk', - 'object_xc', - 'object_vm', - 'object_bv', - 'object_hakach_objects', - 'object_efc_crystal_light', - 'object_efc_fire_ball', - 'object_efc_flash', - 'object_efc_lgt_shower', - 'object_efc_star_field', - 'object_god_lgt', - 'object_light_ring', - 'object_triforce_spot', - 'object_medal', - 'object_bdan_objects', - 'object_sd', - 'object_rd', - 'object_po_sisters', - 'object_heavy_object', - 'object_gndd', - 'object_fd', - 'object_du', - 'object_fw', - 'object_horse_link_child', - 'object_spot02_objects', - 'object_haka', - 'object_ru1', - 'object_syokudai', - 'object_fd2', - 'object_dh', - 'object_rl', - 'object_efc_tw', - 'object_demo_tre_lgt', - 'object_gi_key', - 'object_mir_ray', - 'object_brob', - 'object_gi_jewel', - 'object_spot09_obj', - 'object_spot18_obj', - 'object_bdoor', - 'object_spot17_obj', - 'object_shop_dungen', - 'object_nb', - 'object_mo', - 'object_sb', - 'object_gi_melody', - 'object_gi_heart', - 'object_gi_compass', - 'object_gi_bosskey', - 'object_gi_medal', - 'object_gi_nuts', - 'object_sa', - 'object_gi_hearts', - 'object_gi_arrowcase', - 'object_gi_bombpouch', - 'object_in', - 'object_tr', - 'object_spot16_obj', - 'object_oE1s', - 'object_oE4s', - 'object_os_anime', - 'object_gi_bottle', - 'object_gi_stick', - 'object_gi_map', - 'object_oF1d_map', - 'object_ru2', - 'object_gi_shield_1', - 'object_dekujr', - 'object_gi_magicpot', - 'object_gi_bomb_1', - 'object_oF1s', - 'object_ma2', - 'object_gi_purse', - 'object_hni', - 'object_tw', - 'object_rr', - 'object_bxa', - 'object_anubice', - 'object_gi_gerudo', - 'object_gi_arrow', - 'object_gi_bomb_2', - 'object_gi_egg', - 'object_gi_scale', - 'object_gi_shield_2', - 'object_gi_hookshot', - 'object_gi_ocarina', - 'object_gi_milk', - 'object_ma1', - 'object_ganon', - 'object_sst', - 'object_ny', - 'object_fr', - 'object_gi_pachinko', - 'object_gi_boomerang', - 'object_gi_bow', - 'object_gi_glasses', - 'object_gi_liquid', - 'object_ani', - 'object_demo_6k', - 'object_gi_shield_3', - 'object_gi_letter', - 'object_spot15_obj', - 'object_jya_obj', - 'object_gi_clothes', - 'object_gi_bean', - 'object_gi_fish', - 'object_gi_saw', - 'object_gi_hammer', - 'object_gi_grass', - 'object_gi_longsword', - 'object_spot01_objects', - 'object_md', - 'object_km1', - 'object_kw1', - 'object_zo', - 'object_kz', - 'object_umajump', - 'object_masterkokiri', - 'object_masterkokirihead', - 'object_mastergolon', - 'object_masterzoora', - 'object_aob', - 'object_ik', - 'object_ahg', - 'object_cne', - 'object_gi_niwatori', - 'object_skj', - 'object_gi_bottle_letter', - 'object_bji', - 'object_bba', - 'object_gi_ocarina_0', - 'object_ds', - 'object_ane', - 'object_boj', - 'object_spot03_object', - 'object_spot07_object', - 'object_fz', - 'object_bob', - 'object_ge1', - 'object_yabusame_point', - 'object_gi_boots_2', - 'object_gi_seed', - 'object_gnd_magic', - 'object_d_elevator', - 'object_d_hsblock', - 'object_d_lift', - 'object_mamenoki', - 'object_goroiwa', - 'object_toryo', - 'object_daiku', - 'object_nwc', - 'object_blkobj', - 'object_gm', - 'object_ms', - 'object_hs', - 'object_ingate', - 'object_lightswitch', - 'object_kusa', - 'object_tsubo', - 'object_gi_gloves', - 'object_gi_coin', - 'object_kanban', - 'object_gjyo_objects', - 'object_owl', - 'object_mk', - 'object_fu', - 'object_gi_ki_tan_mask', - 'object_gi_redead_mask', - 'object_gi_skj_mask', - 'object_gi_rabit_mask', - 'object_gi_truth_mask', - 'object_ganon_objects', - 'object_siofuki', - 'object_stream', - 'object_mm', - 'object_fa', - 'object_os', - 'object_gi_eye_lotion', - 'object_gi_powder', - 'object_gi_mushroom', - 'object_gi_ticketstone', - 'object_gi_brokensword', - 'object_js', - 'object_cs', - 'object_gi_prescription', - 'object_gi_bracelet', - 'object_gi_soldout', - 'object_gi_frog', - 'object_mag', - 'object_door_gerudo', - 'object_gt', - 'object_efc_erupc', - 'object_zl2_anime1', - 'object_zl2_anime2', - 'object_gi_golonmask', - 'object_gi_zoramask', - 'object_gi_gerudomask', - 'object_ganon2', - 'object_ka', - 'object_ts', - 'object_zg', - 'object_gi_hoverboots', - 'object_gi_m_arrow', - 'object_ds2', - 'object_ec', - 'object_fish', - 'object_gi_sutaru', - 'object_gi_goddess', - 'object_ssh', - 'object_bigokuta', - 'object_bg', - 'object_spot05_objects', - 'object_spot12_obj', - 'object_bombiwa', - 'object_hintnuts', - 'object_rs', - 'object_spot00_break', - 'object_gla', - 'object_shopnuts', - 'object_geldb', - 'object_gr', - 'object_dog', - 'object_jya_iron', - 'object_jya_door', - 'object_spot01_objects2', - 'object_spot11_obj', - 'object_kibako2', - 'object_dns', - 'object_dnk', - 'object_gi_fire', - 'object_gi_insect', - 'object_gi_butterfly', - 'object_gi_ghost', - 'object_gi_soul', - 'object_bowl', - 'object_po_field', - 'object_demo_kekkai', - 'object_efc_doughnut', - 'object_gi_dekupouch', - 'object_ganon_anime1', - 'object_ganon_anime2', - 'object_ganon_anime3', - 'object_gi_rupy', - 'object_spot01_matoya', - 'object_spot01_matoyab', - 'object_po_composer', - 'object_mu', - 'object_wf', - 'object_skb', - 'object_gj', - 'object_geff', - 'object_haka_door', - 'object_gs', - 'object_ps', - 'object_bwall', - 'object_crow', - 'object_cow', - 'object_cob', - 'object_gi_sword_1', - 'object_door_killer', - 'object_ouke_haka', - 'object_timeblock', - 'object_zl4', - 'g_pn_01', - 'g_pn_02', - 'g_pn_03', - 'g_pn_04', - 'g_pn_05', - 'g_pn_06', - 'g_pn_07', - 'g_pn_08', - 'g_pn_09', - 'g_pn_10', - 'g_pn_11', - 'g_pn_12', - 'g_pn_13', - 'g_pn_14', - 'g_pn_15', - 'g_pn_16', - 'g_pn_17', - 'g_pn_18', - 'g_pn_19', - 'g_pn_20', - 'g_pn_21', - 'g_pn_22', - 'g_pn_23', - 'g_pn_24', - 'g_pn_25', - 'g_pn_26', - 'g_pn_27', - 'g_pn_28', - 'g_pn_29', - 'g_pn_30', - 'g_pn_31', - 'g_pn_32', - 'g_pn_33', - 'g_pn_34', - 'g_pn_35', - 'g_pn_36', - 'g_pn_37', - 'g_pn_38', - 'g_pn_39', - 'g_pn_40', - 'g_pn_41', - 'g_pn_42', - 'g_pn_43', - 'g_pn_44', - 'g_pn_45', - 'g_pn_46', - 'g_pn_47', - 'g_pn_48', - 'g_pn_49', - 'g_pn_50', - 'g_pn_51', - 'g_pn_52', - 'g_pn_53', - 'g_pn_54', - 'g_pn_55', - 'g_pn_56', - 'g_pn_57', - 'z_select_static', - 'nintendo_rogo_static', - 'title_static', - 'parameter_static', - 'vr_fine0_static', - 'vr_fine0_pal_static', - 'vr_fine1_static', - 'vr_fine1_pal_static', - 'vr_fine2_static', - 'vr_fine2_pal_static', - 'vr_fine3_static', - 'vr_fine3_pal_static', - 'vr_cloud0_static', - 'vr_cloud0_pal_static', - 'vr_cloud1_static', - 'vr_cloud1_pal_static', - 'vr_cloud2_static', - 'vr_cloud2_pal_static', - 'vr_cloud3_static', - 'vr_cloud3_pal_static', - 'vr_holy0_static', - 'vr_holy0_pal_static', - 'vr_holy1_static', - 'vr_holy1_pal_static', - 'vr_MDVR_static', - 'vr_MDVR_pal_static', - 'vr_MNVR_static', - 'vr_MNVR_pal_static', - 'vr_RUVR_static', - 'vr_RUVR_pal_static', - 'vr_LHVR_static', - 'vr_LHVR_pal_static', - 'vr_KHVR_static', - 'vr_KHVR_pal_static', - 'vr_K3VR_static', - 'vr_K3VR_pal_static', - 'vr_K4VR_static', - 'vr_K4VR_pal_static', - 'vr_K5VR_static', - 'vr_K5VR_pal_static', - 'vr_SP1a_static', - 'vr_SP1a_pal_static', - 'vr_MLVR_static', - 'vr_MLVR_pal_static', - 'vr_KKRVR_static', - 'vr_KKRVR_pal_static', - 'vr_KR3VR_static', - 'vr_KR3VR_pal_static', - 'vr_IPVR_static', - 'vr_IPVR_pal_static', - 'vr_KSVR_static', - 'vr_KSVR_pal_static', - 'vr_GLVR_static', - 'vr_GLVR_pal_static', - 'vr_ZRVR_static', - 'vr_ZRVR_pal_static', - 'vr_DGVR_static', - 'vr_DGVR_pal_static', - 'vr_ALVR_static', - 'vr_ALVR_pal_static', - 'vr_NSVR_static', - 'vr_NSVR_pal_static', - 'vr_LBVR_static', - 'vr_LBVR_pal_static', - 'vr_TTVR_static', - 'vr_TTVR_pal_static', - 'vr_FCVR_static', - 'vr_FCVR_pal_static', - 'elf_message_field', - 'elf_message_ydan', - 'ydan_scene', -'ydan_room_0', -'ydan_room_1', -'ydan_room_2', -'ydan_room_3', -'ydan_room_4', -'ydan_room_5', -'ydan_room_6', -'ydan_room_7', -'ydan_room_8', -'ydan_room_9', -'ydan_room_10', -'ydan_room_11', -'ddan_scene', -'ddan_room_0', -'ddan_room_1', -'ddan_room_2', -'ddan_room_3', -'ddan_room_4', -'ddan_room_5', -'ddan_room_6', -'ddan_room_7', -'ddan_room_8', -'ddan_room_9', -'ddan_room_10', -'ddan_room_11', -'ddan_room_12', -'ddan_room_13', -'ddan_room_14', -'ddan_room_15', -'ddan_room_16', -'bdan_scene', -'bdan_room_0', -'bdan_room_1', -'bdan_room_2', -'bdan_room_3', -'bdan_room_4', -'bdan_room_5', -'bdan_room_6', -'bdan_room_7', -'bdan_room_8', -'bdan_room_9', -'bdan_room_10', -'bdan_room_11', -'bdan_room_12', -'bdan_room_13', -'bdan_room_14', -'bdan_room_15', -'Bmori1_scene', -'Bmori1_room_0', -'Bmori1_room_1', -'Bmori1_room_2', -'Bmori1_room_3', -'Bmori1_room_4', -'Bmori1_room_5', -'Bmori1_room_6', -'Bmori1_room_7', -'Bmori1_room_8', -'Bmori1_room_9', -'Bmori1_room_10', -'Bmori1_room_11', -'Bmori1_room_12', -'Bmori1_room_13', -'Bmori1_room_14', -'Bmori1_room_15', -'Bmori1_room_16', -'Bmori1_room_17', -'Bmori1_room_18', -'Bmori1_room_19', -'Bmori1_room_20', -'Bmori1_room_21', -'Bmori1_room_22', -'HIDAN_scene', -'HIDAN_room_0', -'HIDAN_room_1', -'HIDAN_room_2', -'HIDAN_room_3', -'HIDAN_room_4', -'HIDAN_room_5', -'HIDAN_room_6', -'HIDAN_room_7', -'HIDAN_room_8', -'HIDAN_room_9', -'HIDAN_room_10', -'HIDAN_room_11', -'HIDAN_room_12', -'HIDAN_room_13', -'HIDAN_room_14', -'HIDAN_room_15', -'HIDAN_room_16', -'HIDAN_room_17', -'HIDAN_room_18', -'HIDAN_room_19', -'HIDAN_room_20', -'HIDAN_room_21', -'HIDAN_room_22', -'HIDAN_room_23', -'HIDAN_room_24', -'HIDAN_room_25', -'HIDAN_room_26', -'MIZUsin_scene', -'MIZUsin_room_0', -'MIZUsin_room_1', -'MIZUsin_room_2', -'MIZUsin_room_3', -'MIZUsin_room_4', -'MIZUsin_room_5', -'MIZUsin_room_6', -'MIZUsin_room_7', -'MIZUsin_room_8', -'MIZUsin_room_9', -'MIZUsin_room_10', -'MIZUsin_room_11', -'MIZUsin_room_12', -'MIZUsin_room_13', -'MIZUsin_room_14', -'MIZUsin_room_15', -'MIZUsin_room_16', -'MIZUsin_room_17', -'MIZUsin_room_18', -'MIZUsin_room_19', -'MIZUsin_room_20', -'MIZUsin_room_21', -'MIZUsin_room_22', -'jyasinzou_scene', -'jyasinzou_room_0', -'jyasinzou_room_1', -'jyasinzou_room_2', -'jyasinzou_room_3', -'jyasinzou_room_4', -'jyasinzou_room_5', -'jyasinzou_room_6', -'jyasinzou_room_7', -'jyasinzou_room_8', -'jyasinzou_room_9', -'jyasinzou_room_10', -'jyasinzou_room_11', -'jyasinzou_room_12', -'jyasinzou_room_13', -'jyasinzou_room_14', -'jyasinzou_room_15', -'jyasinzou_room_16', -'jyasinzou_room_17', -'jyasinzou_room_18', -'jyasinzou_room_19', -'jyasinzou_room_20', -'jyasinzou_room_21', -'jyasinzou_room_22', -'jyasinzou_room_23', -'jyasinzou_room_24', -'jyasinzou_room_25', -'jyasinzou_room_26', -'jyasinzou_room_27', -'jyasinzou_room_28', -'HAKAdan_scene', -'HAKAdan_room_0', -'HAKAdan_room_1', -'HAKAdan_room_2', -'HAKAdan_room_3', -'HAKAdan_room_4', -'HAKAdan_room_5', -'HAKAdan_room_6', -'HAKAdan_room_7', -'HAKAdan_room_8', -'HAKAdan_room_9', -'HAKAdan_room_10', -'HAKAdan_room_11', -'HAKAdan_room_12', -'HAKAdan_room_13', -'HAKAdan_room_14', -'HAKAdan_room_15', -'HAKAdan_room_16', -'HAKAdan_room_17', -'HAKAdan_room_18', -'HAKAdan_room_19', -'HAKAdan_room_20', -'HAKAdan_room_21', -'HAKAdan_room_22', -'HAKAdanCH_scene', -'HAKAdanCH_room_0', -'HAKAdanCH_room_1', -'HAKAdanCH_room_2', -'HAKAdanCH_room_3', -'HAKAdanCH_room_4', -'HAKAdanCH_room_5', -'HAKAdanCH_room_6', -'ice_doukutu_scene', -'ice_doukutu_room_0', -'ice_doukutu_room_1', -'ice_doukutu_room_2', -'ice_doukutu_room_3', -'ice_doukutu_room_4', -'ice_doukutu_room_5', -'ice_doukutu_room_6', -'ice_doukutu_room_7', -'ice_doukutu_room_8', -'ice_doukutu_room_9', -'ice_doukutu_room_10', -'ice_doukutu_room_11', -'men_scene', -'men_room_0', -'men_room_1', -'men_room_2', -'men_room_3', -'men_room_4', -'men_room_5', -'men_room_6', -'men_room_7', -'men_room_8', -'men_room_9', -'men_room_10', -'ganontika_scene', -'ganontika_room_0', -'ganontika_room_1', -'ganontika_room_2', -'ganontika_room_3', -'ganontika_room_4', -'ganontika_room_5', -'ganontika_room_6', -'ganontika_room_7', -'ganontika_room_8', -'ganontika_room_9', -'ganontika_room_10', -'ganontika_room_11', -'ganontika_room_12', -'ganontika_room_13', -'ganontika_room_14', -'ganontika_room_15', -'ganontika_room_16', -'ganontika_room_17', -'ganontika_room_18', -'ganontika_room_19', -'spot00_scene', -'spot00_room_0', -'spot01_scene', -'spot01_room_0', -'spot02_scene', -'spot02_room_0', -'spot02_room_1', -'spot03_scene', -'spot03_room_0', -'spot03_room_1', -'spot04_scene', -'spot04_room_0', -'spot04_room_1', -'spot04_room_2', -'spot05_scene', -'spot05_room_0', -'spot06_scene', -'spot06_room_0', -'spot07_scene', -'spot07_room_0', -'spot07_room_1', -'spot08_scene', -'spot08_room_0', -'spot09_scene', -'spot09_room_0', -'spot10_scene', -'spot10_room_0', -'spot10_room_1', -'spot10_room_2', -'spot10_room_3', -'spot10_room_4', -'spot10_room_5', -'spot10_room_6', -'spot10_room_7', -'spot10_room_8', -'spot10_room_9', -'spot11_scene', -'spot11_room_0', -'spot12_scene', -'spot12_room_0', -'spot12_room_1', -'spot13_scene', -'spot13_room_0', -'spot13_room_1', -'spot15_scene', -'spot15_room_0', -'spot16_scene', -'spot16_room_0', -'spot17_scene', -'spot17_room_0', -'spot17_room_1', -'spot18_scene', -'spot18_room_0', -'spot18_room_1', -'spot18_room_2', -'spot18_room_3', -'market_day_scene', -'market_day_room_0', -'market_night_scene', -'market_night_room_0', -'kenjyanoma_scene', -'kenjyanoma_room_0', -'tokinoma_scene', -'tokinoma_room_0', -'tokinoma_room_1', -'link_home_scene', -'link_home_room_0', -'kokiri_shop_scene', -'kokiri_shop_room_0', -'kokiri_home_scene', -'kokiri_home_room_0', -'kakusiana_scene', -'kakusiana_room_0', -'kakusiana_room_1', -'kakusiana_room_2', -'kakusiana_room_3', -'kakusiana_room_4', -'kakusiana_room_5', -'kakusiana_room_6', -'kakusiana_room_7', -'kakusiana_room_8', -'kakusiana_room_9', -'kakusiana_room_10', -'kakusiana_room_11', -'kakusiana_room_12', -'kakusiana_room_13', -'entra_scene', -'entra_room_0', -'moribossroom_scene', -'moribossroom_room_0', -'moribossroom_room_1', -'syatekijyou_scene', -'syatekijyou_room_0', -'shop1_scene', -'shop1_room_0', -'hairal_niwa_scene', -'hairal_niwa_room_0', -'ganon_tou_scene', -'ganon_tou_room_0', -'market_alley_scene', -'market_alley_room_0', -'spot20_scene', -'spot20_room_0', -'market_ruins_scene', -'market_ruins_room_0', -'entra_n_scene', -'entra_n_room_0', -'enrui_scene', -'enrui_room_0', -'market_alley_n_scene', -'market_alley_n_room_0', -'hiral_demo_scene', -'hiral_demo_room_0', -'kokiri_home3_scene', -'kokiri_home3_room_0', -'malon_stable_scene', -'malon_stable_room_0', -'kakariko_scene', -'kakariko_room_0', -'bdan_boss_scene', -'bdan_boss_room_0', -'bdan_boss_room_1', -'FIRE_bs_scene', -'FIRE_bs_room_0', -'FIRE_bs_room_1', -'hut_scene', -'hut_room_0', -'daiyousei_izumi_scene', -'daiyousei_izumi_room_0', -'hakaana_scene', -'hakaana_room_0', -'yousei_izumi_tate_scene', -'yousei_izumi_tate_room_0', -'yousei_izumi_yoko_scene', -'yousei_izumi_yoko_room_0', -'golon_scene', -'golon_room_0', -'zoora_scene', -'zoora_room_0', -'drag_scene', -'drag_room_0', -'alley_shop_scene', -'alley_shop_room_0', -'night_shop_scene', -'night_shop_room_0', -'impa_scene', -'impa_room_0', -'labo_scene', -'labo_room_0', -'tent_scene', -'tent_room_0', -'nakaniwa_scene', -'nakaniwa_room_0', -'ddan_boss_scene', -'ddan_boss_room_0', -'ddan_boss_room_1', -'ydan_boss_scene', -'ydan_boss_room_0', -'ydan_boss_room_1', -'HAKAdan_bs_scene', -'HAKAdan_bs_room_0', -'HAKAdan_bs_room_1', -'MIZUsin_bs_scene', -'MIZUsin_bs_room_0', -'MIZUsin_bs_room_1', -'ganon_scene', -'ganon_room_0', -'ganon_room_1', -'ganon_room_2', -'ganon_room_3', -'ganon_room_4', -'ganon_room_5', -'ganon_room_6', -'ganon_room_7', -'ganon_room_8', -'ganon_room_9', -'ganon_boss_scene', -'ganon_boss_room_0', -'jyasinboss_scene', -'jyasinboss_room_0', -'jyasinboss_room_1', -'jyasinboss_room_2', -'jyasinboss_room_3', -'kokiri_home4_scene', -'kokiri_home4_room_0', -'kokiri_home5_scene', -'kokiri_home5_room_0', -'ganon_final_scene', -'ganon_final_room_0', -'kakariko3_scene', -'kakariko3_room_0', -'hakasitarelay_scene', -'hakasitarelay_room_0', -'hakasitarelay_room_1', -'hakasitarelay_room_2', -'hakasitarelay_room_3', -'hakasitarelay_room_4', -'hakasitarelay_room_5', -'hakasitarelay_room_6', -'shrine_scene', -'shrine_room_0', -'turibori_scene', -'turibori_room_0', -'shrine_n_scene', -'shrine_n_room_0', -'shrine_r_scene', -'shrine_r_room_0', -'hakaana2_scene', -'hakaana2_room_0', -'gerudoway_scene', -'gerudoway_room_0', -'gerudoway_room_1', -'gerudoway_room_2', -'gerudoway_room_3', -'gerudoway_room_4', -'gerudoway_room_5', -'hairal_niwa_n_scene', -'hairal_niwa_n_room_0', -'bowling_scene', -'bowling_room_0', -'hakaana_ouke_scene', -'hakaana_ouke_room_0', -'hakaana_ouke_room_1', -'hakaana_ouke_room_2', -'hylia_labo_scene', -'hylia_labo_room_0', -'souko_scene', -'souko_room_0', -'souko_room_1', -'souko_room_2', -'miharigoya_scene', -'miharigoya_room_0', -'mahouya_scene', -'mahouya_room_0', -'takaraya_scene', -'takaraya_room_0', -'takaraya_room_1', -'takaraya_room_2', -'takaraya_room_3', -'takaraya_room_4', -'takaraya_room_5', -'takaraya_room_6', -'ganon_sonogo_scene', -'ganon_sonogo_room_0', -'ganon_sonogo_room_1', -'ganon_sonogo_room_2', -'ganon_sonogo_room_3', -'ganon_sonogo_room_4', -'ganon_demo_scene', -'ganon_demo_room_0', -'face_shop_scene', -'face_shop_room_0', -'kinsuta_scene', -'kinsuta_room_0', -'ganontikasonogo_scene', -'ganontikasonogo_room_0', -'ganontikasonogo_room_1', - 'bump_texture_static', - 'anime_model_1_static', - 'anime_model_2_static', - 'anime_model_3_static', - 'anime_model_4_static', - 'anime_model_5_static', - 'anime_model_6_static', - 'anime_texture_1_static', - 'anime_texture_2_static', - 'anime_texture_3_static', - 'anime_texture_4_static', - 'anime_texture_5_static', - 'anime_texture_6_static', - 'softsprite_matrix_static', -] - -romData = None - - -def initialize_worker(rom_data): - global romData - romData = rom_data - -def read_uint32_be(offset): - return struct.unpack('>I', romData[offset:offset+4])[0] - -def write_output_file(name, offset, size): - try: - with open(name, 'wb') as f: - f.write(romData[offset:offset+size]) - except IOError: - print('failed to write file ' + name) - -def ExtractFunc(i): - filename = 'baserom/' + FILE_NAMES[i] - entryOffset = FILE_TABLE_OFFSET + 16 * i - - virtStart = read_uint32_be(entryOffset + 0) - virtEnd = read_uint32_be(entryOffset + 4) - physStart = read_uint32_be(entryOffset + 8) - physEnd = read_uint32_be(entryOffset + 12) - - if physEnd == 0: # uncompressed - compressed = False - size = virtEnd - virtStart - else: # compressed - compressed = True - size = physEnd - physStart - - print('extracting ' + filename + " (0x%08X, 0x%08X)" % (virtStart, virtEnd)) - write_output_file(filename, physStart, size) - if compressed: - os.system('tools/yaz0 -d ' + filename + ' ' + filename) - -##################################################################### - -def main(): - try: - os.mkdir('baserom') - except: - pass - - # read baserom data - try: - with open(ROM_FILE_NAME, 'rb') as f: - rom_data = f.read() - except IOError: - print('failed to read ' + ROM_FILE_NAME) - sys.exit(1) - - # extract files - num_cores = cpu_count() - print("Extracting baserom with " + str(num_cores) + " CPU cores.") - with Pool(num_cores, initialize_worker, (rom_data,)) as p: - p.map(ExtractFunc, range(len(FILE_NAMES))) - -if __name__ == "__main__": - main() diff --git a/OTRExporter/rom_chooser.py b/OTRExporter/rom_chooser.py new file mode 100644 index 000000000..5c5f875d0 --- /dev/null +++ b/OTRExporter/rom_chooser.py @@ -0,0 +1,37 @@ +import os, sys, glob + +from rom_info import Z64Rom + +def chooseROM(): + roms = [] + + for file in glob.glob("*.z64"): + if Z64Rom.isValidRom(file): + roms.append(file) + + if not (roms): + print("Error: No roms located, place one in the OTRExporter directory", file=os.sys.stderr) + sys.exit(1) + + if (len(roms) == 1): + return roms[0] + + print(str(len(roms))+ " roms found, please select one by pressing 1-"+str(len(roms))) + + for i in range(len(roms)): + print(str(i+1)+ ". " + roms[i]) + + while(1): + try: + selection = int(input()) + except: + print("Bad input. Try again with the number keys.") + continue + + if (selection < 1 or selection > len(roms)): + print("Bad input. Try again.") + continue + + else: break + + return roms[selection - 1] diff --git a/OTRExporter/rom_info.py b/OTRExporter/rom_info.py new file mode 100644 index 000000000..3edc8b0f9 --- /dev/null +++ b/OTRExporter/rom_info.py @@ -0,0 +1,87 @@ +from enum import Enum +from tabnanny import check +import struct + +class Checksums(Enum): + OOT_NTSC_10 = "EC7011B7" + OOT_NTSC_11 = "D43DA81F" + OOT_NTSC_12 = "693BA2AE" + OOT_PAL_10 = "B044B569" + OOT_PAL_11 = "B2055FBD" + OOT_NTSC_JP_GC_CE = "F7F52DB8" + OOT_NTSC_JP_GC = "F611F4BA" + OOT_NTSC_US_GC = "F3DD35BA" + OOT_PAL_GC = "09465AC3" + OOT_NTSC_JP_MQ = "F43B45BA" + OOT_NTSC_US_MQ = "F034001A" + OOT_PAL_MQ = "1D4136F3" + OOT_PAL_GC_DBG1 = "871E1C92" + OOT_PAL_GC_DBG2 = "87121EFE" + OOT_PAL_GC_MQ_DBG = "917D18F6" + OOT_IQUE_TW = "3D81FB3E" + OOT_IQUE_CN = "B1E1E07B" + OOT_UNKNOWN = "FFFFFFFF" + + @classmethod + def has_value(self, value): + return value in self._value2member_map_ + +class RomVersion: + def __init__(self, file_table_path, file_table_off, xml_ver): + self.file_table_off = file_table_off + self.xml_ver = xml_ver + with open(file_table_path, 'r') as f: + self.file_table = [line.strip('\n') for line in f] + +ROM_INFO_TABLE = dict() +ROM_INFO_TABLE[Checksums.OOT_PAL_GC] = RomVersion("CFG/filelists/gamecube_pal.txt", 0x7170, "GC_NMQ_PAL_F") +ROM_INFO_TABLE[Checksums.OOT_PAL_GC_DBG1] = RomVersion("CFG/filelists/dbg.txt", 0x12F70, "GC_NMQ_D") + +class RomDmaEntry: + def __init__(self, rom, i): + + off = rom.version.file_table_off + 16 * i + + (self.virtStart, \ + self.virtEnd, \ + self.physStart, \ + self.physEnd) = struct.unpack('>IIII', rom.rom_data[off:off+4*4]) + + self.compressed = self.physEnd != 0 + self.size = self.physEnd - self.physStart \ + if self.compressed \ + else self.virtEnd - self.virtStart + self.name = rom.version.file_table[i] + + +class Z64Rom: + def __init__(self, file_path): + self.file_path = file_path + with open(file_path, 'rb') as f: + self.rom_data = f.read() + + self.is_valid = len(self.rom_data) > 20 * 1024 * 1024 + + if not self.is_valid: + return + + # get checkum + checksum_str = self.rom_data[16:16+4].hex().upper() + self.checksum = Checksums(checksum_str) if Checksums.has_value(checksum_str) else Checksums.OOT_UNKNOWN + + if self.checksum == Checksums.OOT_UNKNOWN: + self.is_valid = False + return + + # get rom version + self.version = ROM_INFO_TABLE[self.checksum] + + def getDmaEntryByIndex(self, i): + return RomDmaEntry(self, i) + + def readDmaEntry(self, entry): + return self.rom_data[entry.physStart:entry.physStart + entry.size] + + @staticmethod + def isValidRom(rom_path): + return Z64Rom(rom_path).is_valid diff --git a/OTRGui/src/game/game.cpp b/OTRGui/src/game/game.cpp index 88bd7201f..022a7788e 100644 --- a/OTRGui/src/game/game.cpp +++ b/OTRGui/src/game/game.cpp @@ -67,13 +67,13 @@ void OTRGame::init(){ mat.shader = shader; } - if(fs::exists("soh.exe") && !fs::exists("oot.otr")) { + if((fs::exists("soh.exe") || fs::exists("soh.elf")) && !fs::exists("oot.otr")) { hide_second_btn = true; sohFolder = "."; } } -void ExtractRom() +void ExtractRom() { WriteResult result; @@ -188,7 +188,7 @@ void OTRGame::draw() { sohFolder = path; } - if (UIUtils::GuiIconButton("Cartridge", "Open\nOoT Rom", 32, 50, currentStep != NULLSTR, "Select an Ocarina of Time\nMaster Quest or Vanilla Debug Rom\n\nYou can dump it or lend one from Nintendo")) { + if (UIUtils::GuiIconButton("Cartridge", "Open\nOoT Rom", 32, 50, currentStep != NULLSTR, "Select an Ocarina of Time\nGameCube PAL or Vanilla Debug Rom\n\nYou can dump it or lend one from Nintendo")) { const std::string path = NativeFS->LaunchFileExplorer(LaunchType::FILE); if (path != NULLSTR) { const std::string patched_n64 = std::string(patched_rom); @@ -220,4 +220,4 @@ void setCurrentStep(const std::string& step) { void OTRGame::exit(){ -} \ No newline at end of file +} diff --git a/README.md b/README.md index 65a6b90e0..3ce3fb21b 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,21 @@ The Ship does not include assets and as such requires a prior copy of the game t ## Quick Start 1) Download The Ship of Harkinian from Discord. -2) Requires an `oot debug` rom (not Master Quest). +2) Requires a supported copy of the game (See supported games below). +3) Use the OTRGui to generate an `oot.otr` archive file. +4) Launch `soh.exe` + +### Supported Games +Ocarina of Time Debug (not Master Quest) ``` Build team: `zelda@srd022j` Build date: `03-02-21 00:49:18` (year-month-day) sha1: cee6bc3c2a634b41728f2af8da54d9bf8cc14099 ``` -3) Use the OTRGui to generate an `oot.otr` archive file. -4) Launch `soh.exe` +Ocarina of Time Pal Gamecube +``` +sha1: d0c95b2cb3c6682a171db267932af7af8cf5fa82 +``` Congratulations, you are now sailing with the Ship of Harkinian! Have fun! @@ -37,7 +44,7 @@ If you still cannot get the tool to work, join our [Discord Server](https://disc ### Running The Ship of Harkinian -Launch the game. If the window immediately closes, or if there are visual artifacts, you may have selected the wrong rom in the OTRGui tool. +Launch the game. If the window immediately closes, or if there are visual artifacts, you may have selected the wrong rom in the OTRGui tool. Currently, DirectX 11 and OpenGL is supported. Change the renderer by opening the `shipofharkinian.ini` configuration file in notepad and add `sdl` to `gfx backend` for OpenGL or leave blank for DirectX. @@ -51,7 +58,7 @@ Official Discord: https://discord.com/invite/BtBmd55HVH ## Building The Ship of Harkinian -Refer to the [building instructions](https://github.com/HarbourMasters/Shipwright/BUILDING.md) to compile SoH. +Refer to the [building instructions](BUILDING.md) to compile SoH. ## Troubleshooting The Exporter - Affirm that you have an `/assets` folder filled with XMLs in the same directory as OTRGui.exe diff --git a/ZAPDTR/ExporterTest/CollisionExporter.cpp b/ZAPDTR/ExporterTest/CollisionExporter.cpp index e00f5c1b0..4ab8a62cd 100644 --- a/ZAPDTR/ExporterTest/CollisionExporter.cpp +++ b/ZAPDTR/ExporterTest/CollisionExporter.cpp @@ -1,6 +1,6 @@ #include "CollisionExporter.h" -void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path outPath, +void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] const fs::path& outPath, BinaryWriter* writer) { ZCollisionHeader* col = (ZCollisionHeader*)res; diff --git a/ZAPDTR/ExporterTest/CollisionExporter.h b/ZAPDTR/ExporterTest/CollisionExporter.h index 5f48e6557..1dc50634e 100644 --- a/ZAPDTR/ExporterTest/CollisionExporter.h +++ b/ZAPDTR/ExporterTest/CollisionExporter.h @@ -6,5 +6,5 @@ class ExporterExample_Collision : public ZResourceExporter { public: - void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override; + void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; }; \ No newline at end of file diff --git a/ZAPDTR/ExporterTest/RoomExporter.cpp b/ZAPDTR/ExporterTest/RoomExporter.cpp index 6c5552d8f..bc7ef3727 100644 --- a/ZAPDTR/ExporterTest/RoomExporter.cpp +++ b/ZAPDTR/ExporterTest/RoomExporter.cpp @@ -20,7 +20,7 @@ #include "ZRoom/Commands/SetTimeSettings.h" #include "ZRoom/Commands/SetWind.h" -void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* writer) +void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) { ZRoom* room = dynamic_cast(res); diff --git a/ZAPDTR/ExporterTest/RoomExporter.h b/ZAPDTR/ExporterTest/RoomExporter.h index ee531dc87..d8f7eae01 100644 --- a/ZAPDTR/ExporterTest/RoomExporter.h +++ b/ZAPDTR/ExporterTest/RoomExporter.h @@ -6,5 +6,5 @@ class ExporterExample_Room : public ZResourceExporter { public: - void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override; + void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; }; \ No newline at end of file diff --git a/ZAPDTR/ExporterTest/TextureExporter.cpp b/ZAPDTR/ExporterTest/TextureExporter.cpp index 6488bed3a..58d0964d3 100644 --- a/ZAPDTR/ExporterTest/TextureExporter.cpp +++ b/ZAPDTR/ExporterTest/TextureExporter.cpp @@ -1,7 +1,7 @@ #include "TextureExporter.h" #include "../ZAPD/ZFile.h" -void ExporterExample_Texture::Save(ZResource* res, [[maybe_unused]] fs::path outPath, +void ExporterExample_Texture::Save(ZResource* res, [[maybe_unused]] const fs::path& outPath, BinaryWriter* writer) { ZTexture* tex = (ZTexture*)res; diff --git a/ZAPDTR/ExporterTest/TextureExporter.h b/ZAPDTR/ExporterTest/TextureExporter.h index 41c4e79be..f3922cac1 100644 --- a/ZAPDTR/ExporterTest/TextureExporter.h +++ b/ZAPDTR/ExporterTest/TextureExporter.h @@ -7,5 +7,5 @@ class ExporterExample_Texture : public ZResourceExporter { public: - void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override; + void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override; }; \ No newline at end of file diff --git a/ZAPDTR/Makefile b/ZAPDTR/Makefile index 2b47a8039..13f0dce20 100644 --- a/ZAPDTR/Makefile +++ b/ZAPDTR/Makefile @@ -44,7 +44,8 @@ ifneq ($(DEPRECATION_ON),0) endif # CXXFLAGS += -DTEXTURE_DEBUG -LDFLAGS := -lm -ldl -lpng +LDFLAGS := -lm -ldl -lpng \ + -L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm -lSDL2 -lGLEW -lGL -lX11 # Use LLD if available. Set LLD=0 to not use it ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) @@ -59,9 +60,9 @@ UNAME := $(shell uname) UNAMEM := $(shell uname -m) ifneq ($(UNAME), Darwin) LDFLAGS += -Wl,-export-dynamic -lstdc++fs - EXPORTERS := -Wl,--whole-archive ExporterTest/ExporterTest.a -Wl,--no-whole-archive + EXPORTERS := -Wl,--whole-archive ../OTRExporter/OTRExporter/OTRExporter.a -Wl,--no-whole-archive else - EXPORTERS := -Wl,-force_load ExporterTest/ExporterTest.a + EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a ifeq ($(UNAMEM),arm64) ifeq ($(shell brew list libpng > /dev/null 2>&1; echo $$?),0) LDFLAGS += -L $(shell brew --prefix)/lib diff --git a/ZAPDTR/ZAPD/Main.cpp b/ZAPDTR/ZAPD/Main.cpp index dd53b9c67..65a65fea6 100644 --- a/ZAPDTR/ZAPD/Main.cpp +++ b/ZAPDTR/ZAPD/Main.cpp @@ -10,7 +10,7 @@ #include "ZFile.h" #include "ZTexture.h" -#if !defined(_MSC_VER) && !defined(__CYGWIN__) +#ifdef __linux__ #include #include #include @@ -28,6 +28,31 @@ //extern const char gBuildHash[]; const char gBuildHash[] = ""; +// LINUX_TODO: remove, those are because of soh <-> lus dependency problems +float divisor_num = 0.0f; + +extern "C" void Audio_SetGameVolume(int player_id, float volume) +{ + +} + + +extern "C" int ResourceMgr_OTRSigCheck(char* imgData) +{ + +} + +void DebugConsole_SaveCVars() +{ + +} + +void DebugConsole_LoadCVars() +{ + +} + + bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, ZFileMode fileMode, int workerID); @@ -38,7 +63,7 @@ int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileM volatile int numWorkersLeft = 0; -#if !defined(_MSC_VER) && !defined(__CYGWIN__) +#ifdef __linux__ #define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0])) void ErrorHandler(int sig) { @@ -196,7 +221,7 @@ int main(int argc, char* argv[]) } else if (arg == "-eh") // Enable Error Handler { - #if !defined(_MSC_VER) && !defined(__CYGWIN__) +#ifdef __linux__ signal(SIGSEGV, ErrorHandler); signal(SIGABRT, ErrorHandler); #else @@ -302,7 +327,7 @@ int main(int argc, char* argv[]) ctpl::thread_pool pool(num_threads / 2); bool parseSuccessful; - + auto start = std::chrono::steady_clock::now(); int fileListSize = fileList.size(); Globals::Instance->singleThreaded = false; @@ -453,6 +478,7 @@ int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileM numWorkersLeft--; } + return 0; } bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, diff --git a/ZAPDTR/ZAPD/OutputFormatter.cpp b/ZAPDTR/ZAPD/OutputFormatter.cpp index 7fac434b2..362ef98fc 100644 --- a/ZAPDTR/ZAPD/OutputFormatter.cpp +++ b/ZAPDTR/ZAPD/OutputFormatter.cpp @@ -96,7 +96,7 @@ int OutputFormatter::Write(const std::string& buf) return Write(buf.data(), buf.size()); } -__declspec(thread) OutputFormatter* OutputFormatter::Instance; +thread_local OutputFormatter* OutputFormatter::Instance; int OutputFormatter::WriteStatic(const char* buf, int count) { diff --git a/ZAPDTR/ZAPD/OutputFormatter.h b/ZAPDTR/ZAPD/OutputFormatter.h index f008df2cb..03abfdb96 100644 --- a/ZAPDTR/ZAPD/OutputFormatter.h +++ b/ZAPDTR/ZAPD/OutputFormatter.h @@ -25,7 +25,7 @@ private: void Flush(); - static __declspec(thread) OutputFormatter* Instance; + static thread_local OutputFormatter* Instance; static int WriteStatic(const char* buf, int count); public: diff --git a/ZAPDTR/ZAPD/ZDisplayList.cpp b/ZAPDTR/ZAPD/ZDisplayList.cpp index 93269b65e..406245b33 100644 --- a/ZAPDTR/ZAPD/ZDisplayList.cpp +++ b/ZAPDTR/ZAPD/ZDisplayList.cpp @@ -15,6 +15,124 @@ #include "WarningHandler.h" #include "gfxd.h" + +#define G_MDSFT_ALPHACOMPARE 0 +#define G_MDSFT_ZSRCSEL 2 +#define G_MDSFT_RENDERMODE 3 +#define G_MDSFT_BLENDER 16 + +#define G_RM_FOG_SHADE_A 0xC8000000 +#define G_RM_FOG_PRIM_A 0xC4000000 +#define G_RM_PASS 0x0C080000 +#define G_RM_AA_ZB_OPA_SURF 0x442078 +#define G_RM_AA_ZB_OPA_SURF2 0x112078 +#define G_RM_AA_ZB_XLU_SURF 0x4049D8 +#define G_RM_AA_ZB_XLU_SURF2 0x1049D8 +#define G_RM_AA_ZB_OPA_DECAL 0x442D58 +#define G_RM_AA_ZB_OPA_DECAL2 0x112D58 +#define G_RM_AA_ZB_XLU_DECAL 0x404DD8 +#define G_RM_AA_ZB_XLU_DECAL2 0x104DD8 +#define G_RM_AA_ZB_OPA_INTER 0x442478 +#define G_RM_AA_ZB_OPA_INTER2 0x112478 +#define G_RM_AA_ZB_XLU_INTER 0x4045D8 +#define G_RM_AA_ZB_XLU_INTER2 0x1045D8 +#define G_RM_AA_ZB_XLU_LINE 0x407858 +#define G_RM_AA_ZB_XLU_LINE2 0x107858 +#define G_RM_AA_ZB_DEC_LINE 0x407F58 +#define G_RM_AA_ZB_DEC_LINE2 0x107F58 +#define G_RM_AA_ZB_TEX_EDGE 0x443078 +#define G_RM_AA_ZB_TEX_EDGE2 0x113078 +#define G_RM_AA_ZB_TEX_INTER 0x443478 +#define G_RM_AA_ZB_TEX_INTER2 0x113478 +#define G_RM_AA_ZB_SUB_SURF 0x442878 +#define G_RM_AA_ZB_SUB_SURF2 0x112278 +#define G_RM_AA_ZB_PCL_SURF 0x40007B +#define G_RM_AA_ZB_PCL_SURF2 0x10007B +#define G_RM_AA_ZB_OPA_TERR 0x402078 +#define G_RM_AA_ZB_OPA_TERR2 0x102078 +#define G_RM_AA_ZB_TEX_TERR 0x403078 +#define G_RM_AA_ZB_TEX_TERR2 0x103078 +#define G_RM_AA_ZB_SUB_TERR 0x402278 +#define G_RM_AA_ZB_SUB_TERR2 0x102278 +#define G_RM_RA_ZB_OPA_SURF 0x442038 +#define G_RM_RA_ZB_OPA_SURF2 0x112038 +#define G_RM_RA_ZB_OPA_DECAL 0x442D18 +#define G_RM_RA_ZB_OPA_DECAL2 0x112D18 +#define G_RM_RA_ZB_OPA_INTER 0x442438 +#define G_RM_RA_ZB_OPA_INTER2 0x112438 +#define G_RM_AA_OPA_SURF 0x442048 +#define G_RM_AA_OPA_SURF2 0x112048 +#define G_RM_AA_XLU_SURF 0x4041C8 +#define G_RM_AA_XLU_SURF2 0x1041C8 +#define G_RM_AA_XLU_LINE 0x407048 +#define G_RM_AA_XLU_LINE2 0x107048 +#define G_RM_AA_DEC_LINE 0x407248 +#define G_RM_AA_DEC_LINE2 0x107248 +#define G_RM_AA_TEX_EDGE 0x443048 +#define G_RM_AA_TEX_EDGE2 0x113048 +#define G_RM_AA_SUB_SURF 0x442248 +#define G_RM_AA_SUB_SURF2 0x112248 +#define G_RM_AA_PCL_SURF 0x40004B +#define G_RM_AA_PCL_SURF2 0x10004B +#define G_RM_AA_OPA_TERR 0x402048 +#define G_RM_AA_OPA_TERR2 0x102048 +#define G_RM_AA_TEX_TERR 0x403048 +#define G_RM_AA_TEX_TERR2 0x103048 +#define G_RM_AA_SUB_TERR 0x402248 +#define G_RM_AA_SUB_TERR2 0x102248 +#define G_RM_RA_OPA_SURF 0x442008 +#define G_RM_RA_OPA_SURF2 0x112008 +#define G_RM_ZB_OPA_SURF 0x442230 +#define G_RM_ZB_OPA_SURF2 0x112230 +#define G_RM_ZB_XLU_SURF 0x404A50 +#define G_RM_ZB_XLU_SURF2 0x104A50 +#define G_RM_ZB_OPA_DECAL 0x442E10 +#define G_RM_ZB_OPA_DECAL2 0x112E10 +#define G_RM_ZB_XLU_DECAL 0x404E50 +#define G_RM_ZB_XLU_DECAL2 0x104E50 +#define G_RM_ZB_CLD_SURF 0x404B50 +#define G_RM_ZB_CLD_SURF2 0x104B50 +#define G_RM_ZB_OVL_SURF 0x404F50 +#define G_RM_ZB_OVL_SURF2 0x104F50 +#define G_RM_ZB_PCL_SURF 0x0C080233 +#define G_RM_ZB_PCL_SURF2 0x03020233 +#define G_RM_OPA_SURF 0x0C084000 +#define G_RM_OPA_SURF2 0x03024000 +#define G_RM_XLU_SURF 0x00404200 +#define G_RM_XLU_SURF2 0x00104240 +#define G_RM_CLD_SURF 0x00404340 +#define G_RM_CLD_SURF2 0x00104340 +#define G_RM_TEX_EDGE 0x0C087008 +#define G_RM_TEX_EDGE2 0x03027008 +#define G_RM_PCL_SURF 0x0C084203 +#define G_RM_PCL_SURF2 0x03024203 +#define G_RM_ADD 0x04484340 +#define G_RM_ADD2 0x01124340 +#define G_RM_NOOP 0x00000000 +#define G_RM_NOOP2 0x00000000 +#define G_RM_VISCVG 0x0C844040 +#define G_RM_VISCVG2 0x03214040 +#define G_RM_OPA_CI 0x0C080000 +#define G_RM_OPA_CI2 0x03020000 + +#define AA_EN 0x8 +#define Z_CMP 0x10 +#define Z_UPD 0x20 +#define IM_RD 0x40 +#define CLR_ON_CVG 0x80 +#define CVG_DST_CLAMP 0 +#define CVG_DST_WRAP 0x100 +#define CVG_DST_FULL 0x200 +#define CVG_DST_SAVE 0x300 +#define ZMODE_OPA 0 +#define ZMODE_INTER 0x400 +#define ZMODE_XLU 0x800 +#define ZMODE_DEC 0xc00 +#define CVG_X_ALPHA 0x1000 +#define ALPHA_CVG_SEL 0x2000 +#define FORCE_BL 0x4000 +#define TEX_EDGE 0x0000 + REGISTER_ZFILENODE(DList, ZDisplayList); ZDisplayList::ZDisplayList(ZFile* nParent) : ZResource(nParent) diff --git a/ZAPDTR/ZAPD/ZDisplayList.h b/ZAPDTR/ZAPD/ZDisplayList.h index 96808315d..f3828cc79 100644 --- a/ZAPDTR/ZAPD/ZDisplayList.h +++ b/ZAPDTR/ZAPD/ZDisplayList.h @@ -166,122 +166,6 @@ enum class OoTSegments FrameBuffer = 16, }; -#define G_MDSFT_ALPHACOMPARE 0 -#define G_MDSFT_ZSRCSEL 2 -#define G_MDSFT_RENDERMODE 3 -#define G_MDSFT_BLENDER 16 - -#define G_RM_FOG_SHADE_A 0xC8000000 -#define G_RM_FOG_PRIM_A 0xC4000000 -#define G_RM_PASS 0x0C080000 -#define G_RM_AA_ZB_OPA_SURF 0x442078 -#define G_RM_AA_ZB_OPA_SURF2 0x112078 -#define G_RM_AA_ZB_XLU_SURF 0x4049D8 -#define G_RM_AA_ZB_XLU_SURF2 0x1049D8 -#define G_RM_AA_ZB_OPA_DECAL 0x442D58 -#define G_RM_AA_ZB_OPA_DECAL2 0x112D58 -#define G_RM_AA_ZB_XLU_DECAL 0x404DD8 -#define G_RM_AA_ZB_XLU_DECAL2 0x104DD8 -#define G_RM_AA_ZB_OPA_INTER 0x442478 -#define G_RM_AA_ZB_OPA_INTER2 0x112478 -#define G_RM_AA_ZB_XLU_INTER 0x4045D8 -#define G_RM_AA_ZB_XLU_INTER2 0x1045D8 -#define G_RM_AA_ZB_XLU_LINE 0x407858 -#define G_RM_AA_ZB_XLU_LINE2 0x107858 -#define G_RM_AA_ZB_DEC_LINE 0x407F58 -#define G_RM_AA_ZB_DEC_LINE2 0x107F58 -#define G_RM_AA_ZB_TEX_EDGE 0x443078 -#define G_RM_AA_ZB_TEX_EDGE2 0x113078 -#define G_RM_AA_ZB_TEX_INTER 0x443478 -#define G_RM_AA_ZB_TEX_INTER2 0x113478 -#define G_RM_AA_ZB_SUB_SURF 0x442878 -#define G_RM_AA_ZB_SUB_SURF2 0x112278 -#define G_RM_AA_ZB_PCL_SURF 0x40007B -#define G_RM_AA_ZB_PCL_SURF2 0x10007B -#define G_RM_AA_ZB_OPA_TERR 0x402078 -#define G_RM_AA_ZB_OPA_TERR2 0x102078 -#define G_RM_AA_ZB_TEX_TERR 0x403078 -#define G_RM_AA_ZB_TEX_TERR2 0x103078 -#define G_RM_AA_ZB_SUB_TERR 0x402278 -#define G_RM_AA_ZB_SUB_TERR2 0x102278 -#define G_RM_RA_ZB_OPA_SURF 0x442038 -#define G_RM_RA_ZB_OPA_SURF2 0x112038 -#define G_RM_RA_ZB_OPA_DECAL 0x442D18 -#define G_RM_RA_ZB_OPA_DECAL2 0x112D18 -#define G_RM_RA_ZB_OPA_INTER 0x442438 -#define G_RM_RA_ZB_OPA_INTER2 0x112438 -#define G_RM_AA_OPA_SURF 0x442048 -#define G_RM_AA_OPA_SURF2 0x112048 -#define G_RM_AA_XLU_SURF 0x4041C8 -#define G_RM_AA_XLU_SURF2 0x1041C8 -#define G_RM_AA_XLU_LINE 0x407048 -#define G_RM_AA_XLU_LINE2 0x107048 -#define G_RM_AA_DEC_LINE 0x407248 -#define G_RM_AA_DEC_LINE2 0x107248 -#define G_RM_AA_TEX_EDGE 0x443048 -#define G_RM_AA_TEX_EDGE2 0x113048 -#define G_RM_AA_SUB_SURF 0x442248 -#define G_RM_AA_SUB_SURF2 0x112248 -#define G_RM_AA_PCL_SURF 0x40004B -#define G_RM_AA_PCL_SURF2 0x10004B -#define G_RM_AA_OPA_TERR 0x402048 -#define G_RM_AA_OPA_TERR2 0x102048 -#define G_RM_AA_TEX_TERR 0x403048 -#define G_RM_AA_TEX_TERR2 0x103048 -#define G_RM_AA_SUB_TERR 0x402248 -#define G_RM_AA_SUB_TERR2 0x102248 -#define G_RM_RA_OPA_SURF 0x442008 -#define G_RM_RA_OPA_SURF2 0x112008 -#define G_RM_ZB_OPA_SURF 0x442230 -#define G_RM_ZB_OPA_SURF2 0x112230 -#define G_RM_ZB_XLU_SURF 0x404A50 -#define G_RM_ZB_XLU_SURF2 0x104A50 -#define G_RM_ZB_OPA_DECAL 0x442E10 -#define G_RM_ZB_OPA_DECAL2 0x112E10 -#define G_RM_ZB_XLU_DECAL 0x404E50 -#define G_RM_ZB_XLU_DECAL2 0x104E50 -#define G_RM_ZB_CLD_SURF 0x404B50 -#define G_RM_ZB_CLD_SURF2 0x104B50 -#define G_RM_ZB_OVL_SURF 0x404F50 -#define G_RM_ZB_OVL_SURF2 0x104F50 -#define G_RM_ZB_PCL_SURF 0x0C080233 -#define G_RM_ZB_PCL_SURF2 0x03020233 -#define G_RM_OPA_SURF 0x0C084000 -#define G_RM_OPA_SURF2 0x03024000 -#define G_RM_XLU_SURF 0x00404200 -#define G_RM_XLU_SURF2 0x00104240 -#define G_RM_CLD_SURF 0x00404340 -#define G_RM_CLD_SURF2 0x00104340 -#define G_RM_TEX_EDGE 0x0C087008 -#define G_RM_TEX_EDGE2 0x03027008 -#define G_RM_PCL_SURF 0x0C084203 -#define G_RM_PCL_SURF2 0x03024203 -#define G_RM_ADD 0x04484340 -#define G_RM_ADD2 0x01124340 -#define G_RM_NOOP 0x00000000 -#define G_RM_NOOP2 0x00000000 -#define G_RM_VISCVG 0x0C844040 -#define G_RM_VISCVG2 0x03214040 -#define G_RM_OPA_CI 0x0C080000 -#define G_RM_OPA_CI2 0x03020000 - -#define AA_EN 0x8 -#define Z_CMP 0x10 -#define Z_UPD 0x20 -#define IM_RD 0x40 -#define CLR_ON_CVG 0x80 -#define CVG_DST_CLAMP 0 -#define CVG_DST_WRAP 0x100 -#define CVG_DST_FULL 0x200 -#define CVG_DST_SAVE 0x300 -#define ZMODE_OPA 0 -#define ZMODE_INTER 0x400 -#define ZMODE_XLU 0x800 -#define ZMODE_DEC 0xc00 -#define CVG_X_ALPHA 0x1000 -#define ALPHA_CVG_SEL 0x2000 -#define FORCE_BL 0x4000 -#define TEX_EDGE 0x0000 class ZDisplayList : public ZResource { diff --git a/ZAPDTR/ZAPD/ZLimb.h b/ZAPDTR/ZAPD/ZLimb.h index 53a414329..5de5276e9 100644 --- a/ZAPDTR/ZAPD/ZLimb.h +++ b/ZAPDTR/ZAPD/ZLimb.h @@ -25,19 +25,19 @@ public: ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_0; // Skin only segptr_t skinSegment = 0; // Skin only - Struct_800A5E28 segmentStruct; // Skin only + Struct_800A5E28 segmentStruct = {0}; // Skin only // Legacy only - float legTransX, legTransY, legTransZ; // Vec3f - uint16_t rotX, rotY, rotZ; // Vec3s - segptr_t childPtr; // LegacyLimb* - segptr_t siblingPtr; // LegacyLimb* + float legTransX = 0, legTransY = 0, legTransZ = 0; // Vec3f + uint16_t rotX = 0, rotY = 0, rotZ = 0; // Vec3s + segptr_t childPtr = 0; // LegacyLimb* + segptr_t siblingPtr = 0; // LegacyLimb* segptr_t dListPtr = 0; segptr_t dList2Ptr = 0; // LOD and Curve Only - int16_t transX, transY, transZ; - uint8_t childIndex, siblingIndex; + int16_t transX = 0, transY = 0, transZ = 0; + uint8_t childIndex = 0, siblingIndex = 0; ZLimb(ZFile* nParent); diff --git a/ZAPDTR/ZAPDUtils/Utils/BitConverter.h b/ZAPDTR/ZAPDUtils/Utils/BitConverter.h index e672b97c2..708d4b537 100644 --- a/ZAPDTR/ZAPDUtils/Utils/BitConverter.h +++ b/ZAPDTR/ZAPDUtils/Utils/BitConverter.h @@ -3,6 +3,7 @@ #include #include #include +#include class BitConverter { diff --git a/ZAPDTR/ZAPDUtils/Utils/Directory.h b/ZAPDTR/ZAPDUtils/Utils/Directory.h index b1ce49699..1ced139be 100644 --- a/ZAPDTR/ZAPDUtils/Utils/Directory.h +++ b/ZAPDTR/ZAPDUtils/Utils/Directory.h @@ -52,7 +52,7 @@ public: for (auto& p : fs::recursive_directory_iterator(dir)) { if (!p.is_directory()) - lst.push_back(p.path().string()); + lst.push_back(p.path().generic_string()); } } diff --git a/ZAPDTR/ZAPDUtils/Utils/StringHelper.cpp b/ZAPDTR/ZAPDUtils/Utils/StringHelper.cpp index e2b646fd9..070fffa63 100644 --- a/ZAPDTR/ZAPDUtils/Utils/StringHelper.cpp +++ b/ZAPDTR/ZAPDUtils/Utils/StringHelper.cpp @@ -3,6 +3,10 @@ #pragma optimize("2", on) #define _CRT_SECURE_NO_WARNINGS +#ifndef _MSC_VER +#define vsprintf_s vsprintf +#endif + std::vector StringHelper::Split(std::string s, const std::string& delimiter) { std::vector result; @@ -44,7 +48,7 @@ std::string StringHelper::Replace(std::string str, const std::string& from, while (start_pos != std::string::npos) { - str.replace(start_pos, from.length(), to); + str.replace(start_pos, from.length(), to); start_pos = str.find(from); } diff --git a/libultraship/.gitignore b/libultraship/.gitignore index da0a72409..1cf3c3325 100644 --- a/libultraship/.gitignore +++ b/libultraship/.gitignore @@ -353,4 +353,6 @@ MigrationBackup/ .ionide/ !libultraship/Lib/** -libultraship/DebugObj/* \ No newline at end of file +libultraship/DebugObj/* +build/ +libultraship.a \ No newline at end of file diff --git a/libultraship/Makefile b/libultraship/Makefile index d7aafd65f..d6789db0b 100644 --- a/libultraship/Makefile +++ b/libultraship/Makefile @@ -1,15 +1,78 @@ # Only used for standalone compilation, usually inherits these from the main makefile -CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17 + +CXX := g++ +CC := gcc +AR := ar +FORMAT := clang-format-11 + +ASAN ?= 0 +DEBUG ?= 1 +OPTFLAGS ?= -O0 +LTO ?= 0 + +WARN := -Wall -Wextra -Werror \ + -Wno-unused-variable \ + -Wno-unused-parameter \ + -Wno-unused-function \ + -Wno-parentheses \ + -Wno-narrowing \ + -Wno-missing-field-initializers + +CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -m32 +CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -m32 +CPPFLAGS := -MMD + +ifneq ($(DEBUG),0) + CXXFLAGS += -g -D_DEBUG + CFLAGS += -g -D_DEBUG +endif + +ifneq ($(ASAN),0) + CXXFLAGS += -fsanitize=address + CFLAGS += -fsanitize=address +endif + +ifneq ($(LTO),0) + CXXFLAGS += -flto + CFLAGS += -flto +endif SRC_DIRS := $(shell find -type d -not -path "*build*") -CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp)) -H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) -O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f) -LIB := otrlib.a +CXX_FILES := \ + $(shell find libultraship/Factories -name *.cpp) \ + $(shell find libultraship/Lib/Fast3D -name *.cpp) \ + $(shell find libultraship -maxdepth 1 -name *.cpp) \ + $(shell find libultraship/Lib/ImGui -maxdepth 1 -name *.cpp) \ + libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp \ + libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp \ + libultraship/Lib/StrHash64.cpp \ + libultraship/Lib/tinyxml2/tinyxml2.cpp + +C_FILES := \ + libultraship/mixer.c \ + libultraship/Lib/stb/stb_impl.c + +FMT_FILES := $(shell find libultraship/ -type f \( -name *.cpp -o -name *.h \) -a -not -path "libultraship/Lib/*") + +O_FILES := \ + $(CXX_FILES:%.cpp=build/%.o) \ + $(C_FILES:%.c=build/%.o) + +D_FILES := $(O_FILES:%.o=%.d) + +LIB := libultraship.a + +INC_DIRS := $(addprefix -I, \ + ../ZAPDTR/ZAPDUtils \ + libultraship/Lib/Fast3D/U64 \ + libultraship/Lib/spdlog \ + libultraship/Lib/spdlog/include \ + libultraship \ +) # create build directories -$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) +$(shell mkdir -p $(SRC_DIRS:%=build/%)) all: $(LIB) @@ -17,12 +80,17 @@ clean: rm -rf build $(LIB) format: - clang-format-11 -i $(CPP_FILES) $(H_FILES) + $(FORMAT) -i $(FMT_FILES) .PHONY: all clean format build/%.o: %.cpp - $(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD/ZAPD -I ../ZAPD/ZAPDUtils -I ../../ZAPD/lib/tinyxml2 -I otrlib/Lib/spdlog/include -c $(OUTPUT_OPTION) $< + $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@ + +build/%.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@ $(LIB): $(O_FILES) $(AR) rcs $@ $^ + +-include $(D_FILES) \ No newline at end of file diff --git a/libultraship/libultraship/Animation.cpp b/libultraship/libultraship/Animation.cpp index be2decad3..f9a6e2ee8 100644 --- a/libultraship/libultraship/Animation.cpp +++ b/libultraship/libultraship/Animation.cpp @@ -21,7 +21,7 @@ void Ship::AnimationV0::ParseFileBinary(BinaryReader* reader, Resource* res) uint32_t rotIndCnt = reader->ReadUInt32(); anim->rotationIndices.reserve(rotIndCnt); - for (int i = 0; i < rotIndCnt; i++) + for (size_t i = 0; i < rotIndCnt; i++) { uint16_t x = reader->ReadUInt16(); uint16_t y = reader->ReadUInt16(); diff --git a/libultraship/libultraship/Archive.cpp b/libultraship/libultraship/Archive.cpp index 41c6649f8..1e8f8d597 100644 --- a/libultraship/libultraship/Archive.cpp +++ b/libultraship/libultraship/Archive.cpp @@ -7,7 +7,7 @@ #include namespace Ship { - Archive::Archive(const std::string& MainPath, bool enableWriting) : Archive(MainPath, "", enableWriting) + Archive::Archive(const std::string& MainPath, bool enableWriting) : Archive(MainPath, "", enableWriting) { mainMPQ = nullptr; } @@ -28,7 +28,7 @@ namespace Ship { std::shared_ptr Archive::CreateArchive(const std::string& archivePath, int fileCapacity) { - Archive* archive = new Archive(archivePath, true); + auto archive = std::make_shared(archivePath, true); TCHAR* t_filename = new TCHAR[archivePath.size() + 1]; t_filename[archivePath.size()] = 0; @@ -37,10 +37,15 @@ namespace Ship { bool success = SFileCreateArchive(t_filename, MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES | MPQ_CREATE_ARCHIVE_V2, fileCapacity, &archive->mainMPQ); int error = GetLastError(); - if (success) { + delete[] t_filename; + + if (success) + { archive->mpqHandles[archivePath] = archive->mainMPQ; - return std::make_shared(*archive); - } else { + return archive; + } + else + { SPDLOG_ERROR("({}) We tried to create an archive, but it has fallen and cannot get up."); return nullptr; } @@ -49,11 +54,16 @@ namespace Ship { std::shared_ptr Archive::LoadFile(const std::string& filePath, bool includeParent, std::shared_ptr FileToLoad) { HANDLE fileHandle = NULL; + if (FileToLoad == nullptr) { + FileToLoad = std::make_shared(); + FileToLoad->path = filePath; + } + if (!SFileOpenFileEx(mainMPQ, filePath.c_str(), 0, &fileHandle)) { SPDLOG_ERROR("({}) Failed to open file {} from mpq archive {}", GetLastError(), filePath.c_str(), MainPath.c_str()); std::unique_lock Lock(FileToLoad->FileLoadMutex); FileToLoad->bHasLoadError = true; - return nullptr; + return FileToLoad; } DWORD dwFileSize = SFileGetFileSize(fileHandle, 0); @@ -67,18 +77,13 @@ namespace Ship { } std::unique_lock Lock(FileToLoad->FileLoadMutex); FileToLoad->bHasLoadError = true; - return nullptr; + return FileToLoad; } if (!SFileCloseFile(fileHandle)) { SPDLOG_ERROR("({}) Failed to close file {} from mpq archive {}", GetLastError(), filePath.c_str(), MainPath.c_str()); } - if (FileToLoad == nullptr) { - FileToLoad = std::make_shared(); - FileToLoad->path = filePath; - } - std::unique_lock Lock(FileToLoad->FileLoadMutex); FileToLoad->parent = includeParent ? shared_from_this() : nullptr; FileToLoad->buffer = fileData; @@ -92,6 +97,11 @@ namespace Ship { HANDLE fileHandle = NULL; HANDLE mpqHandle = NULL; + if (FileToLoad == nullptr) { + FileToLoad = std::make_shared(); + FileToLoad->path = filePath; + } + for(auto [path, handle] : mpqHandles) { if (SFileOpenFileEx(mpqHandle, filePath.c_str(), 0, &fileHandle)) { std::unique_lock Lock(FileToLoad->FileLoadMutex); @@ -116,18 +126,13 @@ namespace Ship { } std::unique_lock Lock(FileToLoad->FileLoadMutex); FileToLoad->bHasLoadError = true; - return nullptr; + return FileToLoad; } if (!SFileCloseFile(fileHandle)) { SPDLOG_ERROR("({}) Failed to close file {} from mpq archive {}", GetLastError(), filePath.c_str(), MainPath.c_str()); } - if (FileToLoad == nullptr) { - FileToLoad = std::make_shared(); - FileToLoad->path = filePath; - } - std::unique_lock Lock(FileToLoad->FileLoadMutex); FileToLoad->parent = includeParent ? shared_from_this() : nullptr; FileToLoad->buffer = fileData; @@ -139,13 +144,16 @@ namespace Ship { bool Archive::AddFile(const std::string& path, uintptr_t fileData, DWORD dwFileSize) { HANDLE hFile; - +#ifdef _WIN32 SYSTEMTIME sysTime; GetSystemTime(&sysTime); FILETIME t; SystemTimeToFileTime(&sysTime, &t); ULONGLONG stupidHack = static_cast(t.dwHighDateTime) << (sizeof(t.dwHighDateTime) * 8) | t.dwLowDateTime; - +#else + time_t stupidHack; + time(&stupidHack); +#endif if (!SFileCreateFile(mainMPQ, path.c_str(), stupidHack, dwFileSize, 0, MPQ_FILE_COMPRESS, &hFile)) { SPDLOG_ERROR("({}) Failed to create file of {} bytes {} in archive {}", GetLastError(), dwFileSize, path.c_str(), MainPath.c_str()); return false; @@ -181,7 +189,7 @@ namespace Ship { SPDLOG_ERROR("({}) Failed to remove file {} in archive {}", GetLastError(), path.c_str(), MainPath.c_str()); return false; } - + return true; } @@ -201,7 +209,7 @@ namespace Ship { SFILE_FIND_DATA findContext; HANDLE hFind; - + hFind = SFileFindFirstFile(mainMPQ, searchMask.c_str(), &findContext, nullptr); //if (hFind && GetLastError() != ERROR_NO_MORE_FILES) { if (hFind != nullptr) { @@ -245,7 +253,7 @@ namespace Ship { auto start = std::chrono::steady_clock::now(); auto lst = ListFiles(filename); - + for (const auto& item : lst) { if (item.cFileName == filename) { result = true; @@ -267,7 +275,7 @@ namespace Ship { return LoadMainMPQ(enableWriting, genCRCMap) && LoadPatchMPQs(); } - bool Archive::Unload() + bool Archive::Unload() { bool success = true; for (const auto& mpqHandle : mpqHandles) { @@ -302,11 +310,16 @@ namespace Ship { bool Archive::LoadMainMPQ(bool enableWriting, bool genCRCMap) { HANDLE mpqHandle = NULL; +#ifdef _WIN32 + std::wstring wfullPath = std::filesystem::absolute(MainPath).wstring(); +#endif std::string fullPath = std::filesystem::absolute(MainPath).string(); - std::wstring wFileName = std::filesystem::absolute(MainPath).wstring(); - - if (!SFileOpenArchive(wFileName.c_str(), 0, enableWriting ? 0 : MPQ_OPEN_READ_ONLY, &mpqHandle)) { +#ifdef _WIN32 + if (!SFileOpenArchive(wfullPath.c_str(), 0, enableWriting ? 0 : MPQ_OPEN_READ_ONLY, &mpqHandle)) { +#else + if (!SFileOpenArchive(fullPath.c_str(), 0, enableWriting ? 0 : MPQ_OPEN_READ_ONLY, &mpqHandle)) { +#endif SPDLOG_ERROR("({}) Failed to open main mpq file {}.", GetLastError(), fullPath.c_str()); return false; } @@ -340,12 +353,19 @@ namespace Ship { std::wstring wPath = std::filesystem::absolute(path).wstring(); +#ifdef _WIN32 if (!SFileOpenArchive(wPath.c_str(), 0, MPQ_OPEN_READ_ONLY, &patchHandle)) { +#else + if (!SFileOpenArchive(fullPath.c_str(), 0, MPQ_OPEN_READ_ONLY, &patchHandle)) { +#endif SPDLOG_ERROR("({}) Failed to open patch mpq file {} while applying to {}.", GetLastError(), path.c_str(), MainPath.c_str()); return false; } - +#ifdef _WIN32 if (!SFileOpenPatchArchive(mainMPQ, wPath.c_str(), "", 0)) { +#else + if (!SFileOpenPatchArchive(mainMPQ, fullPath.c_str(), "", 0)) { +#endif SPDLOG_ERROR("({}) Failed to apply patch mpq file {} to main mpq {}.", GetLastError(), path.c_str(), MainPath.c_str()); return false; } diff --git a/libultraship/libultraship/Array.cpp b/libultraship/libultraship/Array.cpp index f256903bf..fdd522c11 100644 --- a/libultraship/libultraship/Array.cpp +++ b/libultraship/libultraship/Array.cpp @@ -51,6 +51,8 @@ namespace Ship data.u16 = reader->ReadUInt16(); break; // OTRTODO: IMPLEMENT OTHER TYPES! + default: + break; } arr->scalars.push_back(data); diff --git a/libultraship/libultraship/ConfigFile.cpp b/libultraship/libultraship/ConfigFile.cpp index 2e9a8cc94..8a0794643 100644 --- a/libultraship/libultraship/ConfigFile.cpp +++ b/libultraship/libultraship/ConfigFile.cpp @@ -72,7 +72,7 @@ namespace Ship { (*this)["WINDOW"]["FULLSCREEN WIDTH"] = std::to_string(1920); (*this)["WINDOW"]["FULLSCREEN HEIGHT"] = std::to_string(1080); (*this)["WINDOW"]["FULLSCREEN"] = std::to_string(false); - (*this)["WINDOW"]["GFX BACKEND"] = "sdl"; + (*this)["WINDOW"]["GFX BACKEND"] = ""; (*this)["KEYBOARD CONTROLLER BINDING 1"][STR(BTN_CRIGHT)] = std::to_string(0x14D); (*this)["KEYBOARD CONTROLLER BINDING 1"][STR(BTN_CLEFT)] = std::to_string(0x14B); diff --git a/libultraship/libultraship/ConfigFile.h b/libultraship/libultraship/ConfigFile.h index dcf2a0e4a..b94e22f88 100644 --- a/libultraship/libultraship/ConfigFile.h +++ b/libultraship/libultraship/ConfigFile.h @@ -1,3 +1,6 @@ +#ifndef CONFIG_FILE_H +#define CONFIG_FILE_H + #pragma once #include @@ -29,9 +32,11 @@ namespace Ship { bool CreateDefaultConfig(); private: - mINI::INIFile File; mINI::INIStructure Val; std::weak_ptr Context; std::string Path; + mINI::INIFile File; }; } + +#endif diff --git a/libultraship/libultraship/Cvar.cpp b/libultraship/libultraship/Cvar.cpp index 91788fd48..891ee73af 100644 --- a/libultraship/libultraship/Cvar.cpp +++ b/libultraship/libultraship/Cvar.cpp @@ -1,23 +1,22 @@ -#include "cvar.h" +#include "Cvar.h" #include #include +#include +#include +#include #include -std::map cvars; - -CVar* CVar_GetVar(const char* name) { - std::string key(name); - return cvars.contains(key) ? cvars[key] : nullptr; -} +std::map, std::less<>> cvars; extern "C" CVar* CVar_Get(const char* name) { - return CVar_GetVar(name); + auto it = cvars.find(name); + return (it != cvars.end()) ? it->second.get() : nullptr; } extern "C" s32 CVar_GetS32(const char* name, s32 defaultValue) { CVar* cvar = CVar_Get(name); - if (cvar != nullptr) { + if (cvar) { if (cvar->type == CVAR_TYPE_S32) return cvar->value.valueS32; } @@ -28,7 +27,7 @@ extern "C" s32 CVar_GetS32(const char* name, s32 defaultValue) { extern "C" float CVar_GetFloat(const char* name, float defaultValue) { CVar* cvar = CVar_Get(name); - if (cvar != nullptr) { + if (cvar) { if (cvar->type == CVAR_TYPE_FLOAT) return cvar->value.valueFloat; } @@ -36,10 +35,10 @@ extern "C" float CVar_GetFloat(const char* name, float defaultValue) { return defaultValue; } -extern "C" char* CVar_GetString(const char* name, char* defaultValue) { +extern "C" const char* CVar_GetString(const char* name, const char* defaultValue) { CVar* cvar = CVar_Get(name); - if (cvar != nullptr) { + if (cvar) { if (cvar->type == CVAR_TYPE_STRING) return cvar->value.valueStr; } @@ -48,53 +47,43 @@ extern "C" char* CVar_GetString(const char* name, char* defaultValue) { } extern "C" void CVar_SetS32(const char* name, s32 value) { - CVar* cvar = CVar_Get(name); + auto& cvar = cvars[name]; if (!cvar) { - cvar = new CVar; - cvars[std::string(name)] = cvar; + cvar = std::make_unique(); } cvar->type = CVAR_TYPE_S32; cvar->value.valueS32 = value; } void CVar_SetFloat(const char* name, float value) { - CVar* cvar = CVar_Get(name); + auto& cvar = cvars[name]; if (!cvar) { - cvar = new CVar; - cvars[std::string(name)] = cvar; + cvar = std::make_unique(); } cvar->type = CVAR_TYPE_FLOAT; cvar->value.valueFloat = value; } -void CVar_SetString(const char* name, char* value) { - CVar* cvar = CVar_Get(name); +void CVar_SetString(const char* name, const char* value) { + auto& cvar = cvars[name]; if (!cvar) { - cvar = new CVar; - cvars[std::string(name)] = cvar; + cvar = std::make_unique(); } cvar->type = CVAR_TYPE_STRING; cvar->value.valueStr = value; } - extern "C" void CVar_RegisterS32(const char* name, s32 defaultValue) { - CVar* cvar = CVar_Get(name); - - if (cvar == nullptr) + if (!CVar_Get(name)) CVar_SetS32(name, defaultValue); } extern "C" void CVar_RegisterFloat(const char* name, float defaultValue) { - CVar* cvar = CVar_Get(name); - - if (cvar == nullptr) + if (!CVar_Get(name)) CVar_SetFloat(name, defaultValue); } -extern "C" void CVar_RegisterString(const char* name, char* defaultValue) { - CVar* cvar = CVar_Get(name); - - if (cvar == nullptr) +extern "C" void CVar_RegisterString(const char* name, const char* defaultValue) { + if (!CVar_Get(name)) CVar_SetString(name, defaultValue); } diff --git a/libultraship/libultraship/Cvar.h b/libultraship/libultraship/Cvar.h index a85bb8fd3..e16f4469f 100644 --- a/libultraship/libultraship/Cvar.h +++ b/libultraship/libultraship/Cvar.h @@ -6,13 +6,13 @@ typedef enum CVarType { CVAR_TYPE_S32, CVAR_TYPE_FLOAT, CVAR_TYPE_STRING } CVarType; typedef struct CVar { - char* name; + const char* name; CVarType type; union { s32 valueS32; float valueFloat; - char* valueStr; + const char* valueStr; } value; } CVar; @@ -22,16 +22,15 @@ extern "C" #endif //#include - CVar* CVar_Get(const char* name); s32 CVar_GetS32(const char* name, s32 defaultValue); float CVar_GetFloat(const char* name, float defaultValue); -char* CVar_GetString(const char* name, char* defaultValue); +const char* CVar_GetString(const char* name, const char* defaultValue); void CVar_SetS32(const char* name, s32 value); void CVar_RegisterS32(const char* name, s32 defaultValue); void CVar_RegisterFloat(const char* name, float defaultValue); -void CVar_RegisterString(const char* name, char* defaultValue); +void CVar_RegisterString(const char* name, const char* defaultValue); #ifdef __cplusplus }; @@ -40,10 +39,11 @@ void CVar_RegisterString(const char* name, char* defaultValue); #ifdef __cplusplus #include #include +#include +#include -extern std::map cvars; -CVar* CVar_GetVar(const char* name); +extern std::map, std::less<>> cvars; void CVar_SetFloat(const char* name, float value); -void CVar_SetString(const char* name, char* value); +void CVar_SetString(const char* name, const char* value); #endif #endif diff --git a/libultraship/libultraship/Factories/OTRResourceLoader.cpp b/libultraship/libultraship/Factories/OTRResourceLoader.cpp deleted file mode 100644 index 125e0d9ec..000000000 --- a/libultraship/libultraship/Factories/OTRResourceLoader.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "OTRResourceLoader.h" -#include "OTRMaterialFactory.h" -#include "OTRSceneFactory.h" -#include "OTRCollisionHeaderFactory.h" -#include "OTRDisplayListFactory.h" -#include "OTRPlayerAnimationFactory.h" -#include "OTRSkeletonFactory.h" -#include "OTRSkeletonLimbFactory.h" -#include "OTRAnimationFactory.h" -#include "OTRVtxFactory.h" -#include "OTRCutsceneFactory.h" -#include "OTRArrayFactory.h" -#include "OTRPathFactory.h" - -namespace OtrLib -{ - OTRResource* OTRResourceLoader::LoadResource(BinaryReader* reader) - { - Endianess endianess = (Endianess)reader->ReadByte(); - - // TODO: Setup the binaryreader to use the resource's endianess - - ResourceType resourceType = (ResourceType)reader->ReadUInt32(); - OTRResource* result = nullptr; - - switch (resourceType) - { - case ResourceType::OTRMaterial: - result = OTRMaterialFactory::ReadMaterial(reader); - break; - case ResourceType::OTRRoom: - result = OTRSceneFactory::ReadScene(reader); - break; - case ResourceType::OTRCollisionHeader: - result = OTRCollisionHeaderFactory::ReadCollisionHeader(reader); - break; - case ResourceType::OTRDisplayList: - result = OTRDisplayListFactory::ReadDisplayList(reader); - break; - case ResourceType::OTRPlayerAnimation: - result = OTRPlayerAnimationFactory::ReadPlayerAnimation(reader); - break; - case ResourceType::OTRSkeleton: - result = OTRSkeletonFactory::ReadSkeleton(reader); - break; - case ResourceType::OTRSkeletonLimb: - result = OTRSkeletonLimbFactory::ReadSkeletonLimb(reader); - break; - case ResourceType::OTRVtx: - result = OTRVtxFactory::ReadVtx(reader); - break; - case ResourceType::OTRAnimation: - result = OTRAnimationFactory::ReadAnimation(reader); - break; - case ResourceType::OTRCutscene: - result = OTRCutsceneFactory::ReadCutscene(reader); - break; - case ResourceType::OTRArray: - result = OTRArrayFactory::ReadArray(reader); - break; - case ResourceType::OTRPath: - result = OTRPathFactory::ReadPath(reader); - break; - default: - // RESOURCE TYPE NOT SUPPORTED - break; - } - - return result; - } -} \ No newline at end of file diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp new file mode 100644 index 000000000..042ff980c --- /dev/null +++ b/libultraship/libultraship/GameOverlay.cpp @@ -0,0 +1,225 @@ +#include "GameOverlay.h" + +#include "Cvar.h" +#include "File.h" +#include "Archive.h" +#include "ResourceMgr.h" +#include "SohConsole.h" +#include "SohImGuiImpl.h" +#include "TextureMod.h" +#include "Lib/ImGui/imgui_internal.h" +#include "Utils/StringHelper.h" + +void Ship::GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) { + ImGuiIO& io = ImGui::GetIO(); + std::shared_ptr base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive(); + std::shared_ptr font = std::make_shared(); + base->LoadFile(path, false, font); + if (font->bIsLoaded) { + char* font_data = new char[font->dwBufferSize]; + memcpy(font_data, font->buffer.get(), font->dwBufferSize); + Fonts[name] = io.Fonts->AddFontFromMemoryTTF(font_data, font->dwBufferSize, fontSize); + } +} + +void Ship::GameOverlay::TextDraw(float x, float y, bool shadow, ImVec4 color, const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf) - 1] = 0; + va_end(args); + + ImGui::PushStyleColor(ImGuiCol_Text, color); + ImGui::PushFont(Fonts[this->CurrentFont]); + if (shadow) { + ImGui::SetCursorPos(ImVec2(x + 1, y + 1)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(.0f, .0f, .0f, color.w)); + ImGui::Text(buf, args); + } + ImGui::PopStyleColor(); + ImGui::SetCursorPos(ImVec2(x, y)); + ImGui::Text(buf, args); + ImGui::PopFont(); + ImGui::PopStyleColor(); +} + +void Ship::GameOverlay::TextDrawNotification(float duration, bool shadow, const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf) - 1] = 0; + va_end(args); + this->RegisteredOverlays[StringHelper::Sprintf("NotificationID:%d%d", rand(), this->RegisteredOverlays.size())] = new Overlay({ OverlayType::NOTIFICATION, ImStrdup(buf), duration, duration }); + NeedsCleanup = true; +} + +void Ship::GameOverlay::CleanupNotifications() { + if(!NeedsCleanup) return; + for (auto it = this->RegisteredOverlays.begin(); it != this->RegisteredOverlays.end(); ) { + if (it->second->type == OverlayType::NOTIFICATION && it->second->duration <= 0.0f) { + it = this->RegisteredOverlays.erase(it); + } else { + ++it; + } + } + NeedsCleanup = false; +} + +float Ship::GameOverlay::GetScreenWidth() { + const ImGuiViewport* viewport = ImGui::GetMainViewport(); + return viewport->Size.x; +} + +float Ship::GameOverlay::GetScreenHeight() { + const ImGuiViewport* viewport = ImGui::GetMainViewport(); + return viewport->Size.y; +} + +float Ship::GameOverlay::GetStringWidth(const char* text) { + return CalculateTextSize(text).x; +} + +ImVec2 Ship::GameOverlay::CalculateTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) { + ImGuiContext& g = *GImGui; + + const char* text_display_end; + if (hide_text_after_double_hash) + text_display_end = ImGui::FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string + else + text_display_end = text_end; + + GameOverlay* overlay = SohImGui::overlay; + + ImFont* font = overlay->CurrentFont == "Default" ? g.Font : overlay->Fonts[overlay->CurrentFont]; + const float font_size = font->FontSize; + if (text == text_display_end) + return ImVec2(0.0f, font_size); + ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); + + // Round + // FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out. + // FIXME: Investigate using ceilf or e.g. + // - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c + // - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html + text_size.x = IM_FLOOR(text_size.x + 0.99999f); + + return text_size; +} + +void Ship::GameOverlay::Init() { + this->LoadFont("Press Start 2P", "assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf", 12.0f); + this->LoadFont("Fipps", "assets/ship_of_harkinian/fonts/Fipps-Regular.otf", 32.0f); + const std::string DefaultFont = this->Fonts.begin()->first; + if(!this->Fonts.empty()) { + const std::string font = CVar_GetString("gOverlayFont", ImStrdup(DefaultFont.c_str())); + for (auto& [name, _] : this->Fonts) { + if (font.starts_with(name)) { + this->CurrentFont = name; + break; + } + this->CurrentFont = DefaultFont; + } + } + SohImGui::console->Commands["overlay"] = { OverlayCommand, "Draw an overlay using a cvar value" }; +} + +void Ship::GameOverlay::DrawSettings() { + ImGui::Text("Overlays Text Font"); + if (ImGui::BeginCombo("##TextFont", this->CurrentFont.c_str())) { + for (auto& [name, font] : this->Fonts) { + if (ImGui::Selectable(name.c_str(), name == this->CurrentFont)) { + this->CurrentFont = name; + CVar_SetString("gOverlayFont", ImStrdup(name.c_str())); + SohImGui::needs_save = true; + } + + } + ImGui::EndCombo(); + } +} + + +void Ship::GameOverlay::Draw() { + const ImGuiViewport* viewport = ImGui::GetMainViewport(); + + ImGui::SetNextWindowPos(viewport->Pos, ImGuiCond_Always); + ImGui::SetNextWindowSize(viewport->Size, ImGuiCond_Always); + ImGui::Begin("SoHOverlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | + ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs); + + this->CleanupNotifications(); + + float textY = 50; + float notY = 0; + + for (auto &[key, overlay] : this->RegisteredOverlays) { + + if (overlay->type == OverlayType::TEXT) { + const char* text = ImStrdup(overlay->value); + const CVar* var = CVar_Get(text); + ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + + switch (var->type) { + case CVAR_TYPE_FLOAT: + this->TextDraw(30, textY, true, color, "%s %.2f", text, var->value.valueFloat); + break; + case CVAR_TYPE_S32: + this->TextDraw(30, textY, true, color, "%s %d", text, var->value.valueS32); + break; + case CVAR_TYPE_STRING: + this->TextDraw(30, textY, true, color, "%s %s", text, var->value.valueStr); + break; + } + + free((void*) text); + textY += 30; + } + + if (overlay->type == OverlayType::NOTIFICATION && overlay->duration > 0) { + const char* text = overlay->value; + const float duration = overlay->duration / overlay->fadeTime; + + const ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, duration); + const float textWidth = this->GetStringWidth(overlay->value); + + this->TextDraw(GetScreenWidth() - textWidth - 40, GetScreenHeight() - 40 - notY, true, color, text); + notY += 30; + overlay->duration -= .05f; + } + } + + ImGui::End(); +} + + +bool Ship::OverlayCommand(const std::vector& args) { + if (args.size() < 3) { + return CMD_FAILED; + } + + if (CVar_Get(args[2].c_str()) != nullptr) { + const char* key = args[2].c_str(); + GameOverlay* overlay = SohImGui::overlay; + if (args[1] == "add") { + if (!overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); + INFO("Added overlay: %s ", key); + } else { + ERROR("Overlay already exists: %s", key); + } + } else if (args[1] == "remove") { + if (overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays.erase(key); + INFO("Removed overlay: %s ", key); + } else { + ERROR("Overlay not found: %s ", key); + } + } + } else { + ERROR("CVar %s does not exist", args[2].c_str()); + } + + return CMD_SUCCESS; +} \ No newline at end of file diff --git a/libultraship/libultraship/GameOverlay.h b/libultraship/libultraship/GameOverlay.h new file mode 100644 index 000000000..605cd5898 --- /dev/null +++ b/libultraship/libultraship/GameOverlay.h @@ -0,0 +1,42 @@ +#pragma once +#include +#include + +#include "Lib/ImGui/imgui.h" +#include +#include + +enum class OverlayType { + TEXT, IMAGE, NOTIFICATION +}; + +struct Overlay { + OverlayType type; + const char* value; + float fadeTime; + float duration; +}; + +namespace Ship { + class GameOverlay { + public: + std::unordered_map RegisteredOverlays; + std::unordered_map Fonts; + std::string CurrentFont = "Default"; + void Init(); + void Draw(); + void DrawSettings(); + static float GetScreenWidth(); + static float GetScreenHeight(); + static float GetStringWidth(const char* text); + static ImVec2 CalculateTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); + void TextDraw(float x, float y, bool shadow, ImVec4 color, const char* text, ...); + void TextDrawNotification(float duration, bool shadow, const char* fmt, ...); + private: + bool NeedsCleanup = false; + void CleanupNotifications(); + void LoadFont(const std::string& name, const std::string& path, float fontSize); + }; + + static bool OverlayCommand(const std::vector& args); +} diff --git a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp index 9b7543b7d..0cd9aa2f4 100644 --- a/libultraship/libultraship/GameSettings.cpp +++ b/libultraship/libultraship/GameSettings.cpp @@ -1,22 +1,22 @@ #include "GameSettings.h" // Audio +#include +#include #include #include #include -#include #include "ConfigFile.h" #include "Cvar.h" #include "GlobalCtx2.h" #include "SohImGuiImpl.h" -#include "stox.h" #include "../../soh/include/z64audio.h" -#include #include "SohHooks.h" #include "../../soh/soh/Enhancements/debugconsole.h" #include "Window.h" +#include "Lib/Fast3D/gfx_rendering_api.h" #define ABS(var) var < 0 ? -(var) : var @@ -25,14 +25,6 @@ using namespace Ship; namespace Game { bool DeSyncAudio = false; - SoHConfigType Settings; - const std::string ConfSection = DEBUG_SECTION; - const std::string AudioSection = AUDIO_SECTION; - const std::string ControllerSection = CONTROLLER_SECTION; - const std::string EnhancementSection = ENHANCEMENTS_SECTION; - const std::string CosmeticsSection = COSMETICS_SECTION; - const std::string CheatSection = CHEATS_SECTION; - void UpdateAudio() { Audio_SetGameVolume(SEQ_BGM_MAIN, CVar_GetFloat("gMainMusicVolume", 1)); @@ -41,18 +33,6 @@ namespace Game { Audio_SetGameVolume(SEQ_SFX, CVar_GetFloat("gFanfareVolume", 1)); } - void LoadSettings() { - const std::shared_ptr pConf = GlobalCtx2::GetInstance()->GetConfig(); - ConfigFile& Conf = *pConf; - - // Debug - SohImGui::console->opened = stob(Conf[ConfSection]["console"]); - Settings.debug.menu_bar = stob(Conf[ConfSection]["menu_bar"]); - Settings.debug.soh = stob(Conf[ConfSection]["soh_debug"]); - - UpdateAudio(); - } - void LoadPadSettings() { const std::shared_ptr pConf = GlobalCtx2::GetInstance()->GetConfig(); ConfigFile& Conf = *pConf; @@ -65,16 +45,11 @@ namespace Game { } } + void LoadSettings() { + DebugConsole_LoadCVars(); + } + void SaveSettings() { - const std::shared_ptr pConf = GlobalCtx2::GetInstance()->GetConfig(); - ConfigFile& Conf = *pConf; - - // Debug - Conf[ConfSection]["console"] = std::to_string(SohImGui::console->opened); - Conf[ConfSection]["menu_bar"] = std::to_string(Settings.debug.menu_bar); - Conf[ConfSection]["soh_debug"] = std::to_string(Settings.debug.soh); - - Conf.Save(); DebugConsole_SaveCVars(); } @@ -82,6 +57,11 @@ namespace Game { ModInternal::registerHookListener({ AUDIO_INIT, [](HookEvent ev) { UpdateAudio(); }}); + ModInternal::registerHookListener({ GFX_INIT, [](HookEvent ev) { + gfx_get_current_rendering_api()->set_texture_filter((FilteringMode) CVar_GetS32("gTextureFilter", THREE_POINT)); + SohImGui::console->opened = CVar_GetS32("gConsoleEnabled", 0); + UpdateAudio(); + }}); } void SetSeqPlayerVolume(SeqPlayers playerId, float volume) { diff --git a/libultraship/libultraship/GameSettings.h b/libultraship/libultraship/GameSettings.h index 4b9956d17..0a9aa0ee6 100644 --- a/libultraship/libultraship/GameSettings.h +++ b/libultraship/libultraship/GameSettings.h @@ -1,19 +1,5 @@ #pragma once -struct SoHConfigType { - // Debug - struct { - bool soh = false; - bool menu_bar = false; - bool soh_sink = true; - } debug; - - // Graphics - struct { - bool show = false; - } graphics; -}; - enum SeqPlayers { /* 0 */ SEQ_BGM_MAIN, /* 1 */ SEQ_FANFARE, @@ -22,15 +8,7 @@ enum SeqPlayers { /* 4 */ SEQ_MAX }; -#define DEBUG_SECTION "DEBUG SETTINGS" -#define AUDIO_SECTION "AUDIO SETTINGS" -#define CONTROLLER_SECTION "CONTROLLER SECTION" -#define ENHANCEMENTS_SECTION "ENHANCEMENT SETTINGS" -#define COSMETICS_SECTION "COSMETIC SETTINGS" -#define CHEATS_SECTION "CHEATS SETTINGS" - namespace Game { - extern SoHConfigType Settings; void InitSettings(); void LoadSettings(); void LoadPadSettings(); diff --git a/libultraship/libultraship/GameVersions.h b/libultraship/libultraship/GameVersions.h index a25463bf4..8d3753b21 100644 --- a/libultraship/libultraship/GameVersions.h +++ b/libultraship/libultraship/GameVersions.h @@ -1,3 +1,6 @@ +#ifndef GAME_VERSION_H +#define GAME_VERSION_H + #pragma once #define OOT_NTSC_10 0xEC7011B7 @@ -17,4 +20,6 @@ #define OOT_PAL_GC_MQ_DBG 0x917D18F6 #define OOT_IQUE_TW 0x3D81FB3E #define OOT_IQUE_CN 0xB1E1E07B -#define OOT_UNKNOWN 0xFFFFFFFF \ No newline at end of file +#define OOT_UNKNOWN 0xFFFFFFFF + +#endif diff --git a/libultraship/libultraship/GlobalCtx2.cpp b/libultraship/libultraship/GlobalCtx2.cpp index dd8125bcc..5ce59f5ab 100644 --- a/libultraship/libultraship/GlobalCtx2.cpp +++ b/libultraship/libultraship/GlobalCtx2.cpp @@ -30,7 +30,7 @@ namespace Ship { } GlobalCtx2::GlobalCtx2(const std::string& Name) : Name(Name), MainPath(""), PatchesPath("") { - + } GlobalCtx2::~GlobalCtx2() { @@ -54,7 +54,11 @@ namespace Ship { if (!ResMan->DidLoadSuccessfully()) { +#ifdef _WIN32 MessageBox(NULL, L"Main OTR file not found!", L"Uh oh", MB_OK); +#else + SPDLOG_ERROR("Main OTR file not found!"); +#endif exit(1); } INSTANCE = new ModManager(ResMan); diff --git a/libultraship/libultraship/GlobalCtx2.h b/libultraship/libultraship/GlobalCtx2.h index a10421ec0..1ed512347 100644 --- a/libultraship/libultraship/GlobalCtx2.h +++ b/libultraship/libultraship/GlobalCtx2.h @@ -1,3 +1,6 @@ +#ifndef GLOBAL_CTX_2 +#define GLOBAL_CTX_2 + #pragma once #ifdef __cplusplus @@ -38,4 +41,6 @@ namespace Ship { std::string PatchesPath; }; } -#endif \ No newline at end of file +#endif + +#endif diff --git a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h index 8af624e8f..a9e4f035e 100644 --- a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h +++ b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/gbi.h @@ -1004,7 +1004,7 @@ #define G_DL_PUSH 0x00 #define G_DL_NOPUSH 0x01 -#if _MSC_VER +#if defined(_MSC_VER) || defined(__GNUC__) #define _LANGUAGE_C #endif @@ -3132,7 +3132,7 @@ _DW({ \ #endif */ -#ifdef _MSC_VER +#if defined(_MSC_VER) #define CALL_2(A,B) A B #define CALL_3(A,B,C) A B C @@ -3143,12 +3143,12 @@ _DW({ \ #define gsDPSetCombineMode(a, b) gsDPSetCombineLERP(a, b) #endif -#if _MSC_VER +#if defined(_MSC_VER) || defined(__GNUC__) #define CALL_2(A,B) A B #define CALL_3(A,B,C) A B C -#define gsDPSetCombineMode(a, b) CALL_2(gsDPSetCombineLERP, (a, b)) - //#define gsDPSetCombineMode(a, b) _SHIFTL(0, 24, 8), 0 +// #define gsDPSetCombineMode(a, b) CALL_2(gsDPSetCombineLERP, (a, b)) +// #define gsDPSetCombineMode(a, b) _SHIFTL(0, 24, 8), 0 #else #define gsDPSetCombineMode(a, b) gsDPSetCombineLERP(a, b) #endif @@ -4575,6 +4575,20 @@ _DW({ \ _g2->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ } +# define gsSPWideTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ +{{ \ + (_SHIFTL(G_TEXRECT_WIDE, 24, 8) | _SHIFTL((xh), 0, 24)), \ + _SHIFTL((yh), 0, 24), \ +}}, \ +{{ \ + (_SHIFTL((tile), 24, 3) | _SHIFTL((xl), 0, 24)), \ + _SHIFTL((yl), 0, 24), \ +}}, \ +{{ \ + _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ + _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ +}} + /* like gSPTextureRectangle but accepts negative position arguments */ #define gSPScisTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ _DW({ \ diff --git a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/mbi.h b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/mbi.h index fd6042ff5..988c309df 100644 --- a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/mbi.h +++ b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/mbi.h @@ -33,6 +33,7 @@ #define G_OFF (0) #include +#include "types.h" #include "gbi.h" #include "abi.h" diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_direct3d11.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_direct3d11.cpp index cea82e09e..4664a0faa 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_direct3d11.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_direct3d11.cpp @@ -15,11 +15,9 @@ #ifndef _LANGUAGE_C #define _LANGUAGE_C #endif -#include +#include "PR/ultra64/gbi.h" -#include "gfx_cc.h" #include "gfx_window_manager_api.h" -#include "gfx_rendering_api.h" #include "gfx_direct3d_common.h" #define DECLARE_GFX_DXGI_FUNCTIONS @@ -28,7 +26,9 @@ #include "gfx_screen_config.h" #include "../../SohImGuiImpl.h" -#define THREE_POINT_FILTERING 0 +#include "gfx_cc.h" +#include "gfx_rendering_api.h" +#include "gfx_pc.h" #define DEBUG_D3D 0 using namespace Microsoft::WRL; // For ComPtr @@ -135,6 +135,7 @@ static struct { //uint32_t current_width, current_height; uint32_t render_target_height; int current_framebuffer; + FilteringMode current_filter_mode = NONE; int8_t depth_test; int8_t depth_mask; @@ -157,7 +158,7 @@ static LARGE_INTEGER last_time, accumulated_time, frequency; int gfx_d3d11_create_framebuffer(void); -void create_depth_stencil_objects(uint32_t width, uint32_t height, uint32_t msaa_count, ID3D11DepthStencilView **view, ID3D11ShaderResourceView **srv) { +static void create_depth_stencil_objects(uint32_t width, uint32_t height, uint32_t msaa_count, ID3D11DepthStencilView **view, ID3D11ShaderResourceView **srv) { D3D11_TEXTURE2D_DESC texture_desc; texture_desc.Width = width; texture_desc.Height = height; @@ -397,7 +398,7 @@ static struct ShaderProgram *gfx_d3d11_create_and_load_new_shader(uint64_t shade char buf[4096]; size_t len, num_floats; - gfx_direct3d_common_build_shader(buf, len, num_floats, cc_features, false, THREE_POINT_FILTERING); + gfx_direct3d_common_build_shader(buf, len, num_floats, cc_features, false, d3d.current_filter_mode == THREE_POINT); ComPtr vs, ps; ComPtr error_blob; @@ -564,11 +565,8 @@ static void gfx_d3d11_set_sampler_parameters(int tile, bool linear_filter, uint3 D3D11_SAMPLER_DESC sampler_desc; ZeroMemory(&sampler_desc, sizeof(D3D11_SAMPLER_DESC)); -#if THREE_POINT_FILTERING - sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; -#else - sampler_desc.Filter = linear_filter ? D3D11_FILTER_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_POINT; -#endif + sampler_desc.Filter = linear_filter && d3d.current_filter_mode == LINEAR ? D3D11_FILTER_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_POINT; + sampler_desc.AddressU = gfx_cm_to_d3d11(cms); sampler_desc.AddressV = gfx_cm_to_d3d11(cmt); sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; @@ -672,12 +670,12 @@ static void gfx_d3d11_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t d3d.last_resource_views[i] = d3d.textures[d3d.current_texture_ids[i]].resource_view.Get(); d3d.context->PSSetShaderResources(i, 1, d3d.textures[d3d.current_texture_ids[i]].resource_view.GetAddressOf()); -#if THREE_POINT_FILTERING - d3d.per_draw_cb_data.textures[i].width = d3d.textures[d3d.current_texture_ids[i]].width; - d3d.per_draw_cb_data.textures[i].height = d3d.textures[d3d.current_texture_ids[i]].height; - d3d.per_draw_cb_data.textures[i].linear_filtering = d3d.textures[d3d.current_texture_ids[i]].linear_filtering; - textures_changed = true; -#endif + if (d3d.current_filter_mode == THREE_POINT) { + d3d.per_draw_cb_data.textures[i].width = d3d.textures[d3d.current_texture_ids[i]].width; + d3d.per_draw_cb_data.textures[i].height = d3d.textures[d3d.current_texture_ids[i]].height; + d3d.per_draw_cb_data.textures[i].linear_filtering = d3d.textures[d3d.current_texture_ids[i]].linear_filtering; + textures_changed = true; + } if (d3d.last_sampler_states[i].Get() != d3d.textures[d3d.current_texture_ids[i]].sampler_state.Get()) { d3d.last_sampler_states[i] = d3d.textures[d3d.current_texture_ids[i]].sampler_state.Get(); @@ -880,6 +878,15 @@ void gfx_d3d11_select_texture_fb(int fbID) { gfx_d3d11_select_texture(tile, d3d.framebuffers[fbID].texture_id); } +void gfx_d3d11_set_texture_filter(FilteringMode mode) { + d3d.current_filter_mode = mode; + gfx_texture_cache_clear(); +} + +FilteringMode gfx_d3d11_get_texture_filter(void) { + return d3d.current_filter_mode; +} + std::map, uint16_t> gfx_d3d11_get_pixel_depth(int fb_id, const std::set>& coordinates) { Framebuffer& fb = d3d.framebuffers[fb_id]; TextureData& td = d3d.textures[fb.texture_id]; @@ -985,8 +992,8 @@ std::map, uint16_t> gfx_d3d11_get_pixel_depth(int fb_id, } // namespace -ImTextureID SohImGui::GetTextureByID(int id) { - return impl.backend == Backend::DX11 ? d3d.textures[id].resource_view.Get() : reinterpret_cast(id); +ImTextureID gfx_d3d11_get_texture_by_id(int id) { + return d3d.textures[id].resource_view.Get(); } struct GfxRenderingAPI gfx_direct3d11_api = { @@ -1019,7 +1026,9 @@ struct GfxRenderingAPI gfx_direct3d11_api = { gfx_d3d11_get_pixel_depth, gfx_d3d11_get_framebuffer_texture_id, gfx_d3d11_select_texture_fb, - gfx_d3d11_delete_texture + gfx_d3d11_delete_texture, + gfx_d3d11_set_texture_filter, + gfx_d3d11_get_texture_filter }; #endif diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp index 66bb5c182..d450558b2 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp @@ -150,29 +150,29 @@ static struct { Display *dpy; Window root; Window win; - + Atom atom_wm_state; Atom atom_wm_state_fullscreen; Atom atom_wm_delete_window; - + bool is_fullscreen; void (*on_fullscreen_changed)(bool is_now_fullscreen); - + int keymap[256]; bool (*on_key_down)(int scancode); bool (*on_key_up)(int scancode); void (*on_all_keys_up)(void); - + PFNGLXGETSYNCVALUESOMLPROC glXGetSyncValuesOML; PFNGLXSWAPBUFFERSMSCOMLPROC glXSwapBuffersMscOML; PFNGLXWAITFORSBCOMLPROC glXWaitForSbcOML; - + PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; - + PFNGLXGETVIDEOSYNCSGIPROC glXGetVideoSyncSGI; PFNGLXWAITVIDEOSYNCSGIPROC glXWaitVideoSyncSGI; - + bool has_oml_sync_control; uint64_t ust0; int64_t last_msc; @@ -181,7 +181,7 @@ static struct { uint64_t last_ust; int64_t target_msc; bool dropped_frame; - + bool has_sgi_video_sync; uint64_t last_sync_counter; int64_t this_msc; @@ -220,7 +220,7 @@ static int64_t glXGetVideoSyncSGI_wrapper(void) { static void init_keymap(void) { XkbDescPtr desc = XkbGetMap(glx.dpy, 0, XkbUseCoreKbd); XkbGetNames(glx.dpy, XkbKeyNamesMask, desc); - + for (int i = desc->min_key_code; i <= desc->max_key_code && i < 256; i++) { char name[XkbKeyNameLength + 1]; memcpy(name, desc->names->keys[i].name, XkbKeyNameLength); @@ -232,7 +232,7 @@ static void init_keymap(void) { } } } - + XkbFreeNames(desc, XkbKeyNamesMask, True); XkbFreeKeyboard(desc, 0, True); } @@ -265,7 +265,7 @@ static void gfx_glx_set_fullscreen_state(bool on, bool call_callback) { return; } glx.is_fullscreen = on; - + XEvent xev; xev.xany.type = ClientMessage; xev.xclient.message_type = glx.atom_wm_state; @@ -276,8 +276,8 @@ static void gfx_glx_set_fullscreen_state(bool on, bool call_callback) { xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; XSendEvent(glx.dpy, glx.root, 0, SubstructureNotifyMask | SubstructureRedirectMask, &xev); - gfx_glx_ShowHideMouse(on); - + gfx_glx_show_cursor(on); + if (glx.on_fullscreen_changed != NULL && call_callback) { glx.on_fullscreen_changed(on); } @@ -303,7 +303,7 @@ static void gfx_glx_init(const char *game_name, bool start_in_fullscreen) { // which means that glXSwapBuffers should be non-blocking, // if we are sure to wait at least one vsync interval between calls. setenv("__GL_MaxFramesAllowed", "2", true); - + glx.dpy = XOpenDisplay(NULL); if (glx.dpy == NULL) { fprintf(stderr, "Cannot connect to X server\n"); @@ -311,7 +311,7 @@ static void gfx_glx_init(const char *game_name, bool start_in_fullscreen) { } int screen = DefaultScreen(glx.dpy); glx.root = RootWindow(glx.dpy, screen); - + GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None }; XVisualInfo *vi = glXChooseVisual(glx.dpy, 0, att); if (vi == NULL) { @@ -323,7 +323,7 @@ static void gfx_glx_init(const char *game_name, bool start_in_fullscreen) { swa.colormap = cmap; swa.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | FocusChangeMask; glx.win = XCreateWindow(glx.dpy, glx.root, 0, 0, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa); - + glx.atom_wm_state = XInternAtom(glx.dpy, "_NET_WM_STATE", False); glx.atom_wm_state_fullscreen = XInternAtom(glx.dpy, "_NET_WM_STATE_FULLSCREEN", False); glx.atom_wm_delete_window = XInternAtom(glx.dpy, "WM_DELETE_WINDOW", False); @@ -340,11 +340,11 @@ static void gfx_glx_init(const char *game_name, bool start_in_fullscreen) { XStoreName(glx.dpy, glx.win, title); GLXContext glc = glXCreateContext(glx.dpy, vi, NULL, GL_TRUE); glXMakeCurrent(glx.dpy, glx.win, glc); - + init_keymap(); - + const char *extensions = glXQueryExtensionsString(glx.dpy, screen); - + if (gfx_glx_check_extension(extensions, "GLX_OML_sync_control")) { glx.glXGetSyncValuesOML = (PFNGLXGETSYNCVALUESOMLPROC)glXGetProcAddressARB((const GLubyte *)"glXGetSyncValuesOML"); glx.glXSwapBuffersMscOML = (PFNGLXSWAPBUFFERSMSCOMLPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapBuffersMscOML"); @@ -360,7 +360,7 @@ static void gfx_glx_init(const char *game_name, bool start_in_fullscreen) { glx.glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXGetVideoSyncSGI"); glx.glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXWaitVideoSyncSGI"); } - + int64_t ust, msc, sbc; if (glx.glXGetSyncValuesOML != NULL && glx.glXGetSyncValuesOML(glx.dpy, glx.win, &ust, &msc, &sbc)) { glx.has_oml_sync_control = true; @@ -439,7 +439,7 @@ static void gfx_glx_handle_events(void) { } } } - if (xev.type == ClientMessage && xev.xclient.data.l[0] == glx.atom_wm_delete_window) { + if (xev.type == ClientMessage && (Atom)xev.xclient.data.l[0] == glx.atom_wm_delete_window) { exit(0); } } @@ -451,19 +451,19 @@ static bool gfx_glx_start_frame(void) { static void gfx_glx_swap_buffers_begin(void) { glx.wanted_ust += FRAME_INTERVAL_US_NUMERATOR; // advance 1/30 seconds on JP/US or 1/25 seconds on EU - + if (!glx.has_oml_sync_control && !glx.has_sgi_video_sync) { glFlush(); - + uint64_t target = glx.wanted_ust / FRAME_INTERVAL_US_DENOMINATOR; uint64_t now; while (target > (now = (uint64_t)get_time() - glx.ust0)) { - struct timespec ts = {(target - now) / 1000000, ((target - now) % 1000000) * 1000}; + struct timespec ts = {(time_t)((target - now) / 1000000), (time_t)(((target - now) % 1000000) * 1000)}; if (nanosleep(&ts, NULL) == 0) { break; } } - + if (target + 2 * FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR < now) { if (target + 32 * FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR >= now) { printf("Dropping frame\n"); @@ -476,10 +476,10 @@ static void gfx_glx_swap_buffers_begin(void) { } glXSwapBuffers(glx.dpy, glx.win); glx.dropped_frame = false; - + return; } - + double vsyncs_to_wait = (int64_t)(glx.wanted_ust / FRAME_INTERVAL_US_DENOMINATOR - glx.last_ust) / (double)glx.vsync_interval; if (vsyncs_to_wait <= 0) { printf("Dropping frame\n"); @@ -519,17 +519,17 @@ static void gfx_glx_swap_buffers_begin(void) { vsyncs_to_wait = 2; } glx.target_msc = glx.last_msc + vsyncs_to_wait; - + if (glx.has_oml_sync_control) { glx.glXSwapBuffersMscOML(glx.dpy, glx.win, glx.target_msc, 0, 0); } else if (glx.has_sgi_video_sync) { glFlush(); // Try to submit pending work. Don't use glFinish since that busy loops on NVIDIA proprietary driver. - + //uint64_t counter0; uint64_t counter1, counter2; - + //uint64_t before_wait = get_time(); - + counter1 = glXGetVideoSyncSGI_wrapper(); //counter0 = counter1; //int waits = 0; @@ -537,17 +537,17 @@ static void gfx_glx_swap_buffers_begin(void) { counter1 = glXWaitVideoSyncSGI_wrapper(); //++waits; } - + //uint64_t before = get_time(); glXSwapBuffers(glx.dpy, glx.win); - - + + counter2 = glXGetVideoSyncSGI_wrapper(); while (counter2 < (uint64_t)glx.target_msc) { counter2 = glXWaitVideoSyncSGI_wrapper(); } uint64_t after = get_time(); - + //printf("%.3f %.3f %.3f\t%.3f\t%u %d %.2f %u %d\n", before_wait * 0.000060, before * 0.000060, after * 0.000060, (after - before) * 0.000060, counter0, counter2 - counter0, vsyncs_to_wait, (unsigned int)glx.target_msc, waits); glx.this_msc = counter2; glx.this_ust = after; @@ -558,7 +558,7 @@ static void gfx_glx_swap_buffers_end(void) { if (glx.dropped_frame || (!glx.has_oml_sync_control && !glx.has_sgi_video_sync)) { return; } - + int64_t ust, msc, sbc; if (glx.has_oml_sync_control) { if (!glx.glXWaitForSbcOML(glx.dpy, glx.win, 0, &ust, &msc, &sbc)) { @@ -600,6 +600,10 @@ static double gfx_glx_get_time(void) { return 0.0; } +static void gfx_glx_set_frame_divisor(int divisor) { + // TODO +} + struct GfxWindowManagerAPI gfx_glx = { gfx_glx_init, gfx_glx_set_keyboard_callbacks, @@ -612,7 +616,8 @@ struct GfxWindowManagerAPI gfx_glx = { gfx_glx_start_frame, gfx_glx_swap_buffers_begin, gfx_glx_swap_buffers_end, - gfx_glx_get_time + gfx_glx_get_time, + gfx_glx_set_frame_divisor, }; #endif diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_glx.h b/libultraship/libultraship/Lib/Fast3D/gfx_glx.h index fe78db948..1ca410901 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_glx.h +++ b/libultraship/libultraship/Lib/Fast3D/gfx_glx.h @@ -3,6 +3,6 @@ #include "gfx_window_manager_api.h" -struct GfxWindowManagerAPI gfx_glx; +extern struct GfxWindowManagerAPI gfx_glx; #endif diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp index 6c5f47577..b2db3186a 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp @@ -29,8 +29,9 @@ #include "SDL_opengl.h" #else #include +#include #define GL_GLEXT_PROTOTYPES 1 -#include +// #include #endif #include "gfx_cc.h" @@ -73,6 +74,7 @@ static uint32_t frame_count; static vector framebuffers; static size_t current_framebuffer; static float current_noise_scale; +static FilteringMode current_filter_mode = THREE_POINT; GLuint pixel_depth_rb, pixel_depth_fb; size_t pixel_depth_rb_size; @@ -177,6 +179,7 @@ static const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_ return "texel.a"; } } + return ""; } static void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha) { @@ -211,7 +214,7 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad gfx_cc_get_features(shader_id0, shader_id1, &cc_features); char vs_buf[1024]; - char fs_buf[1024]; + char fs_buf[3000]; size_t vs_len = 0; size_t fs_len = 0; size_t num_floats = 4; @@ -312,21 +315,42 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad append_line(fs_buf, &fs_len, "}"); } + if (current_filter_mode == THREE_POINT) { + append_line(fs_buf, &fs_len, "#define TEX_OFFSET(off) texture2D(tex, texCoord - (off)/texSize)"); + append_line(fs_buf, &fs_len, "vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) {"); + append_line(fs_buf, &fs_len, " vec2 offset = fract(texCoord*texSize - vec2(0.5));"); + append_line(fs_buf, &fs_len, " offset -= step(1.0, offset.x + offset.y);"); + append_line(fs_buf, &fs_len, " vec4 c0 = TEX_OFFSET(offset);"); + append_line(fs_buf, &fs_len, " vec4 c1 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y));"); + append_line(fs_buf, &fs_len, " vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y)));"); + append_line(fs_buf, &fs_len, " return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0);"); + append_line(fs_buf, &fs_len, "}"); + append_line(fs_buf, &fs_len, "vec4 hookTexture2D(in sampler2D tex, in vec2 uv, in vec2 texSize) {"); + append_line(fs_buf, &fs_len, " return filter3point(tex, uv, texSize);"); + append_line(fs_buf, &fs_len, "}"); + } else { + append_line(fs_buf, &fs_len, "vec4 hookTexture2D(in sampler2D tex, in vec2 uv, in vec2 texSize) {"); + append_line(fs_buf, &fs_len, " return texture2D(tex, uv);"); + append_line(fs_buf, &fs_len, "}"); + } + append_line(fs_buf, &fs_len, "void main() {"); for (int i = 0; i < 2; i++) { if (cc_features.used_textures[i]) { bool s = cc_features.clamp[i][0], t = cc_features.clamp[i][1]; + + fs_len += sprintf(fs_buf + fs_len, "vec2 texSize%d = textureSize(uTex%d, 0);\n", i, i); + if (!s && !t) { - fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = texture2D(uTex%d, vTexCoord%d);\n", i, i, i); + fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = hookTexture2D(uTex%d, vTexCoord%d, texSize%d);\n", i, i, i, i); } else { - fs_len += sprintf(fs_buf + fs_len, "vec2 texSize%d = textureSize(uTex%d, 0);\n", i, i); if (s && t) { - fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = texture2D(uTex%d, clamp(vTexCoord%d, 0.5 / texSize%d, vec2(vTexClampS%d, vTexClampT%d)));\n", i, i, i, i, i, i); + fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = hookTexture2D(uTex%d, clamp(vTexCoord%d, 0.5 / texSize%d, vec2(vTexClampS%d, vTexClampT%d)), texSize%d);\n", i, i, i, i, i, i, i); } else if (s) { - fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = texture2D(uTex%d, vec2(clamp(vTexCoord%d.s, 0.5 / texSize%d.s, vTexClampS%d), vTexCoord%d.t));\n", i, i, i, i, i, i); + fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = hookTexture2D(uTex%d, vec2(clamp(vTexCoord%d.s, 0.5 / texSize%d.s, vTexClampS%d), vTexCoord%d.t), texSize%d);\n", i, i, i, i, i, i, i); } else { - fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = texture2D(uTex%d, vec2(vTexCoord%d.s, clamp(vTexCoord%d.t, 0.5 / texSize%d.t, vTexClampT%d)));\n", i, i, i, i, i, i); + fs_len += sprintf(fs_buf + fs_len, "vec4 texVal%d = hookTexture2D(uTex%d, vec2(vTexCoord%d.s, clamp(vTexCoord%d.t, 0.5 / texSize%d.t, vTexClampT%d)), texSize%d);\n", i, i, i, i, i, i, i); } } } @@ -422,9 +446,9 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad GLint max_length = 0; glGetShaderiv(fragment_shader, GL_INFO_LOG_LENGTH, &max_length); char error_log[1024]; - //fprintf(stderr, "Fragment shader compilation failed\n"); + fprintf(stderr, "Fragment shader compilation failed\n"); glGetShaderInfoLog(fragment_shader, max_length, &max_length, &error_log[0]); - //fprintf(stderr, "%s\n", &error_log[0]); + fprintf(stderr, "%s\n", &error_log[0]); abort(); } @@ -549,12 +573,14 @@ static uint32_t gfx_cm_to_opengl(uint32_t val) { case G_TX_NOMIRROR | G_TX_WRAP: return GL_REPEAT; } + return 0; } static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) { + const GLint filter = linear_filter && current_filter_mode == LINEAR ? GL_LINEAR : GL_NEAREST; glActiveTexture(GL_TEXTURE0 + tile); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, linear_filter ? GL_LINEAR : GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear_filter ? GL_LINEAR : GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gfx_cm_to_opengl(cms)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gfx_cm_to_opengl(cmt)); } @@ -823,6 +849,15 @@ static std::map, uint16_t> gfx_opengl_get_pixel_depth(in return res; } +void gfx_opengl_set_texture_filter(FilteringMode mode) { + current_filter_mode = mode; + gfx_texture_cache_clear(); +} + +FilteringMode gfx_opengl_get_texture_filter(void) { + return current_filter_mode; +} + struct GfxRenderingAPI gfx_opengl_api = { gfx_opengl_get_clip_parameters, gfx_opengl_unload_shader, @@ -853,7 +888,9 @@ struct GfxRenderingAPI gfx_opengl_api = { gfx_opengl_get_pixel_depth, gfx_opengl_get_framebuffer_texture_id, gfx_opengl_select_texture_fb, - gfx_opengl_delete_texture + gfx_opengl_delete_texture, + gfx_opengl_set_texture_filter, + gfx_opengl_get_texture_filter }; #endif diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index 1d03befe6..da39c0a4d 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #ifndef _LANGUAGE_C #define _LANGUAGE_C @@ -30,6 +31,8 @@ #include "../StrHash64.h" #include "../../SohImGuiImpl.h" #include "../../Environment.h" +#include "../../GameVersions.h" +#include "../../ResourceMgr.h" // OTRTODO: fix header files for these extern "C" { @@ -45,6 +48,8 @@ extern "C" { using namespace std; +#define SEG_ADDR(seg, addr) (addr | (seg << 24) | 1) + #define SUPPORT_CHECK(x) assert(x) // SCALE_M_N: upscale/downscale M-bit integer to N-bit @@ -209,7 +214,7 @@ static map framebuffers; static set> get_pixel_depth_pending; static map, uint16_t> get_pixel_depth_cached; -#ifdef _MSC_VER +#ifdef _WIN32 // TODO: Properly implement for MSVC static unsigned long get_time(void) { @@ -447,15 +452,15 @@ static void gfx_generate_cc(struct ColorCombiner *comb, uint64_t cc_id) { val = SHADER_COMBINED; break; } - // fallthrough for G_ACMUX_LOD_FRACTION c[i][1][j] = G_CCMUX_LOD_FRACTION; + [[fallthrough]]; // for G_ACMUX_LOD_FRACTION case G_ACMUX_1: //case G_ACMUX_PRIM_LOD_FRAC: same numerical value if (j != 2) { val = SHADER_1; break; } - // fallthrough for G_ACMUX_PRIM_LOD_FRAC + [[fallthrough]]; // for G_ACMUX_PRIM_LOD_FRAC case G_ACMUX_PRIMITIVE: case G_ACMUX_SHADE: case G_ACMUX_ENVIRONMENT: @@ -564,7 +569,7 @@ static void gfx_texture_cache_delete(const uint8_t* orig_addr) if (it->first.texture_addr == orig_addr) { gfx_texture_cache.lru.erase(*(list::iterator*)&it->second.lru_location); gfx_texture_cache.free_texture_ids.push_back(it->second.texture_id); - gfx_texture_cache.map.erase(it); + gfx_texture_cache.map.erase(it->first); again = true; break; } @@ -1692,7 +1697,7 @@ static void gfx_dp_load_block(uint8_t tile, uint32_t uls, uint32_t ult, uint32_t SUPPORT_CHECK(ult == 0); // The lrs field rather seems to be number of pixels to load - uint32_t word_size_shift; + uint32_t word_size_shift = 0; switch (rdp.texture_to_load.siz) { case G_IM_SIZ_4b: word_size_shift = 0; // Or -1? It's unused in SM64 anyway. @@ -1720,7 +1725,7 @@ static void gfx_dp_load_block(uint8_t tile, uint32_t uls, uint32_t ult, uint32_t static void gfx_dp_load_tile(uint8_t tile, uint32_t uls, uint32_t ult, uint32_t lrs, uint32_t lrt) { SUPPORT_CHECK(tile == G_TX_LOADTILE); - uint32_t word_size_shift; + uint32_t word_size_shift = 0; switch (rdp.texture_to_load.siz) { case G_IM_SIZ_4b: word_size_shift = 0; @@ -2060,12 +2065,11 @@ static void gfx_s2dex_bg_copy(const uObjBg* bg) { static inline void* seg_addr(uintptr_t w1) { // Segmented? - if (w1 >= 0xF0000000) + if (w1 & 1) { uint32_t segNum = (w1 >> 24); - segNum -= 0xF0; - uint32_t offset = w1 & 0x00FFFFFF; + uint32_t offset = w1 & 0x00FFFFFE; //offset = 0; // Cursed Malon bug if (segmentPointers[segNum] != 0) @@ -2082,7 +2086,7 @@ static inline void* seg_addr(uintptr_t w1) #define C0(pos, width) ((cmd->words.w0 >> (pos)) & ((1U << width) - 1)) #define C1(pos, width) ((cmd->words.w1 >> (pos)) & ((1U << width) - 1)) -int dListBP; +unsigned int dListBP; int matrixBP; uintptr_t clearMtx; @@ -2149,8 +2153,16 @@ static void gfx_run_dl(Gfx* cmd) { uintptr_t mtxAddr = cmd->words.w1; // OTRTODO: Temp way of dealing with gMtxClear. Need something more elegant in the future... - if (mtxAddr == 0xF012DB20 || mtxAddr == 0xF012DB40) - mtxAddr = clearMtx; + uint32_t gameVersion = Ship::GlobalCtx2::GetInstance()->GetResourceManager()->GetGameVersion(); + if (gameVersion == OOT_PAL_GC) { + if (mtxAddr == SEG_ADDR(0, 0x0FBC20)) { + mtxAddr = clearMtx; + } + } else { + if (mtxAddr == SEG_ADDR(0, 0x12DB20) || mtxAddr == SEG_ADDR(0, 0x12DB40)) { + mtxAddr = clearMtx; + } + } #ifdef F3DEX_GBI_2 gfx_sp_matrix(C0(0, 8) ^ G_MTX_PUSH, (const int32_t *) seg_addr(mtxAddr)); @@ -2250,7 +2262,7 @@ static void gfx_run_dl(Gfx* cmd) { cmd--; - if (ourHash != -1) + if (ourHash != (uint64_t)-1) ResourceMgr_RegisterResourcePatch(ourHash, cmd - dListStart, cmd->words.w1); cmd->words.w1 = (uintptr_t)vtx; @@ -2368,7 +2380,7 @@ static void gfx_run_dl(Gfx* cmd) { case G_QUAD: { int bp = 0; - // fallthrough + [[fallthrough]]; } #endif #if defined(F3DEX_GBI) || defined(F3DLP_GBI) @@ -2398,11 +2410,11 @@ static void gfx_run_dl(Gfx* cmd) { char* imgData = (char*)i; - if ((i & 0xF0000000) != 0xF0000000) + if ((i & 1) != 1) if (ResourceMgr_OTRSigCheck(imgData) == 1) i = (uintptr_t)ResourceMgr_LoadTexByName(imgData); - gfx_dp_set_texture_image(C0(21, 3), C0(19, 2), C0(0, 10), (void*) i, imgData); + gfx_dp_set_texture_image(C0(21, 3), C0(19, 2), C0(0, 10), (void*) i, imgData); break; } case G_SETTIMG_OTR: @@ -2419,7 +2431,7 @@ static void gfx_run_dl(Gfx* cmd) { char* tex = NULL; #endif - if (addr != NULL) + if (addr != 0) { tex = (char*)addr; } @@ -2433,7 +2445,7 @@ static void gfx_run_dl(Gfx* cmd) { uintptr_t oldData = cmd->words.w1; cmd->words.w1 = (uintptr_t)tex; - if (ourHash != -1) + if (ourHash != (uint64_t)-1) ResourceMgr_RegisterResourcePatch(ourHash, cmd - dListStart, oldData); cmd++; @@ -2648,7 +2660,7 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, co game_framebuffer_msaa_resolved = gfx_rapi->create_framebuffer(); for (int i = 0; i < 16; i++) - segmentPointers[i] = NULL; + segmentPointers[i] = 0; // Used in the 120 star TAS static uint32_t precomp_shaders[] = { diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h index d682991d9..d9cd9be8d 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h @@ -4,12 +4,14 @@ #include #include #include +#include struct GfxRenderingAPI; struct GfxWindowManagerAPI; struct XYWidthHeight { - int16_t x, y, width, height; + int16_t x, y; + uint32_t width, height; }; struct GfxDimensions { @@ -25,7 +27,7 @@ struct TextureCacheKey { uint8_t palette_index; bool operator==(const TextureCacheKey&) const noexcept = default; - + struct Hasher { size_t operator()(const TextureCacheKey& key) const noexcept { uintptr_t addr = (uintptr_t)key.texture_addr; diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_rendering_api.h b/libultraship/libultraship/Lib/Fast3D/gfx_rendering_api.h index 84247fe60..6318be492 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_rendering_api.h +++ b/libultraship/libultraship/Lib/Fast3D/gfx_rendering_api.h @@ -15,6 +15,12 @@ struct GfxClipParameters { bool invert_y; }; +enum FilteringMode { + THREE_POINT, + LINEAR, + NONE +}; + struct GfxRenderingAPI { struct GfxClipParameters (*get_clip_parameters)(void); void (*unload_shader)(struct ShaderProgram *old_prg); @@ -46,6 +52,8 @@ struct GfxRenderingAPI { void *(*get_framebuffer_texture_id)(int fb_id); void (*select_texture_fb)(int fb_id); void (*delete_texture)(uint32_t texID); + void (*set_texture_filter)(FilteringMode mode); + FilteringMode(*get_texture_filter)(void); }; #endif diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp index ffc46f369..e80097c81 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp @@ -1,6 +1,6 @@ #include -#if !defined(__linux__) && defined(ENABLE_OPENGL) +#if defined(ENABLE_OPENGL) #ifdef __MINGW32__ #define FOR_WINDOWS 1 @@ -23,7 +23,9 @@ #include "gfx_window_manager_api.h" #include "gfx_screen_config.h" +#ifdef _WIN32 #include +#endif #include #define GFX_API_NAME "SDL2 - OpenGL" @@ -41,7 +43,7 @@ static bool (*on_key_up_callback)(int scancode); static void (*on_all_keys_up_callback)(void); const SDL_Scancode windows_scancode_table[] = -{ +{ /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, /* 0 */ @@ -117,7 +119,9 @@ static void set_fullscreen(bool on, bool call_callback) { } static uint64_t previous_time; +#ifndef __linux__ static HANDLE timer; +#endif static int frameDivisor = 1; @@ -131,7 +135,9 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); +#ifndef __linux timer = CreateWaitableTimer(nullptr, false, nullptr); +#endif //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); @@ -188,7 +194,7 @@ static void gfx_sdl_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bo } static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) { - while (1) + while (1) { run_one_game_iter(); } diff --git a/libultraship/libultraship/Lib/StrHash64.h b/libultraship/libultraship/Lib/StrHash64.h index 35401bbf8..d8cc8ff62 100644 --- a/libultraship/libultraship/Lib/StrHash64.h +++ b/libultraship/libultraship/Lib/StrHash64.h @@ -86,14 +86,8 @@ #include -#define u8 uint8_t -#define u16 uint16_t -#define u32 uint32_t -#define u64 uint64_t -#define unint uint32_t - #define INITIAL_CRC64 0xffffffffffffffffULL -extern uint64_t update_crc64(const void* buf, unint len, u64 crc); -extern u64 crc64(const void* buf, unint len); -extern u64 CRC64(const char* t); \ No newline at end of file +extern uint64_t update_crc64(const void* buf, uint32_t len, uint64_t crc); +extern uint64_t crc64(const void* buf, uint32_t len); +extern uint64_t CRC64(const char* t); \ No newline at end of file diff --git a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h index 08729f4dc..4fa03b5e0 100644 --- a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h +++ b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h @@ -10,6 +10,7 @@ #include #include "SohImGuiImpl.h" #include "GameSettings.h" +#include "Cvar.h" #include #include #include @@ -45,8 +46,8 @@ protected: } formatted.push_back('\0'); const char *msg_output = formatted.data(); - if (Game::Settings.debug.soh_sink && SohImGui::console->opened) - SohImGui::console->Append("SoH Logging", priority, msg_output); + if (CVar_GetS32("gSinkEnabled", 0) && SohImGui::console->opened) + SohImGui::console->Append("SoH Logging", priority, "%s", msg_output); } void flush_() override {} @@ -66,6 +67,8 @@ private: return Priority::ERROR_LVL; case spdlog::level::critical: return Priority::ERROR_LVL; + default: + break; } return Priority::LOG_LVL; } diff --git a/libultraship/libultraship/Model.cpp b/libultraship/libultraship/Model.cpp index 27220e3bc..9e37de177 100644 --- a/libultraship/libultraship/Model.cpp +++ b/libultraship/libultraship/Model.cpp @@ -39,7 +39,7 @@ namespace Ship Vertex* vtxData = new Vertex[numVerts]; uint32_t* indicesData = new uint32_t[numPolys]; - if (vertices != NULL) + if (vertices != 0) { reader->Seek(headerStart + vertices, SeekOffsetType::Start); @@ -47,7 +47,7 @@ namespace Ship vtxData[i].pos = reader->ReadVec3f(); } - if (normals != NULL) + if (normals != 0) { reader->Seek(headerStart + normals, SeekOffsetType::Start); @@ -55,7 +55,7 @@ namespace Ship vtxData[i].normal = reader->ReadVec3f(); } - if (vertexColors != NULL) + if (vertexColors != 0) { reader->Seek(headerStart + vertexColors, SeekOffsetType::Start); @@ -63,7 +63,7 @@ namespace Ship vtxData[i].color = reader->ReadColor3b(); } - if (uvCoords != NULL) + if (uvCoords != 0) { reader->Seek(headerStart + uvCoords, SeekOffsetType::Start); @@ -71,7 +71,7 @@ namespace Ship vtxData[i].uv = reader->ReadVec2f(); } - if (boneWeights != NULL) + if (boneWeights != 0) { reader->Seek(headerStart + boneWeights, SeekOffsetType::Start); @@ -81,7 +81,7 @@ namespace Ship mdl->boneWeights[i] = reader->ReadVec2f(); } - if (faces != NULL) + if (faces != 0) { reader->Seek(headerStart + faces, SeekOffsetType::Start); reader->Read((char*)indicesData, numPolys * sizeof(uint32_t)); diff --git a/libultraship/libultraship/PulseAudioPlayer.cpp b/libultraship/libultraship/PulseAudioPlayer.cpp new file mode 100644 index 000000000..955b225d1 --- /dev/null +++ b/libultraship/libultraship/PulseAudioPlayer.cpp @@ -0,0 +1,173 @@ +#if defined(__linux__) || defined(__BSD__) + +#include "PulseAudioPlayer.h" +#include + +namespace Ship +{ + static void pas_context_state_cb(pa_context *c, void *userdata) { + switch (pa_context_get_state(c)) { + case PA_CONTEXT_READY: + case PA_CONTEXT_TERMINATED: + case PA_CONTEXT_FAILED: + *(bool*)userdata = true; + break; + default: + break; + } + } + + static void pas_stream_state_cb(pa_stream *s, void *userdata) { + switch (pa_stream_get_state(s)) { + case PA_STREAM_READY: + case PA_STREAM_FAILED: + case PA_STREAM_TERMINATED: + *(bool*)userdata = true; + break; + default: + break; + } + } + + static void pas_stream_write_cb(pa_stream* s, size_t length, void* userdata) { + } + + static void pas_update_complete(pa_stream* stream, int success, void* userdata) { + *(bool*)userdata = true; + } + + static void pas_write_complete(void* userdata) { + *(bool*)userdata = true; + } + + bool PulseAudioPlayer::Init() + { + bool done = false; + const pa_buffer_attr* applied_attr = nullptr; + + // Create mainloop + m_MainLoop = pa_mainloop_new(); + if (m_MainLoop == NULL) { + return false; + } + + // Create context and connect + m_Context = pa_context_new(pa_mainloop_get_api(m_MainLoop), "Ocarina of Time"); + if (m_Context == NULL) { + goto fail; + } + + pa_context_set_state_callback(m_Context, pas_context_state_cb, &done); + + if (pa_context_connect(m_Context, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) { + goto fail; + } + + while (!done) { + pa_mainloop_iterate(m_MainLoop, true, NULL); + } + pa_context_set_state_callback(m_Context, NULL, NULL); + if (pa_context_get_state(m_Context) != PA_CONTEXT_READY) { + goto fail; + } + + // Create stream + pa_sample_spec ss; + ss.format = PA_SAMPLE_S16LE; + ss.rate = 32000; + ss.channels = 2; + + pa_buffer_attr attr; + attr.maxlength = (1600 + 544 + 528 + 1600) * 4; + attr.tlength = (528*2 + 544) * 4; + attr.prebuf = 1500 * 4; + attr.minreq = 161 * 4; + attr.fragsize = (uint32_t)-1; + + m_Stream = pa_stream_new(m_Context, "zelda", &ss, NULL); + if (m_Stream == NULL) { + goto fail; + } + + done = false; + pa_stream_set_state_callback(m_Stream, pas_stream_state_cb, &done); + pa_stream_set_write_callback(m_Stream, pas_stream_write_cb, NULL); + if (pa_stream_connect_playback(m_Stream, NULL, &attr, PA_STREAM_ADJUST_LATENCY, NULL, NULL) < 0) { + goto fail; + } + + while (!done) { + pa_mainloop_iterate(m_MainLoop, true, NULL); + } + pa_stream_set_state_callback(m_Stream, NULL, NULL); + if (pa_stream_get_state(m_Stream) != PA_STREAM_READY) { + goto fail; + } + + applied_attr = pa_stream_get_buffer_attr(m_Stream); + SPDLOG_TRACE("maxlength: {}\ntlength: {}\nprebuf: {}\nminreq: {}\nfragsize: {}\n", + applied_attr->maxlength, applied_attr->tlength, applied_attr->prebuf, applied_attr->minreq, applied_attr->fragsize); + m_Attr = *applied_attr; + + return true; + + fail: + if (m_Stream != NULL) { + pa_stream_unref(m_Stream); + m_Stream = NULL; + } + if (m_Context != NULL) { + pa_context_disconnect(m_Context); + pa_context_unref(m_Context); + m_Context = NULL; + } + if (m_MainLoop != NULL) { + pa_mainloop_free(m_MainLoop); + m_MainLoop = NULL; + } + return false; + } + + int PulseAudioPlayer::Buffered() + { + if (m_Stream == NULL) { + return 0; + } + + bool done = false; + pa_stream_update_timing_info(m_Stream, pas_update_complete, &done); + while (!done) { + pa_mainloop_iterate(m_MainLoop, true, NULL); + } + + const pa_timing_info *info = pa_stream_get_timing_info(m_Stream); + if (info == NULL) { + SPDLOG_ERROR("pa_stream_get_timing_info failed, state is %d\n", pa_stream_get_state(m_Stream)); + } + return (info->write_index - info->read_index) / 4; + } + + int PulseAudioPlayer::GetDesiredBuffered() + { + // return 1100; + return 1680; + } + + void PulseAudioPlayer::Play(const uint8_t* buff, uint32_t len) + { + size_t ws = m_Attr.maxlength - Buffered() * 4; + if (ws < len) { + len = ws; + } + if (pa_stream_write_ext_free(m_Stream, buff, len, pas_write_complete, &m_WriteComplete, 0LL, PA_SEEK_RELATIVE) < 0) { + SPDLOG_ERROR("pa_stream_write failed"); + return; + } + while (!m_WriteComplete) { + pa_mainloop_iterate(m_MainLoop, true, NULL); + } + m_WriteComplete = false; + } +} + +#endif \ No newline at end of file diff --git a/libultraship/libultraship/PulseAudioPlayer.h b/libultraship/libultraship/PulseAudioPlayer.h new file mode 100644 index 000000000..7bc72b097 --- /dev/null +++ b/libultraship/libultraship/PulseAudioPlayer.h @@ -0,0 +1,26 @@ +#pragma once + +#if defined(__linux__) || defined(__BSD__) + +#include "AudioPlayer.h" +#include + +namespace Ship { + class PulseAudioPlayer : public AudioPlayer { + public: + PulseAudioPlayer() {} + + bool Init() override; + int Buffered() override; + int GetDesiredBuffered() override; + void Play(const uint8_t* buff, uint32_t len) override; + + private: + pa_context* m_Context = nullptr; + pa_stream* m_Stream = nullptr; + pa_mainloop* m_MainLoop = nullptr; + bool m_WriteComplete = false; + pa_buffer_attr m_Attr = {0}; + }; +} +#endif diff --git a/libultraship/libultraship/Resource.cpp b/libultraship/libultraship/Resource.cpp index 5bdfc5efd..04fc2bfbb 100644 --- a/libultraship/libultraship/Resource.cpp +++ b/libultraship/libultraship/Resource.cpp @@ -2,8 +2,8 @@ #include "DisplayList.h" #include "ResourceMgr.h" #include "Utils/BinaryReader.h" -#include "lib/tinyxml2/tinyxml2.h" -#include "lib/Fast3D/U64/PR/ultra64/gbi.h" +#include "Lib/tinyxml2/tinyxml2.h" +#include "Lib/Fast3D/U64/PR/ultra64/gbi.h" namespace Ship { @@ -25,7 +25,7 @@ namespace Ship void ResourceFile::WriteFileBinary(BinaryWriter* writer, Resource* res) { - + } void ResourceFile::WriteFileXML(tinyxml2::XMLElement* writer, Resource* res) @@ -35,17 +35,17 @@ namespace Ship Resource::~Resource() { - free(cachedGameAsset); + free(cachedGameAsset); cachedGameAsset = nullptr; - for (int i = 0; i < patches.size(); i++) + for (size_t i = 0; i < patches.size(); i++) { std::string hashStr = resMgr->HashToString(patches[i].crc); auto resShared = resMgr->GetCachedFile(hashStr); if (resShared != nullptr) { auto res = (Ship::DisplayList*)resShared.get(); - + Gfx* gfx = (Gfx*)&res->instructions[patches[i].index]; gfx->words.w1 = patches[i].origData; } diff --git a/libultraship/libultraship/Resource.h b/libultraship/libultraship/Resource.h index 1df5c5ed7..ae8dc6ce5 100644 --- a/libultraship/libultraship/Resource.h +++ b/libultraship/libultraship/Resource.h @@ -6,7 +6,7 @@ #include "GlobalCtx2.h" #include "StrHash.h" #include "File.h" -#include "lib/tinyxml2/tinyxml2.h" +#include "Lib/tinyxml2/tinyxml2.h" namespace Ship { @@ -101,10 +101,10 @@ namespace Ship class ResourcePromise { public: - std::shared_ptr Resource; - std::shared_ptr File; - std::condition_variable ResourceLoadNotifier; - std::mutex ResourceLoadMutex; + std::shared_ptr resource; + std::shared_ptr file; + std::condition_variable resourceLoadNotifier; + std::mutex resourceLoadMutex; bool bHasResourceLoaded = false; }; } \ No newline at end of file diff --git a/libultraship/libultraship/ResourceMgr.cpp b/libultraship/libultraship/ResourceMgr.cpp index b4d7b76a8..de0296d12 100644 --- a/libultraship/libultraship/ResourceMgr.cpp +++ b/libultraship/libultraship/ResourceMgr.cpp @@ -43,7 +43,7 @@ namespace Ship { const std::lock_guard ResLock(ResourceLoadMutex); bIsRunning = false; } - + FileLoadNotifier.notify_all(); ResourceLoadNotifier.notify_all(); FileLoadThread->join(); @@ -89,7 +89,7 @@ namespace Ship { OTR->LoadFile(ToLoad->path, true, ToLoad); //Lock.lock(); - + if (!ToLoad->bHasLoadError) FileCache[ToLoad->path] = ToLoad->bIsLoaded && !ToLoad->bHasLoadError ? ToLoad : nullptr; @@ -124,15 +124,15 @@ namespace Ship { // Wait for the underlying File to complete loading { - std::unique_lock FileLock(ToLoad->File->FileLoadMutex); - while (!ToLoad->File->bIsLoaded && !ToLoad->File->bHasLoadError) { - ToLoad->File->FileLoadNotifier.wait(FileLock); + std::unique_lock FileLock(ToLoad->file->FileLoadMutex); + while (!ToLoad->file->bIsLoaded && !ToLoad->file->bHasLoadError) { + ToLoad->file->FileLoadNotifier.wait(FileLock); } } - if (!ToLoad->File->bHasLoadError) + if (!ToLoad->file->bHasLoadError) { - auto UnmanagedRes = ResourceLoader::LoadResource(ToLoad->File); + auto UnmanagedRes = ResourceLoader::LoadResource(ToLoad->file); if (UnmanagedRes != nullptr) { @@ -140,13 +140,13 @@ namespace Ship { auto Res = std::shared_ptr(UnmanagedRes); if (Res != nullptr) { - std::unique_lock Lock(ToLoad->ResourceLoadMutex); + std::unique_lock Lock(ToLoad->resourceLoadMutex); ToLoad->bHasResourceLoaded = true; - ToLoad->Resource = Res; + ToLoad->resource = Res; ResourceCache[Res->file->path] = Res; - SPDLOG_DEBUG("Loaded Resource {} on ResourceMgr thread", ToLoad->File->path); + SPDLOG_DEBUG("Loaded Resource {} on ResourceMgr thread", ToLoad->file->path); // Disabled for now because it can cause random crashes //FileCache[Res->File->path] = nullptr; @@ -155,9 +155,9 @@ namespace Ship { } else { ToLoad->bHasResourceLoaded = false; - ToLoad->Resource = nullptr; + ToLoad->resource = nullptr; - SPDLOG_ERROR("Resource load FAILED {} on ResourceMgr thread", ToLoad->File->path); + SPDLOG_ERROR("Resource load FAILED {} on ResourceMgr thread", ToLoad->file->path); } //ResLock.lock(); @@ -167,10 +167,10 @@ namespace Ship { else { ToLoad->bHasResourceLoaded = false; - ToLoad->Resource = nullptr; + ToLoad->resource = nullptr; } - ToLoad->ResourceLoadNotifier.notify_all(); + ToLoad->resourceLoadNotifier.notify_all(); } SPDLOG_INFO("Resource Manager LoadResourceThread ended"); @@ -232,17 +232,17 @@ namespace Ship { if (!Promise->bHasResourceLoaded) { - std::unique_lock Lock(Promise->ResourceLoadMutex); + std::unique_lock Lock(Promise->resourceLoadMutex); while (!Promise->bHasResourceLoaded) { - Promise->ResourceLoadNotifier.wait(Lock); + Promise->resourceLoadNotifier.wait(Lock); } } - return Promise->Resource; + return Promise->resource; } std::shared_ptr ResourceMgr::LoadResourceAsync(std::string FilePath) { - StringHelper::ReplaceOriginal(FilePath, "/", "\\"); + StringHelper::ReplaceOriginal(FilePath, "\\", "/"); if (StringHelper::StartsWith(FilePath, "__OTR__")) FilePath = StringHelper::Split(FilePath, "__OTR__")[1]; @@ -257,9 +257,9 @@ namespace Ship { } std::shared_ptr FileData = LoadFile(FilePath); - Promise->File = FileData; + Promise->file = FileData; - if (Promise->File->bHasLoadError) + if (Promise->file->bHasLoadError) { Promise->bHasResourceLoaded = true; } @@ -271,7 +271,7 @@ namespace Ship { } } else { Promise->bHasResourceLoaded = true; - Promise->Resource = resCacheFind->second; + Promise->resource = resCacheFind->second; } return Promise; @@ -295,37 +295,37 @@ namespace Ship { auto PromiseList = CacheDirectoryAsync(SearchMask); auto LoadedList = std::make_shared>>(); - for (int32_t i = 0; i < PromiseList->size(); i++) { + for (size_t i = 0; i < PromiseList->size(); i++) { auto Promise = PromiseList->at(i); - std::unique_lock Lock(Promise->ResourceLoadMutex); + std::unique_lock Lock(Promise->resourceLoadMutex); while (!Promise->bHasResourceLoaded) { - Promise->ResourceLoadNotifier.wait(Lock); + Promise->resourceLoadNotifier.wait(Lock); } - LoadedList->push_back(Promise->Resource); + LoadedList->push_back(Promise->resource); } return LoadedList; } - std::shared_ptr>> ResourceMgr::DirtyDirectory(std::string SearchMask) + std::shared_ptr>> ResourceMgr::DirtyDirectory(std::string SearchMask) { auto PromiseList = CacheDirectoryAsync(SearchMask); auto LoadedList = std::make_shared>>(); - for (int32_t i = 0; i < PromiseList->size(); i++) { + for (size_t i = 0; i < PromiseList->size(); i++) { auto Promise = PromiseList->at(i); - std::unique_lock Lock(Promise->ResourceLoadMutex); + std::unique_lock Lock(Promise->resourceLoadMutex); while (!Promise->bHasResourceLoaded) { - Promise->ResourceLoadNotifier.wait(Lock); + Promise->resourceLoadNotifier.wait(Lock); } - if (Promise->Resource != nullptr) - Promise->Resource->isDirty = true; + if (Promise->resource != nullptr) + Promise->resource->isDirty = true; - LoadedList->push_back(Promise->Resource); + LoadedList->push_back(Promise->resource); } return LoadedList; diff --git a/libultraship/libultraship/ResourceMgr.h b/libultraship/libultraship/ResourceMgr.h index 5eae61abe..28e77e537 100644 --- a/libultraship/libultraship/ResourceMgr.h +++ b/libultraship/libultraship/ResourceMgr.h @@ -28,7 +28,7 @@ namespace Ship std::string HashToString(uint64_t Hash); void InvalidateResourceCache(); - + uint32_t GetGameVersion(); void SetGameVersion(uint32_t newGameVersion); std::shared_ptr LoadFileAsync(std::string FilePath); @@ -48,6 +48,7 @@ namespace Ship private: std::weak_ptr Context; + volatile bool bIsRunning; std::map> FileCache; std::map> ResourceCache; std::queue> FileLoadQueue; @@ -59,7 +60,6 @@ namespace Ship std::mutex ResourceLoadMutex; std::condition_variable FileLoadNotifier; std::condition_variable ResourceLoadNotifier; - volatile bool bIsRunning; uint32_t gameVersion; }; } \ No newline at end of file diff --git a/libultraship/libultraship/SDLController.cpp b/libultraship/libultraship/SDLController.cpp index 4533df20b..ab2c48b30 100644 --- a/libultraship/libultraship/SDLController.cpp +++ b/libultraship/libultraship/SDLController.cpp @@ -61,17 +61,17 @@ namespace Ship { if (Conf[ConfSection]["GUID"].compare("") == 0 || Conf[ConfSection]["GUID"].compare(INVALID_SDL_CONTROLLER_GUID) == 0 || Conf[ConfSection]["GUID"].compare(NewGuid) == 0) { auto NewCont = SDL_GameControllerOpen(i); - if (SDL_GameControllerHasSensor(NewCont, SDL_SENSOR_GYRO)) - { - SDL_GameControllerSetSensorEnabled(NewCont, SDL_SENSOR_GYRO, SDL_TRUE); - } - // We failed to load the controller. Go to next. if (NewCont == nullptr) { SPDLOG_ERROR("SDL Controller failed to open: ({})", SDL_GetError()); continue; } + if (SDL_GameControllerHasSensor(NewCont, SDL_SENSOR_GYRO)) + { + SDL_GameControllerSetSensorEnabled(NewCont, SDL_SENSOR_GYRO, SDL_TRUE); + } + guid = NewGuid; Cont = NewCont; @@ -101,7 +101,7 @@ namespace Ship { } bool SDLController::Close() { - if (SDL_GameControllerHasRumble(Cont)) { + if (CanRumble()) { SDL_GameControllerRumble(Cont, 0, 0, 0); } if (Cont != nullptr) { @@ -190,7 +190,7 @@ namespace Ship { if (SDL_GameControllerHasSensor(Cont, SDL_SENSOR_GYRO)) { size_t contNumber = GetControllerNumber(); - + float gyroData[3]; SDL_GameControllerGetSensorData(Cont, SDL_SENSOR_GYRO, gyroData, 3); @@ -198,7 +198,7 @@ namespace Ship { const int isSpecialController = !strcmp("PS5 Controller", contName); float gyro_drift_x = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX", contNumber).c_str(), 0.0f); float gyro_drift_y = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY", contNumber).c_str(), 0.0f); - const float gyro_sensitivity = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroSensitivity").c_str(), 1.0f); + const float gyro_sensitivity = CVar_GetFloat(StringHelper::Sprintf("gCont%i_GyroSensitivity", contNumber).c_str(), 1.0f); if (gyro_drift_x == 0) { gyro_drift_x = gyroData[0]; @@ -347,7 +347,7 @@ namespace Ship { void SDLController::WriteToSource(ControllerCallback* controller) { - if (SDL_GameControllerHasRumble(Cont)) { + if (CanRumble()) { if (controller->rumble > 0) { float rumble_strength = CVar_GetFloat(StringHelper::Sprintf("gCont%i_RumbleStrength", GetControllerNumber()).c_str(), 1.0f); SDL_GameControllerRumble(Cont, 0xFFFF * rumble_strength, 0xFFFF * rumble_strength, 0); diff --git a/libultraship/libultraship/SDLController.h b/libultraship/libultraship/SDLController.h index 138466a89..fbffa478f 100644 --- a/libultraship/libultraship/SDLController.h +++ b/libultraship/libultraship/SDLController.h @@ -13,7 +13,12 @@ namespace Ship { void ReadFromSource(); void WriteToSource(ControllerCallback* controller); bool Connected() const { return Cont != nullptr; } - bool CanRumble() const { return SDL_GameControllerHasRumble(Cont); } + bool CanRumble() const { +#if SDL_COMPILEDVERSION >= SDL_VERSIONNUM(2,0,18) + return SDL_GameControllerHasRumble(Cont); +#endif + return true; + } std::string GetGuid() { return guid; }; @@ -30,8 +35,8 @@ namespace Ship { static bool IsGuidInUse(const std::string& guid); private: - std::string guid; SDL_GameController* Cont; + std::string guid; std::map ThresholdMapping; void LoadAxisThresholds(); diff --git a/libultraship/libultraship/Scene.cpp b/libultraship/libultraship/Scene.cpp index 9468e3a59..17d2b6976 100644 --- a/libultraship/libultraship/Scene.cpp +++ b/libultraship/libultraship/Scene.cpp @@ -137,8 +137,8 @@ namespace Ship y = 0; z = 0; unk_06 = 0; - opa; - xlu; + // opa; + // xlu; } SetMesh::SetMesh(BinaryReader* reader) : SceneCommand(reader) @@ -398,18 +398,18 @@ namespace Ship LightInfo light = LightInfo(); light.type = reader->ReadUByte(); - + light.x = reader->ReadInt16(); - light.y = reader->ReadInt16(); + light.y = reader->ReadInt16(); light.z = reader->ReadInt16(); light.r = reader->ReadUByte(); light.g = reader->ReadUByte(); light.b = reader->ReadUByte(); - + light.drawGlow = reader->ReadUByte(); light.radius = reader->ReadInt16(); - + lights.push_back(light); } } diff --git a/libultraship/libultraship/SkeletonLimb.cpp b/libultraship/libultraship/SkeletonLimb.cpp index 5020fe8f5..75fd46780 100644 --- a/libultraship/libultraship/SkeletonLimb.cpp +++ b/libultraship/libultraship/SkeletonLimb.cpp @@ -15,7 +15,7 @@ namespace Ship limb->skinVtxCnt = reader->ReadUInt16(); uint32_t skinCnt = reader->ReadUInt32(); - for (int i = 0; i < skinCnt; i++) + for (size_t i = 0; i < skinCnt; i++) { Struct_800A598C struc; diff --git a/libultraship/libultraship/SohConsole.cpp b/libultraship/libultraship/SohConsole.cpp index 618cd1e1d..6f04bc917 100644 --- a/libultraship/libultraship/SohConsole.cpp +++ b/libultraship/libultraship/SohConsole.cpp @@ -16,7 +16,7 @@ std::map BindingToggle; static bool HelpCommand(const std::vector&) { INFO("SoH Commands:"); for(const auto& cmd : SohImGui::console->Commands) { - INFO((" - " + cmd.first).c_str()); + INFO("%s", (" - " + cmd.first).c_str()); } return CMD_SUCCESS; } @@ -35,7 +35,7 @@ std::string toLowerCase(std::string in) { static bool BindCommand(const std::vector& args) { if(args.size() > 2) { const ImGuiIO* io = &ImGui::GetIO();; - for (int k = 0; k < std::size(io->KeysData); k++) { + for (size_t k = 0; k < std::size(io->KeysData); k++) { std::string key(ImGui::GetKeyName(k)); if(toLowerCase(args[1]) == toLowerCase(key)) { @@ -55,7 +55,7 @@ static bool BindCommand(const std::vector& args) { static bool BindToggleCommand(const std::vector& args) { if (args.size() > 2) { const ImGuiIO* io = &ImGui::GetIO();; - for (int k = 0; k < std::size(io->KeysData); k++) { + for (size_t k = 0; k < std::size(io->KeysData); k++) { std::string key(ImGui::GetKeyName(k)); if (toLowerCase(args[1]) == toLowerCase(key)) { @@ -92,7 +92,7 @@ void Console::Update() { } for (auto [key, var] : BindingToggle) { if (ImGui::IsKeyPressed(key)) { - CVar* cvar = CVar_GetVar(var.c_str()); + CVar* cvar = CVar_Get(var.c_str()); Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast(cvar->value.valueS32))); } } @@ -106,7 +106,7 @@ void Console::Draw() { if (!this->opened) return; ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - ImGui::Begin("Console", &this->opened); + ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); const ImVec2 pos = ImGui::GetWindowPos(); const ImVec2 size = ImGui::GetWindowSize(); @@ -177,8 +177,10 @@ void Console::Draw() { for (const auto& filter : priority_filters) { const bool is_selected = (filter == std::string(this->level_filter)); if (ImGui::Selectable(filter.c_str(), is_selected)) + { this->level_filter = filter; if (is_selected) ImGui::SetItemDefaultFocus(); + } } ImGui::EndCombo(); } @@ -194,7 +196,7 @@ void Console::Draw() { if (ImGui::BeginTable("History", 1)) { if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) - if (this->selectedId < this->Log.size() - 1) ++this->selectedId; + if (this->selectedId < (int)this->Log.size() - 1) ++this->selectedId; if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) if (this->selectedId > 0) --this->selectedId; @@ -226,7 +228,7 @@ void Console::Draw() { ImGui::EndChild(); // Renders input textfield - constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit | + constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; ImGui::PushItemWidth(-1); if(ImGui::InputTextWithHint("CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) { @@ -317,7 +319,7 @@ int Console::CallbackStub(ImGuiInputTextCallbackData* data) { return 0; } -void Console::Append(const std::string& channel, Priority priority, const char* fmt, ...) IM_FMTARGS(4) { +void Console::Append(const std::string& channel, Priority priority, const char* fmt, ...) { char buf[1024]; va_list args; va_start(args, fmt); diff --git a/libultraship/libultraship/SohConsole.h b/libultraship/libultraship/SohConsole.h index 57ad182f8..bfbffd0b9 100644 --- a/libultraship/libultraship/SohConsole.h +++ b/libultraship/libultraship/SohConsole.h @@ -7,10 +7,10 @@ #include "Lib/ImGui/imgui.h" -#define LOG(msg, ...) SohImGui::console->Append("Main", Priority::LOG_LVL, msg, __VA_ARGS__) -#define INFO(msg, ...) SohImGui::console->Append("Main", Priority::INFO_LVL, msg, __VA_ARGS__) -#define WARNING(msg, ...) SohImGui::console->Append("Main", Priority::WARNING_LVL, msg, __VA_ARGS__) -#define ERROR(msg, ...) SohImGui::console->Append("Main", Priority::ERROR_LVL, msg, __VA_ARGS__) +#define LOG(msg, ...) SohImGui::console->Append("Main", Priority::LOG_LVL, msg, ##__VA_ARGS__) +#define INFO(msg, ...) SohImGui::console->Append("Main", Priority::INFO_LVL, msg, ##__VA_ARGS__) +#define WARNING(msg, ...) SohImGui::console->Append("Main", Priority::WARNING_LVL, msg, ##__VA_ARGS__) +#define ERROR(msg, ...) SohImGui::console->Append("Main", Priority::ERROR_LVL, msg, ##__VA_ARGS__) #define CMD_SUCCESS true #define CMD_FAILED false #define MAX_BUFFER_SIZE 255 @@ -75,7 +75,7 @@ public: void Init(); void Update(); void Draw(); - void Append(const std::string& channel, Priority priority, const char* fmt, ...); + void Append(const std::string& channel, Priority priority, const char* fmt, ...) IM_FMTARGS(4); void Dispatch(const std::string& line); static int CallbackStub(ImGuiInputTextCallbackData* data); }; \ No newline at end of file diff --git a/libultraship/libultraship/SohHooks.cpp b/libultraship/libultraship/SohHooks.cpp index d40ab87e2..7ede525d7 100644 --- a/libultraship/libultraship/SohHooks.cpp +++ b/libultraship/libultraship/SohHooks.cpp @@ -24,7 +24,7 @@ namespace ModInternal { bool handleHook(std::shared_ptr call) { std::string hookName = std::string(call->name); - for (int l = 0; l < listeners[hookName].size(); l++) { + for (size_t l = 0; l < listeners[hookName].size(); l++) { (listeners[hookName][l])(call); } return call->cancelled; diff --git a/libultraship/libultraship/SohHooks.h b/libultraship/libultraship/SohHooks.h index 111f789d0..9a41eeb0e 100644 --- a/libultraship/libultraship/SohHooks.h +++ b/libultraship/libultraship/SohHooks.h @@ -47,6 +47,7 @@ struct HookParameter { #include #include #include +#include struct HookCall { std::string name; diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index fb4841ee9..72d9cee1a 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -18,6 +18,7 @@ #include "TextureMod.h" #include "Window.h" #include "Cvar.h" +#include "GameOverlay.h" #include "Texture.h" #include "../Fast3D/gfx_pc.h" #include "Lib/stb/stb_image.h" @@ -43,6 +44,11 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPAR using namespace Ship; bool oldCursorState = true; +#define EXPERIMENTAL() \ + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 50, 50, 255)); \ + ImGui::Text("Experimental"); \ + ImGui::PopStyleColor(); \ + ImGui::Separator(); #define TOGGLE_BTN ImGuiKey_F1 #define HOOK(b) if(b) needs_save = true; OSContPad* pads; @@ -54,8 +60,11 @@ namespace SohImGui { WindowImpl impl; ImGuiIO* io; Console* console = new Console; + GameOverlay* overlay = new GameOverlay; bool p_open = false; bool needs_save = false; + std::vector CustomTexts; + int SelectedLanguage = CVar_GetS32("gLanguages", 0); //Default Language to 0=English 1=German 2=French float kokiri_col[3] = { 0.118f, 0.41f, 0.106f }; float goron_col[3] = { 0.392f, 0.078f, 0.0f }; float zora_col[3] = { 0.0f, 0.235f, 0.392f }; @@ -72,6 +81,12 @@ namespace SohImGui { float navi_prop_i_col[3] = { 0.0f, 0.0f, 0.0f }; float navi_prop_o_col[3] = { 0.0f, 0.0f, 0.0f }; + const char* filters[3] = { + "Three-Point", + "Linear", + "None" + }; + std::map> windowCategories; std::map customWindows; @@ -80,11 +95,15 @@ namespace SohImGui { case Backend::SDL: ImGui_ImplSDL2_InitForOpenGL(static_cast(impl.sdl.window), impl.sdl.context); break; +#if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: ImGui_ImplWin32_Init(impl.dx11.window); break; +#endif + default: + break; } - + // OTRTODO: This gameplay specific stuff should not be in libultraship. This needs to be moved to soh and use sTunicColors kokiri_col[0] = 30 / 255.0f; kokiri_col[1] = 105 / 255.0f; @@ -93,7 +112,7 @@ namespace SohImGui { goron_col[0] = 100 / 255.0f; goron_col[1] = 20 / 255.0f; goron_col[2] = 0; - + zora_col[0] = 0; zora_col[1] = 60 / 255.0f; zora_col[2] = 100 / 255.0f; @@ -136,9 +155,14 @@ namespace SohImGui { case Backend::SDL: ImGui_ImplOpenGL3_Init("#version 120"); break; + +#if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: ImGui_ImplDX11_Init(static_cast(impl.dx11.device), static_cast(impl.dx11.device_context)); break; +#endif + default: + break; } } @@ -147,9 +171,13 @@ namespace SohImGui { case Backend::SDL: ImGui_ImplSDL2_ProcessEvent(static_cast(event.sdl.event)); break; +#if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: ImGui_ImplWin32_WndProcHandler(static_cast(event.win32.handle), event.win32.msg, event.win32.wparam, event.win32.lparam); break; +#endif + default: + break; } } @@ -158,9 +186,13 @@ namespace SohImGui { case Backend::SDL: ImGui_ImplSDL2_NewFrame(static_cast(impl.sdl.window)); break; +#if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: ImGui_ImplWin32_NewFrame(); break; +#endif + default: + break; } } @@ -169,9 +201,13 @@ namespace SohImGui { case Backend::SDL: ImGui_ImplOpenGL3_NewFrame(); break; +#if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: ImGui_ImplDX11_NewFrame(); break; +#endif + default: + break; } } @@ -180,9 +216,13 @@ namespace SohImGui { case Backend::SDL: ImGui_ImplOpenGL3_RenderDrawData(data); break; +#if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: ImGui_ImplDX11_RenderDrawData(data); break; +#endif + default: + break; } } @@ -190,17 +230,18 @@ namespace SohImGui { switch (impl.backend) { case Backend::DX11: return true; + default: + return false; } - return false; } - void SohImGui::ShowCursor(bool hide, Dialogues d) { + void ShowCursor(bool hide, Dialogues d) { if (d == Dialogues::dLoadSettings) { GlobalCtx2::GetInstance()->GetWindow()->ShowCursor(hide); return; } - if (d == Dialogues::dConsole && Game::Settings.debug.menu_bar) { + if (d == Dialogues::dConsole && CVar_GetS32("gOpenMenuBar", 0)) { return; } if (!GlobalCtx2::GetInstance()->GetWindow()->IsFullscreen()) { @@ -216,7 +257,7 @@ namespace SohImGui { void LoadTexture(const std::string& name, const std::string& path) { GfxRenderingAPI* api = gfx_get_current_rendering_api(); - const auto res = GlobalCtx2::GetInstance()->GetResourceManager()->LoadFile(normalize(path)); + const auto res = GlobalCtx2::GetInstance()->GetResourceManager()->LoadFile(path); const auto asset = new GameAsset{ api->new_texture() }; uint8_t* img_data = stbi_load_from_memory(reinterpret_cast(res->buffer.get()), res->dwBufferSize, &asset->width, &asset->height, nullptr, 4); @@ -236,7 +277,7 @@ namespace SohImGui { void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint) { GfxRenderingAPI* api = gfx_get_current_rendering_api(); - const auto res = static_cast(GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(normalize(path)).get()); + const auto res = static_cast(GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(path).get()); std::vector texBuffer; texBuffer.reserve(res->width * res->height * 4); @@ -279,23 +320,26 @@ namespace SohImGui { } void Init(WindowImpl window_impl) { - impl = window_impl; Game::LoadSettings(); + impl = window_impl; ImGuiContext* ctx = ImGui::CreateContext(); ImGui::SetCurrentContext(ctx); io = &ImGui::GetIO(); io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; + io->Fonts->AddFontDefault(); + if (UseViewports()) { io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; } console->Init(); + overlay->Init(); ImGuiWMInit(); ImGuiBackendInit(); ModInternal::registerHookListener({ GFX_INIT, [](const HookEvent ev) { if (GlobalCtx2::GetInstance()->GetWindow()->IsFullscreen()) - ShowCursor(Game::Settings.debug.menu_bar, Dialogues::dLoadSettings); + ShowCursor(CVar_GetS32("gOpenMenuBar", 0), Dialogues::dLoadSettings); LoadTexture("Game_Icon", "assets/ship_of_harkinian/icons/gSohIcon.png"); LoadTexture("A-Btn", "assets/ship_of_harkinian/buttons/ABtn.png"); @@ -310,9 +354,16 @@ namespace SohImGui { LoadTexture("C-Down", "assets/ship_of_harkinian/buttons/CDown.png"); } }); + for (const auto& [i, controllers] : Ship::Window::Controllers) + { + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX", i).c_str(), 0); + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY", i).c_str(), 0); + needs_save = true; + } + ModInternal::registerHookListener({ CONTROLLER_READ, [](const HookEvent ev) { pads = static_cast(ev->baseArgs["cont_pad"]); - } }); + }}); Game::InitSettings(); } @@ -326,7 +377,7 @@ namespace SohImGui { #define BindButton(btn, status) ImGui::Image(GetTextureByID(DefaultAssets[btn]->textureId), ImVec2(16.0f * scale, 16.0f * scale), ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, (status) ? 255 : 0)); - void BindAudioSlider(const char* name, const char* key, float defaultValue, SeqPlayers playerId) + void BindAudioSlider(const char* name, const char* key, float defaultValue, SeqPlayers playerId) { float value = CVar_GetFloat(key, defaultValue); @@ -339,6 +390,24 @@ namespace SohImGui { } } + void EnhancementRadioButton(std::string text, std::string cvarName, int id) { + /*Usage : + EnhancementRadioButton("My Visible Name","gMyCVarName", MyID); + First arg is the visible name of the Radio button + Second is the cvar name where MyID will be saved. + Note: the CVar name should be the same to each Buddies. + Example : + EnhancementRadioButton("English", "gLanguages", 0); + EnhancementRadioButton("German", "gLanguages", 1); + EnhancementRadioButton("French", "gLanguages", 2); + */ + int val = CVar_GetS32(cvarName.c_str(), 0); + if (ImGui::RadioButton(text.c_str(), id==val)) { + CVar_SetS32(cvarName.c_str(), (int)id); + needs_save = true; + } + } + void EnhancementCheckbox(std::string text, std::string cvarName) { bool val = (bool)CVar_GetS32(cvarName.c_str(), 0); @@ -348,13 +417,22 @@ namespace SohImGui { } } + void EnhancementButton(std::string text, std::string cvarName) + { + bool val = (bool)CVar_GetS32(cvarName.c_str(), 0); + if (ImGui::Button(text.c_str())) { + CVar_SetS32(cvarName.c_str(), !val); + needs_save = true; + } + } + void EnhancementSliderInt(std::string text, std::string id, std::string cvarName, int min, int max, std::string format) { int val = CVar_GetS32(cvarName.c_str(), 0); ImGui::Text(text.c_str(), val); - if (ImGui::SliderInt(id.c_str(), &val, min, max, format.c_str())) + if (ImGui::SliderInt(id.c_str(), &val, min, max, format.c_str())) { CVar_SetS32(cvarName.c_str(), val); needs_save = true; @@ -417,7 +495,7 @@ namespace SohImGui { colors[2] = b / 255.0f; { - if (ImGui::ColorEdit3(text.c_str(), colors)) + if (ImGui::ColorEdit3(text.c_str(), colors)) { CVar_SetS32((cvarName + "_Red").c_str(), (int)(colors[0] * 255)); CVar_SetS32((cvarName + "_Green").c_str(), (int)(colors[1] * 255)); @@ -427,7 +505,7 @@ namespace SohImGui { } } - void DrawMainMenuAndCalculateGameSize() { + void DrawMainMenuAndCalculateGameSize() { console->Update(); ImGuiBackendNewFrame(); ImGuiWMNewFrame(); @@ -437,7 +515,7 @@ namespace SohImGui { ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoResize; - if (Game::Settings.debug.menu_bar) window_flags |= ImGuiWindowFlags_MenuBar; + if (CVar_GetS32("gOpenMenuBar", 0)) window_flags |= ImGuiWindowFlags_MenuBar; const ImGuiViewport* viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowPos(viewport->WorkPos); @@ -465,10 +543,11 @@ namespace SohImGui { ImGui::DockSpace(dockId, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None); if (ImGui::IsKeyPressed(TOGGLE_BTN)) { - Game::Settings.debug.menu_bar = !Game::Settings.debug.menu_bar; + bool menu_bar = CVar_GetS32("gOpenMenuBar", 0); + CVar_SetS32("gOpenMenuBar", !menu_bar); needs_save = true; - GlobalCtx2::GetInstance()->GetWindow()->dwMenubar = Game::Settings.debug.menu_bar; - ShowCursor(Game::Settings.debug.menu_bar, Dialogues::dMenubar); + GlobalCtx2::GetInstance()->GetWindow()->dwMenubar = menu_bar; + ShowCursor(menu_bar, Dialogues::dMenubar); } if (ImGui::BeginMenuBar()) { @@ -509,8 +588,8 @@ namespace SohImGui { if (ImGui::Button("Recalibrate Gyro")) { - CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX").c_str(), 0); - CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY").c_str(), 0); + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftX", i).c_str(), 0); + CVar_SetFloat(StringHelper::Sprintf("gCont%i_GyroDriftY", i).c_str(), 0); needs_save = true; } @@ -537,13 +616,47 @@ namespace SohImGui { ImGui::EndMenu(); } + if (ImGui::BeginMenu("Graphics")) + { + EnhancementSliderInt("Internal Resolution: %dx", "##IMul", "gInternalResolution", 1, 8, ""); + gfx_current_dimensions.internal_mul = CVar_GetS32("gInternalResolution", 1); + EnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, ""); + gfx_msaa_level = CVar_GetS32("gMSAAValue", 1); + + EXPERIMENTAL(); + ImGui::Text("Texture Filter (Needs reload)"); + GfxRenderingAPI* gapi = gfx_get_current_rendering_api(); + if (ImGui::BeginCombo("##filters", filters[gapi->get_texture_filter()])) { + for (int fId = 0; fId <= FilteringMode::NONE; fId++) { + if (ImGui::Selectable(filters[fId], fId == gapi->get_texture_filter())) { + INFO("New Filter: %s", filters[fId]); + gapi->set_texture_filter((FilteringMode)fId); + + CVar_SetS32("gTextureFilter", (int) fId); + needs_save = true; + } + + } + ImGui::EndCombo(); + } + overlay->DrawSettings(); + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Languages")) { + EnhancementRadioButton("English", "gLanguages", 0); + EnhancementRadioButton("German", "gLanguages", 1); + EnhancementRadioButton("French", "gLanguages", 2); + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Enhancements")) { - ImGui::Text("Gameplay"); ImGui::Separator(); EnhancementSliderInt("Text Speed: %dx", "##TEXTSPEED", "gTextSpeed", 1, 5, ""); + EnhancementSliderInt("King Zora Speed: %dx", "##WEEPSPEED", "gMweepSpeed", 1, 5, ""); EnhancementCheckbox("Skip Text", "gSkipText"); EnhancementCheckbox("Minimal UI", "gMinimalUI"); @@ -556,51 +669,19 @@ namespace SohImGui { EnhancementCheckbox("N64 Mode", "gN64Mode"); EnhancementCheckbox("Animated Link in Pause Menu", "gPauseLiveLink"); - EnhancementCheckbox("Disable LOD", "gDisableLOD"); EnhancementCheckbox("Enable 3D Dropped items", "gNewDrops"); + EnhancementCheckbox("Faster Block Push", "gFasterBlockPush"); EnhancementCheckbox("Dynamic Wallet Icon", "gDynamicWalletIcon"); + EnhancementCheckbox("Always show dungeon entrances", "gAlwaysShowDungeonMinimapIcon"); - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Developer Tools")) - { - HOOK(ImGui::MenuItem("Stats", nullptr, &Game::Settings.debug.soh)); - HOOK(ImGui::MenuItem("Console", nullptr, &console->opened)); - - ImGui::Text("Debug"); + ImGui::Text("Fixes"); ImGui::Separator(); + EnhancementCheckbox("Fix L&R Pause menu", "gUniformLR"); + EnhancementCheckbox("Fix Dungeon entrances", "gFixDungeonMinimapIcon"); - EnhancementCheckbox("Debug Mode", "gDebugEnabled"); + EXPERIMENTAL(); - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Graphics")) - { - HOOK(ImGui::MenuItem("Anti-aliasing", nullptr, &Game::Settings.graphics.show)); - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Cheats")) - { - if (ImGui::BeginMenu("Infinite...")) { - EnhancementCheckbox("Money", "gInfiniteMoney"); - EnhancementCheckbox("Health", "gInfiniteHealth"); - EnhancementCheckbox("Ammo", "gInfiniteAmmo"); - EnhancementCheckbox("Magic", "gInfiniteMagic"); - EnhancementCheckbox("Nayru's Love", "gInfiniteNayru"); - - ImGui::EndMenu(); - } - - EnhancementCheckbox("No Clip", "gNoClip"); - EnhancementCheckbox("Climb Everything", "gClimbEverything"); - EnhancementCheckbox("Moon Jump on L", "gMoonJumpOnL"); - EnhancementCheckbox("Super Tunic", "gSuperTunic"); - EnhancementCheckbox("Easy ISG", "gEzISG"); - EnhancementCheckbox("Unrestricted Items", "gNoRestrictItems"); - EnhancementCheckbox("Freeze Time", "gFreezeTime"); + EnhancementCheckbox("Disable LOD", "gDisableLOD"); ImGui::EndMenu(); } @@ -629,13 +710,53 @@ namespace SohImGui { ImGui::EndMenu(); } + if (ImGui::BeginMenu("Cheats")) + { + if (ImGui::BeginMenu("Infinite...")) { + EnhancementCheckbox("Money", "gInfiniteMoney"); + EnhancementCheckbox("Health", "gInfiniteHealth"); + EnhancementCheckbox("Ammo", "gInfiniteAmmo"); + EnhancementCheckbox("Magic", "gInfiniteMagic"); + EnhancementCheckbox("Nayru's Love", "gInfiniteNayru"); + + ImGui::EndMenu(); + } + + EnhancementCheckbox("No Clip", "gNoClip"); + EnhancementCheckbox("Climb Everything", "gClimbEverything"); + EnhancementCheckbox("Moon Jump on L", "gMoonJumpOnL"); + EnhancementCheckbox("Super Tunic", "gSuperTunic"); + EnhancementCheckbox("Easy ISG", "gEzISG"); + EnhancementCheckbox("Unrestricted Items", "gNoRestrictItems"); + EnhancementCheckbox("Freeze Time", "gFreezeTime"); + + ImGui::EndMenu(); + } + + if (ImGui::BeginMenu("Developer Tools")) + { + EnhancementCheckbox("OoT Debug Mode", "gDebugEnabled"); + ImGui::Separator(); + EnhancementCheckbox("Stats", "gStatsEnabled"); + EnhancementCheckbox("Console", "gConsoleEnabled"); + console->opened = CVar_GetS32("gConsoleEnabled", 0); + + ImGui::EndMenu(); + } + for (const auto& category : windowCategories) { if (ImGui::BeginMenu(category.first.c_str())) { for (const std::string& name : category.second) { - HOOK(ImGui::MenuItem(name.c_str(), nullptr, &customWindows[name].enabled)); + std::string varName(name); + varName.erase(std::ranges::remove_if(varName, isspace).begin(), varName.end()); + std::string toggleName = "g" + varName + "Enabled"; + + EnhancementCheckbox(name, toggleName); + customWindows[name].enabled = CVar_GetS32(toggleName.c_str(), 0); } ImGui::EndMenu(); } + } ImGui::EndMenuBar(); @@ -643,28 +764,21 @@ namespace SohImGui { ImGui::End(); - if (Game::Settings.debug.soh) { + if (CVar_GetS32("gStatsEnabled", 0)) { const float framerate = ImGui::GetIO().Framerate; ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0)); - ImGui::Begin("Debug Stats", nullptr, ImGuiWindowFlags_None); + ImGui::Begin("Debug Stats", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); +#ifdef _WIN32 ImGui::Text("Platform: Windows"); +#else + ImGui::Text("Platform: Linux"); +#endif ImGui::Text("Status: %.3f ms/frame (%.1f FPS)", 1000.0f / framerate, framerate); ImGui::End(); ImGui::PopStyleColor(); } - if (Game::Settings.graphics.show) { - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0)); - ImGui::Begin("Anti-aliasing settings", nullptr, ImGuiWindowFlags_None); - ImGui::Text("Internal Resolution:"); - ImGui::SliderInt("Mul", reinterpret_cast(&gfx_current_dimensions.internal_mul), 1, 8); - ImGui::Text("MSAA:"); - ImGui::SliderInt("MSAA", reinterpret_cast(&gfx_msaa_level), 1, 8); - ImGui::End(); - ImGui::PopStyleColor(); - } - console->Draw(); for (auto& windowIter : customWindows) { @@ -705,6 +819,8 @@ namespace SohImGui { pos = ImVec2(size.x / 2 - sw / 2, 0); size = ImVec2(sw, size.y); } + + overlay->Draw(); } void DrawFramebufferAndGameInput() { @@ -814,4 +930,15 @@ namespace SohImGui { ImTextureID GetTextureByName(const std::string& name) { return GetTextureByID(DefaultAssets[name]->textureId); } + + ImTextureID GetTextureByID(int id) { +#ifdef ENABLE_DX11 + if (impl.backend == Backend::DX11) + { + ImTextureID gfx_d3d11_get_texture_by_id(int id); + return gfx_d3d11_get_texture_by_id(id); + } +#endif + return reinterpret_cast(id); + } } diff --git a/libultraship/libultraship/SohImGuiImpl.h b/libultraship/libultraship/SohImGuiImpl.h index b2b29e3d5..dd0ec9fd3 100644 --- a/libultraship/libultraship/SohImGuiImpl.h +++ b/libultraship/libultraship/SohImGuiImpl.h @@ -1,5 +1,6 @@ #pragma once +#include "GameOverlay.h" #include "Lib/ImGui/imgui.h" #include "SohConsole.h" @@ -58,13 +59,16 @@ namespace SohImGui { } CustomWindow; extern Console* console; + extern Ship::GameOverlay* overlay; + extern bool needs_save; void Init(WindowImpl window_impl); void Update(EventImpl event); - + void EnhancementRadioButton(std::string text, std::string cvarName, int value); void EnhancementCheckbox(std::string text, std::string cvarName); void EnhancementSliderInt(std::string text, std::string id, std::string cvarName, int min, int max, std::string format); void EnhancementSliderFloat(std::string text, std::string id, std::string cvarName, float min, float max, std::string format, float defaultValue); + void DrawMainMenuAndCalculateGameSize(void); void DrawFramebufferAndGameInput(void); diff --git a/libultraship/libultraship/TextureMod.cpp b/libultraship/libultraship/TextureMod.cpp index 2a7e39511..b44987a62 100644 --- a/libultraship/libultraship/TextureMod.cpp +++ b/libultraship/libultraship/TextureMod.cpp @@ -43,7 +43,7 @@ namespace Ship { if (raw_path == nullptr) return; const auto api = BIND_PTR("gfx_api", GfxRenderingAPI*); - const auto path = normalize(raw_path) + ".png"; + const auto path = std::string(raw_path) + ".png"; const auto node = BIND_PTR("node", TextureCacheNode**); const auto fmt = BIND_VAR("fmt", uint32_t*); const auto siz = BIND_VAR("siz", uint32_t*); diff --git a/libultraship/libultraship/TextureMod.h b/libultraship/libultraship/TextureMod.h index 987a0c6f3..8dac99387 100644 --- a/libultraship/libultraship/TextureMod.h +++ b/libultraship/libultraship/TextureMod.h @@ -36,15 +36,6 @@ namespace Ship { void Hook_InvalidateTexture(HookEvent event); }; - inline std::string normalize(std::string path) { -#ifdef _WIN32 - std::ranges::replace(path, '/', '\\'); -#else - std::replace(path.begin(), path.end(), '\\', '/'); -#endif - return path; - } - inline void GrayOutTexture(uint8_t* data, int width, int height) { for (int x = 0; x < width * height * 4; x += 4) { diff --git a/libultraship/libultraship/Utils.cpp b/libultraship/libultraship/Utils.cpp index e36ba29f5..d54952c77 100644 --- a/libultraship/libultraship/Utils.cpp +++ b/libultraship/libultraship/Utils.cpp @@ -1,9 +1,14 @@ #include "Utils.h" +#include + +#ifdef _MSC_VER +#define strdup _strdup +#endif namespace Utils { std::vector SplitText(const std::string text, char separator = ' ', bool keep_quotes = false) { std::vector args; - char* input = _strdup(text.c_str()); + char* input = strdup(text.c_str()); const size_t length = strlen(input); bool inQuotes = false; diff --git a/libultraship/libultraship/WasapiAudioPlayer.cpp b/libultraship/libultraship/WasapiAudioPlayer.cpp index 26e4504d3..30cb10905 100644 --- a/libultraship/libultraship/WasapiAudioPlayer.cpp +++ b/libultraship/libultraship/WasapiAudioPlayer.cpp @@ -1,3 +1,4 @@ +#ifdef _WIN32 #include "WasapiAudioPlayer.h" #include "spdlog/spdlog.h" @@ -169,4 +170,5 @@ namespace Ship { } return S_OK; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/libultraship/libultraship/WasapiAudioPlayer.h b/libultraship/libultraship/WasapiAudioPlayer.h index 5067d01a2..dac7dd7a7 100644 --- a/libultraship/libultraship/WasapiAudioPlayer.h +++ b/libultraship/libultraship/WasapiAudioPlayer.h @@ -1,4 +1,7 @@ #pragma once + +#ifdef _WIN32 + #include "AudioPlayer.h" #include #include @@ -39,3 +42,4 @@ namespace Ship { bool started; }; } +#endif diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index 0feb7229f..35a95f0de 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -12,6 +12,8 @@ #include "Matrix.h" #include "AudioPlayer.h" #include "WasapiAudioPlayer.h" +#include "PulseAudioPlayer.h" +#include "SDLAudioPlayer.h" #include "Lib/Fast3D/gfx_pc.h" #include "Lib/Fast3D/gfx_sdl.h" #include "Lib/Fast3D/gfx_opengl.h" @@ -22,6 +24,7 @@ #include #include "SohHooks.h" #include "SohConsole.h" + #include extern "C" { @@ -48,7 +51,7 @@ extern "C" { } // TODO: This for loop is debug. Burn it with fire. - for (size_t i = 0; i < SDL_NumJoysticks(); i++) { + for (int i = 0; i < SDL_NumJoysticks(); i++) { if (SDL_IsGameController(i)) { // Get the GUID from SDL char buf[33]; @@ -207,7 +210,7 @@ extern "C" { return (char*)res->imageData; } - void ResourceMgr_WriteTexS16ByName(char* texPath, int index, s16 value) { + void ResourceMgr_WriteTexS16ByName(char* texPath, size_t index, s16 value) { const auto res = static_cast(Ship::GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(texPath).get()); if (res != nullptr) @@ -237,7 +240,7 @@ extern "C" { } } -extern "C" GfxWindowManagerAPI gfx_sdl; +extern GfxWindowManagerAPI gfx_sdl; void SetWindowManager(GfxWindowManagerAPI** WmApi, GfxRenderingAPI** RenderingApi, const std::string& gfx_backend); namespace Ship { @@ -326,6 +329,8 @@ namespace Ship { GlobalCtx2::GetInstance()->GetWindow()->ToggleFullscreen(); } + + // OTRTODO: Rig with Kirito's console? //if (dwScancode == Ship::stoi(Conf["KEYBOARD SHORTCUTS"]["KEY_CONSOLE"])) { // ToggleConsole(); @@ -397,6 +402,12 @@ namespace Ship { } void Window::SetAudioPlayer() { +#ifdef _WIN32 APlayer = std::make_shared(); +#elif defined(__linux) + APlayer = std::make_shared(); +#else + APlayer = std::make_shared(); +#endif } } diff --git a/libultraship/libultraship/WindowShim.cpp b/libultraship/libultraship/WindowShim.cpp index 96b636aff..4469c5c29 100644 --- a/libultraship/libultraship/WindowShim.cpp +++ b/libultraship/libultraship/WindowShim.cpp @@ -23,7 +23,9 @@ void SetWindowManager(struct GfxWindowManagerAPI** WmApi, struct GfxRenderingAPI #ifdef ENABLE_OPENGL *RenderingApi = &gfx_opengl_api; #if defined(__linux__) - *WmApi = &gfx_glx; + // LINUX_TODO: + // *WmApi = &gfx_glx; + *WmApi = &gfx_sdl; #else *WmApi = &gfx_sdl; #endif diff --git a/libultraship/libultraship/libultraship.vcxproj b/libultraship/libultraship/libultraship.vcxproj index 3bf81a67d..b3448e7b0 100644 --- a/libultraship/libultraship/libultraship.vcxproj +++ b/libultraship/libultraship/libultraship.vcxproj @@ -256,6 +256,7 @@ + @@ -343,6 +344,7 @@ + diff --git a/libultraship/libultraship/libultraship.vcxproj.filters b/libultraship/libultraship/libultraship.vcxproj.filters index 5079d826e..8ac4f0afb 100644 --- a/libultraship/libultraship/libultraship.vcxproj.filters +++ b/libultraship/libultraship/libultraship.vcxproj.filters @@ -88,6 +88,9 @@ {bd6557f1-9480-413b-b0cd-843f8efc1939} + + {3285ab8a-06d8-4dac-9af9-efb2a9723ab1} + @@ -339,6 +342,9 @@ Source Files\CustomImpl + + Source Files\CustomImpl\Overlay + @@ -629,5 +635,8 @@ Source Files\Resources + + Source Files\CustomImpl\Overlay + \ No newline at end of file diff --git a/libultraship/libultraship/mixer.c b/libultraship/libultraship/mixer.c index b81eb915a..302a54ef4 100644 --- a/libultraship/libultraship/mixer.c +++ b/libultraship/libultraship/mixer.c @@ -449,13 +449,16 @@ void aFilterImpl(uint8_t flags, uint16_t count_or_buf, int16_t *state_or_filter) int16_t *buf = BUF_S16(count_or_buf); if (flags == A_INIT) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmemset-elt-size" memset(tmp, 0, 8 * sizeof(int16_t)); +#pragma GCC diagnostic pop memset(tmp2, 0, 8 * sizeof(int16_t)); } else { memcpy(tmp, state_or_filter, 8 * sizeof(int16_t)); memcpy(tmp2, state_or_filter + 8, 8 * sizeof(int16_t)); } - + for (int i = 0; i < 8; i++) { rspa.filter[i] = (tmp2[i] + rspa.filter[i]) / 2; } diff --git a/libultraship/libultraship/stox.cpp b/libultraship/libultraship/stox.cpp index 75fcdfbf0..fa2dff974 100644 --- a/libultraship/libultraship/stox.cpp +++ b/libultraship/libultraship/stox.cpp @@ -1,3 +1,4 @@ +#include #include "stox.h" #include "spdlog/spdlog.h" diff --git a/soh/.gitignore b/soh/.gitignore index fafae443d..5920cfba7 100644 --- a/soh/.gitignore +++ b/soh/.gitignore @@ -25,6 +25,10 @@ docs/doxygen/ *.map *.dump out.txt +shipofharkinian.ini +imgui.ini +oot.otr +oot_save.sav # Tool artifacts tools/mipspro7.2_compiler/ @@ -279,7 +283,7 @@ ClientBin/ *.publishsettings orleans.codegen.cs -# Including strong name files can present a security risk +# Including strong name files can present a security risk # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk @@ -375,7 +379,7 @@ __pycache__/ # OpenCover UI analysis results OpenCover/ -# Azure Stream Analytics local run output +# Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log @@ -384,7 +388,7 @@ ASALocalRun/ # NVidia Nsight GPU debugger configuration file *.nvuser -# MFractors (Xamarin productivity tool) working folder +# MFractors (Xamarin productivity tool) working folder .mfractor/ *.out @@ -397,6 +401,7 @@ ZAPDUtils/ZAPDUtils.a build/ ZAPDUtils/build/ ZAPD/BuildInfo.h +cvars.cfg DebugObj/* ReleaseObj/* \ No newline at end of file diff --git a/soh/Makefile b/soh/Makefile new file mode 100644 index 000000000..be46f55e7 --- /dev/null +++ b/soh/Makefile @@ -0,0 +1,158 @@ +CXX := g++ +CC := gcc +LD := lld +AR := ar +FORMAT := clang-format-11 +ZAPD := ../ZAPDTR/ZAPD.out + +LIBULTRASHIP := ../libultraship/libultraship.a +ZAPDUTILS := ../ZAPDTR/ZAPDUtils/ZAPDUtils.a + +ASAN ?= 0 +DEBUG ?= 1 +OPTFLAGS ?= -O0 +LTO ?= 0 + +WARN := \ + -Wno-return-type \ + -funsigned-char \ + -m32 -mhard-float -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ + +CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib -march=i386 +CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib -march=i386 +LDFLAGS := -m32 +CPPFLAGS := -MMD + +ifneq ($(DEBUG),0) + CXXFLAGS += -g + CFLAGS += -g +endif + +ifneq ($(ASAN),0) + CXXFLAGS += -fsanitize=address + LDFLAGS += -fsanitize=address +endif + +ifneq ($(LTO),0) + CXXFLAGS += -flto + LDFLAGS += -flto +endif + +TARGET := soh.elf + +INC_DIRS := $(addprefix -I, \ + . \ + assets \ + build \ + include \ + src \ + ../ZAPDTR/ZAPDUtils \ + ../libultraship/libultraship \ + ../libultraship/libultraship/Lib/spdlog/include \ + ../libultraship/libultraship/Lib/Fast3D/U64 \ + ../libultraship/libultraship/Lib/Fast3D/U64/PR \ +) + +LDDIRS := $(addprefix -L, \ + ../external \ + ../libultraship/ \ +) + +LDLIBS := \ + $(ZAPDUTILS) \ + $(addprefix -l, \ + X11 \ + dl \ + bz2 \ + z \ + pthread \ + atomic \ + SDL2 \ + GL \ + GLEW \ + storm \ + pulse\ + ultraship \ +) \ + +ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*") +ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml)) +ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin)) +ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_XML:.xml=.c),$f) \ + $(foreach f,$(ASSET_FILES_BIN:.bin=.bin.inc.c),build/$f) + +TEXTURE_FILES_PNG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.png)) +TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg)) +TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \ + $(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),build/$f) \ + +CXX_FILES := \ + $(shell find soh -type f -name *.cpp) + +C_FILES := \ + $(shell find soh -type f -name *.c) \ + $(shell find src/boot -type f -name *.c) \ + $(shell find src/buffers -type f -name *.c) \ + $(shell find src/code -type f -name *.c) \ + $(shell find src/overlays -type f -name *.c) \ + src/libultra/gu/coss.c \ + src/libultra/gu/guLookAt.c \ + src/libultra/gu/guLookAtHilite.c \ + src/libultra/gu/guPerspectiveF.c \ + src/libultra/gu/guPosition.c \ + src/libultra/gu/guS2DInitBg.c \ + src/libultra/gu/ortho.c \ + src/libultra/gu/rotate.c \ + src/libultra/gu/sins.c \ + src/libultra/gu/sintable.c \ + src/libultra/libc/sprintf.c + +O_FILES := \ + $(C_FILES:%.c=build/%.o) \ + $(CXX_FILES:%.cpp=build/%.o) +D_FILES := $(O_FILES:%.o=%.d) + +# create build directory +SRC_DIRS := $(shell find . -type d -a -not -path "*build*") +$(shell mkdir -p $(SRC_DIRS:%=build/%)) + +all: + $(MAKE) -C ../libultraship + $(MAKE) $(TARGET) + +setup: + cd ../OTRExporter && python3 extract_baserom.py + $(MAKE) mpq + +mpq: + $(MAKE) -C ../libultraship + $(MAKE) -C ../OTRExporter/OTRExporter + $(MAKE) -C ../ZAPDTR + rm -rf ../OTRExporter/oot.otr + cd ../OTRExporter && python3 extract_assets.py + cp ../OTRExporter/oot.otr . + +distclean: clean + $(RM) -r baserom/ + $(MAKE) clean -C ../libultraship + $(MAKE) clean -C ../OTRExporter/OTRExporter + $(MAKE) clean -C ../ZAPDTR + +clean: + rm -rf build $(TARGET) + +.PHONY: all clean distclean setup mpq + +build/%.o: %.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) $< -o $@ + +build/%.o: %.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) $< -o $@ + +# make soh depend on libultraship +$(TARGET): $(LIBULTRASHIP) + +$(TARGET): $(O_FILES) + $(CXX) $^ -o $@ $(LDFLAGS) -fuse-ld=$(LD) $(LDDIRS) $(LDLIBS) + +-include $(D_FILES) \ No newline at end of file diff --git a/soh/assets/xml/GC_NMQ_D/textures/map_48x85_static.xml b/soh/assets/xml/GC_NMQ_D/textures/map_48x85_static.xml index b5b1d1a85..2788498a8 100644 --- a/soh/assets/xml/GC_NMQ_D/textures/map_48x85_static.xml +++ b/soh/assets/xml/GC_NMQ_D/textures/map_48x85_static.xml @@ -1,72 +1,72 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/soh/assets/xml/GC_NMQ_PAL_F/textures/map_48x85_static.xml b/soh/assets/xml/GC_NMQ_PAL_F/textures/map_48x85_static.xml index b5b1d1a85..b2ea46340 100644 --- a/soh/assets/xml/GC_NMQ_PAL_F/textures/map_48x85_static.xml +++ b/soh/assets/xml/GC_NMQ_PAL_F/textures/map_48x85_static.xml @@ -1,72 +1,72 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/soh/include/alloca.h b/soh/include/alloca.h index 9c6a0ab94..10025b7f7 100644 --- a/soh/include/alloca.h +++ b/soh/include/alloca.h @@ -1,7 +1,7 @@ #ifndef ALLOCA_H #define ALLOCA_H -void* alloca(u32); +// void* alloca(u32); //#define alloca __builtin_alloca #define alloca malloc diff --git a/soh/include/functions.h b/soh/include/functions.h index 13e3a7055..4631cdb92 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -14,7 +14,7 @@ extern "C" #if defined(INCLUDE_GAME_PRINTF) && !defined(NDEBUG) #define osSyncPrintf(fmt, ...) lusprintf(__FILE__, __LINE__, 0, fmt, __VA_ARGS__) #else -#define osSyncPrintf(fmt, ...) osSyncPrintfUnused(fmt, __VA_ARGS__) +#define osSyncPrintf(fmt, ...) osSyncPrintfUnused(fmt, ##__VA_ARGS__) #endif f32 fabsf(f32 f); @@ -29,6 +29,7 @@ void gDPSetTextureImage(Gfx* pkt, u32 f, u32 s, u32 w, uintptr_t i); void gSPDisplayList(Gfx* pkt, Gfx* dl); void gSPDisplayListOffset(Gfx* pkt, Gfx* dl, int offset); void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0); +void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr); void cleararena(void); void bootproc(void); @@ -381,7 +382,7 @@ void Flags_UnsetTempClear(GlobalContext* globalCtx, s32 flag); s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag); void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag); void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s16 x, s16 y, u8 width, - u8 height); + u8 height, s16 hastranslation); void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, s32 width, s32 height, s32 delay); s32 func_8002D53C(GlobalContext* globalCtx, TitleCardContext* titleCtx); @@ -656,10 +657,12 @@ Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041D4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041D70(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_80041D94(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80041DB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80041DE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80041E18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 func_80041E4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041EA4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041EC8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); @@ -2402,7 +2405,9 @@ void Heaps_Alloc(void); void Heaps_Free(void); #ifdef __cplusplus +#undef this }; +#undef this #endif #endif diff --git a/soh/include/global.h b/soh/include/global.h index 4845728dd..2e4808fe0 100644 --- a/soh/include/global.h +++ b/soh/include/global.h @@ -4,8 +4,8 @@ #include "functions.h" #include "variables.h" #include "macros.h" -#include "soh\OTRGlobals.h" -#include "soh\Enhancements\gameconsole.h" +#include "soh/OTRGlobals.h" +#include "soh/Enhancements/gameconsole.h" #include "Cvar.h" diff --git a/soh/include/libc/stddef.h b/soh/include/libc/stddef.h index c30e392f8..e5fbe2d22 100644 --- a/soh/include/libc/stddef.h +++ b/soh/include/libc/stddef.h @@ -1,7 +1,12 @@ #ifndef STDDEF_H #define STDDEF_H +#ifndef __cplusplus #define NULL ((void*)0) +#else +#define NULL nullptr +#endif + #if 0 #define size_t unsigned long #define ssize_t long diff --git a/soh/include/macros.h b/soh/include/macros.h index c57effe02..a621a65f8 100644 --- a/soh/include/macros.h +++ b/soh/include/macros.h @@ -205,6 +205,14 @@ extern GraphicsContext* __gfxCtx; #define ALIGNED8 #endif -#define SEG_ADDR(seg, addr) (addr | (seg << 24) | 0xF0000000) +#define SEG_ADDR(seg, addr) (addr | (seg << 24) | 1) + +#ifdef _MSC_VER +#define BOMSWAP16 _byteswap_ushort +#define BOMSWAP32 _byteswap_ulong +#else +#define BOMSWAP16 __builtin_bswap16 +#define BOMSWAP32 __builtin_bswap32 +#endif #endif diff --git a/soh/include/ultra64.h b/soh/include/ultra64.h index 65ef6d147..c2e0e9b29 100644 --- a/soh/include/ultra64.h +++ b/soh/include/ultra64.h @@ -1,6 +1,9 @@ #ifndef ULTRA64_H #define ULTRA64_H +#include +#include +#include #include "ultra64/types.h" #include "unk.h" diff --git a/soh/include/z64.h b/soh/include/z64.h index f0dfba52d..7720144b4 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -30,6 +30,9 @@ #include "ichain.h" #include "regs.h" +#define AUDIO_HEAP_SIZE 0x38000 +#define SYSTEM_HEAP_SIZE (1024 * 1024 * 4) + #ifdef __cplusplus namespace Ship { @@ -251,6 +254,8 @@ typedef struct { /* 0x0B */ u8 delayTimer; // how long the title card waits to appear /* 0x0C */ s16 alpha; /* 0x0E */ s16 intensity; + /* ---- */ s16 isBossCard; //To detect if that a Boss name title card. + /* ---- */ s16 hasTranslation; // to detect if the current title card has translation (used for bosses only) } TitleCardContext; // size = 0x10 typedef struct { diff --git a/soh/soh.vcxproj b/soh/soh.vcxproj index d35dd18b3..a395a22ce 100644 --- a/soh/soh.vcxproj +++ b/soh/soh.vcxproj @@ -175,9 +175,12 @@ + + + @@ -276,6 +279,7 @@ + @@ -325,7 +329,6 @@ - @@ -922,9 +925,13 @@ + + + + @@ -1404,4 +1411,4 @@ - + \ No newline at end of file diff --git a/soh/soh.vcxproj.filters b/soh/soh.vcxproj.filters index c31a78b19..b9d68b704 100644 --- a/soh/soh.vcxproj.filters +++ b/soh/soh.vcxproj.filters @@ -630,9 +630,6 @@ Source Files\src\code - - Source Files\src\code - Source Files\src\code @@ -2184,6 +2181,18 @@ Source Files\soh + + Source Files\soh\Enhancements\debugger + + + Source Files\soh\Enhancements\debugger + + + Source Files + + + Source Files\soh\Enhancements + @@ -3734,6 +3743,18 @@ Header Files\soh + + Header Files\soh\Enhancements\debugger + + + Header Files\soh\Enhancements\debugger + + + Source Files\soh\Enhancements + + + Source Files\soh + diff --git a/soh/soh/Enhancements/bootcommands.c b/soh/soh/Enhancements/bootcommands.c index da4276f77..03742dae9 100644 --- a/soh/soh/Enhancements/bootcommands.c +++ b/soh/soh/Enhancements/bootcommands.c @@ -29,6 +29,7 @@ void BootCommands_Init() CVar_RegisterS32("gUniformLR", 1); CVar_RegisterS32("gNewDrops", 0); CVar_RegisterS32("gVisualAgony", 0); + CVar_RegisterS32("gLanguages", 0); //0 = English / 1 = German / 2 = French } //void BootCommands_ParseBootArgs(char* str) diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index ff69830e7..1b892be74 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -1,12 +1,22 @@ +#ifdef _MSC_VER +#define NOGDI +#endif + #include "debugconsole.h" #include "../libultraship/SohImGuiImpl.h" +#include "savestates.h" + #include #include +#include "soh/OTRGlobals.h" + #define Path _Path #define PATH_HACK #include #include + +#include "Lib/ImGui/imgui_internal.h" #undef PATH_HACK #undef Path @@ -18,7 +28,7 @@ extern "C" { extern GlobalContext* gGlobalCtx; } -#include "cvar.h" +#include "Cvar.h" #define CMD_REGISTER SohImGui::BindCmd @@ -122,7 +132,7 @@ static bool RuppeHandler(const std::vector& args) { try { rupeeAmount = std::stoi(args[1]); } - catch (std::invalid_argument const& ex) { + catch (std::invalid_argument const& ex) { ERROR("[SOH] Rupee count must be an integer."); return CMD_FAILED; } @@ -168,13 +178,13 @@ static bool ResetHandler(std::vector args) { ERROR("GlobalCtx == nullptr"); return CMD_FAILED; } - + SET_NEXT_GAMESTATE(&gGlobalCtx->state, TitleSetup_Init, GameState); gGlobalCtx->state.running = false; return CMD_SUCCESS; } -const static std::map ammoItems{ +const static std::map ammoItems{ { "sticks", ITEM_STICK }, { "deku_sticks", ITEM_STICK }, { "nuts", ITEM_NUT }, { "deku_nuts", ITEM_NUT }, { "bombs", ITEM_BOMB }, { "arrows", ITEM_BOW }, @@ -194,7 +204,7 @@ static bool AmmoHandler(const std::vector& args) { try { count = std::stoi(args[2]); - } catch (std::invalid_argument const& ex) { + } catch (std::invalid_argument const& ex) { ERROR("Ammo count must be an integer"); return CMD_FAILED; } @@ -203,7 +213,7 @@ static bool AmmoHandler(const std::vector& args) { ERROR("Ammo count must be positive"); return CMD_FAILED; } - + const auto& it = ammoItems.find(args[1]); if (it == ammoItems.end()) { @@ -213,7 +223,7 @@ static bool AmmoHandler(const std::vector& args) { // I dont think you can do OOB with just this AMMO(it->second) = count; - + //To use a change by uncomment this //Inventory_ChangeAmmo(it->second, count); } @@ -236,7 +246,7 @@ static bool BottleHandler(const std::vector& args) { unsigned int slot; try { slot = std::stoi(args[2]); - } catch (std::invalid_argument const& ex) { + } catch (std::invalid_argument const& ex) { ERROR("[SOH] Bottle slot must be an integer."); return CMD_FAILED; } @@ -275,7 +285,7 @@ static bool ItemHandler(const std::vector& args) { return CMD_FAILED; } - gSaveContext.inventory.items[std::stoi(args[1])] = std::stoi(args[2]); + gSaveContext.inventory.items[std::stoi(args[1])] = std::stoi(args[2]); return CMD_SUCCESS; } @@ -301,6 +311,66 @@ static bool EntranceHandler(const std::vector& args) { gSaveContext.nextTransition = 11; } +static bool SaveStateHandler(const std::vector& args) { + unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); + const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::SAVE }); + + switch (rtn) { + case SaveStateReturn::SUCCESS: + INFO("[SOH] Saved state to slot %u", slot); + return CMD_SUCCESS; + case SaveStateReturn::FAIL_WRONG_GAMESTATE: + ERROR("[SOH] Can not save a state outside of \"GamePlay\""); + return CMD_FAILED; + + } +} + +static bool LoadStateHandler(const std::vector& args) { + unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); + const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::LOAD }); + + switch (rtn) { + case SaveStateReturn::SUCCESS: + INFO("[SOH] Loaded state from slot %u", slot); + return CMD_SUCCESS; + case SaveStateReturn::FAIL_INVALID_SLOT: + ERROR("[SOH] Invalid State Slot Number (%u)", slot); + return CMD_FAILED; + case SaveStateReturn::FAIL_STATE_EMPTY: + ERROR("[SOH] State Slot (%u) is empty", slot); + return CMD_FAILED; + case SaveStateReturn::FAIL_WRONG_GAMESTATE: + ERROR("[SOH] Can not load a state outside of \"GamePlay\""); + return CMD_FAILED; + } + +} + +static bool StateSlotSelectHandler(const std::vector& args) { + if (args.size() != 2) { + ERROR("[SOH] Unexpected arguments passed"); + return CMD_FAILED; + } + int slot; + + try { + slot = std::stoi(args[1], nullptr, 10); + } catch (std::invalid_argument const& ex) { + ERROR("[SOH] SaveState slot value must be a number."); + return CMD_FAILED; + } + + if (slot < 0) { + ERROR("[SOH] Invalid slot passed. Slot must be between 0 and 2"); + return CMD_FAILED; + } + + OTRGlobals::Instance->gSaveStateMgr->SetCurrentSlot(slot); + INFO("[SOH] Slot %u selected", OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot()); + return CMD_SUCCESS; +} + #define VARTYPE_INTEGER 0 #define VARTYPE_FLOAT 1 #define VARTYPE_STRING 2 @@ -334,7 +404,7 @@ static bool SetCVarHandler(const std::vector& args) { int vType = CheckVarType(args[2]); if (vType == VARTYPE_STRING) - CVar_SetString(args[1].c_str(), (char*)args[2].c_str()); + CVar_SetString(args[1].c_str(), args[2].c_str()); else if (vType == VARTYPE_FLOAT) CVar_SetFloat(args[1].c_str(), std::stof(args[2])); else @@ -351,7 +421,7 @@ static bool GetCVarHandler(const std::vector& args) { if (args.size() < 2) return CMD_FAILED; - CVar* cvar = CVar_GetVar(args[1].c_str()); + CVar* cvar = CVar_Get(args[1].c_str()); if (cvar != nullptr) { @@ -415,16 +485,39 @@ void DebugConsole_Init(void) { CMD_REGISTER("entrance", { EntranceHandler, "Sends player to the entered entrance (hex)", { { "entrance", ArgumentType::NUMBER } } }); + CMD_REGISTER("save_state", { SaveStateHandler, "Save a state." }); + CMD_REGISTER("load_state", { LoadStateHandler, "Load a state." }); + CMD_REGISTER("set_slot", { StateSlotSelectHandler, "Selects a SaveState slot", { + { "Slot number", ArgumentType::NUMBER, } + } }); DebugConsole_LoadCVars(); } +template bool is_number(const std::string& s) { + Numeric n; + return ((std::istringstream(s) >> n >> std::ws).eof()); +} + void DebugConsole_LoadCVars() { if (File::Exists("cvars.cfg")) { const auto lines = File::ReadAllLines("cvars.cfg"); for (const std::string& line : lines) { - SohImGui::console->Dispatch(line); + std::vector cfg = StringHelper::Split(line, " = "); + if (line.empty()) continue; + if (cfg.size() < 2) continue; + if (cfg[1].find("\"") != std::string::npos) { + std::string value(cfg[1]); + value.erase(std::ranges::remove(value, '\"').begin(), value.end()); + CVar_SetString(cfg[0].c_str(), ImStrdup(value.c_str())); + } + if (is_number(cfg[1])) { + CVar_SetFloat(cfg[0].c_str(), std::stof(cfg[1])); + } + if (is_number(cfg[1])) { + CVar_SetS32(cfg[0].c_str(), std::stoi(cfg[1])); + } } } } @@ -435,11 +528,11 @@ void DebugConsole_SaveCVars() for (const auto &cvar : cvars) { if (cvar.second->type == CVAR_TYPE_STRING) - output += StringHelper::Sprintf("set %s %s\n", cvar.first.c_str(), cvar.second->value.valueStr); + output += StringHelper::Sprintf("%s = \"%s\"\n", cvar.first.c_str(), cvar.second->value.valueStr); else if (cvar.second->type == CVAR_TYPE_S32) - output += StringHelper::Sprintf("set %s %i\n", cvar.first.c_str(), cvar.second->value.valueS32); + output += StringHelper::Sprintf("%s = %i\n", cvar.first.c_str(), cvar.second->value.valueS32); else if (cvar.second->type == CVAR_TYPE_FLOAT) - output += StringHelper::Sprintf("set %s %f\n", cvar.first.c_str(), cvar.second->value.valueFloat); + output += StringHelper::Sprintf("%s = %f\n", cvar.first.c_str(), cvar.second->value.valueFloat); } File::WriteAllText("cvars.cfg", output); diff --git a/soh/soh/Enhancements/debugger/ImGuiHelpers.cpp b/soh/soh/Enhancements/debugger/ImGuiHelpers.cpp new file mode 100644 index 000000000..6f4f00637 --- /dev/null +++ b/soh/soh/Enhancements/debugger/ImGuiHelpers.cpp @@ -0,0 +1,21 @@ +#include "ImGuiHelpers.h" + +// Adds a text tooltip for the previous ImGui item +void SetLastItemHoverText(const std::string& text) { + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text(text.c_str()); + ImGui::EndTooltip(); + } +} + +// Adds a "?" next to the previous ImGui item with a custom tooltip +void InsertHelpHoverText(const std::string& text) { + ImGui::SameLine(); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text(text.c_str()); + ImGui::EndTooltip(); + } +} diff --git a/soh/soh/Enhancements/debugger/ImGuiHelpers.h b/soh/soh/Enhancements/debugger/ImGuiHelpers.h new file mode 100644 index 000000000..7f01e4580 --- /dev/null +++ b/soh/soh/Enhancements/debugger/ImGuiHelpers.h @@ -0,0 +1,8 @@ +#pragma once +#include "../libultraship/Lib/ImGui/imgui.h" + +#include + +void SetLastItemHoverText(const std::string& text); + +void InsertHelpHoverText(const std::string& text); diff --git a/soh/soh/Enhancements/debugger/colViewer.cpp b/soh/soh/Enhancements/debugger/colViewer.cpp new file mode 100644 index 000000000..ed0fe0b56 --- /dev/null +++ b/soh/soh/Enhancements/debugger/colViewer.cpp @@ -0,0 +1,720 @@ +#include "colViewer.h" +#include "../libultraship/SohImGuiImpl.h" +#include "ImGuiHelpers.h" + +#include +#include +#include + +extern "C" { +#include +#include "variables.h" +#include "functions.h" +#include "macros.h" +extern GlobalContext* gGlobalCtx; +} + +enum class ColRenderSetting { + Disabled, + Solid, + Transparent, + NumSettings +}; + +std::string ColRenderSettingNames[] = { + "Disabled", + "Solid", + "Transparent", +}; + +static ColRenderSetting showSceneColSetting = ColRenderSetting::Disabled; +static ColRenderSetting showBgActorSetting = ColRenderSetting::Disabled; +static ColRenderSetting showColCheckSetting = ColRenderSetting::Disabled; +static ColRenderSetting showWaterboxSetting = ColRenderSetting::Disabled; + +static uint32_t sceneColor = 0xFFFFFFFF; +static uint32_t hookshotColor = 0x8080FFFF; +static uint32_t entranceColor = 0x00FF00FF; +static uint32_t specialSurfaceColor = 0xC0FFC0FF; +static uint32_t interactableColor = 0xC000C0FF; +static uint32_t slopeColor = 0xFFFF80FF; +static uint32_t voidColor = 0xFF0000FF; + +static uint32_t ocColor = 0xFFFFFFFF; +static uint32_t acColor = 0x0000FFFF; +static uint32_t atColor = 0xFF0000FF; + +static uint32_t waterboxColor = 0x0000FFFF; + +static bool applyAsDecal = false; +static bool isShaded = false; + +static std::vector opaDl; +static std::vector xluDl; +static std::vector vtxDl; +static std::vector mtxDl; + +// These DLs contain a cylinder/sphere model scaled to 128x (to have less error) +// The idea is to push a model view matrix, then draw the DL, to draw the shape somewhere with a certain size +static std::vector cylinderGfx; +static std::vector cylinderVtx; +static std::vector sphereGfx; +static std::vector sphereVtx; + +// Create a dropdown menu to set a ColRenderSetting +void DrawColRenderSetting(const std::string& name, ColRenderSetting& setting) { + if (ImGui::BeginCombo(name.c_str(), ColRenderSettingNames[static_cast(setting)].c_str())) { + for (int32_t settingIndex = 0; settingIndex < static_cast(ColRenderSetting::NumSettings); settingIndex++) { + if (ImGui::Selectable(ColRenderSettingNames[settingIndex].c_str())) { + setting = static_cast(settingIndex); + } + } + ImGui::EndCombo(); + } +} + +// Draw a color picker box +void DrawColorPicker(const std::string& name, uint32_t& color) { + float colorAsFloat[4]; + colorAsFloat[0] = ((color >> 24) & 0xFF) / 255.0f; + colorAsFloat[1] = ((color >> 16) & 0xFF) / 255.0f; + colorAsFloat[2] = ((color >> 8) & 0xFF) / 255.0f; + colorAsFloat[3] = (color & 0xFF) / 255.0f; + if (ImGui::ColorEdit4(name.c_str(), colorAsFloat, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel)) { + color = static_cast(colorAsFloat[3] * 255) | + static_cast(colorAsFloat[2] * 255) << 8 | + static_cast(colorAsFloat[1] * 255) << 16 | + static_cast(colorAsFloat[0] * 255) << 24; + } + ImGui::SameLine(); + ImGui::Text(name.c_str()); +} + +// Draws the ImGui window for the collision viewer +void DrawColViewerWindow(bool& open) { + if (!open) { + return; + } + + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Collision Viewer", &open, ImGuiWindowFlags_NoFocusOnAppearing)) { + ImGui::End(); + return; + } + + DrawColRenderSetting("Scene", showSceneColSetting); + DrawColRenderSetting("Bg Actors", showBgActorSetting); + DrawColRenderSetting("Col Check", showColCheckSetting); + DrawColRenderSetting("Waterbox", showWaterboxSetting); + + ImGui::Checkbox("Apply as decal", &applyAsDecal); + InsertHelpHoverText("Applies the collision as a decal display. This can be useful if there is z-fighting occuring " + "with the scene geometry, but can cause other artifacts."); + ImGui::Checkbox("Shaded", &isShaded); + InsertHelpHoverText("Applies the scene's shading to the collision display."); + + // This has to be duplicated in both code paths due to the nature of ImGui::IsItemHovered() + const std::string colorHelpText = "View and change the colors used for collision display."; + if (ImGui::TreeNode("Colors")) { + InsertHelpHoverText(colorHelpText); + + DrawColorPicker("Normal", sceneColor); + DrawColorPicker("Hookshot", hookshotColor); + DrawColorPicker("Entrance", entranceColor); + DrawColorPicker("Special Surface (Grass/Sand/Etc)", specialSurfaceColor); + DrawColorPicker("Interactable (Vines/Crawlspace/Etc)", interactableColor); + DrawColorPicker("Slope", slopeColor); + DrawColorPicker("Void", voidColor); + DrawColorPicker("OC", ocColor); + DrawColorPicker("AC", acColor); + DrawColorPicker("AT", atColor); + DrawColorPicker("Waterbox", waterboxColor); + + ImGui::TreePop(); + } else { + InsertHelpHoverText(colorHelpText); + } + + ImGui::End(); +} + +// Calculates the normal for a triangle at the 3 specified points +void CalcTriNorm(const Vec3f& v1, const Vec3f& v2, const Vec3f& v3, Vec3f& norm) { + norm.x = (v2.y - v1.y) * (v3.z - v1.z) - (v2.z - v1.z) * (v3.y - v1.y); + norm.y = (v2.z - v1.z) * (v3.x - v1.x) - (v2.x - v1.x) * (v3.z - v1.z); + norm.z = (v2.x - v1.x) * (v3.y - v1.y) - (v2.y - v1.y) * (v3.x - v1.x); + float norm_d = sqrtf(norm.x * norm.x + norm.y * norm.y + norm.z * norm.z); + if (norm_d != 0.f) { + norm.x *= 127.f / norm_d; + norm.y *= 127.f / norm_d; + norm.z *= 127.f / norm_d; + } +} + +// Various macros used for creating verticies and rendering that aren't in gbi.h +#define G_CC_MODULATERGB_PRIM_ENVA PRIMITIVE, 0, SHADE, 0, 0, 0, 0, ENVIRONMENT +#define G_CC_PRIMITIVE_ENVA 0, 0, 0, PRIMITIVE, 0, 0, 0, ENVIRONMENT +#define qs105(n) ((int16_t)((n)*0x0020)) +#define gdSPDefVtxN(x, y, z, s, t, nx, ny, nz, ca) \ + { \ + .n = {.ob = { x, y, z }, .tc = { qs105(s), qs105(t) }, .n = { nx, ny, nz }, .a = ca } \ + } + + +void CreateCylinderData() { + constexpr int32_t CYL_DIVS = 12; + cylinderGfx.reserve(5 + CYL_DIVS * 2); + cylinderVtx.reserve(2 + CYL_DIVS * 2); + + cylinderVtx.push_back(gdSPDefVtxN(0, 0, 0, 0, 0, 0, -127, 0, 0xFF)); // Bottom center vertex + cylinderVtx.push_back(gdSPDefVtxN(0, 128, 0, 0, 0, 0, 127, 0, 0xFF)); // Top center vertex + // Create two rings of vertices + for (int i = 0; i < CYL_DIVS; ++i) { + short vtx_x = floorf(0.5f + cosf(2.f * M_PI * i / CYL_DIVS) * 128.f); + short vtx_z = floorf(0.5f - sinf(2.f * M_PI * i / CYL_DIVS) * 128.f); + signed char norm_x = cosf(2.f * M_PI * i / CYL_DIVS) * 127.f; + signed char norm_z = -sinf(2.f * M_PI * i / CYL_DIVS) * 127.f; + cylinderVtx.push_back(gdSPDefVtxN(vtx_x, 0, vtx_z, 0, 0, norm_x, 0, norm_z, 0xFF)); + cylinderVtx.push_back(gdSPDefVtxN(vtx_x, 128, vtx_z, 0, 0, norm_x, 0, norm_z, 0xFF)); + } + + // Draw edges + cylinderGfx.push_back(gsSPSetGeometryMode(G_CULL_BACK | G_SHADING_SMOOTH)); + cylinderGfx.push_back(gsSPVertex((uintptr_t)cylinderVtx.data(), 2 + CYL_DIVS * 2, 0)); + for (int i = 0; i < CYL_DIVS; ++i) { + int p = (i + CYL_DIVS - 1) % CYL_DIVS; + int v[4] = { + 2 + p * 2 + 0, + 2 + i * 2 + 0, + 2 + i * 2 + 1, + 2 + p * 2 + 1, + }; + cylinderGfx.push_back(gsSP2Triangles(v[0], v[1], v[2], 0, v[0], v[2], v[3], 0)); + } + + // Draw top & bottom + cylinderGfx.push_back(gsSPClearGeometryMode(G_SHADING_SMOOTH)); + for (int i = 0; i < CYL_DIVS; ++i) { + int p = (i + CYL_DIVS - 1) % CYL_DIVS; + int v[4] = { + 2 + p * 2 + 0, + 2 + i * 2 + 0, + 2 + i * 2 + 1, + 2 + p * 2 + 1, + }; + cylinderGfx.push_back(gsSP2Triangles(0, v[1], v[0], 0, 1, v[3], v[2], 0)); + } + + cylinderGfx.push_back(gsSPClearGeometryMode(G_CULL_BACK)); + cylinderGfx.push_back(gsSPEndDisplayList()); +} + +// This subdivides a face into four tris by placing new verticies at the midpoints of the sides (Like a triforce!), then blowing up the +// verticies so they are on the unit sphere +void CreateSphereFace(std::vector>& faces, int32_t v0Index, int32_t v1Index, int32_t v2Index) { + size_t nextIndex = sphereVtx.size(); + + size_t v01Index = nextIndex; + size_t v12Index = nextIndex + 1; + size_t v20Index = nextIndex + 2; + + faces.emplace_back(v0Index, v01Index, v20Index); + faces.emplace_back(v1Index, v12Index, v01Index); + faces.emplace_back(v2Index, v20Index, v12Index); + faces.emplace_back(v01Index, v12Index, v20Index); + + const Vtx& v0 = sphereVtx[v0Index]; + const Vtx& v1 = sphereVtx[v1Index]; + const Vtx& v2 = sphereVtx[v2Index]; + + // Create 3 new verticies at the midpoints + Vec3f vs[3] = { + Vec3f((v0.n.ob[0] + v1.n.ob[0]) / 2.0f, (v0.n.ob[1] + v1.n.ob[1]) / 2.0f, (v0.n.ob[2] + v1.n.ob[2]) / 2.0f), + Vec3f((v1.n.ob[0] + v2.n.ob[0]) / 2.0f, (v1.n.ob[1] + v2.n.ob[1]) / 2.0f, (v1.n.ob[2] + v2.n.ob[2]) / 2.0f), + Vec3f((v2.n.ob[0] + v0.n.ob[0]) / 2.0f, (v2.n.ob[1] + v0.n.ob[1]) / 2.0f, (v2.n.ob[2] + v0.n.ob[2]) / 2.0f) + }; + + // Normalize vertex positions so they are on the sphere + for (int32_t vAddIndex = 0; vAddIndex < 3; vAddIndex++) { + Vec3f& v = vs[vAddIndex]; + float mag = sqrtf(v.x * v.x + v.y * v.y + v.z * v.z); + v.x /= mag; + v.y /= mag; + v.z /= mag; + sphereVtx.push_back(gdSPDefVtxN((short)(v.x * 127), (short)(v.y * 127), (short)(v.z * 127), 0, 0, + (signed char)(v.x * 127), (signed char)(v.y * 127), (signed char)(v.z * 127), + 0xFF)); + } +} + +// Creates a sphere following the idea in here: http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html +// Spcifically, create a icosahedron by realizing that the points can be placed on 3 rectangles that are on each unit plane. +// Then, subdividing each face. +void CreateSphereData() { + std::vector base; + + float d = (1.0f + sqrtf(5.0f)) / 2.0f; + + // Create the 12 starting verticies, 4 on each rectangle + base.emplace_back(-1, d, 0); + base.emplace_back(1, d, 0); + base.emplace_back(-1, -d, 0); + base.emplace_back(1, -d, 0); + + base.emplace_back(0, -1, d); + base.emplace_back(0, 1, d); + base.emplace_back(0, -1, -d); + base.emplace_back(0, 1, -d); + + base.emplace_back(d, 0, -1); + base.emplace_back(d, 0, 1); + base.emplace_back(-d, 0, -1); + base.emplace_back(-d, 0, 1); + + // Normalize verticies so they are on the unit sphere + for (Vec3f& v : base) { + float mag = sqrtf(v.x * v.x + v.y * v.y + v.z * v.z); + v.x /= mag; + v.y /= mag; + v.z /= mag; + sphereVtx.push_back(gdSPDefVtxN((short)(v.x * 128), (short)(v.y * 128), (short)(v.z * 128), 0, 0, + (signed char)(v.x * 127), (signed char)(v.y * 127), (signed char)(v.z * 127), + 0xFF)); + } + + std::vector> faces; + + // Subdivide faces + CreateSphereFace(faces, 0, 11, 5); + CreateSphereFace(faces, 0, 5, 1); + CreateSphereFace(faces, 0, 1, 7); + CreateSphereFace(faces, 0, 7, 10); + CreateSphereFace(faces, 0, 10, 11); + + CreateSphereFace(faces, 1, 5, 9); + CreateSphereFace(faces, 5, 11, 4); + CreateSphereFace(faces, 11, 10, 2); + CreateSphereFace(faces, 10, 7, 6); + CreateSphereFace(faces, 7, 1, 8); + + CreateSphereFace(faces, 3, 9, 4); + CreateSphereFace(faces, 3, 4, 2); + CreateSphereFace(faces, 3, 2, 6); + CreateSphereFace(faces, 3, 6, 8); + CreateSphereFace(faces, 3, 8, 9); + + CreateSphereFace(faces, 4, 9, 5); + CreateSphereFace(faces, 2, 4, 11); + CreateSphereFace(faces, 6, 2, 10); + CreateSphereFace(faces, 8, 6, 7); + CreateSphereFace(faces, 9, 8, 1); + + size_t vtxStartIndex = sphereVtx.size(); + sphereVtx.reserve(sphereVtx.size() + faces.size() * 3); + for (int32_t faceIndex = 0; faceIndex < faces.size(); faceIndex++) { + sphereVtx.push_back(sphereVtx[std::get<0>(faces[faceIndex])]); + sphereVtx.push_back(sphereVtx[std::get<1>(faces[faceIndex])]); + sphereVtx.push_back(sphereVtx[std::get<2>(faces[faceIndex])]); + sphereGfx.push_back(gsSPVertex((uintptr_t)(sphereVtx.data() + vtxStartIndex + faceIndex * 3), 3, 0)); + sphereGfx.push_back(gsSP1Triangle(0, 1, 2, 0)); + } + + sphereGfx.push_back(gsSPEndDisplayList()); +} + +void InitColViewer() { + SohImGui::AddWindow("Developer Tools", "Collision Viewer", DrawColViewerWindow); + + CreateCylinderData(); + CreateSphereData(); +} + +// Initializes the display list for a ColRenderSetting +void InitGfx(std::vector& gfx, ColRenderSetting setting) { + uint32_t rm; + uint32_t blc1; + uint32_t blc2; + uint8_t alpha; + uint64_t cm; + uint32_t gm; + + if (setting == ColRenderSetting::Transparent) { + rm = Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL; + blc1 = GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA); + blc2 = GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA); + alpha = 0x80; + } else { + rm = Z_CMP | Z_UPD | CVG_DST_CLAMP | FORCE_BL; + blc1 = GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1); + blc2 = GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1); + alpha = 0xFF; + } + + if (applyAsDecal) { + rm |= ZMODE_DEC; + } else if (setting == ColRenderSetting::Transparent) { + rm |= ZMODE_XLU; + } else { + rm |= ZMODE_OPA; + } + + gfx.push_back(gsSPTexture(0, 0, 0, G_TX_RENDERTILE, G_OFF)); + gfx.push_back(gsDPSetCycleType(G_CYC_1CYCLE)); + gfx.push_back(gsDPSetRenderMode(rm | blc1, rm | blc2)); + + if (isShaded) { + gfx.push_back(gsDPSetCombineMode(G_CC_MODULATERGB_PRIM_ENVA, G_CC_MODULATERGB_PRIM_ENVA)); + gfx.push_back(gsSPLoadGeometryMode(G_CULL_BACK | G_ZBUFFER | G_LIGHTING)); + } else { + gfx.push_back(gsDPSetCombineMode(G_CC_PRIMITIVE_ENVA, G_CC_PRIMITIVE_ENVA)); + gfx.push_back(gsSPLoadGeometryMode(G_ZBUFFER)); + } + + gfx.push_back(gsDPSetEnvColor(0xFF, 0xFF, 0xFF, alpha)); +} + +// Draws a dynapoly structure (scenes or Bg Actors) +void DrawDynapoly(std::vector& dl, CollisionHeader* col, int32_t bgId) { + uint32_t color = sceneColor; + uint32_t lastColor = color; + dl.push_back(gsDPSetPrimColor(0, 0, (color >> 24) & 0xFF, (color >> 16) & 0xFF, (color >> 8) & 0xFF, + (color >> 0) & 0xFF)); + + // This keeps track of if we have processed a poly, but not drawn it yet so we can batch them. + // This saves several hundred commands in larger scenes + bool previousPoly = false; + + for (int i = 0; i < col->numPolygons; i++) { + CollisionPoly* poly = &col->polyList[i]; + + if (SurfaceType_IsHookshotSurface(&gGlobalCtx->colCtx, poly, bgId)) { + color = hookshotColor; + } else if (func_80041D94(&gGlobalCtx->colCtx, poly, bgId) > 0x01) { + color = interactableColor; + } else if (func_80041E80(&gGlobalCtx->colCtx, poly, bgId) == 0x0C) { + color = voidColor; + } else if (SurfaceType_GetSceneExitIndex(&gGlobalCtx->colCtx, poly, bgId) || + func_80041E80(&gGlobalCtx->colCtx, poly, bgId) == 0x05) { + color = entranceColor; + } else if (func_80041D4C(&gGlobalCtx->colCtx, poly, bgId) != 0 || + SurfaceType_IsWallDamage(&gGlobalCtx->colCtx, poly, bgId)) { + color = specialSurfaceColor; + } else if (SurfaceType_GetSlope(&gGlobalCtx->colCtx, poly, bgId) == 0x01) { + color = slopeColor; + } else { + color = sceneColor; + } + + if (lastColor != color) { + // Color changed, flush previous poly + if (previousPoly) { + dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 3), 3, 0)); + dl.push_back(gsSP1Triangle(0, 1, 2, 0)); + previousPoly = false; + } + dl.push_back(gsDPSetPrimColor(0, 0, (color >> 24) & 0xFF, (color >> 16) & 0xFF, (color >> 8) & 0xFF, + (color >> 0) & 0xFF)); + } + lastColor = color; + + Vec3s* va = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)]; + Vec3s* vb = &col->vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)]; + Vec3s* vc = &col->vtxList[COLPOLY_VTX_INDEX(poly->vIC)]; + vtxDl.push_back(gdSPDefVtxN(va->x, va->y, va->z, 0, 0, (signed char)(poly->normal.x / 0x100), + (signed char)(poly->normal.y / 0x100), (signed char)(poly->normal.z / 0x100), + 0xFF)); + vtxDl.push_back(gdSPDefVtxN(vb->x, vb->y, vb->z, 0, 0, (signed char)(poly->normal.x / 0x100), + (signed char)(poly->normal.y / 0x100), (signed char)(poly->normal.z / 0x100), + 0xFF)); + vtxDl.push_back(gdSPDefVtxN(vc->x, vc->y, vc->z, 0, 0, (signed char)(poly->normal.x / 0x100), + (signed char)(poly->normal.y / 0x100), (signed char)(poly->normal.z / 0x100), + 0xFF)); + + if (previousPoly) { + dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 6), 6, 0)); + dl.push_back(gsSP2Triangles(0, 1, 2, 0, 3, 4, 5, 0)); + previousPoly = false; + } else { + previousPoly = true; + } + } + + // Flush previous poly if this is the end and there's no more coming + if (previousPoly) { + dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 3), 3, 0)); + dl.push_back(gsSP1Triangle(0, 1, 2, 0)); + previousPoly = false; + } +} + +// Draws the scene +void DrawSceneCollision() { + if (showSceneColSetting == ColRenderSetting::Disabled) { + return; + } + + std::vector& dl = (showSceneColSetting == ColRenderSetting::Transparent) ? xluDl : opaDl; + InitGfx(dl, showSceneColSetting); + dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); + + DrawDynapoly(dl, gGlobalCtx->colCtx.colHeader, BGCHECK_SCENE); +} + +// Draws all Bg Actors +void DrawBgActorCollision() { + if (showBgActorSetting == ColRenderSetting::Disabled) { + return; + } + + std::vector& dl = (showBgActorSetting == ColRenderSetting::Transparent) ? xluDl : opaDl; + InitGfx(dl, showBgActorSetting); + dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); + + for (int32_t bgIndex = 0; bgIndex < BG_ACTOR_MAX; bgIndex++) { + if (gGlobalCtx->colCtx.dyna.bgActorFlags[bgIndex] & 1) { + BgActor& bg = gGlobalCtx->colCtx.dyna.bgActors[bgIndex]; + Mtx m; + MtxF mf; + SkinMatrix_SetTranslateRotateYXZScale(&mf, bg.curTransform.scale.x, bg.curTransform.scale.y, + bg.curTransform.scale.z, bg.curTransform.rot.x, bg.curTransform.rot.y, + bg.curTransform.rot.z, bg.curTransform.pos.x, bg.curTransform.pos.y, + bg.curTransform.pos.z); + guMtxF2L(&mf, &m); + mtxDl.push_back(m); + dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); + + DrawDynapoly(dl, bg.colHeader, bgIndex); + + dl.push_back(gsSPPopMatrix(G_MTX_MODELVIEW)); + } + } + +} + +// Draws a quad +void DrawQuad(std::vector& dl, Vec3f& v0, Vec3f& v1, Vec3f& v2, Vec3f& v3) { + Vec3f norm; + CalcTriNorm(v0, v1, v2, norm); + + vtxDl.push_back(gdSPDefVtxN((short)v0.x, (short)v0.y, (short)v0.z, 0, 0, (signed char)norm.x, (signed char)norm.y, + (signed char)norm.z, 0xFF)); + vtxDl.push_back(gdSPDefVtxN((short)v1.x, (short)v1.y, (short)v1.z, 0, 0, (signed char)norm.x, (signed char)norm.y, + (signed char)norm.z, 0xFF)); + vtxDl.push_back(gdSPDefVtxN((short)v2.x, (short)v2.y, (short)v2.z, 0, 0, (signed char)norm.x, (signed char)norm.y, + (signed char)norm.z, 0xFF)); + vtxDl.push_back(gdSPDefVtxN((short)v3.x, (short)v3.y, (short)v3.z, 0, 0, (signed char)norm.x, (signed char)norm.y, + (signed char)norm.z, 0xFF)); + dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 4), 4, 0)); + dl.push_back(gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0)); +} + +// Draws a list of Col Check objects +void DrawColCheckList(std::vector& dl, Collider** objects, int32_t count) { + for (int32_t colIndex = 0; colIndex < count; colIndex++) { + Collider* col = objects[colIndex]; + switch (col->shape) { + case COLSHAPE_JNTSPH: { + ColliderJntSph* jntSph = (ColliderJntSph*)col; + + for (int32_t sphereIndex = 0; sphereIndex < jntSph->count; sphereIndex++) { + ColliderJntSphElement* sph = &jntSph->elements[sphereIndex]; + + Mtx m; + MtxF mf; + SkinMatrix_SetTranslate(&mf, sph->dim.worldSphere.center.x, sph->dim.worldSphere.center.y, + sph->dim.worldSphere.center.z); + MtxF ms; + int32_t radius = sph->dim.worldSphere.radius == 0 ? 1 : sph->dim.worldSphere.radius; + SkinMatrix_SetScale(&ms, radius / 128.0f, radius / 128.0f, radius / 128.0f); + MtxF dest; + SkinMatrix_MtxFMtxFMult(&mf, &ms, &dest); + guMtxF2L(&dest, &m); + mtxDl.push_back(m); + + dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); + dl.push_back(gsSPDisplayList(sphereGfx.data())); + dl.push_back(gsSPPopMatrix(G_MTX_MODELVIEW)); + } + } break; + case COLSHAPE_CYLINDER: { + ColliderCylinder* cyl = (ColliderCylinder*)col; + + Mtx m; + MtxF mt; + SkinMatrix_SetTranslate(&mt, cyl->dim.pos.x, cyl->dim.pos.y, cyl->dim.pos.z); + MtxF ms; + int32_t radius = cyl->dim.radius == 0 ? 1 : cyl->dim.radius; + SkinMatrix_SetScale(&ms, radius / 128.0f, cyl->dim.height / 128.0f, radius / 128.0f); + MtxF dest; + SkinMatrix_MtxFMtxFMult(&mt, &ms, &dest); + guMtxF2L(&dest, &m); + mtxDl.push_back(m); + + dl.push_back(gsSPMatrix(&mtxDl.back(), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH)); + dl.push_back(gsSPDisplayList(cylinderGfx.data())); + dl.push_back(gsSPPopMatrix(G_MTX_MODELVIEW)); + } break; + case COLSHAPE_TRIS: { + ColliderTris* tris = (ColliderTris*)col; + for (int32_t triIndex = 0; triIndex < tris->count; triIndex++) { + ColliderTrisElement* tri = &tris->elements[triIndex]; + + vtxDl.push_back(gdSPDefVtxN((short)tri->dim.vtx[0].x, (short)tri->dim.vtx[0].y, + (short)tri->dim.vtx[0].z, 0, 0, (signed char)tri->dim.plane.normal.x, + (signed char)tri->dim.plane.normal.y, + (signed char)tri->dim.plane.normal.z, 0xFF)); + vtxDl.push_back(gdSPDefVtxN((short)tri->dim.vtx[1].x, (short)tri->dim.vtx[1].y, + (short)tri->dim.vtx[1].z, 0, 0, (signed char)tri->dim.plane.normal.x, + (signed char)tri->dim.plane.normal.y, + (signed char)tri->dim.plane.normal.z, 0xFF)); + vtxDl.push_back(gdSPDefVtxN((short)tri->dim.vtx[2].x, (short)tri->dim.vtx[2].y, + (short)tri->dim.vtx[2].z, 0, 0, (signed char)tri->dim.plane.normal.x, + (signed char)tri->dim.plane.normal.y, + (signed char)tri->dim.plane.normal.z, 0xFF)); + dl.push_back(gsSPVertex((uintptr_t)&vtxDl.at(vtxDl.size() - 3), 3, 0)); + dl.push_back(gsSP1Triangle(0, 1, 2, 0)); + } + } break; + case COLSHAPE_QUAD: { + ColliderQuad* quad = (ColliderQuad*)col; + DrawQuad(dl, quad->dim.quad[0], quad->dim.quad[2], quad->dim.quad[3], quad->dim.quad[1]); + } break; + default: + break; + } + } +} + +// Draws all Col Check objects +void DrawColCheckCollision() { + if (showColCheckSetting == ColRenderSetting::Disabled) { + return; + } + + std::vector& dl = (showColCheckSetting == ColRenderSetting::Transparent) ? xluDl : opaDl; + InitGfx(dl, showColCheckSetting); + dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); + + CollisionCheckContext& col = gGlobalCtx->colChkCtx; + + dl.push_back(gsDPSetPrimColor(0, 0, (ocColor >> 24) & 0xFF, (ocColor >> 16) & 0xFF, (ocColor >> 8) & 0xFF, + (ocColor >> 0) & 0xFF)); + DrawColCheckList(dl, col.colOC, col.colOCCount); + + dl.push_back(gsDPSetPrimColor(0, 0, (acColor >> 24) & 0xFF, (acColor >> 16) & 0xFF, (acColor >> 8) & 0xFF, + (acColor >> 0) & 0xFF)); + DrawColCheckList(dl, col.colAC, col.colACCount); + + dl.push_back(gsDPSetPrimColor(0, 0, (atColor >> 24) & 0xFF, (atColor >> 16) & 0xFF, (atColor >> 8) & 0xFF, + (atColor >> 0) & 0xFF)); + DrawColCheckList(dl, col.colAT, col.colATCount); +} + +// Draws a waterbox +void DrawWaterbox(std::vector& dl, WaterBox* water, float water_max_depth = -4000.0f) { + // Skip waterboxes that would be disabled in current room + int32_t room = ((water->properties >> 13) & 0x3F); + if ((room != gGlobalCtx->roomCtx.curRoom.num) && (room != 0x3F)) { + return; + } + + Vec3f vtx[] = { + { water->xMin, water->ySurface, water->zMin + water->zLength }, + { water->xMin + water->xLength, water->ySurface, water->zMin + water->zLength }, + { water->xMin + water->xLength, water->ySurface, water->zMin }, + { water->xMin, water->ySurface, water->zMin }, + { water->xMin, water_max_depth, water->zMin + water->zLength }, + { water->xMin + water->xLength, water_max_depth, water->zMin + water->zLength }, + { water->xMin + water->xLength, water_max_depth, water->zMin }, + { water->xMin, water_max_depth, water->zMin }, + }; + DrawQuad(dl, vtx[0], vtx[1], vtx[2], vtx[3]); + DrawQuad(dl, vtx[0], vtx[3], vtx[7], vtx[4]); + DrawQuad(dl, vtx[1], vtx[0], vtx[4], vtx[5]); + DrawQuad(dl, vtx[2], vtx[1], vtx[5], vtx[6]); + DrawQuad(dl, vtx[3], vtx[2], vtx[6], vtx[7]); +} + +extern "C" WaterBox zdWaterBox; +extern "C" f32 zdWaterBoxMinY; + +// Draws all waterboxes +void DrawWaterboxList() { + if (showWaterboxSetting == ColRenderSetting::Disabled) { + return; + } + + std::vector& dl = (showWaterboxSetting == ColRenderSetting::Transparent) ? xluDl : opaDl; + InitGfx(dl, showWaterboxSetting); + dl.push_back(gsSPMatrix(&gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); + dl.push_back(gsDPSetPrimColor(0, 0, (waterboxColor >> 24) & 0xFF, (waterboxColor >> 16) & 0xFF, + (waterboxColor >> 8) & 0xFF, (waterboxColor >> 0) & 0xFF)); + + CollisionHeader* col = gGlobalCtx->colCtx.colHeader; + for (int32_t waterboxIndex = 0; waterboxIndex < col->numWaterBoxes; waterboxIndex++) { + WaterBox* water = &col->waterBoxes[waterboxIndex]; + DrawWaterbox(dl, water); + } + + // Zora's Domain has a special, hard-coded waterbox with a bottom so you can go under the waterfall + if (gGlobalCtx->sceneNum == SCENE_SPOT07) { + DrawWaterbox(dl, &zdWaterBox, zdWaterBoxMinY); + } +} + +// Resets a vector for the next frame and returns the capacity +template +size_t ResetVector(T& vec) { + size_t oldSize = vec.size(); + vec.clear(); + // Reserve slightly more space than last frame to account for variance (such as different amounts of bg actors) + vec.reserve(oldSize * 1.2); + return vec.capacity(); +} + +void DrawColViewer() { + if (gGlobalCtx == nullptr) { + return; + } + + ResetVector(opaDl); + ResetVector(xluDl); + size_t vtxDlCapacity = ResetVector(vtxDl); + size_t mtxDlCapacity = ResetVector(mtxDl); + + DrawSceneCollision(); + DrawBgActorCollision(); + DrawColCheckCollision(); + DrawWaterboxList(); + + // Check if we used up more space than we reserved. If so, redo the drawing with our new sizes. + // This is because we resized the vectors while drawing, invalidating pointers to them. + // This only matters for the Vtx and Mtx vectors. + if ((vtxDl.size() > vtxDlCapacity) || (mtxDl.size() > mtxDlCapacity)) { + ResetVector(opaDl); + ResetVector(xluDl); + vtxDlCapacity = ResetVector(vtxDl); + mtxDlCapacity = ResetVector(mtxDl); + + DrawSceneCollision(); + DrawBgActorCollision(); + DrawColCheckCollision(); + DrawWaterboxList(); + } + + if ((vtxDl.size() > vtxDlCapacity) || (mtxDl.size() > mtxDlCapacity)) { + // If the sizes somehow changed between the two draws, we can't continue because we may be using invalid data + printf("Error drawing collision, vertex/matrix sizes didn't settle.\n"); + return; + } + + OPEN_DISPS(gGlobalCtx->state.gfxCtx, "", 0); + + opaDl.push_back(gsSPEndDisplayList()); + gSPDisplayList(POLY_OPA_DISP++, opaDl.data()); + + xluDl.push_back(gsSPEndDisplayList()); + gSPDisplayList(POLY_XLU_DISP++, xluDl.data()); + + CLOSE_DISPS(gGlobalCtx->state.gfxCtx, "", 0); +} diff --git a/soh/soh/Enhancements/debugger/colViewer.h b/soh/soh/Enhancements/debugger/colViewer.h new file mode 100644 index 000000000..e38da7951 --- /dev/null +++ b/soh/soh/Enhancements/debugger/colViewer.h @@ -0,0 +1,4 @@ +#pragma once + +void InitColViewer(); +void DrawColViewer(); \ No newline at end of file diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 2aaac5a1b..ca1b67798 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -1,6 +1,7 @@ #include "debugSaveEditor.h" #include "../../util.h" #include "../libultraship/SohImGuiImpl.h" +#include "ImGuiHelpers.h" #include #include @@ -224,26 +225,6 @@ std::array songMapping = { { SONG_MAP_ENTRY(QUEST_SONG_PRELUDE, 255, 240, 100), } }; -// Adds a text tooltip for the previous ImGui item -void SetLastItemHoverText(const std::string& text) { - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text(text.c_str()); - ImGui::EndTooltip(); - } -} - -// Adds a "?" next to the previous ImGui item with a custom tooltip -void InsertHelpHoverText(const std::string& text) { - ImGui::SameLine(); - ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::Text(text.c_str()); - ImGui::EndTooltip(); - } -} - // Encapsulates what is drawn by the passed-in function within a border template void DrawGroupWithBorder(T&& drawFunc) { @@ -270,15 +251,31 @@ void DrawGroupWithBorder(T&& drawFunc) { ImGui::EndGroup(); } +char z2ASCII(int code) { + int ret; + if (code < 10) { //Digits + ret = code + 0x30; + } else if (code >= 10 && code < 36) { //Uppercase letters + ret = code + 0x37; + } else if (code >= 36 && code < 62) { //Lowercase letters + ret = code + 0x3D; + } else if (code == 62) { //Space + ret = code - 0x1E; + } else if (code == 63 || code == 64) { // _ and . + ret = code - 0x12; + } else { + ret = code; + } + return char(ret); + +} + void DrawInfoTab() { - // TODO This is the bare minimum to get the player name showing - // There will need to be more effort to get it robust and editable + // TODO Needs a better method for name changing but for now this will work. std::string name; + ImU16 one = 1; for (int i = 0; i < 8; i++) { - char letter = gSaveContext.playerName[i] + 0x3D; - if (letter == '{') { - letter = '\0'; - } + char letter = z2ASCII(gSaveContext.playerName[i]); name += letter; } name += '\0'; @@ -287,6 +284,14 @@ void DrawInfoTab() { ImGui::Text("Name: %s", name.c_str()); InsertHelpHoverText("Player Name"); + std::string nameID; + for (int i = 0; i < 8; i++) { + nameID = z2ASCII(i); + if (i % 4 != 0) { + ImGui::SameLine(); + } + ImGui::InputScalar(nameID.c_str(), ImGuiDataType_U8, &gSaveContext.playerName[i], &one, NULL); + } // Use an intermediary to keep the health from updating (and potentially killing the player) // until it is done being edited @@ -396,21 +401,101 @@ void DrawInfoTab() { ImGui::InputScalar("Bgs Day Count", ImGuiDataType_S32, &gSaveContext.bgsDayCount); InsertHelpHoverText("Total number of days elapsed since giving Biggoron the claim check"); - // TODO Changing Link's age is more involved than just setting gSaveContext.linkAge - // It might not fit here and instead should be only changable when changing scenes - /* - if (ImGui::BeginCombo("Link Age", LINK_IS_ADULT ? "Adult" : "Child")) { - if (ImGui::Selectable("Adult")) { - gSaveContext.linkAge = 0; + ImGui::InputScalar("Entrance Index", ImGuiDataType_S32, &gSaveContext.entranceIndex); + InsertHelpHoverText("From which entrance did Link arrive?"); + + ImGui::InputScalar("Cutscene Index", ImGuiDataType_S32, &gSaveContext.cutsceneIndex); + InsertHelpHoverText("Which cutscene is this?"); + + ImGui::InputScalar("Navi Timer", ImGuiDataType_U16, &gSaveContext.naviTimer); + InsertHelpHoverText("Navi wants to talk at 600 units, decides not to at 3000."); + + ImGui::InputScalar("Timer 1 State", ImGuiDataType_S16, &gSaveContext.timer1State); + InsertHelpHoverText("Heat timer, race timer, etc. Has white font"); + + ImGui::InputScalar("Timer 1 Value", ImGuiDataType_S16, &gSaveContext.timer1Value, &one, NULL); + InsertHelpHoverText("Time, in seconds"); + + ImGui::InputScalar("Timer 2 State", ImGuiDataType_S16, &gSaveContext.timer2State); + InsertHelpHoverText("Trade timer, Ganon collapse timer, etc. Has yellow font"); + + ImGui::InputScalar("Timer 2 Value", ImGuiDataType_S16, &gSaveContext.timer2Value, &one, NULL); + InsertHelpHoverText("Time, in seconds"); + + const char* audioName; + switch (gSaveContext.audioSetting) { + case 0: + audioName = "Stereo"; + break; + case 1: + audioName = "Mono"; + break; + case 2: + audioName = "Headset"; + break; + case 3: + audioName = "Surround"; + break; + default: + audioName = "?"; + } + if (ImGui::BeginCombo("Audio", audioName)) { + if (ImGui::Selectable("Stereo")) { + gSaveContext.audioSetting = 0; } - if (ImGui::Selectable("Child")) { - gSaveContext.linkAge = 1; + if (ImGui::Selectable("Mono")) { + gSaveContext.audioSetting = 1; + } + if (ImGui::Selectable("Headset")) { + gSaveContext.audioSetting = 2; + } + if (ImGui::Selectable("Surround")) { + gSaveContext.audioSetting = 3; } ImGui::EndCombo(); } - */ + InsertHelpHoverText("Sound setting"); + + bool n64DDFlag = gSaveContext.n64ddFlag != 0; + if (ImGui::Checkbox("64 DD file?", &n64DDFlag)) { + gSaveContext.n64ddFlag = n64DDFlag; + } + InsertHelpHoverText("WARNING! If you save, your file may be locked! Use caution!"); + + if (ImGui::BeginCombo("Z Target Mode", gSaveContext.zTargetSetting ? "Hold" : "Switch")) { + if (ImGui::Selectable("Switch")) { + gSaveContext.zTargetSetting = 0; + } + if (ImGui::Selectable("Hold")) { + gSaveContext.zTargetSetting = 1; + } + ImGui::EndCombo(); + } + InsertHelpHoverText("Z-Targeting behavior"); + + ImGui::PushItemWidth(ImGui::GetFontSize() * 10); + static std::array minigameHS = { "Horseback Archery", + "Big Poe Points", + "Fishing", + "Malon's Obstacle Course", + "Running Man Race", + "?", + "Dampe's Race" }; + + if (ImGui::TreeNode("Minigames")) { + for (int i = 0; i < 7; i++) { + if (i == 5) { //HS_UNK_05 is unused + continue; + } + std::string minigameLbl = minigameHS[i]; + ImGui::InputScalar(minigameLbl.c_str(), ImGuiDataType_S32, &gSaveContext.highScores[i], &one, NULL); + } + + ImGui::TreePop(); + } + ImGui::PopItemWidth(); } @@ -524,7 +609,7 @@ void DrawInventoryTab() { } // Draw a flag bitfield as an grid of checkboxes -void DrawFlagArray(const std::string& name, uint32_t& flags) { +void DrawFlagArray32(const std::string& name, uint32_t& flags) { ImGui::PushID(name.c_str()); for (int32_t flagIndex = 0; flagIndex < 32; flagIndex++) { if ((flagIndex % 8) != 0) { @@ -545,6 +630,25 @@ void DrawFlagArray(const std::string& name, uint32_t& flags) { ImGui::PopID(); } +void DrawFlagArray16(const std::string& name, uint16_t& flags) { + ImGui::PushID(name.c_str()); + for (int32_t flagIndex = 15; flagIndex >= 0; flagIndex--) { + ImGui::SameLine(); + ImGui::PushID(flagIndex); + uint32_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); +} + void DrawFlagsTab() { if (ImGui::TreeNode("Current Scene")) { if (gGlobalCtx != nullptr) { @@ -553,7 +657,7 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Switch"); InsertHelpHoverText("Permanently-saved switch flags"); - DrawFlagArray("Switch", act->flags.swch); + DrawFlagArray32("Switch", act->flags.swch); }); ImGui::SameLine(); @@ -561,13 +665,13 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Temp Switch"); InsertHelpHoverText("Temporary switch flags. Unset on scene transitions"); - DrawFlagArray("Temp Switch", act->flags.tempSwch); + DrawFlagArray32("Temp Switch", act->flags.tempSwch); }); DrawGroupWithBorder([&]() { ImGui::Text("Clear"); InsertHelpHoverText("Permanently-saved room-clear flags"); - DrawFlagArray("Clear", act->flags.clear); + DrawFlagArray32("Clear", act->flags.clear); }); ImGui::SameLine(); @@ -575,13 +679,13 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Temp Clear"); InsertHelpHoverText("Temporary room-clear flags. Unset on scene transitions"); - DrawFlagArray("Temp Clear", act->flags.tempClear); + DrawFlagArray32("Temp Clear", act->flags.tempClear); }); DrawGroupWithBorder([&]() { ImGui::Text("Collect"); InsertHelpHoverText("Permanently-saved collect flags"); - DrawFlagArray("Collect", act->flags.collect); + DrawFlagArray32("Collect", act->flags.collect); }); ImGui::SameLine(); @@ -589,13 +693,13 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Temp Collect"); InsertHelpHoverText("Temporary collect flags. Unset on scene transitions"); - DrawFlagArray("Temp Collect", act->flags.tempCollect); + DrawFlagArray32("Temp Collect", act->flags.tempCollect); }); DrawGroupWithBorder([&]() { ImGui::Text("Chest"); InsertHelpHoverText("Permanently-saved chest flags"); - DrawFlagArray("Chest", act->flags.chest); + DrawFlagArray32("Chest", act->flags.chest); }); ImGui::SameLine(); @@ -652,7 +756,7 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Switch"); InsertHelpHoverText("Switch flags"); - DrawFlagArray("Switch", gSaveContext.sceneFlags[selectedSceneFlagMap].swch); + DrawFlagArray32("Switch", gSaveContext.sceneFlags[selectedSceneFlagMap].swch); }); ImGui::SameLine(); @@ -660,13 +764,13 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Clear"); InsertHelpHoverText("Room-clear flags"); - DrawFlagArray("Clear", gSaveContext.sceneFlags[selectedSceneFlagMap].clear); + DrawFlagArray32("Clear", gSaveContext.sceneFlags[selectedSceneFlagMap].clear); }); DrawGroupWithBorder([&]() { ImGui::Text("Collect"); InsertHelpHoverText("Collect flags"); - DrawFlagArray("Collect", gSaveContext.sceneFlags[selectedSceneFlagMap].collect); + DrawFlagArray32("Collect", gSaveContext.sceneFlags[selectedSceneFlagMap].collect); }); ImGui::SameLine(); @@ -674,13 +778,13 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Chest"); InsertHelpHoverText("Chest flags"); - DrawFlagArray("Chest", gSaveContext.sceneFlags[selectedSceneFlagMap].chest); + DrawFlagArray32("Chest", gSaveContext.sceneFlags[selectedSceneFlagMap].chest); }); DrawGroupWithBorder([&]() { ImGui::Text("Rooms"); InsertHelpHoverText("Flags for visted rooms"); - DrawFlagArray("Rooms", gSaveContext.sceneFlags[selectedSceneFlagMap].rooms); + DrawFlagArray32("Rooms", gSaveContext.sceneFlags[selectedSceneFlagMap].rooms); }); ImGui::SameLine(); @@ -688,7 +792,7 @@ void DrawFlagsTab() { DrawGroupWithBorder([&]() { ImGui::Text("Floors"); InsertHelpHoverText("Flags for visted floors"); - DrawFlagArray("Floors", gSaveContext.sceneFlags[selectedSceneFlagMap].floors); + DrawFlagArray32("Floors", gSaveContext.sceneFlags[selectedSceneFlagMap].floors); }); ImGui::TreePop(); @@ -749,6 +853,124 @@ void DrawFlagsTab() { gSaveContext.inventory.gsTokens = gsCount; } }); + + if (ImGui::TreeNode("Event Check Inf Flags")) { + DrawGroupWithBorder([&]() { + ImGui::Text("0"); + InsertHelpHoverText("Mostly Kokiri Forest related"); + DrawFlagArray16("eci0", gSaveContext.eventChkInf[0]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("1"); + InsertHelpHoverText("Mostly Lon Lon Ranch related"); + DrawFlagArray16("eci1", gSaveContext.eventChkInf[1]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("2"); + InsertHelpHoverText("Dodongo Related?"); + DrawFlagArray16("eci2", gSaveContext.eventChkInf[2]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("3"); + InsertHelpHoverText("Mostly Zora related"); + DrawFlagArray16("eci3", gSaveContext.eventChkInf[3]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("4"); + InsertHelpHoverText("Random"); + DrawFlagArray16("eci4", gSaveContext.eventChkInf[4]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("5"); + InsertHelpHoverText("Mostly song learning related"); + DrawFlagArray16("eci5", gSaveContext.eventChkInf[5]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("6"); + InsertHelpHoverText("Random"); + DrawFlagArray16("eci6", gSaveContext.eventChkInf[6]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("7"); + InsertHelpHoverText("Boss Battle related"); + DrawFlagArray16("eci7", gSaveContext.eventChkInf[7]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("8"); + InsertHelpHoverText("Mask related?"); + DrawFlagArray16("eci8", gSaveContext.eventChkInf[8]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("9"); + InsertHelpHoverText("Mostly carpenter related"); + DrawFlagArray16("eci9", gSaveContext.eventChkInf[9]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("A"); + InsertHelpHoverText("First-time overworld entrance cs related"); + DrawFlagArray16("eci1", gSaveContext.eventChkInf[10]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("B"); + InsertHelpHoverText("First-time dungeon entrance cs/trial cs related"); + DrawFlagArray16("eci11", gSaveContext.eventChkInf[11]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("C"); + InsertHelpHoverText("Random"); + DrawFlagArray16("eci12", gSaveContext.eventChkInf[12]); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("D"); + InsertHelpHoverText("Frog songs/GS rewards"); + DrawFlagArray16("eci13", gSaveContext.eventChkInf[13]); + }); + + ImGui::TreePop(); + } + if (ImGui::TreeNode("Inf Table Flags")) { + for (int i = 0; i < 30; i++) { + std::string it_id = "it" + std::to_string(i); + DrawGroupWithBorder([&]() { + ImGui::Text("%2d", i); + DrawFlagArray16(it_id, gSaveContext.infTable[i]); + }); + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Item Get Inf Flags")) { + for (int i = 0; i < 4; i++) { + std::string igi_id = "igi" + std::to_string(i); + DrawGroupWithBorder([&]() { + ImGui::Text("%d", i); + DrawFlagArray16(igi_id, gSaveContext.itemGetInf[i]); + }); + } + ImGui::TreePop(); + } + if (ImGui::TreeNode("Event Inf Flags")) { + for (int i = 0; i < 4; i++) { + std::string ei_id = "ei" + std::to_string(i); + DrawGroupWithBorder([&]() { + ImGui::Text("%d", i); + DrawFlagArray16(ei_id, gSaveContext.eventInf[i]); + }); + } + ImGui::TreePop(); + } } // Draws a combo that lets you choose and upgrade value from a drop-down of text values @@ -1076,13 +1298,249 @@ void DrawQuestStatusTab() { ImGui::PopItemWidth(); } +void DrawPlayerTab() { + if (gGlobalCtx != nullptr) { + Player* player = GET_PLAYER(gGlobalCtx); + const char* curSword; + const char* curShield; + const char* curTunic; + const char* curBoots; + + switch (player->currentSwordItem) { + case ITEM_SWORD_KOKIRI: + curSword = "Kokiri Sword"; + break; + case ITEM_SWORD_MASTER: + curSword = "Master Sword"; + break; + case ITEM_SWORD_BGS: + curSword = "Biggoron's Sword"; + break; + case ITEM_NONE: + curSword = "None"; + break; + default: + curSword = "None"; + break; + } + + switch (player->currentShield) { + case PLAYER_SHIELD_NONE: + curShield = "None"; + break; + case PLAYER_SHIELD_DEKU: + curShield = "Deku Shield"; + break; + case PLAYER_SHIELD_HYLIAN: + curShield = "Hylian Shield"; + break; + case PLAYER_SHIELD_MIRROR: + curShield = "Mirror Shield"; + break; + default: + break; + } + + switch (player->currentTunic) { + case PLAYER_TUNIC_KOKIRI: + curTunic = "Kokiri Tunic"; + break; + case PLAYER_TUNIC_GORON: + curTunic = "Goron Tunic"; + break; + case PLAYER_TUNIC_ZORA: + curTunic = "Zora Tunic"; + break; + default: + break; + } + + switch (player->currentBoots) { + case PLAYER_BOOTS_KOKIRI: + curBoots = "Kokiri Boots"; + break; + case PLAYER_BOOTS_IRON: + curBoots = "Iron Boots"; + break; + case PLAYER_BOOTS_HOVER: + curBoots = "Hover Boots"; + break; + default: + break; + } + + ImGui::PushItemWidth(ImGui::GetFontSize() * 6); + DrawGroupWithBorder([&]() { + ImGui::Text("Link's Position"); + ImGui::InputScalar("X Pos", ImGuiDataType_Float, &player->actor.world.pos.x); + ImGui::SameLine(); + ImGui::InputScalar("Y Pos", ImGuiDataType_Float, &player->actor.world.pos.y); + ImGui::SameLine(); + ImGui::InputScalar("Z Pos", ImGuiDataType_Float, &player->actor.world.pos.z); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("Link's Rotation"); + InsertHelpHoverText("For Link's rotation in relation to the world"); + ImGui::InputScalar("X Rot", ImGuiDataType_S16, &player->actor.world.rot.x); + ImGui::SameLine(); + ImGui::InputScalar("Y Rot", ImGuiDataType_S16, &player->actor.world.rot.y); + ImGui::SameLine(); + ImGui::InputScalar("Z Rot", ImGuiDataType_S16, &player->actor.world.rot.z); + }); + + DrawGroupWithBorder([&]() { + ImGui::Text("Link's Model Rotation"); + InsertHelpHoverText("For Link's actual model"); + ImGui::InputScalar("X ModRot", ImGuiDataType_S16, &player->actor.shape.rot.x); + ImGui::SameLine(); + ImGui::InputScalar("Y ModRot", ImGuiDataType_S16, &player->actor.shape.rot.y); + ImGui::SameLine(); + ImGui::InputScalar("Z ModRot", ImGuiDataType_S16, &player->actor.shape.rot.z); + }); + + ImGui::InputScalar("Linear Velocity", ImGuiDataType_Float, &player->linearVelocity); + InsertHelpHoverText("Link's speed along the XZ plane"); + + ImGui::InputScalar("Y Velocity", ImGuiDataType_Float, &player->actor.velocity.y); + InsertHelpHoverText("Link's speed along the Y plane. Caps at -20"); + + ImGui::InputScalar("Wall Height", ImGuiDataType_Float, &player->wallHeight); + InsertHelpHoverText("\"height used to determine whether link can climb or grab a ledge at the top\""); + + ImGui::InputScalar("Invincibility Timer", ImGuiDataType_S8, &player->invincibilityTimer); + InsertHelpHoverText("Can't take damage while this is nonzero"); + + ImGui::InputScalar("Gravity", ImGuiDataType_Float, &player->actor.gravity); + InsertHelpHoverText("Rate at which Link falls. Default -4.0f"); + + if (ImGui::BeginCombo("Link Age on Load", gGlobalCtx->linkAgeOnLoad == 0 ? "Adult" : "Child")) { + if (ImGui::Selectable("Adult")) { + gGlobalCtx->linkAgeOnLoad = 0; + } + if (ImGui::Selectable("Child")) { + gGlobalCtx->linkAgeOnLoad = 1; + } + ImGui::EndCombo(); + } + + InsertHelpHoverText("This will change Link's age when you load a map"); + + ImGui::Separator(); + + ImGui::Text("Link's Current Equipment"); + ImGui::PushItemWidth(ImGui::GetFontSize() * 15); + if (ImGui::BeginCombo("Sword", curSword)) { + if (ImGui::Selectable("None")) { + player->currentSwordItem = ITEM_NONE; + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE); + } + if (ImGui::Selectable("Kokiri Sword")) { + player->currentSwordItem = ITEM_SWORD_KOKIRI; + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI; + Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI); + } + if (ImGui::Selectable("Master Sword")) { + player->currentSwordItem = ITEM_SWORD_MASTER; + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_MASTER); + } + if (ImGui::Selectable("Biggoron's Sword")) { + if (gSaveContext.bgsFlag) { + if (gSaveContext.swordHealth < 8) { + gSaveContext.swordHealth = 8; + } + player->currentSwordItem = ITEM_SWORD_BGS; + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; + } else { + if (gSaveContext.swordHealth < 8) { + gSaveContext.swordHealth = 8; + } + player->currentSwordItem = ITEM_SWORD_BGS; + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; + } + + Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_BGS); + } + ImGui::EndCombo(); + + } + if (ImGui::BeginCombo("Shield", curShield)) { + if (ImGui::Selectable("None")) { + player->currentShield = PLAYER_SHIELD_NONE; + Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_NONE); + } + if (ImGui::Selectable("Deku Shield")) { + player->currentShield = PLAYER_SHIELD_DEKU; + Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_DEKU); + } + if (ImGui::Selectable("Hylian Shield")) { + player->currentShield = PLAYER_SHIELD_HYLIAN; + Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_HYLIAN); + } + if (ImGui::Selectable("Mirror Shield")) { + player->currentShield = PLAYER_SHIELD_MIRROR; + Inventory_ChangeEquipment(EQUIP_SHIELD, PLAYER_SHIELD_MIRROR); + } + ImGui::EndCombo(); + } + + if (ImGui::BeginCombo("Tunic", curTunic)) { + if (ImGui::Selectable("Kokiri Tunic")) { + player->currentTunic = PLAYER_TUNIC_KOKIRI; + Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_KOKIRI + 1); + } + if (ImGui::Selectable("Goron Tunic")) { + player->currentTunic = PLAYER_TUNIC_GORON; + Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_GORON + 1); + } + if (ImGui::Selectable("Zora Tunic")) { + player->currentTunic = PLAYER_TUNIC_ZORA; + Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_ZORA + 1); + } + ImGui::EndCombo(); + } + + if (ImGui::BeginCombo("Boots", curBoots)) { + if (ImGui::Selectable("Kokiri Boots")) { + player->currentBoots = PLAYER_BOOTS_KOKIRI; + Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_KOKIRI + 1); + } + if (ImGui::Selectable("Iron Boots")) { + player->currentBoots = PLAYER_BOOTS_IRON; + Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_IRON + 1); + } + if (ImGui::Selectable("Hover Boots")) { + player->currentBoots = PLAYER_BOOTS_HOVER; + Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_HOVER + 1); + } + ImGui::EndCombo(); + } + + ImU16 one = 1; + ImGui::PushItemWidth(ImGui::GetFontSize() * 6); + DrawGroupWithBorder([&]() { + ImGui::Text("Current C Equips"); + ImGui::InputScalar("C Left", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[1], &one, NULL); + ImGui::SameLine(); + ImGui::InputScalar("C Down", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[2], &one, NULL); + ImGui::SameLine(); + ImGui::InputScalar("C Right", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[3], &one, NULL); + }); + + } else { + ImGui::Text("Global Context needed for player info!"); + } +} + void DrawSaveEditor(bool& open) { if (!open) { return; } ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Save Editor", &open)) { + if (!ImGui::Begin("Save Editor", &open, ImGuiWindowFlags_NoFocusOnAppearing)) { ImGui::End(); return; } @@ -1113,6 +1571,11 @@ void DrawSaveEditor(bool& open) { ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("Player")) { + DrawPlayerTab(); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); } @@ -1120,7 +1583,7 @@ void DrawSaveEditor(bool& open) { } void InitSaveEditor() { - SohImGui::AddWindow("Debug", "Save Editor", DrawSaveEditor); + SohImGui::AddWindow("Developer Tools", "Save Editor", DrawSaveEditor); // Load item icons into ImGui for (const auto& entry : itemMapping) { diff --git a/soh/soh/Enhancements/debugger/debugger.cpp b/soh/soh/Enhancements/debugger/debugger.cpp index e493375cd..83e6a94a4 100644 --- a/soh/soh/Enhancements/debugger/debugger.cpp +++ b/soh/soh/Enhancements/debugger/debugger.cpp @@ -1,6 +1,16 @@ #include "debugger.h" #include "debugSaveEditor.h" +#include "colViewer.h" + +extern "C" { void Debug_Init(void) { InitSaveEditor(); + InitColViewer(); +} + +void Debug_Draw(void) { + DrawColViewer(); +} + } diff --git a/soh/soh/Enhancements/debugger/debugger.h b/soh/soh/Enhancements/debugger/debugger.h index 4bc0f985b..bbefd2e21 100644 --- a/soh/soh/Enhancements/debugger/debugger.h +++ b/soh/soh/Enhancements/debugger/debugger.h @@ -1,3 +1,12 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + void Debug_Init(void); +void Debug_Draw(void); + +#ifdef __cplusplus +} +#endif diff --git a/soh/soh/Enhancements/gameconsole.h b/soh/soh/Enhancements/gameconsole.h index d7052fce3..33301afe6 100644 --- a/soh/soh/Enhancements/gameconsole.h +++ b/soh/soh/Enhancements/gameconsole.h @@ -3,7 +3,7 @@ #include #include -#include "cvar.h" +#include "Cvar.h" #define MAX_CVARS 2048 diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp new file mode 100644 index 000000000..2b6d27189 --- /dev/null +++ b/soh/soh/Enhancements/savestates.cpp @@ -0,0 +1,957 @@ +#include "savestates.h" + +#include "GameVersions.h" + +#include // std::sprintf + +#include "spdlog/spdlog.h" + +#include +#include + +#include + +#include "z64.h" +#include "z64save.h" +#include +#include +#include "z64map_mark.h" +#include "../../src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h" +#include "../../src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.h" +#include "../../src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h" +#include "../../src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h" +#include "../../src/overlays/actors/ovl_En_Fr/z_en_fr.h" + +extern "C" GlobalContext* gGlobalCtx; + +// FROM z_lights.c +// I didn't feel like moving it into a header file. +#define LIGHTS_BUFFER_SIZE 32 + +typedef struct { + /* 0x000 */ s32 numOccupied; + /* 0x004 */ s32 searchIndex; + /* 0x008 */ LightNode buf[LIGHTS_BUFFER_SIZE]; +} LightsBuffer; // size = 0x188 + +#include "savestates_extern.inc" + +typedef struct SaveStateInfo { + unsigned char sysHeapCopy[SYSTEM_HEAP_SIZE]; + unsigned char audioHeapCopy[AUDIO_HEAP_SIZE]; + + SaveContext saveContextCopy; + GameInfo gameInfoCopy; + LightsBuffer lightBufferCopy; + AudioContext audioContextCopy; + MtxF mtxStackCopy[20]; // always 20 matricies + MtxF currentMtxCopy; + uint32_t rngSeed; + int16_t blueWarpTimerCopy; /* From door_warp_1 */ + + SeqScriptState seqScriptStateCopy[4];// Unrelocated + unk_D_8016E750 unk_D_8016E750Copy[4]; + + ActiveSound gActiveSoundsCopy[7][MAX_CHANNELS_PER_BANK]; + uint8_t gSoundBankMutedCopy[7]; + + u8 D_801333F0_copy; + u8 gAudioSfxSwapOff_copy; + uint16_t gAudioSfxSwapSource_copy[10]; + uint16_t gAudioSfxSwapTarget_copy[10]; + uint8_t gAudioSfxSwapMode_copy[10]; + void (*D_801755D0_copy)(void); + MapMarkData** sLoadedMarkDataTableCopy; + + //Static Data + + //Camera data + int32_t sInitRegs_copy; + int32_t gDbgCamEnabled_copy; + int32_t sDbgModeIdx_copy; + int16_t sNextUID_copy; + int32_t sCameraInterfaceFlags_copy; + int32_t sCameraInterfaceAlpha_copy; + int32_t sCameraShrinkWindowVal_copy; + int32_t D_8011D3AC_copy; + int32_t sDemo5PrevAction12Frame_copy; + int32_t sDemo5PrevSfxFrame_copy; + int32_t D_8011D3F0_copy; + OnePointCsFull D_8011D6AC_copy[3]; + OnePointCsFull D_8011D724_copy[3]; + OnePointCsFull D_8011D79C_copy[3]; + OnePointCsFull D_8011D83C_copy[2]; + OnePointCsFull D_8011D88C_copy[2]; + OnePointCsFull D_8011D8DC_copy[3]; + OnePointCsFull D_8011D954_copy[4]; + OnePointCsFull D_8011D9F4_copy[3]; + int16_t D_8011DB08_copy; + int16_t D_8011DB0C_copy; + int32_t sOOBTimer_copy; + f32 D_8015CE50_copy; + f32 D_8015CE54_copy; + CamColChk D_8015CE58_copy; + + //Gameover + uint16_t gGameOverTimer_copy; + + //One point demo + uint32_t sPrevFrameCs1100_copy; + CutsceneCameraPoint D_8012013C_copy[14]; + CutsceneCameraPoint D_8012021C_copy[14]; + CutsceneCameraPoint D_801204D4_copy[14]; + CutsceneCameraPoint D_801205B4_copy[14]; + OnePointCsFull D_801208EC_copy[3]; + OnePointCsFull D_80120964_copy[2]; + OnePointCsFull D_801209B4_copy[4]; + OnePointCsFull D_80120ACC_copy[5]; + OnePointCsFull D_80120B94_copy[11]; + OnePointCsFull D_80120D4C_copy[7]; + OnePointCsFull D_80120FA4_copy[6]; + OnePointCsFull D_80121184_copy[2]; + OnePointCsFull D_801211D4_copy[2]; + OnePointCsFull D_8012133C_copy[3]; + OnePointCsFull D_801213B4_copy[5]; + OnePointCsFull D_8012151C_copy[2]; + OnePointCsFull D_8012156C_copy[2]; + OnePointCsFull D_801215BC_copy[1]; + OnePointCsFull D_80121C24_copy[7]; + OnePointCsFull D_80121D3C_copy[3]; + OnePointCsFull D_80121F1C_copy[4]; + OnePointCsFull D_80121FBC_copy[4]; + OnePointCsFull D_801220D4_copy[5]; + OnePointCsFull D_80122714_copy[4]; + OnePointCsFull D_80122CB4_copy[2]; + OnePointCsFull D_80122D04_copy[2]; + OnePointCsFull D_80122E44_copy[2][7]; + OnePointCsFull D_8012313C_copy[3]; + OnePointCsFull D_801231B4_copy[4]; + OnePointCsFull D_80123254_copy[2]; + OnePointCsFull D_801232A4_copy[1]; + OnePointCsFull D_80123894_copy[3]; + OnePointCsFull D_8012390C_copy[2]; + OnePointCsFull D_8012395C_copy[3]; + OnePointCsFull D_801239D4_copy[3]; + + uint16_t gTimeIncrement_copy; + + //Overlay static data + // z_bg_ddan_kd + Vec3f sBgDdanKdVelocity_copy; + Vec3f sBgDdanKdAccel_copy; + + // z_bg_dodoago + s16 sBgDodoagoFirstExplosiveFlag_copy; + u8 sBgDodoagoDisableBombCatcher_copy; + s32 sBgDodoagoTimer_copy; + + // z_bg_haka_trap + uint32_t D_80880F30_copy; + uint32_t D_80881014_copy; + + // z_bg_hidan_rock + float D_8088BFC0_copy; + + // z_bg_menkuri_eye + int32_t D_8089C1A0_copy; + + // z_bg_mori_hineri + int16_t sBgMoriHineriNextCamIdx_copy; + + // z_bg_po_event + uint8_t sBgPoEventBlocksAtRest_copy; + uint8_t sBgPoEventPuzzleState_copy; + float sBgPoEventblockPushDist_copy; + + // z_bg_relay_objects + uint32_t D_808A9508_copy; + + // z_bg_spot18_basket + int16_t D_808B85D0_copy; + + // z_boss_ganon + uint32_t sBossGanonSeed1_copy; + uint32_t sBossGanonSeed2_copy; + uint32_t sBossGanonSeed3_copy; + void* sBossGanonGanondorf_copy; + void* sBossGanonZelda_copy; + void* sBossGanonCape_copy; + GanondorfEffect sBossGanonEffectBuf_copy[200]; + + // z_boss_ganon + uint32_t sBossGanonSeed1; + uint32_t sBossGanonSeed2; + uint32_t sBossGanonSeed3; + void* sBossGanonGanondorf; + void* sBossGanonZelda; + void* sBossGanonCape; + GanondorfEffect sBossGanonEffectBuf[200]; + + // z_boss_ganon2 + Vec3f D_8090EB20_copy; + int8_t D_80910638_copy; + void* sBossGanon2Zelda_copy; + void* D_8090EB30_copy; + int32_t sBossGanon2Seed1_copy; + int32_t sBossGanon2Seed2_copy; + int32_t sBossGanon2Seed3_copy; + Vec3f D_809105D8_copy[4]; + Vec3f D_80910608_copy[4]; + BossGanon2Effect sBossGanon2Particles_copy[100]; + + // z_boss_tw + uint8_t sTwInitalized_copy; + BossTwEffect sTwEffects_copy[150]; + + // z_demo_6k + Vec3f sDemo6kVelocity_copy; + + // z_demo_du + int32_t D_8096CE94_copy; + + // z_demo_kekkai + Vec3f demoKekkaiVel_copy; + + // z_en_bw + int32_t sSlugGroup_copy; + + // z_en_clear_tag + uint8_t sClearTagIsEffectInitialized_copy; + EnClearTagEffect sClearTagEffects_copy[CLEAR_TAG_EFFECT_MAX_COUNT]; + + // z_en_fr + EnFrPointers sEnFrPointers_copy; + + // z_en_goma + uint8_t sSpawnNum_copy; + + // z_en_insect + float D_80A7DEB0_copy; + int16_t D_80A7DEB4_copy; + int16_t D_80A7DEB8_copy; + + // z_en_ishi + int16_t sRockRotSpeedX_copy; + int16_t sRockRotSpeedY_copy; + + // z_en_niw + int16_t D_80AB85E0_copy; + uint8_t sLowerRiverSpawned_copy; + uint8_t sUpperRiverSpawned_copy; + + // z_en_po_field + int32_t sEnPoFieldNumSpawned_copy; + Vec3s sEnPoFieldSpawnPositions_copy[10]; + u8 sEnPoFieldSpawnSwitchFlags_copy[10]; + + // z_en_takara_man + uint8_t sTakaraIsInitialized_copy; + + // z_en_xc + int32_t D_80B41D90_copy; + int32_t sEnXcFlameSpawned_copy; + int32_t D_80B41DA8_copy; + int32_t D_80B41DAC_copy; + + // z_en_zf + int16_t D_80B4A1B0_copy; + int16_t D_80B4A1B4_copy; + + int32_t D_80B5A468_copy; + int32_t D_80B5A494_copy; + int32_t D_80B5A4BC_copy; + + uint8_t sKankyoIsSpawned_copy; + int16_t sTrailingFairies_copy; + + + //Misc static data + // z_map_exp + + s16 sPlayerInitialPosX_copy; + s16 sPlayerInitialPosZ_copy; + s16 sPlayerInitialDirection_copy; + + // code_800E(something. fill me in later) + u8 sOcarinaInpEnabled_copy; + s8 D_80130F10_copy; + u8 sCurOcarinaBtnVal_copy; + u8 sPrevOcarinaNoteVal_copy; + u8 sCurOcarinaBtnIdx_copy; + u8 sLearnSongLastBtn_copy; + f32 D_80130F24_copy; + f32 D_80130F28_copy; + s8 D_80130F2C_copy; + s8 D_80130F30_copy; + s8 D_80130F34_copy; + u8 sDisplayedNoteValue_copy; + u8 sPlaybackState_copy; + u32 D_80130F3C_copy; + u32 sNotePlaybackTimer_copy; + u16 sPlaybackNotePos_copy; + u16 sStaffPlaybackPos_copy; + + u32 sCurOcarinaBtnPress_copy; + u32 D_8016BA10_copy; + u32 sPrevOcarinaBtnPress_copy; + s32 D_8016BA18_copy; + s32 D_8016BA1C_copy; + u8 sCurOcarinaSong_copy[8]; + u8 sOcarinaSongAppendPos_copy; + u8 sOcarinaHasStartedSong_copy; + u8 sOcarinaSongNoteStartIdx_copy; + u8 sOcarinaSongCnt_copy; + u16 sOcarinaAvailSongs_copy; + u8 sStaffPlayingPos_copy; + u16 sLearnSongPos_copy[0x10]; + u16 D_8016BA50_copy[0x10]; + u16 D_8016BA70_copy[0x10]; + u8 sLearnSongExpectedNote_copy[0x10]; + OcarinaNote D_8016BAA0_copy; + u8 sAudioHasMalonBgm_copy; + f32 sAudioMalonBgmDist_copy; + + // Message_PAL + s16 sOcarinaNoteBufPos_copy; + s16 sOcarinaNoteBufLen_copy; + u8 sOcarinaNoteBuf_copy[12]; + + u8 D_8014B2F4_copy; + u8 sTextboxSkipped_copy; + u16 sNextTextId_copy; + s16 sLastPlayedSong_copy; + s16 sHasSunsSong_copy; + s16 sMessageHasSetSfx_copy; + u16 sOcarinaSongBitFlags_copy; + + +} SaveStateInfo; + +class SaveState { + friend class SaveStateMgr; + + public: + SaveState(std::shared_ptr mgr, unsigned int slot); + + private: + unsigned int slot; + std::shared_ptr saveStateMgr; + std::shared_ptr info; + + void Save(void); + void Load(void); + void BackupSeqScriptState(void); + void LoadSeqScriptState(void); + void BackupCameraData(void); + void LoadCameraData(void); + void SaveOnePointDemoData(void); + void LoadOnePointDemoData(void); + void SaveOverlayStaticData(void); + void LoadOverlayStaticData(void); + + void SaveMiscCodeData(void); + void LoadMiscCodeData(void); + + SaveStateInfo* GetSaveStateInfo(void); +}; + +SaveStateMgr::SaveStateMgr() { + this->SetCurrentSlot(0); +} +SaveStateMgr::~SaveStateMgr() { + this->states.clear(); +} + +SaveState::SaveState(std::shared_ptr mgr, unsigned int slot) : saveStateMgr(mgr), slot(slot), info(nullptr) { + this->info = std::make_shared(); +} + +void SaveState::BackupSeqScriptState(void) { + for (unsigned int i = 0; i < 4; i++) { + info->seqScriptStateCopy[i].value = gAudioContext.seqPlayers[i].scriptState.value; + + info->seqScriptStateCopy[i].remLoopIters[0] = gAudioContext.seqPlayers[i].scriptState.remLoopIters[0]; + info->seqScriptStateCopy[i].remLoopIters[1] = gAudioContext.seqPlayers[i].scriptState.remLoopIters[1]; + info->seqScriptStateCopy[i].remLoopIters[2] = gAudioContext.seqPlayers[i].scriptState.remLoopIters[2]; + info->seqScriptStateCopy[i].remLoopIters[3] = gAudioContext.seqPlayers[i].scriptState.remLoopIters[3]; + + info->seqScriptStateCopy[i].depth = gAudioContext.seqPlayers[i].scriptState.depth; + + info->seqScriptStateCopy[i].pc = (u8*)((uintptr_t)gAudioContext.seqPlayers[i].scriptState.pc - (uintptr_t)gAudioHeap); + + info->seqScriptStateCopy[i].stack[0] = + (u8*)((uintptr_t)gAudioContext.seqPlayers[i].scriptState.stack[0] - (uintptr_t)gAudioHeap); + info->seqScriptStateCopy[i].stack[1] = + (u8*)((uintptr_t)gAudioContext.seqPlayers[i].scriptState.stack[1] - (uintptr_t)gAudioHeap); + info->seqScriptStateCopy[i].stack[2] = + (u8*)((uintptr_t)gAudioContext.seqPlayers[i].scriptState.stack[2] - (uintptr_t)gAudioHeap); + info->seqScriptStateCopy[i].stack[3] = + (u8*)((uintptr_t)gAudioContext.seqPlayers[i].scriptState.stack[3] - (uintptr_t)gAudioHeap); + } +} + +void SaveState::LoadSeqScriptState(void) { + for (unsigned int i = 0; i < 4; i++) { + gAudioContext.seqPlayers[i].scriptState.value = info->seqScriptStateCopy[i].value; + + gAudioContext.seqPlayers[i].scriptState.remLoopIters[0] = info->seqScriptStateCopy[i].remLoopIters[0]; + gAudioContext.seqPlayers[i].scriptState.remLoopIters[1] = info->seqScriptStateCopy[i].remLoopIters[1]; + gAudioContext.seqPlayers[i].scriptState.remLoopIters[2] = info->seqScriptStateCopy[i].remLoopIters[2]; + gAudioContext.seqPlayers[i].scriptState.remLoopIters[3] = info->seqScriptStateCopy[i].remLoopIters[3]; + + gAudioContext.seqPlayers[i].scriptState.depth = info->seqScriptStateCopy[i].depth; + + gAudioContext.seqPlayers[i].scriptState.pc = + (u8*)((uintptr_t)info->seqScriptStateCopy[i].pc + (uintptr_t)gAudioHeap); + + gAudioContext.seqPlayers[i].scriptState.stack[0] = + (u8*)((uintptr_t)info->seqScriptStateCopy[i].stack[0] + (uintptr_t)gAudioHeap); + gAudioContext.seqPlayers[i].scriptState.stack[1] = + (u8*)((uintptr_t)info->seqScriptStateCopy[i].stack[1] + (uintptr_t)gAudioHeap); + gAudioContext.seqPlayers[i].scriptState.stack[2] = + (u8*)((uintptr_t)info->seqScriptStateCopy[i].stack[2] + (uintptr_t)gAudioHeap); + gAudioContext.seqPlayers[i].scriptState.stack[3] = + (u8*)((uintptr_t)info->seqScriptStateCopy[i].stack[3] + (uintptr_t)gAudioHeap); + } +} + +void SaveState::BackupCameraData(void) { + info->sInitRegs_copy = sInitRegs; + info->gDbgCamEnabled_copy = gDbgCamEnabled; + info->sNextUID_copy = sNextUID; + info->sCameraInterfaceFlags_copy = sCameraInterfaceFlags; + info->sCameraInterfaceAlpha_copy = sCameraInterfaceAlpha; + info->sCameraShrinkWindowVal_copy = sCameraShrinkWindowVal; + info->D_8011D3AC_copy = D_8011D3AC; + info->sDemo5PrevAction12Frame_copy = sDemo5PrevAction12Frame; + info->sDemo5PrevSfxFrame_copy = sDemo5PrevSfxFrame; + info->D_8011D3F0_copy = D_8011D3F0; + memcpy(info->D_8011D6AC_copy, D_8011D6AC, sizeof(info->D_8011D6AC_copy)); + memcpy(info->D_8011D724_copy, D_8011D724, sizeof(info->D_8011D724_copy)); + memcpy(info->D_8011D79C_copy, D_8011D79C, sizeof(info->D_8011D79C_copy)); + memcpy(info->D_8011D83C_copy, D_8011D83C, sizeof(info->D_8011D83C_copy)); + memcpy(info->D_8011D88C_copy, D_8011D88C, sizeof(info->D_8011D88C_copy)); + memcpy(info->D_8011D8DC_copy, D_8011D8DC, sizeof(info->D_8011D8DC_copy)); + memcpy(info->D_8011D954_copy, D_8011D954, sizeof(info->D_8011D954_copy)); + memcpy(info->D_8011D9F4_copy, D_8011D9F4, sizeof(info->D_8011D9F4_copy)); + info->D_8011DB08_copy = D_8011DB08; + info->D_8011DB0C_copy = D_8011DB0C; + info->sOOBTimer_copy = sOOBTimer; + info->D_8015CE50_copy = D_8015CE50; + info->D_8015CE54_copy = D_8015CE54; + memcpy(&info->D_8015CE58_copy, &D_8015CE58, sizeof(info->D_8015CE58_copy)); +} + +void SaveState::LoadCameraData(void) { + sInitRegs = info->sInitRegs_copy; + gDbgCamEnabled = info->gDbgCamEnabled_copy; + sDbgModeIdx = info->sDbgModeIdx_copy; + sNextUID = info->sNextUID_copy; + sCameraInterfaceAlpha = info->sCameraInterfaceAlpha_copy; + sCameraInterfaceFlags = info->sCameraInterfaceFlags_copy; + sCameraShrinkWindowVal = info->sCameraShrinkWindowVal_copy; + D_8011D3AC = info->D_8011D3AC_copy; + sDemo5PrevAction12Frame = info->sDemo5PrevAction12Frame_copy; + sDemo5PrevSfxFrame = info->sDemo5PrevSfxFrame_copy; + D_8011D3F0 = info->D_8011D3F0_copy; + memcpy(D_8011D6AC, info->D_8011D6AC_copy, sizeof(info->D_8011D6AC_copy)); + memcpy(D_8011D724, info->D_8011D724_copy, sizeof(info->D_8011D724_copy)); + memcpy(D_8011D79C, info->D_8011D79C_copy, sizeof(info->D_8011D79C_copy)); + memcpy(D_8011D83C, info->D_8011D83C_copy, sizeof(info->D_8011D83C_copy)); + memcpy(D_8011D88C, info->D_8011D88C_copy, sizeof(info->D_8011D88C_copy)); + memcpy(D_8011D8DC, info->D_8011D8DC_copy, sizeof(info->D_8011D8DC_copy)); + memcpy(D_8011D954, info->D_8011D954_copy, sizeof(info->D_8011D954_copy)); + memcpy(D_8011D9F4, info->D_8011D9F4_copy, sizeof(info->D_8011D9F4_copy)); + D_8011DB08 = info->D_8011DB08_copy; + D_8011DB0C = info->D_8011DB0C_copy; + sOOBTimer = info->sOOBTimer_copy; + D_8015CE50 = info->D_8015CE50_copy; + D_8015CE54 = info->D_8015CE54_copy; + memcpy(&D_8015CE58, &info->D_8015CE58_copy, sizeof(info->D_8015CE58_copy)); +} + +void SaveState::SaveOnePointDemoData(void) { + info->sPrevFrameCs1100_copy = sPrevFrameCs1100; + memcpy(info->D_8012013C_copy, D_8012013C, sizeof(info->D_8012013C_copy)); + memcpy(info->D_8012021C_copy, D_8012021C, sizeof(info->D_8012021C_copy)); + memcpy(info->D_801204D4_copy, D_801204D4, sizeof(info->D_801204D4_copy)); + memcpy(info->D_801205B4_copy, D_801205B4, sizeof(info->D_801205B4_copy)); + memcpy(info->D_801208EC_copy, D_801208EC, sizeof(info->D_801208EC_copy)); + memcpy(info->D_80120964_copy, D_80120964, sizeof(info->D_80120964_copy)); + memcpy(info->D_801209B4_copy, D_801209B4, sizeof(info->D_801209B4_copy)); + memcpy(info->D_80120ACC_copy, D_80120ACC, sizeof(info->D_80120ACC_copy)); + memcpy(info->D_80120B94_copy, D_80120B94, sizeof(info->D_80120B94_copy)); + memcpy(info->D_80120D4C_copy, D_80120D4C, sizeof(info->D_80120D4C_copy)); + memcpy(info->D_80120FA4_copy, D_80120FA4, sizeof(info->D_80120FA4_copy)); + memcpy(info->D_80121184_copy, D_80121184, sizeof(info->D_80121184_copy)); + memcpy(info->D_801211D4_copy, D_801211D4, sizeof(info->D_801211D4_copy)); + memcpy(info->D_8012133C_copy, D_8012133C, sizeof(info->D_8012133C_copy)); + memcpy(info->D_801213B4_copy, D_801213B4, sizeof(info->D_801213B4_copy)); + memcpy(info->D_8012151C_copy, D_8012151C, sizeof(info->D_8012151C_copy)); + memcpy(info->D_8012156C_copy, D_8012156C, sizeof(info->D_8012156C_copy)); + memcpy(info->D_801215BC_copy, D_801215BC, sizeof(info->D_801215BC_copy)); + memcpy(info->D_80121C24_copy, D_80121C24, sizeof(info->D_80121C24_copy)); + memcpy(info->D_80121D3C_copy, D_80121D3C, sizeof(info->D_80121D3C_copy)); + memcpy(info->D_80121F1C_copy, D_80121F1C, sizeof(info->D_80121F1C_copy)); + memcpy(info->D_80121FBC_copy, D_80121FBC, sizeof(info->D_80121FBC_copy)); + memcpy(info->D_801220D4_copy, D_801220D4, sizeof(info->D_801220D4_copy)); + memcpy(info->D_80122714_copy, D_80122714, sizeof(info->D_80122714_copy)); + memcpy(info->D_80122CB4_copy, D_80122CB4, sizeof(info->D_80122CB4_copy)); + memcpy(info->D_80122D04_copy, D_80122D04, sizeof(info->D_80122D04_copy)); + memcpy(info->D_80122E44_copy, D_80122E44, sizeof(info->D_80122E44_copy)); + memcpy(info->D_8012313C_copy, D_8012313C, sizeof(info->D_8012313C_copy)); + memcpy(info->D_801231B4_copy, D_801231B4, sizeof(info->D_801231B4_copy)); + memcpy(info->D_80123254_copy, D_80123254, sizeof(info->D_80123254_copy)); + memcpy(info->D_801232A4_copy, D_801232A4, sizeof(info->D_801232A4_copy)); + memcpy(info->D_80123894_copy, D_80123894, sizeof(info->D_80123894_copy)); + memcpy(info->D_8012390C_copy, D_8012390C, sizeof(info->D_8012390C_copy)); + memcpy(info->D_8012395C_copy, D_8012395C, sizeof(info->D_8012395C_copy)); + memcpy(info->D_801239D4_copy, D_801239D4, sizeof(info->D_801239D4_copy)); +} + +void SaveState::LoadOnePointDemoData(void) { + sPrevFrameCs1100 = info->sPrevFrameCs1100_copy; + memcpy(D_8012013C, info->D_8012013C_copy, sizeof(info->D_8012013C_copy)); + memcpy(D_8012021C, info->D_8012021C_copy, sizeof(info->D_8012021C_copy)); + memcpy(D_801204D4, info->D_801204D4_copy, sizeof(info->D_801204D4_copy)); + memcpy(D_801205B4, info->D_801205B4_copy, sizeof(info->D_801205B4_copy)); + memcpy(D_801208EC, info->D_801208EC_copy, sizeof(info->D_801208EC_copy)); + memcpy(D_80120964, info->D_80120964_copy, sizeof(info->D_80120964_copy)); + memcpy(D_801209B4, info->D_801209B4_copy, sizeof(info->D_801209B4_copy)); + memcpy(D_80120ACC, info->D_80120ACC_copy, sizeof(info->D_80120ACC_copy)); + memcpy(D_80120B94, info->D_80120B94_copy, sizeof(info->D_80120B94_copy)); + memcpy(D_80120D4C, info->D_80120D4C_copy, sizeof(info->D_80120D4C_copy)); + memcpy(D_80120FA4, info->D_80120FA4_copy, sizeof(info->D_80120FA4_copy)); + memcpy(D_80121184, info->D_80121184_copy, sizeof(info->D_80121184_copy)); + memcpy(D_801211D4, info->D_801211D4_copy, sizeof(info->D_801211D4_copy)); + memcpy(D_8012133C, info->D_8012133C_copy, sizeof(info->D_8012133C_copy)); + memcpy(D_801213B4, info->D_801213B4_copy, sizeof(info->D_801213B4_copy)); + memcpy(D_8012151C, info->D_8012151C_copy, sizeof(info->D_8012151C_copy)); + memcpy(D_8012156C, info->D_8012156C_copy, sizeof(info->D_8012156C_copy)); + memcpy(D_801215BC, info->D_801215BC_copy, sizeof(info->D_801215BC_copy)); + memcpy(D_80121C24, info->D_80121C24_copy, sizeof(info->D_80121C24_copy)); + memcpy(D_80121D3C, info->D_80121D3C_copy, sizeof(info->D_80121D3C_copy)); + memcpy(D_80121F1C, info->D_80121F1C_copy, sizeof(info->D_80121F1C_copy)); + memcpy(D_80121FBC, info->D_80121FBC_copy, sizeof(info->D_80121FBC_copy)); + memcpy(D_801220D4, info->D_801220D4_copy, sizeof(info->D_801220D4_copy)); + memcpy(D_80122714, info->D_80122714_copy, sizeof(info->D_80122714_copy)); + memcpy(D_80122CB4, info->D_80122CB4_copy, sizeof(info->D_80122CB4_copy)); + memcpy(D_80122D04, info->D_80122D04_copy, sizeof(info->D_80122D04_copy)); + memcpy(D_80122E44, info->D_80122E44_copy, sizeof(info->D_80122E44_copy)); + memcpy(D_8012313C, info->D_8012313C_copy, sizeof(info->D_8012313C_copy)); + memcpy(D_801231B4, info->D_801231B4_copy, sizeof(info->D_801231B4_copy)); + memcpy(D_80123254, info->D_80123254_copy, sizeof(info->D_80123254_copy)); + memcpy(D_801232A4, info->D_801232A4_copy, sizeof(info->D_801232A4_copy)); + memcpy(D_80123894, info->D_80123894_copy, sizeof(info->D_80123894_copy)); + memcpy(D_8012390C, info->D_8012390C_copy, sizeof(info->D_8012390C_copy)); + memcpy(D_8012395C, info->D_8012395C_copy, sizeof(info->D_8012395C_copy)); + memcpy(D_801239D4, info->D_801239D4_copy, sizeof(info->D_801239D4_copy)); +} + +void SaveState::SaveOverlayStaticData(void) { + info->sBgDdanKdVelocity_copy = sBgDdanKdVelocity; + info->sBgDdanKdAccel_copy = sBgDdanKdAccel; + info->sBgDodoagoFirstExplosiveFlag_copy = sBgDodoagoFirstExplosiveFlag; + info->sBgDodoagoDisableBombCatcher_copy = sBgDodoagoDisableBombCatcher; + info->sBgDodoagoTimer_copy = sBgDodoagoTimer; + info->D_80880F30_copy = D_80880F30; + info->D_80881014_copy = D_80881014; + info->D_8088BFC0_copy = D_8088BFC0; + info->sBgMoriHineriNextCamIdx_copy = sBgMoriHineriNextCamIdx; + info->sBgPoEventBlocksAtRest_copy = sBgPoEventBlocksAtRest; + info->sBgPoEventPuzzleState_copy = sBgPoEventPuzzleState; + info->sBgPoEventblockPushDist_copy = sBgPoEventblockPushDist; + info->D_808A9508_copy = D_808A9508; + info->D_808B85D0_copy = D_808B85D0; + info->sBossGanonSeed1_copy = sBossGanonSeed1; + info->sBossGanonSeed2_copy = sBossGanonSeed2; + info->sBossGanonSeed3_copy = sBossGanonSeed3; + info->sBossGanonGanondorf_copy = sBossGanonGanondorf; + info->sBossGanonZelda_copy = sBossGanonZelda; + info->sBossGanonCape_copy = sBossGanonCape; + memcpy(info->sBossGanonEffectBuf_copy, sBossGanonEffectBuf, sizeof(info->sBossGanonEffectBuf_copy)); + info->D_8090EB20_copy = D_8090EB20; + info->D_80910638_copy = D_80910638; + info->sBossGanon2Zelda_copy = sBossGanon2Zelda; + info->D_8090EB30_copy = D_8090EB30; + info->sBossGanon2Seed1_copy = sBossGanon2Seed1; + info->sBossGanon2Seed2_copy = sBossGanon2Seed2; + info->sBossGanon2Seed3_copy = sBossGanon2Seed3; + memcpy(info->D_809105D8_copy, D_809105D8, sizeof(D_809105D8)); + memcpy(info->D_80910608_copy, D_80910608, sizeof(D_80910608)); + memcpy(info->sBossGanon2Particles_copy, sBossGanon2Particles, sizeof(sBossGanon2Particles)); + info->sTwInitalized_copy = sTwInitalized; + memcpy(info->sTwEffects_copy, sTwEffects, sizeof(sTwEffects)); + info->sDemo6kVelocity_copy = sDemo6kVelocity; + info->D_8096CE94_copy = D_8096CE94; + info->demoKekkaiVel_copy = demoKekkaiVel; + info->sSlugGroup_copy = sSlugGroup; + info->sClearTagIsEffectInitialized_copy = sClearTagIsEffectsInitialized; + memcpy(info->sClearTagEffects_copy, sClearTagEffects, sizeof(sClearTagEffects)); + + memcpy(&info->sEnFrPointers_copy, &sEnFrPointers, sizeof(info->sEnFrPointers_copy)); + info->sSpawnNum_copy = sSpawnNum; + + info->D_80A7DEB0_copy = D_80A7DEB0; + info->D_80A7DEB4_copy = D_80A7DEB4; + info->D_80A7DEB8_copy = D_80A7DEB8; + info->sRockRotSpeedX_copy = sRockRotSpeedX; + info->sRockRotSpeedY_copy = sRockRotSpeedY; + info->D_80AB85E0_copy = D_80AB85E0; + info->sLowerRiverSpawned_copy = sLowerRiverSpawned; + info->sUpperRiverSpawned_copy = sUpperRiverSpawned; + info->sEnPoFieldNumSpawned_copy = sEnPoFieldNumSpawned; + memcpy(info->sEnPoFieldSpawnPositions_copy, sEnPoFieldSpawnPositions, sizeof(info->sEnPoFieldSpawnPositions_copy)); + memcpy(info->sEnPoFieldSpawnSwitchFlags_copy, sEnPoFieldSpawnSwitchFlags, sizeof(info->sEnPoFieldSpawnSwitchFlags_copy)); + + info->sTakaraIsInitialized_copy = sTakaraIsInitialized; + info->D_80B41D90_copy = D_80B41D90; + info->sEnXcFlameSpawned_copy = sEnXcFlameSpawned; + info->D_80B41DA8_copy = D_80B41DA8; + info->D_80B41DAC_copy = D_80B41DAC; + info->D_80B4A1B0_copy = D_80B4A1B0; + info->D_80B4A1B4_copy = D_80B4A1B4; + info->D_80B5A468_copy = D_80B5A468; + info->D_80B5A494_copy = D_80B5A494; + info->D_80B5A4BC_copy = D_80B5A4BC; + info->sKankyoIsSpawned_copy = sKankyoIsSpawned; + info->sTrailingFairies_copy = sTrailingFairies; + +} + +void SaveState::LoadOverlayStaticData(void) { + sBgDdanKdVelocity = info->sBgDdanKdVelocity_copy; + sBgDdanKdAccel = info->sBgDdanKdAccel_copy; + sBgDodoagoFirstExplosiveFlag = info->sBgDodoagoFirstExplosiveFlag_copy; + sBgDodoagoDisableBombCatcher = info->sBgDodoagoDisableBombCatcher_copy; + sBgDodoagoTimer = info->sBgDodoagoTimer_copy; + D_80880F30 = info->D_80880F30_copy; + D_80881014 = info->D_80881014_copy; + D_8088BFC0 = info->D_8088BFC0_copy; + sBgMoriHineriNextCamIdx = info->sBgMoriHineriNextCamIdx_copy; + sBgPoEventBlocksAtRest = info->sBgPoEventBlocksAtRest_copy; + sBgPoEventPuzzleState = info->sBgPoEventPuzzleState_copy; + sBgPoEventblockPushDist = info->sBgPoEventblockPushDist_copy; + D_808A9508 = info->D_808A9508_copy; + D_808B85D0 = info->D_808B85D0_copy; + sBossGanonSeed1 = info->sBossGanonSeed1_copy; + sBossGanonSeed2 = info->sBossGanonSeed2_copy; + sBossGanonSeed3 = info->sBossGanonSeed3_copy; + sBossGanonGanondorf = info->sBossGanonGanondorf_copy; + sBossGanonZelda = info->sBossGanonZelda_copy; + sBossGanonCape = info->sBossGanonCape_copy; + memcpy(sBossGanonEffectBuf, info->sBossGanonEffectBuf_copy, sizeof(info->sBossGanonEffectBuf_copy)); + + D_8090EB20 = info->D_8090EB20_copy; + D_80910638 = info->D_80910638_copy; + sBossGanon2Zelda = info->sBossGanon2Zelda_copy; + D_8090EB30 = info->D_8090EB30_copy; + sBossGanon2Seed1 = info->sBossGanon2Seed1_copy; + sBossGanon2Seed2 = info->sBossGanon2Seed2_copy; + sBossGanon2Seed3 = info->sBossGanon2Seed3_copy; + memcpy(D_809105D8, info->D_809105D8_copy, sizeof(D_809105D8)); + memcpy(D_80910608, info->D_80910608_copy, sizeof(D_80910608)); + memcpy(sBossGanon2Particles, info->sBossGanon2Particles_copy, sizeof(sBossGanon2Particles)); + sTwInitalized = info->sTwInitalized_copy; + memcpy(sTwEffects, info->sTwEffects_copy, sizeof(sTwEffects)); + sDemo6kVelocity = info->sDemo6kVelocity_copy; + + D_8096CE94 = info->D_8096CE94_copy; + demoKekkaiVel = info->demoKekkaiVel_copy; + sSlugGroup = info->sSlugGroup_copy; + sClearTagIsEffectsInitialized = info->sClearTagIsEffectInitialized_copy; + memcpy(sClearTagEffects, info->sClearTagEffects_copy, sizeof(sClearTagEffects)); + + D_80A7DEB0 = info->D_80A7DEB0_copy; + D_80A7DEB4 = info->D_80A7DEB4_copy; + D_80A7DEB8 = info->D_80A7DEB8_copy; + sRockRotSpeedX = info->sRockRotSpeedX_copy; + sRockRotSpeedY = info->sRockRotSpeedY_copy; + D_80AB85E0 = info->D_80AB85E0_copy; + sLowerRiverSpawned = info->sLowerRiverSpawned_copy; + sUpperRiverSpawned = info->sUpperRiverSpawned_copy; + sEnPoFieldNumSpawned = info->sEnPoFieldNumSpawned_copy; + memcpy(sEnPoFieldSpawnPositions, info->sEnPoFieldSpawnPositions_copy, sizeof(info->sEnPoFieldSpawnPositions_copy)); + memcpy(sEnPoFieldSpawnSwitchFlags, info->sEnPoFieldSpawnSwitchFlags_copy, sizeof(info->sEnPoFieldSpawnSwitchFlags_copy)); + + sTakaraIsInitialized = info->sTakaraIsInitialized_copy; + D_80B41D90 = info->D_80B41D90_copy; + sEnXcFlameSpawned = info->sEnXcFlameSpawned_copy; + D_80B41DA8 = info->D_80B41DA8_copy; + D_80B41DAC = info->D_80B41DAC_copy; + D_80B4A1B0 = info->D_80B4A1B0_copy; + D_80B4A1B4 = info->D_80B4A1B4_copy; + D_80B5A468 = info->D_80B5A468_copy; + D_80B5A494 = info->D_80B5A494_copy; + D_80B5A4BC = info->D_80B5A4BC_copy; + sKankyoIsSpawned = info->sKankyoIsSpawned_copy; + sTrailingFairies = info->sTrailingFairies_copy; +} + +void SaveState::SaveMiscCodeData(void) { + info->gGameOverTimer_copy = gGameOverTimer; + info->gTimeIncrement_copy = gTimeIncrement; + info->sLoadedMarkDataTableCopy = sLoadedMarkDataTable; + + info->sPlayerInitialPosX_copy = sPlayerInitialPosX; + info->sPlayerInitialPosZ_copy = sPlayerInitialPosZ; + info->sPlayerInitialDirection_copy = sPlayerInitialDirection; + + info->sOcarinaInpEnabled_copy = sOcarinaInpEnabled; + info->D_80130F10_copy = D_80130F10; + info->sCurOcarinaBtnVal_copy = sCurOcarinaBtnVal; + info->sPrevOcarinaNoteVal_copy = sPrevOcarinaNoteVal; + info->sCurOcarinaBtnIdx_copy = sCurOcarinaBtnIdx; + info->sLearnSongLastBtn_copy = sLearnSongLastBtn; + info->D_80130F24_copy = D_80130F24; + info->D_80130F28_copy = D_80130F28; + info->D_80130F2C_copy = D_80130F2C; + info->D_80130F30_copy = D_80130F30; + info->D_80130F34_copy = D_80130F34; + info->sPlaybackState_copy = sPlaybackState; + info->D_80130F3C_copy = D_80130F3C; + info->sNotePlaybackTimer_copy = sNotePlaybackTimer; + info->sPlaybackNotePos_copy = sPlaybackNotePos; + info->sStaffPlaybackPos_copy = sStaffPlaybackPos; + + + info->sCurOcarinaBtnPress_copy = sCurOcarinaBtnPress; + info->D_8016BA10_copy = D_8016BA10; + info->sPrevOcarinaBtnPress_copy = sPrevOcarinaBtnPress; + info->D_8016BA18_copy = D_8016BA18; + info->D_8016BA1C_copy = D_8016BA1C; + memcpy(info->sCurOcarinaSong_copy, sCurOcarinaSong, sizeof(sCurOcarinaSong)); + info->sOcarinaSongAppendPos_copy = sOcarinaSongAppendPos; + info->sOcarinaHasStartedSong_copy = sOcarinaHasStartedSong; + info->sOcarinaSongNoteStartIdx_copy = sOcarinaSongNoteStartIdx; + info->sOcarinaSongCnt_copy = sOcarinaSongCnt; + info->sOcarinaAvailSongs_copy = sOcarinaAvailSongs; + info->sStaffPlayingPos_copy = sStaffPlayingPos; + memcpy(info->sLearnSongPos_copy, sLearnSongPos, sizeof(sLearnSongPos)); + memcpy(info->D_8016BA50_copy, D_8016BA50, sizeof(D_8016BA50)); + memcpy(info->D_8016BA70_copy, D_8016BA70, sizeof(D_8016BA70)); + memcpy(info->sLearnSongExpectedNote_copy, sLearnSongExpectedNote, sizeof(sLearnSongExpectedNote)); + memcpy(&info->D_8016BAA0_copy, &D_8016BAA0, sizeof(D_8016BAA0)); + info->sAudioHasMalonBgm_copy = sAudioHasMalonBgm; + info->sAudioMalonBgmDist_copy = sAudioMalonBgmDist; + info->sDisplayedNoteValue_copy = sDisplayedNoteValue; + + + info->sOcarinaNoteBufPos_copy = sOcarinaNoteBufPos; + info->sOcarinaNoteBufLen_copy = sOcarinaNoteBufLen; + memcpy(info->sOcarinaNoteBuf_copy, sOcarinaNoteBuf, sizeof(sOcarinaNoteBuf)); + info->D_8014B2F4_copy = D_8014B2F4; + info->sTextboxSkipped_copy = sTextboxSkipped; + info->sNextTextId_copy = sNextTextId; + info->sLastPlayedSong_copy = sLastPlayedSong; + info->sHasSunsSong_copy = sHasSunsSong; + info->sMessageHasSetSfx_copy = sMessageHasSetSfx; + info->sOcarinaSongBitFlags_copy = sOcarinaSongBitFlags; +} + +void SaveState::LoadMiscCodeData(void) { + gGameOverTimer = info->gGameOverTimer_copy; + gTimeIncrement = info->gTimeIncrement_copy; + sLoadedMarkDataTable = info->sLoadedMarkDataTableCopy; + + sPlayerInitialPosX = info->sPlayerInitialPosX_copy; + sPlayerInitialPosZ = info->sPlayerInitialPosZ_copy; + sPlayerInitialDirection = info->sPlayerInitialDirection_copy; + + sOcarinaInpEnabled = info->sOcarinaInpEnabled_copy; + D_80130F10 = info->D_80130F10_copy; + sCurOcarinaBtnVal = info->sCurOcarinaBtnVal_copy; + sPrevOcarinaNoteVal = info->sPrevOcarinaNoteVal_copy; + sCurOcarinaBtnIdx = info->sCurOcarinaBtnIdx_copy; + sLearnSongLastBtn = info->sLearnSongLastBtn_copy; + D_80130F24 = info->D_80130F24_copy; + D_80130F28 = info->D_80130F28_copy; + D_80130F2C = info->D_80130F2C_copy; + D_80130F30 = info->D_80130F30_copy; + D_80130F34 = info->D_80130F34_copy; + sPlaybackState = info->sPlaybackState_copy; + D_80130F3C = info->D_80130F3C_copy; + sNotePlaybackTimer = info->sNotePlaybackTimer_copy; + sPlaybackNotePos = info->sPlaybackNotePos_copy; + sStaffPlaybackPos = info->sStaffPlaybackPos_copy; + + sCurOcarinaBtnPress = info->sCurOcarinaBtnPress_copy; + D_8016BA10 = info->D_8016BA10_copy; + sPrevOcarinaBtnPress = info->sPrevOcarinaBtnPress_copy; + D_8016BA18 = info->D_8016BA18_copy; + D_8016BA1C = info->D_8016BA1C_copy; + memcpy(sCurOcarinaSong, info->sCurOcarinaSong_copy, sizeof(sCurOcarinaSong)); + sOcarinaSongAppendPos = info->sOcarinaSongAppendPos_copy; + sOcarinaHasStartedSong = info->sOcarinaHasStartedSong_copy; + sOcarinaSongNoteStartIdx = info->sOcarinaSongNoteStartIdx_copy; + sOcarinaSongCnt = info->sOcarinaSongCnt_copy; + sOcarinaAvailSongs = info->sOcarinaAvailSongs_copy; + sStaffPlayingPos = info->sStaffPlayingPos_copy; + memcpy(info->sLearnSongPos_copy, info->sLearnSongPos_copy, sizeof(sLearnSongPos)); + memcpy(info->D_8016BA50_copy, info->D_8016BA50_copy, sizeof(D_8016BA50)); + memcpy(info->D_8016BA70_copy, info->D_8016BA70_copy, sizeof(D_8016BA70)); + memcpy(info->sLearnSongExpectedNote_copy, info->sLearnSongExpectedNote_copy, sizeof(sLearnSongExpectedNote)); + memcpy(&D_8016BAA0, &info->D_8016BAA0_copy, sizeof(D_8016BAA0)); + sAudioHasMalonBgm = info->sAudioHasMalonBgm_copy; + sAudioMalonBgmDist = info->sAudioMalonBgmDist_copy; + sDisplayedNoteValue = info->sDisplayedNoteValue_copy; + + sOcarinaNoteBufPos = info->sOcarinaNoteBufPos_copy; + sOcarinaNoteBufLen = info->sOcarinaNoteBufLen_copy; + memcpy(sOcarinaNoteBuf, info->sOcarinaNoteBuf_copy, sizeof(sOcarinaNoteBuf)); + + D_8014B2F4 = info->D_8014B2F4_copy; + sTextboxSkipped = info->sTextboxSkipped_copy; + sNextTextId = info->sNextTextId_copy; + sLastPlayedSong = info->sLastPlayedSong_copy; + sHasSunsSong = info->sHasSunsSong_copy; + sMessageHasSetSfx = info->sMessageHasSetSfx_copy; + sOcarinaSongBitFlags = info->sOcarinaSongBitFlags_copy; + + +} + +extern "C" void ProcessSaveStateRequests(void) { + OTRGlobals::Instance->gSaveStateMgr->ProcessSaveStateRequests(); +} + +void SaveStateMgr::SetCurrentSlot(unsigned int slot) { + SohImGui::overlay->TextDrawNotification(1.0f, true, "slot %u set", slot); + this->currentSlot = slot; +} + +unsigned int SaveStateMgr::GetCurrentSlot(void) { + return this->currentSlot; +} + +void SaveStateMgr::ProcessSaveStateRequests(void) { + while (!this->requests.empty()) { + const auto& request = this->requests.front(); + + switch (request.type) { + case RequestType::SAVE: + if (!this->states.contains(request.slot)) { + this->states[request.slot] = std::make_shared(OTRGlobals::Instance->gSaveStateMgr, request.slot); + } + this->states[request.slot]->Save(); + SohImGui::overlay->TextDrawNotification(1.0f, true, "saved state %u", request.slot); + break; + case RequestType::LOAD: + if (this->states.contains(request.slot)) { + this->states[request.slot]->Load(); + SohImGui::overlay->TextDrawNotification(1.0f, true, "loaded state %u", request.slot); + } else { + SPDLOG_ERROR("Invalid SaveState slot: {}", request.type); + } + break; + [[unlikely]] default: + SPDLOG_ERROR("Invalid SaveState request type: {}", request.type); + break; + } + this->requests.pop(); + } +} + +SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) { + if (gGlobalCtx == nullptr) { + SPDLOG_ERROR("[SOH] Can not save or load a state outside of \"GamePlay\""); + SohImGui::overlay->TextDrawNotification(1.0f, true, "states not available here", request.slot); + return SaveStateReturn::FAIL_WRONG_GAMESTATE; + } + + switch (request.type) { + case RequestType::SAVE: + requests.push(request); + break; + case RequestType::LOAD: + if (states.contains(request.slot)) { + requests.push(request); + } else { + SPDLOG_ERROR("Invalid SaveState slot: {}", request.type); + SohImGui::overlay->TextDrawNotification(1.0f, true, "state slot %u empty", request.slot); + return SaveStateReturn::FAIL_INVALID_SLOT; + } + break; + [[unlikely]] default: + SPDLOG_ERROR("Invalid SaveState request type: {}", request.type); + return SaveStateReturn::FAIL_BAD_REQUEST; + break; + + } +} + +void SaveState::Save(void) { + std::unique_lock Lock(audio.mutex); + memcpy(&info->sysHeapCopy, gSystemHeap, SYSTEM_HEAP_SIZE /* sizeof(gSystemHeap) */); + memcpy(&info->audioHeapCopy, gAudioHeap, AUDIO_HEAP_SIZE /* sizeof(gAudioContext) */); + + memcpy(&info->audioContextCopy, &gAudioContext, sizeof(AudioContext)); + memcpy(&info->unk_D_8016E750Copy, D_8016E750, sizeof(info->unk_D_8016E750Copy)); + BackupSeqScriptState(); + + memcpy(info->gActiveSoundsCopy, gActiveSounds, sizeof(gActiveSounds)); + memcpy(&info->gSoundBankMutedCopy, gSoundBankMuted, sizeof(info->gSoundBankMutedCopy)); + + info->D_801333F0_copy = D_801333F0; + info->gAudioSfxSwapOff_copy = gAudioSfxSwapOff; + + memcpy(&info->gAudioSfxSwapSource_copy, gAudioSfxSwapSource, + sizeof(info->gAudioSfxSwapSource_copy)); + memcpy(&info->gAudioSfxSwapTarget_copy, gAudioSfxSwapTarget, + sizeof(info->gAudioSfxSwapTarget_copy)); + memcpy(&info->gAudioSfxSwapMode_copy, gAudioSfxSwapMode, + sizeof(info->gAudioSfxSwapMode_copy)); + + info->D_801755D0_copy = D_801755D0; + + memcpy(&info->saveContextCopy, &gSaveContext, sizeof(gSaveContext)); + memcpy(&info->gameInfoCopy, gGameInfo, sizeof(*gGameInfo)); + memcpy(&info->lightBufferCopy, &sLightsBuffer, sizeof(sLightsBuffer)); + memcpy(&info->mtxStackCopy, &sMatrixStack, sizeof(MtxF) * 20); + memcpy(&info->currentMtxCopy, &sCurrentMatrix, sizeof(MtxF)); + + //Various static data + info->blueWarpTimerCopy = sWarpTimerTarget; + BackupCameraData(); + SaveOnePointDemoData(); + SaveOverlayStaticData(); + SaveMiscCodeData(); + +} + +void SaveState::Load(void) { + std::unique_lock Lock(audio.mutex); + memcpy(gSystemHeap, &info->sysHeapCopy, SYSTEM_HEAP_SIZE); + memcpy(gAudioHeap, &info->audioHeapCopy, AUDIO_HEAP_SIZE); + + memcpy(&gAudioContext, &info->audioContextCopy, sizeof(AudioContext)); + memcpy(D_8016E750, &info->unk_D_8016E750Copy, sizeof(info->unk_D_8016E750Copy)); + LoadSeqScriptState(); + + memcpy(&gSaveContext, &info->saveContextCopy, sizeof(gSaveContext)); + memcpy(gGameInfo, &info->gameInfoCopy, sizeof(*gGameInfo)); + memcpy(&sLightsBuffer, &info->lightBufferCopy, sizeof(sLightsBuffer)); + memcpy(&sMatrixStack, &info->mtxStackCopy, sizeof(MtxF) * 20); + memcpy(&sCurrentMatrix, &info->currentMtxCopy, sizeof(MtxF)); + sWarpTimerTarget = info->blueWarpTimerCopy; + + memcpy(gActiveSounds, info->gActiveSoundsCopy, sizeof(gActiveSounds)); + memcpy(gSoundBankMuted, &info->gSoundBankMutedCopy, sizeof(info->gSoundBankMutedCopy)); + D_801333F0 = info->D_801333F0_copy; + gAudioSfxSwapOff = info->gAudioSfxSwapOff_copy; + + memcpy(gAudioSfxSwapSource, &info->gAudioSfxSwapSource_copy, + sizeof(info->gAudioSfxSwapSource_copy)); + memcpy(gAudioSfxSwapTarget, &info->gAudioSfxSwapTarget_copy, + sizeof(info->gAudioSfxSwapTarget_copy)); + memcpy(gAudioSfxSwapMode, &info->gAudioSfxSwapMode_copy, + sizeof(info->gAudioSfxSwapMode_copy)); + + //Various static data + D_801755D0 = info->D_801755D0_copy; + LoadCameraData(); + LoadOnePointDemoData(); + LoadOverlayStaticData(); + LoadMiscCodeData(); + +} diff --git a/soh/soh/Enhancements/savestates.h b/soh/soh/Enhancements/savestates.h new file mode 100644 index 000000000..4ac142172 --- /dev/null +++ b/soh/soh/Enhancements/savestates.h @@ -0,0 +1,62 @@ +#ifndef SAVE_STATES_H +#define SAVE_STATES_H + +#include +#include +#include +#include +#include + +enum class SaveStateReturn { + SUCCESS, + FAIL_INVALID_SLOT, + FAIL_NO_MEMORY, + FAIL_STATE_EMPTY, + FAIL_WRONG_GAMESTATE, + FAIL_BAD_REQUEST, +}; + +typedef struct SaveStateHeader { + uint32_t stateMagic; + uint32_t stateVersion; + //uint32_t gameVersion; +} SaveStateHeader; + +enum class RequestType { + SAVE, + LOAD, +}; + +typedef struct SaveStateRequest { + unsigned int slot; + RequestType type; +} SaveStateRequest; + +class SaveState; + +class SaveStateMgr { + friend class SaveState; + private: + unsigned int currentSlot; + std::unordered_map> states; + std::queue requests; + std::mutex mutex; + + public: + + SaveStateReturn AddRequest(const SaveStateRequest request); + SaveStateMgr(); + ~SaveStateMgr(); + + void SetCurrentSlot(unsigned int slot); + unsigned int GetCurrentSlot(void); + + SaveStateMgr& operator=(const SaveStateMgr& rhs) = delete; + SaveStateMgr(const SaveStateMgr& rhs) = delete; + + void ProcessSaveStateRequests(void); + +}; +extern std::shared_ptr gSaveStateMgr; + +#endif diff --git a/soh/soh/Enhancements/savestates_extern.inc b/soh/soh/Enhancements/savestates_extern.inc new file mode 100644 index 000000000..c3b129a32 --- /dev/null +++ b/soh/soh/Enhancements/savestates_extern.inc @@ -0,0 +1,257 @@ +extern "C" MtxF* sMatrixStack; +extern "C" MtxF* sCurrentMatrix; +extern "C" LightsBuffer sLightsBuffer; +extern "C" s16 sWarpTimerTarget; +extern "C" MapMarkData** sLoadedMarkDataTable; + +//Camera static data +extern "C" int32_t sInitRegs; +extern "C" int32_t gDbgCamEnabled; +extern "C" int32_t sDbgModeIdx; +extern "C" int16_t sNextUID; +extern "C" int32_t sCameraInterfaceFlags; +extern "C" int32_t sCameraInterfaceAlpha; +extern "C" int32_t sCameraShrinkWindowVal; +extern "C" int32_t D_8011D3AC; +extern "C" int32_t sDemo5PrevAction12Frame; +extern "C" int32_t sDemo5PrevSfxFrame; +extern "C" int32_t D_8011D3F0; +extern "C" OnePointCsFull D_8011D6AC[]; +extern "C" OnePointCsFull D_8011D724[]; +extern "C" OnePointCsFull D_8011D79C[]; +extern "C" OnePointCsFull D_8011D83C[]; +extern "C" OnePointCsFull D_8011D88C[]; +extern "C" OnePointCsFull D_8011D8DC[]; +extern "C" OnePointCsFull D_8011D954[]; +extern "C" OnePointCsFull D_8011D9F4[]; +extern "C" int16_t D_8011DB08; +extern "C" int16_t D_8011DB0C; +extern "C" int32_t sOOBTimer; +extern "C" f32 D_8015CE50; +extern "C" f32 D_8015CE54; +extern "C" CamColChk D_8015CE58; + +//Gameover +extern "C" uint16_t gGameOverTimer; + +//One Point Demo +extern "C" uint32_t sPrevFrameCs1100; +extern "C" CutsceneCameraPoint D_8012013C[14]; +extern "C" CutsceneCameraPoint D_8012021C[14]; +extern "C" CutsceneCameraPoint D_801204D4[14]; +extern "C" CutsceneCameraPoint D_801205B4[14]; +extern "C" OnePointCsFull D_801208EC[3]; +extern "C" OnePointCsFull D_80120964[2]; +extern "C" OnePointCsFull D_801209B4[4]; +extern "C" OnePointCsFull D_80120ACC[5]; +extern "C" OnePointCsFull D_80120B94[11]; +extern "C" OnePointCsFull D_80120D4C[7]; +extern "C" OnePointCsFull D_80120FA4[6]; +extern "C" OnePointCsFull D_80121184[2]; +extern "C" OnePointCsFull D_801211D4[2]; +extern "C" OnePointCsFull D_8012133C[3]; +extern "C" OnePointCsFull D_801213B4[5]; +extern "C" OnePointCsFull D_8012151C[2]; +extern "C" OnePointCsFull D_8012156C[2]; +extern "C" OnePointCsFull D_801215BC[1]; +extern "C" OnePointCsFull D_80121C24[7]; +extern "C" OnePointCsFull D_80121D3C[3]; +extern "C" OnePointCsFull D_80121F1C[4]; +extern "C" OnePointCsFull D_80121FBC[4]; +extern "C" OnePointCsFull D_801220D4[5]; +extern "C" OnePointCsFull D_80122714[4]; +extern "C" OnePointCsFull D_80122CB4[2]; +extern "C" OnePointCsFull D_80122D04[2]; +extern "C" OnePointCsFull D_80122E44[2][7]; +extern "C" OnePointCsFull D_8012313C[3]; +extern "C" OnePointCsFull D_801231B4[4]; +extern "C" OnePointCsFull D_80123254[2]; +extern "C" OnePointCsFull D_801232A4[1]; +extern "C" OnePointCsFull D_80123894[3]; +extern "C" OnePointCsFull D_8012390C[2]; +extern "C" OnePointCsFull D_8012395C[3]; +extern "C" OnePointCsFull D_801239D4[3]; + +// z_bg_ddan_kd +extern "C" Vec3f sBgDdanKdVelocity; +extern "C" Vec3f sBgDdanKdAccel; + +// z_bg_dodoago +extern "C" s16 sBgDodoagoFirstExplosiveFlag; +extern "C" u8 sBgDodoagoDisableBombCatcher; +extern "C" s32 sBgDodoagoTimer; + +// z_bg_haka_trap +extern "C" uint32_t D_80880F30; +extern "C" uint32_t D_80881014; + +// z_bg_hidan_rock +extern "C" float D_8088BFC0; + +// z_bg_menkuri_eye +extern "C" int32_t D_8089C1A0; + +// z_bg_mori_hineri +extern "C" int16_t sBgMoriHineriNextCamIdx; + +// z_bg_po_event +extern "C" uint8_t sBgPoEventBlocksAtRest; +extern "C" uint8_t sBgPoEventPuzzleState; +extern "C" float sBgPoEventblockPushDist; + +// z_bg_relay_objects +extern "C" uint32_t D_808A9508; + +// z_bg_spot18_basket +extern "C" int16_t D_808B85D0; + +// z_boss_ganon +extern "C" uint32_t sBossGanonSeed1; +extern "C" uint32_t sBossGanonSeed2; +extern "C" uint32_t sBossGanonSeed3; +extern "C" void* sBossGanonGanondorf; +extern "C" void* sBossGanonZelda; +extern "C" void* sBossGanonCape; +extern "C" GanondorfEffect sBossGanonEffectBuf[200]; + +// z_boss_ganon2 +extern "C" Vec3f D_8090EB20; +extern "C" int8_t D_80910638; +extern "C" void* sBossGanon2Zelda; +extern "C" void* D_8090EB30; +extern "C" int32_t sBossGanon2Seed1; +extern "C" int32_t sBossGanon2Seed2; +extern "C" int32_t sBossGanon2Seed3; +extern "C" Vec3f D_809105D8[4]; +extern "C" Vec3f D_80910608[4]; +extern "C" BossGanon2Effect sBossGanon2Particles[100]; + +// z_boss_tw +extern "C" uint8_t sTwInitalized; +extern "C" BossTwEffect sTwEffects[150]; + +// z_demo_6k +extern "C" Vec3f sDemo6kVelocity; + +// z_demo_du +extern "C" int32_t D_8096CE94; + +// z_demo_kekkai +extern "C" Vec3f demoKekkaiVel; + +// z_en_bw +extern "C" int32_t sSlugGroup; + +// z_en_clear_tag +extern "C" uint8_t sClearTagIsEffectsInitialized; +extern "C" EnClearTagEffect sClearTagEffects[CLEAR_TAG_EFFECT_MAX_COUNT]; + +// z_en_fr +extern "C" EnFrPointers sEnFrPointers; + +// z_en_goma +extern "C" uint8_t sSpawnNum; + +// z_en_in +extern "C" int32_t D_80A7B998; + +// z_en_insect +extern "C" float D_80A7DEB0; +extern "C" int16_t D_80A7DEB4; +extern "C" int16_t D_80A7DEB8; + +// z_en_ishi +extern "C" int16_t sRockRotSpeedX; +extern "C" int16_t sRockRotSpeedY; + +// z_en_niw +extern "C" int16_t D_80AB85E0; +extern "C" uint8_t sLowerRiverSpawned; +extern "C" uint8_t sUpperRiverSpawned; + +// z_en_po_field +extern "C" int32_t sEnPoFieldNumSpawned; +extern "C" Vec3s sEnPoFieldSpawnPositions[10]; +extern "C" u8 sEnPoFieldSpawnSwitchFlags[10]; + +// z_en_takara_man +extern "C" uint8_t sTakaraIsInitialized; + +// z_en_xc +extern "C" int32_t D_80B41D90; +extern "C" int32_t sEnXcFlameSpawned; +extern "C" int32_t D_80B41DA8; +extern "C" int32_t D_80B41DAC; + +// z_en_zf +extern "C" int16_t D_80B4A1B0; +extern "C" int16_t D_80B4A1B4; + +extern "C" int32_t D_80B5A468; +extern "C" int32_t D_80B5A494; +extern "C" int32_t D_80B5A4BC; + +extern "C" uint8_t sKankyoIsSpawned; +extern "C" int16_t sTrailingFairies; + +extern "C" uint16_t gTimeIncrement; + +extern "C" s16 sPlayerInitialPosX; +extern "C" s16 sPlayerInitialPosZ; +extern "C" s16 sPlayerInitialDirection; + +// code_800EC960 +// Related to ocarina +extern "C" u8 sOcarinaInpEnabled; +extern "C" s8 D_80130F10; +extern "C" u8 sCurOcarinaBtnVal; +extern "C" u8 sPrevOcarinaNoteVal; +extern "C" u8 sCurOcarinaBtnIdx; +extern "C" u8 sLearnSongLastBtn; +extern "C" f32 D_80130F24; +extern "C" f32 D_80130F28; +extern "C" s8 D_80130F2C; +extern "C" s8 D_80130F30; +extern "C" s8 D_80130F34; +extern "C" u8 sPlaybackState; +extern "C" u32 D_80130F3C; +extern "C" u32 sNotePlaybackTimer; +extern "C" u16 sPlaybackNotePos; +extern "C" u16 sStaffPlaybackPos; + +//IDK what this is but it looks important +extern "C" u32 sCurOcarinaBtnPress; +extern "C" u32 D_8016BA10; +extern "C" u32 sPrevOcarinaBtnPress; +extern "C" s32 D_8016BA18; +extern "C" s32 D_8016BA1C; +extern "C" u8 sCurOcarinaSong[8]; +extern "C" u8 sOcarinaSongAppendPos; +extern "C" u8 sOcarinaHasStartedSong; +extern "C" u8 sOcarinaSongNoteStartIdx; +extern "C" u8 sOcarinaSongCnt; +extern "C" u16 sOcarinaAvailSongs; +extern "C" u8 sStaffPlayingPos; +extern "C" u16 sLearnSongPos[0x10]; +extern "C" u16 D_8016BA50[0x10]; +extern "C" u16 D_8016BA70[0x10]; +extern "C" u8 sLearnSongExpectedNote[0x10]; +extern "C" OcarinaNote D_8016BAA0; +extern "C" u8 sAudioHasMalonBgm; +extern "C" f32 sAudioMalonBgmDist; +extern "C" u8 sDisplayedNoteValue; + + + +// z_message_PAL +extern "C" s16 sOcarinaNoteBufPos; +extern "C" s16 sOcarinaNoteBufLen; +extern "C" u8 sOcarinaNoteBuf[12]; + +extern "C" u8 D_8014B2F4; +extern "C" u8 sTextboxSkipped; +extern "C" u16 sNextTextId; +extern "C" s16 sLastPlayedSong; +extern "C" s16 sHasSunsSong; +extern "C" s16 sMessageHasSetSfx; +extern "C" u16 sOcarinaSongBitFlags; \ No newline at end of file diff --git a/soh/soh/OTRAudio.h b/soh/soh/OTRAudio.h new file mode 100644 index 000000000..ee0ec46a2 --- /dev/null +++ b/soh/soh/OTRAudio.h @@ -0,0 +1,8 @@ +#pragma once + +static struct { + std::condition_variable cv_to_thread, cv_from_thread; + std::mutex mutex; + bool initialized; + bool processing; +} audio; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index d2bc941cf..7456ebf7e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1,4 +1,5 @@ #include "OTRGlobals.h" +#include "OTRAudio.h" #include #include #include @@ -11,10 +12,14 @@ #include "Window.h" #include "z64animation.h" #include "z64bgcheck.h" -#include "../soh/enhancements/gameconsole.h" +#include "Enhancements/gameconsole.h" #include #include +#ifdef _WIN32 #include +#else +#include +#endif #include #include #include @@ -22,23 +27,21 @@ #include #include "Lib/stb/stb_image.h" #include "AudioPlayer.h" -#include "../soh/Enhancements/debugconsole.h" -#include "../soh/Enhancements/debugger/debugger.h" +#include "Enhancements/debugconsole.h" +#include "Enhancements/debugger/debugger.h" #include "Utils/BitConverter.h" #include "variables.h" +#include "macros.h" #include +#include + OTRGlobals* OTRGlobals::Instance; -static struct { - std::condition_variable cv_to_thread, cv_from_thread; - std::mutex mutex; - bool initialized; - bool processing; -} audio; - OTRGlobals::OTRGlobals() { + context = Ship::GlobalCtx2::CreateInstance("Ship of Harkinian"); + gSaveStateMgr = std::make_shared(); context->GetWindow()->Init(); } @@ -59,7 +62,7 @@ extern "C" void InitOTR() { OTRGlobals::Instance = new OTRGlobals(); auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version"); - if (!t->bHasLoadError) + if (!t->bHasLoadError) { //uint32_t gameVersion = BitConverter::ToUInt32BE((uint8_t*)t->buffer.get(), 0); uint32_t gameVersion = *((uint32_t*)t->buffer.get()); @@ -72,6 +75,7 @@ extern "C" void InitOTR() { Debug_Init(); } +#ifdef _WIN32 extern "C" uint64_t GetFrequency() { LARGE_INTEGER nFreq; @@ -86,6 +90,21 @@ extern "C" uint64_t GetPerfCounter() { return ticks.QuadPart; } +#else +extern "C" uint64_t GetFrequency() { + return 1000; // sec -> ms +} + +extern "C" uint64_t GetPerfCounter() { + struct timespec monotime; + clock_gettime(CLOCK_MONOTONIC, &monotime); + + uint64_t remainingMs = (monotime.tv_nsec / 1000000); + + // in milliseconds + return monotime.tv_sec * 1000 + remainingMs; +} +#endif // C->C++ Bridge extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) { @@ -93,6 +112,63 @@ extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) { } extern "C" void Graph_StartFrame() { + // Why -1? + int32_t dwScancode = OTRGlobals::Instance->context->GetWindow()->lastScancode; + OTRGlobals::Instance->context->GetWindow()->lastScancode = -1; + + switch (dwScancode - 1) { + case SDL_SCANCODE_F5: { + const unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); + const SaveStateReturn stateReturn = + OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::SAVE }); + + switch (stateReturn) { + case SaveStateReturn::SUCCESS: + SPDLOG_INFO("[SOH] Saved state to slot {}", slot); + break; + case SaveStateReturn::FAIL_WRONG_GAMESTATE: + SPDLOG_ERROR("[SOH] Can not save a state outside of \"GamePlay\""); + break; + [[unlikely]] default: + break; + } + break; + } + case SDL_SCANCODE_F6: { + unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); + slot++; + if (slot > 5) { + slot = 0; + } + OTRGlobals::Instance->gSaveStateMgr->SetCurrentSlot(slot); + SPDLOG_INFO("Set SaveState slot to {}.", slot); + break; + } + case SDL_SCANCODE_F7: { + const unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); + const SaveStateReturn stateReturn = + OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::LOAD }); + + switch (stateReturn) { + case SaveStateReturn::SUCCESS: + SPDLOG_INFO("[SOH] Loaded state from slot {}", slot); + break; + case SaveStateReturn::FAIL_INVALID_SLOT: + SPDLOG_ERROR("[SOH] Invalid State Slot Number {}", slot); + break; + case SaveStateReturn::FAIL_STATE_EMPTY: + SPDLOG_ERROR("[SOH] State Slot {} is empty", slot); + break; + case SaveStateReturn::FAIL_WRONG_GAMESTATE: + SPDLOG_ERROR("[SOH] Can not load a state outside of \"GamePlay\""); + break; + [[unlikely]] default: + break; + } + + break; + } + } OTRGlobals::Instance->context->GetWindow()->StartFrame(); } @@ -110,6 +186,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { audio.cv_to_thread.wait(Lock); } } + std::unique_lock Lock(audio.mutex); //AudioMgr_ThreadEntry(&gAudioMgr); // 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333.. // in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528 @@ -135,10 +212,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { // printf("Audio samples before submitting: %d\n", audio_api->buffered()); AudioPlayer_Play((u8*)audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE)); - { - std::unique_lock Lock(audio.mutex); - audio.processing = false; - } + audio.processing = false; audio.cv_from_thread.notify_one(); } }).detach(); @@ -185,7 +259,7 @@ extern "C" void OTRResetScancode() OTRGlobals::Instance->context->GetWindow()->lastScancode = -1; } -extern "C" uint32_t ResourceMgr_GetGameVersion() +extern "C" uint32_t ResourceMgr_GetGameVersion() { return OTRGlobals::Instance->context->GetResourceManager()->GetGameVersion(); } @@ -289,6 +363,13 @@ extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path) return (Gfx*)&res->instructions[0]; } +extern "C" Gfx* ResourceMgr_PatchGfxByName(const char* path, int size) { + auto res = std::static_pointer_cast( + OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); + res->instructions.resize(res->instructions.size() + size); + return (Gfx*)&res->instructions[0]; +} + extern "C" char* ResourceMgr_LoadArrayByName(const char* path) { auto res = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); @@ -302,7 +383,7 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) { if (res->cachedGameAsset != nullptr) return (char*)res->cachedGameAsset; - else + else { Vec3s* data = (Vec3s*)malloc(sizeof(Vec3s) * res->scalars.size()); @@ -422,7 +503,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData) { uintptr_t i = (uintptr_t)(imgData); - if (i == 0xD9000000 || i == 0xE7000000 || (i & 0xF0000000) == 0xF0000000) + if (i == 0xD9000000 || i == 0xE7000000 || (i & 1) == 1) return 0; if ((i & 0xFF000000) != 0xAB000000 && (i & 0xFF000000) != 0xCD000000 && i != 0) { @@ -816,24 +897,24 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) { } extern "C" void bswapSoundFontSound(SoundFontSound* swappable) { - swappable->sample = (SoundFontSample*)_byteswap_ulong((u32)swappable->sample); - swappable->tuningAsU32 = _byteswap_ulong((u32)swappable->tuningAsU32); + swappable->sample = (SoundFontSample*)BOMSWAP32((u32)swappable->sample); + swappable->tuningAsU32 = BOMSWAP32((u32)swappable->tuningAsU32); } extern "C" void bswapDrum(Drum* swappable) { bswapSoundFontSound(&swappable->sound); - swappable->envelope = (AdsrEnvelope*)_byteswap_ulong((u32)swappable->envelope); + swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope); } extern "C" void bswapInstrument(Instrument* swappable) { - swappable->envelope = (AdsrEnvelope*)_byteswap_ulong((u32)swappable->envelope); + swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope); bswapSoundFontSound(&swappable->lowNotesSound); bswapSoundFontSound(&swappable->normalNotesSound); bswapSoundFontSound(&swappable->highNotesSound); } extern "C" void bswapSoundFontSample(SoundFontSample* swappable) { - u32 origBitfield = _byteswap_ulong(swappable->asU32); + u32 origBitfield = BOMSWAP32(swappable->asU32); swappable->codec = (origBitfield >> 28) & 0x0F; swappable->medium = (origBitfield >> 24) & 0x03; @@ -841,29 +922,29 @@ extern "C" void bswapSoundFontSample(SoundFontSample* swappable) { swappable->unk_bit25 = (origBitfield >> 21) & 0x01; swappable->size = (origBitfield) & 0x00FFFFFF; - swappable->sampleAddr = (u8*)_byteswap_ulong((u32)swappable->sampleAddr); - swappable->loop = (AdpcmLoop*)_byteswap_ulong((u32)swappable->loop); - swappable->book = (AdpcmBook*)_byteswap_ulong((u32)swappable->book); + swappable->sampleAddr = (u8*)BOMSWAP32((u32)swappable->sampleAddr); + swappable->loop = (AdpcmLoop*)BOMSWAP32((u32)swappable->loop); + swappable->book = (AdpcmBook*)BOMSWAP32((u32)swappable->book); } extern "C" void bswapAdpcmLoop(AdpcmLoop* swappable) { - swappable->start = (u32)_byteswap_ulong((u32)swappable->start); - swappable->end = (u32)_byteswap_ulong((u32)swappable->end); - swappable->count = (u32)_byteswap_ulong((u32)swappable->count); + swappable->start = (u32)BOMSWAP32((u32)swappable->start); + swappable->end = (u32)BOMSWAP32((u32)swappable->end); + swappable->count = (u32)BOMSWAP32((u32)swappable->count); if (swappable->count != 0) { for (int i = 0; i < 16; i++) { - swappable->state[i] = (s16)_byteswap_ushort(swappable->state[i]); + swappable->state[i] = (s16)BOMSWAP16(swappable->state[i]); } } } extern "C" void bswapAdpcmBook(AdpcmBook* swappable) { - swappable->order = (u32)_byteswap_ulong((u32)swappable->order); - swappable->npredictors = (u32)_byteswap_ulong((u32)swappable->npredictors); + swappable->order = (u32)BOMSWAP32((u32)swappable->order); + swappable->npredictors = (u32)BOMSWAP32((u32)swappable->npredictors); for (int i = 0; i < swappable->npredictors * swappable->order * sizeof(s16) * 4; i++) - swappable->book[i] = (s16)_byteswap_ushort(swappable->book[i]); + swappable->book[i] = (s16)BOMSWAP16(swappable->book[i]); } extern "C" bool AudioPlayer_Init(void) { @@ -893,7 +974,7 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) { } extern "C" int Controller_ShouldRumble(size_t i) { - for (const auto& controller : Ship::Window::Controllers.at(i)) + for (const auto& controller : Ship::Window::Controllers.at(i)) { float rumble_strength = CVar_GetFloat(StringHelper::Sprintf("gCont%i_RumbleStrength", i).c_str(), 1.0f); diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 7ce08649a..0a318de73 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -1,17 +1,22 @@ +#ifndef OTR_GLOBALS_H +#define OTR_GLOBALS_H + #pragma once #include "GlobalCtx2.h" #ifdef __cplusplus +#include "Enhancements/savestates.h" class OTRGlobals { public: - static OTRGlobals* Instance; + static OTRGlobals* Instance; - std::shared_ptr context; + std::shared_ptr context; + std::shared_ptr gSaveStateMgr; - OTRGlobals(); - ~OTRGlobals(); + OTRGlobals(); + ~OTRGlobals(); private: @@ -38,6 +43,7 @@ char* ResourceMgr_LoadPlayerAnimByName(const char* animPath); char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc); Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc); Gfx* ResourceMgr_LoadGfxByName(const char* path); +Gfx* ResourceMgr_PatchGfxByName(const char* path, int size); Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc); Vtx* ResourceMgr_LoadVtxByName(const char* path); CollisionHeader* ResourceMgr_LoadColByName(const char* path); @@ -67,3 +73,5 @@ void AudioPlayer_Play(const uint8_t* buf, uint32_t len); void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples); int Controller_ShouldRumble(size_t i); #endif + +#endif \ No newline at end of file diff --git a/soh/soh/stubs.c b/soh/soh/stubs.c index c47c1fa5d..98f3b4823 100644 --- a/soh/soh/stubs.c +++ b/soh/soh/stubs.c @@ -12,12 +12,12 @@ OSViMode osViModeNtscLan1; OSViMode osViModeMpalLan1; OSViMode osViModeFpalLan1; OSViMode osViModePalLan1; -AudioContext gAudioContext; -unk_D_8016E750 D_8016E750[4]; +// AudioContext gAudioContext; +// unk_D_8016E750 D_8016E750[4]; u8 gLetterTLUT[4][32]; u8 gFontFF[999]; DmaEntry gDmaDataTable[0x60C]; -u8 D_80133418; +// u8 D_80133418; u16 gAudioSEFlagSwapSource[64]; u16 gAudioSEFlagSwapTarget[64]; u8 gAudioSEFlagSwapMode[64]; diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index c84e37482..3e2a990d7 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -12,7 +12,7 @@ void OTRGameplay_InitScene(GlobalContext* globalCtx, s32 spawn); s32 OTRScene_ExecuteCommands(GlobalContext* globalCtx, Ship::Scene* sceneCmd); //Ship::OTRResource* OTRGameplay_LoadFile(GlobalContext* globalCtx, RomFile* file) { -Ship::Resource* OTRGameplay_LoadFile(GlobalContext* globalCtx, const char* fileName) +Ship::Resource* OTRGameplay_LoadFile(GlobalContext* globalCtx, const char* fileName) { auto res = OTRGlobals::Instance->context->GetResourceManager()->LoadResource(fileName); return res.get(); @@ -28,7 +28,7 @@ extern "C" void OTRGameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s //osSyncPrintf("\nSCENE SIZE %fK\n", (scene->sceneFile.vromEnd - scene->sceneFile.vromStart) / 1024.0f); - std::string scenePath = StringHelper::Sprintf("scenes\\%s\\%s", scene->sceneFile.fileName, scene->sceneFile.fileName); + std::string scenePath = StringHelper::Sprintf("scenes/%s/%s", scene->sceneFile.fileName, scene->sceneFile.fileName); globalCtx->sceneSegment = (Ship::Scene*)OTRGameplay_LoadFile(globalCtx, scenePath.c_str()); @@ -47,7 +47,7 @@ extern "C" void OTRGameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s //gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); OTRGameplay_InitScene(globalCtx, spawn); - + osSyncPrintf("ROOM SIZE=%fK\n", func_80096FE8(globalCtx, &globalCtx->roomCtx) / 1024.0f); } @@ -72,7 +72,7 @@ void OTRGameplay_InitScene(GlobalContext* globalCtx, s32 spawn) { ->GetResourceManager() ->LoadResource("object_link_child\\object_link_childVtx_01FE08") .get()); - + auto data2 = ResourceMgr_LoadVtxByCRC(0x68d4ea06044e228f);*/ volatile int a = 0; diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index f63df81e4..123f9c636 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -72,7 +72,7 @@ bool func_800985DC(GlobalContext* globalCtx, Ship::SceneCommand* cmd) { else { ActorEntry* entries = (ActorEntry*)malloc(cmdActor->entries.size() * sizeof(ActorEntry)); - + for (int i = 0; i < cmdActor->entries.size(); i++) { entries[i].id = cmdActor->entries[i].actorNum; @@ -241,7 +241,7 @@ bool func_800987F8(GlobalContext* globalCtx, Ship::SceneCommand* cmd) globalCtx->setupEntranceList[i].room = otrEntrance->entrances[i].roomToLoad; globalCtx->setupEntranceList[i].spawn = otrEntrance->entrances[i].startPositionIndex; } - + otrEntrance->cachedGameData = globalCtx->setupEntranceList; } @@ -252,11 +252,11 @@ bool func_800987F8(GlobalContext* globalCtx, Ship::SceneCommand* cmd) bool func_8009883C(GlobalContext* globalCtx, Ship::SceneCommand* cmd) { Ship::SetSpecialObjects* otrSpecial = (Ship::SetSpecialObjects*)cmd; - + if (otrSpecial->globalObject != 0) globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, otrSpecial->globalObject); - if (otrSpecial->elfMessage != 0) + if (otrSpecial->elfMessage != 0) { auto res = (Ship::Blob*)OTRGameplay_LoadFile(globalCtx, sNaviMsgFiles[otrSpecial->elfMessage - 1].fileName); globalCtx->cUpElfMsgs = (ElfMessage*)res->data.data(); @@ -436,7 +436,7 @@ extern "C" void* func_800982FC(ObjectContext * objectCtx, s32 bankIndex, s16 obj bool func_8009899C(GlobalContext* globalCtx, Ship::SceneCommand* cmd) { Ship::SetObjectList* cmdObj = (Ship::SetObjectList*)cmd; - + s32 i; s32 j; s32 k; @@ -743,7 +743,7 @@ bool func_8009918C(GlobalContext* globalCtx, Ship::SceneCommand* cmd) } // Scene Command 0x18: Alternate Headers -bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd) +bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd) { Ship::SetAlternateHeaders* cmdHeaders = (Ship::SetAlternateHeaders*)cmd; @@ -754,7 +754,7 @@ bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd) //osSyncPrintf("\n[ZU]sceneset time =[%X]", ((void)0, gSaveContext.cutsceneIndex)); //osSyncPrintf("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneSetupIndex)); - if (gSaveContext.sceneSetupIndex != 0) + if (gSaveContext.sceneSetupIndex != 0) { std::string desiredHeader = cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1]; Ship::Scene* headerData = nullptr; @@ -798,7 +798,7 @@ bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd) } // Scene Command 0x17: Cutscene Data -bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd) +bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd) { Ship::SetCutscenes* cmdCS = (Ship::SetCutscenes*)cmd; @@ -810,7 +810,7 @@ bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd) } // Scene Command 0x19: Misc. Settings (Camera & World Map Area) -bool func_800993C0(GlobalContext* globalCtx, Ship::SceneCommand* cmd) +bool func_800993C0(GlobalContext* globalCtx, Ship::SceneCommand* cmd) { Ship::SetCameraSettings* cmdCam = (Ship::SetCameraSettings*)cmd; diff --git a/soh/src/buffers/heaps.c b/soh/src/buffers/heaps.c index d09f86e72..b6f16ab11 100644 --- a/soh/src/buffers/heaps.c +++ b/soh/src/buffers/heaps.c @@ -6,9 +6,6 @@ #include #endif -#define AUDIO_HEAP_SIZE 0x38000 -#define SYSTEM_HEAP_SIZE (1024 * 1024 * 128) - u8* gAudioHeap; u8* gSystemHeap; diff --git a/soh/src/code/audio_effects.c b/soh/src/code/audio_effects.c index 4813d1c63..d5aa3644f 100644 --- a/soh/src/code/audio_effects.c +++ b/soh/src/code/audio_effects.c @@ -246,7 +246,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) { retry: case ADSR_STATE_LOOP: - adsr->delay = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].delay); + adsr->delay = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].delay); switch (adsr->delay) { case ADSR_DISABLE: adsr->action.s.state = ADSR_STATE_DISABLED; @@ -255,7 +255,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) { adsr->action.s.state = ADSR_STATE_HANG; break; case ADSR_GOTO: - adsr->envIndex = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].arg); + adsr->envIndex = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].arg); goto retry; case ADSR_RESTART: adsr->action.s.state = ADSR_STATE_INITIAL; @@ -266,7 +266,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) { if (adsr->delay == 0) { adsr->delay = 1; } - adsr->target = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].arg) / 32767.0f; + adsr->target = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0f; adsr->target = adsr->target * adsr->target; adsr->velocity = (adsr->target - adsr->current) / adsr->delay; adsr->action.s.state = ADSR_STATE_FADE; diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c index ec8b7be86..7af9037a6 100644 --- a/soh/src/code/audio_load.c +++ b/soh/src/code/audio_load.c @@ -1058,7 +1058,7 @@ void AudioLoad_InitSwapFontSampleHeaders(SoundFontSample* sample, uintptr_t romA size_t maxSoundFontSize = 0x3AA0; // soundFont 0 is the largest size at 0x3AA0 AdpcmLoop* loop; AdpcmBook* book; - + if (((uintptr_t)sample->loop > maxSoundFontSize) || ((uintptr_t)sample->book > maxSoundFontSize) ) { bswapSoundFontSample(sample); @@ -1093,7 +1093,7 @@ void AudioLoad_InitSwapFont(void) { SoundFontSound* sfxList; SoundFontSound* sfx; Instrument** instList; - Instrument* inst; + Instrument* inst; // Only up to (numFonts - 1) as final font has garbage data to prevent corruption and is never used for (fontId = 0; fontId < (numFonts - 1); fontId++) { @@ -1110,12 +1110,12 @@ void AudioLoad_InitSwapFont(void) { numInstruments = font->numInstruments; // drums - ptrs[0] = (void*)_byteswap_ulong((uintptr_t)ptrs[0]); + ptrs[0] = (void*)BOMSWAP32((uintptr_t)ptrs[0]); if ((ptrs[0] != NULL) && (numDrums != 0)) { drumList = (Drum**)BASE_ROM_OFFSET(ptrs[0]); for (i = 0; i < numDrums; i++) { - drumList[i] = (Drum*)_byteswap_ulong((uintptr_t)drumList[i]); + drumList[i] = (Drum*)BOMSWAP32((uintptr_t)drumList[i]); if (drumList[i] != NULL) { drum = (Drum*)BASE_ROM_OFFSET(drumList[i]); @@ -1128,7 +1128,7 @@ void AudioLoad_InitSwapFont(void) { } // sfxs - ptrs[1] = (void*)_byteswap_ulong((u32)ptrs[1]); + ptrs[1] = (void*)BOMSWAP32((u32)ptrs[1]); if ((ptrs[1] != NULL) && (numSfxs != 0)) { sfxList = (SoundFontSound*)BASE_ROM_OFFSET(ptrs[1]); @@ -1151,7 +1151,7 @@ void AudioLoad_InitSwapFont(void) { instList = (Instrument**)(&ptrs[2]); for (i = 0; i < numInstruments; i++) { - instList[i] = (Instrument*)_byteswap_ulong((uintptr_t)instList[i]); + instList[i] = (Instrument*)BOMSWAP32((uintptr_t)instList[i]); if (instList[i] != NULL) { inst = BASE_ROM_OFFSET(instList[i]); @@ -1159,15 +1159,15 @@ void AudioLoad_InitSwapFont(void) { if (inst->normalRangeLo != 0) { sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->lowNotesSound.sample); - AudioLoad_InitSwapFontSampleHeaders(sample, romAddr); + AudioLoad_InitSwapFontSampleHeaders(sample, romAddr); } sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->normalNotesSound.sample); - AudioLoad_InitSwapFontSampleHeaders(sample, romAddr); - + AudioLoad_InitSwapFontSampleHeaders(sample, romAddr); + if (inst->normalRangeHi != 0x7F) { sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->highNotesSound.sample); - AudioLoad_InitSwapFontSampleHeaders(sample, romAddr); + AudioLoad_InitSwapFontSampleHeaders(sample, romAddr); } } } diff --git a/soh/src/code/audio_seqplayer.c b/soh/src/code/audio_seqplayer.c index 03e8842e3..3dd7b811e 100644 --- a/soh/src/code/audio_seqplayer.c +++ b/soh/src/code/audio_seqplayer.c @@ -1323,14 +1323,14 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { case 0xB2: offset = (u16)parameters[0]; // OTRTODO: Byteswap added for quick audio - channel->unk_22 = _byteswap_ushort(*(u16*)(seqPlayer->seqData + (uintptr_t)(offset + scriptState->value * 2))); + channel->unk_22 = BOMSWAP16(*(u16*)(seqPlayer->seqData + (uintptr_t)(offset + scriptState->value * 2))); break; case 0xB4: channel->dynTable = (void*)&seqPlayer->seqData[channel->unk_22]; break; case 0xB5: // OTRTODO: Byteswap added for quick audio - channel->unk_22 = _byteswap_ushort(((u16*)(channel->dynTable))[scriptState->value]); + channel->unk_22 = BOMSWAP16(((u16*)(channel->dynTable))[scriptState->value]); break; case 0xB6: scriptState->value = (*channel->dynTable)[0][scriptState->value]; diff --git a/soh/src/code/audio_synthesis.c b/soh/src/code/audio_synthesis.c index e71c6b441..037bd2ec3 100644 --- a/soh/src/code/audio_synthesis.c +++ b/soh/src/code/audio_synthesis.c @@ -1162,7 +1162,7 @@ Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS if (temp_v0 < nSamplesToLoad) { repeats = ((nSamplesToLoad - temp_v0 + 0x3F) / 0x40); if (repeats != 0) { - aDuplicate(cmd++, repeats, DMEM_UNCOMPRESSED_NOTE, DMEM_UNCOMPRESSED_NOTE + 0x80, 0x80); + aDuplicate(cmd++, repeats, DMEM_UNCOMPRESSED_NOTE, DMEM_UNCOMPRESSED_NOTE + 0x80); } } synthState->samplePosInt = samplePosInt; @@ -1225,6 +1225,6 @@ Acmd* AudioSynth_NoteApplyHeadsetPanEffects(Acmd* cmd, NoteSubEu* noteSubEu, Not aSaveBuffer(cmd++, DMEM_NOTE_PAN_TEMP + bufLen, &synthState->synthesisBuffers->panResampleState[0x8], ALIGN16(panShift)); } - aAddMixer(cmd++, ALIGN64(bufLen), DMEM_NOTE_PAN_TEMP, dest, 0x7FFF); + aAddMixer(cmd++, ALIGN64(bufLen), DMEM_NOTE_PAN_TEMP, dest); return cmd; } diff --git a/soh/src/code/game.c b/soh/src/code/game.c index b69537fd8..a411523ec 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -421,8 +421,12 @@ void GameState_Update(GameState* gameState) { int32_t prevTime = CVar_GetS32("gPrevTime", gSaveContext.dayTime); gSaveContext.dayTime = prevTime; + } else { + CVar_SetS32("gPrevTime", -1); } - + + //since our CVar is same value and properly default to 0 there is not problems doing this in single line. + gSaveContext.language = CVar_GetS32("gLanguages", 0); gameState->frames++; } diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index 5d0495961..4b1887c18 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -5,6 +5,7 @@ #include #include "soh/Enhancements/gameconsole.h" +#include "soh/Enhancements/debugger/debugger.h" #define GFXPOOL_HEAD_MAGIC 0x1234 #define GFXPOOL_TAIL_MAGIC 0x5678 @@ -282,6 +283,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) { GameState_ReqPadData(gameState); GameState_Update(gameState); + Debug_Draw(); OPEN_DISPS(gfxCtx, "../graph.c", 987); @@ -429,6 +431,8 @@ static struct RunFrameContext { extern AudioMgr gAudioMgr; +extern void ProcessSaveStateRequests(void); + static void RunFrame() { u32 size; @@ -485,6 +489,7 @@ static void RunFrame() //uint64_t diff = (ticksB - ticksA) / (freq / 1000); //printf("Frame simulated in %ims\n", diff); runFrameContext.state = 1; + ProcessSaveStateRequests(); return; nextFrame:; } diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index 08c89869f..b467f5ee6 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -3,7 +3,9 @@ //#include +#ifdef _MSC_VER extern void* __cdecl memset(_Out_writes_bytes_all_(_Size) void* _Dst, _In_ int _Val, _In_ size_t _Size); +#endif s32 D_8012D280 = 1; diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index bb55009bb..a9f50f687 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -7,13 +7,13 @@ #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "objects/object_bdoor/object_bdoor.h" -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__GNUC__) #include #include #include #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__GNUC__) #include "textures/place_title_cards/g_pn_49.h" #include "textures/place_title_cards/g_pn_01.h" #include "textures/place_title_cards/g_pn_02.h" @@ -758,12 +758,14 @@ void func_8002CDE4(GlobalContext* globalCtx, TitleCardContext* titleCtx) { } void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s16 x, s16 y, u8 width, - u8 height) { + u8 height, s16 hasTranslation) { if (ResourceMgr_OTRSigCheck(texture)) texture = ResourceMgr_LoadTexByName(texture); titleCtx->texture = texture; + titleCtx->isBossCard = true; + titleCtx->hasTranslation = hasTranslation; titleCtx->x = x; titleCtx->y = y; titleCtx->width = width; @@ -772,7 +774,7 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx titleCtx->delayTimer = 0; } -void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, char* texture, s32 x, s32 y, +void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, s32 width, s32 height, s32 delay) { SceneTableEntry* loadedScene = globalCtx->loadedScene; @@ -957,7 +959,7 @@ void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCt default: titleCtx->texture = NULL; return; - + } char newName[512]; @@ -981,6 +983,8 @@ void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCt titleCtx->texture = ResourceMgr_LoadTexByName(texture); //titleCtx->texture = texture; + titleCtx->isBossCard = false; + titleCtx->hasTranslation = false; titleCtx->x = x; titleCtx->y = y; titleCtx->width = width; @@ -1009,6 +1013,9 @@ void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { s32 doubleWidth; s32 titleY; s32 titleSecondY; + s32 textureLanguageOffset; + s32 shiftTopY; + s32 shiftBottomY; if (titleCtx->alpha != 0) { width = titleCtx->width; @@ -1022,31 +1029,47 @@ void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { height = (width * height > 0x1000) ? 0x1000 / width : height; titleSecondY = titleY + (height * 4); + textureLanguageOffset = 0x0; + shiftTopY = 0x0; + shiftBottomY = 0x1000; + + //if this card is bosses cards, has translation and that is not using English language. + if (titleCtx->isBossCard && titleCtx->hasTranslation && gSaveContext.language != LANGUAGE_ENG) { + textureLanguageOffset = (width * height * gSaveContext.language); + if (gSaveContext.language == LANGUAGE_GER) { + shiftTopY = 0x400; + shiftBottomY = 0x1400; + } else if (gSaveContext.language == LANGUAGE_FRA) { + shiftTopY = 0x800; + shiftBottomY = 0x1800; + } + } + // WORLD_OVERLAY_DISP Goes over POLY_XLU_DISP but under POLY_KAL_DISP WORLD_OVERLAY_DISP = func_80093808(WORLD_OVERLAY_DISP); gDPSetPrimColor(WORLD_OVERLAY_DISP++, 0, 0, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->alpha); - gDPLoadTextureBlock(WORLD_OVERLAY_DISP++, (uintptr_t)titleCtx->texture, G_IM_FMT_IA, + gDPLoadTextureBlock(WORLD_OVERLAY_DISP++, (uintptr_t)titleCtx->texture + textureLanguageOffset + shiftTopY, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - - gSPTextureRectangle(WORLD_OVERLAY_DISP++, titleX, titleY, ((doubleWidth * 2) + titleX) - 4, titleY + (height * 4) - 1, + //Removing the -1 there remove the gap between top and bottom textures. + gSPTextureRectangle(WORLD_OVERLAY_DISP++, titleX, titleY, ((doubleWidth * 2) + titleX) - 4, titleY + (height * 4), G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); height = titleCtx->height - height; // If texture is bigger than 0x1000, display the rest if (height > 0) { - gDPLoadTextureBlock(WORLD_OVERLAY_DISP++, (uintptr_t)titleCtx->texture + 0x1000, + gDPLoadTextureBlock(WORLD_OVERLAY_DISP++, (uintptr_t)titleCtx->texture + textureLanguageOffset + shiftBottomY, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - + //Removing the -1 there remove the gap between top and bottom textures. gSPTextureRectangle(WORLD_OVERLAY_DISP++, titleX, titleSecondY, ((doubleWidth * 2) + titleX) - 4, - titleSecondY + (height * 4) - 1, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + titleSecondY + (height * 4), G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 2880); @@ -1122,7 +1145,7 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) { CollisionCheck_InitInfo(&actor->colChkInfo); actor->floorBgId = BGCHECK_SCENE; ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); - //if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) + //if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { //Actor_SetObjectDependency(globalCtx, actor); actor->init(actor, globalCtx); @@ -2358,7 +2381,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { actor->sfx = 0; if (actor->init != NULL) { - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) + if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { Actor_SetObjectDependency(globalCtx, actor); actor->init(actor, globalCtx); @@ -2547,10 +2570,16 @@ void func_80030FA8(GraphicsContext* gfxCtx) { gDPLoadTextureBlock(POLY_XLU_DISP++, gLensOfTruthMaskTex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); - gDPSetTileSize(POLY_XLU_DISP++, G_TX_RENDERTILE, 384, 224, 892, 732); - gSPTextureRectangle(POLY_XLU_DISP++, 0, 0, 1280, 960, G_TX_RENDERTILE, 2240, 1600, 576, 597); - gDPPipeSync(POLY_XLU_DISP++); + s32 x = OTRGetRectDimensionFromLeftEdge(0) << 2; + s32 w = OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2; + float ratio = OTRGetAspectRatio(); + + gDPSetTileSize(POLY_XLU_DISP++, G_TX_RENDERTILE, 384, 224, 892, 732); + // TODO: Do correct math to fix it + gSPWideTextureRectangle(POLY_XLU_DISP++, x, 0, x + abs(x), 960, G_TX_RENDERTILE, 0, 0, 0, 0); + gSPWideTextureRectangle(POLY_XLU_DISP++, 0, 0, w, 960, G_TX_RENDERTILE, 2240, 1600, 576, 597); + gDPPipeSync(POLY_XLU_DISP++); CLOSE_DISPS(gfxCtx, "../z_actor.c", 6183); } @@ -2894,7 +2923,7 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) { osSyncPrintf(VT_FGCOL(CYAN)); if (actorOverlay->numLoaded == 0) { - + if (actorOverlay->initInfo->reset != NULL) { actorOverlay->initInfo->reset(); } @@ -3020,7 +3049,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId if (objBankIndex < 0 && !gMapLoading) objBankIndex = 0; - + if ((objBankIndex < 0) || ((actorInit->category == ACTORCAT_ENEMY) && Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num))) { // "No data bank!! (profilep->bank=%d)" @@ -4243,8 +4272,6 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) { return ret; } -#include "z_cheap_proc.c" - u8 func_800353E8(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); diff --git a/soh/src/code/z_bgcheck.c b/soh/src/code/z_bgcheck.c index 9ce139eed..811b0bea1 100644 --- a/soh/src/code/z_bgcheck.c +++ b/soh/src/code/z_bgcheck.c @@ -4031,7 +4031,7 @@ s32 func_80041E4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { /** * unused */ -u32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +s32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 7302f9b21..41c16b5cc 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -26,7 +26,7 @@ s32 Camera_CheckWater(Camera* camera); #define FLG_ADJSLOPE (1 << 0) #define FLG_OFFGROUND (1 << 7) -#include "z_camera_data.c" +#include "z_camera_data.inc" /*===============================================================*/ @@ -565,10 +565,10 @@ s16 Camera_XZAngle(Vec3f* to, Vec3f* from) { return DEGF_TO_BINANG(RADF_TO_DEGF(Math_FAtan2F(from->x - to->x, from->z - to->z))); } + f32 D_8015CE50; + f32 D_8015CE54; + CamColChk D_8015CE58; s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) { - static f32 D_8015CE50; - static f32 D_8015CE54; - static CamColChk D_8015CE58; Vec3f playerPos; Vec3f rotatedPos; Vec3f floorNorm; @@ -7221,9 +7221,9 @@ s32 Camera_DbgChangeMode(Camera* camera) { return true; } +s16 D_8011DB08 = 0x3F0; +s16 D_8011DB0C = 0x156; void func_80058E8C(Camera* camera) { - static s16 D_8011DB08 = 0x3F0; - static s16 D_8011DB0C = 0x156; s32 pad3; f32 sp60; s32 pad; @@ -7299,8 +7299,8 @@ void func_80058E8C(Camera* camera) { } } +s32 sOOBTimer = 0; Vec3s Camera_Update(Camera* camera) { - static s32 sOOBTimer = 0; Vec3f viewAt; Vec3f viewEye; Vec3f viewUp; diff --git a/soh/src/code/z_camera_data.c b/soh/src/code/z_camera_data.inc similarity index 100% rename from soh/src/code/z_camera_data.c rename to soh/src/code/z_camera_data.inc diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c index d0145fb43..f6bb7d572 100644 --- a/soh/src/code/z_demo.c +++ b/soh/src/code/z_demo.c @@ -2105,7 +2105,7 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) { } void Cutscene_SetSegment(GlobalContext* globalCtx, void* segment) { - if (SEGMENT_NUMBER(segment) != 0) + if (SEGMENT_NUMBER(segment) != 0) { globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(segment); } else { diff --git a/soh/src/code/z_fbdemo_circle.c b/soh/src/code/z_fbdemo_circle.c index b19948737..5c8f688fa 100644 --- a/soh/src/code/z_fbdemo_circle.c +++ b/soh/src/code/z_fbdemo_circle.c @@ -19,9 +19,9 @@ Gfx __sCircleDList[] = { G_AC_NONE | G_ZS_PIXEL | G_RM_XLU_SURF | G_RM_XLU_SURF2), // 4 gsDPSetCombineMode(G_CC_BLENDPEDECALA, G_CC_BLENDPEDECALA), // 5 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), // 6 - gsDPLoadTextureBlock(0xF8000000, G_IM_FMT_I, G_IM_SIZ_8b, 16, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, // 7 + gsDPLoadTextureBlock(SEG_ADDR(8, 0), G_IM_FMT_I, G_IM_SIZ_8b, 16, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, // 7 G_TX_NOMIRROR | G_TX_CLAMP, 4, 6, G_TX_NOLOD, G_TX_NOLOD), - gsSPDisplayList(0xF9000000), // 8 + gsSPDisplayList(SEG_ADDR(9, 0)), // 8 gsSPVertex(sCircleWipeVtx, 32, 0), // 9 gsSP2Triangles(0, 1, 2, 0, 1, 3, 4, 0), // 10 gsSP2Triangles(3, 5, 6, 0, 5, 7, 8, 0), // 11 @@ -145,8 +145,6 @@ void TransitionCircle_Draw(void* thisx, Gfx** gfxP) { modelView = this->modelView[this->frame]; - this->color.rgba = 0xFFFFFFFF; - this->frame ^= 1; gDPPipeSync(gfx++); texScroll = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0x10, 0x40); diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index f3ac083ab..9f7518374 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -743,7 +743,7 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment if (envCtx->skyboxDmaState == SKYBOX_DMA_FILE2_DONE) { envCtx->skyboxDmaState = SKYBOX_DMA_PAL2_START; - if ((newSkybox2Index & 1) ^ ((newSkybox2Index & 4) >> 2)) + if ((newSkybox2Index & 1) ^ ((newSkybox2Index & 4) >> 2)) { SkyboxTableEntry entryA = sSkyboxTable[newSkybox2Index]; LoadSkyboxPalette(skyboxCtx, 0, entryA.palettes[0], 16, 8); @@ -753,7 +753,7 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment DmaMgr_SendRequest2(&envCtx->dmaRequest, (uintptr_t)skyboxCtx->palettes, gSkyboxFiles[newSkybox2Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1342);*/ - } else + } else { SkyboxTableEntry entryA = sSkyboxTable[newSkybox2Index]; LoadSkyboxPalette(skyboxCtx, 1, entryA.palettes[0], 16, 8); @@ -769,12 +769,12 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment } if ((envCtx->skyboxDmaState == SKYBOX_DMA_FILE1_START) || (envCtx->skyboxDmaState == SKYBOX_DMA_FILE2_START)) { - //if (osRecvMesg(&envCtx->loadQueue, 0, OS_MESG_NOBLOCK) == 0) + //if (osRecvMesg(&envCtx->loadQueue, 0, OS_MESG_NOBLOCK) == 0) { envCtx->skyboxDmaState++; } } else if (envCtx->skyboxDmaState >= SKYBOX_DMA_FILE1_DONE) { - //if (osRecvMesg(&envCtx->loadQueue, 0, OS_MESG_NOBLOCK) == 0) + //if (osRecvMesg(&envCtx->loadQueue, 0, OS_MESG_NOBLOCK) == 0) { envCtx->skyboxDmaState = SKYBOX_DMA_INACTIVE; } @@ -2275,6 +2275,29 @@ Color_RGB8 sSandstormEnvColors[] = { { 50, 40, 0 }, }; +Gfx* gFieldSandstormDL_Custom = NULL; + +void Environment_PatchSandstorm(GlobalContext* globalCtx) { + if (gFieldSandstormDL_Custom) return; + + gFieldSandstormDL_Custom = ResourceMgr_PatchGfxByName(gFieldSandstormDL, -3); + + const Gfx gFSPatchDL[2] = { gsSPEndDisplayList() }; + bool patched = false; + Gfx* cmd = gFieldSandstormDL_Custom; + int id = 0; + + while (!patched) { + const uint32_t opcode = cmd->words.w0 >> 24; + if (opcode == G_TEXRECT) { + gFieldSandstormDL_Custom[id] = gFSPatchDL[0]; + patched = true; + } + ++cmd; + id++; + } +} + void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { s32 primA1; s32 envA1; @@ -2288,6 +2311,8 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { u16 sp94; u16 sp92; + Environment_PatchSandstorm(globalCtx); + switch (sandstormState) { case 3: if ((globalCtx->sceneNum == SCENE_SPOT13) && (globalCtx->roomCtx.curRoom.num == 0)) { @@ -2394,8 +2419,11 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (u32)sp96 % 0x1000, 0, 0x200, 0x20, 1, (u32)sp94 % 0x1000, 0xFFF - ((u32)sp92 % 0x1000), 0x100, 0x40)); gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); - gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); + gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL_Custom); + gSPWideTextureRectangle(POLY_XLU_DISP++, OTRGetRectDimensionFromLeftEdge(0) << 2, 0, + OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2, 0x03C0, G_TX_RENDERTILE, 0, 0, 0x008C, + -0x008C); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 4068); D_8015FDB0 += (s32)sp98; diff --git a/soh/src/code/z_map_exp.c b/soh/src/code/z_map_exp.c index cfef800c9..e97a1a1a5 100644 --- a/soh/src/code/z_map_exp.c +++ b/soh/src/code/z_map_exp.c @@ -737,21 +737,33 @@ void Minimap_Draw(GlobalContext* globalCtx) { if (((globalCtx->sceneNum != SCENE_SPOT01) && (globalCtx->sceneNum != SCENE_SPOT04) && (globalCtx->sceneNum != SCENE_SPOT08)) || (LINK_AGE_IN_YEARS != YEARS_ADULT)) { + s16 IconSize = 8; + s16 PosX = gMapData->owEntranceIconPosX[sEntranceIconMapIndex]; + s16 PosY = gMapData->owEntranceIconPosY[sEntranceIconMapIndex]; + //gFixDungeonMinimapIcon fix both Y position of visible icon and hide these non needed. + if (CVar_GetS32("gFixDungeonMinimapIcon", 1) != 0){ + //No idea why and how Original value work but this does actually fix them all. + PosY = PosY+1024; + } + s16 TopLeftX = OTRGetRectDimensionFromRightEdge(PosX) << 2; + s16 TopLeftY = PosY << 2; + s16 TopLeftW = OTRGetRectDimensionFromRightEdge(PosX + IconSize) << 2; + s16 TopLeftH = (PosY + IconSize) << 2; if ((gMapData->owEntranceFlag[sEntranceIconMapIndex] == 0xFFFF) || ((gMapData->owEntranceFlag[sEntranceIconMapIndex] != 0xFFFF) && (gSaveContext.infTable[26] & gBitFlags[gMapData->owEntranceFlag[mapIndex]]))) { - + if (gMapData->owEntranceIconPosY[sEntranceIconMapIndex] << 2 != 0 && CVar_GetS32("gFixDungeonMinimapIcon", 1) != 0){ + gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, + IconSize, IconSize, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSPWideTextureRectangle(OVERLAY_DISP++, TopLeftX, TopLeftY, TopLeftW, TopLeftH, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + } else if (CVar_GetS32("gAlwaysShowDungeonMinimapIcon", 0) != 0){ //Ability to show entrance Before beating the dungeon itself gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, - 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, + IconSize, IconSize, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - - gSPWideTextureRectangle(OVERLAY_DISP++, - OTRGetRectDimensionFromLeftEdge(gMapData->owEntranceIconPosX[sEntranceIconMapIndex]) << 2, - gMapData->owEntranceIconPosY[sEntranceIconMapIndex] << 2, - OTRGetRectDimensionFromLeftEdge(gMapData->owEntranceIconPosX[sEntranceIconMapIndex] + 8) << 2, - (gMapData->owEntranceIconPosY[sEntranceIconMapIndex] + 8) << 2, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - } + gSPWideTextureRectangle(OVERLAY_DISP++, TopLeftX, TopLeftY, TopLeftW, TopLeftH, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } } if ((globalCtx->sceneNum == SCENE_SPOT08) && (gSaveContext.infTable[26] & gBitFlags[9])) { diff --git a/soh/src/code/z_map_mark.c b/soh/src/code/z_map_mark.c index f5a8a3c39..8d43a33a0 100644 --- a/soh/src/code/z_map_mark.c +++ b/soh/src/code/z_map_mark.c @@ -52,7 +52,7 @@ static MapMarkDataOverlay sMapMarkDataOvl = { gMapMarkDataTable, }; -static MapMarkData** sLoadedMarkDataTable; +MapMarkData** sLoadedMarkDataTable; void MapMark_Init(GlobalContext* globalCtx) { MapMarkDataOverlay* overlay = &sMapMarkDataOvl; diff --git a/soh/src/code/z_onepointdemo.c b/soh/src/code/z_onepointdemo.c index 96ef33c18..538859764 100644 --- a/soh/src/code/z_onepointdemo.c +++ b/soh/src/code/z_onepointdemo.c @@ -4,9 +4,9 @@ static s16 sDisableAttention = false; static s16 sUnused = -1; -static s32 sPrevFrameCs1100 = -4096; +s32 sPrevFrameCs1100 = -4096; -#include "z_onepointdemo_data.c" +#include "z_onepointdemo_data.inc" void OnePointCutscene_AddVecSphToVec3f(Vec3f* dst, Vec3f* src, VecSph* vecSph) { Vec3f out; diff --git a/soh/src/code/z_onepointdemo_data.c b/soh/src/code/z_onepointdemo_data.inc similarity index 96% rename from soh/src/code/z_onepointdemo_data.c rename to soh/src/code/z_onepointdemo_data.inc index 1d1838b05..2488be71b 100644 --- a/soh/src/code/z_onepointdemo_data.c +++ b/soh/src/code/z_onepointdemo_data.inc @@ -1,6 +1,6 @@ #include "global.h" -static CutsceneCameraPoint D_8012013C[14] = { +CutsceneCameraPoint D_8012013C[14] = { { CS_CMD_CONTINUE, 25, 40, 70.79991f, { -1814, 533, -1297 } }, { CS_CMD_CONTINUE, 20, 40, 70.99991f, { -1805, 434, -1293 } }, { CS_CMD_CONTINUE, 10, 30, 60.0f, { -1794, 323, -1280 } }, @@ -16,7 +16,7 @@ static CutsceneCameraPoint D_8012013C[14] = { { CS_CMD_STOP, 0, 50, 60.0f, { -1974, 12, -1179 } }, { CS_CMD_STOP, 0, 30, 60.0f, { -1974, 12, -1179 } }, }; -static CutsceneCameraPoint D_8012021C[14] = { +CutsceneCameraPoint D_8012021C[14] = { { CS_CMD_CONTINUE, 0, 0, 60.0f, { -1751, 604, -1233 } }, { CS_CMD_CONTINUE, 0, 0, 60.0f, { -1752, 516, -1233 } }, { CS_CMD_CONTINUE, 0, 0, 60.0f, { -1751, 417, -1233 } }, { CS_CMD_CONTINUE, 0, 0, 60.0f, { -1767, 306, -1219 } }, { CS_CMD_CONTINUE, 0, 0, 60.0f, { -1776, 257, -1205 } }, { CS_CMD_CONTINUE, 0, 0, 60.0f, { -1881, 147, -1149 } }, @@ -54,7 +54,7 @@ static CutsceneCameraPoint D_80120434[10] = { { CS_CMD_STOP, 0, 0, 60.0f, { 0, 62, -119 } }, { CS_CMD_STOP, 0, 0, 60.0f, { 0, 62, -119 } }, }; -static CutsceneCameraPoint D_801204D4[14] = { +CutsceneCameraPoint D_801204D4[14] = { { CS_CMD_CONTINUE, -15, 40, 80.600006f, { -60, 332, 183 } }, { CS_CMD_CONTINUE, -22, 30, 80.600006f, { -60, 332, 183 } }, { CS_CMD_CONTINUE, -20, 38, 80.600006f, { -118, 344, 41 } }, @@ -70,7 +70,7 @@ static CutsceneCameraPoint D_801204D4[14] = { { CS_CMD_STOP, 6, 30, 85.199936f, { 25, 127, -950 } }, { CS_CMD_STOP, 0, 30, 85.199936f, { 25, 127, -950 } }, }; -static CutsceneCameraPoint D_801205B4[14] = { +CutsceneCameraPoint D_801205B4[14] = { { CS_CMD_CONTINUE, 0, 0, 60.0f, { -225, 785, -242 } }, { CS_CMD_CONTINUE, -21, 0, 80.600006f, { -245, 784, -242 } }, { CS_CMD_CONTINUE, -21, 0, 80.600006f, { -288, 485, -379 } }, @@ -118,18 +118,18 @@ static s16 D_801208E0 = 12; static s16 D_801208E4 = 90; static s16 D_801208E8 = 8; -static OnePointCsFull D_801208EC[3] = { +OnePointCsFull D_801208EC[3] = { { 0x0F, 0x08, 0x0101, 1, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x81, 0xFF, 0x0101, 1, 0, 60.0f, 1.0f, { 0.0f, -10.0f, 0.0f }, { 0.0f, 0.0f, 150.0f } }, { 0x12, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80120964[2] = { +OnePointCsFull D_80120964[2] = { { 0x8F, 0xFF, 0x0101, 1, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x81, 0xFF, 0xA121, 1, 0, 75.0f, 0.6f, { 0.0f, -10.0f, 0.0f }, { 0.0f, 0.0f, 150.0f } }, }; -static OnePointCsFull D_801209B4[4] = { +OnePointCsFull D_801209B4[4] = { { 0x8F, 0x08, 0x0101, 1, 0, 60.0f, 0.9f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x84, 0x01, 0x0100, 29, 0, 45.0f, 0.1f, { 0.0f, -10.0f, 0.0f }, { 0.0f, 0.0f, 150.0f } }, { 0x83, 0xFF, 0x0000, 10, 0, 60.0f, 0.2f, { 0.0f, -10.0f, 0.0f }, { 0.0f, 0.0f, 150.0f } }, @@ -142,7 +142,7 @@ static OnePointCsFull D_80120A54[3] = { { 0x8B, 0xFF, 0x0022, 5000, 0, 75.0f, 0.005f, { 0.0f, 0.0f, -10.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80120ACC[5] = { +OnePointCsFull D_80120ACC[5] = { { 0x8F, 0xFF, 0x0442, 10, 0, 40.0f, 1.0f, { -10.0f, 45.0f, 20.0f }, { 20.0f, 30.0f, 160.0f } }, { 0x95, 0xFF, 0x0000, 1, 0, 40.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, { 0x8F, 0x01, 0x0442, 10, 0, 40.0f, 1.0f, { -10.0f, 45.0f, 20.0f }, { 20.0f, 30.0f, 160.0f } }, @@ -150,7 +150,7 @@ static OnePointCsFull D_80120ACC[5] = { { 0x11, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80120B94[11] = { +OnePointCsFull D_80120B94[11] = { { 0x8F, 0x01, 0x2142, 1, 0, 40.0f, 1.0f, { 20.0f, 40.0f, 20.0f }, { -20.0f, 0.0f, -30.0f } }, { 0x84, 0xFF, 0x0404, 19, 5, 70.0f, 0.01f, { 0.0f, 30.0f, 20.0f }, { 120.0f, 60.0f, 120.0f } }, { 0x84, 0xFF, 0x0404, 20, 0, 60.0f, 0.01f, { 0.0f, 20.0f, 20.0f }, { 120.0f, 60.0f, 120.0f } }, @@ -164,7 +164,7 @@ static OnePointCsFull D_80120B94[11] = { { 0x98, 0xFF, 0x0000, 1, 0, 50.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80120D4C[7] = { +OnePointCsFull D_80120D4C[7] = { { 0x8F, 0x01, 0x2142, 1, 0, 40.0f, 1.0f, { 20.0f, 40.0f, 20.0f }, { -20.0f, 0.0f, -30.0f } }, { 0x84, 0xFF, 0x0404, 19, 5, 70.0f, 0.01f, { 0.0f, 30.0f, 20.0f }, { 120.0f, 60.0f, 120.0f } }, { 0x84, 0xFF, 0x0404, 20, 0, 60.0f, 0.01f, { 0.0f, 20.0f, 20.0f }, { 120.0f, 60.0f, 120.0f } }, @@ -185,7 +185,7 @@ static OnePointCsFull D_80120E64[8] = { { 0x12, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80120FA4[6] = { +OnePointCsFull D_80120FA4[6] = { { 0x8F, 0x01, 0x2143, 30, 0, 70.0f, 0.4f, { 0.0f, 40.0f, 50.0f }, { 30.0f, 10.0f, -50.0f } }, { 0x95, 0xFF, 0x0000, 1, 0, 50.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, { 0x8F, 0xFF, 0x2222, 10, 0, 42.0f, 1.0f, { 0.0f, 40.0f, 0.0f }, { 0.0f, 85.0f, 45.0f } }, @@ -206,12 +206,12 @@ static OnePointCsFull D_8012110C[3] = { { 0x12, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80121184[2] = { +OnePointCsFull D_80121184[2] = { { 0x83, 0x01, 0x0101, 40, 0, -1.0f, 0.1f, { 0.0f, 10.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x12, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_801211D4[2] = { +OnePointCsFull D_801211D4[2] = { { 0x8F, 0x08, 0x0101, 50, 0, 60.0f, 1.0f, { 0.0f, 10.0f, 0.0f }, { -10.0f, 85.0f, 0.0f } }, { 0x11, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; @@ -229,13 +229,13 @@ static OnePointCsFull D_80121314[1] = { { 0x8F, 0x08, 0x4141, 1000, 0, 75.0f, 0.6f, { 0.0f, 0.0f, 10.0f }, { 0.0f, 0.0f, 100.0f } }, }; -static OnePointCsFull D_8012133C[3] = { +OnePointCsFull D_8012133C[3] = { { 0x8F, 0x01, 0x0141, 40, 0, 75.0f, 1.0f, { 0.0f, 60.0f, 0.0f }, { 0.0f, 0.0f, 100.0f } }, { 0x83, 0xFF, 0x2121, 20, 0, 60.0f, 0.2f, { 0.0f, -10.0f, -10.0f }, { 0.0f, 10.0f, -100.0f } }, { 0x11, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_801213B4[5] = { +OnePointCsFull D_801213B4[5] = { { 0x8F, 0x08, 0xC2C2, 40, 0, 70.0f, 1.0f, { 80.0f, 0.0f, 20.0f }, { 20.0f, 0.0f, 80.0f } }, { 0x8B, 0x01, 0xC2C2, 120, 0, 70.0f, 0.1f, { 80.0f, 0.0f, 20.0f }, { 20.0f, 0.0f, 80.0f } }, { 0x8F, 0x53, 0xC2C2, 30, 0, 50.0f, 1.0f, { 60.0f, 0.0f, 20.0f }, { 60.0f, 0.0f, 60.0f } }, @@ -250,17 +250,17 @@ static OnePointCsFull D_8012147C[4] = { { 0x11, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_8012151C[2] = { +OnePointCsFull D_8012151C[2] = { { 0x0F, 0x01, 0x0101, 29, 0, 60.0f, 1.0f, { -700.0f, 875.0f, -100.0f }, { -550.0f, 920.0f, -150.0f } }, { 0x12, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_8012156C[2] = { +OnePointCsFull D_8012156C[2] = { { 0x8F, 0x4D, 0x4242, 1, 0, 65.0f, 1.0f, { 60.0f, 30.0f, 0.0f }, { 50.0f, 20.0f, 150.0f } }, { 0x81, 0xFF, 0x4242, -1, 0, 65.0f, 1.0f, { -50.0f, 60.0f, 0.0f }, { -60.0f, 40.0f, 150.0f } }, }; -static OnePointCsFull D_801215BC[1] = { +OnePointCsFull D_801215BC[1] = { { 0x0F, 0xFF, 0x0101, 5, 0, 65.0f, 1.0f, { -1185.0f, 655.0f, 1185.0f }, { -1255.0f, 735.0f, 1255.0f } }, }; @@ -331,7 +331,7 @@ static OnePointCsFull D_80121A44[12] = { { 0x12, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80121C24[7] = { +OnePointCsFull D_80121C24[7] = { { 0x0F, 0x05, 0x0101, 1, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x03, 0xFF, 0x0101, 89, 0, 50.0f, 0.4f, { 125.0f, 320.0f, -1500.0f }, { 125.0f, 500.0f, -1150.0f } }, { 0x0F, 0x08, 0x0101, 40, 4, 55.0f, 1.0f, { 0.0f, 375.0f, -1440.0f }, { 5.0f, 365.0f, -1315.0f } }, @@ -341,7 +341,7 @@ static OnePointCsFull D_80121C24[7] = { { 0x11, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80121D3C[3] = { +OnePointCsFull D_80121D3C[3] = { { 0x0F, 0xFF, 0x0101, 1, 0, 60.0f, 1.0f, { 1023.0f, 738.0f, -2628.0f }, { 993.0f, 770.0f, -2740.0f } }, { 0x02, 0xFF, 0x0101, 4, 0, 50.0f, 1.0f, { 1255.0f, 350.0f, -1870.0f }, { 1240.0f, 575.0f, -2100.0f } }, { 0x0F, 0xFF, 0x0000, -1, 0, 75.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, @@ -359,14 +359,14 @@ static OnePointCsFull D_80121DB4[9] = { { 0x12, 0xFF, 0x0000, 1, -1, -1.0f, -1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80121F1C[4] = { +OnePointCsFull D_80121F1C[4] = { { 0x0F, 0x08, 0x0101, 10, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x01, 0xFF, 0x2121, 10, 0, 50.0f, 0.5f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 150.0f } }, { 0x01, 0x02, 0x2121, 23, 0, 50.0f, 0.5f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 150.0f } }, { 0x11, 0xFF, 0x0000, 1, -1, -1.0f, -1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80121FBC[4] = { +OnePointCsFull D_80121FBC[4] = { { 0x0F, 0xFF, 0x0101, 5, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x01, 0xFF, 0x0101, 10, 0, 30.0f, 1.0f, { -2130.0f, 2885.0f, -1055.0f }, { -2085.0f, 2875.0f, -1145.0f } }, { 0x0F, 0xFF, 0x0000, 30, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, @@ -379,7 +379,7 @@ static OnePointCsFull D_8012205C[3] = { { 0x01, 0x01, 0x21A1, 10, 0, 60.0f, 1.0f, { 0.0f, -10.0f, 0.0f }, { 0.0f, 10.0f, -200.0f } }, }; -static OnePointCsFull D_801220D4[5] = { +OnePointCsFull D_801220D4[5] = { { 0x0F, 0x01, 0x0101, 5, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x01, 0xFF, 0x4141, 10, 5, 55.0f, 0.75f, { 400.0f, -50.0f, 800.0f }, { 600.0f, -60.0f, 800.0f } }, { 0x01, 0xFF, 0x4141, 15, 10, 40.0f, 0.75f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 10.0f, 200.0f } }, @@ -443,7 +443,7 @@ static OnePointCsFull D_8012269C[3] = { { 0x11, 0xFF, 0x0000, 1, -1, -1.0f, -1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80122714[4] = { +OnePointCsFull D_80122714[4] = { { 0x0F, 0xFF, 0x0101, 20, 0, 45.0f, 1.0f, { -915.0f, -2185.0f, 6335.0f }, { -915.0f, -2290.0f, 6165.0f } }, { 0x02, 0xFF, 0x0101, -1, 0, 80.0f, 0.8f, { -920.0f, -2270.0f, 6140.0f }, { -920.0f, -2280.0f, 6070.0f } }, { 0x02, 0xFF, 0x0101, 20, 0, 80.0f, 0.9f, { -920.0f, -2300.0f, 6140.0f }, { -920.0f, -2300.0f, 6070.0f } }, @@ -512,12 +512,12 @@ static OnePointCsFull D_80122C8C[1] = { { 0x0F, 0xFF, 0x0101, 999, 5, 60.0f, 1.0f, { -70.0f, 140.0f, 25.0f }, { 10.0f, 180.0f, 195.0f } }, }; -static OnePointCsFull D_80122CB4[2] = { +OnePointCsFull D_80122CB4[2] = { { 0x0F, 0xFF, 0x4242, 5, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 1000.0f }, { 0.0f, 0.0f, 1100.0f } }, { 0x02, 0xFF, 0x4242, -1, 0, 60.0f, 1.0f, { 0.0f, 0.0f, -100.0f }, { 0.0f, 0.0f, 0.0f } }, }; -static OnePointCsFull D_80122D04[2] = { +OnePointCsFull D_80122D04[2] = { { 0x0F, 0xFF, 0x4242, 10, 0, 60.0f, 1.0f, { 0.0f, 0.0f, -100.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x02, 0xFF, 0x4242, -1, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 1000.0f }, { 0.0f, 0.0f, 1100.0f } }, }; @@ -534,7 +534,7 @@ static OnePointCsFull D_80122DCC[3] = { { 0x11, 0xFF, 0x0000, 1, -1, -1.0f, -1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80122E44[2][7] = { +OnePointCsFull D_80122E44[2][7] = { { { 0x83, 0xFF, 0x2222, 10, 5, 90.0f, 0.2f, { 50.0f, 100.0f, 140.0f }, { -30.0f, 10.0f, -20.0f } }, { 0x8F, 0xFF, 0x0000, 20, 0, 90.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, @@ -563,25 +563,25 @@ static OnePointCsFull D_80123074[5] = { { 0x92, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_8012313C[3] = { +OnePointCsFull D_8012313C[3] = { { 0x8F, 0xFF, 0xA2A2, 20, 8, 70.0f, 1.0f, { 65.0f, -150.0f, 50.0f }, { 30.0f, 10.0f, 90.0f } }, { 0x81, 0xFF, 0xA2A2, 100, 0, 60.0f, 1.0f, { 70.0f, -160.0f, 50.0f }, { 25.0f, 180.0f, 180.0f } }, { 0x92, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_801231B4[4] = { +OnePointCsFull D_801231B4[4] = { { 0x8F, 0xC5, 0x4343, 1, 0, 50.0f, 1.0f, { 0.0f, 20.0f, 0.0f }, { 0.0f, 5.0f, -1.0f } }, { 0x81, 0xC5, 0x4343, 48, 0, 50.0f, 0.75f, { 0.0f, 80.0f, 0.0f }, { 0.0f, 15.0f, -1.0f } }, { 0x8F, 0xC5, 0x4343, 1, 5, 45.0f, 1.0f, { 0.0f, 0.0f, 30.0f }, { 30.0f, 120.0f, 60.0f } }, { 0x81, 0xC5, 0x4343, -1, 0, -1.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80123254[2] = { +OnePointCsFull D_80123254[2] = { { 0x0F, 0xFF, 0x0101, 1, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x03, 0xC5, 0x0101, 49, 0, 50.0f, 0.05f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, }; -static OnePointCsFull D_801232A4[1] = { +OnePointCsFull D_801232A4[1] = { { 0x0F, 0x45, 0x0101, 9999, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, }; @@ -646,24 +646,24 @@ static OnePointCsFull D_801237CC[5] = { { 0x0F, 0xFF, 0x0000, 100, -45, 75.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, }; -static OnePointCsFull D_80123894[3] = { +OnePointCsFull D_80123894[3] = { { 0x0F, 0xFF, 0x0101, 60, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x0F, 0xFF, 0x4242, 30, 0, 50.0f, 1.0f, { 0.0f, 28.0f, 0.0f }, { 0.0f, 20.0f, 40.0f } }, { 0x0D, 0xFF, 0x0000, 120, 0, 180.0f, 0.4f, { 0.0f, -5.0f, 0.0f }, { 0.0f, 2.0f, 40.0f } }, }; -static OnePointCsFull D_8012390C[2] = { +OnePointCsFull D_8012390C[2] = { { 0x0F, 0xFF, 0x0101, 30, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x0F, 0xFF, 0x4242, 180, 0, 60.0f, 1.0f, { 0.0f, 78.0f, 0.0f }, { 0.0f, 78.0f, 200.0f } }, }; -static OnePointCsFull D_8012395C[3] = { +OnePointCsFull D_8012395C[3] = { { 0x0F, 0xFF, 0x0101, 60, 0, 60.0f, 1.0f, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x0F, 0xFF, 0x4242, 30, 0, 50.0f, 1.0f, { 0.0f, 28.0f, 0.0f }, { 0.0f, 20.0f, -45.0f } }, { 0x0D, 0xFF, 0x0000, 120, 0, 180.0f, 0.4f, { 0.0f, -5.0f, 0.0f }, { 0.0f, 2.0f, 45.0f } }, }; -static OnePointCsFull D_801239D4[3] = { +OnePointCsFull D_801239D4[3] = { { 0x0F, 0xFF, 0x4242, 5, 0, 60.0f, 1.0f, { 0.0f, 20.0f, 0.0f }, { 0.0f, 40.0f, -120.0f } }, { 0x09, 0xFF, 0x4242, 0, 0, 60.0f, 1.0f, { 0.0f, 20.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0x12, 0xFF, 0x0000, 1, 0, 60.0f, 1.0f, { -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, -1.0f } }, diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 6218b7d76..2934e5e1b 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -421,7 +421,7 @@ void Gameplay_Update(GlobalContext* globalCtx) { input = globalCtx->state.input; - if ((SREG(1) < 0) || (DREG(0) != 0)) { + if ((SREG(1) < 0) || (DREG(0) != 0)) { SREG(1) = 0; ZeldaArena_Display(); } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 7f3507abd..355d323e0 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -654,7 +654,7 @@ u8 sEyeMouthIndexes[][2] = { * from adult Link's object are used here. */ -#if defined(MODDING) || (_MSC_VER) +#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__) //TODO: Formatting void* sEyeTextures[2][8] = { { gLinkAdultEyesOpenTex, gLinkAdultEyesHalfTex, gLinkAdultEyesClosedfTex, gLinkAdultEyesRollLeftTex, @@ -670,7 +670,7 @@ void* sEyeTextures[] = { }; #endif -#if defined(modding) || defined(_MSC_VER) +#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__) void* sMouthTextures[2][4] = { { gLinkAdultMouth1Tex, @@ -726,7 +726,7 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, if (eyeIndex > 7) eyeIndex = 7; -#if defined(MODDING) || (_MSC_VER) +#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__) gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[gSaveContext.linkAge][eyeIndex])); #else gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[eyeIndex])); @@ -738,31 +738,29 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, if (mouthIndex > 3) mouthIndex = 3; -#if defined(MODDING) || (_MSC_VER) +#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__) gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[gSaveContext.linkAge][mouthIndex])); #else gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[eyeIndex])); #endif + Color_RGB8 sTemp; + color = &sTemp; if (tunic == PLAYER_TUNIC_KOKIRI) { - Color_RGB8 sTemp = { CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r), - CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g), - CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b) }; - color = &sTemp; + color->r = CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r); + color->g = CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g); + color->b = CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b); } else if (tunic == PLAYER_TUNIC_GORON) { - Color_RGB8 sTemp = { CVar_GetS32("gTunic_Goron_Red", sTunicColors[PLAYER_TUNIC_GORON].r), - CVar_GetS32("gTunic_Goron_Green", sTunicColors[PLAYER_TUNIC_GORON].g), - CVar_GetS32("gTunic_Goron_Blue", sTunicColors[PLAYER_TUNIC_GORON].b) }; - color = &sTemp; + color->r = CVar_GetS32("gTunic_Goron_Red", sTunicColors[PLAYER_TUNIC_GORON].r); + color->g = CVar_GetS32("gTunic_Goron_Green", sTunicColors[PLAYER_TUNIC_GORON].g); + color->b = CVar_GetS32("gTunic_Goron_Blue", sTunicColors[PLAYER_TUNIC_GORON].b); } else if (tunic == PLAYER_TUNIC_ZORA) { - Color_RGB8 sTemp = { CVar_GetS32("gTunic_Zora_Red", sTunicColors[PLAYER_TUNIC_ZORA].r), - CVar_GetS32("gTunic_Zora_Green", sTunicColors[PLAYER_TUNIC_ZORA].g), - CVar_GetS32("gTunic_Zora_Blue", sTunicColors[PLAYER_TUNIC_ZORA].b) }; - color = &sTemp; + color->r = CVar_GetS32("gTunic_Zora_Red", sTunicColors[PLAYER_TUNIC_ZORA].r); + color->g = CVar_GetS32("gTunic_Zora_Green", sTunicColors[PLAYER_TUNIC_ZORA].g); + color->b = CVar_GetS32("gTunic_Zora_Blue", sTunicColors[PLAYER_TUNIC_ZORA].b); } else { - Color_RGB8 sTemp = { CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r), - CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g), - CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b) }; - color = &sTemp; + color->r = CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r); + color->g = CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g); + color->b = CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b); } gDPSetEnvColor(POLY_OPA_DISP++, color->r, color->g, color->b, 0); diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index 93aab731f..5212799a6 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -126,7 +126,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { sp90.y = polygonDlist->pos.y; sp90.z = polygonDlist->pos.z; SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp90, &sp84, &sp80); - if (-(f32)polygonDlist->unk_06 < sp84.z) + if (-(f32)polygonDlist->unk_06 < sp84.z) { temp_f2 = sp84.z - polygonDlist->unk_06; if (temp_f2 < globalCtx->lightCtx.fogFar) { @@ -171,7 +171,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { Gfx* temp2; polygonDlist = spB4->unk_00; - if (iREG(86) != 0) + if (iREG(86) != 0) { temp = sp78; for (phi_v1 = 0; phi_v1 < polygon2->num; phi_v1++, temp++) { @@ -180,7 +180,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { } } - if (((iREG(86) == 1) && (iREG(89) >= sp9C)) || ((iREG(86) == 2) && (iREG(89) == sp9C))) + if (((iREG(86) == 1) && (iREG(89) >= sp9C)) || ((iREG(86) == 2) && (iREG(89) == sp9C))) { if (flags & 1) { temp2 = polygonDlist->opa; @@ -224,7 +224,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { s32 func_80096238(void* data) { OSTime time; - if (*(u32*)data == JPEG_MARKER) + if (*(u32*)data == JPEG_MARKER) { char* decodedJpeg = ResourceMgr_LoadJPEG(data, 320 * 240 * 2); //char* decodedJpeg = ResourceMgr_LoadJPEG(data, 480 * 240 * 2); @@ -235,8 +235,8 @@ s32 func_80096238(void* data) { osSyncPrintf("ワークバッファアドレス(Zバッファ)%08x\n", gZBuffer); time = osGetTime(); - - //if (!Jpeg_Decode(data, gZBuffer, gGfxSPTaskOutputBuffer, sizeof(gGfxSPTaskOutputBuffer))) + + //if (!Jpeg_Decode(data, gZBuffer, gGfxSPTaskOutputBuffer, sizeof(gGfxSPTaskOutputBuffer))) if (1) { memcpy(data, decodedJpeg, 320 * 240 * 2); @@ -294,14 +294,17 @@ void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 h bg->b.frameW = width * 4; bg->b.frameH = height * 4; guS2DInitBg(bg); - - gDPSetOtherMode(displayListHead++, mode0 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, + + gDPSetOtherMode(displayListHead++, mode0 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); gDPSetFillColor(displayListHead++, GPACK_RGBA5551(0, 0, 0, 1) << 16 | GPACK_RGBA5551(0, 0, 0, 1)); gDPFillWideRectangle(displayListHead++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH), SCREEN_HEIGHT); + gDPSetOtherMode(displayListHead++, mode0 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); + gDPLoadMultiTile(displayListHead++, bg->b.imagePtr, 0, G_TX_RENDERTILE, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, 0, 0, 0, 0 + 31, 0 + 31, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, diff --git a/soh/src/code/z_skelanime.c b/soh/src/code/z_skelanime.c index 2c03390e9..6dbfac7ef 100644 --- a/soh/src/code/z_skelanime.c +++ b/soh/src/code/z_skelanime.c @@ -863,7 +863,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader char animPath[2048]; - sprintf(animPath, "misc\\link_animetion\\gPlayerAnimData_%06X", (((uintptr_t)linkAnimHeader->segment - 0x07000000))); + sprintf(animPath, "misc/link_animetion/gPlayerAnimData_%06X", (((uintptr_t)linkAnimHeader->segment - 0x07000000))); //printf("Streaming %s, seg = %08X\n", animPath, linkAnimHeader->segment); @@ -877,7 +877,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader { ramPtr[i] = i * 7; }*/ - + //DmaMgr_SendRequest2(&entry->data.load.req, ram, //LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame)), diff --git a/soh/src/code/z_vismono.c b/soh/src/code/z_vismono.c index 82acc9a17..2af876ad6 100644 --- a/soh/src/code/z_vismono.c +++ b/soh/src/code/z_vismono.c @@ -42,7 +42,7 @@ Gfx* VisMono_DrawTexture(VisMono* this, Gfx* gfx) s32 y; s32 height = 3; //u16* tex = D_0F000000; - u16* tex = 0xFF000000; + u16* tex = SEG_ADDR(0xF, 0); gDPPipeSync(gfx++); gDPSetOtherMode(gfx++, diff --git a/soh/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c b/soh/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c index 260fa21ea..9ca8599b9 100644 --- a/soh/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c +++ b/soh/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c @@ -121,8 +121,8 @@ void BgDdanKd_CheckForExplosions(BgDdanKd* this, GlobalContext* globalCtx) { } } -static Vec3f velocity = { 0.0f, 5.0f, 0.0f }; -static Vec3f accel = { 0.0f, -0.45f, 0.0f }; +Vec3f sBgDdanKdVelocity = { 0.0f, 5.0f, 0.0f }; +Vec3f sBgDdanKdAccel = { 0.0f, -0.45f, 0.0f }; void BgDdanKd_LowerStairs(BgDdanKd* this, GlobalContext* globalCtx) { Vec3f pos1; @@ -158,11 +158,11 @@ void BgDdanKd_LowerStairs(BgDdanKd* this, GlobalContext* globalCtx) { func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); func_80033480(globalCtx, &pos2, 20.0f, 1, effectStrength * 135.0f, 60, 1); - velocity.x = Rand_CenteredFloat(3.0f); - velocity.z = Rand_CenteredFloat(3.0f); + sBgDdanKdVelocity.x = Rand_CenteredFloat(3.0f); + sBgDdanKdVelocity.z = Rand_CenteredFloat(3.0f); - func_8003555C(globalCtx, &pos1, &velocity, &accel); - func_8003555C(globalCtx, &pos2, &velocity, &accel); + func_8003555C(globalCtx, &pos1, &sBgDdanKdVelocity, &sBgDdanKdAccel); + func_8003555C(globalCtx, &pos2, &sBgDdanKdVelocity, &sBgDdanKdAccel); pos1 = this->dyna.actor.world.pos; pos1.z += 560.0f + Rand_ZeroOne() * 5.0f; @@ -170,7 +170,7 @@ void BgDdanKd_LowerStairs(BgDdanKd* this, GlobalContext* globalCtx) { pos1.y = Rand_ZeroOne() * 3.0f + (this->dyna.actor.floorHeight + 20.0f); func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1); - func_8003555C(globalCtx, &pos1, &velocity, &accel); + func_8003555C(globalCtx, &pos1, &sBgDdanKdVelocity, &sBgDdanKdAccel); } Camera_AddQuake(&globalCtx->mainCamera, 0, effectStrength * 0.6f, 3); Audio_PlaySoundGeneral(NA_SE_EV_PILLAR_SINK - SFX_FLAG, &this->dyna.actor.projectedPos, 4, &D_801333E0, @@ -192,11 +192,11 @@ void BgDdanKd_Draw(Actor* thisx, GlobalContext* globalCtx) { } void BgDdanKd_Reset(void) { - velocity.x = 0.0f; - velocity.y = 5.0f; - velocity.z = 0.0f; + sBgDdanKdVelocity.x = 0.0f; + sBgDdanKdVelocity.y = 5.0f; + sBgDdanKdVelocity.z = 0.0f; - accel.x = 0.0f; - accel.y = -0.45f; - accel.z = 0.0f; + sBgDdanKdAccel.x = 0.0f; + sBgDdanKdAccel.y = -0.45f; + sBgDdanKdAccel.z = 0.0f; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c b/soh/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c index a089aa013..dbeb5eb7c 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c +++ b/soh/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c @@ -74,13 +74,13 @@ static ColliderCylinderInit sColCylinderInitLeftRight = { { 50, 60, 280, { 0, 0, 0 } }, }; -static s16 sFirstExplosiveFlag = false; +s16 sBgDodoagoFirstExplosiveFlag = false; -static u8 sDisableBombCatcher; +u8 sBgDodoagoDisableBombCatcher; -static u8 sUnused[90]; // unknown length +//static u8 sUnused[90]; // unknown length -static s32 sTimer; +s32 sBgDodoagoTimer; void BgDodoago_SetupAction(BgDodoago* this, BgDodoagoActionFunc actionFunc) { this->actionFunc = actionFunc; @@ -135,7 +135,7 @@ void BgDodoago_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->colliderRight, &this->dyna.actor, &sColCylinderInitLeftRight); BgDodoago_SetupAction(this, BgDodoago_WaitExplosives); - sDisableBombCatcher = false; + sBgDodoagoDisableBombCatcher = false; } void BgDodoago_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -170,16 +170,16 @@ void BgDodoago_WaitExplosives(BgDodoago* this, GlobalContext* globalCtx) { } else { OnePointCutscene_Init(globalCtx, 3065, 20, &this->dyna.actor, MAIN_CAM); Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - sTimer += 30; + sBgDodoagoTimer += 30; return; } // the flag is never set back to false, so this only runs once - if (!sFirstExplosiveFlag) { + if (!sBgDodoagoFirstExplosiveFlag) { // this disables the bomb catcher (see BgDodoago_Update) for a few seconds this->dyna.actor.parent = explosive; - sFirstExplosiveFlag = true; - sTimer = 50; + sBgDodoagoFirstExplosiveFlag = true; + sBgDodoagoTimer = 50; } } else if (Flags_GetEventChkInf(0xB0)) { Collider_UpdateCylinder(&this->dyna.actor, &this->colliderMain); @@ -219,11 +219,11 @@ void BgDodoago_OpenJaw(BgDodoago* this, GlobalContext* globalCtx) { } if (globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] != 255 || globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] != 255) { - sTimer--; + sBgDodoagoTimer--; return; } - if (sTimer == 108) { + if (sBgDodoagoTimer == 108) { for (i = ARRAY_COUNT(dustOffsets) - 1; i >= 0; i--) { pos.x = dustOffsets[i].x + this->dyna.actor.world.pos.x; pos.y = dustOffsets[i].y + this->dyna.actor.world.pos.y; @@ -290,16 +290,16 @@ void BgDodoago_Update(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.parent = &bomb->actor; bomb->timer = 50; bomb->actor.speedXZ = 0.0f; - sTimer = 0; + sBgDodoagoTimer = 0; } } } else { - sTimer++; + sBgDodoagoTimer++; Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F); - if (!sDisableBombCatcher && sTimer > 140) { + if (!sBgDodoagoDisableBombCatcher && sBgDodoagoTimer > 140) { if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) { // this prevents clearing the actor's parent pointer, effectively disabling the bomb catcher - sDisableBombCatcher++; + sBgDodoagoDisableBombCatcher++; } else { this->dyna.actor.parent = NULL; } @@ -322,7 +322,7 @@ void BgDodoago_Draw(Actor* thisx, GlobalContext* globalCtx) { } void BgDodoago_Reset(void) { - sFirstExplosiveFlag = false; - sDisableBombCatcher = 0; - sTimer = 0; + sBgDodoagoFirstExplosiveFlag = false; + sBgDodoagoDisableBombCatcher = 0; + sBgDodoagoTimer = 0; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c b/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c index 7e3cd9155..2a4a4420f 100644 --- a/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c +++ b/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c @@ -47,7 +47,7 @@ void BgHakaGate_SkullOfTruth(BgHakaGate* this, GlobalContext* globalCtx); void BgHakaGate_FalseSkull(BgHakaGate* this, GlobalContext* globalCtx); static s16 sSkullOfTruthRotY = 0x100; -static u8 sPuzzleState = 1; +static u8 sBgPoEventPuzzleState = 1; static f32 sStatueDistToPlayer = 0; static s16 sStatueRotY; @@ -82,7 +82,7 @@ void BgHakaGate_Init(Actor* thisx, GlobalContext* globalCtx) { if (sSkullOfTruthRotY != 0x100) { this->actionFunc = BgHakaGate_FalseSkull; } else if (ABS(thisx->shape.rot.y) < 0x4000) { - if ((Rand_ZeroOne() * 3.0f) < sPuzzleState) { + if ((Rand_ZeroOne() * 3.0f) < sBgPoEventPuzzleState) { this->vIsSkullOfTruth = true; sSkullOfTruthRotY = thisx->shape.rot.y + 0x8000; if (Flags_GetSwitch(globalCtx, this->switchFlag)) { @@ -91,7 +91,7 @@ void BgHakaGate_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = BgHakaGate_SkullOfTruth; } } else { - sPuzzleState++; + sBgPoEventPuzzleState++; this->actionFunc = BgHakaGate_FalseSkull; } } else { @@ -141,7 +141,7 @@ void BgHakaGate_Destroy(Actor* thisx, GlobalContext* globalCtx) { DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); if (this->dyna.actor.params == BGHAKAGATE_STATUE) { sSkullOfTruthRotY = 0x100; - sPuzzleState = 1; + sBgPoEventPuzzleState = 1; } } @@ -178,7 +178,7 @@ void BgHakaGate_StatueIdle(BgHakaGate* this, GlobalContext* globalCtx) { } } } else { - if (sPuzzleState == SKULL_OF_TRUTH_FOUND) { + if (sBgPoEventPuzzleState == SKULL_OF_TRUTH_FOUND) { this->actionFunc = BgHakaGate_StatueInactive; } else { this->vTimer = 0; @@ -192,7 +192,12 @@ void BgHakaGate_StatueTurn(BgHakaGate* this, GlobalContext* globalCtx) { s16 turnAngle; this->vTurnRateDeg10++; - this->vTurnRateDeg10 = CLAMP_MAX(this->vTurnRateDeg10, 5); + if (CVar_GetS32("gFasterBlockPush", 0) != 0) { + this->vTurnRateDeg10 = 10; + CLAMP_MAX(this->vTurnRateDeg10, 5); + } else { + this->vTurnRateDeg10 = CLAMP_MAX(this->vTurnRateDeg10, 5); + } turnFinished = Math_StepToS(&this->vTurnAngleDeg10, 600, this->vTurnRateDeg10); turnAngle = this->vTurnAngleDeg10 * this->vTurnDirection; this->dyna.actor.shape.rot.y = (this->vRotYDeg10 + turnAngle) * 0.1f * (0x10000 / 360.0f); @@ -212,7 +217,7 @@ void BgHakaGate_StatueTurn(BgHakaGate* this, GlobalContext* globalCtx) { this->vRotYDeg10 = (this->vRotYDeg10 + turnAngle) % 3600; this->vTurnRateDeg10 = 0; this->vTurnAngleDeg10 = 0; - this->vTimer = 5; + this->vTimer = CVar_GetS32("gFasterBlockPush", 0) != 0 ? 2 : 5; this->actionFunc = BgHakaGate_StatueIdle; this->dyna.unk_150 = 0.0f; } @@ -238,7 +243,7 @@ void BgHakaGate_FloorClosed(BgHakaGate* this, GlobalContext* globalCtx) { sStatueDistToPlayer = 0.0f; if (ABS(yawDiff) < 0x80) { Flags_SetSwitch(globalCtx, this->switchFlag); - sPuzzleState = SKULL_OF_TRUTH_FOUND; + sBgPoEventPuzzleState = SKULL_OF_TRUTH_FOUND; this->actionFunc = BgHakaGate_DoNothing; } else { func_80078884(NA_SE_SY_ERROR); diff --git a/soh/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c b/soh/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c index 83cd8dfd6..877916b67 100644 --- a/soh/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c +++ b/soh/src/overlays/actors/ovl_Bg_Haka_Trap/z_bg_haka_trap.c @@ -28,7 +28,7 @@ void func_80880AE8(BgHakaTrap* this, GlobalContext* globalCtx); void func_80880C0C(BgHakaTrap* this, GlobalContext* globalCtx); void func_80880D68(BgHakaTrap* this); -static UNK_TYPE D_80880F30 = 0; +UNK_TYPE D_80880F30 = 0; const ActorInit Bg_Haka_Trap_InitVars = { ACTOR_BG_HAKA_TRAP, @@ -107,7 +107,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -static UNK_TYPE D_80881014 = 0; +UNK_TYPE D_80881014 = 0; void BgHakaTrap_Init(Actor* thisx, GlobalContext* globalCtx) { BgHakaTrap* this = (BgHakaTrap*)thisx; s32 pad; diff --git a/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c b/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c index 4522a9486..a962dbc2e 100644 --- a/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c +++ b/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c @@ -120,7 +120,7 @@ void func_8088B24C(BgHidanRock* this) { this->actionFunc = func_8088B990; } -static f32 D_8088BFC0 = 0.0f; +f32 D_8088BFC0 = 0.0f; void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx) { f32 sp2C; s32 temp_v1; @@ -137,7 +137,7 @@ void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx) { } } - this->dyna.actor.speedXZ += 0.05f; + this->dyna.actor.speedXZ += CVar_GetS32("gFasterBlockPush", 0) != 0 ? 0.5f : 0.05f; this->dyna.actor.speedXZ = CLAMP_MAX(this->dyna.actor.speedXZ, 2.0f); if (D_8088BFC0 > 0.0f) { @@ -156,7 +156,7 @@ void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx) { this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z; D_8088BFC0 = 0.0f; this->dyna.actor.speedXZ = 0.0f; - this->timer = 5; + this->timer = CVar_GetS32("gFasterBlockPush", 0) != 0 ? 2 : 5; } func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c b/soh/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c index 1d50e6c49..dc1a3b758 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c @@ -23,7 +23,7 @@ void BgJya1flift_SetupDoNothing(BgJya1flift* this); void BgJya1flift_ResetMoveDelay(BgJya1flift* this); void BgJya1flift_DelayMove(BgJya1flift* this, GlobalContext* globalCtx); -static u8 sIsSpawned = false; +static u8 sKankyoIsSpawned = false; const ActorInit Bg_Jya_1flift_InitVars = { ACTOR_BG_JYA_1FLIFT, @@ -94,9 +94,9 @@ void BgJya1flift_InitCollision(Actor* thisx, GlobalContext* globalCtx) { void BgJya1flift_Init(Actor* thisx, GlobalContext* globalCtx) { BgJya1flift* this = (BgJya1flift*)thisx; // "1 F lift" - osSyncPrintf("(1Fリフト)(flag %d)(room %d)\n", sIsSpawned, globalCtx->roomCtx.curRoom.num); + osSyncPrintf("(1Fリフト)(flag %d)(room %d)\n", sKankyoIsSpawned, globalCtx->roomCtx.curRoom.num); this->hasInitialized = false; - if (sIsSpawned) { + if (sKankyoIsSpawned) { Actor_Kill(thisx); return; } @@ -109,7 +109,7 @@ void BgJya1flift_Init(Actor* thisx, GlobalContext* globalCtx) { BgJya1flift_SetupWaitForSwitch(this); } thisx->room = -1; - sIsSpawned = true; + sKankyoIsSpawned = true; this->hasInitialized = true; } @@ -117,7 +117,7 @@ void BgJya1flift_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgJya1flift* this = (BgJya1flift*)thisx; if (this->hasInitialized) { - sIsSpawned = false; + sKankyoIsSpawned = false; Collider_DestroyCylinder(globalCtx, &this->collider); DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c b/soh/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c index 934329337..e872a4cdf 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Bigmirror/z_bg_jya_bigmirror.c @@ -14,7 +14,7 @@ void BgJyaBigmirror_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgJyaBigmirror_Update(Actor* thisx, GlobalContext* globalCtx); void BgJyaBigmirror_Draw(Actor* thisx, GlobalContext* globalCtx); -static u8 sIsSpawned = false; +static u8 sKankyoIsSpawned = false; const ActorInit Bg_Jya_Bigmirror_InitVars = { ACTOR_BG_JYA_BIGMIRROR, @@ -176,7 +176,7 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, GlobalContext* globalCtx) { void BgJyaBigmirror_Init(Actor* thisx, GlobalContext* globalCtx) { BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; - if (sIsSpawned) { + if (sKankyoIsSpawned) { Actor_Kill(&this->actor); return; } @@ -185,7 +185,7 @@ void BgJyaBigmirror_Init(Actor* thisx, GlobalContext* globalCtx) { this->cobraInfo[0].rotY = sCobraSpawnData[0].initRotY; this->cobraInfo[1].rotY = sCobraSpawnData[1].initRotY; this->actor.room = -1; - sIsSpawned = true; + sKankyoIsSpawned = true; this->spawned = true; this->mirRayObjIndex = -1; @@ -197,7 +197,7 @@ void BgJyaBigmirror_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgJyaBigmirror* this = (BgJyaBigmirror*)thisx; if (this->spawned) { - sIsSpawned = false; + sKankyoIsSpawned = false; } } diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c b/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c index 3f659ad57..064537f2d 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c @@ -444,7 +444,7 @@ void func_80896950(BgJyaCobra* this, GlobalContext* globalCtx) { if (this->dyna.unk_150 > 0.001f) { this->unk_168++; - if (this->unk_168 >= 15) { + if (this->unk_168 >= CVar_GetS32("gFasterBlockPush", 0) != 0 ? 5 : 15) { func_808969F8(this, globalCtx); } } else { @@ -484,9 +484,11 @@ void func_808969F8(BgJyaCobra* this, GlobalContext* globalCtx) { void func_80896ABC(BgJyaCobra* this, GlobalContext* globalCtx) { s16 temp_v0; Player* player = GET_PLAYER(globalCtx); + if (CVar_GetS32("gFasterBlockPush", 0) != 0) + this->unk_16E = 150.0f; temp_v0 = (s16)((this->unk_16C * 0x2000) + this->dyna.actor.home.rot.y) - this->dyna.actor.world.rot.y; - if (ABS(temp_v0) < 7424) { + if (ABS(temp_v0) < CVar_GetS32("gFasterBlockPush", 0) != 0 ? 3712 : 7424) { Math_StepToS(&this->unk_16E, 106, 4); } else { Math_StepToS(&this->unk_16E, 21, 10); diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c b/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c index f57c64b84..57c7ac413 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c @@ -20,7 +20,7 @@ void BgJyaLift_DelayMove(BgJyaLift* this, GlobalContext* globalCtx); void BgJyaLift_SetupMove(BgJyaLift* this); void BgJyaLift_Move(BgJyaLift* this, GlobalContext* globalCtx); -static s16 sIsSpawned = false; +static s16 sKankyoIsSpawned = false; const ActorInit Bg_Jya_Lift_InitVars = { ACTOR_BG_JYA_LIFT, @@ -55,7 +55,7 @@ void BgJyaLift_Init(Actor* thisx, GlobalContext* globalCtx) { BgJyaLift* this = (BgJyaLift*)thisx; this->isSpawned = false; - if (sIsSpawned) { + if (sKankyoIsSpawned) { Actor_Kill(thisx); return; } @@ -70,7 +70,7 @@ void BgJyaLift_Init(Actor* thisx, GlobalContext* globalCtx) { BgJyaLift_SetInitPosY(this); } thisx->room = -1; - sIsSpawned = true; + sKankyoIsSpawned = true; this->isSpawned = true; } @@ -81,7 +81,7 @@ void BgJyaLift_Destroy(Actor* thisx, GlobalContext* globalCtx) { // "Goddess Lift DT" osSyncPrintf("女神リフト DT\n"); - sIsSpawned = false; + sKankyoIsSpawned = false; DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } } diff --git a/soh/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.c b/soh/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.c index 70360c423..a8871b50c 100644 --- a/soh/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.c +++ b/soh/src/overlays/actors/ovl_Bg_Menkuri_Eye/z_bg_menkuri_eye.c @@ -28,7 +28,7 @@ const ActorInit Bg_Menkuri_Eye_InitVars = { (ActorResetFunc)BgMenkuriEye_Reset, }; -static s32 D_8089C1A0; +s32 D_8089C1A0; static ColliderJntSphElementInit sJntSphElementsInit[1] = { { diff --git a/soh/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c b/soh/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c index edda63bbb..269b5e411 100644 --- a/soh/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c +++ b/soh/src/overlays/actors/ovl_Bg_Mori_Elevator/z_bg_mori_elevator.c @@ -17,7 +17,7 @@ void func_808A2008(BgMoriElevator* this, GlobalContext* globalCtx); void BgMoriElevator_MoveIntoGround(BgMoriElevator* this, GlobalContext* globalCtx); void BgMoriElevator_MoveAboveGround(BgMoriElevator* this, GlobalContext* globalCtx); -static s16 sIsSpawned = false; +static s16 sKankyoIsSpawned = false; const ActorInit Bg_Mori_Elevator_InitVars = { ACTOR_BG_MORI_ELEVATOR, @@ -87,18 +87,18 @@ void BgMoriElevator_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; CollisionHeader* colHeader = NULL; - this->unk_172 = sIsSpawned; + this->unk_172 = sKankyoIsSpawned; this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX); if (this->moriTexObjIndex < 0) { Actor_Kill(thisx); // "Forest Temple obj elevator Bank Danger!" osSyncPrintf("Error : 森の神殿 obj elevator バンク危険!(%s %d)\n", "../z_bg_mori_elevator.c", 277); } else { - switch (sIsSpawned) { + switch (sKankyoIsSpawned) { case false: // "Forest Temple elevator CT" osSyncPrintf("森の神殿 elevator CT\n"); - sIsSpawned = true; + sKankyoIsSpawned = true; this->dyna.actor.room = -1; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, DPM_PLAYER); @@ -120,7 +120,7 @@ void BgMoriElevator_Destroy(Actor* thisx, GlobalContext* globalCtx) { // "Forest Temple elevator DT" osSyncPrintf("森の神殿 elevator DT\n"); DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - sIsSpawned = false; + sKankyoIsSpawned = false; } } diff --git a/soh/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c b/soh/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c index 8dfbff765..7508b6a24 100644 --- a/soh/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c +++ b/soh/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c @@ -28,7 +28,7 @@ void BgMoriHineri_SpawnBossKeyChest(BgMoriHineri* this, GlobalContext* globalCtx void BgMoriHineri_DoNothing(BgMoriHineri* this, GlobalContext* globalCtx); void func_808A3D58(BgMoriHineri* this, GlobalContext* globalCtx); -static s16 sNextCamIdx = SUBCAM_NONE; +s16 sBgMoriHineriNextCamIdx = SUBCAM_NONE; const ActorInit Bg_Mori_Hineri_InitVars = { ACTOR_BG_MORI_HINERI, @@ -194,28 +194,28 @@ void func_808A3D58(BgMoriHineri* this, GlobalContext* globalCtx) { OnePointCutscene_EndCutscene(globalCtx, mainCamChildIdx); } OnePointCutscene_Init(globalCtx, 3260, 40, &this->dyna.actor, MAIN_CAM); - sNextCamIdx = OnePointCutscene_Init(globalCtx, 3261, 40, &this->dyna.actor, MAIN_CAM); + sBgMoriHineriNextCamIdx = OnePointCutscene_Init(globalCtx, 3261, 40, &this->dyna.actor, MAIN_CAM); } } void func_808A3E54(BgMoriHineri* this, GlobalContext* globalCtx) { s8 objBankIndex; - if (globalCtx->activeCamera == sNextCamIdx) { - if (sNextCamIdx != MAIN_CAM) { + if (globalCtx->activeCamera == sBgMoriHineriNextCamIdx) { + if (sBgMoriHineriNextCamIdx != MAIN_CAM) { objBankIndex = this->dyna.actor.objBankIndex; this->dyna.actor.objBankIndex = this->moriHineriObjIdx; this->moriHineriObjIdx = objBankIndex; this->dyna.actor.params ^= 1; - sNextCamIdx = MAIN_CAM; + sBgMoriHineriNextCamIdx = MAIN_CAM; func_80078884(NA_SE_SY_TRE_BOX_APPEAR); } else { this->dyna.actor.draw = NULL; this->actionFunc = func_808A3D58; - sNextCamIdx = SUBCAM_NONE; + sBgMoriHineriNextCamIdx = SUBCAM_NONE; } } - if ((sNextCamIdx >= SUBCAM_FIRST) && + if ((sBgMoriHineriNextCamIdx >= SUBCAM_FIRST) && ((GET_ACTIVE_CAM(globalCtx)->eye.z - this->dyna.actor.world.pos.z) < 1100.0f)) { func_8002F948(&this->dyna.actor, NA_SE_EV_FLOOR_ROLLING - SFX_FLAG); } @@ -283,5 +283,5 @@ void BgMoriHineri_DrawHallAndRoom(Actor* thisx, GlobalContext* globalCtx) { } void BgMoriHineri_Reset() { - sNextCamIdx = SUBCAM_NONE; + sBgMoriHineriNextCamIdx = SUBCAM_NONE; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c b/soh/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c index 3c605926f..962c4d1aa 100644 --- a/soh/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c +++ b/soh/src/overlays/actors/ovl_Bg_Mori_Idomizu/z_bg_mori_idomizu.c @@ -19,7 +19,7 @@ void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* this, GlobalContext* globalCtx) void BgMoriIdomizu_SetupMain(BgMoriIdomizu* this); void BgMoriIdomizu_Main(BgMoriIdomizu* this, GlobalContext* globalCtx); -static s16 sIsSpawned = false; +static s16 sKankyoIsSpawned = false; const ActorInit Bg_Mori_Idomizu_InitVars = { ACTOR_BG_MORI_IDOMIZU, @@ -50,7 +50,7 @@ void BgMoriIdomizu_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; - if (sIsSpawned) { + if (sKankyoIsSpawned) { Actor_Kill(&this->actor); return; } @@ -76,7 +76,7 @@ void BgMoriIdomizu_Init(Actor* thisx, GlobalContext* globalCtx) { return; } BgMoriIdomizu_SetupWaitForMoriTex(this); - sIsSpawned = true; + sKankyoIsSpawned = true; this->isLoaded = true; this->actor.room = -1; // "Forest Temple well water" @@ -88,7 +88,7 @@ void BgMoriIdomizu_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgMoriIdomizu* this = (BgMoriIdomizu*)thisx; if (this->isLoaded) { - sIsSpawned = false; + sKankyoIsSpawned = false; } } diff --git a/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c b/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c index 4ad89d7b3..68bf02fb7 100644 --- a/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c +++ b/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c @@ -94,7 +94,7 @@ void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* this, GlobalContext* globalCtx) { if (this->dyna.unk_150 > 0.001f) { this->timer++; - if ((this->timer > 28) && !Player_InCsMode(globalCtx)) { + if ((this->timer > CVar_GetS32("gFasterBlockPush", 0) != 0 ? 14 : 28) && !Player_InCsMode(globalCtx)) { BgMoriKaitenkabe_SetupRotate(this); func_8002DF54(globalCtx, &this->dyna.actor, 8); Math_Vec3f_Copy(&this->lockedPlayerPos, &player->actor.world.pos); @@ -118,7 +118,7 @@ void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* this, GlobalContext* globalCtx) { void BgMoriKaitenkabe_SetupRotate(BgMoriKaitenkabe* this) { this->actionFunc = BgMoriKaitenkabe_Rotate; - this->rotSpeed = 0.0f; + this->rotSpeed = CVar_GetS32("gFasterBlockPush", 0) != 0 ? 0.5f : 0.0f; this->rotYdeg = 0.0f; } diff --git a/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c b/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c index 1a1cc6c60..c2ed8a29b 100644 --- a/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c +++ b/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c @@ -80,11 +80,11 @@ static ColliderTrisInit sTrisInit = { sTrisElementsInit, }; -static u8 sBlocksAtRest = 0; +u8 sBgPoEventBlocksAtRest = 0; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static u8 sPuzzleState; +u8 sBgPoEventPuzzleState; void BgPoEvent_InitPaintings(BgPoEvent* this, GlobalContext* globalCtx) { static s16 paintingPosX[] = { -1302, -866, 1421, 985 }; @@ -142,10 +142,10 @@ void BgPoEvent_InitPaintings(BgPoEvent* this, GlobalContext* globalCtx) { } this->timer = 0; if (this->type == 4) { - sPuzzleState = 0; + sBgPoEventPuzzleState = 0; this->actionFunc = BgPoEvent_AmyWait; } else { - sPuzzleState = (s32)(Rand_ZeroOne() * 3.0f) % 3; + sBgPoEventPuzzleState = (s32)(Rand_ZeroOne() * 3.0f) % 3; this->actionFunc = BgPoEvent_PaintingEmpty; } } @@ -236,7 +236,7 @@ void BgPoEvent_Destroy(Actor* thisx, GlobalContext* globalCtx) { void BgPoEvent_BlockWait(BgPoEvent* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y = 833.0f; - if (sPuzzleState == 0x3F) { + if (sBgPoEventPuzzleState == 0x3F) { if (this->type == 1) { OnePointCutscene_Init(globalCtx, 3150, 65, NULL, MAIN_CAM); } @@ -244,14 +244,14 @@ void BgPoEvent_BlockWait(BgPoEvent* this, GlobalContext* globalCtx) { this->actionFunc = BgPoEvent_BlockShake; } else if (this->dyna.actor.xzDistToPlayer > 50.0f) { if (this->type != 1) { - sPuzzleState |= (1 << this->index); + sBgPoEventPuzzleState |= (1 << this->index); } else { - sPuzzleState |= 0x10; + sBgPoEventPuzzleState |= 0x10; } } else if (this->type != 1) { - sPuzzleState &= ~(1 << this->index); + sBgPoEventPuzzleState &= ~(1 << this->index); } else { - sPuzzleState &= ~0x10; + sBgPoEventPuzzleState &= ~0x10; } } @@ -265,7 +265,7 @@ void BgPoEvent_BlockShake(BgPoEvent* this, GlobalContext* globalCtx) { } if (this->timer == 0) { this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - sPuzzleState = 0; + sBgPoEventPuzzleState = 0; this->timer = 60; this->actionFunc = BgPoEvent_BlockFall; } @@ -299,9 +299,9 @@ void BgPoEvent_CheckBlock(BgPoEvent* this) { } } if ((phi_v1 == phi_a1) && ((phi_t0 - phi_a3) == 60)) { - sPuzzleState |= (1 << this->index); + sBgPoEventPuzzleState |= (1 << this->index); } else { - sPuzzleState &= ~(1 << this->index); + sBgPoEventPuzzleState &= ~(1 << this->index); } } @@ -312,7 +312,7 @@ void BgPoEvent_BlockFall(BgPoEvent* this, GlobalContext* globalCtx) { if (Math_StepToF(&this->dyna.actor.world.pos.y, 433.0f, this->dyna.actor.velocity.y)) { this->dyna.actor.flags &= ~ACTOR_FLAG_5; this->dyna.actor.velocity.y = 0.0f; - sBlocksAtRest++; + sBgPoEventBlocksAtRest++; if (this->type != 1) { BgPoEvent_CheckBlock(this); } else { @@ -334,7 +334,7 @@ void BgPoEvent_BlockIdle(BgPoEvent* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Actor* amy; - if (sPuzzleState == 0xF) { + if (sBgPoEventPuzzleState == 0xF) { this->actionFunc = BgPoEvent_BlockSolved; if ((this->type == 0) && (this->index == 0)) { amy = @@ -348,23 +348,23 @@ void BgPoEvent_BlockIdle(BgPoEvent* this, GlobalContext* globalCtx) { gSaveContext.timer1State = 0xA; } } else { - if ((gSaveContext.timer1Value == 0) && (sBlocksAtRest == 5)) { + if ((gSaveContext.timer1Value == 0) && (sBgPoEventBlocksAtRest == 5)) { player->stateFlags2 &= ~0x10; - sPuzzleState = 0x10; - sBlocksAtRest = 0; + sBgPoEventPuzzleState = 0x10; + sBgPoEventBlocksAtRest = 0; } - if ((sPuzzleState == 0x40) || ((sPuzzleState == 0x10) && !Player_InCsMode(globalCtx))) { + if ((sBgPoEventPuzzleState == 0x40) || ((sBgPoEventPuzzleState == 0x10) && !Player_InCsMode(globalCtx))) { this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z; this->actionFunc = BgPoEvent_BlockReset; - if (sPuzzleState == 0x10) { - sPuzzleState = 0x40; + if (sBgPoEventPuzzleState == 0x10) { + sBgPoEventPuzzleState = 0x40; Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_RISING); func_8002DF54(globalCtx, &player->actor, 8); } } else if (this->dyna.unk_150 != 0.0f) { if (this->direction == 0) { if (func_800435D8(globalCtx, &this->dyna, 0x1E, 0x32, -0x14) != 0) { - sBlocksAtRest--; + sBgPoEventBlocksAtRest--; this->direction = (this->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f; this->actionFunc = BgPoEvent_BlockPush; } else { @@ -382,16 +382,16 @@ void BgPoEvent_BlockIdle(BgPoEvent* this, GlobalContext* globalCtx) { } } -static f32 blockPushDist = 0.0f; +f32 sBgPoEventblockPushDist = 0.0f; void BgPoEvent_BlockPush(BgPoEvent* this, GlobalContext* globalCtx) { f32 displacement; s32 blockStop; Player* player = GET_PLAYER(globalCtx); - this->dyna.actor.speedXZ += 0.1f; + this->dyna.actor.speedXZ += CVar_GetS32("gFasterBlockPush", 0) != 0 ? 0.5f : 0.1f; this->dyna.actor.speedXZ = CLAMP_MAX(this->dyna.actor.speedXZ, 2.0f); - blockStop = Math_StepToF(&blockPushDist, 20.0f, this->dyna.actor.speedXZ); - displacement = this->direction * blockPushDist; + blockStop = Math_StepToF(&sBgPoEventblockPushDist, 20.0f, this->dyna.actor.speedXZ); + displacement = this->direction * sBgPoEventblockPushDist; this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.unk_158) * displacement) + this->dyna.actor.home.pos.x; this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.unk_158) * displacement) + this->dyna.actor.home.pos.z; if (blockStop) { @@ -402,10 +402,10 @@ void BgPoEvent_BlockPush(BgPoEvent* this, GlobalContext* globalCtx) { this->dyna.unk_150 = 0.0f; this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x; this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z; - blockPushDist = 0.0f; + sBgPoEventblockPushDist = 0.0f; this->dyna.actor.speedXZ = 0.0f; - this->direction = 5; - sBlocksAtRest++; + this->direction = CVar_GetS32("gFasterBlockPush", 0) != 0 ? 3 : 5; + sBgPoEventBlocksAtRest++; this->actionFunc = BgPoEvent_BlockIdle; if (this->type == 1) { return; @@ -428,7 +428,7 @@ void BgPoEvent_BlockReset(BgPoEvent* this, GlobalContext* globalCtx) { this->index = (this->index + 1) % 4; this->actionFunc = BgPoEvent_BlockFall; - sPuzzleState = 0; + sBgPoEventPuzzleState = 0; if (this->type == 1) { this->timer += 10; this->timer = CLAMP_MAX(this->timer, 120); @@ -443,14 +443,14 @@ void BgPoEvent_BlockSolved(BgPoEvent* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x10; } if (Math_StepToF(&this->dyna.actor.world.pos.y, 369.0f, 2.0f)) { - sPuzzleState = 0x20; + sBgPoEventPuzzleState = 0x20; Actor_Kill(&this->dyna.actor); } } void BgPoEvent_AmyWait(BgPoEvent* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { - sPuzzleState |= 0x20; + sBgPoEventPuzzleState |= 0x20; this->timer = 5; Actor_SetColorFilter(&this->dyna.actor, 0x4000, 0xFF, 0, 5); Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_PO_LAUGH2); @@ -461,12 +461,12 @@ void BgPoEvent_AmyWait(BgPoEvent* this, GlobalContext* globalCtx) { void BgPoEvent_AmyPuzzle(BgPoEvent* this, GlobalContext* globalCtx) { Vec3f pos; - if (sPuzzleState == 0xF) { + if (sBgPoEventPuzzleState == 0xF) { pos.x = this->dyna.actor.world.pos.x - 5.0f; pos.y = Rand_CenteredFloat(120.0f) + this->dyna.actor.world.pos.y; pos.z = Rand_CenteredFloat(120.0f) + this->dyna.actor.world.pos.z; EffectSsDeadDb_Spawn(globalCtx, &pos, &sZeroVec, &sZeroVec, 170, 0, 200, 255, 100, 170, 0, 255, 0, 1, 9, true); - } else if (sPuzzleState == 0x20) { + } else if (sBgPoEventPuzzleState == 0x20) { Actor_Kill(&this->dyna.actor); } else { DECR(this->timer); @@ -476,14 +476,14 @@ void BgPoEvent_AmyPuzzle(BgPoEvent* this, GlobalContext* globalCtx) { s32 BgPoEvent_NextPainting(BgPoEvent* this) { if ((this->dyna.actor.parent != NULL) && (this->dyna.actor.child != NULL)) { if (Rand_ZeroOne() < 0.5f) { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.parent)->index; + sBgPoEventPuzzleState = ((BgPoEvent*)this->dyna.actor.parent)->index; } else { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.child)->index; + sBgPoEventPuzzleState = ((BgPoEvent*)this->dyna.actor.child)->index; } } else if (this->dyna.actor.parent != NULL) { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.parent)->index; + sBgPoEventPuzzleState = ((BgPoEvent*)this->dyna.actor.parent)->index; } else if (this->dyna.actor.child != NULL) { - sPuzzleState = ((BgPoEvent*)this->dyna.actor.child)->index; + sBgPoEventPuzzleState = ((BgPoEvent*)this->dyna.actor.child)->index; } else { return false; } @@ -491,7 +491,7 @@ s32 BgPoEvent_NextPainting(BgPoEvent* this) { } void BgPoEvent_PaintingEmpty(BgPoEvent* this, GlobalContext* globalCtx) { - if (sPuzzleState == this->index) { + if (sBgPoEventPuzzleState == this->index) { this->timer = 255; this->actionFunc = BgPoEvent_PaintingAppear; } @@ -636,7 +636,7 @@ void BgPoEvent_Draw(Actor* thisx, GlobalContext* globalCtx) { } void BgPoEvent_Reset(void) { - sBlocksAtRest = 0; - sPuzzleState = 0; - blockPushDist = 0.0f; + sBgPoEventBlocksAtRest = 0; + sBgPoEventPuzzleState = 0; + sBgPoEventblockPushDist = 0.0f; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c b/soh/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c index 33e94d172..58d0f62d8 100644 --- a/soh/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c +++ b/soh/src/overlays/actors/ovl_Bg_Relay_Objects/z_bg_relay_objects.c @@ -45,7 +45,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -static u32 D_808A9508 = 0; +u32 D_808A9508 = 0; void BgRelayObjects_Init(Actor* thisx, GlobalContext* globalCtx) { BgRelayObjects* this = (BgRelayObjects*)thisx; s32 pad; diff --git a/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c b/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c index 240235917..684336e17 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c @@ -260,7 +260,7 @@ void func_808B4194(BgSpot15Rrbox* this, GlobalContext* globalCtx) { s32 approxFResult; Actor* actor = &this->dyna.actor; - this->unk_174 += 0.5f; + this->unk_174 += CVar_GetS32("gFasterBlockPush", 0) != 0 ? 1.0f : 0.5f; this->unk_174 = CLAMP_MAX(this->unk_174, 2.0f); @@ -294,7 +294,7 @@ void func_808B4194(BgSpot15Rrbox* this, GlobalContext* globalCtx) { this->dyna.unk_150 = 0.0f; this->unk_178 = 0.0f; this->unk_174 = 0.0f; - this->unk_168 = 10; + this->unk_168 = CVar_GetS32("gFasterBlockPush", 0) != 0 ? 3 : 10; func_808B4084(this, globalCtx); } Audio_PlayActorSound2(actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); diff --git a/soh/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c b/soh/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c index 2e9297e4c..caa727c69 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot18_Basket/z_bg_spot18_basket.c @@ -84,7 +84,7 @@ void func_808B7710(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; } -static s16 D_808B85D0 = 0; +s16 D_808B85D0 = 0; void func_808B7770(BgSpot18Basket* this, GlobalContext* globalCtx, f32 arg2) { Vec3f acceleration; Vec3f velocity; diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index 3b130b229..fa4d06b05 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -418,7 +418,7 @@ void BossDodongo_IntroCutscene(BossDodongo* this, GlobalContext* globalCtx) { if (this->unk_198 == 0x5A) { if (!(gSaveContext.eventChkInf[7] & 2)) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gKingDodongoTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + SEGMENTED_TO_VIRTUAL(gKingDodongoTitleCardTex), 160, 180, 128, 40, true); } Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); } diff --git a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index 6553b3c11..649774346 100644 --- a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -493,7 +493,7 @@ void BossFd_Fly(BossFd* this, GlobalContext* globalCtx) { } if ((this->timers[3] == 130) && !(gSaveContext.eventChkInf[7] & 8)) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gVolvagiaBossTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + SEGMENTED_TO_VIRTUAL(gVolvagiaBossTitleCardTex), 160, 180, 128, 40, true); } if (this->timers[3] <= 100) { this->camData.eyeVel.x = this->camData.eyeVel.y = this->camData.eyeVel.z = 2.0f; diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index c5c19f864..f7132bcaf 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -105,35 +105,17 @@ static ColliderCylinderInit sLightBallCylinderInit = { static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 }; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static EnGanonMant* sCape; +EnGanonMant* sBossGanonCape; -static s32 sSeed1; -static s32 sSeed2; -static s32 sSeed3; +s32 sBossGanonSeed1; +s32 sBossGanonSeed3; +s32 sBossGanonSeed2; -static BossGanon* sGanondorf; +BossGanon* sBossGanonGanondorf; -static EnZl3* sZelda; +EnZl3* sBossGanonZelda; -typedef struct { - /* 0x00 */ u8 type; - /* 0x01 */ u8 timer; - /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f accel; - /* 0x28 */ Color_RGB8 color; - /* 0x2C */ s16 alpha; - /* 0x2E */ s16 unk_2E; - /* 0x30 */ s16 unk_30; - /* 0x34 */ f32 scale; - /* 0x38 */ f32 unk_38; // scale target mostly, but used for other things - /* 0x3C */ f32 unk_3C; // mostly z rot - /* 0x40 */ f32 unk_40; - /* 0x44 */ f32 unk_44; // mostly x rot - /* 0x48 */ f32 unk_48; // mostly y rot -} GanondorfEffect; // size = 0x4C - -GanondorfEffect sEffectBuf[200]; +GanondorfEffect sBossGanonEffectBuf[200]; void BossGanonEff_SpawnWindowShard(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, f32 scale) { static Color_RGB8 shardColors[] = { { 255, 175, 85 }, { 155, 205, 155 }, { 155, 125, 55 } }; @@ -348,13 +330,13 @@ void BossGanon_Init(Actor* thisx, GlobalContext* globalCtx2) { if (thisx->params < 0x64) { Flags_SetSwitch(globalCtx, 0x14); - globalCtx->specialEffects = sEffectBuf; + globalCtx->specialEffects = sBossGanonEffectBuf; - for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++) { - sEffectBuf[i].type = GDF_EFF_NONE; + for (i = 0; i < ARRAY_COUNT(sBossGanonEffectBuf); i++) { + sBossGanonEffectBuf[i].type = GDF_EFF_NONE; } - sGanondorf = this; + sBossGanonGanondorf = this; thisx->colChkInfo.health = 40; Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0, NULL, 0); @@ -381,7 +363,7 @@ void BossGanon_Init(Actor* thisx, GlobalContext* globalCtx2) { BossGanon_SetupTowerCutscene(this, globalCtx); } - sCape = (EnGanonMant*)Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_GANON_MANT, 0.0f, + sBossGanonCape = (EnGanonMant*)Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_GANON_MANT, 0.0f, 0.0f, 0.0f, 0, 0, 0, 1); Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_BOSS); } else { @@ -538,10 +520,10 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { gSegments[6] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[this->animBankIndex].segment); - sCape->backPush = -2.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -1.0f; - sCape->minDist = 0.0f; + sBossGanonCape->backPush = -2.0f; + sBossGanonCape->backSwayMagnitude = 0.25f; + sBossGanonCape->sideSwayMagnitude = -1.0f; + sBossGanonCape->minDist = 0.0f; this->csTimer++; @@ -584,13 +566,13 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { this->useOpenHand = true; BossGanon_SetIntroCsCamera(this, 0); this->csState = 1; - sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, + sBossGanonZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, 220.0f, -150.0f, 0, 0, 0, 0x2000); } Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_GANON_ORGAN, 0.0f, 0.0f, 0.0f, 0, 0, 0, 1); - sCape->minY = 57.0f; + sBossGanonCape->minY = 57.0f; // fallthrough case 1: this->envLightMode = 3; @@ -736,7 +718,7 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { this->csState = 9; this->csTimer = 0; func_8002DF54(globalCtx, &this->actor, 8); - sZelda->unk_3C8 = 0; + sBossGanonZelda->unk_3C8 = 0; this->triforceType = GDF_TRIFORCE_ZELDA; this->fwork[GDF_TRIFORCE_SCALE] = 10.0f; this->fwork[GDF_TRIFORCE_PRIM_A] = 0.0f; @@ -755,7 +737,7 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { Math_ApproachF(&this->fwork[GDF_TRIFORCE_ENV_G], 200.0f, 1.0f, 3.0f); if (this->csTimer == 30) { - sZelda->unk_3C8 = 1; + sBossGanonZelda->unk_3C8 = 1; } if (this->csTimer >= 32) { @@ -847,7 +829,7 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { this->csTimer = 0; BossGanon_SetIntroCsCamera(this, 11); this->unk_198 = 2; - sZelda->unk_3C8 = 2; + sBossGanonZelda->unk_3C8 = 2; this->timers[2] = 110; this->envLightMode = 3; } @@ -883,7 +865,7 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { if (this->csTimer > 10) { if (this->csTimer == 62) { - sCape->attachRightArmTimer = 20.0f; + sBossGanonCape->attachRightArmTimer = 20.0f; } if (this->csTimer == 57) { @@ -1076,7 +1058,7 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); SkelAnime_Update(&this->skelAnime); this->actor.shape.yOffset = 0.0f; - sCape->attachShouldersTimer = 18.0f; + sBossGanonCape->attachShouldersTimer = 18.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); this->unk_198 = 0; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_GANONDORF_BOSS); @@ -1088,7 +1070,7 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { if (!(gSaveContext.eventChkInf[7] & 0x100)) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gDorfTitleCardTex), 160, 180, 128, 40); + SEGMENTED_TO_VIRTUAL(gDorfTitleCardTex), 160, 180, 128, 40, false); } gSaveContext.eventChkInf[7] |= 0x100; @@ -1101,9 +1083,9 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.world.pos.y, 228.0f, 0.05f, 2.0f); Math_ApproachF(&this->actor.world.pos.z, -230.0f, 0.05f, 4.0f); - sCape->backPush = -3.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -3.0f; + sBossGanonCape->backPush = -3.0f; + sBossGanonCape->backSwayMagnitude = 0.25f; + sBossGanonCape->sideSwayMagnitude = -3.0f; sin = Math_SinS(this->csTimer * 1500); this->actor.velocity.y = this->fwork[GDF_FWORK_0] * sin * 0.04f; @@ -1136,10 +1118,10 @@ void BossGanon_IntroCutscene(BossGanon* this, GlobalContext* globalCtx) { BossGanon_SetupWait(this, globalCtx); } - if (sZelda != NULL) { - sZelda->actor.world.pos.x = 0.0f; - sZelda->actor.world.pos.y = 350.0f; - sZelda->actor.world.pos.z = 0.0f; + if (sBossGanonZelda != NULL) { + sBossGanonZelda->actor.world.pos.x = 0.0f; + sBossGanonZelda->actor.world.pos.y = 350.0f; + sBossGanonZelda->actor.world.pos.z = 0.0f; } } @@ -1529,7 +1511,7 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) this->fwork[1] = Animation_GetLastFrame(&object_ganon_anime2_Anim_00EA00); this->csState = 101; this->skelAnime.playSpeed = 0.0f; - sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, + sBossGanonZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 0.0f, 6000.0f, 0.0f, 0, 0, 0, 0x2000); player->actor.world.pos.x = -472.0f; @@ -1551,12 +1533,12 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) this->csCamAt.z = -100.0f; - sCape->backPush = -2.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -1.0f; - sCape->minDist = 0.0f; - sCape->minY = 4104.0f; - sCape->tearTimer = 20; + sBossGanonCape->backPush = -2.0f; + sBossGanonCape->backSwayMagnitude = 0.25f; + sBossGanonCape->sideSwayMagnitude = -1.0f; + sBossGanonCape->minDist = 0.0f; + sBossGanonCape->minY = 4104.0f; + sBossGanonCape->tearTimer = 20; this->whiteFillAlpha = 255.0f; globalCtx->envCtx.unk_D8 = 1.0f; @@ -1620,27 +1602,27 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) if (this->csTimer == 90) { this->csState = 103; this->csTimer = 0; - sZelda->actor.world.pos.x = -472.0f; - sZelda->actor.world.pos.y = 4352.0f; - sZelda->actor.world.pos.z = -200.0f; - sZelda->unk_3C8 = 3; + sBossGanonZelda->actor.world.pos.x = -472.0f; + sBossGanonZelda->actor.world.pos.y = 4352.0f; + sBossGanonZelda->actor.world.pos.z = -200.0f; + sBossGanonZelda->unk_3C8 = 3; } break; case 103: - Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_DOWN_TO_GROUND - SFX_FLAG); - Math_ApproachF(&sZelda->actor.world.pos.y, 4102.0f, 0.05f, 1.5f); + Audio_PlayActorSound2(&sBossGanonZelda->actor, NA_SE_EV_DOWN_TO_GROUND - SFX_FLAG); + Math_ApproachF(&sBossGanonZelda->actor.world.pos.y, 4102.0f, 0.05f, 1.5f); this->csCamEye.x = -242.0f; this->csCamEye.y = 4122.0f; this->csCamEye.z = -190.0f; - this->csCamAt.x = sZelda->actor.world.pos.x; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z; + this->csCamAt.x = sBossGanonZelda->actor.world.pos.x; + this->csCamAt.y = sBossGanonZelda->actor.world.pos.y + 40.0f + 5.0f; + this->csCamAt.z = sBossGanonZelda->actor.world.pos.z; if (this->csTimer == 200) { - sZelda->actor.world.pos.y = 4102.0f; + sBossGanonZelda->actor.world.pos.y = 4102.0f; this->csState = 104; this->csTimer = 0; } else { @@ -1652,20 +1634,20 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) this->csCamEye.y = 4147.0f; this->csCamEye.z = -200.0f; - this->csCamAt.x = sZelda->actor.world.pos.x; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z; + this->csCamAt.x = sBossGanonZelda->actor.world.pos.x; + this->csCamAt.y = sBossGanonZelda->actor.world.pos.y + 40.0f + 5.0f; + this->csCamAt.z = sBossGanonZelda->actor.world.pos.z; if (this->csTimer >= 10) { Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); } if (this->csTimer == 10) { - sZelda->unk_3C8 = 8; + sBossGanonZelda->unk_3C8 = 8; } if (this->csTimer == 50) { - sZelda->unk_3C8 = 4; + sBossGanonZelda->unk_3C8 = 4; } if (this->csTimer == 100) { @@ -1679,9 +1661,9 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) this->csCamEye.y = 4154.0f; this->csCamEye.z = -182.0f; - this->csCamAt.x = sZelda->actor.world.pos.x - 5.0f; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z - 25.0f; + this->csCamAt.x = sBossGanonZelda->actor.world.pos.x - 5.0f; + this->csCamAt.y = sBossGanonZelda->actor.world.pos.y + 40.0f + 5.0f; + this->csCamAt.z = sBossGanonZelda->actor.world.pos.z - 25.0f; if (this->csTimer == 10) { Message_StartTextbox(globalCtx, 0x70D0, NULL); @@ -1698,7 +1680,7 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); if (this->csTimer == 20) { - sZelda->unk_3C8 = 5; + sBossGanonZelda->unk_3C8 = 5; func_8002DF54(globalCtx, &this->actor, 0x39); } @@ -1747,15 +1729,15 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) this->csCamEye.y = 4154.0f; this->csCamEye.z = -182.0f; - this->csCamAt.x = sZelda->actor.world.pos.x - 5.0f; - this->csCamAt.y = sZelda->actor.world.pos.y + 40.0f + 5.0f; - this->csCamAt.z = sZelda->actor.world.pos.z - 25.0f; + this->csCamAt.x = sBossGanonZelda->actor.world.pos.x - 5.0f; + this->csCamAt.y = sBossGanonZelda->actor.world.pos.y + 40.0f + 5.0f; + this->csCamAt.z = sBossGanonZelda->actor.world.pos.z - 25.0f; this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.3f; func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); if (this->csTimer == 70) { - sZelda->unk_3C8 = 6; + sBossGanonZelda->unk_3C8 = 6; } if (this->csTimer == 90) { @@ -1778,12 +1760,12 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) this->csCamEye.y = 4154.0f; this->csCamEye.z = -242.0f; - this->csCamAt.x = (sZelda->actor.world.pos.x - 5.0f) - 30.0f; - this->csCamAt.y = (sZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; - this->csCamAt.z = (sZelda->actor.world.pos.z - 25.0f) + 80.0f; + this->csCamAt.x = (sBossGanonZelda->actor.world.pos.x - 5.0f) - 30.0f; + this->csCamAt.y = (sBossGanonZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; + this->csCamAt.z = (sBossGanonZelda->actor.world.pos.z - 25.0f) + 80.0f; if ((this->csTimer > 50) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) { - sZelda->unk_3C8 = 7; + sBossGanonZelda->unk_3C8 = 7; this->csState = 108; this->csTimer = 0; } @@ -1793,9 +1775,9 @@ void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) this->unk_70C = Math_SinS(this->csTimer * 0x6300) * 0.8f; func_80078884(NA_SE_EV_EARTHQUAKE - SFX_FLAG); - this->csCamAt.x = (sZelda->actor.world.pos.x - 5.0f) - 30.0f; - this->csCamAt.y = (sZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; - this->csCamAt.z = (sZelda->actor.world.pos.z - 25.0f) + 80.0f; + this->csCamAt.x = (sBossGanonZelda->actor.world.pos.x - 5.0f) - 30.0f; + this->csCamAt.y = (sBossGanonZelda->actor.world.pos.y + 40.0f + 5.0f) - 20.0f; + this->csCamAt.z = (sBossGanonZelda->actor.world.pos.z - 25.0f) + 80.0f; if (this->csTimer > 50) { mainCam = Gameplay_GetCamera(globalCtx, MAIN_CAM); @@ -1905,7 +1887,7 @@ void BossGanon_PoundFloor(BossGanon* this, GlobalContext* globalCtx) { break; case 1: - sCape->gravity = -1.0f; + sBossGanonCape->gravity = -1.0f; this->envLightMode = 1; Math_ApproachF(&this->actor.velocity.y, -50.0f, 1.0f, 10.0f); this->actor.world.pos.y += this->actor.velocity.y; @@ -1952,7 +1934,7 @@ void BossGanon_PoundFloor(BossGanon* this, GlobalContext* globalCtx) { this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp3Anim); Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 18.0f; + sBossGanonCape->attachShouldersTimer = 18.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); this->unk_1C2 = 4; } @@ -2136,7 +2118,7 @@ void BossGanon_ChargeBigMagic(BossGanon* this, GlobalContext* globalCtx) { } if (this->timers[0] == 1) { - sCape->attachLeftArmTimer = 15.0f; + sBossGanonCape->attachLeftArmTimer = 15.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); } @@ -2174,7 +2156,7 @@ void BossGanon_ChargeBigMagic(BossGanon* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - sCape->attachShouldersTimer = 26.0f; + sBossGanonCape->attachShouldersTimer = 26.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); } @@ -2202,7 +2184,7 @@ void BossGanon_SetupWait(BossGanon* this, GlobalContext* globalCtx) { this->fwork[GDF_FWORK_0] = 0.0f; this->timers[0] = (s16)Rand_ZeroFloat(64.0f) + 30; this->unk_1C2 = 0; - sCape->minY = 2.0f; + sBossGanonCape->minY = 2.0f; } void BossGanon_Wait(BossGanon* this, GlobalContext* globalCtx) { @@ -2213,10 +2195,10 @@ void BossGanon_Wait(BossGanon* this, GlobalContext* globalCtx) { this->legSwayEnabled = true; - sCape->backPush = -3.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -3.0f; - sCape->minDist = 20.0f; + sBossGanonCape->backPush = -3.0f; + sBossGanonCape->backSwayMagnitude = 0.25f; + sBossGanonCape->sideSwayMagnitude = -3.0f; + sBossGanonCape->minDist = 20.0f; SkelAnime_Update(&this->skelAnime); @@ -2271,10 +2253,10 @@ void BossGanon_SetupChargeLightBall(BossGanon* this, GlobalContext* globalCtx) { void BossGanon_ChargeLightBall(BossGanon* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - sCape->backPush = -3.0f; - sCape->backSwayMagnitude = 1.25f; - sCape->sideSwayMagnitude = -2.0f; - sCape->minDist = 10.0f; + sBossGanonCape->backPush = -3.0f; + sBossGanonCape->backSwayMagnitude = 1.25f; + sBossGanonCape->sideSwayMagnitude = -2.0f; + sBossGanonCape->minDist = 10.0f; if (this->timers[0] < 17) { this->envLightMode = 1; @@ -2355,7 +2337,7 @@ void BossGanon_PlayTennis(BossGanon* this, GlobalContext* globalCtx) { rand = Rand_ZeroOne() * 1.99f; this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(volleyAnims[rand]); Animation_MorphToPlayOnce(&this->skelAnime, volleyAnims[rand], 0.0f); - sCape->attachRightArmTimer = capeRightArmDurations[rand]; + sBossGanonCape->attachRightArmTimer = capeRightArmDurations[rand]; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); this->startVolley = false; } @@ -2383,7 +2365,7 @@ void BossGanon_SetupBlock(BossGanon* this, GlobalContext* globalCtx) { } this->unk_1C2 = 0; - sCape->attachLeftArmTimer = this->timers[0] = 10; + sBossGanonCape->attachLeftArmTimer = this->timers[0] = 10; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); this->handLightBallScale = 0.0f; } @@ -2391,10 +2373,10 @@ void BossGanon_SetupBlock(BossGanon* this, GlobalContext* globalCtx) { void BossGanon_Block(BossGanon* this, GlobalContext* globalCtx) { this->collider.base.colType = 9; SkelAnime_Update(&this->skelAnime); - sCape->backPush = -9.0f; - sCape->backSwayMagnitude = 0.25f; - sCape->sideSwayMagnitude = -2.0f; - sCape->minDist = 13.0f; + sBossGanonCape->backPush = -9.0f; + sBossGanonCape->backSwayMagnitude = 0.25f; + sBossGanonCape->sideSwayMagnitude = -2.0f; + sBossGanonCape->minDist = 13.0f; if (this->unk_1C2 == 0) { if (this->timers[0] == 0) { @@ -2402,11 +2384,11 @@ void BossGanon_Block(BossGanon* this, GlobalContext* globalCtx) { Animation_MorphToPlayOnce(&this->skelAnime, &gDorfBlockReleaseAnim, 0.0f); this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBlockReleaseAnim); SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 15.0f; + sBossGanonCape->attachShouldersTimer = 15.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); } } else { - sCape->sideSwayMagnitude = -13.0f; + sBossGanonCape->sideSwayMagnitude = -13.0f; if (Animation_OnFrame(&this->skelAnime, this->fwork[GDF_FWORK_1])) { BossGanon_SetupWait(this, globalCtx); @@ -2429,7 +2411,7 @@ void BossGanon_SetupHitByLightBall(BossGanon* this, GlobalContext* globalCtx) { this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfBigMagicHitAnim); Animation_MorphToPlayOnce(&this->skelAnime, &gDorfBigMagicHitAnim, 0); this->timers[0] = 70; - sCape->attachRightArmTimer = sCape->attachLeftArmTimer = 0; + sBossGanonCape->attachRightArmTimer = sBossGanonCape->attachLeftArmTimer = 0; for (i = 1; i < 15; i++) { this->unk_4E4[i] = D_808E4C58[i]; @@ -2466,7 +2448,7 @@ void BossGanon_HitByLightBall(BossGanon* this, GlobalContext* globalCtx) { Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); this->unk_1C2 = 2; SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 18.0f; + sBossGanonCape->attachShouldersTimer = 18.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_RESTORE); this->timers[2] = 130; @@ -2500,7 +2482,7 @@ void BossGanon_SetupVulnerable(BossGanon* this, GlobalContext* globalCtx) { BossGanon_SetAnimationObject(this, globalCtx, OBJECT_GANON_ANIME1); this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfLightArrowHitAnim); Animation_MorphToPlayOnce(&this->skelAnime, &gDorfLightArrowHitAnim, 0.0f); - sCape->attachRightArmTimer = sCape->attachLeftArmTimer = 0; + sBossGanonCape->attachRightArmTimer = sBossGanonCape->attachLeftArmTimer = 0; this->actionFunc = BossGanon_Vulnerable; this->actor.velocity.x = 0.0f; @@ -2508,10 +2490,10 @@ void BossGanon_SetupVulnerable(BossGanon* this, GlobalContext* globalCtx) { this->actor.velocity.z = 0.0f; this->unk_1C2 = 0; - sCape->backPush = -4.0f; - sCape->backSwayMagnitude = 0.75f; - sCape->sideSwayMagnitude = -3.0f; - sCape->minDist = 20.0f; + sBossGanonCape->backPush = -4.0f; + sBossGanonCape->backSwayMagnitude = 0.75f; + sBossGanonCape->sideSwayMagnitude = -3.0f; + sBossGanonCape->minDist = 20.0f; for (i = 0; i < 10; i++) { Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_GANON, this->unk_1FC.x, @@ -2571,7 +2553,7 @@ void BossGanon_Vulnerable(BossGanon* this, GlobalContext* globalCtx) { break; case 2: - sCape->minDist = 0.0f; + sBossGanonCape->minDist = 0.0f; this->actor.velocity.y = this->actor.velocity.y - 0.5f; if (this->actor.world.pos.y < 40.0f) { @@ -2625,7 +2607,7 @@ void BossGanon_Vulnerable(BossGanon* this, GlobalContext* globalCtx) { this->unk_1C2 = 6; this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gDorfGetUp2Anim); Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp2Anim, 0.0f); - sCape->minDist = 20.0f; + sBossGanonCape->minDist = 20.0f; this->unk_19F = 1; } break; @@ -2646,7 +2628,7 @@ void BossGanon_Vulnerable(BossGanon* this, GlobalContext* globalCtx) { Animation_MorphToPlayOnce(&this->skelAnime, &gDorfGetUp3Anim, 0.0f); this->unk_1C2 = 8; SkelAnime_Update(&this->skelAnime); - sCape->attachShouldersTimer = 18.0f; + sBossGanonCape->attachShouldersTimer = 18.0f; Audio_PlayActorSound2(&this->actor, NA_SE_EV_GANON_MANTLE); Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_RESTORE); break; @@ -2743,10 +2725,10 @@ void BossGanon_UpdateDamage(BossGanon* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health -= damage; } - for (i = 0; i < ARRAY_COUNT(sCape->strands); i++) { + for (i = 0; i < ARRAY_COUNT(sBossGanonCape->strands); i++) { for (j = 1; j < 12; j++) { - sCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); - sCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); + sBossGanonCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); + sBossGanonCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); } } @@ -2762,16 +2744,16 @@ void BossGanon_UpdateDamage(BossGanon* this, GlobalContext* globalCtx) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_GANON_CUTBODY); BossGanon_SetupDamaged(this, globalCtx); this->unk_1A6 = 15; - sCape->tearTimer = 1; + sBossGanonCape->tearTimer = 1; } } } else if (acHitInfo->toucher.dmgFlags & 0x1F8A4) { Audio_PlayActorSound2(&this->actor, 0); - for (i = 0; i < ARRAY_COUNT(sCape->strands); i++) { + for (i = 0; i < ARRAY_COUNT(sBossGanonCape->strands); i++) { for (j = 1; j < 12; j++) { - sCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); - sCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); + sBossGanonCape->strands[i].velocities[j].x = Rand_CenteredFloat(15.0f); + sBossGanonCape->strands[i].velocities[j].z = Rand_CenteredFloat(15.0f); } } } @@ -2841,7 +2823,7 @@ void BossGanon_Update(Actor* thisx, GlobalContext* globalCtx2) { } this->collider.base.colType = 3; - sCape->gravity = -3.0f; + sBossGanonCape->gravity = -3.0f; this->shockGlow = false; this->actor.flags &= ~ACTOR_FLAG_0; this->unk_1A2++; @@ -3334,20 +3316,20 @@ void BossGanon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } void BossGanon_InitRand(s32 seedInit0, s32 seedInit1, s32 seedInit2) { - sSeed1 = seedInit0; - sSeed2 = seedInit1; - sSeed3 = seedInit2; + sBossGanonSeed1 = seedInit0; + sBossGanonSeed2 = seedInit1; + sBossGanonSeed3 = seedInit2; } f32 BossGanon_RandZeroOne(void) { // Wichmann-Hill algorithm f32 randFloat; - sSeed1 = (sSeed1 * 171) % 30269; - sSeed2 = (sSeed2 * 172) % 30307; - sSeed3 = (sSeed3 * 170) % 30323; + sBossGanonSeed1 = (sBossGanonSeed1 * 171) % 30269; + sBossGanonSeed2 = (sBossGanonSeed2 * 172) % 30307; + sBossGanonSeed3 = (sBossGanonSeed3 * 170) % 30323; - randFloat = (sSeed1 / 30269.0f) + (sSeed2 / 30307.0f) + (sSeed3 / 30323.0f); + randFloat = (sBossGanonSeed1 / 30269.0f) + (sBossGanonSeed2 / 30307.0f) + (sBossGanonSeed3 / 30323.0f); while (randFloat >= 1.0f) { randFloat -= 1.0f; @@ -3559,7 +3541,7 @@ void BossGanon_DrawTriforce(BossGanon* this, GlobalContext* globalCtx) { this->triforcePos.y += 3.0f; this->triforcePos.z += -2.0f; } else if (this->triforceType == GDF_TRIFORCE_ZELDA) { - this->triforcePos = sZelda->unk_31C; + this->triforcePos = sBossGanonZelda->unk_31C; this->triforcePos.y += 1.8f; this->triforcePos.z += 4.0f; @@ -3734,9 +3716,9 @@ void BossGanon_GenShadowTexture(u8* tex, BossGanon* this, GlobalContext* globalC for (i = 0; i < 12; i++) { for (j = 0; j < 12; j++) { - sp7C.x = sCape->strands[i].joints[j].x - this->actor.world.pos.x; - sp7C.y = sCape->strands[i].joints[j].y - this->actor.world.pos.y + 76.0f + 100.0f + 30.0f; - sp7C.z = sCape->strands[i].joints[j].z - this->actor.world.pos.z; + sp7C.x = sBossGanonCape->strands[i].joints[j].x - this->actor.world.pos.x; + sp7C.y = sBossGanonCape->strands[i].joints[j].y - this->actor.world.pos.y + 76.0f + 100.0f + 30.0f; + sp7C.z = sBossGanonCape->strands[i].joints[j].z - this->actor.world.pos.z; Matrix_MultVec3f(&sp7C, &sp70); @@ -3746,7 +3728,7 @@ void BossGanon_GenShadowTexture(u8* tex, BossGanon* this, GlobalContext* globalC baseX = (s32)(sp70.x + 32.0f); baseY = (s16)sp70.y * 0x40; - if (!sCape->strands[i].torn[j]) { + if (!sBossGanonCape->strands[i].torn[j]) { for (y = -1, addY = -0x40; y <= 1; y++, addY += 0x40) { for (x = -3; x <= 3; x++) { index = baseX + x + baseY + addY; @@ -3827,13 +3809,13 @@ void BossGanon_Draw(Actor* thisx, GlobalContext* globalCtx) { BossGanon_DrawEffects(globalCtx); - sCape->actor.world.pos = this->actor.world.pos; + sBossGanonCape->actor.world.pos = this->actor.world.pos; - sCape->rightForearmPos = this->unk_214; - sCape->leftForearmPos = this->unk_220; + sBossGanonCape->rightForearmPos = this->unk_214; + sBossGanonCape->leftForearmPos = this->unk_220; - sCape->rightShoulderPos = this->unk_22C; - sCape->leftShoulderPos = this->unk_238; + sBossGanonCape->rightShoulderPos = this->unk_22C; + sBossGanonCape->leftShoulderPos = this->unk_238; BossGanon_DrawShock(this, globalCtx); BossGanon_DrawHandLightBall(this, globalCtx); @@ -4628,7 +4610,7 @@ void BossGanon_UpdateEffects(GlobalContext* globalCtx) { spA0.x = 0.0f; spA0.y = 0.0f; - for (i = 0; i < ARRAY_COUNT(sEffectBuf); i++, eff++) { + for (i = 0; i < ARRAY_COUNT(sBossGanonEffectBuf); i++, eff++) { if (eff->type != GDF_EFF_NONE) { eff->pos.x += eff->velocity.x; eff->pos.y += eff->velocity.y; @@ -4662,9 +4644,9 @@ void BossGanon_UpdateEffects(GlobalContext* globalCtx) { eff->alpha = 255; } } else if (eff->type == GDF_EFF_BLACK_DOT) { - xDiff = sGanondorf->unk_278.x - eff->pos.x; - yDiff = sGanondorf->unk_278.y - eff->pos.y; - zDiff = sGanondorf->unk_278.z - eff->pos.z; + xDiff = sBossGanonGanondorf->unk_278.x - eff->pos.x; + yDiff = sBossGanonGanondorf->unk_278.y - eff->pos.y; + zDiff = sBossGanonGanondorf->unk_278.z - eff->pos.z; yRot = Math_FAtan2F(xDiff, zDiff); @@ -4704,9 +4686,9 @@ void BossGanon_UpdateEffects(GlobalContext* globalCtx) { if (eff->unk_2E == GDF_SHOCK_DORF_YELLOW) { bodyPart = (s16)Rand_ZeroFloat(13.9f) + 1; - eff->pos.x = sGanondorf->unk_2EC[bodyPart].x + Rand_CenteredFloat(20.0f); - eff->pos.y = sGanondorf->unk_2EC[bodyPart].y + Rand_CenteredFloat(20.0f); - eff->pos.z = sGanondorf->unk_2EC[bodyPart].z + Rand_CenteredFloat(20.0f); + eff->pos.x = sBossGanonGanondorf->unk_2EC[bodyPart].x + Rand_CenteredFloat(20.0f); + eff->pos.y = sBossGanonGanondorf->unk_2EC[bodyPart].y + Rand_CenteredFloat(20.0f); + eff->pos.z = sBossGanonGanondorf->unk_2EC[bodyPart].z + Rand_CenteredFloat(20.0f); } else { bodyPart = (s16)Rand_ZeroFloat(17.9f); @@ -4799,7 +4781,7 @@ void BossGanon_UpdateEffects(GlobalContext* globalCtx) { if (((eff->scale * 150.0f) < distToPlayer) && (distToPlayer < (eff->scale * 300.0f))) { eff->timer = 150; - func_8002F6D4(globalCtx, &sGanondorf->actor, 7.0f, sGanondorf->actor.yawTowardsPlayer, 0.0f, + func_8002F6D4(globalCtx, &sBossGanonGanondorf->actor, 7.0f, sBossGanonGanondorf->actor.yawTowardsPlayer, 0.0f, 0x20); } } @@ -4940,7 +4922,7 @@ void BossGanon_DrawEffects(GlobalContext* globalCtx) { 255); gDPSetEnvColor(POLY_XLU_DISP++, sLightningEnvColors[(eff->timer * 3) + 0], sLightningEnvColors[(eff->timer * 3) + 1], sLightningEnvColors[(eff->timer * 3) + 2], 0); - Matrix_Translate(sGanondorf->unk_260.x, sGanondorf->unk_260.y, sGanondorf->unk_260.z, MTXMODE_NEW); + Matrix_Translate(sBossGanonGanondorf->unk_260.x, sBossGanonGanondorf->unk_260.y, sBossGanonGanondorf->unk_260.z, MTXMODE_NEW); Matrix_RotateY(eff->unk_48, MTXMODE_APPLY); Matrix_RotateZ(eff->unk_3C, MTXMODE_APPLY); Matrix_Scale(eff->scale, eff->scale, eff->scale, MTXMODE_APPLY); @@ -5032,16 +5014,11 @@ void BossGanon_DrawEffects(GlobalContext* globalCtx) { #include "overlays/ovl_Boss_Ganon/ovl_Boss_Ganon.h" void BossGanon_Reset(void) { - -static EnGanonMant* sCape; - - sSeed1 = 0; - sSeed2 = 0; - sSeed3 = 0; - sGanondorf = NULL; - sZelda = NULL; - sCape = NULL; - - - memset(sEffectBuf, 0, sizeof(sEffectBuf)); + sBossGanonSeed1 = 0; + sBossGanonSeed2 = 0; + sBossGanonSeed3 = 0; + sBossGanonGanondorf = NULL; + sBossGanonZelda = NULL; + sBossGanonCape = NULL; + memset(sBossGanonEffectBuf, 0, sizeof(sBossGanonEffectBuf)); } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h index a3e3e503e..69a983717 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.h @@ -53,6 +53,24 @@ typedef enum { /* 2 */ GDF_TRIFORCE_DORF } GanondorfTriforceType; +typedef struct { + /* 0x00 */ u8 type; + /* 0x01 */ u8 timer; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ Color_RGB8 color; + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 unk_2E; + /* 0x30 */ s16 unk_30; + /* 0x34 */ f32 scale; + /* 0x38 */ f32 unk_38; // scale target mostly, but used for other things + /* 0x3C */ f32 unk_3C; // mostly z rot + /* 0x40 */ f32 unk_40; + /* 0x44 */ f32 unk_44; // mostly x rot + /* 0x48 */ f32 unk_48; // mostly y rot +} GanondorfEffect; // size = 0x4C + typedef struct BossGanon { /* 0x0000 */ Actor actor; /* 0x014C */ s32 animBankIndex; diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 74da86927..b946054b8 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -49,21 +49,40 @@ const ActorInit Boss_Ganon2_InitVars = { #include "z_boss_ganon2_data.c" +Vec3f D_8090EB20; + +EnZl3* sBossGanon2Zelda; + +Actor* D_8090EB30; + +BossGanon2Effect sBossGanon2Particles[100]; + +s32 sBossGanon2Seed1; +s32 sBossGanon2Seed2; +s32 sBossGanon2Seed3; + +Vec3f D_809105D8[4]; + +Vec3f D_80910608[4]; + +s8 D_80910638; + + void BossGanon2_InitRand(s32 seedInit0, s32 seedInit1, s32 seedInit2) { - sSeed1 = seedInit0; - sSeed2 = seedInit1; - sSeed3 = seedInit2; + sBossGanon2Seed1 = seedInit0; + sBossGanon2Seed2 = seedInit1; + sBossGanon2Seed3 = seedInit2; } f32 BossGanon2_RandZeroOne(void) { // Wichmann-Hill algorithm f32 randFloat; - sSeed1 = (sSeed1 * 171) % 30269; - sSeed2 = (sSeed2 * 172) % 30307; - sSeed3 = (sSeed3 * 170) % 30323; + sBossGanon2Seed1 = (sBossGanon2Seed1 * 171) % 30269; + sBossGanon2Seed2 = (sBossGanon2Seed2 * 172) % 30307; + sBossGanon2Seed3 = (sBossGanon2Seed3 * 170) % 30323; - randFloat = (sSeed1 / 30269.0f) + (sSeed2 / 30307.0f) + (sSeed3 / 30323.0f); + randFloat = (sBossGanon2Seed1 / 30269.0f) + (sBossGanon2Seed2 / 30307.0f) + (sBossGanon2Seed3 / 30323.0f); while (randFloat >= 1.0f) { randFloat -= 1.0f; } @@ -114,7 +133,7 @@ void func_808FD27C(GlobalContext* globalCtx, Vec3f* position, Vec3f* velocity, f BossGanon2Effect* effect = globalCtx->specialEffects; s16 i; - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + for (i = 0; i < ARRAY_COUNT(sBossGanon2Particles); i++, effect++) { if (effect->type == 0) { effect->type = 2; effect->position = *position; @@ -136,10 +155,10 @@ void BossGanon2_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; s16 i; - globalCtx->specialEffects = sParticles; + globalCtx->specialEffects = sBossGanon2Particles; - for (i = 0; i < ARRAY_COUNT(sParticles); i++) { - sParticles[i].type = 0; + for (i = 0; i < ARRAY_COUNT(sBossGanon2Particles); i++) { + sBossGanon2Particles[i].type = 0; } this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -204,13 +223,13 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); Gameplay_ChangeCameraStatus(globalCtx, this->unk_39E, CAM_STAT_ACTIVE); this->unk_39C = 1; - sZelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 970.0f, + sBossGanon2Zelda = (EnZl3*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ZL3, 970.0f, 1086.0f, -200.0f, 0, 0, 0, 1); - sZelda->unk_3C8 = 0; - sZelda->actor.world.pos.x = 970.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -214.0f; - sZelda->actor.shape.rot.y = -0x7000; + sBossGanon2Zelda->unk_3C8 = 0; + sBossGanon2Zelda->actor.world.pos.x = 970.0f; + sBossGanon2Zelda->actor.world.pos.y = 1086.0f; + sBossGanon2Zelda->actor.world.pos.z = -214.0f; + sBossGanon2Zelda->actor.shape.rot.y = -0x7000; this->unk_3BC.x = 0.0f; this->unk_3BC.y = 1.0f; this->unk_3BC.z = 0.0f; @@ -258,20 +277,20 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { player->actor.world.pos.x = 970.0f; player->actor.world.pos.y = 1086.0f; player->actor.world.pos.z = -166.0f; - sZelda->actor.world.pos.x = 974.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; + sBossGanon2Zelda->actor.world.pos.x = 974.0f; + sBossGanon2Zelda->actor.world.pos.y = 1086.0f; + sBossGanon2Zelda->actor.world.pos.z = -186.0f; player->actor.shape.rot.y = -0x5000; - sZelda->actor.shape.rot.y = -0x5000; + sBossGanon2Zelda->actor.shape.rot.y = -0x5000; if (this->unk_398 == 60) { Message_StartTextbox(globalCtx, 0x70D4, NULL); } if (this->unk_398 == 40) { - sZelda->unk_3C8 = 1; + sBossGanon2Zelda->unk_3C8 = 1; func_8002DF54(globalCtx, &this->actor, 0x4E); } if (this->unk_398 == 85) { - sZelda->unk_3C8 = 2; + sBossGanon2Zelda->unk_3C8 = 2; func_8002DF54(globalCtx, &this->actor, 0x4F); } this->unk_3A4.x = 930.0f; @@ -300,14 +319,14 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); } if (this->unk_398 == 20) { - sZelda->unk_3C8 = 3; + sBossGanon2Zelda->unk_3C8 = 3; func_8002DF54(globalCtx, &this->actor, 0x50); } if (this->unk_398 == 55) { this->unk_39C = 4; this->unk_398 = 0; this->unk_410.x = 0.0f; - sZelda->unk_3C8 = 4; + sBossGanon2Zelda->unk_3C8 = 4; func_8002DF54(globalCtx, &this->actor, 0x50); } break; @@ -347,11 +366,11 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { player->actor.world.pos.x = 490.0f; player->actor.world.pos.y = 1086.0f; player->actor.world.pos.z = -166.0f; - sZelda->actor.world.pos.x = 724.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; + sBossGanon2Zelda->actor.world.pos.x = 724.0f; + sBossGanon2Zelda->actor.world.pos.y = 1086.0f; + sBossGanon2Zelda->actor.world.pos.z = -186.0f; player->actor.shape.rot.y = -0x4000; - sZelda->actor.shape.rot.y = -0x5000; + sBossGanon2Zelda->actor.shape.rot.y = -0x5000; this->unk_3A4.x = 410.0f; this->unk_3A4.y = 1096.0f; this->unk_3A4.z = -110.0f; @@ -370,7 +389,7 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { this->unk_339 = 4; } if (this->unk_398 == 30) { - sZelda->unk_3C8 = 5; + sBossGanon2Zelda->unk_3C8 = 5; func_8002DF54(globalCtx, &this->actor, 0x51); } if (this->unk_398 == 50) { @@ -384,11 +403,11 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { player->actor.world.pos.x = 490.0f; player->actor.world.pos.y = 1086.0f; player->actor.world.pos.z = -166.0f; - sZelda->actor.world.pos.x = 724.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; + sBossGanon2Zelda->actor.world.pos.x = 724.0f; + sBossGanon2Zelda->actor.world.pos.y = 1086.0f; + sBossGanon2Zelda->actor.world.pos.z = -186.0f; player->actor.shape.rot.y = -0x4000; - sZelda->actor.shape.rot.y = -0x5000; + sBossGanon2Zelda->actor.shape.rot.y = -0x5000; this->unk_3A4.x = 450.0f; this->unk_3A4.y = 1121.0f; this->unk_3A4.z = -158.0f; @@ -457,9 +476,9 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { player->actor.world.pos.y = 1086.0f; player->actor.world.pos.z = -266.0f; player->actor.shape.rot.y = -0x4000; - sZelda->actor.world.pos.x = 724.0f; - sZelda->actor.world.pos.y = 1086.0f; - sZelda->actor.world.pos.z = -186.0f; + sBossGanon2Zelda->actor.world.pos.x = 724.0f; + sBossGanon2Zelda->actor.world.pos.y = 1086.0f; + sBossGanon2Zelda->actor.world.pos.z = -186.0f; this->unk_3A4.x = this->actor.world.pos.x + -10.0f; this->unk_3A4.y = this->actor.world.pos.y + 80.0f; this->unk_3A4.z = this->actor.world.pos.z + 50.0f; @@ -671,7 +690,8 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { if (this->unk_398 == 80) { BossGanon2_SetObjectSegment(this, globalCtx, OBJECT_GANON2, false); TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(object_ganon2_Tex_021A90), 160, 180, 128, 40); + SEGMENTED_TO_VIRTUAL(object_ganon2_Tex_021A90), 160, 180, 128, 40, true); + //It has translation but they are all the same. they all say "GANON" only } this->unk_3A4.x = ((this->actor.world.pos.x + 500.0f) - 350.0f) + 100.0f; this->unk_3A4.y = this->actor.world.pos.y; @@ -769,9 +789,9 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { BossGanon2Effect* effect = globalCtx->specialEffects; effect->unk_2E = 1; - effect->position.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; - effect->position.y = sZelda->actor.world.pos.y + 350.0f; - effect->position.z = sZelda->actor.world.pos.z - 25.0f; + effect->position.x = sBossGanon2Zelda->actor.world.pos.x + 50.0f + 10.0f; + effect->position.y = sBossGanon2Zelda->actor.world.pos.y + 350.0f; + effect->position.z = sBossGanon2Zelda->actor.world.pos.z - 25.0f; effect->velocity.x = 0.0f; effect->velocity.z = 0.0f; effect->velocity.y = -30.0f; @@ -781,15 +801,15 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { break; } case 26: - this->unk_3A4.x = sZelda->actor.world.pos.x + 100.0f + 30.0f; - this->unk_3A4.y = sZelda->actor.world.pos.y + 10.0f; - this->unk_3A4.z = sZelda->actor.world.pos.z + 5.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 30.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z - 20.0f; + this->unk_3A4.x = sBossGanon2Zelda->actor.world.pos.x + 100.0f + 30.0f; + this->unk_3A4.y = sBossGanon2Zelda->actor.world.pos.y + 10.0f; + this->unk_3A4.z = sBossGanon2Zelda->actor.world.pos.z + 5.0f; + this->unk_3B0.x = sBossGanon2Zelda->actor.world.pos.x; + this->unk_3B0.y = sBossGanon2Zelda->actor.world.pos.y + 30.0f; + this->unk_3B0.z = sBossGanon2Zelda->actor.world.pos.z - 20.0f; this->unk_3BC.z = -0.5f; if (this->unk_398 == 13) { - sZelda->unk_3C8 = 6; + sBossGanon2Zelda->unk_3C8 = 6; } if (this->unk_398 == 50) { this->unk_39C = 27; @@ -878,7 +898,7 @@ void func_808FD5F4(BossGanon2* this, GlobalContext* globalCtx) { func_808FFDB0(this, globalCtx); this->unk_1A2[1] = 50; this->actor.flags |= ACTOR_FLAG_0; - sZelda->unk_3C8 = 7; + sBossGanon2Zelda->unk_3C8 = 7; } break; } @@ -1322,12 +1342,12 @@ void func_80900890(BossGanon2* this, GlobalContext* globalCtx) { break; case 2: this->unk_1A2[0] = 300; - this->unk_3A4.x = sZelda->actor.world.pos.x - 100.0f; - this->unk_3A4.y = sZelda->actor.world.pos.y + 30.0f; - this->unk_3A4.z = (sZelda->actor.world.pos.z + 30.0f) - 60.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 30.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z - 10.0f; + this->unk_3A4.x = sBossGanon2Zelda->actor.world.pos.x - 100.0f; + this->unk_3A4.y = sBossGanon2Zelda->actor.world.pos.y + 30.0f; + this->unk_3A4.z = (sBossGanon2Zelda->actor.world.pos.z + 30.0f) - 60.0f; + this->unk_3B0.x = sBossGanon2Zelda->actor.world.pos.x; + this->unk_3B0.y = sBossGanon2Zelda->actor.world.pos.y + 30.0f; + this->unk_3B0.z = sBossGanon2Zelda->actor.world.pos.z - 10.0f; Math_ApproachZeroF(&this->unk_324, 1.0f, 5.0f); Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 1.0f / 51); if (this->unk_1A2[1] == 80) { @@ -1355,8 +1375,8 @@ void func_80900890(BossGanon2* this, GlobalContext* globalCtx) { func_8002DF54(globalCtx, &this->actor, 0x60); this->unk_398 = 0; case 11: - player->actor.world.pos.x = sZelda->actor.world.pos.x + 50.0f + 10.0f; - player->actor.world.pos.z = sZelda->actor.world.pos.z - 25.0f; + player->actor.world.pos.x = sBossGanon2Zelda->actor.world.pos.x + 50.0f + 10.0f; + player->actor.world.pos.z = sBossGanon2Zelda->actor.world.pos.z - 25.0f; player->actor.shape.rot.y = -0x8000; this->unk_3A4.x = (player->actor.world.pos.x + 100.0f) - 80.0f; this->unk_3A4.y = (player->actor.world.pos.y + 60.0f) - 40.0f; @@ -1481,7 +1501,7 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { func_8002DF54(globalCtx, &this->actor, 8); this->unk_39C = 1; this->unk_398 = 0; - sZelda->unk_3C8 = 9; + sBossGanon2Zelda->unk_3C8 = 9; this->unk_31C = 0; this->unk_1A2[2] = 0; this->unk_336 = 0; @@ -1521,9 +1541,9 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { player->actor.shape.rot.y = -0x4000; player->actor.world.pos.x = 200.0f; player->actor.world.pos.z = 30.0f; - sZelda->actor.world.pos.x = 340.0f; - sZelda->actor.world.pos.z = -250.0f; - sZelda->actor.world.rot.y = sZelda->actor.shape.rot.y = -0x2000; + sBossGanon2Zelda->actor.world.pos.x = 340.0f; + sBossGanon2Zelda->actor.world.pos.z = -250.0f; + sBossGanon2Zelda->actor.world.rot.y = sBossGanon2Zelda->actor.shape.rot.y = -0x2000; this->unk_3A4.x = 250; this->unk_3A4.y = 1150.0f; this->unk_3A4.z = 0.0f; @@ -1542,9 +1562,9 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { this->unk_3A4.x = 250; this->unk_3A4.y = 1150.0f; this->unk_3A4.z = 0.0f; - Math_ApproachF(&this->unk_3B0.x, sZelda->actor.world.pos.x, 0.2f, 20.0f); - Math_ApproachF(&this->unk_3B0.y, sZelda->actor.world.pos.y + 50.0f, 0.2f, 10.0f); - Math_ApproachF(&this->unk_3B0.z, sZelda->actor.world.pos.z, 0.2f, 20.0f); + Math_ApproachF(&this->unk_3B0.x, sBossGanon2Zelda->actor.world.pos.x, 0.2f, 20.0f); + Math_ApproachF(&this->unk_3B0.y, sBossGanon2Zelda->actor.world.pos.y + 50.0f, 0.2f, 10.0f); + Math_ApproachF(&this->unk_3B0.z, sBossGanon2Zelda->actor.world.pos.z, 0.2f, 20.0f); if (this->unk_398 == 50) { this->unk_39C = 3; this->unk_398 = 0; @@ -1556,9 +1576,9 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { this->unk_3A4.x = 330.0f; this->unk_3A4.y = 1120.0f; this->unk_3A4.z = -150.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 40.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z; + this->unk_3B0.x = sBossGanon2Zelda->actor.world.pos.x; + this->unk_3B0.y = sBossGanon2Zelda->actor.world.pos.y + 40.0f; + this->unk_3B0.z = sBossGanon2Zelda->actor.world.pos.z; if (this->unk_398 == 10) { Message_StartTextbox(globalCtx, 0x70D8, NULL); } @@ -1571,7 +1591,7 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { if (this->unk_398 > 10) { Math_ApproachZeroF(&this->unk_37C, 1.0f, 10.0f); if (this->unk_398 == 30) { - sZelda->unk_3C8 = 10; + sBossGanon2Zelda->unk_3C8 = 10; } this->unk_339 = 23; Math_ApproachZeroF(&globalCtx->envCtx.unk_D8, 1.0f, 0.05f); @@ -1742,7 +1762,7 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { if (this->unk_398 == 40) { this->unk_39C = 9; this->unk_398 = 0; - sZelda->unk_3C8 = 11; + sBossGanon2Zelda->unk_3C8 = 11; Message_StartTextbox(globalCtx, 0x70D9, NULL); this->unk_336 = 0; globalCtx->envCtx.unk_D8 = 0.0f; @@ -1753,9 +1773,9 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { this->unk_3A4.x = 330.0f; this->unk_3A4.y = 1120.0f; this->unk_3A4.z = -150.0f; - this->unk_3B0.x = sZelda->actor.world.pos.x; - this->unk_3B0.y = sZelda->actor.world.pos.y + 40.0f; - this->unk_3B0.z = sZelda->actor.world.pos.z; + this->unk_3B0.x = sBossGanon2Zelda->actor.world.pos.x; + this->unk_3B0.y = sBossGanon2Zelda->actor.world.pos.y + 40.0f; + this->unk_3B0.z = sBossGanon2Zelda->actor.world.pos.z; if (this->unk_398 > 60) { this->unk_39C = 10; this->unk_398 = 0; @@ -1770,26 +1790,26 @@ void func_8090120C(BossGanon2* this, GlobalContext* globalCtx) { if ((this->unk_398 >= 40) && (this->unk_398 <= 110)) { Math_ApproachF(&globalCtx->envCtx.unk_D8, 1.0f, 1.0f, 0.02f); Math_ApproachF(&this->unk_384, 10.0f, 0.1f, 0.2f); - Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); + Audio_PlayActorSound2(&sBossGanon2Zelda->actor, NA_SE_EV_GOD_LIGHTBALL_2 - SFX_FLAG); } else { Math_ApproachZeroF(&this->unk_384, 1.0f, 0.2f); } if (this->unk_398 > 130) { - Math_ApproachF(&this->unk_3B0.y, (sZelda->actor.world.pos.y + 40.0f + 10.0f) - 20.0f, 0.1f, + Math_ApproachF(&this->unk_3B0.y, (sBossGanon2Zelda->actor.world.pos.y + 40.0f + 10.0f) - 20.0f, 0.1f, this->unk_410.x); } else { - Math_ApproachF(&this->unk_3B0.y, sZelda->actor.world.pos.y + 40.0f + 10.0f, 0.05f, + Math_ApproachF(&this->unk_3B0.y, sBossGanon2Zelda->actor.world.pos.y + 40.0f + 10.0f, 0.05f, this->unk_410.x * 0.25f); } Math_ApproachF(&this->unk_410.x, 1.0f, 1.0f, 0.01f); if (this->unk_398 == 10) { - sZelda->unk_3C8 = 12; + sBossGanon2Zelda->unk_3C8 = 12; } if (this->unk_398 == 110) { - sZelda->unk_3C8 = 13; + sBossGanon2Zelda->unk_3C8 = 13; } if (this->unk_398 == 140) { - Audio_PlayActorSound2(&sZelda->actor, NA_SE_EV_HUMAN_BOUND); + Audio_PlayActorSound2(&sBossGanon2Zelda->actor, NA_SE_EV_HUMAN_BOUND); } if (this->unk_398 < 160) { break; @@ -1844,7 +1864,7 @@ void func_80902348(BossGanon2* this, GlobalContext* globalCtx) { } func_8002F6D4(globalCtx, &this->actor, 15.0f, this->actor.yawTowardsPlayer + phi_v0_2, 2.0f, 0); - sZelda->unk_3C8 = 8; + sBossGanon2Zelda->unk_3C8 = 8; this->unk_316 = 10; break; } @@ -1863,7 +1883,7 @@ void func_80902348(BossGanon2* this, GlobalContext* globalCtx) { player->isBurning = true; func_8002F6D4(globalCtx, &this->actor, 10.0f, Math_Atan2S(temp_f12, temp_f2), 0.0f, 0x10); - sZelda->unk_3C8 = 8; + sBossGanon2Zelda->unk_3C8 = 8; } } } @@ -2167,7 +2187,7 @@ void BossGanon2_Update(Actor* thisx, GlobalContext* globalCtx) { if (D_80906D78 != 0) { D_80906D78 = 0; - for (i2 = 0; i2 < ARRAY_COUNT(sParticles); i2++) { + for (i2 = 0; i2 < ARRAY_COUNT(sBossGanon2Particles); i2++) { angle = Rand_ZeroFloat(2 * M_PI); sp44 = Rand_ZeroFloat(40.0f) + 10.0f; sp58 = this->actor.world.pos; @@ -2640,7 +2660,7 @@ void func_80904FC8(BossGanon2* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 200); gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 0); gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); - Matrix_Translate(sZelda->actor.world.pos.x, sZelda->actor.world.pos.y + 80.0f, sZelda->actor.world.pos.z, + Matrix_Translate(sBossGanon2Zelda->actor.world.pos.x, sBossGanon2Zelda->actor.world.pos.y + 80.0f, sBossGanon2Zelda->actor.world.pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(this->unk_384, this->unk_384, this->unk_384, MTXMODE_APPLY); @@ -2727,8 +2747,8 @@ void func_80905674(BossGanon2* this, GlobalContext* globalCtx) { this->unk_19C * -8, 32, 32)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, (s16)this->unk_37C); gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 128); - Matrix_Translate(sZelda->actor.world.pos.x + 100.0f, sZelda->actor.world.pos.y + 35.0f + 7.0f, - sZelda->actor.world.pos.z - 100.0f, MTXMODE_NEW); + Matrix_Translate(sBossGanon2Zelda->actor.world.pos.x + 100.0f, sBossGanon2Zelda->actor.world.pos.y + 35.0f + 7.0f, + sBossGanon2Zelda->actor.world.pos.z - 100.0f, MTXMODE_NEW); Matrix_RotateY(-M_PI / 4.0f, MTXMODE_APPLY); Matrix_Scale(0.040000003f, 0.040000003f, this->unk_380, MTXMODE_APPLY); Matrix_RotateX(M_PI / 2.0f, MTXMODE_APPLY); @@ -2825,7 +2845,7 @@ void func_80905DA8(BossGanon2* this, GlobalContext* globalCtx) { Vec3f sp78; s16 i; - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + for (i = 0; i < ARRAY_COUNT(sBossGanon2Particles); i++, effect++) { if (effect->type != 0) { effect->position.x += effect->velocity.x; effect->position.y += effect->velocity.y; @@ -2933,7 +2953,7 @@ void func_809060E8(GlobalContext* globalCtx) { effect = effects; - for (i = 0; i < ARRAY_COUNT(sParticles); i++, effect++) { + for (i = 0; i < ARRAY_COUNT(sBossGanon2Particles); i++, effect++) { if (effect->type == 2) { if (!usingObjectGEff) { BossGanon2_SetObjectSegment(NULL, globalCtx, OBJECT_GEFF, true); @@ -3079,12 +3099,12 @@ void BossGanon2_Reset(void) { D_8090EB20.y = 0; D_8090EB20.z = 0; D_80910638 = 0; - sZelda = NULL; + sBossGanon2Zelda = NULL; D_8090EB30 = NULL; - sSeed1 = 0; - sSeed2 = 0; - sSeed3 = 0; + sBossGanon2Seed1 = 0; + sBossGanon2Seed2 = 0; + sBossGanon2Seed3 = 0; memset(D_809105D8, 0, sizeof(D_809105D8)); memset(D_80910608, 0, sizeof(D_80910608)); - memset(sParticles, 0, sizeof(sParticles)); + memset(sBossGanon2Particles, 0, sizeof(sBossGanon2Particles)); } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.h b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.h index 3d2625231..6271f5c14 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.h +++ b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.h @@ -4,6 +4,20 @@ #include "ultra64.h" #include "global.h" + +typedef struct { + /* 0x00 */ u8 type; + /* 0x01 */ u8 unk_01; + /* 0x04 */ Vec3f position; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ char unk_28[0x6]; + /* 0x2E */ s16 unk_2E; + /* 0x30 */ char unk_30[0x4]; + /* 0x34 */ f32 scale; + /* 0x38 */ Vec3f unk_38; +} BossGanon2Effect; // size = 0x44 + struct BossGanon2; typedef void (*BossGanon2ActionFunc)(struct BossGanon2*, GlobalContext*); diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c index 47201ed0d..e19b36bd6 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2_data.c @@ -2,19 +2,6 @@ #include "overlays/actors/ovl_En_Zl3/z_en_zl3.h" #include "objects/object_ganon2/object_ganon2.h" -typedef struct { - /* 0x00 */ u8 type; - /* 0x01 */ u8 unk_01; - /* 0x04 */ Vec3f position; - /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f accel; - /* 0x28 */ char unk_28[0x6]; - /* 0x2E */ s16 unk_2E; - /* 0x30 */ char unk_30[0x4]; - /* 0x34 */ f32 scale; - /* 0x38 */ Vec3f unk_38; -} BossGanon2Effect; // size = 0x44 - static Vec3f D_80906D60 = { 0.0f, 0.0f, 0.0f }; static Vec3f D_80906D6C = { 0.0f, 0.0f, 500.0f }; @@ -326,31 +313,7 @@ static s16 D_809071CC[] = { 1, -1, 1, 1, 3, 4, 1, 6, 7, 2, 9, 10, 2, 12, 13 }; static u8 D_809071EC[] = { 3, 2, 2, 1, 3, 3, 1, 3, 3, 1, 0, 3, 1, 0, 3 }; -// padding -static u32 D_809071FC[2] = { 0 }; - #include "overlays/ovl_Boss_Ganon2/ovl_Boss_Ganon2.h" -static Vec3f D_8090EB20; - -static EnZl3* sZelda; - -static Actor* D_8090EB30; - -// unused -static UNK_TYPE D_8090EB34; - -static BossGanon2Effect sParticles[100]; - -static s32 sSeed1; -static s32 sSeed2; -static s32 sSeed3; - -// unused -static UNK_TYPE D_809105DC; - -static Vec3f D_809105D8[4]; - -static Vec3f D_80910608[4]; - -static s8 D_80910638; +// padding +//static u32 D_809071FC[2] = { 0 }; diff --git a/soh/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c b/soh/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c index 94ea16422..227e0d6f0 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c @@ -210,7 +210,7 @@ static Vec3f sAudioVec = { 0.0f, 0.0f, 50.0f }; // OTRTODO: This code appears to cause the game to gradually crash... // Might be an OoB write. For now it's disabled. -void BossGanondrof_ClearPixels8x8(s16* texture, u8* mask, s16 index) +void BossGanondrof_ClearPixels8x8(s16* texture, u8* mask, s16 index) { //texture = ResourceMgr_LoadTexByName(texture); if (mask[index]) { @@ -248,18 +248,18 @@ void BossGanondrof_ClearPixels32x16(s16* texture, u8* mask, s16 index) { } } -void BossGanondrof_ClearPixels16x32(s16* texture, u8* mask, s16 index) { +void BossGanondrof_ClearPixels16x32(s16* texture, u8* mask, s16 index) { //texture = ResourceMgr_LoadTexByName(texture); if (mask[index]) { s16 i = ((index & 0xF) * 2) + ((index & 0xF0) * 2); - + ResourceMgr_WriteTexS16ByName(texture, i + 1, 0); ResourceMgr_WriteTexS16ByName(texture, i, 0); //texture[i + 1] = 0; //texture[i] = 0; } - + } void BossGanondrof_ClearPixels(u8* mask, s16 index) { diff --git a/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index ad8e4537d..d84cf4a74 100644 --- a/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/soh/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -926,7 +926,7 @@ void BossGoma_Encounter(BossGoma* this, GlobalContext* globalCtx) { if (!(gSaveContext.eventChkInf[7] & 1)) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gGohmaTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + SEGMENTED_TO_VIRTUAL(gGohmaTitleCardTex), 160, 180, 128, 40, true); } Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); diff --git a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index 7bcfd7c50..ec4899a28 100644 --- a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -144,25 +144,25 @@ static f32 sFlatWidth[41] = { #include "z_boss_mo_colchk.c" static BossMoEffect sEffects[300]; -static s32 sSeed1; -static s32 sSeed2; -static s32 sSeed3; +static s32 sBossGanonSeed1; +static s32 sBossGanonSeed2; +static s32 sBossGanonSeed3; void BossMo_InitRand(s32 seedInit0, s32 seedInit1, s32 seedInit2) { - sSeed1 = seedInit0; - sSeed2 = seedInit1; - sSeed3 = seedInit2; + sBossGanonSeed1 = seedInit0; + sBossGanonSeed2 = seedInit1; + sBossGanonSeed3 = seedInit2; } f32 BossMo_RandZeroOne(void) { // Wichmann-Hill algorithm f32 randFloat; - sSeed1 = (sSeed1 * 171) % 30269; - sSeed2 = (sSeed2 * 172) % 30307; - sSeed3 = (sSeed3 * 170) % 30323; + sBossGanonSeed1 = (sBossGanonSeed1 * 171) % 30269; + sBossGanonSeed2 = (sBossGanonSeed2 * 172) % 30307; + sBossGanonSeed3 = (sBossGanonSeed3 * 170) % 30323; - randFloat = (sSeed1 / 30269.0f) + (sSeed2 / 30307.0f) + (sSeed3 / 30323.0f); + randFloat = (sBossGanonSeed1 / 30269.0f) + (sBossGanonSeed2 / 30307.0f) + (sBossGanonSeed3 / 30323.0f); while (randFloat >= 1.0f) { randFloat -= 1.0f; } @@ -1423,7 +1423,7 @@ void BossMo_IntroCs(BossMo* this, GlobalContext* globalCtx) { } if (this->timers[2] == 130) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 160, 180, 128, 40, true); gSaveContext.eventChkInf[7] |= 0x10; } break; @@ -3588,7 +3588,7 @@ void BossMo_Reset(void) { sMorphaTent1 = NULL; sMorphaTent2 = NULL; memset(sEffects, 0, sizeof(sEffects)); - sSeed1 = 0; - sSeed2 = 0; - sSeed3 = 0; + sBossGanonSeed1 = 0; + sBossGanonSeed2 = 0; + sBossGanonSeed3 = 0; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index 6fae3778b..eeae20698 100644 --- a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -598,7 +598,7 @@ void BossSst_HeadIntro(BossSst* this, GlobalContext* globalCtx) { } else if (revealStateTimer == 85) { if (!(gSaveContext.eventChkInf[7] & 0x80)) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gBongoTitleCardTex), 160, 180, 128, 40); + SEGMENTED_TO_VIRTUAL(gBongoTitleCardTex), 160, 180, 128, 40, true); } Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadEyeCloseAnim, -5.0f); @@ -3245,4 +3245,4 @@ void BossSst_Reset(void) { sCutsceneCamera= 0; sBodyStatic = false; -} \ No newline at end of file +} diff --git a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 38e4996db..3c8fa9d91 100644 --- a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -7,34 +7,6 @@ #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) -typedef enum { - /* 0 */ TWEFF_NONE, - /* 1 */ TWEFF_DOT, - /* 2 */ TWEFF_2, - /* 3 */ TWEFF_3, - /* 4 */ TWEFF_RING, - /* 5 */ TWEFF_PLYR_FRZ, - /* 6 */ TWEFF_FLAME, - /* 7 */ TWEFF_MERGEFLAME, - /* 8 */ TWEFF_SHLD_BLST, - /* 9 */ TWEFF_SHLD_DEFL, - /* 10 */ TWEFF_SHLD_HIT -} TwEffType; - -typedef enum { - /* 0 */ EFF_ARGS, - /* 1 */ EFF_UNKS1, - /* 2 */ EFF_WORK_MAX -} EffectWork; - -typedef enum { - /* 0 */ EFF_SCALE, - /* 1 */ EFF_DIST, - /* 2 */ EFF_ROLL, - /* 3 */ EFF_YAW, - /* 4 */ EFF_FWORK_MAX -} EffectFWork; - typedef enum { /* 0x00 */ TW_KOTAKE, /* 0x01 */ TW_KOUME, @@ -47,19 +19,6 @@ typedef enum { /* 0x69 */ TW_DEATHBALL_KOUME } TwinrovaType; -typedef struct { - /* 0x0000 */ u8 type; - /* 0x0001 */ u8 frame; - /* 0x0004 */ Vec3f pos; - /* 0x0010 */ Vec3f curSpeed; - /* 0x001C */ Vec3f accel; - /* 0x0028 */ Color_RGB8 color; - /* 0x002C */ s16 alpha; - /* 0x002E */ s16 work[EFF_WORK_MAX]; - /* 0x0034 */ f32 workf[EFF_FWORK_MAX]; - /* 0x0044 */ Actor* target; -} BossTwEffect; - void BossTw_Init(Actor* thisx, GlobalContext* globalCtx); void BossTw_Destroy(Actor* thisx, GlobalContext* globalCtx); void BossTw_Update(Actor* thisx, GlobalContext* globalCtx); @@ -200,7 +159,7 @@ static Vec3f sTwinrovaPillarPos[] = { { 0.0f, 380.0f, -580.0f }, }; -static u8 sTwInitalized = false; +u8 sTwInitalized = false; static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), @@ -233,7 +192,7 @@ static u8 D_8094C878; static s16 D_8094C87A; static s16 D_8094C87C; static u8 D_8094C87E; -static BossTwEffect sTwEffects[150]; +BossTwEffect sTwEffects[150]; void BossTw_AddDotEffect(GlobalContext* globalCtx, Vec3f* initalPos, Vec3f* initalSpeed, Vec3f* accel, f32 scale, s16 args, s16 countLimit) { @@ -2220,7 +2179,7 @@ void BossTw_TwinrovaIntroCS(BossTw* this, GlobalContext* globalCtx) { globalCtx->envCtx.unk_BE = 1; globalCtx->envCtx.unk_BD = 1; globalCtx->envCtx.unk_D8 = 0.0f; - TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gTwinrovaTitleCardTex), 160, 180, 128, 40); // OTRTODO + TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gTwinrovaTitleCardTex), 160, 180, 128, 40, true); gSaveContext.eventChkInf[7] |= 0x20; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); } @@ -5469,4 +5428,4 @@ void BossTw_TwinrovaLaugh(BossTw* this, GlobalContext* globalCtx) { void BossTw_Reset(void) { sTwInitalized = false; memset(sTwEffects, 0, sizeof(sTwEffects)); -} \ No newline at end of file +} diff --git a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h index 575997c26..51b664726 100644 --- a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h +++ b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h @@ -4,9 +4,46 @@ #include "ultra64.h" #include "global.h" -struct BossTw; +typedef enum { + /* 0 */ TWEFF_NONE, + /* 1 */ TWEFF_DOT, + /* 2 */ TWEFF_2, + /* 3 */ TWEFF_3, + /* 4 */ TWEFF_RING, + /* 5 */ TWEFF_PLYR_FRZ, + /* 6 */ TWEFF_FLAME, + /* 7 */ TWEFF_MERGEFLAME, + /* 8 */ TWEFF_SHLD_BLST, + /* 9 */ TWEFF_SHLD_DEFL, + /* 10 */ TWEFF_SHLD_HIT +} TwEffType; -typedef void (*BossTwActionFunc)(struct BossTw* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ EFF_ARGS, + /* 1 */ EFF_UNKS1, + /* 2 */ EFF_WORK_MAX +} EffectWork; + +typedef enum { + /* 0 */ EFF_SCALE, + /* 1 */ EFF_DIST, + /* 2 */ EFF_ROLL, + /* 3 */ EFF_YAW, + /* 4 */ EFF_FWORK_MAX +} EffectFWork; + +typedef struct { + /* 0x0000 */ u8 type; + /* 0x0001 */ u8 frame; + /* 0x0004 */ Vec3f pos; + /* 0x0010 */ Vec3f curSpeed; + /* 0x001C */ Vec3f accel; + /* 0x0028 */ Color_RGB8 color; + /* 0x002C */ s16 alpha; + /* 0x002E */ s16 work[EFF_WORK_MAX]; + /* 0x0034 */ f32 workf[EFF_FWORK_MAX]; + /* 0x0044 */ Actor* target; +} BossTwEffect; typedef enum { /* 0 */ CS_TIMER_1, @@ -55,6 +92,10 @@ typedef enum { /* 26 */ FWORK_MAX } TwFwork; +struct BossTw; + +typedef void (*BossTwActionFunc)(struct BossTw*, GlobalContext* globalCtx); + typedef struct BossTw { /* 0x0000 */ Actor actor; /* 0x014C */ BossTwActionFunc actionFunc; diff --git a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index 071baa106..c5b60a327 100644 --- a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -979,7 +979,7 @@ void BossVa_BodyIntro(BossVa* this, GlobalContext* globalCtx) { if (!(gSaveContext.eventChkInf[7] & 0x40)) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gBarinadeTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + SEGMENTED_TO_VIRTUAL(gBarinadeTitleCardTex), 160, 180, 128, 40, true); } if (Rand_ZeroOne() < 0.1f) { @@ -4028,4 +4028,4 @@ void BossVa_Reset(void) { sZapperRot.z = 0; sPhase2Timer = 0; sPhase4HP = 0; -} \ No newline at end of file +} diff --git a/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c b/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c index 4f75a03cd..acff25c75 100644 --- a/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c +++ b/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c @@ -307,7 +307,7 @@ void func_8096712C(Demo6K* this, GlobalContext* globalCtx) { } } -static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; +Vec3f sDemo6kVelocity = { 0.0f, 0.0f, 0.0f }; void func_80967244(Demo6K* this, GlobalContext* globalCtx) { static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Color_RGBA8 primColor = { 255, 255, 255, 0 }; @@ -324,9 +324,9 @@ void func_80967244(Demo6K* this, GlobalContext* globalCtx) { rand1 = Rand_ZeroFloat(0xFFFF); rand2 = Rand_ZeroFloat(0xFFFF); - velocity.x = Math_SinS(rand2) * Math_CosS(rand1) * 20.0f; - velocity.z = Math_CosS(rand2) * Math_CosS(rand1) * 20.0f; - velocity.y = Math_SinS(rand1) * 20.0f; + sDemo6kVelocity.x = Math_SinS(rand2) * Math_CosS(rand1) * 20.0f; + sDemo6kVelocity.z = Math_CosS(rand2) * Math_CosS(rand1) * 20.0f; + sDemo6kVelocity.y = Math_SinS(rand1) * 20.0f; accel.y = 0.0f; @@ -342,7 +342,7 @@ void func_80967244(Demo6K* this, GlobalContext* globalCtx) { scale = 18000; } - EffectSsKiraKira_SpawnFocused(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, scale, 20); + EffectSsKiraKira_SpawnFocused(globalCtx, &pos, &sDemo6kVelocity, &accel, &primColor, &envColor, scale, 20); } void func_80967410(Demo6K* this, GlobalContext* globalCtx) { @@ -820,7 +820,7 @@ void func_809691BC(Demo6K* this, GlobalContext* globalCtx, s32 params) { } void Demo6K_Reset(void) { - velocity.x = 0.0f; - velocity.y = 0.0f; - velocity.z = 0.0f; + sDemo6kVelocity.x = 0.0f; + sDemo6kVelocity.y = 0.0f; + sDemo6kVelocity.z = 0.0f; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c index a94fa36af..53044464c 100644 --- a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c +++ b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c @@ -132,7 +132,7 @@ void DemoKekkai_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider2); } -static Vec3f vel = { 0.0f, 0.0f, 0.0f }; +Vec3f demoKekkaiVel = { 0.0f, 0.0f, 0.0f }; void DemoKekkai_SpawnParticles(DemoKekkai* this, GlobalContext* globalCtx) { static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Color_RGBA8 lightYellow = { 255, 255, 170, 0 }; @@ -144,15 +144,15 @@ void DemoKekkai_SpawnParticles(DemoKekkai* this, GlobalContext* globalCtx) { s16 roll = Rand_ZeroFloat(65535.0f); s16 yaw = Rand_ZeroFloat(65535.0f); - vel.x = Math_SinS(yaw) * Math_CosS(roll) * Rand_ZeroFloat(8.0f); - vel.z = Math_CosS(yaw) * Math_CosS(roll) * Rand_ZeroFloat(8.0f); - vel.y = Math_SinS(roll) * Rand_ZeroFloat(3.0f); + demoKekkaiVel.x = Math_SinS(yaw) * Math_CosS(roll) * Rand_ZeroFloat(8.0f); + demoKekkaiVel.z = Math_CosS(yaw) * Math_CosS(roll) * Rand_ZeroFloat(8.0f); + demoKekkaiVel.y = Math_SinS(roll) * Rand_ZeroFloat(3.0f); - pos.x = (vel.x * 7.0f) + this->actor.world.pos.x; - pos.y = (vel.y * 20.0f) + this->actor.world.pos.y + 120.0f; - pos.z = (vel.z * 7.0f) + this->actor.world.pos.z; + pos.x = (demoKekkaiVel.x * 7.0f) + this->actor.world.pos.x; + pos.y = (demoKekkaiVel.y * 20.0f) + this->actor.world.pos.y + 120.0f; + pos.z = (demoKekkaiVel.z * 7.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnFocused(globalCtx, &pos, &vel, &accel, &lightYellow, &darkRed, 3000, + EffectSsKiraKira_SpawnFocused(globalCtx, &pos, &demoKekkaiVel, &accel, &lightYellow, &darkRed, 3000, (s32)Rand_ZeroFloat(40.0f) + 45); } } @@ -338,7 +338,7 @@ void DemoKekkai_DrawTowerBarrier(Actor* thisx, GlobalContext* globalCtx) { } void DemoKekkai_Reset(void) { - vel.x = 0.0f; - vel.y = 0.0f; - vel.z = 0.0f; + demoKekkaiVel.x = 0.0f; + demoKekkaiVel.y = 0.0f; + demoKekkaiVel.z = 0.0f; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 46f3d1857..ee503dd43 100644 --- a/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -53,7 +53,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 4000, ICHAIN_STOP), }; -static s16 sWarpTimerTarget; +s16 sWarpTimerTarget; void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc) { this->actionFunc = actionFunc; diff --git a/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c b/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c index 14e9ff15c..6eaa2f777 100644 --- a/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c +++ b/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c @@ -122,7 +122,7 @@ static DamageTable sDamageTable = { /* Unknown 2 */ DMG_ENTRY(0, 0x0), }; -static s32 sSlugGroup = 0; +s32 sSlugGroup = 0; void EnBw_SetupAction(EnBw* this, EnBwActionFunc actionFunc) { this->actionFunc = actionFunc; diff --git a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index e68eaabb1..274505978 100644 --- a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -35,7 +35,7 @@ const ActorInit En_Clear_Tag_InitVars = { (ActorResetFunc)EnClearTag_Reset, }; -static u8 sIsEffectsInitialized = false; +u8 sClearTagIsEffectsInitialized = false; static Vec3f sZeroVector = { 0.0f, 0.0f, 0.0f }; @@ -79,10 +79,10 @@ static ColliderCylinderInit sLaserCylinderInit = { { 15, 30, 10, { 0, 0, 0 } }, }; -static UNK_TYPE4 D_809D5C98 = 0; // unused -static UNK_TYPE4 D_809D5C9C = 0; // unused +//static UNK_TYPE4 D_809D5C98 = 0; // unused +//static UNK_TYPE4 D_809D5C9C = 0; // unused -static EnClearTagEffect sClearTagEffects[CLEAR_TAG_EFFECT_MAX_COUNT]; +EnClearTagEffect sClearTagEffects[CLEAR_TAG_EFFECT_MAX_COUNT]; #include "overlays/ovl_En_Clear_Tag/ovl_En_Clear_Tag.h" @@ -273,8 +273,8 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { } // Initialize all effects to available if effects have not been initialized. - if (!sIsEffectsInitialized) { - sIsEffectsInitialized = true; + if (!sClearTagIsEffectsInitialized) { + sClearTagIsEffectsInitialized = true; globalCtx->specialEffects = &sClearTagEffects[0]; for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++) { sClearTagEffects[i].type = CLEAR_TAG_EFFECT_AVAILABLE; @@ -1027,5 +1027,5 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { void EnClearTag_Reset(void) { memset(sClearTagEffects, 0, sizeof(sClearTagEffects)); - sIsEffectsInitialized = false; + sClearTagIsEffectsInitialized = false; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c index 38c86eda3..c84a22fb8 100644 --- a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -84,18 +84,7 @@ sEnFrPointers.flags = 12 - Deactivate frogs, frogs will jump back into the water */ -typedef struct { - u8 flags; - EnFr* frogs[5]; -} EnFrPointers; - -typedef struct { - f32 xzDist; - f32 yaw; - f32 yDist; -} LogSpotToFromWater; - -static EnFrPointers sEnFrPointers = { +EnFrPointers sEnFrPointers = { 0x00, { NULL, @@ -106,6 +95,7 @@ static EnFrPointers sEnFrPointers = { }, }; + // Flags for gSaveContext.eventChkInf[13] static u16 sSongIndex[] = { 0x0002, 0x0004, 0x0010, 0x0008, 0x0020, 0x0040, 0x0001, 0x0000, diff --git a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h index ba2ef5014..154aefc17 100644 --- a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h +++ b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h @@ -28,6 +28,12 @@ typedef enum { /* 07 */ FROG_NO_SONG } FrogSongType; +typedef struct { + f32 xzDist; + f32 yaw; + f32 yDist; +} LogSpotToFromWater; + typedef struct EnFr { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; // Frog Skeleton @@ -69,4 +75,9 @@ typedef struct EnFr { /* 0x03B8 */ Vec3f posButterflyLight; // Used in Lights_PointNoGlowSetInfo() } EnFr; // size = 0x03C4 +typedef struct { + u8 flags; + EnFr* frogs[5]; +} EnFrPointers; + #endif diff --git a/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c b/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c index 85049b7f1..a9997c383 100644 --- a/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c +++ b/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c @@ -96,7 +96,7 @@ static ColliderCylinderInit D_80A4B7CC = { { 15, 30, 10, { 0, 0, 0 } }, }; -static u8 sSpawnNum = 0; +u8 sSpawnNum = 0; static Vec3f sDeadEffectVel = { 0.0f, 0.0f, 0.0f }; static InitChainEntry sInitChain[] = { diff --git a/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c index 649c1b747..bd529ea55 100644 --- a/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -32,9 +32,9 @@ void func_80A7D26C(EnInsect* this, GlobalContext* globalCtx); void func_80A7D39C(EnInsect* this); void func_80A7D460(EnInsect* this, GlobalContext* globalCtx); -static f32 D_80A7DEB0 = 0.0f; -static s16 D_80A7DEB4 = 0; -static s16 D_80A7DEB8 = 0; +f32 D_80A7DEB0 = 0.0f; +s16 D_80A7DEB4 = 0; +s16 D_80A7DEB8 = 0; const ActorInit En_Insect_InitVars = { ACTOR_EN_INSECT, diff --git a/soh/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/soh/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 4ce8fae20..11573dba0 100644 --- a/soh/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/soh/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -29,8 +29,8 @@ void EnIshi_SpawnFragmentsLarge(EnIshi* this, GlobalContext* globalCtx); void EnIshi_SpawnDustSmall(EnIshi* this, GlobalContext* globalCtx); void EnIshi_SpawnDustLarge(EnIshi* this, GlobalContext* globalCtx); -static s16 sRotSpeedX = 0; -static s16 sRotSpeedY = 0; +s16 sRockRotSpeedX = 0; +s16 sRockRotSpeedY = 0; const ActorInit En_Ishi_InitVars = { ACTOR_EN_ISHI, @@ -405,11 +405,11 @@ void EnIshi_SetupFly(EnIshi* this) { this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; if ((this->actor.params & 1) == ROCK_SMALL) { - sRotSpeedX = (Rand_ZeroOne() - 0.5f) * 16000.0f; - sRotSpeedY = (Rand_ZeroOne() - 0.5f) * 2400.0f; + sRockRotSpeedX = (Rand_ZeroOne() - 0.5f) * 16000.0f; + sRockRotSpeedY = (Rand_ZeroOne() - 0.5f) * 2400.0f; } else { - sRotSpeedX = (Rand_ZeroOne() - 0.5f) * 8000.0f; - sRotSpeedY = (Rand_ZeroOne() - 0.5f) * 1600.0f; + sRockRotSpeedX = (Rand_ZeroOne() - 0.5f) * 8000.0f; + sRockRotSpeedY = (Rand_ZeroOne() - 0.5f) * 1600.0f; } this->actor.colChkInfo.mass = 240; this->actionFunc = EnIshi_Fly; @@ -455,8 +455,8 @@ void EnIshi_Fly(EnIshi* this, GlobalContext* globalCtx) { EffectSsGRipple_Spawn(globalCtx, &contactPos, 500, 1300, 8); } this->actor.minVelocityY = -6.0f; - sRotSpeedX >>= 2; - sRotSpeedY >>= 2; + sRockRotSpeedX >>= 2; + sRockRotSpeedY >>= 2; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); this->actor.bgCheckFlags &= ~0x40; } @@ -464,8 +464,8 @@ void EnIshi_Fly(EnIshi* this, GlobalContext* globalCtx) { EnIshi_Fall(this); func_80A7ED94(&this->actor.velocity, D_80A7FA28[type]); func_8002D7EC(&this->actor); - this->actor.shape.rot.x += sRotSpeedX; - this->actor.shape.rot.y += sRotSpeedY; + this->actor.shape.rot.x += sRockRotSpeedX; + this->actor.shape.rot.y += sRockRotSpeedY; Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -502,6 +502,6 @@ void EnIshi_Draw(Actor* thisx, GlobalContext* globalCtx) { } void EnIshi_Reset(void) { - sRotSpeedX = 0; - sRotSpeedY = 0; + sRockRotSpeedX = 0; + sRockRotSpeedY = 0; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c index 1161ba5e3..502f2c056 100644 --- a/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ b/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c @@ -287,7 +287,7 @@ s32 EnKz_FollowPath(EnKz* this, GlobalContext* globalCtx) { pathDiffZ = pointPos->z - this->actor.world.pos.z; Math_SmoothStepToS(&this->actor.world.rot.y, (Math_FAtan2F(pathDiffX, pathDiffZ) * (0x8000 / M_PI)), 0xA, 0x3E8, 1); - if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 10.0f) { + if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 10.0f * CVar_GetS32("gMweepSpeed", 1)) { this->waypoint++; if (this->waypoint >= path->count) { this->waypoint = 0; @@ -378,7 +378,7 @@ void EnKz_SetupMweep(EnKz* this, GlobalContext* globalCtx) { initPos.z += 260.0f; Gameplay_CameraSetAtEye(globalCtx, this->cutsceneCamera, &pos, &initPos); func_8002DF54(globalCtx, &this->actor, 8); - this->actor.speedXZ = 0.1f; + this->actor.speedXZ = 0.1f * CVar_GetS32("gMweepSpeed", 1); this->actionFunc = EnKz_Mweep; } diff --git a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c index c6e23b8b9..5cf7abc25 100644 --- a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -35,7 +35,7 @@ void EnNiw_FeatherSpawn(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 s void EnNiw_FeatherUpdate(EnNiw* this, GlobalContext* globalCtx); void EnNiw_FeatherDraw(EnNiw* this, GlobalContext* globalCtx); -static s16 D_80AB85E0 = 0; +s16 D_80AB85E0 = 0; const ActorInit En_Niw_InitVars = { ACTOR_EN_NIW, @@ -70,9 +70,9 @@ static s16 sKakarikoFlagList[] = { 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, }; -static u8 sLowerRiverSpawned = false; +u8 sLowerRiverSpawned = false; -static u8 sUpperRiverSpawned = false; +u8 sUpperRiverSpawned = false; static ColliderCylinderInit sCylinderInit1 = { { diff --git a/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c b/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c index 93f48417e..63b386238 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c +++ b/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c @@ -126,7 +126,7 @@ static DamageTable sDamageTable = { /* Unknown 2 */ DMG_ENTRY(0, 0x0), }; -static s32 sNumSpawned = 0; +s32 sEnPoFieldNumSpawned = 0; static Vec3f sFieldMiddle = { -1000.0f, 0.0f, 6500.0f }; @@ -145,22 +145,22 @@ static EnPoFieldInfo sPoFieldInfo[2] = { static Vec3f D_80AD714C = { 0.0f, 1400.0f, 0.0f }; -static Vec3s sSpawnPositions[10]; -static u8 sSpawnSwitchFlags[10]; +Vec3s sEnPoFieldSpawnPositions[10]; +u8 sEnPoFieldSpawnSwitchFlags[10]; static MtxF sLimb7Mtx; void EnPoField_Init(Actor* thisx, GlobalContext* globalCtx) { EnPoField* this = (EnPoField*)thisx; s32 pad; - if (sNumSpawned != 10) { - sSpawnPositions[sNumSpawned].x = this->actor.world.pos.x; - sSpawnPositions[sNumSpawned].y = this->actor.world.pos.y; - sSpawnPositions[sNumSpawned].z = this->actor.world.pos.z; - sSpawnSwitchFlags[sNumSpawned] = this->actor.params & 0xFF; - sNumSpawned++; + if (sEnPoFieldNumSpawned != 10) { + sEnPoFieldSpawnPositions[sEnPoFieldNumSpawned].x = this->actor.world.pos.x; + sEnPoFieldSpawnPositions[sEnPoFieldNumSpawned].y = this->actor.world.pos.y; + sEnPoFieldSpawnPositions[sEnPoFieldNumSpawned].z = this->actor.world.pos.z; + sEnPoFieldSpawnSwitchFlags[sEnPoFieldNumSpawned] = this->actor.params & 0xFF; + sEnPoFieldNumSpawned++; } - if (sNumSpawned >= 2) { + if (sEnPoFieldNumSpawned >= 2) { this->actor.params = 0xFF; Actor_Kill(&this->actor); return; @@ -407,10 +407,10 @@ void EnPoField_WaitForSpawn(EnPoField* this, GlobalContext* globalCtx) { this->actionTimer--; } if (this->actionTimer == 0) { - for (i = 0; i < sNumSpawned; i++) { - if (fabsf(sSpawnPositions[i].x - player->actor.world.pos.x) < 150.0f && - fabsf(sSpawnPositions[i].z - player->actor.world.pos.z) < 150.0f) { - if (Flags_GetSwitch(globalCtx, sSpawnSwitchFlags[i])) { + for (i = 0; i < sEnPoFieldNumSpawned; i++) { + if (fabsf(sEnPoFieldSpawnPositions[i].x - player->actor.world.pos.x) < 150.0f && + fabsf(sEnPoFieldSpawnPositions[i].z - player->actor.world.pos.z) < 150.0f) { + if (Flags_GetSwitch(globalCtx, sEnPoFieldSpawnSwitchFlags[i])) { if (player->stateFlags1 & 0x800000) { // Player riding Epona return; } else { @@ -711,7 +711,7 @@ void EnPoField_SoulInteract(EnPoField* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x508F; Item_Give(globalCtx, ITEM_BIG_POE); - Flags_SetSwitch(globalCtx, sSpawnSwitchFlags[this->spawnFlagIndex]); + Flags_SetSwitch(globalCtx, sEnPoFieldSpawnSwitchFlags[this->spawnFlagIndex]); } } else { Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); @@ -1009,8 +1009,8 @@ void EnPoField_DrawSoul(Actor* thisx, GlobalContext* globalCtx) { } void EnPoField_Reset(void) { - sNumSpawned = 0; + sEnPoFieldNumSpawned = 0; - memset(sSpawnPositions, 0, sizeof(sSpawnPositions)); - memset(sSpawnSwitchFlags, 0, sizeof(sSpawnSwitchFlags)); + memset(sEnPoFieldSpawnPositions, 0, sizeof(sEnPoFieldSpawnPositions)); + memset(sEnPoFieldSpawnSwitchFlags, 0, sizeof(sEnPoFieldSpawnSwitchFlags)); } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c b/soh/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c index 71cd47144..c1d169dfe 100644 --- a/soh/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c +++ b/soh/src/overlays/actors/ovl_En_Takara_Man/z_en_takara_man.c @@ -35,7 +35,7 @@ const ActorInit En_Takara_Man_InitVars = { (ActorResetFunc)EnTakaraMan_Reset, }; -static u8 sTakaraIsInitialized = false; +u8 sTakaraIsInitialized = false; void EnTakaraMan_Reset(Actor* thisx, GlobalContext* globalCtx) { sTakaraIsInitialized = false; diff --git a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c index c64f9acb7..92497bf3e 100644 --- a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -447,7 +447,7 @@ void func_80B3D118(GlobalContext* globalCtx) { static Vec3f D_80B42DA0; -static s32 D_80B41D90 = 0; +s32 D_80B41D90 = 0; void EnXc_SetColossusWindSFX(GlobalContext* globalCtx) { if (gSaveContext.sceneSetupIndex == 4) { static Vec3f sPos = { 0.0f, 0.0f, 0.0f }; @@ -484,17 +484,17 @@ void EnXc_SetColossusWindSFX(GlobalContext* globalCtx) { } } -static s32 sFlameSpawned = false; +s32 sEnXcFlameSpawned = false; void EnXc_SpawnFlame(EnXc* this, GlobalContext* globalCtx) { - if (!sFlameSpawned) { + if (!sEnXcFlameSpawned) { CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); f32 xPos = npcAction->startPos.x; f32 yPos = npcAction->startPos.y; f32 zPos = npcAction->startPos.z; this->flameActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_LIGHT, xPos, yPos, zPos, 0, 0, 0, 5); - sFlameSpawned = true; + sEnXcFlameSpawned = true; } } @@ -519,7 +519,7 @@ void EnXc_DestroyFlame(EnXc* this) { Actor_Kill(&this->actor); } -static s32 D_80B41DA8 = 1; +s32 D_80B41DA8 = 1; void EnXc_InitFlame(EnXc* this, GlobalContext* globalCtx) { s32 pad; s16 sceneNum = globalCtx->sceneNum; @@ -1402,7 +1402,7 @@ void func_80B3F534(GlobalContext* globalCtx) { } } -static s32 D_80B41DAC = 1; +s32 D_80B41DAC = 1; void func_80B3F59C(EnXc* this, GlobalContext* globalCtx) { CsCmdActorAction* npcAction = EnXc_GetCsCmd(globalCtx, 0); @@ -2430,7 +2430,7 @@ const ActorInit En_Xc_InitVars = { void EnXc_Reset(void) { D_80B41D90 = 0; - sFlameSpawned = false; + sEnXcFlameSpawned = false; D_80B41DA8 = 1; D_80B41DAC = 1; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c b/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c index c5ed809db..a6b0f5809 100644 --- a/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c +++ b/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c @@ -97,8 +97,8 @@ static Vec3f sPlatformPositions[] = { }; // These seem to relate to the tagging in/out the minibosses do -static s16 D_80B4A1B0 = 0; -static s16 D_80B4A1B4 = 1; +s16 D_80B4A1B0 = 0; +s16 D_80B4A1B4 = 1; const ActorInit En_Zf_InitVars = { ACTOR_EN_ZF, diff --git a/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 8ad3a2cef..6ea271bf4 100644 --- a/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -45,7 +45,7 @@ static void* sEyeTextures[] = { gZelda2EyeOpenTex, gZelda2EyeHalfTex, gZelda2Eye static void* sMouthTextures[] = { gZelda2MouthSeriousTex, gZelda2MouthHappyTex, gZelda2MouthOpenTex }; -static s32 D_80B5A468 = 0; +s32 D_80B5A468 = 0; static Vec3f D_80B5A46C = { 0.0f, 0.0f, 0.0f }; @@ -55,7 +55,7 @@ static f32 D_80B5A484 = 0.0f; static Vec3f D_80B5A488 = { 0.0f, 0.0f, 0.0f }; -static s32 D_80B5A494 = -1; +s32 D_80B5A494 = -1; static Vec3f D_80B5A498 = { 148.0f, 260.0f, -87.0f }; @@ -63,7 +63,7 @@ static Vec3f D_80B5A4A4 = { -12.0f, 260.0f, -147.0f }; static Vec3f D_80B5A4B0 = { 42.0f, 260.0f, 13.0f }; -static u32 D_80B5A4BC = 0; +u32 D_80B5A4BC = 0; void func_80B533B0(Actor* thisx, GlobalContext* globalCtx) { EnZl3* this = (EnZl3*)thisx; diff --git a/soh/src/overlays/actors/ovl_En_fHG/z_en_fhg.c b/soh/src/overlays/actors/ovl_En_fHG/z_en_fhg.c index ce1029165..82f37b801 100644 --- a/soh/src/overlays/actors/ovl_En_fHG/z_en_fhg.c +++ b/soh/src/overlays/actors/ovl_En_fHG/z_en_fhg.c @@ -332,7 +332,7 @@ void EnfHG_Intro(EnfHG* this, GlobalContext* globalCtx) { Math_ApproachF(&this->cameraSpeedMod, 1.0f, 1.0f, 0.05f); if (this->timers[0] == 75) { TitleCard_InitBossName(globalCtx, &globalCtx->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gPhantomGanonTitleCardTex), 160, 180, 128, 40); + SEGMENTED_TO_VIRTUAL(gPhantomGanonTitleCardTex), 160, 180, 128, 40, true); } if (this->timers[0] == 0) { this->cutsceneState = INTRO_RETREAT; diff --git a/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 76e285881..70e4f4d7f 100644 --- a/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -558,7 +558,7 @@ void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx) { f32 pushDistSigned; s32 stopFlag; - this->pushSpeed += 0.5f; + this->pushSpeed += CVar_GetS32("gFasterBlockPush", 0) != 0 ? 1.0f : 0.5f; this->stateFlags |= PUSHBLOCK_PUSH; this->pushSpeed = CLAMP_MAX(this->pushSpeed, 2.0f); stopFlag = Math_StepToF(&this->pushDist, 20.0f, this->pushSpeed); @@ -586,7 +586,7 @@ void ObjOshihiki_Push(ObjOshihiki* this, GlobalContext* globalCtx) { this->dyna.unk_150 = 0.0f; this->pushDist = 0.0f; this->pushSpeed = 0.0f; - this->timer = 10; + this->timer = CVar_GetS32("gFasterBlockPush", 0) != 0 ? 3 : 10; if (this->floorBgIds[this->highestFloor] == BGCHECK_SCENE) { ObjOshihiki_SetupOnScene(this, globalCtx); } else { diff --git a/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 237f1e926..b01bcf1d9 100644 --- a/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -57,8 +57,8 @@ const ActorInit Object_Kankyo_InitVars = { (ActorResetFunc)ObjectKankyo_Reset, }; -static u8 sIsSpawned = false; -static s16 sTrailingFairies = 0; +u8 sKankyoIsSpawned = false; +s16 sTrailingFairies = 0; void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc action) { this->actionFunc = action; @@ -76,18 +76,18 @@ void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.room = -1; switch (this->actor.params) { case 0: - if (!sIsSpawned) { + if (!sKankyoIsSpawned) { ObjectKankyo_SetupAction(this, ObjectKankyo_Fairies); - sIsSpawned = true; + sKankyoIsSpawned = true; } else { Actor_Kill(&this->actor); } break; case 3: - if (!sIsSpawned) { + if (!sKankyoIsSpawned) { ObjectKankyo_SetupAction(this, ObjectKankyo_Snow); - sIsSpawned = true; + sKankyoIsSpawned = true; } else { Actor_Kill(&this->actor); } @@ -939,6 +939,6 @@ void ObjectKankyo_DrawBeams(ObjectKankyo* this2, GlobalContext* globalCtx2) { } void ObjectKankyo_Reset(void) { - sIsSpawned = false; + sKankyoIsSpawned = false; sTrailingFairies = 0; } \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index aa11b6d7e..49ad4e6e4 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -4804,7 +4804,7 @@ s32 func_8083ADD4(GlobalContext* globalCtx, Player* this) { void func_8083AE40(Player* this, s16 objectId) { s32 pad; - u32 size; + size_t size; if (objectId != OBJECT_INVALID) { this->giObjectLoading = true; @@ -4815,7 +4815,7 @@ void func_8083AE40(Player* this, s16 objectId) { LOG_HEX("size", size, "../z_player.c", 9090); ASSERT(size <= 1024 * 8, "size <= 1024 * 8", "../z_player.c", 9091); - DmaMgr_SendRequest2(&this->giObjectDmaRequest, (u32)this->giObjectSegment, gObjectTable[objectId].vromStart, + DmaMgr_SendRequest2(&this->giObjectDmaRequest, (uintptr_t)this->giObjectSegment, gObjectTable[objectId].vromStart, size, 0, &this->giObjectLoadQueue, NULL, "../z_player.c", 9099); } } @@ -10751,7 +10751,7 @@ void Player_UpdateCommon(Player* this, GlobalContext* globalCtx, Input* input) { static Vec3f D_80854838 = { 0.0f, 0.0f, -30.0f }; void Player_Update(Actor* thisx, GlobalContext* globalCtx) { - static Vec3f sDogSpawnPos; + static Vec3f sDogSpawnPos; Player* this = (Player*)thisx; s32 dogParams; s32 pad; diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index dc48b277d..570eedd1f 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1505,9 +1505,9 @@ void FileChoose_LoadGame(GameState* thisx) { (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) { gSaveContext.equips.buttonItems[0] = ITEM_NONE; - swordEquipMask = _byteswap_ushort(gEquipMasks[EQUIP_SWORD]) & gSaveContext.equips.equipment; + swordEquipMask = BOMSWAP16(gEquipMasks[EQUIP_SWORD]) & gSaveContext.equips.equipment; gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_SWORD]; - gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipMask - 1] << _byteswap_ushort(gEquipShifts[EQUIP_SWORD])); + gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipMask - 1] << BOMSWAP16(gEquipShifts[EQUIP_SWORD])); } } } diff --git a/soh/src/overlays/gamestates/ovl_select/z_select.c b/soh/src/overlays/gamestates/ovl_select/z_select.c index 98aaa4a63..c4a467d63 100644 --- a/soh/src/overlays/gamestates/ovl_select/z_select.c +++ b/soh/src/overlays/gamestates/ovl_select/z_select.c @@ -624,10 +624,10 @@ void Select_Init(GameState* thisx) { this->pageDownIndex = dREG(82); } R_UPDATE_RATE = 1; - #ifndef _MSC_VER +#if !defined(_MSC_VER) && !defined(__GNUC__) this->staticSegment = GameState_Alloc(&this->state, size, "../z_select.c", 1114); DmaMgr_SendRequest1(this->staticSegment, _z_select_staticSegmentRomStart, size, "../z_select.c", 1115); - #endif +#endif gSaveContext.cutsceneIndex = 0x8000; gSaveContext.linkAge = 1; } diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 380720dd1..18996f15e 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -34,7 +34,7 @@ void Title_PrintBuildInfo(Gfx** gfxp) { #ifdef _MSC_VER GfxPrint_Printf(&printer, "MSVC SHIP"); #else - GfxPrint_Printf(printer, "GCC SHIP"); + GfxPrint_Printf(&printer, "GCC SHIP"); #endif GfxPrint_SetPos(&printer, 5, 4); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 5b90725e1..27575c3b6 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -119,7 +119,7 @@ void KaleidoScope_DrawPlayerWork(GlobalContext* globalCtx) { func_8009214C(globalCtx, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime, &pos, &rot, scale, CUR_EQUIP_VALUE(EQUIP_SWORD), CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1, CUR_EQUIP_VALUE(EQUIP_SHIELD), CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1); - gsSPResetFB(globalCtx->state.gfxCtx->polyOpa.p++, fbTest); + gsSPResetFB(globalCtx->state.gfxCtx->polyOpa.p++); } void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c index bd5277286..f0b59fa4b 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c @@ -17,6 +17,14 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC gPauseDekuTitleENGTex, gPauseDodongoTitleENGTex, gPauseJabuTitleENGTex, gPauseForestTitleENGTex, gPauseFireTitleENGTex, gPauseWaterTitleENGTex, gPauseSpiritTitleENGTex, gPauseShadowTitleENGTex, gPauseBotWTitleENGTex, gPauseIceCavernTitleENGTex, + + gPauseDekuTitleGERTex, gPauseDodongoTitleGERTex, gPauseJabuTitleGERTex, gPauseForestTitleGERTex, + gPauseFireTitleGERTex, gPauseWaterTitleGERTex, gPauseSpiritTitleGERTex, gPauseShadowTitleGERTex, + gPauseBotWTitleGERTex, gPauseIceCavernTitleGERTex, + + gPauseDekuTitleFRATex, gPauseDodongoTitleFRATex, gPauseJabuTitleFRATex, gPauseForestTitleFRATex, + gPauseFireTitleFRATex, gPauseWaterTitleFRATex, gPauseSpiritTitleFRATex, gPauseShadowTitleFRATex, + gPauseBotWTitleFRATex, gPauseIceCavernTitleFRATex, }; static void* floorIconTexs[] = { gDungeonMapBlankFloorButtonTex, gDungeonMap8FButtonTex, gDungeonMap7FButtonTex, gDungeonMap6FButtonTex, @@ -216,7 +224,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC gSPVertex(POLY_KAL_DISP++, &pauseCtx->mapPageVtx[68], 16, 0); - gDPLoadTextureBlock(POLY_KAL_DISP++, dungeonTitleTexs[gSaveContext.mapIndex], G_IM_FMT_IA, G_IM_SIZ_8b, 96, 16, 0, + gDPLoadTextureBlock(POLY_KAL_DISP++, dungeonTitleTexs[gSaveContext.mapIndex+(10*gSaveContext.language)], G_IM_FMT_IA, G_IM_SIZ_8b, 96, 16, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 8732093ca..df6520ebf 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -3179,9 +3179,9 @@ void KaleidoScope_Update(GlobalContext* globalCtx) if (gSaveContext.language == LANGUAGE_ENG) { memcpy(pauseCtx->nameSegment + 0x400, ResourceMgr_LoadTexByName(mapNameTextures[36 + gSaveContext.worldMapArea]), 0xA00); } else if (gSaveContext.language == LANGUAGE_GER) { - memcpy(pauseCtx->nameSegment + 0x400, ResourceMgr_LoadTexByName(mapNameTextures[59 + gSaveContext.worldMapArea]), 0xA00); + memcpy(pauseCtx->nameSegment + 0x400, ResourceMgr_LoadTexByName(mapNameTextures[58 + gSaveContext.worldMapArea]), 0xA00); } else { - memcpy(pauseCtx->nameSegment + 0x400, ResourceMgr_LoadTexByName(mapNameTextures[81 + gSaveContext.worldMapArea]), 0xA00); + memcpy(pauseCtx->nameSegment + 0x400, ResourceMgr_LoadTexByName(mapNameTextures[80 + gSaveContext.worldMapArea]), 0xA00); } } // OTRTODO - player on pause diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.c index df96fc876..64275108b 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_lmap_mark_data.c @@ -15,6 +15,522 @@ static const Vtx sMarkChestVtx[] = { }; PauseMapMarksData gPauseMapMarkDataTable[] = { + // Deku Tree map 3F + { + { PAUSE_MAP_MARK_CHEST, + 23, //unk + sMarkChestVtx, + 4, //unk + 2, //Number of icons to show. + { //ID, X, Y + { 2, 40.0f, -33.0f }, + { 6, 49.0f, -42.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map 2F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 1, 48.0f, -63.0f }, + { 5, 52.0f, -68.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 3, 84.0f, -39.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map B1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 4, 77.0f, -26.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map B2 + { + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 55.0f, 0.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Dodongo's Cavern map 2F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 10, 25.0f, -41.0f }, + { 4, 53.0f, -47.0f }, + { 6, 58.0f, -59.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Dodongo's Cavern map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 5, 13.0f, -60.0f }, + { 8, 20.0f, -49.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 23.0f, -25.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Jabu-Jabu's Belly map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 1, 67.0f, -13.0f }, + { 2, 28.0f, -13.0f }, + { 4, 38.0f, 0.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 65.0f, -37.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Jabu-Jabu's Belly map B1 + { + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map 2F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 4, + { + { 0, 49.0f, -3.0f }, + { 2, 12.0f, -26.0f }, + { 5, 74.0f, -13.0f }, + { 7, 82.0f, -22.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 4, + { + { 0, 49.0f, -3.0f }, + { 2, 12.0f, -26.0f }, + { 5, 74.0f, -13.0f }, + { 7, 82.0f, -22.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map B1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 9, 31.0f, -29.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map B2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 11, 40.0f, -41.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 50.0f, -11.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 5F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 5, 22.0f, -41.0f }, + { 13, 74.0f, -29.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 4F + { + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 3F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 3, 76.0f, -48.0f }, + { 6, 72.0f, -50.0f }, + { 7, 44.0f, -17.0f }, + { 8, 63.0f, -12.0f }, + { 9, 30.0f, -34.0f }, + { 10, 61.0f, -31.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 2F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 11, 78.0f, -34.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 5, + { + { 0, 48.0f, -17.0f }, + { 1, 35.0f, -45.0f }, + { 2, 67.0f, -58.0f }, + { 4, 74.0f, -15.0f }, + { 12, 47.0f, -27.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 26.0f, -34.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map 3F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 2, 88.0f, -60.0f }, + { 7, 23.0f, -2.0f }, + { 9, 84.0f, -45.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 62.0f, -23.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map 2F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 0, 86.0f, -60.0f }, + { 8, 76.0f, -72.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 4, + { + { 1, 88.0f, -60.0f }, + { 3, 42.0f, -21.0f }, + { 5, 47.0f, -15.0f }, + { 10, 33.0f, -31.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map B1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 6, 77.0f, -66.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 4F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 10, 59.0f, -9.0f }, + { 18, 32.0f, -20.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 3F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 5, + { + { 1, 20.0f, -43.0f }, + { 5, 83.0f, -26.0f }, + { 15, 57.0f, -14.0f }, + { 20, 81.0f, -55.0f }, + { 21, 87.0f, -55.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 47.0f, 0.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 2F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 6, + { + { 2, 41.0f, -16.0f }, + { 3, 47.0f, -17.0f }, + { 6, 27.0f, -16.0f }, + { 12, 29.0f, -20.0f }, + { 13, 70.0f, -22.0f }, + { 14, 70.0f, -25.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 4, + { + { 0, 38.0f, -17.0f }, + { 4, 55.0f, -14.0f }, + { 8, 15.0f, -14.0f }, + { 7, 78.0f, -3.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map B1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 1, 41.0f, -17.0f }, + { 7, 27.0f, -24.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map B2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 2, 81.0f, -20.0f }, + { 3, 74.0f, -37.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map B3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 12, 96.0f, -51.0f }, + { 22, 96.0f, -55.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map B4 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 10, + { + { 4, 43.0f, -66.0f }, + { 5, 37.0f, -66.0f }, + { 6, 33.0f, -72.0f }, + { 8, 85.0f, -18.0f }, + { 9, 61.0f, -42.0f }, + { 10, 15.0f, -4.0f }, + { 11, 25.0f, -4.0f }, + { 13, 19.0f, -29.0f }, + { 21, 92.0f, -29.0f }, + { 20, 87.0f, -20.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 31.0f, -45.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Bottom of the Well map B1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 9, + { + { 1, 51.0f, -24.0f }, + { 3, 84.0f, -38.0f }, + { 4, 31.0f, -2.0f }, + { 5, 67.0f, -27.0f }, + { 8, 46.0f, -27.0f }, + { 10, 82.0f, -12.0f }, + { 12, 80.0f, -16.0f }, + { 14, 62.0f, -24.0f }, + { 20, 89.0f, -38.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Bottom of the Well map B2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 2, 54.0f, -27.0f }, + { 9, 28.0f, -17.0f }, + { 16, 56.0f, -38.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Bottom of the Well map B3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 7, 71.0f, -33.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Ice Cavern map 1F + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 0, 66.0f, -2.0f }, + { 1, 77.0f, -46.0f }, + { 2, 27.0f, -45.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, +}; +PauseMapMarksData gPauseMapMarkDataTableMasterQuest[] = { // Deku Tree map 0 { { PAUSE_MAP_MARK_CHEST,