Expand the abbreviated pointer types to full words on the language surface: ptr -> pointer (a raw address / FFI handle) ptrs -> pointers (a buffer of pointers) The Ludic type name is distinct from LLVM's own `ptr` spelling: llty() maps `pointer`/`pointers` to LLVM `ptr`, and the emitted IR keeps `ptr`, so only the Ludic-level surface changes. Rewrites type annotations across all sources, the 8 hardcoded pointer type-tags, the `pointers`-buffer indexing in emit_addr, the grammars/LSP/JetBrains tokens, and the docs (type-ptr -> type-pointer, type-ptrs -> type-pointers). int/bool keep their conventional short spelling (like Math). Reseeded; C-free fixpoint holds; all suites green (45/24/29); site + check.py OK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
1.8 KiB
Text
56 lines
1.8 KiB
Text
# ============================================================================
|
|
# atlas.ludic — render a Kenney tile pack as one index-labeled sheet, so you can
|
|
# see which sprite id is which before referring to it in a game.
|
|
#
|
|
# ludicc tools/atlas.ludic --headless -o build/atlas
|
|
# ./build/atlas && sips -s format png out.ppm --out atlas.png
|
|
#
|
|
# Replaces the old tools/atlas.c, which used the C runtime that no longer
|
|
# exists. It is the same program, in the language it is a tool for.
|
|
# ============================================================================
|
|
game Atlas {
|
|
const DIR: str = "assets/kenney/tiny-dungeon/Tiles"
|
|
const N: int = 132
|
|
const COLS: int = 12
|
|
const CELL: int = 24
|
|
|
|
system Sheet phase Start {
|
|
clear(0x101018)
|
|
for i in 0 .. N {
|
|
let col = i % COLS
|
|
let row = i / COLS
|
|
let x = col * CELL
|
|
let y = row * CELL
|
|
# tile_0000.png … tile_0131.png — the id is the file's number
|
|
let id = load_png(tile_path(i))
|
|
if id >= 0 {
|
|
draw_sprite(id, x + 4, y + 2)
|
|
}
|
|
text_int(x + 1, y + 18, i, 0x8090b0, 1)
|
|
}
|
|
present()
|
|
quit()
|
|
}
|
|
|
|
# build "<DIR>/tile_%04d.png" without a formatter: the runtime's string
|
|
# helpers write into a scratch buffer we own
|
|
function tile_path(i: int) -> string {
|
|
let buf = atlas_buf()
|
|
let n = rt_put_str(buf, 0, DIR)
|
|
n = rt_put_str(buf, n, "/tile_")
|
|
if i < 1000 { poke8(buf, n, 48) n = n + 1 }
|
|
if i < 100 { poke8(buf, n, 48) n = n + 1 }
|
|
if i < 10 { poke8(buf, n, 48) n = n + 1 }
|
|
n = rt_put_int(buf, n, i)
|
|
n = rt_put_str(buf, n, ".png")
|
|
poke8(buf, n, 0)
|
|
return buf
|
|
}
|
|
|
|
var atlas_scratch: pointer = ptr_null()
|
|
|
|
function atlas_buf() -> pointer {
|
|
if ptr_is_null(atlas_scratch) { atlas_scratch = mem_alloc(512) }
|
|
return atlas_scratch
|
|
}
|
|
}
|