home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / PPL4C11.ZIP / DOS_IO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-18  |  2.0 KB  |  102 lines

  1. /*  dos_io.c
  2. **
  3. **  Preforms DOS function calls.
  4. **  Used by WIN_IO.C
  5. */
  6.  
  7. #define BYTE unsigned char
  8.  
  9. #include  <stdio.h>
  10. #include  <dos.h>
  11.  
  12. /* read keyboard */
  13.  
  14. char ReadKbd(void)
  15. {union REGS  reg;
  16.  reg.h.ah = 0;
  17.  int86(0x16, ®, ®);
  18.  return reg.x.ax;
  19. }
  20.  
  21. /* set cursor type */
  22.  
  23. void SetCursor(BYTE Top,BYTE Bottom)
  24. {union REGS  reg;
  25.  reg.h.ah = 1;
  26.  reg.h.ch = Top;
  27.  reg.h.cl = Bottom;
  28.  int86(0x10, ®, ®);
  29. }
  30.  
  31. /* write character & attribute without advancing cursor */
  32.  
  33. void AttrWrite(BYTE ch, BYTE attr)
  34. {union REGS  reg;
  35.  reg.h.ah = 9;
  36.  reg.h.bh = 0;        /* current text page */
  37.  reg.h.al = ch;       /* character */
  38.  reg.h.bl = attr;
  39.  reg.x.cx = 1;
  40.  int86(0x10, ®, ®);
  41. }
  42.  
  43. /* position cursor at desired row & column */
  44.  
  45. void Position(BYTE row, BYTE col)
  46. {union REGS reg;
  47.  reg.h.ah = 2;
  48.  reg.h.bh = 0;
  49.  reg.h.dh = row;
  50.  reg.h.dl = col;
  51.  int86(0x10, ®, ®);
  52. }
  53.  
  54. /* returns the current row of the cursor */
  55.  
  56. int GetRow()
  57. {union  REGS  reg;
  58.  reg.h.ah = 3;
  59.  reg.h.bh = 0;
  60.  int86(0x10, ®, ®);
  61.  return(reg.h.dh);
  62. }
  63.  
  64. /* returns the current column of the cursor */
  65.  
  66. int GetCol()
  67. {union  REGS  reg;
  68.  reg.h.ah = 3;
  69.  reg.h.bh = 0;
  70.  int86(0x10, ®, ®);
  71.  return(reg.h.dl);
  72. }
  73.  
  74. /* scrolls area specified # rows */
  75.  
  76. void Scroll(
  77.    unsigned  urow,   /* upper row of area */
  78.    unsigned  lcol,   /* left column of area */
  79.    unsigned  lrow,   /* lower row of area */
  80.    unsigned  rcol,   /* right column of area */
  81.    int nrows,        /* # rows to scroll */
  82.    int attr)         /* attribute to use for blank lines */
  83. {union REGS reg;
  84.  reg.h.ah = 6;
  85.  reg.h.ch = urow;
  86.  reg.h.cl = lcol;
  87.  reg.h.al = nrows;
  88.  reg.h.bh = attr;
  89.  reg.h.dh = lrow;
  90.  reg.h.dl = rcol;
  91.  int86(0x10, ®, ®);
  92. }
  93.  
  94. long FreeDiskSpace(void)
  95. {union REGS reg;
  96.  reg.h.ah = 0x36;
  97.  reg.h.dl = 0;
  98.  int86(0x21, ®, ®);
  99.  if(reg.x.ax == 0xffff) return 0;
  100.  return ( (long)reg.x.bx * (long)reg.x.ax * (long)reg.x.cx );
  101. }
  102.