From 70123b2777f85786fe94819068f6ac80e98cf6ef Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 20 Mar 2025 23:19:35 +0100 Subject: [PATCH] Some ScreenEffectBlur, CpuTexture --- config/SOUE01/splits.txt | 3 + config/SOUE01/symbols.txt | 36 +++---- include/egg/egg_types.h | 1 + include/egg/gfx/eggCpuTexture.h | 6 +- include/egg/gfx/eggFrustum.h | 4 + include/egg/gfx/eggGXUtility.h | 6 +- include/egg/gfx/eggPostEffectBase.h | 8 +- include/egg/gfx/eggPostEffectBlur.h | 15 ++- include/egg/gfx/eggScreenEffectBlur.h | 46 ++++++++- src/egg/gfx/eggCpuTexture.cpp | 134 +++++++++++++++++++++++++- src/egg/gfx/eggScreenEffectBlur.cpp | 111 ++++++++++++++++++++- 11 files changed, 338 insertions(+), 32 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 1806fa0d..8d54a2a5 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2189,6 +2189,7 @@ egg/gfx/eggCapTexture.cpp: egg/gfx/eggCpuTexture.cpp: .text start:0x8049DA30 end:0x8049EC94 .data start:0x8056ED80 end:0x8056EDA0 + .sdata2 start:0x8057F418 end:0x8057F440 egg/gfx/eggDrawGX.cpp: .text start:0x8049ECA0 end:0x804A0C24 @@ -2319,6 +2320,8 @@ egg/gfx/eggScreenEffectBase.cpp: egg/gfx/eggScreenEffectBlur.cpp: .text start:0x804B30F0 end:0x804B3D98 + .data start:0x8056F278 end:0x8056F2B0 + .sdata2 start:0x8057F840 end:0x8057F868 egg/gfx/eggStateEfb.cpp: .text start:0x804B3DA0 end:0x804B460C diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 7eb1cd11..85c66915 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -26431,8 +26431,8 @@ FUN_8049d780 = .text:0x8049D780; // type:function size:0x40 configure__Q23EGG10CapTextureFv = .text:0x8049D7C0; // type:function size:0x7C capture__Q23EGG10CapTextureFUsUsbi = .text:0x8049D840; // type:function size:0x184 FUN_8049d9d0 = .text:0x8049D9D0; // type:function size:0x58 -calcColorGradient_EGG_CpuTexture_8049da30 = .text:0x8049DA30; // type:function size:0x188 -makeGradient_EGG_CpuTexture_8049dbc0 = .text:0x8049DBC0; // type:function size:0x450 +calcColorGradient__Q23EGG27@unnamed@eggCpuTexture_cpp@FR8_GXColorRC8_GXColorRC8_GXColorf = .text:0x8049DA30; // type:function size:0x188 +makeGradient__Q23EGG27@unnamed@eggCpuTexture_cpp@FiP8_GXColoriiiRC8_GXColorRC8_GXColor = .text:0x8049DBC0; // type:function size:0x450 __ct__Q23EGG10CpuTextureFv = .text:0x8049E010; // type:function size:0x44 __ct__Q23EGG10CpuTextureFUsUs9_GXTexFmt = .text:0x8049E060; // type:function size:0x40 __ct__Q23EGG10CpuTextureFPC9_GXTexObj = .text:0x8049E0A0; // type:function size:0xB0 @@ -26443,8 +26443,8 @@ load__Q23EGG10CpuTextureCF11_GXTexMapID = .text:0x8049E1F0; // type:function siz getTexObj__Q23EGG10CpuTextureCFP9_GXTexObj = .text:0x8049E230; // type:function size:0x80 flush__Q23EGG10CpuTextureCFv = .text:0x8049E2B0; // type:function size:0x4C buildHeader__Q23EGG10CpuTextureCFv = .text:0x8049E300; // type:function size:0x84 -fillNormalMapSphere__EGG_CpuTexture_8049e390 = .text:0x8049E390; // type:function size:0x1BC -fillGradient_EGG_CpuTexture_8049e550 = .text:0x8049E550; // type:function size:0x3A8 +fillNormalMapSphere__Q23EGG10CpuTextureFff = .text:0x8049E390; // type:function size:0x1BC +fillGradient__Q23EGG10CpuTextureFiiUsUsRC8_GXColorRC8_GXColorbb = .text:0x8049E550; // type:function size:0x3A8 alloc__Q23EGG10CpuTextureFPQ23EGG4Heap = .text:0x8049E900; // type:function size:0x84 allocWithHeaderDebug__Q23EGG10CpuTextureFPQ23EGG4Heap = .text:0x8049E990; // type:function size:0xA8 allocate__Q23EGG10CpuTextureFPQ23EGG4Heap = .text:0x8049EA40; // type:function size:0x4 @@ -26579,7 +26579,7 @@ getTexMtxID__Q23EGG9GXUtilityFi = .text:0x804A7820; // type:function size:0xC setScaleOffsetPerspective__Q23EGG9GXUtilityFPfffff = .text:0x804A7830; // type:function size:0x40 getTexObj__Q23EGG9GXUtilityFP9_GXTexObjRCQ23EGG7ResTIMG = .text:0x804A7870; // type:function size:0x100 getTexObj__Q23EGG9GXUtilityFP9_GXTexObjQ34nw4r3g3d6ResTex14_GXTexWrapMode14_GXTexWrapMode12_GXTexFilter12_GXTexFilter = .text:0x804A7970; // type:function size:0xB8 -FUN_804a7a30 = .text:0x804A7A30; // type:function size:0x190 +getNormalColor__Q23EGG9GXUtilityFR8_GXColorRCQ23EGG8Vector3f = .text:0x804A7A30; // type:function size:0x190 __dt__Q23EGG8IScnProcFv = .text:0x804A7BC0; // type:function size:0xB8 createScnProc__Q23EGG8IScnProcFUsP12MEMAllocator = .text:0x804A7C80; // type:function size:0x110 setPriorityScnProc__Q23EGG8IScnProcFUsUcb = .text:0x804A7D90; // type:function size:0xBC @@ -26744,18 +26744,18 @@ FUN_804b2ee0 = .text:0x804B2EE0; // type:function size:0x14C __sinit_\eggScreen_cpp = .text:0x804B3030; // type:function size:0x84 scope:local __ct__Q23EGG16ScreenEffectBaseFv = .text:0x804B30C0; // type:function size:0x18 __sinit_\eggScreenEffectBase_cpp = .text:0x804B30E0; // type:function size:0xC scope:local -FUN_804b30f0 = .text:0x804B30F0; // type:function size:0x104 -FUN_804b3200 = .text:0x804B3200; // type:function size:0xA8 -FUN_804b32b0 = .text:0x804B32B0; // type:function size:0x454 -FUN_804b3710 = .text:0x804B3710; // type:function size:0x184 -FUN_804b38a0 = .text:0x804B38A0; // type:function size:0x78 -FUN_804b3920 = .text:0x804B3920; // type:function size:0x6C -FUN_804b3990 = .text:0x804B3990; // type:function size:0x3B4 -FUN_804b3d50 = .text:0x804B3D50; // type:function size:0x8 -FUN_804b3d60 = .text:0x804B3D60; // type:function size:0x8 -FUN_804b3d70 = .text:0x804B3D70; // type:function size:0x8 -FUN_804b3d80 = .text:0x804B3D80; // type:function size:0x8 -FUN_804b3d90 = .text:0x804B3D90; // type:function size:0x8 +__ct__Q23EGG16ScreenEffectBlurFv = .text:0x804B30F0; // type:function size:0x104 +__dt__Q23EGG16ScreenEffectBlurFv = .text:0x804B3200; // type:function size:0xA8 +fn_804B32B0__Q23EGG16ScreenEffectBlurFv = .text:0x804B32B0; // type:function size:0x454 +fn_804B3710__Q23EGG16ScreenEffectBlurFv = .text:0x804B3710; // type:function size:0x184 +SetBinaryInner__Q23EGG16ScreenEffectBlurFRCQ33EGG33IBinary3Bin = .text:0x804B38A0; // type:function size:0x78 +GetBinaryInner__Q23EGG16ScreenEffectBlurCFPQ33EGG33IBinary3Bin = .text:0x804B3920; // type:function size:0x6C +SetBinaryInner__Q23EGG16ScreenEffectBlurFRCQ33EGG33IBinary3BinRCQ33EGG33IBinary3Binf = .text:0x804B3990; // type:function size:0x3B4 +GetBinarySize__Q23EGG33IBinaryCFv = .text:0x804B3D50; // type:function size:0x8 +@8@SetBinaryInner__Q23EGG16ScreenEffectBlurFRCQ33EGG33IBinary3Bin = .text:0x804B3D60; // type:function size:0x8 +@8@SetBinaryInner__Q23EGG16ScreenEffectBlurFRCQ33EGG33IBinary3BinRCQ33EGG33IBinary3Binf = .text:0x804B3D70; // type:function size:0x8 +@8@GetBinaryInner__Q23EGG16ScreenEffectBlurCFPQ33EGG33IBinary3Bin = .text:0x804B3D80; // type:function size:0x8 +@8@__dt__Q23EGG16ScreenEffectBlurFv = .text:0x804B3D90; // type:function size:0x8 Clean__Q23EGG8StateEfbFv = .text:0x804B3DA0; // type:function size:0x78 captureEfb__Q23EGG8StateEfbFQ33EGG8StateEfb10BufferTypebUl = .text:0x804B3E20; // type:function size:0x3C8 releaseEfb__Q23EGG8StateEfbFQ33EGG8StateEfb10BufferTypeUl = .text:0x804B41F0; // type:function size:0x7C @@ -37385,7 +37385,7 @@ __vt__Q23EGG16PostEffectSimple = .data:0x8056F210; // type:object size:0x1C sTVModeInfo__Q23EGG6Screen = .data:0x8056F230; // type:object size:0x24 data:2byte EGG__Screen__vtable = .data:0x8056F254; // type:object size:0x14 __vt__Q23EGG16ScreenEffectBase = .data:0x8056F268; // type:object size:0xC -lbl_8056F278 = .data:0x8056F278; // type:object size:0x38 +__vt__Q23EGG16ScreenEffectBlur = .data:0x8056F278; // type:object size:0x38 __vt__Q23EGG13TextureBuffer = .data:0x8056F2B0; // type:object size:0x10 __vt__Q23EGG9ArcPlayer = .data:0x8056F2C0; // type:object size:0x5C __vt__Q23EGG14SimpleAudioMgr = .data:0x8056F320; // type:object size:0xA4 diff --git a/include/egg/egg_types.h b/include/egg/egg_types.h index c1ff24f8..f3f96c61 100644 --- a/include/egg/egg_types.h +++ b/include/egg/egg_types.h @@ -37,6 +37,7 @@ class PostEffectBlur; class PostEffectBlurGather; class PostEffectHDR; class PostEffectSimple; +class PostEffectUnk2; class ResTIMG; class ScnRenderer; class ScnRootEx; diff --git a/include/egg/gfx/eggCpuTexture.h b/include/egg/gfx/eggCpuTexture.h index 7269471f..5c2e55cb 100644 --- a/include/egg/gfx/eggCpuTexture.h +++ b/include/egg/gfx/eggCpuTexture.h @@ -9,7 +9,6 @@ namespace EGG { class CpuTexture { - void makeGradient(UNKTYPE); public: struct Header { @@ -62,11 +61,10 @@ public: u32 getTexBufferSize() const; void buildHeader() const; Header *initHeader(); + void fillNormalMapSphere(f32, f32); void fillGradient(int op, int, u16, u16, const GXColor&, const GXColor&, bool, bool); - UNKTYPE func_80086C8C(UNKTYPE); - void allocTexBuffer(); - void allocTexBufferAndHeader(); + void setColor(u16 x, u16 y, GXColor color); GXColor getColor(u16 x, u16 y) const; diff --git a/include/egg/gfx/eggFrustum.h b/include/egg/gfx/eggFrustum.h index 01c93063..f3dd56d3 100644 --- a/include/egg/gfx/eggFrustum.h +++ b/include/egg/gfx/eggFrustum.h @@ -83,6 +83,10 @@ public: void SetOffset(const nw4r::math::VEC2 &offset) { mOffset = offset; } + + const nw4r::math::VEC2 &GetSize() { + return mSize; + } }; } // namespace EGG diff --git a/include/egg/gfx/eggGXUtility.h b/include/egg/gfx/eggGXUtility.h index daf49239..d3ac74b7 100644 --- a/include/egg/gfx/eggGXUtility.h +++ b/include/egg/gfx/eggGXUtility.h @@ -2,8 +2,10 @@ #define EGG_GX_UTILITY_H #include "egg/gfx/eggTexture.h" +#include "egg/math/eggVector.h" #include "nw4r/g3d/res/g3d_restex.h" #include "rvl/GX/GXTexture.h" +#include "rvl/GX/GXTypes.h" namespace EGG { @@ -11,7 +13,9 @@ class GXUtility { public: static int getTexMtxID(int); static void getTexObj(GXTexObj *, const EGG::ResTIMG &); - static void getTexObj(_GXTexObj *, nw4r::g3d::ResTex, GXTexWrapMode, GXTexWrapMode, GXTexFilter, GXTexFilter); + static void getTexObj(GXTexObj *, nw4r::g3d::ResTex, GXTexWrapMode, GXTexWrapMode, GXTexFilter, GXTexFilter); + + static void getNormalColor(GXColor &outColor, const Vector3f &vec); }; } // namespace EGG diff --git a/include/egg/gfx/eggPostEffectBase.h b/include/egg/gfx/eggPostEffectBase.h index 2c3207ed..84a533c9 100644 --- a/include/egg/gfx/eggPostEffectBase.h +++ b/include/egg/gfx/eggPostEffectBase.h @@ -9,6 +9,13 @@ namespace EGG { class PostEffectBase { +public: + void setField_0x00(u32 val) { + field_0x00 = val; + } + + static void setProjection(const EGG::Screen &screen); + protected: u32 field_0x00; // at 0x0 CapTexture *mpCapTexture; // at 0x4 @@ -34,7 +41,6 @@ protected: static void scaleColor(GXColor &, const GXColor &, bool, f32); static void lerpColor(GXColor &, const GXColor &, const GXColor &, f32); void getBaseTexMtx(nw4r::math::MTX34 *mtx) const; - static void setProjection(const EGG::Screen &screen); protected: virtual void draw(f32 width, f32 height); // at 0xC diff --git a/include/egg/gfx/eggPostEffectBlur.h b/include/egg/gfx/eggPostEffectBlur.h index 62b6625e..103a55af 100644 --- a/include/egg/gfx/eggPostEffectBlur.h +++ b/include/egg/gfx/eggPostEffectBlur.h @@ -4,10 +4,11 @@ #include "common.h" #include "egg/egg_types.h" #include "egg/gfx/eggPostEffectBase.h" +#include "rvl/GX/GXTypes.h" namespace EGG { -class PostEffectBlur : PostEffectBase { +class PostEffectBlur : public PostEffectBase { struct Stage { /* 0x00 */ u8 field_0x00; /* 0x01 */ GXColor field_0x01; @@ -32,6 +33,18 @@ public: field_0x30 = val; } + void setStage0Field0(u8 u1) { + field_0x38[0].field_0x00 = u1; + } + + void setStage0Color(GXColor clr) { + field_0x38[0].field_0x01 = clr; + } + + void setStage0F(f32 f) { + field_0x38[0].field_0x0C = f; + } + private: void drawInternal(u8, u8, f32, f32); diff --git a/include/egg/gfx/eggScreenEffectBlur.h b/include/egg/gfx/eggScreenEffectBlur.h index 0553161f..86150ff8 100644 --- a/include/egg/gfx/eggScreenEffectBlur.h +++ b/include/egg/gfx/eggScreenEffectBlur.h @@ -2,15 +2,55 @@ #define EGG_SCREEN_EFFECT_BLUR_H #include "common.h" +#include "egg/egg_types.h" +#include "egg/gfx/eggScreenEffectBase.h" +#include "egg/prim/eggBinary.h" +#include "rvl/GX/GXTypes.h" + namespace EGG { -class ScreenEffectBlur { +class ScreenEffectBlur : public ScreenEffectBase, IBinary { public: + struct BinData { + u8 field_0x00; + u8 field_0x01; + u8 field_0x02; + f32 field_0x04; + f32 field_0x08; + f32 field_0x0C; + f32 field_0x10; + f32 field_0x14; + f32 field_0x18; + u8 field_0x1C; + u8 field_0x1D; + u8 field_0x1E; + u8 field_0x1F; + }; + ScreenEffectBlur(); - ~ScreenEffectBlur(); + virtual ~ScreenEffectBlur(); + + virtual void SetBinaryInner(const Bin &) override; + virtual void GetBinaryInner(Bin *) const override; + virtual void SetBinaryInner(const Bin &, const Bin &, f32) override; + + void fn_804B32B0(); + void fn_804B3710(); private: - u8 _0x00[0x38 - 0x00]; + /* 0x0C */ u8 field_0x0C; + /* 0x0D */ u8 field_0x0D; + /* 0x0E */ u8 field_0x0E; + /* 0x10 */ f32 field_0x10; + /* 0x14 */ f32 field_0x14; + /* 0x18 */ f32 field_0x18; + /* 0x1C */ f32 field_0x1C; + /* 0x20 */ f32 field_0x20; + /* 0x24 */ f32 field_0x24; + /* 0x28 */ GXColor field_0x28; + /* 0x2C */ PostEffectUnk2 *mpUnk2; + /* 0x30 */ PostEffectBlur *mpBlur; + /* 0x34 */ TextureBuffer *mpCpuTexture; }; } // namespace EGG diff --git a/src/egg/gfx/eggCpuTexture.cpp b/src/egg/gfx/eggCpuTexture.cpp index 9052ff8b..fc927b2f 100644 --- a/src/egg/gfx/eggCpuTexture.cpp +++ b/src/egg/gfx/eggCpuTexture.cpp @@ -2,12 +2,74 @@ #include "common.h" #include "egg/core/eggHeap.h" +#include "egg/gfx/eggGXUtility.h" +#include "egg/math/eggVector.h" #include "rvl/GX/GXTexture.h" #include "rvl/GX/GXTypes.h" +#include "rvl/MTX/vec.h" #include "rvl/OS/OSCache.h" namespace EGG { +namespace { + +void calcColorGradient(GXColor &outColor, const GXColor &c1, const GXColor &c2, f32 amount) { + if (amount <= 0.0f) { + outColor = c1; + } else if (amount >= 1.0f) { + outColor = c2; + } else { + outColor.r = c1.r + amount * (c2.r - c1.r); + outColor.g = c1.g + amount * (c2.g - c1.g); + outColor.b = c1.b + amount * (c2.b - c1.b); + outColor.a = c1.a + amount * (c2.a - c1.a); + } +} + +void makeGradient(int op, GXColor *outColor, int size, int start, int end, const GXColor &c1, const GXColor &c2) { + int start_p1 = start + 1; + // Weird instruction calculation + for (int i = 0; i < start_p1; i++) { + outColor[i] = c1; + } + + int end_1 = end - 1; + for (int i = end_1; i < size; i++) { + outColor[i] = c2; + } + + for (int i = start_p1; i < end_1; i++) { + f32 ratio = (f32)(i - start) / (f32)(end - start); + switch (op) { + case 0: break; + case 1: ratio *= ratio; break; + case 2: + ratio *= ratio; + ratio *= ratio; + break; + case 3: + ratio *= ratio; + ratio *= ratio; + ratio *= ratio; + break; + case 4: + ratio *= ratio; + ratio *= ratio; + ratio *= ratio; + ratio *= ratio; + break; + case 5: ratio = -(ratio - 1.0f) * (ratio - 1.0f) + 1.0f; break; + case 6: + ratio -= 1.0f; + ratio = -ratio * ratio * ratio * ratio + 1.0f; + break; + } + calcColorGradient(outColor[i], c1, c2, ratio); + } +} + +} // namespace + CpuTexture::CpuTexture() { mWidth = 0; mHeight = 0; @@ -196,11 +258,10 @@ GXColor CpuTexture::getColor(u16 x, u16 y) const { case GX_TF_Z16: { int offset = ((x >> 2) + (y >> 2) * (getWidth() / 4)) * 0x20 + (y & 3) * 8 + (x & 3) * 2; u8 *dat = static_cast(getBuffer()) + offset; - // TODO c.a = dat[0]; c.b = dat[1]; - c.g = dat[1]; - c.r = dat[1]; + c.g = c.b; + c.r = c.b; break; } default: break; @@ -208,4 +269,71 @@ GXColor CpuTexture::getColor(u16 x, u16 y) const { return c; } +extern "C" double sqrt(double); + +void CpuTexture::fillNormalMapSphere(f32 f1, f32 f2) { + // NONMATCHING + // fpr regswaps + f32 mid = static_cast(mWidth / 2); + for (u16 y = 0; y < mHeight; y++) { + for (u16 x = 0; x < mWidth; x++) { + Vector3f vec; + vec.x = f1 * ((x + f2) - mid); + vec.y = f1 * -((y + f2) - mid); + f32 z = mid * mid - (vec.x * vec.x + vec.y * vec.y); + vec.z = z < 0.0f ? 0.0f : (f32)sqrt(z); + PSVECNormalize(vec, vec); + GXColor c; + GXUtility::getNormalColor(c, vec); + c.r = c.a; + setColor(x, y, c); + } + } + flush(); +} + +void CpuTexture::fillGradient( + int op, int unk, u16 start, u16 end, const GXColor &c1, const GXColor &c2, bool b1, bool b2 +) { + GXColor gradient[1024]; + GXColor colors[256]; + + + // NONMATCHING - regswaps + bool swapMode = unk == 0x73 || unk == 0x53; + + u16 width = swapMode ? mWidth : mHeight; + int size = width; + u16 height = swapMode ? mHeight : mWidth; + int mid = width / 2; + makeGradient(op, gradient, size, start, end, c1, c2); + if (b1) { + int i2 = mid; + for (int i = 0; i < size; i++, i2++) { + colors[i].r = gradient[i < mid ? i2 : i - mid].r; + colors[i].g = gradient[i < mid ? i2 : i - mid].g; + colors[i].b = gradient[i < mid ? i2 : i - mid].b; + colors[i].a = gradient[i < mid ? i2 : i - mid].a; + } + + for (int i = 0; i < size; i++) { + gradient[i] = colors[i]; + } + } + + u16 start2 = b2 ? 0 : start; + u16 end2 = b2 ? size : end; + + for (u16 x = start2; x < end2; x++) { + for (u16 y = 0; y < height; y++) { + if (swapMode) { + setColor(x, y, gradient[x & 0xFFFF]); + } else { + setColor(y, x, gradient[x & 0xFFFF]); + } + } + } + flush(); +} + } // namespace EGG diff --git a/src/egg/gfx/eggScreenEffectBlur.cpp b/src/egg/gfx/eggScreenEffectBlur.cpp index 65a45952..c445b216 100644 --- a/src/egg/gfx/eggScreenEffectBlur.cpp +++ b/src/egg/gfx/eggScreenEffectBlur.cpp @@ -1,3 +1,112 @@ #include "egg/gfx/eggScreenEffectBlur.h" -namespace EGG {} // namespace EGG +#include "common.h" +#include "egg/gfx/eggDrawGX.h" +#include "egg/gfx/eggPostEffectBase.h" +#include "egg/gfx/eggPostEffectBlur.h" // IWYU pragma: keep +#include "egg/gfx/eggPostEffectUnk2.h" // IWYU pragma: keep +#include "egg/gfx/eggStateGX.h" +#include "egg/gfx/eggTextureBuffer.h" +#include "nw4r/math/math_types.h" +#include "rvl/GX/GXTev.h" +#include "rvl/GX/GXTypes.h" +#include "rvl/MTX/mtx.h" + +namespace EGG { + +static const GXColor sDefaultColor = {0, 0, 0, 0xFF}; +static const GXColor sDefaultColor2 = {0x80, 0x80, 0x80, 0x80}; + +ScreenEffectBlur::ScreenEffectBlur() + : field_0x0C(3), + field_0x0D(0), + field_0x0E(0), + field_0x10(1.0f), + field_0x14(1.0f), + field_0x18(0.5f), + field_0x1C(1.0f), + field_0x20(0.5f), + field_0x24(0.0f), + field_0x28(sDefaultColor), + mpCpuTexture(0) { + mpUnk2 = new PostEffectUnk2(); + mpBlur = new PostEffectBlur(); + mpBlur->setField_0x00(2); + mpBlur->setStage0Field0(4); + mpBlur->setStage0Color(sDefaultColor2); + mpBlur->setStage0F(field_0x1C); +} + +ScreenEffectBlur::~ScreenEffectBlur() { + delete mpUnk2; + delete mpBlur; +} + +void ScreenEffectBlur::fn_804B32B0() { + // Oh god +} + +void ScreenEffectBlur::fn_804B3710() { + if ((mFlag & 1) != 0) { + StateGX::invalidateTexAllGX(); + PostEffectBase::setProjection(sScreen); + nw4r::math::MTX34 mtx; + // Have to perform a float -> u16 -> float round trip here... + u16 sizeY = sScreen.GetSize().y; + u16 sizeX = sScreen.GetSize().x; + PSMTXScale(mtx, sizeX, sizeY, 0.0f); + mpCpuTexture->load(GX_TEXMAP0); + DrawGX::BeginDrawScreen(true, true, true); + GXSetTevKColor(GX_KCOLOR0, field_0x28); + GXSetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0); + GXSetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_KONST); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_KONST, GX_CA_TEXA, GX_CA_ZERO); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_GREATER, field_0x0D); + DrawGX::SetBlendMode((field_0x0C & 4) != 0 ? DrawGX::BLEND_14 : DrawGX::BLEND_0); + DrawGX::DrawDL(DrawGX::DL_16, mtx, DrawGX::WHITE); + } + if (mpCpuTexture != nullptr) { + mpCpuTexture->free(); + mpCpuTexture = nullptr; + } +} + +void ScreenEffectBlur::SetBinaryInner(const Bin &bin) { + if (bin.mHeader.mVersion != 0) { + return; + } + field_0x0C = bin.mData.field_0x00; + field_0x0D = bin.mData.field_0x01; + field_0x0E = bin.mData.field_0x02; + field_0x10 = bin.mData.field_0x04; + field_0x14 = bin.mData.field_0x08; + field_0x18 = bin.mData.field_0x0C; + field_0x1C = bin.mData.field_0x10; + field_0x20 = bin.mData.field_0x14; + field_0x24 = bin.mData.field_0x18; + field_0x28.r = bin.mData.field_0x1C; + field_0x28.g = bin.mData.field_0x1D; + field_0x28.b = bin.mData.field_0x1E; + field_0x28.a = bin.mData.field_0x1F; +} + +void ScreenEffectBlur::GetBinaryInner(Bin *bin) const { + bin->mData.field_0x00 = field_0x0C; + bin->mData.field_0x01 = field_0x0D; + bin->mData.field_0x02 = field_0x0E; + bin->mData.field_0x04 = field_0x10; + bin->mData.field_0x08 = field_0x14; + bin->mData.field_0x0C = field_0x18; + bin->mData.field_0x10 = field_0x1C; + bin->mData.field_0x14 = field_0x20; + bin->mData.field_0x18 = field_0x24; + bin->mData.field_0x1C = field_0x28.r; + bin->mData.field_0x1D = field_0x28.g; + bin->mData.field_0x1E = field_0x28.b; + bin->mData.field_0x1F = field_0x28.a; +} + +void ScreenEffectBlur::SetBinaryInner(const Bin &bin1, const Bin &bin2, f32 blend) {} + +} // namespace EGG