StateGX OK

This commit is contained in:
robojumper
2025-03-21 20:38:00 +01:00
parent 4c9213be54
commit b6505d23ad
11 changed files with 429 additions and 80 deletions
+9
View File
@@ -5,6 +5,7 @@
#include "egg/core/eggSystem.h" // for BaseSystem config
#include "egg/core/eggVideo.h"
#include "egg/prim/eggBitFlag.h"
#include "nw4r/ut/ut_Color.h"
#include "nw4r/ut.h" // IWYU pragma: export
#include "rvl/VI.h" // IWYU pragma: export
@@ -49,6 +50,14 @@ public:
void calcFrequency();
void setBlack(bool b) {}
nw4r::ut::Color getClearColor() const {
return mClearColor;
}
void setClearColor(nw4r::ut::Color color) {
mClearColor = color;
}
public:
static u32 sTickPeriod;
};
+61 -52
View File
@@ -2,64 +2,71 @@
#define EGG_STATE_GX_H
#include "common.h"
#include "rvl/GX/GXTexture.h"
#include "rvl/GX/GXTypes.h"
#include "rvl/GX.h" // IWYU pragma: export
namespace EGG {
class StateGX {
public:
struct ScopedColor {
ScopedColor(bool x) {
old = GXSetColorUpdate_(x);
}
struct ScopedColor
{
ScopedColor(bool x)
{
old = GXSetColorUpdate_(x);
}
~ScopedColor() {
GXSetColorUpdate_(old);
}
~ScopedColor()
{
GXSetColorUpdate_(old);
}
bool old;
};
bool old;
};
struct ScopedAlpha {
ScopedAlpha(bool x) {
old = GXSetAlphaUpdate_(x);
}
struct ScopedAlpha
{
ScopedAlpha(bool x)
{
old = GXSetAlphaUpdate_(x);
}
~ScopedAlpha() {
GXSetAlphaUpdate_(old);
}
~ScopedAlpha()
{
GXSetAlphaUpdate_(old);
}
bool old;
};
bool old;
};
struct ScopedDither {
ScopedDither(bool x) {
old = GXSetDither_(x);
}
struct ScopedDither
{
ScopedDither(bool x)
{
old = GXSetDither_(x);
}
~ScopedDither() {
GXSetDither_(old);
}
~ScopedDither()
{
GXSetDither_(old);
}
bool old;
};
bool old;
};
struct CacheGX {
/* 0x00 */ u8 _0x00[0xC];
/* 0x0C */ bool mDstAlphaEnable;
/* 0x0D */ u8 mDstAlpha;
/* 0x0E */ u8 _0x0E[0x18 - 0x0E];
};
static GXColor& getDefaultTexColor() { return sDefaultTexColor; }
struct MemLayout {
/* 0x00 */ int mLayout;
/* 0x04 */ u32 numRegions;
/* 0x08 */ GXTexRegion mRegions[10];
};
static GXColor &getClearEfb() {
return s_clearEfb;
}
static void initialize(u16, u16, GXColor, GXPixelFmt);
static void frameInit();
static void textureInit(); // Guess for 804b4810
static void setTMemLayout(int layout);
static void resetGX();
static void resetVtx();
@@ -72,33 +79,35 @@ public:
static void resetGXCache();
static void GXSetPixelFmt(GXPixelFmt pixelFmt, GXZFmt16 zFmt);
static void invalidateTexAllGX();
static void GXSetPixelFmt_(GXPixelFmt pixelFmt, GXZFmt16 zFmt);
static bool GXSetColorUpdate_(bool);
static bool GXSetAlphaUpdate_(bool);
static bool GXSetDither_(bool);
static bool GXSetDstAlpha_(bool, u8);
static bool GXSetColorUpdate(bool);
static bool GXSetAlphaUpdate(bool);
static bool GXSetDither();
static void GXCopyTex(void *data, bool);
static bool GXSetDstAlpha();
// Unk func here
static void GXSetProjection(Mtx44, int);
static void GXCopyTex_(void *data, bool);
static CacheGX &GXSetDstAlpha_(bool, u8);
static void GXSetProjection_(Mtx44, GXProjectionType);
static void GXSetProjectionv_(const f32 *);
static void GXSetViewport_(f32, f32, f32, f32, f32, f32);
static void GXSetScissor_(u32, u32, u32, u32);
static void GXSetScissorBoxOffset_(s32, s32);
// not sure
static void CalculateScreenScissor(const f32 src[4], u32 dst[4]);
static u16 s_commandFlag;
static u16 s_flag;
static u16 s_widthEfb;
static u16 s_heightEfb;
static GXColor sDefaultTexColor;
static GXPixelFmt s_pixFormat;
static GXZFmt16 s_zFmt16;
static GXColor s_clearEfb;
static u16 s_flag;
static u16 s_commandFlag;
static CacheGX s_cacheGX;
// Inofficial names
static GXTexObj sDefaultTexObj;
static MemLayout s_tmem_layout; // same name, different type
};
} // namespace EGG
+4
View File
@@ -17,11 +17,15 @@ void GXSetFog(GXFogType type, GXColor color, f32 start, f32 end, f32 near, f32 f
void GXInitFogAdjTable(GXFogAdjTable *table, u16 width, const Mtx44 proj);
void GXSetFogRangeAdj(GXBool enable, u16 center, const GXFogAdjTable *table);
void GXSetBlendMode(GXBlendMode mode, GXBlendFactor src, GXBlendFactor dst, GXLogicOp op);
void GXGetColorUpdate(GXBool *enable);
void GXSetColorUpdate(GXBool enable);
void GXGetAlphaUpdate(GXBool *enable);
void GXSetAlphaUpdate(GXBool enable);
void GXSetZMode(GXBool enableTest, GXCompare func, GXBool enableUpdate);
void GXSetZCompLoc(GXBool beforeTex);
void GXGetPixelFmt(GXPixelFmt *pixelFmt, GXZFmt16 *zFmt);
void GXSetPixelFmt(GXPixelFmt pixelFmt, GXZFmt16 zFmt);
void GXGetDither(GXBool *enable);
void GXSetDither(GXBool enable);
void GXSetDstAlpha(GXBool enable, u8 alpha);
void GXSetFieldMask(GXBool enableEven, GXBool enableOdd);
+3
View File
@@ -44,6 +44,9 @@ void GXGetTexObjLODAll(
u8 *biasClampEnable, u8 *edgeLODEnable, GXAnisotropy *anisotropy
);
void GXSetTexCoordScaleManually(GXTexCoordID, GXBool, u16, u16);
void GXSetTexCoordBias(GXTexCoordID, GXBool, GXBool);
u16 GXGetTexObjWidth(const GXTexObj *obj);
u16 GXGetTexObjHeight(const GXTexObj *obj);
GXTexFmt GXGetTexObjFormat(const GXTexObj *obj);
+1 -1
View File
@@ -33,7 +33,7 @@ void GXGetViewportv(f32 view[6]);
void GXSetZScaleOffset(f32 scale, f32 offset);
void GXSetScissor(u32 x, u32 y, u32 w, u32 h);
void GXGetScissor(u32 *x, u32 *y, u32 *w, u32 *h);
void GXSetScissorBoxOffset(u32 ox, u32 oy);
void GXSetScissorBoxOffset(s32 ox, s32 oy);
void GXSetClipMode(GXClipMode mode);
void __GXSetProjection(void);