Category : C Source Code
Archive   : MONO.ZIP
Filename : MONODLL.C

 
Output of file : MONODLL.C contained in archive : MONO.ZIP
// File : MONODLL.C

// Contents ------------------------------------------------------------------
//
// WEP DLL shutdown routine
// LibMain DLL startup routine
// monoOff Disable the library
// monoOn Enable the library
// mPrint Print a message on the B&W monitor
//
// Description
//
// These routines allow a secondary monochrome monitor to be
// used as a debugging screen. These are Windows compatible.
// See MONO.C for non-Windows version.
//
// The debug calls can be left in the code
// and a single call to monoOff() will disable all further calls to the
// library. This will allow the calls to be turned back on later and
// also keep the B&W video memory from being written to in case there is
// no B&W monitor in the system and the video memory is being used for
// something else (by a memory manager).
//
// Organization
//
// Interface Dependencies
// Implementation Dependencies
// Global Variables
// Functions
//
// End -----------------------------------------------------------------------

// Interface Dependencies ----------------------------------------------------
#include
#include "monodll.h"
// End Interface Dependencies ------------------------------------------------

// Implementation Dependencies -----------------------------------------------
#include /* for strlen */

void mClear( void ); // not meant to be seen outside of this file

// End Implementation Dependencies -------------------------------------------

// Global Variables ----------------------------------------------------------
static int monitorOff = 0; /* library on or off */
static unsigned int far *screen; /* pointer to B000 */
static int currentLine; /* current line and char positions */
static int currentChar;
static int firstTimeThru;
// End Global Variables ------------------------------------------------------

// Functions -----------------------------------------------------------------

void
mIncrementLine( void ) {
// Summary -------------------------------------------------------------------
//
// This is a local routine. It increments the current line pointer and
// performs the scroll function if required.
//
// End -----------------------------------------------------------------------

int i;

currentLine++;

/* scroll the screen if required */
if ( currentLine == LPP ) {

/* move lines 2 thru 25 up one line */
for ( i = CPL; i < (CPL*LPP); i++) {
screen[i-CPL] = screen[i];
}
/* clear last line */
for ( i = CPL*(LPP-1); i < (CPL*LPP); i++ ) {
screen[i] = 0x0700 + ' ';
}

/* decrement current line pointer */
currentLine -= 1;
}
}

void far PASCAL _export
mPrint( int newLine, char far *message ) {
// Summary -------------------------------------------------------------------
//
// This function will display a string on the secondary monitor.
//
// Input Parameters
//
// newLine a true/false parameter used to determine whether a
// CR/LF (newline) is generated after the message is
// displayed on the monitor.
//
// message The character string to be displayed on the monitor.
//
// Remarks
//
// Wrapping is supported and any string that extends past column 80
// is wrapped around. Scrolling is also supported once line 25 is
// is written to.
//
// End -----------------------------------------------------------------------
int i;
int len;

if ( monitorOff ) return;

/* first time thru, we want to clear the screen. We do not do this
in the LibMain routine, because we want the user to be able to
leave calls to this library in his code and then use monoOff/mOn
to enable and disable all the calls.
*/
if ( firstTimeThru ) {
firstTimeThru = 0;
for ( i = 0; i < (CPL*LPP); i++ ) {
screen[i] = 0x0700 + ' ';
}
currentLine = 0;
currentChar = 0;
}

len = _fstrlen( message );

/* send out the message */
for ( i = 0; i < len; i++ ) {

/* check for word or character wrap */
if ( currentChar == CPL ) {
currentChar = 0;
mIncrementLine();
}
screen[(CPL*currentLine)+currentChar] = 0x0700 + message[i];
currentChar++;
}

/* check on newline generation */
if (newLine == 1) {
currentChar = 0;
mIncrementLine();
}

}

void far PASCAL _export
monoOn( void )
// Summary -------------------------------------------------------------------
//
// Turn on access to the monochrome monitor.
//
// End -----------------------------------------------------------------------
{
monitorOff = 0;
}

void far PASCAL _export
monoOff( void )
// Summary -------------------------------------------------------------------
//
// Turn off access to the monochrome monitor.
//
// End -----------------------------------------------------------------------
{
monitorOff = 1;
}

#pragma argsused
int far PASCAL LibMain( HANDLE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR lpszCmdLine )
{
// The startup code for the DLL initializes the local heap (if there is
// one) with a call to LocalInit which locks the data segment.
if ( wHeapSize != 0 )
UnlockData( 0 );

/* use the global selector to access the B&W video memory */

screen = (unsigned int far *) MAKELONG( 0, &_B000H );
firstTimeThru = 1;

return 1; // Indicate that the DLL was initialized successfully.
}/* LibMain() */

void far PASCAL WEP( int nExitType )
{
/* If the device is a hardware device, the port commands */
/* necessary to shut down the device go here. */

switch( nExitType )
{
case WEP_SYSTEM_EXIT:
/* System shutdown in progress. Respond accordingly. */
return;

case WEP_FREE_DLL:
/* DLL use count is zero. Respond accordingly. */
firstTimeThru = 0;
return;

default:
/* Undefined value. Ignore it. */
/* NOTE: even if the kernel hasn't passed us a recognized */
/* nExitType, we should still have shut down the hardware */
/* device before entering this switch. */
return;
}

}/* WEP( ) */

// End Functions -------------------------------------------------------------

// End of File: MONODLL.C



  3 Responses to “Category : C Source Code
Archive   : MONO.ZIP
Filename : MONODLL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/