Ticket #7967: sound.patch

File sound.patch, 1.7 KB (added by aquadran, 18 years ago)

sound.cpp

Line 
189a90,140
2> if ((_gameId == GID_DIG) && (data[0] == 12)){
3> uint32 size, rate, tag, chan;
4> uint8 * ptr = getResourceAddress(rtSound, data[1]);
5> if (ptr != NULL) {
6> ptr+=16; /* Skip header */
7> for (;;) {
8> tag = READ_BE_UINT32(ptr); ptr+=4;
9> switch(tag) {
10> case MKID_BE('FRMT'):
11> size = READ_BE_UINT32(ptr); ptr+=16;
12> rate = READ_BE_UINT32(ptr); ptr+=4;
13> chan = READ_BE_UINT32(ptr); ptr+=4;
14> break;
15> case MKID_BE('TEXT'):
16> case MKID_BE('REGN'):
17> case MKID_BE('STOP'):
18> size = READ_BE_UINT32(ptr); ptr+=size+4;
19> break;
20> case MKID_BE('DATA'):
21> size = READ_BE_UINT32(ptr); ptr+=4;
22> break;
23> default:
24> error("Unknown sfx header %c%c%c%c", tag>>24, tag>>16, tag>>8, tag);
25> }
26> if (tag == MKID_BE('DATA')) break;
27> }
28> if (chan == 1)
29> {
30> uint32 s_size = (size * 2) / 3;
31> byte * buffer = (byte*)malloc (s_size);
32> uint32 l = 0, r = 0, tmp;
33> memset (buffer, 0, s_size);
34> for (; l < size - 1; l += 3)
35> {
36> tmp = (ptr[l + 1] & 0x0f) << 8;
37> tmp = (tmp | ptr[l + 0]) << 4;
38> tmp -= 0x8000;
39> // buffer[r++] = (uint8)(tmp & 0xff);
40> buffer[r++] = (uint8)((tmp >> 8) & 0xff);
41>
42> tmp = (ptr[l + 1] & 0xf0) << 4;
43> tmp = (tmp | ptr[l + 2]) << 4;
44> tmp -= 0x8000;
45> // buffer[r++] = (uint8)(tmp & 0xff);
46> buffer[r++] = (uint8)((tmp >> 8) & 0xff);
47> }
48> _mixer->play_raw(NULL, buffer, s_size, rate, SoundMixer::FLAG_AUTOFREE);
49> }
50> }
51> }
52>