aboutsummaryrefslogtreecommitdiff
path: root/engines/cge
diff options
context:
space:
mode:
Diffstat (limited to 'engines/cge')
-rw-r--r--engines/cge/bitmap.cpp18
-rw-r--r--engines/cge/bitmap.h2
-rw-r--r--engines/cge/btfile.cpp2
-rw-r--r--engines/cge/btfile.h2
-rw-r--r--engines/cge/cfile.cpp18
-rw-r--r--engines/cge/cfile.h8
-rw-r--r--engines/cge/cge.cpp28
-rw-r--r--engines/cge/cge.h28
-rw-r--r--engines/cge/cge_main.cpp220
-rw-r--r--engines/cge/cge_main.h19
-rw-r--r--engines/cge/detection.cpp12
-rw-r--r--engines/cge/events.cpp109
-rw-r--r--engines/cge/events.h51
-rw-r--r--engines/cge/game.cpp10
-rw-r--r--engines/cge/general.cpp26
-rw-r--r--engines/cge/general.h25
-rw-r--r--engines/cge/gettext.cpp6
-rw-r--r--engines/cge/jbw.h1
-rw-r--r--engines/cge/mixer.cpp4
-rw-r--r--engines/cge/mixer.h4
-rw-r--r--engines/cge/snail.cpp33
-rw-r--r--engines/cge/snail.h2
-rw-r--r--engines/cge/talk.cpp72
-rw-r--r--engines/cge/talk.h10
-rw-r--r--engines/cge/text.cpp46
-rw-r--r--engines/cge/text.h29
-rw-r--r--engines/cge/vga13h.cpp96
-rw-r--r--engines/cge/vga13h.h38
-rw-r--r--engines/cge/vmenu.cpp4
-rw-r--r--engines/cge/walk.cpp58
-rw-r--r--engines/cge/walk.h26
-rw-r--r--engines/cge/wav.h10
32 files changed, 488 insertions, 529 deletions
diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp
index 6689998deb..b53cac4e90 100644
--- a/engines/cge/bitmap.cpp
+++ b/engines/cge/bitmap.cpp
@@ -63,11 +63,11 @@ Bitmap::Bitmap(const char *fname, bool rem) : _m(NULL), _v(NULL), _map(0) {
#endif
{
#if (BMP_MODE)
- ForceExt(pat, fname, ".BMP");
+ forceExt(pat, fname, ".BMP");
PIC_FILE file(pat);
if (file._error == 0) {
if (loadBMP(&file)) {
- Code();
+ code();
if (rem) {
free(_m);
_m = NULL;
@@ -126,7 +126,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill)
b->_hide = _w >> 2;
// Replicate across the entire table
- for (HideDesc *hdP = b + 1; hdP < (b + _h); ++hdP)
+ for (HideDesc *hdP = b + 1; hdP < (b + _h); hdP++)
*hdP = *b;
b->_skip = 0; // fix the first entry
@@ -195,7 +195,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) {
}
-BMP_PTR Bitmap::code() {
+BitmapPtr Bitmap::code() {
debugC(1, kCGEDebugBitmap, "Bitmap::code()");
if (!_m)
@@ -421,17 +421,17 @@ bool Bitmap::loadVBM(XFile *f) {
if (p) {
if (_pal) {
// Read in the palette
- byte palData[PAL_SIZ];
- f->read(palData, PAL_SIZ);
+ byte palData[kPalSize];
+ f->read(palData, kPalSize);
const byte *srcP = palData;
- for (int idx = 0; idx < PAL_CNT; ++idx, srcP += 3) {
+ for (int idx = 0; idx < kPalCount; idx++, srcP += 3) {
_pal[idx]._r = *srcP;
_pal[idx]._g = *(srcP + 1);
_pal[idx]._b = *(srcP + 2);
}
} else
- f->seek(f->mark() + PAL_SIZ);
+ f->seek(f->mark() + kPalSize);
}
}
if ((_v = new uint8[n]) == NULL)
@@ -473,7 +473,7 @@ bool Bitmap::loadBMP(XFile *f) {
f->read((byte *)&bpal, sizeof(bpal));
if (f->_error == 0) {
if (_pal) {
- for (i = 0; i < 256; i ++) {
+ for (i = 0; i < 256; i++) {
_pal[i]._r = bpal[i]._R;
_pal[i]._g = bpal[i]._G;
_pal[i]._b = bpal[i]._B;
diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h
index 6b931573f8..30e11d08ec 100644
--- a/engines/cge/bitmap.h
+++ b/engines/cge/bitmap.h
@@ -91,7 +91,7 @@ public:
};
-typedef Bitmap *BMP_PTR;
+typedef Bitmap *BitmapPtr;
} // End of namespace CGE
diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp
index 55511e6382..1f987340b7 100644
--- a/engines/cge/btfile.cpp
+++ b/engines/cge/btfile.cpp
@@ -34,7 +34,7 @@
namespace CGE {
-BtFile::BtFile(const char *name, IOMode mode, CRYPT *crpt)
+BtFile::BtFile(const char *name, IOMode mode, Crypt *crpt)
: IoHand(name, mode, crpt) {
debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode);
diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h
index b589e86aee..6b7155d43d 100644
--- a/engines/cge/btfile.h
+++ b/engines/cge/btfile.h
@@ -83,7 +83,7 @@ class BtFile : public IoHand {
void putPage(int lev, bool hard);
BtPage *getPage(int lev, uint16 pgn);
public:
- BtFile(const char *name, IOMode mode, CRYPT *crpt);
+ BtFile(const char *name, IOMode mode, Crypt *crpt);
virtual ~BtFile();
BtKeypack *find(const char *key);
BtKeypack *next();
diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp
index ac9f782d84..c6144f624b 100644
--- a/engines/cge/cfile.cpp
+++ b/engines/cge/cfile.cpp
@@ -33,24 +33,24 @@
namespace CGE {
-IoBuf::IoBuf(IOMode mode, CRYPT *crpt)
- : IoHand(mode, crpt),
+IoBuf::IoBuf(IOMode mode, Crypt *crypt)
+ : IoHand(mode, crypt),
_bufMark(0),
_ptr(0),
_lim(0) {
- debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crpt)", mode);
+ debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crypt)", mode);
_buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
assert(_buff != NULL);
}
-IoBuf::IoBuf(const char *name, IOMode mode, CRYPT *crpt)
- : IoHand(name, mode, crpt),
+IoBuf::IoBuf(const char *name, IOMode mode, Crypt *crypt)
+ : IoHand(name, mode, crypt),
_bufMark(0),
_ptr(0),
_lim(0) {
- debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode);
+ debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crypt)", name, mode);
_buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
assert(_buff != NULL);
@@ -220,9 +220,9 @@ void IoBuf::write(uint8 b) {
uint16 CFile::_maxLineLen = kLineMaxSize;
-CFile::CFile(const char *name, IOMode mode, CRYPT *crpt)
- : IoBuf(name, mode, crpt) {
- debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crpt)", name, mode);
+CFile::CFile(const char *name, IOMode mode, Crypt *crypt)
+ : IoBuf(name, mode, crypt) {
+ debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crypt)", name, mode);
}
diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h
index 306ec5926b..6ed3b5e750 100644
--- a/engines/cge/cfile.h
+++ b/engines/cge/cfile.h
@@ -42,12 +42,12 @@ protected:
uint16 _lim;
long _bufMark;
uint16 _seed;
- CRYPT *_crypt;
+ Crypt *_crypt;
virtual void readBuf();
virtual void writeBuf();
public:
- IoBuf(IOMode mode, CRYPT *crpt = NULL);
- IoBuf(const char *name, IOMode mode, CRYPT *crpt = NULL);
+ 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);
@@ -61,7 +61,7 @@ public:
class CFile : public IoBuf {
public:
static uint16 _maxLineLen;
- CFile(const char *name, IOMode mode = kModeRead, CRYPT *crpt = NULL);
+ CFile(const char *name, IOMode mode = kModeRead, Crypt *crpt = NULL);
virtual ~CFile();
void flush();
long mark();
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index 8d2073b66f..2baf1cde1e 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -59,21 +59,21 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription)
void CGEEngine::initCaveValues() {
if (_isDemo) {
_mini = new byte[16384];
- CAVE_DX = 23;
- CAVE_DY = 29;
- CAVE_NX = 3;
- CAVE_NY = 1;
+ _caveDx = 23;
+ _caveDy = 29;
+ _caveNx = 3;
+ _caveNy = 1;
} else {
_mini = new byte[65536];
- CAVE_DX = 9;
- CAVE_DY = 10;
- CAVE_NX = 8;
- CAVE_NY = 3;
+ _caveDx = 9;
+ _caveDy = 10;
+ _caveNx = 8;
+ _caveNy = 3;
}
- CAVE_MAX = CAVE_NX * CAVE_NY;
+ _caveMax = _caveNx * _caveNy;
if (_isDemo) {
- _maxCaveArr[0] = CAVE_MAX;
+ _maxCaveArr[0] = _caveMax;
_maxCaveArr[1] = -1;
_maxCaveArr[2] = -1;
_maxCaveArr[3] = -1;
@@ -86,14 +86,14 @@ void CGEEngine::initCaveValues() {
_maxCaveArr[4] = 24;
};
- _heroXY = (Hxy *) malloc (sizeof(Hxy) * CAVE_MAX);
- for (int i = 0; i < CAVE_MAX; i++) {
+ _heroXY = (Hxy *) malloc (sizeof(Hxy) * _caveMax);
+ for (int i = 0; i < _caveMax; i++) {
_heroXY[i]._x = 0;
_heroXY[i]._y = 0;
}
- _barriers = (Bar *) malloc (sizeof(Bar) * (1 + CAVE_MAX));
- for (int i = 0; i < CAVE_MAX + 1; i++) {
+ _barriers = (Bar *) malloc (sizeof(Bar) * (1 + _caveMax));
+ for (int i = 0; i < _caveMax + 1; i++) {
_barriers[i]._horz = 0xFF;
_barriers[i]._vert = 0xFF;
}
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index 9d2503a5cf..54ea9e37f6 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -40,7 +40,8 @@ namespace CGE {
class Console;
class Sprite;
-#define CGE_SAVEGAME_VERSION 1
+#define kSavegameVersion 1
+#define kSavegameStrSize 11
#define kPocketX 174
#define kPocketY 176
#define kPocketDX 18
@@ -75,8 +76,7 @@ struct SavegameHeader {
int totalFrames;
};
-extern const char *SAVEGAME_STR;
-#define SAVEGAME_STR_SIZE 11
+extern const char *savegameStr;
struct Bar {
uint8 _horz;
@@ -133,19 +133,19 @@ public:
Sprite *_sprK2;
Sprite *_sprK3;
- uint8 CAVE_DX;
- uint8 CAVE_DY;
- uint8 CAVE_NX;
- uint8 CAVE_NY;
- uint16 CAVE_MAX;
+ uint8 _caveDx;
+ uint8 _caveDy;
+ uint8 _caveNx;
+ uint8 _caveNy;
+ uint16 _caveMax;
Hxy *_heroXY;
Bar *_barriers;
Common::RandomSource _randomSource;
- byte * _mini;
- BMP_PTR * _miniShp;
- BMP_PTR * _miniShpList;
- int _startGameSlot;
+ byte *_mini;
+ BitmapPtr *_miniShp;
+ BitmapPtr *_miniShpList;
+ int _startGameSlot;
virtual Common::Error run();
GUI::Debugger *getDebugger() {
@@ -168,7 +168,7 @@ public:
bool showTitle(const char *name);
void movie(const char *ext);
void takeName();
- void inf(const char *txt);
+ void inf(const char *text);
void selectSound();
void dummy() {}
void NONE();
@@ -202,7 +202,7 @@ public:
void saveMapping();
void saveSound();
void heroCover(int cvr);
- void trouble(int seq, int txt);
+ void trouble(int seq, int text);
void offUse();
void tooFar();
void loadHeroXY();
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 05beaae58d..d9d32b7f39 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -54,13 +54,7 @@
namespace CGE {
-#define STACK_SIZ 2048
-#define SVGCHKSUM (1956 + _now + _oldLev + _game + _music + _demoText)
-
-#define SVG0NAME ("{{INIT}}" kSvgExt)
-#define SVG0FILE INI_FILE
-
-uint16 _stklen = (STACK_SIZ * 2);
+uint16 _stklen = (kStackSize * 2);
Vga *_vga;
System *_sys;
@@ -90,8 +84,7 @@ Sound *_sound;
// 1.01 - 17VII95 - default savegame with sound ON
// coditionals EVA for 2-month evaluation version
-const char *SAVEGAME_STR = "SCUMMVM_CGE";
-#define SAVEGAME_STR_SIZE 11
+const char *savegameStr = "SCUMMVM_CGE";
//--------------------------------------------------------------------------
@@ -109,41 +102,41 @@ void CGEEngine::syncHeader(Common::Serializer &s) {
s.syncAsUint16LE(_now);
s.syncAsUint16LE(_oldLev);
s.syncAsUint16LE(_demoText);
- for (i = 0; i < 5; ++i)
+ for (i = 0; i < 5; i++)
s.syncAsUint16LE(_game);
s.syncAsSint16LE(i); // unused VGA::Mono variable
s.syncAsUint16LE(_music);
s.syncBytes(_volume, 2);
- for (i = 0; i < 4; ++i)
+ for (i = 0; i < 4; i++)
s.syncAsUint16LE(_flag[i]);
initCaveValues();
if (s.isLoading()) {
//TODO: Fix the memory leak when the game is already running
- _heroXY = (Hxy *) malloc (sizeof(Hxy) * CAVE_MAX);
- _barriers = (Bar *) malloc (sizeof(Bar) * (1 + CAVE_MAX));
+ _heroXY = (Hxy *) malloc (sizeof(Hxy) * _caveMax);
+ _barriers = (Bar *) malloc (sizeof(Bar) * (1 + _caveMax));
}
- for (i = 0; i < CAVE_MAX; ++i) {
+ for (i = 0; i < _caveMax; i++) {
s.syncAsSint16LE(_heroXY[i]._x);
s.syncAsUint16LE(_heroXY[i]._y);
}
- for (i = 0; i < 1 + CAVE_MAX; ++i) {
+ for (i = 0; i < 1 + _caveMax; i++) {
s.syncAsByte(_barriers[i]._horz);
s.syncAsByte(_barriers[i]._vert);
}
- for (i = 0; i < kPocketNX; ++i)
+ for (i = 0; i < kPocketNX; i++)
s.syncAsUint16LE(_pocref[i]);
if (s.isSaving()) {
// Write checksum
- int checksum = SVGCHKSUM;
+ int checksum = kSavegameCheckSum;
s.syncAsUint16LE(checksum);
} else {
// Read checksum and validate it
uint16 checksum;
s.syncAsUint16LE(checksum);
- if (checksum != SVGCHKSUM)
+ if (checksum != kSavegameCheckSum)
error("%s", _text->getText(kBadSVG));
}
}
@@ -156,7 +149,7 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) {
if (slotNumber == -1) {
// Loading the data for the initial game state
- SVG0FILE file = SVG0FILE(SVG0NAME);
+ kSavegame0File file = kSavegame0File(kSavegame0Name);
int size = file.size();
byte *dataBuffer = (byte *)malloc(size);
file.read(dataBuffer, size);
@@ -175,10 +168,10 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) {
}
// Check to see if it's a ScummVM savegame or not
- char buffer[SAVEGAME_STR_SIZE + 1];
- readStream->read(buffer, SAVEGAME_STR_SIZE + 1);
+ char buffer[kSavegameStrSize + 1];
+ readStream->read(buffer, kSavegameStrSize + 1);
- if (strncmp(buffer, SAVEGAME_STR, SAVEGAME_STR_SIZE + 1) != 0) {
+ if (strncmp(buffer, savegameStr, kSavegameStrSize + 1) != 0) {
// It's not, so rewind back to the start
readStream->seek(0);
@@ -269,7 +262,7 @@ void CGEEngine::saveGame(int slotNumber, const Common::String &desc) {
// Write out the ScummVM savegame header
SavegameHeader header;
header.saveName = desc;
- header.version = CGE_SAVEGAME_VERSION;
+ header.version = kSavegameVersion;
writeSavegameHeader(saveFile, header);
// Write out the data of the savegame
@@ -282,9 +275,9 @@ void CGEEngine::saveGame(int slotNumber, const Common::String &desc) {
void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header) {
// Write out a savegame header
- out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1);
+ out->write(savegameStr, kSavegameStrSize + 1);
- out->writeByte(CGE_SAVEGAME_VERSION);
+ out->writeByte(kSavegameVersion);
// Write savegame name
out->write(header.saveName.c_str(), header.saveName.size() + 1);
@@ -376,7 +369,7 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade
// Get the savegame version
header.version = in->readByte();
- if (header.version > CGE_SAVEGAME_VERSION)
+ if (header.version > kSavegameVersion)
return false;
// Read in the string
@@ -409,21 +402,21 @@ void CGEEngine::heroCover(int cvr) {
_snail->addCom(kSnCover, 1, cvr, NULL);
}
-void CGEEngine::trouble(int seq, int txt) {
- debugC(1, kCGEDebugEngine, "CGEEngine::trouble(%d, %d)", seq, txt);
+void CGEEngine::trouble(int seq, int text) {
+ debugC(1, kCGEDebugEngine, "CGEEngine::trouble(%d, %d)", seq, text);
_hero->park();
_snail->addCom(kSnWait, -1, -1, _hero);
_snail->addCom(kSnSeq, -1, seq, _hero);
_snail->addCom(kSnSound, -1, 2, _hero);
_snail->addCom(kSnWait, -1, -1, _hero);
- _snail->addCom(kSnSay, 1, txt, _hero);
+ _snail->addCom(kSnSay, 1, text, _hero);
}
void CGEEngine::offUse() {
debugC(1, kCGEDebugEngine, "CGEEngine::offUse()");
- trouble(kSeqOffUse, kOffUse + new_random(_offUseCount));
+ trouble(kSeqOffUse, kOffUse + newRandom(_offUseCount));
}
void CGEEngine::tooFar() {
@@ -444,7 +437,7 @@ void CGEEngine::loadHeroXY() {
void CGEEngine::loadMapping() {
debugC(1, kCGEDebugEngine, "CGEEngine::loadMapping()");
- if (_now <= CAVE_MAX) {
+ if (_now <= _caveMax) {
INI_FILE cf(progName(".TAB"));
if (!cf._error) {
memset(Cluster::_map, 0, sizeof(Cluster::_map));
@@ -458,7 +451,7 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
_flags._kill = true;
_flags._bDel = false;
- BMP_PTR *MB = new BMP_PTR[2];
+ BitmapPtr *MB = new BitmapPtr[2];
MB[0] = new Bitmap("BRICK", true);
MB[1] = NULL;
setShapeList(MB);
@@ -467,7 +460,7 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
void Square::touch(uint16 mask, int x, int y) {
Sprite::touch(mask, x, y);
- if (mask & L_UP) {
+ if (mask & kMouseLeftUp) {
XZ(_x + x, _y + y).cell() = 0;
_snail_->addCom(kSnKill, -1, 0, this);
}
@@ -480,7 +473,7 @@ void CGEEngine::setMapBrick(int x, int z) {
Square *s = new Square(this);
if (s) {
static char n[] = "00:00";
- s->gotoxy(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID);
+ s->gotoxy(x * kMapGridX, kMapTop + z * kMapGridZ);
wtom(x, n + 0, 10, 2);
wtom(z, n + 3, 10, 2);
Cluster::_map[z][x] = 1;
@@ -688,8 +681,8 @@ void CGEEngine::switchCave(int cav) {
if (!_isDemo)
_vga->_spareQ->_show = 0;
}
- _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
- CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
+ _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX,
+ kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY);
killText();
if (!_startupMode)
keyClick();
@@ -716,7 +709,7 @@ void System::setPal() {
}
void System::funTouch() {
- uint16 n = (PAIN) ? kHeroFun1 : kHeroFun0;
+ uint16 n = (_vm->_flag[0]) ? kHeroFun1 : kHeroFun0; // PAIN flag
if (_talk == NULL || n > _funDel)
_funDel = n;
}
@@ -726,7 +719,7 @@ void System::touch(uint16 mask, int x, int y) {
funTouch();
- if (mask & KEYB) {
+ if (mask & kEventKeyb) {
int pp0;
_vm->keyClick();
killText();
@@ -737,13 +730,13 @@ void System::touch(uint16 mask, int x, int y) {
pp0 = pp;
switch (x) {
case Del:
- if (_keyboard->_key[ALT] && _keyboard->_key[CTRL])
+ if (_keyboard->_key[kKeyAlt] && _keyboard->_key[kKeyCtrl])
_vm->AltCtrlDel();
else
_vm->killSprite();
break;
case 'F':
- if (_keyboard->_key[ALT]) {
+ if (_keyboard->_key[kKeyAlt]) {
Sprite *m = _vga->_showQ->locate(17001);
if (m) {
m->step(1);
@@ -761,7 +754,7 @@ void System::touch(uint16 mask, int x, int y) {
_vm->nextStep();
break;
case '`':
- if (_keyboard->_key[ALT])
+ if (_keyboard->_key[kKeyAlt])
_vm->saveMapping();
else
_vm->switchMapping();
@@ -791,7 +784,7 @@ void System::touch(uint16 mask, int x, int y) {
_sys->_funDel = 1;
break;
case 'X':
- if (_keyboard->_key[ALT])
+ if (_keyboard->_key[kKeyAlt])
_finis = true;
break;
case '0':
@@ -799,7 +792,7 @@ void System::touch(uint16 mask, int x, int y) {
case '2':
case '3':
case '4':
- if (_keyboard->_key[ALT]) {
+ if (_keyboard->_key[kKeyAlt]) {
_snail->addCom(kSnLevel, -1, x - '0', NULL);
break;
}
@@ -837,15 +830,15 @@ void System::touch(uint16 mask, int x, int y) {
_infoLine->update(NULL);
if (y >= kWorldHeight ) {
if (x < kButtonX) { // select cave?
- if (y >= CAVE_Y && y < CAVE_Y + _vm->CAVE_NY * _vm->CAVE_DY &&
- x >= CAVE_X && x < CAVE_X + _vm->CAVE_NX * _vm->CAVE_DX && !_vm->_game) {
- cav = ((y - CAVE_Y) / _vm->CAVE_DY) * _vm->CAVE_NX + (x - CAVE_X) / _vm->CAVE_DX + 1;
+ if (y >= kCaveY && y < kCaveY + _vm->_caveNy * _vm->_caveDy &&
+ x >= kCaveX && x < kCaveX + _vm->_caveNx * _vm->_caveDx && !_vm->_game) {
+ cav = ((y - kCaveY) / _vm->_caveDy) * _vm->_caveNx + (x - kCaveX) / _vm->_caveDx + 1;
if (cav > _vm->_maxCave)
cav = 0;
} else {
cav = 0;
}
- } else if (mask & L_UP) {
+ } else if (mask & kMouseLeftUp) {
if (y >= kPocketY && y < kPocketY + kPocketNY * kPocketDY &&
x >= kPocketX && x < kPocketX + kPocketNX * kPocketDX) {
int n = ((y - kPocketY) / kPocketDY) * kPocketNX + (x - kPocketX) / kPocketDX;
@@ -856,12 +849,12 @@ void System::touch(uint16 mask, int x, int y) {
_vm->postMiniStep(cav - 1);
- if (mask & L_UP) {
+ if (mask & kMouseLeftUp) {
if (cav && _snail->idle() && _hero->_tracePtr < 0)
_vm->switchCave(cav);
if (!_horzLine->_flags._hide) {
- if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) {
+ if (y >= kMapTop && y < kMapTop + kMapHig) {
int8 x1, z1;
XZ(x, y).split(x1, z1);
Cluster::_map[z1][x1] = 1;
@@ -869,7 +862,7 @@ void System::touch(uint16 mask, int x, int y) {
}
} else {
if (!_talk && _snail->idle() && _hero
- && y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_vm->_game) {
+ && y >= kMapTop && y < kMapTop + kMapHig && !_vm->_game) {
_hero->findWay(XZ(x, y));
}
}
@@ -883,10 +876,10 @@ void System::tick() {
if (--_funDel == 0) {
killText();
if (_snail->idle()) {
- if (PAIN)
+ if (_vm->_flag[0]) // Pain flag
_vm->heroCover(9);
else { // CHECKME: Before, was: if (Startup::_core >= CORE_MID) {
- int n = new_random(100);
+ int n = newRandom(100);
if (n > 96)
_vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < kScrWidth / 2));
else {
@@ -917,7 +910,7 @@ void CGEEngine::switchColorMode() {
void CGEEngine::switchMusic() {
debugC(1, kCGEDebugEngine, "CGEEngine::switchMusic()");
- if (_keyboard->_key[ALT]) {
+ if (_keyboard->_key[kKeyAlt]) {
if (Vmenu::_addr)
_snail_->addCom(kSnKill, -1, 0, Vmenu::_addr);
else {
@@ -964,9 +957,9 @@ void CGEEngine::switchMapping() {
if (_horzLine->_flags._hide) {
int i;
- for (i = 0; i < MAP_ZCNT; i++) {
+ for (i = 0; i < kMapZCnt; i++) {
int j;
- for (j = 0; j < MAP_XCNT; j++) {
+ for (j = 0; j < kMapXCnt; j++) {
if (Cluster::_map[i][j])
setMapBrick(j, i);
}
@@ -974,7 +967,7 @@ void CGEEngine::switchMapping() {
} else {
Sprite *s;
for (s = _vga->_showQ->first(); s; s = s->_next)
- if (s->_w == MAP_XGRID && s->_h == MAP_ZGRID)
+ if (s->_w == kMapGridX && s->_h == kMapGridZ)
_snail_->addCom(kSnKill, -1, 0, s);
}
_horzLine->_flags._hide = !_horzLine->_flags._hide;
@@ -1043,42 +1036,42 @@ void CGEEngine::saveMapping() {
}
}
+
+void CGEEngine::sayDebug() {
// 1111111111222222222233333333334444444444555555555566666666667777777777
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789
-static char DebugText[] = " X=000 Y=000 S=00:00 000:000:000 000:000 00";
-
-#define ABSX (DebugText + 3)
-#define ABSY (DebugText + 9)
-#define SP_N (DebugText + 15)
-#define SP_S (DebugText + 18)
-#define SP_X (DebugText + 21)
-#define SP_Y (DebugText + 25)
-#define SP_Z (DebugText + 29)
-#define SP_W (DebugText + 33)
-#define SP_H (DebugText + 37)
-#define SP_F (DebugText + 41)
+ static char DebugText[] = " X=000 Y=000 S=00:00 000:000:000 000:000 00";
+
+ char *absX = DebugText + 3;
+ char *absY = DebugText + 9;
+ char *spN = DebugText + 15;
+ char *spS = DebugText + 18;
+ char *spX = DebugText + 21;
+ char *spY = DebugText + 25;
+ char *spZ = DebugText + 29;
+ char *spW = DebugText + 33;
+ char *spH = DebugText + 37;
+ char *spF = DebugText + 41;
-void CGEEngine::sayDebug() {
if (!_debugLine->_flags._hide) {
- dwtom(_mouse->_x, ABSX, 10, 3);
- dwtom(_mouse->_y, ABSY, 10, 3);
+ dwtom(_mouse->_x, absX, 10, 3);
+ dwtom(_mouse->_y, absY, 10, 3);
// sprite queue size
uint16 n = 0;
- Sprite *spr;
- for (spr = _vga->_showQ->first(); spr; spr = spr->_next) {
+ for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) {
n++;
if (spr == _sprite) {
- dwtom(n, SP_N, 10, 2);
- dwtom(_sprite->_x, SP_X, 10, 3);
- dwtom(_sprite->_y, SP_Y, 10, 3);
- dwtom(_sprite->_z, SP_Z, 10, 3);
- dwtom(_sprite->_w, SP_W, 10, 3);
- dwtom(_sprite->_h, SP_H, 10, 3);
- dwtom(*(uint16 *)(&_sprite->_flags), SP_F, 16, 2);
+ dwtom(n, spN, 10, 2);
+ dwtom(_sprite->_x, spX, 10, 3);
+ dwtom(_sprite->_y, spY, 10, 3);
+ dwtom(_sprite->_z, spZ, 10, 3);
+ dwtom(_sprite->_w, spW, 10, 3);
+ dwtom(_sprite->_h, spH, 10, 3);
+ dwtom(*(uint16 *)(&_sprite->_flags), spF, 16, 2);
}
}
- dwtom(n, SP_S, 10, 2);
+ dwtom(n, spS, 10, 2);
_debugLine->update(DebugText);
}
}
@@ -1092,20 +1085,20 @@ void CGEEngine::switchDebug() {
void CGEEngine::optionTouch(int opt, uint16 mask) {
switch (opt) {
case 1 :
- if (mask & L_UP)
+ if (mask & kMouseLeftUp)
switchColorMode();
break;
case 2 :
- if (mask & L_UP)
+ if (mask & kMouseLeftUp)
switchMusic();
- else if (mask & R_UP)
+ else if (mask & kMouseRightUp)
if (!Mixer::_appear) {
Mixer::_appear = true;
new Mixer(this, kButtonX, kButtonY);
}
break;
case 3 :
- if (mask & L_UP)
+ if (mask & kMouseLeftUp)
quit();
break;
}
@@ -1115,9 +1108,9 @@ void CGEEngine::optionTouch(int opt, uint16 mask) {
#pragma argsused
void Sprite::touch(uint16 mask, int x, int y) {
_sys->funTouch();
- if ((mask & ATTN) == 0) {
+ if ((mask & kEventAttn) == 0) {
_infoLine->update(name());
- if (mask & (R_DN | L_DN))
+ if (mask & (kMouseRightDown | kMouseLeftDown))
_sprite = this;
if (_ref / 10 == 12) {
_vm->optionTouch(_ref % 10, mask);
@@ -1125,11 +1118,11 @@ void Sprite::touch(uint16 mask, int x, int y) {
}
if (_flags._syst)
return; // cannot access system sprites
- if (_vm->_game) if (mask & L_UP) {
- mask &= ~L_UP;
- mask |= R_UP;
+ if (_vm->_game) if (mask & kMouseLeftUp) {
+ mask &= ~kMouseLeftUp;
+ mask |= kMouseRightUp;
}
- if ((mask & R_UP) && _snail->idle()) {
+ if ((mask & kMouseRightUp) && _snail->idle()) {
Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL;
if (ps) {
if (_flags._kept || _hero->distance(this) < kDistMax) {
@@ -1142,7 +1135,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
_vm->tooFar();
} else {
if (_flags._kept)
- mask |= L_UP;
+ mask |= kMouseLeftUp;
else {
if (_hero->distance(this) < kDistMax) {
///
@@ -1169,7 +1162,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
}
}
}
- if ((mask & L_UP) && _snail->idle()) {
+ if ((mask & kMouseLeftUp) && _snail->idle()) {
if (_flags._kept) {
int n;
for (n = 0; n < kPocketNX; n++) {
@@ -1398,9 +1391,6 @@ void CGEEngine::loadScript(const char *fname) {
error("Bad INI line %d [%s]", lcnt, fname);
}
-#define GAME_FRAME_DELAY (1000 / 50)
-#define GAME_TICK_DELAY (1000 / 62)
-
void CGEEngine::mainLoop() {
sayDebug();
@@ -1431,11 +1421,11 @@ void CGEEngine::mainLoop() {
void CGEEngine::handleFrame() {
// Game frame delay
uint32 millis = g_system->getMillis();
- while (!_eventManager->_quitFlag && (millis < (_lastFrame + GAME_FRAME_DELAY))) {
+ while (!_eventManager->_quitFlag && (millis < (_lastFrame + kGameFrameDelay))) {
// Handle any pending events
_eventManager->poll();
- if (millis >= (_lastTick + GAME_TICK_DELAY)) {
+ if (millis >= (_lastTick + kGameTickDelay)) {
// Dispatch the tick to any active objects
tick();
_lastTick = millis;
@@ -1447,7 +1437,7 @@ void CGEEngine::handleFrame() {
}
_lastFrame = millis;
- if (millis >= (_lastTick + GAME_TICK_DELAY)) {
+ if (millis >= (_lastTick + kGameTickDelay)) {
// Dispatch the tick to any active objects
tick();
_lastTick = millis;
@@ -1526,7 +1516,7 @@ void CGEEngine::runGame() {
killMidi();
if (_mini && INI_FILE::exist("MINI.SPR")) {
- _miniShp = new BMP_PTR[2];
+ _miniShp = new BitmapPtr[2];
_miniShp[0] = _miniShp[1] = NULL;
uint8 *ptr = (uint8 *) &*_mini;
@@ -1568,7 +1558,7 @@ void CGEEngine::runGame() {
_debugLine->_z = 126;
_vga->_showQ->insert(_debugLine);
- _horzLine->_y = MAP_TOP - (MAP_TOP > 0);
+ _horzLine->_y = kMapTop - (kMapTop > 0);
_horzLine->_z = 126;
_vga->_showQ->insert(_horzLine);
@@ -1579,8 +1569,8 @@ void CGEEngine::runGame() {
_startupMode = 0;
_snail->addCom(kSnLevel, -1, _oldLev, &_cavLight);
- _cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
- CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
+ _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX,
+ kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY);
caveUp();
_keyboard->setClient(_sys);
@@ -1630,11 +1620,11 @@ bool CGEEngine::showTitle(const char *name) {
return false;
Bitmap::_pal = Vga::_sysPal;
- BMP_PTR *LB = new BMP_PTR[2];
+ BitmapPtr *LB = new BitmapPtr[2];
LB[0] = new Bitmap(name, true);
LB[1] = NULL;
Bitmap::_pal = NULL;
- bool usr_ok = false;
+ bool userOk = false;
Sprite D(this, LB);
D._flags._kill = true;
@@ -1643,7 +1633,7 @@ bool CGEEngine::showTitle(const char *name) {
D.show(2);
if (_mode == 2) {
- inf(SVG0NAME);
+ inf(kSavegame0Name);
_talk->show(2);
}
@@ -1675,7 +1665,7 @@ bool CGEEngine::showTitle(const char *name) {
if (_mode < 2) {
if (_isDemo) {
strcpy(_usrFnam, progName(kSvgExt));
- usr_ok = true;
+ userOk = true;
} else {
#ifndef EVA
// At this point the game originally set the protection variables
@@ -1689,15 +1679,15 @@ bool CGEEngine::showTitle(const char *name) {
// For ScummVM, skip prompting for name if a savegame in slot 0 already exists
if ((_startGameSlot == -1) && savegameExists(0)) {
strcpy(_usrFnam, "User");
- usr_ok = true;
+ userOk = true;
} else {
for (takeName(); GetText::_ptr;) {
mainLoop();
if (_eventManager->_quitFlag)
return false;
}
- if (_keyboard->last() == Enter && *_usrFnam)
- usr_ok = true;
+ if (_keyboard->lastKey() == Enter && *_usrFnam)
+ userOk = true;
}
//Mouse.Off();
_vga->_showQ->clear();
@@ -1705,7 +1695,7 @@ bool CGEEngine::showTitle(const char *name) {
#endif
}
- if (usr_ok && _mode == 0) {
+ if (userOk && _mode == 0) {
if (savegameExists(0)) {
// Load the savegame
loadGame(0, NULL, true); // only system vars
@@ -1728,19 +1718,19 @@ bool CGEEngine::showTitle(const char *name) {
if (_isDemo)
return true;
else
- return (_mode == 2 || usr_ok);
+ return (_mode == 2 || userOk);
}
void CGEEngine::cge_main() {
- uint16 intStack[STACK_SIZ / 2];
+ uint16 intStack[kStackSize / 2];
_intStackPtr = intStack;
memset(_barriers, 0xFF, sizeof(_barriers));
if (!_mouse->_exist)
- error("%s", _text->getText(NO_MOUSE_TEXT));
+ error("%s", _text->getText(kTextNoMouse));
- if (!SVG0FILE::exist(SVG0NAME))
+ if (!kSavegame0File::exist(kSavegame0Name))
_mode = 2;
_debugLine->_flags._hide = true;
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index e3d8d40846..293943d358 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -34,13 +34,11 @@
#include "cge/sound.h"
namespace CGE {
-#define CAVE_X 4
-#define CAVE_Y 166
-#define CAVE_SX 0
-#define CAVE_SY 0
-
-#define PAIN (_vm->_flag[0])
+#define kCaveX 4
+#define kCaveY 166
+#define kCaveSX 0
+#define kCaveSY 0
#define kInfoX 177
#define kInfoY 164
#define kInfoW 140
@@ -85,6 +83,15 @@ namespace CGE {
#define kScrWidth 320
#define kScrHeight 200
#define kWorldHeight (kScrHeight - kPanHeight)
+#define kStackSize 2048
+#define kSavegameCheckSum (1956 + _now + _oldLev + _game + _music + _demoText)
+#define kSavegame0Name ("{{INIT}}" kSvgExt)
+#define kSavegame0File INI_FILE
+#define kSavegameStrSize 11
+#define kGameFrameDelay (1000 / 50)
+#define kGameTickDelay (1000 / 62)
+
+
class System : public Sprite {
int _lum;
diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp
index fbe3bc6076..7eb147d697 100644
--- a/engines/cge/detection.cpp
+++ b/engines/cge/detection.cpp
@@ -165,10 +165,10 @@ SaveStateList CGEMetaEngine::listSaves(const char *target) const {
CGE::SavegameHeader header;
// Check to see if it's a ScummVM savegame or not
- char buffer[SAVEGAME_STR_SIZE + 1];
- file->read(buffer, SAVEGAME_STR_SIZE + 1);
+ char buffer[kSavegameStrSize + 1];
+ file->read(buffer, kSavegameStrSize + 1);
- if (!strncmp(buffer, CGE::SAVEGAME_STR, SAVEGAME_STR_SIZE + 1)) {
+ if (!strncmp(buffer, CGE::savegameStr, kSavegameStrSize + 1)) {
// Valid savegame
if (CGE::CGEEngine::readSavegameHeader(file, header)) {
saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
@@ -195,10 +195,10 @@ SaveStateDescriptor CGEMetaEngine::querySaveMetaInfos(const char *target, int sl
CGE::SavegameHeader header;
// Check to see if it's a ScummVM savegame or not
- char buffer[SAVEGAME_STR_SIZE + 1];
- f->read(buffer, SAVEGAME_STR_SIZE + 1);
+ char buffer[kSavegameStrSize + 1];
+ f->read(buffer, kSavegameStrSize + 1);
- bool hasHeader = !strncmp(buffer, CGE::SAVEGAME_STR, SAVEGAME_STR_SIZE + 1) &&
+ bool hasHeader = !strncmp(buffer, CGE::savegameStr, kSavegameStrSize + 1) &&
CGE::CGEEngine::readSavegameHeader(f, header);
delete f;
diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp
index dc6e65722d..50544255a8 100644
--- a/engines/cge/events.cpp
+++ b/engines/cge/events.cpp
@@ -33,10 +33,6 @@
namespace CGE {
-CGEEvent Evt[EVT_MAX];
-
-uint16 EvtHead = 0, EvtTail = 0;
-
/*----------------- KEYBOARD interface -----------------*/
const uint16 Keyboard::_code[0x60] = {
@@ -85,8 +81,7 @@ const uint16 Keyboard::_scummVmCodes[0x60] = {
0
};
-Keyboard::Keyboard() {
- _client = NULL;
+Keyboard::Keyboard() : _client(NULL) {
Common::set_to(&_key[0], &_key[0x60], false);
_current = 0;
}
@@ -99,9 +94,14 @@ Sprite *Keyboard::setClient(Sprite *spr) {
return spr;
}
-bool Keyboard::getKey(uint16 keycode, int &cgeCode) {
+bool Keyboard::getKey(Common::Event &event, int &cgeCode) {
+ Common::KeyCode keycode = event.kbd.keycode;
if ((keycode == Common::KEYCODE_LCTRL) || (keycode == Common::KEYCODE_RCTRL)) {
- cgeCode = 29;
+ cgeCode = kKeyCtrl;
+ return true;
+ }
+ if ((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) {
+ cgeCode = kKeyAlt;
return true;
}
if (keycode == Common::KEYCODE_KP_ENTER) {
@@ -110,8 +110,8 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) {
}
// Scan through the ScummVM mapping list
- for (int idx = 0; idx < 0x60; ++idx) {
- if (_scummVmCodes[idx] == keycode) {
+ for (int idx = 0; idx < 0x60; idx++) {
+ if (_scummVmCodes[idx] == event.kbd.ascii) {
cgeCode = idx;
return true;
}
@@ -122,7 +122,7 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) {
void Keyboard::newKeyboard(Common::Event &event) {
int keycode;
- if (!getKey(event.kbd.keycode, keycode))
+ if (!getKey(event, keycode))
return;
if (event.type == Common::EVENT_KEYUP) {
@@ -134,15 +134,20 @@ void Keyboard::newKeyboard(Common::Event &event) {
_current = Keyboard::_code[keycode];
if (_client) {
- CGEEvent &evt = Evt[EvtHead];
- EvtHead = (EvtHead + 1) % EVT_MAX;
+ CGEEvent &evt = _eventManager->getNextEvent();
evt._x = _current; // Keycode
- evt._msk = KEYB; // Event mask
- evt._ptr = _client; // Sprite pointer
+ evt._mask = kEventKeyb; // Event mask
+ evt._spritePtr = _client; // Sprite pointer
}
}
}
+uint16 Keyboard::lastKey() {
+ uint16 cur = _current;
+ _current = 0;
+ return cur;
+}
+
/*----------------- MOUSE interface -----------------*/
Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) {
@@ -163,13 +168,13 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0)
Common::copy(ms, ms + 2, seq);
setSeq(seq);
- BMP_PTR *MC = new BMP_PTR[3];
+ BitmapPtr *MC = new BitmapPtr[3];
MC[0] = new Bitmap("MOUSE", true);
MC[1] = new Bitmap("DUMMY", true);
MC[2] = NULL;
setShapeList(MC);
- gotoxy(kScrWidth/2, kScrHeight/2);
+ gotoxy(kScrWidth / 2, kScrHeight / 2);
_z = 127;
step(1);
}
@@ -180,11 +185,6 @@ Mouse::~Mouse() {
}
-//void Mouse::setFun()
-//{
-//}
-
-
void Mouse::on() {
if (_seqPtr && _exist) {
_active = true;
@@ -211,30 +211,29 @@ void Mouse::newMouse(Common::Event &event) {
if (!_active)
return;
- CGEEvent &evt = Evt[EvtHead];
- EvtHead = (EvtHead + 1) % EVT_MAX;
+ CGEEvent &evt = _eventManager->getNextEvent();
evt._x = event.mouse.x;
evt._y = event.mouse.y;
- evt._ptr = spriteAt(evt._x, evt._y);
+ evt._spritePtr = spriteAt(evt._x, evt._y);
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
- evt._msk = ROLL;
+ evt._mask = kMouseRoll;
break;
case Common::EVENT_LBUTTONDOWN:
- evt._msk = L_DN;
+ evt._mask = kMouseLeftDown;
_buttons |= 1;
break;
case Common::EVENT_LBUTTONUP:
- evt._msk = L_UP;
+ evt._mask = kMouseLeftUp;
_buttons &= ~1;
break;
case Common::EVENT_RBUTTONDOWN:
- evt._msk = R_DN;
+ evt._mask = kMouseRightDown;
_buttons |= 2;
break;
case Common::EVENT_RBUTTONUP:
- evt._msk = R_UP;
+ evt._mask = kMouseRightUp;
_buttons &= ~2;
break;
default:
@@ -246,6 +245,8 @@ void Mouse::newMouse(Common::Event &event) {
EventManager::EventManager() {
_quitFlag = false;
+ _eventQueueHead = 0;
+ _eventQueueTail = 0;
}
void EventManager::poll() {
@@ -277,27 +278,27 @@ void EventManager::poll() {
}
void EventManager::handleEvents() {
- while (EvtTail != EvtHead) {
- CGEEvent e = Evt[EvtTail];
- if (e._msk) {
- if (_mouse->_hold && e._ptr != _mouse->_hold)
- _mouse->_hold->touch(e._msk | ATTN, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y);
+ while (_eventQueueTail != _eventQueueHead) {
+ CGEEvent e = _eventQueue[_eventQueueTail];
+ if (e._mask) {
+ if (_mouse->_hold && e._spritePtr != _mouse->_hold)
+ _mouse->_hold->touch(e._mask | kEventAttn, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y);
// update mouse cursor position
- if (e._msk & ROLL)
+ if (e._mask & kMouseRoll)
_mouse->gotoxy(e._x, e._y);
// activate current touched SPRITE
- if (e._ptr) {
- if (e._msk & KEYB)
- e._ptr->touch(e._msk, e._x, e._y);
+ if (e._spritePtr) {
+ if (e._mask & kEventKeyb)
+ e._spritePtr->touch(e._mask, e._x, e._y);
else
- e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y);
+ e._spritePtr->touch(e._mask, e._x - e._spritePtr->_x, e._y - e._spritePtr->_y);
} else if (_sys)
- _sys->touch(e._msk, e._x, e._y);
+ _sys->touch(e._mask, e._x, e._y);
- if (e._msk & L_DN) {
- _mouse->_hold = e._ptr;
+ if (e._mask & kMouseLeftDown) {
+ _mouse->_hold = e._spritePtr;
if (_mouse->_hold) {
_mouse->_hold->_flags._hold = true;
@@ -308,7 +309,7 @@ void EventManager::handleEvents() {
}
}
- if (e._msk & L_UP) {
+ if (e._mask & kMouseLeftUp) {
if (_mouse->_hold) {
_mouse->_hold->_flags._hold = false;
_mouse->_hold = NULL;
@@ -317,10 +318,10 @@ void EventManager::handleEvents() {
///Touched = e.Ptr;
// discard Text if button released
- if (e._msk & (L_UP | R_UP))
+ if (e._mask & (kMouseLeftUp | kMouseRightUp))
killText();
}
- EvtTail = (EvtTail + 1) % EVT_MAX;
+ _eventQueueTail = (_eventQueueTail + 1) % kEventMax;
}
if (_mouse->_hold) {
if (_mouse->_hold->_flags._drag)
@@ -328,14 +329,20 @@ void EventManager::handleEvents() {
}
}
-void EventManager::clrEvt(Sprite *spr) {
+void EventManager::clearEvent(Sprite *spr) {
if (spr) {
uint16 e;
- for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX)
- if (Evt[e]._ptr == spr)
- Evt[e]._msk = 0;
+ for (e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % kEventMax)
+ if (_eventQueue[e]._spritePtr == spr)
+ _eventQueue[e]._mask = 0;
} else
- EvtTail = EvtHead;
+ _eventQueueTail = _eventQueueHead;
}
+CGEEvent &EventManager::getNextEvent() {
+ CGEEvent &evt = _eventQueue[_eventQueueHead];
+ _eventQueueHead = (_eventQueueHead + 1) % kEventMax;
+
+ return evt;
+}
} // End of namespace CGE
diff --git a/engines/cge/events.h b/engines/cge/events.h
index 671878f69a..124597c329 100644
--- a/engines/cge/events.h
+++ b/engines/cge/events.h
@@ -38,30 +38,33 @@ namespace CGE {
/*----------------- KEYBOARD interface -----------------*/
-#define KEYBD_INT 9
-#define LSHIFT 42
-#define RSHIFT 54
-#define CTRL 29
-#define ALT 56
-
+#define kKeyCtrl 29
+#define kKeyAlt 56
+#define kEventMax 256
+
+enum EventMask {
+ kMouseRoll = 1 << 0,
+ kMouseLeftDown = 1 << 1,
+ kMouseLeftUp = 1 << 2,
+ kMouseRightDown = 1 << 3,
+ kMouseRightUp = 1 << 4,
+ kEventAttn = 1 << 5,
+ kEventKeyb = 1 << 7
+};
class Keyboard {
private:
- bool getKey(uint16 keycode, int &cgeCode);
+ bool getKey(Common::Event &event, int &cgeCode);
+ uint16 _current;
public:
static const uint16 _code[0x60];
static const uint16 _scummVmCodes[0x60];
- uint16 _current;
Sprite *_client;
bool _key[0x60];
void newKeyboard(Common::Event &event);
- uint16 last() {
- uint16 cur = _current;
- _current = 0;
- return cur;
- }
+ uint16 lastKey();
Sprite *setClient(Sprite *spr);
Keyboard();
@@ -70,23 +73,13 @@ public:
/*----------------- MOUSE interface -----------------*/
-#define EVT_MAX 256
-#define ROLL 0x01
-#define L_DN 0x02
-#define L_UP 0x04
-#define R_DN 0x08
-#define R_UP 0x10
-#define ATTN 0x20 // 0x40
-#define KEYB 0x80
-
-
extern Talk *_talk;
struct CGEEvent {
- uint16 _msk;
+ uint16 _mask;
uint16 _x;
uint16 _y;
- Sprite *_ptr;
+ Sprite *_spritePtr;
};
@@ -114,13 +107,19 @@ private:
class EventManager {
private:
Common::Event _event;
+ CGEEvent _eventQueue[kEventMax];
+ uint16 _eventQueueHead;
+ uint16 _eventQueueTail;
+
void handleEvents();
public:
bool _quitFlag;
EventManager();
void poll();
- static void clrEvt(Sprite *spr = NULL);
+ void clearEvent(Sprite *spr);
+
+ CGEEvent &getNextEvent();
};
} // End of namespace CGE
diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp
index 4107580691..e64e4af38a 100644
--- a/engines/cge/game.cpp
+++ b/engines/cge/game.cpp
@@ -50,16 +50,16 @@ int Fly::_l = 20,
Fly::Fly(CGEEngine *vm, Bitmap **shpl)
: Sprite(vm, shpl), _tx(0), _ty(0), _vm(vm) {
- step(new_random(2));
- gotoxy(_l + new_random(_r - _l - _w), _t + new_random(_b - _t - _h));
+ step(newRandom(2));
+ gotoxy(_l + newRandom(_r - _l - _w), _t + newRandom(_b - _t - _h));
}
void Fly::tick() {
step();
if (!_flags._kept) {
- if (new_random(10) < 1) {
- _tx = new_random(3) - 1;
- _ty = new_random(3) - 1;
+ if (newRandom(10) < 1) {
+ _tx = newRandom(3) - 1;
+ _ty = newRandom(3) - 1;
}
if (_x + _tx < _l || _x + _tx + _w > _r)
_tx = -_tx;
diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp
index 1947fc6061..b9c10a7029 100644
--- a/engines/cge/general.cpp
+++ b/engines/cge/general.cpp
@@ -110,8 +110,8 @@ const char *progName(const char *ext) {
return buf;
}
-char *mergeExt(char *buf, const char *nam, const char *ext) {
- strcpy(buf, nam);
+char *mergeExt(char *buf, const char *name, const char *ext) {
+ strcpy(buf, name);
char *dot = strrchr(buf, '.');
if (!dot)
strcat(buf, ext);
@@ -119,8 +119,8 @@ char *mergeExt(char *buf, const char *nam, const char *ext) {
return buf;
}
-char *forceExt(char *buf, const char *nam, const char *ext) {
- strcpy(buf, nam);
+char *forceExt(char *buf, const char *name, const char *ext) {
+ strcpy(buf, name);
char *dot = strrchr(buf, '.');
if (dot)
*dot = '\0';
@@ -204,13 +204,13 @@ char *dwtom(uint32 val, char *str, int radix, int len) {
return str;
}
-IoHand::IoHand(IOMode mode, CRYPT *crpt)
- : XFile(mode), _crypt(crpt), _seed(kCryptSeed) {
+IoHand::IoHand(IOMode mode, Crypt *crypt)
+ : XFile(mode), _crypt(crypt), _seed(kCryptSeed) {
_file = new Common::File();
}
-IoHand::IoHand(const char *name, IOMode mode, CRYPT *crpt)
- : XFile(mode), _crypt(crpt), _seed(kCryptSeed) {
+IoHand::IoHand(const char *name, IOMode mode, Crypt *crypt)
+ : XFile(mode), _crypt(crypt), _seed(kCryptSeed) {
// TODO: Check if WRI and/or UPD modes are needed, and map to a save file
assert(mode == kModeRead);
@@ -303,11 +303,11 @@ DataCk *loadWave(XFile *file) {
return NULL;
}
-int takeEnum(const char **tab, const char *txt) {
+int takeEnum(const char **tab, const char *text) {
const char **e;
- if (txt) {
+ if (text) {
for (e = tab; *e; e++) {
- if (scumm_stricmp(txt, *e) == 0) {
+ if (scumm_stricmp(text, *e) == 0) {
return e - tab;
}
}
@@ -327,12 +327,12 @@ long timer() {
return 0;
}
-int new_random(int range) {
+int newRandom(int range) {
return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1);
}
DataCk::~DataCk() {
- if (!_e && _buf)
+ if (_buf)
free(_buf);
}
} // End of namespace CGE
diff --git a/engines/cge/general.h b/engines/cge/general.h
index d55193d85c..fe34606108 100644
--- a/engines/cge/general.h
+++ b/engines/cge/general.h
@@ -47,7 +47,7 @@ struct Dac {
uint8 _b;
};
-typedef uint16 CRYPT(void *buf, uint16 siz, uint16 seed);
+typedef uint16 Crypt(void *buf, uint16 siz, uint16 seed);
template <class T>
void swap(T &A, T &B) {
@@ -92,10 +92,10 @@ class IoHand : public XFile {
protected:
Common::File *_file;
uint16 _seed;
- CRYPT *_crypt;
+ Crypt *_crypt;
public:
- IoHand(const char *name, IOMode mode = kModeRead, CRYPT crypt = NULL);
- IoHand(IOMode mode = kModeRead, CRYPT *crpt = NULL);
+ IoHand(const char *name, IOMode mode = kModeRead, Crypt crypt = NULL);
+ IoHand(IOMode mode = kModeRead, Crypt *crypt = NULL);
virtual ~IoHand();
static bool exist(const char *name);
uint16 read(void *buf, uint16 len);
@@ -105,24 +105,21 @@ public:
long seek(long pos);
};
-CRYPT XCrypt;
-CRYPT RCrypt;
+Crypt XCrypt;
+Crypt RCrypt;
uint16 atow(const char *a);
uint16 xtow(const char *x);
char *wtom(uint16 val, char *str, int radix, int len);
char *dwtom(uint32 val, char *str, int radix, int len);
-int takeEnum(const char **tab, const char *txt);
+int takeEnum(const char **tab, const char *text);
uint16 chkSum(void *m, uint16 n);
long timer();
-char *mergeExt(char *buf, const char *nam, const char *ext);
-char *forceExt(char *buf, const char *nam, const char *ext);
-int driveCD(unsigned drv);
+char *mergeExt(char *buf, const char *name, const char *ext);
+char *forceExt(char *buf, const char *name, const char *ext);
// MISSING FUNCTIONS
void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, const void *));
const char *progName(const char *ext = NULL);
-char *mergeExt(char *buf, const char *nam, const char *ext);
-char *forceExt(char *buf, const char *nam, const char *ext);
unsigned fastRand();
unsigned fastRand(unsigned s);
uint16 rCrypt(void *buf, uint16 siz, uint16 seed);
@@ -130,9 +127,9 @@ uint16 atow(const char *a);
uint16 xtow(const char *x);
char *wtom(uint16 val, char *str, int radix, int len);
char *dwtom(uint32 val, char * str, int radix, int len);
-int takeEnum(const char **tab, const char *txt);
+int takeEnum(const char **tab, const char *text);
long timer();
-int new_random(int range);
+int newRandom(int range);
} // End of namespace CGE
#endif
diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp
index fa30b3a9d1..d96e494402 100644
--- a/engines/cge/gettext.cpp
+++ b/engines/cge/gettext.cpp
@@ -41,7 +41,7 @@ GetText::GetText(CGEEngine *vm, const char *info, char *text, int size)
_ptr = this;
_mode = kTBRect;
- _ts = new BMP_PTR[2];
+ _ts = new BitmapPtr[2];
_ts[0] = box((i + 3) & ~3, 2 * kTextVMargin + 2 * kFontHigh + kTextLineSpace);
_ts[1] = NULL;
setShapeList(_ts);
@@ -77,7 +77,7 @@ void GetText::touch(uint16 mask, int x, int y) {
static char bezo[] = "ACELNOSXZ";
char *p;
- if (mask & KEYB) {
+ if (mask & kEventKeyb) {
_vm->keyClick();
switch (x) {
case Enter :
@@ -103,7 +103,7 @@ void GetText::touch(uint16 mask, int x, int y) {
if (_oldKeybClient)
_oldKeybClient->touch(mask, x, y);
} else {
- if (_keyboard->_key[ALT]) {
+ if (_keyboard->_key[kKeyAlt]) {
p = strchr(bezo, x);
if (p)
x = ogon[p - bezo];
diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h
index 4540c1d8e5..128a92f594 100644
--- a/engines/cge/jbw.h
+++ b/engines/cge/jbw.h
@@ -33,7 +33,6 @@
namespace CGE {
// Defines found in cge.mak
-#define VOL
#define INI_FILE VFile // Or is it CFile?
#define PIC_FILE VFile
#define BMP_MODE 0
diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp
index decc516ae3..ba24f832c3 100644
--- a/engines/cge/mixer.cpp
+++ b/engines/cge/mixer.cpp
@@ -107,7 +107,7 @@ Mixer::~Mixer() {
void Mixer::touch(uint16 mask, int x, int y) {
Sprite::touch(mask, x, y);
- if (mask & L_UP) {
+ if (mask & kMouseLeftUp) {
warning("STUB: Mixer::touch(): Digital Volume");
/* uint8 *vol = (&_sndDrvInfo.Vol2._d) + (x < _w / 2);
if (y < kMixButtonHigh) {
@@ -129,7 +129,7 @@ void Mixer::tick() {
if (spriteAt(x, y) == this) {
_fall = kMixFall;
if (_flags._hold)
- touch(L_UP, x - _x, y - _y);
+ touch(kMouseLeftUp, x - _x, y - _y);
} else {
if (_fall)
_fall--;
diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h
index d97a4f3dd3..10c05e7cfb 100644
--- a/engines/cge/mixer.h
+++ b/engines/cge/mixer.h
@@ -40,8 +40,8 @@ namespace CGE {
#define kMixName 105 // sprite name
class Mixer : public Sprite {
- BMP_PTR _mb[2];
- BMP_PTR _lb[kMixMax + 1];
+ BitmapPtr _mb[2];
+ BitmapPtr _lb[kMixMax + 1];
Sprite *_led[2];
int _fall;
void update();
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index 2cd38d671f..2d4c28c0ab 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -36,15 +36,6 @@
namespace CGE {
-extern Sprite *_pocLight;
-
-//-------------------------------------------------------------------------
-// SPRITE * Pocket[POCKET_NX]={ NULL, NULL, NULL, NULL,
-// NULL, NULL, NULL, NULL, };
-// int _pocPtr = 0;
-//-------------------------------------------------------------------------
-extern Sprite *_pocket[];
-
void CGEEngine::snGame(Sprite *spr, int num) {
debugC(1, kCGEDebugEngine, "CGEEngine::snGame(spr, %d)", num);
@@ -67,11 +58,11 @@ void CGEEngine::snGame(Sprite *spr, int num) {
}
if (_game) { // continue game
- int i = new_random(3), hand = (dup[0]->_shpCnt == 6);
+ int i = newRandom(3), hand = (dup[0]->_shpCnt == 6);
Stage++;
if (hand && Stage > kDressed)
++hand;
- if (i >= 0 || (dup[i] == spr && new_random(3) == 0)) {
+ if (i >= 0 || (dup[i] == spr && newRandom(3) == 0)) {
_snail->addCom(kSnSeq, -1, 3, dup[0]); // yes
_snail->addCom(kSnSeq, -1, 3, dup[1]); // yes
_snail->addCom(kSnSeq, -1, 3, dup[2]); // yes
@@ -149,11 +140,11 @@ void CGEEngine::snGame(Sprite *spr, int num) {
_snail->addCom(kSnGame, 20002, 2, NULL);
_game = true;
} else { // cont
- _sprK1->step(new_random(6));
- _sprK2->step(new_random(6));
- _sprK3->step(new_random(6));
+ _sprK1->step(newRandom(6));
+ _sprK2->step(newRandom(6));
+ _sprK3->step(newRandom(6));
///--------------------
- if (spr->_ref == 1 && _keyboard->_key[ALT]) {
+ if (spr->_ref == 1 && _keyboard->_key[kKeyAlt]) {
_sprK1->step(5);
_sprK2->step(5);
_sprK3->step(5);
@@ -179,7 +170,7 @@ void CGEEngine::snGame(Sprite *spr, int num) {
_game = false;
return;
} else
- _sprK3->step(new_random(5));
+ _sprK3->step(newRandom(5));
}
if (_gameCase2Cpt < 100) {
switch (_gameCase2Cpt) {
@@ -390,7 +381,7 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) {
}
}
-const char *Snail::_comTxt[] = {
+const char *Snail::_comText[] = {
"LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE",
"SAY", "INF", "TIME", "CAVE", "KILL",
"RSEQ", "SEQ", "SEND", "SWAP", "KEEP",
@@ -771,7 +762,7 @@ void CGEEngine::snKill(Sprite *spr) {
Sprite *nx = spr->_next;
hide1(spr);
_vga->_showQ->remove(spr);
- EventManager::clrEvt(spr);
+ _eventManager->clearEvent(spr);
if (spr->_flags._kill)
delete spr;
else {
@@ -871,10 +862,10 @@ void CGEEngine::snFlash(bool on) {
debugC(1, kCGEDebugEngine, "CGEEngine::snFlash(%s)", on ? "true" : "false");
if (on) {
- Dac *pal = (Dac *) malloc(sizeof(Dac) * PAL_CNT);
+ Dac *pal = (Dac *) malloc(sizeof(Dac) * kPalCount);
if (pal) {
- memcpy(pal, Vga::_sysPal, PAL_SIZ);
- for (int i = 0; i < PAL_CNT; i++) {
+ memcpy(pal, Vga::_sysPal, kPalSize);
+ for (int i = 0; i < kPalCount; i++) {
register int c;
c = pal[i]._r << 1;
pal[i]._r = (c < 64) ? c : 63;
diff --git a/engines/cge/snail.h b/engines/cge/snail.h
index 2b488cd5b2..2d12963f2c 100644
--- a/engines/cge/snail.h
+++ b/engines/cge/snail.h
@@ -67,7 +67,7 @@ public:
bool _busy;
bool _textDelay;
uint32 _timerExpiry;
- static const char *_comTxt[];
+ static const char *_comText[];
bool _talkEnable;
Snail(CGEEngine *vm, bool turbo);
~Snail();
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 4a2df79f24..db44536267 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -73,25 +73,12 @@ uint16 Font::width(const char *text) {
return w;
}
-
-/*
-void Font::save() {
- CFILE f((const char *) _path, WRI);
- if (!f._error) {
- f.Write(_wid, WID_SIZ);
- if (!f._error)
- f.Write(_map, _pos[POS_SIZ - 1] + _wid[WID_SIZ - 1]);
- }
-}
-*/
-
-
-Talk::Talk(CGEEngine *vm, const char *tx, TextBoxStyle mode)
+Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode)
: Sprite(vm, NULL), _mode(mode), _vm(vm) {
_ts = NULL;
_flags._syst = true;
- update(tx);
+ update(text);
}
@@ -101,18 +88,6 @@ Talk::Talk(CGEEngine *vm)
_flags._syst = true;
}
-
-/*
-Talk::~Talk() {
- for (uint16 i = 0; i < ShpCnt; i++) {
- if (FP_SEG(_shpList[i]) != _DS) { // small model: always false
- delete _shpList[i];
- ShpList[i] = NULL;
- }
- }
-}
-*/
-
Font *Talk::_font;
void Talk::init() {
@@ -124,17 +99,18 @@ void Talk::deinit() {
}
-void Talk::update(const char *tx) {
+void Talk::update(const char *text) {
uint16 vmarg = (_mode) ? kTextVMargin : 0;
uint16 hmarg = (_mode) ? kTextHMargin : 0;
- uint16 mw = 0, mh, ln = vmarg;
+ uint16 mw = 0;
+ uint16 ln = vmarg;
const char *p;
uint8 *m;
if (!_ts) {
uint16 k = 2 * hmarg;
- mh = 2 * vmarg + kFontHigh;
- for (p = tx; *p; p++) {
+ uint16 mh = 2 * vmarg + kFontHigh;
+ for (p = text; *p; p++) {
if (*p == '|' || *p == '\n') {
mh += kFontHigh + kTextLineSpace;
if (k > mw)
@@ -146,19 +122,19 @@ void Talk::update(const char *tx) {
if (k > mw)
mw = k;
- _ts = new BMP_PTR[2];
+ _ts = new BitmapPtr[2];
_ts[0] = box(mw, mh);
_ts[1] = NULL;
}
m = _ts[0]->_m + ln * mw + hmarg;
- while (* tx) {
- if (*tx == '|' || *tx == '\n')
+ while (*text) {
+ if (*text == '|' || *text == '\n')
m = _ts[0]->_m + (ln += kFontHigh + kTextLineSpace) * mw + hmarg;
else {
- int cw = _font->_wid[(unsigned char)*tx], i;
- uint8 *f = _font->_map + _font->_pos[(unsigned char)*tx];
+ int cw = _font->_wid[(unsigned char)*text], i;
+ uint8 *f = _font->_map + _font->_pos[(unsigned char)*text];
for (i = 0; i < cw; i++) {
uint8 *pp = m;
uint16 n;
@@ -172,7 +148,7 @@ void Talk::update(const char *tx) {
m++;
}
}
- tx++;
+ text++;
}
_ts[0]->code();
setShapeList(_ts);
@@ -239,7 +215,7 @@ void Talk::putLine(int line, const char *text) {
// clear whole rectangle
assert((rsiz % lsiz) == 0);
- for (int planeCtr = 0; planeCtr < 4; ++planeCtr, p += psiz) {
+ for (int planeCtr = 0; planeCtr < 4; planeCtr++, p += psiz) {
for (byte *pDest = p; pDest < (p + (rsiz - lsiz)); pDest += lsiz)
Common::copy(p - lsiz, p, pDest);
}
@@ -273,9 +249,9 @@ void Talk::putLine(int line, const char *text) {
}
-InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldTxt(NULL), _vm(vm) {
+InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm) {
if (!_ts) {
- _ts = new BMP_PTR[2];
+ _ts = new BitmapPtr[2];
_ts[1] = NULL;
}
@@ -284,8 +260,8 @@ InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldTxt(NULL), _vm(vm) {
}
-void InfoLine::update(const char *tx) {
- if (tx != _oldTxt) {
+void InfoLine::update(const char *text) {
+ if (text != _oldText) {
uint16 w = _ts[0]->_w;
uint16 h = _ts[0]->_h;
uint8 *v = (uint8 *) _ts[0]->_v;
@@ -306,12 +282,12 @@ void InfoLine::update(const char *tx) {
}
// paint text line
- if (tx) {
+ if (text) {
uint8 *p = v + 2, * q = p + size;
- while (*tx) {
- uint16 cw = _font->_wid[(unsigned char)*tx];
- uint8 *fp = _font->_map + _font->_pos[(unsigned char)*tx];
+ while (*text) {
+ uint16 cw = _font->_wid[(unsigned char)*text];
+ uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text];
for (uint16 i = 0; i < cw; i++) {
register uint16 b = fp[i];
@@ -324,10 +300,10 @@ void InfoLine::update(const char *tx) {
if (p >= q)
p = p - size + 1;
}
- tx++;
+ text++;
}
}
- _oldTxt = tx;
+ _oldText = text;
}
}
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index d9c29261f6..71db57c887 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -66,10 +66,10 @@ public:
class Talk : public Sprite {
protected:
TextBoxStyle _mode;
- BMP_PTR *_ts;
+ BitmapPtr *_ts;
Bitmap *box(uint16 w, uint16 h);
public:
- Talk(CGEEngine *vm, const char *tx, TextBoxStyle mode);
+ Talk(CGEEngine *vm, const char *text, TextBoxStyle mode);
Talk(CGEEngine *vm);
//~TALK();
@@ -77,7 +77,7 @@ public:
static void init();
static void deinit();
- virtual void update(const char *tx);
+ virtual void update(const char *text);
virtual void update() {}
void putLine(int line, const char *text);
private:
@@ -85,10 +85,10 @@ private:
};
class InfoLine : public Talk {
- const char *_oldTxt;
+ const char *_oldText;
public:
InfoLine(CGEEngine *vm, uint16 wid);
- void update(const char *tx);
+ void update(const char *text);
private:
CGEEngine *_vm;
};
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index f688546810..699bd5bcc1 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -40,13 +40,13 @@ Talk *_talk = NULL;
Text::Text(CGEEngine *vm, const char *fname, int size) : _vm(vm) {
_cache = new Han[size];
- mergeExt(_fileName, fname, SAY_EXT);
+ mergeExt(_fileName, fname, kSayExt);
if (!INI_FILE::exist(_fileName))
error("No talk (%s)\n", _fileName);
for (_size = 0; _size < size; _size++) {
_cache[_size]._ref = 0;
- _cache[_size]._txt = NULL;
+ _cache[_size]._text = NULL;
}
}
@@ -62,8 +62,8 @@ void Text::clear(int from, int upto) {
for (p = _cache, q = p + _size; p < q; p++) {
if (p->_ref && p->_ref >= from && p->_ref < upto) {
p->_ref = 0;
- delete[] p->_txt;
- p->_txt = NULL;
+ delete[] p->_text;
+ p->_text = NULL;
}
}
}
@@ -105,8 +105,8 @@ void Text::preload(int from, int upto) {
p = &_cache[find(ref)];
if (p < CacheLim) {
- delete[] p->_txt;
- p->_txt = NULL;
+ delete[] p->_text;
+ p->_text = NULL;
} else
p = &_cache[find(0)];
if (p >= CacheLim)
@@ -114,10 +114,10 @@ void Text::preload(int from, int upto) {
s += strlen(s);
if (s < line + n)
++s;
- if ((p->_txt = new char[strlen(s) + 1]) == NULL)
+ if ((p->_text = new char[strlen(s) + 1]) == NULL)
break;
p->_ref = ref;
- strcpy(p->_txt, s);
+ strcpy(p->_text, s);
}
}
}
@@ -151,9 +151,9 @@ char *Text::load(int idx, int ref) {
if (s < line + n)
++s;
p->_ref = ref;
- if ((p->_txt = new char[strlen(s) + 1]) == NULL)
+ if ((p->_text = new char[strlen(s) + 1]) == NULL)
return NULL;
- return strcpy(p->_txt, s);
+ return strcpy(p->_text, s);
}
}
return NULL;
@@ -163,10 +163,10 @@ char *Text::load(int idx, int ref) {
char *Text::getText(int ref) {
int i;
if ((i = find(ref)) < _size)
- return _cache[i]._txt;
+ return _cache[i]._text;
if ((i = find(0)) >= _size) {
- clear(SYSTXT_MAX); // clear non-system
+ clear(kSysTextMax); // clear non-system
if ((i = find(0)) >= _size) {
clear(); // clear all
i = 0;
@@ -176,9 +176,9 @@ char *Text::getText(int ref) {
}
-void Text::say(const char *txt, Sprite *spr) {
+void Text::say(const char *text, Sprite *spr) {
killText();
- _talk = new Talk(_vm, txt, kTBRound);
+ _talk = new Talk(_vm, text, kTBRound);
if (_talk) {
bool east = spr->_flags._east;
int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2);
@@ -199,37 +199,37 @@ void Text::say(const char *txt, Sprite *spr) {
_talk->_flags._kill = true;
_talk->_flags._bDel = true;
- _talk->setName(_text->getText(SAY_NAME));
+ _talk->setName(_text->getText(kSayName));
_talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1);
_talk->_z = 125;
- _talk->_ref = SAY_REF;
+ _talk->_ref = kSayRef;
spike->gotoxy(x, _talk->_y + _talk->_h - 1);
spike->_z = 126;
spike->_flags._slav = true;
spike->_flags._kill = true;
- spike->setName(_text->getText(SAY_NAME));
+ spike->setName(_text->getText(kSayName));
spike->step(east);
- spike->_ref = SAY_REF;
+ spike->_ref = kSayRef;
_vga->_showQ->insert(_talk, _vga->_showQ->last());
_vga->_showQ->insert(spike, _vga->_showQ->last());
}
}
-void CGEEngine::inf(const char *txt) {
- debugC(1, kCGEDebugEngine, "CGEEngine::inf(%s)", txt);
+void CGEEngine::inf(const char *text) {
+ debugC(1, kCGEDebugEngine, "CGEEngine::inf(%s)", text);
killText();
- _talk = new Talk(this, txt, kTBRect);
+ _talk = new Talk(this, text, kTBRect);
if (_talk) {
_talk->_flags._kill = true;
_talk->_flags._bDel = true;
- _talk->setName(_text->getText(INF_NAME));
+ _talk->setName(_text->getText(kInfName));
_talk->center();
_talk->gotoxy(_talk->_x, _talk->_y - 20);
_talk->_z = 126;
- _talk->_ref = INF_REF;
+ _talk->_ref = kInfRef;
_vga->_showQ->insert(_talk, _vga->_showQ->last());
}
}
diff --git a/engines/cge/text.h b/engines/cge/text.h
index 196bfc4edb..bb905ac655 100644
--- a/engines/cge/text.h
+++ b/engines/cge/text.h
@@ -33,28 +33,21 @@
namespace CGE {
-#ifndef SYSTXT_MAX
-#define SYSTXT_MAX 1000
-#endif
+#define kSysTextMax 1000
-#define SAY_EXT ".SAY"
+#define kSayExt ".SAY"
-#define NOT_VGA_TEXT 90
-#define BAD_CHIP_TEXT 91
-#define BAD_DOS_TEXT 92
-#define NO_CORE_TEXT 93
-#define BAD_MIPS_TEXT 94
-#define NO_MOUSE_TEXT 95
-#define INF_NAME 101
-#define SAY_NAME 102
-#define INF_REF 301
-#define SAY_REF 302
+#define kTextNoMouse 95
+#define kInfName 101
+#define kSayName 102
+#define kInfRef 301
+#define kSayRef 302
class Text {
struct Han {
int _ref;
- char *_txt;
+ char *_text;
} *_cache;
int _size;
char _fileName[kPathMax];
@@ -66,7 +59,7 @@ public:
void clear(int from = 1, int upto = 0x7FFF);
void preload(int from = 1, int upto = 0x7FFF);
char *getText(int ref);
- void say(const char *txt, Sprite *spr);
+ void say(const char *text, Sprite *spr);
private:
CGEEngine *_vm;
};
@@ -74,9 +67,9 @@ private:
extern Talk *_talk;
extern Text *_text;
-void say(const char *txt, Sprite *spr);
+void say(const char *text, Sprite *spr);
void sayTime(Sprite *spr);
-void inf(const char *txt);
+void inf(const char *text);
void killText();
} // End of namespace CGE
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index 62b902b19c..de28794f3f 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -211,7 +211,7 @@ Sprite *locate(int ref) {
return (spr) ? spr : _vga->_spareQ->locate(ref);
}
-Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP)
+Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP)
: _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0),
_next(NULL), _prev(NULL), _seqPtr(NO_SEQ), _time(0), //Delay(0),
_ext(NULL), _ref(-1), _cave(0), _vm(vm) {
@@ -234,7 +234,7 @@ Sprite::~Sprite() {
}
-BMP_PTR Sprite::shp() {
+BitmapPtr Sprite::shp() {
register SprExt *e = _ext;
if (e)
if (e->_seq) {
@@ -252,17 +252,17 @@ BMP_PTR Sprite::shp() {
}
-BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) {
- BMP_PTR *r = (_ext) ? _ext->_shpList : NULL;
+BitmapPtr *Sprite::setShapeList(BitmapPtr *shpP) {
+ BitmapPtr *r = (_ext) ? _ext->_shpList : NULL;
_shpCnt = 0;
_w = 0;
_h = 0;
if (shpP) {
- BMP_PTR *p;
+ BitmapPtr *p;
for (p = shpP; *p; p++) {
- BMP_PTR b = (*p); // ->Code();
+ BitmapPtr b = (*p); // ->Code();
if (b->_w > _w)
_w = b->_w;
if (b->_h > _h)
@@ -280,7 +280,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) {
void Sprite::moveShapes(uint8 *buf) {
- BMP_PTR *p;
+ BitmapPtr *p;
for (p = _ext->_shpList; *p; p++) {
buf += (*p)->moveVmap(buf);
}
@@ -336,16 +336,16 @@ Snail::Com *Sprite::snList(SnList type) {
}
-void Sprite::setName(char *n) {
+void Sprite::setName(char *name) {
if (_ext) {
if (_ext->_name) {
delete[] _ext->_name;
_ext->_name = NULL;
}
- if (n) {
- _ext->_name = new char[strlen(n) + 1];
+ if (name) {
+ _ext->_name = new char[strlen(name) + 1];
assert(_ext->_name != NULL);
- strcpy(_ext->_name, n);
+ strcpy(_ext->_name, name);
}
}
}
@@ -358,7 +358,7 @@ Sprite *Sprite::expand() {
if (*_file) {
static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL };
char line[kLineMax], fname[kPathMax];
- BMP_PTR *shplist = new BMP_PTR[_shpCnt + 1];
+ BitmapPtr *shplist = new BitmapPtr[_shpCnt + 1];
Seq *seq = NULL;
int shpcnt = 0,
seqcnt = 0,
@@ -420,7 +420,7 @@ Sprite *Sprite::expand() {
nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea));
assert(nea != NULL);
Snail::Com *c = &nea[neacnt++];
- if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0)
+ if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0)
error("Bad NEAR in %d [%s]", lcnt, fname);
c->_ref = atoi(strtok(NULL, " \t,;/"));
c->_val = atoi(strtok(NULL, " \t,;/"));
@@ -433,7 +433,7 @@ Sprite *Sprite::expand() {
tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak));
assert(tak != NULL);
Snail::Com *c = &tak[takcnt++];
- if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0)
+ if ((c->_com = (SnCom)takeEnum(Snail::_comText, strtok(NULL, " \t,;/"))) < 0)
error("Bad NEAR in %d [%s]", lcnt, fname);
c->_ref = atoi(strtok(NULL, " \t,;/"));
c->_val = atoi(strtok(NULL, " \t,;/"));
@@ -529,7 +529,7 @@ void Sprite::tick() {
void Sprite::makeXlat(uint8 *x) {
if (_ext) {
- BMP_PTR *b;
+ BitmapPtr *b;
if (_flags._xlat)
killXlat();
@@ -542,7 +542,7 @@ void Sprite::makeXlat(uint8 *x) {
void Sprite::killXlat() {
if (_flags._xlat && _ext) {
- BMP_PTR *b;
+ BitmapPtr *b;
uint8 *m = (*_ext->_shpList)->_m;
free(m);
@@ -617,10 +617,10 @@ void Sprite::hide() {
}
-BMP_PTR Sprite::ghost() {
+BitmapPtr Sprite::ghost() {
register SprExt *e = _ext;
if (e->_b1) {
- BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL);
+ BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL);
assert(bmp != NULL);
bmp->_w = e->_b1->_w;
bmp->_h = e->_b1->_h;
@@ -786,37 +786,35 @@ Graphics::Surface *Vga::_page[4];
Dac *Vga::_sysPal;
void Vga::init() {
- for (int idx = 0; idx < 4; ++idx) {
+ for (int idx = 0; idx < 4; idx++) {
_page[idx] = new Graphics::Surface();
_page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
}
- _sysPal = new Dac[PAL_CNT];
+ _sysPal = new Dac[kPalCount];
}
void Vga::deinit() {
- for (int idx = 0; idx < 4; ++idx) {
+ for (int idx = 0; idx < 4; idx++) {
_page[idx]->free();
delete _page[idx];
}
-
delete[] _sysPal;
}
Vga::Vga(int mode)
: _frmCnt(0), _oldMode(0), _oldScreen(NULL), _statAdr(VGAST1_),
- _msg(NULL), _nam(NULL), _setPal(false), _mono(0) {
+ _msg(NULL), _name(NULL), _setPal(false), _mono(0) {
_oldColors = NULL;
_newColors = NULL;
_showQ = new Queue(true);
_spareQ = new Queue(false);
bool std = true;
- int i;
- for (i = 10; i < 20; i++) {
- char *txt = _text->getText(i);
- if (txt) {
- debugN("%s", txt);
+ for (int i = 10; i < 20; i++) {
+ char *text = _text->getText(i);
+ if (text) {
+ debugN("%s\n", text);
std = false;
}
}
@@ -827,8 +825,8 @@ Vga::Vga(int mode)
setStatAdr();
if (_statAdr != VGAST1_)
_mono++;
- _oldColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT);
- _newColors = (Dac *) malloc(sizeof(Dac) * PAL_CNT);
+ _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount);
+ _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount);
_oldScreen = SaveScreen();
getColors(_oldColors);
sunset();
@@ -854,8 +852,8 @@ Vga::~Vga() {
free(_newColors);
if (_msg)
buffer = Common::String(_msg);
- if (_nam)
- buffer = buffer + " [" + _nam + "]";
+ if (_name)
+ buffer = buffer + " [" + _name + "]";
debugN("%s", buffer.c_str());
@@ -937,14 +935,14 @@ int Vga::setMode(int mode) {
void Vga::getColors(Dac *tab) {
- byte palData[PAL_SIZ];
- g_system->getPaletteManager()->grabPalette(palData, 0, PAL_CNT);
+ byte palData[kPalSize];
+ g_system->getPaletteManager()->grabPalette(palData, 0, kPalCount);
palToDac(palData, tab);
}
void Vga::palToDac(const byte *palData, Dac *tab) {
const byte *colP = palData;
- for (int idx = 0; idx < PAL_CNT; ++idx, colP += 3) {
+ for (int idx = 0; idx < kPalCount; idx++, colP += 3) {
tab[idx]._r = *colP >> 2;
tab[idx]._g = *(colP + 1) >> 2;
tab[idx]._b = *(colP + 2) >> 2;
@@ -952,7 +950,7 @@ void Vga::palToDac(const byte *palData, Dac *tab) {
}
void Vga::dacToPal(const Dac *tab, byte *palData) {
- for (int idx = 0; idx < PAL_CNT; ++idx, palData += 3) {
+ for (int idx = 0; idx < kPalCount; idx++, palData += 3) {
*palData = tab[idx]._r << 2;
*(palData + 1) = tab[idx]._g << 2;
*(palData + 2) = tab[idx]._b << 2;
@@ -961,7 +959,7 @@ void Vga::dacToPal(const Dac *tab, byte *palData) {
void Vga::setColors(Dac *tab, int lum) {
Dac *palP = tab, *destP = _newColors;
- for (int idx = 0; idx < PAL_CNT; ++idx, ++palP, ++destP) {
+ for (int idx = 0; idx < kPalCount; idx++, palP++, destP++) {
destP->_r = (palP->_r * lum) >> 6;
destP->_g = (palP->_g * lum) >> 6;
destP->_b = (palP->_b * lum) >> 6;
@@ -969,7 +967,7 @@ void Vga::setColors(Dac *tab, int lum) {
if (_mono) {
destP = _newColors;
- for (int idx = 0; idx < PAL_CNT; ++idx, ++destP) {
+ for (int idx = 0; idx < kPalCount; idx++, destP++) {
// Form a greyscalce colour from 30% R, 59% G, 11% B
uint8 intensity = (((int)destP->_r * 77) + ((int)destP->_g * 151) + ((int)destP->_b * 28)) >> 8;
destP->_r = intensity;
@@ -983,7 +981,7 @@ void Vga::setColors(Dac *tab, int lum) {
void Vga::setColors() {
- memset(_newColors, 0, PAL_SIZ);
+ memset(_newColors, 0, kPalSize);
updateColors();
}
@@ -1022,7 +1020,7 @@ void Vga::show() {
void Vga::updateColors() {
- byte palData[PAL_SIZ];
+ byte palData[kPalSize];
dacToPal(_newColors, palData);
g_system->getPaletteManager()->setPalette(palData, 0, 256);
}
@@ -1042,7 +1040,7 @@ void Vga::update() {
void Vga::clear(uint8 color) {
- for (int paneNum = 0; paneNum < 4; ++paneNum)
+ for (int paneNum = 0; paneNum < 4; paneNum++)
_page[paneNum]->fillRect(Common::Rect(0, 0, kScrWidth, kScrHeight), color);
}
@@ -1063,7 +1061,7 @@ void Bitmap::xShow(int16 x, int16 y) {
// Loop through processing data for each plane. The game originally ran in plane mapped mode, where a
// given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data
// must be decompressed and inserted into the surface
- for (int planeCtr = 0; planeCtr < 4; ++planeCtr) {
+ for (int planeCtr = 0; planeCtr < 4; planeCtr++) {
byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y);
for (;;) {
@@ -1080,7 +1078,7 @@ void Bitmap::xShow(int16 x, int16 y) {
assert(destP < destEndP);
if (cmd == 2)
- ++srcP;
+ srcP++;
else if (cmd == 3)
srcP += count;
@@ -1115,7 +1113,7 @@ void Bitmap::show(int16 x, int16 y) {
// Loop through processing data for each plane. The game originally ran in plane mapped mode, where a
// given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data
// must be decompressed and inserted into the surface
- for (int planeCtr = 0; planeCtr < 4; ++planeCtr) {
+ for (int planeCtr = 0; planeCtr < 4; planeCtr++) {
byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y);
for (;;) {
@@ -1153,7 +1151,7 @@ void Bitmap::show(int16 x, int16 y) {
}
if (cmd == 2)
- ++srcP;
+ srcP++;
}
}
/*
@@ -1185,7 +1183,7 @@ void Bitmap::hide(int16 x, int16 y) {
HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) {
// Set the sprite list
- BMP_PTR *HL = new BMP_PTR[2];
+ BitmapPtr *HL = new BitmapPtr[2];
HL[0] = new Bitmap("HLINE", true);
HL[1] = NULL;
@@ -1194,7 +1192,7 @@ HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) {
CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) {
// Set the sprite list
- BMP_PTR *PR = new BMP_PTR[2];
+ BitmapPtr *PR = new BitmapPtr[2];
PR[0] = new Bitmap("PRESS", true);
PR[1] = NULL;
@@ -1203,7 +1201,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) {
Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) {
// Set the sprite list
- BMP_PTR *SP = new BMP_PTR[3];
+ BitmapPtr *SP = new BitmapPtr[3];
SP[0] = new Bitmap("SPK_L", true);
SP[1] = new Bitmap("SPK_R", true);
SP[2] = NULL;
@@ -1213,7 +1211,7 @@ Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) {
PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) {
// Set the sprite list
- BMP_PTR *LI = new BMP_PTR[5];
+ BitmapPtr *LI = new BitmapPtr[5];
LI[0] = new Bitmap("LITE0", true);
LI[1] = new Bitmap("LITE1", true);
LI[2] = new Bitmap("LITE2", true);
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index 15da63efbc..f72d4c693d 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -99,33 +99,32 @@ extern Seq _seq2[];
//extern SEQ * Compass[];
//extern SEQ TurnToS[];
-#define PAL_CNT 256
-#define PAL_SIZ (PAL_CNT * 3)
+#define kPalCount 256
+#define kPalSize (kPalCount * 3)
+
#define VGAATR_ 0x3C0
-#define VGAMIw_ 0x3C0
#define VGASEQ_ 0x3C4
-#define VGAMIr_ 0x3CC
#define VGAGRA_ 0x3CE
#define VGACRT_ 0x3D4
#define VGAST1_ 0x3DA
#define VGAATR (VGAATR_ & 0xFF)
-#define VGAMIw (VGAMIw_ & 0xFF)
#define VGASEQ (VGASEQ_ & 0xFF)
-#define VGAMIr (VGAMIr_ & 0xFF)
#define VGAGRA (VGAGRA_ & 0xFF)
#define VGACRT (VGACRT_ & 0xFF)
-#define VGAST1 (VGAST1_ & 0xFF)
-
class SprExt {
public:
- int _x0, _y0;
- int _x1, _y1;
- BMP_PTR _b0, _b1;
- BMP_PTR *_shpList;
+ int _x0;
+ int _y0;
+ int _x1;
+ int _y1;
+ BitmapPtr _b0;
+ BitmapPtr _b1;
+ BitmapPtr *_shpList;
Seq *_seq;
char *_name;
- Snail::Com *_near, *_take;
+ Snail::Com *_near;
+ Snail::Com *_take;
SprExt() :
_x0(0), _y0(0),
_x1(0), _y1(0),
@@ -179,15 +178,16 @@ public:
inline bool active() {
return _ext != NULL;
}
- Sprite(CGEEngine *vm, BMP_PTR *shp);
+
+ Sprite(CGEEngine *vm, BitmapPtr *shp);
virtual ~Sprite();
- BMP_PTR shp();
- BMP_PTR *setShapeList(BMP_PTR *shp);
+ BitmapPtr shp();
+ BitmapPtr *setShapeList(BitmapPtr *shp);
void moveShapes(uint8 *buf);
Sprite *expand();
Sprite *contract();
Sprite *backShow(bool fast = false);
- void setName(char *n);
+ void setName(char *name);
inline char *name() {
return (_ext) ? _ext->_name : NULL;
}
@@ -195,7 +195,7 @@ public:
void center();
void show();
void hide();
- BMP_PTR ghost();
+ BitmapPtr ghost();
void show(uint16 pg);
void makeXlat(uint8 *x);
void killXlat();
@@ -243,7 +243,7 @@ class Vga {
Dac *_oldColors;
Dac *_newColors;
const char *_msg;
- const char *_nam;
+ const char *_name;
int setMode(int mode);
void updateColors();
diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp
index 934bd6299d..48b27d9727 100644
--- a/engines/cge/vmenu.cpp
+++ b/engines/cge/vmenu.cpp
@@ -48,7 +48,7 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) {
p2 -= w;
}
- _ts = new BMP_PTR[2];
+ _ts = new BitmapPtr[2];
_ts[0] = new Bitmap(w, h, p);
_ts[1] = NULL;
setShapeList(_ts);
@@ -136,7 +136,7 @@ void Vmenu::touch(uint16 mask, int x, int y) {
_bar->gotoxy(_x + kTextHMargin - kMenuBarHM, _y + kTextVMargin + n * h - kMenuBarVM);
- if (ok && (mask & L_UP)) {
+ if (ok && (mask & kMouseLeftUp)) {
_items = 0;
_snail_->addCom(kSnKill, -1, 0, this);
_recent = n;
diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp
index e2c62513dd..a9eeb6db8e 100644
--- a/engines/cge/walk.cpp
+++ b/engines/cge/walk.cpp
@@ -32,7 +32,7 @@ namespace CGE {
Walk *_hero;
-uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT];
+uint8 Cluster::_map[kMapZCnt][kMapXCnt];
CGEEngine *Cluster::_vm;
void Cluster::init(CGEEngine *vm) {
@@ -44,22 +44,22 @@ uint8 &Cluster::cell() {
}
bool Cluster::isValid() const {
- return (_a >= 0) && (_a < MAP_XCNT) && (_b >= 0) && (_b < MAP_ZCNT);
+ return (_a >= 0) && (_a < kMapXCnt) && (_b >= 0) && (_b < kMapZCnt);
}
bool Cluster::chkBar() const {
- assert(_vm->_now <= _vm->CAVE_MAX);
+ assert(_vm->_now <= _vm->_caveMax);
return (_a == _vm->_barriers[_vm->_now]._horz) && (_b == _vm->_barriers[_vm->_now]._vert);
}
Cluster XZ(int x, int y) {
- if (y < MAP_TOP)
- y = MAP_TOP;
+ if (y < kMapTop)
+ y = kMapTop;
- if (y > MAP_TOP + MAP_HIG - MAP_ZGRID)
- y = MAP_TOP + MAP_HIG - MAP_ZGRID;
+ if (y > kMapTop + kMapHig - kMapGridZ)
+ y = kMapTop + kMapHig - kMapGridZ;
- return Cluster(x / MAP_XGRID, (y - MAP_TOP) / MAP_ZGRID);
+ return Cluster(x / kMapGridX, (y - kMapTop) / kMapGridZ);
}
@@ -69,8 +69,8 @@ Cluster XZ(Couple xy) {
return XZ(x, y);
}
-Walk::Walk(CGEEngine *vm, BMP_PTR *shpl)
- : Sprite(vm, shpl), Dir(NO_DIR), _tracePtr(-1), _level(0), _vm(vm) {
+Walk::Walk(CGEEngine *vm, BitmapPtr *shpl)
+ : Sprite(vm, shpl), _dir(kDirNone), _tracePtr(-1), _level(0), _vm(vm) {
}
@@ -80,7 +80,7 @@ void Walk::tick() {
_here = XZ(_x + _w / 2, _y + _h);
- if (Dir != NO_DIR) {
+ if (_dir != kDirNone) {
Sprite *spr;
_sys->funTouch();
for (spr = _vga->_showQ->first(); spr; spr = spr->_next) {
@@ -104,14 +104,14 @@ void Walk::tick() {
} else {
signed char dx, dz;
(_trace[_tracePtr] - _here).split(dx, dz);
- DIR d = (dx) ? ((dx > 0) ? EE : WW) : ((dz > 0) ? SS : NN);
+ Dir d = (dx) ? ((dx > 0) ? kDirEast : kDirWest) : ((dz > 0) ? kDirSouth : kDirNorth);
turn(d);
}
}
step();
- if ((Dir == WW && _x <= 0) ||
- (Dir == EE && _x + _w >= kScrWidth) ||
- (Dir == SS && _y + _w >= kWorldHeight - 2))
+ if ((_dir == kDirWest && _x <= 0) ||
+ (_dir == kDirEast && _x + _w >= kScrWidth) ||
+ (_dir == kDirSouth && _y + _w >= kWorldHeight - 2))
park();
else {
signed char x; // dummy var
@@ -130,7 +130,7 @@ int Walk::distance(Sprite *spr) {
if (dx < 0)
dx = 0;
- dx /= MAP_XGRID;
+ dx /= kMapGridX;
dz = spr->_z - _z;
if (dz < 0)
dz = - dz;
@@ -143,22 +143,22 @@ int Walk::distance(Sprite *spr) {
}
-void Walk::turn(DIR d) {
- DIR dir = (Dir == NO_DIR) ? SS : Dir;
- if (d != Dir) {
+void Walk::turn(Dir d) {
+ Dir dir = (_dir == kDirNone) ? kDirSouth : _dir;
+ if (d != _dir) {
step((d == dir) ? (1 + dir + dir) : (9 + 4 * dir + d));
- Dir = d;
+ _dir = d;
}
}
void Walk::park() {
if (_time == 0)
- ++_time;
+ _time++;
- if (Dir != NO_DIR) {
- step(9 + 4 * Dir + Dir);
- Dir = NO_DIR;
+ if (_dir != kDirNone) {
+ step(9 + 4 * _dir + _dir);
+ _dir = kDirNone;
_tracePtr = -1;
}
}
@@ -166,7 +166,7 @@ void Walk::park() {
void Walk::findWay(Cluster c) {
if (c != _here) {
- for (_findLevel = 1; _findLevel <= MAX_FIND_LEVEL; _findLevel++) {
+ for (_findLevel = 1; _findLevel <= kMaxFindLevel; _findLevel++) {
signed char x, z;
_here.split(x, z);
_target = Couple(x, z);
@@ -175,7 +175,7 @@ void Walk::findWay(Cluster c) {
if (find1Way(Cluster(x, z)))
break;
}
- _tracePtr = (_findLevel > MAX_FIND_LEVEL) ? -1 : (_findLevel - 1);
+ _tracePtr = (_findLevel > kMaxFindLevel) ? -1 : (_findLevel - 1);
if (_tracePtr < 0)
noWay();
_time = 1;
@@ -191,8 +191,8 @@ void Walk::findWay(Sprite *spr) {
x += spr->_w + _w / 2 - kWalkSide;
else
x -= _w / 2 - kWalkSide;
- findWay(Cluster((x / MAP_XGRID),
- ((z < MAP_ZCNT - kDistMax) ? (z + 1)
+ findWay(Cluster((x / kMapGridX),
+ ((z < kMapZCnt - kDistMax) ? (z + 1)
: (z - 1))));
}
}
@@ -250,7 +250,7 @@ bool Walk::find1Way(Cluster c) {
// Loop through each direction
- for (int i = 0; i < tabLen; ++i) {
+ for (int i = 0; i < tabLen; i++) {
// Reset to starting position
c = start;
diff --git a/engines/cge/walk.h b/engines/cge/walk.h
index 15ea9ee0ce..115cb4924a 100644
--- a/engines/cge/walk.h
+++ b/engines/cge/walk.h
@@ -34,13 +34,15 @@
namespace CGE {
-#define MAP_XCNT 40
-#define MAP_ZCNT 20
-#define MAP_TOP 80
-#define MAP_HIG 80
-#define MAP_XGRID (kScrWidth / MAP_XCNT)
-#define MAP_ZGRID (MAP_HIG / MAP_ZCNT)
-#define MAX_FIND_LEVEL 3
+#define kMapXCnt 40
+#define kMapZCnt 20
+#define kMapTop 80
+#define kMapHig 80
+#define kMapGridX (kScrWidth / kMapXCnt)
+#define kMapGridZ (kMapHig / kMapZCnt)
+#define kMaxFindLevel 3
+
+enum Dir { kDirNone = -1, kDirNorth, kDirEast, kDirSouth, kDirWest };
class Couple {
protected:
@@ -83,7 +85,7 @@ public:
class Cluster : public Couple {
public:
- static uint8 _map[MAP_ZCNT][MAP_XCNT];
+ static uint8 _map[kMapZCnt][kMapXCnt];
static CGEEngine *_vm;
static void init(CGEEngine *vm);
@@ -106,15 +108,15 @@ public:
int _level;
int _findLevel;
Couple _target;
- Cluster _trace[MAX_FIND_LEVEL];
+ Cluster _trace[kMaxFindLevel];
- enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir;
- Walk(CGEEngine *vm, BMP_PTR *shpl);
+ Dir _dir;
+ Walk(CGEEngine *vm, BitmapPtr *shpl);
void tick();
void findWay(Cluster c);
void findWay(Sprite *spr);
int distance(Sprite *spr);
- void turn(DIR d);
+ void turn(Dir d);
void park();
bool lower(Sprite *spr);
void reach(Sprite *spr, int mode = -1);
diff --git a/engines/cge/wav.h b/engines/cge/wav.h
index 739e102959..bd9fc96b0a 100644
--- a/engines/cge/wav.h
+++ b/engines/cge/wav.h
@@ -41,20 +41,20 @@ typedef char FourCC[4]; // Four-character code
class ChunkId { // Chunk type identifier
union {
- FourCC _tx;
+ FourCC _text;
uint32 _id;
};
protected:
static XFile *ckFile;
public:
- ChunkId(FourCC t) {
- memcpy(_tx, t, sizeof(_tx));
+ ChunkId(FourCC text) {
+ memcpy(_text, text, sizeof(_text));
}
ChunkId(uint32 d) {
_id = d;
}
ChunkId(XFile *xf) {
- (ckFile = xf)->read(_tx, sizeof(_tx));
+ (ckFile = xf)->read(_text, sizeof(_text));
}
bool operator !=(ChunkId &X) {
return _id != X._id;
@@ -116,7 +116,7 @@ public:
class DataCk : public CkHea {
- bool _e;
+ bool _ef;
uint8 *_buf;
public:
DataCk(CkHea &hea);