home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD2.img / d4xx / d483 / pwkeys / setpwkeys.asm < prev    next >
Assembly Source File  |  1991-05-10  |  40KB  |  1,638 lines

  1. *    SetPWKeys V1.0
  2. *    By Preben Nielsen
  3. *
  4. *
  5. *      SetPWKeys is a program that lets you define key-function
  6. *    bindings for use with the PWKeys program. So if you don't use
  7. *    PWKeys then you won't have any use for SetPWKeys.
  8. *
  9. *    NOTE:    There's no need to 'RUN' or 'RUNBACK' this program from the
  10. *        CLI. It is auto-detaching.
  11. *
  12. *HISTORY
  13. *          Made with Hisoft V2.12
  14. *
  15. *  V1.0   20-Apr-91: The program has now existed for a long time, but I
  16. *                    don't remember exactly when I started on it.
  17.  
  18.     OPT O+
  19.     OPT O1+            ; Tells when a branch could be optimised to short
  20.     OPT i+            ; Tells when '#' is probably missing
  21.  
  22.         include        "PWKeys.i"
  23.         incdir        "AsmInc:"
  24.         include        "exec/exec_lib.i"
  25.         include        "exec/memory.i"
  26.         include        "exec/interrupts.i"
  27.         include        "libraries/dos_lib.i"
  28.         include        "libraries/dosextens.i"
  29.         include        "graphics/graphics_lib.i"
  30.         include        "graphics/gfxbase.i"
  31.         include        "intuition/intuition.i"
  32.         include        "intuition/intuition_lib.i"
  33.  
  34. POPSCREEN            ; If this is defined then the screen will
  35.                 ; pop up from below
  36. ;CUSTOMCOLORS            ; If you remove this then it uses WB-colors
  37.  
  38. PLANES            =1    ; Bitplanes on screen
  39. SWDIFF            =10    ; Difference between screen and window y-coords
  40.  
  41. FUNCTEXTS        =17
  42. GADTEXTS        =7
  43. MSGTEXTS        =7
  44.  
  45. TITLE            =0
  46. NOFILE            =-1
  47. WRONGFILE        =-2
  48. WRITEERR        =-3
  49. NOHANDLER        =-4
  50. DUPLICATES        =-5
  51. ALLISOK            =-6
  52.  
  53. KEYMASK            =$FF
  54.  
  55. SELECTEDBOX        =0
  56. GHOSTEDBOX        =1
  57.  
  58. Prepare        MACRO
  59.         IFC        '\1','Exec_Call'
  60.         movea.l        4.W,A6
  61.         ENDC
  62.         IFC        '\1','Intuition_Call'
  63.         movea.l        IntBase(DB),A6
  64.         ENDC
  65.         IFC        '\1','Gfx_Call'
  66.         movea.l        GraphBase(DB),A6
  67.         ENDC
  68.         IFC        '\1','Dos_Call'
  69.         movea.l        DosBase(DB),A6
  70.         ENDC
  71.         ENDM
  72. CallLib        MACRO
  73.         jsr        _LVO\1(A6)
  74.         ENDM
  75. Call        MACRO
  76.         bsr        \1
  77.         ENDM
  78. Push        MACRO        Push <reg list | all>
  79.         IFC        '\1','all'
  80.         movem.l        D0-D7/A0-A6,-(SP)
  81.         ENDC
  82.         IFNC        '\1','all'
  83.         movem.l        \1,-(SP)
  84.         ENDC
  85.         ENDM
  86. Pop        MACRO        Pop <reg list | all>
  87.         IFC        '\1','all'
  88.         movem.l        (SP)+,D0-D7/A0-A6
  89.         ENDC
  90.         IFNC        '\1','all'
  91.         movem.l        (SP)+,\1
  92.         ENDC
  93.         ENDM
  94. rAPtr        MACRO        Name
  95. DefSiz        set        DefSiz+4
  96. DefPtr        set        DefPtr-4
  97. \1        =        DefPtr
  98.         ENDM
  99. rLong        MACRO        Name
  100. DefSiz        set        DefSiz+4
  101. DefPtr        set        DefPtr-4
  102. \1        =        DefPtr
  103.         ENDM
  104. rWord        MACRO        Name
  105. DefSiz        set        DefSiz+2
  106. DefPtr        set        DefPtr-2
  107. \1        =        DefPtr
  108.         ENDM
  109. rByte        MACRO        Name
  110. DefSiz        set        DefSiz+1
  111. DefPtr        set        DefPtr-1
  112. \1        =        DefPtr
  113.         ENDM
  114. rStorage    MACRO        Name,Size    ;def storage
  115. DefSiz        set        DefSiz+\2
  116. DefPtr        set        DefPtr-\2
  117. \1        =        DefPtr
  118.         ENDM
  119. rEVEN        MACRO                ;word boundary
  120.         IFNE        DefPtr&1
  121. DefPtr        set        DefPtr-1
  122. DefSiz        set        DefSiz+1
  123.         ENDC
  124.         ENDM
  125. rStart        MACRO                ;def var section
  126. DefPtr        set        0
  127. DefSiz        set        0
  128.         ENDM
  129. rEnd        MACRO                ;def var section
  130. RelSize        =        DefSiz
  131.         ENDM
  132. rAlloc        MACRO
  133.         link        DB,#-RelSize
  134.         ENDM
  135. rFree        MACRO                ;De-allocate storage
  136.         unlk        DB
  137.         ENDM
  138. rClear        MACRO                ;reset all variables
  139.         movem.l        D0/A0,-(SP)
  140.         move.w        #RelSize-1,D0
  141.         move.l        DB,A0
  142. rClr.\@        clr.b        -(A0)
  143.         dbf        D0,rClr.\@
  144.         movem.l        (SP)+,D0/A0
  145.         ENDM
  146. Gadget        MACRO
  147.         dc.l        \1
  148.         dc.w        \2,\3,\4,\5,\6,\7,\8
  149.         ENDM
  150. Gadget2        MACRO
  151.         dc.l        \1,\2,\3,\4,\5
  152.         dc.w        \6
  153.         dc.l        \7
  154.         ENDM
  155. Border        MACRO
  156.         dc.w        \1,\2
  157.         dc.b        \3,\4,\5,\6
  158.         dc.l        \7,\8
  159.         ENDM
  160. Image        MACRO
  161.         dc.w        \1,\2,\3,\4,\5
  162.         dc.l        \6
  163.         dc.b        \7,\8
  164.         dc.l        \9
  165.         ENDM
  166. IntuiText    MACRO
  167.         dc.b        \1,\2,\3,0
  168.         dc.w        \4,\5
  169.         dc.l        TxtAttr,\6,\7
  170.         ENDM
  171. Detach        MACRO        ; Detach <'process name'>,stacksize,processpri
  172.         SECTION        MultiSplit,CODE
  173. Start        Prepare        Exec_Call
  174.         suba.l        A1,A1
  175.         CallLib        FindTask        ; Find us
  176.         move.l        D0,A0
  177.         tst.l        pr_CLI(A0)
  178.         bne.S        SegSplit
  179.         jmp        ProcessStart        ; from WorkBench
  180. SegSplit    link        A4,#-100
  181.         CallLib        Forbid            ; From Dos
  182.         lea        DName(PC),A1
  183.         CallLib        OldOpenLibrary
  184.         move.l        D0,D5
  185.         beq        6$
  186.         move.l        Start-4(PC),A1
  187.         move.l        A1,D3
  188.         moveq        #0,D6            ; Number of segments
  189.         moveq        #ML_SIZE,D7        ; Size of memory to allocate
  190.         move.l        SP,A0
  191. 1$        move.l        A1,D0            ; Count segments and make MemEntries on the stack
  192.         beq.S        2$
  193.         adda.l        A1,A1
  194.         adda.l        A1,A1
  195.         subq.l        #4,A1
  196.         move.l        A1,(A0)+        ; MemList -> ml_me[0].me_Addr    = Segment
  197.         move.l        (A1),(A0)+        ; MemList -> ml_me[0].me_Length    = Length
  198.         move.l        4(A1),A1
  199.         addq.w        #1,D6
  200.         addq.w        #ME_SIZE,D7
  201.         bra.S        1$
  202. 2$        move.l        D7,D0
  203.         move.l        #MEMF_PUBLIC|MEMF_CLEAR,D1
  204.         CallLib        AllocMem        ; Allocate Memlist
  205.         move.l        D0,A2
  206.         tst.l        D0
  207.         beq.S        5$
  208.         move.w        D6,ML_NUMENTRIES(A2)    ; MemList -> ml_NumEntries = number of segments
  209.         move.l        SP,A0
  210.         lea        ML_ME(A2),A1
  211.         move.l        D7,D0
  212.         sub.w        #ML_SIZE+1,D0
  213. 3$        move.b        (A0)+,(A1)+
  214.         dbf        D0,3$
  215.         move.l        #ProcessName,D1
  216.         moveq        #\3,D2            ; Priority
  217.         move.l        #\2,D4            ; Stacksize
  218.         move.l        D5,A6
  219.         CallLib        CreateProc
  220.         Prepare        Exec_Call
  221.         move.l        D0,A0
  222.         tst.l        D0
  223.         beq.S        4$
  224.         lea        -pr_MsgPort(A0),A0    ; Now we have process
  225.         not.l        pr_CLI(A0)        ; All MY programs will now think they were started from the CLI
  226.         lea        TC_MEMENTRY(A0),A0
  227.         move.l        A2,A1
  228.         CallLib        AddTail            ; AddTail(&Process->pr_Task.tc_MemEntry,&MemList->ml_Node);
  229.         lea        Start-4(PC),A1
  230.         clr.l        (A1)            ; Split the segments
  231.         bra.S        5$
  232. 4$        move.l        A2,A1            ; CreateProc failed. Can't do anything then
  233.         move.l        D7,D0
  234.         CallLib        FreeMem
  235. 5$        move.l        D5,A1
  236.         CallLib        CloseLibrary
  237. 6$        CallLib        Permit
  238.         unlk        A4
  239.         moveq        #0,D0
  240.         rts
  241. DName        dc.b        'dos.library',0
  242. ProcessName    dc.b        \1,0            ; CreateProc makes a copy of this name
  243.         SECTION        ProcessCode,CODE
  244. ProcessStart
  245.         ENDM
  246.  
  247. DB        EQUR        A4
  248.  
  249. InitProcess    Detach        <'SetPWKeys Process'>,4000,0
  250.         rAlloc                    ; Allocate memory for variables
  251.         rClear                    ; Clear the memory
  252.         Prepare        Exec_Call
  253.         suba.l        A1,A1
  254.         CallLib        FindTask        ; Find us
  255.         move.l        D0,PProcess(DB)
  256.         movea.l        D0,A2
  257.         tst.l        pr_CLI(A2)
  258.         bne.S        GetLibs
  259. WBenchStartup    lea        pr_MsgPort(A2),A0
  260.         CallLib        WaitPort        ; wait for a message
  261.         lea        pr_MsgPort(A2),A0
  262.         CallLib        GetMsg            ; then get it
  263.         move.l        D0,WBenchMsg(DB)    ; save it for later reply
  264. GetLibs        lea        DosName(PC),A1
  265.         CallLib        OldOpenLibrary
  266.         move.l        D0,DosBase(DB)
  267.         beq.S        Error
  268.         lea        GfxName(PC),A1
  269.         CallLib        OldOpenLibrary
  270.         move.l        D0,GraphBase(DB)
  271.         beq.S        Error
  272.         lea        IntName(PC),A1
  273.         CallLib        OldOpenLibrary
  274.         move.l        D0,IntBase(DB)
  275.         beq.S        Error
  276.         Prepare        Intuition_Call
  277.         lea        NewS(PC),A0
  278.     IFD POPSCREEN
  279.         move.l        GraphBase(DB),A1
  280.         move.w        gb_NormalDisplayRows(A1),ns_TopEdge(A0)
  281.         ori.w        #SCREENBEHIND,ns_Type(A0)
  282.     ENDC
  283.         CallLib        OpenScreen
  284.         move.l        D0,DScreen(DB)
  285.         beq.S        Error
  286.         moveq        #sc_ViewPort,D1
  287.         add.l        D0,D1
  288.         move.l        D1,ScrVp(DB)
  289.         moveq        #sc_RastPort,D1
  290.         add.l        D0,D1
  291.         move.l        D1,Rp(DB)
  292.  
  293.     IFD CUSTOMCOLORS
  294.         Prepare        Gfx_Call
  295.         move.l        ScrVp(DB),A0
  296.         lea        ColorTable(PC),A1
  297.         moveq        #2,D0
  298.         CallLib        LoadRGB4
  299.     ENDC
  300.         Prepare        Intuition_Call
  301.         lea        NewW(PC),A0
  302.         move.l        DScreen(DB),nw_Screen(A0)
  303.         CallLib        OpenWindow
  304.         move.l        D0,DWindow(DB)
  305.         movea.l        D0,A0
  306.         beq.S        Error
  307.         move.l        wd_UserPort(A0),Up(DB)
  308.         Call        SetAPen1
  309.         bra.S        Main
  310.  
  311. Exit
  312. Error
  313. FreeWindow    Prepare        Intuition_Call
  314.         move.l        DWindow(DB),D0
  315.         beq.S        FreeScreen
  316.     IFD POPSCREEN
  317.         Call        PushScreen
  318.     ENDC
  319.         move.l        DWindow(DB),A0
  320.         CallLib        CloseWindow
  321. FreeScreen    move.l        DScreen(DB),D0
  322.         beq.S        FreeIntuition
  323.         movea.l        D0,A0
  324.         CallLib        CloseScreen
  325. FreeIntuition    Prepare        Exec_Call
  326.         move.l        IntBase(DB),D0
  327.         beq.S        FreeGraphics
  328.         movea.l        D0,A1
  329.         CallLib        CloseLibrary
  330. FreeGraphics    move.l        GraphBase(DB),D0
  331.         beq.S        FreeDos
  332.         movea.l        D0,A1
  333.         CallLib        CloseLibrary
  334. FreeDos        move.l        DosBase(DB),D0
  335.         beq.S        ReplyWB
  336.         movea.l        D0,A1
  337.         CallLib        CloseLibrary
  338. ReplyWB        move.l        WBenchMsg(DB),D2
  339.         beq.S        AllDone
  340.         CallLib        Forbid
  341.         movea.l        D2,A1
  342.         CallLib        ReplyMsg        ; Reply WBenchMessage if we are started from WB
  343. AllDone        rFree
  344.         moveq        #0,D0
  345.         rts
  346.  
  347. Main        Prepare        Intuition_Call
  348.         move.w        #590,D0
  349.         moveq        #0,D1
  350.         move.l        Rp(DB),A0
  351.         lea        ArrowImages(PC),A1
  352.         CallLib        DrawImage
  353.         moveq        #0,D0
  354.         moveq        #0,D1
  355.         move.l        Rp(DB),A0
  356.         lea        TitleBorder(PC),A1
  357.         CallLib        DrawBorder
  358.         moveq        #0,D0
  359.         moveq        #18,D1
  360.         move.l        Rp(DB),A0
  361.         lea        FuncBorder(PC),A1
  362.         CallLib        DrawBorder
  363.         moveq        #0,D0
  364.         moveq        #KY-6,D1
  365.         move.l        Rp(DB),A0
  366.         lea        KeybBorder(PC),A1
  367.         CallLib        DrawBorder
  368.         moveq        #TITLE,D0
  369.         Call        WriteMsg
  370.         Call        WriteFuncs
  371.         Call        DrawKeys
  372.         Call        SetAPen0
  373.         lea        ReturnKey2(PC),A2
  374.         move.w        Box_x(A2),D2
  375.         add.w        Box_Width(A2),D2
  376.         move.w        Box_y(A2),D3
  377.         move.w        D2,D0
  378.         move.w        D3,D1
  379.         move.l        Rp(DB),A1
  380.         CallLib        Move
  381.         move.w        D2,D0
  382.         move.w        D3,D1
  383.         subq.w        #1,D1
  384.         add.w        Box_Height(A2),D1
  385.         move.l        Rp(DB),A1
  386.         CallLib        Draw
  387.         subq.w        #1,D2
  388.         move.w        D2,D0
  389.         move.w        D3,D1
  390.         addq.w        #1,D1
  391.         move.l        Rp(DB),A1
  392.         CallLib        Move
  393.         move.w        D2,D0
  394.         move.w        D3,D1
  395.         add.w        Box_Height(A2),D1
  396.         subq.w        #1,D1
  397.         move.l        Rp(DB),A1
  398.         CallLib        Draw
  399.         Call        SetAPen1
  400.         Prepare        Exec_Call
  401.         CallLib        Forbid
  402.         lea        PWKeysPortName(PC),A1
  403.         CallLib        FindPort
  404.         tst.l        D0
  405.         beq.S        1$
  406.         move.l        D0,A0            ; Handler was installed
  407.         move.l        ihs_Interrupt+IS_DATA(A0),A0
  408.         lea        TempFile(PC),A1
  409.         move.w        #FilePart,D0        ; Copy keydefinition from the
  410.         Call        MemCopy            ; handlers memory
  411.         Call        UnSortKeys
  412.         Call        InitFuncs
  413. 1$        CallLib        Permit
  414.         lea        Funcs(PC),A0
  415.         bset        #SELECTEDBOX,Box_Flags(A0)
  416.         move.l        A0,CurFunc(DB)
  417.         Call        FillKeyboard
  418.         Call        FillFunctions
  419.     IFD POPSCREEN
  420.         Call        PopScreen        ; Bring screen up
  421.     ENDC
  422. EventLoop    tst.w        Quit(DB)
  423.         bne        Exit
  424.         movea.l        Up(DB),A0
  425.         Prepare        Exec_Call
  426.         CallLib        WaitPort
  427. GetNextMsg    Call        GetAMessage
  428.         beq.S        EventLoop
  429.         move.l        Class(DB),D0
  430.         cmpi.w        #GADGETUP,D0
  431.         beq.S        DoGadget
  432.         cmpi.w        #GADGETDOWN,D0
  433.         beq.S        DoGadget
  434.         cmpi.w        #MOUSEBUTTONS,D0
  435.         beq        DoMouse
  436.         bra.S        GetNextMsg
  437.  
  438.     IFD POPSCREEN
  439. MOVESTEP    =10
  440. PopScreen    Call        DoFront
  441.         moveq        #-MOVESTEP,D2
  442.         move.l        DScreen(DB),A0
  443.         move.w        sc_TopEdge(A0),D1
  444.         Call        PScreen
  445.         rts
  446.  
  447. PushScreen    moveq        #MOVESTEP,D2
  448.         move.l        GraphBase(DB),A0
  449.         move.w        gb_NormalDisplayRows(A0),D1
  450.         move.l        DScreen(DB),A0
  451.         sub.w        sc_TopEdge(A0),D1
  452.         Call        PScreen
  453.         Call        DoBack
  454.         rts
  455.  
  456. * Call: D1 = y-coordinates to move screen
  457. *       D2 = delta-y
  458. PScreen        ext.l        D1
  459.         move.w        D1,D3
  460.         divu        #MOVESTEP,D1
  461.         swap        D1
  462.         sub.w        D1,D3
  463.         tst.w        D2
  464.         bpl.S        1$
  465.         neg.w        D1
  466. 1$        tst.w        D1
  467.         beq.S        4$
  468.         bra.S        3$
  469. 2$        move.w        D2,D1
  470. 3$        moveq        #0,D0
  471.         move.l        DScreen(DB),A0
  472.         Prepare        Intuition_Call
  473.         CallLib        MoveScreen
  474. 4$        sub.w        #MOVESTEP,D3
  475.         bge.S        2$
  476.         rts
  477.     ENDC
  478.  
  479. * A gadget was selected
  480. DoGadget
  481. GJ        movea.l        IAddress(DB),A1
  482.         move.w        gg_GadgetID(A1),D0    ; GadgetID is offset from GJ
  483.         jsr        GJ(PC,D0.W)
  484.         bra        GetNextMsg
  485.  
  486. DoQuit        not.w        Quit(DB)
  487. DoGadgets    rts
  488.  
  489. * User clicked the 'Check' gadget
  490. DoCheck        move.l        CurFunc(DB),A0
  491.         Call        KeysToFunc
  492.         Call        SortKeys
  493.         moveq        #ALLISOK,D7
  494.         Call        FindDuplicates
  495.         bmi.S        1$
  496.         moveq        #DUPLICATES,D7
  497. 1$        move.l        D7,D0
  498.         Call        WriteMsg
  499.         rts
  500.  
  501. * User clicked the 'Use' gadget
  502. DoUse        move.l        CurFunc(DB),A0
  503.         Call        KeysToFunc
  504.         Call        SortKeys
  505.         moveq        #DUPLICATES,D7
  506.         Call        FindDuplicates
  507.         bge.S        2$
  508.         Call        MakeMasks
  509.         Call        CountKeys
  510.         lea        TempDefined(PC),A0
  511.         move.w        D0,(A0)
  512.         Prepare        Exec_Call
  513.         CallLib        Forbid
  514.         lea        PWKeysPortName(PC),A1
  515.         moveq        #NOHANDLER,D7
  516.         CallLib        FindPort
  517.         tst.l        D0
  518.         beq.S        1$
  519.         move.l        D0,A1
  520.         move.l        ihs_Interrupt+IS_DATA(A1),A1
  521.         lea        TempFile(PC),A0
  522.         move.w        #FilePart,D0        ; Copy keydefinition into the
  523.         Call        MemCopy            ; PWKeys-handler memory
  524. 1$        CallLib        Permit
  525.         moveq        #TITLE,D7
  526. 2$        move.l        D7,D0
  527.         Call        WriteMsg
  528.         rts
  529.  
  530. * User clicked the 'Undo' gadget
  531. DoUndo        Call        ClearKeyboard
  532.         move.l        CurFunc(DB),A0
  533.         Call        FillKeyboard
  534.         rts
  535.  
  536. * User clicked the 'Clear' gadget
  537. DoClear        Call        ClearKeyboard
  538.         rts
  539.  
  540. * User clicked the 'ScreentoBack' gadget
  541. DoBack        Prepare        Intuition_Call
  542.         move.l        DScreen(DB),A0
  543.         CallLib        ScreenToBack
  544.         rts
  545.  
  546. * User clicked the 'ScreentoFront' gadget
  547. DoFront        Prepare        Intuition_Call
  548.         move.l        DScreen(DB),A0
  549.         CallLib        ScreenToFront
  550.         rts
  551.  
  552. * User clicked the 'Save' gadget
  553. DoSave        move.l        CurFunc(DB),A0
  554.         Call        KeysToFunc
  555.         Call        SortKeys
  556.         moveq        #DUPLICATES,D7
  557.         Call        FindDuplicates
  558.         bge.S        2$
  559.         Call        MakeMasks
  560.         Prepare        Dos_Call
  561.         lea        FBuffer(PC),A0
  562.         move.l        A0,D1
  563.         move.l        #MODE_NEWFILE,D2
  564.         moveq        #NOFILE,D7
  565.         CallLib        Open
  566.         move.l        D0,FHandle(DB)
  567.         beq.S        1$
  568.         move.l        D0,D1
  569.         lea        TempFile(PC),A0
  570.         move.l        A0,D2
  571.         move.w        #FilePart,D3
  572.         moveq        #WRITEERR,D7
  573.         CallLib        Write
  574.         cmp.l        D0,D3
  575.         bne.S        1$
  576.         moveq        #TITLE,D7
  577. 1$        move.l        FHandle(DB),D1
  578.         beq.S        2$
  579.         CallLib        Close
  580. 2$        move.l        D7,D0
  581.         Call        WriteMsg
  582.         rts
  583.  
  584. * User clicked the 'Load' gadget
  585. DoLoad        Prepare        Dos_Call
  586.         lea        FBuffer(PC),A0
  587.         move.l        A0,D1
  588.         move.l        #MODE_OLDFILE,D2
  589.         moveq        #NOFILE,D7
  590.         CallLib        Open
  591.         move.l        D0,FHandle(DB)
  592.         beq.S        1$
  593.         move.l        D0,D1
  594.         lea        TempFile(PC),A0
  595.         move.l        A0,D2
  596.         move.w        #FilePart,D3
  597.         moveq        #WRONGFILE,D7
  598.         CallLib        Read
  599.         cmp.l        D0,D3
  600.         bne.S        1$
  601.         movem.l        TempFile(PC),D0-D1
  602.         movem.l        PWKVersionID(PC),D2-D3
  603.         cmp.l        D0,D2
  604.         bne.S        1$
  605.         cmp.l        D1,D3
  606.         bne.S        1$
  607.         Call        ClearFunctions
  608.         Call        ClearKeyboard
  609.         Call        UnSortKeys
  610.         Call        InitFuncs
  611.         lea        Funcs(PC),A0
  612.         bset        #SELECTEDBOX,Box_Flags(A0)
  613.         move.l        A0,CurFunc(DB)
  614.         Call        FillKeyboard
  615.         Call        FillFunctions
  616.         moveq        #TITLE,D7
  617. 1$        move.l        FHandle(DB),D1
  618.         beq.S        2$
  619.         CallLib        Close
  620. 2$        move.l        D7,D0
  621.         Call        WriteMsg
  622.         rts
  623.  
  624. * The user pressed/released a mousebutton
  625. DoMouse        cmpi.w        #SELECTDOWN,Code(DB)
  626.         beq.S        DoLB
  627.         cmpi.w        #MENUDOWN,Code(DB)
  628.         bne        DoM
  629. * Perhaps the user clicked on a qualifier-key with RMB
  630. DoRB        cmp.w        #KY-SWDIFF,MouseY(DB)
  631.         blt        DoSelFunc
  632.         Call        WhichKey
  633.         bmi        DoM
  634.         tst.w        KeyBox_Qual(A0)        ; Is it a qual-key ?
  635.         beq        DoM
  636.         btst        #SELECTEDBOX,Box_Flags(A0)
  637.         beq.S        1$
  638.         btst        #GHOSTEDBOX,Box_Flags(A0)
  639.         bne.S        1$
  640.         Call        RawInvert        ; Key was raw
  641.         move.l        #-1,CurCode(DB)
  642. 1$        Call        QualInvert
  643.         bra        DoM
  644. * Perhaps the user clicked on a key with LMB
  645. DoLB        cmp.w        #KY-SWDIFF,MouseY(DB)
  646.         blt.S        DoSelFunc
  647.         Call        WhichKey
  648.         bmi        DoM
  649.         move.l        CurCode(DB),D0
  650.         move.l        A0,CurCode(DB)
  651.         tst.l        D0
  652.         bmi.S        5$
  653.         lea        ReturnKey1(PC),A1    ; Treat the two
  654.         lea        ReturnKey2(PC),A2    ; parts of the
  655.         cmp.l        A1,A0            ; RETURN-key as
  656.         beq.S        1$            ; if they were
  657.         cmp.l        A2,A0            ; one
  658.         bne.S        3$
  659. 1$        cmp.l        A1,D0
  660.         beq.S        2$
  661.         cmp.l        A2,D0
  662.         bne.S        3$
  663. 2$        move.l        A0,D0
  664.  
  665. 3$        cmp.l        A0,D0
  666.         beq.S        4$
  667.         move.l        D0,A0            ; Changed key
  668.         Call        RawInvert
  669.         move.l        CurCode(DB),A0
  670.         bra.S        5$
  671. 4$        move.l        #-1,CurCode(DB)        ; Unselected a key
  672. 5$        btst        #SELECTEDBOX,Box_Flags(A0)
  673.         beq.S        6$
  674.         btst        #GHOSTEDBOX,Box_Flags(A0)
  675.         beq.S        6$
  676.         Call        QualInvert        ; Key was qual
  677. 6$        Call        RawInvert
  678.         bra.S        DoM
  679. * Perhaps the user clicked on a function
  680. DoSelFunc    Call        WhichFunc
  681.         bmi.S        DoM
  682.         move.l        CurFunc(DB),A1
  683.         cmp.l        A0,A1            ; If the function is already selected
  684.         beq.S        1$            ; then this is click is a 'UNDO' click
  685.         move.l        A0,CurFunc(DB)
  686.         move.l        A1,A0
  687.         Call        KeysToFunc        ; Save the selected keys
  688.         btst        #GHOSTEDBOX,Box_Flags(A0)
  689.         beq.S        3$
  690.         Call        RawInvert
  691.         Call        QualInvert
  692.         bset        #GHOSTEDBOX,Box_Flags(A0)
  693.         bra.S        4$
  694. 3$        Call        RawInvert        ; Unselect function
  695. 4$        move.l        CurFunc(DB),A0
  696.         btst        #GHOSTEDBOX,Box_Flags(A0)
  697.         beq.S        2$
  698.         Call        QualInvert
  699. 2$        Call        RawInvert        ; Select function
  700. 1$        Call        ClearKeyboard
  701.         move.l        CurFunc(DB),A0
  702.         Call        FillKeyboard
  703. DoM        bra        GetNextMsg
  704.  
  705. * THE INVERT FUNCTONS ONLY PRESERVES A0
  706. * Complements a key with a pattern
  707. * Call: A0 = box
  708. QualInvert    Push        A0
  709.         bchg        #GHOSTEDBOX,Box_Flags(A0)
  710.         movea.l        Rp(DB),A1
  711.         move.l        #Mask,rp_AreaPtrn(A1)
  712.         move.b        #2,rp_AreaPtSz(A1)
  713.         bra.S        RI2
  714. * Complements a key
  715. * Call: A0 = box
  716. RawInvert    cmp.l        #ReturnKey1,A0
  717.         beq.S        1$
  718.         cmp.l        #ReturnKey2,A0
  719.         bne.S        RI
  720. 1$        Push        A0
  721.         lea        ReturnKey1(PC),A0
  722.         Call        RI
  723.         lea        ReturnKey2(PC),A0
  724.         Call        RI
  725.         Pop        A0
  726.         rts
  727. RI        Push        A0
  728. RI2        bchg        #SELECTEDBOX,Box_Flags(A0)
  729.         move.l        A0,A2
  730.         Prepare        Gfx_Call
  731.         Call        SetDrMd2
  732.         move.w        Box_x(A2),D0
  733.         move.w        Box_y(A2),D1
  734.         move.w        D0,D2
  735.         move.w        D1,D3
  736.         addq.w        #1,D0
  737.         addq.w        #1,D1
  738.         add.w        Box_Width(A2),D2
  739.         add.w        Box_Height(A2),D3
  740.         subq.w        #1,D2
  741.         subq.w        #1,D3
  742.         movea.l        Rp(DB),A1
  743.         CallLib        RectFill
  744.         Call        SetDrMd1
  745.         movea.l        Rp(DB),A1
  746.         clr.l        rp_AreaPtrn(A1)
  747.         clr.b        rp_AreaPtSz(A1)
  748.         Pop        A0
  749.         rts
  750.  
  751. * Finds the selected function box (if any)
  752. * Return: If D0=-1 then couldn't find anything, else A0=FuncBox
  753. WhichFunc    lea        Funcs(PC),A0
  754.         bra.S        WFK
  755. * Finds the selected key (if any)
  756. * Return: If D0=-1 then couldn't find anything, else A0=KeyBox
  757. WhichKey    lea        Keys(PC),A0
  758. WFK        move.w        MouseX(DB),D6
  759.         move.w        MouseY(DB),D7
  760.         add.w        #SWDIFF,D7
  761. 1$        move.w        Box_y(A0),D1
  762.         bmi.S        3$
  763.         cmp.w        D1,D7
  764.         blt.S        2$
  765.         add.w        Box_Height(A0),D1
  766.         cmp.w        D1,D7
  767.         bgt.S        2$
  768.         move.w        Box_x(A0),D0
  769.         cmp.w        D0,D6
  770.         blt.S        2$
  771.         add.w        Box_Width(A0),D0
  772.         cmp.w        D0,D6
  773.         bgt.S        2$
  774.         moveq        #0,D0
  775.         bra.S        4$
  776. 2$        add.l        #FKeyBox_SIZE,A0
  777.         bra.S        1$
  778. 3$        moveq        #-1,D0
  779. 4$        rts
  780.  
  781. * Draw all the keys
  782. DrawKeys    lea        Keys(PC),A2
  783. DL        Prepare        Gfx_Call
  784. 1$        move.w        Box_x(A2),D0
  785.         bmi        3$
  786.         move.w        Box_y(A2),D1
  787.         move.l        Rp(DB),A1
  788.         CallLib        Move
  789.         move.w        Box_x(A2),D0
  790.         move.w        Box_y(A2),D1
  791.         add.w        Box_Width(A2),D0
  792.         move.l        Rp(DB),A1
  793.         CallLib        Draw
  794.         move.w        Box_x(A2),D0
  795.         move.w        Box_y(A2),D1
  796.         add.w        Box_Width(A2),D0
  797.         add.w        Box_Height(A2),D1
  798.         move.l        Rp(DB),A1
  799.         CallLib        Draw
  800.         move.w        Box_x(A2),D0
  801.         move.w        Box_y(A2),D1
  802.         add.w        Box_Height(A2),D1
  803.         move.l        Rp(DB),A1
  804.         CallLib        Draw
  805.         move.w        Box_x(A2),D0
  806.         move.w        Box_y(A2),D1
  807.         move.l        Rp(DB),A1
  808.         CallLib        Draw
  809.         lea        StrBuf(PC),A0
  810.         move.b        KeyBox_Char(A2),(A0)
  811.         beq.S        2$
  812.         move.w        Box_x(A2),D0
  813.         addq.w        #7,D0
  814.         move.w        Box_y(A2),D1
  815.         addq.w        #8,D1
  816.         move.l        Rp(DB),A1
  817.         CallLib        Move
  818.         lea        StrBuf(PC),A0
  819.         moveq        #1,D0
  820.         move.l        Rp(DB),A1
  821.         CallLib        Text
  822. 2$        add.l        #FKeyBox_SIZE,A2
  823.         bra        1$
  824. 3$        rts
  825.  
  826. * Call: A0 = FuncBox
  827. FillFunctions    Call        KeysToFunc
  828.         Push        A2
  829.         lea        Funcs(PC),A2
  830.         bclr        #GHOSTEDBOX,Box_Flags(A2)    ;Just loaded new file, first item needs to be selected
  831.         Pop        A2
  832. * hilites/unhilites all functions with the 'SELECTEDBOX/GHOSTEDBOX' flag set
  833. RefreshFunc    Push        D0-D3/A0-A2/A6
  834.         lea        Funcs(PC),A2
  835.         bra.S        RFK
  836. * Call: A0 = FuncBox
  837. FillKeyboard    Call        FuncToKeys
  838. * hilites/unhilites all keys with the 'SELECTEDBOX'/'GHOSTEDBOX' flag set
  839. RefreshKeys    Push        D0-D3/A0-A2/A6
  840.         lea        Keys(PC),A2
  841. RFK
  842. 1$        move.w        Box_x(A2),D0
  843.         bmi.S        5$
  844.         btst        #SELECTEDBOX,Box_Flags(A2)
  845.         beq.S        4$
  846.         move.l        A2,A0
  847.         btst        #GHOSTEDBOX,Box_Flags(A2)
  848.         beq.S        2$
  849.         Call        QualInvert
  850.         bset        #GHOSTEDBOX,Box_Flags(A2)
  851.         bra.S        3$
  852. 2$        Call        RawInvert
  853. 3$        bset        #SELECTEDBOX,Box_Flags(A2)
  854. 4$        add.l        #FKeyBox_SIZE,A2
  855.         bra.S        1$
  856. 5$        Pop        D0-D3/A0-A2/A6
  857.         rts
  858.  
  859. * Clears all hilite-flags in the 'Funcs' array
  860. ClearFunctions    move.l        CurFunc(DB),A0        ; This is because the selected
  861.         bclr        #GHOSTEDBOX,Box_Flags(A0); can be both selected and ghosted
  862.         Call        RefreshFunc
  863.         Push        A2
  864.         lea        Funcs(PC),A2
  865.         bra.S        CFK
  866. * Clears all hilite-flags in the 'Keys' array
  867. ClearKeyboard    Call        RefreshKeys
  868.         move.l        #-1,CurCode(DB)
  869.         Push        A2
  870.         lea        Keys(PC),A2
  871. CFK    * Clears all hilite-flags in the 'Keys/Funcs' array
  872. 1$        tst.w        Box_x(A2)
  873.         bmi.S        2$
  874.         bclr        #SELECTEDBOX,Box_Flags(A2)
  875.         bclr        #GHOSTEDBOX,Box_Flags(A2)
  876.         add.l        #FKeyBox_SIZE,A2
  877.         bra.S        1$
  878. 2$        Pop        A2
  879.         rts
  880.  
  881. * Call: A0 = FuncBox
  882. * Collects all hilite-flags in the 'Keys' array
  883. KeysToFunc    Push        D0-D2/A0-A2
  884.         move.l        FuncBox_HotKey(A0),A1
  885.         move.w        #U_CODE,D1
  886.         moveq        #U_QUAL,D2
  887.         lea        Keys(PC),A2
  888. 1$        move.w        Box_x(A2),D0
  889.         bmi.S        4$
  890.         btst        #SELECTEDBOX,Box_Flags(A2)
  891.         beq.S        3$
  892.         btst        #GHOSTEDBOX,Box_Flags(A2)
  893.         bne.S        2$
  894.         move.w        KeyBox_Code(A2),D1
  895.         bra.S        3$
  896. 2$        or.w        KeyBox_Qual(A2),D2
  897. 3$        add.l        #FKeyBox_SIZE,A2
  898.         bra.S        1$
  899. 4$        cmp.w        #U_CODE,D1
  900.         bne.S        6$
  901.         bset        #GHOSTEDBOX,Box_Flags(A0)    ; If no code then function has to be ghosted
  902.         moveq        #U_QUAL,D2            ; If no code then no qualifier
  903. 6$        move.w        D1,HotKey_Code(A1)
  904.         move.w        D2,HotKey_Qual(A1)
  905. 5$        Pop        D0-D2/A0-A2
  906.         rts
  907.  
  908. * Call: A0 = FuncBox
  909. * Set all hilite-flags in the 'Keys' array
  910. FuncToKeys    Push        D0/A0/A2
  911.         move.l        FuncBox_HotKey(A0),A0
  912.         lea        Keys(PC),A2
  913. 1$        move.w        Box_x(A2),D0
  914.         bmi.S        4$
  915.         move.w        KeyBox_Code(A2),D0
  916.         cmp.w        HotKey_Code(A0),D0
  917.         bne.S        2$
  918.         move.l        A2,CurCode(DB)
  919.         bset        #SELECTEDBOX,Box_Flags(A2)
  920.         bra.S        3$
  921. 2$        move.w        KeyBox_Qual(A2),D0
  922.         and.w        HotKey_Qual(A0),D0
  923.         beq.S        3$
  924.         bset        #SELECTEDBOX,Box_Flags(A2)
  925.         bset        #GHOSTEDBOX,Box_Flags(A2)
  926. 3$        add.l        #FKeyBox_SIZE,A2
  927.         bra.S        1$
  928. 4$        Pop        D0/A0/A2
  929.         rts
  930.  
  931. * Makes some masks
  932. MakeMasks    Push        D0-D4/A0-A2
  933.         lea        TempPWKeys(PC),A2
  934.         moveq        #0,D0
  935.         moveq        #-2,D2            ; Code
  936. ml        cmp.w        #KeyFuncNumber,D0
  937.         bge.S        5$
  938.         moveq        #0,D1            ; Number
  939.         moveq        #0,D3            ; Qual
  940. 1$        move.l        D0,D4            ; 'OR' qualifiers for all hotkeys with this code
  941.         add.w        D1,D4
  942.         cmp.w        #KeyFuncNumber,D4
  943.         bge.S        2$
  944.         mulu        #HotKey_SIZE,D4
  945.         lea        0(A2,D4),A0
  946.         cmp.w        HotKey_Code(A0),D2
  947.         bne.S        2$
  948.         addq.l        #1,D1
  949.         or.w        HotKey_Qual(A0),D3
  950.         bra.S        1$
  951. 2$        tst.w        D3
  952.         bne.S        4$
  953.         move.w        #KEYMASK,D3
  954.         bra.S        4$
  955. 3$        move.l        D0,D4            ;Store the 'OR'ed qualifiers in all hotkeys with this code
  956.         mulu        #HotKey_SIZE,D4
  957.         lea        0(A2,D4),A1
  958.         move.w        D3,HotKey_QMask(A1)
  959.         addq.l        #1,D0
  960. 4$        dbf        D1,3$
  961.         move.w        HotKey_Code(A0),D2
  962.         bra.S        ml
  963. 5$        Pop        D0-D4/A0-A2
  964.         rts
  965.  
  966. InitFuncs    Push        D0/A0-A2
  967.         lea        Funcs(PC),A2
  968. 1$        move.w        Box_x(A2),D0
  969.         bmi.S        2$
  970.         move.l        FuncBox_HotKey(A2),A0
  971.         bclr        #SELECTEDBOX,Box_Flags(A2)
  972.         bclr        #GHOSTEDBOX,Box_Flags(A2)
  973.         cmp.w        #U_CODE,HotKey_Code(A0)
  974.         bne.S        3$
  975.         bset        #SELECTEDBOX,Box_Flags(A2)
  976.         bset        #GHOSTEDBOX,Box_Flags(A2)
  977. 3$        add.l        #FKeyBox_SIZE,A2
  978.         bra.S        1$
  979. 2$        Pop        D0/A0-A2
  980.         rts
  981.  
  982. * Finds first pair of duplicates (HotKeys must be sorted)
  983. * Return: D0 != -1 means D0 and D1 are the same (and not undefined)
  984. FindDuplicates    Push        A2
  985.         lea        TempPWKeys+HotKey_SIZE(PC),A2
  986.         moveq        #DefFuncNumber,D0
  987.         bra.S        3$
  988. 1$        move.l        -HotKey_SIZE+HotKey_ID(A2),D1
  989.         cmp.l        HotKey_ID(A2),D1
  990.         bne.S        2$
  991.         cmp.l        #(U_CODE<<16)|U_QUAL,D1
  992.         bne.S        4$
  993. 2$        addq.l        #HotKey_SIZE,A2
  994. 3$        dbf        D0,1$    
  995.         moveq        #-1,D0
  996.         bra.S        5$
  997. 4$        moveq        #0,D0
  998.         moveq        #0,D1
  999.         move.b        HotKey_Func(A2),D0
  1000.         move.b        -HotKey_SIZE+HotKey_Func(A2),D1
  1001. 5$        Pop        A2
  1002.         tst.l        D0
  1003.         rts
  1004.  
  1005. * Counts the number of defined hotkeys (HotKeys must be sorted)
  1006. * Return: D0 = count
  1007. CountKeys    Push        D1-D2/A2
  1008.         lea        TempPWKeys(PC),A2
  1009.         moveq        #0,D0
  1010.         moveq        #DefFuncNumber,D1
  1011.         bra.S        2$
  1012. 1$        move.w        HotKey_Code(A2),D2
  1013.         cmp.w        #U_CODE,D2
  1014.         beq.S        3$
  1015.         addq.l        #1,D0
  1016.         addq.l        #HotKey_SIZE,A2
  1017. 2$        dbf        D1,1$
  1018. 3$        Pop        D1-D2/A2
  1019.         rts
  1020.  
  1021. * Sorts HotKeys on 'Code|Qual'
  1022. SortKeys    Push        D0-D7/A0-A6
  1023.         lea        TempFile(PC),A1
  1024.         lea        PWKVersionID(PC),A0
  1025.         move.w        #FilePart,D0
  1026.         Call        MemCopy
  1027.         moveq        #0,D6
  1028.         lea        TempPWKeys(PC),A2
  1029. OuterLoop    moveq        #KeyFuncNumber,D5
  1030.         bra.S        ContSort
  1031. InnerLoop    moveq        #KeyFuncNumber,D0
  1032.         sub.w        D5,D0
  1033.         mulu        #HotKey_SIZE,D0
  1034.         lea        -HotKey_SIZE(A2,D0.L),A0
  1035.         lea        HotKey_SIZE(A0),A1
  1036.         move.l        HotKey_ID(A0),D0
  1037.         move.l        HotKey_ID(A1),D1
  1038.         cmp.l        D0,D1
  1039.         bge.S        ContSort
  1040.         move.l        D1,HotKey_ID(A0)
  1041.         move.l        D0,HotKey_ID(A1)
  1042.         move.l        HotKey_Mask(A0),D0
  1043.         move.l        HotKey_Mask(A1),HotKey_Mask(A0)
  1044.         move.l        D0,HotKey_Mask(A1)
  1045. ContSort    subq.w        #1,D5
  1046.         cmp.w        D5,D6
  1047.         blt.S        InnerLoop
  1048.         addq.w        #1,D6
  1049.         cmp.w        #KeyFuncNumber-1,D6
  1050.         blt.S        OuterLoop
  1051.         Pop        D0-D7/A0-A6
  1052.         rts
  1053.  
  1054. * Unsorts HotKeys on to 'Func'
  1055. UnSortKeys    Push        D0-D7/A0-A6
  1056.         lea        TempFile(PC),A0
  1057.         lea        PWKVersionID(PC),A1
  1058.         move.w        #FilePart,D0
  1059.         Call        MemCopy
  1060.         lea        TempPWKeys(PC),A2
  1061.         moveq        #DefFuncNumber,D0
  1062.         bra.S        2$
  1063. 1$        moveq        #0,D1
  1064.         move.b        HotKey_Func(A2),D1
  1065.         mulu        #HotKey_SIZE,D1
  1066.         lea        KeyDefines(PC),A1
  1067.         add.l        D1,A1
  1068.         move.l        HotKey_ID(A2),HotKey_ID(A1)
  1069.         move.l        HotKey_Mask(A2),HotKey_Mask(A1)
  1070.         addq.l        #HotKey_SIZE,A2
  1071. 2$        dbf        D0,1$
  1072.         Pop        D0-D7/A0-A6
  1073.         rts
  1074.  
  1075.         moveq        #0,D6
  1076.         lea        KeyDefines(PC),A2
  1077. UOuterLoop    moveq        #KeyFuncNumber,D5
  1078.         bra.S        ContUSort
  1079. UInnerLoop    moveq        #KeyFuncNumber,D0
  1080.         sub.w        D5,D0
  1081.         mulu        #HotKey_SIZE,D0
  1082.         lea        -HotKey_SIZE(A2,D0.L),A0
  1083.         lea        HotKey_SIZE(A0),A1
  1084.         moveq        #0,D0
  1085.         moveq        #0,D1
  1086.         move.b        HotKey_Func(A0),D0
  1087.         move.b        HotKey_Func(A1),D1
  1088.         cmp.w        D0,D1
  1089.         bge.S        ContUSort
  1090.         move.l        HotKey_ID(A0),D0
  1091.         move.l        HotKey_ID(A1),HotKey_ID(A0)
  1092.         move.l        D0,HotKey_ID(A1)
  1093.         move.l        HotKey_Mask(A0),D0
  1094.         move.l        HotKey_Mask(A1),HotKey_Mask(A0)
  1095.         move.l        D0,HotKey_Mask(A1)
  1096. ContUSort    subq.w        #1,D5
  1097.         cmp.w        D5,D6
  1098.         blt.S        UInnerLoop
  1099.         addq.w        #1,D6
  1100.         cmp.w        #KeyFuncNumber-1,D6
  1101.         blt.S        UOuterLoop
  1102.         Pop        D0-D7/A0-A6
  1103.         rts
  1104.  
  1105. * Writes the text in the function boxes
  1106. WriteFuncs    Push        D0-D1
  1107.         moveq        #FUNCTEXTS+GADTEXTS,D1
  1108.         bra.S        2$
  1109. 1$        move.w        D1,D0
  1110.         Call        WriteTxt
  1111. 2$        dbf        D1,1$
  1112.         Pop        D0-D1
  1113.         rts
  1114.  
  1115. * Call: D0 = Msg-number
  1116. WriteMsg    Push        D0-D4/A0-A1/A6
  1117.         neg.w        D0
  1118.         add.w        #FUNCTEXTS+GADTEXTS,D0
  1119.         move.l        D0,D5
  1120.         Call        SetAPen0
  1121.         moveq        #4,D0
  1122.         moveq        #2,D1
  1123.         move.w        #570,D2
  1124.         moveq        #10,D3
  1125.         movea.l        Rp(DB),A1
  1126.         CallLib        RectFill
  1127.         Call        SetAPen1
  1128.         move.l        D5,D0
  1129.         Call        WriteTxt
  1130.         Pop        D0-D4/A0-A1/A6
  1131.         rts
  1132.  
  1133. * Call: D0 = Msg-number
  1134. WriteTxt    Push        D0-D1/A0-A3/A6
  1135.         Prepare        Gfx_Call
  1136.         lea        TextTab(PC),A2
  1137.         move.l        A2,A3
  1138.         mulu        #TE_SIZE,D0
  1139.         add.l        D0,A2
  1140.         move.w        TE_x(A2),D0
  1141.         move.w        TE_y(A2),D1
  1142.         movea.l        Rp(DB),A1
  1143.         CallLib        Move
  1144.         move.w        TE_Offset(A2),A0
  1145.         add.l        A3,A0
  1146.         Call        StrLen
  1147.         movea.l        Rp(DB),A1
  1148.         CallLib        Text
  1149.         Pop        D0-D1/A0-A3/A6
  1150.         rts
  1151.  
  1152. * Sets the drawing pen.
  1153. * Destroys D0-D1/A0-A1/A6
  1154. SetAPen0    moveq        #0,D0
  1155.         bra.S        SetPenA
  1156. SetAPen1    moveq        #1,D0
  1157. SetPenA        movea.l        Rp(DB),A1        ; D0=Color
  1158.         Prepare        Gfx_Call
  1159.         CallLib        SetAPen
  1160.         rts
  1161.  
  1162. SetDrMd1    moveq        #1,D0
  1163.         bra.S        SetMdDr
  1164. SetDrMd2    moveq        #2,D0
  1165. SetMdDr        movea.l        Rp(DB),A1        ; D0=Drawmode
  1166.         Prepare        Gfx_Call
  1167.         CallLib        SetDrMd
  1168.         rts
  1169.  
  1170. * Call: A0    = Source
  1171. *       A1    = Destination
  1172. *       D0:16 = Count
  1173. MemCopy        Push        D0/A0-A1
  1174.         bra.S        2$
  1175. 1$        move.b        (A0)+,(A1)+
  1176. 2$        dbf        D0,1$
  1177.         Pop        D0/A0-A1
  1178.         rts
  1179.  
  1180. * Call:   A0 = String
  1181. * Return: D0 = length
  1182. StrLen        Push        A0
  1183.         moveq        #-1,D0
  1184. 1$        addq.l        #1,D0
  1185.         tst.b        (A0)+
  1186.         bne.S        1$
  1187.         Pop        A0
  1188.         rts
  1189.  
  1190. * Return: D0 != means that we got a message
  1191. GetAMessage    Push        D0-D1/A0-A1/A6
  1192.         movea.l        Up(DB),A0
  1193.         Prepare        Exec_Call
  1194.         CallLib        GetMsg
  1195.         tst.l        D0
  1196.         beq.S        NoMessage
  1197. GotAMessage    movea.l        D0,A1
  1198.         move.l        im_Class(A1),Class(DB)
  1199.         move.w        im_Code(A1),Code(DB)
  1200.         move.w        im_Qualifier(A1),Qual(DB)
  1201.         move.l        im_IAddress(A1),IAddress(DB)
  1202.         move.w        im_MouseX(A1),MouseX(DB)
  1203.         move.w        im_MouseY(A1),MouseY(DB)
  1204.         CallLib        ReplyMsg
  1205.         moveq        #1,D0
  1206. NoMessage    Pop        D0-D1/A0-A1/A6
  1207.         rts
  1208.  
  1209. *====================== Data-definition start =======================
  1210.  rStart
  1211.  rWord        Quit
  1212.  rAPtr        PProcess
  1213.  rAPtr        DosBase
  1214.  rAPtr        GraphBase
  1215.  rAPtr        IntBase
  1216.  rLong        WBenchMsg
  1217.  rAPtr        FHandle
  1218.  rAPtr        DScreen
  1219.  rAPtr        DWindow
  1220.  rAPtr        ScrVp            ; ViewPort
  1221.  rAPtr        Rp            ; RastPort
  1222.  rAPtr        Up            ; UserPort
  1223.  rLong        Class            ; IDCMP->Class
  1224.  rWord        Code            ; IDCMP->Code
  1225.  rWord        Qual            ; IDCMP->Qualifier
  1226.  rLong        IAddress        ; IDCMP->IAddress
  1227.  rWord        MouseX            ; IDCMP->MouseX
  1228.  rWord        MouseY            ; IDCMP->MouseY
  1229.  rAPtr        CurFunc            ; Ptr to FuncBox
  1230.  rAPtr        CurCode            ; Ptr to KeyBox
  1231.  rEnd
  1232.         EVEN
  1233. StrBuf        ;Re-use space below after opening libraries
  1234. DosName        dc.b        'dos.library',0
  1235. GfxName        dc.b        'graphics.library',0
  1236. IntName        dc.b        'intuition.library',0
  1237. PWKeysPortName    dc.b        'PWKeys V1.0 Port',0
  1238.         EVEN
  1239.  
  1240. ScrW        =640
  1241. ScrH        =196
  1242. NewS        dc.w        0,0,ScrW,ScrH,PLANES
  1243.         dc.b        0,1
  1244.         dc.w        V_HIRES,CUSTOMSCREEN|SCREENQUIET
  1245.         dc.l        TxtAttr,0,0,0
  1246. IDCMP_Flags    =GADGETUP+MOUSEBUTTONS
  1247. Other_Flags    =NOCAREREFRESH+ACTIVATE+RMBTRAP+BORDERLESS
  1248. NewW        dc.w        0,SWDIFF,ScrW,ScrH-SWDIFF
  1249.         dc.b        0,1
  1250.         dc.l        IDCMP_Flags,Other_Flags,GadgetList,0,0,0,0
  1251.         dc.w        0,0,0,0,CUSTOMSCREEN
  1252.     IFD CUSTOMCOLORS
  1253. ColorTable    dc.w        $0BBC,$0000
  1254.     ENDC
  1255.  
  1256. GadgetList
  1257. Gad1        Gadget        Gad2,502,8,BWIDTH,BHEIGHT,GADGHCOMP,RELVERIFY,BOOLGADGET
  1258.         Gadget2        BBorder,0,0,0,0,DoQuit-GJ,0
  1259. Gad2        Gadget        Gad3,448,25,BWIDTH,BHEIGHT,GADGHCOMP,RELVERIFY,BOOLGADGET
  1260.         Gadget2        BBorder,0,0,0,0,DoCheck-GJ,0
  1261. Gad3        Gadget        Gad4,556,25,BWIDTH,BHEIGHT,GADGHCOMP,RELVERIFY,BOOLGADGET
  1262.         Gadget2        BBorder,0,0,0,0,DoUse-GJ,0
  1263. Gad4        Gadget        Gad5,448,42,BWIDTH,BHEIGHT,GADGHCOMP,RELVERIFY,BOOLGADGET
  1264.         Gadget2        BBorder,0,0,0,0,DoUndo-GJ,0
  1265. Gad5        Gadget        Gad6,556,42,BWIDTH,BHEIGHT,GADGHCOMP,RELVERIFY,BOOLGADGET
  1266.         Gadget2        BBorder,0,0,0,0,DoClear-GJ,0
  1267. Gad6        Gadget        Gad7,448,59,BWIDTH,BHEIGHT,GADGHCOMP,RELVERIFY,BOOLGADGET
  1268.         Gadget2        BBorder,0,0,0,0,DoSave-GJ,0
  1269. Gad7        Gadget        Gad8,556,59,BWIDTH,BHEIGHT,GADGHCOMP,RELVERIFY,BOOLGADGET
  1270.         Gadget2        BBorder,0,0,0,0,DoLoad-GJ,0
  1271. Gad8        Gadget        0,452,78,FWIDTH,FHEIGHT,GADGHCOMP,RELVERIFY,STRGADGET
  1272.         Gadget2        FBorder,0,0,0,FileInfo,DoGadgets-GJ,0
  1273.  
  1274. FileBufLen    =80
  1275. FileInfo    dc.l        FBuffer,0
  1276.         dc.w        0,FileBufLen,0,0,0,0,0,0
  1277.         dc.l        0,0,0
  1278. FBuffer        dc.b        'S:PWKeys.Config'
  1279.         dcb.b        FileBufLen-14,0
  1280.         EVEN
  1281.  
  1282. TxtAttr        dc.l        FontName
  1283.         dc.w        TOPAZ_EIGHTY
  1284.         dc.b        FS_NORMAL,FPB_ROMFONT
  1285. FontName    dc.b        'topaz.font',0
  1286.         EVEN
  1287.  
  1288. ArrowImages    Image        0,0,42,11,1,ArrowsData,%00000001,%00000000,0
  1289. FWIDTH        =188
  1290. FHEIGHT        =11
  1291. FBorder        Border        -6,-3,1,0,1,17,FVectors,0
  1292. FVectors    dc.w        2,0,FWIDTH+1,0,FWIDTH+3,2,FWIDTH+3,FHEIGHT-1,FWIDTH+1,FHEIGHT+1,2,FHEIGHT+1,0,FHEIGHT-1,0,2,2,0
  1293.         dc.w        1,0,-1,2,-1,FHEIGHT-1,1,FHEIGHT+1,FWIDTH+2,FHEIGHT+1,FWIDTH+4,FHEIGHT-1,FWIDTH+4,2,FWIDTH+2,0
  1294. FUNCW        =402
  1295. FUNCH        =84
  1296. FuncBorder    Border        1,0,1,0,1,17,FuncVectors,0
  1297. FuncVectors    dc.w        2,0,FUNCW+1,0,FUNCW+3,2,FUNCW+3,FUNCH-1,FUNCW+1,FUNCH+1,2,FUNCH+1,0,FUNCH-1,0,2,2,0
  1298.         dc.w        1,0,-1,2,-1,FUNCH-1,1,FUNCH+1,FUNCW+2,FUNCH+1,FUNCW+4,FUNCH-1,FUNCW+4,2,FUNCW+2,0
  1299. BWIDTH        =80
  1300. BHEIGHT        =11
  1301. BBorder        Border        -2,-1,1,0,1,17,BVectors,0
  1302. BVectors    dc.w        2,0,BWIDTH+1,0,BWIDTH+3,2,BWIDTH+3,BHEIGHT-1,BWIDTH+1,BHEIGHT+1,2,BHEIGHT+1,0,BHEIGHT-1,0,2,2,0
  1303.         dc.w        1,0,-1,2,-1,BHEIGHT-1,1,BHEIGHT+1,BWIDTH+2,BHEIGHT+1,BWIDTH+4,BHEIGHT-1,BWIDTH+4,2,BWIDTH+2,0
  1304. KEYBW        =ScrW-6
  1305. KEYBH        =85
  1306. KeybBorder    Border        1,0,1,0,1,17,KeybVectors,0
  1307. KeybVectors    dc.w        2,0,KEYBW+1,0,KEYBW+3,2,KEYBW+3,KEYBH-1,KEYBW+1,KEYBH+1,2,KEYBH+1,0,KEYBH-1,0,2,2,0
  1308.         dc.w        1,0,-1,2,-1,KEYBH-1,1,KEYBH+1,KEYBW+2,KEYBH+1,KEYBW+4,KEYBH-1,KEYBW+4,2,KEYBW+2,0
  1309. TITW        =570
  1310. TITH        =11
  1311. TitleBorder    Border        1,0,1,0,1,17,TitleVectors,0
  1312. TitleVectors    dc.w        2,0,TITW+1,0,TITW+3,2,TITW+3,TITH-1,TITW+1,TITH+1,2,TITH+1,0,TITH-1,0,2,2,0
  1313.         dc.w        1,0,-1,2,-1,TITH-1,1,TITH+1,TITW+2,TITH+1,TITW+4,TITH-1,TITW+4,2,TITW+2,0
  1314.  
  1315. TE_x        =0
  1316. TE_y        =2
  1317. TE_Offset    =4
  1318. TE_SIZE        =6
  1319. TEntry        MACRO        'TextEntry'
  1320.         dc.w        \1,\2,\3-TextTab
  1321.         ENDM
  1322. FySpace        =9
  1323. FTx1        =8
  1324. FTx2        =207
  1325. FTy        =27
  1326.  
  1327. TextTab        TEntry        FTx1,FTy+0*FySpace,1$
  1328.         TEntry        FTx1,FTy+1*FySpace,2$
  1329.         TEntry        FTx1,FTy+2*FySpace,3$
  1330.         TEntry        FTx1,FTy+3*FySpace,4$
  1331.         TEntry        FTx1,FTy+4*FySpace,5$
  1332.         TEntry        FTx1,FTy+5*FySpace,6$
  1333.         TEntry        FTx1,FTy+6*FySpace,7$
  1334.         TEntry        FTx1,FTy+7*FySpace,8$
  1335.         TEntry        FTx1,FTy+8*FySpace,9$
  1336.         TEntry        FTx2,FTy+0*FySpace,10$
  1337.         TEntry        FTx2,FTy+1*FySpace,11$
  1338.         TEntry        FTx2,FTy+2*FySpace,12$
  1339.         TEntry        FTx2,FTy+3*FySpace,13$
  1340.         TEntry        FTx2,FTy+4*FySpace,14$
  1341.         TEntry        FTx2,FTy+5*FySpace,15$
  1342.         TEntry        FTx2,FTy+6*FySpace,16$
  1343.         TEntry        FTx2,FTy+7*FySpace,17$
  1344.  
  1345.         TEntry        525,26,21$
  1346.         TEntry        470,43,22$
  1347.         TEntry        578,43,23$
  1348.         TEntry        470,60,24$
  1349.         TEntry        578,60,25$
  1350.         TEntry        470,77,26$
  1351.         TEntry        578,77,27$
  1352.  
  1353.         TEntry        10,9,28$
  1354.         TEntry        10,9,29$
  1355.         TEntry        10,9,30$
  1356.         TEntry        10,9,31$
  1357.         TEntry        10,9,32$
  1358.         TEntry        10,9,33$
  1359.         TEntry        10,9,34$
  1360.  
  1361. * Function texts
  1362. 1$        dc.b        'Window to top',0
  1363. 2$        dc.b        'Window to bottom',0
  1364. 3$        dc.b        'Window to left',0
  1365. 4$        dc.b        'Window to right',0
  1366. 5$        dc.b        'Window to left-top',0
  1367. 6$        dc.b        'Window to left-bottom',0
  1368. 7$        dc.b        'Window to right-top',0
  1369. 8$        dc.b        'Window to right-bottom',0
  1370. 9$        dc.b        'Window to center',0
  1371. 10$        dc.b        'Window to front',0
  1372. 11$        dc.b        'Window to back',0
  1373. 12$        dc.b        'Activate previous window',0
  1374. 13$        dc.b        'Activate next window',0
  1375. 14$        dc.b        'Back window to front',0
  1376. 15$        dc.b        'Front window to back',0
  1377. 16$        dc.b        'Back screen to front',0
  1378. 17$        dc.b        'Front screen to back',0
  1379.  
  1380. * Gadget texts
  1381. 21$        dc.b        'Quit',0
  1382. 22$        dc.b        'Check',0
  1383. 23$        dc.b        'Use',0
  1384. 24$        dc.b        'Undo',0
  1385. 25$        dc.b        'Clear',0
  1386. 26$        dc.b        'Save',0
  1387. 27$        dc.b        'Load',0
  1388.  
  1389. * Message texts
  1390. 28$        dc.b        'SetPWKeys V1.0 1991 by Preben Nielsen',0
  1391. 29$        dc.b        "Error: Can't open file",0
  1392. 30$        dc.b        "Error: Not a PWKeys file",0
  1393. 31$        dc.b        "Error: Can't write file",0
  1394. 32$        dc.b        'Error: The PWKeys-handler is not installed',0
  1395. 33$        dc.b        'Error: Duplicate hotkey definitions.',0
  1396. 34$        dc.b        'There are no duplicate hotkey definitions',0
  1397.         EVEN
  1398.  
  1399. Box_x        =0
  1400. Box_y        =2
  1401. Box_Width    =4
  1402. Box_Height    =6
  1403. Box_Flags    =8
  1404. Box_SIZE    =9
  1405. Box        MACRO
  1406.         dc.w        \1,\2,\3,\4    ; x,y,width,height
  1407.         dc.b        \5        ; Flags
  1408.         ENDM
  1409.  
  1410. FuncBox_HotKey    =10
  1411. FuncBox_SIZE    =14
  1412. FuncBox        MACRO        'Functionbox'
  1413.         Box        \1,\2,\3,\4,\5    ; Box definition
  1414.         dc.b        0        ; Pad
  1415.         dc.l        \6        ; Function
  1416.         ENDM
  1417.  
  1418. KeyBox_Char    =9
  1419. KeyBox_Code    =10
  1420. KeyBox_Qual    =12
  1421. KeyBox_SIZE    =14
  1422. FKeyBox_SIZE    =14
  1423. KeyBox        MACRO        'Keybox'
  1424.         Box        \1,\2,\3,\4,\5    ; Box definition
  1425.         dc.b        \6        ; Char
  1426.         dc.w        \7,\8        ; Raw, Qual
  1427.         ENDM
  1428.  
  1429. FBx1        =FTx1-4
  1430. FBx2        =FTx2-4
  1431. FBy        =FTy-8
  1432. FBWidth        =200
  1433. FBHeight    =11
  1434.  
  1435. Funcs        FuncBox        FBx1,FBy+0*FySpace,FBWidth,FBHeight,0,HK1
  1436.         FuncBox        FBx1,FBy+1*FySpace,FBWidth,FBHeight,0,HK2
  1437.         FuncBox        FBx1,FBy+2*FySpace,FBWidth,FBHeight,0,HK3
  1438.         FuncBox        FBx1,FBy+3*FySpace,FBWidth,FBHeight,0,HK4
  1439.         FuncBox        FBx1,FBy+4*FySpace,FBWidth,FBHeight,0,HK5
  1440.         FuncBox        FBx1,FBy+5*FySpace,FBWidth,FBHeight,0,HK6
  1441.         FuncBox        FBx1,FBy+6*FySpace,FBWidth,FBHeight,0,HK7
  1442.         FuncBox        FBx1,FBy+7*FySpace,FBWidth,FBHeight,0,HK8
  1443.         FuncBox        FBx1,FBy+8*FySpace,FBWidth,FBHeight,0,HK9
  1444.         FuncBox        FBx2,FBy+0*FySpace,FBWidth,FBHeight,0,HK10
  1445.         FuncBox        FBx2,FBy+1*FySpace,FBWidth,FBHeight,0,HK11
  1446.         FuncBox        FBx2,FBy+2*FySpace,FBWidth,FBHeight,0,HK12
  1447.         FuncBox        FBx2,FBy+3*FySpace,FBWidth,FBHeight,0,HK13
  1448.         FuncBox        FBx2,FBy+4*FySpace,FBWidth,FBHeight,0,HK14
  1449.         FuncBox        FBx2,FBy+5*FySpace,FBWidth,FBHeight,0,HK15
  1450.         FuncBox        FBx2,FBy+6*FySpace,FBWidth,FBHeight,0,HK16
  1451.         FuncBox        FBx2,FBy+7*FySpace,FBWidth,FBHeight,0,HK17
  1452.         FuncBox        -1,-1,-1,-1,0,Funcs
  1453.  
  1454. Absx        =20
  1455. KH        =10
  1456. FM        =8
  1457. FW        =27
  1458. FSPACE        =6
  1459. FD        =FW+FSPACE
  1460. NW        =20
  1461. NSPACE        =6
  1462. ND        =NW+NSPACE
  1463. KPx        =Absx+498
  1464. Arx        =Absx+410
  1465. KY        =ScrH-81
  1466. R1x        =Absx+40
  1467. R2x        =Absx+40
  1468. R3x        =Absx+50
  1469. R4x        =Absx+56
  1470. R5x        =Absx+70    ;62
  1471. R1y        =KY+0*(KH+3)
  1472. R2y        =KY+1*(KH+3)
  1473. R3y        =KY+2*(KH+3)
  1474. R4y        =KY+3*(KH+3)
  1475. R5y        =KY+4*(KH+3)
  1476. R6y        =KY+5*(KH+3)
  1477.  
  1478. Keys
  1479. ReturnKey1
  1480.  KeyBox        382,R3y,NW+16,KH*2+3,0,0,$44,0
  1481. ReturnKey2
  1482.  KeyBox        363,R3y+13,20,KH,0,0,$44,0
  1483.  KeyBox        Absx,R1y,NW,KH,0,0,$45,0        ;ESC
  1484.  KeyBox        R1x+00*FD,R1y,FW,KH,0,0,$50,0        ;F1
  1485.  KeyBox        R1x+01*FD,R1y,FW,KH,0,0,$51,0        ;F2
  1486.  KeyBox        R1x+02*FD,R1y,FW,KH,0,0,$52,0        ;F3
  1487.  KeyBox        R1x+03*FD,R1y,FW,KH,0,0,$53,0        ;F4
  1488.  KeyBox        R1x+04*FD,R1y,FW,KH,0,0,$54,0        ;F5
  1489.  KeyBox        R1x+FM+05*FD,R1y,FW,KH,0,0,$55,0    ;F6
  1490.  KeyBox        R1x+FM+06*FD,R1y,FW,KH,0,0,$56,0    ;F7
  1491.  KeyBox        R1x+FM+07*FD,R1y,FW,KH,0,0,$57,0    ;F8
  1492.  KeyBox        R1x+FM+08*FD,R1y,FW,KH,0,0,$58,0    ;F9
  1493.  KeyBox        R1x+FM+09*FD,R1y,FW,KH,0,0,$59,0    ;F10
  1494.  KeyBox        Absx,R2y,FW+6,KH,0,'`',$00,0
  1495.  KeyBox        R2x+00*ND,R2y,NW,KH,0,'1',$01,0
  1496.  KeyBox        R2x+01*ND,R2y,NW,KH,0,'2',$02,0
  1497.  KeyBox        R2x+02*ND,R2y,NW,KH,0,'3',$03,0
  1498.  KeyBox        R2x+03*ND,R2y,NW,KH,0,'4',$04,0
  1499.  KeyBox        R2x+04*ND,R2y,NW,KH,0,'5',$05,0
  1500.  KeyBox        R2x+05*ND,R2y,NW,KH,0,'6',$06,0
  1501.  KeyBox        R2x+06*ND,R2y,NW,KH,0,'7',$07,0
  1502.  KeyBox        R2x+07*ND,R2y,NW,KH,0,'8',$08,0
  1503.  KeyBox        R2x+08*ND,R2y,NW,KH,0,'9',$09,0
  1504.  KeyBox        R2x+09*ND,R2y,NW,KH,0,'0',$0A,0
  1505.  KeyBox        R2x+10*ND,R2y,NW,KH,0,'-',$0B,0
  1506.  KeyBox        R2x+11*ND,R2y,NW,KH,0,'=',$0C,0
  1507.  KeyBox        R2x+12*ND,R2y,NW,KH,0,'\',$0D,0
  1508.  KeyBox        R2x+13*ND,R2y,NW,KH,0,0,$41,0        ;Backspace
  1509.  KeyBox        Arx,R2y,FW+6,KH,0,0,$46,0        ;Del
  1510.  KeyBox        Arx+8+FD,R2y,FW+6,KH,0,0,$5F,0        ;Help
  1511.  KeyBox        KPx+00*ND,R2y,NW,KH,0,'[',$5A,0
  1512.  KeyBox        KPx+01*ND,R2y,NW,KH,0,']',$5B,0
  1513.  KeyBox        KPx+02*ND,R2y,NW,KH,0,'\',$5C,0
  1514.  KeyBox        KPx+03*ND,R2y,NW,KH,0,'*',$5D,0
  1515.  KeyBox        Absx,R3y,FW+16,KH,0,0,$42,0        ;Tab
  1516.  KeyBox        R3x+00*ND,R3y,NW,KH,0,'q',$10,0
  1517.  KeyBox        R3x+01*ND,R3y,NW,KH,0,'w',$11,0
  1518.  KeyBox        R3x+02*ND,R3y,NW,KH,0,'e',$12,0
  1519.  KeyBox        R3x+03*ND,R3y,NW,KH,0,'r',$13,0
  1520.  KeyBox        R3x+04*ND,R3y,NW,KH,0,'t',$14,0
  1521.  KeyBox        R3x+05*ND,R3y,NW,KH,0,'y',$15,0
  1522.  KeyBox        R3x+06*ND,R3y,NW,KH,0,'u',$16,0
  1523.  KeyBox        R3x+07*ND,R3y,NW,KH,0,'i',$17,0
  1524.  KeyBox        R3x+08*ND,R3y,NW,KH,0,'o',$18,0
  1525.  KeyBox        R3x+09*ND,R3y,NW,KH,0,'p',$19,0
  1526.  KeyBox        R3x+10*ND,R3y,NW,KH,0,'[',$1A,0
  1527.  KeyBox        R3x+11*ND,R3y,NW,KH,0,']',$1B,0
  1528.  KeyBox        KPx+00*ND,R3y,NW,KH,0,'7',$3D,0
  1529.  KeyBox        KPx+01*ND,R3y,NW,KH,0,'8',$3E,0
  1530.  KeyBox        KPx+02*ND,R3y,NW,KH,0,'9',$3F,0
  1531.  KeyBox        KPx+03*ND,R3y,NW,KH,0,'-',$4A,0
  1532.  KeyBox        Absx,R4y,NW+3,KH,0,0,$63,IEQUALIFIER_CONTROL
  1533.  KeyBox        Absx+ND+3,R4y,NW,KH,0,0,$62,IEQUALIFIER_CAPSLOCK
  1534.  KeyBox        R4x+00*ND,R4y,NW,KH,0,'a',$20,0
  1535.  KeyBox        R4x+01*ND,R4y,NW,KH,0,'s',$21,0
  1536.  KeyBox        R4x+02*ND,R4y,NW,KH,0,'d',$22,0
  1537.  KeyBox        R4x+03*ND,R4y,NW,KH,0,'f',$23,0
  1538.  KeyBox        R4x+04*ND,R4y,NW,KH,0,'g',$24,0
  1539.  KeyBox        R4x+05*ND,R4y,NW,KH,0,'h',$25,0
  1540.  KeyBox        R4x+06*ND,R4y,NW,KH,0,'j',$26,0
  1541.  KeyBox        R4x+07*ND,R4y,NW,KH,0,'k',$27,0
  1542.  KeyBox        R4x+08*ND,R4y,NW,KH,0,'l',$28,0
  1543.  KeyBox        R4x+09*ND,R4y,NW,KH,0,';',$29,0
  1544.  KeyBox        R4x+10*ND,R4y,NW,KH,0,"'",$2A,0
  1545.  KeyBox        Arx+1*ND,R4y,NW,KH,0,0,$4C,0        ;Uparrow
  1546.  KeyBox        KPx+00*ND,R4y,NW,KH,0,'4',$2D,0
  1547.  KeyBox        KPx+01*ND,R4y,NW,KH,0,'5',$2E,0
  1548.  KeyBox        KPx+02*ND,R4y,NW,KH,0,'6',$2F,0
  1549.  KeyBox        KPx+03*ND,R4y,NW,KH,0,'+',$5E,0
  1550.  KeyBox        Absx,R5y,63,KH,0,0,$60,IEQUALIFIER_LSHIFT
  1551.  KeyBox        R5x+00*ND,R5y,NW,KH,0,'z',$31,0
  1552.  KeyBox        R5x+01*ND,R5y,NW,KH,0,'x',$32,0
  1553.  KeyBox        R5x+02*ND,R5y,NW,KH,0,'c',$33,0
  1554.  KeyBox        R5x+03*ND,R5y,NW,KH,0,'v',$34,0
  1555.  KeyBox        R5x+04*ND,R5y,NW,KH,0,'b',$35,0
  1556.  KeyBox        R5x+05*ND,R5y,NW,KH,0,'n',$36,0
  1557.  KeyBox        R5x+06*ND,R5y,NW,KH,0,'m',$37,0
  1558.  KeyBox        R5x+07*ND,R5y,NW,KH,0,$2C,$38,0        ;','
  1559.  KeyBox        R5x+08*ND,R5y,NW,KH,0,'.',$39,0
  1560.  KeyBox        R5x+09*ND,R5y,NW,KH,0,'/',$3A,0
  1561.  KeyBox        R5x+10*ND,R5y,67,KH,0,0,$61,IEQUALIFIER_RSHIFT
  1562.  KeyBox        Arx+00*ND,R5y,NW,KH,0,0,$4F,0        ;Leftarrow
  1563.  KeyBox        Arx+01*ND,R5y,NW,KH,0,0,$4D,0        ;Downarrow
  1564.  KeyBox        Arx+02*ND,R5y,NW,KH,0,0,$4E,0        ;Rightarrow
  1565.  KeyBox        KPx+00*ND,R5y,NW,KH,0,'1',$1D,0
  1566.  KeyBox        KPx+01*ND,R5y,NW,KH,0,'2',$1E,0
  1567.  KeyBox        KPx+02*ND,R5y,NW,KH,0,'3',$1F,0
  1568.  KeyBox        KPx+03*ND,R5y,NW,KH*2+3,0,0,$43,0    ;Enter
  1569.  KeyBox        Absx+10,R6y,FW+2,KH,0,0,$64,IEQUALIFIER_LALT
  1570.  KeyBox        Absx+10+FD+2,R6y,FW+2,KH,0,0,$66,IEQUALIFIER_LCOMMAND
  1571.  KeyBox        100,R6y,232,KH,0,0,$40,0        ;Space
  1572.  KeyBox        338,R6y,FW+2,KH,0,0,$67,IEQUALIFIER_RCOMMAND
  1573.  KeyBox        338+FD+2,R6y,FW+2,KH,0,0,$65,IEQUALIFIER_RALT
  1574.  KeyBox        KPx+00*ND,R6y,NW+ND,KH,0,'0',$0F,0    ;KeyPad 0
  1575.  KeyBox        KPx+02*ND,R6y,NW,KH,0,'.',$3C,0
  1576.  KeyBox        -1,-1,-1,-1,0,0,0,0
  1577.  
  1578. ihs_Port    =0
  1579. ihs_Interrupt    =MP_SIZE
  1580. ihs_ID        =MP_SIZE+IS_SIZE
  1581. ihs_Length    =MP_SIZE+IS_SIZE+4
  1582. ihs_Flags    =MP_SIZE+IS_SIZE+8
  1583. ihs_PortName    =MP_SIZE+IS_SIZE+10
  1584.  
  1585. PWKVersionID    dc.l        'PWKF'
  1586. PWKVersionNum    dc.w        PWKeysVersion,PWKeysRevision
  1587. PWKPri        dc.b        PWKeysPri,0
  1588.         dc.w        DefFuncNumber
  1589. KeyDefines
  1590. HK1        HotKey        KP8,LAMIGA,LAMIGA,AW_TO_TOP
  1591. HK2        HotKey        KP2,LAMIGA,LAMIGA,AW_TO_BOTTOM
  1592. HK3        HotKey        KP4,LAMIGA,LAMIGA,AW_TO_LEFT
  1593. HK4        HotKey        KP6,LAMIGA,LAMIGA,AW_TO_RIGHT
  1594. HK5        HotKey        KP7,LAMIGA,LAMIGA,AW_TO_LEFT_TOP
  1595. HK6        HotKey        KP1,LAMIGA,LAMIGA,AW_TO_LEFT_BOTTOM
  1596. HK7        HotKey        KP9,LAMIGA,LAMIGA,AW_TO_RIGHT_TOP
  1597. HK8        HotKey        KP3,LAMIGA,LAMIGA,AW_TO_RIGHT_BOTTOM
  1598. HK9        HotKey        KP5,LAMIGA,LAMIGA,AW_TO_CENTER
  1599. HK10        HotKey        DOWNARROW,LAMIGA,LSHIFT|LAMIGA|RAMIGA,AW_TO_FRONT
  1600. HK11        HotKey        UPARROW,LAMIGA,LSHIFT|LAMIGA|RAMIGA,AW_TO_BACK
  1601. HK12        HotKey        LEFTARROW,LAMIGA,LAMIGA,ACTIVATE_PREV_W
  1602. HK13        HotKey        RIGHTARROW,LAMIGA,LAMIGA,ACTIVATE_NEXT_W
  1603. HK14        HotKey        DOWNARROW,LSHIFT|LAMIGA,LSHIFT|LAMIGA|RAMIGA,BACK_W_TO_FRONT
  1604. HK15        HotKey        UPARROW,LSHIFT|LAMIGA,LSHIFT|LAMIGA|RAMIGA,FRONT_W_TO_BACK
  1605. HK16        HotKey        DOWNARROW,RAMIGA,LSHIFT|LAMIGA|RAMIGA,BACK_S_TO_FRONT
  1606. HK17        HotKey        UPARROW,RAMIGA,LSHIFT|LAMIGA|RAMIGA,FRONT_S_TO_BACK
  1607. HK18        HotKey        U_CODE,U_QUAL,U_QUAL,U_FUNC
  1608. HK19        HotKey        U_CODE,U_QUAL,U_QUAL,U_FUNC
  1609. HK20        HotKey        U_CODE,U_QUAL,U_QUAL,U_FUNC
  1610.  
  1611. * Area to use for sorting and IO
  1612. * This is buffer when trying to read file
  1613. TempFile    dc.l        'PWKF'
  1614.         dc.w        PWKeysVersion,PWKeysRevision
  1615.         dc.b        PWKeysPri,0
  1616. TempDefined    dc.w        DefFuncNumber
  1617. TempPWKeys    dcb.b        FilePart-12
  1618.  
  1619.         SECTION        IMAGEDATA,DATA_C    ;Image-data has to be in CHIP-RAM
  1620. Mask        dc.w        %0011001100110011
  1621.         dc.w        %1100110011001100
  1622.         dc.w        %0011001100110011
  1623.         dc.w        %1100110011001100
  1624.  
  1625. ArrowsData    dc.w        %0000000001100000,%0000000001111111,%1111111110000000
  1626.         dc.w        %0000000011110000,%0000000011000000,%0000000011000000
  1627.         dc.w        %0000000110011000,%0000000011000000,%0000000011000000
  1628.         dc.w        %0000001100001100,%0000000001100000,%0000000110000000
  1629.         dc.w        %0000011000000110,%0000000000110000,%0000001100000000
  1630.         dc.w        %0000110000000011,%0000000000011000,%0000011000000000
  1631.         dc.w        %0001100000000001,%1000000000001100,%0000110000000000
  1632.         dc.w        %0011000000000000,%1100000000000110,%0001100000000000
  1633.         dc.w        %0110000000000000,%0110000000000011,%0011000000000000
  1634.         dc.w        %0110000000000000,%0110000000000001,%1110000000000000
  1635.         dc.w        %0011111111111111,%1100000000000000,%1100000000000000
  1636.         END
  1637.  
  1638.