gbdev / gbdev/rgbds

[Feature request] Discontiguous "regions" of tileset and palette space

Open
#1,886 3 comments 0 reactions 0 assignees View on GitHub
enhancement rgbgfx
Dominant language
C++
Stars
1.6k
Forks
193
Avg merge
22h 17m
Merged PRs (30d)
26

Description

RGBGFX currently lets you control tile and palette output by specifying a base/starting ID and a maximum number of IDs:

- **Tiles:** `-b/--base-tiles B₀,B₁` and `-N/--nb-tiles N₀,N₁`
This places tiles in bank 0 with the IDs *B*₀, *B*₀+1, *B*₀+2, ...*B*₀+*N*₀−1; then continues in bank 1 with the IDs *B₁*, *B₁*+1, *B₁*+2, ...*B*₁+*N*₁−1; for a max total of *N*₀+*N*₁ tiles.
- **Palettes:** `-l/--base-palette B` and `-n/--nb-palettes N`
This places palettes with the IDs *B*, *B*+1, *B*+2, ...*B*+*N*−1; for a max total of *N* palettes.

This is sufficient *if* your output needs to take up one contiguous region (or for tiles, one contiguous region per bank).

However, there are cases where you'd want to use multiple discontiguous regions. For example, I want to start my tile output in $1:00-7E, continue in $1:80-FE, and continue further in $0:00-7E, but skip tiles $1:7F and $1:FF. Or maybe I'd want to use all of VRAM1 except $1:60-7F (let's say those $20 are font tiles instead of my tilemapped rgbgfx-generated graphic). Sometimes I can use the existing options to hackily fake this, if I can pretend that two discontiguous regions are two different banks (as long as I can ignore or postprocess-correct the attribute data). But three or more is just not possible. All of that also applies to palettes, e.g. if I've reserved palettes 3 and 7 for some purpose, but can freely generate into 0-2 and 4-6.

**Proposal:** add two new flags to specify a sequence of "regions":

- **Tiles:** `-R/--tile-regions "B₀:P₀-Q₀, B₁:P₁-Q₁, ..."`
This places tiles in bank *B*₀ with the IDs *P*₀, *P*₀+1, *P*₀+2, ...*Q*₀; then continues in bank *B*₁ with the IDs *P*₁, *P*₁+1, *P*₁+2, ...*Q*₁; and so on for each region, for a max total of (*Q*₀−*P*₀+1 + *Q*₁−*P*₁+1 + ...) tiles.
- **Palettes:** `-S/--palette-regions "P₀-Q₀, P₁-Q₁, ..."`
This places palettes with the IDs *P*₀, *P*₀+1, *P*₀+2, ...*Q*₀; then continues with the IDs *P*₁, *P*₁+1, *P*₁+2, ...*Q*₁; and so on for each region, for a max total of (*Q*₀−*P*₀+1 + *Q*₁−*P*₁+1 + ...) palettes.
- Regions with a single tile/palette, like `X-X`, could be abbreviated as `X` without a hyphen.

I imagine this could be implemented by calculating the max total number of tiles/palettes, and allocating them from 0 to that quantity; then remapping into the discontiguous IDs just before output.

There was already some discussion of this proposal [on GBDev's Discord](https://discord.com/channels/303217943234215948/870005582042628196/1463589629335834756), after my [motivating use case](https://discord.com/channels/303217943234215948/870005582042628196/1463573938096308327).

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests; start by locating RGBGFX's handling of --base-tiles, --nb-tiles, --base-palette, and --nb-palettes. Trace how those options determine output IDs, then define how the proposed region flags and abbreviated single-ID regions should behave. Done means discontiguous tile and palette regions are accepted and output allocation follows their declared order.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.