Category : C Source Code
Archive   : GTAK201S.ZIP
Filename : DDEBUG.C

 
Output of file : DDEBUG.C contained in archive : GTAK201S.ZIP
/*****************************************************************************
* $Id: ddebug.c,v 1.3 1992/07/24 11:34:11 ak Rel $
*****************************************************************************
* $Log: ddebug.c,v $
* Revision 1.3 1992/07/24 11:34:11 ak
* OS/2 2.0
* BASEDEV drivers
* VGA debugging
*
* Revision 1.2 1992/01/06 20:09:26 ak
* *** empty log message ***
*
* Revision 1.1.1.1 1992/01/06 19:54:09 ak
* Alpha version.
*
* Revision 1.1 1992/01/06 19:54:07 ak
* Initial revision
*
*****************************************************************************/

#include "dd.h"
#define INCL_DOS
#include
#include

#define DefaultAddress 0x0B0000L
#define NCols 80
#define NRows 25
#define LineSize (NCols * sizeof(word))
#define ScreenSize (NRows * LineSize)
#define Attrib 0x0700

static word _far * screen;
static int row, col;
dword video_address;

void _cdecl
_STI_ddebug()
{
word sel;
if (video_address == 0)
video_address = DefaultAddress;
AllocGDTSelector(&sel, 1);
PhysToGDTSelector(video_address, ScreenSize, sel);
screen = Pointer(sel, 0);
row = col = 0;
}

void
putc(byte c)
{
if (inInitPhase()) {
USHORT nw;
static byte cr = 0x0D;
if (c == '\n')
DosWrite(1, &cr, 1, &nw);
DosWrite(1, &c, 1, &nw);
} else if (c == '\t') {
do putc(' '); while (col & 7);
} else {
word _far *scr = inProtMode()
? screen
: (word _far *)(video_address << 12);
if (c == '\n' || col == 80) {
col = 0;
row += 1;
}
if (row == NRows) {
int i;
movedata(Segment(scr), LineSize, Segment(scr), 0,
ScreenSize - LineSize);
for (i = 0; i < NCols; ++i)
scr[(NRows - 1) * NCols + i] = ' ' + Attrib;
row = NRows - 1;
}
if (c != '\n')
scr[row * NCols + col++] = c | Attrib;
}
}

void
puts(char _far *s)
{
while (*s)
putc(*s++);
}

void
putx(dword x)
{
int i = 32 - 4;
for (; i != 0; i -= 4)
if (x >= 1L << i)
break;
for (; i >= 0; i -= 4)
putc("0123456789ABCDEF"[x >> i & 0x0F]);
}

void
putd(long x)
{
if (x == -0x80000000L) {
puts("-2147483648");
return;
}
if (x < 0) {
putc('-');
x = -x;
}
if (x >= 10) {
putd(x / 10);
x %= 10;
}
putc("0123456789"[x]);
}


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