Ticket #7969: voc_speech_and_effects_patch.2

File voc_speech_and_effects_patch.2, 6.2 KB (added by SF/olki, 22 years ago)

fixed patch

Line 
1--- simon.cpp.orig Thu May 30 20:11:14 2002
2+++ simon.cpp Fri May 31 18:17:47 2002
3@@ -19,6 +19,7 @@
4 *
5 */
6
7+#define MY_SIMON
8
9 #include "stdafx.h"
10 #include "scummsys.h"
11@@ -54,10 +55,18 @@
12 1000000, /* VGA_MEM_SIZE */
13 50000, /* TABLES_MEM_SIZE */
14 3624, /* NUM_VOICE_RESOURCES */
15+#ifdef MY_SIMON
16+ 141, /* NUM_EFFECTS_RESOURCES */
17+#endif
18 1316/4, /* MUSIC_INDEX_BASE */
19 0, /* SOUND_INDEX_BASE */
20 "SIMON.GME", /* gme_filename */
21+#ifndef MY_SIMON
22 "SIMON.WAV", /* wav_filename */
23+#else
24+ "SIMON.VOC", /* wav_filename */
25+ "EFFECTS.VOC", /* effects_filename */
26+#endif
27 "GAMEPC", /* gamepc_filename */
28 };
29
30@@ -70,10 +79,16 @@
31 2000000, /* VGA_MEM_SIZE */
32 100000, /* TABLES_MEM_SIZE */
33 12256, /* NUM_VOICE_RESOURCES */
34+#ifdef MY_SIMON
35+ 0,
36+#endif
37 1128/4, /* MUSIC_INDEX_BASE */
38 1660/4, /* SOUND_INDEX_BASE */
39 "SIMON2.GME", /* gme_filename */
40 "SIMON2.WAV", /* wav_filename */
41+#ifdef MY_SIMON
42+ "",
43+#endif
44 "GSPTR30", /* gamepc_filename */
45 };
46
47@@ -8256,10 +8271,34 @@
48
49 if (fread(_voice_offsets, gss->NUM_VOICE_RESOURCES * sizeof(uint32), 1, _voice_file) != 1)
50 error("Cannot read voice offsets");
51+
52+#ifdef MY_SIMON
53+ const char *e = gss->effects_filename;
54+
55+ _effects_offsets = NULL;
56+
57+ _effects_file = fopen_maybe_lowercase(e);
58+ if (_effects_file == NULL) {
59+ warning("Cannot open %s",e);
60+ return;
61+ }
62+
63+ _effects_offsets = (uint32*)malloc(gss->NUM_EFFECTS_RESOURCES * sizeof(uint32));
64+ if (_effects_offsets == NULL)
65+ error("Out of memory for effects offsets");
66+
67+ if (fread(_effects_offsets, gss->NUM_EFFECTS_RESOURCES * sizeof(uint32), 1, _effects_file) != 1)
68+ error("Cannot read effects offsets");
69+#endif
70+
71 #if defined(SCUMM_BIG_ENDIAN)
72 for( int r = 0; r < gss->NUM_VOICE_RESOURCES; r++ )
73 _voice_offsets[ r ] = READ_LE_UINT32( &_voice_offsets[ r ] );
74-#endif
75+#ifdef MY_SIMON
76+ for( int r = 0; r < gss->NUM_EFFECTS_RESOURCES; r++ )
77+ _effects_offsets[ r ] = READ_LE_UINT32( &_effects_offsets[ r ] );
78+#endif /* MY_SIMON */
79+#endif /* defined(SCUMM_BIG_ENDIAN) */
80 }
81 }
82
83@@ -8284,14 +8323,29 @@
84 uint16 bits_per_sample;
85 } GCC_PACK;
86
87+struct VocHeader {
88+ uint8 desc[20];
89+ uint16 datablock_offset;
90+ uint16 version;
91+ uint16 id;
92+ uint8 blocktype;
93+} GCC_PACK;
94+
95+struct VocBlockHeader {
96+ uint8 tc;
97+ uint8 pack;
98+} GCC_PACK;
99+
100 #if !defined(__GNUC__)
101 #pragma END_PACK_STRUCTS
102 #endif
103
104
105 void SimonState::playVoice(uint voice) {
106+#ifndef MY_SIMON
107 WaveHeader wave_hdr;
108 uint32 data[2];
109+#endif
110
111 // assert(voice < 14496/4);
112
113@@ -8302,6 +8356,7 @@
114
115 fseek(_voice_file, _voice_offsets[voice], SEEK_SET);
116
117+#ifndef MY_SIMON
118 if (fread(&wave_hdr, sizeof(wave_hdr), 1, _voice_file)!=1 ||
119 wave_hdr.riff!=MKID('RIFF') || wave_hdr.wave!=MKID('WAVE') || wave_hdr.fmt!=MKID('fmt ') ||
120 READ_LE_UINT16(&wave_hdr.format_tag)!=1 || READ_LE_UINT16(&wave_hdr.channels)!=1 ||
121@@ -8322,11 +8377,33 @@
122
123 _mixer->play_raw(&_voice_sound, _voice_file, data[1], READ_LE_UINT32(&wave_hdr.samples_per_sec),
124 SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
125+#else
126+ VocHeader voc_hdr;
127+ VocBlockHeader voc_block_hdr;
128+ uint32 size;
129+
130+ if (fread(&voc_hdr, sizeof(voc_hdr), 1, _voice_file)!=1 ||
131+ strncmp((char *)voc_hdr.desc,"Creative Voice File\x1A",10)!=0) {
132+ warning("playVoice(%d): cannot read voc header", voice);
133+ return;
134+ }
135+
136+ fread(&size, 4, 1, _voice_file);
137+ size = size & 0xffffff;
138+ fseek(_voice_file, -1, SEEK_CUR);
139+ fread(&voc_block_hdr, sizeof(voc_block_hdr), 1, _voice_file);
140+
141+ ulong samples_per_sec = 1000000L/(256L-(long)voc_block_hdr.tc);
142+
143+ _mixer->play_raw(&_voice_sound, _voice_file, size, samples_per_sec,
144+ SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
145+#endif
146 }
147
148
149 void SimonState::playSound(uint sound) {
150 if (_game & GAME_WIN) {
151+#ifndef MY_SIMON
152 byte *p;
153
154 _mixer->stop(_playing_sound);
155@@ -8352,6 +8429,34 @@
156 }
157
158 _mixer->play_raw(&_playing_sound, p+8,READ_LE_UINT32(p+4),22050,SoundMixer::FLAG_UNSIGNED);
159+#else
160+ if (_effects_offsets == NULL)
161+ return;
162+
163+ _mixer->stop(_effects_sound);
164+
165+ fseek(_effects_file, _effects_offsets[sound], SEEK_SET);
166+
167+ VocHeader voc_hdr;
168+ VocBlockHeader voc_block_hdr;
169+ uint32 size;
170+
171+ if (fread(&voc_hdr, sizeof(voc_hdr), 1, _effects_file)!=1 ||
172+ strncmp((char *)voc_hdr.desc,"Creative Voice File\x1A",10)!=0) {
173+ warning("playSound(%d): cannot read voc header", sound);
174+ return;
175+ }
176+
177+ fread(&size, 4, 1, _effects_file);
178+ size = size & 0xffffff;
179+ fseek(_effects_file, -1, SEEK_CUR);
180+ fread(&voc_block_hdr, sizeof(voc_block_hdr), 1, _effects_file);
181+
182+ ulong samples_per_sec = 1000000L/(256L-(long)voc_block_hdr.tc);
183+
184+ _mixer->play_raw(&_effects_sound, _effects_file, size, samples_per_sec,
185+ SoundMixer::FLAG_FILE|SoundMixer::FLAG_UNSIGNED);
186+#endif
187 } else {
188 warning("playSound(%d)", sound);
189 }
190@@ -8364,7 +8469,11 @@
191
192 /* FIXME: not properly implemented */
193 if (_game & GAME_WIN) {
194+#ifndef MY_SIMON
195 fseek(_game_file, _game_offsets_ptr[gss->MUSIC_INDEX_BASE + music],SEEK_SET);
196+#else
197+ fseek(_game_file, _game_offsets_ptr[gss->MUSIC_INDEX_BASE + music] - 1,SEEK_SET);
198+#endif
199 f = _game_file;
200
201 midi.read_all_songs(f);
202--- simon.h.orig Thu May 30 21:10:30 2002
203+++ simon.h Thu May 30 23:23:55 2002
204@@ -19,6 +19,8 @@
205 *
206 */
207
208+#define MY_SIMON
209+
210 /* GFX Settings. Sound & Music only works properly with SIMON1WIN */
211 #define USE_SOUND
212 #define USE_MUSIC
213@@ -337,10 +339,16 @@
214 uint VGA_MEM_SIZE;
215 uint TABLES_MEM_SIZE;
216 uint NUM_VOICE_RESOURCES;
217+#ifdef MY_SIMON
218+ uint NUM_EFFECTS_RESOURCES;
219+#endif
220 uint MUSIC_INDEX_BASE;
221 uint SOUND_INDEX_BASE;
222 const char *gme_filename;
223 const char *wav_filename;
224+#ifdef MY_SIMON
225+ const char *effects_filename;
226+#endif
227 const char *gamepc_filename;
228 };
229
230@@ -374,6 +382,11 @@
231 FILE *_game_file;
232 FILE *_voice_file;
233 uint32 *_voice_offsets;
234+#ifdef MY_SIMON
235+ FILE *_effects_file;
236+ uint32 *_effects_offsets;
237+#endif
238+
239
240 byte *_stripped_txt_mem;
241 uint _text_size;
242@@ -589,7 +602,11 @@
243 int _num_screen_updates;
244 int _vga_tick_counter;
245
246+#ifndef MY_SIMON
247 PlayingSoundHandle _playing_sound;
248+#else
249+ PlayingSoundHandle _effects_sound;
250+#endif
251 PlayingSoundHandle _voice_sound;
252
253 int _timer_id;