Ticket #8017: creative.diff
File creative.diff, 5.0 KB (added by , 22 years ago) |
---|
-
resource.cpp
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v retrieving revision 1.103 diff -u -r1.103 resource.cpp
725 725 total_size = fileReadDwordBE(); 726 726 fileRead(_fileHandle, createResource(type, idx, total_size), total_size - 8); 727 727 return 1; 728 } else if (basetag == MKID('Crea')) { 729 fileSeek(_fileHandle, -12, SEEK_CUR); 730 total_size = fileReadDwordBE(); 731 fileRead(_fileHandle, createResource(type, idx, total_size), total_size - 8); 732 return 1; 728 733 } else { 729 734 fprintf(stderr, "WARNING: Unrecognized base tag 0x%08lx in sound %d\n", basetag, idx); 730 735 } … … 837 842 { 838 843 byte *ptr; 839 844 840 debug(9, "nukeResource(%s,%d)", resTypeFromId(type), idx);841 845 842 846 CHECK_HEAP if (!res.address[type]) 843 847 return; … … 845 849 assert(idx >= 0 && idx < res.num[type]); 846 850 847 851 if ((ptr = res.address[type][idx]) != NULL) { 852 debug(9, "nukeResource(%s,%d)", resTypeFromId(type), idx); 848 853 res.address[type][idx] = 0; 849 854 res.flags[type][idx] = 0; 850 855 _allocatedSize -= ((MemBlkHeader *)ptr)->size; -
sound.cpp
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v retrieving revision 1.129 diff -u -r1.129 sound.cpp
48 48 _scumm->_vars[_scumm->VAR_LAST_SOUND] = sound; 49 49 _scumm->ensureResourceLoaded(rtSound, sound); 50 50 addSoundToQueue2(sound); 51 } else { 52 // WARNING ! This may break something, maybe this sould be put inside if(_gameID == GID_FT) ? 53 // But why addSoundToQueue should not queue sound ? 54 _scumm->ensureResourceLoaded(rtSound, sound); 55 addSoundToQueue2(sound); 51 56 } 52 57 53 58 // if (_features & GF_AUDIOTRACKS) … … 162 167 _soundQuePos = 0; 163 168 } 164 169 170 static char * read_creative_voc_file(byte * ptr, int & size, int & rate) { 171 assert(strncmp((char*)ptr, "Creative Voice File\x1A", 20) == 0); 172 int offset = READ_LE_UINT16(ptr+20); 173 short version = READ_LE_UINT16(ptr+22); 174 short code = READ_LE_UINT16(ptr+24); 175 assert(version == 0x010A || version == 0x0114); 176 assert(code == ~version + 0x1234); 177 bool quit = 0; 178 char * ret_sound = 0; size = 0; 179 while(!quit) { 180 int len = READ_LE_UINT32(ptr + offset); 181 offset += 4; 182 int code = len & 0xFF; // FIXME not sure this is endian correct 183 len >>= 8; 184 switch(code) { 185 case 0: quit = 1; break; 186 case 1: { 187 int time_constant = ptr[offset++]; 188 int packing = ptr[offset++]; 189 len -= 2; 190 rate = 1000000L / (256L - time_constant); 191 debug(9, "VOC Data Bloc : %d, %d, %d", rate, packing, len); 192 if(packing == 0) { 193 if(size) { 194 ret_sound = (char*)realloc(ret_sound, size + len); 195 } else { 196 ret_sound = (char*)malloc(len); 197 } 198 memcpy(ret_sound + size, ptr + offset, len); 199 size += len; 200 } else { 201 warning("VOC file packing %d unsupported", packing); 202 } 203 } break; 204 case 6: // begin of loop 205 debug(3, "loops in Creative files not supported"); 206 break; 207 case 7: // end of loop 208 break; 209 default: 210 warning("Invalid code in VOC file : %d", code); 211 //~ quit = 1; 212 break; 213 } 214 offset += len; 215 } 216 debug(9, "VOC Data Size : %d", size); 217 return ret_sound; 218 } 219 165 220 void Sound::playSound(int sound) { 166 221 byte *ptr; 167 IMuse *se = _scumm->_imuse; 168 222 169 223 ptr = _scumm->getResourceAddress(rtSound, sound); 170 224 if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) { 171 225 ptr += 8; … … 180 234 _scumm->current_cd_sound = sound; 181 235 return; 182 236 } 183 184 237 // Support for SFX in Monkey Island 1, Mac version 185 238 // This is rather hackish right now, but works OK. SFX are not sounding 186 239 // 100% correct, though, not sure right now what is causing this. 187 if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) {240 else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) { 188 241 189 242 // Read info from the header 190 243 int size = READ_UINT32_UNALIGNED(ptr+0x60); … … 216 269 _scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE); 217 270 return; 218 271 } 272 else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) { 273 int size, rate; 274 char * sound = read_creative_voc_file(ptr, size, rate); 275 if(sound != NULL) { 276 _scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE); 277 } 278 return; 279 } 219 280 // Support for sampled sound effects in Monkey1 and Monkey2 220 281 else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SBL ')) { 221 282 debug(2, "Using SBL sound effect"); … … 332 393 if (_scumm->_gameId == GID_MONKEY_VGA) 333 394 return; /* FIXME */ 334 395 396 IMuse *se = _scumm->_imuse; 335 397 if (se) { 336 398 _scumm->getResourceAddress(rtSound, sound); 337 399 se->start_sound(sound);