home *** CD-ROM | disk | FTP | other *** search
/ Grapevine 5 / Grapevine 5.adf / grapevine5 / MOUSE.S < prev    next >
Encoding:
Text File  |  1990-09-07  |  2.4 KB  |  74 lines

  1.  
  2.            opt      c-,o-
  3. Ymax       = 256                        ; Maximum allowed Y position
  4. Ymin       = 0                          ; Minimum allowed Y position
  5.  
  6.  
  7.  
  8.            ********************
  9.            clr.l    d0
  10.            move.b   $dff00a,d0          ; joy0dat
  11.            move.w   d0,oldy             ; setup lastreading variable
  12.            move.w   #0,ypos             ; clear ypos
  13.            ********************
  14.            ; Your program goes here. You should put 'Bsr Readmouse' in your
  15.            ; VBlank (level 3) interupt and then when you want to read the mouse
  16.            ; position you should just get the word found at Ypos: which contains
  17.            ; the mouse position.
  18.  
  19.  
  20.  
  21.            *******************          ; Include this subroutine in your
  22.                                         ; program.
  23. readmouse:
  24.            clr.w    d0
  25.            move.b   $dff00a,d0          ; joy0dat
  26.            move.w   oldy,d1
  27.            sub      d0,d1
  28.            move.w   d1,yp               ; calculate diference between the
  29.                                         ; last reading and the current reading
  30.  
  31.            move.w   d0,oldy             ; store the current reading
  32.  
  33.            cmp.w    #128,yp             ; is the diference greater that 128
  34.                                         ; (129-255)
  35.            blt      mouse_not_128
  36.            sub.w    #256,yp             ; make it 0 to 127
  37.  
  38. mouse_not_128:
  39.            cmp.w    #-128,yp            ; is the differnce between -128 and 0
  40.            bgt      mouse_not_minus
  41.            add.w    #256,yp             ; make it in the range 0 to 127
  42.  
  43. mouse_not_minus:
  44.            move.w   yp,d0
  45.            add.w    d0,yp2              ; add on the difference to the mouse
  46.                                         ; position
  47.  
  48.            cmp.w    #ymin,yp2           ; check if it goes out of range
  49.            bge.s    ypos_ok1
  50.            move.w   #ymin,yp2           ; stop if going out of range
  51. ypos_ok1:
  52.  
  53.            cmp.w    #ymax,yp2           ; check if it goes out of range
  54.            blt.s    ypos_ok2
  55.            move.w   #ymax,yp2           ; stop if going out of range
  56. ypos_ok2:
  57.  
  58.            move.w   #256,d0             ; invert the reading as mouse reader
  59.            sub.w    yp2,d0              ; gives the reverse info
  60.            move.w   d0,ypos             ; store in user var
  61.  
  62.            rts
  63.  
  64.  
  65. ypos:      dc.w     0
  66. oldy:      dc.w     0
  67. yp:        dc.w     0
  68. yp2:       dc.w     0
  69.  
  70.  
  71.            end
  72.  
  73.  
  74.