diff --git a/configure.py b/configure.py index 7fac6562e..dc64659d6 100644 --- a/configure.py +++ b/configure.py @@ -455,7 +455,7 @@ def MatchingFor(*versions): Object(Matching, "SB/Core/x/xQuickCull.cpp"), Object(Matching, "SB/Core/x/xsavegame.cpp"), Object(NonMatching, "SB/Core/x/xScene.cpp", extra_cflags=["-sym on"]), - Object(NonMatching, "SB/Core/x/xScrFx.cpp"), + Object(Equivalent, "SB/Core/x/xScrFx.cpp", extra_cflags=["-sym on"]), Object(NonMatching, "SB/Core/x/xserializer.cpp"), Object(NonMatching, "SB/Core/x/xSFX.cpp"), Object(NonMatching, "SB/Core/x/xShadow.cpp"), diff --git a/include/rwsdk/rwcore.h b/include/rwsdk/rwcore.h index 311d8bfc1..ec75306f8 100644 --- a/include/rwsdk/rwcore.h +++ b/include/rwsdk/rwcore.h @@ -3,24 +3,19 @@ #include -typedef struct _RxObjSpace3DVertex RxObjSpace3DVertex; - -union RxColorUnion -{ - RwRGBA preLitColor; - RwRGBA color; -}; - -// TODO: Determine whether c should go before or after objNormal -// Context: These headers came from an official header source (unsure of release platform) -// However, currently decomped functions seem to pack the struct -// in this particular way so it's like this for now. -// See: zActionLIne.cpp -struct _RxObjSpace3DVertex -{ - RwV3d objVertex; - RwV3d objNormal; - RxColorUnion c; +typedef struct RxObjSpace3DVertex RxObjSpace3DVertex; +struct RxObjSpace3DVertex +{ + RwReal x; + RwReal y; + RwReal z; + RwReal nx; + RwReal ny; + RwReal nz; + RwUInt8 r; + RwUInt8 g; + RwUInt8 b; + RwUInt8 a; RwReal u; RwReal v; }; @@ -28,6 +23,53 @@ struct _RxObjSpace3DVertex typedef RxObjSpace3DVertex RxObjSpace3DLitVertex; typedef RxObjSpace3DLitVertex RwIm3DVertex; +#define RwIm3DVertexSetPos(_vert, _imx, _imy, _imz) \ +MACRO_START \ +{ \ + (_vert)->x = _imx; \ + (_vert)->y = _imy; \ + (_vert)->z = _imz; \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetNormal(_vert, _imx, _imy, _imz) \ +MACRO_START \ +{ \ + (_vert)->nx = _imx; \ + (_vert)->ny = _imy; \ + (_vert)->nz = _imz; \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetRGBA(_vert, _r, _g, _b, _a) \ +MACRO_START \ +{ \ + (_vert)->r = _r; \ + (_vert)->g = _g; \ + (_vert)->b = _b; \ + (_vert)->a = _a; \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetUV(_vert, _u, _v) \ +MACRO_START \ +{ \ + (_vert)->u = _u; \ + (_vert)->v = _v; \ +} \ +MACRO_STOP + +enum RwIm3DTransformFlags +{ + rwIM3D_VERTEXUV = 1, + rwIM3D_ALLOPAQUE = 2, + rwIM3D_NOCLIP = 4, + rwIM3D_VERTEXXYZ = 8, + rwIM3D_VERTEXRGBA = 16, + rwIM3DTRANSFORMFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwIm3DTransformFlags RwIm3DTransformFlags; + typedef struct rxHeapFreeBlock; typedef struct rxHeapSuperBlockDescriptor; typedef struct RxHeap; diff --git a/src/SB/Core/gc/iParMgr.cpp b/src/SB/Core/gc/iParMgr.cpp index befa60fe3..bd79a77f0 100644 --- a/src/SB/Core/gc/iParMgr.cpp +++ b/src/SB/Core/gc/iParMgr.cpp @@ -57,7 +57,7 @@ void iRenderFlush() void iRenderTrianglesImmediate(S32 vertType, S32 vertTypeSize, void* data, S32 dataSize, U16* index, S32 indexSize) { - if (RwIm3DTransform((_RxObjSpace3DVertex *)data, dataSize, NULL, 1) != NULL) + if (RwIm3DTransform((RwIm3DVertex *)data, dataSize, NULL, 1) != NULL) { if (indexSize != 0) { diff --git a/src/SB/Core/x/xScrFx.cpp b/src/SB/Core/x/xScrFx.cpp index 2d14f9efb..237805dc9 100644 --- a/src/SB/Core/x/xScrFx.cpp +++ b/src/SB/Core/x/xScrFx.cpp @@ -1,21 +1,49 @@ #include "xScrFx.h" -#include +#include "zGame.h" +#include "zMenu.h" +#include "xDebug.h" +#include "zGlobals.h" +#include "xstransvc.h" -U8 g_debugRenderSafeArea; +struct _xFadeData +{ + S32 active; + S32 hold; + iColor_tag src; + iColor_tag dest; + F32 time_passed; + F32 time_total; + void(*cb)(); +}; -static F32 mLetterboxO; -static F32 mLetterboxTO; -static F32 sLetterBoxSize; -static U8 sLetterBoxAlpha = 255; -F32 sFullScreenGlareIntensity; // Needs to be initialized +bool g_debugRenderSafeArea = false; static _xFadeData mFade; + +static F32 mLetterboxO = 0.0f; +static F32 mLetterboxTO = 0.0f; +static F32 sLetterBoxSize = 0.0f; +static U8 sLetterBoxAlpha = 255; + +DistortionParticle gDistortionParticles[100]; +S32 gNumDistortionParticles = 0; + +static F32 sNoGlobalTime = 0.0f; + +xVec3 ddir = { 0.0f, -0.5f, 0.0f }; + xGlare sGlare[10]; -extern RwGlobals* RwEngineInstance; -extern RwInt32 RwEngineGetCurrentVideoMode(void); -extern RwVideoMode* RwEngineGetVideoModeInfo(RwVideoMode* modeinfo, RwInt32 modeIndex); +xVec3 sFullScreenGlareDir = { -0.3f, 1.0f, 0.4f }; +F32 sFullScreenGlareIntensity = 0.5f; +RwRGBA sFullScreenGlareColor = { 255, 255, 255, 64 }; +S32 sFullScreenGlareEnabled = 0; +U32 sFullScreenGlareTextureID = xStrHash("fx_streak2"); +RwTexture* sFullScreenGlareTexturePtr = NULL; + +static void xScrFxDistortionUpdate(F32 dt); +static void xScrFxDistortionRender(RwCamera*); void xScrFxInit() { @@ -42,50 +70,55 @@ void xScrFxUpdate(RwCamera* cam, F32 dt) void xScrFxRender(RwCamera* cam) { iScrFxBegin(); - xScrFxDistortionRender((RwCamera*)RwEngineInstance->curCamera); - if (g_debugRenderSafeArea != '\0') + xScrFxDistortionRender(RwCameraGetCurrentCamera()); + + if (g_debugRenderSafeArea) { xScrFxDrawSafeArea(); } + iScrFxEnd(); } void xScrFxDrawScreenSizeRectangle() { - // I honestly dont know how to complete this function - // FIXME: First 2 params of xScrFxDrawBox seem to be correct - // The rest of them confuse me. - RwVideoMode video_mode; - - F32 x2 = 0; - F32 y2 = 0; - U8 red = 0; - U8 green = 0; - U8 blue = 0; - U8 alpha = 255; - F32 ushift = 0; - F32 vshift = 0; - - S32 mode = RwEngineGetCurrentVideoMode(); - RwEngineGetVideoModeInfo(&video_mode, mode); - xScrFxDrawBox((F32)video_mode.width, (F32)video_mode.height, x2, y2, red, green, blue, alpha, - ushift, vshift); + RwEngineGetVideoModeInfo(&video_mode, RwEngineGetCurrentVideoMode()); + iScrFxDrawBox(0.0f, 0.0f, video_mode.width, video_mode.height, 0, 0, 0, 255); } void xScrFxFadeInit() { - memset(&mFade, 0, 0x1c); + memset(&mFade, 0, sizeof(mFade)); } -void InterpCol(F32 unk, U8 unk1, U8 unk2) +static U8 InterpCol(F32 t, U8 s, U8 d) { + U8 uval; + F32 val = d - s; + val *= t; + val += s; + uval = (U8)val; + return uval; } void xScrFxFade(iColor_tag* base, iColor_tag* dest, F32 seconds, void (*callback)(), S32 hold) { mFade.active = 1; - base->operator=(*(iColor_tag*)dest); + mFade.src = *base; + mFade.dest = *dest; + mFade.time_passed = 0.0f; + mFade.time_total = seconds; + mFade.cb = callback; + + if (!hold) + { + mFade.hold = 0; + } + else + { + mFade.hold = 1; + } } void xScrFxStopFade() @@ -98,6 +131,61 @@ S32 xScrFxIsFading() return mFade.active; } +void xScrFxUpdateFade(RwCamera*, F32 seconds) +{ + if (zGameIsPaused()) return; + if (!mFade.active) return; + + F32 t; + if (mFade.hold == 2) + { + t = 1.0f; + } + else + { + if (!mFade.time_passed) + { + t = 0.0f; + } + else + { + mFade.time_total = MAX(0.00001f, mFade.time_total); + t = mFade.time_passed / mFade.time_total; + } + + mFade.time_passed += seconds; + + if (t >= 1.0f) + { + t = 1.0f; + + if (mFade.hold == 1) + { + mFade.hold = 2; + } + else + { + mFade.active = 0; + } + + if (mFade.cb) + { + mFade.cb(); + } + } + } + + iColor_tag c; + c.r = InterpCol(t, mFade.src.r, mFade.dest.r); + c.g = InterpCol(t, mFade.src.g, mFade.dest.g); + c.b = InterpCol(t, mFade.src.b, mFade.dest.b); + c.a = InterpCol(t, mFade.src.a, mFade.dest.a); + + RwVideoMode video_mode; + RwEngineGetVideoModeInfo(&video_mode, RwEngineGetCurrentVideoMode()); + iScrFxDrawBox(0.0f, 0.0f, video_mode.width, video_mode.height, c.r, c.g, c.b, c.a); +} + void xScrFxLetterBoxInit() { mLetterboxO = 0.0f; @@ -122,11 +210,12 @@ void xScrFxLetterBoxSetAlpha(U8 alpha) void xScrFxLetterbox(S32 enable) { - if (zMenuRunning() != 0) + if (zMenuRunning()) { enable = 0; } - if (enable != 0) + + if (enable) { mLetterboxTO = sLetterBoxSize; } @@ -136,16 +225,108 @@ void xScrFxLetterbox(S32 enable) } } +void xScrFxUpdateLetterBox(RwCamera*, F32 seconds) +{ + if (!zGameIsPaused()) + { + if (mLetterboxO < mLetterboxTO) + { + mLetterboxO += 100.0f * seconds; + if (mLetterboxO > mLetterboxTO) + { + mLetterboxO = mLetterboxTO; + } + } + else if (mLetterboxO > mLetterboxTO) + { + mLetterboxO -= 100.0f * seconds; + if (mLetterboxO < mLetterboxTO) + { + mLetterboxO = mLetterboxTO; + } + } + } + + F32 o = mLetterboxO; + + if (o > 0.0f) + { + RwVideoMode video_mode; + RwEngineGetVideoModeInfo(&video_mode, RwEngineGetCurrentVideoMode()); + iScrFxDrawBox(0.0f, 0.0f, video_mode.width, o, 0, 0, 0, sLetterBoxAlpha); + iScrFxDrawBox(0.0f, video_mode.height - o, video_mode.width, video_mode.height, 0, 0, 0, sLetterBoxAlpha); + } + +} + S32 xScrFxIsLetterbox() { - return (((mLetterboxTO > 0.0f) << 2) << 0x1c) >> 0x1e; + return mLetterboxTO > 0.0f; +} + +void xScrFxDrawSafeArea() +{ + RwVideoMode videoMode; + RwEngineGetVideoModeInfo(&videoMode, RwEngineGetCurrentVideoMode()); + + U32 screenWidth = videoMode.width; + U32 screenHeight = videoMode.height; + U32 safeX = screenWidth * 0.85f; + U32 safeY = screenHeight * 0.85f; + U32 xMargin = (screenWidth - safeX) / 2; + U32 yMargin = (screenHeight - safeY) / 2; + S32 top = yMargin; + S32 bottom = screenHeight - yMargin; + S32 left = xMargin; + S32 right = screenWidth - xMargin; + F32 width = 2.0f; + + iScrFxDrawBox(left - width, top - width, right + width, top, 255, 0, 0, 255); + iScrFxDrawBox(left - width, bottom, right + width, bottom + width, 255, 0, 0, 255); + iScrFxDrawBox(left - width, top, left, bottom, 255, 0, 0, 255); + iScrFxDrawBox(right, top, right + width, bottom, 255, 0, 0, 255); } void xScrFxDistortionAdd(xVec3*, xVec3*, S32) { } -void xScrFxDistortionRender(RwCamera*) +static void xScrFxDistortionUpdate(F32 dt) +{ + DistortionParticle* dp = &gDistortionParticles[0]; + + if (zGameIsPaused()) + { + return; + } + + sNoGlobalTime += dt; + + for (S32 i = 0; i < gNumDistortionParticles; i++, dp++) + { + if (dp->death != 0.0f) + { + dp->life += dt; + if (dp->life >= dp->death) + { + *dp = gDistortionParticles[gNumDistortionParticles - 1]; + gDistortionParticles[gNumDistortionParticles - 1].death = 0.0f; + i--; + dp--; + gNumDistortionParticles--; + } + } + } + + if (gFrameCount % 2 == 0) + { + xVec3 pos = *xEntGetPos(&globals.player.ent); + pos.y += 0.5f; + xScrFxDistortionAdd(&pos, &ddir, 1); + } +} + +static void xScrFxDistortionRender(RwCamera*) { } @@ -162,3 +343,235 @@ void xScrFXGlareReset() { xScrFXGlareInit(); } + +S32 xScrFXGlareAdd(xVec3* pos, F32 life, F32 intensity, F32 size, F32 r, F32 g, F32 b, F32 a, RwRaster* raster) +{ + for (S32 i = 0; i < 10; i++) + { + if (sGlare[i].flags == 0) + { + sGlare[i].lifetime = life; + sGlare[i].intensity = intensity; + sGlare[i].pos = *pos; + sGlare[i].flags = 0x1; + sGlare[i].col.alpha = a; + sGlare[i].col.red = r; + sGlare[i].col.green = g; + sGlare[i].col.blue = b; + sGlare[i].size = size; + sGlare[i].intensityFadeRate = sGlare[i].intensity / sGlare[i].lifetime; + + if (!raster) + { + RwTexture* texturePtr = (RwTexture*)xSTFindAsset(xStrHash("fx_radialgradient"), NULL); + if (texturePtr) + { + sGlare[i].raster = RwTextureGetRaster(texturePtr); + } + else + { + sGlare[i].raster = NULL; + } + } + else + { + sGlare[i].raster = raster; + } + + return i; + } + } + + return -1; +} + +void xScrFXGlareUpdate(F32 dt) +{ + for (S32 i = 0; i < 10; i++) + { + if (sGlare[i].flags != 0) + { + sGlare[i].lifetime -= dt; + sGlare[i].intensity -= dt * sGlare[i].intensityFadeRate; + if (sGlare[i].lifetime <= 0.0f) + { + sGlare[i].flags = 0; + } + } + } +} + +void xScrFXFullScreenGlareRender() +{ + if (!sFullScreenGlareEnabled) + { + return; + } + + xMat4x3 mat; + iCamGetViewMatrix(xglobals->camera.lo_cam, &mat); + + xVec3 v; + xVec3Copy(&v, &mat.at); + xVec3Normalize(&v, &v); + + xVec3 glareDir; + xVec3Normalize(&glareDir, &sFullScreenGlareDir); + + F32 dp = glareDir.dot(v); + + F32 d = dp; + d = 0.5f + d; + d *= d * d * d; + d *= sFullScreenGlareIntensity; + if (d == 0.0f) + { + return; + } + + RwRGBA color; + color.red = sFullScreenGlareColor.red; + color.green = sFullScreenGlareColor.green; + color.blue = sFullScreenGlareColor.blue; + + F32 alpha = sFullScreenGlareColor.alpha * d; + if (alpha > 255.0f) + { + alpha = 255.0f; + } + color.alpha = alpha; + + if (!sFullScreenGlareTexturePtr) + { + sFullScreenGlareTexturePtr = (RwTexture*)xSTFindAsset(sFullScreenGlareTextureID, NULL); + } + if (sFullScreenGlareTexturePtr) + { + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)RwTextureGetRaster(sFullScreenGlareTexturePtr)); + } + else + { + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)NULL); + } + + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + + xScrFxDrawBox(0.0f, 0.0f, 640.0f, 480.0f, color.red, color.green, color.blue, color.alpha, dp, 0.0f); +} + +void xScrFXGlareRender(xCamera* cam) +{ + if (!cam) + { + return; + } + + for (S32 i = 0; i < 10; i++) + { + xGlare* g = &sGlare[i]; + if (g->flags == 0) + { + continue; + } + + xVec3 w, h; + h = cam->mat.right; + w = cam->mat.up; + xVec3Normalize(&h, &h); + xVec3Normalize(&w, &w); + h *= 0.5f * g->size; + w *= 0.5f * g->size; + + xVec3 v; + xVec3Copy(&v, &cam->mat.at); + xVec3Normalize(&v, &v); + + xVec3 glareDir; + glareDir.x = g->pos.x - cam->mat.pos.x; + glareDir.y = g->pos.y - cam->mat.pos.y; + glareDir.z = g->pos.z - cam->mat.pos.z; + xVec3Normalize(&glareDir, &glareDir); + + F32 dot = glareDir.dot(v); + + F32 val = (1.0f + dot) * 0.5f; + val *= val * val * val; + + F32 glareDirLen = xVec3Length(&glareDir); + + val *= g->intensity / glareDirLen; + if (val != 0.0f) + { + static RwIm3DVertex sStripVert[4]; + + RwIm3DVertex* vert = &sStripVert[0]; + RwIm3DVertexSetPos(vert, g->pos.x - w.x - h.x, g->pos.y - w.y - h.y, g->pos.z - w.z - h.z); + RwIm3DVertexSetUV(vert, 0.0f, 0.0f); + RwIm3DVertexSetRGBA(vert, 255.0f * g->col.red, 255.0f * g->col.green, 255.0f * g->col.blue, 255.0f * g->col.alpha * val); + vert++; + RwIm3DVertexSetPos(vert, g->pos.x - w.x + h.x, g->pos.y - w.y + h.y, g->pos.z - w.z + h.z); + RwIm3DVertexSetUV(vert, 0.0f, 1.0f); + RwIm3DVertexSetRGBA(vert, 255.0f * g->col.red, 255.0f * g->col.green, 255.0f * g->col.blue, 255.0f * g->col.alpha * val); + vert++; + RwIm3DVertexSetPos(vert, g->pos.x + w.x - h.x, g->pos.y + w.y - h.y, g->pos.z + w.z - h.z); + RwIm3DVertexSetUV(vert, 1.0f, 0.0f); + RwIm3DVertexSetRGBA(vert, 255.0f * g->col.red, 255.0f * g->col.green, 255.0f * g->col.blue, 255.0f * g->col.alpha * val); + vert++; + RwIm3DVertexSetPos(vert, g->pos.x + w.x + h.x, g->pos.y + w.y + h.y, g->pos.z + w.z + h.z); + RwIm3DVertexSetUV(vert, 1.0f, 1.0f); + RwIm3DVertexSetRGBA(vert, 255.0f * g->col.red, 255.0f * g->col.green, 255.0f * g->col.blue, 255.0f * g->col.alpha * val); + + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)g->raster); + + if (RwIm3DTransform(sStripVert, 4, NULL, rwIM3D_VERTEXXYZ | rwIM3D_VERTEXUV | rwIM3D_VERTEXRGBA)) + { + RwIm3DRenderPrimitive(rwPRIMTYPETRISTRIP); + RwIm3DEnd(); + } + } + } +} + +void xScrFxDrawBox(F32 x1, F32 y1, F32 x2, F32 y2, U8 red, U8 green, U8 blue, U8 alpha, F32 ushift, F32 vshift) +{ + F32 oocameraNearClipPlane = RwIm2DGetNearScreenZ(); + + if (alpha == 0) + { + return; + } + + static RwImVertexIndex indices[4] = { 0, 1, 2, 3 }; + static RwIm2DVertex v[4]; + + RwIm2DVertexSetScreenX(&v[0], x1); + RwIm2DVertexSetScreenY(&v[0], y1); + RwIm2DVertexSetScreenX(&v[1], x2); + RwIm2DVertexSetScreenY(&v[1], y1); + RwIm2DVertexSetScreenX(&v[2], x1); + RwIm2DVertexSetScreenY(&v[2], y2); + RwIm2DVertexSetScreenX(&v[3], x2); + RwIm2DVertexSetScreenY(&v[3], y2); + + RwIm2DVertexSetScreenZ(&v[0], oocameraNearClipPlane); + RwIm2DVertexSetScreenZ(&v[1], oocameraNearClipPlane); + RwIm2DVertexSetScreenZ(&v[2], oocameraNearClipPlane); + RwIm2DVertexSetScreenZ(&v[3], oocameraNearClipPlane); + + RwIm2DVertexSetIntRGBA(&v[0], red, green, blue, alpha); + RwIm2DVertexSetIntRGBA(&v[1], red, green, blue, alpha); + RwIm2DVertexSetIntRGBA(&v[2], red, green, blue, alpha); + RwIm2DVertexSetIntRGBA(&v[3], red, green, blue, alpha); + + RwIm2DVertexSetU(&v[0], ushift, 0); + RwIm2DVertexSetV(&v[0], vshift, 0); + RwIm2DVertexSetU(&v[1], 1.0f + ushift, 0); + RwIm2DVertexSetV(&v[1], vshift, 0); + RwIm2DVertexSetU(&v[2], ushift, 0); + RwIm2DVertexSetV(&v[2], 1.0f + vshift, 0); + RwIm2DVertexSetU(&v[3], 1.0f + ushift, 0); + RwIm2DVertexSetV(&v[3], 1.0f + vshift, 0); + + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRISTRIP, v, 4, indices, 4); +} diff --git a/src/SB/Core/x/xScrFx.h b/src/SB/Core/x/xScrFx.h index b550c3152..08d0d1f02 100644 --- a/src/SB/Core/x/xScrFx.h +++ b/src/SB/Core/x/xScrFx.h @@ -1,44 +1,54 @@ #ifndef XSCRFX_H #define XSCRFX_H -#include "xCamera.h" #include "iColor.h" #include "iScrFX.h" -#include "zMenu.h" +#include "xMath3.h" #include -#include -struct _xFadeData +struct DistortionParticle { - S32 active; // offset 0x0, size 0x4 - S32 hold; // offset 0x4, size 0x4 - iColor_tag src; // offset 0x8, size 0x4 - iColor_tag dest; // offset 0xC, size 0x4 - F32 time_passed; // offset 0x10, size 0x4 - F32 time_total; // offset 0x14, size 0x4 - void (*cb)(); // offset 0x18, size 0x4 + xVec3 pos; + U32 flags; + xVec3 dir; + F32 life; + xVec3 vel; + F32 death; }; struct xGlare { - S32 flags; // offset 0x0, size 0x4 - xVec3 pos; // offset 0x4, size 0xC - F32 intensity; // offset 0x10, size 0x4 - F32 intensityFadeRate; // offset 0x14, size 0x4 - F32 lifetime; // offset 0x18, size 0x4 - F32 size; // offset 0x1C, size 0x4 - RwRGBAReal col; // offset 0x20, size 0x10 - RwRaster* raster; // offset 0x30, size 0x4 + S32 flags; + xVec3 pos; + F32 intensity; + F32 intensityFadeRate; + F32 lifetime; + F32 size; + RwRGBAReal col; + RwRaster* raster; }; +extern bool g_debugRenderSafeArea; +extern DistortionParticle gDistortionParticles[100]; +extern S32 gNumDistortionParticles; +extern xVec3 ddir; +extern xGlare sGlare[10]; +extern xVec3 sFullScreenGlareDir; +extern F32 sFullScreenGlareIntensity; +extern RwRGBA sFullScreenGlareColor; +extern S32 sFullScreenGlareEnabled; +extern U32 sFullScreenGlareTextureID; +extern RwTexture* sFullScreenGlareTexturePtr; + +struct xCamera; + void xScrFxInit(); void xScrFxReset(); void xScrFxUpdate(RwCamera* cam, F32 dt); void xScrFxRender(RwCamera*); void xScrFxDrawScreenSizeRectangle(); void xScrFxFadeInit(); -void InterpCol(F32, U8, U8); void xScrFxFade(iColor_tag* base, iColor_tag* dest, F32 seconds, void (*callback)(), S32 hold); void xScrFxStopFade(); S32 xScrFxIsFading(); @@ -54,13 +64,11 @@ void xScrFxUpdateLetterBox(RwCamera* cam, F32 seconds); S32 xScrFxIsLetterbox(); void xScrFxDrawSafeArea(); void xScrFxDistortionAdd(xVec3*, xVec3*, S32); -static void xScrFxDistortionUpdate(F32 dt); -static void xScrFxDistortionRender(RwCamera*); void xScrFXGlareInit(); void xScrFXGlareReset(); S32 xScrFXGlareAdd(xVec3* pos, F32 life, F32 intensity, F32 size, F32 r, F32 g, F32 b, F32 a, RwRaster* raster); -void xScrFXGlareUpdate(F32); // Return type may be wrong, Not in dwarf +void xScrFXGlareUpdate(F32 dt); void xScrFXFullScreenGlareRender(); void xScrFXGlareRender(xCamera* cam); void xScrFxDrawBox(F32 x1, F32 y1, F32 x2, F32 y2, U8 red, U8 green, U8 blue, U8 alpha, F32 ushift, diff --git a/src/SB/Core/x/xShadowSimple.cpp b/src/SB/Core/x/xShadowSimple.cpp index 2a62bec72..f6cf7f956 100644 --- a/src/SB/Core/x/xShadowSimple.cpp +++ b/src/SB/Core/x/xShadowSimple.cpp @@ -92,21 +92,32 @@ void xShadowSimple_Init() memset(sShadVert, 0, sizeof(sShadVert)); - // Not sure what's going on in this loop - for (u32 i = 0; i < 384; i++) + for (u32 i = 0; i < 64; i++) { - sShadVert[i].c = RxColorUnion(); - - sShadVert[i].u = 1.0f; - sShadVert[i].v = 1.0f; - - sShadVert[i].objVertex.x = 0.0f; - sShadVert[i].objVertex.y = 0.0f; - sShadVert[i].objVertex.z = 0.0f; - - sShadVert[i].objNormal.x = 0.0f; - sShadVert[i].objNormal.y = 0.0f; - sShadVert[i].objNormal.z = 0.0f; + sShadVert[i*6+1].u = 1.0f; + sShadVert[i*6+2].v = 1.0f; + sShadVert[i*6+3].u = 1.0f; + sShadVert[i*6+4].v = 1.0f; + sShadVert[i*6+5].u = 1.0f; + sShadVert[i*6+5].v = 1.0f; + sShadVert[i*6+0].nx = 0.0f; + sShadVert[i*6+0].ny = 1.0f; + sShadVert[i*6+0].nz = 0.0f; + sShadVert[i*6+1].nx = 0.0f; + sShadVert[i*6+1].ny = 1.0f; + sShadVert[i*6+1].nz = 0.0f; + sShadVert[i*6+2].nx = 0.0f; + sShadVert[i*6+2].ny = 1.0f; + sShadVert[i*6+2].nz = 0.0f; + sShadVert[i*6+3].nx = 0.0f; + sShadVert[i*6+3].ny = 1.0f; + sShadVert[i*6+3].nz = 0.0f; + sShadVert[i*6+4].nx = 0.0f; + sShadVert[i*6+4].ny = 1.0f; + sShadVert[i*6+4].nz = 0.0f; + sShadVert[i*6+5].nx = 0.0f; + sShadVert[i*6+5].ny = 1.0f; + sShadVert[i*6+5].nz = 0.0f; } } diff --git a/src/SB/Game/zActionLine.cpp b/src/SB/Game/zActionLine.cpp index f58031845..9ac79b071 100644 --- a/src/SB/Game/zActionLine.cpp +++ b/src/SB/Game/zActionLine.cpp @@ -52,15 +52,9 @@ static void RenderActionLine(_tagActionLine* l) for (S32 i = 0; i < 4; i++) { - sStripVert[i].objVertex.y = l->pos[i].y; - sStripVert[i].objVertex.z = l->pos[i].z; - sStripVert[i].objVertex.x = l->pos[i].x; - sStripVert[i].u = 0.0f; - sStripVert[i].v = 0.0f; - sStripVert[i].c.color.red = 0xFF; - sStripVert[i].c.color.green = 0xFF; - sStripVert[i].c.color.blue = 0xFF; - sStripVert[i].c.color.alpha = 0x80; + RwIm3DVertexSetPos(&sStripVert[i], l->pos[i].x, l->pos[i].y, l->pos[i].z); + RwIm3DVertexSetUV(&sStripVert[i], 0.0f, 0.0f); + RwIm3DVertexSetRGBA(&sStripVert[i], 0xFF, 0xFF, 0xFF, 0x80); } if (RwIm3DTransform(sStripVert, 4, NULL, 0x19) != NULL) diff --git a/src/SB/Game/zNPCTypeBossSandy.cpp b/src/SB/Game/zNPCTypeBossSandy.cpp index f1f764616..0c197b496 100644 --- a/src/SB/Game/zNPCTypeBossSandy.cpp +++ b/src/SB/Game/zNPCTypeBossSandy.cpp @@ -337,42 +337,21 @@ void zNPCBSandy::Init(xEntAsset* asset) sNFSoundValue[i] = xStrHash(sNFSoundLabel[i]); } - this->iconVert[0].objVertex.x = 1.0f; - this->iconVert[0].objVertex.y = 0.0f; - this->iconVert[0].objVertex.z = 1.0f; - this->iconVert[1].objVertex.x = -1.0f; - this->iconVert[1].objVertex.y = 1.0f; - this->iconVert[1].objVertex.z = 1.0f; - this->iconVert[2].objVertex.x = 0.0f; - this->iconVert[2].objVertex.y = -1.0f; - this->iconVert[2].objVertex.z = -1.0f; - this->iconVert[3].objVertex.x = -1.0f; - this->iconVert[3].objVertex.y = 0.0f; - this->iconVert[3].objVertex.z = -1.0f; - this->iconVert[0].c.preLitColor.red = 0xff; - this->iconVert[0].c.preLitColor.green = 0xff; - this->iconVert[0].c.preLitColor.blue = 0xff; - this->iconVert[0].c.preLitColor.alpha = 0xff; - this->iconVert[1].c.preLitColor.red = 0xff; - this->iconVert[1].c.preLitColor.green = 0xff; - this->iconVert[1].c.preLitColor.blue = 0xff; - this->iconVert[1].c.preLitColor.alpha = 0xff; - this->iconVert[2].c.preLitColor.red = 0xff; - this->iconVert[2].c.preLitColor.green = 0xff; - this->iconVert[2].c.preLitColor.blue = 0xff; - this->iconVert[2].c.preLitColor.alpha = 0xff; - this->iconVert[3].c.preLitColor.red = 0xff; - this->iconVert[3].c.preLitColor.green = 0xff; - this->iconVert[3].c.preLitColor.blue = 0xff; - this->iconVert[3].c.preLitColor.alpha = 0xff; - this->iconVert[0].u = 0.0f; - this->iconVert[1].u = 1.0f; - this->iconVert[2].u = 0.0f; - this->iconVert[3].u = 1.0f; - this->iconVert[0].v = 0.0f; - this->iconVert[1].v = 0.0f; - this->iconVert[2].v = 1.0f; - this->iconVert[3].v = 1.0f; + RwIm3DVertexSetPos(&this->iconVert[0], 1.0f, 0.0f, 1.0f); + RwIm3DVertexSetPos(&this->iconVert[1], -1.0f, 1.0f, 1.0f); + RwIm3DVertexSetPos(&this->iconVert[2], 0.0f, -1.0f, -1.0f); + RwIm3DVertexSetPos(&this->iconVert[3], -1.0f, 0.0f, -1.0f); + + RwIm3DVertexSetRGBA(&this->iconVert[0], 0xff, 0xff, 0xff, 0xff); + RwIm3DVertexSetRGBA(&this->iconVert[1], 0xff, 0xff, 0xff, 0xff); + RwIm3DVertexSetRGBA(&this->iconVert[2], 0xff, 0xff, 0xff, 0xff); + RwIm3DVertexSetRGBA(&this->iconVert[3], 0xff, 0xff, 0xff, 0xff); + + RwIm3DVertexSetUV(&this->iconVert[0], 0.0f, 0.0f); + RwIm3DVertexSetUV(&this->iconVert[1], 1.0f, 0.0f); + RwIm3DVertexSetUV(&this->iconVert[2], 0.0f, 1.0f); + RwIm3DVertexSetUV(&this->iconVert[3], 1.0f, 1.0f); + this->wireLight[0] = 0; this->wireLight[1] = 0;