Skip to content

Commit 893e9fe

Browse files
committed
Matches
1 parent 3a8ad12 commit 893e9fe

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

GolDP/include/purpledune0x7c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PurpleDune0x7c : public GoldDune0x38 {
4343
// Unsure about size, might be a union
4444
LegoU8* m_pixels; // 0x00
4545
LegoU32 m_pitch; // 0x04
46-
undefined m_unk0x08[0x18 - 0x00]; // 0x08
46+
undefined m_unk0x08[0x18 - 0x08]; // 0x08
4747
};
4848

4949
undefined4 m_unk0x38; // 0x38

GolDP/src/purpledune0x7c.cpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ PurpleDune0x7c::~PurpleDune0x7c()
1919
{
2020
FUN_10016380();
2121
m_unk0x50.FUN_1002a1b0();
22+
2223
if (m_pixels != NULL) {
2324
delete[] m_pixels;
2425
m_pixels = NULL;
2526
}
27+
2628
m_pixelFlags = 0;
2729
}
2830

@@ -44,18 +46,21 @@ void PurpleDune0x7c::VTable0x34(
4446
if (m_pixelFlags & c_lockRequestRead) {
4547
VTable0x38();
4648
}
49+
4750
m_pixelFlags |= c_lockRequestRead;
4851
m_width = p_width;
4952
m_height = p_height;
5053
m_textureFormat = p_textureFormat;
51-
m_pitch = (p_width * m_textureFormat.m_bitsPerPixel + 7) / 8;
54+
m_pitch = ((LegoU32) (LegoU16) p_width * m_textureFormat.m_bitsPerPixel + 7) / 8;
5255
m_pixels = new LegoU8[m_pitch * p_height];
56+
5357
if (m_pixels == NULL) {
5458
GOL_FATALERROR(c_golErrorOutOfMemory);
5559
}
5660
if (p_textureFormat.m_paletteMask != 0) {
5761
m_unk0x50.FUN_1002a120(p_textureFormat);
5862
}
63+
5964
FUN_10016460(static_cast<BronzeFalcon0xc8770&>(p_renderer));
6065
}
6166

@@ -64,23 +69,25 @@ void PurpleDune0x7c::VTable0x38()
6469
{
6570
FUN_10016380();
6671
m_unk0x50.FUN_1002a1b0();
72+
6773
if (m_pixels != NULL) {
6874
delete[] m_pixels;
6975
m_pixels = NULL;
7076
}
77+
7178
m_pixelFlags = 0;
7279
}
7380

