libsidplayfp  1.0.3
residfp-emu.h
00001 /*
00002  * This file is part of libsidplayfp, a SID player engine.
00003  *
00004  * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
00005  * Copyright 2007-2010 Antti Lankila
00006  * Copyright 2001 Simon White
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021  */
00022 
00023 #ifndef RESIDFP_EMU_H
00024 #define RESIDFP_EMU_H
00025 
00026 #include <string>
00027 
00028 #include "residfp/SID.h"
00029 #include "sidplayfp/sidemu.h"
00030 #include "sidplayfp/EventScheduler.h"
00031 
00032 #ifdef HAVE_CONFIG_H
00033 #  include "config.h"
00034 #endif
00035 
00036 #define RESID_NAMESPACE reSIDfp
00037 
00038 enum {
00039     OUTPUTBUFFERSIZE = 5000 //32768
00040 };
00041 
00042 class ReSIDfp: public sidemu
00043 {
00044 private:
00045     EventContext *m_context;
00046     RESID_NAMESPACE::SID &m_sid;
00047     event_clock_t m_accessClk;
00048     const  char  *m_error;
00049     bool          m_status;
00050     bool          m_locked;
00051 
00052     static std::string m_credit;
00053 
00054 public:
00055     static const char* getCredits();
00056 
00057 public:
00058     ReSIDfp(sidbuilder *builder);
00059     ~ReSIDfp();
00060 
00061     // Standard component functions
00062     const char *credits() const { return getCredits(); }
00063     
00064     void reset() { sidemu::reset (); }
00065     void reset(uint8_t volume);
00066 
00067     uint8_t read(uint_least8_t addr);
00068     void write(uint_least8_t addr, uint8_t data);
00069 
00070     const char *error() const { return m_error; }
00071 
00072     // Standard SID functions
00073     void clock();
00074     void filter(bool enable);
00075     void voice(unsigned int num, bool mute) { m_sid.mute(num, mute); }
00076 
00077     bool getStatus() const { return m_status; }
00078 
00079     // Specific to resid
00080     void sampling(float systemclock, float freq,
00081         SidConfig::sampling_method_t method, bool fast);
00082 
00083     void filter6581Curve(double filterCurve);
00084     void filter8580Curve(double filterCurve);
00085     void model(SidConfig::sid_model_t model);
00086 
00087     // Must lock the SID before using the standard functions.
00088     bool lock(EventContext *env);
00089     void unlock();
00090 };
00091 
00092 #endif // RESIDFP_EMU_H