[Scummvm-git-logs] scummvm master -> 46667ccddc157f58bf64e61fa3c0b427abfd4e82

neuromancer noreply at scummvm.org
Thu Apr 27 19:05:43 UTC 2023


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

Summary:
4e53bb7eef FREESCAPE: correctly print the SETVAR opcode
5894cda45f FREESCAPE: refactored clear code as drawBackground
a7d96804de FREESCAPE: improved image reading for castle in DOS/EGA
8f218f398d FREESCAPE: improved border palette for castle in DOS/EGA
8473046fc8 FREESCAPE: make sure the floor is available in area 2 of castle
46667ccddc FREESCAPE: better rendering of EGA colors in castle


Commit: 4e53bb7eef70112193a24bf173946f09159d6eba
    https://github.com/scummvm/scummvm/commit/4e53bb7eef70112193a24bf173946f09159d6eba
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-27T20:35:03+02:00

Commit Message:
FREESCAPE: correctly print the SETVAR opcode

Changed paths:
    engines/freescape/language/8bitDetokeniser.cpp


diff --git a/engines/freescape/language/8bitDetokeniser.cpp b/engines/freescape/language/8bitDetokeniser.cpp
index 1d28314779c..3b76b2fa9e6 100644
--- a/engines/freescape/language/8bitDetokeniser.cpp
+++ b/engines/freescape/language/8bitDetokeniser.cpp
@@ -359,8 +359,7 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
 			break;
 
 		case 20:
-			detokenisedStream += "SETVAR ";
-			detokenisedStream += Common::String::format("(v%d, %d)", (int)tokenisedCondition[bytePointer], (int)tokenisedCondition[bytePointer + 1]);
+			detokenisedStream += "SETVAR (v";
 			currentInstruction = FCLInstruction(Token::SETVAR);
 			break;
 


Commit: 5894cda45fd260b236c473f275465bf404c3be5b
    https://github.com/scummvm/scummvm/commit/5894cda45fd260b236c473f275465bf404c3be5b
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-27T20:35:03+02:00

Commit Message:
FREESCAPE: refactored clear code as drawBackground

Changed paths:
    engines/freescape/area.cpp
    engines/freescape/freescape.cpp
    engines/freescape/games/castle.cpp
    engines/freescape/games/eclipse.cpp
    engines/freescape/gfx.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/area.cpp b/engines/freescape/area.cpp
