[Scummvm-git-logs] scummvm master -> 0368d97c8e96fa346eec04ba54fff6a6c583314f
elasota
noreply at scummvm.org
Sat Feb 25 05:00:53 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9733f14df4 VCRUISE: Fix case statement miscompilation
60508e2412 VCRUISE: Add some more script ops
0368d97c8e VCRUISE: Implement FPS overrides
Commit: 9733f14df4379735fc8a03da5379b4a764585e24
https://github.com/scummvm/scummvm/commit/9733f14df4379735fc8a03da5379b4a764585e24
Author: elasota (ejlasota at gmail.com)
Date: 2023-02-25T00:00:20-05:00
Commit Message:
VCRUISE: Fix case statement miscompilation
Changed paths:
engines/vcruise/script.cpp
diff --git a/engines/vcruise/script.cpp b/engines/vcruise/script.cpp
index 5f8474f7527..f8bdb1ebd72 100644
--- a/engines/vcruise/script.cpp
+++ b/engines/vcruise/script.cpp
@@ -677,7 +677,7 @@ void ScriptCompiler::codeGenScript(ProtoScript &protoScript, Script &script) {
for (const CodeGenSwitchCase &caseDef : switchBlock.cases) {
instrs2.push_back(ProtoInstruction(ScriptOps::kCheckValue, caseDef.value));
- instrs2.push_back(ProtoInstruction(kProtoOpJumpToLabel, ScriptOps::kInvalid, caseDef.value));
+ instrs2.push_back(ProtoInstruction(kProtoOpJumpToLabel, ScriptOps::kInvalid, caseDef.label));
}
instrs2.push_back(ProtoInstruction(ScriptOps::kDrop));
Commit: 60508e24127a6011a9fdcf75b49e3dc2c48bdd2d
https://github.com/scummvm/scummvm/commit/60508e24127a6011a9fdcf75b49e3dc2c48bdd2d
Author: elasota (ejlasota at gmail.com)
Date: 2023-02-25T00:00:20-05:00
Commit Message:
VCRUISE: Add some more script ops
Changed paths:
engines/vcruise/runtime.cpp
engines/vcruise/runtime.h
diff --git a/engines/vcruise/runtime.cpp b/engines/vcruise/runtime.cpp
index 65ba88d0f56..c030634ff27 100644
--- a/engines/vcruise/runtime.cpp
+++ b/engines/vcruise/runtime.cpp
@@ -20,10 +20,11 @@
*/
#include "common/formats/winexe.h"
+#include "common/file.h"
#include "common/ptr.h"
+#include "common/random.h"
#include "common/system.h"
#include "common/stream.h"
-#include "common/file.h"
#include "graphics/cursorman.h"
#include "graphics/font.h"
@@ -94,6 +95,8 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
for (uint i = 0; i < kPanCursorMaxCount; i++)
_panCursors[i] = 0;
+
+ _rng.reset(new Common::RandomSource("vcruise"));
}
Runtime::~Runtime() {
@@ -1314,7 +1317,12 @@ void Runtime::scriptOpRotate(ScriptArg_t arg) {
OPCODE_STUB(Angle)
OPCODE_STUB(AngleGGet)
-OPCODE_STUB(Speed)
+
+void Runtime::scriptOpSpeed(ScriptArg_t arg) {
+ TAKE_STACK(1);
+
+ warning("Speed change isn't implemented yet");
+}
void Runtime::scriptOpSAnimL(ScriptArg_t arg) {
TAKE_STACK(kAnimDefStackArgs + 2);
@@ -1445,7 +1453,19 @@ void Runtime::scriptOpAnim(ScriptArg_t arg) {
changeToCursor(_cursors[kCursorArrow]);
}
-OPCODE_STUB(Static)
+void Runtime::scriptOpStatic(ScriptArg_t arg) {
+ TAKE_STACK(kAnimDefStackArgs);
+
+ AnimationDef animDef = stackArgsToAnimDef(stackArgs);
+
+ animDef.firstFrame = animDef.lastFrame;
+ changeAnimation(animDef);
+
+ _havePendingReturnToIdleState = true;
+ _havePanAnimations = false;
+
+ _gameState = kGameStateWaitingForAnimation;
+}
void Runtime::scriptOpVarLoad(ScriptArg_t arg) {
TAKE_STACK(1);
@@ -1525,7 +1545,15 @@ OPCODE_STUB(ParmG)
OPCODE_STUB(VolumeDn4)
OPCODE_STUB(VolumeUp3)
-OPCODE_STUB(Random)
+
+void Runtime::scriptOpRandom(ScriptArg_t arg) {
+ TAKE_STACK(1);
+
+ if (stackArgs[0] == 0)
+ _scriptStack.push_back(0);
+ else
+ _scriptStack.push_back(_rng->getRandomNumber(stackArgs[0] - 1));
+}
void Runtime::scriptOpDrop(ScriptArg_t arg) {
TAKE_STACK(1);
@@ -1539,7 +1567,12 @@ void Runtime::scriptOpDup(ScriptArg_t arg) {
_scriptStack.push_back(stackArgs[0]);
}
-OPCODE_STUB(Say3)
+void Runtime::scriptOpSay3(ScriptArg_t arg) {
+ TAKE_STACK(3);
+
+ warning("Say3 opcode is not implemented yet");
+}
+
OPCODE_STUB(SetTimer)
OPCODE_STUB(LoSet)
OPCODE_STUB(LoGet)
@@ -1570,9 +1603,26 @@ void Runtime::scriptOpCmpEq(ScriptArg_t arg) {
_scriptStack.push_back((stackArgs[0] == stackArgs[1]) ? 1 : 0);
}
-OPCODE_STUB(BitLoad)
-OPCODE_STUB(BitSet0)
-OPCODE_STUB(BitSet1)
+void Runtime::scriptOpBitLoad(ScriptArg_t arg) {
+ TAKE_STACK(2);
+
+
+ _scriptStack.push_back((stackArgs[0] >> stackArgs[1]) & 1);
+}
+
+void Runtime::scriptOpBitSet0(ScriptArg_t arg) {
+ TAKE_STACK(2);
+
+ ScriptArg_t bitMask = static_cast<ScriptArg_t>(1) << stackArgs[1];
+ _scriptStack.push_back(stackArgs[0] & ~bitMask);
+}
+
+void Runtime::scriptOpBitSet1(ScriptArg_t arg) {
+ TAKE_STACK(2);
+
+ ScriptArg_t bitMask = static_cast<ScriptArg_t>(1) << stackArgs[1];
+ _scriptStack.push_back(stackArgs[0] | bitMask);
+}
void Runtime::scriptOpDisc1(ScriptArg_t arg) {
// Disc check, always pass
diff --git a/engines/vcruise/runtime.h b/engines/vcruise/runtime.h
index 37f62394614..2d38aaf4f27 100644
--- a/engines/vcruise/runtime.h
+++ b/engines/vcruise/runtime.h
@@ -29,6 +29,12 @@
class OSystem;
+namespace Common {
+
+class RandomSource;
+
+} // End of namespace Commom
+
namespace Graphics {
struct PixelFormat;
@@ -381,6 +387,8 @@ private:
Common::Array<StackValue_t> _scriptStack;
ScriptEnvironmentVars _scriptEnv;
+ Common::SharedPtr<Common::RandomSource> _rng;
+
Common::SharedPtr<AudioPlayer> _musicPlayer;
Common::SharedPtr<Video::AVIDecoder> _animDecoder;
Commit: 0368d97c8e96fa346eec04ba54fff6a6c583314f
https://github.com/scummvm/scummvm/commit/0368d97c8e96fa346eec04ba54fff6a6c583314f
Author: elasota (ejlasota at gmail.com)
Date: 2023-02-25T00:00:20-05:00
Commit Message:
VCRUISE: Implement FPS overrides
Changed paths:
engines/vcruise/runtime.cpp
engines/vcruise/runtime.h
diff --git a/engines/vcruise/runtime.cpp b/engines/vcruise/runtime.cpp
index c030634ff27..610f62b0d35 100644
--- a/engines/vcruise/runtime.cpp
+++ b/engines/vcruise/runtime.cpp
@@ -69,7 +69,7 @@ const MapScreenDirectionDef *MapDef::getScreenDirection(uint screen, uint direct
return screenDirections[screen][direction].get();
}
-ScriptEnvironmentVars::ScriptEnvironmentVars() : lmb(false), panInteractionID(0) {
+ScriptEnvironmentVars::ScriptEnvironmentVars() : lmb(false), panInteractionID(0), fpsOverride(0) {
}
void Runtime::RenderSection::init(const Common::Rect ¶mRect, const Graphics::PixelFormat &fmt) {
@@ -85,7 +85,7 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
: _system(system), _mixer(mixer), _roomNumber(1), _screenNumber(0), _direction(0), _havePanAnimations(0), _loadedRoomNumber(0), _activeScreenNumber(0),
_gameState(kGameStateBoot), _gameID(gameID), _havePendingScreenChange(false), _havePendingReturnToIdleState(false), _scriptNextInstruction(0),
_escOn(false), _debugMode(false), _panoramaDirectionFlags(0),
- _loadedAnimation(0), _animPendingDecodeFrame(0), _animDisplayingFrame(0), _animFirstFrame(0), _animLastFrame(0), _animDecoderState(kAnimDecoderStateStopped),
+ _loadedAnimation(0), _animPendingDecodeFrame(0), _animDisplayingFrame(0), _animFirstFrame(0), _animLastFrame(0), _animFrameRateLock(0), _animStartTime(0), _animFramesDecoded(0), _animDecoderState(kAnimDecoderStateStopped),
_animPlayWhileIdle(false), _idleIsOnInteraction(false), _idleInteractionID(0),
_lmbDown(false), _lmbDragging(false), _lmbReleaseWasClick(false), _lmbDownTime(0),
_panoramaState(kPanoramaStateInactive) {
@@ -371,7 +371,7 @@ bool Runtime::runWaitForFacing() {
continuePlayingAnimation(false, animEnded);
if (animEnded) {
- changeAnimation(_postFacingAnimDef);
+ changeAnimation(_postFacingAnimDef, true);
_gameState = kGameStateWaitingForAnimation;
return true;
}
@@ -399,9 +399,29 @@ void Runtime::continuePlayingAnimation(bool loop, bool &outAnimationEnded) {
needsFirstFrame = true;
}
+ uint32 millis = 0;
+
+ // Avoid spamming event recorder as much if we don't actually need to fetch millis, but also only fetch it once here.
+ if (_animFrameRateLock)
+ millis = g_system->getMillis();
+
for (;;) {
- bool needNewFrame = needsFirstFrame || (_animDecoder->getTimeToNextFrame() == 0);
- needsFirstFrame = false;
+ bool needNewFrame = false;
+
+ if (needsFirstFrame) {
+ needNewFrame = true;
+ needsFirstFrame = false;
+ } else {
+ if (_animFrameRateLock) {
+ // if ((millis - startTime) / 1000 * frameRate) >= framesDecoded
+ if ((millis - _animStartTime) * static_cast<uint64>(_animFrameRateLock) >= (static_cast<uint64>(_animFramesDecoded) * 1000u))
+ needNewFrame = true;
+ debug("FPS lock: New frame at %u millis and %u decoded? %s", static_cast<uint>(millis - _animStartTime), static_cast<uint>(_animFramesDecoded), needNewFrame ? "yes" : "no");
+ } else {
+ if (_animDecoder->getTimeToNextFrame() == 0)
+ needNewFrame = true;
+ }
+ }
if (!needNewFrame)
break;
@@ -429,6 +449,7 @@ void Runtime::continuePlayingAnimation(bool loop, bool &outAnimationEnded) {
_animDisplayingFrame = _animPendingDecodeFrame;
_animPendingDecodeFrame++;
+ _animFramesDecoded++;
Common::Rect copyRect = Common::Rect(0, 0, surface->w, surface->h);
@@ -767,7 +788,7 @@ void Runtime::returnToIdleState() {
_animPlayWhileIdle = false;
if (_haveIdleAnimations[_direction]) {
- changeAnimation(_idleAnimations[_direction]);
+ changeAnimation(_idleAnimations[_direction], false);
_animPlayWhileIdle = true;
}
@@ -951,11 +972,11 @@ void Runtime::changeMusicTrack(int track) {
}
}
-void Runtime::changeAnimation(const AnimationDef &animDef) {
- changeAnimation(animDef, animDef.firstFrame);
+void Runtime::changeAnimation(const AnimationDef &animDef, bool consumeFPSOverride) {
+ changeAnimation(animDef, animDef.firstFrame, consumeFPSOverride);
}
-void Runtime::changeAnimation(const AnimationDef &animDef, uint initialFrame) {
+void Runtime::changeAnimation(const AnimationDef &animDef, uint initialFrame, bool consumeFPSOverride) {
int animFile = animDef.animNum;
if (animFile < 0)
animFile = -animFile;
@@ -991,6 +1012,14 @@ void Runtime::changeAnimation(const AnimationDef &animDef, uint initialFrame) {
_animPendingDecodeFrame = initialFrame;
_animFirstFrame = animDef.firstFrame;
_animLastFrame = animDef.lastFrame;
+ _animFrameRateLock = 0;
+
+ if (consumeFPSOverride) {
+ _animFrameRateLock = _scriptEnv.fpsOverride;
+ _animFramesDecoded = 0;
+ _animStartTime = g_system->getMillis();
+ _scriptEnv.fpsOverride = 0;
+ }
debug(1, "Animation last frame set to %u", animDef.lastFrame);
}
@@ -1321,7 +1350,7 @@ OPCODE_STUB(AngleGGet)
void Runtime::scriptOpSpeed(ScriptArg_t arg) {
TAKE_STACK(1);
- warning("Speed change isn't implemented yet");
+ _scriptEnv.fpsOverride = stackArgs[0];
}
void Runtime::scriptOpSAnimL(ScriptArg_t arg) {
@@ -1359,7 +1388,7 @@ void Runtime::scriptOpAnimR(ScriptArg_t arg) {
debug(1, "Running frame loop of %u - %u from frame %u", trimmedAnimation.firstFrame, trimmedAnimation.lastFrame, initialFrame);
- changeAnimation(trimmedAnimation, initialFrame);
+ changeAnimation(trimmedAnimation, initialFrame, false);
_gameState = kGameStatePanLeft;
} else if (_scriptEnv.panInteractionID == kPanRightInteraction) {
debug(1, "Pan-right interaction from direction %u", _direction);
@@ -1371,7 +1400,7 @@ void Runtime::scriptOpAnimR(ScriptArg_t arg) {
debug(1, "Running frame loop of %u - %u from frame %u", trimmedAnimation.firstFrame, trimmedAnimation.lastFrame, initialFrame);
- changeAnimation(_panRightAnimationDef, initialFrame);
+ changeAnimation(_panRightAnimationDef, initialFrame, false);
_gameState = kGameStatePanRight;
isRight = true;
@@ -1407,10 +1436,10 @@ void Runtime::scriptOpAnimF(ScriptArg_t arg) {
AnimationDef faceDirectionAnimDef;
if (computeFaceDirectionAnimation(stackArgs[kAnimDefStackArgs + 2], faceDirectionAnimDef)) {
_postFacingAnimDef = animDef;
- changeAnimation(faceDirectionAnimDef);
+ changeAnimation(faceDirectionAnimDef, false);
_gameState = kGameStateWaitingForFacing;
} else {
- changeAnimation(animDef);
+ changeAnimation(animDef, true);
_gameState = kGameStateWaitingForAnimation;
}
_screenNumber = stackArgs[kAnimDefStackArgs + 0];
@@ -1429,7 +1458,7 @@ void Runtime::scriptOpAnimS(ScriptArg_t arg) {
AnimationDef animDef = stackArgsToAnimDef(stackArgs + 0);
animDef.lastFrame = animDef.firstFrame; // Static animation
- changeAnimation(animDef);
+ changeAnimation(animDef, false);
_gameState = kGameStateWaitingForAnimation;
_screenNumber = stackArgs[kAnimDefStackArgs + 0];
@@ -1443,7 +1472,7 @@ void Runtime::scriptOpAnim(ScriptArg_t arg) {
TAKE_STACK(kAnimDefStackArgs + 2);
AnimationDef animDef = stackArgsToAnimDef(stackArgs + 0);
- changeAnimation(animDef);
+ changeAnimation(animDef, true);
_gameState = kGameStateWaitingForAnimation;
_screenNumber = stackArgs[kAnimDefStackArgs + 0];
@@ -1459,7 +1488,7 @@ void Runtime::scriptOpStatic(ScriptArg_t arg) {
AnimationDef animDef = stackArgsToAnimDef(stackArgs);
animDef.firstFrame = animDef.lastFrame;
- changeAnimation(animDef);
+ changeAnimation(animDef, false);
_havePendingReturnToIdleState = true;
_havePanAnimations = false;
diff --git a/engines/vcruise/runtime.h b/engines/vcruise/runtime.h
index 2d38aaf4f27..2e9bc43567c 100644
--- a/engines/vcruise/runtime.h
+++ b/engines/vcruise/runtime.h
@@ -117,6 +117,7 @@ struct ScriptEnvironmentVars {
bool lmb;
uint panInteractionID;
+ uint fpsOverride;
};
class Runtime {
@@ -239,8 +240,8 @@ private:
void loadMap(Common::SeekableReadStream *stream);
void changeMusicTrack(int musicID);
- void changeAnimation(const AnimationDef &animDef);
- void changeAnimation(const AnimationDef &animDef, uint initialFrame);
+ void changeAnimation(const AnimationDef &animDef, bool consumeFPSOverride);
+ void changeAnimation(const AnimationDef &animDef, uint initialFrame, bool consumeFPSOverride);
AnimationDef stackArgsToAnimDef(const StackValue_t *args) const;
@@ -397,6 +398,9 @@ private:
uint _animDisplayingFrame;
uint _animFirstFrame;
uint _animLastFrame;
+ uint _animFrameRateLock;
+ uint32 _animStartTime;
+ uint32 _animFramesDecoded;
uint _loadedAnimation;
bool _animPlayWhileIdle;
More information about the Scummvm-git-logs
mailing list