Skip to content

Commit

Permalink
Did some major render stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Jan 2, 2024
1 parent 3f07b05 commit c84b62a
Show file tree
Hide file tree
Showing 38 changed files with 1,431 additions and 68 deletions.
67 changes: 60 additions & 7 deletions OpenJPOG/Source/ABINKMoviePlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "ABINKMoviePlayer.h"
#include "main.h"
#include "TKernel/TManagedPointer.h"
#include "TRender/TTextureFactory.h"
#include "TRenderD3D/TRenderD3DInterface.h"

TOSHI_NAMESPACE_USING

Expand All @@ -18,14 +22,12 @@ ABINKMoviePlayer::ABINKMoviePlayer()

TBOOL ABINKMoviePlayer::InitializeMoviePlayer()
{
HRESULT hResult = DirectSoundCreate(NULL, &m_pDirectSound, NULL);
if (FAILED(hResult)) {
m_pDirectSound = NULL;
if (!m_bIsBINKInitialized) {
InitializeAudioResource();
InitializeVideoResource();
m_bIsBINKInitialized = TTRUE;
}
else {
BinkSoundUseDirectSound(m_pDirectSound);
}
return TTRUE;
return TFALSE;
}

TBOOL ABINKMoviePlayer::ShutdownMoviePlayer()
Expand All @@ -39,6 +41,13 @@ TBOOL ABINKMoviePlayer::ShutdownMoviePlayer()
return TFALSE;
}

TBOOL ABINKMoviePlayer::StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUnk3)
{
TManagedPtr<TRenderInterface> renderer = g_oTheApp.GetRootTask()->GetRenderInterface();

return TBOOL();
}

TBOOL ABINKMoviePlayer::Update(TFLOAT a_fDeltaTime)
{
if (!m_bHasMovieStopped && m_hBink) {
Expand Down Expand Up @@ -111,6 +120,50 @@ TBOOL ABINKMoviePlayer::RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iDestWidth, T
return TFALSE;
}

TBOOL ABINKMoviePlayer::InitializeVideoResource()
{
TManagedPtr<TRenderInterface> renderer = g_oTheApp.GetRootTask()->GetRenderInterface();
TTextureFactory* factory = (TTextureFactory*)renderer->GetSystemResource(TRenderInterface::SYSRESOURCE_TEXTUREFACTORY);
TINT size;
TTEXTURERESOURCEFORMAT textureFormat;
TINT textureFormatSize;
if (renderer->Supports32BitTextures()) {
size = 4;
textureFormat = TTEXTURERESOURCEFORMAT::R8G8B8A8;
textureFormatSize = 32;
}
else {
size = 2;
textureFormat = TTEXTURERESOURCEFORMAT::R5G5B5A1;
textureFormatSize = 8;
}
size *= 0x10000;
TPVOID buffer = tmalloc(size, TNULL, -1);
TSystem::MemSet(buffer, 0xFF, size);
factory->CreateEx(buffer, size, 256, 256, 1, textureFormat, textureFormatSize);
return TTRUE;
}

TBOOL ABINKMoviePlayer::InitializeAudioResource()
{
TManagedPtr<TRenderD3DInterface> renderer = (TRenderD3DInterface*)g_oTheApp.GetRootTask()->GetRenderInterface().m_pObject;
HRESULT hResult = DirectSoundCreate(NULL, &m_pDirectSound, NULL);

if (FAILED(hResult)) {
m_pDirectSound = NULL;
}
else {
m_pDirectSound->SetCooperativeLevel(renderer->GetMSWindow()->GetHWND(), 2);
BinkSoundUseDirectSound(m_pDirectSound);
}
return TTRUE;
}

TBOOL ABINKMoviePlayer::FreeVideoResource()
{
return TTRUE;
}

void ABINKMoviePlayer::BinkSleep(TINT a_iMicroseconds)
{
static S32 s_iTotalSleep = 0;
Expand Down
10 changes: 6 additions & 4 deletions OpenJPOG/Source/ABINKMoviePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ class ABINKMoviePlayer : public AMoviePlayer

virtual TBOOL ShutdownMoviePlayer();

virtual TBOOL StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUnk3);

virtual TBOOL Update(TFLOAT a_fDeltaTime);

virtual TBOOL RenderToTexture(TTextureResource *a_pTexture);

virtual TBOOL RenderToFrameBuffer();
virtual TBOOL RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iSourceHeigth, TINT a_iDestHeigth, TINT a_iDestPitch, TINT a_iDestX, INT a_iDestY, INT a_iSrcX, INT a_iSrcY);

virtual TBOOL FreeVideoResource()
{
return TTRUE;
}
virtual TBOOL InitializeVideoResource();
virtual TBOOL InitializeAudioResource();

virtual TBOOL FreeVideoResource();

