-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
198 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
#include "TApplication/TApplication.h" | ||
#include "TMemory.h" | ||
|
||
class AApplication : public Toshi::TApplication | ||
{ | ||
virtual TBOOL OnCreate(TINT argc, TPCHAR* const argv) override | ||
{ | ||
return TTRUE; | ||
} | ||
}; | ||
|
||
static AApplication g_oTheApp; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
return 1; | ||
if (g_oTheApp.Create("Jurassic Park: Operation Genesis - (c) Blue Tongue Software", argc, argv)) { | ||
Toshi::TMemory::DebugPrintHALMemInfo(TNULL); | ||
g_oTheApp.Execute(); | ||
} | ||
g_oTheApp.Destroy(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "TKernel/TUser.h" | ||
#include <catch2/catch_test_macros.hpp> | ||
|
||
TOSHI_NAMESPACE_USING | ||
|
||
TEST_CASE("Register User", "[TUser]") | ||
{ | ||
TUser user("AdventureT"); | ||
TSHORT iUserID = user.Register(); | ||
REQUIRE(iUserID != -1); | ||
REQUIRE(user.IsRegistered()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "TMemory.h" | ||
|
||
TOSHI_NAMESPACE_BEGIN | ||
|
||
class TOSHI_EXPORT TFreeList | ||
{ | ||
public: | ||
|
||
struct Node | ||
{ | ||
Node* pNext = TNULL; | ||
}; | ||
|
||
TFreeList(); | ||
|
||
TINT GetCapacity() const { return m_iCapacity; } | ||
TINT GetGrowSize() const { return m_iGrowSize; } | ||
TINT GetFreeCount() { return m_iFreeCount; } | ||
private: | ||
TFreeList* m_pPrevList; | ||
TINT m_iFreeCount; // 0x0 | ||
TUINT m_uiItemSize; | ||
Node m_LastNode; | ||
TINT m_iCapacity; // 0xC | ||
Node m_RootNode; | ||
TINT m_iGrowSize; // 0x1C | ||
}; | ||
|
||
TOSHI_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "TDebug.h" | ||
|
||
#define MAX_USERS 50 | ||
|
||
TOSHI_NAMESPACE_BEGIN | ||
|
||
class TOSHI_EXPORT TUser | ||
{ | ||
friend class TUserHandler; | ||
public: | ||
TUser(TCHAR const* a_sName); | ||
|
||
TBOOL IsRegistered() { return m_iUserID != -1; } | ||
TSHORT Register(); | ||
void Deregister(); | ||
|
||
TSHORT GetUserID() { return m_iUserID; } | ||
TSHORT GetNameLength() { return m_iNameLen; } | ||
TCHAR const* GetName() { return m_sName; } | ||
|
||
private: | ||
TCHAR const* m_sName; // 0x0 | ||
TSHORT m_iNameLen; // 0x4 | ||
TSHORT m_iUserID; // 0x6 | ||
}; | ||
|
||
class TOSHI_EXPORT TUserHandler | ||
{ | ||
protected: | ||
TUserHandler(); | ||
~TUserHandler() = default; | ||
public: | ||
TSHORT RegisterUser(TUser &a_rUser); | ||
void DeregisterUser(TUser &a_rUser); | ||
TUser* FindUser(TCHAR const* a_sName); | ||
|
||
TINT GetUserCount() { return m_iUserCount; } | ||
TUser* GetUser(TINT a_iUserID) { return m_pUsers[a_iUserID]; } | ||
static TUserHandler& __stdcall GetSingleton(); | ||
|
||
private: | ||
static TUserHandler ms_oSingleton; | ||
|
||
TINT m_iUserCount; // 0x0 | ||
TUser* m_pUsers[MAX_USERS]; // 0x4 | ||
}; | ||
|
||
TOSHI_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "TFreeList.h" | ||
|
||
TOSHI_NAMESPACE_USING | ||
|
||
TFreeList::TFreeList() | ||
{ | ||
TASSERT(m_iGrowSize >= 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "TUser.h" | ||
#include "TSystemTools.h" | ||
|
||
TOSHI_NAMESPACE_USING | ||
|
||
TUserHandler TUserHandler::ms_oSingleton = TUserHandler(); | ||
|
||
TUser::TUser(TCHAR const* a_sName) | ||
{ | ||
m_sName = a_sName; | ||
m_iUserID = -1; | ||
TVALIDADDRESS(m_sName); | ||
m_iNameLen = TSystem::StringLength(m_sName); | ||
} | ||
|
||
TUserHandler::TUserHandler() | ||
{ | ||
m_iUserCount = 0; | ||
TSystem::MemSet(m_pUsers, 0, sizeof(m_pUsers)); | ||
} | ||
|
||
TSHORT TUserHandler::RegisterUser(TUser& a_rUser) | ||
{ | ||
TASSERT(TFALSE==a_rUser.IsRegistered()); | ||
TINT curUserCount = GetUserCount(); | ||
if (curUserCount < MAX_USERS) { | ||
m_iUserCount++; | ||
a_rUser.m_iUserID = curUserCount; | ||
m_pUsers[curUserCount] = &a_rUser; | ||
return a_rUser.GetUserID(); | ||
} | ||
a_rUser.m_iUserID = -1; | ||
return -1; | ||
} | ||
|
||
void TUserHandler::DeregisterUser(TUser& a_rUser) | ||
{ | ||
if (a_rUser.GetUserID() != -1) { | ||
m_pUsers[a_rUser.GetUserID()] = TNULL; | ||
} | ||
a_rUser.m_iUserID = -1; | ||
} | ||
|
||
TUser* TUserHandler::FindUser(TCHAR const* a_sName) | ||
{ | ||
TINT iNameLength = TSystem::StringLength(a_sName); | ||
for (TINT i = 0; i < MAX_USERS; i++) { | ||
if (m_pUsers[i] && | ||
m_pUsers[i]->GetNameLength() == iNameLength && | ||
TSystem::StringCompareNoCase(m_pUsers[i]->GetName(), a_sName, -1) == 0) { | ||
return m_pUsers[i]; | ||
} | ||
} | ||
return TNULL; | ||
} | ||
|
||
TUserHandler& TUserHandler::GetSingleton() | ||
{ | ||
return ms_oSingleton; | ||
} | ||
|
||
TSHORT TUser::Register() | ||
{ | ||
return TUserHandler::GetSingleton().RegisterUser(*this); | ||
} | ||
|
||
void TUser::Deregister() | ||
{ | ||
TUserHandler::GetSingleton().DeregisterUser(*this); | ||
} |