[Scummvm-git-logs] scummvm master -> 0c7d018b31ca5f988c6657cedab5f6d631336f0a

neuromancer noreply at scummvm.org
Sat Dec 31 16:58:30 UTC 2022


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

Summary:
0c7d018b31 FREESCAPE: basic implementation of color decoding in CPC


Commit: 0c7d018b31ca5f988c6657cedab5f6d631336f0a
    https://github.com/scummvm/scummvm/commit/0c7d018b31ca5f988c6657cedab5f6d631336f0a
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-12-31T13:57:19-03:00

Commit Message:
FREESCAPE: basic implementation of color decoding in CPC

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


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 5117b7e1a3f..81bd32d5c4d 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -680,7 +680,7 @@ void FreescapeEngine::drawStringInSurface(const Common::String &str, int x, int
 	Common::String ustr = str;
 	ustr.toUppercase();
 
-	if (isDOS() || isSpectrum()) {
+	if (isDOS() || isSpectrum() || isCPC()) {
 		for (uint32 c = 0; c < ustr.size(); c++) {
 			assert(ustr[c] >= 32);
 			for (int j = 0; j < 6; j++) {
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 53039576998..6688c844d2d 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -394,6 +394,7 @@ private:
 
 	void drawDOSUI(Graphics::Surface *surface);
 	void drawZXUI(Graphics::Surface *surface);
+	void drawCPCUI(Graphics::Surface *surface);
 	void drawAmigaAtariSTUI(Graphics::Surface *surface);
 };
 
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index 1e8a2cb2df9..552dc1c18ba 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -505,16 +505,16 @@ void DrillerEngine::loadAssetsFullGame() {
 	} else if (isCPC()) {
 		loadBundledImages();
 		Common::SeekableReadStream *stream = parseEDSK("driller.cpc.edsk");
-		//loadMessagesFixedSize(&file, 0x20e4, 14, 20);
 
-		//loadFonts(&file, 0x62ca);
-		//loadGlobalObjects(&file, 0x1c93);
-
-		if (_variant & ADGF_CPC_RETAIL)
+		if (_variant & ADGF_CPC_RETAIL) {
+			loadMessagesFixedSize(stream, 0xb0f7, 14, 20);
+			loadFonts(stream, 0xeb14);
 			load8bitBinary(stream, 0xec76, 4);
-		else if (_variant & ADGF_CPC_ZAFIRO)
+			//loadGlobalObjects(&file, 0x1c93);
+		} else if (_variant & ADGF_CPC_ZAFIRO) {
 			load8bitBinary(stream, 0xda76, 4);
-		else
+			// TODO
+		} else
 			error("Unknown Amstrad CPC variant");
 
 	} else if (_renderMode == Common::kRenderEGA) {
@@ -627,6 +627,8 @@ void DrillerEngine::drawUI() {
 		drawDOSUI(surface);
 	else if (isSpectrum())
 		drawZXUI(surface);
+	else if (isCPC())
+		drawCPCUI(surface);
 	else if (isAmiga() || isAtariST())
 		drawAmigaAtariSTUI(surface);
 
@@ -716,6 +718,78 @@ void DrillerEngine::drawDOSUI(Graphics::Surface *surface) {
 	}
 }
 
+void DrillerEngine::drawCPCUI(Graphics::Surface *surface) {
+	uint32 color = 1;
+	uint8 r, g, b;
+
+	_gfx->readFromPalette(color, r, g, b);
+	uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+	color = 0;
+	if (_gfx->_colorRemaps && _gfx->_colorRemaps->contains(color)) {
+		color = (*_gfx->_colorRemaps)[color];
+	}
+
+	_gfx->readFromPalette(color, r, g, b);
+	uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+
+	int score = _gameStateVars[k8bitVariableScore];
+	drawStringInSurface(_currentArea->_name, 200, 188, front, back, surface);
+	drawStringInSurface(Common::String::format("%04d", int(2 * _position.x())), 149, 148, front, back, surface);
+	drawStringInSurface(Common::String::format("%04d", int(2 * _position.z())), 149, 156, front, back, surface);
+	drawStringInSurface(Common::String::format("%04d", int(2 * _position.y())), 149, 164, front, back, surface);
+	if (_playerHeightNumber >= 0)
+		drawStringInSurface(Common::String::format("%d", _playerHeightNumber), 54, 164, front, back, surface);
+	else
+		drawStringInSurface(Common::String::format("%s", "J"), 54, 164, front, back, surface);
+
+	drawStringInSurface(Common::String::format("%02d", int(_angleRotations[_angleRotationIndex])), 46, 148, front, back, surface);
+	drawStringInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), 44, 156, front, back, surface);
+	drawStringInSurface(Common::String::format("%07d", score), 239, 132, front, back, surface);
+
+	int hours = _countdown <= 0 ? 0 : _countdown / 3600;
+	drawStringInSurface(Common::String::format("%02d", hours), 209, 11, front, back, surface);
+	int minutes = _countdown <= 0 ? 0 : (_countdown - hours * 3600) / 60;
+	drawStringInSurface(Common::String::format("%02d", minutes), 232, 11, front, back, surface);
+	int seconds = _countdown <= 0 ? 0 : _countdown - hours * 3600 - minutes * 60;
+	drawStringInSurface(Common::String::format("%02d", seconds), 254, 11, front, back, surface);
+
+	Common::String message;
+	int deadline;
+	getLatestMessages(message, deadline);
+	if (deadline <= _countdown) {
+		drawStringInSurface(message, 191, 180, back, front, surface);
+		_temporaryMessages.push_back(message);
+		_temporaryMessageDeadlines.push_back(deadline);
+	} else {
+		if (_currentArea->_gasPocketRadius == 0)
+			message = _messagesList[2];
+		else if (_drillStatusByArea[_currentArea->getAreaID()])
+			message = _messagesList[0];
+		else
+			message = _messagesList[1];
+
+		drawStringInSurface(message, 191, 180, front, back, surface);
+	}
+
+	int energy = _gameStateVars[k8bitVariableEnergy];
+	int shield = _gameStateVars[k8bitVariableShield];
+
+	if (energy >= 0) {
+		Common::Rect backBar(25, 187, 89 - energy, 194);
+		surface->fillRect(backBar, back);
+		Common::Rect energyBar(88 - energy, 187, 88, 194);
+		surface->fillRect(energyBar, front);
+	}
+
+	if (shield >= 0) {
+		Common::Rect backBar(25, 180, 89 - shield, 186);
+		surface->fillRect(backBar, back);
+
+		Common::Rect shieldBar(88 - shield, 180, 88, 186);
+		surface->fillRect(shieldBar, front);
+	}
+}
 
 void DrillerEngine::drawZXUI(Graphics::Surface *surface) {
 	uint32 color = 5;
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index f5aa745d93b..85390ee9526 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -121,6 +121,48 @@ bool Renderer::getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r
 	return true;
 }
 
+void extractIndexes(byte cm1, byte cm2, uint8 &i1, uint8 &i2) {
+	if (cm1 == 0xb4)
+		i1 = 1;
+	else if (cm1 == 0xb0)
+		i1 = 1;
+	else if (cm1 == 0x05)
+		i1 = 2;
+	else if (cm1 == 0x50)
+		i1 = 1;
+	else if (cm1 == 0x55)
+		i1 = 3;
+	else if (cm1 == 0xf5)
+		i1 = 3;
+	else if (cm1 == 0x5a)
+		i1 = 1;
+	else if (cm1 == 0xbb)
+		i1 = 3;
+	else
+		error("%x %x", cm1, cm2);
+
+	if (cm2 == 0xe1)
+		i2 = 2;
+	else if (cm2 == 0x0a)
+		i2 = 0;
+	else if (cm2 == 0xaa)
+		i2 = 0;
+	else if (cm2 == 0xa0)
+		i2 = 0;
+	else if (cm2 == 0x00)
+		i2 = 0;
+	else if (cm2 == 0xfa)
+		i2 = 1;
+	else if (cm2 == 0xa5)
+		i2 = 2;
+	else if (cm2 == 0xee)
+		i2 = 0;
+	else if (cm2 == 0xe0)
+		i2 = 0;
+	else
+		error("%x %x", cm1, cm2);
+}
+
 bool Renderer::getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2) {
 	if (index == _keyColor)
 		return false;
@@ -135,12 +177,15 @@ bool Renderer::getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &
 	}
 
 	byte *entry = (*_colorMap)[index - 1];
-	//entry++;
+	byte cm1 = *(entry);
 	entry++;
-	byte be = *(entry);
-	//be = *(entry);
-	readFromPalette((be >> 4) % 4, r1, g1, b1);
-	readFromPalette((be & 0xf) % 4, r2, g2, b2);
+	byte cm2 = *(entry);
+
+	uint8 i1;
+	uint8 i2;
+	extractIndexes(cm1, cm2, i1, i2);
+	readFromPalette(i1, r1, g1, b1);
+	readFromPalette(i2, r2, g2, b2);
 	return true;
 }
 
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 299f1daf8eb..3ec6fa47242 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -602,7 +602,7 @@ void FreescapeEngine::loadFonts(Common::SeekableReadStream *file, int offset) {
 	file->seek(offset);
 	int charNumber = 60;
 	byte *font = nullptr;
-	if (isDOS() || isSpectrum()) {
+	if (isDOS() || isSpectrum() || isCPC()) {
 		font = (byte *)malloc(6 * charNumber);
 		file->read(font, 6 * charNumber);
 




More information about the Scummvm-git-logs mailing list