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

mgerhardy martin.gerhardy at gmail.com
Fri Oct 30 22:53:40 UTC 2020


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

Summary:
9f316e4757 TWINE: introduced sample constants
a04bb62cac TWINE: reduced visibility
5fd0fb22d4 TWINE: removed unused method from HQRDepack
2dfbde435a TWINE: cleanup error and warning messages
216306859b TWINE: the hqr code doesn't have any state - converted back to functions
e93dd7d519 TWINE: removed unused entries from pressedKeyCharMap
39be27bbe6 TWINE: removed unused PageUp action type
8db2b58a9a TWINE: const


Commit: 9f316e4757521acf4ead2330abfb35bff959c616
    https://github.com/scummvm/scummvm/commit/9f316e4757521acf4ead2330abfb35bff959c616
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:50:44+01:00

Commit Message:
TWINE: introduced sample constants

Changed paths:
    engines/twine/actor.cpp
    engines/twine/animations.cpp
    engines/twine/extra.cpp
    engines/twine/gamestate.cpp
    engines/twine/redraw.cpp
    engines/twine/scene.cpp
    engines/twine/sound.cpp
    engines/twine/sound.h
    engines/twine/twine.cpp


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 65fd68711e..d99194e3d7 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -517,12 +517,12 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
 	if (actor->dynamicFlags.bIsDead) {
 		_engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, 0x100, 0, currentBonus, actor->bonusAmount);
 		// FIXME add constant for sample index
