From dc964931c25f0ef308620b677649ff1e3524198d Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 30 Aug 2024 00:23:01 +0200 Subject: [PATCH] [ntsc-1.2] Match z_demo.c, z_eff_blure.c, z_eff_spark.c (#2096) * Match z_demo.c * Match z_eff_blure.c * Match z_eff_spark.c (fake inc.) * review * improve EffectSpark_Draw match Co-authored-by: cadmic * cleanup * fix merge * review * better match EffectBlure_DrawSimpleVertices (ty cadmic) * review * rm unneeded include versions.h --------- Co-authored-by: cadmic --- include/n64dd.h | 2 + src/code/z_demo.c | 16 ++++- src/code/z_eff_blure.c | 149 ++++++++++++++++++++--------------------- src/code/z_eff_spark.c | 66 +++++++++--------- 4 files changed, 123 insertions(+), 110 deletions(-) diff --git a/include/n64dd.h b/include/n64dd.h index 3eb1283875..d744711849 100644 --- a/include/n64dd.h +++ b/include/n64dd.h @@ -34,6 +34,8 @@ typedef struct n64ddStruct_80121AF0 { char unk_48[0x24]; void (*unk_6C)(struct PlayState*, SceneDrawConfigFunc*); s32 (*unk_70)(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk, OSMesgQueue* queue, OSMesg msg); + char unk_74[4]; + s32 (*unk_78)(struct PlayState*, void*, void*); } n64ddStruct_80121AF0; // size = ? void func_800ADA80(void); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 7417b78687..56a94816c0 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,6 +1,9 @@ #include "global.h" #include "quake.h" #include "z64camera.h" +#if PLATFORM_N64 +#include "n64dd.h" +#endif #include "assets/scenes/indoors/tokinoma/tokinoma_scene.h" @@ -111,7 +114,7 @@ EntranceCutscene sEntranceCutsceneTable[] = { { ENTR_KOKIRI_FOREST_12, 2, EVENTCHKINF_C6, gKokiriForestDekuSproutCs }, }; -void* sUnusedEntranceCsList[] = { +void* sCutscenesUnknownList[] = { gDekuTreeIntroCs, gJabuJabuIntroCs, gDcOpeningCs, gMinuetCs, gIceCavernSerenadeCs, gTowerBarrierCs, }; @@ -1702,6 +1705,9 @@ s32 CutsceneCmd_SetCamAt(PlayState* play, CutsceneContext* csCtx, u8* script, u8 void CutsceneCmd_Text(PlayState* play, CutsceneContext* csCtx, CsCmdText* cmd) { u8 dialogState; +#if PLATFORM_N64 + s32 pad; +#endif s16 endFrame; if ((csCtx->curFrame > cmd->startFrame) && (csCtx->curFrame <= cmd->endFrame)) { @@ -2416,6 +2422,14 @@ void Cutscene_HandleConditionalTriggers(PlayState* play) { } void Cutscene_SetScript(PlayState* play, void* script) { +#if PLATFORM_N64 + if ((B_80121AF0 != NULL) && (B_80121AF0->unk_78 != NULL)) { + if (B_80121AF0->unk_78(play, script, sCutscenesUnknownList)) { + return; + } + } +#endif + if (SEGMENT_NUMBER(script) != 0) { play->csCtx.script = SEGMENTED_TO_VIRTUAL(script); } else { diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 9dbc91a1bf..e0957a0164 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -399,76 +399,78 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* if (vtx == NULL) { PRINTF(T("z_eff_blure.c::SQ_NoInterpolate_disp() 頂点確保できず。\n", "z_eff_blure.c::SQ_NoInterpolate_disp() Vertices cannot be secured.\n")); - } else { - vtx[0].v = baseVtx; - vtx[1].v = baseVtx; - vtx[2].v = baseVtx; - vtx[3].v = baseVtx; - - ratio = (f32)elem->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index, ratio, &sp8C, &sp84, &sp7C, &sp78); - - sp60.x = sp84.x; - sp60.y = sp84.y; - sp60.z = sp84.z; - Math_Vec3f_Diff(&sp60, &sp6C, &sp54); - Math_Vec3f_Scale(&sp54, 10.0f); - vtx[0].v.ob[0] = sp54.x; - vtx[0].v.ob[1] = sp54.y; - vtx[0].v.ob[2] = sp54.z; - vtx[0].v.cn[0] = sp78.r; - vtx[0].v.cn[1] = sp78.g; - vtx[0].v.cn[2] = sp78.b; - vtx[0].v.cn[3] = sp78.a; - - if (1) {} // Necessary to match - - sp60.x = sp8C.x; - sp60.y = sp8C.y; - sp60.z = sp8C.z; - Math_Vec3f_Diff(&sp60, &sp6C, &sp54); - Math_Vec3f_Scale(&sp54, 10.0f); - vtx[1].v.ob[0] = sp54.x; - vtx[1].v.ob[1] = sp54.y; - vtx[1].v.ob[2] = sp54.z; - vtx[1].v.cn[0] = sp7C.r; - vtx[1].v.cn[1] = sp7C.g; - vtx[1].v.cn[2] = sp7C.b; - vtx[1].v.cn[3] = sp7C.a; - - ratio = (f32)(elem + 1)->timer / (f32)this->elemDuration; - EffectBlure_GetComputedValues(this, index + 1, ratio, &sp8C, &sp84, &sp7C, &sp78); - - sp60.x = sp8C.x; - sp60.y = sp8C.y; - sp60.z = sp8C.z; - Math_Vec3f_Diff(&sp60, &sp6C, &sp54); - Math_Vec3f_Scale(&sp54, 10.0f); - vtx[2].v.ob[0] = sp54.x; - vtx[2].v.ob[1] = sp54.y; - vtx[2].v.ob[2] = sp54.z; - vtx[2].v.cn[0] = sp7C.r; - vtx[2].v.cn[1] = sp7C.g; - vtx[2].v.cn[2] = sp7C.b; - vtx[2].v.cn[3] = sp7C.a; - - sp60.x = sp84.x; - sp60.y = sp84.y; - sp60.z = sp84.z; - Math_Vec3f_Diff(&sp60, &sp6C, &sp54); - Math_Vec3f_Scale(&sp54, 10.0f); - vtx[3].v.ob[0] = sp54.x; - vtx[3].v.ob[1] = sp54.y; - vtx[3].v.ob[2] = sp54.z; - vtx[3].v.cn[0] = sp78.r; - vtx[3].v.cn[1] = sp78.g; - vtx[3].v.cn[2] = sp78.b; - vtx[3].v.cn[3] = sp78.a; - - gSPVertex(POLY_XLU_DISP++, vtx, 4, 0); - gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 2, 3, 0); + goto end; } + vtx[0].v = baseVtx; + vtx[1].v = baseVtx; + vtx[2].v = baseVtx; + vtx[3].v = baseVtx; + + ratio = (f32)elem->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index, ratio, &sp8C, &sp84, &sp7C, &sp78); + + sp60.x = sp84.x; + sp60.y = sp84.y; + sp60.z = sp84.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[0].v.ob[0] = sp54.x; + vtx[0].v.ob[1] = sp54.y; + vtx[0].v.ob[2] = sp54.z; + vtx[0].v.cn[0] = sp78.r; + vtx[0].v.cn[1] = sp78.g; + vtx[0].v.cn[2] = sp78.b; + vtx[0].v.cn[3] = sp78.a; + + sp60.x = sp8C.x; + sp60.y = sp8C.y; + sp60.z = sp8C.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[1].v.ob[0] = sp54.x; + vtx[1].v.ob[1] = sp54.y; + vtx[1].v.ob[2] = sp54.z; + vtx[1].v.cn[0] = sp7C.r; + vtx[1].v.cn[1] = sp7C.g; + vtx[1].v.cn[2] = sp7C.b; + vtx[1].v.cn[3] = sp7C.a; + + ratio = (f32)(elem + 1)->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index + 1, ratio, &sp8C, &sp84, &sp7C, &sp78); + + sp60.x = sp8C.x; + sp60.y = sp8C.y; + sp60.z = sp8C.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[2].v.ob[0] = sp54.x; + vtx[2].v.ob[1] = sp54.y; + vtx[2].v.ob[2] = sp54.z; + vtx[2].v.cn[0] = sp7C.r; + vtx[2].v.cn[1] = sp7C.g; + vtx[2].v.cn[2] = sp7C.b; + vtx[2].v.cn[3] = sp7C.a; + + sp60.x = sp84.x; + sp60.y = sp84.y; + sp60.z = sp84.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[3].v.ob[0] = sp54.x; + vtx[3].v.ob[1] = sp54.y; + vtx[3].v.ob[2] = sp54.z; + vtx[3].v.cn[0] = sp78.r; + vtx[3].v.cn[1] = sp78.g; + vtx[3].v.cn[2] = sp78.b; + vtx[3].v.cn[3] = sp78.a; + + if (1) {} + + gSPVertex(POLY_XLU_DISP++, vtx, 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 2, 3, 0); + +end: CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 932); } @@ -759,9 +761,6 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, MtxF sp94; f32 scale; s32 i; - s32 j; - - j = 0; for (i = 0; i < this->numElements - 1; i++) { if (this->drawMode == 1) { @@ -771,9 +770,7 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, gDPPipeSync(POLY_XLU_DISP++); } - if (1) {} // Necessary to match - - gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0); + gSPVertex(POLY_XLU_DISP++, &vtx[4 * i], 4, 0); gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0); if (this->flags & 4) { @@ -806,13 +803,11 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, } gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0); + gSPVertex(POLY_XLU_DISP++, &vtx[4 * i], 4, 0); gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } } - - j += 4; } } diff --git a/src/code/z_eff_spark.c b/src/code/z_eff_spark.c index 41da753687..ba39da6b80 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.c @@ -222,41 +222,43 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { vertices[j].v.tc[0] = 0; vertices[j].v.tc[1] = 1024; vertices[j].v.flag = 0; + j++; - vertices[j + 1].v.ob[0] = 32; - vertices[j + 1].v.ob[1] = 32; - vertices[j + 1].v.ob[2] = 0; - vertices[j + 1].v.cn[0] = sp1CF; - vertices[j + 1].v.cn[1] = sp1CE; - vertices[j + 1].v.cn[2] = sp1CD; - vertices[j + 1].v.cn[3] = sp1CC; - vertices[j + 1].v.tc[0] = 1024; - vertices[j + 1].v.tc[1] = 0; - vertices[j + 1].v.flag = 0; + vertices[j].v.ob[0] = 32; + vertices[j].v.ob[1] = 32; + vertices[j].v.ob[2] = 0; + vertices[j].v.cn[0] = sp1CF; + vertices[j].v.cn[1] = sp1CE; + vertices[j].v.cn[2] = sp1CD; + vertices[j].v.cn[3] = sp1CC; + vertices[j].v.tc[0] = 1024; + vertices[j].v.tc[1] = 0; + vertices[j].v.flag = 0; + j++; - vertices[j + 2].v.ob[0] = -32; - vertices[j + 2].v.ob[1] = 32; - vertices[j + 2].v.ob[2] = 0; - vertices[j + 2].v.cn[0] = sp1CB; - vertices[j + 2].v.cn[1] = sp1CA; - vertices[j + 2].v.cn[2] = sp1C9; - vertices[j + 2].v.cn[3] = sp1C8; - vertices[j + 2].v.tc[0] = 0; - vertices[j + 2].v.tc[1] = 0; - vertices[j + 2].v.flag = 0; + vertices[j].v.ob[0] = -32; + vertices[j].v.ob[1] = 32; + vertices[j].v.ob[2] = 0; + vertices[j].v.cn[0] = sp1CB; + vertices[j].v.cn[1] = sp1CA; + vertices[j].v.cn[2] = sp1C9; + vertices[j].v.cn[3] = sp1C8; + vertices[j].v.tc[0] = 0; + vertices[j].v.tc[1] = 0; + vertices[j].v.flag = 0; + j++; - vertices[j + 3].v.ob[0] = 32; - vertices[j + 3].v.ob[1] = -32; - vertices[j + 3].v.ob[2] = 0; - vertices[j + 3].v.cn[0] = sp1C7; - vertices[j + 3].v.cn[1] = sp1C6; - vertices[j + 3].v.cn[2] = sp1C5; - vertices[j + 3].v.cn[3] = sp1C4; - vertices[j + 3].v.tc[0] = 1024; - vertices[j + 3].v.tc[1] = 1024; - vertices[j + 3].v.flag = 0; - - j += 4; + vertices[j].v.ob[0] = 32; + vertices[j].v.ob[1] = -32; + vertices[j].v.ob[2] = 0; + vertices[j].v.cn[0] = sp1C7; + vertices[j].v.cn[1] = sp1C6; + vertices[j].v.cn[2] = sp1C5; + vertices[j].v.cn[3] = sp1C4; + vertices[j].v.tc[0] = 1024; + vertices[j].v.tc[1] = 1024; + vertices[j].v.flag = 0; + j++; mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp12C); if (mtx == NULL) {