home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / commod / huntwi30.lha / huntwindows.s < prev   
Text File  |  1993-05-17  |  46KB  |  2,229 lines

  1.              output    work:huntwindows
  2.             OPT o+,ow-
  3.             ;no includes - i use them all preassembled!
  4.  
  5.             ;.... nearly all ....
  6.  
  7.             incdir    "asminc:"
  8.             include "workbench/startup.i"
  9.             include "workbench/workbench.i"
  10.             include    "workbench/icon_lib.i"
  11.             include    "libraries/commodities.i"
  12.             include    "graphics/view.i"
  13.  
  14.             ;Some helpful macros
  15. CALL            macro
  16.             jsr    _LVO\1(a6)
  17.             endm
  18. Push            macro
  19.             movem.l    \1,-(sp)
  20.             endm
  21. Pull            macro
  22.             movem.l    (sp)+,\1
  23.             endm
  24. RSave            macro
  25.             movem.l    a0-a6/d0-d7,-(sp)
  26.             endm
  27. RLoad            macro
  28.             movem.l    (sp)+,a0-a6/d0-d7
  29.             endm
  30.  
  31. MaxScreens        equ    64    ;Maximum of 64 Screens - who has more?
  32. ScreenMemSize        equ    MaxScreens*8    
  33.  
  34.         ;Bits for Communication
  35. SignalWindow        equ    0
  36. SignalScreen        equ    1
  37. SignalButton        equ    2
  38.  
  39.  
  40.  
  41. MyHotkeyID    =    1
  42. MyActionID    =    2
  43. MyCustomID    =    3
  44.  
  45.             RSave
  46.  
  47.             move.l    $04,a6
  48.             move.l    #AllocLength,d0
  49.             move.l    #MEMF_CLEAR,d1
  50.             CALL    AllocMem
  51.             move.l    d0,a4
  52.             tst.l    d0
  53.             beq    EndeRaus
  54.  
  55.             move.l    d0,RememberA4
  56.             move.l    a7,RememberStack
  57.  
  58.             lea    intuition(pc),a1
  59.             moveq.l    #37,d0
  60.             CALL    OpenLibrary
  61.             move.l    d0,IntBase(a4)
  62.             beq    Error2
  63.  
  64.             lea    DosName(pc),a1
  65.             moveq.l    #37,d0
  66.             CALL    OpenLibrary    
  67.             move.l    d0,DosBase(a4)
  68.             beq    Error2
  69.  
  70.             lea    GadName(pc),a1
  71.             moveq.l    #37,d0
  72.             CALL    OpenLibrary
  73.             move.l    d0,GadBase(a4)
  74.             beq    Error2
  75.  
  76.             lea    CommName(pc),a1
  77.             moveq.l    #37,d0
  78.             CALL    OpenLibrary
  79.             move.l    d0,CommBase(a4)
  80.             beq    Error2
  81.  
  82.             CALL    CreateMsgPort
  83.             move.l    d0,MouseMsgPort(a4)
  84.             beq    Error2
  85.  
  86.             move.l    #SIGBREAKF_CTRL_C,SignalMask(a4)
  87.  
  88.             move.l    d0,a0
  89.             move.l    #IOSTD_SIZE,d0
  90.             CALL    CreateIORequest
  91.             move.l    d0,MyIORequest(a4)
  92.             beq    Error2
  93.  
  94.             lea    InputName(pc),a0
  95.             moveq.l    #0,d0
  96.             move.l    MyIORequest(a4),a1
  97.             moveq.l    #0,d1
  98.             CALL    OpenDevice
  99.             tst.l    d0
  100.             bne    Error2
  101.  
  102.             lea    IconName(pc),a1
  103.             moveq.l    #33,d0
  104.             CALL    OpenLibrary
  105.             move.l    d0,IconBase(a4)
  106.             beq    Error2
  107.  
  108.             move.l    ThisTask(a6),a1
  109.             move.l    a1,OwnTask(a4)
  110.             tst.l    pr_CLI(a1)
  111.             bne    CliStart
  112.             lea    pr_MsgPort(a1),a2
  113.             move.l    a2,a0
  114.             CALL    WaitPort
  115.             move.l    a2,a0
  116.             CALL    GetMsg
  117.             move.l    d0,WBMessage(a4)
  118.             move.l    d0,a3
  119.         
  120.             move.l    sm_ArgList(a3),d7
  121.             beq    DisableSave
  122.             move.l    d7,a0
  123.             move.l    wa_Lock(a0),d1
  124.             move.l    DosBase(a4),a6
  125.             CALL    CurrentDir
  126.  
  127.             move.l    IconBase(a4),a6
  128.             move.l    d7,a0
  129.             move.l    wa_Name(a0),a0
  130.             CALL    GetDiskObject
  131.             move.l    d0,DObject(a4)
  132.             beq    Error2
  133.  
  134.             lea    WBTemplate(pc),a3
  135.  
  136.             move.l    d0,a0
  137.             move.l    do_ToolTypes(a0),a0
  138.             
  139. GetEmLoop        tst.l    (a3)
  140.             beq.s    FreeDobj
  141.             move.l    TemplateText(a3),a1
  142.             beq.s    FreeDobj
  143.             move.l    a0,-(sp)
  144.             CALL    FindToolType
  145.             move.l    (sp)+,a0
  146.             sub.l    a2,a2
  147.             move.w    TemplateA4(a3),a2
  148.             add.l    a4,a2
  149.             move.l    d0,(a2)
  150.             add.l    #TemplateSize,a3
  151.             bra.s    GetEmLoop
  152.  
  153. FreeDobj        bsr    BuildPatterns
  154.  
  155.             bra.s    SkipReadArgs
  156.  
  157. CliStart        move.l    DosBase(a4),a6
  158.  
  159.             move.l    #Template,d1
  160.             lea    TemplateArray(a4),a0
  161.             move.l    a0,d2
  162.             moveq.l    #0,d3
  163.             CALL    ReadArgs    ;Get options
  164.             tst.l    d0
  165.             beq    Error2
  166.             move.l    d0,Args(a4)
  167.     
  168.             bsr    BuildPatterns
  169.  
  170. DisableSave        move.l    #1,TempSave(a4)
  171.  
  172. SkipReadArgs        move.l    $04,a6
  173.             lea    GraphicsName(pc),a1
  174.             moveq.l    #36,d0
  175.             CALL    OpenLibrary
  176.             move.l    d0,GraphicsBase(a4)
  177.             beq    Error2
  178.  
  179.             tst.l    TempHADJ(a4)
  180.             beq    GotIt1
  181.             move.l    TempHADJ(a4),a0
  182.             bsr    GetNexta0
  183.             clr.l    TempHADJ(a4)
  184.             cmp.b    #"l",d0
  185.             beq.s    GotIt1
  186.             add.l    #1,TempHADJ(a4)
  187.             cmp.b    #"r",d0
  188.             beq.s    GotIt1
  189.             add.l    #1,TempHADJ(a4)
  190.             cmp.b    #"c",d0
  191.             beq.s    GotIt1
  192.             add.l    #1,TempHADJ(a4)
  193.  
  194. GotIt1            tst.l    TempVADJ(a4)
  195.             beq    GotIt2
  196.             move.l    TempVADJ(a4),a0
  197.             bsr    GetNexta0
  198.             clr.l    TempVADJ(a4)
  199.             cmp.b    #"t",d0
  200.             beq.s    GotIt2
  201.             add.l    #1,TempVADJ(a4)
  202.             cmp.b    #"b",d0
  203.             beq.s    GotIt2
  204.             add.l    #1,TempVADJ(a4)
  205.             cmp.b    #"c",d0
  206.             beq.s    GotIt2
  207.             add.l    #1,TempVADJ(a4)
  208.  
  209. GotIt2            tst.l    TempAction(a4)
  210.             beq    GotIt3
  211.             move.l    TempAction(a4),a0
  212.             bsr    GetNexta0
  213.             clr.l    TempAction(a4)
  214.             cmp.b    #"h",d0
  215.             beq.s    GotIt3
  216.             add.l    #1,TempAction(a4)
  217.             cmp.b    #"a",d0
  218.             beq.s    GotIt3
  219.             add.l    #1,TempAction(a4)
  220.  
  221. GotIt3            tst.l    TempCXPRI(a4)
  222.             beq.s    GotIt3_1
  223.             move.l    TempCXPRI(a4),a0
  224.             bsr    GetNexta0
  225.             bsr    GetInteger
  226.             move.l    d0,TempCXPRI(a4)
  227.             move.b    d0,MyPri
  228.  
  229. GotIt3_1        tst.l    TempDelay(a4)
  230.             beq.s    GotIt4
  231.             move.l    TempDelay(a4),a0
  232.             bsr    GetNexta0
  233.             bsr    GetInteger
  234.             tst.l    d0
  235.             bmi.s    GotIt4
  236.             cmp.l    #100,d0
  237.             bgt.s    GotIt4
  238.             move.l    d0,TempDelay(a4)
  239.  
  240. GotIt4            move.l    $04,a6
  241.             CALL    CreateMsgPort
  242.             move.l    d0,BrokerPort
  243.             move.l    d0,MyPort(a4)
  244.             move.l    d0,a0
  245.             move.b    MP_SIGBIT(a0),d0
  246.             move.l    SignalMask(a4),d1    ;Enter signal into
  247.             bset    d0,d1            ;mask for waiting
  248.             move.l    d1,SignalMask(a4)
  249.  
  250.             move.l    CommBase(a4),a6
  251.             lea    MyNewBroker(pc),a0
  252.             clr.l    d0
  253.             CALL    CxBroker
  254.             tst.l    d0
  255.             beq    QuitPrg
  256.             move.l    d0,Broker(a4)
  257.  
  258.             move.l    d0,a0
  259.             moveq.l    #1,d0
  260.             CALL    ActivateCxObj
  261.             
  262.             ;Install Handler for Mouse_Button_test
  263.  
  264.             move.l    #CX_CUSTOM,d0
  265.             lea    TestButton(pc),a0    ;My Program
  266.             move.l    #MyCustomID,a1        ;ID
  267.             CALL    CreateCxObj
  268.             move.l    d0,a1
  269.             tst.l    d0
  270.             beq    QuitPrg
  271.             move.l    Broker(a4),a0
  272.             CALL    AttachCxObj
  273.  
  274.             bsr    InstallHotKey
  275.  
  276.             move.l    $04,a6
  277.                     moveq   #-1,d0            ;A Signal for telling
  278.                     jsr     _LVOAllocSignal(a6)    ;our task that sth happened
  279.                     tst.l   d0
  280.                     bmi     Error2
  281.                     move.l  d0,Signal(a4)
  282.             move.l    SignalMask(a4),d1
  283.                     bset    d0,d1
  284.                     move.l    d1,SignalMask(a4)
  285.  
  286.             lea    MyInterrupt(a4),a1
  287.             move.l    #Interrupt3,IS_CODE(a1)
  288.             clr.l    IS_DATA(a1)
  289.             move.b    #NT_INTERRUPT,LN_TYPE(a1)
  290.             move.b    #0,LN_PRI(a1)
  291.             move.l    #HandlerName,LN_NAME(a1)
  292.             move.l    #5,d0            ;INTB_VERTB
  293.             jsr    _LVOAddIntServer(a6)
  294.  
  295.             tst.l    TempCXPOPUP(a4)
  296.             beq.s    WaitOn
  297.             bsr    OpenGUI
  298.  
  299. WaitOn            tst.w    QuitMe(a4)
  300.             bne    QuitPrg
  301.             move.l    $04,a6
  302.             move.l    SignalMask(a4),d0    ;Wait for Port and Break
  303.             CALL    Wait
  304.             btst    #SIGBREAKB_CTRL_C,d0    ;This means quit
  305.             bne    QuitPrg
  306.             move.l    Signal(a4),d1
  307.             btst    d1,d0            ;Signal from Interrupt?
  308.             beq.s    TryNextMsg
  309.  
  310.             tst.w    DisableHW(a4)
  311.             bne.s    TryNextMsg        ;Do nothing
  312.  
  313.             tst.l    TempDelay(a4)
  314.             beq.s    NoDelay
  315.             tst.w    GUIOpened(a4)
  316.             bne    NoDelay    ;Not with GUI opened
  317.  
  318. ReDelay            clr.w    DelayDo(a4)
  319.             move.l    DosBase(a4),a6
  320.             move.l    TempDelay(a4),d1    ;Microseconds
  321.             CALL    Delay
  322.             tst.w    DelayDo(a4)    ;Something happened again
  323.             bne.s    ReDelay        ;so wait till things calmed down
  324.             move.l    $04,a6
  325.  
  326. NoDelay            tst.w    ButtonPressed(a4)
  327.             bne.s    TryNextMsg        ;Omit that stuff for now
  328.             bclr    #SignalButton,What(a4)    ;We will get a signal when
  329.                             ;the button will be released
  330.  
  331.             cmp.l    #1,TempAction(a4)    ;Only do it on Hotkey
  332.             beq.s    TryNextMsg
  333.  
  334. OnHotKey        btst    #SignalWindow,What(a4)
  335.             beq.s    NoWindowStuff
  336.             
  337.             bsr    DoYourJob
  338.             bclr    #SignalWindow,What(a4)
  339.  
  340. NoWindowStuff        btst    #SignalScreen,What(a4)
  341.             beq.s    TryNextMsg
  342.             bsr    AdjustScreen
  343.             bclr    #SignalScreen,What(a4)
  344.  
  345. TryNextMsg        move.l    MyPort(a4),a0        ;Get the message awaiting
  346.             CALL    GetMsg
  347.             tst.l    d0
  348.             bne.s    GotMsg
  349.             bsr    CheckGUI
  350.             bra    WaitOn
  351.  
  352. GotMsg            move.l    d0,a3
  353.             move.l    d0,a0
  354.             move.l    CommBase(a4),a6
  355.             CALL    CxMsgType
  356.             move.l    d0,d6
  357.             move.l    a3,a0
  358.             CALL    CxMsgID
  359.             move.l    d0,d5
  360.             move.l    a3,a1
  361.             move.l    $04,a6
  362.             CALL    ReplyMsg
  363.             cmp.w    #CXM_IEVENT,d6
  364.             bne.s    OtherCommand
  365.             cmp.l    #MyActionID,d5
  366.             beq.s    NotGUIKey
  367.             bsr    OpenGUI
  368.             bra.s    OtherCommand
  369. NotGUIKey        bset    #SignalWindow,What(a4)
  370.             bset    #SignalScreen,What(a4)
  371.             bra    OnHotKey
  372.  
  373. OtherCommand        cmp.w    #CXM_COMMAND,d6
  374.             bne    WaitOn
  375.  
  376.             cmp.w    #CXCMD_DISABLE,d5
  377.             bne.s    OtherI1
  378.             move.w    #1,DisableHW(a4)
  379.  
  380. OtherI1            cmp.w    #CXCMD_ENABLE,d5
  381.             bne.s    OtherI2
  382.             clr.w    DisableHW(a4)
  383.  
  384. OtherI2            cmp.w    #CXCMD_UNIQUE,d5
  385.             beq.s    OtherII
  386.             cmp.w    #CXCMD_APPEAR,d5
  387.             bne.s    OtherI3
  388. OtherII            bsr    OpenGUI
  389.  
  390. OtherI3            cmp.w    #CXCMD_DISAPPEAR,d5
  391.             bne.s    OtherI4
  392.             bsr    CloseGUI
  393.  
  394. OtherI4            cmp.w    #CXCMD_KILL,d5
  395.             beq    QuitPrg
  396.  
  397.             bra    TryNextMsg
  398.  
  399. Error2            lea    Text1(pc),a0        ;Seems there is an error
  400.             bsr    OpenRequester        ;in the given arguments
  401.             bra.s    QuitPrg
  402.  
  403. EndeRaus2        lea    Text2(pc),a0        ;Wrong Kickstart
  404.             bsr    PrintText
  405.  
  406. QuitPrg            move.l    RememberStack,a7
  407.             bsr    CloseGUI
  408.             move.l    $04,a6    
  409.             move.l    #5,d0
  410.             lea    MyInterrupt(a4),a1
  411.             tst.l    IS_CODE(a1)
  412.             beq.s    NoHandler
  413.             CALL    RemIntServer        ;Remove the Interrupt-Server
  414.  
  415. NoHandler        tst.l    MyIORequest(a4)
  416.             beq.s    NoDevIO
  417.             move.l    MyIORequest(a4),a1
  418.             CALL    CloseDevice
  419.             move.l    MyIORequest(a4),a0
  420.             CALL    DeleteIORequest    
  421. NoDevIO            tst.l    MouseMsgPort(a4)
  422.             beq.s    NoMouseMsg
  423.  
  424.             move.l    MouseMsgPort(a4),a0
  425.             bsr    CloseMsgPort
  426.  
  427. NoMouseMsg        move.l    IconBase(a4),a6
  428.             tst.l    DObject(a4)
  429.             beq.s    SkipFreeDobj
  430.             move.l    DObject(a4),a0
  431.             CALL    FreeDiskObject
  432.  
  433. SkipFreeDobj        move.l    $04,a6
  434.             move.l    Signal(a4),d0        ;Free the signal
  435.             beq.s    DontFreeS
  436.                     CALL    FreeSignal
  437.  
  438. DontFreeS        tst.l    Args(a4)
  439.             beq.s    HmmNoArgs
  440.             move.l    DosBase(a4),a6
  441.             move.l    Args(a4),d1
  442.             CALL    FreeArgs
  443.  
  444. HmmNoArgs        move.l    #Filter,d5
  445.             bsr    RemovePopKey
  446.             move.l    #Filter2,d5
  447.             bsr    RemovePopKey
  448.  
  449.             tst.l    Broker(a4)
  450.             beq.s    NoCX
  451.             move.l    CommBase(a4),a6
  452.             move.l    Broker(a4),a0
  453.             CALL    DeleteCxObjAll
  454.  
  455. NoCX            move.l    $04,a6
  456.             tst.l    MyPort(a4)
  457.             beq.s    NoPort
  458.             move.l    MyPort(a4),a0
  459.             bsr    CloseMsgPort
  460.  
  461. NoPort            move.l    IntBase(a4),d0        ;Close librarys
  462.             beq.s    ErrorX2
  463.             move.l    d0,a1
  464.             CALL    CloseLibrary
  465.  
  466. ErrorX2            move.l    GraphicsBase(a4),d0
  467.             beq.s    ErrorX1
  468.             move.l    d0,a1
  469.             CALL    CloseLibrary
  470.  
  471. ErrorX1            move.l    IconBase(a4),d0
  472.             beq.s    NoIconLib
  473.             move.l    d0,a1
  474.             CALL    CloseLibrary
  475.             
  476. NoIconLib        move.l    CommBase(a4),d0
  477.             beq.s    NoCommLib
  478.             move.l    d0,a1
  479.             CALL    CloseLibrary
  480.  
  481. NoCommLib        move.l    GadBase(a4),d0
  482.             beq.s    OnlyDOS
  483.             move.l    d0,a1
  484.             CALL    CloseLibrary
  485.  
  486. OnlyDOS            move.l    DosBase(a4),d0
  487.             beq.s    FreeOnly
  488.             move.l    d0,a1
  489.             CALL    CloseLibrary
  490.  
  491. FreeOnly        move.l    ScreenPatLen(a4),d0
  492.             beq.s    NoScreenPat
  493.             move.l    ScreenPattern(a4),a1
  494.             CALL    FreeMem
  495.  
  496. NoScreenPat        move.l    WindowPatLen(a4),d0
  497.             beq.s    NoWindowPat
  498.             move.l    WindowPattern(a4),a1
  499.             CALL    FreeMem
  500.  
  501. NoWindowPat        move.l    WBMessage(a4),d7
  502.             move.l    a4,a1
  503.             move.l    #AllocLength,d0
  504.             CALL    FreeMem            
  505.  
  506.             move.l    d7,a1
  507.             tst.l    d7
  508.             beq.s    EndeRaus
  509.             CALL    Forbid
  510.             CALL    ReplyMsg
  511.  
  512. EndeRaus        RLoad
  513.             moveq.l    #0,d0
  514.             rts
  515.  
  516. CloseMsgPort        move.l    a0,a3
  517. ClosePortRout        move.l    a3,a0
  518.             CALL    GetMsg
  519.             tst.l    d0
  520.             beq.s    NoMsgLeft
  521.             move.l    d0,a1
  522.             CALL    ReplyMsg
  523.             bra.s    ClosePortRout
  524. NoMsgLeft        move.l    a3,a0
  525.             CALL    DeleteMsgPort        ;and free it
  526.             rts
  527.  
  528.  
  529.             ;Subroutine to print a text to stdout
  530. PrintText        Push    d0-d4/a0-a1/a6
  531.             move.l    a0,a1
  532.             moveq.l    #0,d0
  533. TestLen            tst.b    (a1)+
  534.             beq.s    LaengeOk
  535.             addq    #1,d0
  536.             bra.s    TestLen
  537. LaengeOk        move.l    $04,a6
  538.             lea    DosName(pc),a1
  539.             moveq.l    #0,d0
  540.             CALL    OpenLibrary    
  541.             move.l    d0,DosBase(a4)
  542.             beq    SkipWrite
  543.             move.l    d0,a6
  544.             move.l    a0,d2
  545.             move.l    d0,d3
  546.             CALL    Output
  547.             move.l    d0,d1
  548.             beq.s    SkipWrite
  549.             CALL    Write
  550. SkipWrite        Pull    d0-d4/a0-a1/a6
  551.             rts
  552.  
  553.             ;MainPart: does the scrolling if necessary
  554. DoYourJob        RSave
  555.             move.l    IntBase(a4),a6
  556.             clr.l    d0
  557.             CALL    LockIBase
  558.             move.l    d0,IBaseLock(a4)
  559.  
  560.             move.l    ib_ActiveWindow(a6),d0
  561.             beq    LeaveIt
  562.             move.l    d0,a5
  563.  
  564.             move.l    wd_WScreen(a5),d0
  565.             beq    LeaveIt
  566.             move.l    d0,a3
  567.             
  568.             move.l    DosBase(a4),a6
  569.  
  570.             tst.l    TempRestrict(a4)
  571.             bne.s    NoMatter2
  572.  
  573.             tst.b    ScreenPatternMem(a4)
  574.             beq.s    NoMatter2
  575.             move.l    ScreenPattern(a4),d1
  576.             move.l    sc_DefaultTitle(a3),d2
  577.             CALL    MatchPatternNoCase
  578.             beq    LeaveIt
  579.  
  580. NoMatter2        tst.b    WindowPatternMem(a4)
  581.             beq.s    NoMatter3
  582.             move.l    WindowPattern(a4),d1
  583.             move.l    wd_Title(a5),d2
  584.             CALL    MatchPatternNoCase
  585.             beq    LeaveIt
  586.  
  587. NoMatter3        bsr    RememberWindow
  588.  
  589.             move.l    GraphicsBase(a4),a6    ;Get the visible size
  590.             lea    sc_ViewPort(a3),a0    ;of the screen to
  591.             move.l    vp_ColorMap(a0),a0
  592.  
  593.             ;Taglist on Stack (because it gets changed)
  594.             move.l    #TAG_DONE,-(sp)
  595.             clr.l    -(sp)
  596.             move.l    #VTAG_VIEWPORTEXTRA_GET,-(sp)
  597.             move.l    a7,a1
  598.  
  599.             CALL    VideoControl
  600.             tst.l    d0
  601.             bne    LeaveIt
  602.             movem.l    (sp)+,d0-d2    ;Get Taglist from Stack
  603.             move.l    d1,a0        ;In the middle is our data
  604.             lea    vpe_DisplayClip(a0),a0 ;extra
  605.  
  606.             move.w    ra_MaxX(a0),d0
  607.             sub.w    ra_MinX(a0),d0
  608.             addq    #1,d0
  609.             move.w    d0,VisualX(a4)
  610.             move.w    sc_LeftEdge(a3),d0
  611.             sub.w    ra_MinX(a0),d0
  612.             move.w    d0,PositionX(a4)
  613.  
  614.             move.w    ra_MaxY(a0),d0
  615.             sub.w    ra_MinY(a0),d0
  616.             addq    #1,d0
  617.             move.w    d0,VisualY(a4)
  618.             move.w    sc_TopEdge(a3),d0
  619.             sub.w    ra_MinY(a0),d0
  620.             move.w    d0,PositionY(a4)
  621.  
  622.             move.l    IntBase(a4),a6
  623.             tst.l    TempSFront(a4)        ;do we want screentofront?
  624.             beq.s    NoFront
  625.             cmp.l    ib_FirstScreen(a6),a3
  626.             beq.s    NoFront            ;Not necessary (optimize!)
  627.  
  628.             bsr    UnlockIt
  629.             move.l    a3,a0
  630.             CALL    ScreenToFront
  631.             bset    #SignalScreen,What(a4)    ;ScreenChange!
  632.             bsr    RelockAndTest
  633.  
  634. NoFront            move.l    wd_Flags(a5),d0
  635.             and.l    #WFLG_BACKDROP,d0
  636.             bne    LeaveIt            ;Not with backdrops!
  637.  
  638.             tst.l    TempWFront(a4)        ;do we WindowToFront() ?
  639.             beq.s    NoFront2
  640.             
  641.             bsr    UnlockIt
  642.             move.l    a5,a0
  643.             CALL    WindowToFront
  644.             bsr    RelockAndTest
  645.  
  646. NoFront2        tst.l    TempMove(a4)
  647.             beq    LeaveIt
  648.  
  649.             move.l    wd_WScreen(a5),a0    
  650.             ;moveq.l    #0,d7
  651.             ;moveq.l    #0,d6
  652.             ;moveq.l    #0,d0
  653.             ;moveq.l    #0,d2
  654.  
  655.             ;Calculate how the window is located towards the view
  656.             
  657.             move.w    wd_LeftEdge(a5),d0
  658.             add.w    PositionX(a4),d0
  659.             move.w    wd_LeftEdge(a5),d1
  660.             add.w    wd_Width(a5),d1
  661.             move.w    PositionX(a4),d7
  662.             sub.w    VisualX(a4),d7
  663.             add.w    d7,d1
  664.             move.w    wd_TopEdge(a5),d2
  665.             add.w    PositionY(a4),d2
  666.             move.w    wd_TopEdge(a5),d3
  667.             add.w    wd_Height(a5),d3
  668.             move.w    PositionY(a4),d7
  669.             sub.w    VisualY(a4),d7
  670.             add.w    d7,d3
  671.             
  672.             ;d0: Pixels out left border (out = negative)
  673.             ;d1: Pixels out right border (out = positive)
  674.             ;d2: Pixels out top border (out = negative)
  675.             ;d3: Pixels out bottom border (out = positive)
  676.             ;For scrolling all these Values have to be negated
  677.  
  678.             ;Horizontal Section
  679.             
  680.  
  681.             cmp.l    #2,TempAction(a4)    ;Always
  682.             beq.s    HScrollNeeded
  683.  
  684.             tst.w    d0
  685.             bmi.s    HScrollNeeded
  686.             tst.w    d1
  687.             bmi.s    NoHScrollNeeded
  688.  
  689. HScrollNeeded        cmp.l    #2,TempHADJ(a4)
  690.             bne.s    HNoCenter
  691.  
  692.             ;Center Window
  693.  
  694.             move.w    d0,d4
  695.             add.w    d1,d4
  696.             asr.w    #1,d4    ;CenterScrollValue
  697.             bra.s    HDone
  698.  
  699. HNoCenter        cmp.l    #1,TempHADJ(a4)
  700.             bne.s    HNoRight
  701.  
  702.             ;Adjust Window to Right Border
  703.  
  704.             move.w    d1,d4
  705.             bra.s    HDone
  706.  
  707. HNoRight        tst.l    TempHADJ(a4)
  708.             bne.s    HNoLeft
  709.  
  710.             ;Adjust Window to Left Border
  711.  
  712.             move.w    d0,d4
  713.             bra.s    HDone
  714.  
  715. HNoLeft            ;Optimized Adjustment
  716.             ;When coming here it is shure that at least ONE scroll
  717.             ;is necessary!!!
  718.             tst.w    d0
  719.             beq.s    THScroll
  720.             bpl.s    NoHScroll1
  721.             move.w    d0,d4
  722.  
  723. THScroll        tst.w    d1
  724.             bmi.s    HDone        ;Has to be for normal windows
  725.             ;This means the window leaps out BOTH borders!
  726.             ;Then we do NOTHING
  727.             bra.s    NoHScrollNeeded
  728.  
  729. NoHScroll1        move.w    d1,d4
  730.             bra.s    HDone
  731.  
  732. NoHScrollNeeded        moveq.l    #0,d4
  733.  
  734. HDone            ext.l    d4
  735.             neg.l    d4
  736.  
  737.             ;The Vertical section works almost equally
  738.  
  739.             cmp.l    #2,TempAction(a4)    ;Always
  740.             beq.s    VScrollNeeded
  741.  
  742.             tst.w    d2
  743.             bmi.s    VScrollNeeded
  744.             tst.w    d3
  745.             bmi.s    NoVScrollNeeded
  746.  
  747. VScrollNeeded        cmp.l    #2,TempVADJ(a4)
  748.             bne.s    VNoCenter
  749.  
  750.             ;Center Window
  751.  
  752.             move.w    d2,d5
  753.             add.w    d3,d5
  754.             asr.w    #1,d5    ;CenterScrollValue
  755.             bra.s    VDone
  756.  
  757. VNoCenter        cmp.l    #1,TempVADJ(a4)
  758.             bne.s    VNoBottom
  759.  
  760.             ;Adjust Window to Bottom Border
  761.  
  762.             move.w    d3,d5
  763.             bra.s    VDone
  764.  
  765. VNoBottom        tst.l    TempVADJ(a4)
  766.             bne.s    VNoTop
  767.  
  768.             ;Adjust Window to Top Border
  769.  
  770.             move.w    d2,d5
  771.             bra.s    VDone
  772.  
  773. VNoTop            ;Optimized Adjustment
  774.             ;When coming here it is shure that at least ONE scroll
  775.             ;is necessary!!!
  776.             tst.w    d2
  777.             beq    TVScroll
  778.             bpl.s    NoVScroll1
  779.             move.w    d2,d5
  780.  
  781. TVScroll        tst.w    d3
  782.             bmi.s    VDone        ;Has to be for normal windows
  783.             ;This means the window leaps out BOTH borders!
  784.             ;Then we do NOTHING
  785.             bra.s    NoVScrollNeeded
  786.  
  787. NoVScroll1        move.w    d3,d5
  788.             bra.s    VDone
  789.  
  790. NoVScrollNeeded        moveq.l    #0,d5
  791.  
  792. VDone            ext.l    d5
  793.             neg.l    d5
  794.  
  795.             move.l    d4,d0
  796.             move.l    d5,d1
  797.  
  798.             move.w    PositionY(a4),d4    ;Prevent dragging a screen
  799.             neg.w    d4            ;further down than at Pos 0
  800.             sub.w    d1,d4
  801.             bpl.s    NoOutRange
  802.             move.w    PositionY(a4),d1
  803.             neg.w    d1
  804.  
  805. NoOutRange        move.w    sc_TopEdge(a0),d5
  806.             move.w    sc_LeftEdge(a0),d6
  807.  
  808.             bsr    UnlockIt
  809.             Push    a0-a1/d0-d4
  810.             CALL    MoveScreen
  811.             clr.l    d0
  812.             CALL    LockIBase        ;relock - no test window!
  813.             move.l    d0,IBaseLock(a4)
  814.             Pull    a0-a1/d0-d4
  815.  
  816.             sub.w    sc_TopEdge(a0),d5    ;Find out how far the
  817.             sub.w    sc_LeftEdge(a0),d6    ;screen really moves
  818.             move.l    d6,d0
  819.             move.l    d5,d1
  820.             neg.l    d0
  821.             neg.l    d1
  822.  
  823.             tst.l    TempMoveMouse(a4)
  824.             beq.s    LeaveIt
  825.  
  826.             ;If a window becomes active without clicking, the Mouse
  827.             ;can be out of range, and moving it would scroll the
  828.             ;Screen back, so we check this here and disable movement
  829.             ;if "dangerous"
  830.             move.w    sc_MouseX(a0),d2
  831.             add.w    sc_LeftEdge(a0),d2
  832.             add.w    d0,d2            ;Movement in X
  833.             bmi.s    ClearXMovement
  834.             cmp.w    VisualX(a4),d2
  835.             bcs.s    LeaveXMovement
  836. ClearXMovement        moveq.l    #0,d0
  837. LeaveXMovement        move.w    sc_MouseY(a0),d2
  838.             add.w    sc_TopEdge(a0),d2
  839.             add.w    d1,d2            ;Movement in Y
  840.             bmi.s    ClearYMovement
  841.             cmp.w    VisualY(a4),d2
  842.             bcs.s    LeaveYMoveMent
  843. ClearYMovement        moveq.l    #0,d1
  844. LeaveYMoveMent        bsr    UnlockIt
  845.             tst.w    d0
  846.             bne.s    SetIt
  847.             tst.w    d1
  848.             beq.s    LeaveItReal
  849. SetIt            bsr    SetPointer
  850. LeaveItReal        RLoad
  851.             rts
  852.  
  853. LeaveIt            move.l    IntBase(a4),a6
  854.             move.l    IBaseLock(a4),a0
  855.             CALL    UnlockIBase
  856.             bra.s    LeaveItReal
  857.  
  858. UnlockIt        Push    a0-a1/d0-d1
  859.             move.l    IBaseLock(a4),a0
  860.             CALL    UnlockIBase
  861.             Pull    a0-a1/d0-d1
  862.             rts
  863.  
  864. RelockAndTest        Push    a0-a1/d0-d1
  865.             move.l    IntBase(a4),a6
  866.             clr.l    d0
  867.             CALL    LockIBase
  868.             move.l    d0,IBaseLock(a4)
  869.  
  870.             move.l    ib_ActiveWindow(a6),d0
  871.             beq.s    TestFailed
  872.             cmp.l    d0,a5
  873.             bne.s    TestFailed
  874.  
  875.             move.l    wd_WScreen(a5),d0
  876.             beq.s    TestFailed
  877.             cmp.l    d0,a3
  878.             bne.s    TestFailed
  879.             Pull    a0-a1/d0-d1
  880.             rts
  881.  
  882. TestFailed        Pull    a0-a1/d0-d1
  883.             tst.l    (sp)+    ;rts
  884.             ;Window or Screen changed while we had Ibase unlocked
  885.             ;=> leave
  886.             bra.s    LeaveIt
  887.  
  888. AdjustScreen        RSave                
  889.             move.l    IntBase(a4),a6
  890.             clr.l    d0
  891.             CALL    LockIBase
  892.             move.l    d0,d7
  893.             move.l    ib_FirstScreen(a6),d0
  894.             beq    SkipActive
  895.  
  896.             move.l    d0,a3
  897.             tst.b    ScreenPatternMem(a4)
  898.             beq.s    NoMatter5
  899.             move.l    ScreenPattern(a4),d1
  900.             move.l    sc_DefaultTitle(a3),d2
  901.             move.l    DosBase(a4),a6
  902.             CALL    MatchPatternNoCase
  903.             bne.s    NoMatter5
  904.  
  905.             tst.l    TempRestrict(a4)
  906.             bne.s    Skip_NoPub2
  907.  
  908.             bra    SkipActive
  909.  
  910. NoMatter5        tst.l    TempPDef(a4)    ;Enter FirstScreen as Default
  911.                         ;PublicScreen ?
  912.             beq.s    Skip_NoPub2
  913.             move.l    d7,a0
  914.             move.l    IntBase(a4),a6
  915.             CALL    UnlockIBase
  916.  
  917.             CALL    LockPubScreenList
  918.  
  919. CarryListOn        move.l    d0,a0
  920.             cmp.l    psn_Screen(a0),a3
  921.             beq.s    ScreenFound
  922.             move.l    LN_SUCC(a0),d0
  923.             bne.s    CarryListOn
  924.             CALL    UnlockPubScreenList
  925.             bra.s    Skip_NoPub
  926.  
  927. ScreenFound        move.l    LN_NAME(a0),d5
  928.             CALL    UnlockPubScreenList
  929.  
  930.             move.l    d5,a0
  931.             CALL    SetDefaultPubScreen
  932.  
  933. Skip_NoPub        clr.l    d0
  934.             CALL    LockIBase
  935.             move.l    d0,d7
  936.             move.l    ib_FirstScreen(a6),d0
  937.             beq    SkipActive
  938.             move.l    d0,a3
  939.  
  940. Skip_NoPub2        move.l    a3,a0
  941.             tst.l    TempRemWin(a4)    ;Activate a Window on the new
  942.                         ;Screen?
  943.             beq.s    SkipActive
  944.             bsr    GetScreenWindow
  945.             tst.l    d0
  946.             bne.s    FoundActive
  947.  
  948.             move.l    sc_FirstWindow(a0),d0    ;Take Firstwindow if none
  949.             beq.s    SkipActive        ;known
  950.  
  951. FoundActive        move.l    d0,a5
  952.             tst.b    WindowPatternMem(a4)
  953.             beq.s    NoMatter4
  954.             move.l    WindowPattern(a4),d1
  955.             move.l    wd_Title(a5),d2
  956.             move.l    DosBase(a4),a6
  957.             CALL    MatchPatternNoCase
  958.             beq    SkipActive
  959. NoMatter4        move.l    IntBase(a4),a6
  960.             move.l    d7,a0
  961.             CALL    UnlockIBase
  962.             move.l    a5,a0
  963.             CALL    ActivateWindow
  964. SkipOut            RLoad    
  965.             rts
  966. SkipActive        move.l    IntBase(a4),a6
  967.             move.l    d7,a0
  968.             CALL    UnlockIBase
  969.             bra.s    SkipOut
  970.  
  971.  
  972.         ;a0=Screen         Back:d0=Window
  973. GetScreenWindow        Push    a1/d1
  974.             lea    ScreenMem(a4),a1
  975.             move.w    #MaxScreens-1,d1
  976. ScreenFindLoop        cmp.l    (a1),a0
  977.             beq.s    FoundScreen
  978.             lea    8(a1),a1
  979.             dbf    d1,ScreenFindLoop
  980. FoundScreen        move.l    4(a1),d0
  981.             bsr    TestWindowOnScreen
  982.             Pull    a1/d1
  983.             rts
  984.  
  985.         ;a3=Screen a5=Window
  986. RememberWindow        Push    a0-a3/a6/d1
  987.             move.l    IntBase(a4),a6
  988.             lea    ScreenMem(a4),a1
  989.             move.w    #MaxScreens-1,d1
  990. ScreenFindLoop2        tst.l    (a1)
  991.             beq.s    FoundEmpty
  992.             cmp.l    (a1),a3
  993.             beq.s    FoundEmpty
  994.             move.l    (a1),a2
  995.             move.l    ib_FirstScreen(a6),d0
  996.             beq.s    IgnoreOver    ;No FirstScreen!
  997. CheckAllScreens        move.l    d0,a0
  998.             cmp.l    a0,a2
  999.             beq    ScreenValid
  1000.             move.l    sc_NextScreen(a0),d0
  1001.             bne.s    CheckAllScreens
  1002.             bra.s    FoundEmpty    ;because Entry is invalid
  1003.  
  1004. ScreenValid        lea    8(a1),a1
  1005.             dbf    d1,ScreenFindLoop2
  1006.             ;Reaching this Point our List is full of valid
  1007.             ;Screens - not the best thing, but we simply ignore...
  1008.             bra.s    IgnoreOver
  1009. FoundEmpty        move.l    a3,(a1)
  1010.             move.l    a5,4(a1)
  1011. IgnoreOver        Pull    a0-a3/a6/d1
  1012.             rts
  1013.  
  1014.         ;d0=Window , a0=Screen    =Back: d0=0 no window
  1015. TestWindowOnScreen    tst.l    d0
  1016.             beq.s    NotWindow
  1017.             move.l    sc_FirstWindow(a0),d1
  1018.             beq.s    NotWindow
  1019. WindowListOn        move.l    d1,a1
  1020.             cmp.l    d0,a1
  1021.             beq.s    WindowIsOK
  1022.             move.l    wd_NextWindow(a1),d1
  1023.             bne.s    WindowListOn
  1024. WindowIsOK        move.l    a1,d0
  1025.             rts
  1026. NotWindow        clr.l    d0
  1027.             rts
  1028.  
  1029.  
  1030. Interrupt3        Push    d1-d4/a0-a1/a3/a4/a6
  1031.             move.l    RememberA4,a4
  1032.             move.l    IntBase(a4),a3
  1033.             move.l    Active(a4),d0
  1034.             move.l    ib_ActiveWindow(a3),a0
  1035.             cmp.l    a0,d0            ;New ActiveWindow?
  1036.             beq.s    CheckSize
  1037.             move.l    a0,Active(a4)
  1038.             move.l    a0,d0
  1039.             beq.s    DoScreen        ;Changed to NoWindow!
  1040. ChangedPosOrSize    move.l    wd_LeftEdge(a0),WindPosRem(a4)
  1041.             move.l    wd_Width(a0),WindSizeRem(a4)
  1042.  
  1043.             bsr    SignalMyself
  1044.  
  1045.             bset    #SignalWindow,What(a4)
  1046.             
  1047.             bra.s    DoScreen
  1048.  
  1049. CheckSize        move.l    wd_LeftEdge(a0),d0    ;A Check on .l is faster
  1050.             cmp.l    WindPosRem(a4),d0    ;because I only wanna know
  1051.             bne.s    ChangedPosOrSize    ;if Position or Size changed
  1052.             move.l    wd_Width(a0),d0        ;and not how
  1053.             cmp.l    WindSizeRem(a4),d0
  1054.             bne.s    ChangedPosOrSize
  1055.             
  1056. DoScreen        move.l    FirstSc(a4),d0
  1057.             cmp.l    ib_FirstScreen(a3),d0        ;New FirstScreen?
  1058.             beq.s    DoNothing
  1059.             move.l    ib_FirstScreen(a3),FirstSc(a4)
  1060.  
  1061.             bsr    SignalMyself
  1062.  
  1063.             bset    #SignalScreen,What(a4)
  1064.  
  1065. DoNothing        Pull    d1-d4/a0-a1/a3/a4/a6
  1066.             moveq.l    #0,d0
  1067.             rts
  1068.  
  1069. SignalMyself        move.l  $04,a6
  1070.             move.w    #1,DelayDo(a4)
  1071.             move.l  OwnTask(a4),a1
  1072.             move.l  Signal(a4),d1        ;send a signal to move Screen
  1073.             moveq.l    #0,d0
  1074.             bset    d1,d0
  1075.             jmp    _LVOSignal(a6)
  1076.  
  1077. OpenGUI            RSave
  1078.             tst.w    GUIOpened(a4)
  1079.             bne    OpenNoGUI
  1080.             move.l    IntBase(a4),a6
  1081.             sub.l    a0,a0
  1082.             CALL    LockPubScreen
  1083.             move.l    d0,PublicScreen(a4)
  1084.             move.l    d0,StorePublicScreen
  1085.  
  1086.             move.l    d0,a0
  1087.             lea    sc_RastPort(a0),a1
  1088.             move.l    a1,PublicRastport(a4)
  1089.             lea    TagListDone(pc),a1
  1090.             move.l    GadBase(a4),a6
  1091.             CALL    GetVisualInfoA
  1092.             move.l    d0,MyVisual(a4)
  1093.             lea    MyNewGadget(a4),a3
  1094.             move.l    d0,gng_VisualInfo(a3)
  1095.  
  1096.             lea    GadgetList(a4),a0
  1097.             CALL    CreateContext
  1098.             move.l    d0,Gadget0(a4)
  1099.  
  1100.             move.l    GraphicsBase(a4),a6
  1101.             move.l    PublicRastport(a4),a1
  1102.             lea    GUI_Text5(pc),a0
  1103.             moveq.l    #GUI_Text6-GUI_Text5-1,d0
  1104.             CALL    TextLength
  1105.             add.w    #40,d0        ;CheckBox
  1106.             ;lsr.w    #1,d0
  1107.             move.w    d0,RemLen(a4)
  1108.  
  1109.             moveq.l    #1,d0
  1110.             add.w    RemLen(a4),d0
  1111.             mulu    #NumberOfCols,d0
  1112.             move.l    d0,StoreInnerWidth
  1113.  
  1114.             move.l    PublicScreen(a4),a0
  1115.             moveq.l    #6,d0
  1116.             add.b    sc_WBorLeft(a0),d0
  1117.             move.w    d0,RemLeft(a4)
  1118.  
  1119.             move.l    sc_Font(a0),a1
  1120.             move.l    a1,gng_TextAttr(a3)
  1121.             moveq.l    #1,d0
  1122.             add.b    sc_WBorTop(a0),d0    ;Base (Top)
  1123.             move.w    d0,RemTop(a4)
  1124.  
  1125.             move.w    ta_YSize(a1),d6
  1126.             add.w    #4,d6            ;Height of One Line
  1127.             move.w    d6,RemHeight(a4)
  1128.  
  1129.             add.w    #2,d6
  1130.             mulu    #NumberOfLines,d6
  1131.             add.w    #8,d6
  1132.             move.l    d6,StoreInnerHeight
  1133.  
  1134.             move.l    Gadget0(a4),d7
  1135.  
  1136.             bsr    DoAllGadgets
  1137.  
  1138.             move.l    d7,LastGadget(a4)
  1139.  
  1140.             sub.l    a0,a0
  1141.             lea    WindowTagList(pc),a1
  1142.             move.l    IntBase(a4),a6
  1143.             CALL    OpenWindowTagList
  1144.             move.l    d0,MyWindow(a4)
  1145.             beq    FailWindow
  1146.  
  1147.             move.l    d0,a0
  1148.             bsr    EnterSignal
  1149.             ;move.l    d0,a0
  1150.             move.l    GadgetList(a4),a1
  1151.             moveq.l    #-1,d0
  1152.             moveq.l    #-1,d1
  1153.             sub.l    a2,a2
  1154.             CALL    AddGList
  1155.  
  1156.             move.l    GadgetList(a4),a0
  1157.             move.l    MyWindow(a4),a1
  1158.             moveq.l    #-1,d0
  1159.             sub.l    a2,a2
  1160.             CALL    RefreshGList
  1161.             
  1162.             move.l    GadBase(a4),a6
  1163.             move.l    MyWindow(a4),a0
  1164.             sub.l    a1,a1
  1165.             CALL    GT_RefreshWindow
  1166.  
  1167.             move.w    #1,GUIOpened(a4)
  1168.             RLoad
  1169.             rts
  1170. OpenNoGUI        move.l    IntBase(a4),a6
  1171.             move.l    MyWindow(a4),a0
  1172.             CALL    ActivateWindow
  1173.             RLoad
  1174.             rts
  1175.  
  1176.             rsreset
  1177. MyGadgetText        rs.l    1
  1178. MyGadgetList        rs.l    1
  1179. MyGadgetRowNr        rs.b    1
  1180. MyGadgetXPos        rs.b    1
  1181. MyGadgetWidth        rs.b    1
  1182. MyGadgetFlags        rs.b    1
  1183. MyGadgetStore        rs.w    1
  1184. MyGadgetKind        rs.w    1
  1185. MyGadgetSize        rs.w    1
  1186.             
  1187.             ;    gng_Flags      ,gng_Text ,CreateKind   ,CreateTags
  1188.             ;    gng_TopEdge    ,gng_LeftEdge
  1189. AllGadgets        dc.l    GUI_Text8,CycleTagList
  1190.             dc.b    1,1,1,PLACETEXT_LEFT
  1191.             dc.w    TempHADJ,CYCLE_KIND
  1192.             dc.l    GUI_Text9,CycleTagList2
  1193.             dc.b    2,1,1,PLACETEXT_LEFT
  1194.             dc.w    TempVADJ,CYCLE_KIND
  1195.             dc.l    GUI_Text12,StringTagList
  1196.             dc.b    3,1,1,PLACETEXT_LEFT
  1197.             dc.w    TempScreen,STRING_KIND
  1198.             dc.l    GUI_Text13,StringTagList
  1199.             dc.b    4,1,1,PLACETEXT_LEFT
  1200.             dc.w    TempWindow,STRING_KIND
  1201.             dc.l    GUI_Text16,StringTagList
  1202.             dc.b    5,1,1,PLACETEXT_LEFT
  1203.             dc.w    TempCXPOPKEY,STRING_KIND
  1204.             dc.l    GUI_Text17,StringTagList
  1205.             dc.b    6,1,1,PLACETEXT_LEFT
  1206.             dc.w    TempActionKey,STRING_KIND
  1207.             dc.l    GUI_Text18,CycleTagList3
  1208.             dc.b    7,1,1,PLACETEXT_LEFT
  1209.             dc.w    TempAction,CYCLE_KIND
  1210.             dc.l    0,SlideTagList
  1211.             dc.b    8,1,1,0
  1212.             dc.w    TempDelay,SLIDER_KIND
  1213.  
  1214.             dc.l    GUI_Text1,GadgetTagList
  1215.             dc.b    1,2,1,PLACETEXT_RIGHT
  1216.             dc.w    TempMove,CHECKBOX_KIND
  1217.  
  1218.             dc.l    GUI_Text3,GadgetTagList
  1219.             dc.b    2,2,1,PLACETEXT_RIGHT
  1220.             dc.w    TempWFront,CHECKBOX_KIND
  1221.  
  1222.             dc.l    GUI_Text6,GadgetTagList
  1223.             dc.b    3,2,1,PLACETEXT_RIGHT
  1224.             dc.w    TempRestrict,CHECKBOX_KIND
  1225.  
  1226.             dc.l    GUI_Text2,GadgetTagList
  1227.             dc.b    4,2,1,PLACETEXT_RIGHT
  1228.             dc.w    TempSFront,CHECKBOX_KIND
  1229.  
  1230.             dc.l    GUI_Text5,GadgetTagList
  1231.             dc.b    5,2,1,PLACETEXT_RIGHT
  1232.             dc.w    TempPDef,CHECKBOX_KIND
  1233.  
  1234.             dc.l    GUI_Text7,GadgetTagList
  1235.             dc.b    6,2,1,PLACETEXT_RIGHT
  1236.             dc.w    TempRemWin,CHECKBOX_KIND
  1237.  
  1238.             dc.l    GUI_Text7_1,GadgetTagList
  1239.             dc.b    7,2,1,PLACETEXT_RIGHT
  1240.             dc.w    TempMoveMouse,CHECKBOX_KIND
  1241.  
  1242.             dc.l    GUI_Text7_2,GadgetTagList
  1243.             dc.b    8,2,1,PLACETEXT_RIGHT
  1244.             dc.w    TempCXPOPUP,CHECKBOX_KIND
  1245.  
  1246.             dc.l    GUI_Text10,TagList
  1247.             dc.b    9,0,1,PLACETEXT_IN
  1248.             dc.w    TempZero,BUTTON_KIND
  1249.             dc.l    GUI_Text11,TagList
  1250.             dc.b    9,2,1,PLACETEXT_IN
  1251.             dc.w    TempZero,BUTTON_KIND
  1252. SaveGadgData        dc.l    GUI_Text14,TagList
  1253.             dc.b    9,1,1,PLACETEXT_IN
  1254.             dc.w    TempSave,BUTTON_KIND
  1255.  
  1256.             dc.l    -1
  1257.  
  1258. NumberOfLines        =    9
  1259. NumberOfCols        =    3
  1260.  
  1261.  
  1262. ;a3:Pointer to the GadgetStructure
  1263. ;d7:Previous Gadget
  1264.  
  1265. DoAllGadgets        lea    AllGadgets(pc),a5
  1266.             move.l    GadBase(a4),a6
  1267.             moveq.l    #1,d6
  1268.  
  1269. DoAllGadgets2        tst.l    (a5)
  1270.             bmi.s    WasLastGadget
  1271.  
  1272.             moveq.l    #0,d0
  1273.             move.b    MyGadgetRowNr(a5),d0
  1274.             move.w    RemHeight(a4),d1
  1275.             addq.w    #2,d1
  1276.             mulu    d1,d0
  1277.             add.w    RemTop(a4),d0        ;Top
  1278.             move.w    d0,gng_TopEdge(a3)
  1279.  
  1280.             moveq.l    #0,d0
  1281.             move.b    MyGadgetXPos(a5),d0
  1282.             mulu    RemLen(a4),d0
  1283.             add.w    RemLeft(a4),d0
  1284.             move.w    d0,gng_LeftEdge(a3)
  1285.  
  1286.             moveq.l    #0,d0
  1287.             move.b    MyGadgetWidth(a5),d0
  1288.             mulu    RemLen(a4),d0
  1289.             sub.w    #8,d0
  1290.             move.w    d0,gng_Width(a3)
  1291.  
  1292.             move.w    RemHeight(a4),gng_Height(a3)
  1293.  
  1294.             moveq.l    #0,d0
  1295.             move.b    MyGadgetFlags(a5),d0
  1296.             move.l    d0,gng_Flags(a3)
  1297.             add.w    #1,gng_GadgetID(a3)
  1298.  
  1299.             move.l    MyGadgetText(a5),gng_GadgetText(a3)
  1300.  
  1301.             move.w    d6,gng_GadgetID(a3)
  1302.  
  1303.             sub.l    a2,a2
  1304.             move.w    MyGadgetStore(a5),a2
  1305.             add.l    a4,a2
  1306.             move.l    (a2),d4
  1307.  
  1308.             moveq.l    #0,d0
  1309.             move.w    MyGadgetKind(a5),d0
  1310.             move.l    d7,a0        ;Previous Gadget
  1311.             move.l    a3,a1
  1312.             move.l    MyGadgetList(a5),a2
  1313.             move.l    d4,4(a2)
  1314.             CALL    CreateGadgetA
  1315.             move.l    d0,d7        ;Remember Previous Gadget
  1316.             add.l    #MyGadgetSize,a5
  1317.             addq.l    #1,d6
  1318.             bra.s    DoAllGadgets2
  1319. WasLastGadget        rts
  1320.  
  1321. CheckGUI        RSave
  1322.  
  1323.             tst.w    GUIOpened(a4)
  1324.             beq    NoGUI
  1325.  
  1326.             move.l    GadBase(a4),a6
  1327.             move.l    MyWindow(a4),a0
  1328.             move.l  wd_UserPort(a0),a0
  1329.             CALL    GT_GetIMsg
  1330.             tst.l   d0         
  1331.             beq     NoGUI
  1332.             move.l  d0,a1
  1333.             moveq.l    #0,d6
  1334.             move.w    im_Code(a1),d6    ;Value of Gadget
  1335.             move.l  im_IAddress(a1),a2
  1336.  
  1337.             move.l    im_Class(a1),d7
  1338.             CALL    GT_ReplyIMsg
  1339.  
  1340.             cmp.l    #GADGETUP,d7
  1341.             bne    Others
  1342.  
  1343.             move.w    gg_GadgetID(a2),d0
  1344.             move.l    gg_SpecialInfo(a2),a3
  1345.             cmp.w    #17,d0
  1346.             beq    HideGad
  1347.             cmp.w    #18,d0
  1348.             beq    QuitGad
  1349.             cmp.w    #19,d0
  1350.             beq    SaveGad
  1351.  
  1352.             subq.l    #1,d0
  1353.  
  1354.             lea    AllGadgets(pc),a5
  1355.             mulu    #MyGadgetSize,d0
  1356.             sub.l    a2,a2
  1357.             move.w    MyGadgetStore(a5,d0.w),a2
  1358.             add.l    a4,a2
  1359.  
  1360. StringTest        cmp.w    #STRING_KIND,MyGadgetKind(a5,d0.w)
  1361.             bne.s    CheckBoxTest
  1362.             move.l    si_Buffer(a3),a0
  1363.             move.l    (a2),a1
  1364.             bsr    CopyPattern
  1365.             bsr    BuildPatterns
  1366.             bsr    InstallHotKey
  1367.             bra.s    NoGUI
  1368.  
  1369. CheckBoxTest        cmp.w    #CHECKBOX_KIND,MyGadgetKind(a5,d0.w)
  1370.             bne.s    StandardGUI
  1371.             ;using im_Code works only since V39, so:
  1372.             moveq.l    #1,d6
  1373.             tst.l    (a2)
  1374.             beq.s    StandardGUI
  1375.             moveq.l    #0,d6
  1376.  
  1377. StandardGUI        move.l    d6,(a2)
  1378.             bra.s    NoGUI
  1379.  
  1380. SaveGad            bsr    SaveConfig
  1381.             bra.s    NoGUI
  1382.  
  1383. QuitGad            bsr    CloseGUI
  1384.             move.w    #1,QuitMe(a4)
  1385.             bra.s    HideGad
  1386.  
  1387. Others                    cmp.l   #CLOSEWINDOW,d7
  1388.                     bne.s    NoClose
  1389. HideGad            bsr    CloseGUI
  1390.             bra.s    NoGUI
  1391. NoClose            cmp.l    #IDCMP_VANILLAKEY,d7
  1392.             bne.s    NoGUI
  1393.             cmp.b    #"q",d6
  1394.             beq.s    QuitGad
  1395.             cmp.b    #"s",d6
  1396.             beq.s    SaveGad
  1397.             cmp.b    #"h",d6
  1398.             beq.s    HideGad
  1399.  
  1400. NoGUI            RLoad
  1401.             rts
  1402.  
  1403. CloseGUI        RSave
  1404.             tst.w    GUIOpened(a4)
  1405.             beq.s    NotOpened
  1406.  
  1407.             bsr    RefreshStrings
  1408.  
  1409.             move.l    IntBase(a4),a6
  1410.             move.l    MyWindow(a4),a0
  1411.             bsr    RemoveSignal
  1412.             ;move.l    MyWindow(a4),a0
  1413.             move.l    GadgetList(a4),a1
  1414.             moveq.l    #-1,d0
  1415.             CALL    RemoveGList
  1416.  
  1417.             move.l    MyWindow(a4),a0
  1418.             clr.l    d0
  1419.             move.w    wd_TopEdge(a0),d0
  1420.             move.l    d0,RemWindowY
  1421.             move.w    wd_LeftEdge(a0),d0
  1422.             move.l    d0,RemWindowX
  1423.             CALL    CloseWindow
  1424.             
  1425. FailWindow        move.l    GadgetList(a4),a0
  1426.             move.l    GadBase(a4),a6
  1427.             CALL    FreeGadgets
  1428.  
  1429.             move.l    MyVisual(a4),a0
  1430.             CALL    FreeVisualInfo
  1431.  
  1432.             move.l    IntBase(a4),a6
  1433.             sub.l    a0,a0
  1434.             move.l    PublicScreen(a4),a1
  1435.             CALL    UnlockPubScreen
  1436.  
  1437. NotOpened        clr.w    GUIOpened(a4)
  1438.  
  1439.             RLoad
  1440.             rts
  1441.  
  1442. EnterSignal        Push    d0-d1/a0          
  1443.             move.l  wd_UserPort(a0),a0
  1444.             move.b  MP_SIGBIT(a0),d0  
  1445.             move.l    SignalMask(a4),d1
  1446.             bset    d0,d1             
  1447.             move.l  d1,SignalMask(a4) 
  1448.             Pull    d0-d1/a0          
  1449.             rts                       
  1450.                                           
  1451. RemoveSignal        Push    d0-d1/a0          
  1452.             move.l  wd_UserPort(a0),a0
  1453.             move.b  MP_SIGBIT(a0),d0
  1454.             move.l    SignalMask(a4),d1
  1455.             bclr    d0,d1             
  1456.             move.l    d1,SignalMask(a4) 
  1457.             Pull    d0-d1/a0          
  1458.             rts
  1459.  
  1460. GetNexta0.1        tst.b    (a0)+
  1461. GetNexta0        move.b    (a0),d0
  1462.             cmp.b    #"=",d0
  1463.             beq.s    GetNexta0.1
  1464.             cmp.b    #" ",d0
  1465.             beq.s    GetNexta0.1
  1466.             or.w    #$20,d0
  1467.             rts
  1468.  
  1469. RefreshStrings        RSave
  1470.             move.l    GadgetList(a4),a3
  1471.  
  1472. ThruAll            move.w    gg_GadgetID(a3),d0
  1473.             subq.l    #1,d0
  1474.             lea    AllGadgets(pc),a5
  1475.             mulu    #MyGadgetSize,d0
  1476.             sub.l    a2,a2
  1477.             move.w    MyGadgetStore(a5,d0.w),a2
  1478.             add.l    a4,a2    ;TempXXX
  1479.  
  1480.             cmp.w    #STRING_KIND,MyGadgetKind(a5,d0.w)
  1481.             bne.s    NextGaddie
  1482.             move.l    gg_SpecialInfo(a3),a0
  1483.             move.l    si_Buffer(a0),a0
  1484.             move.l    (a2),a1
  1485.             bsr    CopyPattern
  1486.             bsr    BuildPatterns
  1487.             bsr    InstallHotKey
  1488.  
  1489. NextGaddie        move.l    gg_NextGadget(a3),a3
  1490.             move.l    a3,d0
  1491.             bne.s    ThruAll
  1492.             RLoad
  1493.             rts
  1494.  
  1495.  
  1496. ;Screen in a0, X-Coord(rel) in d0, Y-Coord(rel) in d1
  1497. SetPointer        Push    a0-a2/d0-d1/a6
  1498.             lea    PointerPixEvent(a4),a2
  1499.             move.l    a0,iepp_Screen(a2)
  1500.             move.w    sc_MouseX(a0),d2
  1501.             move.w    sc_MouseY(a0),d3
  1502.  
  1503.             move.l    MyIORequest(a4),a1
  1504.             move.w    #IND_WRITEEVENT,io_Command(a1)
  1505.             lea    MyInputEvent(a4),a0
  1506.             move.l    #0,ie_NextEvent(a0)
  1507.             move.b    #IECLASS_NEWPOINTERPOS,ie_Class(a0)
  1508.             move.w    #0,ie_Qualifier(a0)
  1509.             add.w    d0,d2
  1510.             add.w    d1,d3
  1511.             move.w    d2,iepp_PositionX(a2)
  1512.             move.w    d3,iepp_PositionY(a2)
  1513.             move.l    a2,ie_EventAddress(a0)
  1514.  
  1515.             move.b    #IESUBCLASS_PIXEL,ie_SubClass(a0)
  1516.             move.w    #IECODE_NOBUTTON,ie_Code(a0)
  1517.             move.l    a0,io_Data(a1)
  1518.             move.l    #ie_SIZEOF,io_Length(a1)
  1519.             move.l    $04,a6
  1520.             CALL    DoIO
  1521.             Pull    a0-a2/a6/d0-d1
  1522.             rts
  1523.  
  1524. BuildPatterns        RSave
  1525.             tst.l    TempScreen(a4)
  1526.             beq.s    NoScreenPattern
  1527.             move.l    TempScreen(a4),a0
  1528.             bsr    GetNexta0
  1529.             lea    ScreenPatternMem(a4),a1
  1530.             bsr    CopyPattern
  1531.  
  1532.             lea    ScreenPatternMem(a4),a0
  1533.             lea    ScreenPatLen(a4),a2
  1534.             lea    ScreenPattern(a4),a3
  1535.             bsr    GetLen
  1536.             bpl    NoScreenPattern
  1537.             bsr    PatternError
  1538.  
  1539. NoScreenPattern        lea    ScreenPatternMem(a4),a0
  1540.             move.l    a0,TempScreen(a4)
  1541.             tst.l    TempWindow(a4)
  1542.             beq.s    NoWindowPattern
  1543.             move.l    TempWindow(a4),a0
  1544.             bsr    GetNexta0
  1545.             lea    WindowPatternMem(a4),a1
  1546.             bsr    CopyPattern
  1547.  
  1548.             lea    WindowPatternMem(a4),a0
  1549.             lea    WindowPatLen(a4),a2
  1550.             lea    WindowPattern(a4),a3
  1551.             bsr    GetLen
  1552.             bpl.s    NoWindowPattern
  1553.             bsr    PatternError
  1554.     
  1555. NoWindowPattern        lea    WindowPatternMem(a4),a0
  1556.             move.l    a0,TempWindow(a4)
  1557.             RLoad
  1558.             rts        
  1559.  
  1560. PatternError        lea    Text3(pc),a0
  1561.             bra    OpenRequester
  1562.  
  1563. ;a0:Source, a1:Dest
  1564. CopyPattern        move.w    #511,d0
  1565. CopyPattern2        move.b    (a0)+,(a1)+
  1566.             beq.s    EndCopy
  1567.             dbf    d0,CopyPattern2
  1568.             bsr    PatternError
  1569. EndCopy            rts
  1570.  
  1571.  
  1572. ;In: (a2): LEN - (a3): MEMORY - a0: Source-Pattern    :back: d0=pattern ok?
  1573. GetLen            move.l    a0,d6
  1574.             clr.l    d3
  1575. GetLen2            tst.b    (a0)+
  1576.             beq.s    EndOfString
  1577.             addq.l    #1,d3
  1578.             bra.s    GetLen2
  1579. EndOfString        lsl.w    #1,d3    ;StandardLen Of Pattern
  1580.             addq    #2,d3
  1581.             move.l    $04,a6
  1582.             tst.l    (a3)
  1583.             beq    AllocNew
  1584.             move.l    (a3),a1
  1585.             move.l    (a2),d0
  1586.             CALL    FreeMem
  1587.             clr.l    (a3)
  1588. AllocNew        move.l    d3,(a2)
  1589.             move.l    d3,d0
  1590.             move.l    #MEMF_CLEAR,d1
  1591.             CALL    AllocMem
  1592.             move.l    d0,d2
  1593.             beq    QuitPrg        ;No Memory? Good bye !
  1594.             move.l    d0,(a3)
  1595.             move.l    d6,d1
  1596.             move.l    DosBase(a4),a6
  1597.             CALL    ParsePatternNoCase
  1598.             rts
  1599.  
  1600.             
  1601. ;a0: Requester-Text
  1602. OpenRequester        Push    a0-a3
  1603.             lea    EasyReqStruct(a4),a1
  1604.             lea    PortName(pc),a2
  1605.             move.l    a2,es_Title(a1)
  1606.             move.l    a0,es_TextFormat(a1)
  1607.             lea    GadgetText(pc),a2
  1608.             move.l    a2,es_GadgetFormat(a1)
  1609.             move.l    IntBase(a4),a6
  1610.             sub.l    a0,a0
  1611.             ;a1: EasyReq
  1612.             sub.l    a2,a2
  1613.             sub.l    a3,a3
  1614.             CALL    EasyRequestArgs
  1615.             Pull    a0-a3
  1616.             rts
  1617.  
  1618. SaveConfig        RSave
  1619.             tst.l    WBMessage(a4)
  1620.             beq    SkipConfig
  1621.             move.l    WBMessage(a4),a3
  1622.             move.l    sm_ArgList(a3),d0
  1623.             beq    SkipConfig
  1624.             move.l    d0,a0
  1625.             move.l    wa_Name(a0),a0
  1626.             move.l    a0,d5
  1627.  
  1628.             move.l    DObject(a4),d0
  1629.             beq    SkipConfig
  1630.  
  1631.             move.l    d0,a0
  1632.             move.l    do_ToolTypes(a0),a5    ;Remember Old
  1633.             move.l    #1,TempDummy(a4)
  1634.  
  1635.             bsr    RefreshStrings
  1636.  
  1637.             Push    a0/a6
  1638.             move.l    $04,a6
  1639.             move.l    #NumberOfTemps*10+2*512+2*8,d0    ;Memory for tool arrays
  1640.             move.l    #MEMF_CLEAR,d1
  1641.             CALL    AllocMem
  1642.             move.l    d0,a3
  1643.             beq    MemErrTool
  1644.             move.l    DObject(a4),a0
  1645.             move.l    d0,do_ToolTypes(a0)
  1646.  
  1647.             move.l    d0,a1
  1648.             add.l    #(NumberOfTemps+1)*4,a1    ;Maximum Number of Pointers
  1649.  
  1650.             clr.l    d7
  1651.             lea    WBTemplate(pc),a2
  1652. LoopAllTemps        sub.l    a0,a0
  1653.             move.w    TemplateA4(a2),a0
  1654.             add.l    a4,a0
  1655.             move.l    (a0),d6
  1656.             beq.s    IsDefault
  1657.             move.l    a1,(a3,d7)
  1658.             move.l    TemplateText(a2),a0
  1659.             bsr    CopyPattern
  1660.             move.w    TemplateType(a2),d1
  1661.             beq    ThatsAllTemp
  1662.             move.b    #"=",-1(a1)
  1663.             
  1664.             cmp.w    #T_CYCLE,d1
  1665.             bne.s    ThatsString
  1666.             move.l    TemplateSpecial(a2),a0
  1667.             lsl.l    #2,d6
  1668.             move.l    (a0,d6.w),a0
  1669.             bsr    CopyPattern
  1670.             bra.s    ThatsAllTemp
  1671.  
  1672. ThatsString        cmp.w    #T_STRING,d1
  1673.             bne.s    ThatsInteger
  1674.             move.l    d6,a0
  1675.             bsr    CopyPattern
  1676.             bra.s    ThatsAllTemp
  1677.  
  1678. ThatsInteger        move.l    d6,d0
  1679.             bsr    PrintInteger
  1680.  
  1681. ThatsAllTemp        addq.l    #4,d7
  1682.             move.l    a1,d0
  1683.             and.l    #$ffffffc,d0
  1684.             move.l    d0,a1
  1685.             lea    4(a1),a1    ;Align on Longwords
  1686. IsDefault        add.l    #TemplateSize,a2
  1687.             tst.l    TemplateText(a2)
  1688.             bne    LoopAllTemps
  1689.  
  1690.             move.l    d5,a0
  1691.             move.l    DObject(a4),a1
  1692.             move.l    IconBase(a4),a6
  1693.             CALL    PutDiskObject
  1694.             bne.s    Done
  1695.             lea    Text4(pc),a0
  1696.             bsr    OpenRequester
  1697.  
  1698. Done            move.l    $04,a6
  1699.             move.l    #NumberOfTemps*10+2*512+2*8,d0
  1700.             move.l    a3,a1
  1701.             CALL    FreeMem
  1702. MemErrTool        Pull    a0/a6
  1703.  
  1704.             move.l    a5,do_ToolTypes(a0)
  1705.                 
  1706.             bra.s    DoneConfig
  1707.  
  1708. SkipConfig        lea    Text4(pc),a0
  1709.             bsr    OpenRequester
  1710. DoneConfig        RLoad
  1711.             rts
  1712.  
  1713.  
  1714. ;Where in hell has this damned OS a atoi and itoa function???
  1715.  
  1716. ;Quick implementation of word-only functions:
  1717.  
  1718. ;a0:String    Back: d0: Integer
  1719. GetInteger        Push    d1-d2/a0
  1720.             moveq.l    #0,d0
  1721.             moveq.l    #0,d1
  1722.             moveq.l    #1,d2
  1723.             cmp.b    #"-",(a0)
  1724.             bne.s    GetDezNr
  1725.             tst.b    (a0)+
  1726.             moveq.l    #-1,d2
  1727. GetDezNr        move.b    (a0)+,d1
  1728.             cmp.b    #"0",d1
  1729.             bcs    StringOver
  1730.             cmp.b    #"9"+1,d1
  1731.             bcc    StringOver
  1732.             sub.w    #$30,d1
  1733.             mulu    #$0a,d0
  1734.             add.l    d1,d0
  1735.             bra.s    GetDezNr
  1736. StringOver        muls    d2,d0
  1737.             Pull    d1-d2/a0
  1738.             rts    
  1739.  
  1740. ;d0: Integer        a1:String
  1741. PrintInteger        tst.l    d0
  1742.             bpl.s    PrDez0
  1743.             move.b    #"-",(a1)+
  1744.             neg.l    d0
  1745. PrDez0            move.w    #-1,-(sp)
  1746. PrDez            divu    #$0a,d0
  1747.             swap    d0
  1748.             move.w    d0,-(sp)
  1749.             clr.w    d0
  1750.             swap    d0
  1751.             bne.s    PrDez
  1752. PrDez1            move.w    (sp)+,d0
  1753.             bmi.s    CloseUp
  1754.             add.w    #"0",d0
  1755.             move.b    d0,(a1)+
  1756.             bra.s    PrDez1
  1757. CloseUp            clr.b    (a1)+
  1758.             rts
  1759.  
  1760.             rsreset
  1761. HK_Default        rs.l    1
  1762. HK_Description        rs.l    1
  1763. HK_Store        rs.l    1
  1764. HK_ID            rs.l    1
  1765. HK_Filter        rs.l    1
  1766. HK_SIZEOF        rs.l    0
  1767.  
  1768. HotKeyTable        dc.l    DefaultDescr2,Description2,TempActionKey,MyActionID,Filter2
  1769.             dc.l    DefaultDescr,Description,TempCXPOPKEY,MyHotkeyID,Filter
  1770.             dc.l    0
  1771.  
  1772. InstallHotKey        Push    a0-a1/a5-a6/d4-d5
  1773.             lea    HotKeyTable(pc),a5
  1774. InstallHotKey2        move.l    HK_Default(a5),a0
  1775.             move.l    HK_Description(a5),d0
  1776.             lea    (a4,d0),a1
  1777.             move.l    HK_Store(a5),d4
  1778.             tst.l    (a4,d4)
  1779.             beq.s    NoPOPKEY
  1780.             move.l    (a4,d4),a0
  1781.             bsr    GetNexta0
  1782. NoPOPKEY        move.l    a1,(a4,d4)
  1783.             bsr    CopyKey
  1784.             bmi.s    HotKeyError
  1785.  
  1786.             move.l    HK_Filter(a5),d5
  1787.             bsr    RemovePopKey
  1788.  
  1789.             move.l    HK_Description(a5),d0
  1790.             lea    (a4,d0),a0
  1791.             move.l    MyPort(a4),a1
  1792.             move.l    HK_ID(a5),d0
  1793.             bsr    HotKey
  1794.             bmi.s    HotKeyError
  1795.             move.l    a0,(a4,d5)
  1796.             CALL    CxObjError
  1797.             tst.l    d0
  1798.             bne.s    DeleteAndErr
  1799.             move.l    (a4,d5),a1
  1800.             move.l    Broker(a4),a0
  1801.             CALL    AttachCxObj
  1802.  
  1803.             lea    HK_SIZEOF(a5),a5
  1804.             tst.l    (a5)
  1805.             bne.s    InstallHotKey2
  1806.             Pull    a0-a1/a5-a6/d4-d5
  1807.             rts
  1808.  
  1809. DeleteAndErr        bsr    DeletePopKey
  1810. HotKeyError        lea    HotKeyErrorT(pc),a0
  1811.             bsr    OpenRequester
  1812.             clr.l    (a4,d4)
  1813.             bra    InstallHotKey2
  1814.  
  1815. CopyKey            move.w    #63,d0
  1816. CopyString        move.b    (a0)+,(a1)+
  1817.             beq.s    EndString
  1818.             dbf    d0,CopyString
  1819.             moveq.l    #-1,d0
  1820. EndString        rts
  1821.  
  1822. RemovePopKey        move.l    CommBase(a4),a6
  1823.             tst.l    (a4,d5)
  1824.             beq.s    NoFilter
  1825.             move.l    (a4,d5),a0
  1826.             CALL    RemoveCxObj
  1827. DeletePopKey        move.l    (a4,d5),a0
  1828.             CALL    DeleteCxObjAll
  1829.             clr.l    (a4,d5)
  1830. NoFilter        rts                
  1831.  
  1832.  
  1833. ;Implementation of the cx.lib function
  1834. ;HotKey(char *Description,MsgPort *CxPort,long Event)
  1835.  
  1836. ;a0=Description, a1=CxPort, d0=Event    ;Back: d0:Error, a0:Filter
  1837. HotKey            Push    d1-d7/a1-a2/a6
  1838.             move.l    a1,a2        ;Rem Port
  1839.             move.l    d0,d6        ;Rem Event
  1840.             move.l    CommBase(a4),a6
  1841.             move.l    #CX_FILTER,d0
  1842.             ;Description is in a0
  1843.             sub.l    a1,a1
  1844.             CALL    CreateCxObj
  1845.             move.l    d0,d7        ;Remember Filter
  1846.             beq.s    HKErr2
  1847.             move.l    #CX_SEND,d0
  1848.             move.l    a2,a0        ;Given Port
  1849.             move.l    d6,a1        ;Event
  1850.             CALL    CreateCxObj
  1851.             move.l    d0,d6        ;Remember Sender
  1852.             beq.s    HKErr
  1853.             move.l    d7,a0        ;Filter
  1854.             move.l    d6,a1        ;Sender
  1855.             CALL    AttachCxObj
  1856.             move.l    #CX_TRANSLATE,d0
  1857.             sub.l    a0,a0
  1858.             move.l    a0,a1
  1859.             CALL    CreateCxObj
  1860.             move.l    d0,a1
  1861.             tst.l    d0
  1862.             beq.s    HKErr
  1863.             move.l    d7,a0            ;Filter 
  1864.             ;Translate is in a1
  1865.             CALL    AttachCxObj
  1866.             move.l    d7,a0        ;Return Filter in a0
  1867.             moveq.l    #0,d0
  1868.             bra.s    HKOut
  1869. HKErr            move.l    d7,a0
  1870.             CALL    DeleteCxObjAll
  1871. HKErr2            moveq.l    #-1,d0
  1872. HKOut            Pull    d1-d7/a1-a2/a6
  1873.             rts
  1874.  
  1875. TestButton        RSave
  1876.             cmp.l    #0,a0
  1877.             beq.s    SkipTestButton
  1878.             move.l    RememberA4,a4
  1879.             move.l    CommBase(a4),a6
  1880.             CALL    CxMsgData
  1881.             tst.l    d0
  1882.             beq    SkipTestButton
  1883.             move.l    d0,a0
  1884.             cmp.b    #IECLASS_RAWMOUSE,ie_Class(a0)
  1885.             bne.s    SkipTestButton
  1886.             cmp.w    #IECODE_UP_PREFIX!IECODE_LBUTTON,ie_Code(a0)
  1887.             beq.s    RelButton
  1888.             cmp.w    #IECODE_LBUTTON,ie_Code(a0)
  1889.             bne.s    SkipTestButton
  1890.             move.w    #1,ButtonPressed(a4)
  1891.             bra.s    SkipTestButton
  1892. RelButton        clr.w    ButtonPressed(a4)
  1893.             bsr    SignalMyself
  1894.  
  1895.             bset    #SignalButton,What(a4)
  1896.  
  1897. SkipTestButton        RLoad
  1898.             rts
  1899.  
  1900. ;Debugging stuff - only documented out, because I need it again certainly
  1901. BLINK            RSave
  1902.             move.w    #$10,d1
  1903. blink2            move.w    #$7fff,d0
  1904. blink1            move.w    d0,$dff180
  1905.             dbf    d0,blink1
  1906.             dbf    d1,blink2
  1907.             RLoad
  1908.             rts
  1909.  
  1910. StringTagList        dc.l    GTST_String
  1911.             dc.l    0
  1912.             dc.l    GTST_MaxChars
  1913.             dc.l    511
  1914.             dc.l    TAG_DONE
  1915.  
  1916. CycleTagList        dc.l    GTCY_Active
  1917.             dc.l    0
  1918.             dc.l    GTCY_Labels
  1919.             dc.l    CycleList
  1920.             dc.l    TAG_DONE
  1921.  
  1922. CycleTagList2        dc.l    GTCY_Active
  1923.             dc.l    0
  1924.             dc.l    GTCY_Labels
  1925.             dc.l    CycleList2
  1926.             dc.l    TAG_DONE
  1927.  
  1928. CycleTagList3        dc.l    GTCY_Active
  1929.             dc.l    0
  1930.             dc.l    GTCY_Labels
  1931.             dc.l    CycleList3
  1932.             dc.l    TAG_DONE
  1933.  
  1934. GadgetTagList        dc.l    GTCB_Checked
  1935.             dc.l    0
  1936.             dc.l    TAG_DONE
  1937.  
  1938. SlideTagList        dc.l    GTSL_Level
  1939.             dc.l    0
  1940.             dc.l    GTSL_Min
  1941.             dc.l    0
  1942.             dc.l    GTSL_Max
  1943.             dc.l    99
  1944.             dc.l    GTSL_LevelFormat
  1945.             dc.l    SliderText
  1946.             dc.l    GTSL_LevelPlace
  1947.             dc.l    PLACETEXT_LEFT
  1948.             dc.l    GTSL_MaxLevelLen
  1949.             dc.l    50
  1950.             dc.l    GA_RelVerify
  1951.             dc.l    1
  1952.             dc.l    TAG_DONE
  1953.  
  1954. TagList            dc.l    GA_Disabled
  1955.             dc.l    0
  1956.             dc.l    GT_Underscore
  1957.             dc.l    '_'
  1958. TagListDone        dc.l    TAG_DONE
  1959.  
  1960. WindowTagList        dc.l    WA_InnerWidth
  1961. StoreInnerWidth            dc.l    0
  1962.             dc.l    WA_InnerHeight
  1963. StoreInnerHeight        dc.l    0
  1964.             dc.l    WA_IDCMP
  1965.                 dc.l    BUTTONIDCMP!CLOSEWINDOW!IDCMP_VANILLAKEY
  1966.             dc.l    WA_Flags
  1967.                 dc.l    WINDOWCLOSE!WINDOWDRAG!WINDOWDEPTH!ACTIVATE    
  1968.             dc.l    WA_PubScreen
  1969. StorePublicScreen        dc.l    0
  1970.             dc.l    WA_Title
  1971.                 dc.l    Texth
  1972.             dc.l    WA_AutoAdjust
  1973.                 dc.l    1
  1974.             dc.l    WA_Left
  1975. RemWindowX            dc.l    -1
  1976.             dc.l    WA_Top
  1977. RemWindowY            dc.l    -1
  1978.             dc.l    TAG_DONE
  1979.  
  1980. RememberA4        dc.l    0
  1981. RememberStack        dc.l    0
  1982.  
  1983.             rsreset
  1984. ScreenPatLen        rs.l    1
  1985. ScreenPattern        rs.l    1
  1986. WindowPatLen        rs.l    1
  1987. WindowPattern        rs.l    1
  1988. GadgetList        rs.l    1
  1989. WindPosRem        rs.l    1
  1990. WindSizeRem        rs.l    1
  1991. PositionX        rs.w    1
  1992. PositionY        rs.w    1
  1993. What            rs.w    1
  1994. DisableHW        rs.w    1
  1995. GUIOpened        rs.w    1
  1996. QuitMe            rs.w    1
  1997. RemFontSize        rs.w    1
  1998. ButtonPressed        rs.w    1
  1999. GadgetInside        rs.w    11
  2000. MyPort            rs.l    1
  2001. MyVisual        rs.l    1
  2002. Broker            rs.l    1
  2003. ScreenMem        rs.b    ScreenMemSize
  2004. IntBase            rs.l    1
  2005. IBaseLock        rs.l    1
  2006. RemLen            rs.w    1
  2007. RemHeight        rs.w    1
  2008. RemTop            rs.w    1
  2009. RemLeft            rs.w    1
  2010. DelayDo            rs.w    1
  2011. GadBase            rs.l    1
  2012. DosBase            rs.l    1
  2013. CommBase        rs.l    1
  2014. IconBase        rs.l    1
  2015. DObject            rs.l    1
  2016. Active            rs.l    1
  2017. FirstSc            rs.l    1
  2018. GraphicsBase        rs.l    1
  2019. PublicScreen        rs.l    1
  2020. PublicRastport        rs.l    1
  2021. Gadget0            rs.l    1
  2022. Filter            rs.l    1
  2023. Filter2            rs.l    1
  2024. VisualX            rs.w    1
  2025. VisualY            rs.w    1
  2026. TemplateArray        rs.l    0    ;Do not change order!
  2027. TempMove        rs.l    1
  2028. TempSFront        rs.l    1
  2029. TempWFront        rs.l    1
  2030. TempPDef        rs.l    1
  2031. TempRemWin        rs.l    1
  2032. TempMoveMouse        rs.l    1
  2033. TempCXPOPUP        rs.l    1
  2034. TempRestrict        rs.l    1
  2035. TempCXPRI        rs.l    1
  2036. TempCXPOPKEY        rs.l    1
  2037. TempHADJ        rs.l    1
  2038. TempVADJ        rs.l    1
  2039. TempScreen        rs.l    1
  2040. TempWindow        rs.l    1
  2041. TempActionKey        rs.l    1
  2042. TempAction        rs.l    1
  2043. TempDelay        rs.l    1
  2044. TempDummy        rs.l    1
  2045. TempZero        rs.l    1
  2046. TempSave        rs.l    1
  2047.  
  2048. OwnTask            rs.l    1
  2049. Signal            rs.l    1
  2050. Args            rs.l    1
  2051. WBMessage        rs.l    1
  2052. SignalMask        rs.l    1
  2053. MyWindow        rs.l    1
  2054. LastGadget        rs.l    1
  2055. MyIORequest        rs.l    1
  2056. MouseMsgPort        rs.l    1
  2057. MyNewGadget        rs.b    gng_SIZEOF
  2058. MyInterrupt        rs.b    IS_SIZE
  2059. MyInputEvent        rs.b    ie_SIZEOF
  2060. PointerPixEvent        rs.b    IEPointerPixel_SIZEOF
  2061. EasyReqStruct        rs.b    es_SIZEOF
  2062. Description        rs.b    64
  2063. Description2        rs.b    64
  2064. ScreenPatternMem    rs.b    512    ;sufficient I think
  2065. WindowPatternMem    rs.b    512
  2066. AllocLength        rs.w    1
  2067.  
  2068. intuition        dc.b    "intuition.library",0
  2069. DosName            dc.b    "dos.library",0
  2070. InputName        dc.b    "input.device",0
  2071. GraphicsName        dc.b    "graphics.library",0
  2072. IconName        dc.b    "icon.library",0
  2073. GadName            dc.b    "gadtools.library",0
  2074. CommName        dc.b    "commodities.library",0
  2075.             even
  2076.  
  2077. MyNewBroker        dc.b    NB_VERSION    ;Version
  2078.             dc.b    0        ;Reserve1
  2079.             dc.l    HandlerName    ;Name
  2080.             dc.l    PortName    ;Title
  2081.             dc.l    DescText    ;Description
  2082.             dc.w    NBU_NOTIFY!NBU_UNIQUE        ;Unique
  2083.             dc.w    COF_SHOW_HIDE    ;Flags
  2084. MyPri            dc.b    0        ;Pri
  2085.             dc.b    0        ;Reserve2
  2086. BrokerPort        dc.l    0        ;Port
  2087.             dc.w    0        ;ReservedChannel
  2088.  
  2089. CycleList    dc.l    GUI_Choose1.1,GUI_Choose1.2,GUI_Choose1.3,GUI_Choose1.4,0
  2090. CycleList2    dc.l    GUI_Choose2.1,GUI_Choose2.2,GUI_Choose2.3,GUI_Choose2.4,0
  2091. CycleList3    dc.l    GUI_Choose3.1,GUI_Choose3.2,GUI_Choose3.3,0
  2092.  
  2093.         rsreset
  2094. TemplateText    rs.l    1
  2095. TemplateSpecial    rs.l    1
  2096. TemplateA4    rs.w    1
  2097. TemplateType    rs.w    1
  2098. TemplateSize    rs.w    0
  2099.  
  2100. T_CHECK        =    0
  2101. T_CYCLE        =    1
  2102. T_STRING    =    2
  2103. T_INTEGER    =    3
  2104.  
  2105. NumberOfTemps    =    18
  2106.  
  2107. WBTemplate    dc.l    TextDNW,0
  2108.         dc.w    TempDummy,T_CHECK
  2109.  
  2110.         dc.l    TextMove,0
  2111.         dc.w    TempMove,T_CHECK
  2112.  
  2113.         dc.l    TextSFront,0
  2114.         dc.w    TempSFront,T_CHECK
  2115.  
  2116.         dc.l    TextWFront,0
  2117.         dc.w    TempWFront,T_CHECK
  2118.  
  2119.         dc.l    TextPDef,0
  2120.         dc.w    TempPDef,T_CHECK
  2121.  
  2122.         dc.l    TextRestrict,0
  2123.         dc.w    TempRestrict,T_CHECK
  2124.  
  2125.         dc.l    TextDelay,0
  2126.         dc.w    TempDelay,T_INTEGER
  2127.  
  2128.         dc.l    TextAction,CycleList3
  2129.         dc.w    TempAction,T_CYCLE
  2130.  
  2131.         dc.l    TextRemWin,0
  2132.         dc.w    TempRemWin,T_CHECK
  2133.  
  2134.         dc.l    TextMoveMouse,0
  2135.         dc.w    TempMoveMouse,T_CHECK
  2136.  
  2137.         dc.l    TextCXPOPUP,0
  2138.         dc.w    TempCXPOPUP,T_CHECK
  2139.  
  2140.         dc.l    TextScreen,0
  2141.         dc.w    TempScreen,T_STRING
  2142.  
  2143.         dc.l    TextWindow,0
  2144.         dc.w    TempWindow,T_STRING
  2145.  
  2146.         dc.l    TextCXPOPKEY,0
  2147.         dc.w    TempCXPOPKEY,T_STRING
  2148.  
  2149.         dc.l    TextCXPRI,0
  2150.         dc.w    TempCXPRI,T_INTEGER
  2151.  
  2152.         dc.l    TextHADJ,CycleList
  2153.         dc.w    TempHADJ,T_CYCLE
  2154.  
  2155.         dc.l    TextVADJ,CycleList2
  2156.         dc.w    TempVADJ,T_CYCLE
  2157.  
  2158.         dc.l    TextActionKey,0
  2159.         dc.w    TempActionKey,T_STRING
  2160.  
  2161.         dc.l    0
  2162.  
  2163.  
  2164. TextDNW        dc.b    "DONOTWAIT",0
  2165. TextMove    dc.b    "MOVE",0
  2166. TextSFront    dc.b    "SFRONT",0
  2167. TextWFront    dc.b    "WFRONT",0
  2168. TextPDef    dc.b    "DEFPUB",0
  2169. TextCXPOPUP    dc.b    "CX_POPUP",0
  2170. TextRestrict    dc.b    "RESTRICT",0
  2171. TextCXPRI    dc.b    "CX_PRIORITY",0
  2172. TextCXPOPKEY    dc.b    "CX_POPKEY",0
  2173. TextRemWin    dc.b    "REMWIN",0
  2174. TextMoveMouse    dc.b    "MOVEMOUSE",0
  2175. TextHADJ    dc.b    "HADJ",0
  2176. TextVADJ    dc.b    "VADJ",0
  2177. TextScreen    dc.b    "SCREEN",0
  2178. TextWindow    dc.b    "WINDOW",0
  2179. TextActionKey    dc.b    "ACTIONKEY",0
  2180. TextAction    dc.b    "ACTION",0
  2181. TextDelay    dc.b    "DELAY",0
  2182. Template    dc.b    "MOVE/S,SFRONT/S,WFRONT/S,DEFPUB/S,REMWIN/S,MOVEMOUSE/S,CX_POPUP/S,RESTRICT/S,CX_PRIORITY/K,CX_POPKEY/K,HADJ/K,VADJ/K,SCREEN/K,WINDOW/K,ACTIONKEY/K,ACTION/K,DELAY/K",0
  2183. PortName    dc.b    "Huntwindows 3.0",0
  2184. HandlerName    dc.b    "Huntwindows",0
  2185. GadgetText    dc.b    "Ok",0
  2186. DefaultDescr    dc.b    "control alt h",0
  2187. DefaultDescr2    dc.b    "control help",0
  2188. HotKeyErrorT    dc.b    "Wrong hotkey description!",$0a,0
  2189. Text1        dc.b    "Error in arguments or libraries!",$0a,0
  2190. Text2        dc.b    "I need V37+ !",$0a,0
  2191. Text3        dc.b    "Error in given patterns!",$0a,0
  2192. Text4        dc.b    "Cannot Save!",$0a,0
  2193.         dc.b    "$VER: "    ;for version information
  2194. Texth        dc.b    "Huntwindows 3.0 (17.5.93) by Jörg Bublath 1992-1993",0
  2195. DescText    dc.b    "Moves screen to show windows",0
  2196. GUI_Text1    dc.b    "Move Screen",0
  2197. GUI_Text2    dc.b    "ScreenToFront",0
  2198. GUI_Text3    dc.b    "WindowToFront",0
  2199. GUI_Text5    dc.b    "Set Default PubScreen",0
  2200. GUI_Text6    dc.b    "Restrict on DefPub",0
  2201. GUI_Text7    dc.b    "Remember Window",0
  2202. GUI_Text7_1    dc.b    "Move Mouse",0
  2203. GUI_Text7_2    dc.b    "GUI Popup",0
  2204. GUI_Text8    dc.b    "Horizontal Adjustment",0
  2205. GUI_Text9    dc.b    "Vertical Adjustment",0
  2206. GUI_Text10    dc.b    "_Hide",0
  2207. GUI_Text11    dc.b    "_Quit",0
  2208. GUI_Text12    dc.b    "Screen Pattern",0
  2209. GUI_Text13    dc.b    "Window Pattern",0
  2210. GUI_Text14    dc.b    "_Save",0
  2211. GUI_Text16    dc.b    "Popup Hotkey",0
  2212. GUI_Text17    dc.b    "Action Hotkey",0
  2213. GUI_Text18    dc.b    "Action Condition",0
  2214. GUI_Text19    dc.b    "Delay in 1/50 seconds",0
  2215. SliderText    dc.b    "Delay in 1/50 seconds:%ld ",0
  2216. GUI_TextEnd    ;
  2217. GUI_Choose1.1    dc.b    "left",0
  2218. GUI_Choose1.2    dc.b    "right",0
  2219. GUI_Choose1.3    dc.b    "center",0
  2220. GUI_Choose1.4    dc.b    "off",0
  2221. GUI_Choose2.1    dc.b    "top",0
  2222. GUI_Choose2.2    dc.b    "bottom",0
  2223. GUI_Choose2.3    dc.b    "center",0
  2224. GUI_Choose2.4    dc.b    "off",0
  2225. GUI_Choose3.1    dc.b    "necessary",0
  2226. GUI_Choose3.2    dc.b    "hotkey",0
  2227. GUI_Choose3.3    dc.b    "always",0
  2228.         even
  2229.