From 6f92cdd0d0e124653c4164c7ab0f91e5b910f6bc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 2 Aug 2011 21:47:56 +0200 Subject: CGE: Rename some more defines --- engines/cge/bitmap.cpp | 4 +- engines/cge/cge.h | 6 +- engines/cge/cge_main.cpp | 152 ++++++++++++++++++++++------------------------ engines/cge/cge_main.h | 19 ++++-- engines/cge/detection.cpp | 12 ++-- engines/cge/events.cpp | 30 ++++----- engines/cge/events.h | 22 ++++--- engines/cge/game.cpp | 10 +-- engines/cge/general.cpp | 2 +- engines/cge/general.h | 2 +- engines/cge/gettext.cpp | 2 +- engines/cge/jbw.h | 1 - engines/cge/mixer.cpp | 4 +- engines/cge/snail.cpp | 21 ++----- engines/cge/text.cpp | 12 ++-- engines/cge/text.h | 15 ++--- engines/cge/vmenu.cpp | 2 +- 17 files changed, 150 insertions(+), 166 deletions(-) (limited to 'engines') diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index ddde3bbd21..63f7c0dadf 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; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 7adc44fac6..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; diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 1198946a41..cbba280ff8 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"; //-------------------------------------------------------------------------- @@ -137,13 +130,13 @@ void CGEEngine::syncHeader(Common::Serializer &s) { 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 @@ -423,7 +416,7 @@ void CGEEngine::trouble(int seq, int text) { void CGEEngine::offUse() { debugC(1, kCGEDebugEngine, "CGEEngine::offUse()"); - trouble(kSeqOffUse, kOffUse + new_random(_offUseCount)); + trouble(kSeqOffUse, kOffUse + newRandom(_offUseCount)); } void CGEEngine::tooFar() { @@ -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); } @@ -688,8 +681,8 @@ void CGEEngine::switchCave(int cav) { if (!_isDemo) _vga->_spareQ->_show = 0; } - _cavLight->gotoxy(CAVE_X + ((_now - 1) % _caveNx) * _caveDx + CAVE_SX, - CAVE_Y + ((_now - 1) / _caveNx) * _caveDy + 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(); @@ -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->_caveNy * _vm->_caveDy && - x >= CAVE_X && x < CAVE_X + _vm->_caveNx * _vm->_caveDx && !_vm->_game) { - cav = ((y - CAVE_Y) / _vm->_caveDy) * _vm->_caveNx + (x - CAVE_X) / _vm->_caveDx + 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,7 +849,7 @@ 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); @@ -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 { @@ -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; @@ -1579,8 +1569,8 @@ void CGEEngine::runGame() { _startupMode = 0; _snail->addCom(kSnLevel, -1, _oldLev, &_cavLight); - _cavLight->gotoxy(CAVE_X + ((_now - 1) % _caveNx) * _caveDx + CAVE_SX, - CAVE_Y + ((_now - 1) / _caveNx) * _caveDy + CAVE_SY); + _cavLight->gotoxy(kCaveX + ((_now - 1) % _caveNx) * _caveDx + kCaveSX, + kCaveY + ((_now - 1) / _caveNx) * _caveDy + kCaveSY); caveUp(); _keyboard->setClient(_sys); @@ -1643,7 +1633,7 @@ bool CGEEngine::showTitle(const char *name) { D.show(2); if (_mode == 2) { - inf(SVG0NAME); + inf(kSavegame0Name); _talk->show(2); } @@ -1732,15 +1722,15 @@ bool CGEEngine::showTitle(const char *name) { } 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 24fd3d2043..3455052730 100644 --- a/engines/cge/detection.cpp +++ b/engines/cge/detection.cpp @@ -154,10 +154,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)); @@ -184,10 +184,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 113b64cee8..50544255a8 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -136,7 +136,7 @@ void Keyboard::newKeyboard(Common::Event &event) { if (_client) { CGEEvent &evt = _eventManager->getNextEvent(); evt._x = _current; // Keycode - evt._mask = KEYB; // Event mask + evt._mask = kEventKeyb; // Event mask evt._spritePtr = _client; // Sprite pointer } } @@ -218,22 +218,22 @@ void Mouse::newMouse(Common::Event &event) { switch (event.type) { case Common::EVENT_MOUSEMOVE: - evt._mask = ROLL; + evt._mask = kMouseRoll; break; case Common::EVENT_LBUTTONDOWN: - evt._mask = L_DN; + evt._mask = kMouseLeftDown; _buttons |= 1; break; case Common::EVENT_LBUTTONUP: - evt._mask = L_UP; + evt._mask = kMouseLeftUp; _buttons &= ~1; break; case Common::EVENT_RBUTTONDOWN: - evt._mask = R_DN; + evt._mask = kMouseRightDown; _buttons |= 2; break; case Common::EVENT_RBUTTONUP: - evt._mask = R_UP; + evt._mask = kMouseRightUp; _buttons &= ~2; break; default: @@ -282,22 +282,22 @@ void EventManager::handleEvents() { CGEEvent e = _eventQueue[_eventQueueTail]; if (e._mask) { if (_mouse->_hold && e._spritePtr != _mouse->_hold) - _mouse->_hold->touch(e._mask | ATTN, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y); + _mouse->_hold->touch(e._mask | kEventAttn, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y); // update mouse cursor position - if (e._mask & ROLL) + if (e._mask & kMouseRoll) _mouse->gotoxy(e._x, e._y); // activate current touched SPRITE if (e._spritePtr) { - if (e._mask & KEYB) + if (e._mask & kEventKeyb) e._spritePtr->touch(e._mask, e._x, e._y); else e._spritePtr->touch(e._mask, e._x - e._spritePtr->_x, e._y - e._spritePtr->_y); } else if (_sys) _sys->touch(e._mask, e._x, e._y); - if (e._mask & L_DN) { + if (e._mask & kMouseLeftDown) { _mouse->_hold = e._spritePtr; if (_mouse->_hold) { _mouse->_hold->_flags._hold = true; @@ -309,7 +309,7 @@ void EventManager::handleEvents() { } } - if (e._mask & L_UP) { + if (e._mask & kMouseLeftUp) { if (_mouse->_hold) { _mouse->_hold->_flags._hold = false; _mouse->_hold = NULL; @@ -318,10 +318,10 @@ void EventManager::handleEvents() { ///Touched = e.Ptr; // discard Text if button released - if (e._mask & (L_UP | R_UP)) + if (e._mask & (kMouseLeftUp | kMouseRightUp)) killText(); } - _eventQueueTail = (_eventQueueTail + 1) % EVT_MAX; + _eventQueueTail = (_eventQueueTail + 1) % kEventMax; } if (_mouse->_hold) { if (_mouse->_hold->_flags._drag) @@ -332,7 +332,7 @@ void EventManager::handleEvents() { void EventManager::clearEvent(Sprite *spr) { if (spr) { uint16 e; - for (e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % EVT_MAX) + for (e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % kEventMax) if (_eventQueue[e]._spritePtr == spr) _eventQueue[e]._mask = 0; } else @@ -341,7 +341,7 @@ void EventManager::clearEvent(Sprite *spr) { CGEEvent &EventManager::getNextEvent() { CGEEvent &evt = _eventQueue[_eventQueueHead]; - _eventQueueHead = (_eventQueueHead + 1) % EVT_MAX; + _eventQueueHead = (_eventQueueHead + 1) % kEventMax; return evt; } diff --git a/engines/cge/events.h b/engines/cge/events.h index b213caed3c..124597c329 100644 --- a/engines/cge/events.h +++ b/engines/cge/events.h @@ -40,6 +40,17 @@ namespace CGE { #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: @@ -62,15 +73,6 @@ 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 { @@ -105,7 +107,7 @@ private: class EventManager { private: Common::Event _event; - CGEEvent _eventQueue[EVT_MAX]; + CGEEvent _eventQueue[kEventMax]; uint16 _eventQueueHead; uint16 _eventQueueTail; 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 8e141a8be4..b9c10a7029 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -327,7 +327,7 @@ long timer() { return 0; } -int new_random(int range) { +int newRandom(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } diff --git a/engines/cge/general.h b/engines/cge/general.h index 57991f2125..fe34606108 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -129,7 +129,7 @@ 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 *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 a2408bc792..d96e494402 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -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 : 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/snail.cpp b/engines/cge/snail.cpp index aece48a933..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,9 +140,9 @@ 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[kKeyAlt]) { _sprK1->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) { diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 485ba00ad1..699bd5bcc1 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -199,18 +199,18 @@ void Text::say(const char *text, 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()); @@ -225,11 +225,11 @@ void CGEEngine::inf(const char *text) { 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 6ed5b32b22..bb905ac655 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -37,16 +37,11 @@ namespace CGE { #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 { diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index e8aa899583..48b27d9727 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -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; -- cgit v1.2.3