aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Brown2002-03-18 11:50:09 +0000
committerJames Brown2002-03-18 11:50:09 +0000
commitac19e7001a5a5a3355bfc1473350b25b4ee1ab03 (patch)
tree3331d25fdc40396fcba6e8751f67a9ca21f1df05
parent32186f8614700f979f2f3e80c8e19263e25c6e51 (diff)
downloadscummvm-rg350-ac19e7001a5a5a3355bfc1473350b25b4ee1ab03.tar.gz
scummvm-rg350-ac19e7001a5a5a3355bfc1473350b25b4ee1ab03.tar.bz2
scummvm-rg350-ac19e7001a5a5a3355bfc1473350b25b4ee1ab03.zip
Do some stuff to fix loom cd-music syncro. Sequences now run without 'speeding' by.. but they are still slightly out of sync.
svn-id: r3781
-rw-r--r--cdmusic.h2
-rw-r--r--script.cpp2
-rw-r--r--script_v1.cpp19
-rw-r--r--scummvm.cpp4
-rw-r--r--sdl.cpp39
-rw-r--r--sound.cpp2
6 files changed, 36 insertions, 32 deletions
diff --git a/cdmusic.h b/cdmusic.h
index ae8637dcd9..f8514504d7 100644
--- a/cdmusic.h
+++ b/cdmusic.h
@@ -22,7 +22,7 @@
#define CD_MUSIC_H
void cd_stop();
-void cd_play(int track, int num_loops, int start_frame);
+void cd_play(int track, int num_loops, int start_frame, int end_track);
int cd_is_running();
void cd_music_loop();
diff --git a/script.cpp b/script.cpp
index dae762e0cb..1f96cb8e51 100644
--- a/script.cpp
+++ b/script.cpp
@@ -35,7 +35,7 @@ void Scumm::runScript(int script, int a, int b, int16 *lvarptr) {
if (b==0)
stopScriptNr(script);
-
+
if (script < _numGlobalScripts) {
scriptPtr = getResourceAddress(rtScript, script);
if(_features & GF_SMALL_HEADER)
diff --git a/script_v1.cpp b/script_v1.cpp
index 670a5e33af..0218d32226 100644
--- a/script_v1.cpp
+++ b/script_v1.cpp
@@ -22,6 +22,7 @@
#include "stdafx.h"
#include "scumm.h"
+#include "cdmusic.h"
void Scumm::setupOpcodes() {
static const OpcodeProc opcode_list[] = {
@@ -2450,14 +2451,16 @@ void Scumm::decodeParseString() {
case 7: /* overhead */
string[textSlot].overhead = true;
break;
- case 8: { /* play loom talkie sound - use in other games ? */
- int offset = getVarOrDirectWord(0x80);
- int delay = getVarOrDirectWord(0x40);
-
- if (_gameId == GID_LOOM256)
- cd_playtrack(1, offset, delay);
- break;
- }
+ case 8: { /* play loom talkie sound - use in other games ? */
+ int offset = (int)(getVarOrDirectWord(0x80) * 7.5 - 22650);
+ int delay = (int)(getVarOrDirectWord(0x40) * 7.5) + 10;
+
+ if (_gameId == GID_LOOM256)
+ cd_play(1, 0, offset, delay);
+ else
+ warning("parseString: 8");
+ }
+ break;
case 15:
_messagePtr = _scriptPointer;
switch(textSlot) {
diff --git a/scummvm.cpp b/scummvm.cpp
index 1f9b2d7a7a..8e61d41f94 100644
--- a/scummvm.cpp
+++ b/scummvm.cpp
@@ -341,7 +341,7 @@ int Scumm::scummLoop(int delta) {
_vars[VAR_MI1_TIMER]+=5;
else
if(_features & GF_OLD256)
- _vars[VAR_MUSIC_FLAG]++;
+ _vars[VAR_MUSIC_FLAG]++; // ENDERFIX
if (_saveLoadFlag) {
if (_saveLoadFlag==1) {
@@ -432,7 +432,7 @@ int Scumm::scummLoop(int delta) {
if (!(++_expire_counter)) {
increaseResourceCounter();
}
-
+
_vars[VAR_TIMER] = 0;
return _vars[VAR_TIMER_NEXT];
diff --git a/sdl.cpp b/sdl.cpp
index 25e1659502..428fedf412 100644
--- a/sdl.cpp
+++ b/sdl.cpp
@@ -666,32 +666,25 @@ void fill_sound(void *userdata, Uint8 *stream, int len) {
scumm.mixWaves((int16*)stream, len>>1);
}
-void cd_playtrack(int track, int offset, int delay) {
- if (!cdrom) return;
-
- SDL_CDStatus(cdrom);
- SDL_CDPlayTracks(cdrom, track, (int)((offset * 7.5) - 22650), 0, (int)(delay * 7.5));
-}
-
-static int cd_track, cd_num_loops = 0, cd_start_frame;
+static int cd_track, cd_num_loops = 0, cd_start_frame, cd_end_frame;
// On my system, calling SDL_CDStatus all the time slows things down a
// lot and prevents music from playing at all :( So this saves the
// time the track is expected to be finished.
-static Uint32 cd_end_time;
+static Uint32 cd_end_time, cd_stop_time, cd_next_second;
-static Uint32 cd_stop_time;
-
-void cd_play(int track, int num_loops, int start_frame) {
- // warning("cd_play(%d,%d,%d)", track, num_loops, start_frame);
+void cd_play(int track, int num_loops, int start_frame, int end_frame) {
+ // warning("cd_play(%d,%d,%d,%d)", track, num_loops, start_frame, end_frame);
if (!cdrom) return;
+ scumm._vars[14] = 0;
cd_track = track;
cd_num_loops = num_loops;
cd_start_frame = start_frame;
-
+
SDL_CDStatus(cdrom);
- SDL_CDPlayTracks(cdrom, track, start_frame, 1, 0);
+ SDL_CDPlayTracks(cdrom, track, start_frame, 0, end_frame);
+ cd_end_frame = end_frame;
cd_stop_time = 0;
cd_end_time = SDL_GetTicks() +
cdrom->track[track].length * 1000 / CD_FPS;
@@ -721,26 +714,34 @@ static void cd_shutdown() {
void cd_music_loop() {
if (!cdrom) return;
-
+/* if (SDL_GetTicks() >= cd_next_second) {
+ / printf("%d started at %d, fps\n", scumm._vars[14], cd_start_frame, CD_FPS);
+ //scumm._vars[14]++; //varmusicflag
+ cd_next_second = SDL_GetTicks() + 1;
+ } */
+
if (cd_stop_time != 0 && SDL_GetTicks() >= cd_stop_time) {
SDL_CDStop(cdrom);
cd_num_loops = 0;
cd_stop_time = 0;
return;
}
+
if (cd_num_loops == 0 || SDL_GetTicks() < cd_end_time)
return;
+
if (cd_num_loops != 1 && SDL_CDStatus(cdrom) != CD_STOPPED) {
// Wait another second for it to be done
cd_end_time += 1000;
return;
}
+
if (cd_num_loops > 0)
cd_num_loops--;
+
if (cd_num_loops != 0) {
- SDL_CDPlayTracks(cdrom, cd_track, cd_start_frame, 1, 0);
- cd_end_time = SDL_GetTicks() +
- cdrom->track[cd_track].length * 1000 / CD_FPS;
+ SDL_CDPlayTracks(cdrom, cd_track, cd_start_frame, 0, cd_end_frame);
+ cd_end_time = SDL_GetTicks() + cdrom->track[cd_track].length * 1000 / CD_FPS;
}
}
diff --git a/sound.cpp b/sound.cpp
index 50b36e2884..3c90b528be 100644
--- a/sound.cpp
+++ b/sound.cpp
@@ -106,7 +106,7 @@ void Scumm::playSound(int sound) {
if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
ptr += 8;
cd_play(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
- (ptr[18] * 60 + ptr[19]) * 75 + ptr[20]);
+ (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
current_cd_sound = sound;
return;
}