crtc.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 CRTC_H
00021 #define CRTC_H
00022 
00023 #include "types.h"
00024 
00025 #include "vdu.h"
00026 #include "ppi.h"
00027 
00029 
00031 class Crtc
00032 {
00033 
00034 public:
00035         enum Register
00036         {                                 
00037             HorizontalTotal         =  0, 
00038             HorizontalDisplayed     =  1, 
00039             HorizontalSyncPosition  =  2, 
00040             SyncWidth               =  3, 
00041             VerticalTotal           =  4, 
00042             VerticalTotalAdjust     =  5, 
00043             VerticalDisplayed       =  6, 
00044             VerticalSyncPosition    =  7, 
00045             InterlaceAndSkew        =  8, 
00046             MaximumRasterAddress    =  9, 
00047             CursorStartRaster       = 10, 
00048             CursorEndRaster         = 11, 
00049             StartAddressHigh        = 12, 
00050             StartAddressLow         = 13, 
00051             CursorHigh              = 14, 
00052             CursorLow               = 15, 
00053             LightPenHigh            = 16, 
00054             LightPenLow             = 17  
00055         };
00056 
00057         enum Flags
00058         {
00059             VS     = 1,
00060             HS     = 2,
00061             HDT    = 4,
00062             VDT    = 8,
00063             HT     = 16,
00064             VT     = 32,
00065             MR     = 64,
00066             VTadj  = 128,
00067             VSf    = 256
00068         };
00069 
00070         Crtc() : mSelected(0) {mVdu=0; mPpi=0; init();}
00071         ~Crtc() {}
00072 
00073         void init(Vdu* vdu=0, Ppi* ppi=0);
00074         void reset() {init();}
00075 
00076         UBYTE selected() {return mSelected;}
00077 
00078         void  select(UBYTE reg)             {if (reg < 18) mSelected=reg;}
00079         UBYTE read()                        {return mRegister[mSelected];}
00080         UBYTE read(UBYTE num)               {return (num < 18) ? mRegister[num] : 0;}
00081         void  write(UBYTE reg, UBYTE value) {mRegister[reg]=value;}
00082         void  write(UBYTE value);
00083 
00084         uint flags()   {return mFlags;}
00085         UBYTE hsw()            {return mHsw;}
00086         UBYTE hswCount()       {return mHswCount;}
00087         UBYTE hswActive()      {return mHswActive;}
00088         UBYTE vsw()            {return mVsw;}
00089         UBYTE vswCount()       {return mVswCount;}
00090         UBYTE lastHDisp()      {return mLastHDisp;}
00091         UBYTE skew()           {return mSkew;}
00092         UBYTE vtAdjust()       {return mVtAdjust;}
00093         UBYTE vtAdjustCount()  {return mVtAdjustCount;}
00094         UBYTE maxRaster()      {return mMaxRaster;}
00095         UBYTE rasterCount()    {return mRasterCount;}
00096         UBYTE lineCount()      {return mLineCount;}
00097         UBYTE charCount()      {return mCharCount;}
00098         uint requestedAddr()  {return mRequestedAddr;}
00099         uint addr()           {return mAddr;}
00100 
00101         void setFlags   (uint flags) {mFlags = flags;}
00102         void addFlags   (uint flags) {mFlags |= flags;}
00103         void removeFlags(uint flags) {mFlags &= ~flags;}
00104 
00105         //void setHsw(UBYTE val) {write(read(SyncWidth) | (val & 0x0f));}
00106         //void setVsw(UBYTE val) {write(read(SyncWidth) | (val >> 4));}
00107 
00108         void setHswActive     (UBYTE value) {mHswActive     = value;}
00109         void setHswCount      (UBYTE value) {mHswCount      = value;}
00110         void setAddr   (uint value) {mAddr          = value;}
00111         void setVtAdjust      (UBYTE value) {mVtAdjust      = value;}
00112         void setVtAdjustCount (UBYTE value) {mVtAdjustCount = value;}
00113         void setVswCount      (UBYTE value) {mVswCount      = value;}
00114         void setLastHDisp     (UBYTE value) {mLastHDisp     = value;}
00115         void setCharCount     (UBYTE value) {mCharCount     = value;}
00116         void setLineCount     (UBYTE value) {mLineCount     = value;}
00117         void setRasterCount   (UBYTE value) {mRasterCount   = value;}
00118         void setSkew          (UBYTE value) {mSkew          = value;}
00119 
00120         void incVswCount()  {mVswCount++;}
00121         //void decVswCount()  {--mVswCount;}
00122         //void incLineCount() {mLineCount++;}
00123 
00124 private:
00125         Vdu* mVdu;
00126         Ppi* mPpi;
00127         
00128         UBYTE mRegister[18];
00129         UBYTE mSelected;
00130 
00131         uint mFlags;
00132         UBYTE mHsw;
00133         UBYTE mHswCount;
00134         UBYTE mHswActive;
00135         UBYTE mVsw;
00136         UBYTE mVswCount;
00137         UBYTE mLastHDisp;
00138         UBYTE mSkew;
00139         UBYTE mVtAdjust;
00140         UBYTE mVtAdjustCount;
00141         UBYTE mMaxRaster;
00142         UBYTE mRasterCount;
00143         UBYTE mLineCount;
00144         UBYTE mCharCount;
00145         uint mRequestedAddr;
00146         uint mAddr;
00147 
00148 };
00149 
00150 #endif

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