Skip to content

Commit

Permalink
Fix final build and fixed TKernelInterface::OnUpdate() bug (replaing …
Browse files Browse the repository at this point in the history
…dll on setup.exe might work now?)
  • Loading branch information
AdventureT committed Dec 7, 2023
1 parent ddc612a commit bea7e53
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 10 deletions.
4 changes: 2 additions & 2 deletions OpenJPOG/Source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "TApplication/TApplication.h"
#include "TMemory.h"
#include "TKernel/TMemory.h"

class AApplication : public Toshi::TApplication
{
virtual TBOOL OnCreate(TINT argc, TPCHAR* const argv) override
{
return TTRUE;
return TApplication::OnCreate(argc, argv);
}
};

Expand Down
3 changes: 2 additions & 1 deletion OpenJPOG/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project ("OpenJPOG")
links
{
"TKernelInterface",
"TApplication",
"libtheora",
"theoraplay"
}
Expand All @@ -19,7 +20,6 @@ project ("OpenJPOG")
includedirs
{
"%{wks.location}/Toshi/Include",
"%{wks.location}/Toshi/Include/TKernel",
}

defines
Expand All @@ -30,6 +30,7 @@ project ("OpenJPOG")
postbuildcommands
{
"{COPY} \"%{wks.location}bin/" .. outputdir .. "/TKernelInterface/TKernelInterface.dll\" \"%{wks.location}bin/" .. outputdir .. "/%{prj.name}\"",
"{COPY} \"%{wks.location}bin/" .. outputdir .. "/TApplication/TApplication.dll\" \"%{wks.location}bin/" .. outputdir .. "/%{prj.name}\"",
}

filter "system:windows"
Expand Down
2 changes: 1 addition & 1 deletion Toshi/Include/TApplication/TApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TOSHI_EXPORT TApplication

virtual TBOOL OnUpdate(TFLOAT a_fDelta)
{
return HASFLAG(m_uiState & TApplicationFlag_Destroyed);
return (m_uiState & TApplicationFlag_Destroyed) == 0;
}

TKernelInterface* GetKernel() { return m_pKernel; }
Expand Down
7 changes: 6 additions & 1 deletion Toshi/Include/TKernel/TKernelInterface.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
#include "TObject.h"
#include "TKernel/THPTimer.h"
#include "THPTimer.h"
#include "TManagedPointer.h"
#include "TScheduler.h"

TOSHI_NAMESPACE_BEGIN

Expand All @@ -17,6 +19,9 @@ class TOSHI_EXPORT TKernelInterface : public TObject
THPTimer* GetSystemTimer() { return &m_oSysTimer; }
private:
THPTimer m_oSysTimer; // 0x8
TManagedPointer<TScheduler> m_pScheduler; // 0x30
TFLOAT m_fDeltaTime; // 0x44
TFLOAT m_fAvgFPS; // 0x48
};

TOSHI_NAMESPACE_END
11 changes: 8 additions & 3 deletions Toshi/Include/TKernel/TManagedPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ template<class T>
class TOSHI_EXPORT TManagedPointer
{
public:
TManagedPointer() : m_pObject(new T())
{

}

TManagedPointer(T* a_pObject) : m_pObject(a_pObject)
{

Expand All @@ -17,11 +22,11 @@ class TOSHI_EXPORT TManagedPointer
delete m_pObject;
}

T& operator*() { return *m_pObject; }
T& operator*() { TASSERT(m_pObject != TNULL); return *m_pObject; }

operator T*() { return m_pObject; }
operator T* () { TASSERT(m_pObject!=TNULL); return m_pObject; }

T* operator->() { return m_pObject; }
T* operator->() { TASSERT(m_pObject != TNULL); return m_pObject; }

private:
T* m_pObject;
Expand Down
13 changes: 13 additions & 0 deletions Toshi/Include/TKernel/TScheduler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "TDebug.h"

TOSHI_NAMESPACE_BEGIN

class TOSHI_EXPORT TScheduler
{
public:
void Update();
};

TOSHI_NAMESPACE_END
14 changes: 12 additions & 2 deletions Toshi/Source/TKernel/TKernelInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ IMPLEMENT_DYNAMIC(TKernelInterface, TObject);

TKernelInterface::TKernelInterface(TINT argc, TPCHAR* const argv, TBOOL a_bVerbose)
{
TWARNING("TKernelInterface::TKernelInterface() not implemented");
TWARNING("TKernelInterface::TKernelInterface() not implemented\n");
TCHAR pPath[260];
TPCHAR pBuffer = _getcwd(pPath, sizeof(pPath));
TVALIDADDRESS(pBuffer);
Expand All @@ -27,7 +27,17 @@ TKernelInterface::TKernelInterface(TINT argc, TPCHAR* const argv, TBOOL a_bVerbo

TBOOL TKernelInterface::Update()
{
TWARNING("TKernelInterface::Update() not implemented");
THPTimer *pSysTimer = GetSystemTimer();
pSysTimer->Update();
TFLOAT deltaTime = pSysTimer->GetDelta();
m_fDeltaTime += deltaTime;

if (m_fDeltaTime > 1.0f) {
m_fAvgFPS += (1.0f / deltaTime) * 0.5f;
m_fDeltaTime = 0.0f;
}

m_pScheduler->Update();
return TTRUE;
}

Expand Down
7 changes: 7 additions & 0 deletions Toshi/Source/TKernel/TScheduler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "TScheduler.h"

TOSHI_NAMESPACE_USING

void TScheduler::Update()
{
}

0 comments on commit bea7e53

Please sign in to comment.