1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

Make VRAM access delay a timing property.

This commit is contained in:
Thomas Harte 2023-01-07 12:48:43 -05:00
parent f9e21df701
commit 5d2d3944ef
3 changed files with 6 additions and 12 deletions

View File

@ -22,16 +22,6 @@ namespace {
constexpr unsigned int CRTCyclesPerLine = 1365;
constexpr unsigned int CRTCyclesDivider = 4;
template <Personality personality> constexpr int vram_access_delay() {
// This seems to be correct for all currently-modelled VDPs;
// it's the delay between an external device scheduling a
// read or write and the very first time that can occur
// (though, in practice, it won't happen until the next
// external slot after this number of cycles after the
// device has requested the read or write).
return 6;
}
}
template <Personality personality>
@ -500,7 +490,7 @@ void TMS9918<personality>::write(int address, uint8_t value) {
// Enqueue the write to occur at the next available slot.
this->read_ahead_buffer_ = value;
this->queued_access_ = MemoryAccess::Write;
this->cycles_until_access_ = vram_access_delay<personality>();
this->cycles_until_access_ = Timing<personality>::VRAMAccessDelay;
return;
}
@ -615,7 +605,7 @@ void TMS9918<personality>::write(int address, uint8_t value) {
// A read request is enqueued upon setting the address; conversely a write
// won't be enqueued unless and until some actual data is supplied.
this->queued_access_ = MemoryAccess::Read;
this->cycles_until_access_ = vram_access_delay<personality>();
this->cycles_until_access_ = Timing<personality>::VRAMAccessDelay;
}
this->master_system_.cram_is_selected = false;
}

View File

@ -21,16 +21,19 @@ template <Personality, typename Enable = void> struct Timing {};
template <Personality personality>
struct Timing<personality, std::enable_if_t<is_yamaha_vdp(personality)>> {
constexpr static int CyclesPerLine = 1368;
constexpr static int VRAMAccessDelay = 6;
};
template <Personality personality>
struct Timing<personality, std::enable_if_t<is_classic_vdp(personality)>> {
constexpr static int CyclesPerLine = 342;
constexpr static int VRAMAccessDelay = 6;
};
template <>
struct Timing<Personality::MDVDP> {
constexpr static int CyclesPerLine = 3420;
constexpr static int VRAMAccessDelay = 6;
};
constexpr int TMSAccessWindowsPerLine = 171;

View File

@ -21,6 +21,7 @@ constexpr bool is_yamaha_vdp(Personality p) {
return p == Personality::V9938 || p == Personality::V9958;
}
// i.e. one with the original internal timings.
constexpr bool is_classic_vdp(Personality p) {
return
p == Personality::TMS9918A ||