[Scummvm-git-logs] scummvm master -> 995b5a84522e30f2b50b066da28e066e52482cb0

neuromancer noreply at scummvm.org
Sun Jan 29 12:14:07 UTC 2023


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:
bf286618e3 FREESCAPE: implemented skanner in driller
995b5a8452 FREESCAPE: implemented SETVAR instruction


Commit: bf286618e304a5b03cab7226d8a7266b8500e349
    https://github.com/scummvm/scummvm/commit/bf286618e304a5b03cab7226d8a7266b8500e349
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-01-29T13:15:17+01:00

Commit Message:
FREESCAPE: implemented skanner in driller

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


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index bd6bfa77441..d91f73ddc3c 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -142,6 +142,7 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
 	_countdown = 0;
 	_ticks = 0;
 	_lastTick = -1;
+	_lastMinute = -1;
 	_frameLimiter = nullptr;
 	_vsyncEnabled = false;
 
@@ -497,6 +498,18 @@ void FreescapeEngine::processInput() {
 	}
 }
 
+void FreescapeEngine::updateTimeVariables() {
+	int seconds, minutes, hours;
+	getTimeFromCountdown(seconds, minutes, hours);
+
+	if (_lastMinute != minutes) {
+		_lastMinute = minutes;
+		_gameStateVars[0x1e] += 1;
+		_gameStateVars[0x1f] += 1;
+		executeLocalGlobalConditions(false, true); // Only execute "on collision" room/global conditions
+	}
+}
+
 Common::Error FreescapeEngine::run() {
 	_vsyncEnabled = g_system->getFeatureState(OSystem::kFeatureVSync);
 	_frameLimiter = new Graphics::FrameLimiter(g_system, ConfMan.getInt("engine_speed"));
@@ -550,6 +563,7 @@ Common::Error FreescapeEngine::run() {
 	g_system->updateScreen();
 
 	while (!shouldQuit()) {
+		updateTimeVariables();
 		if (endGame) {
 			initGameState();
 			gotoArea(_startArea, _startEntrance);
@@ -828,6 +842,17 @@ Graphics::Surface *FreescapeEngine::loadAndConvertNeoImage(Common::SeekableReadS
 	return surface;
 }
 
+void FreescapeEngine::getTimeFromCountdown(int &seconds, int &minutes, int &hours) {
+	int countdown = _countdown;
+	int h = countdown <= 0 ? 0 : countdown / 3600;
+	int m = countdown <= 0 ? 0 : (countdown - h * 3600) / 60;
+	int s = countdown <= 0 ? 0 : countdown - h * 3600 - m * 60;
+
+	seconds = s;
+	minutes = m;
+	hours = h;
+}
+
 static void countdownCallback(void *refCon) {
 	FreescapeEngine* self = (FreescapeEngine *)refCon;
 	self->_ticks++;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 30c5cd555dc..3e108874486 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -352,6 +352,10 @@ public:
 	int _countdown;
 	int _ticks;
 	int _lastTick;
+	int _lastMinute;
+
+	void getTimeFromCountdown(int &seconds, int &minutes, int &hours);
+	void updateTimeVariables();
 
 	// Cheats
 	bool _useExtendedTimer;
@@ -416,6 +420,7 @@ private:
 	void addDrill(const Math::Vector3d position, bool gasFound);
 	bool checkDrill(const Math::Vector3d position);
 	void removeDrill(Area *area);
+	void addSkanner(Area *area);
 
 	void loadAssetsDemo();
 	void loadAssetsFullGame();
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index 292bedeff42..129cf255948 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -219,6 +219,7 @@ void DrillerEngine::gotoArea(uint16 areaID, int entranceID) {
 		_sensors = _currentArea->getSensors();
 	}
 	_lastPosition = _position;
+	_gameStateVars[0x1f] = 0;
 
 	if (areaID == _startArea && entranceID == _startEntrance) {
 		_yaw = 280;
@@ -804,11 +805,10 @@ void DrillerEngine::drawDOSUI(Graphics::Surface *surface) {
 	drawStringInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), _renderMode == Common::kRenderCGA ? 44 : 46, 153, front, back, surface);
 	drawStringInSurface(Common::String::format("%07d", score), 238, 129, front, back, surface);
 
-	int hours = _countdown <= 0 ? 0 : _countdown / 3600;
+	int seconds, minutes, hours;
+	getTimeFromCountdown(seconds, minutes, hours);
 	drawStringInSurface(Common::String::format("%02d", hours), 208, 8, front, back, surface);
-	int minutes = _countdown <= 0 ? 0 : (_countdown - hours * 3600) / 60;
 	drawStringInSurface(Common::String::format("%02d", minutes), 230, 8, front, back, surface);
-	int seconds = _countdown <= 0 ? 0 : _countdown - hours * 3600 - minutes * 60;
 	drawStringInSurface(Common::String::format("%02d", seconds), 254, 8, front, back, surface);
 
 	Common::String message;
@@ -877,11 +877,10 @@ void DrillerEngine::drawCPCUI(Graphics::Surface *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;
+	int seconds, minutes, hours;
+	getTimeFromCountdown(seconds, minutes, hours);
 	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;
@@ -950,11 +949,10 @@ void DrillerEngine::drawC64UI(Graphics::Surface *surface) {
 	drawStringInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), 44, 156, front, back, surface);
 	drawStringInSurface(Common::String::format("%07d", score), 240, 128, front, back, surface);
 
-	int hours = _countdown <= 0 ? 0 : _countdown / 3600;
+	int seconds, minutes, hours;
+	getTimeFromCountdown(seconds, minutes, hours);
 	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;
@@ -1024,11 +1022,10 @@ void DrillerEngine::drawZXUI(Graphics::Surface *surface) {
 	drawStringInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), 65, 157, front, back, surface);
 	drawStringInSurface(Common::String::format("%07d", score), 217, 133, white, back, surface);
 
-	int hours = _countdown <= 0 ? 0 : _countdown / 3600;
+	int seconds, minutes, hours;
+	getTimeFromCountdown(seconds, minutes, hours);
 	drawStringInSurface(Common::String::format("%02d", hours), 187, 12, front, back, surface);
-	int minutes = _countdown <= 0 ? 0 : (_countdown - hours * 3600) / 60;
 	drawStringInSurface(Common::String::format("%02d", minutes), 209, 12, front, back, surface);
-	int seconds = _countdown <= 0 ? 0 : _countdown - hours * 3600 - minutes * 60;
 	drawStringInSurface(Common::String::format("%02d", seconds), 232, 12, front, back, surface);
 
 	Common::String message;
@@ -1099,11 +1096,10 @@ void DrillerEngine::drawAmigaAtariSTUI(Graphics::Surface *surface) {
 	drawStringInSurface(_currentArea->_name, 188, 185, yellow, black, surface);
 	drawStringInSurface(Common::String::format("%07d", score), 240, 129, yellow, black, surface);
 
-	int hours = _countdown <= 0 ? 0 : _countdown / 3600;
+	int seconds, minutes, hours;
+	getTimeFromCountdown(seconds, minutes, hours);
 	drawStringInSurface(Common::String::format("%02d:", hours), 208, 7, yellow, black, surface);
-	int minutes = _countdown <= 0 ? 0 : (_countdown - hours * 3600) / 60;
 	drawStringInSurface(Common::String::format("%02d:", minutes), 230, 7, yellow, black, surface);
-	int seconds = _countdown <= 0 ? 0 : _countdown - hours * 3600 - minutes * 60;
 	drawStringInSurface(Common::String::format("%02d", seconds), 254, 7, yellow, black, surface);
 
 	Common::String message;
@@ -1492,6 +1488,33 @@ bool DrillerEngine::checkDrill(const Math::Vector3d position) {
 }
 
 
+void DrillerEngine::addSkanner(Area *area) {
+	debug("area: %d", area->getAreaID());
+	GeometricObject *obj = nullptr;
+	int16 id;
+
+	id = 248;
+	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+	assert(obj);
+	obj = (GeometricObject *)obj->duplicate();
+	area->addObject(obj);
+
+	id = 249;
+	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+	assert(obj);
+	obj = (GeometricObject *)obj->duplicate();
+	area->addObject(obj);
+
+	id = 250;
+	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+	assert(obj);
+	obj = (GeometricObject *)obj->duplicate();
+	area->addObject(obj);
+}
+
 void DrillerEngine::addDrill(const Math::Vector3d position, bool gasFound) {
 	// int drillObjectIDs[8] = {255, 254, 253, 252, 251, 250, 248, 247};
 	GeometricObject *obj = nullptr;
@@ -1606,6 +1629,7 @@ void DrillerEngine::initGameState() {
 			removeDrill(it._value);
 		_drillStatusByArea[it._key] = kDrillerNoRig;
 		if (it._key != 255) {
+			addSkanner(it._value);
 			_drillMaxScoreByArea[it._key] = (10 + _rnd->getRandomNumber(89)) * 1000;
 		}
 		_drillSuccessByArea[it._key] = 0;
@@ -1624,7 +1648,7 @@ void DrillerEngine::initGameState() {
 	_playerHeight = _playerHeights[_playerHeightNumber];
 	removeTimers();
 	startCountdown(_initialCountdown);
-
+	_lastMinute = 0;
 	_demoIndex = 0;
 	_demoEvents.clear();
 }


Commit: 995b5a84522e30f2b50b066da28e066e52482cb0
    https://github.com/scummvm/scummvm/commit/995b5a84522e30f2b50b066da28e066e52482cb0
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-01-29T13:15:18+01:00

Commit Message:
FREESCAPE: implemented SETVAR instruction

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


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 3e108874486..cca53101991 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -244,6 +244,7 @@ public:
 	// Instructions
 	void executeIncrementVariable(FCLInstruction &instruction);
 	void executeDecrementVariable(FCLInstruction &instruction);
+	void executeSetVariable(FCLInstruction &instruction);
 	void executeGoto(FCLInstruction &instruction);
 	void executeIfThenElse(FCLInstruction &instruction);
 	void executeMakeInvisible(FCLInstruction &instruction);
diff --git a/engines/freescape/language/8bitDetokeniser.cpp b/engines/freescape/language/8bitDetokeniser.cpp
index ba09025bc0e..20eb2d0733a 100644
--- a/engines/freescape/language/8bitDetokeniser.cpp
+++ b/engines/freescape/language/8bitDetokeniser.cpp
@@ -340,7 +340,7 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
 
 		case 20:
 			detokenisedStream += "SETVAR ";
-			detokenisedStream += Common::String::format("(%d, v%d)", (int)tokenisedCondition[bytePointer], (int)tokenisedCondition[bytePointer + 1]);
+			detokenisedStream += Common::String::format("(v%d, %d)", (int)tokenisedCondition[bytePointer], (int)tokenisedCondition[bytePointer + 1]);
 			bytePointer += 2;
 			numberOfArguments = 0;
 			break;
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 204f1bce1a6..473b3748cd3 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -130,6 +130,9 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
 		case Token::SUBVAR:
 			executeDecrementVariable(instruction);
 			break;
+		case Token::SETVAR:
+			executeSetVariable(instruction);
+			break;
 		case Token::GOTO:
 			executeGoto(instruction);
 			break;
@@ -327,6 +330,16 @@ void FreescapeEngine::executeDecrementVariable(FCLInstruction &instruction) {
 		debugC(1, kFreescapeDebugCode, "Variable %d by %d incremented up to %d!", variable, decrement, _gameStateVars[variable]);
 }
 
+void FreescapeEngine::executeSetVariable(FCLInstruction &instruction) {
+	uint16 variable = instruction._source;
+	uint16 value = instruction._destination;
+	_gameStateVars[variable] = value;
+	if (variable == k8bitVariableEnergy)
+		debugC(1, kFreescapeDebugCode, "Energy set to %d", value);
+	else
+		debugC(1, kFreescapeDebugCode, "Variable %d by set to %d!", variable, value);
+}
+
 void FreescapeEngine::executeDestroy(FCLInstruction &instruction) {
 	uint16 objectID = 0;
 	uint16 areaID = _currentArea->getAreaID();




More information about the Scummvm-git-logs mailing list