28 #include "sidplayfp/event.h"
29 #include "EventScheduler.h"
41 static const int_least32_t CIAT_CR_START = 0x01;
42 static const int_least32_t CIAT_STEP = 0x04;
43 static const int_least32_t CIAT_CR_ONESHOT = 0x08;
44 static const int_least32_t CIAT_CR_FLOAD = 0x10;
45 static const int_least32_t CIAT_PHI2IN = 0x20;
46 static const int_least32_t CIAT_CR_MASK = CIAT_CR_START | CIAT_CR_ONESHOT | CIAT_CR_FLOAD | CIAT_PHI2IN;
48 static const int_least32_t CIAT_COUNT2 = 0x100;
49 static const int_least32_t CIAT_COUNT3 = 0x200;
51 static const int_least32_t CIAT_ONESHOT0 = 0x08 << 8;
52 static const int_least32_t CIAT_ONESHOT = 0x08 << 16;
53 static const int_least32_t CIAT_LOAD1 = 0x10 << 8;
54 static const int_least32_t CIAT_LOAD = 0x10 << 16;
56 static const int_least32_t CIAT_OUT = 0x80000000;
72 event_clock_t ciaEventPauseTime;
84 uint8_t lastControlValue;
97 void cycleSkippingEvent();
109 inline void reschedule();
119 virtual void underFlow() =0;
124 virtual void serialPort() {};
136 m_cycleSkippingEvent(
"Skip CIA clock decrement cycles", *this, &
Timer::cycleSkippingEvent),
137 event_context(*context),
208 inline uint_least16_t
getTimer()
const {
return timer; }
216 inline bool getPb(uint8_t reg)
const {
return (reg & 0x04) ? pbToggle : (
state & CIAT_OUT); }
219 void Timer::reschedule()
230 const int_least32_t unwanted = CIAT_OUT | CIAT_CR_FLOAD | CIAT_LOAD1 | CIAT_LOAD;
231 if ((
state & unwanted) != 0)
237 if ((
state & CIAT_COUNT3) != 0)
242 const int_least32_t wanted = CIAT_CR_START | CIAT_PHI2IN | CIAT_COUNT2 | CIAT_COUNT3;
243 if (timer > 2 && (
state & wanted) == wanted)
248 ciaEventPauseTime = event_context.
getTime(EVENT_CLOCK_PHI1) + 1;
250 event_context.
schedule(m_cycleSkippingEvent, timer - 1);
261 const int_least32_t unwanted1 = CIAT_CR_START | CIAT_PHI2IN;
262 const int_least32_t unwanted2 = CIAT_CR_START | CIAT_STEP;
264 if ((
state & unwanted1) == unwanted1
265 || (
state & unwanted2) == unwanted2)
271 ciaEventPauseTime = -1;