From 11a4fef956dc955c44fc323bdb28580bcb8888e5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Jun 2013 15:41:22 -0400 Subject: VOYEUR: Some further work implementing fading --- engines/voyeur/events.cpp | 76 ++++++++++++++++++++++++++++++++++++--------- engines/voyeur/events.h | 10 ++++-- engines/voyeur/game.cpp | 12 +++++-- engines/voyeur/game.h | 13 ++++++-- engines/voyeur/graphics.cpp | 2 +- 5 files changed, 90 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/voyeur/events.cpp b/engines/voyeur/events.cpp index 88a0be879f..f76f99ac9f 100644 --- a/engines/voyeur/events.cpp +++ b/engines/voyeur/events.cpp @@ -33,9 +33,17 @@ IntNode::IntNode() { _flags = 0; } +IntNode::IntNode(uint16 curTime, uint16 timeReset, uint16 flags) { + _intFunc = NULL; + _curTime = curTime; + _timeReset = timeReset; + _flags = flags; +} + /*------------------------------------------------------------------------*/ -EventsManager::EventsManager(): _intPtr(_audioStruc) { +EventsManager::EventsManager(): _intPtr(_gameData), + _fadeIntNode(0, 0, 3), _cycleIntNode(0, 0, 3) { _cycleStatus = 0; _mouseButton = 0; _fadeStatus = 0; @@ -65,7 +73,7 @@ void EventsManager::vStopCycle() { void EventsManager::sWaitFlip() { // TODO: See if this needs a proper wait loop with event polling - //while (_intPtr._field39) ; + //while (_intPtr.field39) ; Common::Array &viewPorts = _vm->_graphicsManager._viewPortListPtr->_entries; for (uint idx = 0; idx < viewPorts.size(); ++idx) { @@ -93,7 +101,7 @@ void EventsManager::checkForNextFrameCounter() { _priorFrameTime = milli; // Run the timer-based updates - videoTimer(); + voyeurTimer(); // Display the frame g_system->copyRectToScreen((byte *)_vm->_graphicsManager._screenSurface.pixels, @@ -105,13 +113,51 @@ void EventsManager::checkForNextFrameCounter() { } } +void EventsManager::voyeurTimer() { + _gameData.field22 += _gameData.field24; + _gameData.field1A += _gameData.field1E; + // _gameData.field1C += _gameData._timerFn; *** WHY INC field by a function pointer?! + + _gameData.field16 = 0; + _gameData.field3D = 1; + + if (--_gameData.field26 <= 0) { + if (_gameData._flipWait) { + _gameData.field38 = 1; + _gameData._flipWait = false; + _gameData.field3B = 0; + } + + _gameData.field26 >>= 8; + } + + videoTimer(); + + // Iterate through the list of registered nodes + Common::List::iterator i; + for (i = _intNodes.begin(); i != _intNodes.end(); ++i) { + IntNode &node = **i; + + if (node._flags & 1) + continue; + if (!(node._flags & 2)) { + if (--node._curTime != 0) + continue; + + node._curTime = node._timeReset; + } + + (this->*node._intFunc)(); + } +} + void EventsManager::videoTimer() { - if (_audioStruc._hasPalette) { - _audioStruc._hasPalette = false; + if (_gameData._hasPalette) { + _gameData._hasPalette = false; - g_system->getPaletteManager()->setPalette(_audioStruc._palette, - _audioStruc._palStartIndex, - _audioStruc._palEndIndex - _audioStruc._palStartIndex + 1); + g_system->getPaletteManager()->setPalette(_gameData._palette, + _gameData._palStartIndex, + _gameData._palEndIndex - _gameData._palStartIndex + 1); } } @@ -193,7 +239,7 @@ void EventsManager::startFade(CMapResource *cMap) { } if (cMap->_fadeStatus & 2) - _intPtr._field3B = 1; + _intPtr.field3B = 1; _fadeIntNode._flags &= ~1; } else { byte *vgaP = &_vm->_graphicsManager._VGAColors[_fadeFirstCol * 3]; @@ -213,7 +259,7 @@ void EventsManager::startFade(CMapResource *cMap) { _intPtr._hasPalette = true; if (!(cMap->_fadeStatus & 2)) - _intPtr._field38 = 1; + _intPtr.field38 = 1; } if (_cycleStatus & 1) @@ -225,7 +271,7 @@ void EventsManager::addIntNode(IntNode *node) { } void EventsManager::addFadeInt() { - IntNode &node = _fadeIntNode; + IntNode &node = _fade2IntNode; node._intFunc = &EventsManager::fadeIntFunc; node._flags = 0; node._curTime = 0; @@ -235,7 +281,7 @@ void EventsManager::addFadeInt() { } void EventsManager::vDoFadeInt() { - if (_intPtr._field3B & 1) + if (_intPtr.field3B & 1) return; if (--_fadeCount == 0) { _fadeIntNode._flags |= 1; @@ -262,7 +308,7 @@ void EventsManager::vDoFadeInt() { _intPtr._palEndIndex = _fadeLastCol; _intPtr._hasPalette = true; - _intPtr._field38 = 1; + _intPtr.field38 = 1; } void EventsManager::vDoCycleInt() { @@ -277,7 +323,9 @@ void EventsManager::fadeIntFunc() { void EventsManager::vInitColor() { _fadeIntNode._intFunc = &EventsManager::vDoFadeInt; _cycleIntNode._intFunc = &EventsManager::vDoCycleInt; - // TODO: more + + addIntNode(&_fadeIntNode); + addIntNode(&_cycleIntNode); } } // End of namespace Voyeur diff --git a/engines/voyeur/events.h b/engines/voyeur/events.h index 1b47109c5c..22626cd003 100644 --- a/engines/voyeur/events.h +++ b/engines/voyeur/events.h @@ -24,6 +24,7 @@ #define VOYEUR_EVENTS_H #include "common/scummsys.h" +#include "common/list.h" #include "voyeur/game.h" namespace Voyeur { @@ -40,11 +41,12 @@ typedef void (EventsManager::*EventMethodPtr)(); class IntNode { public: EventMethodPtr _intFunc; - uint32 _curTime; - uint32 _timeReset; + uint16 _curTime; + uint16 _timeReset; uint32 _flags; public: IntNode(); + IntNode(uint16 curTime, uint16 timeReset, uint16 flags); }; class EventsManager { @@ -59,14 +61,16 @@ private: void mainVoyeurIntFunc(); private: void checkForNextFrameCounter(); + void voyeurTimer(); void videoTimer(); void vDoFadeInt(); void vDoCycleInt(); void fadeIntFunc(); public: - IntData _audioStruc; + IntData _gameData; IntData &_intPtr; IntNode _fadeIntNode; + IntNode _fade2IntNode; IntNode _cycleIntNode; IntNode _evintnode; IntNode _mainIntNode; diff --git a/engines/voyeur/game.cpp b/engines/voyeur/game.cpp index d6aeb69eb7..e1ad8592f0 100644 --- a/engines/voyeur/game.cpp +++ b/engines/voyeur/game.cpp @@ -28,8 +28,16 @@ IntData::IntData() { _field9 = false; _flipWait = false; _hasPalette = false; - _field3B = 0; - _field2A = 0; + field16 = 0; + field1A = 0; + field1E = 0; + field22 = 0; + field24 = 0; + field26 = 0; + field2A = 0; + field38 = 0; + field3B = 0; + field3D = 0; _palStartIndex = 0; _palEndIndex = 0; _palette = NULL; diff --git a/engines/voyeur/game.h b/engines/voyeur/game.h index 7acc921096..5ad90ddf1a 100644 --- a/engines/voyeur/game.h +++ b/engines/voyeur/game.h @@ -101,10 +101,17 @@ class IntData { public: bool _field9; bool _flipWait; - int _field2A; + int field16; + int field1A; + int field1E; + int field22; + int field24; + int field26; + int field2A; bool _hasPalette; - int _field38; - int _field3B; + int field38; + int field3B; + int field3D; int _palStartIndex; int _palEndIndex; byte *_palette; diff --git a/engines/voyeur/graphics.cpp b/engines/voyeur/graphics.cpp index a236e8bbd3..7f9fd48c8f 100644 --- a/engines/voyeur/graphics.cpp +++ b/engines/voyeur/graphics.cpp @@ -324,7 +324,7 @@ void GraphicsManager::sDrawPic(DisplayResource *srcDisplay, DisplayResource *des */ void GraphicsManager::sDisplayPic(PictureResource *pic) { if (pic->_flags & 8) { - _vm->_eventsManager._intPtr._field2A = READ_LE_UINT32(pic->_imgData) >> _sImageShift; + _vm->_eventsManager._intPtr.field2A = READ_LE_UINT32(pic->_imgData) >> _sImageShift; } _vm->_eventsManager._intPtr._flipWait = true; -- cgit v1.2.3