aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cge/cge.h2
-rw-r--r--engines/cge/cge_main.cpp30
-rw-r--r--engines/cge/config.cpp4
-rw-r--r--engines/cge/general.h2
-rw-r--r--engines/cge/mixer.cpp4
-rw-r--r--engines/cge/snail.cpp41
-rw-r--r--engines/cge/snail.h4
-rw-r--r--engines/cge/startup.h1
8 files changed, 56 insertions, 32 deletions
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index 29a7a11b9d..644e06e7e7 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -46,6 +46,7 @@ enum {
};
enum SNLIST { NEAR, TAKE };
+enum CALLBACK { NULLCB = 0, QGAME, MINISTEP, XCAVE, SELECTSOUND, SNSELECT, SNDSETVOLUME };
#define POCKET_NX 8
@@ -145,6 +146,7 @@ public:
void sayDebug();
void nextStep();
void switchDebug();
+ void miniStep(int stp);
void snBackPt(Sprite *spr, int stp);
void snBarrier(int cav, int bar, bool horz);
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 05e936e4e5..f2aca3ed8b 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -584,8 +584,7 @@ static void AltCtrlDel() {
SNPOST_(SNSAY, -1, A_C_D_TEXT, _hero);
}
-// Used in stubbed function, do not remove!
-static void miniStep(int stp) {
+void CGEEngine::miniStep(int stp) {
if (stp < 0)
_miniCave->_flags._hide = true;
else {
@@ -600,10 +599,9 @@ static void miniStep(int stp) {
static void postMiniStep(int stp) {
- //static int recent = -2;
- //TODO Change the SNPOST message send to a special way to send function pointer
- //if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep);
- warning("STUB: PostMiniStep()");
+ static int recent = -2;
+ if (_miniCave && stp != recent)
+ SNPOST2_(SNEXEC, -1, recent = stp, MINISTEP);
}
void System::setPal() {
@@ -744,9 +742,7 @@ void CGEEngine::switchCave(int cav) {
_heart->_enable = false;
if (cav < 0) {
SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint
- //TODO Change the SNPOST message send to a special way to send function pointer
- //SNPOST(SNEXEC, -1, 0, (void *)&QGame); // switch cave
- warning("SwitchCave() - SNPOST");
+ SNPOST2(SNEXEC, -1, 0, QGAME); // switch cave
} else {
_now = cav;
_mouse->off();
@@ -764,9 +760,7 @@ void CGEEngine::switchCave(int cav) {
if (!_startupMode)
keyClick();
SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint
- //TODO Change the SNPOST message send to a special way to send function pointer
- //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave
- warning("SwitchCave() - SNPOST");
+ SNPOST2(SNEXEC, 0, 0, XCAVE); // switch cave
}
}
}
@@ -997,9 +991,7 @@ void CGEEngine::switchMusic() {
SNPOST_(SNKILL, -1, 0, Vmenu::_addr);
else {
SNPOST_(SNSEQ, 122, (_music = false), NULL);
- //TODO Change the SNPOST message send to a special way to send function pointer
- // SNPOST(SNEXEC, -1, 0, (void *)&selectSound);
- warning("SwitchMusic() - SNPOST");
+ SNPOST2(SNEXEC, -1, 0, SELECTSOUND);
}
} else {
if (Startup::_core < CORE_HIG)
@@ -1580,7 +1572,8 @@ void CGEEngine::runGame() {
_vga->_showQ->append(_cavLight);
_cavLight->_flags._hide = true;
- const Seq pocSeq[] = { { 0, 0, 0, 0, 20 },
+ const Seq pocSeq[] = {
+ { 0, 0, 0, 0, 20 },
{ 1, 2, 0, 0, 4 },
{ 2, 3, 0, 0, 4 },
{ 3, 4, 0, 0, 16 },
@@ -1668,9 +1661,8 @@ void CGEEngine::runGame() {
_keyboard->setClient(_sys);
// main loop
while (!_finis && !_eventManager->_quitFlag) {
- //TODO Change the SNPOST message send to a special way to send function pointer
- // if (FINIS) SNPOST(SNEXEC, -1, 0, (void *)&QGame);
- warning("RunGame: problematic use of SNPOST");
+ if (_finis)
+ SNPOST2(SNEXEC, -1, 0, QGAME);
mainLoop();
}
diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp
index 808d74ff9b..0152961982 100644
--- a/engines/cge/config.cpp
+++ b/engines/cge/config.cpp
@@ -192,9 +192,7 @@ void CGEEngine::snSelect() {
static void select(Choice *cho, int hlp) {
_cho = cho;
_hlp = hlp;
- //TODO Change the SNPOST message send to a special way to send function pointer
- //SNPOST(SNEXEC, -1, 0, (void *)&SNSelect);
- warning("STUB: select");
+ SNPOST2(SNEXEC, -1, 0, SNSELECT);
}
diff --git a/engines/cge/general.h b/engines/cge/general.h
index a3cc12080d..b4f73726ee 100644
--- a/engines/cge/general.h
+++ b/engines/cge/general.h
@@ -112,7 +112,7 @@ class Emm {
int _han;
static void *_frame;
public:
- Emm(long size = 0);
+ Emm(long size);
~Emm();
Ems *alloc(uint16 siz);
void release();
diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp
index 0e3a613e60..8b11dbcc4c 100644
--- a/engines/cge/mixer.cpp
+++ b/engines/cge/mixer.cpp
@@ -142,9 +142,7 @@ void Mixer::update() {
_led[0]->step(_sndDrvInfo.Vol4._ml);
_led[1]->step(_sndDrvInfo.Vol4._dl);
- //TODO Change the SNPOST message send to a special way to send function pointer
- //SNPOST_(SNEXEC, -1, 0, (void*)&sndSetVolume);
- warning("STUB: Mixer::Update");
+ SNPOST2_(SNEXEC, -1, 0, SNDSETVOLUME);
}
} // End of namespace CGE
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index 2fe2d22d5b..23a182cbd5 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -411,6 +411,21 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) {
snc->_ref = ref;
snc->_val = val;
snc->_ptr = ptr;
+ snc->_cbType = NULLCB;
+ if (com == SNCLEAR) {
+ _tail = _head;
+ killText();
+ _timerExpiry = 0;
+ }
+}
+
+void Snail::addCom2(SNCOM com, int ref, int val, CALLBACK cbType) {
+ Com *snc = &_snList[_head++];
+ snc->_com = com;
+ snc->_ref = ref;
+ snc->_val = val;
+ snc->_ptr = NULL;
+ snc->_cbType = cbType;
if (com == SNCLEAR) {
_tail = _head;
killText();
@@ -913,8 +928,7 @@ void Snail::runCom() {
}
break;
case SNCAVE :
- // SwitchCave(snc->_val);
- warning("Problematic call of SwitchCave in SNAIL::runCom");
+ _vm->switchCave(snc->_val);
break;
case SNKILL :
_vm->snKill(sprel);
@@ -1042,9 +1056,26 @@ void Snail::runCom() {
count = snc->_val;
break;
case SNEXEC :
- // TODO: Handle correctly the execution of function pointer coming from Message send SNPOST
- // ((void(*)(int)) (snc->_ptr))(snc->_val);
- warning("STUB: SNEXEC code");
+ switch (snc->_cbType) {
+ case QGAME:
+ _vm->qGame();
+ break;
+ case MINISTEP:
+ _vm->miniStep(snc->_val);
+ break;
+ case XCAVE:
+ _vm->xCave();
+ break;
+ case SELECTSOUND:
+ _vm->selectSound();
+ break;
+ case SNSELECT:
+ _vm->snSelect();
+ break;
+ case SNDSETVOLUME:
+ sndSetVolume();
+ break;
+ }
break;
case SNSTEP :
sprel->step();
diff --git a/engines/cge/snail.h b/engines/cge/snail.h
index 888fae6ce9..48e5900248 100644
--- a/engines/cge/snail.h
+++ b/engines/cge/snail.h
@@ -44,7 +44,9 @@ namespace CGE {
#define SNINSERT(c, r, v, p) _snail->insCom(c, r, v, p)
#define SNPOST(c, r, v, p) _snail->addCom(c, r, v, p)
+#define SNPOST2(c, r, v, p) _snail->addCom2(c, r, v, p)
#define SNPOST_(c, r, v, p) _snail_->addCom(c, r, v, p)
+#define SNPOST2_(c, r, v, p) _snail_->addCom2(c, r, v, p)
#define SNAIL_FRAME_RATE 62
#define SNAIL_FRAME_DELAY (1000 / SNAIL_FRAME_RATE)
@@ -77,6 +79,7 @@ public:
int _ref;
int _val;
void *_ptr;
+ CALLBACK _cbType;
} *_snList;
uint8 _head;
uint8 _tail;
@@ -90,6 +93,7 @@ public:
~Snail();
void runCom();
void addCom(SNCOM com, int ref, int val, void *ptr);
+ void addCom2(SNCOM com, int ref, int val, CALLBACK cbType);
void insCom(SNCOM com, int ref, int val, void *ptr);
bool idle();
private:
diff --git a/engines/cge/startup.h b/engines/cge/startup.h
index cc16f2a123..5479945104 100644
--- a/engines/cge/startup.h
+++ b/engines/cge/startup.h
@@ -56,7 +56,6 @@ namespace CGE {
#endif
#define CORE_MID (CORE_HIG - 20)
-#define CORE_LOW (CORE_MID - 20)
class Startup {