# Build ART fixtures (tools/fixtures.py). No Duke 3D data (proprietary): a random PALETTE.DAT (256 distinct 6-bit # colours, 32 shade tables, a translucency table) and LOOKUP.DAT (palookups 1 and 5, five alternate palettes) are # made here. References, from the nix eduke32 source (tools/fixtures/_build_ref.py): # - arttool create / addtile builds TILES000.ART (tiles 10..15, two of them empty) from 8-bit PCX files written # here, with centre offsets and animation fields; `arttool info` gives the per-tile fields; # - arttool exporttile writes each tile back as PCX through palette.dat (<< 2 scaling): its RGB is the reference; # - an independent Python reading of the ART bytes (BUILDINF.TXT layout) gives each tile's column-major indices. # tests/gen/art.luau { art, palette, lookup, start, last, tiles = { { tile, w, h, idx, rgb, xofs, yofs, animType, # animFrames, animSpeed, picanm } }, shade = { n, table }, remap = { pal, table } } import os, shutil, struct, subprocess, tempfile, importlib.util _spec = importlib.util.spec_from_file_location("_build_ref", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_build_ref.py")) B = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(B) INPUTS = ["tools/fixtures/_build_ref.py"] def palette_dat(rng): cols, seen = [], set() while len(cols) < 256: c = (rng.randrange(64), rng.randrange(64), rng.randrange(64)) if c not in seen: seen.add(c) cols.append(c) pal = bytes(v for c in cols for v in c) shades = rng.randbytes(32 * 256) return pal + struct.pack(" 0: idx = bytes(cols[x * h + y] for y in range(h) for x in range(w)) assert idx == made[t] run("exporttile", str(t)) pw, ph, pidx, ppal = B.pcx_read(open(os.path.join(tmp, "tile%04d.pcx" % t), "rb").read()) assert (pw, ph, pidx) == (w, h, idx) e["idx"] = idx e["rgb"] = bytes(ppal[v * 3 + k] for v in pidx for k in range(3)) tiles.append(e) finally: shutil.rmtree(tmp) ctx.emit("art", { "art": art, "palette": pal_dat, "lookup": lookup, "start": first, "last": last, "tiles": tiles, "shade": {"n": 7, "table": pal_dat[770 + 7 * 256:770 + 8 * 256]}, "remap": {"pal": 5, "table": lookup[1 + 257 + 1:1 + 257 + 257]}, })