diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-05-06 09:55:36 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-05-07 16:58:12 +0300 |
commit | d4b8634136355205591131be6d0df52b85f04879 (patch) | |
tree | 8bad60c7692d181380de9bb82a3320dbba5c0558 | |
parent | 50f07cbee2da2a71a49d99ee2723a182cc3d86b4 (diff) | |
download | videoteco-fork-d4b8634136355205591131be6d0df52b85f04879.tar.gz |
DOS: detect ANSIPLUS driverv7.0
Actually, we cannot (easily) detect NANSI.SYS, so we don't enable optimizations by default.
You will have to `set TECO_TERM=nansi.sys` to enable optimizations.
Of course you can also still set the TERMCAP variable.
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | teco.h | 2 | ||||
-rw-r--r-- | tecterm.c | 42 |
3 files changed, 40 insertions, 17 deletions
@@ -68,14 +68,13 @@ set up correctly (`. owsetenv.sh`): ### Features and limitations -* Being ported from UNIX, it outputs escape sequences and requires +* Being ported from UNIX, it outputs escape sequences and requires an ANSI driver like [ANSI.SYS](https://en.wikipedia.org/wiki/ANSI.SYS), [NANSI.SYS](http://www.kegel.com/nansi/) or [ANSIPLUS](http://www.sweger.com/ansiplus/). - There is special NANSI.SYS support, so that driver is preferred. - Video TECO has a builtin termcap "database", but you can - set the `TERMCAP` environment variable to a custom termcap definition file - to tweak definitions. + ANSIPLUS is detected automatically, which enables some optimizations. + To enable NANSI.SYS-specific optimizations, try `set TECO_TERM=nansi.sys`. + You can also set the TERMCAP environment variable to a custom termcap definition file. * The console size/resolution is automatically detected. * It supports the same Csh-like wildcard expansions as on UNIX for command-line parameters. @@ -99,6 +98,7 @@ set up correctly (`. owsetenv.sh`): ### TODO +- [ ] Make use of ANSIPLUS scroll regions. - [ ] Re-evaluate Video TECO's lookaside buffers. But they probably don't make sense considering the memory constraints. - [ ] Dosbox has problems with drawing the command line cursor. @@ -106,6 +106,7 @@ set up correctly (`. owsetenv.sh`): so a moving reverse `' '` leaks the attribute to the preceding or following cell. It also cannot deal with more than 25 rows. + Interestingly, this persists even after loading ANSIPLUS. But perhaps it's not so important to support Dosbox. -- [ ] Command line help (`-h`) +- [ ] ommand line help (`-h`) - [ ] SvarDOS package @@ -84,7 +84,7 @@ #ifndef AUTO_DATE /* should be passed in from the build system */ -#define AUTO_DATE "$Date: 2025/05/06 00:03:29 $" +#define AUTO_DATE "$Date: 2025/05/07 16:57:28 $" #endif /* @@ -1073,7 +1073,7 @@ term_flush() static int term_isvga(void) { - union REGS regs; + union REGS regs = {0}; regs.x.ax = 0x1a00; int86(VIDEO, ®s, ®s); return regs.h.al == 0x1a && regs.h.bl > 6; @@ -1082,7 +1082,7 @@ term_isvga(void) static int term_isega(void) { - union REGS regs; + union REGS regs = {0}; if(term_isvga()) return 0; regs.h.ah = 0x12; regs.h.bl = 0x10; @@ -1090,16 +1090,38 @@ term_isega(void) return regs.h.bl != 0x10; } +#if 0 /** - * Detect NANSI.SYS (4.0c or later). + * Returns true if any of ANSI.SYS, NANSI.SYS (4.0c or later) + * or ANSIPLUS (2.0 or later) are detected. */ static inline int -term_have_nansi(void) +term_have_ansi_driver(void) { - union REGS regs; + union REGS regs = {0}; regs.x.ax = 0x1a00; int86(0x2f, ®s, ®s); - return regs.h.al == 0xFF; + return regs.h.al == 0xff; +} +#endif + +/** + * Returns true if ANSIPLUS driver is installed. + */ +static inline int +term_have_ansiplus(void) +{ + union REGS regs = {0}; + regs.x.ax = 0x1a00; + regs.x.bx = ('A' << 8) | 'N'; + regs.x.cx = ('S' << 8) | 'I'; + regs.x.dx = ('+' << 8) | '+'; + int86(0x2f, ®s, ®s); + /* + * NOTE: The ANSIPLUS documentation is wrong. + * AL won't be 0. + */ + return regs.h.al == 0xff && regs.x.cx != (('S' << 8) | 'I'); } #endif /* MSDOS */ @@ -1410,8 +1432,8 @@ char *termcap = */ ":cd=\\E[2J:te=\\E[2J:" /* - * Some NANSI.SYS extensions, i.e. not supported by MS-DOS ANSI.SYS. - * They are enabled dynamically by overwriting the leading null byte. + * Some NANSI.SYS/ANSIPLUS extensions, i.e. not supported by MS-DOS ANSI.SYS. + * They may be enabled dynamically by overwriting the leading null byte. */ "\0al=\\E[1L:AL=\\E[%dL:dl=\\E[1M:DL=\\E[%dM:ic=\\E[1@:dc=\\E[1P:"; #endif /* MSDOS */ @@ -1459,8 +1481,8 @@ FILE *fd; if(cp == NULL){ cp = termcap; #ifdef MSDOS - /* enable extended NANSI.SYS definitions */ - if(term_have_nansi()) *strchr(cp, '\0') = ':'; + /* enable extended ANSIPLUS definitions */ + if(!strcmp(term_name,"nansi.sys") || term_have_ansiplus()) *strchr(cp, '\0') = ':'; #endif } dp = current_termcap_description = buffer; |