Skip to content

Commit f2c3ebd

Browse files
committed
Ladies and Gentlemen we got sound!
Sadly nothing visual :(
1 parent 064028f commit f2c3ebd

19 files changed

+803
-31
lines changed

Toshi/Include/TGui/TGUIColour.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ class TGUIINTERFACE_EXPORTS TGUIColour
1414
m_green = -1;
1515
m_blue = -1;
1616
}
17+
// $TGUIInterface: FUNCTION 100089e0
18+
TUINT GetABGR() const
19+
{
20+
return m_alpha << 0x18 | m_blue << 0x10 | m_green << 0x8 | m_red;
21+
}
22+
// $TGUIInterface: FUNCTION 10008a00
23+
TUINT GetARGB() const
24+
{
25+
return m_alpha << 0x18 | m_red << 0x10 | m_green << 0x8 | m_blue;
26+
}
27+
1728
private:
1829
TCHAR m_alpha; // 0x0
1930
TCHAR m_red; // 0x1

Toshi/Include/TRender/TIndexPoolResourceInterface.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ class TRENDERINTERFACE_EXPORTS TIndexPoolResourceInterface : public TResource
99

1010
public:
1111

12+
struct LockBuffer
13+
{
14+
TUINT m_uiOffset = 0;
15+
TUINT32 m_uiStartIndex = 0;
16+
unsigned short *m_pBuffer = TNULL;
17+
};
18+
1219
TIndexPoolResourceInterface();
1320

1421
protected:
1522
virtual void OnDestroy() override;
16-
virtual TBOOL Lock(void *a_pLockBuffer) = 0;
23+
virtual TBOOL Lock(LockBuffer *a_pLockBuffer) = 0;
1724
virtual void Unlock(TUSHORT a_uiNewNumVertices) = 0;
1825
virtual TBOOL Create(TIndexFactoryResourceInterface *a_pFactory, TUINT a_uiMaxVertices, TUINT a_uiFlags);
1926

@@ -29,7 +36,7 @@ class TRENDERINTERFACE_EXPORTS TIndexPoolResourceInterface : public TResource
2936
// $TRenderInterface: FUNCTION 1000fce0
3037
TBOOL IsLocked() const { return m_uiLockCount != 0; }
3138

