home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / SNPD9404.ZIP / VIDPORT.C < prev    next >
C/C++ Source or Header  |  1994-04-03  |  2KB  |  91 lines

  1. .D 11 5
  2. .D 30 2
  3. .I 34 87
  4.  
  5. void GetCurPos(int *col, int *row)
  6. {
  7.       union REGS regs;
  8.  
  9.       regs.h.ah = 0x03;
  10.       regs.h.bh = VIDPAGE;
  11.       int86(0x10, ®s, ®s);
  12.       *row = regs.h.dh;
  13.       *col = regs.h.dl;
  14. }
  15.  
  16. int GetCurAtr(void)
  17. {
  18.       int row, col;
  19.       unsigned short chat;
  20.  
  21.       GetCurPos(&col, &row);
  22.       chat = *((unsigned FAR *)MK_FP(SCREENSEG,
  23.             (row * SCREENCOLS + col) << 1));
  24.       return (chat >> 8);
  25. }
  26.  
  27. void ClrEol(void)
  28. {
  29.       int row, col;
  30.  
  31.       GetCurPos(&col, &row);
  32.       scroll(0, 0, GetCurAtr(), row, col, row, SCREENCOLS);
  33. }
  34.  
  35. void ClrEop(void)
  36. {
  37.       int row, col;
  38.  
  39.       GetCurPos(&col, &row);
  40.       ClrEol();
  41.       if (++row < SCREENROWS)
  42.             scroll(0, 0, GetCurAtr(), row, 0, SCREENROWS, SCREENCOLS);
  43. }
  44.  
  45. void Repaint(int vattrib)
  46. {
  47.       unsigned short FAR *screen = SCRBUFF;
  48.       int row, col;
  49.  
  50.       for (row = 0; row < SCREENROWS; ++row)
  51.       {
  52.             for (col = 0; col < SCREENCOLS; ++col, ++screen)
  53.                   *screen = (*screen & 0xff) + (vattrib << 8);
  54.       }
  55. }
  56.  
  57. #ifdef TEST
  58.  
  59. #include <conio.h>
  60.  
  61. /*
  62. **  Run this test with a screenful of misc. stuff
  63. */
  64.  
  65. main()
  66. {
  67.       int vatr = GetCurAtr();
  68.  
  69.       GotoXY(1, 1);
  70.       fputs("Testing ClrEol()", stderr);
  71.       ClrEol();
  72.       fputs("\nHit any key to continue...\n", stderr);
  73.       getch();
  74.       fputs("Testing ClrEop()", stderr);
  75.       ClrEop();
  76.       fputs("\nHit any key to continue...\n", stderr);
  77.       getch();
  78.       ClrScrn(vatr);
  79.       GotoXY(0, 0);
  80.       fputs("ClrScrn() tested", stderr);
  81.       fputs("\nHit any key to continue...\n", stderr);
  82.       getch();
  83.       Repaint(BG_(CYAN) | BLACK);
  84.       fputs("Repaint() tested", stderr);
  85.       fputs("\nHit any key to continue...\n", stderr);
  86.       getch();
  87.       Repaint(vatr);
  88. }
  89.  
  90. #endif
  91.