libsidplayfp  1.1.0
resid-emu.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 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 RESID_EMU_H
24 #define RESID_EMU_H
25 
26 #include <string>
27 
28 #include "sidplayfp/sidemu.h"
29 #include "sidplayfp/EventScheduler.h"
30 #include "resid/sid.h"
31 
32 #ifdef HAVE_CONFIG_H
33 # include "config.h"
34 #endif
35 
36 //FIXME
37 #define RESID_NAMESPACE reSID
38 
39 #ifdef RESID_NAMESPACE
40 # define RESID_NS ::RESID_NAMESPACE
41 #else
42 # define RESID_NS
43 #endif
44 
45 class ReSID: public sidemu
46 {
47 private:
48  EventContext *m_context;
49  RESID_NS::SID &m_sid;
50  event_clock_t m_accessClk;
51  const char *m_error;
52  bool m_status;
53  bool m_locked;
54  uint8_t m_voiceMask;
55 
56  static std::string m_credit;
57 
58 public:
59  static const char* getCredits();
60 
61 public:
62  ReSID(sidbuilder *builder);
63  ~ReSID();
64 
65  // Standard component functions
66  const char *credits () const { return getCredits(); }
67 
68  void reset() { sidemu::reset (); }
69  void reset(uint8_t volume);
70 
71  uint8_t read(uint_least8_t addr);
72  void write(uint_least8_t addr, uint8_t data);
73 
74  const char *error() const { return m_error; }
75 
76  // Standard SID functions
77  void clock();
78  void filter(bool enable);
79  void voice(unsigned int num, bool mute);
80 
81  bool getStatus() const { return m_status; }
82 
83  // Specific to resid
84  void sampling(float systemclock, float freq,
85  SidConfig::sampling_method_t method, bool fast);
86 
87  void bias(double dac_bias);
88  void model(SidConfig::sid_model_t model);
89 
90  // Must lock the SID before using the standard functions.
91  bool lock(EventContext *env);
92  void unlock();
93 };
94 
95 #endif // RESID_EMU_H