home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / bios / mouse.asm < prev    next >
Assembly Source File  |  1998-06-08  |  7KB  |  345 lines

  1. ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  2. ;SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  3. ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  4. ;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  5. ;IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  6. ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  7. ;FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  8. ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  9. ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  10. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  11. ;
  12. ; $Source: f:/miner/source/bios/rcs/mouse.asm $
  13. ; $Revision: 1.5 $
  14. ; $Author: john $
  15. ; $Date: 1994/04/29 12:14:12 $
  16. ;
  17. ; Contains routines for a mouse interface.
  18. ;
  19. ; $Log: mouse.asm $
  20. ; Revision 1.5  1994/04/29  12:14:12  john
  21. ; Locked all memory used during interrupts so that program
  22. ; won't hang when using virtual memory.
  23. ; Revision 1.4  1993/07/26  10:47:03  john
  24. ; added sub mouse_set_pos
  25. ; Revision 1.3  1993/07/22  13:57:13  john
  26. ; aligned push/pops in mouse_set_limits
  27. ; Revision 1.2  1993/07/22  13:14:43  john
  28. ; added mouse set limts sub
  29. ; Revision 1.1  1993/07/10  13:10:43  matt
  30. ; Initial revision
  31. ;
  32. ;
  33. ;
  34.  
  35. ;***************************************************************************
  36. ;***************************************************************************
  37. ;*****                                                                 *****
  38. ;*****                      M O U S E . A S M                          *****
  39. ;*****                                                                 *****
  40. ;***** Contains routines for a mouse interface.                        *****
  41. ;*****                                                                 *****
  42. ;*****                                                                 *****
  43. ;***** PROCEDURES                                                      *****
  44. ;*****                                                                 *****
  45. ;***** VARIABLES                                                       *****
  46. ;*****                                                                 *****
  47. ;*****                                                                 *****
  48. ;***** CONSTANTS                                                       *****
  49. ;*****                                                                 *****
  50. ;*****                                                                 *****
  51. ;***************************************************************************
  52. ;***************************************************************************
  53.  
  54. .386
  55.  
  56. ;************************************************************************
  57. ;**************** FLAT MODEL DATA SEGMENT STUFF *************************
  58. ;************************************************************************
  59.  
  60. _DATA   SEGMENT BYTE PUBLIC USE32 'DATA'
  61.  
  62. rcsid   db  "$Id: mouse.asm 1.5 1994/04/29 12:14:12 john Exp $"
  63.  
  64.         MOUSE_EVENT STRUCT 2
  65.             MouseDX         dw  ?
  66.             MouseDY         dw  ?
  67.             MouseButtons    dw  ?
  68.             MouseFlags      dw  ?
  69.         MOUSE_EVENT ENDS
  70.  
  71.         NumberOfButtons dw ?
  72.  
  73.         MyEvent             MOUSE_EVENT < >
  74.         MyEventHandler      dd  0
  75.  
  76.  
  77.  
  78. _DATA   ENDS
  79.  
  80. DGROUP  GROUP _DATA
  81.  
  82.  
  83. ;************************************************************************
  84. ;**************** FLAT MODEL CODE SEGMENT STUFF *************************
  85. ;************************************************************************
  86.  
  87. _TEXT   SEGMENT BYTE PUBLIC USE32 'CODE'
  88.  
  89.         ASSUME  ds:_DATA
  90.         ASSUME  cs:_TEXT
  91.  
  92. PUBLIC  mouse_init_
  93.  
  94. mouse_init_:
  95.  
  96.         push    bx
  97.         xor     ax, ax      ; Reset mouse
  98.         int     33h
  99.         mov     NumberOfButtons, bx
  100.         pop     bx
  101.         or      ax, ax
  102.         jnz     present
  103.         jmp     absent
  104.  
  105.  
  106. present:
  107.         mov     ax, 0020h   ; Enable driver
  108.         int     33h
  109.  
  110.         mov     ax, 1
  111.         ret
  112.  
  113. absent:
  114.         mov     ax, 0
  115.         ret
  116.  
  117.  
  118.  
  119. PUBLIC  mouse_get_pos_
  120.  
  121. mouse_get_pos_:
  122.  
  123.         push    eax
  124.         push    ebx
  125.         push    ecx
  126.         push    edx
  127.  
  128.         push    eax
  129.  
  130.         mov     ax, 03h     ; Get Mouse Position and Button Status
  131.         int     33h
  132.         ; bx = buttons, cx = x, dx = y
  133.  
  134.         pop     eax
  135.         mov     [eax], cx
  136.         pop     eax
  137.         mov     [eax], dx
  138.         mov     edx, eax
  139.  
  140.         pop     ecx
  141.         pop     ebx
  142.         pop     eax
  143.  
  144.         ret
  145.  
  146. PUBLIC  mouse_get_delta_
  147.  
  148. mouse_get_delta_:
  149.  
  150.         push    eax
  151.         push    ebx
  152.         push    ecx
  153.         push    edx
  154.  
  155.  
  156.         push    eax
  157.  
  158.         mov     eax, 0bh    ; Read Mouse Motion Counters
  159.         int     33h
  160.  
  161.         pop     eax
  162.         mov     [eax], cx
  163.         pop     eax
  164.         mov     [eax], dx
  165.         mov     edx, eax
  166.  
  167.         pop     ecx
  168.         pop     ebx
  169.         pop     eax
  170.         ret
  171.  
  172.  
  173. PUBLIC  mouse_get_btns_
  174.  
  175. mouse_get_btns_:
  176.  
  177.         push    ebx
  178.         push    ecx
  179.         push    edx
  180.  
  181.         mov     ax, 03h     ; Get Mouse Position and Button Status
  182.         int     33h
  183.         ; bx = buttons, cx = x, dx = y
  184.  
  185.         movzx   eax, bx
  186.  
  187.         pop     edx
  188.         pop     ecx
  189.         pop     ebx
  190.  
  191.         ret
  192.  
  193.  
  194. PUBLIC  mouse_close_
  195.  
  196. mouse_close_:
  197.  
  198.         push    eax
  199.         push    ebx
  200.         push    es
  201.  
  202.         mov     ax, 01fh    ; Disable mouse driver
  203.         int     33h
  204.  
  205.         pop     es
  206.         pop     ebx
  207.         pop     eax
  208.  
  209.         ret
  210.  
  211. MyHandler:
  212.  
  213.         pushad
  214.         push    ds
  215.  
  216.         push    ax
  217.         mov     ax, DGROUP
  218.         mov     ds, ax
  219.         pop     ax
  220.  
  221.         mov     MyEvent.MouseDX, cx
  222.         mov     MyEvent.MouseDY, dx
  223.         mov     MyEvent.MouseButtons, bx
  224.         mov     MyEvent.MouseFlags, ax
  225.  
  226.         mov     eax, offset MyEvent
  227.  
  228.         call    MyEventHandler
  229.  
  230.         pop     ds
  231.         popad
  232.  
  233.         retf
  234.  
  235. PUBLIC  mouse_set_handler_
  236.  
  237. mouse_set_handler_:
  238.  
  239.         push    eax
  240.         push    ebx
  241.         push    ecx
  242.         push    edx
  243.         push    es
  244.  
  245.         mov     MyEventHandler, edx
  246.  
  247.         mov     ecx, eax    ; Event flags
  248.         mov     edx, MyHandler
  249.         mov     ax, cs
  250.         mov     es, ax
  251.         mov     ax, 0Ch     ; Set User-defined Mouse Event Handler
  252.         int     33h
  253.  
  254.         pop     es
  255.         pop     edx
  256.         pop     ecx
  257.         pop     edx
  258.         pop     eax
  259.  
  260.         ret
  261.  
  262. PUBLIC  mouse_clear_handler_
  263.  
  264. mouse_clear_handler_:
  265.  
  266.         push    eax
  267.         push    ebx
  268.         push    ecx
  269.         push    edx
  270.         push    es
  271.  
  272.         mov     MyEventHandler, 0
  273.  
  274.         mov     ecx, 0    ; Event flags
  275.         mov     edx, MyHandler
  276.         mov     ax, cs
  277.         mov     es, ax
  278.         mov     ax, 0Ch     ; Set User-defined Mouse Event Handler
  279.         int     33h
  280.  
  281.         pop     es
  282.         pop     edx
  283.         pop     ecx
  284.         pop     edx
  285.         pop     eax
  286.  
  287.         ret
  288.  
  289.  
  290. PUBLIC  mouse_set_limits_
  291.  
  292. mouse_set_limits_:
  293.  
  294.         ; EAX = minx
  295.         ; EDX = miny
  296.         ; EBX = maxx
  297.         ; ECX = maxy
  298.  
  299.         push    edx     ; Save Vertical stuff
  300.         push    ecx
  301.  
  302.         mov     cx, ax
  303.         mov     dx, bx
  304.         mov     ax, 7
  305.         int     33h
  306.  
  307.         pop     edx
  308.         pop     ecx
  309.         mov     ax, 8
  310.         int     33h
  311.  
  312.         ret
  313.  
  314.  
  315. ;extern void mouse_set_pos( short x, short y);
  316.  
  317.  
  318. PUBLIC  mouse_set_pos_
  319.  
  320. mouse_set_pos_:
  321.  
  322.         ; EAX = x
  323.         ; EDX = y
  324.  
  325.         push    ecx
  326.  
  327.         mov     ecx, eax
  328.         mov     eax, 04h
  329.         int     33h
  330.         pop     ecx
  331.  
  332.  
  333.         ret
  334.  
  335.  
  336.  
  337. _TEXT   ENDS
  338.  
  339.  
  340.         END
  341.