home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / MOOSE.143 / IKBD.S < prev    next >
Encoding:
Text File  |  1996-05-06  |  2.4 KB  |  106 lines

  1. *** IKBD Handler **********************************************************
  2.  
  3.     SECTION TEXT
  4.  
  5.  
  6. * The IKBD handler is where we gather interesting mouse button information
  7. * and jam it into the md_buffer ready for the VBI timer handler to
  8. * interpret.
  9.  
  10. IKBD_handler    movem.l    d1-7/a0-6,-(a7)
  11.  
  12.     lea    variables(pc),a6
  13.  
  14.  
  15. * if the buffer is full, just return (there's nothing we can do about
  16. * this except get a bigger buffer - but don't worry, I can't see any
  17. * human being making 64 mouse clicks in 1/50th of a second - that's
  18. * 0.3125 milliseconds per click... :)
  19.  
  20.     cmpi.w    #MD_BUFFER_SIZE,inbuf(a6)
  21.     beq    .return
  22.  
  23.  
  24. * make sure we only interpret relative mouse data (if someone tells the
  25. * IKBD be strange and report mouse data as absolute, we won't break)
  26.  
  27.     move.b    (a0),d0
  28.     andi.b    #$f8,d0
  29.     cmpi.b    #$f8,d0
  30.     bne    .return
  31.  
  32.  
  33. ** handle the buttons
  34.  
  35. * convert IKBD button state into AES button state
  36.  
  37.     moveq    #0,d0    make the buttons AES format
  38.     move.b    (a0),d0
  39.     andi.b    #%11,d0
  40.     lsr.b    #1,d0
  41.     bcc    .done_convert        
  42.     bset    #1,d0        
  43. .done_convert
  44.  
  45. * are buttons different to what they were last time? if not, don't write
  46. * another button packet (this happens all the time since we also get mouse
  47. * movement packets here)
  48.  
  49.     cmp.w    old_buttons(a6),d0
  50.     beq    .done_buttons
  51.  
  52.     move.w    d0,old_buttons(a6)
  53.  
  54.  
  55. * write the button packet to the moose device buffer
  56.  
  57.     bsr    IKBD_but_write
  58. .done_buttons
  59.  
  60.  
  61. ** handle the mouse movement
  62.  
  63. * well, actually we don't... but we could if we wanted to handle mouse
  64. * rectangles here
  65.  
  66.  
  67. .return    move.l    old_IKBD_handler(a6),d0
  68.     movem.l    (a7)+,d1-7/a0-6
  69.     move.l    d0,-(a7)
  70.     rts
  71.  
  72.  
  73. ** Write a Packet of Button Data To MD_BUFFER ********************** A6 ***
  74.  
  75. * This writes a button event packet to the moose device. The
  76. * moose x and y position as added in here.
  77.  
  78. *  in: d0.w=button state for this packet
  79.  
  80. * packet data format is as per the BUT_PAK structure                        4.w=x at click, 6.w=y at click
  81.  
  82.  
  83. IKBD_but_write    movem.l    d0-7/a0-6,-(a7)
  84.  
  85.     lea    moose_packet(pc),a0
  86.  
  87.     move.l    linea(a6),a1
  88.     
  89.     move.w    #(BUT_PAK_LEN/2)-1,(a0)
  90.  
  91.     move.b    #BUT_PAK,BUT_PAK_TYPE+2(a0)
  92.     move.b    d0,BUT_PAK_STATE+2(a0)
  93.     OPT    NOCHKIMM
  94.     move.w    SYSTIMER+2,BUT_PAK_TIME+2(a0)
  95.     OPT    CHKIMM
  96.     move.w    -602(a1),BUT_PAK_X+2(a0)
  97.     move.w    -600(a1),BUT_PAK_Y+2(a0)
  98.  
  99.     bsr    int_write
  100.  
  101.     movem.l    (a7)+,d0-7/a0-6
  102.     rts
  103.  
  104.  
  105. ***************************************************************************
  106.