virtual TBOOL FreeAudioResource()
{
Expand Down
1 change: 1 addition & 0 deletions OpenJPOG/Source/AGUIGameHUD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "AGUIGameHUD.h"
5 changes: 5 additions & 0 deletions OpenJPOG/Source/AGUIGameHUD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
class AGUIGameHUD
{
};

6 changes: 6 additions & 0 deletions OpenJPOG/Source/ARenderer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "ARenderer.h"

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(ARenderer, TTask)

11 changes: 11 additions & 0 deletions OpenJPOG/Source/ARenderer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include "TKernel/TTask.h"

TOSHI_NAMESPACE_BEGIN

class ARenderer : public TTask
{
DECLARE_DYNAMIC(ARenderer)
};

TOSHI_NAMESPACE_END
5 changes: 5 additions & 0 deletions OpenJPOG/Source/ARootState.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "ARootState.h"

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(ARootState, TObject)
19 changes: 19 additions & 0 deletions OpenJPOG/Source/ARootState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include "TKernel/TObject.h"
#include "AGUIGameHUD.h"

class ARootState : public Toshi::TObject
{
DECLARE_DYNAMIC(ARootState)


public:

AGUIGameHUD& GetHUDState() { return m_oHUDState; }

private:
ARootState* m_pParent; // 0x4
ARootState* m_pNext; // 0x8
AGUIGameHUD m_oHUDState; // 0x10
};

9 changes: 7 additions & 2 deletions OpenJPOG/Source/ARootTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "TKernel/TCString.h"
#include "AVibrationManager.h"
#include "ABINKMoviePlayer.h"
#include "TRender/TRenderInterface.h"
#include "TKernel/TManagedPointer.h"

class ARootTask : public Toshi::TTask
{
Expand All @@ -20,12 +22,15 @@ class ARootTask : public Toshi::TTask
m_szName = a_szName;
}

Toshi::TManagedPtr<Toshi::TRenderInterface> GetRenderInterface() { return m_pRenderInterface; }

private:
void AllocateInputSystem();

private:
Toshi::TCString m_szName;
TTask* m_pInputTask; // 0x38
AVibrationManager* m_pVibrationTask; // 0xE8
Toshi::TTask* m_pInputTask; // 0x38
Toshi::TRenderInterface* m_pRenderInterface;// 0xD0
AVibrationManager* m_pVibrationTask; // 0xE8
Toshi::ABINKMoviePlayer* m_pMoviePlayer; // 0xF0
};
18 changes: 17 additions & 1 deletion OpenJPOG/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ project ("OpenJPOG")
"TKernelInterface",
"TApplication",
"TRenderInterface",
"TRenderD3DInterface",
"d3d8.lib",
"d3dx8.lib",
"dxguid.lib",
"dxgi.lib",
"DxErr8.lib",
"dsound.lib",
"legacy_stdio_definitions.lib",
"winmm.lib",
"dinput8.lib",
"fmodvc.lib",
"binkw32.lib"
}
Expand All @@ -27,6 +36,11 @@ project ("OpenJPOG")
"%{IncludeDir.bink}"
}

externalincludedirs
{
"%{IncludeDir.dx8}"
}

defines
{
"TOSHI_USER_CLIENT"
Expand All @@ -35,14 +49,16 @@ project ("OpenJPOG")
libdirs
{
"%{LibDir.fmod}",
"%{LibDir.bink}"
"%{LibDir.bink}",
"%{LibDir.dx8}"
}

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}\"",
"{COPY} \"%{wks.location}bin/" .. outputdir .. "/TRenderInterface/TRenderInterface.dll\" \"%{wks.location}bin/" .. outputdir .. "/%{prj.name}\"",
"{COPY} \"%{wks.location}bin/" .. outputdir .. "/TRenderD3DInterface/TRenderD3DInterface.dll\" \"%{wks.location}bin/" .. outputdir .. "/%{prj.name}\"",
"{COPY} \"%{wks.location}Toshi/vendor/fmod/lib/fmod.dll\" \"%{wks.location}bin/" .. outputdir .. "/%{prj.name}\"",
"{COPY} \"%{wks.location}Toshi/vendor/bink/lib/binkw32.dll\" \"%{wks.location}bin/" .. outputdir .. "/%{prj.name}\"",
}
Expand Down
4 changes: 2 additions & 2 deletions Tools/UnitTests/Source/TKernel/TManagedPointer_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ struct Test
int m_iTest;
};

