From 6852ffbe99ae81a6bcba47b1c931ad0d24c1abc5 Mon Sep 17 00:00:00 2001 From: Matthew Mondor Date: Sat, 9 Apr 2022 05:38:16 +0000 Subject: [PATCH] Blinking now behaves like in xterm. --- MATT/TODO.txt | 5 ----- MATT/test/m.sh | 2 ++ hacks/analogterm.c | 27 +++++++++++++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/MATT/TODO.txt b/MATT/TODO.txt index 5580c77..c394388 100644 --- a/MATT/TODO.txt +++ b/MATT/TODO.txt @@ -3,11 +3,6 @@ BUILD - make TODO -- Currently, blinking also implies inverse, but inverse takes precedence, - stopping blinking when both are enabled. Perhaps implement blinking like - xterm does, where the text can be normal or inverse while blinking or not. - In blinking+reverse mode, the background should not blink but the foreground - text should. - All uint8_t mode bits are already allocated. Ideally we would need a larger word but this will affect operations using memset(3), memmove(3) and memcpy(3). Double-underline, italics and striked currently lack a mode bit. diff --git a/MATT/test/m.sh b/MATT/test/m.sh index 33b97d9..bf8ec25 100755 --- a/MATT/test/m.sh +++ b/MATT/test/m.sh @@ -1,2 +1,4 @@ #!/bin/sh printf '\033[1mbold\033[m \033[2mdim\033[m \033[3mitalic\033[m \033[4munderline\033[m \033[5mblink\033[m \033[6mbold\033[m \033[7minverse\033[m \033[8minvisible\033[m \033[9mstriked\033[m \033[21mdouble-underline\033[m\n' +printf '\033[1m\033[7mBoldInverse\033[m \033[1m\033[5mBoldBlink\033[m \033[7m\033[5mInverseBlink\033[m \033[1m\033[5m\033[7mBoldInverseBlink\033[m\n' +printf '\033[2m\033[7mDimInverse\033[m \033[2m\033[5mDimBlink\033[m \033[7m\033[5mInverseBlink\033[m \033[2m\033[5m\033[7mDimInverseBlink\033[m\n' diff --git a/hacks/analogterm.c b/hacks/analogterm.c index feeb693..2daec2d 100644 --- a/hacks/analogterm.c +++ b/hacks/analogterm.c @@ -443,7 +443,7 @@ analogterm_one_frame (analogterm_sim_t *sim) sim->dec->powerup=sim->curtime; } - blinkphase=sim->curtime/0.2; /* XXX 0.8 */ + blinkphase=sim->curtime/0.6; /* XXX 0.8 */ /* The blinking rate was controlled by 555 timer with a resistor/capacitor time constant. Because the capacitor was electrolytic, the flash rate @@ -576,19 +576,26 @@ analogterm_one_frame (analogterm_sim_t *sim) /* With 25 lines the offset was changed to 3 to avoid loss */ pp=&sim->inp->signal[row+ANALOGTV_TOP+/*4*/3][ANALOGTV_PIC_START+100]; for (col=0; col<80; col++) { - int rev, level; + int rev, level, olevel, iblink; int c = st->textlines_char[textrow][col] & 0xff; unsigned char m = st->textlines_mode[textrow][col] & 0xff; XImage *im = sim->text_im[m & TMODE_GFX ? 1 : 0]; - rev = ((m & (TMODE_INVERSE | TMODE_BGCOLOR)) != 0) || - ((m & TMODE_BLINK) != 0 && st->blink); + rev = ((m & (TMODE_INVERSE | TMODE_BGCOLOR)) != 0); level = TMODE_NORMAL_LEVEL; if ((m & (TMODE_BOLD/* | TMODE_FGCOLOR XXX */)) != 0) level = TMODE_BOLD_LEVEL; - else if ((m & (TMODE_DIM)) != 0) + else if ((m & TMODE_DIM) != 0) level = TMODE_DIM_LEVEL; + olevel = level; + if ((m & TMODE_BLINK) != 0 && st->blink) + level = ANALOGTV_BLACK_LEVEL; + if ((m & (TMODE_INVERSE | TMODE_BLINK)) == + (TMODE_INVERSE | TMODE_BLINK)) + iblink = 1; + else + iblink = 0; /* * Font is 96 7x8 glyphs including embedded spacing. @@ -607,7 +614,15 @@ analogterm_one_frame (analogterm_sim_t *sim) pix = XGetPixel(im, (c - 32) * 7 + i, row % 8); if ((m & TMODE_UNDERLINE) != 0 && lastrow) pix = 1; - *pp++ = ((pix^rev) ? level : ANALOGTV_BLACK_LEVEL); + if (iblink) { + if (!pix) + pix = olevel; + else + pix = (!st->blink ? ANALOGTV_BLACK_LEVEL : + olevel); + } else + pix = ((pix ^ rev) ? level : ANALOGTV_BLACK_LEVEL); + *pp++ = pix; } } } -- 2.9.0