[Scummvm-cvs-logs] CVS: scummvm cdmusic.h,1.1,1.2 script.cpp,1.36,1.37 script_v1.cpp,1.49,1.50 scummvm.cpp,1.87,1.88 sdl.cpp,1.45,1.46 sound.cpp,1.31,1.32

James Brown ender at users.sourceforge.net
Mon Mar 18 03:51:04 CET 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv24007

Modified Files:
	cdmusic.h script.cpp script_v1.cpp scummvm.cpp sdl.cpp 
	sound.cpp 
Log Message:
Do some stuff to fix loom cd-music syncro. Sequences now run without 'speeding' by.. but they are still slightly out of sync.


Index: cdmusic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/cdmusic.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** cdmusic.h	16 Mar 2002 05:43:38 -0000	1.1
--- cdmusic.h	18 Mar 2002 11:50:08 -0000	1.2
***************
*** 23,27 ****
  
  void cd_stop();
! void cd_play(int track, int num_loops, int start_frame);
  int cd_is_running();
  void cd_music_loop();
--- 23,27 ----
  
  void cd_stop();
! void cd_play(int track, int num_loops, int start_frame, int end_track);
  int cd_is_running();
  void cd_music_loop();

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** script.cpp	16 Mar 2002 18:03:28 -0000	1.36
--- script.cpp	18 Mar 2002 11:50:08 -0000	1.37
***************
*** 36,40 ****
  	if (b==0)
  		stopScriptNr(script);
! 
  	if (script < _numGlobalScripts) {
  		scriptPtr = getResourceAddress(rtScript, script);
--- 36,40 ----
  	if (b==0)
  		stopScriptNr(script);
! 	
  	if (script < _numGlobalScripts) {
  		scriptPtr = getResourceAddress(rtScript, script);

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v1.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** script_v1.cpp	18 Mar 2002 01:15:41 -0000	1.49
--- script_v1.cpp	18 Mar 2002 11:50:08 -0000	1.50
***************
*** 23,26 ****
--- 23,27 ----
  #include "stdafx.h"
  #include "scumm.h"
+ #include "cdmusic.h"
  
  void Scumm::setupOpcodes() {
***************
*** 2451,2462 ****
  			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 15:
  			_messagePtr = _scriptPointer;
--- 2452,2465 ----
  			string[textSlot].overhead = true;
  			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;

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** scummvm.cpp	17 Mar 2002 13:00:11 -0000	1.87
--- scummvm.cpp	18 Mar 2002 11:50:08 -0000	1.88
***************
*** 342,346 ****
  	else
  		if(_features & GF_OLD256)
! 			_vars[VAR_MUSIC_FLAG]++;
  
  	if (_saveLoadFlag) {
--- 342,346 ----
  	else
  		if(_features & GF_OLD256)
! 			_vars[VAR_MUSIC_FLAG]++; // ENDERFIX
  
  	if (_saveLoadFlag) {
***************
*** 433,437 ****
  		increaseResourceCounter();
  	}
! 
  	_vars[VAR_TIMER] = 0;
  	return _vars[VAR_TIMER_NEXT];
--- 433,437 ----
  		increaseResourceCounter();
  	}
! 	
  	_vars[VAR_TIMER] = 0;
  	return _vars[VAR_TIMER_NEXT];

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sdl.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** sdl.cpp	17 Mar 2002 13:00:11 -0000	1.45
--- sdl.cpp	18 Mar 2002 11:50:09 -0000	1.46
***************
*** 667,696 ****
  }
  
! 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;
  
  // 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_stop_time;
  
! void cd_play(int track, int num_loops, int start_frame) {
! 	// warning("cd_play(%d,%d,%d)", track, num_loops, start_frame);
  	if (!cdrom) return;
  
  	cd_track = track;
  	cd_num_loops = num_loops;
  	cd_start_frame = start_frame;
! 
  	SDL_CDStatus(cdrom);
! 	SDL_CDPlayTracks(cdrom, track, start_frame, 1, 0);
  	cd_stop_time = 0;
  	cd_end_time = SDL_GetTicks() +
--- 667,689 ----
  }
  
! 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, cd_stop_time, cd_next_second;
  
! 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, 0, end_frame);
! 	cd_end_frame = end_frame;
  	cd_stop_time = 0;
  	cd_end_time = SDL_GetTicks() +
***************
*** 722,726 ****
  void cd_music_loop() {
  	if (!cdrom) return;
! 
  	if (cd_stop_time != 0 && SDL_GetTicks() >= cd_stop_time) {
  		SDL_CDStop(cdrom);
--- 715,724 ----
  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);
***************
*** 729,734 ****
--- 727,734 ----
  		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
***************
*** 736,745 ****
  		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;
  	}
  }
--- 736,746 ----
  		return;
  	}
+ 	
  	if (cd_num_loops > 0)
  		cd_num_loops--;
+ 
  	if (cd_num_loops != 0) {
! 		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;
  	}
  }

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** sound.cpp	16 Mar 2002 05:33:25 -0000	1.31
--- sound.cpp	18 Mar 2002 11:50:09 -0000	1.32
***************
*** 107,111 ****
  		ptr += 8;
  		cd_play(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
! 			(ptr[18] * 60 + ptr[19]) * 75 + ptr[20]);
  		current_cd_sound = sound;
  		return;
--- 107,111 ----
  		ptr += 8;
  		cd_play(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
! 			(ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
  		current_cd_sound = sound;
  		return;





More information about the Scummvm-git-logs mailing list