The timer's NTSC and PAL clock speeds are swapped

Open Beginner friendly
#155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp

Research direction

Start with the timer's two #ifdef branches and Tests/src/testsTimer.hpp, especially timer_from_seconds_builder around line 707. Verify the NTSC 60-frame duration against Mednafen, then add a Capture() test asserting 1000–1006 ms and correct the test comment. Done means the clock values and test expectation match the stated hardware timings.

Written by the indexing model from the issue text.

Description

bug good first issue
  • What this is: The timer turns hardware ticks into seconds and milliseconds, using the CPU clock of the console's region.
    • Problem: The library treats NTSC as 26.6875 / 28.4375 MHz and PAL as 26.8741 / 28.6364 MHz. Mednafen's source has them the other way round: NTSC is 1746818182 / 65 = 26.8741 MHz, and PAL is 26.6875 MHz. So every time value is 0.7% off on both regions. A 10-minute countdown ends about 4 seconds early on NTSC.
    • Why the tests missed it: The comment at the top of Tests/src/testsTimer.hpp copies the same wrong numbers. timer_from_seconds_builder (line 707) only checks that High is 3 or 4, which is a ±33% window. Both were written from the code, not from the hardware.
    • Fix: Swap the two #ifdef branches (4 lines) and fix the test comment. Add one test that measures 60 frames with Capture(). On NTSC, one frame is 427 dots × 263 lines × 4 CPU clocks, so 60 frames is about 1003 ms; the swapped constants give about 1010 ms. Assert 1000–1006 ms. Check the expected value in mednafen first.
Dominant language
C++
Stars
90
Forks
5
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ReyeMe/SaturnRingLib

All issues in ReyeMe/SaturnRingLib

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.