newmif.asm

来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 550 行 · 第 1/2 页

ASM
550
字号
   TITLE   mif

; Title   : Microsoft C language interface to the Logitech mouse driver
; Author  : ra
; Date    : 10-30-85
; System  : Microsoft Macro Assembler
; Version : 1.00


; Short Explanation:
;   The Microsoft C compiler can link an object module produced by the
;  macro assembler with its own object modules. When this interface
;  module is assembled it produces an object module which exports mouse
;  driver interface functions for use by a C program.
;   The mouse driver functions are documented in the Logitech Mouse Driver
;  programming interface manual.
;   This driver interface is compatible with the Microsoft Mouse Driver
;  interface.

;  Microsoft is a registered trademark of Microsoft Corporation.


; Naming Convention:
;   The names follow the same convention as the Logitech Modula-2 language
;  interface.

;
; N.B. : This interface assumes the LARGE memory model - ie long (4 byte)
;        addresses for both data and subroutine calls.
;        When the user compiles the application to link with the interface
;        he/she should specify this model.On the Microsoft C compiler this
;        is done using the -Ml option, ' cc -c -Ml main.c '.
;

; ****************************************************************
; *                                                              *
; *                  M  A  C  R  O  S                            *
; *                                                              *
; ****************************************************************
; enter and leave are now instructions

do_enter   MACRO
        push  bp           ; standard C compiler call entry
        mov   bp, sp
        push  di
        push  si
        ENDM

do_leave   MACRO
        pop   si           ; standard call exit
        pop   di
        mov   sp, bp
        pop   bp
        ret
        ENDM


; ****************************************************************
; *                                                              *
; *          A S S E M B L E R    D I R E C T I V E S            *
; *                                                              *
; ****************************************************************

_TEXT   SEGMENT  BYTE PUBLIC 'CODE'
_TEXT   ENDS

CONST   SEGMENT  WORD PUBLIC 'CONST'
CONST   ENDS

_BSS    SEGMENT  WORD PUBLIC 'BSS'
_BSS    ENDS

_DATA   SEGMENT  WORD PUBLIC 'DATA'
_DATA   ENDS

DGROUP  GROUP   CONST,  _BSS,   _DATA
        ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP

PUBLIC  _FlagReset
PUBLIC  _ShowCursor
PUBLIC  _HideCursor
PUBLIC  _GetPosBut
PUBLIC  _SetCursorPos
PUBLIC  _GetButPres
PUBLIC  _GetButRel
PUBLIC  _SetHorizontalLimits
PUBLIC  _SetVerticalLimits
PUBLIC  _SetGraphicCursor
PUBLIC  _ReadMotionCounters
PUBLIC  _SetEventHandler
PUBLIC  _LightPenOn
PUBLIC  _LightPenOff
PUBLIC  _SetMickeysPerPixel
PUBLIC  _ConditionalOff
PUBLIC  _SetSpeedThreshold


_DATA   SEGMENT
_DATA   ENDS

_TEXT      SEGMENT

; ****************************************************************
; *                                                              *
; *         T H E   I N T E R F A C E   R O U T I N E S          *
; *                                                              *
; ****************************************************************


CDataSeg  dw  DGROUP

; ****************************************************************
; *        F U N C T I O N  0  :  F l a g R e s e t              *
; ****************************************************************

PUBLIC  _FlagReset
;
;     FlagReset( mouseStatusPtr, numberOfButtonsPtr )
;     int *mouseStatusPtr, *numberOfButtonsPtr;
;

_FlagReset      PROC FAR
;          Output: AX --> mouse status
;                   0 (FALSE): mouse hardware and software
;                              not installed
;                  -1 (TRUE) : mouse hardware and software
;                              installed
;                  BX --> number of mouse buttons
;
                            do_enter
                            mov   ax, 0        ; function 0
                            int   33h          ; call mouse driver function
                            les   di, 6[bp]    ; address of mouseStatus
                            mov   es:[di], ax  ; mouseStatus = ax
                            les   di, 10[bp]   ; address of numberOfButtons
                            mov   es:[di], bx  ; numberOfButtons = bx
                            do_leave

