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

Takes a guess at one-shot mode.

This commit is contained in:
Thomas Harte 2021-07-24 15:53:18 -04:00
parent e3bb9fc1d7
commit ceca32ceb3
2 changed files with 20 additions and 10 deletions

View File

@ -69,9 +69,15 @@ void MOS6526<BusHandlerT, personality>::write(int address, uint8_t value) {
// Counters; writes set the reload values.
case 4: counter_[0].reload = (counter_[0].reload & 0xff00) | uint16_t(value << 0); break;
case 5: counter_[0].reload = (counter_[0].reload & 0x00ff) | uint16_t(value << 8); break;
case 5:
counter_[0].reload = (counter_[0].reload & 0x00ff) | uint16_t(value << 8);
counter_[0].is_counting = true;
break;
case 6: counter_[1].reload = (counter_[1].reload & 0xff00) | uint16_t(value << 0); break;
case 7: counter_[1].reload = (counter_[1].reload & 0x00ff) | uint16_t(value << 8); break;
case 7:
counter_[1].reload = (counter_[1].reload & 0x00ff) | uint16_t(value << 8);
counter_[1].is_counting = true;
break;
// Time-of-day clock.
//
@ -138,6 +144,7 @@ void MOS6526<BusHandlerT, personality>::write(int address, uint8_t value) {
case 14:
if(value & 0x10) {
counter_[0].value = counter_[0].reload;
counter_[0].is_counting = true;
}
counter_[0].control = value & 0xef;
printf("Ignoring control A write: %02x\n", value);
@ -146,6 +153,7 @@ void MOS6526<BusHandlerT, personality>::write(int address, uint8_t value) {
case 15:
if(value & 0x10) {
counter_[1].value = counter_[1].reload;
counter_[1].is_counting = true;
}
counter_[1].control = value;
printf("Ignoring control B write: %02x\n", value);

View File

@ -30,18 +30,20 @@ struct MOS6526Storage {
uint16_t reload = 0;
uint16_t value = 0;
uint8_t control = 0;
// int one_shot_mask = 0;
bool is_counting = false;
int subtract(int count) {
if(control & 8) {
// One-shot.
// value -= count;
// if(value < 0) {
// const int underflows = one_shot_mask;
// value = 0;
// one_shot_mask = 0;
// return underflows;
// }
if(is_counting) {
if(value < count) {
value = reload;
is_counting = false;
return 1;
} else {
value -= count;
}
}
return 0;
} else {
// Continuous.