annotate playercode/drv_wav_v2.c @ 19:84565bb86869

Makefile Added clean rule
author darius
date Thu, 23 Apr 1998 22:59:21 +0000
parents 437e8455d862
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
1
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
2 #include "mikmod.h"
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
3
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
4 #ifdef __GNUC__
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
5 #include <sys/types.h>
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
6 #else
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
7 #include <io.h>
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
8 #endif
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
9 #include <sys/stat.h>
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
10 #include <fcntl.h>
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
11
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
12 #define WAVBUFFERSIZE 65536
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
13
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
14 static FILE *wavout;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
15
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
16 static SBYTE *WAV_DMABUF;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
17 static ULONG dumpsize;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
18
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
19 static BOOL WAV_IsThere(void)
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
20 {
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
21 return 1;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
22 }
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
23
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
24
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
25 static BOOL WAV_Init(void)
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
26 {
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
27 if(NULL == (wavout = fopen("music.wav", "wb"))) return 1;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
28 if(NULL == (WAV_DMABUF = _mm_malloc(WAVBUFFERSIZE))) return 1;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
29
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
30 md_mode |= DMODE_SOFT_MUSIC | DMODE_SOFT_SNDFX;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
31
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
32 if(VC2_Init()) return 1;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
33
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
34 _mm_write_string("RIFF WAVEfmt ",wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
35 _mm_write_I_ULONG(16,wavout); // length of this RIFF block crap
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
36
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
37 _mm_write_I_UWORD(1, wavout); // microsoft format type
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
38 _mm_write_I_UWORD((md_mode & DMODE_STEREO) ? 2 : 1, wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
39 _mm_write_I_ULONG(md_mixfreq, wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
40 _mm_write_I_ULONG(md_mixfreq * ((md_mode & DMODE_STEREO) ? 2 : 1) *
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
41 ((md_mode & DMODE_16BITS) ? 2 : 1), wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
42
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
43 _mm_write_I_UWORD(((md_mode & DMODE_16BITS) ? 2 : 1) *
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
44 ((md_mode & DMODE_STEREO) ? 2 : 1), wavout); // block alignment (8/16 bit)
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
45
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
46 _mm_write_I_UWORD((md_mode & DMODE_16BITS) ? 16 : 8,wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
47
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
48 _mm_write_string("data",wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
49
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
50 dumpsize = 0;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
51
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
52 return 0;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
53 }
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
54
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
55
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
56 static void WAV_Exit(void)
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
57 {
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
58 VC2_Exit();
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
59
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
60 // write in the actual sizes now
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
61
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
62 if(wavout!=NULL)
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
63 { _mm_fseek(wavout,4,SEEK_SET);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
64 _mm_write_I_ULONG(dumpsize + 32, wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
65 _mm_fseek(wavout,40,SEEK_SET);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
66 _mm_write_I_ULONG(dumpsize, wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
67
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
68 fclose(wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
69
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
70 if(WAV_DMABUF != NULL) free(WAV_DMABUF);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
71 }
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
72 }
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
73
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
74
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
75 static void WAV_Update(void)
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
76 {
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
77 VC2_WriteBytes(WAV_DMABUF, WAVBUFFERSIZE);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
78 fwrite(WAV_DMABUF, 1, WAVBUFFERSIZE, wavout);
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
79 dumpsize += WAVBUFFERSIZE;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
80 }
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
81
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
82
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
83 static BOOL WAV_Reset(void)
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
84 {
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
85 return 0;
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
86 }
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
87
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
88
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
89 MDRIVER drv_wav =
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
90 { NULL,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
91 "music.wav file",
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
92 "WAV [music.wav] file output driver v1.0",
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
93 0,255,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
94 WAV_IsThere,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
95 VC2_SampleLoad,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
96 VC2_SampleUnload,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
97 VC2_SampleSpace,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
98 VC2_SampleLength,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
99 WAV_Init,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
100 WAV_Exit,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
101 WAV_Reset,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
102 VC2_SetNumVoices,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
103 VC2_PlayStart,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
104 VC2_PlayStop,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
105 WAV_Update,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
106 VC2_VoiceSetVolume,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
107 VC2_VoiceSetFrequency,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
108 VC2_VoiceSetPanning,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
109 VC2_VoicePlay,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
110 VC2_VoiceStop,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
111 VC2_VoiceStopped,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
112 VC2_VoiceReleaseSustain,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
113 VC2_VoiceGetPosition,
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
114 NULL
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
115 };
437e8455d862 General tidy up..
darius
parents: 9
diff changeset
116