home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
- * LPEN.C *
- * *
- * Demonstrates use of light pen emulation from C 5.1 *
- * and QuickC. First, emulation is on. Press both mouse *
- * buttons to emulate pen down. Press any key to turn *
- * off emulation. Registers returned from BIOS Function 4, *
- * Interrupt 10h, are displayed (Get Light Pen Position). *
- * *
- * Note: The BIOS Function 4, Interrupt 10H, doesn't *
- * return light pen position for VGA. It's *
- * designed to work with CGA and EGA only. *
- * *
- * This program uses int86() to call the mouse driver. *
- * *
- * Microsoft C 5.1: *
- * cl lpen.c *
- * *
- * QuickC: *
- * Program List (not required) *
- * NOTE: Program assumes mouse driver and mouse installed *
- ************************************************************/
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <graph.h>
-
- main()
- {
- union REGS iReg,oReg;
- struct SREGS segregs;
-
- /* Mouse Reset and Status */
- iReg.x.ax = 0;
- int86(0x33, &iReg, &oReg);
-
- /* Show Cursor */
- iReg.x.ax = 1;
- int86(0x33, &iReg, &oReg);
-
- /* Display message */
- printf("\n\nLight Pen Emulation Mode On, Status...\n");
-
- while (!kbhit())
- {
- iReg.h.ah = 4; /* Get Light Pen Position */
- int86(0x10, &iReg, &oReg);
- printf("\rAX: %.4X BX: %.4X CX: %.4X DX: %.4X",
- iReg.x.ax,iReg.x.bx,iReg.x.cx,iReg.x.dx);
- }
- getch();
-
- /* Light Pen Emulation Mode Off */
- iReg.x.ax = 14;
- int86(0x33, &iReg, &oReg);
-
- /* Display message */
- printf("\n\nLight Pen Emulation Mode Off, Status...\n");
-
- while (!kbhit())
- {
- iReg.h.ah = 4; /* Get Light Pen Position */
- int86(0x10, &iReg, &oReg);
- printf("\rAX: %.4X BX: %.4X CX: %.4X DX: %.4X",
- iReg.x.ax,iReg.x.bx,iReg.x.cx,iReg.x.dx);
- }
- getch();
-
- /* Mouse Reset and Status */
- iReg.x.ax = 0;
- int86(0x33, &iReg, &oReg);
- }
-