home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 33 VDrivers
/
33-VDrivers.zip
/
DBMONO.ZIP
/
README
< prev
Wrap
Text File
|
1993-03-05
|
7KB
|
246 lines
Description
-----------
DBMONO.SYS is an OS/2 monochrome adapter device driver compatible
with OS/2 1.x and OS/2 2.0.
This device driver allows applications and DLLs to display text
on an attached monochrome monitor.
These applications can be DOS, OS/2 1.x, OS/2 2.0, Microsoft
Windows applications, and DLLs.
Device Driver Installation
--------------------------
1. Copy the file DBMONO.SYS to your hard disk:
copy dbmono.sys c:\
2. Add the following line to your CONFIG.SYS file:
DEVICE=c:\dbmono.sys
This example assumes that the file DBMONO.SYS is placed on
the root of the C drive. Change this to meet your own
requirements.
3. Shutdown OS/2 and then reboot your computer.
4. Observe the device driver's installation messages during
OS/2's startup sequence.
Testing the Device Driver for proper installation
-------------------------------------------------
1. Make sure your monochrome monitor is properly attached to your
computer and is turned on.
2. At an OS/2 FULL SCREEN prompt, type in the following and press
the Enter key:
mode mono
Your full screen session should now be visible on the
monochrome monitor (if not, then you've got other problems).
3. Now get back to your full screen by typing in the following and
press the Enter key:
mode co80,25
4. At this point you have verified that your monochrome monitor is
correctly attached to your computer and working. To test if the
monochrome device driver is working, type in the following and
press the Enter key:
dir > dbmono$$
You should see the output of the dir command displayed on the
monochrome monitor (if not, something is wrong).
Sending debug output to monochrome monitor from your applications
-----------------------------------------------------------------
Keep in mind that this monochrome monitor device driver is a
standard OS/2 1.x character mode device driver. This fact
has the following implications:
o Multiple concurrent threads (or processes) can interact with
this device without the need for explicity exclusion semaphores,
etc, since OS/2 itself will serialize requests to the device.
o Any application (EXE or DLL) that can open the device can write
to it. This means that both executables and dynamic link libraries
can display text on the monochrome monitor. These executables can
be DOS, OS/2 1.x, OS/2 2.0, or Microsoft Windows applications.
This driver functions both under OS/2 1.x and OS/2 2.0.
o This device driver basically implements a very simple "dumb" TTY
terminal. This implies that:
- text is automatically scrolled as necessary.
- carriage returns (\r) and line feeds (\n) are correctly
interpreted. Note to C programmers: if you open the device
in "binary" mode, you will need to send a "\r\n" sequence
to move to the next line; if you open the device in
text mode (fopen), the "\n" will be translated into a
"\r\n" by the C runtime.
- a form feed (\f) character clears the screen and sets the
current position at the upper left corner of the screen.
An application (or DLL) must do the following two things to send
output to the monochrome monitor, 1) Open the device (done once),
and 2) write to it (as often as you wish).
This device driver is known by the device name "DBMONO$$".
Open this device using whatever standard file open API is
appropriate for your programming environment.
For example, if you program in C Set/2 under OS/2 2.0, the following
code fragment shows one method of opening the device, writing a string
to it, then closing it:
#define Error( code, string ) \
( fprintf( stderr, "%d: %s.\n", code, string ), exit(0) )
static CHAR szText[] = "Hello out there from 32-bit land!" ;
#define CBYTES (sizeof szText - 1)
int main()
{
HFILE hf = 0 ;
APIRET rc ;
ULONG ulTemp ;
ULONG cBytes = 0 ;
rc = DosOpen( "DBMONO$$"
, &hf
, &ulTemp
, 0
, FILE_NORMAL
, FILE_OPEN
, OPEN_ACCESS_WRITEONLY
| OPEN_SHARE_DENYNONE
| OPEN_FLAGS_FAIL_ON_ERROR
, 0
) ;
if ( rc )
Error( rc, "DosOpen failed" ) ;
rc = DosWrite( hf, szText, CBYTES, &cBytes ) ;
if ( rc )
Error( rc, "DosWrite failed" ) ;
if ( cBytes != CBYTES )
Error( cBytes, "DosWrite: cBytes != CBYTES" ) ;
rc = DosClose( hf ) ;
}/*main*/
You could also use the standard ANSI C file API to accomplish the
same thing:
#define Error( code, string ) \
( fprintf( stderr, "%d: %s.\n", code, string ), exit(0) )
static CHAR szText[] = "Hello out there from 32-bit land!" ;
#define CBYTES (sizeof szText - 1)
int main()
{
FILE * fp = NULL ;
int cBytes = 0 ;
fp = fopen( "DBMONO$$", "w" ) ;
if ( NULL == fp )
Error( fp, "fopen failed" ) ;
cBytes = fwrite( szText, 1, CBYTES, fp ) ;
if ( rc )
Error( rc, "DosWrite failed" ) ;
if ( cBytes != CBYTES )
Error( cBytes, "fwrite: cBytes != CBYTES" ) ;
fclose( fp ) ;
}/*main*/
Here is a useful function that I use:
//=============================================================================
// DB - display debug output to DBMONO$$. If the DBMONO.SYS device driver is
// installed, then DBMONO$$ refers to the monochrome adapter. Otherwise,
// DBMONO$$ refers to the file DBMONO$$.
//-----------------------------------------------------------------------------
// pszFormat - format string optionally followed by parameters. This is the
// same syntax as the standard printf() function. For example:
//
// DB( "My id is %d.\n", sId ) ;
// DB( "p1 = %0x, p2 = %0x, p2 = %ld.\n", ulp1, ulp2, lp3 ) ;
// DB( "%s: %c %d.\n", szName, chData, sAge ) ;
//
//-----------------------------------------------------------------------------
// Returns nothing.
//=============================================================================
VOID DB( const CHAR * pszFormat, ... )
{
va_list args ;
if ( NULL == hfDebug )
hfDebug = fopen( "DBMONO$$", "w+" ) ;
if ( NULL == hfDebug )
return ;
va_start( args, pszFormat ) ;
vfprintf( hfDebug, pszFormat, args ) ;
va_end( args ) ;
}/*DB*/
Limitations
-----------
The following limitations are know to exist with this device driver:
1. The cursor is not modified in any way. Disregard the cursor
completely.
2. Sometimes your monochrome monitor's screen may seem to go blank.
I don't know why this occurs, but its real easy to "get it back"
by typing the following two lines at an OS/2 FULL SCREEN prompt:
mode mono
mode co80,25
3. This device driver is provided on an "as is" basis, with no
guarantee that it won't trash your hard disk, your work in
progress, etc (<grin>).
Adel Hazzah (70720,411)