ANSI.SYS

Last updated

ANSI.SYS is a device driver in the DOS family of operating systems that provides extra console functions through ANSI escape sequences. It is partially based upon a subset of the text terminal control standard proposed by the ANSI X3L2 Technical Committee on Codes and Character Sets (the "X3 Committee").

Contents

As it was not installed by default, and was notoriously slow, little software took advantage of it and instead resorted to directly manipulating the IBM PC hardware. A number of third-party alternatives that ran at reasonable speed were created, such as ANSI.COM, [1] NANSI.SYS [2] and ANSIPLUS.EXE [3] to attempt to change this.[ third-party source needed ]

Usage

To use ANSI.SYS under DOS, a line is added to the CONFIG.SYS (or CONFIG.NT under Windows NT based versions of Windows) file that reads:

DEVICE=drive:\path\ANSI.SYS options

where drive: and path are the drive letter and path to the directory in which the file ANSI.SYS is found, and options can be a number of optional switches to control the behaviour. ANSI.SYS may also be loaded into upper memory via DEVICEHIGH / HIDEVICE .

Functionality

Using this driver, programs that write to the standard output can make use of the 16 text foreground colors and 8 background colors available in VGA-compatible text mode, make text blink, change the location of the cursor on the screen, and blank the screen. It also allows for the changing of the video mode from standard 80×25 text mode to a number of different graphics modes (for example, 320×200 graphics mode with text drawn as pixels, though ANSI.SYS is not able to turn individual pixels on and off).

The standard ANSI.SYS is relatively slow as it maps escape sequences to BIOS calls (which managed to be designed so that two calls were needed to put a character on the screen and move the cursor right). Several companies made third-party replacements that interface directly with the video memory, in a similar way to most DOS programs that have a full-screen user interface.

By default, the internal DOS command CLS works by directly calling the corresponding BIOS function to clear the screen, thereby prominently violating the hardware abstraction model. [5]

Keyboard remapping

An interesting feature of ANSI.SYS is the ability to remap any key on the keyboard in order to perform shortcuts or macros for complex instructions. Using special escape sequences, the user can define any keystroke that has a character-code mapping to simulate an arbitrary sequence of such keystrokes. [6] This feature was also used to create simple trojans out of text files laced with nefarious keyboard remaps, known as "ANSI bombs". A number of products were released to protect users against this:

Occurrence

ANSI.SYS appeared in MS-DOS 2.0, the first version of the operating system supporting device drivers. [11] It was supported by all following versions of MS-DOS. It is also present in many non-Microsoft DOS systems, e.g. IBM PC DOS and DR-DOS. [12]

ANSI.SYS was required to run some software that used its cursor and color control functions. [12] It could also be used to enable elaborate color codes in the COMMAND.COM prompt. These uses were overshadowed by the use of ANSI.SYS in BBSes; ANSI escape sequences were used to enable BBSes to send text graphics more elaborate than ASCII art, and to control the cursor in ways that were used in a number of online games and similar features.

Most versions of Windows did not support ANSI escape codes in any useful way (it could be used by MSDOS emulation in some versions). In Windows 10 support for similar escape sequences was built into the Win32 console (the text terminal window), but must be activated using the Windows API function SetConsoleMode by setting the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag. [13]

Features

CSI (Control Sequence Introducer) is a placeholder for the common two-byte escape lead-in sequence "ESC [" (that is, 0x1B 0x5B). [12] The ANSI standard also defines an alternative single-byte CSI code 0x9B, which is not supported by ANSI.SYS (this code instead drew a cent sign ¢ from CP437).

Standard DOS ANSI.SYS drivers support only the following sub-set of ANSI escape sequences: [12]

