aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/voyeur/files.cpp106
-rw-r--r--engines/voyeur/files.h15
-rw-r--r--engines/voyeur/graphics.cpp2
-rw-r--r--engines/voyeur/graphics.h2
-rw-r--r--engines/voyeur/voyeur.cpp1
5 files changed, 110 insertions, 16 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp
index ee581065a9..93f1b87089 100644
--- a/engines/voyeur/files.cpp
+++ b/engines/voyeur/files.cpp
@@ -21,6 +21,8 @@
*/
#include "voyeur/files.h"
+#include "voyeur/graphics.h"
+#include "voyeur/voyeur.h"
namespace Voyeur {
@@ -47,8 +49,9 @@ BoltFilesState::BoltFilesState() {
_runType = 0;
_runValue = 0;
_runOffset = 0;
-
Common::fill(&_historyBuffer[0], &_historyBuffer[0x200], 0);
+ _curFd = NULL;
+ _boltPageFrame = NULL;
}
#define NEXT_BYTE if (--_bytesLeft <= 0) nextBlock()
@@ -126,7 +129,9 @@ byte *BoltFilesState::decompress(byte *buf, int size, int mode) {
case 0:
while (len-- > 0) {
NEXT_BYTE;
- _historyBuffer[_historyIndex] = *_bufPos++;
+ byte v = *_bufPos++;
+ _historyBuffer[_historyIndex] = v;
+ *bufP++ = v;
_historyIndex = (_historyIndex + 1) & 0x1ff;
}
break;
@@ -135,6 +140,7 @@ byte *BoltFilesState::decompress(byte *buf, int size, int mode) {
_historyBuffer[_historyIndex] = _historyBuffer[runOffset];
*bufP++ = _historyBuffer[runOffset];
_historyIndex = (_historyIndex + 1) & 0x1ff;
+ runOffset = (runOffset + 1) & 0x1ff;
}
break;
default:
@@ -154,10 +160,10 @@ byte *BoltFilesState::decompress(byte *buf, int size, int mode) {
void BoltFilesState::nextBlock() {
if (_curFilePosition != _bufferEnd)
- _curFd.seek(_bufferEnd);
+ _curFd->seek(_bufferEnd);
_bufferBegin = _bufferEnd;
- int bytesRead = _curFd.read(_bufStart, _bufSize);
+ int bytesRead = _curFd->read(_bufStart, _bufSize);
_bufferEnd = _curFilePosition = _bufferBegin + bytesRead;
_bytesLeft = bytesRead - 1;
@@ -195,24 +201,25 @@ const BoltMethodPtr BoltFile::_fnInitType[25] = {
};
BoltFile::BoltFile(BoltFilesState &state): _state(state) {
- if (!_state._curFd.open("bvoy.blt"))
+ _state._curFd = &_file;
+ if (!_file.open("bvoy.blt"))
error("Could not open buoy.blt");
_state._curFilePosition = 0;
// Read in the file header
byte header[16];
- _state._curFd.read(&header[0], 16);
+ _file.read(&header[0], 16);
if (strncmp((const char *)&header[0], "BOLT", 4) != 0)
error("Tried to load non-bolt file");
int totalGroups = header[11] ? header[11] : 0x100;
for (int i = 0; i < totalGroups; ++i)
- _groups.push_back(BoltGroup(&_state._curFd));
+ _groups.push_back(BoltGroup(_state._curFd));
}
BoltFile::~BoltFile() {
- _state._curFd.close();
+ _state._curFd->close();
}
bool BoltFile::getBoltGroup(uint32 id) {
@@ -280,15 +287,15 @@ byte *BoltFile::getBoltMember(uint32 id) {
_state._bufStart = _state._decompressBuf;
_state._bufSize = DECOMPRESS_SIZE;
- if (_state._curMemberPtr->_fileOffset < _state._bufferBegin || _state._curMemberPtr->_fileOffset >= _state._bufferEnd) {
+ if ((_state._curFd != &_file) || (_state._curMemberPtr->_fileOffset < _state._bufferBegin)
+ || (_state._curMemberPtr->_fileOffset >= _state._bufferEnd)) {
_state._bytesLeft = 0;
_state._bufPos = _state._bufStart;
_state._bufferBegin = -1;
_state._bufferEnd = _state._curMemberPtr->_fileOffset;
} else {
- _state._bufPos = _state._curMemberPtr->_fileOffset + _state._bufferBegin + _state._bufStart;
- _state._bufSize = ((_state._bufPos - _state._bufStart) << 16) >> 16; // TODO: Validate this
- _state._bytesLeft = _state._bufSize;
+ _state._bufPos = _state._curMemberPtr->_fileOffset - _state._bufferBegin + _state._bufStart;
+ _state._bytesLeft = _state._bufSize - (_state._bufPos - _state._bufStart);
}
}
@@ -309,8 +316,9 @@ void BoltFile::initDefault() {
void BoltFile::sInitPic() {
// Read in the header data
- _state._curMemberPtr->_data = _state.decompress(0, 24, _state._curMemberPtr->_mode);
-
+ _state._curMemberPtr->_data = _state.decompress(NULL, 24, _state._curMemberPtr->_mode);
+ _state._curMemberPtr->_picResource = new PictureResource(_state,
+ _state._curMemberPtr->_data);
}
void BoltFile::vInitCMap() {
@@ -401,6 +409,76 @@ PictureResource::PictureResource(BoltFilesState &state, const byte *src) {
_maskData = READ_LE_UINT32(&src[14]);
_imgData = NULL;
+
+ int nbytes = _width * _height;
+ if (_flags & 0x20) {
+ warning("TODO: sInitPic flags&0x20");
+ } else if (_flags & 8) {
+ int mode = 0;
+ if (_width == 320) {
+ mode = 147;
+ state._sImageShift = 2;
+ state._SVGAReset = false;
+ } else {
+ state._SVGAReset = true;
+ if (_width == 640) {
+ if (_height == 400) {
+ mode = 220;
+ state._sImageShift = 3;
+ } else {
+ mode = 221;
+ state._sImageShift = 3;
+ }
+ } else if (_width == 800) {
+ mode = 222;
+ state._sImageShift = 3;
+ } else if (_width == 1024) {
+ mode = 226;
+ state._sImageShift = 3;
+ }
+ }
+
+ if (mode != state._vm->_graphicsManager._SVGAMode) {
+ state._vm->_graphicsManager._SVGAMode = mode;
+ // TODO: If necessary, simulate SVGA mode change
+ }
+
+// byte *imgData = _imgData;
+ if (_flags & 0x10) {
+ // TODO: Figure out what it's doing. Looks like a direct clearing
+ // of the screen directly
+ } else {
+ // TODO: Figure out direct screen loading
+ }
+ } else {
+ if (_flags & 0x1000) {
+ if (!(_flags & 0x10))
+ nbytes = state._curMemberPtr->_size - 24;
+
+ int mask = (nbytes + 0x3FFF) >> 14;
+ _imgData = NULL;
+
+ if (state._boltPageFrame == 0)
+ state.EMSGetFrameAddr(&state._boltPageFrame);
+ if (state._boltPageFrame != 0) {
+ if (!state.EMSAllocatePages(&_planeSize)) {
+ _maskData = mask;
+
+ for (int idx = 0; idx < mask; ++idx)
+ state.EMSMapPageHandle(_planeSize, idx, idx);
+
+ state.decompress(state._boltPageFrame, nbytes, state._curMemberPtr->_mode);
+ return;
+ }
+ }
+ }
+
+ if (_flags & 0x10) {
+ _imgData = new byte[nbytes];
+ } else {
+ _imgData = state.decompress(NULL, nbytes, state._curMemberPtr->_mode);
+ }
+ }
}
PictureResource::~PictureResource() {
diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h
index 658f7ac405..64a164a9dc 100644
--- a/engines/voyeur/files.h
+++ b/engines/voyeur/files.h
@@ -41,6 +41,7 @@ typedef void (BoltFile::*BoltMethodPtr)();
class BoltFilesState {
public:
+ VoyeurEngine *_vm;
BoltFile *_curLibPtr;
BoltGroup *_curGroupPtr;
BoltEntry *_curMemberPtr;
@@ -63,12 +64,20 @@ public:
int _runType;
int _runValue;
int _runOffset;
- Common::File _curFd;
+ Common::File *_curFd;
+
+ byte *_boltPageFrame;
+ int _sImageShift;
+ bool _SVGAReset;
public:
BoltFilesState();
byte *decompress(byte *buf, int size, int mode);
void nextBlock();
+
+ void EMSGetFrameAddr(byte **pageFrame) {} // TODO: Maybe?
+ bool EMSAllocatePages(uint *planeSize) { return false; } // TODO: Maybe?
+ void EMSMapPageHandle(int planeSize, int idx1, int idx2) {} // TODO: Maybe?
};
class BoltFile {
@@ -77,6 +86,7 @@ private:
private:
BoltFilesState &_state;
Common::Array<BoltGroup> _groups;
+ Common::File _file;
// initType method table
void initDefault();
@@ -150,6 +160,7 @@ public:
BoltFile *_curLibPtr;
public:
FilesManager();
+ void setVm(VoyeurEngine *vm) { _boltFilesState._vm = vm; }
bool openBoltLib(const Common::String &filename, BoltFile *&boltFile);
};
@@ -164,7 +175,7 @@ class PictureResource {
int _width;
int _height;
uint32 _maskData;
- uint16 _planeSize;
+ uint _planeSize;
byte *_imgData;
public:
diff --git a/engines/voyeur/graphics.cpp b/engines/voyeur/graphics.cpp
index 2261b4f73b..be8e5316fe 100644
--- a/engines/voyeur/graphics.cpp
+++ b/engines/voyeur/graphics.cpp
@@ -30,6 +30,8 @@ namespace Voyeur {
GraphicsManager::GraphicsManager() {
_palFlag = false;
+ _SVGAPage = 0;
+ _SVGAMode = 0;
}
void GraphicsManager::sInitGraphics() {
diff --git a/engines/voyeur/graphics.h b/engines/voyeur/graphics.h
index a0f01dfc63..72b5047b29 100644
--- a/engines/voyeur/graphics.h
+++ b/engines/voyeur/graphics.h
@@ -47,6 +47,8 @@ public:
byte _VGAColors[PALETTE_SIZE];
Common::Array<byte *> _colorChain;
byte *_backgroundPage;
+ int _SVGAPage;
+ int _SVGAMode;
private:
static void fadeIntFunc();
static void vDoFadeInt();
diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp
index beded3e6fd..457d8639b3 100644
--- a/engines/voyeur/voyeur.cpp
+++ b/engines/voyeur/voyeur.cpp
@@ -94,6 +94,7 @@ int VoyeurEngine::getRandomNumber(int maxNumber) {
void VoyeurEngine::initialiseManagers() {
_eventsManager.setVm(this);
+ _filesManager.setVm(this);
_graphicsManager.setVm(this);
}