Ticket #7921: jumbo-midi.patch

File jumbo-midi.patch, 19.3 KB (added by SF/mattjon, 22 years ago)

MIDI "jumbo" patch.

  • Makefile

    diff -urN scummvm/Makefile scummvm-jumbomidi/Makefile
    old new  
    22
    33CC      = gcc
    44CFLAGS  = -g -Wno-multichar
    5 DEFINES = -DUNIX -DHAVE_READLINE -DUSE_TIMIDITY
     5DEFINES = -DUNIX -DHAVE_READLINE
    66LDFLAGS :=
    77INCLUDES:= `sdl-config --cflags`
    88CPPFLAGS= $(DEFINES) $(INCLUDES)
    99LIBS    = `sdl-config --libs` -lreadline -lncurses -lhistory
    1010ZIPFILE := scummvm-`date '+%Y-%m-%d'`.zip
    1111
    12 INCS    = scumm.h scummsys.h stdafx.h
     12INCS    = scumm.h scummsys.h stdafx.h mt32patch.h
    1313
    1414OBJS    = actor.o boxes.o costume.o gfx.o object.o resource.o \
    1515          saveload.o script.o scummvm.o sound.o string.o \
  • imuse.cpp

    diff -urN scummvm/imuse.cpp scummvm-jumbomidi/imuse.cpp
    old new  
    2525#include "stdafx.h"
    2626#include "scumm.h"
    2727#include "sound.h"
     28#include "mt32patch.h"
     29
     30/* includes needed for unix midi support through timidity or internal sequencer */
     31#ifndef WIN32
    2832
    29 #ifdef USE_TIMIDITY
    3033#include <sys/time.h>
    3134#include <unistd.h>
    3235#include <sys/types.h>
     
    4043/* Copy-pasted from Timidity */
    4144#define SEQ_MIDIPUTC            5
    4245
    43 #endif /* USE_TIMIDITY */
     46#endif
    4447
    4548#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
    4649
     
    155158        return 0;
    156159}
    157160
     161void SoundEngine::midiSetDriver(int devicetype, int seq_device) {
     162        _midi_driver.DeviceType = devicetype;
     163        _midi_driver.SeqDevice = seq_device;
     164        _midi_driver.midiInit();
     165}
     166
     167void SoundEngine::midiSetDriver(int devicetype) {
     168        _midi_driver.DeviceType = devicetype;
     169        _midi_driver.midiInit();
     170}
     171
     172int MidiDriver::connect_to_timidity(int port) {
     173        struct hostent *serverhost;
     174        struct sockaddr_in sadd;
     175        int s;
     176       
     177        serverhost = gethostbyname("localhost");
     178        if (serverhost == NULL)
     179                error("Could not resolve host");
     180        sadd.sin_family = serverhost->h_addrtype;
     181        sadd.sin_port = htons(port);
     182        memcpy(&(sadd.sin_addr), serverhost->h_addr_list[0], serverhost->h_length);
     183       
     184        s = socket(AF_INET,SOCK_STREAM,0);
     185        if (s < 0)
     186                error("Could not open socket");
     187        if (connect(s, (struct sockaddr *) &sadd, sizeof(struct sockaddr_in)) < 0)
     188                error("Could not connect to server");
     189       
     190        return s;
     191}
     192
     193int MidiDriver::open_sequencer_device() {
     194        int device;
     195        device = (open("/dev/sequencer", O_RDWR, 0));
     196        if (device < 0) {
     197                        warning("Cannot open sequencer device - using /dev/null (no music will be heard) ");
     198                device = (open(("/dev/null"), O_RDWR, 0));
     199                if (device < 0)
     200                        error("Cannot open /dev/null to dump midi output");
     201        }
     202        return device;
     203}
     204
     205void MidiDriver::midiInitTimidity() {
     206        int s, s2;
     207        int len;
     208        int dummy, newport;
     209        char buf[256];
     210       
     211        SeqDevice = 0;
     212
     213        s = connect_to_timidity(7777);
     214        len = read(s, buf, 256);
     215        buf[len] = '\0';
     216        printf("%s", buf);
     217
     218        sprintf(buf, "SETBUF %f %f\n", 0.1, 0.15);
     219        write(s, buf, strlen(buf));
     220        len = read(s, buf, 256);
     221        buf[len] = '\0';
     222        printf("%s", buf);     
     223       
     224        sprintf(buf, "OPEN lsb\n");
     225        write(s, buf, strlen(buf));
     226        len = read(s, buf, 256);
     227        buf[len] = '\0';
     228        printf("%s", buf);     
     229
     230        sscanf(buf, "%d %d", &dummy, &newport);
     231        printf("         => port = %d\n", newport);
     232       
     233        s2 = connect_to_timidity(newport);
     234        _mo = (void *) s2;
     235}
     236
     237void MidiDriver::midiInitSeq() {
     238        int device;
     239        device = open_sequencer_device();
     240        _mo = (void *) device;
     241}
     242
     243void MidiDriver::midiInitWindows() {
     244        #ifdef WIN32
     245        if (midiOutOpen((HMIDIOUT*)&_mo, MIDI_MAPPER, NULL, NULL, 0) != MMSYSERR_NOERROR)
     246                error("midiOutOpen failed");
     247        #endif
     248}
     249
     250void MidiDriver::midiInitNull() {
     251        warning("Using the NULL midi driver, no music will be heard");
     252}
     253
     254void MidiDriver::midiInit() {
     255        if (MidiInitialized != true) {
     256                switch (DeviceType) {
     257                case MIDI_NULL:
     258                        midiInitNull();
     259                        break;
     260                case MIDI_WINDOWS:
     261                        midiInitWindows();
     262                        break;
     263                case MIDI_TIMIDITY:
     264                        midiInitTimidity();
     265                        break;
     266                case MIDI_SEQ:
     267                        midiInitSeq();
     268                        break;
     269                default:
     270                        #ifdef WIN32
     271                        midiInitWindows();
     272                        #else
     273                        DeviceType = 0;
     274                        midiInitNull();
     275                        #endif
     276                        break;
     277                }
     278                MidiInitialized = true;
     279        } else {
     280                error("Midi driver already initialized");
     281        }
     282}
     283
     284void MidiDriver::MidiOutSeq(void *a, int b) {
     285        int s = (int) a;
     286        unsigned char buf[256];
     287        int position = 0;
     288        switch (b & 0xF0) {
     289        case 0x80:
     290        case 0x90:
     291        case 0xA0:
     292        case 0xB0:
     293        case 0xE0:
     294                buf[position++] = SEQ_MIDIPUTC;
     295                buf[position++] = b;
     296                buf[position++] = SeqDevice;           
     297                buf[position++] = 0;
     298                buf[position++] = SEQ_MIDIPUTC;
     299                buf[position++] = (b >> 8) & 0x7F;
     300                buf[position++] = SeqDevice;           
     301                buf[position++] = 0;
     302                buf[position++] = SEQ_MIDIPUTC;
     303                buf[position++] = (b >> 16) & 0x7F;
     304                buf[position++] = SeqDevice;           
     305                buf[position++] = 0;
     306                break;
     307        case 0xC0:
     308        case 0xD0:
     309                buf[position++] = SEQ_MIDIPUTC;
     310                buf[position++] = b;
     311                buf[position++] = SeqDevice;           
     312                buf[position++] = 0;
     313                buf[position++] = SEQ_MIDIPUTC;
     314                buf[position++] = (b >> 8) & 0x7F;
     315                buf[position++] = SeqDevice;           
     316                buf[position++] = 0;
     317                break;
     318        default:
     319                fprintf(stderr, "Unknown : %08x\n", b);
     320                break;
     321        }
     322        write(s, buf, position);
     323}
     324
     325void MidiDriver::MidiOutWindows(void *a, int b) {
     326        #ifdef WIN32
     327        midiOutShortMsg((HMIDIOUT) a, b);
     328        #endif 
     329}
     330
     331void MidiDriver::MidiOut(void *a, int b) {
     332        if (MidiInitialized != true) {
     333                #ifdef WIN32
     334                DeviceType = MIDI_WINDOWS;
     335                midiInit();
     336                #else
     337                DeviceType = MIDI_NULL;
     338                midiInit();
     339                #endif
     340        }
     341       
     342        if (MidiInitialized == true) {
     343                switch (DeviceType) {
     344                case MIDI_NULL:
     345                        break;
     346                case MIDI_WINDOWS:
     347                        MidiOutWindows(a, b);
     348                        break;
     349                case MIDI_TIMIDITY:
     350                case MIDI_SEQ:
     351                        MidiOutSeq(a, b);
     352                        break;
     353                default:
     354                        error("Invalid midi device type ");
     355                        break;
     356                }
     357        } else {
     358                warning("Trying to write midi data without the driver being initialized");
     359        }
     360}
     361
    158362/**********************************************************************/
    159363
    160364byte *SoundEngine::findTag(int sound, char *tag, int index) {
    161365        byte *ptr = _base_sounds[sound];
    162366        int32 size,pos;
    163367
     368        _using_mt32_translation = (_s->_gameId != GID_TENTACLE);
     369
    164370        if (ptr==NULL) {
    165371                debug(1, "SoundEngine::findTag completely failed finding sound %d", sound);
    166372                return 0;
     
    9141120        init_volume_fader();
    9151121        init_queue();
    9161122        init_parts();
    917         midiInit();
    918 
    9191123        _initialized = true;
    9201124       
    9211125        return 0;
     
    24622666        }
    24632667}
    24642668
    2465 #if defined(WIN32)
    2466 
    2467 void SoundEngine::midiInit() {
    2468         if (midiOutOpen((HMIDIOUT*)&_mo, MIDI_MAPPER, NULL, NULL, 0) != MMSYSERR_NOERROR)
    2469                 error("midiOutOpen failed");
    2470 }
    2471 
    2472 #define MIDI_OUT(a,b) midiOutShortMsg((HMIDIOUT)(a), (b))
    2473 
    2474 #elif defined(USE_TIMIDITY)
    2475 
    2476 static int connect_to_timidity(int port)
    2477 {
    2478         struct hostent *serverhost;
    2479         struct sockaddr_in sadd;
    2480         int s;
    2481        
    2482         serverhost = gethostbyname("localhost");
    2483         if (serverhost == NULL)
    2484                 error("Could not resolve host");
    2485         sadd.sin_family = serverhost->h_addrtype;
    2486         sadd.sin_port = htons(port);
    2487         memcpy(&(sadd.sin_addr), serverhost->h_addr_list[0], serverhost->h_length);
    2488        
    2489         s = socket(AF_INET,SOCK_STREAM,0);
    2490         if (s < 0)
    2491                 error("Could not open socket");
    2492         if (connect(s, (struct sockaddr *) &sadd, sizeof(struct sockaddr_in)) < 0)
    2493                 error("Could not connect to server");
    2494        
    2495         return s;
    2496 }
    2497 
    2498 void SoundEngine::midiInit() {
    2499         int s, s2;
    2500         int len;
    2501         int dummy, newport;
    2502         char buf[256];
    2503 
    2504         s = connect_to_timidity(7777);
    2505         len = read(s, buf, 256);
    2506         buf[len] = '\0';
    2507         printf("%s", buf);
    2508 
    2509         sprintf(buf, "SETBUF %f %f\n", 0.1, 0.15);
    2510         write(s, buf, strlen(buf));
    2511         len = read(s, buf, 256);
    2512         buf[len] = '\0';
    2513         printf("%s", buf);     
    2514        
    2515         sprintf(buf, "OPEN lsb\n");
    2516         write(s, buf, strlen(buf));
    2517         len = read(s, buf, 256);
    2518         buf[len] = '\0';
    2519         printf("%s", buf);     
    2520 
    2521         sscanf(buf, "%d %d", &dummy, &newport);
    2522         printf("         => port = %d\n", newport);
    2523        
    2524         s2 = connect_to_timidity(newport);
    2525         _mo = (void *) s2;
    2526 }
    2527 
    2528 #define DEVICE_NUM 0
    2529 
    2530 static inline void MIDI_OUT(void *a, int b) {
    2531         int s = (int) a;
    2532         unsigned char buf[256];
    2533         int position = 0;
    2534        
    2535         switch (b & 0xF0) {
    2536         case 0x80:
    2537         case 0x90:
    2538         case 0xA0:
    2539         case 0xB0:
    2540         case 0xE0:
    2541                 buf[position++] = SEQ_MIDIPUTC;
    2542                 buf[position++] = b;
    2543                 buf[position++] = DEVICE_NUM;           
    2544                 buf[position++] = 0;
    2545                 buf[position++] = SEQ_MIDIPUTC;
    2546                 buf[position++] = (b >> 8) & 0x7F;
    2547                 buf[position++] = DEVICE_NUM;           
    2548                 buf[position++] = 0;
    2549                 buf[position++] = SEQ_MIDIPUTC;
    2550                 buf[position++] = (b >> 16) & 0x7F;
    2551                 buf[position++] = DEVICE_NUM;           
    2552                 buf[position++] = 0;
    2553                 break;
    2554         case 0xC0:
    2555         case 0xD0:
    2556                 buf[position++] = SEQ_MIDIPUTC;
    2557                 buf[position++] = b;
    2558                 buf[position++] = DEVICE_NUM;           
    2559                 buf[position++] = 0;
    2560                 buf[position++] = SEQ_MIDIPUTC;
    2561                 buf[position++] = (b >> 8) & 0x7F;
    2562                 buf[position++] = DEVICE_NUM;           
    2563                 buf[position++] = 0;
    2564                 break;
    2565         default:
    2566                 fprintf(stderr, "Unknown : %08x\n", b);
    2567                 break;
    2568         }
    2569         write(s, buf, position);
    2570 }
    2571 
    2572 #else
    2573 #define MIDI_OUT(a,b)
    2574 void SoundEngine::midiInit() { }
    2575 #endif
    2576 
    25772669void SoundEngine::midiPitchBend(byte chan, int16 pitchbend) {
    25782670        uint16 tmp;
    25792671
    25802672        if (_midi_pitchbend_last[chan] != pitchbend) {
    25812673                _midi_pitchbend_last[chan] = pitchbend;
    25822674                tmp = (pitchbend<<2) + 0x2000;
    2583                 MIDI_OUT(_mo, ((tmp>>7)&0x7F)<<16 | (tmp&0x7F)<<8 | 0xE0 | chan);
     2675                _midi_driver.MidiOut(_midi_driver._mo, ((tmp>>7)&0x7F)<<16 | (tmp&0x7F)<<8 | 0xE0 | chan);
    25842676        }
    25852677}
    25862678
    25872679void SoundEngine::midiVolume(byte chan, byte volume) {
    25882680        if (_midi_volume_last[chan] != volume) {
    25892681                _midi_volume_last[chan] = volume;
    2590                 MIDI_OUT(_mo, volume<<16 | 7<<8 | 0xB0 | chan);
     2682                _midi_driver.MidiOut(_midi_driver._mo, volume<<16 | 7<<8 | 0xB0 | chan);
    25912683        }
    25922684}
    25932685void SoundEngine::midiPedal(byte chan, bool pedal) {
    25942686        if (_midi_pedal_last[chan] != pedal) {
    25952687                _midi_pedal_last[chan] = pedal;
    2596                 MIDI_OUT(_mo, pedal<<16 | 64<<8 | 0xB0 | chan);
     2688                _midi_driver.MidiOut(_midi_driver._mo, pedal<<16 | 64<<8 | 0xB0 | chan);
    25972689        }
    25982690}
    25992691
    26002692void SoundEngine::midiModWheel(byte chan, byte modwheel) {
    26012693        if (_midi_modwheel_last[chan] != modwheel) {
    26022694                _midi_modwheel_last[chan] = modwheel;
    2603                 MIDI_OUT(_mo, modwheel<<16 | 1<<8 | 0xB0 | chan);
     2695                _midi_driver.MidiOut(_midi_driver._mo, modwheel<<16 | 1<<8 | 0xB0 | chan);
    26042696        }
    26052697}
    26062698
    26072699void SoundEngine::midiEffectLevel(byte chan, byte level) {
    26082700        if (_midi_effectlevel_last[chan] != level) {
    26092701                _midi_effectlevel_last[chan] = level;
    2610                 MIDI_OUT(_mo, level<<16 | 91<<8 | 0xB0 | chan);
     2702                _midi_driver.MidiOut(_midi_driver._mo, level<<16 | 91<<8 | 0xB0 | chan);
    26112703        }
    26122704}
    26132705
    26142706void SoundEngine::midiChorus(byte chan, byte chorus) {
    26152707        if (_midi_chorus_last[chan] != chorus) {
    26162708                _midi_chorus_last[chan] = chorus;
    2617                 MIDI_OUT(_mo, chorus<<16 | 93<<8 | 0xB0 | chan);
     2709                _midi_driver.MidiOut(_midi_driver._mo, chorus<<16 | 93<<8 | 0xB0 | chan);
    26182710        }
    26192711}
    26202712
    26212713void SoundEngine::midiControl0(byte chan, byte value) {
    2622         MIDI_OUT(_mo, value<<16 | 0<<8 | 0xB0 | chan);
     2714        _midi_driver.MidiOut(_midi_driver._mo, value<<16 | 0<<8 | 0xB0 | chan);
    26232715}
    26242716
    26252717void SoundEngine::midiProgram(byte chan, byte program) {
    2626         MIDI_OUT(_mo, program<<8 | 0xC0 | chan);
     2718        if ((chan + 1) != 10) {
     2719                // every percussion item seems to be preceded by a patch change.
     2720                // this is pointless and just wasts midi_driver time.
     2721                if (_using_mt32_translation) {
     2722                        program = mt32pgm[program];
     2723                }
     2724                _midi_driver.MidiOut(_midi_driver._mo, program<<8 | 0xC0 | chan);
     2725        }
    26272726}
    26282727
    26292728void SoundEngine::midiPan(byte chan, int8 pan) {
    26302729        if (_midi_pan_last[chan] != pan) {
    26312730                _midi_pan_last[chan] = pan;
    2632                 MIDI_OUT(_mo, ((pan-64)&0x7F)<<16 | 10<<8 | 0xB0 | chan);
     2731                _midi_driver.MidiOut(_midi_driver._mo, ((pan-64)&0x7F)<<16 | 10<<8 | 0xB0 | chan);
    26332732        }
    26342733}
    26352734
    26362735void SoundEngine::midiNoteOn(byte chan, byte note, byte velocity) {
    2637         MIDI_OUT(_mo, velocity<<16 | note<<8 | 0x90 | chan);   
     2736        _midi_driver.MidiOut(_midi_driver._mo, velocity<<16 | note<<8 | 0x90 | chan);   
    26382737}
    26392738
    26402739void SoundEngine::midiNoteOff(byte chan, byte note) {
    2641         MIDI_OUT(_mo, note<<8 | 0x80 | chan);   
     2740        _midi_driver.MidiOut(_midi_driver._mo, note<<8 | 0x80 | chan); 
    26422741}
    26432742
    26442743void SoundEngine::midiSilence(byte chan) {
    2645         MIDI_OUT(_mo, (64<<8)|0xB0|chan);
    2646         MIDI_OUT(_mo, (123<<8)|0xB0|chan);
     2744        _midi_driver.MidiOut(_midi_driver._mo, (64<<8)|0xB0|chan);
     2745        _midi_driver.MidiOut(_midi_driver._mo, (123<<8)|0xB0|chan);
    26472746}
  • mt32patch.h

    diff -urN scummvm/mt32patch.h scummvm-jumbomidi/mt32patch.h
    old new  
     1uint mt32pgm[128] =
     2{
     3   0,   1,   2,   4,   4,   5,   5,   3,  16,  17,  18,  18,  19,
     4  19,  20,  21,   6,   6,   6,   7,   7,   7,   8,   8,  62,  63,
     5  62,  63,  38,  39,  38,  39,  88,  89,  52, 113,  97,  96,  91,
     6  85,  14, 101,  68,  95,  86, 103,  88,  80,  48,  49,  51,  45,
     7  40,  40,  42,  42,  43,  46,  46,  24,  25,  26,  27, 104,  32,
     8  33,  34,  39,  36,  37,  38,  35,  79,  73,  72,  72,  74,  75,
     9  64,  65,  66,  67,  71,  71,  68,  69,  70,  22,  56,  59,  57,
     10  63,  60,  60,  58,  61,  61,  11,  11,  12,  88,   9,  14,  13,
     11  12, 107, 111,  77,  78,  78,  76, 121,  47, 117, 127, 115, 118,
     12 116, 118,  94, 115,   9,  55, 124, 123, 125, 126, 127
     13};
     14
  • readme.txt

    diff -urN scummvm/readme.txt scummvm-jumbomidi/readme.txt
    old new  
    3434
    3535Running:
    3636--------
    37 Before you run the engine, you need to put the game's datafiles in the same directory as the scummvm executable. The filenames must be in lowercase (monkey2.000 and monkey2.001).
     37Before you run the engine, you need to put the game's datafiles in the same directory as the
     38scummvm executable. The filenames must be in lowercase (monkey2.000 and monkey2.001).
    3839
    3940You can use Ctrl 0-9 and Shift 0-9 to load and save states.
    4041Ctrl-z quits, and Ctrl-f runs in fast mode.
     
    4243Ctrl-s shows memory consumption.
    4344
    4445
    45 Playing sound with Timidity:
    46 ----------------------------
    47 Start Timidity with the following command line :
    48 
    49 $ timidity -irv 7777
    50 
    51 Then just start ScummVM and you should have sound.
    52 
    53 
    54 Good Luck,
    55 Ludvig Strigeus
    56 
    57 
    58 
     46Playing music in Unix with a sound card
     47---------------------------------------
     48*Compile ScummVM as per the instructions above
     49*Start ScummVM as follows:
    5950
     51$ scummvm -sX
     52where X is the device number of your midi output (On most cards, 0 is the external midi device
     53and 1 is the internal midi synth.
    6054
     55Be warned, very few cards apart from Soundblaster Live and Soundblaster AWE cards actually have
     56an internal synth that works in Linux!
    6157
    6258
     59Playing music in Unix with Timidity:
     60----------------------------
     61*Compile ScummVM as per the instructions above
     62*Make sure you have timidity set up with a set of sounds (see the timidity docs for this)
     63*Start timidity with the following command line:
    6364
     65$ timidity -irv 7777
     66If you get errors about invalid interfaces, make sure you have compiled timidity with the
     67configure option "--enable-server"
    6468
     69*Start ScummVM and you should have music.
    6570
    6671
     72Good Luck,
     73Ludvig Strigeus
  • resource.cpp

    diff -urN scummvm/resource.cpp scummvm-jumbomidi/resource.cpp
    old new  
     1
    12/* ScummVM - Scumm Interpreter
    23 * Copyright (C) 2001  Ludvig Strigeus
    34 *
     
    522523                                fileSeek(_fileHandle, -8, SEEK_CUR);
    523524                                fileRead(_fileHandle,createResource(type, index, size2+8), size2+8);
    524525                                return 1;
     526                        } else {
     527                                debug(1,"Scumm::readSoundResource found tag '%c%c%c%c' which it wasn't expecting",
     528                                        tag&0xFF, tag>>8, tag>>16, tag>>24);
    525529                        }
    526530                }
    527531
  • scumm.h

    diff -urN scummvm/scumm.h scummvm-jumbomidi/scumm.h
    old new  
    357357        RF_USAGE_MAX = RF_USAGE
    358358};
    359359
     360enum {
     361        MIDI_NULL = 0,
     362        MIDI_WINDOWS = 1,
     363        MIDI_TIMIDITY = 2,
     364        MIDI_SEQ = 3,
     365};
     366
    360367#define _maxRooms res.num[rtRoom]
    361368#define _maxScripts res.num[rtScript]
    362369#define _maxCostumes res.num[rtCostume]
     
    686693
    687694        int _keyPressed;
    688695
     696        int _midi_driver;
     697        int _midi_seq_device;
    689698        void *_soundDriver;
    690699
    691700        uint16 *_inventory;
  • scummvm.cpp

    diff -urN scummvm/scummvm.cpp scummvm-jumbomidi/scummvm.cpp
    old new  
    382382                        s++;
    383383                        while (*s) {
    384384                                switch(tolower(*s)) {
     385                                #ifndef WIN32
     386                                case 't':
     387                                        _midi_driver = MIDI_TIMIDITY;
     388                                        goto NextArg;
     389                                case 's':
     390                                        _midi_driver = MIDI_SEQ;
     391                                        _midi_seq_device = atoi(s+1);
     392                                        goto NextArg;
     393                                #endif
    385394                                case 'b':
    386395                                        _bootParam = atoi(s+1);
    387396                                        goto NextArg;
     
    396405                                                "\tscummvm [-b<num>] game\n"
    397406                                                "Flags:\n"
    398407                                                "\tb<num> - start in that room\n"
     408                                                #ifndef WIN32
     409                                                "\tt - use timidity for music output\n"
     410                                                "\ts<num> - use a midi sequencer device <num> for music output\n"
     411                                                #endif
    399412                                                "\tf - fullscreen mode\n");
    400413                                        exit(1);
    401414                                }
  • sdl.cpp

    diff -urN scummvm/sdl.cpp scummvm-jumbomidi/sdl.cpp
    old new  
    565565
    566566        scumm._gui = &gui;
    567567        scumm.scummMain(argc, argv);
    568 
     568       
     569        if (scumm._midi_driver == MIDI_SEQ)
     570                sound.midiSetDriver(scumm._midi_driver, scumm._midi_seq_device);
     571        else
     572                sound.midiSetDriver(scumm._midi_driver);
     573               
    569574        gui.init(&scumm);
    570575
    571576        last_time = SDL_GetTicks();
  • sound.cpp

    diff -urN scummvm/sound.cpp scummvm-jumbomidi/sound.cpp
    old new  
    284284 * is needed.
    285285 */
    286286   
    287 static const uint32 sound_tags[] = {
     287static const uint32 gmidi_sound_tags[] = {
    288288        MKID('GMD ')
    289289};
    290290
     291static const uint32 roland_sound_tags[] = {
     292        MKID('ROL ')
     293};
     294
    291295void Scumm::setupSound() {
    292296        SoundEngine *se = (SoundEngine*)_soundDriver;
    293297        if (se)
    294298                se->_base_sounds = res.address[rtSound];
    295299
    296         _soundTagTable = (byte*)sound_tags;
     300        if (_gameId == GID_TENTACLE) {
     301                debug(1,"Found DOTT, so using GMIDI sound tagging");
     302                _soundTagTable = (byte*)gmidi_sound_tags;
     303        } else {
     304                debug(1,"This isn't DOTT, so using Roland sound tagging");
     305                _soundTagTable = (byte*)roland_sound_tags;
     306        }
    297307        _numSoundTags = 1;
    298308        _sfxFile = openSfxFile();
    299309}
  • sound.h

    diff -urN scummvm/sound.h scummvm-jumbomidi/sound.h
    old new  
    3030struct HookDatas;
    3131struct SoundEngine;
    3232
     33struct MidiDriver {
     34        bool MidiInitialized;
     35        int DeviceType;
     36        int SeqDevice;
     37        void *_mo; /* midi out */
     38       
     39        void midiInit();
     40        void midiInitTimidity();
     41        void midiInitSeq();
     42        void midiInitWindows();
     43        void midiInitNull();
     44       
     45        void MidiOut(void *a, int b);
     46        void MidiOutSeq(void *a, int b);
     47        void MidiOutWindows(void *a, int b);
     48       
     49        int connect_to_timidity(int port);
     50        int open_sequencer_device();
     51};
     52
    3353struct Part {
    3454        SoundEngine *_se;
    3555        Part *_next, *_prev;
     
    236256};
    237257
    238258struct SoundEngine {
    239         void *_mo; /* midi out */
    240 
    241259        byte **_base_sounds;
    242260
    243261        Scumm *_s;
     
    247265        bool _paused;
    248266        bool _active_volume_faders;
    249267        bool _initialized;
     268        bool _using_mt32_translation;
     269
    250270        byte _volume_fader_counter;
    251271
    252272        uint _queue_end, _queue_pos, _queue_sound;
     
    268288        uint16 _channel_volume_eff[8]; /* NoSave */
    269289        uint16 _volchan_table[8];
    270290       
     291        MidiDriver _midi_driver;
    271292        Player _players[8];
    272293        SustainingNotes _sustaining_notes[24];
    273294        VolumeFader _volume_fader[8];
     
    341362        void midiNoteOn(byte chan, byte note, byte velocity);
    342363        void midiNoteOff(byte chan, byte note);
    343364        void midiSilence(byte chan);
    344         void midiInit();
    345365
     366        void midiSetDriver(int devicetype);
     367        void midiSetDriver(int devicetype, int seq_device);
     368       
    346369        void adjust_priorities();
    347370
    348371        void fix_parts_after_load();