diff --git a/OTRExporter/version b/OTRExporter/version deleted file mode 100644 index fedd7e51b..000000000 --- a/OTRExporter/version +++ /dev/null @@ -1 +0,0 @@ -UNKNOWN \ No newline at end of file diff --git a/OTRGui/src/game/game.cpp b/OTRGui/src/game/game.cpp index 53e7373a8..68f2bd122 100644 --- a/OTRGui/src/game/game.cpp +++ b/OTRGui/src/game/game.cpp @@ -75,6 +75,7 @@ void ExtractRom() { const WriteResult result = ExtractBaserom(patched_rom); if (result.error == NULLSTR) { if (MoonUtils::exists("oot.otr")) MoonUtils::rm("oot.otr"); + if (MoonUtils::exists("Extract")) MoonUtils::rm("Extract"); startWorker(version); extracting = true; } diff --git a/OTRGui/src/impl/baserom_extractor/baserom_extractor.h b/OTRGui/src/impl/baserom_extractor/baserom_extractor.h index 8548f4eca..9538c87f6 100644 --- a/OTRGui/src/impl/baserom_extractor/baserom_extractor.h +++ b/OTRGui/src/impl/baserom_extractor/baserom_extractor.h @@ -1,23 +1,7 @@ #ifndef EXTRACT_BASEROM_H_ #define EXTRACT_BASEROM_H_ -#define OOT_NTSC_10 0xEC7011B7 -#define OOT_NTSC_11 0xD43DA81F -#define OOT_NTSC_12 0x693BA2AE -#define OOT_PAL_10 0xB044B569 -#define OOT_PAL_11 0xB2055FBD -#define OOT_NTSC_JP_GC_CE 0xF7F52DB8 -#define OOT_NTSC_JP_GC 0xF611F4BA -#define OOT_NTSC_US_GC 0xF3DD35BA -#define OOT_PAL_GC 0x09465AC3 -#define OOT_NTSC_JP_MQ 0xF43B45BA -#define OOT_NTSC_US_MQ 0xF034001A -#define OOT_PAL_MQ 0x1D4136F3 -#define OOT_PAL_GC_DBG1 0x871E1C92 // 03-21-2002 build -#define OOT_PAL_GC_DBG2 0x87121EFE // 03-13-2002 build -#define OOT_PAL_GC_MQ_DBG 0x917D18F6 -#define OOT_IQUE_TW 0x3D81FB3E -#define OOT_IQUE_CN 0xB1E1E07B +#include "../../libultraship/libultraship/GameVersions.h" #include #include diff --git a/OTRGui/src/impl/extractor/extractor.cpp b/OTRGui/src/impl/extractor/extractor.cpp index 35369cab5..e7fd8a756 100644 --- a/OTRGui/src/impl/extractor/extractor.cpp +++ b/OTRGui/src/impl/extractor/extractor.cpp @@ -39,6 +39,7 @@ void BuildOTR(const std::string output) { Util::copy("tmp/baserom/Audiobank", "Extract/Audiobank"); Util::copy("tmp/baserom/Audioseq", "Extract/Audioseq"); Util::copy("tmp/baserom/Audiotable", "Extract/Audiotable"); + Util::copy("tmp/baserom/version", "Extract/version"); Util::copy("assets/game/", "Extract/assets/"); @@ -82,6 +83,8 @@ void startWorker(RomVersion version) { path += GetXMLVersion(version); + Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc)); + std::vector files; Util::dirscan(path, files); std::vector xmlFiles; diff --git a/libultraship/libultraship/GameVersions.h b/libultraship/libultraship/GameVersions.h new file mode 100644 index 000000000..a25463bf4 --- /dev/null +++ b/libultraship/libultraship/GameVersions.h @@ -0,0 +1,20 @@ +#pragma once + +#define OOT_NTSC_10 0xEC7011B7 +#define OOT_NTSC_11 0xD43DA81F +#define OOT_NTSC_12 0x693BA2AE +#define OOT_PAL_10 0xB044B569 +#define OOT_PAL_11 0xB2055FBD +#define OOT_NTSC_JP_GC_CE 0xF7F52DB8 +#define OOT_NTSC_JP_GC 0xF611F4BA +#define OOT_NTSC_US_GC 0xF3DD35BA +#define OOT_PAL_GC 0x09465AC3 +#define OOT_NTSC_JP_MQ 0xF43B45BA +#define OOT_NTSC_US_MQ 0xF034001A +#define OOT_PAL_MQ 0x1D4136F3 +#define OOT_PAL_GC_DBG1 0x871E1C92 // 03-21-2002 build +#define OOT_PAL_GC_DBG2 0x87121EFE // 03-13-2002 build +#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 diff --git a/libultraship/libultraship/ResourceMgr.cpp b/libultraship/libultraship/ResourceMgr.cpp index 790b4648a..e6f3c8a0a 100644 --- a/libultraship/libultraship/ResourceMgr.cpp +++ b/libultraship/libultraship/ResourceMgr.cpp @@ -3,6 +3,7 @@ #include "spdlog/spdlog.h" #include "File.h" #include "Archive.h" +#include "GameVersions.h" #include #include "Lib/StormLib/StormLib.h" @@ -11,6 +12,8 @@ namespace Ship { ResourceMgr::ResourceMgr(std::shared_ptr Context, std::string MainPath, std::string PatchesPath) : Context(Context), bIsRunning(false), FileLoadThread(nullptr) { OTR = std::make_shared(MainPath, PatchesPath, false); + gameVersion = OOT_UNKNOWN; + if (OTR->IsMainMPQValid()) Start(); } @@ -173,6 +176,16 @@ namespace Ship { SPDLOG_INFO("Resource Manager LoadResourceThread ended"); } + uint32_t ResourceMgr::GetGameVersion() + { + return gameVersion; + } + + void ResourceMgr::SetGameVersion(uint32_t newGameVersion) + { + gameVersion = newGameVersion; + } + std::shared_ptr ResourceMgr::LoadFileAsync(std::string FilePath) { const std::lock_guard Lock(FileLoadMutex); // File NOT already loaded...? diff --git a/libultraship/libultraship/ResourceMgr.h b/libultraship/libultraship/ResourceMgr.h index 86e0cc268..5eae61abe 100644 --- a/libultraship/libultraship/ResourceMgr.h +++ b/libultraship/libultraship/ResourceMgr.h @@ -29,6 +29,8 @@ namespace Ship void InvalidateResourceCache(); + uint32_t GetGameVersion(); + void SetGameVersion(uint32_t newGameVersion); std::shared_ptr LoadFileAsync(std::string FilePath); std::shared_ptr LoadFile(std::string FilePath); std::shared_ptr GetCachedFile(std::string FilePath); @@ -58,5 +60,6 @@ namespace Ship 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/libultraship.vcxproj b/libultraship/libultraship/libultraship.vcxproj index 625c5142c..3bf81a67d 100644 --- a/libultraship/libultraship/libultraship.vcxproj +++ b/libultraship/libultraship/libultraship.vcxproj @@ -344,6 +344,7 @@ + diff --git a/libultraship/libultraship/libultraship.vcxproj.filters b/libultraship/libultraship/libultraship.vcxproj.filters index deed867c8..5079d826e 100644 --- a/libultraship/libultraship/libultraship.vcxproj.filters +++ b/libultraship/libultraship/libultraship.vcxproj.filters @@ -626,5 +626,8 @@ Source Files\CustomImpl + + Source Files\Resources + \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 0732a80e1..c000ce8e1 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -22,6 +22,7 @@ #include "Lib/stb/stb_image.h" #include "AudioPlayer.h" #include "../soh/Enhancements/debugconsole.h" +#include "Utils/BitConverter.h" OTRGlobals* OTRGlobals::Instance; @@ -41,6 +42,15 @@ extern "C" void OTRMessage_Init(); // C->C++ Bridge extern "C" void InitOTR() { OTRGlobals::Instance = new OTRGlobals(); + auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version"); + + if (!t->bHasLoadError) + { + //uint32_t gameVersion = BitConverter::ToUInt32BE((uint8_t*)t->buffer.get(), 0); + uint32_t gameVersion = *((uint32_t*)t->buffer.get()); + OTRGlobals::Instance->context->GetResourceManager()->SetGameVersion(gameVersion); + } + clearMtx = (uintptr_t)&gMtxClear; OTRMessage_Init(); DebugConsole_Init(); @@ -96,6 +106,11 @@ extern "C" void OTRResetScancode() OTRGlobals::Instance->context->GetWindow()->lastScancode = -1; } +extern "C" uint32_t ResourceMgr_GetGameVersion() +{ + return OTRGlobals::Instance->context->GetResourceManager()->GetGameVersion(); +} + extern "C" void ResourceMgr_CacheDirectory(const char* resName) { OTRGlobals::Instance->context->GetResourceManager()->CacheDirectory(resName); } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index f7e525834..4a439fc6d 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -27,6 +27,7 @@ void OTRGfxPrint(const char* str, void* printer, void (*printImpl)(void*, char)) void OTRSetFrameDivisor(int divisor); uint16_t OTRGetPixelDepth(float x, float y); int32_t OTRGetLastScancode(); +uint32_t ResourceMgr_GetGameVersion(); void ResourceMgr_CacheDirectory(const char* resName); void ResourceMgr_LoadFile(const char* resName); char* ResourceMgr_LoadFileFromDisk(const char* filePath); diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index e45cdf27b..942962f2e 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -10,6 +10,9 @@ #include "alloca.h" #include "textures/nintendo_rogo_static/nintendo_rogo_static.h" #include +#include "GameVersions.h" + +const char* GetGameVersionString(); char* quote; @@ -18,6 +21,8 @@ void Title_PrintBuildInfo(Gfx** gfxp) { //GfxPrint* printer; GfxPrint printer; + const char* gameVersionStr = GetGameVersionString(); + g = *gfxp; g = func_8009411C(g); //printer = alloca(sizeof(GfxPrint)); @@ -32,6 +37,9 @@ void Title_PrintBuildInfo(Gfx** gfxp) { GfxPrint_Printf(printer, "GCC SHIP"); #endif + GfxPrint_SetPos(&printer, 5, 4); + GfxPrint_Printf(&printer, "Game Version: %s", gameVersionStr); + GfxPrint_SetColor(&printer, 255, 255, 255, 255); GfxPrint_SetPos(&printer, 2, 22); GfxPrint_Printf(&printer, quote); @@ -66,6 +74,36 @@ char* SetQuote() { return quotes[randomQuote]; } +const char* GetGameVersionString() { + uint32_t gameVersion = ResourceMgr_GetGameVersion(); + switch (gameVersion) { + case OOT_NTSC_10: + return "N64 NTSC 1.0"; + case OOT_NTSC_11: + return "N64 NTSC 1.1"; + case OOT_NTSC_12: + return "N64 NTSC 1.2"; + case OOT_PAL_10: + return "N64 PAL 1.0"; + case OOT_PAL_11: + return "N64 PAL 1.1"; + case OOT_PAL_GC: + return "GC PAL"; + case OOT_PAL_MQ: + return "GC PAL MQ"; + case OOT_PAL_GC_DBG1: + return "GC PAL DEBUG"; + case OOT_PAL_GC_DBG2: + return "GC PAL DEBUG MQ"; + case OOT_IQUE_CN: + return "IQUE CN"; + case OOT_IQUE_TW: + return "IQUE TW"; + default: + return "UNKNOWN"; + } +} + // Note: In other rom versions this function also updates unk_1D4, coverAlpha, addAlpha, visibleDuration to calculate // the fade-in/fade-out + the duration of the n64 logo animation void Title_Calc(TitleContext* this) {