[Scummvm-git-logs] scummvm master -> 047d525f137e014eb55569050127323e0b2cbb9c

neuromancer noreply at scummvm.org
Tue Mar 7 20:27:18 UTC 2023


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1c96737ae1 FREESCAPE: enable some spfx effects for different platforms (zx, cpc)
3c9cbb3fe0 FREESCAPE: use managed surfaces for border and title images
22fcff4ece FREESCAPE: allow to change the palette of title and border per level using managed surfaces
23a594af6c FREESCAPE: load original images and adjust ui for driller cpc
047d525f13 FREESCAPE: load correct border palette for certain driller releases


Commit: 1c96737ae10cb9cb19a655ac91db9adaa6ab7202
    https://github.com/scummvm/scummvm/commit/1c96737ae10cb9cb19a655ac91db9adaa6ab7202
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-03-07T21:27:45+01:00

Commit Message:
FREESCAPE: enable some spfx effects for different platforms (zx, cpc)

Changed paths:
    engines/freescape/language/instruction.cpp


diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 3389ca99493..2f68554d9cb 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -249,7 +249,7 @@ void FreescapeEngine::executeSPFX(FCLInstruction &instruction) {
 		debugC(1, kFreescapeDebugCode, "Switching complete palette to color %d", dst);
 		for (int i = 1; i < 16; i++)
 			_currentArea->remapColor(i, color);
-	} else if (isDOS()) {
+	} else {
 		debugC(1, kFreescapeDebugCode, "Switching palette from position %d to %d", src, dst);
 		if (src == 0 && dst == 1)
 			_currentArea->remapColor(_currentArea->_usualBackgroundColor, _renderMode == Common::kRenderCGA ? 1 : _currentArea->_underFireBackgroundColor);


Commit: 3c9cbb3fe02c620f583dd26ace45eb8e8093cc21
    https://github.com/scummvm/scummvm/commit/3c9cbb3fe02c620f583dd26ace45eb8e8093cc21
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-03-07T21:27:45+01:00

Commit Message:
FREESCAPE: use managed surfaces for border and title images

Changed paths:
    engines/freescape/freescape.cpp
    engines/freescape/freescape.h
    engines/freescape/games/driller/dos.cpp
    engines/freescape/gfx.cpp
    engines/freescape/gfx.h
    engines/freescape/loaders/8bitBinaryLoader.cpp


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 1a8728e8a65..d989f6fe573 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -194,7 +194,7 @@ void FreescapeEngine::drawBorder() {
 void FreescapeEngine::drawTitle() {
 	_gfx->setViewport(_fullscreenViewArea);
 	if (isSpectrum()) {
-		Graphics::Surface *title = new Graphics::Surface();
+		Graphics::ManagedSurface *title = new Graphics::ManagedSurface();
 		title->create(320, 200, _title->format);
 		title->copyRectToSurface(*_title, (320 - _title->w) / 2, (200 - _title->h) / 2, Common::Rect(_title->w, _title->h));
 		_title->free();
@@ -202,7 +202,7 @@ void FreescapeEngine::drawTitle() {
 		_title = title;
 	}
 	if (!_titleTexture)
-		_titleTexture = _gfx->createTexture(_title);
+		_titleTexture = _gfx->createTexture(&_title->rawSurface());
 	_gfx->drawTexturedRect2D(_fullscreenViewArea, _fullscreenViewArea, _titleTexture);
 	_gfx->setViewport(_viewArea);
 }
@@ -598,7 +598,7 @@ void FreescapeEngine::borderScreen() {}
 
 void FreescapeEngine::loadBorder() {
 	if (_border)
-		_borderTexture = _gfx->createTexture(_border);
+		_borderTexture = _gfx->createTexture(&_border->rawSurface());
 }
 
 void FreescapeEngine::processBorder() {
@@ -618,7 +618,7 @@ void FreescapeEngine::processBorder() {
 					_border->setPixel(i, j, transparent);
 			}
 		}
-		_borderTexture = _gfx->createTexture(_border);
+		_borderTexture = _gfx->createTexture(&_border->rawSurface());
 	}
 }
 
@@ -850,20 +850,20 @@ byte *FreescapeEngine::getPaletteFromNeoImage(Common::SeekableReadStream *stream
 	return palette;
 }
 
-Graphics::Surface *FreescapeEngine::loadAndConvertNeoImage(Common::SeekableReadStream *stream, int offset, byte *palette) {
+Graphics::ManagedSurface *FreescapeEngine::loadAndConvertNeoImage(Common::SeekableReadStream *stream, int offset, byte *palette) {
 	stream->seek(offset);
 	NeoDecoder decoder(palette);
 	decoder.loadStream(*stream);
-	Graphics::Surface *surface = new Graphics::Surface();
+	Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
 	surface->copyFrom(*decoder.getSurface());
 	surface->convertToInPlace(_gfx->_currentPixelFormat, decoder.getPalette());
 	return surface;
 }
 
-Graphics::Surface *FreescapeEngine::loadAndCenterScrImage(Common::SeekableReadStream *stream) {
+Graphics::ManagedSurface *FreescapeEngine::loadAndCenterScrImage(Common::SeekableReadStream *stream) {
 	ScrDecoder decoder;
 	decoder.loadStream(*stream);
-	Graphics::Surface *surface = new Graphics::Surface();
+	Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
 	const Graphics::Surface *decoded = decoder.getSurface();
 	surface->create(320, 200, decoded->format);
 	surface->copyRectToSurface(*decoded, (320 - decoded->w) / 2, (200 - decoded->h) / 2, Common::Rect(decoded->w, decoded->h));
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 94521c68e43..1b21c8edcc4 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -25,6 +25,7 @@
 #include "common/bitarray.h"
 #include "common/events.h"
 #include "engines/advancedDetector.h"
+#include "graphics/managed_surface.h"
 #include "graphics/surface.h"
 
 #include "audio/decoders/wave.h"
@@ -124,8 +125,8 @@ public:
 	virtual void drawInfoMenu();
 
 	virtual void drawCrossair(Graphics::Surface *surface);
-	Graphics::Surface *_border;
-	Graphics::Surface *_title;
+	Graphics::ManagedSurface *_border;
+	Graphics::ManagedSurface *_title;
 	Texture *_borderTexture;
 	Texture *_titleTexture;
 	Texture *_uiTexture;
@@ -139,8 +140,8 @@ public:
 	void loadDataBundle();
 	void loadBundledImages();
 	byte *getPaletteFromNeoImage(Common::SeekableReadStream *stream, int offset);
-	Graphics::Surface *loadAndConvertNeoImage(Common::SeekableReadStream *stream, int offset, byte *palette = nullptr);
-	Graphics::Surface *loadAndCenterScrImage(Common::SeekableReadStream *stream);
+	Graphics::ManagedSurface *loadAndConvertNeoImage(Common::SeekableReadStream *stream, int offset, byte *palette = nullptr);
+	Graphics::ManagedSurface *loadAndCenterScrImage(Common::SeekableReadStream *stream);
 	void loadPalettes(Common::SeekableReadStream *file, int offset);
 	void swapPalette(uint16 areaID);
 	Common::HashMap<uint16, byte *> _paletteByArea;
@@ -165,12 +166,12 @@ public:
 	void load8bitBinary(Common::SeekableReadStream *file, int offset, int ncolors);
 	Area *load8bitArea(Common::SeekableReadStream *file, uint16 ncolors);
 	Object *load8bitObject(Common::SeekableReadStream *file);
-	void renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color);
+	void renderPixels8bitBinImage(Graphics::ManagedSurface *surface, int &i, int &j, uint8 pixels, int color);
 
-	void renderPixels8bitBinCGAImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color);
-	void renderPixels8bitBinEGAImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color);
+	void renderPixels8bitBinCGAImage(Graphics::ManagedSurface *surface, int &i, int &j, uint8 pixels, int color);
+	void renderPixels8bitBinEGAImage(Graphics::ManagedSurface *surface, int &i, int &j, uint8 pixels, int color);
 
-	Graphics::Surface *load8bitBinImage(Common::SeekableReadStream *file, int offset);
+	Graphics::ManagedSurface *load8bitBinImage(Common::SeekableReadStream *file, int offset);
 
 	// Areas
 	uint16 _startArea;
@@ -460,9 +461,9 @@ private:
 	void drawC64UI(Graphics::Surface *surface);
 	void drawAmigaAtariSTUI(Graphics::Surface *surface);
 
-	Graphics::Surface *load8bitTitleImage(Common::SeekableReadStream *file, int offset);
+	Graphics::ManagedSurface *load8bitTitleImage(Common::SeekableReadStream *file, int offset);
 	uint32 getPixel8bitTitleImage(int index);
-	void renderPixels8bitTitleImage(Graphics::Surface *surface, int &i, int &j, int pixels);
+	void renderPixels8bitTitleImage(Graphics::ManagedSurface *surface, int &i, int &j, int pixels);
 };
 
 class DarkEngine : public FreescapeEngine {
diff --git a/engines/freescape/games/driller/dos.cpp b/engines/freescape/games/driller/dos.cpp
index bb3f0b52d32..ee38b0a6b13 100644
--- a/engines/freescape/games/driller/dos.cpp
+++ b/engines/freescape/games/driller/dos.cpp
@@ -35,16 +35,13 @@ extern byte kEGADefaultPaletteData[16][3];
 */
 
 uint32 DrillerEngine::getPixel8bitTitleImage(int index) {
-	uint8 r, g, b;
 	if (index < 4 || _renderMode == Common::kRenderEGA) {
-		_gfx->readFromPalette(index, r, g, b);
-		return _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b);
+		return index;
 	}
-	_gfx->readFromPalette(index / 4, r, g, b);
-	return _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b);
+	return index / 4;
 }
 
