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

neuromancer noreply at scummvm.org
Sun Jul 21 08:25:49 UTC 2024


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

Summary:
5c68819504 FREESCAPE: refactored intro code and removed part of the duplicated functions
13fc65d664 FREESCAPE: eclipse related fixes on the loading of data and color handling
d343e4ef3f FREESCAPE: properly select character in castle


Commit: 5c68819504e5243c9ede1eddf98f7627149554ea
    https://github.com/scummvm/scummvm/commit/5c68819504e5243c9ede1eddf98f7627149554ea
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-21T10:25:07+02:00

Commit Message:
FREESCAPE: refactored intro code and removed part of the duplicated functions

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


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 6f22c907ea0..64112c2cba2 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -149,7 +149,7 @@ public:
 	void clearBackground();
 	virtual void drawUI();
 	virtual void drawInfoMenu();
-	void drawBorderScreenAndWait(Graphics::Surface *surface);
+	void drawBorderScreenAndWait(Graphics::Surface *surface, int maxWait = INT_MAX);
 
 	virtual void drawCrossair(Graphics::Surface *surface);
 	Graphics::ManagedSurface *_border;
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 6a6ac8f1b16..137f6b60a32 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -622,8 +622,8 @@ void CastleEngine::updateTimeVariables() {
 	}
 }
 
