libsidplayfp 1.0.3
sidemu.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 2000-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 SIDEMU_H
00024 #define SIDEMU_H
00025 
00026 #include "SidConfig.h"
00027 #include "component.h"
00028 #include "sidplayfp/c64/Banks/Bank.h"
00029 #include "sidplayfp/siddefs.h"
00030 
00031 class sidbuilder;
00032 class EventContext;
00033 
00037 class sidemu : public component, public Bank
00038 {
00039 private:
00040     sidbuilder *m_builder;
00041 
00042 protected:
00043     short *m_buffer;
00044     int m_bufferpos;
00045 
00046 public:
00047     sidemu(sidbuilder *builder) :
00048         m_builder (builder), m_buffer(0) {}
00049     virtual ~sidemu() {}
00050 
00051     // Standard component functions
00052     void reset() { reset (0); }
00053 
00054     virtual void reset(uint8_t volume) = 0;
00055 
00056     virtual void clock() = 0;
00057 
00058     virtual bool lock(EventContext *env) = 0;
00059     virtual void unlock() = 0;
00060 
00061     // Standard SID functions
00062     virtual void voice(unsigned int num, bool mute) = 0;
00063     virtual void model(SidConfig::sid_model_t model) = 0;
00064 
00065     sidbuilder *builder() const { return m_builder; }
00066 
00067     virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED,
00068         SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED) {}
00069 
00070     int bufferpos() const { return m_bufferpos; }
00071     void bufferpos(int pos) { m_bufferpos = pos; }
00072     short *buffer() const { return m_buffer; }
00073 
00074     void poke(uint_least16_t address, uint8_t value) { write(address & 0x1f, value); }
00075     uint8_t peek(uint_least16_t address) { return read(address & 0x1f); }
00076 };
00077 
00078 #endif // SIDEMU_H