Closes the two open issues and lands the pending unreleased batch: - #90: `Sprite { atlas: 1 }` routes esys_sprite through atlas_draw_ex (scale/flip/tint), so cell / cell_span / strip ids of any size draw through the engine sprite-render system. examples/library/sprite_atlas is the pixel-readback regression. - #91: `become` from an @On(Event) listener / global handler / plain function no longer segfaults the compiler; it emits @L_scene_leave() (a dispatch on the live scene id) so the leaving scene's on-exit runs. UI_* handles are readable from any code (widget table built on first use). examples/library/scene_menus covers it. - fix: a windowed `ludicc -o` build that reaches the audio runtime only through the atlas/Assets preload import now links audio.ll + AVFoundation (the audio backend link was gated on a game-level Audio.* call, so any windowed game declaring Sprite failed to link). - the hand-written "Unreleased" CHANGELOG section is converted to changesets under changes/ so `x release` generates it. - plus the batch: engine-driven retained UI + UiClicked event, Overlay phase, TileSkin tilemap-render system, Key.* constants, Font/Ui/File namespaces, Sprite.strip, prefabs, managers, countdown fields, enum-typed machines, layer @Queries, ludic.prefs / ludic.dungeon packages, Ai.seek pathing, Solids.solid2, cursor confine (mode 3) fix, shooter centre-aim fix, reserved-word function diagnostic. Verified: x test (124/124), x test-tools, check-impl, check-vocabulary, check-docs, docs-gen + docs-check, bootstrap-cfree (seed is a fixpoint). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
e9c2c51bc3
commit
ad548840c7
139 changed files with 58981 additions and 43671 deletions
|
|
@ -20,6 +20,7 @@ function is_ivec_ns(meth: pointer) -> bool {
|
|||
if (meth == "make") or (meth == "zero") or (meth == "x") or (meth == "y") { return true }
|
||||
if (meth == "add") or (meth == "sub") or (meth == "scale") or (meth == "dot") { return true }
|
||||
if (meth == "equal") or (meth == "manhattan") or (meth == "to_vector") { return true }
|
||||
if (meth == "distance2") or (meth == "within") or (meth == "heading") or (meth == "along") or (meth == "step") { return true }
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +40,34 @@ function emit_ivec_ns(meth: pointer, e: Node) -> Val {
|
|||
let v = emit_expr(e.kids[0])
|
||||
return val(vec_y(v.code), "int")
|
||||
}
|
||||
if (meth == "distance2") or (meth == "within") { # squared distance; within(a, b, radius)
|
||||
let a = emit_expr(e.kids[0]); let b = emit_expr(e.kids[1])
|
||||
let dx = emit_bind(`sub i32 {vec_x(b.code)}, {vec_x(a.code)}`)
|
||||
let dy = emit_bind(`sub i32 {vec_y(b.code)}, {vec_y(a.code)}`)
|
||||
let xx = emit_bind(`mul i32 {dx}, {dx}`)
|
||||
let yy = emit_bind(`mul i32 {dy}, {dy}`)
|
||||
let d2 = emit_bind(`add i32 {xx}, {yy}`)
|
||||
if (meth == "distance2") { return val(d2, "int") }
|
||||
let r = emit_expr(e.kids[2])
|
||||
let rr = emit_bind(`mul i32 {r.code}, {r.code}`)
|
||||
let c = emit_bind(`icmp sle i32 {d2}, {rr}`)
|
||||
return val(emit_bind(`zext i1 {c} to i32`), "bool")
|
||||
}
|
||||
if (meth == "heading") { # degrees from a to b (0 = +x, 90 = +y)
|
||||
if find_fn("rt_ivec_heading") == null { perr("IVec2.heading needs the engine runtime") }
|
||||
let a = emit_expr(e.kids[0]); let b = emit_expr(e.kids[1])
|
||||
return val(emit_bind(`call i32 @fn_rt_ivec_heading(i64 {a.code}, i64 {b.code})`), "int")
|
||||
}
|
||||
if (meth == "along") { # the point `distance` along `degrees` from origin
|
||||
if find_fn("rt_ivec_along") == null { perr("IVec2.along needs the engine runtime") }
|
||||
let o = emit_expr(e.kids[0]); let d = emit_expr(e.kids[1]); let n = emit_expr(e.kids[2])
|
||||
return val(emit_bind(`call i64 @fn_rt_ivec_along(i64 {o.code}, i32 {d.code}, i32 {n.code})`), "IVec2")
|
||||
}
|
||||
if (meth == "step") { # a -1/0/1 unit step along `degrees`
|
||||
if find_fn("rt_ivec_step") == null { perr("IVec2.step needs the engine runtime") }
|
||||
let d = emit_expr(e.kids[0])
|
||||
return val(emit_bind(`call i64 @fn_rt_ivec_step(i32 {d.code})`), "IVec2")
|
||||
}
|
||||
if (meth == "add") { # component-wise a + b
|
||||
let a = emit_expr(e.kids[0]); let b = emit_expr(e.kids[1])
|
||||
let ax = vec_x(a.code); let ay = vec_y(a.code); let bx = vec_x(b.code); let by = vec_y(b.code)
|
||||
|
|
|
|||
34
selfhost/backend/stdlib/emit_key.ludic
Normal file
34
selfhost/backend/stdlib/emit_key.ludic
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# emit_key.ludic — `Key.Name` -> the key code the input layer delivers, folded at
|
||||
# compile time (like Color.*). Letters are the lowercase character (what the held-key
|
||||
# set stores), digits their ASCII, plus the specials. Arrow keys alias WASD because the
|
||||
# platform layer maps them that way; Escape is 27 (0.3, #88).
|
||||
function key_lookup(name: pointer) -> int {
|
||||
if (name == "Space") { return 32 }
|
||||
if (name == "Enter") { return 10 }
|
||||
if (name == "Return") { return 10 }
|
||||
if (name == "Escape") { return 27 }
|
||||
if (name == "Esc") { return 27 }
|
||||
if (name == "Shift") { return 16 }
|
||||
if (name == "Tab") { return 9 }
|
||||
if (name == "Backspace") { return 8 }
|
||||
if (name == "Up") { return 119 }
|
||||
if (name == "Down") { return 115 }
|
||||
if (name == "Left") { return 97 }
|
||||
if (name == "Right") { return 100 }
|
||||
if (name == "Digit0") { return 48 }
|
||||
if (name == "Digit1") { return 49 }
|
||||
if (name == "Digit2") { return 50 }
|
||||
if (name == "Digit3") { return 51 }
|
||||
if (name == "Digit4") { return 52 }
|
||||
if (name == "Digit5") { return 53 }
|
||||
if (name == "Digit6") { return 54 }
|
||||
if (name == "Digit7") { return 55 }
|
||||
if (name == "Digit8") { return 56 }
|
||||
if (name == "Digit9") { return 57 }
|
||||
# a single capital letter names that letter key: Key.A .. Key.Z
|
||||
if (name[1] == 0) {
|
||||
let c = name[0]
|
||||
if (c >= 65) and (c <= 90) { return c + 32 }
|
||||
}
|
||||
return 0 - 1
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ function list_elem_addr(h: pointer, elt: pointer, idx: pointer) -> pointer {
|
|||
}
|
||||
|
||||
function is_list_ns(meth: pointer) -> bool {
|
||||
if (meth == "len") or (meth == "push") or (meth == "clear") { return true }
|
||||
if (meth == "len") or (meth == "push") or (meth == "clear") or (meth == "sample") { return true }
|
||||
if (meth == "first") or (meth == "last") or (meth == "pop") or (meth == "swap") { return true }
|
||||
if (meth == "contains") or (meth == "index_of") or (meth == "reverse") { return true }
|
||||
if (meth == "insert") or (meth == "remove_at") or (meth == "remove") or (meth == "sort") { return true }
|
||||
|
|
@ -228,6 +228,12 @@ function sort_fn_arg(meth: pointer, e: Node) -> pointer {
|
|||
function emit_list_ns(meth: pointer, e: Node) -> Val {
|
||||
if (meth == "len") { return emit_len(e) } # same header length as len(s)
|
||||
if (meth == "push") { return emit_push(e) } # same as push(s, v)
|
||||
if (meth == "sample") { # count random picks from an int slice (runtime)
|
||||
let pool = emit_expr(e.kids[0])
|
||||
let cnt = emit_expr(e.kids[1])
|
||||
if find_fn("rt_list_sample") == null { perr("List.sample needs the engine runtime (a game, or import ludic.core)") }
|
||||
return val(emit_bind(`call ptr @fn_rt_list_sample(ptr {pool.code}, i32 {cnt.code})`), "[]int")
|
||||
}
|
||||
let s = emit_expr(e.kids[0])
|
||||
if not is_slice_ty(s.ty) { perr(`List.{meth} needs a slice`) }
|
||||
let el = slice_elem(s.ty)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue