mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
CGE: Move some more globals to CGEEngine
This commit is contained in:
parent
f5eca79658
commit
4778ff720c
@ -49,8 +49,8 @@ Bitmap::Bitmap(CGEEngine *vm, const char *fname) : _m(NULL), _v(NULL), _map(0),
|
|||||||
char pat[kMaxPath];
|
char pat[kMaxPath];
|
||||||
forceExt(pat, fname, ".VBM");
|
forceExt(pat, fname, ".VBM");
|
||||||
|
|
||||||
if (_resman->exist(pat)) {
|
if (_vm->_resman->exist(pat)) {
|
||||||
EncryptedStream file(pat);
|
EncryptedStream file(_vm, pat);
|
||||||
if (file.err())
|
if (file.err())
|
||||||
error("Unable to find VBM [%s]", fname);
|
error("Unable to find VBM [%s]", fname);
|
||||||
if (!loadVBM(&file))
|
if (!loadVBM(&file))
|
||||||
|
@ -102,11 +102,11 @@ void CGEEngine::init() {
|
|||||||
_debugLine = new InfoLine(this, kScrWidth);
|
_debugLine = new InfoLine(this, kScrWidth);
|
||||||
_snail = new Snail(this, false);
|
_snail = new Snail(this, false);
|
||||||
_snail_ = new Snail(this, true);
|
_snail_ = new Snail(this, true);
|
||||||
|
_midiPlayer = new MusicPlayer(this);
|
||||||
_mouse = new Mouse(this);
|
_mouse = new Mouse(this);
|
||||||
_keyboard = new Keyboard(this);
|
_keyboard = new Keyboard(this);
|
||||||
_eventManager = new EventManager(this);
|
_eventManager = new EventManager(this);
|
||||||
_fx = new Fx(16); // must precede SOUND!!
|
_fx = new Fx(this, 16); // must precede SOUND!!
|
||||||
_sound = new Sound(this);
|
_sound = new Sound(this);
|
||||||
|
|
||||||
_offUseCount = atoi(_text->getText(kOffUseCount));
|
_offUseCount = atoi(_text->getText(kOffUseCount));
|
||||||
@ -148,7 +148,7 @@ void CGEEngine::deinit() {
|
|||||||
DebugMan.clearAllDebugChannels();
|
DebugMan.clearAllDebugChannels();
|
||||||
|
|
||||||
delete _console;
|
delete _console;
|
||||||
_midiPlayer.killMidi();
|
_midiPlayer->killMidi();
|
||||||
|
|
||||||
// Delete engine objects
|
// Delete engine objects
|
||||||
delete _vga;
|
delete _vga;
|
||||||
|
@ -45,6 +45,13 @@ class Vga;
|
|||||||
class System;
|
class System;
|
||||||
class Keyboard;
|
class Keyboard;
|
||||||
class Mouse;
|
class Mouse;
|
||||||
|
class HorizLine;
|
||||||
|
class InfoLine;
|
||||||
|
class SceneLight;
|
||||||
|
class Snail;
|
||||||
|
class Snail;
|
||||||
|
class EventManager;
|
||||||
|
class ResourceManager;
|
||||||
|
|
||||||
#define kSavegameVersion 2
|
#define kSavegameVersion 2
|
||||||
#define kSavegameStrSize 11
|
#define kSavegameStrSize 11
|
||||||
@ -164,9 +171,22 @@ public:
|
|||||||
Sprite *_pocLight;
|
Sprite *_pocLight;
|
||||||
Keyboard *_keyboard;
|
Keyboard *_keyboard;
|
||||||
Mouse *_mouse;
|
Mouse *_mouse;
|
||||||
|
Sprite *_sprite;
|
||||||
|
Sprite *_miniScene;
|
||||||
|
Sprite *_shadow;
|
||||||
|
HorizLine *_horzLine;
|
||||||
|
InfoLine *_infoLine;
|
||||||
|
InfoLine *_debugLine;
|
||||||
|
SceneLight *_sceneLight;
|
||||||
|
Snail *_snail;
|
||||||
|
Snail *_snail_;
|
||||||
|
EventManager *_eventManager;
|
||||||
|
Fx *_fx;
|
||||||
|
Sound *_sound;
|
||||||
|
ResourceManager *_resman;
|
||||||
|
|
||||||
Common::RandomSource _randomSource;
|
Common::RandomSource _randomSource;
|
||||||
MusicPlayer _midiPlayer;
|
MusicPlayer *_midiPlayer;
|
||||||
BitmapPtr *_miniShp;
|
BitmapPtr *_miniShp;
|
||||||
BitmapPtr *_miniShpList;
|
BitmapPtr *_miniShpList;
|
||||||
int _startGameSlot;
|
int _startGameSlot;
|
||||||
|
@ -52,22 +52,7 @@ namespace CGE {
|
|||||||
|
|
||||||
uint16 _stklen = (kStackSize * 2);
|
uint16 _stklen = (kStackSize * 2);
|
||||||
|
|
||||||
EventManager *_eventManager;
|
|
||||||
Sprite *_pocket[kPocketNX];
|
Sprite *_pocket[kPocketNX];
|
||||||
Sprite *_sprite;
|
|
||||||
Sprite *_miniScene;
|
|
||||||
Sprite *_shadow;
|
|
||||||
HorizLine *_horzLine;
|
|
||||||
InfoLine *_infoLine;
|
|
||||||
SceneLight *_sceneLight;
|
|
||||||
InfoLine *_debugLine;
|
|
||||||
|
|
||||||
Snail *_snail;
|
|
||||||
Snail *_snail_;
|
|
||||||
|
|
||||||
Fx *_fx;
|
|
||||||
Sound *_sound;
|
|
||||||
ResourceManager *_resman;
|
|
||||||
|
|
||||||
const char *savegameStr = "SCUMMVM_CGE";
|
const char *savegameStr = "SCUMMVM_CGE";
|
||||||
|
|
||||||
@ -219,7 +204,7 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) {
|
|||||||
|
|
||||||
if (slotNumber == -1) {
|
if (slotNumber == -1) {
|
||||||
// Loading the data for the initial game state
|
// Loading the data for the initial game state
|
||||||
kSavegame0File file = kSavegame0File(kSavegame0Name);
|
kSavegame0File file = kSavegame0File(this, kSavegame0Name);
|
||||||
int size = file.size();
|
int size = file.size();
|
||||||
byte *dataBuffer = (byte *)malloc(size);
|
byte *dataBuffer = (byte *)malloc(size);
|
||||||
file.read(dataBuffer, size);
|
file.read(dataBuffer, size);
|
||||||
@ -490,7 +475,7 @@ void CGEEngine::tooFar() {
|
|||||||
void CGEEngine::loadHeroXY() {
|
void CGEEngine::loadHeroXY() {
|
||||||
debugC(1, kCGEDebugEngine, "CGEEngine::loadHeroXY()");
|
debugC(1, kCGEDebugEngine, "CGEEngine::loadHeroXY()");
|
||||||
|
|
||||||
EncryptedStream cf("CGE.HXY");
|
EncryptedStream cf(this, "CGE.HXY");
|
||||||
uint16 x, y;
|
uint16 x, y;
|
||||||
|
|
||||||
memset(_heroXY, 0, sizeof(_heroXY));
|
memset(_heroXY, 0, sizeof(_heroXY));
|
||||||
@ -509,7 +494,7 @@ void CGEEngine::loadMapping() {
|
|||||||
debugC(1, kCGEDebugEngine, "CGEEngine::loadMapping()");
|
debugC(1, kCGEDebugEngine, "CGEEngine::loadMapping()");
|
||||||
|
|
||||||
if (_now <= kSceneMax) {
|
if (_now <= kSceneMax) {
|
||||||
EncryptedStream cf("CGE.TAB");
|
EncryptedStream cf(this, "CGE.TAB");
|
||||||
if (!cf.err()) {
|
if (!cf.err()) {
|
||||||
// Move to the data for the given room
|
// Move to the data for the given room
|
||||||
cf.seek((_now - 1) * kMapArrSize);
|
cf.seek((_now - 1) * kMapArrSize);
|
||||||
@ -536,7 +521,7 @@ void Square::touch(uint16 mask, int x, int y) {
|
|||||||
Sprite::touch(mask, x, y);
|
Sprite::touch(mask, x, y);
|
||||||
if (mask & kMouseLeftUp) {
|
if (mask & kMouseLeftUp) {
|
||||||
_vm->XZ(_x + x, _y + y).cell() = 0;
|
_vm->XZ(_x + x, _y + y).cell() = 0;
|
||||||
_snail_->addCom(kSnKill, -1, 0, this);
|
_vm->_snail_->addCom(kSnKill, -1, 0, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,7 +614,7 @@ void CGEEngine::sceneUp() {
|
|||||||
|
|
||||||
const int BakRef = 1000 * _now;
|
const int BakRef = 1000 * _now;
|
||||||
if (_music)
|
if (_music)
|
||||||
_midiPlayer.loadMidi(_now);
|
_midiPlayer->loadMidi(_now);
|
||||||
|
|
||||||
showBak(BakRef);
|
showBak(BakRef);
|
||||||
loadMapping();
|
loadMapping();
|
||||||
@ -775,7 +760,7 @@ void System::touch(uint16 mask, int x, int y) {
|
|||||||
_vm->keyClick();
|
_vm->keyClick();
|
||||||
_vm->killText();
|
_vm->killText();
|
||||||
if (_vm->_startupMode == 1) {
|
if (_vm->_startupMode == 1) {
|
||||||
_snail->addCom(kSnClear, -1, 0, NULL);
|
_vm->_snail->addCom(kSnClear, -1, 0, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (x) {
|
switch (x) {
|
||||||
@ -789,7 +774,7 @@ void System::touch(uint16 mask, int x, int y) {
|
|||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
if (_vm->_keyboard->_key[kKeyAlt]) {
|
if (_vm->_keyboard->_key[kKeyAlt]) {
|
||||||
_snail->addCom(kSnLevel, -1, x - '0', NULL);
|
_vm->_snail->addCom(kSnLevel, -1, x - '0', NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -798,7 +783,7 @@ void System::touch(uint16 mask, int x, int y) {
|
|||||||
if (_vm->_startupMode)
|
if (_vm->_startupMode)
|
||||||
return;
|
return;
|
||||||
int selectedScene = 0;
|
int selectedScene = 0;
|
||||||
_infoLine->update(NULL);
|
_vm->_infoLine->update(NULL);
|
||||||
if (y >= kWorldHeight ) {
|
if (y >= kWorldHeight ) {
|
||||||
if (x < kButtonX) { // select scene?
|
if (x < kButtonX) { // select scene?
|
||||||
if (y >= kSceneY && y < kSceneY + kSceneNy * kSceneDy &&
|
if (y >= kSceneY && y < kSceneY + kSceneNy * kSceneDy &&
|
||||||
@ -821,10 +806,10 @@ void System::touch(uint16 mask, int x, int y) {
|
|||||||
_vm->postMiniStep(selectedScene - 1);
|
_vm->postMiniStep(selectedScene - 1);
|
||||||
|
|
||||||
if (mask & kMouseLeftUp) {
|
if (mask & kMouseLeftUp) {
|
||||||
if (selectedScene && _snail->idle() && _hero->_tracePtr < 0)
|
if (selectedScene && _vm->_snail->idle() && _hero->_tracePtr < 0)
|
||||||
_vm->switchScene(selectedScene);
|
_vm->switchScene(selectedScene);
|
||||||
|
|
||||||
if (_horzLine && !_horzLine->_flags._hide) {
|
if (_vm->_horzLine && !_vm->_horzLine->_flags._hide) {
|
||||||
if (y >= kMapTop && y < kMapTop + kMapHig) {
|
if (y >= kMapTop && y < kMapTop + kMapHig) {
|
||||||
Cluster tmpCluster = _vm->XZ(x, y);
|
Cluster tmpCluster = _vm->XZ(x, y);
|
||||||
int16 x1 = tmpCluster._pt.x;
|
int16 x1 = tmpCluster._pt.x;
|
||||||
@ -833,7 +818,7 @@ void System::touch(uint16 mask, int x, int y) {
|
|||||||
_vm->setMapBrick(x1, z1);
|
_vm->setMapBrick(x1, z1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!_talk && _snail->idle() && _hero
|
if (!_talk && _vm->_snail->idle() && _hero
|
||||||
&& y >= kMapTop && y < kMapTop + kMapHig && !_vm->_game) {
|
&& y >= kMapTop && y < kMapTop + kMapHig && !_vm->_game) {
|
||||||
_hero->findWay(_vm->XZ(x, y));
|
_hero->findWay(_vm->XZ(x, y));
|
||||||
}
|
}
|
||||||
@ -846,7 +831,7 @@ void System::tick() {
|
|||||||
if (!_vm->_startupMode)
|
if (!_vm->_startupMode)
|
||||||
if (--_funDel == 0) {
|
if (--_funDel == 0) {
|
||||||
_vm->killText();
|
_vm->killText();
|
||||||
if (_snail->idle()) {
|
if (_vm->_snail->idle()) {
|
||||||
if (_vm->_flag[0]) // Pain flag
|
if (_vm->_flag[0]) // Pain flag
|
||||||
_vm->heroCover(9);
|
_vm->heroCover(9);
|
||||||
else { // CHECKME: Before, was: if (Startup::_core >= CORE_MID) {
|
else { // CHECKME: Before, was: if (Startup::_core >= CORE_MID) {
|
||||||
@ -881,9 +866,9 @@ void CGEEngine::switchMusic() {
|
|||||||
keyClick();
|
keyClick();
|
||||||
|
|
||||||
if (_music)
|
if (_music)
|
||||||
_midiPlayer.loadMidi(_now);
|
_midiPlayer->loadMidi(_now);
|
||||||
else
|
else
|
||||||
_midiPlayer.killMidi();
|
_midiPlayer->killMidi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGEEngine::startCountDown() {
|
void CGEEngine::startCountDown() {
|
||||||
@ -946,10 +931,10 @@ void Sprite::touch(uint16 mask, int x, int y) {
|
|||||||
if ((mask & kEventAttn) != 0)
|
if ((mask & kEventAttn) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_infoLine->update(name());
|
_vm->_infoLine->update(name());
|
||||||
|
|
||||||
if (mask & (kMouseRightDown | kMouseLeftDown))
|
if (mask & (kMouseRightDown | kMouseLeftDown))
|
||||||
_sprite = this;
|
_vm->_sprite = this;
|
||||||
|
|
||||||
if (_ref / 10 == 12) {
|
if (_ref / 10 == 12) {
|
||||||
_vm->optionTouch(_ref % 10, mask);
|
_vm->optionTouch(_ref % 10, mask);
|
||||||
@ -965,7 +950,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
|
|||||||
mask |= kMouseRightUp;
|
mask |= kMouseRightUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mask & kMouseRightUp) && _snail->idle()) {
|
if ((mask & kMouseRightUp) && _vm->_snail->idle()) {
|
||||||
Sprite *ps = (_vm->_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL;
|
Sprite *ps = (_vm->_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL;
|
||||||
if (ps) {
|
if (ps) {
|
||||||
if (_flags._kept || _hero->distance(this) < kDistMax) {
|
if (_flags._kept || _hero->distance(this) < kDistMax) {
|
||||||
@ -985,8 +970,8 @@ void Sprite::touch(uint16 mask, int x, int y) {
|
|||||||
if (_vm->findPocket(NULL) < 0) {
|
if (_vm->findPocket(NULL) < 0) {
|
||||||
_vm->pocFul();
|
_vm->pocFul();
|
||||||
} else {
|
} else {
|
||||||
_snail->addCom(kSnReach, -1, -1, this);
|
_vm->_snail->addCom(kSnReach, -1, -1, this);
|
||||||
_snail->addCom(kSnKeep, -1, -1, this);
|
_vm->_snail->addCom(kSnKeep, -1, -1, this);
|
||||||
_flags._port = false;
|
_flags._port = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1006,7 +991,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mask & kMouseLeftUp) && _snail->idle()) {
|
if ((mask & kMouseLeftUp) && _vm->_snail->idle()) {
|
||||||
if (_flags._kept) {
|
if (_flags._kept) {
|
||||||
for (int n = 0; n < kPocketNX; n++) {
|
for (int n = 0; n < kPocketNX; n++) {
|
||||||
if (_pocket[n] == this) {
|
if (_pocket[n] == this) {
|
||||||
@ -1015,7 +1000,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_snail->addCom(kSnWalk, -1, -1, this); // Hero->FindWay(this);
|
_vm->_snail->addCom(kSnWalk, -1, -1, this); // Hero->FindWay(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1043,7 +1028,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int scene, int col = 0, i
|
|||||||
mergeExt(tmpStr, fname, kSprExt);
|
mergeExt(tmpStr, fname, kSprExt);
|
||||||
|
|
||||||
if (_resman->exist(tmpStr)) { // sprite description file exist
|
if (_resman->exist(tmpStr)) { // sprite description file exist
|
||||||
EncryptedStream sprf(tmpStr);
|
EncryptedStream sprf(this, tmpStr);
|
||||||
if (sprf.err())
|
if (sprf.err())
|
||||||
error("Bad SPR [%s]", tmpStr);
|
error("Bad SPR [%s]", tmpStr);
|
||||||
|
|
||||||
@ -1148,7 +1133,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int scene, int col = 0, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGEEngine::loadScript(const char *fname) {
|
void CGEEngine::loadScript(const char *fname) {
|
||||||
EncryptedStream scrf(fname);
|
EncryptedStream scrf(this, fname);
|
||||||
|
|
||||||
if (scrf.err())
|
if (scrf.err())
|
||||||
return;
|
return;
|
||||||
@ -1356,7 +1341,7 @@ void CGEEngine::runGame() {
|
|||||||
_sprite->step(_music);
|
_sprite->step(_music);
|
||||||
_snail_->addCom(kSnSeq, -1, _music, _sprite);
|
_snail_->addCom(kSnSeq, -1, _music, _sprite);
|
||||||
if (!_music)
|
if (!_music)
|
||||||
_midiPlayer.killMidi();
|
_midiPlayer->killMidi();
|
||||||
|
|
||||||
if (_resman->exist("MINI.SPR")) {
|
if (_resman->exist("MINI.SPR")) {
|
||||||
_miniShp = new BitmapPtr[2];
|
_miniShp = new BitmapPtr[2];
|
||||||
@ -1505,7 +1490,7 @@ bool CGEEngine::showTitle(const char *name) {
|
|||||||
_vga->copyPage(0, 2);
|
_vga->copyPage(0, 2);
|
||||||
_soundOk = 2;
|
_soundOk = 2;
|
||||||
if (_music)
|
if (_music)
|
||||||
_midiPlayer.loadMidi(0);
|
_midiPlayer->loadMidi(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_mode < 2) {
|
if (_mode < 2) {
|
||||||
@ -1560,7 +1545,7 @@ void CGEEngine::cge_main() {
|
|||||||
_horzLine->_flags._hide = true;
|
_horzLine->_flags._hide = true;
|
||||||
|
|
||||||
if (_music && _soundOk)
|
if (_music && _soundOk)
|
||||||
_midiPlayer.loadMidi(0);
|
_midiPlayer->loadMidi(0);
|
||||||
|
|
||||||
if (_startGameSlot != -1) {
|
if (_startGameSlot != -1) {
|
||||||
// Starting up a savegame from the launcher
|
// Starting up a savegame from the launcher
|
||||||
|
@ -109,19 +109,7 @@ private:
|
|||||||
CGEEngine *_vm;
|
CGEEngine *_vm;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EventManager *_eventManager;
|
|
||||||
extern Sprite *_pocket[];
|
extern Sprite *_pocket[];
|
||||||
extern Sprite *_sprite;
|
|
||||||
extern Sprite *_miniScene;
|
|
||||||
extern Sprite *_shadow;
|
|
||||||
extern HorizLine *_horzLine;
|
|
||||||
extern InfoLine *_infoLine;
|
|
||||||
extern SceneLight *_sceneLight;
|
|
||||||
extern InfoLine *_debugLine;
|
|
||||||
extern Snail *_snail;
|
|
||||||
extern Snail *_snail_;
|
|
||||||
extern Fx *_fx;
|
|
||||||
extern Sound *_sound;
|
|
||||||
|
|
||||||
} // End of namespace CGE
|
} // End of namespace CGE
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void Keyboard::newKeyboard(Common::Event &event) {
|
|||||||
_current = Keyboard::_code[keycode];
|
_current = Keyboard::_code[keycode];
|
||||||
|
|
||||||
if (_client) {
|
if (_client) {
|
||||||
CGEEvent &evt = _eventManager->getNextEvent();
|
CGEEvent &evt = _vm->_eventManager->getNextEvent();
|
||||||
evt._x = _current; // Keycode
|
evt._x = _current; // Keycode
|
||||||
evt._mask = kEventKeyb; // Event mask
|
evt._mask = kEventKeyb; // Event mask
|
||||||
evt._spritePtr = _client; // Sprite pointer
|
evt._spritePtr = _client; // Sprite pointer
|
||||||
@ -239,7 +239,7 @@ void Mouse::newMouse(Common::Event &event) {
|
|||||||
if (!_active)
|
if (!_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CGEEvent &evt = _eventManager->getNextEvent();
|
CGEEvent &evt = _vm->_eventManager->getNextEvent();
|
||||||
evt._x = event.mouse.x;
|
evt._x = event.mouse.x;
|
||||||
evt._y = event.mouse.y;
|
evt._y = event.mouse.y;
|
||||||
evt._spritePtr = _vm->spriteAt(evt._x, evt._y);
|
evt._spritePtr = _vm->spriteAt(evt._x, evt._y);
|
||||||
|
@ -192,17 +192,17 @@ uint16 ResourceManager::catRead(void *buf, uint16 length) {
|
|||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
* EncryptedStream
|
* EncryptedStream
|
||||||
*-----------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------*/
|
||||||
EncryptedStream::EncryptedStream(const char *name) {
|
EncryptedStream::EncryptedStream(CGEEngine *vm, const char *name) : _vm(vm) {
|
||||||
debugC(3, kCGEDebugFile, "EncryptedStream::EncryptedStream(%s)", name);
|
debugC(3, kCGEDebugFile, "EncryptedStream::EncryptedStream(%s)", name);
|
||||||
|
|
||||||
_error = false;
|
_error = false;
|
||||||
BtKeypack *kp = _resman->find(name);
|
BtKeypack *kp = _vm->_resman->find(name);
|
||||||
if (scumm_stricmp(kp->_key, name) != 0)
|
if (scumm_stricmp(kp->_key, name) != 0)
|
||||||
_error = true;
|
_error = true;
|
||||||
|
|
||||||
_resman->seek(kp->_pos);
|
_vm->_resman->seek(kp->_pos);
|
||||||
byte *dataBuffer = (byte *)malloc(kp->_size);
|
byte *dataBuffer = (byte *)malloc(kp->_size);
|
||||||
_resman->read(dataBuffer, kp->_size);
|
_vm->_resman->read(dataBuffer, kp->_size);
|
||||||
_readStream = new Common::MemoryReadStream(dataBuffer, kp->_size, DisposeAfterUse::YES);
|
_readStream = new Common::MemoryReadStream(dataBuffer, kp->_size, DisposeAfterUse::YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
namespace CGE {
|
namespace CGE {
|
||||||
|
|
||||||
|
class CGEEngine;
|
||||||
|
|
||||||
#define kBtSize 1024
|
#define kBtSize 1024
|
||||||
#define kBtKeySize 13
|
#define kBtKeySize 13
|
||||||
#define kBtLevel 2
|
#define kBtLevel 2
|
||||||
@ -98,10 +100,11 @@ public:
|
|||||||
|
|
||||||
class EncryptedStream {
|
class EncryptedStream {
|
||||||
private:
|
private:
|
||||||
|
CGEEngine *_vm;
|
||||||
Common::SeekableReadStream *_readStream;
|
Common::SeekableReadStream *_readStream;
|
||||||
bool _error;
|
bool _error;
|
||||||
public:
|
public:
|
||||||
EncryptedStream(const char *name);
|
EncryptedStream(CGEEngine *vm, const char *name);
|
||||||
~EncryptedStream();
|
~EncryptedStream();
|
||||||
bool err();
|
bool err();
|
||||||
bool eos();
|
bool eos();
|
||||||
@ -112,8 +115,6 @@ public:
|
|||||||
Common::String readLine();
|
Common::String readLine();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ResourceManager *_resman;
|
|
||||||
|
|
||||||
} // End of namespace CGE
|
} // End of namespace CGE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1136,7 +1136,7 @@ void Snail::runCom() {
|
|||||||
_vm->snSound(spr, snc->_val);
|
_vm->snSound(spr, snc->_val);
|
||||||
break;
|
break;
|
||||||
case kSnCount:
|
case kSnCount:
|
||||||
_sound->setRepeat(snc->_val);
|
_vm->_sound->setRepeat(snc->_val);
|
||||||
break;
|
break;
|
||||||
case kSnExec:
|
case kSnExec:
|
||||||
switch (snc->_cbType) {
|
switch (snc->_cbType) {
|
||||||
|
@ -55,12 +55,12 @@ Sound::~Sound() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Sound::close() {
|
void Sound::close() {
|
||||||
_vm->_midiPlayer.killMidi();
|
_vm->_midiPlayer->killMidi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::open() {
|
void Sound::open() {
|
||||||
setRepeat(1);
|
setRepeat(1);
|
||||||
play((*_fx)[30000], 8);
|
play((*_vm->_fx)[30000], 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::setRepeat(int16 count) {
|
void Sound::setRepeat(int16 count) {
|
||||||
@ -103,7 +103,7 @@ void Sound::sndDigiStop(SmpInfo *PSmpInfo) {
|
|||||||
_audioStream = NULL;
|
_audioStream = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fx::Fx(int size) : _current(NULL) {
|
Fx::Fx(CGEEngine *vm, int size) : _current(NULL), _vm(vm) {
|
||||||
_cache = new Handler[size];
|
_cache = new Handler[size];
|
||||||
for (_size = 0; _size < size; _size++) {
|
for (_size = 0; _size < size; _size++) {
|
||||||
_cache[_size]._ref = 0;
|
_cache[_size]._ref = 0;
|
||||||
@ -144,7 +144,7 @@ void Fx::preload(int ref0) {
|
|||||||
|
|
||||||
for (int ref = ref0; ref < ref0 + 10; ref++) {
|
for (int ref = ref0; ref < ref0 + 10; ref++) {
|
||||||
sprintf(filename, "FX%05d.WAV", ref);
|
sprintf(filename, "FX%05d.WAV", ref);
|
||||||
EncryptedStream file = filename;
|
EncryptedStream file(_vm, filename);
|
||||||
DataCk *wav = loadWave(&file);
|
DataCk *wav = loadWave(&file);
|
||||||
if (wav) {
|
if (wav) {
|
||||||
Handler *p = &_cache[find(0)];
|
Handler *p = &_cache[find(0)];
|
||||||
@ -162,7 +162,7 @@ DataCk *Fx::load(int idx, int ref) {
|
|||||||
char filename[12];
|
char filename[12];
|
||||||
sprintf(filename, "FX%05d.WAV", ref);
|
sprintf(filename, "FX%05d.WAV", ref);
|
||||||
|
|
||||||
EncryptedStream file = filename;
|
EncryptedStream file(_vm, filename);
|
||||||
DataCk *wav = loadWave(&file);
|
DataCk *wav = loadWave(&file);
|
||||||
if (wav) {
|
if (wav) {
|
||||||
Handler *p = &_cache[idx];
|
Handler *p = &_cache[idx];
|
||||||
@ -195,7 +195,7 @@ DataCk *Fx::operator[](int ref) {
|
|||||||
return _current;
|
return _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicPlayer::MusicPlayer() {
|
MusicPlayer::MusicPlayer(CGEEngine *vm) : _vm(vm) {
|
||||||
_data = NULL;
|
_data = NULL;
|
||||||
_isGM = false;
|
_isGM = false;
|
||||||
|
|
||||||
@ -230,14 +230,14 @@ void MusicPlayer::killMidi() {
|
|||||||
void MusicPlayer::loadMidi(int ref) {
|
void MusicPlayer::loadMidi(int ref) {
|
||||||
// Work out the filename and check the given MIDI file exists
|
// Work out the filename and check the given MIDI file exists
|
||||||
Common::String filename = Common::String::format("%.2d.MID", ref);
|
Common::String filename = Common::String::format("%.2d.MID", ref);
|
||||||
if (!_resman->exist(filename.c_str()))
|
if (!_vm->_resman->exist(filename.c_str()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stop any currently playing MIDI file
|
// Stop any currently playing MIDI file
|
||||||
killMidi();
|
killMidi();
|
||||||
|
|
||||||
// Read in the data for the file
|
// Read in the data for the file
|
||||||
EncryptedStream mid(filename.c_str());
|
EncryptedStream mid(_vm, filename.c_str());
|
||||||
_dataSize = mid.size();
|
_dataSize = mid.size();
|
||||||
_data = (byte *)malloc(_dataSize);
|
_data = (byte *)malloc(_dataSize);
|
||||||
mid.read(_data, _dataSize);
|
mid.read(_data, _dataSize);
|
||||||
|
@ -87,6 +87,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Fx {
|
class Fx {
|
||||||
|
CGEEngine *_vm;
|
||||||
struct Handler {
|
struct Handler {
|
||||||
int _ref;
|
int _ref;
|
||||||
DataCk *_wav;
|
DataCk *_wav;
|
||||||
@ -99,7 +100,7 @@ class Fx {
|
|||||||
public:
|
public:
|
||||||
DataCk *_current;
|
DataCk *_current;
|
||||||
|
|
||||||
Fx(int size);
|
Fx(CGEEngine *vm, int size);
|
||||||
~Fx();
|
~Fx();
|
||||||
void clear();
|
void clear();
|
||||||
void preload(int ref0);
|
void preload(int ref0);
|
||||||
@ -108,6 +109,7 @@ public:
|
|||||||
|
|
||||||
class MusicPlayer: public Audio::MidiPlayer {
|
class MusicPlayer: public Audio::MidiPlayer {
|
||||||
private:
|
private:
|
||||||
|
CGEEngine *_vm;
|
||||||
byte *_data;
|
byte *_data;
|
||||||
int _dataSize;
|
int _dataSize;
|
||||||
bool _isGM;
|
bool _isGM;
|
||||||
@ -118,7 +120,7 @@ private:
|
|||||||
// Stop MIDI File
|
// Stop MIDI File
|
||||||
void sndMidiStop();
|
void sndMidiStop();
|
||||||
public:
|
public:
|
||||||
MusicPlayer();
|
MusicPlayer(CGEEngine *vm);
|
||||||
~MusicPlayer();
|
~MusicPlayer();
|
||||||
|
|
||||||
void loadMidi(int ref);
|
void loadMidi(int ref);
|
||||||
|
@ -50,7 +50,7 @@ Font::~Font() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Font::load() {
|
void Font::load() {
|
||||||
EncryptedStream f = _path;
|
EncryptedStream f(_vm, _path);
|
||||||
assert(!f.err());
|
assert(!f.err());
|
||||||
|
|
||||||
f.read(_widthArr, kWidSize);
|
f.read(_widthArr, kWidSize);
|
||||||
|
@ -40,7 +40,7 @@ Talk *_talk = NULL;
|
|||||||
|
|
||||||
Text::Text(CGEEngine *vm, const char *fname) : _vm(vm) {
|
Text::Text(CGEEngine *vm, const char *fname) : _vm(vm) {
|
||||||
_vm->mergeExt(_fileName, fname, kSayExt);
|
_vm->mergeExt(_fileName, fname, kSayExt);
|
||||||
if (!_resman->exist(_fileName))
|
if (!_vm->_resman->exist(_fileName))
|
||||||
error("No talk (%s)\n", _fileName);
|
error("No talk (%s)\n", _fileName);
|
||||||
int16 txtCount = count() + 1;
|
int16 txtCount = count() + 1;
|
||||||
if (!txtCount)
|
if (!txtCount)
|
||||||
@ -60,7 +60,7 @@ Text::~Text() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int16 Text::count() {
|
int16 Text::count() {
|
||||||
EncryptedStream tf = _fileName;
|
EncryptedStream tf(_vm, _fileName);
|
||||||
if (tf.err())
|
if (tf.err())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ void Text::clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Text::load() {
|
void Text::load() {
|
||||||
EncryptedStream tf = _fileName;
|
EncryptedStream tf(_vm, _fileName);
|
||||||
assert(!tf.err());
|
assert(!tf.err());
|
||||||
|
|
||||||
Common::String line;
|
Common::String line;
|
||||||
|
@ -72,8 +72,8 @@ Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Sprite::~Sprite() {
|
Sprite::~Sprite() {
|
||||||
if (_sprite == this)
|
if (_vm->_sprite == this)
|
||||||
_sprite = NULL;
|
_vm->_sprite = NULL;
|
||||||
|
|
||||||
contract();
|
contract();
|
||||||
}
|
}
|
||||||
@ -211,8 +211,8 @@ Sprite *Sprite::expand() {
|
|||||||
Snail::Com *nearList = NULL;
|
Snail::Com *nearList = NULL;
|
||||||
Snail::Com *takeList = NULL;
|
Snail::Com *takeList = NULL;
|
||||||
_vm->mergeExt(fname, _file, kSprExt);
|
_vm->mergeExt(fname, _file, kSprExt);
|
||||||
if (_resman->exist(fname)) { // sprite description file exist
|
if (_vm->_resman->exist(fname)) { // sprite description file exist
|
||||||
EncryptedStream sprf(fname);
|
EncryptedStream sprf(_vm, fname);
|
||||||
if (sprf.err())
|
if (sprf.err())
|
||||||
error("Bad SPR [%s]", fname);
|
error("Bad SPR [%s]", fname);
|
||||||
Common::String line;
|
Common::String line;
|
||||||
|
@ -112,7 +112,7 @@ void Vmenu::touch(uint16 mask, int x, int y) {
|
|||||||
|
|
||||||
if (ok && (mask & kMouseLeftUp)) {
|
if (ok && (mask & kMouseLeftUp)) {
|
||||||
_items = 0;
|
_items = 0;
|
||||||
_snail_->addCom(kSnKill, -1, 0, this);
|
_vm->_snail_->addCom(kSnKill, -1, 0, this);
|
||||||
_recent = n;
|
_recent = n;
|
||||||
assert(_menu[n].Proc);
|
assert(_menu[n].Proc);
|
||||||
CALL_MEMBER_FN(*_vm, _menu[n].Proc)();
|
CALL_MEMBER_FN(*_vm, _menu[n].Proc)();
|
||||||
|
@ -95,7 +95,7 @@ void Walk::tick() {
|
|||||||
} else {
|
} else {
|
||||||
// take current Z position
|
// take current Z position
|
||||||
_z = _here._pt.y;
|
_z = _here._pt.y;
|
||||||
_snail_->addCom(kSnZTrim, -1, 0, this); // update Hero's pos in show queue
|
_vm->_snail_->addCom(kSnZTrim, -1, 0, this); // update Hero's pos in show queue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,10 +187,10 @@ void Walk::reach(Sprite *spr, int mode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// note: insert SNAIL commands in reverse order
|
// note: insert SNAIL commands in reverse order
|
||||||
_snail->insCom(kSnPause, -1, 64, NULL);
|
_vm->_snail->insCom(kSnPause, -1, 64, NULL);
|
||||||
_snail->insCom(kSnSeq, -1, kTSeq + mode, this);
|
_vm->_snail->insCom(kSnSeq, -1, kTSeq + mode, this);
|
||||||
if (spr) {
|
if (spr) {
|
||||||
_snail->insCom(kSnWait, -1, -1, _hero);
|
_vm->_snail->insCom(kSnWait, -1, -1, _hero);
|
||||||
//SNINSERT(SNWALK, -1, -1, spr);
|
//SNINSERT(SNWALK, -1, -1, spr);
|
||||||
}
|
}
|
||||||
// sequence is not finished,
|
// sequence is not finished,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user