From 5369f96a056f6331012bb091df638d13fc514106 Mon Sep 17 00:00:00 2001 From: AdventureT Date: Sat, 9 Dec 2023 11:58:55 +0100 Subject: [PATCH] Created TLString.h --- Toshi/Include/TKernel/TLString.h | 25 +++++++++++++++++++++++++ Toshi/Include/TKernel/TMemory.h | 18 +++++++++++++++--- Toshi/Include/TKernel/TNodeList.h | 20 +++----------------- Toshi/Source/TKernel/TLString.cpp | 5 +++++ Toshi/Source/TKernel/TMemory.cpp | 9 +++++++++ 5 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 Toshi/Include/TKernel/TLString.h create mode 100644 Toshi/Source/TKernel/TLString.cpp diff --git a/Toshi/Include/TKernel/TLString.h b/Toshi/Include/TKernel/TLString.h new file mode 100644 index 0000000..4fc8e97 --- /dev/null +++ b/Toshi/Include/TKernel/TLString.h @@ -0,0 +1,25 @@ +#pragma once + +#include "TDebug.h" +#include "TFreeList.h" + +TOSHI_NAMESPACE_BEGIN + +class TOSHI_EXPORT TLocale +{ +public: + static int const TEMP_START_INDEX = 0x40000000; +}; + +class TOSHI_EXPORT TLocalisedString +{ +public: + static TFreeList& __stdcall GetFreeList() { return m_oFreelist; } + +private: + static TFreeList m_oFreelist; + + TINT m_iIDInt; // 0x4 +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TKernel/TMemory.h b/Toshi/Include/TKernel/TMemory.h index aa31af3..553f132 100644 --- a/Toshi/Include/TKernel/TMemory.h +++ b/Toshi/Include/TKernel/TMemory.h @@ -1,6 +1,7 @@ #pragma once #include "TDebug.h" #include "TThread.h" +#include "TNodeList.h" #define TMEMORY_ROUNDUP 4 @@ -34,14 +35,20 @@ class TOSHI_EXPORT TMemory }; - class MemBlockSlot - { + class MemBlockSlot : TNodeList::TNode + { + public: + TINT m_iSlot; // 0xC }; class MemBlock { - TPVOID m_pMemBlockSlot; // 0x0 TNodeList + public: + MemBlockSlot* m_pMemBlockSlot; // 0x0 + // 0x4 + TPVOID m_pMemory; // 0x8 + TUINT m_uiMemorySize; // 0xC }; public: @@ -49,10 +56,15 @@ class TOSHI_EXPORT TMemory static void __stdcall DebugPrintHALMemInfo(TCHAR const*) {}; static TMemory& __stdcall GetMemMangager(); static MemBlock* __stdcall GetGlobalBlock(); + static MemNode* __stdcall GetMemNodeFromAddress(TPVOID a_pAddr); + static void __stdcall ExtendNodeSize(MemNode* a_pMemNode, TUINT a_iuSize); TPVOID Alloc(TUINT a_uiSize, TUINT a_uiAlignment, MemBlock* a_pMemBlock, TPCHAR a_pBuffer ,TINT a_iUnk3); TBOOL Free(TPVOID a_pMem); +protected: + static TUINT __stdcall GetFreePhysicalMemory() { return 0x8000000; } + private: inline static TBOOL m_bInitialised = TFALSE; diff --git a/Toshi/Include/TKernel/TNodeList.h b/Toshi/Include/TKernel/TNodeList.h index 67f35b6..b024bec 100644 --- a/Toshi/Include/TKernel/TNodeList.h +++ b/Toshi/Include/TKernel/TNodeList.h @@ -323,26 +323,12 @@ class TOSHI_EXPORT TGenericNodeList TINT m_iCount; // 0x10 }; -template -class TDList : public TGenericDList +template +class TNodeList : public TGenericNodeList { public: - TDList() { } - - - - - T* Head() { return static_cast(TGenericDList::Head()); } - T* Tail() { return static_cast(TGenericDList::Tail()); } - Iterator Begin() { return (T*)(TGenericDList::Begin()); } - Iterator End() const { return (T*)(TGenericDList::End()); } - TBOOL IsEmpty() { return TGenericDList::IsEmpty(); } - TBOOL IsLinked() { return m_Root.IsLinked(); } - void RemoveHead() { TGenericDList::RemoveHead(); } - void RemoveTail() { TGenericDList::RemoveTail(); } - void InsertHead(TNode* a_pNode) { TGenericDList::InsertHead(a_pNode); } - void InsertTail(TNode* a_pNode) { TGenericDList::InsertTail(a_pNode); } + TNodeList() { } }; TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Source/TKernel/TLString.cpp b/Toshi/Source/TKernel/TLString.cpp new file mode 100644 index 0000000..8544cac --- /dev/null +++ b/Toshi/Source/TKernel/TLString.cpp @@ -0,0 +1,5 @@ +#include "TLString.h" + +TOSHI_NAMESPACE_USING + +TFreeList TLocalisedString::m_oFreelist = TFreeList(sizeof(TLocalisedString), 0, 2000, (char*)"") \ No newline at end of file diff --git a/Toshi/Source/TKernel/TMemory.cpp b/Toshi/Source/TKernel/TMemory.cpp index 749e8d4..29baebc 100644 --- a/Toshi/Source/TKernel/TMemory.cpp +++ b/Toshi/Source/TKernel/TMemory.cpp @@ -28,6 +28,15 @@ TMemory::MemBlock* __stdcall TMemory::GetGlobalBlock() return g_oMemManager.m_pMemBlock; } +TMemory::MemNode* __stdcall TMemory::GetMemNodeFromAddress(TPVOID a_pAddr) +{ + return TNULL; +} + +void __stdcall TMemory::ExtendNodeSize(MemNode* a_pMemNode, TUINT a_uiSize) +{ +} + TPVOID TMemory::Alloc(TUINT a_uiSize, TUINT a_uiAlignment, MemBlock* a_pMemBlock, TPCHAR a_pBuffer, TINT a_iUnk3) { // Let's just use malloc until i implemented this