home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
monomsg.zip
/
MONOMSG.C
next >
Wrap
C/C++ Source or Header
|
1991-02-28
|
3KB
|
81 lines
/***************************************************************************
monomsg : Display a string on the monochrome screen
Author : Jon Roper
Date : 12/12/90
Use for debugging Windows programs.
This routine will display a string on the 25th line of the monochrome
monitor. It prepends a sequence number to the message. If the message
is a duplicate of the previous message the message is updated with a number
appended showing the number of times the routine was called with a duplicate
message.
If the message is not a duplicate the screen is scrolled 1 line prior to
displaying the new message.
NOTE - message length is not checked, messages longer than about 60 bytes
may cause havoc.
1-29-91 Added code to allow running in protected mode (monobuf.asm)
***************************************************************************/
#include <dos.h>
#include <stdio.h>
#include <windows.h>
unsigned int MONOBUFFER;
unsigned int FAR PASCAL DpmSelectorFromSegment(WORD);
void monomsg(msg)
char *msg; /* Display this message on the monochrome screen */
{
OFSTRUCT fstruct;
static HANDLE fp;
static int dups; /* number of duplicate messages */
static prev_msg[256]; /* previous message */
static int n; /* Line number */
struct SREGS regs; /* registers */
int i; /* every program needs one */
char buf[128]; /* sprintf buffer */
/**************************************************************************/
if (!fp)
{ /* call to get virtual address of monochrome buffer */
MONOBUFFER = DpmSelectorFromSegment(0xb000);
fp=OpenFile("monomsg.txt",&fstruct,
OF_CREATE|OF_WRITE);
}
if (!n)
monoscroll(25); /* first time in scroll all the data off */
if (!strcmp(prev_msg,msg)) /* same message, don't scroll */
{
++dups; /* how many duplicate messages received */
sprintf(buf,"%4d %s [%04d]",n,prev_msg,dups+1); /* msg with dup # */
}
else
{
dups = 0; /* this is not a duplicate line */
++n; /* line number displayed */
sprintf(buf,"%4d %s",n,msg); /* Setup message with msg number */
monoscroll(1); /* scroll monochrome screen 1 line */
}
segread(®s); /* Get ds register */
buf[80] = 0; /* Make sure we don't run off the screen. */
for (i = 0; i < strlen(buf); ++i) /* display message on 25th line */
movedata(regs.ds,buf+i,MONOBUFFER,(i+(24*80))*2,1); /* poke into memory */
strcpy(prev_msg,msg); /* save message for next time around */
write(fp,buf,strlen(buf));
write(fp,"\n",1);
}
/***************************************************************************
Scroll the monochrome screen lines number of times
***************************************************************************/
monoscroll(lines)
int lines; /* how many lines to scroll off */
{
while (lines--)
movedata(MONOBUFFER,160,MONOBUFFER,0,25*160);
}