home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best Objectech Shareware Selections
/
UNTITLED.iso
/
boss
/
util
/
misc
/
016
/
vgasave.doc
< prev
next >
Wrap
Text File
|
1993-03-07
|
86KB
|
1,691 lines
VGAsave Version 1.93 2/28/93
====================================================================
Copyright (c) 1992, 1993 Bill Javurek
====================================================================
System Requirements
===================
VGA.
Important: This product is not compatible with Microsoft Windows. See
usage notes below for info regarding MS Windows.
Introduction to VGAsave
=======================
VGAsave is yet another screen saver. The design philosophy behind this
screen saver is twofold:
1. To use the smallest amount of memory possible. VGAsave requires
352 bytes of memory (448 bytes with the int 33h handler
installed).
2. To allow the user some control over the screen saver.
VGAsave also has the ability to detect the use of a mouse and treat it
similar to keystroke on the keyboard. This is a nice feature when using
programs, such as, the dosshell which use a mouse as the primary input
device. However, due to the first requirement mentioned above VGAsave
does not suppress any mouse event used to restore a saved screen.
So, be forewarned that any action on the mouse used to restore a blanked
screen will be passed on to the program currently running as if nothing
happened. Hence, if you press a button on the mouse to restore the
screen, the program currently running will also detect the button press.
I would strongly recommend sticking to some type of nondestructive action
like nudging the mouse slightly to restore a blanked screen.
Note: The keystrokes used to restore a blanked screen must be a
valid keystroke and will be suppressed by VGAsave. By the
term "valid keystroke," it is meant that you have to hit a
letter, number, function key, etc. to restore the screen.
Hitting the alt, ctrl, or shift keys alone will NOT restore
the screen. I usually use the space bar, but that's a matter
of preference.
Features
========
* A hot key which may be used to blank the screen at anytime.
* Detects mouse movement to restore a blanked screen.
* User selected time out.
* User selected hot key.
* Help screen.
* Off and On options to disable and enable VGAsave once
VGAsave is resident in memory.
* An interactive menu to control various options after
it has been loaded into memory. Simply type "VGAsave"
at the DOS prompt to start VGAsave. Then type "VGAsave"
again to bring up the menu.
* Command line switches for controlling VGAsave directly
from the DOS prompt or from batch files.
* Minimal resident memory requirements -- 352 bytes to be
exact (448 if the int 33h handler is installed).
* Supports DOS 5.0 upper memory blocks when loaded with
DOS 5.0's loadhigh command.
* Its freeware.
Freeware Notice
===============
VGAsave is released as FREEWARE and may not be sold under any
condition. The copyright for VGAsave remains the sole property
of the author. Modifications are prohibited.
If you redistribute VGAsave, please distribute the entire package which
consists of VGAsave.com, Whatsnew, Readme, and VGAsave.doc.
Disclaimer
==========
This program is provided as is without any written or implied
warranty.
Starting VGAsave
================
VGAsave may be started with a default time out of 2 minutes by entering
VGAsave at the DOS prompt. You may optionally specify a new time out by
using /c:[time out in seconds] as a command line argument. For example,
entering "VGAsave /c:300" will start VGAsave with a time out value of
300 seconds or 5 minutes. The /m- command line switch to disable the
mouse intercept, and the /key: switch to override the default hot key
described below may also be used when starting VGAsave.
The IRQ line that VGAsave uses for its mouse intercept may be specified
with the /mirq command line switch. An int 33h handler can be loaded
by using the /int33 switch. The usage of the /mirq and /int33 is
discussed in the section entitled "Mouse Problems". See the section
entitled "Command Line Switches" for full explanation of the command line
switches.
Below are some examples on starting VGAsave.
Examples: C:>VGAsave Start VGAsave with default values.
======== (Default values are shown below.)
C:>VGAsave /m- Start VGAsave and disable the mouse
intercept. You can turn the mouse
intercept back on once VGAsave is loaded
by using the /m+ switch described below.
Note that since you can turn the mouse
back on when you load VGAsave with the
/m- switch. When used during loading,
this switch has the same overall effect
if you were to start VGAsave then run
it again with the /m- switch. Hence,
VGAsave will report the same information
concerning the mouse whether or not this
switch is used during start up.
C:>VGAsave /c:300 Start VGAsave with a time out value of
5 minutes. Again, you can later change
this.
C:>VGAsave /key:Alt-9 Start VGAsave and use alt-9 as a
hot key to blank the screen on
demand. This may be also changed
after VGAsave is loaded.
C:>VGASave /mirq:3 Start VGAsave and force VGAsave
to use IRQ 3 for the mouse
intercept. See "Mouse Problems"
below before using the switch.
C:>VGAsave /int33 Start VGAsave with the hook int 33h.
Read the section "Mouse Problems"
before using this switch.
Any combination of the command line switches shown above
may be used when starting VGAsave. For example,
C:>VGAsave /c:300 /m- /Key:Alt-9
Sets the time out value to 5 minutes, disables the mouse
intercept, sets the hot key to Alt-9.
See the section entitled "Controlling VGAsave after loading"
for information on how to change VGAsave's settings after
it has been started.
Once the time out value has been reached VGAsave, will blank the screen
and return control back the program that is currently running. Hence,
your program will continue to run as if nothing happened even if the
screen is blanked. Once the screen is blanked, it may be restored by
pressing any key on the keyboard or by moving the mouse.
Default Settings for VGAsave
=============================
Saver: Enabled
Mouse Intercept: (Enabled if you have a mouse)
Time Out: 120 seconds
Hot Key: Alt-0
Controlling VGAsave after loading
=================================
Once VGAsave has been loaded in memory, commands may be passed to it in
two ways.
1. Issuing "VGAsave" at the DOS prompt will bring up a menu of
choices.
2. Issuing VGAsave save at the DOS command prompt with one
or more command line arguments.
Interactive Menu
================
Running VGAsave.com without any command line arguments once the screen
saver has been loaded into memory will bring up the following menu of
choices. Note that this means you have to run VGAsave more than once
to get the menu. The first time you run the program, VGAsave loads
the screen saver code into memory. The second time you run VGAsave, the
menu will be displayed if no command line switches were used.
VGAsave already installed.
Press <R> to remove from memory
<-> to disable VGAsave
<+> to enable VGAsave
<N> to blank the screen now
<C> for a new time out
<M> to enable mouse intercept
<D> to disable mouse intercept
<K> for new hot key
<S> for VGAsave settings
<?> for help
or any other key to continue:
* All the functions listed in the menu above have a command
line equivalent which are outlined below along with an
explanation of what each function does. A listing of the
command line parameters may be obtained by using "?" from
the above menu. There is also a command line option, /i?,
which may be used in batch files to obtain the current status
of VGAsave, and an /unblank switch which can be used to force
the screen to unblank from within batch files. See the
discussion on "Command Line Switches" below for further
information on the /i? and /unblank switches.
* Note that the keys used to select a menu option are not case
sensitive. In other words, either "S" or "s" will select the
VGAsave settings option form the menu.
* Selecting option "C" for a new time out value will display the
current time out and bring up the following prompt:
Enter the new time out in seconds or hit <enter> to quit:
If you change you mind at this point and decide that you don't
to change the time out, just hit the enter key with an empty
input field. Otherwise, just type in the desired time out in
seconds and hit enter.
Destructive backspacing is supported and the escape key will
clear the entire input field. Note the time out value must be a
whole number between 10 and 3600. If you try and enter more
than 4 digits, VGAsave will beep at you since that is automatically
invalid. If you enter a value too large or too small VGAsave
will report an error along with the proper command line syntax
for changing the time out value and kick you out of the program
without changing the time out value.
* Selecting option "K" from the menu will bring up the following
screen of possible hot key choices:
Alt-A Alt-B Alt-C Alt-D Alt-E Alt-F Alt-G
Alt-H Alt-I Alt-J Alt-K Alt-L Alt-M Alt-N
Alt-O Alt-P Alt-Q Alt-R Alt-S Alt-T Alt-U
Alt-V Alt-W Alt-X Alt-Y Alt-Z
Alt-0 Alt-1 Alt-2 Alt-3 Alt-4 Alt-5 Alt-6
Alt-7 Alt-8 Alt-9 None
The hot key currently being used by VGAsave will be highlighted.
Simply use the cursor controls to move the highlight bar
to the desired key and hit the enter key or the space bar
to select that key.
The highlight bar will "wrap" around the menu if you hit a
cursor key that points to a location off the menu. Please note
that since the keys are divided into 2 groups on the screen,
numbers and letters, the highlight bar wraps as follows:
Horizontal Wrapping Vertical Wrapping
Alt-A <==> Alt-Z Alt-A <==> Alt-7
Alt-G <==> Alt-H Alt-B <==> Alt-8
Alt-N <==> Alt-O Alt-C <==> Alt-9
Alt-U <==> Alt-V Alt-D <==> None
Alt-0 <==> None Alt-E <==> Alt-4
Alt-6 <==> Alt-7 Alt-F <==> Alt-5
Alt-G <==> Alt-6
In other words, the vertical cursor controls fully wrap around
the menu. But, the horizontal ones wrap in a manner so that
the highlight bar will always remain in the upper or lower portion
of the menu.
Command Line Switches
=====================
/? Displays a help message -- Note that VGAsave need not
be loaded in memory to display the help message. In
other words, issuing "VGAsave /?" at the DOS prompt
when VGAsave is not currently loaded in memory will
cause it to display a help message outlining the
command line parameters without loading VGAsave into
memory.
/c:n Changes the time out value to n seconds and
10 ≤ n ≤ 3600 -- This command line argument may
be specified when VGAsave is initially being loaded
into memory.
/off Disables VGAsave -- useful for programs that don't
require much user interaction, such as, gif viewers or
programs, such as, Microsoft Windows which are not
compatible with VGAsave.
/on Enables VGAsave -- when it has been disabled with /off
Note: /on and /off can be used to trick VGAsave into
resetting its internal clock to 0 as follows:
VGAsave /off ; disables VGAsave and
; resets the current time
; count to 0
VGAsave /on ; enables VGAsave
This is sometimes useful in batch files.
/r Removes VGAsave from memory.
See section below on "Removing VGAsave from Memory".
/now Forces the screen to immediately blank -- may be useful
for batch files. The same action can be accomplished
directly from the keyboard by using the user-selected
hot key (Alt-0 by default). Note that this command
forces VGAsave to be enabled otherwise there would be
no means to restore the screen if VGAsave was disabled.
/unblank Forces the screen to immediately if it is blank. If
the screen is not blanked, the only effect this command
will have is to set VGAsave's internal time count to
zero. This switch is intended for use in batch files.
It makes no sense to type it in from the command line
since the first key you hit to type in the command will
cause the screen to wake up.
Take the follow example for a batch file:
@echo off
rem this is optional
vgasave /now
rem Now run some program(s) that
rem take(s) a long time to complete
slowpgm.exe
vgasave /unblank
If you are running DOS 5 or 4DOS, a similar thing
can be accomplished from the command line using the
command line separator (ctrl-T in DOS 5).
Example:
C:>slowpgm.exe<ctrl-T>VGAsave /unblank
Note: In the above line, <ctrl-T> means hold
down the control key and hit the T key.
This will produce a pilcrow character on the
screen.
/m- Disables mouse intercept -- can be used to disable the
screen restoring on mouse action feature. This command
line switch may be used when starting VGAsave. (Only
useful if you have a mouse.)
If you do use this command on start up, it has the overall
effect of starting VGAsave and then issuing VGAsave /m- after
VGAsave has been started. Hence, the same behavior can be
expected from VGAsave if you were to do the following:
C:>VGAsave (load VGAsave into memory)
C:>VGAsave /m- (turn off mouse intercept)
So, if VGAsave is giving an error related to the mouse
when its initially loaded into memory, using the /m- switch
on start up will not cause VGAsave to quit reporting the
message. VGAsave will load as usual then if the /m- switch
is found, VGAsave will disable the mouse intercept. The
reason it works like this is that if you did load VGAsave
with /m- for some reason you could later enable the mouse
with /m+ without removing VGAsave from memory and
re-installing it. I'm not sure if I like it this way or
not.
/m+ Enables mouse intercept -- used to restore the screen
restoring feature on a mouse action when it has been
disabled with /m-. (Only useful if you have a mouse.)
/int33 Instructs VGAsave to install an int 33h handler during
start up. The interrupt 33h handler is required by VGAsave
if VGAsave fails to unblank the screen with a mouse action
after a program has been run or is running that has mouse
support. (Only useful if you have a mouse.)
THIS COMMAND LINE SWITCH MAY ONLY BE USED DURING START UP.
Read the section "Mouse Problems" before using this switch.
/mirq: Allows the user to manually specify the IRQ line to be
hooked by VGAsave for the mouse intercept. (Only useful
if you have a mouse.)
THIS COMMAND LINE SWITCH MAY ONLY BE USED DURING START UP.
THIS COMMAND SHOULD ONLY BE USED IF YOU ARE EXPERIENCING
DIFFICULTIES WITH YOUR MOUSE RESTORING A BLANKED SCREEN.
Syntax: /mirq:[num]
Where [num] is the IRQ line that you want VGAsave to
hook. Valid IRQ lines are from 2 to 15. Read the section
below entitled "Mouse Problems" before using this switch.
Example: VGAsave /mirq:3
Tells VGAsave to hook up IRQ 3 which is typically
used by COM2. Hence, you are telling VGAsave that
you have a serial mouse that is using IRQ 3.
/key: This command line switch changes the hot key used to
blank the screen on demand.
Syntax: /KEY:[key]
where [key] is one of the following:
Alt-0 to Alt-9, Alt-A to Alt-Z
None (disables the hot key)
Note that Alt-0 is the default
For example, to set the hot key to Alt-5, issue
"VGAsave /Key:Alt-5" at the DOS prompt. If the
none option is selected (i.e. "VGAsave /Key:none"),
then the hot key support to blank the screen will
be disabled -- the hot key may be later enabled
again by selecting a hot key other than None.
The /key: command line switch may also be used
when VGAsave is initially loaded into memory.
You can also change the hot key interactively
after starting VGAsave by issuing "VGAsave" at
the DOS prompt and selecting option "K" from the
menu. This will bring up a menu of possible choices
and some instructions.
/S Displays the current settings of VGAsave. For example,
issuing "VGAsave /s" at the DOS prompt after starting
VGAsave without any command line options displays the
following information:
Copyright (c) 1992, 1993 Bill Javurek
Freeware. No Modifications. May not be sold.
Alt-0 may be used to blank the screen at any time.
Saver: Enabled
Mouse Intercept: (Enabled if you have a mouse)
Time Out: 120 seconds
Hot Key: Alt-0
which reflects VGAsave's default settings.
/i? Returns the status of VGAsave by means of an exit code.
This option provides a means for batch files to
obtain the current status of VGAsave and branch with
an ErrorLevel statement. This option has no
interactive (i.e. menu option) equivalent like the other
command line options do.
The possible exit codes are as follows:
Exit Code = 1 ==> VGAsave is not installed
Exit Code = 2 ==> VGAsave is currently disabled
Exit Code = 0 ==> Neither of the above are true :)
These Exit codes may be used by a batch file in the
following manner:
VGAsave /i?
If ErrorLevel == 2 Goto VGAsaveDisabled
If ErrorLevel == 1 Goto VGAsaveNotInstalled
Note that the ErrorLevel must be tested in "reverse
order" since DOS checks for greater than or equal to
when using an If statement in a batch file.
IMPORTANT: VGAsave will only return a non-zero
exit code when this command line switch is used.
In all other cases, the exit code for VGAsave will
be zero.
Notes On Command Line Usage
===========================
The "/i?" switch has highest priority. Using this command will cause
VGAsave to return its current status and exit the program. ALL OTHER
COMMANDS WILL BE IGNORED.
The help command "/?" has second highest priority. Using this command
will cause VGAsave to display a help message and exit the program. ALL
OTHER COMMANDS WILL BE IGNORED.
The remaining commands may be used individually or in groups of
compatible commands. The following table shows the INCOMPATIBLE command
groups.
/r with any thing else ==> Can't remove the screen saver and
send commands to the resident code
at the same time.
/off /on ==> Can't turn the screen saver on and off
at the same time.
/m+ /m- ==> Can't have the mouse intercept enabled
and disabled at the same time.
/off /now ==> The screen saver must be enabled to use
the /now switch. (If the saver is
currently disabled, and the /now switch
is used without the /off switch, VGAsave
will enable itself and blank the screen).
If VGAsave detects an invalid command group, it will ignore the
conflicting commands and report an error. If any other valid commands
were included in the command line, they will be processed. For example,
issuing "VGAsave /off /m+ /m-" will disable VGAsave (/off switch) and
report an error message for the two conflicting commands (/m+ and /m-).
VGAsave is also capable of detecting multiple command line conflicts.
Try "VGAsave /m- /m+ /off /on /now /r".
The command must be proceeded by either a forward slash, /, a back
slash, \, or a dash, -. In other words, issuing "VGAsave /r",
"VGAsave \r", or "VGAsave -r" all have the same effect. The forward
slash has been used above for purposes of illustration. However, the
back slash or the dash may also be used.
Also note that the command line is not case sensitive, i.e. the
command /r is identical to /R.
One final point on command line usage, the /mirq and /int33 command
line switches may only be used when VGAsave is initially loaded into
memory.
Batch File Usage Notes
======================
If you call VGAsave in a batch file to disable it or whatever, you
can hide VGAsave's messages by redirecting its output to the DOS
NUL device.
Example: VGAsave /off >nul
You can try the above example at the DOS command prompt for a test.
Then try VGAsave /on to enable VGAsave and see a message similar to
the one suppressed by the DOS I/O redirection.
Compatibility Issues
====================
Some software will not function properly with VGAsave due to the
manner in which the keyboard and mouse interrupts are used. For
example, Microsoft Windows is completely incompatible with VGAsave.
On the other hand, some software is only partially compatible with
VGAsave. In particular, some games capture the keyboard interrupt
to increase speed, and VGAsave will not be able to detect any
keystrokes. Hence, when the screen blanks, it cannot be restored by
pressing a key -- any key pressed will be processed directly by the
game. However, when using VGAsave in conjunction with some games
the screen may be restored by moving the mouse which can best be
described as a partial incompatibility. The only way to find out if
a problem such as this exists is to try VGAsave. If a problem does
exist, use VGAsave /off before starting the incompatible application.
Then VGAsave /on can be used after running the application. If this
is a satisfactory solution a batch file can then be written to launch
the application which turns VGAsave off before running the program and
then turns VGAsave back on afterward.
Some users have reported problems with the mouse support. The
basic scenario is that everything is fine until an application is
launched that uses the mouse. VGAsave then no longer recognizes
the presence of the mouse. This topic is discussed in the section
entitled "Mouse Problems below.
A potential compatibility problem also may exist with some keyboard
enhancement programs since VGAsave directly manipulates the BIOS keyboard
buffer. This issue is discussed under the section entitled
Technical Info.
Note for Microsoft Windows
==========================
Since Windows is a multitasking environment, it handles the use
of software interrupts differently than DOS does, and in enhanced
mode windows uses a completely different memory addressing scheme.
Hence, most TSR's will not function properly under Windows. In
the case of VGAsave, the screen will blank according to the specified
time out value. However, Windows will not allow VGAsave to properly
detect any mouse motion or keyboard action to restore the screen. So,
your stuck with a blank screen that can't restored without somehow
exiting Windows (which is tough when you can't see what you are doing)
or rebooting the system. Therefore, I recommend launching Windows
from a batch file as follows:
VGAsave /off > nul
Win.com
VGAsave /on > nul
The "> nul" is used to hide VGAsave's messages and may be omitted.
You can make the batch file a little more spiffy by using the /i?
option as follows:
VGAsave /i?
If ErrorLevel == 2 Goto RunWindows
rem VGAsave is already off
If ErrorLevel == 1 Goto RunWindows
rem VGAsave not installed
rem Get to this point if VGAsave is installed and
rem active
VGAsave /off > nul
win.com
VGAsave /on > nul
Goto End
:RunWindows
win.com
:End
rem End of batch file
This problem is not unique to VGAsave and has occurred with other
screen savers that I have tried in the past. This is one of the
reasons that prompted me to write VGAsave. At least with VGAsave,
you can temporarily disable it with /off while using Windows. Whereas
with most other screen savers, you are forced to reboot the system
before running Windows to get the screen saver out of memory since a
means to disable the screen blanking function is not usually provided.
Windows 3.0
===========
The rstmouse utility is no longer needed with Windows 3.0 when VGAsave
1.93 is used. VGAsave now forces a mouse reset with an int 33h, service
00h call each time the mouse is enabled or the VGAsave is enabled.
This was necessary for VGAsave to function properly when started with
the /int33 switch.
What if VGAsave doesn't work?
=============================
If VGAsave is having difficulty recognizing the mouse on your
system, read the section on Mouse Problems and follow the
recommendations outlined in that section. Then if VGAsave is still
giving you trouble, the discussion here may be of some help.
VGAsave was written in what I consider a robust manner. But, some
problems still could arise.
First, if you are experiencing problems and you are loading VGAsave
high, try loading it into base memory. I've had some bad experiences
loading TSR's high which I don't really want to recall. So, this could
be a problem. If VGAsave works fine in base memory but malfunctions
when loaded high, the only thing that can be done is to rearrange
the order in which you load all your TSR's in the autoexec.bat. My
understanding here is that you can run into problems loading TSR's
high since the UMB's are non-contiguous and fixed in size.
If you are loading VGAsave in base memory and still having trouble, the
next logical step is to boot the system off of a floppy loading just
command.com, the mouse driver (if you have a mouse) and VGAsave. If the
problem goes away then VGAsave is conflicting with another TSR that
you are using. I can't stress this point enough. If you are having
problems, remove all unnecessary TSR's and device drivers before you
determine that you have found a bug in VGAsave. Now if VGAsave works
when it is the only thing loaded besides command.com and the mouse
driver, try restoring your config.sys and rebooting. If all everything
is still fine at this point, start adding your TSR's back into your
autoexec.bat one by one rebooting after adding each one. Eventually,
you should come to a point where VGAsave malfunctions. Then you know
which TSR VGAsave is conflicting with. Once you have reached that
point try loading VGAsave before and after the conflicting TSR, and you
should find that either loading VGAsave before or after makes both
VGAsave and the other TSR happy. If not, then you have to make a choice
about which TSR you'd rather have.
The problem here is not necessarily VGAsave or the other TSR. It boils
down to the many different approaches used to write TSRs some are better
than others. When I wrote VGAsave, as I mentioned, I did quite a bit of
research on the topic and tried to pick the most reliable configuration.
Unfortunately, TSR development is something not very well documented.
Hence, over the years, programmers have developed many different
approaches. Thus, you may have to juggle the order in which you load
everything to make all your TSR's happy.
Another possible situation that could arises is that all is well until
you add VGAsave to your autoexec.bat then some other TSR refuses to load.
In this case what is happening is that VGAsave is using the other TSR's
int 2fh or multiplex signature. This is possible since when you first
load VGAsave into memory it will search for the first unused int 2fh
signature as explained in the section on Interrupt Usage below and use
it. If this happens to be the signature of another TSR, that one may
refuse to load or corrupt VGAsave if the "other" TSR uses int 2fh,
service 00 in a nonstandard way. In that case, the solution is
to load VGAsave at a different point in your autoexec.bat. If you are
loading VGAsave first in your autoexec.bat, try loading it last and
vice versa. TSR's are strange animals. So, you may have to play around
a little bit to make all your TSR's function correctly.
Another possibility is that VGAsave is not compatible with some application
that you have. In that case, the best that can be done is to launch that
particular application from a batch file similar to the one described
above for windows. In particular, games could pose a problem since
they may directly process the mouse and keyboard interrupts and directly
access the graphics card.
Mouse Problems
==============
Several users have reported problems with VGAsave 1.91 recognizing the
mouse on their systems. These problems fall into 2 categories.
1. The interrupt chain is corrupted by the mouse driver forcing
the mouse IRQ to point directly to the mouse driver with out
preserving the interrupt chain. (The mouse IRQ hook is explained
below in the section "Mouse Hardware Interrupt", and the interrupt
chain concept is outlined in "Removing VGAsave from Memory".)
2. The mouse driver is not reporting or is incorrectly reporting
the IRQ line that the mouse is using.
Try and bare with me while I attempt to explain all of this. This mouse
issue is somewhat complicated. After outlining the problems in detail,
the actions will be discussed. So, here we go.
Problem #1: Interrupt chain corruption.
----------------------------------------
Interrupt chain corruption was first observed when running the dosshell
with VGAsave. The symptoms are that VGAsave works fine until the dosshell
is launched then VGAsave fails to recognize the mouse even after the shell
has been exited. The root cause of the problem has been traced to the
mouse driver. In essence, what happens is that the dosshell makes a call
to the mouse driver via int 33h, and the mouse driver for whatever reason
forces the mouse IRQ to point directly to the mouse driver while it is
processing the int 33h call. The mouse driver's interrupt handler for
the mouse IRQ terminates in an iret. Hence, the interrupt chain is not
preserved, and all mouse actions become "invisible" to VGAsave.
Thus, if VGAsave is unblanking the screen with mouse actions as it is
supposed to then quits recognizing the mouse after some application is
started. Most likely the interrupt chain has become corrupted in the
manner described above. Note again that the cause is the *mouse driver*.
So, the problem is application independent and depends only on the mouse
driver.
The solution to this problem implemented was to add an int 33h hook
to VGAsave. By default the int 33 handler is not installed to conserve
memory. To use the int 33 handler start VGAsave with the /int33 switch.
When VGAsave is started in this manner, every call made to int 33h will
cause VGAsave to check the mouse IRQ. Since the mouse driver corrupts
the interrupt chain as part of the int 33h service, VGAsave first calls
the mouse driver int 33h handler as a subroutine to process the interrupt
call. Then VGAsave will check to see if the mouse IRQ is still pointing
to VGAsave. If the IRQ is not pointing to VGAsave, VGAsave checks to see
if it is pointing at the mouse driver. If the IRQ vector is pointing to
the mouse driver, VGAsave forces it to point back to VGAsave which is the
state that the mouse IRQ interrupt chain was in before the mouse driver
redirected the vector (the int table points to VGAsave, VGAsave points to
the mouse driver). Strictly speaking, checking to see if the mouse IRQ is
pointing to the mouse driver if it is not pointing to VGAsave is not
necessary, but it is an insurance policy.
The reason for the "insurance policy" is that an assumption has been
made that VGAsave and the mouse driver are the only programs hooked to
the mouse IRQ vector. This assumption is reasonable since if some
other peripheral was to use the same IRQ vector as the mouse a conflict
probably would arise. But, its difficult if not impossible to depend
on that. Hence, if for some reason another TSR/device driver takes
control of the mouse IRQ VGAsave will not change the IRQ vector as a
means of insuring system integrity. The reason for this is that the
fundamental assumption that the int 33h hook was designed around has been
violated, and the state of the system is unknown at this point. This case
*should* never occur. But, if it did and a check (i.e. insurance policy)
was not implemented, VGAsave would update the interrupt table, and a system
crash becomes possible. However, even if some weird case would occur that
would violate the fundamental assumption, the mouse will only be
temporarily be invisible to VGAsave since sooner or later the mouse driver
will force the IRQ vector to point back to the mouse driver. Then on the
next int 33h call, VGAsave will point the mouse IRQ back to VGAsave.
The other assumption buried in this is that VGAsave is loaded in memory
after the mouse. This is true by default since during start up VGAsave
will not detect the presence of the mouse if VGAsave is loaded in memory
before the mouse driver.
It should be clear at this point that installing the int 33h hook will
not influence VGAsave if the int 33h hook is not required. The
reason that I have made this optional is that the int 33h hook will
increase the resident memory requirement of VGAsave to 448 bytes.
Granted, its a trivial increase, but why spend memory if its not required.
Problem 2: Mouse Driver fails to report the IRQ line.
------------------------------------------------------
First, lets discuss how VGAsave uses the mouse driver during start up.
When VGAsave is run for the first time, an int 33h, function 00h is
called to detect the presence of the mouse. If a mouse is
detected, VGAsave then calls int 33h, function 36d to get the IRQ line
used by the mouse. Several things can go wrong when function 36 is
called.
The most common problem is that the mouse driver is old and
function 36 is not supported. If VGAsave detects that this function
is not supported the following error will be reported:
"Mouse function 36 not supported by the current mouse driver."
It is possible that VGAsave does not detect that this function is
unsupported by the current mouse driver or that the mouse driver
is reporting nonstandard data. If this is the case, VGAsave will
load up and act like everything is fine, but you won't be able to
unblank the screen with the mouse.
Basically, there are two things you can do at this point, if either
one of these conditions are true: get a new mouse driver or use the
/mirq command line switch.
The /mirq switch
----------------
As noted above, this switch allows the user to manually supply
the IRQ line that VGAsave will hook for the mouse interrupt.
This switch may only be used when VGAsave is initially loaded
into memory and will force VGAsave to skip the int 33h, function
36d call. You are completely on your own here and you
have to find out what IRQ your mouse is using before this switch
may be used.
If you are lucky, your mouse driver reports the IRQ usage when
the driver is loaded into memory. So, all that you may have to
do is strip down your autoexec.bat and config.sys files so that
any messages the mouse driver prints when loading won't scroll
off the screen. Another possibility is to check the documentation
that came with the mouse.
If neither of these approaches work, you need to get a "bigger hammer".
The big hammer in this case would be some kind of memory mapping software
that will show you the interrupt usage. Norton Utilities 6.01 has
a sysinfo program that will report IRQ usage, one user noted that
QEMM's manifest will report interrupt usage, the turbo assembler
comes with tdmem that reports software interrupt usage. I assume that
PC Tools has something that will work too. If you don't have access
to any of the mentioned tools or something similar, there are several
memory mapping programs at simtel that could probably be used for this
purpose. If you need to download a memory mapper from simtel, try
in the msdos/sysutl and msdos/info directories. Another possibility
is to check into some PC Magazine utilities.
As explained in the "Mouse Hardware Interrupt" section below,
when an IRQ occurs the current program is suspended and the CPU
executes an int instruction to service the IRQ request. The int
that the CPU issues does *NOT* have the same number as the IRQ since
IRQ refers to Interrupt Request and it is a hardware concept. The
correspondence is as follows: (Note h ==> hex and d ==> decimal number.)
IRQ ==> software int *Typical* Usage
--- ------------ ---------------
IRQ 00 ==> int 08h (int 08d) Timer
IRQ 01 ==> int 09h (int 09d) Keyboard
IRQ 02 ==> int 0ah (int 10d) Slave PIC
IRQ 03 ==> int 0bh (int 11d) COM 2
IRQ 04 ==> int 0ch (int 12d) COM 1
IRQ 05 ==> int 0dh (int 13d) LPT 2
IRQ 06 ==> int 0eh (int 14d) Floppy disks
IRQ 07 ==> int 0fh (int 15d) LPT 1
IRQ 08 ==> int 70h (int 112d) Real time clock
IRQ 09 ==> int 71h (int 113d) IRQ 2 redirect
IRQ 10 ==> int 72h (int 114d) ?
IRQ 11 ==> int 73h (int 115d) ?
IRQ 12 ==> int 74h (int 116d) Mouse on PS/2 50+
IRQ 13 ==> int 75h (int 117d) Math Coprocessor
IRQ 14 ==> int 76h (int 118d) Hard disk
IRQ 15 ==> int 77h (int 119d) ?
Unless the software specifically indicates that it is reporting
hardware interrupts or IRQ lines, it is probably telling you the
software interrupt. Most likely, the memory mapping software
will report the software interrupt in hexadecimal notation. Also,
noted above is "typical" usage for the IRQ lines in a PC. From
the research that I have done, the usage seems to vary. So, its
difficult to say exactly what is going on. IRQ 00 and IRQ 01 are
used as stated above as a standard, and the same appears to hold
true for IRQ 3 (COM 2) and IRQ 4 (COM 1). But, for some of the
other IRQ lines the usage seems to be depended upon which book
you read.
So, what we gain from the table above is that if you have a
serial mouse on COM 2 most likely the IRQ line that it is using
is #3. Likewise, if your mouse is on COM 1, it is probably using
IRQ 4. Microsoft bus mice usually use IRQ 5, and some IBM PS/2's use
IRQ 12 for the mouse.
Now that you are armed with some memory mapping software and have
an approximate idea of the IRQ usage on the PC, you can now try
to determine which IRQ the mouse is using. It would be best to
boot up the system loading only DOS and the mouse driver before
you start hunting for the mouse IRQ. Rebooting the system is an
important to step since it will strip out all the unnecessary TSR's
and device drivers. Failure to do this may result in an unclear
picture of the interrupts that the mouse driver is using since another
TSR or device driver may be using some of the interrupts used by the
mouse driver. When two TSR's use the same interrupt, the memory
mapping software will report that the interrupt is pointing to the
last TSR in memory that uses it.
It sounds complicated, but essentially all that is required to find
out which interrupt vectors are pointing to the mouse driver and used
the table above to determine which IRQ line is used by the mouse.
The memory mapping software should report an IRQ vector between
2 and 15 from the table above pointing to your mouse driver along
with int 33h, probably int 08 (IRQ 00), possibly int 09h (IRQ 01), and
maybe a few others. The interrupts used by the mouse driver depend
upon the mouse. So, its impossible to state which interrupts will
be used.
Again note that a memory mapper will probably show the software
interrupts pointing to the mouse driver. So, you'll have to use the
table above to determine the IRQ line that you want to use with VGAsave.
For an example, the interrupt usage on my system when booting up
with just command.com and the mouse driver is as follows:
PSP bytes owner command line hooked vectors
----- ----- -------- ---------------- ---------------
0008 10816 config
0DFD 4704 command 22 24 2E DB E5 E8
0F29 16896 N/A N/A 08 0D 10 2F 33
134A 576352 free
The "PSP" field shows where in memory the "owner" located. The "bytes"
field is the size of the program, and the "hooked vectors" is what we
are interested in. The first entry, config, is what is used by
DOS to set up its default drivers, COM, LPT, etc... So, we ignore
that. The next entry, command, is the kernel of command.com. Then
finally we come to the "N/A" entry which is the mouse driver. How do
I know its the mouse driver -- because I booted the system and loaded
only command.com and the mouse driver. So, there is no doubt that it
is the mouse driver. The reason that you don't see the program name,
mouse.com, is that the mouse driver frees its environment block when
loading to conserve memory. VGAsave does the same thing.
Now, consider the "hooked vector" field for the mouse driver. It shows
the following:
int 08h ==> System Clock (IRQ 00)
int 0dh ==> This is the Mouse IRQ (IRQ 5)
int 10h ==> Video services
int 2fh ==> Multiplex interrupt
int 33h ==> Mouse services
Since int 0dh indicates IRQ 5 and it falls in the range of 2 to 15,
that is the interrupt that VGAsave will use for the mouse intercept.
Don't confuse this with int 33h. Int 33h is used at the software level.
For example, a program that needs to know the location of the mouse
pointer when you click the mouse would make an int 33h call.
Once the mouse IRQ has been determined, you are ready to use the
/mirq switch with VGAsave.
/mirq switch usage
------------------
IMPORTANT!!!
No warranty is written or implied with VGAsave especially
with the usage of the /mirq switch. You are accessing the
system on a very low level at this point. Failure to use
this switch properly may result in a serious system crash.
BE CAREFUL!!! If this bothers you, abort the process now
and contact somebody that has experience in these matters or
contact the manufacturer of your mouse for an updated driver.
To manually specify the IRQ that VGAsave is to use for the mouse
the /mirq switch can be used at start up. Note that the /mirq switch
can only be used when VGAsave is initially loaded into memory. You cannot
change the IRQ number without first removing VGAsave from memory.
Syntax:
VGAsave /mirq:[IRQ_num]
Where IRQ_num ranges from 2 to 15.
Note that IRQ 0 and IRQ 1 are not valid here since it makes no sense
to hook either with the /mirq switch. Recall that IRQ 0 is the system
clock. Hence, if VGAsave was launched with /mirq:00, the screen would
never blank if the mouse was enabled since 18.2 times a second VGAsave's
internal time count would be set to zero. In other words, VGAsave will
behave as if you were constantly moving the mouse. IRQ 1 is invalid
since hooking this interrupt is redundant. IRQ 1 is already used by
VGAsave to detect keyboard action and to implement the hot key.
For the example above with my bus mouse, it was determined from the
memory map that the mouse uses IRQ 5. Hence, the proper syntax would be
VGAsave /mirq:5
This will bypass the autodetection of the mouse IRQ in VGAsave and set
the IRQ to #5 for the mouse. If you were now to reboot the system
loading just command.com, the mouse driver, and VGAsave /mirq:5, you
would see int 0dh pointing to VGAsave and not the mouse driver. This
concept is explained below in the section "Removing VGAsave from Memory".
In a nutshell, int 0dh points at VGAsave and VGAsave points at the mouse
driver.
For another example, if you determined that your mouse is using
IRQ 2, the proper syntax would be:
VGAsave /mirq:2
What VGAsave Does with the Mouse IRQ or what if you use the wrong IRQ?
----------------------------------------------------------------------
In flow chart form, the mouse intercept in VGAsave works as follows:
+------------+
no | Is Mouse |
+-----| Enabled? |
| +------------+
| |
| | yes
| \|/
| +------------+ +------------------+
| | Is VGAsave | yes | Set the internal |
| | enabled? |-----> | time count to 0 |
| +------------+ +------------------+
| | |
| | no |
| | \|/
| | no +------------------+
| | +------------| Is screen blank? |
| | | +------------------+
| | | |
| | | | yes
| | | |
| | | \|/
| | | +------------------+
| | | +-------| Unblank screen |
| | | | +------------------+
\|/ \|/ \|/ \|/
+-----------------------+
| jmp to original IRQ |
+-----------------------+
So, basically 3 steps:
1. Is Mouse enabled?
A. If not absolutely nothing happens. VGAsave passes control
to the original IRQ vector which points to the mouse driver.
B. If true, VGAsave checks to see if the screen saver is
enabled.
2. Is VGAsave enabled?
A. If not, nothing happens again. VGAsave passes control
to the original IRQ vector.
B. If true, VGAsave sets its internal time count to 0 which
involves moving a zero into the resident data segment.
3. Is the screen blank?
A. If not, nothing more happens. VGAsave hands control
over to the original IRQ vector.
B. If true, VGAsave unblanks the screen. This is done
by directly sending the command out to the VGA card
with "in" and "out" instructions.
Thus, if you hook VGAsave to the wrong IRQ by mistake, your system
integrity should not be corrupted. Most likely what will happen is that
VGAsave will act a bit strange. One possibility is that VGAsave will
unblanking the screen without the user hitting a key or moving the mouse.
The other is that VGAsave will refuse to blank the screen since its
internal time count is getting set to zero. Both symptoms could appear
"randomly" depending upon which IRQ you link VGAsave too.
Just as a test, I hooked my copy of VGAsave to IRQ 6 (Floppy disk) using
/mirq:6. No, the system didn't crash when I did a dir on a:. But, what
did happen is that accessing the floppy caused the screen to unblank
which could be demonstrated with the following test:
C:>vgasave /now<ctrl-T>dir a:
If your not using DOS 5 and cannot use the ctrl-T command line
separator, a batch file can be used. Since it survived a dir command,
the "acid test" sort to speak was to copy a file from the hard disk
to the floppy and read it back. So, I do the following:
C:>vgasave /now<ctrl-T>copy vgasave.asm a:
The result was that the screen was unblanked during the file copy
since I was hooked to IRQ 6 and that the file copied fine.
So, if you get confused and give VGAsave the wrong IRQ, everything should
be okay. But, I am *NOT* guaranteeing it. IRQ usage is system
dependent. Hooking the COM port which has the modem on my system may not
cause a crash, but it could on yours. So, be careful. Based on the
analysis of what VGAsave does when it gets the mouse IRQ, everything
should be safe. But, its impossible to bank on that. Again, BE CAREFUL!
The best way I think to tell if you have given VGAsave the correct IRQ
number with the /mirq switch is to start VGAsave with the IRQ number
desired then hit the hot key to blank the screen. Now nudge the mouse if
the screen unblanks, all is well.
Now if you are curious, here is what the memory map of my system looks
like loading just command.com the mouse driver (mouse.com) and
VGAsave /mirq:5. Note that the memory map shown below would be the same
if I did not use /mirq:5 on start up since VGAsave properly detects the
IRQ that my mouse is using. Thus, in my situation, starting VGAsave
with /mirq:5 makes no difference whatsoever.
PSP bytes owner command line hooked vectors
----- ----- -------- --------------- -------------------
0008 10816 config
0DFD 4704 command 22 24 2E DB E5 E8
0F29 16896 N/A N/A 08 33
134A 352 N/A N/A 09 0D 10 1C 2F
1361 575984 free
Note that VGAsave is the "352 N/A" line in the memory map and that
int 0dh (IRQ 5) is pointing to VGAsave.
Determining which mouse switch to use
-------------------------------------
1. If VGAsave is in your autoexec.bat, use a rem statement so
that VGAsave will not be loaded during boot up.
2. Reboot the system.
3. Start VGAsave from the command line.
4. If VGAsave reports that function 36 is not supported by the currnet
mouse driver, the /mirq switch is required. If this is the case,
abort the test and determine which IRQ your mouse is using. Then
goto step 12.
5. Use the hot key or issue VGASave /now to blank the screen.
6. Move the mouse.
7. If the screen does *not* come back on, the /mirq switch is required
even if VGAsave does not report that mouse function 36 is not
supported . If this is true, abort the test at this point and
determine which IRQ line your mouse is using. Then goto step 12.
8. Start some application that uses the mouse, such as the dosshell.
9. Use the hot key to blank the screen.
10. Move the mouse. If the screen does not come back on, the /int33
switch is required.
11. If the screen is restored in step 10, exit the application and try
step 10 again. The situation with mouse driver is not 100 % clear
since its impossible to predict the behavior of each and every mouse
drive. So, you may have to try several applications repeating steps
10 and 11 before VGAsave will not recognize the mouse.
12. Note: You should be using the /mirq switch if you get to this point.
A. Reboot the system.
B. Start VGAsave with the appropriate /mirq switch.
C. Do step 5 and step 6. The screen should come back on when you
move the mouse. If it doesn't then you have the wrong IRQ for
your mouse.
D. Do steps 8, 9, 10, and 11 above.
E. If the screen does not come back on in step 10 and/or 11, you
need to use the /int33 switch along with the /mirq switch when
starting VGAsave.
F. Add the appropriate command line switches to VGAsave in your
autoexec.bat, remove the rem statement, and reboot.
Mouse switch summary
====================
/int33
This switch may only be used during start up and directs VGAsave to
install the interrupt 33h hook. Should not be used unless necessary
since this switch will increase the resident memory requirement of
VGAsave to 448 bytes. However, if memory usage is not an issue, this
command may be used unconditionally.
/mirq:[irq_num] where [irq_num] = 2 to 15
Manual override for the mouse IRQ line. This command bypasses the
autodetection of the mouse IRQ line that VGAsave uses during start up.
Does not increase the resident memory requirement of VGAsave, and may
be used unconditionally when given the correct IRQ number.
Removing VGAsave from Memory
============================
VGAsave can be removed from memory with the /r command line switch
or by selecting the "R" option from the interactive menu. Note that
VGAsave or any TSR for that matter can only be removed from memory if
all the captured interrupts are currently pointing at it. This usually
means that it has to be loaded last. If the TSR is not loaded last,
then it is possible that it cannot be removed from memory. VGAsave will
detect this condition and refuse to remove itself from memory if all
hooked interrupts are not currently pointing to the resident code. In
this case the only way to remove VGAsave from memory is to reboot the
system. However, keep in mind that VGAsave can always be disabled via
the /off switch if it cannot be removed from memory.
The reason for this is that when a TSR is removed from memory all the
hooked interrupts must be restored to their original state for the
pc to continue to function properly. If one of the hooked interrupts
no longer points to the TSR's resident code, then the TSR has no means
to restore the proper vector to the interrupt table. Consider the
following to illustrate the point:
Before Loading VGAsave After loading VGAsave
+-----------+ +------------+
| TSR 1 | | TSR 1 |
+-----------+ +------------+
/|\ /|\
| |
| Int X | Int X
| |
+-----------+ +-----------+
| Int Table | | VGAsave |
+-----------+ +-----------+
/|\
|
| Int X
|
+-----------+
| Int Table |
+-----------+
Before loading VGAsave assume that some TSR, TSR 1, is loaded in memory
and has some interrupt (call it Int X) pointing at TSR 1 that is
used by VGAsave. In this case, the interrupt vector points directly
to TSR 1 as shown above on the left. When VGAsave is loaded,
VGAsave make a copy of the int X vector and saves it as resident data.
VGAsave then updates the interrupt table via an int 21h call
so that int X points to VGAsave. Hence, the interrupt table points to
VGAsave, and VGAsave points to TSR 1 to form a chain as shown above on
the right. Thus, whenever int X is issued, control is passed to VGAsave,
and VGAsave passes control to TSR 1. When VGAsave is removed from
memory, int X is restored back to its original vector using the
data stored within VGAsave's resident data block to update the interrupt
table via an int 21h call. This operation then restores the PC back
to its original state before VGAsave was loaded (figure on the left).
Now consider the case when another TSR, TSR 2, is loaded after VGAsave
as shown below.
+-----------+
| TSR 1 |
+-----------+
/|\
|
| Int X
|
+-----------+
| VGAsave |
+-----------+
/|\
|
| Int X
|
+-----------+
| TSR 2 |
+-----------+
/|\
|
| Int X
|
+-----------+
| Int Table |
+-----------+
In this case, the interrupt table points to TSR 2, TSR 2 points to
VGAsave, and VGAsave points to TSR 1. Hence, when int X is issued,
control is passed to TSR 2, TSR 2 passes control to VGAsave, and
VGAsave passes control to TSR 1. If VGAsave were to be removed from
memory under these conditions, the interrupt chain would become corrupted
as shown below.
+-----------+
| TSR 1 |
+-----------+
/|\
|
+---------------+
+--------+ |
| Free | +-----------+ |
| Memory |<----------- | TSR 2 | | int X
+--------+ +-----------+ |
|
+---------------+
|
+-----------+
| Int Table |
+-----------+
TSR 2 gets completely bypassed since VGAsave points to TSR 1 and that
is the interrupt vector that gets restored to the interrupt table when
VGAsave is removed from memory. Thus, TSR 2 will no longer be part of
the interrupt chain, and the interrupt vector stored within TSR 2 points
to where VGAsave was which is now free memory.
Note that in the event that VGAsave is not loaded last and can be
remove from memory, beware that a "hole" will remain in DOS memory where
VGAsave was residing since DOS cannot "pack" the pc's memory. This
idea gets involved with DOS memory allocation strategy which I'm not
very familiar with. Considering that we're only talking about 352 bytes
of memory, this isn't a major concern.
Memory Requirements/Loading VGAsave High
========================================
The resident memory requirement of the VGAsave is 352 bytes. Extended
or expanded memory is not required. VGAsave supports DOS 5.0 Upper
Memory Blocks (UMB) when the loadhigh command is used. Personally,
I've run into some difficulties with loading TSR's high occasionally.
So, if you are loading VGAsave high and its not working properly, try
loading it in base memory before you decide that the software is buggy.
Since the UMBs are fixed in size, sometimes you have to juggle the
order in which you load TSR's to get them all to fit properly. Don't
ask me why. This has just been my experience. Keep in mind that all
is not lost if you have to load VGAsave in base memory since it only
requires 352 bytes of memory.
Technical info
==============
This section is intended to provide a general feeling for how VGAsave
works and covers some of the common questions that I have encountered.
It is by no means a complete discussion on TSR design. One could
easily write a book on that topic.
VGAsave was written in assembler and employs direct access techniques
to keep the size of the resident code small. In particular, VGAsave
directly accesses the VGA card to blank and restore the screen. Thus,
VGAsave WILL ONLY WORK ON VGA SYSTEMS. The other direct access technique
employed is the direct manipulation of the BIOS keyboard buffer area
which is described below.
Interrupts hooked:
(See also the section, "Mouse Problems" above.)
int 09h: Keyboard hardware interrupt
=====================================
The hot key is implemented by hooking int 09h (kbd hardware int i.e.
IRQ 01) and directly manipulating the BIOS keyboard buffer area to
avoid making a call to BIOS from within the resident code. A call
to BIOS from within a TSR requires reserving stack space within the
resident code for BIOS to use which increases the amount of memory
required by the TSR significantly.
In essence, what happens here is that every time a key is pressed or
released an int 09h is issued by the keyboard so that the PC can
detect and process keystrokes. VGAsave takes advantage of this by
hooking this interrupt to keep track of keyboard activity and to
implement the hot key feature.
Whenever an int 09h occurs, control is passed to VGAsave, and VGAsave
makes a copy of the current BIOS keyboard buffer tail (the BIOS
keyboard buffer is a circular buffer) and then calls the BIOS ISR
(interrupt service routine) for the keyboard (int 09h) as a subroutine.
After the BIOS ISR is called, control is returned to VGAsave, and the
new keyboard buffer tail is compared to the old one. If they are
different, then a valid BIOS keystroke occurred. This solves the
problem of differentiating between key presses and releases both of
which cause int 09h to occur. If a keystroke is detected, the
VGAsave reads the scan code directly from the BIOS keyboard buffer.
By reading the scan code directly from the BIOS keyboard buffer, an
int 16h call is not required which eliminates the need to reserve
stack space within the resident code for the int 16h call.
Once VGAsave obtains a keystroke, it is compared to the hot key
scan code stored within VGSsave's resident code. If a match is found,
the VGAsave blanks the screen and removes the keystroke from
the BIOS keyboard buffer. If no match is found and the screen is
blanked, VGAsave restores the screen, sets its internal time
count to zero, and suppresses the keystroke. The final possibility is
that VGAsave does not detect its hotkey and the screen is not blanked.
In this case, VGAsave sets its internal time count to zero and does
not suppress the keystroke.
Removing the keystroke from the BIOS keyboard buffer is accomplished
by restoring the keyboard buffer tail back to its value before the
BIOS int 09h ISR was invoked. This is why a valid BIOS keystroke is
required to restore a blanked screen, a scan code must be generated by
BIOS for VGAsave to detect a keystroke. If no hot key is selected,
the hot key scan code used by VGAsave is set to 00h, and the int 09h
ISR inside VGAsave remains active.
NOTE: Due to the direct manipulation of the BIOS keyboard buffer
area, an incompatibility may occur between VGAsave and
some keyboard buffer extension programs since the extended
keyboard buffer is held some other place in memory. However,
extended buffers usually don't start stacking up keystrokes
until the default BIOS keyboard buffer is full. Hence, under
normal circumstances, an extended keyboard buffer shouldn't
cause any problem. The problem occurs when the BIOS keyboard
buffer spills over into the extended buffer. In this case, if
you try to blank the screen via the hot key, VGAsave has
no means to detect or suppress the keystroke since it doesn't
know where to look for the keystroke. This leaves you with an
extra alt-0 (or which ever hot key you are using) stuck in the
extended keyboard buffer which may or may not be a problem
when it is eventually processed by BIOS. If this extra
keystroke is a problem, I have two recommendations both of
which accomplish the same thing:
1. Don't use the hot key to blank the screen if you
have a large number of keystrokes waiting to be
processed.
2. Disable the hot key support with "VGAsave /key:none"
or selecting "none" from the interactive menu.
int 10h: BIOS Video services
=============================
Used by VGAsave to keep the screen blanked once the selected
time has passed even if a program is running which switches
video modes via int 10h, service 00h. Int 10h, service 00h
forces most (if not all) of the registers on a VGA card to
become re-initialized when the video mode is changed. This will
cause a blanked screen to be restored. This causes no harm, but
without hooking this interrupt VGAsave will not reblank the screen
since it does not have a means to detect that the screen has been
been turned back on. In other words, VGAsave would think that
the screen is blank even though it isn't without the int 10h hook.
Thus, VGAsave would appear as if it quit working if the video mode
is changed while the screen is blanked. The other side effect that
would occur without hooking int 10h is that once the screen comes back
on due to a video mode change, the next key that is pressed will be
suppressed by VGAsave since VGAsave thinks that the screen was blanked
and needs to be restored. Its a subtle point. But it can be an
irritant if you are running something that switches video modes such
as, CAD packages.
int 1ch: User timer tick
==========================
Used by VGAsave to keep track of the time that has elapsed since
a keystroke or a mouse movement. Note that this interrupt occurs
18.2 times a second. So if you use VGAsave /s, VGAsave may
report a time out that off by a second or two due to round off
error. The reason for this is that the time out value provided
by the user gets multiplied by 18.2 before being saved in the
resident data block since the user provides a time out in seconds.
Then when VGAsave /s is used to retrieve this value from the
resident data block, it has to be divided by 18.2 in order for
VGAsave to return the value in seconds. These two operations
are preformed by VGAsave using integer arithmetic i.e. the number
of seconds are multiplied by 182 then divided by 10 to get system
timer ticks and the reverse process is used to get the number of
seconds from the number of timer ticks. Hence, round off error
becomes a possibility.
int 2fh: Multiplex Interrupt
==============================
VGAsave hooks interrupt 2fh as a means for communication between
the resident code and the transient code. It is this hook which
provides VGAsave the ability to change hot key, to remove itself
from memory, to perform an installation check, etc.
In order to understand how VGAsave handles this, it is necessary
to first have a feeling for how an int 2fh hook works. A TSR
is a program which has two parts, a resident part and a transient
part. It is the resident part of the TSR which stays in memory
after the program has terminated, and the transient part which takes
care of initializing the TSR and communication with the resident
portion. Hence, the next time that the TSR is executed, the transient
portion will detect that the TSR is already resident in memory and
allow the user to communicate with the resident code. An int 2fh hook
can be used to accomplish this task. A signature or id byte is assigned
to the TSR which is placed in ah before calling int 2fh and al is set
to 00h. Typically, when the resident code finds its signature in ah,
it will return ffh in al to denote that it is resident in memory and
whatever other information is necessary for the transient part of the
code to communicate with it. So far, so good. But, a problem arises
when two or more TSR's use the same signature. In that case, one TSR
may attempt to communicate with another which will result in disaster
since the two programs will be structured differently.
VGAsave employs a more sophisticated installation check to avoid this
problem. During start up, VGAsave looks for an unused int 2fh
signature starting with 0c0h and ranging to 0ffh. Signatures
below 0c0h are not considered since they are reserved by Microsoft.
The search is accomplished by loading ah with the signature in
question and al with 00h and then calling int 2fh. If any non-zero
value is returned in al by the int 2fh call, VGAsave assumes that
that the signature in ah is currently being used. Once VGAsave finds
a free signature, VGAsave will save it in the resident portion of
the program. If VGAsave cannot find a free signature, it will report
an error and refuse to load. With this approach, VGAsave is not
locked into using a fixed multiplex signature and can adapt itself to
its environment.
Note that the signature detection approach used by VGAsave conforms
to the standard usage for this interrupt. As stated the int 2fh
is called with the signature in ah, and 00h in al. The data in al
can be though of as the function number 0 for the TSR using the
signature in ah. The standard usage for service 00h is an install
check. If a TSR is hooked to int 2fh, when its signature is placed
in ah with al equal to zero, the TSR should return ffh in al to denote
that it is installed. This fact is very important for VGAsave
to detect a free signature. If there is a TSR loaded in memory that
does not return a non-zero value in al for an install check, VGAsave
will think that the signature it has made the int 2fh call with is
not being used. VGAsave will then use this signature for itself. What
happens now is that there is two TSR's using the same multiplex
signature and there will be a conflict. This conflict can cause
both VGAsave and the other TSR to misbehave. The symptoms for VGAsave
could be something like you can't control it once its loaded (i.e.
turn it off, etc.), VGAsave loads itself more than once in memory
because its resident data/code is getting corrupted and it can't
recognize itself in memory, or in the worst case the system may crash.
The reason these possibilities exist is that VGAsave may intercept the
other TSR's data/commands as its own on an int 2fh call and the
resident code will become corrupted. Unfortunately, it is impossible
for me to know every non-standard usage the install check function
on int 2fh. Hence, the solution to this problem is to change the
order in the autoexec.bat that your TSR's are loaded and hope that
this will resolve the conflict.
Once VGAsave is resident in memory and VGAsave is run again to
take advantage of one of its options, a means must be provided for
VGAsave to figure out what multiplex signature it is using. This
is accomplished in an almost identical manner. A loop is set up
to make int 2fh calls starting with 0c0h in ah ranging to 0ffh with
al set to 00h. Once VGAsave finds an int 2fh call that returns a
non-zero value in al, it assumes that it has found the resident
portion of VGAsave. If it has actually found the resident portion
of VGAsave, the bx register will contain the resident code segment.
The trick here is that the transient portion of VGAsave doing
the multiplex signature check has a copy of the resident code along
with it. Hence, to verify that the multiplex signature belongs
to VGAsave, VGAsave compares the resident code to the copy of it
in the transient portion. If a match is found, then VGAsave knows
that it has the correct multiplex signature. If no match is found,
VGAsave keeps looking. The comparison used checks the first 38 bytes
of the resident code which in effect gives VGAsave a 38 byte
identification string with using any additional memory.
There is one possible conflict that can occur with this approach.
VGAsave grabs a mux signature that is used by some other TSR. In
this case, load VGAsave after the TSR causing problems. VGAsave
will detect that particular multiplex signature is being used, and
VGAsave will use a different one.
Mouse Hardware interrupt
========================
The mouse intercept is achieved detecting the presence of the mouse
by calling int 33h, service 00h. The reason that this approach
has been implemented in version 1.93 was that it has been found
that some older mouse drivers need to be reset before the
hardware will start issuing the IRQ when a mouse event occurs.
Once the presence of the mouse is determined, the mouse hardware
interrupt (i.e. IRQ number) is determined with a call to function 36d
to the mouse driver (i.e. int 33h, service 36d). The IRQ number is
then translated to its corresponding software interrupt vector that
processes the hardware interrupt so that VGAsave can link up with the
mouse. For example, I have a Microsoft Bus Mouse on IRQ 5. Hence,
whenever something is done with the mouse, the PC is signaled by the
mouse issuing a signal to the PIC (Programmable Interrupt Controller)
on the mother board via request line #5. The PIC then tells the CPU
that an interrupt or IRQ has occurred. The CPU then issues the
appropriate *software* interrupt *instruction* (int 0dh for IRQ 5)
which causes the mouse driver to swing into action. This sequence
repeats every time the mouse is moved or a button is pushed. Thus,
in essence, all the IRQ is doing is telling the mouse driver that
something is going on with the mouse. Its then up to the mouse
driver to extract the data from the mouse hardware to see what the
mouse is doing. Since VGAsave doesn't care what the mouse is doing
only that something is being done with the mouse, hooking the mouse
IRQ line is a good way for VGAsave to link up with the mouse.
For IRQ 5 in the example above as noted, via the PIC an IRQ 5 causes
an int 0dh to occur. Hence, VGAsave will hook interrupt 0Dh. Then
whenever IRQ 5 occurs, int 0dh occurs, and whatever program is
currently running is suspended, VGAsave detects the mouse event then
passes control to the mouse driver which passes control back to the
suspended program when it is done.
Thus, by hooking the mouse hardware interrupt, any mouse event (button
presses, releases, motion, etc.) can be detected by VGAsave and are used
to reset the internal time count to zero and restore the screen if it is
blanked.
Int 33h: Mouse Services
========================
This hook is only present if VGAsave is started with the /int33
switch. The purpose is to allow VGAsave to work with mouse drivers
that re-point the mouse IRQ vector to the directly to the mouse driver
as part of the int 33h service without preserving the interrupt chain.
The architecture of this hook is outlined in the section on "Mouse
Problems" above.
Author
======
If you have any comments or suggestions, I may be reached via internet
e-mail at javurek@msen.com. If you send mail, please mention VGAsave
in the subject header.
As noted in the readme file, its getting difficult to thoroughly test
all the possible combinations of command line switches, etc. Every
effort has been made to insure that this software is as bug free as
possible, but a few may have slipped by. If you do encounter a bug,
please send me mail so that I can keep track of the problems that users
are experiencing.
Mail indicating that you are not having any problems and that you like
the program is always welcome. I've spent quite a bit of time on this
project and it is nice to know that somebody besides me and a few other
folks are using VGAsave.
If you're wondering, no the source code is not available. If you're
not wondering then forget I mentioned it.
Acknowledgements
================
I would like to thank Tim Emmerich for his suggestions and beta testing.
I'd also like to thank all the people who sent e-mail and helped me sort
out the difficulties associated with the mouse in version 1.91 and
provided suggestions for version 1.93.