libsidplayfp  1.0.3
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 "SidConfig.h"
27 #include "component.h"
28 #include "sidplayfp/c64/Banks/Bank.h"
29 #include "sidplayfp/siddefs.h"
30 
31 class sidbuilder;
32 class EventContext;
33 
37 class sidemu : public component, public Bank
38 {
39 private:
40  sidbuilder *m_builder;
41 
42 protected:
43  short *m_buffer;
44  int m_bufferpos;
45 
46 public:
47  sidemu(sidbuilder *builder) :
48  m_builder (builder), m_buffer(0) {}
49  virtual ~sidemu() {}
50 
51  // Standard component functions
52  void reset() { reset (0); }
53 
54  virtual void reset(uint8_t volume) = 0;
55 
56  virtual void clock() = 0;
57 
58  virtual bool lock(EventContext *env) = 0;
59  virtual void unlock() = 0;
60 
61  // Standard SID functions
62  virtual void voice(unsigned int num, bool mute) = 0;
63  virtual void model(SidConfig::sid_model_t model) = 0;
64 
65  sidbuilder *builder() const { return m_builder; }
66 
67  virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED,
68  SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED) {}
69 
70  int bufferpos() const { return m_bufferpos; }
71  void bufferpos(int pos) { m_bufferpos = pos; }
72  short *buffer() const { return m_buffer; }
73 
74  void poke(uint_least16_t address, uint8_t value) { write(address & 0x1f, value); }
75  uint8_t peek(uint_least16_t address) { return read(address & 0x1f); }
76 };
77 
78 #endif // SIDEMU_H