[Scummvm-git-logs] scummvm master -> 9bc91d3e5a9a47aeca6aacc3792eda5d46d8b8ba

neuromancer noreply at scummvm.org
Thu Jun 13 06:22:57 UTC 2024


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

Summary:
5ed21ff358 FREESCAPE: character selection screen on castle for dos
9bc91d3e5a FREESCAPE: initial code for support zx release of castle


Commit: 5ed21ff35851b9b847754337773171f8318f4068
    https://github.com/scummvm/scummvm/commit/5ed21ff35851b9b847754337773171f8318f4068
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-06-13T08:24:02+02:00

Commit Message:
FREESCAPE: character selection screen on castle for dos

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


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index b9db18b1873..b003cfa61a1 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -46,6 +46,7 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
 	_maxFallingDistance = 8192;
 	_maxShield = 24;
 	_option = nullptr;
+	_optionTexture = nullptr;
 }
 
 CastleEngine::~CastleEngine() {
@@ -496,6 +497,84 @@ void CastleEngine::updateTimeVariables() {
 	}
 }
 
+void CastleEngine::titleScreen() {
+	FreescapeEngine::titleScreen();
+	selectCharacterScreen();
+}
+
+void CastleEngine::drawOption() {
+	_gfx->setViewport(_fullscreenViewArea);
+	if (_option) {
+		if (!_optionTexture) {
+			Graphics::Surface *title = _gfx->convertImageFormatIfNecessary(_option);
+			_optionTexture = _gfx->createTexture(title);
+			title->free();
+			delete title;
+		}
+		_gfx->drawTexturedRect2D(_fullscreenViewArea, _fullscreenViewArea, _optionTexture);
+	}
+	_gfx->setViewport(_viewArea);
+}
+
+void CastleEngine::selectCharacterScreen() {
+	if (!_option)
+		return;
+
+	Graphics::Surface *surface = new Graphics::Surface();
+	surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
+
+	uint32 green = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0xFF, 0x00);
+	uint32 transparent = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
+	drawStringInSurface("Select your character", 63, 16, green, transparent, surface);
+	drawStringInSurface("1. Prince", 150, 82, green, transparent, surface);
+	drawStringInSurface("1. Princess", 150, 92, green, transparent, surface);
+
+	bool selected = false;
+	while (!selected) {
+		Common::Event event;
+		while (_eventManager->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_QUIT:
+			case Common::EVENT_RETURN_TO_LAUNCHER:
+				quitGame();
+				return;
+
+			case Common::EVENT_SCREEN_CHANGED:
+				_gfx->computeScreenViewport();
+				_gfx->clear(0, 0, 0, true);
+				break;
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_1:
+					selected = true;
+					break;
+				case Common::KEYCODE_2:
+					selected = true;
+					break;
+				default:
+					break;
+				}
+			break;
+			case Common::EVENT_RBUTTONDOWN:
+				// fallthrough
+			case Common::EVENT_LBUTTONDOWN:
+				// TODO: allow to select character with mouse
+				break;
+			default:
+				break;
+			}
+		}
+		_gfx->clear(0, 0, 0, true);
+		drawOption();
+		drawFullscreenSurface(surface);
+		_gfx->flipBuffer();
+		g_system->updateScreen();
+		g_system->delayMillis(15); // try to target ~60 FPS
+	}
+	_gfx->clear(0, 0, 0, true);
+
+}
+
 Common::Error CastleEngine::saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave) {
 	return Common::kNoError;
 }
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index fffaca97159..24682967b2b 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -32,6 +32,9 @@ public:
 	void loadAssetsDOSFullGame() override;
 	void loadAssetsDOSDemo() override;
 	void loadAssetsAmigaDemo() override;
+	void titleScreen() override;
+	void selectCharacterScreen();
+	void drawOption();
 
 	void drawDOSUI(Graphics::Surface *surface) override;
 	void drawEnergyMeter(Graphics::Surface *surface);
@@ -51,6 +54,7 @@ private:
 	void drawFullscreenRiddleAndWait(uint16 riddle);
 	void drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics::Surface *surface);
 	void addGhosts();
+	Texture *_optionTexture;
 };
 
 extern byte kFreescapeCastleFont[];


Commit: 9bc91d3e5a9a47aeca6aacc3792eda5d46d8b8ba
    https://github.com/scummvm/scummvm/commit/9bc91d3e5a9a47aeca6aacc3792eda5d46d8b8ba
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-06-13T08:24:02+02:00

Commit Message:
FREESCAPE: initial code for support zx release of castle

Changed paths:
  A engines/freescape/games/castle/zx.cpp
    engines/freescape/area.cpp
    engines/freescape/detection.cpp
    engines/freescape/freescape.cpp
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/castle/castle.h
    engines/freescape/loaders/8bitBinaryLoader.cpp
    engines/freescape/module.mk


diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 76ffb7513db..9d081616138 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -228,7 +228,7 @@ void Area::draw(Freescape::Renderer *gfx, uint32 animationTicks, Math::Vector3d
 	ObjectArray planarObjects;
 	ObjectArray nonPlanarObjects;
 	Object *floor = nullptr;
-	float offset = !gfx->_isAccelerated ? 2.0 : 0.5;
+	float offset = !gfx->_isAccelerated ? 2.0 : 1.0;
 
 	for (auto &obj : _drawableObjects) {
 		if (!obj->isDestroyed() && !obj->isInvisible()) {
diff --git a/engines/freescape/detection.cpp b/engines/freescape/detection.cpp
index af8508ec20f..b4ff2934be1 100644
--- a/engines/freescape/detection.cpp
+++ b/engines/freescape/detection.cpp
@@ -469,7 +469,7 @@ static const ADGameDescription gameDescriptions[] = {
 		},
 		Common::EN_ANY,
 		Common::kPlatformAmstradCPC,
-		ADGF_TESTING | ADGF_DEMO,
+		ADGF_DEMO,
 		GUIO1(GUIO_NOMIDI)
 	},
 	{
@@ -483,7 +483,7 @@ static const ADGameDescription gameDescriptions[] = {
 		},
 		Common::EN_ANY,
 		Common::kPlatformZX,
-		ADGF_TESTING | ADGF_DEMO | GF_ZX_DEMO_MICROHOBBY,
+		ADGF_DEMO | GF_ZX_DEMO_MICROHOBBY,
 		GUIO1(GUIO_NOMIDI)
 	},
 	{
@@ -497,7 +497,7 @@ static const ADGameDescription gameDescriptions[] = {
 		},
 		Common::EN_ANY,
 		Common::kPlatformZX,
-		ADGF_TESTING | ADGF_DEMO | GF_ZX_DEMO_CRASH,
+		ADGF_DEMO | GF_ZX_DEMO_CRASH,
 		GUIO1(GUIO_NOMIDI)
 	},
 	{
@@ -509,7 +509,7 @@ static const ADGameDescription gameDescriptions[] = {
 		},
 		Common::EN_ANY,
 		Common::kPlatformZX,
-		ADGF_TESTING,
+		ADGF_NO_FLAGS,
 		GUIO1(GUIO_NOMIDI)
 	},
 	{
@@ -660,6 +660,18 @@ static const ADGameDescription gameDescriptions[] = {
 		GF_ATARI_BUDGET,
 		GUIO2(GUIO_NOMIDI, GAMEOPTION_AUTOMATIC_DRILLING)
 	},
+	{
+		"castlemaster",
+		"",
+		{
+			{"castlemaster.zx.data", 0, "e2ed83c30cd0ed7119e349d0f677ae91", 36096},
+			AD_LISTEND
+		},
+		Common::EN_ANY,
+		Common::kPlatformZX,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NOMIDI)
+	},
 	{
 		"castlemaster",
 		"Demo",
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 0a685169c9b..79a35fa303c 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -374,8 +374,7 @@ void FreescapeEngine::drawBackground() {
 	clearBackground();
 	_gfx->drawBackground(_currentArea->_skyColor);
 
-	if (isCastle()) {
-		assert(_background);
+	if (isCastle() && _background) {
 		if (!_skyTexture)
 			_skyTexture = _gfx->createTexture(_background);
 		_gfx->drawSkybox(_skyTexture, _position);
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index b003cfa61a1..dac843fd54b 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -29,6 +29,9 @@
 namespace Freescape {
 
 CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : FreescapeEngine(syst, gd) {
+	if (isSpectrum())
+		initZX();
+
 	_playerHeightNumber = 1;
 	_playerHeights.push_back(16);
 	_playerHeights.push_back(48);
@@ -152,10 +155,12 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 	_gfx->_keyColor = 0;
 	_gfx->clearColorPairArray();
 
-	_gfx->_colorPair[_currentArea->_underFireBackgroundColor] = _currentArea->_extraColor[0];
-	_gfx->_colorPair[_currentArea->_usualBackgroundColor] = _currentArea->_extraColor[1];
-	_gfx->_colorPair[_currentArea->_paperColor] = _currentArea->_extraColor[2];
-	_gfx->_colorPair[_currentArea->_inkColor] = _currentArea->_extraColor[3];
+	if (isDOS()) {
+		_gfx->_colorPair[_currentArea->_underFireBackgroundColor] = _currentArea->_extraColor[0];
+		_gfx->_colorPair[_currentArea->_usualBackgroundColor] = _currentArea->_extraColor[1];
+		_gfx->_colorPair[_currentArea->_paperColor] = _currentArea->_extraColor[2];
+		_gfx->_colorPair[_currentArea->_inkColor] = _currentArea->_extraColor[3];
+	}
 
 	swapPalette(areaID);
 	resetInput();
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index 24682967b2b..310ac2dc4d6 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -32,11 +32,15 @@ public:
 	void loadAssetsDOSFullGame() override;
 	void loadAssetsDOSDemo() override;
 	void loadAssetsAmigaDemo() override;
+	void loadAssetsZXFullGame() override;
 	void titleScreen() override;
 	void selectCharacterScreen();
 	void drawOption();
 
+	void initZX();
+
 	void drawDOSUI(Graphics::Surface *surface) override;
+	void drawZXUI(Graphics::Surface *surface) override;
 	void drawEnergyMeter(Graphics::Surface *surface);
 	void pressedKey(const int keycode) override;
 	void checkSensors() override;
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
new file mode 100644
index 00000000000..e1f164b611d
--- /dev/null
+++ b/engines/freescape/games/castle/zx.cpp
@@ -0,0 +1,96 @@
+/* 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/file.h"
+
+#include "freescape/freescape.h"
+#include "freescape/games/castle/castle.h"
+#include "freescape/language/8bitDetokeniser.h"
+
+namespace Freescape {
+
+void CastleEngine::initZX() {
+	_viewArea = Common::Rect(64, 36, 256, 148);
+}
+
+void CastleEngine::loadAssetsZXFullGame() {
+	Common::File file;
+
+	file.open("castlemaster.zx.title");
+	if (file.isOpen()) {
+		_title = loadAndCenterScrImage(&file);
+	} else
+		error("Unable to find castlemaster.zx.title");
+
+	file.close();
+	file.open("castlemaster.zx.border");
+	if (file.isOpen()) {
+		_border = loadAndCenterScrImage(&file);
+	} else
+		error("Unable to find castlemaster.zx.border");
+	file.close();
+
+	file.open("castlemaster.zx.data");
+	if (!file.isOpen())
+		error("Failed to open castlemaster.zx.data");
+
+	//loadMessagesFixedSize(&file, 0x4bc + 1, 16, 27);
+    loadFonts(kFreescapeCastleFont, 59);
+    loadMessagesVariableSize(&file, 0x4bc, 84 - 13);
+
+    load8bitBinary(&file, 0x6a3b, 16);
+	loadSpeakerFxZX(&file, 0xc91, 0xccd);
+
+	for (auto &it : _areaMap)
+		it._value->addStructure(_areaMap[255]);
+
+	_areaMap[1]->addFloor();
+	_areaMap[2]->addFloor();
+}
+
+void CastleEngine::drawZXUI(Graphics::Surface *surface) {
+	uint32 color = 5;
+	uint8 r, g, b;
+
+	_gfx->readFromPalette(color, r, g, b);
+	uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+	color = 0;
+	_gfx->readFromPalette(color, r, g, b);
+	uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+	Common::Rect backRect(123, 179, 242 + 5, 188);
+	surface->fillRect(backRect, black);
+
+	Common::String message;
+	int deadline;
+	getLatestMessages(message, deadline);
+	if (deadline <= _countdown) {
+		drawStringInSurface(message, 120, 179, front, black, surface);
+		_temporaryMessages.push_back(message);
+		_temporaryMessageDeadlines.push_back(deadline);
+	} else
+		drawStringInSurface(_currentArea->_name, 120, 179, front, black, surface);
+
+	//drawEnergyMeter(surface);
+}
+
+} // End of namespace Freescape
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 05bbb35f8ea..0f9ee590264 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -530,22 +530,29 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 	if (groundColor == 0)
 		groundColor = 255;
 
-	uint8 usualBackgroundColor = readField(file, 8);
-	uint8 underFireBackgroundColor = readField(file, 8);
-	uint8 paperColor = readField(file, 8);
-	uint8 inkColor = readField(file, 8);
+	uint8 usualBackgroundColor = 0;
+	uint8 underFireBackgroundColor = 0;
+	uint8 paperColor = 0;
+	uint8 inkColor = 0;
+
+	if (!(isCastle() && isSpectrum())) {
+		usualBackgroundColor = readField(file, 8);
+		underFireBackgroundColor = readField(file, 8);
+		paperColor = readField(file, 8);
+		inkColor = readField(file, 8);
+	} else {
+		uint8 attribute = readField(file, 8);
+		debugC(1, kFreescapeDebugParser, "Attribute: %x", attribute);
+		paperColor = attribute > 4;
+		inkColor = attribute & 0xf;
+		skyColor = 0;
+	}
+
 	debugC(1, kFreescapeDebugParser, "Colors usual background: %d", usualBackgroundColor);
 	debugC(1, kFreescapeDebugParser, "Colors under fire background: %d", underFireBackgroundColor);
 	debugC(1, kFreescapeDebugParser, "Color Paper: %d", paperColor);
 	debugC(1, kFreescapeDebugParser, "Color Ink: %d", inkColor);
-
 	debugC(1, kFreescapeDebugParser, "Additional colors: %d %d", skyColor, groundColor);
-	// CPC
-	// groundColor = file->readByte() & 15;
-	// skyColor = file->readByte() & 15;
-	// debugC(1, kFreescapeDebugParser, "Colors: %d %d", skyColor, groundColor);
-
-	// Graphics::PixelBuffer *palette = getPalette(areaNumber, ci1, ci2, skyColor, groundColor, ncolors);
 
 	debugC(1, kFreescapeDebugParser, "Area %d", areaNumber);
 	debugC(1, kFreescapeDebugParser, "Flags: %d Objects: %d", areaFlags, numberOfObjects);
@@ -593,12 +600,17 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 		byte idx = readField(file, 8);
 		if (isAmiga())
 			name = _messagesList[idx + 51];
+		if (isSpectrum())
+			name = areaNumber == 255 ? "GLOBAL" : _messagesList[idx + 17];
 		else
 			name = _messagesList[idx + 41];
-		extraColor[0] = readField(file, 8);
-		extraColor[1] = readField(file, 8);
-		extraColor[2] = readField(file, 8);
-		extraColor[3] = readField(file, 8);
+
+		if (isDOS()) {
+			extraColor[0] = readField(file, 8);
+			extraColor[1] = readField(file, 8);
+			extraColor[2] = readField(file, 8);
+			extraColor[3] = readField(file, 8);
+		}
 
 		if (isAmiga()) {
 			// TODO
@@ -711,17 +723,29 @@ void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offse
 	debugC(1, kFreescapeDebugParser, "Start area: %d", startArea);
 	uint8 startEntrance = readField(file, 8);
 	debugC(1, kFreescapeDebugParser, "Entrace area: %d", startEntrance);
-	readField(file, 8); // Unknown
 
-	uint8 initialEnergy1 = readField(file, 8);
-	uint8 initialShield1 = readField(file, 8);
-	uint8 initialEnergy2 = readField(file, 8);
-	uint8 initialShield2 = readField(file, 8);
+	uint8 initialEnergy1 = 0;
+	uint8 initialShield1 = 0;
+	uint8 initialEnergy2 = 0;
+	uint8 initialShield2 = 0;
+
+	if (isCastle() && isSpectrum()) {
+		initialShield1 = readField(file, 8);
+	} else {
+		readField(file, 8); // Unknown
+
+		initialEnergy1 = readField(file, 8);
+		initialShield1 = readField(file, 8);
+		initialEnergy2 = readField(file, 8);
+		initialShield2 = readField(file, 8);
+	}
 
 	debugC(1, kFreescapeDebugParser, "Initial levels of energy: %d and shield: %d", initialEnergy1, initialShield1);
 	debugC(1, kFreescapeDebugParser, "Initial levels of energy: %d and shield: %d", initialEnergy2, initialShield2);
 
-	if (isAmiga() || isAtariST())
+	if (isCastle() && isSpectrum())
+		file->seek(offset + 0x6);
+	else if (isAmiga() || isAtariST())
 		file->seek(offset + 0x14);
 	else
 		file->seek(offset + 0xa);
@@ -749,7 +773,9 @@ void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offse
 		_colorMap.push_back(entry - 3);
 	}
 
-	if (isAmiga() || isAtariST())
+	if (isCastle() && isSpectrum())
+		file->seek(offset + 0x42);
+	else if (isAmiga() || isAtariST())
 		file->seek(offset + 0x8c);
 	else
 		file->seek(offset + 0x46);
@@ -822,11 +848,12 @@ void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offse
 	else if (isEclipse())
 		_initialCountdown = 7200; // 02:00:00
 
-	if (isAmiga() || isAtariST())
+	if (isCastle() && isSpectrum())
+		file->seek(offset + 0x4f);
+	else if (isAmiga() || isAtariST())
 		file->seek(offset + 0x190);
 	else
 		file->seek(offset + 0xc8);
-	// file->seek(offset + 0x4f); //CPC
 
 	debugC(1, kFreescapeDebugParser, "areas index at: %lx", long(file->pos()));
 	uint16 *fileOffsetForArea = new uint16[numberOfAreas];
diff --git a/engines/freescape/module.mk b/engines/freescape/module.mk
index f1dc467271c..72f4c10e3fe 100644
--- a/engines/freescape/module.mk
+++ b/engines/freescape/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS := \
 	games/castle/castle.o \
 	games/castle/amiga.o \
 	games/castle/dos.o \
+	games/castle/zx.o \
 	games/dark/amiga.o \
 	games/dark/atari.o \
 	games/dark/cpc.o \




More information about the Scummvm-git-logs mailing list