+#define zB(i) ((((i >> 10) & 0x1F) << 3) | (((i >> 10) & 0x1F) >> 2))
+#define zG(i) ((((i >> 5) & 0x1F) << 3) | (((i >> 5) & 0x1F) >> 2))
+#define zR(i) ((((i ) & 0x1F) << 3) | (((i ) & 0x1F) >> 2))
+
+#define zRGB(i) (zR(i) << 16 | zG(i) << 8 | zB(i))
+
+/*
+ * z_set_true_colour, set the foreground and background colours
+ * to specific RGB colour values.
+ *
+ * zargs[0] = foreground colour
+ * zargs[1] = background colour
+ * zargs[2] = window (-3 is the current one, optional)
+ *
+ */
+
+void z_set_true_colour (void)
+{
+ int zfore = zargs[0];
+ int zback = zargs[1];
+
+ if (!(zfore < 0))
+ zfore = zRGB(zargs[0]);
+
+ if (!(zback < 0))
+ zback = zRGB(zargs[1]);
+
+#ifdef GARGLK
+ garglk_set_zcolors(zfore, zback);
+#endif /* GARGLK */
+
+ curr_fg = zfore;
+ curr_bg = zback;
+}
+
+static int zcolor_map[] = {
+ -2, /* 0 = current */
+ -1, /* 1 = default */
+ 0x0000, /* 2 = black */
+ 0x001D, /* 3 = red */
+ 0x0340, /* 4 = green */
+ 0x03BD, /* 5 = yellow */
+ 0x59A0, /* 6 = blue */
+ 0x7C1F, /* 7 = magenta */
+ 0x77A0, /* 8 = cyan */
+ 0x7FFF, /* 9 = white */
+ 0x5AD6, /* 10 = light grey */
+ 0x4631, /* 11 = medium grey */
+ 0x2D6B, /* 12 = dark grey */
+};
+
+#define zcolor_NUMCOLORS (13)
+