about summary refs log tree commit diff homepage
path: root/torus.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-07-30 02:40:03 -0400
committerJune McEnroe <june@causal.agency>2017-07-30 02:41:09 -0400
commit664e9245cbfa9ecaf11037c15d55505b171ca1fb (patch)
tree5e6c41da811ed3c6f40a5940bf21dda7c4e43b5f /torus.h
downloadtorus-664e9245cbfa9ecaf11037c15d55505b171ca1fb.tar.gz
torus-664e9245cbfa9ecaf11037c15d55505b171ca1fb.zip
Initial commit
Diffstat (limited to '')
-rw-r--r--torus.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/torus.h b/torus.h
new file mode 100644
index 0000000..23b4708
--- /dev/null
+++ b/torus.h
@@ -0,0 +1,78 @@
+#include <stdbool.h>
+#include <stdint.h>
+#include <assert.h>
+
+#define ALIGNED(x) __attribute__((aligned(x)))
+
+enum {
+    COLOR_BLACK,
+    COLOR_RED,
+    COLOR_GREEN,
+    COLOR_YELLOW,
+    COLOR_BLUE,
+    COLOR_MAGENTA,
+    COLOR_CYAN,
+    COLOR_WHITE,
+    COLOR_BRIGHT,
+};
+
+#define CELL_ROWS (25)
+#define CELL_COLS (80)
+#define CELLS_SIZE (sizeof(char[CELL_ROWS][CELL_COLS]))
+
+#define CELL_INIT_X (CELL_COLS / 2)
+#define CELL_INIT_Y (CELL_ROWS / 2)
+
+struct Tile {
+    bool present;
+    char cells[CELL_ROWS][CELL_COLS] ALIGNED(16);
+    uint8_t colors[CELL_ROWS][CELL_COLS] ALIGNED(16);
+} ALIGNED(4096);
+static_assert(sizeof(struct Tile) == 4096, "struct Tile is page-sized");
+
+#define TILE_ROWS (512)
+#define TILE_COLS (512)
+#define TILES_SIZE (sizeof(struct Tile[TILE_ROWS][TILE_COLS]))
+
+#define TILE_INIT_X (0)
+#define TILE_INIT_Y (0)
+
+enum ServerMessageType {
+    SERVER_TILE,
+    SERVER_MOVE,
+    SERVER_PUT,
+};
+
+struct ServerMessage {
+    enum ServerMessageType type;
+    union {
+        struct {
+            uint8_t cellX;
+            uint8_t cellY;
+        } m;
+        struct {
+            uint8_t cellX;
+            uint8_t cellY;
+            uint8_t color;
+            char cell;
+        } p;
+    } data;
+};
+
+enum ClientMessageType {
+    CLIENT_MOVE,
+    CLIENT_COLOR,
+    CLIENT_PUT,
+};
+
+struct ClientMessage {
+    enum ClientMessageType type;
+    union {
+        struct {
+            int8_t dx;
+            int8_t dy;
+        } m;
+        uint8_t c;
+        char p;
+    } data;
+};
fers, not to mention all the heap allocations for the separate mbs buffers! There might be a way to be more clever about capacities, but I don't think it's worth it. 2022-02-20Clear edit buffer before running commandJune McEnroe Otherwise a command that switches windows will update the status line while the edit buffer still has input "pending", showing an indicator. 2022-02-20Show indicator in status when window has pending inputJune McEnroe 2022-02-20Use separate edit buffers for each IDJune McEnroe 2022-02-20Make sure new cap is actually larger than new lengthJune McEnroe 2022-02-20Remove unused mbs.len field from struct EditJune McEnroe 2022-02-19Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe In other words, warn when a function is missing static. I don't see why this isn't in -Wextra. 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe I know, it feels wrong. 2022-02-18Implement new line editing "library"June McEnroe Losing tab complete and text macros, for now. This new implementation works on an instance of a struct and does not interact with the rest of catgirl, making it possible to copy into another project. Unlike existing line editing libraries, this one is entirely abstract and can be rendered externally. My goal with this library is to be able to implement vi mode. Since it operates on struct instances rather than globals, it might also be possible to give catgirl separate line editing buffers for each window, which would be a nice UX improvement. 2022-02-18Simplify cursor positioning in inputJune McEnroe Do some extra work by adding the portion before the cursor to the input window twice, but simplify the interaction with the split point. This fixes the awkward behaviour when moving the cursor across colour codes where the code would be partially interpreted up to the cursor. 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe