From 02efcf0a65212583c068a270e6ed08ae62524d8d Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sat, 15 Nov 2025 02:00:54 -0500 Subject: [PATCH 1/2] Some Symbols --- config/SOUE01/symbols.txt | 68 ++++++------ include/egg/core/eggController.h | 2 +- include/egg/gfx/eggDrawGX.h | 8 -- include/egg/gfx/eggLightObject.h | 6 +- include/egg/gfx/eggLightTexture.h | 6 +- include/egg/gfx/eggStateEfb.h | 11 +- include/egg/gfx/eggStateGX.h | 6 +- src/egg/core/eggController.cpp | 4 +- src/egg/core/eggVideo.cpp | 11 +- src/egg/gfx/eggCpuTexture.cpp | 4 +- src/egg/gfx/eggDrawGX.cpp | 166 +++++++++++++++--------------- src/egg/gfx/eggLightObject.cpp | 27 ++--- src/egg/gfx/eggLightTexture.cpp | 71 +++++++------ src/egg/gfx/eggStateEfb.cpp | 22 ++-- src/egg/gfx/eggStateGX.cpp | 37 ++++--- src/toBeSorted/d_d3d.cpp | 20 ++-- 16 files changed, 232 insertions(+), 237 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 60eae4d3..1cf49233 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -17844,7 +17844,7 @@ XrotS__6mMtx_cFRC4mAng = .text:0x802F16B0; // type:function size:0xBC XrotM__6mMtx_cFRC4mAng = .text:0x802F1770; // type:function size:0x4C YrotS__6mMtx_cFRC4mAng = .text:0x802F17C0; // type:function size:0xBC YrotM__6mMtx_cFRC4mAng = .text:0x802F1880; // type:function size:0x4C -mMtx__ZrotS = .text:0x802F18D0; // type:function size:0xBC +ZrotS__6mMtx_cF4mAng = .text:0x802F18D0; // type:function size:0xBC ZrotM__6mMtx_cFRC4mAng = .text:0x802F1990; // type:function size:0x4C ZXYrotS__6mMtx_cFRC4mAngRC4mAngRC4mAng = .text:0x802F19E0; // type:function size:0x60 ZXYrotM__6mMtx_cFRC4mAngRC4mAngRC4mAng = .text:0x802F1A40; // type:function size:0x60 @@ -17876,7 +17876,7 @@ normalizeRS__7mVec3_cFv = .text:0x802F2BF0; // type:function size:0x84 rotX__7mVec3_cFRC4mAng = .text:0x802F2C80; // type:function size:0xA8 rotY__7mVec3_cFRC4mAng = .text:0x802F2D30; // type:function size:0xAC rotZ__7mVec3_cFRC4mAng = .text:0x802F2DE0; // type:function size:0xA8 -mVec__sinit = .text:0x802F2E90; // type:function size:0x78 +__sinit_\m_vec_cpp = .text:0x802F2E90; // type:function size:0x78 init__Q210homebutton15FrameControllerFifff = .text:0x802F2F10; // type:function size:0x38 initFrame__Q210homebutton15FrameControllerFv = .text:0x802F2F50; // type:function size:0x20 calc__Q210homebutton15FrameControllerFv = .text:0x802F2F70; // type:function size:0x14C @@ -26430,7 +26430,7 @@ __dt__Q23EGG9AnalizeDLFv = .text:0x8049D780; // type:function size:0x40 scope:we configure__Q23EGG10CapTextureFv = .text:0x8049D7C0; // type:function size:0x7C capture__Q23EGG10CapTextureFUsUsbi = .text:0x8049D840; // type:function size:0x184 fn_8049D9D0__Q23EGG10CapTextureFUc = .text:0x8049D9D0; // type:function size:0x58 -calcColorGradient__Q23EGG27@unnamed@eggCpuTexture_cpp@FR8_GXColorRC8_GXColorRC8_GXColorf = .text:0x8049DA30; // type:function size:0x188 +blendColor__Q23EGG27@unnamed@eggCpuTexture_cpp@FR8_GXColorRC8_GXColorRC8_GXColorf = .text:0x8049DA30; // type:function size:0x188 makeGradient__Q23EGG27@unnamed@eggCpuTexture_cpp@FiP8_GXColorUsUsUsRC8_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 @@ -26620,9 +26620,9 @@ InitGX__Q23EGG11LightObjectCFP11_GXLightObj = .text:0x804A9D40; // type:function CopyToG3D_World__Q23EGG11LightObjectCFRQ34nw4r3g3d8LightObj = .text:0x804A9F40; // type:function size:0x150 CopyToG3D_View__Q23EGG11LightObjectCFRQ34nw4r3g3d8LightObjRCQ34nw4r4math5MTX34 = .text:0x804AA090; // type:function size:0x144 CopyFromG3D__Q23EGG11LightObjectFRCQ34nw4r3g3d11ResAnmLightfPQ23EGG11LightObjectb = .text:0x804AA1E0; // type:function size:0xD8 -ApplyAnmResultInner__Q23EGG11LightObjectFRCQ34nw4r3g3d14LightAnmResult = .text:0x804AA2C0; // type:function size:0x9C -ApplyAnmResultA__Q23EGG11LightObjectFRCQ34nw4r3g3d14LightAnmResult = .text:0x804AA360; // type:function size:0x168 -ApplyAnmResultB__Q23EGG11LightObjectFRCQ34nw4r3g3d14LightAnmResult = .text:0x804AA4D0; // type:function size:0xA8 +ImportAnmG3D__Q23EGG11LightObjectFRCQ34nw4r3g3d14LightAnmResult = .text:0x804AA2C0; // type:function size:0x9C +ImportAnmG3D_Diff__Q23EGG11LightObjectFRCQ34nw4r3g3d14LightAnmResult = .text:0x804AA360; // type:function size:0x168 +ImportAnmG3D_Spec__Q23EGG11LightObjectFRCQ34nw4r3g3d14LightAnmResult = .text:0x804AA4D0; // type:function size:0xA8 CalcDirDist__Q23EGG11LightObjectFv = .text:0x804AA580; // type:function size:0xD4 CalcAt__Q23EGG11LightObjectFv = .text:0x804AA660; // type:function size:0x44 SetPos__Q23EGG11LightObjectFRCQ34nw4r4math4VEC3 = .text:0x804AA6B0; // type:function size:0x1C @@ -26634,10 +26634,10 @@ GetBinaryInner__Q23EGG11LightObjectCFPQ33EGG28IBinary3Bin = SetBinaryInner__Q23EGG11LightObjectFRCQ33EGG28IBinary3BinRCQ33EGG28IBinary3Binf = .text:0x804AAC60; // type:function size:0x5EC GetBinaryType__Q23EGG29IBinaryFv = .text:0x804AB250; // type:function size:0x8 GetVersion__Q23EGG29IBinaryFv = .text:0x804AB260; // type:function size:0x8 -fn_804AB270__Q23EGG12LightTextureFv = .text:0x804AB270; // type:function size:0x9C -fn_804AB310__Q23EGG12LightTextureFRC8_GXColor = .text:0x804AB310; // type:function size:0x124 -fn_804AB440__Q23EGG12LightTextureFv = .text:0x804AB440; // type:function size:0x1B4 -fn_804AB600__Q23EGG12LightTextureFv = .text:0x804AB600; // type:function size:0x180 +setMaterialCommon__29@unnamed@eggLightTexture_cpp@Fv = .text:0x804AB270; // type:function size:0x9C +setMaterialAmbient__29@unnamed@eggLightTexture_cpp@FRC8_GXColor = .text:0x804AB310; // type:function size:0x124 +setMaterialNormalSphere__29@unnamed@eggLightTexture_cpp@Fv = .text:0x804AB440; // type:function size:0x1B4 +setMaterialCrossOver__29@unnamed@eggLightTexture_cpp@Fv = .text:0x804AB600; // type:function size:0x180 initialize__Q23EGG12LightTextureFUsPQ23EGG4Heap = .text:0x804AB780; // type:function size:0x26C __ct__Q23EGG12LightTextureFPCcPCQ23EGG19LightTextureManager = .text:0x804AB9F0; // type:function size:0x284 __dt__Q23EGG12LightTextureFv = .text:0x804ABC80; // type:function size:0x90 @@ -26783,7 +26783,7 @@ GXSetAlphaUpdate___Q23EGG7StateGXFb = .text:0x804B50F0; // type:function size:0x GXSetDither___Q23EGG7StateGXFb = .text:0x804B5140; // type:function size:0x4C GXCopyTex___Q23EGG7StateGXFPvb = .text:0x804B5190; // type:function size:0x8 GXSetDstAlpha___Q23EGG7StateGXFbUc = .text:0x804B51A0; // type:function size:0x4C -CalculateScreenScissor__Q23EGG7StateGXFPCfPUl = .text:0x804B51F0; // type:function size:0x108 +GetScissorSafeParam__Q23EGG7StateGXFPCfPUl = .text:0x804B51F0; // type:function size:0x108 GXSetProjection___Q23EGG7StateGXFPA4_f17_GXProjectionType = .text:0x804B5300; // type:function size:0x2C GXSetProjectionv___Q23EGG7StateGXFPCf = .text:0x804B5330; // type:function size:0x2C GXSetViewport___Q23EGG7StateGXFffffff = .text:0x804B5360; // type:function size:0x2C @@ -29198,24 +29198,24 @@ gRMO_Pal60_640x456IntDf_4x3__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB908; // t gRMO_Pal50_640x456IntDf_4x3__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB944; // type:object size:0x3C scope:local gRMO_Ntsc_640x456Prog_4x3__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB980; // type:object size:0x3C scope:local gRMO_Ntsc_640x456IntDf_4x3__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB9BC; // type:object size:0x3C scope:local -renderModes__3EGG = .rodata:0x804FB9F8; // type:object size:0x28 scope:local +gStandardRenderModeObjSet__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB9F8; // type:object size:0x28 scope:local @4804 = .rodata:0x804FBA20; // type:object size:0x10 scope:local data:4byte copyArg2__3EGG = .rodata:0x804FBA30; // type:object size:0x18 scope:local sVtxTypes__3EGG = .rodata:0x804FBA60; // type:object size:0x10 @LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@sVtxDataType0 = .rodata:0x804FBA80; // type:object size:0x30 align:32 @LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@sNrmDataType0@0 = .rodata:0x804FBAC0; // type:object size:0x24 align:32 -@LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@sVtxDataType7@1 = .rodata:0x804FBB00; // type:object size:0x10 align:32 -@LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@sVtxDataType9@4 = .rodata:0x804FBB20; // type:object size:0x18 align:32 -s_ZMode__Q23EGG6DrawGX = .rodata:0x804FBB38; // type:object size:0x30 -s_Blend__Q23EGG6DrawGX = .rodata:0x804FBB68; // type:object size:0xF0 +@LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@QUAD_VTX@1 = .rodata:0x804FBB00; // type:object size:0x10 align:32 +@LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@QUAD_VTX@4 = .rodata:0x804FBB20; // type:object size:0x18 align:32 +@LOCAL@SetZMode__Q23EGG6DrawGXFQ33EGG6DrawGX5ZMode@Z_ARG = .rodata:0x804FBB38; // type:object size:0x30 +@LOCAL@SetBlendMode__Q23EGG6DrawGXFQ33EGG6DrawGX5Blend@BLEND = .rodata:0x804FBB68; // type:object size:0xF0 lbl_804FBC58 = .rodata:0x804FBC58; // type:object size:0x18 lbl_804FBC70 = .rodata:0x804FBC70; // type:object size:0xC lbl_804FBC7C = .rodata:0x804FBC7C; // type:object size:0xC -zeroVec__3EGG = .rodata:0x804FBC88; // type:object size:0xC align:4 data:float -sTevkColorArg__3EGG = .rodata:0x804FBC98; // type:object size:0xC scope:local data:4byte +ZERO_VEC__28@unnamed@eggLightObject_cpp@ = .rodata:0x804FBC88; // type:object size:0xC align:4 data:float +TEV_MAIN_COLOR__29@unnamed@eggLightTexture_cpp@ = .rodata:0x804FBC98; // type:object size:0xC scope:local data:4byte ...rodata.0 = .rodata:0x804FBC98; // type:label scope:local -sTevkColorSel__3EGG = .rodata:0x804FBCA4; // type:object size:0xC scope:local data:4byte -sIndTexMtxId__3EGG = .rodata:0x804FBCB0; // type:object size:0xC scope:local data:4byte +TEV_SUB_COLOR__29@unnamed@eggLightTexture_cpp@ = .rodata:0x804FBCA4; // type:object size:0xC scope:local data:4byte +TEV_MTX_ID__29@unnamed@eggLightTexture_cpp@ = .rodata:0x804FBCB0; // type:object size:0xC scope:local data:4byte @LOCAL@initialize__Q23EGG12LightTextureFUsPQ23EGG4Heap@sCpuTexGradientOp = .rodata:0x804FBCC0; // type:object size:0x48 scope:local data:4byte sFaceMin__3EGG = .rodata:0x804FBD08; // type:object size:0xC scope:local align:4 data:float ...rodata.0 = .rodata:0x804FBD08; // type:label scope:local @@ -29227,10 +29227,10 @@ lbl_804FBD50 = .rodata:0x804FBD50; // type:object size:0x10 align:4 data:float lbl_804FBD60 = .rodata:0x804FBD60; // type:object size:0x10 align:4 data:float lbl_804FBD70 = .rodata:0x804FBD70; // type:object size:0x18 lbl_804FBD88 = .rodata:0x804FBD88; // type:object size:0x18 data:4byte -identity__24@unnamed@eggStateGX_cpp@ = .rodata:0x804FBDA0; // type:object size:0x30 scope:local +IDENTITY__24@unnamed@eggStateGX_cpp@ = .rodata:0x804FBDA0; // type:object size:0x30 scope:local @LOCAL@setTMemLayout__Q23EGG7StateGXFi@numbers = .rodata:0x804FBDD0; // type:object size:0x10 scope:local @LOCAL@setTMemLayout__Q23EGG7StateGXFi@offsets@0 = .rodata:0x804FBDE0; // type:object size:0x10 scope:local -@LOCAL@resetIndirect__Q23EGG7StateGXFv@ind = .rodata:0x804FBDF0; // type:object size:0x18 scope:local +@LOCAL@resetIndirect__Q23EGG7StateGXFv@offsetMtx = .rodata:0x804FBDF0; // type:object size:0x18 scope:local lbl_804FBE08 = .rodata:0x804FBE08; // type:object size:0x10 data:4byte lbl_804FBE18 = .rodata:0x804FBE18; // type:object size:0x40 lbl_804FBE58 = .rodata:0x804FBE58; // type:object size:0xC @@ -39192,7 +39192,7 @@ __vt__Q23EGG12LookAtCamera = .data:0x8056ED30; // type:object size:0x30 __vt__Q23EGG9AnalizeDL = .data:0x8056ED60; // type:object size:0xC scope:weak __vt__Q23EGG10CapTexture = .data:0x8056ED70; // type:object size:0x10 __vt__Q23EGG10CpuTexture = .data:0x8056ED80; // type:object size:0x10 -DummyTexureData = .data:0x8056EDA0; // type:object size:0x40 +@LOCAL@Initialize__Q23EGG6DrawGXFPQ23EGG4Heap@s_clear_z_TX = .data:0x8056EDA0; // type:object size:0x40 jumptable_8056EDE0 = .data:0x8056EDE0; // type:object size:0x38 scope:local jumptable_8056EE18 = .data:0x8056EE18; // type:object size:0x48 scope:local __vt__Q23EGG12DrawPathBase = .data:0x8056EE60; // type:object size:0x50 @@ -41660,13 +41660,13 @@ sWPADWorkSize__Q23EGG17CoreControllerMgr = .sdata:0x80574EE8; // type:object siz @3877 = .sdata:0x80574F00; // type:object size:0x8 scope:local data:string @3879 = .sdata:0x80574F08; // type:object size:0x8 scope:local data:string @3880 = .sdata:0x80574F10; // type:object size:0x7 scope:local data:string -sLightMaskDefault__Q23EGG6DrawGX = .sdata:0x80574F18; // type:object size:0x4 data:4byte +LIGHTMASK_DEFAULT__23@unnamed@eggDrawGX_cpp@ = .sdata:0x80574F18; // type:object size:0x4 data:4byte lbl_80574F20 = .sdata:0x80574F20; // type:object size:0x8 lbl_80574F28 = .sdata:0x80574F28; // type:object size:0x4 -lbl_80574F2C = .sdata:0x80574F2C; // type:object size:0x4 data:4byte +DISABLE_STRING__29@unnamed@eggLightManager_cpp@ = .sdata:0x80574F2C; // type:object size:0x4 data:4byte lbl_80574F30 = .sdata:0x80574F30; // type:object size:0x8 sTextureSize__Q23EGG12LightTexture = .sdata:0x80574F38; // type:object size:0x2 data:2byte -lbl_80574F3A__3EGG = .sdata:0x80574F3A; // type:object size:0x1 scope:local data:byte +sScaleExp__Q23EGG12LightTexture = .sdata:0x80574F3A; // type:object size:0x1 scope:local data:byte @8921 = .sdata:0x80574F3C; // type:object size:0x5 scope:local data:string sByteCodeCalcStr__Q23EGG7ModelEx = .sdata:0x80574F48; // type:object size:0x4 data:4byte @5795 = .sdata:0x80574F50; // type:object size:0x8 scope:local data:string @@ -42961,7 +42961,7 @@ sInstance__Q23EGG17CoreControllerMgr = .sbss:0x805767A8; // type:object size:0x4 sStaticDisposer__Q33EGG17CoreControllerMgr11T__Disposer = .sbss:0x805767AC; // type:object size:0x4 data:4byte sCoreControllerFactory__Q23EGG17CoreControllerMgr = .sbss:0x805767B0; // type:object size:0x4 data:4byte sConnectCallback__Q23EGG17CoreControllerMgr = .sbss:0x805767B4; // type:object size:0x4 data:4byte -sUseBuiltinWpadAllocator__Q23EGG17CoreControllerMgr = .sbss:0x805767B8; // type:object size:0x1 data:byte +sWPADRegisterAllocatorOFF__Q23EGG17CoreControllerMgr = .sbss:0x805767B8; // type:object size:0x1 data:byte sAllocator__Q23EGG27@unnamed@eggController_cpp@ = .sbss:0x805767BC; // type:object size:0x4 scope:local data:4byte zero__Q23EGG8Vector2f = .sbss:0x805767C0; // type:object size:0x8 align:4 data:float ex__Q23EGG8Vector2f = .sbss:0x805767C8; // type:object size:0x8 align:4 data:float @@ -42976,7 +42976,7 @@ sPtrOverride__Q23EGG6Assert = .sbss:0x80576800; // type:object size:0x4 data:4by sInstantHalt__Q23EGG6Assert = .sbss:0x80576804; // type:object size:0x1 data:byte sAssertOccurred__Q23EGG6Assert = .sbss:0x80576805; // type:object size:0x1 data:byte s_flag__Q23EGG6DrawGX = .sbss:0x80576808; // type:object size:0x4 data:4byte -sTexMapDefault__Q23EGG6DrawGX = .sbss:0x8057680C; // type:object size:0x4 data:4byte +TEXMAP_DEFAULT__23@unnamed@eggDrawGX_cpp@ = .sbss:0x8057680C; // type:object size:0x4 data:4byte sGlobalScale__Q23EGG7Frustum = .sbss:0x80576810; // type:object size:0x8 align:4 data:float sGlobalOffset__Q23EGG7Frustum = .sbss:0x80576818; // type:object size:0x8 align:4 data:float sId__Q23EGG10G3DUtility = .sbss:0x80576820; // type:object size:0x1 data:byte @@ -50480,7 +50480,7 @@ lbl_8057F6BC = .sdata2:0x8057F6BC; // type:object size:0x4 align:4 data:float @9007 = .sdata2:0x8057F6C0; // type:object size:0x4 scope:local align:4 data:float @9008 = .sdata2:0x8057F6C4; // type:object size:0x4 scope:local align:4 data:float @9044 = .sdata2:0x8057F6C8; // type:object size:0x4 scope:local align:4 data:float -@LOCAL@initDrawSetting__Q23EGG12LightTextureFUsUsUsUs@sVtxBuf = .sdata2:0x8057F6E0; // type:object size:0x8 scope:local +@LOCAL@initDrawSetting__Q23EGG12LightTextureFUsUsUsUs@vtx = .sdata2:0x8057F6E0; // type:object size:0x8 scope:local @9079 = .sdata2:0x8057F6E8; // type:object size:0x8 scope:local align:8 data:double @9165 = .sdata2:0x8057F6F0; // type:object size:0x4 scope:local align:4 data:float @9170 = .sdata2:0x8057F6F8; // type:object size:0x8 scope:local align:8 data:double @@ -50559,7 +50559,7 @@ lbl_8057F874 = .sdata2:0x8057F874; // type:object size:0x4 align:4 data:float lbl_8057F878 = .sdata2:0x8057F878; // type:object size:0x4 align:4 data:float lbl_8057F880 = .sdata2:0x8057F880; // type:object size:0x8 align:8 data:double lbl_8057F888 = .sdata2:0x8057F888; // type:object size:0x4 align:4 data:float -white__24@unnamed@eggStateGX_cpp@ = .sdata2:0x8057F890; // type:object size:0x4 scope:local data:4byte +WHITE__24@unnamed@eggStateGX_cpp@ = .sdata2:0x8057F890; // type:object size:0x4 scope:local data:4byte @4136 = .sdata2:0x8057F894; // type:object size:0x4 scope:local align:4 data:float @4227 = .sdata2:0x8057F898; // type:object size:0x4 scope:local align:4 data:float @4228 = .sdata2:0x8057F89C; // type:object size:0x4 scope:local align:4 data:float @@ -52554,7 +52554,7 @@ ez__Q23EGG8Vector3f = .bss:0x80674C54; // type:object size:0xC data:float buf__Q23EGG6Assert = .bss:0x80674C60; // type:object size:0x104 s_DL__Q23EGG6DrawGX = .bss:0x80674D68; // type:object size:0x90 s_cameraMtx__Q23EGG6DrawGX = .bss:0x80674DF8; // type:object size:0x30 align:4 data:float -sDummyTexObj__Q23EGG6DrawGX = .bss:0x80674E28; // type:object size:0x20 +CLEAR_Z_TEX_OBJ__23@unnamed@eggDrawGX_cpp@ = .bss:0x80674E28; // type:object size:0x20 sMtx__Q23EGG15GlobalDrawState = .bss:0x80674E48; // type:object size:0x30 sCpuTexArray__3EGG = .bss:0x80674E78; // type:object size:0x48 scope:local data:4byte sIdentityMtx__3EGG = .bss:0x80674EC0; // type:object size:0x30 scope:local align:4 data:float @@ -52564,11 +52564,11 @@ sScreen__Q23EGG16ScreenEffectBase = .bss:0x80674F88; // type:object size:0x88 spBufferSet__Q23EGG8StateEfb = .bss:0x80675010; // type:object size:0x30 sWorkSpaceV__Q23EGG8StateEfb = .bss:0x80675040; // type:object size:0x18 align:4 data:float sWorkSpaceHideV__Q23EGG8StateEfb = .bss:0x80675058; // type:object size:0x18 align:4 data:float -sUnkBuffer__Q23EGG8StateEfb = .bss:0x80675070; // type:object size:0x18 align:4 data:float -sDefaultTexObj__Q23EGG7StateGX = .bss:0x806750A0; // type:object size:0x20 +sShiftViewPort__Q23EGG8StateEfb = .bss:0x80675070; // type:object size:0x18 align:4 data:float +DUMMY_TEX_OBJ__24@unnamed@eggStateGX_cpp@ = .bss:0x806750A0; // type:object size:0x20 s_tmem_layout__Q23EGG7StateGX = .bss:0x806750C0; // type:object size:0xA8 data:4byte s_cacheGX__Q23EGG7StateGX = .bss:0x80675168; // type:object size:0x18 -@LOCAL@initialize__Q23EGG7StateGXFUsUs8_GXColor11_GXPixelFmt@sDefaultTexObjData = .bss:0x80675180; // type:object size:0x10 scope:local +@LOCAL@initialize__Q23EGG7StateGXFUsUs8_GXColor11_GXPixelFmt@NullTexData = .bss:0x80675180; // type:object size:0x10 scope:local spBufferTable__Q23EGG13TextureBuffer = .bss:0x80675190; // type:object size:0x200 data:4byte sConnectTask__Q23EGG18AudioRmtSpeakerMgr = .bss:0x80675390; // type:object size:0xF0 sMoveParamMgr__Q23EGG12AudioUtility = .bss:0x80675480; // type:object size:0xC diff --git a/include/egg/core/eggController.h b/include/egg/core/eggController.h index e8414b13..a790b667 100644 --- a/include/egg/core/eggController.h +++ b/include/egg/core/eggController.h @@ -362,7 +362,7 @@ private: static CoreControllerFactory sCoreControllerFactory; static CoreControllerConnectCallback sConnectCallback; - static bool sUseBuiltinWpadAllocator; + static bool sWPADRegisterAllocatorOFF; static s32 sWPADWorkSize; }; diff --git a/include/egg/gfx/eggDrawGX.h b/include/egg/gfx/eggDrawGX.h index e7e944af..862792f8 100644 --- a/include/egg/gfx/eggDrawGX.h +++ b/include/egg/gfx/eggDrawGX.h @@ -172,14 +172,6 @@ public: static const DL s_DL7; static const DL s_DL8; - static const ZModeConfig s_ZMode[ZMODE_MAX]; - static const BlendModeConfig s_Blend[BLEND_MAX]; - static GXTexObj sDummyTexObj; - // not sure end - - static GXTexMapID sTexMapDefault; - static GXLightID sLightMaskDefault; - static nw4r::math::MTX34 s_cameraMtx; static u32 s_flag; diff --git a/include/egg/gfx/eggLightObject.h b/include/egg/gfx/eggLightObject.h index a072e190..c6dcd9a9 100644 --- a/include/egg/gfx/eggLightObject.h +++ b/include/egg/gfx/eggLightObject.h @@ -52,9 +52,9 @@ public: void CopyToG3D_View(nw4r::g3d::LightObj &, const nw4r::math::MTX34 &) const; void CopyFromG3D(const nw4r::g3d::ResAnmLight &, f32, EGG::LightObject *, bool); - void ApplyAnmResultInner(const nw4r::g3d::LightAnmResult &); - void ApplyAnmResultA(const nw4r::g3d::LightAnmResult &); - bool ApplyAnmResultB(const nw4r::g3d::LightAnmResult &); + void ImportAnmG3D(const nw4r::g3d::LightAnmResult &); + void ImportAnmG3D_Diff(const nw4r::g3d::LightAnmResult &); + bool ImportAnmG3D_Spec(const nw4r::g3d::LightAnmResult &); void CalcAt(); void SetPos(const nw4r::math::VEC3 &); diff --git a/include/egg/gfx/eggLightTexture.h b/include/egg/gfx/eggLightTexture.h index ef441058..f7c59554 100644 --- a/include/egg/gfx/eggLightTexture.h +++ b/include/egg/gfx/eggLightTexture.h @@ -92,11 +92,6 @@ public: static void getTexDimensions(u16 *, u16 *, u16 *, u16 *, u16); private: - static void fn_804AB270(); - static void fn_804AB310(const GXColor &color); - static void fn_804AB440(); - static void fn_804AB600(); - static void fn_804AC0A0(int, int *, int *); static void loadTextureData(int index, void *data, GXTexFmt fmt); @@ -125,6 +120,7 @@ private: /* 0x9F */ u8 field_0x9F; static u16 sTextureSize; + static s8 sScaleExp; static u16 sDrawWidth; static u16 sDrawHeight; diff --git a/include/egg/gfx/eggStateEfb.h b/include/egg/gfx/eggStateEfb.h index a1eac8e2..b854e16d 100644 --- a/include/egg/gfx/eggStateEfb.h +++ b/include/egg/gfx/eggStateEfb.h @@ -22,27 +22,28 @@ public: u32 userData; u32 field_0x08; }; + private: static Buffer spBufferSet[BUFFER_MAX]; static f32 sWorkSpaceV[6]; static f32 sWorkSpaceHideV[6]; - static f32 sUnkBuffer[6]; // unk name + static f32 sShiftViewPort[6]; // unk name static s32 sWorkBuffer; static s32 sPushCount; static u32 sFlag; static bool isEnableDirtyBufferMode(); static bool GetUseTfRgb565(); - - public: + +public: static bool CheckFlag0x2() { return (sFlag & 2) != 0; } - + static void Clean(); static TextureBuffer *captureEfb(BufferType type, bool, u32 userData); static bool releaseEfb(BufferType type, u32 userData); - + // Unknown names static void fn_804B4270(BufferType type, u32 userData); static void popWorkBuffer(bool b, u32 userData); diff --git a/include/egg/gfx/eggStateGX.h b/include/egg/gfx/eggStateGX.h index 697e3dc6..4d4e7fd9 100644 --- a/include/egg/gfx/eggStateGX.h +++ b/include/egg/gfx/eggStateGX.h @@ -87,15 +87,13 @@ public: static bool GXSetDither_(bool); static void GXCopyTex_(void *data, bool); static CacheGX &GXSetDstAlpha_(bool, u8); + static void GetScissorSafeParam(const f32 src[4], u32 dst[4]); static void GXSetProjection_(Mtx44, GXProjectionType); static void GXSetProjectionv_(const f32 *); static void GXSetViewport_(f32 ox, f32 oy, f32 sx, f32 sy, f32 near, f32 far); 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_widthEfb; static u16 s_heightEfb; static GXPixelFmt s_pixFormat; @@ -105,8 +103,6 @@ public: static u16 s_commandFlag; static CacheGX s_cacheGX; - // Inofficial names - static GXTexObj sDefaultTexObj; static MemLayout s_tmem_layout; // same name, different type }; diff --git a/src/egg/core/eggController.cpp b/src/egg/core/eggController.cpp index 0fb022ac..ef1ea585 100644 --- a/src/egg/core/eggController.cpp +++ b/src/egg/core/eggController.cpp @@ -20,7 +20,7 @@ CoreControllerMgr::T__Disposer *CoreControllerMgr::T__Disposer::sStaticDisposer; CoreControllerFactory CoreControllerMgr::sCoreControllerFactory; CoreControllerConnectCallback CoreControllerMgr::sConnectCallback; // This controls whether EggController registers an allocator within the WPAD driver -bool CoreControllerMgr::sUseBuiltinWpadAllocator; +bool CoreControllerMgr::sWPADRegisterAllocatorOFF; s32 CoreControllerMgr::sWPADWorkSize = 0x32000; void CoreStatus::init() { @@ -356,7 +356,7 @@ void CoreControllerMgr::connectCallback(s32 a1, s32 a2) { /* 0x80499D10 */ CoreControllerMgr::CoreControllerMgr() { const int idxes[] = {0, 1, 2, 3}; - if (sUseBuiltinWpadAllocator == false) { + if (sWPADRegisterAllocatorOFF == false) { Heap *heap = ExpHeap::create(sWPADWorkSize, BaseSystem::mConfigData->mRootHeapMem2, 0); heap->mName = "EGG::CoreControllerMgr"; sAllocator = new Allocator(heap, 0x20); diff --git a/src/egg/core/eggVideo.cpp b/src/egg/core/eggVideo.cpp index 702343f0..09a74182 100644 --- a/src/egg/core/eggVideo.cpp +++ b/src/egg/core/eggVideo.cpp @@ -296,16 +296,15 @@ const GXRenderModeObj gRMO_Ntsc_640x456IntDf_4x3 = { {0, 0, 21, 22, 21, 0, 0} // vFilter }; -} // namespace - -namespace EGG { - -const EGG::Video::RenderModeObjSet renderModes = { +const EGG::Video::RenderModeObjSet gStandardRenderModeObjSet = { {&gRMO_Pal60_640x456Prog_16x9, &gRMO_Pal60_640x456IntDf_16x9, &gRMO_Pal50_640x456IntDf_16x9, &gRMO_Ntsc_640x456Prog_16x9, &gRMO_Ntsc_640x456IntDf_16x9, &gRMO_Pal60_640x456Prog_4x3, &gRMO_Pal60_640x456IntDf_4x3, &gRMO_Pal50_640x456IntDf_4x3, &gRMO_Ntsc_640x456Prog_4x3, &gRMO_Ntsc_640x456IntDf_4x3} }; +} // namespace + +namespace EGG { void Video::initialize(GXRenderModeObj *obj, const RenderModeObjSet *set) { VIInit(); @@ -315,7 +314,7 @@ void Video::initialize(GXRenderModeObj *obj, const RenderModeObjSet *set) { GXRenderModeObj *Video::configure(GXRenderModeObj *obj, const RenderModeObjSet *set) { GXRenderModeObj *oldMode = pRenderMode; if (set == nullptr) { - set = &renderModes; + set = &gStandardRenderModeObjSet; } if (obj == nullptr) { // Cast away constness. In an incredibly cursed way, adding proper diff --git a/src/egg/gfx/eggCpuTexture.cpp b/src/egg/gfx/eggCpuTexture.cpp index 6fb11fcc..c0d9cd8e 100644 --- a/src/egg/gfx/eggCpuTexture.cpp +++ b/src/egg/gfx/eggCpuTexture.cpp @@ -14,7 +14,7 @@ namespace EGG { namespace { -void calcColorGradient(GXColor &outColor, const GXColor &c1, const GXColor &c2, f32 amount) { +void blendColor(GXColor &outColor, const GXColor &c1, const GXColor &c2, f32 amount) { if (amount <= 0.0f) { outColor = c1; } else if (amount >= 1.0f) { @@ -62,7 +62,7 @@ void makeGradient(int op, GXColor *outColor, u16 size, u16 start, u16 end, const ratio = -ratio * ratio * ratio * ratio + 1.0f; break; } - calcColorGradient(outColor[i], c1, c2, ratio); + blendColor(outColor[i], c1, c2, ratio); } } diff --git a/src/egg/gfx/eggDrawGX.cpp b/src/egg/gfx/eggDrawGX.cpp index 31e973e6..d13efa19 100644 --- a/src/egg/gfx/eggDrawGX.cpp +++ b/src/egg/gfx/eggDrawGX.cpp @@ -36,12 +36,8 @@ const DrawGX::DL DrawGX::s_DL0 = DrawGX::DL_0; const DrawGX::DL DrawGX::s_DL7 = DrawGX::DL_7; const DrawGX::DL DrawGX::s_DL8 = DrawGX::DL_8; -GXTexMapID DrawGX::sTexMapDefault; -GXLightID DrawGX::sLightMaskDefault = GX_LIGHT0; - nw4r::math::MTX34 DrawGX::s_cameraMtx; DrawGX::DLData DrawGX::s_DL[DL_MAX]; -GXTexObj DrawGX::sDummyTexObj; u32 DrawGX::s_flag; @@ -49,6 +45,10 @@ u32 DrawGX::s_flag; namespace { +static GXTexObj CLEAR_Z_TEX_OBJ; +static GXLightID LIGHTMASK_DEFAULT = GX_LIGHT0; +static GXTexMapID TEXMAP_DEFAULT; + static void DrawQuadNormal(u8 x1, u8 x2, u8 x3, u8 x4, u8 y) { GXPosition2u8(x1, y); GXPosition2u8(x2, y); @@ -118,42 +118,42 @@ namespace EGG { static DrawGX sDrawGX; -static u8 DummyTextureData[64] = { - // clang-format off -0x00, 0xFF, 0x00, 0xFF, -0x00, 0xFF, 0x00, 0xFF, -0x00, 0xFF, 0x00, 0xFF, -0x00, 0xFF, 0x00, 0xFF, -0x00, 0xFF, 0x00, 0xFF, -0x00, 0xFF, 0x00, 0xFF, -0x00, 0xFF, 0x00, 0xFF, -0x00, 0xFF, 0x00, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, - // clang-format on -}; - void DrawGX::Initialize(Heap *pHeap_) { - 2.0f; // cool + 2.0f; // cool+ + + static u8 s_clear_z_TX[64] = { + // clang-format off + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + // clang-format on + }; Heap *pHeap = pHeap_ == nullptr ? Heap::getCurrentHeap() : pHeap_; - GXInitTexObj(&sDummyTexObj, DummyTextureData, 4, 4, GX_TF_Z24X8, GX_REPEAT, GX_REPEAT, false); - GXInitTexObjLOD(&sDummyTexObj, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, 0, 0, GX_ANISO_1); + GXInitTexObj(&CLEAR_Z_TEX_OBJ, s_clear_z_TX, 4, 4, GX_TF_Z24X8, GX_REPEAT, GX_REPEAT, false); + GXInitTexObjLOD(&CLEAR_Z_TEX_OBJ, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, 0, 0, GX_ANISO_1); PSMTXIdentity(s_cameraMtx.m); CreateDisplayList(pHeap); } GXTexMapID DrawGX::GetTexMapDefault() { - return sTexMapDefault; + return TEXMAP_DEFAULT; } GXLightID DrawGX::GetLightMaskDefault() { - return sLightMaskDefault; + return LIGHTMASK_DEFAULT; } void DrawGX::BeginDrawLine(ColorChannel chan, ZMode zMode) { @@ -240,7 +240,7 @@ void DrawGX::ClearEfb( GXSetCullMode(GX_CULL_NONE); if (b3) { SetMat_TexGen(TEXGEN_1); - GXLoadTexObj(&sDummyTexObj, sTexMapDefault); + GXLoadTexObj(&CLEAR_Z_TEX_OBJ, TEXMAP_DEFAULT); } else { SetMat_TexGen(TEXGEN_0); } @@ -252,7 +252,7 @@ void DrawGX::ClearEfb( GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0); GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); if (b3) { - GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, sTexMapDefault, GX_COLOR_NULL); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, TEXMAP_DEFAULT, GX_COLOR_NULL); } else { GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); } @@ -336,7 +336,7 @@ void DrawGX::SetMat_Tev(GXTevStageID stageId, enum TevSetting setting) { break; case TEV_2: GXSetTevDirect(stageId); - GXSetTevOrder(stageId, GX_TEXCOORD0, sTexMapDefault, GX_COLOR0A0); + GXSetTevOrder(stageId, GX_TEXCOORD0, TEXMAP_DEFAULT, GX_COLOR0A0); GXSetTevSwapMode(stageId, GX_TEV_SWAP0, GX_TEV_SWAP0); GXSetTevColorIn(stageId, GX_CC_ZERO, GX_CC_TEXC, GX_CC_RASC, GX_CC_ZERO); GXSetTevColorOp(stageId, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV); @@ -345,7 +345,7 @@ void DrawGX::SetMat_Tev(GXTevStageID stageId, enum TevSetting setting) { break; case TEV_1: GXSetTevDirect(stageId); - GXSetTevOrder(stageId, GX_TEXCOORD0, sTexMapDefault, GX_COLOR0A0); + GXSetTevOrder(stageId, GX_TEXCOORD0, TEXMAP_DEFAULT, GX_COLOR0A0); GXSetTevSwapMode(stageId, GX_TEV_SWAP0, GX_TEV_SWAP0); GXSetTevColorIn(stageId, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC); GXSetTevColorOp(stageId, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV); @@ -377,7 +377,7 @@ void DrawGX::LoadTexture(nw4r::g3d::ResTex tex, GXTexMapID texMapId) { void DrawGX::SetVtxState(EGG::DrawGX::VtxType type) { GXClearVtxDesc(); switch (type) { - case VTX_TYPE_0: + case VTX_TYPE_0: { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0xe); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_S16, 0xe); // clang-format off @@ -405,16 +405,18 @@ void DrawGX::SetVtxState(EGG::DrawGX::VtxType type) { GXSetVtxDesc(GX_VA_POS, GX_INDEX8); GXSetVtxDesc(GX_VA_NRM, GX_INDEX8); break; + } case VTX_TYPE_2: case VTX_TYPE_3: case VTX_TYPE_4: - case VTX_TYPE_5: + case VTX_TYPE_5: { GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxDesc(GX_VA_NRM, GX_DIRECT); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); break; - case VTX_TYPE_6: + } + case VTX_TYPE_6: { GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxDesc(GX_VA_NRM, GX_DIRECT); GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); @@ -422,23 +424,25 @@ void DrawGX::SetVtxState(EGG::DrawGX::VtxType type) { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); break; - case VTX_TYPE_1: + } + case VTX_TYPE_1: { GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); break; + } case VTX_TYPE_7: - case VTX_TYPE_8: + case VTX_TYPE_8: { // clang-format off - static const ALIGN_DECL(32) s16 sVtxDataType7[][2] = { + static const ALIGN_DECL(32) s16 QUAD_VTX[][2] = { {0xE000, 0x2000}, {0x2000, 0x2000}, {0x2000, 0xE000}, {0xE000, 0xE000}, }; - static const ALIGN_DECL(32) s16 sNrmDataType7[][3] = { + static const ALIGN_DECL(32) s16 QUAD_NRM[][3] = { {0x0000, 0x0000, 0x4000} }; - static const ALIGN_DECL(32) u8 sTexDataType7[][2] = { + static const ALIGN_DECL(32) u8 QUAD_UV[][2] = { {0x00, 0x00}, {0x01, 0x00}, {0x01, 0x01}, @@ -455,21 +459,22 @@ void DrawGX::SetVtxState(EGG::DrawGX::VtxType type) { if (type == VTX_TYPE_7) { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U8, 0); } - GXSetArray(GX_VA_POS, sVtxDataType7, 4); - GXSetArray(GX_VA_NRM, sNrmDataType7, 6); + GXSetArray(GX_VA_POS, QUAD_VTX, 4); + GXSetArray(GX_VA_NRM, QUAD_NRM, 6); if (type == VTX_TYPE_7) { - GXSetArray(GX_VA_TEX0, sTexDataType7, 2); + GXSetArray(GX_VA_TEX0, QUAD_UV, 2); } break; - case VTX_TYPE_9: + } + case VTX_TYPE_9: { // clang-format off - static const ALIGN_DECL(32) s16 sVtxDataType9[][3] = { + static const ALIGN_DECL(32) s16 QUAD_VTX[][3] = { {0xE000, 0x0000, 0xE000}, {0x2000, 0x0000, 0xE000}, {0x2000, 0x0000, 0x2000}, {0xE000, 0x0000, 0x2000}, }; - static const ALIGN_DECL(32) s16 sNrmDataType9[][3] = { + static const ALIGN_DECL(32) s16 QUAD_NRM[][3] = { {0x0000, 0x4000, 0x0000} }; // clang-format on @@ -477,21 +482,22 @@ void DrawGX::SetVtxState(EGG::DrawGX::VtxType type) { GXSetVtxDesc(GX_VA_NRM, GX_INDEX8); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0xe); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_S16, 0xe); - GXSetArray(GX_VA_POS, sVtxDataType9, 6); - GXSetArray(GX_VA_NRM, sNrmDataType9, 6); + GXSetArray(GX_VA_POS, QUAD_VTX, 6); + GXSetArray(GX_VA_NRM, QUAD_NRM, 6); break; + } case VTX_TYPE_10: case VTX_TYPE_11: case VTX_TYPE_12: case VTX_TYPE_13: { // clang-format off - static const ALIGN_DECL(32) u8 sPosDataType10[][2] = { + static const ALIGN_DECL(32) u8 SCREEN_VTX[][2] = { {0x00, 0x01}, {0x01, 0x01}, {0x01, 0x00}, {0x00, 0x00}, }; - static const ALIGN_DECL(32) u8 sTexDataType10[][2] = { + static const ALIGN_DECL(32) u8 SCREEN_VTX_LU[][2] = { {0x00, 0x00}, {0x01, 0x00}, {0x01, 0x01}, @@ -504,9 +510,9 @@ void DrawGX::SetVtxState(EGG::DrawGX::VtxType type) { if (bVar2) { GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8); } - GXSetArray(GX_VA_POS, bVar1 ? sTexDataType10 : sPosDataType10, 2); + GXSetArray(GX_VA_POS, bVar1 ? SCREEN_VTX_LU : SCREEN_VTX, 2); if (bVar2) { - GXSetArray(GX_VA_TEX0, sTexDataType10, 2); + GXSetArray(GX_VA_TEX0, SCREEN_VTX_LU, 2); } GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_U8, 0); if (bVar2) { @@ -683,38 +689,36 @@ void DrawGX::DrawDL(enum DL dl, const nw4r::math::MTX34 &mtx, GXColor clr) { GXCallDisplayList(s_DL[dl].mpList, s_DL[dl].mLen); } -const DrawGX::ZModeConfig DrawGX::s_ZMode[ZMODE_MAX] = { - {false, GX_ALWAYS, false}, - { true, GX_LEQUAL, true}, - { true, GX_LEQUAL, false}, - { true, GX_ALWAYS, true}, -}; - void DrawGX::SetZMode(enum ZMode mode) { - GXSetZMode(s_ZMode[mode].mTest, s_ZMode[mode].mCompare, s_ZMode[mode].mUpdate); + static const DrawGX::ZModeConfig Z_ARG[ZMODE_MAX] = { + {false, GX_ALWAYS, false}, + { true, GX_LEQUAL, true}, + { true, GX_LEQUAL, false}, + { true, GX_ALWAYS, true}, + }; + GXSetZMode(Z_ARG[mode].mTest, Z_ARG[mode].mCompare, Z_ARG[mode].mUpdate); } -const DrawGX::BlendModeConfig DrawGX::s_Blend[BLEND_MAX] = { - { GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_INVSRCALPHA, GX_BL_SRCALPHA, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_ONE, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_SRCCLR, GX_BL_ONE, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_INVSRCCLR, GX_BL_ONE, GX_LO_CLEAR}, - {GX_BM_SUBTRACT, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_ZERO, GX_BL_SRCCLR, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_ZERO, GX_BL_INVSRCCLR, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_DSTALPHA, GX_BL_INVDSTALPHA, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_INVDSTALPHA, GX_BL_DSTALPHA, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_DSTALPHA, GX_BL_ONE, GX_LO_CLEAR}, - { GX_BM_BLEND, GX_BL_INVDSTALPHA, GX_BL_ONE, GX_LO_CLEAR}, - { GX_BM_NONE, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR}, -}; - void DrawGX::SetBlendMode(enum Blend mode) { + static const DrawGX::BlendModeConfig BLEND[BLEND_MAX] = { + { GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_INVSRCALPHA, GX_BL_SRCALPHA, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_ONE, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_SRCCLR, GX_BL_ONE, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_INVSRCCLR, GX_BL_ONE, GX_LO_CLEAR}, + {GX_BM_SUBTRACT, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_ZERO, GX_BL_SRCCLR, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_ZERO, GX_BL_INVSRCCLR, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_DSTALPHA, GX_BL_INVDSTALPHA, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_INVDSTALPHA, GX_BL_DSTALPHA, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_DSTALPHA, GX_BL_ONE, GX_LO_CLEAR}, + { GX_BM_BLEND, GX_BL_INVDSTALPHA, GX_BL_ONE, GX_LO_CLEAR}, + { GX_BM_NONE, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR}, + }; GXSetBlendMode( - s_Blend[mode].mBlendMode, s_Blend[mode].mBlendFactorSrc, s_Blend[mode].mBlendFactorDst, s_Blend[mode].mLogicOp + BLEND[mode].mBlendMode, BLEND[mode].mBlendFactorSrc, BLEND[mode].mBlendFactorDst, BLEND[mode].mLogicOp ); } diff --git a/src/egg/gfx/eggLightObject.cpp b/src/egg/gfx/eggLightObject.cpp index baf6a6a8..6bf66ef1 100644 --- a/src/egg/gfx/eggLightObject.cpp +++ b/src/egg/gfx/eggLightObject.cpp @@ -31,12 +31,15 @@ int IBinary::GetVersion() { } // why -static const f32 zeroVec[3] = {0.0f, 0.0f, 0.0f}; +namespace { + +static const f32 ZERO_VEC[3] = {0.0f, 0.0f, 0.0f}; +} LightObject::LightObject() : mIndex(0), field_0x06(0), - mAt(zeroVec), + mAt(ZERO_VEC), mPos(-10000.0f, 10000.0f, 10000.0f), mDir(0.0f, -1.0f, 0.0f), mWhite(DrawGX::WHITE), @@ -54,7 +57,7 @@ LightObject::LightObject() mFlags(0x661) {} void LightObject::Reset() { - SetPosAt(nw4r::math::VEC3(-10000.0f, 10000.0f, 10000.0f), zeroVec); + SetPosAt(nw4r::math::VEC3(-10000.0f, 10000.0f, 10000.0f), ZERO_VEC); mFlags = 0x661; mWhite = DrawGX::WHITE; mBlack = DrawGX::BLACK; @@ -149,12 +152,12 @@ void LightObject::InitGX(GXLightObj *obj) const { case 1: { nw4r::math::VEC3 tmp = field_0x94 * -1e10f; GXInitLightPos(obj, tmp.x, tmp.y, tmp.z); - GXInitLightDir(obj, zeroVec[0], zeroVec[1], zeroVec[2]); + GXInitLightDir(obj, ZERO_VEC[0], ZERO_VEC[1], ZERO_VEC[2]); break; } case 0: { GXInitLightPos(obj, mViewPos.x, mViewPos.y, mViewPos.z); - GXInitLightDir(obj, zeroVec[0], zeroVec[1], zeroVec[2]); + GXInitLightDir(obj, ZERO_VEC[0], ZERO_VEC[1], ZERO_VEC[2]); break; } case 2: { @@ -259,8 +262,8 @@ void LightObject::CopyFromG3D( g3dLight.GetAnmResult(&result, frame); if (!skipDoingSomething || (result.flags & nw4r::g3d::LightAnmResult::FLAG_LIGHT_ENABLE) != 0) { if ((result.flags & nw4r::g3d::LightAnmResult::FLAG_LIGHT_ENABLE) != 0) { - ApplyAnmResultA(result); - if (optObj != nullptr && optObj->ApplyAnmResultB(result)) { + ImportAnmG3D_Diff(result); + if (optObj != nullptr && optObj->ImportAnmG3D_Spec(result)) { optObj->field_0x06 = mIndex; optObj->mFlags |= 2; } @@ -273,7 +276,7 @@ void LightObject::CopyFromG3D( } } -void LightObject::ApplyAnmResultInner(const nw4r::g3d::LightAnmResult &res) { +void LightObject::ImportAnmG3D(const nw4r::g3d::LightAnmResult &res) { // TODO mFlags = mFlags & 0xF07E; mCutoff = 90.0f; @@ -298,8 +301,8 @@ void LightObject::ApplyAnmResultInner(const nw4r::g3d::LightAnmResult &res) { } } -void LightObject::ApplyAnmResultA(const nw4r::g3d::LightAnmResult &res) { - ApplyAnmResultInner(res); +void LightObject::ImportAnmG3D_Diff(const nw4r::g3d::LightAnmResult &res) { + ImportAnmG3D(res); switch ((int)(res.flags & nw4r::g3d::LightAnmResult::FLAG_LIGHT_TYPE_MASK)) { case 0: { field_0x3D = 0; @@ -334,9 +337,9 @@ void LightObject::ApplyAnmResultA(const nw4r::g3d::LightAnmResult &res) { } } -bool LightObject::ApplyAnmResultB(const nw4r::g3d::LightAnmResult &res) { +bool LightObject::ImportAnmG3D_Spec(const nw4r::g3d::LightAnmResult &res) { if ((res.flags & nw4r::g3d::LightAnmResult::FLAG_SPECULAR_ENABLE) != 0) { - ApplyAnmResultInner(res); + ImportAnmG3D(res); field_0x3D = 1; mWhite = res.specColor; SetPosAt(res.pos, res.aim); diff --git a/src/egg/gfx/eggLightTexture.cpp b/src/egg/gfx/eggLightTexture.cpp index edf02b41..b8b823ca 100644 --- a/src/egg/gfx/eggLightTexture.cpp +++ b/src/egg/gfx/eggLightTexture.cpp @@ -42,7 +42,7 @@ bool LightTexture::sUseDebug; u16 LightTexture::sTextureSize = 0x20; -static s8 lbl_80574F3A = 0xFE; +s8 LightTexture::sScaleExp = 0xFE; template <> const char *IBinary::GetBinaryType() { @@ -53,18 +53,25 @@ template <> int IBinary::GetVersion() { return 3; } +} // namespace EGG -void LightTexture::fn_804AB270() { +namespace { + +static const GXTevColorArg TEV_MAIN_COLOR[3] = {GX_CC_C0, GX_CC_C1, GX_CC_C2}; +static const GXTevKColorSel TEV_SUB_COLOR[3] = {GX_TEV_KCSEL_K0, GX_TEV_KCSEL_K1, GX_TEV_KCSEL_K2}; +static const GXIndTexMtxID TEV_MTX_ID[3] = {GX_ITM_0, GX_ITM_1, GX_ITM_2}; + +void setMaterialCommon() { GXSetNumChans(1); GXSetCullMode(GX_CULL_BACK); GXSetChanCtrl(GX_COLOR0A0, false, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_SIGN, GX_AF_NONE); GXSetChanCtrl(GX_COLOR1A1, false, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); GXSetZMode(false, GX_LEQUAL, false); - EGG::DrawGX::SetBlendMode(DrawGX::BLEND_14); + EGG::DrawGX::SetBlendMode(EGG::DrawGX::BLEND_14); } -void LightTexture::fn_804AB310(const GXColor &color) { +void setMaterialAmbient(const GXColor &color) { GXSetNumTexGens(0); GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x3c, 0, 0x7d); GXSetNumIndStages(0); @@ -79,14 +86,9 @@ void LightTexture::fn_804AB310(const GXColor &color) { GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV); GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); - EGG::DrawGX::SetBlendMode(DrawGX::BLEND_14); + EGG::DrawGX::SetBlendMode(EGG::DrawGX::BLEND_14); } - -static const GXTevColorArg sTevkColorArg[3] = {GX_CC_C0, GX_CC_C1, GX_CC_C2}; -static const GXTevKColorSel sTevkColorSel[3] = {GX_TEV_KCSEL_K0, GX_TEV_KCSEL_K1, GX_TEV_KCSEL_K2}; -static const GXIndTexMtxID sIndTexMtxId[3] = {GX_ITM_0, GX_ITM_1, GX_ITM_2}; - -void LightTexture::fn_804AB440() { +void setMaterialNormalSphere() { GXSetNumTexGens(1); GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x3c, 0, 0x7d); GXSetNumIndStages(1); @@ -101,20 +103,20 @@ void LightTexture::fn_804AB440() { GXSetTevSwapMode(id, GX_TEV_SWAP0, GX_TEV_SWAP0); GXSetTevOrder(id, GX_TEXCOORD_NULL, static_cast(GX_TEXMAP1 + i), GX_COLOR_NULL); - GXSetTevKColorSel(id, sTevkColorSel[i]); + GXSetTevKColorSel(id, TEV_SUB_COLOR[i]); GXSetTevKAlphaSel(id, GX_TEV_KASEL_1); - GXSetTevColorIn(id, GX_CC_KONST, sTevkColorArg[i], GX_CC_TEXC, tevColorArg); + GXSetTevColorIn(id, GX_CC_KONST, TEV_MAIN_COLOR[i], GX_CC_TEXC, tevColorArg); GXSetTevColorOp(id, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV); GXSetTevAlphaIn(id, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); GXSetTevAlphaOp(id, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); GXSetTevIndirect( - id, GX_INDTEXSTAGE0, GX_ITF_8, GX_ITB_STU, sIndTexMtxId[i], GX_ITW_0, GX_ITW_0, false, false, GX_ITBA_OFF + id, GX_INDTEXSTAGE0, GX_ITF_8, GX_ITB_STU, TEV_MTX_ID[i], GX_ITW_0, GX_ITW_0, false, false, GX_ITBA_OFF ); } - EGG::DrawGX::SetBlendMode(DrawGX::BLEND_2); + EGG::DrawGX::SetBlendMode(EGG::DrawGX::BLEND_2); } -void LightTexture::fn_804AB600() { +void setMaterialCrossOver() { GXSetNumTexGens(2); GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x3c, 0, 0x7d); GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, 0x1e, 0, 0x7d); @@ -128,17 +130,20 @@ void LightTexture::fn_804AB600() { GXSetTevOrder( id, static_cast(GX_TEXCOORD0 + i), static_cast(GX_TEXMAP0 + i), GX_COLOR_NULL ); - GXSetTevKColorSel(id, sTevkColorSel[i]); + GXSetTevKColorSel(id, TEV_SUB_COLOR[i]); GXSetTevKAlphaSel(id, GX_TEV_KASEL_1); - GXSetTevColorIn(id, GX_CC_KONST, sTevkColorArg[i], GX_CC_TEXC, tevColorArg); + GXSetTevColorIn(id, GX_CC_KONST, TEV_MAIN_COLOR[i], GX_CC_TEXC, tevColorArg); GXSetTevColorOp(id, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV); GXSetTevAlphaIn(id, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); GXSetTevAlphaOp(id, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); GXSetTevDirect(id); } - EGG::DrawGX::SetBlendMode(DrawGX::BLEND_2); + EGG::DrawGX::SetBlendMode(EGG::DrawGX::BLEND_2); } +} // namespace +namespace EGG { + void LightTexture::initialize(u16 textureSize, Heap *pHeap) { static const int sCpuTexGradientOp[NUM_CPU_TEX] = {0, 0, 0, 1, 2, 3, 4, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -174,19 +179,19 @@ void LightTexture::initialize(u16 textureSize, Heap *pHeap) { tex->fillGradient(sCpuTexGradientOp[i], 0x73, a + 1, b - 1, DrawGX::BLACK, DrawGX::WHITE, true, true); } if (sTextureSize == 0x100) { - lbl_80574F3A = 1; + sScaleExp = 1; } else if (sTextureSize == 0x80) { - lbl_80574F3A = 0; + sScaleExp = 0; } else if (sTextureSize == 0x40) { - lbl_80574F3A = -1; + sScaleExp = -1; } else if (sTextureSize == 0x20) { - lbl_80574F3A = -2; + sScaleExp = -2; } else if (sTextureSize == 0x10) { - lbl_80574F3A = -3; + sScaleExp = -3; } else if (sTextureSize == 0x8) { - lbl_80574F3A = -4; + sScaleExp = -4; } else if (sTextureSize == 0x4) { - lbl_80574F3A = -5; + sScaleExp = -5; } spNormalEnvironment = new (pHeap) CpuTexture(sTextureSize, sTextureSize, GX_TF_RGBA8); @@ -274,7 +279,7 @@ void LightTexture::loadTextureFromResTimg(int index, EGG::ResTIMG *img) { } void LightTexture::initDrawSetting(u16 u1, u16 u2, u16 u3, u16 u4) { - static const u8 ALIGN_DECL(32) sVtxBuf[] = {0, 0, 0, 1, 1, 1, 1, 0}; + static const u8 ALIGN_DECL(32) vtx[] = {0, 0, 0, 1, 1, 1, 1, 0}; nw4r::math::MTX44 mtx; C_MTXOrtho(mtx, u4, 0.0f, 0.0f, u3, 0.0f, 1.0f); @@ -285,7 +290,7 @@ void LightTexture::initDrawSetting(u16 u1, u16 u2, u16 u3, u16 u4) { GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX8); GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); - GXSetArray(GX_VA_POS, sVtxBuf, 2); + GXSetArray(GX_VA_POS, vtx, 2); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_RGB565, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0); @@ -298,7 +303,7 @@ void LightTexture::initDrawSetting(u16 u1, u16 u2, u16 u3, u16 u4) { sDrawPosX = u1; sDrawPosY = u2; - fn_804AB270(); + setMaterialCommon(); GXSetCurrentMtx(0); GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); } @@ -352,7 +357,7 @@ void LightTexture::fn_804AC0E0(int i, const GXColor &color, bool b) { c = DrawGX::BLACK; } - fn_804AB310(c); + setMaterialAmbient(c); f32 origin = 0.0f; GXBegin(GX_QUADS, GX_VTXFMT0, 4); @@ -374,13 +379,13 @@ void LightTexture::fn_804AC0E0(int i, const GXColor &color, bool b) { case 0: case 2: spNormalEnvironment->load(GX_TEXMAP0); - fn_804AB440(); + setMaterialNormalSphere(); field_0x9D = 3; field_0x9E = 1; break; case 1: - fn_804AB600(); + setMaterialCrossOver(); field_0x9D = 2; field_0x9E = 0; break; @@ -568,7 +573,7 @@ void LightTexture::addLight(const EGG::LightObject &obj) { mtx[1][1] = 0.0f; mtx[1][2] = 0.0f; - GXSetIndTexMtx(sIndTexMtxId[remainder], mtx, -1); + GXSetIndTexMtx(TEV_MTX_ID[remainder], mtx, -1); } if (remainder == field_0x9D - 1) { diff --git a/src/egg/gfx/eggStateEfb.cpp b/src/egg/gfx/eggStateEfb.cpp index 5872e1ef..721c71a9 100644 --- a/src/egg/gfx/eggStateEfb.cpp +++ b/src/egg/gfx/eggStateEfb.cpp @@ -15,7 +15,7 @@ namespace EGG { StateEfb::Buffer StateEfb::spBufferSet[BUFFER_MAX]; f32 StateEfb::sWorkSpaceV[6]; f32 StateEfb::sWorkSpaceHideV[6]; -f32 StateEfb::sUnkBuffer[6]; +f32 StateEfb::sShiftViewPort[6]; u32 StateEfb::sFlag = 4; s32 StateEfb::sWorkBuffer = -1; @@ -204,18 +204,20 @@ void StateEfb::popWorkBuffer(bool b, u32 userData) { f32 *StateEfb::fn_804B4550() { const Screen::DataEfb &efb = GlobalDrawState::getScreen().GetDataEfb(); - sUnkBuffer[0] = sWorkSpaceV[0]; - sUnkBuffer[1] = sWorkSpaceV[1]; - sUnkBuffer[2] = efb.vp.x2; - sUnkBuffer[3] = efb.vp.y2; - sUnkBuffer[4] = efb.vp.z1; - sUnkBuffer[5] = efb.vp.z2; - StateGX::GXSetViewport_(sUnkBuffer[0], sUnkBuffer[1], sUnkBuffer[2], sUnkBuffer[3], sUnkBuffer[4], sUnkBuffer[5]); + sShiftViewPort[0] = sWorkSpaceV[0]; + sShiftViewPort[1] = sWorkSpaceV[1]; + sShiftViewPort[2] = efb.vp.x2; + sShiftViewPort[3] = efb.vp.y2; + sShiftViewPort[4] = efb.vp.z1; + sShiftViewPort[5] = efb.vp.z2; + StateGX::GXSetViewport_( + sShiftViewPort[0], sShiftViewPort[1], sShiftViewPort[2], sShiftViewPort[3], sShiftViewPort[4], sShiftViewPort[5] + ); u32 f[4]; - StateGX::CalculateScreenScissor(sUnkBuffer, f); + StateGX::GetScissorSafeParam(sShiftViewPort, f); StateGX::GXSetScissor_(f[0], f[1], f[2], f[3]); StateGX::GXSetScissorBoxOffset_(0, 0); - return sUnkBuffer; + return sShiftViewPort; } bool StateEfb::isEnableDirtyBufferMode() { diff --git a/src/egg/gfx/eggStateGX.cpp b/src/egg/gfx/eggStateGX.cpp index 21972b94..ef219bd4 100644 --- a/src/egg/gfx/eggStateGX.cpp +++ b/src/egg/gfx/eggStateGX.cpp @@ -21,10 +21,11 @@ namespace { static GXTexRegion *texRegionCallback(const GXTexObj *pObj, GXTexMapID map) { return &EGG::StateGX::s_tmem_layout.mRegions[map % EGG::StateGX::s_tmem_layout.numRegions]; } +static GXTexObj ALIGN_DECL(32) DUMMY_TEX_OBJ; -static const GXColor white = {0xFF, 0xFF, 0xFF, 0xFF}; +static const GXColor WHITE = {0xFF, 0xFF, 0xFF, 0xFF}; -static const f32 identity[3][4] = { +static const f32 IDENTITY[3][4] = { {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, @@ -33,8 +34,6 @@ static const f32 identity[3][4] = { } // namespace namespace EGG { - -GXTexObj ALIGN_DECL(32) StateGX::sDefaultTexObj; StateGX::MemLayout StateGX::s_tmem_layout; StateGX::CacheGX StateGX::s_cacheGX; @@ -56,10 +55,10 @@ void StateGX::initialize(u16 width, u16 height, GXColor color, GXPixelFmt pixelF BaseSystem::getDisplay()->setClearColor(color); } - static u8 sDefaultTexObjData[16] = {0}; + static u8 NullTexData[16] = {0}; - GXInitTexObj(&sDefaultTexObj, sDefaultTexObjData, 4, 4, GX_TF_IA8, GX_CLAMP, GX_CLAMP, 0); - GXInitTexObjLOD(&sDefaultTexObj, GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GXInitTexObj(&DUMMY_TEX_OBJ, NullTexData, 4, 4, GX_TF_IA8, GX_CLAMP, GX_CLAMP, 0); + GXInitTexObjLOD(&DUMMY_TEX_OBJ, GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); invalidateTexAllGX(); frameInit(); setTMemLayout(nw4r::g3d::tmem::TMEM_LAYOUT_1); @@ -137,12 +136,12 @@ void StateGX::resetVtx() { void StateGX::resetColorChannel() { GXSetNumChans(1); - GXSetChanAmbColor(GX_COLOR0A0, white); - GXSetChanAmbColor(GX_COLOR1A1, white); + GXSetChanAmbColor(GX_COLOR0A0, WHITE); + GXSetChanAmbColor(GX_COLOR1A1, WHITE); - GXSetChanMatColor(GX_COLOR0A0, white); + GXSetChanMatColor(GX_COLOR0A0, WHITE); - GXSetChanMatColor(GX_COLOR1A1, white); + GXSetChanMatColor(GX_COLOR1A1, WHITE); GXSetCullMode(GX_CULL_BACK); GXSetChanCtrl(GX_COLOR0A0, false, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); GXSetChanCtrl(GX_COLOR1A1, false, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); @@ -150,12 +149,12 @@ void StateGX::resetColorChannel() { void StateGX::resetIndirect() { GXSetNumIndStages(0); - static const f32 ind[2][3] = { + static const f32 offsetMtx[2][3] = { {0.5f, 0.0f, 0.0f}, {0.0f, 0.5f, 0.0f}, }; for (u32 i = 0; i < 3; i++) { - GXSetIndTexMtx(static_cast(i + GX_ITM_0), ind, 1); + GXSetIndTexMtx(static_cast(i + GX_ITM_0), offsetMtx, 1); } for (u32 i = 0; i < 4; i++) { GXSetIndTexCoordScale(static_cast(i + GX_INDTEXSTAGE0), GX_ITS_1, GX_ITS_1); @@ -164,7 +163,7 @@ void StateGX::resetIndirect() { void StateGX::resetTexture() { for (u32 i = 0; i < s_tmem_layout.numRegions; i++) { - GXLoadTexObj(&sDefaultTexObj, static_cast(i + GX_TEXMAP0)); + GXLoadTexObj(&DUMMY_TEX_OBJ, static_cast(i + GX_TEXMAP0)); } } @@ -172,7 +171,7 @@ void StateGX::resetTexGen() { GXSetNumTexGens(1); for (u32 i = 0; i < 10; i++) { - GXLoadTexMtxImm(identity, i * 3 + 0x1E, GX_MTX3x4); + GXLoadTexMtxImm(IDENTITY, i * 3 + 0x1E, GX_MTX3x4); } for (u32 i = 0; i < GX_MAX_TEXCOORD; i++) { @@ -198,12 +197,12 @@ void StateGX::resetTev() { for (u32 i = 0; i < GX_MAX_KCOLOR; i++) { GXTevKColorID id = static_cast(i); - GXSetTevKColor(id, white); + GXSetTevKColor(id, WHITE); } for (u32 i = 0; i < GX_MAX_TEVREG; i++) { GXTevRegID id = static_cast(i); - GXSetTevColor(id, white); + GXSetTevColor(id, WHITE); } GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); @@ -217,7 +216,7 @@ void StateGX::resetPE() { GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); GXSetZTexture(0, GX_TF_Z24X8, 0); GXSetZMode(true, GX_LEQUAL, true); - GXSetFog(GX_FOG_NONE, white, 0.0f, 1.0f, 0.1f, 1.0f); + GXSetFog(GX_FOG_NONE, WHITE, 0.0f, 1.0f, 0.1f, 1.0f); GXSetFogRangeAdj(false, 0, nullptr); GXSetZCompLoc(true); GXSetDstAlpha(false, 0); @@ -288,7 +287,7 @@ StateGX::CacheGX &StateGX::GXSetDstAlpha_(bool enable, u8 alpha) { return s_cacheGX; } -void StateGX::CalculateScreenScissor(const f32 src[4], u32 dst[4]) { +void StateGX::GetScissorSafeParam(const f32 src[4], u32 dst[4]) { dst[0] = src[0] >= 0.0f ? src[0] : 0.0f; dst[1] = src[1] >= 0.0f ? src[1] : 0.0f; dst[2] = dst[0] + src[2] > 640.0f ? 640 - dst[0] : src[2]; diff --git a/src/toBeSorted/d_d3d.cpp b/src/toBeSorted/d_d3d.cpp index e43fdac8..5f508849 100644 --- a/src/toBeSorted/d_d3d.cpp +++ b/src/toBeSorted/d_d3d.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/a/obj/d_a_obj_base.h" +#include "d/d_gfx.h" #include "d/d_light_env.h" #include "d/d_sc_game.h" #include "d/t/d_t_siren.h" @@ -25,7 +26,7 @@ namespace d3d { static EGG::Screen sSomeScreen; -static SomeList sSomeList; +static SomeList l_list; AnmMdlWrapper::AnmMdlWrapper() : mpSoundSource(nullptr), mpSoundData(nullptr) {} @@ -210,22 +211,19 @@ bool AnmMdlWrapper2::setAnm(const char *anmFile, m3d::playMode_e mode, f32 frame return false; } -extern "C" f32 lbl_80575150; -extern "C" f32 lbl_8057514C; -extern "C" f32 lbl_80576A0C; - void insertNode(SomeListNode *node, f32 a, f32 b) { - node->field_0x04 = ((a * lbl_80575150) - 0.5f) + lbl_8057514C; - node->field_0x06 = (lbl_80575150 - 0.5f) - b; - sSomeList.append(node); + node->field_0x04 = + ((a * dGfx_c::getCurrentScreenTo4x3WidthScaleF()) - 0.5f) + dGfx_c::getCurrentScreenWidthLimitF(); + node->field_0x06 = (dGfx_c::getCurrentScreenHeightLimitF() - 0.5f) - b; + l_list.append(node); } void clearList() { // TODO - for (SomeList::Iterator it = sSomeList.GetBeginIter(); it != sSomeList.GetEndIter(); ++it) { + for (SomeList::Iterator it = l_list.GetBeginIter(); it != l_list.GetEndIter(); ++it) { SomeListNode *nd = &*it; - SomeList::Iterator itCopy = sSomeList.GetPosition(nd); - sSomeList.remove(nd); + SomeList::Iterator itCopy = l_list.GetPosition(nd); + l_list.remove(nd); it = itCopy; } } From 1d3ad120782659c4b3e05b5d07212ef49f71aaa8 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sat, 15 Nov 2025 02:29:24 -0500 Subject: [PATCH 2/2] some more --- config/SOUE01/splits.txt | 2 +- config/SOUE01/symbols.txt | 16 +++++++--------- include/egg/gfx/eggCapTexture.h | 3 +++ src/egg/gfx/eggCapTexture.cpp | 23 +++++++++++++++-------- src/egg/gfx/eggPostEffectMaskDOF.cpp | 18 +++++++++++------- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 56c714be..90cb6779 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -4904,7 +4904,7 @@ egg/gfx/eggCapTexture.cpp: .text start:0x8049D7C0 end:0x8049DA28 align:16 .rodata start:0x804FBA30 end:0x804FBA48 .data start:0x8056ED70 end:0x8056ED80 - .sdata2 start:0x8057F410 end:0x8057F418 + .sdata2 start:0x8057F408 end:0x8057F418 .sbss2 start:0x8057FFC0 end:0x8057FFC8 egg/gfx/eggCpuTexture.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 1cf49233..b824b3f8 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -29200,7 +29200,7 @@ gRMO_Ntsc_640x456Prog_4x3__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB980; // typ gRMO_Ntsc_640x456IntDf_4x3__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB9BC; // type:object size:0x3C scope:local gStandardRenderModeObjSet__22@unnamed@eggVideo_cpp@ = .rodata:0x804FB9F8; // type:object size:0x28 scope:local @4804 = .rodata:0x804FBA20; // type:object size:0x10 scope:local data:4byte -copyArg2__3EGG = .rodata:0x804FBA30; // type:object size:0x18 scope:local +SAMPLE_PATTERN_OFF__27@unnamed@eggCapTexture_cpp@ = .rodata:0x804FBA30; // type:object size:0x18 scope:local sVtxTypes__3EGG = .rodata:0x804FBA60; // type:object size:0x10 @LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@sVtxDataType0 = .rodata:0x804FBA80; // type:object size:0x30 align:32 @LOCAL@SetVtxState__Q23EGG6DrawGXFQ33EGG6DrawGX7VtxType@sNrmDataType0@0 = .rodata:0x804FBAC0; // type:object size:0x24 align:32 @@ -50364,10 +50364,8 @@ FLT_EPSILON = .sdata2:0x8057F3A4; // type:object size:0x4 align:4 data:float @2742 = .sdata2:0x8057F3F0; // type:object size:0x8 scope:local align:8 data:double sArr1__3EGG = .sdata2:0x8057F3F8; // type:object size:0x4 scope:local sArr2__3EGG = .sdata2:0x8057F3FC; // type:object size:0x6 scope:local -lbl_8057F408 = .sdata2:0x8057F408; // type:object size:0x4 data:4byte -lbl_8057F40C = .sdata2:0x8057F40C; // type:object size:0x2 data:2byte -lbl_8057F40E = .sdata2:0x8057F40E; // type:object size:0x1 data:byte -defaultFilter__3EGG = .sdata2:0x8057F410; // type:object size:0x7 scope:local data:byte +VFILTER_BLUR__Q23EGG10CapTexture = .sdata2:0x8057F408; // type:object size:0x7 scope:global data:byte +VFILTER_OFF__Q23EGG10CapTexture = .sdata2:0x8057F410; // type:object size:0x7 scope:global data:byte lbl_8057F418 = .sdata2:0x8057F418; // type:object size:0x4 align:4 data:float lbl_8057F41C = .sdata2:0x8057F41C; // type:object size:0x4 align:4 data:float lbl_8057F420 = .sdata2:0x8057F420; // type:object size:0x8 align:8 data:double @@ -50522,8 +50520,8 @@ lbl_8057F7BC = .sdata2:0x8057F7BC; // type:object size:0x4 align:4 data:float lbl_8057F7C0 = .sdata2:0x8057F7C0; // type:object size:0x4 align:4 data:float @5225 = .sdata2:0x8057F7C8; // type:object size:0x4 scope:local align:4 data:float @5226 = .sdata2:0x8057F7CC; // type:object size:0x4 scope:local align:4 data:float -sColorNear__3EGG = .sdata2:0x8057F7D0; // type:object size:0x4 -sColorFar__3EGG = .sdata2:0x8057F7D4; // type:object size:0x4 +NEAR__34@unnamed@eggPostEffectMaskDOF_cpp@ = .sdata2:0x8057F7D0; // type:object size:0x4 +FAR__34@unnamed@eggPostEffectMaskDOF_cpp@ = .sdata2:0x8057F7D4; // type:object size:0x4 lbl_8057F7D8 = .sdata2:0x8057F7D8; // type:object size:0x4 align:4 data:float lbl_8057F7DC = .sdata2:0x8057F7DC; // type:object size:0x4 align:4 data:float lbl_8057F7E0 = .sdata2:0x8057F7E0; // type:object size:0x4 align:4 data:float @@ -50800,8 +50798,8 @@ lbl_8057FFA0 = .sbss2:0x8057FFA0; // type:object size:0x8 data:4byte bta_dm_pm_cfg = .sbss2:0x8057FFA8; // type:object size:0x8 bd_addr_null = .sbss2:0x8057FFB0; // type:object size:0x8 DefaultBlackColor = .sbss2:0x8057FFB8; // type:object size:0x8 scope:local data:2byte -sBlack__3EGG = .sbss2:0x8057FFC0; // type:object size:0x4 scope:local data:byte -lbl_8057FFC8 = .sbss2:0x8057FFC8; // type:object size:0x4 +DEFUALT_CLEAR_COLOR__27@unnamed@eggCapTexture_cpp@ = .sbss2:0x8057FFC0; // type:object size:0x4 scope:local data:byte +CENTER__34@unnamed@eggPostEffectMaskDOF_cpp@ = .sbss2:0x8057FFC8; // type:object size:0x4 sSavedErrorHandlers = .bss:0x80580000; // type:object size:0x14 scope:local data:4byte @5782 = .bss:0x80580014; // type:object size:0xC scope:local @LOCAL@exceptionCreate__FPQ23EGG4Heap@mapFile = .bss:0x80580020; // type:object size:0x14 scope:local data:4byte diff --git a/include/egg/gfx/eggCapTexture.h b/include/egg/gfx/eggCapTexture.h index a3887e5b..820b0961 100644 --- a/include/egg/gfx/eggCapTexture.h +++ b/include/egg/gfx/eggCapTexture.h @@ -43,6 +43,9 @@ public: mCopyFilterArg = filt; } + static const CopyFilter VFILTER_BLUR; + static const CopyFilter VFILTER_OFF; + private: /* 0x18 */ u8 mCapFlags; /* 0x19 */ GXColor mClearColor; diff --git a/src/egg/gfx/eggCapTexture.cpp b/src/egg/gfx/eggCapTexture.cpp index 0847d808..d1194d85 100644 --- a/src/egg/gfx/eggCapTexture.cpp +++ b/src/egg/gfx/eggCapTexture.cpp @@ -6,21 +6,27 @@ #include "rvl/GX/GXPixel.h" #include "rvl/GX/GXTypes.h" +namespace { +static const GXColor DEFUALT_CLEAR_COLOR = {0, 0, 0, 0}; +static const u8 SAMPLE_PATTERN_OFF[12][2] = {}; + +} // namespace namespace EGG { -static const GXColor sBlack = {0, 0, 0, 0}; -static const CopyFilter defaultFilter = { - {0, 0, 1, 0x3F, 0, 0, 0} +const CopyFilter CapTexture::VFILTER_BLUR = { + {0x15, 0, 0, 0x16, 0, 0x15, 0} }; -static const u8 copyArg2[12][2] = {}; +const CopyFilter CapTexture::VFILTER_OFF = { + {0, 0, 1, 0x3F, 0, 0, 0} +}; void CapTexture::configure() { CpuTexture::configure(); mCapFlags = 0; - mClearColor = sBlack; + mClearColor = DEFUALT_CLEAR_COLOR; field_0x20 = 0xFFFFFF; - mCopyFilterArg = defaultFilter; + mCopyFilterArg = VFILTER_OFF; } void CapTexture::capture(u16 x, u16 y, bool upscale, int format) { @@ -32,7 +38,8 @@ void CapTexture::capture(u16 x, u16 y, bool upscale, int format) { GXSetTexCopyDst(mWidth, mHeight, fmt, upscale); GXSetCopyFilter( - 0, copyArg2, (mCapFlags & 8) ? true : false, (mCapFlags & 8) ? mCopyFilterArg.values : defaultFilter.values + 0, SAMPLE_PATTERN_OFF, (mCapFlags & 8) ? true : false, + (mCapFlags & 8) ? mCopyFilterArg.values : VFILTER_OFF.values ); StateGX::ScopedColor colorUpdate((mCapFlags & 1) != 0); @@ -41,7 +48,7 @@ void CapTexture::capture(u16 x, u16 y, bool upscale, int format) { GXSetCopyClear(mClearColor, field_0x20); GXSetCopyClamp(3); StateGX::GXCopyTex_(dataPtr, true); - GXSetCopyFilter(0, copyArg2, 0, defaultFilter.values); + GXSetCopyFilter(0, SAMPLE_PATTERN_OFF, 0, VFILTER_OFF.values); if ((mCapFlags & 0x10) != 0) { GXPixModeSync(); diff --git a/src/egg/gfx/eggPostEffectMaskDOF.cpp b/src/egg/gfx/eggPostEffectMaskDOF.cpp index 06ac1da6..b340038b 100644 --- a/src/egg/gfx/eggPostEffectMaskDOF.cpp +++ b/src/egg/gfx/eggPostEffectMaskDOF.cpp @@ -8,11 +8,15 @@ #include "rvl/GX/GXTypes.h" #include "rvl/MTX/mtx.h" -namespace EGG { +namespace { -static const GXColor sColorNear = (GXColor){0x00, 0xFF, 0x00, 0xFF}; -static const GXColor sColorFar = (GXColor){0xFF, 0x00, 0x00, 0x00}; -static const GXColor sColorCenter = (GXColor){0x00, 0x00, 0x00, 0x00}; +static const GXColor NEAR = (GXColor){0x00, 0xFF, 0x00, 0xFF}; +static const GXColor FAR = (GXColor){0xFF, 0x00, 0x00, 0x00}; +static const GXColor CENTER = (GXColor){0x00, 0x00, 0x00, 0x00}; + +} // namespace + +namespace EGG { PostEffectMaskDOF::PostEffectMaskDOF() : field_0x2C(8), @@ -234,13 +238,13 @@ void PostEffectMaskDOF::setMaterialInternal() { } const GXColor &PostEffectMaskDOF::getNearColor() { - return sColorNear; + return NEAR; } const GXColor &PostEffectMaskDOF::getFarColor() { - return sColorFar; + return FAR; } const GXColor &PostEffectMaskDOF::getCenterColor() { - return sColorCenter; + return CENTER; } } // namespace EGG