aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cge/bitmap.cpp24
-rw-r--r--engines/cge/bitmap.h2
-rw-r--r--engines/cge/cge_main.h5
-rw-r--r--engines/cge/fileio.cpp52
-rw-r--r--engines/cge/fileio.h16
5 files changed, 20 insertions, 79 deletions
diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp
index 3d2ca70868..c54ba09245 100644
--- a/engines/cge/bitmap.cpp
+++ b/engines/cge/bitmap.cpp
@@ -50,8 +50,10 @@ Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) {
forceExt(pat, fname, ".VBM");
if (_cat->exist(pat)) {
- VFile file(pat);
- if ((file._error == 0) && (!loadVBM(&file)))
+ EncryptedStream file(pat);
+ if (file.err())
+ error("Unable to find VBM [%s]", fname);
+ if (!loadVBM(&file))
error("Bad VBM [%s]", fname);
} else {
error("Bad VBM [%s]", fname);
@@ -341,27 +343,27 @@ bool Bitmap::solidAt(int16 x, int16 y) {
}
}
-bool Bitmap::loadVBM(VFile *f) {
+bool Bitmap::loadVBM(EncryptedStream *f) {
debugC(5, kCGEDebugBitmap, "Bitmap::loadVBM(f)");
uint16 p = 0, n = 0;
- if (f->_error == 0)
+ if (!f->err())
f->read((uint8 *)&p, sizeof(p));
p = FROM_LE_16(p);
- if (f->_error == 0)
+ if (!f->err())
f->read((uint8 *)&n, sizeof(n));
n = FROM_LE_16(n);
- if (f->_error == 0)
+ if (!f->err())
f->read((uint8 *)&_w, sizeof(_w));
_w = FROM_LE_16(_w);
- if (f->_error == 0)
+ if (!f->err())
f->read((uint8 *)&_h, sizeof(_h));
_h = FROM_LE_16(_h);
- if (f->_error == 0) {
+ if (!f->err()) {
if (p) {
if (_pal) {
// Read in the palette
@@ -375,17 +377,17 @@ bool Bitmap::loadVBM(VFile *f) {
_pal[idx]._b = *(srcP + 2);
}
} else
- f->seek(f->mark() + kPalSize);
+ f->seek(f->pos() + kPalSize);
}
}
if ((_v = new uint8[n]) == NULL)
return false;
- if (f->_error == 0)
+ if (!f->err())
f->read(_v, n);
_b = (HideDesc *)(_v + n - _h * sizeof(HideDesc));
- return (f->_error == 0);
+ return (!f->err());
}
} // End of namespace CGE
diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h
index fbaeead31e..bc37591399 100644
--- a/engines/cge/bitmap.h
+++ b/engines/cge/bitmap.h
@@ -50,7 +50,7 @@ struct HideDesc {
#include "common/pack-end.h"
class Bitmap {
- bool loadVBM(VFile *f);
+ bool loadVBM(EncryptedStream *f);
public:
static Dac *_pal;
uint16 _w;
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index d6f1a996d1..54258c7ab9 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -61,9 +61,6 @@ namespace CGE {
#define kGetNamePrompt 50
#define kGetNameTitle 51
#define kTSeq 96
-//Useless?
-//#define kBadSnd 97
-//#define kBadMidi 98
#define kNoMusic 98
#define kBadSVG 99
#define kSeqHTalk (kTSeq + 4)
@@ -87,7 +84,7 @@ namespace CGE {
#define kStackSize 2048
#define kSavegameCheckSum (1956 + _now + _oldLev + _game + _music + _demoText)
#define kSavegame0Name ("{{INIT}}" kSvgExt)
-#define kSavegame0File VFile
+#define kSavegame0File EncryptedStream
#define kSavegameStrSize 11
#define kGameFrameDelay (1000 / 50)
#define kGameTickDelay (1000 / 62)
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
index 024ea77693..888437c18c 100644
--- a/engines/cge/fileio.cpp
+++ b/engines/cge/fileio.cpp
@@ -331,54 +331,6 @@ bool BtFile::exist(const char *name) {
}
/*-----------------------------------------------------------------------
- * VFile
- *-----------------------------------------------------------------------*/
-VFile::VFile(const char *name) : IoBuf(NULL) {
- debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name);
-
- if (_dat->_error || _cat->_error)
- error("Bad volume data");
- BtKeypack *kp = _cat->find(name);
- if (scumm_stricmp(kp->_key, name) != 0)
- _error = 1;
- _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size;
-}
-
-VFile::~VFile() {
-}
-
-void VFile::readBuf() {
- debugC(3, kCGEDebugFile, "VFile::readBuf()");
-
- _dat->seek(_bufMark + _lim);
- _bufMark = _dat->mark();
- long n = _endMark - _bufMark;
- if (n > kBufferSize)
- n = kBufferSize;
- _lim = _dat->read(_buff, (uint16) n);
- _ptr = 0;
-}
-
-long VFile::mark() {
- debugC(5, kCGEDebugFile, "VFile::mark()");
-
- return (_bufMark + _ptr) - _begMark;
-}
-
-long VFile::size() {
- debugC(1, kCGEDebugFile, "VFile::size()");
-
- return _endMark - _begMark;
-}
-
-long VFile::seek(long pos) {
- debugC(1, kCGEDebugFile, "VFile::seek(%ld)", pos);
-
- _lim = 0;
- return (_bufMark = _begMark + pos);
-}
-
-/*-----------------------------------------------------------------------
* EncryptedStream
*-----------------------------------------------------------------------*/
EncryptedStream::EncryptedStream(const char *name) {
@@ -422,6 +374,10 @@ int32 EncryptedStream::size() {
return _readStream->size();
}
+int32 EncryptedStream::pos() {
+ return _readStream->pos();
+}
+
EncryptedStream::~EncryptedStream() {
}
diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h
index f6f0a98d54..8e5779cbab 100644
--- a/engines/cge/fileio.h
+++ b/engines/cge/fileio.h
@@ -132,21 +132,6 @@ public:
bool exist(const char *name);
};
-class VFile : public IoBuf {
-private:
- long _begMark;
- long _endMark;
-
- void readBuf();
-public:
- VFile(const char *name);
- ~VFile();
-
- long mark();
- long size();
- long seek(long pos);
-};
-
class EncryptedStream {
private:
Common::SeekableReadStream *_readStream;
@@ -157,6 +142,7 @@ public:
bool err();
bool eos();
bool seek(int32 offset);
+ int32 pos();
int32 size();
uint32 read(void *dataPtr, uint32 dataSize);
Common::String readLine();