[Scummvm-git-logs] scummvm master -> 8e5afba3791260df58b78b85cd53dc64fe068f51
mgerhardy
noreply at scummvm.org
Sun Jan 22 17:51:17 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5ccbc0d472 TWINE: handle lba2 holomap locations
8e5afba379 TWINE: handle lba2 game chapter
Commit: 5ccbc0d4727f0622b4c79dcf6a3a8e422766a5ed
https://github.com/scummvm/scummvm/commit/5ccbc0d4727f0622b4c79dcf6a3a8e422766a5ed
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-22T18:48:19+01:00
Commit Message:
TWINE: handle lba2 holomap locations
Changed paths:
engines/twine/debugger/console.cpp
engines/twine/detection.cpp
engines/twine/holomap.cpp
engines/twine/menu/menuoptions.cpp
engines/twine/resources/resources.h
engines/twine/scene/gamestate.cpp
engines/twine/scene/gamestate.h
engines/twine/shared.h
engines/twine/twine.h
diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index 2fd3c3aa1b0..b2e4e9b1fe1 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -288,14 +288,14 @@ bool TwinEConsole::doPrintInventoryFlag(int argc, const char **argv) {
bool TwinEConsole::doPrintHolomapFlag(int argc, const char **argv) {
if (argc <= 1) {
- for (int i = 0; i < NUM_LOCATIONS; ++i) {
+ for (int i = 0; i < _engine->numLocations(); ++i) {
debugPrintf("[%03d] = %d\n", i, _engine->_gameState->_holomapFlags[i]);
}
return true;
}
- const uint8 idx = atoi(argv[1]);
- if (idx < NUM_LOCATIONS) {
+ const uint16 idx = atoi(argv[1]);
+ if (idx < _engine->numLocations()) {
debugPrintf("[%03d] = %d\n", idx, _engine->_gameState->_holomapFlags[idx]);
}
diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index a5af5358711..cffef0aa498 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -407,6 +407,7 @@ static const ADGameDescription twineGameDescriptions[] = {
// LBA2.EXE
// 4 Sep 2004 at 18:44
TWINE_DETECTION_ENTRY("lba2", "CD Original European Version", AD_ENTRY1s("LBA2.EXE", "ba915d65b3c7a743a87804f73f29675b", 616448), Common::kPlatformDOS, ADGF_UNSTABLE),
+ TWINE_DETECTION_ENTRY("lba2", "CD Original European Version", AD_ENTRY1s("text.hqr", "dafcec7d9f1b2ab4a12d478786eb0f61", 443010), Common::kPlatformDOS, ADGF_UNSTABLE),
AD_TABLE_END_MARKER
};
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 7ece1e2eed7..73917c708c4 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -85,8 +85,8 @@ bool Holomap::loadLocations() {
Common::MemoryReadStream stream(locationsPtr, locationsSize, DisposeAfterUse::YES);
_numLocations = locationsSize / 8;
- if (_numLocations > NUM_LOCATIONS) {
- warning("Amount of locations (%i) exceeds the maximum of %i", _numLocations, NUM_LOCATIONS);
+ if (_numLocations > _engine->numLocations()) {
+ warning("Amount of locations (%i) exceeds the maximum of %i", _numLocations, _engine->numLocations());
return false;
}
@@ -432,11 +432,12 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
int32 Holomap::searchNextArrow(int32 currentLocation, int32 dir) const {
const int32 idx = currentLocation;
+ const int maxLocations = _engine->numLocations();
for (int32 i = currentLocation + dir; i != idx; i += dir) {
if (i < 0) {
- i = NUM_LOCATIONS - 1;
+ i = maxLocations - 1;
} else {
- i %= NUM_LOCATIONS;
+ i %= maxLocations;
}
if ((_engine->_gameState->_holomapFlags[i] & HOLOMAP_ACTIVE) != 0u) {
return i;
diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index 854c8d1f275..94034f0755d 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -48,42 +48,46 @@ void MenuOptions::newGame() {
_engine->_music->stopMusic();
_engine->_sound->stopSamples();
- int32 tmpFlagDisplayText = _engine->_cfgfile.FlagDisplayText;
- _engine->_cfgfile.FlagDisplayText = true;
+ if (_engine->isLBA1()) {
+ int32 tmpFlagDisplayText = _engine->_cfgfile.FlagDisplayText;
+ _engine->_cfgfile.FlagDisplayText = true;
- // intro screen 1 - twinsun
- _engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 15, 16));
+ // intro screen 1 - twinsun
+ _engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 15, 16));
- _engine->_text->_drawTextBoxBackground = false;
- _engine->_text->_renderTextTriangle = true;
+ _engine->_text->_drawTextBoxBackground = false;
+ _engine->_text->_renderTextTriangle = true;
- _engine->_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
- _engine->_text->textClipFull();
- _engine->_text->setFontCrossColor(COLOR_WHITE);
+ _engine->_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
+ _engine->_text->textClipFull();
+ _engine->_text->setFontCrossColor(COLOR_WHITE);
- bool aborted = _engine->_text->drawTextProgressive(TextId::kIntroText1);
-
- // intro screen 2
- if (!aborted) {
- _engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 17, 18));
- aborted |= _engine->_text->drawTextProgressive(TextId::kIntroText2);
+ bool aborted = _engine->_text->drawTextProgressive(TextId::kIntroText1);
+ // intro screen 2
if (!aborted) {
- _engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 19, 20));
- aborted |= _engine->_text->drawTextProgressive(TextId::kIntroText3);
+ _engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 17, 18));
+ aborted |= _engine->_text->drawTextProgressive(TextId::kIntroText2);
+
+ if (!aborted) {
+ _engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 19, 20));
+ aborted |= _engine->_text->drawTextProgressive(TextId::kIntroText3);
+ }
}
- }
- _engine->_cfgfile.FlagDisplayText = tmpFlagDisplayText;
+ _engine->_cfgfile.FlagDisplayText = tmpFlagDisplayText;
- _engine->_screens->fadeToBlack(_engine->_screens->_paletteRGBACustom);
- _engine->_screens->clearScreen();
+ _engine->_screens->fadeToBlack(_engine->_screens->_paletteRGBACustom);
+ _engine->_screens->clearScreen();
- if (!aborted) {
- _engine->_music->playMidiMusic(1);
- _engine->_movie->playMovie(FLA_INTROD);
- }
+ if (!aborted) {
+ _engine->_music->playMidiMusic(1);
+ _engine->_movie->playMovie(FLA_INTROD);
+ }
- _engine->_text->textClipSmall();
+ _engine->_text->textClipSmall();
+ } else {
+ _engine->_movie->playMovie(ACF_INTRO);
+ }
_engine->_screens->clearScreen();
_engine->_text->_drawTextBoxBackground = true;
diff --git a/engines/twine/resources/resources.h b/engines/twine/resources/resources.h
index 7d4486719ed..b5d681cafbf 100644
--- a/engines/twine/resources/resources.h
+++ b/engines/twine/resources/resources.h
@@ -64,6 +64,8 @@ namespace TwinE {
#define FLA_THEEND "the_end"
#define FLA_BATEAU "bateau"
+#define ACF_INTRO "INTRO"
+
#define FILE3DHQR_HERONORMAL 0
#define FILE3DHQR_HEROATHLETIC 1
#define FILE3DHQR_HEROAGGRESSIVE 2
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 9fae01faa43..1c3b5d0fa3d 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -198,11 +198,11 @@ bool GameState::loadGame(Common::SeekableReadStream *file) {
_engine->_scene->_sceneHero->_genBody = (BodyType)file->readByte();
const byte numHolomapFlags = file->readByte(); // number of holomap locations
- if (numHolomapFlags != NUM_LOCATIONS) {
- warning("Failed to load holomapflags. Got %u, expected %i", numHolomapFlags, NUM_LOCATIONS);
+ if (numHolomapFlags != _engine->numLocations()) {
+ warning("Failed to load holomapflags. Got %u, expected %i", numHolomapFlags, _engine->numLocations());
return false;
}
- file->read(_holomapFlags, NUM_LOCATIONS);
+ file->read(_holomapFlags, _engine->numLocations());
setGas(file->readByte());
@@ -265,8 +265,8 @@ bool GameState::saveGame(Common::WriteStream *file) {
file->writeByte((uint8)_engine->_scene->_sceneHero->_genBody);
// number of holomap locations
- file->writeByte(NUM_LOCATIONS);
- file->write(_holomapFlags, NUM_LOCATIONS);
+ file->writeByte(_engine->numLocations());
+ file->write(_holomapFlags, _engine->numLocations());
file->writeByte(_inventoryNumGas);
diff --git a/engines/twine/scene/gamestate.h b/engines/twine/scene/gamestate.h
index 95bb78c4d0f..c40591719f0 100644
--- a/engines/twine/scene/gamestate.h
+++ b/engines/twine/scene/gamestate.h
@@ -93,6 +93,7 @@ public:
* 14: - still looking for plans
* 15: The final showdown - "good day"
*/
+ // TODO: this is 253 gameflag in lba2
int16 _gameChapter = 0;
/** Magic ball type index */
@@ -128,7 +129,7 @@ public:
*/
uint8 _inventoryFlags[NUM_INVENTORY_ITEMS];
- uint8 _holomapFlags[NUM_LOCATIONS]; // GV14
+ uint8 _holomapFlags[NUM_LOCATIONS];
char _sceneName[30] {};
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index a4d3ace45ff..4258552d105 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -29,7 +29,7 @@
/** Number of colors used in the game */
#define NUMOFCOLORS 256
-#define NUM_LOCATIONS 150
+#define NUM_LOCATIONS 334 /* 150 for lba1 */
#define NUM_INVENTORY_ITEMS 28
/**
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 3093159e713..9a7c6fe9bf2 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -39,6 +39,7 @@
#include "twine/scene/actor.h"
#include "twine/script/script_life.h"
#include "twine/script/script_move.h"
+#include "twine/shared.h"
namespace TwinE {
@@ -263,6 +264,11 @@ public:
const char *getGameId() const;
Common::Language getGameLang() const;
+ inline int numLocations() const {
+ const int maxLocations = isLBA1() ? 150 : NUM_LOCATIONS;
+ return maxLocations;
+ }
+
bool unlockAchievement(const Common::String &id);
Actor *_actor;
Commit: 8e5afba3791260df58b78b85cd53dc64fe068f51
https://github.com/scummvm/scummvm/commit/8e5afba3791260df58b78b85cd53dc64fe068f51
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-22T18:48:20+01:00
Commit Message:
TWINE: handle lba2 game chapter
Changed paths:
engines/twine/debugger/console.cpp
engines/twine/scene/gamestate.cpp
engines/twine/scene/gamestate.h
engines/twine/script/script_life.cpp
diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index b2e4e9b1fe1..d298cc7a67c 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -430,8 +430,8 @@ bool TwinEConsole::doChangeChapter(int argc, const char **argv) {
debugPrintf("Expected to get a chapter index as first parameter\n");
return true;
}
- debugPrintf("Old chapter was: %i\n", _engine->_gameState->_gameChapter);
- _engine->_gameState->_gameChapter = (int16)atoi(argv[1]);
+ debugPrintf("Old chapter was: %i\n", _engine->_gameState->getChapter());
+ _engine->_gameState->setChapter(atoi(argv[1]));
return true;
}
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 1c3b5d0fa3d..b40f3bbb1a1 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -134,7 +134,7 @@ void GameState::initEngineVars() {
_magicLevelIdx = 0;
_usingSabre = false;
- _gameChapter = 0;
+ setChapter(0);
_engine->_scene->_sceneTextBank = TextBankId::Options_and_menus;
_engine->_scene->_currentlyFollowedActor = OWN_ACTOR_SCENE_INDEX;
@@ -181,7 +181,7 @@ bool GameState::loadGame(Common::SeekableReadStream *file) {
setGameFlag(i, file->readByte());
}
_engine->_scene->_needChangeScene = file->readByte(); // scene index
- _gameChapter = file->readByte();
+ setChapter(file->readByte());
_engine->_actor->_heroBehaviour = (HeroBehaviourType)file->readByte();
_engine->_actor->_previousHeroBehaviour = _engine->_actor->_heroBehaviour;
@@ -249,7 +249,7 @@ bool GameState::saveGame(Common::WriteStream *file) {
file->writeByte(hasGameFlag(i));
}
file->writeByte(sceneIdx);
- file->writeByte(_gameChapter);
+ file->writeByte(getChapter());
file->writeByte((byte)_engine->_actor->_heroBehaviour);
file->writeByte(_engine->_scene->_sceneHero->_lifePoint);
file->writeSint16LE(_goldPieces);
@@ -281,6 +281,21 @@ bool GameState::saveGame(Common::WriteStream *file) {
return true;
}
+void GameState::setChapter(int16 chapter) {
+ if (_engine->isLBA1()) {
+ _gameChapter = chapter;
+ return;
+ }
+ setGameFlag(253, chapter);
+}
+
+int16 GameState::getChapter() const {
+ if (_engine->isLBA1()) {
+ return _gameChapter;
+ }
+ return _gameStateFlags[253];
+}
+
void GameState::setGameFlag(uint8 index, uint8 value) {
if (_gameStateFlags[index] == value) {
return;
diff --git a/engines/twine/scene/gamestate.h b/engines/twine/scene/gamestate.h
index c40591719f0..c2126b060b7 100644
--- a/engines/twine/scene/gamestate.h
+++ b/engines/twine/scene/gamestate.h
@@ -70,6 +70,8 @@ private:
*/
// TODO: why not NUM_GAME_FLAGS?
uint8 _gameStateFlags[256];
+ // only lba1 - lba2 uses 253 gameflag
+ int16 _gameChapter = 0;
public:
GameState(TwinEEngine *engine);
@@ -93,8 +95,8 @@ public:
* 14: - still looking for plans
* 15: The final showdown - "good day"
*/
- // TODO: this is 253 gameflag in lba2
- int16 _gameChapter = 0;
+ void setChapter(int16 chapter);
+ int16 getChapter() const;
/** Magic ball type index */
int16 _magicBall = 0;
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 1f07e2d6f23..676012fc609 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -316,7 +316,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
break;
case kcCHAPTER:
debugCN(3, kDebugLevels::kDebugScripts, "chapter(");
- engine->_scene->_currentScriptValue = engine->_gameState->_gameChapter;
+ engine->_scene->_currentScriptValue = engine->_gameState->getChapter();
break;
case kcDISTANCE_3D: {
int32 targetActorIdx;
@@ -1214,8 +1214,8 @@ int32 ScriptLife::lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
*/
int32 ScriptLife::lINC_CHAPTER(TwinEEngine *engine, LifeScriptContext &ctx) {
debugC(3, kDebugLevels::kDebugScripts, "LIFE::INC_CHAPTER()");
- engine->_gameState->_gameChapter++;
- debug("Switched chapter to %i", engine->_gameState->_gameChapter);
+ engine->_gameState->setChapter(engine->_gameState->getChapter() + 1);
+ debug("Switched chapter to %i", engine->_gameState->getChapter());
return 0;
}
More information about the Scummvm-git-logs
mailing list