aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2013-12-30 16:52:50 +1100
committerPaul Gilbert2013-12-30 16:52:50 +1100
commit60743fc8c90a9d35bde1e632ed2ae5b55fb8168d (patch)
treefb6fcfbb3e9df1ab3462dd6e785941debcda722e
parent485c19b569bce6b69dd8b90c5304dca334f9ddc5 (diff)
downloadscummvm-rg350-60743fc8c90a9d35bde1e632ed2ae5b55fb8168d.tar.gz
scummvm-rg350-60743fc8c90a9d35bde1e632ed2ae5b55fb8168d.tar.bz2
scummvm-rg350-60743fc8c90a9d35bde1e632ed2ae5b55fb8168d.zip
VOYEUR: Implemented vDoCycleInt
-rw-r--r--engines/voyeur/events.cpp80
-rw-r--r--engines/voyeur/events.h6
-rw-r--r--engines/voyeur/files.cpp23
-rw-r--r--engines/voyeur/files.h5
4 files changed, 104 insertions, 10 deletions
diff --git a/engines/voyeur/events.cpp b/engines/voyeur/events.cpp
index 61c37a6db9..115482ec29 100644
--- a/engines/voyeur/events.cpp
+++ b/engines/voyeur/events.cpp
@@ -75,7 +75,7 @@ EventsManager::EventsManager(): _intPtr(_gameData),
_joe = 0;
Common::fill(&_keyState[0], &_keyState[256], false);
Common::fill(&_cycleTime[0], &_cycleTime[4], 0);
- Common::fill(&_cycleNext[0], &_cycleNext[4], 0);
+ Common::fill(&_cycleNext[0], &_cycleNext[4], (byte *)nullptr);
_cyclePtr = NULL;
_leftClick = _rightClick = false;
@@ -383,7 +383,83 @@ void EventsManager::vDoFadeInt() {
}
void EventsManager::vDoCycleInt() {
- warning("TODO");
+ for (int idx = 3; idx >= 0; --idx) {
+ if (_cyclePtr->_v[idx] && --_cycleTime[idx] <= 0) {
+ byte *pSrc = _cycleNext[idx];
+ byte *pPal = _vm->_graphicsManager._VGAColors;
+
+ if (_cyclePtr->_v[idx] == 1) {
+ do {
+ int palIndex = READ_LE_UINT16(pSrc);
+ pPal[palIndex * 3] = pSrc[3];
+ pPal[palIndex * 3 + 1] = pSrc[4];
+ pPal[palIndex * 3 + 1] = pSrc[5];
+ pSrc += 6;
+
+ if ((int16)READ_LE_UINT16(pSrc) >= 0) {
+ // Resetting back to start of cycle data
+ pSrc = _cycleNext[idx];
+ break;
+ }
+ } while (*(pSrc + 2) == 0);
+
+ _cycleNext[idx] = pSrc;
+ _cycleTime[idx] = pSrc[2];
+ } else {
+ _cycleTime[idx] = pSrc[4];
+
+ if (pSrc[5] == 1) {
+ // Move palette entry to end of range
+ int start = READ_LE_UINT16(pSrc);
+ int end = READ_LE_UINT16(&pSrc[2]);
+ int len = end - start;
+
+ // Store the RGB of the first entry to be moved
+ byte r = pSrc[start * 3];
+ byte g = pSrc[start * 3 + 1];
+ byte b = pSrc[start * 3 + 2];
+
+ // Move the remainder of the range backwards one entry
+ // TODO: Is this allowing for overlap properly?
+ Common::copy(&pSrc[start * 3 + 3], &pSrc[end * 3], &pSrc[start * 3]);
+
+ // Place the original saved entry at the end of the range
+ pSrc[end * 3 - 3] = r;
+ pSrc[end * 3 - 2] = g;
+ pSrc[end * 3 - 1] = b;
+
+ if (_fadeStatus & 1) {
+ //dx = start, di = end
+ warning("TODO: Adjustment of ViewPortListResource");
+ }
+ } else {
+ // Move palette entry to end of range
+ int start = READ_LE_UINT16(pSrc);
+ int end = READ_LE_UINT16(&pSrc[2]);
+ int len = end - start;
+
+ // Store the RGB of the entry to be moved
+ byte r = pSrc[end * 3 - 3];
+ byte g = pSrc[end * 3 - 2];
+ byte b = pSrc[end * 3 - 1];
+
+ // Move the remainder of the range forwards one entry
+ // TODO: Does this allow for overlap range correctly?
+ Common::copy_backward(&pSrc[start * 3 + 3], &pSrc[end * 3], &pSrc[start * 3]);
+
+ // Place the original saved entry at the end of the range
+ pSrc[start * 3] = r;
+ pSrc[start * 3] = g;
+ pSrc[start * 3] = b;
+
+ if (_fadeStatus & 1) {
+ //dx = start, di = end
+ warning("TODO: Adjustment of ViewPortListResource");
+ }
+ }
+ }
+ }
+ }
}
diff --git a/engines/voyeur/events.h b/engines/voyeur/events.h
index 99f583a2d0..c346426fad 100644
--- a/engines/voyeur/events.h
+++ b/engines/voyeur/events.h
@@ -162,9 +162,6 @@ private:
int _mouseButton;
Common::List<IntNode *> _intNodes;
Common::Point _mousePos;
- int _cycleTime[4];
- int _cycleNext[4];
- VInitCycleResource *_cyclePtr;
void mainVoyeurIntFunc();
private:
@@ -198,6 +195,9 @@ public:
int _v2A0A2;
int _videoComputerBut4;
int _videoDead;
+ int _cycleTime[4];
+ byte *_cycleNext[4];
+ VInitCycleResource *_cyclePtr;
public:
EventsManager();
void setVm(VoyeurEngine *vm) { _vm = vm; }
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp
index d02c5ce577..b4867881e0 100644
--- a/engines/voyeur/files.cpp
+++ b/engines/voyeur/files.cpp
@@ -1408,18 +1408,33 @@ void CMapResource::startFade() {
/*------------------------------------------------------------------------*/
-VInitCycleResource::VInitCycleResource(BoltFilesState &state, const byte *src) {
+VInitCycleResource::VInitCycleResource(BoltFilesState &state, const byte *src):
+ _state(state) {
+ // Set up arrays
for (int i = 0; i < 4; ++i) {
+ _v[i] = READ_LE_UINT16(src + i * 2);
state._curLibPtr->resolveIt(READ_LE_UINT32(src + 8 + i * 4), &_ptr[i]);
}
}
-void VInitCycleResource::vStartCycle() {
- error("TODO");
+void VInitCycleResource::vStartCycle(int flags) {
+ EventsManager &evt = _state._vm->_eventsManager;
+ evt._cycleIntNode._flags |= 1;
+ evt._cyclePtr = this;
+
+ for (int i = 0; i < 4; ++i) {
+ evt._cycleNext[i] = _ptr[i];
+ evt._cycleTime[i] = 0;
+ }
+
+ evt._cycleStatus = flags | 1;
+ evt._cycleIntNode._flags &= ~1;
}
void VInitCycleResource::vStopCycle() {
- error("TODO: vStopCycle");
+ EventsManager &evt = _state._vm->_eventsManager;
+ evt._cycleIntNode._flags |= 1;
+ evt._cycleStatus &= ~1;
}
/*------------------------------------------------------------------------*/
diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h
index 47a6df5c8f..dd798915a7 100644
--- a/engines/voyeur/files.h
+++ b/engines/voyeur/files.h
@@ -404,13 +404,16 @@ public:
};
class VInitCycleResource {
+private:
+ BoltFilesState &_state;
public:
+ int _v[4];
byte *_ptr[4];
public:
VInitCycleResource(BoltFilesState &state, const byte *src);
virtual ~VInitCycleResource() {}
- void vStartCycle();
+ void vStartCycle(int flags = 0);
void vStopCycle();
};