-void DrillerEngine::renderPixels8bitTitleImage(Graphics::Surface *surface, int &i, int &j, int pixels) {
+void DrillerEngine::renderPixels8bitTitleImage(Graphics::ManagedSurface *surface, int &i, int &j, int pixels) {
 	int c1 = pixels >> 4;
 	int c2 = pixels & 0xf;
 
@@ -80,17 +77,10 @@ void DrillerEngine::renderPixels8bitTitleImage(Graphics::Surface *surface, int &
 	i++;
 }
 
-Graphics::Surface *DrillerEngine::load8bitTitleImage(Common::SeekableReadStream *file, int offset) {
-	Graphics::Surface *surface = new Graphics::Surface();
-	if (_renderMode == Common::kRenderCGA)
-		_gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
-	else if (_renderMode == Common::kRenderEGA)
-		_gfx->_palette = (byte *)kEGADefaultPaletteData;
-	else
-		error("Invalid render mode: %d", _renderMode);
-	surface->create(_screenW, _screenH, _gfx->_currentPixelFormat);
-	uint32 black = _gfx->_currentPixelFormat.ARGBToColor(0xFF, 0, 0, 0);
-	surface->fillRect(Common::Rect(0, 0, 320, 200), black);
+Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableReadStream *file, int offset) {
+	Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
+	surface->create(_screenW, _screenH, Graphics::PixelFormat::createFormatCLUT8());
+	surface->fillRect(Common::Rect(0, 0, 320, 200), 0);
 
 	int i = 0;
 	int j = 0;
@@ -180,17 +170,45 @@ Graphics::Surface *DrillerEngine::load8bitTitleImage(Common::SeekableReadStream
 	}
 	return surface;
 }
+
+byte kCGAPalettePinkBlueWhiteData[4][3] = {
+	{0x00, 0x00, 0x00},
+	{0x55, 0xff, 0xff},
+	{0xff, 0x55, 0xff},
+	{0xff, 0xff, 0xff},
+};
+
+byte kEGADefaultPaletteData[16][3] = {
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0xaa},
+	{0x00, 0xaa, 0x00},
+	{0xaa, 0x00, 0x00},
+	{0xaa, 0x00, 0xaa},
+	{0xaa, 0x55, 0x00},
+	{0x55, 0xff, 0x55},
+	{0xff, 0x55, 0x55},
+	{0x12, 0x34, 0x56},
+	{0xff, 0xff, 0x55},
+	{0xff, 0xff, 0xff},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00}
+};
+
 void DrillerEngine::loadAssetsDOSFullGame() {
 	Common::File file;
 	if (_renderMode == Common::kRenderEGA) {
 		file.open("SCN1E.DAT");
 		if (file.isOpen()) {
 			_title = load8bitBinImage(&file, 0x0);
+			_title->setPalette((byte*)&kEGADefaultPaletteData, 0, 16);
 		}
 		file.close();
 		file.open("EGATITLE.RL");
 		if (file.isOpen()) {
 			_title = load8bitTitleImage(&file, 0x1b3);
+			_title->setPalette((byte*)&kEGADefaultPaletteData, 0, 16);
 		}
 		file.close();
 
@@ -204,15 +222,18 @@ void DrillerEngine::loadAssetsDOSFullGame() {
 		loadGlobalObjects(&file, 0x3b42);
 		load8bitBinary(&file, 0x9b40, 16);
 		_border = load8bitBinImage(&file, 0x210);
+		_border->setPalette((byte*)&kEGADefaultPaletteData, 0, 16);
 	} else if (_renderMode == Common::kRenderCGA) {
 		file.open("SCN1C.DAT");
 		if (file.isOpen()) {
 			_title = load8bitBinImage(&file, 0x0);
+			_title->setPalette((byte*)&kCGAPalettePinkBlueWhiteData, 0, 4);
 		}
 		file.close();
 		file.open("CGATITLE.RL");
 		if (file.isOpen()) {
 			_title = load8bitTitleImage(&file, 0x1b3);
+			_title->setPalette((byte*)&kCGAPalettePinkBlueWhiteData, 0, 4);
 		}
 		file.close();
 		file.open("DRILLC.EXE");
@@ -225,6 +246,7 @@ void DrillerEngine::loadAssetsDOSFullGame() {
 		load8bitBinary(&file, 0x7bb0, 4);
 		loadGlobalObjects(&file, 0x1fa2);
 		_border = load8bitBinImage(&file, 0x210);
+		_border->setPalette((byte*)&kCGAPalettePinkBlueWhiteData, 0, 4);
 	} else
 		error("Unsupported video mode for DOS");
 }
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index 3fab0026779..aeb830a9119 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -76,7 +76,7 @@ bool Renderer::getRGBAtCGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &
 		return false;
 
 	assert (_renderMode == Common::kRenderCGA);
-	if (index <= 4) { // Solid colors 
+	if (index <= 4) { // Solid colors
 		readFromPalette(index - 1, r1, g1, b1);
 		r2 = r1;
 		g2 = g1;
@@ -164,7 +164,7 @@ bool Renderer::getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r
 		return false;
 
 	byte *entry = (*_colorMap)[index - 1];
-	if (entry[0] == 0 && entry[1] == 0 && entry[2] == 0 && entry[3] == 0) { 
+	if (entry[0] == 0 && entry[1] == 0 && entry[2] == 0 && entry[3] == 0) {
 		readFromPalette(_paperColor, r1, g1, b1);
 		readFromPalette(_paperColor, r2, g2, b2);
 		return true;
@@ -342,12 +342,16 @@ void Renderer::flipVertical(Graphics::Surface *s) {
 	}
 }
 
-void Renderer::convertImageFormatIfNecessary(Graphics::Surface *surface) {
+void Renderer::convertImageFormatIfNecessary(Graphics::ManagedSurface *surface) {
 	if (!surface)
 		return;
 
-	if (surface->format != _texturePixelFormat)
-		surface->convertToInPlace(_texturePixelFormat);
+	if (surface->format != _texturePixelFormat) {
+		byte *palette = (byte *)malloc(sizeof(byte) * 16 * 3);
+		surface->grabPalette(palette, 0, 16); // Maximum should be 16 colours
+		surface->convertToInPlace(_texturePixelFormat, palette);
+		free(palette);
+	}
 }
 
 Common::Rect Renderer::viewport() const {
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index a8b08b5cd66..074ce8be090 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -26,6 +26,7 @@
 #include "common/rect.h"
 
 #include "graphics/pixelformat.h"
+#include "graphics/managed_surface.h"
 #include "graphics/renderer.h"
 #include "math/frustum.h"
 #include "math/vector3d.h"
@@ -76,7 +77,7 @@ public:
 	virtual void polygonOffset(bool enabled) = 0;
 
 	virtual Texture *createTexture(const Graphics::Surface *surface) = 0;
-	void convertImageFormatIfNecessary(Graphics::Surface *surface);
+	void convertImageFormatIfNecessary(Graphics::ManagedSurface *surface);
 
 	virtual void freeTexture(Texture *texture) = 0;
 	virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) = 0;
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index b39cd64c2e3..b62a5e6d28f 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -298,32 +298,7 @@ static const char *eclipseRoomName[] = {
 	"ILLUSION",
 	"????????"};
 
-byte kCGAPalettePinkBlueWhiteData[4][3] = {
-	{0x00, 0x00, 0x00},
-	{0x55, 0xff, 0xff},
-	{0xff, 0x55, 0xff},
-	{0xff, 0xff, 0xff},
-};
-
-byte kEGADefaultPaletteData[16][3] = {
-	{0x00, 0x00, 0x00},
-	{0x00, 0x00, 0xaa},
-	{0x00, 0xaa, 0x00},
-	{0xaa, 0x00, 0x00},
-	{0xaa, 0x00, 0xaa},
-	{0xaa, 0x55, 0x00},
-	{0x55, 0xff, 0x55},
-	{0xff, 0x55, 0x55},
-	{0x12, 0x34, 0x56},
-	{0xff, 0xff, 0x55},
-	{0xff, 0xff, 0xff},
-	{0x00, 0x00, 0x00},
-	{0x00, 0x00, 0x00},
-	{0x00, 0x00, 0x00},
-	{0x00, 0x00, 0x00}
-};
-
-void FreescapeEngine::renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color) {
+void FreescapeEngine::renderPixels8bitBinImage(Graphics::ManagedSurface *surface, int &i, int &j, uint8 pixels, int color) {
 	if (i >= 320) {
 		//debug("cannot continue, stopping here at row %d!", j);
 		return;
@@ -333,13 +308,8 @@ void FreescapeEngine::renderPixels8bitBinImage(Graphics::Surface *surface, int &
 	while (acc > 0) {
 		assert(i < 320);
 		if (acc & pixels) {
-			uint8 r, g, b;
-			uint32 previousPixel = surface->getPixel(i, j);
-			_gfx->_currentPixelFormat.colorToRGB(previousPixel, r, g, b);
-			int previousColor = _gfx->indexFromColor(r, g, b);
-			//debug("index: %d", previousColor + color);
-			_gfx->readFromPalette(previousColor + color, r, g, b);
-			surface->setPixel(i, j, _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b));
+			int previousColor = surface->getPixel(i, j);
+			surface->setPixel(i, j, previousColor + color);
 		}
 		i++;
 		acc = acc >> 1;
@@ -347,18 +317,10 @@ void FreescapeEngine::renderPixels8bitBinImage(Graphics::Surface *surface, int &
 
 }
 
-Graphics::Surface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream *file, int offset) {
-	Graphics::Surface *surface = new Graphics::Surface();
-	if (_renderMode == Common::kRenderCGA)
-		_gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
-	else if (_renderMode == Common::kRenderEGA)
-		_gfx->_palette = (byte *)kEGADefaultPaletteData;
-	else
-		error("Invalid render mode: %d", _renderMode);
-
-	surface->create(_screenW, _screenH, _gfx->_currentPixelFormat);
-	uint32 black = _gfx->_currentPixelFormat.ARGBToColor(0xFF, 0, 0, 0);
-	surface->fillRect(Common::Rect(0, 0, 320, 200), black);
+Graphics::ManagedSurface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream *file, int offset) {
+	Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
+	surface->create(_screenW, _screenH, Graphics::PixelFormat::createFormatCLUT8());
+	surface->fillRect(Common::Rect(0, 0, 320, 200), 0);
 
 	file->seek(offset);
 	int imageSize = file->readUint16BE();
@@ -735,7 +697,7 @@ void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offse
 }
 
 void FreescapeEngine::loadBundledImages() {
-	Image::BitmapDecoder decoder;
+	/*Image::BitmapDecoder decoder;
 	Common::String targetName = Common::String(_gameDescription->gameId);
 	if (isDOS() && isDemo())
 		Common::replace(targetName, "-demo", "");
@@ -757,7 +719,7 @@ void FreescapeEngine::loadBundledImages() {
 		_title = new Graphics::Surface();
 		_title->copyFrom(*decoder.getSurface());
 		decoder.destroy();
-	}
+	}*/
 }
 
 void FreescapeEngine::loadFonts(Common::SeekableReadStream *file, int offset) {


Commit: 22fcff4ece14a062c3ba2acec57cdcfe4003c0d3
    https://github.com/scummvm/scummvm/commit/22fcff4ece14a062c3ba2acec57cdcfe4003c0d3
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-03-07T21:27:45+01:00

Commit Message:
FREESCAPE: allow to change the palette of title and border per level using managed surfaces

Changed paths:
    engines/freescape/freescape.cpp
    engines/freescape/games/driller/driller.cpp
    engines/freescape/games/palettes.cpp
    engines/freescape/gfx.cpp
    engines/freescape/gfx.h
    engines/freescape/loaders/8bitBinaryLoader.cpp


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index d989f6fe573..27567e85686 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -193,16 +193,12 @@ void FreescapeEngine::drawBorder() {
 
 void FreescapeEngine::drawTitle() {
 	_gfx->setViewport(_fullscreenViewArea);
-	if (isSpectrum()) {
-		Graphics::ManagedSurface *title = new Graphics::ManagedSurface();
-		title->create(320, 200, _title->format);
-		title->copyRectToSurface(*_title, (320 - _title->w) / 2, (200 - _title->h) / 2, Common::Rect(_title->w, _title->h));
-		_title->free();
-		delete _title;
-		_title = title;
+	if (!_titleTexture) {
+		Graphics::Surface *title = _gfx->convertImageFormatIfNecessary(_title);
+		_titleTexture = _gfx->createTexture(title);
+		title->free();
+		delete title;
 	}
-	if (!_titleTexture)
-		_titleTexture = _gfx->createTexture(&_title->rawSurface());
 	_gfx->drawTexturedRect2D(_fullscreenViewArea, _fullscreenViewArea, _titleTexture);
 	_gfx->setViewport(_viewArea);
 }
@@ -540,8 +536,6 @@ Common::Error FreescapeEngine::run() {
 	initGameState();
 	loadColorPalette();
 
-	_gfx->convertImageFormatIfNecessary(_title);
-	_gfx->convertImageFormatIfNecessary(_border);
 	g_system->lockMouse(true);
 
 	// Simple main event loop
@@ -597,28 +591,37 @@ void FreescapeEngine::titleScreen() {}
 void FreescapeEngine::borderScreen() {}
 
 void FreescapeEngine::loadBorder() {
-	if (_border)
-		_borderTexture = _gfx->createTexture(&_border->rawSurface());
+	if (_border) {
+		Graphics::Surface *border = _gfx->convertImageFormatIfNecessary(_border);
+		_borderTexture = _gfx->createTexture(border);
+		border->free();
+		delete border;
+	}
 }
 
 void FreescapeEngine::processBorder() {
 	if (_border) {
 		if (_borderTexture)
 			delete _borderTexture;
+		Graphics::Surface *border = _gfx->convertImageFormatIfNecessary(_border);
+
 		uint32 gray = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0xA0, 0xA0, 0xA0);
-		_border->fillRect(_viewArea, gray);
+		border->fillRect(_viewArea, gray);
 
 		// Replace black pixel for transparent ones
-		uint32 black = _border->format.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
-		uint32 transparent = _border->format.ARGBToColor(0x00, 0x00, 0x00, 0x00);
+		uint32 black = border->format.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
+		uint32 transparent = border->format.ARGBToColor(0x00, 0x00, 0x00, 0x00);
 
-		for (int i = 0; i < _border->w; i++) {
-			for (int j = 0; j < _border->h; j++) {
-				if (_border->getPixel(i, j) == black)
-					_border->setPixel(i, j, transparent);
+		for (int i = 0; i < border->w; i++) {
+			for (int j = 0; j < border->h; j++) {
+				if (border->getPixel(i, j) == black)
+					border->setPixel(i, j, transparent);
 			}
 		}
-		_borderTexture = _gfx->createTexture(&_border->rawSurface());
+
+		_borderTexture = _gfx->createTexture(border);
+		border->free();
+		delete border;
 	}
 }
 
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index 97ce479a819..c1e33edd9e2 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -29,59 +29,6 @@
 
 namespace Freescape {
 
-enum {
-	kDrillerCGAPalettePinkBlue = 0,
-	kDrillerCGAPaletteRedGreen = 1,
-};
-
-static const struct CGAPalettteEntry {
-	int areaId;
-	int palette;
-} rawCGAPaletteTable[] {
-	{1, kDrillerCGAPaletteRedGreen},
-	{2, kDrillerCGAPalettePinkBlue},
-	{3, kDrillerCGAPaletteRedGreen},
-	{4, kDrillerCGAPalettePinkBlue},
-	{5, kDrillerCGAPaletteRedGreen},
-	{6, kDrillerCGAPalettePinkBlue},
-	{7, kDrillerCGAPaletteRedGreen},
-	{8, kDrillerCGAPalettePinkBlue},
-	{9, kDrillerCGAPaletteRedGreen},
-	{10, kDrillerCGAPalettePinkBlue},
-	{11, kDrillerCGAPaletteRedGreen},
-	{12, kDrillerCGAPalettePinkBlue},
-
-	{14, kDrillerCGAPalettePinkBlue},
-
-	{16, kDrillerCGAPalettePinkBlue},
-
-	{19, kDrillerCGAPaletteRedGreen},
-	{20, kDrillerCGAPalettePinkBlue},
-	{21, kDrillerCGAPaletteRedGreen},
-	{22, kDrillerCGAPalettePinkBlue},
-	{23, kDrillerCGAPaletteRedGreen},
-
-	{28, kDrillerCGAPalettePinkBlue},
-
-	{32, kDrillerCGAPalettePinkBlue},
-	{127, kDrillerCGAPaletteRedGreen},
-	{0, 0}   // This marks the end
-};
-
-byte kDrillerCGAPalettePinkBlueData[4][3] = {
-	{0x00, 0x00, 0x00},
-	{0x00, 0xaa, 0xaa},
-	{0xaa, 0x00, 0xaa},
-	{0xaa, 0xaa, 0xaa},
-};
-
-byte kDrillerCGAPaletteRedGreenData[4][3] = {
-	{0x00, 0x00, 0x00},
-	{0x00, 0xaa, 0x00},
-	{0xaa, 0x00, 0x00},
-	{0xaa, 0x55, 0x00},
-};
-
 enum {
 	kDrillerNoRig = 0,
 	kDrillerRigInPlace = 1,
@@ -147,7 +94,7 @@ void DrillerEngine::titleScreen() {
 	if (isDOS() && isDemo()) // Demo will not show any title screen
 		return;
 
-	if (isAmiga() || isAtariST()) // These releases has their own screens
+	if (isAmiga() || isAtariST()) // TODO: implement these with their own animations
 		return;
 
 	if (_title) {
@@ -161,7 +108,7 @@ void DrillerEngine::borderScreen() {
 	if (isDOS() && isDemo()) // Demo will not show the border
 		return;
 
-	if (isAmiga() || isAtariST()) // These releases has their own screens
+	if (isAmiga() || isAtariST()) // TODO: implement these with their own animations
 		return;
 
 	if (_border) {
@@ -346,47 +293,6 @@ void DrillerEngine::loadAssetsFullGame() {
 
 void DrillerEngine::processBorder() {
 	FreescapeEngine::processBorder();
-	if (isDOS() && _renderMode == Common::kRenderCGA) { // Replace some colors for the CGA borders
-		uint32 color1 = _border->format.ARGBToColor(0xFF, 0xAA, 0x00, 0xAA);
-		uint32 color2 = _border->format.ARGBToColor(0xFF, 0xAA, 0x55, 0x00);
-
-		uint32 colorA = _border->format.ARGBToColor(0xFF, 0x00, 0xAA, 0xAA);
-		uint32 colorB = _border->format.ARGBToColor(0xFF, 0x00, 0xAA, 0x00);
-
-		uint32 colorX = _border->format.ARGBToColor(0xFF, 0xAA, 0xAA, 0xAA);
-		uint32 colorY = _border->format.ARGBToColor(0xFF, 0xAA, 0x00, 0x00);
-
-		Graphics::Surface *borderRedGreen = new Graphics::Surface();
-		borderRedGreen->create(1, 1, _border->format);
-		borderRedGreen->copyFrom(*_border);
-
-		for (int i = 0; i < _border->w; i++) {
-			for (int j = 0; j < _border->h; j++) {
-				if (borderRedGreen->getPixel(i, j) == color1)
-					borderRedGreen->setPixel(i, j, color2);
-				else if (borderRedGreen->getPixel(i, j) == colorA)
-					borderRedGreen->setPixel(i, j, colorB);
-				else if (borderRedGreen->getPixel(i, j) == colorX)
-					borderRedGreen->setPixel(i, j, colorY);
-
-			}
-		}
-		Texture *borderTextureRedGreen = _gfx->createTexture(borderRedGreen);
-
-		const CGAPalettteEntry *entry = rawCGAPaletteTable;
-		while (entry->areaId) {
-
-			if (entry->palette == kDrillerCGAPaletteRedGreen) {
-				_borderCGAByArea[entry->areaId] = borderTextureRedGreen;
-				_paletteCGAByArea[entry->areaId] = (byte *)kDrillerCGAPaletteRedGreenData;
-			} else if (entry->palette == kDrillerCGAPalettePinkBlue) {
-				_borderCGAByArea[entry->areaId] = _borderTexture;
-				_paletteCGAByArea[entry->areaId] = (byte *)kDrillerCGAPalettePinkBlueData;
-			} else
-				error("Invalid CGA palette to use");
-			entry++;
-		}
-	}
 }
 
 void DrillerEngine::drawUI() {
diff --git a/engines/freescape/games/palettes.cpp b/engines/freescape/games/palettes.cpp
index 1f4c8766fe6..97d4cfbf94c 100644
--- a/engines/freescape/games/palettes.cpp
+++ b/engines/freescape/games/palettes.cpp
@@ -155,6 +155,59 @@ void FreescapeEngine::loadPalettes(Common::SeekableReadStream *file, int offset)
 	}
 }
 
+enum {
+	kDrillerCGAPalettePinkBlue = 0,
+	kDrillerCGAPaletteRedGreen = 1,
+};
+
+static const struct CGAPalettteEntry {
+	int areaId;
+	int palette;
+} rawCGAPaletteTable[] {
+	{1, kDrillerCGAPaletteRedGreen},
+	{2, kDrillerCGAPalettePinkBlue},
+	{3, kDrillerCGAPaletteRedGreen},
+	{4, kDrillerCGAPalettePinkBlue},
+	{5, kDrillerCGAPaletteRedGreen},
+	{6, kDrillerCGAPalettePinkBlue},
+	{7, kDrillerCGAPaletteRedGreen},
+	{8, kDrillerCGAPalettePinkBlue},
+	{9, kDrillerCGAPaletteRedGreen},
+	{10, kDrillerCGAPalettePinkBlue},
+	{11, kDrillerCGAPaletteRedGreen},
+	{12, kDrillerCGAPalettePinkBlue},
+
+	{14, kDrillerCGAPalettePinkBlue},
+
+	{16, kDrillerCGAPalettePinkBlue},
+
+	{19, kDrillerCGAPaletteRedGreen},
+	{20, kDrillerCGAPalettePinkBlue},
+	{21, kDrillerCGAPaletteRedGreen},
+	{22, kDrillerCGAPalettePinkBlue},
+	{23, kDrillerCGAPaletteRedGreen},
+
+	{28, kDrillerCGAPalettePinkBlue},
+
+	{32, kDrillerCGAPalettePinkBlue},
+	{127, kDrillerCGAPaletteRedGreen},
+	{0, 0}   // This marks the end
+};
+
+byte kDrillerCGAPalettePinkBlueData[4][3] = {
+	{0x00, 0x00, 0x00},
+	{0x00, 0xaa, 0xaa},
+	{0xaa, 0x00, 0xaa},
+	{0xaa, 0xaa, 0xaa},
+};
+
+byte kDrillerCGAPaletteRedGreenData[4][3] = {
+	{0x00, 0x00, 0x00},
+	{0x00, 0xaa, 0x00},
+	{0xaa, 0x00, 0x00},
+	{0xaa, 0x55, 0x00},
+};
+
 void FreescapeEngine::swapPalette(uint16 levelID) {
 	if (isAmiga() || isAtariST())
 		_gfx->_palette = _paletteByArea[levelID];
@@ -163,11 +216,28 @@ void FreescapeEngine::swapPalette(uint16 levelID) {
 		_gfx->_paperColor = _areaMap[levelID]->_paperColor;
 		_gfx->_underFireBackgroundColor = _areaMap[levelID]->_underFireBackgroundColor;
 	} else if (isDOS() && _renderMode == Common::kRenderCGA) {
-		assert(_borderCGAByArea.contains(levelID));
-		assert(_paletteCGAByArea.contains(levelID));
-		_borderTexture = _borderCGAByArea.getVal(levelID);
-		_gfx->_palette = _paletteCGAByArea.getVal(levelID);
+		const CGAPalettteEntry *entry = rawCGAPaletteTable;
+		while (entry->areaId) {
+			if (entry->areaId == levelID) {
+				if (entry->palette == kDrillerCGAPaletteRedGreen) {
+					_gfx->_palette = (byte *)kDrillerCGAPaletteRedGreenData;
+				} else if (entry->palette == kDrillerCGAPalettePinkBlue) {
+					_gfx->_palette = (byte *)kDrillerCGAPalettePinkBlueData;
+				} else
+					error("Invalid CGA palette to use");
+				break;
+			}
+			entry++;
+		}
+
+		assert(entry->areaId == levelID);
+		_border->setPalette(_gfx->_palette, 0, 4);
+		processBorder();
+	} else if (isDOS() && _renderMode == Common::kRenderEGA) {
+		_border->setPalette(_gfx->_palette, 0, 4);
+		processBorder();
 	}
+
 }
 
 } // End of namespace Freescape
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index aeb830a9119..c0db20465c1 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -342,16 +342,18 @@ void Renderer::flipVertical(Graphics::Surface *s) {
 	}
 }
 
-void Renderer::convertImageFormatIfNecessary(Graphics::ManagedSurface *surface) {
-	if (!surface)
-		return;
-
-	if (surface->format != _texturePixelFormat) {
-		byte *palette = (byte *)malloc(sizeof(byte) * 16 * 3);
-		surface->grabPalette(palette, 0, 16); // Maximum should be 16 colours
-		surface->convertToInPlace(_texturePixelFormat, palette);
-		free(palette);
-	}
+Graphics::Surface *Renderer::convertImageFormatIfNecessary(Graphics::ManagedSurface *msurface) {
+	if (!msurface)
+		return nullptr;
+
+	assert(msurface->format != _texturePixelFormat);
+	Graphics::Surface *surface = new Graphics::Surface();
+	surface->copyFrom(msurface->rawSurface());
+	byte *palette = (byte *)malloc(sizeof(byte) * 16 * 3);
+	msurface->grabPalette(palette, 0, 16); // Maximum should be 16 colours
+	surface->convertToInPlace(_texturePixelFormat, palette);
+	free(palette);
+	return surface;
 }
 
 Common::Rect Renderer::viewport() const {
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 074ce8be090..867da87b0f0 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -77,7 +77,7 @@ public:
 	virtual void polygonOffset(bool enabled) = 0;
 
 	virtual Texture *createTexture(const Graphics::Surface *surface) = 0;
-	void convertImageFormatIfNecessary(Graphics::ManagedSurface *surface);
+	Graphics::Surface *convertImageFormatIfNecessary(Graphics::ManagedSurface *surface);
 
 	virtual void freeTexture(Texture *texture) = 0;
 	virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) = 0;
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index b62a5e6d28f..d9e1157be65 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -310,6 +310,7 @@ void FreescapeEngine::renderPixels8bitBinImage(Graphics::ManagedSurface *surface
 		if (acc & pixels) {
 			int previousColor = surface->getPixel(i, j);
 			surface->setPixel(i, j, previousColor + color);
+			assert(previousColor + color < 16);
 		}
 		i++;
 		acc = acc >> 1;


Commit: 23a594af6ca37b9cf73a4aa36e7e6ab9e9e089d8
    https://github.com/scummvm/scummvm/commit/23a594af6ca37b9cf73a4aa36e7e6ab9e9e089d8
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-03-07T21:27:45+01:00

Commit Message:
FREESCAPE: load original images and adjust ui for driller cpc

Changed paths:
    engines/freescape/games/driller/cpc.cpp


diff --git a/engines/freescape/games/driller/cpc.cpp b/engines/freescape/games/driller/cpc.cpp
index c42df9fbd49..25750cfb6b1 100644
--- a/engines/freescape/games/driller/cpc.cpp
+++ b/engines/freescape/games/driller/cpc.cpp
@@ -123,9 +123,75 @@ void deobfuscateDrillerCPCVirtualWorlds(byte *memBuffer) {
 	}
 }
 
+byte kCPCPalettePinkBlueWhiteData[4][3] = {
+	{0x00, 0x00, 0x00},
+	{0x55, 0xff, 0xff},
+	{0xff, 0x55, 0xff},
+	{0xff, 0xff, 0xff},
+};
+
+Graphics::ManagedSurface *readCPCImage(Common::SeekableReadStream *file) {
+	Graphics::ManagedSurface *surface = new Graphics::ManagedSurface();
+	surface->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
+	surface->fillRect(Common::Rect(0, 0, 320, 200), 0);
+
+	int x, y;
+	file->seek(0x80);
+	for (int block = 0; block < 8; block++) {
+		for (int line = 0; line < 25; line++) {
+			for (int offset = 0; offset < 320 / 4; offset++) {
+				byte cpc_byte = file->readByte(); // Get CPC byte
+
+				// Process first pixel
+				int pixel_0 = ((cpc_byte & 0x08) >> 2) | ((cpc_byte & 0x80) >> 7); // %Aa
+				y = line * 8 + block ; // Coord Y for the pixel
+				x = 4 * offset + 0; // Coord X for the pixel
+				surface->setPixel(x, y, pixel_0);
+
+				// Process second pixel
+				int pixel_1 = ((cpc_byte & 0x04) >> 1) | ((cpc_byte & 0x40) >> 6); // %Bb
+				y = line * 8 + block ; // Coord Y for the pixel
+				x = 4 * offset + 1; // Coord X for the pixel
+				surface->setPixel(x, y, pixel_1);
+
+				// Process third pixel
+				int pixel_2 = (cpc_byte & 0x02)        | ((cpc_byte & 0x20) >> 5); // %Cc
+				y = line * 8 + block ; // Coord Y for the pixel
+				x = 4 * offset + 2; // Coord X for the pixel
+				surface->setPixel(x, y, pixel_2);
+
+				// Process fourth pixel
+				int pixel_3 = ((cpc_byte & 0x01) << 1) | ((cpc_byte & 0x10) >> 4); // %Dd
+				y = line * 8 + block ; // Coord Y for the pixel
+				x = 4 * offset + 3; // Coord X for the pixel
+				surface->setPixel(x, y, pixel_3);
+			}
+		}
+		// We should skip the next 48 bytes, because they are padding the block to be 2048 bytes
+		file->seek(48, SEEK_CUR);
+	}
+	return surface;
+}
+
 void DrillerEngine::loadAssetsCPCFullGame() {
 	Common::File file;
-	loadBundledImages();
+
+	file.open("DSCN1.BIN");
+	if (!file.isOpen())
+		error("Failed to open DSCN1.BIN");
+
+	_title = readCPCImage(&file);
+	_title->setPalette((byte*)&kCPCPalettePinkBlueWhiteData, 0, 4);
+
+	file.close();
+	file.open("DSCN2.BIN");
+	if (!file.isOpen())
+		error("Failed to open DSCN2.BIN");
+
+	_border = readCPCImage(&file);
+	_border->setPalette((byte*)&kCPCPalettePinkBlueWhiteData, 0, 4);
+
+	file.close();
 	file.open("DRILL.BIN");
 
 	if (!file.isOpen())
@@ -153,30 +219,30 @@ void DrillerEngine::drawCPCUI(Graphics::Surface *surface) {
 	uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
 
 	int score = _gameStateVars[k8bitVariableScore];
-	drawStringInSurface(_currentArea->_name, 200, 188, front, back, surface);
-	drawStringInSurface(Common::String::format("%04d", int(2 * _position.x())), 149, 148, front, back, surface);
-	drawStringInSurface(Common::String::format("%04d", int(2 * _position.z())), 149, 156, front, back, surface);
-	drawStringInSurface(Common::String::format("%04d", int(2 * _position.y())), 149, 164, front, back, surface);
+	drawStringInSurface(_currentArea->_name, 200, 185, front, back, surface);
+	drawStringInSurface(Common::String::format("%04d", int(2 * _position.x())), 149, 145, front, back, surface);
+	drawStringInSurface(Common::String::format("%04d", int(2 * _position.z())), 149, 153, front, back, surface);
+	drawStringInSurface(Common::String::format("%04d", int(2 * _position.y())), 149, 161, front, back, surface);
 	if (_playerHeightNumber >= 0)
-		drawStringInSurface(Common::String::format("%d", _playerHeightNumber), 54, 164, front, back, surface);
+		drawStringInSurface(Common::String::format("%d", _playerHeightNumber), 54, 161, front, back, surface);
 	else
-		drawStringInSurface(Common::String::format("%s", "J"), 54, 164, front, back, surface);
+		drawStringInSurface(Common::String::format("%s", "J"), 54, 161, front, back, surface);
 
-	drawStringInSurface(Common::String::format("%02d", int(_angleRotations[_angleRotationIndex])), 46, 148, front, back, surface);
-	drawStringInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), 44, 156, front, back, surface);
-	drawStringInSurface(Common::String::format("%07d", score), 239, 132, front, back, surface);
+	drawStringInSurface(Common::String::format("%02d", int(_angleRotations[_angleRotationIndex])), 46, 145, front, back, surface);
+	drawStringInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), 44, 153, front, back, surface);
+	drawStringInSurface(Common::String::format("%07d", score), 239, 129, front, back, surface);
 
 	int seconds, minutes, hours;
 	getTimeFromCountdown(seconds, minutes, hours);
-	drawStringInSurface(Common::String::format("%02d", hours), 209, 11, front, back, surface);
-	drawStringInSurface(Common::String::format("%02d", minutes), 232, 11, front, back, surface);
-	drawStringInSurface(Common::String::format("%02d", seconds), 254, 11, front, back, surface);
+	drawStringInSurface(Common::String::format("%02d", hours), 209, 8, front, back, surface);
+	drawStringInSurface(Common::String::format("%02d", minutes), 232, 8, front, back, surface);
+	drawStringInSurface(Common::String::format("%02d", seconds), 254, 8, front, back, surface);
 
 	Common::String message;
 	int deadline;
 	getLatestMessages(message, deadline);
 	if (deadline <= _countdown) {
-		drawStringInSurface(message, 191, 180, back, front, surface);
+		drawStringInSurface(message, 191, 177, back, front, surface);
 		_temporaryMessages.push_back(message);
 		_temporaryMessageDeadlines.push_back(deadline);
 	} else if (_messagesList.size() > 0) {
@@ -187,24 +253,24 @@ void DrillerEngine::drawCPCUI(Graphics::Surface *surface) {
 		else
 			message = _messagesList[1];
 
-		drawStringInSurface(message, 191, 180, front, back, surface);
+		drawStringInSurface(message, 191, 177, front, back, surface);
 	}
 
 	int energy = _gameStateVars[k8bitVariableEnergy];
 	int shield = _gameStateVars[k8bitVariableShield];
 
 	if (energy >= 0) {
-		Common::Rect backBar(25, 187, 89 - energy, 194);
+		Common::Rect backBar(25, 184, 89 - energy, 191);
 		surface->fillRect(backBar, back);
-		Common::Rect energyBar(88 - energy, 187, 88, 194);
+		Common::Rect energyBar(88 - energy, 184, 88, 191);
 		surface->fillRect(energyBar, front);
 	}
 
 	if (shield >= 0) {
-		Common::Rect backBar(25, 180, 89 - shield, 186);
+		Common::Rect backBar(25, 177, 89 - shield, 183);
 		surface->fillRect(backBar, back);
 
-		Common::Rect shieldBar(88 - shield, 180, 88, 186);
+		Common::Rect shieldBar(88 - shield, 177, 88, 183);
 		surface->fillRect(shieldBar, front);
 	}
 }


Commit: 047d525f137e014eb55569050127323e0b2cbb9c
    https://github.com/scummvm/scummvm/commit/047d525f137e014eb55569050127323e0b2cbb9c
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-03-07T21:27:45+01:00

Commit Message:
FREESCAPE: load correct border palette for certain driller releases

Changed paths:
    engines/freescape/games/driller/driller.cpp
    engines/freescape/games/palettes.cpp


diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index c1e33edd9e2..76bef52466b 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -54,7 +54,7 @@ DrillerEngine::DrillerEngine(OSystem *syst, const ADGameDescription *gd) : Frees
 	else if (isSpectrum())
 		_viewArea = Common::Rect(56, 20, 264, 124);
 	else if (isCPC())
-		_viewArea = Common::Rect(36, 19, 284, 120);
+		_viewArea = Common::Rect(36, 16, 284, 117);
 	else if (isC64())
 		_viewArea = Common::Rect(32, 16, 288, 119);
 
diff --git a/engines/freescape/games/palettes.cpp b/engines/freescape/games/palettes.cpp
index 97d4cfbf94c..6baef6c443f 100644
--- a/engines/freescape/games/palettes.cpp
+++ b/engines/freescape/games/palettes.cpp
@@ -215,6 +215,18 @@ void FreescapeEngine::swapPalette(uint16 levelID) {
 		_gfx->_inkColor = _areaMap[levelID]->_inkColor;
 		_gfx->_paperColor = _areaMap[levelID]->_paperColor;
 		_gfx->_underFireBackgroundColor = _areaMap[levelID]->_underFireBackgroundColor;
+
+		byte *palette = (byte *)malloc(sizeof(byte) * 4 * 3);
+		for (int c = 0; c < 4; c++) {
+			byte r, g, b;
+			_gfx->selectColorFromFourColorPalette(c, r, g, b);
+			palette[3 * c + 0] = r;
+			palette[3 * c + 1] = g;
+			palette[3 * c + 2] = b;
+		}
+		_border->setPalette(palette, 0, 4);
+		free(palette);
+		processBorder();
 	} else if (isDOS() && _renderMode == Common::kRenderCGA) {
 		const CGAPalettteEntry *entry = rawCGAPaletteTable;
 		while (entry->areaId) {




More information about the Scummvm-git-logs mailing list