28 #include "sidplayfp/EventScheduler.h"
40 static const int_least32_t CIAT_CR_START = 0x01;
41 static const int_least32_t CIAT_STEP = 0x04;
42 static const int_least32_t CIAT_CR_ONESHOT = 0x08;
43 static const int_least32_t CIAT_CR_FLOAD = 0x10;
44 static const int_least32_t CIAT_PHI2IN = 0x20;
45 static const int_least32_t CIAT_CR_MASK = CIAT_CR_START | CIAT_CR_ONESHOT | CIAT_CR_FLOAD | CIAT_PHI2IN;
47 static const int_least32_t CIAT_COUNT2 = 0x100;
48 static const int_least32_t CIAT_COUNT3 = 0x200;
50 static const int_least32_t CIAT_ONESHOT0 = 0x08 << 8;
51 static const int_least32_t CIAT_ONESHOT = 0x08 << 16;
52 static const int_least32_t CIAT_LOAD1 = 0x10 << 8;
53 static const int_least32_t CIAT_LOAD = 0x10 << 16;
55 static const int_least32_t CIAT_OUT = 0x80000000;
73 event_clock_t ciaEventPauseTime;
93 uint8_t lastControlValue;
110 void cycleSkippingEvent();
122 inline void reschedule();
132 virtual void underFlow() =0;
137 virtual void serialPort() {};
149 m_cycleSkippingEvent(
"Skip CIA clock decrement cycles", *this, &
Timer::cycleSkippingEvent),
150 event_context(*context),
222 inline uint_least16_t
getTimer()
const {
return timer; }
230 inline bool getPb(uint8_t reg)
const {
return (reg & 0x04) ? pbToggle : (
state & CIAT_OUT); }
233 void Timer::reschedule()
244 const int_least32_t unwanted = CIAT_OUT | CIAT_CR_FLOAD | CIAT_LOAD1 | CIAT_LOAD;
245 if ((
state & unwanted) != 0)
251 if ((
state & CIAT_COUNT3) != 0)
256 const int_least32_t wanted = CIAT_CR_START | CIAT_PHI2IN | CIAT_COUNT2 | CIAT_COUNT3;
257 if (timer > 2 && (
state & wanted) == wanted)
262 ciaEventPauseTime = event_context.
getTime(EVENT_CLOCK_PHI1) + 1;
264 event_context.
schedule(m_cycleSkippingEvent, timer - 1);
275 const int_least32_t unwanted1 = CIAT_CR_START | CIAT_PHI2IN;
276 const int_least32_t unwanted2 = CIAT_CR_START | CIAT_STEP;
278 if ((
state & unwanted1) == unwanted1
279 || (
state & unwanted2) == unwanted2)
285 ciaEventPauseTime = -1;