32-
private:
39+
protected:
3340
// TResource base 0x0 -> 0x30
3441
TIndexFactoryResourceInterface *m_pFactory; // 0x30
3542
TUSHORT m_usFlags; // 0x34
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#pragma once
2+
#include "TRender/TResource.h"
3+
#include "TKernel/TFreeList.h"
4+
#include "TKernel/TSystemTools.h"
5+
#include "TRender/TIndexFactoryResourceInterface.h"
6+
#include "TRender/TIndexPoolResourceInterface.h"
7+
#include <d3d8.h>
8+
#include "Defines.h"
9+
10+
TOSHI_NAMESPACE_BEGIN
11+
12+
class TIndexPoolResource;
13+
class TIndexFactoryResource;
14+
15+
class TRENDERINTERFACED3D_EXPORTS TIndexBlockResource : public TResource
16+
{
17+
DECLARE_DYNAMIC(TIndexBlockResource)
18+
DECLARE_FREELIST(TIndexBlockResource)
19+
20+
public:
21+
struct TRENDERINTERFACED3D_EXPORTS HALBuffer
22+
{
23+
TUINT m_uiIndexOffset = 0;
24+
IDirect3DIndexBuffer8 *pIndexBuffer = NULL;
25+
};
26+
27+
TIndexBlockResource()
28+
{
29+
m_pFactory = TNULL;
30+
m_uiFlags = 0;
31+
m_uiMaxIndices = 0;
32+
m_uiOffset = 0;
33+
m_uiIndicesUsed = 0;
34+
m_uiLockCount = 0;
35+
m_Unk1 = 0;
36+
}
37+
38+
virtual TBOOL Validate();
39+
40+
TBOOL Create(TIndexFactoryResource *a_pFactory, TUSHORT a_uiMaxVertices, TUINT a_uiFlags);
41+
42+
protected:
43+
TBOOL CreateHAL();
44+
void DestroyHAL();
45+
46+
public:
47+
48+
TBOOL GetHAL(TIndexBlockResource::HALBuffer *a_pHALBuffer);
49+
50+
TBOOL AttachPool(TIndexPoolResource *a_pPool);
51+
TBOOL DetachPool(TIndexPoolResource *a_pPool);
52+
TBOOL CanFit(TIndexPoolResource *a_pPoolResource);
53+
54+
TBOOL Lock(TIndexPoolResourceInterface::LockBuffer *a_pLockBuffer, TUSHORT a_usNumVertices);
55+
void Unlock();
56+
57+
// $TRenderD3DInterface: FUNCTION 1000ae20
58+
void ChildIndexUsedChanged(TINT a_iChange)
59+
{
60+
if (a_iChange < 0) {
61+
TASSERT(m_uiIndicesUsed >= -a_iChange);
62+
}
63+
m_uiIndicesUsed += a_iChange;
64+
}
65+
66+
// $TRenderD3DInterface: FUNCTION 1000b2f0
67+
TIndexFactoryResourceInterface *GetFactory()
68+
{
69+
return m_pFactory;
70+
}
71+
// $TRenderD3DInterface: FUNCTION 1000b2c0
72+
TUINT GetFlags()
73+
{
74+
return m_uiFlags;
75+
}
76+
// $TRenderD3DInterface: FUNCTION 1000b2e0
77+
TUSHORT GetMaxIndices() const
78+
{
79+
return m_uiMaxIndices;
80+
}
81+
// $TRenderD3DInterface: FUNCTION 1000b2d0
82+
TUSHORT GetIndicesUsed() const
83+
{
84+
return m_uiMaxIndices;
85+
}
86+
87+
inline static TINT s_iHALMemoryUsage;
88+
89+
private:
90+
TIndexFactoryResourceInterface *m_pFactory; // 0x30
91+
TUINT m_uiFlags; // 0x34
92+
TUSHORT m_uiMaxIndices; // 0x38
93+
TUINT m_uiOffset; // 0x3C
94+
TUINT m_uiIndicesUsed; // 0x40
95+
TUINT m_uiLockCount; // 0x44
96+
TUINT m_Unk1;
97+
HALBuffer m_HALBuffer;
98+
};
99+
100+
TOSHI_NAMESPACE_END
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
#include "TRenderD3D/TD3DIndexPoolResource.h"
3+
#include "TRenderD3D/TD3DIndexBlockResource.h"
4+
#include "TRender/TIndexFactoryResourceInterface.h"
5+
#include "Defines.h"
6+
7+
TOSHI_NAMESPACE_BEGIN
8+
9+
class TIndexFactoryResource : public TIndexFactoryResourceInterface
10+
{
11+
public:
12+
DECLARE_DYNAMIC(TIndexFactoryResource);
13+
14+
public:
15+
virtual TIndexPoolResourceInterface *CreatePoolResource(TUINT16 a_uiMaxStaticIndices, TUINT16 a_uiFlags);
16+
17+
TIndexBlockResource *FindBlockResource(TIndexPoolResource *a_pResource);
18+
TIndexBlockResource *CreateBlockResource(TUINT16 a_uiMaxIndices, TUINT32 a_uiFlags);
19+
};
20+
21+
TOSHI_NAMESPACE_END
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#pragma once
2+
3+
#include "TRender/TIndexPoolResourceInterface.h"
4+
#include "TRenderD3D/TD3DIndexBlockResource.h"
5+
#include "Defines.h"
6+
7+
TOSHI_NAMESPACE_BEGIN
8+
9+
class TRENDERINTERFACED3D_EXPORTS TIndexPoolResource : public TIndexPoolResourceInterface
10+
{
11+
DECLARE_DYNAMIC(TIndexPoolResource)
12+
13+
friend class TIndexFactoryResource;
14+
15+
public:
16+
TIndexPoolResource()
17+
{
18+
m_uiIndexOffset = 0;
19+
m_uiNumLocksOverall = 0;
20+
m_apManagedBuffer = TNULL;
21+
}
22+
23+
virtual TBOOL Validate() override;
24+
virtual void Invalidate() override;
25+
virtual void OnDestroy() override;
26+
virtual TBOOL Lock(LockBuffer *a_pLockBuffer) override;
27+
virtual void Unlock(TUSHORT a_uiNewNumVertices) override;
28+
virtual TBOOL Create(TIndexFactoryResourceInterface *a_pFactory, TUINT a_uiMaxVertices, TUINT a_uiFlags) override;
29+
30+
public:
31+
32+
TBOOL GetHAL(TIndexBlockResource::HALBuffer *a_pHALBuffer);
33+
34+
// This function is always inlined
35+
TFORCEINLINE TResource *GetParent()
36+
{
37+
if (GetTree()) {
38+
return Parent() == GetTree()->GetRoot() ? TNULL : Parent();
39+
}
40+
return Parent();
41+
}
42+
43+
// $TRenderD3DInterface: FUNCTION 1000c0a0
44+
TIndexBlockResource *GetIndexBlock()
45+
{
46+
if (Parent()->IsExactly(TGetClass(TIndexBlockResource))) {
47+
return static_cast<TIndexBlockResource *>(Parent());
48+
}
49+
return TNULL;
50+
}
51+
52+
// $TRenderD3DInterface: FUNCTION 1000bf70
53+
unsigned short *GetManagedBuffer()
54+
{
55+
TASSERT(TFALSE==IsLocked());
56+
if (!IsLocked()) {
57+
return m_apManagedBuffer;
58+
}
59+
return TNULL;
60+
}
61+
62+
public:
63+
TUINT m_uiIndexOffset; // 0x3C
64+
unsigned short *m_apManagedBuffer; // 0x40
65+
TUINT m_uiNumLocksOverall; // 0x60
66+
};
67+
68+
TOSHI_NAMESPACE_END

