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

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

// Contents ------------------------------------------------------------------
//
// monoOff Disable the library
// monoOn Enable the library
// mPrint Print a string on the B&W monitor
// mPrintf Print variables using a format on the B&W monitor.
//
// Description
//
// These routines allow a secondary monochrome monitor to be
// used as a debugging screen. These routines are not Windows
// Compatible. See MONODLL.C for Windows Compatible 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 // for MK_FP
#include "monodos.h"
#include // for vsprintf
#include /* for variable parameter processing */
// End Interface Dependencies ------------------------------------------------

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

// 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;
// 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
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;
static firstTimeThru = 1;

if ( monitorOff ) return;

/* first time thru, we want to clear the screen.*/
if ( firstTimeThru ) {
firstTimeThru = 0;
screen = (unsigned int far*) MK_FP( 0xB000, 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
mPrintf( int newLine, char *format, ...) {
// Summary -------------------------------------------------------------------
//
// This function displays a formatted string on the secondary monitor
// and accepts the same parameter list as printf.
//
// 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.
//
// format,... See printf in the c library.
//
// Remarks
//
// The non parameter formatting strings usable in printf will not work
// the same way on the monochrome monitor. Control codes will be
// displayed as solid squares.
//
// End -----------------------------------------------------------------------
va_list argptr;
char buf[MONOBUFSIZE];

va_start( argptr, format );
vsprintf( buf, format, argptr );
va_end( argptr );

mPrint( newLine, buf );
}

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

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

// End of File: MONO.C



  3 Responses to “Category : C Source Code
Archive   : MONO.ZIP
Filename : MONODOS.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/