KYRA: Cleanup background music looping of Kyra3.

This commit is contained in:
Johannes Schickel
2011-04-07 01:01:55 +02:00
parent 40dd4f89ba
commit f19e2019b8
8 changed files with 5 additions and 127 deletions
-1
View File
@@ -336,7 +336,6 @@ void KyraEngine_MR::setupSceneAnimObject(int animId, uint16 flags, int x, int y,
if (flags & 8) {
_sceneAnimMovie[animId]->open(filename, 1, 0);
musicUpdate(0);
if (_sceneAnimMovie[animId]->opened()) {
anim.wsaFlag = 1;
if (x2 == -1)
-14
View File
@@ -830,8 +830,6 @@ void KyraEngine_MR::processAlbum() {
checkInput(buttonList);
removeInputTop();
musicUpdate(0);
if (_album.curPage != _album.nextPage) {
int oldPage = _album.curPage;
_album.curPage = _album.nextPage;
@@ -1085,11 +1083,6 @@ void GUI_MR::flagButtonDisable(Button *button) {
}
}
void GUI_MR::getInput() {
_vm->musicUpdate(0);
GUI_v2::getInput();
}
const char *GUI_MR::getMenuTitle(const Menu &menu) {
if (!menu.menuNameId)
return 0;
@@ -1173,8 +1166,6 @@ int GUI_MR::quitGame(Button *caller) {
int GUI_MR::optionsButton(Button *button) {
PauseTimer pause(*_vm->_timer);
_vm->musicUpdate(0);
_screen->hideMouse();
updateButton(&_vm->_mainButtonData[0]);
_screen->showMouse();
@@ -1200,7 +1191,6 @@ int GUI_MR::optionsButton(Button *button) {
int oldHandItem = _vm->_itemInHand;
_screen->setMouseCursor(0, 0, _vm->getShapePtr(0));
_vm->musicUpdate(0);
_displayMenu = true;
for (int i = 0; i < 4; ++i) {
@@ -1226,8 +1216,6 @@ int GUI_MR::optionsButton(Button *button) {
_currentMenu = &_mainMenu;
_vm->musicUpdate(0);
if (_vm->_menuDirectlyToLoad) {
backUpPage1(_vm->_screenBuffer);
@@ -1256,7 +1244,6 @@ int GUI_MR::optionsButton(Button *button) {
_isDeathMenu = false;
}
_vm->musicUpdate(0);
backUpPage1(_vm->_screenBuffer);
initMenu(*_currentMenu);
_madeSave = false;
@@ -1407,7 +1394,6 @@ int GUI_MR::gameOptions(Button *caller) {
}
void GUI_MR::setupOptionsButtons() {
_vm->musicUpdate(0);
if (_vm->_configWalkspeed == 3)
_gameOptions.item[0].itemId = 28;
else
-2
View File
@@ -50,8 +50,6 @@ public:
void createScreenThumbnail(Graphics::Surface &dst);
private:
void getInput();
const char *getMenuTitle(const Menu &menu);
const char *getMenuItemTitle(const MenuItem &menuItem);
const char *getMenuItemLabel(const MenuItem &menuItem);
+1 -53
View File
@@ -428,7 +428,7 @@ void KyraEngine_MR::snd_playWanderScoreViaMap(int track, int force) {
char file[13];
sprintf(file, "%s", _soundList[track]);
_musicSoundChannel = _soundDigital->playSound(file, 0xFF, Audio::Mixer::kMusicSoundType);
_musicSoundChannel = _soundDigital->playSound(file, 0xFF, Audio::Mixer::kMusicSoundType, true);
}
_lastMusicCommand = track;
@@ -442,31 +442,6 @@ void KyraEngine_MR::stopMusicTrack() {
_musicSoundChannel = -1;
}
int KyraEngine_MR::musicUpdate(int forceRestart) {
static uint32 mTimer = 0;
static uint16 lock = 0;
if (ABS<int>(_system->getMillis() - mTimer) > (int)(0x0F * _tickLength))
mTimer = _system->getMillis();
if (_system->getMillis() < mTimer && !forceRestart)
return 1;
if (!lock) {
lock = 1;
if (_musicSoundChannel >= 0) {
if (!_soundDigital->isPlaying(_musicSoundChannel)) {
if (_lastMusicCommand != -1)
snd_playWanderScoreViaMap(_lastMusicCommand, 1);
}
}
lock = 0;
mTimer = _system->getMillis() + 0x0F * _tickLength;
}
return 1;
}
void KyraEngine_MR::fadeOutMusic(int ticks) {
if (_musicSoundChannel >= 0) {
_fadeOutMusicChannel = _musicSoundChannel;
@@ -550,11 +525,8 @@ void KyraEngine_MR::startup() {
assert(_album.leftPage.wsa);
_album.rightPage.wsa = new WSAMovie_v2(this);
assert(_album.rightPage.wsa);
musicUpdate(0);
_gamePlayBuffer = new uint8[64000];
musicUpdate(0);
musicUpdate(0);
_interface = new uint8[17920];
_interfaceCommandLine = new uint8[3840];
@@ -562,17 +534,11 @@ void KyraEngine_MR::startup() {
_screen->setFont(Screen::FID_8_FNT);
_stringBuffer = new char[500];
musicUpdate(0);
allocAnimObjects(1, 16, 50);
musicUpdate(0);
memset(_sceneShapes, 0, sizeof(_sceneShapes));
_screenBuffer = new uint8[64000];
musicUpdate(0);
musicUpdate(0);
if (!loadLanguageFile("ITEMS.", _itemFile))
error("Couldn't load ITEMS");
if (!loadLanguageFile("SCORE.", _scoreFile))
@@ -586,13 +552,10 @@ void KyraEngine_MR::startup() {
if (!loadLanguageFile("_ACTOR.", _actorFile))
error("couldn't load _ACTOR");
musicUpdate(0);
openTalkFile(0);
musicUpdate(0);
_currentTalkFile = 0;
openTalkFile(1);
loadCostPal();
musicUpdate(0);
for (int i = 0; i < 16; ++i) {
_sceneAnims[i].flags = 0;
@@ -607,30 +570,24 @@ void KyraEngine_MR::startup() {
for (int i = 0; i < 88; ++i)
_talkObjectList[i].sceneId = 0xFF;
musicUpdate(0);
_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
initItemList(50);
resetItemList();
loadShadowShape();
musicUpdate(0);
loadExtrasShapes();
musicUpdate(0);
_characterShapeFile = 0;
loadCharacterShapes(_characterShapeFile);
updateMalcolmShapes();
musicUpdate(0);
initMainButtonList(true);
loadButtonShapes();
loadInterfaceShapes();
musicUpdate(0);
_screen->loadPalette("PALETTE.COL", _screen->getPalette(0));
_paletteOverlay = new uint8[256];
_screen->generateOverlay(_screen->getPalette(0), _paletteOverlay, 0xF0, 0x19);
loadInterface();
musicUpdate(0);
clearAnimObjects();
@@ -640,8 +597,6 @@ void KyraEngine_MR::startup() {
_scoreMax += _scoreTable[i];
}
musicUpdate(0);
memset(_newSceneDlgState, 0, sizeof(_newSceneDlgState));
memset(_conversationState, -1, sizeof(_conversationState));
@@ -650,7 +605,6 @@ void KyraEngine_MR::startup() {
memset(_sceneList, 0, sizeof(SceneDesc)*98);
_sceneListSize = 98;
musicUpdate(0);
runStartupScript(1, 0);
_res->exists("MOODOMTR.WSA", true);
_invWsa = new WSAMovie_v2(this);
@@ -667,7 +621,6 @@ void KyraEngine_MR::startup() {
(*_mainButtonData[0].buttonCallback)(&_mainButtonData[0]);
_screen->updateScreen();
musicUpdate(0);
_screen->showMouse();
setNextIdleAnimTimer();
@@ -1113,14 +1066,11 @@ int KyraEngine_MR::inputSceneChange(int x, int y, int unk1, int unk2) {
void KyraEngine_MR::update() {
updateInput();
musicUpdate(0);
refreshAnimObjectsIfNeed();
musicUpdate(0);
updateMouse();
updateSpecialSceneScripts();
updateCommandLine();
updateItemAnimations();
musicUpdate(0);
_screen->updateScreen();
}
@@ -1128,12 +1078,10 @@ void KyraEngine_MR::update() {
void KyraEngine_MR::updateWithText() {
updateInput();
musicUpdate(0);
updateMouse();
updateItemAnimations();
updateSpecialSceneScripts();
updateCommandLine();
musicUpdate(0);
restorePage3();
drawAnimObjects();
-1
View File
@@ -122,7 +122,6 @@ private:
void snd_playWanderScoreViaMap(int track, int force);
void stopMusicTrack();
int musicUpdate(int forceRestart);
void fadeOutMusic(int ticks);
void snd_playSoundEffect(int item, int volume);
+3 -47
View File
@@ -36,20 +36,13 @@ void KyraEngine_MR::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2
_screen->hideMouse();
showMessage(0, 0xF0, 0xF0);
if (_inventoryState) {
if (_inventoryState)
hideInventory();
musicUpdate(0);
}
musicUpdate(0);
if (_currentChapter != _currentTalkFile) {
_currentTalkFile = _currentChapter;
openTalkFile(_currentTalkFile);
}
musicUpdate(0);
if (!unk3)
musicUpdate(0);
if (unk1) {
int x = _mainCharacter.x1;
@@ -73,11 +66,9 @@ void KyraEngine_MR::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2
break;
}
musicUpdate(0);
moveCharacter(facing, x, y);
}
musicUpdate(0);
uint32 waitUntilTimer = 0;
if (_lastMusicCommand != _sceneList[sceneId].sound) {
fadeOutMusic(60);
@@ -89,33 +80,23 @@ void KyraEngine_MR::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2
if (!unk3) {
_emc->init(&_sceneScriptState, &_sceneScriptData);
_emc->start(&_sceneScriptState, 5);
while (_emc->isValid(&_sceneScriptState)) {
while (_emc->isValid(&_sceneScriptState))
_emc->run(&_sceneScriptState);
musicUpdate(0);
}
}
musicUpdate(0);
_specialExitCount = 0;
Common::set_to(_specialExitTable, _specialExitTable+ARRAYSIZE(_specialExitTable), 0xFFFF);
musicUpdate(0);
_mainCharacter.sceneId = sceneId;
_sceneList[sceneId].flags &= ~1;
musicUpdate(0);
unloadScene();
musicUpdate(0);
for (int i = 0; i < 4; ++i) {
if (i != _musicSoundChannel && i != _fadeOutMusicChannel)
_soundDigital->stopSound(i);
}
_fadeOutMusicChannel = -1;
musicUpdate(0);
loadScenePal();
musicUpdate(0);
if (queryGameFlag(0x1D9)) {
char filename[20];
@@ -141,9 +122,7 @@ void KyraEngine_MR::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2
resetGameFlag(0x1D9);
}
musicUpdate(0);
loadSceneMsc();
musicUpdate(0);
_sceneExit1 = _sceneList[sceneId].exit1;
_sceneExit2 = _sceneList[sceneId].exit2;
_sceneExit3 = _sceneList[sceneId].exit3;
@@ -152,9 +131,7 @@ void KyraEngine_MR::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2
while (_system->getMillis() < waitUntilTimer)
_system->delayMillis(10);
musicUpdate(0);
initSceneScript(unk3);
musicUpdate(0);
if (_overwriteSceneFacing) {
facing = _mainCharacter.facing;
@@ -162,7 +139,6 @@ void KyraEngine_MR::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2
}
enterNewSceneUnk1(facing, unk2, unk3);
musicUpdate(0);
setCommandLineRestoreTimer(-1);
_sceneScriptState.regs[3] = 1;
enterNewSceneUnk2(unk3);
@@ -306,13 +282,9 @@ void KyraEngine_MR::enterNewSceneUnk2(int unk1) {
void KyraEngine_MR::unloadScene() {
delete[] _sceneStrings;
_sceneStrings = 0;
musicUpdate(0);
_emc->unload(&_sceneScriptData);
musicUpdate(0);
freeSceneShapes();
musicUpdate(0);
freeSceneAnims();
musicUpdate(0);
}
void KyraEngine_MR::freeSceneShapes() {
@@ -356,13 +328,11 @@ void KyraEngine_MR::loadSceneMsc() {
height = stream->readSint16LE();
delete stream;
stream = 0;
musicUpdate(0);
_maskPageMinY = minY;
_maskPageMaxY = minY + height - 1;
_screen->setShapePages(5, 3, _maskPageMinY, _maskPageMaxY);
musicUpdate(0);
_screen->loadBitmap(filename, 5, 5, 0, true);
// HACK
@@ -372,12 +342,10 @@ void KyraEngine_MR::loadSceneMsc() {
_screen->copyBlockToPage(5, 0, _maskPageMinY, 320, height, data);
delete[] data;
musicUpdate(0);
}
void KyraEngine_MR::initSceneScript(int unk1) {
const SceneDesc &scene = _sceneList[_mainCharacter.sceneId];
musicUpdate(0);
char filename[16];
strcpy(filename, scene.filename1);
@@ -400,7 +368,6 @@ void KyraEngine_MR::initSceneScript(int unk1) {
if (shapesCount > 0) {
strcpy(filename, scene.filename1);
strcat(filename, "9.CPS");
musicUpdate(0);
_screen->loadBitmap(filename, 3, 3, 0);
int pageBackUp = _screen->_curPage;
_screen->_curPage = 2;
@@ -413,19 +380,15 @@ void KyraEngine_MR::initSceneScript(int unk1) {
_sceneShapeDescs[i].drawY = stream->readSint16LE();
_sceneShapes[i] = _screen->encodeShape(x, y, w, h, 0);
assert(_sceneShapes[i]);
musicUpdate(0);
}
_screen->_curPage = pageBackUp;
musicUpdate(0);
}
delete stream;
stream = 0;
musicUpdate(0);
strcpy(filename, scene.filename1);
strcat(filename, ".CPS");
_screen->loadBitmap(filename, 3, 3, 0);
musicUpdate(0);
Common::set_to(_specialSceneScriptState, _specialSceneScriptState+ARRAYSIZE(_specialSceneScriptState), false);
_sceneEnterX1 = 160;
@@ -442,14 +405,12 @@ void KyraEngine_MR::initSceneScript(int unk1) {
_emc->init(&_sceneScriptState, &_sceneScriptData);
strcpy(filename, scene.filename2);
strcat(filename, ".EMC");
musicUpdate(0);
_res->exists(filename, true);
_emc->load(filename, &_sceneScriptData, &_opcodes);
strcpy(filename, scene.filename2);
strcat(filename, ".");
loadLanguageFile(filename, _sceneStrings);
musicUpdate(0);
runSceneScript8();
_emc->start(&_sceneScriptState, 0);
@@ -459,12 +420,10 @@ void KyraEngine_MR::initSceneScript(int unk1) {
_emc->run(&_sceneScriptState);
_screen->copyRegionToBuffer(3, 0, 0, 320, 200, _gamePlayBuffer);
musicUpdate(0);
for (int i = 0; i < 10; ++i) {
_emc->init(&_sceneSpecialScripts[i], &_sceneScriptData);
_emc->start(&_sceneSpecialScripts[i], i+9);
musicUpdate(0);
_sceneSpecialScriptsTimer[i] = 0;
}
@@ -476,7 +435,6 @@ void KyraEngine_MR::initSceneScript(int unk1) {
_sceneEnterY3 &= ~1;
_sceneEnterX4 &= ~3;
_sceneEnterY4 &= ~1;
musicUpdate(0);
}
void KyraEngine_MR::initSceneAnims(int unk1) {
@@ -789,10 +747,8 @@ void KyraEngine_MR::runSceneScript4(int unk1) {
void KyraEngine_MR::runSceneScript8() {
_emc->start(&_sceneScriptState, 8);
while (_emc->isValid(&_sceneScriptState)) {
musicUpdate(0);
while (_emc->isValid(&_sceneScriptState))
_emc->run(&_sceneScriptState);
}
}
bool KyraEngine_MR::lineIsPassable(int x, int y) {
-6
View File
@@ -857,8 +857,6 @@ int KyraEngine_MR::o3_defineSceneAnim(EMCState *script) {
const int animId = stackPos(0);
SceneAnim &anim = _sceneAnims[animId];
musicUpdate(0);
uint16 flags = anim.flags = stackPos(1);
int x = anim.x = stackPos(2);
int y = anim.y = stackPos(3);
@@ -875,7 +873,6 @@ int KyraEngine_MR::o3_defineSceneAnim(EMCState *script) {
if (flags & 8) {
_sceneAnimMovie[animId]->open(filename, 1, 0);
musicUpdate(0);
if (_sceneAnimMovie[animId]->opened()) {
anim.wsaFlag = 1;
if (x2 == -1)
@@ -900,8 +897,6 @@ int KyraEngine_MR::o3_defineSceneAnim(EMCState *script) {
}
}
musicUpdate(0);
return 9;
}
@@ -1080,7 +1075,6 @@ int KyraEngine_MR::o3_setupSceneAnimObject(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3_setupSceneAnimObject(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s)", (const void *)script,
stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9),
stackPos(10), stackPos(11), stackPosString(12));
musicUpdate(0);
setupSceneAnimObject(stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8),
stackPos(9), stackPos(10), stackPos(11), stackPosString(12));
return 0;
+1 -3
View File
@@ -340,10 +340,8 @@ void KyraEngine_MR::objectChatWaitToFinish() {
_emc->start(&_chatScriptState, 1);
_animNeedUpdate = false;
while (!_animNeedUpdate && _emc->isValid(&_chatScriptState) && !shouldQuit()) {
musicUpdate(0);
while (!_animNeedUpdate && _emc->isValid(&_chatScriptState) && !shouldQuit())
_emc->run(&_chatScriptState);
}
int curFrame = _animNewFrame;
uint32 delayTime = _animDelayTime;