diff options
author | Paul Gilbert | 2013-12-29 09:58:43 +1100 |
---|---|---|
committer | Paul Gilbert | 2013-12-29 09:58:43 +1100 |
commit | 10af04da6a9a01d2f1ff5febed86c4c5ca6cfb8d (patch) | |
tree | 4f8dba56e6f8121d0fd826b54cb6df7018ffe064 /engines/voyeur | |
parent | 1256fb6b666a36fbbd8f3223d2c776bca9a3ca83 (diff) | |
download | scummvm-rg350-10af04da6a9a01d2f1ff5febed86c4c5ca6cfb8d.tar.gz scummvm-rg350-10af04da6a9a01d2f1ff5febed86c4c5ca6cfb8d.tar.bz2 scummvm-rg350-10af04da6a9a01d2f1ff5febed86c4c5ca6cfb8d.zip |
VOYEUR: Mouse flags cleanup and in progress work on doGossip
Diffstat (limited to 'engines/voyeur')
-rw-r--r-- | engines/voyeur/animation.cpp | 13 | ||||
-rw-r--r-- | engines/voyeur/animation.h | 3 | ||||
-rw-r--r-- | engines/voyeur/events.cpp | 47 | ||||
-rw-r--r-- | engines/voyeur/events.h | 15 | ||||
-rw-r--r-- | engines/voyeur/files_threads.cpp | 34 | ||||
-rw-r--r-- | engines/voyeur/voyeur.cpp | 14 | ||||
-rw-r--r-- | engines/voyeur/voyeur_game.cpp | 70 |
7 files changed, 108 insertions, 88 deletions
diff --git a/engines/voyeur/animation.cpp b/engines/voyeur/animation.cpp index ce1fc9e2b5..4f8cca5707 100644 --- a/engines/voyeur/animation.cpp +++ b/engines/voyeur/animation.cpp @@ -67,7 +67,7 @@ bool RL2Decoder::loadStream(Common::SeekableReadStream *stream) { } const Common::List<Common::Rect> *RL2Decoder::getDirtyRects() const { - const Track *track = getTrack(0); + const Track *track = getTrack(1); if (track) return ((const RL2VideoTrack *)track)->getDirtyRects(); @@ -76,19 +76,26 @@ const Common::List<Common::Rect> *RL2Decoder::getDirtyRects() const { } void RL2Decoder::clearDirtyRects() { - Track *track = getTrack(0); + Track *track = getTrack(1); if (track) ((RL2VideoTrack *)track)->clearDirtyRects(); } void RL2Decoder::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) { - Track *track = getTrack(0); + Track *track = getTrack(1); if (track) ((RL2VideoTrack *)track)->copyDirtyRectsToBuffer(dst, pitch); } +Graphics::Surface *RL2Decoder::getVideoSurface() { + Track *track = getTrack(1); + assert(track); + + return ((RL2VideoTrack *)track)->getSurface(); +} + /*------------------------------------------------------------------------*/ RL2Decoder::RL2FileHeader::RL2FileHeader() { diff --git a/engines/voyeur/animation.h b/engines/voyeur/animation.h index b06e3cb5d9..feaaf2166c 100644 --- a/engines/voyeur/animation.h +++ b/engines/voyeur/animation.h @@ -78,7 +78,7 @@ public: const Common::List<Common::Rect> *getDirtyRects() const; void clearDirtyRects(); void copyDirtyRectsToBuffer(uint8 *dst, uint pitch); - + Graphics::Surface *getVideoSurface(); private: class RL2AudioTrack : public AudioTrack { public: @@ -112,6 +112,7 @@ private: uint16 getWidth() const; uint16 getHeight() const; + Graphics::Surface *getSurface() { return _surface; } Graphics::PixelFormat getPixelFormat() const; int getCurFrame() const { return _curFrame; } int getFrameCount() const { return _header._numFrames; } diff --git a/engines/voyeur/events.cpp b/engines/voyeur/events.cpp index 469d80cc6e..890eaeaf23 100644 --- a/engines/voyeur/events.cpp +++ b/engines/voyeur/events.cpp @@ -74,6 +74,11 @@ EventsManager::EventsManager(): _intPtr(_gameData), _priorFrameTime = g_system->getMillis(); _joe = 0; Common::fill(&_keyState[0], &_keyState[256], false); + + _leftClick = _rightClick = false; + _mouseClicked = _mouseUnk = false; + _newLeftClick = _newRightClick = false;; + _newMouseClicked = _newMouseUnk = false; _v2A0A2 = 0; _videoComputerBut4 = 0; @@ -106,11 +111,6 @@ void EventsManager::vStopCycle() { } void EventsManager::sWaitFlip() { - while (_gameData._flipWait && !_vm->shouldQuit()) { - pollEvents(); - g_system->delayMillis(10); - } - Common::Array<ViewPortResource *> &viewPorts = _vm->_graphicsManager._viewPortListPtr->_entries; for (uint idx = 0; idx < viewPorts.size(); ++idx) { ViewPortResource &viewPort = *viewPorts[idx]; @@ -128,6 +128,11 @@ void EventsManager::sWaitFlip() { viewPort._flags &= ~DISPFLAG_40; } } + + while (_gameData._flipWait && !_vm->shouldQuit()) { + pollEvents(); + g_system->delayMillis(10); + } } void EventsManager::checkForNextFrameCounter() { @@ -221,7 +226,7 @@ void EventsManager::delayClick(int cycles) { g_system->delayMillis(10); getMouseInfo(); } while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd - && !_vm->_voy._mouseClicked); + && !_vm->_eventsManager._mouseClicked); } void EventsManager::pollEvents() { @@ -243,19 +248,19 @@ void EventsManager::pollEvents() { return; case Common::EVENT_LBUTTONDOWN: _mouseButton = 1; - _vm->_voy._newLeftClick = true; - _vm->_voy._newMouseClicked = true; + _vm->_eventsManager._newLeftClick = true; + _vm->_eventsManager._newMouseClicked = true; return; case Common::EVENT_RBUTTONDOWN: _mouseButton = 2; - _vm->_voy._newRightClick = true; - _vm->_voy._newMouseClicked = true; + _vm->_eventsManager._newRightClick = true; + _vm->_eventsManager._newMouseClicked = true; return; case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONUP: - _vm->_voy._newMouseClicked = false; - _vm->_voy._newLeftClick = false; - _vm->_voy._newRightClick = false; + _vm->_eventsManager._newMouseClicked = false; + _vm->_eventsManager._newLeftClick = false; + _vm->_eventsManager._newRightClick = false; _mouseButton = 0; return; case Common::EVENT_MOUSEMOVE: @@ -453,15 +458,15 @@ void EventsManager::getMouseInfo() { } } - _vm->_voy._mouseClicked = _vm->_voy._newMouseClicked; - _vm->_voy._leftClick = _vm->_voy._newLeftClick; - _vm->_voy._rightClick = _vm->_voy._newRightClick; - _vm->_voy._mouseUnk = _vm->_voy._newMouseUnk; + _vm->_eventsManager._mouseClicked = _vm->_eventsManager._newMouseClicked; + _vm->_eventsManager._leftClick = _vm->_eventsManager._newLeftClick; + _vm->_eventsManager._rightClick = _vm->_eventsManager._newRightClick; + _vm->_eventsManager._mouseUnk = _vm->_eventsManager._newMouseUnk; - _vm->_voy._newMouseClicked = false; - _vm->_voy._newLeftClick = false; - _vm->_voy._newRightClick = false; - _vm->_voy._mouseUnk = false; + _vm->_eventsManager._newMouseClicked = false; + _vm->_eventsManager._newLeftClick = false; + _vm->_eventsManager._newRightClick = false; + _vm->_eventsManager._mouseUnk = false; } void EventsManager::checkForKey() { diff --git a/engines/voyeur/events.h b/engines/voyeur/events.h index 3d1c5779e5..487d59e94d 100644 --- a/engines/voyeur/events.h +++ b/engines/voyeur/events.h @@ -125,15 +125,7 @@ public: int _curICF0; int _curICF1; int _fadeICF0; - bool _leftClick, _rightClick; - bool _mouseClicked; - bool _mouseUnk; int _policeEvent; - - // Fields not originally in _voy, but I'm putting in for convenience - bool _newMouseClicked; - bool _newLeftClick, _newRightClick; - bool _newMouseUnk; }; class IntData { @@ -193,6 +185,13 @@ public: int _fadeCount; int _fadeStatus; + bool _leftClick, _rightClick; + bool _mouseClicked; + bool _mouseUnk; + bool _newMouseClicked; + bool _newLeftClick, _newRightClick; + bool _newMouseUnk; + int _v2A0A2; int _videoComputerBut4; int _videoDead; diff --git a/engines/voyeur/files_threads.cpp b/engines/voyeur/files_threads.cpp index 6b2b26860d..1d04ddc44e 100644 --- a/engines/voyeur/files_threads.cpp +++ b/engines/voyeur/files_threads.cpp @@ -406,7 +406,7 @@ void ThreadResource::parsePlayCommands() { _vm->_voy._field478 |= 16; _vm->_eventsManager.startCursorBlink(); - while (!_vm->shouldQuit() && !_vm->_voy._mouseClicked && + while (!_vm->shouldQuit() && !_vm->_eventsManager._mouseClicked && _vm->_soundManager.getVOCStatus()) _vm->_eventsManager.delayClick(1); @@ -460,7 +460,7 @@ void ThreadResource::parsePlayCommands() { } _vm->_eventsManager._videoDead = -1; - if (_field42 == 2 && _vm->_voy._mouseClicked == 0) { + if (_field42 == 2 && _vm->_eventsManager._mouseClicked == 0) { _vm->_voy._field470 = 132; parseIndex = 999; } else { @@ -515,7 +515,7 @@ void ThreadResource::parsePlayCommands() { Common::String file = Common::String::format("news%d.voc", i + 1); _vm->_soundManager.startVOCPlay(file); - while (!_vm->shouldQuit() && !_vm->_voy._mouseClicked && + while (!_vm->shouldQuit() && !_vm->_eventsManager._mouseClicked && _vm->_soundManager.getVOCStatus()) { _vm->_eventsManager.delayClick(1); _vm->_eventsManager.getMouseInfo(); @@ -526,7 +526,7 @@ void ThreadResource::parsePlayCommands() { if (i == (count - 1)) _vm->_eventsManager.delay(480); - if (_vm->shouldQuit() || _vm->_voy._mouseClicked) + if (_vm->shouldQuit() || _vm->_eventsManager._mouseClicked) break; } @@ -706,7 +706,7 @@ void ThreadResource::parsePlayCommands() { Common::String fname = Common::String::format("news%d.voc", idx); - while (!_vm->shouldQuit() && !_vm->_voy._mouseClicked && + while (!_vm->shouldQuit() && !_vm->_eventsManager._mouseClicked && _vm->_soundManager.getVOCStatus()) _vm->_eventsManager.delay(1); @@ -714,7 +714,7 @@ void ThreadResource::parsePlayCommands() { if (idx == 3) _vm->_eventsManager.delay(3); - if (_vm->shouldQuit() || _vm->_voy._mouseClicked) + if (_vm->shouldQuit() || _vm->_eventsManager._mouseClicked) break; } @@ -1107,7 +1107,7 @@ int ThreadResource::doApt() { _vm->flipPageAndWait(); - } while (!_vm->shouldQuit() && (!_vm->_voy._leftClick || hotspotId == -1)); + } while (!_vm->shouldQuit() && (!_vm->_eventsManager._leftClick || hotspotId == -1)); pt = _vm->_eventsManager.getMousePos(); _doAptPosX = pt.x; @@ -1231,10 +1231,10 @@ void ThreadResource::doRoom() { vm._eventsManager._intPtr._hasPalette = true; vm._graphicsManager.flipPage(); vm._eventsManager.sWaitFlip(); - } while (!vm.shouldQuit() && !voy._mouseClicked); + } while (!vm.shouldQuit() && !vm._eventsManager._mouseClicked); - if (!voy._leftClick || i4e4 == -1) { - if (voy._rightClick) + if (!vm._eventsManager._leftClick || i4e4 == -1) { + if (vm._eventsManager._rightClick) breakFlag = true; Common::Point pt = vm._eventsManager.getMousePos(); @@ -1258,7 +1258,7 @@ void ThreadResource::doRoom() { vm._eventsManager.addComputerEventStart(); - voy._mouseClicked = false; + vm._eventsManager._mouseClicked = false; vm._eventsManager.startCursorBlink(); int v = vm.doComputerText(9999); @@ -1271,7 +1271,7 @@ void ThreadResource::doRoom() { } voy._field478 &= ~0x10; - if (!voy._mouseClicked) + if (!vm._eventsManager._mouseClicked) vm._eventsManager.delayClick(18000); vm._bVoy->freeBoltGroup(vm._playStamp1); @@ -1487,7 +1487,7 @@ int ThreadResource::doInterface() { pt = _vm->_eventsManager.getMousePos(); if ((_vm->_voy._field476 <= _vm->_voy._RTVNum) || ((_vm->_voy._field478 & 0x80) && - (_vm->_voy._rightClick != NULL) && (pt.x == 0))) { + (_vm->_eventsManager._rightClick != NULL) && (pt.x == 0))) { _vm->_eventsManager.getMouseInfo(); if (_vm->_voy._transitionId == 15) { @@ -1495,7 +1495,7 @@ int ThreadResource::doInterface() { _vm->_voy._transitionId = 17; _vm->_soundManager.stopVOCPlay(); _vm->checkTransition(); - _vm->_voy._leftClick = true; + _vm->_eventsManager._leftClick = true; } else { _vm->_voy._field478 = 1; _currentMouseX = pt.x; @@ -1518,15 +1518,15 @@ int ThreadResource::doInterface() { _vm->_eventsManager._intPtr.field1A = 0; } } - } while (!_vm->_voy._rightClick && !_vm->shouldQuit() && - (!_vm->_voy._leftClick || regionIndex == -1)); + } while (!_vm->_eventsManager._rightClick && !_vm->shouldQuit() && + (!_vm->_eventsManager._leftClick || regionIndex == -1)); _vm->_voy._field478 |= 1; _vm->_bVoy->freeBoltGroup(_vm->_playStamp1); if (_vm->_playStamp2 != -1) _vm->_soundManager.stopVOCPlay(); - return !_vm->_voy._rightClick ? regionIndex : -2; + return !_vm->_eventsManager._rightClick ? regionIndex : -2; } bool ThreadResource::goToStateID(int stackId, int sceneId) { diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp index f4b83e589a..b2256f06b5 100644 --- a/engines/voyeur/voyeur.cpp +++ b/engines/voyeur/voyeur.cpp @@ -184,12 +184,12 @@ bool VoyeurEngine::doHeadTitle() { // showTitleScreen(); // Opening - if (!_voy._mouseClicked) { + if (!_eventsManager._mouseClicked) { // doOpening(); // doTransitionCard("Saturday Afternoon", "Player's Apartment"); _eventsManager.delayClick(90); } else { - _voy._mouseClicked = false; + _eventsManager._mouseClicked = false; } if (_voy._field478 & 0x80) { @@ -341,8 +341,8 @@ bool VoyeurEngine::doLock() { _eventsManager._intPtr._hasPalette = true; _eventsManager.delay(1); - } while (!shouldQuit() && !_voy._mouseClicked); - _voy._mouseClicked = false; + } while (!shouldQuit() && !_eventsManager._mouseClicked); + _eventsManager._mouseClicked = false; } while (!shouldQuit() && key == -1); _soundManager.abortVOCMap(); @@ -493,7 +493,7 @@ void VoyeurEngine::doOpening() { decoder.loadFile("a2300100.rl2"); decoder.start(); - while (!shouldQuit() && !decoder.endOfVideo() && !_voy._mouseClicked) { + while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager._mouseClicked) { if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); _graphicsManager.setPalette(palette, 0, 256); @@ -517,7 +517,7 @@ void VoyeurEngine::playRL2Video(const Common::String &filename) { decoder.loadFile(filename); decoder.start(); - while (!shouldQuit() && !decoder.endOfVideo() && !_voy._mouseClicked) { + while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager._mouseClicked) { if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); _graphicsManager.setPalette(palette, 0, 256); @@ -554,7 +554,7 @@ void VoyeurEngine::playAVideoDuration(int videoId, int duration) { decoder.seek(Audio::Timestamp(_voy._vocSecondsOffset * 1000)); int endFrame = decoder.getCurFrame() + totalFrames; - while (!shouldQuit() && !decoder.endOfVideo() && !_voy._mouseClicked && + while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager._mouseClicked && (decoder.getCurFrame() < endFrame)) { if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp index 8a228874f1..8f49680202 100644 --- a/engines/voyeur/voyeur_game.cpp +++ b/engines/voyeur/voyeur_game.cpp @@ -144,7 +144,7 @@ void VoyeurEngine::playStamp() { _graphicsManager._backColors = _bVoy->boltEntry(_playStamp1 + 1)._cMapResource; buttonId = getChooseButton(); - if (_voy._rightClick) + if (_eventsManager._rightClick) buttonId = 4; _bVoy->freeBoltGroup(_playStamp1); @@ -350,7 +350,7 @@ void VoyeurEngine::reviewTape() { if ((tempPos.y - 31) % 15 >= 12 || (si + foundIndex) >= _voy._eventCount) { _eventsManager.setCursorColor(128, 0); foundIndex = 999; - } else if (!_voy._leftClick) { + } else if (!_eventsManager._leftClick) { _eventsManager.setCursorColor(128, 2); foundIndex = 999; } else { @@ -409,7 +409,7 @@ void VoyeurEngine::reviewTape() { _eventsManager._intPtr.field38 = true; _eventsManager._intPtr._hasPalette = true; - if (_voy._mouseClicked || _voy._mouseUnk) { + if (_eventsManager._mouseClicked || _eventsManager._mouseUnk) { switch (foundIndex) { case 2: if (si > 0) { @@ -456,17 +456,17 @@ void VoyeurEngine::reviewTape() { } pt = _eventsManager.getMousePos(); - if (_voy._mouseClicked && _voy._viewBounds->left == pt.x && - (_voy._field478 & 0x40) && _voy._rightClick) { + if (_eventsManager._mouseClicked && _voy._viewBounds->left == pt.x && + (_voy._field478 & 0x40) && _eventsManager._rightClick) { WRITE_LE_UINT32(_controlPtr->_ptr + 4, (pt.y / 60) + 1); foundIndex = -1; - _voy._rightClick = 0; + _eventsManager._rightClick = 0; } - if (_voy._rightClick) + if (_eventsManager._rightClick) foundIndex = 0; - } while (!shouldQuit() && (!_voy._mouseClicked || foundIndex == -1)); + } while (!shouldQuit() && (!_eventsManager._mouseClicked || foundIndex == -1)); @@ -487,42 +487,50 @@ void VoyeurEngine::doGossip() { if (!_bVoy->getBoltGroup(0x300)) return; - PictureResource *pic = _bVoy->boltEntry(0x300)._picResource; - (*_graphicsManager._vPort)->setupViewPort(pic); - CMapResource *pal = _bVoy->boltEntry(0x301)._cMapResource; - pal->startFade(); - - flipPageAndWaitForFade(); - // Load the gossip animation ::Video::RL2Decoder decoder; decoder.loadFile("a2050100.rl2"); + decoder.start(); + + PictureResource *bgPic = _bVoy->boltEntry(0x300)._picResource; + CMapResource *pal = _bVoy->boltEntry(0x301)._cMapResource; + pal->startFade(); + + // Transfer initial background to video decoder + PictureResource videoFrame(decoder.getVideoSurface()); + _graphicsManager.sDrawPic(bgPic, &videoFrame, Common::Point(-32, -20)); byte *frameNumsP = _bVoy->memberAddr(0x309); - byte *posP = _bVoy->memberAddr(0x30A); + byte *posP = _bVoy->boltEntry(0x30A)._data; // Main playback loop + int picCtr = 0; decoder.start(); - while (!shouldQuit() && !decoder.endOfVideo() && !_voy._mouseClicked) { + while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager._mouseClicked) { if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); _graphicsManager.setPalette(palette, 0, 256); } if (decoder.needsUpdate()) { - const Graphics::Surface *frame = decoder.decodeNextFrame(); - - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)_graphicsManager._screenSurface.getPixels()); - + // If reached a point where a new background is needed, load it + // and copy over to the video decoder if (decoder.getCurFrame() >= READ_LE_UINT16(frameNumsP + picCtr * 4)) { - PictureResource *pic = _bVoy->boltEntry(0x302 + picCtr)._picResource; + PictureResource *newBgPic = _bVoy->boltEntry(0x302 + picCtr)._picResource; Common::Point pt(READ_LE_UINT16(posP + 4 * picCtr + 2), READ_LE_UINT16(posP + 4 * picCtr)); - _graphicsManager.sDrawPic(pic, *_graphicsManager._vPort, pt); + + _graphicsManager.sDrawPic(newBgPic, &videoFrame, pt); + ++picCtr; } + // Decode the next frame and display + const Graphics::Surface *frame = decoder.decodeNextFrame(); + Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, + (byte *)_graphicsManager._screenSurface.getPixels()); + + flipPageAndWait(); } @@ -533,7 +541,7 @@ void VoyeurEngine::doGossip() { decoder.loadFile("a2110100.rl2"); decoder.start(); - while (!shouldQuit() && !decoder.endOfVideo() && !_voy._mouseClicked) { + while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager._mouseClicked) { if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); _graphicsManager.setPalette(palette, 0, 256); @@ -571,7 +579,7 @@ void VoyeurEngine::doTapePlaying() { cycle->vStartCycle(); _soundManager.startVOCPlay("vcr.voc"); - while (!shouldQuit() && !_voy._mouseClicked && _soundManager.getVOCStatus()) { + while (!shouldQuit() && !_eventsManager._mouseClicked && _soundManager.getVOCStatus()) { _eventsManager.delayClick(2); } @@ -734,8 +742,8 @@ int VoyeurEngine::getChooseButton() { Common::Point(pt.x + 13, pt.y - 12)); flipPageAndWait(); - } while (!shouldQuit() && !_voy._mouseClicked); - } while (!shouldQuit() && selectedIndex == -1 && !_voy._rightClick); + } while (!shouldQuit() && !_eventsManager._mouseClicked); + } while (!shouldQuit() && selectedIndex == -1 && !_eventsManager._rightClick); return selectedIndex; } @@ -992,7 +1000,7 @@ bool VoyeurEngine::doComputerText(int maxLen) { _eventsManager.getMouseInfo(); ++totalChars; - } while (!shouldQuit() && !_voy._mouseClicked && totalChars < maxLen); + } while (!shouldQuit() && !_eventsManager._mouseClicked && totalChars < maxLen); _voy._field4EE = 0; } @@ -1119,7 +1127,7 @@ void VoyeurEngine::doEvidDisplay(int evidId, int eventId) { int arrIndex = 0; int evidIdx = evidId; - while (!shouldQuit() && !_voy._rightClick) { + while (!shouldQuit() && !_eventsManager._rightClick) { if (_playStamp2 != -1 && !_soundManager.getVOCStatus()) { if (_voy._vocSecondsOffset > 60) _voy._vocSecondsOffset = 0; @@ -1128,7 +1136,7 @@ void VoyeurEngine::doEvidDisplay(int evidId, int eventId) { } _eventsManager.delayClick(600); - if (_voy._rightClick) + if (_eventsManager._rightClick) break; if (count == 0 || evidIdx >= eventId) continue; |