home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ANSILOAD.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  74 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  ANSILOAD.C - tries to detect if an ANSI-style driver is loaded
  5. **
  6. **  public domain by Bob Jarvis
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <dos.h>
  11. #include "sniptype.h"
  12. #include "ansiload.h"
  13.  
  14. static void goto_rc(int row, int col)
  15. {
  16.       union REGS regs;
  17.  
  18.       regs.h.ah = 2;
  19.       regs.h.bh = 0;                /* assumes we're using video page 0 */
  20.       regs.h.dh = (unsigned char)row;
  21.       regs.h.dl = (unsigned char)col;
  22.  
  23.       int86(0x10, ®s, ®s);
  24. }
  25.  
  26. static void get_rc(int *row, int *col)
  27. {
  28.       union REGS regs;
  29.  
  30.       regs.h.ah = 3;
  31.       regs.h.bh = 0;                /* again, assume video page 0       */
  32.  
  33.       int86(0x10, ®s, ®s);
  34.  
  35.       *row = regs.h.dh;
  36.       *col = regs.h.dl;
  37. }
  38.  
  39. int is_ansi_loaded(void)
  40. {
  41.       int save_r, save_c;
  42.       int new_r, new_c;
  43.       int isloaded;
  44.  
  45.       get_rc(&save_r, &save_c);
  46.       goto_rc(15,15);
  47.       fputs("\x1B[0;0H", stderr);
  48.  
  49.       get_rc(&new_r, &new_c);
  50.  
  51.       if(new_r == 0 && new_c == 0)
  52.             isloaded = True_;
  53.       else
  54.       {
  55.             isloaded = False_;
  56.             fputs("\b\b\b\b\b\b      \b\b\b\b\b\b", stderr);
  57.       }
  58.  
  59.       goto_rc(save_r, save_c);
  60.       return isloaded;
  61. }
  62.  
  63. #ifdef TEST
  64.  
  65. main()
  66. {
  67.       if(is_ansi_loaded())
  68.             puts("ANSI.SYS is loaded");
  69.       else  puts("ANSI.SYS is NOT loaded");
  70.       return 0;
  71. }
  72.  
  73. #endif /* TEST */
  74.