SpriteLayer::SetOpacity(1.0) writes ratio -1

Open Beginner friendly
#151 0 comments 0 reactions 1 assignee View on GitHub

@seven-shades is already working on this.

Since Nov 17, 2026.

Assessment

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

Research direction

Start at srl_vdp2.hpp lines 1854-1860, the SetOpacity conversion of 0.0-1.0 into hardware blend ratios; trace how the shift result is computed and why 1.0 yields 32 before the subtraction. Read SGL's definition of VDP2_CCRSA to confirm the register allows 0-31. Clamp the ratio to 31, then add a test calling SetOpacity(1.0), (0.5) and (0.0) and reading back VDP2_CCRSA; done when the values stay in range and the suite passes.

Written by the indexing model from the issue text.

Description

bug required hardware test

(saturnringlib/srl_vdp2.hpp:1854-1860)

  • What this is: It turns an opacity from 0.0 to 1.0 into one of the 32 hardware blend ratios (0 to 31).
    • Problem: 1.0 is accepted, and 31 - (0x10000 >> 11) is 31 - 32 = -1, which becomes 0xFFFF as a 16-bit value. The largest opacity gives a value outside the register's range.
    • Fix: Clamp the shift result to 31 before subtracting. Add a test that reads SGL's copy VDP2_CCRSA after SetOpacity(1.0), SetOpacity(0.5) and SetOpacity(0.0).
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.