home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_12 / tc_mouse.asm < prev    next >
Assembly Source File  |  1990-11-13  |  15KB  |  750 lines

  1.  
  2.         TITLE    MicroSoft Mouse    Library    Module
  3.         PAGE    60,132
  4.  
  5.  
  6.     COMMENT     !
  7.  
  8.     Assembler Source Code for MicroSoft Mouse Driver Interface
  9.  
  10.     Source is Compatible with MASM 5.0 and TASM 2.0
  11.  
  12.     $$$$   IMPORTANT NOTE:   $$$$
  13.  
  14.         I originally assembled each function as a separate
  15.         module, and constructed a .LIB file, but since the
  16.         code for the entire interface assembles to less than
  17.         2Kbytes, the space saved is not worth the effort of
  18.         seperate assembly.  Just link in tc_mouse.obj normally.
  19.  
  20.         The Turbo C V.1.5 and 2.0 compatible project file
  21.         ( testq.prj ) assumes a subdirectory named "EXE"
  22.         where your ".OBJ" files are kept.  If you are using
  23.         the project file in this way, change the last file
  24.         on the line form tc_mouse.lib to exe\tc_mouse.obj
  25.  
  26.     Use the command:
  27.                 TASM /ml tc_mouse
  28.  
  29.         or
  30.  
  31.                 MASM /ml tc_mouse;
  32.  
  33.     to assemble to object format
  34.  
  35.     then link with small model C program
  36.  
  37.     !
  38.  
  39.     .MODEL SMALL, C
  40.  
  41.     .DATA
  42.  
  43.     .STACK
  44.  
  45.     .CODE
  46.  
  47.     public _mouse_reset
  48.     public _mouse_show
  49.     public _mouse_hide
  50.     public _mouse_get_pos
  51.     public _mouse_set_pos
  52.     public _mouse_button_press
  53.     public _mouse_button_rel
  54.     public _mouse_limit_x
  55.     public _mouse_limit_y
  56.     public _mouse_set_graphcursor
  57.     public _mouse_set_textcursor
  58.     public _mouse_get_movement
  59.     public _mouse_set_eventhandler
  60.     public _mouse_start_pen_emul
  61.     public _mouse_stop_pen_emul
  62.     public _mouse_set_movement_ratio
  63.     public _mouse_conditional_off
  64.     public _mouse_set_speed
  65.     public _mouse_swap_vector
  66.     public _mouse_get_bufsize
  67.     public _mouse_save_state
  68.     public _mouse_restore_state
  69.     public _mouse_set_alt_handler
  70.     public _mouse_get_alt_handler
  71.     public _mouse_set_sens
  72.     public _mouse_get_sens
  73.     public _mouse_set_crt_page
  74.     public _mouse_get_crt_page
  75.     public _mouse_disable_drvr
  76.     public _mouse_enable_drvr
  77.     public _mouse_soft_reset
  78.  
  79.  
  80. ;****************************************
  81. ; _mouse_reset   PROC:
  82. ;
  83. ;     Description:    initialize the mouse driver
  84. ;
  85. ; int  mouse_reset(int *num_buttons);
  86. ;
  87. ;****************************************
  88.  
  89. _mouse_reset    PROC
  90.         xor    ax,ax
  91.         int    33h
  92.         ret
  93. _mouse_reset    ENDP
  94.  
  95. ;****************************************
  96. ; _mouse_show    PROC:
  97. ;
  98. ;     Description:    display    the mouse cursor
  99. ;
  100. ; void _mouse_show(void);
  101. ;
  102. ;****************************************
  103.  
  104. _mouse_show     PROC
  105.         mov    ax,1
  106.         int    33h
  107.         ret
  108. _mouse_show     ENDP
  109.  
  110. ;****************************************
  111. ; _mouse_hide    PROC:
  112. ;
  113. ;     Description:    hide the mouse cursor
  114. ;
  115. ; void _mouse_hide(void);
  116. ;
  117. ;****************************************
  118.  
  119. _mouse_hide     PROC
  120.         mov    ax,2
  121.         int    33h
  122.         ret
  123. _mouse_hide     ENDP
  124.  
  125. ;****************************************
  126. ; _mouse_get_pos PROC:
  127. ;
  128. ;     Description:    get the    mouse cursor position
  129. ;
  130. ; int  mouse_get_pos(int *x, int *y);
  131. ;
  132. ;****************************************
  133.  
  134. _mouse_get_pos  PROC
  135.         push    bp
  136.         mov     bp,sp
  137.         mov    ax,3
  138.         int    33h
  139.         mov    ax,bx
  140.         mov     bx,[bp+4]
  141.         mov    [bx],cx
  142.         mov     bx,[bp+6]
  143.         mov     [bx],dx
  144.         pop     bp
  145.         ret
  146. _mouse_get_pos  ENDP
  147.  
  148. ;****************************************
  149. ; _mouse_set_pos PROC:
  150. ;
  151. ;     Description:    set the    mouse cursor position;
  152. ;
  153. ; void _mouse_set_pos(int x, int y);
  154. ;
  155. ;****************************************
  156.  
  157. _mouse_set_pos  PROC
  158.         push    bp
  159.         mov     bp,sp
  160.         mov    ax,4
  161.         mov     cx,[bp+4]
  162.         mov     dx,[bp+6]
  163.         int     33h
  164.         pop     bp
  165.         ret
  166. _mouse_set_pos  ENDP
  167.  
  168. ;****************************************
  169. ; _mouse_button_press    PROC:
  170. ;
  171. ;     Description:    get mouse button press information
  172. ;
  173. ; int  mouse_button_press(int *x, int *y, int *count, int button);
  174. ;
  175. ;****************************************
  176.  
  177. _mouse_button_press     PROC
  178.             push    bp
  179.             mov     bp,sp
  180.             mov    ax,5
  181.             mov     bx,[bp+10]
  182.             int     33h
  183.  
  184.             push    bx
  185.             mov     bx,[bp+8]
  186.             pop    [bx]
  187.             mov     bx,[bp+6]
  188.             mov    [bx],dx
  189.             mov     bx,[bp+4]
  190.             mov    [bx],cx
  191.  
  192.             pop     bp
  193.             ret
  194. _mouse_button_press     ENDP
  195.  
  196. ;****************************************
  197. ; _mouse_button_rel      PROC:
  198. ;
  199. ;     Description:    get mouse button release information
  200. ;
  201. ;
  202. ; int  mouse_button_rel(int *x, int *y, int *count, int button);
  203. ;
  204. ;****************************************
  205.  
  206. _mouse_button_rel       PROC
  207.             push    bp
  208.             mov     bp,sp
  209.             mov    ax,6
  210.             mov     bx,[bp+10]
  211.             int    33h
  212.             push    bx
  213.  
  214.             mov     bx,[bp+8]
  215.             pop    [bx]
  216.             mov     bx,[bp+6]
  217.             mov    [bx],dx
  218.             mov     bx,[bp+4]
  219.             mov    [bx],cx
  220.  
  221.             pop     bp
  222.             ret
  223. _mouse_button_rel       ENDP
  224.  
  225. ;****************************************
  226. ; _mouse_limit_x PROC:
  227. ;
  228. ;     Description:    limit mouse cursor movement on the x axis (column)
  229. ;
  230. ; void _mouse_limit_x(int min_x, int max_x);
  231. ;
  232. ;****************************************
  233.  
  234. _mouse_limit_x  PROC
  235.         push    bp
  236.         mov     bp,sp
  237.         mov    ax,7
  238.         mov     cx,[bp+4]
  239.         mov     dx,[bp+6]
  240.         int     33h
  241.         pop     bp
  242.         ret
  243. _mouse_limit_x  ENDP
  244.  
  245. ;****************************************
  246. ; _mouse_limit_y PROC:
  247. ;
  248. ;     Description:    limit mouse cursor movement on the y axis (row)
  249. ;
  250. ; void _mouse_limit_y(int min_y, int max_y);
  251. ;
  252. ;****************************************
  253.  
  254. _mouse_limit_y  PROC
  255.         push    bp
  256.         mov     bp,sp
  257.         mov    ax,8
  258.         mov     cx,[bp+4]
  259.         mov     dx,[bp+6]
  260.         int     33h
  261.         pop     bp
  262.         ret
  263. _mouse_limit_y  ENDP
  264.  
  265.  
  266. ;****************************************
  267. ; _mouse_set_graphcursor   PROC
  268. ;
  269. ;     Description:    set mouse graphics cursor shape
  270. ;
  271. ; void _mouse_set_graphcursor(int xspot,int yspot,void far *masks);
  272. ;
  273. ;****************************************
  274.  
  275. _mouse_set_graphcursor  PROC
  276.             push    bp
  277.             mov     bp,sp
  278.             push    es
  279.             mov    ax,9
  280.             mov     bx,[bp+4]
  281.             mov     cx,[bp+6]
  282.             les     dx,[bp+8]
  283.             int     33h
  284.             pop     es
  285.             pop     bp
  286.             ret
  287. _mouse_set_graphcursor  ENDP
  288.  
  289.  
  290. ;****************************************
  291. ; _mouse_set_textcursor  PROC:
  292. ;
  293. ;     Description:    set mouse text cursor shape
  294. ;
  295. ; void _mouse_set_textcursor(int cursor_type,int scr_mask,int curs_mask);
  296. ;
  297. ;****************************************
  298.  
  299. _mouse_set_textcursor   PROC
  300.             push    bp
  301.             mov     bp,sp
  302.             mov    ax,0Ah
  303.             mov     bx,[bp+4]
  304.             mov     cx,[bp+6]
  305.             mov     dx,[bp+8]
  306.             int     33h
  307.             pop     bp
  308.             ret
  309. _mouse_set_textcursor   ENDP
  310.  
  311. ;****************************************
  312. ; _mouse_get_movement    PROC:
  313. ;
  314. ;     Description:    get mouse cursor movement information
  315. ;
  316. ; void _mouse_get_movement(int *x,int *y);
  317. ;
  318. ;****************************************
  319.  
  320. _mouse_get_movement     PROC
  321.             push    bp
  322.             mov     bp,sp
  323.             push    es
  324.             mov    ax,0Bh
  325.             int    33h
  326.  
  327.             mov     bx,[bp+4]
  328.             mov    [bx],cx
  329.             mov     bx,[bp+6]
  330.             mov     [bx],dx
  331.             pop     es
  332.             pop     bp
  333.             ret
  334. _mouse_get_movement     ENDP
  335.  
  336. ;****************************************
  337. ; _mouse_set_eventhandler        PROC:
  338. ;
  339. ;     Description:    set up a mouse event handler to    be called by
  340. ;             by the    mouse driver.
  341. ;
  342. ; void _mouse_set_eventhandler(int event_mask, void far (*mhandler)());
  343. ;
  344. ;****************************************
  345.  
  346. _mouse_set_eventhandler PROC
  347.             push    bp
  348.             mov     bp,sp
  349.             push    es
  350.             mov    ax,0Ch
  351.             mov     cx,[bp+4]
  352.             les     dx,[bp+6]
  353.             int     33h
  354.             pop     es
  355.             pop     bp
  356.             ret
  357. _mouse_set_eventhandler ENDP
  358.  
  359. ;****************************************
  360. ; _mouse_start_pen_emul  PROC:
  361. ;
  362. ;     Description:    start mouse light-pen emulation
  363. ;
  364. ; void _mouse_start_pen_emul(void);
  365. ;
  366. ;****************************************
  367.  
  368. _mouse_start_pen_emul   PROC
  369.             mov    ax,0Dh
  370.             int    33h
  371.             ret
  372. _mouse_start_pen_emul   ENDP
  373.  
  374. ;****************************************
  375. ; _mouse_stop_pen_emul   PROC:
  376. ;
  377. ;     Description:    stop mouse light-pen emulation
  378. ;
  379. ; void _mouse_stop_pen_emul(void);
  380. ;
  381. ;****************************************
  382.  
  383. _mouse_stop_pen_emul    PROC
  384.             mov    ax,0Eh
  385.             int    33h
  386.             ret
  387. _mouse_stop_pen_emul    ENDP
  388.  
  389. ;****************************************
  390. ; _mouse_set_movement_ratio      PROC:
  391. ;
  392. ;     Description:    set mouse cursor movement ratio
  393. ;
  394. ; void _mouse_set_movement_ratio(int x_ratio,int y_ratio);
  395. ;
  396. ;****************************************
  397.  
  398. _mouse_set_movement_ratio       PROC
  399.                 push    bp
  400.                 mov     bp,sp
  401.                 mov    ax,0Fh
  402.                 mov     cx,[bp+4]
  403.                 mov     dx,[bp+6]
  404.                 int     33h
  405.                 pop     bp
  406.                 ret
  407. _mouse_set_movement_ratio       ENDP
  408.  
  409. ;****************************************
  410. ; _mouse_conditional_off PROC:
  411. ;
  412. ;     Description:    conditionally turn the mouse cursor  off
  413. ;
  414. ; void _mouse_conditional_off(int left,int top,int right,int bottom);
  415. ;
  416. ;****************************************
  417.  
  418. _mouse_conditional_off  PROC
  419.  
  420.             push    bp
  421.             mov     bp,sp
  422.             push    si
  423.             push    di
  424.  
  425.             mov    ax,10h
  426.             mov     cx,[bp+4]
  427.             mov     dx,[bp+6]
  428.             mov     si,[bp+8]
  429.             mov     di,[bp+10]
  430.             int     33h
  431.  
  432.             pop     di
  433.             pop     si
  434.             pop     bp
  435.             ret
  436. _mouse_conditional_off  ENDP
  437.  
  438. ;****************************************
  439. ; _mouse_set_speed       PROC:
  440. ;
  441. ;     Description:    set mouse cursor speed
  442. ;
  443. ; void _mouse_set_speed(int threshold);
  444. ;
  445. ;****************************************
  446.  
  447. _mouse_set_speed PROC
  448.         push    bp
  449.         mov     bp,sp
  450.         mov    ax,13h
  451.         mov     bx,[bp+4]
  452.         int     33h
  453.         pop     bp
  454.         ret
  455. _mouse_set_speed ENDP
  456.  
  457. ;****************************************
  458. ; _mouse_swap_vector     PROC:
  459. ;
  460. ;     Description:    swap mouse interrupt vectors
  461. ;
  462. ; void far *_mouse_swap_vector(int new_mask,int *old_mask,void far *new_vector);
  463. ;
  464. ;****************************************
  465.  
  466. _mouse_swap_vector      PROC
  467.             push    bp
  468.             mov     bp,sp
  469.             push    es
  470.  
  471.             mov    ax,14h
  472.             mov     cx,[bp+4]
  473.             mov     bx,[bp+6]
  474.             mov    [bx],cx
  475.             les     dx,[bp+8]
  476.             int    33h
  477.             mov    ax,es
  478.             xchg    ax,dx
  479.             pop     es
  480.             pop     bp
  481.             ret
  482. _mouse_swap_vector      ENDP
  483.  
  484. ;****************************************
  485. ; _mouse_get_bufsize     PROC:
  486. ;
  487. ;     Description:    get buffer size    needed to store    mouse "state" info
  488. ;
  489. ; int  mouse_get_bufsize(void);
  490. ;
  491. ;****************************************
  492.  
  493. _mouse_get_bufsize      PROC
  494.             mov    ax,15h
  495.             int    33h
  496.             mov    ax,bx
  497.             ret
  498. _mouse_get_bufsize      ENDP
  499.  
  500. ;****************************************
  501. ; _mouse_save_state      PROC:
  502. ;
  503. ;     Description:    save the "state" of the    mouse driver
  504. ;
  505. ; void _mouse_save_state(void far *state_buf);
  506. ;
  507. ;****************************************
  508.  
  509. _mouse_save_state       PROC
  510.             push    bp
  511.             mov     bp,sp
  512.             push    es
  513.  
  514.             mov    ax,16h
  515.             les     dx,[bp+4]
  516.             int     33h
  517.  
  518.             pop     es
  519.             pop     bp
  520.             ret
  521. _mouse_save_state       ENDP
  522.  
  523. ;****************************************
  524. ; _mouse_restore_state   PROC:
  525. ;
  526. ;     Description:    restore    the mouse driver "state"
  527. ;
  528. ; void _mouse_restore_state(void far *state_buf);
  529. ;
  530. ;****************************************
  531.  
  532. _mouse_restore_state    PROC
  533.             push    bp
  534.             mov     bp,sp
  535.             push    es
  536.  
  537.             mov    ax,17h
  538.             les     dx,[bp+4]
  539.             int     33h
  540.  
  541.             pop     es
  542.             pop     bp
  543.             ret
  544. _mouse_restore_state    ENDP
  545.  
  546. ;****************************************
  547. ; _mouse_set_alt_handler PROC:
  548. ;
  549. ;     Description:    set an alternate mouse event handler
  550. ;
  551. ; void _mouse_set_alt_handler(int alt_mask,void far (*func)());
  552. ;
  553. ;****************************************
  554.  
  555. _mouse_set_alt_handler  PROC
  556.             push    bp
  557.             mov     bp,sp
  558.             push    es
  559.  
  560.             mov    ax,18h
  561.             mov     cx,[bp+4]
  562.             les     dx,[bp+6]
  563.             int     33h
  564.  
  565.             pop     es
  566.             pop     bp
  567.             ret
  568. _mouse_set_alt_handler  ENDP
  569.  
  570. ;****************************************
  571. ; _mouse_get_alt_handler PROC:
  572. ;
  573. ;     Description:    get address of alternate mouse event handler
  574. ;
  575. ; int  mouse_get_alt_handler(int alt_mask,void far *handler);
  576. ;
  577. ;****************************************
  578.  
  579. _mouse_get_alt_handler  PROC
  580.             push    bp
  581.             mov     bp,sp
  582.             push    es
  583.             push    di
  584.  
  585.             mov    ax,19h
  586.             mov     cx,[bp+4]
  587.             int    33h
  588.             les     di,[bp+6]
  589.             mov    word ptr es:[di],dx
  590.             mov    word ptr es:[di+2],bx
  591.             mov     ax,cx
  592.  
  593.             pop     di
  594.             pop     es
  595.             pop     bp
  596.             ret
  597. _mouse_get_alt_handler  ENDP
  598.  
  599. ;****************************************
  600. ; _mouse_set_sens        PROC:
  601. ;
  602. ;     Description:    set mouse sensitivity
  603. ;
  604. ; void _mouse_set_sens(int x_ratio,int y_ratio,int threshold);
  605. ;
  606. ;****************************************
  607.  
  608. _mouse_set_sens PROC
  609.         push    bp
  610.         mov     bp,sp
  611.         mov    ax,1Ah
  612.         mov     bx,[bp+4]
  613.         mov     cx,[bp+6]
  614.         mov     dx,[bp+8]
  615.         int     33h
  616.         pop     bp
  617.         ret
  618. _mouse_set_sens ENDP
  619.  
  620. ;****************************************
  621. ; _mouse_get_sens        PROC:
  622. ;
  623. ;     Description:    get mouse sensitivity
  624. ;
  625. ; void _mouse_get_sens(int *x_ratio,int *y_ratio,int *threshold);
  626. ;
  627. ;****************************************
  628.  
  629. _mouse_get_sens  PROC
  630.         push    bp
  631.         mov     bp,sp
  632.         mov    ax,1Bh
  633.         int    33h
  634.         push    bx
  635.         mov     bx,[bp+4]
  636.         pop    [bx]
  637.         mov     bx,[bp+6]
  638.         mov    [bx],cx
  639.         mov     bx,[bp+8]
  640.         mov     [bx],dx
  641.         pop     bp
  642.         ret
  643. _mouse_get_sens ENDP
  644.  
  645. ;****************************************
  646. ; _mouse_set_crt_page    PROC:
  647. ;
  648. ;     Description:    set mouse crt page (video page)
  649. ;
  650. ; void _mouse_set_crt_page(int crt_page);
  651. ;
  652. ;****************************************
  653.  
  654. _mouse_set_crt_page     PROC
  655.             push    bp
  656.             mov     bp,sp
  657.             mov    ax,1Dh
  658.             mov     bx,[bp+4]
  659.             int     33h
  660.             pop     bp
  661.             ret
  662. _mouse_set_crt_page     ENDP
  663.  
  664. ;****************************************
  665. ; _mouse_get_crt_page    PROC:
  666. ;
  667. ;     Description:    get mouse crt page (video page)
  668. ;
  669. ; int  mouse_get_crt_page(void);
  670. ;
  671. ;****************************************
  672.  
  673. _mouse_get_crt_page     PROC
  674.             mov    ax,1Eh
  675.             int    33h
  676.             mov    ax,bx
  677.             ret
  678. _mouse_get_crt_page     ENDP
  679.  
  680. ;****************************************
  681. ; _mouse_disable_drvr    PROC:
  682. ;
  683. ;     Description:    disable    mouse driver
  684. ;
  685. ; int  mouse_disable_drvr(void far *vector_33h);
  686. ;
  687. ;****************************************
  688.  
  689. _mouse_disable_drvr     PROC
  690.             push    bp
  691.             mov     bp,sp
  692.             push    es
  693.  
  694.             mov    ax,1Fh
  695.             int    33h
  696.             cmp    ax,-1
  697.             je      disable_exit
  698.             mov    dx,es
  699.             mov    cx,bx
  700.             les     bx,[bp+4]
  701.             mov    word ptr es:[bx],cx
  702.             mov    word ptr es:[bx+2],dx
  703.     disable_exit:
  704.             pop     es
  705.             pop     bp
  706.             ret
  707. _mouse_disable_drvr     ENDP
  708.  
  709. ;****************************************
  710. ; _mouse_enable_drvr     PROC:
  711. ;
  712. ;     Description:    enable mouse driver
  713. ;
  714. ; void _mouse_enable_drvr(void);
  715. ;
  716. ;****************************************
  717.  
  718. _mouse_enable_drvr      PROC
  719.             mov    ax,20h
  720.             int    33h
  721.             ret
  722. _mouse_enable_drvr      ENDP
  723.  
  724. ;****************************************
  725. ; _mouse_soft_reset      PROC:
  726. ;
  727. ;     Description:    mouse software reset
  728. ;
  729. ; int  mouse_soft_reset(int *nbuttons);
  730. ;
  731. ;****************************************
  732.  
  733. _mouse_soft_reset       PROC
  734.             push    bp
  735.             mov     bp,sp
  736.             mov    ax,21h
  737.             int    33h
  738.             cmp    ax,-1
  739.             jne     soft_exit
  740.             push    bx
  741.             mov     bx,[bp+4]
  742.             pop    [bx]
  743.  
  744.     soft_exit:
  745.             pop     bp
  746.             ret
  747. _mouse_soft_reset       ENDP
  748.  
  749.             END
  750.