home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 1994 October
/
SOFM_Oct1994.bin
/
pc
/
gi
/
mpause
/
mpause.asm
< prev
next >
Wrap
Assembly Source File
|
1994-07-23
|
6KB
|
113 lines
;┌───────────────────────────────────────────────────────────────────────────┐
;│ MPAUSE.COM 24 July 1994 │
;├───────────────────────────────────────────────────────────────────────────┤
;│ by Michael A. Jarvis -- mjarvis@okcforum.osrhe.edu │
;│ │
;│ The standard MS-DOS pause command does not test for a mouse click to │
;│ continue. Frequently if I'm using the mouse to move though menus, etc., │
;│ and I come across PAUSE in a batch file, I have to take my hand off the │
;│ mouse and press any key on the keyboard. Very frustrating! I wanted to │
;│ be able to just click either mouse button to continue, just as if I had │
;│ pressed a key. │
;│ │
;│ That is where this program is useful. It quietly checks to see if you │
;│ have a mouse present on your computer. If you do, it checks not only │
;│ for a key press, but also for a mouse click. │
;│ │
;│ Questions or comments are definitely welcome! │
;│ │
;│ Send them to... Internet: mjarvis@okcforum.osrhe.edu │
;│ Compuserve: 75051,42 │
;│ │
;│ I am using Borland's TASM 4.0. The code's fairly straightforward, and │
;│ should run under other assemblers as well. Mileage may vary! │
;└───────────────────────────────────────────────────────────────────────────┘
code_seg segment
assume cs:code_seg, ds:code_seg, es:code_seg, ss:code_seg
org 100h
start: jmp Program
Txt1 db "Press any key or click mouse button to continue . . .",13,10,"$"
Txt2 db "Press any key to continue . . .",13,10,"$"
Program:
mov ah,35h ; First we want to see if a mouse is
mov al,33h ; present, so we check the interrupt
int 21h ; vector for the mouse interrupt.
or ax,bx ; Was an address returned?
jz NoMouse ; No...so no mouse is present.
; Next we check to see if IRET was returned.
cmp byte ptr es:[bx],0CFh
je NoMouse ; If IRET was returned, there is no
; mouse present, even though an address
; was returned.
mov ax,00h ; Attempt to initialize the mouse.
int 33h
cmp ax,00h ; If 0 was returned, no mouse.
je NoMouse ; No mouse!
clc ; Mouse exists. Set CF to zero and
; continue with program!
mov dx, offset Txt1 ; Print "Press any key message"
call PrntMsg ; Call the print message procedure
mov ax,02h ; Hide the mouse cursor.
int 33h
MouseLoop: ; This is the beginning of the loop
; that tests for a keypress or a mouse
; button pressed.
mov ax,0600h ; We're going to check to see if a key
mov dx,00FFh ; has been pressed, without pausing,
int 21h ; and we'll check for ^C manually.
cmp al,00h ; Test the value of AL.
je Continue ; If it is zero, then no key was pressed.
cmp al,03h ; A key was pressed...was it ^C?
jne Exit ; If not, then exit program normally.
int 1Bh ; ^C was pressed, so we execute INT 1bh
int 23h ; and INT 23h to force a ^Break.
mov ax,4C01h ; Function 4Ch of INT 21h will allow
int 21h ; us to exit with return code.
Continue: ; No keypress, check the mouse.
mov ax,03h ; INT 33h-03h will get Mouse status.
int 33h ; IF BL = 01h, then left button was pressed
; IF BL = 10h, then right button was pressed
; IF BL = 11h, then BOTH buttons were pressed
; IF BL = 00h, then NO buttons were pressed
cmp bl,03h ; Were both buttons pressed?
je Exit ; If so, exit.
cmp bl,01h ; Was the left button pressed?
je Exit ; If so, exit.
cmp bl,02h ; Was the right button pressed?
je Exit ; If so, exit.
jmp MouseLoop ; Nothing happened, so do it again!
NoMouse: ; A mouse was not detected, so we're going
; to emulate the "normal" PAUSE command.
mov dx, offset Txt2 ; Load up the "Press any key" message
call PrntMsg ; and print it.
mov ah,08h ; We want to use INT 21h, Service 08h
int 21h ; Which checks for console imput w/o
; echo but with ^C check.
Exit:
int 20h ; This will terminate the program
PrntMsg proc near ; This procedure assumes that DS:DX
; points to a string that ends with "$"
mov ah,09h ; We're going to use INT 21h, service 09h
int 21h
ret
PrntMsg endp
code_seg ends
end start