mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Use sprites to render things on screen (#478)
This commit is contained in:
parent
af045eefed
commit
77c832c237
@ -396,86 +396,81 @@ void MxDisplaySurface::VTable0x28(
|
|||||||
DDSURFACEDESC ddsd;
|
DDSURFACEDESC ddsd;
|
||||||
memset(&ddsd, 0, sizeof(ddsd));
|
memset(&ddsd, 0, sizeof(ddsd));
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
ddsd.dwSize = sizeof(ddsd);
|
||||||
|
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
|
||||||
|
ddsd.dwWidth = p_width;
|
||||||
|
ddsd.dwHeight = p_height;
|
||||||
|
ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat;
|
||||||
|
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||||
|
|
||||||
HRESULT hr = m_ddSurface2->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
|
LPDIRECTDRAWSURFACE tempSurface = nullptr;
|
||||||
|
LPDIRECTDRAW draw = MVideoManager()->GetDirectDraw();
|
||||||
|
HRESULT hr = draw->CreateSurface(&ddsd, &tempSurface, nullptr);
|
||||||
|
if (hr != DD_OK || !tempSurface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DDCOLORKEY colorKey;
|
||||||
|
colorKey.dwColorSpaceLowValue = colorKey.dwColorSpaceHighValue = RGB555_CREATE(0x1f, 0, 0x1f);
|
||||||
|
tempSurface->SetColorKey(DDCKEY_SRCBLT, &colorKey);
|
||||||
|
|
||||||
|
DDSURFACEDESC tempDesc;
|
||||||
|
memset(&tempDesc, 0, sizeof(tempDesc));
|
||||||
|
tempDesc.dwSize = sizeof(tempDesc);
|
||||||
|
|
||||||
|
hr = tempSurface->Lock(NULL, &tempDesc, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
|
||||||
if (hr == DDERR_SURFACELOST) {
|
if (hr == DDERR_SURFACELOST) {
|
||||||
m_ddSurface2->Restore();
|
tempSurface->Restore();
|
||||||
hr = m_ddSurface2->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
|
hr = tempSurface->Lock(NULL, &tempDesc, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hr != DD_OK) {
|
if (hr != DD_OK) {
|
||||||
|
tempSurface->Release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8;
|
||||||
if (m_videoParam.Flags().GetF1bit3()) {
|
MxU8* surface = (MxU8*) tempDesc.lpSurface;
|
||||||
p_bottom *= 2;
|
|
||||||
p_right *= 2;
|
|
||||||
|
|
||||||
MxU8* surface = (MxU8*) ddsd.lpSurface + (bytesPerPixel * p_right) + (p_bottom * ddsd.lPitch);
|
MxLong stride = (bytesPerPixel == 1) ? GetAdjustedStride(p_bitmap) : -p_width + GetAdjustedStride(p_bitmap);
|
||||||
MxLong stride = -p_width + GetAdjustedStride(p_bitmap);
|
MxLong length = tempDesc.lPitch - (p_width * bytesPerPixel);
|
||||||
MxS32 copyWidth = p_width * bytesPerPixel * 2;
|
|
||||||
MxLong length = -(copyWidth) + ddsd.lPitch;
|
|
||||||
|
|
||||||
while (p_height--) {
|
for (MxS32 i = 0; i < p_height; i++) {
|
||||||
MxU8* surfaceBefore = surface;
|
if (bytesPerPixel == 1) {
|
||||||
|
memcpy(surface, data, p_width);
|
||||||
for (MxS32 i = 0; i < p_width; i++) {
|
surface += length + p_width;
|
||||||
if (bytesPerPixel == 1) {
|
|
||||||
surface[0] = surface[1] = *data;
|
|
||||||
}
|
|
||||||
else if (bytesPerPixel == 2) {
|
|
||||||
((MxU16*) surface)[0] = ((MxU16*) surface)[1] = m_16bitPal[*data];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
((MxU32*) surface)[0] = ((MxU32*) surface)[1] = m_32bitPal[*data];
|
|
||||||
}
|
|
||||||
surface += bytesPerPixel * 2;
|
|
||||||
data++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stride || length != ddsd.lPitch - copyWidth) {
|
|
||||||
data += stride;
|
|
||||||
surface += length;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(surface, surfaceBefore, copyWidth);
|
|
||||||
surface += ddsd.lPitch;
|
|
||||||
}
|
}
|
||||||
|
else if (bytesPerPixel == 2) {
|
||||||
|
for (MxS32 j = 0; j < p_width; j++) {
|
||||||
|
*(MxU16*) surface = m_16bitPal[*data++];
|
||||||
|
surface += bytesPerPixel;
|
||||||
|
}
|
||||||
|
|
||||||
|
surface += length;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (MxS32 j = 0; j < p_width; j++) {
|
||||||
|
*(MxU32*) surface = m_32bitPal[*data++];
|
||||||
|
surface += bytesPerPixel;
|
||||||
|
}
|
||||||
|
surface += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
data += stride;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempSurface->Unlock(NULL);
|
||||||
|
|
||||||
|
if (m_videoParam.Flags().GetF1bit3()) {
|
||||||
|
RECT destRect = {p_right, p_bottom, p_right + p_width * 2, p_bottom + p_height * 2};
|
||||||
|
m_ddSurface2->Blt(&destRect, tempSurface, NULL, DDBLT_WAIT | DDBLT_KEYSRC, NULL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MxU8* surface = (MxU8*) ddsd.lpSurface + (bytesPerPixel * p_right) + (p_bottom * ddsd.lPitch);
|
m_ddSurface2->BltFast(p_right, p_bottom, tempSurface, NULL, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
|
||||||
MxLong stride = (bytesPerPixel == 1) ? GetAdjustedStride(p_bitmap) : -p_width + GetAdjustedStride(p_bitmap);
|
|
||||||
MxLong length = ddsd.lPitch - (p_width * bytesPerPixel);
|
|
||||||
|
|
||||||
for (MxS32 i = 0; i < p_height; i++) {
|
|
||||||
if (bytesPerPixel == 1) {
|
|
||||||
memcpy(surface, data, p_width);
|
|
||||||
surface += length + p_width;
|
|
||||||
}
|
|
||||||
else if (bytesPerPixel == 2) {
|
|
||||||
for (MxS32 j = 0; j < p_width; j++) {
|
|
||||||
*(MxU16*) surface = m_16bitPal[*data++];
|
|
||||||
surface += bytesPerPixel;
|
|
||||||
}
|
|
||||||
|
|
||||||
surface += length;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (MxS32 j = 0; j < p_width; j++) {
|
|
||||||
*(MxU32*) surface = m_32bitPal[*data++];
|
|
||||||
surface += bytesPerPixel;
|
|
||||||
}
|
|
||||||
surface += length;
|
|
||||||
}
|
|
||||||
|
|
||||||
data += stride;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ddSurface2->Unlock(ddsd.lpSurface);
|
tempSurface->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100bb1d0
|
// FUNCTION: LEGO1 0x100bb1d0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user