[Scummvm-git-logs] scummvm master -> 315ee1a530eee5f15bf289886eda109eec796719
mgerhardy
martin.gerhardy at gmail.com
Mon Dec 28 23:18:50 UTC 2020
This automated email contains information about 17 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6b40f4a96e TWINE: removed unused member variable
3a6455a434 TWINE: small helper method for model bone
5d137ee1ca TWINE: extract to constants
4f0040deff TWINE: drawBehaviour cleanup
67dd46a071 TWINE: extended TextId enum
3bc2447e44 TWINE: use TextId constants
3dfcdef673 TWINE: extract to method
e414eaa208 TWINE: doxygen
e7eea92883 TWINE: extracted into own method
c652b46999 TWINE: prepare drawTextFullscreen to use diplayText
1d37d3d3a6 TWINE: fixed processing of @ (newline) followed by another newline
ff56096ea3 TWINE: format the code
0b37e42a04 TWINE: refactored the text rendering
72486eb179 TWINE: removed todo comment + const
d91019ff31 TWINE: starting to refactor Text::drawCharacter
bb6f37394e TWINE: minor optimization of Text::drawCharacter
315ee1a530 TWINE: const
Commit: 6b40f4a96e5341ab9a4daec0871fd15c2d953833
https://github.com/scummvm/scummvm/commit/6b40f4a96e5341ab9a4daec0871fd15c2d953833
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: removed unused member variable
Changed paths:
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index a0a5566b8b..ceb9770d98 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -409,8 +409,6 @@ public:
const int16 *const shadeAngleTab3;
- int16 vertexCoordinates[193]{0};
-
void setLightVector(int32 angleX, int32 angleY, int32 angleZ);
static void prepareIsoModel(uint8 *bodyPtr);
Commit: 3a6455a4340cb7404541388c70b06352dd3f0b74
https://github.com/scummvm/scummvm/commit/3a6455a4340cb7404541388c70b06352dd3f0b74
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: small helper method for model bone
Changed paths:
engines/twine/parser/body.h
diff --git a/engines/twine/parser/body.h b/engines/twine/parser/body.h
index fa01363153..1666f104e7 100644
--- a/engines/twine/parser/body.h
+++ b/engines/twine/parser/body.h
@@ -44,6 +44,10 @@ struct BodyBone {
uint16 vertex;
int32 numOfShades;
BoneFrame initalBoneState;
+
+ inline bool isRoot() const {
+ return parent == 0xffff;
+ }
};
struct BodyShade {
Commit: 5d137ee1ca868e8efff00bd81deffba8f994cd5f
https://github.com/scummvm/scummvm/commit/5d137ee1ca868e8efff00bd81deffba8f994cd5f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: extract to constants
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 80e6e23c70..6fb1423893 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -463,27 +463,30 @@ void Text::processTextLine() {
}
void Text::renderContinueReadingTriangle() {
- const int32 right = _dialTextBox.right - 3;
- const int32 left = _dialTextBox.right - 24;
- const int32 top = _dialTextBox.bottom - 24;
- const int32 bottom = _dialTextBox.bottom - 3;
+ const int32 border = 3;
+ const int32 size = 21;
+ const int16 color = 136;
+ const int32 right = _dialTextBox.right - border;
+ const int32 left = _dialTextBox.right - (size + border);
+ const int32 top = _dialTextBox.bottom - (size + border);
+ const int32 bottom = _dialTextBox.bottom - border;
Vertex vertices[3];
- vertices[0].colorIndex = 136;
+ vertices[0].colorIndex = color;
vertices[0].x = right;
vertices[0].y = top;
- vertices[1].colorIndex = 136;
+ vertices[1].colorIndex = color;
vertices[1].x = left;
vertices[1].y = bottom;
- vertices[2].colorIndex = 136;
+ vertices[2].colorIndex = color;
vertices[2].x = right;
vertices[2].y = bottom;
CmdRenderPolygon polygon;
- polygon.numVertices = 3;
+ polygon.numVertices = ARRAYSIZE(vertices);
polygon.colorIndex = _dialTextStopColor;
polygon.renderType = POLYGONTYPE_FLAT;
_engine->_renderer->renderPolygons(polygon, vertices);
Commit: 4f0040deff88f3da477f4f6f2e895b9b2cf8b5b3
https://github.com/scummvm/scummvm/commit/4f0040deff88f3da477f4f6f2e895b9b2cf8b5b3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: drawBehaviour cleanup
Changed paths:
engines/twine/menu/menu.cpp
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index bbf627017a..7989b1774c 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -905,9 +905,7 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, bool cantDraw
_engine->_interface->saveClip();
_engine->_interface->resetClip();
- if (behaviour != _engine->_actor->heroBehaviour) { // unselected
- _engine->_interface->drawSplittedBox(boxRect, 0);
- } else { // selected
+ if (behaviour == _engine->_actor->heroBehaviour) {
_engine->_interface->drawSplittedBox(boxRect, 69);
// behaviour menu title
@@ -920,6 +918,8 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, bool cantDraw
_engine->_text->getMenuText(_engine->_actor->getTextIdForBehaviour(), dialText, sizeof(dialText));
_engine->_text->drawText(SCREEN_WIDTH / 2 - _engine->_text->getTextSize(dialText) / 2, titleBoxTop + 1, dialText);
+ } else {
+ _engine->_interface->drawSplittedBox(boxRect, 0);
}
_engine->_renderer->renderBehaviourModel(boxRect, -600, angle, behaviourEntity);
Commit: 67dd46a07159c6080ec411177a0a9b4dce31155f
https://github.com/scummvm/scummvm/commit/67dd46a07159c6080ec411177a0a9b4dce31155f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: extended TextId enum
Changed paths:
engines/twine/text.h
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 1256854a66..2e35a1dfaa 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -59,6 +59,7 @@ enum _TextId {
kBehaviourHiding = 3,
kBehaviourAgressiveAuto = 4,
kUseProtopack = 5,
+ kSendell = 6,
kMusicVolume = 10,
kSoundVolume = 11,
kCDVolume = 12,
@@ -93,6 +94,11 @@ enum _TextId {
kDetailsPolygonsMiddle = 131,
kShadowsFigures = 132,
kScenaryZoomOn = 133,
+ kIntroText1 = 150,
+ kIntroText2 = 151,
+ kIntroText3 = 152,
+ kBookOfBu = 161,
+ kBonusList = 162,
kDetailsPolygonsLow = 231,
kShadowsDisabled = 232,
kNoScenaryZoom = 233
Commit: 3bc2447e449600ca3a61e7a583accbfab4dc72af
https://github.com/scummvm/scummvm/commit/3bc2447e449600ca3a61e7a583accbfab4dc72af
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: use TextId constants
Changed paths:
engines/twine/menu/menuoptions.cpp
engines/twine/script/script_life_v1.cpp
diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index 829677c3c0..49476bed3b 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -61,16 +61,16 @@ void MenuOptions::newGame() {
_engine->_text->textClipFull();
_engine->_text->setFontCrossColor(15);
- bool aborted = _engine->_text->drawTextFullscreen(150);
+ bool aborted = _engine->_text->drawTextFullscreen(TextId::kIntroText1);
// intro screen 2
if (!aborted) {
_engine->_screens->loadImage(RESSHQR_INTROSCREEN2IMG, RESSHQR_INTROSCREEN2PAL);
- aborted |= _engine->_text->drawTextFullscreen(151);
+ aborted |= _engine->_text->drawTextFullscreen(TextId::kIntroText2);
if (!aborted) {
_engine->_screens->loadImage(RESSHQR_INTROSCREEN3IMG, RESSHQR_INTROSCREEN3PAL);
- aborted |= _engine->_text->drawTextFullscreen(152);
+ aborted |= _engine->_text->drawTextFullscreen(TextId::kIntroText3);
}
}
_engine->cfgfile.FlagDisplayText = tmpFlagDisplayText;
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index f015a87c7c..4b84dbc756 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -1610,7 +1610,7 @@ static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_text->drawTextBoxBackground = false;
const bool tmpFlagDisplayText = engine->cfgfile.FlagDisplayText;
engine->cfgfile.FlagDisplayText = true;
- engine->_text->drawTextFullscreen(6);
+ engine->_text->drawTextFullscreen(TextId::kSendell);
engine->_text->drawTextBoxBackground = true;
engine->_text->textClipSmall();
engine->_screens->fadeToBlack(engine->_screens->paletteRGBACustom);
Commit: 3dfcdef67352dce514d24466692302c690f0028b
https://github.com/scummvm/scummvm/commit/3dfcdef67352dce514d24466692302c690f0028b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: extract to method
Changed paths:
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index da1cb742eb..b053777209 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -496,6 +496,36 @@ void TwinEEngine::processActorSamplePosition(int32 actorIdx) {
_sound->setSamplePosition(channelIdx, actor->x, actor->y, actor->z);
}
+void TwinEEngine::processBookOfBu() {
+ _screens->fadeToBlack(_screens->paletteRGBA);
+ _screens->loadImage(RESSHQR_INTROSCREEN1IMG, RESSHQR_INTROSCREEN1PAL);
+ _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
+ _text->drawTextBoxBackground = false;
+ _text->textClipFull();
+ _text->setFontCrossColor(15);
+ const bool tmpFlagDisplayText = cfgfile.FlagDisplayText;
+ cfgfile.FlagDisplayText = true;
+ _text->drawTextFullscreen(TextId::kBookOfBu);
+ cfgfile.FlagDisplayText = tmpFlagDisplayText;
+ _text->textClipSmall();
+ _text->drawTextBoxBackground = true;
+ _text->initSceneTextBank();
+ _screens->fadeToBlack(_screens->paletteRGBACustom);
+ _screens->clearScreen();
+ flip();
+ setPalette(_screens->paletteRGBA);
+ _screens->lockPalette = true;
+}
+
+void TwinEEngine::processBonusList() {
+ _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
+ _text->textClipFull();
+ _text->setFontCrossColor(15);
+ _text->drawTextFullscreen(TextId::kBonusList);
+ _text->textClipSmall();
+ _text->initSceneTextBank();
+}
+
void TwinEEngine::processInventoryAction() {
ScopedEngineFreeze scoped(this);
_menu->processInventoryMenu();
@@ -523,24 +553,7 @@ void TwinEEngine::processInventoryAction() {
}
break;
case kiBookOfBu: {
- _screens->fadeToBlack(_screens->paletteRGBA);
- _screens->loadImage(RESSHQR_INTROSCREEN1IMG, RESSHQR_INTROSCREEN1PAL);
- _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
- _text->drawTextBoxBackground = false;
- _text->textClipFull();
- _text->setFontCrossColor(15);
- const bool tmpFlagDisplayText = cfgfile.FlagDisplayText;
- cfgfile.FlagDisplayText = true;
- _text->drawTextFullscreen(161);
- cfgfile.FlagDisplayText = tmpFlagDisplayText;
- _text->textClipSmall();
- _text->drawTextBoxBackground = true;
- _text->initSceneTextBank();
- _screens->fadeToBlack(_screens->paletteRGBACustom);
- _screens->clearScreen();
- flip();
- setPalette(_screens->paletteRGBA);
- _screens->lockPalette = true;
+ processBookOfBu();
break;
}
case kiProtoPack:
@@ -582,12 +595,7 @@ void TwinEEngine::processInventoryAction() {
unfreezeTime();
_redraw->redrawEngineActions(true);
freezeTime();
- _text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
- _text->textClipFull();
- _text->setFontCrossColor(15);
- _text->drawTextFullscreen(162);
- _text->textClipSmall();
- _text->initSceneTextBank();
+ processBonusList();
break;
}
case kiCloverLeaf:
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 52c8ee4b16..c4e86e82a4 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -188,6 +188,8 @@ private:
TwineGameType _gameType;
EngineState _state = EngineState::Menu;
+ void processBookOfBu();
+ void processBonusList();
void processInventoryAction();
void processOptionsMenu();
/** recenter screen on followed actor automatically */
Commit: e414eaa208df0358bc0b09bc2a8dffcfc4a4cede
https://github.com/scummvm/scummvm/commit/e414eaa208df0358bc0b09bc2a8dffcfc4a4cede
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: doxygen
Changed paths:
engines/twine/text.h
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 2e35a1dfaa..d2e5acd6f4 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -108,9 +108,9 @@ enum _TextId {
#define TEXT_MAX_FADE_IN_CHR 32
enum class ProgressiveTextState {
- End = 0,
+ End = 0, /**< Text has reached its end and we are waiting for user input */
UNK1 = 1,
- NextPage = 2
+ NextPage = 2 /**< Waiting for user input to abort or start the next page to fade in */
};
class TwinEEngine;
Commit: e7eea92883876e7107c4956b17f7cf4f296ced7a
https://github.com/scummvm/scummvm/commit/e7eea92883876e7107c4956b17f7cf4f296ced7a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: extracted into own method
Changed paths:
engines/twine/text.cpp
engines/twine/text.h
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 6fb1423893..119ea48a25 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -602,6 +602,46 @@ ProgressiveTextState Text::updateProgressiveText() {
return ProgressiveTextState::UNK1;
}
+void Text::displayText(int32 index) {
+ // get right VOX entry index
+ initVoxToPlay(index);
+
+ initText(index);
+ initDialogueBox();
+
+ ProgressiveTextState textState = ProgressiveTextState::UNK1;
+ do {
+ ScopedFPS scopedFps(66);
+ _engine->readKeys();
+ textState = updateProgressiveText();
+
+ if (textState == ProgressiveTextState::NextPage) {
+ do {
+ ScopedFPS scopedFpsNextPage;
+ _engine->readKeys();
+ if (_engine->shouldQuit()) {
+ break;
+ }
+ if (!playVoxSimple(currDialTextEntry)) {
+ break;
+ }
+ } while (!_engine->_input->toggleAbortAction());
+ }
+ } while (textState != ProgressiveTextState::End);
+
+ while (playVoxSimple(currDialTextEntry)) {
+ ScopedFPS scopedFps;
+ if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
+ stopVox(currDialTextEntry);
+ break;
+ }
+ }
+
+ hasHiddenVox = false;
+ voxHiddenIndex = 0;
+ _hasValidTextHandle = false;
+}
+
// TODO: refactor this code
bool Text::drawTextFullscreen(int32 index) {
ScopedKeyMap scoped(_engine, cutsceneKeyMapId);
@@ -780,43 +820,7 @@ void Text::textClipSmall() {
}
void Text::drawAskQuestion(int32 index) {
- // get right VOX entry index
- initVoxToPlay(index);
-
- initText(index);
- initDialogueBox();
-
- ProgressiveTextState textState = ProgressiveTextState::UNK1;
- do {
- ScopedFPS scopedFps(66);
- _engine->readKeys();
- textState = updateProgressiveText();
-
- if (textState == ProgressiveTextState::NextPage) {
- do {
- ScopedFPS scopedFpsNextPage;
- _engine->readKeys();
- if (_engine->shouldQuit()) {
- break;
- }
- if (!playVoxSimple(currDialTextEntry)) {
- break;
- }
- } while (!_engine->_input->toggleAbortAction());
- }
- } while (textState != ProgressiveTextState::End);
-
- while (playVoxSimple(currDialTextEntry)) {
- ScopedFPS scopedFps;
- if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
- stopVox(currDialTextEntry);
- break;
- }
- }
-
- hasHiddenVox = false;
- voxHiddenIndex = 0;
- _hasValidTextHandle = false;
+ displayText(index);
}
} // namespace TwinE
diff --git a/engines/twine/text.h b/engines/twine/text.h
index d2e5acd6f4..8daee447e4 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -226,6 +226,8 @@ private:
int32 _dialTextBoxLines = 0; // dialogueBoxParam1
int32 _dialTextBoxMaxX = 0; // dialogueBoxParam2
+
+ bool displayText(int32 index);
public:
Text(TwinEEngine *engine);
~Text();
Commit: c652b4699978a2dd78a22a1142a4872afa5fb291
https://github.com/scummvm/scummvm/commit/c652b4699978a2dd78a22a1142a4872afa5fb291
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: prepare drawTextFullscreen to use diplayText
Changed paths:
engines/twine/text.cpp
engines/twine/text.h
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 119ea48a25..77f80c6ce0 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -602,9 +602,11 @@ ProgressiveTextState Text::updateProgressiveText() {
return ProgressiveTextState::UNK1;
}
-void Text::displayText(int32 index) {
- // get right VOX entry index
- initVoxToPlay(index);
+bool Text::displayText(int32 index, bool showText, bool playVox) {
+ if (playVox) {
+ // get right VOX entry index
+ initVoxToPlay(index);
+ }
initText(index);
initDialogueBox();
@@ -629,7 +631,7 @@ void Text::displayText(int32 index) {
}
} while (textState != ProgressiveTextState::End);
- while (playVoxSimple(currDialTextEntry)) {
+ while (playVox && playVoxSimple(currDialTextEntry)) {
ScopedFPS scopedFps;
if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
stopVox(currDialTextEntry);
@@ -640,6 +642,8 @@ void Text::displayText(int32 index) {
hasHiddenVox = false;
voxHiddenIndex = 0;
_hasValidTextHandle = false;
+
+ return false;
}
// TODO: refactor this code
@@ -820,7 +824,7 @@ void Text::textClipSmall() {
}
void Text::drawAskQuestion(int32 index) {
- displayText(index);
+ displayText(index, true, true);
}
} // namespace TwinE
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 8daee447e4..6994238645 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -227,7 +227,7 @@ private:
int32 _dialTextBoxLines = 0; // dialogueBoxParam1
int32 _dialTextBoxMaxX = 0; // dialogueBoxParam2
- bool displayText(int32 index);
+ bool displayText(int32 index, bool showText, bool playVox);
public:
Text(TwinEEngine *engine);
~Text();
Commit: 1d37d3d3a6040370d3d284bcee567146637a6847
https://github.com/scummvm/scummvm/commit/1d37d3d3a6040370d3d284bcee567146637a6847
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: fixed processing of @ (newline) followed by another newline
this is visible on the third page of the intro text
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 77f80c6ce0..dee1e3fc2e 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -421,7 +421,7 @@ void Text::processTextLine() {
if (lineBreakX == 0) {
lineBreakX = 7;
*(_progressiveTextBuffer + 0) = ' ';
- *(_progressiveTextBuffer + 1) = ' ';
+ *(_progressiveTextBuffer + 1) = '\0';
}
// new page?
if (wordBuf[1] == 'P') {
Commit: ff56096ea3f06b7bf30fe4dc74ae8b86e545111b
https://github.com/scummvm/scummvm/commit/ff56096ea3f06b7bf30fe4dc74ae8b86e545111b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: format the code
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index dee1e3fc2e..ddbef87514 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -27,13 +27,14 @@
#include "common/scummsys.h"
#include "common/str.h"
#include "common/system.h"
+#include "common/util.h"
#include "twine/audio/sound.h"
-#include "twine/resources/hqr.h"
#include "twine/input.h"
#include "twine/menu/interface.h"
#include "twine/menu/menu.h"
#include "twine/renderer/renderer.h"
#include "twine/renderer/screens.h"
+#include "twine/resources/hqr.h"
#include "twine/resources/resources.h"
#include "twine/scene/scene.h"
#include "twine/twine.h"
@@ -214,7 +215,7 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
} while (1);
}
-void Text::drawCharacterShadow(int32 x, int32 y, uint8 character, int32 color, Common::Rect& dirtyRect) { // drawDoubleLetter
+void Text::drawCharacterShadow(int32 x, int32 y, uint8 character, int32 color, Common::Rect &dirtyRect) { // drawDoubleLetter
if (character == ' ') {
return;
}
@@ -242,7 +243,7 @@ void Text::drawText(int32 x, int32 y, const char *dialogue) {
}
do {
- const uint8 currChar = (uint8) *dialogue++; // read the next char from the string
+ const uint8 currChar = (uint8)*dialogue++; // read the next char from the string
if (currChar == '\0') {
break;
}
Commit: 0b37e42a04ec5fb08c4c29f3f24e07e0262872c7
https://github.com/scummvm/scummvm/commit/0b37e42a04ec5fb08c4c29f3f24e07e0262872c7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: refactored the text rendering
there is a problem left with not 100% faded in characters at the end of the page
Changed paths:
engines/twine/menu/menu.cpp
engines/twine/scene/gamestate.cpp
engines/twine/text.cpp
engines/twine/text.h
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index 7989b1774c..6490bb3ec5 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -1105,12 +1105,11 @@ void Menu::processInventoryMenu() {
_engine->_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
- bool updateItemText = true;
-
_engine->_text->setFontCrossColor(4);
_engine->_text->initDialogueBox();
- ProgressiveTextState textState = ProgressiveTextState::End;
+ ProgressiveTextState textState = ProgressiveTextState::ContinueRunning;
+ bool updateItemText = true;
#if 0
ScopedCursor scopedCursor(_engine);
@@ -1167,22 +1166,22 @@ void Menu::processInventoryMenu() {
} else {
_engine->_text->initInventoryText(NUM_INVENTORY_ITEMS);
}
+ textState = ProgressiveTextState::ContinueRunning;
+ updateItemText = false;
}
- if (updateItemText || textState != ProgressiveTextState::NextPage) {
+ if (textState == ProgressiveTextState::ContinueRunning) {
textState = _engine->_text->updateProgressiveText();
- updateItemText = false;
}
if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
+ // restart the item description to appear from the beginning
+ if (textState == ProgressiveTextState::End) {
+ updateItemText = true;
+ }
if (textState == ProgressiveTextState::NextPage) {
_engine->_text->initInventoryDialogueBox();
- textState = ProgressiveTextState::End;
- } else {
- if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)inventorySelectedItem) && !_engine->_gameState->inventoryDisabled()) {
- _engine->_text->initInventoryDialogueBox();
- _engine->_text->initInventoryText(inventorySelectedItem);
- }
+ textState = ProgressiveTextState::ContinueRunning;
}
}
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index e5eb4c7f4b..fbe4e2be46 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -314,7 +314,7 @@ void GameState::processFoundItem(int32 item) {
_engine->_text->initItemFoundText(item);
_engine->_text->initDialogueBox();
- ProgressiveTextState textState = ProgressiveTextState::UNK1;
+ ProgressiveTextState textState = ProgressiveTextState::ContinueRunning;
_engine->_text->initVoxToPlay(item);
@@ -361,7 +361,7 @@ void GameState::processFoundItem(int32 item) {
_engine->_grid->drawOverModelActor(itemX, itemY, itemZ);
_engine->_redraw->addRedrawArea(_engine->_redraw->renderRect);
- if (textState != ProgressiveTextState::End) {
+ if (textState == ProgressiveTextState::ContinueRunning) {
_engine->_interface->resetClip();
textState = _engine->_text->updateProgressiveText();
}
@@ -376,10 +376,11 @@ void GameState::processFoundItem(int32 item) {
if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
if (textState == ProgressiveTextState::End) {
+ _engine->_text->stopVox(_engine->_text->currDialTextEntry);
break;
}
if (textState == ProgressiveTextState::NextPage) {
- textState = ProgressiveTextState::UNK1;
+ textState = ProgressiveTextState::ContinueRunning;
}
}
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index ddbef87514..256a4555a9 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -327,13 +327,14 @@ void Text::initText(int32 index) {
_progressiveTextBuffer[0] = '\0';
_fadeInCharactersPos = 0;
_dialTextXPos = _dialTextBox.left + 8;
- _progressiveTextEnd = false;
- _progressiveTextNextPage = false;
_dialTextYPos = _dialTextBox.top + 8;
_currentTextPosition = _currDialTextPtr;
// lba font is get while engine start
setFontParameters(2, 7);
+
+ // fetch the first line
+ processTextLine();
}
void Text::initProgressiveTextBuffer() {
@@ -435,7 +436,7 @@ void Text::processTextLine() {
buffer += wordSize.inChar;
_currentTextPosition = buffer;
strncat(_progressiveTextBuffer, wordBuf, sizeof(_progressiveTextBuffer) - strlen(_progressiveTextBuffer) - 1);
- strncat(_progressiveTextBuffer, " ", sizeof(_progressiveTextBuffer) - strlen(_progressiveTextBuffer) - 1); // not 100% accurate
+ strncat(_progressiveTextBuffer, " ", sizeof(_progressiveTextBuffer) - strlen(_progressiveTextBuffer) - 1);
spaceCharCount++;
lineBreakX += wordSize.inPixel + _dialCharSpace;
@@ -526,41 +527,20 @@ int32 Text::getCharHeight(uint8 chr) const {
return stream.readByte();
}
-// TODO: refactor this code
ProgressiveTextState Text::updateProgressiveText() {
if (!_hasValidTextHandle) {
return ProgressiveTextState::End;
}
if (*_progressiveTextBufferPtr == '\0') {
- if (_progressiveTextEnd) {
- if (renderTextTriangle) {
- renderContinueReadingTriangle();
- }
- _hasValidTextHandle = false;
- return ProgressiveTextState::End;
- }
- if (_progressiveTextNextPage) {
- _engine->_interface->blitBox(_dialTextBox, _engine->workVideoBuffer, _engine->frontVideoBuffer);
- _engine->copyBlockPhys(_dialTextBox);
- _fadeInCharactersPos = 0;
- _progressiveTextNextPage = false;
- _dialTextXPos = _dialTextBox.left + 8;
- _dialTextYPos = _dialTextBox.top + 8;
- }
- if (*_currentTextPosition == '\0') {
- initProgressiveTextBuffer();
- _progressiveTextEnd = true;
- return ProgressiveTextState::UNK1;
- }
+ initProgressiveTextBuffer();
processTextLine();
+ initDialogueBox();
+ _dialTextXPos = _dialTextBox.left + 8;
+ _dialTextYPos = _dialTextBox.top + 8;
}
const char currentChar = *_progressiveTextBufferPtr;
- // RECHECK this later
- if (currentChar == '\0') {
- return ProgressiveTextState::UNK1;
- }
-
+ assert(currentChar != '\0');
fillFadeInBuffer(_dialTextXPos, _dialTextYPos, currentChar);
fadeInCharacters(_fadeInCharactersPos, _dialTextStartColor);
const int8 charWidth = getCharWidth(currentChar);
@@ -576,31 +556,30 @@ ProgressiveTextState Text::updateProgressiveText() {
// reaching 0-byte means a new line - as we are fading in per line
if (*_progressiveTextBufferPtr != '\0') {
- return ProgressiveTextState::UNK1;
+ return ProgressiveTextState::ContinueRunning;
}
+ if (*_currentTextPosition == '\0') {
+ _hasValidTextHandle = false;
+ renderContinueReadingTriangle();
+ return ProgressiveTextState::End;
+ }
+
+ // reached a new line that is about get faded in
+ _dialTextBoxCurrentLine++;
+
const int32 lineHeight = 38;
_dialTextYPos += lineHeight;
_dialTextXPos = _dialTextBox.left + 8;
- if (_progressiveTextNextPage && !_progressiveTextEnd) {
+ if (_dialTextBoxCurrentLine > _dialTextBoxLines) {
renderContinueReadingTriangle();
return ProgressiveTextState::NextPage;
}
- _dialTextBoxCurrentLine++;
- if (_dialTextBoxCurrentLine < _dialTextBoxLines) {
- return ProgressiveTextState::UNK1;
- }
+ processTextLine();
- initProgressiveTextBuffer();
- _progressiveTextNextPage = true;
-
- if (*_currentTextPosition == '\0') {
- _progressiveTextEnd = true;
- }
-
- return ProgressiveTextState::UNK1;
+ return ProgressiveTextState::ContinueRunning;
}
bool Text::displayText(int32 index, bool showText, bool playVox) {
@@ -609,108 +588,58 @@ bool Text::displayText(int32 index, bool showText, bool playVox) {
initVoxToPlay(index);
}
- initText(index);
- initDialogueBox();
+ bool aborted = false;
- ProgressiveTextState textState = ProgressiveTextState::UNK1;
- do {
- ScopedFPS scopedFps(66);
- _engine->readKeys();
- textState = updateProgressiveText();
+ // if we don't display text, than still plays vox file
+ if (showText) {
+ initText(index);
+ initDialogueBox();
- if (textState == ProgressiveTextState::NextPage) {
- do {
- ScopedFPS scopedFpsNextPage;
- _engine->readKeys();
- if (_engine->shouldQuit()) {
+ ProgressiveTextState textState = ProgressiveTextState::ContinueRunning;
+ for (;;) {
+ ScopedFPS scopedFps(66);
+ _engine->readKeys();
+ if (textState == ProgressiveTextState::ContinueRunning) {
+ textState = updateProgressiveText();
+ }
+ if (_engine->_input->toggleActionIfActive(TwinEActionType::UINextPage)) {
+ if (textState == ProgressiveTextState::End) {
+ stopVox(currDialTextEntry);
break;
}
- if (!playVoxSimple(currDialTextEntry)) {
- break;
+ if (textState == ProgressiveTextState::NextPage) {
+ textState = ProgressiveTextState::ContinueRunning;
}
- } while (!_engine->_input->toggleAbortAction());
+ }
+ if (_engine->_input->toggleAbortAction() || _engine->shouldQuit()) {
+ stopVox(currDialTextEntry);
+ aborted = true;
+ break;
+ }
}
- } while (textState != ProgressiveTextState::End);
-
- while (playVox && playVoxSimple(currDialTextEntry)) {
+ }
+ while (_engine->_sound->isSamplePlaying(currDialTextEntry)) {
ScopedFPS scopedFps;
+ _engine->readKeys();
if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
stopVox(currDialTextEntry);
+ aborted = true;
break;
}
}
-
- hasHiddenVox = false;
voxHiddenIndex = 0;
+ hasHiddenVox = false;
_hasValidTextHandle = false;
- return false;
+ return aborted;
}
// TODO: refactor this code
bool Text::drawTextFullscreen(int32 index) {
- ScopedKeyMap scoped(_engine, cutsceneKeyMapId);
_engine->_interface->saveClip();
_engine->_interface->resetClip();
_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
-
- // get right VOX entry index
- initVoxToPlay(index);
-
- bool aborted = false;
-
- // if we don't display text, than still plays vox file
- if (_engine->cfgfile.FlagDisplayText) {
- initText(index);
- initDialogueBox();
-
- ProgressiveTextState textState;
- for (;;) {
- ScopedFPS scopedFps(66);
- _engine->readKeys();
- textState = updateProgressiveText();
- playVox(currDialTextEntry);
-
- if (textState == ProgressiveTextState::End && !_engine->_sound->isSamplePlaying(currDialTextEntry)) {
- break;
- }
-
- if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
- aborted = true;
- break;
- }
- }
- hasHiddenVox = false;
-
- _hasValidTextHandle = false;
-
- if (textState == ProgressiveTextState::End) {
- stopVox(currDialTextEntry);
- // wait displaying text
- for (;;) {
- ScopedFPS scopedFps;
- _engine->readKeys();
- if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
- aborted = true;
- break;
- }
- }
- }
- } else { // RECHECK THIS
- while (playVox(currDialTextEntry)) {
- ScopedFPS scopedFps;
- _engine->readKeys();
- if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
- aborted = true;
- break;
- }
- }
- hasHiddenVox = false;
- voxHiddenIndex = 0;
- }
-
- stopVox(currDialTextEntry);
-
+ const bool aborted = displayText(index, _engine->cfgfile.FlagDisplayText, true);
_engine->_interface->loadClip();
return aborted;
}
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 6994238645..2b12e51e9e 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -109,7 +109,7 @@ enum _TextId {
enum class ProgressiveTextState {
End = 0, /**< Text has reached its end and we are waiting for user input */
- UNK1 = 1,
+ ContinueRunning = 1, /**< Text is fading in */
NextPage = 2 /**< Waiting for user input to abort or start the next page to fade in */
};
@@ -183,8 +183,6 @@ private:
char *_progressiveTextBufferPtr = nullptr;
int32 _dialTextBoxCurrentLine = 0;
- bool _progressiveTextEnd = false;
- bool _progressiveTextNextPage = false;
struct BlendInCharacter {
int16 chr = 0;
int16 x = 0;
Commit: 72486eb17923f50106e4e18f851812024b6d89a9
https://github.com/scummvm/scummvm/commit/72486eb17923f50106e4e18f851812024b6d89a9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: removed todo comment + const
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 256a4555a9..c7bde28e2f 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -169,7 +169,8 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
Common::MemoryReadStream stream(_engine->_resources->fontPtr, _engine->_resources->fontBufSize);
stream.seek(character * 4);
stream.seek(stream.readSint16LE());
- stream.skip(2);
+ /*uint8 charWidth =*/ stream.readByte();
+ /*uint8 charHeight =*/ stream.readByte();
x += stream.readByte();
y += stream.readByte();
@@ -191,7 +192,7 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
}
break;
}
- uint8 number = stream.readByte();
+ const uint8 number = stream.readByte();
tempX += jump;
for (uint8 i = 0; i < number; i++) {
if (tempX >= SCREEN_TEXTLIMIT_LEFT && tempX < SCREEN_TEXTLIMIT_RIGHT && tempY >= SCREEN_TEXTLIMIT_TOP && tempY < SCREEN_TEXTLIMIT_BOTTOM) {
@@ -634,7 +635,6 @@ bool Text::displayText(int32 index, bool showText, bool playVox) {
return aborted;
}
-// TODO: refactor this code
bool Text::drawTextFullscreen(int32 index) {
_engine->_interface->saveClip();
_engine->_interface->resetClip();
Commit: d91019ff31ee1edec7bcb6119a3025f9235c7219
https://github.com/scummvm/scummvm/commit/d91019ff31ee1edec7bcb6119a3025f9235c7219
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: starting to refactor Text::drawCharacter
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index c7bde28e2f..b353acb346 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -165,12 +165,11 @@ void Text::initSceneTextBank() {
}
void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
- uint8 sizeY = getCharHeight(character);
Common::MemoryReadStream stream(_engine->_resources->fontPtr, _engine->_resources->fontBufSize);
stream.seek(character * 4);
stream.seek(stream.readSint16LE());
/*uint8 charWidth =*/ stream.readByte();
- /*uint8 charHeight =*/ stream.readByte();
+ const uint8 sizeY = stream.readByte();
x += stream.readByte();
y += stream.readByte();
@@ -179,17 +178,13 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
int32 tempX = x;
int32 tempY = y;
- do {
+ for (uint8 fontY = 0; fontY < sizeY; ++fontY) {
uint8 index = stream.readByte();
do {
const uint8 jump = stream.readByte();
if (--index == 0) {
tempY++;
tempX = x;
- sizeY--;
- if (sizeY <= 0) {
- return;
- }
break;
}
const uint8 number = stream.readByte();
@@ -205,15 +200,10 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
if (--index == 0) {
tempY++;
tempX = x;
-
- sizeY--;
- if (sizeY <= 0) {
- return;
- }
break;
}
} while (1);
- } while (1);
+ }
}
void Text::drawCharacterShadow(int32 x, int32 y, uint8 character, int32 color, Common::Rect &dirtyRect) { // drawDoubleLetter
Commit: bb6f37394ee4ce556f9ee2bc39b71c6adcb4a797
https://github.com/scummvm/scummvm/commit/bb6f37394ee4ce556f9ee2bc39b71c6adcb4a797
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: minor optimization of Text::drawCharacter
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index b353acb346..ad561b023f 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -189,11 +189,13 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
}
const uint8 number = stream.readByte();
tempX += jump;
+ uint8* basePtr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(tempX, tempY);
for (uint8 i = 0; i < number; i++) {
if (tempX >= SCREEN_TEXTLIMIT_LEFT && tempX < SCREEN_TEXTLIMIT_RIGHT && tempY >= SCREEN_TEXTLIMIT_TOP && tempY < SCREEN_TEXTLIMIT_BOTTOM) {
- *((uint8 *)_engine->frontVideoBuffer.getBasePtr(tempX, tempY)) = usedColor;
+ *basePtr = usedColor;
}
+ ++basePtr;
tempX++;
}
Commit: 315ee1a530eee5f15bf289886eda109eec796719
https://github.com/scummvm/scummvm/commit/315ee1a530eee5f15bf289886eda109eec796719
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-29T00:16:46+01:00
Commit Message:
TWINE: const
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index ad561b023f..90b19b9415 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -244,7 +244,7 @@ void Text::drawText(int32 x, int32 y, const char *dialogue) {
if (currChar == ' ') {
x += _dialCharSpace;
} else {
- int32 dialTextSize = getCharWidth(currChar);
+ const int32 dialTextSize = getCharWidth(currChar);
drawCharacter(x, y, currChar); // draw the character on screen
// add the length of the space between 2 characters
x += _dialSpaceBetween;
@@ -259,7 +259,7 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
do {
const uint8 currChar = (uint8) * (dialogue++);
- if (currChar == 0) {
+ if (currChar == '\0') {
break;
}
More information about the Scummvm-git-logs
mailing list