From f2c1b182424f3e76ab72a770e8d3f059deb8e929 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Jun 2009 12:15:50 +0000 Subject: Added variable to savegame format so that savegames can be correctly loaded from the ScummVM launcher svn-id: r41423 --- engines/cruise/function.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 7789cb6fb1..5194ad4269 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -774,8 +774,6 @@ int16 Op_UnfreezeParent(void) { return 0; } -int16 protectionCode = 0; - int16 Op_ProtectionFlag(void) { int16 temp = protectionCode; int16 newVar; -- cgit v1.2.3 From 2f3e5f11cb0f384c81cf37c716c66c33976634d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Jun 2009 03:39:30 +0000 Subject: Beginnings of music support for Cruise, based on the cine engine sound code (note that the music played isn't yet correct, though) svn-id: r41506 --- engines/cruise/function.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 5194ad4269..7df674a3d3 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -1354,22 +1354,22 @@ int16 Op_LoadSong(void) { strcpy(buffer, ptr); strToUpper(buffer); - _vm->music().loadSong(buffer); + _vm->sound().loadMusic(buffer); changeCursor(CURSOR_NORMAL); return 0; } int16 Op_PlaySong(void) { - if (_vm->music().songLoaded() && !_vm->music().songPlayed()) - _vm->music().startSong(); + if (_vm->sound().songLoaded() && !_vm->sound().songPlayed()) + _vm->sound().playMusic(); return 0; } int16 Op_StopSong(void) { - if (_vm->music().isPlaying()) - _vm->music().stop(); + if (_vm->sound().isPlaying()) + _vm->sound().stopMusic(); return 0; } @@ -1383,12 +1383,12 @@ int16 Op_RestoreSong(void) { int16 Op_SongSize(void) { int size, oldSize; - if (_vm->music().songLoaded()) { - byte *pSize = _vm->music().songData() + 470; - oldSize = *pSize; + if (_vm->sound().songLoaded()) { + oldSize = _vm->sound().numOrders(); + size = popVar(); if ((size >= 1) && (size < 128)) - *pSize = size; + _vm->sound().setNumOrders(size); } else oldSize = 0; @@ -1399,35 +1399,34 @@ int16 Op_SetPattern(void) { int value = popVar(); int offset = popVar(); - if (_vm->music().songLoaded()) { - byte *pData = _vm->music().songData(); - *(pData + 472 + offset) = (byte)value; + if (_vm->sound().songLoaded()) { + _vm->sound().setPattern(offset, value); } return 0; } int16 Op_FadeSong(void) { - _vm->music().fadeSong(); + _vm->sound().fadeSong(); return 0; } int16 Op_FreeSong(void) { - _vm->music().stop(); - _vm->music().removeSong(); + _vm->sound().stopMusic(); + _vm->sound().removeMusic(); return 0; } int16 Op_SongLoop(void) { - bool oldLooping = _vm->music().looping(); - _vm->music().setLoop(popVar() != 0); + bool oldLooping = _vm->sound().musicLooping(); + _vm->sound().musicLoop(popVar() != 0); return oldLooping; } int16 Op_SongPlayed(void) { - return _vm->music().songPlayed(); + return _vm->sound().songPlayed(); } void setVar49Value(int value) { @@ -1632,7 +1631,7 @@ int16 Op_GetNodeY(void) { } int16 Op_SetVolume(void) { - int oldVolume = _vm->music().getVolume() >> 2; + int oldVolume = _vm->sound().getVolume() >> 2; int newVolume = popVar(); // TODO: The game seems to expect the volume will only range from 0 - 63, so for now @@ -1641,7 +1640,7 @@ int16 Op_SetVolume(void) { if (newVolume > 63) newVolume = 63; if (newVolume >= 0) { int volume = 63 - newVolume; - _vm->music().setVolume(volume << 2); + _vm->sound().setVolume(volume << 2); } return oldVolume >> 2; -- cgit v1.2.3 From 31ace2c66cba4e2e689daef8fb28fc8f3ab0b14e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 20 Jun 2009 08:15:39 +0000 Subject: Implemented the library function Op_SongExist svn-id: r41703 --- engines/cruise/function.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 7df674a3d3..a27fa7a044 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -1647,9 +1647,16 @@ int16 Op_SetVolume(void) { } int16 Op_SongExist(void) { - char* songName = (char*)popPtr(); + const char *songName = (char*)popPtr(); - warning("Unimplemented \"Op_SongExist\": %s", songName); + if (songName) { + char name[33]; + strcpy(name, songName); + strToUpper(name); + + if (!strcmp(_vm->sound().musicName(), name)) + return 1; + } return 0; } -- cgit v1.2.3 From 382af0407f1ed5e1447a783822a327d3cc4f17cd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Jun 2009 05:13:29 +0000 Subject: Bugfixes to pre-loading and handling of resources such as sound files svn-id: r41724 --- engines/cruise/function.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index a27fa7a044..44107d4879 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -357,10 +357,10 @@ int16 Op_FindSet(void) { } int16 Op_RemoveFrame(void) { - int var1 = popVar(); - int var2 = popVar(); + int count = popVar(); + int start = popVar(); - resetFileEntryRange(var2, var1); + resetFileEntryRange(start, count); return (0); } @@ -563,26 +563,22 @@ int16 Op_LoadFrame(void) { } int16 Op_LoadAbs(void) { - int param1; -// int param2; -// int param3; + int slot; char name[36] = ""; char *ptr; int result = 0; ptr = (char *) popPtr(); + slot = popVar(); - strcpy(name, ptr); - - param1 = popVar(); - - if (param1 >= 0 || param1 < NUM_FILE_ENTRIES) { + if ((slot >= 0) && (slot < NUM_FILE_ENTRIES)) { + strcpy(name, ptr); strToUpper(name); gfxModuleData_gfxWaitVSync(); gfxModuleData_gfxWaitVSync(); - result = loadFullBundle(name, param1); + result = loadFullBundle(name, slot); } changeCursor(CURSOR_NORMAL); -- cgit v1.2.3 From b14fa66f9f7b105d18b00488c9bd620f77082fab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Jun 2009 11:53:11 +0000 Subject: Minor fixes to the individual note playing code svn-id: r41726 --- engines/cruise/function.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 44107d4879..1dbac3e209 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -32,6 +32,10 @@ namespace Cruise { +uint32 Period(uint32 hz) { + return ((uint32)(100000000L / ((uint32)hz * 28L))); +} + //#define FUNCTION_DEBUG int16 Op_LoadOverlay(void) { @@ -246,15 +250,14 @@ int16 Op_StopFX(void) { int16 Op_FreqFX(void) { int volume = popVar(); - int speed = popVar(); + int freq2 = popVar(); int channelNum = popVar(); int sampleNum = popVar(); if ((sampleNum >= 0) && (sampleNum < NUM_FILE_ENTRIES) && (filesDatabase[sampleNum].subData.ptr)) { - if (speed == -1) - speed = filesDatabase[sampleNum].subData.transparency; - - _vm->sound().startNote(channelNum, volume, speed); + int freq = Period(freq2 * 1000); + + _vm->sound().startNote(channelNum, volume, freq); } return (0); -- cgit v1.2.3 From 8dfbd0f845689a092615352b157a85bb779a3f1e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 22 Jun 2009 06:17:50 +0000 Subject: Implemented the Op_SetVolume method like the original, which simply set a dummy variable and never actually changed the volume svn-id: r41748 --- engines/cruise/function.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 1dbac3e209..db7d1eb167 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -1630,16 +1630,13 @@ int16 Op_GetNodeY(void) { } int16 Op_SetVolume(void) { - int oldVolume = _vm->sound().getVolume() >> 2; + int oldVolume = _vm->sound().getVolume(); int newVolume = popVar(); - // TODO: The game seems to expect the volume will only range from 0 - 63, so for now - // I'm doing a translation of the full range 0 - 255 to the 0 - 63 for this script. - // Need to verify at some point that there's no problem with this if (newVolume > 63) newVolume = 63; if (newVolume >= 0) { int volume = 63 - newVolume; - _vm->sound().setVolume(volume << 2); + _vm->sound().setVolume(volume); } return oldVolume >> 2; -- cgit v1.2.3 From 4f631e9a8998788e3ebc9d346d7db6a7504c7058 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 22 Jun 2009 10:41:32 +0000 Subject: Removed redundant variation of the routine to play sound effects svn-id: r41763 --- engines/cruise/function.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index db7d1eb167..10d05de46c 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -209,8 +209,8 @@ int16 Op_PlayFX(void) { if (speed == -1) speed = filesDatabase[sampleNum].subData.transparency; - _vm->sound().startSound(channelNum, filesDatabase[sampleNum].subData.ptr, - filesDatabase[sampleNum].width, speed, volume, false); + _vm->sound().playSound(channelNum, filesDatabase[sampleNum].subData.ptr, + filesDatabase[sampleNum].width, volume); } return (0); @@ -226,8 +226,8 @@ int16 Op_LoopFX(void) { if (speed == -1) speed = filesDatabase[sampleNum].subData.transparency; - _vm->sound().startSound(channelNum, filesDatabase[sampleNum].subData.ptr, - filesDatabase[sampleNum].width, speed, volume, true); + _vm->sound().playSound(channelNum, filesDatabase[sampleNum].subData.ptr, + filesDatabase[sampleNum].width, volume); } return (0); -- cgit v1.2.3 From 510700b0860e2f109deadcc2523b1232399085ea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 23 Jun 2009 01:01:16 +0000 Subject: Bugfixes to keep sound effects to channel #4 like the original (it ignores the channel parameter to the given library routine) svn-id: r41787 --- engines/cruise/function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 10d05de46c..5f65dce913 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -209,7 +209,7 @@ int16 Op_PlayFX(void) { if (speed == -1) speed = filesDatabase[sampleNum].subData.transparency; - _vm->sound().playSound(channelNum, filesDatabase[sampleNum].subData.ptr, + _vm->sound().playSound(filesDatabase[sampleNum].subData.ptr, filesDatabase[sampleNum].width, volume); } @@ -226,7 +226,7 @@ int16 Op_LoopFX(void) { if (speed == -1) speed = filesDatabase[sampleNum].subData.transparency; - _vm->sound().playSound(channelNum, filesDatabase[sampleNum].subData.ptr, + _vm->sound().playSound(filesDatabase[sampleNum].subData.ptr, filesDatabase[sampleNum].width, volume); } -- cgit v1.2.3 From 6c049f6b29591262a30864d0570f2a6128f1594d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 24 Jun 2009 17:01:01 +0000 Subject: Silence unsued variables warnings. svn-id: r41827 --- engines/cruise/function.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cruise/function.cpp') diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 5f65dce913..eab69c6846 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -202,7 +202,7 @@ int16 Op_Random(void) { int16 Op_PlayFX(void) { int volume = popVar(); int speed = popVar(); - int channelNum = popVar(); + /*int channelNum = */popVar(); int sampleNum = popVar(); if ((sampleNum >= 0) && (sampleNum < NUM_FILE_ENTRIES) && (filesDatabase[sampleNum].subData.ptr)) { @@ -219,7 +219,7 @@ int16 Op_PlayFX(void) { int16 Op_LoopFX(void) { int volume = popVar(); int speed = popVar(); - int channelNum = popVar(); + /*int channelNum = */popVar(); int sampleNum = popVar(); if ((sampleNum >= 0) && (sampleNum < NUM_FILE_ENTRIES) && (filesDatabase[sampleNum].subData.ptr)) { -- cgit v1.2.3