[Scummvm-git-logs] scummvm master -> 33c2631290b76de616ae323f6705e237494eb754
athrxx
noreply at scummvm.org
Fri Jul 15 13:58:21 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
33c2631290 SCUMM: (V2) - improve CGA and Hercules modes
Commit: 33c2631290b76de616ae323f6705e237494eb754
https://github.com/scummvm/scummvm/commit/33c2631290b76de616ae323f6705e237494eb754
Author: athrxx (athrxx at scummvm.org)
Date: 2022-07-15T15:40:16+02:00
Commit Message:
SCUMM: (V2) - improve CGA and Hercules modes
Should be pixel-perfect now.
This change is only about SCUMM2 (ZAK/MM).
Changed paths:
engines/scumm/charset.cpp
engines/scumm/costume.cpp
engines/scumm/gfx.cpp
engines/scumm/gfx.h
engines/scumm/input.cpp
engines/scumm/palette.cpp
engines/scumm/scumm.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index ab505f8c295..73685802489 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -943,8 +943,9 @@ void CharsetRendererV3::drawChar(int chr, Graphics::Surface &s, int x, int y) {
}
void CharsetRenderer::translateColor() {
- // Don't do anything for v1 here.
- if (_vm->_game.version == 1)
+ // Don't do anything for v1 and v2 CGA and Hercules modes
+ // here (and v0 doesn't have any of these modes).
+ if (_vm->_game.version < 3)
return;
// Based on disassembly
diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp
index 44c242a4849..d680720c959 100644
--- a/engines/scumm/costume.cpp
+++ b/engines/scumm/costume.cpp
@@ -1085,6 +1085,8 @@ void ClassicCostumeRenderer::setPalette(uint16 *palette) {
if (_vm->getCurrentLights() & LIGHTMODE_actor_use_colors) {
for (i = 0; i < 16; i++)
_palette[i] = palette[i];
+ if (_vm->_game.version == 2)
+ _palette[12] = (_vm->_renderMode == Common::kRenderCGA || _vm->_renderMode == Common::kRenderHercA || _vm->_renderMode == Common::kRenderHercG) ? 0x0F : 0x0C;
} else {
for (i = 0; i < 16; i++)
_palette[i] = 8;
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 5b38148c6ab..27ea8aa4bec 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -767,9 +767,11 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
_system->copyRectToScreen(blackbuf, 16, 0, 0, 16, 240); // Fix left strip
}
}
- } else if (_game.version == 1) {
- src = postProcessV1Graphics(vs, pitch, x, y, width, height);
+ } else if (_game.version == 1 || _game.version == 2) {
+ // MM/ZAK v1/v2
+ src = postProcessV2Graphics(vs, pitch, x, y, width, height);
} else if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
+ // MI1
ditherHerc(_compositeBuf, _hercCGAScaleBuf, width, &x, &y, &width, &height);
src = _hercCGAScaleBuf + x + y * kHercWidth;
@@ -784,6 +786,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
width *= m;
height *= m;
} else if (_renderMode == Common::kRenderCGA) {
+ // LOOM, MI1
ditherCGA(_compositeBuf, width, x, y, width, height);
}
}
@@ -792,28 +795,30 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
_system->copyRectToScreen(src, pitch, x, y, width, height);
}
-const byte *ScummEngine::postProcessV1Graphics(VirtScreen *vs, int &pitch, int &x, int &y, int &width, int &height) const {
- static const byte zakVrbColMap[] = { 0x0, 0x5, 0x5, 0x5, 0xA, 0xA, 0xA, 0xF, 0xF, 0x5, 0x5, 0x5, 0xA, 0xA, 0xF, 0xF };
- static const byte zakTxtColMap[] = { 0x0, 0xF, 0xA, 0x5, 0xA, 0x5, 0x5, 0xF, 0xA, 0xA, 0xA, 0xA, 0xA, 0x5, 0x5, 0xF };
- static const byte mmVrbColMap[] = { 0x0, 0x5, 0x5, 0x5, 0xA, 0xA, 0xA, 0xF, 0xA, 0x5, 0x5, 0x5, 0xA, 0xA, 0xA, 0xF };
+const byte *ScummEngine::postProcessV2Graphics(VirtScreen *vs, int &pitch, int &x, int &y, int &width, int &height) const {
+ static const byte v2VrbColMap[] = { 0x0, 0x5, 0x5, 0x5, 0xA, 0xA, 0xA, 0xF, 0xF, 0x5, 0x5, 0x5, 0xA, 0xA, 0xF, 0xF };
+ static const byte v2TxtColMap[] = { 0x0, 0xF, 0xA, 0x5, 0xA, 0x5, 0x5, 0xF, 0xA, 0xA, 0xA, 0xA, 0xA, 0x5, 0x5, 0xF };
+ static const byte mmv1VrbColMap[] = { 0x0, 0x5, 0x5, 0x5, 0xA, 0xA, 0xA, 0xF, 0xA, 0x5, 0x5, 0x5, 0xA, 0xA, 0xA, 0xF };
+ static const byte v2MainColMap[] = { 0x0, 0x4, 0x1, 0x5, 0x8, 0xA, 0x2, 0xF, 0xC, 0x7, 0xD, 0x5, 0xE, 0xB, 0xD, 0xF };
- byte mmTxtColMap[16];
- for (uint8 i = 0; i < ARRAYSIZE(mmTxtColMap); ++i)
- mmTxtColMap[i] = mmVrbColMap[_gdi->remapColorToRenderMode(i)];
+ byte tmpTxtColMap[16];
+ for (uint8 i = 0; i < ARRAYSIZE(tmpTxtColMap); ++i)
+ tmpTxtColMap[i] = mmv1VrbColMap[_gdi->remapColorToRenderMode(i)];
byte *res = _compositeBuf;
byte *dst = _compositeBuf;
const byte *src = res;
bool renderHerc = (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG);
-
- const byte *colMap = (_game.id == GID_ZAK) ? ((vs->number == kVerbVirtScreen || renderHerc) ? zakVrbColMap : zakTxtColMap) : (vs->number == kVerbVirtScreen ? mmVrbColMap : mmTxtColMap);
+ const byte *colMap = (_game.id == GID_ZAK || _game.version == 2) ? ((vs->number == kVerbVirtScreen || renderHerc) ? v2VrbColMap : v2TxtColMap) : (vs->number == kVerbVirtScreen ? mmv1VrbColMap : tmpTxtColMap);
if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderCGAComp) {
if (vs->number == kMainVirtScreen) {
for (int h = height; h; --h) {
for (int w = width >> 1; w; --w) {
- *dst++ = (*src++ >> 2) & 3;
- *dst++ = *src++ & 3;
+ byte c = (_game.version == 1) ? *src : (v2MainColMap[src[0]] & 0x0C) | (v2MainColMap[src[1]] & 0x03);
+ *dst++ = (c >> 2) & 3;
+ *dst++ = c & 3;
+ src += 2;
}
}
} else {
@@ -851,10 +856,11 @@ const byte *ScummEngine::postProcessV1Graphics(VirtScreen *vs, int &pitch, int &
for (int h = height2; h; --h) {
for (int w = width >> 1; w; --w) {
const uint32 *s = (const uint32*)dst;
- *dst++ = (*src >> 3) & 1;
- *dst++ = (*src >> 2) & 1;
- *dst++ = (*src >> 1) & 1;
- *dst++ = *src & 1;
+ byte c = (_game.version == 1) ? *src : (v2MainColMap[src[0]] & 0x0C) | (v2MainColMap[src[1]] & 0x03);
+ *dst++ = (c >> 3) & 1;
+ *dst++ = (c >> 2) & 1;
+ *dst++ = (c >> 1) & 1;
+ *dst++ = c & 1;
*dst2++ = renderHerc ? 0 : *s;
src += 2;
}
@@ -899,11 +905,13 @@ const byte *ScummEngine::postProcessV1Graphics(VirtScreen *vs, int &pitch, int &
height <<= 1;
}
- } else if (vs->number == kTextVirtScreen) {
+ } else if (_game.version == 1 && vs->number == kTextVirtScreen) {
// For EGA, the only colors that need remapping are for the kTextVirtScreen.
+ for (uint8 i = 0; i < ARRAYSIZE(tmpTxtColMap); ++i)
+ tmpTxtColMap[i] = _gdi->remapColorToRenderMode(i);
for (int h = height; h; --h) {
for (int w = width; w; --w)
- *dst++ = _gdi->remapColorToRenderMode(*src++);
+ *dst++ = tmpTxtColMap[*src++];
}
}
@@ -933,11 +941,7 @@ void ScummEngine::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, in
// But apparently there is a mistake for 10th color.
for (int y1 = 0; y1 < height; y1++) {
ptr = dst + y1 * dstPitch;
-
- if (_game.version <= 2)
- idx1 = 0;
- else
- idx1 = (y + y1) % 2;
+ idx1 = (y + y1) % 2;
for (int x1 = 0; x1 < width; x1++) {
idx2 = (x + x1) % 2;
diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h
index 79e92564f95..7bb1dbd5b84 100644
--- a/engines/scumm/gfx.h
+++ b/engines/scumm/gfx.h
@@ -407,7 +407,7 @@ protected:
byte maskMap[4096], maskChar[4096];
} _V1;
- const byte *_colorMap;
+ const byte *_colorMap = 0;
protected:
void decodeV1Gfx(const byte *src, byte *dst, int size) const;
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index e4d65b4572d..c7e8ad047cd 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -199,16 +199,17 @@ void ScummEngine::parseEvent(Common::Event event) {
if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
_mouse.x -= (kHercWidth - _screenWidth * 2) / 2;
_mouse.x >>= 1;
- if (_game.version == 1) {
+ if (_game.version < 3) {
+ // MM/ZAK v1/v2
if (_mouse.y >= _virtscr[kMainVirtScreen].topline)
_mouse.y = _mouse.y / 2 + _virtscr[kMainVirtScreen].topline / 2;
if (_mouse.y > _virtscr[kVerbVirtScreen].topline)
_mouse.y += (_mouse.y - _virtscr[kVerbVirtScreen].topline);
-
} else {
+ // MI1
_mouse.y = _mouse.y * 4 / 7;
}
-
+
} else if (_macScreen || (_useCJKMode && _textSurfaceMultiplier == 2) || _renderMode == Common::kRenderCGA_BW) {
_mouse.x >>= 1;
_mouse.y >>= 1;
diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp
index ed0edf2bbdd..a0ff7d86533 100644
--- a/engines/scumm/palette.cpp
+++ b/engines/scumm/palette.cpp
@@ -191,7 +191,19 @@ void ScummEngine::resetPalette() {
int cgaPalIndex = 1;
int cgaPalIntensity = 1;
- if (_game.version <= 1) {
+ if (_renderMode == Common::kRenderHercA) {
+ setPaletteFromTable(tableHercAPalette, sizeof(tableHercAPalette) / 3);
+ } else if (_renderMode == Common::kRenderHercG) {
+ setPaletteFromTable(tableHercGPalette, sizeof(tableHercGPalette) / 3);
+ } else if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderCGAComp) {
+ setPaletteFromTable(_cgaColors[cgaPalIndex * 2 + cgaPalIntensity], sizeof(_cgaColors[0]) / 3);
+ // Cursor palette
+ if (_game.version >= 3) {
+ setPalColor( 7, 170, 170, 170);
+ setPalColor( 8, 85, 85, 85);
+ setPalColor(15, 255, 255, 255);
+ }
+ } else if (_game.version <= 1) {
if (_game.platform == Common::kPlatformApple2GS) {
setPaletteFromTable(tableApple2gsPalette, sizeof(tableApple2gsPalette) / 3);
} else if (_game.platform == Common::kPlatformC64) {
@@ -201,21 +213,13 @@ void ScummEngine::resetPalette() {
setPaletteFromTable(tableNESClassicPalette, sizeof(tableNESClassicPalette) / 3);
else
setPaletteFromTable(tableNESNTSCPalette, sizeof(tableNESNTSCPalette) / 3);
- } else if (_renderMode == Common::kRenderHercA) {
- setPaletteFromTable(tableHercAPalette, sizeof(tableHercAPalette) / 3);
- } else if (_renderMode == Common::kRenderHercG) {
- setPaletteFromTable(tableHercGPalette, sizeof(tableHercGPalette) / 3);
- } else if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderCGAComp) {
- setPaletteFromTable(_cgaColors[cgaPalIndex * 2 + cgaPalIntensity], sizeof(_cgaColors[0]) / 3);
- } else if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderCGA_BW) {
+ } else if (_renderMode == Common::kRenderCGA_BW) {
setPalColor(0, 0x00, 0x00, 0x00);
setPalColor(1, 0xff, 0xff, 0xff);
} else {
setPaletteFromTable(tableEGAPalette, sizeof(tableEGAPalette) / 3);
}
} else if (_game.features & GF_16COLOR) {
- bool setupCursor = false;
-
switch (_renderMode) {
case Common::kRenderEGA:
case Common::kRenderMacintoshBW:
@@ -229,21 +233,6 @@ void ScummEngine::resetPalette() {
setPaletteFromTable(tableAmigaPalette, sizeof(tableAmigaPalette) / 3);
break;
- case Common::kRenderCGA:
- setPaletteFromTable(_cgaColors[cgaPalIndex * 2 + cgaPalIntensity], sizeof(_cgaColors[0]) / 3);
- setupCursor = true;
- break;
-
- case Common::kRenderHercA:
- setPaletteFromTable(tableHercAPalette, sizeof(tableHercAPalette) / 3);
- setupCursor = true;
- break;
-
- case Common::kRenderHercG:
- setPaletteFromTable(tableHercGPalette, sizeof(tableHercGPalette) / 3);
- setupCursor = true;
- break;
-
default:
if ((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST))
setPaletteFromTable(tableAmigaPalette, sizeof(tableAmigaPalette) / 3);
@@ -252,12 +241,6 @@ void ScummEngine::resetPalette() {
else
setPaletteFromTable(tableEGAPalette, sizeof(tableEGAPalette) / 3);
}
- if (setupCursor) {
- // Setup cursor palette
- setPalColor( 7, 170, 170, 170);
- setPalColor( 8, 85, 85, 85);
- setPalColor(15, 255, 255, 255);
- }
} else {
if ((_game.platform == Common::kPlatformAmiga) && _game.version == 4) {
@@ -467,7 +450,7 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) {
setDirtyColors(0, 255);
}
-void ScummEngine::updateColorTableV1(int renderMode) {
+void ScummEngine::setV1ColorTable(int renderMode) {
static const byte v1ColorMaps[5][16] = {
// C-64: Just leave everything the way it is
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F },
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 0eb268a82d2..0cd105a6454 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -327,7 +327,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
else if (_renderMode == Common::kRenderCGA_BW)
_hercCGAScaleBuf = (byte *)malloc(_screenWidth * 2 * _screenHeight * 2);
- updateColorTableV1(_renderMode);
+ setV1ColorTable(_renderMode);
_isRTL = (_language == Common::HE_ISR && _game.heversion == 0)
&& (_game.id == GID_MANIAC || (_game.version >= 4 && _game.version < 7));
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 09c4aa09172..3bc449b4531 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -1025,7 +1025,7 @@ protected:
void setPCEPaletteFromPtr(const byte *ptr);
void setAmigaPaletteFromPtr(const byte *ptr);
virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
- void updateColorTableV1(int renderMode);
+ void setV1ColorTable(int renderMode);
virtual void setPalColor(int index, int r, int g, int b);
void setDirtyColors(int min, int max);
@@ -1071,7 +1071,7 @@ protected:
void mac_undrawIndy3TextBox();
void mac_undrawIndy3CreditsText();
- const byte *postProcessV1Graphics(VirtScreen *vs, int &pitch, int &x, int &y, int &width, int &height) const;
+ const byte *postProcessV2Graphics(VirtScreen *vs, int &pitch, int &x, int &y, int &width, int &height) const;
void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const;
public:
More information about the Scummvm-git-logs
mailing list