Skip to content

Commit f3724a5

Browse files
authored
BronzeFalconSurface0x5c (isledecomp#246)
* `BronzeFalconSurface0x5c` * Match
1 parent eb7dc27 commit f3724a5

4 files changed

Lines changed: 68 additions & 11 deletions

File tree

GolDP/include/bronzefalcon0xc8770.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class BronzeFalcon0xc8770 : public WhiteFalcon0x140 {
177177

178178
friend class PearlDew0x0c;
179179
friend class SlatePeak0x58;
180+
friend class BronzeFalconSurface0x5c;
180181

181182
private:
182183
static LegoFloat ScaleColorChannel(double p_color, double p_materialColor)

GolDP/include/goldrawdpstate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class GolDrawDPState : public GolCommonDrawState {
6262
friend class DepthBuffer0x38;
6363
friend class SlatePeak0x58;
6464
friend class BronzeFalcon0xc8770;
65+
friend class BronzeFalconSurface0x5c;
6566

6667
private:
6768
void ReleaseDDraw();

GolDP/include/silverdune0x30.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SilverDune0x30 {
4646
LegoU16 GetWidth() const { return m_width; }
4747
LegoU16 GetHeight() const { return m_height; }
4848
GolSurfaceFormat& GetTextureFormat() { return m_textureFormat; }
49+
const GolSurfaceFormat& GetTextureFormat() const { return m_textureFormat; }
4950

5051
protected:
5152
friend class BronzeFalcon0xc8770;

GolDP/src/bronzefalconsurface0x5c.cpp

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,42 @@
11
#include "bronzefalconsurface0x5c.h"
22

3+
#include "bronzefalcon0xc8770.h"
4+
#include "golcommondrawstate.h"
5+
#include "goldrawdpstate.h"
6+
#include "goldrawstate.h"
7+
#include "golerror.h"
8+
9+
#include <stdio.h>
10+
#include <string.h>
11+
312
// FUNCTION: GOLDP 0x10013540
413
BronzeFalconSurface0x5c::BronzeFalconSurface0x5c()
514
{
615
m_next = NULL;
716
}
817

9-
// STUB: GOLDP 0x10013580
18+
// FUNCTION: GOLDP 0x10013580
1019
BronzeFalconSurface0x5c::~BronzeFalconSurface0x5c()
1120
{
12-
// TODO
13-
STUB(0x10013580);
21+
ReleaseResources();
22+
m_next = NULL;
23+
m_drawState = NULL;
1424
}
1525

16-
// STUB: GOLDP 0x10013600
17-
void BronzeFalconSurface0x5c::FUN_10013600(BronzeFalcon0xc8770*, undefined2, undefined2)
26+
// FUNCTION: GOLDP 0x10013600
27+
void BronzeFalconSurface0x5c::FUN_10013600(BronzeFalcon0xc8770* p_renderer, undefined2 p_width, undefined2 p_height)
1828
{
19-
// TODO
20-
STUB(0x10013600);
29+
if (m_pixelFlags & c_lockRequestRead) {
30+
VTable0x34();
31+
}
32+
33+
GolCommonDrawState* drawState = p_renderer->GetDrawState();
34+
m_unk0x30 = drawState;
35+
m_drawState = drawState;
36+
m_width = p_width;
37+
m_height = p_height;
38+
m_textureFormat = p_renderer->GetRenderTargetInfo()->GetTextureFormat();
39+
FUN_100136a0(p_renderer);
2140
}
2241

2342
// FUNCTION: GOLDP 0x1002c020 FOLDED
@@ -34,11 +53,46 @@ void BronzeFalconSurface0x5c::VTable0x34()
3453
m_drawState = NULL;
3554
}
3655

37-
// STUB: GOLDP 0x100136a0
38-
void BronzeFalconSurface0x5c::FUN_100136a0(BronzeFalcon0xc8770*)
56+
// FUNCTION: GOLDP 0x100136a0
57+
void BronzeFalconSurface0x5c::FUN_100136a0(BronzeFalcon0xc8770* p_renderer)
3958
{
40-
// TODO
41-
STUB(0x100136a0);
59+
LPDIRECTDRAW4 ddraw = static_cast<GolDrawDPState*>(m_drawState)->m_ddraw4;
60+
61+
DDSURFACEDESC2 surfaceDesc;
62+
LegoChar errorMessage[100];
63+
m_renderSurface = NULL;
64+
::memset(&surfaceDesc, 0, sizeof(surfaceDesc));
65+
surfaceDesc.dwSize = sizeof(surfaceDesc);
66+
67+
HRESULT result = p_renderer->m_renderTargetInfo->GetRenderSurface()->GetSurfaceDesc(&surfaceDesc);
68+
if (result) {
69+
::sprintf(errorMessage, "Unable to get surface desc\nerror %x", result);
70+
GOL_FATALERROR_MESSAGE(errorMessage);
71+
}
72+
73+
surfaceDesc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
74+
surfaceDesc.dwWidth = m_width;
75+
surfaceDesc.dwHeight = m_height;
76+
surfaceDesc.ddpfPixelFormat.dwSize = sizeof(surfaceDesc.ddpfPixelFormat);
77+
78+
if ((m_drawState->m_flags & GolDrawState::c_flagBit19) || (p_renderer->m_flags & WhiteFalcon0x140::c_flagBit16)) {
79+
surfaceDesc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
80+
m_unk0x34 &= ~(c_surfaceFlagWindowed | c_surfaceFlagFlip);
81+
}
82+
else {
83+
surfaceDesc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
84+
m_unk0x34 &= ~(c_surfaceFlagWindowed | c_surfaceFlagFlip);
85+
m_unk0x34 |= c_surfaceFlagFlip;
86+
}
87+
88+
result = ddraw->CreateSurface(&surfaceDesc, &m_displaySurface, NULL);
89+
if (result) {
90+
::sprintf(errorMessage, "Unable to create rendering surface\nerror %x", result);
91+
GOL_FATALERROR_MESSAGE(errorMessage);
92+
}
93+
94+
m_pixelFlags = c_lockRequestRead;
95+
m_renderSurface = m_displaySurface;
4296
}
4397

4498
// FUNCTION: GOLDP 0x100137d0

0 commit comments

Comments
 (0)