aboutsummaryrefslogtreecommitdiff
path: root/engines/cge
diff options
context:
space:
mode:
authorAlyssa Milburn2011-08-20 00:11:30 +0200
committerAlyssa Milburn2011-08-20 00:11:30 +0200
commitc1807138fbb9dca4ff2d59f8c5ed39385716c6a0 (patch)
tree016158f1e366182b47457dc441e3bfbddc658ed1 /engines/cge
parent3917c116915ccb1e5fa2f37ae7a3ef86ac6661a2 (diff)
downloadscummvm-rg350-c1807138fbb9dca4ff2d59f8c5ed39385716c6a0.tar.gz
scummvm-rg350-c1807138fbb9dca4ff2d59f8c5ed39385716c6a0.tar.bz2
scummvm-rg350-c1807138fbb9dca4ff2d59f8c5ed39385716c6a0.zip
CGE: Cleanup of snail.cpp.
Diffstat (limited to 'engines/cge')
-rw-r--r--engines/cge/snail.cpp1025
-rw-r--r--engines/cge/snail.h1
2 files changed, 508 insertions, 518 deletions
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index ea8e480b35..ef766b9a4e 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -40,7 +40,7 @@ void CGEEngine::snGame(Sprite *spr, int num) {
debugC(1, kCGEDebugEngine, "CGEEngine::snGame(spr, %d)", num);
switch (num) {
- case 1 : {
+ case 1: {
static Sprite *dup[3] = { NULL, NULL, NULL };
int buref = 0;
int Stage = 0;
@@ -125,10 +125,9 @@ void CGEEngine::snGame(Sprite *spr, int num) {
_snail->addCom(kSnSay, buref, 16008, NULL); // zgadnij!
_game = true;
}
- }
- break;
- //--------------------------------------------------------------------
- case 2 : {
+ }
+ break;
+ case 2:
if (_sprTv == NULL) {
_sprTv = _vga->_showQ->locate(20700);
_sprK1 = _vga->_showQ->locate(20701);
@@ -139,105 +138,108 @@ void CGEEngine::snGame(Sprite *spr, int num) {
if (!_game) { // init
_snail->addCom(kSnGame, 20002, 2, NULL);
_game = true;
- } else { // cont
- _sprK1->step(newRandom(6));
- _sprK2->step(newRandom(6));
- _sprK3->step(newRandom(6));
- ///--------------------
- if (spr->_ref == 1 && _keyboard->_key[kKeyAlt]) {
- _sprK1->step(5);
- _sprK2->step(5);
- _sprK3->step(5);
- }
- ///--------------------
- _snail->addCom(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);
- _game = false;
- return;
- } else
- _sprK3->step(newRandom(5));
- }
- if (_gameCase2Cpt < 100) {
- switch (_gameCase2Cpt) {
- case 15 :
- _snail->addCom(kSnSay, 20003, 20021, NULL);
- break;
- case 30 :
- case 45 :
- case 60 :
- case 75 :
- _snail->addCom(kSnSay, 20003, 20022, NULL);
- break;
- }
- _gameCase2Cpt++;
- }
- 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!
- 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!
+ break;
+ }
+
+ // cont
+ _sprK1->step(newRandom(6));
+ _sprK2->step(newRandom(6));
+ _sprK3->step(newRandom(6));
+
+ if (spr->_ref == 1 && _keyboard->_key[kKeyAlt]) {
+ _sprK1->step(5);
+ _sprK2->step(5);
+ _sprK3->step(5);
+ }
+
+ _snail->addCom(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);
+ _game = false;
+ return;
+ } else
+ _sprK3->step(newRandom(5));
+ }
+
+ if (_gameCase2Cpt < 100) {
+ switch (_gameCase2Cpt) {
+ case 15:
+ _snail->addCom(kSnSay, 20003, 20021, NULL);
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!
+ case 30:
+ case 45:
+ case 60:
+ case 75:
+ _snail->addCom(kSnSay, 20003, 20022, NULL);
break;
}
+ _gameCase2Cpt++;
+ }
+
+ 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!
+ 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!
+ 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!
+ break;
}
- }
- break;
}
}
-
void CGEEngine::expandSprite(Sprite *spr) {
debugC(5, kCGEDebugEngine, "CGEEngine::expandSprite(spr)");
@@ -245,7 +247,6 @@ void CGEEngine::expandSprite(Sprite *spr) {
_vga->_showQ->insert(_vga->_spareQ->remove(spr));
}
-
void CGEEngine::contractSprite(Sprite *spr) {
debugC(1, kCGEDebugEngine, "CGEEngine::contractSprite(spr)");
@@ -257,12 +258,11 @@ int CGEEngine::findPocket(Sprite *spr) {
debugC(1, kCGEDebugEngine, "CGEEngine::findPocket(spr)");
for (int i = 0; i < kPocketNX; i++)
- if (_pocket[i] == spr)
- return i;
+ if (_pocket[i] == spr)
+ return i;
return -1;
}
-
void CGEEngine::selectPocket(int n) {
debugC(1, kCGEDebugEngine, "CGEEngine::selectPocket(%d)", n);
@@ -309,76 +309,77 @@ void CGEEngine::snGhost(Bitmap *bmp) {
void CGEEngine::feedSnail(Sprite *spr, SnList snq) {
debugC(1, kCGEDebugEngine, "CGEEngine::feedSnail(spr, snq)");
- if (spr)
- if (spr->active()) {
- uint8 ptr = (snq == kTake) ? spr->_takePtr : spr->_nearPtr;
-
- if (ptr != NO_PTR) {
- Snail::Com *comtab = spr->snList(snq);
- Snail::Com *c = comtab + ptr;
-
- if (findPocket(NULL) < 0) { // no empty pockets?
- Snail::Com *p;
- for (p = c; p->_com != kSnNext; p++) { // find KEEP command
- if (p->_com == kSnKeep) {
- pocFul();
- return;
- }
- if (p->_ptr)
- break;
- }
- }
- while (true) {
- if (c->_com == kSnTalk) {
- if ((_snail->_talkEnable = (c->_val != 0)) == false)
- killText();
- }
- if (c->_com == kSnNext) {
- Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref);
- if (s) {
- uint8 *idx = (snq == kTake) ? &s->_takePtr : &s->_nearPtr;
- if (*idx != NO_PTR) {
- int v;
- switch (c->_val) {
- case -1 :
- v = c - comtab + 1;
- break;
- case -2 :
- v = c - comtab;
- break;
- case -3 :
- v = -1;
- break;
- default :
- v = c->_val;
- break;
- }
- if (v >= 0)
- *idx = v;
- }
- }
- if (s == spr)
- break;
- }
- if (c->_com == kSnIf) {
- Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref);
- if (s) { // sprite extsts
- if (! s->seqTest(-1))
- c = comtab + c->_val; // not parked
- else
- ++c;
- } else
- ++c;
- } else {
- _snail->addCom(c->_com, c->_ref, c->_val, spr);
- if (c->_ptr)
- break;
- else
- c++;
+ if (!spr || !spr->active())
+ return;
+
+ uint8 ptr = (snq == kTake) ? spr->_takePtr : spr->_nearPtr;
+
+ if (ptr == NO_PTR)
+ return;
+
+ Snail::Com *comtab = spr->snList(snq);
+ Snail::Com *c = comtab + ptr;
+
+ if (findPocket(NULL) < 0) { // no empty pockets?
+ Snail::Com *p;
+ for (p = c; p->_com != kSnNext; p++) { // find KEEP command
+ if (p->_com == kSnKeep) {
+ pocFul();
+ return;
+ }
+ if (p->_ptr)
+ break;
+ }
+ }
+ while (true) {
+ if (c->_com == kSnTalk) {
+ if ((_snail->_talkEnable = (c->_val != 0)) == false)
+ killText();
+ }
+ if (c->_com == kSnNext) {
+ Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref);
+ if (s) {
+ uint8 *idx = (snq == kTake) ? &s->_takePtr : &s->_nearPtr;
+ if (*idx != NO_PTR) {
+ int v;
+ switch (c->_val) {
+ case -1 :
+ v = c - comtab + 1;
+ break;
+ case -2 :
+ v = c - comtab;
+ break;
+ case -3 :
+ v = -1;
+ break;
+ default :
+ v = c->_val;
+ break;
}
+ if (v >= 0)
+ *idx = v;
}
}
+ if (s == spr)
+ break;
+ }
+ if (c->_com == kSnIf) {
+ Sprite *s = (c->_ref < 0) ? spr : locate(c->_ref);
+ if (s) { // sprite extsts
+ if (! s->seqTest(-1))
+ c = comtab + c->_val; // not parked
+ else
+ ++c;
+ } else
+ ++c;
+ } else {
+ _snail->addCom(c->_com, c->_ref, c->_val, spr);
+ if (c->_ptr)
+ break;
+ else
+ c++;
}
+ }
}
const char *Snail::_comText[] = {
@@ -395,7 +396,6 @@ const char *Snail::_comText[] = {
"MOUSE", "SOUND", "COUNT", NULL
};
-
Snail::Snail(CGEEngine *vm, bool turbo)
: _turbo(turbo), _busy(false), _textDelay(false),
_timerExpiry(0), _talkEnable(true),
@@ -490,16 +490,15 @@ void CGEEngine::snRTNext(Sprite *spr, int p) {
void CGEEngine::snZTrim(Sprite *spr) {
debugC(4, kCGEDebugEngine, "CGEEngine::snZTrim(spr)");
- if (spr)
- if (spr->active()) {
- Sprite *s;
- s = (spr->_flags._shad) ? spr->_prev : NULL;
- _vga->_showQ->insert(_vga->_showQ->remove(spr));
- if (s) {
- s->_z = spr->_z;
- _vga->_showQ->insert(_vga->_showQ->remove(s), spr);
- }
- }
+ if (!spr || !spr->active())
+ return;
+
+ Sprite *s = (spr->_flags._shad) ? spr->_prev : NULL;
+ _vga->_showQ->insert(_vga->_showQ->remove(spr));
+ if (s) {
+ s->_z = spr->_z;
+ _vga->_showQ->insert(_vga->_showQ->remove(s), spr);
+ }
}
void CGEEngine::snHide(Sprite *spr, int val) {
@@ -547,30 +546,31 @@ void CGEEngine::snRSeq(Sprite *spr, int val) {
void CGEEngine::snSend(Sprite *spr, int val) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSend(spr, %d)", val);
- if (spr) {
- int was = spr->_cave;
- bool was1 = (was == 0 || was == _now);
- bool val1 = (val == 0 || val == _now);
- spr->_cave = val;
- if (val1 != was1) {
- if (was1) {
- if (spr->_flags._kept) {
- int n = findPocket(spr);
- if (n >= 0)
- _pocket[n] = NULL;
- }
- hide1(spr);
- contractSprite(spr);
- spr->_flags._slav = false;
- } else {
- if (spr->_ref % 1000 == 0)
- Bitmap::_pal = Vga::_sysPal;
- if (spr->_flags._back)
- spr->backShow(true);
- else
- expandSprite(spr);
- Bitmap::_pal = NULL;
+ if (!spr)
+ return;
+
+ int was = spr->_cave;
+ bool was1 = (was == 0 || was == _now);
+ bool val1 = (val == 0 || val == _now);
+ spr->_cave = val;
+ if (val1 != was1) {
+ if (was1) {
+ if (spr->_flags._kept) {
+ int n = findPocket(spr);
+ if (n >= 0)
+ _pocket[n] = NULL;
}
+ hide1(spr);
+ contractSprite(spr);
+ spr->_flags._slav = false;
+ } else {
+ if (spr->_ref % 1000 == 0)
+ Bitmap::_pal = Vga::_sysPal;
+ if (spr->_flags._back)
+ spr->backShow(true);
+ else
+ expandSprite(spr);
+ Bitmap::_pal = NULL;
}
}
}
@@ -579,77 +579,77 @@ void CGEEngine::snSwap(Sprite *spr, int xref) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSwap(spr, %d)", xref);
Sprite *xspr = locate(xref);
- if (spr && xspr) {
- int was = spr->_cave;
- int xwas = xspr->_cave;
- bool was1 = (was == 0 || was == _now);
- bool xwas1 = (xwas == 0 || xwas == _now);
-
- swap(spr->_cave, xspr->_cave);
- swap(spr->_x, xspr->_x);
- swap(spr->_y, xspr->_y);
- swap(spr->_z, xspr->_z);
- if (spr->_flags._kept) {
- int n = findPocket(spr);
- if (n >= 0)
- _pocket[n] = xspr;
- xspr->_flags._kept = true;
- xspr->_flags._port = false;
- }
- if (xwas1 != was1) {
- if (was1) {
- hide1(spr);
- contractSprite(spr);
- } else
- expandSprite(spr);
- if (xwas1) {
- hide1(xspr);
- contractSprite(xspr);
- } else
- expandSprite(xspr);
- }
+ if (!spr || !xspr)
+ return;
+
+ int was = spr->_cave;
+ int xwas = xspr->_cave;
+ bool was1 = (was == 0 || was == _now);
+ bool xwas1 = (xwas == 0 || xwas == _now);
+
+ swap(spr->_cave, xspr->_cave);
+ swap(spr->_x, xspr->_x);
+ swap(spr->_y, xspr->_y);
+ swap(spr->_z, xspr->_z);
+ if (spr->_flags._kept) {
+ int n = findPocket(spr);
+ if (n >= 0)
+ _pocket[n] = xspr;
+ xspr->_flags._kept = true;
+ xspr->_flags._port = false;
+ }
+ if (xwas1 != was1) {
+ if (was1) {
+ hide1(spr);
+ contractSprite(spr);
+ } else
+ expandSprite(spr);
+ if (xwas1) {
+ hide1(xspr);
+ contractSprite(xspr);
+ } else
+ expandSprite(xspr);
}
}
-
void CGEEngine::snCover(Sprite *spr, int xref) {
debugC(1, kCGEDebugEngine, "CGEEngine::snCover(spr, %d)", xref);
Sprite *xspr = locate(xref);
- if (spr && xspr) {
- spr->_flags._hide = true;
- xspr->_z = spr->_z;
- xspr->_cave = spr->_cave;
- xspr->gotoxy(spr->_x, spr->_y);
- expandSprite(xspr);
- if ((xspr->_flags._shad = spr->_flags._shad) == 1) {
- _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr);
- spr->_flags._shad = false;
- }
- feedSnail(xspr, kNear);
+ if (!spr || !xspr)
+ return;
+
+ spr->_flags._hide = true;
+ xspr->_z = spr->_z;
+ xspr->_cave = spr->_cave;
+ xspr->gotoxy(spr->_x, spr->_y);
+ expandSprite(xspr);
+ if ((xspr->_flags._shad = spr->_flags._shad) == 1) {
+ _vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr);
+ spr->_flags._shad = false;
}
+ feedSnail(xspr, kNear);
}
-
void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) {
debugC(1, kCGEDebugEngine, "CGEEngine::snUncover(spr, xspr)");
- if (spr && xspr) {
- spr->_flags._hide = false;
- spr->_cave = xspr->_cave;
- spr->gotoxy(xspr->_x, xspr->_y);
- if ((spr->_flags._shad = xspr->_flags._shad) == 1) {
- _vga->_showQ->insert(_vga->_showQ->remove(xspr->_prev), spr);
- xspr->_flags._shad = false;
- }
- spr->_z = xspr->_z;
- snSend(xspr, -1);
- if (spr->_time == 0)
- spr->_time++;
+ if (!spr || !xspr)
+ return;
+
+ spr->_flags._hide = false;
+ spr->_cave = xspr->_cave;
+ spr->gotoxy(xspr->_x, xspr->_y);
+ if ((spr->_flags._shad = xspr->_flags._shad) == 1) {
+ _vga->_showQ->insert(_vga->_showQ->remove(xspr->_prev), spr);
+ xspr->_flags._shad = false;
}
+ spr->_z = xspr->_z;
+ snSend(xspr, -1);
+ if (spr->_time == 0)
+ spr->_time++;
}
-
void CGEEngine::snSetX0(int cav, int x0) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSetX0(%d, %d)", cav, x0);
@@ -683,7 +683,6 @@ void CGEEngine::snRelY(Sprite *spr, int y) {
spr->gotoxy(spr->_x, _hero->_y + y);
}
-
void CGEEngine::snRelZ(Sprite *spr, int z) {
debugC(1, kCGEDebugEngine, "CGEEngine::snRelZ(spr, %d)", z);
@@ -693,7 +692,6 @@ void CGEEngine::snRelZ(Sprite *spr, int z) {
}
}
-
void CGEEngine::snSetX(Sprite *spr, int x) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSetX(spr, %d)", x);
@@ -701,7 +699,6 @@ void CGEEngine::snSetX(Sprite *spr, int x) {
spr->gotoxy(x, spr->_y);
}
-
void CGEEngine::snSetY(Sprite *spr, int y) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSetY(spr, %d)", y);
@@ -709,7 +706,6 @@ void CGEEngine::snSetY(Sprite *spr, int y) {
spr->gotoxy(spr->_x, y);
}
-
void CGEEngine::snSetZ(Sprite *spr, int z) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSetZ(spr, %d)", z);
@@ -720,7 +716,6 @@ void CGEEngine::snSetZ(Sprite *spr, int z) {
}
}
-
void CGEEngine::snSlave(Sprite *spr, int ref) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSlave(spr, %d)", ref);
@@ -735,7 +730,6 @@ void CGEEngine::snSlave(Sprite *spr, int ref) {
}
}
-
void CGEEngine::snTrans(Sprite *spr, int trans) {
debugC(1, kCGEDebugEngine, "CGEEngine::snTrans(spr, %d)", trans);
@@ -753,30 +747,30 @@ void CGEEngine::snPort(Sprite *spr, int port) {
void CGEEngine::snKill(Sprite *spr) {
debugC(1, kCGEDebugEngine, "CGEEngine::snKill(spr)");
- if (spr) {
- if (spr->_flags._kept) {
- int n = findPocket(spr);
- if (n >= 0)
- _pocket[n] = NULL;
- }
- Sprite *nx = spr->_next;
- hide1(spr);
- _vga->_showQ->remove(spr);
- _eventManager->clearEvent(spr);
- if (spr->_flags._kill)
- delete spr;
- else {
- spr->_cave = -1;
- _vga->_spareQ->append(spr);
- }
- if (nx) {
- if (nx->_flags._slav)
- snKill(nx);
- }
+ if (!spr)
+ return;
+
+ if (spr->_flags._kept) {
+ int n = findPocket(spr);
+ if (n >= 0)
+ _pocket[n] = NULL;
+ }
+ Sprite *nx = spr->_next;
+ hide1(spr);
+ _vga->_showQ->remove(spr);
+ _eventManager->clearEvent(spr);
+ if (spr->_flags._kill) {
+ delete spr;
+ } else {
+ spr->_cave = -1;
+ _vga->_spareQ->append(spr);
+ }
+ if (nx) {
+ if (nx->_flags._slav)
+ snKill(nx);
}
}
-
void CGEEngine::snSound(Sprite *spr, int wav, int cnt) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt);
@@ -786,7 +780,6 @@ void CGEEngine::snSound(Sprite *spr, int wav, int cnt) {
_sound->play((*_fx)[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt);
}
-
void CGEEngine::snKeep(Sprite *spr, int stp) {
debugC(1, kCGEDebugEngine, "CGEEngine::snKeep(spr, %d)", stp);
@@ -846,7 +839,6 @@ void CGEEngine::snLevel(Sprite *spr, int lev) {
spr->_flags._hide = false;
}
-
void CGEEngine::snFlag(int indx, bool v) {
_flag[indx] = v;
}
@@ -881,7 +873,6 @@ void CGEEngine::snFlash(bool on) {
_dark = false;
}
-
void CGEEngine::snLight(bool in) {
debugC(1, kCGEDebugEngine, "CGEEngine::snLight(%s)", in ? "true" : "false");
@@ -889,7 +880,7 @@ void CGEEngine::snLight(bool in) {
_vga->sunrise(Vga::_sysPal);
else
_vga->sunset();
- _dark = ! in;
+ _dark = !in;
}
void CGEEngine::snBarrier(int cav, int bar, bool horz) {
@@ -925,254 +916,254 @@ void CGEEngine::snMouse(bool on) {
_mouse->off();
}
-
void Snail::runCom() {
static int count = 1;
- if (!_busy) {
- _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) {
- killText();
- _textDelay = false;
- }
- }
- if (_talk && snc->_com != kSnPause)
+ 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;
- }
- Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr));
- switch (snc->_com) {
- case kSnLabel:
- break;
- case kSnPause :
- _timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay;
- if (_talk)
- _textDelay = true;
- break;
- case kSnWait:
- if (spr) {
- if (spr->seqTest(snc->_val) &&
- (snc->_val >= 0 || spr != _hero || _hero->_tracePtr < 0)) {
- _timerExpiry = g_system->getMillis() + spr->_time * kSnailFrameDelay;
- } else
- goto xit;
- }
- break;
- case kSnLevel:
- _vm->snLevel(spr, snc->_val);
- break;
- case kSnHide:
- _vm->snHide(spr, snc->_val);
- break;
- case kSnSay:
- if (spr && _talkEnable) {
- if (spr == _hero && spr->seqTest(-1))
- spr->step(kSeqHTalk);
- _text->say(_text->getText(snc->_val), spr);
- _sys->_funDel = kHeroFun0;
- }
- break;
- case kSnInf:
- if (_talkEnable) {
- _vm->inf(_text->getText(snc->_val));
- _sys->_funDel = kHeroFun0;
- }
- break;
- case kSnTime:
- if (spr && _talkEnable) {
- if (spr == _hero && spr->seqTest(-1))
- spr->step(kSeqHTalk);
- _text->sayTime(spr);
+ // Delay is finished
+ _timerExpiry = 0;
+ } else {
+ if (_textDelay) {
+ killText();
+ _textDelay = false;
}
+ }
+ if (_talk && snc->_com != kSnPause)
break;
- case kSnCave:
- _vm->switchCave(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) ? 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->snBarrier(snc->_ref, snc->_val, true);
- break;
- case kSnSetVBarrier:
- _vm->snBarrier(snc->_ref, snc->_val, false);
- 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, count);
- count = 1;
- break;
- case kSnCount:
- count = snc->_val;
+ }
+
+ Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr));
+ switch (snc->_com) {
+ case kSnLabel:
+ break;
+ case kSnPause :
+ _timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay;
+ if (_talk)
+ _textDelay = true;
+ break;
+ case kSnWait:
+ if (spr) {
+ if (spr->seqTest(snc->_val) &&
+ (snc->_val >= 0 || spr != _hero || _hero->_tracePtr < 0)) {
+ _timerExpiry = g_system->getMillis() + spr->_time * kSnailFrameDelay;
+ } else
+ goto xit;
+ }
+ break;
+ case kSnLevel:
+ _vm->snLevel(spr, snc->_val);
+ break;
+ case kSnHide:
+ _vm->snHide(spr, snc->_val);
+ break;
+ case kSnSay:
+ if (spr && _talkEnable) {
+ if (spr == _hero && spr->seqTest(-1))
+ spr->step(kSeqHTalk);
+ _text->say(_text->getText(snc->_val), spr);
+ _sys->_funDel = kHeroFun0;
+ }
+ break;
+ case kSnInf:
+ if (_talkEnable) {
+ _vm->inf(_text->getText(snc->_val));
+ _sys->_funDel = kHeroFun0;
+ }
+ break;
+ case kSnTime:
+ if (spr && _talkEnable) {
+ if (spr == _hero && spr->seqTest(-1))
+ spr->step(kSeqHTalk);
+ _text->sayTime(spr);
+ }
+ break;
+ case kSnCave:
+ _vm->switchCave(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) ? 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->snBarrier(snc->_ref, snc->_val, true);
+ break;
+ case kSnSetVBarrier:
+ _vm->snBarrier(snc->_ref, snc->_val, false);
+ 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, count);
+ count = 1;
+ break;
+ case kSnCount:
+ count = snc->_val;
+ break;
+ case kSnExec:
+ switch (snc->_cbType) {
+ case kQGame:
+ _vm->qGame();
break;
- case kSnExec:
- switch (snc->_cbType) {
- case kQGame:
- _vm->qGame();
- break;
- case kMiniStep:
- _vm->miniStep(snc->_val);
- break;
- case kXCave:
- _vm->xCave();
- break;
- case kSelectSound:
- warning("TODO: Select sound card");
- break;
- case kSnSelect:
- warning("TODO: Sound card selection");
- break;
- case kSndSetVolume:
- sndSetVolume();
- break;
- default:
- error("Unknown Callback Type in SNEXEC");
- }
+ case kMiniStep:
+ _vm->miniStep(snc->_val);
break;
- case kSnStep:
- spr->step();
+ case kXCave:
+ _vm->xCave();
break;
- case kSnZTrim:
- _vm->snZTrim(spr);
+ case kSelectSound:
+ warning("TODO: Select sound card");
break;
- case kSnGhost:
- _vm->snGhost((Bitmap *) snc->_ptr);
+ case kSnSelect:
+ warning("TODO: Sound card selection");
break;
- default :
- warning("Unhandled snc->_com in SNMouse(bool)");
+ case kSndSetVolume:
+ sndSetVolume();
break;
+ default:
+ error("Unknown Callback Type in SNEXEC");
}
- _tail++;
- if (!_turbo)
- break;
+ 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;
}
-xit:
- _busy = false;
+ _tail++;
+ if (!_turbo)
+ break;
}
+xit:
+ _busy = false;
}
-
bool Snail::idle() {
return (_head == _tail);
}
diff --git a/engines/cge/snail.h b/engines/cge/snail.h
index 2d12963f2c..e478ad95ff 100644
--- a/engines/cge/snail.h
+++ b/engines/cge/snail.h
@@ -80,7 +80,6 @@ private:
CGEEngine *_vm;
};
-
} // End of namespace CGE
#endif