Ticket #7969: vocpatch

File vocpatch, 2.1 KB (added by SF/olki, 19 years ago)

patch for voc support

Line 
1--- simon.cpp.orig Thu May 30 20:11:14 2002
2+++ simon.cpp Thu May 30 20:17:29 2002
3@@ -19,6 +19,7 @@
4 *
5 */
6
7+#define MY_SIMON
8
9 #include "stdafx.h"
10 #include "scummsys.h"
11@@ -8284,14 +8285,29 @@
12 uint16 bits_per_sample;
13 } GCC_PACK;
14
15+struct VocHeader {
16+ uint8 desc[20];
17+ uint16 datablock_offset;
18+ uint16 version;
19+ uint16 id;
20+ uint8 blocktype;
21+} GCC_PACK;
22+
23+struct VocBlockHeader {
24+ uint8 tc;
25+ uint8 pack;
26+} GCC_PACK;
27+
28 #if !defined(__GNUC__)
29 #pragma END_PACK_STRUCTS
30 #endif
31
32
33 void SimonState::playVoice(uint voice) {
34+#ifndef MY_SIMON
35 WaveHeader wave_hdr;
36 uint32 data[2];
37+#endif
38
39 // assert(voice < 14496/4);
40
41@@ -8302,6 +8318,7 @@
42
43 fseek(_voice_file, _voice_offsets[voice], SEEK_SET);
44
45+#ifndef MY_SIMON
46 if (fread(&wave_hdr, sizeof(wave_hdr), 1, _voice_file)!=1 ||
47 wave_hdr.riff!=MKID('RIFF') || wave_hdr.wave!=MKID('WAVE') || wave_hdr.fmt!=MKID('fmt ') ||
48 READ_LE_UINT16(&wave_hdr.format_tag)!=1 || READ_LE_UINT16(&wave_hdr.channels)!=1 ||
49@@ -8322,6 +8339,25 @@
50
51 _mixer->play_raw(&_voice_sound, _voice_file, data[1], READ_LE_UINT32(&wave_hdr.samples_per_sec),
52 SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
53+#else
54+ VocHeader voc_hdr;
55+ VocBlockHeader voc_block_hdr;
56+ uint32 size;
57+
58+ if (fread(&voc_hdr, sizeof(voc_hdr), 1, _voice_file)!=1 ||
59+ strncmp((char *)voc_hdr.desc,"Creative Voice File\x1A",10)!=0) {
60+ warning("playVoice(%d): cannot read voc header", voice);
61+ return;
62+ }
63+
64+ fread(&size, 3, 1, _voice_file);
65+ fread(&voc_block_hdr, sizeof(voc_block_hdr), 1, _voice_file);
66+
67+ ulong samples_per_sec = 1000000L/(256L-(long)voc_block_hdr.tc);
68+
69+ _mixer->play_raw(&_voice_sound, _voice_file, size, samples_per_sec,
70+ SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
71+#endif
72 }
73
74
75@@ -8364,7 +8400,11 @@
76
77 /* FIXME: not properly implemented */
78 if (_game & GAME_WIN) {
79+#ifndef MY_SIMON
80 fseek(_game_file, _game_offsets_ptr[gss->MUSIC_INDEX_BASE + music],SEEK_SET);
81+#else
82+ fseek(_game_file, _game_offsets_ptr[gss->MUSIC_INDEX_BASE + music] - 1,SEEK_SET);
83+#endif
84 f = _game_file;
85
86 midi.read_all_songs(f);