@@ -21,10 +21,7 @@ static constexpr bool matteMF(const uint32_t matteCommand) noexcept
2121 * Every array member with 2 elements means its meant to be index based on the plane number \ref ImagePlane.
2222 *
2323 * TODO:
24- * - Should the renderer manage the line count and draw itself the final frame and the cursor when reached,
25- * or let it to the user of the renderer with a `Plane RenderFrame();` method ?
2624 * - V.25/V.26 Pixel repeat on pixel decoding, pixel hold on overlay.
27- * - Implement cursor blink.
2825 * - Should there be a reset method?
2926 *
3027 * TODO optimizations:
@@ -80,8 +77,9 @@ class Renderer
8077 Renderer& operator =(Renderer&&) = delete ;
8178
8279 constexpr DisplayFormat GetDisplayFormat () const noexcept { return m_displayFormat; }
83- void SetDisplayFormat (DisplayFormat display, bool highResolution) noexcept ;
80+ void SetDisplayFormat (DisplayFormat display, bool highResolution, bool fps60 ) noexcept ;
8481 static bool isValidDisplayFormat (DisplayFormat display) noexcept ;
82+
8583 static constexpr uint16_t getDisplayWidth (DisplayFormat display) noexcept
8684 {
8785 return display == DisplayFormat::NTSCMonitor ? 360 : 384 ;
@@ -103,6 +101,7 @@ class Renderer
103101 return m_screen.m_width == 720 ;
104102 }
105103
104+ void IncrementCursorTime (double ns) noexcept ;
106105 virtual std::pair<uint16_t , uint16_t > DrawLine (const uint8_t * lineA, const uint8_t * lineB, uint16_t lineNumber) noexcept = 0;
107106 const Plane& RenderFrame () noexcept ;
108107
@@ -155,7 +154,7 @@ class Renderer
155154 uint8_t m_cursorColor : 4 {}; /* *< YRGB color code. */
156155 std::array<uint16_t , 16 > m_cursorPatterns{};
157156 bool m_cursorBlinkType{}; /* *< false is on/off, true is on/complement. */
158- uint8_t m_cursorBlinkOn : 3 {}; /* *< ON period (zero not allowed). */
157+ uint8_t m_cursorBlinkOn : 3 {1 }; /* *< ON period (zero not allowed). */
159158 uint8_t m_cursorBlinkOff : 3 {}; /* *< OFF period (if zero, blink is disabled). */
160159
161160 // Image Contribution Factor.
@@ -229,9 +228,16 @@ class Renderer
229228 };
230229
231230protected:
231+ static constexpr double DELTA_50FPS = 240'000'000 .; /* *< GB VII.2.3.4.2 GC_Blnk. */
232+ static constexpr double DELTA_60FPS = 200'000'000 .; /* *< GB VII.2.3.4.2 GC_Blnk. */
233+
234+ double m_cursorTime{0.0 }; /* *< Keeps track of the emulated time for cursor blink. */
235+ bool m_cursorIsOn{true }; /* *< Keeps the state of the cursor (ON or OFF/complement). true when ON. */
236+
232237 uint16_t m_lineNumber{}; /* *< Current line being drawn, starts at 0. Handled by the caller. */
233238 DisplayFormat m_displayFormat{DisplayFormat::PAL}; /* *< Used to select 360/384 width and 240/280 height. */
234239 bool m_highResolution{false }; /* *< True for 480/560, false for 240/280 pixels height. */
240+ bool m_60FPS{false }; /* *< False for 50FPS, true for 60FPS. */
235241
236242 virtual void DrawCursor () noexcept = 0;
237243 void DrawLineBackdrop () noexcept
0 commit comments