Added version file

This commit is contained in:
Jack Walker 2022-03-30 15:09:22 -04:00
commit be07a14534
12 changed files with 99 additions and 18 deletions

View file

@ -1 +0,0 @@
UNKNOWN

View file

@ -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;
}

View file

@ -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 <cstdio>
#include <string>

View file

@ -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<std::string> files;
Util::dirscan(path, files);
std::vector<std::string> xmlFiles;

View file

@ -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

View file

@ -3,6 +3,7 @@
#include "spdlog/spdlog.h"
#include "File.h"
#include "Archive.h"
#include "GameVersions.h"
#include <Utils/StringHelper.h>
#include "Lib/StormLib/StormLib.h"
@ -11,6 +12,8 @@ namespace Ship {
ResourceMgr::ResourceMgr(std::shared_ptr<GlobalCtx2> Context, std::string MainPath, std::string PatchesPath) : Context(Context), bIsRunning(false), FileLoadThread(nullptr) {
OTR = std::make_shared<Archive>(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<File> ResourceMgr::LoadFileAsync(std::string FilePath) {
const std::lock_guard<std::mutex> Lock(FileLoadMutex);
// File NOT already loaded...?

View file

@ -29,6 +29,8 @@ namespace Ship
void InvalidateResourceCache();
uint32_t GetGameVersion();
void SetGameVersion(uint32_t newGameVersion);
std::shared_ptr<File> LoadFileAsync(std::string FilePath);
std::shared_ptr<File> LoadFile(std::string FilePath);
std::shared_ptr<Ship::Resource> GetCachedFile(std::string FilePath);
@ -58,5 +60,6 @@ namespace Ship
std::condition_variable FileLoadNotifier;
std::condition_variable ResourceLoadNotifier;
volatile bool bIsRunning;
uint32_t gameVersion;
};
}

View file

@ -344,6 +344,7 @@
<ClInclude Include="Cvar.h" />
<ClInclude Include="Environment.h" />
<ClInclude Include="GameSettings.h" />
<ClInclude Include="GameVersions.h" />
<ClInclude Include="Lib\ImGui\backends\imgui_impl_dx11.h" />
<ClInclude Include="Lib\ImGui\backends\imgui_impl_win32.h" />
<ClInclude Include="Lib\stb\stb_image_write.h" />

View file

@ -626,5 +626,8 @@
<ClInclude Include="GameSettings.h">
<Filter>Source Files\CustomImpl</Filter>
</ClInclude>
<ClInclude Include="GameVersions.h">
<Filter>Source Files\Resources</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -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);
}

View file

@ -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);

View file

@ -10,6 +10,9 @@
#include "alloca.h"
#include "textures/nintendo_rogo_static/nintendo_rogo_static.h"
#include <soh/Enhancements/bootcommands.h>
#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) {