home *** CD-ROM | disk | FTP | other *** search
- page 58,132
-
- ; userin.asm
- ; contains: Userin(), inikbd(), mousinst(), ctlmscur(), setcbvec()
- ; rescbvec(), cntrlbrk(), setmctyp()
- ;
- ifndef _LCODE
- include model.h
- endif
- include prologue.h
- name userin
-
- ;==>-- Options for conditional Assembly
- ;
- GETKEYCODE equ 1 ;Return old-style getkey() code
- USERBUFFER equ 1 ;Input from user buffer feature enabled
-
- if (_LCODE eq 0) and (_LDATA eq 0) ;;Small Model
- _codepsize equ 1 ;size of code pointer (words)
- _datapsize equ 1 ;size of data pointer (words)
- endif
-
- if (_LCODE eq 0) and (_LDATA ne 0) ;;Compact Model
- _codepsize equ 1 ;size of code pointer (words)
- _datapsize equ 2 ;size of data pointer (words)
- endif
-
- if (_LCODE ne 0) and (_LDATA eq 0) ;;Medium Model
- _codepsize equ 2 ;size of code pointer (words)
- _datapsize equ 1 ;size of data pointer (words)
- endif
-
- if (_LCODE ne 0) and (_LDATA ne 0) ;;Large Model
- _codepsize equ 2 ;size of code pointer (words)
- _datapsize equ 2 ;size of data pointer (words)
- endif
-
-
-
- ;==>-- GKEYdefines the structure thats address is passed to the keyboard
- ; function.
- ;
- GKEY struc
- Option dw ? ;See Option bits below
- Status dw ? ;See Status values below
- Mstat dw ? ;See Mstat values below
- Char db ? ;Character code (ASCII)
- Scan db ? ;Scan code
- Shift dw ? ;Shift Status bits
- MouseX dw ? ;Mouse X position
- MouseY dw ? ;Mouse Y position
- MouseBtns dw ? ;Mouse button information
- UserHook dw _codepsize dup(?) ;Points to optional user idle function
- UserData dw _datapsize dup(?) ;Points to optional user input buffer
- GetKeyVal dw ? ;For compatibility getkey() return value
- GKEY ends
-
- ;==>-- Bits for Option structure member.
- ;
- WAITFORKEY equ 0000000000000001b ;Wait for key before returning
- MONSHIFT equ 0000000000000010b ;Monitor Shift Status
- MONXMOUSE equ 0000000000000100b ;Monitor Mouse X position
- MONYMOUSE equ 0000000000001000b ;Monitor Mouse Y position
- MONMOUSEBUTTN equ 0000000000010000b ;Monitor Mouse Buttons
- MOUSEMAPPING equ 0000000000100000b ;Enable Mouse Character Position mapping
- CALLDOS equ 0000000001000000b ;Call Dos before checking keyboard
- NOEXTKBDTEST equ 0000000010000000b ;Skip Extended keyboard test
- PASSEXTCHCODES equ 0000000100000000b ;Pass Extended character codes
- BUFFERSCAN equ 1000000000000000b ;Buffer has scan/ascii codes
-
- ;==>-- Possible values for Status structure member and return code from
- ; function.
- ;
- KEYACTIVITY equ 0fff0h ;A key has been pressed.
- MOUSEACTIVITY equ 0fff1h ;Mouse activity detected, look at Mstat.
- SHIFTACTIVITY equ 0fff2h ;Shift activity.
-
- ;==>-- Possible values for Mstat structure member.
- ;
- MOUXCHANGE equ 1 ;Mouse X position has changed.
- MOUYCHANGE equ 2 ;Mouse Y position has changed.
- MOUBUTTNCHANGE equ 3 ;Mouse Button status has changed.
-
- ;==>-- Possible values for bits in MouseBtns structure member.
- ;
- MOURIGHTBUTTON equ 2 ;Right mouse button is pressed
- MOULEFTBUTTON equ 1 ;Left mouse button is pressed
-
- ;==>-- Constants for DOS, BIOS and Mouse function calls
- ;
- DOSCALL equ 21h ;Dos: call software interrupt number
- DOSCBREAK equ 23h ;Dos: Control break vector
- DOSGETVECTOR equ 35h ;Dos: Get Interrupt vector function number
- DOSSETVECTOR equ 25h ;Dos: Set Interrupt vector
- CHKSTDINPUTST equ 0bh ;Dos: Check standard input status
- CONTROLBRKCHK equ 33h ;Dos: Control Break Set/Check
- MOUSECALL equ 33h ;Mouse: call software interrupt number
- MOUGETBSTMPOS equ 03h ;Mouse: Get Button Status and Mouse Position
- MOUSHOWCURSOR equ 01h ;Mouse: Show cursor
- MOUHIDECURSOR equ 02h ;Mouse: Hide cursor
- MOUSETTXTCURSOR equ 0ah ;Mouse: Set Text Cursor Type
- MOUSESETMAXY equ 08h ;Mouse: Set Maximum Y position
- KBDCALL equ 16h ;Keyboard: call software interrupt number
- KBDREAD equ 00h ;Keyboard: read function number
- KBDSTATUS equ 01h ;Keyboard: status function number
- XKBDWRITE equ 05h ;Extended: Keyboard Write function number
- XKBDREAD equ 10h ;Extended: read function number
- XKBDSTATUS equ 11h ;Extended: status function number
-
- NOKEY equ 0ffffh ;When returned from the idle function
- ;signifies that the idle function is
- ;not returning any keyboard codes.
-
- DONTKNOW equ 0ffh ;Constant for MouseInstalled and EnhancedKeybd
-
- ;;==>-- Values passed to users idle function
- ;;
- IDLEINIT equ 00h ;Initialize idle function
- IDLEIDLE equ 01h ;Keyboard waiting
- IDLESHUTDOWN equ 02h ;Shutdown idle function
-
- ROMBIOSSEG equ 040h ;Rom Bios Segment
- KBFLAG equ 017h ;Offset for keyboard flag in ROM Bios Segment
-
- dseg duserin
-
-
- ifdef TURBOC
- if _HUGE
- assume es:_duserin_DATA
- else
- assume es:DGROUP
- endif
- else
- ifndef AZTEC
- assume es:DGROUP
- else
- assume es:dataseg
- endif
- endif
-
- MouseInstalled db DONTKNOW ;001h=Yes, 000h=No
- EnhancedKeybd db DONTKNOW ;010h=Yes, 000h=No
- IdleState db DONTKNOW
- PrevCtlBreak dd 0 ;Previous control break address
- if _LCODE
- CtlBreakAddress dd 0 ;Users control break function
- else
- CtlBreakAddress dw 0 ;Users control break function
- endif
-
- endds
-
- pseg puserin
- ;/*
- ;** unsigned
- ;** UserIn(GKEY *table)
- ;**
- ;** ARGUMENT(s)
- ;** (GKEY *) table - pointer to a GKEY data structure
- ;**
- ;** DESCRIPTION
- ;**
- ;** RETURNS
- ;** table.Status
- ;**
- ;** AUTHOR
- ;** "" Tue 01-Nov-1988 10:22:32
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;** "" Fri 02-Dec-1988 09:53:37
- ;** Added code to translate the 0xE0 returned as a character code when any
- ;** of the four cursor keys on the extended keyboard are pressed to a 0x00
- ;** character code to be consistent with the character code returned from
- ;** the cursor keys on a non-extended keyboard.
- ;**
- ;*/
- cproc UserIn
- mov IdleState,DONTKNOW
- push es
- if _LDATA
- push ds
- mov di,ds
- lds si,parm1_ ;DS:SI -> GKEY
- else
- mov si,parm1_ ;DS:SI -> GKEY
- mov di,ds
- endif
- mov [si+Status],0 ;Say nothing happened
- mov [si+Mstat],0 ;clear mouse status also
- if GETKEYCODE
- mov [si+GetKeyVal],NOKEY
- endif
-
- if USERBUFFER
-
- ; See if users data structure has UserData pointing to some data,
- ; if so return value as if a key had been pressed. Increment
- ; UserData until the end of the data is detected. When the end
- ; is detected set UserData = (void *)0.
-
- if _LDATA
- les bx,dword ptr [si+UserData] ;ES:BX -> user's data buffer
- mov ax,es
- or ax,bx ;check for (void *)0
- else
- mov bx,[si+UserData] ;BX -> users data buffer
- or bx,bx ;check for (void *)0
- endif
- jz CheckShift ;if pointer == (void *)0 skip out
- test [si+Option],BUFFERSCAN ;does buffer have scan codes
- jnz hasscans
- if _LDATA
- mov al,es:[bx] ;ASCII character to AL
- else
- mov al,[bx] ;ASCII character to AL
- endif
- or al,al ;terminator reached?
- jnz notterm1 ;if not take jump else set
- ;UserData=(void *)0
- if _LDATA
- mov word ptr [si+UserData],0
- mov word ptr [si+UserData+2],0
- else
- mov [si+UserData],0
- endif
- jmp short CheckShift
- notterm1: mov [si+Char],al ;Save in structure
- mov [si+Scan],0 ;Clear Scan code
- if GETKEYCODE
- xor ah,ah
- mov [si+GetKeyVal],ax
- endif
- mov [si+Status],KEYACTIVITY
- inc bx ;Increment data pointer
- if _LDATA
- mov word ptr [si+UserData],bx
- else
- mov [si+UserData],bx
- endif
- jmp NewKeyExit ;get out with value
- hasscans:
- if _LDATA
- mov ax,es:[bx] ;AL=Character, AH=Scan
- else
- mov ax,[bx] ;AL=Character, AH=Scan
- endif
- or ax,ax ;reached terminator?
- jnz notterm2
- if _LDATA
- mov word ptr [si+UserData],0
- mov word ptr [si+UserData+2],0
- else
- mov [si+UserData],0
- endif
- jmp short CheckShift
- notterm2: mov [si+Char],al ;save ASCII code in structure
- mov [si+Scan],ah ;save Scan code in structure
- mov [si+Status],KEYACTIVITY
- add bx,2 ;bx+=2
- if _LDATA
- mov word ptr [si+UserData],bx
- else
- mov [si+UserData],bx
- endif
- if GETKEYCODE
- or al,al ;is it extended?
- jz xltkey1 ;if so put in structure
- xor ah,ah ;else zero high 8 bits
- xltkey1: mov [si+GetKeyVal],ax
- endif
- jmp NewKeyExit ;Exit function with value in AX
- endif
-
- ; Now see if Option has the MONSHIFT bit set, if so call the GetShiftWord
- ; routine and compare the return value (AX) to the Shift structure member.
- ; If they are different put the new value in the Shift structure member
- ; and set the Status member to SHIFTACTIVITY.
- CheckShift:
- test [si+Option],MONSHIFT ;monitor shift status?
- jz CheckMouse ;if not skip to mouse test
- call GetShiftWord ;get 16 bits of shift info to AX
- cmp ax,[si+Shift] ;is it different?
- jz CheckMouse ;if not skip to mouse
- mov [si+Shift],ax ;else update data structure and return
- mov [si+Status],SHIFTACTIVITY
- jmp NewKeyExit
-
- ; See if Option has the MONXMOUSE, MONYMOUSE or MONMOUSEBUTTN
- ; bits set. If so check for each in this order: MONMOUSEBUTTN,
- ; MONXMOUSE and MONYMOUSE. Return on the first condition that
- ; has changed.
-
- CheckMouse: test [si+Option],MONXMOUSE+MONYMOUSE+MONMOUSEBUTTN
- jnz reqmouse
- jmp CheckKeys
- reqmouse:
- if _LDATA
- mov es,di ;ES = original DS
- mov al,es:MouseInstalled ;AL = MouseInstalled Variable
- else
- mov al,MouseInstalled ;AL = MouseInstalled Variable
- endif
- cmp al,1 ;MouseInstalled==1==mouseinstalled
- jz chkmousebtn
- or al,al ;if(MouseInstalled==0), no mouse
- ;;;jz CheckKeys ;skip mouse testing
- jnz reqm1
- jmp short CheckKeys
-
- ; See if mouse is installed, update MouseInstalled to 1 if installed, 0 if
- ; not installed.
-
- reqm1: call MousePresent
- or ax,ax
- jnz chkmousebtn
- jmp short CheckKeys
-
- ; Mouse is definitely installed at this point, it is safe to make mouse
- ; function calls via the software interrupt interface.
-
- chkmousebtn: mov ax,MOUGETBSTMPOS ;get mouse information from mouse driver
- int MOUSECALL
-
- ; If user program wants to know about button changes and the button
- ; change value has changed update structure with new value, set
- ; Status=MOUSEACTIVITY and Mstat=MOUBUTTNCHANGE.
-
- test [si+Option],MONMOUSEBUTTN
- jz chkmousexpos
- cmp [si+MouseBtns],bx ;did button status change?
- jz chkmousexpos ;if not check next
- mov [si+MouseBtns],bx ;update structure
- mov [si+Status],MOUSEACTIVITY
- mov [si+Mstat],MOUBUTTNCHANGE
- jmp NewKeyExit
-
- ; If user program wants to know about changes in the X (horizontal)
- ; mouse position and the position has changed update structure with
- ; new value, set status=MOUSEACTIVITY and Mstat=MOUXCHANGE.
-
- chkmousexpos: test [si+Option],MONXMOUSE
- jz chkmouseypos
- test [si+Option],MOUSEMAPPING
- jz nomapchkx
- shr cx,1 ;divide mouse position by 8
- shr cx,1
- shr cx,1
- nomapchkx: cmp [si+MouseX],cx ;did x position change?
- jz chkmouseypos ;if not check
- mov [si+MouseX],cx ;update structure
- mov [si+Status],MOUSEACTIVITY
- mov [si+Mstat],MOUXCHANGE
- jmp NewKeyExit
-
- ; If user program wants to know about changes in the Y (vertical)
- ; mouse position and the position has changed update structure with
- ; new value, set status=MOUSEACTIVITY and Mstat=MOUYCHANGE.
-
- chkmouseypos: test [si+Option],MONYMOUSE
- jz CheckKeys
- test [si+Option],MOUSEMAPPING
- jz nomapchky
- shr dx,1 ;divide mouse positon by 8
- shr dx,1
- shr dx,1
- nomapchky: cmp [si+MouseY],dx ;did y position change?
- jz CheckKeys ;if not go on with keyboard
- mov [si+MouseY],dx ;update structure
- mov [si+Status],MOUSEACTIVITY
- mov [si+Mstat],MOUYCHANGE
- jmp NewKeyExit
-
- ; Check for keyboard activity, if first time through determine if
- ; extended keyboard functions are supported. If so set EnhancedKeybd
- ; variable to 0x10 if not supported set to 00h
- CheckKeys:
- test [si+Option],CALLDOS ;do we call dos
- jz nocalldos
- mov ah,CHKSTDINPUTST
- int DOSCALL
- nocalldos:
- if _LDATA
- mov es,di ;ES = original DS
- mov al,es:EnhancedKeybd ;AL = EnhancedKeybd Variable
- else
- mov al,EnhancedKeybd ;AL = EnhancedKeybd Variable
- endif
- cmp al,DONTKNOW
- jnz keysetup
-
- ; Test for enhanced keyboard, update EnhancedKeybd variable
- test [si+Option],NOEXTKBDTEST
- jz oktotest ;skip extended keyboard test?
- if _LDATA
- mov es:EnhancedKeybd,0
- else
- mov EnhancedKeybd,0
- endif
- jmp short keysetup
- oktotest: call ExtendedKbdFunc
- if _LDATA
- mov es:EnhancedKeybd,al ;save return value in variable
- else
- mov EnhancedKeybd,al ;save return value in variable
- endif
-
- ; We now know if we can accept the extended keyboard codes or
- ; not and the EnhancedKeybd variable is set accordingly.
- ; Next we see if there is a key available from the keyboard, if
- ; so we put it in the structure and set the Status member
- ; indicating there is KEYACTIVITY.
- keysetup:
- mov ah,KBDSTATUS
- if _LDATA
- or ah,es:EnhancedKeybd
- else
- or ah,EnhancedKeybd
- endif
- int KBDCALL ;check for keyboard activity
- jz nokeyavail ;if nothing available
- mov ah,KBDREAD ;read the key now
- if _LDATA
- or ah,es:EnhancedKeybd
- else
- or ah,EnhancedKeybd
- endif
- int KBDCALL ;AL=ASCII, AH=Scan
- cmp al,0E0h ;Ascii==0E0h?
- jnz noxlte0
- or ah,ah ;is scan = 0
- jz noxlte0
- test [si+Option],PASSEXTCHCODES
- jnz noxlte0
- xor al,al ;make ascii == 0
- noxlte0: mov [si+Char],al
- mov [si+Scan],ah ;save in structure
- mov [si+Status],KEYACTIVITY ;say there is key activity
- if GETKEYCODE
- or al,al ;is it extended?
- jz xltkey4 ;if so put in structure
- xor ah,ah ;else zero high 8 bits
- xltkey4: mov [si+GetKeyVal],ax
- endif
- jmp short NewKeyExit ;and leave
-
- ; No keyboard code is available, do we wait for one? If
- ; so is there an idle function? If so let's call it now
-
- nokeyavail: test [si+Option],WAITFORKEY ;wait for a key
- jz NewKeyExit ;no, don't wait leave
- if _LCODE
- les bx,dword ptr [si+UserHook] ;ES:BX = UserHook
- mov ax,es
- or ax,bx ;is pointer 0:0?
- else
- mov bx,[si+UserHook] ;BX = UserHook
- or bx,bx ;is pointer 0?
- endif
- jz endcheckkeys ;if no user hook repeat loop
-
- ; There is an idle function to be called, if it has not yet
- ; been called we will call it twice. The first time with
- ; a parameter of 0 so it can set things up, immediately
- ; followed by a call with a parameter of 1 which says
- ; we are waiting. When a parameter of 1 is passed to
- ; the idle function it (the idle function) can return
- ; keyboard codes. We assume that this is a 16 bit code
- ; with the scan code in the upper 8 bits and the ascii
- ; code in the lower 8 bits. If the idle function is not
- ; returning a keyboard/scan code it returns the value
- ; NOKEY (0xffff)
-
- if _LDATA
- mov es,di
- mov al,es:IdleState ;AL=IdleState Variable
- else
- mov al,IdleState ;AL=IdleState Variable
- endif
- cmp al,DONTKNOW ;have we initialized it?
- jnz idle1 ;if so skip initialization
- mov ax,IDLEINIT ;initialize the idle function
- call DispatchIdle
- if _LDATA
- mov es:IdleState,IDLEIDLE ;advance state
- else
- mov IdleState,IDLEIDLE
- endif
-
- idle1: mov ax,IDLEIDLE ;we are now idling
- call DispatchIdle
- cmp ax,NOKEY ;was value returned?
- jz endcheckkeys ;if not go to bottom of loop
-
- ; The idle function has returned a 16 bit keyboard code.
- ; We act as though this value was actually received from
- ; the ROM BIOS.
-
- mov [si+Char],al
- mov [si+Scan],ah ;save in structure
- mov [si+Status],KEYACTIVITY ;say there is key activity
- if GETKEYCODE
- or al,al ;is it extended?
- jz xltkey6 ;if so put in structure
- xor ah,ah ;else zero high 8 bits
- xltkey6: mov [si+GetKeyVal],ax
- endif
- jmp short NewKeyExit
- endcheckkeys: jmp CheckShift ;repeat thyself
-
- ; When execution gets to this point it is time to go back
- ; to the caller. Before returning we must see if we have
- ; initialized an idle function. If we have then we must
- ; call it with a parameter of IDLESHUTDOWN. The return value
- ; of this function is equal to the Status member of the
- ; structure.
- NewKeyExit:
- if _LDATA
- mov es,di
- cmp es:IdleState,DONTKNOW
- else
- cmp IdleState,DONTKNOW
- endif
- jz noidleshutdown
- mov ax,IDLESHUTDOWN
- call DispatchIdle
- noidleshutdown:
- if GETKEYCODE
- mov ax,[si+GetKeyVal] ;return value of GetKeyVal
- cmp ax,NOKEY ;make sure it is not NOKEY
- jnz getkeyhasval
- endif
- mov ax,[si+Status] ;return value == Status
- getkeyhasval:
- if _LDATA
- pop ds ;Restore original DS
- endif
- pop es
- cproce
-
-
- ;/*
- ;** void
- ;** inikbd(unsigned option,GKEY *table)
- ;**
- ;** ARGUMENT(s)
- ;** (unsigned option - values for Option member of structure.
- ;** (GKEY *) table - points to the GKEY data structure.
- ;**
- ;** DESCRIPTION
- ;** inikbd() is responsible for initializing the GKEY data structure to
- ;** the following values:
- ;**
- ;** Option = option parameter
- ;** Status = 0
- ;** Mstat = 0
- ;** Char = 0
- ;** Scan = 0
- ;** Shift = Current Shift Status
- ;** MouseX = Current Mouse X position (if mouse attached)
- ;** MouseY = Current Mouse Y position (if mouse attached)
- ;** MouseBtns = Current Mouse Button information (if mouse attached)
- ;** UserHook = (unsigned (*)())0
- ;** UserData = (void *)0
- ;** GetKeyVal = NOKEY
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Tue 01-Nov-1988 17:52:39
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc inikbd
- if _LDATA
- push ds
- lds si,parm2_ ;DS:SI -> GKEY
- else
- mov si,parm2_ ;DS:SI -> GKEY
- endif
- mov ax,parm1_ ;AX=option parameter
- mov [si+Option],ax
- xor ax,ax
- mov [si+Status],ax
- mov [si+Mstat],ax
- mov [si+Char],al
- mov [si+Scan],al
- mov [si+GetKeyVal],NOKEY
- if _LDATA
- mov word ptr [si+UserData],ax
- mov word ptr [si+UserData+2],ax
- else
- mov [si+UserData],ax
- endif
- if _LCODE
- mov word ptr [si+UserHook],ax
- mov word ptr [si+UserHook+2],ax
- else
- mov [si+UserHook],ax
- endif
- call GetShiftWord ;get shift word to AX
- mov [si+Shift],ax ;and save in structure
- call MousePresent ;is mouse present
- or ax,ax
- jnz initmouse
- mov [si+MouseX],ax ;if no mouse init to 0
- mov [si+MouseY],ax
- mov [si+MouseBtns],ax
- jmp short skipmouse
- initmouse: mov ax,MOUGETBSTMPOS ;call mouse driver for current info
- int MOUSECALL
- test [si+Option],MOUSEMAPPING
- jz nomapinit
- shr cx,1 ;divide mouse X & Y positons
- shr cx,1 ;by 8
- shr cx,1
- shr dx,1
- shr dx,1
- shr dx,1
- nomapinit: mov [si+MouseX],cx ;save mouse x position
- mov [si+MouseY],dx ;save mouse y position
- mov [si+MouseBtns],bx ;save mouse button information
- skipmouse:
- if _LDATA
- pop ds
- endif
- cproce
-
-
- ;/*
- ;** int
- ;** mousinst(void)
- ;**
- ;** ARGUMENT(s)
- ;** (none)
- ;**
- ;** DESCRIPTION
- ;** Checks for presence of mouse driver.
- ;**
- ;** RETURNS
- ;** TRUE (1) = Mouse is installed.
- ;** FALSE (0) = Mouse is NOT installed.
- ;**
- ;** AUTHOR
- ;** "" Wed 02-Nov-1988 15:39:49
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc mousinst
- call MousePresent ;MousePresent returns with AX==1 if present,
- ;AX==0 if not present.
- cproce
-
- ;/*
- ;** void
- ;** ctlmscur(int option)
- ;**
- ;** ARGUMENT(s)
- ;** (int) option - 1 == show cursor
- ;** 0 == hide cursor
- ;**
- ;** DESCRIPTION
- ;** Controls whether or not the mouse cursor is visible. This function
- ;** does its own test for mouse present making it always safe to call.
- ;**
- ;** RETURNS
- ;** void (nothing)
- ;**
- ;** AUTHOR
- ;** "" Wed 02-Nov-1988 13:21:59
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc ctlmscur
- if _LDATA
- push es
- mov ax,seg MouseInstalled
- mov es,ax
- mov al,es:MouseInstalled
- pop es
- else
- mov al,MouseInstalled ;AL = MouseInstalled Variable
- endif
- cmp al,1 ;MouseInstalled==1==mouseinstalled
- jz ctlmscur1 ;O.K. to make mouse calls
- or al,al ;is mouse not present
- jz ctlmscurexit ;if not skip this
- call MousePresent ;is mouse with us?
- or ax,ax
- jz ctlmscurexit ;if not get out
- ctlmscur1: mov ax,MOUHIDECURSOR ;assume hide
- cmp word ptr parm1_,0 ;check assumption
- jz ctlmsset
- mov ax,MOUSHOWCURSOR ;correct assumption
- ctlmsset: int MOUSECALL
- ctlmscurexit:
- cproce
-
- ;/*
- ;** void setcbvec(void (*)())
- ;**
- ;** ARGUMENT(s)
- ;** (int (*)()) - pointer to new interrupt routine
- ;**
- ;** DESCRIPTION
- ;** Sets a users control break handler. This function also stores the
- ;** original value in an internal static variable.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 03-Nov-1988 09:33:41
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc setcbvec
- push es
- push ds
- mov ax,DOSGETVECTOR*256+DOSCBREAK
- int DOSCALL ;get current settings first
- mov word ptr PrevCtlBreak,bx
- mov word ptr PrevCtlBreak+2,es
- if _LCODE
- les bx,parm1_
- mov word ptr CtlBreakAddress,bx
- mov word ptr CtlBreakAddress+2,es
- else
- mov bx,parm1_
- mov CtlBreakAddress,bx
- endif
- mov ax,seg CBDispatch
- mov ds,ax
- mov dx,offset CBDispatch
- mov ax,DOSSETVECTOR*256+DOSCBREAK
- int DOSCALL
- pop ds
- pop es
- cproce
-
-
- ;/*
- ;** void rescbvec(void)
- ;**
- ;** ARGUMENT(s)
- ;** none
- ;**
- ;** DESCRIPTION
- ;** Restores previously stored control break handler.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 03-Nov-1988 13:02:19
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc rescbvec
- push ds
- lds dx,PrevCtlBreak
- mov ax,ds
- or ax,dx
- jz skipreset
- mov ax,DOSSETVECTOR*256+DOSCBREAK
- int DOSCALL
- skipreset: pop ds
- cproce
-
-
-
- ;/*
- ;** int
- ;** cntrlbrk(int option)
- ;**
- ;** ARGUMENT(s)
- ;** (int) option - Determines whether to set break on, off
- ;** or just inquire the current setting.
- ;**
- ;** 0 = set current state OFF
- ;** 1 = set current state ON
- ;** 2 = inquire current state only
- ;**
- ;** DESCRIPTION
- ;** Interface with MS-DOS control break checking/setting function.
- ;**
- ;** RETURNS
- ;** option==0 or option==1 return the previous condition of Ctrl-Break
- ;** checking. option=2 return the current state of Ctrl-Break checking.
- ;**
- ;** AUTHOR
- ;** "" Wed 09-Nov-1988 15:24:21
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc cntrlbrk
- mov ax,CONTROLBRKCHK*256+0 ;get current state
- int DOSCALL ;from DOS
- xor dh,dh ;dx=current value
- mov ax,dx ;put in ax for possible return
- mov dl,parm1_ ;get parameter from user
- cmp dl,2 ;just want to read current value?
- jz cntrlbrkout ;if so leave
- push ax ;else save for later
- mov ax,CONTROLBRKCHK*256+1 ;set current state
- int DOSCALL ;dl=users parameter
- pop ax ;get previous value back
- cntrlbrkout:
- cproce
-
- ;/*
- ;** void
- ;** setmctyp(unsigned select,unsigned scrnmaskstart,unsigned curmaskstop)
- ;**
- ;** ARGUMENT(s)
- ;** (unsigned) select - Specifies which cursor is selected
- ;** 0 = software text cursor.
- ;** 1 = hardware text cursor.
- ;**
- ;** (unsigned) scrnmaskstart - Specifies screen mask if software
- ;** text cursor is selected. Specifies
- ;** starting scan line number when the
- ;** hardware text cursor has been selected.
- ;**
- ;** (unsigned) curmaskstop - Specifies cursor mask if software
- ;** text cursor is selected. Specifies
- ;** ending scan line number when the
- ;** hardware text cursor has been selected.
- ;**
- ;** DESCRIPTION
- ;** Selects the software or hardware text cursor. Your program must call
- ;** ctlmscur(1) to actually display the cursor.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Wed 09-Nov-1988 15:24:21
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc setmctyp
- if _LDATA
- push es
- mov ax,seg MouseInstalled
- mov es,ax
- mov al,es:MouseInstalled
- pop es
- else
- mov al,MouseInstalled ;AL = MouseInstalled Variable
- endif
- cmp al,1 ;MouseInstalled==1==mouseinstalled
- jz setmctype ;O.K. to make mouse calls
- or al,al ;is mouse not present
- jz setmctypexit ;if not skip this
- call MousePresent ;is mouse with us?
- or ax,ax
- jz setmctypexit ;if not get out
- setmctype: mov bx,parm1_ ;bx=select
- mov cx,parm2_ ;cx=screen mask / scan start
- mov dx,parm3_ ;dx=cursor mask / scan stop
- mov ax,MOUSETTXTCURSOR ;ax=function number
- int MOUSECALL ;call mouse driver
- setmctypexit:
- cproce
-
-
- ;/*
- ;** void
- ;** setmxy(unsigned minvert,unsigned maxvert)
- ;**
- ;** ARGUMENT(s)
- ;** maxvert - minimum vertical cursor position
- ;** maxhoriz - maximum vertical cursor position
- ;**
- ;** DESCRIPTION
- ;** Sets the minimum and maximum vertical mouse positions.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 15-Dec-1988 10:07:55
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc setmxy
- if _LDATA
- push es
- mov ax,seg MouseInstalled
- mov es,ax
- mov al,es:MouseInstalled
- pop es
- else
- mov al,MouseInstalled ;AL = MouseInstalled Variable
- endif
- cmp al,1 ;MouseInstalled==1==mouseinstalled
- jz oksetmaxy ;O.K. to make mouse calls
- or al,al ;is mouse not present
- jz setmaxyexit ;if not skip this
- call MousePresent ;is mouse with us?
- or ax,ax
- jz setmctypexit ;if not get out
- oksetmaxy: mov cx,parm1_ ;bx=min y
- mov dx,parm2_ ;dx=max y
- mov ax,MOUSESETMAXY ;ax=function number
- int MOUSECALL ;call mouse driver
- setmaxyexit:
- cproce
-
- subttl ***[ Internal Helper Routines (Not C Functions) ]***
- page
-
- ;/*
- ;** interrupt far
- ;** CBDispatcher()
- ;**
- ;** ARGUMENT(s)
- ;** none
- ;**
- ;** DESCRIPTION
- ;** Gets control when the control break happens, calls users C routine.
- ;**
- ;**
- ;** RETURNS
- ;** via IRET instruction
- ;**
- ;** AUTHOR
- ;** "" Thu 03-Nov-1988 12:34:44
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- CBDispatch proc far
- push ax ;save registers
- push cx
- push dx
- push bx
- push sp
- push bp
- push si
- push di
- push ds
- push es
- mov bp,sp
- ifdef TURBOC
- if _HUGE
- mov ax,es:_duserin_DATA
- else
- mov ax,DGROUP
- endif
- else
- ifndef AZTEC
- mov ax,DGROUP
- else
- mov ax,dataseg
- endif
- endif
- mov ds,ax
- cld
- sti
- call CtlBreakAddress
- mov sp,bp
- pop es
- pop ds
- pop di
- pop si
- pop bp
- pop sp
- pop bx
- pop dx
- pop cx
- pop ax
- iret
- CBDispatch endp
-
- ;/*
- ;** static unsigned
- ;** DispatchIdle(void)
- ;**
- ;** ARGUMENT(s)
- ;** No formal parameters, however the following registers must be set
- ;** up:
- ;** AX = parameter to be passed to idle function (0, 1 or 2)
- ;**
- ;** Small Data Models:
- ;** DS = points to default data segment
- ;** DS:SI = points to GKEYdata structure
- ;** Large Data Models:
- ;** DS:SI = points to GKEYdata structure
- ;** DI = contains the address of the default data segment
- ;** DESCRIPTION
- ;** Calls user defined idle function. This function CANNOT be called from C.
- ;**
- ;** RETURNS
- ;** Return value from user idle function (in AX).
- ;**
- ;** AUTHOR
- ;** "" Wed 02-Nov-1988 11:40:27
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- DispatchIdle proc near
- push bx ;save our registers
- push cx
- push si
- push di
- push es
- if _LDATA
- push ds
- push ax ;parameter for call
- mov ax,ds
- mov es,ax ;ES:SI point to GKEY structure
- mov ds,di ;make di point to default data
- if _LCODE
- call dword ptr es:[si+UserHook]
- else
- call es:[si+UserHook]
- endif
- add sp,2 ;re-align stack
- pop ds
- else
- push ax ;parameter for call
- if _LCODE
- call dword ptr es:[si+UserHook]
- else
- call [si+UserHook]
- endif
- add sp,2 ;re-align stack
- endif
- pop es ;restore our registers
- pop di
- pop si
- pop cx
- pop bx
- ret
- DispatchIdle endp
-
- ;/*
- ;** static int
- ;** ExtendedKbdFunc(void)
- ;**
- ;** ARGUMENT(s)
- ;** none
- ;**
- ;** DESCRIPTION
- ;** Determine if the enhanced keyboard functions are supported. Use the method
- ;** described in the IBM Personal System/2 and Personal Computer BIOS
- ;** Interface Technical Reference. This function CANNOT be called from C.
- ;**
- ;** RETURNS
- ;** 0x10 = Extended keyboard functions supported.
- ;** 0x00 = Extended keyboard functions are NOT supported.
- ;**
- ;** AUTHOR
- ;** "" Wed 02-Nov-1988 09:33:58
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- ExtendedKbdFunc proc near
- mov cx,0ffffh ;write scan code/character code
- mov ah,XKBDWRITE ;combination FFFF to buffer
- int KBDCALL
- mov dl,16 ;dl = counter
- extchkloop: mov ah,XKBDREAD
- int KBDCALL
- inc ax ;check for return of FFFF
- jz isextended ;if so hop out
- dec dh ;else try again
- jnz extchkloop ;repeat 16 times
- xor ax,ax ;say not installed
- jmp short extkbex
- isextended: mov ax,XKBDREAD-KBDREAD ;is extended, return value
- extkbex: ret
- ExtendedKbdFunc endp
-
- ;/*
- ;** static int
- ;** MousePresent(void)
- ;**
- ;** ARGUMENT(s)
- ;** none
- ;**
- ;** DESCRIPTION
- ;** Determine if mouse is installed or not. This function CANNOT be
- ;** called from C. The method used for checking is documented in
- ;** the Microsoft Mouse Programmers Reference Guide. This function also
- ;** updates the local variable indicating whether or not a mouse is installed.
- ;**
- ;** RETURNS (AX)
- ;** TRUE (1) = Mouse is installed.
- ;** FALSE (0) = Mouse is NOT installed.
- ;**
- ;** AUTHOR
- ;** "" Tue 01-Nov-1988 17:33:16
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- MousePresent proc near
- mov ax,DOSGETVECTOR*256+MOUSECALL
- int DOSCALL ;ES:BX points to interrupt handler
- xor ax,ax ;assume return value to false
- mov cx,es ;see if 0000:0000
- or cx,bx ;check assumption
- jz mouinnom
- cmp byte ptr es:[bx],0cfh
- jz mouinnom ;check another assumption
- inc ax ;assumption wrong
- mouinnom:
- if _LDATA
- push ds
- mov cx,seg MouseInstalled
- mov ds,cx
- mov MouseInstalled,al
- pop ds
- else
- mov MouseInstalled,al
- endif
- ret
- MousePresent endp
-
- ;/*
- ;** static unsigned
- ;** GetShiftWord(void)
- ;**
- ;** ARGUMENT(s)
- ;** none
- ;**
- ;** DESCRIPTION
- ;** Gets 16 bits of shift information, KB_FLAG is returned in AL,
- ;** KB_FLAG1 is returned in AH. This function CANNOT be called
- ;** from C.
- ;**
- ;** AUTHOR
- ;** "" Tue 01-Nov-1988 13:43:03
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- GetShiftWord proc near
- mov ax,ROMBIOSSEG
- mov cx,ds ;save DS in CX
- mov ds,ax ;DS = Rom bios data segment
- mov bx,KBFLAG
- mov ax,[bx] ;get keyboard flags to AX
- mov ds,cx ;restore DS from CX
- ret
- GetShiftWord endp
-
- endps
- end
-