diff --git a/Toshi/Include/TKernel/TFreeList.h b/Toshi/Include/TKernel/TFreeList.h index db93d90..cc7b228 100644 --- a/Toshi/Include/TKernel/TFreeList.h +++ b/Toshi/Include/TKernel/TFreeList.h @@ -2,6 +2,10 @@ #include "TMemory.h" +// There is some kind of critical issue with free lists which causes memory being uninitialised, so we disable it for now +#define DECLARE_FREELIST(class_name) +#define IMPLEMENT_FREELIST(class_name, InitialSize, GrowSize) +#if 0 #define DECLARE_FREELIST(class_name) \ public: \ static TPVOID TOSHI_API operator new(TUINT s, TPVOID mem) { return mem; } \ @@ -14,7 +18,7 @@ private: static Toshi::TFreeList ms_oFreeList; #define IMPLEMENT_FREELIST(class_name, InitialSize, GrowSize) \ Toshi::TFreeList class_name::ms_oFreeList = Toshi::TFreeList(sizeof(class_name), InitialSize, GrowSize, TNULL); - +#endif TOSHI_NAMESPACE_BEGIN class TKERNELINTERFACE_EXPORTS TFreeList diff --git a/Toshi/Include/TKernel/TMemory.h b/Toshi/Include/TKernel/TMemory.h index e9e8867..efe3236 100644 --- a/Toshi/Include/TKernel/TMemory.h +++ b/Toshi/Include/TKernel/TMemory.h @@ -53,7 +53,7 @@ class TKERNELINTERFACE_EXPORTS TMemory public: static TBOOL TOSHI_API Initialise(); - static void TOSHI_API DebugPrintHALMemInfo(TCHAR const*) {}; + static void TOSHI_API DebugPrintHALMemInfo(TCHAR const* a_pPrint) { }; static TMemory& TOSHI_API GetMemMangager(); static MemBlock* TOSHI_API GetGlobalBlock(); static MemNode* TOSHI_API GetMemNodeFromAddress(TPVOID a_pAddr); diff --git a/Toshi/Include/TKernel/TNodeTree.h b/Toshi/Include/TKernel/TNodeTree.h index 17006b8..51f998e 100644 --- a/Toshi/Include/TKernel/TNodeTree.h +++ b/Toshi/Include/TKernel/TNodeTree.h @@ -62,16 +62,16 @@ class TNodeTree /** * Inserts node as a child of another node. * - * @param parentNode Pointer to the parent node. - * @param a_pSourceNode Pointer to the node you want to insert. + * @param parentNode Reference to the parent node. + * @param a_rSourceNode Reference to the node you want to insert. */ - void Insert(T* parentNode, T* a_pSourceNode) + void Insert(T* parentNode, T* a_rSourceNode) { // Toshi::TNodeTree::Insert - 00691aa0 - TASSERT(a_pSourceNode->IsLinked() == TFALSE); + TASSERT(a_rSourceNode->IsLinked() == TFALSE); // Remove the source node from the tree - Remove(*a_pSourceNode, TFALSE); + Remove(*a_rSourceNode, TFALSE); // Get the first attached to parent node T* firstAttached = parentNode->Child(); @@ -81,27 +81,27 @@ class TNodeTree // Attach node to other attached nodes T* lastAttached = firstAttached->Prev(); - lastAttached->m_Next = a_pSourceNode; - firstAttached->m_Prev = a_pSourceNode; + lastAttached->m_Next = a_rSourceNode; + firstAttached->m_Prev = a_rSourceNode; - a_pSourceNode->m_Next = firstAttached; - a_pSourceNode->m_Prev = lastAttached; + a_rSourceNode->m_Next = firstAttached; + a_rSourceNode->m_Prev = lastAttached; } else { // Attach node as the first one - parentNode->m_Child = a_pSourceNode; + parentNode->m_Child = a_rSourceNode; } - a_pSourceNode->m_Tree = this; - a_pSourceNode->m_Parent = parentNode; + a_rSourceNode->m_Tree = this; + a_rSourceNode->m_Parent = parentNode; m_Count++; } /** * Inserts node to the default tree. * - * @param a_pSourceNode Pointer to the node you want to insert. + * @param a_rSourceNode Pointer to the node you want to insert. */ void InsertAtRoot(T* sourceNode) { @@ -109,7 +109,7 @@ class TNodeTree } /** - * Tries to remove a_pSourceNode from the tree and inserts it to the parentNode or to the root + * Tries to remove a_rSourceNode from the tree and inserts it to the parentNode or to the root */ void ReInsert(T* parentNode, T* sourceNode) { @@ -132,24 +132,20 @@ class TNodeTree // Toshi::TNodeTree::Remove - 00691e70 TNodeTree* nodeRoot = node.GetTree(); T* nodeParent = node.Parent(); - - if (nodeRoot != TNULL) - { + + if (nodeRoot) { // Check if the node belongs to the current tree - if (nodeRoot != this) - { + if (nodeRoot != this) { TASSERT(!"A node is being removed from a different tree from it's current tree."); return &node; } - m_Count--; } - if (flag) - { + if (flag) { T* attachedNode = node.Child(); - while (attachedNode != TNULL) + while (attachedNode) { TNodeTree* nodeRoot = node.GetTree(); diff --git a/Toshi/Include/TKernel/TVector2.h b/Toshi/Include/TKernel/TVector2.h index a88a93e..c51e6f3 100644 --- a/Toshi/Include/TKernel/TVector2.h +++ b/Toshi/Include/TKernel/TVector2.h @@ -6,6 +6,40 @@ TOSHI_NAMESPACE_BEGIN class TKERNELINTERFACE_EXPORTS TVector2 { +public: + + TVector2() + { + + } + + TVector2(TFLOAT a_fX, TFLOAT a_fY) + { + Set(a_fX, a_fY); + } + + TVector2(const TFLOAT a_pfVec[2]) + { + Set(a_pfVec); + } + + void Set(TFLOAT a_fX, TFLOAT a_fY) + { + m_fX = a_fX; + m_fY = a_fY; + } + + void Set(const TFLOAT a_pfVec[2]) + { + m_fX = a_pfVec[0]; + m_fY = a_pfVec[1]; + } + + static const TVector2 VEC_ZERO; + static const TVector2 VEC_POSX; + static const TVector2 VEC_POSY; + static const TVector2 VEC_NEGX; + static const TVector2 VEC_NEGY; private: TFLOAT m_fX; // 0x0 TFLOAT m_fY; // 0x4 diff --git a/Toshi/Include/TRender/TRenderInterface.h b/Toshi/Include/TRender/TRenderInterface.h index 9492669..1ba01b0 100644 --- a/Toshi/Include/TRender/TRenderInterface.h +++ b/Toshi/Include/TRender/TRenderInterface.h @@ -103,7 +103,6 @@ class TRENDERINTERFACE_EXPORTS TRenderInterface : public TObject public: - TResource* CreateResource(const TClass* a_pClass, TPCCHAR a_szResName, TResource* a_pResource); const TRenderAdapter::Mode::Device* FindDevice(const DisplayParams* a_pDisplayParams); diff --git a/Toshi/Include/TRenderD3D/TTextureResourceD3D.h b/Toshi/Include/TRenderD3D/TTextureResourceD3D.h index 192cf86..7e4d468 100644 --- a/Toshi/Include/TRenderD3D/TTextureResourceD3D.h +++ b/Toshi/Include/TRenderD3D/TTextureResourceD3D.h @@ -9,7 +9,7 @@ TOSHI_NAMESPACE_BEGIN class TRENDERINTERFACED3D_EXPORTS TTextureResourceHAL : public TTextureResource { DECLARE_DYNAMIC(TTextureResourceHAL) - DECLARE_FREELIST(TTextureResourceHAL) + //DECLARE_FREELIST(TTextureResourceHAL) enum MIPMAPFLAGS { diff --git a/Toshi/Source/TKernel/TVector2.cpp b/Toshi/Source/TKernel/TVector2.cpp index adeb555..a793a15 100644 --- a/Toshi/Source/TKernel/TVector2.cpp +++ b/Toshi/Source/TKernel/TVector2.cpp @@ -1 +1,11 @@ -#include "TVector2.h" \ No newline at end of file +#include "TVector2.h" + +TOSHI_NAMESPACE_BEGIN + +const TVector2 TVector2::VEC_ZERO = { 0, 0 }; +const TVector2 TVector2::VEC_POSX = { 1, 0 }; +const TVector2 TVector2::VEC_POSY = { 0, 1 }; +const TVector2 TVector2::VEC_NEGX = { -1, 0 }; +const TVector2 TVector2::VEC_NEGY = { 0, -1 }; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Source/TRender/TRenderInterface.cpp b/Toshi/Source/TRender/TRenderInterface.cpp index 8b6ff54..c4953e0 100644 --- a/Toshi/Source/TRender/TRenderInterface.cpp +++ b/Toshi/Source/TRender/TRenderInterface.cpp @@ -120,7 +120,7 @@ void TRenderInterface::DestroySystemResources() } TResource* TRenderInterface::CreateResource(const TClass* a_pClass, TPCCHAR a_szResName, TResource* a_pParent) -{ +{ TASSERT(TNULL != a_pClass); TASSERT(a_pClass->IsA(TGetClass(TResource))); diff --git a/Toshi/Source/TRenderD3D/TTextureResourceD3D.cpp b/Toshi/Source/TRenderD3D/TTextureResourceD3D.cpp index 42c9758..6abbd32 100644 --- a/Toshi/Source/TRenderD3D/TTextureResourceD3D.cpp +++ b/Toshi/Source/TRenderD3D/TTextureResourceD3D.cpp @@ -6,7 +6,7 @@ TOSHI_NAMESPACE_USING IMPLEMENT_DYNCREATE(TTextureResourceHAL, TTextureResource) -IMPLEMENT_FREELIST(TTextureResourceHAL, 0, 8) +//IMPLEMENT_FREELIST(TTextureResourceHAL, 0, 8) TBOOL TTextureResourceHAL::Validate() { @@ -20,8 +20,10 @@ TBOOL TTextureResourceHAL::Validate() if (m_iLoadFromMemory) { // Load from memory if (m_pData && m_uiDataSize != 0) { - if (HASFLAG(m_eTextureFlags & 0x40) && !CreateFromFormat()) { - return TFALSE; + if (HASFLAG(m_eTextureFlags & 0x40)) { + if (!CreateFromFormat()) { + return TFALSE; + } } else { TUINT uiLayout = m_eTextureFlags & 0x38; @@ -36,7 +38,22 @@ TBOOL TTextureResourceHAL::Validate() CreateFromMemory8888(m_uiWidth, m_uiHeight, 0, m_pData); } else { - CreateFromMemoryDDS(m_uiWidth, m_uiHeight, -1, m_pData); + HRESULT hRes = D3DXCreateTextureFromFileInMemoryEx(pRenderer->GetD3DDevice(), + m_pData, + m_uiDataSize, + -1, + -1, + -1, + 0, + D3DFMT_UNKNOWN, + D3DPOOL_MANAGED, + D3DX_FILTER_BOX, + D3DX_FILTER_BOX, + 0, + &m_oImageInfo, + NULL, + &m_pD3DTexture); + TRenderD3DInterface::TD3DAssert(hRes, TNULL); } } }