about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c6
-rw-r--r--help.c22
-rw-r--r--torus.h29
3 files changed, 33 insertions, 24 deletions
diff --git a/client.c b/client.c
index 8b4732e..bddf20f 100644
--- a/client.c
+++ b/client.c
@@ -29,8 +29,10 @@
 
 #include "torus.h"
 
-#define ESC (0x1B)
-#define DEL (0x7F)
+enum {
+    ESC = 0x1B,
+    DEL = 0x7F,
+};
 
 #define CH_COLOR(ch) (ch & A_BOLD ? COLOR_BRIGHT | ch >> 8 & 0xFF : ch >> 8 & 0xFF)
 
diff --git a/help.c b/help.c
index 43a03bc..f82cd5d 100644
--- a/help.c
+++ b/help.c
@@ -46,16 +46,18 @@ static void clientPut(uint8_t color, char cell) {
     clientMessage(msg);
 }
 
-#define DELAY (50000)
-
-#define R (COLOR_RED)
-#define G (COLOR_GREEN)
-#define Y (COLOR_YELLOW)
-#define B (COLOR_BLUE)
-#define M (COLOR_MAGENTA)
-#define C (COLOR_CYAN)
-#define W (COLOR_WHITE)
-#define I (COLOR_BRIGHT | COLOR_WHITE)
+static const useconds_t DELAY = 50000;
+
+enum {
+    R = COLOR_RED,
+    G = COLOR_GREEN,
+    Y = COLOR_YELLOW,
+    B = COLOR_BLUE,
+    M = COLOR_MAGENTA,
+    C = COLOR_CYAN,
+    W = COLOR_WHITE,
+    I = COLOR_BRIGHT | COLOR_WHITE,
+};
 
 static void h(void) { clientMove(-1,  0); usleep(DELAY); }
 static void j(void) { clientMove( 0,  1); usleep(DELAY); }
diff --git a/torus.h b/torus.h
index e9fa2d1..7597878 100644
--- a/torus.h
+++ b/torus.h
@@ -18,6 +18,7 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <time.h>
 
 #define PACKED __attribute__((packed))
@@ -44,12 +45,14 @@ enum {
     COLOR_BRIGHT,
 };
 
-#define CELL_ROWS (25)
-#define CELL_COLS (80)
-#define CELLS_SIZE (sizeof(char[CELL_ROWS][CELL_COLS]))
+enum {
+    CELL_ROWS = 25,
+    CELL_COLS = 80,
+};
+static const size_t CELLS_SIZE = sizeof(char[CELL_ROWS][CELL_COLS]);
 
-#define CELL_INIT_X (CELL_COLS / 2)
-#define CELL_INIT_Y (CELL_ROWS / 2)
+static const uint8_t CELL_INIT_X = CELL_COLS / 2;
+static const uint8_t CELL_INIT_Y = CELL_ROWS / 2;
 
 struct ALIGNED(4096) Tile {
     time_t createTime;
@@ -64,12 +67,14 @@ static_assert(4096 == sizeof(struct Tile), "struct File is page-sized");
 static_assert(16 == offsetof(struct Tile, cells), "stable cells offset");
 static_assert(2016 == offsetof(struct Tile, colors), "stable colors offset");
 
-#define TILE_ROWS (512)
-#define TILE_COLS (512)
-#define TILES_SIZE (sizeof(struct Tile[TILE_ROWS][TILE_COLS]))
+enum {
+    TILE_ROWS = 512,
+    TILE_COLS = 512,
+};
+static const size_t TILES_SIZE = sizeof(struct Tile[TILE_ROWS][TILE_COLS]);
 
-#define TILE_VOID_X UINT32_MAX
-#define TILE_VOID_Y UINT32_MAX
+static const uint32_t TILE_VOID_X = UINT32_MAX;
+static const uint32_t TILE_VOID_Y = UINT32_MAX;
 
 static const struct {
     uint32_t tileX;
@@ -81,7 +86,7 @@ static const struct {
     { TILE_COLS * 1 / 4, TILE_ROWS * 1 / 4 }, // SE
     { TILE_COLS * 3 / 4, TILE_ROWS * 1 / 4 }, // SW
 };
-#define SPAWNS_LEN (sizeof(SPAWNS) / sizeof(SPAWNS[0]))
+static const size_t SPAWNS_LEN = sizeof(SPAWNS) / sizeof(SPAWNS[0]);
 
 struct ServerMessage {
     enum PACKED {
@@ -110,7 +115,7 @@ struct ServerMessage {
     } data;
 };
 
-#define CURSOR_NONE UINT8_MAX
+static const uint8_t CURSOR_NONE = UINT8_MAX;
 
 struct ClientMessage {
     enum PACKED {