Skip to content

Conversation

@bobtista
Copy link

@bobtista bobtista commented Jan 4, 2026

Summary

  • Credits screen scrolling now uses frame delta time instead of frame counting
  • Credits scroll at consistent speed regardless of frame rate
  • Credits won't jump ahead when tabbing out and back in

Changes

  • Replaced m_framesSinceStarted frame counter with m_scrollAccumulator for fractional pixel tracking
  • Uses TheFramePacer->getUpdateTime() for frame-rate independent timing
  • Accumulates fractional scroll progress and moves whole pixels when accumulator >= 1

Test plan

  • Verify credits scroll at the same speed at 30fps and higher frame rates
  • Verify credits still scroll smoothly without stuttering
  • Verify credits don't jump ahead after tabbing out and back in

30FPS
https://github.com/user-attachments/assets/0215fd82-49f7-4c7c-9903-c8b0f53eb239

60FPS
https://github.com/user-attachments/assets/a45a847b-1f9d-4642-8ab3-23e30de25c04

@bobtista bobtista force-pushed the bobtista/fix-credits-scroll-timing branch 2 times, most recently from aa81f5a to 7fa2519 Compare January 4, 2026 06:21
@bobtista bobtista force-pushed the bobtista/fix-credits-scroll-timing branch from 5a98add to 7d49889 Compare January 30, 2026 03:14
@greptile-apps
Copy link

greptile-apps bot commented Jan 30, 2026

Greptile Overview

Greptile Summary

Replaced frame-based credits scrolling with time-based scrolling using TheFramePacer->getUpdateTime() for frame-rate independence. The new implementation accumulates fractional pixels per frame and scrolls only when at least 1 whole pixel has accumulated, preserving smooth scrolling across different frame rates. Changes are mirrored across both Generals and GeneralsMD codebases.

Key changes:

  • Replaced Int m_framesSinceStarted with Real m_scrollAccumulator to track fractional pixel accumulation
  • Added Common/FramePacer.h include for delta time access
  • Converted frame-based scroll rate to pixels-per-second using SECONDS_PER_LOGICFRAME_REAL
  • Scroll logic now accumulates time-weighted pixels and moves by integer amounts
  • Clear, informative inline comments explain the accumulator approach

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • Clean refactoring that correctly converts frame-based timing to time-based timing. The math is sound, implementation is identical across both codebases, includes appropriate comments, and has been tested at multiple frame rates per the test plan
  • No files require special attention

Sequence Diagram

sequenceDiagram
    participant Game as Game Loop
    participant Credits as CreditsManager::update()
    participant FramePacer as TheFramePacer
    participant Display as Credits Display

    Game->>Credits: Call update()
    Credits->>Credits: Check if finished
    alt Not finished
        Credits->>FramePacer: getUpdateTime()
        FramePacer-->>Credits: deltaTime (seconds)
        Credits->>Credits: Calculate scrollSpeedPixelsPerSec<br/>=scrollRate/(scrollRatePerFrames*SECONDS_PER_LOGICFRAME_REAL)
        Credits->>Credits: Accumulate: m_scrollAccumulator += deltaTime * scrollSpeedPixelsPerSec
        Credits->>Credits: Cast to Int: pixelsToMove = (Int)m_scrollAccumulator
        alt pixelsToMove >= 1
            Credits->>Credits: Subtract moved pixels: m_scrollAccumulator -= pixelsToMove
            Credits->>Display: Update all credit line positions by pixelsToMove
            Credits->>Display: Remove lines that scrolled off-screen
            Credits->>Display: Add new lines if needed
        else pixelsToMove < 1
            Credits-->>Game: Return (skip this frame)
        end
    else Finished
        Credits-->>Game: Return immediately
    end
Loading

@xezon xezon added GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Enhancement Is new feature or request labels Jan 30, 2026
@xezon
Copy link

xezon commented Jan 30, 2026

Is the Pull Description up-to-date?

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. Did not test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants