[Scummvm-git-logs] scummvm master -> ff8b1513ba0db69d03115e78f0888bafb4d08121
neuromancer
noreply at scummvm.org
Thu Jan 5 00:58:22 UTC 2023
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:
ff8b1513ba FREESCAPE: improved handling of colors in Driller for CPC
Commit: ff8b1513ba0db69d03115e78f0888bafb4d08121
https://github.com/scummvm/scummvm/commit/ff8b1513ba0db69d03115e78f0888bafb4d08121
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-01-04T21:54:20-03:00
Commit Message:
FREESCAPE: improved handling of colors in Driller for CPC
Changed paths:
engines/freescape/games/driller.cpp
engines/freescape/games/palettes.cpp
engines/freescape/gfx.cpp
engines/freescape/gfx.h
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index 6d3f8ceeaea..7f4ede551a5 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -734,7 +734,7 @@ void DrillerEngine::drawCPCUI(Graphics::Surface *surface) {
uint32 color = 1;
uint8 r, g, b;
- _gfx->readFromPalette(color, r, g, b);
+ _gfx->selectColorFromCPCPalette(color, r, g, b);
uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
color = 0;
diff --git a/engines/freescape/games/palettes.cpp b/engines/freescape/games/palettes.cpp
index c04ffdbc946..1c586f9c2ce 100644
--- a/engines/freescape/games/palettes.cpp
+++ b/engines/freescape/games/palettes.cpp
@@ -73,34 +73,39 @@ byte kDrillerZXPalette[9][3] = {
{0x00, 0x00, 0x00},
};
-byte kDrillerCPCPalette[27][3] = {
- {0x00, 0x00, 0x00},
- {0x00, 0x00, 0x80},
- {0x00, 0x00, 0xff},
- {0x80, 0x00, 0x00},
- {0x80, 0x00, 0x80},
- {0x80, 0x00, 0xff},
- {0xff, 0x00, 0x00},
- {0xff, 0x00, 0x80},
- {0xff, 0x00, 0xff},
- {0x00, 0x80, 0x00},
- {0x00, 0x80, 0x80},
- {0x00, 0x88, 0xff},
- {0x80, 0x80, 0x00},
- {0x80, 0x80, 0x80},
- {0x80, 0x80, 0xff},
- {0xff, 0x80, 0x00},
- {0xff, 0x80, 0x80},
- {0xff, 0x80, 0xff},
- {0x00, 0xff, 0x00},
- {0x00, 0xff, 0x80},
- {0x00, 0xff, 0xff},
- {0x80, 0xff, 0x00},
- {0x80, 0xff, 0x80},
- {0x80, 0xff, 0xff},
- {0xff, 0xff, 0x00},
- {0xff, 0xff, 0x80},
- {0xff, 0xff, 0xff},
+byte kDrillerCPCPalette[32][3] = {
+ {0x00, 0x00, 0x00}, // 0: special case?
+ {0x11, 0x22, 0x33},
+ {0x80, 0xff, 0x80}, // 2
+ {0xff, 0xff, 0x80}, // 3
+ {0x11, 0x22, 0x33},
+ {0xff, 0x00, 0x80}, // 5
+ {0x00, 0xff, 0x80}, // 6
+ {0xff, 0x80, 0x80}, // 7
+ {0x11, 0x22, 0x33},
+ {0x11, 0x22, 0x33},
+ {0xff, 0xff, 0x00}, // 10
+ {0xff, 0xff, 0xff}, // 11
+ {0xff, 0x00, 0x00}, // 12
+ {0x11, 0x22, 0x33},
+ {0xff, 0x80, 0x00}, // 14
+ {0x11, 0x22, 0x33},
+ {0x11, 0x22, 0x33},
+ {0x00, 0xff, 0x80}, // 17
+ {0x00, 0xff, 0x00}, // 18
+ {0x80, 0xff, 0xff}, // 19
+ {0x11, 0x22, 0x33},
+ {0x00, 0x00, 0xff}, // 21
+ {0x00, 0x80, 0x00}, // 22
+ {0x00, 0x80, 0xff}, // 23
+ {0x80, 0x00, 0x80}, // 24
+ {0x11, 0x22, 0x33},
+ {0x11, 0x22, 0x33},
+ {0x00, 0xff, 0xff}, // 27
+ {0x80, 0x00, 0x00}, // 28
+ {0x11, 0x22, 0x33},
+ {0x11, 0x22, 0x33},
+ {0x80, 0x80, 0xff}, // 31
};
byte kDrillerCPCPalette1[27][3] = {
@@ -118,7 +123,7 @@ void FreescapeEngine::loadColorPalette() {
} else if (_renderMode == Common::kRenderZX) {
_gfx->_palette = (byte *)kDrillerZXPalette;
} else if (_renderMode == Common::kRenderCPC) {
- _gfx->_palette = (byte *)kDrillerCPCPalette1;
+ _gfx->_palette = (byte *)kDrillerCPCPalette;
} else if (_renderMode == Common::kRenderCGA) {
_gfx->_palette = nullptr; // palette depends on the area
} else if (_renderMode == Common::kRenderAmiga || _renderMode == Common::kRenderAtariST) {
@@ -160,9 +165,10 @@ void FreescapeEngine::loadPalettes(Common::SeekableReadStream *file, int offset)
void FreescapeEngine::swapPalette(uint16 levelID) {
if (isAmiga() || isAtariST())
_gfx->_palette = _paletteByArea[levelID];
- else if (isSpectrum()) {
+ else if (isSpectrum() || isCPC()) {
_gfx->_inkColor = _areaMap[levelID]->_inkColor;
_gfx->_paperColor = _areaMap[levelID]->_paperColor;
+ _gfx->_underFireBackgroundColor = _areaMap[levelID]->_underFireBackgroundColor;
} else if (isDOS() && _renderMode == Common::kRenderCGA) {
assert(_borderCGAByArea.contains(levelID));
assert(_paletteCGAByArea.contains(levelID));
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index c271c80daf3..14580f0871c 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -42,6 +42,7 @@ Renderer::Renderer(int screenW, int screenH, Common::RenderMode renderMode) {
_keyColor = -1;
_inkColor = -1;
_paperColor = -1;
+ _underFireBackgroundColor = -1;
_palette = nullptr;
_colorMap = nullptr;
_colorRemaps = nullptr;
@@ -134,71 +135,78 @@ bool Renderer::getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r
return true;
}
-void extractIndexes(byte cm1, byte cm2, uint8 &i1, uint8 &i2) {
- if (cm1 == 0xb4)
+void Renderer::extractCPCIndexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2) {
+ if (cm1 == 0xb4 && cm2 == 0xe1) {
i1 = 1;
- else if (cm1 == 0xb0)
+ i2 = 2;
+ } else if (cm1 == 0xb0 && cm2 == 0xe0) {
i1 = 1;
- else if (cm1 == 0x05)
+ i2 = 0;
+ } else if (cm1 == 0x05 && cm2 == 0x0a) {
i1 = 2;
- else if (cm1 == 0x50)
+ i2 = 0;
+ } else if (cm1 == 0x50 && cm2 == 0xa0) {
i1 = 1;
- else if (cm1 == 0x55)
+ i2 = 0;
+ } else if (cm1 == 0x55 && cm2 == 0xaa) {
i1 = 3;
- else if (cm1 == 0xf5)
+ i2 = 0;
+ } else if (cm1 == 0xf5 && cm2 == 0xfa) {
i1 = 3;
- else if (cm1 == 0x5a)
+ i2 = 1;
+ } else if (cm1 == 0x5a && cm2 == 0xa5) {
i1 = 1;
- else if (cm1 == 0xbb)
- i1 = 3;
- else
- error("%x %x", cm1, cm2);
-
- if (cm2 == 0xe1)
i2 = 2;
- else if (cm2 == 0x0a)
- i2 = 0;
- else if (cm2 == 0xaa)
- i2 = 0;
- else if (cm2 == 0xa0)
- i2 = 0;
- else if (cm2 == 0x00)
+ } else if (cm1 == 0xbb && cm2 == 0xee) {
+ i1 = 3;
i2 = 0;
- else if (cm2 == 0xfa)
- i2 = 1;
- else if (cm2 == 0xa5)
+ } else if (cm1 == 0x5f && cm2 == 0xaf) {
+ i1 = 3;
i2 = 2;
- else if (cm2 == 0xee)
- i2 = 0;
- else if (cm2 == 0xe0)
+ } else if (cm1 == 0xfb && cm2 == 0xfe) { // TODO
+ i1 = 0;
i2 = 0;
- else
+ } else
error("%x %x", cm1, cm2);
}
+void Renderer::selectColorFromCPCPalette(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1) {
+ if (index == 0) {
+ r1 = 0;
+ g1 = 0;
+ b1 = 0;
+ } else if (index == 1) {
+ readFromPalette(_underFireBackgroundColor, r1, g1, b1);
+ } else if (index == 2) {
+ readFromPalette(_paperColor, r1, g1, b1);
+ } else if (index == 3) {
+ readFromPalette(_inkColor, r1, g1, b1);
+ } else
+ error("Invalid color");
+}
+
bool Renderer::getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2) {
if (index == _keyColor)
return false;
assert (_renderMode == Common::kRenderCPC);
if (index <= 4) { // Solid colors
- readFromPalette(index - 1, r1, g1, b1);
+ selectColorFromCPCPalette(index - 1, r1, g1, b1);
r2 = r1;
g2 = g1;
b2 = b1;
return true;
}
+ uint8 i1, i2;
byte *entry = (*_colorMap)[index - 1];
- byte cm1 = *(entry);
+ uint8 cm1 = *(entry);
entry++;
- byte cm2 = *(entry);
+ uint8 cm2 = *(entry);
- uint8 i1;
- uint8 i2;
- extractIndexes(cm1, cm2, i1, i2);
- readFromPalette(i1, r1, g1, b1);
- readFromPalette(i2, r2, g2, b2);
+ extractCPCIndexes(cm1, cm2, i1, i2);
+ selectColorFromCPCPalette(i1, r1, g1, b1);
+ selectColorFromCPCPalette(i2, r2, g2, b2);
return true;
}
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 9d7ca6c378b..3d43afc9094 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -104,6 +104,8 @@ public:
bool getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2);
bool getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2);
bool getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *stipple);
+ void extractCPCIndexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2);
+ void selectColorFromCPCPalette(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1);
virtual void setStippleData(byte *data) {};
virtual void useStipple(bool enabled) {};
@@ -113,6 +115,7 @@ public:
int _keyColor;
int _inkColor;
int _paperColor;
+ int _underFireBackgroundColor;
/**
* Select the window where to render
More information about the Scummvm-git-logs
mailing list