home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / bbs / mikes30c.arc / CONTCUR.C < prev    next >
Text File  |  1985-09-26  |  2KB  |  98 lines

  1. /**************************************************************************
  2.    These routines are very useful in doing the job of cursor control for
  3.    Microsoft C 3.0.  You must #include <dos.h>  for these to work.
  4.  
  5.           Mike's "C" Board   619-722-8724
  6. **************************************************************************/
  7.  
  8.  
  9. gotoxy(row, col)  /* Position cursor at x,y on screen */
  10. int    row, col;
  11. {
  12.     union REGS REG;
  13.  
  14.     REG.h.ah = 02;
  15.     REG.h.bh = 00;
  16.     REG.h.dh = row;
  17.     REG.h.dl = col;
  18.     int86(0x10, ®, ®);
  19. }
  20.  
  21.  
  22. getxy(hold) /* Get cursor coordinate and attribute */
  23. int    *hold;
  24. {
  25.     union REGS REG;
  26.  
  27.     REG.h.ah = 03;
  28.     REG.h.bh = 00;
  29.     int86(0x10, ®, ®);
  30.     hold[0] = REG.h.dh;
  31.     hold[1] = REG.h.dl;
  32.     hold[2] = REG.h.ch;
  33.     hold[3] = REG.h.cl;
  34. }
  35.  
  36.  
  37. restorxy(hold)  /* Restore cursor gotten above */
  38. int    *hold;
  39. {
  40.     union REGS REG;
  41.  
  42.     gotoxy(hold[0], hold[1]);
  43.     REG.h.ah = 01;
  44.     REG.h.bh = 00;
  45.     REG.h.ch = hold[2];
  46.     REG.h.cl = hold[3];
  47.     int86(0x10, ®, ®);
  48.  
  49. }
  50.  
  51.  
  52. get_mode()   /* Check for Monocrome or graphics  */
  53. {
  54.     union REGS REG;
  55.  
  56.     REG.h.ah = 15;
  57.     REG.h.bh = 00;
  58.     REG.h.ch = 0;
  59.     REG.h.cl = 0;
  60.     int86(0x10, ®, ®);
  61.  
  62.     return(REG.h.al);
  63. }
  64.  
  65.  
  66. del_cur()  /* Make cursor disappear */
  67. {
  68.     union REGS REG;
  69.  
  70.     REG.h.ah = 01;
  71.     REG.h.bh = 00;
  72.     REG.h.ch = 0x26;
  73.     REG.h.cl = 7;
  74.     int86(0x10, ®, ®);
  75. }
  76.  
  77.  
  78. restor_cur()  /* Put cursor back on screen checking for adapter */
  79. {
  80.     union REGS REG;
  81.     unsigned    st, en;
  82.  
  83.     if (get_mode() == 7)       /* Monocrone adapter */
  84.         st = 0x0d, en = 14;
  85.     else
  86.         st = 0x06, en = 7;     /* Color graphics adapter */
  87.  
  88.     REG.h.ah = 01;
  89.     REG.h.bh = 00;
  90.     REG.h.ch = st;
  91.     REG.h.cl = en;
  92.     int86(0x10, ®, ®);
  93.  
  94.  
  95. }
  96.  
  97.  
  98.