00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MOS656X_H
00024 #define MOS656X_H
00025
00026 #include "sidplayfp/component.h"
00027 #include "sidplayfp/EventScheduler.h"
00028
00029
00030 class MOS656X: public component, private Event
00031 {
00032 public:
00033 typedef enum
00034 {
00035 MOS6567R56A = 0
00036 ,MOS6567R8
00037 ,MOS6569
00038 ,MOS6572
00039 } model_t;
00040
00041 private:
00042 static const char *credit;
00043
00044 private:
00046 static const int IRQ_RASTER = 1 << 0;
00047
00049 static const int IRQ_LIGHTPEN = 1 << 3;
00050
00051 protected:
00053 static const int FIRST_DMA_LINE = 0x30;
00054
00056 static const int LAST_DMA_LINE = 0xf7;
00057
00058 protected:
00059 event_clock_t m_rasterClk;
00060
00062 EventContext &event_context;
00063
00065 uint_least16_t cyclesPerLine;
00066
00067 uint_least16_t maxRasters;
00068
00069 uint_least16_t raster_irq;
00070
00072 uint_least16_t lineCycle;
00073
00075 uint_least16_t rasterY;
00076
00078 uint_least16_t yscroll;
00079
00081 bool areBadLinesEnabled;
00082
00084 bool isBadLine;
00085
00087 bool vblanking;
00088
00090 bool lp_triggered;
00091
00093 uint8_t irqFlags;
00094
00096 uint8_t irqMask;
00097
00099 uint8_t lpx, lpy;
00100
00103 uint8_t &sprite_enable, &sprite_y_expansion;
00104 uint8_t sprite_dma, sprite_expand_y;
00105 uint8_t sprite_mc_base[8];
00107
00109 uint8_t regs[0x40];
00110
00111 private:
00112 event_clock_t clock();
00113
00115 void handleIrqState();
00116
00117 protected:
00118 MOS656X(EventContext *context);
00119 ~MOS656X() {}
00120
00121 void event();
00122
00123 EventCallback<MOS656X> badLineStateChangeEvent;
00124
00126 void badLineStateChange() { setBA(false); }
00127
00132 void activateIRQFlag(int flag)
00133 {
00134 irqFlags |= flag;
00135 handleIrqState();
00136 }
00137
00143 bool readDEN() const { return (regs[0x11] & 0x10) != 0; }
00144
00145 bool evaluateIsBadLine() const
00146 {
00147 return areBadLinesEnabled
00148 && rasterY >= FIRST_DMA_LINE
00149 && rasterY <= LAST_DMA_LINE
00150 && (rasterY & 7) == yscroll;
00151 }
00152
00153
00154 virtual void interrupt (bool state) = 0;
00155 virtual void setBA (bool state) = 0;
00156
00163 uint8_t read(uint_least8_t addr);
00164
00173 void write(uint_least8_t addr, uint8_t data);
00174
00175 public:
00176 void chip(model_t model);
00177 void lightpen();
00178
00179
00180 void reset();
00181
00182 const char *credits() const { return credit; }
00183
00184 uint_least16_t getCyclesPerLine() const { return cyclesPerLine; }
00185
00186 uint_least16_t getRasterLines() const { return maxRasters; }
00187 };
00188
00189 #endif // MOS656X_H