index 64304fb9b6e..c1aa7f9a0ee 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -223,7 +223,6 @@ void Area::resetArea() {
 
 
 void Area::draw(Freescape::Renderer *gfx) {
-	gfx->clear(_skyColor);
 	assert(_drawableObjects.size() > 0);
 	for (auto &obj : _drawableObjects) {
 		if (!obj->isDestroyed() && !obj->isInvisible()) {
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 661a2db9dff..da72e733d90 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -267,9 +267,9 @@ void FreescapeEngine::takeDamageFromSensor() {
 
 void FreescapeEngine::drawBackground() {
 	_gfx->setViewport(_fullscreenViewArea);
-	_gfx->clear(_currentArea->_usualBackgroundColor);
+	_gfx->drawBackground(_currentArea->_usualBackgroundColor);
 	_gfx->setViewport(_viewArea);
-	_gfx->clear(_currentArea->_skyColor);
+	_gfx->drawBackground(_currentArea->_skyColor);
 }
 
 void FreescapeEngine::drawFrame() {
diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp
index a1e6f6555ff..1aa53d527f9 100644
--- a/engines/freescape/games/castle.cpp
+++ b/engines/freescape/games/castle.cpp
@@ -124,7 +124,6 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 
 	if (_currentArea->_skyColor > 0 && _currentArea->_skyColor != 255) {
 		_gfx->_keyColor = 0;
-		_gfx->clear(_currentArea->_skyColor);
 	} else
 		_gfx->_keyColor = 255;
 }
diff --git a/engines/freescape/games/eclipse.cpp b/engines/freescape/games/eclipse.cpp
index 7f970e86209..0eff0b8a1b3 100644
--- a/engines/freescape/games/eclipse.cpp
+++ b/engines/freescape/games/eclipse.cpp
@@ -181,7 +181,6 @@ void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
 
 	if (_currentArea->_skyColor > 0 && _currentArea->_skyColor != 255) {
 		_gfx->_keyColor = 0;
-		_gfx->clear(_currentArea->_skyColor);
 	} else
 		_gfx->_keyColor = 255;
 }
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index e70c08282c6..dd891144994 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -918,6 +918,22 @@ void Renderer::renderPolygon(const Math::Vector3d &origin, const Math::Vector3d
 	polygonOffset(false);
 }
 
+void Renderer::drawBackground(uint8 color) {
+
+	if (_colorRemaps && _colorRemaps->contains(color)) {
+		color = (*_colorRemaps)[color];
+	}
+
+	byte *stipple = nullptr;
+	uint8 r1, g1, b1, r2, g2, b2;
+	bool render = getRGBAt(color, r1, g1, b1, r2, g2, b2, stipple);
+	if (!render)
+		r1 = g1 = b1 = 0;
+
+	assert(stipple == nullptr); // Unclear if this is ever used
+	clear(r1, g1, b1);
+}
+
 Graphics::RendererType determinateRenderType() {
 	Common::String rendererConfig = ConfMan.get("renderer");
 	Graphics::RendererType desiredRendererType = Graphics::Renderer::parseTypeCode(rendererConfig);
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 6bae31840c9..0d3acc47099 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -91,8 +91,9 @@ public:
 	virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) = 0;
 
 	void setColorRemaps(ColorReMap *colorRemaps);
-	virtual void clear(uint8 color) = 0;
+	virtual void clear(uint8 r, uint8 g, uint8 b) = 0;
 	virtual void drawFloor(uint8 color) = 0;
+	virtual void drawBackground(uint8 color);
 
 	Common::Rect viewport() const;
 
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 0c09bb0f5ba..75c6408d35f 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -306,14 +306,7 @@ void OpenGLRenderer::useColor(uint8 r, uint8 g, uint8 b) {
 	glColor3ub(r, g, b);
 }
 
-void OpenGLRenderer::clear(uint8 color) {
-	uint8 r, g, b;
-
-	if (_colorRemaps && _colorRemaps->contains(color)) {
-		color = (*_colorRemaps)[color];
-	}
-
-	readFromPalette(color, r, g, b);
+void OpenGLRenderer::clear(uint8 r, uint8 g, uint8 b) {
 	glClearColor(r / 255., g / 255., b / 255., 1.0);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 }
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index a3925a8d4ba..07536360988 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -82,7 +82,7 @@ public:
 	GLubyte *_variableStippleArray;
 
 	virtual void init() override;
-	virtual void clear(uint8 color) override;
+	virtual void clear(uint8 r, uint8 g, uint8 b) 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;
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index d43f8966bbc..f46abb766fe 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -316,15 +316,8 @@ void OpenGLShaderRenderer::useColor(uint8 r, uint8 g, uint8 b) {
 	_triangleShader->setUniform("color", color);
 }
 
-void OpenGLShaderRenderer::clear(uint8 color) {
-	uint8 r, g, b;
-
-	if (_colorRemaps && _colorRemaps->contains(color)) {
-		color = (*_colorRemaps)[color];
-	}
-
-	readFromPalette(color, r, g, b);
-	glClearColor(0, 0, 0, 1.0);
+void OpenGLShaderRenderer::clear(uint8 r, uint8 g, uint8 b) {
+	glClearColor(r / 255., g / 255., b / 255., 1.0);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 }
 
diff --git a/engines/freescape/gfx_opengl_shaders.h b/engines/freescape/gfx_opengl_shaders.h
index ae3592a6587..ddcfe4a15b5 100644
--- a/engines/freescape/gfx_opengl_shaders.h
+++ b/engines/freescape/gfx_opengl_shaders.h
@@ -65,7 +65,7 @@ public:
 	int _variableStippleArray[64];
 
 	virtual void init() override;
-	virtual void clear(uint8 color) override;
+	virtual void clear(uint8 r, uint8 g, uint8 b) 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;
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index ea2318ba36c..6101f8bec33 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -213,14 +213,7 @@ void TinyGLRenderer::useColor(uint8 r, uint8 g, uint8 b) {
 	tglColor3ub(r, g, b);
 }
 
-void TinyGLRenderer::clear(uint8 color) {
-	uint8 r, g, b;
-
-	if (_colorRemaps && _colorRemaps->contains(color)) {
-		color = (*_colorRemaps)[color];
-	}
-
-	readFromPalette(color, r, g, b);
+void TinyGLRenderer::clear(uint8 r, uint8 g, uint8 b) {
 	tglClearColor(r / 255., g / 255., b / 255., 1.0);
 	tglClear(TGL_COLOR_BUFFER_BIT | TGL_DEPTH_BUFFER_BIT);
 }
diff --git a/engines/freescape/gfx_tinygl.h b/engines/freescape/gfx_tinygl.h
index e5a6f3d480e..ad65a171581 100644
--- a/engines/freescape/gfx_tinygl.h
+++ b/engines/freescape/gfx_tinygl.h
@@ -47,7 +47,7 @@ public:
 	Vertex *_verts;
 
 	virtual void init() override;
-	virtual void clear(uint8 color) override;
+	virtual void clear(uint8 r, uint8 g, uint8 b) 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;


Commit: a7d96804dec360e74c47f51a50d5d2474f5118fb
    https://github.com/scummvm/scummvm/commit/a7d96804dec360e74c47f51a50d5d2474f5118fb
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-27T20:35:03+02:00

Commit Message:
FREESCAPE: improved image reading for castle in DOS/EGA

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


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index da72e733d90..a5af1711f29 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -165,7 +165,6 @@ FreescapeEngine::~FreescapeEngine() {
 		delete _border;
 	}
 
-
 	if (_gfx->_isAccelerated) {
 		delete _borderTexture;
 		delete _uiTexture;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 0d81cb0a5d0..eb1f87275d1 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -560,7 +560,10 @@ public:
 class CastleEngine : public FreescapeEngine {
 public:
 	CastleEngine(OSystem *syst, const ADGameDescription *gd);
+	~CastleEngine();
 
+
+	Graphics::ManagedSurface *_option;
 	void titleScreen() override;
 	void loadAssetsDOSFullGame() override;
 	void drawUI() override;
diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp
index 1aa53d527f9..35bbc14f12d 100644
--- a/engines/freescape/games/castle.cpp
+++ b/engines/freescape/games/castle.cpp
@@ -36,6 +36,33 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
 	_playerDepth = 8;
 }
 
+CastleEngine::~CastleEngine() {
+	if (_option) {
+		_option->free();
+		delete _option;
+	}
+}
+
+byte kCastleTitleDOSPalette[16][3] = {
+	{0x00, 0x00, 0x00}, // correct!
+	{0x00, 0x00, 0xaa}, // correct!
+	{0x00, 0x00, 0x00}, // ????
+	{0x00, 0xaa, 0xaa}, // changed
+	{0x55, 0x55, 0x55}, // changed
+	{0x55, 0x55, 0xff}, // changed
+	{0xaa, 0xaa, 0xaa}, // changed
+	{0x55, 0xff, 0xff}, // changed
+	{0xff, 0x55, 0xff}, // changed
+	{0x00, 0x00, 0x00},
+	{0xff, 0xff, 0xff}, // changed
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00}
+};
+
+
 Common::SeekableReadStream *CastleEngine::decryptFile(const Common::String filename) {
 	Common::File file;
 	file.open(filename);
@@ -65,16 +92,19 @@ void CastleEngine::loadAssetsDOSFullGame() {
 	if (_renderMode == Common::kRenderEGA) {
 		_viewArea = Common::Rect(39, 31, 278, 150);
 
-		file.open("CMOE.DAT");
+		file.open("CMLE.DAT");
 		_title = load8bitBinImage(&file, 0x0);
-		_title->setPalette((byte *)&kEGADefaultPaletteData, 0, 16);
+		_title->setPalette((byte *)&kCastleTitleDOSPalette, 0, 16);
+		file.close();
 
+		file.open("CMOE.DAT");
+		_option = load8bitBinImage(&file, 0x0);
+		_option->setPalette((byte *)&kEGADefaultPaletteData, 0, 16);
 		file.close();
 
 		file.open("CME.DAT");
 		_border = load8bitBinImage(&file, 0x0);
 		_border->setPalette((byte *)&kEGADefaultPaletteData, 0, 16);
-
 		file.close();
 
 		stream = decryptFile("CMLE");


Commit: 8f218f398dffb5a29b84a57e6b782e32dbb597b2
    https://github.com/scummvm/scummvm/commit/8f218f398dffb5a29b84a57e6b782e32dbb597b2
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-27T20:35:03+02:00

Commit Message:
FREESCAPE: improved border palette for castle in DOS/EGA

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


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index a5af1711f29..007ba3d185f 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -643,7 +643,7 @@ void FreescapeEngine::processBorder() {
 
 		for (int i = 0; i < border->w; i++) {
 			for (int j = 0; j < border->h; j++) {
-				if (border->getPixel(i, j) == black)
+				if (!isCastle() && border->getPixel(i, j) == black)
 					border->setPixel(i, j, transparent);
 			}
 		}
diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp
index 35bbc14f12d..c9b07f07587 100644
--- a/engines/freescape/games/castle.cpp
+++ b/engines/freescape/games/castle.cpp
@@ -62,6 +62,42 @@ byte kCastleTitleDOSPalette[16][3] = {
 	{0x00, 0x00, 0x00}
 };
 
+byte kCastleOptionDOSPalette[16][3] = {
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0xaa},
+	{0x00, 0xaa, 0x00},
+	{0xaa, 0x00, 0x00},
+	{0x55, 0x55, 0x55},
+	{0xaa, 0x55, 0x00},
+	{0xaa, 0xaa, 0xaa},
+	{0xff, 0x55, 0x55},
+	{0x12, 0x34, 0x56},
+	{0xff, 0xff, 0x55},
+	{0xff, 0xff, 0xff},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00}
+};
+
+byte kCastleBorderDOSPalette[16][3] = {
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0xaa},
+	{0x00, 0xaa, 0x00},
+	{0xaa, 0x00, 0x00},
+	{0x55, 0x55, 0x55},
+	{0xaa, 0x55, 0x00},
+	{0xaa, 0xaa, 0xaa}, // can be also green
+	{0xff, 0x55, 0x55},
+	{0x00, 0x00, 0x00},
+	{0xff, 0xff, 0x55},
+	{0xff, 0xff, 0xff},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00},
+	{0x00, 0x00, 0x00}
+};
 
 Common::SeekableReadStream *CastleEngine::decryptFile(const Common::String filename) {
 	Common::File file;
@@ -90,7 +126,7 @@ void CastleEngine::loadAssetsDOSFullGame() {
 	Common::SeekableReadStream *stream = nullptr;
 
 	if (_renderMode == Common::kRenderEGA) {
-		_viewArea = Common::Rect(39, 31, 278, 150);
+		_viewArea = Common::Rect(40, 33, 280, 152);
 
 		file.open("CMLE.DAT");
 		_title = load8bitBinImage(&file, 0x0);
@@ -99,12 +135,12 @@ void CastleEngine::loadAssetsDOSFullGame() {
 
 		file.open("CMOE.DAT");
 		_option = load8bitBinImage(&file, 0x0);
-		_option->setPalette((byte *)&kEGADefaultPaletteData, 0, 16);
+		_option->setPalette((byte *)&kCastleOptionDOSPalette, 0, 16);
 		file.close();
 
 		file.open("CME.DAT");
 		_border = load8bitBinImage(&file, 0x0);
-		_border->setPalette((byte *)&kEGADefaultPaletteData, 0, 16);
+		_border->setPalette((byte *)&kCastleBorderDOSPalette, 0, 16);
 		file.close();
 
 		stream = decryptFile("CMLE");


Commit: 8473046fc8363b0b2a87c330bf131a76b72870a0
    https://github.com/scummvm/scummvm/commit/8473046fc8363b0b2a87c330bf131a76b72870a0
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-27T20:35:03+02:00

Commit Message:
FREESCAPE: make sure the floor is available in area 2 of castle

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


diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index c1aa7f9a0ee..3039bc5c5e1 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -330,25 +330,29 @@ void Area::addObjectFromArea(int16 id, Area *global) {
 	}
 }
 
+void Area::addFloor() {
+	int id = 0;
+	assert(!_objectsByID->contains(id));
+	Common::Array<uint8> *gColors = new Common::Array<uint8>;
+	for (int i = 0; i < 6; i++)
+		gColors->push_back(_groundColor);
+
+	Object *obj = (Object *)new GeometricObject(
+		ObjectType::kCubeType,
+		id,
+		0,                             // flags
+		Math::Vector3d(0, -1, 0),      // Position
+		Math::Vector3d(4128, 1, 4128), // size
+		gColors,
+		nullptr,
+		FCLInstructionVector());
+	(*_objectsByID)[id] = obj;
+	_drawableObjects.insert_at(0, obj);
+}
+
 void Area::addStructure(Area *global) {
-	Object *obj = nullptr;
 	if (!global || !_entrancesByID->contains(255)) {
-		int id = 254;
-		Common::Array<uint8> *gColors = new Common::Array<uint8>;
-		for (int i = 0; i < 6; i++)
-			gColors->push_back(_groundColor);
-
-		obj = (Object *)new GeometricObject(
-			ObjectType::kCubeType,
-			id,
-			0,                             // flags
-			Math::Vector3d(0, -1, 0),      // Position
-			Math::Vector3d(4128, 1, 4128), // size
-			gColors,
-			nullptr,
-			FCLInstructionVector());
-		(*_objectsByID)[id] = obj;
-		_drawableObjects.insert_at(0, obj);
+		addFloor();
 		return;
 	}
 	GlobalStructure *rs = (GlobalStructure *)(*_entrancesByID)[255];
diff --git a/engines/freescape/area.h b/engines/freescape/area.h
index 49cffb6632a..950854432f9 100644
--- a/engines/freescape/area.h
+++ b/engines/freescape/area.h
@@ -57,6 +57,7 @@ public:
 	ObjectArray checkCollisions(const Math::AABB &boundingBox);
 	void addObjectFromArea(int16 id, Area *global);
 	void addObject(Object *obj);
+	void addFloor();
 	void addStructure(Area *global);
 	void removeObject(int16 id);
 	void resetArea();
diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp
index c9b07f07587..a9fcdb495f8 100644
--- a/engines/freescape/games/castle.cpp
+++ b/engines/freescape/games/castle.cpp
@@ -151,6 +151,8 @@ void CastleEngine::loadAssetsDOSFullGame() {
 		load8bitBinary(stream, 0, 16);
 		for (auto &it : _areaMap)
 			it._value->addStructure(_areaMap[255]);
+
+		_areaMap[2]->addFloor();
 		delete stream;
 	} else
 		error("Not implemented yet");


Commit: 46667ccddc157f58bf64e61fa3c0b427abfd4e82
    https://github.com/scummvm/scummvm/commit/46667ccddc157f58bf64e61fa3c0b427abfd4e82
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-27T20:35:03+02:00

Commit Message:
FREESCAPE: better rendering of EGA colors in castle

Changed paths:
    engines/freescape/area.h
    engines/freescape/games/castle.cpp
    engines/freescape/gfx.cpp
    engines/freescape/gfx.h
    engines/freescape/loaders/8bitBinaryLoader.cpp


diff --git a/engines/freescape/area.h b/engines/freescape/area.h
index 950854432f9..294b73a5c88 100644
--- a/engines/freescape/area.h
+++ b/engines/freescape/area.h
@@ -80,6 +80,7 @@ public:
 	uint8 _underFireBackgroundColor;
 	uint8 _inkColor;
 	uint8 _paperColor;
+	uint8 _extraColor[4];
 	ColorReMap _colorRemaps;
 
 private:
diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp
index a9fcdb495f8..505c6bfd86a 100644
--- a/engines/freescape/games/castle.cpp
+++ b/engines/freescape/games/castle.cpp
@@ -194,6 +194,28 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 		_gfx->_keyColor = 0;
 	} else
 		_gfx->_keyColor = 255;
+
+	_lastPosition = _position;
+	_gameStateVars[0x1f] = 0;
+
+	if (areaID == _startArea && entranceID == _startEntrance) {
+		_yaw = 310;
+		_pitch = 0;
+	}
+
+	debugC(1, kFreescapeDebugMove, "starting player position: %f, %f, %f", _position.x(), _position.y(), _position.z());
+	clearTemporalMessages();
+	playSound(5, false);
+	// Ignore sky/ground fields
+	_gfx->_keyColor = 0;
+
+	_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();
 }
 
 void CastleEngine::drawUI() {
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index dd891144994..dd2680a18c6 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -361,8 +361,7 @@ bool Renderer::getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &
 	return true;
 }
 
-bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2) {
- 	// assert(index-1 < _colorMap->size());
+uint8 Renderer::mapEGAColor(uint8 index) {
 	byte *entry = (*_colorMap)[index - 1];
 	uint8 color = 0;
 	uint8 acc = 1;
@@ -376,10 +375,23 @@ bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &
 		entry++;
 	}
 	assert(color < 16);
-	readFromPalette(color, r1, g1, b1);
-	r2 = r1;
-	g2 = g1;
-	b2 = b1;
+	return color;
+}
+
+bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2) {
+	uint8 color;
+	if (_colorPair[index] > 0) {
+		color = mapEGAColor(_colorPair[index] & 0xf);
+		readFromPalette(color, r1, g1, b1);
+		color = mapEGAColor(_colorPair[index] >> 4);
+		readFromPalette(color, r2, g2, b2);
+	} else {
+		color = mapEGAColor(index);
+		readFromPalette(color, r1, g1, b1);
+		r2 = r1;
+		g2 = g1;
+		b2 = b1;
+	}
 	return true;
 }
 
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 0d3acc47099..047cb82589f 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -100,6 +100,8 @@ public:
 	// palette
 	void readFromPalette(uint8 index, uint8 &r, uint8 &g, uint8 &b);
 	uint8 indexFromColor(uint8 r, uint8 g, uint8 b);
+	uint8 mapEGAColor(uint8 index);
+
 	bool getRGBAt(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
 	bool getRGBAtC64(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2);
 	bool getRGBAtCGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 47bce668a63..e5265274b59 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -438,10 +438,12 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 	// debug("Condition Ptr: %x", cPtr);
 	debugC(1, kFreescapeDebugParser, "Pos before first object: %lx", file->pos());
 
+	// Driller specific
 	uint8 gasPocketX = 0;
 	uint8 gasPocketY = 0;
 	uint8 gasPocketRadius = 0;
-
+	// Castle specific
+	uint8 extraColor[4];
 	if (isEclipse()) {
 		byte idx = file->readByte();
 		name = idx < 8 ? eclipseRoomName[idx] : eclipseRoomName[8];
@@ -471,10 +473,10 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 	} else if (isCastle()) {
 		byte idx = file->readByte();
 		name = _messagesList[idx + 41];
-		debug("byte: %d", file->readByte());
-		debug("byte: %d", file->readByte());
-		debug("byte: %d", file->readByte());
-		debug("byte: %d", file->readByte());
+		extraColor[0] = file->readByte();
+		extraColor[1] = file->readByte();
+		extraColor[2] = file->readByte();
+		extraColor[3] = file->readByte();
 	}
 	debugC(1, kFreescapeDebugParser, "Area name: %s", name.c_str());
 
@@ -511,11 +513,17 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 	area->_scale = scale;
 	area->_skyColor = skyColor;
 	area->_groundColor = groundColor;
+
 	area->_inkColor = inkColor;
 	area->_paperColor = paperColor;
 	area->_usualBackgroundColor = usualBackgroundColor;
 	area->_underFireBackgroundColor = underFireBackgroundColor;
 
+	area->_extraColor[0] = extraColor[0];
+	area->_extraColor[1] = extraColor[1];
+	area->_extraColor[2] = extraColor[2];
+	area->_extraColor[3] = extraColor[3];
+
 	// Driller specific
 	area->_gasPocketPosition = Common::Point(32 * gasPocketX, 32 * gasPocketY);
 	area->_gasPocketRadius = 32 * gasPocketRadius;




More information about the Scummvm-git-logs mailing list