Ticket #8241: loom-adlib-sound.diff
File loom-adlib-sound.diff, 6.3 KB (added by , 21 years ago) |
---|
-
scumm/resource.cpp
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v retrieving revision 1.95 diff -u -r1.95 resource.cpp
642 642 _fileHandle.seek(fileOffs + _fileOffset, SEEK_SET); 643 643 644 644 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 } 647 652 } else if (_features & GF_SMALL_HEADER) { 648 653 if (!(_features & GF_SMALL_NAMES)) 649 654 _fileHandle.seek(8, SEEK_CUR); … … 979 984 980 985 int Scumm::readSoundResourceSmallHeader(int type, int idx) { 981 986 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; 983 989 984 990 debug(4, "readSoundResourceSmallHeader(%s,%d)", resTypeFromId(type), idx); 985 991 986 992 //if (_rescache->readResource(roomNr, type, idx)) 987 993 // return 1; 988 994 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(); 998 1005 tag = _fileHandle.readUint16LE(); 999 1006 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 } 1014 1033 } 1034 _fileHandle.seek(size - 6, SEEK_CUR); 1015 1035 } 1016 _fileHandle.seek(size - 6, SEEK_CUR);1017 1036 } 1018 1037 1019 1038 // AD resources have a header, instrument definitions and one MIDI track. 1020 1039 // We build an 'ADL ' resource from that: 1021 1040 // 8 bytes resource header … … 1028 1047 // - proper handling of the short (non-music, SFX) AD resources format 1029 1048 // - check the LE/BE handling for platforms other than PC 1030 1049 1031 if ( best_offs != 0) {1050 if (ad_offs != 0) { 1032 1051 byte *ptr, *track, *instr; 1033 1052 byte ticks, play_once; 1034 1053 byte music_type, num_instr; 1035 1054 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); 1037 1069 1038 ptr = createResource(type, idx, best_size);1039 _fileHandle.read(ptr, best_size);1040 1070 1041 music_type = *(ptr + 8); // 0x80: is music; otherwise not.1071 music_type = *(ptr + 2); // 0x80: is music; otherwise not. 1042 1072 1043 1073 if (music_type != 0x80) { 1044 1074 // It's an SFX; we don't know how to handle those yet … … 1049 1079 } 1050 1080 1051 1081 // The "speed" of the song 1052 ticks = *(ptr + 9);1082 ticks = *(ptr + 3); 1053 1083 1054 1084 // 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); 1056 1086 1057 1087 // Number of instruments used 1058 num_instr = *(ptr + 1 6); // Normally 81088 num_instr = *(ptr + 10); // Normally 8 1059 1089 if (num_instr != 8) 1060 1090 warning("Sound %d has %d instruments, expected 8", idx, num_instr); 1061 1091 1062 1092 // copy the instrument data in another memory area 1063 1093 instr = (byte *)calloc(8 * 16, 1); 1064 1094 assert(instr); 1065 memcpy(instr, ptr + 0x1 9, 8*16);1095 memcpy(instr, ptr + 0x13, 8*16); 1066 1096 1067 1097 // 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; 1071 1100 CHECK_HEAP 1072 1101 track = (byte *)calloc(size, 1); 1073 1102 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
602 602 _imuseDigital = new IMuseDigital(this); 603 603 _imuse = NULL; 604 604 _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*/) { 606 607 _playerV2 = NULL; 607 608 if (!(_features & GF_AMIGA)) 608 609 _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
390 390 391 391 } 392 392 393 if (_scumm->_features & GF_OLD_BUNDLE) { 393 if ((_scumm->_features & GF_OLD_BUNDLE) 394 && (_scumm->_features & GF_AFTER_V2)) { 394 395 // FIXME: support amiga sounds 395 396 uint16 amigatest; 396 397 amigatest = READ_LE_UINT16(ptr + 12);