[Scummvm-git-logs] scummvm master -> 6f3248e1b9160d3643adee39314990353149df34
mgerhardy
martin.gerhardy at gmail.com
Sun Nov 22 22:16:21 UTC 2020
This automated email contains information about 16 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
825127676c TWINE: connect the opcode lHOLOMAP_TRAJ to drawHolomapTrajectory
297fe3a68c TWINE: added two new debug commands
e993e65989 TWINE: extracted into single methods
057712cdc3 TWINE: hide access to gameFlags array
672e68e3ee TWINE: add debug message for missing implementation
abe94d4316 TWINE: renamed some members of the Text class
d43f929af8 TWINE: replaced magic numbers
6bf64769ea TWINE: fixed missing textid in while condition
c1ec0a7627 TWINE: renamed Text class members and methods
0e8232bad4 TWINE: renamed more Text class members
cd019aa41e TWINE: removed unused var
d5174c2cf7 TWINE: renamed method
4e7e7e67dd TWINE: renamed Text class members
d30035ab50 TWINE: reduced scope
f88ab25d25 TWINE: const
6f3248e1b9 TWINE: reduced cyclic complexity
Commit: 825127676ccfea2b25e9019fe47f20c2b649d8a3
https://github.com/scummvm/scummvm/commit/825127676ccfea2b25e9019fe47f20c2b649d8a3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: connect the opcode lHOLOMAP_TRAJ to drawHolomapTrajectory
Changed paths:
engines/twine/script_life_v1.cpp
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 774a2ba897..0b0ba4dad9 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1651,8 +1651,8 @@ static int32 lANIM_SET(TwinEEngine *engine, LifeScriptContext &ctx) {
* @note Opcode @c 0x60
*/
static int32 lHOLOMAP_TRAJ(TwinEEngine *engine, LifeScriptContext &ctx) {
- ctx.stream.skip(1); // index of the holomap trajectory
- return -1;
+ engine->_holomap->drawHolomapTrajectory(ctx.stream.readByte());
+ return 0;
}
/**
Commit: 297fe3a68c1ba27a68659e3247cbe037eb07f651
https://github.com/scummvm/scummvm/commit/297fe3a68c1ba27a68659e3247cbe037eb07f651
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: added two new debug commands
Changed paths:
engines/twine/console.cpp
engines/twine/console.h
diff --git a/engines/twine/console.cpp b/engines/twine/console.cpp
index d9d4f35b68..56c747b8a7 100644
--- a/engines/twine/console.cpp
+++ b/engines/twine/console.cpp
@@ -40,6 +40,8 @@ TwinEConsole::TwinEConsole(TwinEEngine *engine) : _engine(engine), GUI::Debugger
registerCmd("toggle_freecamera", WRAP_METHOD(TwinEConsole, doToggleFreeCamera));
registerCmd("toggle_scenechanges", WRAP_METHOD(TwinEConsole, doToggleSceneChanges));
registerCmd("scene_actor", WRAP_METHOD(TwinEConsole, doSkipSceneActorsBut));
+ registerCmd("game_flag", WRAP_METHOD(TwinEConsole, doSetGameFlag));
+ registerCmd("inventory_flag", WRAP_METHOD(TwinEConsole, doSetInventoryFlag));
}
TwinEConsole::~TwinEConsole() {
@@ -59,9 +61,6 @@ TwinEConsole::~TwinEConsole() {
bool TwinEConsole::doToggleZoneRendering(int argc, const char **argv) {
TOGGLE_DEBUG(_engine->_debugScene->showingZones, "zone rendering")
- if (argc == 1) {
- // TODO: support typeZones
- }
return true;
}
@@ -86,6 +85,36 @@ bool TwinEConsole::doToggleSceneChanges(int argc, const char **argv) {
return true;
}
+bool TwinEConsole::doSetInventoryFlag(int argc, const char **argv) {
+ if (argc <= 1) {
+ warning("Expected to get a inventory flag index as first parameter");
+ return false;
+ }
+
+ const uint8 idx = atoi(argv[1]);
+ if (idx >= NUM_INVENTORY_ITEMS) {
+ warning("given index exceeds the max allowed value of %i", NUM_INVENTORY_ITEMS - 1);
+ return false;
+ }
+ const uint8 val = argc == 3 ? atoi(argv[2]) : 0;
+ _engine->_gameState->inventoryFlags[idx] = val;
+
+ return true;
+}
+
+bool TwinEConsole::doSetGameFlag(int argc, const char **argv) {
+ if (argc <= 1) {
+ warning("Expected to get a game flag index as first parameter");
+ return false;
+ }
+
+ const uint8 idx = atoi(argv[1]);
+ const uint8 val = argc == 3 ? atoi(argv[2]) : 0;
+ _engine->_gameState->gameFlags[idx] = val;
+
+ return true;
+}
+
bool TwinEConsole::doGiveKey(int argc, const char **argv) {
int amount = 1;
if (argc >= 1) {
diff --git a/engines/twine/console.h b/engines/twine/console.h
index 4b41171e5a..cef999df20 100644
--- a/engines/twine/console.h
+++ b/engines/twine/console.h
@@ -43,6 +43,8 @@ private:
bool doToggleFreeCamera(int argc, const char **argv);
bool doToggleSceneChanges(int argc, const char **argv);
bool doSkipSceneActorsBut(int argc, const char **argv);
+ bool doSetGameFlag(int argc, const char **argv);
+ bool doSetInventoryFlag(int argc, const char **argv);
public:
TwinEConsole(TwinEEngine *engine);
~TwinEConsole() override;
Commit: e993e659897e12153d09d1f4716c825e7df15c12
https://github.com/scummvm/scummvm/commit/e993e659897e12153d09d1f4716c825e7df15c12
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: extracted into single methods
Changed paths:
engines/twine/holomap.h
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index 00d8abe270..60bdfd0776 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -32,6 +32,11 @@ namespace TwinE {
class TwinEEngine;
+/**
+ * The Holomap shows the hero position. The arrows (@c RESSHQR_HOLOARROWMDL) represent important places in your quest - they automatically disappear once that part of
+ * the quest is done (@c clearHolomapPosition()). You can rotate the holoamp by pressing ctrl+cursor keys - but only using the cursor keys, you can scroll through the
+ * text for the visible arrows.
+ */
class Holomap {
private:
TwinEEngine *_engine;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index ee6b842f40..85ecaa7898 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -429,6 +429,149 @@ void TwinEEngine::processActorSamplePosition(int32 actorIdx) {
_sound->setSamplePosition(channelIdx, actor->x, actor->y, actor->z);
}
+void TwinEEngine::processInventoryAction() {
+ ScopedEngineFreeze scoped(this);
+ _menu->processInventoryMenu();
+
+ switch (loopInventoryItem) {
+ case kiHolomap:
+ _holomap->processHolomap();
+ _screens->lockPalette = true;
+ warning("Use inventory [kiHolomap] not implemented!");
+ break;
+ case kiMagicBall:
+ if (_gameState->usingSabre) {
+ _actor->initModelActor(0, OWN_ACTOR_SCENE_INDEX);
+ }
+ _gameState->usingSabre = false;
+ break;
+ case kiUseSabre:
+ if (_scene->sceneHero->body != InventoryItems::kiUseSabre) {
+ if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
+ _actor->setBehaviour(HeroBehaviourType::kNormal);
+ }
+ _actor->initModelActor(InventoryItems::kiUseSabre, OWN_ACTOR_SCENE_INDEX);
+ _animations->initAnim(AnimationTypes::kSabreUnknown, 1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
+
+ _gameState->usingSabre = true;
+ }
+ break;
+ case kiBookOfBu: {
+ _screens->fadeToBlack(_screens->paletteRGBA);
+ _screens->loadImage(RESSHQR_INTROSCREEN1IMG);
+ _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
+ _text->newGameVar4 = 0;
+ _text->textClipFull();
+ _text->setFontCrossColor(15);
+ const bool tmpFlagDisplayText = cfgfile.FlagDisplayText;
+ cfgfile.FlagDisplayText = true;
+ _text->drawTextFullscreen(161);
+ cfgfile.FlagDisplayText = tmpFlagDisplayText;
+ _text->textClipSmall();
+ _text->newGameVar4 = 1;
+ _text->initTextBank(_scene->sceneTextBank + 3);
+ _screens->fadeToBlack(_screens->paletteRGBACustom);
+ _screens->clearScreen();
+ flip();
+ setPalette(_screens->paletteRGBA);
+ _screens->lockPalette = true;
+ break;
+ }
+ case kiProtoPack:
+ if (_gameState->gameFlags[InventoryItems::kiBookOfBu]) {
+ _scene->sceneHero->body = 0;
+ } else {
+ _scene->sceneHero->body = 1;
+ }
+
+ if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
+ _actor->setBehaviour(HeroBehaviourType::kNormal);
+ } else {
+ _actor->setBehaviour(HeroBehaviourType::kProtoPack);
+ }
+ break;
+ case kiPinguin: {
+ ActorStruct *pinguin = _scene->getActor(_scene->mecaPinguinIdx);
+
+ pinguin->x = _renderer->destX + _scene->sceneHero->x;
+ pinguin->y = _scene->sceneHero->y;
+ pinguin->z = _renderer->destZ + _scene->sceneHero->z;
+ pinguin->angle = _scene->sceneHero->angle;
+
+ _movements->rotateActor(0, 800, pinguin->angle);
+
+ if (!_collision->checkCollisionWithActors(_scene->mecaPinguinIdx)) {
+ pinguin->life = 50;
+ pinguin->body = -1;
+ _actor->initModelActor(0, _scene->mecaPinguinIdx);
+ pinguin->dynamicFlags.bIsDead = 0; // &= 0xDF
+ pinguin->setBrickShape(ShapeType::kNone);
+ _movements->moveActor(pinguin->angle, pinguin->angle, pinguin->speed, &pinguin->move);
+ _gameState->gameFlags[InventoryItems::kiPinguin] = 0; // byte_50D89 = 0;
+ pinguin->delayInMillis = lbaTime + 1500;
+ }
+ break;
+ }
+ case kiBonusList: {
+ unfreezeTime();
+ _redraw->redrawEngineActions(1);
+ freezeTime();
+ _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
+ _text->textClipFull();
+ _text->setFontCrossColor(15);
+ _text->drawTextFullscreen(162);
+ _text->textClipSmall();
+ _text->initTextBank(_scene->sceneTextBank + 3);
+ break;
+ }
+ case kiCloverLeaf:
+ if (_scene->sceneHero->life < 50) {
+ if (_gameState->inventoryNumLeafs > 0) {
+ _scene->sceneHero->life = 50;
+ _gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
+ _gameState->inventoryNumLeafs--;
+ _redraw->addOverlay(koInventoryItem, 27, 0, 0, 0, koNormal, 3);
+ }
+ }
+ break;
+ }
+
+ _redraw->redrawEngineActions(1);
+}
+
+void TwinEEngine::processOptionsMenu() {
+ ScopedEngineFreeze scoped(this);
+ _sound->pauseSamples();
+ _menu->inGameOptionsMenu();
+ // TODO: play music
+ _sound->resumeSamples();
+ _redraw->redrawEngineActions(1);
+}
+
+void TwinEEngine::centerScreenOnActor() {
+ if (!disableScreenRecenter && !_debugGrid->useFreeCamera) {
+ ActorStruct *actor = _scene->getActor(_scene->currentlyFollowedActor);
+ _renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX << 9),
+ actor->y - (_grid->newCameraY << 8),
+ actor->z - (_grid->newCameraZ << 9));
+ if (_renderer->projPosX < 80 || _renderer->projPosX >= SCREEN_WIDTH - 60 || _renderer->projPosY < 80 || _renderer->projPosY >= SCREEN_HEIGHT - 50) {
+ _grid->newCameraX = ((actor->x + 0x100) >> 9) + (((actor->x + 0x100) >> 9) - _grid->newCameraX) / 2;
+ _grid->newCameraY = actor->y >> 8;
+ _grid->newCameraZ = ((actor->z + 0x100) >> 9) + (((actor->z + 0x100) >> 9) - _grid->newCameraZ) / 2;
+
+ if (_grid->newCameraX >= 64) {
+ _grid->newCameraX = 63;
+ }
+
+ if (_grid->newCameraZ >= 64) {
+ _grid->newCameraZ = 63;
+ }
+
+ _redraw->reqBgRedraw = true;
+ }
+ }
+}
+
int32 TwinEEngine::runGameEngine() { // mainLoopInteration
_input->enableKeyMap(mainKeyMapId);
@@ -468,125 +611,13 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
}
if (_input->toggleActionIfActive(TwinEActionType::OptionsMenu)) {
- freezeTime();
- _sound->pauseSamples();
- _menu->inGameOptionsMenu();
- // TODO: play music
- _sound->resumeSamples();
- unfreezeTime();
- _redraw->redrawEngineActions(1);
+ processOptionsMenu();
}
// inventory menu
loopInventoryItem = -1;
if (_input->isActionActive(TwinEActionType::InventoryMenu) && _scene->sceneHero->entity != -1 && _scene->sceneHero->controlMode == ControlMode::kManual) {
- freezeTime();
- _menu->processInventoryMenu();
-
- switch (loopInventoryItem) {
- case kiHolomap:
- _holomap->processHolomap();
- _screens->lockPalette = true;
- warning("Use inventory [kiHolomap] not implemented!");
- break;
- case kiMagicBall:
- if (_gameState->usingSabre) {
- _actor->initModelActor(0, OWN_ACTOR_SCENE_INDEX);
- }
- _gameState->usingSabre = false;
- break;
- case kiUseSabre:
- if (_scene->sceneHero->body != InventoryItems::kiUseSabre) {
- if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
- _actor->setBehaviour(HeroBehaviourType::kNormal);
- }
- _actor->initModelActor(InventoryItems::kiUseSabre, OWN_ACTOR_SCENE_INDEX);
- _animations->initAnim(AnimationTypes::kSabreUnknown, 1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
-
- _gameState->usingSabre = true;
- }
- break;
- case kiBookOfBu: {
- _screens->fadeToBlack(_screens->paletteRGBA);
- _screens->loadImage(RESSHQR_INTROSCREEN1IMG);
- _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
- _text->newGameVar4 = 0;
- _text->textClipFull();
- _text->setFontCrossColor(15);
- const bool tmpFlagDisplayText = cfgfile.FlagDisplayText;
- cfgfile.FlagDisplayText = true;
- _text->drawTextFullscreen(161);
- cfgfile.FlagDisplayText = tmpFlagDisplayText;
- _text->textClipSmall();
- _text->newGameVar4 = 1;
- _text->initTextBank(_scene->sceneTextBank + 3);
- _screens->fadeToBlack(_screens->paletteRGBACustom);
- _screens->clearScreen();
- flip();
- setPalette(_screens->paletteRGBA);
- _screens->lockPalette = true;
- } break;
- case kiProtoPack:
- if (_gameState->gameFlags[InventoryItems::kiBookOfBu]) {
- _scene->sceneHero->body = 0;
- } else {
- _scene->sceneHero->body = 1;
- }
-
- if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
- _actor->setBehaviour(HeroBehaviourType::kNormal);
- } else {
- _actor->setBehaviour(HeroBehaviourType::kProtoPack);
- }
- break;
- case kiPinguin: {
- ActorStruct *pinguin = _scene->getActor(_scene->mecaPinguinIdx);
-
- pinguin->x = _renderer->destX + _scene->sceneHero->x;
- pinguin->y = _scene->sceneHero->y;
- pinguin->z = _renderer->destZ + _scene->sceneHero->z;
- pinguin->angle = _scene->sceneHero->angle;
-
- _movements->rotateActor(0, 800, pinguin->angle);
-
- if (!_collision->checkCollisionWithActors(_scene->mecaPinguinIdx)) {
- pinguin->life = 50;
- pinguin->body = -1;
- _actor->initModelActor(0, _scene->mecaPinguinIdx);
- pinguin->dynamicFlags.bIsDead = 0; // &= 0xDF
- pinguin->setBrickShape(ShapeType::kNone);
- _movements->moveActor(pinguin->angle, pinguin->angle, pinguin->speed, &pinguin->move);
- _gameState->gameFlags[InventoryItems::kiPinguin] = 0; // byte_50D89 = 0;
- pinguin->delayInMillis = lbaTime + 1500;
- }
- break;
- }
- case kiBonusList: {
- unfreezeTime();
- _redraw->redrawEngineActions(1);
- freezeTime();
- _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
- _text->textClipFull();
- _text->setFontCrossColor(15);
- _text->drawTextFullscreen(162);
- _text->textClipSmall();
- _text->initTextBank(_scene->sceneTextBank + 3);
- break;
- }
- case kiCloverLeaf:
- if (_scene->sceneHero->life < 50) {
- if (_gameState->inventoryNumLeafs > 0) {
- _scene->sceneHero->life = 50;
- _gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
- _gameState->inventoryNumLeafs--;
- _redraw->addOverlay(koInventoryItem, 27, 0, 0, 0, koNormal, 3);
- }
- }
- break;
- }
-
- unfreezeTime();
- _redraw->redrawEngineActions(1);
+ processInventoryAction();
}
// Process behaviour menu
@@ -683,164 +714,145 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
for (int32 a = 0; a < _scene->sceneNumActors; a++) {
ActorStruct *actor = _scene->getActor(a);
- if (!actor->dynamicFlags.bIsDead) {
- if (actor->life == 0) {
- if (IS_HERO(a)) {
- _animations->initAnim(AnimationTypes::kLandDeath, 4, AnimationTypes::kStanding, 0);
- actor->controlMode = ControlMode::kNoMove;
- } else {
- _sound->playSample(Samples::Explode, getRandomNumber(2000) + 3096, 1, actor->x, actor->y, actor->z, a);
+ if (actor->dynamicFlags.bIsDead) {
+ continue;
+ }
- if (a == _scene->mecaPinguinIdx) {
- _extra->addExtraExplode(actor->x, actor->y, actor->z);
- }
- }
+ if (actor->life == 0) {
+ if (IS_HERO(a)) {
+ _animations->initAnim(AnimationTypes::kLandDeath, 4, AnimationTypes::kStanding, 0);
+ actor->controlMode = ControlMode::kNoMove;
+ } else {
+ _sound->playSample(Samples::Explode, getRandomNumber(2000) + 3096, 1, actor->x, actor->y, actor->z, a);
- if (!actor->bonusParameter.unk1 && (actor->bonusParameter.cloverleaf || actor->bonusParameter.kashes || actor->bonusParameter.key || actor->bonusParameter.lifepoints || actor->bonusParameter.magicpoints)) {
- _actor->processActorExtraBonus(a);
+ if (a == _scene->mecaPinguinIdx) {
+ _extra->addExtraExplode(actor->x, actor->y, actor->z);
}
}
- _movements->processActorMovements(a);
+ if (!actor->bonusParameter.unk1 && (actor->bonusParameter.cloverleaf || actor->bonusParameter.kashes || actor->bonusParameter.key || actor->bonusParameter.lifepoints || actor->bonusParameter.magicpoints)) {
+ _actor->processActorExtraBonus(a);
+ }
+ }
- actor->collisionX = actor->x;
- actor->collisionY = actor->y;
- actor->collisionZ = actor->z;
+ _movements->processActorMovements(a);
- if (actor->positionInMoveScript != -1) {
- _scriptMove->processMoveScript(a);
- }
+ actor->collisionX = actor->x;
+ actor->collisionY = actor->y;
+ actor->collisionZ = actor->z;
- _animations->processActorAnimations(a);
+ if (actor->positionInMoveScript != -1) {
+ _scriptMove->processMoveScript(a);
+ }
- if (actor->staticFlags.bIsZonable) {
- _scene->processActorZones(a);
- }
+ _animations->processActorAnimations(a);
- if (actor->positionInLifeScript != -1) {
- _scriptLife->processLifeScript(a);
- }
+ if (actor->staticFlags.bIsZonable) {
+ _scene->processActorZones(a);
+ }
- processActorSamplePosition(a);
+ if (actor->positionInLifeScript != -1) {
+ _scriptLife->processLifeScript(a);
+ }
- if (quitGame != -1) {
- return quitGame;
- }
+ processActorSamplePosition(a);
+
+ if (quitGame != -1) {
+ return quitGame;
+ }
+
+ if (actor->staticFlags.bCanDrown) {
+ int32 brickSound = _grid->getBrickSoundType(actor->x, actor->y - 1, actor->z);
+ actor->brickSound = brickSound;
- if (actor->staticFlags.bCanDrown) {
- int32 brickSound = _grid->getBrickSoundType(actor->x, actor->y - 1, actor->z);
- actor->brickSound = brickSound;
-
- if ((brickSound & 0xF0) == 0xF0) {
- if ((brickSound & 0x0F) == 1) {
- if (IS_HERO(a)) {
- if (_actor->heroBehaviour != HeroBehaviourType::kProtoPack || actor->anim != AnimationTypes::kForward) {
- if (!_actor->cropBottomScreen) {
- _animations->initAnim(AnimationTypes::kDrawn, 4, AnimationTypes::kStanding, 0);
- _renderer->projectPositionOnScreen(actor->x - _grid->cameraX, actor->y - _grid->cameraY, actor->z - _grid->cameraZ);
- _actor->cropBottomScreen = _renderer->projPosY;
- }
+ if ((brickSound & 0xF0) == 0xF0) {
+ if ((brickSound & 0x0F) == 1) {
+ if (IS_HERO(a)) {
+ if (_actor->heroBehaviour != HeroBehaviourType::kProtoPack || actor->anim != AnimationTypes::kForward) {
+ if (!_actor->cropBottomScreen) {
+ _animations->initAnim(AnimationTypes::kDrawn, 4, AnimationTypes::kStanding, 0);
_renderer->projectPositionOnScreen(actor->x - _grid->cameraX, actor->y - _grid->cameraY, actor->z - _grid->cameraZ);
- actor->controlMode = ControlMode::kNoMove;
- actor->life = -1;
_actor->cropBottomScreen = _renderer->projPosY;
- actor->staticFlags.bCanDrown |= 0x10; // TODO: doesn't make sense
}
- } else {
- const int32 rnd = getRandomNumber(2000) + 3096;
- _sound->playSample(Samples::Explode, rnd, 1, actor->x, actor->y, actor->z, a);
- if (actor->bonusParameter.cloverleaf || actor->bonusParameter.kashes || actor->bonusParameter.key || actor->bonusParameter.lifepoints || actor->bonusParameter.magicpoints) {
- if (!actor->bonusParameter.unk1) {
- _actor->processActorExtraBonus(a);
- }
- actor->life = 0;
+ _renderer->projectPositionOnScreen(actor->x - _grid->cameraX, actor->y - _grid->cameraY, actor->z - _grid->cameraZ);
+ actor->controlMode = ControlMode::kNoMove;
+ actor->life = -1;
+ _actor->cropBottomScreen = _renderer->projPosY;
+ actor->staticFlags.bCanDrown |= 0x10; // TODO: doesn't make sense
+ }
+ } else {
+ const int32 rnd = getRandomNumber(2000) + 3096;
+ _sound->playSample(Samples::Explode, rnd, 1, actor->x, actor->y, actor->z, a);
+ if (actor->bonusParameter.cloverleaf || actor->bonusParameter.kashes || actor->bonusParameter.key || actor->bonusParameter.lifepoints || actor->bonusParameter.magicpoints) {
+ if (!actor->bonusParameter.unk1) {
+ _actor->processActorExtraBonus(a);
}
+ actor->life = 0;
}
}
}
}
+ }
- if (actor->life <= 0) {
- if (IS_HERO(a)) {
- if (actor->dynamicFlags.bAnimEnded) {
- if (_gameState->inventoryNumLeafs > 0) { // use clover leaf automaticaly
- _scene->sceneHero->x = _scene->newHeroX;
- _scene->sceneHero->y = _scene->newHeroY;
- _scene->sceneHero->z = _scene->newHeroZ;
-
- _scene->needChangeScene = _scene->currentSceneIdx;
- _gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
-
- _grid->newCameraX = (_scene->sceneHero->x >> 9);
- _grid->newCameraY = (_scene->sceneHero->y >> 8);
- _grid->newCameraZ = (_scene->sceneHero->z >> 9);
-
- _scene->heroPositionType = ScenePositionType::kReborn;
-
- _scene->sceneHero->life = 50;
- _redraw->reqBgRedraw = true;
- _screens->lockPalette = true;
- _gameState->inventoryNumLeafs--;
- _actor->cropBottomScreen = 0;
- } else { // game over
- _gameState->inventoryNumLeafsBox = 2;
- _gameState->inventoryNumLeafs = 1;
- _gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
- _actor->heroBehaviour = _actor->previousHeroBehaviour;
- actor->angle = _actor->previousHeroAngle;
- actor->life = 50;
-
- if (_scene->previousSceneIdx != _scene->currentSceneIdx) {
- _scene->newHeroX = -1;
- _scene->newHeroY = -1;
- _scene->newHeroZ = -1;
- _scene->currentSceneIdx = _scene->previousSceneIdx;
- _scene->stopRunningGame();
- }
+ if (actor->life <= 0) {
+ if (IS_HERO(a)) {
+ if (actor->dynamicFlags.bAnimEnded) {
+ if (_gameState->inventoryNumLeafs > 0) { // use clover leaf automaticaly
+ _scene->sceneHero->x = _scene->newHeroX;
+ _scene->sceneHero->y = _scene->newHeroY;
+ _scene->sceneHero->z = _scene->newHeroZ;
- autoSave();
- _gameState->processGameoverAnimation();
- quitGame = 0;
- return 0;
- }
- }
- } else {
- _actor->processActorCarrier(a);
- actor->dynamicFlags.bIsDead = 1;
- actor->entity = -1;
- actor->zone = -1;
- }
- }
+ _scene->needChangeScene = _scene->currentSceneIdx;
+ _gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
- if (_scene->needChangeScene != -1) {
- return 0;
- }
- }
- }
+ _grid->newCameraX = (_scene->sceneHero->x >> 9);
+ _grid->newCameraY = (_scene->sceneHero->y >> 8);
+ _grid->newCameraZ = (_scene->sceneHero->z >> 9);
- // recenter screen automatically
- if (!disableScreenRecenter && !_debugGrid->useFreeCamera) {
- ActorStruct *actor = _scene->getActor(_scene->currentlyFollowedActor);
- _renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX << 9),
- actor->y - (_grid->newCameraY << 8),
- actor->z - (_grid->newCameraZ << 9));
- if (_renderer->projPosX < 80 || _renderer->projPosX >= SCREEN_WIDTH - 60 || _renderer->projPosY < 80 || _renderer->projPosY >= SCREEN_HEIGHT - 50) {
- _grid->newCameraX = ((actor->x + 0x100) >> 9) + (((actor->x + 0x100) >> 9) - _grid->newCameraX) / 2;
- _grid->newCameraY = actor->y >> 8;
- _grid->newCameraZ = ((actor->z + 0x100) >> 9) + (((actor->z + 0x100) >> 9) - _grid->newCameraZ) / 2;
+ _scene->heroPositionType = ScenePositionType::kReborn;
- if (_grid->newCameraX >= 64) {
- _grid->newCameraX = 63;
- }
+ _scene->sceneHero->life = 50;
+ _redraw->reqBgRedraw = true;
+ _screens->lockPalette = true;
+ _gameState->inventoryNumLeafs--;
+ _actor->cropBottomScreen = 0;
+ } else { // game over
+ _gameState->inventoryNumLeafsBox = 2;
+ _gameState->inventoryNumLeafs = 1;
+ _gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
+ _actor->heroBehaviour = _actor->previousHeroBehaviour;
+ actor->angle = _actor->previousHeroAngle;
+ actor->life = 50;
+
+ if (_scene->previousSceneIdx != _scene->currentSceneIdx) {
+ _scene->newHeroX = -1;
+ _scene->newHeroY = -1;
+ _scene->newHeroZ = -1;
+ _scene->currentSceneIdx = _scene->previousSceneIdx;
+ _scene->stopRunningGame();
+ }
- if (_grid->newCameraZ >= 64) {
- _grid->newCameraZ = 63;
+ autoSave();
+ _gameState->processGameoverAnimation();
+ quitGame = 0;
+ return 0;
+ }
+ }
+ } else {
+ _actor->processActorCarrier(a);
+ actor->dynamicFlags.bIsDead = 1;
+ actor->entity = -1;
+ actor->zone = -1;
}
+ }
- _redraw->reqBgRedraw = true;
+ if (_scene->needChangeScene != -1) {
+ return 0;
}
}
+ centerScreenOnActor();
+
_redraw->redrawEngineActions(_redraw->reqBgRedraw);
// workaround to fix hero redraw after drowning
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 92795b52e4..af98f28399 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -170,6 +170,11 @@ private:
TwineGameType _gameType;
EngineState _state = EngineState::Menu;
+ void processInventoryAction();
+ void processOptionsMenu();
+ /** recenter screen on followed actor automatically */
+ void centerScreenOnActor();
+
public:
TwinEEngine(OSystem *system, Common::Language language, uint32 flagsTwineGameType, TwineGameType gameType);
~TwinEEngine() override;
Commit: 057712cdc32b361b33cacc705874f0d9311331c2
https://github.com/scummvm/scummvm/commit/057712cdc32b361b33cacc705874f0d9311331c2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: hide access to gameFlags array
Changed paths:
engines/twine/gamestate.h
engines/twine/menu.cpp
engines/twine/movements.cpp
engines/twine/scene.cpp
engines/twine/script_life_v1.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/gamestate.h b/engines/twine/gamestate.h
index e3ec8593a1..dd4d22cbf3 100644
--- a/engines/twine/gamestate.h
+++ b/engines/twine/gamestate.h
@@ -92,6 +92,30 @@ private:
public:
GameState(TwinEEngine *engine);
+ inline bool inventoryDisabled() const {
+ return gameFlags[GAMEFLAG_INVENTORY_DISABLED] != 0;
+ }
+
+ inline bool hasOpenedFunfrocksSafe() const {
+ return gameFlags[30] != 0;
+ }
+
+ inline bool hasItem(InventoryItems item) const {
+ return gameFlags[item] != 0;
+ }
+
+ inline void giveItem(InventoryItems item) {
+ gameFlags[item] = 1;
+ }
+
+ inline void removeItem(InventoryItems item) {
+ gameFlags[item] = 0;
+ }
+
+ inline void setFlag(uint8 index, uint8 value) {
+ gameFlags[index] = value;
+ }
+
/**
* LBA engine game flags to save quest states
*
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 80738716d6..2bfad83ce4 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -758,7 +758,7 @@ void Menu::drawInfoMenu(int16 left, int16 top) {
_engine->_interface->drawSplittedBox(newBoxLeft, boxTop, boxLeft, boxBottom, 91);
drawBox(left + 25, top + 10, left + 324, top + 10 + 14);
- if (!_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] && _engine->_gameState->gameFlags[InventoryItems::kiTunic]) {
+ if (!_engine->_gameState->inventoryDisabled() && _engine->_gameState->hasItem(InventoryItems::kiTunic)) {
_engine->_grid->drawSprite(0, newBoxLeft2, top + 36, _engine->_resources->spriteTable[SPRITEHQR_MAGICPOINTS]);
if (_engine->_gameState->magicLevelIdx > 0) {
_engine->_interface->drawSplittedBox(newBoxLeft, top + 35, _engine->_screens->crossDot(newBoxLeft, boxRight, 80, _engine->_gameState->inventoryMagicPoints), top + 50, 75);
@@ -957,7 +957,7 @@ void Menu::drawItem(int32 item) {
_engine->_interface->drawSplittedBox(left, top, right, bottom,
inventorySelectedItem == item ? inventorySelectedColor : 0);
- if (_engine->_gameState->gameFlags[item] && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] && item < NUM_INVENTORY_ITEMS) {
+ if (item < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)item) && !_engine->_gameState->inventoryDisabled()) {
_engine->_renderer->prepareIsoModel(_engine->_resources->inventoryTable[item]);
itemAngle[item] += 8;
_engine->_renderer->renderInventoryItem(itemX, itemY, _engine->_resources->inventoryTable[item], itemAngle[item], 15000);
@@ -995,9 +995,9 @@ void Menu::processInventoryMenu() {
inventorySelectedColor = 68;
if (_engine->_gameState->inventoryNumLeafs > 0) {
- _engine->_gameState->gameFlags[InventoryItems::kiCloverLeaf] = 1;
+ _engine->_gameState->giveItem(InventoryItems::kiCloverLeaf);
// TODO: shouldn't this get reset? } else {
- // _engine->_gameState->gameFlags[InventoryItems::kiCloverLeaf] = 0;
+ // _engine->_gameState->removeItem(InventoryItems::kiCloverLeaf);
}
drawInventoryItems();
@@ -1059,7 +1059,7 @@ void Menu::processInventoryMenu() {
if (bx == 3) {
_engine->_text->initInventoryDialogueBox();
- if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
+ if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)inventorySelectedItem) && !_engine->_gameState->inventoryDisabled()) {
_engine->_text->initText(inventorySelectedItem + 100);
} else {
_engine->_text->initText(128);
@@ -1081,7 +1081,7 @@ void Menu::processInventoryMenu() {
_engine->_text->initInventoryDialogueBox();
bx = 0;
} else {
- if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
+ if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)inventorySelectedItem) && !_engine->_gameState->inventoryDisabled()) {
_engine->_text->initInventoryDialogueBox();
_engine->_text->initText(inventorySelectedItem + 100);
}
@@ -1090,7 +1090,7 @@ void Menu::processInventoryMenu() {
drawItem(inventorySelectedItem);
- if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_input->toggleActionIfActive(TwinEActionType::UIEnter) && _engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
+ if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_input->toggleActionIfActive(TwinEActionType::UIEnter) && _engine->_gameState->hasItem((InventoryItems)inventorySelectedItem) && !_engine->_gameState->inventoryDisabled()) {
_engine->loopInventoryItem = inventorySelectedItem;
inventorySelectedColor = 91;
drawItem(inventorySelectedItem);
diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index 0aa18e4d84..8067a71fff 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -308,7 +308,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
bool Movements::processAttackExecution(int actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
if (!_engine->_gameState->usingSabre) { // Use Magic Ball
- if (_engine->_gameState->gameFlags[InventoryItems::kiMagicBall]) {
+ if (_engine->_gameState->hasItem(InventoryItems::kiMagicBall)) {
if (_engine->_gameState->magicBallIdx == -1) {
_engine->_animations->initAnim(AnimationTypes::kThrowBall, 1, AnimationTypes::kStanding, actorIdx);
}
@@ -316,7 +316,7 @@ bool Movements::processAttackExecution(int actorIdx) {
actor->angle = getRealAngle(&actor->move);
return true;
}
- } else if (_engine->_gameState->gameFlags[InventoryItems::kiUseSabre]) {
+ } else if (_engine->_gameState->hasItem(InventoryItems::kiUseSabre)) {
if (actor->body != InventoryItems::kiUseSabre) {
_engine->_actor->initModelActor(InventoryItems::kiUseSabre, actorIdx);
}
@@ -395,7 +395,7 @@ void Movements::processManualAction(int actorIdx) {
}
}
- if (_engine->_input->isActionActive(TwinEActionType::ThrowMagicBall) && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
+ if (_engine->_input->isActionActive(TwinEActionType::ThrowMagicBall) && !_engine->_gameState->inventoryDisabled()) {
if (processAttackExecution(actorIdx)) {
heroMoved = true;
}
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 865a14bb00..050b38376e 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -290,7 +290,7 @@ void Scene::resetScene() {
void Scene::changeScene() {
// change twinsen house destroyed hard-coded
- if (needChangeScene == LBA1SceneId::Citadel_Island_near_twinsens_house && _engine->_gameState->gameFlags[30] != 0) {
+ if (needChangeScene == LBA1SceneId::Citadel_Island_near_twinsens_house && _engine->_gameState->hasOpenedFunfrocksSafe()) {
needChangeScene = LBA1SceneId::Citadel_Island_Twinsens_house_destroyed;
}
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 0b0ba4dad9..26c1edfa80 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -261,12 +261,12 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
break;
case kcFLAG_GAME: {
int32 flagIdx = ctx.stream.readByte();
- if (!engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] ||
- (engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] && flagIdx >= MaxInventoryItems)) {
+ if (!engine->_gameState->inventoryDisabled() ||
+ (engine->_gameState->inventoryDisabled() && flagIdx >= MaxInventoryItems)) {
engine->_scene->currentScriptValue = engine->_gameState->gameFlags[flagIdx];
} else {
if (flagIdx == GAMEFLAG_INVENTORY_DISABLED) {
- engine->_scene->currentScriptValue = engine->_gameState->gameFlags[flagIdx];
+ engine->_scene->currentScriptValue = engine->_gameState->inventoryDisabled();
} else {
engine->_scene->currentScriptValue = 0;
}
@@ -322,11 +322,11 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
case kcUSE_INVENTORY: {
int32 item = ctx.stream.readByte();
- if (!engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
+ if (!engine->_gameState->inventoryDisabled()) {
if (item == engine->loopInventoryItem) {
engine->_scene->currentScriptValue = 1;
} else {
- if (engine->_gameState->inventoryFlags[item] == 1 && engine->_gameState->gameFlags[item] == 1) {
+ if (engine->_gameState->inventoryFlags[item] == 1 && engine->_gameState->hasItem((InventoryItems)item)) {
engine->_scene->currentScriptValue = 1;
} else {
engine->_scene->currentScriptValue = 0;
@@ -786,11 +786,9 @@ static int32 lEND_COMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx) {
* @note Opcode @c 0x24
*/
static int32 lSET_FLAG_GAME(TwinEEngine *engine, LifeScriptContext &ctx) {
- const int32 flagIdx = ctx.stream.readByte();
- const int32 flagValue = ctx.stream.readByte();
-
- engine->_gameState->gameFlags[flagIdx] = flagValue;
-
+ const uint8 flagIdx = ctx.stream.readByte();
+ const uint8 flagValue = ctx.stream.readByte();
+ engine->_gameState->setFlag(flagIdx, flagValue);
return 0;
}
@@ -1332,7 +1330,7 @@ static int32 lINIT_PINGOUIN(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 location = ctx.stream.readByte();
engine->_holomap->setHolomapPosition(location);
- if (engine->_gameState->gameFlags[InventoryItems::kiHolomap]) {
+ if (engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
engine->_redraw->addOverlay(koInventoryItem, 0, 0, 0, 0, koNormal, 3);
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 85ecaa7898..692fee29cb 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -478,7 +478,7 @@ void TwinEEngine::processInventoryAction() {
break;
}
case kiProtoPack:
- if (_gameState->gameFlags[InventoryItems::kiBookOfBu]) {
+ if (_gameState->hasItem(InventoryItems::kiBookOfBu)) {
_scene->sceneHero->body = 0;
} else {
_scene->sceneHero->body = 1;
@@ -507,7 +507,7 @@ void TwinEEngine::processInventoryAction() {
pinguin->dynamicFlags.bIsDead = 0; // &= 0xDF
pinguin->setBrickShape(ShapeType::kNone);
_movements->moveActor(pinguin->angle, pinguin->angle, pinguin->speed, &pinguin->move);
- _gameState->gameFlags[InventoryItems::kiPinguin] = 0; // byte_50D89 = 0;
+ _gameState->removeItem(InventoryItems::kiPinguin); // byte_50D89 = 0;
pinguin->delayInMillis = lbaTime + 1500;
}
break;
@@ -643,8 +643,8 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
}
// use Proto-Pack
- if (_input->toggleActionIfActive(TwinEActionType::UseProtoPack) && _gameState->gameFlags[InventoryItems::kiProtoPack] == 1) {
- if (_gameState->gameFlags[InventoryItems::kiBookOfBu]) {
+ if (_input->toggleActionIfActive(TwinEActionType::UseProtoPack) && _gameState->hasItem(InventoryItems::kiProtoPack)) {
+ if (_gameState->hasItem(InventoryItems::kiBookOfBu)) {
_scene->sceneHero->body = 0;
} else {
_scene->sceneHero->body = 1;
@@ -667,7 +667,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
}
// Draw holomap
- if (_input->isActionActive(TwinEActionType::OpenHolomap) && _gameState->gameFlags[InventoryItems::kiHolomap] == 1 && !_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
+ if (_input->isActionActive(TwinEActionType::OpenHolomap) && _gameState->hasItem(InventoryItems::kiHolomap) && !_gameState->inventoryDisabled()) {
freezeTime();
//TestRestoreModeSVGA(1);
_holomap->processHolomap();
Commit: 672e68e3ee8c79a551995510b1b52e9fb2e9c119
https://github.com/scummvm/scummvm/commit/672e68e3ee8c79a551995510b1b52e9fb2e9c119
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: add debug message for missing implementation
Changed paths:
engines/twine/holomap.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index c7a4c7f39d..a5a927f600 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -138,6 +138,7 @@ void Holomap::drawHolomapTitle(int32 width, int32 height) {
}
void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
+ debug("Draw trajectory index %i", trajectoryIndex);
// TODO
}
Commit: abe94d43167e02b81ef397fb705b7af7c252044f
https://github.com/scummvm/scummvm/commit/abe94d43167e02b81ef397fb705b7af7c252044f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: renamed some members of the Text class
Changed paths:
engines/twine/holomap.cpp
engines/twine/menu.cpp
engines/twine/menuoptions.cpp
engines/twine/script_life_v1.cpp
engines/twine/text.cpp
engines/twine/text.h
engines/twine/twine.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index a5a927f600..4db487d2e9 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -166,7 +166,7 @@ void Holomap::processHolomap() {
// TODO
- _engine->_text->newGameVar4 = 1;
+ _engine->_text->drawTextBoxBackground = true;
_engine->_screens->fadeToBlack(_engine->_screens->paletteRGBA);
_engine->_scene->alphaLight = alphaLightTmp;
_engine->_scene->betaLight = betaLightTmp;
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 2bfad83ce4..434dafa6c8 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -1102,7 +1102,7 @@ void Menu::processInventoryMenu() {
keymapper->getKeymap(uiKeyMapId)->setEnabled(false);
- _engine->_text->printTextVar13 = 0;
+ _engine->_text->printTextVar13 = false;
_engine->_scene->alphaLight = tmpAlphaLight;
_engine->_scene->betaLight = tmpBetaLight;
diff --git a/engines/twine/menuoptions.cpp b/engines/twine/menuoptions.cpp
index ae6be2b430..d318bc1e32 100644
--- a/engines/twine/menuoptions.cpp
+++ b/engines/twine/menuoptions.cpp
@@ -57,8 +57,8 @@ void MenuOptions::newGame() {
// intro screen 1 - twinsun
_engine->_screens->loadImage(RESSHQR_INTROSCREEN1IMG);
- _engine->_text->newGameVar4 = 0;
- _engine->_text->newGameVar5 = 1;
+ _engine->_text->drawTextBoxBackground = false;
+ _engine->_text->renderTextTriangle = true;
_engine->_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
_engine->_text->textClipFull();
@@ -91,8 +91,8 @@ void MenuOptions::newGame() {
_engine->_screens->clearScreen();
_engine->flip();
- _engine->_text->newGameVar4 = 1;
- _engine->_text->newGameVar5 = 0;
+ _engine->_text->drawTextBoxBackground = true;
+ _engine->_text->renderTextTriangle = false;
// set main palette back
_engine->setPalette(_engine->_screens->paletteRGBA);
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 26c1edfa80..7a864062ae 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1611,11 +1611,11 @@ static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_screens->loadImage(25);
engine->_text->textClipFull();
engine->_text->setFontCrossColor(15);
- engine->_text->newGameVar4 = 0;
+ engine->_text->drawTextBoxBackground = false;
const bool tmpFlagDisplayText = engine->cfgfile.FlagDisplayText;
engine->cfgfile.FlagDisplayText = true;
engine->_text->drawTextFullscreen(6);
- engine->_text->newGameVar4 = 1;
+ engine->_text->drawTextBoxBackground = true;
engine->_text->textClipSmall();
engine->_screens->fadeToBlack(engine->_screens->paletteRGBACustom);
engine->_screens->clearScreen();
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 66da6a3068..aab287c589 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -285,7 +285,7 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
void Text::initDialogueBox() { // InitDialWindow
_engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
- if (newGameVar4 != 0) {
+ if (drawTextBoxBackground) {
_engine->_menu->drawBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
_engine->_interface->drawTransparentBox(dialTextBoxLeft + 1, dialTextBoxTop + 1, dialTextBoxRight - 1, dialTextBoxBottom - 1, 3);
}
@@ -304,14 +304,14 @@ void Text::initInventoryDialogueBox() { // SecondInitDialWindow
// TODO: refactor this code
void Text::initText(int32 index) {
if (!getText(index)) {
- printTextVar13 = 0;
+ printTextVar13 = false;
return;
}
printText8Ptr1 = buf1;
printText8Ptr2 = buf2;
- printTextVar13 = 1;
+ printTextVar13 = true;
printText8Var1 = 0;
buf1[0] = 0;
@@ -456,7 +456,7 @@ void Text::processTextLine() {
printText8Ptr2 = buf2;
}
-void Text::printText10Sub() {
+void Text::renderContinueReadingTriangle() {
const int32 right = dialTextBoxRight - 3;
const int32 left = dialTextBoxRight - 24;
const int32 top = dialTextBoxBottom - 24;
@@ -517,16 +517,16 @@ int32 Text::getCharHeight(uint8 chr) const {
// TODO: refactor this code
int Text::printText10() {
- if (printTextVar13 == 0) {
+ if (!printTextVar13) {
return 0;
}
if (*printText8Ptr2 == '\0') {
if (printText8Var5 != 0) {
- if (newGameVar5 != 0) {
- printText10Sub();
+ if (renderTextTriangle) {
+ renderContinueReadingTriangle();
}
- printTextVar13 = 0;
+ printTextVar13 = false;
return 0;
}
if (printText8Var6 != 0) {
@@ -575,7 +575,7 @@ int Text::printText10() {
TEXT_CurrentLetterX = dialTextBoxLeft + 8;
if (printText8Var6 == 1 && printText8Var5 == 0) {
- printText10Sub();
+ renderContinueReadingTriangle();
return 2;
}
@@ -629,7 +629,7 @@ bool Text::drawTextFullscreen(int32 index) {
}
hasHiddenVox = false;
- printTextVar13 = 0;
+ printTextVar13 = false;
if (printedText == 0) {
stopVox(currDialTextEntry);
@@ -809,7 +809,7 @@ void Text::drawAskQuestion(int32 index) {
hasHiddenVox = false;
voxHiddenIndex = 0;
- printTextVar13 = 0;
+ printTextVar13 = false;
}
} // namespace TwinE
diff --git a/engines/twine/text.h b/engines/twine/text.h
index ee0414beb8..6f8d6c8ebb 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -127,7 +127,7 @@ private:
WordSize getWordSize(const char *arg1, char *arg2);
void processTextLine();
// draw next page arrow polygon
- void printText10Sub();
+ void renderContinueReadingTriangle();
void printText10Sub2();
int32 getCharWidth(uint8 chr) const;
int32 getCharHeight(uint8 chr) const;
@@ -207,9 +207,10 @@ public:
~Text();
// TODO: refactor all this variables and related functions
- int32 printTextVar13 = 0;
- int32 newGameVar4 = 0;
- int32 newGameVar5 = 0;
+ bool printTextVar13 = false;
+ // renders a triangle if the next side of the text can get activated
+ bool renderTextTriangle = false;
+ bool drawTextBoxBackground = false;
bool hasHiddenVox = false; // printTextVar5
int32 voxHiddenIndex = 0;
// ---
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 692fee29cb..47c190026a 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -187,9 +187,9 @@ Common::Error TwinEEngine::run() {
if (_scene->newHeroX == -1) {
_scene->heroPositionType = ScenePositionType::kNoPosition;
}
- _text->newGameVar5 = 0;
+ _text->renderTextTriangle = false;
_text->textClipSmall();
- _text->newGameVar4 = 1;
+ _text->drawTextBoxBackground = true;
_state = EngineState::GameLoop;
break;
case EngineState::GameLoop:
@@ -460,7 +460,7 @@ void TwinEEngine::processInventoryAction() {
_screens->fadeToBlack(_screens->paletteRGBA);
_screens->loadImage(RESSHQR_INTROSCREEN1IMG);
_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
- _text->newGameVar4 = 0;
+ _text->drawTextBoxBackground = false;
_text->textClipFull();
_text->setFontCrossColor(15);
const bool tmpFlagDisplayText = cfgfile.FlagDisplayText;
@@ -468,7 +468,7 @@ void TwinEEngine::processInventoryAction() {
_text->drawTextFullscreen(161);
cfgfile.FlagDisplayText = tmpFlagDisplayText;
_text->textClipSmall();
- _text->newGameVar4 = 1;
+ _text->drawTextBoxBackground = true;
_text->initTextBank(_scene->sceneTextBank + 3);
_screens->fadeToBlack(_screens->paletteRGBACustom);
_screens->clearScreen();
Commit: d43f929af89ae72b221e036aef1cd5a60309d3f6
https://github.com/scummvm/scummvm/commit/d43f929af89ae72b221e036aef1cd5a60309d3f6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: replaced magic numbers
Changed paths:
engines/twine/menu.cpp
engines/twine/renderer.h
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 434dafa6c8..9348705e1a 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -800,10 +800,22 @@ void Menu::drawInfoMenu(int16 left, int16 top) {
// TODO: convert cantDrawBox to bool
void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, int16 cantDrawBox) {
- int32 boxLeft = (int32)behaviour * 110 + 110;
- int32 boxRight = boxLeft + 99;
- int32 boxTop = 110;
- int32 boxBottom = 229;
+ const int border = 110;
+ const int32 padding = 11;
+ const int32 width = 99;
+ const int height = 119;
+
+ const int32 boxLeft = (int32)behaviour * (width + padding) + border;
+ const int32 boxRight = boxLeft + width;
+ const int32 boxTop = border;
+ const int32 boxBottom = boxTop + height;
+
+ const int titleOffset = 10;
+ const int titleHeight = 40;
+ const int32 titleBoxLeft = border;
+ const int32 titleBoxRight = 540;
+ const int32 titleBoxTop = boxBottom + titleOffset;
+ const int32 titleBoxBottom = titleBoxTop + titleHeight;
uint8 *currentAnim = _engine->_resources->animTable[_engine->_actor->heroAnimIdx[(byte)behaviour]];
int16 currentAnimState = behaviourAnimState[(byte)behaviour];
@@ -829,21 +841,21 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, int16 cantDra
_engine->_interface->drawSplittedBox(boxLeft, boxTop, boxRight, boxBottom, 69);
// behaviour menu title
- _engine->_interface->drawSplittedBox(110, 239, 540, 279, 0);
- drawBox(110, 239, 540, 279);
+ _engine->_interface->drawSplittedBox(titleBoxLeft, titleBoxTop, titleBoxRight, titleBoxBottom, 0);
+ drawBox(titleBoxLeft, titleBoxTop, titleBoxRight, titleBoxBottom);
_engine->_text->setFontColor(15);
char dialText[256];
_engine->_text->getMenuText(_engine->_actor->getTextIdForBehaviour(), dialText, sizeof(dialText));
- _engine->_text->drawText((650 - _engine->_text->getTextSize(dialText)) / 2, 240, dialText);
+ _engine->_text->drawText((650 - _engine->_text->getTextSize(dialText)) / 2, titleBoxTop + 1, dialText);
}
_engine->_renderer->renderBehaviourModel(boxLeft, boxTop, boxRight, boxBottom, -600, angle, behaviourEntity);
_engine->copyBlockPhys(boxLeft, boxTop, boxRight, boxBottom);
- _engine->copyBlockPhys(110, 239, 540, 279);
+ _engine->copyBlockPhys(titleBoxLeft, titleBoxTop, titleBoxRight, titleBoxBottom);
_engine->_interface->loadClip();
}
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 373dba405f..61c180293e 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -239,7 +239,7 @@ public:
void copyActorInternAnim(const uint8 *bodyPtrSrc, uint8 *bodyPtrDest);
- void renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight, int32 boxBottom, int32 Y, int32 angle, uint8 *entityPtr);
+ void renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight, int32 boxBottom, int32 y, int32 angle, uint8 *entityPtr);
void renderInventoryItem(int32 x, int32 y, uint8 *itemBodyPtr, int32 angle, int32 param);
};
Commit: 6bf64769ea7228f3e96ec0277253c487e1c106d3
https://github.com/scummvm/scummvm/commit/6bf64769ea7228f3e96ec0277253c487e1c106d3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: fixed missing textid in while condition
Changed paths:
engines/twine/menu.cpp
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 9348705e1a..50a8291c5d 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -735,7 +735,7 @@ int32 Menu::giveupMenu() {
}
_engine->_text->initTextBank(_engine->_scene->sceneTextBank + 3);
_engine->_system->delayMillis(1000 / _engine->cfgfile.Fps);
- } while (menuId != TextId::kGiveUp && menuId != TextId::kContinue);
+ } while (menuId != TextId::kGiveUp && menuId != TextId::kContinue && menuId != TextId::kCreateSaveGame);
return 0;
}
Commit: c1ec0a76274b4661f4488665c497e4ad37a8a3b3
https://github.com/scummvm/scummvm/commit/c1ec0a76274b4661f4488665c497e4ad37a8a3b3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: renamed Text class members and methods
Changed paths:
engines/twine/console.cpp
engines/twine/menu.cpp
engines/twine/text.cpp
engines/twine/text.h
engines/twine/twine.cpp
diff --git a/engines/twine/console.cpp b/engines/twine/console.cpp
index 56c747b8a7..d6ffba3d23 100644
--- a/engines/twine/console.cpp
+++ b/engines/twine/console.cpp
@@ -136,6 +136,7 @@ bool TwinEConsole::doToggleDebug(int argc, const char **argv) {
}
bool TwinEConsole::doListMenuText(int argc, const char **argv) {
+ _engine->_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
for (int32 i = 0; i < 1000; ++i) {
char buf[256];
if (_engine->_text->getMenuText(i, buf, sizeof(buf))) {
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 50a8291c5d..c23f9d95d7 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -742,8 +742,10 @@ int32 Menu::giveupMenu() {
void Menu::drawInfoMenu(int16 left, int16 top) {
_engine->_interface->resetClip();
- drawBox(left, top, left + 450, top + 80);
- _engine->_interface->drawSplittedBox(left + 1, top + 1, left + 449, top + 79, 0);
+ const int32 width = 450;
+ const int32 height = 80;
+ drawBox(left, top, left + width, top + height);
+ _engine->_interface->drawSplittedBox(left + 1, top + 1, left + width - 1, top + height - 1, 0);
int32 newBoxLeft2 = left + 9;
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index aab287c589..93fa7aa894 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -32,8 +32,8 @@
#include "twine/menu.h"
#include "twine/renderer.h"
#include "twine/resources.h"
-#include "twine/screens.h"
#include "twine/scene.h"
+#include "twine/screens.h"
#include "twine/sound.h"
#include "twine/twine.h"
@@ -83,7 +83,7 @@ bool Text::initVoxToPlay(int32 index) { // setVoxFileAtDigit
voxHiddenIndex = 0;
hasHiddenVox = false;
- Common::MemoryReadStream stream((const byte*)dialOrderPtr, dialOrderSize);
+ Common::MemoryReadStream stream((const byte *)dialOrderPtr, dialOrderSize);
// choose right text from order index
for (int32 i = 0; i < numDialTextEntries; i++) {
int32 orderIdx = stream.readSint16LE();
@@ -291,14 +291,14 @@ void Text::initDialogueBox() { // InitDialWindow
}
_engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
- printText8Var3 = 0;
+ _blendInCharactersPos = 0;
_engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->frontVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->workVideoBuffer);
}
void Text::initInventoryDialogueBox() { // SecondInitDialWindow
_engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
_engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
- printText8Var3 = 0;
+ _blendInCharactersPos = 0;
}
// TODO: refactor this code
@@ -309,18 +309,17 @@ void Text::initText(int32 index) {
}
printText8Ptr1 = buf1;
- printText8Ptr2 = buf2;
+ progressiveTextBuffer = buf2;
printTextVar13 = true;
printText8Var1 = 0;
- buf1[0] = 0;
- buf2[0] = 0;
- printText8Var2 = index;
- printText8Var3 = 0;
+ buf1[0] = '\0';
+ buf2[0] = '\0';
+ _blendInCharactersPos = 0;
TEXT_CurrentLetterX = dialTextBoxLeft + 8;
- printText8Var5 = 0;
- printText8Var6 = 0;
+ printText8Var5 = false;
+ printText8Var6 = false;
TEXT_CurrentLetterY = dialTextBoxTop + 8;
printText8Var8 = currDialTextPtr;
@@ -338,34 +337,29 @@ void Text::initProgressiveTextBuffer() {
i++;
};
- printText8Ptr2 = buf2;
+ progressiveTextBuffer = buf2;
addLineBreakX = 16;
printText8Var1 = 0;
}
-void Text::printText8Sub4(int16 a, int16 b, int16 c) {
+void Text::fillFadeInBuffer(int16 x, int16 y, int16 chr) {
+ if (_blendInCharactersPos < 32) {
+ _blendInCharacters[_blendInCharactersPos].chr = chr;
+ _blendInCharacters[_blendInCharactersPos].x = x;
+ _blendInCharacters[_blendInCharactersPos].y = y;
+ _blendInCharactersPos++;
+ return;
+ }
int32 counter2 = 0;
-
- if (printText8Var3 < 32) {
- const int32 temp = printText8Var3 * 3;
- pt8s4[temp] = c;
- pt8s4[temp + 1] = a;
- pt8s4[temp + 2] = b;
-
- printText8Var3++;
- } else {
- while (counter2 < 31) {
- const int32 var1 = (counter2 + 1) * 3;
- const int32 var2 = counter2 * 3;
- pt8s4[var2] = pt8s4[var1];
- pt8s4[var2 + 1] = pt8s4[var1 + 1];
- pt8s4[var2 + 2] = pt8s4[var1 + 2];
- counter2++;
- }
- pt8s4[93] = c;
- pt8s4[94] = a;
- pt8s4[95] = b;
+ while (counter2 < 31) {
+ const int32 var1 = (counter2 + 1);
+ const int32 var2 = counter2;
+ _blendInCharacters[var2] = _blendInCharacters[var1];
+ counter2++;
}
+ _blendInCharacters[31].chr = chr;
+ _blendInCharacters[31].x = x;
+ _blendInCharacters[31].y = y;
}
Text::WordSize Text::getWordSize(const char *arg1, char *arg2) {
@@ -453,7 +447,7 @@ void Text::processTextLine() {
printText8Var8 = buffer;
- printText8Ptr2 = buf2;
+ progressiveTextBuffer = buf2;
}
void Text::renderContinueReadingTriangle() {
@@ -481,23 +475,16 @@ void Text::renderContinueReadingTriangle() {
_engine->copyBlockPhys(left, top, right, bottom);
}
-void Text::printText10Sub2() {
- const int32 currentLetter = printText8Var3 - 1;
- const int32 currentIndex = currentLetter * 3;
- int16 *ptr = pt8s4 + currentIndex;
- int32 counter = printText8Var3;
- int32 fontColor = dialTextStartColor;
-
- _engine->_system->delayMillis(15);
-
+void Text::fadeInCharacters(int32 counter, int32 fontColor) {
+ _engine->_system->delayMillis(1);
while (--counter >= 0) {
+ const BlendInCharacter *ptr = &_blendInCharacters[counter];
setFontColor(fontColor);
- drawCharacterShadow(*(ptr + 1), *(ptr + 2), (uint8)*ptr, fontColor);
+ drawCharacterShadow(ptr->x, ptr->y, ptr->chr, fontColor);
fontColor -= dialTextStepSize;
if (fontColor > dialTextStopColor) {
fontColor = dialTextStopColor;
}
- ptr -= 3;
}
}
@@ -521,40 +508,40 @@ int Text::printText10() {
return 0;
}
- if (*printText8Ptr2 == '\0') {
- if (printText8Var5 != 0) {
+ if (*progressiveTextBuffer == '\0') {
+ if (printText8Var5) {
if (renderTextTriangle) {
renderContinueReadingTriangle();
}
printTextVar13 = false;
return 0;
}
- if (printText8Var6 != 0) {
+ if (printText8Var6) {
_engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
_engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
- printText8Var3 = 0;
- printText8Var6 = 0;
+ _blendInCharactersPos = 0;
+ printText8Var6 = false;
TEXT_CurrentLetterX = dialTextBoxLeft + 8;
TEXT_CurrentLetterY = dialTextBoxTop + 8;
}
if (*printText8Var8 == '\0') {
initProgressiveTextBuffer();
- printText8Var5 = 1;
+ printText8Var5 = true;
return 1;
}
processTextLine();
}
// RECHECK this later
- if (*printText8Ptr2 == '\0') {
+ if (*progressiveTextBuffer == '\0') {
return 1;
}
- printText8Sub4(TEXT_CurrentLetterX, TEXT_CurrentLetterY, *printText8Ptr2);
- printText10Sub2();
- int8 charWidth = getCharWidth(*printText8Ptr2);
+ fillFadeInBuffer(TEXT_CurrentLetterX, TEXT_CurrentLetterY, *progressiveTextBuffer);
+ fadeInCharacters(_blendInCharactersPos, dialTextStartColor);
+ int8 charWidth = getCharWidth(*progressiveTextBuffer);
- if (*printText8Ptr2 != ' ') {
+ if (*progressiveTextBuffer != ' ') {
TEXT_CurrentLetterX += charWidth + 2;
} else {
if (printText10Var1 != 0) {
@@ -565,16 +552,16 @@ int Text::printText10() {
}
// next character
- printText8Ptr2++;
+ progressiveTextBuffer++;
- if (*printText8Ptr2 != '\0') {
+ if (*progressiveTextBuffer != '\0') {
return 1;
}
TEXT_CurrentLetterY += 38;
TEXT_CurrentLetterX = dialTextBoxLeft + 8;
- if (printText8Var6 == 1 && printText8Var5 == 0) {
+ if (printText8Var6 && !printText8Var5) {
renderContinueReadingTriangle();
return 2;
}
@@ -585,10 +572,10 @@ int Text::printText10() {
}
initProgressiveTextBuffer();
- printText8Var6 = 1;
+ printText8Var6 = true;
if (*printText8Var8 == '\0') {
- printText8Var5 = 1;
+ printText8Var5 = true;
}
return 1;
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 6f8d6c8ebb..8f7bb85537 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -119,7 +119,6 @@ private:
*/
void drawCharacterShadow(int32 x, int32 y, uint8 character, int32 color);
void initProgressiveTextBuffer();
- void printText8Sub4(int16 a, int16 b, int16 c);
struct WordSize {
int32 inChar = 0;
int32 inPixel = 0;
@@ -128,7 +127,17 @@ private:
void processTextLine();
// draw next page arrow polygon
void renderContinueReadingTriangle();
- void printText10Sub2();
+ /**
+ * @see fadeInCharacters
+ */
+ void fillFadeInBuffer(int16 x, int16 y, int16 chr);
+ /**
+ * Blend in characters for a text scrolling in
+ *
+ * @see fillFadeInBuffer
+ * @param counter The amount of characters to handle - max 32
+ */
+ void fadeInCharacters(int32 counter, int32 fontColor);
int32 getCharWidth(uint8 chr) const;
int32 getCharHeight(uint8 chr) const;
/**
@@ -157,18 +166,22 @@ private:
char buf1[256] {'\0'};
char buf2[256] {'\0'};
char *printText8Ptr1 = nullptr;
- char *printText8Ptr2 = nullptr;
+ char *progressiveTextBuffer = nullptr;
int32 printText8Var1 = 0;
- int32 printText8Var2 = 0;
- int32 printText8Var3 = 0;
+ int32 _blendInCharactersPos = 0;
int32 TEXT_CurrentLetterX = 0;
- int32 printText8Var5 = 0;
- int32 printText8Var6 = 0;
+ bool printText8Var5 = false;
+ bool printText8Var6 = false;
int32 TEXT_CurrentLetterY = 0;
char *printText8Var8 = nullptr;
int32 printText10Var1 = 0;
int32 addLineBreakX = 0;
- int16 pt8s4[96] {0};
+ struct BlendInCharacter {
+ int16 chr = 0;
+ int16 x = 0;
+ int16 y = 0;
+ };
+ BlendInCharacter _blendInCharacters[32];
int32 printText8PrepareBufferVar2 = 0;
// ---
@@ -190,7 +203,11 @@ private:
int32 dialTextStartColor = 0;
/** Dialogue text stop color for cross coloring dialogues */
int32 dialTextStopColor = 0;
- /** Dialogue text step size for cross coloring dialogues */
+ /**
+ * Dialogue text step size for cross coloring dialogues
+ *
+ * The speed in which the color reaches it's destination color while fading in.
+ */
int32 dialTextStepSize = 0;
/** Dialogue text buffer size for cross coloring dialogues */
int32 dialTextBufferSize = 0;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 47c190026a..4e7f56584f 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -437,7 +437,6 @@ void TwinEEngine::processInventoryAction() {
case kiHolomap:
_holomap->processHolomap();
_screens->lockPalette = true;
- warning("Use inventory [kiHolomap] not implemented!");
break;
case kiMagicBall:
if (_gameState->usingSabre) {
Commit: 0e8232bad4883f8191900f319da804bebac4899e
https://github.com/scummvm/scummvm/commit/0e8232bad4883f8191900f319da804bebac4899e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: renamed more Text class members
Changed paths:
engines/twine/menu.cpp
engines/twine/text.cpp
engines/twine/text.h
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index c23f9d95d7..e28853b99a 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -1116,7 +1116,7 @@ void Menu::processInventoryMenu() {
keymapper->getKeymap(uiKeyMapId)->setEnabled(false);
- _engine->_text->printTextVar13 = false;
+ _engine->_text->_hasValidTextHandle = false;
_engine->_scene->alphaLight = tmpAlphaLight;
_engine->_scene->betaLight = tmpBetaLight;
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 93fa7aa894..13aafd9497 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -304,14 +304,13 @@ void Text::initInventoryDialogueBox() { // SecondInitDialWindow
// TODO: refactor this code
void Text::initText(int32 index) {
if (!getText(index)) {
- printTextVar13 = false;
+ _hasValidTextHandle = false;
return;
}
- printText8Ptr1 = buf1;
progressiveTextBuffer = buf2;
- printTextVar13 = true;
+ _hasValidTextHandle = true;
printText8Var1 = 0;
buf1[0] = '\0';
@@ -381,7 +380,7 @@ Text::WordSize Text::getWordSize(const char *arg1, char *arg2) {
void Text::processTextLine() {
char *buffer = printText8Var8;
dialCharSpace = 7;
- int16 var4 = 1;
+ bool var4 = true;
addLineBreakX = 0;
printText8PrepareBufferVar2 = 0;
@@ -401,11 +400,11 @@ void Text::processTextLine() {
if (addLineBreakX + dialCharSpace + wordSize.inPixel < dialTextBoxParam2) {
char *temp = buffer + 1;
if (*buffer == 1) {
- var4 = 0;
+ var4 = false;
buffer = temp;
} else {
if (*buf1 == '@') {
- var4 = 0;
+ var4 = false;
buffer = temp;
if (addLineBreakX == 0) {
addLineBreakX = 7;
@@ -437,7 +436,7 @@ void Text::processTextLine() {
printText8PrepareBufferVar2--;
}
- if (*printText8Var8 != '\0' && var4 == 1) {
+ if (*printText8Var8 != '\0' && var4) {
if (printText8PrepareBufferVar2 == 0) {
printText8PrepareBufferVar2 = 1;
}
@@ -476,7 +475,7 @@ void Text::renderContinueReadingTriangle() {
}
void Text::fadeInCharacters(int32 counter, int32 fontColor) {
- _engine->_system->delayMillis(1);
+ _engine->_system->delayMillis(15);
while (--counter >= 0) {
const BlendInCharacter *ptr = &_blendInCharacters[counter];
setFontColor(fontColor);
@@ -504,7 +503,7 @@ int32 Text::getCharHeight(uint8 chr) const {
// TODO: refactor this code
int Text::printText10() {
- if (!printTextVar13) {
+ if (!_hasValidTextHandle) {
return 0;
}
@@ -513,7 +512,7 @@ int Text::printText10() {
if (renderTextTriangle) {
renderContinueReadingTriangle();
}
- printTextVar13 = false;
+ _hasValidTextHandle = false;
return 0;
}
if (printText8Var6) {
@@ -616,7 +615,7 @@ bool Text::drawTextFullscreen(int32 index) {
}
hasHiddenVox = false;
- printTextVar13 = false;
+ _hasValidTextHandle = false;
if (printedText == 0) {
stopVox(currDialTextEntry);
@@ -796,7 +795,7 @@ void Text::drawAskQuestion(int32 index) {
hasHiddenVox = false;
voxHiddenIndex = 0;
- printTextVar13 = false;
+ _hasValidTextHandle = false;
}
} // namespace TwinE
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 8f7bb85537..098dbc22b9 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -165,10 +165,8 @@ private:
// TODO: refactor all this variables and related functions
char buf1[256] {'\0'};
char buf2[256] {'\0'};
- char *printText8Ptr1 = nullptr;
char *progressiveTextBuffer = nullptr;
int32 printText8Var1 = 0;
- int32 _blendInCharactersPos = 0;
int32 TEXT_CurrentLetterX = 0;
bool printText8Var5 = false;
bool printText8Var6 = false;
@@ -182,6 +180,7 @@ private:
int16 y = 0;
};
BlendInCharacter _blendInCharacters[32];
+ int32 _blendInCharactersPos = 0;
int32 printText8PrepareBufferVar2 = 0;
// ---
@@ -224,7 +223,7 @@ public:
~Text();
// TODO: refactor all this variables and related functions
- bool printTextVar13 = false;
+ bool _hasValidTextHandle = false;
// renders a triangle if the next side of the text can get activated
bool renderTextTriangle = false;
bool drawTextBoxBackground = false;
Commit: cd019aa41e2623071d0e5521488e9d8320683694
https://github.com/scummvm/scummvm/commit/cd019aa41e2623071d0e5521488e9d8320683694
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: removed unused var
Changed paths:
engines/twine/text.cpp
engines/twine/text.h
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 13aafd9497..548afa3c43 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -133,7 +133,6 @@ void Text::initTextBank(int32 bankIdx) {
}
currentBankIdx = bankIdx;
- textVar2[0] = '\0';
// get index according with language
const int32 size = _engine->isLBA1() ? 28 : 30;
@@ -441,7 +440,7 @@ void Text::processTextLine() {
printText8PrepareBufferVar2 = 1;
}
dialCharSpace += (dialTextBoxParam2 - addLineBreakX) / printText8PrepareBufferVar2;
- printText10Var1 = dialTextBoxParam2 - addLineBreakX - dialTextBoxParam2 - addLineBreakX; // stupid... recheck
+ printText10Var1 = -2 * addLineBreakX;
}
printText8Var8 = buffer;
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 098dbc22b9..c6829793a9 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -150,7 +150,6 @@ private:
// RECHECK THIS LATER
int32 currentBankIdx = TextBankId::None; // textVar1
- char textVar2[256] {'\0'};
/** Dialogue text pointer */
char *dialTextPtr = nullptr; // bufText
Commit: d5174c2cf76b0c44c9cf6afb1fdea82fca7e728a
https://github.com/scummvm/scummvm/commit/d5174c2cf76b0c44c9cf6afb1fdea82fca7e728a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: renamed method
Changed paths:
engines/twine/gamestate.cpp
engines/twine/menu.cpp
engines/twine/text.cpp
engines/twine/text.h
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index dcc6dc1442..9a2d4f15c3 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -361,7 +361,7 @@ void GameState::processFoundItem(int32 item) {
if (textState) {
_engine->_interface->resetClip();
- textState = _engine->_text->printText10();
+ textState = _engine->_text->updateProgressiveText();
}
if (textState == 0 || textState == 2) {
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index e28853b99a..47929b3a2f 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -1082,7 +1082,7 @@ void Menu::processInventoryMenu() {
}
if (bx != 2) {
- bx = _engine->_text->printText10();
+ bx = _engine->_text->updateProgressiveText();
}
// TRICKY: 3D model rotation delay - only apply when no text is drawing
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 548afa3c43..33adf5dab9 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -501,7 +501,7 @@ int32 Text::getCharHeight(uint8 chr) const {
}
// TODO: refactor this code
-int Text::printText10() {
+int Text::updateProgressiveText() {
if (!_hasValidTextHandle) {
return 0;
}
@@ -599,7 +599,7 @@ bool Text::drawTextFullscreen(int32 index) {
int32 printedText;
for (;;) {
_engine->readKeys();
- printedText = printText10();
+ printedText = updateProgressiveText();
playVox(currDialTextEntry);
if (!printedText && !_engine->_sound->isSamplePlaying(currDialTextEntry)) {
@@ -766,7 +766,7 @@ void Text::drawAskQuestion(int32 index) {
int32 textStatus = 1;
do {
_engine->readKeys();
- textStatus = printText10();
+ textStatus = updateProgressiveText();
if (textStatus == 2) {
do {
diff --git a/engines/twine/text.h b/engines/twine/text.h
index c6829793a9..d6de50f862 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -262,7 +262,7 @@ public:
void initInventoryDialogueBox();
void initText(int32 index);
- int printText10();
+ int updateProgressiveText();
/**
* Set font type parameters
Commit: 4e7e7e67ddf2bc853b30383979d62b0898bae9ea
https://github.com/scummvm/scummvm/commit/4e7e7e67ddf2bc853b30383979d62b0898bae9ea
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: renamed Text class members
Changed paths:
engines/twine/text.cpp
engines/twine/text.h
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 33adf5dab9..9a155e2dcb 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -164,7 +164,7 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
x += stream.readByte();
y += stream.readByte();
- const uint8 usedColor = dialTextColor;
+ const uint8 usedColor = _dialTextColor;
uint8 *screen2 = (uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y);
@@ -250,20 +250,20 @@ void Text::drawText(int32 x, int32 y, const char *dialogue) { // Font
}
if (currChar == ' ') {
- x += dialCharSpace;
+ x += _dialCharSpace;
} else {
- dialTextSize = getCharWidth(currChar);
+ _dialTextSize = getCharWidth(currChar);
drawCharacter(x, y, currChar); // draw the character on screen
// add the length of the space between 2 characters
- x += dialSpaceBetween;
+ x += _dialSpaceBetween;
// add the length of the current character
- x += dialTextSize;
+ x += _dialTextSize;
}
} while (1);
}
int32 Text::getTextSize(const char *dialogue) { // SizeFont
- dialTextSize = 0;
+ _dialTextSize = 0;
do {
uint8 currChar = (uint8) * (dialogue++);
@@ -271,32 +271,32 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
break;
if (currChar == ' ') {
- dialTextSize += dialCharSpace;
+ _dialTextSize += _dialCharSpace;
} else {
- dialTextSize += dialSpaceBetween;
- dialTextSize += getCharWidth(currChar);
+ _dialTextSize += _dialSpaceBetween;
+ _dialTextSize += getCharWidth(currChar);
}
} while (1);
- return (dialTextSize);
+ return (_dialTextSize);
}
void Text::initDialogueBox() { // InitDialWindow
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
+ _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
if (drawTextBoxBackground) {
- _engine->_menu->drawBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
- _engine->_interface->drawTransparentBox(dialTextBoxLeft + 1, dialTextBoxTop + 1, dialTextBoxRight - 1, dialTextBoxBottom - 1, 3);
+ _engine->_menu->drawBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
+ _engine->_interface->drawTransparentBox(_dialTextBoxLeft + 1, _dialTextBoxTop + 1, _dialTextBoxRight - 1, _dialTextBoxBottom - 1, 3);
}
- _engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
+ _engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
_blendInCharactersPos = 0;
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->frontVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->workVideoBuffer);
+ _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->frontVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->workVideoBuffer);
}
void Text::initInventoryDialogueBox() { // SecondInitDialWindow
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
- _engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
+ _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
+ _engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
_blendInCharactersPos = 0;
}
@@ -307,19 +307,19 @@ void Text::initText(int32 index) {
return;
}
- progressiveTextBuffer = buf2;
+ _progressiveTextBuffer = buf2;
_hasValidTextHandle = true;
- printText8Var1 = 0;
+ _dialTextBoxCurrentLine = 0;
buf1[0] = '\0';
buf2[0] = '\0';
_blendInCharactersPos = 0;
- TEXT_CurrentLetterX = dialTextBoxLeft + 8;
- printText8Var5 = false;
- printText8Var6 = false;
- TEXT_CurrentLetterY = dialTextBoxTop + 8;
- printText8Var8 = currDialTextPtr;
+ _dialTextYPos = _dialTextBoxLeft + 8;
+ _progressiveTextEnd = false;
+ _progressiveTextNextPage = false;
+ _dialTextXPos = _dialTextBoxTop + 8;
+ printText8Var8 = _currDialTextPtr;
// lba font is get while engine start
setFontParameters(2, 7);
@@ -330,14 +330,14 @@ void Text::initProgressiveTextBuffer() {
buf2[0] = '\0';
- while (i < dialTextBufferSize) {
+ while (i < _dialTextBufferSize) {
strncat(buf2, " ", sizeof(buf2));
i++;
};
- progressiveTextBuffer = buf2;
- addLineBreakX = 16;
- printText8Var1 = 0;
+ _progressiveTextBuffer = buf2;
+ _addLineBreakX = 16;
+ _dialTextBoxCurrentLine = 0;
}
void Text::fillFadeInBuffer(int16 x, int16 y, int16 chr) {
@@ -378,10 +378,10 @@ Text::WordSize Text::getWordSize(const char *arg1, char *arg2) {
void Text::processTextLine() {
char *buffer = printText8Var8;
- dialCharSpace = 7;
+ _dialCharSpace = 7;
bool var4 = true;
- addLineBreakX = 0;
+ _addLineBreakX = 0;
printText8PrepareBufferVar2 = 0;
buf2[0] = 0;
@@ -396,7 +396,7 @@ void Text::processTextLine() {
printText8Var8 = buffer;
WordSize wordSize = getWordSize(buffer, buf1);
- if (addLineBreakX + dialCharSpace + wordSize.inPixel < dialTextBoxParam2) {
+ if (_addLineBreakX + _dialCharSpace + wordSize.inPixel < _dialTextBoxParam2) {
char *temp = buffer + 1;
if (*buffer == 1) {
var4 = false;
@@ -405,12 +405,12 @@ void Text::processTextLine() {
if (*buf1 == '@') {
var4 = false;
buffer = temp;
- if (addLineBreakX == 0) {
- addLineBreakX = 7;
+ if (_addLineBreakX == 0) {
+ _addLineBreakX = 7;
*((int16 *)buf2) = spaceChar;
}
if (buf1[1] == 'P') {
- printText8Var1 = dialTextBoxParam1;
+ _dialTextBoxCurrentLine = _dialTextBoxLines;
buffer++;
}
} else {
@@ -420,7 +420,7 @@ void Text::processTextLine() {
strncat(buf2, " ", sizeof(buf2)); // not 100% accurate
printText8PrepareBufferVar2++;
- addLineBreakX += wordSize.inPixel + dialCharSpace;
+ _addLineBreakX += wordSize.inPixel + _dialCharSpace;
if (*printText8Var8 != '\0') {
printText8Var8++;
continue;
@@ -439,36 +439,36 @@ void Text::processTextLine() {
if (printText8PrepareBufferVar2 == 0) {
printText8PrepareBufferVar2 = 1;
}
- dialCharSpace += (dialTextBoxParam2 - addLineBreakX) / printText8PrepareBufferVar2;
- printText10Var1 = -2 * addLineBreakX;
+ _dialCharSpace += (_dialTextBoxParam2 - _addLineBreakX) / printText8PrepareBufferVar2;
+ printText10Var1 = -2 * _addLineBreakX;
}
printText8Var8 = buffer;
- progressiveTextBuffer = buf2;
+ _progressiveTextBuffer = buf2;
}
void Text::renderContinueReadingTriangle() {
- const int32 right = dialTextBoxRight - 3;
- const int32 left = dialTextBoxRight - 24;
- const int32 top = dialTextBoxBottom - 24;
- const int32 bottom = dialTextBoxBottom - 3;
+ const int32 right = _dialTextBoxRight - 3;
+ const int32 left = _dialTextBoxRight - 24;
+ const int32 top = _dialTextBoxBottom - 24;
+ const int32 bottom = _dialTextBoxBottom - 3;
- _engine->_renderer->vertexCoordinates[0] = dialTextStopColor;
+ _engine->_renderer->vertexCoordinates[0] = _dialTextStopColor;
_engine->_renderer->vertexCoordinates[1] = right;
_engine->_renderer->vertexCoordinates[2] = top;
- _engine->_renderer->vertexCoordinates[3] = dialTextStopColor;
+ _engine->_renderer->vertexCoordinates[3] = _dialTextStopColor;
_engine->_renderer->vertexCoordinates[4] = left;
_engine->_renderer->vertexCoordinates[5] = bottom;
- _engine->_renderer->vertexCoordinates[6] = dialTextStartColor;
+ _engine->_renderer->vertexCoordinates[6] = _dialTextStartColor;
_engine->_renderer->vertexCoordinates[7] = _engine->_renderer->vertexCoordinates[1];
_engine->_renderer->vertexCoordinates[8] = _engine->_renderer->vertexCoordinates[5];
_engine->_renderer->numOfVertex = 3;
- _engine->_renderer->renderPolygons(POLYGONTYPE_FLAT, dialTextStopColor);
+ _engine->_renderer->renderPolygons(POLYGONTYPE_FLAT, _dialTextStopColor);
_engine->copyBlockPhys(left, top, right, bottom);
}
@@ -479,9 +479,9 @@ void Text::fadeInCharacters(int32 counter, int32 fontColor) {
const BlendInCharacter *ptr = &_blendInCharacters[counter];
setFontColor(fontColor);
drawCharacterShadow(ptr->x, ptr->y, ptr->chr, fontColor);
- fontColor -= dialTextStepSize;
- if (fontColor > dialTextStopColor) {
- fontColor = dialTextStopColor;
+ fontColor -= _dialTextStepSize;
+ if (fontColor > _dialTextStopColor) {
+ fontColor = _dialTextStopColor;
}
}
}
@@ -506,74 +506,75 @@ int Text::updateProgressiveText() {
return 0;
}
- if (*progressiveTextBuffer == '\0') {
- if (printText8Var5) {
+ if (*_progressiveTextBuffer == '\0') {
+ if (_progressiveTextEnd) {
if (renderTextTriangle) {
renderContinueReadingTriangle();
}
_hasValidTextHandle = false;
return 0;
}
- if (printText8Var6) {
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
- _engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
+ if (_progressiveTextNextPage) {
+ _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
+ _engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
_blendInCharactersPos = 0;
- printText8Var6 = false;
- TEXT_CurrentLetterX = dialTextBoxLeft + 8;
- TEXT_CurrentLetterY = dialTextBoxTop + 8;
+ _progressiveTextNextPage = false;
+ _dialTextYPos = _dialTextBoxLeft + 8;
+ _dialTextXPos = _dialTextBoxTop + 8;
}
if (*printText8Var8 == '\0') {
initProgressiveTextBuffer();
- printText8Var5 = true;
+ _progressiveTextEnd = true;
return 1;
}
processTextLine();
}
// RECHECK this later
- if (*progressiveTextBuffer == '\0') {
+ if (*_progressiveTextBuffer == '\0') {
return 1;
}
- fillFadeInBuffer(TEXT_CurrentLetterX, TEXT_CurrentLetterY, *progressiveTextBuffer);
- fadeInCharacters(_blendInCharactersPos, dialTextStartColor);
- int8 charWidth = getCharWidth(*progressiveTextBuffer);
+ fillFadeInBuffer(_dialTextYPos, _dialTextXPos, *_progressiveTextBuffer);
+ fadeInCharacters(_blendInCharactersPos, _dialTextStartColor);
+ int8 charWidth = getCharWidth(*_progressiveTextBuffer);
- if (*progressiveTextBuffer != ' ') {
- TEXT_CurrentLetterX += charWidth + 2;
+ if (*_progressiveTextBuffer != ' ') {
+ _dialTextYPos += charWidth + 2;
} else {
if (printText10Var1 != 0) {
- TEXT_CurrentLetterX++;
+ _dialTextYPos++;
printText10Var1--;
}
- TEXT_CurrentLetterX += dialCharSpace;
+ _dialTextYPos += _dialCharSpace;
}
// next character
- progressiveTextBuffer++;
+ _progressiveTextBuffer++;
- if (*progressiveTextBuffer != '\0') {
+ if (*_progressiveTextBuffer != '\0') {
return 1;
}
- TEXT_CurrentLetterY += 38;
- TEXT_CurrentLetterX = dialTextBoxLeft + 8;
+ const int32 lineHeight = 38;
+ _dialTextXPos += lineHeight;
+ _dialTextYPos = _dialTextBoxLeft + 8;
- if (printText8Var6 && !printText8Var5) {
+ if (_progressiveTextNextPage && !_progressiveTextEnd) {
renderContinueReadingTriangle();
return 2;
}
- printText8Var1++;
- if (printText8Var1 < dialTextBoxParam1) {
+ _dialTextBoxCurrentLine++;
+ if (_dialTextBoxCurrentLine < _dialTextBoxLines) {
return 1;
}
initProgressiveTextBuffer();
- printText8Var6 = true;
+ _progressiveTextNextPage = true;
if (*printText8Var8 == '\0') {
- printText8Var5 = true;
+ _progressiveTextEnd = true;
}
return 1;
@@ -648,26 +649,26 @@ bool Text::drawTextFullscreen(int32 index) {
}
void Text::setFontParameters(int32 spaceBetween, int32 charSpace) {
- dialSpaceBetween = spaceBetween;
- dialCharSpace = charSpace;
+ _dialSpaceBetween = spaceBetween;
+ _dialCharSpace = charSpace;
}
void Text::setFontCrossColor(int32 color) {
- dialTextStepSize = -1;
- dialTextBufferSize = 14;
- dialTextStartColor = color << 4;
- dialTextStopColor = (color << 4) + 12;
+ _dialTextStepSize = -1;
+ _dialTextBufferSize = 14;
+ _dialTextStartColor = color << 4;
+ _dialTextStopColor = (color << 4) + 12;
}
void Text::setFontColor(int32 color) {
- dialTextColor = color;
+ _dialTextColor = color;
}
void Text::setTextCrossColor(int32 stopColor, int32 startColor, int32 stepSize) {
- dialTextStartColor = startColor;
- dialTextStopColor = stopColor;
- dialTextStepSize = stepSize;
- dialTextBufferSize = ((startColor - stopColor) + 1) / stepSize;
+ _dialTextStartColor = startColor;
+ _dialTextStopColor = stopColor;
+ _dialTextStepSize = stepSize;
+ _dialTextBufferSize = ((startColor - stopColor) + 1) / stepSize;
}
bool Text::getText(int32 index) {
@@ -695,8 +696,8 @@ bool Text::getText(int32 index) {
int32 ptrCurrentEntry = READ_LE_INT16(&localTextBuf[currIdx]);
int32 ptrNextEntry = READ_LE_INT16(&localTextBuf[currIdx + 1]);
- currDialTextPtr = (dialTextPtr + ptrCurrentEntry);
- currDialTextSize = ptrNextEntry - ptrCurrentEntry;
+ _currDialTextPtr = (dialTextPtr + ptrCurrentEntry);
+ _currDialTextSize = ptrNextEntry - ptrCurrentEntry;
numDialTextEntries = numEntries;
// RECHECK: this was added for vox playback
@@ -724,13 +725,13 @@ bool Text::getMenuText(int32 index, char *text, uint32 textSize) {
return false;
}
- if ((currDialTextSize - 1) > 0xFF) {
- currDialTextSize = 0xFF;
+ if ((_currDialTextSize - 1) > 0xFF) {
+ _currDialTextSize = 0xFF;
}
- copyText(currDialTextPtr, text, currDialTextSize);
- currDialTextSize++;
- copyText(text, _engine->_menu->currMenuTextBuffer, currDialTextSize);
+ copyText(_currDialTextPtr, text, _currDialTextSize);
+ _currDialTextSize++;
+ copyText(text, _engine->_menu->currMenuTextBuffer, _currDialTextSize);
_engine->_menu->currMenuTextIndex = index;
_engine->_menu->currMenuTextBank = _engine->_scene->sceneTextBank;
@@ -738,22 +739,22 @@ bool Text::getMenuText(int32 index, char *text, uint32 textSize) {
}
void Text::textClipFull() { // newGame2
- dialTextBoxLeft = 8;
- dialTextBoxTop = 8;
- dialTextBoxRight = 631;
+ _dialTextBoxLeft = 8;
+ _dialTextBoxTop = 8;
+ _dialTextBoxRight = 631;
- dialTextBoxBottom = 471;
- dialTextBoxParam1 = 11;
- dialTextBoxParam2 = 607;
+ _dialTextBoxBottom = 471;
+ _dialTextBoxLines = 11;
+ _dialTextBoxParam2 = 607;
}
void Text::textClipSmall() { // newGame4
- dialTextBoxLeft = 16;
- dialTextBoxTop = 334;
- dialTextBoxRight = 623;
- dialTextBoxBottom = 463;
- dialTextBoxParam1 = 3;
- dialTextBoxParam2 = 591;
+ _dialTextBoxLeft = 16;
+ _dialTextBoxTop = 334;
+ _dialTextBoxRight = 623;
+ _dialTextBoxBottom = 463;
+ _dialTextBoxLines = 3;
+ _dialTextBoxParam2 = 591;
}
void Text::drawAskQuestion(int32 index) {
diff --git a/engines/twine/text.h b/engines/twine/text.h
index d6de50f862..40aee14cd4 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -164,15 +164,16 @@ private:
// TODO: refactor all this variables and related functions
char buf1[256] {'\0'};
char buf2[256] {'\0'};
- char *progressiveTextBuffer = nullptr;
- int32 printText8Var1 = 0;
- int32 TEXT_CurrentLetterX = 0;
- bool printText8Var5 = false;
- bool printText8Var6 = false;
- int32 TEXT_CurrentLetterY = 0;
char *printText8Var8 = nullptr;
int32 printText10Var1 = 0;
- int32 addLineBreakX = 0;
+
+ int32 _dialTextXPos = 0;
+ char *_progressiveTextBuffer = nullptr;
+ int32 _dialTextBoxCurrentLine = 0;
+ int32 _dialTextYPos = 0;
+ bool _progressiveTextEnd = false;
+ bool _progressiveTextNextPage = false;
+ int32 _addLineBreakX = 0;
struct BlendInCharacter {
int16 chr = 0;
int16 x = 0;
@@ -184,39 +185,39 @@ private:
// ---
/** Current dialogue text pointer */
- char *currDialTextPtr = nullptr;
+ char *_currDialTextPtr = nullptr;
/** Current dialogue text size */
- int32 currDialTextSize = 0;
+ int32 _currDialTextSize = 0;
/** Dialogue text size */
- int32 dialTextSize = 0;
+ int32 _dialTextSize = 0;
/** Pixel size between dialogue text */
- int32 dialSpaceBetween = 0;
+ int32 _dialSpaceBetween = 0;
/** Pixel size of the space character */
- int32 dialCharSpace = 0;
+ int32 _dialCharSpace = 0;
/** Dialogue text color */
- int32 dialTextColor = 0;
+ int32 _dialTextColor = 0;
/** Dialogue text start color for cross coloring dialogues */
- int32 dialTextStartColor = 0;
+ int32 _dialTextStartColor = 0;
/** Dialogue text stop color for cross coloring dialogues */
- int32 dialTextStopColor = 0;
+ int32 _dialTextStopColor = 0;
/**
* Dialogue text step size for cross coloring dialogues
*
* The speed in which the color reaches it's destination color while fading in.
*/
- int32 dialTextStepSize = 0;
+ int32 _dialTextStepSize = 0;
/** Dialogue text buffer size for cross coloring dialogues */
- int32 dialTextBufferSize = 0;
+ int32 _dialTextBufferSize = 0;
- int32 dialTextBoxLeft = 0; // dialogueBoxLeft
- int32 dialTextBoxTop = 0; // dialogueBoxTop
- int32 dialTextBoxRight = 0; // dialogueBoxRight
- int32 dialTextBoxBottom = 0; // dialogueBoxBottom
+ int32 _dialTextBoxLeft = 0; // dialogueBoxLeft
+ int32 _dialTextBoxTop = 0; // dialogueBoxTop
+ int32 _dialTextBoxRight = 0; // dialogueBoxRight
+ int32 _dialTextBoxBottom = 0; // dialogueBoxBottom
- int32 dialTextBoxParam1 = 0; // dialogueBoxParam1
- int32 dialTextBoxParam2 = 0; // dialogueBoxParam2
+ int32 _dialTextBoxLines = 0; // dialogueBoxParam1
+ int32 _dialTextBoxParam2 = 0; // dialogueBoxParam2
public:
Text(TwinEEngine *engine) : _engine(engine) {}
~Text();
Commit: d30035ab50a886912faab1b3b69d0ec4f58e6ed1
https://github.com/scummvm/scummvm/commit/d30035ab50a886912faab1b3b69d0ec4f58e6ed1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: reduced scope
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 9a155e2dcb..b157521cba 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -278,7 +278,7 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
}
} while (1);
- return (_dialTextSize);
+ return _dialTextSize;
}
void Text::initDialogueBox() { // InitDialWindow
@@ -672,22 +672,19 @@ void Text::setTextCrossColor(int32 stopColor, int32 startColor, int32 stepSize)
}
bool Text::getText(int32 index) {
- int32 currIdx = 0;
- int32 orderIdx = 0;
-
const int16 *localTextBuf = (const int16 *)dialTextPtr;
const int16 *localOrderBuf = (const int16 *)dialOrderPtr;
- int32 numEntries = numDialTextEntries;
-
+ const int32 numEntries = numDialTextEntries;
+ int32 currIdx = 0;
// choose right text from order index
do {
- orderIdx = *(localOrderBuf++);
+ int32 orderIdx = *(localOrderBuf++);
if (orderIdx == index) {
break;
}
currIdx++;
- } while (currIdx < numDialTextEntries);
+ } while (currIdx < numEntries);
if (currIdx >= numEntries) {
return false;
@@ -696,9 +693,8 @@ bool Text::getText(int32 index) {
int32 ptrCurrentEntry = READ_LE_INT16(&localTextBuf[currIdx]);
int32 ptrNextEntry = READ_LE_INT16(&localTextBuf[currIdx + 1]);
- _currDialTextPtr = (dialTextPtr + ptrCurrentEntry);
+ _currDialTextPtr = dialTextPtr + ptrCurrentEntry;
_currDialTextSize = ptrNextEntry - ptrCurrentEntry;
- numDialTextEntries = numEntries;
// RECHECK: this was added for vox playback
currDialTextEntry = currIdx;
@@ -725,7 +721,7 @@ bool Text::getMenuText(int32 index, char *text, uint32 textSize) {
return false;
}
- if ((_currDialTextSize - 1) > 0xFF) {
+ if (_currDialTextSize - 1 > 0xFF) {
_currDialTextSize = 0xFF;
}
Commit: f88ab25d25537ace158b579a1a5b77ac1f9fec87
https://github.com/scummvm/scummvm/commit/f88ab25d25537ace158b579a1a5b77ac1f9fec87
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: const
Changed paths:
engines/twine/resources.h
engines/twine/script_life_v1.cpp
engines/twine/text.cpp
diff --git a/engines/twine/resources.h b/engines/twine/resources.h
index 3e60ea9e95..023cc67621 100644
--- a/engines/twine/resources.h
+++ b/engines/twine/resources.h
@@ -55,6 +55,7 @@ namespace TwinE {
#define RESSHQR_ALARMREDPAL 22
#define RESSHQR_DARKPAL 24
+#define RESSHQR_TWINSEN_ZOE_SENDELL 25
#define RESSHQR_ADELINEIMG 27
#define RESSHQR_ADELINEPAL 28
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 7a864062ae..353ed252a3 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1608,7 +1608,7 @@ static int32 lSET_NORMAL_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
ScopedEngineFreeze scoped(engine);
engine->_screens->fadeToBlack(engine->_screens->paletteRGBA);
- engine->_screens->loadImage(25);
+ engine->_screens->loadImage(RESSHQR_TWINSEN_ZOE_SENDELL);
engine->_text->textClipFull();
engine->_text->setFontCrossColor(15);
engine->_text->drawTextBoxBackground = false;
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index b157521cba..e994644cc4 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -679,7 +679,7 @@ bool Text::getText(int32 index) {
int32 currIdx = 0;
// choose right text from order index
do {
- int32 orderIdx = *(localOrderBuf++);
+ const int32 orderIdx = *(localOrderBuf++);
if (orderIdx == index) {
break;
}
@@ -690,8 +690,8 @@ bool Text::getText(int32 index) {
return false;
}
- int32 ptrCurrentEntry = READ_LE_INT16(&localTextBuf[currIdx]);
- int32 ptrNextEntry = READ_LE_INT16(&localTextBuf[currIdx + 1]);
+ const int32 ptrCurrentEntry = READ_LE_INT16(&localTextBuf[currIdx]);
+ const int32 ptrNextEntry = READ_LE_INT16(&localTextBuf[currIdx + 1]);
_currDialTextPtr = dialTextPtr + ptrCurrentEntry;
_currDialTextSize = ptrNextEntry - ptrCurrentEntry;
Commit: 6f3248e1b9160d3643adee39314990353149df34
https://github.com/scummvm/scummvm/commit/6f3248e1b9160d3643adee39314990353149df34
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T22:42:24+01:00
Commit Message:
TWINE: reduced cyclic complexity
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index e994644cc4..33f362c4a2 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -215,29 +215,28 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
}
void Text::drawCharacterShadow(int32 x, int32 y, uint8 character, int32 color) { // drawDoubleLetter
- int32 left, top, right, bottom;
-
- if (character != ' ') {
- // shadow color
- setFontColor(0);
- drawCharacter(x + 2, y + 4, character);
+ if (character == ' ') {
+ return;
+ }
+ // shadow color
+ setFontColor(0);
+ drawCharacter(x + 2, y + 4, character);
- // text color
- setFontColor(color);
- drawCharacter(x, y, character);
+ // text color
+ setFontColor(color);
+ drawCharacter(x, y, character);
- left = x;
- top = y;
- // FIXME: get right font size
- right = x + 32;
- bottom = y + 38;
+ int32 left = x;
+ int32 top = y;
+ // FIXME: get right font size
+ int32 right = x + 32;
+ int32 bottom = y + 38;
- _engine->copyBlockPhys(left, top, right, bottom);
- }
+ _engine->copyBlockPhys(left, top, right, bottom);
}
-void Text::drawText(int32 x, int32 y, const char *dialogue) { // Font
- // if the font is not defined
+void Text::drawText(int32 x, int32 y, const char *dialogue) {
+ // if the font is not defined
if (_engine->_resources->fontPtr == nullptr) {
return;
}
@@ -266,9 +265,10 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
_dialTextSize = 0;
do {
- uint8 currChar = (uint8) * (dialogue++);
- if (currChar == 0)
+ const uint8 currChar = (uint8) * (dialogue++);
+ if (currChar == 0) {
break;
+ }
if (currChar == ' ') {
_dialTextSize += _dialCharSpace;
@@ -326,14 +326,13 @@ void Text::initText(int32 index) {
}
void Text::initProgressiveTextBuffer() {
- int32 i = 0;
-
buf2[0] = '\0';
+ int32 i = 0;
while (i < _dialTextBufferSize) {
strncat(buf2, " ", sizeof(buf2));
i++;
- };
+ }
_progressiveTextBuffer = buf2;
_addLineBreakX = 16;
More information about the Scummvm-git-logs
mailing list