1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-11 08:30:55 +00:00

Expand fixed timing constants.

This commit is contained in:
Thomas Harte 2023-01-07 13:10:51 -05:00
parent 5d2d3944ef
commit 56831e02fc
3 changed files with 29 additions and 9 deletions

View File

@ -269,14 +269,14 @@ void TMS9918<personality>::run_for(const HalfCycles cycles) {
this->set_current_screen_mode();
// Based on the output mode, pick a line mode.
next_line_buffer.first_pixel_output_column = 86; // TODO: these should be a function of Timing<personality>
next_line_buffer.next_border_column = 342;
next_line_buffer.first_pixel_output_column = Timing<personality>::FirstPixelCycle;
next_line_buffer.next_border_column = Timing<personality>::CyclesPerLine;
this->mode_timing_.maximum_visible_sprites = 4;
switch(this->screen_mode_) {
case ScreenMode::Text:
next_line_buffer.line_mode = LineMode::Text;
next_line_buffer.first_pixel_output_column = 94;
next_line_buffer.next_border_column = 334;
next_line_buffer.first_pixel_output_column = Timing<personality>::FirstTextCycle;
next_line_buffer.next_border_column = Timing<personality>::LastTextCycle;
break;
case ScreenMode::SMSMode4:
next_line_buffer.line_mode = LineMode::SMS;

View File

@ -214,7 +214,7 @@ template <Personality personality> struct Base {
// Internal mechanisms for position tracking.
int latched_column_ = 0;
// A struct to contain timing information for the current mode.
// A struct to contain timing information that is a function of the current mode.
struct {
/*
Vertical layout:

View File

@ -19,21 +19,41 @@ namespace TMS {
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;
struct Timing<personality, std::enable_if_t<is_classic_vdp(personality)>> {
/// The total number of internal cycles per line of output.
constexpr static int CyclesPerLine = 342;
/// The number of internal cycles that must elapse between a request to read or write and
/// it becoming a candidate for action.
constexpr static int VRAMAccessDelay = 6;
/// The first internal cycle at which pixels will be output in any mode other than text.
/// Pixels implicitly run from here to the end of the line.
constexpr static int FirstPixelCycle = 86;
/// The first internal cycle at which pixels will be output text mode.
constexpr static int FirstTextCycle = 94;
/// The final internal cycle at which pixels will be output text mode.
constexpr static int LastTextCycle = 334;
};
template <Personality personality>
struct Timing<personality, std::enable_if_t<is_classic_vdp(personality)>> {
constexpr static int CyclesPerLine = 342;
struct Timing<personality, std::enable_if_t<is_yamaha_vdp(personality)>> {
constexpr static int CyclesPerLine = 1368;
constexpr static int VRAMAccessDelay = 6;
constexpr static int FirstPixelCycle = 344;
constexpr static int FirstTextCycle = 376;
constexpr static int LastTextCycle = 1336;
};
template <>
struct Timing<Personality::MDVDP> {
constexpr static int CyclesPerLine = 3420;
constexpr static int VRAMAccessDelay = 6;
constexpr static int FirstPixelCycle = 860;
constexpr static int FirstTextCycle = 940;
constexpr static int LastTextCycle = 3340;
};
constexpr int TMSAccessWindowsPerLine = 171;