home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 118.lha / MouseUtil.asm < prev    next >
Assembly Source File  |  1986-11-20  |  9KB  |  439 lines

  1. ******************************************************************
  2. *                                                                *
  3. *                     MouseUtil  Version 1.0                     *
  4. *                 Programming By Luciano Bertato                 *
  5. *                     CompuServe: 73246,1744                     *
  6. *             Canada Remote Systems: LUCIANO BERTATO             *
  7. *                 Date:  Saturday March 26, 1988                 *
  8. *                                                                *
  9. ******************************************************************
  10.  
  11. ** external reference
  12.  
  13.    XREF     _AbsExecBase
  14.  
  15. ** macros
  16.  
  17. LIBCALL  MACRO
  18.            XREF    _LVO\1
  19.            CLR.L   d0
  20.            MOVEA.L _AbsExecBase,a6
  21.            JSR     _LVO\1(a6)
  22.          ENDM
  23.  
  24. CALL     MACRO
  25.            XREF    _LVO\1
  26.            JSR     _LVO\1(a6)
  27.          ENDM
  28.  
  29. ** open everything ***********************************************
  30.  
  31. ** start
  32.  
  33. _main:
  34.    movem.l  d0-d7/a0-a6,-(sp)
  35.  
  36.    movea.l  #IntuiName,a1
  37.    LIBCALL  OpenLibrary
  38.    move.l   d0,IntuitionBase
  39.    beq      abort1
  40.  
  41.    movea.l  #DosName,a1
  42.    LIBCALL  OpenLibrary
  43.    move.l   d0,DosBase
  44.    beq      abort2
  45.  
  46.    movea.l  #GfxName,a1
  47.    LIBCALL  OpenLibrary
  48.    move.l   d0,GfxBase
  49.    beq      abort3
  50.  
  51.    movea.l  #PrefBuffer,a0
  52.    movea.l  IntuitionBase,a6
  53.    move.l   #PrefBufferSize,d0
  54.    CALL     GetPrefs
  55.    tst.w    d0
  56.    beq      abort4
  57.    move.l   d0,a0
  58.    move.w   PointerTicks(a0),d0
  59.    move.w   d0,TickValue
  60.    cmp.w    #4,d0
  61.    beq      Fourset
  62.    cmp.w    #2,d0
  63.    beq      Twoset
  64.    or.w     #SELECTED,OneGadget+12
  65.    bra      Windowmake
  66. Twoset:
  67.    or.w     #SELECTED,TwoGadget+12
  68.    bra      Windowmake
  69. Fourset:
  70.    or.w     #SELECTED,FourGadget+12
  71.  
  72. Windowmake:
  73.    movea.l  #window,a0
  74.    movea.l  IntuitionBase,a6
  75.    CALL     OpenWindow
  76.    move.l   d0,Windowptr
  77.    beq      abort4
  78.    move.l   d0,a0
  79.    move.l   wd_RPort(a0),RPort
  80.  
  81.    movea.l  #TextAttr,a0
  82.    movea.l  GfxBase,a6
  83.    CALL     OpenFont
  84.    movea.l  d0,a0
  85.    beq      abort5
  86.    move.l   a0,Fontptr
  87.    movea.l  RPort,a1
  88.    movea.l  GfxBase,a6
  89.    CALL     SetFont
  90.  
  91. ******************************************************************
  92.  
  93. **waiting for gadget selection
  94.  
  95. AdjustLoop:
  96.    movea.l  Windowptr,a0
  97.    movea.l  wd_UserPort(a0),a0
  98.    move.b   MP_SIGBIT(a0),d1
  99.    moveq.l  #1,d0
  100.    lsl.l    d1,d0
  101.    movea.l  _AbsExecBase,a6
  102.    CALL     Wait
  103.  
  104. ******************************************************************
  105.  
  106. Look:
  107.    movea.l  Windowptr,a0
  108.    movea.l  wd_UserPort(a0),a0
  109.    movea.l  _AbsExecBase,a6
  110.    CALL     GetMsg
  111.    movea.l  d0,a1
  112.    move.l   a1,-(sp)
  113.    movea.l  im_IAddress(a1),a0
  114.    move.w   gg_GadgetID(a0),d0
  115.    cmp.w    #8,d0
  116.    beq      Done
  117.    cmp.w    #16,d0
  118.    bne      AdjustTicks
  119.    move.w   TickValue,d0
  120.    jsr      ChangeTicks
  121.    bra      Done
  122. AdjustTicks:
  123.    jsr      ChangeTicks
  124.    movea.l  (sp)+,a1
  125.    jsr      Reply
  126.    move.w   NewTickValue,d0
  127.    cmp.w    #1,d0
  128.    bne      Jump1
  129.    or.w     #SELECTED,OneGadget+12
  130.    bra      Jump2
  131. Jump1:
  132.    and.w    #DESELECTED,OneGadget+12
  133. Jump2:
  134.    cmp.w    #2,d0
  135.    bne      Jump3
  136.    or.w     #SELECTED,TwoGadget+12
  137.    bra      Jump4
  138. Jump3:
  139.    and.w    #DESELECTED,TwoGadget+12
  140. Jump4:
  141.    cmp.w    #4,d0
  142.    bne      Jump5
  143.    or.w     #SELECTED,FourGadget+12
  144.    bra      Jump6
  145. Jump5:
  146.    and.w    #DESELECTED,FourGadget+12
  147. Jump6:
  148.    bra      AdjustLoop
  149.  
  150. ** exit program **************************************************
  151.  
  152. **Done
  153.  
  154. Done:
  155.    movea.l  (sp)+,a1
  156.    jsr      Reply
  157.  
  158. **abort
  159.  
  160. abort5:
  161.    movea.l  Windowptr,a0
  162.    movea.l  IntuitionBase,a6
  163.    CALL     CloseWindow
  164. abort4:
  165.    movea.l  GfxBase,a1
  166.    LIBCALL  CloseLibrary
  167. abort3:
  168.    movea.l  DosBase,a1
  169.    LIBCALL  CloseLibrary
  170. abort2:
  171.    movea.l  IntuitionBase,a1
  172.    LIBCALL  CloseLibrary
  173. abort1:
  174.    movem.l  (sp)+,d0-d7/a0-a6
  175.    clr.l    d0
  176.    rts
  177.  
  178. ******************************************************************
  179.  
  180. **subroutines
  181.  
  182. ChangeTicks:
  183.    movea.l  #PrefBuffer,a0
  184.    lea      PointerTicks(a0),a1
  185.    move.w   d0,(a1)
  186.    move.w   d0,NewTickValue
  187.    movea.l  IntuitionBase,a6
  188.    move.l   #PrefBufferSize,d0
  189.    moveq.l  #1,d1
  190.    CALL     SetPrefs
  191.    rts
  192. Reply:
  193.    movea.l  _AbsExecBase,a6
  194.    CALL     ReplyMsg
  195.    rts
  196.  
  197. ******************************************************************
  198.  
  199.    SECTION  data,DATA
  200.  
  201. window:
  202.    dc.w     30,30,320,90
  203.    dc.b     0,1
  204.    dc.l     IDCMPflags,flags,DoneGadget,0,title,0,0
  205.    dc.w     1,1,640,200,WBENCHSCREEN
  206.  
  207. ******************************************************************
  208.  
  209. DoneGadget:
  210.    dc.l     CancelGadget
  211.    dc.w     200,70,50,11
  212.    dc.w     GADGHCOMP,RELVERIFY,BOOLGADGET
  213.    dc.l     Done_border,0,Done_text,0,0
  214.    dc.w     8
  215.    dc.l     0
  216. Done_text:
  217.    dc.b     1,0,1,0
  218.    dc.w     2,2
  219.    dc.l     0,DG_text,0
  220. Done_border:
  221.    dc.w     0,0
  222.    dc.b     1,0,JAM1,5
  223.    dc.l     DoneXY,0
  224. DoneXY:
  225.    dc.w     0,0
  226.    dc.w     50,0
  227.    dc.w     50,11
  228.    dc.w     0,11
  229.    dc.w     0,0
  230. DG_text:
  231.    dc.b     ' Done ',0,0
  232.  
  233. ******************************************************************
  234.  
  235. CancelGadget:
  236.    dc.l     OneGadget
  237.    dc.w     70,70,66,11
  238.    dc.w     GADGHCOMP,RELVERIFY,BOOLGADGET
  239.    dc.l     Cancel_border,0,Cancel_text,0,0
  240.    dc.w     16
  241.    dc.l     0
  242. Cancel_text:
  243.    dc.b     1,0,1,0
  244.    dc.w     2,2
  245.    dc.l     0,CG_text,0
  246. Cancel_border:
  247.    dc.w     0,0
  248.    dc.b     1,0,JAM1,5
  249.    dc.l     CancelXY,0
  250. CancelXY:
  251.    dc.w     0,0
  252.    dc.w     66,0
  253.    dc.w     66,11
  254.    dc.w     0,11
  255.    dc.w     0,0
  256. CG_text:
  257.    dc.b     ' Cancel ',0,0
  258.  
  259. ******************************************************************
  260.  
  261. OneGadget:
  262.    dc.l     TwoGadget
  263.    dc.w     193,45,66,11
  264.    dc.w     GADGHNONE,TOGGLESELECT!RELVERIFY,BOOLGADGET
  265.    dc.l     One_border,0,One_text,0,0
  266.    dc.w     1
  267.    dc.l     0
  268. One_text:
  269.    dc.b     1,0,1,0
  270.    dc.w     31,2
  271.    dc.l     0,OG_text,0
  272. One_border:
  273.    dc.w     0,0
  274.    dc.b     1,0,JAM1,5
  275.    dc.l     OneXY,0
  276. OneXY:
  277.    dc.w     0,0
  278.    dc.w     66,0
  279.    dc.w     66,11
  280.    dc.w     0,11
  281.    dc.w     0,0
  282. OG_text:
  283.    dc.b     '1',0
  284.  
  285. ******************************************************************
  286.  
  287. TwoGadget:
  288.    dc.l     FourGadget
  289.    dc.w     127,45,66,11
  290.    dc.w     GADGHNONE,TOGGLESELECT!RELVERIFY,BOOLGADGET
  291.    dc.l     Two_border,0,Two_text,0,0
  292.    dc.w     2
  293.    dc.l     0
  294. Two_text:
  295.    dc.b     1,0,1,0
  296.    dc.w     31,2
  297.    dc.l     0,TG_text,0
  298. Two_border:
  299.    dc.w     0,0
  300.    dc.b     1,0,JAM1,5
  301.    dc.l     TwoXY,0
  302. TwoXY:
  303.    dc.w     0,0
  304.    dc.w     66,0
  305.    dc.w     66,11
  306.    dc.w     0,11
  307.    dc.w     0,0
  308. TG_text:
  309.    dc.b     '2',0
  310.  
  311. ******************************************************************
  312.  
  313. FourGadget:
  314.    dc.l     0
  315.    dc.w     61,45,66,11
  316.    dc.w     GADGHNONE,TOGGLESELECT!RELVERIFY,BOOLGADGET
  317.    dc.l     Four_border,0,Four_text,0,0
  318.    dc.w     4
  319.    dc.l     0
  320. Four_text:
  321.    dc.b     1,0,1,0
  322.    dc.w     31,2
  323.    dc.l     0,FG_text,Four_text2
  324. Four_text2:
  325.    dc.b     1,0,1,0
  326.    dc.w     10,-25
  327.    dc.l     0,FG_text2,Four_text3
  328. Four_text3:
  329.    dc.b     1,0,1,0
  330.    dc.w     0,-8
  331.    dc.l     0,FG_text3,Four_text4
  332. Four_text4:
  333.    dc.b     1,0,1,0
  334.    dc.w     168,-8
  335.    dc.l     0,FG_text4,0
  336. Four_border:
  337.    dc.w     0,0
  338.    dc.b     1,0,JAM1,5
  339.    dc.l     FourXY,0
  340. FourXY:
  341.    dc.w     0,0
  342.    dc.w     66,0
  343.    dc.w     66,11
  344.    dc.w     0,11
  345.    dc.w     0,0
  346. FG_text:
  347.    dc.b     '4',0
  348. FG_text2:
  349.    dc.b     'Select The Mouse Speed:',0
  350. FG_text3:
  351.    dc.b     'Slow',0,0
  352. FG_text4:
  353.    dc.b     'Fast',0,0
  354.  
  355. ******************************************************************
  356.  
  357. TextAttr:
  358.    dc.l     FontName
  359.    dc.w     8
  360.    dc.b     0,0
  361.  
  362. ******************************************************************
  363.  
  364. title:
  365.    dc.b     ' MouseUtil V1.0 ',0,0
  366. IntuiName:
  367.    dc.b     'intuition.library',0
  368. DosName:
  369.    dc.b     'dos.library',0
  370. GfxName:
  371.    dc.b     'graphics.library',0,0
  372. FontName:
  373.    dc.b     'topaz.font',0,0
  374.  
  375. ******************************************************************
  376.  
  377. WBENCHSCREEN EQU $0001
  378. ACTIVATE EQU $1000
  379. WINDOWDRAG EQU $0002
  380. WINDOWCLOSE EQU $0008
  381. SMART_REFRESH EQU $0000
  382. STRGADGET EQU $0004
  383. BOOLGADGET EQU $0001
  384. PROPGADGET EQU $0003
  385. TOGGLESELECT EQU $0100
  386. RELVERIFY EQU $0001
  387. GADGIMMEDIATE EQU $0002
  388. FOLLOWMOUSE EQU $0008
  389. SELECTED EQU $0080
  390. DESELECTED EQU $FF7F
  391. GADGHCOMP EQU $0000
  392. GADGHBOX EQU $0001
  393. GADGHIMAGE EQU $0002
  394. GADGHNONE EQU $0003
  395. CLOSEWINDOW EQU $00000200
  396. GADGETUP EQU $00000040
  397. FREEVERT EQU $0004
  398. FREEHORIZ EQU $0002
  399. AUTOKNOB EQU $0001
  400. JAM1 EQU $0000
  401. MP_SIGBIT EQU $0F
  402. wd_UserPort EQU $56
  403. wd_RPort EQU $32
  404. im_IAddress EQU $1c
  405. gg_GadgetID EQU 38
  406. PointerTicks EQU $6c
  407. PrefBufferSize EQU 232
  408.  
  409. flags EQU ACTIVATE!WINDOWDRAG!SMART_REFRESH
  410. IDCMPflags EQU GADGETUP
  411.  
  412. ******************************************************************
  413.  
  414.    SECTION  mem,BSS
  415.  
  416. IntuitionBase:
  417.    ds.l     1   ;intuition base address pointer
  418. DosBase:
  419.    ds.l     1   ;dos base address pointer
  420. GfxBase:
  421.    ds.l     1   ;graphics base address pointer
  422. Windowptr:
  423.    ds.l     1   ;pointer to window
  424. RPort:
  425.    ds.l     1   ;rp pointer for window
  426. Fontptr:
  427.    ds.l     1   ;pointer to font
  428. TickValue:
  429.    ds.w     1   ;original mouse speed
  430. NewTickValue:
  431.    ds.w     1   ;changed mouse speed
  432. PrefBuffer:
  433.    ds.b     232 ;preferences buffer
  434.  
  435. ******************************************************************
  436.  
  437.    END
  438.  
  439.