Ticket #7930: mi1_cdmusic.diff

File mi1_cdmusic.diff, 13.7 KB (added by SF/realmz, 19 years ago)
  • CVS/Entries

    diff -ruN scummvm/CVS/Entries scumm_cd/CVS/Entries
    old new  
    3434/verbs.cpp/1.12/Thu Dec 27 17:51:58 2001//
    3535/whatsnew.txt/1.3/Sun Jan 13 19:49:26 2002//
    3636/windows.cpp/1.24/Fri Dec 28 15:26:28 2001//
    37 D
     37D/PocketSCUMM////
     38D/debian////
     39D/sound////
     40D/wince////
     41D/scummvm////
  • CVS/Entries.Log

    diff -ruN scummvm/CVS/Entries.Log scumm_cd/CVS/Entries.Log
    old new  
    1 A D/PocketSCUMM////
    2 A D/debian////
    3 A D/sound////
    4 A D/wince////
  • Makefile

    diff -ruN scummvm/Makefile scumm_cd/Makefile
    old new  
    1515        saveload.o script.o scummvm.o sound.o string.o \
    1616        sys.o verbs.o sdl.o script_v1.o script_v2.o debug.o gui.o \
    1717        sound/imuse.o sound/fmopl.o sound/adlib.o sound/gmidi.o debugrl.o \
    18         akos.o
     18        akos.o sound/cdmusic.o
    1919
    2020DISTFILES=$(OBJS:.o=.cpp) Makefile scumm.h scummsys.h stdafx.h stdafx.cpp \
    2121        windows.cpp debugrl.h whatsnew.txt readme.txt copying.txt \
  • PocketSCUMM/CVS/Entries

    diff -ruN scummvm/PocketSCUMM/CVS/Entries scumm_cd/PocketSCUMM/CVS/Entries
    old new  
    1 D
     1D/gapi////
     2D/missing////
  • PocketSCUMM/CVS/Entries.Log

    diff -ruN scummvm/PocketSCUMM/CVS/Entries.Log scumm_cd/PocketSCUMM/CVS/Entries.Log
    old new  
    1 A D/gapi////
    2 A D/missing////
  • PocketSCUMM/missing/CVS/Entries

    diff -ruN scummvm/PocketSCUMM/missing/CVS/Entries scumm_cd/PocketSCUMM/missing/CVS/Entries
    old new  
    1 D
     1D/sys////
  • PocketSCUMM/missing/CVS/Entries.Log

    diff -ruN scummvm/PocketSCUMM/missing/CVS/Entries.Log scumm_cd/PocketSCUMM/missing/CVS/Entries.Log
    old new  
    1 A D/sys////
  • debug.cpp

    diff -ruN scummvm/debug.cpp scumm_cd/debug.cpp
    old new  
    2626#include "stdafx.h"
    2727#include "scumm.h"
    2828
     29#include "cdmusic.h"
     30
    2931#ifdef HAVE_READLINE
    3032#include "debugrl.h"
    3133#endif
     
    3840        CMD_ACTOR,
    3941        CMD_SCRIPTS,
    4042        CMD_LOAD_ROOM,
     43        CMD_CD_INFO,
    4144        CMD_EXIT
    4245};
    4346
     
    6871                                "(a)ctor [actornum] -> show actor information\n"
    6972                                "(r)oom roomnum -> load room\n"
    7073                                "(s)cripts -> show running scripts\n"
     74                                "(c)dinfo -> show cd and track info\n"
    7175                                "(e)xit -> exit game\n"
    7276                           );
    7377                return true;
     
    102106                }
    103107                return true;
    104108
     109/*-------------------------------------------------------------------------*/
     110/*CD Music related commands added by realmz for use with Monkey Island 1
     111and for Loom (When Loom support is added and it SHOULD be sooner!) */
     112
     113        case CMD_CD_INFO:
     114                cd_print_info();
     115        return true;
     116
     117/*-------------------------------------------------------------------------*/
     118
    105119        case CMD_EXIT:
    106120                exit(1);
    107121        }
     
    144158        { "a", 1, CMD_ACTOR },
    145159        { "s", 1, CMD_SCRIPTS },
    146160        { "r", 1, CMD_LOAD_ROOM },
     161        { "c", 1, CMD_CD_INFO },
    147162        { "e", 1, CMD_EXIT },
    148163        { 0, 0, 0 },
    149164};
  • debugrl.cpp

    diff -ruN scummvm/debugrl.cpp scumm_cd/debugrl.cpp
    old new  
    1010  "go",
    1111  "actor",
    1212  "scripts",
     13  "cdinfo",
    1314  "exit",
    1415  (char *)NULL
    1516};
  • scummvm.cpp

    diff -ruN scummvm/scummvm.cpp scumm_cd/scummvm.cpp
    old new  
    2323#include "scumm.h"
    2424#include "gui.h"
    2525
     26#include "cdmusic.h"
     27
    2628void Scumm::initRandSeeds() {
    2729        _randSeed1 = 0xA943DE35;
    2830        _randSeed2 = 0x37A9ED27;
     
    202204//      if (_gameId==GID_MONKEY2 && _bootParam==0) {
    203205//              _bootParam = 10001;
    204206//      }
     207
     208        //Init CD Music if Monkey Island 1
     209        if(_gameId==GID_MONKEY) {
     210                cd_init(0); //Init for MI1
     211
     212        }
    205213
    206214        initGraphics(this, _fullScreen);
    207215
  • sdl.cpp

    diff -ruN scummvm/sdl.cpp scumm_cd/sdl.cpp
    old new  
    2727#include "sound.h"
    2828#include "SDL_thread.h"
    2929
     30#include "cdmusic.h"
     31
    3032#define SCALEUP_2x2
    3133
    3234Scumm scumm;
     
    98100                                                s->_saveLoadFlag = 2;
    99101                                        s->_saveLoadCompatible = false;
    100102                                } else if (event.key.keysym.sym=='z' && event.key.keysym.mod&KMOD_CTRL) {
     103                                        cd_stop(); //Stop music on exit
    101104                                        exit(1);
    102105                                } else if (event.key.keysym.sym=='f' && event.key.keysym.mod&KMOD_CTRL) {
    103106                                        s->_fastMode ^= 1;
     
    149152                                break;
    150153
    151154                        case SDL_QUIT:
     155                                cd_stop(); //Stop music on exit
    152156                                exit(1);
    153157                                break;
    154158                        }
    155159                }
     160
     161                cd_music_loop(); //Loop CD Music
    156162
    157163                if (SDL_GetTicks() >= start_time + msec_delay)
    158164                        break;
  • sound/cdmusic.cpp

    diff -ruN scummvm/sound/cdmusic.cpp scumm_cd/sound/cdmusic.cpp
    old new  
     1/* ScummVM - Scumm Interpreter
     2 * Copyright (C) 2001  Ludvig Strigeus
     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 * -------------------------------------------------------------------------
     19 *
     20 * The Secret of Monkey Island uses audio tracks from a CD-ROM for music.
     21 * This file adds FULL support for CD music for Monkey Island through
     22 * custom mapping of sounds to tracks. There is NO purpose and mabye
     23 * no way to know how SCUMM originally mapped the sounds.
     24 * This will also be used to support music and voice for Loom WHEN
     25 * Loom is supported.
     26 *
     27 * By: realmz <realmi2@yahoo.com>
     28 *
     29 * -------------------------------------------------------------------------
     30 */
     31
     32#include <SDL.h>
     33
     34#include "cdmusic.h"
     35
     36
     37#define MAX_MI1_TRACKS 26 //Maximum number of tracks for MI1
     38
     39//Stores a sound number for each track
     40int mi1_sound[MAX_MI1_TRACKS*2] =
     41{
     42        1,115,  //Voodoo
     43        2,114,  //Jail
     44        2,107,  //Saving Elaine (Unsure if correct track)
     45        3,109,  //Forest
     46        3,107,  //Saving Elaine (Unsure if correct track)
     47        4,103,  //Chapel
     48        5,112,  //Melee Island Map
     49        6,104,  //Part x (room changed too fast to hear all)
     50        7,117,  //Guybrush & Elaine
     51        8,101,  //SCUMM Bar
     52        10,119,  //Meanwhile... (Returned to MI)
     53        9,111,  //On LeCheck's Ship
     54        10,100, //Meanwhile... (A Problem...)
     55        11,113, //Circus
     56        14,116, //Monkey Island Map
     57        14,128, //Monkey Island Map
     58        15,105, //Voyage
     59//      15,102, //Voyage (Commented out to prevent restarting track)
     60        17,110, //Intro
     61        17,108, //Intro - Lookout
     62        18,121, //Stan's Used Ships
     63        19,129, //LeChuck Leaving Melee (Kidnapping)
     64        21,127, //Village
     65        22,122, //Dock Sounds
     66        23,126, //Night Sounds
     67        24,123  //Jungle Sounds
     68
     69        //00,106, // ???
     70};
     71
     72int cd_current_track, current_sound;
     73
     74SDL_CD *cdrom;
     75
     76int start_frame,length; //For Loom Support
     77
     78int game_type;
     79
     80int cd_init(int game)
     81{
     82
     83        if (SDL_Init (SDL_INIT_CDROM) < 0)
     84        {
     85              printf ("Failed to open CD-ROM: %s\n", SDL_GetError ());
     86                return -1;
     87        }
     88
     89        if(!SDL_CDNumDrives()){
     90          printf("No CDROM devices available\n");
     91        return -1;
     92        }
     93
     94        cdrom=SDL_CDOpen(0);
     95
     96        if(cdrom == NULL)
     97        {
     98          printf("Couldn't open drive: %s\n", SDL_GetError());
     99          exit(-1);
     100        }
     101
     102cd_current_track = -1;
     103
     104current_sound = -1;
     105
     106start_frame = 0;
     107length = 0;
     108
     109game_type = game; // 0 is MI1 and 1 is Loom
     110
     111return 0;
     112}
     113
     114int cd_print_info()
     115{
     116int min,sec,frame;
     117
     118if(!cdrom)
     119{
     120printf("No CD Music support for this game.\n");
     121return -1;
     122}
     123
     124FRAMES_TO_MSF(cdrom->cur_frame, &min, &sec, &frame);
     125
     126
     127printf("| Track # | M:S:F  |\n");
     128printf("|   %d    | %d:%d:%d |\n",cd_current_track,min,sec,frame);
     129
     130printf(
     131        "Sound Map:\n"
     132        "|---------------|\n"
     133        "| Sound | Track |\n"
     134        "|---------------|\n");
     135
     136for(int i = 0;i<MAX_MI1_TRACKS*2;i+=2)
     137{
     138if(mi1_sound[i] < 10)
     139printf("|  %d    |   %d |\n",mi1_sound[i+1],mi1_sound[i]);
     140else
     141printf("|  %d    |  %d |\n",mi1_sound[i+1],mi1_sound[i]);
     142}
     143
     144printf( "|---------------|\n");
     145
     146return 0;
     147}
     148
     149int cd_stop()
     150{
     151if(!cdrom)
     152return -1;
     153
     154SDL_CDStop(cdrom);
     155
     156cd_current_track = -1;
     157current_sound = -1;
     158
     159return 0;
     160}
     161
     162int cd_stop(int sound)
     163{
     164
     165if(sound == current_sound)
     166return cd_stop();
     167
     168return -1;
     169}
     170
     171int cd_play()
     172{
     173if(!cdrom)
     174return -1;
     175
     176//cd_stop();
     177
     178SDL_CDStatus (cdrom); //Update SDL_CD
     179
     180if(current_sound == 108 && game_type == 0) //Play specific section of track 17
     181{
     182SDL_CDPlayTracks(cdrom,cd_current_track,96*CD_FPS,0,0);
     183return 0;
     184}
     185
     186SDL_CDPlayTracks(cdrom,cd_current_track,start_frame,0,length);
     187
     188return 0;
     189}
     190
     191int cd_track_set(int track)
     192{
     193
     194cd_current_track = track;
     195
     196return 0;
     197}
     198
     199int cd_set_sound(int sound)
     200{
     201
     202if(!cdrom)
     203        return -1;
     204
     205if(game_type == 0) //MI1
     206{
     207
     208if(sound == current_sound) //Don't restart the same sound
     209return 0;
     210
     211        for(int i = 0;i<MAX_MI1_TRACKS*2;i+=2)
     212        {
     213
     214                if(mi1_sound[i+1] == sound)
     215                {
     216                        current_sound = sound;
     217                        cd_track_set(mi1_sound[i]);
     218                        cd_play();
     219                        return 0;
     220                }
     221        }
     222
     223return -1;
     224}
     225
     226else //game_type == 1 which is Loom
     227{
     228        //No loom support yet :(
     229}
     230
     231}
     232
     233int cd_music_loop()
     234{
     235if(!cdrom)
     236return 0;
     237
     238SDL_CDStatus (cdrom); //Update SDL_CD
     239
     240if(cdrom->cur_track != cd_current_track)
     241{
     242cd_play();
     243}
     244
     245return 0;
     246}
  • sound/cdmusic.h

    diff -ruN scummvm/sound/cdmusic.h scumm_cd/sound/cdmusic.h
    old new  
     1/* ScummVM - Scumm Interpreter
     2 * Copyright (C) 2001  Ludvig Strigeus
     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 * -------------------------------------------------------------------------
     19 *
     20 * The Secret of Monkey Island uses audio tracks from a CD-ROM for music.
     21 * This file adds FULL support for CD music for Monkey Island through
     22 * custom mapping of sounds to tracks. There is NO purpose and mabye
     23 * no way to know how SCUMM originally mapped the sounds.
     24 * This will also be used to support music and voice for Loom WHEN
     25 * Loom is supported.
     26 *
     27 * By: realmz <realmi2@yahoo.com>
     28 *
     29 * -------------------------------------------------------------------------
     30 */
     31
     32#ifndef CD_MUSIC_H
     33#define CD_MUSIC_H
     34
     35int cd_init(int game);
     36int cd_print_info();
     37int cd_stop();
     38int cd_stop(int sound);
     39int cd_play();
     40int cd_track_set(int track);
     41int cd_set_sound(int sound);
     42int cd_music_loop();
     43
     44#endif
     45
  • sound.cpp

    diff -ruN scummvm/sound.cpp scumm_cd/sound.cpp
    old new  
    2323#include "scumm.h"
    2424#include "sound.h"
    2525
     26#include "cdmusic.h"
     27
    2628void Scumm::addSoundToQueue(int sound) {
    2729#if !defined(FULL_THROTTLE)
    2830        _vars[VAR_LAST_SOUND] = sound;
     
    9092
    9193void Scumm::playSound(int sound) {
    9294        SoundEngine *se = (SoundEngine*)_soundEngine;
     95
     96        //Set the sound for CD Music, if it's not for music then uses resources.
     97        if(cd_set_sound(sound) == 0)
     98                return;
     99
    93100        if (se) {
    94101                getResourceAddress(rtSound, sound);
    95102                se->start_sound(sound);
     
    239246        for (i=0; i<10; i++)
    240247                if (_soundQue2[i] == (byte)a)
    241248                        _soundQue2[i] = 0;
     249
     250        cd_stop(a);
     251
    242252}
    243253
    244254void Scumm::stopAllSounds() {
  • wince/CVS/Entries

    diff -ruN scummvm/wince/CVS/Entries scumm_cd/wince/CVS/Entries
    old new  
    77/screen.cpp/1.1.1.1/Sun Nov 18 10:24:47 2001//
    88/screen.h/1.1.1.1/Sun Nov 18 10:24:47 2001//
    99/sdl.h/1.1.1.1/Sun Nov 18 10:24:47 2001//
    10 D
     10D/missing////
  • wince/CVS/Entries.Log

    diff -ruN scummvm/wince/CVS/Entries.Log scumm_cd/wince/CVS/Entries.Log
    old new  
    1 A D/missing////
  • wince/missing/CVS/Entries

    diff -ruN scummvm/wince/missing/CVS/Entries scumm_cd/wince/missing/CVS/Entries
    old new  
    1010/signal.h/1.1.1.1/Sun Nov 18 10:24:48 2001//
    1111/time.h/1.1.1.1/Sun Nov 18 10:24:48 2001//
    1212/unistd.h/1.1.1.1/Sun Nov 18 10:24:48 2001//
    13 D
     13D/sys////
  • wince/missing/CVS/Entries.Log

    diff -ruN scummvm/wince/missing/CVS/Entries.Log scumm_cd/wince/missing/CVS/Entries.Log
    old new  
    1 A D/sys////