CGE2: Implement busy() and revise connected parts of the engine.

This commit is contained in:
uruk 2014-06-23 11:50:49 +02:00
parent 2226eb0789
commit 23adc159ef
5 changed files with 28 additions and 8 deletions

View File

@ -96,6 +96,8 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_sayCap = true;
_sayVox = true;
_req = 1;
_midiNotify = nullptr;
_spriteNotify = nullptr;
}
void CGE2Engine::init() {

View File

@ -113,6 +113,8 @@ enum Action { kNear, kMTake, kFTake, kActions };
enum ColorBank { kCBRel, kCBStd, kCBSay, kCBInf, kCBMnu, kCBWar };
typedef void (CGE2Engine::*NotifyFunctionType)();
class CGE2Engine : public Engine {
private:
uint32 _lastFrame, _lastTick;
@ -170,6 +172,7 @@ public:
Sprite *spriteAt(V2D pos);
void keyClick();
void swapInPocket(Sprite *spr, Sprite *xspr);
void busyStep();
void optionTouch(int opt, uint16 mask);
void switchColorMode();
@ -262,6 +265,8 @@ public:
bool _sayCap;
bool _sayVox;
int _req;
NotifyFunctionType _midiNotify;
NotifyFunctionType _spriteNotify;
ResourceManager *_resman;
Vga *_vga;

View File

@ -648,7 +648,21 @@ void CGE2Engine::selectPocket(int n) {
}
void CGE2Engine::busy(bool on) {
warning("STUB: CGE2Engine::busy()");
if (on) {
_spriteNotify = _midiNotify = &CGE2::CGE2Engine::busyStep;
busyStep();
} else {
if (_busyPtr)
_busyPtr->step(0);
_spriteNotify = _midiNotify = nullptr;
}
}
void CGE2Engine::busyStep() {
if (_busyPtr) {
_busyPtr->step((_busyPtr->_seqPtr) ? -1 : 1);
_busyPtr->show(0);
}
}
void CGE2Engine::runGame() {

View File

@ -190,7 +190,8 @@ void MusicPlayer::killMidi() {
}
void MusicPlayer::loadMidi(int ref) {
warning("STUB: MusicPlayer::loadMidi()"); // if (MidiNotify) MidiNotify();
if (_vm->_midiNotify != nullptr)
(_vm->*_vm->_midiNotify)();
// Work out the filename and check the given MIDI file exists
Common::String filename = Common::String::format("%.2dSG%.2d.MID", ref >> 8, ref & 0xFF);

View File

@ -56,8 +56,6 @@ Seq *getConstantSeq(bool seqFlag) {
return seq;
}
void (*Sprite::notify)() = nullptr;
byte Sprite::_constY = 0;
byte Sprite::_follow = 0;
@ -249,8 +247,8 @@ Sprite *Sprite::expand() {
if (_ext)
return this;
if (notify != nullptr)
notify();
if (_vm->_spriteNotify != nullptr)
(_vm->*_vm->_spriteNotify)();
_ext = new SprExt(_vm);
assert(_ext != NULL);
@ -439,8 +437,8 @@ Sprite *Sprite::contract() {
curSeq->_dx = curSeq->_dy = curSeq->_dz = 0;
}
if (notify)
notify();
if (_vm->_spriteNotify != nullptr)
(_vm->*_vm->_spriteNotify)();
if (e->_name) {
delete[] e->_name;