From 954f60b9e14b92bcc3801b789e00b1c3000d71cf Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 20 Jan 2019 11:10:24 +0000 Subject: [PATCH] Add 4-cell mosaic graphics. These follow the same approach as 6-cell graphics: the smoothing algorithm is disabled and there's no margin between character cells. This is necessary to ensure that "upblock" and "dnblock" harmonise with "lfblock" and "rtblock", the latter two being unified with 6-cell graphics and the former not. I've filled in the rest of the 4-cell characters on the basis that an alternate history in which Teletext used 4-cell rather than 6-cell graphics is perfectly plausible and Bedstead may as well support it. --- bedstead.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/bedstead.c b/bedstead.c index 5a84cc2..c69fa90 100644 --- a/bedstead.c +++ b/bedstead.c @@ -217,6 +217,7 @@ static void doprologue(void); static void dochar(char const data[YSIZE], unsigned flags); static void dochar_plotter(char const data[YSIZE], unsigned flags); static void domosaic(unsigned code, bool sep); +static void domosaic4(unsigned code); static void dopanose(void); static void glyph_complement(void); @@ -225,8 +226,9 @@ static struct glyph { int unicode; char const *name; unsigned int flags; -#define SC 0x01 /* Character has a small-caps variant. */ -#define MOS 0x02 /* Mosaic graphics character */ +#define SC 0x01 /* Character has a small-caps variant. */ +#define MOS 0x02 /* Mosaic graphics character */ +#define MOS4 0x04 /* 4-cell mosaic graphics character */ } const glyphs[] = { /* * The first batch of glyphs comes from the code tables at the end of @@ -1333,14 +1335,17 @@ static struct glyph { {{012,012,012,033,000,033,012,012,012}, 0x256c, "SF440000" }, /* Block elements */ - {{037,037,037,037,037,000,000,000,000}, 0x2580, "upblock" }, - {{000,000,000,000,037,037,037,037,037}, 0x2584, "dnblock" }, + {{ 3}, 0x2580, "upblock", MOS4 }, {{12}, 0x2584, "dnblock", MOS4 }, {{0x5f}, 0x2588, "block", MOS }, - {{0x15}, 0x258c, "lfblock", MOS }, - {{0x4a}, 0x2590, "rtblock", MOS }, + {{0x15}, 0x258c, "lfblock", MOS }, {{0x4a}, 0x2590, "rtblock", MOS }, {{025,000,012,000,025,000,012,000,025}, 0x2591, "ltshade" }, {{022,011,004,022,011,004,022,011,004}, 0x2592, "shade" }, {{025,037,012,037,025,037,012,037,025}, 0x2593, "dkshade" }, + {{ 4}, 0x2596, NULL, MOS4 }, {{ 8}, 0x2597, NULL, MOS4 }, + {{ 1}, 0x2598, NULL, MOS4 }, {{13}, 0x2599, NULL, MOS4 }, + {{ 9}, 0x259a, NULL, MOS4 }, {{ 7}, 0x259b, NULL, MOS4 }, + {{11}, 0x259c, NULL, MOS4 }, {{ 2}, 0x259d, NULL, MOS4 }, + {{ 6}, 0x259e, NULL, MOS4 }, {{14}, 0x259f, NULL, MOS4 }, /* Geometric shapes */ {{037,021,021,021,021,021,037,000,000}, 0x25a1, "H22073" }, @@ -1795,6 +1800,8 @@ main(int argc, char **argv) if (glyphs[i].flags & MOS) domosaic(glyphs[i].data[0], (glyphs[i].data[0] & 0x20) != 0); + else if (glyphs[i].flags & MOS4) + domosaic4(glyphs[i].data[0]); else { if (plottermode) dochar_plotter(glyphs[i].data, glyphs[i].flags); @@ -2505,6 +2512,19 @@ domosaic(unsigned code, bool sep) emit_path(); } +static void +domosaic4(unsigned code) +{ + + clearpath(); + if (code & 1) tile(0, 6, 3, 11); + if (code & 2) tile(3, 6, 6, 11); + if (code & 4) tile(0, 1, 3, 6); + if (code & 8) tile(3, 1, 6, 6); + clean_path(); + emit_path(); +} + static int byunicode(const void *va, const void *vb) { -- 2.30.2