TEST_CASE("Test Managed Pointer", "[TManagedPointer]")
TEST_CASE("Test Managed Pointer", "[TManagedPtr]")
{
Test* test = new Test;
{
TManagedPointer<Test> testptr(test);
TManagedPtr<Test> testptr(test);
}

// Ensure that the pointer is not 0xCC (freed memory)
Expand Down
3 changes: 2 additions & 1 deletion Toshi/Include/TApplication/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ typedef unsigned __int64 TUINT64;
typedef short TSHORT;
typedef unsigned short TUSHORT;
typedef wchar_t TWCHAR;
typedef unsigned short* TPWCHAR;
typedef wchar_t* TPWCHAR;
typedef const wchar_t* TPCWCHAR;
typedef const char* TPCCHAR;
typedef char* TPCHAR;
typedef char TCHAR;
Expand Down
13 changes: 7 additions & 6 deletions Toshi/Include/TKernel/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ typedef unsigned __int64 TUINT64;
typedef short TSHORT;
typedef unsigned short TUSHORT;
typedef wchar_t TWCHAR;
typedef unsigned short* TPWCHAR;
typedef const char* TPCCHAR;
typedef char* TPCHAR;
typedef wchar_t* TPWCHAR;
typedef const wchar_t* TPCWCHAR;
typedef const char* TPCCHAR;
typedef char* TPCHAR;
typedef char TCHAR;
typedef const char TCCHAR;
typedef char TINT8;
typedef unsigned char TUINT8;
typedef unsigned char TBYTE;
typedef unsigned char* TPBYTE;
typedef void* TPVOID;
typedef const void* TPCVOID;
typedef unsigned char* TPBYTE;
typedef void* TPVOID;
typedef const void* TPCVOID;
typedef float TFLOAT;
typedef const float TCFLOAT;
1 change: 1 addition & 0 deletions Toshi/Include/TKernel/TCString.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TKERNELINTERFACE_EXPORTS TCString
}

TCString& Concat(TCString const& a_rString, TINT a_iLength = -1);
TCString& Concat(TPCCHAR a_String, TINT a_iLength = -1);
TINT Compare(TPCCHAR a_pcString, int a_iLength = -1) const;

void Copy(const TCString& a_rOther, TINT a_iLength = -1);
Expand Down
2 changes: 1 addition & 1 deletion Toshi/Include/TKernel/TKernelInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TKERNELINTERFACE_EXPORTS TKernelInterface : public TObject
TScheduler* GetScheduler() const { return m_pScheduler.m_pObject; }
private:
THPTimer m_oSysTimer; // 0x8
TManagedPointer<TScheduler> m_pScheduler; // 0x30
TManagedPtr<TScheduler> m_pScheduler; // 0x30
TFLOAT m_fDeltaTime; // 0x44
TFLOAT m_fAvgFPS; // 0x48
TBOOL m_bVerbose; // 0x4C
Expand Down
8 changes: 4 additions & 4 deletions Toshi/Include/TKernel/TManagedPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
TOSHI_NAMESPACE_BEGIN

template<class T>
class TManagedPointer
class TManagedPtr
{
public:
TManagedPointer() : m_pObject(TNULL)
TManagedPtr() : m_pObject(TNULL)
{

}

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

}

~TManagedPointer()
~TManagedPtr()
{
delete m_pObject;
}
Expand Down
5 changes: 5 additions & 0 deletions Toshi/Include/TKernel/TSystemTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ class TKERNELINTERFACE_EXPORTS TSystem
{
public:

static TPCCHAR TOSHI_API StringUnicodeToChar(TPCHAR a_CharString, TPCWCHAR a_UnicodeString, TINT a_iLength);
static TPCCHAR TOSHI_API StringIntToString(TINT a_iInt, TPCHAR a_szString, TINT a_iRadix);
static TINT TOSHI_API StringLength(TPCCHAR a_String);
static TINT TOSHI_API StringLength(TPCWCHAR a_String);
static TINT TOSHI_API StringCompareNoCase(TPCCHAR a_String1, TPCCHAR a_String2, TINT a_uiSize);
static TCHAR const* TOSHI_API StringCopy(TPCHAR a_DestinationString, TCHAR const* a_SourceString, TINT a_iCount);
static TPCWCHAR TOSHI_API StringCopy(TPWCHAR a_DestinationString, TPCWCHAR a_SourceString, TINT a_iCount);
static TPVOID TOSHI_API MemCopy(TPVOID a_dest, TPCVOID a_src, TUINT a_iSize);
static TPVOID TOSHI_API MemSet(TPVOID a_dest, TINT a_iValue, TINT m_iSize);

static TPBYTE GetScratchMem() { return ms_aScratchMem; }
static TPCWCHAR GetTempWString() { return (TPCWCHAR)ms_aScratchMem; }
static TPCHAR GetTempCString() { return (TPCHAR)ms_aScratchMem; }
private:
inline static TBYTE ms_aScratchMem[1024] = {};
};
Expand Down
Loading

0 comments on commit c84b62a

Please sign in to comment.