Toshi/Include/TRenderD3D/TD3DVertexBlockResource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class TRENDERINTERFACED3D_EXPORTS TVertexBlockResource : public TResource
5454

5555
public:
5656

57+
TBOOL GetHAL(TVertexBlockResource::HALBuffer *a_pHALBuffer);
58+
5759
TBOOL AttachPool(TVertexPoolResource *a_pPool);
5860
TBOOL DetachPool(TVertexPoolResource *a_pPool);
5961
TBOOL CanFit(TVertexPoolResource *a_pPoolResource);

Toshi/Include/TRenderD3D/TD3DVertexPoolResource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class TRENDERINTERFACED3D_EXPORTS TVertexPoolResource : public TVertexPoolResour
5858
return TNULL;
5959
}
6060

61+
TBOOL GetHAL(TVertexBlockResource::HALBuffer *a_pHALBuffer);
62+
6163
public:
6264
TUINT m_uiVertexOffset; // 0x3C
6365
TBYTE *m_apManagedStreams[TVertexFactoryFormat::MAX_NUM_STREAMS]; // 0x40

Toshi/Shaders/TSpriteShader/Include/D3D/TSpriteShaderD3D.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "TRenderD3D/TTextureResourceD3D.h"
66
#include "TRenderD3D/TOrderTable.h"
77
#include "TRenderD3D/TD3DVertexPoolResource.h"
8+
#include "TRenderD3D/TD3DIndexPoolResource.h"
89

910
TOSHI_NAMESPACE_BEGIN
1011

@@ -38,30 +39,37 @@ class TSPRITESHADERD3D_EXPORTS TSpriteShaderHAL : public TSpriteShader
3839
DECLARE_DYNAMIC(TSpriteShaderHAL)
3940

4041
public:
42+
// $TSpriteShaderD3D: FUNCTION 10002610
4143
TSpriteShaderHAL()
4244
: m_oOrderTable(this, 1000, 5000)
4345
{
4446
m_dwVertexShaderHandle = INVALIDSHADERHANDLE;
4547
m_bVertexShaderSuccess = TTRUE;
4648
m_pVertexPool = TNULL;
49+
m_pIndexPool = TNULL;
4750
m_bMipMapLODBias = TTRUE;
4851
}
49-
52+
// $TSpriteShaderD3D: FUNCTION 10003990
5053
TRenderD3DInterface *GetRenderer() const
5154
{
5255
return TSTATICCAST(TRenderD3DInterface *, m_pRenderer);
5356
}
54-
57+
// $TSpriteShaderD3D: FUNCTION 100035c0
5558
DWORD GetVertexShaderHandle()
5659
{
5760
Validate();
5861
return m_dwVertexShaderHandle;
5962
}
60-
63+
// $TSpriteShaderD3D: FUNCTION 10003960
6164
TVertexPoolResourceInterface *GetVertexPool()
6265
{
6366
return m_pVertexPool;
6467
}
68+
// $TSpriteShaderD3D: FUNCTION 10003950
69+
TIndexPoolResourceInterface *GetIndexPool()
70+
{
71+
return m_pIndexPool;
72+
}
6573
// $TSpriteShaderD3D: FUNCTION 10003970
6674
TSpriteShaderOrderTable *GetOrderTable()
6775
{
@@ -92,6 +100,7 @@ class TSPRITESHADERD3D_EXPORTS TSpriteShaderHAL : public TSpriteShader
92100
TBOOL m_bVertexShaderSuccess; // 0x12C
93101
TSpriteShaderOrderTable m_oOrderTable; // 0x130
94102
TVertexPoolResource *m_pVertexPool; // 0x140
103+
TIndexPoolResource *m_pIndexPool; // 0x144
95104
TBOOL m_bMipMapLODBias; // 0x148
96105
};
97106

