diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b1a6c67..a43a1390 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,7 +216,7 @@ add_library(lego1 SHARED LEGO1/tgl/d3drm/light.cpp LEGO1/tgl/d3drm/mesh.cpp LEGO1/tgl/d3drm/renderer.cpp - LEGO1/tgl/d3drm/something.cpp + LEGO1/tgl/d3drm/unk.cpp LEGO1/tgl/d3drm/texture.cpp LEGO1/tgl/d3drm/view.cpp LEGO1/towtrack.cpp diff --git a/LEGO1/tgl/d3drm/camera.cpp b/LEGO1/tgl/d3drm/camera.cpp index 0f6f4b0a..fb3966cc 100644 --- a/LEGO1/tgl/d3drm/camera.cpp +++ b/LEGO1/tgl/d3drm/camera.cpp @@ -21,10 +21,10 @@ void* CameraImpl::ImplementationDataPtr() } // OFFSET: LEGO1 0x100a3700 -Result CameraImpl::SetTransformation(const FloatMatrix4& p_matrix) +Result CameraImpl::SetTransformation(const FloatMatrix4& matrix) { D3DRMMATRIX4D helper; - D3DRMMATRIX4D* pTransformation = Translate(p_matrix, helper); + D3DRMMATRIX4D* pTransformation = Translate(matrix, helper); D3DVECTOR position; Result result; diff --git a/LEGO1/tgl/d3drm/device.cpp b/LEGO1/tgl/d3drm/device.cpp index 8659d3a3..dc7748b7 100644 --- a/LEGO1/tgl/d3drm/device.cpp +++ b/LEGO1/tgl/d3drm/device.cpp @@ -38,24 +38,24 @@ Result DeviceImpl::SetColorModel(ColorModel) } // OFFSET: LEGO1 0x100a2c30 -Result DeviceImpl::SetShadingModel(ShadingModel p_model) +Result DeviceImpl::SetShadingModel(ShadingModel model) { // Doesn't match well even though we know this is exactly // the original code thanks to the jump table. - D3DRMRENDERQUALITY renderQuality = Translate(p_model); + D3DRMRENDERQUALITY renderQuality = Translate(model); return ResultVal(m_data->SetQuality(renderQuality)); } // OFFSET: LEGO1 0x100a2ca0 -Result DeviceImpl::SetShadeCount(unsigned long p_shadeCount) +Result DeviceImpl::SetShadeCount(unsigned long shadeCount) { - return ResultVal(m_data->SetShades(p_shadeCount)); + return ResultVal(m_data->SetShades(shadeCount)); } // OFFSET: LEGO1 0x100a2cc0 -Result DeviceImpl::SetDither(int p_dither) +Result DeviceImpl::SetDither(int dither) { - return ResultVal(m_data->SetDither(p_dither)); + return ResultVal(m_data->SetDither(dither)); } // Probably wrong, not sure what's going on in this method. diff --git a/LEGO1/tgl/d3drm/group.cpp b/LEGO1/tgl/d3drm/group.cpp index 7c33f187..3ab1d8f0 100644 --- a/LEGO1/tgl/d3drm/group.cpp +++ b/LEGO1/tgl/d3drm/group.cpp @@ -6,7 +6,7 @@ using namespace TglImpl; GroupImpl::~GroupImpl() { if (m_data) { - free(m_data); + m_data->Release(); m_data = NULL; } } @@ -18,43 +18,43 @@ void* GroupImpl::ImplementationDataPtr() } // OFFSET: LEGO1 0x100a31e0 -Result GroupImpl::SetTransformation(const FloatMatrix4& p_matrix) +Result GroupImpl::SetTransformation(const FloatMatrix4& matrix) { D3DRMMATRIX4D helper; - D3DRMMATRIX4D* matrix = Translate(p_matrix, helper); - return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *matrix)); + D3DRMMATRIX4D* d3dMatrix = Translate(matrix, helper); + return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *d3dMatrix)); } // OFFSET: LEGO1 0x100a3240 -Result GroupImpl::SetColor(float p_r, float p_g, float p_b, float p_a) +Result GroupImpl::SetColor(float r, float g, float b, float a) { // The first instruction makes no sense here: // cmp dword ptr [esp + 0x10], 0 // This compares a, which we know is a float because it immediately // gets passed into D3DRMCreateColorRGBA, but does the comparison // as though it's an int?? - if (*reinterpret_cast(&p_a) > 0) { - D3DCOLOR color = D3DRMCreateColorRGBA(p_r, p_g, p_b, p_a); + if (*reinterpret_cast(&a) > 0) { + D3DCOLOR color = D3DRMCreateColorRGBA(r, g, b, a); return ResultVal(m_data->SetColor(color)); } else { - return ResultVal(m_data->SetColorRGB(p_r, p_a, p_b)); + return ResultVal(m_data->SetColorRGB(r, a, b)); } } // OFFSET: LEGO1 0x100a32b0 -Result GroupImpl::SetTexture(const Texture* p_texture) +Result GroupImpl::SetTexture(const Texture* pTexture) { - IDirect3DRMTexture* texture = p_texture ? static_cast(p_texture)->ImplementationData() : NULL; - return ResultVal(m_data->SetTexture(texture)); + IDirect3DRMTexture* pD3DTexture = pTexture ? static_cast(pTexture)->ImplementationData() : NULL; + return ResultVal(m_data->SetTexture(pD3DTexture)); } // OFFSET: LEGO1 0x100a32e0 -Result GroupImpl::GetTexture(Texture*& p_texture) +Result GroupImpl::GetTexture(Texture*& pTexture) { - IDirect3DRMTexture* texture; + IDirect3DRMTexture* pD3DTexture; TextureImpl* holder = new TextureImpl(); - Result result = ResultVal(m_data->GetTexture(&texture)); + Result result = ResultVal(m_data->GetTexture(&pD3DTexture)); if (result) { // Seems to actually call the first virtual method of holder here // but that doesn't make any sense since it passes three arguments @@ -63,57 +63,57 @@ Result GroupImpl::GetTexture(Texture*& p_texture) // This line makes the start of the function match and is what I // would expect to see there but it clearly isn't what's actually // there. - holder->SetImplementation(texture); + holder->SetImplementation(pD3DTexture); } - p_texture = holder; + pTexture = holder; return Success; } // OFFSET: LEGO1 0x100a33c0 -Result GroupImpl::SetMaterialMode(MaterialMode p_mode) +Result GroupImpl::SetMaterialMode(MaterialMode mode) { - D3DRMMATERIALMODE mode; - switch (p_mode) + D3DRMMATERIALMODE d3dMode; + switch (mode) { case FromParent: - mode = D3DRMMATERIAL_FROMPARENT; + d3dMode = D3DRMMATERIAL_FROMPARENT; break; case FromFrame: - mode = D3DRMMATERIAL_FROMFRAME; + d3dMode = D3DRMMATERIAL_FROMFRAME; break; case FromMesh: - mode = D3DRMMATERIAL_FROMMESH; + d3dMode = D3DRMMATERIAL_FROMMESH; break; } - return ResultVal(m_data->SetMaterialMode(mode)); + return ResultVal(m_data->SetMaterialMode(d3dMode)); } // OFFSET: LEGO1 0x100a3410 -Result GroupImpl::Add(const Mesh* p_mesh) +Result GroupImpl::Add(const Mesh* pMesh) { - const MeshImpl* mesh = static_cast(p_mesh); - return ResultVal(m_data->AddVisual(mesh->ImplementationData()->groupMesh)); + const MeshImpl* pMeshImpl = static_cast(pMesh); + return ResultVal(m_data->AddVisual(pMeshImpl->ImplementationData()->groupMesh)); } // OFFSET: LEGO1 0x100a3430 -Result GroupImpl::Add(const Group* p_group) +Result GroupImpl::Add(const Group* pGroup) { - const GroupImpl* group = static_cast(p_group); - return ResultVal(m_data->AddVisual(group->m_data)); + const GroupImpl* pGroupImpl = static_cast(pGroup); + return ResultVal(m_data->AddVisual(pGroupImpl->m_data)); } // OFFSET: LEGO1 0x100a3450 -Result GroupImpl::Remove(const Group* p_group) +Result GroupImpl::Remove(const Group* pGroup) { - const GroupImpl* group = static_cast(p_group); - return ResultVal(m_data->DeleteVisual(group->m_data)); + const GroupImpl* pGroupImpl = static_cast(pGroup); + return ResultVal(m_data->DeleteVisual(pGroupImpl->m_data)); } // OFFSET: LEGO1 0x100a3480 -Result GroupImpl::Remove(const Mesh* p_mesh) +Result GroupImpl::Remove(const Mesh* pMesh) { - const MeshImpl* mesh = static_cast(p_mesh); - return ResultVal(m_data->DeleteVisual(mesh->ImplementationData()->groupMesh)); + const MeshImpl* pMeshImpl = static_cast(pMesh); + return ResultVal(m_data->DeleteVisual(pMeshImpl->ImplementationData()->groupMesh)); } // OFFSET: LEGO1 0x100a34b0 STUB diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index 627043b3..31af6bec 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -19,9 +19,9 @@ namespace TglImpl using namespace Tgl; // Utility function used by implementations -inline Result ResultVal(HRESULT p_result) +inline Result ResultVal(HRESULT result) { - return SUCCEEDED(p_result) ? Success : Error; + return SUCCEEDED(result) ? Success : Error; } // Forward declare implementations @@ -33,6 +33,7 @@ class CameraImpl; class GroupImpl; class MeshImpl; class TextureImpl; +class UnkImpl; // VTABLE 0x100db910 class RendererImpl : public Renderer { @@ -50,26 +51,26 @@ class RendererImpl : public Renderer { virtual View* CreateView( const Device*, const Camera*, - unsigned long p_x, - unsigned long p_y, - unsigned long p_width, - unsigned long p_height + unsigned long x, + unsigned long y, + unsigned long width, + unsigned long height ); virtual Camera* CreateCamera(); - virtual Light* CreateLight(LightType, float p_r, float p_g, float p_b); - virtual Group* CreateGroup(const Group* p_parent); + virtual Light* CreateLight(LightType, float r, float g, float b); + virtual Group* CreateGroup(const Group* pParent); // vtable+0x20 - virtual Something* CreateSomething(); + virtual Unk* CreateUnk(); virtual Texture* CreateTexture(); virtual Texture* CreateTexture( - int p_width, - int p_height, - int p_bitsPerTexel, - const void* p_pTexels, - int p_pTexelsArePersistent, - int p_paletteEntryCount, - const PaletteEntry* p_pEntries + int width, + int height, + int bitsPerTexel, + const void* pTexels, + int pTexelsArePersistent, + int paletteEntryCount, + const PaletteEntry* pEntries ); virtual Result SetTextureDefaultShadeCount(unsigned long); @@ -130,11 +131,11 @@ class ViewImpl : public View { // vtable+0x10 virtual Result SetCamera(const Camera*); virtual Result SetProjection(ProjectionType); - virtual Result SetFrustrum(float p_frontClippingDistance, float p_backClippingDistance, float p_degrees); - virtual Result SetBackgroundColor(float p_r, float p_g, float p_b); + virtual Result SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees); + virtual Result SetBackgroundColor(float r, float g, float b); // vtable+0x20 - virtual Result GetBackgroundColor(float* p_r, float* p_g, float* p_b); + virtual Result GetBackgroundColor(float* r, float* g, float* b); virtual Result Clear(); virtual Result Render(const Light*); virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height); @@ -143,12 +144,12 @@ class ViewImpl : public View { virtual Result TransformWorldToScreen(const float world[3], float screen[4]); virtual Result TransformScreenToWorld(const float screen[4], float world[3]); virtual Result Pick( - unsigned long p_x, - unsigned long p_y, - const Group** p_ppGroupsToPickFrom, - int p_groupsToPickFromCount, - const Group**& p_rppPickedGroups, - int& p_rPickedGroupCount + unsigned long x, + unsigned long y, + const Group** ppGroupsToPickFrom, + int groupsToPickFromCount, + const Group**& rppPickedGroups, + int& rPickedGroupCount ); inline IDirect3DRMViewport* ImplementationData() const { return m_data; } @@ -190,7 +191,7 @@ class LightImpl : public Light { // vtable+0x08 virtual Result SetTransformation(const FloatMatrix4&); - virtual Result SetColor(float p_r, float p_g, float p_b); + virtual Result SetColor(float r, float g, float b); inline IDirect3DRMFrame* ImplementationData() const { return m_data; } @@ -215,17 +216,17 @@ class MeshImpl : public Mesh { virtual void* ImplementationDataPtr(); // vtable+0x08 - virtual Result SetColor(float p_r, float p_g, float p_b, float p_a); + virtual Result SetColor(float r, float g, float b, float a); virtual Result SetTexture(const Texture*); // vtable+0x10 virtual Result GetTexture(Texture*&); virtual Result SetTextureMappingMode(ProjectionType); virtual Result SetShadingModel(ShadingModel); - virtual Mesh* DeepClone(Something*); + virtual Mesh* DeepClone(Unk*); // vtable+0x20 - virtual Mesh* ShallowClone(Something*); + virtual Mesh* ShallowClone(Unk*); struct MeshData { IDirect3DRMMesh* groupMesh; @@ -250,7 +251,7 @@ class GroupImpl : public Group { // vtable+0x08 virtual Result SetTransformation(const FloatMatrix4&); - virtual Result SetColor(float p_r, float p_g, float p_b, float p_a); + virtual Result SetColor(float r, float g, float b, float a); // vtable+0x10 virtual Result SetTexture(const Texture*); @@ -274,27 +275,27 @@ class GroupImpl : public Group { }; // VTABLE 0x100dbb18 -class SomethingImpl : public Something { +class UnkImpl : public Unk { public: - SomethingImpl() : m_data(0) {} - ~SomethingImpl(); + UnkImpl() : m_data(0) {} + ~UnkImpl(); virtual void* ImplementationDataPtr(); // vtable+0x08 virtual Result SetMeshData( - unsigned long p_faceCount, - unsigned long p_vertexCount, - const float (*p_positions)[3], - const float (*p_normals)[3], - const float (*p_textureCoordinates)[2], - unsigned long p_vertexPerFaceCount, - unsigned long* p_faceData + unsigned long faceCount, + unsigned long vertexCount, + const float (*pPositions)[3], + const float (*pNormals)[3], + const float (*pTextureCoordinates)[2], + unsigned long vertexPerFaceCount, + unsigned long* pFaceData ); - virtual Result GetBoundingBox(float p_min[3], float p_max[3]); + virtual Result GetBoundingBox(float min[3], float max[3]); // vtable+0x10 - virtual Something* Clone(); + virtual Unk* Clone(); inline IDirect3DRMMesh* ImplementationData() const { return m_data; } @@ -308,20 +309,20 @@ class SomethingImpl : public Something { class TglD3DRMIMAGE { public: TglD3DRMIMAGE( - int p_width, - int p_height, - int p_depth, - void* p_buffer, - int p_useBuffer, - int p_paletteSize, - PaletteEntry* p_palette + int width, + int height, + int depth, + void* pBuffer, + int useBuffer, + int paletteSize, + PaletteEntry* pEntries ); ~TglD3DRMIMAGE() { Destroy(); } - Result CreateBuffer(int p_width, int p_height, int p_depth, void* p_buffer, int p_useBuffer); + Result CreateBuffer(int width, int height, int depth, void* pBuffer, int useBuffer); void Destroy(); - void FillRowsOfTexture(int p_y, int p_height, char* p_content); - Result InitializePalette(int p_paletteSize, PaletteEntry* p_palette); + void FillRowsOfTexture(int y, int height, char* content); + Result InitializePalette(int paletteSize, PaletteEntry* pEntries); D3DRMIMAGE m_image; int m_texelsAllocatedByClient; @@ -336,38 +337,38 @@ class TextureImpl : public Texture { virtual void* ImplementationDataPtr(); // vtable+0x08 - virtual Result SetTexels(int p_width, int p_height, int p_bitsPerTexel, void* p_texels); - virtual void FillRowsOfTexture(int p_y, int p_height, void* p_buffer); + virtual Result SetTexels(int width, int height, int bitsPerTexel, void* pTexels); + virtual void FillRowsOfTexture(int y, int height, void* pBuffer); // vtable+0x10 - virtual Result Changed(int p_texelsChanged, int p_paletteChanged); + virtual Result Changed(int texelsChanged, int paletteChanged); virtual Result GetBufferAndPalette( - int* p_width, - int* p_height, - int* p_depth, - void** p_buffer, - int* p_paletteSize, - PaletteEntry** p_palette + int* pWidth, + int* pHeight, + int* pDepth, + void** ppBuffer, + int* ppPaletteSize, + PaletteEntry** ppPalette ); - virtual Result SetPalette(int p_entryCount, PaletteEntry* p_entries); + virtual Result SetPalette(int entryCount, PaletteEntry* entries); inline IDirect3DRMTexture* ImplementationData() const { return m_data; } - inline void SetImplementation(IDirect3DRMTexture* data) { m_data = data; } + inline void SetImplementation(IDirect3DRMTexture* pData) { m_data = pData; } friend class RendererImpl; - static Result SetImage(IDirect3DRMTexture* p_self, TglD3DRMIMAGE* p_image); + static Result SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage); private: IDirect3DRMTexture* m_data; }; // Translation helpers -inline D3DRMRENDERQUALITY Translate(ShadingModel p_tglShadingModel) +inline D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel) { D3DRMRENDERQUALITY renderQuality; - switch (p_tglShadingModel) { + switch (tglShadingModel) { case Wireframe: renderQuality = D3DRMRENDER_WIREFRAME; break; @@ -391,10 +392,10 @@ inline D3DRMRENDERQUALITY Translate(ShadingModel p_tglShadingModel) return renderQuality; } -inline D3DRMPROJECTIONTYPE Translate(ProjectionType p_tglProjectionType) +inline D3DRMPROJECTIONTYPE Translate(ProjectionType tglProjectionType) { D3DRMPROJECTIONTYPE projectionType; - switch (p_tglProjectionType) { + switch (tglProjectionType) { case Perspective: projectionType = D3DRMPROJECT_PERSPECTIVE; break; diff --git a/LEGO1/tgl/d3drm/light.cpp b/LEGO1/tgl/d3drm/light.cpp index ced46c92..2364179c 100644 --- a/LEGO1/tgl/d3drm/light.cpp +++ b/LEGO1/tgl/d3drm/light.cpp @@ -21,19 +21,19 @@ void* LightImpl::ImplementationDataPtr() } // OFFSET: LEGO1 0x100a3780 -Result LightImpl::SetTransformation(const FloatMatrix4& p_matrix) +Result LightImpl::SetTransformation(const FloatMatrix4& matrix) { D3DRMMATRIX4D helper; - D3DRMMATRIX4D* matrix = Translate(p_matrix, helper); - return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *matrix)); + D3DRMMATRIX4D* d3dMatrix = Translate(matrix, helper); + return ResultVal(m_data->AddTransform(D3DRMCOMBINE_REPLACE, *d3dMatrix)); } // OFFSET: LEGO1 0x100a37e0 -Result LightImpl::SetColor(float p_r, float p_g, float p_b) +Result LightImpl::SetColor(float r, float g, float b) { IDirect3DRMLightArray* lightArray; IDirect3DRMLight* light; m_data->GetLights(&lightArray); lightArray->GetElement(0, &light); - return ResultVal(light->SetColorRGB(p_r, p_g, p_b)); + return ResultVal(light->SetColorRGB(r, g, b)); } \ No newline at end of file diff --git a/LEGO1/tgl/d3drm/mesh.cpp b/LEGO1/tgl/d3drm/mesh.cpp index c6fd0e56..46223d0e 100644 --- a/LEGO1/tgl/d3drm/mesh.cpp +++ b/LEGO1/tgl/d3drm/mesh.cpp @@ -14,19 +14,19 @@ void* MeshImpl::ImplementationDataPtr() } // OFFSET: LEGO1 0x100a3ee0 -Result MeshImpl::SetColor(float p_r, float p_g, float p_b, float p_a) +Result MeshImpl::SetColor(float r, float g, float b, float a) { // The first instruction makes no sense here: // cmp dword ptr [esp + 0x10], 0 // This compares a, which we know is a float because it immediately // gets passed into D3DRMCreateColorRGBA, but does the comparison // as though it's an int?? - if (*reinterpret_cast(&p_a) > 0) { - D3DCOLOR color = D3DRMCreateColorRGBA(p_r, p_g, p_b, p_a); + if (*reinterpret_cast(&a) > 0) { + D3DCOLOR color = D3DRMCreateColorRGBA(r, g, b, a); return ResultVal(m_data->groupMesh->SetGroupColor(m_data->groupIndex, color)); } else { - return ResultVal(m_data->groupMesh->SetGroupColorRGB(m_data->groupIndex, p_r, p_g, p_b)); + return ResultVal(m_data->groupMesh->SetGroupColorRGB(m_data->groupIndex, r, g, b)); } } @@ -34,16 +34,16 @@ Result MeshImpl::SetColor(float p_r, float p_g, float p_b, float p_a) // TglImpl::MeshImpl::`scalar deleting destructor' // OFFSET: LEGO1 0x100a3f50 -Result MeshImpl::SetTexture(const Texture* p_texture) +Result MeshImpl::SetTexture(const Texture* pTexture) { - IDirect3DRMTexture* texture = p_texture ? static_cast(p_texture)->ImplementationData() : NULL; + IDirect3DRMTexture* texture = pTexture ? static_cast(pTexture)->ImplementationData() : NULL; return ResultVal(m_data->groupMesh->SetGroupTexture(m_data->groupIndex, texture)); } // OFFSET: LEGO1 0x100a3f80 -Result MeshImpl::SetTextureMappingMode(ProjectionType p_projType) +Result MeshImpl::SetTextureMappingMode(ProjectionType projType) { - if (p_projType == Perspective) { + if (projType == Perspective) { return ResultVal(m_data->groupMesh->SetGroupMapping(m_data->groupIndex, D3DRMMAP_PERSPCORRECT)); } else { @@ -52,10 +52,10 @@ Result MeshImpl::SetTextureMappingMode(ProjectionType p_projType) } // OFFSET: LEGO1 0x100a3fc0 -Result MeshImpl::SetShadingModel(ShadingModel p_model) +Result MeshImpl::SetShadingModel(ShadingModel model) { D3DRMRENDERQUALITY mode; - switch (p_model) { + switch (model) { case Wireframe: mode = D3DRMRENDER_WIREFRAME; break; @@ -76,21 +76,21 @@ Result MeshImpl::SetShadingModel(ShadingModel p_model) } // OFFSET: LEGO1 0x100a4030 -Mesh* MeshImpl::DeepClone(Something* p_mesh) +Mesh* MeshImpl::DeepClone(Unk* pUnk) { // Create group - MeshImpl* newSomething = new MeshImpl(); + MeshImpl* newMesh = new MeshImpl(); MeshData* data = new MeshData(); - newSomething->m_data = data; + newMesh->m_data = data; // Query information from old group DWORD dataSize; unsigned int vcount, fcount, vperface; m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, NULL); - unsigned int* faceBuffer = (unsigned int*) malloc(dataSize * sizeof(unsigned int)); + unsigned int* faceBuffer = new unsigned int[dataSize]; m_data->groupMesh->GetGroup(m_data->groupIndex, &vcount, &fcount, &vperface, &dataSize, faceBuffer); // We expect vertex to be sized 0x24, checked at start of file. - D3DRMVERTEX* vertexBuffer = (D3DRMVERTEX*) malloc(vcount * sizeof(D3DRMVERTEX)); + D3DRMVERTEX* vertexBuffer = new D3DRMVERTEX[vcount]; m_data->groupMesh->GetVertices(m_data->groupIndex, 0, vcount, vertexBuffer); LPDIRECT3DRMTEXTURE textureRef; m_data->groupMesh->GetGroupTexture(m_data->groupIndex, &textureRef); @@ -99,10 +99,10 @@ Mesh* MeshImpl::DeepClone(Something* p_mesh) D3DCOLOR color = m_data->groupMesh->GetGroupColor(m_data->groupIndex); // Push information to new group - SomethingImpl* target = static_cast(p_mesh); + UnkImpl* target = static_cast(pUnk); D3DRMGROUPINDEX index; target->ImplementationData()->AddGroup(vcount, fcount, vperface, faceBuffer, &index); - newSomething->m_data->groupIndex = index; + newMesh->m_data->groupIndex = index; target->ImplementationData()->SetVertices(index, 0, vcount, vertexBuffer); target->ImplementationData()->SetGroupTexture(index, textureRef); target->ImplementationData()->SetGroupMapping(index, mapping); @@ -110,27 +110,25 @@ Mesh* MeshImpl::DeepClone(Something* p_mesh) Result result = ResultVal(target->ImplementationData()->SetGroupColor(index, color)); // Cleanup - if (faceBuffer) - free(faceBuffer); - if (vertexBuffer) - free(vertexBuffer); + delete[] faceBuffer; + delete[] vertexBuffer; if (result == Error) { - delete newSomething; - newSomething = NULL; + delete newMesh; + newMesh = NULL; } - return newSomething; + return newMesh; } // OFFSET: LEGO1 0x100a4240 -Mesh* MeshImpl::ShallowClone(Something* p_mesh) +Mesh* MeshImpl::ShallowClone(Unk* pUnk) { MeshImpl* newGroup = new MeshImpl(); MeshData* newData = new MeshData(); newGroup->m_data = newData; if (newData) { newData->groupIndex = m_data->groupIndex; - newData->groupMesh = static_cast(p_mesh)->ImplementationData(); + newData->groupMesh = static_cast(pUnk)->ImplementationData(); } else { delete newGroup; @@ -140,7 +138,7 @@ Mesh* MeshImpl::ShallowClone(Something* p_mesh) } // OFFSET: LEGO1 0x100a4330 -Result MeshImpl::GetTexture(Texture*& p_texture) +Result MeshImpl::GetTexture(Texture*& rpTexture) { IDirect3DRMTexture* texture; TextureImpl* holder = new TextureImpl(); @@ -155,6 +153,6 @@ Result MeshImpl::GetTexture(Texture*& p_texture) // there. holder->SetImplementation(texture); } - p_texture = holder; + rpTexture = holder; return Success; } diff --git a/LEGO1/tgl/d3drm/renderer.cpp b/LEGO1/tgl/d3drm/renderer.cpp index c11b311a..02f51c76 100644 --- a/LEGO1/tgl/d3drm/renderer.cpp +++ b/LEGO1/tgl/d3drm/renderer.cpp @@ -3,7 +3,7 @@ using namespace TglImpl; // OFFSET: LEGO1 0x100a15e0 -Renderer* CreateRenderer() +Renderer* Tgl::CreateRenderer() { RendererImpl* renderer = new RendererImpl(); if (!renderer->Create()) { @@ -42,10 +42,10 @@ void RendererImpl::Destroy() } // OFFSET: LEGO1 0x100a1894 -Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& p_data) +Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& data) { DeviceImpl* device = new DeviceImpl(); - HRESULT result = m_data->CreateDeviceFromD3D(p_data.m_pDirect3D, p_data.m_pDirect3DDevice, &device->m_data); + HRESULT result = m_data->CreateDeviceFromD3D(data.m_pDirect3D, data.m_pDirect3DDevice, &device->m_data); if (!SUCCEEDED(result)) { delete device; device = NULL; @@ -57,16 +57,16 @@ Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& p_data) static int gSetBufferCount = 1; // OFFSET: LEGO1 0x100a1900 -Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& p_data) +Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& data) { DeviceImpl* device = new DeviceImpl(); HRESULT result = m_data->CreateDeviceFromSurface( - const_cast(p_data.m_driverGUID), - p_data.m_pDirectDraw, - p_data.m_pBackBuffer, + const_cast(data.m_driverGUID), + data.m_pDirectDraw, + data.m_pBackBuffer, &device->m_data ); - if (SUCCEEDED(result) && p_data.m_pBackBuffer && gSetBufferCount) { + if (SUCCEEDED(result) && data.m_pBackBuffer && gSetBufferCount) { device->m_data->SetBufferCount(2); } if (!SUCCEEDED(result)) { @@ -77,22 +77,22 @@ Device* RendererImpl::CreateDevice(const DeviceDirectDrawCreateData& p_data) } inline Result RendererCreateView( - IDirect3DRM* p_renderer, - IDirect3DRMDevice* p_device, - IDirect3DRMFrame* p_camera, - IDirect3DRMViewport*& p_view, - unsigned long p_x, - unsigned long p_y, - unsigned long p_width, - unsigned long p_height + IDirect3DRM* pRenderer, + IDirect3DRMDevice* pDevice, + IDirect3DRMFrame* pCamera, + IDirect3DRMViewport*& rpView, + unsigned long x, + unsigned long y, + unsigned long width, + unsigned long height ) { - Result result = ResultVal(p_renderer->CreateViewport(p_device, p_camera, p_x, p_y, p_width, p_height, &p_view)); + Result result = ResultVal(pRenderer->CreateViewport(pDevice, pCamera, x, y, width, height, &rpView)); if (Succeeded(result)) { - result = ViewImpl::ViewportCreateAppData(p_renderer, p_view, p_camera); + result = ViewImpl::ViewportCreateAppData(pRenderer, rpView, pCamera); if (!Succeeded(result)) { - p_view->Release(); - p_view = NULL; + rpView->Release(); + rpView = NULL; } } return result; @@ -100,24 +100,24 @@ inline Result RendererCreateView( // OFFSET: LEGO1 0x100a1a00 View* RendererImpl::CreateView( - const Device* p_device, - const Camera* p_camera, - unsigned long p_x, - unsigned long p_y, - unsigned long p_width, - unsigned long p_height + const Device* pDevice, + const Camera* pCamera, + unsigned long x, + unsigned long y, + unsigned long width, + unsigned long height ) { ViewImpl* view = new ViewImpl(); Result result = RendererCreateView( m_data, - static_cast(p_device)->m_data, - static_cast(p_camera)->m_data, + static_cast(pDevice)->m_data, + static_cast(pCamera)->m_data, view->m_data, - p_x, - p_y, - p_width, - p_height + x, + y, + width, + height ); if (!result) { delete view; @@ -126,25 +126,25 @@ View* RendererImpl::CreateView( return view; } -inline Result RendererCreateGroup(IDirect3DRM* p_renderer, IDirect3DRMFrame* p_parent, IDirect3DRMFrame*& p_group) +inline Result RendererCreateGroup(IDirect3DRM* pRenderer, IDirect3DRMFrame* pParent, IDirect3DRMFrame*& rpGroup) { - Result result = ResultVal(p_renderer->CreateFrame(NULL, &p_group)); - if (Succeeded(result) && p_parent) { - result = ResultVal(p_parent->AddVisual(p_group)); + Result result = ResultVal(pRenderer->CreateFrame(NULL, &rpGroup)); + if (Succeeded(result) && pParent) { + result = ResultVal(pParent->AddVisual(rpGroup)); if (!Succeeded(result)) { - p_group->Release(); - p_group = NULL; + rpGroup->Release(); + rpGroup = NULL; } } return result; } // OFFSET: LEGO1 0x100a1b20 -Group* RendererImpl::CreateGroup(const Group* p_parent) +Group* RendererImpl::CreateGroup(const Group* pParent) { GroupImpl* group = new GroupImpl(); Result result = - RendererCreateGroup(m_data, p_parent ? static_cast(p_parent)->m_data : NULL, group->m_data); + RendererCreateGroup(m_data, pParent ? static_cast(pParent)->m_data : NULL, group->m_data); if (!result) { delete group; group = NULL; @@ -164,11 +164,11 @@ Camera* RendererImpl::CreateCamera() } // OFFSET: LEGO1 0x100a1cf0 -Light* RendererImpl::CreateLight(LightType p_type, float p_r, float p_g, float p_b) +Light* RendererImpl::CreateLight(LightType type, float r, float g, float b) { LightImpl* newLight = new LightImpl(); D3DRMLIGHTTYPE translatedType; - switch (p_type) { + switch (type) { case Ambient: translatedType = D3DRMLIGHT_AMBIENT; break; @@ -192,7 +192,7 @@ Light* RendererImpl::CreateLight(LightType p_type, float p_r, float p_g, float p Result result = ResultVal(m_data->CreateFrame(NULL, &frame)); if (Succeeded(result)) { LPDIRECT3DRMLIGHT d3dLight; - result = ResultVal(m_data->CreateLightRGB(translatedType, p_r, p_g, p_b, &d3dLight)); + result = ResultVal(m_data->CreateLightRGB(translatedType, r, g, b, &d3dLight)); if (!Succeeded(result)) { frame->Release(); } @@ -216,44 +216,44 @@ Light* RendererImpl::CreateLight(LightType p_type, float p_r, float p_g, float p } // OFFSET: LEGO1 0x100a1e90 -Something* RendererImpl::CreateSomething() +Unk* RendererImpl::CreateUnk() { - // Note: I'm fairly certain that Something is not what Tgl calls a + // Note: I'm fairly certain that Unknown is not what Tgl calls a // "Mesh", because the methods on Mesh in the Tgl leak line up much // more closely with a different vtable than the one assigned in // this method (meaning this method is not creating a Mesh). // Maybe this method is something like CreateMeshBuilder where the // Mesh data type in the Tgl leak was split into builder/result? - SomethingImpl* something = new SomethingImpl(); - if (FAILED(m_data->CreateMesh(&something->m_data))) { - delete something; - something = NULL; + UnkImpl* unknown = new UnkImpl(); + if (FAILED(m_data->CreateMesh(&unknown->m_data))) { + delete unknown; + unknown = NULL; } - return something; + return unknown; } inline Result RendererCreateTexture( - IDirect3DRM* p_renderer, - IDirect3DRMTexture*& p_texture, - int p_width, - int p_height, - int p_bytesPerPixel, - void* p_buffer, - int p_useBuffer, - int p_paletteSize, - PaletteEntry* p_palette + IDirect3DRM* renderer, + IDirect3DRMTexture*& texture, + int width, + int height, + int bytesPerPixel, + void* pBuffer, + int useBuffer, + int paletteSize, + PaletteEntry* pEntries ) { TglD3DRMIMAGE* image; Result result; - image = new TglD3DRMIMAGE(p_width, p_height, p_bytesPerPixel, p_buffer, p_useBuffer, p_paletteSize, p_palette); - result = ResultVal(p_renderer->CreateTexture(&image->m_image, &p_texture)); + image = new TglD3DRMIMAGE(width, height, bytesPerPixel, pBuffer, useBuffer, paletteSize, pEntries); + result = ResultVal(renderer->CreateTexture(&image->m_image, &texture)); if (Succeeded(result)) { - result = TextureImpl::SetImage(p_texture, image); + result = TextureImpl::SetImage(texture, image); if (!Succeeded(result)) { - p_texture->Release(); - p_texture = NULL; + texture->Release(); + texture = NULL; delete image; } } @@ -265,26 +265,26 @@ inline Result RendererCreateTexture( // OFFSET: LEGO1 0x100a1f50 Texture* RendererImpl::CreateTexture( - int p_width, - int p_height, - int p_bitsPerTexel, - const void* p_pTexels, - int p_texelsArePersistent, - int p_paletteEntryCount, - const PaletteEntry* p_pEntries + int width, + int height, + int bitsPerTexel, + const void* pTexels, + int texelsArePersistent, + int paletteEntryCount, + const PaletteEntry* pEntries ) { TextureImpl* texture = new TextureImpl(); if (!Succeeded(RendererCreateTexture( m_data, texture->m_data, - p_width, - p_height, - p_bitsPerTexel, - const_cast(p_pTexels), - p_texelsArePersistent, - p_paletteEntryCount, - const_cast(p_pEntries) + width, + height, + bitsPerTexel, + const_cast(pTexels), + texelsArePersistent, + paletteEntryCount, + const_cast(pEntries) ))) { delete texture; texture = NULL; @@ -305,15 +305,15 @@ Texture* RendererImpl::CreateTexture() // OFFSET: LEGO1 0x100a2270 -Result RendererImpl::SetTextureDefaultShadeCount(unsigned long p_shadeCount) +Result RendererImpl::SetTextureDefaultShadeCount(unsigned long shadeCount) { - return ResultVal(m_data->SetDefaultTextureShades(p_shadeCount)); + return ResultVal(m_data->SetDefaultTextureShades(shadeCount)); } // OFFSET: LEGO1 0x100a2290 -Result RendererImpl::SetTextureDefaultColorCount(unsigned long p_colorCount) +Result RendererImpl::SetTextureDefaultColorCount(unsigned long colorCount) { - return ResultVal(m_data->SetDefaultTextureColors(p_colorCount)); + return ResultVal(m_data->SetDefaultTextureColors(colorCount)); } // OFFSET: LEGO1 0x100a22b0 diff --git a/LEGO1/tgl/d3drm/something.cpp b/LEGO1/tgl/d3drm/something.cpp deleted file mode 100644 index 1edbb046..00000000 --- a/LEGO1/tgl/d3drm/something.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "impl.h" - -using namespace TglImpl; - -DECOMP_SIZE_ASSERT(Something, 0x4); -DECOMP_SIZE_ASSERT(SomethingImpl, 0x8); - -// Inlined only -SomethingImpl::~SomethingImpl() -{ - if (m_data) { - m_data->Release(); - m_data = NULL; - } -} - -// OFFSET: LEGO1 0x100a3830 -void* SomethingImpl::ImplementationDataPtr() -{ - return reinterpret_cast(&m_data); -} - -// OFFSET: LEGO1 0x100a3840 STUB -Result SomethingImpl::SetMeshData( - unsigned long p_faceCount, - unsigned long p_vertexCount, - const float (*p_positions)[3], - const float (*p_normals)[3], - const float (*p_textureCoordinates)[2], - unsigned long p_vertexPerFaceCount, - unsigned long* p_faceData -) -{ - return Error; -} - -// OFFSET: LEGO1 0x100a3ae0 -Result SomethingImpl::GetBoundingBox(float p_min[3], float p_max[3]) -{ - D3DRMBOX box; - Result result = ResultVal(m_data->GetBox(&box)); - if (result == Success) { - p_min[0] = box.min.x; - p_min[1] = box.min.y; - p_min[2] = box.min.z; - p_max[0] = box.max.x; - p_max[1] = box.max.y; - p_max[2] = box.max.z; - } - return result; -} - -// OFFSET: LEGO1 0x100a3b40 -Something* SomethingImpl::Clone() -{ - SomethingImpl* mesh = new SomethingImpl(); - int ret = m_data->Clone(0, IID_IDirect3DRMMeshBuilder, (void**) &mesh->m_data); - if (ret < 0) { - delete mesh; - mesh = NULL; - } - return mesh; -} diff --git a/LEGO1/tgl/d3drm/texture.cpp b/LEGO1/tgl/d3drm/texture.cpp index d69fec86..18b121eb 100644 --- a/LEGO1/tgl/d3drm/texture.cpp +++ b/LEGO1/tgl/d3drm/texture.cpp @@ -4,31 +4,31 @@ using namespace TglImpl; DECOMP_SIZE_ASSERT(TglD3DRMIMAGE, 0x40); -inline TglD3DRMIMAGE* TextureGetImage(IDirect3DRMTexture* p_texture) +inline TglD3DRMIMAGE* TextureGetImage(IDirect3DRMTexture* pTexture) { - return reinterpret_cast(p_texture->GetAppData()); + return reinterpret_cast(pTexture->GetAppData()); } // Forward declare to satisfy order check void TextureDestroyCallback(IDirect3DRMObject* pObject, void* pArg); // OFFSET: LEGO1 0x100a12a0 -Result TextureImpl::SetImage(IDirect3DRMTexture* p_self, TglD3DRMIMAGE* p_image) +Result TextureImpl::SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage) { unsigned long appData; Result result; - appData = reinterpret_cast(p_image); + appData = reinterpret_cast(pImage); // This is here because in the original code they asserted // on the return value being NULL. - TextureGetImage(p_self); + TextureGetImage(pSelf); - result = ResultVal(p_self->SetAppData(appData)); - if (Succeeded(result) && p_image) { - result = ResultVal(p_self->AddDestroyCallback(TextureDestroyCallback, NULL)); + result = ResultVal(pSelf->SetAppData(appData)); + if (Succeeded(result) && pImage) { + result = ResultVal(pSelf->AddDestroyCallback(TextureDestroyCallback, NULL)); if (!Succeeded(result)) { - p_self->SetAppData(0); + pSelf->SetAppData(0); } } return result; @@ -44,13 +44,13 @@ void TextureDestroyCallback(IDirect3DRMObject* pObject, void* pArg) // OFFSET: LEGO1 0x100a1330 TglD3DRMIMAGE::TglD3DRMIMAGE( - int p_width, - int p_height, - int p_depth, - void* p_buffer, - int p_useBuffer, - int p_paletteSize, - PaletteEntry* p_palette + int width, + int height, + int depth, + void* pBuffer, + int useBuffer, + int paletteSize, + PaletteEntry* pEntries ) { m_image.aspectx = 1; @@ -69,11 +69,11 @@ TglD3DRMIMAGE::TglD3DRMIMAGE( m_image.palette_size = 0; m_image.palette = NULL; m_texelsAllocatedByClient = 0; - if (p_buffer != NULL) { - CreateBuffer(p_width, p_height, p_depth, p_buffer, p_useBuffer); + if (pBuffer != NULL) { + CreateBuffer(width, height, depth, pBuffer, useBuffer); } - if (p_palette != NULL) { - InitializePalette(p_paletteSize, p_palette); + if (pEntries != NULL) { + InitializePalette(paletteSize, pEntries); } } @@ -87,39 +87,39 @@ void TglD3DRMIMAGE::Destroy() } // OFFSET: LEGO1 0x100a13e0 STUB -Result TglD3DRMIMAGE::CreateBuffer(int p_width, int p_height, int p_depth, void* p_buffer, int p_useBuffer) +Result TglD3DRMIMAGE::CreateBuffer(int width, int height, int depth, void* pBuffer, int useBuffer) { return Error; } // OFFSET: LEGO1 0x100a1510 -void TglD3DRMIMAGE::FillRowsOfTexture(int p_y, int p_height, char* p_content) +void TglD3DRMIMAGE::FillRowsOfTexture(int y, int height, char* pContent) { // The purpose is clearly this but I can't get the assembly to line up. - memcpy((char*) m_image.buffer1 + (p_y * m_image.bytes_per_line), p_content, p_height * m_image.bytes_per_line); + memcpy((char*) m_image.buffer1 + (y * m_image.bytes_per_line), pContent, height * m_image.bytes_per_line); } // OFFSET: LEGO1 0x100a1550 -Result TglD3DRMIMAGE::InitializePalette(int p_paletteSize, PaletteEntry* p_palette) +Result TglD3DRMIMAGE::InitializePalette(int paletteSize, PaletteEntry* pEntries) { // This function is a 100% match if the PaletteEntry class is copied // into into the TglD3DRMIMAGE class instead of being a global struct. - if (m_image.palette_size != p_paletteSize) { + if (m_image.palette_size != paletteSize) { if (m_image.palette != NULL) { free(m_image.palette); m_image.palette = NULL; m_image.palette_size = 0; } - if (p_paletteSize > 0) { - m_image.palette = (D3DRMPALETTEENTRY*) malloc(4 * p_paletteSize); - m_image.palette_size = p_paletteSize; + if (paletteSize > 0) { + m_image.palette = (D3DRMPALETTEENTRY*) malloc(4 * paletteSize); + m_image.palette_size = paletteSize; } } - if (p_paletteSize > 0) { - for (int i = 0; i < p_paletteSize; i++) { - m_image.palette[i].red = p_palette[i].m_red; - m_image.palette[i].green = p_palette[i].m_green; - m_image.palette[i].blue = p_palette[i].m_blue; + if (paletteSize > 0) { + for (int i = 0; i < paletteSize; i++) { + m_image.palette[i].red = pEntries[i].m_red; + m_image.palette[i].green = pEntries[i].m_green; + m_image.palette[i].blue = pEntries[i].m_blue; m_image.palette[i].flags = D3DRMPALETTE_READONLY; } } @@ -136,10 +136,10 @@ TextureImpl::~TextureImpl() } // OFFSET: LEGO1 0x100a3c10 -Result TextureImpl::SetTexels(int p_width, int p_height, int p_bitsPerTexel, void* p_texels) +Result TextureImpl::SetTexels(int width, int height, int bitsPerTexel, void* pTexels) { TglD3DRMIMAGE* image = TextureGetImage(m_data); - Result result = image->CreateBuffer(p_width, p_height, p_bitsPerTexel, p_texels, TRUE); + Result result = image->CreateBuffer(width, height, bitsPerTexel, pTexels, TRUE); if (Succeeded(result)) { result = ResultVal(m_data->Changed(TRUE, FALSE)); } @@ -147,50 +147,50 @@ Result TextureImpl::SetTexels(int p_width, int p_height, int p_bitsPerTexel, voi } // OFFSET: LEGO1 0x100a3c60 -void TextureImpl::FillRowsOfTexture(int p_y, int p_height, void* p_buffer) +void TextureImpl::FillRowsOfTexture(int y, int height, void* pBuffer) { TglD3DRMIMAGE* image = TextureGetImage(m_data); - image->FillRowsOfTexture(p_y, p_height, (char*) p_buffer); + image->FillRowsOfTexture(y, height, (char*) pBuffer); } // OFFSET: LEGO1 0x100a3c90 -Result TextureImpl::Changed(int p_texelsChanged, int p_paletteChanged) +Result TextureImpl::Changed(int texelsChanged, int paletteChanged) { - return ResultVal(m_data->Changed(p_texelsChanged, p_paletteChanged)); + return ResultVal(m_data->Changed(texelsChanged, paletteChanged)); } // OFFSET: LEGO1 0x100a3d00 Result TextureImpl::GetBufferAndPalette( - int* p_width, - int* p_height, - int* p_depth, - void** p_buffer, - int* p_paletteSize, - PaletteEntry** p_palette + int* width, + int* height, + int* depth, + void** pBuffer, + int* paletteSize, + PaletteEntry** pEntries ) { // Something really doesn't match here, not sure what's up. TglD3DRMIMAGE* image = TextureGetImage(m_data); - *p_width = image->m_image.width; - *p_height = image->m_image.height; - *p_depth = image->m_image.depth; - *p_buffer = image->m_image.buffer1; - *p_paletteSize = image->m_image.palette_size; + *width = image->m_image.width; + *height = image->m_image.height; + *depth = image->m_image.depth; + *pBuffer = image->m_image.buffer1; + *paletteSize = image->m_image.palette_size; for (int i = 0; i < image->m_image.palette_size; i++) { - p_palette[i]->m_red = image->m_image.palette[i].red; - p_palette[i]->m_green = image->m_image.palette[i].green; - p_palette[i]->m_blue = image->m_image.palette[i].blue; + pEntries[i]->m_red = image->m_image.palette[i].red; + pEntries[i]->m_green = image->m_image.palette[i].green; + pEntries[i]->m_blue = image->m_image.palette[i].blue; } return Success; } // OFFSET: LEGO1 0x100a3d40 -Result TextureImpl::SetPalette(int p_entryCount, PaletteEntry* p_entries) +Result TextureImpl::SetPalette(int entryCount, PaletteEntry* pEntries) { // Not 100% confident this is supposed to directly be forwarding arguments, // but it probably is given FillRowsOfTexture matches doing that. TglD3DRMIMAGE* image = TextureGetImage(m_data); - image->InitializePalette(p_entryCount, p_entries); + image->InitializePalette(entryCount, pEntries); m_data->Changed(FALSE, TRUE); return Success; } diff --git a/LEGO1/tgl/d3drm/unk.cpp b/LEGO1/tgl/d3drm/unk.cpp new file mode 100644 index 00000000..53eb72ca --- /dev/null +++ b/LEGO1/tgl/d3drm/unk.cpp @@ -0,0 +1,63 @@ +#include "impl.h" + +using namespace TglImpl; + +DECOMP_SIZE_ASSERT(Unk, 0x4); +DECOMP_SIZE_ASSERT(UnkImpl, 0x8); + +// Inlined only +UnkImpl::~UnkImpl() +{ + if (m_data) { + m_data->Release(); + m_data = NULL; + } +} + +// OFFSET: LEGO1 0x100a3830 +void* UnkImpl::ImplementationDataPtr() +{ + return reinterpret_cast(&m_data); +} + +// OFFSET: LEGO1 0x100a3840 STUB +Result UnkImpl::SetMeshData( + unsigned long faceCount, + unsigned long vertexCount, + const float (*pPositions)[3], + const float (*pNormals)[3], + const float (*pTextureCoordinates)[2], + unsigned long vertexPerFaceCount, + unsigned long* pFaceData +) +{ + return Error; +} + +// OFFSET: LEGO1 0x100a3ae0 +Result UnkImpl::GetBoundingBox(float min[3], float max[3]) +{ + D3DRMBOX box; + Result result = ResultVal(m_data->GetBox(&box)); + if (result == Success) { + min[0] = box.min.x; + min[1] = box.min.y; + min[2] = box.min.z; + max[0] = box.max.x; + max[1] = box.max.y; + max[2] = box.max.z; + } + return result; +} + +// OFFSET: LEGO1 0x100a3b40 +Unk* UnkImpl::Clone() +{ + UnkImpl* mesh = new UnkImpl(); + int ret = m_data->Clone(0, IID_IDirect3DRMMeshBuilder, (void**) &mesh->m_data); + if (ret < 0) { + delete mesh; + mesh = NULL; + } + return mesh; +} diff --git a/LEGO1/tgl/d3drm/view.cpp b/LEGO1/tgl/d3drm/view.cpp index 68f76a3a..c51a692a 100644 --- a/LEGO1/tgl/d3drm/view.cpp +++ b/LEGO1/tgl/d3drm/view.cpp @@ -3,7 +3,7 @@ using namespace TglImpl; struct ViewportAppData { - ViewportAppData(IDirect3DRM* p_renderer); + ViewportAppData(IDirect3DRM* pRenderer); ~ViewportAppData(); IDirect3DRMFrame* m_pLightFrame; @@ -17,9 +17,9 @@ struct ViewportAppData { DECOMP_SIZE_ASSERT(ViewportAppData, 0x18); // OFFSET: LEGO1 0x100a10b0 -ViewportAppData::ViewportAppData(IDirect3DRM* p_renderer) +ViewportAppData::ViewportAppData(IDirect3DRM* pRenderer) { - p_renderer->CreateFrame(NULL, &m_pLightFrame); + pRenderer->CreateFrame(NULL, &m_pLightFrame); m_pCamera = NULL; m_pLastRenderedFrame = NULL; m_backgroundColorRed = 0.0f; @@ -43,20 +43,20 @@ ViewportAppData::~ViewportAppData() } // Forward declare to satisfy order check -void ViewportDestroyCallback(IDirect3DRMObject* p_object, void* p_arg); +void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg); // OFFSET: LEGO1 0x100a1160 -Result ViewImpl::ViewportCreateAppData(IDirect3DRM* p_device, IDirect3DRMViewport* p_view, IDirect3DRMFrame* p_camera) +Result ViewImpl::ViewportCreateAppData(IDirect3DRM* pDevice, IDirect3DRMViewport* pView, IDirect3DRMFrame* pCamera) { - ViewportAppData* data = new ViewportAppData(p_device); - data->m_pCamera = p_camera; - Result result = ResultVal(p_view->SetAppData(reinterpret_cast(data))); + ViewportAppData* data = new ViewportAppData(pDevice); + data->m_pCamera = pCamera; + Result result = ResultVal(pView->SetAppData(reinterpret_cast(data))); if (Succeeded(result)) { - result = ResultVal(p_view->AddDestroyCallback(ViewportDestroyCallback, data)); + result = ResultVal(pView->AddDestroyCallback(ViewportDestroyCallback, data)); } if (!Succeeded(result)) { delete data; - p_view->SetAppData(0); + pView->SetAppData(0); } return result; } @@ -81,9 +81,9 @@ inline Result ViewRestoreFrameAfterRender( } // OFFSET: LEGO1 0x100a1240 -void ViewportDestroyCallback(IDirect3DRMObject* p_object, void* p_arg) +void ViewportDestroyCallback(IDirect3DRMObject* pObject, void* pArg) { - ViewportAppData* pViewportAppData = reinterpret_cast(p_arg); + ViewportAppData* pViewportAppData = reinterpret_cast(pArg); ViewRestoreFrameAfterRender( pViewportAppData->m_pLastRenderedFrame, @@ -96,7 +96,7 @@ void ViewportDestroyCallback(IDirect3DRMObject* p_object, void* p_arg) // OFFSET: LEGO1 0x100a1290 Result ViewportPickImpl( - IDirect3DRMViewport* p_viewport, + IDirect3DRMViewport* pViewport, int x, int y, const Group** ppGroupsToPickFrom, @@ -109,14 +109,14 @@ Result ViewportPickImpl( return Error; } -inline ViewportAppData* ViewportGetData(IDirect3DRMViewport* p_viewport) +inline ViewportAppData* ViewportGetData(IDirect3DRMViewport* pViewport) { - return reinterpret_cast(p_viewport->GetAppData()); + return reinterpret_cast(pViewport->GetAppData()); } -inline IDirect3DRMFrame* ViewportGetLightFrame(IDirect3DRMViewport* p_viewport) +inline IDirect3DRMFrame* ViewportGetLightFrame(IDirect3DRMViewport* pViewport) { - return ViewportGetData(p_viewport)->m_pLightFrame; + return ViewportGetData(pViewport)->m_pLightFrame; } // Inlined only @@ -135,25 +135,25 @@ void* ViewImpl::ImplementationDataPtr() } // OFFSET: LEGO1 0x100a2d90 -Result ViewImpl::Add(const Light* p_light) +Result ViewImpl::Add(const Light* pLight) { - const LightImpl* light = static_cast(p_light); + const LightImpl* light = static_cast(pLight); IDirect3DRMFrame* frame = light->ImplementationData(); return ResultVal(ViewportGetLightFrame(m_data)->AddChild(frame)); } // OFFSET: LEGO1 0x100a2dc0 -Result ViewImpl::Remove(const Light* p_light) +Result ViewImpl::Remove(const Light* pLight) { - const LightImpl* light = static_cast(p_light); + const LightImpl* light = static_cast(pLight); IDirect3DRMFrame* frame = light->ImplementationData(); return ResultVal(ViewportGetLightFrame(m_data)->DeleteChild(frame)); } // OFFSET: LEGO1 0x100a2df0 -Result ViewImpl::SetCamera(const Camera* p_camera) +Result ViewImpl::SetCamera(const Camera* pCamera) { - const CameraImpl* camera = static_cast(p_camera); + const CameraImpl* camera = static_cast(pCamera); IDirect3DRMFrame* frame = camera->ImplementationData(); ViewportAppData* pViewportAppData; @@ -172,19 +172,19 @@ Result ViewImpl::SetCamera(const Camera* p_camera) } // OFFSET: LEGO1 0x100a2e70 -Result ViewImpl::SetProjection(ProjectionType p_type) +Result ViewImpl::SetProjection(ProjectionType type) { - return ResultVal(m_data->SetProjection(Translate(p_type))); + return ResultVal(m_data->SetProjection(Translate(type))); } // OFFSET: LEGO1 0x100a2eb0 -Result ViewImpl::SetFrustrum(float p_frontClippingDistance, float p_backClippingDistance, float p_degrees) +Result ViewImpl::SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees) { - float field = p_frontClippingDistance * tan(DegreesToRadians(p_degrees / 2)); + float field = frontClippingDistance * tan(DegreesToRadians(degrees / 2)); Result result; - result = ResultVal(m_data->SetFront(p_frontClippingDistance)); + result = ResultVal(m_data->SetFront(frontClippingDistance)); if (Succeeded(result)) { - result = ResultVal(m_data->SetBack(p_backClippingDistance)); + result = ResultVal(m_data->SetBack(backClippingDistance)); } if (Succeeded(result)) { result = ResultVal(m_data->SetField(field)); @@ -194,28 +194,28 @@ Result ViewImpl::SetFrustrum(float p_frontClippingDistance, float p_backClipping } // OFFSET: LEGO1 0x100a2f30 -Result ViewImpl::SetBackgroundColor(float p_r, float p_g, float p_b) +Result ViewImpl::SetBackgroundColor(float r, float g, float b) { Result ret = Success; // Note, this method in the shipped game is very diverged from // the Tgl leak code. ViewportAppData* data = ViewportGetData(m_data); - data->m_backgroundColorRed = p_r; - data->m_backgroundColorGreen = p_g; - data->m_backgroundColorBlue = p_b; + data->m_backgroundColorRed = r; + data->m_backgroundColorGreen = g; + data->m_backgroundColorBlue = b; if (data->m_pLastRenderedFrame) { - ret = ResultVal(data->m_pLastRenderedFrame->SetSceneBackgroundRGB(p_r, p_g, p_b)); + ret = ResultVal(data->m_pLastRenderedFrame->SetSceneBackgroundRGB(r, g, b)); } return ret; } // OFFSET: LEGO1 0x100a2f80 -Result ViewImpl::GetBackgroundColor(float* p_r, float* p_g, float* p_b) +Result ViewImpl::GetBackgroundColor(float* r, float* g, float* b) { ViewportAppData* data = ViewportGetData(m_data); - *p_r = data->m_backgroundColorRed; - *p_g = data->m_backgroundColorGreen; - *p_b = data->m_backgroundColorBlue; + *r = data->m_backgroundColorRed; + *g = data->m_backgroundColorGreen; + *b = data->m_backgroundColorBlue; return Success; } @@ -254,11 +254,11 @@ inline Result ViewPrepareFrameForRender( } // OFFSET: LEGO1 0x100a2fd0 -Result ViewImpl::Render(const Light* p_camera) +Result ViewImpl::Render(const Light* pCamera) { ViewportAppData* appdata = ViewportGetData(m_data); - IDirect3DRMFrame* light = static_cast(p_camera)->ImplementationData(); + IDirect3DRMFrame* light = static_cast(pCamera)->ImplementationData(); IDirect3DRMFrame* lastRendered = appdata->m_pLastRenderedFrame; if (light != lastRendered) { @@ -332,23 +332,23 @@ Result ViewImpl::TransformWorldToScreen(const float world[3], float screen[4]) } // OFFSET: LEGO1 0x100a3160 -Result ViewImpl::TransformScreenToWorld(const float p_screen[4], float p_world[3]) +Result ViewImpl::TransformScreenToWorld(const float screen[4], float world[3]) { // 100% match minus instruction reordering. D3DVECTOR d3dRMWorld; D3DRMVECTOR4D d3dScreen; - d3dScreen.x = p_screen[0]; - d3dScreen.y = p_screen[1]; - d3dScreen.z = p_screen[2]; - d3dScreen.w = p_screen[3]; + d3dScreen.x = screen[0]; + d3dScreen.y = screen[1]; + d3dScreen.z = screen[2]; + d3dScreen.w = screen[3]; Result result; result = ResultVal(m_data->InverseTransform(&d3dRMWorld, &d3dScreen)); if (Succeeded(result)) { - p_world[0] = d3dRMWorld.x; - p_world[1] = d3dRMWorld.y; - p_world[2] = d3dRMWorld.z; + world[0] = d3dRMWorld.x; + world[1] = d3dRMWorld.y; + world[2] = d3dRMWorld.z; } return result; diff --git a/LEGO1/tgl/tgl.h b/LEGO1/tgl/tgl.h index 0006e4db..9bf4ce3a 100644 --- a/LEGO1/tgl/tgl.h +++ b/LEGO1/tgl/tgl.h @@ -96,7 +96,7 @@ class Camera; class Group; class Mesh; class Texture; -class Something; +class Unk; // VTABLE 0x100db980 class Object { @@ -123,20 +123,20 @@ class Renderer : public Object { unsigned long height ) = 0; virtual Camera* CreateCamera() = 0; - virtual Light* CreateLight(LightType, float p_r, float p_g, float p_b) = 0; - virtual Group* CreateGroup(const Group* p_parent = 0) = 0; + virtual Light* CreateLight(LightType, float r, float g, float b) = 0; + virtual Group* CreateGroup(const Group* pParent = 0) = 0; // vtable+0x20 - virtual Something* CreateSomething() = 0; + virtual Unk* CreateUnk() = 0; virtual Texture* CreateTexture() = 0; virtual Texture* CreateTexture( - int p_width, - int p_height, - int p_bitsPerTexel, - const void* p_pTexels, - int p_pTexelsArePersistent, - int p_paletteEntryCount, - const PaletteEntry* p_pEntries + int width, + int height, + int bitsPerTexel, + const void* pTexels, + int pTexelsArePersistent, + int paletteEntryCount, + const PaletteEntry* pEntries ) = 0; virtual Result SetTextureDefaultShadeCount(unsigned long) = 0; @@ -174,11 +174,11 @@ class View : public Object { // vtable+0x10 virtual Result SetCamera(const Camera*) = 0; virtual Result SetProjection(ProjectionType) = 0; - virtual Result SetFrustrum(float p_frontClippingDistance, float p_backClippingDistance, float p_degrees) = 0; - virtual Result SetBackgroundColor(float p_r, float p_g, float p_b) = 0; + virtual Result SetFrustrum(float frontClippingDistance, float backClippingDistance, float degrees) = 0; + virtual Result SetBackgroundColor(float r, float g, float b) = 0; // vtable+0x20 - virtual Result GetBackgroundColor(float* p_r, float* p_g, float* p_b) = 0; + virtual Result GetBackgroundColor(float* r, float* g, float* b) = 0; virtual Result Clear() = 0; virtual Result Render(const Light*) = 0; virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height) = 0; @@ -229,13 +229,13 @@ class Camera : public Object { class Light : public Object { public: virtual Result SetTransformation(const FloatMatrix4&) = 0; - virtual Result SetColor(float p_r, float p_g, float p_b) = 0; + virtual Result SetColor(float r, float g, float b) = 0; }; // VTABLE 0x100dbbb0 class Mesh : public Object { public: - virtual Result SetColor(float p_r, float p_g, float p_b, float p_a) = 0; + virtual Result SetColor(float r, float g, float b, float a) = 0; virtual Result SetTexture(const Texture*) = 0; virtual Result GetTexture(Texture*&) = 0; @@ -243,17 +243,17 @@ class Mesh : public Object { virtual Result SetShadingModel(ShadingModel) = 0; // Clone data in underlying group - virtual Mesh* DeepClone(Something*) = 0; + virtual Mesh* DeepClone(Unk*) = 0; // Just get another Group pointing to the same underlying data - virtual Mesh* ShallowClone(Something*) = 0; + virtual Mesh* ShallowClone(Unk*) = 0; }; // VTABLE 0x100dbaa0 class Group : public Object { public: virtual Result SetTransformation(const FloatMatrix4&) = 0; - virtual Result SetColor(float p_r, float p_g, float p_b, float p_a) = 0; + virtual Result SetColor(float r, float g, float b, float a) = 0; virtual Result SetTexture(const Texture*) = 0; virtual Result GetTexture(Texture*&) = 0; virtual Result SetMaterialMode(MaterialMode) = 0; @@ -272,39 +272,39 @@ class Group : public Object { // was not in the leaked Tgl code. My suspicion is that it's // some kind of builder class for creating meshes. // VTABLE 0x100dbb30 -class Something : public Object { +class Unk : public Object { public: virtual Result SetMeshData( - unsigned long p_faceCount, - unsigned long p_vertexCount, - const float (*p_positions)[3], - const float (*p_normals)[3], - const float (*p_textureCoordinates)[2], - unsigned long p_vertexPerFaceCount, - unsigned long* p_faceData + unsigned long faceCount, + unsigned long vertexCount, + const float (*pPositions)[3], + const float (*pNormals)[3], + const float (*pTextureCoordinates)[2], + unsigned long vertexPerFaceCount, + unsigned long* pFaceData ) = 0; - virtual Result GetBoundingBox(float p_min[3], float p_max[3]) = 0; - virtual Something* Clone() = 0; + virtual Result GetBoundingBox(float min[3], float max[3]) = 0; + virtual Unk* Clone() = 0; }; // VTABLE 0x100dbb68 class Texture : public Object { public: // vtable+0x08 - virtual Result SetTexels(int p_width, int p_height, int p_bitsPerTexel, void* p_texels) = 0; - virtual void FillRowsOfTexture(int p_y, int p_height, void* p_buffer) = 0; + virtual Result SetTexels(int width, int height, int bitsPerTexel, void* pTexels) = 0; + virtual void FillRowsOfTexture(int y, int height, void* pBuffer) = 0; // vtable+0x10 - virtual Result Changed(int p_texelsChanged, int p_paletteChanged) = 0; + virtual Result Changed(int texelsChanged, int paletteChanged) = 0; virtual Result GetBufferAndPalette( - int* p_width, - int* p_height, - int* p_depth, - void** p_buffer, - int* p_paletteSize, - PaletteEntry** p_palette + int* pWidth, + int* pHeight, + int* pDepth, + void** ppBuffer, + int* pPaletteSize, + PaletteEntry** ppPalette ) = 0; - virtual Result SetPalette(int p_entryCount, PaletteEntry* p_entries) = 0; + virtual Result SetPalette(int entryCount, PaletteEntry* pEntries) = 0; }; } // namespace Tgl diff --git a/LEGO1/viewmanager/viewlodlist.h b/LEGO1/viewmanager/viewlodlist.h index 9e7c778c..12817ff9 100644 --- a/LEGO1/viewmanager/viewlodlist.h +++ b/LEGO1/viewmanager/viewlodlist.h @@ -44,7 +44,7 @@ class ViewLODList : public LODList { // ??? for now, until we have symbol management typedef const char* ROIName; struct ROINameComparator { - int operator()(const ROIName& rName1, const ROIName& rName2) const + bool operator()(const ROIName& rName1, const ROIName& rName2) const { return strcmp((const char*) rName1, (const char*) rName2) > 0; }