7481
// FUNCTION: GOLDP 0x10015e30
7582
void PurpleDune0x7c::LockPixels(LegoU8** p_pixels, LegoU32* p_pitch, LegoU32 p_flags)
7683
{
77-
DDSURFACEDESC2 surfaceDesc; // = { 0};
7884
if (p_flags & c_lockRequestRead) {
7985
m_pixelFlags |= c_lockFlagRead;
8086
}
8187
if (p_flags & c_lockRequestWrite) {
8288
m_pixelFlags |= c_lockFlagWrite;
8389
}
90+
8491
m_pixelFlags |= c_lockFlagLocked;
8592
if (m_pixels == NULL) {
8693
if (m_unk0x44 != NULL) {
@@ -99,8 +106,11 @@ void PurpleDune0x7c::LockPixels(LegoU8** p_pixels, LegoU32* p_pitch, LegoU32 p_f
99106
lockFlags = DDLOCK_WRITEONLY;
100107
}
101108
}
109+
110+
DDSURFACEDESC2 surfaceDesc;
102111
::memset(&surfaceDesc, 0, sizeof(surfaceDesc));
103112
surfaceDesc.dwSize = sizeof(surfaceDesc);
113+
104114
for (;;) {
105115
HRESULT hresult = LockDirectDrawSurface(m_surface, NULL, &surfaceDesc, lockFlags, NULL);
106116
switch (hresult) {
@@ -151,34 +161,40 @@ void PurpleDune0x7c::FUN_10015fb0()
151161
{
152162
DDCOLORKEY colorkey;
153163
ColorRGBA rgba;
164+
154165
if (m_unk0x44 == NULL && (m_unk0x36 & c_unk0x36Bit5) && !(m_unk0x36 & c_unk0x36Bit10) &&
155166
(m_unk0x36 & c_unk0x36Bit11)) {
156167
if (m_textureFormat2.m_paletteMask == 0) {
168+
LegoU32 color;
169+
157170
if (m_unk0x36 & c_unk0x36Bit7) {
158-
::memset(&colorkey, 0, sizeof(colorkey));
171+
color = 0;
159172
}
160173
else {
161174
LegoU32 redRightShift = 8 - m_textureFormat2.GetRedBitCount();
162175
LegoU32 grnRightShift = 8 - m_textureFormat2.GetGreenBitCount();
163176
LegoU32 bluRightShift = 8 - m_textureFormat2.GetBlueBitCount();
164-
colorkey.dwColorSpaceHighValue =
165-
((m_unk0x30.m_blu >> bluRightShift) << m_textureFormat2.GetBlueBitShift()) |
166-
((m_unk0x30.m_grn >> grnRightShift) << m_textureFormat2.GetGreenBitShift()) |
167-
((m_unk0x30.m_red >> redRightShift) << m_textureFormat2.GetRedBitShift());
168-
colorkey.dwColorSpaceLowValue = colorkey.dwColorSpaceHighValue;
177+
LegoU32 red = (m_unk0x30.m_red >> redRightShift) << m_textureFormat2.GetRedBitShift();
178+
LegoU32 grn = (m_unk0x30.m_grn >> grnRightShift) << m_textureFormat2.GetGreenBitShift();
179+
LegoU32 blu = (m_unk0x30.m_blu >> bluRightShift) << m_textureFormat2.GetBlueBitShift();
180+
color = blu | grn | red;
169181
}
182+
colorkey.dwColorSpaceHighValue = color;
183+
colorkey.dwColorSpaceLowValue = color;
170184
}
171185
else {
186+
LegoS32 color;
187+
172188
if (m_unk0x36 & c_unk0x36Bit7) {
173189
rgba.m_red = 0;
174190
rgba.m_grn = 0;
175191
rgba.m_blu = 0;
176192
rgba.m_alp = 0;
193+
color = m_unk0x40->FindEntry(rgba);
177194
}
178195
else {
179-
rgba = m_unk0x30;
196+
color = m_unk0x40->FindEntry(m_unk0x30);
180197
}
181-
LegoS32 color = m_unk0x40->FindEntry(rgba);
182198
colorkey.dwColorSpaceHighValue = color;
183199
colorkey.dwColorSpaceLowValue = colorkey.dwColorSpaceHighValue;
184200

@@ -202,9 +218,11 @@ IPalette0x4* PurpleDune0x7c::GetPalette()
202218
return m_unk0x40;
203219
}
204220
}
221+
205222
if (m_unk0x50.HasEntries()) {
206223
return &m_unk0x50;
207224
}
225+
208226
return NULL;
209227
}
210228

@@ -219,13 +237,15 @@ void PurpleDune0x7c::FUN_10016100()
219237
void PurpleDune0x7c::FUN_10016380()
220238
{
221239
LegoU32 i;
240+
222241
if (m_unk0x44 != NULL) {
223242
if (m_unk0x40 != NULL) {
224243
FalconDuneBag0x10* palette = static_cast<FalconDuneBag0x10*>(m_unk0x40);
225244
palette->Destroy();
226245
if (palette != NULL) {
227246
delete palette;
228247
}
248+
229249
m_unk0x40 = NULL;
230250
}
231251
for (i = 0; i < m_unk0x34; i++) {
@@ -234,13 +254,15 @@ void PurpleDune0x7c::FUN_10016380()
234254
m_unk0x44[i].m_pixels = NULL;
235255
}
236256
}
257+
237258
delete[] m_unk0x44;
238259
m_unk0x44 = NULL;
239260
}
240261
else {
241262
if (m_unk0x40 != NULL) {
242263
PearlDew0x0c* palette = static_cast<PearlDew0x0c*>(m_unk0x40);
243264
palette->Release();
265+
244266
if (m_unk0x40 != NULL) {
245267
delete palette;
246268
m_unk0x40 = NULL;
@@ -251,6 +273,7 @@ void PurpleDune0x7c::FUN_10016380()
251273
m_unk0x4c = NULL;
252274
}
253275
}
276+
254277
if (m_surface != NULL) {
255278
m_surface->Release();
256279
m_surface = NULL;

0 commit comments

Comments
 (0)