Toshi/Shaders/TSpriteShader/Include/TSpriteShader.h

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,24 @@ class TSpriteMesh : public TMesh
4242
virtual void Unlock(TUSHORT a_iX, TUSHORT a_iY);
4343
virtual TBOOL Lock();
4444

45+
// $TSpriteShaderD3D: FUNCTION 10001f40
46+
TVertexPoolResourceInterface *GetVertexPool()
47+
{
48+
return m_pVertexPool;
49+
}
50+
4551
// $TSpriteShaderD3D: FUNCTION 10001f20
4652
void SetVertexPool(TVertexPoolResourceInterface *a_pVertexPool)
4753
{
4854
m_pVertexPool = a_pVertexPool;
4955
}
5056

57+
// $TSpriteShaderD3D: FUNCTION 10001f30
58+
TIndexPoolResourceInterface *GetIndexPool()
59+
{
60+
return m_pIndexPool;
61+
}
62+
5163
// $TSpriteShaderD3D: FUNCTION 10001f10
5264
void SetIndexPool(TIndexPoolResourceInterface *a_pIndexPool)
5365
{
@@ -59,6 +71,16 @@ class TSpriteMesh : public TMesh
5971
return m_iNumIndices;
6072
}
6173

74+
TUSHORT GetDeltaNumIndices()
75+
{
76+
return m_iDeltaNumIndices;
77+
}
78+
79+
TUSHORT GetDeltaNumVertices()
80+
{
81+
return m_iDeltaNumVertices;
82+
}
83+
6284
TUSHORT GetNumVertices()
6385
{
6486
return m_iNumVertices;
@@ -105,6 +127,11 @@ class TSpriteMaterial : public TMaterial
105127
m_pTexture = a_pTexture;
106128
}
107129

130+
TINT GetBlendMode()
131+
{
132+
return m_eBlendMode;
133+
}
134+
108135
protected:
109136
TTextureResource *m_pTexture; // 0x40
110137
TINT m_eBlendMode; // 0x44
@@ -138,10 +165,6 @@ class TSpriteShader : public TShader
138165
m_usMaxStaticVertices = 9216;
139166
m_unkFlags = m_unkFlags & 0x80 | 0x4E;
140167
m_pMaterial = TNULL;
141-
m_colorR = -1;
142-
m_colorG = -1;
143-
m_colorB = -1;
144-
m_colorA = -1;
145168
}
146169

147170
virtual TBOOL Create();
@@ -177,10 +200,7 @@ class TSpriteShader : public TShader
177200
protected:
178201
TINT m_unkFlags; // 0x30
179202
TSpriteMaterial *m_pMaterial; // 0x4C
180-
TCHAR m_colorR; // 0x50
181-
TCHAR m_colorG; // 0x51
182-
TCHAR m_colorB; // 0x52
183-
TCHAR m_colorA; // 0x53
203+
TGUIColour m_oColour; // 0x50
184204
TVector2 m_vPos1; // 0x54
185205
TVector2 m_vPos2; // 0x5C
186206
TVector2 m_vUV1; // 0x64
@@ -191,6 +211,7 @@ class TSpriteShader : public TShader
191211
TVertexPoolResourceInterface::LockBuffer m_VertexLockBuffer; // 0xE0
192212
Vertex m_aVertices[4]; // 0xE8
193213
TMatrix44 m_oModelViewMatrix; // 0x8C
214+
TIndexPoolResourceInterface::LockBuffer m_IndexLockBuffer; // 0x108
194215
TUSHORT m_iNumIndices; // 0x110
195216
TUSHORT m_iNumVertices; // 0x114
196217
TSpriteMaterial *m_pLineMaterial; // 0x118

0 commit comments

Comments
 (0)