From ca99d9a5c1d99c6a3b211e5cf46ea67f38c616f1 Mon Sep 17 00:00:00 2001 From: escape209 Date: Fri, 21 Mar 2025 08:50:54 +0000 Subject: [PATCH 1/6] Match parse_tag_var --- src/SB/Game/zVar.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/SB/Game/zVar.cpp b/src/SB/Game/zVar.cpp index dc5e58b12..68a7a5619 100644 --- a/src/SB/Game/zVar.cpp +++ b/src/SB/Game/zVar.cpp @@ -495,30 +495,18 @@ namespace return NULL; } - // Not close, don't know enough about the data structures to know if things are - // looking correct or not. void parse_tag_var(xtextbox::jot& r31, const xtextbox& r4, const xtextbox& r5, const xtextbox::split_tag& r6) { - if (r6.action.size != 1) + if ((r6.action.size != 1) || (r6.action.text[0] != 0x3A) || (r6.value.size <= 1)) return; - if (r6.action.text[0] != 0x3A) - return; - - if (r6.value.size > 1) + r31.context = var_text(r6.value); + r31.context_size = 0; + if (r31.context != NULL) { - r31.context = var_text(r6.value); - r31.context_size = 0; - if (r31.context) - { - r31.context_size = 0xFC00; - // Maybe not the correct flags, something is up with the struct - r31.flag.dynamic = 1; - // No clue what this line is: - // r31.flag.upper. something = something?? - r31.flag.insert = 1; - } + r31.context_size = 0xFC00; + r31.flag.insert = r31.flag.dynamic = 1; } } From 5e76545e5b6b59c4772b8d4b035295bb23714511 Mon Sep 17 00:00:00 2001 From: escape209 Date: Fri, 21 Mar 2025 09:22:57 +0000 Subject: [PATCH 2/6] Match zNPCCommon::SndIsAnyPlaying --- src/SB/Game/zNPCTypeCommon.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/SB/Game/zNPCTypeCommon.cpp b/src/SB/Game/zNPCTypeCommon.cpp index d40f656ed..c11fe9caa 100644 --- a/src/SB/Game/zNPCTypeCommon.cpp +++ b/src/SB/Game/zNPCTypeCommon.cpp @@ -256,15 +256,13 @@ S32 zNPCCommon::SomethingWonderful() return flg_wonder; } -/* -// Off by one instruction, I don't understand what the original code is doing S32 zNPCCommon::SndIsAnyPlaying() { S32 iVar1 = 0; for (S32 i = 0; i < 4; i++) { - iVar1 = xSndIsPlaying(0, this->id); + iVar1 = xSndIsPlaying(0, (U32)this + i); if (iVar1) { break; @@ -273,7 +271,6 @@ S32 zNPCCommon::SndIsAnyPlaying() return iVar1; } -*/ U32 zNPCCommon::LassoInit() { From c71c5bb09531e4e4b55f73b06aa70db84d283ec0 Mon Sep 17 00:00:00 2001 From: escape209 Date: Fri, 21 Mar 2025 10:52:48 +0000 Subject: [PATCH 3/6] Match xNPCBasic::Reset --- src/SB/Core/x/xNPCBasic.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/SB/Core/x/xNPCBasic.cpp b/src/SB/Core/x/xNPCBasic.cpp index 8a49a1503..3b6cfbbfb 100644 --- a/src/SB/Core/x/xNPCBasic.cpp +++ b/src/SB/Core/x/xNPCBasic.cpp @@ -103,7 +103,6 @@ void xNPCBasic::Init(xEntAsset* asset) baseFlags &= 0xffef; } -// Register assignment in the floating point instructions is slightly wrong. void xNPCBasic::Reset() { xEntReset(this); @@ -111,7 +110,7 @@ void xNPCBasic::Reset() if (!(U32(flags1.flg_basenpc) & 0x2)) { xVec3Copy(&frame->drot.axis, &g_Y3); - frame->drot.angle = xNPCBasic_float_0; + frame->drot.angle = 0.0f; xVec3Copy(&frame->rot.axis, &g_Y3); frame->rot.angle = asset->ang.x; } @@ -119,16 +118,8 @@ void xNPCBasic::Reset() flags1.flg_basenpc |= 4; colFreq = -1; - F32 f1 = xurand(); - F32 f0 = xNPCBasic_float_onehalf; - F32 f2 = xNPCBasic_float_onequarter; - f1 -= f0; - f0 = xNPCBasic_float_15; - f1 = f2 * f1; - f0 = f0 * f1 + f0; - colFreqReset = (S32)f0; + colFreqReset = (15.0f * (0.25f * (xurand() - 0.5f))) + 15.0f; RestoreColFlags(); - return; } void NPC_alwaysUseSphere(xEnt* ent, xVec3* value) From e2da3ce3eaac46c2c4d8803a2a8ae54949293107 Mon Sep 17 00:00:00 2001 From: escape209 Date: Fri, 21 Mar 2025 14:39:34 +0000 Subject: [PATCH 4/6] Couple more --- src/SB/Core/gc/iTRC.cpp | 52 +++++++++++++++++++-------------------- src/SB/Core/gc/iTRC.h | 17 ++++++++++--- src/SB/Core/x/xString.cpp | 22 +++++------------ 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/SB/Core/gc/iTRC.cpp b/src/SB/Core/gc/iTRC.cpp index 3e54cbee8..881a8957a 100644 --- a/src/SB/Core/gc/iTRC.cpp +++ b/src/SB/Core/gc/iTRC.cpp @@ -73,71 +73,69 @@ void ROMFont::DrawTextBox(int, int, int, int, char*) } - - -int ResetButton::EnableReset() -{ - return ResetButton::mResetEnabled = 1; +void ResetButton::EnableReset() +{ + ResetButton::mResetEnabled = 1; } -int ResetButton::DisableReset() -{ - return ResetButton::mResetEnabled = 0; +void ResetButton::DisableReset() +{ + ResetButton::mResetEnabled = 0; } void ResetButton::SetSndKillFunction(void (*Func)()) { - + ResetButton::mSndKill = Func; } void ResetButton::CheckResetButton() { - + } bool iTRCDisk::Init(void) { - bool RFInit = ROMFont::Init(); - return RFInit; + return ROMFont::Init(); } -void iTRCDisk::SetErrorMessage(const char*) +void iTRCDisk::SetErrorMessage(const char* message) { - + strcpy(mMessage, message); } void iTRCDisk::ResetMessage() { + memset(mMessage, 0, 0x100); } -void iTRCDisk::SetPadStopRumblingFunction(void (*)(void)) +void iTRCDisk::SetPadStopRumblingFunction(void (*Func)()) { - + mPadStopRumbling = Func; } -void iTRCDisk::SetSndSuspendFunction(void (*)(void)) +void iTRCDisk::SetSndSuspendFunction(void (*Func)()) { - + mSndSuspend = Func; } -void iTRCDisk::SetSndResumeFunction(void (*)(void)) +void iTRCDisk::SetSndResumeFunction(void (*Func)()) { - + mSndResume = Func; } -void iTRCDisk::SetSndKillFunction(void (*)(void)) +void iTRCDisk::SetSndKillFunction(void (*Func)()) { - + mSndKill = Func; } -void iTRCDisk::SetMovieSuspendFunction(void (*)(void)) +void iTRCDisk::SetMovieSuspendFunction(void (*Func)()) { - + mMovieSuspendFunction = Func; } -void iTRCDisk::SetMovieResumeFunction(void (*)(void)) +void iTRCDisk::SetMovieResumeFunction(void (*Func)()) { - + mMovieResumeFunction = Func; } bool iTRCDisk::IsDiskIDed() @@ -147,7 +145,7 @@ bool iTRCDisk::IsDiskIDed() void iTRCDisk::DisplayErrorMessage() { - + } void iTRCDisk::SetDVDState() diff --git a/src/SB/Core/gc/iTRC.h b/src/SB/Core/gc/iTRC.h index 7ce5f31cf..815f3c398 100644 --- a/src/SB/Core/gc/iTRC.h +++ b/src/SB/Core/gc/iTRC.h @@ -28,6 +28,14 @@ namespace ROMFont // Yes, this is a namespace, not a class. namespace iTRCDisk { + char mMessage[]; + void (*mPadStopRumbling)(); + void (*mSndSuspend)(); + void (*mSndResume)(); + void (*mSndKill)(); + void (*mMovieSuspendFunction)(); + void (*mMovieResumeFunction)(); + void SetPadStopRumblingFunction(void (*)(void)); void SetSndSuspendFunction(void (*)(void)); void SetSndResumeFunction(void (*)(void)); @@ -41,14 +49,15 @@ namespace iTRCDisk void SetDVDState(); void SetErrorMessage(const char*); bool IsDiskIDed(); - char mMessage(); } // namespace iTRCDisk namespace ResetButton { - int EnableReset(); - int mResetEnabled; - int DisableReset(); + bool mResetEnabled; + void (*mSndKill)(); + + void EnableReset(); + void DisableReset(); void SetSndKillFunction(void (*func)()); void CheckResetButton(); diff --git a/src/SB/Core/x/xString.cpp b/src/SB/Core/x/xString.cpp index a66aa69e3..9a0bebe7d 100644 --- a/src/SB/Core/x/xString.cpp +++ b/src/SB/Core/x/xString.cpp @@ -1,4 +1,5 @@ #include "xString.h" +#include "xMath.h" #include @@ -76,24 +77,13 @@ U32 tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi(U32 param_1) } } -/* -// Non-matching S32 icompare(const substr& s1, const substr& s2) { - S32 result; - U32 len; - - len = s2.size; - - if (s1.size < s2.size) - { - len = s1.size; - } - - result = imemcmp(s1.text, s2.text, len); - - if (result == 0) + U32 len = MIN(s1.size, s2.size); + S32 result = imemcmp(s1.text, s2.text, len); + switch (result) { + case 0: if (s1.size == s2.size) { result = 0; @@ -106,7 +96,7 @@ S32 icompare(const substr& s1, const substr& s2) result = -1; } } + break; } return result; } -*/ From 974f37169b65c98fbcb3d04a4ec3a69adc5a7ab1 Mon Sep 17 00:00:00 2001 From: escape209 Date: Fri, 21 Mar 2025 19:19:21 +0000 Subject: [PATCH 5/6] Match xEntMotionInit --- src/SB/Core/x/xEntMotion.cpp | 94 ++++++++++++++++++++++++++++++++++++ src/SB/Core/x/xEntMotion.h | 1 + src/SB/Game/zNPCSpawner.cpp | 2 +- 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/src/SB/Core/x/xEntMotion.cpp b/src/SB/Core/x/xEntMotion.cpp index 6f0205231..fc51d920c 100644 --- a/src/SB/Core/x/xEntMotion.cpp +++ b/src/SB/Core/x/xEntMotion.cpp @@ -1,4 +1,5 @@ #include "xEntMotion.h" +#include "xMath.h" #include @@ -12,3 +13,96 @@ void xMat3x3RMulVec(xVec3* o, const xMat3x3* m, const xVec3* v) o->y = y; o->z = z; } + +void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c) +{ + a->asset = c; + a->type = c->type; + a->flags = c->flags; + + if (a->type == 0) // ER + { + xVec3Copy(&a->er.a, &c->er.ret_pos); + xVec3Add(&a->er.b, &c->er.ret_pos, &c->er.ext_dpos); + + a->er.et = c->er.ext_tm; + a->er.wet = c->er.ext_wait_tm; + a->er.rt = c->er.ret_tm; + a->er.wrt = c->er.ret_wait_tm; + + if (a->er.p <= 0) + { + a->er.p = 10.0f; + } + + a->er.brt = a->er.et + a->er.wet; + a->er.ert = a->er.brt + a->er.rt; + a->er.p = a->er.ert + a->er.wrt; + } + else if (a->type == 1) // Orbit + { + xVec3Copy((xVec3*)(&a->er.b), &c->er.ret_pos); + + a->orb.a = c->orb.w; + a->orb.b = c->orb.h; + + if (c->orb.period <= 0.0f) + { + c->orb.period = 10.0f; + } + + a->orb.p = c->orb.period; + a->orb.w = (2 * PI) / c->orb.period; + } + else if (a->type == 3) // MP + { + // literally nothing + } + else if (a->type == 5) // Pen + { + if (c->pen.period <= 1e-5f) + { + c->pen.period = 0; + } + + a->pen.w = (2 * PI) / c->pen.period; + } + else if (a->type == 4) // Mech + { + if (c->mp.speed < 1e-5f) + { + c->mp.speed = 0; + } + + if (c->mech.sld_acc_tm + c->mech.sld_dec_tm > c->mech.sld_tm) + { + c->mech.sld_dec_tm = + c->mech.sld_acc_tm = + c->mech.sld_tm * 0.5f; + } + + if (c->mech.rot_tm < 3.0f) + { + c->mech.rot_tm = 1.0f; + } + + if (c->mech.type == 2) + { + if ( c->mech.rot_tm != c->mech.sld_tm ) + { + c->mech.rot_tm = c->mech.sld_tm; + } + } + if (c->mech.rot_acc_tm + c->mech.rot_dec_tm > c->mech.rot_tm) + { + c->mech.rot_dec_tm = + c->mech.rot_acc_tm = + c->mech.rot_tm * 0.5f; + } + } + + a->owner = b; + a->target = NULL; + + xEntMotionDebugAdd(a); +} \ No newline at end of file diff --git a/src/SB/Core/x/xEntMotion.h b/src/SB/Core/x/xEntMotion.h index d99864929..e830f9aa8 100644 --- a/src/SB/Core/x/xEntMotion.h +++ b/src/SB/Core/x/xEntMotion.h @@ -174,6 +174,7 @@ void xEntMotionReset(xEntMotion* motion, xScene* sc); void xEntMotionMove(xEntMotion* motion, xScene* sc, F32 dt, xEntFrame* frame); void xEntMotionTranslate(xEntMotion* motion, const xVec3* dpos, xMat4x3* dmat); void xEntMotionDebugInit(U16 num_xems); +void xEntMotionDebugAdd(xEntMotion*); void xEntMotionDebugExit(); void xEntMotionStop(xEntMotion* motion); void xEntMotionRun(xEntMotion* motion); diff --git a/src/SB/Game/zNPCSpawner.cpp b/src/SB/Game/zNPCSpawner.cpp index ab71b63ac..5a89ef58d 100644 --- a/src/SB/Game/zNPCSpawner.cpp +++ b/src/SB/Game/zNPCSpawner.cpp @@ -175,7 +175,7 @@ st_XORDEREDARRAY* zNPCSpawner::FillPending() { ClearPending(); ReFillPending(); - return &this->actvlist; + return (st_XORDEREDARRAY*)this->pendlist.cnt; } st_XORDEREDARRAY* zNPCSpawner::ReFillPending() From d142619798551525846cad3ab21710302dc8e788 Mon Sep 17 00:00:00 2001 From: escape209 Date: Fri, 21 Mar 2025 23:35:56 +0000 Subject: [PATCH 6/6] Match xEntMechForward --- src/SB/Core/x/xEntMotion.cpp | 64 ++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/src/SB/Core/x/xEntMotion.cpp b/src/SB/Core/x/xEntMotion.cpp index fc51d920c..bee2977d2 100644 --- a/src/SB/Core/x/xEntMotion.cpp +++ b/src/SB/Core/x/xEntMotion.cpp @@ -14,13 +14,24 @@ void xMat3x3RMulVec(xVec3* o, const xMat3x3* m, const xVec3* v) o->z = z; } +// Artificial +enum en_MOTIONTYPE +{ + MOTION_TYPE_EXRT, + MOTION_TYPE_ORBT, + MOTION_TYPE_SPLN, + MOTION_TYPE_MVPT, + MOTION_TYPE_MECH, + MOTION_TYPE_PEND +}; + void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c) { a->asset = c; a->type = c->type; a->flags = c->flags; - if (a->type == 0) // ER + if (a->type == MOTION_TYPE_EXRT) { xVec3Copy(&a->er.a, &c->er.ret_pos); xVec3Add(&a->er.b, &c->er.ret_pos, &c->er.ext_dpos); @@ -39,7 +50,7 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c) a->er.ert = a->er.brt + a->er.rt; a->er.p = a->er.ert + a->er.wrt; } - else if (a->type == 1) // Orbit + else if (a->type == MOTION_TYPE_ORBT) { xVec3Copy((xVec3*)(&a->er.b), &c->er.ret_pos); @@ -54,11 +65,11 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c) a->orb.p = c->orb.period; a->orb.w = (2 * PI) / c->orb.period; } - else if (a->type == 3) // MP + else if (a->type == MOTION_TYPE_MVPT) { // literally nothing } - else if (a->type == 5) // Pen + else if (a->type == MOTION_TYPE_PEND) { if (c->pen.period <= 1e-5f) { @@ -67,7 +78,7 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c) a->pen.w = (2 * PI) / c->pen.period; } - else if (a->type == 4) // Mech + else if (a->type == MOTION_TYPE_MECH) { if (c->mp.speed < 1e-5f) { @@ -105,4 +116,45 @@ void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c) a->target = NULL; xEntMotionDebugAdd(a); -} \ No newline at end of file +} + +void xEntMechForward(xEntMotion* motion) +{ + xEntMotionMechData* mech = &(motion->asset->mech); + xEntMotionAsset* mkasst = motion->asset; + + xEntMotionRun(motion); + + if ((motion->mech.state != 0) && (motion->mech.state != 1) && (motion->mech.state != 2)) + { + if (motion->mech.state == 3) + { + motion->mech.ss = -motion->mech.ss; + motion->mech.sr = -motion->mech.sr; + motion->tmr = mkasst->mech.sld_tm - motion->tmr; + motion->mech.state = 0; + } + else if (motion->mech.state == 4) + { + motion->mech.ss = -motion->mech.ss; + motion->mech.sr = -motion->mech.sr; + motion->tmr = mkasst->mech.rot_tm - motion->tmr; + motion->mech.state = 1; + } + else if ((motion->mech.state != 5) && (motion->mech.state != 6) && (motion->mech.state == 7)) + { + motion->mech.ss = -motion->mech.ss; + motion->mech.sr = -motion->mech.sr; + motion->tmr = 0.0f; + + if ((mech->type == 0) || (mech->type == 2) || (mech->type == 4)) + { + motion->mech.state = 0; + } + else + { + motion->mech.state = 1; + } + } + } +}