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
413BronzeFalconSurface0x5c::BronzeFalconSurface0x5c ()
514{
615 m_next = NULL ;
716}
817
9- // STUB : GOLDP 0x10013580
18+ // FUNCTION : GOLDP 0x10013580
1019BronzeFalconSurface0x5c::~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\n error %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\n error %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