Skip to content

shadetable ​

Tool tools/formats/shadetable.py (program, Formats). Read a shade, fog or remap table of a palette game: for each level, the colour that each palette colour turns into.

Run it with ./gameframe run shadetable ARGS or python3 tools/formats/shadetable.py. Source on GitHub.

Its own help ​

This is the help text in the tool itself, as ./gameframe tool shadetable prints it.

text
Read a shade, fog or remap table of a palette game: for each level, the colour that each
palette colour turns into. Says which level is black, which leaves every colour unchanged,
which is white, and what colour the levels fade toward.

Usage: shadetable.py FILE --palette PAL [--offset N] [--levels N] [--colours N]
                     [--layout level|colour] [--palette-offset N] [--dac shift|scale]
                     [--png OUT.png] [--json]

  FILE          the file that holds the table (a remap file, the executable, a memory dump)
  --palette     the palette the table belongs to: 768 bytes of RGB, 6-bit or 8-bit, or a JASC
                .pal; --palette-offset N reads it from inside a bigger file (after a header)
  --offset N    where the table starts in FILE (default 0)
  --levels N    the number of levels (default 64; 32 and 16 are common too)
  --colours N   the colours per level (default 256)
  --layout      level: one row of N colours per level, table[level * colours + colour], the
                way most renderers look it up. colour: one run of levels per colour,
                table[colour * levels + level], the way some files store it. Default: the
                one that has a level leaving every colour as it is, else level
  --dac         how 6-bit palette values become 8 bits (rawimage.py --dac)
  --png OUT     a picture of the table: one row per level, one column per colour, each in the
                colour it maps to, 4 pixels wide (look at it: a fade to black or to a haze
                colour is obvious)
  --json        the measurements per level

A game with 256 colours cannot multiply a colour by a light value. It looks the answer up in
a table instead: row `level`, column `colour`. The renderer turns an intensity into a level
with a shift, so a 2.14 light of 0x4000 becomes level 32 with `>> 9`. Knowing which level
leaves colours unchanged tells you the intensity the game treats as normal light, and so how
the lighting code's numbers map to what is drawn (docs/hardware/software-rendering.md).

For each level the tool reports how many colours map to themselves, how bright the result is
compared with the input (measured on the palette's luminance), and, when most colours move
toward one colour, that colour: fog and haze tables fade toward the fog's colour, light
tables toward black or white. It does not find the table in a file: give its offset (the code
that loads it, re-trace) or try candidate offsets. Standard library only.

Named by ​

Skills: re-format.

Code: Apache 2.0. Content: CC0 1.0. No game material: bring your own copy.