ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/SID_Be.h
Revision: 1.3
Committed: 2003-07-09T13:54:22Z (21 years, 4 months ago) by cebix
Content type: text/plain
Branch: MAIN
Changes since 1.2: +1 -1 lines
Log Message:
applied misc fixes that have accumulated over the time

File Contents

# Content
1 /*
2 * SID_Be.h - 6581 emulation, Be specific stuff
3 *
4 * Frodo (C) 1994-1997,2002-2003 Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include <MediaKit.h>
22
23 #include "C64.h"
24
25
26 /*
27 * Initialization, open subscriber
28 */
29
30 void DigitalRenderer::init_sound(void)
31 {
32 in_stream = false;
33
34 the_stream = new BDACStream();
35 the_sub = new BSubscriber("Frodo SID emulation");
36 ready = the_sub->Subscribe(the_stream) == B_NO_ERROR;
37 if (ready) {
38 the_stream->SetSamplingRate(SAMPLE_FREQ);
39 the_sub->EnterStream(NULL, true, this, stream_func, NULL, true);
40 the_stream->SetStreamBuffers(SAMPLE_FREQ / CALC_FREQ * 4, 4); // Must be called after EnterStream()
41 in_stream = true;
42 }
43 }
44
45
46 /*
47 * Destructor, close subscriber
48 */
49
50 DigitalRenderer::~DigitalRenderer()
51 {
52 if (ready) {
53 if (in_stream) {
54 the_sub->ExitStream(true);
55 in_stream = false;
56 }
57 the_stream->SetStreamBuffers(4096, 8);
58 the_sub->Unsubscribe();
59 ready = false;
60 }
61 delete the_sub;
62 delete the_stream;
63 }
64
65
66 /*
67 * Sample volume (for sampled voice)
68 */
69
70 void DigitalRenderer::EmulateLine(void)
71 {
72 sample_buf[sample_in_ptr] = volume;
73 sample_in_ptr = (sample_in_ptr + 1) % SAMPLE_BUF_SIZE;
74 }
75
76
77 /*
78 * Pause sound output
79 */
80
81 void DigitalRenderer::Pause(void)
82 {
83 if (in_stream) {
84 the_sub->ExitStream(true);
85 in_stream = false;
86 }
87 }
88
89
90 /*
91 * Resume sound output
92 */
93
94 void DigitalRenderer::Resume(void)
95 {
96 if (!in_stream) {
97 the_sub->EnterStream(NULL, true, this, stream_func, NULL, true);
98 in_stream = true;
99 }
100 }
101
102
103 /*
104 * Stream function
105 */
106
107 bool DigitalRenderer::stream_func(void *arg, char *buf, size_t count, void *header)
108 {
109 ((DigitalRenderer *)arg)->calc_buffer((int16 *)buf, count);
110 ((DigitalRenderer *)arg)->the_c64->SoundSync();
111 return true;
112 }