home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gtak212.zip / OS2-DD / d2debug.c next >
C/C++ Source or Header  |  1993-01-17  |  2KB  |  112 lines

  1. /*****************************************************************************
  2.  * $Id: d2debug.c,v 1.3 1993/01/17 10:46:59 ak Exp $
  3.  *****************************************************************************
  4.  * $Log: d2debug.c,v $
  5.  * Revision 1.3  1993/01/17  10:46:59  ak
  6.  * *** empty log message ***
  7.  *
  8.  * Revision 1.2  1992/10/14  16:48:54  ak
  9.  * _fmemcpy as macro
  10.  *
  11.  * Revision 1.1  1992/07/24  11:33:10  ak
  12.  * Initial revision
  13.  *
  14.  * Revision 1.2  1992/01/06  20:09:26  ak
  15.  * *** empty log message ***
  16.  *
  17.  * Revision 1.1.1.1  1992/01/06  19:54:09  ak
  18.  * Alpha version.
  19.  *
  20.  * Revision 1.1  1992/01/06  19:54:07  ak
  21.  * Initial revision
  22.  *
  23.  *****************************************************************************/
  24.  
  25. #include "dd.h"
  26. #define INCL_DOS
  27. #include <os2.h>
  28. #include <string.h>
  29. #ifdef __ZTC__
  30. # define _fmemcpy(d,s,n) movedata(Segment(s), Offset(s), Segment(d), Offset(d), n)
  31. #else
  32. # include <memory.h>
  33. #endif
  34.  
  35. #define DefaultAddress     0x0B8000L
  36. #define NCols        80
  37. #define NRows        25
  38. #define Attrib        0x0700
  39.  
  40. static int    row, col;
  41. dword        video_address;
  42.  
  43. void _cdecl
  44. _STI_d2debug()
  45. {
  46.     if (video_address == 0)
  47.         video_address = DefaultAddress;
  48.     row = col = 0;
  49. }
  50.  
  51. void
  52. put2c(byte c)
  53. {
  54.     if (c == '\t') {
  55.         do put2c(' '); while (col & 7);
  56.     } else {
  57.         word _far *scr = PhysToVirt(video_address, NRows * NCols * 2);
  58.         if (scr) {
  59.             if (c == '\n' || col == 80) {
  60.                 col = 0;
  61.                 row += 1;
  62.             }
  63.             if (row == NRows) {
  64.                 int i;
  65.                 _fmemmove(scr, scr + NCols, (NRows - 1) * NCols * 2);
  66.                 for (i = 0; i < NCols; ++i)
  67.                     scr[(NRows - 1) * NCols + i] = ' ' + Attrib;
  68.                 row = NRows - 1;
  69.             }
  70.             if (c != '\n')
  71.                 scr[row * NCols + col++] = c | Attrib;
  72.             UnPhysToVirt();
  73.         }
  74.     }
  75. }
  76.  
  77. void
  78. put2s(char _far *s)
  79. {
  80.     while (*s)
  81.         put2c(*s++);
  82. }
  83.  
  84. void
  85. put2x(dword x)
  86. {
  87.     int i = 32 - 4;
  88.     for (; i != 0; i -= 4)
  89.         if (x >= 1L << i)
  90.             break;
  91.     for (; i >= 0; i -= 4)
  92.         put2c("0123456789ABCDEF"[x >> i & 0x0F]);
  93. }
  94.  
  95. void
  96. put2d(long x)
  97. {
  98.     if (x == -0x80000000L) {
  99.         put2s("-2147483648");
  100.         return;
  101.     }
  102.     if (x < 0) {
  103.         put2c('-');
  104.         x = -x;
  105.     }
  106.     if (x >= 10) {
  107.         put2d(x / 10);
  108.         x %= 10;
  109.     }
  110.     put2c("0123456789"[x]);
  111. }
  112.