src/krb/krb_caps.c: flat-file key/value storage (KRB_CAP_STORE_DIR,
atomic replace-and-append), KrbFn adaptors, and KrbCapInstallDefaults
binding storage.get/set + audio.play/stop. The raylib surface host
installs a real audio hook (LoadSound/PlaySound/StopSound) via
constructor, so cartridges on desktop get working audio; headless
hosts return -1 rather than pretending. tests/krb_caps_test.c covers
install count, set/get/replace/missing round-trip, and the audio
hook; wired into make test. All suites green; 11/11 cross-engine
byte-identical.
DATA nodes now carry their initializer (ints in x, CSTRs via text),
and KrbAutoMount(img) binds them into malloc'd slots. krb-run and
krb-sdl both call it, so bound counters, checkbox defaults, and
TextField contents render identically with or without generated
host binds. Cross-engine 11/11 byte-identical; suites green,
goldens regenerated.
New VM pieces: OP_MOD, and OP_NODE_SET (pops an i16 and patches a
node's x/y/w/h through a mutable node overlay allocated on first
use). TIME is now a first-class term in expressions. The k2b program
compiler was restructured around an ordered instruction stream
(updates, draws, guard/else brackets interleaved in source order) so
conditional assignments compile correctly — previously both branches
of an if always ran, last-write-wins. Updates accept full
term-or-term-arith-term right sides including % and TIME.
examples/26_inbe_whm_session.kry: the Wim Hof session as a cartridge —
TIME -> elapsed -> phase -> triangle wave -> animated ring radius via
AnimNode('ring0','w',&radius), breath counter with clamp, in/out
phase text. Verified across frames: t=0/600ms/5s produce the exact
expected phase, radius, and breath values. Eight exactness screens
byte-identical kry_sw == SDL.
KRB_FLAG_NAV buttons write a screen id to a state path on press
(cartridge-owned navigation; no host import). k2b compiles
NavButton(label, x, y, w, h, &state.screen, id). Screens are guarded
node ranges over one state field; examples/23_inbe_app.kry is Inner
Breeze as a single 6 MB cartridge — language, settings, and manual
screens with dropdowns, scroll, checkboxes, and the breath ring,
navigable end to end (verified: Next/Manual/Back transitions via
injected clicks). Scroll containers now draw a 1px outline instead
of a filled rect. All five exactness screens byte-identical
kry_sw == SDL.
KRB_CTRL_DROPDOWN (kind 4) implemented end to end: the control record's
reserved options_off/option_count now carry consecutive NUL-terminated
option strings (k2b appends them without interning so they stay
contiguous; Dropdown(id,x,y,w,"a;b;c",&val)). Click toggles the popup,
clicking a row writes the selected index to the bound int and closes.
Loader initializes the open-dropdown slot to -1 (0 is a valid index).
New node type 13: bounded field drawing the mounted CSTR with a
blinking caret when focused (click to focus). Typed input flows through
the new optional KryBackend.text_key (codepoints, 0x08 backspace):
kry_sw queues via KrySwText (drained per frame by Advance), the raylib
surface backend maps GetCharPressed, SDL maps SDL_TEXTINPUT/BACKSPACE,
krb-web exports krb_web_text from keypress events. UTF-8 runes append
and strip correctly. k2b compiles TextField(x,y,w,h,&state.field).
Verified: click-focus, typing with backspace, and that unfocused
fields ignore keys.
SCROLL node (type 12): viewport bounds, content height in font_size,
mounted pixel offset at name_off. Children (parent = scroll index)
draw translated by -offset and clipped to the viewport; a new
optional KryBackend.wheel entry drives the offset when the pointer is
over the viewport, clamped to [0, content_h - h]. Implemented in
kry_sw (+KrySwWheel injection), the raylib surface backend, the null
and recorder backends; krb-sdl maps SDL_MOUSEWHEEL, krb-web exposes
krb_web_wheel from canvas wheel events. k2b compiles
Scroll(x, y, w, h, contentH, &state.off) ... EndScroll()
bracketing child widgets (parent-linked). Fixed a compounding-offset
bug where draw_tree's origin was mutated across children.
Cartridges can now carry their pictures: a v2 asset section (header
offset 28 = asset_bytes) after controls[] holds a directory of
20-byte entries (path, absolute data offset, size, kind, w, h) plus
blobs. KrbAssetFind looks paths up; a PICTURE node whose path is
embedded renders from cartridge pixels through the new optional
KryBackend.texture_rgba (nearest-neighbor scaled, tint-modulated,
clipped) — kry_sw implements it, so krb-run, krb-web, and krb-sdl all
get embedded assets. Non-embedded paths still fall back to host
texture loading. kinds: 0 raw RGBA8, 1 reserved for the glyph atlas.
tests/krb_asset_test.c proves lookup + 2x2->8x8 scaled, tinted blit
with correct bounds; spec updated in KRB_FORMAT.md. k2b embedding of
decoded image files is the follow-up.
The plan-07 core: cartridges stop being static pictures.
- New v2 opcodes: a 16-deep int stack machine (PUSH_CONST/PUSH_PATH/
POP_STORE, ADD..GE, JMP/JZ, TIME) plus OP_DRAW_NODE so UI can be
conditional on mounted state. Loader accepts v1 and v2; k2b now
writes version 2.
- New node types CIRCLE (center+radius) and RING (annulus), the shapes
the inbe breath visualizer needs; k2b parses DrawCircleV/DrawRing
(with (Color){r,g,b,a} literals). KryBackend gains optional circle/
ring entries — implemented in kry_sw, the raylib surface backend,
the null backend, and forwarded+logged by the recorder.
- tests/krb_logic_test.c: hand-assembled v2 cartridge proving counter
increments per frame, conditional node visibility across frames,
circle/ring rasterization bounds, and TIME. Engine golden test passes
unchanged on v2 output (render back-compat).
- KRB_FORMAT.md documents v2 and the R>=0x80 theme-slot color caveat.
Add a controls[] table to the format for interactive widgets whose args don't
fit the 28-byte node. The header's reserved field becomes control_count
(backward compatible: old files have 0 -> no section). Each 24-byte KrbControl
record carries kind/id/min/max/step + value_off/label_off/options_off; a
KRB_NODE_CONTROL (9) node references it by bind_slot.
Range widgets bind a state{} field (value_off), render with KryBackend
primitives, and update the value on interaction:
- Slider / VerticalSlider: a held drag sets the value across [min,max].
- Spinbox: a click steps by 'step' (clamped), left half down / right half up.
The cartridge owns the value (read/write via the mount), like Checkbox/Toggle.
Dropdown/Combobox (need a state-array option parser) and by-value Radio/TabBar
remain deferred.
Verified: 03_theme.kry emits a Slider as a CONTROL node + control record;
krb_mount_test builds a SLIDER cartridge and asserts a drag sets 0->80 (and a
no-drag frame leaves it); make test green. KRB_FORMAT.md documents the
controls[] section and the CONTROL node.
Add the first interactive cartridge widgets. CHECKBOX (7) and TOGGLE (8) bind
to a state{} field by name (the widget's &val arg -> name_off), render with
KryBackend primitives (box outline + check / track + thumb + label), and on an
in-bounds mouse press flip the value back through the mount. The cartridge
owns the toggle (no host handler, unlike BUTTON) — the host just reads the
resulting state. Only state{} fields bind (what the host mounts).
These two fit the existing 28-byte node (path/label/id map to spare fields);
range/options widgets (Slider/Spinbox/Dropdown/Combobox) and by-value widgets
(Radio/TabBar) need a controls[] args section and are deferred.
Verified: krb_mount_test builds a CHECKBOX, mounts a value, and asserts an
in-bounds press flips 0->1 (and no-press leaves it); the cartridge frame
fixture now carries a Checkbox and asserts its value path lands in the string
table; make test green.
The .kry->.krb slice only captured Background/Text/Rect/Button and collapsed
every non-theme color to opaque black. Broaden it:
- parse_color now understands hex (0xRRGGBBAA / 0xRRGGBB) and the raylib color
sentinels (WHITE/BLACK/BLANK/RED/GREEN/BLUE/...), not just theme getters.
- New parsers map static widgets onto existing node types: Separator (themed
rail RECT), Line (axis-aligned bounding RECT), Bevel (light-face RECT),
TextInRect (TEXT). A shared node_rect() helper parses (Rectangle){...}.
- Picture becomes a first-class node type KRB_NODE_PICTURE=6 (additive; old
loaders hit default:break). text_off carries the asset path, color the tint,
style the UIPictureFit. KryBackend gains a texture() entry (implemented via
KryLoadPictureTexture + KryPictureFitRect in the raylib backend, no-op in the
null backend), and draw_node renders it. A depth-aware find_match_brace() is
needed because PictureProps nests Rectangle/Vector2 braces.
Interactive stateful widgets (Slider/Toggle/Checkbox/TextField/Dropdown/etc.)
are deferred: they need host-side state + event capture. Verified: 19_pictures
compiles to 2 PICTURE nodes and kryon-preview cartridge renders the real
textures; all krait samples still compile; make test green.
KRB_NODE_GROUP, KRB_EXPORT_LOCAL/R/RW, and KRB_FLAG_EXPORT_MASK were
defined but never emitted, set, or read. Per the no-dead-code rule, remove
them so the shipped v1 surface is honest: node types are BACKGROUND/TEXT/
RECT/BUTTON/DATA (type 0 reserved), and flags carry only SCALE_X/Y/W/H
(bits 0-1 reserved). The three opcodes stay (they are implemented and
host-appendable). KRB_FORMAT.md updated to match and to document DATA.
KRB_F32 was defined as a field kind but had no accessor: KrbReadI32/
KrbWriteI32 returned -1 for it. Add dedicated KrbReadF32/KrbWriteF32 (typed
memcpy of a float, size>=4) and route format_bound through them so a TEXT
node bound to a float renders via the node's printf format (default "%g").
krb_mount_test gains a float round-trip, an i32/f32 type-discrimination
check, and a capture-backend assertion that a %.1f-bound text node draws
"3.1" from 3.14159.
A .krb file is a little-endian image: a 32-byte header (magic "KRB\0",
version 1), a 28-byte VFS node table (group/background/text/rect/button/
data), a UTF-8 string table, a tiny program (OP_DRAW_TREE/OP_CALL_HOST/
OP_SET_I32), and a host-import name list. Behavior stays in C.
KrbLoad/KrbLoadFile validate and map the image in place; KrbDraw/KrbExec
walk it through a KryBackend; KrbMount/KrbBindMem map live C fields onto
paths so TEXT nodes draw live values; KrbBind wires host functions to
import slots. Format spec in docs/KRB_FORMAT.md.