Skip to content

Commit 619a283

Browse files
madebrfoxtacles
andauthored
Implement DrawTriangle and DrawRectangle (isledecomp#202)
* Implement DrawTriangle and DrawRectangle * Improve a bit --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
1 parent c016217 commit 619a283

13 files changed

Lines changed: 436 additions & 137 deletions

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ set(COMMON_SOURCES
9999
set(GOLDP_INLINE_EXPANSION_SOURCES
100100
GolDP/src/amberlensbase0x120.cpp
101101
GolDP/src/boundingshape0x2c.cpp
102+
GolDP/src/duskwindbananarelic0x30.cpp
102103
GolDP/src/golfontbase0x40.cpp
103104
GolDP/src/goldrawstate.cpp
104105
GolDP/src/silverdune0x30.cpp

GolDP/include/bronzefalcon0xc8770.h

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,21 @@ class BronzeFalcon0xc8770 : public WhiteFalcon0x140 {
7171
SilverDune0x30::Rect* p_destRect,
7272
SilverDune0x30::Rect* p_sourceRect,
7373
undefined4 p_unk0x14
74-
) override; // vtable+0x7c
75-
void VTable0x80() override; // vtable+0x80
74+
) override; // vtable+0x7c
75+
void DrawRectangle(
76+
const IntRectangle0x10& p_rect,
77+
LegoFloat p_z,
78+
const ColorRGBA& p_color1,
79+
const ColorRGBA& p_color2,
80+
const ColorRGBA& p_color3,
81+
const ColorRGBA& p_color4,
82+
undefined4 p_arg7
83+
) override; // vtable+0x80
7684
void DrawTriangle(
7785
const TexturedVertex* p_vertex0,
7886
const TexturedVertex* p_vertex1,
7987
const TexturedVertex* p_vertex2,
80-
undefined4 p_material,
88+
DuskwindBananaRelic0x24* p_material,
8189
undefined4 p_flags
8290
) override; // vtable+0x84
8391
void VTable0x88(undefined4, undefined4, undefined4) override; // vtable+0x88
@@ -106,12 +114,12 @@ class BronzeFalcon0xc8770 : public WhiteFalcon0x140 {
106114
void VTable0xec(undefined4) override; // vtable+0xec
107115
void VTable0xf0() override; // vtable+0xf0
108116
void VTable0xf4() override; // vtable+0xf4
109-
void VTable0xf8() override; // vtable+0xf8
110-
void VTable0xfc() override; // vtable+0xfc
111-
void VTable0x100() override; // vtable+0x100
112-
void VTable0x104() override; // vtable+0x104
113-
void VTable0x108() override; // vtable+0x108
114-
void VTable0x10c() override; // vtable+0x10c
117+
LegoU32 GetMinimumTextureWidth(undefined4) const override; // vtable+0xf8
118+
LegoU32 GetMaximumTextureWidth(undefined4) const override; // vtable+0xfc
119+
LegoU32 GetMinimumTextureHeight(undefined4) const override; // vtable+0x100
120+
LegoU32 GetMaximumTextureHeight(undefined4) const override; // vtable+0x104
121+
LegoBool32 TexturesMustBeSquare() const override; // vtable+0x108
122+
LegoBool32 TextureSizesMustBePowersOfTwo() const override; // vtable+0x10c
115123
LegoBool32 VTable0x110() const override; // vtable+0x110
116124

117125
undefined4 FUN_10007d90(GolDrawDPState*, SlatePeak0x58*, LegoU32 p_flags);
@@ -128,43 +136,47 @@ class BronzeFalcon0xc8770 : public WhiteFalcon0x140 {
128136

129137
private:
130138
void FUN_100082e0();
131-
void FUN_1000a2c0(undefined*);
132-
void FUN_1000a950(undefined*);
139+
void FUN_1000a2c0(DuskwindBananaRelic0x24*);
140+
void FUN_1000a950(DuskwindBananaRelic0x24*);
141+
void FUN_1000ac00(undefined4*);
133142
void FUN_1000b4a0();
134143
void Reset();
135144
static HRESULT CALLBACK CountTextureFormatsCallback(DDPIXELFORMAT* p_format, void* p_context);
136145
static HRESULT CALLBACK EnumerateTextureFormatsCallback(DDPIXELFORMAT* p_format, void* p_context);
137146

138-
GolDrawDPState* m_drawState; // 0x140
139-
LPDIRECT3DDEVICE3 m_d3dDevice; // 0x144
140-
D3DDEVICEDESC m_d3dDeviceDesc; // 0x148
141-
LPDIRECT3DVIEWPORT3 m_d3dViewport; // 0x244
142-
D3DVIEWPORT2 m_viewportParams; // 0x248
143-
D3DMATERIAL m_materialParams; // 0x274
144-
LPDIRECT3DMATERIAL3 m_backgroundMaterial; // 0x2c4
145-
D3DMATERIALHANDLE m_backgroundMaterialHandle; // 0x2c8
146-
ColorRGBA m_unk0x2cc; // 0x2cc
147-
LegoU32 m_unk0x2d0; // 0x2d0
148-
DuskwindBananaRelic0x30 m_unk0x2d4; // 0x2d4
149-
SlatePeak0x58* m_unk0x304; // 0x304
150-
SlatePeak0x58* m_renderTargetInfo; // 0x308
151-
BronzeFalconSurface0x5c* m_unk0x30c; // 0x30c
152-
DepthBuffer0x38 m_depthBuffer; // 0x310
153-
undefined m_unk0x348[0xc384c - 0x348]; // 0x348
154-
undefined4 m_unk0xc384c; // 0xc384c
155-
undefined m_unk0xc3850[0xc83b4 - 0xc3850]; // 0xc3850
156-
Field0xc83b4 m_unk0xc83b4; // 0xc83b4
157-
undefined4 m_unk0xc83c4; // 0xc83c4
158-
undefined m_unk0xc83c8[0xc8698 - 0xc83c8]; // 0xc83c8
159-
SoftwareRenderer0x58 m_softwareRenderer; // 0xc8698
160-
undefined m_unk0xc86f0[0xc86fc - 0xc86f0]; // 0xc86f0
161-
float m_unk0xc86fc; // 0xc86fc
162-
undefined4 m_unk0xc8700; // 0xc8700
163-
undefined m_unk0xc8704[0xc8708 - 0xc8704]; // 0xc8704
164-
undefined4 m_unk0xc8708[11]; // 0xc8708
165-
undefined4 m_unk0xc8734[11]; // 0xc8734
166-
undefined m_unk0xc8760[0xc876c - 0xc8760]; // 0xc8760
167-
void (BronzeFalcon0xc8770::*m_unk0xc876c)(undefined*); // 0xc876c
147+
GolDrawDPState* m_drawState; // 0x140
148+
LPDIRECT3DDEVICE3 m_d3dDevice; // 0x144
149+
D3DDEVICEDESC m_d3dDeviceDesc; // 0x148
150+
LPDIRECT3DVIEWPORT3 m_d3dViewport; // 0x244
151+
D3DVIEWPORT2 m_viewportParams; // 0x248
152+
D3DMATERIAL m_materialParams; // 0x274
153+
LPDIRECT3DMATERIAL3 m_backgroundMaterial; // 0x2c4
154+
D3DMATERIALHANDLE m_backgroundMaterialHandle; // 0x2c8
155+
ColorRGBA m_unk0x2cc; // 0x2cc
156+
LegoU32 m_unk0x2d0; // 0x2d0
157+
DuskwindBananaRelic0x30 m_unk0x2d4; // 0x2d4
158+
SlatePeak0x58* m_unk0x304; // 0x304
159+
SlatePeak0x58* m_renderTargetInfo; // 0x308
160+
BronzeFalconSurface0x5c* m_unk0x30c; // 0x30c
161+
DepthBuffer0x38 m_depthBuffer; // 0x310
162+
D3DTLVERTEX m_unk0x348[25000]; // 0x348
163+
undefined4 m_unk0xc3848; // 0xc3848
164+
undefined4 m_unk0xc384c; // 0xc384c
165+
undefined m_unk0xc3850[0xc83b4 - 0xc3850]; // 0xc3850
166+
Field0xc83b4 m_unk0xc83b4; // 0xc83b4
167+
undefined4 m_unk0xc83c4; // 0xc83c4
168+
undefined m_unk0xc83c8[0xc8698 - 0xc83c8]; // 0xc83c8
169+
SoftwareRenderer0x58 m_softwareRenderer; // 0xc8698
170+
SoftwareRenderer0x58::Command0x14* m_unk0xc86f0; // 0xc86f0
171+
LegoS32 m_unk0xc86f4; // 0xc86f4
172+
LegoS32 m_unk0xc86f8; // 0xc86f8
173+
float m_unk0xc86fc; // 0xc86fc
174+
undefined4 m_unk0xc8700; // 0xc8700
175+
undefined m_unk0xc8704[0xc8708 - 0xc8704]; // 0xc8704
176+
undefined4 m_unk0xc8708[11]; // 0xc8708
177+
undefined4 m_unk0xc8734[11]; // 0xc8734
178+
undefined m_unk0xc8760[0xc876c - 0xc8760]; // 0xc8760
179+
void (BronzeFalcon0xc8770::*m_unk0xc876c)(DuskwindBananaRelic0x24*); // 0xc876c
168180
};
169181

170182
#endif // BRONZEFALCON0XC8770_H

GolDP/include/duskwindbananarelic0x24.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,22 @@ struct DuskwindBananaRelicColor {
2323
// SIZE 0x24
2424
class DuskwindBananaRelic0x24 {
2525
public:
26+
enum {
27+
c_flagBit0 = 1 << 0,
28+
c_flagBit14 = 1 << 14,
29+
};
30+
2631
DuskwindBananaRelic0x24();
2732
virtual ~DuskwindBananaRelic0x24(); // vtable+0x00
2833

34+
undefined4* GetUnk0x04() const { return m_unk0x04; }
35+
LegoU32 GetUnk0x08() const { return m_unk0x08; }
36+
2937
// SYNTHETIC: GOLDP 0x100257b0
3038
// DuskwindBananaRelic0x24::`scalar deleting destructor'
3139

3240
protected:
33-
enum {
34-
c_flagBit0 = 1 << 0,
35-
};
36-
37-
undefined4 m_unk0x04;
41+
undefined4* m_unk0x04;
3842
LegoU32 m_unk0x08;
3943
DuskwindBananaRelicColor m_unk0x0c;
4044
DuskwindBananaRelicColor m_unk0x10;

GolDP/include/duskwindbananarelic0x30.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "compat.h"
55
#include "duskwindbananarelic0x24.h"
66

7+
#include <d3d.h>
8+
79
class BronzeFalcon0xc8770;
810

911
// VTABLE: GOLDP 0x100563c4
@@ -13,15 +15,17 @@ class DuskwindBananaRelic0x30 : public DuskwindBananaRelic0x24 {
1315
DuskwindBananaRelic0x30();
1416
~DuskwindBananaRelic0x30() override; // vtable+0x00
1517

16-
void FUN_10006320(BronzeFalcon0xc8770*);
18+
void FUN_10006320(BronzeFalcon0xc8770& p_renderer);
1719

1820
// SYNTHETIC: GOLDP 0x10004b00
1921
// DuskwindBananaRelic0x30::`vector deleting destructor'
2022

23+
void Destroy();
24+
2125
private:
22-
undefined4* m_unk0x24; // 0x24
23-
undefined4 m_unk0x28; // 0x28
24-
undefined4* m_unk0x2c; // 0x2c
26+
LPDIRECT3DMATERIAL3 m_unk0x24; // 0x24
27+
undefined4 m_unk0x28; // 0x28
28+
undefined4* m_unk0x2c; // 0x2c
2529
};
2630

2731
#endif // DUSKWINDBANANARELIC0x30_H

GolDP/include/rectangle.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef RECTANGLE_H
2+
#define RECTANGLE_H
3+
4+
// SIZE 0x10
5+
struct IntRectangle0x10 {
6+
LegoS32 m_left; // 0x00
7+
LegoS32 m_top; // 0x04
8+
LegoS32 m_right; // 0x08
9+
LegoS32 m_bottom; // 0x0c
10+
};
11+
12+
#endif // RECTANGLE_H

GolDP/include/softwarerenderer0x58.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44
#include "decomp.h"
55
#include "types.h"
66

7+
#include <d3dtypes.h>
8+
79
// SIZE 0x58
810
class SoftwareRenderer0x58 {
911
public:
12+
// SIZE 0x14
13+
struct Command0x14 {
14+
undefined m_unk0x00[0x04 - 0x00]; // 0x00
15+
LegoFloat m_unk0x04; // 0x04
16+
undefined2 m_unk0x08; // 0x08
17+
undefined2 m_unk0x0a; // 0x0a
18+
undefined2 m_unk0x0c; // 0x0c
19+
undefined4 m_unk0x10; // 0x10
20+
};
21+
1022
enum PixelFormat {
1123
e_format555 = 0,
1224
e_format565 = 1,
@@ -18,7 +30,9 @@ class SoftwareRenderer0x58 {
1830

1931
LegoBool Initialize(PixelFormat p_pixelFormat, LegoS32 p_nodeCapacity);
2032

21-
void SetUnk0x4c(undefined* p_arg) { m_unk0x4c = p_arg; }
33+
void SetUnk0x4c(D3DTLVERTEX* p_arg) { m_unk0x4c = p_arg; }
34+
void FUN_100417a0(Command0x14* p_cmds, LegoU32 p_count, LegoFloat);
35+
void FUN_100417c0(Command0x14* p_cmds, LegoU32 p_count);
2236

2337
private:
2438
// SIZE 0x14
@@ -45,7 +59,7 @@ class SoftwareRenderer0x58 {
4559
LegoS32 m_nodeCapacity; // 0x40
4660
RenderNode* m_nodes; // 0x44
4761
undefined m_unk0x48[0x4c - 0x48]; // 0x48
48-
undefined* m_unk0x4c; // 0x4c
62+
D3DTLVERTEX* m_unk0x4c; // 0x4c
4963
undefined m_unk0x50[0x54 - 0x50]; // 0x50
5064
RenderNode* m_unk0x54; // 0x54
5165
};

GolDP/include/whitefalcon0x140.h

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ class AmberHaze0x1c;
1111
class AmberLens0x344;
1212
class BronzeFalcon0xc8770;
1313
class CinderBasin0x28;
14+
class DuskwindBananaRelic0x24;
1415
class FalconTextureFormat;
1516
class GolFont0xa0;
1617
class GolCommonDrawState;
1718
class GolNameTable;
1819
class HypnoticNoise0x1c;
20+
struct IntRectangle0x10;
1921
class MagentaRibbon0x20;
2022
class SlatePeak0x58;
2123
class UtopianPan0xa4;
@@ -26,15 +28,12 @@ class WhiteFalcon0x140 {
2628
public:
2729
// SIZE 0x18
2830
struct TexturedVertex {
29-
LegoFloat m_x; // 0x00
30-
LegoFloat m_y; // 0x04
31-
LegoFloat m_z; // 0x08
32-
LegoFloat m_u; // 0x0c
33-
LegoFloat m_v; // 0x10
34-
LegoU8 m_red; // 0x14
35-
LegoU8 m_green; // 0x15
36-
LegoU8 m_blue; // 0x16
37-
LegoU8 m_alpha; // 0x17
31+
LegoFloat m_x; // 0x00
32+
LegoFloat m_y; // 0x04
33+
LegoFloat m_z; // 0x08
34+
LegoFloat m_u; // 0x0c
35+
LegoFloat m_v; // 0x10
36+
ColorRGBA m_color; // 0x14
3837
};
3938

4039
enum Flags {
@@ -98,13 +97,21 @@ class WhiteFalcon0x140 {
9897
SilverDune0x30::Rect* p_destRect,
9998
SilverDune0x30::Rect* p_sourceRect,
10099
undefined4 p_unk0x14
101-
) = 0; // vtable+0x7c
102-
virtual void VTable0x80() = 0; // vtable+0x80
100+
) = 0; // vtable+0x7c
101+
virtual void DrawRectangle(
102+
const IntRectangle0x10& p_rect,
103+
LegoFloat p_z,
104+
const ColorRGBA& p_color1,
105+
const ColorRGBA& p_color2,
106+
const ColorRGBA& p_color3,
107+
const ColorRGBA& p_color4,
108+
undefined4 p_arg7
109+
) = 0; // vtable+0x80
103110
virtual void DrawTriangle(
104111
const TexturedVertex* p_vertex0,
105112
const TexturedVertex* p_vertex1,
106113
const TexturedVertex* p_vertex2,
107-
undefined4 p_material,
114+
DuskwindBananaRelic0x24* p_material,
108115
undefined4 p_flags
109116
) = 0; // vtable+0x84
110117
virtual void VTable0x88(undefined4, undefined4, undefined4); // vtable+0x88
@@ -135,12 +142,12 @@ class WhiteFalcon0x140 {
135142
virtual void VTable0xec(undefined4); // vtable+0xec
136143
virtual void VTable0xf0() = 0; // vtable+0xf0
137144
virtual void VTable0xf4(); // vtable+0xf4
138-
virtual void VTable0xf8() = 0; // vtable+0xf8
139-
virtual void VTable0xfc() = 0; // vtable+0xfc
140-
virtual void VTable0x100() = 0; // vtable+0x100
141-
virtual void VTable0x104() = 0; // vtable+0x104
142-
virtual void VTable0x108() = 0; // vtable+0x108
143-
virtual void VTable0x10c() = 0; // vtable+0x10c
145+
virtual LegoU32 GetMinimumTextureWidth(undefined4) const = 0; // vtable+0xf8
146+
virtual LegoU32 GetMaximumTextureWidth(undefined4) const = 0; // vtable+0xfc
147+
virtual LegoU32 GetMinimumTextureHeight(undefined4) const = 0; // vtable+0x100
148+
virtual LegoU32 GetMaximumTextureHeight(undefined4) const = 0; // vtable+0x104
149+
virtual LegoBool32 TexturesMustBeSquare() const = 0; // vtable+0x108
150+
virtual LegoBool32 TextureSizesMustBePowersOfTwo() const = 0; // vtable+0x10c
144151
virtual LegoBool32 VTable0x110() const;
145152

146153
void Destroy();

0 commit comments

Comments
 (0)