libsidplayfp  1.0.3
c64vic.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 C64VIC_H
00024 #define C64VIC_H
00025 
00026 // The VIC emulation is very generic and here we need to effectively
00027 // wire it into the computer (like adding a chip to a PCB).
00028 
00029 #include "Banks/Bank.h"
00030 #include "sidplayfp/c64/c64env.h"
00031 #include "sidplayfp/sidendian.h"
00032 #include "VIC_II/mos656x.h"
00033 
00038 class c64vic: public MOS656X, public Bank
00039 {
00040 private:
00041     c64env &m_env;
00042 
00043 protected:
00044     void interrupt(bool state)
00045     {
00046         m_env.interruptIRQ (state);
00047     }
00048 
00049     void setBA(bool state)
00050     {
00051         m_env.setBA (state);
00052     }
00053 
00054 public:
00055     c64vic(c64env *env) :
00056         MOS656X(&(env->context ())),
00057         m_env(*env) {}
00058 
00059     void poke(uint_least16_t address, uint8_t value)
00060     {
00061         write(endian_16lo8(address), value);
00062     }
00063 
00064     uint8_t peek(uint_least16_t address)
00065     {
00066         return read(endian_16lo8(address));
00067     }
00068 
00069     const char *error() const { return ""; }
00070 };
00071 
00072 #endif // C64VIC_H