mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-17 10:30:31 +00:00
Merge pull request #173 from TomHarte/TimingFixes
Corrects two misimplementations of the CPC's interrupt counter
This commit is contained in:
commit
c2bb019381
@ -106,7 +106,8 @@ template <class T> class CRTC6845 {
|
|||||||
// check for start of vertical sync
|
// check for start of vertical sync
|
||||||
if(line_counter_ == registers_[7]) {
|
if(line_counter_ == registers_[7]) {
|
||||||
bus_state_.vsync = true;
|
bus_state_.vsync = true;
|
||||||
vsync_down_counter_ = 16; // TODO
|
vsync_down_counter_ = registers_[3] >> 4;
|
||||||
|
if(!vsync_down_counter_) vsync_down_counter_ = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for entry into the overflow area
|
// check for entry into the overflow area
|
||||||
|
@ -30,9 +30,9 @@ class InterruptTimer {
|
|||||||
InterruptTimer() : timer_(0), interrupt_request_(false) {}
|
InterruptTimer() : timer_(0), interrupt_request_(false) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Indicates that a new hsync pulse has been recognised. Per documentation
|
Indicates that a new hsync pulse has been recognised. This should be
|
||||||
difficulties, it is not presently clear to me whether this should be
|
supplied on the falling edge of the CRTC HSYNC signal, which is the
|
||||||
the leading or trailing edge of horizontal sync.
|
trailing edge because it is active high.
|
||||||
*/
|
*/
|
||||||
inline void signal_hsync() {
|
inline void signal_hsync() {
|
||||||
// Increment the timer and if it has hit 52 then reset it and
|
// Increment the timer and if it has hit 52 then reset it and
|
||||||
@ -49,7 +49,7 @@ class InterruptTimer {
|
|||||||
if(reset_counter_) {
|
if(reset_counter_) {
|
||||||
reset_counter_--;
|
reset_counter_--;
|
||||||
if(!reset_counter_) {
|
if(!reset_counter_) {
|
||||||
if(timer_ < 32) {
|
if(timer_ & 32) {
|
||||||
interrupt_request_ = true;
|
interrupt_request_ = true;
|
||||||
}
|
}
|
||||||
timer_ = 0;
|
timer_ = 0;
|
||||||
@ -76,6 +76,7 @@ class InterruptTimer {
|
|||||||
/// Resets the timer.
|
/// Resets the timer.
|
||||||
inline void reset_count() {
|
inline void reset_count() {
|
||||||
timer_ = 0;
|
timer_ = 0;
|
||||||
|
interrupt_request_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -504,8 +505,8 @@ class ConcreteMachine:
|
|||||||
// will do as it's safe to conclude that nobody else has touched video RAM
|
// will do as it's safe to conclude that nobody else has touched video RAM
|
||||||
// during that whole window
|
// during that whole window
|
||||||
crtc_counter_ += cycle.length;
|
crtc_counter_ += cycle.length;
|
||||||
int crtc_cycles = crtc_counter_.divide(HalfCycles(8)).as_int();
|
Cycles crtc_cycles = crtc_counter_.divide_cycles(Cycles(4));
|
||||||
if(crtc_cycles) crtc_.run_for(Cycles(1));
|
if(crtc_cycles > Cycles(0)) crtc_.run_for(crtc_cycles);
|
||||||
z80_.set_interrupt_line(interrupt_timer_.get_request());
|
z80_.set_interrupt_line(interrupt_timer_.get_request());
|
||||||
|
|
||||||
// TODO (in the player, not here): adapt it to accept an input clock rate and
|
// TODO (in the player, not here): adapt it to accept an input clock rate and
|
||||||
@ -541,7 +542,7 @@ class ConcreteMachine:
|
|||||||
read_pointers_[3] = (*cycle.value & 8) ? &ram_[49152] : basic_.data();
|
read_pointers_[3] = (*cycle.value & 8) ? &ram_[49152] : basic_.data();
|
||||||
|
|
||||||
// Reset the interrupt timer if requested.
|
// Reset the interrupt timer if requested.
|
||||||
if(*cycle.value & 15) interrupt_timer_.reset_count();
|
if(*cycle.value & 0x10) interrupt_timer_.reset_count();
|
||||||
|
|
||||||
// Post the next mode.
|
// Post the next mode.
|
||||||
crtc_bus_handler_.set_next_mode(*cycle.value & 3);
|
crtc_bus_handler_.set_next_mode(*cycle.value & 3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user