[Scummvm-git-logs] scummvm master -> 8e1686659b3ef066d1f7c6da841f6391fbd65d28

mgerhardy martin.gerhardy at gmail.com
Wed Dec 23 14:50:10 UTC 2020


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

Summary:
b0e9aac6a9 TWINE: refactored the wait we control the fps in the game
32d0007e90 TWINE: reduced cyclic complexity
3528957112 TWINE: make the grid brick buffer size dependent from the resolution
1c7c5351c3 TWINE: replaced magic numbers
8e1686659b TWINE: made polygon buffer resolution dependent


Commit: b0e9aac6a973e3c2f4659d7744deecc9836c1d84
    https://github.com/scummvm/scummvm/commit/b0e9aac6a973e3c2f4659d7744deecc9836c1d84
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T14:28:07+01:00

Commit Message:
TWINE: refactored the wait we control the fps in the game

Changed paths:
    engines/twine/debugger/debug.cpp
    engines/twine/flamovies.cpp
    engines/twine/menu/menu.cpp
    engines/twine/menu/menuoptions.cpp
    engines/twine/renderer/screens.cpp
    engines/twine/scene/gamestate.cpp
    engines/twine/script/script_life_v1.cpp
    engines/twine/text.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/debugger/debug.cpp b/engines/twine/debugger/debug.cpp
