mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Rationalises reload logic and cuts storage.
Failure point is now chaining, I think.
This commit is contained in:
parent
77c627e822
commit
38848ca2db
@ -248,9 +248,9 @@ void MOS6526<BusHandlerT, personality>::run_for(const HalfCycles half_cycles) {
|
||||
pending_ &= PendingClearMask;
|
||||
|
||||
// TODO: use CNT potentially to clock timer A, elimiante conditional above.
|
||||
counter_[0].advance(false);
|
||||
counter_[1].advance(counter_[0].hit_zero);
|
||||
posit_interrupt((counter_[0].hit_zero ? 0x01 : 0x00) | (counter_[1].hit_zero ? 0x02 : 0x00));
|
||||
const bool timer1_did_reload = counter_[0].advance(false);
|
||||
const bool timer2_did_reload = counter_[1].advance(timer1_did_reload);
|
||||
posit_interrupt((timer1_did_reload ? 0x01 : 0x00) | (timer2_did_reload ? 0x02 : 0x00));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ struct MOS6526Storage {
|
||||
uint16_t reload = 0;
|
||||
uint16_t value = 0;
|
||||
uint8_t control = 0;
|
||||
bool hit_zero = false;
|
||||
|
||||
template <int shift> void set_reload(uint8_t v) {
|
||||
reload = (reload & (0xff00 >> shift)) | uint16_t(v << shift);
|
||||
@ -46,16 +45,19 @@ struct MOS6526Storage {
|
||||
control = v;
|
||||
}
|
||||
|
||||
void advance(bool chained_input) {
|
||||
bool advance(bool chained_input) {
|
||||
// TODO: remove most of the conditionals here.
|
||||
|
||||
pending <<= 1;
|
||||
|
||||
//
|
||||
// Apply feeder states inputs: anything that
|
||||
// will take effect in the future.
|
||||
//
|
||||
if(control & 0x10) {
|
||||
pending |= ReloadInOne;
|
||||
control &= ~0x10;
|
||||
}
|
||||
|
||||
if((control & 0x01) || chained_input) {
|
||||
pending |= ApplyClockInTwo;
|
||||
}
|
||||
@ -63,24 +65,40 @@ struct MOS6526Storage {
|
||||
pending |= OneShotInOne;
|
||||
}
|
||||
|
||||
if((pending & ReloadNow) || (hit_zero && (pending & ApplyClockInTwo))) {
|
||||
value = reload;
|
||||
pending &= ~ApplyClockNow; // Skip one decrement.
|
||||
}
|
||||
|
||||
//
|
||||
// Perform a timer tick and decide whether a reload is prompted.
|
||||
//
|
||||
if(pending & ApplyClockNow) {
|
||||
--value;
|
||||
hit_zero = !value;
|
||||
} else {
|
||||
hit_zero = false;
|
||||
}
|
||||
const bool should_reload = !value && (pending & ApplyClockInOne);
|
||||
|
||||
// Schedule a reload if so ordered.
|
||||
if(should_reload) {
|
||||
pending |= ReloadNow; // Combine this decision with a deferred
|
||||
// input from the force-reoad test above.
|
||||
|
||||
// If this was one-shot, stop.
|
||||
if(pending&(OneShotInOne | OneShotNow)) {
|
||||
control &= ~1;
|
||||
pending &= ~(ApplyClockInOne|ApplyClockInTwo);
|
||||
}
|
||||
}
|
||||
|
||||
if(hit_zero && pending&(OneShotInOne | OneShotNow)) {
|
||||
control &= ~1;
|
||||
// Reload if scheduled.
|
||||
if(pending & ReloadNow) {
|
||||
value = reload;
|
||||
pending &= ~ApplyClockInOne; // Skip one decrement.
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Clear any bits that would flow into the wrong field.
|
||||
//
|
||||
pending &= PendingClearMask;
|
||||
|
||||
return should_reload;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -6225,7 +6225,7 @@
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = DV3346VVUN;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
ENABLE_HARDENED_RUNTIME = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(USER_LIBRARY_DIR)/Frameworks",
|
||||
@ -6275,7 +6275,7 @@
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = DV3346VVUN;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
ENABLE_HARDENED_RUNTIME = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(USER_LIBRARY_DIR)/Frameworks",
|
||||
|
Loading…
x
Reference in New Issue
Block a user