Skip to content

Commit

Permalink
KYRA: Cleanup background music looping of Kyra3.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schickel committed Apr 6, 2011
1 parent 40dd4f8 commit f19e201
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 127 deletions.
1 change: 0 additions & 1 deletion engines/kyra/animator_mr.cpp
Expand Up @@ -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)
Expand Down
14 changes: 0 additions & 14 deletions engines/kyra/gui_mr.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -1226,8 +1216,6 @@ int GUI_MR::optionsButton(Button *button) {

_currentMenu = &_mainMenu;

_vm->musicUpdate(0);

if (_vm->_menuDirectlyToLoad) {
backUpPage1(_vm->_screenBuffer);

Expand Down Expand Up @@ -1256,7 +1244,6 @@ int GUI_MR::optionsButton(Button *button) {
_isDeathMenu = false;
}

_vm->musicUpdate(0);
backUpPage1(_vm->_screenBuffer);
initMenu(*_currentMenu);
_madeSave = false;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions engines/kyra/gui_mr.h
Expand Up @@ -50,8 +50,6 @@ friend class KyraEngine_MR;

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);
Expand Down
54 changes: 1 addition & 53 deletions engines/kyra/kyra_mr.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -550,29 +525,20 @@ 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];

_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))
Expand All @@ -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;
Expand All @@ -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();

Expand All @@ -640,8 +597,6 @@ void KyraEngine_MR::startup() {
_scoreMax += _scoreTable[i];
}

musicUpdate(0);

memset(_newSceneDlgState, 0, sizeof(_newSceneDlgState));
memset(_conversationState, -1, sizeof(_conversationState));

Expand All @@ -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);
Expand All @@ -667,7 +621,6 @@ void KyraEngine_MR::startup() {
(*_mainButtonData[0].buttonCallback)(&_mainButtonData[0]);

_screen->updateScreen();
musicUpdate(0);
_screen->showMouse();

setNextIdleAnimTimer();
Expand Down Expand Up @@ -1113,27 +1066,22 @@ 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();
}

void KyraEngine_MR::updateWithText() {
updateInput();

musicUpdate(0);
updateMouse();
updateItemAnimations();
updateSpecialSceneScripts();
updateCommandLine();
musicUpdate(0);

restorePage3();
drawAnimObjects();
Expand Down
1 change: 0 additions & 1 deletion engines/kyra/kyra_mr.h
Expand Up @@ -122,7 +122,6 @@ friend class GUI_MR;
void snd_playWanderScoreViaMap(int track, int force);
void stopMusicTrack();

int musicUpdate(int forceRestart);
void fadeOutMusic(int ticks);

void snd_playSoundEffect(int item, int volume);
Expand Down

0 comments on commit f19e201

Please sign in to comment.