Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/ui/mind.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / ui / mind.h` 77 lines ยท 3626 bytes Raw Blame History 1 /* mind.h -- Allen's presence: no face and no body, a crisp network. 2 * 3 * About a hundred sharp points sit on and inside a sphere, joined by fine 4 * threads into a network, turning slowly in three dimensions round a compact 5 * heart. Cool points and heart have native-pixel-bounded coverage, never bloom. 6 * Small sparks run along the threads from point to point; each one that 7 * arrives lights its point for a moment. How it moves is how Allen is: 8 * idle it breathes (a slow swell) and turns slowly; a few sparks. 9 * listening each key typed sends a soft wave of light up through it. 10 * thinking it draws in a little, turns faster, the cool heart pulses and 11 * sparks cascade through the whole network. 12 * speaking every word sends a pulse out from the heart, and the heart 13 * follows the voice. 14 * It is born from the light of the black holes' merger: the points start 15 * scattered wide and gather, spiralling, into the network. 16 * 17 * Integer only, freestanding. ck_mind_at moves it to a time (one caller); 18 * ck_mind_draw then only reads, so several processor cores can draw 19 * different parts of the screen at once. Host tested in 20 * ui/tests/allen_ui_test.c and ui/tests/mind_phases_test.c. */ 21 #ifndef AIENOS_MIND_H 22 #define AIENOS_MIND_H 23 #include 24 #include 25 26 #include "paint.h" 27 28 #define CK_MIND_NODES 120u 29 #define CK_MIND_EDGES 300u 30 #define CK_MIND_SPARKS 64u 31 #define CK_MIND_FORM_MS 3000u /* from born to fully gathered */ 32 33 enum { CK_MIND_IDLE, CK_MIND_LISTEN, CK_MIND_THINK, CK_MIND_SPEAK }; 34 35 typedef struct { 36 /* the shape, fixed at init */ 37 int32_t cx, cy, R; /* px */ 38 uint32_t k; 39 int16_t home[CK_MIND_NODES][3]; /* unit sphere, Q14 */ 40 uint8_t ea[CK_MIND_EDGES], eb[CK_MIND_EDGES]; 41 unsigned ne; 42 uint32_t born; /* ms */ 43 /* how it is, moved on by ck_mind_at */ 44 uint32_t t, rng, spawn; 45 int mode; 46 uint32_t angle; /* the turn so far, 1/256 of a 65536th */ 47 uint32_t spin, squeeze; /* eased toward the mode's: per-ms turn (same units), and 0..256 drawn in */ 48 uint32_t heart, voice; /* 0..256 */ 49 uint32_t words[4], keys[4]; /* when the last pulses began (ms; 0 none) */ 50 uint16_t act[CK_MIND_NODES]; /* how lit each point is, 0..256 */ 51 struct { 52 uint16_t e, dur; 53 uint8_t back; /* runs eb to ea */ 54 uint32_t t0; 55 } spark[CK_MIND_SPARKS]; 56 unsigned nspark; 57 /* the frame, worked out by ck_mind_at for ck_mind_draw */ 58 int32_t px[CK_MIND_NODES], py[CK_MIND_NODES]; /* 16ths of a pixel */ 59 uint16_t lum[CK_MIND_NODES], near[CK_MIND_NODES]; /* brightness 0..256; nearness 0..256 */ 60 uint32_t alpha; /* the whole figure, 0..256 */ 61 int32_t hx, hy, hr; /* compact heart centre and radius: 16ths of a pixel */ 62 ck_rect box, was; /* where it is now, and was the frame before */ 63 } ck_mind; 64 65 /* (cx, cy) its centre, px; k the scale (1/256 px per design px); born the 66 * time it starts to gather (ms). */ 67 void ck_mind_init(ck_mind *m, int32_t cx, int32_t cy, uint32_t k, uint32_t born); 68 void ck_mind_mode(ck_mind *m, int mode, uint32_t t); 69 void ck_mind_word(ck_mind *m, uint32_t t); /* a word was spoken */ 70 void ck_mind_key(ck_mind *m, uint32_t t); /* a key was typed */ 71 void ck_mind_voice(ck_mind *m, uint32_t level); /* 0..256 */ 72 void ck_mind_at(ck_mind *m, uint32_t t); 73 /* The figure into the part r of out (cool threads and coverage-mixed points). */ 74 void ck_mind_draw(const ck_mind *m, ck_canvas *out, const ck_rect *r); 75 /* What needs redrawing for this frame: where it was and where it is. */ 76 ck_rect ck_mind_dirty(const ck_mind *m); 77 #endif