summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-02-04 11:59:14 -0500
committerJune McEnroe <june@causal.agency>2018-02-04 11:59:14 -0500
commit222e30c163f4db23f0bec4e711a4a1baf7e1e542 (patch)
tree1464b4ee2634f75dcd2a13379a194e332998445a
parentAdd Quit menu item to gfcocoa (diff)
downloadsrc-222e30c163f4db23f0bec4e711a4a1baf7e1e542.tar.gz
src-222e30c163f4db23f0bec4e711a4a1baf7e1e542.zip
Add 4-bit RGB to gfxx
Replace default palette with alternating black and white.
Diffstat (limited to '')
-rw-r--r--bin/gfxx.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/gfxx.c b/bin/gfxx.c
index 7a3f24df..46b4cebc 100644
--- a/bin/gfxx.c
+++ b/bin/gfxx.c
@@ -38,10 +38,9 @@ static enum {
 static uint8_t bits = 1;
 static bool endian;
 static uint32_t palette[256] = {
-#define P8 0x000000, 0xFF0000, 0x00FF00, 0xFFFF00, 0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFF,
-    P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8
-    P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8 P8
-#undef P8
+#define X(...) __VA_ARGS__, __VA_ARGS__
+    X(X(X(X(X(X(X(0x000000, 0xFFFFFF)))))))
+#undef X
 };
 
 static bool reverse;
@@ -187,6 +186,8 @@ static void drawBits(struct Pos *pos) {
             uint8_t n = get(i) >> (endian ? 8 - bits - s : s) & MASK(bits);
             if (space == COLOR_PALETTE) {
                 put(pos, palette[n]);
+            } else if (space == COLOR_RGB && bits == 4) {
+                put(pos, RGB(SCALE(1, n & 1), SCALE(1, n & 2), SCALE(1, n & 4)));
             } else {
                 put(pos, GRAY(SCALE(bits, n)));
             }