libsidplayfp  1.2.2
sidemu.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2013 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 "component.h"
27 #include "SidConfig.h"
28 #include "siddefs.h"
29 #include "c64/c64sid.h"
30 
31 class sidbuilder;
32 class EventContext;
33 
37 enum
38 {
39  OUTPUTBUFFERSIZE = 5000
40 };
41 
45 class sidemu : public c64sid, public component
46 {
47 private:
48  sidbuilder *m_builder;
49 
50 protected:
51  short *m_buffer;
52  int m_bufferpos;
53 
54 public:
55  sidemu(sidbuilder *builder) :
56  m_builder (builder), m_buffer(0) {}
57  virtual ~sidemu() {}
58 
59  // Standard component functions
60  void reset() { reset(0); }
61 
62  virtual void reset(uint8_t volume) = 0;
63 
64  virtual void clock() = 0;
65 
66  virtual bool lock(EventContext *env) = 0;
67  virtual void unlock() = 0;
68 
69  // Standard SID functions
70  virtual void voice(unsigned int num, bool mute) = 0;
71  virtual void model(SidConfig::sid_model_t model) = 0;
72 
73  sidbuilder *builder() const { return m_builder; }
74 
75  virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED,
76  SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED) {}
77 
78  int bufferpos() const { return m_bufferpos; }
79  void bufferpos(int pos) { m_bufferpos = pos; }
80  short *buffer() const { return m_buffer; }
81 
82  void poke(uint_least16_t address, uint8_t value) { write(address & 0x1f, value); }
83  uint8_t peek(uint_least16_t address) { return read(address & 0x1f); }
84 };
85 
86 #endif // SIDEMU_H
Definition: sidemu.h:45
void poke(uint_least16_t address, uint8_t value)
Definition: sidemu.h:82
Definition: c64sid.h:31
Definition: event.h:101
Definition: component.h:28
uint8_t peek(uint_least16_t address)
Definition: sidemu.h:83
Definition: sidbuilder.h:37