-void CastleEngine::titleScreen() {
-	FreescapeEngine::titleScreen();
+void CastleEngine::borderScreen() {
+	FreescapeEngine::borderScreen();
 	selectCharacterScreen();
 }
 
@@ -641,18 +641,29 @@ void CastleEngine::drawOption() {
 	_gfx->setViewport(_viewArea);
 }
 
-void CastleEngine::selectCharacterScreen() {
-	if (!_option)
-		return;
+extern Common::String centerAndPadString(const Common::String &x, int y);
 
-	Graphics::Surface *surface = new Graphics::Surface();
-	surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
+void CastleEngine::selectCharacterScreen() {
+	Common::Array<Common::String> lines;
+	if (isDOS()) {
+		lines.push_back("Select your character");
+		lines.push_back("");
+		lines.push_back("");
+		lines.push_back("            1. Prince");
+		lines.push_back("            2. Princess");
+	} else if (isSpectrum()) {
+		lines.push_back(centerAndPadString("*******************", 21));
+		lines.push_back(centerAndPadString("Select your character", 21));
+		lines.push_back(centerAndPadString("you wish to play", 21));
+		lines.push_back(centerAndPadString("and press enter", 21));
+		lines.push_back("");
+		lines.push_back(centerAndPadString("1. Prince  ", 21));
+		lines.push_back(centerAndPadString("2. Princess", 21));
+		lines.push_back("");
+		lines.push_back(centerAndPadString("*******************", 21));
+	}
 
-	uint32 green = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0xFF, 0x00);
-	uint32 transparent = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
-	drawStringInSurface("Select your character", 63, 16, green, transparent, surface);
-	drawStringInSurface("1. Prince", 150, 82, green, transparent, surface);
-	drawStringInSurface("1. Princess", 150, 92, green, transparent, surface);
+	Graphics::Surface *surface = drawStringsInSurface(lines);
 
 	bool selected = false;
 	while (!selected) {
@@ -690,7 +701,10 @@ void CastleEngine::selectCharacterScreen() {
 			}
 		}
 		_gfx->clear(0, 0, 0, true);
-		drawOption();
+		if (_option)
+			drawOption();
+		else
+			drawBorder();
 		drawFullscreenSurface(surface);
 		_gfx->flipBuffer();
 		g_system->updateScreen();
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index b5c0cd3cc2a..83a7cc7af99 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -36,7 +36,7 @@ public:
 	void loadAssetsDOSDemo() override;
 	void loadAssetsAmigaDemo() override;
 	void loadAssetsZXFullGame() override;
-	void titleScreen() override;
+	void borderScreen() override;
 	void selectCharacterScreen();
 	void drawOption();
 
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 53f744652a7..8d84338b7c3 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -640,6 +640,12 @@ void DarkEngine::updateTimeVariables() {
 void DarkEngine::borderScreen() {
 	if (_border) {
 		drawBorder();
+		// Modify and reload the border
+		_border->fillRect(_viewArea, _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0, 0, 0));
+		delete _borderTexture;
+		_borderTexture = nullptr;
+		loadBorder();
+
 		if (isDemo()) {
 			drawFullscreenMessageAndWait(_messagesList[27]);
 			drawFullscreenMessageAndWait(_messagesList[28]);
diff --git a/engines/freescape/ui.cpp b/engines/freescape/ui.cpp
index 6a4eff72888..89c2259226a 100644
--- a/engines/freescape/ui.cpp
+++ b/engines/freescape/ui.cpp
@@ -75,8 +75,7 @@ Graphics::Surface *FreescapeEngine::drawStringsInSurface(const Common::Array<Com
 	surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
 	surface->fillRect(_fullscreenViewArea, color);
 
-	uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
-	surface->fillRect(_viewArea, black);
+	uint32 back = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
 
 	switch (_renderMode) {
 		case Common::kRenderCGA:
@@ -104,16 +103,12 @@ Graphics::Surface *FreescapeEngine::drawStringsInSurface(const Common::Array<Com
 
 	uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
 
-	int x = isCastle() ? 45 : 55;
-	int y = isEclipse() || isCastle() ? 40 : 32;
-
-	if (isSpectrum() || isCPC()) {
-		black = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
-	}
+	int x = _viewArea.left;
+	int y = _viewArea.top;
 
 	for (int i = 0; i < int(lines.size()); i++) {
-		drawStringInSurface(lines[i], x, y, front, black, surface);
-		y = y + 9;
+		drawStringInSurface(lines[i], x, y, front, back, surface);
+		y = y + (isCastle() ? 12 : 9);
 	}
 	return surface;
 }
@@ -126,7 +121,12 @@ void FreescapeEngine::borderScreen() {
 		if (isAmiga() || isAtariST())
 			return; // TODO: add animation
 
-		drawBorderScreenAndWait(nullptr);
+		drawBorderScreenAndWait(nullptr, 6 * 60);
+		// Modify and reload the border
+		_border->fillRect(_viewArea, _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0, 0, 0));
+		delete _borderTexture;
+		_borderTexture = nullptr;
+		loadBorder();
 
 		if (isDemo())
 			return;
@@ -155,116 +155,38 @@ void FreescapeEngine::borderScreen() {
 
 		lines.push_back("");
 		Graphics::Surface *surface = drawStringsInSurface(lines);
-		drawBorderScreenAndWait(surface);
+		drawBorderScreenAndWait(surface, 6 * 60);
 		surface->free();
 		delete surface;
 	}
 }
 
-void FreescapeEngine::drawFullscreenMessage(Common::String message, uint32 front, Graphics::Surface *surface) {
-	uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
-	uint32 color = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
-
-	surface->fillRect(_fullscreenViewArea, color);
-	surface->fillRect(_viewArea, black);
-	int x = 0;
-	int y = 0;
+void FreescapeEngine::drawFullscreenMessageAndWait(Common::String message) {
 	int letterPerLine = 0;
 	int numberOfLines = 0;
 
 	if (isDOS()) {
-		x = 50;
-		y = 32;
 		letterPerLine = 28;
 		numberOfLines = 10;
 	} else if (isSpectrum() || isCPC()) {
-		x = _viewArea.left;
-		y = _viewArea.top;
 		letterPerLine = 24;
 		numberOfLines = 12;
 	} else if (isAtariST()) {
-		x = 33;
-		y = 40;
 		letterPerLine = 32;
 		numberOfLines = 10;
 	}
 
+	Common::Array<Common::String> lines;
 	for (int i = 0; i < numberOfLines; i++) {
-		Common::String line = message.substr(letterPerLine * i, letterPerLine);
-		//debug("'%s' %d", line.c_str(), line.size());
-		drawStringInSurface(line, x, y, front, black, surface);
-		y = y + 8;
+		lines.push_back(message.substr(letterPerLine * i, letterPerLine));
 	}
-	drawFullscreenSurface(surface);
-}
-
-void FreescapeEngine::drawFullscreenMessageAndWait(Common::String message) {
-	_savedScreen = _gfx->getScreenshot();
-	uint32 color = 0;
-	switch (_renderMode) {
-		case Common::kRenderCPC:
-			color = 14;
-			break;
-		case Common::kRenderCGA:
-			color = 1;
-			break;
-		case Common::kRenderZX:
-			color = 6;
-			break;
-		default:
-			color = 14;
-	}
-	uint8 r, g, b;
-	_gfx->readFromPalette(color, r, g, b);
-	uint32 front = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
-
-	Graphics::Surface *surface = new Graphics::Surface();
-	surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
-
-	Common::Event event;
-	bool cont = true;
-	while (!shouldQuit() && cont) {
-		while (_eventManager->pollEvent(event)) {
-
-			// Events
-			switch (event.type) {
-			case Common::EVENT_KEYDOWN:
-				if (event.kbd.keycode == Common::KEYCODE_SPACE) {
-					cont = false;
-				}
-				break;
-			case Common::EVENT_SCREEN_CHANGED:
-				_gfx->computeScreenViewport();
-				break;
-			case Common::EVENT_RBUTTONDOWN:
-				// fallthrough
-			case Common::EVENT_LBUTTONDOWN:
-				if (g_system->hasFeature(OSystem::kFeatureTouchscreen))
-					cont = false;
-				break;
-			default:
-				break;
-			}
-		}
-		_gfx->clear(0, 0, 0, true);
-		drawBorder();
-		if (_currentArea)
-			drawUI();
-		drawFullscreenMessage(message, front, surface);
-		_gfx->flipBuffer();
-		g_system->updateScreen();
-		g_system->delayMillis(15); // try to target ~60 FPS
-	}
-
-	_savedScreen->free();
-	delete _savedScreen;
+	Graphics::Surface *surface = drawStringsInSurface(lines);
+	drawBorderScreenAndWait(surface);
 	surface->free();
 	delete surface;
 }
 
-
-void FreescapeEngine::drawBorderScreenAndWait(Graphics::Surface *surface) {
-	int maxWait = 6 * 60;
+void FreescapeEngine::drawBorderScreenAndWait(Graphics::Surface *surface, int maxWait) {
 	for (int i = 0; i < maxWait; i++ ) {
 		Common::Event event;
 		while (_eventManager->pollEvent(event)) {
@@ -281,11 +203,11 @@ void FreescapeEngine::drawBorderScreenAndWait(Graphics::Surface *surface) {
 			case Common::EVENT_KEYDOWN:
 				switch (event.kbd.keycode) {
 				case Common::KEYCODE_SPACE:
-					i = maxWait;
+					maxWait = -1;
 					break;
 				case Common::KEYCODE_d:
 					_demoMode = true;
-					i = maxWait;
+					maxWait = -1;
 					break;
 				default:
 					break;


Commit: 13fc65d6647e7307a227eedb192349482e92c7c4
    https://github.com/scummvm/scummvm/commit/13fc65d6647e7307a227eedb192349482e92c7c4
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-21T10:25:07+02:00

Commit Message:
FREESCAPE: eclipse related fixes on the loading of data and color handling

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


diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index cf75b8446a9..38cc8a71ded 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -91,9 +91,15 @@ void EclipseEngine::loadAssets() {
 	//_noEnergyMessage = _messagesList[16];
 	_fallenMessage = _messagesList[3];
 	_crushedMessage = _messagesList[2];
+
 	_areaMap[1]->addFloor();
-	if (!isDemo())
+	if (isSpectrum())
+		_areaMap[1]->_paperColor = 1;
+
+	if (!isDemo() && !isEclipse2()) {
 		_areaMap[51]->addFloor();
+		_areaMap[51]->_paperColor = 1;
+	}
 }
 
 bool EclipseEngine::checkIfGameEnded() {
diff --git a/engines/freescape/games/eclipse/zx.cpp b/engines/freescape/games/eclipse/zx.cpp
index 75f34f63965..a1942019650 100644
--- a/engines/freescape/games/eclipse/zx.cpp
+++ b/engines/freescape/games/eclipse/zx.cpp
@@ -35,7 +35,6 @@ void EclipseEngine::initZX() {
 
 void EclipseEngine::loadAssetsZXFullGame() {
 	Common::File file;
-	bool isTotalEclipse2 = _targetName.hasPrefix("totaleclipse2");
 
 	file.open("totaleclipse.zx.title");
 	if (file.isOpen()) {
@@ -55,7 +54,7 @@ void EclipseEngine::loadAssetsZXFullGame() {
 	if (!file.isOpen())
 		error("Failed to open totaleclipse.zx.data");
 
-	if (isTotalEclipse2) {
+	if (isEclipse2()) {
 		loadMessagesFixedSize(&file, 0x2ac, 16, 30);
 		loadFonts(&file, 0x61c3, _font);
 		loadSpeakerFxZX(&file, 0x8c6, 0x91a);
@@ -66,11 +65,7 @@ void EclipseEngine::loadAssetsZXFullGame() {
 		loadSpeakerFxZX(&file, 0x816, 0x86a);
 		load8bitBinary(&file, 0x635b, 4);
 
-		// These paper colors are invalid, probably to signal the use of floor/sky colors
-		_areaMap[1]->_paperColor = 1;
-		_areaMap[51]->_paperColor = 1;
-
-		// These paper colors are also invalid, but to signal the use of a special effect
+		// These paper colors are also invalid, but to signal the use of a special effect (only in zx release)
 		_areaMap[42]->_paperColor = 0;
 		_areaMap[42]->_underFireBackgroundColor = 0;
 	}
@@ -78,7 +73,7 @@ void EclipseEngine::loadAssetsZXFullGame() {
 	for (auto &it : _areaMap) {
 		it._value->addStructure(_areaMap[255]);
 
-		if (isTotalEclipse2 && it._value->getAreaID() == 1)
+		if (isEclipse2() && it._value->getAreaID() == 1)
 			continue;
 
 		if (isEclipse2() && it._value->getAreaID() == _startArea)


Commit: d343e4ef3f1c7dc9aebfbd02db4bfeac97fdfac1
    https://github.com/scummvm/scummvm/commit/d343e4ef3f1c7dc9aebfbd02db4bfeac97fdfac1
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-07-21T10:25:07+02:00

Commit Message:
FREESCAPE: properly select character in castle

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


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 137f6b60a32..b80ff766b24 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -683,9 +683,11 @@ void CastleEngine::selectCharacterScreen() {
 				switch (event.kbd.keycode) {
 				case Common::KEYCODE_1:
 					selected = true;
+					// Nothing, since game bit should be already zero
 					break;
 				case Common::KEYCODE_2:
 					selected = true;
+					setGameBit(32);
 					break;
 				default:
 					break;




More information about the Scummvm-git-logs mailing list