@muhammedaksam/opentui-doom 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/doom/build/doom.js +1 -1
- package/doom/build/doom.wasm +0 -0
- package/doom/doom_js_sound_bridge.c +240 -0
- package/doom/i_sound.c +327 -0
- package/doom/s_sound.c +566 -0
- package/package.json +5 -1
- package/scripts/build-doom.sh +7 -1
- package/sound/d_bunny.mp3 +0 -0
- package/sound/d_e1m1.mp3 +0 -0
- package/sound/d_e1m5.mp3 +0 -0
- package/sound/d_intro.mp3 +0 -0
- package/sound/dsbarexp.wav +0 -0
- package/sound/dsbdcls.wav +0 -0
- package/sound/dsbdopn.wav +0 -0
- package/sound/dsbfg.wav +0 -0
- package/sound/dsbgact.wav +0 -0
- package/sound/dsbgdth1.wav +0 -0
- package/sound/dsbgdth2.wav +0 -0
- package/sound/dsbgsit1.wav +0 -0
- package/sound/dsbgsit2.wav +0 -0
- package/sound/dsboscub.wav +0 -0
- package/sound/dsbosdth.wav +0 -0
- package/sound/dsbospit.wav +0 -0
- package/sound/dsbospn.wav +0 -0
- package/sound/dsbossit.wav +0 -0
- package/sound/dsbrsdth.wav +0 -0
- package/sound/dsbrssit.wav +0 -0
- package/sound/dsbspact.wav +0 -0
- package/sound/dsbspdth.wav +0 -0
- package/sound/dsbspsit.wav +0 -0
- package/sound/dsbspwlk.wav +0 -0
- package/sound/dscacdth.wav +0 -0
- package/sound/dscacsit.wav +0 -0
- package/sound/dsclaw.wav +0 -0
- package/sound/dscybdth.wav +0 -0
- package/sound/dscybsit.wav +0 -0
- package/sound/dsdbcls.wav +0 -0
- package/sound/dsdbload.wav +0 -0
- package/sound/dsdbopn.wav +0 -0
- package/sound/dsdmact.wav +0 -0
- package/sound/dsdmpain.wav +0 -0
- package/sound/dsdorcls.wav +0 -0
- package/sound/dsdoropn.wav +0 -0
- package/sound/dsdshtgn.wav +0 -0
- package/sound/dsfirsht.wav +0 -0
- package/sound/dsfirxpl.wav +0 -0
- package/sound/dsflame.wav +0 -0
- package/sound/dsflamst.wav +0 -0
- package/sound/dsgetpow.wav +0 -0
- package/sound/dshoof.wav +0 -0
- package/sound/dsitemup.wav +0 -0
- package/sound/dsitmbk.wav +0 -0
- package/sound/dskeendt.wav +0 -0
- package/sound/dskeenpn.wav +0 -0
- package/sound/dskntdth.wav +0 -0
- package/sound/dskntsit.wav +0 -0
- package/sound/dsmanatk.wav +0 -0
- package/sound/dsmandth.wav +0 -0
- package/sound/dsmansit.wav +0 -0
- package/sound/dsmetal.wav +0 -0
- package/sound/dsmnpain.wav +0 -0
- package/sound/dsnoway.wav +0 -0
- package/sound/dsoof.wav +0 -0
- package/sound/dspdiehi.wav +0 -0
- package/sound/dspedth.wav +0 -0
- package/sound/dspepain.wav +0 -0
- package/sound/dspesit.wav +0 -0
- package/sound/dspistol.wav +0 -0
- package/sound/dsplasma.wav +0 -0
- package/sound/dspldeth.wav +0 -0
- package/sound/dsplpain.wav +0 -0
- package/sound/dspodth1.wav +0 -0
- package/sound/dspodth2.wav +0 -0
- package/sound/dspodth3.wav +0 -0
- package/sound/dspopain.wav +0 -0
- package/sound/dsposact.wav +0 -0
- package/sound/dsposit1.wav +0 -0
- package/sound/dsposit2.wav +0 -0
- package/sound/dsposit3.wav +0 -0
- package/sound/dspstart.wav +0 -0
- package/sound/dspstop.wav +0 -0
- package/sound/dspunch.wav +0 -0
- package/sound/dsradio.wav +0 -0
- package/sound/dsrlaunc.wav +0 -0
- package/sound/dsrxplod.wav +0 -0
- package/sound/dssawful.wav +0 -0
- package/sound/dssawhit.wav +0 -0
- package/sound/dssawidl.wav +0 -0
- package/sound/dssawup.wav +0 -0
- package/sound/dssgcock.wav +0 -0
- package/sound/dssgtatk.wav +0 -0
- package/sound/dssgtdth.wav +0 -0
- package/sound/dssgtsit.wav +0 -0
- package/sound/dsshotgn.wav +0 -0
- package/sound/dsskeact.wav +0 -0
- package/sound/dsskeatk.wav +0 -0
- package/sound/dsskedth.wav +0 -0
- package/sound/dsskepch.wav +0 -0
- package/sound/dsskesit.wav +0 -0
- package/sound/dsskeswg.wav +0 -0
- package/sound/dssklatk.wav +0 -0
- package/sound/dsskldth.wav +0 -0
- package/sound/dsslop.wav +0 -0
- package/sound/dsspidth.wav +0 -0
- package/sound/dsspisit.wav +0 -0
- package/sound/dsssdth.wav +0 -0
- package/sound/dssssit.wav +0 -0
- package/sound/dsstnmov.wav +0 -0
- package/sound/dsswtchn.wav +0 -0
- package/sound/dsswtchx.wav +0 -0
- package/sound/dstelept.wav +0 -0
- package/sound/dstink.wav +0 -0
- package/sound/dsvilact.wav +0 -0
- package/sound/dsvilatk.wav +0 -0
- package/sound/dsvildth.wav +0 -0
- package/sound/dsvilsit.wav +0 -0
- package/sound/dsvipain.wav +0 -0
- package/sound/dswpnup.wav +0 -0
- package/src/doom-audio.ts +243 -0
- package/src/doom-engine.ts +32 -6
- package/src/doom-input.ts +18 -3
- package/src/index.ts +21 -2
package/doom/i_sound.c
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright(C) 1993-1996 Id Software, Inc.
|
|
3
|
+
// Copyright(C) 2005-2014 Simon Howard
|
|
4
|
+
//
|
|
5
|
+
// This program is free software; you can redistribute it and/or
|
|
6
|
+
// modify it under the terms of the GNU General Public License
|
|
7
|
+
// as published by the Free Software Foundation; either version 2
|
|
8
|
+
// of the License, or (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// DESCRIPTION: none
|
|
16
|
+
//
|
|
17
|
+
|
|
18
|
+
#include <stdio.h>
|
|
19
|
+
#include <stdlib.h>
|
|
20
|
+
|
|
21
|
+
#include "config.h"
|
|
22
|
+
#include "doomfeatures.h"
|
|
23
|
+
#include "doomtype.h"
|
|
24
|
+
|
|
25
|
+
#ifdef ORIGCODE
|
|
26
|
+
#include "gusconf.h"
|
|
27
|
+
#endif
|
|
28
|
+
#include "i_sound.h"
|
|
29
|
+
#include "i_video.h"
|
|
30
|
+
#include "m_argv.h"
|
|
31
|
+
#include "m_config.h"
|
|
32
|
+
|
|
33
|
+
// Sound sample rate to use for digital output (Hz)
|
|
34
|
+
int snd_samplerate = 44100;
|
|
35
|
+
|
|
36
|
+
// Maximum number of bytes to dedicate to allocated sound effects.
|
|
37
|
+
// (Default: 64MB)
|
|
38
|
+
int snd_cachesize = 64 * 1024 * 1024;
|
|
39
|
+
|
|
40
|
+
// Config variable that controls the sound buffer size.
|
|
41
|
+
// We default to 28ms (1000 / 35fps = 1 buffer per tic).
|
|
42
|
+
int snd_maxslicetime_ms = 28;
|
|
43
|
+
|
|
44
|
+
// External command to invoke to play back music.
|
|
45
|
+
char *snd_musiccmd = "";
|
|
46
|
+
|
|
47
|
+
// Low-level sound and music modules we are using
|
|
48
|
+
static sound_module_t *sound_module = NULL;
|
|
49
|
+
static music_module_t *music_module = NULL;
|
|
50
|
+
|
|
51
|
+
// Use CD device to avoid both the d_introa special case and GENMIDI init
|
|
52
|
+
int snd_musicdevice = SNDDEVICE_CD;
|
|
53
|
+
int snd_sfxdevice = SNDDEVICE_SB;
|
|
54
|
+
|
|
55
|
+
// DOS-specific options: These are unused but should be maintained
|
|
56
|
+
// so that the config file can be shared between chocolate
|
|
57
|
+
// doom and doom.exe
|
|
58
|
+
static int snd_sbport = 0;
|
|
59
|
+
static int snd_sbirq = 0;
|
|
60
|
+
static int snd_sbdma = 0;
|
|
61
|
+
static int snd_mport = 0;
|
|
62
|
+
|
|
63
|
+
// Compiled-in sound modules:
|
|
64
|
+
static sound_module_t *sound_modules[] = {
|
|
65
|
+
#ifdef FEATURE_SOUND
|
|
66
|
+
&DG_sound_module,
|
|
67
|
+
#endif
|
|
68
|
+
NULL,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Check if a sound device is in the given list of devices
|
|
72
|
+
static boolean SndDeviceInList(snddevice_t device, snddevice_t *list, int len) {
|
|
73
|
+
int i;
|
|
74
|
+
|
|
75
|
+
for (i = 0; i < len; ++i) {
|
|
76
|
+
if (device == list[i]) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Find and initialize a sound_module_t appropriate for the setting
|
|
85
|
+
// in snd_sfxdevice.
|
|
86
|
+
static void InitSfxModule(boolean use_sfx_prefix) {
|
|
87
|
+
int i;
|
|
88
|
+
|
|
89
|
+
sound_module = NULL;
|
|
90
|
+
|
|
91
|
+
for (i = 0; sound_modules[i] != NULL; ++i) {
|
|
92
|
+
// Is the sfx device in the list of devices supported by
|
|
93
|
+
// this module?
|
|
94
|
+
|
|
95
|
+
if (SndDeviceInList(snd_sfxdevice, sound_modules[i]->sound_devices,
|
|
96
|
+
sound_modules[i]->num_sound_devices)) {
|
|
97
|
+
// Initialize the module
|
|
98
|
+
|
|
99
|
+
if (sound_modules[i]->Init(use_sfx_prefix)) {
|
|
100
|
+
sound_module = sound_modules[i];
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Initialize music according to snd_musicdevice.
|
|
108
|
+
static void InitMusicModule(void) {
|
|
109
|
+
#ifdef FEATURE_SOUND
|
|
110
|
+
// No music support
|
|
111
|
+
music_module = &DG_music_module;
|
|
112
|
+
#endif /* FEATURE_SOUND */
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//
|
|
116
|
+
// Initializes sound stuff, including volume
|
|
117
|
+
// Sets channels, SFX and music volume,
|
|
118
|
+
// allocates channel buffer, sets S_sfx lookup.
|
|
119
|
+
//
|
|
120
|
+
void I_InitSound(boolean use_sfx_prefix) {
|
|
121
|
+
boolean nosound, nosfx, nomusic;
|
|
122
|
+
|
|
123
|
+
//!
|
|
124
|
+
// @vanilla
|
|
125
|
+
//
|
|
126
|
+
// Disable all sound output.
|
|
127
|
+
//
|
|
128
|
+
|
|
129
|
+
nosound = M_CheckParm("-nosound") > 0;
|
|
130
|
+
|
|
131
|
+
//!
|
|
132
|
+
// @vanilla
|
|
133
|
+
//
|
|
134
|
+
// Disable sound effects.
|
|
135
|
+
//
|
|
136
|
+
|
|
137
|
+
nosfx = M_CheckParm("-nosfx") > 0;
|
|
138
|
+
|
|
139
|
+
//!
|
|
140
|
+
// @vanilla
|
|
141
|
+
//
|
|
142
|
+
// Disable music.
|
|
143
|
+
//
|
|
144
|
+
|
|
145
|
+
nomusic = M_CheckParm("-nomusic") > 0;
|
|
146
|
+
|
|
147
|
+
// Initialize the sound and music subsystems.
|
|
148
|
+
|
|
149
|
+
if (!nosound && !screensaver_mode) {
|
|
150
|
+
// This is kind of a hack. If native MIDI is enabled, set up
|
|
151
|
+
// the TIMIDITY_CFG environment variable here before SDL_mixer
|
|
152
|
+
// is opened.
|
|
153
|
+
|
|
154
|
+
if (!nomusic && (snd_musicdevice == SNDDEVICE_GENMIDI ||
|
|
155
|
+
snd_musicdevice == SNDDEVICE_GUS)) {
|
|
156
|
+
// I_InitTimidityConfig();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (!nosfx) {
|
|
160
|
+
InitSfxModule(use_sfx_prefix);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (!nomusic) {
|
|
164
|
+
InitMusicModule();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
void I_ShutdownSound(void) {
|
|
170
|
+
if (sound_module != NULL) {
|
|
171
|
+
sound_module->Shutdown();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (music_module != NULL) {
|
|
175
|
+
music_module->Shutdown();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
int I_GetSfxLumpNum(sfxinfo_t *sfxinfo) {
|
|
180
|
+
if (sound_module != NULL) {
|
|
181
|
+
return sound_module->GetSfxLumpNum(sfxinfo);
|
|
182
|
+
} else {
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
void I_UpdateSound(void) {
|
|
188
|
+
if (sound_module != NULL) {
|
|
189
|
+
sound_module->Update();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (music_module != NULL && music_module->Poll != NULL) {
|
|
193
|
+
music_module->Poll();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static void CheckVolumeSeparation(int *vol, int *sep) {
|
|
198
|
+
if (*sep < 0) {
|
|
199
|
+
*sep = 0;
|
|
200
|
+
} else if (*sep > 254) {
|
|
201
|
+
*sep = 254;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (*vol < 0) {
|
|
205
|
+
*vol = 0;
|
|
206
|
+
} else if (*vol > 127) {
|
|
207
|
+
*vol = 127;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
void I_UpdateSoundParams(int channel, int vol, int sep) {
|
|
212
|
+
if (sound_module != NULL) {
|
|
213
|
+
CheckVolumeSeparation(&vol, &sep);
|
|
214
|
+
sound_module->UpdateSoundParams(channel, vol, sep);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
int I_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep) {
|
|
219
|
+
if (sound_module != NULL) {
|
|
220
|
+
CheckVolumeSeparation(&vol, &sep);
|
|
221
|
+
return sound_module->StartSound(sfxinfo, channel, vol, sep);
|
|
222
|
+
} else {
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
void I_StopSound(int channel) {
|
|
228
|
+
if (sound_module != NULL) {
|
|
229
|
+
sound_module->StopSound(channel);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
boolean I_SoundIsPlaying(int channel) {
|
|
234
|
+
if (sound_module != NULL) {
|
|
235
|
+
return sound_module->SoundIsPlaying(channel);
|
|
236
|
+
} else {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
void I_PrecacheSounds(sfxinfo_t *sounds, int num_sounds) {
|
|
242
|
+
if (sound_module != NULL && sound_module->CacheSounds != NULL) {
|
|
243
|
+
sound_module->CacheSounds(sounds, num_sounds);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
void I_InitMusic(void) {
|
|
248
|
+
if (music_module != NULL) {
|
|
249
|
+
music_module->Init();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
void I_ShutdownMusic(void) {}
|
|
254
|
+
|
|
255
|
+
void I_SetMusicVolume(int volume) {
|
|
256
|
+
if (music_module != NULL) {
|
|
257
|
+
music_module->SetMusicVolume(volume);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
void I_PauseSong(void) {
|
|
262
|
+
if (music_module != NULL) {
|
|
263
|
+
music_module->PauseMusic();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
void I_ResumeSong(void) {
|
|
268
|
+
if (music_module != NULL) {
|
|
269
|
+
music_module->ResumeMusic();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
void *I_RegisterSong(void *data, int len) {
|
|
274
|
+
if (music_module != NULL) {
|
|
275
|
+
return music_module->RegisterSong(data, len);
|
|
276
|
+
} else {
|
|
277
|
+
return NULL;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
void I_UnRegisterSong(void *handle) {
|
|
282
|
+
if (music_module != NULL) {
|
|
283
|
+
music_module->UnRegisterSong(handle);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
void I_PlaySong(void *handle, boolean looping) {
|
|
288
|
+
printf("[DOOM-DEBUG] I_PlaySong called\n");
|
|
289
|
+
if (music_module != NULL) {
|
|
290
|
+
music_module->PlaySong(handle, looping);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
void I_StopSong(void) {
|
|
295
|
+
if (music_module != NULL) {
|
|
296
|
+
music_module->StopSong();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
boolean I_MusicIsPlaying(void) {
|
|
301
|
+
if (music_module != NULL) {
|
|
302
|
+
return music_module->MusicIsPlaying();
|
|
303
|
+
} else {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
void I_BindSoundVariables(void) {
|
|
309
|
+
extern int use_libsamplerate;
|
|
310
|
+
extern float libsamplerate_scale;
|
|
311
|
+
|
|
312
|
+
M_BindVariable("snd_musicdevice", &snd_musicdevice);
|
|
313
|
+
M_BindVariable("snd_sfxdevice", &snd_sfxdevice);
|
|
314
|
+
M_BindVariable("snd_sbport", &snd_sbport);
|
|
315
|
+
M_BindVariable("snd_sbirq", &snd_sbirq);
|
|
316
|
+
M_BindVariable("snd_sbdma", &snd_sbdma);
|
|
317
|
+
M_BindVariable("snd_mport", &snd_mport);
|
|
318
|
+
M_BindVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms);
|
|
319
|
+
M_BindVariable("snd_musiccmd", &snd_musiccmd);
|
|
320
|
+
M_BindVariable("snd_samplerate", &snd_samplerate);
|
|
321
|
+
M_BindVariable("snd_cachesize", &snd_cachesize);
|
|
322
|
+
|
|
323
|
+
#ifdef FEATURE_SOUND
|
|
324
|
+
M_BindVariable("use_libsamplerate", &use_libsamplerate);
|
|
325
|
+
M_BindVariable("libsamplerate_scale", &libsamplerate_scale);
|
|
326
|
+
#endif
|
|
327
|
+
}
|