128- and 64-color palettes can share color memory with other palettes (saturnringlib/srl_cram.hpp:173-264)

Open Beginner friendly
#147 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

The bug sits in saturnringlib/srl_cram.hpp, lines 173-264, in GetBankUsedState, SetBankUsedState and GetFreeBank. Check the 128-color and 64-color shift expressions against the 16-color block indexing, then make GetFreeBank call GetBankUsedState instead of repeating the masks. Done when allocating a 16-color palette followed by a 128-color palette marks blocks 2-9, and the next 16-color allocation skips them.

Written by the indexing model from the issue text.

Description

bug required hardware test
  • What this is: CRAM (color RAM, where palettes live) is tracked with a bit mask, one bit per 16-color block.
    • Problem: The bit shift is wrong. A 128-color bank uses (bank&1)<<1 where it needs <<3, and a 64-color bank uses (bank&2)<<2 where it needs (bank&3)<<2. Example: allocate one 16-color palette (bank 0), then a 128-color palette. The 128-color palette lands at colors 128–255 but only marks blocks 2–9 as used. The next 16-color palette can then get block 10, which sits inside the 128-color palette.
    • Fix: Correct the two shifts in GetBankUsedState and SetBankUsedState. Make GetFreeBank call GetBankUsedState instead of repeating the masks, since the copied masks are where the bug lives.
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.