[Scummvm-git-logs] scummvm master -> 434726cf5f5fb827faabd8cbfeb03bcd61db1bf3

neuromancer noreply at scummvm.org
Sun Feb 12 17:19:51 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:
434726cf5f FREESCAPE: drafted code that reads title image of driller US release for DOS


Commit: 434726cf5f5fb827faabd8cbfeb03bcd61db1bf3
    https://github.com/scummvm/scummvm/commit/434726cf5f5fb827faabd8cbfeb03bcd61db1bf3
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-02-12T18:19:17+01:00

Commit Message:
FREESCAPE: drafted code that reads title image of driller US release for DOS

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


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index ac30334df92..6772c476c23 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -164,6 +164,9 @@ public:
 	void load8bitBinary(Common::SeekableReadStream *file, int offset, int ncolors);
 	Area *load8bitArea(Common::SeekableReadStream *file, uint16 ncolors);
 	Object *load8bitObject(Common::SeekableReadStream *file);
+	void renderPixels8bitImage(Graphics::Surface *surface, int &i, int &j, int pixels);
+	uint32 getPixel8bitImage(int index);
+	Graphics::Surface *load8bitImage(Common::SeekableReadStream *file, int ncolors, int offset);
 
 	// Areas
 	uint16 _startArea;
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index a30e97a8087..b154dc77ee6 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -660,6 +660,12 @@ void DrillerEngine::loadAssetsFullGame() {
 
 	} else if (_renderMode == Common::kRenderCGA) {
 		loadBundledImages();
+		_title->free();
+		delete _title;
+		file.open("CGATITLE.RL");
+		_title = load8bitImage(&file, 4, 0x1b3);
+
+		file.close();
 		file.open("DRILLC.EXE");
 
 		if (!file.isOpen())
@@ -669,6 +675,7 @@ void DrillerEngine::loadAssetsFullGame() {
 		loadMessagesFixedSize(&file, 0x2585, 14, 20);
 		load8bitBinary(&file, 0x7bb0, 4);
 		loadGlobalObjects(&file, 0x1fa2);
+		//_border = load8bitImage(&file, 4, 0x261);
 	} else
 		error("Invalid or unsupported render mode %s for Driller", Common::getRenderModeDescription(_renderMode));
 
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 1e5a7f48126..7ae1b7cd240 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -298,6 +298,154 @@ static const char *eclipseRoomName[] = {
 	"ILLUSION",
 	"????????"};
 
+byte kCGAPalettePinkBlueWhiteData[4][3] = {
+	{0x00, 0x00, 0x00},
+	{0x55, 0xff, 0xff},
+	{0xff, 0x55, 0xff},
+	{0xff, 0xff, 0xff},
+};
+
+uint32 FreescapeEngine::getPixel8bitImage(int index) {
+	uint8 r, g, b;
+	if (index < 4) {
+		_gfx->readFromPalette(0, r, g, b);
+		return _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b);
+	}
+	_gfx->readFromPalette(index / 4, r, g, b);
+	return _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b);
+}
+
+void FreescapeEngine::renderPixels8bitImage(Graphics::Surface *surface, int &i, int &j, int pixels) {
+	int c1 = pixels >> 4;
+	int c2 = pixels & 0xf;
+
+	if (i == 320) {
+		return;
+	}
+
+	surface->setPixel(i, j, getPixel8bitImage(c1));
+	i++;
+
+	if (i == 320) {
+		return;
+	}
+
+	surface->setPixel(i, j, getPixel8bitImage(c1));
+	i++;
+
+	if (i == 320) {
+		return;
+	}
+
+	surface->setPixel(i, j, getPixel8bitImage(c2));
+	i++;
+
+	if (i == 320) {
+		return;
+	}
+
+	surface->setPixel(i, j, getPixel8bitImage(c2));
+	i++;
+}
+
+Graphics::Surface *FreescapeEngine::load8bitImage(Common::SeekableReadStream *file, int ncolors, int offset) {
+	Graphics::Surface *surface = new Graphics::Surface();
+	assert(ncolors == 4);
+	_gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
+	surface->create(_screenW, _screenH, _gfx->_currentPixelFormat);
+	uint32 black = _gfx->_currentPixelFormat.ARGBToColor(0xFF, 0, 0, 0);
+	surface->fillRect(Common::Rect(0, 0, 320, 200), black);
+
+	int i = 0;
+	int j = 0;
+	int command = -1;
+	int singlePixelsToProcess = 0;
+	bool repeatedPixelsToProcess = false;
+	file->seek(offset);
+	while (!file->eos()) {
+		assert(i <= 320);
+		int pixels = -1;
+		int repetition = -1;
+
+		if (singlePixelsToProcess == 0 && !repeatedPixelsToProcess) {
+			if (command < 0)
+				command = file->readByte();
+
+			//debug("reading command: %x at %lx", command, file->pos() - 1);
+
+			assert(command >= 0x7f);
+			singlePixelsToProcess = (0xff - command + 2) * 2;
+			//debug("single Pixels to process: %d", singlePixelsToProcess);
+
+			repeatedPixelsToProcess = true;
+			if (i == 320) {
+				j++;
+				i = 0;
+			}
+			command = -1;
+			continue;
+		}
+
+		if (singlePixelsToProcess > 0) {
+			singlePixelsToProcess--;
+			pixels = file->readByte();
+			//debug("reading pixels: %x at %d, %d", pixels, i, j);
+			renderPixels8bitImage(surface, i, j, pixels);
+		} else if (repeatedPixelsToProcess) {
+			repetition = file->readByte() + 1;
+			//debug("reading repetition: %x", repetition - 1);
+			assert(repetition > 0);
+			if (repetition >= 0x80) {
+				command = repetition - 1;
+				repeatedPixelsToProcess = false;
+				continue;
+			}
+
+			if (i == 320) {
+				j++;
+				i = 0;
+				continue;
+			}
+
+			int pixels1 = file->readByte();
+			//debug("reading pixels: %x", pixels1);
+
+			int pixels2 = file->readByte();
+			//debug("reading pixels: %x", pixels2);
+
+			if (repetition >= 1) {
+				while (repetition > 0) {
+					repetition--;
+
+					if (i == 320) {
+						j++;
+						i = 0;
+					}
+
+					if (j == 200)
+						return surface;
+
+					//sdebug("repeating pixels: %x at %d, %d", pixels1, i, j);
+					renderPixels8bitImage(surface, i, j, pixels1);
+
+					if (i == 320) {
+						j++;
+						i = 0;
+					}
+
+					if (j == 200)
+						return surface;
+
+					//debug("repeating pixels: %x at %d, %d", pixels2, i, j);
+					renderPixels8bitImage(surface, i, j, pixels2);
+				}
+			}
+		}
+	}
+
+	return surface;
+}
+
 Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 ncolors) {
 
 	Common::String name;




More information about the Scummvm-git-logs mailing list