1
+ #if 0
1
2
#include "ds_mix.h"
2
3
#include "doomstat.h"
3
4
#include "sounds.h"
8
9
#include "w_wad.h"
9
10
#include <3ds.h>
10
11
12
+ #define USE_CSND
13
+
14
+ #ifndef USE_CSND
15
+ void * ndspMix_init (int channel , int speed , int channels );
16
+ void ndsp_update (void * pmix , short * pAudioData , int count );
17
+ int ndspMix_pos (void * pmix );
18
+ void ndspMix_exit (void * pmix );
19
+ void ndspMix_clear (void * pmix );
20
+ void * _ndspMixer = 0 ;
21
+
22
+ u64 g_sound_time ;
23
+ u64 g_paint_time ;
24
+ #endif
25
+
26
+
11
27
extern int snd_card ;
12
28
extern boolean nosfxparm ;
13
29
@@ -62,7 +78,6 @@ portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
62
78
static int snd_scaletable [32 ][256 ];
63
79
int audio_initialized = 0 ;
64
80
65
- #if 1
66
81
67
82
static u64 sound_start ;
68
83
#define TICKS_PER_SEC 268123480.0
@@ -78,8 +93,8 @@ void mix_start() {
78
93
memset (c_snd_Buffer_right , 0 , SND_SAMPLES );
79
94
//c_snd_Buffer_left[4] = c_snd_Buffer_left[5] = 0x7f; // force a pop for debugging
80
95
//c_snd_Buffer_right[4] = c_snd_Buffer_right[5] = 0x7f; // force a pop for debugging
81
- GSPGPU_FlushDataCache (NULL , c_snd_Buffer_left , SND_SAMPLES );
82
- GSPGPU_FlushDataCache (NULL , c_snd_Buffer_right , SND_SAMPLES );
96
+ GSPGPU_FlushDataCache (c_snd_Buffer_left , SND_SAMPLES );
97
+ GSPGPU_FlushDataCache (c_snd_Buffer_right , SND_SAMPLES );
83
98
}
84
99
85
100
@@ -109,6 +124,8 @@ void MIX_init() {
109
124
u8 playing = 0 ;
110
125
111
126
MIX_InitScaletable ();
127
+
128
+ #ifdef USE_CSND
112
129
113
130
snd_Samples = SND_SAMPLES ;
114
131
snd_Speed = 11025 ;
@@ -136,15 +153,29 @@ void MIX_init() {
136
153
csndExecCmds (true);
137
154
138
155
sound_start = svcGetSystemTick ();
156
+ #else
157
+ _ndspMixer = ndspMix_init (1 , 32768 , 2 );
158
+ g_sound_time = g_paint_time = ndspMix_pos ();
159
+ #endif
139
160
}
140
161
141
162
void MIX_exit () {
163
+ #ifdef USE_CSND
142
164
CSND_SetPlayState (0x8 , 0 );
143
165
CSND_SetPlayState (0x9 , 0 );
166
+ #else
167
+ ndspMixer_exit (_ndspMixer );
168
+ #endif
144
169
}
145
170
146
171
void MIX_TransferPaintBuffer (int endtime )
147
172
{
173
+ #ifndef USE_CSND
174
+ int count = endtime - paintedtime ;
175
+
176
+ m_hw -> update ((int * )paintbuffer , count );
177
+
178
+ #else
148
179
int out_idx ;
149
180
int count , count1 , count2 , pos ;
150
181
int out_mask ;
@@ -185,7 +216,7 @@ void MIX_TransferPaintBuffer(int endtime)
185
216
186
217
out_idx = (out_idx + 1 ) & out_mask ;
187
218
}
188
-
219
+ #endif
189
220
}
190
221
191
222
void MIX_PaintChannelFrom8 (channel_t * ch , byte * sfx , int count )
@@ -354,8 +385,8 @@ void MIX_Update_(void)
354
385
//printf("mixing %d %d %d\n", soundtime, paintedtime, endtime);
355
386
MIX_PaintChannels (endtime );
356
387
//DC_FlushRange(c_snd_Buffer, SND_SAMPLES * 2);
357
- GSPGPU_FlushDataCache (NULL , c_snd_Buffer_left , SND_SAMPLES );
358
- GSPGPU_FlushDataCache (NULL , c_snd_Buffer_right , SND_SAMPLES );
388
+ GSPGPU_FlushDataCache (c_snd_Buffer_left , SND_SAMPLES );
389
+ GSPGPU_FlushDataCache (c_snd_Buffer_right , SND_SAMPLES );
359
390
}
360
391
361
392
extern int snd_SfxVolume ;
@@ -751,7 +782,6 @@ void S_StartSoundAtVolume(void *origin_p, int sfx_id, int volume)
751
782
752
783
I_StartSound (sfx , cnum , volume , sep , pitch , priority );
753
784
}
754
- #endif
755
785
756
786
void S_StartSound (void * origin , int sound_id ) {
757
787
S_StartSoundAtVolume (origin , sound_id , snd_SfxVolume );
@@ -777,3 +807,4 @@ void S_Stop(void)
777
807
//so it should not make any noise while the level loads
778
808
mix_start ();
779
809
}
810
+ #endif
0 commit comments