From ce8bd011d702dbce6bbcf111cfe02d84ba317630 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 18 May 2023 16:50:46 -0400 Subject: [PATCH] Add commentary, and TODOs. --- Components/9918/Implementation/9918.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 34af6a73b..7011e3681 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -35,12 +35,16 @@ Base::Base() : // "For a line interrupt, /INT is pulled low 608 mclks into the appropriate scanline relative to pixel 0. // This is 3 mclks before the rising edge of /HSYNC which starts the next scanline." + // + // i.e. it's 304 internal clocks after the end of the left border. mode_timing_.line_interrupt_position = (LineLayout::EndOfLeftBorder + 304) % LineLayout::CyclesPerLine; // For a frame interrupt, /INT is pulled low 607 mclks into scanline 192 (of scanlines 0 through 261) relative to pixel 0. // This is 4 mclks before the rising edge of /HSYNC which starts the next scanline. + // + // i.e. it's 1/2 cycle before the line interrupt position, which I have rounded. Ugh. mode_timing_.end_of_frame_interrupt_position.column = mode_timing_.line_interrupt_position - 1; - mode_timing_.end_of_frame_interrupt_position.row = 193; + mode_timing_.end_of_frame_interrupt_position.row = 192 + (LineLayout::EndOfLeftBorder + 304) / LineLayout::CyclesPerLine; } if constexpr (is_yamaha_vdp(personality)) { @@ -81,6 +85,7 @@ TMS9918::TMS9918() { template void TMS9918::set_tv_standard(TVStandard standard) { + // TODO: the Yamaha is programmable on this at runtime. this->tv_standard_ = standard; switch(standard) { case TVStandard::PAL: @@ -214,8 +219,10 @@ void TMS9918::run_for(const HalfCycles cycles) { // --------------------------------------- // Latch scrolling position, if necessary. // --------------------------------------- + // TODO: shouldn't this happen one per frame? if constexpr (is_sega_vdp(personality)) { - if(this->fetch_pointer_.column < 61 && end_column >= 61) { + constexpr auto latch_time = to_internal(61); // TODO: where did this magic constant come from? Is it the same for the Game Gear, etc? + if(this->fetch_pointer_.column < latch_time && end_column >= latch_time) { if(!this->fetch_pointer_.row) { Storage::latched_vertical_scroll_ = Storage::vertical_scroll_;