SequenceEffect
ESC [r ACursor up (CUU)
ESC [r BCursor down (CUD)
ESC [c CCursor forward (CUF)
ESC [c DCursor back (CUB)
ESC [r;c fHorizontal and vertical position (HVP)
ESC [r;c HCursor position (CUP)
ESC [n JErase display (ED) (n=0, 2 or n=0, 1, 2) [nb 1]
ESC [n KErase in line (EL) (n=0 or n=0, 1, 2) [nb 1]
ESC [n mSelect graphic rendition (SGR) (n=0..47)
ESC [ 6 nDevice status report (DSR) requests cursor position,
returned as cursor position report (CPR):
ESC [r;c R
ESC [ sSave cursor position (SCP)
ESC [ uRestore cursor position (RCP)

There are also some escape sequences specific to the implementation of ANSI.SYS. They are not generally supported by ANSI consoles in other operating systems.

SequenceEffect
ESC [n h
ESC [ ?n h
ESC [ =n h
ESC [ >n h [nb 2]
Set screen mode (SM) [nb 2]
ESC [n l
ESC [ ?n l
ESC [ =n l
ESC [ >n l [nb 2]
Reset screen mode (RM) [nb 2]
ESC [n qEnable (n=1) or disable (n=0) /X support [nb 3]
ESC [ LInsert line (IL) [nb 4]
ESC [ MDelete line (DL) [nb 4]
ESC $ ) 1Switch keyboard input mode to Korean (Hangul) [nb 5]
ESC ( 2Switch keyboard input mode to English [nb 5]
ESC [ +Enable console output [nb 6]
ESC [ -Disable console output [nb 6]
ESC [a;b;... pSet key re-definement (SKR/KR)
Screen modes
ModeDescriptionModeDescription
040 × 25 monochrome140 × 25 color
280 × 25 monochrome380 × 25 color
4320 × 200 color5320 × 200 monochrome
6640 × 200 monochrome
7Wrap at end of line [nb 7]
13320 x 200 color (graphics)14640 x 200 color (16-color graphics)
15640 x 350 monochrome (2-color graphics)16640 x 350 color (16-color graphics)
17640 x 480 monochrome (2-color graphics)18640 x 480 color (16-color graphics)
19 320 x 200 color (256-color graphics)
114640 x 480 color (16-color graphics) [nb 8] 115640 x 475 color (16-color graphics) [nb 8]

In some DOS implementations, video modes above 7 are not documented. Under Multiuser DOS, the only valid argument in conjunction with PCTERM is 7.

See also

Notes

  1. 1 2 Arguments 0, 1, 2 are only supported and distinguished by Japanese versions of MS-DOS and PC DOS ANSI.SYS. Western issues of ANSI.SYS will not support or not distinguish between them. They are, however, also supported by Multiuser DOS.
  2. 1 2 3 4 Lead-in prefix '>' is only supported in Japanese versions of MS-DOS, PC DOS and DR-DOS ANSI.SYS to access special Japanese display modes.
  3. This non-standard escape sequence is only supported by MS-DOS and PC DOS ANSI.SYS. It can be used to enable or disable extended keyboard support at runtime similar to the ANSI.SYS/X startup option.
  4. 1 2 These non-standand escape sequences to insert and delete lines are only supported by Japanese versions of MS-DOS and PC DOS. They are also supported by Western issues of Multiuser DOS, but not by DR-DOS.
  5. 1 2 These non-standard escape sequences to switch between the Korean and English keyboard input modes are only supported by Korean versions of MS-DOS, PC DOS and DR-DOS ANSI.SYS.
  6. 1 2 These non-standard escape sequences to disable and reenable any output to the CON: device are supported by ANSI.SYS of DR-DOS 7.02 and higher only. They are used to mute the console output during boot, for example in conjunction with DR-WebSpyder boot floppies.
  7. A value of 7 is used to either enable (with SM) or disable (with RM) the wrap around at the end of rows. If enabled, the option causes extra characters to wrap onto the next line, while these characters will be lost, if wrapping is disabled.
  8. 1 2 Video modes 114 and 115 are only supported by Japanese DOS/V issues of ANSI.SYS found in DR DOS 6.0, Novell DOS 7 and higher.

Related Research Articles

<span class="mw-page-title-main">Scroll Lock</span> Computer key

Scroll Lock is a lock key on most IBM-compatible computer keyboards.

<span class="mw-page-title-main">ANSI escape code</span> Method used for display options on video text terminals

ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape character and a bracket character, are embedded into text. The terminal interprets these sequences as commands, rather than text to display verbatim.

<span class="mw-page-title-main">COMMAND.COM</span> Default command line for MS-DOS and Windows 9x

COMMAND.COM is the default command-line interpreter for MS-DOS, Windows 95, Windows 98 and Windows Me. In the case of DOS, it is the default user interface as well. It has an additional role as the usual first program run after boot, hence being responsible for setting up the system by running the AUTOEXEC.BAT configuration file, and being the ancestor of all processes.

<span class="mw-page-title-main">Computer terminal</span> Computer input/output device for users

A computer terminal is an electronic or electromechanical hardware device that can be used for entering data into, and transcribing data from, a computer or a computing system. The teletype was an example of an early-day hard-copy terminal and predated the use of a computer screen by decades.

An environment variable is a user-definable value that can affect the way running processes will behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.

<span class="mw-page-title-main">Conventional memory</span> First 640K of RAM under DOS

In DOS memory management, conventional memory, also called base memory, is the first 640 kilobytes of the memory on IBM PC or compatible systems. It is the read-write memory directly addressable by the processor for use by the operating system and application programs. As memory prices rapidly declined, this design decision became a limitation in the use of large memory capacities until the introduction of operating systems and processors that made it irrelevant.

<span class="mw-page-title-main">Text-based user interface</span> Type of interface based on outputting to or controlling a text display

In computing, text-based user interfaces (TUI), is a retronym describing a type of user interface (UI) common as an early form of human–computer interaction, before the advent of bitmapped displays and modern conventional graphical user interfaces (GUIs). Like modern GUIs, they can use the entire screen area and may accept mouse and other inputs. They may also use color and often structure the display using box-drawing characters such as ┌ and ╣. The modern context of use is usually a terminal emulator.

CONFIG.SYS is the primary configuration file for the DOS and OS/2 operating systems. It is a special ASCII text file that contains user-accessible setup or configuration directives evaluated by the operating system's DOS BIOS during boot. CONFIG.SYS was introduced with DOS 2.0.

AUTOEXEC.BAT is a system file that was originally on DOS-type operating systems. It is a plain-text batch file in the root directory of the boot device. The name of the file is an abbreviation of "automatic execution", which describes its function in automatically executing commands on system startup; the filename was coined in response to the 8.3 filename limitations of the FAT file system family.

<span class="mw-page-title-main">Windows Console</span> Infrastructure for console applications in Microsoft Windows

Windows Console is the infrastructure for console applications in Microsoft Windows. An instance of a Windows Console has a screen buffer and an input buffer. It allows console apps to run inside a window or in hardware text mode. The user can switch between the two using the Alt+↵ Enter key combination. The text mode is unavailable in Windows Vista and later. Starting with Windows 10, however, a native full-screen mode is available.

<span class="mw-page-title-main">DOS/V</span> Variant of PC DOS/MS-DOS developed for Japan

DOS/V is a Japanese computing initiative starting in 1990 to allow DOS on IBM PC compatibles with VGA cards to handle double-byte (DBCS) Japanese text via software alone. It was initially developed from PC DOS by IBM for its PS/55 machines, but IBM gave the driver source code to Microsoft, who then licensed a DOS/V-compatible version of MS-DOS to other companies. Kanji fonts and other locale information are stored on the hard disk rather than on special chips as in the preceding AX architecture. As with AX, its great value for the Japanese computing industry is in allowing compatibility with foreign software. This had not been possible under NEC's proprietary PC-98 system, which was the market leader before DOS/V emerged. DOS/V stands for "Disk Operating System/VGA". In Japan, IBM compatible PCs became popular along with DOS/V, so they are often referred to as "DOS/V machine" or "DOS/V pasocom" even though DOS/V operating systems are no longer common.

EMM386 is the expanded memory manager of Microsoft's MS-DOS, IBM's PC DOS, Digital Research's DR-DOS, and Datalight's ROM-DOS which is used to create expanded memory using extended memory on Intel 80386 CPUs. There also is an EMM386.EXE available in FreeDOS.

<span class="mw-page-title-main">Esc key</span> Computer key

On computer keyboards, the Esc keyEsc is a key used to generate the escape character. The escape character, when sent from the keyboard to a computer, often is interpreted by software as "stop", and when sent from the computer to an external device marks the beginning of an escape sequence to specify operating modes or characteristics generally.

tree (command) Shell command in various operating systems

In computing, tree is a recursive directory listing command or program that produces a depth-indented listing of files. Originating in PC- and MS-DOS, it is found in Digital Research FlexOS, IBM/Toshiba 4690 OS, PTS-DOS, FreeDOS, IBM OS/2, Microsoft Windows, and ReactOS. A version for Unix and Unix-like systems is also available.

.sys is a filename extension used in MS-DOS applications and Microsoft Windows operating systems. They are system files that contain device drivers or hardware configurations for the system.

<span class="mw-page-title-main">DOS</span> Group of closely related IBM PC-compatible operating systems

DOS is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of Microsoft's MS-DOS and a rebranded version, IBM PC DOS, both of which were introduced in 1981. Later compatible systems from other manufacturers include DR-DOS (1988), ROM-DOS (1989), PTS-DOS (1993), and FreeDOS (1998). MS-DOS dominated the IBM PC compatible market between 1981 and 1995.

<span class="mw-page-title-main">Linux console</span> Console of the Linux kernel

The Linux console is a system console internal to the Linux kernel. A system console is the device which receives all kernel messages and warnings and which allows logins in single user mode. The Linux console provides a way for the kernel and other processes to send text output to the user, and to receive text input from the user. The user typically enters text with a computer keyboard and reads the output text on a computer monitor. The Linux kernel supports virtual consoles – consoles that are logically separate, but which access the same physical keyboard and display. The Linux console are implemented by the VT subsystem of the Linux kernel, and do not rely on any user space software. This is in contrast to a terminal emulator, which is a user space process that emulates a terminal, and is typically used in a graphical display environment.

Control-Alt-Delete is a computer keyboard command on IBM PC compatible computers, invoked by pressing the Delete key while holding the Control and Alt keys: Ctrl+Alt+Delete. The function of the key combination differs depending on the context but it generally interrupts or facilitates interrupting a function. For instance, in pre-boot environment or in MS-DOS, Windows 3.0 and earlier versions of Windows or OS/2, the key combination reboots the computer. Starting with Windows 95, the key combination invokes a task manager or security related component that facilitates ending a Windows session or killing a frozen application.

References

  1. Mefford, Michael (1989-02-07). "ANSI.com: Download It Here". PC Magazine . Retrieved 2011-08-10.
  2. 1 2 Kegel, Daniel; Almy, Tom; Auer, Eric (1999-02-28). "NANSI – An Enhanced MS-DOS Console Driver". 4.0. Dan Kegel's Web Hostel. Archived from the original on 2018-05-19. Retrieved 2011-08-10.
  3. 1 2 Sweger, Kristofer (2007) [2000]. "Configuring ANSIPLUS". Archived from the original on 2018-10-04. Retrieved 2018-10-04.
  4. 1 2 3 "Guide to using ANSI.SYS". Archived from the original on 2007-06-23. Retrieved 2017-09-11.
  5. Paul, Matthias R. (1997-07-30) [1994-05-01]. NWDOS-TIPs Tips & Tricks rund um Novell DOS 7, mit Blick auf undokumentierte Details, Bugs und Workarounds. Archived from the original on 2017-09-10. Retrieved 2014-08-06.{{cite book}}: |work= ignored (help) (NB. NWDOSTIP.TXT is a comprehensive work on Novell DOS 7 and OpenDOS 7.01, including the description of many undocumented features and internals. It is part of the author's yet larger MPDOSTIP.ZIP collection maintained up to 2001 and distributed on many sites at the time. The provided link points to a HTML-converted older version of the NWDOSTIP.TXT file.)
  6. "ANSI Keyboard codes - ANSI.SYS Key and Extended Key Codes". µVGA - VGA Microcontroller interface. SECONS Ltd. 2012. Archived from the original on 2017-09-11. Retrieved 2017-09-11.
  7. Datalight, Inc.; GPvNO (April 2005) [1999]. "Datalight ROM-DOS User's Guide" (PDF). Datalight, Inc. 3010-0200-0716. Retrieved 2018-09-16.
  8. "PTS-DOS 2000 Pro User Manual" (PDF). Buggingen, Germany: Paragon Technology GmbH. 1999. Archived (PDF) from the original on 2018-05-12. Retrieved 2018-05-12.
  9. Günther, Jens; Ernst, Tobias (2004-04-25) [1996]. Ellsässer, Wolfgang (ed.). "Inoffizielle deutschsprachige PTS-DOS-FAQ (PTS/FAQD)" [Inofficial German PTS-DOS FAQ] (in German). Retrieved 2018-10-02.
  10. Massingill, Michael D. Pearson, Dave (ed.). "PK SAFE ANSI (PKSFANSI.COM)". Archived from the original on 2017-09-11. Retrieved 2017-09-11.
  11. Field, Tim (November 1983). "Installable Device Drivers for PC DOS 2.0 - Inside the IBM PC". BYTE . 8 (11): 188–196. Retrieved 2016-03-19.
  12. 1 2 3 4 "Chapter 9: Configuring the System". Caldera, Inc. 1998. Archived from the original on 2017-09-10. Retrieved 2017-09-10. (NB. DR-DOS 7 user documentation, description of ANSI.SYS escape sequences (incomplete))
  13. "Console Virtual Terminal Sequences". Windows Console. 20 September 2022.