diff --git a/engines/vcruise/runtime.cpp b/engines/vcruise/runtime.cpp index 7b7aaf9b860..2d6bd5fe7ed 100644 --- a/engines/vcruise/runtime.cpp +++ b/engines/vcruise/runtime.cpp @@ -940,7 +940,7 @@ void SaveGameSwappableState::Sound::read(Common::ReadStream *stream, uint saveGa params3D.read(stream); } -SaveGameSwappableState::SaveGameSwappableState() : roomNumber(0), screenNumber(0), direction(0), havePendingPostSwapScreenReset(false), +SaveGameSwappableState::SaveGameSwappableState() : roomNumber(0), screenNumber(0), direction(0), disc(0), havePendingPostSwapScreenReset(false), musicTrack(0), musicVolume(100), musicActive(true), musicMuteDisabled(false), animVolume(100), loadedAnimation(0), animDisplayingFrame(0) { } @@ -959,6 +959,7 @@ void SaveGameSnapshot::write(Common::WriteStream *stream) const { stream->writeUint32BE(states[sti]->roomNumber); stream->writeUint32BE(states[sti]->screenNumber); stream->writeUint32BE(states[sti]->direction); + stream->writeUint32BE(states[sti]->disc); stream->writeByte(states[sti]->havePendingPostSwapScreenReset ? 1 : 0); } @@ -1067,6 +1068,9 @@ LoadGameOutcome SaveGameSnapshot::read(Common::ReadStream *stream) { states[sti]->screenNumber = stream->readUint32BE(); states[sti]->direction = stream->readUint32BE(); + if (saveVersion >= 10) + states[sti]->disc = stream->readUint32BE(); + if (saveVersion >= 7) states[sti]->havePendingPostSwapScreenReset = (stream->readByte() != 0); } @@ -1218,7 +1222,7 @@ FontCacheItem::FontCacheItem() : font(nullptr), size(0) { } Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &rootFSNode, VCruiseGameID gameID, Common::Language defaultLanguage) - : _system(system), _mixer(mixer), _roomNumber(1), _screenNumber(0), _direction(0), _hero(0), _swapOutRoom(0), _swapOutScreen(0), _swapOutDirection(0), + : _system(system), _mixer(mixer), _roomNumber(1), _screenNumber(0), _direction(0), _hero(0), _disc(0), _swapOutRoom(0), _swapOutScreen(0), _swapOutDirection(0), _haveHorizPanAnimations(false), _loadedRoomNumber(0), _activeScreenNumber(0), _gameState(kGameStateBoot), _gameID(gameID), _havePendingScreenChange(false), _forceScreenChange(false), _havePendingPreIdleActions(false), _havePendingReturnToIdleState(false), _havePendingPostSwapScreenReset(false), _havePendingCompletionCheck(false), _havePendingPlayAmbientSounds(false), _ambientSoundFinishTime(0), _escOn(false), _debugMode(false), _fastAnimationMode(false), _lowQualityGraphicsMode(false), @@ -1388,6 +1392,8 @@ void Runtime::loadCursors(const char *exeName) { _namedCursors["CUR_PRAWO"] = 3; // Prawo = right _namedCursors["CUR_LEWO"] = 1; // Lewo = left _namedCursors["CUR_LUPA"] = 6; // Lupa = magnifier + _namedCursors["CUR_NAC"] = 5; // Nac = top? Not sure. But this is the finger pointer. + _namedCursors["CUR_TYL"] = 2; // Tyl = back } _panCursors[kPanCursorDraggableHoriz | kPanCursorDraggableUp] = 2; @@ -6155,6 +6161,7 @@ void Runtime::restoreSaveGameSnapshot() { _roomNumber = mainState->roomNumber; _screenNumber = mainState->screenNumber; _direction = mainState->direction; + _disc = mainState->disc; _havePendingPostSwapScreenReset = mainState->havePendingPostSwapScreenReset; _hero = snapshot->hero; _swapOutRoom = snapshot->swapOutRoom; diff --git a/engines/vcruise/runtime.h b/engines/vcruise/runtime.h index 916be46cea1..60a4ff2cc23 100644 --- a/engines/vcruise/runtime.h +++ b/engines/vcruise/runtime.h @@ -451,6 +451,7 @@ struct SaveGameSwappableState { uint roomNumber; uint screenNumber; uint direction; + uint disc; bool havePendingPostSwapScreenReset; uint loadedAnimation; @@ -478,7 +479,7 @@ struct SaveGameSnapshot { LoadGameOutcome read(Common::ReadStream *stream); static const uint kSaveGameIdentifier = 0x53566372; - static const uint kSaveGameCurrentVersion = 9; + static const uint kSaveGameCurrentVersion = 10; static const uint kSaveGameEarliestSupportedVersion = 2; static const uint kMaxStates = 2; @@ -1204,6 +1205,7 @@ private: uint _screenNumber; uint _direction; uint _hero; + uint _disc; uint _swapOutRoom; uint _swapOutScreen; diff --git a/engines/vcruise/runtime_scriptexec.cpp b/engines/vcruise/runtime_scriptexec.cpp index 34a6f81cb63..1a9a01551f6 100644 --- a/engines/vcruise/runtime_scriptexec.cpp +++ b/engines/vcruise/runtime_scriptexec.cpp @@ -2103,9 +2103,32 @@ void Runtime::scriptOpNoUpdate(ScriptArg_t arg) { OPCODE_STUB(NoClear) -OPCODE_STUB(Say1_AD2044) +void Runtime::scriptOpSay1_AD2044(ScriptArg_t arg) { + TAKE_STACK_INT(1); + + Common::String soundName = Common::String::format("%02i-%08i", static_cast(_disc * 10u + 1u), static_cast(stackArgs[0])); + + StackInt_t soundID = 0; + SoundInstance *cachedSound = nullptr; + resolveSoundByName(soundName, true, soundID, cachedSound); + + if (cachedSound) { + TriggeredOneShot oneShot; + oneShot.soundID = soundID; + oneShot.uniqueSlot = _disc; + + if (Common::find(_triggeredOneShots.begin(), _triggeredOneShots.end(), oneShot) == _triggeredOneShots.end()) { + triggerSound(kSoundLoopBehaviorNo, *cachedSound, 100, 0, false, true); + _triggeredOneShots.push_back(oneShot); + } + } +} + +void Runtime::scriptOpSay1Rnd(ScriptArg_t arg) { + scriptOpSay1_AD2044(arg); +} + OPCODE_STUB(Say2_AD2044) -OPCODE_STUB(Say1Rnd) void Runtime::scriptOpM(ScriptArg_t arg) { // Looks like this is possibly support to present a mouse click prompt and end @@ -2383,6 +2406,9 @@ bool Runtime::runScript() { DISPATCH_OP(SDot); DISPATCH_OP(E); + DISPATCH_OP(Sound); + DISPATCH_OP(ISound); + default: error("Unimplemented opcode %i", static_cast(instr.op)); }