aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/bitmap.cpp78
-rw-r--r--engines/cge/bitmap.h28
-rw-r--r--engines/cge/boot.h64
-rw-r--r--engines/cge/btfile.cpp110
-rw-r--r--engines/cge/btfile.h61
-rw-r--r--engines/cge/cfile.cpp168
-rw-r--r--engines/cge/cfile.h53
-rw-r--r--engines/cge/cge.cpp22
-rw-r--r--engines/cge/cge_main.cpp67
-rw-r--r--engines/cge/general.cpp26
-rw-r--r--engines/cge/general.h36
-rw-r--r--engines/cge/mixer.cpp4
-rw-r--r--engines/cge/snail.cpp4
-rw-r--r--engines/cge/sound.cpp10
-rw-r--r--engines/cge/talk.cpp10
-rw-r--r--engines/cge/text.cpp6
-rw-r--r--engines/cge/vga13h.cpp30
-rw-r--r--engines/cge/vol.cpp52
-rw-r--r--engines/cge/vol.h48
-rw-r--r--engines/cge/wav.h2
20 files changed, 441 insertions, 438 deletions
diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp
index ab5c1ff3c7..3068499975 100644
--- a/engines/cge/bitmap.cpp
+++ b/engines/cge/bitmap.cpp
@@ -35,11 +35,11 @@
namespace CGE {
-DAC *Bitmap::Pal = NULL;
+DAC *Bitmap::_pal = NULL;
#define MAXPATH 128
void Bitmap::init() {
- Pal = NULL;
+ _pal = NULL;
}
void Bitmap::deinit() {
@@ -51,9 +51,9 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) {
ForceExt(pat, fname, ".VBM");
#if (BMP_MODE < 2)
- if (rem && PIC_FILE::Exist(pat)) {
+ if (rem && PIC_FILE::exist(pat)) {
PIC_FILE file(pat);
- if ((file.Error == 0) && (!VBMLoad(&file)))
+ if ((file.Error == 0) && (!loadVBM(&file)))
error("Bad VBM [%s]", fname);
} else
#endif
@@ -62,7 +62,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) {
ForceExt(pat, fname, ".BMP");
PIC_FILE file(pat);
if (file.Error == 0) {
- if (BMPLoad(&file)) {
+ if (loadBMP(&file)) {
Code();
if (rem) {
free(_m);
@@ -80,7 +80,7 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL) {
Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL) {
if (map)
- Code();
+ code();
}
@@ -169,7 +169,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) {
}
-uint16 Bitmap::MoveVmap(uint8 *buf) {
+uint16 Bitmap::moveVmap(uint8 *buf) {
if (_v) {
uint16 vsiz = (uint8 *)_b - (uint8 *)_v;
uint16 siz = vsiz + _h * sizeof(HideDesc);
@@ -183,7 +183,7 @@ uint16 Bitmap::MoveVmap(uint8 *buf) {
}
-BMP_PTR Bitmap::Code(void) {
+BMP_PTR Bitmap::code(void) {
if (_m) {
uint16 i, cnt;
@@ -305,7 +305,7 @@ BMP_PTR Bitmap::Code(void) {
}
-bool Bitmap::SolidAt(int x, int y) {
+bool Bitmap::solidAt(int x, int y) {
uint8 *m;
uint16 r, n, n0;
@@ -366,67 +366,67 @@ bool Bitmap::SolidAt(int x, int y) {
}
-bool Bitmap::VBMSave(XFILE *f) {
- uint16 p = (Pal != NULL),
+bool Bitmap::saveVBM(XFILE *f) {
+ uint16 p = (_pal != NULL),
n = ((uint16)(((uint8 *)_b) - _v)) + _h * sizeof(HideDesc);
if (f->Error == 0)
- f->Write((uint8 *)&p, sizeof(p));
+ f->write((uint8 *)&p, sizeof(p));
if (f->Error == 0)
- f->Write((uint8 *)&n, sizeof(n));
+ f->write((uint8 *)&n, sizeof(n));
if (f->Error == 0)
- f->Write((uint8 *)&_w, sizeof(_w));
+ f->write((uint8 *)&_w, sizeof(_w));
if (f->Error == 0)
- f->Write((uint8 *)&_h, sizeof(_h));
+ f->write((uint8 *)&_h, sizeof(_h));
if (f->Error == 0)
if (p)
- f->Write((uint8 *)Pal, 256 * 3);
+ f->write((uint8 *)_pal, 256 * 3);
if (f->Error == 0)
- f->Write(_v, n);
+ f->write(_v, n);
return (f->Error == 0);
}
-bool Bitmap::VBMLoad(XFILE *f) {
+bool Bitmap::loadVBM(XFILE *f) {
uint16 p = 0, n = 0;
if (f->Error == 0)
- f->Read((uint8 *)&p, sizeof(p));
+ f->read((uint8 *)&p, sizeof(p));
if (f->Error == 0)
- f->Read((uint8 *)&n, sizeof(n));
+ f->read((uint8 *)&n, sizeof(n));
if (f->Error == 0)
- f->Read((uint8 *)&_w, sizeof(_w));
+ f->read((uint8 *)&_w, sizeof(_w));
if (f->Error == 0)
- f->Read((uint8 *)&_h, sizeof(_h));
+ f->read((uint8 *)&_h, sizeof(_h));
if (f->Error == 0) {
if (p) {
- if (Pal) {
+ if (_pal) {
byte palData[PAL_SIZ];
- f->Read(palData, PAL_SIZ);
- VGA::pal2DAC(palData, Pal);
+ f->read(palData, PAL_SIZ);
+ VGA::pal2DAC(palData, _pal);
} else
- f->Seek(f->Mark() + PAL_SIZ);
+ f->seek(f->mark() + PAL_SIZ);
}
}
if ((_v = farnew(uint8, n)) == NULL)
return false;
if (f->Error == 0)
- f->Read(_v, n);
+ f->read(_v, n);
_b = (HideDesc *)(_v + n - _h * sizeof(HideDesc));
return (f->Error == 0);
}
-bool Bitmap::BMPLoad (XFILE * f) {
+bool Bitmap::loadBMP(XFILE * f) {
struct {
char BM[2];
union { int16 len; int32 len_; };
@@ -445,19 +445,19 @@ bool Bitmap::BMPLoad (XFILE * f) {
} hea;
BGR4 bpal[256];
- f->Read((byte *)&hea, sizeof(hea));
+ f->read((byte *)&hea, sizeof(hea));
if (f->Error == 0) {
if (hea.hdr == 0x436L) {
int16 i = (hea.hdr - sizeof(hea)) / sizeof(BGR4);
- f->Read((byte *)&bpal, sizeof(bpal));
+ f->read((byte *)&bpal, sizeof(bpal));
if (f->Error == 0) {
- if (Pal) {
- for (i = 0; i < 256; i ++) {
- Pal[i].R = bpal[i].R;
- Pal[i].G = bpal[i].G;
- Pal[i].B = bpal[i].B;
- }
- Pal = NULL;
+ if (_pal) {
+ for (i = 0; i < 256; i ++) {
+ _pal[i].R = bpal[i].R;
+ _pal[i].G = bpal[i].G;
+ _pal[i].B = bpal[i].B;
+ }
+ _pal = NULL;
}
_h = hea.hig;
_w = hea.wid;
@@ -465,9 +465,9 @@ bool Bitmap::BMPLoad (XFILE * f) {
int16 r = (4 - (hea.wid & 3)) % 4;
byte buf[3]; int i;
for (i = _h - 1; i >= 0; i--) {
- f->Read(_m + (_w * i), _w);
+ f->read(_m + (_w * i), _w);
if (r && f->Error == 0)
- f->Read(buf, r);
+ f->read(buf, r);
if (f->Error)
break;
}
diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h
index cfa7830f39..b13912a3c6 100644
--- a/engines/cge/bitmap.h
+++ b/engines/cge/bitmap.h
@@ -60,33 +60,33 @@ struct HideDesc {
#include "common/pack-end.h"
class Bitmap {
- bool BMPLoad(XFILE *f);
- bool VBMLoad(XFILE *f);
+ bool loadBMP(XFILE *f);
+ bool loadVBM(XFILE *f);
public:
- static DAC *Pal;
+ static DAC *_pal;
uint16 _w;
uint16 _h;
uint8 *_m;
uint8 *_v;
HideDesc *_b;
- Bitmap(const char *fname, bool rem = true);
+ Bitmap(const char *fname, bool rem);
Bitmap(uint16 w, uint16 h, uint8 *map);
Bitmap(uint16 w, uint16 h, uint8 fill);
Bitmap(const Bitmap &bmp);
- ~Bitmap(void);
+ ~Bitmap();
+
static void init();
static void deinit();
-
- Bitmap *FlipH(void);
- Bitmap *Code();
+ Bitmap *flipH();
+ Bitmap *code();
Bitmap &operator = (const Bitmap &bmp);
- void Hide(int x, int y);
- void Show(int x, int y);
- void XShow(int x, int y);
- bool SolidAt(int x, int y);
- bool VBMSave(XFILE *f);
- uint16 MoveVmap(uint8 *buf);
+ void hide(int x, int y);
+ void show(int x, int y);
+ void xShow(int x, int y);
+ bool solidAt(int x, int y);
+ bool saveVBM(XFILE *f);
+ uint16 moveVmap(uint8 *buf);
};
diff --git a/engines/cge/boot.h b/engines/cge/boot.h
index ab4dcde0e2..2dce0d6d16 100644
--- a/engines/cge/boot.h
+++ b/engines/cge/boot.h
@@ -37,42 +37,38 @@ namespace CGE {
#define BOOTCODE_SIZ BOOTSECT_SIZ-BOOTHEAD_SIZ
#define FreeBoot(b) free(b)
-#ifndef EC
-#define EC
-#endif
-
-typedef struct {
- uint8 Jmp[3]; // NEAR jump machine code
- char OEM_ID[8]; // OEM name and version
- uint16 SectSize; // bytes per sector
- uint8 ClustSize; // sectors per cluster
- uint16 ResSecs; // sectors before 1st FAT
- uint8 FatCnt; // number of FATs
- uint16 RootSize; // root directory entries
- uint16 TotSecs; // total sectors on disk
- uint8 Media; // media descriptor byte
- uint16 FatSize; // sectors per FAT
- uint16 TrkSecs; // sectors per track
- uint16 HeadCnt; // number of sufraces
- uint16 HidnSecs; // special hidden sectors
- uint16 _; // (unknown: reserved?)
- uint32 lTotSecs; // total number of sectors
- uint16 DriveNum; // physical drive number
- uint8 XSign; // extended boot signature
- uint32 Serial; // volume serial number
- char Label[11]; // volume label
- char FileSysID[8]; // file system ID
- char Code[BOOTCODE_SIZ - 8]; // 8 = length of following
- uint32 Secret; // long secret number
- uint8 BootCheck; // boot sector checksum
- uint8 BootFlags; // secret flags
- uint16 BootSig; // boot signature 0xAA55
-} Boot;
+struct Boot {
+ uint8 _jmp[3]; // NEAR jump machine code
+ char _idOEM[8]; // OEM name and version
+ uint16 _sectSize; // bytes per sector
+ uint8 _clustSize; // sectors per cluster
+ uint16 _resSecs; // sectors before 1st FAT
+ uint8 _fatCnt; // number of FATs
+ uint16 _rootSize; // root directory entries
+ uint16 _totSecs; // total sectors on disk
+ uint8 _media; // media descriptor byte
+ uint16 _fatSize; // sectors per FAT
+ uint16 _trkSecs; // sectors per track
+ uint16 _headCnt; // number of sufraces
+ uint16 _hidnSecs; // special hidden sectors
+ uint16 __; // (unknown: reserved?)
+ uint32 _lTotSecs; // total number of sectors
+ uint16 _driveNum; // physical drive number
+ uint8 _xSign; // extended boot signature
+ uint32 _serial; // volume serial number
+ char _label[11]; // volume label
+ char _fileSysID[8]; // file system ID
+ char _code[BOOTCODE_SIZ - 8]; // 8 = length of following
+ uint32 _secret; // long secret number
+ uint8 _bootCheck; // boot sector checksum
+ uint8 _bootFlags; // secret flags
+ uint16 _bootSig; // boot signature 0xAA55
+};
-EC Boot *ReadBoot(int drive);
-EC uint8 CheckBoot(Boot *boot);
-EC bool WriteBoot(int drive, Boot *boot);
+Boot *readBoot(int drive);
+uint8 checkBoot(Boot *boot);
+bool writeBoot(int drive, Boot *boot);
} // End of namespace CGE
diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp
index db0ebc2d5f..8255775fd1 100644
--- a/engines/cge/btfile.cpp
+++ b/engines/cge/btfile.cpp
@@ -40,80 +40,80 @@ namespace CGE {
#define BT_KEYLEN 13
#endif
-BTFILE::BTFILE(const char *name, IOMODE mode, CRYPT *crpt)
- : IOHAND(name, mode, crpt) {
+BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt)
+ : IoHand(name, mode, crpt) {
for (int i = 0; i < BT_LEVELS; i++) {
- Buff[i].Page = new BT_PAGE;
- Buff[i].PgNo = BT_NONE;
- Buff[i].Indx = -1;
- Buff[i].Updt = false;
- if (Buff[i].Page == NULL)
+ _buff[i]._page = new BtPage;
+ _buff[i]._pgNo = BT_NONE;
+ _buff[i]._indx = -1;
+ _buff[i]._updt = false;
+ if (_buff[i]._page == NULL)
error("No core");
}
}
-BTFILE::~BTFILE(void) {
+BtFile::~BtFile(void) {
for (int i = 0; i < BT_LEVELS; i++) {
- PutPage(i);
- delete Buff[i].Page;
+ putPage(i);
+ delete _buff[i]._page;
}
}
-void BTFILE::PutPage(int lev, bool hard) {
- if (hard || Buff[lev].Updt) {
- Seek(Buff[lev].PgNo * sizeof(BT_PAGE));
- Write((uint8 *) Buff[lev].Page, sizeof(BT_PAGE));
- Buff[lev].Updt = false;
+void BtFile::putPage(int lev, bool hard) {
+ if (hard || _buff[lev]._updt) {
+ seek(_buff[lev]._pgNo * sizeof(BtPage));
+ write((uint8 *) _buff[lev]._page, sizeof(BtPage));
+ _buff[lev]._updt = false;
}
}
-BT_PAGE *BTFILE::GetPage(int lev, uint16 pgn) {
- if (Buff[lev].PgNo != pgn) {
- int32 pos = pgn * sizeof(BT_PAGE);
- PutPage(lev);
- Buff[lev].PgNo = pgn;
- if (Size() > pos) {
- Seek((uint32) pgn * sizeof(BT_PAGE));
- Read((uint8 *) Buff[lev].Page, sizeof(BT_PAGE));
- Buff[lev].Updt = false;
+BtPage *BtFile::getPage(int lev, uint16 pgn) {
+ if (_buff[lev]._pgNo != pgn) {
+ int32 pos = pgn * sizeof(BtPage);
+ putPage(lev);
+ _buff[lev]._pgNo = pgn;
+ if (size() > pos) {
+ seek((uint32) pgn * sizeof(BtPage));
+ read((uint8 *) _buff[lev]._page, sizeof(BtPage));
+ _buff[lev]._updt = false;
} else {
- Buff[lev].Page->Hea.Count = 0;
- Buff[lev].Page->Hea.Down = BT_NONE;
- memset(Buff[lev].Page->Data, '\0', sizeof(Buff[lev].Page->Data));
- Buff[lev].Updt = true;
+ _buff[lev]._page->_hea._count = 0;
+ _buff[lev]._page->_hea._down = BT_NONE;
+ memset(_buff[lev]._page->_data, '\0', sizeof(_buff[lev]._page->_data));
+ _buff[lev]._updt = true;
}
- Buff[lev].Indx = -1;
+ _buff[lev]._indx = -1;
}
- return Buff[lev].Page;
+ return _buff[lev]._page;
}
-BT_KEYPACK *BTFILE::Find(const char *key) {
+BtKeypack *BtFile::find(const char *key) {
int lev = 0;
uint16 nxt = BT_ROOT;
while (! Error) {
- BT_PAGE *pg = GetPage(lev, nxt);
+ BtPage *pg = getPage(lev, nxt);
// search
- if (pg->Hea.Down != BT_NONE) {
+ if (pg->_hea._down != BT_NONE) {
int i;
- for (i = 0; i < pg->Hea.Count; 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, BT_KEYLEN) < 0)
+ if (scumm_strnicmp((const char *)key, (const char*)pg->_inn[i]._key, BT_KEYLEN) < 0)
break;
}
- nxt = (i) ? pg->Inn[i - 1].Down : pg->Hea.Down;
- Buff[lev].Indx = i - 1;
- ++ lev;
+ 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)
+ 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];
+ _buff[lev]._indx = i;
+ return &pg->_lea[i];
}
}
return NULL;
@@ -125,26 +125,26 @@ int keycomp(const void *k1, const void *k2) {
}
-void BTFILE::Make(BT_KEYPACK *keypack, uint16 count) {
+void BtFile::make(BtKeypack *keypack, uint16 count) {
#if BT_LEVELS != 2
#error This tiny BTREE implementation works with exactly 2 levels!
#endif
_fqsort(keypack, count, sizeof(*keypack), keycomp);
uint16 n = 0;
- BT_PAGE *Root = GetPage(0, n++),
- *Leaf = GetPage(1, n);
- Root->Hea.Down = n;
- PutPage(0, true);
+ BtPage *Root = getPage(0, n++);
+ BtPage *Leaf = getPage(1, n);
+ Root->_hea._down = n;
+ putPage(0, true);
while (count--) {
- if (Leaf->Hea.Count >= ArrayCount(Leaf->Lea)) {
- PutPage(1, true); // save filled page
- Leaf = GetPage(1, ++n); // take empty page
- memcpy(Root->Inn[Root->Hea.Count].Key, keypack->Key, BT_KEYLEN);
- Root->Inn[Root->Hea.Count++].Down = n;
- Buff[0].Updt = true;
+ if (Leaf->_hea._count >= ArrayCount(Leaf->_lea)) {
+ putPage(1, true); // save filled page
+ Leaf = getPage(1, ++n); // take empty page
+ memcpy(Root->_inn[Root->_hea._count]._key, keypack->_key, BT_KEYLEN);
+ Root->_inn[Root->_hea._count++]._down = n;
+ _buff[0]._updt = true;
}
- Leaf->Lea[Leaf->Hea.Count++] = *(keypack++);
- Buff[1].Updt = true;
+ Leaf->_lea[Leaf->_hea._count++] = *(keypack++);
+ _buff[1]._updt = true;
}
}
diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h
index 449f200140..3fd3175798 100644
--- a/engines/cge/btfile.h
+++ b/engines/cge/btfile.h
@@ -41,50 +41,53 @@ namespace CGE {
#include "common/pack-start.h" // START STRUCT PACKING
-struct BT_KEYPACK {
- char Key[BT_KEYLEN];
- uint32 Mark;
- uint16 Size;
+struct BtKeypack {
+ char _key[BT_KEYLEN];
+ uint32 _mark;
+ uint16 _size;
};
-typedef struct {
- uint8 Key[BT_KEYLEN];
- uint16 Down;
-} INNER;
+struct Inner {
+ uint8 _key[BT_KEYLEN];
+ uint16 _down;
+};
+
+struct Hea {
+ uint16 _count;
+ uint16 _down;
+};
-struct BT_PAGE {
- struct HEA {
- uint16 Count;
- uint16 Down;
- } Hea;
+struct BtPage {
+ Hea _hea;
union {
// dummy filler to make proper size of union
- uint8 Data[BT_SIZE - sizeof(HEA)];
+ uint8 _data[BT_SIZE - sizeof(Hea)];
// inner version of data: key + word-sized page link
- INNER Inn[(BT_SIZE - sizeof(HEA)) / sizeof(INNER)];
+ Inner _inn[(BT_SIZE - sizeof(Hea)) / sizeof(Inner)];
// leaf version of data: key + all user data
- BT_KEYPACK Lea[(BT_SIZE - sizeof(HEA)) / sizeof(BT_KEYPACK)];
+ BtKeypack _lea[(BT_SIZE - sizeof(Hea)) / sizeof(BtKeypack)];
};
};
#include "common/pack-end.h" // END STRUCT PACKING
-class BTFILE : public IOHAND {
+class BtFile : public IoHand {
struct {
- BT_PAGE *Page;
- uint16 PgNo;
- int Indx;
- bool Updt;
- } Buff[BT_LEVELS];
- void PutPage(int lev, bool hard = false);
- BT_PAGE *GetPage(int lev, uint16 pgn);
+ BtPage *_page;
+ uint16 _pgNo;
+ int _indx;
+ bool _updt;
+ } _buff[BT_LEVELS];
+
+ void putPage(int lev, bool hard = false);
+ BtPage *getPage(int lev, uint16 pgn);
public:
- BTFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL);
- virtual ~BTFILE(void);
- BT_KEYPACK *Find(const char *key);
- BT_KEYPACK *Next(void);
- void Make(BT_KEYPACK *keypack, uint16 count);
+ BtFile(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL);
+ virtual ~BtFile();
+ BtKeypack *find(const char *key);
+ BtKeypack *next();
+ void make(BtKeypack *keypack, uint16 count);
};
} // End of namespace CGE
diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp
index 85e51a94c1..9a2b697bd7 100644
--- a/engines/cge/cfile.cpp
+++ b/engines/cge/cfile.cpp
@@ -32,65 +32,65 @@
namespace CGE {
-IOBUF::IOBUF(IOMODE mode, CRYPT *crpt)
- : IOHAND(mode, crpt),
- BufMark(0),
- Ptr(0),
- Lim(0) {
- Buff = farnew(uint8, IOBUF_SIZE);
- if (Buff == NULL)
+IoBuf::IoBuf(IOMODE mode, CRYPT *crpt)
+ : IoHand(mode, crpt),
+ _bufMark(0),
+ _ptr(0),
+ _lim(0) {
+ _buff = farnew(uint8, IOBUF_SIZE);
+ if (_buff == NULL)
error("No core for I/O");
}
-IOBUF::IOBUF(const char *name, IOMODE mode, CRYPT *crpt)
- : IOHAND(name, mode, crpt),
- BufMark(0),
- Ptr(0),
- Lim(0) {
- Buff = farnew(uint8, IOBUF_SIZE);
- if (Buff == NULL)
+IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt)
+ : IoHand(name, mode, crpt),
+ _bufMark(0),
+ _ptr(0),
+ _lim(0) {
+ _buff = farnew(uint8, IOBUF_SIZE);
+ if (_buff == NULL)
error("No core for I/O [%s]", name);
}
-IOBUF::~IOBUF(void) {
+IoBuf::~IoBuf(void) {
if (Mode > REA)
- WriteBuff();
- if (Buff)
- free(Buff);
+ writeBuff();
+ if (_buff)
+ free(_buff);
}
-void IOBUF::ReadBuff(void) {
- BufMark = IOHAND::Mark();
- Lim = IOHAND::Read(Buff, IOBUF_SIZE);
- Ptr = 0;
+void IoBuf::readBuff(void) {
+ _bufMark = IoHand::mark();
+ _lim = IoHand::read(_buff, IOBUF_SIZE);
+ _ptr = 0;
}
-void IOBUF::WriteBuff(void) {
- if (Lim) {
- IOHAND::Write(Buff, Lim);
- BufMark = IOHAND::Mark();
- Lim = 0;
+void IoBuf::writeBuff(void) {
+ if (_lim) {
+ IoHand::write(_buff, _lim);
+ _bufMark = IoHand::mark();
+ _lim = 0;
}
}
-uint16 IOBUF::Read(void *buf, uint16 len) {
+uint16 IoBuf::read(void *buf, uint16 len) {
uint16 total = 0;
while (len) {
- if (Ptr >= Lim)
- ReadBuff();
- uint16 n = Lim - Ptr;
+ if (_ptr >= _lim)
+ readBuff();
+ uint16 n = _lim - _ptr;
if (n) {
if (len < n)
n = len;
- memcpy(buf, Buff + Ptr, n);
+ memcpy(buf, _buff + _ptr, n);
buf = (uint8 *)buf + n;
len -= n;
total += n;
- Ptr += n;
+ _ptr += n;
} else
break;
}
@@ -98,14 +98,14 @@ uint16 IOBUF::Read(void *buf, uint16 len) {
}
-uint16 IOBUF::Read(uint8 *buf) {
+uint16 IoBuf::read(uint8 *buf) {
uint16 total = 0;
while (total < LINE_MAX - 2) {
- if (Ptr >= Lim)
- ReadBuff();
- uint8 *p = Buff + Ptr;
- uint16 n = Lim - Ptr;
+ if (_ptr >= _lim)
+ readBuff();
+ uint8 *p = _buff + _ptr;
+ uint16 n = _lim - _ptr;
if (n) {
if (total + n >= LINE_MAX - 2)
n = LINE_MAX - 2 - total;
@@ -115,7 +115,7 @@ uint16 IOBUF::Read(uint8 *buf) {
uint8 *eof = (uint8 *) memchr(p, '\32', n);
if (eof) { // end-of-file
n = (uint16)(eof - p);
- Ptr = (uint16)(eof - Buff);
+ _ptr = (uint16)(eof - _buff);
}
if (n)
memcpy(buf, p, n);
@@ -123,16 +123,16 @@ uint16 IOBUF::Read(uint8 *buf) {
total += n;
if (eof)
break;
- Ptr += n;
+ _ptr += n;
if (eol) {
- ++ Ptr;
+ _ptr++;
*(buf++) = '\n';
- ++ total;
- if (Ptr >= Lim)
- ReadBuff();
- if (Ptr < Lim)
- if (Buff[Ptr] == '\n')
- ++Ptr;
+ total++;
+ if (_ptr >= _lim)
+ readBuff();
+ if (_ptr < _lim)
+ if (_buff[_ptr] == '\n')
+ ++_ptr;
break;
}
} else
@@ -143,36 +143,36 @@ uint16 IOBUF::Read(uint8 *buf) {
}
-uint16 IOBUF::Write(void *buf, uint16 len) {
+uint16 IoBuf::write(void *buf, uint16 len) {
uint16 tot = 0;
while (len) {
- uint16 n = IOBUF_SIZE - Lim;
+ uint16 n = IOBUF_SIZE - _lim;
if (n > len)
n = len;
if (n) {
- memcpy(Buff + Lim, buf, n);
- Lim += n;
+ memcpy(_buff + _lim, buf, n);
+ _lim += n;
len -= n;
buf = (uint8 *)buf + n;
tot += n;
} else
- WriteBuff();
+ writeBuff();
}
return tot;
}
-uint16 IOBUF::Write(uint8 *buf) {
+uint16 IoBuf::write(uint8 *buf) {
uint16 len = 0;
if (buf) {
len = strlen((const char *) buf);
if (len)
if (buf[len - 1] == '\n')
--len;
- len = Write(buf, len);
+ len = write(buf, len);
if (len) {
static char EOL[] = "\r\n";
- uint16 n = Write(EOL, sizeof(EOL) - 1);
+ uint16 n = write(EOL, sizeof(EOL) - 1);
len += n;
}
}
@@ -180,40 +180,40 @@ uint16 IOBUF::Write(uint8 *buf) {
}
-int IOBUF::Read(void) {
- if (Ptr >= Lim) {
- ReadBuff();
- if (Lim == 0)
+int IoBuf::read() {
+ if (_ptr >= _lim) {
+ readBuff();
+ if (_lim == 0)
return -1;
}
- return Buff[Ptr++];
+ return _buff[_ptr++];
}
-void IOBUF::Write(uint8 b) {
- if (Lim >= IOBUF_SIZE)
- WriteBuff();
- Buff[Lim++] = b;
+void IoBuf::write(uint8 b) {
+ if (_lim >= IOBUF_SIZE)
+ writeBuff();
+ _buff[_lim++] = b;
}
-uint16 CFILE::MaxLineLen = LINE_MAX;
+uint16 CFile::_maxLineLen = LINE_MAX;
-CFILE::CFILE(const char *name, IOMODE mode, CRYPT *crpt)
- : IOBUF(name, mode, crpt) {
+CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt)
+ : IoBuf(name, mode, crpt) {
}
-CFILE::~CFILE(void) {
+CFile::~CFile(void) {
}
-void CFILE::Flush(void) {
+void CFile::flush(void) {
if (Mode > REA)
- WriteBuff();
+ writeBuff();
else
- Lim = 0;
+ _lim = 0;
/*
_BX = Handle;
@@ -224,33 +224,33 @@ void CFILE::Flush(void) {
}
-long CFILE::Mark(void) {
- return BufMark + ((Mode > REA) ? Lim : Ptr);
+long CFile::mark(void) {
+ return _bufMark + ((Mode > REA) ? _lim : _ptr);
}
-long CFILE::Seek(long pos) {
- if (pos >= BufMark && pos < BufMark + Lim) {
- ((Mode == REA) ? Ptr : Lim) = (uint16)(pos - BufMark);
+long CFile::seek(long pos) {
+ if (pos >= _bufMark && pos < _bufMark + _lim) {
+ ((Mode == REA) ? _ptr : _lim) = (uint16)(pos - _bufMark);
return pos;
} else {
if (Mode > REA)
- WriteBuff();
+ writeBuff();
else
- Lim = 0;
+ _lim = 0;
- Ptr = 0;
- return BufMark = IOHAND::Seek(pos);
+ _ptr = 0;
+ return _bufMark = IoHand::seek(pos);
}
}
-void CFILE::Append(CFILE &f) {
- Seek(Size());
+void CFile::append(CFile &f) {
+ seek(size());
if (f.Error == 0) {
while (true) {
- if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE)
- WriteBuff();
+ if ((_lim = f.IoHand::read(_buff, IOBUF_SIZE)) == IOBUF_SIZE)
+ writeBuff();
else
break;
if ((Error = f.Error) != 0)
diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h
index f045c48c0f..376e50ae44 100644
--- a/engines/cge/cfile.h
+++ b/engines/cge/cfile.h
@@ -38,40 +38,41 @@ namespace CGE {
#define IOBUF_SIZE K(2)
#endif
-#define CFREAD(x) Read((uint8 *)(x),sizeof(*(x)))
+#define CFREAD(x) read((uint8 *)(x),sizeof(*(x)))
-class IOBUF : public IOHAND {
+class IoBuf : public IoHand {
protected:
- uint8 *Buff;
- uint16 Ptr, Lim;
- long BufMark;
- uint16 Seed;
- CRYPT *Crypt;
- virtual void ReadBuff(void);
- virtual void WriteBuff(void);
+ uint8 *_buff;
+ uint16 _ptr;
+ uint16 _lim;
+ long _bufMark;
+ uint16 _seed;
+ CRYPT *_crypt;
+ virtual void readBuff();
+ virtual void writeBuff();
public:
- IOBUF(IOMODE mode, CRYPT *crpt = NULL);
- IOBUF(const char *name, IOMODE mode, CRYPT *crpt = NULL);
- virtual ~IOBUF(void);
- uint16 Read(void *buf, uint16 len);
- uint16 Read(uint8 *buf);
- int Read(void);
- uint16 Write(void *buf, uint16 len);
- uint16 Write(uint8 *buf);
- void Write(uint8 b);
+ IoBuf(IOMODE mode, CRYPT *crpt = NULL);
+ IoBuf(const char *name, IOMODE mode, CRYPT *crpt = NULL);
+ virtual ~IoBuf();
+ uint16 read(void *buf, uint16 len);
+ uint16 read(uint8 *buf);
+ int read();
+ uint16 write(void *buf, uint16 len);
+ uint16 write(uint8 *buf);
+ void write(uint8 b);
};
-class CFILE : public IOBUF {
+class CFile : public IoBuf {
public:
- static uint16 MaxLineLen;
- CFILE(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL);
- virtual ~CFILE(void);
- void Flush(void);
- long Mark(void);
- long Seek(long pos);
- void Append(CFILE &f);
+ static uint16 _maxLineLen;
+ CFile(const char *name, IOMODE mode = REA, CRYPT *crpt = NULL);
+ virtual ~CFile();
+ void flush();
+ long mark();
+ long seek(long pos);
+ void append(CFile &f);
};
} // End of namespace CGE
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index 885aa4d492..c921d7c6ba 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -77,22 +77,22 @@ void CGEEngine::setup() {
InfoLine = new INFO_LINE(this, INFO_W);
_cavLight = new Sprite(this, PR);
DebugLine = new INFO_LINE(this, SCR_WID);
- MB[0] = new Bitmap("BRICK");
+ MB[0] = new Bitmap("BRICK", true);
MB[1] = NULL;
- HL[0] = new Bitmap("HLINE");
+ HL[0] = new Bitmap("HLINE", true);
HL[1] = NULL;
- MC[0] = new Bitmap("MOUSE");
- MC[1] = new Bitmap("DUMMY");
+ MC[0] = new Bitmap("MOUSE", true);
+ MC[1] = new Bitmap("DUMMY", true);
MC[2] = NULL;
- PR[0] = new Bitmap("PRESS");
+ PR[0] = new Bitmap("PRESS", true);
PR[1] = NULL;
- SP[0] = new Bitmap("SPK_L");
- SP[1] = new Bitmap("SPK_R");
+ SP[0] = new Bitmap("SPK_L", true);
+ SP[1] = new Bitmap("SPK_R", true);
SP[2] = NULL;
- LI[0] = new Bitmap("LITE0");
- LI[1] = new Bitmap("LITE1");
- LI[2] = new Bitmap("LITE2");
- LI[3] = new Bitmap("LITE3");
+ LI[0] = new Bitmap("LITE0", true);
+ LI[1] = new Bitmap("LITE1", true);
+ LI[2] = new Bitmap("LITE2", true);
+ LI[3] = new Bitmap("LITE3", true);
LI[4] = NULL;
Snail = new SNAIL(this, false);
Snail_ = new SNAIL(this, true);
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 1e1b952f77..035c4dc317 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -257,10 +257,10 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) {
for (st = _savTab; st->Ptr; st++) {
if (file.Error)
error("Bad SVG");
- file.Read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len);
+ file.read((uint8 *)((tiny || st->Flg) ? st->Ptr : &i), st->Len);
}
- file.Read((uint8 *) &i, sizeof(i));
+ file.read((uint8 *) &i, sizeof(i));
if (i != SVGCHKSUM)
error("%s", Text->getText(BADSVG_TEXT));
@@ -276,7 +276,7 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) {
if (! tiny) { // load sprites & pocket
while (! file.Error) {
Sprite S(this, NULL);
- uint16 n = file.Read((uint8 *) &S, sizeof(S));
+ uint16 n = file.read((uint8 *) &S, sizeof(S));
if (n != sizeof(S))
break;
@@ -299,8 +299,9 @@ void CGEEngine::LoadGame(XFILE &file, bool tiny = false) {
static void SaveSound(void) {
- CFILE cfg(UsrPath(ProgName(CFG_EXT)), WRI);
- if (! cfg.Error) cfg.Write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2));
+ CFile cfg(UsrPath(ProgName(CFG_EXT)), WRI);
+ if (! cfg.Error)
+ cfg.write(&SNDDrvInfo, sizeof(SNDDrvInfo) - sizeof(SNDDrvInfo.VOL2));
}
@@ -320,15 +321,15 @@ static void SaveGame(XFILE &file) {
for (st = _savTab; st->Ptr; st++) {
if (file.Error)
error("Bad SVG");
- file.Write((uint8 *) st->Ptr, st->Len);
+ file.write((uint8 *) st->Ptr, st->Len);
}
- file.Write((uint8 *) & (i = SVGCHKSUM), sizeof(i));
+ file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i));
for (spr = Vga->SpareQ->First(); spr; spr = spr->_next)
if (spr->_ref >= 1000)
if (!file.Error)
- file.Write((uint8 *)spr, sizeof(*spr));
+ file.write((uint8 *)spr, sizeof(*spr));
}
@@ -376,8 +377,8 @@ static void LoadMapping(void) {
INI_FILE cf(ProgName(".TAB"));
if (! cf.Error) {
memset(CLUSTER::Map, 0, sizeof(CLUSTER::Map));
- cf.Seek((Now - 1) * sizeof(CLUSTER::Map));
- cf.Read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map));
+ cf.seek((Now - 1) * sizeof(CLUSTER::Map));
+ cf.read((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map));
}
}
}
@@ -675,9 +676,9 @@ void SYSTEM::FunTouch(void) {
static void ShowBak(int ref) {
Sprite *spr = Vga->SpareQ->Locate(ref);
if (spr) {
- Bitmap::Pal = VGA::SysPal;
+ Bitmap::_pal = VGA::SysPal;
spr->Expand();
- Bitmap::Pal = NULL;
+ Bitmap::_pal = NULL;
spr->Show(2);
Vga->CopyPage(1, 2);
Sys->SetPal();
@@ -776,7 +777,7 @@ void CGEEngine::QGame() {
CaveDown();
OldLev = Lev;
SaveSound();
- CFILE file = CFILE(UsrPath(UsrFnam), WRI, RCrypt);
+ CFile file = CFile(UsrPath(UsrFnam), WRI, RCrypt);
SaveGame(file);
Vga->Sunset();
Finis = true;
@@ -1145,18 +1146,18 @@ static void NextStep(void) {
static void SaveMapping(void) {
{
- IOHAND cf(ProgName(".TAB"), UPD);
+ IoHand cf(ProgName(".TAB"), UPD);
if (!cf.Error) {
- cf.Seek((Now - 1) * sizeof(CLUSTER::Map));
- cf.Write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map));
+ cf.seek((Now - 1) * sizeof(CLUSTER::Map));
+ cf.write((uint8 *) CLUSTER::Map, sizeof(CLUSTER::Map));
}
}
{
- IOHAND cf(ProgName(".HXY"), WRI);
+ IoHand cf(ProgName(".HXY"), WRI);
if (!cf.Error) {
HeroXY[Now - 1]._x = Hero->_x;
HeroXY[Now - 1]._y = Hero->_y;
- cf.Write((uint8 *) HeroXY, sizeof(HeroXY));
+ cf.write((uint8 *) HeroXY, sizeof(HeroXY));
}
}
}
@@ -1345,12 +1346,12 @@ void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int
uint16 len;
MergeExt(line, fname, SPR_EXT);
- if (INI_FILE::Exist(line)) { // sprite description file exist
+ if (INI_FILE::exist(line)) { // sprite description file exist
INI_FILE sprf(line);
if (sprf.Error)
error("Bad SPR [%s]", line);
- while ((len = sprf.Read((uint8 *)line)) != 0) {
+ while ((len = sprf.read((uint8 *)line)) != 0) {
++ lcnt;
if (len && line[len - 1] == '\n')
line[-- len] = '\0';
@@ -1490,7 +1491,7 @@ void CGEEngine::LoadScript(const char *fname) {
if (scrf.Error)
return;
- while (scrf.Read((uint8 *)line) != 0) {
+ while (scrf.read((uint8 *)line) != 0) {
char *p;
++lcnt;
@@ -1566,7 +1567,7 @@ void CGEEngine::MainLoop() {
void CGEEngine::LoadUser() {
// set scene
if (STARTUP::Mode == 0) { // user .SVG file found
- CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt);
+ CFile cfile = CFile(UsrPath(UsrFnam), REA, RCrypt);
LoadGame(cfile);
} else {
if (STARTUP::Mode == 1) {
@@ -1575,7 +1576,7 @@ void CGEEngine::LoadUser() {
} else {
LoadScript(ProgName(INI_EXT));
Music = true;
- CFILE file = CFILE(SVG0NAME, WRI);
+ CFile file = CFile(SVG0NAME, WRI);
SaveGame(file);
error("Ok [%s]", SVG0NAME);
}
@@ -1623,7 +1624,7 @@ void CGEEngine::RunGame() {
if (! Music)
KillMIDI();
- if (Mini && INI_FILE::Exist("MINI.SPR")) {
+ if (Mini && INI_FILE::exist("MINI.SPR")) {
uint8 *ptr = (uint8 *) &*Mini;
if (ptr != NULL) {
LoadSprite("MINI", -1, 0, MINI_X, MINI_Y);
@@ -1641,7 +1642,7 @@ void CGEEngine::RunGame() {
if (Hero) {
ExpandSprite(Hero);
Hero->Goto(HeroXY[Now - 1]._x, HeroXY[Now - 1]._y);
- if (INI_FILE::Exist("00SHADOW.SPR")) {
+ if (INI_FILE::exist("00SHADOW.SPR")) {
LoadSprite("00SHADOW", -1, 0, Hero->_x + 14, Hero->_y + 51);
if ((_shadow = _sprite) != NULL) {
_shadow->_ref = 2;
@@ -1698,7 +1699,7 @@ void CGEEngine::RunGame() {
void CGEEngine::Movie(const char *ext) {
const char *fn = ProgName(ext);
- if (INI_FILE::Exist(fn)) {
+ if (INI_FILE::exist(fn)) {
LoadScript(fn);
ExpandSprite(Vga->SpareQ->Locate(999));
FeedSnail(Vga->ShowQ->Locate(999), TAKE);
@@ -1722,9 +1723,9 @@ void CGEEngine::Movie(const char *ext) {
bool CGEEngine::ShowTitle(const char *name) {
- Bitmap::Pal = VGA::SysPal;
- BMP_PTR LB[] = { new Bitmap(name), NULL };
- Bitmap::Pal = NULL;
+ Bitmap::_pal = VGA::SysPal;
+ BMP_PTR LB[] = { new Bitmap(name, true), NULL };
+ Bitmap::_pal = NULL;
bool usr_ok = false;
Sprite D(this, LB);
@@ -1774,7 +1775,7 @@ bool CGEEngine::ShowTitle(const char *name) {
// Boot * b = ReadBoot(getdisk());
warning("ShowTitle: FIXME ReadBoot");
Boot *b = ReadBoot(0);
- uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs;
+ uint32 sn = (b->_xSign == 0x29) ? b->_serial : b->_lTotSecs;
free(b);
sn -= ((IDENT *)Copr)->disk;
STARTUP::Summa |= Lo(sn) | Hi(sn);
@@ -1801,8 +1802,8 @@ bool CGEEngine::ShowTitle(const char *name) {
if (usr_ok && STARTUP::Mode == 0) {
const char *n = UsrPath(UsrFnam);
- if (CFILE::Exist(n)) {
- CFILE file = CFILE(n, REA, RCrypt);
+ if (CFile::exist(n)) {
+ CFile file = CFile(n, REA, RCrypt);
LoadGame(file, true); // only system vars
Vga->SetColors(VGA::SysPal, 64);
Vga->Update();
@@ -1846,7 +1847,7 @@ void CGEEngine::cge_main(void) {
if (!Mouse->Exist)
error("%s", Text->getText(NO_MOUSE_TEXT));
- if (!SVG0FILE::Exist(SVG0NAME))
+ if (!SVG0FILE::exist(SVG0NAME))
STARTUP::Mode = 2;
DebugLine->_flags._hide = true;
diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp
index 7bf753ff9f..510456087f 100644
--- a/engines/cge/general.cpp
+++ b/engines/cge/general.cpp
@@ -211,13 +211,13 @@ char *dwtom(uint32 val, char *str, int radix, int len) {
return str;
}
-IOHAND::IOHAND(IOMODE mode, CRYPT *crpt)
- : XFILE(mode), Crypt(crpt), Seed(SEED) {
+IoHand::IoHand(IOMODE mode, CRYPT *crpt)
+ : XFILE(mode), _crypt(crpt), _seed(SEED) {
_file = new Common::File();
}
-IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt)
- : XFILE(mode), Crypt(crpt), Seed(SEED) {
+IoHand::IoHand(const char *name, IOMODE mode, CRYPT *crpt)
+ : XFILE(mode), _crypt(crpt), _seed(SEED) {
// TODO: Check if WRI and/or UPD modes are needed, and map to a save file
assert(mode == REA);
@@ -225,24 +225,24 @@ IOHAND::IOHAND(const char *name, IOMODE mode, CRYPT *crpt)
_file->open(name);
}
-IOHAND::~IOHAND(void) {
+IoHand::~IoHand(void) {
_file->close();
delete _file;
}
-uint16 IOHAND::Read(void *buf, uint16 len) {
+uint16 IoHand::read(void *buf, uint16 len) {
if (Mode == WRI || !_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);
+ if (_crypt)
+ _seed = _crypt(buf, len, Seed);
return bytesRead;
}
-uint16 IOHAND::Write(void *buf, uint16 len) {
+uint16 IoHand::write(void *buf, uint16 len) {
error("IOHAND::Write not supported");
/*
if (len) {
@@ -258,20 +258,20 @@ uint16 IOHAND::Write(void *buf, uint16 len) {
*/
}
-long IOHAND::Mark(void) {
+long IoHand::mark(void) {
return _file->pos();
}
-long IOHAND::Seek(long pos) {
+long IoHand::seek(long pos) {
_file->seek(pos, SEEK_SET);
return _file->pos();
}
-long IOHAND::Size(void) {
+long IoHand::size(void) {
return _file->size();
}
-bool IOHAND::Exist(const char *name) {
+bool IoHand::exist(const char *name) {
Common::File f;
return f.exists(name);
}
diff --git a/engines/cge/general.h b/engines/cge/general.h
index 4946e40c7b..1ecec9fbe9 100644
--- a/engines/cge/general.h
+++ b/engines/cge/general.h
@@ -168,36 +168,36 @@ public:
uint16 Error;
XFILE(void) : Mode(REA), Error(0) { }
XFILE(IOMODE mode) : Mode(mode), Error(0) { }
- virtual uint16 Read(void *buf, uint16 len) = 0;
- virtual uint16 Write(void *buf, uint16 len) = 0;
- virtual long Mark(void) = 0;
- virtual long Size(void) = 0;
- virtual long Seek(long pos) = 0;
+ virtual uint16 read(void *buf, uint16 len) = 0;
+ virtual uint16 write(void *buf, uint16 len) = 0;
+ virtual long mark(void) = 0;
+ virtual long size(void) = 0;
+ virtual long seek(long pos) = 0;
virtual ~XFILE() { }
};
template <class T>
inline uint16 XRead(XFILE *xf, T *t) {
- return xf->Read((uint8 *) t, sizeof(*t));
+ return xf->read((uint8 *) t, sizeof(*t));
}
-class IOHAND : public XFILE {
+class IoHand : public XFILE {
protected:
Common::File *_file;
- uint16 Seed;
- CRYPT *Crypt;
+ uint16 _seed;
+ CRYPT *_crypt;
public:
- IOHAND(const char *name, IOMODE mode = REA, CRYPT crypt = NULL);
- IOHAND(IOMODE mode = REA, CRYPT *crpt = NULL);
- virtual ~IOHAND(void);
- static bool Exist(const char *name);
- uint16 Read(void *buf, uint16 len);
- uint16 Write(void *buf, uint16 len);
- long Mark(void);
- long Size(void);
- long Seek(long pos);
+ IoHand(const char *name, IOMODE mode = REA, CRYPT crypt = NULL);
+ IoHand(IOMODE mode = REA, CRYPT *crpt = NULL);
+ virtual ~IoHand();
+ static bool exist(const char *name);
+ uint16 read(void *buf, uint16 len);
+ uint16 write(void *buf, uint16 len);
+ long mark();
+ long size();
+ long seek(long pos);
//timeb Time (void);
// void SetTime (timeb t);
};
diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp
index 7b9ce59f5e..a5ef5b8b62 100644
--- a/engines/cge/mixer.cpp
+++ b/engines/cge/mixer.cpp
@@ -42,7 +42,7 @@ bool MIXER::Appear = false;
MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _vm(vm) {
Appear = true;
- mb[0] = new Bitmap("VOLUME");
+ mb[0] = new Bitmap("VOLUME", true);
mb[1] = NULL;
SetShapeList(mb);
SetName(Text->getText(MIX_NAME));
@@ -58,7 +58,7 @@ MIXER::MIXER(CGEEngine *vm, int x, int y) : Sprite(vm, NULL), Fall(MIX_FALL), _v
for (i = 0; i < MIX_MAX; i++) {
static char fn[] = "V00";
wtom(i, fn + 1, 10, 2);
- lb[i] = new Bitmap(fn);
+ lb[i] = new Bitmap(fn, true);
ls[i].Now = ls[i].Next = i;
ls[i].Dx = ls[i].Dy = ls[i].Dly = 0;
}
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index 565c7d33f0..e9d9b4643f 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -575,12 +575,12 @@ void SNSend(Sprite *spr, int val) {
spr->_flags._slav = false;
} else {
if (spr->_ref % 1000 == 0)
- Bitmap::Pal = VGA::SysPal;
+ Bitmap::_pal = VGA::SysPal;
if (spr->_flags._back)
spr->BackShow(true);
else
ExpandSprite(spr);
- Bitmap::Pal = NULL;
+ Bitmap::_pal = NULL;
}
}
}
diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp
index 4a7b63fb08..eecd3bacb2 100644
--- a/engines/cge/sound.cpp
+++ b/engines/cge/sound.cpp
@@ -187,14 +187,14 @@ void KillMIDI(void) {
void LoadMIDI(int ref) {
static char fn[] = "00.MID";
wtom(ref, fn, 10, 2);
- if (INI_FILE::Exist(fn)) {
+ if (INI_FILE::exist(fn)) {
KillMIDI();
INI_FILE mid = fn;
if (mid.Error == 0) {
- uint16 siz = (uint16) mid.Size();
+ uint16 siz = (uint16) mid.size();
midi = new uint8[siz];
if (midi) {
- mid.Read(midi, siz);
+ mid.read(midi, siz);
if (mid.Error)
KillMIDI();
else
@@ -212,10 +212,10 @@ EC void *Patch(int pat) {
wtom(pat, fn + 5, 10, 3);
INI_FILE snd = fn;
if (! snd.Error) {
- uint16 siz = (uint16) snd.Size();
+ uint16 siz = (uint16) snd.size();
p = (uint8 *) malloc(siz);
if (p) {
- snd.Read(p, siz);
+ snd.read(p, siz);
if (snd.Error) {
free(p);
p = NULL;
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 5aa5e44b8d..c8aa8292e8 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -53,24 +53,24 @@ FONT::FONT(const char *name) {
}
-FONT::~FONT(void) {
+FONT::~FONT() {
free(Map);
free(Pos);
free(Wid);
}
-void FONT::Load(void) {
+void FONT::Load() {
INI_FILE f(Path);
if (! f.Error) {
- f.Read(Wid, WID_SIZ);
+ f.read(Wid, WID_SIZ);
if (! f.Error) {
uint16 i, p = 0;
for (i = 0; i < POS_SIZ; i++) {
Pos[i] = p;
p += Wid[i];
}
- f.Read(Map, p);
+ f.read(Map, p);
}
}
}
@@ -181,7 +181,7 @@ void TALK::Update(const char *tx) {
}
tx++;
}
- TS[0]->Code();
+ TS[0]->code();
SetShapeList(TS);
}
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index 7b191b492b..7df51f1126 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -45,7 +45,7 @@ TALK *Talk = NULL;
TEXT::TEXT(CGEEngine *vm, const char *fname, int size) : _vm(vm) {
Cache = new HAN[size];
MergeExt(FileName, fname, SAY_EXT);
- if (!INI_FILE::Exist(FileName))
+ if (!INI_FILE::exist(FileName))
error("No talk (%s)\n", FileName);
for (Size = 0; Size < size; Size++) {
@@ -93,7 +93,7 @@ void TEXT::Preload(int from, int upto) {
char line[LINE_MAX + 1];
int n;
- while ((n = tf.Read((uint8 *)line)) != 0) {
+ while ((n = tf.read((uint8 *)line)) != 0) {
char *s;
int ref;
@@ -135,7 +135,7 @@ char *TEXT::Load(int idx, int ref) {
char line[LINE_MAX + 1];
int n;
- while ((n = tf.Read((uint8 *)line)) != 0) {
+ while ((n = tf.read((uint8 *)line)) != 0) {
char *s;
if (line[n - 1] == '\n')
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index 673d6036d8..f26d202dca 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -417,7 +417,7 @@ BMP_PTR *Sprite::SetShapeList(BMP_PTR *shp) {
void Sprite::MoveShapes(uint8 *buf) {
BMP_PTR *p;
for (p = _ext->_shpList; *p; p++) {
- buf += (*p)->MoveVmap(buf);
+ buf += (*p)->moveVmap(buf);
}
}
@@ -503,12 +503,12 @@ Sprite *Sprite::Expand(void) {
SNAIL::COM *nea = NULL;
SNAIL::COM *tak = NULL;
MergeExt(fname, File, SPR_EXT);
- if (INI_FILE::Exist(fname)) { // sprite description file exist
+ if (INI_FILE::exist(fname)) { // sprite description file exist
INI_FILE sprf(fname);
if (! (sprf.Error==0))
error("Bad SPR [%s]", fname);
int len = 0, lcnt = 0;
- while ((len = sprf.Read((uint8 *)line)) != 0) {
+ while ((len = sprf.read((uint8 *)line)) != 0) {
++lcnt;
if (len && line[len - 1] == '\n')
line[-- len] = '\0';
@@ -521,7 +521,7 @@ Sprite *Sprite::Expand(void) {
break;
}
case 1 : { // Phase
- shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"));
+ shplist[shpcnt++] = new Bitmap(strtok(NULL, " \t,;/"), true);
break;
}
case 2 : { // Seq
@@ -583,7 +583,7 @@ Sprite *Sprite::Expand(void) {
}
}
} else { // no sprite description: try to read immediately from .BMP
- shplist[shpcnt++] = new Bitmap(File);
+ shplist[shpcnt++] = new Bitmap(File, true);
}
shplist[shpcnt] = NULL;
if (seq) {
@@ -748,9 +748,9 @@ void Sprite::Show(void) {
// asm sti // ...done!
if (!_flags._hide) {
if (_flags._xlat)
- e->_b1->XShow(e->_x1, e->_y1);
+ e->_b1->xShow(e->_x1, e->_y1);
else
- e->_b1->Show(e->_x1, e->_y1);
+ e->_b1->show(e->_x1, e->_y1);
}
}
@@ -758,7 +758,7 @@ void Sprite::Show(void) {
void Sprite::Show(uint16 pg) {
Graphics::Surface *a = VGA::Page[1];
VGA::Page[1] = VGA::Page[pg & 3];
- Shp()->Show(_x, _y);
+ Shp()->show(_x, _y);
VGA::Page[1] = a;
}
@@ -766,7 +766,7 @@ void Sprite::Show(uint16 pg) {
void Sprite::Hide(void) {
register SprExt *e = _ext;
if (e->_b0)
- e->_b0->Hide(e->_x0, e->_y0);
+ e->_b0->hide(e->_x0, e->_y0);
}
@@ -795,7 +795,7 @@ Sprite *SpriteAt(int x, int y) {
if (tail) {
for (spr = tail->_prev; spr; spr = spr->_prev) {
if (! spr->_flags._hide && ! spr->_flags._tran) {
- if (spr->Shp()->SolidAt(x - spr->_x, y - spr->_y))
+ if (spr->Shp()->solidAt(x - spr->_x, y - spr->_y))
break;
}
}
@@ -1178,7 +1178,7 @@ void VGA::CopyPage(uint16 d, uint16 s) {
//--------------------------------------------------------------------------
-void Bitmap::XShow(int x, int y) {
+void Bitmap::xShow(int x, int y) {
/*
uint8 rmsk = x % 4,
mask = 1 << rmsk,
@@ -1256,11 +1256,11 @@ void Bitmap::XShow(int x, int y) {
asm pop si
asm pop bx
*/
- warning("STUB: BITMAP::XShow");
+ warning("STUB: BITMAP::xShow");
}
-void Bitmap::Show(int x, int y) {
+void Bitmap::show(int x, int y) {
const byte *srcP = (const byte *)_v;
byte *destEndP = (byte *)VGA::Page[1]->pixels + (SCR_WID * SCR_HIG);
@@ -1322,7 +1322,7 @@ void Bitmap::Show(int x, int y) {
}
-void Bitmap::Hide(int x, int y) {
+void Bitmap::hide(int x, int y) {
/*
uint8 *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4;
uint16 d = FP_OFF(VGA::Page[2]) - FP_OFF(VGA::Page[1]);
@@ -1385,7 +1385,7 @@ void Bitmap::Hide(int x, int y) {
asm pop si
// asm pop bx
*/
- warning("STUB: Bitmap::Hide");
+ warning("STUB: Bitmap::hide");
}
} // End of namespace CGE
diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp
index c76914c003..8170bd5980 100644
--- a/engines/cge/vol.cpp
+++ b/engines/cge/vol.cpp
@@ -34,9 +34,9 @@
namespace CGE {
-DAT *VFILE::_Dat = NULL;
-BTFILE *VFILE::_Cat = NULL;
-VFILE *VFILE::_Recent = NULL;
+DAT *VFILE::_dat = NULL;
+BtFile *VFILE::_cat = NULL;
+VFILE *VFILE::_recent = NULL;
/*-----------------------------------------------------------------------*/
@@ -52,30 +52,30 @@ DAT::DAT():
/*-----------------------------------------------------------------------*/
void VFILE::init() {
- _Dat = new DAT();
+ _dat = new DAT();
#ifdef VOL_UPD
- _Cat = new BTFILE(CAT_NAME, UPD, CRP);
+ _cat = new BtFile(CAT_NAME, UPD, CRP);
#else
- _Cat = new BTFILE(CAT_NAME, REA, CRP);
+ _cat = new BtFile(CAT_NAME, REA, CRP);
#endif
- _Recent = NULL;
+ _recent = NULL;
}
void VFILE::deinit() {
- delete _Dat;
- delete _Cat;
+ delete _dat;
+ delete _cat;
}
VFILE::VFILE(const char *name, IOMODE mode)
- : IOBUF(mode) {
+ : IoBuf(mode) {
if (mode == REA) {
- if (_Dat->_File.Error || _Cat->Error)
+ if (_dat->_File.Error || _cat->Error)
error("Bad volume data");
- BT_KEYPACK *kp = _Cat->Find(name);
- if (scumm_stricmp(kp->Key, name) != 0)
+ BtKeypack *kp = _cat->find(name);
+ if (scumm_stricmp(kp->_key, name) != 0)
Error = 1;
- EndMark = (BufMark = BegMark = kp->Mark) + kp->Size;
+ _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size;
}
#ifdef VOL_UPD
else
@@ -85,27 +85,27 @@ VFILE::VFILE(const char *name, IOMODE mode)
VFILE::~VFILE(void) {
- if (_Recent == this)
- _Recent = NULL;
+ if (_recent == this)
+ _recent = NULL;
}
-bool VFILE::Exist(const char *name) {
- return scumm_stricmp(_Cat->Find(name)->Key, name) == 0;
+bool VFILE::exist(const char *name) {
+ return scumm_stricmp(_cat->find(name)->_key, name) == 0;
}
-void VFILE::ReadBuff(void) {
- if (_Recent != this) {
- _Dat->_File.Seek(BufMark + Lim);
- _Recent = this;
+void VFILE::readBuff(void) {
+ if (_recent != this) {
+ _dat->_File.seek(_bufMark + _lim);
+ _recent = this;
}
- BufMark = _Dat->_File.Mark();
- long n = EndMark - BufMark;
+ _bufMark = _dat->_File.mark();
+ long n = _endMark - _bufMark;
if (n > IOBUF_SIZE)
n = IOBUF_SIZE;
- Lim = _Dat->_File.Read(Buff, (uint16) n);
- Ptr = 0;
+ _lim = _dat->_File.read(_buff, (uint16) n);
+ _ptr = 0;
}
} // End of namespace CGE
diff --git a/engines/cge/vol.h b/engines/cge/vol.h
index a910aa7209..c2e676130e 100644
--- a/engines/cge/vol.h
+++ b/engines/cge/vol.h
@@ -45,7 +45,7 @@ namespace CGE {
#ifdef VOL_UPD
#define VOLBASE IOHAND
#else
-#define VOLBASE CFILE
+#define VOLBASE CFile
#endif
@@ -55,40 +55,42 @@ class DAT {
public:
DAT();
- bool Append(uint8 *buf, uint16 len);
- bool Write(CFILE &f);
- bool Read(long org, uint16 len, uint8 *buf);
+ bool append(uint8 *buf, uint16 len);
+ bool write(CFile &f);
+ bool read(long org, uint16 len, uint8 *buf);
};
-class VFILE : public IOBUF {
+class VFILE : public IoBuf {
private:
- static DAT *_Dat;
- static BTFILE *_Cat;
- static VFILE *_Recent;
-
- long BegMark, EndMark;
- void ReadBuff(void);
- void WriteBuff(void) { }
- void Make(const char *fspec);
+ static DAT *_dat;
+ static BtFile *_cat;
+ static VFILE *_recent;
+
+ long _begMark;
+ long _endMark;
+
+ void readBuff(void);
+ void writeBuff(void) { }
+ void make(const char *fspec);
public:
VFILE(const char *name, IOMODE mode = REA);
~VFILE(void);
static void init();
static void deinit();
- static bool Exist(const char *name);
- static const char *Next(void);
- long Mark(void) {
- return (BufMark + Ptr) - BegMark;
+ static bool exist(const char *name);
+ static const char *next(void);
+ long mark(void) {
+ return (_bufMark + _ptr) - _begMark;
}
- long Size(void) {
- return EndMark - BegMark;
+ long size(void) {
+ return _endMark - _begMark;
}
- long Seek(long pos) {
- _Recent = NULL;
- Lim = 0;
- return (BufMark = BegMark + pos);
+ long seek(long pos) {
+ _recent = NULL;
+ _lim = 0;
+ return (_bufMark = _begMark + pos);
}
};
diff --git a/engines/cge/wav.h b/engines/cge/wav.h
index 304c2827d8..3423c43033 100644
--- a/engines/cge/wav.h
+++ b/engines/cge/wav.h
@@ -58,7 +58,7 @@ public:
Id = d;
}
CKID(XFILE *xf) {
- (ckFile = xf)->Read(Tx, sizeof(Tx));
+ (ckFile = xf)->read(Tx, sizeof(Tx));
}
bool operator !=(CKID &X) {
return Id != X.Id;