[Scummvm-git-logs] scummvm master -> 957b4164875d01af1f76009f53b3a9d87cf15678

neuromancer noreply at scummvm.org
Wed Feb 22 19:52:57 UTC 2023


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

Summary:
4acae4e320 FREESCAPE: load title/borders images in dark side EGA (and demo) directly from the game data
465c613be2 FREESCAPE: load title/borders images in total eclipse EGA directly from the game data
957b416487 FREESCAPE: implemented scr image loader and read title/borders images in driller for zx directly from the game data


Commit: 4acae4e3200c35593e6fb678c072629f9cd51f97
    https://github.com/scummvm/scummvm/commit/4acae4e3200c35593e6fb678c072629f9cd51f97
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-02-22T20:51:37+01:00

Commit Message:
FREESCAPE: load title/borders images in dark side EGA (and demo) directly from the game data

Changed paths:
    engines/freescape/freescape.h
    engines/freescape/games/dark.cpp


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 1e177654887..1bd2c977df9 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -459,6 +459,7 @@ public:
 	void loadAssets() override;
 	void initGameState() override;
 	void borderScreen() override;
+	void titleScreen() override;
 
 	void gotoArea(uint16 areaID, int entranceID) override;
 	void checkIfStillInArea() override;
diff --git a/engines/freescape/games/dark.cpp b/engines/freescape/games/dark.cpp
index edd1d0bcfe4..1a10368adb1 100644
--- a/engines/freescape/games/dark.cpp
+++ b/engines/freescape/games/dark.cpp
@@ -49,6 +49,18 @@ DarkEngine::DarkEngine(OSystem *syst, const ADGameDescription *gd) : FreescapeEn
 	_initialShield = 15;
 }
 
