Ticket #8241: loom-adlib-sound.diff

File loom-adlib-sound.diff, 6.3 KB (added by SF/hoenicke, 21 years ago)

Adlib support for loom.

  • scumm/resource.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
    retrieving revision 1.95
    diff -u -r1.95 resource.cpp
     
    642642        _fileHandle.seek(fileOffs + _fileOffset, SEEK_SET);
    643643
    644644        if (_features & GF_OLD_BUNDLE) {
    645                 size = _fileHandle.readUint16LE();
    646                 _fileHandle.seek(-2, SEEK_CUR);
     645                if ((_features & GF_AFTER_V3)
     646                    && type == rtSound) {
     647                        return readSoundResourceSmallHeader(type, idx);
     648                } else {
     649                        size = _fileHandle.readUint16LE();
     650                        _fileHandle.seek(-2, SEEK_CUR);
     651                }
    647652        } else if (_features & GF_SMALL_HEADER) {
    648653                if (!(_features & GF_SMALL_NAMES))
    649654                        _fileHandle.seek(8, SEEK_CUR);
     
    979984
    980985int Scumm::readSoundResourceSmallHeader(int type, int idx) {
    981986        uint32 pos, total_size, size, dw, tag;
    982         uint32 best_size = 0, best_offs = 0;
     987        uint32 ad_size = 0, ad_offs = 0;
     988        uint32 wa_size = 0, wa_offs = 0;
    983989
    984990        debug(4, "readSoundResourceSmallHeader(%s,%d)", resTypeFromId(type), idx);
    985991
    986992        //if (_rescache->readResource(roomNr, type, idx))
    987993        //              return 1;
    988994
    989         total_size = size = _fileHandle.readUint32LE();
    990         tag = _fileHandle.readUint16LE();
    991         debug(4, "  tag='%c%c', size=%d",
    992                                         (char) (tag & 0xff),
    993                                         (char) ((tag >> 8) & 0xff), size);
    994 
    995         pos = 6;
    996         while (pos < total_size) {
    997                 size = _fileHandle.readUint32LE();
     995        if ((_features & GF_OLD_BUNDLE)) {
     996                wa_offs = _fileHandle.pos();
     997                wa_size = _fileHandle.readUint16LE();
     998                _fileHandle.seek(wa_size - 2, SEEK_CUR);
     999                ad_offs = _fileHandle.pos();
     1000                ad_size = _fileHandle.readUint16LE();
     1001                _fileHandle.seek(4, SEEK_CUR);
     1002                total_size = wa_size + ad_size;
     1003        } else {
     1004                total_size = size = _fileHandle.readUint32LE();
    9981005                tag = _fileHandle.readUint16LE();
    9991006                debug(4, "  tag='%c%c', size=%d",
    1000                                         (char) (tag & 0xff),
    1001                                         (char) ((tag >> 8) & 0xff), size);
    1002                 pos += size;
    1003 
    1004                 // MI1 and Indy3 uses one or more nested SO resources, which contains AD and WA
    1005                 // resources.
    1006                 if ((tag == 0x4441) && !(best_offs)) { // AD
    1007                                 best_size = size;
    1008                                 best_offs = _fileHandle.pos();
    1009                 } else { // other AD, WA and nested SO resources
    1010                         if (tag == 0x4F53) {
    1011                                 pos -= size;
    1012                                 size = 6;
    1013                                 pos += 6;
     1007                      (char) (tag & 0xff),
     1008                      (char) ((tag >> 8) & 0xff), size);
     1009               
     1010                pos = 6;
     1011                while (pos < total_size) {
     1012                        size = _fileHandle.readUint32LE();
     1013                        tag = _fileHandle.readUint16LE();
     1014                        debug(4, "  tag='%c%c', size=%d",
     1015                              (char) (tag & 0xff),
     1016                              (char) ((tag >> 8) & 0xff), size);
     1017                        pos += size;
     1018                       
     1019                        // MI1 and Indy3 uses one or more nested SO resources, which contains AD and WA
     1020                        // resources.
     1021                        if ((tag == 0x4441) && !(ad_offs)) { // AD
     1022                                ad_size = size;
     1023                                ad_offs = _fileHandle.pos() - 6;
     1024                        } else if ((tag == 0x4157) && !(wa_offs)) { // WA
     1025                                wa_size = size;
     1026                                wa_offs = _fileHandle.pos() - 6;
     1027                        } else { // other AD, WA and nested SO resources
     1028                                if (tag == 0x4F53) { // SO
     1029                                        pos -= size;
     1030                                        size = 6;
     1031                                        pos += 6;
     1032                                }
    10141033                        }
     1034                        _fileHandle.seek(size - 6, SEEK_CUR);
    10151035                }
    1016                 _fileHandle.seek(size - 6, SEEK_CUR);
    10171036        }
    1018 
     1037               
    10191038        // AD resources have a header, instrument definitions and one MIDI track.
    10201039        // We build an 'ADL ' resource from that:
    10211040        //   8 bytes resource header
     
    10281047        //        - proper handling of the short (non-music, SFX) AD resources format
    10291048        //        - check the LE/BE handling for platforms other than PC
    10301049
    1031         if (best_offs != 0) {
     1050        if (ad_offs != 0) {
    10321051                byte *ptr, *track, *instr;
    10331052                byte ticks, play_once;
    10341053                byte music_type, num_instr;
    10351054
    1036                 _fileHandle.seek(best_offs - 6, SEEK_SET);
     1055                _fileHandle.seek(ad_offs, SEEK_SET);
     1056
     1057                ptr = createResource(type, idx, ad_size);
     1058                _fileHandle.read(ptr, ad_size);
     1059                size = ad_size;
     1060
     1061                if ((_features & GF_OLD_BUNDLE)) {
     1062                        ptr += 4;
     1063                        size -= 4;
     1064                } else {
     1065                        ptr += 6;
     1066                        size -= 6;
     1067                }
     1068                hexdump(ptr, size);
    10371069
    1038                 ptr = createResource(type, idx, best_size);
    1039                 _fileHandle.read(ptr, best_size);
    10401070
    1041                 music_type = *(ptr + 8);        // 0x80: is music; otherwise not.
     1071                music_type = *(ptr + 2);        // 0x80: is music; otherwise not.
    10421072               
    10431073                if (music_type != 0x80) {
    10441074                        // It's an SFX; we don't know how to handle those yet
     
    10491079                }
    10501080               
    10511081                // The "speed" of the song
    1052                 ticks = *(ptr + 9);
     1082                ticks = *(ptr + 3);
    10531083               
    10541084                // Flag that tells us whether we should loop the song (0) or play it only once (1)
    1055                 play_once = *(ptr + 10);
     1085                play_once = *(ptr + 4);
    10561086               
    10571087                // Number of instruments used
    1058                 num_instr = *(ptr + 16);        // Normally 8
     1088                num_instr = *(ptr + 10);        // Normally 8
    10591089                if (num_instr != 8)
    10601090                        warning("Sound %d has %d instruments, expected 8", idx, num_instr);
    10611091
    10621092                // copy the instrument data in another memory area
    10631093                instr = (byte *)calloc(8 * 16, 1);
    10641094                assert(instr);
    1065                 memcpy(instr, ptr + 0x19, 8*16);
     1095                memcpy(instr, ptr + 0x13, 8*16);
    10661096
    10671097                // skip over the rest of the header and copy the MIDI data into a buffer
    1068                 size = best_size;
    1069                 ptr  += 0x19 + 8 * 16;
    1070                 size -= 0x19 + 8 * 16;
     1098                ptr  += 0x13 + 8 * 16;
     1099                size -= 0x13 + 8 * 16;
    10711100                CHECK_HEAP
    10721101                track = (byte *)calloc(size, 1);
    10731102                if (track == NULL) {
  • scumm/scummvm.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
    retrieving revision 2.202
    diff -u -r2.202 scummvm.cpp
     
    602602                _imuseDigital = new IMuseDigital(this);
    603603                _imuse = NULL;
    604604                _playerV2 = NULL;
    605         } else if ((_features & GF_OLD_BUNDLE) && !(_features & GF_AMIGA)) {
     605        } else if ((_features & GF_OLD_BUNDLE) && !(_features & GF_AMIGA)
     606                   && !(_features & GF_AFTER_V3) /* hack to make loom use imuse*/) {
    606607                _playerV2 = NULL;
    607608                if (!(_features & GF_AMIGA))
    608609                        _playerV2 = new Player_V2(this);
  • scumm/sound.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
    retrieving revision 1.130
    diff -u -r1.130 sound.cpp
     
    390390       
    391391        }
    392392       
    393         if (_scumm->_features & GF_OLD_BUNDLE) {
     393        if ((_scumm->_features & GF_OLD_BUNDLE)
     394            && (_scumm->_features & GF_AFTER_V2)) {
    394395                // FIXME: support amiga sounds
    395396                uint16 amigatest;
    396397                amigatest = READ_LE_UINT16(ptr + 12);