home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1994 October / SOFM_Oct1994.bin / pc / gi / mpause / mpause.asm < prev    next >
Assembly Source File  |  1994-07-23  |  6KB  |  113 lines

  1. ;┌───────────────────────────────────────────────────────────────────────────┐
  2. ;│ MPAUSE.COM                                                   24 July 1994 │
  3. ;├───────────────────────────────────────────────────────────────────────────┤
  4. ;│ by Michael A. Jarvis  -- mjarvis@okcforum.osrhe.edu                       │
  5. ;│                                                                           │
  6. ;│ The standard MS-DOS pause command does not test for a mouse click to      │
  7. ;│ continue.  Frequently if I'm using the mouse to move though menus, etc.,  │
  8. ;│ and I come across PAUSE in a batch file, I have to take my hand off the   │
  9. ;│ mouse and press any key on the keyboard.  Very frustrating!  I wanted to  │
  10. ;│ be able to just click either mouse button to continue, just as if I had   │
  11. ;│ pressed a key.                                                            │
  12. ;│                                                                           │
  13. ;│ That is where this program is useful.  It quietly checks to see if you    │
  14. ;│ have a mouse present on your computer.  If you do, it checks not only     │
  15. ;│ for a key press, but also for a mouse click.                              │
  16. ;│                                                                           │
  17. ;│ Questions or comments are definitely welcome!                             │
  18. ;│                                                                           │
  19. ;│ Send them to...       Internet:  mjarvis@okcforum.osrhe.edu               │
  20. ;│                     Compuserve:  75051,42                                 │
  21. ;│                                                                           │
  22. ;│ I am using Borland's TASM 4.0.  The code's fairly straightforward, and    │
  23. ;│ should run under other assemblers as well.  Mileage may vary!             │
  24. ;└───────────────────────────────────────────────────────────────────────────┘
  25. code_seg        segment
  26.         assume  cs:code_seg, ds:code_seg, es:code_seg, ss:code_seg
  27.         org     100h
  28. start:  jmp     Program
  29.         Txt1    db      "Press any key or click mouse button to continue . . .",13,10,"$"
  30.         Txt2    db      "Press any key to continue . . .",13,10,"$"
  31. Program:
  32.         mov     ah,35h          ; First we want to see if a mouse is
  33.         mov     al,33h          ; present, so we check the interrupt
  34.         int     21h             ; vector for the mouse interrupt.
  35.  
  36.         or      ax,bx           ; Was an address returned?
  37.         jz      NoMouse         ; No...so no mouse is present.
  38.                                 ; Next we check to see if IRET was returned.
  39.         cmp     byte ptr es:[bx],0CFh
  40.         je      NoMouse         ; If IRET was returned, there is no
  41.                                 ; mouse present, even though an address
  42.                                 ; was returned.
  43.  
  44.         mov     ax,00h           ; Attempt to initialize the mouse.
  45.         int     33h
  46.         cmp     ax,00h          ; If 0 was returned, no mouse.
  47.         je      NoMouse         ; No mouse!
  48.  
  49.         clc                     ; Mouse exists.  Set CF to zero and
  50.                                 ; continue with program!
  51.  
  52.         mov     dx, offset Txt1 ; Print "Press any key message"
  53.         call    PrntMsg         ; Call the print message procedure
  54.  
  55.         mov     ax,02h          ; Hide the mouse cursor.
  56.         int     33h
  57.  
  58. MouseLoop:                      ; This is the beginning of the loop
  59.                                 ; that tests for a keypress or a mouse
  60.                                 ; button pressed.
  61.                     
  62.         mov     ax,0600h        ; We're going to check to see if a key
  63.         mov     dx,00FFh        ; has been pressed, without pausing,
  64.         int     21h             ; and we'll check for ^C manually.
  65.  
  66.         cmp     al,00h          ; Test the value of AL.
  67.         je      Continue        ; If it is zero, then no key was pressed.
  68.  
  69.         cmp     al,03h          ; A key was pressed...was it ^C?
  70.         jne     Exit            ; If not, then exit program normally.
  71.  
  72.         int     1Bh             ; ^C was pressed, so we execute INT 1bh
  73.         int     23h             ; and INT 23h to force a ^Break.
  74.         mov     ax,4C01h        ; Function 4Ch of INT 21h will allow
  75.         int     21h             ; us to exit with return code.
  76.  
  77. Continue:                       ; No keypress, check the mouse.
  78.         mov     ax,03h          ; INT 33h-03h will get Mouse status.
  79.         int     33h             ; IF BL = 01h, then left button was pressed
  80.                                 ; IF BL = 10h, then right button was pressed
  81.                                 ; IF BL = 11h, then BOTH buttons were pressed
  82.                                 ; IF BL = 00h, then NO buttons were pressed
  83.  
  84.         cmp     bl,03h          ; Were both buttons pressed?
  85.         je      Exit            ; If so, exit.
  86.         cmp     bl,01h          ; Was the left button pressed?
  87.         je      Exit            ; If so, exit.
  88.         cmp     bl,02h          ; Was the right button pressed?
  89.         je      Exit            ; If so, exit.
  90.  
  91.         jmp     MouseLoop       ; Nothing happened, so do it again!
  92.  
  93. NoMouse:                        ; A mouse was not detected, so we're going
  94.                                 ; to emulate the "normal" PAUSE command.
  95.  
  96.         mov     dx, offset Txt2 ; Load up the "Press any key" message
  97.         call    PrntMsg         ; and print it.
  98.  
  99.         mov     ah,08h          ; We want to use INT 21h, Service 08h
  100.         int     21h             ; Which checks for console imput w/o
  101.                                 ; echo but with ^C check.
  102. Exit:
  103.         int     20h             ; This will terminate the program
  104.  
  105. PrntMsg proc near               ; This procedure assumes that DS:DX
  106.                                 ; points to a string that ends with "$"
  107.         mov     ah,09h          ; We're going to use INT 21h, service 09h
  108.         int     21h
  109.         ret
  110. PrntMsg endp
  111. code_seg        ends
  112.         end     start
  113.