cpc.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Fred Klaus                                      *
00003  *   frednet@web.de                                                        *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef CPC_H
00021 #define CPC_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024         #include <config.h>
00025 #endif
00026 
00027 #include "types.h"
00028 #include "prefs.h"
00029 
00030 #ifdef ENABLE_RAZE
00031         #include "raze.h"
00032 #endif
00033         
00034 #include "z80.h"
00035 #include "crtc.h"
00036 #include "ppi.h"
00037 #include "fdc.h"
00038 #include "psg.h"
00039 #include "gatearray.h"
00040 #include "memman.h"
00041 #include "keyboard.h"
00042 #include "colours.h"
00043 #include "sound.h"
00044 #include "vdu.h"
00045 
00046 
00047 #define MIN_SPEED_SETTING 2
00048 #define MAX_SPEED_SETTING 32
00049 #define DEF_SPEED_SETTING 4
00050 
00051 // number of CPU cycles per frame = 4MHz divided by 50Hz
00052 #define CYCLE_COUNT_INIT 80000
00053 
00054 #define mPsg_write \
00055 { \
00056    UBYTE control = mPsg.control() & 0xc0; /* isolate PSG control bits */ \
00057    if (control == 0xc0) { /* latch address? */ \
00058       mPsg.setSelected(mPsg_data); /* select new PSG register */ \
00059 } else if (control == 0x80) { /* write? */ \
00060       if (mPsg.selected() < 16) { /* valid register? */ \
00061          mSound.setAYRegister(mPsg.selected(), mPsg_data); \
00062 } \
00063 } \
00064 }
00065 
00066 
00067 
00069 class Cpc
00070 {
00071 
00072 public:
00073         enum CpcType {cpc464=0, cpc664=1, cpc6128=2};
00074         enum RamSize {ram64=64, ram128=128, ram256=256, ram512=512};
00075         //enum Monitor {colour=0, green=1, grey=2};
00076 
00077 
00078         Cpc(Prefs* prefs);
00079         ~Cpc() {}
00080 
00081         int init(Prefs* prefs=0);
00082 
00083         void setSpeed(uint value) {mSpeed=value;}
00084 
00085         uint    speed()   {return mSpeed;}
00086         //Monitor monitor() {return mMonitor;}
00087 
00088         UBYTE z80_in_handler (REGPAIR port); //@todo change This !!
00089         void  z80_out_handler(REGPAIR port, UBYTE value);
00090         void waitstates();
00091 
00092 
00093         Z80       & z80()       {return mZ80;}
00094         Ppi       & ppi()       {return mPpi;}
00095         Fdc       & fdc()       {return mFdc;}
00096         Psg       & psg()       {return mPsg;}
00097         Vdu       & vdu()       {return mVdu;}
00098         Crtc      & crtc()      {return mCrtc;}
00099         Sound     & sound()     {return mSound;}
00100         MemMan    & memman()    {return mMemman;}
00101         Colours   & colours()   {return mColours;}
00102         Keyboard  & keyboard()  {return mKeyboard;}
00103         GateArray & gatearray() {return mGatearray;}
00104 
00105 private:
00106         CpcType   mCpcType;
00107         //Monitor  mMonitor;
00108 
00109         uint      mSpeed;
00110         uint      mBpp;
00111 
00112         Prefs*    mPrefs;
00113 
00114         Z80       mZ80; //@todo change this !!!!!!!!!!!!!
00115         Crtc      mCrtc;
00116         Ppi       mPpi;
00117         Fdc       mFdc;
00118         Psg       mPsg;
00119         GateArray mGatearray;
00120         Keyboard  mKeyboard;
00121         Colours   mColours;
00122         MemMan    mMemman;
00123         Sound     mSound;
00124         Vdu       mVdu;
00125 
00126 };
00127 
00128 #endif

Generated on Fri Mar 16 21:30:28 2007 for roland.kdevelop by  doxygen 1.5.0