mirror of
https://github.com/TomHarte/CLK.git
synced 2024-09-08 18:55:14 +00:00
Merge pull request #916 from TomHarte/OffByOne
Corrects off-by-one timing errors in the ZX Spectrum.
This commit is contained in:
commit
76370d9418
@ -98,7 +98,7 @@ template <VideoTiming timing> class Video {
|
|||||||
.contention_duration = 129 * 2,
|
.contention_duration = 129 * 2,
|
||||||
|
|
||||||
// i.e. interrupt is first signalled 14368 cycles before the first video fetch.
|
// i.e. interrupt is first signalled 14368 cycles before the first video fetch.
|
||||||
.interrupt_time = (228*311 - 14360) * 2,
|
.interrupt_time = (1 + 228*311 - 14365 - 5) * 2,
|
||||||
|
|
||||||
.delays = { // Should start at 14365
|
.delays = { // Should start at 14365
|
||||||
2, 1,
|
2, 1,
|
||||||
@ -123,7 +123,7 @@ template <VideoTiming timing> class Video {
|
|||||||
.contention_leadin = 4 * 2,
|
.contention_leadin = 4 * 2,
|
||||||
.contention_duration = 128 * 2,
|
.contention_duration = 128 * 2,
|
||||||
|
|
||||||
.interrupt_time = (228*311 - 14357) * 2,
|
.interrupt_time = (1 + 228*311 - 14361 - 4) * 2,
|
||||||
|
|
||||||
.delays = { // Should start at 14361.
|
.delays = { // Should start at 14361.
|
||||||
12, 11,
|
12, 11,
|
||||||
@ -148,7 +148,7 @@ template <VideoTiming timing> class Video {
|
|||||||
.contention_leadin = 4 * 2,
|
.contention_leadin = 4 * 2,
|
||||||
.contention_duration = 128 * 2,
|
.contention_duration = 128 * 2,
|
||||||
|
|
||||||
.interrupt_time = (224*312 - 14331) * 2,
|
.interrupt_time = (1 + 224*312 - 14335 - 4) * 2,
|
||||||
|
|
||||||
.delays = { // Should start at 14335.
|
.delays = { // Should start at 14335.
|
||||||
12, 11,
|
12, 11,
|
||||||
|
@ -245,7 +245,7 @@ template<Model model> class ConcreteMachine:
|
|||||||
// always occurs if it is in the $4000–$8000 range regardless of current
|
// always occurs if it is in the $4000–$8000 range regardless of current
|
||||||
// memory mapping.
|
// memory mapping.
|
||||||
HalfCycles delay;
|
HalfCycles delay;
|
||||||
HalfCycles time = video_.time_since_flush() + HalfCycles(1);
|
HalfCycles time = video_.time_since_flush();
|
||||||
|
|
||||||
if((address & 0xc000) == 0x4000) {
|
if((address & 0xc000) == 0x4000) {
|
||||||
for(int c = 0; c < ((address & 1) ? 4 : 2); c++) {
|
for(int c = 0; c < ((address & 1) ? 4 : 2); c++) {
|
||||||
@ -269,7 +269,7 @@ template<Model model> class ConcreteMachine:
|
|||||||
// These all start by loading the address bus, then set MREQ
|
// These all start by loading the address bus, then set MREQ
|
||||||
// half a cycle later.
|
// half a cycle later.
|
||||||
if(is_contended_[address >> 14]) {
|
if(is_contended_[address >> 14]) {
|
||||||
const HalfCycles delay = video_.last_valid()->access_delay(video_.time_since_flush() + HalfCycles(1));
|
const HalfCycles delay = video_.last_valid()->access_delay(video_.time_since_flush());
|
||||||
|
|
||||||
advance(cycle.length + delay);
|
advance(cycle.length + delay);
|
||||||
return delay;
|
return delay;
|
||||||
@ -284,7 +284,7 @@ template<Model model> class ConcreteMachine:
|
|||||||
const auto half_cycles = cycle.length.as<int>();
|
const auto half_cycles = cycle.length.as<int>();
|
||||||
assert(!(half_cycles & 1));
|
assert(!(half_cycles & 1));
|
||||||
|
|
||||||
HalfCycles time = video_.time_since_flush() + HalfCycles(1);
|
HalfCycles time = video_.time_since_flush();
|
||||||
HalfCycles delay;
|
HalfCycles delay;
|
||||||
for(int c = 0; c < half_cycles; c += 2) {
|
for(int c = 0; c < half_cycles; c += 2) {
|
||||||
const auto next_delay = video_.last_valid()->access_delay(time);
|
const auto next_delay = video_.last_valid()->access_delay(time);
|
||||||
|
Loading…
Reference in New Issue
Block a user