From ce5b8c54a92accf12d43fe1f681d277166b72fb9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 3 Jan 2014 20:11:00 -1000 Subject: VOYEUR: Hooked up debugger, and added a 'time' command --- engines/voyeur/debugger.cpp | 53 ++++++++++++++++++++++++++++++- engines/voyeur/debugger.h | 9 ++++++ engines/voyeur/events.cpp | 23 +++++++++++--- engines/voyeur/events.h | 2 +- engines/voyeur/files_threads.cpp | 21 +++++++------ engines/voyeur/voyeur.h | 10 ++++++ engines/voyeur/voyeur_game.cpp | 67 +++++++++++++++++++++++----------------- 7 files changed, 140 insertions(+), 45 deletions(-) diff --git a/engines/voyeur/debugger.cpp b/engines/voyeur/debugger.cpp index 8407ead22f..04fdff2d49 100644 --- a/engines/voyeur/debugger.cpp +++ b/engines/voyeur/debugger.cpp @@ -21,14 +21,65 @@ */ #include "voyeur/debugger.h" - #include "voyeur/graphics.h" #include "voyeur/voyeur.h" +#include "voyeur/staticres.h" namespace Voyeur { Debugger::Debugger() : GUI::Debugger() { + // Register methods DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("exit", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("time", WRAP_METHOD(Debugger, Cmd_Time)); + + // Set fields + _isTimeActive = true; +} + +bool Debugger::Cmd_Time(int argc, const char **argv) { + if (argc < 2) { + // Get the current day and time of day + Common::String dtString = _vm->getDayName(); + Common::String timeString = _vm->getTimeOfDay(); + if (!timeString.empty()) + dtString += " " + timeString; + + DebugPrintf("Current date/time is: %s, time is %s\n", + dtString.c_str(), _isTimeActive ? "on" : "off"); + DebugPrintf("Format: %s [on | off | 1..17]\n\n", argv[0]); + } else { + if (!strcmp(argv[1], "on")) { + _isTimeActive = true; + DebugPrintf("Time is now on\n\n"); + } else if (!strcmp(argv[1], "off")) { + _isTimeActive = false; + DebugPrintf("Time is now off\n\n"); + } else { + int timeId = atoi(argv[1]); + if (timeId >= 1 && timeId <= 17) { + _vm->_voy._transitionId = timeId; + _vm->_gameHour = LEVEL_H[timeId - 1]; + _vm->_gameMinute = LEVEL_M[timeId - 1]; + _vm->_voy._isAM = timeId == 6; + + _vm->_voy._RTVNum = 0; + _vm->_voy._RTANum = 255; + + // Get the new current day and time of day + Common::String dtString = _vm->getDayName(); + Common::String timeString = _vm->getTimeOfDay(); + if (!timeString.empty()) + dtString += " " + timeString; + + DebugPrintf("Current date/time is now: %s\n\n", dtString.c_str()); + } else { + DebugPrintf("Unknown parameter\n\n"); + } + } + } + + return true; } } // End of namespace Voyeur diff --git a/engines/voyeur/debugger.h b/engines/voyeur/debugger.h index 302008716b..0391fadffd 100644 --- a/engines/voyeur/debugger.h +++ b/engines/voyeur/debugger.h @@ -33,11 +33,20 @@ class VoyeurEngine; class Debugger : public GUI::Debugger { private: VoyeurEngine *_vm; +public: + /** + * Specifies whether time should pass, and the video camera's batteries go down + * @default true + */ + bool _isTimeActive; +protected: + bool Cmd_Time(int argc, const char **argv); public: Debugger(); virtual ~Debugger() {} void setVm(VoyeurEngine *vm) { _vm = vm; } + }; } // End of namespace Voyeur diff --git a/engines/voyeur/events.cpp b/engines/voyeur/events.cpp index 5053b38d85..a46de4740b 100644 --- a/engines/voyeur/events.cpp +++ b/engines/voyeur/events.cpp @@ -101,9 +101,14 @@ void EventsManager::startMainClockInt() { void EventsManager::mainVoyeurIntFunc() { if (!(_vm->_voy._field478 & 1)) { ++_vm->_voy._switchBGNum; - ++_vm->_voy._RTVNum; - if (_vm->_voy._RTVNum >= _vm->_voy._field4F2) - _vm->_voy._field4F0 = 1; + + if (_vm->_debugger._isTimeActive) { + // Increase camera discharge + ++_vm->_voy._RTVNum; + + if (_vm->_voy._RTVNum >= _vm->_voy._field4F2) + _vm->_voy._field4F0 = 1; + } } } @@ -145,6 +150,9 @@ void EventsManager::checkForNextFrameCounter() { if ((_gameCounter % GAME_FRAME_RATE) == 0) mainVoyeurIntFunc(); + // Give time to the debugger + _vm->_debugger.onFrame(); + // Display the frame g_system->copyRectToScreen((byte *)_vm->_graphicsManager._screenSurface.getPixels(), SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); @@ -238,7 +246,14 @@ void EventsManager::pollEvents() { return; case Common::EVENT_KEYDOWN: - _keyState[(byte)toupper(event.kbd.ascii)] = true; + // Check for debugger + if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) { + // Attach to the debugger + _vm->_debugger.attach(); + _vm->_debugger.onFrame(); + } else { + _keyState[(byte)toupper(event.kbd.ascii)] = true; + } return; case Common::EVENT_KEYUP: _keyState[(byte)toupper(event.kbd.ascii)] = false; diff --git a/engines/voyeur/events.h b/engines/voyeur/events.h index 1e884c684d..e7aedd5218 100644 --- a/engines/voyeur/events.h +++ b/engines/voyeur/events.h @@ -86,7 +86,7 @@ public: int _field470; int _field472; int _transitionId; - int _field476; + int _RTVLimit; int _field478; int _field47A; PictureResource *_evPicPtrs[6]; diff --git a/engines/voyeur/files_threads.cpp b/engines/voyeur/files_threads.cpp index 2b791c43ab..b7d1402b35 100644 --- a/engines/voyeur/files_threads.cpp +++ b/engines/voyeur/files_threads.cpp @@ -538,7 +538,7 @@ void ThreadResource::parsePlayCommands() { if (v2 == 0 || READ_LE_UINT16(_vm->_controlPtr->_ptr + 4) == 0) { _vm->_voy._field470 = 5; int count = READ_LE_UINT16(dataP + 2); - _vm->_voy._field476 = READ_LE_UINT16(dataP + 4); + _vm->_voy._RTVLimit = READ_LE_UINT16(dataP + 4); if (_vm->_voy._transitionId != count) { if (_vm->_voy._transitionId > 1) @@ -552,7 +552,7 @@ void ThreadResource::parsePlayCommands() { _vm->_voy._RTANum = 255; } - _vm->_voy._isAM = (_vm->_voy._transitionId == 6) ? 1 : 0; + _vm->_voy._isAM = _vm->_voy._transitionId == 6; } dataP += 6; @@ -1353,18 +1353,18 @@ int ThreadResource::doInterface() { _vm->_eventsManager._intPtr.field1E = 1; _vm->_eventsManager._intPtr.field1A = 0; - if (_vm->_voy._RTVNum >= _vm->_voy._field476 || _vm->_voy._RTVNum < 0) - _vm->_voy._RTVNum = _vm->_voy._field476 - 1; + if (_vm->_voy._RTVNum >= _vm->_voy._RTVLimit || _vm->_voy._RTVNum < 0) + _vm->_voy._RTVNum = _vm->_voy._RTVLimit - 1; - if (_vm->_voy._transitionId < 15 && (_vm->_voy._field476 - 3) < _vm->_voy._RTVNum) { - _vm->_voy._RTVNum = _vm->_voy._field476; + if (_vm->_voy._transitionId < 15 && (_vm->_voy._RTVLimit - 3) < _vm->_voy._RTVNum) { + _vm->_voy._RTVNum = _vm->_voy._RTVLimit; _vm->makeViewFinder(); _vm->initIFace(); - _vm->_voy._RTVNum = _vm->_voy._field476 - 4; + _vm->_voy._RTVNum = _vm->_voy._RTVLimit - 4; _vm->_voy._field478 &= ~1; - while (!_vm->shouldQuit() && _vm->_voy._RTVNum < _vm->_voy._field476) { + while (!_vm->shouldQuit() && _vm->_voy._RTVNum < _vm->_voy._RTVLimit) { _vm->flashTimeBar(); } @@ -1490,8 +1490,9 @@ int ThreadResource::doInterface() { _vm->flipPageAndWait(); pt = _vm->_eventsManager.getMousePos(); - if ((_vm->_voy._field476 <= _vm->_voy._RTVNum) || ((_vm->_voy._field478 & 0x80) && - (_vm->_eventsManager._rightClick != NULL) && (pt.x == 0))) { + if ((_vm->_voy._RTVNum >= _vm->_voy._RTVLimit) || ((_vm->_voy._field478 & 0x80) && + _vm->_eventsManager._rightClick && (pt.x == 0))) { + // Time to transition to the next time period _vm->_eventsManager.getMouseInfo(); if (_vm->_voy._transitionId == 15) { diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h index f146ee2599..c0bc1d9c82 100644 --- a/engines/voyeur/voyeur.h +++ b/engines/voyeur/voyeur.h @@ -232,6 +232,16 @@ public: * Flips the active page and waits until it's drawn and faded in */ void flipPageAndWaitForFade(); + + /** + * Returns the string for the current in-game day of the week + */ + Common::String getDayName(); + + /** + * Returns the string for the current in-game time of day + */ + Common::String getTimeOfDay(); }; } // End of namespace Voyeur diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp index 5f6b7b3949..9364247ba6 100644 --- a/engines/voyeur/voyeur_game.cpp +++ b/engines/voyeur/voyeur_game.cpp @@ -1078,40 +1078,49 @@ void VoyeurEngine::checkTransition(){ Common::String time, day; if (_voy._transitionId != _checkTransitionId) { - switch (_voy._transitionId) { - case 0: - break; - case 1: - case 2: - case 3: - case 4: - day = SATURDAY; - break; - case 17: - day = MONDAY; - break; - default: - day = SUNDAY; - break; - } + // Get the day + day = getDayName(); + // Only proceed if a valid day string was returned if (!day.empty()) { _graphicsManager.fadeDownICF(6); - if (_voy._transitionId != 17) { - const char *amPm = _voy._isAM ? AM : PM; - time = Common::String::format("%d:%02d%s", - _gameHour, _gameMinute, amPm); - } + // Get the time of day string + time = getTimeOfDay(); + // Show a transition card with the day and time, and wait doTransitionCard(day, time); - _eventsManager.delay(180); + _eventsManager.delayClick(180); } _checkTransitionId = _voy._transitionId; } } +Common::String VoyeurEngine::getDayName() { + switch (_voy._transitionId) { + case 0: + return ""; + case 1: + case 2: + case 3: + case 4: + return SATURDAY; + case 17: + return MONDAY; + default: + return SUNDAY; + } +} + +Common::String VoyeurEngine::getTimeOfDay() { + if (_voy._transitionId == 17) + return ""; + + const char *amPm = _voy._isAM ? AM : PM; + return Common::String::format("%d:%02d%s", _gameHour, _gameMinute, amPm); +} + bool VoyeurEngine::doComputerText(int maxLen) { FontInfoResource &font = *_graphicsManager._fontPtr; int totalChars = 0; @@ -1214,12 +1223,12 @@ void VoyeurEngine::getComputerBrush() { void VoyeurEngine::doTimeBar(bool force) { flashTimeBar(); - if ((force || _timeBarVal != _voy._RTVNum) && _voy._field476 > 0) { - if (_voy._RTVNum > _voy._field476 || _voy._RTVNum < 0) - _voy._RTVNum = _voy._field476 - 1; + if ((force || _timeBarVal != _voy._RTVNum) && _voy._RTVLimit > 0) { + if (_voy._RTVNum > _voy._RTVLimit || _voy._RTVNum < 0) + _voy._RTVNum = _voy._RTVLimit - 1; _timeBarVal = _voy._RTVNum; - int height = ((_voy._field476 - _voy._RTVNum) * 59) / _voy._field476; + int height = ((_voy._RTVLimit - _voy._RTVNum) * 59) / _voy._RTVLimit; int fullHeight = MAX(151 - height, 93); _graphicsManager._drawPtr->_penColor = 134; @@ -1239,10 +1248,10 @@ void VoyeurEngine::doTimeBar(bool force) { } void VoyeurEngine::flashTimeBar(){ - if (_voy._RTVNum >= 0 && (_voy._field476 - _voy._RTVNum) < 11 && + if (_voy._RTVNum >= 0 && (_voy._RTVLimit - _voy._RTVNum) < 11 && (_eventsManager._intPtr.field1A >= (_flashTimeVal + 15) || _eventsManager._intPtr.field1A < _flashTimeVal)) { - // Within time range + // Within camera low power range _flashTimeVal = _eventsManager._intPtr.field1A; if (_flashTimeFlag) @@ -1257,7 +1266,7 @@ void VoyeurEngine::flashTimeBar(){ } void VoyeurEngine::checkPhoneCall() { - if ((_voy._field476 - _voy._RTVNum) >= 36 && _voy._field4B8 < 5 && + if ((_voy._RTVLimit - _voy._RTVNum) >= 36 && _voy._field4B8 < 5 && _playStamp2 <= 151 && _playStamp2 > 146) { if ((_voy._switchBGNum < _checkPhoneVal || _checkPhoneVal > 180) && !_soundManager.getVOCStatus()) { -- cgit v1.2.3