mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-05 05:34:20 +00:00
Takes a guess at one-shot mode.
This commit is contained in:
parent
e3bb9fc1d7
commit
ceca32ceb3
@ -69,9 +69,15 @@ void MOS6526<BusHandlerT, personality>::write(int address, uint8_t value) {
|
|||||||
|
|
||||||
// Counters; writes set the reload values.
|
// Counters; writes set the reload values.
|
||||||
case 4: counter_[0].reload = (counter_[0].reload & 0xff00) | uint16_t(value << 0); break;
|
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 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.
|
// Time-of-day clock.
|
||||||
//
|
//
|
||||||
@ -138,6 +144,7 @@ void MOS6526<BusHandlerT, personality>::write(int address, uint8_t value) {
|
|||||||
case 14:
|
case 14:
|
||||||
if(value & 0x10) {
|
if(value & 0x10) {
|
||||||
counter_[0].value = counter_[0].reload;
|
counter_[0].value = counter_[0].reload;
|
||||||
|
counter_[0].is_counting = true;
|
||||||
}
|
}
|
||||||
counter_[0].control = value & 0xef;
|
counter_[0].control = value & 0xef;
|
||||||
printf("Ignoring control A write: %02x\n", value);
|
printf("Ignoring control A write: %02x\n", value);
|
||||||
@ -146,6 +153,7 @@ void MOS6526<BusHandlerT, personality>::write(int address, uint8_t value) {
|
|||||||
case 15:
|
case 15:
|
||||||
if(value & 0x10) {
|
if(value & 0x10) {
|
||||||
counter_[1].value = counter_[1].reload;
|
counter_[1].value = counter_[1].reload;
|
||||||
|
counter_[1].is_counting = true;
|
||||||
}
|
}
|
||||||
counter_[1].control = value;
|
counter_[1].control = value;
|
||||||
printf("Ignoring control B write: %02x\n", value);
|
printf("Ignoring control B write: %02x\n", value);
|
||||||
|
@ -30,18 +30,20 @@ struct MOS6526Storage {
|
|||||||
uint16_t reload = 0;
|
uint16_t reload = 0;
|
||||||
uint16_t value = 0;
|
uint16_t value = 0;
|
||||||
uint8_t control = 0;
|
uint8_t control = 0;
|
||||||
// int one_shot_mask = 0;
|
bool is_counting = false;
|
||||||
|
|
||||||
int subtract(int count) {
|
int subtract(int count) {
|
||||||
if(control & 8) {
|
if(control & 8) {
|
||||||
// One-shot.
|
// One-shot.
|
||||||
// value -= count;
|
if(is_counting) {
|
||||||
// if(value < 0) {
|
if(value < count) {
|
||||||
// const int underflows = one_shot_mask;
|
value = reload;
|
||||||
// value = 0;
|
is_counting = false;
|
||||||
// one_shot_mask = 0;
|
return 1;
|
||||||
// return underflows;
|
} else {
|
||||||
// }
|
value -= count;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// Continuous.
|
// Continuous.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user