aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2011-09-13 00:07:00 +0200
committerStrangerke2011-09-13 00:07:00 +0200
commit5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1 (patch)
tree5920c953a2316f7e135fb57b418178a716e498ba /engines
parent7624cc382210d364dbcf3fab2c782d5cd0b121a3 (diff)
downloadscummvm-rg350-5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1.tar.gz
scummvm-rg350-5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1.tar.bz2
scummvm-rg350-5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1.zip
CGE: Remove IoBuf and CFile
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/cge.cpp2
-rw-r--r--engines/cge/cge_main.cpp2
-rw-r--r--engines/cge/fileio.cpp146
-rw-r--r--engines/cge/fileio.h27
4 files changed, 3 insertions, 174 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index ade3071497..a5967da13e 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -79,7 +79,7 @@ void CGEEngine::init() {
_miniShp = NULL;
_miniShpList = NULL;
_sprite = NULL;
- _dat = new CFile(kDatName, XCrypt);
+ _dat = new IoHand(kDatName, XCrypt);
_cat = new BtFile(kCatName, XCrypt);
// Create debugger console
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index e56fad5d91..e35e5c6699 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -72,7 +72,7 @@ Snail *_snail_;
Fx *_fx;
Sound *_sound;
-CFile *_dat;
+IoHand *_dat;
BtFile *_cat;
// 0.75 - 17II95 - full sound support
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
index 888437c18c..5c63d41ff2 100644
--- a/engines/cge/fileio.cpp
+++ b/engines/cge/fileio.cpp
@@ -79,152 +79,6 @@ long IoHand::size() {
}
/*-----------------------------------------------------------------------
- * 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
- *-----------------------------------------------------------------------*/
-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) {
diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h
index 8e5779cbab..bc4fd0a074 100644
--- a/engines/cge/fileio.h
+++ b/engines/cge/fileio.h
@@ -78,31 +78,6 @@ public:
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:
- CFile(const char *name, Crypt *crpt);
- virtual ~CFile();
- long mark();
- long seek(long pos);
-};
-
struct BtPage {
Header _header;
union {
@@ -148,7 +123,7 @@ public:
Common::String readLine();
};
-extern CFile *_dat;
+extern IoHand *_dat;
extern BtFile *_cat;
} // End of namespace CGE