about summary refs log tree commit diff homepage
path: root/torus.h
blob: 9158ef70d744b7e1d2c3883b9f694a8a4ffa8b53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <time.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 {
    time_t create;
    time_t access;
    char cells[CELL_ROWS][CELL_COLS] ALIGNED(16);
    uint8_t colors[CELL_ROWS][CELL_COLS] ALIGNED(16);
    uint32_t accessCount;
} ALIGNED(4096);
static_assert(sizeof(struct Tile) == 4096, "struct Tile is page-sized");
static_assert(offsetof(struct Tile, cells) == 16, "stable cells offset");
static_assert(offsetof(struct Tile, colors) == 2016, "stable colors offset");

#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,
    SERVER_CURSOR,
};

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;
        struct {
            uint8_t oldCellX;
            uint8_t oldCellY;
            uint8_t newCellX;
            uint8_t newCellY;
        } c;
    } data;
};

#define CURSOR_NONE UINT8_MAX

enum ClientMessageType {
    CLIENT_MOVE,
    CLIENT_PUT,
};

struct ClientMessage {
    enum ClientMessageType type;
    union {
        struct {
            int8_t dx;
            int8_t dy;
        } m;
        struct {
            uint8_t color;
            char cell;
        } p;
    } data;
};
af3791d661fd780b8da773499c10ee05d03569&follow=1'>Set push.autoSetupRemoteJune McEnroe 2022-07-08Remove TOURJune McEnroe There is not that much distinct stuff here anymore. 2022-07-03Add The Bone Shard EmperorJune McEnroe Suffers a little bit from middle book but I really enjoyed it. Read it faster than the first one too, despite its length. 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe Mixed bag like most collections of short stories. Some of them are pretty good. The author of the worst written story also has the worst written bio. 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe Absolutely indiscriminately. 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine. 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe