Ticket #7941: mi1_cdmusic.diff
File mi1_cdmusic.diff, 7.5 KB (added by , 22 years ago) |
---|
-
CVS/Entries
diff -urN scummvm/CVS/Entries scumm_cd/CVS/Entries
old new 40 40 /whatsnew.txt/1.3/Sun Jan 13 19:49:26 2002// 41 41 /windows.cpp/1.29/Sun Mar 10 17:33:04 2002// 42 42 /x11.cpp/1.3/Wed Mar 6 23:14:16 2002// 43 D/PocketSCUMM////44 43 D/dc//// 45 44 D/debian//// 46 45 D/mac//// -
CVS/Entries.Log
diff -urN scummvm/CVS/Entries.Log scumm_cd/CVS/Entries.Log
old new 1 A D/PocketSCUMM//// 1 2 R D/PocketSCUMM//// -
cdmusic.h
diff -urN scummvm/cdmusic.h scumm_cd/cdmusic.h
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2002 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Header: /cvsroot/scummvm/scummvm/cdmusic.h 1.1 2002/03/14 17:36:13 ender Exp $ 19 */ 20 21 #ifndef CD_MUSIC_H 22 #define CD_MUSIC_H 23 24 void cd_stop(); 25 void cd_play(int track, int num_loops, int start_frame); 26 int cd_is_running(); 27 void cd_music_loop(); 28 29 #endif -
resource.cpp
diff -urN scummvm/resource.cpp scumm_cd/resource.cpp
old new 666 666 fileRead(_fileHandle,createResource(type, idx, total_size+8), total_size+8); 667 667 return 1; 668 668 } 669 } else {669 } else if (basetag == MKID('SOU ')) { 670 670 best_pri = -1; 671 671 while (pos < total_size) { 672 672 tag = fileReadDword(); … … 697 697 fileRead(_fileHandle,createResource(type, idx, best_size), best_size); 698 698 return 1; 699 699 } 700 } else if (FROM_LE_32(basetag) == 24) { 701 fileSeek(_fileHandle, -12, SEEK_CUR); 702 total_size = fileReadDwordBE(); 703 fileSeek(_fileHandle, -8, SEEK_CUR); 704 fileRead(_fileHandle, createResource(type, idx, total_size), total_size); 705 return 1; 706 } else { 707 error("Unrecognized base tag %c%c%c%c in sound %d", 708 basetag&0xff, basetag>>8, basetag>>16, basetag>>24, 709 idx); 700 710 } 701 711 res.roomoffs[type][idx] = 0xFFFFFFFF; 702 712 return 0; -
scumm.h
diff -urN scummvm/scumm.h scumm_cd/scumm.h
old new 1204 1204 OffsetTable *offset_table; 1205 1205 int num_sound_effects; 1206 1206 #endif 1207 1207 1208 int current_cd_sound; 1209 1208 1210 void openRoom(int room); 1209 1211 void deleteRoomOffsets(); 1210 1212 void readRoomsOffsets(); -
sdl.cpp
diff -urN scummvm/sdl.cpp scumm_cd/sdl.cpp
old new 27 27 #include "sound.h" 28 28 #include "SDL_thread.h" 29 29 30 #include "cdmusic.h" 31 30 32 static unsigned int scale; 31 33 32 34 Scumm scumm; … … 176 178 } 177 179 } 178 180 181 cd_music_loop(); // Loop CD Music if necessary 182 179 183 if (SDL_GetTicks() >= start_time + msec_delay) 180 184 break; 181 185 SDL_Delay(10); … … 667 671 SDL_CDPlayTracks(cdrom, track, (int)((offset * 7.5) - 22650), 0, (int)(delay * 7.5)); 668 672 } 669 673 674 static int cd_track, cd_num_loops = 0, cd_start_frame; 675 676 // On my system, calling SDL_CDStatus all the time slows things down a 677 // lot and prevents music from playing at all :( So this saves the 678 // time the track is expected to be finished. 679 static Uint32 cd_end_time; 680 681 static Uint32 cd_stop_time; 682 683 void cd_play(int track, int num_loops, int start_frame) { 684 warning("cd_play(%d,%d,%d)", track, num_loops, start_frame); 685 cd_track = track; 686 cd_num_loops = num_loops; 687 cd_start_frame = start_frame; 688 689 SDL_CDStatus(cdrom); 690 SDL_CDPlayTracks(cdrom, track, start_frame, 1, 0); 691 cd_stop_time = 0; 692 cd_end_time = SDL_GetTicks() + 693 cdrom->track[track].length * 1000 / CD_FPS; 694 } 695 696 // Schedule the music to be stopped after 1/10 sec, unless another 697 // track is started in the meantime. (On my machine, stopping and 698 // then restarting the CD takes a few seconds.) 699 void cd_stop() { 700 cd_stop_time = SDL_GetTicks() + 100; 701 cd_num_loops = 0; 702 } 703 704 int cd_is_running() { 705 return (cd_num_loops != 0 && (SDL_GetTicks() < cd_end_time || 706 SDL_CDStatus(cdrom) != CD_STOPPED)); 707 } 708 709 static void cd_shutdown() { 710 if (cd_num_loops != 0) 711 SDL_CDStop(cdrom); 712 } 713 714 void cd_music_loop() { 715 if (cd_stop_time != 0 && SDL_GetTicks() >= cd_stop_time) { 716 SDL_CDStop(cdrom); 717 cd_num_loops = 0; 718 cd_stop_time = 0; 719 return; 720 } 721 if (cd_num_loops == 0 || SDL_GetTicks() < cd_end_time) 722 return; 723 if (cd_num_loops != 1 && SDL_CDStatus(cdrom) != CD_STOPPED) { 724 // Wait another second for it to be done 725 cd_end_time += 1000; 726 return; 727 } 728 if (cd_num_loops > 0) 729 cd_num_loops--; 730 if (cd_num_loops != 0) { 731 SDL_CDPlayTracks(cdrom, cd_track, cd_start_frame, 1, 0); 732 cd_end_time = SDL_GetTicks() + 733 cdrom->track[cd_track].length * 1000 / CD_FPS; 734 } 735 } 736 670 737 int music_thread(Scumm *s) { 671 738 int old_time, cur_time; 672 739 … … 703 770 704 771 /* Clean up on exit */ 705 772 atexit(SDL_Quit); 773 atexit(cd_shutdown); 706 774 atexit(resetCursor); 707 775 708 776 char buf[512], *gameName; -
sound/CVS/Entries
diff -urN scummvm/sound/CVS/Entries scumm_cd/sound/CVS/Entries
old new 3 3 /fmopl.h/1.1/Sat Dec 1 17:06:13 2001// 4 4 /gmidi.cpp/1.8/Thu Mar 14 13:28:32 2002// 5 5 /gmidi.h/1.2/Thu Mar 14 08:04:21 2002// 6 /imuse.cpp/1.15/ Thu Mar 14 17:36:13 2002//6 /imuse.cpp/1.15/Sat Mar 16 01:38:43 2002// 7 7 D -
sound.cpp
diff -urN scummvm/sound.cpp scumm_cd/sound.cpp
old new 21 21 22 22 #include "stdafx.h" 23 23 #include "scumm.h" 24 #include "sound.h" 25 26 #ifdef _WIN32_WCE 27 extern void *bsearch(const void *, const void *, size_t, 28 size_t, int (*x)(const void *, const void *)); 24 #include "sound.h" 25 #include "cdmusic.h" 26 27 #ifdef _WIN32_WCE 28 extern void *bsearch(const void *, const void *, size_t, 29 size_t, int (*x)(const void *, const void *)); 29 30 #endif 30 31 31 32 void Scumm::addSoundToQueue(int sound) { … … 98 99 } 99 100 100 101 void Scumm::playSound(int sound) { 102 byte *ptr; 101 103 SoundEngine *se = (SoundEngine*)_soundEngine; 104 105 ptr = getResourceAddress(rtSound, sound); 106 if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) { 107 ptr += 8; 108 cd_play(ptr[16], ptr[17] == 0xff ? -1 : ptr[17], 109 (ptr[18] * 60 + ptr[19]) * 75 + ptr[20]); 110 current_cd_sound = sound; 111 return; 112 } 113 102 114 if (_features & GF_OLD256) return; /* FIXME */ 103 115 104 116 if (se) { … … 233 245 SoundEngine *se; 234 246 int i; 235 247 248 if (sound == current_cd_sound) 249 return cd_is_running(); 250 236 251 i = _soundQue2Pos; 237 252 while (i--) { 238 253 if (_soundQue2[i] == sound) … … 275 290 SoundEngine *se; 276 291 int i; 277 292 293 if (a == current_cd_sound) { 294 current_cd_sound = 0; 295 cd_stop(); 296 } 297 278 298 se = (SoundEngine*)_soundEngine; 279 299 if (se) 280 300 se->stop_sound(a); … … 286 306 287 307 void Scumm::stopAllSounds() { 288 308 SoundEngine *se = (SoundEngine*)_soundEngine; 309 310 if (current_cd_sound != 0) { 311 current_cd_sound = 0; 312 cd_stop(); 313 } 314 289 315 if (se) { 290 316 se->stop_all_sounds(); 291 317 se->clear_queue();