build engine: docs/guide sections (ART tiles, Build maps) with inputs from tools/fixtures/docs_build.py, bench lines, type fixes; bundles rebuilt
This commit is contained in:
1 parent
aacc78fac2
commit
082ea2019e
10 files changed
+3575
-1085
No files matched your search
@@ -1902,3 +1902,33 @@ do
|
||||
jitTune(false)
|
||||
end
|
||||
end
|
||||
do
|
||||
-- Build engine (ws-build): an ART of 64 random 128 x 128 tiles to rgba8 through a palette (MB/s of rgba8 output),
|
||||
-- and the two-room map of tools/fixtures/buildmap.py to a Scene (MB/s of map bytes)
|
||||
local Art = require("@rosetta/image/art")
|
||||
local BuildMap = require("@rosetta/model/buildmap")
|
||||
local AF = require("@tests/gen/art")
|
||||
local BF = require("@tests/gen/buildmap")
|
||||
local rnd = 12345
|
||||
local frames: { Types.Frame } = {}
|
||||
for i = 1, 64 do
|
||||
local img = Types.Image.new(128, 128, "gray8")
|
||||
for k = 0, 128 * 128 - 1 do
|
||||
rnd = (rnd * 1103515245 + 12345) % 2147483648
|
||||
buffer.writeu8(img.pixels, k, rnd % 256)
|
||||
end
|
||||
img.meta.tile = i - 1
|
||||
frames[i] = { image = img, delay = 0, x = 0, y = 0, dispose = "none", blend = "source" }
|
||||
end
|
||||
local top = Types.Image.new(1, 1, "gray8")
|
||||
top.frames = frames
|
||||
local art = assert(Art.encode(top))
|
||||
local pal = buffer.fromstring(AF.palette)
|
||||
bench("art decode 64 x 128x128 -> rgba8", 3, 64 * 128 * 128 * 4, function()
|
||||
Art.decode(Bytes.reader(art), { palette = pal })
|
||||
end)
|
||||
local map = buffer.fromstring(BF.maps[1].data)
|
||||
bench("buildmap rooms -> Scene", 20, buffer.len(map), function()
|
||||
BuildMap.decode(Bytes.reader(map))
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,38 @@
|
||||
# Docs inputs for the Build engine sections of the image / scene pages (tools/fixtures.py; tools/docs_check.py explains
|
||||
# the inputs): an ART file of three tiles and a random PALETTE.DAT written here (BUILDINF.TXT layout), and the two-room
|
||||
# map of tools/fixtures/buildmap.py.
|
||||
# tests/gen/docs_build.luau { files = { [name] = bytes }, vars = { artBytes = "TILES000.ART", ... } }
|
||||
import importlib.util, os, struct
|
||||
|
||||
INPUTS = ["tools/docs_check.py", "tools/fixtures/buildmap.py"]
|
||||
|
||||
|
||||
def mod(ctx, path, name):
|
||||
spec = importlib.util.spec_from_file_location(name, os.path.join(ctx.root, path))
|
||||
m = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(m)
|
||||
return m
|
||||
|
||||
|
||||
def art(rng, first, tiles):
|
||||
"""tiles: [(w, h, picanm)]; column-major random indices"""
|
||||
out = bytearray(struct.pack("<4I", 1, 0, first, first + len(tiles) - 1))
|
||||
out += b"".join(struct.pack("<h", w) for w, _, _ in tiles)
|
||||
out += b"".join(struct.pack("<h", h) for _, h, _ in tiles)
|
||||
out += b"".join(struct.pack("<I", a) for _, _, a in tiles)
|
||||
for w, h, _ in tiles:
|
||||
out += bytes(rng.randrange(255) for _ in range(w * h))
|
||||
return bytes(out)
|
||||
|
||||
|
||||
def generate(ctx):
|
||||
rng = ctx.rng(5)
|
||||
check = mod(ctx, "tools/docs_check.py", "docs_check")
|
||||
bm = mod(ctx, "tools/fixtures/buildmap.py", "fx_buildmap")
|
||||
pal = bytes(rng.randrange(64) for _ in range(768)) + struct.pack("<H", 1) + bytes(range(256))
|
||||
files = {
|
||||
"TILES000.ART": art(rng, 0, [(16, 16, 0), (8, 4, 2 | (2 << 6) | (3 << 24)), (0, 0, 0)]),
|
||||
"PALETTE.DAT": pal,
|
||||
"E1L1.MAP": bm.rooms(rng).write(7),
|
||||
}
|
||||
check.emit_inputs(ctx, files, {"artBytes": "TILES000.ART", "paletteBytes": "PALETTE.DAT", "buildmapBytes": "E1L1.MAP"})
|
||||
Reference in new issue
Block a user