1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Reinstates clocking.

This commit is contained in:
Thomas Harte 2021-08-01 21:35:08 -04:00
parent 60b09d9bb0
commit c640132699
2 changed files with 13 additions and 47 deletions

View File

@ -253,42 +253,6 @@ void MOS6526<BusHandlerT, personality>::run_for(const HalfCycles half_cycles) {
}
}
/*template <typename BusHandlerT, Personality personality>
void MOS6526<BusHandlerT, personality>::advance_counters(int sub) {
// Is counter A running and linked to the clock input?
int counter_a_underflows = 0;
if(counter_[0].control & 0x20) {
printf("Unimplemented: Timer A CNT \n");
} else {
counter_a_underflows = counter_[0].subtract(sub);
}
// Counter A might be clocking the shift register.
if(counter_a_underflows && counter_[0].control & 0x40) {
printf("Unimplemented shift register clocking\n");
}
// Update counter B.
int counter_b_underflows = 0;
switch(counter_[1].control & 0x61) {
case 0x01:
counter_b_underflows = counter_[1].subtract(sub);
break;
case 0x41:
counter_b_underflows = counter_[1].subtract(counter_a_underflows);
break;
default:
if(counter_[1].control & 1) {
printf("Unimplemented 6526 CNT input\n");
assert(false);
}
break;
}
// Apply interrupts.
posit_interrupt((counter_a_underflows ? 0x01 : 0x00) | (counter_b_underflows ? 0x02 : 0x00));
}*/
template <typename BusHandlerT, Personality personality>
void MOS6526<BusHandlerT, personality>::advance_tod(int count) {
if(!count) return;

View File

@ -52,7 +52,7 @@ struct MOS6526Storage {
pending <<= 1;
if(control & 0x10) {
pending |= ReloadInTwo;
pending |= ReloadInOne;
control &= ~0x10;
}
@ -60,16 +60,14 @@ struct MOS6526Storage {
pending |= ApplyClockInTwo;
}
if(control & 0x08) {
pending |= OneShotInOne;
pending |= OneShotInTwo;
}
if((pending & ReloadNow) || (hit_zero && (pending & ApplyClockInTwo))) {
value = reload;
pending &= ~ApplyClockInOne;
pending &= ~ApplyClockInOne; // Skip one decrement.
}
pending &= PendingClearMask;
if(pending & ApplyClockNow) {
--value;
hit_zero = !value;
@ -80,6 +78,9 @@ struct MOS6526Storage {
if(hit_zero && pending&(OneShotInOne | OneShotNow)) {
control &= ~1;
}
// Clear any bits that would flow into the wrong field.
pending &= PendingClearMask;
}
private:
@ -90,13 +91,14 @@ struct MOS6526Storage {
static constexpr int ReloadInOne = 1 << 2;
static constexpr int ReloadNow = 1 << 3;
static constexpr int OneShotInOne = 1 << 4;
static constexpr int OneShotNow = 1 << 5;
static constexpr int OneShotInTwo = 1 << 4;
static constexpr int OneShotInOne = 1 << 5;
static constexpr int OneShotNow = 1 << 6;
static constexpr int ApplyClockInThree = 1 << 6;
static constexpr int ApplyClockInTwo = 1 << 7;
static constexpr int ApplyClockInOne = 1 << 8;
static constexpr int ApplyClockNow = 1 << 9;
static constexpr int ApplyClockInThree = 1 << 7;
static constexpr int ApplyClockInTwo = 1 << 8;
static constexpr int ApplyClockInOne = 1 << 9;
static constexpr int ApplyClockNow = 1 << 10;
static constexpr int PendingClearMask = ~(ReloadNow | OneShotNow | ApplyClockNow);