mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-22 19:41:04 -04:00
Align FakeMosaicTransition with MosaicTransition (#545)
The palette is a bit off but I have no strong urge to fix it
This commit is contained in:
parent
b82cfc4b36
commit
c6b94dabcf
@ -701,22 +701,28 @@ void MxTransitionManager::FakeMosaicTransition()
|
||||
EndTransition(TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
else {
|
||||
if (m_animationTimer == 0) {
|
||||
g_colorOffset = SDL_rand(32);
|
||||
for (MxS32 i = 0; i < 64; i++) {
|
||||
|
||||
// Same init/shuffle steps as the dissolve transition, except that
|
||||
// we are using big blocky pixels and only need 64 columns.
|
||||
MxS32 i;
|
||||
for (i = 0; i < 64; i++) {
|
||||
m_columnOrder[i] = i;
|
||||
}
|
||||
for (MxS32 i = 0; i < 64; i++) {
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
MxS32 swap = SDL_rand(64);
|
||||
std::swap(m_columnOrder[i], m_columnOrder[swap]);
|
||||
}
|
||||
for (MxS32 i = 0; i < 48; i++) {
|
||||
m_randomShift[i] = SDL_rand(64);
|
||||
}
|
||||
MxU16 t = m_columnOrder[i];
|
||||
m_columnOrder[i] = m_columnOrder[swap];
|
||||
m_columnOrder[swap] = t;
|
||||
}
|
||||
|
||||
if (!g_fakeTranstionSurface) {
|
||||
// The same is true here. We only need 48 rows.
|
||||
for (i = 0; i < 48; i++) {
|
||||
m_randomShift[i] = SDL_rand(64);
|
||||
}
|
||||
DDSURFACEDESC mainDesc = {};
|
||||
mainDesc.dwSize = sizeof(mainDesc);
|
||||
if (m_ddSurface->GetSurfaceDesc(&mainDesc) != DD_OK) {
|
||||
@ -731,14 +737,35 @@ void MxTransitionManager::FakeMosaicTransition()
|
||||
tempDesc.ddpfPixelFormat = mainDesc.ddpfPixelFormat;
|
||||
tempDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
|
||||
HRESULT hr = MVideoManager()->GetDirectDraw()->CreateSurface(&tempDesc, &g_fakeTranstionSurface, nullptr);
|
||||
if (hr != DD_OK || !g_fakeTranstionSurface) {
|
||||
if (MVideoManager()->GetDirectDraw()->CreateSurface(&tempDesc, &g_fakeTranstionSurface, nullptr) != DD_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD fillColor = 0x00000000;
|
||||
switch (mainDesc.ddpfPixelFormat.dwRGBBitCount) {
|
||||
case 8:
|
||||
fillColor = 0x10;
|
||||
break;
|
||||
case 16:
|
||||
fillColor = RGB555_CREATE(0x1f, 0, 0x1f);
|
||||
break;
|
||||
}
|
||||
|
||||
DDSURFACEDESC ddsd = {};
|
||||
DDBLTFX bltFx = {};
|
||||
bltFx.dwSize = sizeof(bltFx);
|
||||
bltFx.dwFillColor = fillColor;
|
||||
g_fakeTranstionSurface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltFx);
|
||||
|
||||
DDCOLORKEY key = {};
|
||||
key.dwColorSpaceLowValue = key.dwColorSpaceHighValue = fillColor;
|
||||
g_fakeTranstionSurface->SetColorKey(DDCKEY_SRCBLT, &key);
|
||||
}
|
||||
|
||||
// Run one tick of the animation
|
||||
DDSURFACEDESC ddsd;
|
||||
memset(&ddsd, 0, sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
|
||||
HRESULT res = g_fakeTranstionSurface->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
|
||||
if (res == DDERR_SURFACELOST) {
|
||||
g_fakeTranstionSurface->Restore();
|
||||
@ -761,21 +788,21 @@ void MxTransitionManager::FakeMosaicTransition()
|
||||
MxS32 bytesPerPixel = ddsd.ddpfPixelFormat.dwRGBBitCount / 8;
|
||||
|
||||
for (MxS32 col = 0; col < 64; col++) {
|
||||
// Select 4 columns on each tick
|
||||
if (m_animationTimer * 4 > m_columnOrder[col]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_animationTimer * 4 + 3 < m_columnOrder[col]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (MxS32 row = 0; row < 48; row++) {
|
||||
int paletteIndex = GetColorIndexWithLocality(col, row);
|
||||
MxS32 x = (m_randomShift[row] + col) % 64;
|
||||
MxU8* dest = (MxU8*) ddsd.lpSurface + row * ddsd.lPitch + x * bytesPerPixel;
|
||||
|
||||
const MxU8 paletteIndex = GetColorIndexWithLocality(col, row);
|
||||
const MxU8* color = g_palette[paletteIndex];
|
||||
|
||||
MxS32 xShift = (m_randomShift[row] + col) % 64;
|
||||
MxU8* dest = (MxU8*) ddsd.lpSurface + row * ddsd.lPitch + xShift * bytesPerPixel;
|
||||
|
||||
switch (bytesPerPixel) {
|
||||
case 1:
|
||||
*dest = paletteIndex;
|
||||
@ -794,8 +821,9 @@ void MxTransitionManager::FakeMosaicTransition()
|
||||
g_fakeTranstionSurface->Unlock(ddsd.lpSurface);
|
||||
|
||||
RECT srcRect = {0, 0, 64, 48};
|
||||
m_ddSurface->Blt(&g_fullScreenRect, g_fakeTranstionSurface, &srcRect, DDBLT_WAIT, NULL);
|
||||
}
|
||||
m_ddSurface->Blt(&g_fullScreenRect, g_fakeTranstionSurface, &srcRect, DDBLT_WAIT | DDBLT_KEYSRC, NULL);
|
||||
|
||||
m_animationTimer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user