couple of DECgraphics optimizations
If a termcap entry for ending attributes and color also contains the code to switch from secondary font back to primary (HE_resets_AS hack), maybe strip the AS code out of HE (and clear the HE_resets_AS flag) when setting up DECgraphics. Affects whether nethack sends extra AS sequences while rendering a run of VT line-drawing chars. My HE doesn't reset AS so that aspect hasn't been exercized. When switching back and forth between normal and line-drawing, defer the switch away from line-drawing if the character will be rendered the same in both character sets (uppercase letter, digit, most punctuation). That might just defer the AE, but could skip it and next AS depending on what characters are written. The cycle might repeat an arbitrary number of times, avoiding sending many AS+AE combinations rather than just one. Both of these optimizations are pretty small but reducing the number of characters sent from a server to a remote user is worthwhile.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1377 $ $NHDT-Date: 1707525192 2024/02/10 00:33:12 $
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1380 $ $NHDT-Date: 1708290308 2024/02/18 21:05:08 $
|
||||
|
||||
General Fixes and Modified Features
|
||||
-----------------------------------
|
||||
@@ -2542,6 +2542,11 @@ tiles: male and female variations in monsters.txt; tested only with tile2bmp
|
||||
tty: use bright colors directly on supporting terminals
|
||||
tty: if a message is marked urgent, override message suppression initiated
|
||||
by user having typed ESC at previous --More-- prompt
|
||||
tty+DECgraphics: when ready to print a normal character after having printed
|
||||
a line-drawing character, don't switch back to normal character set
|
||||
unless current char is one that gets rendered differently as a line
|
||||
drawing char (mainly lowercase letters) so that we might be able to
|
||||
avoid the need to switch to line drawing for next char that uses that
|
||||
Unix: can define NOSUSPEND in config.h or src/Makefile's CFLAGS to prevent
|
||||
unixconf.h from enabling SUSPEND without need to modify unixconf.h
|
||||
Unix: support --nethackrc=filename on the command line; same effect as
|
||||
|
||||
@@ -399,6 +399,13 @@ tty_decgraphics_termcap_fixup(void)
|
||||
#if defined(ASCIIGRAPH) && !defined(NO_TERMS)
|
||||
/* some termcaps suffer from the bizarre notion that resetting
|
||||
video attributes should also reset the chosen character set */
|
||||
if (dynamic_HIHE) {
|
||||
(void) strsubst(nh_HE, AE, "");
|
||||
(void) strsubst(nh_HE, ctrlO, "");
|
||||
}
|
||||
/* if AE has prefixing, substituting empty string for it probably
|
||||
didn't work; however, if that _did_ work, we'll be able to
|
||||
avoid HE_resets_AS and the degraded performance it causes */
|
||||
{
|
||||
const char *nh_he = nh_HE, *ae = AE;
|
||||
int he_limit, ae_length;
|
||||
@@ -426,6 +433,16 @@ tty_decgraphics_termcap_fixup(void)
|
||||
++nh_he, --he_limit;
|
||||
}
|
||||
}
|
||||
/* some termcaps have AS load the line-drawing character set as
|
||||
primary instead of having initialization load it as secondary
|
||||
(we've already done that init) and then having AS simply switch
|
||||
to secondary (change to do that now); they also have AE load
|
||||
the US character set, which we avoid by not touching primary
|
||||
[this speedup won't happen if they have delay prefixing though] */
|
||||
if (!strcmp(AS, "\033(0") && !strcmp(AE, "\033(B")) {
|
||||
AS = ctrlN;
|
||||
AE = ctrlO;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* TERMLIB */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 wintty.c $NHDT-Date: 1702002970 2023/12/08 02:36:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.376 $ */
|
||||
/* NetHack 3.7 wintty.c $NHDT-Date: 1708290310 2024/02/18 21:05:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.386 $ */
|
||||
/* Copyright (c) David Cohrs, 1991 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2229,11 +2229,9 @@ tty_putstr(winid window, int attr, const char *str)
|
||||
/* if ^C occurs, player is prompted with "Really quit?" and that
|
||||
prompt is issued via tty_putstr(WIN_MESSAGE); if ^C happens
|
||||
while writing DECgraphics chars, the prompt text would be
|
||||
rendered as VT line-drawing characters unless we do this */
|
||||
if (GFlag) {
|
||||
graph_off();
|
||||
GFlag = FALSE;
|
||||
}
|
||||
rendered as VT line-drawing characters unless we do this;
|
||||
also, if color was in progress it wouldn't be switched off */
|
||||
end_glyphout();
|
||||
#endif
|
||||
/* if message is designated 'urgent' don't suppress it if user has
|
||||
typed ESC at --More-- prompt when dismissing an earlier message;
|
||||
@@ -3710,19 +3708,12 @@ g_putch(int in_ch)
|
||||
}
|
||||
(void) putchar((ch ^ 0x80)); /* Strip 8th bit */
|
||||
} else {
|
||||
/*
|
||||
* TODO?
|
||||
* for DECgraphics, we only need to switch back from the
|
||||
* line drawing character set to the normal one if 'ch' is
|
||||
* a lowercase letter or one of a handful of punctuation
|
||||
* characters (the range is contiguous but somewhat odd):
|
||||
* if (GFlag && ch >= 0x5f && ch <= 0x7e).
|
||||
* Leaving it on for other characters might result in only
|
||||
* deferring this graph_off(), but it could possibly skip
|
||||
* both this graph_off() and the need for next graph_on()
|
||||
* depending on whatever follows 'ch'.
|
||||
*/
|
||||
if (GFlag) {
|
||||
/* for DECgraphics, we only need to switch back from the line
|
||||
drawing character set to the normal one if 'ch' is a lowercase
|
||||
letter or one of a handful of punctuation characters (the
|
||||
range is contiguous but somewhat odd); deferring graph_off()
|
||||
now might allow skipping both it and next potential graph_on() */
|
||||
if (GFlag && ch >= 0x5f && ch <= 0x7e) {
|
||||
graph_off();
|
||||
GFlag = FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user