[Scummvm-git-logs] scummvm master -> 5ae5a557b8efcb90f7f53c3eec7a233319776f54
mgerhardy
martin.gerhardy at gmail.com
Sun Aug 1 18:29:21 UTC 2021
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3d8e34b756 TWINE: time freeze cleanup
86a5627051 TWINE: fixed disabled code
627e557828 TWINE: todo comments
37bbfeb6ee TWINE: sanity check for trajectory data array access
5ae5a557b8 TWINE: fixed game loop in Holomap::drawHolomapTrajectory
Commit: 3d8e34b756d997992a929df236fbc534226daee2
https://github.com/scummvm/scummvm/commit/3d8e34b756d997992a929df236fbc534226daee2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-01T20:28:02+02:00
Commit Message:
TWINE: time freeze cleanup
Changed paths:
engines/twine/scene/scene.cpp
engines/twine/script/script_life_v1.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 002aed1c66..2562f1af45 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -722,12 +722,11 @@ void Scene::processActorZones(int32 actorIdx) {
break;
case ZoneType::kText:
if (IS_HERO(actorIdx) && _engine->_movements->shouldTriggerZoneAction()) {
- _engine->freezeTime();
+ ScopedEngineFreeze scopedFreeze(_engine);
_engine->exitSceneryView();
_engine->_text->setFontCrossColor(zone->infoData.DisplayText.textColor);
_talkingActor = actorIdx;
_engine->_text->drawTextProgressive(zone->infoData.DisplayText.textIdx);
- _engine->unfreezeTime();
_engine->_redraw->redrawEngineActions(true);
}
break;
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index 97e87a7975..786d638429 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -649,7 +649,7 @@ static int32 lSET_TRACK_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
const TextId textIdx = (TextId)ctx.stream.readSint16LE();
- engine->freezeTime();
+ ScopedEngineFreeze scopedFreeze(engine);
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(ctx.actorIdx);
}
@@ -659,7 +659,6 @@ static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
if (engine->_scene->_currentSceneIdx == LBA1SceneId::Principal_Island_Library && engine->_scene->_talkingActor == 8)/* && (*(short *)lifeScriptPosition == 0xe2 [226])*/ {
engine->unlockAchievement("LBA_ACH_008");
}
- engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;
@@ -905,14 +904,13 @@ static int32 lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
const int32 otherActorIdx = ctx.stream.readByte();
const TextId textIdx = (TextId)ctx.stream.readSint16LE();
- engine->freezeTime();
+ ScopedEngineFreeze scopedFreeze(engine);
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(otherActorIdx);
}
engine->_text->setFontCrossColor(engine->_scene->getActor(otherActorIdx)->_talkColor);
engine->_scene->_talkingActor = otherActorIdx;
engine->_text->drawTextProgressive(textIdx);
- engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;
@@ -1256,14 +1254,13 @@ static int32 lADD_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
TextId choiceIdx = (TextId)ctx.stream.readSint16LE();
- engine->freezeTime();
+ ScopedEngineFreeze scopedFreeze(engine);
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(ctx.actorIdx);
}
engine->_text->setFontCrossColor(ctx.actor->_talkColor);
engine->_gameState->processGameChoices(choiceIdx);
engine->_gameState->_numChoices = 0;
- engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;
@@ -1276,7 +1273,7 @@ static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
TextId textIdx = (TextId)ctx.stream.readSint16LE();
- engine->freezeTime();
+ ScopedEngineFreeze scopedFreeze(engine);
engine->_text->textClipFull();
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(ctx.actorIdx);
@@ -1285,7 +1282,6 @@ static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_scene->_talkingActor = ctx.actorIdx;
engine->_text->drawTextProgressive(textIdx);
engine->_text->textClipSmall();
- engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index ddee4a7c59..e77eacddad 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -547,7 +547,7 @@ int TwinEEngine::getRandomNumber(uint max) {
}
void TwinEEngine::freezeTime() {
- if (!_isTimeFreezed) {
+ if (_isTimeFreezed == 0) {
_saveFreezedTime = _lbaTime;
_pauseToken = pauseEngine();
}
@@ -667,9 +667,7 @@ void TwinEEngine::processInventoryAction() {
break;
}
case kiBonusList: {
- unfreezeTime();
_redraw->redrawEngineActions(true);
- freezeTime();
processBonusList();
break;
}
@@ -731,19 +729,17 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
} else {
// Process give up menu - Press ESC
if (_input->toggleAbortAction() && _scene->_sceneHero->_life > 0 && _scene->_sceneHero->_entity != -1 && !_scene->_sceneHero->_staticFlags.bIsHidden) {
- freezeTime();
+ ScopedEngineFreeze scopedFreeze(this);
exitSceneryView();
const int giveUp = _menu->giveupMenu();
if (giveUp == kQuitEngine) {
return 0;
}
if (giveUp == 1) {
- unfreezeTime();
_redraw->redrawEngineActions(true);
_quitGame = 0;
return 0;
}
- unfreezeTime();
_redraw->redrawEngineActions(true);
}
@@ -783,9 +779,8 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
} else if (_input->isActionActive(TwinEActionType::QuickBehaviourDiscreet, false)) {
_actor->_heroBehaviour = HeroBehaviourType::kDiscrete;
}
- freezeTime();
+ ScopedEngineFreeze scopedFreeze(this);
_menu->processBehaviourMenu();
- unfreezeTime();
_redraw->redrawEngineActions(true);
}
@@ -812,16 +807,14 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
// Draw holomap
if (_input->toggleActionIfActive(TwinEActionType::OpenHolomap) && _gameState->hasItem(InventoryItems::kiHolomap) && !_gameState->inventoryDisabled()) {
- freezeTime();
_holomap->processHolomap();
_screens->_lockPalette = true;
- unfreezeTime();
_redraw->redrawEngineActions(true);
}
// Process Pause
if (_input->toggleActionIfActive(TwinEActionType::Pause)) {
- freezeTime();
+ ScopedEngineFreeze scopedFreeze(this);
const char *PauseString = "Pause";
_text->setFontColor(COLOR_WHITE);
if (_redraw->_inSceneryView) {
@@ -840,7 +833,6 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
break;
}
} while (!_input->toggleActionIfActive(TwinEActionType::Pause));
- unfreezeTime();
_redraw->redrawEngineActions(true);
}
}
Commit: 86a56270517da77c49713f463967251c8b34d4bd
https://github.com/scummvm/scummvm/commit/86a56270517da77c49713f463967251c8b34d4bd
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-01T20:28:02+02:00
Commit Message:
TWINE: fixed disabled code
Changed paths:
engines/twine/renderer/screens.cpp
diff --git a/engines/twine/renderer/screens.cpp b/engines/twine/renderer/screens.cpp
index 46b06b4511..329ab15034 100644
--- a/engines/twine/renderer/screens.cpp
+++ b/engines/twine/renderer/screens.cpp
@@ -104,13 +104,17 @@ void Screens::fadeIn(const uint32 *pal) {
}
void Screens::fadeOut(const uint32 *pal) {
- /*if(cfgfile.CrossFade)
- crossFade(frontVideoBuffer, pal);
- else
- fadeToBlack(pal);*/
+#if 0
+ if (_engine->_cfgfile.CrossFade) {
+ _engine->crossFade(pal);
+ } else {
+ fadeToBlack(pal);
+ }
+#else
if (!_engine->_cfgfile.CrossFade) {
fadeToBlack(pal);
}
+#endif
}
int32 Screens::crossDot(int32 modifier, int32 color, int32 param, int32 intensity) {
Commit: 627e557828abc2f614df8d76c3764f8a9ee62b18
https://github.com/scummvm/scummvm/commit/627e557828abc2f614df8d76c3764f8a9ee62b18
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-01T20:28:02+02:00
Commit Message:
TWINE: todo comments
Changed paths:
engines/twine/scene/movements.cpp
engines/twine/script/script_life_v1.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index d4362f19da..7b6710f8a6 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -488,6 +488,7 @@ void Movements::processActorMovements(int32 actorIdx) {
processTrackAction(actorIdx);
break;
case ControlMode::kSameXZ:
+ // TODO: see lSET_DIRMODE and lSET_DIRMODE_OBJ opcodes
processSameXZAction(actorIdx);
break;
case ControlMode::kRandom:
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index 786d638429..6e5f869f38 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -682,6 +682,7 @@ static int32 lSET_DIRMODE(TwinEEngine *engine, LifeScriptContext &ctx) {
const int32 controlMode = ctx.stream.readByte();
ctx.actor->_controlMode = (ControlMode)controlMode;
+ // TODO: should ControlMode::kSameXZ be taken into account, too - see processSameXZAction
if (ctx.actor->_controlMode == ControlMode::kFollow || ctx.actor->_controlMode == ControlMode::kFollow2) {
ctx.actor->_followedActor = ctx.stream.readByte();
}
@@ -699,6 +700,7 @@ static int32 lSET_DIRMODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
ActorStruct *otherActor = engine->_scene->getActor(otherActorIdx);
otherActor->_controlMode = (ControlMode)controlMode;
+ // TODO: should ControlMode::kSameXZ be taken into account, too - see processSameXZAction
if (otherActor->_controlMode == ControlMode::kFollow || ctx.actor->_controlMode == ControlMode::kFollow2) {
otherActor->_followedActor = ctx.stream.readByte();
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index e77eacddad..64a289666b 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -658,10 +658,10 @@ void TwinEEngine::processInventoryAction() {
pinguin->setLife(kActorMaxLife);
pinguin->_body = BodyType::btNone;
_actor->initModelActor(BodyType::btNormal, _scene->_mecaPinguinIdx);
- pinguin->_dynamicFlags.bIsDead = 0; // &= 0xDF
+ pinguin->_dynamicFlags.bIsDead = 0;
pinguin->setBrickShape(ShapeType::kNone);
_movements->moveActor(pinguin->_angle, pinguin->_angle, pinguin->_speed, &pinguin->_move);
- _gameState->removeItem(InventoryItems::kiPinguin); // byte_50D89 = 0;
+ _gameState->removeItem(InventoryItems::kiPinguin);
pinguin->_delayInMillis = _lbaTime + 1500;
}
break;
Commit: 37bbfeb6ee384b9cb1a139f4c934c06584c0d8ab
https://github.com/scummvm/scummvm/commit/37bbfeb6ee384b9cb1a139f4c934c06584c0d8ab
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-01T20:28:02+02:00
Commit Message:
TWINE: sanity check for trajectory data array access
Changed paths:
engines/twine/parser/holomap.h
diff --git a/engines/twine/parser/holomap.h b/engines/twine/parser/holomap.h
index 255d7a6fc4..81a9650d68 100644
--- a/engines/twine/parser/holomap.h
+++ b/engines/twine/parser/holomap.h
@@ -77,7 +77,10 @@ private:
public:
bool loadFromStream(Common::SeekableReadStream &stream) override;
- const Trajectory *getTrajectory(int index) const {
+ const Trajectory *getTrajectory(uint index) const {
+ if (index >= _trajectories.size()) {
+ return nullptr;
+ }
return &_trajectories[index];
}
Commit: 5ae5a557b8efcb90f7f53c3eec7a233319776f54
https://github.com/scummvm/scummvm/commit/5ae5a557b8efcb90f7f53c3eec7a233319776f54
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-08-01T20:28:02+02:00
Commit Message:
TWINE: fixed game loop in Holomap::drawHolomapTrajectory
Changed paths:
engines/twine/holomap.cpp
engines/twine/holomap.h
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 98e27ad56c..afd35dbf05 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -270,13 +270,20 @@ void Holomap::drawHolomapText(int32 centerx, int32 top, const char *title) {
_engine->_text->drawText(x, y, title);
}
-void Holomap::renderHolomapModel(const BodyData &bodyData, int32 x, int32 y, int32 zPos) {
+void Holomap::renderHolomapPointModel(const Location &location, int32 x, int32 y) {
_engine->_renderer->setBaseRotation(x, y, 0);
- _engine->_renderer->getBaseRotationPosition(0, 0, zPos + 1000);
- _engine->_renderer->getBaseRotationPosition(_engine->_renderer->_destPos.x, _engine->_renderer->_destPos.y, _engine->_renderer->_destPos.z);
+ _engine->_renderer->getBaseRotationPosition(0, 0, 1000);
+ const IVec3 destPos = _engine->_renderer->_destPos;
+ _engine->_renderer->setBaseTranslation(0, 0, 0);
+ _engine->_renderer->setBaseRotation(location.angle);
+ _engine->_renderer->updateCameraAnglePositions(5300);
+ // why is this needed? _engine->_renderer->_baseTransPos = _engine->_renderer->_destPos;
+ _engine->_renderer->getBaseRotationPosition(destPos);
_engine->_interface->resetClip();
Common::Rect dummy;
- _engine->_renderer->renderIsoModel(_engine->_renderer->_destPos.x, _engine->_renderer->_destPos.y, _engine->_renderer->_destPos.z, x, y, ANGLE_0, bodyData, dummy);
+ _engine->_renderer->renderIsoModel(destPos, x, y, ANGLE_0, _engine->_resources->holomapPointModelPtr, dummy);
+ // debug(3, "renderHolomapPointModel(%i, %i): dirty(%i:%i:%i:%i)", x, y, dummy.left, dummy.top, dummy.right, dummy.bottom);
+ // TODO: update the screen _engine->copyBlockPhys(_engine->rect());
}
void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
@@ -301,7 +308,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
renderHolomapSurfacePolygons();
const Location &loc = _locations[data->locationIdx];
- renderHolomapModel(_engine->_resources->holomapPointModelPtr, loc.angle.x, loc.angle.y, 0);
+ renderHolomapPointModel(loc, loc.angle.x, loc.angle.y);
ActorMoveStruct move;
AnimTimerDataStruct animTimerData;
@@ -340,6 +347,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
_engine->_movements->setActorAngleSafe(ANGLE_0, -ANGLE_90, 500, &move);
}
+ // render the vehicle you travel with
if (_engine->_animations->setModelAnimation(frameNumber, animData, bodyData, &animTimerData)) {
frameNumber++;
if (frameNumber >= animData.getNumKeyframes()) {
@@ -357,6 +365,9 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
_engine->_renderer->setCameraPosition(400, 240, 128, 1024, 1024);
_engine->_renderer->setCameraAngle(0, 0, 0, data->pos.x, data->pos.y, data->pos.z, 5300);
_engine->_renderer->setLightVector(data->pos.x, data->pos.y, 0);
+
+ // animate the path from point 1 to point 2 by rendering a point model on each position
+ // on the global every 40 timeunits
if (frameTime + 40 <= _engine->_lbaTime) {
frameTime = _engine->_lbaTime;
int32 modelX;
@@ -368,10 +379,10 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
if (data->numAnimFrames < trajAnimFrameIdx) {
break;
}
- modelX = _locations[data->trajLocationIdx].angle.x;
- modelY = _locations[data->trajLocationIdx].angle.y;
+ modelX = loc.angle.x;
+ modelY = loc.angle.y;
}
- renderHolomapModel(_engine->_resources->holomapPointModelPtr, modelX, modelY, 0);
+ renderHolomapPointModel(loc, modelX, modelY);
++trajAnimFrameIdx;
}
@@ -380,6 +391,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
// TODO: this does a flip - which puts stuff onto the screen that shouldn't be there
//_engine->_screens->fadeToPal(_engine->_screens->paletteRGBA);
}
+ ++_engine->_lbaTime;
}
_engine->_screens->clearScreen();
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index c4b8462b6f..84b7ff9f85 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -79,7 +79,7 @@ private:
void renderLocations(int xRot, int yRot, int zRot, bool lower);
- void renderHolomapModel(const BodyData &bodyData, int32 x, int32 y, int32 zPos);
+ void renderHolomapPointModel(const Location &location, int32 x, int32 y);
void prepareHolomapSurface();
void prepareHolomapProjectedPositions();
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index e063823039..ec9117e7f2 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -205,11 +205,15 @@ void Renderer::setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ,
_baseRotPos.z += param6;
- getCameraAnglePositions(_baseRotPos.x, _baseRotPos.y, _baseRotPos.z);
+ updateCameraAnglePositions();
_baseTransPos = _destPos;
}
+void Renderer::updateCameraAnglePositions(int zShift) {
+ getCameraAnglePositions(_baseRotPos.x, _baseRotPos.y, _baseRotPos.z + zShift);
+}
+
IVec3 Renderer::getHolomapRotation(const int32 angleX, const int32 angleY, const int32 angleZ) const {
int32 rotX = angleX * 2 + 1000;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 0b2ad6c302..ad3a2dfb75 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -138,6 +138,9 @@ private:
void circleFill(int32 x, int32 y, int32 radius, uint8 color);
bool renderModelElements(int32 numOfPrimitives, const BodyData &bodyData, RenderCommand **renderCmds, ModelData *modelData, Common::Rect &modelRect);
void getCameraAnglePositions(int32 x, int32 y, int32 z);
+ inline void getCameraAnglePositions(const IVec3 &vec) {
+ getCameraAnglePositions(vec.x, vec.y, vec.z);
+ }
void applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix, const IVec3 &angleVec);
void applyPointsRotation(const Common::Array<BodyVertex>& vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *rotationMatrix);
void processRotatedElement(IMatrix3x3 *targetMatrix, const Common::Array<BodyVertex>& vertices, int32 rotX, int32 rotY, int32 rotZ, const BodyBone &bone, ModelData *modelData);
@@ -217,6 +220,10 @@ public:
void setLightVector(int32 angleX, int32 angleY, int32 angleZ);
void getBaseRotationPosition(int32 x, int32 y, int32 z);
+ inline void getBaseRotationPosition(const IVec3& vec) {
+ getBaseRotationPosition(vec.x, vec.y, vec.z);
+ }
+
void renderPolygons(const CmdRenderPolygon &polygon, Vertex *vertices, int vtop, int vbottom);
inline int32 projectPositionOnScreen(const IVec3& pos) {
@@ -231,12 +238,22 @@ public:
void projectXYPositionOnScreen(int32 x,int32 y,int32 z);
void setCameraPosition(int32 x, int32 y, int32 depthOffset, int32 scaleY, int32 scaleZ);
void setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ, int32 rotPosX, int32 rotPosY, int32 rotPosZ, int32 param6);
+ void updateCameraAnglePositions(int zShift = 0);
void setBaseTranslation(int32 x, int32 y, int32 z);
void setBaseRotation(int32 x, int32 y, int32 z, bool transpose = false);
+
+ inline void setBaseRotation(const IVec3 &rot, bool transpose = false) {
+ setBaseRotation(rot.x, rot.y, rot.z, transpose);
+ }
+
void setOrthoProjection(int32 x, int32 y, int32 z);
bool renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ, const BodyData &bodyData, Common::Rect &modelRect);
+ inline bool renderIsoModel(const IVec3 &pos, int32 angleX, int32 angleY, int32 angleZ, const BodyData &bodyData, Common::Rect &modelRect) {
+ return renderIsoModel(pos.x, pos.y, pos.z, angleX, angleY, angleZ, bodyData, modelRect);
+ }
+
/**
* @param angle A value of @c -1 means that the model is automatically rotated
*/
More information about the Scummvm-git-logs
mailing list