Added support for multiple game versions (#107)

* WIP Multiversion support

* GC PAL Non-MQ support complete

* Updated OtrGui to handle different game versions

* Added version file

* Added new extract mode to ZAPD and optimized OTR gen time

* Fixed bug causing crash

* Further optimized OTRExporter, saving around ~20 seconds.

* ZAPD is now multi-threaded.

* Fixed merge issue

* Fixed memory leak and fog issue on pause screen.

* Additional fog fixes.

Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
This commit is contained in:
Nicholas Estelami 2022-03-31 19:42:44 -04:00 committed by GitHub
commit c80f9fbd57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1203 changed files with 30620 additions and 501 deletions

View file

@ -1495,26 +1495,6 @@ void Gameplay_InitScene(GlobalContext* globalCtx, s32 spawn)
void Gameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s32 spawn) {
OTRGameplay_SpawnScene(globalCtx, sceneNum, spawn);
return;
SceneTableEntry* scene = &gSceneTable[sceneNum];
scene->unk_13 = 0;
globalCtx->loadedScene = scene;
globalCtx->sceneNum = sceneNum;
globalCtx->sceneConfig = scene->config;
osSyncPrintf("\nSCENE SIZE %fK\n", (scene->sceneFile.vromEnd - scene->sceneFile.vromStart) / 1024.0f);
globalCtx->sceneSegment = Gameplay_LoadFile(globalCtx, &scene->sceneFile);
scene->unk_13 = 0;
ASSERT(globalCtx->sceneSegment != NULL, "this->sceneSegment != NULL", "../z_play.c", 4960);
gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment);
Gameplay_InitScene(globalCtx, spawn);
osSyncPrintf("ROOM SIZE=%fK\n", func_80096FE8(globalCtx, &globalCtx->roomCtx) / 1024.0f);
}
void func_800C016C(GlobalContext* globalCtx, Vec3f* src, Vec3f* dest) {

View file

@ -1625,6 +1625,8 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime
POLY_XLU_DISP = ohNo;
}
POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP++);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 3288);
}

View file

@ -1001,9 +1001,8 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox
LoadSkyboxPalette(globalCtx, skyboxCtx, 2, gBackAlleyHouseBg3Tlut, 16, 16);
break;
default:
skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, 0x10000 * 8, "../z_vr_box.c", 1226);
//skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, 0x10000 * 8, "../z_vr_box.c", 1226);
skyboxCtx->staticSegments[1] = malloc(0x10000 * 8); // OTRTODO
skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, 0x10000 * 4, "../z_vr_box.c", 1226);
skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, 0x10000 * 4, "../z_vr_box.c", 1226);
skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, 0x1000, "../z_vr_box.c", 1226);
break;
}

View file

@ -138,6 +138,10 @@ void ElfMsg_CallNaviCylinder(ElfMsg* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
EnElf* navi = (EnElf*)player->naviActor;
// This fixes a crash when using a grotto exit when you never properly entered
if (navi == NULL)
return;
if (ElfMsg_WithinXZDistance(&player->actor.world.pos, &this->actor.world.pos, this->actor.scale.x * 100.0f) &&
(this->actor.world.pos.y <= player->actor.world.pos.y) &&
((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) {
@ -164,9 +168,13 @@ void ElfMsg_Update(Actor* thisx, GlobalContext* globalCtx) {
}
}
#ifdef ZELDA_DEBUG
#include "overlays/ovl_Elf_Msg/ovl_Elf_Msg.h"
#endif
void ElfMsg_Draw(Actor* thisx, GlobalContext* globalCtx) {
void ElfMsg_Draw(Actor* thisx, GlobalContext* globalCtx)
{
#ifdef ZELDA_DEBUG
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg.c", 436);
if (R_NAVI_MSG_REGION_ALPHA == 0) {
@ -191,4 +199,5 @@ void ElfMsg_Draw(Actor* thisx, GlobalContext* globalCtx) {
}
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg.c", 457);
#endif
}

View file

@ -148,9 +148,12 @@ void ElfMsg2_Update(Actor* thisx, GlobalContext* globalCtx) {
}
}
#if ZELDA_DEBUG
#include "overlays/ovl_Elf_Msg2/ovl_Elf_Msg2.h"
#endif
void ElfMsg2_Draw(Actor* thisx, GlobalContext* globalCtx) {
#if ZELDA_DEBUG
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 355);
if (R_NAVI_MSG_REGION_ALPHA == 0) {
@ -165,4 +168,5 @@ void ElfMsg2_Draw(Actor* thisx, GlobalContext* globalCtx) {
gSPDisplayList(POLY_XLU_DISP++, sCubeDL);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_elf_msg2.c", 367);
#endif
}

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) {

View file

@ -789,40 +789,10 @@ static PreRender sPlayerPreRender;
static void* sPreRenderCvg;
extern int fbTest;
// OTRTODO: This function is no longer used. We could probably remove it.
void KaleidoScope_SetupPlayerPreRender(GlobalContext* globalCtx) {
Gfx* gfx;
Gfx* gfxRef;
void* fbuf;
static Gfx testBuffer[2048];
//return;
fbuf = globalCtx->state.gfxCtx->curFrameBuffer;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 496);
gfx = &testBuffer[0];
PreRender_SetValues(&sPlayerPreRender, 64, 112, fbuf, NULL);
func_800C1F20(&sPlayerPreRender, &gfx);
func_800C20B4(&sPlayerPreRender, &gfx);
gSPEndDisplayList(gfx++);
gSPDisplayList(POLY_KAL_DISP++, &testBuffer[0]);
SREG(33) |= 1;
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 509);
}
//OTRTODO - Player on pause
#if 1
void KaleidoScope_ProcessPlayerPreRender(void) {
//Sleep_Msec(50);
PreRender_Calc(&sPlayerPreRender);
PreRender_Destroy(&sPlayerPreRender);
}
#endif
Gfx* KaleidoScope_QuadTextureIA4(Gfx* gfx, void* texture, s16 width, s16 height, u16 point) {
gDPLoadTextureBlock_4b(gfx++, texture, G_IM_FMT_IA, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP,
@ -4026,7 +3996,6 @@ void KaleidoScope_Update(GlobalContext* globalCtx)
ResourceMgr_DirtyDirectory("textures/icon_item_24_static*");
ResourceMgr_DirtyDirectory("textures/icon_item_static*");
CVar_SetS32("gPauseTriforce", 0);
//ResourceMgr_InvalidateCache();
func_800981B8(&globalCtx->objectCtx);
func_800418D0(&globalCtx->colCtx, globalCtx);