From d42d6122d963237ea35afc8e7015a2ae5b087523 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 1 Apr 2009 10:43:24 +0000 Subject: Laid the basics for music handling svn-id: r39786 --- engines/cruise/function.cpp | 59 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 55e08c99e1..148f8df111 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -26,6 +26,7 @@ #include "cruise/cruise.h" #include "cruise/cruise_main.h" #include "cruise/cell.h" +#include "cruise/sound.h" #include "cruise/staticres.h" #include "common/util.h" @@ -732,11 +733,6 @@ int16 Op_LoadCt(void) { return initCt((char*)popPtr()); } -int16 Op_LoadSong(void) { - popPtr(); - return 0; -} - int16 Op_EndAnim(void) { int param1 = popVar(); int param2 = popVar(); @@ -1207,12 +1203,6 @@ int16 Op_TrackAnim(void) { // setup actor position return 0; } -int16 Op_StopSong(void) { - printf("Partial op 45 stop sound\n"); - - return 0; -} - int16 Op_BgName(void) { char* bgName = (char*)popPtr(); int bgIdx = popVar(); @@ -1237,38 +1227,55 @@ int16 Op_StopFX(void) { return 0; } -int16 Op_PlaySong(void) { - printf("PlaySong()\n"); +int16 Op_LoadSong(void) { + const char *ptr = (const char *)popPtr(); + char buffer[33]; + + strcpy(buffer, ptr); + strupr(buffer); + _vm->music().loadSong(buffer); + changeCursor(CURSOR_NORMAL); return 0; } -void setVar49Value(int value) { - flagCt = value; -} +int16 Op_PlaySong(void) { + if (_vm->music().songLoaded() && !_vm->music().songPlayed()) + _vm->music().startSong(); -int16 Op_CTOn(void) { - setVar49Value(1); return 0; } -int16 Op_CTOff(void) { - setVar49Value(0); +int16 Op_StopSong(void) { + if (_vm->music().isPlaying()) + _vm->music().stop(); + return 0; } int16 Op_FadeSong(void) { - printf("FadeSong()\n"); + _vm->music().fadeSong(); + return 0; } int16 Op_FreeSong(void) { - printf("FreeSong()\n"); - //freeStuff1(); - freeStuff2(); + _vm->music().stop(); + _vm->music().removeSong(); + return 0; +} + +void setVar49Value(int value) { + flagCt = value; +} - playMusic2 = 0; - playMusic = 0; +int16 Op_CTOn(void) { + setVar49Value(1); + return 0; +} + +int16 Op_CTOff(void) { + setVar49Value(0); return 0; } -- cgit v1.2.3