-		_engine->_sound->playSample(11, 0x1000, 1, actor->x, actor->y, actor->z, actorIdx);
+		_engine->_sound->playSample(Samples::ItemPopup, 0x1000, 1, actor->x, actor->y, actor->z, actorIdx);
 	} else {
 		int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(actor->x, actor->z, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->z);
 		_engine->_extra->addExtraBonus(actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, 200, angle, currentBonus, actor->bonusAmount);
 		// FIXME add constant for sample index
-		_engine->_sound->playSample(11, 0x1000, 1, actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, actorIdx);
+		_engine->_sound->playSample(Samples::ItemPopup, 0x1000, 1, actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, actorIdx);
 	}
 }
 
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 9d6e80a366..949d02ce18 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -515,7 +515,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int16 sampleIdx = stream.readSint16LE();
 
 			if (animPos == actor->animPosition) {
-				_engine->_sound->playSample(sampleIdx, 0x1000, 1, actor->x, actor->y, actor->z, actorIdx);
+				_engine->_sound->playSample(sampleIdx, 4096, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
 		}
@@ -525,7 +525,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 			int16 frequency = stream.readSint16LE();
 
 			if (animPos == actor->animPosition) {
-				frequency = _engine->getRandomNumber(frequency) + 0x1000 - (ABS(frequency) >> 1);
+				frequency = _engine->getRandomNumber(frequency) + 4096 - (ABS(frequency) >> 1);
 				_engine->_sound->playSample(sampleIdx, frequency, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
@@ -611,14 +611,14 @@ void Animations::processAnimActions(int32 actorIdx) {
 		case ACTION_SAMPLE_BRICK_1:
 			animPos = stream.readByte();
 			if (animPos == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
-				const int16 sampleIdx = (actor->brickSound & 0x0F) + 126;
+				const int16 sampleIdx = (actor->brickSound & 0x0F) + Samples::WalkFloorBegin;
 				_engine->_sound->playSample(sampleIdx, _engine->getRandomNumber(1000) + 3596, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
 		case ACTION_SAMPLE_BRICK_2:
 			animPos = stream.readByte();
 			if (animPos == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
-				const int16 sampleIdx = (actor->brickSound & 0x0F) + 126;
+				const int16 sampleIdx = (actor->brickSound & 0x0F) + Samples::WalkFloorBegin;
 				_engine->_sound->playSample(sampleIdx, _engine->getRandomNumber(1000) + 3596, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index fec4813b24..7280ff8754 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -670,7 +670,7 @@ void Extra::processExtras() {
 				int32 angle = (tmpAngle - extra->angle) & 0x3FF;
 
 				if (angle > 400 && angle < 600) {
-					_engine->_sound->playSample(97, 0x1000, 1, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->y, _engine->_scene->sceneHero->z, 0);
+					_engine->_sound->playSample(Samples::ItemFound, 4096, 1, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->y, _engine->_scene->sceneHero->z, 0);
 
 					if (extraKey->info1 > 1) {
 						_engine->_renderer->projectPositionOnScreen(extraKey->x - _engine->_grid->cameraX, extraKey->y - _engine->_grid->cameraY, extraKey->z - _engine->_grid->cameraZ);
@@ -703,7 +703,7 @@ void Extra::processExtras() {
 				_engine->_movements->setActorAngle(0, extra->destZ, 50, &extra->trackActorMove);
 
 				if (actorIdx == _engine->_collision->checkExtraCollisionWithExtra(extra, _engine->_gameState->magicBallIdx)) {
-					_engine->_sound->playSample(97, 0x1000, 1, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->y, _engine->_scene->sceneHero->z, 0);
+					_engine->_sound->playSample(Samples::ItemFound, 4096, 1, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->y, _engine->_scene->sceneHero->z, 0);
 
 					if (extraKey->info1 > 1) {
 						_engine->_renderer->projectPositionOnScreen(extraKey->x - _engine->_grid->cameraX, extraKey->y - _engine->_grid->cameraY, extraKey->z - _engine->_grid->cameraZ);
@@ -778,8 +778,7 @@ void Extra::processExtras() {
 					}
 					// if extra is magic ball
 					if (i == _engine->_gameState->magicBallIdx) {
-						// FIXME: add constant for sample index
-						_engine->_sound->playSample(86, _engine->getRandomNumber(300) + 3946, 1, extra->x, extra->y, extra->z, -1);
+						_engine->_sound->playSample(Samples::Hit, _engine->getRandomNumber(300) + 3946, 1, extra->x, extra->y, extra->z);
 
 						// cant bounce with not magic points
 						if (_engine->_gameState->magicBallNumBounce <= 0) {
@@ -850,8 +849,7 @@ void Extra::processExtras() {
 			if ((extra->type & 0x20) && !(extra->type & 0x2)) {
 				// if hero touch extra
 				if (_engine->_collision->checkExtraCollisionWithActors(extra, -1) == 0) {
-					// FIXME: add constant for sample index
-					_engine->_sound->playSample(97, 4096, 1, extra->x, extra->y, extra->z);
+					_engine->_sound->playSample(Samples::ItemFound, 4096, 1, extra->x, extra->y, extra->z);
 
 					if (extra->info1 > 1 && !_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
 						_engine->_renderer->projectPositionOnScreen(extra->x - _engine->_grid->cameraX, extra->y - _engine->_grid->cameraY, extra->z - _engine->_grid->cameraZ);
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index e1b602b414..1be99333c1 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -311,7 +311,7 @@ void GameState::processFoundItem(int32 item) {
 	const int32 boxBottomRightX = _engine->_renderer->projPosX + 65;
 	const int32 boxBottomRightY = _engine->_renderer->projPosY + 65;
 
-	_engine->_sound->playSample(41);
+	_engine->_sound->playSample(Samples::BitItemFound);
 
 	// process vox play
 	_engine->_music->stopMusic();
@@ -485,7 +485,7 @@ void GameState::processGameoverAnimation() {
 		_engine->_system->delayMillis(15);
 	}
 
-	_engine->_sound->playSample(37, _engine->getRandomNumber(2000) + 3096);
+	_engine->_sound->playSample(Samples::Explode, _engine->getRandomNumber(2000) + 3096);
 	_engine->_interface->blitBox(left, top, right, bottom, (int8 *)_engine->workVideoBuffer.getPixels(), 120, 120, (int8 *)_engine->frontVideoBuffer.getPixels());
 	_engine->_renderer->setCameraAngle(0, 0, 0, 0, 0, 0, 3200);
 	_engine->_renderer->renderIsoModel(0, 0, 0, 0, 0, 0, gameOverPtr);
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 4536778ff5..6351193697 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -309,8 +309,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				if (_engine->lbaTime - extra->lifeTime > 35) {
 					extra->lifeTime = _engine->lbaTime;
 					extra->type &= 0xFBFF;
-					// FIXME make constant for sample index
-					_engine->_sound->playSample(11, 4096, 1, extra->x, extra->y, extra->z);
+					_engine->_sound->playSample(Samples::ItemPopup, 4096, 1, extra->x, extra->y, extra->z);
 				}
 			} else {
 				if ((extra->type & 1) || (extra->type & 0x40) || (extra->actorIdx + extra->lifeTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->lifeTime) & 8))) {
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 7c25ba8fe9..d4fc909f4a 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -347,13 +347,10 @@ ActorStruct *Scene::getActor(int32 actorIdx) {
 }
 
 void Scene::processEnvironmentSound() {
-	int16 s, currentAmb, decal, repeat;
-	int16 sampleIdx = -1;
-
 	if (_engine->lbaTime >= sampleAmbienceTime) {
-		currentAmb = _engine->getRandomNumber(4); // random ambiance
+		int16 currentAmb = _engine->getRandomNumber(4); // random ambiance
 
-		for (s = 0; s < 4; s++) {
+		for (int32 s = 0; s < 4; s++) {
 			if (!(samplePlayed & (1 << currentAmb))) { // if not already played
 				samplePlayed |= (1 << currentAmb);     // make sample played
 
@@ -361,12 +358,12 @@ void Scene::processEnvironmentSound() {
 					samplePlayed = 0;
 				}
 
-				sampleIdx = sampleAmbiance[currentAmb];
+				int16 sampleIdx = sampleAmbiance[currentAmb];
 				if (sampleIdx != -1) {
-					decal = sampleRound[currentAmb];
-					repeat = sampleRepeat[currentAmb];
+					int16 decal = sampleRound[currentAmb];
+					int16 repeat = sampleRepeat[currentAmb];
 
-					_engine->_sound->playSample(sampleIdx, (0x1000 + _engine->getRandomNumber(decal) - (decal / 2)), repeat, 110, -1, 110);
+					_engine->_sound->playSample(sampleIdx, (4096 + _engine->getRandomNumber(decal) - (decal / 2)), repeat, 110, -1, 110);
 					break;
 				}
 			}
diff --git a/engines/twine/sound.cpp b/engines/twine/sound.cpp
index c6aaeaad7c..cc73fea946 100644
--- a/engines/twine/sound.cpp
+++ b/engines/twine/sound.cpp
@@ -84,7 +84,6 @@ void Sound::playSample(int32 index, int32 frequency, int32 repeat, int32 x, int3
 		return;
 	}
 
-
 	if (actorIdx != -1) {
 		setSamplePosition(channelIdx, x, y, z);
 		// save the actor index for the channel so we can check the position
@@ -103,11 +102,16 @@ void Sound::playVoxSample(int32 index) {
 
 	int channelIdx = getFreeSampleChannelIndex();
 	if (channelIdx != -1) {
+		warning("Failed to play vox sample for index: %i - no free channel", index);
 		return;
 	}
 
 	uint8 *sampPtr = nullptr;
 	int32 sampSize = _engine->_hqrdepack->hqrGetallocVoxEntry(&sampPtr, _engine->_text->currentVoxBankFile.c_str(), index, _engine->_text->voxHiddenIndex);
+	if (sampSize == 0) {
+		warning("Failed to get vox sample for index: %i", index);
+		return;
+	}
 
 	// Fix incorrect sample files first byte
 	if (*sampPtr != 'C') {
diff --git a/engines/twine/sound.h b/engines/twine/sound.h
index eaf3ef1bab..f782480a98 100644
--- a/engines/twine/sound.h
+++ b/engines/twine/sound.h
@@ -31,6 +31,20 @@ namespace TwinE {
 
 #define NUM_CHANNELS 32
 
+namespace Samples {
+enum _Samples {
+	TwinsenHit = 0,
+	SoldierHit = 4,
+	ItemPopup = 11,
+	Explode = 37,
+	BitItemFound = 41,
+	TaskCompleted = 41,
+	Hit = 86,
+	ItemFound = 97,
+	WalkFloorBegin = 126
+};
+}
+
 class TwinEEngine;
 class Sound {
 private:
@@ -52,7 +66,6 @@ public:
 
 	bool isChannelPlaying(int32 channel);
 
-
 	/**
 	 * Play FLA movie samples
 	 * @param index sample index under flasamp.hqr file
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 095cb5a2d9..64c7d81411 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -650,7 +650,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 					_animations->initAnim(kLandDeath, 4, 0, 0);
 					actor->controlMode = ControlMode::kNoMove;
 				} else {
-					_sound->playSample(37, getRandomNumber(2000) + 3096, 1, actor->x, actor->y, actor->z, a);
+					_sound->playSample(Samples::Explode, getRandomNumber(2000) + 3096, 1, actor->x, actor->y, actor->z, a);
 
 					if (a == _scene->mecaPinguinIdx) {
 						_extra->addExtraExplode(actor->x, actor->y, actor->z);
@@ -697,7 +697,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 					if ((brickSound & 0xF) == 1) {
 						if (a) { // all other actors
 							int32 rnd = getRandomNumber(2000) + 3096;
-							_sound->playSample(37, rnd, 1, actor->x, actor->y, actor->z, a);
+							_sound->playSample(Samples::Explode, rnd, 1, actor->x, actor->y, actor->z, a);
 							if (actor->bonusParameter & 0x1F0) {
 								if (!(actor->bonusParameter & 1)) {
 									_actor->processActorExtraBonus(a);


Commit: a04bb62cacf5cf8c08b1c4af71e6c00b018d9a16
    https://github.com/scummvm/scummvm/commit/a04bb62cacf5cf8c08b1c4af71e6c00b018d9a16
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:50:44+01:00

Commit Message:
TWINE: reduced visibility

Changed paths:
    engines/twine/sound.h


diff --git a/engines/twine/sound.h b/engines/twine/sound.h
index f782480a98..cd753ad9b2 100644
--- a/engines/twine/sound.h
+++ b/engines/twine/sound.h
@@ -61,11 +61,17 @@ private:
 
 	bool playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize, int32 loop, const char *name, DisposeAfterUse::Flag disposeFlag = DisposeAfterUse::YES);
 
+	bool isChannelPlaying(int32 channel);
+
+	/** Find a free channel slot to use */
+	int32 getFreeSampleChannelIndex();
+
+	/** Remove a sample from the channel usage list */
+	void removeSampleChannel(int32 index);
+
 public:
 	Sound(TwinEEngine *engine);
 
-	bool isChannelPlaying(int32 channel);
-
 	/**
 	 * Play FLA movie samples
 	 * @param index sample index under flasamp.hqr file
@@ -87,6 +93,7 @@ public:
 	 * @param x sound generating entity x position
 	 * @param y sound generating entity y position
 	 * @param z sound generating entity z position
+	 * @param actorIdx
 	 */
 	void playSample(int32 index, int32 frequency = 4096, int32 repeat = 1, int32 x = 128, int32 y = 128, int32 z = 128, int32 actorIdx = -1);
 
@@ -105,12 +112,6 @@ public:
 	/** Stops a specific sample */
 	void stopSample(int32 index);
 
-	/** Find a free channel slot to use */
-	int32 getFreeSampleChannelIndex();
-
-	/** Remove a sample from the channel usage list */
-	void removeSampleChannel(int32 index);
-
 	/** Check if a sample is playing */
 	int32 isSamplePlaying(int32 index);
 


Commit: 5fd0fb22d413de501a12a9c7e0cb0dad869f919a
    https://github.com/scummvm/scummvm/commit/5fd0fb22d413de501a12a9c7e0cb0dad869f919a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:50:44+01:00

Commit Message:
TWINE: removed unused method from HQRDepack

Changed paths:
    engines/twine/hqrdepack.cpp
    engines/twine/hqrdepack.h


diff --git a/engines/twine/hqrdepack.cpp b/engines/twine/hqrdepack.cpp
index f6b99c6349..7bfb1d210a 100644
--- a/engines/twine/hqrdepack.cpp
+++ b/engines/twine/hqrdepack.cpp
@@ -53,40 +53,6 @@ void HQRDepack::hqrDecompressEntry(uint8 *dst, uint8 *src, int32 decompsize, int
 	} while (decompsize);
 }
 
-void HQRDepack::hqrDecompressLZEntry(uint8 *dst, uint8 *src, int32 decompsize, int32 mode) {
-	while (decompsize > 0) {
-		uint8 type = *(src++);
-		for (uint8 bits = 1; bits != 0; bits <<= 1) {
-			int32 length;
-			if (!(type & bits)) {
-				uint16 offset = *(uint16 *)(src);
-				src += 2;
-				length = (offset & 0x0F) + (mode + 1);
-				uint8 *ptr = dst - (offset >> 4) - 1;
-				if (offset == 0) {
-					memset(dst, *ptr, length);
-				} else {
-					if ((ptr + length) >= dst) {
-						uint8 *tmp = dst;
-						for (int32 n = 0; n < length; n++)
-							*tmp++ = *ptr++;
-					} else {
-						memcpy(dst, ptr, length);
-					}
-				}
-				dst += length;
-			} else {
-				length = 1;
-				*(dst++) = *(src++);
-			}
-			decompsize -= length;
-			if (decompsize <= 0) {
-				return;
-			}
-		}
-	}
-}
-
 int32 HQRDepack::hqrGetEntry(uint8 *ptr, const char *filename, int32 index) {
 	if (!ptr) {
 		return 0;
@@ -122,7 +88,7 @@ int32 HQRDepack::hqrGetEntry(uint8 *ptr, const char *filename, int32 index) {
 	}
 	// compressed: modes (1 & 2)
 	else if (mode == 1 || mode == 2) {
-		uint8 *compDataPtr = 0;
+		uint8 *compDataPtr = nullptr;
 		compDataPtr = (uint8 *)malloc(compSize);
 		wrap(file.read(compDataPtr, compSize))
 		hqrDecompressEntry(ptr, compDataPtr, realSize, mode);
diff --git a/engines/twine/hqrdepack.h b/engines/twine/hqrdepack.h
index 9eb837c917..d2fcce28a6 100644
--- a/engines/twine/hqrdepack.h
+++ b/engines/twine/hqrdepack.h
@@ -43,14 +43,6 @@ private:
 	 * @return entry real size
 	 * */
 	int hqrVoxEntrySize(const char *filename, int32 index, int32 hiddenIndex);
-	/**
-	 * Decompress entry based in the original expand lzss lba code
-	 * @param dst destination pointer where will be the decompressed entry
-	 * @param src compressed data pointer
-	 * @param decompsize real file size after decompression
-	 * @param mode compression mode used
-	 */
-	void hqrDecompressLZEntry(uint8 *dst, uint8 *src, int32 decompsize, int32 mode);
 	/**
 	 * Decompress entry based in Yaz0r and Zink decompression code
 	 * @param dst destination pointer where will be the decompressed entry


Commit: 2dfbde435ad040885f8aabafba0311320360d4ae
    https://github.com/scummvm/scummvm/commit/2dfbde435ad040885f8aabafba0311320360d4ae
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:50:44+01:00

Commit Message:
TWINE: cleanup error and warning messages

Changed paths:
    engines/twine/hqrdepack.cpp


diff --git a/engines/twine/hqrdepack.cpp b/engines/twine/hqrdepack.cpp
index 7bfb1d210a..959f4e8b93 100644
--- a/engines/twine/hqrdepack.cpp
+++ b/engines/twine/hqrdepack.cpp
@@ -36,10 +36,10 @@ void HQRDepack::hqrDecompressEntry(uint8 *dst, uint8 *src, int32 decompsize, int
 		for (int32 d = 0; d < 8; d++) {
 			int32 length;
 			if (!(b & (1 << d))) {
-				uint16 offset = *(uint16 *)(src);
+				const uint16 offset = *(uint16 *)(src);
 				src += 2;
 				length = (offset & 0x0F) + (mode + 1);
-				uint8 *ptr = dst - (offset >> 4) - 1;
+				const uint8 *ptr = dst - (offset >> 4) - 1;
 				for (int32 i = 0; i < length; i++)
 					*(dst++) = *(ptr++);
 			} else {
@@ -63,14 +63,14 @@ int32 HQRDepack::hqrGetEntry(uint8 *ptr, const char *filename, int32 index) {
 
 	Common::File file;
 	if (!file.open(filename)) {
-		debug("Could not open %s", filename);
+		debug("HQR: Could not open %s", filename);
 		return 0;
 	}
 
 	uint32 headerSize = file.readUint32LE();
 
 	if ((uint32)index >= headerSize / 4) {
-		warning("HQR WARNING: Invalid entry index!!");
+		warning("HQR: Invalid entry index");
 		return 0;
 	}
 
@@ -105,14 +105,14 @@ int32 HQRDepack::hqrEntrySize(const char *filename, int32 index) {
 
 	Common::File file;
 	if (!file.open(filename)) {
-		error("HQR: %s can't be found!", filename);
+		error("HQR: Could not open %s", filename);
 	}
 
 	uint32 headerSize;
 	wrap(file.read(&headerSize, 4))
 
 	if ((uint32)index >= headerSize / 4) {
-		warning("HQR WARNING: Invalid entry index!!");
+		warning("HQR: Invalid entry index");
 		return 0;
 	}
 
@@ -134,7 +134,7 @@ int32 HQRDepack::hqrNumEntries(const char *filename) {
 
 	Common::File file;
 	if (!file.open(filename)) {
-		error("HQR: %s can't be found!", filename);
+		error("HQR: Could not open %s", filename);
 	}
 
 	uint32 headerSize;
@@ -146,7 +146,7 @@ int32 HQRDepack::hqrGetallocEntry(uint8 **ptr, const char *filename, int32 index
 	const int32 size = hqrEntrySize(filename, index);
 	*ptr = (uint8 *)malloc(size * sizeof(uint8));
 	if (!*ptr) {
-		warning("HQR WARNING: unable to allocate entry memory!!");
+		warning("HQR: unable to allocate entry memory");
 		return 0;
 	}
 	hqrGetEntry(*ptr, filename, index);
@@ -164,14 +164,14 @@ int32 HQRDepack::hqrGetVoxEntry(uint8 *ptr, const char *filename, int32 index, i
 
 	Common::File file;
 	if (!file.open(filename)) {
-		error("HQR: %s can't be found!", filename);
+		error("HQR: Could not open %s", filename);
 	}
 
 	uint32 headerSize;
 	wrap(file.read(&headerSize, 4))
 
 	if ((uint32)index >= headerSize / 4) {
-		warning("HQR WARNING: Invalid entry index!!");
+		warning("HQR: Invalid entry index");
 		return 0;
 	}
 
@@ -220,14 +220,14 @@ int HQRDepack::hqrVoxEntrySize(const char *filename, int32 index, int32 hiddenIn
 
 	Common::File file;
 	if (!file.open(filename)) {
-		error("HQR: %s can't be found!", filename);
+		error("HQR: Could not open %s", filename);
 	}
 
 	uint32 headerSize;
 	wrap(file.read(&headerSize, 4))
 
 	if ((uint32)index >= headerSize / 4) {
-		warning("HQR WARNING: Invalid entry index!!");
+		warning("HQR: Invalid entry index");
 		return 0;
 	}
 
@@ -258,7 +258,7 @@ int32 HQRDepack::hqrGetallocVoxEntry(uint8 **ptr, const char *filename, int32 in
 
 	*ptr = (uint8 *)malloc(size * sizeof(uint8));
 	if (!*ptr) {
-		warning("HQR WARNING: unable to allocate entry memory!!\n");
+		warning("HQR: unable to allocate entry memory");
 		return 0;
 	}
 	hqrGetVoxEntry(*ptr, filename, index, hiddenIndex);


Commit: 216306859b714a2f859c534088b7c6ad7656a8ee
    https://github.com/scummvm/scummvm/commit/216306859b714a2f859c534088b7c6ad7656a8ee
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:50:44+01:00

Commit Message:
TWINE: the hqr code doesn't have any state - converted back to functions

Changed paths:
  A engines/twine/hqr.cpp
  A engines/twine/hqr.h
  R engines/twine/hqrdepack.cpp
  R engines/twine/hqrdepack.h
    engines/twine/actor.cpp
    engines/twine/gamestate.cpp
    engines/twine/grid.cpp
    engines/twine/holomap.cpp
    engines/twine/menu.cpp
    engines/twine/module.mk
    engines/twine/music.cpp
    engines/twine/redraw.cpp
    engines/twine/resources.cpp
    engines/twine/resources.h
    engines/twine/scene.cpp
    engines/twine/screens.cpp
    engines/twine/script_life_v1.cpp
    engines/twine/sound.cpp
    engines/twine/text.cpp
    engines/twine/twine.cpp
    engines/twine/twine.h


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index d99194e3d7..742813a56d 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -27,7 +27,7 @@
 #include "twine/extra.h"
 #include "twine/gamestate.h"
 #include "twine/grid.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/movements.h"
 #include "twine/renderer.h"
 #include "twine/resources.h"
@@ -78,35 +78,35 @@ void Actor::restartHeroScene() {
 }
 
 void Actor::loadHeroEntities() {
-	heroEntityATHLETICSize = _engine->_hqrdepack->hqrGetallocEntry(&heroEntityATHLETIC, Resources::HQR_FILE3D_FILE, FILE3DHQR_HEROATHLETIC);
+	heroEntityATHLETICSize = HQR::getAllocEntry(&heroEntityATHLETIC, Resources::HQR_FILE3D_FILE, FILE3DHQR_HEROATHLETIC);
 	if (heroEntityATHLETICSize == 0) {
 		error("Failed to load actor athletic 3d data");
 	}
 	_engine->_scene->sceneHero->entityDataPtr = heroEntityATHLETIC;
 	heroAnimIdxATHLETIC = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
 
-	heroEntityAGGRESSIVESize = _engine->_hqrdepack->hqrGetallocEntry(&heroEntityAGGRESSIVE, Resources::HQR_FILE3D_FILE, FILE3DHQR_HEROAGGRESSIVE);
+	heroEntityAGGRESSIVESize = HQR::getAllocEntry(&heroEntityAGGRESSIVE, Resources::HQR_FILE3D_FILE, FILE3DHQR_HEROAGGRESSIVE);
 	if (heroEntityAGGRESSIVESize == 0) {
 		error("Failed to load actor aggressive 3d data");
 	}
 	_engine->_scene->sceneHero->entityDataPtr = heroEntityAGGRESSIVE;
 	heroAnimIdxAGGRESSIVE = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
 
-	heroEntityDISCRETESize = _engine->_hqrdepack->hqrGetallocEntry(&heroEntityDISCRETE, Resources::HQR_FILE3D_FILE, FILE3DHQR_HERODISCRETE);
+	heroEntityDISCRETESize = HQR::getAllocEntry(&heroEntityDISCRETE, Resources::HQR_FILE3D_FILE, FILE3DHQR_HERODISCRETE);
 	if (heroEntityDISCRETESize == 0) {
 		error("Failed to load actor discrete 3d data");
 	}
 	_engine->_scene->sceneHero->entityDataPtr = heroEntityDISCRETE;
 	heroAnimIdxDISCRETE = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
 
-	heroEntityPROTOPACKSize = _engine->_hqrdepack->hqrGetallocEntry(&heroEntityPROTOPACK, Resources::HQR_FILE3D_FILE, FILE3DHQR_HEROPROTOPACK);
+	heroEntityPROTOPACKSize = HQR::getAllocEntry(&heroEntityPROTOPACK, Resources::HQR_FILE3D_FILE, FILE3DHQR_HEROPROTOPACK);
 	if (heroEntityPROTOPACKSize == 0) {
 		error("Failed to load actor protopack 3d data");
 	}
 	_engine->_scene->sceneHero->entityDataPtr = heroEntityPROTOPACK;
 	heroAnimIdxPROTOPACK = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
 
-	heroEntityNORMALSize = _engine->_hqrdepack->hqrGetallocEntry(&heroEntityNORMAL, Resources::HQR_FILE3D_FILE, FILE3DHQR_HERONORMAL);
+	heroEntityNORMALSize = HQR::getAllocEntry(&heroEntityNORMAL, Resources::HQR_FILE3D_FILE, FILE3DHQR_HERONORMAL);
 	if (heroEntityNORMALSize == 0) {
 		error("Failed to load actor normal 3d data");
 	}
@@ -200,7 +200,7 @@ int32 Actor::initBody(int32 bodyIdx, int32 actorIdx) {
 					if (bodyTable[currentPositionInBodyPtrTab]) {
 						free(bodyTable[currentPositionInBodyPtrTab]);
 					}
-					_engine->_hqrdepack->hqrGetallocEntry(&bodyTable[currentPositionInBodyPtrTab], Resources::HQR_BODY_FILE, flag & 0xFFFF);
+					HQR::getAllocEntry(&bodyTable[currentPositionInBodyPtrTab], Resources::HQR_BODY_FILE, flag & 0xFFFF);
 
 					if (!bodyTable[currentPositionInBodyPtrTab]) {
 						error("HQR ERROR: Loading body entities");
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 1be99333c1..dd77e5d682 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -452,7 +452,7 @@ void GameState::processGameoverAnimation() {
 	_engine->setPalette(_engine->_screens->paletteRGBA);
 	_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
 	uint8 *gameOverPtr = nullptr;
-	if (_engine->_hqrdepack->hqrGetallocEntry(&gameOverPtr, Resources::HQR_RESS_FILE, RESSHQR_GAMEOVERMDL) == 0) {
+	if (HQR::getAllocEntry(&gameOverPtr, Resources::HQR_RESS_FILE, RESSHQR_GAMEOVERMDL) == 0) {
 		return;
 	}
 
diff --git a/engines/twine/grid.cpp b/engines/twine/grid.cpp
index fe0a2773f6..6f359f58bb 100644
--- a/engines/twine/grid.cpp
+++ b/engines/twine/grid.cpp
@@ -313,7 +313,7 @@ int32 Grid::loadGridBricks(int32 gridSize) {
 		if (brickTable[i]) {
 			free(brickTable[i]);
 		}
-		brickSizeTable[i] = _engine->_hqrdepack->hqrGetallocEntry(&brickTable[i], Resources::HQR_LBA_BRK_FILE, i);
+		brickSizeTable[i] = HQR::getAllocEntry(&brickTable[i], Resources::HQR_LBA_BRK_FILE, i);
 		if (brickSizeTable[i] == 0) {
 			warning("Failed to load isometric brick index %i", i);
 		}
@@ -416,14 +416,14 @@ void Grid::createCellingGridMap(uint8 *gridPtr) {
 
 bool Grid::initGrid(int32 index) {
 	// load grids from file
-	const int32 gridSize = _engine->_hqrdepack->hqrGetallocEntry(&currentGrid, Resources::HQR_LBA_GRI_FILE, index);
+	const int32 gridSize = HQR::getAllocEntry(&currentGrid, Resources::HQR_LBA_GRI_FILE, index);
 	if (gridSize == 0) {
 		warning("Failed to load grid index: %i", index);
 		return false;
 	}
 
 	// load layouts from file
-	_engine->_hqrdepack->hqrGetallocEntry(&currentBll, Resources::HQR_LBA_BLL_FILE, index);
+	HQR::getAllocEntry(&currentBll, Resources::HQR_LBA_BLL_FILE, index);
 
 	loadGridBricks(gridSize);
 
@@ -441,7 +441,7 @@ bool Grid::initCellingGrid(int32 index) {
 
 	// load grids from file
 	const int realIndex = index + CELLING_GRIDS_START_INDEX;
-	if (_engine->_hqrdepack->hqrGetallocEntry(&gridPtr, Resources::HQR_LBA_GRI_FILE, realIndex) == 0) {
+	if (HQR::getAllocEntry(&gridPtr, Resources::HQR_LBA_GRI_FILE, realIndex) == 0) {
 		warning("Failed to load grid index %i", realIndex);
 		return false;
 	}
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 62d7bc55c9..c2cb8fc921 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -65,12 +65,12 @@ void Holomap::loadHolomapGFX() {
 
 	uint8 *videoPtr5 = videoPtr1 + 73934;
 
-	_engine->_hqrdepack->hqrGetEntry(videoPtr3, Resources::HQR_RESS_FILE, RESSHQR_HOLOSURFACE);
-	_engine->_hqrdepack->hqrGetEntry(videoPtr4, Resources::HQR_RESS_FILE, RESSHQR_HOLOIMG);
+	HQR::getEntry(videoPtr3, Resources::HQR_RESS_FILE, RESSHQR_HOLOSURFACE);
+	HQR::getEntry(videoPtr4, Resources::HQR_RESS_FILE, RESSHQR_HOLOIMG);
 
-	uint8 *videoPtr6 = videoPtr5 + _engine->_hqrdepack->hqrGetEntry(videoPtr5, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINMDL);
-	uint8 *videoPtr7 = videoPtr6 + _engine->_hqrdepack->hqrGetEntry(videoPtr6, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWMDL);
-	uint8 *videoPtr8 = videoPtr7 + _engine->_hqrdepack->hqrGetEntry(videoPtr7, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINARROWMDL);
+	uint8 *videoPtr6 = videoPtr5 + HQR::getEntry(videoPtr5, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINMDL);
+	uint8 *videoPtr7 = videoPtr6 + HQR::getEntry(videoPtr6, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWMDL);
+	uint8 *videoPtr8 = videoPtr7 + HQR::getEntry(videoPtr7, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINARROWMDL);
 
 	loadGfxSub(videoPtr5);
 	loadGfxSub(videoPtr6);
@@ -80,10 +80,10 @@ void Holomap::loadHolomapGFX() {
 
 	// TODO:
 	// uint8 *videoPtr2 = videoPtr1 + 4488;
-	// uint8 *videoPtr11 = videoPtr8 + _engine->_hqrdepack->hqrGetEntry(videoPtr8, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTMDL);
+	// uint8 *videoPtr11 = videoPtr8 + HQR::getEntry(videoPtr8, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTMDL);
 	// uint8 *videoPtr10 = videoPtr11 + 4488;
-	// uint8 *videoPtr12 = videoPtr10 + _engine->_hqrdepack->hqrGetEntry(videoPtr10, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWINFO);
-	// uint8 *videoPtr13 = videoPtr12 + _engine->_hqrdepack->hqrGetEntry(videoPtr12, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTANIM);
+	// uint8 *videoPtr12 = videoPtr10 + HQR::getEntry(videoPtr10, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWINFO);
+	// uint8 *videoPtr13 = videoPtr12 + HQR::getEntry(videoPtr12, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTANIM);
 
 	_engine->_screens->loadCustomPalette(RESSHQR_HOLOPAL);
 
diff --git a/engines/twine/hqrdepack.cpp b/engines/twine/hqr.cpp
similarity index 72%
rename from engines/twine/hqrdepack.cpp
rename to engines/twine/hqr.cpp
index 959f4e8b93..d33560bb00 100644
--- a/engines/twine/hqrdepack.cpp
+++ b/engines/twine/hqr.cpp
@@ -20,7 +20,7 @@
  *
  */
 
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "common/debug.h"
 #include "common/file.h"
 #include "common/system.h"
@@ -28,9 +28,22 @@
 
 namespace TwinE {
 
-#define wrap(cmd) if ((cmd) == 0) { warning("Failed to execute " #cmd ); return 0; }
+namespace HQR {
 
-void HQRDepack::hqrDecompressEntry(uint8 *dst, uint8 *src, int32 decompsize, int32 mode) {
+#define wrap(cmd)                           \
+	if ((cmd) == 0) {                       \
+		warning("Failed to execute " #cmd); \
+		return 0;                           \
+	}
+
+/**
+ * Decompress entry based in Yaz0r and Zink decompression code
+ * @param dst destination pointer where will be the decompressed entry
+ * @param src compressed data pointer
+ * @param decompsize real file size after decompression
+ * @param mode compression mode used
+ */
+static void decompressEntry(uint8 *dst, uint8 *src, int32 decompsize, int32 mode) {
 	do {
 		uint8 b = *(src++);
 		for (int32 d = 0; d < 8; d++) {
@@ -53,7 +66,53 @@ void HQRDepack::hqrDecompressEntry(uint8 *dst, uint8 *src, int32 decompsize, int
 	} while (decompsize);
 }
 
-int32 HQRDepack::hqrGetEntry(uint8 *ptr, const char *filename, int32 index) {
+/**
+ * Get a HQR entry pointer
+ * @param filename HQR file name
+ * @param index entry index to extract
+ * @return entry real size
+ */
+static int voxEntrySize(const char *filename, int32 index, int32 hiddenIndex) {
+	if (!filename) {
+		return 0;
+	}
+
+	Common::File file;
+	if (!file.open(filename)) {
+		error("HQR: Could not open %s", filename);
+	}
+
+	uint32 headerSize;
+	wrap(file.read(&headerSize, 4))
+
+	if ((uint32)index >= headerSize / 4) {
+		warning("HQR: Invalid entry index");
+		return 0;
+	}
+
+	wrap(file.seek(index * 4))
+	uint32 offsetToData;
+	wrap(file.read(&offsetToData, 4))
+
+	wrap(file.seek(offsetToData))
+	uint32 realSize;
+	wrap(file.read(&realSize, 4))
+	uint32 compSize;
+	wrap(file.read(&compSize, 4))
+
+	    // exist hidden entries
+	for (int32 i = 0; i < hiddenIndex; i++) {
+		wrap(file.seek(offsetToData + compSize + 10)) // hidden entry
+		offsetToData = offsetToData + compSize + 10;  // current hidden offset
+
+		wrap(file.read(&realSize, 4))
+		wrap(file.read(&compSize, 4))
+	}
+
+	return realSize;
+}
+
+int32 getEntry(uint8 *ptr, const char *filename, int32 index) {
 	if (!ptr) {
 		return 0;
 	}
@@ -91,14 +150,14 @@ int32 HQRDepack::hqrGetEntry(uint8 *ptr, const char *filename, int32 index) {
 		uint8 *compDataPtr = nullptr;
 		compDataPtr = (uint8 *)malloc(compSize);
 		wrap(file.read(compDataPtr, compSize))
-		hqrDecompressEntry(ptr, compDataPtr, realSize, mode);
+		decompressEntry(ptr, compDataPtr, realSize, mode);
 		free(compDataPtr);
 	}
 
 	return realSize;
 }
 
-int32 HQRDepack::hqrEntrySize(const char *filename, int32 index) {
+int32 entrySize(const char *filename, int32 index) {
 	if (!filename) {
 		return 0;
 	}
@@ -127,7 +186,7 @@ int32 HQRDepack::hqrEntrySize(const char *filename, int32 index) {
 	return realSize;
 }
 
-int32 HQRDepack::hqrNumEntries(const char *filename) {
+int32 numEntries(const char *filename) {
 	if (!filename) {
 		return 0;
 	}
@@ -138,23 +197,22 @@ int32 HQRDepack::hqrNumEntries(const char *filename) {
 	}
 
 	uint32 headerSize;
-	wrap(file.read(&headerSize, 4))
-	return ((int)headerSize / 4) - 1;
+	wrap(file.read(&headerSize, 4)) return ((int)headerSize / 4) - 1;
 }
 
-int32 HQRDepack::hqrGetallocEntry(uint8 **ptr, const char *filename, int32 index) {
-	const int32 size = hqrEntrySize(filename, index);
+int32 getAllocEntry(uint8 **ptr, const char *filename, int32 index) {
+	const int32 size = entrySize(filename, index);
 	*ptr = (uint8 *)malloc(size * sizeof(uint8));
 	if (!*ptr) {
 		warning("HQR: unable to allocate entry memory");
 		return 0;
 	}
-	hqrGetEntry(*ptr, filename, index);
+	getEntry(*ptr, filename, index);
 
 	return size;
 }
 
-int32 HQRDepack::hqrGetVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenIndex) {
+int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenIndex) {
 	if (!ptr) {
 		return 0;
 	}
@@ -189,12 +247,12 @@ int32 HQRDepack::hqrGetVoxEntry(uint8 *ptr, const char *filename, int32 index, i
 
 	// exist hidden entries
 	for (int32 i = 0; i < hiddenIndex; i++) {
-		wrap(file.seek(offsetToData + compSize + 10))   // hidden entry
-		offsetToData = offsetToData + compSize + 10; // current hidden offset
+		wrap(file.seek(offsetToData + compSize + 10)) // hidden entry
+		offsetToData = offsetToData + compSize + 10;  // current hidden offset
 
 		wrap(file.read(&realSize, 4))
 		wrap(file.read(&compSize, 4))
-		wrap(file.read(&mode, 2))
+			wrap(file.read(&mode, 2))
 	}
 
 	// uncompressed
@@ -206,66 +264,28 @@ int32 HQRDepack::hqrGetVoxEntry(uint8 *ptr, const char *filename, int32 index, i
 		uint8 *compDataPtr = 0;
 		compDataPtr = (uint8 *)malloc(compSize);
 		wrap(file.read(compDataPtr, compSize))
-		hqrDecompressEntry(ptr, compDataPtr, realSize, mode);
+		decompressEntry(ptr, compDataPtr, realSize, mode);
 		free(compDataPtr);
 	}
 
 	return realSize;
 }
 
-int HQRDepack::hqrVoxEntrySize(const char *filename, int32 index, int32 hiddenIndex) {
-	if (!filename) {
-		return 0;
-	}
-
-	Common::File file;
-	if (!file.open(filename)) {
-		error("HQR: Could not open %s", filename);
-	}
-
-	uint32 headerSize;
-	wrap(file.read(&headerSize, 4))
-
-	if ((uint32)index >= headerSize / 4) {
-		warning("HQR: Invalid entry index");
-		return 0;
-	}
-
-	wrap(file.seek(index * 4))
-	uint32 offsetToData;
-	wrap(file.read(&offsetToData, 4))
-
-	wrap(file.seek(offsetToData))
-	uint32 realSize;
-	wrap(file.read(&realSize, 4))
-	uint32 compSize;
-	wrap(file.read(&compSize, 4))
-
-	// exist hidden entries
-	for (int32 i = 0; i < hiddenIndex; i++) {
-		wrap(file.seek(offsetToData + compSize + 10))   // hidden entry
-		offsetToData = offsetToData + compSize + 10; // current hidden offset
-
-		wrap(file.read(&realSize, 4))
-		wrap(file.read(&compSize, 4))
-	}
-
-	return realSize;
-}
-
-int32 HQRDepack::hqrGetallocVoxEntry(uint8 **ptr, const char *filename, int32 index, int32 hiddenIndex) {
-	const int32 size = hqrVoxEntrySize(filename, index, hiddenIndex);
+int32 getAllocVoxEntry(uint8 **ptr, const char *filename, int32 index, int32 hiddenIndex) {
+	const int32 size = voxEntrySize(filename, index, hiddenIndex);
 
 	*ptr = (uint8 *)malloc(size * sizeof(uint8));
 	if (!*ptr) {
 		warning("HQR: unable to allocate entry memory");
 		return 0;
 	}
-	hqrGetVoxEntry(*ptr, filename, index, hiddenIndex);
+	getVoxEntry(*ptr, filename, index, hiddenIndex);
 
 	return size;
 }
 
 #undef wrap
 
+} // namespace HQR
+
 } // namespace TwinE
diff --git a/engines/twine/hqr.h b/engines/twine/hqr.h
new file mode 100644
index 0000000000..0885d99b67
--- /dev/null
+++ b/engines/twine/hqr.h
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TWINE_HQR_H
+#define TWINE_HQR_H
+
+#include "common/scummsys.h"
+
+namespace TwinE {
+
+class TwinEEngine;
+
+/**
+ * High Quality Resource
+ *
+ * http://lbafileinfo.kazekr.net/index.php?title=High_quality_resource
+ */
+namespace HQR {
+
+/**
+ * Get a HQR entry pointer
+ * @param ptr pointer to save the entry
+ * @param filename HQR file name
+ * @param index entry index to extract
+ * @return entry real size
+ */
+int32 getEntry(uint8 *ptr, const char *filename, int32 index);
+
+/**
+ * Get a HQR entry pointer
+ * @param filename HQR file name
+ * @param index entry index to extract
+ * @return entry real size
+ */
+int32 entrySize(const char *filename, int32 index);
+
+/**
+ * Get a HQR total number of entries
+ * @param filename HQR file name
+ * @return total number of entries
+ */
+int32 numEntries(const char *filename);
+
+/**
+ * Get a HQR entry pointer with memory allocation
+ * @param ptr pointer to save the entry
+ * @param filename HQR file name
+ * @param index entry index to extract
+ * @return entry real size
+ */
+int32 getAllocEntry(uint8 **ptr, const char *filename, int32 index);
+
+/**
+ * Get a HQR entry pointer
+ * @param ptr pointer to save the entry
+ * @param filename HQR file name
+ * @param index entry index to extract
+ * @return entry real size
+ */
+int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenIndex);
+/**
+ * Get a HQR entry pointer with memory allocation
+ * @param ptr pointer to save the entry
+ * @param filename HQR file name
+ * @param index entry index to extract
+ * @return entry real size
+ */
+int32 getAllocVoxEntry(uint8 **ptr, const char *filename, int32 index, int32 hiddenIndex);
+} // namespace HQR
+
+} // namespace TwinE
+
+#endif
diff --git a/engines/twine/hqrdepack.h b/engines/twine/hqrdepack.h
deleted file mode 100644
index d2fcce28a6..0000000000
--- a/engines/twine/hqrdepack.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TWINE_HQRDEPACK_H
-#define TWINE_HQRDEPACK_H
-
-#include "common/scummsys.h"
-
-namespace TwinE {
-
-class TwinEEngine;
-
-/**
- * High Quality Resource
- *
- * http://lbafileinfo.kazekr.net/index.php?title=High_quality_resource
- */
-class HQRDepack {
-private:
-	/**
-	 * Get a HQR entry pointer
-	 * @param filename HQR file name
-	 * @param index entry index to extract
-	 * @return entry real size
-	 * */
-	int hqrVoxEntrySize(const char *filename, int32 index, int32 hiddenIndex);
-	/**
-	 * Decompress entry based in Yaz0r and Zink decompression code
-	 * @param dst destination pointer where will be the decompressed entry
-	 * @param src compressed data pointer
-	 * @param decompsize real file size after decompression
-	 * @param mode compression mode used
-	 */
-	void hqrDecompressEntry(uint8 *dst, uint8 *src, int32 decompsize, int32 mode);
-
-public:
-	/**
-	 * Get a HQR entry pointer
-	 * @param ptr pointer to save the entry
-	 * @param filename HQR file name
-	 * @param index entry index to extract
-	 * @return entry real size
-	 */
-	int32 hqrGetEntry(uint8 *ptr, const char *filename, int32 index);
-
-	/**
-	 * Get a HQR entry pointer
-	 * @param filename HQR file name
-	 * @param index entry index to extract
-	 * @return entry real size
-	 */
-	int32 hqrEntrySize(const char *filename, int32 index);
-
-	/**
-	 * Get a HQR total number of entries
-	 * @param filename HQR file name
-	 * @return total number of entries
-	 */
-	int32 hqrNumEntries(const char *filename);
-
-	/**
-	 * Get a HQR entry pointer with memory allocation
-	 * @param ptr pointer to save the entry
-	 * @param filename HQR file name
-	 * @param index entry index to extract
-	 * @return entry real size
-	 */
-	int32 hqrGetallocEntry(uint8 **ptr, const char *filename, int32 index);
-
-	/**
-	 * Get a HQR entry pointer
-	 * @param ptr pointer to save the entry
-	 * @param filename HQR file name
-	 * @param index entry index to extract
-	 * @return entry real size
-	 */
-	int32 hqrGetVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenIndex);
-	/**
-	 * Get a HQR entry pointer with memory allocation
-	 * @param ptr pointer to save the entry
-	 * @param filename HQR file name
-	 * @param index entry index to extract
-	 * @return entry real size
-	 */
-	int32 hqrGetallocVoxEntry(uint8 **ptr, const char *filename, int32 index, int32 hiddenIndex);
-};
-
-} // namespace TwinE
-
-#endif
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 996c0b24f3..1e45794b48 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -34,7 +34,7 @@
 #include "twine/animations.h"
 #include "twine/gamestate.h"
 #include "twine/grid.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/input.h"
 #include "twine/interface.h"
 #include "twine/menuoptions.h"
@@ -696,7 +696,7 @@ bool Menu::init() {
 	// load menu effect file only once
 	plasmaEffectPtr = (uint8 *)malloc(kPlasmaEffectFilesize);
 	memset(plasmaEffectPtr, 0, kPlasmaEffectFilesize);
-	return _engine->_hqrdepack->hqrGetEntry(plasmaEffectPtr, Resources::HQR_RESS_FILE, RESSHQR_PLASMAEFFECT) > 0;
+	return HQR::getEntry(plasmaEffectPtr, Resources::HQR_RESS_FILE, RESSHQR_PLASMAEFFECT) > 0;
 }
 
 void Menu::run() {
diff --git a/engines/twine/module.mk b/engines/twine/module.mk
index f3afd43fc9..0e1f3c860e 100644
--- a/engines/twine/module.mk
+++ b/engines/twine/module.mk
@@ -14,7 +14,7 @@ MODULE_OBJS := \
 	gamestate.o \
 	grid.o \
 	holomap.o \
-	hqrdepack.o \
+	hqr.o \
 	interface.o \
 	input.o \
 	menu.o \
diff --git a/engines/twine/music.cpp b/engines/twine/music.cpp
index 5bbeb90c1c..ab1b8f2541 100644
--- a/engines/twine/music.cpp
+++ b/engines/twine/music.cpp
@@ -27,7 +27,7 @@
 #include "common/debug.h"
 #include "common/system.h"
 #include "common/textconsole.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/resources.h"
 #include "twine/twine.h"
 
@@ -185,7 +185,7 @@ void Music::playMidiMusic(int32 midiIdx, int32 loop) {
 		stopMidiMusic();
 	}
 
-	int32 midiSize = _engine->_hqrdepack->hqrGetallocEntry(&midiPtr, filename, midiIdx);
+	int32 midiSize = HQR::getAllocEntry(&midiPtr, filename, midiIdx);
 	_midiPlayer.play(midiPtr, midiSize);
 }
 
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 6351193697..c8fc2bcbfc 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -28,7 +28,7 @@
 #include "twine/collision.h"
 #include "twine/debug_scene.h"
 #include "twine/grid.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/input.h"
 #include "twine/interface.h"
 #include "twine/menu.h"
diff --git a/engines/twine/resources.cpp b/engines/twine/resources.cpp
index 253e753ccc..d65c6fc435 100644
--- a/engines/twine/resources.cpp
+++ b/engines/twine/resources.cpp
@@ -50,7 +50,7 @@ Resources::~Resources() {
 
 void Resources::initPalettes() {
 	// Init standard palette
-	_engine->_hqrdepack->hqrGetallocEntry(&_engine->_screens->mainPalette, Resources::HQR_RESS_FILE, RESSHQR_MAINPAL);
+	HQR::getAllocEntry(&_engine->_screens->mainPalette, Resources::HQR_RESS_FILE, RESSHQR_MAINPAL);
 	_engine->_screens->convertPalToRGBA(_engine->_screens->mainPalette, _engine->_screens->mainPaletteRGBA);
 
 	memcpy(_engine->_screens->palette, _engine->_screens->mainPalette, NUMOFCOLORS * 3);
@@ -63,35 +63,35 @@ void Resources::initPalettes() {
 }
 
 void Resources::preloadSprites() {
-	const int32 numEntries = _engine->_hqrdepack->hqrNumEntries(Resources::HQR_SPRITES_FILE);
+	const int32 numEntries = HQR::numEntries(Resources::HQR_SPRITES_FILE);
 	if (numEntries > NUM_SPRITES) {
 		error("Max allowed sprites exceeded: %i/%i", numEntries, NUM_SPRITES);
 	}
 	debug("preload %i sprites", numEntries);
 	for (int32 i = 0; i < numEntries; i++) {
-		spriteSizeTable[i] = _engine->_hqrdepack->hqrGetallocEntry(&spriteTable[i], Resources::HQR_SPRITES_FILE, i);
+		spriteSizeTable[i] = HQR::getAllocEntry(&spriteTable[i], Resources::HQR_SPRITES_FILE, i);
 	}
 }
 
 void Resources::preloadAnimations() {
-	const int32 numEntries = _engine->_hqrdepack->hqrNumEntries(Resources::HQR_ANIM_FILE);
+	const int32 numEntries = HQR::numEntries(Resources::HQR_ANIM_FILE);
 	if (numEntries > NUM_ANIMS) {
 		error("Max allowed animations exceeded: %i/%i", numEntries, NUM_ANIMS);
 	}
 	debug("preload %i animations", numEntries);
 	for (int32 i = 0; i < numEntries; i++) {
-		animSizeTable[i] = _engine->_hqrdepack->hqrGetallocEntry(&animTable[i], Resources::HQR_ANIM_FILE, i);
+		animSizeTable[i] = HQR::getAllocEntry(&animTable[i], Resources::HQR_ANIM_FILE, i);
 	}
 }
 
 void Resources::preloadSamples() {
-	const int32 numEntries = _engine->_hqrdepack->hqrNumEntries(Resources::HQR_SAMPLES_FILE);
+	const int32 numEntries = HQR::numEntries(Resources::HQR_SAMPLES_FILE);
 	if (numEntries > NUM_SAMPLES) {
 		error("Max allowed samples exceeded: %i/%i", numEntries, NUM_SAMPLES);
 	}
 	debug("preload %i samples", numEntries);
 	for (int32 i = 0; i < numEntries; i++) {
-		samplesSizeTable[i] = _engine->_hqrdepack->hqrGetallocEntry(&samplesTable[i], Resources::HQR_SAMPLES_FILE, i);
+		samplesSizeTable[i] = HQR::getAllocEntry(&samplesTable[i], Resources::HQR_SAMPLES_FILE, i);
 		if (samplesSizeTable[i] == 0) {
 			warning("Failed to load sample %i", i);
 			continue;
@@ -105,13 +105,13 @@ void Resources::preloadSamples() {
 }
 
 void Resources::preloadInventoryItems() {
-	const int32 numEntries = _engine->_hqrdepack->hqrNumEntries(Resources::HQR_INVOBJ_FILE);
+	const int32 numEntries = HQR::numEntries(Resources::HQR_INVOBJ_FILE);
 	if (numEntries > NUM_INVENTORY_ITEMS) {
 		error("Max allowed inventory items exceeded: %i/%i", numEntries, NUM_INVENTORY_ITEMS);
 	}
 	debug("preload %i inventory items", numEntries);
 	for (int32 i = 0; i < numEntries; i++) {
-		inventorySizeTable[i] = _engine->_hqrdepack->hqrGetallocEntry(&inventoryTable[i], Resources::HQR_INVOBJ_FILE, i);
+		inventorySizeTable[i] = HQR::getAllocEntry(&inventoryTable[i], Resources::HQR_INVOBJ_FILE, i);
 	}
 }
 
@@ -119,7 +119,7 @@ void Resources::initResources() {
 	// Menu and in-game palette
 	initPalettes();
 
-	if (_engine->_hqrdepack->hqrGetallocEntry(&fontPtr, Resources::HQR_RESS_FILE, RESSHQR_LBAFONT) == 0) {
+	if (HQR::getAllocEntry(&fontPtr, Resources::HQR_RESS_FILE, RESSHQR_LBAFONT) == 0) {
 		error("Failed to load font");
 	}
 
@@ -127,11 +127,11 @@ void Resources::initResources() {
 	_engine->_text->setFontColor(14);
 	_engine->_text->setTextCrossColor(136, 143, 2);
 
-	if (_engine->_hqrdepack->hqrGetallocEntry(&spriteShadowPtr, Resources::HQR_RESS_FILE, RESSHQR_SPRITESHADOW) == 0) {
+	if (HQR::getAllocEntry(&spriteShadowPtr, Resources::HQR_RESS_FILE, RESSHQR_SPRITESHADOW) == 0) {
 		error("Failed to load sprite shadow");
 	}
 
-	if (_engine->_hqrdepack->hqrGetallocEntry(&spriteBoundingBoxPtr, Resources::HQR_RESS_FILE, RESSHQR_SPRITEBOXDATA) == 0) {
+	if (HQR::getAllocEntry(&spriteBoundingBoxPtr, Resources::HQR_RESS_FILE, RESSHQR_SPRITEBOXDATA) == 0) {
 		error("Failed to load actors bounding box data");
 	}
 
diff --git a/engines/twine/resources.h b/engines/twine/resources.h
index 752e10000a..64621f5eaa 100644
--- a/engines/twine/resources.h
+++ b/engines/twine/resources.h
@@ -25,7 +25,7 @@
 
 #include "common/scummsys.h"
 #include "twine/gamestate.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 
 namespace TwinE {
 
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index d4fc909f4a..1bf160425d 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -153,7 +153,7 @@ bool Scene::loadSceneLBA1() {
 		act->entity = stream.readUint16LE();
 
 		if (!act->staticFlags.bIsSpriteActor) {
-			act->entityDataSize = _engine->_hqrdepack->hqrGetallocEntry(&act->entityDataPtr, Resources::HQR_FILE3D_FILE, act->entity);
+			act->entityDataSize = HQR::getAllocEntry(&act->entityDataPtr, Resources::HQR_FILE3D_FILE, act->entity);
 		}
 
 		act->body = stream.readByte();
@@ -224,7 +224,7 @@ bool Scene::loadSceneLBA1() {
 
 bool Scene::initScene(int32 index) {
 	// load scene from file
-	_currentSceneSize = _engine->_hqrdepack->hqrGetallocEntry(&currentScene, Resources::HQR_SCENE_FILE, index);
+	_currentSceneSize = HQR::getAllocEntry(&currentScene, Resources::HQR_SCENE_FILE, index);
 	if (_currentSceneSize == 0) {
 		return false;
 	}
diff --git a/engines/twine/screens.cpp b/engines/twine/screens.cpp
index b1da7253bf..2e58140e57 100644
--- a/engines/twine/screens.cpp
+++ b/engines/twine/screens.cpp
@@ -23,7 +23,7 @@
 #include "common/system.h"
 #include "graphics/surface.h"
 #include "twine/screens.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/music.h"
 #include "twine/resources.h"
 #include "twine/twine.h"
@@ -41,7 +41,7 @@ bool Screens::adelineLogo() {
 }
 
 void Screens::loadMenuImage(bool fade_in) {
-	if (_engine->_hqrdepack->hqrGetEntry((uint8*)_engine->workVideoBuffer.getPixels(), Resources::HQR_RESS_FILE, RESSHQR_MENUIMG) == 0) {
+	if (HQR::getEntry((uint8*)_engine->workVideoBuffer.getPixels(), Resources::HQR_RESS_FILE, RESSHQR_MENUIMG) == 0) {
 		warning("Failed to load menu image");
 		return;
 	}
@@ -56,7 +56,7 @@ void Screens::loadMenuImage(bool fade_in) {
 }
 
 void Screens::loadCustomPalette(int32 index) {
-	if (_engine->_hqrdepack->hqrGetEntry(palette, Resources::HQR_RESS_FILE, index) == 0) {
+	if (HQR::getEntry(palette, Resources::HQR_RESS_FILE, index) == 0) {
 		warning("Failed to load custom palette %i", index);
 		return;
 	}
@@ -75,7 +75,7 @@ void Screens::convertPalToRGBA(const uint8* in, uint32* out) {
 }
 
 void Screens::loadImage(int32 index, bool fade_in) {
-	if (_engine->_hqrdepack->hqrGetEntry((uint8*)_engine->workVideoBuffer.getPixels(), Resources::HQR_RESS_FILE, index) == 0) {
+	if (HQR::getEntry((uint8*)_engine->workVideoBuffer.getPixels(), Resources::HQR_RESS_FILE, index) == 0) {
 		warning("Failed to load image with index %i", index);
 		return;
 	}
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index e6e0fafe4b..2e926c84fc 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1238,7 +1238,7 @@ static int32 lFADE_PAL_RED(TwinEEngine *engine, ScriptContext& ctx) {
 /*0x53*/
 static int32 lFADE_ALARM_RED(TwinEEngine *engine, ScriptContext& ctx) {
 	engine->freezeTime();
-	engine->_hqrdepack->hqrGetEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
+	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
 	engine->_screens->convertPalToRGBA(engine->_screens->palette, engine->_screens->paletteRGBA);
 	engine->_screens->fadePalRed(engine->_screens->paletteRGBA);
 	engine->_screens->useAlternatePalette = true;
@@ -1249,7 +1249,7 @@ static int32 lFADE_ALARM_RED(TwinEEngine *engine, ScriptContext& ctx) {
 /*0x54*/
 static int32 lFADE_ALARM_PAL(TwinEEngine *engine, ScriptContext& ctx) {
 	engine->freezeTime();
-	engine->_hqrdepack->hqrGetEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
+	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
 	engine->_screens->convertPalToRGBA(engine->_screens->palette, engine->_screens->paletteRGBA);
 	engine->_screens->adjustCrossPalette(engine->_screens->paletteRGBA, engine->_screens->mainPaletteRGBA);
 	engine->_screens->useAlternatePalette = false;
@@ -1269,7 +1269,7 @@ static int32 lFADE_RED_PAL(TwinEEngine *engine, ScriptContext& ctx) {
 /*0x56*/
 static int32 lFADE_RED_ALARM(TwinEEngine *engine, ScriptContext& ctx) {
 	engine->freezeTime();
-	engine->_hqrdepack->hqrGetEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
+	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
 	engine->_screens->convertPalToRGBA(engine->_screens->palette, engine->_screens->paletteRGBA);
 	engine->_screens->fadeRedPal(engine->_screens->paletteRGBA);
 	engine->_screens->useAlternatePalette = true;
@@ -1280,7 +1280,7 @@ static int32 lFADE_RED_ALARM(TwinEEngine *engine, ScriptContext& ctx) {
 /*0x57*/
 static int32 lFADE_PAL_ALARM(TwinEEngine *engine, ScriptContext& ctx) {
 	engine->freezeTime();
-	engine->_hqrdepack->hqrGetEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
+	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
 	engine->_screens->convertPalToRGBA(engine->_screens->palette, engine->_screens->paletteRGBA);
 	engine->_screens->adjustCrossPalette(engine->_screens->mainPaletteRGBA, engine->_screens->paletteRGBA);
 	engine->_screens->useAlternatePalette = true;
@@ -1332,7 +1332,7 @@ static int32 lASK_CHOICE_OBJ(TwinEEngine *engine, ScriptContext& ctx) {
 /*0x5C*/
 static int32 lSET_DARK_PAL(TwinEEngine *engine, ScriptContext& ctx) {
 	engine->freezeTime();
-	engine->_hqrdepack->hqrGetEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_DARKPAL);
+	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_DARKPAL);
 	if (!engine->_screens->lockPalette) {
 		engine->_screens->convertPalToRGBA(engine->_screens->palette, engine->_screens->paletteRGBA);
 		engine->setPalette(engine->_screens->paletteRGBA);
diff --git a/engines/twine/sound.cpp b/engines/twine/sound.cpp
index cc73fea946..34f4dd16ed 100644
--- a/engines/twine/sound.cpp
+++ b/engines/twine/sound.cpp
@@ -30,7 +30,7 @@
 #include "twine/collision.h"
 #include "twine/flamovies.h"
 #include "twine/grid.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/movements.h"
 #include "twine/resources.h"
 #include "twine/text.h"
@@ -65,7 +65,7 @@ void Sound::playFlaSample(int32 index, int32 frequency, int32 repeat, int32 x, i
 	}
 
 	uint8 *sampPtr;
-	const int32 sampSize = _engine->_hqrdepack->hqrGetallocEntry(&sampPtr, Resources::HQR_FLASAMP_FILE, index);
+	const int32 sampSize = HQR::getAllocEntry(&sampPtr, Resources::HQR_FLASAMP_FILE, index);
 	if (sampSize == 0) {
 		warning("Failed to load %s", Resources::HQR_FLASAMP_FILE);
 		return;
@@ -107,7 +107,7 @@ void Sound::playVoxSample(int32 index) {
 	}
 
 	uint8 *sampPtr = nullptr;
-	int32 sampSize = _engine->_hqrdepack->hqrGetallocVoxEntry(&sampPtr, _engine->_text->currentVoxBankFile.c_str(), index, _engine->_text->voxHiddenIndex);
+	int32 sampSize = HQR::getAllocVoxEntry(&sampPtr, _engine->_text->currentVoxBankFile.c_str(), index, _engine->_text->voxHiddenIndex);
 	if (sampSize == 0) {
 		warning("Failed to get vox sample for index: %i", index);
 		return;
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 417b46602c..57bfe2ac20 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -24,7 +24,7 @@
 #include "common/scummsys.h"
 #include "common/str.h"
 #include "common/system.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/input.h"
 #include "twine/interface.h"
 #include "twine/menu.h"
@@ -134,7 +134,7 @@ void Text::initTextBank(int32 bankIdx) {
 	// get index according with language
 	const int32 size = _engine->isLBA1() ? 28 : 30;
 	const int32 languageIndex = _engine->cfgfile.LanguageId * size + bankIdx * 2;
-	const int32 hqrSize = _engine->_hqrdepack->hqrGetallocEntry((uint8 **)&dialOrderPtr, Resources::HQR_TEXT_FILE, languageIndex + INDEXOFFSET);
+	const int32 hqrSize = HQR::getAllocEntry((uint8 **)&dialOrderPtr, Resources::HQR_TEXT_FILE, languageIndex + INDEXOFFSET);
 	if (hqrSize == 0) {
 		warning("Failed to initialize text bank %i from file %s", languageIndex, Resources::HQR_TEXT_FILE);
 		return;
@@ -142,7 +142,7 @@ void Text::initTextBank(int32 bankIdx) {
 
 	numDialTextEntries = hqrSize / 2;
 
-	if (_engine->_hqrdepack->hqrGetallocEntry((uint8 **)&dialTextPtr, Resources::HQR_TEXT_FILE, languageIndex + DIALOGSOFFSET) == 0) {
+	if (HQR::getAllocEntry((uint8 **)&dialTextPtr, Resources::HQR_TEXT_FILE, languageIndex + DIALOGSOFFSET) == 0) {
 		warning("Failed to initialize additional text bank %i from file %s", languageIndex + 1, Resources::HQR_TEXT_FILE);
 		return;
 	}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 64c7d81411..2ba2925d95 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -52,7 +52,7 @@
 #include "twine/gamestate.h"
 #include "twine/grid.h"
 #include "twine/holomap.h"
-#include "twine/hqrdepack.h"
+#include "twine/hqr.h"
 #include "twine/input.h"
 #include "twine/interface.h"
 #include "twine/menu.h"
@@ -86,7 +86,6 @@ TwinEEngine::TwinEEngine(OSystem *system, Common::Language language, uint32 flag
 	_gameState = new GameState(this);
 	_grid = new Grid(this);
 	_movements = new Movements(this);
-	_hqrdepack = new HQRDepack();
 	_interface = new Interface(this);
 	_menu = new Menu(this);
 	_flaMovies = new FlaMovies(this);
@@ -116,7 +115,6 @@ TwinEEngine::~TwinEEngine() {
 	delete _gameState;
 	delete _grid;
 	delete _movements;
-	delete _hqrdepack;
 	delete _interface;
 	delete _menu;
 	delete _flaMovies;
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 2abf1e1725..b030001bc1 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -134,7 +134,6 @@ class Extra;
 class GameState;
 class Grid;
 class Movements;
-class HQRDepack;
 class Interface;
 class Menu;
 class FlaMovies;
@@ -186,7 +185,6 @@ public:
 	GameState *_gameState;
 	Grid *_grid;
 	Movements *_movements;
-	HQRDepack *_hqrdepack;
 	Interface *_interface;
 	Menu *_menu;
 	FlaMovies *_flaMovies;


Commit: e93dd7d5192efc0e844ec6790b78732265db9da6
    https://github.com/scummvm/scummvm/commit/e93dd7d5192efc0e844ec6790b78732265db9da6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:50:44+01:00

Commit Message:
TWINE: removed unused entries from pressedKeyCharMap

Changed paths:
    engines/twine/input.cpp


diff --git a/engines/twine/input.cpp b/engines/twine/input.cpp
index aa946ef70f..171ebf6a9a 100644
--- a/engines/twine/input.cpp
+++ b/engines/twine/input.cpp
@@ -44,37 +44,14 @@ static const struct KeyProperties {
     {0x02, true, 0x50}, // down
     {0x04, true, 0x4B}, // left
     {0x08, true, 0x4D}, // right
-	#if 0
-    {0x05, true, 0x47}, // home
-    {0x09, true, 0x49}, // pageup
-    {0x0A, true, 0x51}, // pagedown
-    {0x06, true, 0x4F}, // end
-	#endif
     {0x01, false, 0x39},  // space bar
     {0x02, false, 0x1C},  // enter
     {0x04, false, 0x1D},  // ctrl
     {0x08, false, 0x38},  // alt
     {0x10, false, 0x53},  // del
     {0x20, false, 0x2A},  // left shift
-    {0x20, false, 0x36},  // right shift
-	#if 0
-    {0x01, false, 0x3B},  // F1
-    {0x02, false, 0x3C},  // F2
-    {0x04, false, 0x3D},  // F3
-    {0x08, false, 0x3E},  // F4
-    {0x10, false, 0x3F},  // F5
-    {0x20, false, 0x40},  // F6
-    {0x40, false, 0x41},  // F7
-    {0x80, false, 0x42},  // F8
-    {0x01, false, 0x43},  // F9
-    {0x02, false, 0x44},  // F10
-    {0x04, false, 0x57},  // ?
-    {0x08, false, 0x58},  // ?
-    {0x00, false, 0x2A},  // left shift
-    {0x00, false, 0x00},
-	#endif
-    {0x01, true, 0x01}, // esc
-    {0x00, true, 0x00}};
+    {0x20, false, 0x36}  // right shift
+};
 
 ScopedKeyMap::ScopedKeyMap(TwinEEngine* engine, const char *id) : _engine(engine) {
 	_prevKeyMap = _engine->_input->currentKeyMap();


Commit: 39be27bbe6e02ab61a01cabddf8f016309d1d0ef
    https://github.com/scummvm/scummvm/commit/39be27bbe6e02ab61a01cabddf8f016309d1d0ef
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:50:44+01:00

Commit Message:
TWINE: removed unused PageUp action type

Changed paths:
    engines/twine/input.cpp
    engines/twine/input.h
    engines/twine/metaengine.cpp


diff --git a/engines/twine/input.cpp b/engines/twine/input.cpp
index 171ebf6a9a..2374c58805 100644
--- a/engines/twine/input.cpp
+++ b/engines/twine/input.cpp
@@ -150,7 +150,6 @@ static constexpr const struct ActionMapping {
     {InventoryMenu, 0x36},
     {SpecialAction, 0x11},
     {Escape, 0x01},
-    {PageUp, 0x49}, // TODO: used for what?
     {UIEnter, 0x00},
     {UIAbort, 0x00},
     {UILeft, 0x00},
diff --git a/engines/twine/input.h b/engines/twine/input.h
index e325e2ceca..bef0b44a8a 100644
--- a/engines/twine/input.h
+++ b/engines/twine/input.h
@@ -66,7 +66,6 @@ enum TwinEActionType {
 	InventoryMenu,
 	SpecialAction,
 	Escape,
-	PageUp,
 
 	UIEnter,
 	UIAbort,
diff --git a/engines/twine/metaengine.cpp b/engines/twine/metaengine.cpp
index a5ef1c8caf..73e2d16609 100644
--- a/engines/twine/metaengine.cpp
+++ b/engines/twine/metaengine.cpp
@@ -225,11 +225,6 @@ Common::KeymapArray TwinEMetaEngine::initKeymaps(const char *target) const {
 		act->addDefaultInputMapping("ESCAPE");
 		gameKeyMap->addAction(act);
 
-		act = new Action("PAGEUP", _("Page Up"));
-		act->setCustomEngineActionEvent(TwinEActionType::PageUp);
-		act->addDefaultInputMapping("PAGEUP");
-		gameKeyMap->addAction(act);
-
 		array[0] = gameKeyMap;
 	}
 


Commit: 8db2b58a9a5bf13487b35aac9ad163c1297233eb
    https://github.com/scummvm/scummvm/commit/8db2b58a9a5bf13487b35aac9ad163c1297233eb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-30T23:53:16+01:00

Commit Message:
TWINE: const

Changed paths:
    engines/twine/actor.h
    engines/twine/animations.cpp
    engines/twine/animations.h
    engines/twine/collision.cpp
    engines/twine/debug_grid.cpp
    engines/twine/grid.cpp
    engines/twine/grid.h
    engines/twine/interface.cpp
    engines/twine/movements.cpp
    engines/twine/redraw.cpp
    engines/twine/renderer.cpp
    engines/twine/renderer.h


diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index 88988f9935..6c9c4b3c9b 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -169,7 +169,7 @@ struct ActorStruct {
 	AnimationTypes anim = kAnimNone;
 	int32 animExtra = 0;  //field_2
 	int32 brickShape = 0; // field_3
-	uint8 *animExtraPtr = nullptr;
+	const uint8 *animExtraPtr = nullptr;
 	int32 sprite = 0; // field_8
 	uint8 *entityDataPtr = nullptr;
 	int32 entityDataSize = 0;
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 949d02ce18..bb41cd4a3b 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -160,10 +160,10 @@ void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx) {
 	int16 angleDif;
 	int16 computedAngle;
 
-	lastAngle = *(int16 *)(lastKeyFramePtr);
+	lastAngle = *(const int16 *)(lastKeyFramePtr);
 	lastKeyFramePtr += 2;
 
-	newAngle = *(int16 *)(keyFramePtr);
+	newAngle = *(const int16 *)(keyFramePtr);
 	keyFramePtr += 2;
 
 	lastAngle &= 0x3FF;
@@ -195,10 +195,10 @@ void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx) {
 	int16 angleDif;
 	int16 computedAngle;
 
-	lastAngle = *(int16 *)lastKeyFramePtr;
+	lastAngle = *(const int16 *)lastKeyFramePtr;
 	lastKeyFramePtr += 2;
 
-	newAngle = *(int16 *)keyFramePtr;
+	newAngle = *(const int16 *)keyFramePtr;
 	keyFramePtr += 2;
 
 	angleDif = newAngle - lastAngle;
@@ -431,15 +431,15 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
 }
 
 int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
-	int32 numOfPointInAnim = *(int16 *)(animPtr + 2);
+	const int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
 	keyFramePtr = ((numOfPointInAnim * 8 + 8) * animIdx) + animPtr + 8;
-	int32 keyFrameLength = *(int16 *)(keyFramePtr);
-	int16 bodyHeader = *(int16 *)(bodyPtr);
+	const int32 keyFrameLength = *(const int16 *)(keyFramePtr);
+	const int16 bodyHeader = *(const int16 *)(bodyPtr);
 	if (!(bodyHeader & 2)) {
 		return 0;
 	}
 
-	uint8 *ebx = animTimerDataPtr->ptr;
+	const uint8 *ebx = animTimerDataPtr->ptr;
 	int32 ebp = animTimerDataPtr->time;
 
 	if (!ebx) {
@@ -449,35 +449,35 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
 
 	lastKeyFramePtr = ebx;
 
-	int32 eax = _engine->lbaTime - ebp;
+	const int32 eax = _engine->lbaTime - ebp;
 
 	if (eax >= keyFrameLength) {
 		animTimerDataPtr->ptr = keyFramePtr;
 		animTimerDataPtr->time = _engine->lbaTime;
 
-		currentStepX = *(int16 *)(keyFramePtr + 2);
-		currentStepY = *(int16 *)(keyFramePtr + 4);
-		currentStepZ = *(int16 *)(keyFramePtr + 6);
+		currentStepX = *(const int16 *)(keyFramePtr + 2);
+		currentStepY = *(const int16 *)(keyFramePtr + 4);
+		currentStepZ = *(const int16 *)(keyFramePtr + 6);
 
-		processRotationByAnim = *(int16 *)(keyFramePtr + 8);
-		processLastRotationAngle = *(int16 *)(keyFramePtr + 12);
+		processRotationByAnim = *(const int16 *)(keyFramePtr + 8);
+		processLastRotationAngle = *(const int16 *)(keyFramePtr + 12);
 
 		return 1;
 	}
-	uint8 *keyFramePtrOld = keyFramePtr;
+	const uint8 *keyFramePtrOld = keyFramePtr;
 
 	lastKeyFramePtr += 8;
 	keyFramePtr += 8;
 
-	processRotationByAnim = *(int16 *)(keyFramePtr);
-	processLastRotationAngle = (*(int16 *)(keyFramePtr + 4) * eax) / keyFrameLength;
+	processRotationByAnim = *(const int16 *)(keyFramePtr);
+	processLastRotationAngle = (*(const int16 *)(keyFramePtr + 4) * eax) / keyFrameLength;
 
 	lastKeyFramePtr += 8;
 	keyFramePtr += 8;
 
-	currentStepX = (*(int16 *)(keyFramePtrOld + 2) * eax) / keyFrameLength;
-	currentStepY = (*(int16 *)(keyFramePtrOld + 4) * eax) / keyFrameLength;
-	currentStepZ = (*(int16 *)(keyFramePtrOld + 6) * eax) / keyFrameLength;
+	currentStepX = (*(const int16 *)(keyFramePtrOld + 2) * eax) / keyFrameLength;
+	currentStepY = (*(const int16 *)(keyFramePtrOld + 4) * eax) / keyFrameLength;
+	currentStepZ = (*(const int16 *)(keyFramePtrOld + 6) * eax) / keyFrameLength;
 
 	return 0;
 }
@@ -493,7 +493,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 	int32 index = 0;
 	const int32 endAnimEntityIdx = stream.readByte();
 	while (index++ < endAnimEntityIdx) {
-		int32 actionType = stream.readByte() - 5;
+		const int32 actionType = stream.readByte() - 5;
 		if (actionType >= ACTION_LAST) {
 			return;
 		}
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index 3a86c08c92..cb6b7e854f 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -56,7 +56,7 @@ private:
 	/** Pointer to current animation keyframe */
 	uint8 *keyFramePtr = nullptr;
 	/** Pointer to last animation keyframe */
-	uint8 *lastKeyFramePtr = nullptr;
+	const uint8 *lastKeyFramePtr = nullptr;
 
 public:
 	Animations(TwinEEngine *engine);
@@ -65,7 +65,7 @@ public:
 	/** Current process actor index */
 	int16 currentlyProcessedActorIdx = 0;
 	/** Current actor anim extra pointer */
-	uint8 *currentActorAnimExtraPtr = nullptr;
+	const uint8 *currentActorAnimExtraPtr = nullptr;
 
 	/**
 	 * Set animation keyframe
diff --git a/engines/twine/collision.cpp b/engines/twine/collision.cpp
index 60e33cb121..ec6fa13391 100644
--- a/engines/twine/collision.cpp
+++ b/engines/twine/collision.cpp
@@ -449,10 +449,8 @@ void Collision::checkActorCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 d
 }
 
 void Collision::stopFalling() { // ReceptionObj()
-	int32 fall;
-
 	if (_engine->_animations->currentlyProcessedActorIdx == 0) {
-		fall = _engine->_scene->heroYBeforeFall - _engine->_movements->processActorY;
+		const int32 fall = _engine->_scene->heroYBeforeFall - _engine->_movements->processActorY;
 
 		if (fall >= 0x1000) {
 			_engine->_extra->addExtraSpecial(_engine->_actor->processActorPtr->x, _engine->_actor->processActorPtr->y + 1000, _engine->_actor->processActorPtr->z, kHitStars);
@@ -478,29 +476,25 @@ void Collision::stopFalling() { // ReceptionObj()
 }
 
 int32 Collision::checkExtraCollisionWithActors(ExtraListStruct *extra, int32 actorIdx) {
-	int16 *spriteBounding = (int16 *)(_engine->_resources->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
-
-	int32 xLeft = *(spriteBounding++) + extra->x;
-	int32 xRight = *(spriteBounding++) + extra->x;
-
-	int32 yLeft = *(spriteBounding++) + extra->y;
-	int32 yRight = *(spriteBounding++) + extra->y;
+	const int16 *spriteBounding = (const int16 *)(_engine->_resources->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
 
-	int32 zLeft = *(spriteBounding++) + extra->z;
-	int32 zRight = *(spriteBounding++) + extra->z;
+	const int32 xLeft = *(spriteBounding++) + extra->x;
+	const int32 xRight = *(spriteBounding++) + extra->x;
+	const int32 yLeft = *(spriteBounding++) + extra->y;
+	const int32 yRight = *(spriteBounding++) + extra->y;
+	const int32 zLeft = *(spriteBounding++) + extra->z;
+	const int32 zRight = *(spriteBounding++) + extra->z;
 
 	for (int32 a = 0; a < _engine->_scene->sceneNumActors; a++) {
-		ActorStruct *actorTest = _engine->_scene->getActor(a);
+		const ActorStruct *actorTest = _engine->_scene->getActor(a);
 
 		if (a != actorIdx && actorTest->entity != -1) {
-			int32 xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
-			int32 xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
-
-			int32 yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
-			int32 yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
-
-			int32 zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
-			int32 zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
+			const int32 xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
+			const int32 xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
+			const int32 yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
+			const int32 yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
+			const int32 zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
+			const int32 zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
 
 			if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {
 				if (extra->strengthOfHit != 0) {
@@ -520,9 +514,9 @@ int32 Collision::checkExtraCollisionWithBricks(int32 X, int32 Y, int32 Z, int32
 		return 1;
 	}
 
-	int32 averageX = ABS(X + oldX) / 2;
-	int32 averageY = ABS(Y + oldY) / 2;
-	int32 averageZ = ABS(Z + oldZ) / 2;
+	const int32 averageX = ABS(X + oldX) / 2;
+	const int32 averageY = ABS(Y + oldY) / 2;
+	const int32 averageZ = ABS(Z + oldZ) / 2;
 
 	if (_engine->_grid->getBrickShape(averageX, averageY, averageZ)) {
 		return 1;
@@ -540,31 +534,27 @@ int32 Collision::checkExtraCollisionWithBricks(int32 X, int32 Y, int32 Z, int32
 }
 
 int32 Collision::checkExtraCollisionWithExtra(ExtraListStruct *extra, int32 extraIdx) {
-	int16 *spriteBounding = (int16 *)(_engine->_resources->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
-
-	int32 xLeft = *(spriteBounding++) + extra->x;
-	int32 xRight = *(spriteBounding++) + extra->x;
+	const int16 *spriteBounding = (const int16 *)(_engine->_resources->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
 
-	int32 yLeft = *(spriteBounding++) + extra->y;
-	int32 yRight = *(spriteBounding++) + extra->y;
-
-	int32 zLeft = *(spriteBounding++) + extra->z;
-	int32 zRight = *(spriteBounding++) + extra->z;
+	const int32 xLeft = *(spriteBounding++) + extra->x;
+	const int32 xRight = *(spriteBounding++) + extra->x;
+	const int32 yLeft = *(spriteBounding++) + extra->y;
+	const int32 yRight = *(spriteBounding++) + extra->y;
+	const int32 zLeft = *(spriteBounding++) + extra->z;
+	const int32 zRight = *(spriteBounding++) + extra->z;
 
 	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
-		ExtraListStruct *extraTest = &_engine->_extra->extraList[i];
+		const ExtraListStruct *extraTest = &_engine->_extra->extraList[i];
 		if (i != extraIdx && extraTest->info0 != -1) {
-			//            int16 * spriteBoundingTest;
-			//	        spriteBoundingTest = (int16*)(_engine->_resources->spriteBoundingBoxPtr + extraTest->info0 * 16 + 4);
-
-			int32 xLeftTest = *(spriteBounding++) + extraTest->x;
-			int32 xRightTest = *(spriteBounding++) + extraTest->x;
-
-			int32 yLeftTest = *(spriteBounding++) + extraTest->y;
-			int32 yRightTest = *(spriteBounding++) + extraTest->y;
-
-			int32 zLeftTest = *(spriteBounding++) + extraTest->z;
-			int32 zRightTest = *(spriteBounding++) + extraTest->z;
+			//          const int16 * spriteBoundingTest;
+			//	        spriteBoundingTest = (const int16*)(_engine->_resources->spriteBoundingBoxPtr + extraTest->info0 * 16 + 4);
+
+			const int32 xLeftTest = *(spriteBounding++) + extraTest->x;
+			const int32 xRightTest = *(spriteBounding++) + extraTest->x;
+			const int32 yLeftTest = *(spriteBounding++) + extraTest->y;
+			const int32 yRightTest = *(spriteBounding++) + extraTest->y;
+			const int32 zLeftTest = *(spriteBounding++) + extraTest->z;
+			const int32 zRightTest = *(spriteBounding++) + extraTest->z;
 
 			if (xLeft < xLeftTest) {
 				if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {
diff --git a/engines/twine/debug_grid.cpp b/engines/twine/debug_grid.cpp
index 7a2400fd79..86b7220032 100644
--- a/engines/twine/debug_grid.cpp
+++ b/engines/twine/debug_grid.cpp
@@ -92,14 +92,16 @@ void DebugGrid::applyCellingGrid() {
 	// Increase celling grid index
 	if (_engine->_input->toggleActionIfActive(TwinEActionType::IncreaseCellingGridIndex)) {
 		_engine->_grid->cellingGridIdx++;
-		if (_engine->_grid->cellingGridIdx > 133)
+		if (_engine->_grid->cellingGridIdx > 133) {
 			_engine->_grid->cellingGridIdx = 133;
+		}
 	}
 	// Decrease celling grid index
 	else if (_engine->_input->toggleActionIfActive(TwinEActionType::DecreaseCellingGridIndex)) {
 		_engine->_grid->cellingGridIdx--;
-		if (_engine->_grid->cellingGridIdx < 0)
+		if (_engine->_grid->cellingGridIdx < 0) {
 			_engine->_grid->cellingGridIdx = 0;
+		}
 	}
 	// Enable/disable celling grid
 	else if (_engine->_input->toggleActionIfActive(TwinEActionType::ApplyCellingGrid)) {
diff --git a/engines/twine/grid.cpp b/engines/twine/grid.cpp
index 6f359f58bb..53b7735a59 100644
--- a/engines/twine/grid.cpp
+++ b/engines/twine/grid.cpp
@@ -48,7 +48,7 @@ Grid::~Grid() {
 	}
 }
 
-void Grid::copyGridMask(int32 index, int32 x, int32 y, uint8 *buffer) {
+void Grid::copyGridMask(int32 index, int32 x, int32 y, const uint8 *buffer) {
 	uint8 *ptr = brickMaskTable[index];
 
 	int32 left = x + *(ptr + 2);
@@ -100,7 +100,7 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, uint8 *buffer) {
 	}
 
 	uint8 *outPtr = (uint8 *)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[absY] + left;
-	uint8 *inPtr = buffer + _engine->screenLookupTable[absY] + left;
+	const uint8 *inPtr = buffer + _engine->screenLookupTable[absY] + left;
 
 	do {
 		int32 vc3 = *(ptr++);
@@ -119,8 +119,9 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, uint8 *buffer) {
 			temp = *(ptr++); // copy size
 
 			for (int32 j = 0; j < temp; j++) {
-				if (absX >= _engine->_interface->textWindowLeft && absX <= _engine->_interface->textWindowRight)
+				if (absX >= _engine->_interface->textWindowLeft && absX <= _engine->_interface->textWindowRight) {
 					*outPtr = *inPtr;
+				}
 
 				absX++;
 				outPtr++;
@@ -173,16 +174,16 @@ void Grid::drawOverSpriteActor(int32 x, int32 y, int32 z) {
 	}
 }
 
-int Grid::processGridMask(uint8 *buffer, uint8 *ptr) {
-	uint32 *ptrSave = (uint32 *)ptr;
-	int32 ebx = *((uint32 *)buffer); // brick flag
+int Grid::processGridMask(const uint8 *buffer, uint8 *ptr) {
+	const uint32 *ptrSave = (const uint32 *)ptr;
+	int32 ebx = *((const uint32 *)buffer); // brick flag
 	buffer += 4;
 	*((uint32 *)ptr) = ebx;
 	ptr += 4;
 
 	uint8 bh = (ebx & 0x0000FF00) >> 8;
 
-	uint8 *esi = (uint8 *)buffer;
+	const uint8 *esi = (const uint8 *)buffer;
 	uint8 *edi = (uint8 *)ptr;
 
 	uint8 iteration = 0;
@@ -196,7 +197,7 @@ int Grid::processGridMask(uint8 *buffer, uint8 *ptr) {
 
 		uint8 bl = *(esi++);
 
-		if (*(esi)&0xC0) { // the first time isn't skip. the skip size is 0 in that case
+		if (*esi & 0xC0) { // the first time isn't skip. the skip size is 0 in that case
 			*edi++ = 0;
 			numOfBlock++;
 		}
@@ -234,7 +235,7 @@ int Grid::processGridMask(uint8 *buffer, uint8 *ptr) {
 		*ptr2 = numOfBlock;
 	} while (--bh > 0);
 
-	return ((int)((uint8 *)edi - (uint8 *)ptrSave));
+	return ((int)((const uint8 *)edi - (const uint8 *)ptrSave));
 }
 
 void Grid::createGridMask() {
@@ -250,8 +251,8 @@ void Grid::createGridMask() {
 	}
 }
 
-void Grid::getSpriteSize(int32 offset, int32 *width, int32 *height, uint8 *spritePtr) {
-	spritePtr += *((int32 *)(spritePtr + offset * 4));
+void Grid::getSpriteSize(int32 offset, int32 *width, int32 *height, const uint8 *spritePtr) {
+	spritePtr += *((const int32 *)(spritePtr + offset * 4));
 
 	*width = *spritePtr;
 	*height = *(spritePtr + 1);
@@ -267,7 +268,7 @@ int32 Grid::loadGridBricks(int32 gridSize) {
 	memset(brickUsageTable, 0, sizeof(brickUsageTable));
 
 	// get block librarie usage bits
-	uint8 *ptrToBllBits = currentGrid + (gridSize - 32);
+	const uint8 *ptrToBllBits = currentGrid + (gridSize - 32);
 
 	// for all bits under the 32bytes (256bits)
 	for (uint32 i = 1; i < 256; i++) {
@@ -275,8 +276,8 @@ int32 Grid::loadGridBricks(int32 gridSize) {
 		uint8 currentBitMask = 1 << (7 - (i & 7));
 
 		if (currentBitByte & currentBitMask) {
-			uint32 currentBllOffset = *((uint32 *)(currentBll + currentBllEntryIdx));
-			uint8 *currentBllPtr = currentBll + currentBllOffset;
+			uint32 currentBllOffset = *((const uint32 *)(currentBll + currentBllEntryIdx));
+			const uint8 *currentBllPtr = currentBll + currentBllOffset;
 
 			uint32 bllSizeX = currentBllPtr[0];
 			uint32 bllSizeY = currentBllPtr[1];
@@ -284,10 +285,10 @@ int32 Grid::loadGridBricks(int32 gridSize) {
 
 			uint32 bllSize = bllSizeX * bllSizeY * bllSizeZ;
 
-			uint8 *bllDataPtr = currentBllPtr + 5;
+			const uint8 *bllDataPtr = currentBllPtr + 5;
 
 			for (uint32 j = 0; j < bllSize; j++) {
-				uint32 brickIdx = *((int16 *)(bllDataPtr));
+				uint32 brickIdx = *((const int16 *)(bllDataPtr));
 
 				if (brickIdx) {
 					brickIdx--;
@@ -322,35 +323,38 @@ int32 Grid::loadGridBricks(int32 gridSize) {
 	return 1;
 }
 
-void Grid::createGridColumn(uint8 *gridEntry, uint8 *dest) {
+void Grid::createGridColumn(const uint8 *gridEntry, uint8 *dest) {
 	int32 brickCount = *(gridEntry++);
 
 	do {
 		int32 flag = *(gridEntry++);
 		int32 blockCount = (flag & 0x3F) + 1;
 
-		uint16 *gridBuffer = (uint16 *)gridEntry;
+		const uint16 *gridBuffer = (const uint16 *)gridEntry;
 		uint16 *blockByffer = (uint16 *)dest;
 
 		if (!(flag & 0xC0)) {
-			for (int32 i = 0; i < blockCount; i++)
+			for (int32 i = 0; i < blockCount; i++) {
 				*(blockByffer++) = 0;
+			}
 		} else if (flag & 0x40) {
-			for (int32 i = 0; i < blockCount; i++)
+			for (int32 i = 0; i < blockCount; i++) {
 				*(blockByffer++) = *(gridBuffer++);
+			}
 		} else {
 			int32 gridIdx = *(gridBuffer++);
-			for (int32 i = 0; i < blockCount; i++)
+			for (int32 i = 0; i < blockCount; i++) {
 				*(blockByffer++) = gridIdx;
+			}
 		}
 
-		gridEntry = (uint8 *)gridBuffer;
+		gridEntry = (const uint8 *)gridBuffer;
 		dest = (uint8 *)blockByffer;
 
 	} while (--brickCount);
 }
 
-void Grid::createCellingGridColumn(uint8 *gridEntry, uint8 *dest) {
+void Grid::createCellingGridColumn(const uint8 *gridEntry, uint8 *dest) {
 	int32 brickCount = *(gridEntry++);
 
 	do {
@@ -358,22 +362,25 @@ void Grid::createCellingGridColumn(uint8 *gridEntry, uint8 *dest) {
 
 		int32 blockCount = (flag & 0x3F) + 1;
 
-		uint16 *gridBuffer = (uint16 *)gridEntry;
+		const uint16 *gridBuffer = (const uint16 *)gridEntry;
 		uint16 *blockByffer = (uint16 *)dest;
 
 		if (!(flag & 0xC0)) {
-			for (int32 i = 0; i < blockCount; i++)
+			for (int32 i = 0; i < blockCount; i++) {
 				blockByffer++;
+			}
 		} else if (flag & 0x40) {
-			for (int32 i = 0; i < blockCount; i++)
+			for (int32 i = 0; i < blockCount; i++) {
 				*(blockByffer++) = *(gridBuffer++);
+			}
 		} else {
 			int32 gridIdx = *(gridBuffer++);
-			for (int32 i = 0; i < blockCount; i++)
+			for (int32 i = 0; i < blockCount; i++) {
 				*(blockByffer++) = gridIdx;
+			}
 		}
 
-		gridEntry = (uint8 *)gridBuffer;
+		gridEntry = (const uint8 *)gridBuffer;
 		dest = (uint8 *)blockByffer;
 
 	} while (--brickCount);
@@ -387,7 +394,7 @@ void Grid::createGridMap() {
 		int32 gridIdx = z << 6;
 
 		for (int32 x = 0; x < GRID_SIZE_X; x++) {
-			int32 gridOffset = *((uint16 *)(currentGrid + 2 * (x + gridIdx)));
+			int32 gridOffset = *((const uint16 *)(currentGrid + 2 * (x + gridIdx)));
 			createGridColumn(currentGrid + gridOffset, blockBuffer + blockOffset);
 			blockOffset += 50;
 		}
@@ -395,16 +402,16 @@ void Grid::createGridMap() {
 	}
 }
 
-void Grid::createCellingGridMap(uint8 *gridPtr) {
+void Grid::createCellingGridMap(const uint8 *gridPtr) {
 	int32 currGridOffset = 0;
 	int32 currOffset = 0;
 
 	for (int32 z = 0; z < GRID_SIZE_Z; z++) {
 		int32 blockOffset = currOffset;
-		uint8 *tempGridPtr = gridPtr + currGridOffset;
+		const uint8 *tempGridPtr = gridPtr + currGridOffset;
 
 		for (int32 x = 0; x < GRID_SIZE_X; x++) {
-			int gridOffset = *((uint16 *)tempGridPtr);
+			int gridOffset = *((const uint16 *)tempGridPtr);
 			tempGridPtr += 2;
 			createCellingGridColumn(gridPtr + gridOffset, blockBuffer + blockOffset);
 			blockOffset += 50;
@@ -429,7 +436,7 @@ bool Grid::initGrid(int32 index) {
 
 	createGridMask();
 
-	numberOfBll = (*((uint32 *)currentBll) >> 2);
+	numberOfBll = (*((const uint32 *)currentBll) >> 2);
 
 	createGridMap();
 
@@ -526,9 +533,9 @@ void Grid::drawBrickSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr
 }
 
 uint8* Grid::getBlockBuffer(int32 x, int32 y, int32 z) {
-	int32 tempX = (x + 0x100) >> 9;
-	int32 tempY = y >> 8;
-	int32 tempZ = (z + 0x100) >> 9;
+	const int32 tempX = (x + 0x100) >> 9;
+	const int32 tempY = y >> 8;
+	const int32 tempZ = (z + 0x100) >> 9;
 	return blockBuffer + tempY * 2 + tempX * GRID_SIZE_Y * 2 + (tempZ << 6) * GRID_SIZE_Y * 2;
 }
 
@@ -553,10 +560,9 @@ const uint8* Grid::getBlockBufferGround(int32 x, int32 y, int32 z, int16 &ground
 	return ptr;
 }
 
-
-uint8 *Grid::getBlockLibrary(int32 index) {
-	int32 offset = *((uint32 *)(currentBll + 4 * index));
-	return (uint8 *)(currentBll + offset);
+const uint8 *Grid::getBlockLibrary(int32 index) {
+	const int32 offset = *((const uint32 *)(currentBll + 4 * index));
+	return (const uint8 *)(currentBll + offset);
 }
 
 void Grid::getBrickPos(int32 x, int32 y, int32 z) {
@@ -565,11 +571,11 @@ void Grid::getBrickPos(int32 x, int32 y, int32 z) {
 }
 
 void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z) {
-	uint8 *blockPtr = getBlockLibrary(blockIdx) + 3 + brickBlockIdx * 4;
+	const uint8 *blockPtr = getBlockLibrary(blockIdx) + 3 + brickBlockIdx * 4;
 
-	uint8 brickShape = *((uint8 *)(blockPtr + 0));
-	uint8 brickSound = *((uint8 *)(blockPtr + 1));
-	uint16 brickIdx = *((uint16 *)(blockPtr + 2));
+	uint8 brickShape = *((const uint8 *)(blockPtr + 0));
+	uint8 brickSound = *((const uint8 *)(blockPtr + 1));
+	uint16 brickIdx = *((const uint16 *)(blockPtr + 2));
 	if (!brickIdx) {
 		return;
 	}
@@ -595,7 +601,7 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
 	int32 brickBuffIdx = (brickPixelPosX + 24) / 24;
 
 	if (brickInfoBuffer[brickBuffIdx] >= 150) {
-		warning("GRID WARNING: brick buffer exceeded");
+		warning("GRID: brick buffer exceeded");
 		return;
 	}
 
@@ -666,9 +672,9 @@ int32 Grid::getBrickShape(int32 x, int32 y, int32 z) {
 	uint8 blockIdx = *blockBufferPtr;
 
 	if (blockIdx) {
-		uint8 *blockPtr = currentBll;
+		const uint8 *blockPtr = currentBll;
 
-		blockPtr += *(uint32 *)(blockPtr + blockIdx * 4 - 4);
+		blockPtr += *(const uint32 *)(blockPtr + blockIdx * 4 - 4);
 		blockPtr += 3;
 
 		const uint8 tmpBrickIdx = *(blockBufferPtr + 1);
@@ -708,9 +714,9 @@ int32 Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
 	uint8 blockIdx = *blockBufferPtr;
 
 	if (blockIdx) {
-		uint8 *blockPtr = currentBll;
+		const uint8 *blockPtr = currentBll;
 
-		blockPtr += *(uint32 *)(blockPtr + blockIdx * 4 - 4);
+		blockPtr += *(const uint32 *)(blockPtr + blockIdx * 4 - 4);
 		blockPtr += 3;
 
 		uint8 tmpBrickIdx = *(blockBufferPtr + 1);
@@ -729,7 +735,7 @@ int32 Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
 			blockBufferPtr += 2;
 			currY++;
 
-			if (*(int16 *)(blockBufferPtr) != 0) {
+			if (*(const int16 *)(blockBufferPtr) != 0) {
 				return 1;
 			}
 		}
@@ -749,7 +755,7 @@ int32 Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
 		blockBufferPtr += 2;
 		currY++;
 
-		if (*(int16 *)(blockBufferPtr) != 0) {
+		if (*(const int16 *)(blockBufferPtr) != 0) {
 			return 1;
 		}
 	}
@@ -772,7 +778,7 @@ int32 Grid::getBrickSoundType(int32 x, int32 y, int32 z) { // getPos2
 		return 0;
 	}
 
-	uint8 *blockBufferPtr = blockBuffer;
+	const uint8 *blockBufferPtr = blockBuffer;
 	blockBufferPtr += _engine->_collision->collisionX * GRID_SIZE_Y * 2;
 	blockBufferPtr += _engine->_collision->collisionY * 2;
 	blockBufferPtr += (_engine->_collision->collisionZ << 7) * GRID_SIZE_Y;
@@ -780,16 +786,16 @@ int32 Grid::getBrickSoundType(int32 x, int32 y, int32 z) { // getPos2
 	uint8 blockIdx = *blockBufferPtr;
 
 	if (blockIdx) {
-		uint8 *blockPtr = currentBll;
+		const uint8 *blockPtr = currentBll;
 
-		blockPtr += *(uint32 *)(blockPtr + blockIdx * 4 - 4);
+		blockPtr += *(const uint32 *)(blockPtr + blockIdx * 4 - 4);
 		blockPtr += 3;
 
 		uint8 tmpBrickIdx = *(blockBufferPtr + 1);
 		blockPtr = blockPtr + tmpBrickIdx * 4;
 		blockPtr++;
 
-		return *((int16 *)blockPtr);
+		return *((const int16 *)blockPtr);
 	}
 
 	return 0xF0;
diff --git a/engines/twine/grid.h b/engines/twine/grid.h
index f3a15841a5..e0cb2afe7c 100644
--- a/engines/twine/grid.h
+++ b/engines/twine/grid.h
@@ -113,19 +113,19 @@ private:
 	 * Create celling grid map from celling grid to block library buffer
 	 * @param gridPtr celling grid buffer pointer
 	 */
-	void createCellingGridMap(uint8 *gridPtr);
+	void createCellingGridMap(const uint8 *gridPtr);
 	/**
 	 * Create grid Y column in block buffer
 	 * @param gridEntry current grid index
 	 * @param dest destination block buffer
 	 */
-	void createCellingGridColumn(uint8 *gridEntry, uint8 *dest);
+	void createCellingGridColumn(const uint8 *gridEntry, uint8 *dest);
 	/**
 	 * Create grid Y column in block buffer
 	 * @param gridEntry current grid index
 	 * @param dest destination block buffer
 	 */
-	void createGridColumn(uint8 *gridEntry, uint8 *dest);
+	void createGridColumn(const uint8 *gridEntry, uint8 *dest);
 	/**
 	 * Load grid bricks according with block librarie usage
 	 * @param gridSize size of the current grid
@@ -139,7 +139,7 @@ private:
 	 * @param buffer brick pointer buffer
 	 * @param ptr brick mask pointer buffer
 	 */
-	int processGridMask(uint8 *buffer, uint8 *ptr);
+	int processGridMask(const uint8 *buffer, uint8 *ptr);
 	/**
 	 * Copy grid mask to allow actors to display over the bricks
 	 * @param index current brick index
@@ -147,7 +147,7 @@ private:
 	 * @param y grid Y coordinate
 	 * @param buffer work video buffer
 	 */
-	void copyGridMask(int32 index, int32 x, int32 y, uint8 *buffer);
+	void copyGridMask(int32 index, int32 x, int32 y, const uint8 *buffer);
 
 	/** Table with all loaded bricks */
 	uint8 *brickTable[NUM_BRICKS]{nullptr};
@@ -235,7 +235,7 @@ public:
 	 * @param height sprite height size
 	 * @param spritePtr sprite buffer pointer
 	 */
-	void getSpriteSize(int32 offset, int32 *width, int32 *height, uint8 *spritePtr);
+	void getSpriteSize(int32 offset, int32 *width, int32 *height, const uint8 *spritePtr);
 
 	/**
 	 * Draw brick sprite in the screen
@@ -269,7 +269,7 @@ public:
 	 * @param index block library index
 	 * @return pointer to the current block index
 	 */
-	uint8 *getBlockLibrary(int32 index);
+	const uint8 *getBlockLibrary(int32 index);
 
 	/** Create grid map from current grid to block library buffer */
 	void createGridMap();
diff --git a/engines/twine/interface.cpp b/engines/twine/interface.cpp
index 902b6b750d..3872e1dff4 100644
--- a/engines/twine/interface.cpp
+++ b/engines/twine/interface.cpp
@@ -241,20 +241,24 @@ void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom
 }
 
 void Interface::setClip(int32 left, int32 top, int32 right, int32 bottom) {
-	if (left < 0)
+	if (left < 0) {
 		left = 0;
+	}
 	textWindowLeft = left;
 
-	if (top < 0)
+	if (top < 0) {
 		top = 0;
+	}
 	textWindowTop = top;
 
-	if (right >= SCREEN_WIDTH)
+	if (right >= SCREEN_WIDTH) {
 		right = SCREEN_TEXTLIMIT_RIGHT;
+	}
 	textWindowRight = right;
 
-	if (bottom >= SCREEN_HEIGHT)
+	if (bottom >= SCREEN_HEIGHT) {
 		bottom = SCREEN_TEXTLIMIT_BOTTOM;
+	}
 	textWindowBottom = bottom;
 }
 
diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index 36f71d6207..740c338930 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -42,8 +42,8 @@ void Movements::getShadowPosition(int32 x, int32 y, int32 z) {
 	processActorZ = z;
 
 	if (*ptr) {
-		uint8 *blockPtr = _engine->_grid->getBlockLibrary(*ptr - 1) + 3 + *(ptr + 1) * 4;
-		uint8 brickShape = *((uint8 *)(blockPtr));
+		const uint8 *blockPtr = _engine->_grid->getBlockLibrary(*ptr - 1) + 3 + *(ptr + 1) * 4;
+		const uint8 brickShape = *((const uint8 *)(blockPtr));
 		_engine->_actor->shadowCollisionType = brickShape;
 	} else {
 		_engine->_actor->shadowCollisionType = 0;
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index c8fc2bcbfc..ba89437f3c 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -49,28 +49,32 @@ void Redraw::addRedrawCurrentArea(int32 left, int32 top, int32 right, int32 bott
 
 	while (i < numOfRedrawBox) {
 		int32 leftValue;
-		if (currentRedrawList[i].left >= left)
+		if (currentRedrawList[i].left >= left) {
 			leftValue = left;
-		else
+		} else {
 			leftValue = currentRedrawList[i].left;
+		}
 
 		int32 rightValue;
-		if (currentRedrawList[i].right <= right)
+		if (currentRedrawList[i].right <= right) {
 			rightValue = right;
-		else
+		} else {
 			rightValue = currentRedrawList[i].right;
+		}
 
 		int32 topValue;
-		if (currentRedrawList[i].top >= top)
+		if (currentRedrawList[i].top >= top) {
 			topValue = top;
-		else
+		} else {
 			topValue = currentRedrawList[i].top;
+		}
 
 		int32 bottomValue;
-		if (currentRedrawList[i].bottom <= bottom)
+		if (currentRedrawList[i].bottom <= bottom) {
 			bottomValue = bottom;
-		else
+		} else {
 			bottomValue = currentRedrawList[i].bottom;
+		}
 
 		if ((rightValue - leftValue) * (bottomValue - topValue) < ((currentRedrawList[i].bottom - currentRedrawList[i].top) * (currentRedrawList[i].right - currentRedrawList[i].left) + area)) {
 			currentRedrawList[i].left = leftValue;
@@ -98,11 +102,11 @@ void Redraw::addRedrawCurrentArea(int32 left, int32 top, int32 right, int32 bott
 }
 
 void Redraw::addRedrawArea(int32 left, int32 top, int32 right, int32 bottom) {
-	if (left < 0) {
-		left = 0;
+	if (left < SCREEN_TEXTLIMIT_LEFT) {
+		left = SCREEN_TEXTLIMIT_LEFT;
 	}
-	if (top < 0) {
-		top = 0;
+	if (top < SCREEN_TEXTLIMIT_TOP) {
+		top = SCREEN_TEXTLIMIT_TOP;
 	}
 	if (right >= SCREEN_WIDTH) {
 		right = SCREEN_TEXTLIMIT_RIGHT;
@@ -198,19 +202,16 @@ void Redraw::updateOverlayTypePosition(int16 X1, int16 Y1, int16 X2, int16 Y2) {
 
 // TODO: convert to bool and check if this isn't always true...
 void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
-	int16 tmp_projPosX;
-	int16 tmp_projPosY;
-	ActorStruct *actor;
-
-	tmp_projPosX = _engine->_renderer->projPosXScreen;
-	tmp_projPosY = _engine->_renderer->projPosYScreen;
+	int16 tmp_projPosX = _engine->_renderer->projPosXScreen;
+	int16 tmp_projPosY = _engine->_renderer->projPosYScreen;
 
 	_engine->_interface->resetClip();
 
 	if (bgRedraw) {
 		_engine->freezeTime();
-		if (_engine->_scene->needChangeScene != -1 && _engine->_scene->needChangeScene != -2)
+		if (_engine->_scene->needChangeScene != -1 && _engine->_scene->needChangeScene != -2) {
 			_engine->_screens->fadeOut(_engine->_screens->paletteRGBA);
+		}
 		_engine->_screens->clearScreen();
 		_engine->_grid->redrawGrid();
 		updateOverlayTypePosition(tmp_projPosX, tmp_projPosY, _engine->_renderer->projPosXScreen, _engine->_renderer->projPosYScreen);
@@ -233,10 +234,10 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 
 	// Process actors drawing list
 	for (modelActorPos = 0; modelActorPos < _engine->_scene->sceneNumActors; modelActorPos++, spriteActorPos++, shadowActorPos++) {
-		actor = _engine->_scene->getActor(modelActorPos);
+		ActorStruct *actor = _engine->_scene->getActor(modelActorPos);
 		actor->dynamicFlags.bIsVisible = 0; // reset visible state
 
-		if (_engine->_grid->useCellingGrid == -1 || actor->y <= (*(int16 *)(_engine->_grid->cellingGridIdx * 24 + (int8 *)_engine->_scene->sceneZones + 8))) {
+		if (_engine->_grid->useCellingGrid == -1 || actor->y <= (*(const int16 *)(_engine->_grid->cellingGridIdx * 24 + (const int8 *)_engine->_scene->sceneZones + 8))) {
 			// no redraw required
 			if (actor->staticFlags.bIsBackgrounded && bgRedraw == 0) {
 				// get actor position on screen
@@ -355,11 +356,11 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 					_engine->_animations->setModelAnimation(actor2->animPosition, _engine->_resources->animTable[actor2->previousAnimIdx], _engine->_actor->bodyTable[actor2->entity], &actor2->animTimerData);
 
 					if (!_engine->_renderer->renderIsoModel(actor2->x - _engine->_grid->cameraX, actor2->y - _engine->_grid->cameraY, actor2->z - _engine->_grid->cameraZ, 0, actor2->angle, 0, _engine->_actor->bodyTable[actor2->entity])) {
-						if (renderLeft < 0) {
+						if (renderLeft < SCREEN_TEXTLIMIT_LEFT) {
 							renderLeft = SCREEN_TEXTLIMIT_LEFT;
 						}
 
-						if (renderTop < 0) {
+						if (renderTop < SCREEN_TEXTLIMIT_TOP) {
 							renderTop = SCREEN_TEXTLIMIT_TOP;
 						}
 
@@ -401,7 +402,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 			}
 			// Drawing shadows
 			else if (flags == 0xC00 && !_engine->_actor->cropBottomScreen) {
-				DrawListStruct shadow = drawList[pos];
+				const DrawListStruct& shadow = drawList[pos];
 
 				// get actor position on screen
 				_engine->_renderer->projectPositionOnScreen(shadow.x - _engine->_grid->cameraX, shadow.y - _engine->_grid->cameraY, shadow.z - _engine->_grid->cameraZ);
@@ -582,12 +583,11 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				break;
 			}
 			case koNumber: {
-				int32 textLength, textHeight;
 				char text[10];
 				snprintf(text, sizeof(text), "%d", overlay->info0);
 
-				textLength = _engine->_text->getTextSize(text);
-				textHeight = 48;
+				int32 textLength = _engine->_text->getTextSize(text);
+				int32 textHeight = 48;
 
 				renderLeft = overlay->x - (textLength / 2);
 				renderTop = overlay->y - 24;
@@ -606,15 +606,14 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				break;
 			}
 			case koNumberRange: {
-				int32 textLength, textHeight, range;
 				char text[10];
 
-				range = _engine->_collision->getAverageValue(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->lbaTime - 50);
+				int32 range = _engine->_collision->getAverageValue(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->lbaTime - 50);
 
 				sprintf(text, "%d", range);
 
-				textLength = _engine->_text->getTextSize(text);
-				textHeight = 48;
+				int32 textLength = _engine->_text->getTextSize(text);
+				int32 textHeight = 48;
 
 				renderLeft = overlay->x - (textLength / 2);
 				renderTop = overlay->y - 24;
@@ -663,12 +662,12 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				renderRight = overlay->x + (textLength / 2);
 				renderBottom = overlay->y + textHeight;
 
-				if (renderLeft < 0) {
-					renderLeft = 0;
+				if (renderLeft < SCREEN_TEXTLIMIT_LEFT) {
+					renderLeft = SCREEN_TEXTLIMIT_LEFT;
 				}
 
-				if (renderTop < 0) {
-					renderTop = 0;
+				if (renderTop < SCREEN_TEXTLIMIT_TOP) {
+					renderTop = SCREEN_TEXTLIMIT_TOP;
 				}
 
 				if (renderRight > SCREEN_TEXTLIMIT_RIGHT) {
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 1ad806afaa..058651d295 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -167,7 +167,7 @@ void Renderer::setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ,
 	baseTransPosZ = destZ;
 }
 
-void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
+void Renderer::applyRotation(int32 *tempMatrix, const int32 *currentMatrix) {
 	int32 matrix1[9];
 	int32 matrix2[9];
 
@@ -188,8 +188,9 @@ void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
 		matrix1[7] = (currentMatrix[8] * angleVar2 + currentMatrix[7] * angleVar1) >> 14;
 		matrix1[8] = (currentMatrix[8] * angleVar1 - currentMatrix[7] * angleVar2) >> 14;
 	} else {
-		for (int32 i = 0; i < 9; i++)
+		for (int32 i = 0; i < 9; i++) {
 			matrix1[i] = currentMatrix[i];
+		}
 	}
 
 	if (renderAngleZ) {
@@ -209,8 +210,9 @@ void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
 		matrix2[6] = (matrix1[7] * angleVar2 + matrix1[6] * angleVar1) >> 14;
 		matrix2[7] = (matrix1[7] * angleVar1 - matrix1[6] * angleVar2) >> 14;
 	} else {
-		for (int32 i = 0; i < 9; i++)
+		for (int32 i = 0; i < 9; i++) {
 			matrix2[i] = matrix1[i];
+		}
 	}
 
 	if (renderAngleY) {
@@ -231,17 +233,18 @@ void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
 		tempMatrix[6] = (matrix2[6] * angleVar1 - matrix2[8] * angleVar2) >> 14;
 		tempMatrix[8] = (matrix2[6] * angleVar2 + matrix2[8] * angleVar1) >> 14;
 	} else {
-		for (int32 i = 0; i < 9; i++)
+		for (int32 i = 0; i < 9; i++) {
 			tempMatrix[i] = matrix2[i];
+		}
 	}
 }
 
-void Renderer::applyPointsRotation(uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, int32 *rotationMatrix) {
+void Renderer::applyPointsRotation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *rotationMatrix) {
 	int32 numOfPoints2 = numPoints;
 
 	do {
-		uint8 *pointsPtr2 = firstPointsPtr;
-		const int16 *tempPtr = (int16 *)(firstPointsPtr);
+		const uint8 *pointsPtr2 = firstPointsPtr;
+		const int16 *tempPtr = (const int16 *)(firstPointsPtr);
 
 		const int16 tmpX = tempPtr[0];
 		const int16 tmpY = tempPtr[1];
@@ -256,7 +259,7 @@ void Renderer::applyPointsRotation(uint8 *firstPointsPtr, int32 numPoints, point
 	} while (--numOfPoints2);
 }
 
-void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, elementEntry *elemPtr) { // unsigned char * elemPtr) // loadPart
+void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr) { // unsigned char * elemPtr) // loadPart
 	int32 firstPoint = elemPtr->firstPoint;
 	int32 numOfPoints2 = elemPtr->numOfPoints;
 
@@ -271,7 +274,7 @@ void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, element
 	//baseElement = *((unsigned short int*)elemPtr+6);
 	const int16 baseElement = elemPtr->baseElement;
 
-	int32 *currentMatrix;
+	const int32 *currentMatrix;
 	// if its the first point
 	if (baseElement == -1) {
 		currentMatrix = baseMatrix;
@@ -281,7 +284,7 @@ void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, element
 		destZ = 0;
 	} else {
 		int32 pointIdx = (elemPtr->basePoint) / 6;
-		currentMatrix = (int32 *)((uint8 *)matricesTable + baseElement);
+		currentMatrix = (const int32 *)((const uint8 *)matricesTable + baseElement);
 
 		destX = computedPoints[pointIdx].X;
 		destY = computedPoints[pointIdx].Y;
@@ -294,15 +297,15 @@ void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, element
 		warning("RENDER WARNING: No points in this model!");
 	}
 
-	applyPointsRotation(pointsPtr + firstPoint, numOfPoints2, &computedPoints[firstPoint / 6], (int32 *)currentMatrixTableEntry);
+	applyPointsRotation(pointsPtr + firstPoint, numOfPoints2, &computedPoints[firstPoint / 6], (const int32 *)currentMatrixTableEntry);
 }
 
-void Renderer::applyPointsTranslation(uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, int32 *translationMatrix) {
+void Renderer::applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *translationMatrix) {
 	int32 numOfPoints2 = numPoints;
 
 	do {
-		uint8 *pointsPtr2 = firstPointsPtr;
-		int16 *tempPtr = (int16 *)(firstPointsPtr);
+		const uint8 *pointsPtr2 = firstPointsPtr;
+		const int16 *tempPtr = (const int16 *)(firstPointsPtr);
 
 		const int16 tmpX = tempPtr[0] + renderAngleZ;
 		const int16 tmpY = tempPtr[1] + renderAngleY;
@@ -317,7 +320,7 @@ void Renderer::applyPointsTranslation(uint8 *firstPointsPtr, int32 numPoints, po
 	} while (--numOfPoints2);
 }
 
-void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, elementEntry *elemPtr) {
+void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr) {
 	renderAngleX = rotX;
 	renderAngleY = rotY;
 	renderAngleZ = rotZ;
@@ -329,8 +332,9 @@ void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, elem
 
 		int32 *dest = (int32 *)currentMatrixTableEntry;
 
-		for (int32 i = 0; i < 9; i++)
+		for (int32 i = 0; i < 9; i++) {
 			dest[i] = baseMatrix[i];
+		}
 	} else { // dependent
 		destX = computedPoints[(elemPtr->basePoint) / 6].X;
 		destY = computedPoints[(elemPtr->basePoint) / 6].Y;
@@ -339,8 +343,9 @@ void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, elem
 		const int32 *source = (const int32 *)((const uint8 *)matricesTable + elemPtr->baseElement);
 		int32 *dest = (int32 *)currentMatrixTableEntry;
 
-		for (int32 i = 0; i < 9; i++)
+		for (int32 i = 0; i < 9; i++) {
 			dest[i] = source[i];
+		}
 	}
 
 	applyPointsTranslation(pointsPtr + elemPtr->firstPoint, elemPtr->numOfPoints, &computedPoints[elemPtr->firstPoint / 6], (int32 *)currentMatrixTableEntry);
@@ -997,7 +1002,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	int16 type;
 	int16 color;
 
-	lineData *lineDataPtr;
+	const lineData *lineDataPtr;
 	lineCoordinates *lineCoordinatesPtr;
 
 	int32 point1;
@@ -1200,22 +1205,22 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 	// prepare lines
 
-	temp = *((int16 *)pointer);
+	temp = *((const int16 *)pointer);
 	pointer += 2;
 	if (temp) {
 		numOfPrimitives += temp;
 		do {
 			int32 param;
-			lineDataPtr = (lineData *)pointer;
+			lineDataPtr = (const lineData *)pointer;
 			lineCoordinatesPtr = (lineCoordinates *)edi;
 
-			if (*((int16 *)&lineDataPtr->p1) % 6 != 0 || *((int16 *)&lineDataPtr->p2) % 6 != 0) {
+			if (*((const int16 *)&lineDataPtr->p1) % 6 != 0 || *((const int16 *)&lineDataPtr->p2) % 6 != 0) {
 				error("RENDER ERROR: lineDataPtr reference is malformed!");
 			}
 
-			point1 = *((int16 *)&lineDataPtr->p1) / 6;
-			point2 = *((int16 *)&lineDataPtr->p2) / 6;
-			param = *((int32 *)&lineDataPtr->data);
+			point1 = *((const int16 *)&lineDataPtr->p1) / 6;
+			point2 = *((const int16 *)&lineDataPtr->p2) / 6;
+			param = *((const int32 *)&lineDataPtr->data);
 			*((int32 *)&lineCoordinatesPtr->data) = param;
 			*((int16 *)&lineCoordinatesPtr->x1) = flattenPoints[point1].X;
 			*((int16 *)&lineCoordinatesPtr->y1) = flattenPoints[point1].Y;
@@ -1305,16 +1310,16 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 				lineCoordinatesPtr = (lineCoordinates *)pointer;
 				color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
 
-				x1 = *((int16 *)&lineCoordinatesPtr->x1);
-				y1 = *((int16 *)&lineCoordinatesPtr->y1);
-				x2 = *((int16 *)&lineCoordinatesPtr->x2);
-				y2 = *((int16 *)&lineCoordinatesPtr->y2);
+				x1 = *((const int16 *)&lineCoordinatesPtr->x1);
+				y1 = *((const int16 *)&lineCoordinatesPtr->y1);
+				x2 = *((const int16 *)&lineCoordinatesPtr->x2);
+				y2 = *((const int16 *)&lineCoordinatesPtr->y2);
 
 				_engine->_interface->drawLine(x1, y1, x2, y2, color);
 				break;
 			}
 			case RENDERTYPE_DRAWPOLYGON: { // draw a polygon
-				eax = *((int *)pointer);
+				eax = *((const int *)pointer);
 				pointer += 4;
 
 				polyRenderType = eax & 0xFF;
@@ -1324,7 +1329,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 				destPtr = (uint8 *)vertexCoordinates;
 
 				for (i = 0; i < (numOfVertex * 3); i++) {
-					*((int16 *)destPtr) = *((int16 *)pointer);
+					*((int16 *)destPtr) = *((const int16 *)pointer);
 					destPtr += 2;
 					pointer += 2;
 				}
@@ -1342,15 +1347,15 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 				int32 circleParam4;
 				int32 circleParam5;
 
-				eax = *(int *)pointer;
+				eax = *(const int *)pointer;
 
-				circleParam1 = *(uint8 *)pointer;
-				circleParam4 = *((int16 *)(pointer + 1));
-				circleParam5 = *((int16 *)(pointer + 3));
-				circleParam3 = *((int16 *)(pointer + 5));
+				circleParam1 = *(const uint8 *)pointer;
+				circleParam4 = *((const int16 *)(pointer + 1));
+				circleParam5 = *((const int16 *)(pointer + 3));
+				circleParam3 = *((const int16 *)(pointer + 5));
 
 				if (!isUsingOrhoProjection) {
-					circleParam3 = (circleParam3 * cameraPosY) / (cameraPosX + *(int16 *)pointer);
+					circleParam3 = (circleParam3 * cameraPosY) / (cameraPosX + *(const int16 *)pointer);
 				} else {
 					circleParam3 = (circleParam3 * 34) >> 9;
 				}
@@ -1394,29 +1399,29 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 	elementEntry *elemEntryPtr;
-	pointTab *pointPtr;
+	const pointTab *pointPtr;
 	pointTab *pointPtrDest;
 	int32 coX;
 	int32 coY;
 	int32 coZ;
-	uint8 *tmpElemPtr;
+	const uint8 *tmpElemPtr;
 	//	int32 *tmpLightMatrix;
-	uint8 *tmpShadePtr;
+	const uint8 *tmpShadePtr;
 	int32 numOfShades;
 
-	numOfPoints = *((uint16 *)bodyPtr);
+	numOfPoints = *((const uint16 *)bodyPtr);
 	bodyPtr += 2;
 	pointsPtr = bodyPtr;
 
 	bodyPtr += numOfPoints * 6;
 
-	numOfElements = *((uint16 *)bodyPtr);
+	numOfElements = *((const uint16 *)bodyPtr);
 	bodyPtr += 2;
 	elementsPtr = elementsPtr2 = bodyPtr;
 
 	currentMatrixTableEntry = (uint8 *)matricesTable;
 
-	processRotatedElement(renderAngleX, renderAngleY, renderAngleZ, (elementEntry *)elementsPtr);
+	processRotatedElement(renderAngleX, renderAngleY, renderAngleZ, (const elementEntry *)elementsPtr);
 
 	elementsPtr += 38;
 
@@ -1456,15 +1461,19 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 			pointPtrDest->Y = (((coX - coZ) * 12) - coY * 30) / 512 + orthoProjY;
 			pointPtrDest->Z = coZ - coX - coY;
 
-			if (pointPtrDest->X < _engine->_redraw->renderLeft)
+			if (pointPtrDest->X < _engine->_redraw->renderLeft) {
 				_engine->_redraw->renderLeft = pointPtrDest->X;
-			if (pointPtrDest->X > _engine->_redraw->renderRight)
+			}
+			if (pointPtrDest->X > _engine->_redraw->renderRight) {
 				_engine->_redraw->renderRight = pointPtrDest->X;
+			}
 
-			if (pointPtrDest->Y < _engine->_redraw->renderTop)
+			if (pointPtrDest->Y < _engine->_redraw->renderTop) {
 				_engine->_redraw->renderTop = pointPtrDest->Y;
-			if (pointPtrDest->Y > _engine->_redraw->renderBottom)
+			}
+			if (pointPtrDest->Y > _engine->_redraw->renderBottom) {
 				_engine->_redraw->renderBottom = pointPtrDest->Y;
+			}
 
 			pointPtr++;
 			pointPtrDest++;
@@ -1527,7 +1536,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 	shadePtr = (int32 *)elementsPtr;
 
-	numOfShades = *((uint16 *)shadePtr);
+	numOfShades = *((const uint16 *)shadePtr);
 
 	shadePtr = (int32 *)(((uint8 *)shadePtr) + 2);
 
@@ -1537,14 +1546,14 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 		uint8 *currentShadeDestination = (uint8 *)shadeTable;
 		int32 *lightMatrix = matricesTable;
-		uint8 *pri2Ptr3;
+		const uint8 *pri2Ptr3;
 
 		numOfPrimitives = numOfElements;
 
 		tmpElemPtr = pri2Ptr3 = elementsPtr2 + 18;
 
 		do { // for each element
-			numOfShades = *((uint16 *)tmpElemPtr);
+			numOfShades = *((const uint16 *)tmpElemPtr);
 
 			if (numOfShades) {
 				int32 numShades = numOfShades;
@@ -1566,13 +1575,13 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 					int16 col2;
 					int16 col3;
 
-					int16 *colPtr;
+					const int16 *colPtr;
 
-					colPtr = (int16 *)shadePtr;
+					colPtr = (const int16 *)shadePtr;
 
-					col1 = *((int16 *)colPtr++);
-					col2 = *((int16 *)colPtr++);
-					col3 = *((int16 *)colPtr++);
+					col1 = *((const int16 *)colPtr++);
+					col2 = *((const int16 *)colPtr++);
+					col3 = *((const int16 *)colPtr++);
 
 					color = shadeMatrix[0] * col1 + shadeMatrix[1] * col2 + shadeMatrix[2] * col3;
 					color += shadeMatrix[3] * col1 + shadeMatrix[4] * col2 + shadeMatrix[5] * col3;
@@ -1582,8 +1591,8 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 					if (color > 0) {
 						color >>= 14;
-						tmpShadePtr = (uint8 *)shadePtr;
-						color /= *((uint16 *)(tmpShadePtr + 6));
+						tmpShadePtr = (const uint8 *)shadePtr;
+						color /= *((const uint16 *)(tmpShadePtr + 6));
 						shade = (uint16)color;
 					}
 
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index e9dc7032de..72bd360f69 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -121,13 +121,13 @@ private:
 	int32 renderAnimatedModel(uint8 *bodyPtr);
 	void circleFill(int32 x, int32 y, int32 radius, int8 color);
 	int32 renderModelElements(uint8 *pointer);
-	void getBaseRotationPosition(int32 X, int32 Y, int32 Z);
-	void getCameraAnglePositions(int32 X, int32 Y, int32 Z);
-	void applyRotation(int32 *tempMatrix, int32 *currentMatrix);
-	void applyPointsRotation(uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, int32 *rotationMatrix);
-	void processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, elementEntry *elemPtr);
-	void applyPointsTranslation(uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, int32 *translationMatrix);
-	void processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, elementEntry *elemPtr);
+	void getBaseRotationPosition(int32 x, int32 y, int32 z);
+	void getCameraAnglePositions(int32 x, int32 y, int32 z);
+	void applyRotation(int32 *tempMatrix, const int32 *currentMatrix);
+	void applyPointsRotation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *rotationMatrix);
+	void processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr);
+	void applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *translationMatrix);
+	void processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr);
 	void translateGroup(int16 ax, int16 bx, int16 cx);
 
 	// ---- variables ----
@@ -166,11 +166,11 @@ private:
 
 	int32 numOfPoints = 0;
 	int32 numOfElements = 0;
-	uint8 *pointsPtr = nullptr;
+	const uint8 *pointsPtr = nullptr;
 	uint8 *elementsPtr = nullptr;
 	uint8 *elementsPtr2 = nullptr;
 
-	uint8 *pri2Ptr2 = nullptr;
+	const uint8 *pri2Ptr2 = nullptr;
 
 	int32 matricesTable[271] {0};
 	uint8 *currentMatrixTableEntry = nullptr;
@@ -187,7 +187,7 @@ private:
 
 	int16 primitiveCounter = 0;
 	renderTabEntry *renderTabEntryPtr = nullptr;
-	renderTabEntry *renderTabEntryPtr2 = nullptr;
+	const renderTabEntry *renderTabEntryPtr2 = nullptr;
 	renderTabEntry *renderTabSortedPtr = nullptr;
 
 	renderTabEntry renderTab[1000];
@@ -198,7 +198,7 @@ private:
 
 	// render polygon vars
 	int16 pRenderV3[96] {0};
-	int16 *pRenderV2 = 0;
+	const int16 *pRenderV2 = 0;
 
 	int16 vleft = 0;
 	int16 vtop = 0;
@@ -249,13 +249,13 @@ public:
 	void prepareIsoModel(uint8 *bodyPtr); // loadGfxSub
 
 	int32 projectPositionOnScreen(int32 cX, int32 cY, int32 cZ);
-	void setCameraPosition(int32 X, int32 Y, int32 cX, int32 cY, int32 cZ);
+	void setCameraPosition(int32 x, int32 y, int32 cX, int32 cY, int32 cZ);
 	void setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ, int32 rotPosX, int32 rotPosY, int32 rotPosZ, int32 param6);
-	void setBaseTranslation(int32 X, int32 Y, int32 Z);
-	void setBaseRotation(int32 X, int32 Y, int32 Z);
-	void setOrthoProjection(int32 X, int32 Y, int32 Z);
+	void setBaseTranslation(int32 x, int32 y, int32 z);
+	void setBaseRotation(int32 x, int32 y, int32 z);
+	void setOrthoProjection(int32 x, int32 y, int32 z);
 
-	int32 renderIsoModel(int32 X, int32 Y, int32 Z, int32 angleX, int32 angleY, int32 angleZ, uint8 *bodyPtr);
+	int32 renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ, uint8 *bodyPtr);
 
 	void copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest);
 




More information about the Scummvm-git-logs mailing list