home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / maj / 2360 / maxline.c < prev    next >
C/C++ Source or Header  |  1994-01-16  |  1KB  |  56 lines

  1. // Name   : MAXLINE.C
  2. // Author : Philippe Duby & J.D. Pauget
  3. // Date   : January 12 94
  4. // Note   : Source tab = 3
  5.  
  6. #include <dos.h>
  7. #include <mem.h>
  8.  
  9. #define VARBIOS(n)    *(char far *)MK_FP (0x40, n)// Read Bios variable
  10. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  11. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  12.  
  13. main ()
  14. {
  15.     union REGS    regs, regc;
  16.     int    i;
  17.  
  18.     regc.h.ah = 0x3;                            // Get cursor info
  19.     regc.x.bx = 0;
  20.     int86 (0x10, ®c, ®c);
  21.     i = regc.h.dh;
  22.  
  23.     regs.h.ah = 0x0F;                            // Get video mode
  24.     int86 (0x10, ®s, ®s);
  25.     if (regs.h.al == 3)                          // Text color
  26.         if (VARBIOS (0x84)+1 == 25)        // We are in 25 lines mode
  27.         {
  28.             int    c = *(int far *)MK_FP (0xB800, 2*(80*i+regc.h.dl)),
  29.                     far *p= (int far *)MK_FP (0xB800, 2*80*25);
  30.  
  31.             for (i=25*80 ; i < 50*80 ; i++)// Empty screen after line 25
  32.                 *p++ = c;
  33.  
  34.             regs.x.ax = 0x1112;                // Set small font
  35.             regs.h.bl = 0;
  36.             int86 (0x10, ®s, ®s);
  37.         }
  38.         else                                        // We are in 43 or 50 lines mode
  39.         {
  40.             char szBuf[4000];                    // Screen save buffer
  41.  
  42.             _fmemcpy (szBuf, MK_FP (0xB800, 2*80*max (i-25, 0)), 4000);
  43.  
  44.             regs.x.ax = 0x1114;                // Set big font
  45.             regs.h.bl = 0;
  46.             int86 (0x10, ®s, ®s);
  47.  
  48.             _fmemcpy (MK_FP (0xB800, 0), szBuf, 4000);
  49.  
  50.             regc.h.ah = 0x2;                    // Set cursor
  51.             regc.h.dh = min(i, 24);
  52.             int86 (0x10, ®c, ®c);
  53.         }
  54.  
  55.     return 0;
  56. }