libsidplayfp 1.8.8
sidemu.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2014 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2000-2001 Simon White
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#ifndef SIDEMU_H
24#define SIDEMU_H
25
26#include <string>
27
28#include "SidConfig.h"
29#include "siddefs.h"
30#include "event.h"
31#include "c64/c64sid.h"
32
33class sidbuilder;
34class EventContext;
35
39class sidemu : public c64sid
40{
41public:
45 enum
46 {
47 OUTPUTBUFFERSIZE = 5000
48 };
49
50private:
51 sidbuilder *m_builder;
52
53protected:
54 static std::string m_credit;
55
56protected:
57 static const char ERR_UNSUPPORTED_FREQ[];
58 static const char ERR_INVALID_SAMPLING[];
59 static const char ERR_INVALID_CHIP[];
60
61protected:
62 EventContext *m_context;
63
64 event_clock_t m_accessClk;
65
67 short *m_buffer;
68
71
72 bool m_status;
73 bool m_locked;
74
75 std::string m_error;
76
77public:
78 sidemu(sidbuilder *builder) :
79 m_builder (builder),
80 m_context(0),
81 m_buffer(0),
82 m_bufferpos(0),
83 m_status(true),
84 m_locked(false),
85 m_error("N/A") {}
86 virtual ~sidemu() {}
87
91 virtual void clock() = 0;
92
96 virtual bool lock(EventContext *env);
97
101 virtual void unlock();
102
103 // Standard SID functions
104
108 virtual void voice(unsigned int num, bool mute) = 0;
109
113 virtual void model(SidConfig::sid_model_t model) = 0;
114
123 virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED,
124 SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED) {}
125
129 const char *error() const { return m_error.c_str(); }
130
131 sidbuilder *builder() const { return m_builder; }
132
136 int bufferpos() const { return m_bufferpos; }
137
141 void bufferpos(int pos) { m_bufferpos = pos; }
142
146 short *buffer() const { return m_buffer; }
147
148 void poke(uint_least16_t address, uint8_t value) { write(address & 0x1f, value); }
149 uint8_t peek(uint_least16_t address) { return read(address & 0x1f); }
150};
151
152#endif // SIDEMU_H
Definition: event.h:108
Definition: c64sid.h:33
Definition: sidbuilder.h:38
Definition: sidemu.h:40
short * m_buffer
The sample buffer.
Definition: sidemu.h:67
short * buffer() const
Definition: sidemu.h:146
virtual bool lock(EventContext *env)
Definition: sidemu.cpp:31
virtual void unlock()
Definition: sidemu.cpp:42
const char * error() const
Definition: sidemu.h:129
uint8_t peek(uint_least16_t address)
Definition: sidemu.h:149
virtual void clock()=0
virtual void voice(unsigned int num, bool mute)=0
void bufferpos(int pos)
Definition: sidemu.h:141
virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED, SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED)
Definition: sidemu.h:123
virtual void model(SidConfig::sid_model_t model)=0
int m_bufferpos
Current position in buffer.
Definition: sidemu.h:70
void poke(uint_least16_t address, uint8_t value)
Definition: sidemu.h:148
int bufferpos() const
Definition: sidemu.h:136