aboutsummaryrefslogtreecommitdiff
path: root/engines/voyeur/voyeur.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/voyeur/voyeur.cpp')
-rw-r--r--engines/voyeur/voyeur.cpp176
1 files changed, 166 insertions, 10 deletions
diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp
index 5c3c42c46f..c2e99076af 100644
--- a/engines/voyeur/voyeur.cpp
+++ b/engines/voyeur/voyeur.cpp
@@ -22,6 +22,7 @@
#include "voyeur/voyeur.h"
#include "voyeur/graphics.h"
+#include "voyeur/utils.h"
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
@@ -97,6 +98,7 @@ void VoyeurEngine::initialiseManagers() {
_eventsManager.setVm(this);
_filesManager.setVm(this);
_graphicsManager.setVm(this);
+ _soundManager.setVm(this);
}
void VoyeurEngine::ESP_Init() {
@@ -114,8 +116,7 @@ void VoyeurEngine::globalInitBolt() {
Common::fill((byte *)&_voy, (byte *)&_voy + sizeof(SVoy), 0);
_voy._eCursorOff[0x74 / 2] = 1;
_voy._eCursorOff[0x68 / 2] = 0;
- _voy._eventTable[998]._data3 = 63;
- _voy._eventTable[998]._data4 = 63;
+ _voy._eventTable[998]._data = NULL; // Original set 63h:63h
_voy._evidence[19] = 0;
_voy._evidence[17] = 0;
_voy._evidence[18] = 9999;
@@ -192,16 +193,171 @@ void VoyeurEngine::showConversionScreen() {
}
bool VoyeurEngine::doLock() {
- int var12 = 0;
- int var14 = 0;
- int di = 1;
- int wrongSize;
- byte *buttonVoc = _filesManager.fload("button.voc");
- byte *wrongVoc = _filesManager.fload("wrong.voc", &wrongSize);
- bool result = false;
+ bool result = true;
+ bool flag = false;
+ int buttonVocSize, wrongVocSize;
+ byte *buttonVoc = _filesManager.fload("button.voc", &buttonVocSize);
+ byte *wrongVoc = _filesManager.fload("wrong.voc", &wrongVocSize);
+ LockClass lock;
+ PictureResource *srcPic;
+ byte *keyData;
+ int keyCount;
+ Common::String msg;
+ int key;
if (_bVoy->getBoltGroup(0x10700)) {
-
+ lock.getSysDate();
+ lock.getThePassword();
+
+ _voy._eventTable[999]._type = lock.fieldC;
+ _voy._eventTable[999]._data = _bVoy->memberAddr(0x704);
+
+ Common::String password = lock._password;
+ srcPic = _bVoy->getPictureResource(0x702);
+
+ // Get the mappings of keys on the keypad
+ keyData = _bVoy->memberAddr(0x705);
+ keyCount = READ_LE_UINT16(keyData);
+
+ _graphicsManager._backColors = _bVoy->getCMapResource(0x7010000);
+ _graphicsManager._backgroundPage = _bVoy->getPictureResource(0x700);
+ (*_graphicsManager._vPort)->setupViewPort();
+
+ _graphicsManager._backColors->startFade();
+ (*_graphicsManager._vPort)->_flags |= 8;
+
+ _graphicsManager.flipPage();
+ _eventsManager.sWaitFlip();
+ while (!shouldQuit() && (_eventsManager._fadeStatus & 1))
+ _eventsManager.delay(1);
+
+ _eventsManager.setCursorTo(127, 0);
+ _graphicsManager.setColor(1, 0x40, 0x40, 0x40);
+ _graphicsManager.setColor(2, 0x60, 0x60, 0x60);
+ _graphicsManager.setColor(3, 0x0A, 0xA0, 0x0A);
+ _graphicsManager.setColor(4, 0x0E, 0xE0, 0x0E);
+
+ _eventsManager._intPtr.field38 = 1;
+ _eventsManager._intPtr._hasPalette = true;
+
+ _graphicsManager._fontPtr->_curFont = _bVoy->getBoltEntry(0x708)._fontResource;
+ _graphicsManager._fontPtr->_fontSaveBack = 0;
+ _graphicsManager._fontPtr->_fontFlags = 0;
+
+ Common::String dateString = lock.getDateString();
+ Common::String playString = Common::String::format("Last Play %s", msg.c_str());
+
+ bool breakFlag = false;
+ while (!breakFlag && !shouldQuit()) {
+ (*_graphicsManager._vPort)->setupViewPort();
+ (*_graphicsManager._vPort)->_flags |= 8;
+ _graphicsManager.flipPage();
+ _eventsManager.sWaitFlip();
+
+ // Display the last play time
+ _graphicsManager._fontPtr->_pos = Common::Point(0, 97);
+ _graphicsManager._fontPtr->_justify = 1;
+ _graphicsManager._fontPtr->_justifyWidth = 384;
+ _graphicsManager._fontPtr->_justifyHeight = 97;
+
+ (*_graphicsManager._vPort)->drawText(playString);
+ (*_graphicsManager._vPort)->_flags |= 8;
+ _graphicsManager.flipPage();
+ _eventsManager.sWaitFlip();
+
+ // Loop for getting key presses
+ do {
+ do {
+ // Scan through the list of key rects to check if a keypad key is highlighted
+ key = -1;
+ Common::Point mousePos = _eventsManager.getMousePos();
+
+ for (int keyIndex = 0; keyIndex < keyCount; ++keyIndex) {
+ int x1 = READ_LE_UINT16(keyData + (((keyIndex << 2) + 1) << 1));
+ int x2 = READ_LE_UINT16(keyData + (((keyIndex << 2) + 3) << 1));
+ int y1 = READ_LE_UINT16(keyData + (((keyIndex << 2) + 2) << 1));
+ int y2 = READ_LE_UINT16(keyData + (((keyIndex << 2) + 2) << 1));
+
+ if (mousePos.x >= x1 && mousePos.x <= x2 && mousePos.y >= y1 && mousePos.y <= y2) {
+ key = keyIndex;
+ }
+ }
+
+ _eventsManager.setCursorTo(127, (key == -1) ? 0 : 1);
+ _eventsManager._intPtr.field38 = 1;
+ _eventsManager._intPtr._hasPalette = true;
+
+ // TODO: Check is the mouse cursor being manually drawn here? I so, refactor
+ _graphicsManager.sDrawPic(srcPic, *_graphicsManager._vPort, mousePos);
+ (*_graphicsManager._vPort)->_flags |= 8;
+ _graphicsManager.flipPage();
+ _eventsManager.sWaitFlip();
+
+ _eventsManager.delay(1);
+ } while (!shouldQuit() && !_voy._incriminate);
+ } while (!shouldQuit() && key == -1);
+
+ _soundManager.abortVOCMap();
+ _soundManager.playVOCMap(buttonVoc, buttonVocSize);
+
+ while (_soundManager.vocMapStatus()) {
+ if (shouldQuit())
+ break;
+
+ _soundManager.continueVocMap();
+ _eventsManager.delay(1);
+ }
+
+ // Process the key
+ if (key < 10) {
+ if (playString.size() < 10) {
+ playString += '0' + key;
+ continue;
+ }
+ } else if (key == 10) {
+ if (!flag) {
+ if ((password.size() == 0 && !playString.size()) || (password == playString)) {
+ breakFlag = true;
+ result = true;
+ break;
+ }
+ } else {
+ if (playString.size() > 0) {
+ result = 1;
+ breakFlag = true;
+ break;
+ }
+ }
+ } else if (key == 11) {
+ if ((password.size() == 0 && !playString.size()) || (password != playString)) {
+ (*_graphicsManager._vPort)->setupViewPort();
+ flag = true;
+ playString = "";
+ continue;
+ }
+ } else if (key == 12) {
+ breakFlag = true;
+ result = false;
+ break;
+ } else {
+ continue;
+ }
+
+ _soundManager.playVOCMap(wrongVoc, wrongVocSize);
+ }
+
+ _graphicsManager.fillPic(*_graphicsManager._vPort);
+ (*_graphicsManager._vPort)->_flags |= 8;
+ _graphicsManager.flipPage();
+ _eventsManager.sWaitFlip();
+ _graphicsManager.resetPalette();
+
+ if (flag && result)
+ lock._password = msg;
+ lock.saveThePassword();
+
+ _voy._eventTable[999]._data = NULL;
+ _bVoy->freeBoltGroup(0x10700);
}
delete[] buttonVoc;