home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / MSMOUSE1.ZIP / C&QC.ZIP / LPEN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-10  |  2.6 KB  |  74 lines

  1. /************************************************************
  2. *  LPEN.C                                                   *
  3. *                                                           *
  4. *  Demonstrates use of light pen emulation from C 5.1       *
  5. *  and QuickC. First, emulation is on. Press both mouse     *
  6. *  buttons to emulate pen down. Press any key to turn       *
  7. *  off emulation. Registers returned from BIOS Function 4,  *
  8. *  Interrupt 10h, are displayed (Get Light Pen Position).   *
  9. *                                                           *
  10. *  Note: The BIOS Function 4, Interrupt 10H, doesn't        *
  11. *        return light pen position for VGA. It's            *
  12. *        designed to work with CGA and EGA only.            *
  13. *                                                           *
  14. *  This program uses int86() to call the mouse driver.      *
  15. *                                                           *
  16. *  Microsoft C 5.1:                                         *
  17. *     cl lpen.c                                             *
  18. *                                                           *
  19. *  QuickC:                                                  *
  20. *     Program List (not required)                           *
  21. *  NOTE: Program assumes mouse driver and mouse installed   *
  22. ************************************************************/
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <dos.h>
  27. #include <graph.h>
  28.  
  29. main()
  30. {
  31.     union REGS iReg,oReg;
  32.     struct SREGS segregs;
  33.  
  34.     /* Mouse Reset and Status */
  35.     iReg.x.ax = 0;
  36.     int86(0x33, &iReg, &oReg);
  37.  
  38.     /* Show Cursor */
  39.     iReg.x.ax = 1;
  40.     int86(0x33, &iReg, &oReg);
  41.  
  42.     /* Display message */
  43.     printf("\n\nLight Pen Emulation Mode On, Status...\n");
  44.  
  45.     while (!kbhit())
  46.        {
  47.        iReg.h.ah = 4;                  /* Get Light Pen Position */
  48.        int86(0x10, &iReg, &oReg);
  49.        printf("\rAX: %.4X  BX: %.4X  CX: %.4X  DX: %.4X",
  50.                iReg.x.ax,iReg.x.bx,iReg.x.cx,iReg.x.dx);
  51.        }
  52.     getch();
  53.  
  54.     /* Light Pen Emulation Mode Off */
  55.     iReg.x.ax = 14;
  56.     int86(0x33, &iReg, &oReg);
  57.  
  58.     /* Display message */
  59.     printf("\n\nLight Pen Emulation Mode Off, Status...\n");
  60.  
  61.     while (!kbhit())
  62.        {
  63.        iReg.h.ah = 4;                  /* Get Light Pen Position */
  64.        int86(0x10, &iReg, &oReg);
  65.        printf("\rAX: %.4X  BX: %.4X  CX: %.4X  DX: %.4X",
  66.                iReg.x.ax,iReg.x.bx,iReg.x.cx,iReg.x.dx);
  67.        }
  68.     getch();
  69.  
  70.     /* Mouse Reset and Status */
  71.     iReg.x.ax = 0;
  72.     int86(0x33, &iReg, &oReg);
  73. }
  74.