ANSI.SYS

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Template:Short description 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").

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 <templatestyles src="Mono/styles.css" />ANSI.COM,[1] <templatestyles src="Mono/styles.css" />NANSI.SYS[2] and <templatestyles src="Mono/styles.css" />ANSIPLUS.EXE[3] to attempt to change this.Template:Third-party inline

Usage

To use <templatestyles src="Mono/styles.css" />ANSI.SYS under DOS, a line is added to the <templatestyles src="Mono/styles.css" />CONFIG.SYS (or <templatestyles src="Mono/styles.css" />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 <templatestyles src="Mono/styles.css" />ANSI.SYS is found, and options can be a number of optional switches to control the behaviour. <templatestyles src="Mono/styles.css" />ANSI.SYS may also be loaded into upper memory via <templatestyles src="Mono/styles.css" />DEVICEHIGH/<templatestyles src="Mono/styles.css" />HIDEVICE.

  • <templatestyles src="Mono/styles.css" />/K use extended keyboard BIOS functions (INT 16h) rather than standard ones[4] This made the F11 and F12 keys work.
  • <templatestyles src="Mono/styles.css" />/L force number of lines
  • <templatestyles src="Mono/styles.css" />/R adjust line scrolling to support screen readers[4]
  • <templatestyles src="Mono/styles.css" />/S or <templatestyles src="Mono/styles.css" />/SCREENSIZE set screensize
  • <templatestyles src="Mono/styles.css" />/X support redefinition of extended key codes independent of standard codes[4]

Functionality

Using this driver, programs that write to the standard output can write escape sequences to 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. They could also change 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 <templatestyles src="Mono/styles.css" />ANSI.SYS is very 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 such as <templatestyles src="Mono/styles.css" />NANSI.SYS[2] that interface directly with the video memory, in a similar way to most DOS programs that have a full-screen user interface.

Template:Tt checked if this driver was in use, and changed the <templatestyles src="Mono/styles.css" />CLS command to use an escape sequence instead of a BIOS call.[5]

Keyboard remapping

An interesting (mis)feature of <templatestyles src="Mono/styles.css" />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 was 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:

  • Many replacements for <templatestyles src="Mono/styles.css" />ANSI.SYS support a command line switch to disable the key remapping feature, f.e. the option <templatestyles src="Mono/styles.css" />/S (Secure) in Datalight ROM-DOS[7] or NANSI.SYS[2] of FreeDOS. Other ANSI drivers like ANSIPLUS can be configured to disable the redefinition of keys as well.[3]
  • Some replacements were deliberately designed never to support the keyboard remapping functions.[8][9]
  • PKWARE produced a terminate-and-stay-resident program, PKSFANSI (PK Safe ANSI), which filters out keyboard remapping escape codes as they are written to the standard output.[10] This has the advantage that the user can load some useful remappings from a text file and then run PKSFANSI to prevent further, possibly malicious remappings.

Occurrence

<templatestyles src="Mono/styles.css" />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]

<templatestyles src="Mono/styles.css" />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 <templatestyles src="Mono/styles.css" />COMMAND.COM prompt. These uses were overshadowed by the use of <templatestyles src="Mono/styles.css" />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 "<templatestyles src="Mono/styles.css" />ESC [" (that is, <templatestyles src="Mono/styles.css" />0x1B 0x5B).[12] The ANSI standard also defines an alternative single-byte CSI code <templatestyles src="Mono/styles.css" />0x9B, which is not supported by ANSI.SYS (this code instead drew a cent sign Template:Angbr from CP437).

Standard DOS <templatestyles src="Mono/styles.css" />ANSI.SYS drivers support only the following sub-set of ANSI escape sequences:[12]

