Added support for scene music and the music-playing opcode to make the

opening scene a bit nicer.

svn-id: r15241
This commit is contained in:
Torbjörn Andersson 2004-09-23 06:53:46 +00:00
parent c7338cccdb
commit caed46c816
3 changed files with 56 additions and 1 deletions

View File

@ -962,6 +962,17 @@ int Scene::defaultScene(int param, R_SCENE_INFO *scene_info) {
_vm->_script->SThreadCompleteThread();
}
if (_desc.musicRN >= 0) {
event.type = R_ONESHOT_EVENT;
event.code = R_MUSIC_EVENT;
event.param = _desc.musicRN;
event.op = EVENT_PLAY;
event.time = 0;
_vm->_events->queue(&event);
} else
_vm->_music->stop();
if (_desc.sceneScriptNum > 0) {
R_SCRIPT_THREAD *_sceneScriptThread;

View File

@ -252,6 +252,7 @@ private:
int SF_setActorZ(R_SCRIPTFUNC_PARAMS);
int SF_getActorX(R_SCRIPTFUNC_PARAMS);
int SF_getActorY(R_SCRIPTFUNC_PARAMS);
int SF_playMusic(R_SCRIPTFUNC_PARAMS);
};
} // End of namespace Saga

View File

@ -104,7 +104,7 @@ void Script::setupScriptFuncList(void) {
{60, 0, OPCODE(SF_getActorX)},
{61, 0, OPCODE(SF_getActorY)},
{62, 0, NULL},
{63, 0, NULL},
{63, 0, OPCODE(SF_playMusic)},
{64, 0, NULL},
{65, 0, NULL},
{66, 0, NULL},
@ -619,4 +619,47 @@ int Script::SF_getActorY(R_SCRIPTFUNC_PARAMS) {
return R_SUCCESS;
}
static int musicTable[] = {
MUSIC_1,
MUSIC_2,
MUSIC_3,
MUSIC_4,
MUSIC_5,
MUSIC_6,
MUSIC_7,
MUSIC_8,
MUSIC_9,
MUSIC_10,
MUSIC_11,
MUSIC_12,
MUSIC_13,
MUSIC_14,
MUSIC_15,
MUSIC_16,
MUSIC_17,
MUSIC_18,
MUSIC_19,
MUSIC_20,
MUSIC_21,
MUSIC_22,
MUSIC_23,
MUSIC_24,
MUSIC_25,
MUSIC_26
};
// Script function #63
int Script::SF_playMusic(R_SCRIPTFUNC_PARAMS) {
SDataWord_T param;
param = thread->pop();
if (/* param >= 0 && */ param < ARRAYSIZE(musicTable))
_vm->_music->play(musicTable[param], 0);
else
_vm->_music->stop();
return R_SUCCESS;
}
} // End of namespace Saga