Ticket #7969: vocpatch.2

File vocpatch.2, 2.3 KB (added by SF/olki, 22 years ago)

corrected patch

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