Sequence Effect
ESC [ r A Cursor up (CUU)
ESC [ r B Cursor down (CUD)
ESC [ c C Cursor forward (CUF)
ESC [ c D Cursor back (CUB)
ESC [ r;c f Horizontal and vertical position (HVP)
ESC [ r;c H Cursor position (CUP)
ESC [ n J Erase display (ED) (n=0, 2 or n=0, 1, 2)[nb 1]
ESC [ n K Erase in line (EL) (n=0 or n=0, 1, 2)[nb 1]
ESC [ n m Select graphic rendition (SGR) (n=0..47)
ESC [ 6 n Device status report (DSR) requests cursor position,
returned as cursor position report (CPR):
ESC [ r;c R
ESC [ s Save cursor position (SCP)
ESC [ u Restore cursor position (RCP)

There are also some escape sequences specific to the implementation of <templatestyles src="Mono/styles.css" />ANSI.SYS. They are not generally supported by ANSI consoles in other operating systems.

Sequence Effect
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 q Enable (n=1) or disable (n=0) <templatestyles src="Mono/styles.css" />/X support[nb 3]
ESC [ L Insert line (IL)[nb 4]
ESC [ M Delete line (DL)[nb 4]
ESC $ ) 1 Switch keyboard input mode to Korean (Hangul)[nb 5]
ESC ( 2 Switch keyboard input mode to English[nb 5]
ESC [ + Enable console output[nb 6]
ESC [ - Disable console output[nb 6]
ESC [ a;b;... p Set key re-definement (SKR/KR)
Script error: No such module "anchor". Screen modes
Mode Description Mode Description
0 40 × 25 monochrome 1 40 × 25 color
2 80 × 25 monochrome 3 80 × 25 color
4 320 × 200 color 5 320 × 200 monochrome
6 640 × 200 monochrome
7 Wrap at end of line[nb 7]
13 320 x 200 color (graphics) 14 640 x 200 color (16-color graphics)
15 640 x 350 monochrome (2-color graphics) 16 640 x 350 color (16-color graphics)
17 640 x 480 monochrome (2-color graphics) 18 640 x 480 color (16-color graphics)
19 320 x 200 color (256-color graphics)
114 640 x 480 color (16-color graphics)[nb 8] 115 640 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

<templatestyles src="Reflist/styles.css" />

  1. a b Arguments 0, 1, 2 are only supported and distinguished by Japanese versions of MS-DOS and PC DOS <templatestyles src="Mono/styles.css" />ANSI.SYS. Western issues of <templatestyles src="Mono/styles.css" />ANSI.SYS will not support or not distinguish between them. They are, however, also supported by Multiuser DOS.
  2. a b c d Lead-in prefix '>' is only supported in Japanese versions of MS-DOS, PC DOS and DR-DOS <templatestyles src="Mono/styles.css" />ANSI.SYS to access special Japanese display modes.
  3. This non-standard escape sequence is only supported by MS-DOS and PC DOS <templatestyles src="Mono/styles.css" />ANSI.SYS. It can be used to enable or disable extended keyboard support at runtime similar to the <templatestyles src="Mono/styles.css" />ANSI.SYS <templatestyles src="Mono/styles.css" />/X startup option.
  4. a b These non-standard 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. a b 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 <templatestyles src="Mono/styles.css" />ANSI.SYS.
  6. a b These non-standard escape sequences to disable and reenable any output to the CON: device are supported by <templatestyles src="Mono/styles.css" />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. a b Video modes 114 and 115 are only supported by Japanese DOS/V issues of <templatestyles src="Mono/styles.css" />ANSI.SYS found in DR DOS 6.0, Novell DOS 7 and higher.

Script error: No such module "Check for unknown parameters".

References

<templatestyles src="Reflist/styles.css" />

  1. Script error: No such module "Citation/CS1".
  2. a b c Script error: No such module "citation/CS1".
  3. a b Script error: No such module "citation/CS1".
  4. a b c Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1". (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 <templatestyles src="Mono/styles.css" />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 <templatestyles src="Mono/styles.css" />NWDOSTIP.TXT file.) [1]
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".
  8. Script error: No such module "citation/CS1".
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "Citation/CS1".
  12. a b c d Script error: No such module "citation/CS1". (NB. DR-DOS 7 user documentation, description of <templatestyles src="Mono/styles.css" />ANSI.SYS escape sequences (incomplete))
  13. Script error: No such module "citation/CS1".

Script error: No such module "Check for unknown parameters".

External links

  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".