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

neuromancer noreply at scummvm.org
Fri Nov 25 12:04:35 UTC 2022


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:
bb177a0a46 FREESCAPE: correctly parse background colors for UI
c599b4e737 FREESCAPE: basic implementation of special effect when player is taking damage


Commit: bb177a0a4605bc341f0cbf69407c89abc9e77068
    https://github.com/scummvm/scummvm/commit/bb177a0a4605bc341f0cbf69407c89abc9e77068
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-25T13:05:29+01:00

Commit Message:
FREESCAPE: correctly parse background colors for UI

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


diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 925e9100e1d..96858891295 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -67,6 +67,9 @@ Area::Area(uint16 areaID_, uint16 areaFlags_, ObjectMap *objectsByID_, ObjectMap
 	_scale = 0;
 	_skyColor = 255;
 	_groundColor = 255;
+	_usualBackgroundColor = 255;
+	_underFireBackgroundColor = 255;
+
 	_gasPocketRadius = 0;
 
 	// create a list of drawable objects only
diff --git a/engines/freescape/area.h b/engines/freescape/area.h
index 6abeddb4bc4..33b962c27c1 100644
--- a/engines/freescape/area.h
+++ b/engines/freescape/area.h
@@ -72,6 +72,8 @@ public:
 	uint8 _scale;
 	uint8 _skyColor;
 	uint8 _groundColor;
+	uint8 _usualBackgroundColor;
+	uint8 _underFireBackgroundColor;
 	ColorReMap _colorRemaps;
 
 private:
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 70d53cd0774..00f722fd6bc 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -294,8 +294,6 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 	uint8 scale = readField(file, 8);
 	debugC(1, kFreescapeDebugParser, "Scale: %d", scale);
 
-	uint8 ci1 = 0;
-	uint8 ci2 = 0;
 	uint8 ci3 = 0;
 	uint8 ci4 = 0;
 	uint8 skyColor = areaFlags & 15;
@@ -306,11 +304,14 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 	if (skyColor == 0)
 		skyColor = 255;
 
-	ci1 = readField(file, 8);
-	ci2 = readField(file, 8);
+	uint8 usualBackgroundColor = readField(file, 8);
+	uint8 underFireBackgroundColor = readField(file, 8);
 	ci3 = readField(file, 8);
 	ci4 = readField(file, 8);
-	debugC(1, kFreescapeDebugParser, "Colors: %d %d %d %d %d %d", ci1, ci2, ci3, ci4, skyColor, groundColor);
+	debugC(1, kFreescapeDebugParser, "Colors usual background: %d", usualBackgroundColor);
+	debugC(1, kFreescapeDebugParser, "Colors under fire background: %d", underFireBackgroundColor);
+
+	debugC(1, kFreescapeDebugParser, "Colors: %d %d %d %d", ci3, ci4, skyColor, groundColor);
 	// CPC
 	// groundColor = file->readByte() & 15;
 	// skyColor = file->readByte() & 15;
@@ -401,6 +402,8 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 	area->_scale = scale;
 	area->_skyColor = skyColor;
 	area->_groundColor = groundColor;
+	area->_usualBackgroundColor = usualBackgroundColor;
+	area->_underFireBackgroundColor = underFireBackgroundColor;
 
 	// Driller specific
 	area->_gasPocketPosition = Common::Point(32 * gasPocketX, 32 * gasPocketY);


Commit: c599b4e737c177397b830ec86be6f2235e6ea2f7
    https://github.com/scummvm/scummvm/commit/c599b4e737c177397b830ec86be6f2235e6ea2f7
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-25T13:05:29+01:00

Commit Message:
FREESCAPE: basic implementation of special effect when player is taking damage

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


diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 96858891295..85725518a6f 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -171,9 +171,12 @@ void Area::remapColor(int index, int color) {
 	_colorRemaps[index] = color;
 }
 
+void Area::unremapColor(int index) {
+	_colorRemaps.clear(index);
+}
 
 void Area::draw(Freescape::Renderer *gfx) {
-	gfx->clear();
+	gfx->clear(_skyColor);
 	assert(_drawableObjects.size() > 0);
 	for (auto &obj : _drawableObjects) {
 		if (!obj->isDestroyed() && !obj->isInvisible()) {
diff --git a/engines/freescape/area.h b/engines/freescape/area.h
index 33b962c27c1..53a243de42f 100644
--- a/engines/freescape/area.h
+++ b/engines/freescape/area.h
@@ -48,6 +48,7 @@ public:
 	uint16 getAreaFlags();
 	uint8 getScale();
 	void remapColor(int index, int color);
+	void unremapColor(int index);
 	void draw(Renderer *gfx);
 	void show();
 
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 56c9f29721a..76a5bbef52c 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -157,8 +157,20 @@ void FreescapeEngine::drawBorder() {
 		return;
 
 	_gfx->setViewport(_fullscreenViewArea);
-	if (!_borderTexture)
+
+	if (!_borderTexture) {
+		// Replace black pixel for transparent ones
+		uint32 black = _border->format.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
+		uint32 transparent = _border->format.ARGBToColor(0x00, 0x00, 0x00, 0x00);
+
+		for (int i = 0; i < _border->w; i++) {
+			for (int j = 0; j < _border->h; j++) {
+				if (_border->getPixel(i, j) == black)
+					_border->setPixel(i, j, transparent);
+			}
+		}
 		_borderTexture = _gfx->createTexture(_border);
+	}
 	_gfx->drawTexturedRect2D(_fullscreenViewArea, _fullscreenViewArea, _borderTexture);
 	_gfx->setViewport(_viewArea);
 }
@@ -235,12 +247,27 @@ void FreescapeEngine::drawSensorShoot(Sensor *sensor) {
 
 void FreescapeEngine::takeDamageFromSensor() {
 	_gameStateVars[k8bitVariableShield]--;
+	_currentArea->remapColor(_currentArea->_usualBackgroundColor, _currentArea->_underFireBackgroundColor);
+	_currentArea->remapColor(_currentArea->_skyColor, _currentArea->_underFireBackgroundColor);
+	drawFrame();
+	_gfx->flipBuffer();
+	g_system->updateScreen();
+	_currentArea->unremapColor(_currentArea->_usualBackgroundColor);
+	_currentArea->unremapColor(_currentArea->_skyColor);
+}
+
+void FreescapeEngine::drawBackground() {
+	_gfx->setViewport(_fullscreenViewArea);
+	_gfx->clear(_currentArea->_usualBackgroundColor);
+	_gfx->setViewport(_viewArea);
+	_gfx->clear(_currentArea->_skyColor);
 }
 
 
 void FreescapeEngine::drawFrame() {
 	_gfx->updateProjectionMatrix(70.0, _nearClipPlane, _farClipPlane);
 	_gfx->positionCamera(_position, _position + _cameraFront);
+	drawBackground();
 	_currentArea->draw(_gfx);
 	drawBorder();
 	drawUI();
@@ -479,7 +506,6 @@ Common::Error FreescapeEngine::run() {
 		return Common::kUserCanceled;
 
 	_gfx->init();
-	_gfx->clear();
 
 	// Load game data and init game state
 	loadDataBundle();
@@ -487,6 +513,7 @@ Common::Error FreescapeEngine::run() {
 	initGameState();
 	loadColorPalette();
 
+	_gfx->clear(0);
 
 	_gfx->convertImageFormatIfNecessary(_title);
 	_gfx->convertImageFormatIfNecessary(_border);
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 8ed6da21ebf..ea77651b648 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -110,6 +110,7 @@ public:
 	void convertBorder();
 	void drawBorder();
 	void drawTitle();
+	void drawBackground();
 	virtual void drawUI();
 	virtual void drawCrossair(Graphics::Surface *surface);
 	Graphics::Surface *_border;
diff --git a/engines/freescape/games/castle.cpp b/engines/freescape/games/castle.cpp
index 4600652b457..249c3b32064 100644
--- a/engines/freescape/games/castle.cpp
+++ b/engines/freescape/games/castle.cpp
@@ -93,7 +93,7 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 
 	if (_currentArea->_skyColor > 0 && _currentArea->_skyColor != 255) {
 		_gfx->_keyColor = 0;
-		_gfx->setSkyColor(_currentArea->_skyColor);
+		_gfx->clear(_currentArea->_skyColor);
 	} else
 		_gfx->_keyColor = 255;
 }
diff --git a/engines/freescape/games/eclipse.cpp b/engines/freescape/games/eclipse.cpp
index 723400bf679..9e4e47a2d00 100644
--- a/engines/freescape/games/eclipse.cpp
+++ b/engines/freescape/games/eclipse.cpp
@@ -161,7 +161,7 @@ void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
 
 	if (_currentArea->_skyColor > 0 && _currentArea->_skyColor != 255) {
 		_gfx->_keyColor = 0;
-		_gfx->setSkyColor(_currentArea->_skyColor);
+		_gfx->clear(_currentArea->_skyColor);
 	} else
 		_gfx->_keyColor = 255;
 }
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index b7af8bdbe66..44260689783 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -66,7 +66,6 @@ public:
 	bool _isAccelerated;
 
 	virtual void init() = 0;
-	virtual void clear() = 0;
 	virtual void setViewport(const Common::Rect &rect) = 0;
 
 	/**
@@ -91,7 +90,7 @@ public:
 	virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) = 0;
 
 	void setColorRemaps(ColorReMap *colorRemaps);
-	virtual void setSkyColor(uint8 color) = 0;
+	virtual void clear(uint8 color) = 0;
 	virtual void drawFloor(uint8 color) = 0;
 
 	Common::Rect viewport() const;
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 1825b4b5752..4954609a6b9 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -89,11 +89,6 @@ void OpenGLRenderer::setViewport(const Common::Rect &rect) {
 	glScissor(_viewport.left, g_system->getHeight() - _viewport.bottom, _viewport.width(), _viewport.height());
 }
 
-void OpenGLRenderer::clear() {
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	glColor3f(1.0f, 1.0f, 1.0f);
-}
-
 void OpenGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) {
 	OpenGLTexture *glTexture = static_cast<OpenGLTexture *>(texture);
 
@@ -263,9 +258,14 @@ void OpenGLRenderer::useColor(uint8 r, uint8 g, uint8 b) {
 	glColor3ub(r, g, b);
 }
 
-void OpenGLRenderer::setSkyColor(uint8 color) {
+void OpenGLRenderer::clear(uint8 color) {
 	uint8 r, g, b;
-	assert(getRGBAt(color, r, g, b)); // TODO: move check inside this function
+
+	if (_colorRemaps && _colorRemaps->contains(color)) {
+		color = (*_colorRemaps)[color];
+	}
+
+	readFromPalette(color, r, g, 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 28d17fff1a5..4c793990d75 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -61,7 +61,7 @@ public:
 	}
 
 	virtual void init() override;
-	virtual void clear() override;
+	virtual void clear(uint8 color) 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;
@@ -78,7 +78,6 @@ public:
 	virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
 
 	virtual void flipBuffer() override;
-	virtual void setSkyColor(uint8 color) override;
 	virtual void drawFloor(uint8 color) override;
 };
 
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index 34b1a824248..ee4709f48a2 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -79,11 +79,6 @@ void TinyGLRenderer::setViewport(const Common::Rect &rect) {
 	tglViewport(rect.left, g_system->getHeight() - rect.bottom, rect.width(), rect.height());
 }
 
-void TinyGLRenderer::clear() {
-	tglClear(TGL_COLOR_BUFFER_BIT | TGL_DEPTH_BUFFER_BIT);
-	tglColor3f(1.0f, 1.0f, 1.0f);
-}
-
 void TinyGLRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) {
 	const float sLeft = screenRect.left;
 	const float sTop = screenRect.top;
@@ -210,9 +205,14 @@ void TinyGLRenderer::useColor(uint8 r, uint8 g, uint8 b) {
 	tglColor3ub(r, g, b);
 }
 
-void TinyGLRenderer::setSkyColor(uint8 color) {
+void TinyGLRenderer::clear(uint8 color) {
 	uint8 r, g, b;
-	assert(getRGBAt(color, r, g, b)); // TODO: move check inside this function
+
+	if (_colorRemaps && _colorRemaps->contains(color)) {
+		color = (*_colorRemaps)[color];
+	}
+
+	readFromPalette(color, r, g, 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 061ab5c6383..2752f18e4c3 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() override;
+	virtual void clear(uint8 color) 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;
@@ -64,7 +64,6 @@ public:
 	virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
 
 	virtual void flipBuffer() override;
-	virtual void setSkyColor(uint8 color) override;
 	virtual void drawFloor(uint8 color) override;
 };
 
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 00f722fd6bc..3a9d35c0661 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -301,8 +301,6 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 
 	if (groundColor == 0)
 		groundColor = 255;
-	if (skyColor == 0)
-		skyColor = 255;
 
 	uint8 usualBackgroundColor = readField(file, 8);
 	uint8 underFireBackgroundColor = readField(file, 8);




More information about the Scummvm-git-logs mailing list