tables
Tool
tools/triage/tables.py(program, Triage). Find the sine and cosine tables in a binary or a data file, and say exactly how each was made: its length, its scale, its number type and how it was rounded.
Run it with ./gameframe run tables ARGS or python3 tools/triage/tables.py. Source on GitHub.
Its own help
This is the help text in the tool itself, as ./gameframe tool tables prints it.
text
Find the sine and cosine tables in a binary or a data file, and say exactly how each was
made: its length, its scale, its number type and how it was rounded.
Usage: tables.py FILE [FILE ...] [--json]
Games of the 1980s and 1990s rarely called sin() at run time. They kept a table: 256 or 1024
steps round the circle (sometimes 360, or a quarter circle), scaled to a fixed-point range such
as 127, 256, 16384 or 65536, stored as bytes, 16-bit or 32-bit integers, or floats. A port must
use the same table, entry for entry, or every rotation, wave and trajectory drifts. This tool
builds candidate tables for the common shapes and searches for their first entries. Each hit
names the shape, the address and how many entries match the formula. Where the rounding is
unusual, the entries that differ are listed: then copy the table from the binary
(tools/pe/readdata.py) instead of computing it.
The search covers sine and cosine with these choices:
steps 64, 128, 256, 360, 512, 1024, 2048, 4096, 8192, 16384 per circle
scale the value at 90 degrees: 63, 64, 127, 128, 255, 256, 1023, 1024, 4095, 4096,
16383, 16384, 32767, 32768, 65535, 65536 (and 1.0 for floats)
type signed 8-bit, 16-bit and 32-bit integers, little-endian and big-endian; 32-bit
and 64-bit floats
rounding to nearest, and toward zero (truncation)
Standard library only.Named by
Skills: re-trace.