_FlagReset                  ENDP


; ****************************************************************
; *        F U N C T I O N  1  :
; ****************************************************************

PUBLIC _ShowCursor
;
; ShowCursor();
;

_ShowCursor  PROC FAR
                            do_enter
                            mov   ax, 1        ; function 1
                            int   33h          ; call mouse driver function
                            do_leave

_ShowCursor                 ENDP

; ****************************************************************
; *        F U N C T I O N  2  :
; ****************************************************************

PUBLIC _HideCursor
;
; HideCursor();
;

_HideCursor PROC FAR
                            do_enter
                            mov   ax, 2        ; function 2
                            int   33h          ; call mouse driver function
                            do_leave

_HideCursor                 ENDP


; ****************************************************************
; *        F U N C T I O N  3  :
; ****************************************************************

PUBLIC _GetPosBut
;
; GetPosBut ( buttonStatus, horizontal, vertical )
; struct {
;    unsigned leftButton  : 1;
;    unsigned rightButton : 1;
;        } *buttons;
; int *horizontal, *vertical;
;

_GetPosBut PROC FAR
                            do_enter
                            mov   ax, 3        ; function 3
                            int   33h          ; call mouse driver function
                            les   di, 6[bp]    ; address of buttonStatus
                            mov   es:[di], bx  ; buttonStatus = bx
                            les   di, 10[bp]   ; address of horizontal
                            mov   es:[di], cx  ; horizontal = cx
                            les   di, 14[bp]   ; address of vertical
                            mov   es:[di], dx  ; vertical = dx
                            do_leave
_GetPosBut ENDP


; ****************************************************************
; *        F U N C T I O N  4  :
; ****************************************************************

PUBLIC _SetCursorPos
;
; SetCursorPos (horizontal, vertical)
; int horizontal, vertical;
;

_SetCursorPos PROC FAR
                            do_enter
                            mov   cx, 6[bp]    ; cx = horizontal
                            mov   dx, 8[bp]    ; dx = vertical
                            mov   ax, 4        ; function 4
                            int   33h          ; call mouse driver function
                            do_leave
_SetCursorPos ENDP


; ****************************************************************
; *        F U N C T I O N  5  :
; ****************************************************************

PUBLIC _GetButPres
;
; GetButPres (button, buttonStatus, buttonPressCount, horizontal, vertical)
; int button, *buttonStatus, *buttonPressCount, *horizontal, *vertical;
;

_GetButPres PROC FAR
                            do_enter
                            mov   bx, 6[bp]    ; bx = button
                            mov   ax, 5        ; function 5
                            int   33h          ; call mouse driver function
                            les   di, 8[bp]   ; address of buttonStatus
                            mov   es:[di], ax  ; buttonStatus = ax
                            les   di, 12[bp]   ; address of buttonPressCount
                            mov   es:[di], bx  ; buttonPressCount = bx
                            les   di, 16[bp]   ; address of horizontal
                            mov   es:[di], cx  ; horizontal = cx
                            les   di, 20[bp]   ; address of vertical
                            mov   es:[di], dx  ; vertical = dx
                            do_leave
_GetButPres ENDP


; ****************************************************************
; *        F U N C T I O N  6  :
; ****************************************************************

PUBLIC _GetButRel
;
; GetButRel (button, buttonStatus, buttonReleaseCount, horizontal, vertical)
; int button, *buttonStatus, *buttonReleaseCount, *horizontal, *vertical;


_GetButRel PROC FAR
                            do_enter
                            mov   bx, 6[bp]    ; bx = button
                            mov   ax, 6        ; function 6
                            int   33h          ; call mouse driver function
                            les   di, 8[bp]    ; address of buttonStatus
                            mov   es:[di], ax  ; buttonStatus = ax
                            les   di, 12[bp]   ; address of buttonReleaseCount
                            mov   es:[di], bx  ; buttonReleaseCount = bx
                            les   di, 16[bp]   ; address of horizontal
                            mov   es:[di], cx  ; horizontal = cx
                            les   di, 20[bp]   ; address of vertical
                            mov   es:[di], dx  ; vertical = dx
                            do_leave

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?