1 /*  Copyright 2004 Stephane Dallongeville
2     Copyright 2004-2007 Theo Berkau
3     Copyright 2006 Guillaume Duhamel
4 
5     This file is part of Yabause.
6 
7     Yabause is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11 
12     Yabause is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with Yabause; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
20 */
21 
22 /*! \file snddummy.c
23     \brief Dummy sound interface.
24 */
25 
26 #include "scsp.h"
27 
28 //////////////////////////////////////////////////////////////////////////////
29 // Dummy Sound Interface
30 //////////////////////////////////////////////////////////////////////////////
31 
32 static int SNDDummyInit(void);
33 static void SNDDummyDeInit(void);
34 static int SNDDummyReset(void);
35 static int SNDDummyChangeVideoFormat(int vertfreq);
36 static void SNDDummyUpdateAudio(u32 *leftchanbuffer, u32 *rightchanbuffer, u32 num_samples);
37 static u32 SNDDummyGetAudioSpace(void);
38 static void SNDDummyMuteAudio(void);
39 static void SNDDummyUnMuteAudio(void);
40 static void SNDDummySetVolume(int volume);
41 #ifdef USE_SCSPMIDI
42 int SNDDummyMidiChangePorts(int inport, int outport);
43 u8 SNDDummyMidiIn(int *isdata);
44 int SNDDummyMidiOut(u8 data);
45 #endif
46 
47 SoundInterface_struct SNDDummy = {
48 SNDCORE_DUMMY,
49 "Dummy Sound Interface",
50 SNDDummyInit,
51 SNDDummyDeInit,
52 SNDDummyReset,
53 SNDDummyChangeVideoFormat,
54 SNDDummyUpdateAudio,
55 SNDDummyGetAudioSpace,
56 SNDDummyMuteAudio,
57 SNDDummyUnMuteAudio,
58 SNDDummySetVolume,
59 #ifdef USE_SCSPMIDI
60 SNDDummyMidiChangePorts,
61 SNDDummyMidiIn,
62 SNDDummyMidiOut
63 #endif
64 };
65 
66 //////////////////////////////////////////////////////////////////////////////
67 
SNDDummyInit(void)68 static int SNDDummyInit(void)
69 {
70    return 0;
71 }
72 
73 //////////////////////////////////////////////////////////////////////////////
74 
SNDDummyDeInit(void)75 static void SNDDummyDeInit(void)
76 {
77 }
78 
79 //////////////////////////////////////////////////////////////////////////////
80 
SNDDummyReset(void)81 static int SNDDummyReset(void)
82 {
83    return 0;
84 }
85 
86 //////////////////////////////////////////////////////////////////////////////
87 
SNDDummyChangeVideoFormat(UNUSED int vertfreq)88 static int SNDDummyChangeVideoFormat(UNUSED int vertfreq)
89 {
90    return 0;
91 }
92 
93 //////////////////////////////////////////////////////////////////////////////
94 
SNDDummyUpdateAudio(UNUSED u32 * leftchanbuffer,UNUSED u32 * rightchanbuffer,UNUSED u32 num_samples)95 static void SNDDummyUpdateAudio(UNUSED u32 *leftchanbuffer, UNUSED u32 *rightchanbuffer, UNUSED u32 num_samples)
96 {
97 }
98 
99 //////////////////////////////////////////////////////////////////////////////
100 
SNDDummyGetAudioSpace(void)101 static u32 SNDDummyGetAudioSpace(void)
102 {
103    /* A "hack" to get dummy sound core working enough
104     * so videos are not "freezing". Values have been
105     * found by experiments... I don't have a clue why
106     * they are working ^^;
107     */
108    static int i = 0;
109    i++;
110    if (i == 55) {
111       i = 0;
112       return 85;
113    } else {
114       return 0;
115    }
116 }
117 
118 //////////////////////////////////////////////////////////////////////////////
119 
SNDDummyMuteAudio()120 void SNDDummyMuteAudio()
121 {
122 }
123 
124 //////////////////////////////////////////////////////////////////////////////
125 
SNDDummyUnMuteAudio()126 void SNDDummyUnMuteAudio()
127 {
128 }
129 
130 //////////////////////////////////////////////////////////////////////////////
131 
SNDDummySetVolume(UNUSED int volume)132 void SNDDummySetVolume(UNUSED int volume)
133 {
134 }
135 
136 //////////////////////////////////////////////////////////////////////////////
137 
138 #ifdef USE_SCSPMIDI
SNDDummyMidiChangePorts(int inport,int outport)139 int SNDDummyMidiChangePorts(int inport, int outport)
140 {
141 	return 0;
142 }
143 
144 //////////////////////////////////////////////////////////////////////////////
145 
SNDDummyMidiIn(int * isdata)146 u8 SNDDummyMidiIn(int *isdata)
147 {
148 	*isdata = 0;
149 	/* Called when SCSP wants more MIDI data. Set isdata to 1 if there's data to return */
150 	return 0;
151 }
152 
153 //////////////////////////////////////////////////////////////////////////////
154 
SNDDummyMidiOut(u8 data)155 int SNDDummyMidiOut(u8 data)
156 {
157 	/* Called when SCSP wants to send out MIDI data. num is the number of bytes in buffer. Return 1 if data used, or 0 if not */
158 	return 1;
159 }
160 #endif
161 
162 //////////////////////////////////////////////////////////////////////////////
163 
164