[Scummvm-git-logs] scummvm master -> d5c1318d1f84ee70165e277ee88580a0a37a5ba4

neuromancer noreply at scummvm.org
Sat Jul 13 18:07:26 UTC 2024


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

Summary:
4a2bf42189 FREESCAPE: improved group handling and execution
b5d035c9cb FREESCAPE: removed hardcoded castle font and load the proper one in the dos release
c8e8e5edff FREESCAPE: improved rendering of fonts in castle for dos
db19b6ced9 FREESCAPE: basic key management in castle for zx
7584e354b3 FREESCAPE: added missing entrance in castle for zx
f08ad64ea9 FREESCAPE: language implementation changes for castle in zx
1440ef9e12 FREESCAPE: loading/showing some riddles in castle in zx
d5c1318d1f FREESCAPE: perspective improvements and color fixes for castle in zx


Commit: 4a2bf421896c660ece95e9ae25089681c85f8e74
    https://github.com/scummvm/scummvm/commit/4a2bf421896c660ece95e9ae25089681c85f8e74
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: improved group handling and execution

Changed paths:
    engines/freescape/objects/group.cpp
    engines/freescape/objects/group.h


diff --git a/engines/freescape/objects/group.cpp b/engines/freescape/objects/group.cpp
index d326da5cf59..8569d312a1c 100644
--- a/engines/freescape/objects/group.cpp
+++ b/engines/freescape/objects/group.cpp
@@ -31,8 +31,7 @@ const Common::Array<AnimationOpcode *> operations_) {
 	_objectID = objectID_;
 	_flags = flags_;
 	_scale = 0;
-	_active = false;
-	_finished = false;
+	_active = true;
 	_step = 0;
 
 	for (int i = 0; i < int(objectIds_.size()); i++) {
@@ -97,39 +96,46 @@ void Group::assemble(int index) {
 }
 
 void Group::run() {
-	if (_finished || _step < 0)
+	if (!_active)
 		return;
 
 	int opcode = _operations[_step]->opcode;
 	debugC(1, kFreescapeDebugCode, "Executing opcode 0x%x at step %d", opcode, _step);
 	if (opcode == 0x80 || opcode == 0xff) {
-		reset();
+		debugC(1, kFreescapeDebugCode, "Executing group rewind");
+		_active = true;
+		_step = -1;
+		//reset();
 	} else if (opcode == 0x01) {
 		debugC(1, kFreescapeDebugCode, "Executing group condition %s", _operations[_step]->conditionSource.c_str());
 		g_freescape->executeCode(_operations[_step]->condition, false, true, false, false);
+	} else if (opcode == 0x04) {
+		debugC(1, kFreescapeDebugCode, "Ignoring unknown opcode");
+	} else if (opcode == 0x10) {
+		uint32 groupSize = _objects.size();
+		for (uint32 i = 0; i < groupSize ; i++)
+			assemble(i);
+		_active = false;
+		_step++;
 	} else if (opcode == 0x6e) {
 		uint32 groupSize = _objects.size();
 		for (uint32 i = 0; i < groupSize ; i++)
 			_objects[i]->makeInvisible();
-	} else {
+	} else if (opcode == 0x68) {
+		debugC(1, kFreescapeDebugCode, "Ignoring unknown opcode");
+	} else if (opcode == 0x0) {
+		debugC(1, kFreescapeDebugCode, "Executing group assemble");
 		uint32 groupSize = _objects.size();
 		for (uint32 i = 0; i < groupSize ; i++)
 			assemble(i);
-
-		if (opcode == 0x10) {
-			if (!_active) {
-				_step = -1;
-				return;
-			}
-		}
+	} else {
+		debug("Unknown opcode 0x%x", opcode);
+		assert(0);
 	}
 }
 
 void Group::reset() {
-	_step = -1;
-	_active = false;
-	_finished = false;
-	uint32 groupSize = _objects.size();
+	/*uint32 groupSize = _objects.size();
 	for (uint32 i = 0; i < groupSize ; i++) {
 		GeometricObject *gobj = (GeometricObject *)_objects[i];
 		if (GeometricObject::isPolygon(_objects[i]->getType())) {
@@ -137,10 +143,13 @@ void Group::reset() {
 			gobj->restoreOrdinates();
 			//gobj->makeInvisible();
 		}
-	}
+	}*/
 }
 
 void Group::draw(Renderer *gfx, float offset) {
+	if (!_active)
+		return;
+
 	uint32 groupSize = _objects.size();
 	for (uint32 i = 0; i < groupSize ; i++) {
 		if (!_objects[i]->isDestroyed() && !_objects[i]->isInvisible())
@@ -149,14 +158,15 @@ void Group::draw(Renderer *gfx, float offset) {
 }
 
 void Group::step() {
-	if (_finished)
+	if (!_active)
 		return;
 
 	debugC(1, kFreescapeDebugCode, "Stepping group %d", _objectID);
 	if (_step < int(_operations.size() - 1))
 		_step++;
 	else {
-		_finished = true;
+		_active = false;
+		_step = -1;
 	}
 }
 
diff --git a/engines/freescape/objects/group.h b/engines/freescape/objects/group.h
index 3232098e9f8..3e652f62612 100644
--- a/engines/freescape/objects/group.h
+++ b/engines/freescape/objects/group.h
@@ -57,13 +57,12 @@ public:
 	int _scale;
 	int _step;
 	bool _active;
-	bool _finished;
 
 	ObjectType getType() override { return ObjectType::kGroupType; };
 	bool isDrawable() override { return true; }
 	void draw(Renderer *gfx, float offset = 0.0) override;
 	void scale(int scale_) override { _scale = scale_; };
-	bool isActive() { return !isDestroyed() && !isInvisible() && _step > 0 && !_finished; };
+	bool isActive() { return !isDestroyed() && !isInvisible() && _step > 0 && _active; };
 	Object *duplicate() override;
 };
 


Commit: b5d035c9cbe8b1cd247e7c8da218e7df8c0fb6dc
    https://github.com/scummvm/scummvm/commit/b5d035c9cbe8b1cd247e7c8da218e7df8c0fb6dc
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: removed hardcoded castle font and load the proper one in the dos release

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


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index d071d5a8124..6391b90d2ca 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -57,68 +57,6 @@ CastleEngine::~CastleEngine() {
 	}
 }
 
-byte kFreescapeCastleFont[] = {
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x1c, 0x1c, 0x1c, 0x18, 0x18, 0x00, 0x18, 0x18,
-	0x66, 0x66, 0x44, 0x22, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x00,
-	0x10, 0x54, 0x38, 0xfe, 0x38, 0x54, 0x10, 0x00,
-	0x3c, 0x42, 0x9d, 0xb1, 0xb1, 0x9d, 0x42, 0x3c,
-	0x78, 0xcc, 0xcc, 0x78, 0xdb, 0xcf, 0xce, 0x7b,
-	0x30, 0x30, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00,
-	0x10, 0x20, 0x40, 0x40, 0x40, 0x40, 0x20, 0x10,
-	0x10, 0x08, 0x04, 0x04, 0x04, 0x04, 0x08, 0x10,
-	0x10, 0x54, 0x38, 0xfe, 0x38, 0x54, 0x10, 0x00,
-	0x00, 0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10,
-	0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18,
-	0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
-	0x18, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x18,
-	0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
-	0x9e, 0x61, 0x01, 0x7e, 0xe0, 0xc6, 0xe3, 0xfe,
-	0xee, 0x73, 0x03, 0x3e, 0x03, 0x01, 0x7f, 0xe6,
-	0x0e, 0x1c, 0x38, 0x71, 0xfd, 0xe6, 0x0c, 0x0c,
-	0xfd, 0x86, 0x80, 0x7e, 0x07, 0x63, 0xc7, 0x7c,
-	0x3d, 0x66, 0xc0, 0xf0, 0xfc, 0xc6, 0x66, 0x3c,
-	0xb3, 0x4e, 0x06, 0x0c, 0x0c, 0x18, 0x18, 0x3c,
-	0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc2, 0xfe, 0x4c,
-	0x3c, 0x4e, 0xc6, 0xc6, 0x4e, 0x36, 0x46, 0x3c,
-	0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00,
-	0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x08, 0x10,
-	0x03, 0x0c, 0x30, 0xc0, 0x30, 0x0c, 0x03, 0x00,
-	0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
-	0xc0, 0x30, 0x0c, 0x03, 0x0c, 0x30, 0xc0, 0x00,
-	0x7c, 0xc6, 0x06, 0x0c, 0x30, 0x30, 0x00, 0x30,
-	0x00, 0x08, 0x0c, 0xfe, 0xff, 0xfe, 0x0c, 0x08,
-	0x1e, 0x1c, 0x1e, 0x66, 0xbe, 0x26, 0x43, 0xe3,
-	0xee, 0x73, 0x23, 0x3e, 0x23, 0x21, 0x7f, 0xe6,
-	0x39, 0x6e, 0xc6, 0xc0, 0xc0, 0xc2, 0x63, 0x3e,
-	0xec, 0x72, 0x23, 0x23, 0x23, 0x23, 0x72, 0xec,
-	0xce, 0x7f, 0x61, 0x6c, 0x78, 0x61, 0x7f, 0xce,
-	0xce, 0x7f, 0x61, 0x6c, 0x78, 0x60, 0x60, 0xf0,
-	0x3d, 0x66, 0xc0, 0xc1, 0xce, 0xc6, 0x66, 0x3c,
-	0xe7, 0x66, 0x66, 0x6e, 0x76, 0x66, 0x66, 0xe7,
-	0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x66,
-	0x33, 0x1e, 0x0c, 0x8c, 0x4c, 0xcc, 0xdc, 0x78,
-	0xf2, 0x67, 0x64, 0x68, 0x7e, 0x66, 0x66, 0xf3,
-	0xd8, 0x70, 0x60, 0x60, 0x66, 0x61, 0xf3, 0x7e,
-	0xc3, 0x66, 0x6e, 0x76, 0x56, 0x46, 0x46, 0xef,
-	0x87, 0x62, 0x72, 0x7a, 0x5e, 0x4e, 0x46, 0xe1,
-	0x18, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x18,
-	0xec, 0x72, 0x63, 0x63, 0x72, 0x6c, 0x60, 0xf0,
-	0x3c, 0x66, 0xc3, 0xc3, 0x66, 0x3c, 0x31, 0x1e,
-	0xec, 0x72, 0x63, 0x63, 0x76, 0x6c, 0x66, 0xf1,
-	0x79, 0x86, 0x80, 0x7e, 0x07, 0x63, 0xc7, 0x7c,
-	0x01, 0x7f, 0xfe, 0x98, 0x58, 0x18, 0x18, 0x3c,
-	0xf7, 0x62, 0x62, 0x62, 0x62, 0x62, 0xf2, 0x3c,
-	0xf3, 0x61, 0x72, 0x72, 0x32, 0x32, 0x1c, 0x3e,
-	0xc3, 0x62, 0x62, 0x6a, 0x6e, 0x76, 0x66, 0xc3,
-	0xf3, 0x72, 0x3c, 0x38, 0x1c, 0x3c, 0x4e, 0xcf,
-	0xe3, 0x72, 0x34, 0x38, 0x18, 0x18, 0x18, 0x3c,
-	0x7f, 0x87, 0x0e, 0x1c, 0x38, 0x71, 0xfd, 0xe6,
-};
-
 void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 	debugC(1, kFreescapeDebugMove, "Jumping to area: %d, entrance: %d", areaID, entranceID);
 
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index 310ac2dc4d6..bbfdbfe526c 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -55,6 +55,7 @@ public:
 private:
 	Common::SeekableReadStream *decryptFile(const Common::Path &filename);
 	void loadRiddles(Common::SeekableReadStream *file, int offset, int number);
+	void loadDOSFonts(Common::SeekableReadStream *file, int pos);
 	void drawFullscreenRiddleAndWait(uint16 riddle);
 	void drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics::Surface *surface);
 	void addGhosts();
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index 8486c62d02f..bee5b260320 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -51,6 +51,27 @@ Common::SeekableReadStream *CastleEngine::decryptFile(const Common::Path &filena
 extern byte kEGADefaultPalette[16][3];
 extern Common::MemoryReadStream *unpackEXE(Common::File &ms);
 
+void CastleEngine::loadDOSFonts(Common::SeekableReadStream *file, int pos) {
+	file->seek(pos);
+	byte *buffer = (byte *)malloc(sizeof(byte) * 59 * 8);
+
+	for (int i = 0; i < 59 * 8; i++) {
+		//debug("%lx", file->pos());
+		for (int j = 0; j < 4; j++) {
+			uint16 c = readField(file, 16);
+			if (j == 3) {
+				//debugN("0x%x, ", c);
+				assert(c < 256);
+				buffer[i] = c;
+			}
+		}
+		//debugN("\n");
+	}
+	debug("%lx", file->pos());
+	loadFonts(buffer, 59);
+	free(buffer);
+}
+
 void CastleEngine::loadAssetsDOSFullGame() {
 	Common::File file;
 	Common::SeekableReadStream *stream = nullptr;
@@ -62,6 +83,7 @@ void CastleEngine::loadAssetsDOSFullGame() {
 		stream = unpackEXE(file);
 		if (stream) {
 			loadSpeakerFxDOS(stream, 0x636d + 0x200, 0x63ed + 0x200);
+			loadDOSFonts(stream, 0x29696);
 		}
 
 		delete stream;
@@ -103,7 +125,6 @@ void CastleEngine::loadAssetsDOSFullGame() {
 				error("Invalid or unsupported language: %x", _language);
 		}
 
-		loadFonts(kFreescapeCastleFont, 59);
 		delete stream;
 
 		stream = decryptFile("CMEDF");
@@ -140,6 +161,7 @@ void CastleEngine::loadAssetsDOSDemo() {
 		stream = unpackEXE(file);
 		if (stream) {
 			loadSpeakerFxDOS(stream, 0x636d + 0x200, 0x63ed + 0x200);
+			loadDOSFonts(stream, 0x29696);
 		}
 
 		delete stream;
@@ -161,18 +183,8 @@ void CastleEngine::loadAssetsDOSDemo() {
 		file.close();
 
 		stream = decryptFile("CMLD"); // Only english
-		loadFonts(kFreescapeCastleFont, 59);
 		loadMessagesVariableSize(stream, 0x11, 164);
 		loadRiddles(stream, 0xaae, 10);
-
-		/*for (int i = 0; i < 16; i++) {
-			debug("%lx", stream->pos());
-			for (int j = 0; j < 16; j++) {
-				byte c = stream->readByte();
-				debugN("%x/%c", c, c);
-			}
-			debugN("\n");
-		}*/
 		delete stream;
 
 		stream = decryptFile("CDEDF");
@@ -183,9 +195,9 @@ void CastleEngine::loadAssetsDOSDemo() {
 		_areaMap[1]->addFloor();
 		_areaMap[2]->addFloor();
 		delete stream;
-		_background = loadBundledImage("background");
-		assert(_background);
-		_background->convertToInPlace(_gfx->_texturePixelFormat);
+		//_background = loadBundledImage("background");
+		//assert(_background);
+		//_background->convertToInPlace(_gfx->_texturePixelFormat);
 	} else
 		error("Not implemented yet");
 }
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index 569425b2933..585143e6b43 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -53,8 +53,8 @@ void CastleEngine::loadAssetsZXFullGame() {
 		error("Failed to open castlemaster.zx.data");
 
 	//loadMessagesFixedSize(&file, 0x4bc + 1, 16, 27);
-    loadFonts(kFreescapeCastleFont, 59);
-    loadMessagesVariableSize(&file, 0x4bd, 71);
+	loadFonts(&file, 0x1219, _font);
+	loadMessagesVariableSize(&file, 0x4bd, 71);
 
     load8bitBinary(&file, 0x6a3b, 16);
 	loadSpeakerFxZX(&file, 0xc91, 0xccd);


Commit: c8e8e5edff346b3dd01b41efe7c844338d905e93
    https://github.com/scummvm/scummvm/commit/c8e8e5edff346b3dd01b41efe7c844338d905e93
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: improved rendering of fonts in castle for dos

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


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index deca21116fd..f863bf8fa21 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -936,6 +936,7 @@ void FreescapeEngine::drawStringInSurface(const Common::String &str, int x, int
 	if (!_fontLoaded)
 		return;
 	Common::String ustr = str;
+	uint32 transparent = _gfx->_texturePixelFormat.ARGBToColor(0, 0, 0, 0);
 	ustr.toUppercase();
 
 	int sizeX = 8;
@@ -948,9 +949,9 @@ void FreescapeEngine::drawStringInSurface(const Common::String &str, int x, int
 		int position = sizeX * sizeY * (offset + ustr[c] - 32);
 		for (int j = 0; j < sizeY; j++) {
 			for (int i = 0; i < sizeX; i++) {
-				if (_font.get(position + additional + j * 8 + i))
+				if (_font.get(position + additional + j * 8 + i) && fontColor != transparent)
 					surface->setPixel(x + 8 - i + sep * c, y + j, fontColor);
-				else
+				else if (backColor != transparent)
 					surface->setPixel(x + 8 - i + sep * c, y + j, backColor);
 			}
 		}
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 458e76a57b8..757e4d32502 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -443,8 +443,8 @@ public:
 	Common::StringArray _currentEphymeralMessages;
 	Common::BitArray _font;
 	bool _fontLoaded;
-	void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
-	void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
+	virtual void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
+	virtual void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0);
 	Graphics::Surface *drawStringsInSurface(const Common::Array<Common::String> &lines);
 
 	// Game state
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 6391b90d2ca..bb1004df5c4 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -331,6 +331,26 @@ void CastleEngine::drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics
 	drawFullscreenSurface(surface);
 }
 
+void CastleEngine::drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset) {
+	if (isSpectrum() || isCPC()) {
+		FreescapeEngine::drawStringInSurface(str, x, y, fontColor, backColor, surface, offset);
+		return;
+	}
+
+	uint32 transparent = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
+	uint32 yellow = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xFF, 0xFF, 0x00);
+	//uint32 green = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x80, 0x00);
+
+	_font = _fontPlane1;
+	FreescapeEngine::drawStringInSurface(str, x, y, fontColor, backColor, surface, offset);
+
+	_font = _fontPlane2;
+	FreescapeEngine::drawStringInSurface(str, x, y, yellow, transparent, surface, offset);
+
+	//_font = _fontPlane3;
+	//FreescapeEngine::drawStringInSurface(str, x, y, transparent, green, surface, offset);
+}
+
 void CastleEngine::drawEnergyMeter(Graphics::Surface *surface) {
 	uint32 back = 0;
 	uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index bbfdbfe526c..3788855a088 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -52,6 +52,13 @@ public:
 	Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
 
 	Common::StringArray _riddleList;
+	Common::BitArray _fontPlane1;
+	Common::BitArray _fontPlane2;
+	Common::BitArray _fontPlane3;
+
+	void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
+	//void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
+
 private:
 	Common::SeekableReadStream *decryptFile(const Common::Path &filename);
 	void loadRiddles(Common::SeekableReadStream *file, int offset, int number);
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index bee5b260320..4317b7147e3 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -53,23 +53,38 @@ extern Common::MemoryReadStream *unpackEXE(Common::File &ms);
 
 void CastleEngine::loadDOSFonts(Common::SeekableReadStream *file, int pos) {
 	file->seek(pos);
-	byte *buffer = (byte *)malloc(sizeof(byte) * 59 * 8);
+	byte *bufferPlane1 = (byte *)malloc(sizeof(byte) * 59 * 8);
+	byte *bufferPlane2 = (byte *)malloc(sizeof(byte) * 59 * 8);
+	byte *bufferPlane3 = (byte *)malloc(sizeof(byte) * 59 * 8);
 
 	for (int i = 0; i < 59 * 8; i++) {
 		//debug("%lx", file->pos());
 		for (int j = 0; j < 4; j++) {
 			uint16 c = readField(file, 16);
-			if (j == 3) {
-				//debugN("0x%x, ", c);
-				assert(c < 256);
-				buffer[i] = c;
+			assert(c < 256);
+			if (j == 1) {
+				bufferPlane1[i] = c;
+			} else if (j == 2) {
+				bufferPlane2[i] = c;
+			} else if (j == 3) {
+				bufferPlane3[i] = c;
 			}
 		}
 		//debugN("\n");
 	}
 	debug("%lx", file->pos());
-	loadFonts(buffer, 59);
-	free(buffer);
+	_fontPlane1.set_size(64 * 59);
+	_fontPlane1.set_bits(bufferPlane1);
+
+	_fontPlane2.set_size(64 * 59);
+	_fontPlane2.set_bits(bufferPlane2);
+
+	_fontPlane3.set_size(64 * 59);
+	_fontPlane3.set_bits(bufferPlane3);
+	_fontLoaded = true;
+	free(bufferPlane1);
+	free(bufferPlane2);
+	free(bufferPlane3);
 }
 
 void CastleEngine::loadAssetsDOSFullGame() {


Commit: db19b6ced93856bba502197e581e2e634e669946
    https://github.com/scummvm/scummvm/commit/db19b6ced93856bba502197e581e2e634e669946
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: basic key management in castle for zx

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


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index bb1004df5c4..4b2a3a09482 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -48,6 +48,9 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
 	_maxShield = 24;
 	_option = nullptr;
 	_optionTexture = nullptr;
+	_keysFrame = nullptr;
+
+	_numberKeys = 0;
 }
 
 CastleEngine::~CastleEngine() {
@@ -109,6 +112,7 @@ void CastleEngine::initGameState() {
 	_gameStateVars[k8bitVariableShield] = 16;
 	_gameStateVars[k8bitVariableEnergy] = 1;
 	_countdown = INT_MAX;
+	_numberKeys = 0;
 }
 
 void CastleEngine::endGame() {
@@ -454,6 +458,7 @@ void CastleEngine::updateTimeVariables() {
 	if (_gameStateVars[32] > 0) { // Key collected!
 		setGameBit(_gameStateVars[32]);
 		_gameStateVars[32] = 0;
+		_numberKeys++;
 	}
 }
 
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index 3788855a088..69c15e24c10 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -58,6 +58,10 @@ public:
 
 	void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
 	//void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
+	Graphics::Surface *loadFrames(Common::SeekableReadStream *file, int pos, int numFrames, uint32 back);
+
+	Graphics::Surface *_keysFrame;
+	int _numberKeys;
 
 private:
 	Common::SeekableReadStream *decryptFile(const Common::Path &filename);
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index 585143e6b43..62629518bdc 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -31,8 +31,37 @@ void CastleEngine::initZX() {
 	_viewArea = Common::Rect(64, 36, 256, 148);
 }
 
+Graphics::Surface *CastleEngine::loadFrames(Common::SeekableReadStream *file, int pos, int numFrames, uint32 back) {
+	Graphics::Surface *surface = new Graphics::Surface();
+	file->seek(pos);
+	int16 width = file->readByte();
+	int16 height = file->readByte();
+	surface->create(width * 8, height, _gfx->_texturePixelFormat);
+
+	/*byte mask =*/ file->readByte();
+
+	uint8 r, g, b;
+	_gfx->readFromPalette(7, r, g, b);
+	uint32 white = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+	surface->fillRect(Common::Rect(0, 0, width * 8, height), white);
+	/*int frameSize =*/ file->readUint16LE();
+
+	for (int i = 0; i < width * height; i++) {
+		byte color = file->readByte();
+		for (int n = 0; n < 8; n++) {
+			int y = i / width;
+			int x = (i % width) * 8 + (7 - n);
+			if ((color & (1 << n)))
+				surface->setPixel(x, y, back);
+		}
+	}
+	return surface;
+}
+
 void CastleEngine::loadAssetsZXFullGame() {
 	Common::File file;
+	uint8 r, g, b;
 
 	file.open("castlemaster.zx.title");
 	if (file.isOpen()) {
@@ -59,6 +88,11 @@ void CastleEngine::loadAssetsZXFullGame() {
     load8bitBinary(&file, 0x6a3b, 16);
 	loadSpeakerFxZX(&file, 0xc91, 0xccd);
 
+	loadColorPalette();
+	_gfx->readFromPalette(2, r, g, b);
+	uint32 red = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+	_keysFrame = loadFrames(&file, 0xdf7, 1, red);
+
 	for (auto &it : _areaMap) {
 		it._value->addStructure(_areaMap[255]);
 		for (int16 id = 136; id < 140; id++) {
@@ -98,6 +132,10 @@ void CastleEngine::drawZXUI(Graphics::Surface *surface) {
 	} else
 		drawStringInSurface(_currentArea->_name, 120, 179, front, black, surface);
 
+	for (int k = 0; k < _numberKeys; k++) {
+		surface->copyRectToSurface((const Graphics::Surface)*_keysFrame, 99 - k * 4, 177, Common::Rect(0, 0, 6, 11));
+	}
+
 	//drawEnergyMeter(surface);
 }
 


Commit: 7584e354b3f0e871e12351f190d3b8f8df286cc0
    https://github.com/scummvm/scummvm/commit/7584e354b3f0e871e12351f190d3b8f8df286cc0
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: added missing entrance in castle for zx

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


diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index 62629518bdc..666eb173c9f 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -95,6 +95,8 @@ void CastleEngine::loadAssetsZXFullGame() {
 
 	for (auto &it : _areaMap) {
 		it._value->addStructure(_areaMap[255]);
+
+		it._value->addObjectFromArea(164, _areaMap[255]);
 		for (int16 id = 136; id < 140; id++) {
 			it._value->addObjectFromArea(id, _areaMap[255]);
 		}


Commit: f08ad64ea9ec5914a7a9633bbe8aa05dffdadb7b
    https://github.com/scummvm/scummvm/commit/f08ad64ea9ec5914a7a9633bbe8aa05dffdadb7b
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: language implementation changes for castle in zx

Changed paths:
    engines/freescape/freescape.h
    engines/freescape/games/castle/castle.cpp
    engines/freescape/language/instruction.cpp
    engines/freescape/loaders/8bitBinaryLoader.cpp
    engines/freescape/objects/entrance.h


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 757e4d32502..cae79e6527d 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -337,6 +337,7 @@ public:
 	Math::Vector3d _objExecutingCodeSize;
 	virtual void executeMovementConditions();
 	bool executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated);
+	void executeEntranceConditions(Entrance *entrance);
 	void executeLocalGlobalConditions(bool shot, bool collided, bool timer);
 	void executeCode(FCLInstructionVector &code, bool shot, bool collided, bool timer, bool activated);
 
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 4b2a3a09482..a7623008355 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -103,6 +103,9 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 
 	swapPalette(areaID);
 	resetInput();
+	Entrance *entrance = (Entrance *)_currentArea->entranceWithID(entranceID);
+	assert(entrance);
+	executeEntranceConditions(entrance);
 }
 
 void CastleEngine::initGameState() {
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index e70d0d69f16..8e4fee2183f 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -89,6 +89,16 @@ Token::Type FCLInstruction::getType() {
 	return _type;
 }
 
+void FreescapeEngine::executeEntranceConditions(Entrance *entrance) {
+	if (!entrance->_conditionSource.empty()) {
+		_firstSound = true;
+		_syncSound = false;
+
+		debugC(1, kFreescapeDebugCode, "Executing entrance condition with collision flag: %s", entrance->_conditionSource.c_str());
+		executeCode(entrance->_condition, false, true, false, false);
+	}
+}
+
 bool FreescapeEngine::executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated) {
 	bool executed = false;
 	assert(obj != nullptr);
@@ -161,8 +171,12 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
 			break;
 
 		case Token::VARNOTEQ:
-			if (executeEndIfNotEqual(instruction))
-				ip = codeSize;
+			if (executeEndIfNotEqual(instruction)) {
+				if (isCastle())
+					skip = true;
+				else
+					ip = codeSize;
+			}
 			break;
 		case Token::IFGTEQ:
 			skip = !checkIfGreaterOrEqual(instruction);
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 3bf23a60718..8927d1b854c 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -424,14 +424,15 @@ Object *FreescapeEngine::load8bitObject(Common::SeekableReadStream *file) {
 	} break;
 	case kEntranceType: {
 		debugC(1, kFreescapeDebugParser, "rotation: %f %f %f", v.x(), v.y(), v.z());
+		FCLInstructionVector instructions;
+		Common::String conditionSource;
+
 		if (byteSizeOfObject > 0) {
 			if (!isCastle()) {
 				debugC(1, kFreescapeDebugParser, "Warning: extra %d bytes in entrance", byteSizeOfObject);
 				while (byteSizeOfObject--)
 					debugC(1, kFreescapeDebugParser, "b: %x", readField(file, 8));
 			} else {
-				FCLInstructionVector instructions;
-				Common::String conditionSource;
 				Common::Array<uint16> conditionArray = readArray(file, byteSizeOfObject);
 				conditionSource = detokenise8bitCondition(conditionArray, instructions, isAmiga() || isAtariST());
 				debugC(1, kFreescapeDebugParser, "Entrance condition:");
@@ -445,7 +446,9 @@ Object *FreescapeEngine::load8bitObject(Common::SeekableReadStream *file) {
 		return new Entrance(
 			objectID,
 			32 * position,
-			5 * v); // rotation
+			5 * v, // rotation
+			instructions,
+			conditionSource);
 	} break;
 
 	case kSensorType: {
diff --git a/engines/freescape/objects/entrance.h b/engines/freescape/objects/entrance.h
index af7bca54f3c..fb0ed17c5c5 100644
--- a/engines/freescape/objects/entrance.h
+++ b/engines/freescape/objects/entrance.h
@@ -29,15 +29,22 @@
 
 namespace Freescape {
 
+extern FCLInstructionVector *duplicateCondition(FCLInstructionVector *condition);
+
 class Entrance : public Object {
 public:
 	Entrance(
 		uint16 objectID_,
 		const Math::Vector3d &origin_,
-		const Math::Vector3d &rotation_) {
+		const Math::Vector3d &rotation_,
+		FCLInstructionVector conditionInstructions_,
+		Common::String conditionSource_) {
 		_objectID = objectID_;
 		_origin = origin_;
 		_rotation = rotation_;
+
+		_condition = conditionInstructions_;
+		_conditionSource = conditionSource_;
 		_flags = 0;
 	}
 	virtual ~Entrance() {}
@@ -45,11 +52,19 @@ public:
 	bool isDrawable() override { return false; }
 	bool isPlanar() override { return true; }
 	void scale(int factor) override { _origin = _origin / factor; };
-	Object *duplicate() override { return (new Entrance(_objectID, _origin, _rotation)); };
+	Object *duplicate() override {
+		FCLInstructionVector *conditionCopy = nullptr;
+		conditionCopy = duplicateCondition(&_condition);
+		assert(conditionCopy);
+		return (new Entrance(_objectID, _origin, _rotation, *conditionCopy, _conditionSource));
+	};
 
 	ObjectType getType() override { return ObjectType::kEntranceType; };
 	Math::Vector3d getRotation() { return _rotation; }
 
+	Common::String _conditionSource;
+	FCLInstructionVector _condition;
+
 	void draw(Freescape::Renderer *gfx, float offset = 0.0) override { error("cannot render Entrance"); };
 };
 


Commit: 1440ef9e12138cfbf9eddd79d6a78a43a27a43a4
    https://github.com/scummvm/scummvm/commit/1440ef9e12138cfbf9eddd79d6a78a43a27a43a4
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: loading/showing some riddles in castle in zx

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


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index a7623008355..2427a493493 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -188,11 +188,25 @@ void CastleEngine::loadRiddles(Common::SeekableReadStream *file, int offset, int
 		for (int j = 0; j < 6; j++) {
 			int size = file->readByte();
 			debugC(1, kFreescapeDebugParser, "size: %d (max 22?)", size);
+
+			Common::String message = "";
+			if (size == 255) {
+				size = 19;
+				while (size-- > 0)
+					message = message + "*";
+
+				_riddleList.push_back(message);
+				debugC(1, kFreescapeDebugParser, "extra byte: %x", file->readByte());
+				debugC(1, kFreescapeDebugParser, "extra byte: %x", file->readByte());
+				debugC(1, kFreescapeDebugParser, "'%s'", message.c_str());
+				continue;
+			}
+
 			//if (size > 22)
 			//	size = 22;
 			int padSpaces = (22 - size) / 2;
 			debugC(1, kFreescapeDebugParser, "extra byte: %x", file->readByte());
-			Common::String message = "";
+
 			int k = padSpaces;
 
 			if (size > 0) {
@@ -235,24 +249,26 @@ void CastleEngine::loadRiddles(Common::SeekableReadStream *file, int offset, int
 
 void CastleEngine::drawFullscreenRiddleAndWait(uint16 riddle) {
 	_savedScreen = _gfx->getScreenshot();
-	uint32 color = 0;
+	int frontColor = 6;
+	int backColor = 0;
 	switch (_renderMode) {
 		case Common::kRenderCPC:
-			color = 14;
+			backColor = 14;
 			break;
 		case Common::kRenderCGA:
-			color = 1;
+			backColor = 1;
 			break;
 		case Common::kRenderZX:
-			color = 6;
+			backColor = 0;
+			frontColor = 7;
 			break;
 		default:
-			color = 14;
+			backColor = 14;
 	}
 	uint8 r, g, b;
-	_gfx->readFromPalette(6, r, g, b);
+	_gfx->readFromPalette(frontColor, r, g, b);
 	uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
-	_gfx->readFromPalette(color, r, g, b);
+	_gfx->readFromPalette(backColor, r, g, b);
 	uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
 
 	Graphics::Surface *surface = new Graphics::Surface();
@@ -311,12 +327,26 @@ void CastleEngine::drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics
 	uint32 grey = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x60, 0x60, 0x60);
 	uint32 frame = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xA7, 0xA7, 0xA7);
 
+	Common::Rect outerFrame(47, 47, 271, 147);
+	Common::Rect innerFrame(53, 53, 266, 141);
+
+	if (isDOS()) {
+		black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
+		grey = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x60, 0x60, 0x60);
+		frame = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xA7, 0xA7, 0xA7);
+	} else {
+		outerFrame = Common::Rect(67, 47, 251, 143 - 5);
+		innerFrame = Common::Rect(70, 49, 249, 141 - 5);
+		grey = noColor;
+		frame = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xD8, 0xD8, 0xD8);
+	}
+
 	surface->fillRect(_fullscreenViewArea, noColor);
 	surface->fillRect(_viewArea, black);
 
-	surface->fillRect(Common::Rect(47, 47, 271, 147), grey);
-	surface->frameRect(Common::Rect(47, 47, 271, 147), frame);
-	surface->frameRect(Common::Rect(53, 53, 266, 141), frame);
+	surface->fillRect(outerFrame, grey);
+	surface->frameRect(outerFrame, frame);
+	surface->frameRect(innerFrame, frame);
 
 	surface->fillRect(Common::Rect(54, 54, 265, 140), back);
 	int x = 0;
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index 666eb173c9f..092d760aec4 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -81,6 +81,7 @@ void CastleEngine::loadAssetsZXFullGame() {
 	if (!file.isOpen())
 		error("Failed to open castlemaster.zx.data");
 
+	loadRiddles(&file, 0x1460 - 1 - 3, 8);
 	//loadMessagesFixedSize(&file, 0x4bc + 1, 16, 27);
 	loadFonts(&file, 0x1219, _font);
 	loadMessagesVariableSize(&file, 0x4bd, 71);


Commit: d5c1318d1f84ee70165e277ee88580a0a37a5ba4
    https://github.com/scummvm/scummvm/commit/d5c1318d1f84ee70165e277ee88580a0a37a5ba4
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-13T20:08:49+02:00

Commit Message:
FREESCAPE: perspective improvements and color fixes for castle in zx

Changed paths:
    engines/freescape/freescape.cpp
    engines/freescape/freescape.h
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/castle/zx.cpp
    engines/freescape/gfx.h
    engines/freescape/gfx_opengl.cpp
    engines/freescape/gfx_opengl.h
    engines/freescape/gfx_opengl_shaders.cpp
    engines/freescape/gfx_opengl_shaders.h
    engines/freescape/gfx_tinygl.cpp
    engines/freescape/gfx_tinygl.h


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index f863bf8fa21..88627125260 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -139,6 +139,8 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
 	_lastFrame = 0;
 	_nearClipPlane = 2;
 	_farClipPlane = 8192 + 1802; // Added some extra distance to avoid flickering
+	_yminValue = -0.625;
+	_ymaxValue = 0.625;
 
 	// These depends on the specific game
 	_playerHeight = 0;
@@ -387,7 +389,7 @@ void FreescapeEngine::drawFrame() {
 	if (_currentArea->isOutside())
 		farClipPlane *= 100;
 
-	_gfx->updateProjectionMatrix(90.0, _nearClipPlane, farClipPlane);
+	_gfx->updateProjectionMatrix(90.0, _yminValue, _ymaxValue, _nearClipPlane, farClipPlane);
 	_gfx->positionCamera(_position, _position + _cameraFront);
 
 	if (_underFireFrames > 0) {
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index cae79e6527d..5fb8f610fd2 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -417,6 +417,8 @@ public:
 	Math::Vector3d _scaleVector;
 	float _nearClipPlane;
 	float _farClipPlane;
+	float _yminValue;
+	float _ymaxValue;
 
 	// Text messages and Fonts
 	void insertTemporaryMessage(const Common::String message, int deadline);
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 2427a493493..ee2eaebf80d 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
 	_stepUpDistance = 32;
 	_maxFallingDistance = 8192;
 	_maxShield = 24;
+
 	_option = nullptr;
 	_optionTexture = nullptr;
 	_keysFrame = nullptr;
@@ -102,6 +103,8 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 	}
 
 	swapPalette(areaID);
+	if (isSpectrum() || isCPC())
+		_gfx->_paperColor = 0;
 	resetInput();
 	Entrance *entrance = (Entrance *)_currentArea->entranceWithID(entranceID);
 	assert(entrance);
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index 092d760aec4..61cc6c48c2f 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -29,6 +29,8 @@ namespace Freescape {
 
 void CastleEngine::initZX() {
 	_viewArea = Common::Rect(64, 36, 256, 148);
+	_yminValue = -1;
+	_ymaxValue = 1;
 }
 
 Graphics::Surface *CastleEngine::loadFrames(Common::SeekableReadStream *file, int pos, int numFrames, uint32 back) {
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 7c4748d660d..8c08b4cf615 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -150,7 +150,7 @@ public:
 	 */
 
 	virtual void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest) = 0;
-	virtual void updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) = 0;
+	virtual void updateProjectionMatrix(float fov, float yminValue, float ymaxValue, float nearClipPlane, float farClipPlane) = 0;
 
 	Math::Matrix4 getMvpMatrix() const { return _mvpMatrix; }
 	virtual Graphics::Surface *getScreenshot() = 0;
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 058ba9384c0..98534485b72 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -191,7 +191,7 @@ void OpenGLRenderer::drawSkybox(Texture *texture, Math::Vector3d camera) {
 	glFlush();
 }
 
-void OpenGLRenderer::updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) {
+void OpenGLRenderer::updateProjectionMatrix(float fov, float yminValue, float ymaxValue, float nearClipPlane, float farClipPlane) {
 	glMatrixMode(GL_PROJECTION);
 	glLoadIdentity();
 	// Determining xmaxValue and ymaxValue still needs some work for matching the 3D view in freescape games
@@ -202,7 +202,7 @@ void OpenGLRenderer::updateProjectionMatrix(float fov, float nearClipPlane, floa
 	// debug("max values: %f %f", xmaxValue, ymaxValue);
 
 	glFrustum(xmaxValue, -xmaxValue, -ymaxValue, ymaxValue, nearClipPlane, farClipPlane);*/
-	glFrustum(1.5, -1.5, -0.625, 0.625, nearClipPlane, farClipPlane);
+	glFrustum(1.5, -1.5, yminValue, ymaxValue, nearClipPlane, farClipPlane);
 	glMatrixMode(GL_MODELVIEW);
 	glLoadIdentity();
 }
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index 731d8742a55..78a347aed23 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -88,7 +88,7 @@ public:
 	virtual void setViewport(const Common::Rect &rect) override;
 	virtual Common::Point nativeResolution() override;
 	virtual void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest) override;
-	virtual void updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) override;
+	virtual void updateProjectionMatrix(float fov, float yminValue, float ymaxValue, float nearClipPlane, float farClipPlane) override;
 
 	virtual void useColor(uint8 r, uint8 g, uint8 b) override;
 	virtual void polygonOffset(bool enabled) override;
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index 5287e587337..8e9da82aeec 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -137,13 +137,13 @@ void OpenGLShaderRenderer::drawTexturedRect2D(const Common::Rect &screenRect, co
 	_bitmapShader->unbind();
 }
 
-void OpenGLShaderRenderer::updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) {
+void OpenGLShaderRenderer::updateProjectionMatrix(float fov, float yminValue, float ymaxValue, float nearClipPlane, float farClipPlane) {
 	// Determining xmaxValue and ymaxValue still needs some work for matching the 3D view in freescape games
 	/*float aspectRatio = _screenW / (float)_screenH;
 	float xmaxValue = nearClipPlane * tan(Common::deg2rad(fov) / 2);
 	float ymaxValue = xmaxValue / aspectRatio;
 	_projectionMatrix = Math::makeFrustumMatrix(xmaxValue, -xmaxValue, -ymaxValue, ymaxValue, nearClipPlane, farClipPlane);*/
-	_projectionMatrix = Math::makeFrustumMatrix(1.5, -1.5, -0.625, 0.625, nearClipPlane, farClipPlane);
+	_projectionMatrix = Math::makeFrustumMatrix(1.5, -1.5, yminValue, ymaxValue, nearClipPlane, farClipPlane);
 }
 
 void OpenGLShaderRenderer::positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest) {
diff --git a/engines/freescape/gfx_opengl_shaders.h b/engines/freescape/gfx_opengl_shaders.h
index abd0b2b0218..9cff7bca06e 100644
--- a/engines/freescape/gfx_opengl_shaders.h
+++ b/engines/freescape/gfx_opengl_shaders.h
@@ -69,7 +69,7 @@ public:
 	virtual void setViewport(const Common::Rect &rect) override;
 	virtual Common::Point nativeResolution() override;
 	virtual void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest) override;
-	virtual void updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) override;
+	virtual void updateProjectionMatrix(float fov, float yminValue, float ymaxValue, float nearClipPlane, float farClipPlane) override;
 
 	virtual void useColor(uint8 r, uint8 g, uint8 b) override;
 	virtual void polygonOffset(bool enabled) override;
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index 87d5e658947..84d27d31e1b 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -96,7 +96,7 @@ void TinyGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Co
 	tglBlit(((TinyGLTexture *)texture)->getBlitTexture(), transform);
 }
 
-void TinyGLRenderer::updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) {
+void TinyGLRenderer::updateProjectionMatrix(float fov, float yminValue, float ymaxValue, float nearClipPlane, float farClipPlane) {
 	tglMatrixMode(TGL_PROJECTION);
 	tglLoadIdentity();
 
@@ -108,7 +108,7 @@ void TinyGLRenderer::updateProjectionMatrix(float fov, float nearClipPlane, floa
 	// debug("max values: %f %f", xmaxValue, ymaxValue);
 
 	tglFrustumf(xmaxValue, -xmaxValue, -ymaxValue, ymaxValue, nearClipPlane, farClipPlane);*/
-	tglFrustumf(1.5, -1.5, -0.625, 0.625, nearClipPlane, farClipPlane);
+	tglFrustumf(1.5, -1.5, yminValue, ymaxValue, nearClipPlane, farClipPlane);
 	tglMatrixMode(TGL_MODELVIEW);
 	tglLoadIdentity();
 }
diff --git a/engines/freescape/gfx_tinygl.h b/engines/freescape/gfx_tinygl.h
index 8ed7ea4ceb7..e2208644461 100644
--- a/engines/freescape/gfx_tinygl.h
+++ b/engines/freescape/gfx_tinygl.h
@@ -50,7 +50,7 @@ public:
 	virtual void clear(uint8 r, uint8 g, uint8 b, bool ignoreViewport = false) override;
 	virtual void setViewport(const Common::Rect &rect) override;
 	virtual void positionCamera(const Math::Vector3d &pos, const Math::Vector3d &interest) override;
-	virtual void updateProjectionMatrix(float fov, float nearClipPlane, float farClipPlane) override;
+	virtual void updateProjectionMatrix(float fov, float yminValue, float ymaxValue, float nearClipPlane, float farClipPlane) override;
 
 	virtual void useColor(uint8 r, uint8 g, uint8 b) override;
 	virtual void polygonOffset(bool enabled) override;




More information about the Scummvm-git-logs mailing list