From 17087cb94e176341885e0d1deeedf74cf6997ffb Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Fri, 25 Apr 2025 22:54:43 -0400 Subject: [PATCH] Matched functions that were ported. Added all zParticleSystemWaterfall --- src/SB/Core/gc/iARAMTmp.cpp | 26 ++ src/SB/Core/gc/iARAMTmp.h | 13 + src/SB/Core/gc/iCutscene.h | 1 + src/SB/Core/gc/iScrFX.cpp | 45 ++ src/SB/Core/gc/iScrFX.h | 46 +- src/SB/Core/gc/iTRC.cpp | 343 +++++--------- src/SB/Core/gc/iTRC.h | 106 +++-- src/SB/Core/gc/iWad.cpp | 112 +++-- src/SB/Core/gc/iWad.h | 2 + src/SB/Core/x/xSnd.h | 1 + src/SB/Game/zParticleSystemWaterfall.cpp | 220 +++++---- src/SB/Game/zParticleSystemWaterfall.h | 550 +++++++++++------------ 12 files changed, 719 insertions(+), 746 deletions(-) create mode 100644 src/SB/Core/gc/iARAMTmp.h diff --git a/src/SB/Core/gc/iARAMTmp.cpp b/src/SB/Core/gc/iARAMTmp.cpp index e69de29..83ee103 100644 --- a/src/SB/Core/gc/iARAMTmp.cpp +++ b/src/SB/Core/gc/iARAMTmp.cpp @@ -0,0 +1,26 @@ +#include "iARAMTmp.h" + +bool iARAMTmpEnd(bool) +{ +} + +void* iARAMTmpInARAMTemp(void*) +{ +} + +void* iARAMTmpFree(void*) +{ +} + +U32 iARAMTmpMalloc(unsigned int) +{ + return 0; +} + +U32 iARAMTmpBegin(unsigned int, unsigned int) +{ +} + +U64 transferDoneCB(unsigned long) +{ +} diff --git a/src/SB/Core/gc/iARAMTmp.h b/src/SB/Core/gc/iARAMTmp.h new file mode 100644 index 0000000..41fe2bd --- /dev/null +++ b/src/SB/Core/gc/iARAMTmp.h @@ -0,0 +1,13 @@ +#ifndef IARAMTMP_H +#define IARAMTMP_H + +#include + +bool iARAMTmpEnd(bool); +void* iARAMTmpInARAMTemp(void*); +void* iARAMTmpFree(void*); +U32 iARAMTmpMalloc(unsigned int); +U32 iARAMTmpBegin(unsigned int, unsigned int); +U64 transferDoneCB(unsigned long); + +#endif diff --git a/src/SB/Core/gc/iCutscene.h b/src/SB/Core/gc/iCutscene.h index 8872dc6..2d67250 100644 --- a/src/SB/Core/gc/iCutscene.h +++ b/src/SB/Core/gc/iCutscene.h @@ -10,6 +10,7 @@ U32 iCSFileOpen(xCutscene* csn); void iCSFileAsyncRead(xCutscene* csn, void* dest, U32 size); void iCSFileAsyncSkip(xCutscene* csn, U32 amount); void iCSFileClose(xCutscene* csn); +bool DVDCancelAllAsync(); S32 iCSLoadStep(xCutscene* csn); #endif diff --git a/src/SB/Core/gc/iScrFX.cpp b/src/SB/Core/gc/iScrFX.cpp index e69de29..7ac2e1d 100644 --- a/src/SB/Core/gc/iScrFX.cpp +++ b/src/SB/Core/gc/iScrFX.cpp @@ -0,0 +1,45 @@ +#include "iScrFX.h" + +extern RwRaster* g_rast_gctapdance; +extern S32 g_alreadyTriedAlloc; +extern _iMotionBlurData sMBD; +extern U32 sMotionBlurEnabled; + +void iScrFxLensFlare_Reset() +{ +} + +S32 iScrFxCameraDestroyed(RwCamera* pCamera) +{ + if (sMBD.motionBlurFrontBuffer != NULL) + { + RwRasterDestroy(sMBD.motionBlurFrontBuffer); + sMBD.motionBlurFrontBuffer = NULL; + return 1; + } + return 0; +} + +void iScrFxCameraEndScene(RwCamera* pCamera) +{ +} + +void iScrFxCameraCreated(RwCamera* pCamera) +{ + sMBD.motionBlurAlpha = 0x90; + sMBD.motionBlurFrontBuffer = NULL; + sMBD.index[0] = 0; + sMBD.index[1] = 1; + sMBD.index[2] = 2; + sMBD.index[3] = 0; + sMBD.index[4] = 2; + sMBD.index[5] = 3; +} + +void iScrFxBegin() +{ +} + +void iScrFxInit() +{ +} diff --git a/src/SB/Core/gc/iScrFX.h b/src/SB/Core/gc/iScrFX.h index b132fec..0d6ef3a 100644 --- a/src/SB/Core/gc/iScrFX.h +++ b/src/SB/Core/gc/iScrFX.h @@ -5,35 +5,37 @@ #include #include -struct _iMotionBlurData { - S32 motionBlurAlpha; - RwRaster *motionBlurFrontBuffer; - // RwSky2DVertex vertex[4]; This doesn't seem right... Due to how the data is - // used, it only makes sense for this to be 96 only. - U8 vertex[96]; - U16 index[6]; - U32 w; - U32 h; - U8 unk[10]; // There is something here to make this structure 0x88. +// PORTED DIRECTLY FROM BFBB + +struct _iMotionBlurData +{ + S32 motionBlurAlpha; + RwRaster* motionBlurFrontBuffer; + // RwSky2DVertex vertex[4]; This doesn't seem right... Due to how the data is + // used, it only makes sense for this to be 96 only. + U8 vertex[96]; + U16 index[6]; + U32 w; + U32 h; + U8 unk[10]; // There is something here to make this structure 0x88. }; void iScrFxInit(); void iScrFxBegin(); void iScrFxEnd(); -void iScrFxDrawBox(F32 x1, F32 y1, F32 x2, F32 y2, U8 red, U8 green, U8 blue, - U8 alpha); +void iScrFxDrawBox(F32 x1, F32 y1, F32 x2, F32 y2, U8 red, U8 green, U8 blue, U8 alpha); void iCameraMotionBlurActivate(U32 activate); void iCameraSetBlurriness(F32 amount); -void iScrFxCameraCreated(RwCamera *pCamera); -void iScrFxCameraEndScene(RwCamera *pCamera); -void iScrFxPostCameraEnd(RwCamera *pCamera); -void iCameraOverlayRender(RwCamera *pcamera, RwRaster *ras, RwRGBA col); -RwRaster *FBMBlur_DebugIntervention(RwCamera *camera, RwRaster *ras); -S32 iScrFxMotionBlurOpen(RwCamera *camera); -S32 iScrFxCameraDestroyed(RwCamera *pCamera); -void iScrFxMotionBlurRender(RwCamera *camera, U32 col); -void GCMB_MakeFrameBufferCopy(const RwCamera *camera); +void iScrFxCameraCreated(RwCamera* pCamera); +void iScrFxCameraEndScene(RwCamera* pCamera); +void iScrFxPostCameraEnd(RwCamera* pCamera); +void iCameraOverlayRender(RwCamera* pcamera, RwRaster* ras, RwRGBA col); +RwRaster* FBMBlur_DebugIntervention(RwCamera* camera, RwRaster* ras); +S32 iScrFxMotionBlurOpen(RwCamera* camera); +S32 iScrFxCameraDestroyed(RwCamera* pCamera); +void iScrFxMotionBlurRender(RwCamera* camera, U32 col); +void GCMB_MakeFrameBufferCopy(const RwCamera* camera); void GCMB_KillFrameBufferCopy(); -void GCMB_SiphonFrameBuffer(const RwCamera *camera); +void GCMB_SiphonFrameBuffer(const RwCamera* camera); #endif diff --git a/src/SB/Core/gc/iTRC.cpp b/src/SB/Core/gc/iTRC.cpp index 978778d..be1c0b5 100644 --- a/src/SB/Core/gc/iTRC.cpp +++ b/src/SB/Core/gc/iTRC.cpp @@ -18,279 +18,152 @@ extern void GXPosition3s16(S32, S32, S32); extern void GXTexCoord2s16(S32, S32); -namespace ROMFont { -OSFontHeader *mFontData; -void *mXFBs[2]; -void *mCurrentFrameBuffer; -GXRenderModeObj *mRenderMode; -bool mFirstFrame = true; +namespace ROMFont +{ + OSFontHeader* mFontData; + void* mXFBs[2]; + void* mCurrentFrameBuffer; + GXRenderModeObj* mRenderMode; + bool mFirstFrame = true; } // namespace ROMFont -namespace ResetButton { -bool mResetEnabled = 1; -BOOL mWasResetButtonPressed; -void (*mSndKill)(); +namespace ResetButton +{ + bool mResetEnabled = 1; + BOOL mWasResetButtonPressed; + bool mDiscIded; // Return type may be wrong + void (*mSndKill)(); + void (*mMovieKillFunction)(); // Return type may be wrong } // namespace ResetButton -namespace iTRCDisk { -char mMessage[256]; +namespace iTRCDisk +{ + char mMessage[256]; -void (*mSndSuspend)(); -void (*mSndResume)(); -void (*mPadStopRumbling)(); -void (*mSndKill)(); -void (*mMovieSuspendFunction)(); -void (*mMovieResumeFunction)(); -} // namespace iTRCDisk + void (*mSndSuspend)(); + void (*mSndResume)(); + void (*mAsyncLoadSuspend)(); + void (*mAsyncLoadResume)(); + void (*mPadStopRumbling)(); + void (*mMovieSuspendFunction)(); + void (*mMovieResumeFunction)(); + void (*mMovieResetCallBack)(); + bool mInFModLockingCode; -BOOL ROMFont::Init() { - if (OSGetFontEncode() == 1) { - ROMFont::mFontData = - (OSFontHeader *)OSAllocFromHeap(__OSCurrHeap, 0xF00 + 0x12); - } else { - ROMFont::mFontData = - (OSFontHeader *)OSAllocFromHeap(__OSCurrHeap, 0x2 + 0x120); - } +} // namespace iTRCDisk - return OSInitFont(ROMFont::mFontData); +void iTRCDisk::SetDVDState() +{ } -void ROMFont::InitGX() { - U16 scaledHeight; - GXSetViewport(0.0f, 0.0f, mRenderMode->fbWidth, mRenderMode->efbHeight, 0.0f, - 1.0f); - GXSetScissor(0, 0, mRenderMode->fbWidth, mRenderMode->efbHeight); - - scaledHeight = GXSetDispCopyYScale( - GXGetYScaleFactor(mRenderMode->efbHeight, mRenderMode->xfbHeight)); - GXSetDispCopySrc(0, 0, mRenderMode->fbWidth, mRenderMode->efbHeight); - GXSetDispCopyDst(mRenderMode->fbWidth, scaledHeight); - - GXSetCopyFilter(mRenderMode->aa, mRenderMode->sample_pattern, TRUE, - mRenderMode->vfilter); - - if (mRenderMode->aa != FALSE) { - GXSetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); - } else { - GXSetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); - } - - GXCopyDisp(mCurrentFrameBuffer, 1); - GXSetDispCopyGamma(GX_GM_1_0); - GXSetCullMode(GX_CULL_NONE); +void iTRCDisk::DisplayErrorMessage() +{ } -void ROMFont::InitVI() { - VISetNextFrameBuffer(mXFBs[0]); - mCurrentFrameBuffer = mXFBs[1]; - VIFlush(); - VIWaitForRetrace(); - if (mRenderMode->viTVmode & 1) { - VIWaitForRetrace(); - } +bool iTRCDisk::SetInFModLockingCode(bool Func) +{ + return mInFModLockingCode = Func; } -void ROMFont::RenderBegin() { - if (mRenderMode->field_rendering != FALSE) { - GXSetViewportJitter(0.0f, 0.0f, mRenderMode->fbWidth, - mRenderMode->efbHeight, 0.0f, 1.0f, VIGetNextField()); - } else { - GXSetViewport(0.0f, 0.0f, mRenderMode->fbWidth, mRenderMode->efbHeight, - 0.0f, 1.0f); - } - - GXInvalidateVtxCache(); - GXInvalidateTexAll(); +bool iTRCDisk::IsDiskIDed() +{ + return DVDCheckDisk(); } -void ROMFont::RenderEnd() { - GXSetZMode(TRUE, GX_LEQUAL, TRUE); - GXSetColorUpdate(TRUE); - GXCopyDisp(mCurrentFrameBuffer, TRUE); - GXDrawDone(); - SwapBuffers(); +void iTRCDisk::SetMovieResetCallBack(void (*Func)()) +{ + mMovieResetCallBack = Func; } -void ROMFont::SwapBuffers() { - void *buffer; - - VISetNextFrameBuffer(mCurrentFrameBuffer); - - if (mFirstFrame != false) { - VISetBlack(TRUE); - mFirstFrame = false; - } else { - VISetBlack(FALSE); - } - - VIFlush(); - VIWaitForRetrace(); - - mCurrentFrameBuffer = mCurrentFrameBuffer == mXFBs[0] ? mXFBs[1] : mXFBs[0]; +void iTRCDisk::SetMovieResumeFunction(void (*Func)()) +{ + mMovieResumeFunction = Func; } -// FIXME: Revisit after GXTexCoord2s16 and GXPosition3s16 have been decompiled, -// looks like they were inlined -void ROMFont::DrawCell(S32 param_1, S32 param_2, S32 param_3, S32 param_4) { - U16 uVar1; - U16 uVar2; - S16 sVar3; - S32 iVar4; - S32 iVar5; - S32 iVar6; - - uVar1 = mFontData->cellWidth; - uVar2 = mFontData->cellHeight; - iVar5 = (int)(short)(param_1 + uVar1); - iVar4 = (int)(short)(param_2 + uVar2); - - GXBegin(GX_LINESTRIP, GX_VTXFMT0, 4); - - GXPosition3s16((int)param_1, (int)param_2, 0); - GXTexCoord2s16((int)param_3, param_4); - - GXPosition3s16(iVar5, (int)param_2, 0); - - iVar6 = (int)(short)(param_3 + uVar1); - - GXTexCoord2s16(iVar6, param_4); - GXPosition3s16(iVar5, iVar4, 0); - - sVar3 = param_4 + uVar2; - - GXTexCoord2s16(iVar6, sVar3); - GXPosition3s16((int)param_1, iVar4, 0); - GXTexCoord2s16((int)param_3, sVar3); - - GXEnd(); +void iTRCDisk::SetMovieSuspendFunction(void (*Func)()) +{ + mMovieSuspendFunction = Func; } -void ROMFont::LoadSheet(void *image_ptr) { - GXAnisotropy max_aniso; - GXTexObj GStack_68; - F32 afStack_48[3][4]; - U32 uStack_14; - U32 uStack_c; - - max_aniso = GX_ANISO_1; - GXInitTexObj(&GStack_68, image_ptr, mFontData->sheetWidth, - mFontData->sheetHeight, (GXTexFmt)mFontData->sheetFormat, - GX_CLAMP, GX_CLAMP, NULL); - GXInitTexObjLOD(&GStack_68, GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, FALSE, - FALSE, max_aniso); - GXLoadTexObj(&GStack_68, GX_TEXMAP0); - uStack_14 = mFontData->sheetWidth; - uStack_c = mFontData->sheetHeight; - PSMTXScale(afStack_48, 1.0f / uStack_14, 1.0f / uStack_c, 1.0f); - GXLoadTexMtxImm(afStack_48, FONT_MATRIX_ID, GX_MTX2x4); - GXSetNumTexGens(1); - GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, FONT_MATRIX_ID); +void iTRCDisk::SetAsyncLoadResumeFunction(void (*Func)()) +{ + mAsyncLoadResume = Func; } -S32 ROMFont::DrawString(S32 param_1, S32 param_2, char *string) { - S32 iVar1; - S32 x; - S32 y; - S32 width; - void *image[3]; - - iVar1 = 0; - while (*string != '\0') { - string = - OSGetFontTexture(string, image, (s32 *)&x, (s32 *)&y, (s32 *)&width); - ROMFont::LoadSheet(image[0]); - ROMFont::DrawCell(param_1 + iVar1, param_2, x, y); - iVar1 = iVar1 + width; - } - return iVar1; +void iTRCDisk::SetAsyncLoadSuspendFunction(void (*Func)()) +{ + mAsyncLoadSuspend = Func; } -S32 ROMFont::GetWidth(char *string) { - S32 iVar1; - void *image[1]; - S32 x; - S32 y; - S32 width; - - iVar1 = 0; - while (*string != '\0') { - string = - OSGetFontTexture(string, image, (s32 *)&x, (s32 *)&y, (s32 *)&width); - iVar1 = iVar1 + width; - } - return iVar1; +void iTRCDisk::SetSndResumeFunction(void (*Func)()) +{ + mSndResume = Func; } -void ROMFont::DrawTextBox(S32 param_1, S32 param_2, S32 param_3, S32 param_4, - char *str) { - char *tokenizedString; - S32 baseWidth; - S32 tokWidth; - S32 iVar4; - S32 iVar5; - char acStack_128[TEXTBOX_MAX_TEXT_LENGTH]; - - if (str != NULL) { - RenderBegin(); - strcpy(acStack_128, str); - tokenizedString = strtok(acStack_128, " "); - baseWidth = GetWidth(" "); - iVar4 = param_2 + param_4; - iVar5 = param_1; - while ((tokenizedString != NULL && (param_2 < iVar4))) { - tokWidth = GetWidth(tokenizedString); - if (param_1 + param_3 < iVar5 + tokWidth) { - param_2 = param_2 + mFontData->cellHeight; - iVar5 = param_1; - } - DrawString(iVar5, param_2, tokenizedString); - tokenizedString = strtok(NULL, " "); - iVar5 = tokWidth + baseWidth + iVar5; - } - RenderEnd(); - } +void iTRCDisk::SetSndSuspendFunction(void (*Func)()) +{ + mSndSuspend = Func; } -void ResetButton::EnableReset() { ResetButton::mResetEnabled = 1; } - -void ResetButton::DisableReset() { ResetButton::mResetEnabled = 0; } - -void ResetButton::SetSndKillFunction(void (*Func)()) { - ResetButton::mSndKill = Func; +void iTRCDisk::SetPadStopRumblingFunction(void (*Func)()) +{ + mPadStopRumbling = Func; } -void ResetButton::CheckResetButton() {} - -bool iTRCDisk::Init(void) { return ROMFont::Init(); } - -void iTRCDisk::SetErrorMessage(const char *message) { - strcpy(mMessage, message); +bool iTRCDisk::Init(void) +{ + return ROMFont::Init(); } -void iTRCDisk::ResetMessage() { memset(mMessage, 0, 0x100); } - -void iTRCDisk::SetPadStopRumblingFunction(void (*Func)()) { - mPadStopRumbling = Func; +void ResetButton::SetMovieKillFunciton(void (*Func)()) +{ + ResetButton::mMovieKillFunction = Func; } -void iTRCDisk::SetSndSuspendFunction(void (*Func)()) { mSndSuspend = Func; } - -void iTRCDisk::SetSndResumeFunction(void (*Func)()) { mSndResume = Func; } - -void iTRCDisk::SetSndKillFunction(void (*Func)()) { mSndKill = Func; } - -void iTRCDisk::SetMovieSuspendFunction(void (*Func)()) { - mMovieSuspendFunction = Func; +void ResetButton::SetSndKillFunction(void (*Func)()) +{ + ResetButton::mSndKill = Func; } -void iTRCDisk::SetMovieResumeFunction(void (*Func)()) { - mMovieResumeFunction = Func; +void ResetButton::DisableReset() +{ + ResetButton::mResetEnabled = 0; } -bool iTRCDisk::IsDiskIDed() { return false; } - -void iTRCDisk::DisplayErrorMessage() {} +void ResetButton::EnableReset() +{ + ResetButton::mResetEnabled = 1; +} -void iTRCDisk::SetDVDState() {} +void ROMFont::DrawTextBox(S32 param_1, S32 param_2, S32 param_3, S32 param_4, char* str) +{ + char* tokenizedString; + S32 baseWidth; + S32 tokWidth; + S32 iVar4; + S32 iVar5; + char acStack_128[TEXTBOX_MAX_TEXT_LENGTH]; -bool iTRCDisk::CheckDVDAndResetState() { return false; } + if (str != NULL) + { + RenderBegin(); + strcpy(acStack_128, str); + tokenizedString = strtok(acStack_128, " "); + baseWidth = GetWidth(" "); + iVar4 = param_2 + param_4; + iVar5 = param_1; + while ((tokenizedString != NULL && (param_2 < iVar4))) + { + tokWidth = GetWidth(tokenizedString); + if (param_1 + param_3 < iVar5 + tokWidth) + { + param_2 = param_2 + mFontData->cellHeight; + iVar5 = param_1; + } + DrawString(iVar5, param_2, tokenizedString); + tokenizedString = strtok(NULL, " "); + iVar5 = tokWidth + baseWidth + iVar5; + } + RenderEnd(); + } +} diff --git a/src/SB/Core/gc/iTRC.h b/src/SB/Core/gc/iTRC.h index 3a189f7..2027ae2 100644 --- a/src/SB/Core/gc/iTRC.h +++ b/src/SB/Core/gc/iTRC.h @@ -5,6 +5,7 @@ #include #include #include +#include #include // Copied from bfbb repo @@ -15,60 +16,73 @@ // _tagPadInit pad_init; // }; -namespace ROMFont { -extern OSFontHeader *mFontData; -extern void *mXFBs[2]; -extern void *mCurrentFrameBuffer; -extern GXRenderModeObj *mRenderMode; -extern bool mFirstFrame; +namespace ROMFont +{ + extern OSFontHeader* mFontData; + extern void* mXFBs[2]; + extern void* mCurrentFrameBuffer; + extern GXRenderModeObj* mRenderMode; + extern bool mFirstFrame; -BOOL Init(); -void InitGX(); -void InitVI(); -void RenderBegin(); -void RenderEnd(); -void SwapBuffers(); -void DrawCell(S32 param_1, S32 param_2, S32 param_3, S32 param_4); -void LoadSheet(void *image_ptr); -S32 DrawString(S32 param_1, S32 param_2, char *string); -S32 GetWidth(char *string); -void DrawTextBox(S32 param_1, S32 param_2, S32 param_3, S32 param_4, char *str); + BOOL Init(); + void InitGX(); + void InitVI(); + void RenderBegin(); + void RenderEnd(); + void SwapBuffers(); + void DrawCell(S32 param_1, S32 param_2, S32 param_3, S32 param_4); + void LoadSheet(void* image_ptr); + S32 DrawString(S32 param_1, S32 param_2, char* string); + S32 GetWidth(char* string); + void DrawTextBox(S32 param_1, S32 param_2, S32 param_3, S32 param_4, char* str); } // namespace ROMFont // Yes, this is a namespace, not a class. -namespace iTRCDisk { -extern char mMessage[256]; -extern void (*mSndSuspend)(); -extern void (*mSndResume)(); -extern void (*mPadStopRumbling)(); -extern void (*mSndKill)(); -extern void (*mMovieSuspendFunction)(); -extern void (*mMovieResumeFunction)(); +namespace iTRCDisk +{ + extern char mMessage[256]; + extern void (*mSndSuspend)(); + extern void (*mSndResume)(); + extern void (*mPadStopRumbling)(); + extern void (*mSndKill)(); + extern void (*mMovieSuspendFunction)(); + extern void (*mMovieResumeFunction)(); + extern void (*mAsyncLoadResume)(); + extern void (*mAsyncLoadSuspend)(); + extern void (*mMovieResetCallBack)(); + extern bool mInFModLockingCode; -void SetPadStopRumblingFunction(void (*)(void)); -void SetSndSuspendFunction(void (*)(void)); -void SetSndResumeFunction(void (*)(void)); -void SetSndKillFunction(void (*)(void)); -void SetMovieSuspendFunction(void (*)(void)); -void SetMovieResumeFunction(void (*)(void)); -bool CheckDVDAndResetState(); -bool Init(); -void ResetMessage(); -void DisplayErrorMessage(); -void SetDVDState(); -void SetErrorMessage(const char *); -bool IsDiskIDed(); + void SetPadStopRumblingFunction(void (*)(void)); + void SetSndSuspendFunction(void (*)(void)); + void SetSndResumeFunction(void (*)(void)); + void SetSndKillFunction(void (*)(void)); + void SetMovieSuspendFunction(void (*)(void)); + void SetMovieResumeFunction(void (*)(void)); + void SetMovieResetCallBack(void (*)(void)); + void SetAsyncLoadResumeFunction(void (*)(void)); + void SetAsyncLoadSuspendFunction(void (*)(void)); + bool CheckDVDAndResetState(); + bool TRCCheck(); + bool Init(); + void ResetMessage(); + void DisplayErrorMessage(); + void SetDVDState(); + void SetErrorMessage(const char*); + bool IsDiskIDed(); + bool SetInFModLockingCode(bool); } // namespace iTRCDisk -namespace ResetButton { -extern bool mResetEnabled; -extern BOOL mWasResetButtonPressed; -extern void (*mSndKill)(); +namespace ResetButton +{ + extern bool mResetEnabled; + extern BOOL mWasResetButtonPressed; + extern void (*mSndKill)(); -void EnableReset(); -void DisableReset(); -void SetSndKillFunction(void (*func)()); -void CheckResetButton(); + void EnableReset(); + void DisableReset(); + void SetSndKillFunction(void (*func)()); + void SetMovieKillFunciton(void (*)(void)); + void CheckResetButton(); } // namespace ResetButton diff --git a/src/SB/Core/gc/iWad.cpp b/src/SB/Core/gc/iWad.cpp index c721e73..489d896 100644 --- a/src/SB/Core/gc/iWad.cpp +++ b/src/SB/Core/gc/iWad.cpp @@ -38,9 +38,10 @@ F32 iTimeGetGame() return sGameTime; } -F32 iTimeDiffSec(iTime t0, iTime t1) +F32 iTimeDiffSec(iTime time, iTime t1) { - return iTimeDiffSec(t1 - t0); + time = t1 - time; + return (F32)time / (GET_BUS_FREQUENCY() / 4); } F32 iTimeDiffSec(iTime time) @@ -128,14 +129,14 @@ void* malloc(U32 __size) return NULL; } - void* result = OSAllocFromHeap(the_heap, __size); + iMemInit(); - if (result == NULL) + if (__size == NULL) { - null_func(); + OSAllocFromHeap(the_heap, __size); } - return result; + return 0; } void free(void* __ptr) @@ -200,6 +201,10 @@ void iSndSetExternalCallback(void* func_ptr) { } +void iSndExit() +{ +} + // void iSndStartStereo(iSndHandle id1, iSndHandle id2) // { // } @@ -610,6 +615,7 @@ static S32 iSG_mcqa_fwrite(st_ISG_MEMCARD_DATA* mcdata, char* buf, S32 len) S32 x = 1000; CARDStat* fstat = &mcdata->fstat; s32 result; + iTRCDisk::TRCCheck(); do { result = CARDGetResultCode(mcdata->chan); @@ -633,16 +639,17 @@ static S32 iSG_mcqa_fwrite(st_ISG_MEMCARD_DATA* mcdata, char* buf, S32 len) } result = CARD_RESULT_BUSY; + iTRCDisk::TRCCheck(); do { if (x++ > 500) { result = CARDGetResultCode(mcdata->chan); - xSndUpdate(); + xSndMgrUpdate(); CARDGetXferredBytes(mcdata->chan); x = 0; } - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); } while (result == CARD_RESULT_BUSY); if (asynresult == CARD_RESULT_READY) @@ -692,12 +699,12 @@ static S32 iSG_mcqa_fread(st_ISG_MEMCARD_DATA* mcdata, char* buf, S32 len, S32 o { if (x++ > 500) { - xSndUpdate(); + xSndMgrUpdate(); CARDGetXferredBytes(mcdata->chan); result = CARDGetResultCode(mcdata->chan); x = 0; } - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); } while (result == CARD_RESULT_BUSY); return result != 0 ? 0 : 1; } @@ -855,7 +862,7 @@ static S32 iSG_load_icondata() g_rawicon = (st_ISG_TPL_TEXPALETTE*)iFileLoad("/SBGCIcon.tpl", NULL, &g_iconsize); g_rawbanr = (st_ISG_TPL_TEXPALETTE*)iFileLoad("/SBGCBanner.tpl", NULL, &g_banrsize); iSG_tpl_unpack(g_rawicon); - iSG_bnr_unpack(g_rawbanr); + iSG_tpl_unpack(g_rawbanr); return g_rawicon && (S32)g_iconsize && g_rawbanr && (S32)g_banrsize ? 1 : 0; } @@ -1131,7 +1138,7 @@ S32 iSGReadLeader(st_ISGSESSION* isgdata, const char* fname, char* databuf, S32 return 0; } - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); iconsize = iSG_cubeicon_size(data->chan, data->sectorSize); S32 sectorsize200 = ALIGN_THING(data->sectorSize, 0x200); if ((S32)databuf % 32 != 0 || numbytes - (numbytes / sectorsize200) * sectorsize200 != 0) @@ -1149,7 +1156,7 @@ S32 iSGReadLeader(st_ISGSESSION* isgdata, const char* fname, char* databuf, S32 bufsize = numbytes; } - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); if (iSG_mc_fopen(data, fname, -1, ISG_IOMODE_READ, &operr) != 0) { @@ -1238,7 +1245,7 @@ S32 iSGSaveFile(st_ISGSESSION* isgdata, const char* fname, char* data, S32 n, S3 return 0; } - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); iconsize = iSG_cubeicon_size(isgdata->slot, mcdata->sectorSize); S32 sectorsize200 = ALIGN_THING(mcdata->sectorSize, 0x200); iconsize += ALIGN_THING(sectorsize200, n); @@ -1249,7 +1256,7 @@ S32 iSGSaveFile(st_ISGSESSION* isgdata, const char* fname, char* data, S32 n, S3 icondata = (char*)((U32)alloc + 0x1f & 0xFFFFFFE0); memcpy(iSG_bfr_icondata(icondata, &statA, arg5, mcdata->sectorSize), data, n); - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); if (iSG_mc_fopen(mcdata, fname, iconsize, ISG_IOMODE_WRITE, &operr) != 0) { @@ -1298,7 +1305,7 @@ S32 iSGSaveFile(st_ISGSESSION* isgdata, const char* fname, char* data, S32 n, S3 } ResetButton::EnableReset(); - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); isgdata->unk_268 = ISG_OPERR_NONE; if (writeret != 0) @@ -1539,7 +1546,7 @@ S32 iSGFileSize(st_ISGSESSION* isgdata, const char* fname) return -1; } st_ISG_MEMCARD_DATA* data = &isgdata->mcdata[isgdata->slot]; - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); ret = iSG_get_fsize(data, fname); if (ret >= 0) { @@ -1574,7 +1581,7 @@ S32 iSGTgtHaveRoomStartup(st_ISGSESSION* isgdata, S32 tidx, S32 fsize, const cha { for (i = 0; i < ISG_NUM_FILES; ++i) { - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); fname = iSGMakeName(ISG_NGTYP_GAMEFILE, NULL, i); if (iSG_get_finfo(data, fname) != 0) { @@ -1648,7 +1655,7 @@ S32 iSGTgtHaveRoom(st_ISGSESSION* isgdata, S32 tidx, S32 fsize, const char* dpat { for (i = 0; i < ISG_NUM_FILES; ++i) { - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); fname = iSGMakeName(ISG_NGTYP_GAMEFILE, NULL, i); if (iSG_get_finfo(data, fname) != 0) { @@ -1730,7 +1737,7 @@ U32 iSGTgtState(st_ISGSESSION* isgdata, S32 tgtidx, const char* dpath) S32 slot = 0; S32 x = 0; S32 y = 0; - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); iSG_mcidx2slot(tgtidx, &slot, NULL); if (slot != isgdata->slot) @@ -1812,7 +1819,7 @@ S32 iSGTgtFormat(st_ISGSESSION* isgdata, S32 tgtidx, S32 async, S32* canRecover) { S32 slot = 0; S32 rc = 0; - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); if (iSG_mc_exists(isgdata->slot) == 0) { return 0; @@ -1867,7 +1874,7 @@ S32 iSGTgtCount(st_ISGSESSION* isgdata, S32* max) for (S32 i = 0; i < ISG_NUM_SLOTS; ++i) { - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); s32 result; do { @@ -1906,12 +1913,15 @@ static S32 iSG_mc_unmount(S32 slot) void iSGSessionEnd(st_ISGSESSION* isgdata) { - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); for (S32 i = 0; i < ISG_NUM_SLOTS; i++) { if (isgdata->mcdata[i].unk_0) { - iSG_mc_unmount(i); + if (isgdata->mcdata[i].unk_0) + { + CARDUnmount(i); + } isgdata->mcdata[i].unk_0 = 0; } } @@ -1926,14 +1936,13 @@ static S32 iSG_chk_icondata() st_ISGSESSION* iSGSessionBegin(void* cltdata, void (*chgfunc)(void*, en_CHGCODE), S32 monitor) { - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); memset(&g_isgdata_MAIN, 0, sizeof(st_ISGSESSION)); g_isgdata_MAIN.slot = -1; g_isgdata_MAIN.chgfunc = chgfunc; g_isgdata_MAIN.cltdata = cltdata; - iSG_chk_icondata(); return &g_isgdata_MAIN; } @@ -1972,7 +1981,7 @@ char* iSGMakeName(en_NAMEGEN_TYPE type, const char* base, S32 idx) return use_buf; } -static void iSG_discard_icondata() +S32 iSGShutdown() { OSFreeToHeap(__OSCurrHeap, g_rawicon); OSFreeToHeap(__OSCurrHeap, g_rawbanr); @@ -1980,30 +1989,21 @@ static void iSG_discard_icondata() g_iconsize = 0; g_rawbanr = NULL; g_banrsize = 0; -} - -S32 iSGShutdown() -{ - iSG_discard_icondata(); return 1; } -static S32 iSG_start_your_engines() -{ - CARDInit(); - return 1; -} - -S32 iSGStartup() +S32 iSGStartup() // TO-DO - 92% { if (g_isginit++ != 0) { return g_isginit; } - - iSG_start_your_engines(); - iSG_load_icondata(); - return g_isginit; + else + { + CARDInit(); + iSG_load_icondata(); + return g_isginit; + } } // iPar @@ -2543,6 +2543,7 @@ void iLightDestroy(iLight* light) if (frame) { + _rwFrameSyncDirty(); RwFrameDestroy(frame); } @@ -2845,7 +2846,7 @@ static void PlayFMV(char* fname, u32 buttons, F32 time) BinkGetError(); } } - if (iTRCDisk::CheckDVDAndResetState() != 0) + if (iTRCDisk::TRCCheck() != 0) { break; } @@ -2853,7 +2854,7 @@ static void PlayFMV(char* fname, u32 buttons, F32 time) { iFileOpen(fname, 0, &file); DVDSeekAsyncPrio(pfinfo, 0, NULL, 2); - if (iTRCDisk::CheckDVDAndResetState()) + if (iTRCDisk::TRCCheck()) { DVDCancel(&pfinfo->cb); break; @@ -2889,7 +2890,7 @@ static void PlayFMV(char* fname, u32 buttons, F32 time) do { - if (iTRCDisk::CheckDVDAndResetState()) + if (iTRCDisk::TRCCheck()) { goto superbreak; } @@ -2945,6 +2946,11 @@ U32 iFMVPlay(char* filename, U32 buttons, F32 time, bool skippable, bool lockCon return 0; } +S32 iFMVSystemInit() +{ + return 1; +} + void _MovieFree(void* mem) { RwFree(mem); @@ -3165,7 +3171,7 @@ U32 iFileRead(tag_xFile* file, void* buf, U32 size) while (iFileSyncAsyncReadActive) { - iTRCDisk::CheckDVDAndResetState(); + iTRCDisk::TRCCheck(); } return size; @@ -3307,7 +3313,7 @@ void iEnvEndRenderFX(iEnv*) { iEnv* env = lastEnv; - if (env->fx && globalCamera && sBeginDrawFX) + if (lastEnv && env->fx && globalCamera && sBeginDrawFX) { RpWorldRemoveCamera(env->fx, globalCamera); RpWorldAddCamera(env->world, globalCamera); @@ -3363,18 +3369,10 @@ void iEnvFree(iEnv* env) static RpAtomic* SetPipelineCB(RpAtomic* atomic, void* data) { - if (RwCameraBeginUpdate(sPipeCamera)) - { - RpAtomicInstance(atomic); - RwCameraEndUpdate(sPipeCamera); - } - if (data) { RpAtomicSetPipeline(atomic, (RxPipeline*)data); } - - return atomic; } // iXF / iDraw @@ -3572,7 +3570,7 @@ S32 iCSLoadStep(xCutscene* csn) void iCSFileClose(xCutscene* csn) { - iFileReadStop(); + DVDCancelAllAsync(false); // TO-DO Im not sure this is right, but it matches csn->Opened = 0; } diff --git a/src/SB/Core/gc/iWad.h b/src/SB/Core/gc/iWad.h index ddcc2fe..b967af5 100644 --- a/src/SB/Core/gc/iWad.h +++ b/src/SB/Core/gc/iWad.h @@ -5,6 +5,7 @@ #include "iAnim.h" #include "iAnimSKB.h" +#include "iARAMTmp.h" #include "iCollide.h" #include "iCollideFast.h" #include "iColor.h" @@ -39,6 +40,7 @@ #include #include #include +#include void iFuncProfileFuncs(int, int, float); diff --git a/src/SB/Core/x/xSnd.h b/src/SB/Core/x/xSnd.h index 1873b48..04739e4 100644 --- a/src/SB/Core/x/xSnd.h +++ b/src/SB/Core/x/xSnd.h @@ -105,6 +105,7 @@ extern xSndGlobals gSnd; void xSndSceneInit(); void xSndResume(); void xSndUpdate(); +void xSndMgrUpdate(); void xSndSetEnvironmentalEffect(sound_effect effectType); void xSndSuspend(); void xSndSetVol(U32 snd, F32 vol); diff --git a/src/SB/Game/zParticleSystemWaterfall.cpp b/src/SB/Game/zParticleSystemWaterfall.cpp index bb663e9..36ab086 100644 --- a/src/SB/Game/zParticleSystemWaterfall.cpp +++ b/src/SB/Game/zParticleSystemWaterfall.cpp @@ -1,112 +1,110 @@ -// #include "zParticleSystemWaterfall.h" - -// void zParticleGeneratorWaterfallSplash::deactivate() -// { -// zParticleGenerator* pGen; -// pGen->deactivate(); -// locator.deactivate(); -// } - -// void zParticleGeneratorWaterfallSplash::activate() -// { -// zParticleGenerator* pGen; -// pGen->activate(); -// locator.activate(*asset, attach_to); // Make const -// } - -// void zParticleGeneratorWaterfallSplash::reset() -// { -// zParticleGenerator::reset(); -// emitted = 0; -// locator.restart(); -// locator.deactivate(); -// if (&flags != 0) // This arg needs fixed -// { -// locator.activate(*asset, attach_to); -// } -// } - -// S32 zParticleSystemWaterfallSplash::get_asset_size() const -// { -// return 56; // Calls for 0x38 -// } - -// void zParticleSystemWaterfallSplash::scene_enter() -// { -// batch_group.create(); -// } - -// void zParticleGeneratorWaterfallMist::deactivate() -// { -// zParticleGenerator* pGen; -// pGen->deactivate(); -// locator.deactivate(); -// } - -// void zParticleGeneratorWaterfallMist::activate() -// { -// zParticleGenerator* pGen; -// pGen->activate(); -// locator.activate(*asset, attach_to); // Make const -// } - -// void zParticleGeneratorWaterfallMist::reset() -// { -// zParticleGenerator::reset(); -// emitted = 0; -// locator.restart(); -// locator.deactivate(); -// if (&flags != 0) // This arg needs fixed -// { -// locator.activate(*asset, attach_to); -// } -// } - -// S32 zParticleSystemWaterfallMist::get_asset_size() const -// { -// return 52; // Calls for 0x34 -// } - -// void zParticleSystemWaterfallMist::scene_enter() -// { -// batch_group.create(); -// } - -// void zParticleGeneratorWaterfall::deactivate() -// { -// zParticleGenerator* pGen; -// pGen->deactivate(); -// locator.deactivate(); -// } - -// void zParticleGeneratorWaterfall::activate() -// { -// zParticleGenerator* pGen; -// pGen->activate(); -// locator.activate(*asset, attach_to); // Make const -// } - -// void zParticleGeneratorWaterfall::reset() // 87% -// { -// zParticleGenerator::reset(); -// emitted = 0; -// locator.restart(); -// locator.deactivate(); -// if (&flags != 0) // This arg needs fixed -// { -// locator.activate(*asset, attach_to); -// } -// } - -// S32 zParticleSystemWaterfall::get_asset_size() const -// { -// return 76; // Calls for 0x4c -// } - -// void zParticleSystemWaterfall::scene_enter() -// { -// batch_group.create(); -// } - - +#include "zParticleSystemWaterfall.h" + +void zParticleGeneratorWaterfallSplash::deactivate() +{ + zParticleGenerator* pGen; + pGen->deactivate(); + locator.deactivate(); +} + +void zParticleGeneratorWaterfallSplash::activate() +{ + zParticleGenerator* pGen; + pGen->activate(); + locator.activate(*asset, attach_to); // Make const +} + +void zParticleGeneratorWaterfallSplash::reset() +{ + zParticleGenerator::reset(); + emitted = 0; + locator.restart(); + locator.deactivate(); + if (&flags != 0) // This arg needs fixed + { + locator.activate(*asset, attach_to); + } +} + +S32 zParticleSystemWaterfallSplash::get_asset_size() const +{ + return 56; // Calls for 0x38 +} + +void zParticleSystemWaterfallSplash::scene_enter() +{ + batch_group.create(); +} + +void zParticleGeneratorWaterfallMist::deactivate() +{ + zParticleGenerator* pGen; + pGen->deactivate(); + locator.deactivate(); +} + +void zParticleGeneratorWaterfallMist::activate() +{ + zParticleGenerator* pGen; + pGen->activate(); + locator.activate(*asset, attach_to); // Make const +} + +void zParticleGeneratorWaterfallMist::reset() +{ + zParticleGenerator::reset(); + emitted = 0; + locator.restart(); + locator.deactivate(); + if (&flags != 0) // This arg needs fixed + { + locator.activate(*asset, attach_to); + } +} + +S32 zParticleSystemWaterfallMist::get_asset_size() const +{ + return 52; // Calls for 0x34 +} + +void zParticleSystemWaterfallMist::scene_enter() +{ + batch_group.create(); +} + +void zParticleGeneratorWaterfall::deactivate() +{ + zParticleGenerator* pGen; + pGen->deactivate(); + locator.deactivate(); +} + +void zParticleGeneratorWaterfall::activate() +{ + zParticleGenerator* pGen; + pGen->activate(); + locator.activate(*asset, attach_to); // Make const +} + +void zParticleGeneratorWaterfall::reset() // 87% +{ + zParticleGenerator::reset(); + emitted = 0; + locator.restart(); + locator.deactivate(); + if (&flags != 0) // This arg needs fixed + { + locator.activate(*asset, attach_to); + } +} + +S32 zParticleSystemWaterfall::get_asset_size() const +{ + return 76; // Calls for 0x4c +} + +void zParticleSystemWaterfall::scene_enter() +{ + batch_group.create(); +} diff --git a/src/SB/Game/zParticleSystemWaterfall.h b/src/SB/Game/zParticleSystemWaterfall.h index 394ecb3..617cb54 100644 --- a/src/SB/Game/zParticleSystemWaterfall.h +++ b/src/SB/Game/zParticleSystemWaterfall.h @@ -1,276 +1,276 @@ -// #ifndef ZPARTICLESYSTEMWATERFALL_H -// #define ZPARTICLESYSTEMWATERFALL_H - -// #include "xNME.h" - -// struct _class_0 -// { -// F32 yaw; -// F32 pitch; -// F32 roll; -// }; - -// struct attach_fixed_data -// { -// }; - -// struct attach_entity_data -// { -// U32 entity; -// U8 bone; -// U8 pad1; -// U8 pad2; -// U8 pad3; -// }; - -// struct attach_entity_tag_data -// { -// U32 entity; -// xVec3 tag; -// }; - -// struct attach_data -// { -// union -// { -// attach_fixed_data fixed; -// attach_entity_data entity; -// attach_entity_tag_data entity_tag; -// }; -// }; - -// struct motion_none_data -// { -// }; - -// struct motion_spiral_data -// { -// U8 flags; -// U8 points; -// U8 pad1; -// U8 pad2; -// F32 radius_inner; -// F32 radius_outer; -// F32 duration; -// F32 frequency; -// }; - -// struct motion_data -// { -// union -// { -// motion_none_data none; -// motion_spiral_data spiral; -// }; -// }; - -// struct volume_point_data -// { -// }; - -// struct volume_sphere_data -// { -// F32 radius; -// }; - -// struct volume_circle_data -// { -// F32 radius; -// F32 arc_length; -// }; - -// struct volume_line_data -// { -// U8 flags; -// U8 pad1; -// U8 pad2; -// U8 pad3; -// F32 radius; -// F32 length; -// }; - -// struct volume_model_data -// { -// U8 flags; -// U8 exclude; -// U8 pad1; -// U8 pad2; -// F32 expand; -// }; - -// struct volume_data -// { -// union -// { -// volume_point_data point; -// volume_sphere_data sphere; -// volume_circle_data circle; -// volume_line_data line; -// volume_model_data model; -// }; -// }; - -// struct zParticleAsset : xDynAsset -// { -// U8 flags; -// U8 attach_flags; -// U8 motion_flags; -// U8 volume_flags; -// F32 rate; -// U32 texture; -// U8 attach_type; -// U8 motion_type; -// U8 volume_type; -// U8 system_type; -// xVec3 location; -// _class_0 axis; -// attach_data attach; -// motion_data motion; -// volume_data volume; -// }; - -// struct zParticleGenerator : xBase -// { -// zParticleAsset* asset; -// S32 flags; - -// void activate(); -// void deactivate(); -// void reset(); -// void perturb_dir(xVec3& dir, F32 angle); -// xEnt* get_attach_entity(zParticleAsset& asset); -// void event_handler(xBase* to, U32 event); -// }; - -// struct relative_ordering -// { -// S32 other; -// U8 before_other; -// }; - -// struct zParticleSystem -// { -// S32 type; -// S32 need; -// zParticleGenerator** generators; -// S32 generators_size; -// S32 generators_active; - -// void destroy_generator(); -// void scene_exit(); -// void setup(); -// void reset(); -// void pre_render(); -// void render(); -// relative_ordering* get_ordering(S32& size); -// void scene_enter(); -// void update(); -// }; - -// struct xParticleBatchGroup -// { -// U8* elements; -// S32 elements_size; - -// void create(); -// }; - -// struct zParticleSystemWaterfall : zParticleSystem -// { -// S32 unk; -// xParticleBatchGroup batch_group; - -// S32 get_asset_size() const; -// void update(F32 dt); -// void scene_enter(); -// zParticleGenerator* create_generator(zParticleAsset& asset); -// }; - -// struct activity_data -// { -// }; - -// struct zParticleLocator -// { -// activity_data* activity; - -// void restart(); -// void scene_enter(); -// U8 activate(zParticleAsset& asset, xEnt* attach_to); -// void deactivate(); -// }; - -// struct zParticleGeneratorWaterfall : zParticleGenerator -// { -// S32 unk; -// zParticleSystemWaterfall* system; -// xEnt* attach_to; -// F32 emitted; //0x24 -// zParticleLocator locator; -// S32 batch_id; -// xVec3 vel_dir; - -// void deactivate(); -// void activate(); -// void reset(); -// void create(zParticleSystemWaterfall& system, zParticleAsset& asset); -// void update(F32 dt); -// }; - -// struct zParticleSystemWaterfallMist : zParticleSystem -// { -// S32 unk; -// xParticleBatchGroup batch_group; - -// S32 get_asset_size() const; -// void update(F32 dt); -// void scene_enter(); -// zParticleGenerator* create_generator(zParticleAsset& asset); -// }; - -// struct zParticleGeneratorWaterfallMist : zParticleGenerator -// { -// S32 unk; -// zParticleSystemWaterfallMist* system; -// xEnt* attach_to; -// F32 emitted; -// zParticleLocator locator; -// S32 batch_id; - -// void deactivate(); -// void activate(); -// void reset(); -// void create(zParticleSystemWaterfallMist& system, zParticleAsset& asset); -// void update(F32 dt); -// }; - -// struct zParticleSystemWaterfallSplash : zParticleSystem -// { -// S32 unk; -// xParticleBatchGroup batch_group; - -// S32 get_asset_size() const; -// void update(F32 dt); -// void scene_enter(); -// zParticleGenerator* create_generator(zParticleAsset& asset); -// }; - -// struct zParticleGeneratorWaterfallSplash : zParticleGenerator -// { -// S32 unk; -// zParticleSystemWaterfallSplash* system; -// xEnt* attach_to; -// F32 emitted; -// zParticleLocator locator; -// S32 batch_id; - -// void deactivate(); -// void activate(); -// void reset(); -// void create(zParticleSystemWaterfallSplash& system, zParticleAsset& asset); -// void update(F32 dt); -// }; - -// #endif - +#ifndef ZPARTICLESYSTEMWATERFALL_H +#define ZPARTICLESYSTEMWATERFALL_H + +#include "xDynAsset.h" +#include "xEnt.h" + +struct _class_0 +{ + F32 yaw; + F32 pitch; + F32 roll; +}; + +struct attach_fixed_data +{ +}; + +struct attach_entity_data +{ + U32 entity; + U8 bone; + U8 pad1; + U8 pad2; + U8 pad3; +}; + +struct attach_entity_tag_data +{ + U32 entity; + xVec3 tag; +}; + +struct attach_data +{ + union + { + attach_fixed_data fixed; + attach_entity_data entity; + attach_entity_tag_data entity_tag; + }; +}; + +struct motion_none_data +{ +}; + +struct motion_spiral_data +{ + U8 flags; + U8 points; + U8 pad1; + U8 pad2; + F32 radius_inner; + F32 radius_outer; + F32 duration; + F32 frequency; +}; + +struct motion_data +{ + union + { + motion_none_data none; + motion_spiral_data spiral; + }; +}; + +struct volume_point_data +{ +}; + +struct volume_sphere_data +{ + F32 radius; +}; + +struct volume_circle_data +{ + F32 radius; + F32 arc_length; +}; + +struct volume_line_data +{ + U8 flags; + U8 pad1; + U8 pad2; + U8 pad3; + F32 radius; + F32 length; +}; + +struct volume_model_data +{ + U8 flags; + U8 exclude; + U8 pad1; + U8 pad2; + F32 expand; +}; + +struct volume_data +{ + union + { + volume_point_data point; + volume_sphere_data sphere; + volume_circle_data circle; + volume_line_data line; + volume_model_data model; + }; +}; + +struct zParticleAsset : xDynAsset +{ + U8 flags; + U8 attach_flags; + U8 motion_flags; + U8 volume_flags; + F32 rate; + U32 texture; + U8 attach_type; + U8 motion_type; + U8 volume_type; + U8 system_type; + xVec3 location; + _class_0 axis; + attach_data attach; + motion_data motion; + volume_data volume; +}; + +struct zParticleGenerator : xBase +{ + zParticleAsset* asset; + S32 flags; + + void activate(); + void deactivate(); + void reset(); + void perturb_dir(xVec3& dir, F32 angle); + xEnt* get_attach_entity(zParticleAsset& asset); + void event_handler(xBase* to, U32 event); +}; + +struct relative_ordering +{ + S32 other; + U8 before_other; +}; + +struct zParticleSystem +{ + S32 type; + S32 need; + zParticleGenerator** generators; + S32 generators_size; + S32 generators_active; + + void destroy_generator(); + void scene_exit(); + void setup(); + void reset(); + void pre_render(); + void render(); + relative_ordering* get_ordering(S32& size); + void scene_enter(); + void update(); +}; + +struct xParticleBatchGroup +{ + U8* elements; + S32 elements_size; + + void create(); +}; + +struct zParticleSystemWaterfall : zParticleSystem +{ + S32 unk; + xParticleBatchGroup batch_group; + + S32 get_asset_size() const; + void update(F32 dt); + void scene_enter(); + zParticleGenerator* create_generator(zParticleAsset& asset); +}; + +struct activity_data +{ +}; + +struct zParticleLocator +{ + activity_data* activity; + + void restart(); + void scene_enter(); + U8 activate(zParticleAsset& asset, xEnt* attach_to); + void deactivate(); +}; + +struct zParticleGeneratorWaterfall : zParticleGenerator +{ + S32 unk; + zParticleSystemWaterfall* system; + xEnt* attach_to; + F32 emitted; //0x24 + zParticleLocator locator; + S32 batch_id; + xVec3 vel_dir; + + void deactivate(); + void activate(); + void reset(); + void create(zParticleSystemWaterfall& system, zParticleAsset& asset); + void update(F32 dt); +}; + +struct zParticleSystemWaterfallMist : zParticleSystem +{ + S32 unk; + xParticleBatchGroup batch_group; + + S32 get_asset_size() const; + void update(F32 dt); + void scene_enter(); + zParticleGenerator* create_generator(zParticleAsset& asset); +}; + +struct zParticleGeneratorWaterfallMist : zParticleGenerator +{ + S32 unk; + zParticleSystemWaterfallMist* system; + xEnt* attach_to; + F32 emitted; + zParticleLocator locator; + S32 batch_id; + + void deactivate(); + void activate(); + void reset(); + void create(zParticleSystemWaterfallMist& system, zParticleAsset& asset); + void update(F32 dt); +}; + +struct zParticleSystemWaterfallSplash : zParticleSystem +{ + S32 unk; + xParticleBatchGroup batch_group; + + S32 get_asset_size() const; + void update(F32 dt); + void scene_enter(); + zParticleGenerator* create_generator(zParticleAsset& asset); +}; + +struct zParticleGeneratorWaterfallSplash : zParticleGenerator +{ + S32 unk; + zParticleSystemWaterfallSplash* system; + xEnt* attach_to; + F32 emitted; + zParticleLocator locator; + S32 batch_id; + + void deactivate(); + void activate(); + void reset(); + void create(zParticleSystemWaterfallSplash& system, zParticleAsset& asset); + void update(F32 dt); +}; + +#endif