index dd974a3566..5de69d6b20 100644
--- a/engines/twine/debugger/debug.cpp
+++ b/engines/twine/debugger/debug.cpp
@@ -427,6 +427,7 @@ void Debug::debugProcessWindow() {
 		debugDrawWindows();
 
 		for (;;) {
+			ScopedFPS scopedFps(25);
 			_engine->readKeys();
 			if (_engine->shouldQuit()) {
 				break;
@@ -463,8 +464,6 @@ void Debug::debugProcessWindow() {
 				break;
 			}
 
-			_engine->_system->delayMillis(1000 / 25); // rest
-
 			count++;
 		}
 		_engine->_redraw->reqBgRedraw = true;
diff --git a/engines/twine/flamovies.cpp b/engines/twine/flamovies.cpp
index 7241271f61..2fa6b966bb 100644
--- a/engines/twine/flamovies.cpp
+++ b/engines/twine/flamovies.cpp
@@ -304,6 +304,7 @@ void FlaMovies::playFlaMovie(const char *flaName) {
 		ScopedKeyMap scopedKeyMap(_engine, cutsceneKeyMapId);
 
 		do {
+			ScopedFPS scopedFps(flaHeaderData.speed);
 			_engine->readKeys();
 			if (_engine->shouldQuit()) {
 				break;
@@ -334,8 +335,6 @@ void FlaMovies::playFlaMovie(const char *flaName) {
 			}
 
 			currentFrame++;
-
-			_engine->_system->delayMillis(1000 / flaHeaderData.speed + 1);
 		} while (!_engine->_input->toggleAbortAction());
 	}
 
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index 3ba0dc712d..5e6eb5e2a4 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -404,6 +404,7 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
 	}
 	uint32 startMillis = _engine->_system->getMillis();
 	do {
+		ScopedFPS scopedFps;
 		const uint32 loopMillis = _engine->_system->getMillis();
 		_engine->readKeys();
 
@@ -559,7 +560,6 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
 			startMillis = _engine->_system->getMillis();
 			_engine->_screens->loadMenuImage(false);
 		}
-		_engine->_system->delayMillis(10);
 	} while (!_engine->_input->toggleActionIfActive(TwinEActionType::UIEnter));
 
 	return menuSettings->getActiveButtonTextId();
@@ -719,6 +719,7 @@ bool Menu::init() {
 }
 
 EngineState Menu::run() {
+	ScopedFPS scopedFps;
 	_engine->_text->initTextBank(TextBankId::Options_and_menus);
 
 	_engine->_music->playTrackMusic(9); // LBA's Theme
@@ -751,7 +752,6 @@ EngineState Menu::run() {
 		debug("quit the game");
 		return EngineState::QuitGame;
 	}
-	_engine->_system->delayMillis(1000 / _engine->cfgfile.Fps);
 	return EngineState::Menu;
 }
 
@@ -770,6 +770,7 @@ int32 Menu::giveupMenu() {
 
 	int32 menuId;
 	do {
+		ScopedFPS scopedFps;
 		_engine->_text->initTextBank(TextBankId::Options_and_menus);
 		menuId = processMenu(localMenu);
 		switch (menuId) {
@@ -788,7 +789,6 @@ int32 Menu::giveupMenu() {
 			warning("Unknown menu button handled: %i", menuId);
 		}
 		_engine->_text->initTextBank(_engine->_scene->sceneTextBank + 3);
-		_engine->_system->delayMillis(1000 / _engine->cfgfile.Fps);
 	} while (menuId != TextId::kGiveUp && menuId != TextId::kContinue && menuId != TextId::kCreateSaveGame);
 
 	return 0;
@@ -988,6 +988,7 @@ void Menu::processBehaviourMenu() {
 #endif
 	ScopedKeyMap scopedKeyMap(_engine, uiKeyMapId);
 	while (_engine->_input->isActionActive(TwinEActionType::BehaviourMenu) || _engine->_input->isQuickBehaviourActionActive()) {
+		ScopedFPS scopedFps(50);
 		_engine->readKeys();
 
 #if 0
@@ -1026,7 +1027,6 @@ void Menu::processBehaviourMenu() {
 
 		drawBehaviour(_engine->_actor->heroBehaviour, -1, true);
 
-		_engine->_system->delayMillis(1000 / 50);
 		_engine->lbaTime++;
 	}
 
@@ -1117,7 +1117,7 @@ void Menu::processInventoryMenu() {
 #endif
 	ScopedKeyMap scopedKeyMap(_engine, uiKeyMapId);
 	for (;;) {
-		ScopedFPS fps(1000 / 15);
+		ScopedFPS fps(66);
 		_engine->readKeys();
 		int32 prevSelectedItem = inventorySelectedItem;
 
@@ -1194,8 +1194,6 @@ void Menu::processInventoryMenu() {
 			drawItem(inventorySelectedItem);
 			break;
 		}
-
-		_engine->_system->delayMillis(1);
 	}
 
 	_engine->_text->_hasValidTextHandle = false;
diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index 703f239ad2..829677c3c0 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -253,6 +253,7 @@ bool MenuOptions::enterPlayerName(int32 textIdx) {
 	Common::fill(&_onScreenKeyboardDirty[0], &_onScreenKeyboardDirty[ARRAYSIZE(_onScreenKeyboardDirty)], 1);
 	ScopedFeatureState scopedVirtualKeyboard(OSystem::kFeatureVirtualKeyboard, true);
 	for (;;) {
+		ScopedFPS scopedFps;
 		Common::Event event;
 		while (g_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
@@ -337,7 +338,6 @@ bool MenuOptions::enterPlayerName(int32 textIdx) {
 		}
 		drawPlayerName(halfScreenWidth, 100, 1);
 		drawSelectableCharacters();
-		_engine->_system->delayMillis(1);
 	}
 	return false;
 }
diff --git a/engines/twine/renderer/screens.cpp b/engines/twine/renderer/screens.cpp
index 9ca4278f8c..bf3e95371f 100644
--- a/engines/twine/renderer/screens.cpp
+++ b/engines/twine/renderer/screens.cpp
@@ -167,6 +167,7 @@ void Screens::adjustCrossPalette(const uint32 *pal1, const uint32 *pal2) {
 	const uint8 *pal2p = (const uint8 *)pal2;
 	uint8 *paletteOut = (uint8 *)pal;
 	do {
+		ScopedFPS scopedFps(50);
 		counter = 0;
 
 		uint8 *newR = &paletteOut[counter];
@@ -189,8 +190,6 @@ void Screens::adjustCrossPalette(const uint32 *pal1, const uint32 *pal2) {
 		}
 
 		_engine->setPalette(pal);
-		_engine->_system->delayMillis(1000 / 50);
-
 		intensity++;
 	} while (intensity <= 100);
 }
@@ -201,8 +200,8 @@ void Screens::fadeToBlack(const uint32 *pal) {
 	}
 
 	for (int32 i = 100; i >= 0; i -= 3) {
+		ScopedFPS scopedFps(50);
 		adjustPalette(0, 0, 0, pal, i);
-		_engine->_system->delayMillis(1000 / 50);
 	}
 
 	palResetted = true;
@@ -210,8 +209,8 @@ void Screens::fadeToBlack(const uint32 *pal) {
 
 void Screens::fadeToPal(const uint32 *pal) {
 	for (int32 i = 0; i <= 100; i += 3) {
+		ScopedFPS scopedFps(50);
 		adjustPalette(0, 0, 0, pal, i);
-		_engine->_system->delayMillis(1000 / 50);
 	}
 
 	_engine->setPalette(pal);
@@ -240,15 +239,15 @@ void Screens::setBackPal() {
 
 void Screens::fadePalRed(const uint32 *pal) {
 	for (int32 i = 100; i >= 0; i -= 2) {
+		ScopedFPS scopedFps(50);
 		adjustPalette(0xFF, 0, 0, pal, i);
-		_engine->_system->delayMillis(1000 / 50);
 	}
 }
 
 void Screens::fadeRedPal(const uint32 *pal) {
 	for (int32 i = 0; i <= 100; i += 2) {
+		ScopedFPS scopedFps(50);
 		adjustPalette(0xFF, 0, 0, pal, i);
-		_engine->_system->delayMillis(1000 / 50);
 	}
 }
 
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index c6d2cb04eb..6a82e60250 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -387,11 +387,11 @@ void GameState::processFoundItem(int32 item) {
 	}
 
 	while (_engine->_text->playVoxSimple(_engine->_text->currDialTextEntry)) {
+		ScopedFPS scopedFps;
 		_engine->readKeys();
 		if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
 			break;
 		}
-		_engine->_system->delayMillis(1);
 	}
 
 	initEngineProjections();
@@ -421,6 +421,7 @@ void GameState::processGameChoices(int32 choiceIdx) {
 	// get right VOX entry index
 	if (_engine->_text->initVoxToPlay(choiceAnswer)) {
 		while (_engine->_text->playVoxSimple(_engine->_text->currDialTextEntry)) {
+			ScopedFPS scopedFps;
 			if (_engine->shouldQuit()) {
 				break;
 			}
@@ -461,6 +462,7 @@ void GameState::processGameoverAnimation() {
 	_engine->_interface->setClip(rect);
 
 	while (!_engine->_input->toggleAbortAction() && (_engine->lbaTime - startLbaTime) <= 500) {
+		ScopedFPS scopedFps(66);
 		_engine->readKeys();
 		if (_engine->shouldQuit()) {
 			free(gameOverPtr);
@@ -476,7 +478,6 @@ void GameState::processGameoverAnimation() {
 		_engine->copyBlockPhys(rect);
 
 		_engine->lbaTime++;
-		_engine->_system->delayMillis(15);
 	}
 
 	_engine->_sound->playSample(Samples::Explode);
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index 9e25b462ea..af597a397a 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -1617,12 +1617,6 @@ static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_screens->clearScreen();
 	engine->setPalette(engine->_screens->paletteRGBA);
 	engine->cfgfile.FlagDisplayText = tmpFlagDisplayText;
-
-	do {
-		engine->readKeys();
-		engine->_system->delayMillis(1);
-	} while (engine->_input->toggleAbortAction());
-
 	return 0;
 }
 
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 673174e10b..dbefed455d 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -634,22 +634,22 @@ bool Text::drawTextFullscreen(int32 index) {
 			stopVox(currDialTextEntry);
 			// wait displaying text
 			for (;;) {
+				ScopedFPS scopedFps;
 				_engine->readKeys();
 				if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
 					aborted = true;
 					break;
 				}
-				_engine->_system->delayMillis(1);
 			}
 		}
 	} else { // RECHECK THIS
 		while (playVox(currDialTextEntry)) {
+			ScopedFPS scopedFps;
 			_engine->readKeys();
 			if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
 				aborted = true;
 				break;
 			}
-			_engine->_system->delayMillis(1);
 		}
 		hasHiddenVox = false;
 		voxHiddenIndex = 0;
@@ -779,11 +779,13 @@ void Text::drawAskQuestion(int32 index) {
 
 	ProgressiveTextState textStatus = ProgressiveTextState::UNK1;
 	do {
+		ScopedFPS scopedFps;
 		_engine->readKeys();
 		textStatus = updateProgressiveText();
 
 		if (textStatus == ProgressiveTextState::NextPage) {
 			do {
+				ScopedFPS scopedFpsNextPage;
 				_engine->readKeys();
 				if (_engine->shouldQuit()) {
 					break;
@@ -791,19 +793,16 @@ void Text::drawAskQuestion(int32 index) {
 				if (!playVoxSimple(currDialTextEntry)) {
 					break;
 				}
-				_engine->_system->delayMillis(1);
 			} while (!_engine->_input->toggleAbortAction());
 		}
-
-		_engine->_system->delayMillis(1);
 	} while (textStatus != ProgressiveTextState::End);
 
 	while (playVoxSimple(currDialTextEntry)) {
+		ScopedFPS scopedFps;
 		if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
 			stopVox(currDialTextEntry);
 			break;
 		}
-		_engine->_system->delayMillis(1);
 	}
 
 	hasHiddenVox = false;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index b2aa6d82fc..d4ae4eaadf 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -754,11 +754,11 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 			_text->drawText(5, 446, "Pause"); // no key for pause in Text Bank
 			copyBlockPhys(5, 446, 100, 479);
 			do {
+				ScopedFPS scopedFps;
 				readKeys();
 				if (shouldQuit()) {
 					break;
 				}
-				g_system->delayMillis(10);
 			} while (!_input->toggleActionIfActive(TwinEActionType::Pause));
 			unfreezeTime();
 			_redraw->redrawEngineActions(true);
@@ -964,6 +964,7 @@ bool TwinEEngine::delaySkip(uint32 time) {
 	uint32 startTicks = _system->getMillis();
 	uint32 stopTicks = 0;
 	do {
+		ScopedFPS scopedFps;
 		readKeys();
 		if (_input->toggleAbortAction()) {
 			return true;
@@ -972,7 +973,6 @@ bool TwinEEngine::delaySkip(uint32 time) {
 			return true;
 		}
 		stopTicks = _system->getMillis() - startTicks;
-		_system->delayMillis(1);
 		//lbaTime++;
 	} while (stopTicks <= time);
 	return false;


Commit: 32d0007e907dceffd478df97de0480754b7bce40
    https://github.com/scummvm/scummvm/commit/32d0007e907dceffd478df97de0480754b7bce40
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T14:31:03+01:00

Commit Message:
TWINE: reduced cyclic complexity

Changed paths:
    engines/twine/debugger/debug.cpp


diff --git a/engines/twine/debugger/debug.cpp b/engines/twine/debugger/debug.cpp
index 5de69d6b20..48dc983144 100644
--- a/engines/twine/debugger/debug.cpp
+++ b/engines/twine/debugger/debug.cpp
@@ -106,7 +106,7 @@ int32 Debug::debugTypeUseMenu(int32 type) {
 			if (btn.type != type) {
 				continue;
 			}
-			int submenu = btn.submenu;
+			const int submenu = btn.submenu;
 			if (submenu > 0) {
 				debugWindows[submenu].isActive = !debugWindows[submenu].isActive;
 			}
@@ -182,7 +182,7 @@ void Debug::debugResetButton(int32 type) {
 			if (btn.type != type) {
 				continue;
 			}
-			int submenu = btn.submenu;
+			const int submenu = btn.submenu;
 			btn.isActive = 0;
 			if (submenu > 0) {
 				debugWindows[submenu].debugButtons[b].isActive = !debugWindows[submenu].debugButtons[b].isActive;
@@ -405,7 +405,7 @@ void Debug::debugPlasmaWindow(const char *text, int32 color) {
 	if (!(_engine->getRandomNumber() % 5)) {
 		_engine->_menu->plasmaEffectPtr[_engine->getRandomNumber() % PLASMA_WIDTH * 10 + 6400] = 255;
 	}
-	int32 textSize = _engine->_text->getTextSize(text);
+	const int32 textSize = _engine->_text->getTextSize(text);
 	_engine->_text->drawText((SCREEN_WIDTH / 2) - (textSize / 2), 10, text);
 	const Common::Rect rect(5, 5, 634, 50);
 	_engine->_menu->drawBox(rect);
@@ -413,61 +413,61 @@ void Debug::debugPlasmaWindow(const char *text, int32 color) {
 }
 
 void Debug::debugProcessWindow() {
-	if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenu)) {
-		const char *text = "Game Debug Window";
-		int32 colorIdx = 4;
-		int32 count = 0;
+	if (!_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenu)) {
+		return;
+	}
+	const char *text = "Game Debug Window";
+	int32 colorIdx = 4;
+	int32 count = 0;
 
-		_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
+	_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
 
-		debugResetButtonsState();
-		if (numDebugWindows == 0) {
-			debugLeftMenu();
-		}
-		debugDrawWindows();
+	debugResetButtonsState();
+	if (numDebugWindows == 0) {
+		debugLeftMenu();
+	}
+	debugDrawWindows();
 
-		for (;;) {
-			ScopedFPS scopedFps(25);
-			_engine->readKeys();
-			if (_engine->shouldQuit()) {
-				break;
-			}
-			const Common::Point &point = _engine->_input->getMousePositions();
-
-			if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenuActivate)) {
-				int type = 0;
-				if ((type = debugProcessButton(point.x, point.y)) != NO_ACTION) { // process menu item
-					if (debugTypeUseMenu(type)) {
-						_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
-						_engine->copyBlockPhys(205, 55, 634, 474);
-					}
-
-					debugRefreshButtons(type);
-					debugSetActions(type);
+	for (;;) {
+		ScopedFPS scopedFps(25);
+		_engine->readKeys();
+		if (_engine->shouldQuit()) {
+			break;
+		}
+		const Common::Point &point = _engine->_input->getMousePositions();
+
+		if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenuActivate)) {
+			int type = 0;
+			if ((type = debugProcessButton(point.x, point.y)) != NO_ACTION) { // process menu item
+				if (debugTypeUseMenu(type)) {
+					_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
+					_engine->copyBlockPhys(205, 55, 634, 474);
 				}
-			}
 
-			// draw window plasma effect
-			if (count == 256) {
-				colorIdx++;
-				count = 0;
-			}
-			int32 color = colorIdx * 16;
-			if (color >= 240) {
-				color = 64;
-				colorIdx = 4;
+				debugRefreshButtons(type);
+				debugSetActions(type);
 			}
-			debugPlasmaWindow(text, color);
+		}
 
-			// quit
-			if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenu)) {
-				break;
-			}
+		// draw window plasma effect
+		if (count == 256) {
+			colorIdx++;
+			count = 0;
+		}
+		int32 color = colorIdx * 16;
+		if (color >= 240) {
+			color = 64;
+			colorIdx = 4;
+		}
+		debugPlasmaWindow(text, color);
 
-			count++;
+		if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugMenu)) {
+			break;
 		}
-		_engine->_redraw->reqBgRedraw = true;
+
+		count++;
 	}
+	_engine->_redraw->reqBgRedraw = true;
 }
 
 void Debug::processDebug() {


Commit: 35289571129ba661a62d3c0b2d6e1af03061d4ac
    https://github.com/scummvm/scummvm/commit/35289571129ba661a62d3c0b2d6e1af03061d4ac
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T14:39:28+01:00

Commit Message:
TWINE: make the grid brick buffer size dependent from the resolution

Changed paths:
    engines/twine/scene/grid.h


diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index 734bc15a28..ae7c34cbb7 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "twine/shared.h"
+#include "twine/twine.h"
 
 namespace Graphics {
 class ManagedSurface;
@@ -72,6 +73,8 @@ struct BrickEntry {
 /** Grip Z size */
 #define GRID_SIZE_Z GRID_SIZE_X
 
+#define NUMBRICKENTRIES (1 + (SCREEN_WIDTH + 24) / 24)
+
 class TwinEEngine;
 
 class Grid {
@@ -152,9 +155,9 @@ private:
 	int32 numberOfBll = 0;
 
 	/** Brick data buffer */
-	BrickEntry bricksDataBuffer[28][150];
+	BrickEntry bricksDataBuffer[NUMBRICKENTRIES][150];
 	/** Brick info buffer */
-	int16 brickInfoBuffer[28]{0};
+	int16 brickInfoBuffer[NUMBRICKENTRIES]{0};
 
 	/** Current brick pixel X position */
 	int32 brickPixelPosX = 0;


Commit: 1c7c5351c39fea5db3dfdbb4d04e67b6be3f5c91
    https://github.com/scummvm/scummvm/commit/1c7c5351c39fea5db3dfdbb4d04e67b6be3f5c91
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T14:43:07+01:00

Commit Message:
TWINE: replaced magic numbers

Changed paths:
    engines/twine/scene/grid.cpp


diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 6afcbfd290..3b65c4404a 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -393,14 +393,14 @@ void Grid::createGridMap() {
 
 	for (int32 z = 0; z < GRID_SIZE_Z; z++) {
 		int32 blockOffset = currOffset;
-		int32 gridIdx = z << 6;
+		const int32 gridIdx = z << 6;
 
 		for (int32 x = 0; x < GRID_SIZE_X; x++) {
-			int32 gridOffset = READ_LE_UINT16(currentGrid + 2 * (x + gridIdx));
+			const int32 gridOffset = READ_LE_UINT16(currentGrid + 2 * (x + gridIdx));
 			createGridColumn(currentGrid + gridOffset, currentGridSize - gridOffset, blockBuffer + blockOffset, blockBufferSize - blockOffset);
 			blockOffset += 50;
 		}
-		currOffset += 3200;
+		currOffset += GRID_SIZE_X * 50;
 	}
 }
 
@@ -413,13 +413,13 @@ void Grid::createCellingGridMap(const uint8 *gridPtr, int32 gridPtrSize) {
 		const uint8 *tempGridPtr = gridPtr + currGridOffset;
 
 		for (int32 x = 0; x < GRID_SIZE_X; x++) {
-			int gridOffset = READ_LE_UINT16(tempGridPtr);
+			const int gridOffset = READ_LE_UINT16(tempGridPtr);
 			tempGridPtr += 2;
 			createCellingGridColumn(gridPtr + gridOffset, gridPtrSize - gridOffset, blockBuffer + blockOffset, blockBufferSize - blockOffset);
 			blockOffset += 50;
 		}
 		currGridOffset += 128;
-		currOffset += 3200;
+		currOffset += GRID_SIZE_X * 50;
 	}
 }
 


Commit: 8e1686659b3ef066d1f7c6da841f6391fbd65d28
    https://github.com/scummvm/scummvm/commit/8e1686659b3ef066d1f7c6da841f6391fbd65d28
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T14:46:30+01:00

Commit Message:
TWINE: made polygon buffer resolution dependent

Changed paths:
    engines/twine/renderer/renderer.h


diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 407866d7e3..60f0ef4bc7 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -27,6 +27,7 @@
 #include "common/rect.h"
 #include "common/scummsys.h"
 #include "twine/parser/body.h"
+#include "twine/twine.h"
 
 #define POLYGONTYPE_FLAT 0
 #define POLYGONTYPE_COPPER 1
@@ -38,6 +39,8 @@
 #define POLYGONTYPE_GOURAUD 7
 #define POLYGONTYPE_DITHER 8
 
+#define POLYTABSIZE (SCREEN_HEIGHT + (SCREEN_HEIGHT / 2))
+
 namespace Common {
 class MemoryReadStream;
 }
@@ -362,8 +365,8 @@ private:
 	RenderCommand _renderCmds[1000];
 	uint8 renderCoordinatesBuffer[10000]{0};
 
-	int16 polyTab[960]{0};
-	int16 polyTab2[960]{0};
+	int16 polyTab[POLYTABSIZE]{0};
+	int16 polyTab2[POLYTABSIZE]{0};
 	// end render polygon vars
 
 	bool isUsingOrhoProjection = false;




More information about the Scummvm-git-logs mailing list