aboutsummaryrefslogtreecommitdiff
path: root/engines/cge2
diff options
context:
space:
mode:
authoruruk2014-06-17 15:37:55 +0200
committeruruk2014-06-17 15:37:55 +0200
commit186d90e5b58c09e04f570b51f97a7bd3315dcbde (patch)
tree89ad609f7854fa078c0a76b6b0be13c0838d739e /engines/cge2
parent40262bad980ffb0a86492e67c5430b24e6454438 (diff)
downloadscummvm-rg350-186d90e5b58c09e04f570b51f97a7bd3315dcbde.tar.gz
scummvm-rg350-186d90e5b58c09e04f570b51f97a7bd3315dcbde.tar.bz2
scummvm-rg350-186d90e5b58c09e04f570b51f97a7bd3315dcbde.zip
CGE2: Implement switching between scenes.
Minor modification in Spare again to do so.
Diffstat (limited to 'engines/cge2')
-rw-r--r--engines/cge2/cge2.cpp1
-rw-r--r--engines/cge2/cge2.h14
-rw-r--r--engines/cge2/cge2_main.cpp70
-rw-r--r--engines/cge2/snail.cpp41
-rw-r--r--engines/cge2/spare.cpp2
5 files changed, 115 insertions, 13 deletions
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp
index 135f786de0..96beff7195 100644
--- a/engines/cge2/cge2.cpp
+++ b/engines/cge2/cge2.cpp
@@ -96,6 +96,7 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_flag[i] = false;
_sayCap = true;
_sayVox = true;
+ _req = 1;
}
void CGE2Engine::init() {
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index e19ca576d3..bc4a16c33f 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -78,8 +78,11 @@ class Map;
#define kPocketsWidth 59
#define kLineMax 512
+#define kExitOkText 40
+#define kCrackedText 44
+
enum CallbackType {
- kNullCB = 0, kQGame, kMiniStep, kXScene, kSoundSetVolume
+ kNullCB = 0, kQGame, kXScene, kSoundSetVolume
};
enum Action { kNear, kMTake, kFTake, kActions };
@@ -108,7 +111,9 @@ public:
void loadSprite(const char *fname, int ref, int scene, V3D &pos);
void badLab(const char *fn);
void sceneUp(int cav);
- void switchScene(int cav);
+ void sceneDown();
+ void closePocket();
+ void switchScene(int scene);
void showBak(int ref);
void loadTab();
int newRandom(int range);
@@ -126,7 +131,6 @@ public:
bool isHero(Sprite *spr);
void loadUser();
void checkSaySwitch();
- void qGame();
void loadPos();
void releasePocket(Sprite *spr);
void switchHero(int sex);
@@ -194,6 +198,9 @@ public:
void hide1(Sprite *spr);
Sprite *expandSprite(Sprite *spr);
+ void qGame();
+ void xScene();
+ void sndSetVolume();
const ADGameDescription *_gameDescription;
@@ -219,6 +226,7 @@ public:
bool _flag[4];
bool _sayCap;
bool _sayVox;
+ int _req;
ResourceManager *_resman;
Vga *_vga;
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index c0b41e4756..0fc2d5af71 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -459,8 +459,69 @@ void CGE2Engine::sceneUp(int cav) {
//setDrawColors(); - It's only for debugging purposes. Can be left out for now.
}
-void CGE2Engine::switchScene(int cav) {
- warning("STUB: CGE2Engine::switchScene()");
+void CGE2Engine::sceneDown() {
+ busy(true);
+ _commandStat._wait = nullptr; // unlock snail
+ Sprite *spr = _vga->_showQ->locate((_now << 8) | 254);
+ if (spr)
+ feedSnail(spr, kNear, _heroTab[_sex]->_ptr);
+ while (!(_commandHandler->idle() && _commandHandlerTurbo->idle())) {
+ _commandHandlerTurbo->runCommand();
+ _commandHandler->runCommand();
+ }
+ closePocket();
+ for (int i = 0; i < 2; i++)
+ _spare->update(_vga->_showQ->remove(_heroTab[i]->_ptr));
+ _spare->dispose();
+}
+
+void CGE2Engine::closePocket() {
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < kPocketMax + 1; j++) {
+ Sprite *spr = _heroTab[i]->_pocket[j];
+ _heroTab[i]->_pocket[j] = (Sprite*)((spr) ? spr->_ref : -1);
+ }
+ }
+}
+
+void CGE2Engine::switchScene(int scene) {
+ if (scene == _now)
+ return;
+
+ if (scene >= 0) {
+ if (!_flag[2]) // PROT
+ _flag[2] = true;
+ else {
+ int t = _text->getText(kCrackedText) ? kCrackedText : kExitOkText;
+ _commandHandler->addCommand(kCmdInf, -1, t, nullptr);
+ return;
+ }
+ }
+
+ _req = scene;
+ for (int i = 0; i < 2; i++) {
+ Hero *h = _heroTab[i]->_ptr;
+ if (h->_scene == _now) {
+ delete _heroTab[i]->_posTab[_now];
+ V2D *temp = new V2D(this, h->_pos3D._x.trunc(), h->_pos3D._z.trunc());
+ _heroTab[i]->_posTab[_now] = temp;
+ }
+ }
+ *(_eyeTab[_now]) = *_eye;
+ if (scene < 0)
+ _commandHandler->addCallback(kCmdExec, -1, 0, kQGame); // quit game
+ else {
+ if (_heroTab[_sex]->_ptr->_scene == _now) {
+ _heroTab[_sex]->_ptr->setScene(scene);
+ if (_heroTab[!_sex]->_ptr->_scene == _now)
+ _heroTab[!_sex]->_ptr->setScene(scene);
+ }
+ _mouse->off();
+ if (_heroTab[_sex]->_ptr)
+ _heroTab[_sex]->_ptr->park();
+ killText();
+ _commandHandler->addCallback(kCmdExec, -1, 0, kXScene); // switch scene
+ }
}
void CGE2Engine::showBak(int ref) {
@@ -701,11 +762,6 @@ void CGE2Engine::checkSaySwitch() {
warning("STUB: CGE2Engine::checkSaySwitch()");
}
-void CGE2Engine::qGame() {
- warning("STUB: CGE2Engine::qGame()");
- _endGame = true;
-}
-
void CGE2Engine::loadTab() {
setEye(_text->getText(240));
for (int i = 0; i < kSceneMax; i++)
diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp
index 068ccf86d5..d799f28cc1 100644
--- a/engines/cge2/snail.cpp
+++ b/engines/cge2/snail.cpp
@@ -301,7 +301,20 @@ void CommandHandler::runCommand() {
_vm->snDim(spr, tailCmd._val);
break;
case kCmdExec:
- warning("Unhandled command - kCmdExec");
+ switch (tailCmd._cbType) {
+ case kQGame:
+ _vm->qGame();
+ break;
+ case kXScene:
+ _vm->xScene();
+ break;
+ case kSoundSetVolume:
+ _vm->sndSetVolume();
+ break;
+ default:
+ error("Unknown Callback Type in SNEXEC");
+ break;
+ }
break;
case kCmdStep:
spr->step();
@@ -638,6 +651,20 @@ Sprite *CGE2Engine::expandSprite(Sprite *spr) {
return spr;
}
+void CGE2Engine::qGame() {
+ warning("STUB: CGE2Engine::qGame()");
+ _endGame = true;
+}
+
+void CGE2Engine::xScene() {
+ sceneDown();
+ sceneUp(_req);
+}
+
+void CGE2Engine::sndSetVolume() {
+ warning("STUB: CGE2Engine::sndSetVolume()");
+}
+
void CommandHandler::addCommand(CommandType com, int ref, int val, void *ptr) {
if (ref == 2)
ref = 142 - _vm->_sex;
@@ -653,7 +680,17 @@ void CommandHandler::addCommand(CommandType com, int ref, int val, void *ptr) {
}
void CommandHandler::addCallback(CommandType com, int ref, int val, CallbackType cbType) {
- warning("STUB: CommandHandler::addCallback()");
+ Command *headCmd = &_commandList[_head++];
+ headCmd->_commandType = com;
+ headCmd->_ref = ref;
+ headCmd->_val = val;
+ headCmd->_spritePtr = NULL;
+ headCmd->_cbType = cbType;
+ if (headCmd->_commandType == kCmdClear) {
+ _tail = _head;
+ _vm->killText();
+ _timerExpiry = 0;
+ }
}
void CommandHandler::insertCommand(CommandType com, int ref, int val, void *ptr) {
diff --git a/engines/cge2/spare.cpp b/engines/cge2/spare.cpp
index 2977a586f3..8382310e1b 100644
--- a/engines/cge2/spare.cpp
+++ b/engines/cge2/spare.cpp
@@ -65,7 +65,7 @@ void Spare::takeScene(int cav) {
Sprite *spr = tempCont[i];
int c = spr->_scene;
if ((c == _vm->_now || c == 0) && spr->_ref != bakRef) {
- spr = take(spr->_ref);
+ spr = locate(spr->_ref);
_vm->_vga->_showQ->insert(spr);
}
}