From: Ben Harris Date: Mon, 21 Oct 2024 08:31:57 +0000 (+0100) Subject: Make co-ordinate systems more sensible X-Git-Tag: bedstead-3.246~105 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=32079c7b7547fa4ba5921070a92501576696aee3;p=bedstead.git Make co-ordinate systems more sensible The SAA5050 character images appear at the bottom-right corner of the character cell, with a blank pixel to the top and the left. This can be seen if you put am alphanumeric character and a mosaic graphics character side-by-side, since mosaic graphics characters fill the entire character cell. However, when I first made Bedstead, I put the character images in the top-right corner, and the co-ordinate system matched that. When I fixed this in 2013 (commit 7bea0c6fadc35de50ea08eb184d4b15a7b411ef3), I just did it by adjusting the final transformation of the vector co-ordinates, leaving all the internal co-ordinate systems intact. This was visible when I added mosaic graphics, which had to be offset by one pixel to compensate. Now I've finally corrected the problem somewhat properly. Pixel co-ordinates count from (0,0) in the top-left corner of the character cell. Vector co-ordinates count from (0,0) in the bottom-left corner and are offset to the baseline on emission. The conversion between the two forms is still weirdly spread all over the place though. --- diff --git a/bedstead.c b/bedstead.c index 6759768..65c1c11 100644 --- a/bedstead.c +++ b/bedstead.c @@ -198,7 +198,8 @@ static void glyph_complement(void); static struct glyph { union { - char data[YSIZE]; + /* Top row (and left column) don't appear in ROM. */ + char data[YSIZE - 1]; char const *alias_of; }; int_least32_t unicode; @@ -2620,10 +2621,17 @@ static bool getpix(char const data[YSIZE], int x, int y, unsigned flags) { - if (x < 0 || x >= XSIZE || y < 0 || y >= YSIZE) + /* + * Pixel co-ordinates count from (0,0) in the top left of the + * character cell. In the glyph array, the top row isn't + * represented and the columns are right-aligned in a char. + * Like the top row, the left column of the character cell + * always reads as 0. + */ + if (x < 1 || x >= XSIZE || y < 1 || y >= YSIZE) return 0; else - return (data[y] >> (XSIZE - x - 1)) & 1; + return (data[y - 1] >> (XSIZE - x - 1)) & 1; } static bool plottermode = false; @@ -3349,7 +3357,7 @@ emit_contour(point *p0) do { printf(" %g %g %s 1\n", (double)p->v.x / XSCALE, - (double)p->v.y / YSCALE - 3*YPIX, + (double)p->v.y / YSCALE - 2*YPIX, p == p0 && p->next ? "m" : "l"); p1 = p->next; p->prev = p->next = NULL; @@ -3684,12 +3692,12 @@ domosaic(unsigned code, bool sep) { clearpath(); - if (code & 1) tile(0 + sep, 8 + sep, 3, 11); - if (code & 2) tile(3 + sep, 8 + sep, 6, 11); - if (code & 4) tile(0 + sep, 4 + sep, 3, 8); - if (code & 8) tile(3 + sep, 4 + sep, 6, 8); - if (code & 16) tile(0 + sep, 1 + sep, 3, 4); - if (code & 32) tile(3 + sep, 1 + sep, 6, 4); + if (code & 1) tile(0 + sep, 7 + sep, 3, 10); + if (code & 2) tile(3 + sep, 7 + sep, 6, 10); + if (code & 4) tile(0 + sep, 3 + sep, 3, 7); + if (code & 8) tile(3 + sep, 3 + sep, 6, 7); + if (code & 16) tile(0 + sep, 0 + sep, 3, 3); + if (code & 32) tile(3 + sep, 0 + sep, 6, 3); clean_path(); emit_path(); } @@ -3699,10 +3707,10 @@ domosaic4(unsigned code, bool sep) { clearpath(); - if (code & 1) tile(0 + sep, 6 + sep, 3, 11); - if (code & 2) tile(3 + sep, 6 + sep, 6, 11); - if (code & 4) tile(0 + sep, 1 + sep, 3, 6); - if (code & 8) tile(3 + sep, 1 + sep, 6, 6); + if (code & 1) tile(0 + sep, 5 + sep, 3, 10); + if (code & 2) tile(3 + sep, 5 + sep, 6, 10); + if (code & 4) tile(0 + sep, 0 + sep, 3, 5); + if (code & 8) tile(3 + sep, 0 + sep, 6, 5); clean_path(); emit_path(); }