Note: MS-DOS and Windows are trademarks of Microsoft Corporation.
PC/XT, PC/AT, and PS/2 are trademarks of IBM Corporation.
4DOS is a trademark of J.P. Software.
MKS Toolkit is a trademark of Mortice Kern Systems Inc.
PROCOMM is a trademark of Datastorm Technologies, Inc.
Typing Tutor IV is a trademark of Kriya Systems, Inc.
Desqview and QEMM are trademarks of Quarterdeck.
386MAX is a trademark of Qualitas.
Manufacturers' names are the trademarks of their respective manufacturers.
That should take care of everyone.
Documentation for version 1/93.
This version of NNANSI contains the following improvements
over NNANSI version 9/92:
1. Support of DOS/V, the Japanese version of MS/DOS. (thanks, Akira Kikuchi!)
2. Optional support of extended (101+ key) keyboard added, about a
decade late.
3. ANSI state machine code straightened out. Keyboard remapping function
fixed.
IMPORTANT NOTE: the compiled NNANSI.COM is intended for 80286 or later
systems with "AT" style (12 function key) keyboards and VGA displays. You
will need to recompile on systems that don't meet this requirement.
*********INTRODUCTION
NNANSI.COM (version 1/93) is an improved version of NANSI.SYS
(version 2.2), by Daniel Kegel, which is in turn such an improvement
over ANSI.SYS that *no one* should be without one of these.
If you are using ANSI.SYS, be aware that either of these drivers
will offer greatly improved performance and functionality over
your current driver. Current users of NANSI.SYS with EGA or VGA
displays (and other enhanced ANSI.SYS drivers) will notice still
greater performance and functionality in NNANSI.SYS.
Even if you don't use an ANSI.SYS driver, you will achieve major
performance benefits. (Note that there will be no performance
benefits for programs that write directly to the display).
A short list of improvements of NANSI.SYS (version 3.0) over
ANSI.SYS:
1. Intrinsic 43 or 50 line support (MS-DOS 4.0 now has this).
2. Some additional text mode escape sequences: Insert Lines,
Delete Lines, Insert Characters, Delete Characters.
3. Greater to *much* greater performance.
4. Supports higher resolutions, both text and graphic modes.
5. Graphic mode cursor
A short list of improvements of NNANSI.COM (version 1/93) over
NANSI.SYS:
1. Additional escape sequences: erase to start/end of display,
insert/delete lines in graphic modes, added Set Graphic
Rendition codes (and properly working reverse video,
underline, and invisible modes). Accurate ANSI escape
sequence parsing
2. Graphic cursor support is better, and can be disabled.
3. Intrinsic support for both 43 and 50 line modes on a VGA. The
prompt command can be used to maintain 43 or 50 line display
modes. 40 column support for 43 and 50 line modes.
4. Faster text mode performance; *much* faster scrolling
(when in "fast mode").
5. Much faster performance in 640x350 to 800x600 16 color
graphic modes. Every ANSI control sequence (except
insert/delete characters and blink) work in these modes
as well.
6. Readily configured for enhanced graphic and text modes of
various display cards. Support for several popular cards
are provided.
7. Blink in 16 color graphics modes (up to 800x600) will exclusive-OR
characters.
8. Support for MS-DOS V4.0 and later MODE commands, and properly
clears the display in enhanced modes using command.com's CLS.
9. Driver can be loaded as TSR from the command line.
10. Desqview aware.
11. Supports Japanese DOS/V
On the other hand, NANSI is smaller, and works with MDA as distributed.
**********************LICENSE REQUIREMENTS
Daniel Kegel is the author of NANSI.SYS, of which this is a derived
work. I, Tom Almy, think enough of his efforts and programming skills
that I used NANSI.SYS as a base for NNANSI.COM. NANSI.SYS version 2.2
came with sources and free distribution for personal or educational
use, but prohibits commercial use. I have an agreement with Mr.
Kegel to license NNANSI.COM in accordance with his newest NANSI.SYS
license arrangement:
"If you use this program for education or at home, you are
encouraged to send a US$10 donation to the author. If you use
it for business purposes, you are required to purchase a
right-to-use license by sending US$10 to the author."
Send contributions/user fees to:
Daniel Kegel
1977 N. El Molino
Altadena, CA 91001
You can also reach him at his permanent internet address:
dank@alumni.caltech.edu
Everyone wins with this arrangement!
* Commercial users can now legally use NNANSI.COM
* Personal users can show their gratitude.
* Daniel Kegel can make a little money for his efforts.
* I won't feel guilty for "ripping off" his work.
I place no restrictions on my modifications to NANSI.SYS. I
neither request nor will I accept any contributions for my work
on this program. I made these modifications as part of an effort
to understand the workings of DOS device drivers and the EGA/VGA
display.
On the other hand, I do like to hear from users, satisfied or
(even) not satisfied.
I M P O R T A N T
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Please, if you have problems, check the PROBLEMS section of this
document before contacting me. Greater than 90% of the problem
reports I receive are answered in this section.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
My address is:
tom.almy@tek.com (Internet)
or
Tom Almy
17830 SW Shasta Trail
Tualatin, OR 97062
I also now run a BBS at (503)-620-0307, 1200-9600 (v.32) bps
If you must use the postal service. Enclose a stamped, self-
addressed envelope if you desire a reply.
*********DISTRIBUTED FILES
The distribution has the following files:
readme.1st - READ THIS FIRST
nnansi.com - Driver, with compilation options set as shown
- in the file CONFIG.INC
nnansi.doc - this file
howto.doc - explaination about the different ways to
write to the display
gcon.bat - turns graphic cursor on
gcoff.bat - turns graphic cursor off
fast.bat - turns fast mode on
slow.bat - turns fast mode off
biosw.bat - turns ANSI bios write_tty on
nobiosw.bat - turns ANSI bios write_tty off
25.bat - set 80x25 text mode
43.bat - set 80x43 text mode
50.bat - set 80x50 text mode (VGA only)
run.bat - load NNANSI TSR as full function driver
norun.bat - unload NNANSI TSR when loaded as full
function driver
dtest.exe - Performance testing program for ANSI drivers
stat.com - Print out information about display status
makefile - for Don Kneller's NDMAKE
nnansi.asm - The source file
config.inc - Configuration selections (part of source)
drivers.inc - Display specific macros (part of source)
*********INSTALLATION
NOTE: If you have an MDA (Monochrome or Hercules display adapter) you
will need to reassemble NNANSI first. You will also need to
reassemble if you are using DOS/V, an 8088 processor, an EGA display,
or an original 84 key keyboard. You will probably want to reassemble
to configure for your specific display card (if it is an "Enhanced"
card), will not be using Desqview, are using a DOS prior to version
4.0, or otherwise want other defaults.
NNANSI installs just like ANSI.SYS (or NANSI.SYS), it is a device
driver that you specify in your CONFIG.SYS file:
DEVICE=NNANSI.COM
If you are using code pages, place this command before the
DEVICE=DISPLAY.SYS command, otherwise code pages will not work.
You can also load NNANSI as a TSR (Terminate and Stay Resident)
program instead. To do this, add the following lines to your
AUTOEXEC.BAT file:
NNANSI D
CTTY CON
If you wish to load the driver as a TSR in Desqview or Windows,
see the section on "NNANSI as a TSR". You cannot use the D option,
and the CTTY command is not needed but the driver will have limited
features.
If NNANSI is the last TSR loaded, it can then be removed. See the
section "NNANSI as a TSR" for the special technique necessary to
remove NNANSI.
For optimum performance, run fast.bat and biosw.bat, but if
applications have trouble with either of these, you will have to
revert back to slower operating modes (read section "FAST MODE").
While the supplied compiled driver is suitable for most
installations, you can get better results by customizing the driver
for your display card. To do this you will need an assembler, such as
Borland Turbo Assembler, a text editor, and (optionally) Don
Kneller's NDMAKE program. I understand that Borland's MAKE will also
work.
Some people have asked why I don't have command line options for
the driver or a separate configuring program but require the user to
use an assembler. The reasons:
1. These make the driver larger and possibly slower than it needs to be.
If you insist on a full-featured display driver try FANSI-CONSOLE.
2. I feel that users who are sophisticated enough to be able to utilize
NNANSI either have an assembler or have access to one. This is not
a program for novices.
3. I'm lazy. I'm not interested. I've got other things to do (which pay).
All options are specified in the file CONFIG.INC. Edit that
file and make changes as appropriate. These descriptions assume
the initial default settings:
DOSV (FALSE)
Set true to use with DOS/V. This option will eliminate most of
NNANSI's performance improvements.
VGA (TRUE)
If you have an EGA display, set this to FALSE. You might
also want to set this to FALSE if you have a VGA and are
used to the ESC [=43h sequence giving 50 line mode.
EGA (FALSE)
If you have an EGA, set this to TRUE.
MONO (FALSE)
Must be TRUE if you have a Monochrome Display Adapter (MDA)
or Hercules card either as your sole display or in addition
to a color display controller. If you don't, leave this FALSE
as it both hurts performance and enlarges the driver. You cannot
use an MDA with Desqview and NNANSI at the same time.
TSR (set on tasm command line)
If TRUE, compiles TSR/DRIVER COM file version, otherwise compiles
DRIVER only, SYS file version.
DESQVIEW (TRUE)
If TRUE, and TSR is TRUE, compiles DESQVIEW awareness code.
If you don't intend to use DESQVIEW you should set this to
FALSE.
VESA (FALSE)
Set TRUE if you have a VESA compatible display card BIOS.
You will also need to have a particular display specified
for best results. VESA has been successfully tested with
a Diamond Speedstar card (TSENG4000 set TRUE) and using
Diamond's VESA BIOS extension, and with a Diamond Steath
with built in VESA support. When using built in VESA, there
seems to be a problem in selecting graphics modes via their
VESA mode numbers.
VEGA, PARADISE, STBVGA... (all FALSE)
Set only one of these TRUE to match your enhanced
EGA/VGA display card. If you have a card not on the list
and experience problems with either blotches in enhanced
text mode or poor performance (unsettable background
colors is a clue) in graphics modes CONTACT THE AUTHOR.
BAD_ERASE (FALSE, except if TSENG4000 selected)
Set to true if erase to end of line and erase to start/end of
screen erase the wrong portion of the display
cheap_pc (FALSE)
Set to FALSE for "PC/AT" and "PS/2" class machines which
have 80186 or greater processors.
ext_keybd (TRUE)
Set to TRUE for "PC/AT" and "PS/2" class machines with 101+ key
keyboards (the kind with 12 function keys and separate cursor keys
from the numeric pad).
key_redef (FALSE)
Set to TRUE if you use key redefinition. There are
Trojan Horse programs that take advantage of this
feature, and most people don't use it anyway, so the
default is FALSE.
init_buffer_size (256)
Enlarge if you use key redefinition and don't have
enough room.
quick_char (TRUE)
Faster graphics display in 16 color modes, at cost of
much extra code since this involves added display
routines. Must be TRUE if gbackground is also TRUE.
fast29 (TRUE)
Makes int29 display calls (used by DOS) 15% faster at a
cost of about 100 bytes.
bios_write_tty (TRUE)
The write tty BIOS call is taken over. It will now
perform faster and understand ANSI escape sequences. This
latter feature can be a mixed blessing. This feature can be
disabled at runtime if it is assembled in.
gbackground (TRUE)
Enables setting of non-black background color in 16 color
graphic modes (640x350 to 800x600 resolutions). If set to
TRUE, quick_char must also be set to TRUE. If this feature is
not desired, it is possible (depending on the system) to get
greater performance by defining both gbackground and
quick_char FALSE. This will also save quite a bit of
code. Experiment and see for yourself.
dos4 (TRUE)
Under MS/PC DOS version 4.0 (and 5.0) allows command.com and
mode.com to recognize NNANSI as an ANSI driver. If you are
using older DOS versions, you can define this to be FALSE.
initgc (FALSE)
Graphic mode cursor is initially off. You can turn it on/off
with a control sequence.
initfast (FALSE)
Fast scroll mode is initially off. This also means that
multiple page support is initially on. You can turn it on/off
with a control sequence, and there are other work-arounds as
well.
initbiosw (FALSE)
ANSI bios write_tty is initially off. You can turn it on/off
with a control sequence.
You can then either use the supplied makefile to generate a new
nnansi.sys/nnansi.com or assemble manually as shown (Borland tools
illustrated):
tasm /m5 /DTSR=0 nnansi (Use /m5 for version 2.0 or later)
tlink nnansi,nnansi.sys/m/t (generates nnansi.sys for config.sys)
tasm /m5 /DTSR=1 nnansi
tlink nnansi,nnansi.bin/m/t (generates nnansi.com for config.sys
rename nnansi.bin nnansi.com or TSR use)
The .sys driver offers no advantages other than it takes less memory
while loading (this might be a consideration with some high memory
management programs). For this reason, a .sys version is no longer
distributed.
IMPORTANT NOTE FOR USERS OF BORLAND TURBO ASSEMBLER V3.0:
There is a bug in this version which causes the assembler to hang
when assembling the sys version of NNANSI. The solution is to only
build the com version. The bug is fixed with V3.1.
NOTE FOR MICROSOFT MASM USERS:
With the Microsoft assembler, you will need to make some changes to
the source to avoid the branch out of range errors, and you will need
to use the exe2bin program to convert the linker generated exe file
into a binary image file, which you then have to rename to
NNANSI.SYS or NNANSI.COM.
To correct the branch out of range, you will need to replace the conditional
branch with an conditional branch of the opposite sense around an
unconditional branch to the same destination. Example:
jne foo ; original statement, now "out of range"
becomes:
je new_label
jmp foo
new_label:
You will also need to delete the first few lines in NNANSI.ASM, which
are directives for the Borland Assembler.
**************NNANSI AS A TSR**
NNANSI can now be loaded as a TSR in two modes, limited and full. If
you intend to use NNANSI as a TSR, such as in a Desqview window, or
for temporary use, please read this section carefully.
To load NNANSI in full driver mode, execute the following two commands
(or execute run.bat):
nnansi d
ctty con
This will load the driver such as it runs identically to NNANSI loaded
as a driver in CONFIG.SYS. This means that not only does it take control
of several interrupt vectors, the driver is also linked into the DOS
driver chain. The CTTY command is necessary to force command.com to
"reopen" its console interface to use the NNANSI driver.
This method must not be used within a multitasking environment such
as Microsoft Windows or Desqview, because the relinking of the driver
chain corrupts system integrity. However it may be used to load
NNANSI before running Windows. In the Desqview case, a batch file can
be used to unload NNANSI, run Desqview, and then reload NNANSI when
finished.
Within each DOS window in Windows or Desqview, the limited version of the
NNANSI TSR can be loaded (described below). The copy of NNANSI should
be unloaded before closing the DOS window.
NNANSI in full driver mode can be unloaded using the following procedure
providing it is the last TSR loaded, you are not "shelled out" of a program,
are running the same instance of COMMAND.COM, and did not load NNANSI
"high" using QEMM, 386/MAX, or DOS 5.0. From a batch file, execute:
@echo off
nnansi u
ctty con
The ctty command must be executed immediately after the NNANSI command,
otherwise the system may "crash". The batch file norun.bat is provided
to unload NNANSI.
Note that full driver mode NANNSI must be uninstalled using NNANSI, and
not with a TSR management program. Such programs are incapable of
unchaining NNANSI from the device driver list.
--------------------
NNANSI also has a limited TSR mode. In this mode the driver is not
linked into the DOS driver chain. To load NNANSI in limited mode execute:
nnansi
In limited mode the device status report will not function, nor will
keyboard key reassignment. The DOS MODE command will not change the
number of display lines either. Also the performance improvement for
RAW mode (which gives NNANSI its greatest performance) will not be
available.
You can unload NNANSI which has been loaded in limited mode by executing:
nnansi u
The limited TSR mode driver can be used in a Microsoft Windows or Desqview
window without problems. You can also uninstall the limited mode driver
with a TSR management program.
**************HOW MUCH PERFORMANCE IMPROVEMENT IS THERE?
I have performed considerable testing on an EVEREX 25Mhz 80386
machine with a Video 7 (Headland) Fastwrite VGA display controller
(and its BIOS), under both DOS 3.3 and 4.0. Your results will
probably vary, and BIOS performance without NNANSI will also improve
if the EGA/VGA BIOS is copied to RAM as supported by some vendors and
also possible with QEMM or 386/MAX on 80386 based systems.
Performance is proportional to roughly independent factors, writing
speed and scrolling speed. Writing speed is the rate at which
characters can be drawn on the display without the display scrolling.
Scrolling speed is the rate at which the display can scroll (no
new characters are drawn). Writing speed tends to be independent of
display mode (except graphic modes are slower), while scrolling speed
tends to be proportional to the number of character positions on the
display (except for NNANSI fast mode, which is independent of screen
size).
When using ANSI.SYS rather than no driver at all, there is roughly a
2.3x degradation in performance for writing. Scrolling performance
improves 44% when DOS 4.0 ANSI driver is used, but remains unchanged
with the DOS 3.3 driver.
Compared to no driver, NANSI.SYS (3.0) is 3x to 3.5x faster for
writing, and is roughly 45x faster when writing using DOS in RAW
mode. It is roughly 2x faster scrolling.
Compared to the no driver or other ANSI drivers, NNANSI is 4x faster
in BIOS TTY write calls.
Compared to NANSI.SYS it is 2x faster in INT29 calls, 73% faster in
DOS write calls, but there is no speedup in RAW mode. When fast mode
is used, scrolling is 15x to 25x faster.
This means that text mode programs that take advantage of RAW
mode and buffering can display 100 times faster with NNANSI (and
without scrolling, NANSI) over ANSI.SYS. It works out to about
420,000 characters per second with my fast machine.
NNANSI also has speedups for 16 color graphic modes with resolutions
between 640x350 and 800x600. With the graphic cursor turned on, the
TTY BIOS call is about 10% slower than the standard BIOS call (which
doesn't display a cursor), but other output calls are 2.5x to 3.5x
faster than that of NANSI.SYS. Turning the graphics cursor off
roughly doubles the writing speed of all modes but RAW.
**************FAST MODE **READ THIS!!**
To get maximum speed, NNANSI has what I call Fast Mode. In text
mode, there is more display memory than there are character on
the display. Normally, the BIOS supports display "pages" that you
can switch among. Changing the display page changes the region
of the display memory that is sent to the display. Fast Mode
uses the same technique (changing the starting location of the
viewable memory region) to scroll the display upwards.
Programs that make use of multiple display pages and scroll the
display require that fast mode be turned off. Many debugging programs
use two pages to maintain separate debugging and application
displays. Some of the programs will still work in fast mode if they
have a "swap screens" option ("-ds" for Borland Turbo Debugger, for
instance).
A number of programs that directly access the display don't work if
starting address has changed. These programs may not work properly in
fast mode (or for that matter in display pages other than the first).
NNANSI tries its best to work with these programs by resetting the
display start location if any program does the "get display mode" or
"scroll/clear display" BIOS calls. These calls are typically done by
potentially offending applications when they start. As long as the
display never scrolls under NNANSI control everything will work fine.
A typical problem occurs in programs that have DOS or "shell escape"
commands. If the DOS sub-shell (invocation of COMMAND.COM) causes the
display to scroll, then upon exiting the sub-shell the display will
be ruined. The solution to this problem (other than not using fast
mode) is to clear the screen just before exiting the sub-shell.
Please note that Windows 3.0 in Enhanced Mode has problems with DOS
applications running in a window using NNANSI's fast mode. You will
need to run Windows with NNANSI in slow mode.
Some offending programs can be "fixed" by invoking them from a
batch file (or alias if you use MKS Toolkit, 4DOS, ANARKEY...)
which first clears the screen. Or you can use a batch file which
turns off fast mode, then turn fast mode back on again after
program execution. Example:
echo ^[[=98l
offendingpgm %1 %2 %3 %4 %5
echo ^[[=98h
Where "^[" is the escape (code 27) character.
Batch programs have been provided to enable (fast.bat) and disable
(slow.bat) fast mode.
NNANSI can also speed up programs that use BIOS calls for writing
characters. NNANSI adds the ANSI features to such calls, which can
cause problems with some applications. This feature is turned off by
default, but can be enabled via an ANSI sequence or by executing the
supplied batch file biosw.bat. The feature can be disabled with
nobiosw.bat.
******************WRITING PROGRAMS FOR BEST PERFORMANCE
To get best performance in programs you write, you must put the
display in RAW mode, and buffer output.
In assembler, you can set raw mode with the following sequence
(adapt this for other languages):
mov ax,4400h ; get device status
mov bx, 1 ; of device 1 (standard output)
int 21h
xor dh, dh ; clear upper byte
mov saved_state, dx ; save it for later
mov ax, 4401h ; set new status
or dl, 20h ; with raw bit set
int 21h
Reset raw mode before terminating the application:
mov ax, 4401h ; set status to original values
mov bx, 1
mov dx, saved_state
int 21h
There is a fixed amount of overhead (and it is high) for each
DOS call. Therefore you should buffer up write requests into a
single call. With the C language, you can use the setvbuf() call
to set a large buffer size.
Even if you don't follow this advice, you will get a major
performance improvement over ANSI.SYS (or no device driver at
all).
Programs using RAW mode and buffering easily beat the
performance of the supposedly high speed console drivers
supplied in Turbo C and Microsoft C. And by using ANSI control
sequences your programs can be made portable to other systems!
*****************TYPICAL PROBLEMS
ALSO READ THE SECTION "FAST MODE"
SYSTEM CRASHES UPON BOOTING, OR DISPLAY BADLY CORRUPTED EVEN IN
STANDARD 80x25 TEXT MODE.
You have assembled NNANSI with cheap_pc set to FALSE on an 8088 based
system, or you are trying to use NNANSI on an MDA or Hercules
Graphics equipped system without reassembling with MONO equal TRUE.
This can also happen if you are using DOS/V with NNANSI not compiled for
DOS/V operation.
KEYBOARD IS "LOCKED"
You have set ext_keybd TRUE when you have an original style (10 function
key) keyboard, or a BIOS that does not support the extended keyboard.
ON A VGA, SETTING 43 LINE MODE GIVES 43 LINES, WHEN IT GAVE 50
WITH AN OLDER VERSION OF NNANSI.SYS OR WITH NANSI.SYS
This is correct. There is now a new setting for 50 line mode. If
you require that 43 line mode give 50 lines, recompile the
system with VGA set to FALSE.
I USED AN EARLIER VERSION OF NNANSI, AND NOW I FIND THAT NNANSI IS
MUCH SLOWER THAN BEFORE
The defaults have changed. You now have to run FAST and BIOSW for
fastest operation.
I USED AN EARLIER VERSION OF NNANSI, AND NOW FIND MY DISPLAY
INEXPLICABLY CHANGING MODES
The commands for graphic cursor, fast mode, and line wrap are
more restrictive. Use the new batch files for fast, slow, gcon, and
gcoff, and change any code of your own appropriately.
ON A VGA, SETTING 50 LINE MODE CAUSES VERY STRANGE BEHAVIOR
Two possibilities. Your display adapter is really an EGA, or you
have compiled NNANSI with VGA set to FALSE. In the latter
case, you can get 50 line mode by setting 43 line mode, while in
the former case you can't get 50 line mode at all.
ON A VGA, AFTER LEAVING 43/50 LINE MODE THE CURSOR IS IN THE
MIDDLE OF THE CHARACTER BLOCK
Recompile the driver with EGA set to FALSE.