31 #include "sidplayfp/event.h" 32 #include "c64/component.h" 33 #include "EventScheduler.h" 48 typedef event_clock_t (
MOS656X::*ClockFunc)();
52 unsigned int rasterLines;
53 unsigned int cyclesPerLine;
58 static const char *credit;
60 static const model_data_t modelData[];
63 static const int IRQ_RASTER = 1 << 0;
66 static const int IRQ_LIGHTPEN = 1 << 3;
69 static const unsigned int FIRST_DMA_LINE = 0x30;
72 static const unsigned int LAST_DMA_LINE = 0xf7;
77 event_clock_t rasterClk;
83 unsigned int cyclesPerLine;
86 unsigned int maxRasters;
89 unsigned int lineCycle;
98 bool areBadLinesEnabled;
104 bool rasterYIRQCondition;
128 event_clock_t clockPAL();
129 event_clock_t clockNTSC();
130 event_clock_t clockOldNTSC();
135 void handleIrqState();
142 void badLineStateChange() { setBA(!isBadLine); }
149 void rasterYIRQEdgeDetector()
151 const bool oldRasterYIRQCondition = rasterYIRQCondition;
152 rasterYIRQCondition = rasterY == readRasterLineIRQ();
153 if (!oldRasterYIRQCondition && rasterYIRQCondition)
154 activateIRQFlag(IRQ_RASTER);
161 void activateIRQFlag(
int flag)
172 unsigned int readRasterLineIRQ()
const 174 return (regs[0x12] & 0xff) + ((regs[0x11] & 0x80) << 1);
182 bool readDEN()
const {
return (regs[0x11] & 0x10) != 0; }
184 bool evaluateIsBadLine()
const 186 return areBadLinesEnabled
187 && rasterY >= FIRST_DMA_LINE
188 && rasterY <= LAST_DMA_LINE
189 && (rasterY & 7) == yscroll;
195 inline unsigned int oldRasterY()
const 197 return rasterY > 0 ? rasterY - 1 : maxRasters - 1;
202 event_context.
cancel(*
this);
209 inline void checkVblank()
212 if (rasterY == (maxRasters - 1))
218 if (rasterY == FIRST_DMA_LINE
219 && !areBadLinesEnabled
222 areBadLinesEnabled =
true;
226 if (rasterY == LAST_DMA_LINE)
228 areBadLinesEnabled =
false;
236 rasterYIRQEdgeDetector();
239 if (evaluateIsBadLine())
250 rasterYIRQEdgeDetector();
252 if (lpAsserted && lp.
retrigger(lineCycle, rasterY))
254 activateIRQFlag(IRQ_LIGHTPEN);
263 inline void startDma()
265 if (sprites.
isDma(0x01 << n))
275 if (!sprites.
isDma(0x06 << n))
282 inline void startBadline()
293 virtual void interrupt (
bool state) = 0;
294 virtual void setBA (
bool state) = 0;
302 uint8_t
read(uint_least8_t addr);
312 void write(uint_least8_t addr, uint8_t data);
317 void chip(model_t model);
332 static const char *credits() {
return credit; }
341 inline void MOS656X::startDma<0>()
343 setBA(!sprites.
isDma(0x01));
350 inline void MOS656X::endDma<7>()
void untrigger()
Definition: lightpen.h:133
bool isDma(unsigned int val) const
Definition: sprites.h:159
model_t
Definition: mos656x.h:39
void event()
Definition: mos656x.cpp:245
PAL-N.
Definition: mos656x.h:44
Definition: component.h:28
Definition: lightpen.h:30
uint8_t read(uint_least8_t addr)
Definition: mos656x.cpp:104
void clearLightpen()
Definition: mos656x.cpp:675
void write(uint_least8_t addr, uint8_t data)
Definition: mos656x.cpp:140
bool retrigger(unsigned int lineCycle, unsigned int rasterY)
Definition: lightpen.h:88
virtual void cancel(Event &event)=0
OLD NTSC CHIP.
Definition: mos656x.h:41
NTSC-M.
Definition: mos656x.h:42
void triggerLightpen()
Definition: mos656x.cpp:662
PAL-B.
Definition: mos656x.h:43