Use 8bit surfaces for 2D content on miniwin (#680)

This commit is contained in:
Anders Jenbo 2025-08-20 23:58:10 +02:00 committed by GitHub
parent 61632ea0a7
commit 57e918904c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 155 additions and 247 deletions

View File

@ -630,7 +630,6 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC p_ddsc)
// Setup display surface // Setup display surface
if ((m_waitIndicator->GetAction()->GetFlags() & MxDSAction::c_bit5) != 0) { if ((m_waitIndicator->GetAction()->GetFlags() & MxDSAction::c_bit5) != 0) {
MxDisplaySurface* displaySurface = VideoManager()->GetDisplaySurface(); MxDisplaySurface* displaySurface = VideoManager()->GetDisplaySurface();
MxBool und = FALSE;
displaySurface->VTable0x2c( displaySurface->VTable0x2c(
p_ddsc, p_ddsc,
m_waitIndicator->GetBitmap(), m_waitIndicator->GetBitmap(),
@ -639,8 +638,7 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC p_ddsc)
m_waitIndicator->GetLocation().GetX(), m_waitIndicator->GetLocation().GetX(),
m_waitIndicator->GetLocation().GetY(), m_waitIndicator->GetLocation().GetY(),
m_waitIndicator->GetWidth(), m_waitIndicator->GetWidth(),
m_waitIndicator->GetHeight(), m_waitIndicator->GetHeight()
und
); );
} }
else { else {

View File

@ -852,7 +852,7 @@ void LegoVideoManager::SetCursorBitmap(const CursorBitmap* p_cursorBitmap)
m_cursorRect.bottom = p_cursorBitmap->height; m_cursorRect.bottom = p_cursorBitmap->height;
m_cursorRect.right = p_cursorBitmap->width; m_cursorRect.right = p_cursorBitmap->width;
m_cursorSurface = MxDisplaySurface::CreateCursorSurface(p_cursorBitmap); m_cursorSurface = MxDisplaySurface::CreateCursorSurface(p_cursorBitmap, m_videoParam.GetPalette());
if (m_cursorSurface == NULL) { if (m_cursorSurface == NULL) {
m_drawCursor = FALSE; m_drawCursor = FALSE;

View File

@ -61,8 +61,7 @@ class MxDisplaySurface : public MxCore {
MxS32 p_right, MxS32 p_right,
MxS32 p_bottom, MxS32 p_bottom,
MxS32 p_width, MxS32 p_width,
MxS32 p_height, MxS32 p_height
MxBool p_RLE
); // vtable+0x2c ); // vtable+0x2c
virtual void VTable0x30( virtual void VTable0x30(
MxBitmap* p_bitmap, MxBitmap* p_bitmap,
@ -71,8 +70,7 @@ class MxDisplaySurface : public MxCore {
MxS32 p_right, MxS32 p_right,
MxS32 p_bottom, MxS32 p_bottom,
MxS32 p_width, MxS32 p_width,
MxS32 p_height, MxS32 p_height
MxBool p_RLE
); // vtable+0x30 ); // vtable+0x30
virtual void Display( virtual void Display(
MxS32 p_left, MxS32 p_left,
@ -92,23 +90,12 @@ class MxDisplaySurface : public MxCore {
); // vtable+0x44 ); // vtable+0x44
void ClearScreen(); void ClearScreen();
static LPDIRECTDRAWSURFACE CreateCursorSurface(const CursorBitmap* p_cursorBitmap); static LPDIRECTDRAWSURFACE CreateCursorSurface(const CursorBitmap* p_cursorBitmap, MxPalette* p_palette);
static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src); static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src);
LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return m_ddSurface1; } LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return m_ddSurface1; }
LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return m_ddSurface2; } LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return m_ddSurface2; }
MxVideoParam& GetVideoParam() { return m_videoParam; } MxVideoParam& GetVideoParam() { return m_videoParam; }
void DrawTransparentRLE(
MxU8*& p_bitmapData,
MxU8*& p_surfaceData,
MxU32 p_bitmapSize,
MxS32 p_width,
MxS32 p_height,
MxLong p_pitch,
MxU8 p_bpp
);
LPDIRECTDRAWSURFACE FUN_100bc8b0(MxS32 p_width, MxS32 p_height); LPDIRECTDRAWSURFACE FUN_100bc8b0(MxS32 p_width, MxS32 p_height);
private: private:

View File

@ -327,6 +327,7 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette)
} }
} }
#ifndef MINIWIN
MxS32 bitCount = m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount; MxS32 bitCount = m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount;
if (bitCount == 8) { if (bitCount == 8) {
return; return;
@ -378,6 +379,7 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette)
m_32bitPal[i] = red | green | blue | alpha; m_32bitPal[i] = red | green | blue | alpha;
} }
} }
#endif
} }
// FUNCTION: LEGO1 0x100bacc0 // FUNCTION: LEGO1 0x100bacc0
@ -412,7 +414,13 @@ void MxDisplaySurface::VTable0x28(
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
ddsd.dwWidth = p_width; ddsd.dwWidth = p_width;
ddsd.dwHeight = p_height; ddsd.dwHeight = p_height;
#ifdef MINIWIN
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
ddsd.ddpfPixelFormat.dwRGBBitCount = 8;
#else
ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat; ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat;
#endif
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
LPDIRECTDRAWSURFACE tempSurface = nullptr; LPDIRECTDRAWSURFACE tempSurface = nullptr;
@ -422,6 +430,24 @@ void MxDisplaySurface::VTable0x28(
return; return;
} }
#ifdef MINIWIN
MxBITMAPINFO* bmi = p_bitmap->GetBitmapInfo();
if (bmi) {
PALETTEENTRY pe[256];
for (int i = 0; i < 256; i++) {
pe[i].peRed = bmi->m_bmiColors[i].rgbRed;
pe[i].peGreen = bmi->m_bmiColors[i].rgbGreen;
pe[i].peBlue = bmi->m_bmiColors[i].rgbBlue;
pe[i].peFlags = PC_NONE;
}
LPDIRECTDRAWPALETTE palette = nullptr;
if (draw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, pe, &palette, NULL) == DD_OK && palette) {
tempSurface->SetPalette(palette);
palette->Release();
}
}
#else
if (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount != 32) { if (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount != 32) {
DDCOLORKEY colorKey; DDCOLORKEY colorKey;
if (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount == 8) { if (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount == 8) {
@ -432,6 +458,7 @@ void MxDisplaySurface::VTable0x28(
} }
tempSurface->SetColorKey(DDCKEY_SRCBLT, &colorKey); tempSurface->SetColorKey(DDCKEY_SRCBLT, &colorKey);
} }
#endif
DDSURFACEDESC tempDesc; DDSURFACEDESC tempDesc;
memset(&tempDesc, 0, sizeof(tempDesc)); memset(&tempDesc, 0, sizeof(tempDesc));
@ -450,7 +477,7 @@ void MxDisplaySurface::VTable0x28(
MxU8* data = p_bitmap->GetStart(p_left, p_top); MxU8* data = p_bitmap->GetStart(p_left, p_top);
MxS32 bytesPerPixel = m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8; MxS32 bytesPerPixel = tempDesc.ddpfPixelFormat.dwRGBBitCount / 8;
MxU8* surface = (MxU8*) tempDesc.lpSurface; MxU8* surface = (MxU8*) tempDesc.lpSurface;
MxLong stride = (bytesPerPixel == 1) ? GetAdjustedStride(p_bitmap) : -p_width + GetAdjustedStride(p_bitmap); MxLong stride = (bytesPerPixel == 1) ? GetAdjustedStride(p_bitmap) : -p_width + GetAdjustedStride(p_bitmap);
@ -502,8 +529,7 @@ void MxDisplaySurface::VTable0x30(
MxS32 p_right, MxS32 p_right,
MxS32 p_bottom, MxS32 p_bottom,
MxS32 p_width, MxS32 p_width,
MxS32 p_height, MxS32 p_height
MxBool p_RLE
) )
{ {
if (!GetRectIntersection( if (!GetRectIntersection(
@ -526,7 +552,13 @@ void MxDisplaySurface::VTable0x30(
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
ddsd.dwWidth = p_width; ddsd.dwWidth = p_width;
ddsd.dwHeight = p_height; ddsd.dwHeight = p_height;
#ifdef MINIWIN
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
ddsd.ddpfPixelFormat.dwRGBBitCount = 8;
#else
ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat; ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat;
#endif
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
LPDIRECTDRAW draw = MVideoManager()->GetDirectDraw(); LPDIRECTDRAW draw = MVideoManager()->GetDirectDraw();
@ -535,6 +567,25 @@ void MxDisplaySurface::VTable0x30(
return; return;
} }
#ifdef MINIWIN
MxBITMAPINFO* bmi = p_bitmap->GetBitmapInfo();
if (bmi) {
PALETTEENTRY pe[256];
for (int i = 0; i < 256; i++) {
pe[i].peRed = bmi->m_bmiColors[i].rgbRed;
pe[i].peGreen = bmi->m_bmiColors[i].rgbGreen;
pe[i].peBlue = bmi->m_bmiColors[i].rgbBlue;
pe[i].peFlags = PC_NONE;
}
LPDIRECTDRAWPALETTE palette = nullptr;
if (draw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, pe, &palette, NULL) == DD_OK && palette) {
tempSurface->SetPalette(palette);
palette->Release();
}
}
#endif
DDCOLORKEY colorKey; DDCOLORKEY colorKey;
colorKey.dwColorSpaceLowValue = colorKey.dwColorSpaceHighValue = 0; colorKey.dwColorSpaceLowValue = colorKey.dwColorSpaceHighValue = 0;
tempSurface->SetColorKey(DDCKEY_SRCBLT, &colorKey); tempSurface->SetColorKey(DDCKEY_SRCBLT, &colorKey);
@ -550,38 +601,32 @@ void MxDisplaySurface::VTable0x30(
MxU8* data = p_bitmap->GetStart(p_left, p_top); MxU8* data = p_bitmap->GetStart(p_left, p_top);
MxS32 bytesPerPixel = m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8; MxS32 bytesPerPixel = tempDesc.ddpfPixelFormat.dwRGBBitCount / 8;
MxU8* surface = (MxU8*) tempDesc.lpSurface; MxU8* surface = (MxU8*) tempDesc.lpSurface;
if (p_RLE) { MxLong stride = -p_width + GetAdjustedStride(p_bitmap);
MxS32 size = p_bitmap->GetBmiHeader()->biSizeImage; MxLong length = -bytesPerPixel * p_width + tempDesc.lPitch;
DrawTransparentRLE(data, surface, size, p_width, p_height, tempDesc.lPitch, bytesPerPixel * 8);
}
else {
MxLong stride = -p_width + GetAdjustedStride(p_bitmap);
MxLong length = -bytesPerPixel * p_width + tempDesc.lPitch;
for (MxS32 i = 0; i < p_height; i++) { for (MxS32 i = 0; i < p_height; i++) {
for (MxS32 j = 0; j < p_width; j++) { for (MxS32 j = 0; j < p_width; j++) {
if (*data != 0) { if (*data != 0) {
switch (bytesPerPixel) { switch (bytesPerPixel) {
case 1: case 1:
*surface = *data; *surface = *data;
break; break;
case 2: case 2:
*(MxU16*) surface = m_16bitPal[*data]; *(MxU16*) surface = m_16bitPal[*data];
break; break;
default: default:
*(MxU32*) surface = m_32bitPal[*data]; *(MxU32*) surface = m_32bitPal[*data];
break; break;
}
} }
data++;
surface += bytesPerPixel;
} }
data += stride; data++;
surface += length; surface += bytesPerPixel;
} }
data += stride;
surface += length;
} }
tempSurface->Unlock(NULL); tempSurface->Unlock(NULL);
@ -591,161 +636,6 @@ void MxDisplaySurface::VTable0x30(
tempSurface->Release(); tempSurface->Release();
} }
// FUNCTION: LEGO1 0x100bb500
// FUNCTION: BETA10 0x10140cd6
void MxDisplaySurface::DrawTransparentRLE(
MxU8*& p_bitmapData,
MxU8*& p_surfaceData,
MxU32 p_bitmapSize,
MxS32 p_width,
MxS32 p_height,
MxLong p_pitch,
MxU8 p_bpp
)
{
/* Assumes partial RLE for the bitmap: only the skipped pixels are compressed.
The drawn pixels are uncompressed. The procedure is:
1. Read 3 bytes from p_bitmapData. Skip this many pixels on the surface.
2. Read 3 bytes from p_bitmapData. Draw this many pixels on the surface.
3. Repeat until the end of p_bitmapData is reached. */
MxU8* end = p_bitmapData + p_bitmapSize;
MxU8* surfCopy = p_surfaceData; // unused?
// The total number of pixels drawn or skipped
MxU32 count = 0;
// Used in both 8 and 16 bit branches
MxU32 skipCount;
MxU32 drawCount;
MxU32 t;
if (p_bpp == 16) {
// DECOMP: why goto?
goto sixteen_bit;
}
while (p_bitmapData < end) {
skipCount = *p_bitmapData++;
t = *p_bitmapData++;
skipCount += t << 8;
t = *p_bitmapData++;
skipCount += t << 16;
MxS32 rowRemainder = p_width - count % p_width;
count += skipCount;
if (skipCount >= rowRemainder) {
p_surfaceData += rowRemainder; // skip the rest of this row
skipCount -= rowRemainder;
p_surfaceData += p_pitch - p_width; // seek to start of next row
p_surfaceData += p_pitch * (skipCount / p_width); // skip entire rows if any
}
// skip any pixels at the start of this row
p_surfaceData += skipCount % p_width;
if (p_bitmapData >= end) {
break;
}
drawCount = *p_bitmapData++;
t = *p_bitmapData++;
drawCount += t << 8;
t = *p_bitmapData++;
drawCount += t << 16;
rowRemainder = p_width - count % p_width;
count += drawCount;
if (drawCount >= rowRemainder) {
memcpy(p_surfaceData, p_bitmapData, rowRemainder);
p_surfaceData += rowRemainder;
p_bitmapData += rowRemainder;
drawCount -= rowRemainder;
// seek to start of bitmap on this screen row
p_surfaceData += p_pitch - p_width;
MxS32 rows = drawCount / p_width;
for (MxU32 i = 0; i < rows; i++) {
memcpy(p_surfaceData, p_bitmapData, p_width);
p_bitmapData += p_width;
p_surfaceData += p_pitch;
}
}
MxS32 tail = drawCount % p_width;
memcpy(p_surfaceData, p_bitmapData, tail);
p_surfaceData += tail;
p_bitmapData += tail;
}
return;
sixteen_bit:
while (p_bitmapData < end) {
skipCount = *p_bitmapData++;
t = *p_bitmapData++;
skipCount += t << 8;
t = *p_bitmapData++;
skipCount += t << 16;
MxS32 rowRemainder = p_width - count % p_width;
count += skipCount;
if (skipCount >= rowRemainder) {
p_surfaceData += 2 * rowRemainder;
skipCount -= rowRemainder;
p_surfaceData += p_pitch - 2 * p_width;
p_surfaceData += p_pitch * (skipCount / p_width);
}
p_surfaceData += 2 * (skipCount % p_width);
if (p_bitmapData >= end) {
break;
}
drawCount = *p_bitmapData++;
t = *p_bitmapData++;
drawCount += t << 8;
t = *p_bitmapData++;
drawCount += t << 16;
rowRemainder = p_width - count % p_width;
count += drawCount;
if (drawCount >= rowRemainder) {
// memcpy
for (MxU32 j = 0; j < rowRemainder; j++) {
*((MxU16*) p_surfaceData) = m_16bitPal[*p_bitmapData++];
p_surfaceData += 2;
}
drawCount -= rowRemainder;
p_surfaceData += p_pitch - 2 * p_width;
MxS32 rows = drawCount / p_width;
for (MxU32 i = 0; i < rows; i++) {
// memcpy
for (MxS32 j = 0; j < p_width; j++) {
*((MxU16*) p_surfaceData) = m_16bitPal[*p_bitmapData++];
p_surfaceData += 2;
}
p_surfaceData += p_pitch - 2 * p_width;
}
}
MxS32 tail = drawCount % p_width;
// memcpy
for (MxS32 j = 0; j < tail; j++) {
*((MxU16*) p_surfaceData) = m_16bitPal[*p_bitmapData++];
p_surfaceData += 2;
}
}
}
// FUNCTION: LEGO1 0x100bba50 // FUNCTION: LEGO1 0x100bba50
void MxDisplaySurface::Display(MxS32 p_left, MxS32 p_top, MxS32 p_left2, MxS32 p_top2, MxS32 p_width, MxS32 p_height) void MxDisplaySurface::Display(MxS32 p_left, MxS32 p_top, MxS32 p_left2, MxS32 p_top2, MxS32 p_width, MxS32 p_height)
{ {
@ -829,7 +719,13 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
ddsd.dwWidth = p_bitmap->GetBmiWidth(); ddsd.dwWidth = p_bitmap->GetBmiWidth();
ddsd.dwHeight = p_bitmap->GetBmiHeightAbs(); ddsd.dwHeight = p_bitmap->GetBmiHeightAbs();
#ifdef MINIWIN
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
ddsd.ddpfPixelFormat.dwRGBBitCount = 8;
#else
ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat; ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat;
#endif
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
*p_ret = 0; *p_ret = 0;
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
@ -852,6 +748,24 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
} }
if (surface) { if (surface) {
#ifdef MINIWIN
MxBITMAPINFO* bmi = p_bitmap->GetBitmapInfo();
if (bmi) {
PALETTEENTRY pe[256];
for (int i = 0; i < 256; i++) {
pe[i].peRed = bmi->m_bmiColors[i].rgbRed;
pe[i].peGreen = bmi->m_bmiColors[i].rgbGreen;
pe[i].peBlue = bmi->m_bmiColors[i].rgbBlue;
pe[i].peFlags = PC_NONE;
}
LPDIRECTDRAWPALETTE palette = nullptr;
if (draw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, pe, &palette, NULL) == DD_OK && palette) {
surface->SetPalette(palette);
palette->Release();
}
}
#endif
memset(&ddsd, 0, sizeof(ddsd)); memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd); ddsd.dwSize = sizeof(ddsd);
@ -971,6 +885,21 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CopySurface(LPDIRECTDRAWSURFACE p_src)
return NULL; return NULL;
} }
#ifdef MINIWIN
LPDIRECTDRAWPALETTE srcPalette = nullptr;
if (p_src->GetPalette(&srcPalette) == DD_OK && srcPalette) {
PALETTEENTRY pe[256];
if (srcPalette->GetEntries(0, 0, 256, pe) == DD_OK) {
LPDIRECTDRAWPALETTE newPalette = nullptr;
if (draw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, pe, &newPalette, NULL) == DD_OK) {
newSurface->SetPalette(newPalette);
newPalette->Release();
}
}
srcPalette->Release();
}
#endif
RECT rect = {0, 0, (LONG) ddsd.dwWidth, (LONG) ddsd.dwHeight}; RECT rect = {0, 0, (LONG) ddsd.dwWidth, (LONG) ddsd.dwHeight};
if (newSurface->BltFast(0, 0, p_src, &rect, DDBLTFAST_WAIT) != DD_OK) { if (newSurface->BltFast(0, 0, p_src, &rect, DDBLTFAST_WAIT) != DD_OK) {
@ -1084,8 +1013,7 @@ void MxDisplaySurface::VTable0x2c(
MxS32 p_right, MxS32 p_right,
MxS32 p_bottom, MxS32 p_bottom,
MxS32 p_width, MxS32 p_width,
MxS32 p_height, MxS32 p_height
MxBool p_RLE
) )
{ {
// DECOMP: Almost an exact copy of VTable0x28, except that it uses the argument DDSURFACEDESC // DECOMP: Almost an exact copy of VTable0x28, except that it uses the argument DDSURFACEDESC
@ -1111,38 +1039,25 @@ void MxDisplaySurface::VTable0x2c(
MxLong destStride = p_desc->lPitch; MxLong destStride = p_desc->lPitch;
MxU8* dest = (MxU8*) p_desc->lpSurface + bytesPerPixel * p_right + (p_bottom * destStride); MxU8* dest = (MxU8*) p_desc->lpSurface + bytesPerPixel * p_right + (p_bottom * destStride);
if (p_RLE) { MxLong srcStride = GetAdjustedStride(p_bitmap);
DrawTransparentRLE( MxLong srcSkip = srcStride - p_width;
src, MxLong destSkip = destStride - bytesPerPixel * p_width;
dest, for (MxS32 i = 0; i < p_height; i++, src += srcSkip, dest += destSkip) {
p_bitmap->GetBmiHeader()->biSizeImage, for (MxS32 j = 0; j < p_width; j++, src++) {
p_width, if (*src != 0) {
p_height, switch (bytesPerPixel) {
destStride, case 1:
m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount *dest = *src;
); break;
} case 2:
else { *(MxU16*) dest = m_16bitPal[*src];
MxLong srcStride = GetAdjustedStride(p_bitmap); break;
MxLong srcSkip = srcStride - p_width; default:
MxLong destSkip = destStride - bytesPerPixel * p_width; *(MxU32*) dest = m_32bitPal[*src];
for (MxS32 i = 0; i < p_height; i++, src += srcSkip, dest += destSkip) { break;
for (MxS32 j = 0; j < p_width; j++, src++) {
if (*src != 0) {
switch (bytesPerPixel) {
case 1:
*dest = *src;
break;
case 2:
*(MxU16*) dest = m_16bitPal[*src];
break;
default:
*(MxU32*) dest = m_32bitPal[*src];
break;
}
} }
dest += bytesPerPixel;
} }
dest += bytesPerPixel;
} }
} }
} }
@ -1183,11 +1098,10 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bc8b0(MxS32 p_width, MxS32 p_height
return surface; return surface;
} }
LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_cursorBitmap) LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_cursorBitmap, MxPalette* p_palette)
{ {
LPDIRECTDRAWSURFACE newSurface = NULL; LPDIRECTDRAWSURFACE newSurface = NULL;
IDirectDraw* draw = MVideoManager()->GetDirectDraw(); IDirectDraw* draw = MVideoManager()->GetDirectDraw();
MVideoManager();
DDSURFACEDESC ddsd; DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd)); memset(&ddsd, 0, sizeof(ddsd));
@ -1197,14 +1111,19 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_
return NULL; return NULL;
} }
MxS32 bytesPerPixel = ddsd.ddpfPixelFormat.dwRGBBitCount / 8;
MxBool isAlphaAvailable = ((ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) == DDPF_ALPHAPIXELS) &&
(ddsd.ddpfPixelFormat.dwRGBAlphaBitMask != 0);
ddsd.dwWidth = p_cursorBitmap->width; ddsd.dwWidth = p_cursorBitmap->width;
ddsd.dwHeight = p_cursorBitmap->height; ddsd.dwHeight = p_cursorBitmap->height;
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN;
#ifdef MINIWIN
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
ddsd.ddpfPixelFormat.dwRGBBitCount = 8;
#endif
MxS32 bytesPerPixel = ddsd.ddpfPixelFormat.dwRGBBitCount / 8;
MxBool isAlphaAvailable = ((ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) == DDPF_ALPHAPIXELS) &&
(ddsd.ddpfPixelFormat.dwRGBAlphaBitMask != 0);
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) { if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) {
ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY; ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
@ -1215,6 +1134,10 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_
} }
} }
#ifdef MINIWIN
newSurface->SetPalette(p_palette->CreateNativePalette());
#endif
memset(&ddsd, 0, sizeof(ddsd)); memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd); ddsd.dwSize = sizeof(ddsd);
@ -1242,6 +1165,8 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_
else { else {
pixel = isBlack ? 0 : 0xff; pixel = isBlack ? 0 : 0xff;
} }
surface[x + y * p_cursorBitmap->width] = pixel;
break;
} }
case 2: { case 2: {
MxU16* surface = (MxU16*) ddsd.lpSurface; MxU16* surface = (MxU16*) ddsd.lpSurface;
@ -1284,8 +1209,7 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_
switch (bytesPerPixel) { switch (bytesPerPixel) {
case 1: { case 1: {
DDCOLORKEY colorkey; DDCOLORKEY colorkey;
colorkey.dwColorSpaceHighValue = 0x10; colorkey.dwColorSpaceHighValue = colorkey.dwColorSpaceLowValue = 0x10;
colorkey.dwColorSpaceLowValue = 0x10;
newSurface->SetColorKey(DDCKEY_SRCBLT, &colorkey); newSurface->SetColorKey(DDCKEY_SRCBLT, &colorkey);
break; break;
} }

View File

@ -253,8 +253,7 @@ void MxVideoPresenter::PutFrame()
rect.GetLeft(), rect.GetLeft(),
rect.GetTop(), rect.GetTop(),
m_frameBitmap->GetBmiWidth(), m_frameBitmap->GetBmiWidth(),
m_frameBitmap->GetBmiHeightAbs(), m_frameBitmap->GetBmiHeightAbs()
TRUE
); );
} }
} }
@ -280,7 +279,7 @@ void MxVideoPresenter::PutFrame()
} }
} }
else { else {
displaySurface->VTable0x30(m_frameBitmap, 0, 0, GetX(), GetY(), GetWidth(), GetHeight(), FALSE); displaySurface->VTable0x30(m_frameBitmap, 0, 0, GetX(), GetY(), GetWidth(), GetHeight());
} }
} }
else if (m_surface) { else if (m_surface) {