2022-03-21 21:51:23 -04:00
|
|
|
/*
|
|
|
|
* File: z_title.c
|
|
|
|
* Overlay: ovl_title
|
|
|
|
* Description: Displays the Nintendo Logo
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NORMAL_GAMEPLAY
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "alloca.h"
|
|
|
|
#include "textures/nintendo_rogo_static/nintendo_rogo_static.h"
|
2022-12-20 23:32:01 -05:00
|
|
|
#include "assets/objects/gameplay_keep/gameplay_keep.h"
|
2022-03-21 21:51:23 -04:00
|
|
|
#include <soh/Enhancements/bootcommands.h>
|
2022-11-14 05:22:34 -05:00
|
|
|
#include <GameVersions.h>
|
2022-07-21 18:36:46 -04:00
|
|
|
#include <soh/SaveManager.h>
|
2024-04-12 14:23:17 -04:00
|
|
|
#include <string.h>
|
2022-03-31 19:42:44 -04:00
|
|
|
|
2022-09-29 19:07:48 -04:00
|
|
|
#include "time.h"
|
|
|
|
|
2022-11-20 14:13:54 -05:00
|
|
|
const char* GetGameVersionString(s32 index);
|
2022-03-21 21:51:23 -04:00
|
|
|
char* quote;
|
|
|
|
|
|
|
|
void Title_PrintBuildInfo(Gfx** gfxp) {
|
|
|
|
Gfx* g;
|
|
|
|
GfxPrint printer;
|
|
|
|
|
|
|
|
g = *gfxp;
|
2022-11-29 18:29:36 -05:00
|
|
|
g = Gfx_SetupDL_28(g);
|
2023-04-23 19:13:51 -04:00
|
|
|
|
2022-03-21 21:51:23 -04:00
|
|
|
GfxPrint_Init(&printer);
|
|
|
|
GfxPrint_Open(&printer, g);
|
2023-04-23 19:13:51 -04:00
|
|
|
GfxPrint_SetColor(&printer, 131, 154, 255, 255);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
2024-04-12 14:57:34 -04:00
|
|
|
//if tag is empty (not a release build)
|
|
|
|
bool showGitBranch = gGitCommitTag[0] == 0;
|
2024-04-12 13:14:37 -04:00
|
|
|
bool showGitCommit = CVarGetInteger("gDebugEnabled", 0);
|
|
|
|
|
|
|
|
GfxPrint_SetPos(&printer, 1, showGitBranch ? (showGitCommit ? 23 : 24) : (showGitCommit ? 24 : 25));
|
2023-04-23 19:13:51 -04:00
|
|
|
GfxPrint_Printf(&printer, "%s", gBuildVersion);
|
2024-04-12 13:14:37 -04:00
|
|
|
if (showGitBranch) {
|
|
|
|
GfxPrint_SetPos(&printer, 1, showGitCommit ? 24 : 25);
|
|
|
|
GfxPrint_Printf(&printer, "Git Branch: %s", gGitBranch);
|
|
|
|
}
|
|
|
|
if (showGitCommit) {
|
|
|
|
//truncate the commit to 7 characters
|
|
|
|
char gGitCommitHashTruncated[8];
|
|
|
|
strncpy(gGitCommitHashTruncated, gGitCommitHash, 7);
|
|
|
|
gGitCommitHashTruncated[7] = 0;
|
|
|
|
|
|
|
|
GfxPrint_SetPos(&printer, 1, 25);
|
|
|
|
GfxPrint_Printf(&printer, "Git Commit: %s", gGitCommitHashTruncated);
|
|
|
|
}
|
2023-04-23 19:13:51 -04:00
|
|
|
GfxPrint_SetPos(&printer, 1, 26);
|
|
|
|
GfxPrint_Printf(&printer, "%s", gBuildDate);
|
2022-11-20 14:13:54 -05:00
|
|
|
|
|
|
|
u32 numVersions = ResourceMgr_GetNumGameVersions();
|
2023-04-23 19:13:51 -04:00
|
|
|
s32 pos = 27 - numVersions;
|
|
|
|
for (u32 i = 0; i < numVersions; i++) {
|
|
|
|
GfxPrint_SetPos(&printer, 29, pos++);
|
|
|
|
GfxPrint_Printf(&printer, "%s", GetGameVersionString(i));
|
2022-11-20 14:13:54 -05:00
|
|
|
}
|
|
|
|
|
2022-03-21 21:51:23 -04:00
|
|
|
g = GfxPrint_Close(&printer);
|
|
|
|
GfxPrint_Destroy(&printer);
|
|
|
|
*gfxp = g;
|
|
|
|
}
|
|
|
|
|
2022-11-20 14:13:54 -05:00
|
|
|
const char* GetGameVersionString(s32 index) {
|
|
|
|
uint32_t gameVersion = ResourceMgr_GetGameVersion(index);
|
2022-03-31 19:42:44 -04:00
|
|
|
switch (gameVersion) {
|
2023-04-23 19:13:51 -04:00
|
|
|
case OOT_NTSC_US_10:
|
|
|
|
return "NTSC-U 1.0";
|
|
|
|
case OOT_NTSC_US_11:
|
|
|
|
return "NTSC-U 1.1";
|
|
|
|
case OOT_NTSC_US_12:
|
|
|
|
return "NTSC-U 1.2";
|
2022-03-31 19:42:44 -04:00
|
|
|
case OOT_PAL_10:
|
2023-04-23 19:13:51 -04:00
|
|
|
return "PAL 1.0";
|
2022-03-31 19:42:44 -04:00
|
|
|
case OOT_PAL_11:
|
2023-04-23 19:13:51 -04:00
|
|
|
return "PAL 1.1";
|
2022-03-31 19:42:44 -04:00
|
|
|
case OOT_PAL_GC:
|
2023-04-23 19:13:51 -04:00
|
|
|
return "PAL GC";
|
2022-03-31 19:42:44 -04:00
|
|
|
case OOT_PAL_MQ:
|
2023-04-23 19:13:51 -04:00
|
|
|
return "PAL MQ";
|
2022-03-31 19:42:44 -04:00
|
|
|
case OOT_PAL_GC_DBG1:
|
|
|
|
case OOT_PAL_GC_DBG2:
|
2023-04-23 19:13:51 -04:00
|
|
|
return "PAL GC-D";
|
2022-09-29 19:07:48 -04:00
|
|
|
case OOT_PAL_GC_MQ_DBG:
|
2023-04-23 19:13:51 -04:00
|
|
|
return "PAL MQ-D";
|
2022-03-31 19:42:44 -04:00
|
|
|
case OOT_IQUE_CN:
|
|
|
|
return "IQUE CN";
|
|
|
|
case OOT_IQUE_TW:
|
|
|
|
return "IQUE TW";
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-21 21:51:23 -04:00
|
|
|
// 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) {
|
|
|
|
#ifdef NORMAL_GAMEPLAY
|
|
|
|
if ((this->coverAlpha == 0) && (this->visibleDuration != 0)) {
|
|
|
|
this->visibleDuration--;
|
|
|
|
this->unk_1D4--;
|
|
|
|
if (this->unk_1D4 == 0) {
|
|
|
|
this->unk_1D4 = 400;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this->coverAlpha += this->addAlpha;
|
|
|
|
if (this->coverAlpha <= 0) {
|
|
|
|
this->coverAlpha = 0;
|
|
|
|
this->addAlpha = 3;
|
|
|
|
} else if (this->coverAlpha >= 0xFF) {
|
|
|
|
this->coverAlpha = 0xFF;
|
|
|
|
this->exit = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->uls = this->ult & 0x7F;
|
|
|
|
this->ult++;
|
|
|
|
|
|
|
|
if (gSkipLogoTest || gLoadFileSelect) {
|
2022-08-16 21:53:28 -04:00
|
|
|
this->exit = true;
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2022-08-16 21:53:28 -04:00
|
|
|
this->exit = true;
|
2022-03-21 21:51:23 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void Title_SetupView(TitleContext* this, f32 x, f32 y, f32 z) {
|
|
|
|
View* view = &this->view;
|
|
|
|
Vec3f eye;
|
|
|
|
Vec3f lookAt;
|
|
|
|
Vec3f up;
|
|
|
|
|
|
|
|
eye.x = x;
|
|
|
|
eye.y = y;
|
|
|
|
eye.z = z;
|
|
|
|
up.x = up.z = 0.0f;
|
|
|
|
lookAt.x = lookAt.y = lookAt.z = 0.0f;
|
|
|
|
up.y = 1.0f;
|
|
|
|
|
|
|
|
func_800AA460(view, 30.0f, 10.0f, 12800.0f);
|
|
|
|
func_800AA358(view, &eye, &lookAt, &up);
|
|
|
|
func_800AAA50(view, 0xF);
|
|
|
|
}
|
|
|
|
|
2023-04-27 19:20:41 -04:00
|
|
|
#define dgShipLogoDL "__OTR__textures/nintendo_rogo_static/gShipLogoDL"
|
|
|
|
static const ALIGN_ASSET(2) char gShipLogoDL[] = dgShipLogoDL;
|
|
|
|
|
|
|
|
#define dnintendo_rogo_static_Tex_LUS_000000 "__OTR__textures/nintendo_rogo_static/nintendo_rogo_static_Tex_LUS_000000"
|
|
|
|
static const ALIGN_ASSET(2) char nintendo_rogo_static_Tex_LUS_000000[] = dnintendo_rogo_static_Tex_LUS_000000;
|
|
|
|
|
2022-03-21 21:51:23 -04:00
|
|
|
void Title_Draw(TitleContext* this) {
|
|
|
|
static s16 sTitleRotY = 0;
|
|
|
|
static Lights1 sTitleLights = gdSPDefLights1(0x64, 0x64, 0x64, 0xFF, 0xFF, 0xFF, 0x45, 0x45, 0x45);
|
|
|
|
|
|
|
|
u16 y;
|
|
|
|
u16 idx;
|
|
|
|
s32 pad1;
|
|
|
|
Vec3f v3;
|
|
|
|
Vec3f v1;
|
|
|
|
Vec3f v2;
|
|
|
|
s32 pad2[2];
|
|
|
|
|
2022-07-05 19:29:34 -04:00
|
|
|
OPEN_DISPS(this->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
v3.x = 69;
|
|
|
|
v3.y = 69;
|
|
|
|
v3.z = 69;
|
|
|
|
v2.x = -4949.148;
|
|
|
|
v2.y = 4002.5417;
|
|
|
|
v1.x = 0;
|
|
|
|
v1.y = 0;
|
|
|
|
v1.z = 0;
|
|
|
|
v2.z = 1119.0837;
|
|
|
|
|
|
|
|
func_8002EABC(&v1, &v2, &v3, this->state.gfxCtx);
|
|
|
|
gSPSetLights1(POLY_OPA_DISP++, sTitleLights);
|
|
|
|
Title_SetupView(this, 0, 150.0, 300.0);
|
2022-11-29 18:29:36 -05:00
|
|
|
Gfx_SetupDL_25Opa(this->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
Matrix_Translate(-53.0, -5.0, 0, MTXMODE_NEW);
|
|
|
|
Matrix_Scale(1.0, 1.0, 1.0, MTXMODE_APPLY);
|
|
|
|
Matrix_RotateZYX(0, sTitleRotY, 0, MTXMODE_APPLY);
|
|
|
|
|
2022-07-05 19:29:34 -04:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(this->state.gfxCtx), G_MTX_LOAD);
|
2023-04-27 19:20:41 -04:00
|
|
|
if (CVarGetInteger("gAuthenticLogo", 0)) {
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoDL);
|
|
|
|
} else {
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, gShipLogoDL);
|
|
|
|
}
|
2022-11-29 18:29:36 -05:00
|
|
|
Gfx_SetupDL_39Opa(this->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
gDPPipeSync(POLY_OPA_DISP++);
|
|
|
|
gDPSetCycleType(POLY_OPA_DISP++, G_CYC_2CYCLE);
|
|
|
|
gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF2, G_RM_OPA_CI | CVG_DST_WRAP);
|
|
|
|
gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, PRIMITIVE, ENV_ALPHA, TEXEL0, 0, 0, 0, TEXEL0, PRIMITIVE, ENVIRONMENT,
|
|
|
|
COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0);
|
2023-01-17 00:17:49 -05:00
|
|
|
if (CVarGetInteger("gCosmetics.Title_NintendoLogo.Changed", 0)) {
|
|
|
|
Color_RGB8 nintendoLogoColor = CVarGetColor24("gCosmetics.Title_NintendoLogo.Value", (Color_RGB8){0, 0, 255});
|
2022-12-08 23:24:39 -05:00
|
|
|
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255);
|
|
|
|
gDPSetEnvColor(POLY_OPA_DISP++, nintendoLogoColor.r, nintendoLogoColor.g, nintendoLogoColor.b, 128);
|
|
|
|
} else {
|
|
|
|
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 170, 255, 255, 255);
|
|
|
|
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 255, 128);
|
|
|
|
}
|
2022-03-21 21:51:23 -04:00
|
|
|
|
2022-04-25 16:19:00 -04:00
|
|
|
gDPLoadMultiBlock(POLY_OPA_DISP++, nintendo_rogo_static_Tex_001800, 0x100, 1, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0,
|
2022-03-21 21:51:23 -04:00
|
|
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, 5, 2, 11);
|
|
|
|
|
|
|
|
for (idx = 0, y = 94; idx < 16; idx++, y += 2)
|
|
|
|
{
|
2023-04-27 19:20:41 -04:00
|
|
|
gDPLoadMultiTile(POLY_OPA_DISP++, CVarGetInteger("gAuthenticLogo", 0) ? nintendo_rogo_static_Tex_000000 : nintendo_rogo_static_Tex_LUS_000000, 0, G_TX_RENDERTILE, G_IM_FMT_I, G_IM_SIZ_8b, 192, 32,
|
|
|
|
0, idx * 2, 192 - 1, (idx + 1) * 2 - 1, 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);
|
|
|
|
|
|
|
|
gDPSetTileSize(POLY_OPA_DISP++, 0, 0, 0, (192 - 1) << G_TEXTURE_IMAGE_FRAC,
|
|
|
|
(2 - 1) << G_TEXTURE_IMAGE_FRAC);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
gDPSetTileSize(POLY_OPA_DISP++, 1, this->uls, (this->ult & 0x7F) - idx * 4, 0, 0);
|
|
|
|
gSPTextureRectangle(POLY_OPA_DISP++, 388, y << 2, 1156, (y + 2) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
|
|
|
|
}
|
|
|
|
|
2022-12-20 23:32:01 -05:00
|
|
|
// Draw ice cube around N64 logo.
|
2023-01-17 00:17:49 -05:00
|
|
|
if (CVarGetInteger("gLetItSnow", 0)) {
|
2022-12-20 23:32:01 -05:00
|
|
|
f32 scale = 0.4f;
|
|
|
|
|
|
|
|
gSPSegment(POLY_OPA_DISP++, 0x08,
|
|
|
|
Gfx_TwoTexScroll(this->state.gfxCtx, 0, 0, (0 - 1) % 128, 32, 32, 1,
|
|
|
|
0, (1 * -2) % 128, 32, 32));
|
|
|
|
|
|
|
|
Matrix_Translate(0.0f, -10.0f, 0.0f, MTXMODE_APPLY);
|
|
|
|
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
|
|
|
|
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(this->state.gfxCtx),
|
|
|
|
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
|
|
|
gDPSetEnvColor(POLY_OPA_DISP++, 0, 50, 100, 255);
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, gEffIceFragment3DL);
|
|
|
|
}
|
|
|
|
|
2022-03-21 21:51:23 -04:00
|
|
|
Environment_FillScreen(this->state.gfxCtx, 0, 0, 0, (s16)this->coverAlpha, FILL_SCREEN_XLU);
|
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
sTitleRotY += (300 * CVarGetFloat("gCosmetics.N64Logo_SpinSpeed", 1.0f));
|
2022-03-21 21:51:23 -04:00
|
|
|
|
2022-07-05 19:29:34 -04:00
|
|
|
CLOSE_DISPS(this->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Title_Main(GameState* thisx) {
|
|
|
|
TitleContext* this = (TitleContext*)thisx;
|
|
|
|
|
2022-07-05 19:29:34 -04:00
|
|
|
OPEN_DISPS(this->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
|
|
|
|
gSPSegment(POLY_OPA_DISP++, 0, NULL);
|
|
|
|
gSPSegment(POLY_OPA_DISP++, 1, this->staticSegment);
|
2022-11-29 18:29:36 -05:00
|
|
|
Gfx_SetupFrame(this->state.gfxCtx, 0, 0, 0);
|
2022-03-21 21:51:23 -04:00
|
|
|
Title_Calc(this);
|
|
|
|
Title_Draw(this);
|
|
|
|
|
2023-04-27 19:20:41 -04:00
|
|
|
if (!CVarGetInteger("gAuthenticLogo", 0)) {
|
2022-03-21 21:51:23 -04:00
|
|
|
Gfx* gfx = POLY_OPA_DISP;
|
|
|
|
s32 pad;
|
|
|
|
|
|
|
|
Title_PrintBuildInfo(&gfx);
|
|
|
|
POLY_OPA_DISP = gfx;
|
|
|
|
}
|
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
if (this->exit || CVarGetInteger("gSkipLogoTitle", 0)) {
|
2022-03-21 21:51:23 -04:00
|
|
|
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
|
|
|
|
gSaveContext.natureAmbienceId = 0xFF;
|
|
|
|
gSaveContext.gameMode = 1;
|
|
|
|
this->state.running = false;
|
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
if (gLoadFileSelect || CVarGetInteger("gSkipLogoTitle", 0))
|
2022-03-21 21:51:23 -04:00
|
|
|
SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext);
|
|
|
|
else
|
|
|
|
SET_NEXT_GAMESTATE(&this->state, Opening_Init, OpeningContext);
|
|
|
|
}
|
|
|
|
|
2022-07-05 19:29:34 -04:00
|
|
|
CLOSE_DISPS(this->state.gfxCtx);
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Title_Destroy(GameState* thisx) {
|
|
|
|
TitleContext* this = (TitleContext*)thisx;
|
|
|
|
|
2022-06-20 13:41:43 -04:00
|
|
|
Sram_InitSram(&this->state);
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Title_Init(GameState* thisx) {
|
|
|
|
//u32 size = 0;
|
|
|
|
TitleContext* this = (TitleContext*)thisx;
|
2022-10-29 13:53:39 -04:00
|
|
|
|
|
|
|
this->staticSegment = NULL;
|
|
|
|
//this->staticSegment = GAMESTATE_ALLOC_MC(&this->state, size);
|
|
|
|
osSyncPrintf("z_title.c\n");
|
|
|
|
|
2023-03-14 02:45:19 -04:00
|
|
|
//ResourceMgr_LoadDirectory("nintendo_rogo_static*");
|
2022-10-29 13:53:39 -04:00
|
|
|
|
|
|
|
// Disable vismono
|
|
|
|
D_801614B0.a = 0;
|
|
|
|
R_UPDATE_RATE = 1;
|
|
|
|
Matrix_Init(&this->state);
|
|
|
|
View_Init(&this->view, this->state.gfxCtx);
|
|
|
|
this->state.main = Title_Main;
|
|
|
|
this->state.destroy = Title_Destroy;
|
|
|
|
this->exit = false;
|
|
|
|
gSaveContext.fileNum = 0xFF;
|
|
|
|
this->ult = 0;
|
|
|
|
this->unk_1D4 = 0x14;
|
|
|
|
this->coverAlpha = 255;
|
|
|
|
this->addAlpha = -3;
|
|
|
|
this->visibleDuration = 0x3C;
|
2022-03-21 21:51:23 -04:00
|
|
|
}
|