mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Use 8bit surfaces for 2D content on miniwin (#680)
This commit is contained in:
parent
61632ea0a7
commit
57e918904c
@ -630,7 +630,6 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC p_ddsc)
|
||||
// Setup display surface
|
||||
if ((m_waitIndicator->GetAction()->GetFlags() & MxDSAction::c_bit5) != 0) {
|
||||
MxDisplaySurface* displaySurface = VideoManager()->GetDisplaySurface();
|
||||
MxBool und = FALSE;
|
||||
displaySurface->VTable0x2c(
|
||||
p_ddsc,
|
||||
m_waitIndicator->GetBitmap(),
|
||||
@ -639,8 +638,7 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC p_ddsc)
|
||||
m_waitIndicator->GetLocation().GetX(),
|
||||
m_waitIndicator->GetLocation().GetY(),
|
||||
m_waitIndicator->GetWidth(),
|
||||
m_waitIndicator->GetHeight(),
|
||||
und
|
||||
m_waitIndicator->GetHeight()
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -852,7 +852,7 @@ void LegoVideoManager::SetCursorBitmap(const CursorBitmap* p_cursorBitmap)
|
||||
m_cursorRect.bottom = p_cursorBitmap->height;
|
||||
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) {
|
||||
m_drawCursor = FALSE;
|
||||
|
||||
@ -61,8 +61,7 @@ class MxDisplaySurface : public MxCore {
|
||||
MxS32 p_right,
|
||||
MxS32 p_bottom,
|
||||
MxS32 p_width,
|
||||
MxS32 p_height,
|
||||
MxBool p_RLE
|
||||
MxS32 p_height
|
||||
); // vtable+0x2c
|
||||
virtual void VTable0x30(
|
||||
MxBitmap* p_bitmap,
|
||||
@ -71,8 +70,7 @@ class MxDisplaySurface : public MxCore {
|
||||
MxS32 p_right,
|
||||
MxS32 p_bottom,
|
||||
MxS32 p_width,
|
||||
MxS32 p_height,
|
||||
MxBool p_RLE
|
||||
MxS32 p_height
|
||||
); // vtable+0x30
|
||||
virtual void Display(
|
||||
MxS32 p_left,
|
||||
@ -92,23 +90,12 @@ class MxDisplaySurface : public MxCore {
|
||||
); // vtable+0x44
|
||||
|
||||
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);
|
||||
|
||||
LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return m_ddSurface1; }
|
||||
LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return m_ddSurface2; }
|
||||
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);
|
||||
|
||||
private:
|
||||
|
||||
@ -327,6 +327,7 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MINIWIN
|
||||
MxS32 bitCount = m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount;
|
||||
if (bitCount == 8) {
|
||||
return;
|
||||
@ -378,6 +379,7 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette)
|
||||
m_32bitPal[i] = red | green | blue | alpha;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100bacc0
|
||||
@ -412,7 +414,13 @@ void MxDisplaySurface::VTable0x28(
|
||||
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
|
||||
ddsd.dwWidth = p_width;
|
||||
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;
|
||||
#endif
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
|
||||
LPDIRECTDRAWSURFACE tempSurface = nullptr;
|
||||
@ -422,6 +430,24 @@ void MxDisplaySurface::VTable0x28(
|
||||
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) {
|
||||
DDCOLORKEY colorKey;
|
||||
if (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount == 8) {
|
||||
@ -432,6 +458,7 @@ void MxDisplaySurface::VTable0x28(
|
||||
}
|
||||
tempSurface->SetColorKey(DDCKEY_SRCBLT, &colorKey);
|
||||
}
|
||||
#endif
|
||||
|
||||
DDSURFACEDESC tempDesc;
|
||||
memset(&tempDesc, 0, sizeof(tempDesc));
|
||||
@ -450,7 +477,7 @@ void MxDisplaySurface::VTable0x28(
|
||||
|
||||
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;
|
||||
|
||||
MxLong stride = (bytesPerPixel == 1) ? GetAdjustedStride(p_bitmap) : -p_width + GetAdjustedStride(p_bitmap);
|
||||
@ -502,8 +529,7 @@ void MxDisplaySurface::VTable0x30(
|
||||
MxS32 p_right,
|
||||
MxS32 p_bottom,
|
||||
MxS32 p_width,
|
||||
MxS32 p_height,
|
||||
MxBool p_RLE
|
||||
MxS32 p_height
|
||||
)
|
||||
{
|
||||
if (!GetRectIntersection(
|
||||
@ -526,7 +552,13 @@ void MxDisplaySurface::VTable0x30(
|
||||
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
|
||||
ddsd.dwWidth = p_width;
|
||||
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;
|
||||
#endif
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
|
||||
LPDIRECTDRAW draw = MVideoManager()->GetDirectDraw();
|
||||
@ -535,6 +567,25 @@ void MxDisplaySurface::VTable0x30(
|
||||
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;
|
||||
colorKey.dwColorSpaceLowValue = colorKey.dwColorSpaceHighValue = 0;
|
||||
tempSurface->SetColorKey(DDCKEY_SRCBLT, &colorKey);
|
||||
@ -550,14 +601,9 @@ void MxDisplaySurface::VTable0x30(
|
||||
|
||||
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;
|
||||
|
||||
if (p_RLE) {
|
||||
MxS32 size = p_bitmap->GetBmiHeader()->biSizeImage;
|
||||
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;
|
||||
|
||||
@ -582,7 +628,6 @@ void MxDisplaySurface::VTable0x30(
|
||||
data += stride;
|
||||
surface += length;
|
||||
}
|
||||
}
|
||||
|
||||
tempSurface->Unlock(NULL);
|
||||
|
||||
@ -591,161 +636,6 @@ void MxDisplaySurface::VTable0x30(
|
||||
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
|
||||
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.dwWidth = p_bitmap->GetBmiWidth();
|
||||
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;
|
||||
#endif
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
*p_ret = 0;
|
||||
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
||||
@ -852,6 +748,24 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
|
||||
}
|
||||
|
||||
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));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
@ -971,6 +885,21 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CopySurface(LPDIRECTDRAWSURFACE p_src)
|
||||
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};
|
||||
|
||||
if (newSurface->BltFast(0, 0, p_src, &rect, DDBLTFAST_WAIT) != DD_OK) {
|
||||
@ -1084,8 +1013,7 @@ void MxDisplaySurface::VTable0x2c(
|
||||
MxS32 p_right,
|
||||
MxS32 p_bottom,
|
||||
MxS32 p_width,
|
||||
MxS32 p_height,
|
||||
MxBool p_RLE
|
||||
MxS32 p_height
|
||||
)
|
||||
{
|
||||
// DECOMP: Almost an exact copy of VTable0x28, except that it uses the argument DDSURFACEDESC
|
||||
@ -1111,18 +1039,6 @@ void MxDisplaySurface::VTable0x2c(
|
||||
MxLong destStride = p_desc->lPitch;
|
||||
MxU8* dest = (MxU8*) p_desc->lpSurface + bytesPerPixel * p_right + (p_bottom * destStride);
|
||||
|
||||
if (p_RLE) {
|
||||
DrawTransparentRLE(
|
||||
src,
|
||||
dest,
|
||||
p_bitmap->GetBmiHeader()->biSizeImage,
|
||||
p_width,
|
||||
p_height,
|
||||
destStride,
|
||||
m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount
|
||||
);
|
||||
}
|
||||
else {
|
||||
MxLong srcStride = GetAdjustedStride(p_bitmap);
|
||||
MxLong srcSkip = srcStride - p_width;
|
||||
MxLong destSkip = destStride - bytesPerPixel * p_width;
|
||||
@ -1144,7 +1060,6 @@ void MxDisplaySurface::VTable0x2c(
|
||||
dest += bytesPerPixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100bc8b0
|
||||
@ -1183,11 +1098,10 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bc8b0(MxS32 p_width, MxS32 p_height
|
||||
return surface;
|
||||
}
|
||||
|
||||
LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_cursorBitmap)
|
||||
LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_cursorBitmap, MxPalette* p_palette)
|
||||
{
|
||||
LPDIRECTDRAWSURFACE newSurface = NULL;
|
||||
IDirectDraw* draw = MVideoManager()->GetDirectDraw();
|
||||
MVideoManager();
|
||||
|
||||
DDSURFACEDESC ddsd;
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
@ -1197,14 +1111,19 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_
|
||||
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.dwHeight = p_cursorBitmap->height;
|
||||
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
|
||||
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) {
|
||||
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));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
@ -1242,6 +1165,8 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_
|
||||
else {
|
||||
pixel = isBlack ? 0 : 0xff;
|
||||
}
|
||||
surface[x + y * p_cursorBitmap->width] = pixel;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
MxU16* surface = (MxU16*) ddsd.lpSurface;
|
||||
@ -1284,8 +1209,7 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface(const CursorBitmap* p_
|
||||
switch (bytesPerPixel) {
|
||||
case 1: {
|
||||
DDCOLORKEY colorkey;
|
||||
colorkey.dwColorSpaceHighValue = 0x10;
|
||||
colorkey.dwColorSpaceLowValue = 0x10;
|
||||
colorkey.dwColorSpaceHighValue = colorkey.dwColorSpaceLowValue = 0x10;
|
||||
newSurface->SetColorKey(DDCKEY_SRCBLT, &colorkey);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -253,8 +253,7 @@ void MxVideoPresenter::PutFrame()
|
||||
rect.GetLeft(),
|
||||
rect.GetTop(),
|
||||
m_frameBitmap->GetBmiWidth(),
|
||||
m_frameBitmap->GetBmiHeightAbs(),
|
||||
TRUE
|
||||
m_frameBitmap->GetBmiHeightAbs()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -280,7 +279,7 @@ void MxVideoPresenter::PutFrame()
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user