CGE2: Implement runGame().

This commit is contained in:
uruk 2014-05-26 10:33:47 +02:00
parent 54956d8a81
commit 4e232814d5
4 changed files with 93 additions and 1 deletions

View File

@ -65,6 +65,9 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
for (int i = 0; i < kMaxPoint; i++)
_point[i] = nullptr;
_sys = nullptr;
_busyPtr = nullptr;
for (int i = 0; i < 2; i++)
_vol[i] = nullptr;
_quitFlag = false;
_bitmapPalette = nullptr;
@ -81,6 +84,9 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_waitRef = 0;
_commandStat = { nullptr, { 0 , 0 } };
_taken = false;
_endGame = false;
for (int i = 0; i < 4; i++)
_flag[i] = false;
}
void CGE2Engine::init() {

View File

@ -68,6 +68,9 @@ class System;
#define kPocketMax 4
#define kCaveMax 100
#define kMaxPoint 4
#define kInfoX 160
#define kInfoY -11
#define kInfoW 180
enum CallbackType {
kNullCB = 0, kQGame, kMiniStep, kXScene, kSoundSetVolume
@ -129,6 +132,9 @@ public:
void handleFrame();
Sprite *locate(int ref);
bool isHero(Sprite *spr);
void loadUser();
void checkSaySwitch();
void qGame();
void setEye(V3D &e);
void setEye(const V2D& e2, int z = -kScrWidth);
@ -199,6 +205,8 @@ public:
int _ref[2];
} _commandStat;
bool _taken;
bool _endGame;
bool _flag[4];
ResourceManager *_resman;
Vga *_vga;
@ -219,6 +227,8 @@ public:
Talk *_talk;
V3D *_point[kMaxPoint];
System *_sys;
Sprite *_busyPtr;
Sprite *_vol[2];
private:
void init();
void deinit();

View File

@ -498,7 +498,74 @@ void CGE2Engine::busy(bool on) {
}
void CGE2Engine::runGame() {
warning("STUB: CGE2Engine::runGame()");
if (_quitFlag)
return;
selectPocket(-1);
loadUser();
_commandHandlerTurbo->addCommand(kCmdSeq, kMusicRef, _music, nullptr);
if (!_music)
_midiPlayer->killMidi();
checkSaySwitch();
_infoLine->gotoxyz(V3D(kInfoX, kInfoY, 0));
_infoLine->setText(nullptr);
_vga->_showQ->insert(_infoLine);
caveUp(_now);
_startupMode = 0;
_mouse->center();
_mouse->off();
_mouse->on();
_keyboard->setClient(_sys);
_commandHandler->addCommand(kCmdSeq, kPowerRef, 1, nullptr);
_busyPtr = _vga->_showQ->locate(kBusyRef);
_vol[0] = _vga->_showQ->locate(kDvolRef);
_vol[1] = _vga->_showQ->locate(kMvolRef);
// these sprites are loaded with SeqPtr==0 (why?!)
if (_vol[0])
_vol[0]->step((/*(int)SNDDrvInfo.VOL4.DL * */ _vol[0]->_seqCnt + _vol[0]->_seqCnt / 2) >> 4);
if (_vol[1])
_vol[1]->step((/*(int)SNDDrvInfo.VOL4.ML * */ _vol[1]->_seqCnt + _vol[1]->_seqCnt / 2) >> 4);
// TODO: Recheck these! ^
// main loop
while (!_endGame && !_quitFlag) {
if (_flag[3]) // Flag FINIS
_commandHandler->addCallback(kCmdExec, -1, 0, kQGame);
mainLoop();
}
// If finishing game due to closing ScummVM window, explicitly save the game
if (!_endGame && canSaveGameStateCurrently())
qGame();
_keyboard->setClient(nullptr);
_commandHandler->addCommand(kCmdClear, -1, 0, nullptr);
_commandHandlerTurbo->addCommand(kCmdClear, -1, 0, nullptr);
_mouse->off();
_vga->_showQ->clear();
_vga->_spareQ->clear();
}
void CGE2Engine::loadUser() {
warning("STUB: CGE2Engine::loadUser()");
}
void CGE2Engine::checkSaySwitch() {
warning("STUB: CGE2Engine::checkSaySwitch()");
}
void CGE2Engine::qGame() {
warning("STUB: CGE2Engine::qGame()");
_endGame = true;
}
void CGE2Engine::loadTab() {

View File

@ -40,6 +40,15 @@ namespace CGE2 {
#define kGameFrameDelay (750 / 50)
#define kGameTickDelay (750 / 62)
#define kMusicRef 122
#define kPowerRef 123
#define kDvolRef 124
#define kMvolRef 125
#define kRef 126
#define kBusyRef 127
#define kCapRef 128
#define kVoxRef 129
class System : public Sprite {
public:
int _funDel;