mirror of
https://github.com/TomHarte/CLK.git
synced 2024-08-17 07:29:04 +00:00
Adds the shift register interrupt.
This commit is contained in:
parent
8b72043f33
commit
2ba0364850
@ -84,7 +84,10 @@ template <typename T> void MOS6522<T>::set_register(int address, uint8_t value)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Shift
|
// Shift
|
||||||
case 0xa: registers_.shift = value; break;
|
case 0xa:
|
||||||
|
registers_.shift = value;
|
||||||
|
shift_bits_remaining_ = 8;
|
||||||
|
break;
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
case 0xb:
|
case 0xb:
|
||||||
@ -175,7 +178,9 @@ template <typename T> uint8_t MOS6522<T>::get_register(int address) {
|
|||||||
return registers_.timer[1] & 0x00ff;
|
return registers_.timer[1] & 0x00ff;
|
||||||
case 0x9: return registers_.timer[1] >> 8;
|
case 0x9: return registers_.timer[1] >> 8;
|
||||||
|
|
||||||
case 0xa: return registers_.shift;
|
case 0xa:
|
||||||
|
shift_bits_remaining_ = 8;
|
||||||
|
return registers_.shift;
|
||||||
|
|
||||||
case 0xb: return registers_.auxiliary_control;
|
case 0xb: return registers_.auxiliary_control;
|
||||||
case 0xc: return registers_.peripheral_control;
|
case 0xc: return registers_.peripheral_control;
|
||||||
@ -363,11 +368,21 @@ template <typename T> void MOS6522<T>::set_control_line_output(Port port, Line l
|
|||||||
|
|
||||||
template <typename T> void MOS6522<T>::shift_in() {
|
template <typename T> void MOS6522<T>::shift_in() {
|
||||||
registers_.shift = uint8_t((registers_.shift << 1) | (control_inputs_[1].lines[1] ? 1 : 0));
|
registers_.shift = uint8_t((registers_.shift << 1) | (control_inputs_[1].lines[1] ? 1 : 0));
|
||||||
|
--shift_bits_remaining_;
|
||||||
|
if(!shift_bits_remaining_) {
|
||||||
|
registers_.interrupt_flags |= InterruptFlag::ShiftRegister;
|
||||||
|
reevaluate_interrupts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void MOS6522<T>::shift_out() {
|
template <typename T> void MOS6522<T>::shift_out() {
|
||||||
set_control_line_output(Port::B, Line::Two, registers_.shift & 0x80);
|
set_control_line_output(Port::B, Line::Two, registers_.shift & 0x80);
|
||||||
registers_.shift <<= 1;
|
registers_.shift <<= 1;
|
||||||
|
--shift_bits_remaining_;
|
||||||
|
if(!shift_bits_remaining_) {
|
||||||
|
registers_.interrupt_flags |= InterruptFlag::ShiftRegister;
|
||||||
|
reevaluate_interrupts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ class MOS6522Storage {
|
|||||||
|
|
||||||
bool timer_is_running_[2] = {false, false};
|
bool timer_is_running_[2] = {false, false};
|
||||||
bool last_posted_interrupt_status_ = false;
|
bool last_posted_interrupt_status_ = false;
|
||||||
|
int shift_bits_remaining_ = 8;
|
||||||
|
|
||||||
enum InterruptFlag: uint8_t {
|
enum InterruptFlag: uint8_t {
|
||||||
CA2ActiveEdge = 1 << 0,
|
CA2ActiveEdge = 1 << 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user