aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cge/bitmap.cpp7
-rw-r--r--engines/cge/bitmap.h3
-rw-r--r--engines/cge/btfile.cpp132
-rw-r--r--engines/cge/cfile.cpp179
-rw-r--r--engines/cge/cfile.h66
-rw-r--r--engines/cge/cge.cpp1
-rw-r--r--engines/cge/cge_main.cpp18
-rw-r--r--engines/cge/cge_main.h2
-rw-r--r--engines/cge/fileio.cpp427
-rw-r--r--engines/cge/fileio.h (renamed from engines/cge/btfile.h)102
-rw-r--r--engines/cge/general.cpp77
-rw-r--r--engines/cge/general.h40
-rw-r--r--engines/cge/jbw.h5
-rw-r--r--engines/cge/module.mk4
-rw-r--r--engines/cge/sound.cpp10
-rw-r--r--engines/cge/sound.h2
-rw-r--r--engines/cge/talk.cpp4
-rw-r--r--engines/cge/text.cpp7
-rw-r--r--engines/cge/vga13h.cpp5
-rw-r--r--engines/cge/vol.cpp120
-rw-r--r--engines/cge/vol.h77
21 files changed, 548 insertions, 740 deletions
diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp
index 50bec4ed57..02265f09bc 100644
--- a/engines/cge/bitmap.cpp
+++ b/engines/cge/bitmap.cpp
@@ -26,10 +26,7 @@
*/
#include "cge/bitmap.h"
-#include "cge/cfile.h"
#include "cge/jbw.h"
-#include "cge/vol.h"
-#include "cge/cfile.h"
#include "cge/vga13h.h"
#include "cge/cge_main.h"
#include "common/system.h"
@@ -53,8 +50,8 @@ Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) {
char pat[kMaxPath];
forceExt(pat, fname, ".VBM");
- if (PIC_FILE::exist(pat)) {
- PIC_FILE file(pat);
+ if (VFile::exist(pat)) {
+ VFile file(pat);
if ((file._error == 0) && (!loadVBM(&file)))
error("Bad VBM [%s]", fname);
} else {
diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h
index 7604cb8081..8896d13bb4 100644
--- a/engines/cge/bitmap.h
+++ b/engines/cge/bitmap.h
@@ -28,7 +28,8 @@
#ifndef __CGE_BITMAP__
#define __CGE_BITMAP__
-#include "cge/general.h"
+#include "cge/fileio.h"
+//#include "cge/general.h"
namespace CGE {
diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp
deleted file mode 100644
index ca02e1e43d..0000000000
--- a/engines/cge/btfile.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on original Soltys source code
- * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
- */
-
-#include "cge/btfile.h"
-#include "common/system.h"
-#include "common/str.h"
-#include "cge/cge.h"
-#include "common/debug.h"
-#include "common/debug-channels.h"
-#include "common/memstream.h"
-
-namespace CGE {
-
-BtFile::BtFile(const char *name, Crypt *crpt)
- : IoHand(name, crpt) {
- debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, crpt)", name);
-
- for (int i = 0; i < kBtLevel; i++) {
- _buff[i]._page = new BtPage;
- _buff[i]._pgNo = kBtValNone;
- _buff[i]._indx = -1;
- assert(_buff[i]._page != NULL);
- }
-}
-
-BtFile::~BtFile() {
- debugC(1, kCGEDebugFile, "BtFile::~BtFile()");
- for (int i = 0; i < kBtLevel; i++)
- delete _buff[i]._page;
-}
-
-BtPage *BtFile::getPage(int lev, uint16 pgn) {
- debugC(1, kCGEDebugFile, "BtFile::getPage(%d, %d)", lev, pgn);
-
- if (_buff[lev]._pgNo != pgn) {
- int32 pos = pgn * kBtSize;
- _buff[lev]._pgNo = pgn;
- assert(size() > pos);
- // In the original, there was a check verifying if the
- // purpose was to write a new file. This should only be
- // to create a new file, thus it was removed.
- seek((uint32) pgn * kBtSize);
-
- // Read in the page
- byte buffer[kBtSize];
- int bytesRead = read(buffer, kBtSize);
-
- // Unpack it into the page structure
- Common::MemoryReadStream stream(buffer, bytesRead, DisposeAfterUse::NO);
- _buff[lev]._page->read(stream);
-
- _buff[lev]._indx = -1;
- }
- return _buff[lev]._page;
-}
-
-BtKeypack *BtFile::find(const char *key) {
- debugC(1, kCGEDebugFile, "BtFile::find(%s)", key);
-
- int lev = 0;
- uint16 nxt = kBtValRoot;
- while (!_error) {
- BtPage *pg = getPage(lev, nxt);
- // search
- if (pg->_hea._down != kBtValNone) {
- int i;
- for (i = 0; i < pg->_hea._count; i++) {
- // Does this work, or does it have to compare the entire buffer?
- if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, kBtKeySize) < 0)
- break;
- }
- nxt = (i) ? pg->_inn[i - 1]._down : pg->_hea._down;
- _buff[lev]._indx = i - 1;
- lev++;
- } else {
- int i;
- for (i = 0; i < pg->_hea._count - 1; i++) {
- if (scumm_stricmp((const char *)key, (const char *)pg->_lea[i]._key) <= 0)
- break;
- }
- _buff[lev]._indx = i;
- return &pg->_lea[i];
- }
- }
- return NULL;
-}
-
-void BtPage::read(Common::ReadStream &s) {
- _hea._count = s.readUint16LE();
- _hea._down = s.readUint16LE();
-
- if (_hea._down == kBtValNone) {
- // Leaf list
- for (int i = 0; i < kBtLeafCount; ++i) {
- s.read(_lea[i]._key, kBtKeySize);
- _lea[i]._mark = s.readUint32LE();
- _lea[i]._size = s.readUint16LE();
- }
- } else {
- // Root index
- for (int i = 0; i < kBtInnerCount; ++i) {
- s.read(_inn[i]._key, kBtKeySize);
- _inn[i]._down = s.readUint16LE();
- }
- }
-}
-
-} // End of namespace CGE
diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp
deleted file mode 100644
index 23881cf89a..0000000000
--- a/engines/cge/cfile.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on original Soltys source code
- * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
- */
-
-#include "cge/cfile.h"
-#include "common/system.h"
-#include "cge/cge.h"
-#include "common/debug.h"
-#include "common/debug-channels.h"
-
-namespace CGE {
-
-IoBuf::IoBuf(Crypt *crypt)
- : IoHand(crypt),
- _bufMark(0),
- _ptr(0),
- _lim(0) {
- debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)");
-
- _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
- assert(_buff != NULL);
-}
-
-IoBuf::IoBuf(const char *name, Crypt *crypt)
- : IoHand(name, crypt),
- _bufMark(0),
- _ptr(0),
- _lim(0) {
- debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, crypt)", name);
-
- _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
- assert(_buff != NULL);
-}
-
-IoBuf::~IoBuf() {
- debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()");
- free(_buff);
-}
-
-void IoBuf::readBuf() {
- debugC(4, kCGEDebugFile, "IoBuf::readBuf()");
-
- _bufMark = IoHand::mark();
- _lim = IoHand::read(_buff, kBufferSize);
- _ptr = 0;
-}
-
-uint16 IoBuf::read(void *buf, uint16 len) {
- debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len);
-
- uint16 total = 0;
- while (len) {
- if (_ptr >= _lim)
- readBuf();
- uint16 n = _lim - _ptr;
- if (n) {
- if (len < n)
- n = len;
- memcpy(buf, _buff + _ptr, n);
- buf = (uint8 *)buf + n;
- len -= n;
- total += n;
- _ptr += n;
- } else
- break;
- }
- return total;
-}
-
-uint16 IoBuf::read(uint8 *buf) {
- debugC(3, kCGEDebugFile, "IoBuf::read(buf)");
-
- uint16 total = 0;
-
- while (total < kLineMaxSize - 2) {
- if (_ptr >= _lim)
- readBuf();
- uint8 *p = _buff + _ptr;
- uint16 n = _lim - _ptr;
- if (n) {
- if (total + n >= kLineMaxSize - 2)
- n = kLineMaxSize - 2 - total;
- uint8 *eol = (uint8 *) memchr(p, '\r', n);
- if (eol)
- n = (uint16)(eol - p);
- uint8 *eof = (uint8 *) memchr(p, '\32', n);
- if (eof) { // end-of-file
- n = (uint16)(eof - p);
- _ptr = (uint16)(eof - _buff);
- }
- if (n)
- memcpy(buf, p, n);
- buf += n;
- total += n;
- if (eof)
- break;
- _ptr += n;
- if (eol) {
- _ptr++;
- *(buf++) = '\n';
- total++;
- if (_ptr >= _lim)
- readBuf();
- if (_ptr < _lim)
- if (_buff[_ptr] == '\n')
- ++_ptr;
- break;
- }
- } else
- break;
- }
- *buf = '\0';
- return total;
-}
-
-int IoBuf::read() {
- debugC(1, kCGEDebugFile, "IoBuf::read()");
-
- if (_ptr >= _lim) {
- readBuf();
- if (_lim == 0)
- return -1;
- }
- return _buff[_ptr++];
-}
-
-uint16 CFile::_maxLineLen = kLineMaxSize;
-
-CFile::CFile(const char *name, Crypt *crypt)
- : IoBuf(name, crypt) {
- debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name);
-}
-
-CFile::~CFile() {
-}
-
-long CFile::mark() {
- debugC(5, kCGEDebugFile, "CFile::mark()");
-
- return _bufMark + _ptr;
-}
-
-long CFile::seek(long pos) {
- debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos);
-
- if (pos >= _bufMark && pos < _bufMark + _lim) {
- _ptr = (uint16)(pos - _bufMark);
- return pos;
- } else {
- _lim = 0;
- _ptr = 0;
- return _bufMark = IoHand::seek(pos);
- }
-}
-
-} // End of namespace CGE
diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h
deleted file mode 100644
index f7b45d8ade..0000000000
--- a/engines/cge/cfile.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on original Soltys source code
- * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
- */
-
-#ifndef __CGE_CFILE__
-#define __CGE_CFILE__
-
-#include "cge/general.h"
-
-namespace CGE {
-
-#define kLineMaxSize 512
-#define kBufferSize 2048
-
-class IoBuf : public IoHand {
-protected:
- uint8 *_buff;
- uint16 _ptr;
- uint16 _lim;
- long _bufMark;
- virtual void readBuf();
-public:
- IoBuf(Crypt *crpt);
- IoBuf(const char *name, Crypt *crpt);
- virtual ~IoBuf();
- uint16 read(void *buf, uint16 len);
- uint16 read(uint8 *buf);
- int read();
-};
-
-
-class CFile : public IoBuf {
-public:
- static uint16 _maxLineLen;
- CFile(const char *name, Crypt *crpt);
- virtual ~CFile();
- long mark();
- long seek(long pos);
-};
-
-} // End of namespace CGE
-
-#endif
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index 584512b69a..0dbc1c8696 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -34,7 +34,6 @@
#include "cge/cge_main.h"
#include "cge/talk.h"
#include "cge/text.h"
-#include "cge/vol.h"
#include "cge/walk.h"
namespace CGE {
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 0309f9f724..cf3e5223b4 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -41,8 +41,6 @@
#include "cge/text.h"
#include "cge/game.h"
#include "cge/events.h"
-#include "cge/cfile.h"
-#include "cge/vol.h"
#include "cge/talk.h"
#include "cge/vmenu.h"
#include "cge/gettext.h"
@@ -427,7 +425,7 @@ void CGEEngine::tooFar() {
void CGEEngine::loadHeroXY() {
debugC(1, kCGEDebugEngine, "CGEEngine::loadHeroXY()");
- INI_FILE cf(progName(".HXY"));
+ VFile cf(progName(".HXY"));
uint16 x, y;
memset(_heroXY, 0, sizeof(_heroXY));
@@ -446,7 +444,7 @@ void CGEEngine::loadMapping() {
debugC(1, kCGEDebugEngine, "CGEEngine::loadMapping()");
if (_now <= _caveMax) {
- INI_FILE cf(progName(".TAB"));
+ VFile cf(progName(".TAB"));
if (!cf._error) {
// Move to the data for the given room
cf.seek((_now - 1) * kMapArrSize);
@@ -1021,8 +1019,8 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int
char line[kLineMax];
mergeExt(line, fname, kSprExt);
- if (INI_FILE::exist(line)) { // sprite description file exist
- INI_FILE sprf(line);
+ if (VFile::exist(line)) { // sprite description file exist
+ VFile sprf(line);
if (sprf._error)
error("Bad SPR [%s]", line);
@@ -1158,7 +1156,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int
}
void CGEEngine::loadScript(const char *fname) {
- INI_FILE scrf(fname);
+ VFile scrf(fname);
if (scrf._error)
return;
@@ -1344,7 +1342,7 @@ void CGEEngine::runGame() {
if (!_music)
_midiPlayer.killMidi();
- if (INI_FILE::exist("MINI.SPR")) {
+ if (VFile::exist("MINI.SPR")) {
_miniShp = new BitmapPtr[2];
_miniShp[0] = _miniShp[1] = NULL;
@@ -1362,7 +1360,7 @@ void CGEEngine::runGame() {
if (_hero) {
expandSprite(_hero);
_hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y);
- if (INI_FILE::exist("00SHADOW.SPR")) {
+ if (VFile::exist("00SHADOW.SPR")) {
loadSprite("00SHADOW", -1, 0, _hero->_x + 14, _hero->_y + 51);
delete _shadow;
if ((_shadow = _sprite) != NULL) {
@@ -1427,7 +1425,7 @@ void CGEEngine::movie(const char *ext) {
return;
const char *fn = progName(ext);
- if (INI_FILE::exist(fn)) {
+ if (VFile::exist(fn)) {
loadScript(fn);
expandSprite(_vga->_spareQ->locate(999));
feedSnail(_vga->_showQ->locate(999), kTake);
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index ad1e4e258f..cce3122235 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -84,7 +84,7 @@ namespace CGE {
#define kStackSize 2048
#define kSavegameCheckSum (1956 + _now + _oldLev + _game + _music + _demoText)
#define kSavegame0Name ("{{INIT}}" kSvgExt)
-#define kSavegame0File INI_FILE
+#define kSavegame0File VFile
#define kSavegameStrSize 11
#define kGameFrameDelay (1000 / 50)
#define kGameTickDelay (1000 / 62)
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
new file mode 100644
index 0000000000..b2761f33be
--- /dev/null
+++ b/engines/cge/fileio.cpp
@@ -0,0 +1,427 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on original Soltys source code
+ * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
+ */
+
+#include "common/system.h"
+#include "common/str.h"
+#include "common/debug.h"
+#include "common/debug-channels.h"
+#include "common/memstream.h"
+#include "cge/cge.h"
+#include "cge/fileio.h"
+
+namespace CGE {
+
+Dat *VFile::_dat = NULL;
+BtFile *VFile::_cat = NULL;
+VFile *VFile::_recent = NULL;
+
+uint16 XCrypt(void *buf, uint16 siz, uint16 seed) {
+ byte *b = static_cast<byte *>(buf);
+
+ for (uint16 i = 0; i < siz; i++)
+ *b++ ^= seed;
+
+ return seed;
+}
+
+/*-----------------------------------------------------------------------
+ * IOHand
+ *-----------------------------------------------------------------------*/
+IoHand::IoHand(Crypt *crypt) : XFile(), _crypt(crypt), _seed(kCryptSeed) {
+ _file = new Common::File();
+}
+
+IoHand::IoHand(const char *name, Crypt *crypt)
+ : XFile(), _crypt(crypt), _seed(kCryptSeed) {
+ _file = new Common::File();
+ _file->open(name);
+}
+
+IoHand::~IoHand() {
+ _file->close();
+ delete _file;
+}
+
+uint16 IoHand::read(void *buf, uint16 len) {
+ if (!_file->isOpen())
+ return 0;
+
+ uint16 bytesRead = _file->read(buf, len);
+ if (!bytesRead)
+ error("Read %s - %d bytes", _file->getName(), len);
+ if (_crypt)
+ _seed = _crypt(buf, len, kCryptSeed);
+ return bytesRead;
+}
+
+long IoHand::mark() {
+ return _file->pos();
+}
+
+long IoHand::seek(long pos) {
+ _file->seek(pos, SEEK_SET);
+ return _file->pos();
+}
+
+long IoHand::size() {
+ return _file->size();
+}
+
+bool IoHand::exist(const char *name) {
+ return Common::File::exists(name);
+}
+
+/*-----------------------------------------------------------------------
+ * IoBuf
+ *-----------------------------------------------------------------------*/
+IoBuf::IoBuf(Crypt *crypt)
+ : IoHand(crypt),
+ _bufMark(0),
+ _ptr(0),
+ _lim(0) {
+ debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)");
+
+ _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
+ assert(_buff != NULL);
+}
+
+IoBuf::IoBuf(const char *name, Crypt *crypt)
+ : IoHand(name, crypt),
+ _bufMark(0),
+ _ptr(0),
+ _lim(0) {
+ debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, crypt)", name);
+
+ _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
+ assert(_buff != NULL);
+}
+
+IoBuf::~IoBuf() {
+ debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()");
+ free(_buff);
+}
+
+void IoBuf::readBuf() {
+ debugC(4, kCGEDebugFile, "IoBuf::readBuf()");
+
+ _bufMark = IoHand::mark();
+ _lim = IoHand::read(_buff, kBufferSize);
+ _ptr = 0;
+}
+
+uint16 IoBuf::read(void *buf, uint16 len) {
+ debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len);
+
+ uint16 total = 0;
+ while (len) {
+ if (_ptr >= _lim)
+ readBuf();
+ uint16 n = _lim - _ptr;
+ if (n) {
+ if (len < n)
+ n = len;
+ memcpy(buf, _buff + _ptr, n);
+ buf = (uint8 *)buf + n;
+ len -= n;
+ total += n;
+ _ptr += n;
+ } else
+ break;
+ }
+ return total;
+}
+
+uint16 IoBuf::read(uint8 *buf) {
+ debugC(3, kCGEDebugFile, "IoBuf::read(buf)");
+
+ uint16 total = 0;
+
+ while (total < kLineMaxSize - 2) {
+ if (_ptr >= _lim)
+ readBuf();
+ uint8 *p = _buff + _ptr;
+ uint16 n = _lim - _ptr;
+ if (n) {
+ if (total + n >= kLineMaxSize - 2)
+ n = kLineMaxSize - 2 - total;
+ uint8 *eol = (uint8 *) memchr(p, '\r', n);
+ if (eol)
+ n = (uint16)(eol - p);
+ uint8 *eof = (uint8 *) memchr(p, '\32', n);
+ if (eof) { // end-of-file
+ n = (uint16)(eof - p);
+ _ptr = (uint16)(eof - _buff);
+ }
+ if (n)
+ memcpy(buf, p, n);
+ buf += n;
+ total += n;
+ if (eof)
+ break;
+ _ptr += n;
+ if (eol) {
+ _ptr++;
+ *(buf++) = '\n';
+ total++;
+ if (_ptr >= _lim)
+ readBuf();
+ if (_ptr < _lim)
+ if (_buff[_ptr] == '\n')
+ ++_ptr;
+ break;
+ }
+ } else
+ break;
+ }
+ *buf = '\0';
+ return total;
+}
+
+int IoBuf::read() {
+ debugC(1, kCGEDebugFile, "IoBuf::read()");
+
+ if (_ptr >= _lim) {
+ readBuf();
+ if (_lim == 0)
+ return -1;
+ }
+ return _buff[_ptr++];
+}
+
+/*-----------------------------------------------------------------------
+ * CFile
+ *-----------------------------------------------------------------------*/
+uint16 CFile::_maxLineLen = kLineMaxSize;
+
+CFile::CFile(const char *name, Crypt *crypt)
+ : IoBuf(name, crypt) {
+ debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name);
+}
+
+CFile::~CFile() {
+}
+
+long CFile::mark() {
+ debugC(5, kCGEDebugFile, "CFile::mark()");
+
+ return _bufMark + _ptr;
+}
+
+long CFile::seek(long pos) {
+ debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos);
+
+ if (pos >= _bufMark && pos < _bufMark + _lim) {
+ _ptr = (uint16)(pos - _bufMark);
+ return pos;
+ } else {
+ _lim = 0;
+ _ptr = 0;
+ return _bufMark = IoHand::seek(pos);
+ }
+}
+
+/*-----------------------------------------------------------------------
+ * BtPage
+ *-----------------------------------------------------------------------*/
+void BtPage::read(Common::ReadStream &s) {
+ _hea._count = s.readUint16LE();
+ _hea._down = s.readUint16LE();
+
+ if (_hea._down == kBtValNone) {
+ // Leaf list
+ for (int i = 0; i < kBtLeafCount; ++i) {
+ s.read(_lea[i]._key, kBtKeySize);
+ _lea[i]._mark = s.readUint32LE();
+ _lea[i]._size = s.readUint16LE();
+ }
+ } else {
+ // Root index
+ for (int i = 0; i < kBtInnerCount; ++i) {
+ s.read(_inn[i]._key, kBtKeySize);
+ _inn[i]._down = s.readUint16LE();
+ }
+ }
+}
+
+/*-----------------------------------------------------------------------
+ * BtFile
+ *-----------------------------------------------------------------------*/
+BtFile::BtFile(const char *name, Crypt *crpt)
+ : IoHand(name, crpt) {
+ debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, crpt)", name);
+
+ for (int i = 0; i < kBtLevel; i++) {
+ _buff[i]._page = new BtPage;
+ _buff[i]._pgNo = kBtValNone;
+ _buff[i]._indx = -1;
+ assert(_buff[i]._page != NULL);
+ }
+}
+
+BtFile::~BtFile() {
+ debugC(1, kCGEDebugFile, "BtFile::~BtFile()");
+ for (int i = 0; i < kBtLevel; i++)
+ delete _buff[i]._page;
+}
+
+BtPage *BtFile::getPage(int lev, uint16 pgn) {
+ debugC(1, kCGEDebugFile, "BtFile::getPage(%d, %d)", lev, pgn);
+
+ if (_buff[lev]._pgNo != pgn) {
+ int32 pos = pgn * kBtSize;
+ _buff[lev]._pgNo = pgn;
+ assert(size() > pos);
+ // In the original, there was a check verifying if the
+ // purpose was to write a new file. This should only be
+ // to create a new file, thus it was removed.
+ seek((uint32) pgn * kBtSize);
+
+ // Read in the page
+ byte buffer[kBtSize];
+ int bytesRead = read(buffer, kBtSize);
+
+ // Unpack it into the page structure
+ Common::MemoryReadStream stream(buffer, bytesRead, DisposeAfterUse::NO);
+ _buff[lev]._page->read(stream);
+
+ _buff[lev]._indx = -1;
+ }
+ return _buff[lev]._page;
+}
+
+BtKeypack *BtFile::find(const char *key) {
+ debugC(1, kCGEDebugFile, "BtFile::find(%s)", key);
+
+ int lev = 0;
+ uint16 nxt = kBtValRoot;
+ while (!_error) {
+ BtPage *pg = getPage(lev, nxt);
+ // search
+ if (pg->_hea._down != kBtValNone) {
+ int i;
+ for (i = 0; i < pg->_hea._count; i++) {
+ // Does this work, or does it have to compare the entire buffer?
+ if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, kBtKeySize) < 0)
+ break;
+ }
+ nxt = (i) ? pg->_inn[i - 1]._down : pg->_hea._down;
+ _buff[lev]._indx = i - 1;
+ lev++;
+ } else {
+ int i;
+ for (i = 0; i < pg->_hea._count - 1; i++) {
+ if (scumm_stricmp((const char *)key, (const char *)pg->_lea[i]._key) <= 0)
+ break;
+ }
+ _buff[lev]._indx = i;
+ return &pg->_lea[i];
+ }
+ }
+ return NULL;
+}
+
+/*-----------------------------------------------------------------------
+ * Dat
+ *-----------------------------------------------------------------------*/
+Dat::Dat(): _file(kDatName, XCrypt) {
+ debugC(1, kCGEDebugFile, "Dat::Dat()");
+}
+
+/*-----------------------------------------------------------------------
+ * VFile
+ *-----------------------------------------------------------------------*/
+void VFile::init() {
+ debugC(1, kCGEDebugFile, "VFile::init()");
+
+ _dat = new Dat();
+ _cat = new BtFile(kCatName, XCrypt);
+ _recent = NULL;
+}
+
+void VFile::deinit() {
+ delete _dat;
+ delete _cat;
+}
+
+VFile::VFile(const char *name) : IoBuf(NULL) {
+ debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name);
+
+ if (_dat->_file._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() {
+ if (_recent == this)
+ _recent = NULL;
+}
+
+bool VFile::exist(const char *name) {
+ debugC(1, kCGEDebugFile, "VFile::exist(%s)", name);
+
+ return scumm_stricmp(_cat->find(name)->_key, name) == 0;
+}
+
+void VFile::readBuf() {
+ debugC(3, kCGEDebugFile, "VFile::readBuf()");
+
+ if (_recent != this) {
+ _dat->_file.seek(_bufMark + _lim);
+ _recent = this;
+ }
+ _bufMark = _dat->_file.mark();
+ long n = _endMark - _bufMark;
+ if (n > kBufferSize)
+ n = kBufferSize;
+ _lim = _dat->_file.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);
+
+ _recent = NULL;
+ _lim = 0;
+ return (_bufMark = _begMark + pos);
+}
+
+} // End of namespace CGE
diff --git a/engines/cge/btfile.h b/engines/cge/fileio.h
index 19b10c3eed..a8577207bd 100644
--- a/engines/cge/btfile.h
+++ b/engines/cge/fileio.h
@@ -33,14 +33,17 @@
namespace CGE {
-#define kBtSize 1024
-#define kBtKeySize 13
-#define kBtLevel 2
+#define kBtSize 1024
+#define kBtKeySize 13
+#define kBtLevel 2
#define kBtInnerCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 2 /*sizeof(Inner) */))
-#define kBtLeafCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 4 + 2 /*sizeof(BtKeypack) */))
-
-#define kBtValNone 0xFFFF
-#define kBtValRoot 0
+#define kBtLeafCount ((kBtSize - 4 /*sizeof(Hea) */) / (kBtKeySize + 4 + 2 /*sizeof(BtKeypack) */))
+#define kBtValNone 0xFFFF
+#define kBtValRoot 0
+#define kLineMaxSize 512
+#define kBufferSize 2048
+#define kCatName "VOL.CAT"
+#define kDatName "VOL.DAT"
struct BtKeypack {
char _key[kBtKeySize];
@@ -58,6 +61,60 @@ struct Hea {
uint16 _down;
};
+class XFile {
+public:
+ uint16 _error;
+
+ XFile() : _error(0) { }
+ virtual ~XFile() { }
+ virtual uint16 read(void *buf, uint16 len) = 0;
+ virtual long mark() = 0;
+ virtual long size() = 0;
+ virtual long seek(long pos) = 0;
+};
+
+class IoHand : public XFile {
+protected:
+ Common::File *_file;
+ uint16 _seed;
+ Crypt *_crypt;
+public:
+ IoHand(const char *name, Crypt crypt);
+ IoHand(Crypt *crypt);
+ virtual ~IoHand();
+ static bool exist(const char *name);
+ uint16 read(void *buf, uint16 len);
+ long mark();
+ long size();
+ long seek(long pos);
+};
+
+class IoBuf : public IoHand {
+protected:
+ uint8 *_buff;
+ uint16 _ptr;
+ uint16 _lim;
+ long _bufMark;
+ virtual void readBuf();
+public:
+ IoBuf(Crypt *crpt);
+ IoBuf(const char *name, Crypt *crpt);
+ virtual ~IoBuf();
+ uint16 read(void *buf, uint16 len);
+ uint16 read(uint8 *buf);
+ int read();
+};
+
+
+class CFile : public IoBuf {
+public:
+ static uint16 _maxLineLen;
+ CFile(const char *name, Crypt *crpt);
+ virtual ~CFile();
+ long mark();
+ long seek(long pos);
+};
+
struct BtPage {
Hea _hea;
union {
@@ -87,6 +144,37 @@ public:
BtKeypack *next();
};
+class Dat {
+ friend class VFile;
+ CFile _file;
+public:
+ Dat();
+ bool read(long org, uint16 len, uint8 *buf);
+};
+
+class VFile : public IoBuf {
+private:
+ static Dat *_dat;
+ static BtFile *_cat;
+ static VFile *_recent;
+
+ long _begMark;
+ long _endMark;
+
+ void readBuf();
+public:
+ VFile(const char *name);
+ ~VFile();
+
+ static void init();
+ static void deinit();
+ static bool exist(const char *name);
+ static const char *next();
+ long mark();
+ long size();
+ long seek(long pos);
+};
+
} // End of namespace CGE
#endif
diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp
index a3258e9415..68db71e918 100644
--- a/engines/cge/general.cpp
+++ b/engines/cge/general.cpp
@@ -124,38 +124,6 @@ char *forceExt(char *buf, const char *name, const char *ext) {
return buf;
}
-static unsigned Seed = 0xA5;
-
-unsigned fastRand() {
- return Seed = 257 * Seed + 817;
-}
-unsigned fastRand(unsigned s) {
- return Seed = 257 * s + 817;
-}
-
-uint16 RCrypt(void *buf, uint16 siz, uint16 seed) {
- if (buf && siz) {
- byte *b = static_cast<byte *>(buf);
- byte *q = b + (siz - 1);
- seed = fastRand(seed);
- *b++ ^= seed;
- while (buf < q)
- *b++ ^= fastRand();
- if (buf == q)
- *b ^= (seed = fastRand());
- }
- return seed;
-}
-
-uint16 XCrypt(void *buf, uint16 siz, uint16 seed) {
- byte *b = static_cast<byte *>(buf);
-
- for (uint16 i = 0; i < siz; i++)
- *b++ ^= seed;
-
- return seed;
-}
-
uint16 atow(const char *a) {
if (!a)
return 0;
@@ -202,51 +170,6 @@ char *dwtom(uint32 val, char *str, int radix, int len) {
return str;
}
-IoHand::IoHand(Crypt *crypt)
- : XFile(), _crypt(crypt), _seed(kCryptSeed) {
- _file = new Common::File();
-}
-
-IoHand::IoHand(const char *name, Crypt *crypt)
- : XFile(), _crypt(crypt), _seed(kCryptSeed) {
- _file = new Common::File();
- _file->open(name);
-}
-
-IoHand::~IoHand() {
- _file->close();
- delete _file;
-}
-
-uint16 IoHand::read(void *buf, uint16 len) {
- if (!_file->isOpen())
- return 0;
-
- uint16 bytesRead = _file->read(buf, len);
- if (!bytesRead)
- error("Read %s - %d bytes", _file->getName(), len);
- if (_crypt)
- _seed = _crypt(buf, len, Seed);
- return bytesRead;
-}
-
-long IoHand::mark() {
- return _file->pos();
-}
-
-long IoHand::seek(long pos) {
- _file->seek(pos, SEEK_SET);
- return _file->pos();
-}
-
-long IoHand::size() {
- return _file->size();
-}
-
-bool IoHand::exist(const char *name) {
- return Common::File::exists(name);
-}
-
void sndSetVolume() {
warning("STUB: SNDSetVolume");
}
diff --git a/engines/cge/general.h b/engines/cge/general.h
index 37f492a538..fbb5fc4c45 100644
--- a/engines/cge/general.h
+++ b/engines/cge/general.h
@@ -64,43 +64,6 @@ T min(T A, T B) {
return (A < B) ? A : B;
}
-class XFile {
-public:
- uint16 _error;
-
- XFile() : _error(0) { }
- virtual ~XFile() { }
- virtual uint16 read(void *buf, uint16 len) = 0;
- virtual long mark() = 0;
- virtual long size() = 0;
- virtual long seek(long pos) = 0;
-};
-
-
-template <class T>
-inline uint16 XRead(XFile *xf, T *t) {
- return xf->read((uint8 *) t, sizeof(*t));
-}
-
-
-class IoHand : public XFile {
-protected:
- Common::File *_file;
- uint16 _seed;
- Crypt *_crypt;
-public:
- IoHand(const char *name, Crypt crypt = NULL);
- IoHand(Crypt *crypt = NULL);
- virtual ~IoHand();
- static bool exist(const char *name);
- uint16 read(void *buf, uint16 len);
- long mark();
- long size();
- long seek(long pos);
-};
-
-Crypt XCrypt;
-Crypt RCrypt;
uint16 atow(const char *a);
uint16 xtow(const char *x);
char *wtom(uint16 val, char *str, int radix, int len);
@@ -112,9 +75,6 @@ char *forceExt(char *buf, const char *name, const char *ext);
// MISSING FUNCTIONS
const char *progName(const char *ext = NULL);
-unsigned fastRand();
-unsigned fastRand(unsigned s);
-uint16 rCrypt(void *buf, uint16 siz, uint16 seed);
int newRandom(int range);
} // End of namespace CGE
diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h
index 0ba8a1956b..490c79803a 100644
--- a/engines/cge/jbw.h
+++ b/engines/cge/jbw.h
@@ -32,11 +32,6 @@
namespace CGE {
-// Defines found in cge.mak
-#define INI_FILE VFile // Or is it CFile?
-#define PIC_FILE VFile
-//
-
#define kMaxFile 128
#define IsDigit(c) ((c) >= '0' && (c) <= '9')
diff --git a/engines/cge/module.mk b/engines/cge/module.mk
index e71de2d9e4..6d34cdfd14 100644
--- a/engines/cge/module.mk
+++ b/engines/cge/module.mk
@@ -2,13 +2,12 @@ MODULE := engines/cge
MODULE_OBJS := \
bitmap.o \
- btfile.o \
- cfile.o \
cge.o \
cge_main.o \
console.o \
detection.o \
events.o \
+ fileio.o \
game.o \
general.o \
gettext.o \
@@ -18,7 +17,6 @@ MODULE_OBJS := \
text.o \
vga13h.o \
vmenu.o \
- vol.o \
walk.o
MODULE_DIRS += \
diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp
index 432bca75b5..daef3fa429 100644
--- a/engines/cge/sound.cpp
+++ b/engines/cge/sound.cpp
@@ -28,8 +28,6 @@
#include "cge/general.h"
#include "cge/sound.h"
#include "cge/text.h"
-#include "cge/cfile.h"
-#include "cge/vol.h"
#include "cge/cge_main.h"
#include "common/config-manager.h"
#include "common/memstream.h"
@@ -126,7 +124,7 @@ void Fx::preload(int ref0) {
for (int ref = ref0; ref < ref0 + 10; ref++) {
static char fname[] = "FX00000.WAV";
wtom(ref, fname + 2, 10, 5);
- INI_FILE file = INI_FILE(fname);
+ VFile file = VFile(fname);
DataCk *wav = loadWave(&file);
if (wav) {
Han *p = &_cache[find(0)];
@@ -142,7 +140,7 @@ DataCk *Fx::load(int idx, int ref) {
static char fname[] = "FX00000.WAV";
wtom(ref, fname + 2, 10, 5);
- INI_FILE file = INI_FILE(fname);
+ VFile file = VFile(fname);
DataCk *wav = loadWave(&file);
if (wav) {
Han *p = &_cache[idx];
@@ -203,14 +201,14 @@ void MusicPlayer::killMidi() {
void MusicPlayer::loadMidi(int ref) {
// Work out the filename and check the given MIDI file exists
Common::String filename = Common::String::format("%.2d.MID", ref);
- if (!INI_FILE::exist(filename.c_str()))
+ if (!VFile::exist(filename.c_str()))
return;
// Stop any currently playing MIDI file
killMidi();
// Read in the data for the file
- INI_FILE mid(filename.c_str());
+ VFile mid(filename.c_str());
_dataSize = mid.size();
_data = (byte *)malloc(_dataSize);
mid.read(_data, _dataSize);
diff --git a/engines/cge/sound.h b/engines/cge/sound.h
index e6bc2dedde..53f57a19b0 100644
--- a/engines/cge/sound.h
+++ b/engines/cge/sound.h
@@ -28,7 +28,7 @@
#ifndef __CGE_SOUND__
#define __CGE_SOUND__
-#include "cge/general.h"
+#include "cge/fileio.h"
#include "cge/snddrv.h"
#include "audio/audiostream.h"
#include "audio/decoders/wave.h"
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 812fa1d9dc..5e8aa1b869 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -27,7 +27,6 @@
#include "cge/general.h"
#include "cge/talk.h"
-#include "cge/vol.h"
#include "cge/game.h"
#include "cge/events.h"
@@ -50,7 +49,7 @@ Font::~Font() {
}
void Font::load() {
- INI_FILE f(_path);
+ VFile f(_path);
if (f._error)
return;
@@ -61,6 +60,7 @@ void Font::load() {
uint16 p = 0;
for (uint16 i = 0; i < kPosSize; i++) {
_pos[i] = p;
+ warning("Fonts 0x%X 0x%X", i, p);
p += _wid[i];
}
f.read(_map, p);
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index 0e6fc40920..973aadd23a 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -28,7 +28,6 @@
#include "cge/general.h"
#include "cge/text.h"
#include "cge/talk.h"
-#include "cge/vol.h"
#include "cge/game.h"
#include "cge/snail.h"
#include "cge/cge_main.h"
@@ -41,7 +40,7 @@ Talk *_talk = NULL;
Text::Text(CGEEngine *vm, const char *fname, int size) : _vm(vm) {
_cache = new Han[size];
mergeExt(_fileName, fname, kSayExt);
- if (!INI_FILE::exist(_fileName))
+ if (!VFile::exist(_fileName))
error("No talk (%s)\n", _fileName);
for (_size = 0; _size < size; _size++) {
@@ -78,7 +77,7 @@ int Text::find(int ref) {
void Text::preload(int from, int upto) {
- INI_FILE tf = _fileName;
+ VFile tf = _fileName;
if (tf._error)
return;
@@ -123,7 +122,7 @@ void Text::preload(int from, int upto) {
char *Text::load(int idx, int ref) {
- INI_FILE tf = _fileName;
+ VFile tf = _fileName;
if (tf._error)
return NULL;
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index 8213a1bcf3..317cb415f8 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -31,7 +31,6 @@
#include "cge/general.h"
#include "cge/vga13h.h"
#include "cge/bitmap.h"
-#include "cge/vol.h"
#include "cge/text.h"
#include "cge/cge_main.h"
#include "cge/cge.h"
@@ -232,8 +231,8 @@ Sprite *Sprite::expand() {
Snail::Com *nea = NULL;
Snail::Com *tak = NULL;
mergeExt(fname, _file, kSprExt);
- if (INI_FILE::exist(fname)) { // sprite description file exist
- INI_FILE sprf(fname);
+ if (VFile::exist(fname)) { // sprite description file exist
+ VFile sprf(fname);
if (!(sprf._error==0))
error("Bad SPR [%s]", fname);
int len = 0, lcnt = 0;
diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp
deleted file mode 100644
index ff0a979b1d..0000000000
--- a/engines/cge/vol.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on original Soltys source code
- * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
- */
-
-#include "cge/vol.h"
-#include "common/system.h"
-#include "common/str.h"
-#include "cge/cge.h"
-#include "common/debug.h"
-#include "common/debug-channels.h"
-
-namespace CGE {
-
-Dat *VFile::_dat = NULL;
-BtFile *VFile::_cat = NULL;
-VFile *VFile::_recent = NULL;
-
-/*-----------------------------------------------------------------------*/
-
-Dat::Dat(): _file(DAT_NAME, CRP) {
- debugC(1, kCGEDebugFile, "Dat::Dat()");
-}
-
-/*-----------------------------------------------------------------------*/
-
-void VFile::init() {
- debugC(1, kCGEDebugFile, "VFile::init()");
-
- _dat = new Dat();
- _cat = new BtFile(CAT_NAME, CRP);
- _recent = NULL;
-}
-
-void VFile::deinit() {
- delete _dat;
- delete _cat;
-}
-
-VFile::VFile(const char *name)
- : IoBuf(NULL) {
- debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name);
-
- if (_dat->_file._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() {
- if (_recent == this)
- _recent = NULL;
-}
-
-bool VFile::exist(const char *name) {
- debugC(1, kCGEDebugFile, "VFile::exist(%s)", name);
-
- return scumm_stricmp(_cat->find(name)->_key, name) == 0;
-}
-
-void VFile::readBuf() {
- debugC(3, kCGEDebugFile, "VFile::readBuf()");
-
- if (_recent != this) {
- _dat->_file.seek(_bufMark + _lim);
- _recent = this;
- }
- _bufMark = _dat->_file.mark();
- long n = _endMark - _bufMark;
- if (n > kBufferSize)
- n = kBufferSize;
- _lim = _dat->_file.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::seel(%ld)", pos);
-
- _recent = NULL;
- _lim = 0;
- return (_bufMark = _begMark + pos);
-}
-
-} // End of namespace CGE
diff --git a/engines/cge/vol.h b/engines/cge/vol.h
deleted file mode 100644
index d7184ba064..0000000000
--- a/engines/cge/vol.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on original Soltys source code
- * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
- */
-
-#ifndef __CGE_VOL__
-#define __CGE_VOL__
-
-#include "cge/btfile.h"
-#include "cge/cfile.h"
-
-namespace CGE {
-
-#define CAT_NAME "VOL.CAT"
-#define DAT_NAME "VOL.DAT"
-
-#define CRP XCrypt
-#define XMASK 0xA5
-#define VOLBASE CFile
-
-class Dat {
- friend class VFile;
- VOLBASE _file;
-public:
- Dat();
- bool read(long org, uint16 len, uint8 *buf);
-};
-
-class VFile : public IoBuf {
-private:
- static Dat *_dat;
- static BtFile *_cat;
- static VFile *_recent;
-
- long _begMark;
- long _endMark;
-
- void readBuf();
-public:
- VFile(const char *name);
- ~VFile();
-
- static void init();
- static void deinit();
- static bool exist(const char *name);
- static const char *next();
- long mark();
- long size();
- long seek(long pos);
-};
-
-
-} // End of namespace CGE
-
-#endif