home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / WINCPP.ZIP / WMISC.CPP < prev   
C/C++ Source or Header  |  1994-01-25  |  2KB  |  140 lines

  1. #include "window.h"
  2. #include <dos.h>
  3. #include <stdlib.h>
  4.  
  5. int Window::Getch()
  6. {
  7.     union REGS reg;
  8.  
  9.     reg.h.ah = 0x07;
  10.     int86(0x21, ®, ®);
  11.     return (int)(reg.h.al);
  12. }
  13.  
  14.  
  15. void Window::SetVideoMem()
  16. {
  17.     if ((vc == TYPE_MDA) || (vc == TYPE_HGC))
  18.         Video = (short far *)MK_FP(0xb000, 0);
  19.     else
  20.         Video = (short far *)MK_FP(0xb800, 0);
  21. }
  22.  
  23.  
  24. void Error(char *msg)
  25. {
  26.     fprintf(stderr, msg);
  27.     fprintf(stderr, "\n");
  28.     exit(1);
  29. }
  30.  
  31.  
  32. VideoCardType Window::IdentifyVideoCard()
  33. {
  34.     union REGS reg;
  35.     uchar isvga, disptype;
  36.  
  37.     // call VGA "Identify Adapter Service" first
  38.     reg.x.ax = 0x1a00;
  39.     int86(0x10, ®, ®);
  40.     isvga = reg.h.al;
  41.     disptype = reg.h.bl;
  42.  
  43.     if (isvga == 0x1a)
  44.         switch (disptype) {
  45.             case 1:
  46.                 return(TYPE_MDA);
  47.             case 2:
  48.                 return(TYPE_CGA);
  49.             case 4:
  50.             case 5:
  51.                 return(TYPE_EGA);
  52.             case 7:
  53.             case 8:
  54.                 return(TYPE_VGA);
  55.             case 10:
  56.             case 11:
  57.             case 12:
  58.                 return(TYPE_MCGA);
  59.             default:
  60.                 return(TYPE_UNKNOWN);
  61.         }
  62.     else {
  63.         // VGA services not available -- maybe it's EGA
  64.         uchar isega;
  65.  
  66.         reg.h.ah = 0x1a;
  67.         reg.h.bl = 0x10;
  68.         int86(0x10, ®, ®);
  69.         isega = reg.h.bl;
  70.  
  71.         // if BL is not 0x10, we have an EGA
  72.         if (isega != 0x10)
  73.             return(TYPE_EGA);
  74.         else {
  75.             // check 2-bit monitor type setting in eqip word
  76.             unsigned short equip, i, status_changed;
  77.             uchar orig_status;
  78.  
  79.             int86(0x11, ®, ®);
  80.             equip = reg.x.ax;
  81.             switch ((equip & 0x30) >> 4) {
  82.                 case 0:
  83.                     return(TYPE_UNKNOWN);
  84.                 case 1:
  85.                 case 2:
  86.                     return(TYPE_CGA);
  87.                 case 3:
  88.                     status_changed = 0;
  89.                     orig_status = (uchar)(inp(0x03ba) &
  90.                               0x80);
  91.                     for (i=0; i<30000u; i++) {
  92.                         if (orig_status != (uchar)
  93.                             (inp(0x03ba) & 0x80)) {
  94.                             status_changed = 1;
  95.                             break;
  96.                         }
  97.                     }
  98.                     if (status_changed)
  99.                         return(TYPE_HGC);
  100.                     else
  101.                         return(TYPE_MDA);
  102.             }
  103.         }
  104.     }
  105. }
  106.  
  107.  
  108. void Window::HideCursor()
  109. {
  110.     union REGS reg;
  111.  
  112.     if (CursorHidden)
  113.         return;
  114.     else {
  115.         reg.h.ah = 0x03;
  116.         reg.h.bh = 0;
  117.         int86(0x10, ®, ®);
  118.         CursorShape = reg.x.cx;
  119.         reg.h.ah = 0x01;
  120.         reg.x.cx = 0x2000;
  121.         int86(0x10, ®, ®);
  122.         CursorHidden = TRUE;
  123.     }
  124. }
  125.  
  126.  
  127. void Window::ShowCursor()
  128. {
  129.     union REGS reg;
  130.  
  131.     if (!CursorHidden)
  132.         return;
  133.     else {
  134.         reg.h.ah = 0x01;
  135.         reg.x.cx = CursorShape;
  136.         int86(0x10, ®, ®);
  137.         CursorHidden = FALSE;
  138.     }
  139. }
  140.