home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 1183.dms / 1183.adf / MouseXY / Mouse-xy.asm < prev    next >
Assembly Source File  |  1991-07-17  |  19KB  |  773 lines

  1. *    Mouse-xy V1.0
  2. *    By Preben Nielsen
  3. *
  4. *      This utility opens a little window in which it shows
  5. *    the mouse coordinates and the color at that position
  6. *      If the left mousebutton is being held down, the coordinates
  7. *    is relative to the spot where the mouse was when button got
  8. *    pressed.
  9. *
  10. *      Double-clicking the right mousebutton while the window is
  11. *    active will make it try to jump to another screen (if any).
  12. *
  13. *      The size of the window and the use of colors in it depends on
  14. *    the version of the Kickstart/Workbench (1.2/1.3 vs. 2.?) and
  15. *    the screen mode (LORES vs. HIRES)
  16. *
  17. *    NOTE:    There's no need to 'RUN' or 'RUNBACK' this program from the
  18. *        CLI. It is auto-detaching.
  19. *
  20. *HISTORY
  21. *          Made with Hisoft V2.12
  22. *
  23. *  V1.0   17-Mar-91: First attempt
  24. *         19-Mar-91: Added color monitoring
  25. *         21-Mar-91: Even Works while intuition locks all layers because
  26. *                    I now patch 'LockLayerRom' and 'UnLockLayerRom'.
  27. *                    You can now monitor the coordinates even while you
  28. *                    are sizing  window, dragging window/icons and even
  29. *                    when you select menus
  30. *         07-Apr-91: I Now patch 'CloseScreen' so that the window
  31. *                    automatically evacuates any closing screen.
  32. *         19-Apr-91: Made some modifications to make it look better
  33. *                    under WB2.0 (haven't actually tried it yet)
  34.  
  35.     OPT O+
  36.     OPT O1+            ; Tells when a branch could be optimised to short
  37. ;    OPT i+            ; Tells when '#' is probably missing
  38.  
  39. LMBBUT        =$BFE001    ; Bit 6
  40.  
  41. Prepare        MACRO
  42.         IFC        '\1','Exec_Call'
  43.         movea.l        4.W,A6
  44.         ENDC
  45.         IFC        '\1','Intuition_Call'
  46.         movea.l        IntBase(DB),A6
  47.         ENDC
  48.         IFC        '\1','Gfx_Call'
  49.         movea.l        GfxBase(DB),A6
  50.         ENDC
  51.         IFC        '\1','Dos_Call'
  52.         movea.l        DosBase(DB),A6
  53.         ENDC
  54.         ENDM
  55. CallLib        MACRO
  56.         jsr        _LVO\1(A6)
  57.         ENDM
  58. Call        MACRO
  59.         bsr        \1
  60.         ENDM
  61. Push        MACRO        Push <reg-list | All>
  62.         IFC        '\1','All'
  63.         movem.l        D0-D7/A0-A6,-(SP)
  64.         ENDC
  65.         IFNC        '\1','All'
  66.         movem.l        \1,-(SP)
  67.         ENDC
  68.         ENDM
  69. Pop        MACRO        Pop <reg-list | All>
  70.         IFC        '\1','All'
  71.         movem.l        (SP)+,D0-D7/A0-A6
  72.         ENDC
  73.         IFNC        '\1','All'
  74.         movem.l        (SP)+,\1
  75.         ENDC
  76.         ENDM
  77. rAPtr        MACRO        Name
  78. DefSiz        set        DefSiz+4
  79. DefPtr        set        DefPtr-4
  80. \1        =        DefPtr
  81.         ENDM
  82. rLong        MACRO        Name
  83. DefSiz        set        DefSiz+4
  84. DefPtr        set        DefPtr-4
  85. \1        =        DefPtr
  86.         ENDM
  87. rWord        MACRO        Name
  88. DefSiz        set        DefSiz+2
  89. DefPtr        set        DefPtr-2
  90. \1        =        DefPtr
  91.         ENDM
  92. rByte        MACRO        Name
  93. DefSiz        set        DefSiz+1
  94. DefPtr        set        DefPtr-1
  95. \1        =        DefPtr
  96.         ENDM
  97. rStorage    MACRO        Name,Size    ; Define storage
  98. DefSiz        set        DefSiz+\2
  99. DefPtr        set        DefPtr-\2
  100. \1        =        DefPtr
  101.         ENDM
  102. rEVEN        MACRO                ; Word boundary
  103.         IFNE        DefPtr&1
  104. DefPtr        set        DefPtr-1
  105. DefSiz        set        DefSiz+1
  106.         ENDC
  107.         ENDM
  108. rStart        MACRO                ; Define var section
  109. DefPtr        set        0
  110. DefSiz        set        0
  111.         ENDM
  112. rEnd        MACRO                ; End var section
  113. RelSize        =        DefSiz
  114.         ENDM
  115. rAlloc        MACRO                ; Allocate storage
  116.         link        DB,#-RelSize
  117.         ENDM
  118. rFree        MACRO                ; De-allocate storage
  119.         unlk        DB
  120.         ENDM
  121. rClear        MACRO                ; Reset all variables
  122.         movem.l        D0/A0,-(SP)
  123.         move.w        #RelSize-1,D0
  124.         move.l        DB,A0
  125. rClr.\@        clr.b        -(A0)
  126.         dbf        D0,rClr.\@
  127.         movem.l        (SP)+,D0/A0
  128.         ENDM
  129. Detach        MACRO        ; Detach <'process name'>,stacksize,processpri
  130.         SECTION        SingleSplit,CODE
  131. Start        Prepare        Exec_Call
  132.         suba.l        A1,A1
  133.         CallLib        FindTask        ; Find us
  134.         move.l        D0,A2
  135.         tst.l        pr_CLI(A2)
  136.         bne.S        SegSplit
  137.         jmp        ProcessStart        ; from WorkBench
  138. SegSplit    CallLib        Forbid            ; From Dos
  139.         lea        DName(PC),A1
  140.         CallLib        OldOpenLibrary
  141.         move.l        D0,D5
  142.         beq.S        3$
  143.         moveq        #ML_SIZE+1*ME_SIZE,D0
  144.         move.l        #MEMF_PUBLIC|MEMF_CLEAR,D1
  145.         CallLib        AllocMem        ; Allocate Memlist
  146.         move.l        D0,A2
  147.         tst.l        D0
  148.         beq.S        2$
  149.         move.l        #ProcessName,D1
  150.         moveq        #\3,D2            ; Priority
  151.         move.l        Start-4(PC),D3
  152.         move.l        #\2,D4            ; StackSize
  153.         move.l        D5,A6
  154.         CallLib        CreateProc
  155.         Prepare        Exec_Call
  156.         tst.l        D0
  157.         beq.S        1$
  158.         move.l        D0,A0
  159.         lea        -pr_MsgPort(A0),A0    ; Now we have process
  160.         not.l        pr_CLI(A0)        ; All MY programs will now think they were started from the CLI
  161.         lsl.l        #2,D3
  162.         subq.l        #4,D3
  163.         move.l        D3,A1
  164.         move.w        #1,ML_NUMENTRIES(A2)    ; MemList -> ml_NumEntries    = 1
  165.         move.l        A1,ML_ME+ME_ADDR(A2)    ; MemList -> ml_me[0].me_Addr    = Segment
  166.         move.l        (A1),ML_ME+ME_LENGTH(A2); MemList -> ml_me[0].me_Length    = Length
  167.         lea        TC_MEMENTRY(A0),A0
  168.         move.l        A2,A1
  169.         CallLib        AddTail            ; AddTail(&Process->pr_Task.tc_MemEntry,&MemList->ml_Node);
  170.         lea        Start-4(PC),A0
  171.         clr.l        (A0)            ; Split the segments
  172.         bra.S        2$
  173. 1$        move.l        A2,A1            ; CreateProc failed. Can't do anything then
  174.         moveq        #ML_SIZE+1*ME_SIZE,D0
  175.         CallLib        FreeMem
  176. 2$        move.l        D5,A1
  177.         CallLib        CloseLibrary
  178. 3$        CallLib        Permit
  179.         moveq        #0,D0
  180.         rts
  181. DName        dc.b        'dos.library',0
  182. ProcessName    dc.b        \1,0            ; CreateProc makes a copy of this name
  183.         SECTION        ProcessCode,CODE
  184. ProcessStart
  185.         ENDM
  186.  
  187.         incdir        "AsmInc:"
  188.         include        "exec/exec_lib.i"
  189.         include        "exec/memory.i"
  190.         include        "exec/interrupts.i"
  191.         include        "intuition/intuition.i"
  192.         include        "intuition/intuitionbase.i"
  193.         include        "intuition/intuition_lib.i"
  194.         include        "graphics/graphics_lib.i"
  195.         include        "libraries/dos_lib.i"
  196.         include        "libraries/dosextens.i"
  197.         include        "hardware/intbits.i"
  198.  
  199. xy_Change_B    =SIGBREAKB_CTRL_D
  200. xy_Change_F    =1<<xy_Change_B
  201. LMB_Change_B    =SIGBREAKB_CTRL_E
  202. LMB_Change_F    =1<<LMB_Change_B
  203. Remove_Screen_B    =SIGBREAKB_CTRL_F
  204. Remove_Screen_F =1<<Remove_Screen_B
  205. WaitMask    =xy_Change_F|LMB_Change_F|Remove_Screen_F
  206.  
  207. DB        EQUR        A4
  208.  
  209. InitProcess    Detach        <'xy Process'>,4000,0
  210.         rAlloc                    ; Allocate memory for variables
  211.         rClear                    ; Clear the memory
  212.         lea        SpareA4(PC),A0
  213.         move.l        DB,(A0)
  214.         Prepare        Exec_Call
  215.         suba.l        A1,A1
  216.         CallLib        FindTask        ; Find us
  217.         move.l        D0,xyProcess(DB)
  218.         movea.l        D0,A2
  219.         tst.l        pr_CLI(A2)
  220.         bne.S        GetLibs
  221. WBenchStartup    lea        pr_MsgPort(A2),A0
  222.         CallLib        WaitPort        ; Wait for a message
  223.         lea        pr_MsgPort(A2),A0
  224.         CallLib        GetMsg                        then get it
  225.         move.l        D0,WBenchMsg(DB)    ; Save it for later reply
  226. GetLibs        lea        GfxName(PC),A1
  227.         CallLib        OldOpenLibrary
  228.         move.l        D0,GfxBase(DB)
  229.         beq        Error
  230.         lea        IntName(PC),A1
  231.         CallLib        OldOpenLibrary
  232.         move.l        D0,IntBase(DB)
  233.         beq        Error
  234.  
  235. SetInterrupt    Prepare        Exec_Call
  236.         lea        xyInterrupt(DB),A1    ; Start vertical-blanking interrupt-Server
  237.         move.b        #NT_INTERRUPT,LN_TYPE(A1); xyInterrupt->is_Node.ln_Type=NT_INTERRUPT
  238.         lea        xyIntName(PC),A0
  239.         move.l        A0,LN_NAME(A1)        ; xyInterrupt->is_Node.ln_Name=xyIntName
  240.         lea        xyIntServer(PC),A0
  241.         move.l        A0,IS_CODE(A1)        ; xyInterrupt->is_Code          =xyIntServer
  242.         move.l        DB,IS_DATA(A1)        ; xyInterrupt->is_Data          =DB
  243.         moveq        #INTB_VERTB,D0
  244.         CallLib        AddIntServer
  245.  
  246. SetPatches    CallLib        Forbid
  247.         lea        LockPatch(PC),A0    : Patch 'LockLayerRom'
  248.         move.l        A0,D0
  249.         move.l        GfxBase(DB),A1
  250.         move.w        #_LVOLockLayerRom,A0
  251.         CallLib        SetFunction
  252.         move.l        D0,JmpOldLock+2
  253.         lea        UnlockPatch(PC),A0    ; Patch 'UnlockLayerRom'
  254.         move.l        A0,D0
  255.         move.l        GfxBase(DB),A1
  256.         move.w        #_LVOUnlockLayerRom,A0
  257.         CallLib        SetFunction
  258.         move.l        D0,JmpOldUnlock+2
  259.         lea        CloseSPatch(PC),A0    ; Patch 'CloseScreen'
  260.         move.l        A0,D0
  261.         move.l        IntBase(DB),A1
  262.         move.w        #_LVOCloseScreen,A0
  263.         CallLib        SetFunction
  264.         move.l        D0,JmpOldCloseS+2
  265.         CallLib        Permit
  266.  
  267. GetFont        Prepare        Gfx_Call
  268.         lea        TxtAttr(PC),A0
  269.         CallLib        OpenFont
  270.         move.l        D0,Font(DB)
  271.         beq.S        Error
  272.  
  273. GetWindow    suba.l        A0,A0
  274.         Call        FindOtherScreen
  275.         move.l        D0,DScreen(DB)
  276.         beq.S        Error
  277.         Call        OpenW
  278.         bne        Main
  279.  
  280. Error
  281. Exit        Prepare        Exec_Call
  282.         lea        xyInterrupt(DB),A1
  283.         tst.l        IS_CODE(A1)        ; If this is set then server has been added
  284.         beq.S        FreeFont
  285. FreePatches    CallLib        Forbid
  286.         move.l        JmpOldCloseS+2(PC),D0
  287.         move.l        IntBase(DB),A1
  288.         move.w        #_LVOCloseScreen,A0
  289.         CallLib        SetFunction
  290.         move.l        JmpOldLock+2(PC),D0
  291.         move.l        GfxBase(DB),A1
  292.         move.w        #_LVOLockLayerRom,A0
  293.         CallLib        SetFunction
  294.         move.l        JmpOldUnlock+2(PC),D0
  295.         move.l        GfxBase(DB),A1
  296.         move.w        #_LVOUnlockLayerRom,A0
  297.         CallLib        SetFunction
  298.         CallLib        Permit
  299. FreeInterrupt    lea        xyInterrupt(DB),A1
  300.         moveq        #INTB_VERTB,D0
  301.         CallLib        RemIntServer
  302. FreeFont    Prepare        Gfx_Call
  303.         move.l        Font(DB),D0
  304.         beq.S        FreeWindow
  305.         move.l        D0,A1
  306.         CallLib        CloseFont
  307. FreeWindow    Call        CloseW
  308. FreeInt        Prepare        Exec_Call
  309.         move.l        IntBase(DB),D0
  310.         beq.S        FreeGfx
  311.         move.l        D0,A1
  312.         CallLib        CloseLibrary
  313. FreeGfx        move.l        GfxBase(DB),D0
  314.         beq.S        ReplyWB
  315.         move.l        D0,A1
  316.         CallLib        CloseLibrary
  317. ReplyWB        move.l        WBenchMsg(DB),D2
  318.         beq.S        AllDone
  319.         CallLib        Forbid
  320.         movea.l        D2,A1
  321.         CallLib        ReplyMsg        ; Reply WBenchMessage if we are started from WB
  322. AllDone        rFree
  323.         moveq        #0,D0
  324.         rts
  325.  
  326. Main
  327. Change        Call        UpdateDisplay
  328. EventLoop    move.l        Up(DB),A0
  329.         moveq        #0,D0
  330.         moveq        #0,D1
  331.         move.b        MP_SIGBIT(A0),D1
  332.         bset        D1,D0
  333.         ori.l        #WaitMask,D0
  334.         Prepare        Exec_Call
  335.         CallLib        Wait
  336.         move.l        D0,D5
  337.         move.b        Relative(DB),D7
  338.         move.l        Up(DB),A0
  339.         moveq        #0,D0
  340.         move.b        MP_SIGBIT(A0),D0
  341.         btst        D0,D5
  342.         beq.S        CheckBits
  343.  
  344. GetNextMsg    move.l        Up(DB),A0
  345.         Prepare        Exec_Call
  346.         CallLib        GetMsg
  347.         tst.l        D0
  348.         beq.S        CheckBits
  349.         move.l        D0,A1
  350.         move.l        im_Class(A1),Class(DB)
  351.         move.w        im_Code(A1),Code(DB)
  352.         move.l        im_Seconds(A1),Seconds(DB)
  353.         move.l        im_Micros(A1),Micros(DB)
  354.         CallLib        ReplyMsg
  355.         move.l        Class(DB),D0
  356.         cmp.l        #CLOSEWINDOW,D0
  357.         beq        Exit
  358.         cmp.l        #MOUSEBUTTONS,D0
  359.         beq        DoButtons
  360.         tst.w        Version(DB)        ; No need to change color
  361.         beq.S        3$            ; under 1.2/1.3
  362.         cmp.l        #ACTIVEWINDOW,D0
  363.         bne.S        1$
  364.         move.w        BColorA(DB),D0
  365.         bra.S        2$
  366. 1$        cmp.l        #INACTIVEWINDOW,D0
  367.         bne.S        3$
  368.         move.w        BColorI(DB),D0
  369. 2$        move.l        Rp(DB),A1
  370.         Prepare        Gfx_Call
  371.         CallLib        SetBPen
  372.  
  373. 3$        Call        UpdateDisplay        ; Do some refreshing
  374.         bra.S        GetNextMsg
  375.  
  376. CheckBits    btst        #Remove_Screen_B,D5
  377.         beq.S        CheckMouse
  378.         move.l        RemScreen(DB),D0
  379.         beq.S        CheckMouse
  380.         Call        CloseW
  381.         Prepare        Intuition_Call
  382.         clr.l        RemScreen(DB)
  383.         move.l        D0,A0
  384.         CallLib        CloseScreen
  385.         sub.l        A0,A0
  386.         Call        FindOtherScreen
  387.         move.l        D0,DScreen(DB)
  388.         beq        Exit
  389.         Call        OpenW
  390.         beq        Exit
  391.  
  392. CheckMouse    btst        #LMB_Change_B,D5
  393.         beq.S        1$
  394.         move.l        my(DB),ry(DB)
  395.         tst.b        D7
  396.         bne.S        2$
  397.         clr.l        ry(DB)            ; Released LMB
  398.         not.l        oy(DB)            ; ox/oy != mx/my
  399.         bra.S        2$
  400. 1$        btst        #xy_Change_B,D5
  401.         beq        EventLoop
  402. 2$        move.w        mx(DB),D0
  403.         sub.w        rx(DB),D0
  404.         cmp.w        ox(DB),D0
  405.         beq.S        3$
  406.         lea        xyTxt+2(PC),A0
  407.         Call        DecStr1
  408. 3$        move.w        my(DB),D0
  409.         sub.w        ry(DB),D0
  410.         cmp.w        oy(DB),D0
  411.         beq.S        4$
  412.         lea        xyTxt+9(PC),A0
  413.         Call        DecStr1
  414. 4$        move.l        my(DB),oy(DB)
  415.         move.l        DScreen(DB),A1
  416.         lea        sc_RastPort(A1),A1
  417.         move.w        mx(DB),D0
  418.         bmi.S        5$
  419.         move.w        my(DB),D1
  420.         bmi.S        5$
  421.         Prepare        Gfx_Call
  422.         CallLib        ReadPixel
  423.         move.w        D0,Color(DB)
  424.         bmi.S        5$
  425.         cmp.w        oColor(DB),D0
  426.         beq.s        6$
  427.         lea        xyTxt+20(PC),A0
  428.         Call        DecStr2
  429.         bra.S        6$
  430. 5$        lea        xyTxt+20(PC),A0
  431.         move.b        #' ',(A0)+
  432.         move.b        #' ',(A0)+
  433.         move.b        #'?',(A0)+
  434. 6$        move.w        Color(DB),oColor(DB)
  435.         bra        Change
  436.  
  437. DoButtons    cmp.w        #MENUDOWN,Code(DB)
  438.         bne        GetNextMsg
  439.         Prepare        Intuition_Call
  440.         movem.l        Seconds(DB),D2-D3
  441.         movem.l        oSeconds(DB),D0-D1
  442.         movem.l        D2-D3,oSeconds(DB)
  443.         CallLib        DoubleClick
  444.         tst.l        D0
  445.         beq        GetNextMsg
  446.         move.l        DScreen(DB),A0
  447.         Call        FindOtherScreen
  448.         beq.S        1$
  449.         move.l        D0,DScreen(DB)
  450.         Call        CloseW
  451.         Call        OpenW
  452.         beq        Exit
  453. 1$        bra        GetNextMsg
  454.  
  455. OpenW        Push        D1/A0-A2/A6
  456.         Prepare        Intuition_Call
  457.         lea        NW(PC),A0
  458.         move.l        DScreen(DB),nw_Screen(A0)
  459.         move.w        Width(DB),nw_Width(A0)
  460.         move.w        Height(DB),nw_Height(A0)
  461.         CallLib        OpenWindow
  462.         move.l        D0,DWindow(DB)
  463.         beq.S        2$
  464.         move.l        D0,A0
  465.         move.l        wd_RPort(A0),Rp(DB)
  466.         move.l        wd_UserPort(A0),Up(DB)
  467.         suba.l        A1,A1
  468.         lea        ScrTitle(PC),A2
  469.         CallLib        SetWindowTitles
  470.         move.l        DScreen(DB),A0
  471.         CallLib        ScreenToFront
  472.         Prepare        Gfx_Call
  473.         move.l        Rp(DB),A2
  474.         move.l        A2,A1
  475.         move.w        AColor(DB),D0
  476.         CallLib        SetAPen
  477.         move.l        A2,A1
  478.         move.w        BColorI(DB),D0
  479.         CallLib        SetBPen
  480.         move.l        A2,A1
  481.         moveq        #RP_JAM2,D0
  482.         CallLib        SetDrMd
  483.         move.l        Font(DB),A0
  484.         move.l        A2,A1
  485.         CallLib        SetFont
  486.         lea        Counter(PC),A0
  487.         clr.w        (A0)
  488.         lea        WLayer(PC),A0
  489.         move.l        rp_Layer(A2),(A0)
  490.         lea        WScreen(PC),A0
  491.         move.l        DScreen(DB),(A0)
  492.         moveq        #1,D0
  493. 2$        Pop        D1/A0-A2/A6
  494.         rts
  495.  
  496. CloseW        Push        D0-D1/A0-A1/A6
  497.         Prepare        Intuition_Call
  498.         move.l        DWindow(DB),D0
  499.         beq.S        1$
  500.         lea        WLayer(PC),A0
  501.         clr.l        (A0)            ; Disable patches
  502.         lea        WScreen(PC),A0
  503.         clr.l        (A0)            ; Disable patch
  504.         move.l        D0,A0
  505.         CallLib        CloseWindow
  506.         clr.l        DWindow(DB)
  507.         not.l        my(DB)
  508. 1$        Pop        D0-D1/A0-A1/A6
  509.         rts
  510.  
  511. * Call  : A0 = current screen or NULL
  512. * Return: D0 = new screen or NULL
  513. * Tries to find a new screen big enough to open the window on
  514. FindOtherScreen Push        D1-D5/A1-A2/A6
  515.         Prepare        Exec_Call
  516.         CallLib        Forbid
  517.         Prepare        Intuition_Call
  518.         move.l        A0,D0
  519.         bne.S        1$
  520.         move.l        ib_FirstScreen(A6),D0
  521.         bra.S        CheckScreen
  522. 1$        move.l        sc_NextScreen(A0),D0
  523. NextScreen    tst.l        D0
  524.         bne.S        CheckScreen
  525.         move.l        ib_FirstScreen(A6),D0
  526. CheckScreen    cmp.l        A0,D0
  527.         beq.S        5$            ; Have we checked all screens ?
  528.         move.l        D0,A1
  529.         move.w        sc_ViewPort+vp_Modes(A1),D1
  530.         andi.w        #V_HIRES,D1
  531.         Prepare        Exec_Call
  532.         lea        Settings1.3H(PC),A2
  533.         cmp.w        #34,LIB_VERSION(A6)
  534.         bge.S        1$
  535.         tst.w        D1
  536.         bne.S        2$
  537.         lea        Settings1.3L(PC),A2
  538.         bra.S        2$
  539. 1$        lea        Settings2.0H(PC),A2
  540.         tst.w        D1
  541.         bne.S        2$
  542.         lea        Settings2.0L(PC),A2
  543. 2$        movem.l        (A2),D1-D4
  544.         movem.l        D1-D4,Version(DB)    ; Initialize variables
  545.         tst.w        Version(DB)
  546.         beq.S        3$
  547.         moveq        #0,D1
  548.         move.b        sc_BarHeight(A1),D1
  549.         move.w        D1,Height(DB)
  550.         subq.w        #7,D1
  551.         lsr.w        #1,D1
  552.         addq.w        #6,D1
  553.         move.w        D1,yPos(DB)
  554. 3$        move.w        sc_Width(A1),D1
  555.         cmp.w        Width(DB),D1
  556.         blt.S        4$
  557.         move.w        sc_Height(A1),D1
  558.         cmp.w        Height(DB),D1
  559.         bge.S        6$
  560. 4$        move.l        D0,A1
  561.         move.l        sc_NextScreen(A1),D0    ; Screen was too small, try another
  562.         bra.S        NextScreen
  563. 5$        moveq        #0,D0
  564. 6$        move.l        D0,D2
  565.         Prepare        Exec_Call
  566.         CallLib        Permit
  567.         move.l        D2,D0
  568.         Pop        D1-D5/A1-A2/A6
  569.         rts
  570.  
  571. UpdateDisplay    Prepare        Gfx_Call
  572.         move.l        Rp(DB),A1
  573.         move.w        xPos(DB),D0
  574.         move.w        yPos(DB),D1
  575.         CallLib        Move
  576.         lea        xyTxt(PC),A0
  577.         move.l        Rp(DB),A1
  578.         moveq        #StringLength,D0
  579.         CallLib        Text
  580.         rts
  581.  
  582. DecStr2        moveq        #' ',D1
  583.         bra.S        NEG
  584. DecStr1        moveq        #' ',D1
  585.         ext.l        D0
  586.         bge.S        POS
  587.         neg.l        D0
  588.         move.b        #'-',(A0)+
  589.         bra.S        NEG
  590. POS        move.b        D1,(A0)+
  591. NEG        move.b        D1,(A0)+
  592.         move.b        D1,(A0)+
  593.         moveq        #'0',D1
  594.         move.b        D1,(A0)+
  595. 1$        tst.l        D0
  596.         beq.S        2$
  597.         divu        #10,D0
  598.         swap        D0
  599.         add.w        D1,D0
  600.         move.b        D0,-(A0)
  601.         clr.w        D0
  602.         swap        D0
  603.         bra.S        1$
  604. 2$        rts
  605.  
  606. * A1=DB
  607. * Inside the server the registers D0-D1/A0-A1/A5-A6 can be used
  608. * without restoring them on exit
  609. xyIntServer    btst        #6,LMBBUT
  610.         seq        D1
  611.         cmp.b        Relative(A1),D1
  612.         beq.S        1$
  613.         move.b        D1,Relative(A1)
  614.         move.l        DScreen(A1),A0
  615.         move.l        sc_MouseY(A0),my(A1)
  616.         move.l        #LMB_Change_F,D0
  617.         bra.S        2$
  618. 1$        move.l        DScreen(A1),A0
  619.         move.l        sc_MouseY(A0),D1
  620.         cmp.l        my(A1),D1
  621.         beq.S        3$
  622.         move.l        D1,my(A1)
  623.         move.l        #xy_Change_F,D0
  624. 2$        move.l        xyProcess(A1),A1
  625.         Prepare        Exec_Call
  626.         CallLib        Signal
  627. 3$        moveq        #0,D0            ; Set the Z flag
  628.         rts
  629.  
  630. * These patch-functions prevents the graphics functions to
  631. * 'LockLayerRom' and 'UnlockLayerRom' on my windows layer
  632. *
  633. * Any calls to 'LockLayerRom' that had not yet been matched
  634. * by a 'UnlockLayerRom' when these pathches got installed, can
  635. * still use 'UnlockLayerRom' normally because of the counter.
  636. LockPatch    cmp.l        WLayer(PC),A5
  637.         bne.S        JmpOldLock
  638.         addq.w        #1,Counter
  639.         rts
  640. JmpOldLock    jmp        12345678        ; Not my windows layer
  641.  
  642. UnlockPatch    cmp.l        WLayer(PC),A5
  643.         bne.S        JmpOldUnlock
  644.         subq.w        #1,Counter
  645.         bmi.S        JmpOldUnlock
  646.         rts
  647. JmpOldUnlock    jmp        12345678        ; Not my windows layer
  648. Counter        dc.w        0
  649. WLayer        dc.l        0            ; My windows layer
  650.  
  651. * This patch-function helps Mouse-xy evacuate any closing screen.
  652. * I don't just close the window here because I don't know what the
  653. * Mouse-xy is process is doing to the window at this moment. I don't
  654. * even close the screen here but instead I signal process to close
  655. * the window and screen under more controlled circumstances.
  656. CloseSPatch    cmp.l        WScreen(PC),A0
  657.         bne.S        JmpOldCloseS
  658.         Push        D0-D7/A0-A6
  659.         move.l        SpareA4(PC),DB
  660.         move.l        A0,RemScreen(DB)
  661.         move.l        #Remove_Screen_F,D0
  662.         move.l        xyProcess(DB),A1
  663.         Prepare        Exec_Call
  664.         CallLib        Signal
  665.         Pop        D0-D7/A0-A6
  666.         rts
  667. JmpOldCloseS    jmp        12345678        ; Not my windows screen
  668. WScreen        dc.l        0
  669. SpareA4        dc.l        0
  670.  
  671. * Stack variables
  672.  rStart
  673.  rAPtr        RemScreen
  674.  rWord        Relative        ; 0 means absolute coordinates
  675.  rAPtr        xyProcess
  676.  rAPtr        GfxBase
  677.  rAPtr        IntBase
  678.  rAPtr        WBenchMsg        ; Message from Workbench
  679.  rAPtr        DWindow            ; APtr to Window
  680.  rAPtr        DScreen            ; APtr to Screen
  681.  rAPtr        Rp            ; APtr to RastPort
  682.  rAPtr        Up            ; APtr to UserPort
  683.  rAPtr        Font            ; Window-font
  684.  rWord        BColorI            ; Background color (Inactive)
  685.  rWord        BColorA            ; Background color (Active)
  686.  rWord        AColor            ; Foreground color
  687.  rWord        yPos            ; y-position of text in window
  688.  rWord        xPos            ; x-position of text in window
  689.  rWord        Height            ; Height of window
  690.  rWord        Width            ; Width of window
  691.  rWord        Version            ; Kickstart version ID
  692.  rWord        mx            ; \The order is important
  693.  rWord        my            ; /
  694.  rWord        ox            ; \The order is important
  695.  rWord        oy            ; /
  696.  rWord        rx            ; \The order is important
  697.  rWord        ry            ; /
  698.  rWord        Color
  699.  rWord        oColor
  700.  rLong        Class            ; im_Class
  701.  rWord        Code            ; im_Code
  702.  rLong        Micros            ; \The order is important
  703.  rLong        Seconds            ; /
  704.  rLong        oMicros            ; \The order is important
  705.  rLong        oSeconds        ; /
  706.  rStorage    xyInterrupt,IS_SIZE    ; Interrupt structure
  707.  rEnd
  708.  
  709. StringLength    =23
  710. StringSpace    =StringLength*8
  711.  
  712. Kick1        =0
  713. * Defines for hires under kickstart 1.2-1.3 (and below ?)
  714. Width1.3H    =84+StringSpace
  715. Height1.3H    =10
  716. xPos1.3H    =30
  717. yPos1.3H    =7
  718. AColor1.3H    =0
  719. BColor1.3H    =1
  720.  
  721. * Defines for lores under  kickstart 1.2-1.3 (and below ?)
  722. Width1.3L    =51+StringSpace
  723. Height1.3L    =10
  724. xPos1.3L    =16
  725. yPos1.3L    =7
  726. AColor1.3L    =0
  727. BColor1.3L    =1
  728.  
  729. Kick2        =1
  730. * Defines for hires under kickstart 2.0 (and up ?)
  731. Width2.0H    =51+StringSpace
  732. Height2.0H    =11
  733. xPos2.0H    =23
  734. yPos2.0H    =8
  735. AColor2.0H    =1
  736. BColor2.0HA    =3        ; Active background color
  737. BColor2.0HI    =0        ; Inactive background color
  738.  
  739. * Defines for lores under kickstart 2.0 (and up ?)
  740. Width2.0L    =40+StringSpace
  741. Height2.0L    =11
  742. xPos2.0L    =18
  743. yPos2.0L    =8
  744. AColor2.0L    =1
  745. BColor2.0LA    =3        ; Active background color
  746. BColor2.0LI    =0        ; Inactive background color
  747.  
  748. Settings1.3H    dc.w        Kick1,Width1.3H,Height1.3H,xPos1.3H,yPos1.3H,AColor1.3H,BColor1.3H,BColor1.3H
  749. Settings1.3L    dc.w        Kick1,Width1.3L,Height1.3L,xPos1.3L,yPos1.3L,AColor1.3L,BColor1.3L,BColor1.3L
  750. Settings2.0H    dc.w        Kick2,Width2.0H,Height2.0H,xPos2.0H,yPos2.0H,AColor2.0H,BColor2.0HA,BColor2.0HI
  751. Settings2.0L    dc.w        Kick2,Width2.0L,Height2.0L,xPos2.0L,yPos2.0L,AColor2.0L,BColor2.0LA,BColor2.0LI
  752.  
  753. GfxName        dc.b        'graphics.library',0
  754. IntName        dc.b        'intuition.library',0
  755. xyIntName    dc.b        'xy Interrupt',0
  756. xyTxt        dc.b        'x:   0 y:   0 Color:  0',0
  757. ScrTitle    dc.b        'Mouse-xy V1.0 1991 by Preben Nielsen',0
  758.         EVEN
  759.  
  760. IDCMP_Flags    =        CLOSEWINDOW|MOUSEBUTTONS|INACTIVEWINDOW|ACTIVEWINDOW
  761. Other_Flags    =        RMBTRAP|WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG
  762. NW        dc.w        0,0,0,0
  763.         dc.b        0,1
  764.         dc.l        IDCMP_Flags,Other_Flags,0,0,0,0,0
  765.         dc.w        0,0,0,0,CUSTOMSCREEN
  766.  
  767. TxtAttr        dc.l        FontName
  768.         dc.w        TOPAZ_EIGHTY
  769.         dc.b        FS_NORMAL,FPB_ROMFONT
  770. FontName    dc.b        'topaz.font',0
  771.         END
  772.  
  773.