LAB: Move event update functions out of updateMusic
This commit is contained in:
parent
7380ddf400
commit
be4c436dca
11 changed files with 98 additions and 93 deletions
|
@ -130,7 +130,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_header = _diffFile->readUint32LE();
|
_header = _diffFile->readUint32LE();
|
||||||
_size = _diffFile->readUint32LE();
|
_size = _diffFile->readUint32LE();
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
|
||||||
case 31:
|
case 31:
|
||||||
if (_waitForEffect) {
|
if (_waitForEffect) {
|
||||||
while (_vm->_music->isSoundEffectActive()) {
|
while (_vm->_music->isSoundEffectActive()) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
|
||||||
|
|
||||||
if (_waitForEffect) {
|
if (_waitForEffect) {
|
||||||
while (_vm->_music->isSoundEffectActive()) {
|
while (_vm->_music->isSoundEffectActive()) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
|
|
||||||
if (_vm->_graphics->_dispBitMap->_drawOnScreen)
|
if (_vm->_graphics->_dispBitMap->_drawOnScreen)
|
||||||
|
@ -251,7 +251,7 @@ void Anim::stopDiffEnd() {
|
||||||
|
|
||||||
_stopPlayingEnd = true;
|
_stopPlayingEnd = true;
|
||||||
while (_isPlaying) {
|
while (_isPlaying) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
diffNextFrame();
|
diffNextFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
|
||||||
void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
|
void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
|
||||||
_vm->_anim->stopDiff();
|
_vm->_anim->stopDiff();
|
||||||
loadPict(filename);
|
loadPict(filename);
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
if (!_vm->_music->_loopSoundEffect)
|
if (!_vm->_music->_loopSoundEffect)
|
||||||
_vm->_music->stopSoundEffect();
|
_vm->_music->stopSoundEffect();
|
||||||
|
@ -647,16 +647,16 @@ void DisplayMan::doScrollBlack() {
|
||||||
img._width = width;
|
img._width = width;
|
||||||
img._height = height;
|
img._height = height;
|
||||||
img._imageData = mem;
|
img._imageData = mem;
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
img.readScreenImage(0, 0);
|
img.readScreenImage(0, 0);
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
byte *baseAddr = getCurrentDrawingBuffer();
|
byte *baseAddr = getCurrentDrawingBuffer();
|
||||||
uint16 by = _vm->_utils->vgaScaleX(4);
|
uint16 by = _vm->_utils->vgaScaleX(4);
|
||||||
uint16 nheight = height;
|
uint16 nheight = height;
|
||||||
|
|
||||||
while (nheight) {
|
while (nheight) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
if (!_vm->_isHiRes)
|
if (!_vm->_isHiRes)
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
|
@ -734,7 +734,7 @@ void DisplayMan::doScrollWipe(const Common::String filename) {
|
||||||
uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
|
uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
|
||||||
|
|
||||||
while (_vm->_music->isSoundEffectActive()) {
|
while (_vm->_music->isSoundEffectActive()) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,13 +742,13 @@ void DisplayMan::doScrollWipe(const Common::String filename) {
|
||||||
setPalette(_vm->_anim->_diffPalette, 256);
|
setPalette(_vm->_anim->_diffPalette, 256);
|
||||||
byte *mem = _vm->_anim->_rawDiffBM._planes[0];
|
byte *mem = _vm->_anim->_rawDiffBM._planes[0];
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
uint16 by = _vm->_utils->vgaScaleX(3);
|
uint16 by = _vm->_utils->vgaScaleX(3);
|
||||||
uint16 nheight = height;
|
uint16 nheight = height;
|
||||||
uint16 startLine = 0, onRow = 0;
|
uint16 startLine = 0, onRow = 0;
|
||||||
|
|
||||||
while (onRow < _vm->_anim->_headerdata._height) {
|
while (onRow < _vm->_anim->_headerdata._height) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
if ((by > nheight) && nheight)
|
if ((by > nheight) && nheight)
|
||||||
by = nheight;
|
by = nheight;
|
||||||
|
@ -798,11 +798,11 @@ void DisplayMan::doScrollBounce() {
|
||||||
int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
|
int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
|
||||||
byte *mem = _vm->_anim->_rawDiffBM._planes[0];
|
byte *mem = _vm->_anim->_rawDiffBM._planes[0];
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
int startLine = _vm->_anim->_headerdata._height - height - 1;
|
int startLine = _vm->_anim->_headerdata._height - height - 1;
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
startLine -= newby[i];
|
startLine -= newby[i];
|
||||||
copyPage(width, height, 0, startLine, mem);
|
copyPage(width, height, 0, startLine, mem);
|
||||||
|
|
||||||
|
@ -811,7 +811,7 @@ void DisplayMan::doScrollBounce() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 8; i > 0; i--) {
|
for (int i = 8; i > 0; i--) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
startLine += newby1[i - 1];
|
startLine += newby1[i - 1];
|
||||||
copyPage(width, height, 0, startLine, mem);
|
copyPage(width, height, 0, startLine, mem);
|
||||||
|
|
||||||
|
@ -841,7 +841,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
|
||||||
|
|
||||||
while (curY < lastY) {
|
while (curY < lastY) {
|
||||||
if (linesDone >= linesLast) {
|
if (linesDone >= linesLast) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
linesDone = 0;
|
linesDone = 0;
|
||||||
}
|
}
|
||||||
|
@ -886,7 +886,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
|
||||||
|
|
||||||
while (curY < lastY) {
|
while (curY < lastY) {
|
||||||
if (linesDone >= linesLast) {
|
if (linesDone >= linesLast) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
linesDone = 0;
|
linesDone = 0;
|
||||||
}
|
}
|
||||||
|
@ -1045,7 +1045,7 @@ void DisplayMan::fade(bool fadeIn, uint16 res) {
|
||||||
|
|
||||||
setAmigaPal(newPal, 16);
|
setAmigaPal(newPal, 16);
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -493,7 +493,7 @@ void LabEngine::mainGameLoop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we check the music at least after every message
|
// Make sure we check the music at least after every message
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
interfaceOn();
|
interfaceOn();
|
||||||
IntuiMessage *curMsg = _event->getMsg();
|
IntuiMessage *curMsg = _event->getMsg();
|
||||||
if (g_engine->shouldQuit()) {
|
if (g_engine->shouldQuit()) {
|
||||||
|
@ -505,7 +505,7 @@ void LabEngine::mainGameLoop() {
|
||||||
// Does music load and next animation frame when you've run out of messages
|
// Does music load and next animation frame when you've run out of messages
|
||||||
gotMessage = false;
|
gotMessage = false;
|
||||||
_music->checkRoomMusic();
|
_music->checkRoomMusic();
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
_anim->diffNextFrame();
|
_anim->diffNextFrame();
|
||||||
|
|
||||||
if (_followingCrumbs) {
|
if (_followingCrumbs) {
|
||||||
|
@ -551,7 +551,7 @@ void LabEngine::showLab2Teaser() {
|
||||||
_graphics->readPict("P:End/L2In.1");
|
_graphics->readPict("P:End/L2In.1");
|
||||||
|
|
||||||
for (uint16 i = 0; i < 120; i++) {
|
for (uint16 i = 0; i < 120; i++) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
waitTOF();
|
waitTOF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +559,7 @@ void LabEngine::showLab2Teaser() {
|
||||||
_graphics->readPict("P:End/Lost");
|
_graphics->readPict("P:End/Lost");
|
||||||
|
|
||||||
while (!_event->getMsg() && !shouldQuit()) {
|
while (!_event->getMsg() && !shouldQuit()) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
_anim->diffNextFrame();
|
_anim->diffNextFrame();
|
||||||
waitTOF();
|
waitTOF();
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// Make sure we check the music at least after every message
|
// Make sure we check the music at least after every message
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
curMsg = _event->getMsg();
|
curMsg = _event->getMsg();
|
||||||
|
|
||||||
if (g_engine->shouldQuit())
|
if (g_engine->shouldQuit())
|
||||||
|
@ -736,7 +736,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
|
||||||
|
|
||||||
if (!curMsg) {
|
if (!curMsg) {
|
||||||
// Does music load and next animation frame when you've run out of messages
|
// Does music load and next animation frame when you've run out of messages
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
_anim->diffNextFrame();
|
_anim->diffNextFrame();
|
||||||
} else if (curMsg->_msgClass == kMessageRawKey) {
|
} else if (curMsg->_msgClass == kMessageRawKey) {
|
||||||
if ((curMsg->_code == Common::KEYCODE_y) || (curMsg->_code == Common::KEYCODE_q)) {
|
if ((curMsg->_code == Common::KEYCODE_y) || (curMsg->_code == Common::KEYCODE_q)) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
|
||||||
Common::String path = Common::String("Lab:rooms/Intro/") + filename;
|
Common::String path = Common::String("Lab:rooms/Intro/") + filename;
|
||||||
|
|
||||||
uint timeDelay = (isScreen) ? 35 : 7;
|
uint timeDelay = (isScreen) ? 35 : 7;
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
if (_quitIntro)
|
if (_quitIntro)
|
||||||
return;
|
return;
|
||||||
|
@ -124,7 +124,7 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->_anim->diffNextFrame();
|
_vm->_anim->diffNextFrame();
|
||||||
|
|
||||||
uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000;
|
uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000;
|
||||||
|
@ -190,13 +190,13 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
|
||||||
}
|
}
|
||||||
|
|
||||||
void Intro::musicDelay() {
|
void Intro::musicDelay() {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
if (_quitIntro)
|
if (_quitIntro)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (uint16 i = 0; i < 20; i++) {
|
for (uint16 i = 0; i < 20; i++) {
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
|
@ -206,7 +206,7 @@ void Intro::musicDelay() {
|
||||||
void Intro::nReadPict(const Common::String filename, bool playOnce) {
|
void Intro::nReadPict(const Common::String filename, bool playOnce) {
|
||||||
Common::String finalFileName = Common::String("P:Intro/") + filename;
|
Common::String finalFileName = Common::String("P:Intro/") + filename;
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
introEatMessages();
|
introEatMessages();
|
||||||
|
|
||||||
if (_quitIntro)
|
if (_quitIntro)
|
||||||
|
@ -268,14 +268,14 @@ void Intro::introSequence() {
|
||||||
(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
|
(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->_graphics->fade(true, 0);
|
_vm->_graphics->fade(true, 0);
|
||||||
|
|
||||||
for (int times = 0; times < 150; times++) {
|
for (int times = 0; times < 150; times++) {
|
||||||
if (_quitIntro)
|
if (_quitIntro)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
uint16 temp = palette[2];
|
uint16 temp = palette[2];
|
||||||
|
|
||||||
for (uint16 i = 2; i < 15; i++)
|
for (uint16 i = 2; i < 15; i++)
|
||||||
|
@ -289,7 +289,7 @@ void Intro::introSequence() {
|
||||||
|
|
||||||
_vm->_graphics->fade(false, 0);
|
_vm->_graphics->fade(false, 0);
|
||||||
_vm->_graphics->blackAllScreen();
|
_vm->_graphics->blackAllScreen();
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
nReadPict("Title.A");
|
nReadPict("Title.A");
|
||||||
nReadPict("AB");
|
nReadPict("AB");
|
||||||
|
@ -311,9 +311,9 @@ void Intro::introSequence() {
|
||||||
nReadPict("DA");
|
nReadPict("DA");
|
||||||
musicDelay();
|
musicDelay();
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->_graphics->blackAllScreen();
|
_vm->_graphics->blackAllScreen();
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
TextFont *msgFont = _vm->_resource->getFont("F:Map.fon");
|
TextFont *msgFont = _vm->_resource->getFont("F:Map.fon");
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ void Intro::introSequence() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_graphics->blackAllScreen();
|
_vm->_graphics->blackAllScreen();
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
_introDoBlack = true;
|
_introDoBlack = true;
|
||||||
nReadPict("Station1");
|
nReadPict("Station1");
|
||||||
|
@ -369,7 +369,7 @@ void Intro::introSequence() {
|
||||||
for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
|
for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
|
||||||
_vm->_anim->_diffPalette[idx] = 255 - _vm->_anim->_diffPalette[idx];
|
_vm->_anim->_diffPalette[idx] = 255 - _vm->_anim->_diffPalette[idx];
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
|
_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
|
|
|
@ -239,4 +239,10 @@ void LabEngine::waitTOF() {
|
||||||
_lastWaitTOFTicks = now;
|
_lastWaitTOFTicks = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LabEngine::updateMusicAndEvents() {
|
||||||
|
_event->processInput();
|
||||||
|
_event->updateMouse();
|
||||||
|
_music->updateMusic();
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Lab
|
} // End of namespace Lab
|
||||||
|
|
|
@ -196,6 +196,7 @@ public:
|
||||||
uint16 getQuarters();
|
uint16 getQuarters();
|
||||||
void setDirection(uint16 direction) { _direction = direction; };
|
void setDirection(uint16 direction) { _direction = direction; };
|
||||||
void setQuarters(uint16 quarters);
|
void setQuarters(uint16 quarters);
|
||||||
|
void updateMusicAndEvents();
|
||||||
void waitTOF();
|
void waitTOF();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -82,7 +82,7 @@ void LabEngine::loadMapData() {
|
||||||
delete mapImages;
|
delete mapImages;
|
||||||
|
|
||||||
Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
|
Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
if (!_music->_loopSoundEffect)
|
if (!_music->_loopSoundEffect)
|
||||||
_music->stopSoundEffect();
|
_music->stopSoundEffect();
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
|
||||||
for (uint16 i = 1; i <= _maxRooms; i++) {
|
for (uint16 i = 1; i <= _maxRooms; i++) {
|
||||||
if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
|
if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
|
||||||
drawRoomMap(i, (bool)(i == curRoom));
|
drawRoomMap(i, (bool)(i == curRoom));
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ void LabEngine::processMap(uint16 curRoom) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// Make sure we check the music at least after every message
|
// Make sure we check the music at least after every message
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
IntuiMessage *msg = _event->getMsg();
|
IntuiMessage *msg = _event->getMsg();
|
||||||
if (g_engine->shouldQuit()) {
|
if (g_engine->shouldQuit()) {
|
||||||
_quitLab = true;
|
_quitLab = true;
|
||||||
|
@ -405,7 +405,7 @@ void LabEngine::processMap(uint16 curRoom) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
|
|
||||||
byte newcolor[3];
|
byte newcolor[3];
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ void LabEngine::doMap(uint16 curRoom) {
|
||||||
|
|
||||||
_graphics->_fadePalette = amigaMapPalette;
|
_graphics->_fadePalette = amigaMapPalette;
|
||||||
|
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
loadMapData();
|
loadMapData();
|
||||||
_graphics->blackAllScreen();
|
_graphics->blackAllScreen();
|
||||||
_event->attachButtonList(&_mapButtonList);
|
_event->attachButtonList(&_mapButtonList);
|
||||||
|
|
|
@ -64,34 +64,32 @@ Music::Music(LabEngine *vm) : _vm(vm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Music::updateMusic() {
|
void Music::updateMusic() {
|
||||||
_vm->_event->processInput();
|
if (!_musicOn || (getPlayingBufferCount() >= MAXBUFFERS))
|
||||||
_vm->_event->updateMouse();
|
return;
|
||||||
|
|
||||||
if (_musicOn && (getPlayingBufferCount() < MAXBUFFERS)) {
|
// NOTE: We need to use malloc(), cause this will be freed with free()
|
||||||
// NOTE: We need to use malloc(), cause this will be freed with free()
|
// by the music code
|
||||||
// by the music code
|
byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
|
||||||
byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
|
fillbuffer(musicBuffer);
|
||||||
fillbuffer(musicBuffer);
|
|
||||||
|
|
||||||
// Queue a music block, and start the music, if needed
|
// Queue a music block, and start the music, if needed
|
||||||
bool startMusicFlag = false;
|
bool startMusicFlag = false;
|
||||||
|
|
||||||
if (!_queuingAudioStream) {
|
if (!_queuingAudioStream) {
|
||||||
_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
|
_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
|
||||||
startMusicFlag = true;
|
startMusicFlag = true;
|
||||||
}
|
|
||||||
|
|
||||||
byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
|
|
||||||
if (_vm->getPlatform() == Common::kPlatformWindows)
|
|
||||||
soundFlags |= Audio::FLAG_16BITS;
|
|
||||||
else if (_vm->getPlatform() == Common::kPlatformDOS)
|
|
||||||
soundFlags |= Audio::FLAG_UNSIGNED;
|
|
||||||
|
|
||||||
_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
|
|
||||||
|
|
||||||
if (startMusicFlag)
|
|
||||||
_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
|
||||||
|
if (_vm->getPlatform() == Common::kPlatformWindows)
|
||||||
|
soundFlags |= Audio::FLAG_16BITS;
|
||||||
|
else if (_vm->getPlatform() == Common::kPlatformDOS)
|
||||||
|
soundFlags |= Audio::FLAG_UNSIGNED;
|
||||||
|
|
||||||
|
_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
|
||||||
|
|
||||||
|
if (startMusicFlag)
|
||||||
|
_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 Music::getPlayingBufferCount() {
|
uint16 Music::getPlayingBufferCount() {
|
||||||
|
@ -157,7 +155,7 @@ void Music::startMusic(bool restartFl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_musicOn = true;
|
_musicOn = true;
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Music::initMusic(const Common::String filename) {
|
bool Music::initMusic(const Common::String filename) {
|
||||||
|
@ -181,7 +179,7 @@ void Music::freeMusic() {
|
||||||
|
|
||||||
void Music::pauseBackMusic() {
|
void Music::pauseBackMusic() {
|
||||||
if (!_musicPaused && _musicOn) {
|
if (!_musicPaused && _musicOn) {
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_musicOn = false;
|
_musicOn = false;
|
||||||
stopSoundEffect();
|
stopSoundEffect();
|
||||||
|
|
||||||
|
@ -198,7 +196,7 @@ void Music::resumeBackMusic() {
|
||||||
|
|
||||||
_vm->_mixer->pauseHandle(_musicHandle, false);
|
_vm->_mixer->pauseHandle(_musicHandle, false);
|
||||||
|
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_musicPaused = false;
|
_musicPaused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +209,7 @@ void Music::setMusic(bool on) {
|
||||||
startMusic(true);
|
startMusic(true);
|
||||||
} else if (!on && _musicOn) {
|
} else if (!on && _musicOn) {
|
||||||
_musicOn = false;
|
_musicOn = false;
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
} else
|
} else
|
||||||
_musicOn = on;
|
_musicOn = on;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +262,7 @@ void Music::resetMusic() {
|
||||||
|
|
||||||
_musicOn = true;
|
_musicOn = true;
|
||||||
setMusic(false);
|
setMusic(false);
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
if (!_oldMusicOn) {
|
if (!_oldMusicOn) {
|
||||||
_tFile = 0;
|
_tFile = 0;
|
||||||
|
@ -279,7 +277,7 @@ void Music::resetMusic() {
|
||||||
|
|
||||||
bool Music::readMusic(const Common::String filename, bool waitTillFinished) {
|
bool Music::readMusic(const Common::String filename, bool waitTillFinished) {
|
||||||
Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
|
Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
if (!_loopSoundEffect)
|
if (!_loopSoundEffect)
|
||||||
stopSoundEffect();
|
stopSoundEffect();
|
||||||
|
|
||||||
|
@ -307,14 +305,14 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (soundTag != 65535) {
|
while (soundTag != 65535) {
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
soundTag = file->readUint32LE();
|
soundTag = file->readUint32LE();
|
||||||
soundSize = file->readUint32LE() - 8;
|
soundSize = file->readUint32LE() - 8;
|
||||||
|
|
||||||
if ((soundTag == 30) || (soundTag == 31)) {
|
if ((soundTag == 30) || (soundTag == 31)) {
|
||||||
if (waitTillFinished) {
|
if (waitTillFinished) {
|
||||||
while (isSoundEffectActive()) {
|
while (isSoundEffectActive()) {
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +325,7 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
|
||||||
} else if (soundTag == 65535L) {
|
} else if (soundTag == 65535L) {
|
||||||
if (waitTillFinished) {
|
if (waitTillFinished) {
|
||||||
while (isSoundEffectActive()) {
|
while (isSoundEffectActive()) {
|
||||||
updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
_vm->waitTOF();
|
_vm->waitTOF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) {
|
||||||
|
|
||||||
void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
|
void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
|
||||||
while (actionList) {
|
while (actionList) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
|
|
||||||
switch (actionList->_actionType) {
|
switch (actionList->_actionType) {
|
||||||
case PLAYSOUND:
|
case PLAYSOUND:
|
||||||
|
@ -387,7 +387,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
|
||||||
_graphics->screenUpdate();
|
_graphics->screenUpdate();
|
||||||
|
|
||||||
while (g_system->getMillis() < targetMillis) {
|
while (g_system->getMillis() < targetMillis) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
_anim->diffNextFrame();
|
_anim->diffNextFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,12 +412,12 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILLMUSIC:
|
case FILLMUSIC:
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAITSOUND:
|
case WAITSOUND:
|
||||||
while (_music->isSoundEffectActive()) {
|
while (_music->isSoundEffectActive()) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
_anim->diffNextFrame();
|
_anim->diffNextFrame();
|
||||||
waitTOF();
|
waitTOF();
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
|
||||||
_music->stopSoundEffect();
|
_music->stopSoundEffect();
|
||||||
} else {
|
} else {
|
||||||
while (_music->isSoundEffectActive()) {
|
while (_music->isSoundEffectActive()) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
_anim->diffNextFrame();
|
_anim->diffNextFrame();
|
||||||
waitTOF();
|
waitTOF();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ TextFont *Resource::getFont(const Common::String fileName) {
|
||||||
if (fileSize <= headerSize)
|
if (fileSize <= headerSize)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
TextFont *textfont = new TextFont();
|
TextFont *textfont = new TextFont();
|
||||||
textfont->_dataLength = fileSize - headerSize;
|
textfont->_dataLength = fileSize - headerSize;
|
||||||
|
@ -76,7 +76,7 @@ TextFont *Resource::getFont(const Common::String fileName) {
|
||||||
Common::String Resource::getText(const Common::String fileName) {
|
Common::String Resource::getText(const Common::String fileName) {
|
||||||
Common::File *dataFile = openDataFile(fileName);
|
Common::File *dataFile = openDataFile(fileName);
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
|
|
||||||
uint32 count = dataFile->size();
|
uint32 count = dataFile->size();
|
||||||
byte *buffer = new byte[count];
|
byte *buffer = new byte[count];
|
||||||
|
@ -151,7 +151,7 @@ void Resource::readViews(uint16 roomNum) {
|
||||||
curRoom->_view[WEST] = readView(dataFile);
|
curRoom->_view[WEST] = readView(dataFile);
|
||||||
curRoom->_rules = readRule(dataFile);
|
curRoom->_rules = readRule(dataFile);
|
||||||
|
|
||||||
_vm->_music->updateMusic();
|
_vm->updateMusicAndEvents();
|
||||||
delete dataFile;
|
delete dataFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ void LabEngine::loadJournalData() {
|
||||||
_graphics->closeFont(&_journalFont);
|
_graphics->closeFont(&_journalFont);
|
||||||
|
|
||||||
_journalFont = _resource->getFont("F:Journal.fon");
|
_journalFont = _resource->getFont("F:Journal.fon");
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
|
|
||||||
Common::String filename = "Lab:Rooms/j0";
|
Common::String filename = "Lab:Rooms/j0";
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ void LabEngine::drawJournalText() {
|
||||||
const char *curText = _journalText.c_str();
|
const char *curText = _journalText.c_str();
|
||||||
|
|
||||||
while (drawingToPage < _journalPage) {
|
while (drawingToPage < _journalPage) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
curText = _journalText.c_str() + charsDrawn;
|
curText = _journalText.c_str() + charsDrawn;
|
||||||
charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
|
charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ void LabEngine::drawJournalText() {
|
||||||
charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
|
charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
|
||||||
}
|
}
|
||||||
|
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
curText = _journalText.c_str() + charsDrawn;
|
curText = _journalText.c_str() + charsDrawn;
|
||||||
_lastPage = (*curText == 0);
|
_lastPage = (*curText == 0);
|
||||||
_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText);
|
_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText);
|
||||||
|
@ -183,14 +183,14 @@ void LabEngine::drawJournalText() {
|
||||||
void LabEngine::turnPage(bool fromLeft) {
|
void LabEngine::turnPage(bool fromLeft) {
|
||||||
if (fromLeft) {
|
if (fromLeft) {
|
||||||
for (int i = 0; i < _graphics->_screenWidth; i += 8) {
|
for (int i = 0; i < _graphics->_screenWidth; i += 8) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
waitTOF();
|
waitTOF();
|
||||||
_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
|
_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
|
||||||
_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
|
_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) {
|
for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
waitTOF();
|
waitTOF();
|
||||||
_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
|
_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
|
||||||
_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
|
_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
|
||||||
|
@ -200,7 +200,7 @@ void LabEngine::turnPage(bool fromLeft) {
|
||||||
|
|
||||||
void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
|
void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
|
||||||
_event->mouseHide();
|
_event->mouseHide();
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
drawJournalText();
|
drawJournalText();
|
||||||
_graphics->loadBackPict("P:Journal.pic", _highPalette);
|
_graphics->loadBackPict("P:Journal.pic", _highPalette);
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
|
||||||
void LabEngine::processJournal() {
|
void LabEngine::processJournal() {
|
||||||
while (1) {
|
while (1) {
|
||||||
// Make sure we check the music at least after every message
|
// Make sure we check the music at least after every message
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
IntuiMessage *msg = _event->getMsg();
|
IntuiMessage *msg = _event->getMsg();
|
||||||
if (g_engine->shouldQuit()) {
|
if (g_engine->shouldQuit()) {
|
||||||
_quitLab = true;
|
_quitLab = true;
|
||||||
|
@ -233,7 +233,7 @@ void LabEngine::processJournal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg)
|
if (!msg)
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
else {
|
else {
|
||||||
uint32 msgClass = msg->_msgClass;
|
uint32 msgClass = msg->_msgClass;
|
||||||
uint16 buttonId = msg->_code;
|
uint16 buttonId = msg->_code;
|
||||||
|
@ -269,7 +269,7 @@ void LabEngine::doJournal() {
|
||||||
_journalBackImage->_imageData = nullptr;
|
_journalBackImage->_imageData = nullptr;
|
||||||
_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
|
_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
|
||||||
|
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
loadJournalData();
|
loadJournalData();
|
||||||
_event->attachButtonList(&_journalButtonList);
|
_event->attachButtonList(&_journalButtonList);
|
||||||
drawJournal(0, true);
|
drawJournal(0, true);
|
||||||
|
@ -330,7 +330,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text
|
||||||
}
|
}
|
||||||
|
|
||||||
while (drawingToPage < _monitorPage) {
|
while (drawingToPage < _monitorPage) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
curText = text + charsDrawn;
|
curText = text + charsDrawn;
|
||||||
charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
|
charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
|
||||||
_lastPage = (*curText == 0);
|
_lastPage = (*curText == 0);
|
||||||
|
@ -377,7 +377,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we check the music at least after every message
|
// Make sure we check the music at least after every message
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
IntuiMessage *msg = _event->getMsg();
|
IntuiMessage *msg = _event->getMsg();
|
||||||
if (g_engine->shouldQuit()) {
|
if (g_engine->shouldQuit()) {
|
||||||
_quitLab = true;
|
_quitLab = true;
|
||||||
|
@ -385,7 +385,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
_music->updateMusic();
|
updateMusicAndEvents();
|
||||||
} else {
|
} else {
|
||||||
uint32 msgClass = msg->_msgClass;
|
uint32 msgClass = msg->_msgClass;
|
||||||
uint16 mouseX = msg->_mouse.x;
|
uint16 mouseX = msg->_mouse.x;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue