From 68e2c2013ed36475c5a537500a146d20de525fe5 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 9 Jul 2026 15:43:01 -0700 Subject: [PATCH] More CCubeModel matches --- config/GM8E01_00/symbols.txt | 18 +++--- config/GM8E01_01/symbols.txt | 2 +- include/Kyoto/Graphics/CCubeModel.hpp | 9 ++- src/Dolphin/GBA/GBARead.c | 8 +-- src/Dolphin/GBA/GBAWrite.c | 3 +- src/Kyoto/Graphics/CCubeModel.cpp | 87 +++++++++++++++++++++++++++ src/Kyoto/Graphics/DolphinCModel.cpp | 2 +- 7 files changed, 111 insertions(+), 18 deletions(-) diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 4f0d82c4..af363b13 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -13377,7 +13377,7 @@ BuildLocalAmbient__6CLightFRC9CVector3fRC6CColor = .text:0x803064A4; // type:fun __ct__6CLightFRC9CVector3fRC9CVector3fRC6CColorffffff = .text:0x803064DC; // type:function size:0x94 scope:global __ct__6CLightF10ELightTypeRC9CVector3fRC9CVector3fRC6CColorf = .text:0x80306570; // type:function size:0x94 scope:global __sinit_CLight_cpp = .text:0x80306604; // type:function size:0x2C scope:local -fn_80306630 = .text:0x80306630; // type:function size:0x1C0 +DrawNormal__10CCubeModelCFPCfPCf17ESurfaceSelection = .text:0x80306630; // type:function size:0x1C0 RemapMaterialData__10CCubeModelFPCvPQ24rstl60vector<23TCachedToken<8CTexture>,Q24rstl17rmemory_allocator> = .text:0x803067F0; // type:function size:0x1C scope:global UnlockTextures__10CCubeModelCFv = .text:0x8030680C; // type:function size:0x84 scope:global SetModelWireframe__10CCubeModelFb = .text:0x80306890; // type:function size:0x8 scope:global @@ -17788,8 +17788,8 @@ lbl_803D6E90 = .rodata:0x803D6E90; // type:object size:0x7 data:string lbl_803D6EA0 = .rodata:0x803D6EA0; // type:object size:0x28 gCantBeginChars = .rodata:0x803D6EC8; // type:object size:0x1F8 scope:global gCantEndChars = .rodata:0x803D70C0; // type:object size:0x2C8 scope:global -lbl_803D7388 = .rodata:0x803D7388; // type:object size:0x10 -lbl_803D7398 = .rodata:0x803D7398; // type:object size:0x7 data:string +sDesc$426 = .rodata:0x803D7388; // type:object size:0x10 scope:local +@stringBase0 = .rodata:0x803D7398; // type:object size:0x7 scope:local data:string indMtx$287 = .rodata:0x803D73A0; // type:object size:0x18 scope:local vtxDescList$308 = .rodata:0x803D73B8; // type:object size:0x10 scope:local skPosColorTexDirect = .rodata:0x803D73C8; // type:object size:0x20 @@ -22014,13 +22014,13 @@ lbl_805A932C = .sbss:0x805A932C; // type:object size:0x1 data:byte mManagerInstalled__14CDvdRequestSys = .sbss:0x805A9330; // type:object size:0x1 scope:global data:byte lbl_805A9338 = .sbss:0x805A9338; // type:object size:0x1 data:byte lbl_805A933C = .sbss:0x805A933C; // type:object size:0x1 data:byte -sDrawingOccluders = .sbss:0x805A9340; // type:object size:0x1 data:byte -sDrawingWireframe = .sbss:0x805A9341; // type:object size:0x1 data:byte +sDrawingOccluders = .sbss:0x805A9340; // type:object size:0x1 scope:local data:byte +sDrawingWireframe = .sbss:0x805A9341; // type:object size:0x1 scope:local data:byte sUsingPackedLightmaps__10CCubeModel = .sbss:0x805A9342; // type:object size:0x1 data:byte -lbl_805A9344 = .sbss:0x805A9344; // type:object size:0x4 data:4byte -lbl_805A9348 = .sbss:0x805A9348; // type:object size:0x1 data:byte -lbl_805A934C = .sbss:0x805A934C; // type:object size:0x4 data:4byte -lbl_805A9350 = .sbss:0x805A9350; // type:object size:0x8 data:byte +sLastDesc$411 = .sbss:0x805A9344; // type:object size:0x4 scope:local data:4byte +init$412 = .sbss:0x805A9348; // type:object size:0x1 scope:local data:byte +sAttrCount$414 = .sbss:0x805A934C; // type:object size:0x4 scope:local data:4byte +init$415 = .sbss:0x805A9350; // type:object size:0x1 scope:local data:byte sNextUniquePass__13CTevCombiners = .sbss:0x805A9358; // type:object size:0x4 scope:global data:4byte skAlphaOne__13CTevCombiners = .sbss:0x805A935C; // type:object size:0x4 scope:global skColorOne__13CTevCombiners = .sbss:0x805A9360; // type:object size:0x4 scope:global diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index d5b81ad1..d59225f2 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -13377,7 +13377,7 @@ BuildLocalAmbient__6CLightFRC9CVector3fRC6CColor = .text:0x80306584; // type:fun __ct__6CLightFRC9CVector3fRC9CVector3fRC6CColorffffff = .text:0x803065BC; // type:function size:0x94 scope:global __ct__6CLightF10ELightTypeRC9CVector3fRC9CVector3fRC6CColorf = .text:0x80306650; // type:function size:0x94 scope:global __sinit_CLight_cpp = .text:0x803066E4; // type:function size:0x2C scope:local -fn_80306630 = .text:0x80306710; // type:function size:0x1C0 scope:global +DrawNormal__10CCubeModelCFPCfPCf17ESurfaceSelection = .text:0x80306710; // type:function size:0x1C0 scope:global RemapMaterialData__10CCubeModelFPCvPQ24rstl60vector<23TCachedToken<8CTexture>,Q24rstl17rmemory_allocator> = .text:0x803068D0; // type:function size:0x1C scope:global UnlockTextures__10CCubeModelCFv = .text:0x803068EC; // type:function size:0x84 scope:global SetModelWireframe__10CCubeModelFb = .text:0x80306970; // type:function size:0x8 scope:global diff --git a/include/Kyoto/Graphics/CCubeModel.hpp b/include/Kyoto/Graphics/CCubeModel.hpp index 05e33c50..4917fa1f 100644 --- a/include/Kyoto/Graphics/CCubeModel.hpp +++ b/include/Kyoto/Graphics/CCubeModel.hpp @@ -59,6 +59,9 @@ public: uchar visorFlags, bool texturesLoaded, uint idx); static void SetRenderModelBlack(bool v); static void SetModelWireframe(bool v); + void UnlockTextures() const; + void RemapMaterialData(const void* data, rstl::vector< TCachedToken< CTexture > >* texture); + void DrawNormal(const float* positions, const float* normals, ESurfaceSelection which) const; static void DisableShadowMaps(); static void EnableShadowMaps(const CTexture*, const CTransform4f&, unsigned char, unsigned char); static void SetNewPlayerPositionAndTime(const CVector3f&, const CStopwatch&); @@ -81,10 +84,14 @@ public: void SetSkinningArraysCurrent(const float* positions, const float* normals) const; void SetUsingPackedLightmaps(const bool use) const; static bool IsUsingPackedLightmaps() { return sUsingPackedLightmaps; } - void DrawFlat(const float* positions, const float* normals, ESurfaceSelection which) const; void DrawSurface(const CCubeSurface& surface, const CModelFlags& modelFlags) const; void DrawSurfaceWireframe(const CCubeSurface& surface) const; + void DrawFlat(const float* positions, const float* normals, ESurfaceSelection which) const; bool TryLockTextures() const; + void Draw(const CModelFlags& flags) const; + void Draw(const float* positions, const float* normals, const CModelFlags& flags) const; + void DrawNormal(const CModelFlags& flags) const; + void DrawAlpha(const CModelFlags& flags) const; void DrawSurfaces(const CModelFlags& flags) const; void DrawNormalSurfaces(const CModelFlags& flags) const; void DrawAlphaSurfaces(const CModelFlags& flags) const; diff --git a/src/Dolphin/GBA/GBARead.c b/src/Dolphin/GBA/GBARead.c index 9981d0f1..90c5cf62 100644 --- a/src/Dolphin/GBA/GBARead.c +++ b/src/Dolphin/GBA/GBARead.c @@ -29,13 +29,13 @@ s32 GBAReadAsync(s32 chan, u8* dst, u8* status, GBACallback callback) { } s32 GBARead(s32 chan, u8* dst, u8* status) { - s32 tmp; + s32 unused; GBAControl* gba = &__GBA[chan]; - s32 ret; - ret = GBAReadAsync(chan, dst, status, __GBASyncCallback); + s32 ret = GBAReadAsync(chan, dst, status, __GBASyncCallback); if (ret != GBA_READY) { return ret; } - return __GBASync(chan); + ret = __GBASync(chan); + return ret; } diff --git a/src/Dolphin/GBA/GBAWrite.c b/src/Dolphin/GBA/GBAWrite.c index efbfadeb..e4757a12 100644 --- a/src/Dolphin/GBA/GBAWrite.c +++ b/src/Dolphin/GBA/GBAWrite.c @@ -27,8 +27,7 @@ s32 GBAWriteAsync(s32 chan, u8* src, u8* status, GBACallback callback) { } s32 GBAWrite(s32 chan, u8* src, u8* status) { - s32 tmp; - GBAControl* gba = &__GBA[chan]; + s32 _[2]; s32 ret; ret = GBAWriteAsync(chan, src, status, __GBASyncCallback); if (ret != GBA_READY) { diff --git a/src/Kyoto/Graphics/CCubeModel.cpp b/src/Kyoto/Graphics/CCubeModel.cpp index 766b3725..a7b8afca 100644 --- a/src/Kyoto/Graphics/CCubeModel.cpp +++ b/src/Kyoto/Graphics/CCubeModel.cpp @@ -242,3 +242,90 @@ void CCubeModel::DrawAlphaSurfaces(const CModelFlags& flags) const { } } } + +void CCubeModel::DrawFlat(const float* positions, const float* normals, + ESurfaceSelection which) const { + if (positions != nullptr) { + SetSkinningArraysCurrent(positions, normals); + } else { + SetArraysCurrent(); + } + + if (which != kSS_Sorted) { + for (CCubeSurface surface = x38_firstUnsorted; surface.IsValid(); + surface = surface.GetNextSurface()) { + CCubeMaterial material = GetMaterialByIndex(surface.GetMaterialIndex()); + CGX::SetVtxDescv_Compressed(material.GetVertexDesc()); + CGX::CallDisplayList(surface.GetDisplayList(), surface.GetDisplayListSize()); + } + } + + if (which != kSS_Unsorted) { + for (CCubeSurface surface = x3c_firstSorted; surface.IsValid(); + surface = surface.GetNextSurface()) { + CCubeMaterial material = GetMaterialByIndex(surface.GetMaterialIndex()); + CGX::SetVtxDescv_Compressed(material.GetVertexDesc()); + CGX::CallDisplayList(surface.GetDisplayList(), surface.GetDisplayListSize()); + } + } +} + +void CCubeModel::Draw(const CModelFlags& flags) const { + CCubeMaterial::KillCachedViewDepState(); + SetArraysCurrent(); + DrawSurfaces(flags); +} + +void CCubeModel::Draw(const float* positions, const float* normals, + const CModelFlags& flags) const { + CCubeMaterial::KillCachedViewDepState(); + SetSkinningArraysCurrent(positions, normals); + DrawSurfaces(flags); +} + +void CCubeModel::DrawNormal(const CModelFlags& flags) const { + CCubeMaterial::KillCachedViewDepState(); + SetArraysCurrent(); + DrawNormalSurfaces(flags); +} + +void CCubeModel::DrawAlpha(const CModelFlags& flags) const { + CCubeMaterial::KillCachedViewDepState(); + SetArraysCurrent(); + DrawAlphaSurfaces(flags); +} + +void CCubeModel::SetDrawingOccluders(const bool drawOccluders) { + sDrawingOccluders = drawOccluders; +} + +void CCubeModel::SetModelWireframe(const bool drawWireframe) { sDrawingWireframe = drawWireframe; } + +void CCubeModel::UnlockTextures() const { + for (AUTO(texture, x1c_textures->begin()); texture != x1c_textures->end(); ++texture) { + texture->Unlock(); + } + + x40_24_loadTextures = false; +} + +void CCubeModel::RemapMaterialData(const void* data, + rstl::vector< TCachedToken< CTexture > >* texture) { + + x0_instance.SetMaterialPointer(data); + x1c_textures = texture; + x40_24_loadTextures = false; +} + +void CCubeModel::DrawNormal(const float* positions, const float* normals, ESurfaceSelection which) const { + CGX::SetNumIndStages(0); + CGX::SetNumTevStages(1); + CGX::SetNumTexGens(1); + CGX::SetZMode(true, GX_LEQUAL, true); + CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); + CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0); + CGX::SetBlendMode(GX_BM_BLEND, GX_BL_ZERO, GX_BL_ONE, GX_LO_CLEAR); + DrawFlat(positions, normals, which); +} \ No newline at end of file diff --git a/src/Kyoto/Graphics/DolphinCModel.cpp b/src/Kyoto/Graphics/DolphinCModel.cpp index 4fd9f90c..3a344f02 100644 --- a/src/Kyoto/Graphics/DolphinCModel.cpp +++ b/src/Kyoto/Graphics/DolphinCModel.cpp @@ -82,4 +82,4 @@ CModel::CModel(const rstl::auto_ptr< uchar >& data, int length, IObjectStore& st x4_dataLen += x8_surfaces.size() * 4; sTotalMemory += x4_dataLen; DCFlushRange(x0_data.get(), x4_dataLen); -} +} \ No newline at end of file