+void DarkEngine::titleScreen() {
+	if (isAmiga() || isAtariST()) // These releases has their own screens
+		return;
+
+	if (_title) {
+		drawTitle();
+		_gfx->flipBuffer();
+		g_system->updateScreen();
+		g_system->delayMillis(3000);
+	}
+}
+
 void DarkEngine::loadAssets() {
 	if (isDemo())
 		loadAssetsDemo();
@@ -59,7 +71,10 @@ void DarkEngine::loadAssets() {
 void DarkEngine::loadAssetsDemo() {
 	Common::File file;
 	if (isDOS() && _renderMode == Common::kRenderEGA) {
-		loadBundledImages();
+		file.open("SCN1E.DAT");
+		if (file.isOpen())
+			_title = load8bitBinImage(&file, 0x0);
+		file.close();
 		file.open("DSIDEE.EXE");
 
 		if (!file.isOpen())
@@ -69,6 +84,7 @@ void DarkEngine::loadAssetsDemo() {
 		loadFonts(&file, 0xa598);
 		loadGlobalObjects(&file, 0x3d04);
 		load8bitBinary(&file, 0xa700, 16);
+		_border = load8bitBinImage(&file, 0x210);
 	} else if (isDOS() && _renderMode == Common::kRenderCGA) {
 		//loadBundledImages();
 		file.open("DSIDEC.EXE");
@@ -129,7 +145,10 @@ void DarkEngine::initGameState() {
 void DarkEngine::loadAssetsFullGame() {
 	Common::File file;
 	if (_renderMode == Common::kRenderEGA) {
-		loadBundledImages();
+		file.open("SCN1E.DAT");
+		if (file.isOpen())
+			_title = load8bitBinImage(&file, 0x0);
+		file.close();
 		file.open("DSIDEE.EXE");
 
 		if (!file.isOpen())
@@ -139,6 +158,8 @@ void DarkEngine::loadAssetsFullGame() {
 		loadMessagesFixedSize(&file, 0x4525, 16, 27);
 		loadGlobalObjects(&file, 0x3d04);
 		load8bitBinary(&file, 0xa280, 16);
+		_border = load8bitBinImage(&file, 0x210);
+
 		// TODO: load objects
 		/*for (auto &it : _areaMap) {
 			if (!it._value->entranceWithID(255))


Commit: 465c613be237e359e457460a420bcc6d3b47a6d7
    https://github.com/scummvm/scummvm/commit/465c613be237e359e457460a420bcc6d3b47a6d7
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-02-22T20:51:37+01:00

Commit Message:
FREESCAPE: load title/borders images in total eclipse EGA directly from the game data

Changed paths:
    engines/freescape/freescape.h
    engines/freescape/games/eclipse.cpp


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 1bd2c977df9..975f8c9d5e3 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -487,6 +487,7 @@ public:
 	EclipseEngine(OSystem *syst, const ADGameDescription *gd);
 
 	void loadAssets() override;
+	void titleScreen() override;
 
 	void gotoArea(uint16 areaID, int entranceID) override;
 
diff --git a/engines/freescape/games/eclipse.cpp b/engines/freescape/games/eclipse.cpp
index 9e4e47a2d00..56baa42f46b 100644
--- a/engines/freescape/games/eclipse.cpp
+++ b/engines/freescape/games/eclipse.cpp
@@ -99,10 +99,26 @@ EclipseEngine::EclipseEngine(OSystem *syst, const ADGameDescription *gd) : Frees
 	}
 }
 
+void EclipseEngine::titleScreen() {
+	if (isAmiga() || isAtariST()) // These releases has their own screens
+		return;
+
+	if (_title) {
+		drawTitle();
+		_gfx->flipBuffer();
+		g_system->updateScreen();
+		g_system->delayMillis(3000);
+	}
+}
+
 void EclipseEngine::loadAssets() {
 	Common::File file;
 	if (_renderMode == Common::kRenderEGA) {
-		loadBundledImages();
+		file.open("SCN1E.DAT");
+		if (file.isOpen()) {
+			_title = load8bitBinImage(&file, 0x0);
+		}
+		file.close();
 		file.open("TOTEE.EXE");
 
 		if (!file.isOpen())
@@ -112,7 +128,7 @@ void EclipseEngine::loadAssets() {
 		load8bitBinary(&file, 0x3ce0, 16);
 		for (auto &it : _areaMap)
 			it._value->addStructure(_areaMap[255]);
-
+		_border = load8bitBinImage(&file, 0x210);
 	} else if (_renderMode == Common::kRenderCGA) {
 		loadBundledImages();
 		file.open("TOTEC.EXE");


Commit: 957b4164875d01af1f76009f53b3a9d87cf15678
    https://github.com/scummvm/scummvm/commit/957b4164875d01af1f76009f53b3a9d87cf15678
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-02-22T20:53:49+01:00

Commit Message:
FREESCAPE: implemented scr image loader and read title/borders images in driller for zx directly from the game data

Changed paths:
  A engines/freescape/scr.cpp
  A engines/freescape/scr.h
    engines/freescape/freescape.cpp
    engines/freescape/freescape.h
    engines/freescape/games/driller.cpp
    engines/freescape/module.mk


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 6481d0dc7ff..690fcff4492 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -30,6 +30,7 @@
 #include "freescape/freescape.h"
 #include "freescape/language/8bitDetokeniser.h"
 #include "freescape/neo.h"
+#include "freescape/scr.h"
 #include "freescape/objects/sensor.h"
 
 namespace Freescape {
@@ -185,7 +186,6 @@ void FreescapeEngine::drawBorder() {
 		return;
 
 	_gfx->setViewport(_fullscreenViewArea);
-
 	assert(_borderTexture);
 	_gfx->drawTexturedRect2D(_fullscreenViewArea, _fullscreenViewArea, _borderTexture);
 	_gfx->setViewport(_viewArea);
@@ -860,6 +860,16 @@ Graphics::Surface *FreescapeEngine::loadAndConvertNeoImage(Common::SeekableReadS
 	return surface;
 }
 
+Graphics::Surface *FreescapeEngine::loadAndCenterScrImage(Common::SeekableReadStream *stream) {
+	ScrDecoder decoder;
+	decoder.loadStream(*stream);
+	Graphics::Surface *surface = new Graphics::Surface();
+	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));
+	return surface;
+}
+
 void FreescapeEngine::getTimeFromCountdown(int &seconds, int &minutes, int &hours) {
 	int countdown = _countdown;
 	int h = countdown <= 0 ? 0 : countdown / 3600;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 975f8c9d5e3..5a255ca3b3d 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -140,6 +140,7 @@ public:
 	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);
 	void loadPalettes(Common::SeekableReadStream *file, int offset);
 	void swapPalette(uint16 areaID);
 	Common::HashMap<uint16, byte *> _paletteByArea;
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index 902000f563d..5650a51e3a5 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -538,7 +538,21 @@ void DrillerEngine::loadAssetsFullGame() {
 		loadPalettes(&file, 0x296fa);
 		loadSoundsFx(&file, 0x30da6, 25);
 	} else if (isSpectrum()) {
-		loadBundledImages();
+		file.open("driller.zx.title");
+		if (file.isOpen()) {
+			_title = loadAndCenterScrImage(&file);
+		} else
+			error("Unable to find driller.zx.title");
+
+		file.close();
+
+		file.open("driller.zx.border");
+		if (file.isOpen()) {
+			_border = loadAndCenterScrImage(&file);
+		} else
+			error("Unable to find driller.zx.border");
+		file.close();
+
 		file.open("driller.zx.extracted");
 
 		if (!file.isOpen())
diff --git a/engines/freescape/module.mk b/engines/freescape/module.mk
index 9b3b656ce6c..556a28f6efa 100644
--- a/engines/freescape/module.mk
+++ b/engines/freescape/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	neo.o \
 	objects/geometricobject.o \
 	objects/sensor.o \
+	scr.o \
 	sound.o
 
 ifdef USE_TINYGL
diff --git a/engines/freescape/scr.cpp b/engines/freescape/scr.cpp
new file mode 100644
index 00000000000..1621363fe30
--- /dev/null
+++ b/engines/freescape/scr.cpp
@@ -0,0 +1,105 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/stream.h"
+#include "common/textconsole.h"
+#include "graphics/pixelformat.h"
+#include "graphics/surface.h"
+
+#include "freescape/scr.h"
+
+namespace Freescape {
+
+ScrDecoder::ScrDecoder() {
+	_surface = nullptr;
+}
+
+ScrDecoder::~ScrDecoder() {
+	destroy();
+}
+
+void ScrDecoder::destroy() {
+	if (_surface) {
+		_surface->free();
+		delete _surface;
+		_surface = nullptr;
+	}
+}
+
+uint32 ScrDecoder::getPixelAddress(int x, int y) {
+	uint32 y76 = y & 0xc0;
+	uint32 y53 = y & 0x38;
+	uint32 y20 = y & 0x07;
+	return (y76 << 5) + (y20 << 8) + (y53 << 2) + (x >> 3);
+}
+
+uint32 ScrDecoder::getAttributeAddress(int x, int y) {
+	uint32 y73 = y & 0xf8;
+	return (y73 << 2) + (x >> 3);
+}
+
+bool ScrDecoder::loadStream(Common::SeekableReadStream &stream) {
+	destroy();
+
+	if (stream.size() != 6912)
+		warning("Header check failed for reading scr image");
+
+	byte *data = (byte *)malloc(6144 * sizeof(byte));
+	byte *attributes = (byte *)malloc(768 * sizeof(byte));
+
+	stream.read(data, 6144);
+	stream.read(attributes, 768);
+
+	int width = 256;
+	int height = 192;
+	Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
+
+	_surface = new Graphics::Surface();
+	_surface->create(width, height, format);
+
+    for (int y = 0; y < height; y++) {
+		for (int col = 0; col < width >> 3; col++) {
+			int x = col << 3;
+			byte byt = data[getPixelAddress(x, y)];
+			byte attr = attributes[getAttributeAddress(x, y)];
+			byte ink = attr & 0x07;
+			byte paper = (attr >> 3) & 0x07;
+			byte bright = (attr >> 6) & 1;
+			byte val = bright ? 0xff : 0xcd;
+			for (int bit = 0; bit < 8; bit++) {
+				bool set = (byt >> (7 - bit)) & 1;
+				int color = set ? ink : paper;
+
+				byte r = val * (color >> 1 & 1);
+				byte g = val * (color >> 2 & 1);
+				byte b = val * (color >> 0 & 1);
+
+				_surface->setPixel(x + bit, y, format.ARGBToColor(0xFF, r, g, b));
+			}
+		}
+	}
+
+	free(data);
+	free(attributes);
+	return true;
+}
+
+} // End of namespace Freescape
diff --git a/engines/freescape/scr.h b/engines/freescape/scr.h
new file mode 100644
index 00000000000..054dc0a16de
--- /dev/null
+++ b/engines/freescape/scr.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef FREESCAPE_SCR_H
+#define FREESCAPE_SCR_H
+
+#include "image/image_decoder.h"
+
+/*
+ZX-Spectrum SCREEN$ decoder based on:
+https://gist.github.com/alexanderk23/f459c76847d9412548f7
+*/
+
+namespace Common {
+class SeekableReadStream;
+}
+
+namespace Freescape {
+
+class ScrDecoder : public Image::ImageDecoder {
+public:
+	ScrDecoder();
+	virtual ~ScrDecoder();
+
+	// ImageDecoder API
+	void destroy();
+	virtual bool loadStream(Common::SeekableReadStream &stream);
+	virtual const Graphics::Surface *getSurface() const { return _surface; }
+private:
+	Graphics::Surface *_surface;
+	uint32 getPixelAddress(int x, int y);
+	uint32 getAttributeAddress(int x, int y);
+};
+} // End of namespace Freescape
+
+#endif // FREESCAPE_SCR_H




More information about the Scummvm-git-logs mailing list