author | tron |
Sun, 28 Aug 2005 10:59:34 +0000 | |
changeset 2372 | f751e366f618 |
parent 2371 | fafe059a4472 |
child 2594 | c65db1a9f630 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1498
diff
changeset
|
4 |
#include "openttd.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
1891
diff
changeset
|
5 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
337
diff
changeset
|
6 |
#include "map.h" |
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
7 |
#include "mixer.h" |
0 | 8 |
#include "sound.h" |
9 |
#include "vehicle.h" |
|
10 |
#include "window.h" |
|
11 |
#include "viewport.h" |
|
12 |
#include "fileio.h" |
|
13 |
||
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
14 |
typedef struct FileEntry { |
0 | 15 |
uint32 file_offset; |
16 |
uint32 file_size; |
|
17 |
uint16 rate; |
|
18 |
uint8 bits_per_sample; |
|
19 |
uint8 channels; |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
20 |
} FileEntry; |
0 | 21 |
|
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
22 |
static uint _file_count; |
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
23 |
static FileEntry* _files; |
0 | 24 |
|
25 |
#define SOUND_SLOT 31 |
|
26 |
||
27 |
||
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
28 |
static void OpenBankFile(const char *filename) |
0 | 29 |
{ |
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
30 |
FileEntry* fe; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
31 |
uint count; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
32 |
uint i; |
0 | 33 |
|
34 |
FioOpenFile(SOUND_SLOT, filename); |
|
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
35 |
count = FioReadDword() / 8; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
36 |
fe = calloc(sizeof(*fe), count); |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
37 |
|
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
38 |
if (fe == NULL) { |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
39 |
_file_count = 0; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
40 |
_files = NULL; |
2372 | 41 |
return; |
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
42 |
} |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
43 |
|
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
44 |
_file_count = count; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
45 |
_files = fe; |
0 | 46 |
|
47 |
FioSeekTo(0, SEEK_SET); |
|
48 |
||
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
49 |
for (i = 0; i != count; i++) { |
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
50 |
fe[i].file_offset = FioReadDword(); |
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
51 |
fe[i].file_size = FioReadDword(); |
0 | 52 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
53 |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
54 |
for (i = 0; i != count; i++, fe++) { |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
55 |
char name[255]; |
0 | 56 |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
57 |
FioSeekTo(fe->file_offset, SEEK_SET); |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
58 |
|
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
59 |
// Check for special case, see else case |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
60 |
FioReadBlock(name, FioReadByte()); // Read the name of the sound |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
61 |
if (strcmp(name, "Corrupt sound") != 0) { |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
62 |
FioSeekTo(12, SEEK_CUR); // Skip past RIFF header |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
63 |
|
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
64 |
// Read riff tags |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
65 |
for (;;) { |
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
66 |
uint32 tag = FioReadDword(); |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
67 |
uint32 size = FioReadDword(); |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
68 |
|
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
69 |
if (tag == ' tmf') { |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
70 |
FioReadWord(); // wFormatTag |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
71 |
fe->channels = FioReadWord(); // wChannels |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
72 |
FioReadDword(); // samples per second |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
73 |
fe->rate = 11025; // seems like all samples should be played at this rate. |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
74 |
FioReadDword(); // avg bytes per second |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
75 |
FioReadWord(); // alignment |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
76 |
fe->bits_per_sample = FioReadByte(); // bits per sample |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
77 |
FioSeekTo(size - (2 + 2 + 4 + 4 + 2 + 1), SEEK_CUR); |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
78 |
} else if (tag == 'atad') { |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
79 |
fe->file_size = size; |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
80 |
fe->file_offset = FioGetPos() | (SOUND_SLOT << 24); |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
81 |
break; |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
82 |
} else { |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
83 |
fe->file_size = 0; |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
84 |
break; |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
85 |
} |
0 | 86 |
} |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
87 |
} else { |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
88 |
/* |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
89 |
* Special case for the jackhammer sound |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
90 |
* (name in sample.cat is "Corrupt sound") |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
91 |
* It's no RIFF file, but raw PCM data |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
92 |
*/ |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
93 |
fe->channels = 1; |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
94 |
fe->rate = 11025; |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
95 |
fe->bits_per_sample = 8; |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
96 |
fe->file_offset = FioGetPos() | (SOUND_SLOT << 24); |
0 | 97 |
} |
98 |
} |
|
99 |
} |
|
100 |
||
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
101 |
static bool SetBankSource(MixerChannel *mc, uint bank) |
0 | 102 |
{ |
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
103 |
FileEntry* fe; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
104 |
int8* mem; |
0 | 105 |
uint i; |
106 |
||
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
107 |
if (bank >= _file_count) return false; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
108 |
fe = &_files[bank]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
109 |
|
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
110 |
if (fe->file_size == 0) return false; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
111 |
|
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
112 |
mem = malloc(fe->file_size); |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
113 |
if (mem == NULL) return false; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
114 |
|
0 | 115 |
FioSeekToFile(fe->file_offset); |
116 |
FioReadBlock(mem, fe->file_size); |
|
117 |
||
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
118 |
for (i = 0; i != fe->file_size; i++) |
1136 | 119 |
mem[i] += -128; // Convert unsigned sound data to signed |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
120 |
|
0 | 121 |
assert(fe->bits_per_sample == 8 && fe->channels == 1 && fe->file_size != 0 && fe->rate != 0); |
122 |
||
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
123 |
MxSetChannelRawSrc(mc, mem, fe->file_size, fe->rate, MX_AUTOFREE); |
0 | 124 |
|
125 |
return true; |
|
126 |
} |
|
127 |
||
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
128 |
bool SoundInitialize(const char *filename) |
0 | 129 |
{ |
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1136
diff
changeset
|
130 |
OpenBankFile(filename); |
0 | 131 |
return true; |
132 |
} |
|
133 |
||
134 |
// Low level sound player |
|
135 |
static void StartSound(uint sound, uint panning, uint volume) |
|
136 |
{ |
|
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
137 |
MixerChannel* mc; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
138 |
|
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
139 |
if (volume == 0) return; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
140 |
mc = MxAllocateChannel(_mixer); |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
141 |
if (mc == NULL) return; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
142 |
if (!SetBankSource(mc, sound)) return; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
143 |
MxSetChannelVolume(mc, volume << 8, volume << 8); |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
144 |
MxActivateChannel(mc); |
0 | 145 |
} |
146 |
||
147 |
||
148 |
static const byte _vol_factor_by_zoom[] = {255, 190, 134}; |
|
149 |
||
150 |
static const byte _sound_base_vol[] = { |
|
151 |
128, 90, 128, 128, 128, 128, 128, 128, |
|
152 |
128, 90, 90, 128, 128, 128, 128, 128, |
|
153 |
128, 128, 128, 80, 128, 128, 128, 128, |
|
154 |
128, 128, 128, 128, 128, 128, 128, 128, |
|
155 |
128, 128, 90, 90, 90, 128, 90, 128, |
|
156 |
128, 90, 128, 128, 128, 90, 128, 128, |
|
157 |
128, 128, 128, 128, 90, 128, 128, 128, |
|
158 |
128, 90, 128, 128, 128, 128, 128, 128, |
|
159 |
128, 128, 90, 90, 90, 128, 128, 128, |
|
160 |
90, |
|
161 |
}; |
|
162 |
||
163 |
static const byte _sound_idx[] = { |
|
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
164 |
2, 3, 4, 5, 6, 7, 8, 9, |
0 | 165 |
10, 11, 12, 13, 14, 15, 16, 17, |
166 |
18, 19, 20, 21, 22, 23, 24, 25, |
|
167 |
26, 27, 28, 29, 30, 31, 32, 33, |
|
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
168 |
34, 35, 36, 37, 38, 39, 40, 0, |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
169 |
1, 41, 42, 43, 44, 45, 46, 47, |
0 | 170 |
48, 49, 50, 51, 52, 53, 54, 55, |
171 |
56, 57, 58, 59, 60, 61, 62, 63, |
|
172 |
64, 65, 66, 67, 68, 69, 70, 71, |
|
173 |
72, |
|
174 |
}; |
|
175 |
||
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
176 |
static void SndPlayScreenCoordFx(SoundFx sound, int x, int y) |
0 | 177 |
{ |
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
178 |
const Window* w; |
0 | 179 |
|
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
180 |
if (msf.effect_vol == 0) return; |
0 | 181 |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
182 |
for (w = _windows; w != _last_window; w++) { |
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
183 |
const ViewPort* vp = w->viewport; |
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
184 |
|
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
185 |
if (vp != NULL && |
0 | 186 |
IS_INSIDE_1D(x, vp->virtual_left, vp->virtual_width) && |
187 |
IS_INSIDE_1D(y, vp->virtual_top, vp->virtual_height)) { |
|
2371
fafe059a4472
(svn r2897) Check the return values of [cm]alloc and the length of an array, plus some smaller changes
tron
parents:
2186
diff
changeset
|
188 |
int left = ((x - vp->virtual_left) >> vp->zoom) + vp->left; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
189 |
|
0 | 190 |
StartSound( |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
191 |
_sound_idx[sound], |
0 | 192 |
clamp(left / 71, 0, 8), |
193 |
(_sound_base_vol[sound] * msf.effect_vol * _vol_factor_by_zoom[vp->zoom]) >> 15 |
|
194 |
); |
|
195 |
return; |
|
196 |
} |
|
197 |
} |
|
198 |
||
199 |
} |
|
200 |
||
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
201 |
void SndPlayTileFx(SoundFx sound, TileIndex tile) |
0 | 202 |
{ |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
203 |
/* emits sound from center (+ 8) of the tile */ |
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
679
diff
changeset
|
204 |
int x = TileX(tile) * 16 + 8; |
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
679
diff
changeset
|
205 |
int y = TileY(tile) * 16 + 8; |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
206 |
Point pt = RemapCoords(x, y, GetSlopeZ(x, y)); |
0 | 207 |
SndPlayScreenCoordFx(sound, pt.x, pt.y); |
208 |
} |
|
209 |
||
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
210 |
void SndPlayVehicleFx(SoundFx sound, const Vehicle *v) |
0 | 211 |
{ |
212 |
SndPlayScreenCoordFx(sound, |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
213 |
(v->left_coord + v->right_coord) / 2, |
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
214 |
(v->top_coord + v->bottom_coord) / 2 |
0 | 215 |
); |
216 |
} |
|
217 |
||
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
218 |
void SndPlayFx(SoundFx sound) |
0 | 219 |
{ |
220 |
StartSound( |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
221 |
_sound_idx[sound], |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
222 |
4, |
0 | 223 |
(_sound_base_vol[sound] * msf.effect_vol) >> 7 |
224 |
); |
|
225 |
} |