mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 04:33:09 +00:00
CGE: add a new SNPOST to fix the function pointer issue
This commit is contained in:
parent
4d96ec7034
commit
5148f80fa5
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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:
|
||||
|
@ -56,7 +56,6 @@ namespace CGE {
|
||||
#endif
|
||||
|
||||
#define CORE_MID (CORE_HIG - 20)
|
||||
#define CORE_LOW (CORE_MID - 20)
|
||||
|
||||
|
||||
class Startup {
|
||||
|
Loading…
x
Reference in New Issue
Block a user