summaryrefslogtreecommitdiff
path: root/src/kinds
diff options
context:
space:
mode:
Diffstat (limited to 'src/kinds')
-rw-r--r--src/kinds/pardes_addon.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/kinds/pardes_addon.h b/src/kinds/pardes_addon.h
index 8a95d6d7..c3fbc097 100644
--- a/src/kinds/pardes_addon.h
+++ b/src/kinds/pardes_addon.h
@@ -39,8 +39,10 @@
#define PA_REVERSE 0x10u
#define PA_UNDERLINE 0x100u
-/* A cell: one character, `len` bytes of UTF-8 (at most 7). */
-#define PA_UNPAINTED 0x01u /* flags: the pane's background, nothing drawn */
+/* A cell: one character, `len` bytes of UTF-8 (at most 7), drawn only
+ * with PA_PAINTED in its flags (pa_put sets it); a zero cell is the pane's
+ * background. */
+#define PA_PAINTED 0x01u
typedef struct pa_cell {
uint8_t text[8];
uint32_t fg, bg;
@@ -50,7 +52,7 @@ typedef struct pa_cell {
} pa_cell;
/* The pane's body, which `paint` writes: `rows` rows of `cols` cells,
- * `stride` cells apart, every one PA_UNPAINTED when the call begins. */
+ * `stride` cells apart, every one zero (unpainted) when the call begins. */
typedef struct pa_window {
pa_cell *cells;
uint32_t stride;
@@ -146,6 +148,9 @@ typedef struct pa_api {
void (*say)(const char *text, uint32_t n, int err);
/* A new text pane named `name` holding `bytes`; its serial, 0 if none. */
uint32_t (*text)(const char *name, uint32_t name_len, const char *bytes, uint32_t n);
+ /* The pane's seed: the same pane, the same number, on every machine (a
+ * game's board), and what `pardes --addon-test`'s `seed N` sets. */
+ uint64_t (*seed)(void);
} pa_api;
/* A job's answer buffer: `alloc` it once, write it, return its length. */
@@ -224,6 +229,20 @@ typedef struct pa_ops {
int (*load)(void *st, const uint8_t *buf, uint32_t n, uint32_t version);
} pa_ops;
+/* The records' sizes on a 64-bit target: an addon built against another
+ * copy of this header that disagrees does not compile. */
+#if UINTPTR_MAX == 0xffffffffffffffffu
+_Static_assert(sizeof(pa_cell) == 20, "pa_cell");
+_Static_assert(sizeof(pa_window) == 24, "pa_window");
+_Static_assert(sizeof(pa_rect) == 16 && sizeof(pa_cells) == 8, "pa_rect");
+_Static_assert(sizeof(pa_placement) == 72, "pa_placement");
+_Static_assert(sizeof(pa_paint) == 120, "pa_paint");
+_Static_assert(sizeof(pa_key) == 8 && sizeof(pa_mouse) == 10, "pa_key");
+_Static_assert(sizeof(pa_api) == 64 && sizeof(pa_out) == 16, "pa_api");
+_Static_assert(sizeof(pa_word) == 40 && sizeof(pa_head) == 56, "pa_head");
+_Static_assert(sizeof(pa_ops) == 192, "pa_ops");
+#endif
+
/* ---- helpers ---- */
static inline pa_cell *pa_at(const pa_window *w, unsigned row, unsigned col) {
@@ -244,7 +263,7 @@ static inline unsigned pa_put(const pa_window *w, unsigned row, unsigned col, co
c->fg = fg;
c->bg = bg;
c->attrs = 0;
- c->flags = 0;
+ c->flags = PA_PAINTED;
n++;
}
text += len;