aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2011-09-17 23:03:37 +0200
committerStrangerke2011-09-17 23:04:12 +0200
commit17802f8903d82cd703cc1ede8d2b91291826248e (patch)
treec0b1a0883b9fb4600fea8ca64637900b96de8a31
parentf8ee4f385f38a734fb9a872e79ed415cec21c7ff (diff)
downloadscummvm-rg350-17802f8903d82cd703cc1ede8d2b91291826248e.tar.gz
scummvm-rg350-17802f8903d82cd703cc1ede8d2b91291826248e.tar.bz2
scummvm-rg350-17802f8903d82cd703cc1ede8d2b91291826248e.zip
CGE: Fix a potential bug in insertCommand(), some renaming
-rw-r--r--engines/cge/cge_main.cpp74
-rw-r--r--engines/cge/snail.cpp886
-rw-r--r--engines/cge/snail.h12
-rw-r--r--engines/cge/text.cpp22
-rw-r--r--engines/cge/vga13h.cpp26
-rw-r--r--engines/cge/vga13h.h10
-rw-r--r--engines/cge/vmenu.cpp2
-rw-r--r--engines/cge/walk.cpp8
8 files changed, 531 insertions, 509 deletions
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index b1427465d3..d2ca81bfce 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -281,7 +281,7 @@ Common::Error CGEEngine::loadGameState(int slot) {
// Load the game
loadGame(slot, NULL);
- _snail->addCom(kSnLevel, -1, _oldLev, &_sceneLight);
+ _snail->addCommand(kSnLevel, -1, _oldLev, &_sceneLight);
_sceneLight->gotoxy(kSceneX + ((_now - 1) % kSceneNx) * kSceneDx + kSceneSX,
kSceneY + ((_now - 1) / kSceneNx) * kSceneDy + kSceneSY);
sceneUp();
@@ -442,18 +442,18 @@ bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &heade
void CGEEngine::heroCover(int cvr) {
debugC(1, kCGEDebugEngine, "CGEEngine::heroCover(%d)", cvr);
- _snail->addCom(kSnCover, 1, cvr, NULL);
+ _snail->addCommand(kSnCover, 1, cvr, NULL);
}
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, text, _hero);
+ _snail->addCommand(kSnWait, -1, -1, _hero);
+ _snail->addCommand(kSnSeq, -1, seq, _hero);
+ _snail->addCommand(kSnSound, -1, 2, _hero);
+ _snail->addCommand(kSnWait, -1, -1, _hero);
+ _snail->addCommand(kSnSay, 1, text, _hero);
}
void CGEEngine::offUse() {
@@ -517,7 +517,7 @@ void Square::touch(uint16 mask, int x, int y) {
Sprite::touch(mask, x, y);
if (mask & kMouseLeftUp) {
_vm->XZ(_x + x, _y + y).cell() = 0;
- _vm->_snail_->addCom(kSnKill, -1, 0, this);
+ _vm->_snail_->addCommand(kSnKill, -1, 0, this);
}
}
@@ -538,13 +538,13 @@ void CGEEngine::setMapBrick(int x, int z) {
void CGEEngine::keyClick() {
debugC(1, kCGEDebugEngine, "CGEEngine::keyClick()");
- _snail_->addCom(kSnSound, -1, 5, NULL);
+ _snail_->addCommand(kSnSound, -1, 5, NULL);
}
void CGEEngine::resetQSwitch() {
debugC(1, kCGEDebugEngine, "CGEEngine::resetQSwitch()");
- _snail_->addCom(kSnSeq, 123, 0, NULL);
+ _snail_->addCommand(kSnSeq, 123, 0, NULL);
keyClick();
}
@@ -559,13 +559,13 @@ void CGEEngine::quit() {
if (_snail->idle() && !_hero->_flags._hide) {
if (Vmenu::_addr) {
- _snail_->addCom(kSnKill, -1, 0, Vmenu::_addr);
+ _snail_->addCommand(kSnKill, -1, 0, Vmenu::_addr);
resetQSwitch();
} else {
QuitMenu[0]._text = _text->getText(kQuit);
QuitMenu[1]._text = _text->getText(kNoQuit);
(new Vmenu(this, QuitMenu, -1, -1))->setName(_text->getText(kQuitTitle));
- _snail_->addCom(kSnSeq, 123, 1, NULL);
+ _snail_->addCommand(kSnSeq, 123, 1, NULL);
keyClick();
}
}
@@ -586,7 +586,7 @@ void CGEEngine::postMiniStep(int step) {
debugC(6, kCGEDebugEngine, "CGEEngine::postMiniStep(%d)", step);
if (_miniScene && step != _recentStep)
- _snail_->addCom2(kSnExec, -1, _recentStep = step, kMiniStep);
+ _snail_->addCallback(kSnExec, -1, _recentStep = step, kMiniStep);
}
void CGEEngine::showBak(int ref) {
@@ -708,8 +708,8 @@ void CGEEngine::switchScene(int newScene) {
return;
if (newScene < 0) {
- _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint
- _snail->addCom2(kSnExec, -1, 0, kQGame); // switch scene
+ _snail->addCommand(kSnLabel, -1, 0, NULL); // wait for repaint
+ _snail->addCallback(kSnExec, -1, 0, kQGame); // quit game
} else {
_now = newScene;
_mouse->off();
@@ -723,8 +723,8 @@ void CGEEngine::switchScene(int newScene) {
killText();
if (!_startupMode)
keyClick();
- _snail->addCom(kSnLabel, -1, 0, NULL); // wait for repaint
- _snail->addCom2(kSnExec, 0, 0, kXScene); // switch scene
+ _snail->addCommand(kSnLabel, -1, 0, NULL); // wait for repaint
+ _snail->addCallback(kSnExec, 0, 0, kXScene); // switch scene
}
}
@@ -756,7 +756,7 @@ void System::touch(uint16 mask, int x, int y) {
_vm->keyClick();
_vm->killText();
if (_vm->_startupMode == 1) {
- _vm->_snail->addCom(kSnClear, -1, 0, NULL);
+ _vm->_snail->addCommand(kSnClear, -1, 0, NULL);
return;
}
switch (x) {
@@ -770,7 +770,7 @@ void System::touch(uint16 mask, int x, int y) {
case '3':
case '4':
if (_vm->_keyboard->_key[kKeyAlt]) {
- _vm->_snail->addCom(kSnLevel, -1, x - '0', NULL);
+ _vm->_snail->addCommand(kSnLevel, -1, x - '0', NULL);
break;
}
break;
@@ -850,7 +850,7 @@ void System::tick() {
void CGEEngine::switchColorMode() {
debugC(1, kCGEDebugEngine, "CGEEngine::switchColorMode()");
- _snail_->addCom(kSnSeq, 121, _vga->_mono = !_vga->_mono, NULL);
+ _snail_->addCommand(kSnSeq, 121, _vga->_mono = !_vga->_mono, NULL);
keyClick();
_vga->setColors(_vga->_sysPal, 64);
}
@@ -858,7 +858,7 @@ void CGEEngine::switchColorMode() {
void CGEEngine::switchMusic() {
debugC(1, kCGEDebugEngine, "CGEEngine::switchMusic()");
- _snail_->addCom(kSnSeq, 122, (_music = !_music), NULL);
+ _snail_->addCommand(kSnSeq, 122, (_music = !_music), NULL);
keyClick();
if (_music)
@@ -887,7 +887,7 @@ void CGEEngine::switchMapping() {
} else {
for (Sprite *s = _vga->_showQ->first(); s; s = s->_next)
if (s->_w == kMapGridX && s->_h == kMapGridZ)
- _snail_->addCom(kSnKill, -1, 0, s);
+ _snail_->addCommand(kSnKill, -1, 0, s);
}
_horzLine->_flags._hide = !_horzLine->_flags._hide;
}
@@ -897,7 +897,7 @@ void CGEEngine::killSprite() {
_sprite->_flags._kill = true;
_sprite->_flags._bDel = true;
- _snail_->addCom(kSnKill, -1, 0, _sprite);
+ _snail_->addCommand(kSnKill, -1, 0, _sprite);
_sprite = NULL;
}
@@ -966,8 +966,8 @@ void Sprite::touch(uint16 mask, int x, int y) {
if (_vm->findPocket(NULL) < 0) {
_vm->pocFul();
} else {
- _vm->_snail->addCom(kSnReach, -1, -1, this);
- _vm->_snail->addCom(kSnKeep, -1, -1, this);
+ _vm->_snail->addCommand(kSnReach, -1, -1, this);
+ _vm->_snail->addCommand(kSnKeep, -1, -1, this);
_flags._port = false;
}
} else {
@@ -996,7 +996,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
}
}
} else {
- _vm->_snail->addCom(kSnWalk, -1, -1, this); // Hero->FindWay(this);
+ _vm->_snail->addCommand(kSnWalk, -1, -1, this); // Hero->FindWay(this);
}
}
}
@@ -1229,14 +1229,14 @@ void CGEEngine::killText() {
if (!_talk)
return;
- _snail_->addCom(kSnKill, -1, 0, _talk);
+ _snail_->addCommand(kSnKill, -1, 0, _talk);
_talk = NULL;
}
void CGEEngine::mainLoop() {
_vga->show();
- _snail_->runCom();
- _snail->runCom();
+ _snail_->runCommand();
+ _snail->runCommand();
// Handle a delay between game frames
handleFrame();
@@ -1332,10 +1332,10 @@ void CGEEngine::runGame() {
// ~~~~~~~~~~~
if ((_sprite = _vga->_spareQ->locate(121)) != NULL)
- _snail_->addCom(kSnSeq, -1, _vga->_mono, _sprite);
+ _snail_->addCommand(kSnSeq, -1, _vga->_mono, _sprite);
if ((_sprite = _vga->_spareQ->locate(122)) != NULL)
_sprite->step(_music);
- _snail_->addCom(kSnSeq, -1, _music, _sprite);
+ _snail_->addCommand(kSnSeq, -1, _music, _sprite);
if (!_music)
_midiPlayer->killMidi();
@@ -1390,7 +1390,7 @@ void CGEEngine::runGame() {
_startupMode = 0;
- _snail->addCom(kSnLevel, -1, _oldLev, &_sceneLight);
+ _snail->addCommand(kSnLevel, -1, _oldLev, &_sceneLight);
_sceneLight->gotoxy(kSceneX + ((_now - 1) % kSceneNx) * kSceneDx + kSceneSX,
kSceneY + ((_now - 1) / kSceneNx) * kSceneDy + kSceneSY);
sceneUp();
@@ -1399,7 +1399,7 @@ void CGEEngine::runGame() {
// main loop
while (!_finis && !_eventManager->_quitFlag) {
if (_flag[3])
- _snail->addCom2(kSnExec, -1, 0, kQGame);
+ _snail->addCallback(kSnExec, -1, 0, kQGame);
mainLoop();
}
@@ -1408,8 +1408,8 @@ void CGEEngine::runGame() {
qGame();
_keyboard->setClient(NULL);
- _snail->addCom(kSnClear, -1, 0, NULL);
- _snail_->addCom(kSnClear, -1, 0, NULL);
+ _snail->addCommand(kSnClear, -1, 0, NULL);
+ _snail_->addCommand(kSnClear, -1, 0, NULL);
_mouse->off();
_vga->_showQ->clear();
_vga->_spareQ->clear();
@@ -1436,8 +1436,8 @@ void CGEEngine::movie(const char *ext) {
mainLoop();
_keyboard->setClient(NULL);
- _snail->addCom(kSnClear, -1, 0, NULL);
- _snail_->addCom(kSnClear, -1, 0, NULL);
+ _snail->addCommand(kSnClear, -1, 0, NULL);
+ _snail_->addCommand(kSnClear, -1, 0, NULL);
_vga->_showQ->clear();
_vga->_spareQ->clear();
}
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index d4993c9998..175cf93d23 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -36,6 +36,345 @@
namespace CGE {
+const char *Snail::_comText[] = {
+ "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE",
+ "SAY", "INF", "TIME", "CAVE", "KILL",
+ "RSEQ", "SEQ", "SEND", "SWAP", "KEEP",
+ "GIVE", "IF", "GAME", "SETX0", "SETY0",
+ "SLAVE", "SETXY", "RELX", "RELY", "RELZ",
+ "SETX", "SETY", "SETZ", "TRANS", "PORT",
+ "NEXT", "NNEXT", "TNEXT", "RNNEXT", "RTNEXT",
+ "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT",
+ "FLASH", "LIGHT", "SETHB", "SETVB", "WALK",
+ "REACH", "COVER", "UNCOVER", "CLEAR", "TALK",
+ "MOUSE", "SOUND", "COUNT", NULL
+};
+
+Snail::Snail(CGEEngine *vm, bool turbo)
+ : _turbo(turbo), _busy(false), _textDelay(false),
+ _timerExpiry(0), _talkEnable(true),
+ _head(0), _tail(0), _snList((Command *)malloc(sizeof(Command) * 256)), _vm(vm) {
+}
+
+Snail::~Snail() {
+ free(_snList);
+}
+
+/**
+ * Add a Command on the head of _snList
+ * @param com Command
+ * @param ref Reference
+ * @param val Value
+ * @param ptr Sprite pointer
+ */
+void Snail::addCommand(SnCom com, int ref, int val, void *ptr) {
+ Command *snc = &_snList[_head++];
+ snc->_com = com;
+ snc->_ref = ref;
+ snc->_val = val;
+ snc->_spritePtr = ptr;
+ snc->_cbType = kNullCB;
+ if (com == kSnClear) {
+ _tail = _head;
+ _vm->killText();
+ _timerExpiry = 0;
+ }
+}
+
+/**
+ * Add a Callback on the head of _snList
+ * @param com Command
+ * @param ref Reference
+ * @param val Value
+ * @param CallbackType Callback type
+ */
+void Snail::addCallback(SnCom com, int ref, int val, CallbackType cbType) {
+ Command *snc = &_snList[_head++];
+ snc->_com = com;
+ snc->_ref = ref;
+ snc->_val = val;
+ snc->_spritePtr = NULL;
+ snc->_cbType = cbType;
+ if (com == kSnClear) {
+ _tail = _head;
+ _vm->killText();
+ _timerExpiry = 0;
+ }
+}
+
+/**
+ * Add a Command on the tail of _snList
+ * @param com Command
+ * @param ref Reference
+ * @param val Value
+ * @param ptr Sprite pointer
+ */
+void Snail::insertCommand(SnCom com, int ref, int val, void *ptr) {
+ Command *snc;
+
+ if (_busy) {
+ _snList[(_tail - 1) & 0xFF] = _snList[_tail];
+ snc = &_snList[_tail];
+ } else
+ snc = &_snList[(_tail - 1) & 0xFF];
+ _tail--;
+ snc->_com = com;
+ snc->_ref = ref;
+ snc->_val = val;
+ snc->_spritePtr = ptr;
+ snc->_cbType = kNullCB;
+ if (com == kSnClear) {
+ _tail = _head;
+ _vm->killText();
+ _timerExpiry = 0;
+ }
+}
+
+void Snail::runCommand() {
+ if (_busy)
+ return;
+
+ _busy = true;
+ uint8 tmpHead = _head;
+ while (_tail != tmpHead) {
+ Command *snc = &_snList[_tail];
+
+ if (!_turbo) { // only for the slower one
+ if (_timerExpiry) {
+ // Delay in progress
+ if (_timerExpiry > g_system->getMillis())
+ // Delay not yet ended
+ break;
+
+ // Delay is finished
+ _timerExpiry = 0;
+ } else {
+ if (_textDelay) {
+ _vm->killText();
+ _textDelay = false;
+ }
+ }
+ if (_vm->_talk && snc->_com != kSnPause)
+ break;
+ }
+
+ Sprite *spr = ((snc->_ref >= 0) ? _vm->locate(snc->_ref) : ((Sprite *) snc->_spritePtr));
+ switch (snc->_com) {
+ case kSnLabel:
+ break;
+ case kSnPause :
+ _timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay;
+ if (_vm->_talk)
+ _textDelay = true;
+ break;
+ case kSnWait:
+ if (spr) {
+ if (spr->seqTest(snc->_val) &&
+ (snc->_val >= 0 || spr != _vm->_hero || _vm->_hero->_tracePtr < 0)) {
+ _timerExpiry = g_system->getMillis() + spr->_time * kSnailFrameDelay;
+ } else {
+ _busy = false;
+ return;
+ }
+ }
+ break;
+ case kSnLevel:
+ _vm->snLevel(spr, snc->_val);
+ break;
+ case kSnHide:
+ _vm->snHide(spr, snc->_val);
+ break;
+ case kSnSay:
+ if (spr && _talkEnable) {
+ if (spr == _vm->_hero && spr->seqTest(-1))
+ spr->step(kSeqHTalk);
+ _vm->_text->say(_vm->_text->getText(snc->_val), spr);
+ _vm->_sys->_funDel = kHeroFun0;
+ }
+ break;
+ case kSnInf:
+ if (_talkEnable) {
+ _vm->inf(_vm->_text->getText(snc->_val));
+ _vm->_sys->_funDel = kHeroFun0;
+ }
+ break;
+ case kSnTime:
+ if (spr && _talkEnable) {
+ if (spr == _vm->_hero && spr->seqTest(-1))
+ spr->step(kSeqHTalk);
+ _vm->_text->sayTime(spr);
+ }
+ break;
+ case kSnCave:
+ _vm->switchScene(snc->_val);
+ break;
+ case kSnKill:
+ _vm->snKill(spr);
+ break;
+ case kSnSeq:
+ _vm->snSeq(spr, snc->_val);
+ break;
+ case kSnRSeq:
+ _vm->snRSeq(spr, snc->_val);
+ break;
+ case kSnSend:
+ _vm->snSend(spr, snc->_val);
+ break;
+ case kSnSwap:
+ _vm->snSwap(spr, snc->_val);
+ break;
+ case kSnCover:
+ _vm->snCover(spr, snc->_val);
+ break;
+ case kSnUncover:
+ _vm->snUncover(spr, (snc->_val >= 0) ? _vm->locate(snc->_val) : ((Sprite *) snc->_spritePtr));
+ break;
+ case kSnKeep:
+ _vm->snKeep(spr, snc->_val);
+ break;
+ case kSnGive:
+ _vm->snGive(spr, snc->_val);
+ break;
+ case kSnGame:
+ _vm->snGame(spr, snc->_val);
+ break;
+ case kSnSetX0:
+ _vm->snSetX0(snc->_ref, snc->_val);
+ break;
+ case kSnSetY0:
+ _vm->snSetY0(snc->_ref, snc->_val);
+ break;
+ case kSnSetXY:
+ _vm->snSetXY(spr, snc->_val);
+ break;
+ case kSnRelX:
+ _vm->snRelX(spr, snc->_val);
+ break;
+ case kSnRelY:
+ _vm->snRelY(spr, snc->_val);
+ break;
+ case kSnRelZ:
+ _vm->snRelZ(spr, snc->_val);
+ break;
+ case kSnSetX:
+ _vm->snSetX(spr, snc->_val);
+ break;
+ case kSnSetY:
+ _vm->snSetY(spr, snc->_val);
+ break;
+ case kSnSetZ:
+ _vm->snSetZ(spr, snc->_val);
+ break;
+ case kSnSlave:
+ _vm->snSlave(spr, snc->_val);
+ break;
+ case kSnTrans:
+ _vm->snTrans(spr, snc->_val);
+ break;
+ case kSnPort:
+ _vm->snPort(spr, snc->_val);
+ break;
+ case kSnNext:
+ case kSnIf:
+ case kSnTalk:
+ break;
+ case kSnMouse:
+ _vm->snMouse(snc->_val != 0);
+ break;
+ case kSnNNext:
+ _vm->snNNext(spr, snc->_val);
+ break;
+ case kSnTNext:
+ _vm->snTNext(spr, snc->_val);
+ break;
+ case kSnRNNext:
+ _vm->snRNNext(spr, snc->_val);
+ break;
+ case kSnRTNext:
+ _vm->snRTNext(spr, snc->_val);
+ break;
+ case kSnRMNear:
+ _vm->snRmNear(spr);
+ break;
+ case kSnRmTake:
+ _vm->snRmTake(spr);
+ break;
+ case kSnFlag:
+ _vm->snFlag(snc->_ref & 3, snc->_val != 0);
+ break;
+ case kSnSetRef:
+ _vm->snSetRef(spr, snc->_val);
+ break;
+ case kSnBackPt:
+ _vm->snBackPt(spr, snc->_val);
+ break;
+ case kSnFlash:
+ _vm->snFlash(snc->_val != 0);
+ break;
+ case kSnLight:
+ _vm->snLight(snc->_val != 0);
+ break;
+ case kSnSetHBarrier:
+ _vm->snHBarrier(snc->_ref, snc->_val);
+ break;
+ case kSnSetVBarrier:
+ _vm->snVBarrier(snc->_ref, snc->_val);
+ break;
+ case kSnWalk:
+ _vm->snWalk(spr, snc->_ref, snc->_val);
+ break;
+ case kSnReach:
+ _vm->snReach(spr, snc->_val);
+ break;
+ case kSnSound:
+ _vm->snSound(spr, snc->_val);
+ break;
+ case kSnCount:
+ _vm->_sound->setRepeat(snc->_val);
+ break;
+ case kSnExec:
+ switch (snc->_cbType) {
+ case kQGame:
+ _vm->qGame();
+ break;
+ case kMiniStep:
+ _vm->miniStep(snc->_val);
+ break;
+ case kXScene:
+ _vm->xScene();
+ break;
+ case kSndSetVolume:
+ _vm->sndSetVolume();
+ break;
+ default:
+ error("Unknown Callback Type in SNEXEC");
+ }
+ break;
+ case kSnStep:
+ spr->step();
+ break;
+ case kSnZTrim:
+ _vm->snZTrim(spr);
+ break;
+ case kSnGhost:
+ _vm->snGhost((Bitmap *) snc->_spritePtr);
+ break;
+ default:
+ warning("Unhandled snc->_com in SNMouse(bool)");
+ break;
+ }
+ _tail++;
+ if (!_turbo)
+ break;
+ }
+
+ _busy = false;
+}
+
+bool Snail::idle() {
+ return (_head == _tail);
+}
+
void CGEEngine::snGame(Sprite *spr, int num) {
debugC(1, kCGEDebugEngine, "CGEEngine::snGame(spr, %d)", num);
@@ -63,66 +402,66 @@ void CGEEngine::snGame(Sprite *spr, int num) {
if (hand && Stage > kDressed)
++hand;
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
- _snail->addCom(kSnTNext, -1, 0, dup[0]); // reset Take
- _snail->addCom(kSnTNext, -1, 0, dup[1]); // reset Take
- _snail->addCom(kSnTNext, -1, 0, dup[2]); // reset Take
- _snail->addCom(kSnNNext, -1, 0, dup[0]); // reset Near
- _snail->addCom(kSnPause, -1, 72, NULL); // little rest
- _snail->addCom(kSnSay, 1, 16009, NULL); // hura
- _snail->addCom(kSnSay, buref, 16010, NULL); // siadaj
- _snail->addCom(kSnSay, 1, 16011, NULL); // postoj‘
+ _snail->addCommand(kSnSeq, -1, 3, dup[0]); // yes
+ _snail->addCommand(kSnSeq, -1, 3, dup[1]); // yes
+ _snail->addCommand(kSnSeq, -1, 3, dup[2]); // yes
+ _snail->addCommand(kSnTNext, -1, 0, dup[0]); // reset Take
+ _snail->addCommand(kSnTNext, -1, 0, dup[1]); // reset Take
+ _snail->addCommand(kSnTNext, -1, 0, dup[2]); // reset Take
+ _snail->addCommand(kSnNNext, -1, 0, dup[0]); // reset Near
+ _snail->addCommand(kSnPause, -1, 72, NULL); // little rest
+ _snail->addCommand(kSnSay, 1, 16009, NULL); // hura
+ _snail->addCommand(kSnSay, buref, 16010, NULL); // siadaj
+ _snail->addCommand(kSnSay, 1, 16011, NULL); // postoj‘
if (hand) {
- _snail->addCom(kSnSend, 16060 + hand, 16, NULL); // dawaj r‘k‘
- _snail->addCom(kSnSeq, buref, 4, NULL); // zdejmowanie
- _snail->addCom(kSnSeq, 16060 + hand, 1, NULL); // ruch
- _snail->addCom(kSnSound, 16060 + hand, 16002, NULL); // szelest
- _snail->addCom(kSnWait, 16060 + hand, 3, NULL); // podniesie
- _snail->addCom(kSnSwap, buref, buref + 100, NULL); // rozdziana
- _snail->addCom(kSnSeq, 16016, Stage, NULL); // rožnie kupa
- _snail->addCom(kSnSend, 16060 + hand, -1, NULL); // chowaj r‘k‘
- _snail->addCom(kSnWait, 16060 + hand, -1, NULL); // r‘ka zamar’a
+ _snail->addCommand(kSnSend, 16060 + hand, 16, NULL); // dawaj r‘k‘
+ _snail->addCommand(kSnSeq, buref, 4, NULL); // zdejmowanie
+ _snail->addCommand(kSnSeq, 16060 + hand, 1, NULL); // ruch
+ _snail->addCommand(kSnSound, 16060 + hand, 16002, NULL); // szelest
+ _snail->addCommand(kSnWait, 16060 + hand, 3, NULL); // podniesie
+ _snail->addCommand(kSnSwap, buref, buref + 100, NULL); // rozdziana
+ _snail->addCommand(kSnSeq, 16016, Stage, NULL); // rožnie kupa
+ _snail->addCommand(kSnSend, 16060 + hand, -1, NULL); // chowaj r‘k‘
+ _snail->addCommand(kSnWait, 16060 + hand, -1, NULL); // r‘ka zamar’a
} else {
- _snail->addCom(kSnSeq, buref, 4, NULL); // zdejmowanie
- _snail->addCom(kSnSound, 16060 + hand, 16002, NULL); // szelest
- _snail->addCom(kSnWait, buref, -1, NULL); // zdejmie
- _snail->addCom(kSnSwap, buref, buref + 100, NULL); // rozdziana
- _snail->addCom(kSnSeq, 16016, Stage, NULL); // rožnie kupa
+ _snail->addCommand(kSnSeq, buref, 4, NULL); // zdejmowanie
+ _snail->addCommand(kSnSound, 16060 + hand, 16002, NULL); // szelest
+ _snail->addCommand(kSnWait, buref, -1, NULL); // zdejmie
+ _snail->addCommand(kSnSwap, buref, buref + 100, NULL); // rozdziana
+ _snail->addCommand(kSnSeq, 16016, Stage, NULL); // rožnie kupa
}
//SNPOST(SNSEQ, buref+100, 0, NULL); // reset
- _snail->addCom(kSnPause, -1, 72, NULL); // chwilk‘...
- _snail->addCom(kSnSeq, -1, 0, dup[1]); // odstaw Go
- _snail->addCom(kSnSetXY, -1, 203 + kScrWidth * 49, dup[1]);
- _snail->addCom(kSnSetZ, -1, 7, dup[1]);
- _snail->addCom(kSnSeq, -1, 0, dup[2]); // odstaw J†
- _snail->addCom(kSnSetXY, -1, 182 + kScrWidth * 62, dup[2]);
- _snail->addCom(kSnSetZ, -1, 9, dup[2]);
+ _snail->addCommand(kSnPause, -1, 72, NULL); // chwilk‘...
+ _snail->addCommand(kSnSeq, -1, 0, dup[1]); // odstaw Go
+ _snail->addCommand(kSnSetXY, -1, 203 + kScrWidth * 49, dup[1]);
+ _snail->addCommand(kSnSetZ, -1, 7, dup[1]);
+ _snail->addCommand(kSnSeq, -1, 0, dup[2]); // odstaw J†
+ _snail->addCommand(kSnSetXY, -1, 182 + kScrWidth * 62, dup[2]);
+ _snail->addCommand(kSnSetZ, -1, 9, dup[2]);
_game = 0;
return;
} else {
- _snail->addCom(kSnSeq, -1, 2, dup[0]); // no
- _snail->addCom(kSnSeq, -1, 2, dup[1]); // no
- _snail->addCom(kSnSeq, -1, 2, dup[2]); // no
- _snail->addCom(kSnPause, -1, 72, NULL); // 1 sec
+ _snail->addCommand(kSnSeq, -1, 2, dup[0]); // no
+ _snail->addCommand(kSnSeq, -1, 2, dup[1]); // no
+ _snail->addCommand(kSnSeq, -1, 2, dup[2]); // no
+ _snail->addCommand(kSnPause, -1, 72, NULL); // 1 sec
}
}
- _snail->addCom(kSnWalk, 198, 134, NULL); // na miejsce
- _snail->addCom(kSnWait, 1, -1, NULL); // stoi
- _snail->addCom(kSnCover, 1, 16101, NULL); // ch’op do bicia
- _snail->addCom(kSnSeq, 16101, 1, NULL); // wystaw
- _snail->addCom(kSnWait, 16101, 5, NULL); // czekaj
- _snail->addCom(kSnPause, 16101, 24, NULL); // czekaj chwil‘
- _snail->addCom(kSnSeq, 16040, 1, NULL); // plask
- _snail->addCom(kSnSound, 16101, 16001, NULL); // plask!
- _snail->addCom(kSnPause, 16101, 24, NULL); // czekaj chwil‘
- _snail->addCom(kSnSeq, 16040, 0, NULL); // schowaj plask
- _snail->addCom(kSnWait, 16101, -1, NULL); // stoi
- _snail->addCom(kSnUncover, 1, 16101, NULL); // SDS
+ _snail->addCommand(kSnWalk, 198, 134, NULL); // na miejsce
+ _snail->addCommand(kSnWait, 1, -1, NULL); // stoi
+ _snail->addCommand(kSnCover, 1, 16101, NULL); // ch’op do bicia
+ _snail->addCommand(kSnSeq, 16101, 1, NULL); // wystaw
+ _snail->addCommand(kSnWait, 16101, 5, NULL); // czekaj
+ _snail->addCommand(kSnPause, 16101, 24, NULL); // czekaj chwil‘
+ _snail->addCommand(kSnSeq, 16040, 1, NULL); // plask
+ _snail->addCommand(kSnSound, 16101, 16001, NULL); // plask!
+ _snail->addCommand(kSnPause, 16101, 24, NULL); // czekaj chwil‘
+ _snail->addCommand(kSnSeq, 16040, 0, NULL); // schowaj plask
+ _snail->addCommand(kSnWait, 16101, -1, NULL); // stoi
+ _snail->addCommand(kSnUncover, 1, 16101, NULL); // SDS
if (!_game) {
- _snail->addCom(kSnSay, buref, 16008, NULL); // zgadnij!
+ _snail->addCommand(kSnSay, buref, 16008, NULL); // zgadnij!
_game = true;
}
}
@@ -136,7 +475,7 @@ void CGEEngine::snGame(Sprite *spr, int num) {
}
if (!_game) { // init
- _snail->addCom(kSnGame, 20002, 2, NULL);
+ _snail->addCommand(kSnGame, 20002, 2, NULL);
_game = true;
break;
}
@@ -152,23 +491,23 @@ void CGEEngine::snGame(Sprite *spr, int num) {
_sprK3->step(5);
}
- _snail->addCom(kSnSetZ, 20700, 0, NULL);
+ _snail->addCommand(kSnSetZ, 20700, 0, NULL);
bool hit = (_sprK1->_seqPtr + _sprK2->_seqPtr + _sprK3->_seqPtr == 15);
if (hit) {
if (spr->_ref == 1) {
- _snail->addCom(kSnSay, 1, 20003, NULL); // hura!
- _snail->addCom(kSnSeq, 20011, 2, NULL); // kamera won
- _snail->addCom(kSnSend, 20701, -1, NULL); // k1 won
- _snail->addCom(kSnSend, 20702, -1, NULL); // k2 won
- _snail->addCom(kSnSend, 20703, -1, NULL); // k3 won
- _snail->addCom(kSnSend, 20700, -1, NULL); // tv won
- _snail->addCom(kSnKeep, 20007, 0, NULL); // do kieszeni
- _snail->addCom(kSnSend, 20006, 20, NULL); // bilon
- _snail->addCom(kSnSound, 20006, 20002, NULL); // bilon!
- _snail->addCom(kSnSay, 20002, 20004, NULL);
- _snail->addCom(kSnSend, 20010, 20, NULL); // papier
- _snail->addCom(kSnSound, 20010, 20003, NULL); // papier!
- _snail->addCom(kSnSay, 20001, 20005, NULL);
+ _snail->addCommand(kSnSay, 1, 20003, NULL); // hura!
+ _snail->addCommand(kSnSeq, 20011, 2, NULL); // kamera won
+ _snail->addCommand(kSnSend, 20701, -1, NULL); // k1 won
+ _snail->addCommand(kSnSend, 20702, -1, NULL); // k2 won
+ _snail->addCommand(kSnSend, 20703, -1, NULL); // k3 won
+ _snail->addCommand(kSnSend, 20700, -1, NULL); // tv won
+ _snail->addCommand(kSnKeep, 20007, 0, NULL); // do kieszeni
+ _snail->addCommand(kSnSend, 20006, 20, NULL); // bilon
+ _snail->addCommand(kSnSound, 20006, 20002, NULL); // bilon!
+ _snail->addCommand(kSnSay, 20002, 20004, NULL);
+ _snail->addCommand(kSnSend, 20010, 20, NULL); // papier
+ _snail->addCommand(kSnSound, 20010, 20003, NULL); // papier!
+ _snail->addCommand(kSnSay, 20001, 20005, NULL);
_game = false;
return;
} else
@@ -178,13 +517,13 @@ void CGEEngine::snGame(Sprite *spr, int num) {
if (_gameCase2Cpt < 100) {
switch (_gameCase2Cpt) {
case 15:
- _snail->addCom(kSnSay, 20003, 20021, NULL);
+ _snail->addCommand(kSnSay, 20003, 20021, NULL);
break;
case 30:
case 45:
case 60:
case 75:
- _snail->addCom(kSnSay, 20003, 20022, NULL);
+ _snail->addCommand(kSnSay, 20003, 20022, NULL);
break;
}
_gameCase2Cpt++;
@@ -192,49 +531,49 @@ void CGEEngine::snGame(Sprite *spr, int num) {
switch (spr->_ref) {
case 1:
- _snail->addCom(kSnSay, 20001, 20011, NULL); // zapro
- _snail->addCom(kSnSeq, 20001, 1, NULL); // rzuŤ
- _snail->addCom(kSnWait, 20001, 1, NULL); // czekaj
- _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k
- _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k
- _snail->addCom(kSnWait, 20001, 16, NULL); // czekaj
- _snail->addCom(kSnSeq, 20007, 1, NULL); // lec†
- _snail->addCom(kSnHide, 20007, 0, NULL); // poka§
- _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech
- _snail->addCom(kSnWait, 20007, -1, NULL); // koniec
- _snail->addCom(kSnGame, 20001, 2, NULL); // again!
+ _snail->addCommand(kSnSay, 20001, 20011, NULL); // zapro
+ _snail->addCommand(kSnSeq, 20001, 1, NULL); // rzuŤ
+ _snail->addCommand(kSnWait, 20001, 1, NULL); // czekaj
+ _snail->addCommand(kSnSetZ, 20700, 2, NULL); // skryj k
+ _snail->addCommand(kSnHide, 20007, 1, NULL); // skryj k
+ _snail->addCommand(kSnWait, 20001, 16, NULL); // czekaj
+ _snail->addCommand(kSnSeq, 20007, 1, NULL); // lec†
+ _snail->addCommand(kSnHide, 20007, 0, NULL); // poka§
+ _snail->addCommand(kSnSound, 20007, 20001, NULL); // grzech
+ _snail->addCommand(kSnWait, 20007, -1, NULL); // koniec
+ _snail->addCommand(kSnGame, 20001, 2, NULL); // again!
break;
case 20001:
- _snail->addCom(kSnSay, 20002, 20012, NULL); // zapro
- _snail->addCom(kSnSeq, 20002, 1, NULL); // rzuŤ
- _snail->addCom(kSnWait, 20002, 3, NULL); // czekaj
- _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k
- _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k
- _snail->addCom(kSnWait, 20002, 10, NULL); // czekaj
- _snail->addCom(kSnSeq, 20007, 2, NULL); // lec†
- _snail->addCom(kSnHide, 20007, 0, NULL); // poka§
- _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech
- _snail->addCom(kSnWait, 20007, -1, NULL); // koniec
- _snail->addCom(kSnGame, 20002, 2, NULL); // again!
+ _snail->addCommand(kSnSay, 20002, 20012, NULL); // zapro
+ _snail->addCommand(kSnSeq, 20002, 1, NULL); // rzuŤ
+ _snail->addCommand(kSnWait, 20002, 3, NULL); // czekaj
+ _snail->addCommand(kSnSetZ, 20700, 2, NULL); // skryj k
+ _snail->addCommand(kSnHide, 20007, 1, NULL); // skryj k
+ _snail->addCommand(kSnWait, 20002, 10, NULL); // czekaj
+ _snail->addCommand(kSnSeq, 20007, 2, NULL); // lec†
+ _snail->addCommand(kSnHide, 20007, 0, NULL); // poka§
+ _snail->addCommand(kSnSound, 20007, 20001, NULL); // grzech
+ _snail->addCommand(kSnWait, 20007, -1, NULL); // koniec
+ _snail->addCommand(kSnGame, 20002, 2, NULL); // again!
break;
case 20002:
- _snail->addCom(kSnSay, 20002, 20010, NULL); // zapro
- _snail->addCom(kSnWalk, 20005, -1, NULL); // do stol
- _snail->addCom(kSnWait, 1, -1, NULL); // stoi
- _snail->addCom(kSnCover, 1, 20101, NULL); // grasol
- _snail->addCom(kSnSeq, 20101, 1, NULL); // rzuŤ
- _snail->addCom(kSnWait, 20101, 5, NULL); // czekaj
- _snail->addCom(kSnSetZ, 20700, 2, NULL); // skryj k
- _snail->addCom(kSnHide, 20007, 1, NULL); // skryj k
- _snail->addCom(kSnWait, 20101, 15, NULL); // czekaj
- _snail->addCom(kSnSeq, 20007, 1, NULL); // lec†
- _snail->addCom(kSnHide, 20007, 0, NULL); // poka§
- _snail->addCom(kSnSound, 20007, 20001, NULL); // grzech
- _snail->addCom(kSnWait, 20101, -1, NULL); // koniec
- _snail->addCom(kSnUncover, 1, 20101, NULL); // SDS
- _snail->addCom(kSnGame, 1, 2, NULL); // again!
+ _snail->addCommand(kSnSay, 20002, 20010, NULL); // zapro
+ _snail->addCommand(kSnWalk, 20005, -1, NULL); // do stol
+ _snail->addCommand(kSnWait, 1, -1, NULL); // stoi
+ _snail->addCommand(kSnCover, 1, 20101, NULL); // grasol
+ _snail->addCommand(kSnSeq, 20101, 1, NULL); // rzuŤ
+ _snail->addCommand(kSnWait, 20101, 5, NULL); // czekaj
+ _snail->addCommand(kSnSetZ, 20700, 2, NULL); // skryj k
+ _snail->addCommand(kSnHide, 20007, 1, NULL); // skryj k
+ _snail->addCommand(kSnWait, 20101, 15, NULL); // czekaj
+ _snail->addCommand(kSnSeq, 20007, 1, NULL); // lec†
+ _snail->addCommand(kSnHide, 20007, 0, NULL); // poka§
+ _snail->addCommand(kSnSound, 20007, 20001, NULL); // grzech
+ _snail->addCommand(kSnWait, 20101, -1, NULL); // koniec
+ _snail->addCommand(kSnUncover, 1, 20101, NULL); // SDS
+ _snail->addCommand(kSnGame, 1, 2, NULL); // again!
break;
}
}
@@ -284,17 +623,17 @@ void CGEEngine::pocFul() {
debugC(1, kCGEDebugEngine, "CGEEngine::pocFul()");
_hero->park();
- _snail->addCom(kSnWait, -1, -1, _hero);
- _snail->addCom(kSnSeq, -1, kSeqPocketFull, _hero);
- _snail->addCom(kSnSound, -1, 2, _hero);
- _snail->addCom(kSnWait, -1, -1, _hero);
- _snail->addCom(kSnSay, 1, kPocketFull, _hero);
+ _snail->addCommand(kSnWait, -1, -1, _hero);
+ _snail->addCommand(kSnSeq, -1, kSeqPocketFull, _hero);
+ _snail->addCommand(kSnSound, -1, 2, _hero);
+ _snail->addCommand(kSnWait, -1, -1, _hero);
+ _snail->addCommand(kSnSay, 1, kPocketFull, _hero);
}
void CGEEngine::hide1(Sprite *spr) {
debugC(1, kCGEDebugEngine, "CGEEngine::hide1(spr)");
- _snail_->addCom(kSnGhost, -1, 0, spr->ghost());
+ _snail_->addCommand(kSnGhost, -1, 0, spr->ghost());
}
void CGEEngine::snGhost(Bitmap *bmp) {
@@ -317,17 +656,17 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) {
if (ptr == kNoPtr)
return;
- Snail::Com *comtab = spr->snList(snq);
- Snail::Com *c = comtab + ptr;
+ Snail::Command *comtab = spr->snList(snq);
+ Snail::Command *c = comtab + ptr;
if (findPocket(NULL) < 0) { // no empty pockets?
- Snail::Com *p;
+ Snail::Command *p;
for (p = c; p->_com != kSnNext; p++) { // find KEEP command
if (p->_com == kSnKeep) {
pocFul();
return;
}
- if (p->_ptr)
+ if (p->_spritePtr)
break;
}
}
@@ -373,8 +712,8 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) {
} else
++c;
} else {
- _snail->addCom(c->_com, c->_ref, c->_val, spr);
- if (c->_ptr)
+ _snail->addCommand(c->_com, c->_ref, c->_val, spr);
+ if (c->_spritePtr)
break;
else
c++;
@@ -382,78 +721,6 @@ void CGEEngine::feedSnail(Sprite *spr, SnList snq) {
}
}
-const char *Snail::_comText[] = {
- "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE",
- "SAY", "INF", "TIME", "CAVE", "KILL",
- "RSEQ", "SEQ", "SEND", "SWAP", "KEEP",
- "GIVE", "IF", "GAME", "SETX0", "SETY0",
- "SLAVE", "SETXY", "RELX", "RELY", "RELZ",
- "SETX", "SETY", "SETZ", "TRANS", "PORT",
- "NEXT", "NNEXT", "TNEXT", "RNNEXT", "RTNEXT",
- "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT",
- "FLASH", "LIGHT", "SETHB", "SETVB", "WALK",
- "REACH", "COVER", "UNCOVER", "CLEAR", "TALK",
- "MOUSE", "SOUND", "COUNT", NULL
-};
-
-Snail::Snail(CGEEngine *vm, bool turbo)
- : _turbo(turbo), _busy(false), _textDelay(false),
- _timerExpiry(0), _talkEnable(true),
- _head(0), _tail(0), _snList((Com *)malloc(sizeof(Com) * 256)), _vm(vm) {
-}
-
-Snail::~Snail() {
- free(_snList);
-}
-
-void Snail::addCom(SnCom com, int ref, int val, void *ptr) {
- Com *snc = &_snList[_head++];
- snc->_com = com;
- snc->_ref = ref;
- snc->_val = val;
- snc->_ptr = ptr;
- snc->_cbType = kNullCB;
- if (com == kSnClear) {
- _tail = _head;
- _vm->killText();
- _timerExpiry = 0;
- }
-}
-
-void Snail::addCom2(SnCom com, int ref, int val, CallbackType cbType) {
- Com *snc = &_snList[_head++];
- snc->_com = com;
- snc->_ref = ref;
- snc->_val = val;
- snc->_ptr = NULL;
- snc->_cbType = cbType;
- if (com == kSnClear) {
- _tail = _head;
- _vm->killText();
- _timerExpiry = 0;
- }
-}
-
-void Snail::insCom(SnCom com, int ref, int val, void *ptr) {
- Com *snc;
-
- if (_busy) {
- _snList[(_tail - 1) & 0xFF] = _snList[_tail];
- snc = &_snList[_tail];
- } else
- snc = &_snList[(_tail - 1) & 0xFF];
- _tail--;
- snc->_com = com;
- snc->_ref = ref;
- snc->_val = val;
- snc->_ptr = ptr;
- if (com == kSnClear) {
- _tail = _head;
- _vm->killText();
- _timerExpiry = 0;
- }
-}
-
void CGEEngine::snNNext(Sprite *spr, int p) {
debugC(1, kCGEDebugEngine, "CGEEngine::snNNext(spr, %d)", p);
@@ -936,249 +1203,4 @@ void CGEEngine::snMouse(bool on) {
_mouse->off();
}
-void Snail::runCom() {
- if (_busy)
- return;
-
- _busy = true;
- uint8 tmpHead = _head;
- while (_tail != tmpHead) {
- Com *snc = &_snList[_tail];
-
- if (!_turbo) { // only for the slower one
- if (_timerExpiry) {
- // Delay in progress
- if (_timerExpiry > g_system->getMillis())
- // Delay not yet ended
- break;
-
- // Delay is finished
- _timerExpiry = 0;
- } else {
- if (_textDelay) {
- _vm->killText();
- _textDelay = false;
- }
- }
- if (_vm->_talk && snc->_com != kSnPause)
- break;
- }
-
- Sprite *spr = ((snc->_ref >= 0) ? _vm->locate(snc->_ref) : ((Sprite *) snc->_ptr));
- switch (snc->_com) {
- case kSnLabel:
- break;
- case kSnPause :
- _timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay;
- if (_vm->_talk)
- _textDelay = true;
- break;
- case kSnWait:
- if (spr) {
- if (spr->seqTest(snc->_val) &&
- (snc->_val >= 0 || spr != _vm->_hero || _vm->_hero->_tracePtr < 0)) {
- _timerExpiry = g_system->getMillis() + spr->_time * kSnailFrameDelay;
- } else {
- _busy = false;
- return;
- }
- }
- break;
- case kSnLevel:
- _vm->snLevel(spr, snc->_val);
- break;
- case kSnHide:
- _vm->snHide(spr, snc->_val);
- break;
- case kSnSay:
- if (spr && _talkEnable) {
- if (spr == _vm->_hero && spr->seqTest(-1))
- spr->step(kSeqHTalk);
- _vm->_text->say(_vm->_text->getText(snc->_val), spr);
- _vm->_sys->_funDel = kHeroFun0;
- }
- break;
- case kSnInf:
- if (_talkEnable) {
- _vm->inf(_vm->_text->getText(snc->_val));
- _vm->_sys->_funDel = kHeroFun0;
- }
- break;
- case kSnTime:
- if (spr && _talkEnable) {
- if (spr == _vm->_hero && spr->seqTest(-1))
- spr->step(kSeqHTalk);
- _vm->_text->sayTime(spr);
- }
- break;
- case kSnCave:
- _vm->switchScene(snc->_val);
- break;
- case kSnKill:
- _vm->snKill(spr);
- break;
- case kSnSeq:
- _vm->snSeq(spr, snc->_val);
- break;
- case kSnRSeq:
- _vm->snRSeq(spr, snc->_val);
- break;
- case kSnSend:
- _vm->snSend(spr, snc->_val);
- break;
- case kSnSwap:
- _vm->snSwap(spr, snc->_val);
- break;
- case kSnCover:
- _vm->snCover(spr, snc->_val);
- break;
- case kSnUncover:
- _vm->snUncover(spr, (snc->_val >= 0) ? _vm->locate(snc->_val) : ((Sprite *) snc->_ptr));
- break;
- case kSnKeep:
- _vm->snKeep(spr, snc->_val);
- break;
- case kSnGive:
- _vm->snGive(spr, snc->_val);
- break;
- case kSnGame:
- _vm->snGame(spr, snc->_val);
- break;
- case kSnSetX0:
- _vm->snSetX0(snc->_ref, snc->_val);
- break;
- case kSnSetY0:
- _vm->snSetY0(snc->_ref, snc->_val);
- break;
- case kSnSetXY:
- _vm->snSetXY(spr, snc->_val);
- break;
- case kSnRelX:
- _vm->snRelX(spr, snc->_val);
- break;
- case kSnRelY:
- _vm->snRelY(spr, snc->_val);
- break;
- case kSnRelZ:
- _vm->snRelZ(spr, snc->_val);
- break;
- case kSnSetX:
- _vm->snSetX(spr, snc->_val);
- break;
- case kSnSetY:
- _vm->snSetY(spr, snc->_val);
- break;
- case kSnSetZ:
- _vm->snSetZ(spr, snc->_val);
- break;
- case kSnSlave:
- _vm->snSlave(spr, snc->_val);
- break;
- case kSnTrans:
- _vm->snTrans(spr, snc->_val);
- break;
- case kSnPort:
- _vm->snPort(spr, snc->_val);
- break;
- case kSnNext:
- case kSnIf:
- case kSnTalk:
- break;
- case kSnMouse:
- _vm->snMouse(snc->_val != 0);
- break;
- case kSnNNext:
- _vm->snNNext(spr, snc->_val);
- break;
- case kSnTNext:
- _vm->snTNext(spr, snc->_val);
- break;
- case kSnRNNext:
- _vm->snRNNext(spr, snc->_val);
- break;
- case kSnRTNext:
- _vm->snRTNext(spr, snc->_val);
- break;
- case kSnRMNear:
- _vm->snRmNear(spr);
- break;
- case kSnRmTake:
- _vm->snRmTake(spr);
- break;
- case kSnFlag:
- _vm->snFlag(snc->_ref & 3, snc->_val != 0);
- break;
- case kSnSetRef:
- _vm->snSetRef(spr, snc->_val);
- break;
- case kSnBackPt:
- _vm->snBackPt(spr, snc->_val);
- break;
- case kSnFlash:
- _vm->snFlash(snc->_val != 0);
- break;
- case kSnLight:
- _vm->snLight(snc->_val != 0);
- break;
- case kSnSetHBarrier:
- _vm->snHBarrier(snc->_ref, snc->_val);
- break;
- case kSnSetVBarrier:
- _vm->snVBarrier(snc->_ref, snc->_val);
- break;
- case kSnWalk:
- _vm->snWalk(spr, snc->_ref, snc->_val);
- break;
- case kSnReach:
- _vm->snReach(spr, snc->_val);
- break;
- case kSnSound:
- _vm->snSound(spr, snc->_val);
- break;
- case kSnCount:
- _vm->_sound->setRepeat(snc->_val);
- break;
- case kSnExec:
- switch (snc->_cbType) {
- case kQGame:
- _vm->qGame();
- break;
- case kMiniStep:
- _vm->miniStep(snc->_val);
- break;
- case kXScene:
- _vm->xScene();
- break;
- case kSndSetVolume:
- _vm->sndSetVolume();
- break;
- default:
- error("Unknown Callback Type in SNEXEC");
- }
- break;
- case kSnStep:
- spr->step();
- break;
- case kSnZTrim:
- _vm->snZTrim(spr);
- break;
- case kSnGhost:
- _vm->snGhost((Bitmap *) snc->_ptr);
- break;
- default:
- warning("Unhandled snc->_com in SNMouse(bool)");
- break;
- }
- _tail++;
- if (!_turbo)
- break;
- }
-
- _busy = false;
-}
-
-bool Snail::idle() {
- return (_head == _tail);
-}
-
} // End of namespace CGE
diff --git a/engines/cge/snail.h b/engines/cge/snail.h
index 481f0a5542..883c2b9766 100644
--- a/engines/cge/snail.h
+++ b/engines/cge/snail.h
@@ -53,11 +53,11 @@ enum SnCom {
class Snail {
public:
- struct Com {
+ struct Command {
SnCom _com;
int _ref;
int _val;
- void *_ptr;
+ void *_spritePtr;
CallbackType _cbType;
} *_snList;
static const char *_comText[];
@@ -65,10 +65,10 @@ public:
Snail(CGEEngine *vm, bool turbo);
~Snail();
- void runCom();
- void addCom(SnCom com, int ref, int val, void *ptr);
- void addCom2(SnCom com, int ref, int val, CallbackType cbType);
- void insCom(SnCom com, int ref, int val, void *ptr);
+ void runCommand();
+ void addCommand(SnCom com, int ref, int val, void *ptr);
+ void addCallback(SnCom com, int ref, int val, CallbackType cbType);
+ void insertCommand(SnCom com, int ref, int val, void *ptr);
bool idle();
private:
CGEEngine *_vm;
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index e5a1520bd2..64f9959442 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -142,8 +142,8 @@ void Text::say(const char *text, Sprite *spr) {
bool east = spr->_flags._east;
int x = (east) ? (spr->_x + spr->_w - 2) : (spr->_x + 2);
int y = spr->_y + 2;
- Sprite *spike = new Spike(_vm);
- uint16 sw = spike->_w;
+ Speaker *speaker = new Speaker(_vm);
+ uint16 sw = speaker->_w;
if (east) {
if (x + sw + kTextRoundCorner + 5 >= kScrWidth)
@@ -159,20 +159,20 @@ void Text::say(const char *text, Sprite *spr) {
_vm->_talk->_flags._kill = true;
_vm->_talk->_flags._bDel = true;
_vm->_talk->setName(_vm->_text->getText(kSayName));
- _vm->_talk->gotoxy(x - (_vm->_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _vm->_talk->_h + 1);
+ _vm->_talk->gotoxy(x - (_vm->_talk->_w - sw) / 2 - 3 + 6 * east, y - speaker->_h - _vm->_talk->_h + 1);
_vm->_talk->_z = 125;
_vm->_talk->_ref = kSayRef;
- spike->gotoxy(x, _vm->_talk->_y + _vm->_talk->_h - 1);
- spike->_z = 126;
- spike->_flags._slav = true;
- spike->_flags._kill = true;
- spike->setName(_vm->_text->getText(kSayName));
- spike->step(east);
- spike->_ref = kSayRef;
+ speaker->gotoxy(x, _vm->_talk->_y + _vm->_talk->_h - 1);
+ speaker->_z = 126;
+ speaker->_flags._slav = true;
+ speaker->_flags._kill = true;
+ speaker->setName(_vm->_text->getText(kSayName));
+ speaker->step(east);
+ speaker->_ref = kSayRef;
_vm->_vga->_showQ->insert(_vm->_talk, _vm->_vga->_showQ->last());
- _vm->_vga->_showQ->insert(spike, _vm->_vga->_showQ->last());
+ _vm->_vga->_showQ->insert(speaker, _vm->_vga->_showQ->last());
}
void CGEEngine::inf(const char *text) {
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index 531c5f1f71..02ed4ba74c 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -126,7 +126,7 @@ bool Sprite::works(Sprite *spr) {
if (!spr || !spr->_ext)
return false;
- Snail::Com *c = spr->_ext->_take;
+ Snail::Command *c = spr->_ext->_take;
if (c != NULL) {
c += spr->_takePtr;
if (c->_ref == _ref)
@@ -162,7 +162,7 @@ bool Sprite::seqTest(int n) {
return true;
}
-Snail::Com *Sprite::snList(SnList type) {
+Snail::Command *Sprite::snList(SnList type) {
SprExt *e = _ext;
if (e)
return (type == kNear) ? e->_near : e->_take;
@@ -208,8 +208,8 @@ Sprite *Sprite::expand() {
maxnow = 0,
maxnxt = 0;
- Snail::Com *nearList = NULL;
- Snail::Com *takeList = NULL;
+ Snail::Command *nearList = NULL;
+ Snail::Command *takeList = NULL;
_vm->mergeExt(fname, _file, kSprExt);
if (_vm->_resman->exist(fname)) { // sprite description file exist
EncryptedStream sprf(_vm, fname);
@@ -226,7 +226,7 @@ Sprite *Sprite::expand() {
if (len == 0 || *tmpStr == '.')
continue;
- Snail::Com *c;
+ Snail::Command *c;
switch (_vm->takeEnum(Comd, strtok(tmpStr, " =\t"))) {
case 0:
// Name
@@ -269,27 +269,27 @@ Sprite *Sprite::expand() {
// Near
if (_nearPtr == kNoPtr)
break;
- nearList = (Snail::Com *)realloc(nearList, (nearCount + 1) * sizeof(*nearList));
+ nearList = (Snail::Command *)realloc(nearList, (nearCount + 1) * sizeof(*nearList));
assert(nearList != NULL);
c = &nearList[nearCount++];
if ((c->_com = (SnCom)_vm->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,;/"));
- c->_ptr = NULL;
- break;
+ c->_spritePtr = NULL;
+ break;
case 4:
// Take
if (_takePtr == kNoPtr)
break;
- takeList = (Snail::Com *)realloc(takeList, (takeCount + 1) * sizeof(*takeList));
+ takeList = (Snail::Command *)realloc(takeList, (takeCount + 1) * sizeof(*takeList));
assert(takeList != NULL);
c = &takeList[takeCount++];
if ((c->_com = (SnCom)_vm->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,;/"));
- c->_ptr = NULL;
+ c->_spritePtr = NULL;
break;
}
}
@@ -316,11 +316,11 @@ Sprite *Sprite::expand() {
setShapeList(shapeList);
if (nearList)
- nearList[nearCount - 1]._ptr = _ext->_near = nearList;
+ nearList[nearCount - 1]._spritePtr = _ext->_near = nearList;
else
_nearPtr = kNoPtr;
if (takeList)
- takeList[takeCount - 1]._ptr = _ext->_take = takeList;
+ takeList[takeCount - 1]._spritePtr = _ext->_take = takeList;
else
_takePtr = kNoPtr;
@@ -982,7 +982,7 @@ SceneLight::SceneLight(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
setShapeList(PR);
}
-Spike::Spike(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) {
+Speaker::Speaker(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) {
// Set the sprite list
BitmapPtr *SP = new BitmapPtr[3];
SP[0] = new Bitmap(_vm, "SPK_L");
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index 01b1d0ead4..b64920acb7 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -69,8 +69,8 @@ public:
BitmapPtr *_shpList;
Seq *_seq;
char *_name;
- Snail::Com *_near;
- Snail::Com *_take;
+ Snail::Command *_near;
+ Snail::Command *_take;
SprExt() :
_x0(0), _y0(0),
_x1(0), _y1(0),
@@ -146,7 +146,7 @@ public:
void killXlat();
void step(int nr = -1);
Seq *setSeq(Seq *seq);
- Snail::Com *snList(SnList type);
+ Snail::Command *snList(SnList type);
virtual void touch(uint16 mask, int x, int y);
virtual void tick();
void sync(Common::Serializer &s);
@@ -226,10 +226,10 @@ public:
SceneLight(CGEEngine *vm);
};
-class Spike: public Sprite {
+class Speaker: public Sprite {
CGEEngine *_vm;
public:
- Spike(CGEEngine *vm);
+ Speaker(CGEEngine *vm);
};
class PocLight: public Sprite {
diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp
index 76d6850174..2303d0fafa 100644
--- a/engines/cge/vmenu.cpp
+++ b/engines/cge/vmenu.cpp
@@ -112,7 +112,7 @@ void Vmenu::touch(uint16 mask, int x, int y) {
if (ok && (mask & kMouseLeftUp)) {
_items = 0;
- _vm->_snail_->addCom(kSnKill, -1, 0, this);
+ _vm->_snail_->addCommand(kSnKill, -1, 0, this);
_recent = n;
assert(_menu[n].Proc);
CALL_MEMBER_FN(*_vm, _menu[n].Proc)();
diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp
index 04c85a4c6a..64f75983c3 100644
--- a/engines/cge/walk.cpp
+++ b/engines/cge/walk.cpp
@@ -103,7 +103,7 @@ void Walk::tick() {
} else {
// take current Z position
_z = _here._pt.y;
- _vm->_snail_->addCom(kSnZTrim, -1, 0, this); // update Hero's pos in show queue
+ _vm->_snail_->addCommand(kSnZTrim, -1, 0, this); // update Hero's pos in show queue
}
}
@@ -195,10 +195,10 @@ void Walk::reach(Sprite *spr, int mode) {
}
}
// note: insert SNAIL commands in reverse order
- _vm->_snail->insCom(kSnPause, -1, 64, NULL);
- _vm->_snail->insCom(kSnSeq, -1, kTSeq + mode, this);
+ _vm->_snail->insertCommand(kSnPause, -1, 64, NULL);
+ _vm->_snail->insertCommand(kSnSeq, -1, kTSeq + mode, this);
if (spr) {
- _vm->_snail->insCom(kSnWait, -1, -1, _vm->_hero);
+ _vm->_snail->insertCommand(kSnWait, -1, -1, _vm->_hero);
//SNINSERT(SNWALK, -1, -1, spr);
}
// sequence is not finished,