home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / monitors / xoper / src.lha / Xoper.s
Text File  |  1995-02-02  |  186KB  |  9,403 lines

  1. ******************************************
  2. *                     *
  3. * Xoper 2.5 Copyright (C) Werner GÜnther *
  4. *    (68881 code by Lothar English)      *
  5. *(Kick 2.0+ enhancements by Gunther Nikl)*
  6. *                     *
  7. ******************************************
  8. *  Written for the A68k V2.71 Assembler     *
  9. * by Charlie Gibbs and Brian R. Anderson *
  10. *                     *
  11. * Do not use Smallcode/Smalldata when     *
  12. *        linking             *
  13. ******************************************
  14.  
  15. ;DEBUG SET 1
  16.  
  17. ; revison control...
  18.  
  19. VERSION        macro
  20.         dc.b    'Xoper 2.5 (2.2.95)',0
  21.         endm
  22.  
  23. ; include stuff
  24.  
  25.         include    exec/types.i
  26.         include    lvo13/dos_lib.i
  27.         include    lvo13/exec_lib.i
  28.         include    lvo13/console_lib.i
  29.         include    lvo13/graphics_lib.i
  30.         include    lvo13/diskfont_lib.i
  31.         include    lvo13/intuition_lib.i
  32.  
  33. ; >=V36 functions
  34.  
  35. _LVOColdReboot        equ    -726        ; exec
  36. _LVOFindDisplayInfo    equ    -726        ; graphics
  37. _LVOGetDisplayInfoData    equ    -756
  38. _LVOGetVPModeID        equ    -792
  39. _LVOQueryOverscan    equ    -474        ; intuition
  40. _LVOLockPubScreen    equ    -510
  41. _LVOUnlockPubScreen    equ    -516
  42. _LVOLockPubScreenList    equ    -522
  43. _LVOUnlockPubScreenList    equ    -528
  44. _LVOPubScreenStatus    equ    -552
  45. _LVOReadEClock        equ    -60        ; timer
  46. _LVOAddAppIcon        equ    -60        ; workbench
  47. _LVORemoveAppIcon    equ    -66
  48. _LVOCreateCxObj        equ    -30        ; commodity
  49. _LVOCxBroker        equ    -36
  50. _LVOActivateCxObj    equ    -42
  51. _LVODeleteCxObjAll    equ    -54
  52. _LVOCxObjError        equ    -66
  53. _LVOAttachCxObj        equ    -84
  54. _LVOSetFilter        equ    -120
  55. _LVOCxMsgType        equ    -138
  56. _LVOCxMsgID        equ    -150
  57.  
  58. ; macro stuff
  59.  
  60. CALL        MACRO
  61.         move.l    \2,a6
  62.         jsr    _LVO\1(a6)
  63.         ENDM
  64.  
  65. RECALL        MACRO
  66.         jsr    _LVO\1(a6)
  67.         ENDM
  68.  
  69. ADDCMD        MACRO
  70. cmdnum        set    cmdnum+1
  71.         dc.b    \1,0
  72.         ENDM
  73.  
  74. ; global stuff
  75.  
  76.     STRUCTURE Globals,0
  77.  
  78.       ULONG  sysbase
  79.       ULONG  dosbase
  80.       ULONG  intuibase
  81.       ULONG  gfxbase
  82.       ULONG  wbbase
  83.       ULONG  cxbase
  84.       ULONG  condev
  85.       ULONG  wbmsg
  86.       ULONG  wblock
  87.       ULONG  myseg
  88.       ULONG  realstack
  89.       ULONG  idletask
  90.       ULONG  node
  91.       ULONG  parmtxt
  92.       ULONG  infile
  93.       ULONG  ptr
  94.       ULONG  auxsig
  95.       ULONG  mysignal            ; init with $20000
  96.       ULONG  trapsignal
  97.       ULONG  tasksigs
  98.       ULONG  cancelbit
  99.       ULONG  cancelbnum
  100.       ULONG  broker
  101.       ULONG  filter
  102.       ULONG  inputport
  103.        ULONG  inputio
  104.       ULONG  startmess
  105.       ULONG  savedat
  106.       ULONG  wnptr
  107.       ULONG  ownfont
  108.       ULONG  topazfont
  109.       ULONG  aliaslist
  110.       ULONG  screenptr
  111.       ULONG  intuimsg
  112.       ULONG  mytask
  113.       ULONG  oldprwin
  114.       ULONG  pointer
  115.       ULONG  replyport
  116.       ULONG  timerport
  117.       ULONG  finfoptr
  118.       ULONG  dispatches
  119.       ULONG  maxdisp
  120.       ULONG  oldswitches
  121.       ULONG  remembr
  122.       ULONG  remembr2
  123.       ULONG  snoopport
  124.       ULONG  captask
  125.       ULONG  capiscli
  126.       ULONG  capseg
  127.       ULONG  blanks
  128.       ULONG  hidestart
  129.       ULONG  iocount
  130.       ULONG  rastport
  131.       ULONG  outchain
  132.       ULONG  firstline
  133.       ULONG  oldfirstline
  134.       ULONG  numlines
  135.       ULONG  oldnumlines
  136.       ULONG  timeoutm
  137.       ULONG  gothline
  138.       ULONG  lastprinted
  139.       ULONG  oldlastprinted
  140.       ULONG  maxlines            ; init with 500
  141.       ULONG  oldpageend
  142.       ULONG  secs
  143.       ULONG  mics
  144.       ULONG  time10
  145.       ULONG  tsecs
  146.       ULONG  tmics
  147.       ULONG  devicelock
  148.       ULONG  timerticks
  149.       ULONG  excpterror
  150.       ULONG  excpttask
  151.       ULONG  excptaddr
  152.       ULONG  excptpc
  153.       ULONG  lasttime
  154.       STRUCT newtime,4*2
  155.       STRUCT osecs,4*4
  156.       STRUCT tdtasks,4*4
  157.  
  158.       ULONG  OldSwitch
  159.       ULONG  OldAddTask
  160.       ULONG  OldAllocMem
  161.       ULONG  OldFreeMem
  162.       ULONG  OldTrap
  163.       ULONG  OldProcTrap
  164.       ULONG  div32
  165.  
  166.       UWORD  txheight
  167.       UWORD  txwidth
  168.       UWORD  firstpos
  169.       UWORD  colms
  170.       UWORD  timersig
  171.       UWORD  cxsig
  172.       UWORD  intuisig
  173.       UWORD  ibufferlen
  174.       UWORD  oldibuflen
  175.       UWORD  cposy
  176.       UWORD  curpos
  177.       UWORD  oldpos
  178.       UWORD  bottomin
  179.       UWORD  ipos
  180.       UWORD  hnum
  181.       UWORD  minnumchars            ; init with 2
  182.       UWORD  maxhlines            ; init with 10
  183.       UWORD  qualifier
  184.       UWORD  rows
  185.       UWORD  maxllength
  186.       UWORD  loffset
  187.       UWORD  repeatlen
  188.       UWORD  edline
  189.       UWORD  cmdptr
  190.       UWORD  currenty
  191.       UWORD  cmdcompnr
  192.       UWORD  cmdcomplen
  193.       UWORD  cmdcplen
  194.       UWORD  numtaskstimed
  195.       UWORD  tasksnum
  196.       UWORD  procnum
  197.  
  198.       STRUCT hexarea,10
  199.       STRUCT binarea,12
  200.       STRUCT minus,2
  201.       STRUCT decimal,6
  202.  
  203.       UBYTE  entries
  204.       UBYTE  timeout            ; init with 5
  205.       UBYTE  newpri
  206.       UBYTE  tasktyp
  207.       UBYTE  getanswer
  208.       UBYTE  printed
  209.       UBYTE  useageon
  210.       UBYTE  tports
  211.       UBYTE  hideon                ; init with
  212.       UBYTE  headon
  213.       UBYTE  tinfo
  214.       UBYTE  cmdcli                ;    |
  215.       UBYTE  sorton                ;    |
  216.       UBYTE  cxstate            ;    |
  217.       UBYTE  iconifyon            ;    V
  218.       UBYTE  propgadon
  219.       UBYTE  propupdate
  220.       UBYTE  finfopen            ; -1 !!!!
  221.       UBYTE  patchmode
  222.       UBYTE  timerstate
  223.       UBYTE  cbreak
  224.       UBYTE  bool
  225.       UBYTE  wanttraps
  226.       UBYTE  addlines
  227.       UBYTE  gotguru
  228.       UBYTE  ownscreen
  229.       UBYTE  topaz
  230.       UBYTE  insmode
  231.       UBYTE  repeat
  232.       UBYTE  capgone
  233.       UBYTE  capwaiting
  234.       UBYTE  cliexec
  235.       UBYTE  appicn
  236.       UBYTE  pcheck
  237.       UBYTE  snoopon
  238.       UBYTE  msnoop
  239.       UBYTE  newtab
  240.       UBYTE  oldtab
  241.       UBYTE  bleft
  242.       UBYTE  waitexit
  243.       UBYTE  wantexit
  244.       UBYTE  wanthold
  245.       UBYTE  wantwindow
  246.       UBYTE  noscript
  247.       UBYTE  post_V34
  248.       UBYTE  post_V38
  249.       UBYTE  pad2
  250.       UBYTE  pad3
  251.  
  252. ; make sure that mypacket is *ALWAYS* longword aligned !!!
  253.       STRUCT mypacket,68
  254. ; don't change argument order below !!!
  255.       STRUCT buffer,2800
  256.       STRUCT out,100+100
  257.       STRUCT dummy,80+40
  258.       STRUCT in,80+40
  259.       STRUCT cputime,1000
  260.       STRUCT taskstampid,128*4
  261.       STRUCT taskstamps,128*4
  262.       STRUCT usedtime,128*4
  263.       STRUCT ievent,32
  264.       STRUCT outevent,20
  265.       STRUCT inputbuffer,88+40
  266.       STRUCT timerio,40
  267.       STRUCT sampleio,40
  268.       STRUCT repeatbuffer,84+40
  269.       STRUCT hotkeybuf,42
  270.       STRUCT winkeybuf,110
  271.  
  272.     LABEL gb_SIZEOF
  273.  
  274. ; some defines
  275.  
  276. mysigbit    equ    17
  277. maxarg        equ    20
  278.  
  279.         SECTION    Start,CODE
  280.  
  281. ; Program startup.
  282. ; If called from DOS we use segment splitting to detach from our DOS-task.
  283.  
  284. start        lea    dataarea,a4        ; globals
  285.         move.l    d0,d2            ; save (possible) arguments
  286.         move.l    a0,a2
  287.         move.l    a4,a1
  288.         move.w    #(gb_SIZEOF>>2)-1,d1
  289. 1$        clr.l    (a1)+            ; clear bss area
  290.         dbra    d1,1$
  291.         bsr.s    InitVars        ; default values
  292.         move.l    4,a6
  293.         move.l    a6,sysbase(a4)
  294.         move.l    276(a6),a3
  295.         tst.l    172(a3)
  296.         bne.s    fromCLI
  297. fromWB        lea    92(a3),a0        ; get wb msg
  298.         RECALL    WaitPort
  299.         lea    92(a3),a0
  300.         RECALL    GetMsg
  301.         move.l    d0,wbmsg(a4)
  302. fromCLI        lea    dosname(pc),a1        ; open dos
  303.         moveq    #33,d0
  304.         RECALL    OpenLibrary
  305.         move.l    d0,dosbase(a4)
  306.         beq.s    exit
  307.         move.l    wbmsg(a4),d1
  308.         beq.s    1$            ; not wb start
  309.         move.l    d1,a1
  310.         bsr.s    GetToolTypes        ; make cmdline for wb
  311. 1$        bsr    GetCmdLine
  312.         bsr    CreateProc        ; start prog
  313.         move.l    dosbase(a4),a1
  314.     IFD DEBUG
  315.         move.l    sysbase(a4),a6
  316.     ENDC
  317.         RECALL    CloseLibrary
  318. exit        move.l    wbmsg(a4),d2
  319.         beq.s    1$
  320.         RECALL    Forbid
  321.         move.l    d2,a1
  322.         RECALL    ReplyMsg
  323. 1$        moveq    #0,d0
  324.         rts
  325.  
  326. ; some default values (before zero!)
  327.  
  328. InitVars    addq.w    #2,mysignal(a4)        ; mask := $20000
  329.         move.w    #500,maxlines+2(a4)
  330.         addq.w    #1,bottomin(a4)
  331.         addq.w    #2,minnumchars(a4)
  332.         move.w    #10,maxhlines(a4)
  333.         move.w    #999,edline(a4)
  334.         addq.b    #5,timeout(a4)
  335.         subq.l    #1,hideon(a4)        ; +headon+tinfo+cmdcli
  336.         subq.l    #1,sorton(a4)        ; +cxstate+iconifyon+propgadon
  337.         subq.w    #1,propupdate(a4)    ; + finfopen
  338.         rts
  339.  
  340. ; a1 - wbmsg
  341.  
  342. _LVOGetDiskObject    equ    -78
  343. _LVOFreeDiskObject    equ    -90
  344.  
  345. GetToolTypes    move.l    36(a1),a3        ; sm_ArgList
  346.         move.l    28(a1),d1
  347.         subq.l    #1,d1            ; sm_NumArgs == 1 ?
  348.         beq.s    7$
  349.         addq.w    #8,a3            ; project icon
  350. 7$        lea    icnname(pc),a1
  351.         moveq    #33,d0
  352.         RECALL    OpenLibrary
  353.         move.l    d0,d6
  354.         beq.s    1$            ; no icon library ?!
  355.         move.l    0(a3),d1
  356.         move.l    d1,wblock(a4)
  357.         CALL    CurrentDir,dosbase(a4)    ; set wa_Lock
  358.         move.l    d0,d3
  359.         move.l    4(a3),a0
  360.         CALL    GetDiskObject,d6    ; iconbase
  361.         move.l    d0,a3
  362.         move.l    d3,d1
  363.         CALL    CurrentDir,dosbase(a4)    ; set old lock
  364.         move.l    a3,d3
  365.         beq.s    2$            ; no icon got
  366.         move.l    54(a3),a3        ; do_ToolTypes
  367.         lea    buffer(a4),a2
  368.         move.l    a2,a1
  369.         bra.s    4$
  370. 6$        move.l    d0,a0
  371.         cmp.b    #'A',(a0)
  372.         bcs.s    4$            ; skip < A
  373.         cmp.b    #'z'+1,(a0)
  374.         bcc.s    4$            ; skip > z
  375.         cmp.b    #'Z'+1,(a0)
  376.         bcs.s    5$            ; ok < Z
  377.         cmp.b    #'a',(a0)
  378.         bcs.s    4$            ; skip < a
  379. 5$        move.b    (a0)+,(a1)+        ; copy value
  380.         bne.s    5$
  381.         move.b    #' ',-1(a1)        ; delimiter
  382. 4$        move.l    (a3)+,d0
  383.         bne.s    6$
  384.         move.l    a1,d2
  385.         sub.l    a2,d2            ; line length
  386.         bne.s    3$
  387.         moveq    #1,d2            ; don't clear illegal
  388. 3$        move.l    d3,a0
  389.         CALL    FreeDiskObject,d6
  390. 2$        move.l    d6,a1            ; close icon lib
  391.         CALL    CloseLibrary,sysbase(a4)
  392. 1$        rts
  393.  
  394. GetCmdLine    clr.b    -1(a2,d2.w)        ; terminate line
  395.         move.l    a2,a1
  396.         moveq    #0,d2
  397.         lea    out(a4),a2
  398.  
  399. ; a1 - pointer into command line
  400. ; d2 - argc
  401. ; a2 - argv
  402.  
  403. ParseCLI    bsr.s    GetNext            ; search argument
  404.         bmi.s    doquote            ; quotation sign
  405.         beq.s    dosemi            ; commentary stops all
  406.         bcs.s    ParseCLI        ; separation sign
  407.         lea    -1(a1),a0        ; argument start
  408.         bsr.s    BumpArgV        ; argc+1 & ptr to argv
  409. build_2        bsr.s    GetNext            ; search separation sign
  410.         beq.s    dosemi            ; commentary stops all
  411.         bcc.s    build_2            ; no separation sign
  412.         clr.b    -1(a1)            ; mark end
  413.         bra.s    ParseCLI        ; continue search
  414.  
  415. doquote        move.l    a1,a0            ; argument start
  416.         bsr.s    BumpArgV        ; argc+1 & ptr to argv
  417. quote_2        bsr.s    GetNext            ; search quotation sign
  418.         bpl.s    quote_2            ; no quotation sign
  419.         clr.b    -1(a1)            ; mark end
  420. quote_3        bsr.s    GetNext            ; search sepaartion sign
  421.         beq.s    dosemi            ; commentary stops all
  422.         bcc.s    quote_3            ; no separation sign
  423.         bra.s    ParseCLI        ; continue search
  424.  
  425. dosemi        clr.b    -(a1)            ; delete semicolon
  426.         bra.s    ParseCLI        ; go on
  427.  
  428. BumpArgV    cmp.w    #maxarg,d2        ; max argc reached ?
  429.         bcc.s    1$
  430.         move.l    a0,(a2)+        ; store argptr
  431.         addq.w    #1,d2            ; increment argc
  432. 1$        rts
  433.  
  434. GetNext        move.b    (a1)+,d0        ; test character
  435.         beq.s    BuildRdy
  436.         moveq    #-3,d1            ; N=1,Z=0,C=0 -> quotation
  437.         cmp.b    #'"',d0
  438.         beq.s    1$
  439.         moveq    #-2,d1            ; N=0,Z=1,C=1 -> semicolon
  440.         cmp.b    #';',d0
  441.         beq.s    1$
  442.         moveq    #-1,d1            ; N=0,Z=0,C=1 -> separation
  443.         cmp.b    #'=',d0
  444.         beq.s    1$
  445.         cmp.b    #' ',d0
  446.         beq.s    1$
  447.         cmp.b    #9,d0
  448.         beq.s    1$
  449.         moveq    #0,d1            ; N=0,Z=0,C=0 -> others
  450. 1$        addq.l    #2,d1            ; set flags ( see above )
  451.         rts
  452.  
  453. BuildRdy    move.b    d2,entries(a4)
  454.         addq.l    #4,sp            ; set correct return address
  455.         rts
  456.  
  457. ; usage requsted
  458.  
  459. showhelp    CALL    Output,dosbase(a4)
  460.         move.l    d0,d4
  461.         move.l    d4,d1
  462.         lea    template.str(pc),a2
  463.         move.l    a2,d2
  464.         moveq    #cmd.str-template.str-1,d3
  465.         RECALL    Write
  466.         move.l    d4,d1
  467.         lea    buffer(a4),a2
  468.         move.l    a2,d2
  469.         moveq    #80,d3
  470.         RECALL    Read
  471.         move.l    d0,d2
  472.         bra    GetCmdLine        ; check input
  473.  
  474. ; check template for cli or wb
  475.  
  476. CheckArgs    tst.l    wbmsg(a4)        ; workbench ?
  477.         bne.s    8$
  478.         lea    help.str(pc),a0        ; help ?
  479.         bsr    findarg
  480.         bne.s    8$
  481.         bsr.s    showhelp
  482.  
  483. 8$        lea    cxpop.str(pc),a0    ; popup ?
  484.         bsr.s    findarg
  485.         bne.s    7$
  486.         bsr    nextarg
  487.         beq.s    7$
  488.         lea    cxyes.str(pc),a0
  489.         jsr    StrCmp(a4)
  490.         sne    wanthold(a4)
  491.  
  492. 7$        lea    cxkey.str(pc),a0    ; new popkey ?
  493.         bsr.s    findarg
  494.         bne.s    6$
  495.         bsr.s    nextarg
  496.         bne.s    5$
  497. 6$        lea    defhotkey(a4),a1
  498. 5$        lea    hotkeybuf(a4),a0
  499.         moveq    #39,d0
  500. 4$        move.b    (a1)+,(a0)+        ; copy hotkey description
  501.         dbeq    d0,4$
  502.         clr.b    (a0)
  503.  
  504.         lea    cxpri.str(pc),a0
  505.         bsr.s    findarg
  506.         bne.s    3$
  507.         bsr.s    nextarg
  508.         beq.s    3$
  509.         move.l    a1,a0
  510.         jsr    GetNum(a4)
  511.         move.b    d2,newbroker+18(a4)    ; nb_Pri
  512.  
  513. 3$        lea    noscript.str(pc),a0    ; skip scriptfile ?
  514.         bsr.s    findarg
  515.         seq    noscript(a4)
  516.  
  517.         lea    cmd.str(pc),a0        ; defaultcmd ?
  518.         bsr.s    findarg
  519.         bne.s    2$
  520.         bsr.s    nextarg
  521.         beq.s    2$
  522.         move.b    (a1),d2            ; first char
  523.         lea    kill.str(pc),a0
  524.         jsr    StrCmp(a4)
  525.         bne.s    1$
  526.         st    bool(a4)        ; kill
  527. 2$        moveq    #'t',d2            ; display default to tasks
  528. 1$        lsl.w    #8,d2
  529.         or.w    #10,d2            ; LF
  530.         move.w    d2,in(a4)
  531.         rts
  532.  
  533. findarg        move.b    entries(a4),d2        ; search argument
  534.         lea    out(a4),a2
  535. 2$        subq.b    #1,d2
  536.         bcs.s    1$
  537.         move.l    (a2)+,a1
  538.         jsr    StrCmp(a4)        ; compare it
  539.         bne.s    2$
  540. 1$        rts
  541.  
  542. nextarg        move.l    (a2),a1            ; make sure ptr is valid
  543.         move.l    a1,d1
  544.         rts
  545.  
  546. CreateProc    bsr    CheckArgs
  547.         CALL    Forbid,sysbase(a4)
  548.         lea    xopcon(a4),a1
  549.         RECALL    FindPort
  550.         move.l    d0,a5
  551.         move.l    a5,d0
  552.         beq.s    1$
  553.         move.l    16(a5),a1
  554.         move.l    mysignal(a4),d0
  555.     IFND DEBUG                ; kill for full version only !
  556.         tst.b    bool(a4)
  557.         beq.s    2$            ; wake Xoper up
  558.  
  559. ; This code tries to remove Xoper from the System in case Xoper 'freezes'
  560. ; or crashes. It works as follows:
  561. ; Xoper leaves the address of its cleanup routine in the UserData field of
  562. ; its Task structure. EXEC's context-restore code leaves the current PC of
  563. ; a task in the first longword of the tasks stack. All we have to do is to
  564. ; copy the address of Xoper's cleanup routine to its stack and to reschedule
  565. ; Xoper (using Signal() in this case).
  566.  
  567.         move.l    54(a1),a0
  568.         btst    #4,297(a6)        ; AttnFlags FPU
  569.         beq.s    3$            ; no FPU
  570.         moveq    #0,d0
  571.         move.b    (a0),d1            ; NULL frame ?
  572.         beq.s    4$
  573.         move.w    (a0),d1            ; frame flag / format word
  574.         lea    110(a0),a0        ; offset to fpu regs
  575.         addq.w    #1,d1            ; -1 ?
  576.         beq.s    5$
  577.         lea    12(a0),a0        ; add 3 longs
  578. 5$        move.b    1(a0),d0        ; frame size
  579. 4$        lea    4(a0,d0.w),a0
  580. 3$        move.l    88(a1),d0
  581.         beq.s    1$            ; exit already started
  582.         move.l    d0,0(a0)
  583.         moveq    #-1,d0
  584.     ENDC
  585. 2$        RECALL    Signal
  586. 1$        RECALL    Permit
  587.         move.l    a5,d0
  588.         bne    leave
  589.         tst.b    bool(a4)        ; kill request only !
  590.         bne.s    leave
  591.     IFND DEBUG
  592.         move.l    dosbase(a4),a5        ; start as background proccess
  593.         exg.l    a5,a6
  594.         tst.b    wanthold(a4)
  595.         beq.s    stt1            ; do not sleep
  596.         RECALL    Output
  597.         move.l    d0,d4
  598.         beq.s    stt1
  599.         move.l    d4,d1
  600.         lea    verstring(a4),a2
  601.         move.l    a2,d2
  602.         moveq    #copyright-verstring-1,d3
  603.         RECALL    Write
  604.         move.l    d4,d1
  605.         lea    cr(a4),a2
  606.         move.l    a2,d2
  607.         moveq    #1,d3
  608.         RECALL    Write
  609. stt1        move.l    wblock(a4),d1
  610.         bne.s    2$
  611.         move.l    276(a5),a1
  612.         move.l    152(a1),d1
  613. 2$        RECALL    DupLock
  614.         exg.l    a5,a6
  615.         move.l    d0,wblock(a4)
  616.         beq.s    leave
  617.         RECALL    Forbid
  618.         lea    newname(a4),a1
  619.         move.l    a1,d1
  620.         moveq    #0,d2
  621.         lea    start(pc),a1
  622.         move.l    -(a1),d3
  623.         move.l    d3,myseg(a4)
  624.         clr.l    (a1)+
  625.         moveq    #(4096>>6),d4
  626.         lsl.w    #6,d4
  627.         exg.l    a5,a6
  628.         RECALL    CreateProc
  629.         tst.l    d0
  630.         bne.s    1$
  631.         move.l    wblock(a4),d1
  632.         RECALL    UnLock
  633. 1$        exg.l    a5,a6
  634.         RECALL    Permit
  635.     ENDC
  636.     IFD DEBUG
  637.         jsr    mainprg
  638.     ENDC
  639. leave        rts
  640.  
  641. dosname        dc.b    'dos.library',0
  642. icnname        dc.b    'icon.library',0
  643. template.str    dc.b    'CMD/K,NOSCRIPT/S,CX_POPUP/K,CX_POPKEY/K,CX_PRIORITY/K/N: ',0
  644. cmd.str        dc.b    'CMD',0
  645. kill.str    dc.b    'KILL',0
  646. noscript.str    dc.b    'NOSCRIPT',0
  647. cxpop.str    dc.b    'CX_POPUP',0
  648. cxkey.str    dc.b    'CX_POPKEY',0
  649. cxpri.str    dc.b    'CX_PRIORITY',0
  650. cxyes.str    dc.b    'YES',0
  651. help.str    dc.b    '?',0
  652.  
  653.         SECTION    Xoper,CODE
  654.  
  655. mainprg        lea    dataarea(pc),a4        ; global base ptr
  656.         move.l    sp,realstack(a4)
  657.         move.l    sysbase(a4),a6
  658.         move.w    20(a6),d0        ; LIB_VERSION
  659.         sub.w    #36,d0
  660.         bcs.s    10$
  661.         st    post_V34(a4)        ; Kick2.0+
  662.         subq.w    #3,d0
  663.         scc    post_V38(a4)        ; Kick3.0+
  664.         move.w    #imagesize,d0
  665.         move.l    image+10(a4),a0
  666. 11$        not.l    (a0)+            ; reverse iconify image
  667.         dbra    d0,11$
  668. 10$        move.l    304(a6),OldTrap(a4)    ; original EXEC Trap-Handler
  669.         move.l    276(a6),a0        ; ExecBase->ThisTask
  670.         move.l    a0,mytask(a4)
  671.         move.l    50(a0),OldProcTrap(a4)    ; original AmigaDOS Trap-Handler
  672.         lea    stopall(pc),a1
  673.         move.l    a1,88(a0)        ; leave a message for 'Kill Xoper'
  674.         move.l    184(a0),oldprwin(a4)
  675.         moveq    #-1,d0            ; disable the 'please insert'
  676.         move.l    d0,184(a0)        ; requester
  677.  
  678.         lea    div68000(pc),a0        ; set processor dependent
  679.         btst    #1,297(a6)
  680.         beq.s    9$
  681.         lea    div68020(pc),a0
  682. 9$        move.l    a0,div32(a4)        ; division function!
  683.  
  684.         lea    350(a6),a0        ; necessary libs & devs
  685.         lea    conname(a4),a1
  686.         RECALL    FindName
  687.         move.l    d0,condev(a4)
  688.         lea    378(a6),a0
  689.         lea    gfxname(a4),a1
  690.         RECALL    FindName
  691.         move.l    d0,gfxbase(a4)
  692.         lea    378(a6),a0
  693.         lea    intname(a4),a1
  694.         RECALL    FindName
  695.         move.l    d0,intuibase(a4)
  696.         move.l    d0,a0
  697.         move.l    56(a0),a0        ; ib_ActiveScreen
  698.         move.w    12(a0),d0        ; sc_Width
  699.         add.w    d0,window_l(a4)
  700.         move.b    30(a0),d0        ; sc_Barheight
  701.         add.b    d0,window_l+3(a4)
  702.         sub.b    d0,window_w+3(a4)
  703.  
  704.         bsr    OpenLibsV37        ; Kick 2.0+ libraries
  705.  
  706.         moveq    #0,d0
  707.         lea    xopcon(a4),a0
  708.         bsr    CreatePort
  709.         move.l    d0,replyport(a4)
  710.         moveq    #0,d0
  711.         suba.l    a0,a0
  712.         bsr    CreatePort
  713.         move.l    d0,timerport(a4)
  714.         move.l    d0,a0
  715.         move.b    15(a0),d0
  716.         ext.w    d0
  717.         move.w    d0,timersig(a4)
  718.         lea    timerio(a4),a1
  719.         move.l    a0,14(a1)        ; timerport
  720.         lea    timernam(a4),a0
  721.         moveq    #1,d0
  722.         moveq    #0,d1
  723.         RECALL    OpenDevice        ; open 'timer.device'
  724.  
  725.         tst.b    post_V34(a4)
  726.         beq.s    8$
  727.         lea    newtime(a4),a0
  728.         CALL    ReadEClock,timerio+20(a4)
  729.         move.l    newtime+4(a4),lasttime(a4)
  730.         lsr.l    #8,d0
  731.         bra.s    7$
  732.  
  733. 8$        moveq    #0,d0
  734.         suba.l    a0,a0    
  735.         bsr    CreatePort
  736.         lea    sampleio(a4),a1
  737.         move.l    d0,14(a1)
  738.         lea    timernam(a4),a0
  739.         moveq    #0,d0
  740.         moveq    #0,d1
  741.         RECALL    OpenDevice        ; open 'timer.device'
  742.         lea    sampleio(a4),a1
  743.         move.l    #3599999,32(a1)
  744.         move.w    #9,28(a1)
  745.         RECALL    SendIO
  746.         move.l    #3906,d0
  747.  
  748. 7$        move.l    d0,timerticks(a4)
  749.         bsr    starttasktimer
  750.  
  751. ;assumes sysbase is in a6 !
  752. ;install a counter to determine the amount of cpu-time each task uses.
  753.  
  754.         RECALL    Forbid
  755.  
  756.         moveq    #_LVOSwitch,d0
  757.         lea    myswitch(pc),a0
  758.         exg.l    d0,a0
  759.         move.l    a6,a1
  760.         RECALL    SetFunction
  761.         move.l    d0,OldSwitch(a4)
  762.  
  763.         lea    myaddtask(pc),a0
  764.         move.l    a0,d0
  765.         move.w    #_LVOAddTask,a0
  766.         move.l    a6,a1
  767.         RECALL    SetFunction
  768.         move.l    d0,OldAddTask(a4)
  769.  
  770.         RECALL    Permit
  771.  
  772. ;install a counter for PORT-Interrupts
  773.         lea    iocounter(a4),a1
  774.         move.l    a4,14(a1)
  775.         moveq    #3,d0
  776.         RECALL    AddIntServer
  777.  
  778.         moveq    #$40,d0
  779.         lsl.w    #2,d0            ; 256
  780.         moveq    #-128,d1        ; Pri
  781.         lea    kidlename(a4),a0    ; Name
  782.         lea    killidle(pc),a1        ; Code
  783.         bsr    CreateTask
  784.         move.l    d0,idletask(a4)
  785.  
  786.         bsr    gettdtasks
  787.  
  788. ;prepare screen tags
  789.         moveq    #-1,d0
  790.         RECALL    AllocSignal
  791.         move.l    d0,nspubsig+4(a4)
  792.         move.l    mytask(a4),nspubtask+4(a4)
  793.  
  794. ;install hotkeys
  795.         moveq    #mysigbit,d0
  796.         RECALL    AllocSignal
  797.         bsr    installh
  798.  
  799.         move.l    dosbase(a4),a6
  800.     IFND DEBUG
  801. ;set our 'real' directory - remember old one
  802.         move.l    wblock(a4),d1
  803.         RECALL    CurrentDir
  804.         move.l    d0,wblock(a4)
  805.     ENDC
  806.  
  807. ;attempt to open a startup script
  808.         lea    infile(a4),a2
  809.         lea    dummy(a4),a5
  810.  
  811.         tst.b    noscript(a4)        ; process script?
  812.         bne.s    nostartup
  813.  
  814.         lea    startupname(a4),a0    ; 'ENV:Xoper.Startup'
  815.         move.l    a5,a1
  816. 6$        move.b    (a0)+,(a1)+        ; copy string
  817.         bne.s    6$
  818.         moveq    #4,d1
  819.         add.l    a5,d1
  820.         move.l    #1005,d2
  821.         RECALL    Open            ; 'Xoper.startup'
  822.         move.l    d0,(a2)
  823.         bne.s    5$
  824.         move.l    a5,d1
  825.         RECALL    Open            ; 'ENV:Xoper.Startup'
  826.         move.l    d0,(a2)
  827.         bne.s    5$
  828.         moveq    #2,d1
  829.         move.b    #'S',0(a5,d1.w)
  830.         add.l    a5,d1
  831.         RECALL    Open            ; 'S:Xoper.startup'
  832.         move.l    d0,(a2)
  833.         beq.s    nostartup
  834.  
  835. 5$        movem.l    a2/a5/a6,-(sp)        ; infile, dummy & dosbase
  836.         moveq    #-1,d5
  837. 4$        addq.l    #1,d5
  838.         move.l    (a2),d1
  839.         move.l    a5,d2
  840.         add.l    d5,d2
  841.         moveq    #1,d3
  842.         RECALL    Read
  843.         tst.l    d0
  844.         bgt.s    3$
  845.  
  846.         move.l    (a2),d1
  847.         RECALL    Close
  848.         clr.l    (a2)
  849.         tst.w    d5
  850.         beq.s    1$
  851.         bra.s    2$
  852.  
  853. 3$        cmp.b    #10,0(a5,d5.l)
  854.         beq.s    2$
  855.         cmp.b    #13,0(a5,d5.l)
  856.         bne.s    4$
  857.  
  858. 2$        moveq    #1,d0
  859.         add.l    d5,d0
  860.         bsr    cli             ; execute the script as if typed in
  861. 1$        movem.l    (sp)+,a2/a5/a6
  862.         tst.l    (a2)            ; check infile
  863.         bne.s    5$
  864.  
  865. nostartup    tst.b    wanthold(a4)        ; background task ?
  866.         bne    instback
  867.  
  868. ; This code just opens a Window. Position and size are
  869. ; taken from window_l,window_t,window_w,window_h.
  870.  
  871. restart        move.l    intuibase(a4),a6
  872.         lea    setupwindow(pc),a0
  873.         tst.b    ownscreen(a4)
  874.         beq.s    1$
  875.         clr.b    ownscreen(a4)
  876.         lea    createscreen(pc),a0
  877. 1$        jsr    0(a0)            ; screen and/or window
  878.         move.l    mytask(a4),a0
  879.         clr.l    26(a0)            ; clear 'spurious' signals
  880.         clr.l    ptr(a4)
  881.         tst.b    gotguru(a4)
  882.         beq.s    2$
  883.         bsr    showguru
  884.         clr.b    gotguru(a4)
  885. 2$        bra    processmsgs
  886.  
  887. OpenLibsV37    lea    wbname(a4),a1
  888.         bsr.s    1$            ; open 'workbench.library'
  889.         move.l    d0,wbbase(a4)
  890.         lea    cxname(a4),a1
  891.         bsr.s    1$            ; open 'commodities.library'
  892.         move.l    d0,cxbase(a4)
  893.         rts
  894. 1$        moveq    #37,d0
  895.         jmp    _LVOOpenLibrary(a6)    ; a6 - SysBase !
  896.  
  897. starttasktimer    lea    tsecs(a4),a0
  898.         lea    tmics(a4),a1
  899.         CALL    CurrentTime,intuibase(a4)
  900.         bsr    getaskdat2        ; returns SysBase in a6 !
  901.         move.l    tsecs(a4),d0
  902.         lea    taskstampid(a4),a0
  903.         lea    taskstamps(a4),a1
  904.         lea    usedtime(a4),a2
  905.         moveq    #0,d1
  906. 1$        subq.b    #1,d5
  907.         bmi.s    2$
  908.         lea    -16(a5),a5
  909.         move.l    0(a5),(a0)+
  910.         move.l    d0,(a1)+
  911.         clr.l    (a2)+
  912.         addq.w    #1,d1
  913.         cmp.w    #128,d1
  914.         bmi.s    1$
  915. 2$        move.w    d1,numtaskstimed(a4)
  916.         rts
  917.  
  918. gettdtasks    lea    350(a6),a0        ; a6 - SysBase
  919.         lea    tdname(a4),a1
  920.         RECALL    FindName
  921.         move.l    d0,a0
  922.         move.l    a0,d0
  923.         beq.s    r_t_s
  924.         lea    36(a0),a0
  925.         lea    tdtasks(a4),a1
  926.         moveq    #3,d1
  927. 2$        move.l    (a0)+,d0
  928.         beq.s    1$
  929.         exg.l    d0,a1
  930.         move.l    16(a1),a1
  931.         exg.l    d0,a1
  932. 1$        move.l    d0,(a1)+
  933.         dbra    d1,2$
  934. r_t_s        rts
  935.  
  936. ; exit program 
  937.  
  938. stopall        st    waitexit(a4)        ; wait until pubscr freed
  939.         tst.b    appicn(a4)
  940.         beq.s    exitall
  941.         move.l    wnptr(a4),a0        ; remove appicon here
  942.         CALL    RemoveAppIcon,wbbase(a4)
  943.         clr.l    wnptr(a4)
  944.  
  945. exitall        tst.b    ownscreen(a4)
  946.         beq.s    6$            ; no screen == no pub screen !
  947.         st    wantexit(a4)
  948.         bsr    SetPubStatus
  949.         beq.s    r_t_s            ; pubscreen still used
  950.  
  951. 6$        move.l    mytask(a4),a2
  952.         clr.l    88(a2)            ; disable killing !
  953.  
  954.         moveq    #1,d0
  955.         bsr    CloseGUI        ; close screen & window
  956.  
  957.         bsr    killpage
  958.         bsr    freeblank
  959.         bsr    killhistory
  960.         bsr    freehidmem
  961.         bsr    freealias
  962.         bsr    clrfkeys
  963.  
  964. 5$        move.l    stplist(a4),a3
  965.         tst.l    0(a3)
  966.         beq.s    4$
  967.         move.l    a3,d0
  968.         bsr    waok
  969.         bra.s    5$
  970.  
  971. 4$        bsr    remtraps
  972.         bsr    removeh
  973.  
  974.         move.l    idletask(a4),a1
  975.         CALL    RemTask,sysbase(a4)
  976.  
  977.         st    waitexit(a4)
  978.         st    bool(a4)
  979.  
  980. 36$        tst.b    bool(a4)
  981.         beq.s    33$            ; exec patches removed !
  982.         RECALL    Forbid
  983.         tst.b    patchmode(a4)
  984.         beq.s    35$            ; don't check vectors
  985.         lea    myswitch(pc),a0
  986.         cmp.l    _LVOSwitch+2(a6),a0
  987.         bne.s    34$
  988.         lea    myaddtask(pc),a0
  989.         cmp.l    _LVOAddTask+2(a6),a0
  990.         bne.s    34$
  991. 35$        move.l    OldSwitch(a4),d0
  992.         move.w    #_LVOSwitch,a0
  993.         move.l    a6,a1
  994.         RECALL    SetFunction
  995.         move.l    OldAddTask(a4),d0
  996.         move.w    #_LVOAddTask,a0
  997.         move.l    a6,a1
  998.         RECALL    SetFunction
  999.         clr.b    bool(a4)
  1000. 34$        RECALL    Permit
  1001.  
  1002. 33$        bsr    snoopend        ; mem trace
  1003.         bsr    traceend        ; dos trace
  1004.  
  1005.         move.b    bool(a4),d0        ; exec -> switch,addtask
  1006.         add.b    msnoop(a4),d0        ; exec -> memory
  1007.         add.b    DosTable+5(a4),d0    ; dos  -> open
  1008.         add.b    DosTable+25(a4),d0    ; dos  -> lock
  1009.         beq.s    32$            ; zero == all removed
  1010.         moveq    #0,d0
  1011.         move.l    mysignal(a4),d1
  1012.         CALL    SetSignal,sysbase(a4)
  1013.         st    pcheck(a4)        ; enable checking ...
  1014.         move.l    mysignal(a4),d0
  1015.         RECALL    Wait            ; wait for intr signal
  1016.         bra.s    36$            ; try again ...
  1017.  
  1018. 32$        lea    iocounter(a4),a1
  1019.         moveq    #3,d0
  1020.         RECALL    RemIntServer
  1021.  
  1022.         move.l    replyport(a4),d0
  1023.         bsr    DeletePort
  1024.         bsr    stoptimer
  1025.         lea     timerio(a4),a1
  1026.         CALL    CloseDevice,sysbase(a4)
  1027.         move.l    timerport(a4),d0
  1028.         bsr    DeletePort
  1029.  
  1030.         tst.b    post_V34(a4)
  1031.         bne.s    3$
  1032.         lea    sampleio(a4),a1
  1033.         CALL    AbortIO,sysbase(a4)
  1034.         lea    sampleio(a4),a1
  1035.         move.l    14(a1),d7
  1036.         RECALL    CloseDevice
  1037.         move.l    d7,d0
  1038.         bsr    DeletePort
  1039.  
  1040. 3$        bsr    CloseLibsV37        ; close Kick 2.0+ libraries
  1041.  
  1042.         move.l    dosbase(a4),a6
  1043.         move.l    infile(a4),d1
  1044.         beq.s    2$
  1045.         RECALL    Close
  1046.  
  1047. 2$
  1048.     IFND DEBUG
  1049.         move.l    wblock(a4),d1
  1050.         RECALL    CurrentDir
  1051.         move.l    d0,d1
  1052.         RECALL    UnLock
  1053.         move.l    myseg(a4),d1
  1054.         RECALL    UnLoadSeg
  1055.     ENDC
  1056.  
  1057.         move.l    mytask(a4),a2
  1058.         move.l    oldprwin(a4),184(a2)    ; reset to old value
  1059.  
  1060.         move.l    realstack(a4),sp
  1061.         moveq    #0,d0
  1062.         rts
  1063.  
  1064. CloseLibsV37    move.l    sysbase(a4),a6
  1065.         move.l    cxbase(a4),a1        ; commodities base
  1066.         bsr.s    2$
  1067.         move.l    wbbase(a4),a1        ; workbench base
  1068. 2$        move.l    a1,d0
  1069.         beq.s    1$            ; no lib
  1070.         RECALL    CloseLibrary
  1071. 1$        rts
  1072.  
  1073. ;show a list. The string entered from keyboard is stored
  1074. ;in 'in'. Every character is interpreted as one command
  1075. ;i.e. 'rip' means 'resources'+'interrupts'+'ports'.
  1076. ;search the command to be executed. If none is found,
  1077. ;show a help message
  1078.  
  1079. showwhat    tst.l    infile(a4)
  1080.         bne.s    nomore
  1081.         move.w    cmdptr(a4),d7
  1082.  
  1083. input        lea    in(a4),a0
  1084.         move.b    0(a0,d7.w),d0
  1085.         beq.s    endshow
  1086.         addq.w    #1,d7
  1087.         cmpi.b    #' ',d0
  1088.         bne.s    i1
  1089.         bsr.s    testifend
  1090.         beq.s    endshow
  1091.         move.w    d2,cmdptr(a4)
  1092.         bra.s    endshow2
  1093.  
  1094. i1        cmpi.b    #10,d0
  1095.         beq.s    endshow
  1096.         or.b    #32,d0
  1097.         cmpi.b    #'q',d0
  1098.         beq    quithold
  1099.         lea    params(a4),a0
  1100.         moveq    #parmnum-1,d1
  1101. i2        cmp.b    0(a0,d1.w),d0
  1102.         beq.s    foundp
  1103.         dbra    d1,i2
  1104.         move.w    #usetxt,d0
  1105.         bsr    putnamw
  1106.         bra.s    endshow
  1107.  
  1108. foundp        lea    subs(pc),a0
  1109.         lsl.w    #2,d1
  1110.         jsr    0(a0,d1.w)
  1111.         bsr.s    testifend
  1112.         beq.s    input
  1113.         bsr    newline
  1114.         bra.s    input
  1115.  
  1116. endshow        clr.w    cmdptr(a4)
  1117. endshow2    bsr    starttimer
  1118. nomore        tst.l    infile(a4)
  1119.         bne.s    1$
  1120.         clr.l    lastprinted(a4)
  1121.         bsr    blastout
  1122. 1$        rts
  1123.  
  1124. testifend    lea    in(a4),a0
  1125.         lea    0(a0,d7.w),a0
  1126.         move.w    d7,d2
  1127. 2$        move.b    (a0)+,d0
  1128.         beq.s    1$
  1129.         cmpi.b    #' ',d0
  1130.         bne.s    3$
  1131.         addq.w    #1,d2
  1132.         bra.s    2$
  1133. 3$        cmpi.b    #10,d0
  1134. 1$        rts
  1135.  
  1136. ;get the string from inputbuffer; search and execute
  1137. ;the command, if any.
  1138.  
  1139. cli        lea    dummy(a4),a0
  1140.         subq.w    #1,d0
  1141. cl2        subq.w    #1,d0
  1142.         bmi.s    cl1
  1143.         cmp.b    #' ',0(a0,d0.w)
  1144.         beq.s    cl2
  1145. cl1        addq.w    #1,d0
  1146.         move.b    #10,0(a0,d0.w)
  1147.         bsr    kllblnks        ; remove trailing blanks ... !
  1148.         cmpi.b    #10,0(a0)
  1149.         beq    showwhat
  1150.         cmpi.b    #';',0(a0)
  1151.         beq.s    nomore
  1152.  
  1153.         bsr.s    findcmd
  1154.         tst.l    d2
  1155.         bpl.s    okcmd            ; cmd found
  1156.         bsr.s    findalias
  1157.         tst.l    d2
  1158.         bmi.s    nm0            ; no alias
  1159. okcmd        clr.w    procnum(a4)
  1160.         adda.w    d1,a0
  1161.         bsr    kllblnks
  1162.         lea    cmdaddr(pc),a1
  1163.         lsl.w    #2,d2
  1164.         jsr     0(a1,d2.w)
  1165.         bra.s    nomore
  1166.  
  1167. nm0        moveq    #10,d1            ; LineFeed
  1168.         lea    in(a4),a1
  1169.         lea    buffer(a4),a2
  1170.         movem.l    a1/a2,-(sp)        ; store for later use
  1171. nm1        move.b    (a1),(a2)+        ; in -> buffer
  1172.         cmp.b    (a1)+,d1        ; LF ?
  1173.         bne.s    nm1
  1174.         move.l    (sp)+,a1
  1175. nm2        move.b    (a0),(a1)+        ; cmd -> in
  1176.         cmp.b    (a0)+,d1        ; LF ?
  1177.         bne.s    nm2
  1178.         move.l    (sp)+,a1
  1179.         lea    dummy(a4),a2
  1180. nm3        move.b    (a1),(a2)+        ; buffer -> dummy
  1181.         cmp.b    (a1)+,d1        ; LF ?
  1182.         bne.s    nm3
  1183.         clr.w    cmdptr(a4)
  1184.         bra    showwhat
  1185.  
  1186. findcmd        move.l    a0,-(sp)
  1187.         bsr    strbuf
  1188.         lea    commds(a4),a2
  1189.         moveq    #0,d2
  1190. 1$        lea    buffer(a4),a0
  1191.         move.l    a2,a1
  1192.         bsr    strcmp
  1193.         beq.s    3$
  1194. 2$        tst.b    (a2)+
  1195.         bne.s    2$
  1196.         addq.w    #1,d2
  1197.         cmp.w    #cmdnum,d2
  1198.         bne.s    1$
  1199.         moveq    #-1,d2
  1200. 3$        move.l    (sp)+,a0
  1201.         rts
  1202.  
  1203. findalias    move.l    a0,-(sp)
  1204.         lea    aliaslist(a4),a2
  1205. 1$        move.l    0(a2),d2
  1206.         move.l    d2,a2
  1207.         beq.s    3$
  1208.         lea    buffer(a4),a0
  1209.         lea    5(a2),a1
  1210.         move.b    4(a2),d2
  1211.         ext.w    d2
  1212.         ext.l    d2
  1213.         bsr    strcmp
  1214.         beq.s    4$
  1215.         bra.s    1$
  1216. 3$        moveq    #-1,d2
  1217. 4$        move.l    (sp)+,a0
  1218.         rts
  1219.  
  1220. subs        bra    showtask
  1221.         bra    showaddr
  1222.         bra    showdevs
  1223.         bra    showlibs
  1224.         bra    showres
  1225.         bra    showresi
  1226.         bra    showmem
  1227.         bra    showprt
  1228.         bra    showint
  1229.         bra    stack
  1230.         bra    clicomm
  1231.         bra    tasktime
  1232.         bra    semaphores
  1233. cmdaddr     bra    settime
  1234.         bra    taskpri
  1235.         bra    info
  1236.         bra    pri
  1237.         bra    flush
  1238.         bra    freeze
  1239.         bra    warm
  1240.         bra    signal
  1241.         bra    break
  1242.         bra    alert
  1243.         bra    lastalert
  1244.         bra    instback
  1245.         bra    exitall
  1246.         bra    clear
  1247.         bra    cancel
  1248.         bra    taskports
  1249.         bra    hunks
  1250.         bra    devices
  1251.         bra    openlib
  1252.         bra    closelib
  1253.         bra    currentdir
  1254.         bra    cd
  1255.         bra    mypri
  1256.         bra    openfiles
  1257.         bra    locks
  1258.         bra    unlock
  1259.         bra    screens
  1260.         bra    windows
  1261.         bra    closescreen
  1262.         bra    closewindow
  1263.         bra    fonts
  1264.         bra    windowfonts
  1265.         bra    lockdrive
  1266.         bra    freedrive
  1267.         bra    capture
  1268.         bra    clrcold
  1269.         bra    clrcool
  1270.         bra    clrwarm
  1271.         bra    snoop
  1272.         bra    usage
  1273.         bra    inputhandler
  1274.         bra    nohead
  1275.         bra    sort
  1276.         bra    hide
  1277.         bra    hidden
  1278.         bra    setwindow
  1279.         bra    cancel
  1280.         bra    icongad
  1281.         bra    historylines
  1282.         bra    historylength
  1283.         bra    showhistory
  1284.         bra    repeatcmd
  1285.         bra    remresident
  1286.         bra    saveoutput
  1287.         bra    killhistory
  1288.         bra    iconbackdrp
  1289.         bra    myfont
  1290.         bra    setfont
  1291.         bra    trapguru
  1292.         bra    outputlines
  1293.         bra    usescreen
  1294.         bra    usewindow
  1295.         bra    usetopaz
  1296.         bra    grabtimerio
  1297.         bra    dchange
  1298.         bra    alias
  1299.         bra    remnode
  1300.         bra    setfkey
  1301.         bra    clicmd
  1302.         bra    taskinfo
  1303.         bra    coldreboot
  1304.         bra    reboot
  1305.         bra    zerotimer
  1306.         bra    propgad
  1307.         bra    iconpos
  1308.         bra    remport
  1309.         bra    remintserver
  1310.         bra    frags
  1311.         bra    tracefiles
  1312.         bra    tracelocks
  1313.         bra    cxhandler
  1314.         bra    cxpopkey
  1315.         bra    pubscreens
  1316.         bra    smartpatch
  1317.         bra    lowmemhandler
  1318.  
  1319. ;------ Task-Structures-----
  1320.  
  1321. tasktime    moveq    #-1,d0
  1322.         bra.s    startask
  1323. showaddr    moveq    #0,d0
  1324.         bra.s    startask
  1325. showtask    moveq    #1,d0
  1326. startask    move.b    d0,tasktyp(a4)
  1327.         bsr    getdevhan
  1328.         tst.b    headon(a4)
  1329.         beq.s    noheader1
  1330.         move.w    #infoh1,d0
  1331.         bsr    putstrw
  1332.         move.l    sysbase(a4),a6
  1333.         move.w    296(a6),d1        ; AttnFlags
  1334.         move.w    #cpu4,d0
  1335.         btst    #3,d1            ; mc 68040 ?
  1336.         bne.s    cpupr
  1337.         subq.w    #cpu4-cpu3,d0
  1338.         btst    #2,d1            ; mc 68030 ?
  1339.         bne.s    cpupr
  1340.         subq.w    #cpu3-cpu2,d0
  1341.         btst    #1,d1            ; mc 68020 ?
  1342.         bne.s    cpupr
  1343.         subq.w    #cpu2-cpu1,d0
  1344.         btst    #0,d1            ; mc 68010 ?
  1345.         bne.s    cpupr
  1346.         subq.w    #cpu1-cpu0,d0        ; mc 68000 !
  1347. cpupr        bsr    putstrw
  1348.         move.l    d0,d1
  1349.         move.w    #cpu6,d0
  1350.         btst    #5,297(a6)        ; mc 68882 ?
  1351.         bne.s    fpupr
  1352.         move.l    d1,d0
  1353.         btst    #4,297(a6)        ; mc 68881 ?
  1354.         beq.s    no881
  1355.         subq.w    #cpu6-cpu5,d0
  1356. fpupr        bsr    putstrw
  1357. no881        moveq    #20,d1
  1358.         bsr    tab
  1359.         move.w    #infoh3,d0
  1360.         bsr    putstrw
  1361.  
  1362. noheader1    moveq    #1,d5
  1363.         bsr    getaskdat
  1364.         move.l    a5,savedat(a4)
  1365.         bsr    getstdio
  1366.  
  1367.         lea    usedtime(a4),a0
  1368.         moveq    #0,d4
  1369.         moveq    #0,d3
  1370.         move.l    idletask(a4),d2
  1371.         moveq    #0,d1
  1372.         move.b    entries(a4),d1
  1373.         subq.w    #1,d1
  1374. 1$        lea    -16(a5),a5
  1375.         move.l    12(a5),d5
  1376.         add.l    d5,d4
  1377.         move.l    0(a5),d0
  1378.         cmp.l    d0,d2
  1379.         bne.s    2$
  1380.         move.l    d5,d3
  1381. 2$        bsr    gettimeentry
  1382.         add.l    d5,0(a0,d0.w)
  1383.         dbra    d1,1$
  1384.         move.l    d4,maxdisp(a4)
  1385.         sub.l    d3,d4
  1386.         move.l    d4,dispatches(a4)
  1387.  
  1388.         tst.b    headon(a4)
  1389.         beq.s    noheader2
  1390.         move.l    dispatches(a4),d0
  1391.         move.l    maxdisp(a4),d1
  1392.         bsr    prcent
  1393.         bsr    newline
  1394.         move.w    #infoh2,d0
  1395.         bsr    putstrw
  1396.  
  1397. noheader2    move.l    sysbase(a4),a0
  1398.         move.l    284(a0),d0        ; DispCount
  1399.         move.l    oldswitches(a4),d1
  1400.         move.l    d0,oldswitches(a4)
  1401.         sub.l    d1,d0
  1402.         tst.b    headon(a4)
  1403.         beq.s    noheader3
  1404.         mulu    #100,d0
  1405.         move.l    d0,-(sp)
  1406.         lea    secs(a4),a0
  1407.         lea    mics(a4),a1
  1408.         CALL    CurrentTime,intuibase(a4)
  1409.         move.l    secs(a4),d3
  1410.         add.l    d3,d3
  1411.         move.l    d3,d1
  1412.         lsl.l    #2,d3
  1413.         add.l    d1,d3
  1414.         move.l    mics(a4),d0
  1415.         move.l    #100000,d1
  1416.         bsr    div
  1417.         add.l    d0,d3
  1418.         move.l    time10(a4),d1
  1419.         move.l    d3,time10(a4)
  1420.         sub.l    d1,d3
  1421.         move.l    (sp)+,d0
  1422.         move.l    d3,-(sp)
  1423.         move.l    d3,d1
  1424.         bsr    div
  1425.         moveq    #1,d5
  1426.         bsr    putfrac
  1427.  
  1428.         moveq    #20,d1
  1429.         bsr    tab
  1430.         move.w    #infoh7,d0
  1431.         bsr    putstrw
  1432.         move.l    iocount(a4),d0
  1433.         clr.l    iocount(a4)
  1434.         mulu    #100,d0
  1435.         move.l    (sp)+,d3
  1436.         move.l    d3,d1
  1437.         bsr    div
  1438.         moveq    #1,d5
  1439.         bsr    putfrac
  1440.  
  1441.         bsr    newline
  1442.         bsr    newline
  1443.  
  1444. noheader3    lea    t4header(a4),a0
  1445.         tst.b    tasktyp(a4)
  1446.         bmi.s    phedder
  1447.         lea    theader(a4),a0
  1448.         tst.b    tasktyp(a4)
  1449.         bne.s    phedder
  1450.         lea    t2header(a4),a0
  1451.         move.l    sysbase(a4),a6
  1452.         btst    #4,297(a6)        ; AttnFlags FPU ?
  1453.         bne.s    phedder
  1454.         lea    t3header(a4),a0
  1455. phedder     bsr    puthead
  1456.         move.l    savedat(a4),a5
  1457.  
  1458. pt1        tst.b    entries(a4)
  1459.         beq    pt2
  1460.         lea    -16(a5),a5
  1461.         bsr    hideit
  1462.         beq    ptend
  1463.         move.l    0(a5),a3
  1464.         cmp.l    idletask(a4),a3
  1465.         beq    ptend
  1466.         move.l    a3,node(a4)        ; ID = task address
  1467.         move.l    a3,d0
  1468.         bsr    hexa
  1469.         tst.b    tasktyp(a4)
  1470.         ble.s    pt12
  1471.         moveq    #0,d0
  1472.         move.b    8(a3),d0
  1473.         bsr    gettype
  1474.  
  1475. pt12        moveq    #0,d0
  1476.         move.b    9(a5),d0
  1477.         subq.w    #1,d0
  1478.         mulu    #9,d0
  1479.         move.w    #status,d1
  1480.         add.w    d1,d0
  1481.         bsr    putstrw            ; state
  1482.         tst.b    tasktyp(a4)
  1483.         beq.s    pt345
  1484.         bpl    pt13
  1485.  
  1486.         move.l    0(a5),d0        ; for usage !
  1487.         bsr    gettimeentry
  1488.         lea    taskstamps(a4),a0
  1489.         lea    0(a0,d0.w),a0
  1490.         move.l    secs(a4),d0
  1491.         sub.l    0(a0),d0
  1492.         bsr    putstamp
  1493.         bsr    putblank
  1494.         move.l    usedtime-taskstamps(a0),d0
  1495.         move.l    timerticks(a4),d1
  1496.         bsr    div
  1497.         bsr    putstamp
  1498.         moveq    #'.',d0
  1499.         bsr    putchar
  1500.         move.l    d1,d0
  1501.         move.l    timerticks(a4),d1
  1502.         addq.w    #5,d1
  1503.         divu    #10,d1
  1504.         divu    d1,d0
  1505.         or.b    #'0',d0
  1506.         bsr    putchar
  1507.         bsr    putblank
  1508.         bra    pt346
  1509.  
  1510. pt345        move.l    18(a3),d0        ; SigAlloc
  1511.         bsr    hexa
  1512.         move.w    #longnix,d0
  1513.         cmp.b    #4,9(a5)        ; tc_state waiting ?
  1514.         beq.s    pt14
  1515.         bsr    putstrw
  1516.         bra.s    pt15
  1517.  
  1518. pt14        move.l    22(a3),d0        ; SigWait
  1519.         bsr    hexa
  1520. pt15        move.l    26(a3),d0        ; SigRecvd
  1521.         bsr    hexa
  1522.  
  1523.         move.w    #nofpu,d1        ; assume no FPU
  1524.         move.l    sysbase(a4),a6
  1525.         btst    #4,297(a6)        ; AttnFlags FPU ?
  1526.         beq.s    prt154
  1527.         move.w    #nullstate,d1        ; assume FPU null-state
  1528. prt154        lea    prt154(pc),a1
  1529.         move.l    a1,d0
  1530.         cmp.b    #2,9(a5)        ; tc_state running ?
  1531.         beq.s    pt16            ; can only be xoper itself
  1532.  
  1533.         moveq    #0,d0            ; 0(sp) -> pc when no FPU
  1534.         move.l    54(a3),a1        ; tc_SPReg
  1535.         btst    #4,297(a6)        ; AttnFlags FPU
  1536.         beq.s    prt151            ; no FPU
  1537.  
  1538.         tst.b    (a1)            ; NULL frame ?
  1539.         beq.s    prt150            ; yes
  1540.  
  1541.         move.w    (a1),d0            ; frame flag / format word
  1542.         lea    110(a1),a1        ; offset for fpu regs
  1543.         cmp.w    #-1,d0
  1544.         beq.s    prt153
  1545.         lea    12(a1),a1        ; 3 more longs
  1546.  
  1547. prt153        moveq    #0,d0
  1548.         move.b    1(a1),d0        ; frame size
  1549.         move.l    4(a1,d0.w),d0        ; pc
  1550.  
  1551.         move.w    #idle,d1
  1552.         cmp.b    #$18,1(a1)        ; mc 68881 idle ?
  1553.         beq.s    pt16
  1554.         addq.w    #busy-idle,d1
  1555.         cmp.b    #$b4,1(a1)        ; mc 68881 busy ?
  1556.         beq.s    pt16
  1557. prt152        addq.w    #dontknow-busy,d1    ; maybe mc 68882 ??
  1558.         bra.s    pt16
  1559.  
  1560. prt150        moveq    #4,d0            ; offset NULL frame
  1561. prt151        move.l    0(a1,d0.w),d0        ; n(sp) -> pc
  1562.  
  1563. pt16        bsr    hexa
  1564.  
  1565.         move.l    sysbase(a4),a6
  1566.         btst    #4,297(a6)        ; AttnFlags FPU ?
  1567.         beq.s    pt4
  1568.  
  1569.         move.w    d1,d0            ; fpu state
  1570.         bsr    putstrw
  1571.         bra.s    pt4
  1572.  
  1573. pt13        move.b    10(a5),d3        ; tc_Pri
  1574.         bsr    plusmins
  1575.  
  1576.         move.l    12(a5),d0
  1577.         move.l    dispatches(a4),d1
  1578.         tst.b    useageon(a4)
  1579.         beq.s    pt37
  1580.         move.l    maxdisp(a4),d1
  1581. pt37        bsr    prcent
  1582.  
  1583. pt346        cmpi.b    #13,8(a5)        ; num
  1584.         bne.s    noproc
  1585.         tst.l    172(a3)
  1586.         beq.s    noproc
  1587.         move.b    11(a5),d3
  1588.         bsr    bytedec
  1589.         bra.s    pt4
  1590. noproc        move.w    #nix,d0
  1591.         bsr    putstrw
  1592.  
  1593. pt4        bsr    gettaskname        ; taskname
  1594.  
  1595.         tst.b    tinfo(a4)
  1596.         beq    pt223
  1597.  
  1598.         tst.b    cliexec(a4)        ; display 'real' taskname if
  1599.         beq.s    10$             ; it is a CLI
  1600.         bsr    putblank
  1601.         move.l    4(a5),d0
  1602.         bsr    putstr
  1603.  
  1604. 10$        lea    tdtasks(a4),a1        ; a trackdisk.device ?
  1605.         moveq    #3,d3
  1606. 1$        cmp.l    (a1)+,a3
  1607.         dbeq    d3,1$
  1608.         bne.s    pt224
  1609.  
  1610.         eor.b    #'0'+3,d3        ; print unit#
  1611.         move.b    d3,unitmsg+8(a4)
  1612.         move.w    #unitmsg,d0
  1613.         bsr    putstrw
  1614.  
  1615. pt224        moveq    #0,d3            ; is it a device handler ?
  1616.         lea    buffer+2400(a4),a2
  1617.         lea    200(a2),a1
  1618.  
  1619. 1$        move.l    (a2)+,d0
  1620.         beq.s    pt222
  1621.         move.l    (a1)+,d2
  1622.         cmp.l    0(a5),d0
  1623.         bne.s    1$
  1624.  
  1625. 2$        move.l    #' {',d0        ; print dos devicename
  1626.         bsr    putlongascii
  1627.         move.l    d2,d0
  1628.         bsr    putbcpl
  1629.         move.l    #':}',d0
  1630.         bsr    putlongascii
  1631.  
  1632. pt222        lea    buffer+2160(a4),a1    ; is it a device handler for
  1633.         lea    160(a1),a2        ; some CLI input/output ?
  1634.         moveq    #0,d5
  1635.  
  1636. 3$        move.l    (a1)+,d0
  1637.         beq.s    4$
  1638.         move.w    (a2)+,d2
  1639.         cmp.l    0(a5),d0
  1640.         bne.s    3$
  1641.  
  1642.         tst.w    d5
  1643.         bne.s    5$
  1644.         move.l    #' (',d0        ; print CLI#
  1645.         bsr    putlongascii
  1646.         bra.s    6$
  1647. 5$        move.l    #'& ',d0
  1648.         bsr    putlongascii
  1649. 6$        moveq    #1,d5
  1650.         moveq    #'<',d0
  1651.         tst.w    d2
  1652.         bmi.s    7$
  1653.         moveq    #'>',d0
  1654. 7$        bsr    putchar
  1655.         move.l    #'CLI ',d0
  1656.         bsr    putlongascii
  1657.         moveq    #0,d0
  1658.         move.b    d2,d0
  1659.         moveq    #0,d3
  1660.         bsr    longdec
  1661.         bra.s    3$
  1662.  
  1663. 4$        tst.w    d5
  1664.         beq.s    pt223
  1665.         subq.l    #1,ptr(a4)
  1666.         moveq    #')',d0
  1667.         bsr    putchar
  1668.  
  1669. pt223        bsr    newline
  1670.  
  1671. ptend        subq.b    #1,entries(a4)
  1672.         bra    pt1
  1673. pt2        rts
  1674.  
  1675. getdevhan    tst.b    tinfo(a4)
  1676.         beq.s    4$
  1677.         move.l    a3,-(sp)
  1678.         bsr    devinfo
  1679.         moveq    #49,d3
  1680.         lea    buffer+2400(a4),a2
  1681.         lea    200(a2),a3
  1682. 1$        adda.l    a1,a1
  1683.         adda.l    a1,a1
  1684.         tst.l    4(a1)
  1685.         bne.s    3$
  1686.         move.l    8(a1),d0
  1687.         beq.s    3$
  1688.         moveq    #92,d1
  1689.         sub.l    d1,d0
  1690.         move.l    d0,(a2)+
  1691.         move.l    40(a1),(a3)+
  1692.         subq.w    #1,d3
  1693.         beq.s    2$
  1694. 3$        move.l    0(a1),d0
  1695.         beq.s    2$
  1696.         move.l    d0,a1
  1697.         bra.s    1$
  1698. 2$        clr.l    (a2)+
  1699.         move.l    (sp)+,a3
  1700. 4$        rts
  1701.  
  1702. getstdio    tst.b    tinfo(a4)
  1703.         beq.s    4$
  1704.         move.l    a5,-(sp)
  1705.         lea    buffer+2160(a4),a0
  1706.         lea    160(a0),a1
  1707.         moveq    #0,d3
  1708.         move.b    entries(a4),d3
  1709.         subq.w    #1,d3
  1710.         moveq    #40,d4
  1711. 3$        lea    -16(a5),a5
  1712.         cmpi.b    #13,8(a5)
  1713.         bne.s    1$
  1714.         RECALL    Forbid
  1715.         move.l    0(a5),a3
  1716.         move.l    140(a3),d2        ; pr_TaskNum
  1717.         beq.s    6$
  1718.         move.l    172(a3),d0        ; pr_CLI
  1719.         beq.s    6$
  1720.         move.l    160(a3),d0        ; pr_COS
  1721.         beq.s    2$
  1722.         bsr.s    getstdio2
  1723. 2$        or.w    #$8000,d2
  1724.         move.l    156(a3),d0        ; pr_CIS
  1725.         beq.s    6$
  1726.         bsr.s    getstdio2
  1727. 6$        RECALL    Permit
  1728.         tst.w    d4
  1729.         ble.s    7$
  1730. 1$        dbra    d3,3$
  1731. 7$        clr.l    (a0)+
  1732.         move.l    (sp)+,a5
  1733. 4$        rts
  1734.  
  1735. getstdio2    lsl.l    #2,d0            ; make APTR
  1736.         move.l    d0,a2
  1737.         and.b    #-4,d0
  1738.         cmp.l    a2,d0            ; LW aligned?
  1739.         bne.s    1$
  1740.         move.l    8(a2),d0        ; fh_Type
  1741.         ble.s    1$            ; negative = plain file
  1742.         move.l    d0,a2
  1743.         move.l    16(a2),d0        ; mp_SigTask
  1744.         beq.s    1$
  1745.         move.l    d0,(a0)+
  1746.         move.w    d2,(a1)+
  1747.         subq.w    #1,d4
  1748. 1$        rts
  1749.  
  1750. getaskdat    move.l    d5,-(sp)
  1751.         bsr.s    getaskdat2
  1752.         move.b    d5,entries(a4)
  1753.         move.l    (sp)+,d5
  1754.         beq.s    1$
  1755.         clr.w    tasksnum(a4)
  1756. 1$        moveq    #16,d2
  1757.         lea    -32(a5),a2
  1758.         bsr.s    sortlist
  1759.         rts
  1760.  
  1761. sortlist    tst.b    sorton(a4)
  1762.         beq.s    sort5
  1763.         lea    buffer(a4),a1
  1764. sort1        lea    0(a1,d2.w),a3
  1765. sort2        move.l    0(a1),d1
  1766.         cmp.l    0(a3),d1
  1767.         bge.s    sort3
  1768.         move.l    d2,d1
  1769.         subq.w    #1,d1
  1770. sort4        move.b    0(a3,d1.w),d0
  1771.         move.b    0(a1,d1.w),0(a3,d1.w)
  1772.         move.b    d0,0(a1,d1.w)
  1773.         dbra    d1,sort4
  1774. sort3        lea    0(a3,d2.w),a3
  1775.         cmp.l    a2,a3
  1776.         ble.s    sort2
  1777.         lea    0(a1,d2.w),a1
  1778.         cmp.l    a2,a1
  1779.         bne.s    sort1
  1780. sort5        rts
  1781.  
  1782. getaskdat2    move.l    sysbase(a4),a6
  1783.         lea    buffer(a4),a5
  1784. getaskdat3    moveq    #0,d5
  1785.         move.w    #$4000,$dff09a
  1786.         lea    stplist(a4),a3
  1787.         bsr.s    putlist
  1788.         lea    420(a6),a3        ; SysBase->TaskWait
  1789.         bsr.s    putlist
  1790.         lea    406(a6),a3        ; SysBase->TaskReady
  1791.         bsr.s    putlist
  1792.         move.l    276(a6),a3        ; SysBase->ThisTask
  1793.         bsr.s    putdata
  1794. 1$        move.w  #$C000,$dff09a
  1795.         rts
  1796.  
  1797. putlist        move.l    0(a3),a3
  1798.         tst.l    0(a3)
  1799.         beq.s    endlist
  1800.         bsr.s    putdata
  1801.         bra.s    putlist
  1802. endlist     rts
  1803.  
  1804. putdata     move.l    a3,(a5)+        ;  +0 = task node
  1805.         move.l    10(a3),(a5)+        ;  +4 = task->ln_Name
  1806.         move.b    8(a3),(a5)+        ;  +8 = task->ln_Type
  1807.         move.b    15(a3),(a5)+        ;  +9 = task->tc_State
  1808.         move.b    9(a3),(a5)+        ; +10 = task->ln_Pri
  1809.         move.b    143(a3),(a5)+        ; +11 = Process->pr_Tasknum
  1810.         move.w    tasksnum(a4),d0
  1811.         lea    cputime(a4),a0
  1812.         bra.s    pua2
  1813. pua3        move.l    500(a0),d1
  1814.         cmp.l    (a0)+,a3
  1815.         beq.s    pua1
  1816. pua2        dbra    d0,pua3
  1817.         moveq    #0,d1
  1818. pua1        move.l    d1,(a5)+        ; +12 = task time
  1819.         addq.w    #1,d5
  1820.         rts
  1821.  
  1822. alloctaskbuf    move.l    #2800,d0
  1823.         moveq    #0,d1
  1824.         CALL    AllocMem,sysbase(a4)
  1825.         move.l    d0,a5
  1826.         move.l    a5,d0
  1827.         beq.s    1$
  1828.         move.l    d0,-(sp)
  1829.         bsr    getaskdat3
  1830.         move.l    (sp)+,d0
  1831. 1$        rts
  1832.  
  1833. freetaskbuf    move.l    a5,a1
  1834.         move.l    #2800,d0
  1835.         CALL    FreeMem,sysbase(a4)
  1836.         rts
  1837.  
  1838. cleanuptimers    bsr.s    alloctaskbuf
  1839.         beq.s    2$
  1840.         moveq    #0,d1
  1841.         lea    taskstampid(a4),a1
  1842. 1$        lea    -16(a5),a5
  1843.         move.l    0(a5),d0
  1844.         bsr.s    gettimeentry
  1845.         lea    taskstampid(a4),a3
  1846.         lea    0(a3,d0.w),a3
  1847.         move.l    0(a3),d2
  1848.         move.l    0(a1),0(a3)
  1849.         move.l    d2,(a1)
  1850.         move.l    taskstamps-taskstampid(a3),d2
  1851.         move.l    taskstamps-taskstampid(a1),taskstamps-taskstampid(a3)
  1852.         move.l    d2,taskstamps-taskstampid(a1)
  1853.         move.l    usedtime-taskstampid(a3),d2
  1854.         move.l    usedtime-taskstampid(a1),usedtime-taskstampid(a3)
  1855.         move.l    d2,usedtime-taskstampid(a1)
  1856.         addq.l    #4,a1
  1857.         addq.w    #1,d1
  1858.         subq.b    #1,d5
  1859.         bne.s    1$
  1860.         move.w    d1,numtaskstimed(a4)
  1861.         bsr.s    freetaskbuf
  1862. 2$        rts
  1863.  
  1864. gettimeentry    movem.l    d1/a0/a1,-(sp)
  1865.         lea    taskstampid(a4),a1
  1866.         lea    4(a1),a0
  1867.         move.w    numtaskstimed(a4),d1
  1868.         subq.w     #1,d1
  1869. 1$        cmp.l    (a1)+,d0
  1870.         dbeq    d1,1$
  1871.         sub.l    a0,a1
  1872.         move.l    a1,d0
  1873.         movem.l    (sp)+,d1/a0/a1
  1874.         rts
  1875.  
  1876. getaskname2    movem.l    a3/a5,-(sp)
  1877.         link    a2,#-10
  1878.         move.l    sp,a5
  1879.         move.l    d0,a3
  1880.         tst.l    d0
  1881.         bne.s    2$
  1882.         bsr    putstr
  1883.         bra.s    1$
  1884. 2$        move.b    8(a3),8(a5)
  1885.         move.l    10(a3),4(a5)
  1886.         bsr.s    gettaskname
  1887. 1$        unlk    a2
  1888.         movem.l    (sp)+,a3/a5
  1889.         rts
  1890.  
  1891. gettaskname    movem.l    a1-a2,-(sp)
  1892.         clr.b    cliexec(a4)
  1893.         tst.b    cmdcli(a4)
  1894.         beq.s    2$
  1895.         cmpi.b    #13,8(a5)
  1896.         bne.s    2$
  1897.  
  1898.         CALL    Forbid,sysbase(a4)
  1899.         tst.l    140(a3)            ; pr_TaskNum
  1900.         beq.s    1$
  1901.         move.l    172(a3),d0        ; pr_CLI
  1902.         beq.s    1$
  1903.         lsl.l    #2,d0
  1904.         move.l    d0,a2
  1905.         tst.l    60(a2)            ; cli_Module
  1906.         beq.s    1$
  1907.         move.l    16(a2),a1
  1908.         adda.l    a1,a1
  1909.         adda.l    a1,a1
  1910.         tst.b    0(a1)
  1911.         beq.s    1$
  1912.         move.w    #openbrak,d0
  1913.         bsr    putstrw
  1914.         move.l    16(a2),d0        ; cli_CommandName
  1915.         bsr    putbcpl
  1916.         RECALL    Permit
  1917.         st    cliexec(a4)
  1918.         move.w    #closebrak,d0
  1919.         movem.l    (sp)+,a1-a2
  1920.         bra    putstrw
  1921.  
  1922. 1$        RECALL    Permit            ; a6 - still SysBase
  1923. 2$        move.l    4(a5),d0
  1924.         movem.l    (sp)+,a1-a2
  1925.         bra    putstr
  1926.  
  1927. gettype        moveq    #$f,d1
  1928.         and.l    d1,d0
  1929.         mulu    #11,d0
  1930.         add.w    #type,d0
  1931.         bra    putstrw
  1932.  
  1933. *-------- mem-hunks ------------
  1934.  
  1935. showmem        lea    mheader(a4),a0
  1936.         bsr    puthead
  1937.         move.l    sysbase(a4),a5
  1938.         lea    322(a5),a5        ; SysBase->MemList
  1939.         moveq    #0,d5
  1940. mem1        move.l    0(a5),a5        ; MemList->ln_Next
  1941.         tst.l    0(a5)
  1942.         beq.s    mem2
  1943.         move.l    20(a5),d0        ; MemHeader->mh_Lower
  1944.         bsr    hexa
  1945.         move.l    24(a5),d0        ; MemHeader->mh_Upper
  1946.         bsr    hexa
  1947.         move.l    28(a5),d0        ; MemHeader->mh_Free
  1948.         add.l    d0,d5
  1949.         moveq    #1,d3
  1950.         bsr    longdec
  1951.         move.w    14(a5),d0        ; MemHeader->mh_Attributes
  1952.         bsr    gthex
  1953.         addq.l    #3,d0
  1954.         move.l    d0,a0
  1955.         move.b    #'$',(a0)
  1956.         bsr    putstr
  1957.         move.b    9(a5),d3        ; MemHeader->ln_pri
  1958.         bsr    plusmins
  1959.         move.l    10(a5),d0        ; MemHeader->ln_Name
  1960.         move.l    a5,node(a4)
  1961.         bsr    putnam
  1962.         bra.s    mem1
  1963. mem2        move.w    #infoh6,d0
  1964.         bsr    putstrw
  1965.         moveq    #18,d1
  1966.         bsr    tab
  1967.         move.l    d5,d0
  1968.         moveq    #1,d3
  1969.         bsr    longdec
  1970.         bra    newline
  1971.  
  1972. frags        move.l    sysbase(a4),a5
  1973.         lea    322(a5),a5        ; SysBase->MemList
  1974. 1$        move.l    0(a5),a5        ; MemList->ln_Next
  1975.         tst.l    0(a5)
  1976.         bne.s    10$
  1977.         rts
  1978. 10$        move.w    #memtyp,d0
  1979.         bsr    putstrw
  1980.         move.l    10(a5),d0
  1981.         bsr    putnam
  1982.         lea    fraghead(a4),a0
  1983.         bsr    puthead
  1984.         lea    buffer(a4),a1
  1985.         move.l    a1,a2
  1986.         moveq    #64,d0
  1987. 9$        clr.l    (a2)+
  1988.         dbra    d0,9$
  1989.         lea    128(a1),a2
  1990.         lea    16(a5),a3        ; MemHeader->mh_First
  1991.  
  1992.         CALL    Forbid,sysbase(a4)
  1993. 2$        move.l    0(a3),d0
  1994.         beq.s    5$
  1995.         move.l    d0,a3
  1996.         move.l    4(a3),d0
  1997.         move.l    d0,d5
  1998.         moveq    #31,d1
  1999. 3$        add.l    d0,d0
  2000.         btst.l    #31,d0
  2001.         dbne    d1,3$
  2002.         lsl.l    #2,d1
  2003.         addq.l    #1,0(a1,d1.w)
  2004.         cmp.l    0(a2,d1.w),d5
  2005.         ble.s    2$
  2006.         move.l    d5,0(a2,d1.w)
  2007.         bra.s    2$
  2008. 5$        CALL    Permit,sysbase(a4)
  2009.  
  2010.         moveq    #0,d1
  2011. 8$        move.l    (a2)+,d5
  2012.         move.l    (a1)+,d2
  2013.         beq.s    6$
  2014.         moveq    #0,d0
  2015.         bset.l    d1,d0
  2016.         lsr.l    #1,d0
  2017.         move.l    d0,d4
  2018.         bsr    hexa
  2019.         move.l    d4,d0
  2020.         moveq    #1,d3
  2021.         bsr    longdec
  2022.         move.l    d2,d0
  2023.         bsr    longdec
  2024.         move.l    d5,d0
  2025.         bsr    longdec
  2026. 7$        bsr    newline
  2027. 6$        addq.w    #1,d1
  2028.         cmp.w    #31,d1
  2029.         ble.s    8$
  2030.         bsr    newline
  2031.         bra    1$
  2032.  
  2033. *-------- Task-Stack ------------
  2034.  
  2035. stack        lea    stackhead(a4),a0
  2036.         bsr    puthead
  2037.         moveq    #0,d5
  2038.         bsr    getaskdat
  2039.         bra    sta4
  2040. sta1        lea    -16(a5),a5
  2041.         bsr    hideit
  2042.         beq.s    sta4
  2043.         move.l    0(a5),a1
  2044.         cmp.l    idletask(a4),a1
  2045.         beq.s    sta4
  2046.         move.l    a1,node(a4)
  2047.         moveq    #1,d3            ; longdec right justified
  2048.         cmp.b    #13,8(a1)        ; task->ln_Type
  2049.         bne.s    sta2
  2050.         move.l    172(a1),d0        ; pr_CLI
  2051.         beq.s    sta2
  2052.         lsl.l    #2,d0
  2053.         move.l    d0,a0
  2054.         tst.l    60(a0)            ; cli_Module
  2055.         beq.s    sta2
  2056.         move.l    176(a1),a0
  2057.         move.l    (a0)+,d4        ; stacksize for this CLI-process
  2058.         move.l    a0,d0
  2059.         sub.l    d4,d0            ; (pr_ReturnAddress+4)-stacksize
  2060.         bsr    hexa
  2061.         move.l    d4,d0            ; stacksize
  2062.         bsr    longdec
  2063.         move.l    176(a1),d0        ; pr_ReturnAddress
  2064.         addq.l    #4,d0
  2065.         bra.s    sta3
  2066.  
  2067. sta2        move.l    58(a1),d0        ; tc_SPLower
  2068.         bsr    hexa
  2069.         move.l    62(a1),d4        ; tc_SPUpper
  2070.         sub.l    58(a1),d4        ; tc_SPLower
  2071.         move.l    d4,d0
  2072.         bsr    longdec
  2073.         move.l    62(a1),d0        ; tc_SPUpper
  2074. sta3        sub.l    54(a1),d0        ; tc_SPReg
  2075.         bcs.s    2$
  2076.         cmp.l    d4,d0
  2077.         ble.s    1$
  2078. 2$        moveq    #-1,d0            ; tc_SPReg outside ...
  2079. 1$        bsr    longdec
  2080.         move.l    a1,a3
  2081.         bsr    gettaskname
  2082.         bsr    newline
  2083. sta4        subq.b    #1,entries(a4)
  2084.         bcc    sta1            ; more entries
  2085.         rts
  2086.  
  2087. clicomm        lea    clicomhead(a4),a0
  2088.         bsr    puthead
  2089.         moveq    #0,d5
  2090.         bsr    getaskdat
  2091.         bra    clic0
  2092. clic1        lea    -16(a5),a5
  2093.         bsr    hideit
  2094.         beq    clic0
  2095.         move.l    0(a5),a2
  2096.         cmpi.b    #13,8(a2)        ; ln_Type
  2097.         bne    clic0
  2098.         tst.l    172(a2)
  2099.         beq    clic0
  2100.         move.l    140(a2),d3        ; pr_TaskNum
  2101.         beq     clic0
  2102.         move.l    a2,d0
  2103.         move.l    d0,node(a4)
  2104.         bsr    hexa
  2105.         moveq     #0,d0
  2106.         move.b    9(a5),d0
  2107.         subq.w    #1,d0
  2108.         mulu    #9,d0
  2109.         add.w    #status,d0
  2110.         bsr    putstrw
  2111.         move.l    172(a2),a3        ; pr_CLI
  2112.         adda.l    a3,a3
  2113.         adda.l    a3,a3
  2114.         move.w    #script,d0
  2115.         tst.l    40(a3)            ; cli_InterActive
  2116.         beq.s    clic5
  2117.         addq.w    #interact-script,d0
  2118. clic5        bsr    putstrw
  2119.         move.w    #backg,d0
  2120.         tst.l    44(a3)            ; cli_Background
  2121.         bne.s    clic6
  2122.         addq.w    #foreg-backg,d0
  2123. clic6        bsr    putstrw
  2124.         bsr    bytedec
  2125.         move.l    4(a5),d0
  2126.         bsr    putstr
  2127.         moveq    #49,d1
  2128.         bsr    tab
  2129.         bsr    putblank
  2130.         move.l    128(a2),d0        ; pr_SegList
  2131.         beq.s    noprogloadc
  2132. clic3        move.l    172(a2),d1        ; pr_CLI
  2133.         bne.s    clic4
  2134. noprogloadc    move.w    #longnix,d0
  2135.         bsr     putnamw
  2136.         bra.s    clic0
  2137. clic4        lsl.l    #2,d1
  2138.         move.l    d1,a2
  2139.         move.l    60(a2),d1        ; cli_Module
  2140.         beq.s    noprogloadc
  2141.         move.l    16(a2),d0        ; cli_CommandName
  2142.         bsr    putbcpl
  2143.         move.l    36(a2),d1        ; cli_CommandFile
  2144.         beq.s    1$
  2145.         move.l    d1,d2
  2146.         lsl.l    #2,d1
  2147.         move.l    d1,a0
  2148.         tst.b    0(a0)
  2149.         beq.s    1$
  2150.         bsr     putblank
  2151.         move.w    #openbrak,d0
  2152.         bsr    putstrw
  2153.         move.l    d2,d0
  2154.         bsr    putbcpl
  2155.         move.w    #closebrak,d0
  2156.         bsr    putstrw
  2157. 1$        bsr    newline
  2158.  
  2159. clic0        subq.b    #1,entries(a4)
  2160.         bcc    clic1
  2161. clic8        rts
  2162.  
  2163. *--------- interrupts ------------
  2164.  
  2165. showint        lea    iheader(a4),a0
  2166.         bsr    puthead
  2167.         lea    intnames(a4),a5
  2168.         lea    inttyp(a4),a1
  2169.         moveq    #0,d6
  2170. findint        moveq    #0,d1
  2171.         lea    inttyp(a4),a1
  2172.         moveq    #15,d5
  2173.         move.l    sysbase(a4),a3
  2174.         lea    84(a3),a3        ; SysBase->IntVects[16]
  2175. si0        tst.b    0(a1,d1.w)
  2176.         bne.s    si4
  2177.         move.l    8(a3),a2        ; IntVector->iv_Node
  2178.         bra.s    si5
  2179. si4        move.l    0(a3),a2        ; Interrupt->is_Node
  2180. si5        move.l    a2,d0
  2181.         beq    nxtint
  2182.         tst.b    0(a1,d1.w)
  2183.         beq.s    si1
  2184. si2        move.l    0(a2),a2        ; is_Node->ln_Next
  2185.         tst.l    0(a2)
  2186.         beq    nxtint
  2187. si1        tst.w    d6
  2188.         beq.s    3$
  2189.         cmp.l    a2,d4
  2190.         bne.s    4$
  2191.         rts
  2192. 3$        move.l    a2,node(a4)
  2193.         move.l    a2,d0
  2194.         bsr    hexa
  2195.         move.l    14(a2),d0        ; Interrupt->is_Data
  2196.         bsr    hexan
  2197.         move.l    18(a2),d0        ; Interrupt->is_Code
  2198.         bsr    hexan
  2199.         move.b    9(a2),d3        ; Interrupt->ln_Pri
  2200.         movem.l    d6/a3,-(sp)
  2201.         bsr    plusmins
  2202.         move.w    #intserv,d0
  2203.         tst.b    0(a1,d1.w)
  2204.         bne.s    1$
  2205.         move.w    #inthand,d0
  2206. 1$        bsr    putstrw
  2207.         move.w    #intdis,d0
  2208.         move.w    $dff01c,d3
  2209.         btst.w    d1,d3
  2210.         beq.s    2$
  2211.         move.w    #inten,d0
  2212. 2$        bsr    putstrw
  2213.         movem.l    (sp)+,d6/a3
  2214.         move.l    a5,d0
  2215.         bsr    putstr
  2216.         move.l    10(a2),d0        ; Interrupt->ln_Name
  2217.         bsr    putnam
  2218.         tst.b    0(a1,d1.w)
  2219.         bne    si2
  2220. 4$        tst.l    0(a2)
  2221.         beq.s    nxtint
  2222.         move.l    0(a2),a2
  2223.         bra    si1
  2224. nxtint        addq.w    #1,d1
  2225.         lea    12(a5),a5
  2226.         lea    12(a3),a3
  2227.         dbra    d5,si0
  2228.         rts
  2229.  
  2230. *---------    resident ------------
  2231.  
  2232. showresi    lea    rheader(a4),a0
  2233.         bsr    puthead
  2234.         move.l    sysbase(a4),a5
  2235.         move.l    300(a5),a5        ; SysBase->ResModules
  2236. r1        move.l    (a5)+,d0        ; Resident->ln_Next
  2237.         beq.s    r2
  2238.         bpl.s    r3
  2239.         bclr    #31,d0
  2240.         movea.l    d0,a5
  2241.         bra.s    r1
  2242. r3        move.l    d0,node(a4)
  2243.         movea.l    d0,a3
  2244.         bsr    hexa
  2245.         move.b    13(a3),d3        ; rt_Pri
  2246.         bsr    plusmins
  2247.         move.b    10(a3),d0        ; rt_Flags
  2248.         bsr    bin
  2249.         move.b    11(a3),d3        ; rt_Version
  2250.         bsr    bytedec
  2251.         move.b    12(a3),d0        ; rt_Type
  2252.         bsr    gettype
  2253.         move.l    14(a3),d0        ; rt_Name
  2254.         bsr    putnam
  2255.         bra.s    r1
  2256. r2        rts
  2257.  
  2258. *---------  ports  -------------
  2259.  
  2260. showprt        lea    pheader(a4),a0
  2261.         bsr    puthead
  2262.         moveq    #0,d5
  2263.         lea    buffer(a4),a5
  2264.         move.l    a5,-(sp)
  2265.         CALL    Forbid,sysbase(a4)
  2266.         move.w    #$4000,$dff09a
  2267.         bsr.s    getprts
  2268.         move.w    #$C000,$dff09a
  2269.         RECALL    Permit
  2270.         move.l    (sp)+,a5        ; buffer
  2271.         bra.s    sp2
  2272. sp1        move.l    (a5)+,d0
  2273.         move.l    d0,node(a4)
  2274.         bsr    hexa
  2275.         move.l    (a5)+,d0
  2276.         bsr    putstr
  2277.         moveq    #25,d1
  2278.         bsr     tab
  2279.         bsr    putblank
  2280.         moveq    #3,d0
  2281.         and.b    (a5)+,d0
  2282.         mulu    #9,d0
  2283.         add.w    #mp_flags,d0
  2284.         bsr    putstrw
  2285.         lea    bytedec(pc),a0
  2286.         move.b    (a5)+,d3
  2287.         jsr    0(a0)            ; bytedec
  2288.         move.w    (a5)+,d3
  2289.         bpl.s    1$
  2290.         lea    putstrw(pc),a0
  2291.         move.w    #toomuch,d0
  2292. 1$        jsr    0(a0)            ; bytedec or putstrw
  2293.         move.l    (a5)+,d0
  2294.         bsr    getaskname2
  2295.         bsr    newline
  2296. sp2        subq.w    #1,d5
  2297.         bcc.s    sp1
  2298.         rts
  2299.  
  2300. getprts        lea    392(a6),a3        ; SysBase->PortList
  2301. sp3        move.l    0(a3),a3        ; mp_Node.ln_Next
  2302.         tst.l    0(a3)
  2303.         beq.s    sp4
  2304.         bsr.s    getpdata
  2305.         bra.s    sp3
  2306. sp4        tst.b    tports(a4)
  2307.         beq.s    sp6
  2308.         move.l    276(a6),a3        ; SysBase->ThisTask
  2309.         lea     92(a3),a3        ; Process->pr_MsgPort
  2310.         bsr.s    getpdata
  2311.         lea    406(a6),a2        ; SysBase->TaskReady
  2312.         bsr.s    sp5
  2313.         lea    420(a6),a2        ; SysBase->TaskWait
  2314. sp5        move.l    0(a2),a2
  2315.         tst.l    0(a2)
  2316.         beq.s    sp6
  2317.         lea     92(a2),a3        ; pr_MsgPort
  2318.         cmp.b    #13,8(a2)        ; ln_Type
  2319.         bne.s    sp5
  2320.         bsr.s    getpdata
  2321.         bra.s    sp5
  2322. sp6        rts
  2323.  
  2324. getpdata    move.l    a3,(a5)+
  2325.         move.l    10(a3),(a5)+        ;  +4 = ln_Name
  2326.         move.b    14(a3),(a5)+        ;  +8 = mp_Flags
  2327.         move.b    15(a3),(a5)+        ;  +9 = mp_SigBit
  2328.         moveq    #0,d0
  2329.         suba.l    a0,a0
  2330.         movea.l    20(a3),a1        ; mp_MsgList
  2331. sp7        movea.l    0(a1),a1
  2332.         cmpa.l    a0,a1
  2333.         beq.s    sp8
  2334.         addq.b    #1,d0
  2335.         bcc.s    sp7            ; <256
  2336.         subq.w    #1,d0
  2337. sp8        move.w    d0,(a5)+        ; +10 = msgcnt
  2338.         move.l    16(a3),(a5)+        ; +12 = mp_SigTask
  2339.         addq.w    #1,d5
  2340.         rts
  2341.  
  2342. *-------- resources ------------
  2343.  
  2344. showres        lea    resnam(a4),a3
  2345.         move.w    #336,d3            ; SysBase->ResourceList
  2346.         bra.s    show
  2347.  
  2348. *--------- devices  -------------
  2349.  
  2350. showdevs    lea    devnam(a4),a3
  2351.         move.w    #350,d3            ; SysBase->DeviceList
  2352.         bra.s    show
  2353.  
  2354. *-------- libraries -------------
  2355.  
  2356. showlibs    lea    libnam(a4),a3
  2357.         move.w    #378,d3            ; SysBase->LibList
  2358.  
  2359. show        lea    lheader(a4),a0
  2360.         bsr    puthead1
  2361.         move.l    a3,a0
  2362.         bsr    puthead2
  2363.         moveq    #0,d5
  2364.         lea    buffer(a4),a5
  2365.         move.l    a5,-(sp)
  2366.         CALL    Forbid,sysbase(a4)
  2367.         lea    0(a6,d3.w),a3
  2368. sl1        move.l    0(a3),a3        ; lib_Node.ln_Next
  2369.         tst.l    0(a3)
  2370.         beq.s    sl2
  2371.         move.l    a3,(a5)+
  2372.         move.w    32(a3),(a5)+        ;  +4 = lib_OpenCnt
  2373.         move.w    20(a3),(a5)+        ;  +6 = lib_Version
  2374.         move.w    22(a3),(a5)+        ;  +8 = lib_Revision
  2375.         clr.b    (a5)+
  2376.         move.b    14(a3),(a5)+        ; +11 = lib_Flags
  2377.         move.l    10(a3),(a5)+        ; +12 = ln_Name
  2378.         addq.w    #1,d5
  2379.         bra.s    sl1
  2380. sl2        RECALL    Permit
  2381.         move.l    (sp)+,a5        ; buffer
  2382.         bra.s    sl4
  2383. sl3        move.l    (a5)+,d0
  2384.         move.l    d0,node(a4)
  2385.         bsr    hexa
  2386.         move.w    (a5)+,d3
  2387.         bsr    worddec
  2388.         move.w    (a5)+,d3
  2389.         bsr    worddec
  2390.         move.w    (a5)+,d3
  2391.         bsr    worddec
  2392.         move.w    (a5)+,d0
  2393.         bsr    bin
  2394.         move.l    (a5)+,d0
  2395.         bsr    putnam
  2396. sl4        subq.w    #1,d5
  2397.         bcc.s    sl3            ; not ready
  2398.         rts
  2399.  
  2400. ;--------- Semaphores ---------
  2401.  
  2402. semaphores    lea    semhead(a4),a0
  2403.         bsr    puthead
  2404.         move.l    sysbase(a4),a3
  2405.         lea    532(a3),a3
  2406.         bsr.s    sema
  2407.         tst.b    post_V34(a4)
  2408.         bne.s    sema6
  2409.         move.l    intuibase(a4),a3
  2410.         lea    1010(a3),a3
  2411. sema        moveq    #0,d5            ; examine list
  2412.         lea    buffer(a4),a5
  2413.         move.l    a5,-(sp)
  2414.         move.w    #$4000,$dff09a
  2415. sema2        move.l    0(a3),a3
  2416.         tst.l    0(a3)
  2417.         beq.s    sema3
  2418.         move.l    a3,(a5)+
  2419.         move.l    $28(a3),(a5)+
  2420.         move.b    $2d(a3),(a5)+
  2421.         move.b    $f(a3),(a5)+
  2422.         move.l    10(a3),(a5)+
  2423.         addq.w    #1,d5
  2424.         bra.s     sema2
  2425. sema3        move.w    #$C000,$dff09a
  2426.         move.l    (sp)+,a5        ; buffer
  2427.         bra.s    sema5
  2428. sema4        move.l    (a5)+,d0
  2429.         bsr    hexa
  2430.         move.l    (a5)+,d0
  2431.         bsr    getaskname2
  2432.         moveq    #24,d1
  2433.         bsr    tab
  2434.         moveq    #1,d3
  2435.         add.b    (a5)+,d3
  2436.         bsr    plusmins
  2437.         move.b    (a5)+,d3
  2438.         bsr    plusmins
  2439.         move.l    (a5)+,d0
  2440.         bsr    putnam
  2441. sema5        subq.w    #1,d5
  2442.         bcc.s    sema4            ; not ready
  2443. sema6        rts
  2444.  
  2445. ; unlock a file
  2446.  
  2447. unlock        tst.l    infile(a4)
  2448.         bne.s    ul6
  2449.         bsr    readhex
  2450.         tst.b    d7
  2451.         beq    syntax
  2452.         move.l    d0,remembr(a4)
  2453.         move.l    d0,-(sp)
  2454.         moveq    #-1,d6
  2455.         bsr.s    of44
  2456.         tst.l    remembr(a4)
  2457.         beq.s     ul1
  2458.         move.w    #unlerr,d0
  2459.         bsr    putnamw
  2460.         bra.s    ul4
  2461. ul1        bsr    allocfinfo
  2462.         bsr    ResumeOutput
  2463.         move.w    #unl1,d0
  2464.         bsr    putstrw
  2465.         move.l    0(sp),d0
  2466.         bsr    getpath
  2467.         move.w    #unltxt2,d0
  2468.         bsr    putstrw
  2469.         bsr    readline
  2470.         cmp.b    #'y',d0
  2471.         bne.s     ul5
  2472.         move.l    0(sp),d1
  2473.         CALL    UnLock,dosbase(a4)
  2474. ul5        bsr    freefinfo
  2475. ul4        addq.l    #4,sp
  2476. ul6        rts
  2477.  
  2478. ;---------- Show all Locks------------
  2479.  
  2480. locks        moveq    #0,d6
  2481.         bra.s    of33
  2482.  
  2483. ;---------- Open Files-----------
  2484.  
  2485. openfiles    moveq    #1,d6
  2486. of33        lea    ofheader(a4),a0
  2487.         bsr    puthead
  2488. of44        bsr    allocfinfo
  2489.         bsr    devinfo            ; get pointer to devicelist
  2490.         move.l    a1,a3
  2491. of1        move.l    a3,devicelock(a4)
  2492.         adda.l    a3,a3
  2493.         adda.l    a3,a3
  2494.         moveq    #2,d2             ; 2 = DLT_VOLUME
  2495.         cmp.l    4(a3),d2        ; DeviceList->dl_Type 
  2496.         bne    of2
  2497.         lea    buffer(a4),a5
  2498.         move.l    a5,a1
  2499.         move.l    40(a3),a2        ; dl_Name
  2500.         adda.l    a2,a2
  2501.         adda.l    a2,a2
  2502.         move.b    (a2)+,d2
  2503.         bra.s    of23
  2504. of22        move.b    (a2)+,(a1)+        ; hack to access the 'RAM Disk'
  2505. of23        dbeq    d2,of22            ; as 'RAM:' as the system may
  2506.         bne.s    of24
  2507.         subq.w    #1,a1
  2508. of24        move.b  #':',(a1)+        ; GURU with KS1.2
  2509.         clr.b    0(a1)
  2510.         tst.b    post_V34(a4)
  2511.         bne.s    of5
  2512.         cmp.l    #'RAM ',0(a5)
  2513.         bne.s    of5
  2514.         cmp.l    #'Disk',4(a5)
  2515.         bne.s    of5
  2516.         move.l    #'M:'<<16,2(a5)
  2517. of5        move.l    a5,d1
  2518.         moveq    #-2,d2
  2519.         CALL    Lock,dosbase(a4)    ; get a lock to the device
  2520.         move.l    d0,d2            ; not mounted' if fails
  2521.         bne.s    of6
  2522.         move.l    a5,d0            ; buffer points to device name
  2523.         bsr    putstr
  2524.         move.w    #nomount,d0
  2525.         bsr    putnamw
  2526.         bra    of2
  2527.  
  2528. of6        CALL    Forbid,sysbase(a4)
  2529.         move.l    d2,-(sp)        ; d2 = FileLock
  2530.         lsl.l    #2,d2
  2531.         move.l    d2,a5
  2532.         lea    buffer+40(a4),a6    ; where to store the locks we find
  2533. of4        move.l    0(a5),d0        ; fl_Link
  2534.         cmp.l    #50,d0            ; zero or bogus ?
  2535.         ble.s    1$            ; exit loop
  2536.         tst.l    d6            ; searching for a lock ?
  2537.         bpl.s    3$            ; no !
  2538.  
  2539.         cmp.l    remembr(a4),d0        ; yes, compare them
  2540.         bne.s    3$
  2541.         clr.l    remembr(a4)
  2542.         CALL    Permit,sysbase(a4)
  2543. 2$        move.l    (sp)+,d1
  2544.         CALL    UnLock,dosbase(a4)
  2545.         bra    of55            ; exit if found
  2546.  
  2547. 3$        move.l    d0,(a6)+        ; put lock into buffer
  2548.         clr.w    (a6)+
  2549.         tst.b    post_V34(a4)
  2550.         beq.s    5$
  2551.         bsr    IsBcplLock        ; hack for KS2.0, see if BPTR
  2552.         bne.s    5$            ; isn't really an APTR
  2553.         move.w    #1,-2(a6)
  2554.         bra.s    4$
  2555. 5$        lsl.l    #2,d0            ; convert bptr into aptr
  2556. 4$        move.l    d0,a5
  2557.         bra.s    of4            ; get next lock
  2558.  
  2559. 1$        clr.l    (a6)+            ; end of buffer marker
  2560.         CALL    Permit,sysbase(a4)
  2561.         tst.l    d6            ; just searching for a lock ?
  2562.         bmi    of3             ; skip printing out info
  2563.  
  2564. of45        lea    buffer+40(a4),a2    ; a2-> array of locks
  2565. of46        move.l    (a2)+,d0        ; get a lock
  2566.         beq    of3             ; end of list ?
  2567.         tst.w    (a2)+
  2568.         beq.s    2$
  2569.         lsr.l    #2,d0
  2570. 2$        move.l    d0,d5
  2571.         lsl.l    #2,d0            ; bptr -> aptr
  2572.         move.l    d0,a5
  2573.         move.l    8(a5),d4        ; fl_Access
  2574.         move.l    d5,d0
  2575.         bsr    getfinfo        ; get fileinfo
  2576.         move.l    finfoptr(a4),a5
  2577.         tst.l    d6
  2578.         beq.s    of8
  2579.         bmi.s    of8             ; looking for open files ?
  2580.         tst.l    4(a5)            ; fib_DirEntryType
  2581.         bpl.s    of46            ; not a file
  2582. of8        move.l    d5,d0
  2583.         move.l    d0,node(a4)
  2584.         bsr    hexa            ; display lock
  2585.         move.w    #access,d0        ; access mode
  2586.         cmp.w    #-2,d4
  2587.         beq.s    of7
  2588.         addq.w  #8,d0
  2589. of7        bsr    putstrw
  2590.         tst.l    4(a5)            ; size
  2591.         bmi.s    of9
  2592.         move.w    #longlongnix,d0
  2593.         bsr    putstrw
  2594.         bra.s    of10
  2595. of9        move.l    124(a5),d0
  2596.         moveq    #1,d3
  2597.         bsr    longdec
  2598. of10        move.l    d5,d0            ; path and filename
  2599.         bsr    getpath
  2600.         bra.s    of46
  2601.  
  2602. of3        move.l    (sp)+,d1
  2603.         CALL    UnLock,dosbase(a4)
  2604. of2        move.l    0(a3),d0
  2605.         move.l    d0,a3
  2606.         bne    of1
  2607. of55        bsr    freefinfo
  2608.         rts
  2609.  
  2610. IsBcplLock    movem.l    d0/d1/a0/a1,-(sp)
  2611.         moveq    #0,d1
  2612.         btst    d1,d0
  2613.         bne.s    1$            ; is bcpl
  2614.         bsr.s    CheckAdr        ; chk address
  2615.         bne.s    2$
  2616.         lsl.l    #2,d0
  2617.         moveq    #1,d1
  2618.         bsr.s    CheckAdr        ; chk address
  2619. 2$        move.l    d0,a0
  2620.         move.l    16(a0),a0
  2621.         cmp.l    devicelock(a4),a0
  2622.         bne.s    1$            ; is bcpl
  2623.         move.l    d1,d0
  2624. 1$        movem.l    (sp)+,d0/d1/a0/a1
  2625.         rts
  2626.  
  2627. ; validate address in d0 for accessibility to prevent illegal memory access !
  2628.  
  2629. CheckAdr    move.l    sysbase(a4),a0
  2630.         move.l    322(a0),a0        ; SysBase->MemList
  2631.         sub.l    a1,a1
  2632. 1$        cmp.l    20(a0),d0
  2633.         bcs.s    2$
  2634.         cmp.l    24(a0),d0
  2635.         bcs.s    3$
  2636. 2$        move.l    (a0),a0
  2637.         cmp.l    a0,a1
  2638.         bne.s    1$
  2639. 3$        rts
  2640.  
  2641. ;---------- Dos Devices ----------
  2642.  
  2643. devices        lea    ddheader(a4),a0
  2644.         bsr    puthead
  2645.         bsr    devinfo
  2646. dev1        adda.l    a1,a1
  2647.         adda.l    a1,a1
  2648.         tst.l    4(a1)
  2649.         bne    dev9
  2650.         moveq    #0,d6
  2651.         move.l    40(a1),d0
  2652.         bsr    putbcpl
  2653.         moveq    #10,d1
  2654.         bsr    tab
  2655.         move.w    #notfile,d0
  2656.         lea    putstrw(pc),a0
  2657.         moveq    #20,d1
  2658.         move.l    28(a1),a3
  2659.         cmp.l    d1,a3
  2660.         ble.s    dev3            ; =<20
  2661.         moveq    #1,d6
  2662.         adda.l    a3,a3
  2663.         adda.l    a3,a3
  2664.         move.l    8(a3),a2
  2665.         cmp.l    d1,a2
  2666.         ble.s    dev3            ; =<20
  2667.         adda.l    a2,a2
  2668.         adda.l    a2,a2
  2669.         move.l    12(a2),d3
  2670.         bsr    bytedec
  2671.         move.l    20(a2),d0
  2672.         moveq    #1,d3
  2673.         lea    longdec(pc),a0
  2674.         jsr    0(a0)            ; longdec
  2675.         move.l    40(a2),d0
  2676.         beq.s    dev2
  2677.         addq.l    #1,d0
  2678.         sub.l    36(a2),d0
  2679. dev2        jsr    0(a0)            ; longdec
  2680.         move.l    44(a2),d0
  2681. dev3        jsr    0(a0)            ; putstrw or longdec
  2682. dev4        move.w    #devload,d0
  2683.         tst.l    8(a1)
  2684.         bne.s    dev5
  2685.         move.w    #devnload,d0
  2686. dev5        bsr    putstrw
  2687.         lea    putbcpl(pc),a0
  2688.         tst.w    d6
  2689.         beq.s    dev6
  2690.         move.l    4(a3),d0
  2691.         bne.s    dev7
  2692. dev6        move.l    16(a1),d0
  2693.         bne.s    dev7
  2694.         tst.l    8(a1)
  2695.         beq.s    dev8
  2696.         move.l    8(a1),a3
  2697.         move.l    -82(a3),d0
  2698.         lea    putstr(pc),a0
  2699. dev7        jsr    0(a0)            ; putbcpl or putstr
  2700. dev8        bsr    newline
  2701. dev9        move.l    (a1),d1
  2702.         move.l    d1,a1
  2703.         bne    dev1
  2704.         rts
  2705.  
  2706. ; Re-assign a drive to dos
  2707.  
  2708. freedrive    moveq    #0,d2
  2709.         bra.s    ldr3
  2710.  
  2711. ; Inhibit a disk drive
  2712.  
  2713. lockdrive    moveq    #1,d2
  2714. ldr3        bsr    getstr
  2715.         bsr    finddev
  2716.         lea    buffer(a4),a2
  2717.         bne.s    ldr1
  2718. ldr2        move.l    a2,d0            ; buffer
  2719.         bsr    putstr
  2720.         move.w    #nomount,d0
  2721.         bsr    putstrw
  2722.         move.w    #dishelp,d0
  2723.         bra     putnamw
  2724. ldr1        move.l    a2,d1            ; buffer
  2725.         CALL    DeviceProc,dosbase(a4)
  2726.         move.l    d0,a0
  2727.         move.l    a0,d0
  2728.         beq.s    ldr2
  2729.         moveq    #31,d0
  2730.         move.l    d2,d1
  2731.  
  2732. ; send a packet
  2733. ; d0 = packet type
  2734. ; d1 = arg1
  2735. ; a0 = msgport
  2736.  
  2737. cons1        lea    mypacket(a4),a1
  2738.         lea    20(a1),a2
  2739.         move.l    a2,10(a1)        ; sp_Pkt to sp_Msg->ln_Name
  2740.         move.l    a1,20(a1)        ; sp_Msg to sp_Pkt->dp_Link
  2741.         move.l    replyport(a4),a2
  2742.         move.l    a2,24(a1)        ; sp_Pkt->dp_Port
  2743.         move.l    d0,28(a1)        ; sp_Pkt->dp_Type
  2744.         move.l    d1,40(a1)        ; sp_Pkt->dp_Arg1
  2745.         CALL    PutMsg,sysbase(a4)
  2746.         move.l    a2,a0
  2747.         RECALL    WaitPort
  2748.         move.l    a2,a0
  2749.         jmp    _LVOGetMsg(a6)
  2750.  
  2751. ;display the current directory of all processes,
  2752.  
  2753. currentdir    lea    cdheader(a4),a0
  2754.         bsr    puthead
  2755.         bsr    allocfinfo
  2756.         bsr    alloctaskbuf
  2757.         beq.s    cd7
  2758.         move.l    d0,a5
  2759.         move.b    d5,entries(a4)
  2760.         move.l    a5,-(sp)
  2761.         bra.s    cd6
  2762. cd2        cmp.b    #13,8(a5)
  2763.         bne.s    cd5
  2764.         move.l    0(a5),a3
  2765.         move.l    a5,-(sp)
  2766.         moveq    #-1,d6
  2767.         move.l    152(a3),remembr(a4)
  2768.         bsr    of44
  2769.         move.l    (sp)+,a5
  2770.         tst.l    remembr(a4)
  2771.         bne.s    cd5
  2772.         move.l    0(a5),a3
  2773.         move.l    a3,node(a4)
  2774.         bsr    gettaskname
  2775.         moveq    #21,d1
  2776.         bsr    tab
  2777.         move.l    152(a3),d0
  2778.         bsr    getpath
  2779. cd5        lea     16(a5),a5
  2780. cd6        subq.b    #1,entries(a4)
  2781.         bcc.s    cd2            ; not ready
  2782.         move.l    (sp)+,a5
  2783.         bsr    freetaskbuf
  2784.         bsr    freefinfo
  2785. cd7        rts
  2786.  
  2787. ;Change the current directory setting of a process
  2788.  
  2789. cd        tst.l    infile(a4)
  2790.         bne.s    cd7
  2791.         bsr    getstr
  2792.         lea    buffer(a4),a1
  2793.         move.l    a1,d1
  2794.         moveq    #-2,d2
  2795.         move.l    a0,-(sp)
  2796.         CALL    Lock,dosbase(a4)
  2797.         move.l    (sp)+,a0
  2798.         tst.l    d0
  2799.         bne.s    cd16
  2800.         move.w    #dnotf,d0
  2801.         bra    putnamw
  2802. cd16        move.l    d0,remembr2(a4)
  2803.         move.l    a0,-(sp)
  2804.         bsr    allocfinfo
  2805.         move.l    remembr2(a4),d0
  2806.         bsr    getfinfo
  2807.         move.l    finfoptr(a4),a5
  2808.         move.l    (sp)+,a0
  2809.         tst.l    4(a5)
  2810.         bpl.s    cd11
  2811.         move.w    #notdir,d0
  2812.         bsr    putnamw
  2813.         bra.s    cd18
  2814. cd11        bsr    nodenam
  2815.         moveq    #2,d7
  2816.         lea    TRuNode(pc),a3
  2817.         bsr    findnam
  2818.         tst.b    d7
  2819.         beq.s    cd15
  2820.         move.l    d0,a5
  2821.         cmp.b    #13,8(a5)
  2822.         beq.s    cd15
  2823.         bsr    syntax
  2824.         bra.s    cd18
  2825. cd15        move.l    152(a5),d0
  2826.         beq.s    cd13
  2827.         move.l    a5,-(sp)
  2828.         moveq    #-1,d6
  2829.         move.l    d0,remembr(a4)
  2830.         bsr    of44
  2831.         move.l    (sp)+,a5
  2832.         tst.l    remembr(a4)
  2833.         bne.s    cd18
  2834. cd13        move.l    152(a5),d1
  2835.         move.l    remembr2(a4),152(a5)
  2836.         move.l    d1,remembr2(a4)
  2837. cd12        beq.s     cd14
  2838.         bsr    ResumeOutput
  2839.         move.w    #unltxt,d0
  2840.         bsr    putstrw
  2841.         move.l    remembr2(a4),d0
  2842.         bsr    getpath
  2843.         move.w    #unltxt2,d0
  2844.         bsr    putstrw
  2845.         bsr    readline
  2846.         cmp.b     #'y',d0
  2847.         bne.s    cd14
  2848. cd18        move.l    remembr2(a4),d1
  2849.         beq.s    cd14
  2850.         CALL    UnLock,dosbase(a4)
  2851. cd14        bsr    freefinfo
  2852.         rts
  2853.  
  2854. ;find the first entry in the device-list
  2855. ;returns a1 = pointer to first entry
  2856.  
  2857. devinfo        move.l    dosbase(a4),a1
  2858.         move.l    34(a1),a1        ; dl_Root
  2859.         move.l    24(a1),a1        ; RootNode->rn_Info
  2860.         adda.l    a1,a1
  2861.         adda.l    a1,a1
  2862.         move.l    4(a1),a1        ; DosInfo->di_DevInfo
  2863.         rts
  2864.  
  2865. ; Check if a named dos-device is mounted
  2866. ; name in 'buffer'.
  2867. ; Result: d0 = 0(false) anything else(true).
  2868.  
  2869. finddev        bsr.s    devinfo
  2870. fdev1        adda.l    a1,a1
  2871.         adda.l    a1,a1
  2872.         tst.l    4(a1)
  2873.         bne.s    fdev2
  2874.         move.l    40(a1),a2
  2875.         lea    buffer(a4),a0
  2876.         bsr.s    strbcmp
  2877.         tst.w    d0
  2878.         bne.s    fdev3
  2879. fdev2        move.l    0(a1),d0
  2880.         move.l    d0,a1
  2881.         bne.s    fdev1
  2882. fdev3        rts
  2883.  
  2884. ; compare bcpl string with string
  2885. ; a0 = pointer to string
  2886. ; a2 = bcpl-pointer to bcpl-string
  2887. ; returns d0 = true(0) false(1)
  2888.  
  2889. strbcmp        movem.l    d1/a0/a2,-(sp)
  2890.         moveq    #0,d0
  2891.         moveq    #0,d1
  2892.         adda.l    a2,a2
  2893.         adda.l    a2,a2
  2894.         move.b    (a2)+,d1
  2895.         beq.s    stb1
  2896.         subq.w    #1,d1
  2897. stb2        cmp.b    (a2)+,(a0)+
  2898.         bne.s    stb1
  2899.         dbra    d1,stb2
  2900.         moveq    #1,d0
  2901. stb1        movem.l    (sp)+,d1/a0/a2
  2902.         rts
  2903.  
  2904. ;--------- low memory handlers --------
  2905.  
  2906. lowmemhandler    lea    inheader(a4),a0
  2907.         bsr    puthead
  2908.         tst.b    post_V38(a4)
  2909.         beq.s    inph1            ; not Kick 3.0+
  2910.         move.l    sysbase(a4),a5
  2911.         lea    616(a5),a5
  2912.         bra.s    inph2            ; show all handlers
  2913.  
  2914. ;----------- input handlers -----------
  2915.  
  2916. inputhandler    lea    inheader(a4),a0
  2917.         bsr    puthead
  2918.  
  2919.         lea    ininterrupt(a4),a5
  2920. 1$        move.l    0(a5),a5        ; get list header
  2921.         tst.l    0(a5)
  2922.         bne.s    1$
  2923.         subq.l    #4,a5            ; found it
  2924.  
  2925. inph2        move.l    0(a5),a5
  2926.         tst.l    0(a5)
  2927.         beq.s    inph1
  2928.         move.l    a5,d0
  2929.         move.l    d0,node(a4)
  2930.         bsr    hexa
  2931.         move.l    14(a5),d0
  2932.         bsr    hexa
  2933.         move.l    18(a5),d0
  2934.         bsr    hexa
  2935.         move.b    9(a5),d3
  2936.         bsr    plusmins
  2937.         move.l    10(a5),d0
  2938.         bsr    putnam
  2939.         bra.s    inph2
  2940. inph1        rts
  2941.  
  2942. ;display list of public screens
  2943.  
  2944. pubscreens    lea    pscrheader(a4),a0
  2945.         bsr    puthead
  2946.         tst.b    post_V34(a4)
  2947.         beq.s    1$            ; only Kick 2.0+
  2948.         CALL    LockPubScreenList,intuibase(a4)
  2949.         movea.l    d0,a5
  2950.         move.l    a5,d0
  2951.         beq.s    1$            ; no list ???
  2952. 5$        movea.l    0(a5),a5
  2953.         tst.l    0(a5)
  2954.         beq.s    2$            ; end of list
  2955.         move.l    a5,d0
  2956.         move.l    d0,node(a4)
  2957.         bsr    hexa            ; node
  2958.         move.l    10(a5),d0
  2959.         bsr    putstr            ; name
  2960.         moveq    #25,d1
  2961.         bsr    tab
  2962.         move.w    #pscr_state,d0
  2963.         btst    #0,19(a5)        ; public or private ?
  2964.         beq.s    4$
  2965.         add.w    #10,d0
  2966. 4$        bsr    putstrw            ; state
  2967.         lea    bytedec(pc),a0
  2968.         move.w    22(a5),d3        ; visit count (locks & windows)
  2969.         jsr    0(a0)
  2970.         move.b    28(a5),d3
  2971.         bpl.s    3$            ; valid signal
  2972.         move.w    #nix,d0
  2973.         lea    putstrw(pc),a0
  2974. 3$        jsr    0(a0)
  2975.         move.l    24(a5),d0        ; sigtask
  2976.         bsr    getaskname2
  2977.         bsr    newline
  2978.         bra.s    5$
  2979. 2$        CALL    UnlockPubScreenList,intuibase(a4)
  2980. 1$        rts
  2981.  
  2982. ;get all screen pointers.
  2983. ;result: d5=number of screens
  2984. ;     buffer+100 holds pointers.
  2985.  
  2986. getscr        lea    scrheader(a4),a0
  2987.         bsr    puthead
  2988. getscr2     movem.l    d0/a0,-(sp)
  2989.         moveq    #0,d0
  2990.         CALL    LockIBase,intuibase(a4)
  2991.         lea    buffer+100(a4),a0
  2992.         move.l    60(a6),a1        ; firstscreen
  2993.         moveq    #0,d5
  2994. sr1        addq.w    #1,d5
  2995.         move.l    a1,(a0)+
  2996.         move.l    0(a1),a1
  2997.         move.l    a1,d1
  2998.         bne.s    sr1
  2999.         subq.w    #1,d5
  3000.         move.l    d0,a0
  3001.         RECALL    UnlockIBase
  3002.         movem.l    (sp)+,d0/a0
  3003.         rts
  3004.  
  3005. ;display screen infos
  3006.  
  3007. screens        bsr.s    getscr
  3008.         moveq    #1,d6
  3009.         lea    buffer+100(a4),a5
  3010. sr2        move.w    d6,d3
  3011.         bsr    bytedec            ; number
  3012.         move.l    (a5)+,a2
  3013.         move.l    a2,node(a4)
  3014.         move.l    a2,d0
  3015.         bsr    hexa            ; address
  3016.         move.w    12(a2),d0
  3017.         moveq     #4,d3
  3018.         bsr    longdecn        ; width
  3019.         moveq    #'X',d0
  3020.         bsr    putchar
  3021.         move.w    14(a2),d0
  3022.         bsr    longdecn        ; height
  3023.         move.b    189(a2),d3
  3024.         bsr     bytedec
  3025.         move.l    22(a2),d0        ; depth
  3026.         bsr    putnam            ; name
  3027.         tst.b    post_V34(a4)
  3028.         beq.s    sr5            ; only kick 2.0+
  3029.         move.w    #monitorid,d0
  3030.         bsr    putstrw
  3031.         lea    44(a2),a0        ; ViewPort
  3032.         CALL    GetVPModeID,gfxbase(a4)
  3033.         move.l    d0,-(sp)
  3034.         bsr    hexa            ; DisplayID
  3035.         move.l    #'-> ',d0
  3036.         bsr    putlongascii
  3037.         move.l    (sp)+,d0
  3038.         RECALL    FindDisplayInfo
  3039.         move.l    d0,d2
  3040.         beq.s    sr3            ; no handle
  3041.         move.l    d0,a0
  3042.         lea    -104(a5),a1
  3043.         moveq    #56,d0            ; nif_SIZEOF
  3044.         move.l    #$80003000,d1        ; DTAG_NAME
  3045.         moveq    #0,d2
  3046.         RECALL    GetDisplayInfoData
  3047. sr3        lea    -88(a5),a0        ; NameInfo.Name
  3048.         cmp.l    d2,d0
  3049.         bne.s    sr4            ; ok !
  3050.         move.l    #'???'<<8,(a0)
  3051. sr4        move.l    a0,d0
  3052.         bsr    putnam            ; name + LF
  3053. sr5        addq.w    #1,d6            ; next screen
  3054.         dbra    d5,sr2
  3055.         rts
  3056.  
  3057. ;display windows and associated fonts
  3058. windowfonts    moveq    #1,d0
  3059.         bra.s    windows1
  3060.  
  3061. ;display window addresses and titles
  3062. windows        moveq    #0,d0
  3063. windows1    move.b    d0,bool(a4)
  3064.         bsr    getscr2
  3065.         move.l    d5,-(sp)
  3066.         lea    wnheader(a4),a0
  3067.         bsr    puthead
  3068.         move.l    (sp)+,d5
  3069.         tst.b    bool(a4)
  3070.         beq.s    wn20
  3071.         move.l    d5,-(sp)
  3072.         lea    fohead(a4),a0
  3073.         bsr    puthead
  3074.         move.l    (sp)+,d5
  3075. wn20        lea    buffer+100(a4),a3
  3076. wn2        move.w    #onscr,d0
  3077.         bsr    putstrw
  3078.         move.l    (a3)+,a2
  3079.         move.l    22(a2),d0
  3080.         bsr    putnam
  3081.         lea    4(a2),a1
  3082. wn1        move.l    (a1),d0
  3083.         move.l    d0,a1
  3084.         beq.s    wn3
  3085.         move.l    d0,node(a4)
  3086.         bsr    hexa
  3087.  
  3088.         move.l    86(a1),d0        ; wn->UserPort
  3089.         beq.s    1$
  3090.         move.l    d0,a0
  3091.         move.l    16(a0),d0        ; SigTask
  3092. 1$        bsr    getaskname2
  3093.         moveq    #20,d1
  3094.         bsr    tab
  3095.         bsr    putblank
  3096.  
  3097.         moveq    #4,d3
  3098.         moveq    #2,d2
  3099.         lea    4(a1),a0
  3100. 2$        move.w    (a0)+,d0
  3101.         bsr    longdecn
  3102.         dbra    d2,2$
  3103.         moveq    #'X',d0
  3104.         bsr    putchar
  3105.         move.w    10(a1),d0
  3106.         bsr    longdecn
  3107.  
  3108.         move.l    32(a1),d0
  3109.         bsr    putnam
  3110.  
  3111.         tst.b    bool(a4)
  3112.         beq.s    wn21
  3113.         move.l    a1,-(sp)
  3114.         move.l    50(a1),a1
  3115.         move.l    52(a1),a1
  3116.         bsr    fontdata
  3117.         move.l    (sp)+,a1
  3118.  
  3119. wn21        bra.s    wn1
  3120. wn3        dbra    d5,wn2
  3121.         rts
  3122.  
  3123. ;close a specified screen
  3124.  
  3125. closescreen    bsr    getscr2
  3126.         moveq    #1,d6
  3127.         cmp.b    #'$',0(a0)
  3128.         bne.s    cs1
  3129.         bsr    readhex
  3130.         tst.w    d7
  3131.         beq    syntax
  3132.         move.l    d0,d4
  3133. csin        moveq    #0,d6
  3134. cs1        lea    buffer+100(a4),a2
  3135. cs5        tst.w    d6
  3136.         bne.s    cs2
  3137.         cmp.l    (a2)+,d4
  3138.         beq.s    cs3
  3139.         bra.s    cs4
  3140. cs2        move.l    (a2)+,a1
  3141.         move.l    22(a1),a1
  3142.         bsr    strcmp
  3143.         beq.s    cs3
  3144. cs4        dbra    d5,cs5
  3145.         move.w    #scnofound,d0
  3146.         bra    putnamw
  3147. cs3        move.l    -(a2),a0
  3148.         cmp.l    screenptr(a4),a0    ; own screen ?
  3149.         beq.s    cs8
  3150.         move.l    4(a0),d0        ; Screen->FirstWindow
  3151.         beq.s    cs7
  3152.         move.l    a0,-(sp)
  3153. cs6        move.l    d0,a3
  3154.         move.l    (a3),-(sp)        ; Window->NextWindow
  3155.         bsr.s    clw
  3156.         move.l    (sp)+,d0
  3157.         bne.s    cs6            ; more windows !
  3158.         move.l    (sp)+,a0
  3159. cs7        CALL    CloseScreen,intuibase(a4)
  3160. cs8        rts
  3161.  
  3162. ;close a specified window
  3163.  
  3164. closewindow    bsr.s    getwnptr        ; get windowptr
  3165. clw        move.l    a3,d0            ; close win in a3
  3166.         beq.s    cs8
  3167.         cmp.l    wnptr(a4),a3        ; own window ?
  3168.         beq.s    cs8
  3169.         move.l    intuibase(a4),a6
  3170. cw1        move.l    36(a3),d0
  3171.         move.l    d0,a0
  3172.         beq.s    cw2
  3173.         move.w    #_LVOFreeSysRequest,d1
  3174.         move.w    28(a0),d0
  3175.         and.w    #$4000,d0
  3176.         bne.s    cw3
  3177.         move.l    a3,a1
  3178.         RECALL    EndRequest
  3179.         bra.s    cw1
  3180.  
  3181. cw2        move.w    #_LVOModifyIDCMP,d1    ; d0 already zero !
  3182.         bsr.s    cw3
  3183.         move.w    #_LVOCloseWindow,d1
  3184. cw3        move.l    a3,a0
  3185.         jmp    0(a6,d1.w)        ; CloseWin/FreeSysReq/ModIDCMP
  3186.  
  3187. getwnptr    bsr    getscr2
  3188.         moveq    #1,d6
  3189.         cmp.b    #'$',0(a0)
  3190.         bne.s    cw4
  3191.         bsr    readhex
  3192.         tst.w    d7
  3193.         bne.s    cwin
  3194.         bsr    syntax
  3195.         bra.s    cw10
  3196. cwin        move.l    d0,d4
  3197.         moveq    #0,d6
  3198. cw4        lea    buffer+100(a4),a2
  3199. cw5        move.l    (a2)+,a3
  3200.         move.l    4(a3),d0
  3201.         beq.s    cw9
  3202. cw6        move.l    d0,a3
  3203.         tst.w    d6
  3204.         bne.s    cw7
  3205.         cmp.l    a3,d4
  3206.         beq.s    cw11
  3207.         bra.s    cw8
  3208. cw7        move.l    32(a3),a1
  3209.         bsr    strcmp
  3210.         beq.s    cw11
  3211. cw8        move.l    0(a3),d0
  3212.         bne.s    cw6
  3213. cw9        dbra    d5,cw5
  3214.         move.w    #winnofound,d0
  3215.         bsr    putnamw
  3216. cw10        suba.l    a3,a3
  3217. cw11        rts
  3218.  
  3219. windowoff    movem.l    d1-d7/a0-a6,-(sp)
  3220.         bsr    getscr2
  3221.         bsr.s    cwin
  3222.         move.l    a3,d1
  3223.         beq.s    woff1
  3224.         bsr    clw
  3225.         move.l    -(a2),a0
  3226.         move.l    a0,d4
  3227.         tst.l    4(a0)
  3228.         bne.s    woff1
  3229.         bsr    getscr2
  3230.         bsr    csin
  3231. woff1        movem.l    (sp)+,d1-d7/a0-a6
  3232.         rts
  3233.  
  3234. closetskwin    movem.l    d1-d7/a0-a6,-(sp)
  3235. ctw0        bsr    getscr2
  3236.         lea    buffer+100(a4),a2
  3237. ctw1        move.l    (a2)+,a3
  3238.         addq.l    #4,a3
  3239. ctw6        move.l    (a3),d1
  3240.         move.l    d1,a3
  3241.         beq.s     ctw4
  3242.         move.l    86(a3),a0
  3243.         move.l    16(a0),d1
  3244.         cmp.l    d0,d1
  3245.         bne.s     ctw6
  3246.         move.l    d0,d1
  3247.         move.l    a3,d0
  3248.         bsr.s    windowoff
  3249.         move.l    d1,d0
  3250.         bra.s     ctw0
  3251. ctw4        dbra    d5,ctw1
  3252.         movem.l    (sp)+,d1-d7/a0-a6
  3253.         rts
  3254.  
  3255. ;Change the font for xopers window
  3256.  
  3257. myfont        moveq    #1,d5
  3258.         bra.s    setfon1
  3259.  
  3260. ;Change the font of a specified Window
  3261.  
  3262. setfont        moveq    #0,d5
  3263.  
  3264. setfon1        bsr.s    openfont
  3265.         tst.b    d2
  3266.         beq.s    1$            ; result not ok
  3267.         tst.w    d5
  3268.         bne.s    3$            ; our window
  3269.         move.l    d0,-(sp)
  3270.         move.l    a3,a0
  3271.         bsr    kllblnks
  3272.         bsr    getwnptr
  3273.         move.l    (sp)+,d0
  3274.         move.l    gfxbase(a4),a6        ; preload a6
  3275.         move.l    a3,d1
  3276.         beq.s    2$            ; no window
  3277.         cmp.l    wnptr(a4),a3
  3278.         beq.s    3$            ; xopers window
  3279.         move.l    d0,a0
  3280.         move.l    50(a3),a1
  3281.         RECALL    SetFont
  3282.         move.l    a3,a0
  3283.         CALL    RefreshWindowFrame,intuibase(a4)
  3284.         bra.s    1$
  3285. 3$        move.l    ownfont(a4),-(sp)    ; set font for Xoper
  3286.         move.l    d0,ownfont(a4)
  3287.         clr.b    topaz(a4)        ; use this font !
  3288.         bsr    usetopaz2
  3289.         move.l    (sp)+,d0
  3290.         beq.s    1$            ; no old font
  3291. 2$        move.l    d0,a1
  3292.         RECALL    CloseFont        ; no window or old xoper font
  3293. 1$        rts
  3294.  
  3295. ;Open a requested font
  3296.  
  3297. openfont    bsr    nodenam
  3298.         tst.b    0(a5)
  3299.         beq    3$            ; error
  3300.         tst.w    d5
  3301.         beq.s    14$            ; not myfont
  3302.         lea    deffont(a4),a0
  3303.         move.l    a5,a1
  3304.         bsr    strcmp            ; use "default" ?
  3305.         beq.s    15$
  3306.         sub.b    #$20,d0
  3307.         bne.s    14$
  3308. 15$        subq.w    #7,d1
  3309.         seq    d2            ; set as flag
  3310.         beq    1$            ; len was 7 !
  3311. 14$        move.l    a5,a3
  3312. 12$        cmp.b    #33,(a3)+
  3313.         bge.s    12$
  3314.         tst.b    -(a3)
  3315.         bne.s    11$            ; ok
  3316.         tst.w    d5
  3317.         beq    3$            ; error
  3318. 11$        clr.b    (a3)+
  3319.         lea    -6(a3),a0        ; check for '.font'
  3320.         lea    fontsuf(a4),a1
  3321.         bsr    strcmp
  3322.         beq.s    8$            ; correct suffix
  3323.         move.l    a5,a0
  3324.         lea    dummy(a4),a5
  3325.         move.l    a5,a2
  3326. 10$        move.b    (a0)+,(a2)+        ; copy fontname
  3327.         bne.s    10$
  3328.         subq.w    #1,a2
  3329. 9$        move.b    (a1)+,(a2)+        ; copy suffix
  3330.         bne.s    9$
  3331. 8$        lea    out-4(a4),a2
  3332.         move.l    a2,a0
  3333.         move.l    a5,(a0)+        ; +0
  3334.         move.w    procnum(a4),d2
  3335.         cmp.w    #7,d2
  3336.         bcc.s    7$            ; not smaller than 7 pixels !
  3337.         moveq    #7,d2
  3338. 7$        move.w    d2,(a0)+        ; +4
  3339.         clr.w    (a0)            ; +6
  3340.         move.l    a2,a0            ; TextAttr
  3341.         CALL    OpenFont,gfxbase(a4)
  3342.         move.l    d0,d4
  3343.         beq.s    6$
  3344.         move.l    d4,a0
  3345.         cmp.w    20(a0),d2        ; tf_YSize == ta_YSize ?
  3346.         beq.s    4$
  3347. 6$        lea     diskfont(a4),a1
  3348.         CALL    OldOpenLibrary,sysbase(a4)
  3349.         move.l    d0,d6
  3350.         beq.s    4$
  3351.         move.l    a2,a0            ; TextAttr
  3352.         CALL    OpenDiskFont,d6
  3353.         move.l    d0,d3
  3354.         beq.s    5$            ; no disk font
  3355.         exg.l    d3,d4
  3356.         move.l    d3,a1
  3357.         move.l    a1,d3
  3358.         beq.s    5$
  3359.         CALL    CloseFont,gfxbase(a4)    ; close font1
  3360. 5$        move.l    d6,a1
  3361.         CALL    CloseLibrary,sysbase(a4)
  3362. 4$        move.l    d4,d0            ; return font
  3363.         sne    d2            ; set as flag
  3364.         bne.s    1$
  3365.         move.w    #fonterr,d0        ; arrgh, no font found
  3366.         bsr    putstrw
  3367.         move.l    0(a2),d0        ; TextAttr->FontName
  3368.         bsr    putnam
  3369.         bra.s    1$
  3370. 3$        bsr    syntax            ; syntax error
  3371. 1$        rts
  3372.  
  3373. ;display loaded font names and definitions
  3374.  
  3375. fonts        lea    fohead(a4),a0
  3376.         bsr    puthead
  3377.         move.l    gfxbase(a4),a1
  3378.         lea    140(a1),a1        ; system fontlist
  3379. fo1        move.l    0(a1),a1
  3380.         tst.l    0(a1)
  3381.         beq.s    fo3
  3382.         bsr.s    fontdata
  3383.         bra.s    fo1
  3384. fo3        rts
  3385.  
  3386. fontdata    move.l    a1,d0
  3387.         move.l    d0,node(a4)
  3388.         bsr    hexa
  3389.         move.w    30(a1),d3
  3390.         bsr    worddec
  3391.         move.w    20(a1),d3
  3392.         bsr    worddec
  3393.         move.w    24(a1),d3
  3394.         bsr    worddec
  3395.         move.w    #romfnt,d0
  3396.         btst    #1,23(a1)
  3397.         beq.s    fod1
  3398.         addq.w    #diskfnt-romfnt,d0
  3399. fod1        bsr    putstrw
  3400.         move.w    #ffixed,d0
  3401.         btst    #5,23(a1)
  3402.         beq.s    1$
  3403.         addq.w    #fprop-ffixed,d0
  3404. 1$        bsr    putstrw
  3405.         move.b    32(a1),d3
  3406.         bsr    bytedec
  3407.         move.b    33(a1),d3
  3408.         bsr    bytedec
  3409.         move.l    10(a1),d0
  3410.         bra    putnam
  3411.  
  3412. ;set update rate
  3413.  
  3414. settime        bsr    getfrac
  3415.         tst.b    d7
  3416.         bne.s    st1
  3417.         move.w    #whattime,d0
  3418.         bsr    putstrw
  3419.         move.l    timeoutm(a4),d0
  3420.         move.l    #100000,d1
  3421.         bsr    div
  3422.         moveq    #0,d1
  3423.         move.b    timeout(a4),d1
  3424.         mulu    #10,d1
  3425.         add.l    d1,d0
  3426.         bne.s    1$
  3427.         move.w    #timenotset,d0
  3428.         bra    putnamw
  3429. 1$        bsr    putfrac
  3430.         bra    newline
  3431.  
  3432. st1        divs    #10,d2
  3433.         move.b    d2,timeout(a4)
  3434.         swap    d2
  3435.         ext.l    d2
  3436.         moveq    #0,d3
  3437.         subq.w    #1,d2
  3438.         bmi.s    1$
  3439. 2$        add.l    #100000,d3
  3440.         dbra    d2,2$
  3441. 1$        move.l    d3,timeoutm(a4)
  3442.         rts
  3443.  
  3444. zerotimer    bsr    nodenam
  3445.         moveq    #2,d7
  3446.         lea    TRuNode(pc),a3
  3447.         bsr    findnam
  3448.         tst.b    d7
  3449.         beq.s    1$
  3450.         bsr    gettimeentry
  3451.         lea    usedtime(a4),a0
  3452.         clr.l    0(a0,d0)
  3453. 1$        rts
  3454.  
  3455. ;cancel a task or a process. The theory is quite simple:
  3456. ;(Process->ReturnAddr)-4 points to the return address on
  3457. ;the stack. Task->SPReg points to the next instruction
  3458. ;to be executed. We just need a
  3459. ; *(Task->SPReg) = *(Process->ReturnAddr-4).
  3460. ;If the process has been started from Dos (CLI) and
  3461. ;the process is doing disk I/O, the CLI will respond with
  3462. ;a GURU #87000004 (AsyncPKT=unexpected packed received).
  3463. ;Thats why the calling CLI is also canceled.
  3464.  
  3465. cancel        tst.l    infile(a4)
  3466.         beq.s    cancel1
  3467.         rts
  3468. cancel1     clr.l    remembr(a4)        ; used for CLI stdio
  3469.         clr.l    remembr2(a4)
  3470.         clr.b    bool(a4)
  3471.         bsr    nodenam
  3472. testagain    moveq    #1,d7
  3473.         lea    TReNode(pc),a3
  3474.         bsr    findnam
  3475.         tst.b    d7
  3476.         bne.s    canok
  3477. cnerr        move.w    #stperr,d0
  3478.         bra    putnamw
  3479.  
  3480. canok        moveq    #0,d5
  3481. canok2        move.l    d0,pointer(a4)        ; d0=task
  3482.         move.l    d0,a1
  3483.         cmp.b    #1,8(a1)        ; TASK ?
  3484.         bne.s    isproc
  3485.         CALL    RemTask,sysbase(a4)
  3486.         move.l    pointer(a4),d0
  3487.         bsr    closetsports
  3488.         move.l    pointer(a4),d0
  3489.         bra    closetskwin
  3490.  
  3491. isproc        tst.w    d5
  3492.         bne.s    isproc2            ; second try !
  3493.         movem.l    d0-d7/a0-a6,-(sp)
  3494.         moveq    #-1,d0            ; needed for recursive killing tasks
  3495.         CALL    AllocSignal,sysbase(a4)
  3496.         move.l    d0,cancelbnum(a4)
  3497.         moveq    #0,d1
  3498.         bset    d0,d1
  3499.         move.l    d1,cancelbit(a4)
  3500.         movem.l    (sp)+,d0-d7/a0-a6
  3501.  
  3502. isproc2        moveq    #0,d5
  3503.         tst.l    172(a1)            ; pr_CLI
  3504.         beq.s    wascreproc
  3505.         move.l    $80(a1),a2        ; Seglist
  3506.         adda.l    a2,a2
  3507.         adda.l    a2,a2
  3508.         move.l    12(a2),d1        ; empty ?
  3509.         bne.s    wascreproc
  3510.         move.l    172(a1),a2        ; CommandLineInterface
  3511.         adda.l    a2,a2
  3512.         adda.l    a2,a2
  3513.         move.l    60(a2),d5        ; cli_Module
  3514.         tst.l    40(a2)            ; IsInteractive
  3515.         beq    dosreturn
  3516.         move.l    28(a2),remembr(a4)    ; yes,get Cli-Window locks
  3517.         move.l    56(a2),remembr2(a4)
  3518.         bra    dosreturn
  3519. wascreproc    tst.b    bool(a4)        ; it is not a CLI, ask what to do
  3520.         bne.s    unload
  3521.         move.b    #3,bool(a4)
  3522.         bsr    ResumeOutput
  3523.         move.w    #canerr0,d0        ; ask for Workbench
  3524.         bsr    putstrw
  3525.         bsr    readline
  3526.         cmp.b    #'y',d0
  3527.         beq.s    andagain
  3528.         move.b    #2,bool(a4)
  3529.         bsr    ResumeOutput
  3530.         move.w    #canerr1,d0        ; ask for unload
  3531.         bsr    putstrw
  3532.         bsr    readline
  3533.         cmp.b    #'y',d0
  3534.         bne.s    andagain
  3535.         move.b    #1,bool(a4)
  3536. andagain    move.l    pointer(a4),d0
  3537.         moveq    #1,d7
  3538.         lea    TReNode(pc),a3
  3539.         bsr    tstnode
  3540.         tst.w    d5
  3541.         beq    cnerr
  3542.         bra    canok2
  3543.  
  3544. unload        move.l    128(a1),d4        ; get Segmentlist
  3545.         beq.s    unl3
  3546.         lsl.l    #2,d4
  3547.         move.l    d4,a3
  3548.         cmp.l    #100,0(a3)
  3549.         bpl.s    ulerr
  3550.         move.l    12(a3),d4
  3551. unl3        tst.l    d4
  3552.         bne.s    unl4
  3553. ulerr        move.w    #unloaderr,d0        ; no Segments !?
  3554.         bra    putnamw
  3555.  
  3556. unl4        cmp.b    #3,bool(a4)        ; Workbench Task
  3557.         bne.s    unl2
  3558.         move.l    a1,-(sp)
  3559.         moveq    #40,d0            ; build a copy of the
  3560.         move.l    #$10001,d1        ; Workbench startup-message
  3561.         CALL    AllocMem,sysbase(a4)
  3562.         move.l    d0,startmess(a4)
  3563.         move.l    d0,a0
  3564.         move.l    a0,-(sp)
  3565.         move.b    #5,8(a0)
  3566.         move.w    #20,18(a0)
  3567.         move.l    d4,24(a0)
  3568.         moveq    #92,d0
  3569.         add.l    4(sp),d0
  3570.         move.l    d0,20(a0)
  3571.         lea    wbportnam(a4),a1
  3572.         RECALL    FindPort
  3573.         movem.l    (sp)+,a0/a1
  3574.         move.l    d0,14(a0)
  3575.         bne.s    unl2
  3576.         move.w    #noworkbench,d0
  3577.         bra    putnamw
  3578.  
  3579. unl2        cmp.b    #1,bool(a4)
  3580.         bne.s    dosreturn
  3581.         move.l    a1,-(sp)        ; unload process manualy
  3582.         move.l    d4,d1
  3583.         CALL    UnLoadSeg,dosbase(a4)
  3584.         move.l    (sp)+,a1
  3585.  
  3586. dosreturn    move.l    140(a1),savedat(a4)    ; Processnumber
  3587. dosret1        move.w    #$4000,$dff09a
  3588.         move.l    54(a1),a3
  3589.         lea    endtask(pc),a0
  3590.         move.l    a0,0(a3)
  3591.         tst.b    gotguru(a4)
  3592.         bne.s    1$
  3593.         tst.b    bool(a4)
  3594.         bne.s    1$
  3595.         move.b    #2,106(a1)        ; ignore messages
  3596. 1$        cmp.b    #4,15(a1)        ; if waiting
  3597.         bne.s    doswait
  3598.         move.l    a1,d4
  3599.         CALL    Remove,sysbase(a4)
  3600.         move.l    d4,a1
  3601.         lea    406(a6),a0        ; activate the task
  3602.         RECALL    AddHead
  3603.         move.l    d4,a1
  3604.  
  3605. doswait        move.w    #$C000,$dff09a
  3606.  
  3607.         tst.b    bool(a4)
  3608.         bne.s    endnodos
  3609.         tst.l    d5
  3610.         beq.s    endcanc
  3611.  
  3612.         move.l    172(a1),a2
  3613.         adda.l    a2,a2
  3614.         adda.l    a2,a2
  3615. dwa1        movem.l    d0-d7/a0-a6,-(sp)
  3616.         move.l    cancelbit(a4),d0
  3617.         CALL    Wait,sysbase(a4)
  3618.         movem.l    (sp)+,d0-d7/a0-a6
  3619.         tst.b    gotguru(a4)
  3620.         bne.s    endnodos
  3621.         moveq    #0,d5
  3622.         bra.s    dosret1
  3623.  
  3624. endcanc        move.l    a1,-(sp)
  3625.         move.l    dosbase(a4),a6
  3626.         move.l    remembr(a4),d1        ; close CLI-Window
  3627.         beq.s    ecan1            ; if any
  3628.         RECALL    Close
  3629. ecan1        move.l    remembr2(a4),d1
  3630.         beq.s    ecan2
  3631.         RECALL    Close
  3632. ecan2        move.l    (sp)+,a1
  3633.  
  3634.         move.l    savedat(a4),d0        ; remove Task from
  3635.         move.l    dosbase(a4),a2        ; TaskArray
  3636.         move.l    34(a2),a2
  3637.         move.l    0(a2),a2
  3638.         adda.l    a2,a2
  3639.         adda.l    a2,a2
  3640.         lsl.l    #2,d0
  3641.         clr.l    0(a2,d0)
  3642.  
  3643. endnodos    move.l    a1,d0
  3644.         bsr    closetskwin
  3645.         move.l    a1,d0
  3646.         bsr    closetsports
  3647.         move.l    cancelbnum(a4),d0    ; remove our Signal
  3648.         CALL    FreeSignal,sysbase(a4)
  3649.         rts
  3650.  
  3651. ;This Code is (hopefully) executed by the Process we want to kill
  3652.  
  3653. endtask        lea    dataarea(pc),a4
  3654.         move.l    sysbase(a4),a6
  3655.         move.l    276(a6),a1
  3656.         move.l    176(a1),a1        ; Process_ReturnAddr
  3657.         lea    -4(a1),sp        ; reset Process Stackptr
  3658.         tst.b    bool(a4)
  3659.         bne.s    et0
  3660.         movea.l    mytask(a4),a1
  3661.         move.l    cancelbit(a4),d0    ; signal Xoper it
  3662.         RECALL    Signal            ; died
  3663. et0        cmp.b    #3,bool(a4)        ; Workbench Process ?
  3664.         bne.s    et1
  3665.         RECALL    Forbid
  3666.         move.l    startmess(a4),a1
  3667.         RECALL    ReplyMsg        ; reply startup message
  3668. et1        rts
  3669.  
  3670. ;Stop a task (just queue it on a special list)
  3671.  
  3672. freeze        bsr    nodenam
  3673.         moveq    #1,d7
  3674.         lea    TReNode(pc),a3
  3675.         bsr    findnam
  3676.         tst.b    d7
  3677.         bne.s    frok
  3678. frerr        move.w    #stperr,d0
  3679.         bra    putstrw
  3680. frok        move.l    d0,a1
  3681.         cmp.b    #13,8(a1)
  3682.         beq.s    1$
  3683.         cmp.b    #1,8(a1)
  3684.         bne.s    frerr
  3685. 1$        move.w    #$4000,$dff09a
  3686.         CALL    Remove,sysbase(a4)
  3687.         move.w    #$C000,$dff09a
  3688.         move.l    d0,a1
  3689.         move.l    d0,a5
  3690.         lea     stplist(a4),a0
  3691.         RECALL    AddHead
  3692.         add.b    #4,15(a5)
  3693.         rts
  3694.  
  3695. ;put the task back on its list
  3696.  
  3697. warm        bsr    nodenam
  3698.         cmp.b    #'$',0(a5)
  3699.         bne.s    1$
  3700.         move.l    d7,d2
  3701.         move.l    a5,a0
  3702.         bsr    readhex
  3703.         tst.b    d7
  3704.         beq.s    1$
  3705.         move.l    stplist(a4),a3
  3706. 3$        tst.l    0(a3)
  3707.         beq.s    2$
  3708.         cmp.l    a3,d0
  3709.         beq.s    waok
  3710.         move.l    0(a3),a3
  3711.         bra.s    3$
  3712. 1$        lea    stplist(a4),a0
  3713.         movea.l    a5,a1
  3714.         moveq    #0,d7
  3715.         bsr    fn4
  3716.         tst.b    d7
  3717.         bne.s    waok
  3718. 2$        move.w    #waerr,d0
  3719.         bra    putstrw
  3720. waok        move.w    #$4000,$dff09a
  3721.         move.l    d0,a1
  3722.         CALL    Remove,sysbase(a4)
  3723.         move.l    d0,a1
  3724.         move.l    d0,a5
  3725.         move.l    TReNode(pc),a0
  3726.         cmp.b    #8,15(a1)
  3727.         bne.s    wa1
  3728.         move.l    TWaNode(pc),a0
  3729. wa1        adda.l    a6,a0
  3730.         RECALL    AddTail
  3731.         move.l    d0,a1
  3732.         subq.b    #4,15(a5)
  3733.         move.w    #$C000,$dff09a
  3734.         move.l    18(a5),d0
  3735.         and.l    26(a5),d0
  3736.         beq.s    wa2
  3737.         movea.l    a5,a1
  3738.         RECALL    Signal
  3739. wa2        rts
  3740.  
  3741. ;show the hunks of a process
  3742. hunks        bsr    nodenam
  3743.         moveq    #2,d7
  3744.         lea    TRuNode(pc),a3
  3745.         bsr    findnam
  3746.         tst.b    d7
  3747.         bne.s    hu1
  3748.         rts
  3749. hu1        move.l    d0,a5
  3750.         cmp.b    #13,8(a5)
  3751.         beq.s    hu2
  3752.         move.w    #noprocs,d0
  3753.         bra    putnamw
  3754. hu2        move.l    128(a5),d0
  3755.         beq.s    noprogload
  3756.         lsl.l    #2,d0
  3757.         move.l    d0,a3
  3758.         move.l    12(a3),d1
  3759.         beq.s    hu3
  3760.         cmp.l    #100,0(a3)
  3761.         ble.s    1$
  3762.         move.w    #unloaderr,d0
  3763.         bra.s    huxx
  3764. 1$        move.w    #segloaded,d0
  3765.         bsr    putnamw
  3766.         bra.s    hu5
  3767. hu3        move.l    172(a5),d1
  3768.         bne.s    hu4
  3769. noprogload    move.w    #notload,d0
  3770. huxx        bra    putnam
  3771. hu4        move.w    #cliprocs,d0
  3772.         bsr    putnamw
  3773.         lsl.l    #2,d1
  3774.         move.l    d1,a5
  3775.         move.l    60(a5),d1
  3776.         beq.s    noprogload
  3777.         move.w    #procloaded,d0
  3778.         bsr    putstrw
  3779.         move.l    16(a5),d0
  3780.         bsr    putbcpl
  3781.         bsr    newline
  3782. hu5        lea    hunkheader(a4),a0
  3783.         bsr    puthead
  3784.         moveq    #0,d5
  3785. hu6        move.l    d5,d3
  3786.         bsr    bytedec
  3787.         addq.l    #1,d5
  3788.         move.l    d1,d0
  3789.         bsr    hexa
  3790.         lsl.l    #2,d1
  3791.         move.l    d1,a5
  3792.         move.l    d1,d0
  3793.         addq.l    #4,d0
  3794.         bsr    hexa
  3795.         move.l    -4(a5),d0
  3796.         moveq    #1,d3
  3797.         bsr    longdec
  3798.         move.l    #'($',d0
  3799.         bsr    putlongascii
  3800.         move.l    -4(a5),d0
  3801.         bsr    hexa
  3802.         subq.l    #1,ptr(a4)
  3803.         moveq    #')',d0
  3804.         bsr    putchar
  3805.         bsr    newline
  3806.         move.l    0(a5),d1
  3807.         bne.s    hu6
  3808.         rts
  3809.  
  3810. ;change the priority of a node
  3811.  
  3812. pri        bsr    getnum
  3813.         tst.b    d7
  3814.         beq    syntax
  3815.         move.b    d2,newpri(a4)
  3816.         bsr    nodenam2
  3817.         moveq    #8,d7
  3818.         lea    TRuNode(pc),a3
  3819.         bsr    findnam
  3820.         tst.b    d7
  3821.         beq.s    pi1
  3822.         move.l    d0,a1
  3823.         cmp.b    #13,8(a1)
  3824.         beq.s    tp2
  3825.         cmp.b    #1,8(a1)
  3826.         beq.s    tp2
  3827.         move.b    newpri(a4),9(a1)
  3828.         lea    SemNode(pc),a0
  3829.         cmp.l    a0,a3
  3830.         ble.s    pi2
  3831.         move.w    #listerr,d0
  3832.         bra    putnamw
  3833. pi2        CALL    Forbid,sysbase(a4)
  3834.         RECALL    Remove
  3835.         move.l    d0,a1
  3836.         movea.l    (a3),a0
  3837.         adda.l    a6,a0
  3838.         RECALL    Enqueue
  3839.         RECALL    Permit
  3840. pi1        rts
  3841.  
  3842. ;set the priority of our task
  3843.  
  3844. mypri        bsr    getnum
  3845.         tst.b    d7
  3846.         beq    syntax
  3847.         move.l    sysbase(a4),a1
  3848.         move.l    276(a1),a1
  3849.         move.l    d2,d0
  3850.         bra.s    tp3
  3851.  
  3852. ;modify a task's priority
  3853.  
  3854. taskpri        bsr    getnum
  3855.         tst.b    d7
  3856.         beq    syntax
  3857.         move.b    d2,newpri(a4)
  3858.         bsr    nodenam
  3859.         moveq    #2,d7
  3860.         lea    TRuNode(pc),a3
  3861.         bsr    findnam
  3862.         tst.b    d7
  3863.         beq.s    tp1
  3864.         move.l    d0,a1
  3865. tp2        move.b    newpri(a4),d0
  3866. tp3        CALL    SetTaskPri,sysbase(a4)
  3867. tp1        rts
  3868.  
  3869. ;set all break signals of a task
  3870.  
  3871. break        move.l    #$f000,d0
  3872.         bra.s    setthem
  3873.  
  3874. signal        bsr    readhex
  3875.         tst.b    d7
  3876.         beq    syntax
  3877. setthem     move.l    d0,savedat(a4)
  3878.         bsr    nodenam
  3879.         moveq    #2,d7
  3880.         lea    TReNode(pc),a3
  3881.         bsr    findnam
  3882.         tst.b    d7
  3883.         beq.s    1$
  3884.         move.l    d0,a1
  3885.         move.l    savedat(a4),d0
  3886.         and.l    18(a1),d0
  3887.         CALL    Signal,sysbase(a4)
  3888. 1$        rts
  3889.  
  3890. ;set up a list of tasknames which should't be displayed
  3891.  
  3892. hide        cmp.b    #10,0(a0)
  3893.         bne.s    hid5
  3894.         bra    syntax
  3895. hid5        lea    hidestart(a4),a2
  3896.         move.l    a2,d3
  3897. hid0        tst.l    0(a2)
  3898.         beq.s    hid1
  3899.         move.l    0(a2),a2
  3900.         lea    4(a2),a1
  3901.         bsr    strcmp
  3902.         beq.s    hid2
  3903.         move.l    a2,d3
  3904.         bra.s    hid0
  3905. hid1        move.l    a0,a3
  3906.         moveq    #10,d0
  3907.         bsr    strlen2
  3908.         addq.l    #5,d0
  3909.         moveq    #1,d1
  3910.         swap    d1
  3911.         CALL    AllocMem,sysbase(a4)
  3912.         move.l    d0,a1
  3913.         move.l    a1,d0
  3914.         beq.s     hid4
  3915.         move.l    d0,0(a2)
  3916.         addq.l    #4,a1
  3917. hid3        cmp.b    #10,0(a3)
  3918.         beq.s    hid4
  3919.         move.b    (a3)+,(a1)+
  3920.         bra.s    hid3
  3921. hid4        rts
  3922. hid2        move.l    d3,a3
  3923.         move.l    0(a2),0(a3)
  3924. freehidden    lea    4(a2),a0
  3925.         bsr    strlen
  3926.         addq.l    #5,d0
  3927.         move.l    a2,a1
  3928.         CALL    FreeMem,sysbase(a4)
  3929.         rts
  3930.  
  3931. freehidmem    move.l    hidestart(a4),a3
  3932. fhm0        move.l    a3,d0
  3933.         beq.s    fhm1
  3934.         move.l    a3,a2
  3935.         move.l    0(a2),a3
  3936.         bsr.s    freehidden
  3937.         bra.s    fhm0
  3938. fhm1        rts
  3939.  
  3940. hideit        tst.b    hideon(a4)
  3941.         beq.s    pt76
  3942.         lea    hidestart(a4),a3
  3943.         move.l    4(a5),a0
  3944. pt74        tst.l    0(a3)
  3945.         beq.s    pt76
  3946.         move.l    0(a3),a3
  3947.         lea    4(a3),a1
  3948.         bsr    strcmp
  3949.         bne.s    pt74
  3950.         rts
  3951. pt76         moveq    #1,d0
  3952.         rts
  3953.  
  3954. ;set up an ALIAS list
  3955.  
  3956. alias        cmp.b    #10,0(a0)
  3957.         beq    showalias
  3958.         bsr    strbuf
  3959.         lea    buffer(a4),a3
  3960.         move.l    a0,a5
  3961.         move.l    a3,a0
  3962.         bsr    strlen
  3963.         tst.l    d0
  3964.         beq    syntax
  3965.  
  3966.         cmp.w    #1,d0
  3967.         bne.s    5$
  3968.         lea    params(a4),a0
  3969.         moveq    #parmnum-1,d1
  3970.         move.b    0(a3),d2
  3971. 6$        cmp.b    (a0)+,d2
  3972.         dbeq    d1,6$
  3973.         bne.s    5$
  3974.         move.w     #aliaserr,d0
  3975.         bsr    putstrw
  3976.         move.w    #params,d0
  3977.         bsr    putstrw
  3978.         move.w    #aliaserr2,d0
  3979.         bra    putnamw
  3980.  
  3981. 5$        move.l    d0,d5
  3982.         bsr    findalias
  3983.         tst.l    d2
  3984.         bmi.s    7$            ; no alias
  3985.         lea    aliaslist(a4),a0
  3986.         cmp.l    (a0),a2
  3987. 10$        beq.s    9$
  3988.         move.l    (a0),a0
  3989.         bra.s    10$
  3990. 9$        move.l    (a2),(a0)
  3991.         lea    5(a2),a0
  3992. 8$        tst.b    (a0)+
  3993.         bne.s    8$
  3994.         move.l    a0,d0
  3995.         move.l    a2,a1
  3996.         sub.l    a1,d0
  3997.         CALL    FreeMem,sysbase(a4)
  3998.         cmp.b    #10,0(a5,d5.l)
  3999.         beq.s    1$            ; was 'unalias'
  4000.  
  4001. 7$        lea    0(a5,d5.l),a0
  4002.         bsr    kllblnks
  4003.         bsr    findcmd
  4004.         tst.l    d2
  4005.         bmi    syntax
  4006.         move.l    a5,a0
  4007.         bsr    strbuf
  4008.  
  4009.         addq.l    #6,d5
  4010.         move.l    d5,d0
  4011.         moveq    #1,d1
  4012.         swap    d1
  4013.         CALL    AllocMem,sysbase(a4)
  4014.         tst.l    d0
  4015.         beq.s    1$
  4016.  
  4017.         lea    aliaslist(a4),a0
  4018. 2$        move.l    (a0),d1
  4019.         beq.s    3$
  4020.         move.l    d1,a0
  4021.         bra.s    2$
  4022. 3$        move.l    d0,0(a0)
  4023.  
  4024.         move.l    d0,a0
  4025.         move.b    d2,4(a0)
  4026.  
  4027.         addq.w    #5,a0
  4028. 4$        move.b    (a3)+,(a0)+
  4029.         bne.s    4$
  4030. 1$        rts
  4031.  
  4032. showalias    lea    alhead(a4),a0
  4033.         bsr    puthead
  4034.         move.l    aliaslist(a4),d0
  4035.         beq.s    1$
  4036. 2$        move.l    d0,a5
  4037.         addq.l    #5,d0
  4038.         bsr    putstr
  4039.         move.w    #15,d1
  4040.         bsr    tab
  4041.         move.w    #equal,d0
  4042.         bsr    putstrw
  4043.         move.b    4(a5),d0
  4044.         ext.w    d0
  4045.         bsr.s    getcmdptr
  4046.         bsr    putnam
  4047.         move.l    0(a5),d0
  4048.         bne.s    2$
  4049. 1$        rts
  4050.  
  4051. freealias    move.l    aliaslist(a4),a3
  4052. 1$        move.l    a3,d0
  4053.         beq.s    2$
  4054.         move.l    a3,a2
  4055.         move.l    0(a2),a3
  4056.         lea    5(a2),a0
  4057.         bsr    strlen
  4058.         addq.l    #6,d0
  4059.         move.l    a2,a1
  4060.         CALL    FreeMem,sysbase(a4)
  4061.         bra.s    1$
  4062. 2$        rts
  4063.  
  4064. getcmdptr    move.l    a0,-(sp)
  4065.         lea    commds(a4),a0
  4066. 2$        subq.w    #1,d0
  4067.         bcs.s    1$
  4068. 3$        tst.b    (a0)+
  4069.         bne.s    3$
  4070.         bra.s    2$
  4071. 1$        move.l    a0,d0
  4072.         move.l    (sp)+,a0
  4073.         rts
  4074.  
  4075. ;add a fkey definition to the fkey list. Each entry
  4076. ;looks like this: long Succ, long Pred, byte Key#, byte length,
  4077. ;          char text[]
  4078.  
  4079. showfkeys    lea    fkhead(a4),a0
  4080.         bsr    puthead
  4081.         lea    fkeys(a4),a1
  4082. 1$        move.l    0(a1),a1
  4083.         tst.l    0(a1)
  4084.         beq.s    2$
  4085.         moveq    #'F',d0
  4086.         bsr    putchar
  4087.         moveq    #1,d3
  4088.         add.b    8(a1),d3
  4089.         bsr    bytedec
  4090.         move.b    9(a1),d1
  4091.         subq.b    #1,d1
  4092.         lea    10(a1),a2
  4093. 3$        move.b    (a2)+,d0
  4094.         bsr    putchar
  4095.         subq.b    #1,d1
  4096.         bcc.s    3$            ; dbra for bytes ...
  4097.         bsr    newline
  4098.         bra.s    1$
  4099. 2$        rts
  4100.  
  4101. setfkey        bsr    nodenam
  4102.         move.w    procnum(a4),d5
  4103.         beq.s    showfkeys
  4104.         cmp.w    #21,d5
  4105.         bcc    syntax
  4106.         subq.w    #1,d5
  4107.         move.w    d5,procnum(a4)
  4108.         move.l    sysbase(a4),a6
  4109.         lea    fkeys(a4),a1
  4110. 1$        move.l    0(a1),a1
  4111.         tst.l    0(a1)
  4112.         beq.s    2$
  4113.         cmp.b    8(a1),d5
  4114.         bne.s    1$
  4115.         move.l    a1,d3
  4116.         RECALL    Remove
  4117.         move.l    d3,a1
  4118.         bsr.s    removefkey
  4119. 2$        tst.b    0(a5)
  4120.         beq.s    4$
  4121.         move.l    a5,a0
  4122.         bsr    strlen
  4123.         move.l    d0,d5
  4124.         add.w    #10,d0
  4125.         moveq    #0,d1
  4126.         RECALL    AllocMem
  4127.         move.l    d0,a1
  4128.         move.l    a1,d0
  4129.         beq.s    4$
  4130.         move.l    d0,a3
  4131.         move.b    procnum+1(a4),8(a1)
  4132.         move.b    d5,9(a1)
  4133.         lea    fkeys(a4),a0
  4134.         RECALL    AddHead
  4135.         lea    10(a3),a3
  4136.         subq.w    #1,d5
  4137. 3$        move.b    (a5)+,(a3)+
  4138.         dbeq    d5,3$
  4139. 4$        rts
  4140.  
  4141. clrfkeys    move.l    sysbase(a4),a6
  4142. 2$        lea    fkeys(a4),a0
  4143.         RECALL    RemHead
  4144.         move.l    d0,a1
  4145.         move.l    a1,d0
  4146.         beq.s    1$
  4147.         bsr.s    removefkey
  4148.         bra.s    2$
  4149. 1$        rts
  4150.  
  4151. removefkey    move.b    9(a1),d0        ; length
  4152.         ext.w    d0
  4153.         ext.l    d0
  4154.         add.w    #10,d0
  4155.         jmp    _LVOFreeMem(a6)
  4156.  
  4157. ;'flushlibs'
  4158.  
  4159. flush        moveq    #-1,d0
  4160.         moveq    #0,d1
  4161.         move.l    sysbase(a4),a6
  4162.         jmp    _LVOAllocMem(a6)
  4163.  
  4164. ;display library->lib_IDString
  4165.  
  4166. info        bsr    nodenam2
  4167.         moveq    #2,d7
  4168.         lea    DevNode(pc),a3
  4169.         bsr    findnam
  4170.         tst.b    d7
  4171.         beq.s    removefkey-2        ; hack !
  4172.         move.l    d0,a0
  4173.         move.l    24(a0),d0
  4174.         beq.s    if2
  4175.         move.l    d0,a0
  4176.         tst.b    (a0)
  4177.         bne.s    if1
  4178. if2        move.w    #noinfo,d0
  4179.         bsr    putstrw
  4180.         move.l    a5,d0
  4181. if1        bra    putnam
  4182.  
  4183. ; reset vectors
  4184.  
  4185. capture        move.l    sysbase(a4),a1
  4186.         lea     42(a1),a0
  4187.         moveq    #2,d6
  4188.         lea    coldtxt(a4),a3
  4189. cap0        move.l    a3,d0
  4190.         bsr    putstr
  4191.         move.l    (a0)+,d0
  4192.         bne.s    cap1
  4193.         move.w    #unset,d0
  4194.         bsr    putstrw
  4195.         bra.s    cap2
  4196. cap1        bsr    hexa
  4197. cap2        bsr    newline
  4198.         lea     15(a3),a3
  4199.         dbra    d6,cap0
  4200.         move.w    #kicktxt,d0
  4201.         bsr    putstrw
  4202.         move.l    546(a1),d0
  4203.         bne.s    kickm3
  4204.         move.w    #unset,d0
  4205.         bra    putnamw
  4206. kickm3        move.l    d0,-(sp)
  4207.         bsr    newline
  4208.         lea    kickhead(a4),a0
  4209.         bsr    puthead
  4210.         move.l    (sp)+,a0
  4211. kickm0        move.l    a0,d0
  4212.         beq.s    kickm4
  4213.         bpl.s    kickm1
  4214.         bclr    #31,d0
  4215.         move.l    d0,a0
  4216.         bra.s    kickm0
  4217. kickm1        move.w    14(a0),d6
  4218.         subq.w    #1,d6
  4219.         lea    16(a0),a2
  4220. kickm2        move.l    0(a2),d0
  4221.         bsr    hexa
  4222.         move.l    (a2)+,d0
  4223.         move.l    (a2)+,d4
  4224.         add.l    d4,d0
  4225.         bsr    hexa
  4226.         move.l    d4,d0
  4227.         moveq    #0,d3
  4228.         bsr    longdec
  4229.         bsr    newline
  4230.         dbra    d6,kickm2
  4231.         move.l    0(a0),a0
  4232.         bra.s    kickm0
  4233. kickm4        rts
  4234.  
  4235. clrcold        moveq    #42,d0
  4236.         bra.s    chksum
  4237. clrcool        moveq    #46,d0
  4238.         bra.s    chksum
  4239. clrwarm        moveq    #50,d0
  4240.  
  4241. chksum        move.l    sysbase(a4),a0
  4242.         clr.l    0(a0,d0.w)
  4243.         lea    34(a0),a1
  4244.         moveq    #22,d0
  4245. addchk        add.w    (a1)+,d1
  4246.         dbra     d0,addchk
  4247.         not.w    d1
  4248.         move.w    d1,82(a0)
  4249.         rts
  4250.  
  4251. ;Save the command line to be repeated. If this line doesn't produce
  4252. ;any output, don't repeat it at all
  4253. repeatcmd    not.b    repeat(a4)
  4254.         beq.s    3$
  4255.         move.w    repeatlen(a4),d0
  4256.         subq.w    #7,d0
  4257.         beq.s    4$
  4258.         move.w    d0,repeatlen(a4)
  4259.         lea    repeatbuffer(a4),a1
  4260.         lea    dummy(a4),a2
  4261.         move.w    d0,d1
  4262. 1$        move.b    0(a0),(a1)+
  4263.         move.b    (a0)+,(a2)+
  4264. 2$        dbra    d1,1$
  4265.         clr.l    lastprinted(a4)
  4266.         clr.b    printed(a4)
  4267.         bsr    cli
  4268.         tst.b    printed(a4)
  4269.         beq.s    4$
  4270.         bsr    starttimer
  4271. 3$        rts
  4272. 4$        clr.b    repeat(a4)
  4273.         bra.s    3$
  4274.  
  4275. ;save the parameters from a 'window x y width height' call
  4276. setwindow    tst.l    infile(a4)
  4277.         bne.s    wiw1
  4278. wiw3        move.w    #wiwerr,d0
  4279.         bra    putnamw
  4280. wiw1        lea    window_l(a4),a3
  4281.         moveq    #3,d5
  4282. wiw0        bsr    getnum
  4283.         tst.w    d7
  4284.         beq.s    wiw2
  4285.         move.w    d2,(a3)+
  4286.         dbra    d5,wiw0
  4287. wiw2        rts
  4288.  
  4289. iconpos        bsr    getnum            ; set icon position
  4290.         tst.w    d7
  4291.         beq.s    1$
  4292.         move.w    d2,-(sp)
  4293.         bsr    getnum
  4294.         swap    d2
  4295.         move.w    (sp)+,d2
  4296.         swap    d2            ; X.w,Y.w
  4297.         tst.w    d7
  4298.         beq.s    1$
  4299.         move.l    d2,icnwindow(a4)    ; store new pos
  4300. 1$        rts
  4301.  
  4302. iconbackdrp    eor.w    #$100,icnwindow+16(a4)    ; wn_Flags+2
  4303.         rts
  4304.  
  4305. ;toggle patchmode (ignore cmd if a setfunction manager is installed)
  4306. smartpatch    lea    setmannam(a4),a1    ; public manager port
  4307.         CALL    FindPort,sysbase(a4)
  4308.         tst.l    d0
  4309.         bne.s    smartpatch-2        ; hack !
  4310.         lea    patchmode(a4),a2
  4311.         bra.s    onoff
  4312.  
  4313. ;toggle commodity on/off
  4314. cxhandler    lea    cxstate(a4),a2
  4315.         bsr.s    onoff
  4316.         tst.l    infile(a4)
  4317.         bne.s    1$            ; script !
  4318.         bsr    setwintitle
  4319. 1$        rts
  4320.  
  4321. ;toggle TaskInfo
  4322. taskinfo    lea    tinfo(a4),a2
  4323.         bra.s    onoff
  4324.  
  4325. ;toggle CLI-Commands
  4326. clicmd        lea    cmdcli(a4),a2
  4327.         bra.s    onoff
  4328.  
  4329. ;toggle task-header display
  4330. nohead        lea    headon(a4),a2
  4331.         bra.s    onoff
  4332.  
  4333. ;toggle hide entries
  4334. hidden        lea    hideon(a4),a2
  4335.         bra.s    onoff
  4336.  
  4337. ;toggle sort on/off
  4338. sort        lea    sorton(a4),a2
  4339.         bra.s    onoff
  4340.  
  4341. ;toggle task-ports display
  4342. taskports    lea    tports(a4),a2
  4343.         bra.s    onoff
  4344.  
  4345. ;toggle CPUSE task list
  4346. usage        lea    useageon(a4),a2
  4347.  
  4348. ;test if 'on'(-1) or 'off'(0) was entered
  4349.  
  4350. onoff        bsr    kllblnks
  4351.         moveq    #0,d2
  4352.         lea    offstr(a4),a1
  4353.         bsr    strcmp
  4354.         beq.s    1$
  4355.         subq.b    #1,d2
  4356.         lea    onstr(a4),a1
  4357.         bsr    strcmp
  4358.         beq.s    1$
  4359.         eor.b    d2,0(a2)
  4360.         move.b    0(a2),d2
  4361. 1$        move.b    d2,0(a2)
  4362.         rts
  4363.  
  4364. ;toggle prop gadget on/off
  4365. propgad        moveq    #0,d7
  4366.         lea    propgadon(a4),a2
  4367.         lea    sbgadget(a4),a3
  4368.         bra.s    gadonoff
  4369.  
  4370. ;toggle iconify gadget on/off
  4371. icongad        moveq    #1,d7
  4372.         lea    iconifyon(a4),a2
  4373.         lea    iconifgad(a4),a3
  4374.  
  4375. gadonoff    move.b    (a2),-(sp)        ; save old state
  4376.         bsr.s    onoff
  4377.         move.b    (sp)+,d0
  4378.         tst.w    d7
  4379.         beq.s    3$            ; not iconify gadget
  4380.         tst.b    ownscreen(a4)
  4381.         bne.s    1$            ; only window valid
  4382.         tst.b    post_V34(a4)
  4383.         bne.s    1$            ; only pre Kick2.0+
  4384. 3$        tst.l    infile(a4)
  4385.         bne.s    1$            ; from file
  4386.         cmp.b    (a2),d0
  4387.         beq.s    1$            ; oldstate == newstate !
  4388.         move.l    intuibase(a4),a6
  4389.         move.w    #_LVORemoveGadget,d1
  4390.         tst.b    (a2)
  4391.         beq.s    2$
  4392.         move.w    #_LVOAddGadget,d1
  4393. 2$        moveq    #0,d0            ; top of list !
  4394.         move.l    wnptr(a4),a0
  4395.         move.l    a3,a1
  4396.         jsr    0(a6,d1.w)        ; RemoveGadget or AddGadget
  4397.         bsr    setupscreen
  4398. 1$        rts
  4399.  
  4400. ;Open a library
  4401. openlib        bsr    nodenam2
  4402.         move.l    a5,a1
  4403.         moveq    #0,d0
  4404.         CALL    OpenLibrary,sysbase(a4)
  4405.         tst.l    d0
  4406.         beq    fn5
  4407. opli1        rts
  4408.  
  4409. ;close it
  4410. closelib    bsr    nodenam2
  4411.         moveq    #0,d7
  4412.         lea    LibNode(pc),a3
  4413.         bsr    findnam
  4414.         tst.b    d7
  4415.         beq.s    clli1
  4416.         move.l    d0,a1
  4417.         CALL    CloseLibrary,sysbase(a4)
  4418. clli1        rts
  4419.  
  4420. remnode        bsr    nodenam2
  4421.         moveq    #7,d7
  4422.         lea    TReNode(pc),a3
  4423.         bsr    findnam
  4424.         tst.b    d7
  4425.         beq.s    1$
  4426.         move.l    d0,-(sp)
  4427.         CALL    Disable,sysbase(a4)
  4428.         move.l    (sp)+,a1
  4429.         RECALL    Remove
  4430.         RECALL    Enable
  4431. 1$        rts
  4432.  
  4433. remport        bsr    nodenam2
  4434.         moveq    #0,d7
  4435.         lea    PorNode(pc),a3
  4436.         bsr    findnam
  4437.         tst.b    d7
  4438.         beq.s    1$
  4439.         move.l    d0,a1
  4440.         move.l    16(a1),d0
  4441.         cmp.l    mytask(a4),d0        ; own port ?
  4442.         beq.s    1$
  4443.         move.b    #2,14(a1)
  4444.         CALL    RemPort,sysbase(a4)
  4445. 1$        rts
  4446.  
  4447. closetsports    movem.l    d1-d6/a0-a6,-(sp)
  4448.         move.l    d0,d6
  4449.         move.l    sysbase(a4),a3
  4450.         lea    392(a3),a3
  4451. 1$        move.l    0(a3),a3
  4452.         tst.l    0(a3)
  4453.         beq.s    2$
  4454.         cmp.l    16(a3),d6
  4455.         bne.s    1$
  4456.         move.b    #2,14(a1)
  4457.         move.l    a3,a1
  4458.         CALL    RemPort,sysbase(a4)
  4459.         bra.s    1$
  4460. 2$        movem.l    (sp)+,d1-d6/a0-a6
  4461.         rts
  4462.  
  4463. remintserver    move.l    a0,-(sp)
  4464.         bsr    readhex
  4465.         move.l    (sp)+,a0
  4466.         tst.b    d7
  4467.         beq    syntax
  4468.         move.l    d0,d4
  4469.         moveq    #1,d6
  4470.         move.l    a0,-(sp)
  4471.         bsr    findint
  4472.         move.l    (sp)+,a5
  4473.         tst.w    d5
  4474.         bpl.s    1$
  4475.         bra    fn5
  4476. 1$        tst.b    0(a3,d1.w)
  4477.         bne.s    2$
  4478.         move.w    #nintrserv,d0
  4479.         bra    putnamw
  4480. 2$        lea    iocounter(a4),a1
  4481.         cmp.l    a1,d4
  4482.         beq.s    3$            ; own server !
  4483.         move.l    d4,a1
  4484.         move.l    d1,d0
  4485.         CALL    RemIntServer,sysbase(a4)
  4486. 3$        rts
  4487.  
  4488. ;Remove a resident module from the list. Clears the rt_Matchword
  4489. ;to avoid being found and reinserted during the next reset
  4490.  
  4491. remresident    bsr    nodenam2
  4492.         cmp.b    #'$',0(a5)
  4493.         bne.s    1$
  4494.         move.l    a5,a0
  4495.         bsr    readhex
  4496.         move.l    sysbase(a4),a6
  4497.         tst.b    d7
  4498.         bne.s    2$
  4499. 1$        move.l    a5,a1
  4500.         RECALL    FindResident
  4501.         tst.l    d0
  4502.         beq    fn5
  4503.  
  4504. 2$        move.l    300(a6),a3        ; SysBase->ResModules
  4505. 8$        move.l    (a3)+,d1
  4506.         beq    fn5
  4507.         bpl.s    3$
  4508.         bclr    #31,d1
  4509.         movea.l    d1,a3
  4510.         bra.s    8$
  4511.  
  4512. 3$        cmp.l    d1,d0
  4513.         bne.s    8$
  4514.  
  4515. 4$        move.l    a3,a5
  4516. 5$        tst.l    (a5)+
  4517.         bgt.s    5$
  4518.  
  4519. 6$        move.l    d0,a1
  4520.         clr.w    0(a1)            ; rt_MatchTag
  4521.         clr.b    10(a1)            ; rt_Flags
  4522.         clr.l    22(a1)            ; rt_Init
  4523.         move.l    a5,d0
  4524.         sub.l    a3,d0
  4525.         lsr.w    #2,d0
  4526.         subq.w    #1,d0
  4527.         lea    -4(a3),a1
  4528. 7$        move.l    (a3)+,(a1)+
  4529.         dbra    d0,7$
  4530.         rts
  4531.  
  4532. ;end Xoper but stay in background
  4533. quithold    lea    dummy(a4),a0
  4534.         lea    in(a4),a1
  4535. qh1        move.b    (a0),(a1)+
  4536.         cmp.b    #10,(a0)+
  4537.         bne.s    qh1
  4538.  
  4539. instback    st    wanthold(a4)
  4540.         tst.l    infile(a4)
  4541.         bne.s    quithold-2        ; defer hold
  4542.         moveq    #0,d0
  4543.         bsr    CloseGUI        ; close screen & window
  4544.         beq.s    quithold-2        ; hack ! (pubscreen used)
  4545.         tst.b    wantwindow(a4)
  4546.         beq.s    6$
  4547.         clr.b    wantwindow(a4)
  4548.         clr.b    ownscreen(a4)
  4549.  
  4550. 6$        bsr    killpage
  4551.         bsr    freeblank
  4552.  
  4553.         tst.b    iconifyon(a4)
  4554.         beq.s    3$
  4555.  
  4556. ; appicon (d7=2) or a window (d7=0) !
  4557.  
  4558.         moveq    #2,d7
  4559.         move.l    wbbase(a4),d0        ; try appicon
  4560.         beq.s    5$
  4561.         move.l    a4,-(sp)
  4562.         move.l    d0,a6            ; library base
  4563.         moveq    #0,d0            ; id
  4564.         moveq    #0,d1            ; userdata
  4565.         lea    noname(a4),a0        ; name
  4566.         move.l    replyport(a4),a1    ; port
  4567.         suba.l    a2,a2            ; lock
  4568.         lea    appobj(a4),a3        ; diskobj
  4569.         suba.l    a4,a4            ; tagitems
  4570.         RECALL    AddAppIcon
  4571.         move.l    (sp)+,a4
  4572.         tst.l    d0
  4573.         bne.s    4$
  4574. 5$        moveq    #0,d7
  4575.         lea    icnwindow(a4),a0    ; try icon window
  4576.         CALL    OpenWindow,intuibase(a4)
  4577. 4$        move.l    d0,wnptr(a4)
  4578.         move.b    d7,appicn(a4)
  4579. 3$        bsr.s    handleiconify        ; do iconify
  4580.         move.l    wnptr(a4),d0
  4581.         beq.s    1$
  4582.         move.l    d0,a0
  4583.         moveq    #_LVORemoveAppIcon,d0
  4584.         tst.w    d7
  4585.         bne.s    2$
  4586.         moveq    #_LVOCloseWindow,d0
  4587. 2$        jsr    0(a6,d0.w)        ; remove iconify stuff
  4588.         clr.l    wnptr(a4)
  4589.         clr.b    appicn(a4)
  4590.  
  4591. 1$        clr.b    wanthold(a4)
  4592.         move.b    wantexit(a4),waitexit(a4)
  4593.         bne    exitall
  4594.         move.l    realstack(a4),sp
  4595.         bra    restart
  4596.  
  4597. ; wait for wakeup
  4598.  
  4599. handleiconify    move.l    a6,-(sp)
  4600.         move.l    sysbase(a4),a6        ; setup a6 to ExecBase
  4601.  
  4602.         move.l    mysignal(a4),d6        ; build signal mask
  4603.         or.l    trapsignal(a4),d6
  4604.         move.w    cxsig(a4),d0
  4605.         beq.s    3$            ; no commodity
  4606.         bset    d0,d6
  4607. 3$        move.l    replyport(a4),a2
  4608.         tst.w    d7
  4609.         bne.s    2$            ; appicon
  4610.         move.l    wnptr(a4),d2
  4611.         beq.s    1$
  4612.         move.l    d2,a2
  4613.         move.l    86(a2),a2        ; wn->UserPort
  4614. 2$        move.b    15(a2),d0        ; Port->SigBit
  4615.         bset    d0,d6
  4616. 1$        or.w    #$1000,d6        ; crtl-c
  4617.  
  4618. waitforcall    move.l    d6,d0            ; complete wait-mask
  4619.         RECALL    Wait
  4620.         btst    #mysigbit,d0
  4621.         bne.s    icondone        ; hotkey !!
  4622.         btst    #12,d0
  4623.         sne    wantexit(a4)
  4624.         bne.s    icondone        ; ctrl-c
  4625.         move.l    trapsignal(a4),d1
  4626.         and.l    d0,d1
  4627.         sne    gotguru(a4)
  4628.         bne.s    icondone        ; guru !!
  4629.         bsr    ChkBroker        ; check broker port
  4630.  
  4631. fromport    move.l    a2,a0            ; wn->UserPort
  4632.         RECALL    GetMsg
  4633.         move.l    d0,a1
  4634.         move.l    a1,d0
  4635.         beq.s    waitforcall
  4636.         move.l    30(a1),-(sp)
  4637.         RECALL    ReplyMsg
  4638.         tst.w    d7            ; app icon ?
  4639.         bne.s    1$
  4640.         move.l    a6,(sp)            ; only flag
  4641.         bsr.s    chkpos
  4642.         bne.s    1$
  4643.         lea    osecs(a4),a3
  4644.         lea    8(a3),a0        ; nsecs
  4645.         lea    12(a3),a1        ; nmics
  4646.         move.l    a6,-(sp)
  4647.         CALL    CurrentTime,intuibase(a4)
  4648.         movem.l    0(a3),d0-d3
  4649.         RECALL    DoubleClick
  4650.         move.l    (sp)+,a6
  4651.         move.l    8(a3),(a3)+        ; nsecs->osecs
  4652.         move.l    8(a3),(a3)+        ; nmics->omics
  4653.         tst.l    d0
  4654.         beq.s    1$
  4655.         clr.l    (sp)            ; clear value
  4656. 1$        move.l    (sp)+,d0
  4657.         bne.s    fromport
  4658.  
  4659. icondone    move.l    (sp)+,a6
  4660.         tst.w    d7            ; appicon or window ?
  4661.         bne.s    chkpos2
  4662.  
  4663. chkpos        move.l    wnptr(a4),d0        ; window moved ?
  4664.         beq.s    chkpos2
  4665.         move.l    d0,a0
  4666.         move.l    4(a0),d0        ; new pos
  4667.         move.l    icnwindow(a4),d1    ; old pos
  4668.         move.l    d0,icnwindow(a4)
  4669.         sub.l    d1,d0            ; zero == nothing changed !
  4670. chkpos2        rts
  4671.  
  4672. ;fill all unused memory-chunks with a longword
  4673. clear        moveq    #0,d0
  4674.         cmp.b    #10,0(a0)
  4675.         beq.s    clr5
  4676.         bsr    readhex
  4677.         tst.b    d7
  4678.         beq    syntax
  4679. clr5        move.l    sysbase(a4),a0
  4680.         clr.l    parmtxt(a4)
  4681.         lea     322(a0),a0
  4682.         move.w    #$4000,$dff09a
  4683. clr1        move.l    0(a0),a0
  4684.         tst.l    0(a0)
  4685.         beq.s    clr6
  4686.         move.l    16(a0),a1
  4687. clr2        tst.l    0(a1)
  4688.         beq.s    clr1
  4689.         addq.l    #1,parmtxt(a4)
  4690.         move.l    4(a1),d1
  4691.         subq.l    #8,d1
  4692.         ble.s    clr31
  4693.         lsr.l    #2,d1
  4694.         subq.l    #1,d1
  4695.         bmi.s    clr31
  4696.         lea     8(a1),a2
  4697. clr3        move.l    d0,(a2)+
  4698.         dbra    d1,clr3
  4699. clr31        move.l    0(a1),a1
  4700.         bra.s    clr2
  4701. clr6        move.w    #$C000,$dff09a
  4702.         move.l    parmtxt(a4),d0
  4703.         moveq    #0,d3
  4704.         bsr    longdec
  4705.         move.w    #clrtxt,d0
  4706.         bra    putnamw
  4707.  
  4708. ;change the number of maximum lines in the history buffer
  4709. historylines    bsr    getnum
  4710.         tst.b    d7
  4711.         beq    syntax
  4712.         move.w    d2,maxhlines(a4)
  4713.         move.w    hnum(a4),d0
  4714. 1$        cmp.w    maxhlines(a4),d0
  4715.         ble.s    2$
  4716.         bsr    remhistline
  4717.         subq.w    #1,d0
  4718.         bra.s    1$
  4719. 2$        move.l    history+8(a4),curhist(a4)
  4720.         move.w    d0,hnum(a4)
  4721.         rts
  4722.  
  4723. ;set the minimum number of characters a input line
  4724. ;must have to be added to the history buffer
  4725. historylength    bsr    getnum
  4726.         tst.b    d7
  4727.         beq    syntax
  4728.         tst.b    d2
  4729.         bne.s    1$
  4730.         addq.w    #1,d2
  4731. 1$        move.w    d2,minnumchars(a4)
  4732.         rts
  4733.  
  4734. ;display all lines in the history buffer
  4735. showhistory    lea    inputbuffer(a4),a3
  4736.         moveq    #1,d5
  4737.         move.l    history(a4),a5
  4738. 1$        tst.l    0(a5)
  4739.         beq.s    2$
  4740.         move.l    d5,d3
  4741.         bsr    bytedec
  4742.         moveq    #0,d0
  4743.         move.w    8(a5),d0
  4744.         clr.b    0(a3,d0.w)
  4745.         lea    10(a5),a0
  4746.         move.l    a3,a1
  4747.         CALL    CopyMem,sysbase(a4)
  4748.         move.l    a3,d0
  4749.         bsr    putnam
  4750.         move.l    0(a5),a5
  4751.         addq.l    #1,d5
  4752.         bra.s    1$
  4753. 2$        rts
  4754.  
  4755. ;set the maximum lines the output buffer may hold
  4756. outputlines    bsr    getnum
  4757.         tst.b    d7
  4758.         beq    syntax
  4759.         moveq    #100,d3
  4760.         tst.l    d2
  4761.         bmi.s    2$
  4762.         cmp.l    d3,d2
  4763.         bge.s    1$
  4764. 2$        move.l    d3,d2
  4765. 1$        move.l    d2,maxlines(a4)
  4766.         rts
  4767.  
  4768. ;find a named node
  4769. ;d7 = number of lists to search through
  4770. ;a3 = pointer to the first entry in the
  4771. ;     list-offset-table
  4772. ;a5 = pointer to name
  4773. ;returns:
  4774. ;d7 = TRUE(1) / FALSE (0)
  4775. ;d0 = node
  4776. findnam        tst.b    0(a5)
  4777.         bne.s    1$
  4778.         move.w    #nameerr,d0
  4779.         bsr    putnamw
  4780.         bra    fnerr
  4781. 1$        cmp.b    #'$',0(a5)
  4782.         bne.s    fn2
  4783.         move.l    d7,d2
  4784.         move.l    a5,a0
  4785.         bsr    readhex
  4786.         tst.b    d7
  4787.         beq.s    fn6
  4788.         move.l    d2,d7
  4789.         bsr.s    tstnode
  4790.         tst.w    d5
  4791.         bne.s    fn3
  4792.         bra    fn5
  4793. fn6        move.l    d2,d7
  4794. fn2        move.l    sysbase(a4),a0
  4795.         adda.l    0(a3),a0
  4796.         move.l    a5,a1
  4797. fn4        CALL    FindName,sysbase(a4)
  4798.         move.l    d0,a0
  4799.         move.l    a0,d0
  4800.         bne.s    fn1
  4801. fn41        addq.w    #4,a3
  4802.         dbra    d7,fn2
  4803. fn5        move.w    #namerr,d0
  4804.         bsr    putstrw
  4805.         move.l    a5,d0
  4806.         bsr    putnam
  4807. fnerr        moveq    #0,d7
  4808.         rts
  4809. fn1        move.w    procnum(a4),d2
  4810.         beq.s    fn3
  4811.         cmp.b    143(a0),d2
  4812.         bne.s    fn41
  4813. fn3        moveq    #1,d7
  4814.         rts
  4815.  
  4816. ;list-offset-table
  4817. TRuNode        dc.l    276
  4818. TReNode        dc.l    406
  4819. TWaNode        dc.l    420
  4820. DevNode        dc.l    350
  4821. LibNode        dc.l    378
  4822. ResNode        dc.l    336
  4823. MemNode        dc.l    322
  4824. PorNode        dc.l    392
  4825. SemNode        dc.l    532
  4826.  
  4827. ;Node has been entered in hex. Check if this node exsists
  4828. tstnode        tst.l    infile(a4)
  4829.         bne.s    illegalhex
  4830.         move.l    d0,d1
  4831.         btst    #0,d1
  4832.         beq.s    inrange
  4833.         move.w    #adrerr,d0
  4834.         bsr    putnamw
  4835. illegalhex    moveq    #0,d5
  4836.         rts
  4837. inrange        movem.l    d7/a3,-(sp)
  4838.         moveq    #1,d5
  4839.         lea    TRuNode(pc),a0
  4840.         cmp.l    a0,a3
  4841.         bne.s    1$
  4842.         move.l    sysbase(a4),a0
  4843.         cmp.l    276(a0),d0
  4844.         beq.s    nodefound
  4845.         subq.w    #1,d7
  4846.         addq.w    #4,a3
  4847. 1$        move.w    #$4000,$dff09a
  4848. getlist        move.l    sysbase(a4),a0
  4849.         add.l    0(a3),a0
  4850. nxtnode        tst.l    0(a0)
  4851.         beq.s    nxtlist
  4852.         cmp.l    a0,d0
  4853.         beq.s    nodefound
  4854.         move.l    0(a0),a0
  4855.         bra.s    nxtnode
  4856. nxtlist        addq.w    #4,a3
  4857.         dbra    d7,getlist
  4858.         moveq    #0,d5
  4859. nodefound    move.w    #$C000,$dff09a
  4860.         movem.l    (sp)+,d7/a3
  4861.         rts
  4862.  
  4863. ;allocate FileInfoBlock
  4864. allocfinfo    addq.b    #1,finfopen(a4)
  4865.         bne.s    1$
  4866.         move.l    #260,d0
  4867.         moveq    #0,d1
  4868.         CALL    AllocMem,sysbase(a4)
  4869.         move.l    d0,finfoptr(a4)
  4870. 1$        rts
  4871.  
  4872. ;free FileInfoBlock
  4873. freefinfo    subq.b    #1,finfopen(a4)
  4874.         bpl.s    1$
  4875.         move.l    #260,d0
  4876.         move.l    finfoptr(a4),d1
  4877.         beq.s    1$
  4878.         move.l    d1,a1
  4879.         CALL    FreeMem,sysbase(a4)
  4880.         clr.l    finfoptr(a4)
  4881. 1$        rts
  4882.  
  4883. ;Examine ,d0=Lock
  4884. getfinfo    move.l    d0,d1
  4885.         move.l    finfoptr(a4),d2
  4886.         CALL    Examine,dosbase(a4)
  4887.         rts
  4888.  
  4889. ;construct a Pathname from a lock
  4890. ;d0=Lock ,resulting string is written to window
  4891. getpath        movem.l    d1-d7/a0-a6,-(sp)
  4892.         move.l    d0,d1
  4893.         beq.s    1$
  4894.         CALL    DupLock,dosbase(a4)
  4895. 1$        lea    out(a4),a3
  4896.         clr.b    -(a3)
  4897. gp0        move.l    d0,d5
  4898.         bsr.s    getfinfo
  4899.         move.l    finfoptr(a4),a0
  4900.         move.l    4(a0),d4
  4901.         addq.l    #8,a0
  4902.         bsr    strlen
  4903.         lea    -1(a3),a5
  4904.         tst.l    d4
  4905.         bmi.s    nodir
  4906.         move.b    #'/',-(a3)
  4907. nodir        subq.w    #1,d0
  4908.         bmi.s    nofnam
  4909. gp1        move.b    0(a0,d0.w),-(a3)
  4910.         dbra    d0,gp1
  4911. nofnam        move.l    d5,d1
  4912.         CALL    ParentDir,dosbase(a4)
  4913.         move.l    d0,d4
  4914.         move.l    d5,d1
  4915.         beq.s    2$
  4916.         CALL    UnLock,dosbase(a4)
  4917. 2$        move.l    d4,d0
  4918.         bne.s    gp0
  4919.         cmp.b    #'/',0(a5)
  4920.         bne.s    gp2
  4921.         move.b    #':',0(a5)
  4922. gp2        move.l    a3,d0
  4923.         bsr    putnam
  4924.         movem.l    (sp)+,d1-d7/a0-a6
  4925.         rts
  4926.  
  4927. dchange        lea    dchead(a4),a0
  4928.         bsr    puthead
  4929.         tst.b    post_V34(a4)
  4930.         bne.s    dchange-2        ; hack!
  4931.         move.l    sysbase(a4),a6
  4932.         lea    350(a6),a0
  4933.         lea    tdname(a4),a1
  4934.         RECALL    FindName
  4935.         move.l    d0,a2
  4936.         move.l    a2,d0
  4937.         beq    14$
  4938.         lea    36(a2),a2
  4939.         moveq    #0,d5
  4940. 2$        move.l    (a2)+,d2
  4941.         beq    3$
  4942.         RECALL    Disable
  4943.         move.l    d2,a0
  4944.         lea    $18e(a0),a0
  4945. 5$        tst.l    0(a0)
  4946.         beq.s    6$
  4947.         move.l    0(a0),a0
  4948.         bra.s    5$
  4949. 6$        lea    -4(a0),a5
  4950.         lea    buffer+100(a4),a3
  4951. 9$        move.l    0(a5),a5
  4952.         tst.l    0(a5)
  4953.         beq.s    11$
  4954.         move.l    a5,(a3)+
  4955.         bne.s    9$
  4956. 11$        clr.l    (a3)+
  4957.         RECALL    Enable
  4958.         lea    buffer+100(a4),a3
  4959. 7$        move.l    (a3)+,d0
  4960.         beq.s    3$
  4961.         move.l    d0,a5
  4962.         cmp.w    #20,28(a5)
  4963.         bne.s    7$
  4964.         move.l    40(a5),a3
  4965.         move.l    a3,d0
  4966.         move.l    d0,node(a4)
  4967.         bsr    hexan
  4968.         move.l    a3,d0
  4969.         beq.s    10$
  4970.         move.l    14(a3),d0
  4971.         bsr    hexan
  4972.         move.l    18(a3),d0
  4973.         bsr    hexan
  4974. 10$        move.l    d5,d3
  4975.         or.b    #48,d3
  4976.         move.b    d3,tddrives+2(a4)
  4977.         move.w    #tddrives,d0
  4978.         bsr    putstrw
  4979.         move.l    14(a5),d0
  4980.         beq.s    8$
  4981.         move.l    d0,a0
  4982.         move.l    16(a0),d0
  4983. 8$        bsr    getaskname2
  4984.         bsr    newline
  4985.         bra.s    7$
  4986. 3$        addq.w    #1,d5
  4987.         cmp.w    #4,d5
  4988.         bcs    2$
  4989. 14$        rts
  4990.  
  4991. snoop        lea    snoophead(a4),a2
  4992.         moveq    #0,d2
  4993.         bsr    InitSnoop
  4994.         beq.s    snoop-2
  4995.  
  4996.         tst.b    msnoop(a4)
  4997.         bne.s    1$            ; already patched !
  4998.         RECALL    Forbid
  4999.         lea    capmalloc(pc),a0
  5000.         move.l    a0,d0
  5001.         move.w    #_LVOAllocMem,a0
  5002.         move.l    a6,a1
  5003.         RECALL    SetFunction
  5004.         move.l    d0,OldAllocMem(a4)
  5005.         lea    capmfree(pc),a0
  5006.         move.l    a0,d0
  5007.         move.w    #_LVOFreeMem,a0
  5008.         move.l    a6,a1
  5009.         RECALL    SetFunction
  5010.         move.l    d0,OldFreeMem(a4)
  5011.         st    msnoop(a4)
  5012.         RECALL    Permit
  5013.  
  5014. 1$        st    snoopon(a4)        ; enable snooping
  5015.         clr.b    bool(a4)
  5016.         clr.b    capgone(a4)
  5017.         clr.b    capwaiting(a4)
  5018.         clr.l    capiscli(a4)
  5019.  
  5020.         move.l    captask(a4),a1
  5021.         cmp.b    #13,8(a1)        ; ln_Type
  5022.         bne.s    waitmem
  5023.         tst.l    140(a1)
  5024.         beq.s    waitmem
  5025.         move.l    172(a1),d0        ; pr_CLI
  5026.         beq.s    waitmem
  5027.         lsl.l    #2,d0
  5028.         move.l    d0,a0
  5029.         lea     60(a0),a0
  5030.         move.l    a0,capiscli(a4)
  5031.         move.l    0(a0),d0
  5032.         move.l    d0,capseg(a4)
  5033.         bne.s    waitmem
  5034.         move.w    #capwait,d0
  5035.         bsr    putnamw
  5036.         st    capwaiting(a4)
  5037.  
  5038. waitmem        bsr    processmsgs
  5039.  
  5040. tm7        move.l    snoopport(a4),a0
  5041.         CALL    GetMsg,sysbase(a4)
  5042.         move.l    d0,a3
  5043.         move.l    a3,d0
  5044.         bne.s    tm8
  5045.         tst.b    cbreak(a4)
  5046.         bne    snoopend
  5047.         tst.b    capgone(a4)
  5048.         bne    snoopend
  5049.         bra.s    waitmem
  5050.  
  5051. tm8        tst.b    capwaiting(a4)
  5052.         beq.s    tm15
  5053.         move.l    capiscli(a4),d7
  5054.         beq.s    tm15
  5055.         move.l    d7,a0
  5056.         move.l    0(a0),capseg(a4)
  5057.         beq    tm12
  5058.         clr.b    capwaiting(a4)
  5059.  
  5060. tm15        move.l    20(a3),d3
  5061.         tst.b    36(a3)            ; free or alloc ?
  5062.  
  5063.         beq    freed
  5064.         move.w    #allok,d0
  5065.         bsr    putstrw
  5066.         lea    memname(pc),a2
  5067.         moveq    #9,d5
  5068. tm2        move.w    (a2)+,d1
  5069.         btst    d1,d3
  5070.         beq.s    tm1
  5071.         move.w    (a2),d0
  5072.         bsr    putstrw
  5073. tm1        addq.w    #2,a2
  5074.         dbra    d5,tm2
  5075.         moveq    #41,d1
  5076.         bsr    tab            ; d0 - actual pos
  5077.         bsr    putblank
  5078.         move.l    24(a3),d0
  5079.         move.l    d0,d3
  5080.         bsr    hexa
  5081.         move.l    28(a3),d0
  5082.         bne.s    tm3
  5083.         move.w    #failed,d0
  5084.         bsr    putstrw
  5085.         moveq    #53,d1
  5086.         bsr    tab
  5087.         bra.s    tm4
  5088. tm3        bsr    hexa
  5089.         move.l    28(a3),d0
  5090.         add.l    d3,d0
  5091.         bsr    hexa
  5092.         bra.s    tm4
  5093.  
  5094. freed        move.w    #free,d0
  5095.         bsr    putstrw
  5096.         move.b    #'-',d0
  5097.         moveq    #34,d1
  5098. tm9        bsr    putchar
  5099.         dbra    d1,tm9
  5100.         bsr    putblank
  5101.         move.l    d3,d0
  5102.         bsr    hexa
  5103.         move.l    24(a3),d0
  5104.         bsr    hexa
  5105.         move.l    24(a3),d0
  5106.         add.l    d3,d0
  5107.         bsr    hexa
  5108.  
  5109. tm4        move.l    32(a3),d0
  5110.         bsr    hexa
  5111.         bsr    newline
  5112. tm12        bsr    freemsg
  5113.         move.l    captask(a4),a1
  5114. tm13        tst.b    capwaiting(a4)
  5115.         bne.s    tm10
  5116.         move.l    capiscli(a4),d0
  5117.         beq.s    1$
  5118.         move.l    d0,a0
  5119.         move.l    0(a0),d0
  5120.         cmp.l    capseg(a4),d0
  5121.         bne.s    tm11
  5122. 1$        move.b    15(a1),d0
  5123.         cmp.b    #5,d0
  5124.         bge.s    tm11
  5125.         cmp.b    #2,d0
  5126.         bge.s    tm10
  5127. tm11        st    capgone(a4)
  5128. tm10        bra    tm7
  5129.  
  5130. snoopend    clr.b    snoopon(a4)        ; snooping off
  5131.         tst.b    msnoop(a4)
  5132.         beq.s    1$            ; nothing patched !
  5133.         CALL    Forbid,sysbase(a4)
  5134.         tst.b    patchmode(a4)
  5135.         beq.s    3$            ; don't check vectors
  5136.         lea    capmalloc(pc),a0
  5137.         cmp.l    _LVOAllocMem+2(a6),a0
  5138.         bne.s    2$            ; another patch !
  5139.         lea    capmfree(pc),a0
  5140.         cmp.l    _LVOFreeMem+2(a6),a0
  5141.         bne.s    2$            ; another patch !
  5142. 3$        move.l    OldFreeMem(a4),d0
  5143.         move.w    #_LVOFreeMem,a0
  5144.         move.l    a6,a1
  5145.         RECALL    SetFunction
  5146.         move.l    OldAllocMem(a4),d0
  5147.         move.w    #_LVOAllocMem,a0
  5148.         move.l    a6,a1
  5149.         RECALL    SetFunction
  5150.         clr.b    msnoop(a4)
  5151. 2$        RECALL    Permit
  5152. 1$        bra    ClrSnoop
  5153.  
  5154. memname        dc.w    31,memnoexp,18,memrev,17,memlarg,16,memclr,10,memkick
  5155.         dc.w    9,memdma,8,memloc,2,memfast,1,memchip,0,mempubl
  5156.  
  5157. capmalloc    movem.l    d0-d7/a0-a6,-(sp)    ; a6 - SysBase !
  5158.         lea    dataarea(pc),a4
  5159.         tst.b    snoopon(a4)
  5160.         beq.s    capm1            ; snooping disabled
  5161.         move.l    276(a6),d4
  5162.         cmp.l    captask(a4),d4
  5163.         bne.s    capm1
  5164.         tst.b    bool(a4)
  5165.         bne.s    capm1
  5166.         addq.b    #1,bool(a4)
  5167.         moveq    #40,d6
  5168.         bsr    allocmsg
  5169.         beq.s    capm2
  5170.         move.l    d1,20(a5)
  5171.         move.l    d0,24(a5)
  5172.         move.l    60(sp),32(a5)
  5173.         st    36(a5)            ; is alloc msg
  5174.         move.l    a5,remembr(a4)
  5175.         movem.l    (sp)+,d0-d7/a0-a6
  5176.         bsr.s    memalloc
  5177.         movem.l    d0-d7/a0-a6,-(sp)
  5178.         lea    dataarea(pc),a4
  5179.         move.l    remembr(a4),a1
  5180.         move.l    d0,28(a1)
  5181.         move.l    snoopport(a4),a0
  5182.         move.b    #5,8(a1)
  5183.         RECALL    PutMsg
  5184.         clr.b    bool(a4)
  5185.         movem.l    (sp)+,d0-d7/a0-a6
  5186.         rts
  5187. capm2        clr.b    bool(a4)
  5188. capm1        movem.l    (sp)+,d0-d7/a0-a6
  5189. memalloc    move.l    OldAllocMem+dataarea(pc),-(sp)
  5190.         rts
  5191.  
  5192. capmfree    movem.l    d0-d7/a0-a6,-(sp)    ; a6 - SysBase !
  5193.         lea    dataarea(pc),a4
  5194.         tst.b    snoopon(a4)
  5195.         beq.s    capf1            ; snooping disabled
  5196.         move.l    276(a6),d4
  5197.         cmp.l    captask(a4),d4
  5198.         bne.s    capf1
  5199.         tst.b    bool(a4)
  5200.         bne.s    capf1
  5201.         addq.b    #1,bool(a4)
  5202.         moveq    #40,d6
  5203.         bsr.s    allocmsg
  5204.         beq.s    capf2
  5205.         move.l    d0,20(a5)
  5206.         move.l    a1,24(a5)
  5207.         move.l    60(sp),32(a5)
  5208. ;        clr.b    36(a5)            ; is free msg
  5209.         move.l    snoopport(a4),a0
  5210.         move.b    #5,8(a5)
  5211.         move.l    a5,a1
  5212.         RECALL    PutMsg
  5213. capf2        clr.b    bool(a4)
  5214. capf1        movem.l (sp)+,d0-d7/a0-a6
  5215.         move.l  OldFreeMem+dataarea(pc),-(sp)
  5216.         rts
  5217.  
  5218. allocmsg    movem.l    d0-d1/a0-a1,-(sp)    ; a6 - SysBase
  5219.         move.l    d6,d0
  5220.         move.l    #$10001,d1        ; MEMF_CLEAR|MEMF_PUBLIC
  5221.         tst.b    msnoop(a4)        ; memory snooping ?
  5222.         bne.s    1$
  5223.         RECALL    AllocMem
  5224.         bra.s    2$
  5225. 1$        bsr.s    memalloc
  5226. 2$        tst.l    d0
  5227.         beq.s    alm1
  5228.         move.l    d0,a5
  5229.         move.w    d6,18(a5)
  5230. alm1        movem.l    (sp)+,d0-d1/a0-a1
  5231.         rts
  5232.  
  5233. freemsg        moveq    #0,d0
  5234.         move.w    18(a3),d0
  5235.         move.l    a3,a1
  5236.         CALL    FreeMem,sysbase(a4)
  5237.         rts
  5238.  
  5239. tracelocks    pea    DosTable+20(a4)        ; table entry for locks
  5240.         bra.s    tracedos
  5241.  
  5242. tracefiles    pea    DosTable+00(a4)        ; table entry for open
  5243.  
  5244. tracedos    lea    fileshead(a4),a2
  5245.         moveq    #1,d2
  5246.         bsr    InitSnoop
  5247.         move.l    (sp)+,a2
  5248.         beq.s    tracelocks-2        ; error
  5249.  
  5250.         RECALL    Forbid
  5251.         tst.b    5(a2)
  5252.         bne.s    9$            ; already patched !
  5253.         move.w    0(a2),a0        ; offset
  5254.         move.l    16(a2),d0        ; myfunc
  5255.         move.l    dosbase(a4),a1
  5256.         tst.b    post_V34(a4)
  5257.         beq.s    10$
  5258.         RECALL    SetFunction
  5259.         move.l    d0,12(a2)        ; OldFuncPtr
  5260.         bra.s    9$
  5261. 10$        move.w    0(a1,a0.w),6(a2)    ; OldVec1
  5262.         move.w    #$4ef9,0(a1,a0.w)
  5263.         move.l    2(a1,a0.w),8(a2)    ; OldVec2
  5264.         move.l    d0,2(a1,a0.w)
  5265.         lea    78(a1),a1
  5266.         move.l    a1,12(a2)        ; OldFuncPtr
  5267. 9$        moveq    #-1,d0
  5268.         move.w    d0,4(a2)        ; function patched & active
  5269.         RECALL    Permit
  5270.  
  5271. 8$        bsr    processmsgs
  5272.  
  5273. 7$        move.l    snoopport(a4),a0
  5274.         CALL    GetMsg,sysbase(a4)
  5275.         tst.l    d0
  5276.         bne.s    6$
  5277.         tst.b    cbreak(a4)
  5278.         bne.s    traceend
  5279.         bra.s    8$
  5280.  
  5281. 6$        move.l    d0,a3
  5282.         move.l    20(a3),d0
  5283.         bsr    getaskname2
  5284.         moveq    #11,d1
  5285.         bsr    tab
  5286.         moveq    #' ',d0
  5287.         bsr    putchar
  5288.         move.l    24(a3),d0
  5289.         bne.s    5$
  5290.         move.w    #failed,d0
  5291.         bsr    putstrw
  5292.         moveq    #21,d1
  5293.         bsr    tab
  5294.         bra.s    4$
  5295.  
  5296. 5$        bsr    hexa
  5297. 4$        move.b    28(a3),d0
  5298.         bmi.s    3$
  5299.         cmp.b    #2,d0
  5300.         ble.s    2$
  5301. 3$        move.w    #type,d0
  5302.         bsr    putstrw
  5303.         moveq    #28,d1
  5304.         bsr    tab
  5305.         bra.s    1$
  5306. 2$        ext.w    d0
  5307.         lsl.w    #3,d0
  5308.         add.w    #fmode,d0
  5309.         bsr    putstrw
  5310. 1$        moveq    #29,d0
  5311.         add.l    a3,d0
  5312.         bsr    putnam
  5313.  
  5314.         bsr    freemsg
  5315.         bra.s    7$
  5316.  
  5317. traceend    lea    DosTable+00(a4),a2
  5318.         bsr.s    remtrace        ; for Open()
  5319.         lea    DosTable+20(a4),a2
  5320.         bsr.s    remtrace        ; for Lock()
  5321.         bra    ClrSnoop
  5322.  
  5323. remtrace    CALL    Forbid,sysbase(a4)
  5324.         tst.b    5(a2)
  5325.         beq.s    2$            ; nothing patched !
  5326.         move.w    0(a2),a0        ; offset
  5327.         move.l    16(a2),d0        ; myfunc
  5328.         move.l    dosbase(a4),a1
  5329.         move.b    post_V34(a4),d1
  5330.         beq.s    6$            ; not pre Kick2.0+ !
  5331.         tst.b    patchmode(a4)
  5332.         beq.s    5$            ; don't check vectors
  5333. 6$        cmp.l    2(a1,a0.w),d0
  5334.         bne.s    2$            ; someone else patched !
  5335.         tst.b    d1            ; d1:=post_V34
  5336.         beq.s    4$
  5337. 5$        move.l    12(a2),d0
  5338.         RECALL    SetFunction
  5339.         bra.s    3$
  5340. 4$        move.w    6(a2),0(a1,a0.w)
  5341.         move.l    8(a2),2(a1,a0.w)
  5342. 3$        clr.b    5(a2)
  5343. 2$        clr.b    4(a2)            ; deactivate
  5344.         RECALL    Permit
  5345.         rts
  5346.  
  5347. mylock        moveq    #20,d0            ; trace Lock()
  5348.         bra.s    mytrace
  5349.  
  5350. myopen        moveq    #0,d0            ; trace Open()
  5351.  
  5352. mytrace        movem.l    d3-d7/a0-a6,-(sp)
  5353.         lea    dataarea(pc),a4
  5354.         lea    DosTable(a4),a2
  5355.         add.w    d0,a2
  5356.         move.b    4(a2),d7
  5357.         beq.s    5$            ; disabled
  5358.         move.l    sysbase(a4),a6
  5359.         movem.l    d1-d2,-(sp)
  5360.         move.l    d1,a0
  5361.         bsr    strlen
  5362.         moveq    #30,d6
  5363.         add.l    d0,d6
  5364.         bsr    allocmsg
  5365.         beq.s    2$
  5366.         addq.w    #3,d2            ; lock
  5367.         move.w    2(a2),d3        ; dosoffset
  5368.         addq.w    #1,d3
  5369.         bne.s    3$
  5370.         sub.w     #1007,d2        ; open
  5371. 3$        move.b    d2,28(a5)
  5372.         move.l    276(a6),20(a5)
  5373.         lea    29(a5),a1
  5374.         move.l    d1,a0
  5375.         RECALL    CopyMem
  5376. 2$        movem.l    (sp)+,d1-d2
  5377. 5$        bsr.s    RealDosFunc
  5378.         tst.b    d7            ; disabled
  5379.         beq.s    6$
  5380.         movem.l    d1-d2,-(sp)
  5381.         move.l    d0,d7
  5382.         move.l    a5,d0
  5383.         beq.s    1$
  5384.         move.b    #5,8(a5)
  5385.         move.l    d7,24(a5)
  5386.         move.l    snoopport(a4),a0
  5387.         move.l    a5,a1
  5388.         CALL    PutMsg,sysbase(a4)
  5389. 1$        move.l    d7,d0
  5390.         movem.l    (sp)+,d1-d2
  5391. 6$        movem.l    (sp)+,d3-d7/a0-a6
  5392.         rts
  5393.  
  5394. RealDosFunc    move.w    2(a2),d0        ; dosoffset
  5395.         ext.l    d0
  5396.         move.l    dosbase(a4),a6
  5397.         move.l    12(a2),-(sp)        ; OldFuncPtr
  5398.         rts
  5399.  
  5400. _DosTable    dc.w    _LVOOpen,-1        ; patchwhat & dosoffset
  5401.         dc.w    0,0            ; active,on/off & DosVec1
  5402.         dc.l    0,0            ; DosVec2 & OldFunc
  5403.         dc.l    myopen            ; myfunc
  5404.         dc.w    _LVOLock,-11        ; patchwhat & dosoffset
  5405.         dc.w    0,0            ; active,on/off & DosVec1
  5406.         dc.l    0,0            ; DosVec2 & OldFunc
  5407.         dc.l    mylock            ; myfunc
  5408.  
  5409. ;prepare snooping for memory or dos
  5410. InitSnoop    bsr    cls            ; clear screen
  5411.         tst.w    d2
  5412.         bne.s    2$            ; files
  5413.         bsr    nodenam
  5414.         moveq    #1,d7
  5415.         lea    TReNode(pc),a3
  5416.         bsr    findnam
  5417.         tst.b    d7
  5418.         beq.s    3$            ; task not found
  5419.         move.l    d0,captask(a4)
  5420. 2$        moveq    #0,d0
  5421.         lea    memportname(a4),a0
  5422.         bsr    CreatePort
  5423.         move.l    d0,snoopport(a4)
  5424.         beq.s    1$            ; no port
  5425.         move.l    d0,a0
  5426.         moveq    #0,d1
  5427.         move.b    15(a0),d0
  5428.         bset    d0,d1
  5429.         move.l    d1,auxsig(a4)
  5430.         clr.b    cbreak(a4)
  5431.         st    addlines(a4)
  5432.         move.l    a2,a0            ; header
  5433.         bsr    puthead
  5434.         bsr    replyintui
  5435.         move.l    sysbase(a4),a6
  5436.         moveq    #1,d0
  5437. 1$        rts
  5438. 3$        move.w    #stperr,d0
  5439.         bsr    putnamw            ; task not found
  5440.         moveq    #0,d0
  5441.         bra.s    1$
  5442.  
  5443. ;end snooping for memory or dos
  5444. ClrSnoop    move.l    snoopport(a4),d0
  5445.         beq.s    3$
  5446.         bsr    DeletePort
  5447. 3$        tst.b    waitexit(a4)
  5448.         bne.s    1$            ; Xoper was killed
  5449.         move.w    #stopped,d0
  5450.         tst.b    cbreak(a4)
  5451.         bne.s    2$
  5452.         move.w    #capexited,d0
  5453. 2$        bsr    putnamw
  5454. 1$        clr.l    snoopport(a4)
  5455.         clr.b    addlines(a4)
  5456.         clr.l    auxsig(a4)
  5457.         rts
  5458.  
  5459. ; function to determine cpu-time for each task
  5460. myswitch    movem.l    d0-d1/a0-a2/a4/a6,-(sp)
  5461.         lea    dataarea(pc),a4
  5462.         move.w    tasksnum(a4),d0
  5463.         move.l    sysbase(a4),a0
  5464.         move.l    276(a0),a0
  5465.         lea    cputime(a4),a2
  5466.         bra.s    sw1
  5467. sw0        cmp.l    (a2)+,a0
  5468.         beq.s    sw2
  5469. sw1        dbra    d0,sw0
  5470.         cmp.w    #125,tasksnum(a4)
  5471.         bcc.s    swgo2            ; too much
  5472.         addq.w    #1,tasksnum(a4)
  5473.         move.l    a0,(a2)+        ; new entry
  5474.         clr.l    496(a2)
  5475. sw2        tst.b    post_V34(a4)
  5476.         beq.s    sw3
  5477.         lea    newtime(a4),a0
  5478.         CALL    ReadEClock,timerio+20(a4)
  5479.         move.l    newtime+4(a4),d0
  5480.         move.l    lasttime(a4),d1
  5481.         move.l    d0,lasttime(a4)
  5482.         sub.l    d1,d0
  5483.         bra.s    sw4
  5484. sw3        move.l    #999999,d0
  5485.         move.l    d0,d1
  5486.         sub.l    sampleio+36(a4),d0
  5487.         move.l    d1,sampleio+36(a4)
  5488. sw4        lsr.l    #8,d0
  5489.         add.l    d0,496(a2)
  5490. swgo2        movem.l    (sp)+,d0-d1/a0-a2/a4/a6
  5491.         move.l    OldSwitch+dataarea(pc),-(sp)
  5492.         rts
  5493.  
  5494. myaddtask    movem.l    d0/a0/a4,-(sp)
  5495.         lea    dataarea(pc),a4
  5496.         tst.b    wanttraps(a4)
  5497.         beq.s    2$
  5498.         lea    mytrap(pc),a0        ; trap for task
  5499.         move.l    50(a1),d0
  5500.         beq.s    1$
  5501.         cmp.l    OldTrap(a4),d0
  5502.         beq.s    1$
  5503.         lea    myproctrap(pc),a0    ; trap for process
  5504.         cmp.l    OldProcTrap(a4),d0
  5505.         bne.s    2$
  5506. 1$        move.l    a0,50(a1)
  5507. 2$        movem.l    (sp)+,d0/a0/a4
  5508.         move.l    a1,-(sp)
  5509.         bsr.s    RealAddTask        ; do original function
  5510.         move.l    (sp)+,d0
  5511.         movem.l    d1-d7/a0-a6,-(sp)
  5512.         lea    dataarea(pc),a4
  5513.         move.l    d0,d7
  5514.         lea    tsecs(a4),a0
  5515.         lea    tmics(a4),a1
  5516.         CALL    CurrentTime,intuibase(a4)
  5517.         CALL    Forbid,sysbase(a4)
  5518.         move.w    numtaskstimed(a4),d5
  5519.         lsl.w    #2,d5
  5520.         lea    taskstampid(a4),a5
  5521.         lea    0(a5,d5.w),a5
  5522.         move.l    d7,0(a5)
  5523.         move.l    tsecs(a4),d0
  5524.         move.l    d0,taskstamps-taskstampid(a5)
  5525.         clr.l    usedtime-taskstampid(a5)
  5526.         addq.w    #1,numtaskstimed(a4)
  5527.         bsr    cleanuptimers
  5528.         RECALL    Permit
  5529.         cmp.b    #5,timerio+8(a4)
  5530.         bne.s    3$
  5531.         moveq    #0,d0
  5532.         move.w    timersig(a4),d1
  5533.         bset    d1,d0
  5534.         move.l    mytask(a4),a1
  5535.         RECALL    Signal
  5536. 3$        move.l    d7,d0
  5537.         movem.l    (sp)+,d1-d7/a0-a6
  5538.         rts
  5539. RealAddTask    move.l    OldAddTask+dataarea(pc),-(sp)
  5540.         rts
  5541.  
  5542. ; install or remove traphandlers
  5543.  
  5544. trapguru    tst.b    wanttraps(a4)
  5545.         bne.s    remtraps
  5546.  
  5547. addtraps    moveq    #-1,d0
  5548.         CALL    AllocSignal,sysbase(a4)
  5549.         moveq    #0,d1
  5550.         bset    d0,d1
  5551.         move.l    d1,trapsignal(a4)
  5552.         RECALL    Forbid            ; change the trap handler of
  5553.         moveq    #0,d5            ; aleady running tasks
  5554.         bsr    getaskdat        ; get task stucture pointers
  5555.         bra.s    3$
  5556. 1$        lea    -16(a5),a5
  5557.         move.l    0(a5),a3        ; pointer to a task structure
  5558.         lea    myproctrap(pc),a0
  5559.         move.l    50(a3),d0        ; Task->tc_TrapCode
  5560.         cmp.l    OldProcTrap(a4),d0    ; AmigaDOS Handler ?
  5561.         beq.s    2$
  5562.         lea    mytrap(pc),a0        ; EXEC Handler ?
  5563.         cmp.l    OldTrap(a4),d0
  5564.         bne.s    3$            ; must be a custom one, skip it
  5565. 2$        move.l    a0,50(a3)        ; replace it
  5566. 3$        subq.b    #1,entries(a4)
  5567.         bcc.s    1$
  5568.         RECALL    Permit
  5569.         st    wanttraps(a4)
  5570.         rts
  5571.  
  5572. remtraps    tst.b    wanttraps(a4)
  5573.         beq.s    6$
  5574.         tst.l    infile(a4)
  5575.         bne.s    5$
  5576.         CALL    Forbid,sysbase(a4)
  5577.         moveq    #0,d5
  5578.         bsr    getaskdat
  5579.         bra.s    4$
  5580. 2$        lea    -16(a5),a5
  5581.         move.l    0(a5),a3
  5582.         lea    50(a3),a3
  5583.         move.l    OldProcTrap(a4),d0
  5584.         lea    myproctrap(pc),a0
  5585.         cmp.l    (a3),a0
  5586.         beq.s    3$
  5587.         move.l    OldTrap(a4),d0
  5588.         lea    mytrap(pc),a0
  5589.         cmp.l    (a3),a0
  5590.         bne.s    4$
  5591. 3$        move.l    d0,(a3)
  5592. 4$        subq.b    #1,entries(a4)
  5593.         bcc.s    2$
  5594.         RECALL    Permit
  5595.         moveq    #32,d0
  5596.         move.l    trapsignal(a4),d1
  5597. 7$        subq.l    #1,d0
  5598.         add.l    d1,d1
  5599.         bcc.s    7$
  5600.         RECALL    FreeSignal
  5601.         clr.l    trapsignal(a4)
  5602. 5$        clr.b    wanttraps(a4)
  5603. 6$        rts
  5604.  
  5605. ; execption handlers
  5606.  
  5607. myproctrap    bsr.s    traphandle
  5608.         move.l    OldProcTrap+dataarea(pc),-(sp)
  5609.         rts
  5610.  
  5611. mytrap        bsr.s    traphandle
  5612.         moveq    #0,d0
  5613.         CALL    Wait,sysbase+dataarea(pc)
  5614.         move.l    OldTrap+dataarea(pc),-(sp)
  5615.         rts
  5616.  
  5617. traphandle    movem.l    d0-d7/a0-a6,$180
  5618.         lea    dataarea(pc),a4
  5619.         move.l    sysbase(a4),a6
  5620.         move.l    276(a6),excpttask(a4)
  5621.         move.l    4(sp),d0
  5622.         moveq    #9,d1
  5623.         cmp.l    d1,d0
  5624.         beq.s    2$
  5625.         move.l    d0,excpterror(a4)
  5626.         moveq    #10,d2
  5627.         moveq    #3,d1
  5628.         cmp.l    d1,d0
  5629.         bne.s    1$
  5630.         move.l    0(sp,d2.w),excptaddr(a4)
  5631.         moveq    #18,d2
  5632. 1$        move.l    0(sp,d2.w),excptpc(a4)
  5633.         move.l    mytask(a4),a1
  5634.         move.l    trapsignal(a4),d0
  5635.         RECALL    Signal
  5636. 2$        movem.l    $180,d0-d7/a0-a6
  5637.         rts
  5638.  
  5639. ;display ExecBase->LastAlert
  5640.  
  5641. lastalert    movem.l    $100,d1-d2
  5642.         tst.l    d1
  5643.         bne.s    al1
  5644.         move.l    sysbase(a4),a0
  5645.         movem.l    514(a0),d1-d2
  5646. al1        move.w    #gurutxt,d0
  5647.         bsr    putstrw
  5648.         move.l    d1,d0
  5649.         bsr    hexa
  5650.         subq.l    #1,ptr(a4)
  5651.         moveq    #'.',d0
  5652.         bsr    putchar
  5653.         move.l    d2,d0
  5654.         bsr    hexa
  5655.         bra    newline
  5656.  
  5657. alert        move.l    excpttask(a4),d0
  5658.         bne.s    alert1
  5659.         move.w    #noguru,d0
  5660.         bra    putnamw
  5661. alert1        move.w    #softfail,d0
  5662.         bsr    putstrw
  5663.         move.l    excpttask(a4),d0
  5664.         bsr    getaskname2
  5665.         bsr    newline
  5666.         cmp.l    #3,excpterror(a4)
  5667.         bne.s    1$
  5668.         move.w    #addrserr,d0
  5669.         bsr    putstrw
  5670.         move.l    excptaddr(a4),d0
  5671.         bsr    hexa
  5672.         bsr    newline
  5673. 1$        move.w    #procount,d0
  5674.         bsr    putstrw
  5675.         move.l    excptpc(a4),d0
  5676.         bsr    hexa
  5677.         bsr    newline
  5678.         move.w    #gurutxt,d0
  5679.         bsr    putstrw
  5680.         move.l    excpterror(a4),d0
  5681.         bsr    hexa
  5682.         lea     out(a4),a0
  5683.         move.l    ptr(a4),d0
  5684.         move.b    #'.',-1(a0,d0.w)
  5685.         move.l    excpttask(a4),d0
  5686.         bsr    hexa
  5687.         bra    newline
  5688.  
  5689. showguru    bsr    stoptimer
  5690.         bsr    alert
  5691.         move.w    #_LVOScreenToFront,d0
  5692.         move.l    screenptr(a4),a0
  5693.         tst.b    ownscreen(a4)
  5694.         bne.s    5$
  5695.         move.w    #_LVOWindowToFront,d0
  5696.         move.l    wnptr(a4),a0
  5697. 5$        move.l    intuibase(a4),a6
  5698.         jsr    0(a6,d0.w)        ; Window or Screen ToFront()
  5699.  
  5700.         move.w    #whatnow,d0
  5701.         bsr    putnamw
  5702.         clr.l    oldpageend(a4)
  5703. 2$        bsr    readline
  5704.         cmp.b    #'i',d0
  5705.         beq.s    4$
  5706.         cmp.b    #'k',d0
  5707.         bne.s    2$
  5708.  
  5709.         move.l    excpttask(a4),a1
  5710.         tst.l    22(a1)
  5711.         bne.s    3$
  5712.         CALL    RemTask,sysbase(a4)
  5713.         bra.s    4$
  5714. 3$        move.l    a1,d0
  5715.         bsr    canok
  5716. 4$        clr.l    lastprinted(a4)
  5717.         bsr    starttimer
  5718.         rts
  5719.  
  5720. coldreboot    move.w    #$4000,$dff09a
  5721.         move.l    sysbase(a4),a6
  5722.         neg.w    82(a6)            ; kill ChkSum
  5723.         clr.l    4            ; kill ExecBase Ptr
  5724. reboot        move.l    sysbase(a4),a6
  5725.         tst.b    post_V34(a4)
  5726.         beq.s    1$
  5727.         jmp    _LVOColdReboot(a6)
  5728.  
  5729. 1$        lea    $01000004,a2        ; reboot manually
  5730.         suba.l    -$18(a2),a2
  5731.         movea.l    (a2),a2
  5732.         subq.l    #2,a2
  5733.         lea    2$(pc),a5
  5734.         jsr    _LVOSupervisor(a6)
  5735.         cnop    0,4
  5736. 2$        reset
  5737.         jmp    (a2)
  5738.  
  5739. ;save the contents of the output buffer
  5740. ;to a file, append the output if the file allready exists
  5741. saveoutput    bsr    nodenam2
  5742.         tst.b    0(a5)
  5743.         beq    syntax
  5744.         move.l    a5,d1
  5745.         move.l    #1004,d2        ; mode_readwrite
  5746.         CALL    Open,dosbase(a4)
  5747.         move.l    d0,d5
  5748.         beq.s    5$
  5749.         move.l    d5,d1
  5750.         moveq    #0,d2
  5751.         moveq    #1,d3
  5752.         RECALL    Seek
  5753.         bra.s    1$
  5754. 5$        move.l    a5,d1
  5755. ;        move.l    #1006,d2        ; mode_newfile
  5756.         addq.w    #2,d2
  5757.         RECALL    Open
  5758.         move.l    d0,d5
  5759.         bne.s    1$
  5760.         move.w    #openerr,d0
  5761.         bsr    putstrw
  5762.         move.l    a5,d0
  5763.         bra    putnam
  5764. 1$        move.l    outchain(a4),d0
  5765.         beq.s    3$
  5766. 2$        move.l    d0,a5
  5767.         move.w    12(a5),d3
  5768.         beq.s    4$
  5769.         ext.l    d3
  5770.         lea    14(a5),a0
  5771.         move.l    a0,d2
  5772.         move.l    d5,d1
  5773.         RECALL    Write
  5774.         tst.l    d0
  5775.         ble.s    3$
  5776. 4$        move.l    d5,d1
  5777.         lea     cr(a4),a0
  5778.         move.l    a0,d2
  5779.         moveq    #1,d3
  5780.         RECALL    Write
  5781.         tst.l    d0
  5782.         ble.s    3$
  5783.         move.l    0(a5),d0
  5784.         bne.s    2$
  5785. 3$        move.l    d5,d1
  5786.         RECALL    Close
  5787.         rts
  5788.  
  5789. grabtimerio    lea    tiohead(a4),a0
  5790.         bsr    puthead
  5791.         move.b    timeout(a4),d4
  5792.         st    timeout(a4)        ; 255 !
  5793.         bsr    starttimer
  5794.         move.b  d4,timeout(a4)
  5795.         pea    dummy(a4)
  5796.  
  5797.         CALL    Disable,sysbase(a4)
  5798.         lea    timerio(a4),a5
  5799. 6$        move.l    0(a5),a5
  5800.         tst.l    0(a5)            ; not lh_Tail
  5801.         bne.s    6$
  5802.         subq.l    #4,a5            ; now list header !
  5803.         RECALL    Enable
  5804.  
  5805.         bsr    stoptimer
  5806.         lea    buffer(a4),a3
  5807.         moveq    #1,d4            ; VBlank
  5808.         bsr    gettrq
  5809.  
  5810.         moveq    #40,d0
  5811.         lea    timerio(a4),a0
  5812.         move.l    (sp),a1            ; dummy
  5813.         RECALL    CopyMemQuick
  5814.  
  5815.         moveq    #0,d1
  5816.         moveq    #0,d0
  5817.         lea     timernam(a4),a0
  5818.         move.l    (sp),a1            ; dummy
  5819.         RECALL    OpenDevice
  5820.  
  5821.         move.l    (sp),a1            ; dummy
  5822.         move.l    #1<<30,32(a1)
  5823.         RECALL    SendIO
  5824.  
  5825.         RECALL    Disable
  5826.         move.l    (sp),a5            ; dummy
  5827. 5$        move.l    0(a5),a5
  5828.         tst.l    0(a5)
  5829.         bne.s    5$
  5830.         subq.l    #4,a5            ; now list header !
  5831.         RECALL    Enable
  5832.         move.l    (sp),a1            ; dummy
  5833.         bsr    stoptimer2
  5834.         moveq    #0,d4            ; MicroHz
  5835.         bsr    gettrq
  5836.  
  5837.         move.l    (sp),a1            ; dummy
  5838.         RECALL    CloseDevice
  5839.  
  5840.         clr.l    (a3)
  5841.         lea    -18(a3),a2
  5842.         moveq    #18,d2
  5843.         bsr    sortlist
  5844.  
  5845.         move.l    (sp)+,a0        ; dummy
  5846.  
  5847.         tst.b    post_V34(a4)
  5848.         beq.s    3$            ; "black magic" needed? ;-(
  5849.  
  5850.         CALL    ReadEClock,timerio+20(a4)
  5851.         move.l    dummy+4(a4),d2
  5852.         move.l    d0,d3            ; EClock
  5853.         lea    buffer(a4),a2
  5854. 4$        move.l    0(a2),d0
  5855.         beq.s    3$
  5856.         move.l    10(a2),d0
  5857.         sub.l    d2,d0
  5858.         scc    d1
  5859.         ext.w    d1
  5860.         ext.l    d1
  5861.         and.l    d1,d0
  5862.         move.l    d3,d1
  5863.         bsr    div
  5864.         movem.l    d0/d1,6(a2)
  5865.         lea    18(a2),a2
  5866.         bra.s    4$
  5867.  
  5868. 3$        lea    buffer(a4),a5
  5869. 2$        move.l    (a5)+,d0
  5870.         beq.s    1$
  5871.         bsr    hexa
  5872.         move.w    (a5)+,d0
  5873.         ext.l    d0
  5874.         mulu    #9,d0
  5875.         add.w     #timerunits,d0
  5876.         bsr    putstrw
  5877.         move.l    (a5)+,d0
  5878.         bsr    putstamp
  5879.         moveq    #'.',d0
  5880.         bsr    putchar
  5881.         move.l    (a5)+,d0
  5882.         move.l    #100000,d1
  5883.         bsr    div
  5884.         or.b    #'0',d0
  5885.         bsr    putchar
  5886.         bsr    putblank
  5887.         move.l    (a5)+,d0
  5888.         bsr    getaskname2
  5889.         bsr    newline
  5890.         bra.s    2$
  5891. 1$        rts
  5892.  
  5893. gettrq        RECALL    Disable            ; a6 - SysBase
  5894. 3$        move.l    0(a5),a5
  5895.         tst.l    0(a5)
  5896.         beq.s    4$
  5897.         move.l    a5,(a3)+
  5898.         move.w    d4,(a3)+
  5899.         move.l    32(a5),(a3)+
  5900.         move.l    36(a5),(a3)+
  5901.         move.l    14(a5),a1
  5902.         move.l    16(a1),(a3)+
  5903.         bra.s    3$
  5904. 4$        RECALL    Enable
  5905.         rts
  5906.  
  5907. ; check if the timer is runnig, start it if not
  5908. starttimer    lea    timerio(a4),a1
  5909.         cmp.b    #5,8(a1)
  5910.         beq.s    1$
  5911.         moveq    #0,d0
  5912.         move.b    timeout(a4),d0
  5913.         bne.s    2$
  5914.         tst.l    timeoutm(a4)
  5915.         beq.s    1$
  5916. 2$        move.l    d0,32(a1)
  5917.         move.l    timeoutm(a4),36(a1)
  5918.         move.w    #9,28(a1)
  5919.         CALL    SendIO,sysbase(a4)
  5920. 1$        rts
  5921.  
  5922. ; Abort a timer request, if pending
  5923. stoptimer    move.l    sysbase(a4),a6
  5924.         lea    timerio(a4),a1
  5925.         cmp.b    #5,8(a1)
  5926.         bne.s    stptim
  5927. stoptimer2    move.l    a1,-(sp)
  5928.         RECALL    AbortIO
  5929.         move.l    (sp)+,a1
  5930.         RECALL    WaitIO
  5931. stptim        move.w    timersig(a4),d0
  5932.         moveq    #0,d1
  5933.         bset    d0,d1
  5934.         moveq    #0,d0
  5935.         jmp    _LVOSetSignal(a6)    ; clr signal
  5936.  
  5937. ;install as commodity and/or a input-handler
  5938. installh    move.l    cxbase(a4),d0        ; commodity possible ?
  5939.         beq    1$
  5940.         lea    broker(a4),a3
  5941.         lea    hotkeybuf(a4),a5
  5942.         move.l    d0,a6            ; cxbase
  5943.         moveq    #0,d0
  5944.         suba.l    a0,a0
  5945.         bsr    CreatePort
  5946.         move.l    d0,newbroker+20(a4)
  5947.         move.l    d0,a0
  5948.         move.b    15(a0),cxsig+1(a4)
  5949.         moveq    #0,d0
  5950.         lea    newbroker(a4),a0
  5951.         RECALL    CxBroker
  5952.         move.l    d0,0(a3)
  5953.         beq.s    1$            ; no broker !
  5954.         moveq    #1,d0            ; CX_Filter
  5955.         move.l    a5,a0
  5956.         suba.l    a1,a1
  5957.         RECALL    CreateCxObj
  5958.         move.l    d0,filter(a4)
  5959.         beq.s    3$
  5960.         move.l    d0,a2
  5961.         move.l    d0,a0
  5962.         RECALL    CxObjError
  5963.         tst.l    d0
  5964.         beq.s    4$            ; hotkey definition ok !
  5965.         move.l    a5,a1
  5966.         lea    defhotkey(a4),a0
  5967. 5$        move.b    (a0)+,(a5)+        ; copy string
  5968.         bne.s    5$
  5969.         move.l    a2,a0
  5970.         RECALL    SetFilter        ; try our default
  5971. 4$        moveq    #4,d0            ; CX_Signal
  5972.         move.l    mytask(a4),a0
  5973.         move.w    #mysigbit,a1
  5974.         RECALL    CreateCxObj
  5975.         move.l    d0,a1            ; Signal -> Filter
  5976.         move.l    a2,a0
  5977.         RECALL    AttachCxObj
  5978.         moveq    #5,d0            ; CX_Translate
  5979.         suba.l    a0,a0
  5980.         suba.l    a1,a1
  5981.         RECALL    CreateCxObj
  5982.         move.l    d0,a1            ; Translate -> Filter
  5983.         move.l    a2,a0
  5984.         RECALL    AttachCxObj
  5985.         move.l    a2,a1            ; Filter -> Broker
  5986.         move.l    0(a3),a0
  5987.         RECALL    AttachCxObj
  5988. 3$        move.l    0(a3),a0        ; broker
  5989.         RECALL    CxObjError
  5990.         tst.l    d0
  5991.         beq.s    2$            ; no error
  5992.         move.l    0(a3),a0
  5993.         RECALL    DeleteCxObjAll
  5994.         clr.l    0(a3)            ; clear ptr
  5995. 2$        move.l    0(a3),d0
  5996.         beq.s    1$
  5997.         move.l    d0,a0
  5998.         moveq    #1,d0
  5999.         RECALL    ActivateCxObj
  6000.  
  6001. 1$        moveq    #0,d0
  6002.         suba.l    a0,a0
  6003.         bsr    CreatePort
  6004.         move.l    d0,inputport(a4)
  6005.         bsr    CreateStdIO
  6006.         move.l    d0,inputio(a4)
  6007.         move.l    d0,a1
  6008.         lea    devicenam(a4),a0
  6009.         moveq    #0,d0
  6010.         moveq    #0,d1
  6011.         CALL    OpenDevice,sysbase(a4)
  6012.         lea    ininterrupt(a4),a0
  6013.         move.l    a4,14(a0)
  6014.         movea.l    inputio(a4),a1
  6015.         move.w    #9,28(a1)
  6016.         move.l    a0,40(a1)
  6017.         jmp    _LVODoIO(a6)
  6018.  
  6019. ;change our commodity popkey
  6020. cxpopkey    bsr    nodenam2
  6021.         lea    hotkeybuf(a4),a3
  6022.         move.l    filter(a4),a2
  6023.         move.l    infile(a4),d7
  6024.         bne.s    3$            ; script
  6025.         tst.l    broker(a4)
  6026.         beq.s    1$            ; no broker - ignore
  6027.         move.l    a2,a0
  6028.         move.l    a5,a1
  6029.         CALL    SetFilter,cxbase(a4)    ; set new popkey
  6030.         move.l    a2,a0
  6031.         RECALL    CxObjError
  6032.         tst.l    d0
  6033.         beq.s    3$            ; no error
  6034.         move.l    a2,a0
  6035.         move.l    a3,a1
  6036.         RECALL    SetFilter        ; set old popkey
  6037.         move.l    a3,a5
  6038. 3$        moveq    #39,d0
  6039. 2$        move.b    (a5)+,(a3)+
  6040.         dbeq    d0,2$
  6041.         clr.b    (a3)
  6042.         tst.l    d7            ; script ?
  6043.         bne.s    1$
  6044.         bsr    setwintitle        ; show popkey
  6045. 1$        rts
  6046.  
  6047. ;remove commodity and/or handler
  6048. removeh        move.l    broker(a4),d2
  6049.         beq.s    3$            ; no commodity !
  6050.         move.l    d2,a0
  6051.         moveq    #0,d0            ; disable
  6052.         CALL    ActivateCxObj,cxbase(a4)
  6053.         move.l    d2,a0
  6054.         RECALL    DeleteCxObjAll
  6055. 3$        move.l    newbroker+20(a4),d0
  6056.         beq.s    2$            ; no port to delete
  6057.         bsr.s    1$
  6058. 2$        move.l    inputio(a4),a2
  6059.         move.l    a2,a1
  6060.         move.w    #10,28(a1)
  6061.         lea    ininterrupt(a4),a0
  6062.         move.l    a0,40(a1)
  6063.         CALL    DoIO,sysbase(a4)
  6064.         move.l    a2,a1
  6065.         RECALL    CloseDevice
  6066.         move.l    a2,d0
  6067.         bsr    DeleteStdIO
  6068.         move.l    inputport(a4),d0
  6069. 1$        bra    DeletePort
  6070.  
  6071. ;check broker port for messages from master control 'Exchange'
  6072. ChkBroker    move.l    a2,-(sp)
  6073.         tst.l    broker(a4)
  6074.         beq.s    1$
  6075. 5$        move.l    newbroker+20(a4),a0
  6076.         CALL    GetMsg,sysbase(a4)
  6077.         move.l    d0,a2
  6078.         move.l    a2,d0
  6079.         beq.s    1$
  6080.         move.l    a2,a0
  6081.         CALL    CxMsgType,cxbase(a4)
  6082.         cmp.w    #$40,d0            ; CXM_COMMAND
  6083.         bne.s    2$
  6084.         move.l    a2,a0
  6085.         RECALL    CxMsgID
  6086.         move.l    mysignal(a4),d1
  6087.         cmp.w    #25,d0            ; CXCMD_UNIQUE
  6088.         beq.s    3$
  6089.         cmp.w    #23,d0            ; CXCMD_KILL
  6090.         seq    wantexit(a4)
  6091.         beq.s    4$
  6092.         cmp.w    #19,d0            ; CXCMD_APPEAR
  6093.         beq.s    3$
  6094.         moveq    #0,d1
  6095.         cmp.w    #21,d0            ; CXCMD_DISAPPEAR
  6096.         bne.s    3$
  6097.         st    wanthold(a4)
  6098. 4$        st    cbreak(a4)        ; end snooping (if necessary)
  6099.         move.w    nspubsig+6(a4),d0
  6100.         bset    d0,d1
  6101. 3$        move.l    d1,d0
  6102.         CALL    SetSignal,sysbase(a4)    ; set new signals
  6103. 2$        move.l    a2,a1
  6104.         CALL    ReplyMsg,sysbase(a4)
  6105.         bra.s    5$
  6106. 1$        move.l    (sp)+,a2
  6107.         rts
  6108.  
  6109. ;this is the handler, it checks if amiga-amiga-x
  6110. ;has been pressed and signals it to our task
  6111. keyhandler    move.l    a0,-(sp)
  6112.         tst.l    broker(a1)
  6113.         beq.s    2$        ; not running as commodity !
  6114.         tst.b    cxstate(a1)
  6115.         bne.s    1$        ; handler is off
  6116. 2$        cmp.b    #1,4(a0)
  6117.         bne.s    1$
  6118.         move.w    8(a0),d0
  6119.         andi.w    #$c0,d0
  6120.         cmpi.w    #$c0,d0
  6121.         bne.s    1$
  6122.         cmp.w    #$32,6(a0)
  6123.         bne.s    1$
  6124.         clr.b    4(a0)        ; nop event
  6125.         bsr.s    wakeup
  6126. 1$        move.l    (sp)+,d0    ; return event
  6127.         rts
  6128.  
  6129. ;wakeup Xoper
  6130. wakeup        move.l    mysignal(a1),d0
  6131.         move.l    sysbase(a1),a6
  6132.         movea.l    mytask(a1),a1
  6133.         jmp    _LVOSignal(a6)
  6134.  
  6135. ;ports-handler
  6136. countio        addq.l    #1,iocount(a1)
  6137.         tst.b    pcheck(a1)
  6138.         beq.s    1$            ; check not requested
  6139.         bsr.s    checkit
  6140.         tst.b    d1
  6141.         beq.s    1$
  6142.         clr.b    pcheck(a1)        ; disable checking ...
  6143.         bsr.s    wakeup
  6144. 1$        moveq    #0,d0
  6145.         rts
  6146.  
  6147. checkit        moveq    #0,d1            ; check all patched functions
  6148.         move.l    sysbase(a1),a6        ; exec library
  6149.         tst.b    bool(a1)
  6150.         beq.s    5$
  6151.         lea    myswitch(pc),a5
  6152.         move.w    #_LVOSwitch,d0
  6153.         bsr.s    2$
  6154.         lea    myaddtask(pc),a5
  6155.         move.w    #_LVOAddTask,d0
  6156.         bsr.s    2$
  6157. 5$        tst.b    msnoop(a1)
  6158.         beq.s    4$
  6159.         lea    capmalloc(pc),a5
  6160.         move.w    #_LVOAllocMem,d0
  6161.         bsr.s    2$
  6162.         lea    capmfree(pc),a5
  6163.         move.w    #_LVOFreeMem,d0
  6164.         bsr.s    2$
  6165. 4$        move.l    dosbase(a1),a6        ; dos library
  6166.         tst.b    DosTable+05(a1)
  6167.         beq.s    3$
  6168.         move.l    DosTable+16(a1),a5
  6169.         move.w    DosTable+00(a1),d0
  6170.         bsr.s    2$
  6171. 3$        tst.b    DosTable+25(a1)
  6172.         beq.s    1$
  6173.         move.l    DosTable+36(a1),a5
  6174.         move.w    DosTable+20(a1),d0
  6175. 2$        cmp.l    2(a6,d0.w),a5        ; check library function
  6176.         seq    d1
  6177. 1$        rts
  6178.  
  6179. ;compare strings
  6180. ; -> a0/a1 = pointers to string
  6181. ; <- d0 = true(0) false(1), d1 = length
  6182.  
  6183. strcmp        movem.l    d2/a0/a1,-(sp)
  6184.         moveq    #0,d0
  6185.         moveq    #0,d1
  6186. src2        move.b    (a0)+,d0
  6187.         beq.s    src1
  6188.         cmp.b    #10,d0
  6189.         beq.s    src1
  6190.         bsr.s    src4
  6191.         move.b    d0,d2
  6192.         move.b    (a1)+,d0
  6193.         bsr.s    src4
  6194.         cmp.b    d2,d0
  6195.         bne.s    src3
  6196.         addq.w    #1,d1
  6197.         bra.s    src2
  6198. src1        move.b    0(a1),d0
  6199. src3        movem.l    (sp)+,d2/a0/a1
  6200.         rts
  6201.  
  6202. src4        cmp.b    #'z'+1,d0        ; convert to upper case
  6203.         bcc.s    1$
  6204.         cmp.b    #'a',d0
  6205.         bcs.s    1$
  6206.         add.b    #$e0,d0
  6207. 1$        rts
  6208.  
  6209. strbuf        movem.l    d0/a1-a2,-(sp)
  6210.         move.l    a0,a1
  6211.         lea    buffer(a4),a2
  6212. 1$        move.b    (a1)+,d0
  6213.         cmp.b    #10,d0
  6214.         beq.s    2$
  6215.         cmp.b    #' ',d0
  6216.         beq.s    2$
  6217.         or.b    #' ',d0
  6218.         beq.s    2$
  6219.         move.b    d0,(a2)+
  6220.         bra.s    1$
  6221. 2$        clr.b    (a2)+
  6222.         movem.l    (sp)+,d0/a1-a2
  6223.         rts
  6224.  
  6225. tolower        movem.l    d0-d1/a0,-(sp)
  6226.         subq.w    #1,d0
  6227.         bmi.s    3$
  6228. 1$        move.b    0(a0),d1
  6229.         cmp.b    #'A',d1
  6230.         blt.s    2$
  6231.         cmp.b    #'Z',d1
  6232.         bgt.s    2$
  6233.         or.b    #' ',d1
  6234. 2$        move.b    d1,(a0)+
  6235.         dbra    d0,1$
  6236. 3$        clr.b    (a0)
  6237.         movem.l    (sp)+,d0-d1/a0
  6238.         rts
  6239.  
  6240. div        tst.l    d1
  6241.         beq.s    1$
  6242.         move.l    div32(a4),-(sp)
  6243. 1$        rts
  6244.  
  6245. ; 32-bit division d0 / d1
  6246. ; <- d0 - result
  6247. ;    d1 - remainder
  6248.  
  6249. div68020    dc.w    $4c41,$0001        ; divul.l d1,d1:d0
  6250.         rts
  6251.  
  6252. div68000    move.l    d3,-(sp)
  6253.         move.l    d2,-(sp)
  6254.         move.l    d1,d3
  6255.         swap    d1
  6256.         tst.w    d1
  6257.         bne.s    4$
  6258.         move.w    d0,d2
  6259.         clr.w    d0
  6260.         swap    d0
  6261.         divu.w    d3,d0
  6262.         move.l    d0,d1
  6263.         swap    d0
  6264.         move.w    d2,d1
  6265.         divu.w    d3,d1
  6266.         move.w    d1,d0
  6267.         clr.w    d1
  6268.         swap    d1
  6269.         bra.s    1$
  6270. 4$        move.l    d0,d1
  6271.         swap    d0
  6272.         clr.w    d0
  6273.         clr.w    d1
  6274.         swap    d1
  6275.         moveq    #16-1,d2
  6276. 3$        add.l    d0,d0
  6277.         addx.l    d1,d1
  6278.         cmp.l    d1,d3
  6279.         bhi.s    2$
  6280.         sub.l    d3,d1
  6281.         addq.w    #1,d0
  6282. 2$        dbra    d2,3$
  6283. 1$        move.l    (sp)+,d2
  6284.         move.l    (sp)+,d3
  6285.         rts
  6286.  
  6287. ;copy a string from input to 'buffer'
  6288. ; -> a0 = pointer to string
  6289. getstr        lea    buffer(a4),a5
  6290. 1$        cmp.b    #' ',0(a0)
  6291.         beq.s    2$
  6292.         cmp.b    #10,0(a0)
  6293.         beq.s    2$
  6294.         move.b    (a0)+,(a5)+
  6295.         bra.s    1$
  6296. 2$        clr.b     0(a5)
  6297.  
  6298. ;skip blanks
  6299. ; -> a0 pointer to text
  6300. ; <- a0 = new pointer position
  6301. kllblnks    cmpi.b    #' ',(a0)+
  6302.         beq.s    kllblnks
  6303.         subq.w    #1,a0
  6304.         rts
  6305.  
  6306. ;read in a nodename or a processname
  6307. nodenam        bsr.s    isdec
  6308.         move.w    d2,procnum(a4)
  6309. nodenam2    bsr.s    kllblnks
  6310.         move.l    a0,a5
  6311. gno1        cmp.b    #10,(a0)+
  6312.         bne.s    gno1
  6313.         clr.b    -1(a0)
  6314.         rts
  6315.  
  6316. getfrac        bsr.s    isdec
  6317.         moveq    #0,d0
  6318.         cmp.b    #'.',(a0)
  6319.         bne.s    1$
  6320.         addq.w    #1,a0
  6321.         cmp.b    #10,(a0)
  6322.         beq.s    1$
  6323.         move.b    (a0)+,d0
  6324.         and.b    #$0f,d0
  6325.         moveq    #1,d7
  6326. 1$        muls    #10,d2
  6327.         add.l    d0,d2
  6328.         rts
  6329.  
  6330. ;convert ascii to byte
  6331. ; -> a0 = pointer to text
  6332. ; <- d0 = byte
  6333. getnum        bsr.s    kllblnks
  6334.         cmp.b    #'$',0(a0)
  6335.         bne.s    isdec
  6336.         bsr.s    readhex
  6337.         move.l    d0,d2
  6338.         rts
  6339. isdec        moveq    #0,d2
  6340.         moveq    #0,d3
  6341.         moveq    #0,d6
  6342.         moveq    #0,d7
  6343.         cmp.b    #'-',0(a0)
  6344.         bne.s    gn1
  6345.         addq.w    #1,a0
  6346.         moveq    #1,d6
  6347. gn1        move.b    (a0)+,d3
  6348.         cmp.b    #'9',d3
  6349.         bhi.s    gn2
  6350.         cmp.b    #'0',d3
  6351.         bcs.s    gn2
  6352.         moveq     #1,d7
  6353.         and.b    #$f,d3
  6354.         muls    #10,d2
  6355.         add.l    d3,d2
  6356.         bra.s    gn1
  6357. gn2        tst.b    d6
  6358.         beq.s    gn3
  6359.         neg.l    d2
  6360. gn3        subq.w    #1,a0
  6361.         rts
  6362.  
  6363. ;convert hex to longword
  6364. ; -> a0 = pointer to text
  6365. ; <- d0=value, d7 = ok(1) error(0)
  6366. readhex        movem.l    d1-d6/a1-a5,-(sp)
  6367.         moveq    #1,d7
  6368.         cmp.b    #'$',0(a0)
  6369.         bne.s    rh3
  6370.         addq.l    #1,a0
  6371. rh3        moveq    #0,d0
  6372.         cmpi.b    #10,0(a0)
  6373.         beq.s    rherr
  6374.         lea    hextab(a4),a1
  6375. rh0        move.b    (a0)+,d3
  6376.         moveq.l    #15,d2
  6377. rh1        cmp.b    0(a1,d2.w),d3
  6378.         beq.s    rh2
  6379.         dbra    d2,rh1
  6380.         bra.s    rhend
  6381. rh2        lsl.l    #4,d0
  6382.         or.b    d2,d0
  6383.         bra.s    rh0
  6384. rhend        tst.b    d3
  6385.         beq.s    rhok
  6386.         cmpi.b    #10,d3
  6387.         beq.s    rhok
  6388.         cmpi.b    #' ',d3
  6389.         beq.s    rhok
  6390. rherr        moveq    #0,d7
  6391. rhok        movem.l    (sp)+,d1-d6/a1-a5
  6392.         rts
  6393.  
  6394. longdecn    move.l    d3,-(sp)
  6395.         moveq    #3,d3
  6396.         bsr.s    longdec
  6397.         move.l    (sp)+,d3
  6398.         move.w    #binarea+9,d0
  6399.         sub.w    d3,d0
  6400.         bra    putstrw
  6401.  
  6402. ;convert long to decimal
  6403. ; -> d0 = value
  6404. ;    d3 bit 0 = left/right justified
  6405. ;       bit 1 = write/leave
  6406. ; returns string in 'buffer'
  6407. longdec        movem.l    d1-d2/a1-a2,-(sp)
  6408.         tst.l    d0
  6409.         bmi.s    2$
  6410.         cmp.l    #999999999,d0
  6411.         ble.s    1$
  6412. 2$        move.w    #longlongnix,d0
  6413.         bra.s    ld6
  6414. 1$        lea    binarea(a4),a1
  6415.         move.l    #'    ',(a1)+
  6416.         move.l    #'    ',(a1)+
  6417.         move.w    #'  ',(a1)+
  6418.         clr.b    0(a1)
  6419.         subq.w    #1,a1
  6420.         cmp.w    #2,d3
  6421.         bne.s    ld5
  6422.         clr.b    0(a1)
  6423. ld5        moveq    #1,d2
  6424. ld2        addq.w    #1,d2
  6425.         moveq    #10,d1
  6426.         bsr    div
  6427.         addi.b    #'0',d1
  6428.         move.b    d1,-(a1)
  6429.         tst.l    d0
  6430.         bne.s    ld2
  6431.         btst    #0,d3
  6432.         bne.s    ld1
  6433.         lea    binarea(a4),a2
  6434.         cmpa.l    a2,a1
  6435.         bne.s    ld3
  6436.         subq.l    #1,ptr(a4)
  6437.         bra.s    ld1
  6438. ld3        move.b    0(a1),(a2)+
  6439.         move.b    #' ',(a1)+
  6440.         dbra    d2,ld3
  6441. ld1        move.w    #binarea,d0
  6442. ld6        btst    #1,d3
  6443.         bne.s    ld4
  6444.         bsr    putstrw
  6445. ld4        movem.l    (sp)+,d1-d2/a1-a2
  6446.         rts
  6447.  
  6448. putlongascii    movem.l    d1/d2,-(sp)
  6449.         moveq    #3,d2
  6450.         move.l    d0,d1
  6451. 2$        rol.l    #8,d1
  6452.         move.b    d1,d0
  6453.         beq.s    1$
  6454.         bsr    putchar
  6455. 1$        dbra    d2,2$
  6456.         movem.l    (sp)+,d1/d2
  6457.         rts
  6458.  
  6459. putstamp    movem.l    d0/d1,-(sp)
  6460.         move.l    #3600,d1
  6461.         bsr    div
  6462.         moveq    #3,d3
  6463.         bsr    longdec
  6464.         move.l    binarea+6(a4),d0
  6465.         lsr.l    #8,d0
  6466.         bsr.s    putlongascii
  6467.         moveq    #':',d0
  6468.         bsr    putchar
  6469.         move.l    d1,d0
  6470.         moveq    #60,d1
  6471.         bsr    div
  6472.         bsr.s    write2digs
  6473.         moveq    #':',d0
  6474.         bsr    putchar
  6475.         move.l    d1,d0
  6476.         bsr.s    write2digs
  6477.         movem.l (sp)+,d0/d1
  6478.         rts
  6479.  
  6480. write2digs    movem.l    d0/d1,-(sp)
  6481.         divu    #10,d0
  6482.         move.l    d0,d1
  6483.         or.b    #'0',d0
  6484.         bsr    putchar
  6485.         swap    d1
  6486.         or.b    #'0',d1
  6487.         move.b    d1,d0
  6488.         bsr    putchar
  6489.         movem.l    (sp)+,d0/d1
  6490.         rts
  6491.  
  6492. ;print a bcpl-string
  6493. ; -> d0 = bcpl-pointer to bcpl-string
  6494. putbcpl        movem.l    d3/a0-a1,-(sp)
  6495.         tst.l    d0
  6496.         beq.s    1$
  6497.         lsl.l    #2,d0
  6498.         move.l    d0,a1
  6499.         moveq    #0,d3
  6500.         move.b    (a1)+,d3
  6501.         subq.w    #1,d3
  6502.         bmi.s    1$
  6503. 2$        move.b    (a1)+,d0
  6504.         beq.s    1$
  6505.         bsr    putchar
  6506.         dbra    d3,2$
  6507. 1$        move.l    ptr(a4),d0
  6508.         movem.l    (sp)+,d3/a0-a1
  6509.         rts
  6510.  
  6511. ;write unsigned word
  6512. ; -> d3 = value
  6513. worddec        bsr.s    dec2
  6514.         move.w    #minus+1,d0
  6515.         bra    putstrw
  6516.  
  6517. ;write unsigned byte
  6518. ; -> d3 = value
  6519. bytedec        bsr.s    dec1
  6520.         move.w    #decimal,d0
  6521.         bra    putstrw
  6522.  
  6523. ;write signed byte
  6524. ; -> d3 = value
  6525. plusmins    movem.l    d5/a3,-(sp)
  6526.         move.w    #$2020,minus(a4)
  6527.         move.b    d3,d5
  6528.         bpl.s    2$
  6529.         neg.b    d3
  6530. 2$        bsr.s    dec1
  6531.         tst.b    d5
  6532.         bpl.s    1$
  6533.         move.l    d0,a3
  6534.         move.b    #'-',-(a3)
  6535. 1$        movem.l    (sp)+,d5/a3
  6536.         move.w    #minus+1,d0
  6537.         bra    putstrw
  6538.  
  6539. dec2        movem.l    d3/a2/a3,-(sp)        ; convert word
  6540.         and.l    #$ffff,d3
  6541.         lea    minus(a4),a3
  6542.         move.w    #$2020,(a3)+
  6543.         bra.s    dec
  6544.  
  6545. dec1        movem.l    d3/a2/a3,-(sp)        ; convert byte
  6546.         and.l    #$ff,d3
  6547.         lea    decimal(a4),a3
  6548.  
  6549. dec        move.l    #$20203020,(a3)+
  6550.         subq.l    #1,a3
  6551.         move.l    a3,a2
  6552.         moveq    #'0',d0
  6553. 3$        tst.b    d3
  6554.         beq.s    2$
  6555.         divu    #10,d3
  6556.         swap    d3
  6557.         or.b    d0,d3
  6558.         move.b    d3,-(a3)
  6559.         clr.w    d3
  6560.         swap    d3
  6561.         bra.s    3$
  6562. 2$        cmpa.l    a2,a3
  6563.         bcs.s    1$
  6564.         move.b    d0,-(a3)
  6565. 1$        move.l    a3,d0
  6566.         movem.l    (sp)+,d3/a2/a3
  6567.         rts
  6568.  
  6569. prcent        lsl.l    #3,d0            ; 1000x=1024x-24x
  6570.         move.l    d0,d2
  6571.         add.l    d0,d0
  6572.         add.l    d0,d2
  6573.         lsl.l    #6,d0
  6574.         sub.l    d2,d0
  6575.         bsr    div
  6576.         moveq    #0,d5
  6577.         bsr.s    putfrac
  6578.         move.w    #infoh4,d0
  6579.         bra    putstrw
  6580.  
  6581. putfrac        divu    #10,d0
  6582.         move    d0,d3
  6583.         swap    d0
  6584.         move    d0,d1
  6585.         tst.w    d5
  6586.         bne.s    1$
  6587.         cmp.w    #100,d3
  6588.         ble.s    1$
  6589.         move.w    #whatsthis,d0
  6590.         bra    putstrw
  6591. 1$        bsr    bytedec
  6592.         lea    out(a4),a0
  6593.         move.b    #'.',-1(a0,d0)
  6594.         or.b    #'0',d1
  6595.         move    d1,d0
  6596.         bra    putchar
  6597.  
  6598. ;Write pointer, display '-------' if empty
  6599. hexan        tst.l    d0
  6600.         beq.s    hexa2
  6601.  
  6602. ;Write 8 byte hex value
  6603. ; -> d0 = value
  6604. hexa        bsr.s    gthex
  6605. hexa2        bra    putstr
  6606.  
  6607. gthex        movem.l    d1-d2/a1-a2,-(sp)
  6608.         lea    hexarea+9(a4),a2
  6609.         move.b    #' ',-(a2)
  6610.         lea    hextab(a4),a1
  6611.         moveq    #7,d2
  6612. hexloop     moveq    #$0f,d1
  6613.         and.b    d0,d1
  6614.         move.b    0(a1,d1.w),-(a2)
  6615.         lsr.l    #4,d0
  6616.         dbra    d2,hexloop
  6617.         move.l    a2,d0
  6618.         movem.l    (sp)+,d1-d2/a1-a2
  6619.         rts
  6620.  
  6621. ;Convert/write byte into binary string
  6622. ; -> d0 = value
  6623. bin        movem.l    d1-d7/a0-a6,-(sp)
  6624.         lea    binarea(a4),a0
  6625.         move.l    #$2020<<16,8(a0)
  6626.         moveq    #7,d4
  6627. binloop        moveq    #'0'/2,d1
  6628.         roxr.b    #1,d0
  6629.         roxl.b    #1,d1
  6630.         move.b    d1,0(a0,d4.w)
  6631.         dbra    d4,binloop
  6632.         move.l    a0,d0
  6633.         movem.l    (sp)+,d1-d7/a0-a6
  6634.         bra    putstr
  6635.  
  6636. ;look for NUL-Byte
  6637. strlen        moveq    #0,d0
  6638.  
  6639. ;look for character in d0
  6640. strlen2        move.l    a0,-(sp)
  6641. 1$        cmp.b    (a0)+,d0
  6642.         bne.s    1$
  6643.         move.l    a0,d0
  6644.         move.l    (sp)+,a0
  6645.         sub.l    a0,d0
  6646.         subq.l    #1,d0
  6647.         rts
  6648.  
  6649. ;write a title and underline
  6650. ; -> a0 = pointer to text
  6651. puthead1    bsr.s    strlen
  6652.         move.l    d0,d5
  6653.         move.l    a0,d0
  6654.         bra    putstr
  6655.  
  6656. puthead2    bsr.s    strlen
  6657.         add.l    d0,d5
  6658.         bra.s    ph2
  6659.  
  6660. puthead        bsr.s    strlen
  6661.         move.l    d0,d5
  6662. ph2        move.l    a0,d0
  6663.         bsr.s    putnam
  6664.         lea    out(a4),a0
  6665.         move.l    a0,d0
  6666. ph1        move.b    #'-',(a0)+
  6667.         dbra    d5,ph1
  6668.         move.b    #10,(a0)+
  6669.         clr.b    0(a0)
  6670.         bra.s    putstr
  6671.  
  6672. syntax        move.w    #synerr,d0        ; error
  6673.  
  6674. ;write a string, move cursor into next line
  6675. ; -> d0 = pointer to text
  6676. putnamw        bsr.s    putstrw
  6677.         bra.s    putnam1
  6678. putnam        bsr.s    putstr
  6679. putnam1        tst.b    d0
  6680.         beq.s    1$
  6681.         bsr.s    newline
  6682. 1$        rts
  6683.  
  6684. newline        move.w    #cr,d0            ; linefeed
  6685.  
  6686. ;write a string, strings are only put into the output buffer
  6687. ;when a LF is detected
  6688. ; -> d0 = pointer to string
  6689. ; <- d0 = cursor position
  6690.  
  6691. putstrw        ext.l    d0
  6692.         add.l    a4,d0            ; dataarea
  6693. putstr        movem.l    d1-d7/a0-a6,-(sp)
  6694.         st    printed(a4)
  6695.         move.l    d0,a2
  6696.         lea    out(a4),a3
  6697.         move.l    ptr(a4),d0
  6698.         move.l    a2,d5
  6699.         bne.s    pst1
  6700.         lea    longnix(a4),a2
  6701.  
  6702. pst1        move.b    (a2)+,d1
  6703.         cmpi.b    #13,d1
  6704.         beq.s    pst1
  6705.         cmpi.b    #10,d1
  6706.         beq.s    lineend
  6707.         move.b    d1,0(a3,d0.w)
  6708.         beq    prend
  6709.         cmp.w    #100+100,d0
  6710.         bge.s    pst1
  6711.         addq.l    #1,d0
  6712.         bra.s    pst1
  6713.  
  6714. lineend        tst.l    infile(a4)
  6715.         beq.s    1$
  6716.         moveq    #0,d0
  6717.         bra    prend
  6718.  
  6719. 1$        tst.l    lastprinted(a4)
  6720.         bne.s    2$
  6721.         bsr    killpage
  6722.  
  6723. 2$        addq.w    #1,d0
  6724.         move.l    d0,-(sp)
  6725.         add.w    #14,d0
  6726.         moveq    #0,d1
  6727.         CALL    AllocMem,sysbase(a4)
  6728.         move.l    (sp)+,d1
  6729.         tst.l    d0
  6730.         beq    prend
  6731.         move.l    d0,a0
  6732.         move.w    d1,12(a0)
  6733.         cmp.w    maxllength(a4),d1
  6734.         ble.s    7$
  6735.         move.w    d1,maxllength(a4)
  6736. 7$        move.l    node(a4),8(a0)
  6737.         clr.l    node(a4)
  6738.         clr.l    0(a0)
  6739.         move.l    lastprinted(a4),d0
  6740.         move.l    d0,4(a0)
  6741.         bne.s    3$
  6742.         move.l    a0,outchain(a4)
  6743.         bra.s    4$
  6744. 3$        move.l    d0,a1
  6745.         move.l    a0,0(a1)
  6746. 4$        move.l    a0,lastprinted(a4)
  6747.         lea    out(a4),a1
  6748.         lea    14(a0),a0
  6749.         move.b    #' ',(a0)+
  6750.         subq.w    #2,d1
  6751.         bmi.s    6$
  6752. 5$        move.b    (a1)+,(a0)+
  6753.         dbra    d1,5$
  6754. 6$        move.l    numlines(a4),d2
  6755.         cmp.l    maxlines(a4),d2
  6756.         ble.s    8$
  6757.         move.l    outchain(a4),a1        ; maxlines reached !
  6758.         move.l    0(a1),a0
  6759.         move.l    a0,outchain(a4)
  6760.         clr.l    4(a0)
  6761.         moveq    #14,d0
  6762.         add.w    12(a1),d0
  6763.         CALL    FreeMem,sysbase(a4)
  6764.         bra.s    9$
  6765.  
  6766. 8$        addq.l    #1,numlines(a4)
  6767. 9$        moveq    #0,d0
  6768.         tst.b    addlines(a4)
  6769.         beq.s    10$
  6770.         bsr    addline
  6771. 10$        bra    pst1
  6772. prend        move.l    d0,ptr(a4)
  6773.         movem.l    (sp)+,d1-d7/a0-a6
  6774.         rts
  6775.  
  6776. putblank    moveq    #' ',d0            ; store one blank
  6777.  
  6778. ;write one char 
  6779. ; -> d0 = char
  6780. putchar        movem.l    d1/a1,-(sp)
  6781.         move.l    ptr(a4),d1
  6782.         lea    out(a4),a1
  6783.         move.b    d0,0(a1,d1.w)
  6784.         addq.l    #1,ptr(a4)
  6785.         movem.l    (sp)+,d1/a1
  6786.         rts
  6787.  
  6788. ;move cursor to a column
  6789. ; -> d0 = current position
  6790. ;    d1 = column
  6791. tab        move.l    a3,-(sp)
  6792.         lea    out(a4),a3
  6793. 1$        cmp.b    d1,d0
  6794.         bcc.s    2$
  6795.         move.b    #' ',0(a3,d0.w)
  6796.         addq.b    #1,d0
  6797.         bra.s    1$
  6798. 2$        move.l    d1,ptr(a4)
  6799.         move.l    (sp)+,a3
  6800.         rts
  6801.  
  6802. ; Xoper main loop, process all incoming messages
  6803. processmsgs    moveq    #0,d0
  6804.         move.w    cxsig(a4),d1
  6805.         beq.s    3$
  6806.         bset    d1,d0
  6807. 3$        move.w    nspubsig+6(a4),d1
  6808.         bset    d1,d0
  6809.         move.w    intuisig(a4),d1
  6810.         bset    d1,d0
  6811.         move.w    timersig(a4),d1
  6812.         bset    d1,d0
  6813.         ori.w    #$1000,d0
  6814.         or.l    mysignal(a4),d0
  6815.         or.l    auxsig(a4),d0
  6816.         tst.l    auxsig(a4)
  6817.         bne.s    2$
  6818.         or.l    trapsignal(a4),d0
  6819. 2$        CALL    Wait,sysbase(a4)
  6820.  
  6821.         move.l    d0,tasksigs(a4)
  6822.  
  6823.         move.l    trapsignal(a4),d1
  6824.         and.l    d0,d1
  6825.         beq.s    1$
  6826.         tst.b    gotguru(a4)
  6827.         bne.s    1$
  6828.         st    gotguru(a4)
  6829.         bsr    showguru
  6830.         clr.b    gotguru(a4)
  6831.  
  6832. 1$        bsr    ChkBroker        ; check broker port
  6833.  
  6834. ctrl_c        moveq    #12,d1
  6835.         bsr    testsig
  6836.         beq.s    pubscreen
  6837.         bsr    exitall            ; exit requested (break)
  6838.  
  6839. pubscreen    move.w    nspubsig+6(a4),d1
  6840.         bsr    testsig
  6841.         beq.s    hotkey
  6842.         pea    hotkey(pc)        ; return address (if necessary)
  6843.         tst.b    wantexit(a4)
  6844.         bne    exitall            ; exit requested
  6845.         tst.b    wanthold(a4)
  6846.         bne    instback        ; hold requested
  6847.         tst.b    wantwindow(a4)
  6848.         bne    usewindow        ; window requested
  6849.         addq.w    #4,sp
  6850.         bsr    setupscreen        ; rebuild screen
  6851.  
  6852. hotkey        moveq    #mysigbit,d1
  6853.         bsr    testsig
  6854.         beq.s    timermsg
  6855.         move.l    intuibase(a4),a6    ; Screen & window to front
  6856.         move.l    wnptr(a4),a2
  6857.         tst.b    ownscreen(a4)
  6858.         bne.s    1$            ; for scr window only activate !
  6859.         move.l    a2,a0
  6860.         RECALL    WindowToFront
  6861. 1$        move.l    a2,a0
  6862.         RECALL    ActivateWindow
  6863.         move.l    46(a2),a0        ; Window->Screen frontmost ?
  6864.         cmp.l    60(a6),a0
  6865.         beq.s    timermsg        ; yes, so skip !
  6866.         RECALL    ScreenToFront
  6867.  
  6868. timermsg    move.w    timersig(a4),d1
  6869.         bsr    testsig
  6870.         beq.s    intuimsgs
  6871.         btst.w    #8,propinfo(a4)
  6872.         bne.s    3$
  6873.         tst.b    repeat(a4)
  6874.         bne.s    1$
  6875.         bsr    showwhat
  6876.         bra.s    intuimsgs
  6877. 1$        move.w    repeatlen(a4),d0
  6878.         lea    repeatbuffer(a4),a2
  6879.         lea    dummy(a4),a1
  6880.         move.w    d0,d1
  6881. 2$        move.b    (a2)+,(a1)+
  6882.         dbra    d1,2$
  6883.         bsr    cli
  6884. 3$        bsr    starttimer
  6885.  
  6886. intuimsgs    move.w    intuisig(a4),d1
  6887.         bsr    testsig
  6888.         beq    processnxtmsg
  6889. nextimsg    move.l    wnptr(a4),a0
  6890.         move.l    $56(a0),a0
  6891.         CALL    GetMsg,sysbase(a4)
  6892.         move.l    d0,intuimsg(a4)
  6893.         beq    processnxtmsg
  6894.         move.l    d0,a0
  6895.         move.l    20(a0),d0
  6896.  
  6897.         cmp.l    #$200,d0        ; CloseWindow
  6898.         bne.s    1$
  6899.         tst.b    addlines(a4)
  6900.         beq    instback        ; iconify !
  6901.         st    cbreak(a4)
  6902.         bra    intuiend
  6903.  
  6904. 1$        cmp.l    #2,d0            ; ResizeWindow
  6905.         bne.s    1010$
  6906. 3443$        bsr    setupscreen
  6907.         bra    intuiend
  6908.  
  6909. 1010$        cmp.l    #$10,d0
  6910.         bne.s    2$
  6911.         btst.w    #8,propinfo(a4)
  6912.         bne.s    1004$
  6913.         bra.s    1002$
  6914.  
  6915. 2$        cmp.l    #4,d0            ; refresh
  6916.         bne.s    22$
  6917.         bsr    putiline
  6918.         bsr    blastout
  6919.         bsr    UpdateIArea
  6920.         bra.s    1002$
  6921.  
  6922. 22$        tst.b    addlines(a4)
  6923.         bne.s    3$
  6924.         cmp.l    #$20,d0            ; gadgetdown
  6925.         bne.s    1000$
  6926.         tst.b    getanswer(a4)
  6927.         bne.s    3$
  6928.         move.l    28(a0),a1
  6929.         cmp.w    #3,38(a1)        ; Slidebar
  6930.         bne.s    1002$
  6931.         tst.b    propgadon(a4)
  6932.         beq.s    1002$
  6933. 1004$        bsr    proppos
  6934. 1002$        bra    intuiend
  6935.  
  6936. 1000$        cmp.l    #$40,d0            ; gadgetup
  6937.         bne.s    3$
  6938.         move.l    28(a0),a1
  6939.         cmp.w    #3,38(a1)        ; Slidebar ?
  6940.         bne.s    1003$
  6941.         bclr.w    #8,propinfo(a4)        ; clear 'knop hit' bit
  6942.         bra.s    1002$
  6943.  
  6944. 1003$        bsr    replyintui        ; iconify
  6945.         bsr    stoptimer
  6946.         bra    instback
  6947.  
  6948. 3$        cmp.l    #$400,d0        ; RawKey
  6949.         bne    intuiend
  6950.         move.w    #$80,d0
  6951.         and.w    24(a0),d0
  6952.         bne    intuiend
  6953.         and.w    #$7f,24(a0)
  6954.         lea    ievent(a4),a1
  6955.         move.b    #1,4(a1)
  6956.         move.l    24(a0),6(a1)
  6957.         move.w    26(a0),qualifier(a4)
  6958.         move.l    a1,a0
  6959.         lea    outevent(a4),a1
  6960.         moveq    #20,d1
  6961.         suba.l    a2,a2
  6962.         CALL    RawKeyConvert,condev(a4)
  6963.         tst.l    d0
  6964.         beq    intuiend
  6965.         lea    inputbuffer(a4),a1
  6966.         lea    outevent(a4),a2
  6967.         move.w    curpos(a4),d4
  6968.         moveq    #0,d3
  6969.         tst.b    addlines(a4)
  6970.         bne    197$
  6971.  
  6972.         cmp.b    #$9b,0(a2)        ; SI code
  6973.         bne    110$
  6974.  
  6975.         cmp.b    #'?',1(a2)        ; help
  6976.         bne.s    399$
  6977.         tst.b    getanswer(a4)
  6978.         bne.s    399$
  6979.         bsr    stoptimer
  6980.         tst.w    bottomin(a4)
  6981.         bne.s    398$
  6982.         addq.w    #1,bottomin(a4)
  6983.         bsr    getcurpos
  6984.         clr.w    ibufferlen(a4)
  6985.         clr.w    curpos(a4)
  6986.         bsr    UpdateIArea
  6987. 398$        move.w    #usetxt,d0
  6988.         bsr    putnamw
  6989.         clr.l    lastprinted(a4)
  6990.         bsr    blastout
  6991.         bra.s    420$
  6992.  
  6993. 399$        cmp.b    #'C',1(a2)        ; cursor right
  6994.         bne.s    400$
  6995.         cmp.w    ibufferlen(a4),d4
  6996.         bge.s    420$
  6997.         addq.w    #1,d4
  6998. 421$        move.w    d4,curpos(a4)
  6999. 420$        bra    100$
  7000.  
  7001. 400$        cmp.b    #'D',1(a2)        ; cursor left
  7002.         bne.s    401$
  7003.         subq.w    #1,d4
  7004.         bpl.s    421$
  7005.         bra.s    420$
  7006.  
  7007. 401$        cmp.b    #' ',1(a2)
  7008.         bne.s    402$
  7009.         cmp.b    #'@',2(a2)        ; shift right
  7010.         bne.s    403$
  7011.  
  7012. 404$        cmp.w    ibufferlen(a4),d4
  7013.         bge.s    421$
  7014.         addq.w    #1,d4
  7015.         cmp.b    #' ',0(a1,d4.w)
  7016.         bne.s    404$
  7017. 405$        cmp.w    ibufferlen(a4),d4
  7018.         bge.s    421$
  7019.         addq.w    #1,d4
  7020.         cmp.b    #' ',0(a1,d4.w)
  7021.         beq.s    405$
  7022.         bra.s    421$
  7023.  
  7024. 403$        cmp.b    #'A',2(a2)        ; shift left
  7025.         bne.s    420$
  7026. 406$        tst.w    d4
  7027.         beq.s    421$
  7028.         subq.w    #1,d4
  7029.         cmp.b    #' ',0(a1,d4.w)
  7030.         beq.s    406$
  7031. 407$        tst.w    d4
  7032.         beq.s    421$
  7033.         subq.w    #1,d4
  7034.         cmp.b    #' ',0(a1,d4.w)
  7035.         bne.s    407$
  7036.         addq.w    #1,d4
  7037.         bra.s    421$
  7038.  
  7039. 402$        cmp.b    #'A',1(a2)        ; cursor up
  7040.         bne.s    408$
  7041.         tst.w    bottomin(a4)
  7042.         bne.s    480$
  7043.         tst.w    curpos(a4)
  7044.         bne.s    480$
  7045.  
  7046.         clr.w    curpos(a4)
  7047.         clr.w    ibufferlen(a4)
  7048.         bsr    UpdateIArea
  7049.         bsr    clrcursor
  7050.         move.w    edline(a4),d3
  7051.         ext.l    d3
  7052.         tst.w    d3
  7053.         beq.s    481$
  7054.         subq.l    #1,d3
  7055.         cmp.l    firstline(a4),d3
  7056.         bge.s    481$
  7057.         move.l    d3,-(sp)
  7058.         subq.l    #1,firstline(a4)
  7059.         bsr    blastout
  7060.         move.l    (sp)+,d3
  7061. 481$        move.w    d3,edline(a4)
  7062.         bsr    getcurpos
  7063.         bsr    putcursor
  7064.         bra    intuiend
  7065. 480$        move.l    history(a4),a0
  7066.         tst.l    0(a0)
  7067.         beq.s    423$
  7068.         move.l    curhist(a4),a1
  7069.         cmp.l    a0,a1
  7070.         beq.s    409$
  7071.         move.l    4(a1),d0
  7072.         move.l    d0,curhist(a4)
  7073. 409$        move.l    a1,gothline(a4)
  7074.         bsr    copyhistory
  7075. 423$        bra    100$
  7076.  
  7077. 408$        cmp.b    #'B',1(a2)        ; cursor down
  7078.         bne    410$
  7079.         tst.w    bottomin(a4)
  7080.         bne.s    414$
  7081.         tst.w    curpos(a4)
  7082.         bne.s    414$
  7083.  
  7084.         clr.w    curpos(a4)
  7085.         clr.w    ibufferlen(a4)
  7086.         bsr    UpdateIArea
  7087.         bsr    clrcursor
  7088.         move.w    edline(a4),d3
  7089.         ext.l    d3
  7090.         move.l    numlines(a4),d4
  7091.         subq.l    #1,d4
  7092.         cmp.l    d4,d3
  7093.         beq.s    490$
  7094.         move.l    firstline(a4),d2
  7095.         add.w    rows(a4),d2
  7096.         subq.w    #1,d2
  7097.         addq.w    #1,d3
  7098.         cmp.w    d2,d3
  7099.         ble.s    490$
  7100.         move.l    d3,-(sp)
  7101.         addq.l    #1,firstline(a4)
  7102.         bsr    blastout
  7103.         move.l    (sp)+,d3
  7104. 490$        bra    481$
  7105. 414$        move.l    curhist(a4),d0
  7106.         beq.s    423$
  7107.         move.l    d0,a1
  7108.         move.l    0(a1),a1
  7109.         tst.l    0(a1)
  7110.         bne.s    411$
  7111.         clr.l    gothline(a4)
  7112.         clr.w    curpos(a4)
  7113.         clr.w    ibufferlen(a4)
  7114.         bra    423$
  7115. 411$        move.l    a1,curhist(a4)
  7116.         bra    409$
  7117.  
  7118. 410$        cmp.b    #'T',1(a2)        ; shift up
  7119.         bne.s    412$
  7120.         tst.w    hnum(a4)
  7121.         beq     423$
  7122.         move.l    history(a4),a1
  7123.         move.l    a1,curhist(a4)
  7124.         bra    409$
  7125.  
  7126. 412$        cmp.b    #'S',1(a2)        ; shift down
  7127.         bne.s    440$
  7128.         tst.w    hnum(a4)
  7129.         beq    423$
  7130.         move.l    history+8(a4),curhist(a4)
  7131.         bra.s    414$
  7132.  
  7133. 440$        cmp.b    #'0',1(a2)        ; function keys
  7134.         bmi    423$
  7135.         cmp.b    #'9',1(a2)
  7136.         bgt    423$
  7137.         lea    1(a2),a0
  7138.         bsr    getnum
  7139.         lea    fkeys(a4),a0
  7140. 441$        move.l    0(a0),a0
  7141.         tst.l    0(a0)
  7142.         beq    100$
  7143.         cmp.b    8(a0),d2
  7144.         bne.s    441$
  7145.         moveq    #0,d3
  7146.         move.w    curpos(a4),d4
  7147.         move.b    9(a0),d5
  7148.         ext.w    d5
  7149.         subq.w    #1,d5
  7150.         lea    10(a0),a0
  7151.         lea    inputbuffer(a4),a2
  7152.         lea    0(a2,d4.w),a2
  7153. 445$        move.b    (a0)+,d0
  7154.         cmp.b    #'^',d0
  7155.         bne.s    442$
  7156.         moveq    #1,d3
  7157.         bra.s    443$
  7158. 442$        cmp.b    #'_',d0
  7159.         bne.s     444$
  7160.         move.b    #' ',d0
  7161. 444$        move.b    d0,(a2)+
  7162.         addq.w    #1,d4
  7163. 443$        dbra    d5,445$
  7164.         move.w    d4,curpos(a4)
  7165.         cmp.w    ibufferlen(a4),d4
  7166.         ble.s    446$
  7167.         move.w    d4,ibufferlen(a4)
  7168. 446$        tst.w    d3
  7169.         beq    100$
  7170.         bra    got_fkey
  7171.  
  7172. 110$        moveq    #0,d3
  7173. 101$        move.w    curpos(a4),d4
  7174.         tst.w    d0
  7175.         beq    100$
  7176.         cmp.b    #13,0(a2,d3.w)        ; return
  7177.         beq    got_enter
  7178.  
  7179.         cmp.b    #27,0(a2,d3.w)        ; esc
  7180.         bne    799$
  7181.         tst.b    getanswer(a4)
  7182.         bne    100$
  7183.         clr.b    insmode(a4)
  7184.         clr.w    ibufferlen(a4)
  7185.         move.w    #200,curpos(a4)
  7186.         bsr    UpdateIArea
  7187.         clr.w    curpos(a4)
  7188.         tst.w    bottomin(a4)
  7189.         bne.s    700$
  7190.         addq.w    #1,bottomin(a4)
  7191.         bsr    getcurpos
  7192.         cmp.b    #5,timerstate(a4)
  7193.         bne.s    765$
  7194.         bsr    starttimer
  7195. 765$        bra    100$
  7196.  
  7197. 700$        move.b    timerio+8(a4),timerstate(a4)
  7198.         bsr    stoptimer
  7199.         moveq    #0,d0
  7200.         move.w    edline(a4),d0
  7201.         move.l    firstline(a4),d4
  7202.         cmp.w    d4,d0
  7203.         bmi.s    701$
  7204.         move.w    d4,d5
  7205.         add.w    rows(a4),d5
  7206.         cmp.w    d5,d0
  7207.         bmi.s    702$
  7208. 701$        move.w    rows(a4),d0
  7209.         lsr.w    #1,d0
  7210.         add.w    d4,d0
  7211. 702$        move.l    numlines(a4),d3
  7212.         subq.w    #1,d3
  7213.         cmp.w    d3,d0
  7214.         ble.s    703$
  7215.         move.w    d3,d0
  7216. 703$        move.w    d0,edline(a4)
  7217.         sub.w    d4,d0
  7218.         mulu    txheight(a4),d0
  7219.         add.w    firstpos(a4),d0        ; BarHeight+FontHeight !
  7220.         move.w    d0,cposy(a4)
  7221.         clr.w    bottomin(a4)
  7222.         tst.w    loffset(a4)
  7223.         beq.s    704$
  7224.         clr.w    loffset(a4)
  7225.         bsr    blastout
  7226. 704$        bra    100$
  7227.  
  7228. 799$        cmp.b    #8,0(a2,d3.w)        ; Backspace
  7229.         bne.s    114$
  7230.         tst.w    d4
  7231.         beq.s    179$
  7232.         bsr    delchar
  7233.         subq.w    #1,d4
  7234.         move.w    d4,curpos(a4)
  7235.         bra.s    179$
  7236.  
  7237. 114$        cmp.b    #127,0(a2,d3.w)        ; Del
  7238.         bne.s    150$
  7239. 178$        cmp.w    ibufferlen(a4),d4
  7240.         bge.s    179$
  7241.         addq.w    #1,d4
  7242.         bsr    delchar
  7243. 179$        bra    102$
  7244.  
  7245. 150$        cmp.b    #9,0(a2,d3.w)        ; Tab
  7246.         bne    197$
  7247.         move.w    oldpos(a4),d1
  7248.         lea    inputbuffer(a4),a2
  7249.         move.b    newtab(a4),oldtab(a4)
  7250.         beq.s    152$            ; previous tab
  7251.         clr.b    newtab(a4)
  7252.         move.w    cmdcomplen(a4),d0
  7253.         add.w    d1,d0
  7254.         lea    0(a2,d0.w),a0
  7255.         move.w    cmdcplen(a4),d0
  7256.         lea    0(a0,d0.w),a1
  7257. 151$        move.b    (a1)+,(a0)+        ; restore old cmdline
  7258.         bne.s    151$
  7259.         sub.w    d0,ibufferlen(a4)
  7260.         tst.w    curpos(a4)
  7261.         beq.s    155$
  7262.         move.w    ibufferlen(a4),curpos(a4)
  7263.         bra.s    155$            ; search next cmd
  7264.  
  7265. 152$        move.w    ibufferlen(a4),d0
  7266.         move.l    a2,a0
  7267.         bsr    tolower            ; ibuffer to lower case
  7268.         move.w    curpos(a4),d0
  7269.         move.w    d0,d1
  7270.         beq.s    1532$
  7271. 153$        cmp.b    #' ',-1(a2,d1.w)    ; search down
  7272.         beq.s    1531$
  7273.         subq.w    #1,d1
  7274.         bne.s    153$
  7275. 1531$        move.w    d1,d0
  7276. 1532$        cmp.b    #' ',0(a2,d0.w)        ; search up
  7277.         beq.s    154$
  7278.         addq.w    #1,d0
  7279.         cmp.w    ibufferlen(a4),d0
  7280.         bcs.s    1532$
  7281. 154$        sub.w    d1,d0
  7282.         move.w    d0,cmdcomplen(a4)    ; chars to cmp
  7283.         move.w    d1,oldpos(a4)        ; cmp pos (for next tab)
  7284.         clr.w    cmdcompnr(a4)
  7285. 155$        lea    0(a2,d1.w),a2
  7286.  
  7287. 156$        tst.b    newtab(a4)
  7288.         bne.s    169$            ; found a cmd
  7289.         move.w    cmdcompnr(a4),d0
  7290.         bsr    getcmdptr
  7291.         move.l    d0,a0
  7292.         move.l    a2,a1
  7293.         move.w    cmdcomplen(a4),d1
  7294.         subq.w    #1,d1
  7295. 157$        move.b    (a0)+,d0        ; comp cmd <-> ibuffer
  7296.         beq.s    163$
  7297.         cmp.b    (a1)+,d0
  7298.         bne.s    163$
  7299.         dbra    d1,157$
  7300.  
  7301.         moveq    #-1,d0
  7302. 158$        addq.w    #1,d0
  7303.         tst.b    0(a0,d0.w)
  7304.         bne.s    158$
  7305.         tst.w    d0
  7306.         beq.s    162$            ; nothing to copy !
  7307.         move.l    a1,a2
  7308. 159$        tst.b    (a2)+
  7309.         bne.s    159$
  7310. 160$        move.b    -(a2),0(a2,d0.w)
  7311.         cmp.l    a2,a1
  7312.         bcs.s    160$
  7313.         move.w    d0,-(sp)
  7314. 161$        move.b    -1(a0,d0.w),-1(a1,d0.w)
  7315.         subq.w    #1,d0
  7316.         bne.s    161$
  7317.         move.w    (sp)+,d0
  7318.         tst.w    curpos(a4)
  7319.         beq.s    162$            ; was zero
  7320.         add.w    d0,curpos(a4)
  7321. 162$        add.w    d0,ibufferlen(a4)
  7322.         move.w    ibufferlen(a4),oldibuflen(a4)
  7323.         move.w    d0,cmdcplen(a4)
  7324.         st    newtab(a4)
  7325.  
  7326. 163$        addq.w    #1,cmdcompnr(a4)    ; next cmd
  7327.         moveq    #cmdnum-1,d0
  7328.         sub.w    cmdcompnr(a4),d0
  7329.         bcc.s    156$            ; not ready
  7330.         clr.w    cmdcompnr(a4)
  7331.         tst.b    oldtab(a4)
  7332.         bne.s    156$            ; prev tab
  7333. 169$        bra    100$            ; end it
  7334.  
  7335. 197$        cmp.b    #3,0(a2,d3.w)        ; ctrl c
  7336.         bne.s    104$
  7337.         st    cbreak(a4)
  7338.  
  7339. 104$        tst.b    addlines(a4)
  7340.         bne    processnxtmsg
  7341.         cmp.b    #$18,0(a2,d3.w)        ; ctrl x
  7342.         bne.s    300$
  7343.         clr.w    ibufferlen(a4)
  7344.         clr.w    curpos(a4)
  7345.         bra.s    169$
  7346.  
  7347. 300$        cmp.b    #$b,0(a2,d3.w)        ; ctrl k
  7348.         bne.s    106$
  7349.         move.w    curpos(a4),ibufferlen(a4)
  7350.         bra.s    169$
  7351.  
  7352. 106$        move.w    #$100,d5        ; NumPad
  7353.         and.w    qualifier(a4),d5
  7354.         beq    105$
  7355.         move.l    firstline(a4),d5
  7356.  
  7357.         cmp.b    #'7',0(a2,d3.w)        ; 'Home'
  7358.         bne.s    200$
  7359.         moveq    #0,d5
  7360. 199$        cmp.l    firstline(a4),d5
  7361.         beq.s    196$
  7362.         move.l    d5,firstline(a4)
  7363.         bsr    blastout
  7364.         tst.w    bottomin(a4)
  7365.         bne.s    196$
  7366.         move.w    edline(a4),d0
  7367.         move.l    firstline(a4),d1
  7368.         cmp.w    d1,d0
  7369.         bmi.s    190$
  7370.         add.w    rows(a4),d1
  7371.         cmp.w    d1,d0
  7372.         bmi.s    192$
  7373. 190$        clr.w    curpos(a4)
  7374.         clr.w    ibufferlen(a4)
  7375.         move.w    rows(a4),d0
  7376.         lsr.w    #1,d0
  7377.         ext.l    d0
  7378.         add.l    firstline(a4),d0
  7379.         cmp.l    numlines(a4),d0
  7380.         bmi.s    191$
  7381.         move.l    numlines(a4),d0
  7382.         subq.w    #1,d0
  7383. 191$        move.w    d0,edline(a4)
  7384. 192$        bsr    getcurpos
  7385.         bsr    UpdateIArea
  7386. 196$        bra    100$
  7387.  
  7388. 200$        cmp.b    #'8',0(a2,d3.w)        ; 'up arrow'
  7389.         bne.s    201$
  7390.         tst.w    d5
  7391.         beq    100$
  7392.         subq.w    #1,d5
  7393. 1990$        bra.s    199$
  7394.  
  7395. 201$        cmp.b    #'9',0(a2,d3.w)        ; 'PgUp'
  7396.         bne.s    203$
  7397.         sub.w    rows(a4),d5
  7398.         bpl.s    1990$
  7399.         moveq    #0,d5
  7400.         bra.s    1990$
  7401.  
  7402. 203$        cmp.b    #'1',0(a2,d3.w)        ; 'End'
  7403.         bne.s    205$
  7404. 222$        move.l    numlines(a4),d5
  7405.         sub.w    rows(a4),d5
  7406.         bpl    199$
  7407.         moveq    #0,d5
  7408. 204$        bra    199$
  7409.  
  7410. 205$        cmp.b    #'2',0(a2,d3.w)        ; 'down arrow'
  7411.         bne.s    206$
  7412.         move.l    d5,d2
  7413.         add.w    rows(a4),d2
  7414.         cmp.l    numlines(a4),d2
  7415.         bge    100$
  7416.         addq.w    #1,d5
  7417.         bra    199$
  7418.  
  7419. 206$        cmp.b    #'3',0(a2,d3.w)        ; 'PgDn'
  7420.         bne.s    500$
  7421.         add.w    rows(a4),d5
  7422.         move.l    d5,d2
  7423.         add.w    rows(a4),d2
  7424.         cmp.l    numlines(a4),d2
  7425.         bge.s    222$
  7426.         bra    199$
  7427.  
  7428. 500$        cmp.b    #'4',0(a2,d3.w)        ; left arrow
  7429.         bne.s    501$
  7430.         tst.w    bottomin(a4)
  7431.         beq    102$
  7432.         move.w    loffset(a4),d2
  7433.         sub.w    colms(a4),d2
  7434.         bpl.s    502$
  7435.         moveq    #0,d2
  7436. 502$        move.w    d2,loffset(a4)
  7437.         bsr    blastout
  7438.         bra    100$
  7439.  
  7440. 501$        cmp.b    #'6',0(a2,d3.w)        ; right arrow
  7441.         bne.s    170$
  7442.         tst.w    bottomin(a4)
  7443.         beq.s    102$
  7444.         move.w    loffset(a4),d2
  7445.         add.w    colms(a4),d2
  7446.         bra.s    502$
  7447.  
  7448. 170$        cmp.b    #'0',0(a2,d3.w)        ; Ins
  7449.         bne.s    177$
  7450.         not.b    insmode(a4)
  7451.         bra.s    102$
  7452.  
  7453. 177$        cmp.b    #'.',0(a2,d3.w)        ; Del
  7454.         beq    178$
  7455. 105$        tst.w    bottomin(a4)
  7456.         bne.s    777$
  7457.         tst.w    curpos(a4)
  7458.         bne.s    777$
  7459.         movem.l    d0/d1,-(sp)
  7460.         move.w    edline(a4),d0
  7461.         bsr    findline
  7462.         movem.l    (sp)+,d0/d1
  7463.         tst.l    8(a5)
  7464.         beq    intuiend
  7465. 777$        move.w    curpos(a4),d5
  7466.         ext.l    d5
  7467.         moveq    #79+40,d2
  7468.         cmp.w    d2,d5
  7469.         bge.s    102$
  7470.         tst.b    insmode(a4)
  7471.         beq.s    172$
  7472.         cmp.w    ibufferlen(a4),d5
  7473.         bmi.s    171$
  7474.         bra.s    173$
  7475. 172$        sub.w    d5,d2
  7476.         lea    80+40(a1),a5
  7477.         lea    79+40(a1),a3
  7478. 103$        move.b    -(a3),-(a5)
  7479.         dbra    d2,103$
  7480. 173$        addq.w    #1,ibufferlen(a4)
  7481. 171$        move.b    0(a2,d3),0(a1,d5)
  7482.         addq.w    #1,curpos(a4)
  7483. 102$        subq.w    #1,d0
  7484.         addq.w    #1,d3
  7485.         bra    101$
  7486.  
  7487. 100$        bsr    UpdateIArea
  7488.         bra    intuiend
  7489.  
  7490. got_enter    bsr    puthist
  7491. got_fkey    bsr    stoptimer
  7492.         clr.b    insmode(a4)
  7493.         lea    dummy(a4),a1
  7494.         lea    inputbuffer(a4),a2
  7495.         move.w    ibufferlen(a4),d2
  7496.         beq.s    2$
  7497.         tst.w    bottomin(a4)
  7498.         bne.s    5$
  7499.         movem.l    a1/a2,-(sp)
  7500.         move.w    edline(a4),d0
  7501.         bsr    findline
  7502.         move.l    8(a5),d0
  7503.         bsr    gthex
  7504.         lea    hexarea(a4),a0
  7505.         lea    0(a2,d2.w),a1
  7506.         move.b    #' ',(a1)+
  7507.         move.b    #'$',(a1)+
  7508.         moveq    #8,d0
  7509.         CALL    CopyMem,sysbase(a4)
  7510.         moveq    #10,d2
  7511.         add.w    ibufferlen(a4),d2
  7512.         move.w    d2,ibufferlen(a4)
  7513.         movem.l    (sp)+,a1/a2
  7514. 5$        subq.w    #1,d2
  7515. 1$        move.b    (a2)+,(a1)+
  7516.         dbra    d2,1$
  7517. 2$        move.b    #10,(a1)+
  7518.         move.w    ibufferlen(a4),d0
  7519.         addq.w    #1,d0
  7520.         move.w    d0,-(sp)
  7521.         clr.w    ibufferlen(a4)
  7522.         tst.w    bottomin(a4)
  7523.         bne.s    4$
  7524.         move.w    #100,curpos(a4)
  7525.         bsr    UpdateIArea
  7526. 4$        clr.w    curpos(a4)
  7527.         move.w    #1,bottomin(a4)
  7528.         bsr    getcurpos
  7529.         bsr    UpdateIArea
  7530.         move.w    (sp)+,d0        ; needed for cli
  7531.         move.w    d0,repeatlen(a4)
  7532.         clr.b    repeat(a4)
  7533.         clr.b    printed(a4)
  7534.         tst.b    getanswer(a4)
  7535.         bne.s    rintui
  7536. 6$        bsr    cli
  7537.         tst.b    printed(a4)
  7538.         bne.s    intuiend
  7539.         bsr    starttimer
  7540. intuiend    bsr.s    replyintui
  7541.         move.w    ibufferlen(a4),d0
  7542.         cmp.w    oldibuflen(a4),d0
  7543.         beq.s    1$            ; nothing changed
  7544.         clr.b    newtab(a4)
  7545. 1$        bra    nextimsg
  7546.  
  7547. processnxtmsg    tst.b    addlines(a4)
  7548.         bne.s    rintui
  7549.         tst.b    propupdate(a4)
  7550.         beq.s    1$
  7551.         clr.b    propupdate(a4)
  7552.         tst.b    propgadon(a4)
  7553.         beq.s    1$
  7554.         bsr.s    setprop
  7555. 1$        bra    processmsgs
  7556.  
  7557. replyintui    move.l    intuimsg(a4),d0
  7558.         beq.s    rintui
  7559.         move.l    d0,a1
  7560.         CALL    ReplyMsg,sysbase(a4)
  7561.         clr.l    intuimsg(a4)
  7562. rintui        rts
  7563.  
  7564. ; propgadget code
  7565. setprop        btst.w    #8,propinfo(a4)        ; update slider position and size
  7566.         bne.s    setprop-2
  7567.         moveq    #0,d0
  7568.         CALL    LockIBase,intuibase(a4)
  7569.         move.l    d0,a0
  7570.         move.l    wnptr(a4),a1        ; see if the user hit the
  7571.                         ; scrollbar in the meantime
  7572.         move.l    86(a1),a1        ; wn->UserPort
  7573.         lea    20(a1),a1        ; Userport->MsgList
  7574.         moveq    #$20,d1
  7575. 5$        move.l    0(a1),a1
  7576.         move.l    0(a1),d2        ; more pending messages ?
  7577.         beq.s    6$
  7578.         cmp.l    20(a1),d1        ; gadgetdown ?
  7579.         bne.s    5$
  7580.         move.l    28(a1),a2
  7581.         cmp.w    #3,38(a2)        ; scrollbar ?
  7582.         bne.s    5$
  7583.  
  7584. 6$        RECALL    UnlockIBase        ; a0=ilock
  7585.         tst.l    d2            ; used as flag (see above)!
  7586.         bne.s    4$
  7587.  
  7588. 7$        move.l    numlines(a4),d5
  7589.         moveq    #-1,d4            ; VertBody = rows*MAXBODY/numlines
  7590.         move.w    rows(a4),d3
  7591.         cmp.w    d5,d3
  7592.         bge.s    1$
  7593.         move.w    d3,d4
  7594.         mulu    #$ffff,d4
  7595.         divu    d5,d4
  7596.  
  7597. 1$
  7598. ;        moveq     #0,d2            ; VertPot = firstline*MAXPOT/(numlines-rows)
  7599.         sub.w    d3,d5
  7600.         ble.s    2$
  7601.         move.l    firstline(a4),d2
  7602.         mulu    #$ffff,d2
  7603.         divu    d5,d2
  7604.  
  7605. 2$        cmp.w    propinfo+8(a4),d4    ; did something change ?
  7606.         bne.s    3$
  7607.         cmp.w    propinfo+4(a4),d2
  7608.         beq.s    4$
  7609.  
  7610. 3$        moveq    #1|4,d0
  7611.         moveq    #0,d1
  7612.         moveq    #-1,d3
  7613.         moveq    #1,d5
  7614.         lea    sbgadget(a4),a0
  7615.         move.l    wnptr(a4),a1
  7616.         suba.l    a2,a2
  7617.         RECALL    NewModifyProp
  7618. 4$        rts
  7619.  
  7620. proppos        move.w    propinfo+4(a4),d0    ; get slider position and
  7621.         move.l    numlines(a4),d1        ; update window if necessary
  7622.         sub.w    rows(a4),d1
  7623.         ble.s    1$
  7624.         moveq    #0,d3            ; firstline=VertPot/(MAXPOT/numlines-rows)
  7625.         not.w    d3
  7626.         divu    d1,d3
  7627.         divu    d3,d0
  7628.         ext.l    d0
  7629.         cmp.l    firstline(a4),d0
  7630.         beq.s    1$
  7631.         move.l    d0,firstline(a4)
  7632.         bsr    blastout        ; update screem
  7633. 1$        rts
  7634.  
  7635. ;put an input line into the history buffer
  7636. puthist        move.w    ibufferlen(a4),d5
  7637.         move.l    d5,d0
  7638.         cmp.w    minnumchars(a4),d0
  7639.         bcs.s    1$
  7640.         move.l    gothline(a4),d1
  7641.         beq.s    5$
  7642.         move.l    d1,a2
  7643.         cmp.w    8(a2),d5
  7644.         bne.s    5$
  7645.         lea    10(a2),a2
  7646.         lea    inputbuffer(a4),a1
  7647.         subq.w    #1,d0
  7648. 6$        cmp.b    (a2)+,(a1)+
  7649.         bne.s    5$
  7650.         dbra    d0,6$
  7651.         move.l  gothline(a4),curhist(a4)
  7652.         bra.s    1$
  7653.  
  7654. 5$        moveq    #10,d0
  7655.         add.w    d5,d0
  7656.         ext.l    d0
  7657.         moveq    #1,d1
  7658.         swap    d1            ; MEMF_CLEAR
  7659.         CALL    AllocMem,sysbase(a4)
  7660.         move.l    d0,a0
  7661.         move.l    a0,d0
  7662.         beq.s    1$
  7663.         move.w    d5,8(a0)
  7664.         lea    10(a0),a2
  7665.         subq.w    #1,d5
  7666.         lea    inputbuffer(a4),a1
  7667. 2$        move.b    (a1)+,(a2)+
  7668.         dbra    d5,2$
  7669.         move.w    hnum(a4),d5
  7670.         cmp.w    maxhlines(a4),d5
  7671.         bmi.s    3$
  7672.         bsr    remhistline
  7673.         bra.s    4$
  7674. 3$        addq.w    #1,d5
  7675.         move.w    d5,hnum(a4)
  7676. 4$        move.l    d0,a1
  7677.         move.l    d0,curhist(a4)
  7678.         lea    history(a4),a0
  7679.         CALL    AddTail,sysbase(a4)
  7680. 1$        clr.l    gothline(a4)
  7681.         rts
  7682.  
  7683. ;copy a history line into the input buffer
  7684. copyhistory    lea    inputbuffer(a4),a0
  7685.         move.w    8(a1),d3
  7686.         ext.l    d3
  7687.         move.w    d3,curpos(a4)
  7688.         move.w    d3,ibufferlen(a4)
  7689.         subq.w    #1,d3
  7690.         lea    10(a1),a1
  7691. 1$        move.b    (a1)+,(a0)+
  7692.         dbra    d3,1$
  7693.         rts
  7694.  
  7695. ;remove one line from the history buffer
  7696. ;pointer to the line in A1, returns pointer to the next line in d1
  7697. remhistline    move.l    d0,-(sp)
  7698.         lea     history(a4),a0
  7699.         move.l    0(a0),a5
  7700.         tst.l    0(a5)
  7701.         beq.s    1$
  7702.         CALL    RemHead,sysbase(a4)
  7703.         move.l    a5,a1
  7704.         moveq    #10,d0
  7705.         add.w    8(a1),d0
  7706.         ext.l    d0
  7707.         RECALL    FreeMem
  7708. 1$        move.l    (sp)+,d0
  7709.         rts
  7710.  
  7711. ;kill all history lines
  7712. killhistory    bsr    remhistline
  7713.         move.l    history(a4),a0
  7714.         tst.l    0(a0)
  7715.         bne.s    killhistory
  7716. 2$        clr.w    hnum(a4)
  7717.         clr.l    curhist(a4)
  7718.         rts
  7719.  
  7720. ;delete one char from the input line
  7721. delchar        lea    inputbuffer(a4),a3
  7722.         lea     0(a3,d4.w),a3
  7723.         lea     -1(a3),a5
  7724.         move.w    d4,d5
  7725. 1$        cmp.w    #78+40,d5
  7726.         bge.s    2$
  7727.         move.b    (a3)+,(a5)+
  7728.         addq.w    #1,d5
  7729.         bra.s    1$
  7730. 2$        subq.w    #1,ibufferlen(a4)
  7731.         rts
  7732.  
  7733. testsig        move.l    tasksigs(a4),d0
  7734.         btst    d1,d0
  7735.         rts
  7736.  
  7737. ;Update the current position of the input line
  7738. getcurpos    moveq    #0,d3
  7739.         move.w    ipos(a4),d3
  7740.         tst.w    bottomin(a4)
  7741.         bne.s    1$
  7742.         move.w    edline(a4),d3
  7743.         sub.l    firstline(a4),d3
  7744.         mulu    txheight(a4),d3
  7745.         add.w    firstpos(a4),d3        ; BarHeight+FontHeight !
  7746. 1$        move.w    d3,cposy(a4)
  7747.         rts
  7748.  
  7749. ;rebuild the window from scratch
  7750. setupscreen    move.l    rastport(a4),a1
  7751.         moveq    #0,d0
  7752.         CALL    SetRast,gfxbase(a4)
  7753.         move.l    intuibase(a4),a6
  7754.         moveq    #1,d0
  7755.         bsr    setnewprop        ; does a RefreshWindowFrame()
  7756.         bsr    getwindowsize
  7757.         tst.w    bottomin(a4)
  7758.         bne.s    1$
  7759.         move.w    edline(a4),d0
  7760.         move.l    firstline(a4),d1
  7761.         move.w    rows(a4),d2
  7762.         move.w    d2,d4
  7763.         move.w    numlines(a4),d3
  7764.         add.w    d1,d2
  7765.         cmp.w    d2,d0
  7766.         bmi.s    2$
  7767.         lsr.w    #1,d4
  7768.         sub.w    d4,d0
  7769.         ext.l    d0
  7770.         move.l    d0,firstline(a4)
  7771. 2$        bsr    tstfirstlin
  7772. 1$        bsr.s    getcurpos
  7773.         bsr    putiline
  7774.         bsr    blastout
  7775.         bsr.s    UpdateIArea
  7776.         move.w    rows(a4),currenty(a4)
  7777.         rts
  7778.  
  7779. ;refresh the input area
  7780. UpdateIArea    movem.l    a2/a6,-(sp)        ; to change !
  7781.         move.l    rastport(a4),a2
  7782.         move.l    gfxbase(a4),a6
  7783.         moveq    #1,d0
  7784.         move.l    a2,a1
  7785.         RECALL    SetAPen
  7786.         moveq    #1,d0
  7787.         move.l    a2,a1
  7788.         RECALL    SetDrMd
  7789.         moveq    #2,d0
  7790.         add.b    bleft(a4),d0
  7791.         move.w    cposy(a4),d1
  7792.         move.l    a2,a1
  7793.         RECALL    Move
  7794.         lea    inputbuffer(a4),a0
  7795.         move.w    ibufferlen(a4),d0
  7796.         ext.l    d0
  7797.         move.w    colms(a4),d1
  7798.         sub.w    bottomin(a4),d1
  7799.         cmp.w    d1,d0
  7800.         bmi.s    1$
  7801.         move.w    d1,d0
  7802. 1$        move.w    d0,d2
  7803.         move.l    a2,a1
  7804.         RECALL    Text
  7805.         tst.w    bottomin(a4)
  7806.         bne.s    3$
  7807.         move.w    edline(a4),d0
  7808.         bsr    findline
  7809.         move.w    12(a5),d3
  7810.         sub.w    d2,d3
  7811.         bmi.s    3$
  7812.         move.w    colms(a4),d1
  7813.         sub.w    d2,d1
  7814.         bmi.s    2$
  7815.         cmp.w    d1,d3
  7816.         ble.s    4$
  7817.         move.w    d1,d3
  7818. 4$        move.w    d3,d0
  7819.         lea    14(a5,d2.w),a0
  7820.         move.l    a2,a1
  7821.         RECALL    Text
  7822.         add.w    ibufferlen(a4),d3
  7823.         move.w    d3,d2
  7824. 3$        move.w    colms(a4),d0
  7825.         sub.w    bottomin(a4),d0
  7826.         move.l    blanks(a4),a0
  7827.         ext.l    d0
  7828.         sub.w    d2,d0
  7829.         bmi.s    2$
  7830.         lea    0(a0,d2.w),a0
  7831.         move.l    a2,a1
  7832.         RECALL    Text
  7833. 2$        bsr.s    putcursor
  7834.         movem.l    (sp)+,a2/a6
  7835.         rts
  7836.  
  7837. clrcursor    moveq    #1,d7
  7838.         bra.s    ptc1
  7839. putcursor    moveq    #1+2+4,d7
  7840. ptc1        move.w    colms(a4),d0
  7841.         sub.w    bottomin(a4),d0
  7842.         subq.w    #1,d0
  7843.         cmp.w    curpos(a4),d0
  7844.         bmi.s    1$
  7845.         move.l    d7,d0
  7846.         move.l    rastport(a4),a1
  7847.         CALL    SetDrMd,gfxbase(a4)
  7848.         moveq    #0,d0
  7849.         move.w    curpos(a4),d0
  7850.         mulu    txwidth(a4),d0
  7851.         moveq    #2,d1
  7852.         add.b    bleft(a4),d1
  7853.         add.w    d1,d0
  7854.         move.w    cposy(a4),d1
  7855.         move.l    rastport(a4),a1
  7856.         RECALL    Move
  7857.         moveq    #1,d0
  7858.         lea    oneblank(a4),a0
  7859.         move.l    rastport(a4),a1
  7860.         RECALL    Text
  7861. 1$        rts
  7862.  
  7863. putiline    movem.l    d2/d3/a2,-(sp)
  7864.         move.l    rastport(a4),a2
  7865.         move.l    wnptr(a4),a5
  7866.         move.l    gfxbase(a4),a6
  7867.         moveq    #1,d0
  7868.         move.l    a2,a1
  7869.         RECALL    SetDrMd
  7870.         moveq    #1,d0
  7871.         move.w    ipos(a4),d2
  7872.         sub.w    txheight(a4),d2
  7873.         moveq    #0,d3            ; counter
  7874.         tst.b    ownscreen(a4)
  7875.         bne.s    2$
  7876.         tst.b    post_V34(a4)
  7877.         beq.s    2$
  7878.         moveq    #1,d3            ; counter
  7879. 2$        move.l    a2,a1
  7880.         RECALL    SetAPen
  7881.         moveq    #0,d0
  7882.         add.b    54(a5),d0
  7883.         move.w    d2,d1
  7884.         move.l    a2,a1
  7885.         RECALL    Move
  7886.         move.w    8(a5),d0
  7887.         tst.b    post_V34(a4)
  7888.         beq.s    1$            ; to the end
  7889.         moveq    #0,d1
  7890.         move.b    56(a5),d1
  7891.         sub.w    d1,d0
  7892. 1$        move.w    d2,d1
  7893.         move.l    a2,a1
  7894.         RECALL    Draw
  7895.         subq.w    #1,d2
  7896.         moveq    #2,d0
  7897.         dbra    d3,2$
  7898.         movem.l    (sp)+,d2/d3/a2
  7899.         rts
  7900.  
  7901. readline    moveq    #'n',d0
  7902.         tst.l    infile(a4)
  7903.         bne.s    1$
  7904.         move.l    #31000,firstline(a4)
  7905.         bsr    blastout
  7906.         st    getanswer(a4)
  7907.         bsr    replyintui
  7908. 5$        bsr    processmsgs
  7909.         move.w    d0,d5
  7910.         bsr    replyintui
  7911.         subq.w    #1,d5
  7912.         beq.s    5$
  7913.         clr.b    getanswer(a4)
  7914.         bsr.s    RestoreOutput
  7915.         moveq    #$20,d0
  7916.         or.b    inputbuffer(a4),d0        ; lower case
  7917. 1$        rts
  7918.  
  7919. ResumeOutput    move.l    outchain(a4),d0
  7920.         move.l    d0,a1
  7921.         beq.s    2$
  7922.         move.l    numlines(a4),oldnumlines(a4)
  7923.         move.l    firstline(a4),oldfirstline(a4)
  7924. 4$        tst.l    0(a1)
  7925.         beq.s    3$
  7926.         move.l    0(a1),a1
  7927.         bra.s    4$
  7928. 3$        move.l    a1,lastprinted(a4)
  7929. 2$        move.l    a1,oldpageend(a4)
  7930.         rts
  7931.  
  7932. RestoreOutput    move.l    oldpageend(a4),d3
  7933.         beq.s    1$
  7934.         move.l    oldnumlines(a4),numlines(a4)
  7935.         move.l    oldfirstline(a4),firstline(a4)
  7936.         move.l    oldlastprinted(a4),lastprinted(a4)
  7937.         move.l    d3,a1
  7938.         move.l    0(a1),a1
  7939.         bsr    killlines
  7940.         move.l    d3,a1
  7941.         clr.l    0(a1)
  7942.         bsr.s    blastout
  7943. 1$        rts
  7944.  
  7945. ;kill the remainder of the output buffer
  7946. killlines    move.l    (a1),-(sp)
  7947.         moveq    #14,d0
  7948.         add.w    12(a1),d0
  7949.         CALL    FreeMem,sysbase(a4)
  7950.         move.l    (sp)+,d1
  7951.         move.l    d1,a1
  7952.         bne.s    killlines
  7953.         rts
  7954.  
  7955. ;Kill output buffer
  7956. killpage    movem.l    d0-d7/a0-a6,-(sp)
  7957.         tst.l    outchain(a4)
  7958.         beq.s    2$
  7959.         move.l    outchain(a4),a1
  7960.         bsr.s    killlines
  7961.         clr.l    outchain(a4)
  7962.         clr.l    lastprinted(a4)
  7963.         clr.l    numlines(a4)
  7964.         clr.w    maxllength(a4)
  7965. 2$        movem.l    (sp)+,d0-d7/a0-a6
  7966.         rts
  7967.  
  7968. ;write a portion of the output buffer to the screen
  7969. blastout    move.l    rastport(a4),a1
  7970.         moveq    #1,d0
  7971.         CALL    SetAPen,gfxbase(a4)
  7972.         move.l    rastport(a4),a1
  7973.         moveq    #1,d0
  7974.         CALL    SetDrMd,gfxbase(a4)
  7975.         moveq    #0,d7
  7976.  
  7977.         move.w    loffset(a4),d2
  7978.         beq.s    7$
  7979.         move.w    colms(a4),d4
  7980.         add.w    d4,d2
  7981.         move.w    maxllength(a4),d3
  7982.         cmp.w    d3,d2
  7983.         ble.s    7$
  7984.         move.w    d3,d2
  7985.         sub.w    d4,d2
  7986.         bpl.s    8$
  7987.         moveq    #0,d2
  7988. 8$        move.w    d2,loffset(a4)
  7989.  
  7990. 7$        bsr.s    tstfirstlin
  7991.  
  7992. 1$        tst.l    outchain(a4)
  7993.         beq.s    3$
  7994.         bsr.s    findline
  7995.  
  7996. 2$        move.w    colms(a4),d5
  7997.         ext.l    d5
  7998.         move.w    loffset(a4),d4
  7999.         ext.l    d4
  8000.         move.w    firstpos(a4),d6        ; BarHeight+FontHeight !
  8001.  
  8002. 6$        lea    14(a5,d4.w),a0
  8003.         move.w    12(a5),d3
  8004.         ext.l    d3
  8005.         bsr.s    blastline
  8006.         blt.s    9$
  8007.         move.w    rows(a4),currenty(a4)
  8008.         bra.s    5$
  8009. 9$        tst.l    0(a5)
  8010.         beq.s    5$
  8011.         move.l    0(a5),a5
  8012.         bra.s    6$
  8013. 5$        cmp.w    rows(a4),d7
  8014.         bcc.s    3$
  8015. 10$        moveq    #0,d3
  8016.         bsr.s    blastline
  8017.         bcs.s    10$
  8018. 3$        st    propupdate(a4)
  8019.         rts
  8020.  
  8021. ;get a pointer to a line  (line # in d0)
  8022. findline    move.l    outchain(a4),d1
  8023.         beq.s    2$
  8024.         move.l    d1,a5
  8025. 1$        tst.w    d0
  8026.         beq.s    2$
  8027.         tst.l    0(a5)
  8028.         beq.s    2$
  8029.         move.l    0(a5),a5
  8030.         dbra    d0,1$
  8031. 2$        rts
  8032.  
  8033. ;check if the display is as 'full' as possible
  8034. tstfirstlin    move.l    firstline(a4),d0
  8035.         move.l    d0,d2
  8036.         add.w    rows(a4),d2
  8037.         cmp.l    numlines(a4),d2
  8038.         bmi.s    1$
  8039.         move.l    numlines(a4),d2
  8040.         sub.w    rows(a4),d2
  8041.         bpl.s    4$
  8042.         moveq    #0,d2
  8043. 4$        move.l    d2,d0
  8044.         move.l    d2,firstline(a4)
  8045. 1$        rts
  8046.  
  8047. ;display one line, fill the gap between the end of the line and
  8048. ;the end of the window with spaces.
  8049. ;d6=ypos, d5=colms, d3=linelength, d7=line # in window, a0=text
  8050.  
  8051. blastline    move.l    gfxbase(a4),a6
  8052.         moveq    #2,d0
  8053.         add.b    bleft(a4),d0
  8054.         move.w    d6,d1
  8055.         move.l    rastport(a4),a1
  8056.         RECALL    Move
  8057.         sub.w    d4,d3
  8058.         bpl.s    7$
  8059.         moveq    #0,d3
  8060.         bra.s    6$
  8061. 7$        cmp.w    d5,d3
  8062.         bmi.s    4$
  8063.         move.w    d5,d3
  8064. 4$        move.l    d3,d0
  8065.         beq.s    6$
  8066.         move.l    rastport(a4),a1
  8067.         RECALL    Text
  8068. 6$        move.l    d5,d0
  8069.         sub.l    d3,d0
  8070.         ble.s    5$
  8071.         move.l    blanks(a4),a0
  8072.         move.l    rastport(a4),a1
  8073.         RECALL    Text
  8074. 5$        add.w    txheight(a4),d6
  8075.         addq.w    #1,d7
  8076.         cmp.w    rows(a4),d7
  8077.         rts
  8078.  
  8079. addline        movem.l    d0-d6/a0-a3,-(sp)
  8080.         move.l    gfxbase(a4),a6
  8081.         move.l    rastport(a4),a1
  8082.         moveq    #1,d0
  8083.         RECALL    SetAPen
  8084.         move.l    rastport(a4),a1
  8085.         moveq    #1,d0
  8086.         RECALL    SetDrMd
  8087.         move.w    currenty(a4),d6
  8088.         cmp.w    rows(a4),d6
  8089.         bmi.s    1$
  8090.         bsr.s    cls
  8091. 1$        moveq    #0,d7
  8092.         move.w    currenty(a4),d7
  8093.         move.l    d7,d6
  8094.         mulu    txheight(a4),d6
  8095.         add.w    firstpos(a4),d6        ; BarHeight+FontHeight !
  8096.         move.w    colms(a4),d5
  8097.         moveq    #0,d4
  8098.         move.l    lastprinted(a4),a0
  8099.         move.w    12(a0),d3
  8100.         lea    14(a0),a0
  8101.         bsr    blastline
  8102.         addq.w    #1,currenty(a4)
  8103.         move.l    #31000,firstline(a4)
  8104.         movem.l    (sp)+,d0-d6/a0-a3
  8105.         rts
  8106.  
  8107. cls        movem.l d0-d6/a0-a3,-(sp)
  8108.         move.l    gfxbase(a4),a6
  8109.         moveq    #1,d0
  8110.         move.l    rastport(a4),a1
  8111.         RECALL    SetAPen
  8112.         moveq    #1,d0
  8113.         move.l    rastport(a4),a1
  8114.         RECALL    SetDrMd
  8115.         move.w    colms(a4),d5
  8116.         moveq    #0,d2
  8117. 1$        move.w    d5,d7
  8118.         move.l    d2,d6
  8119.         mulu    txheight(a4),d6
  8120.         add.w    firstpos(a4),d6        ; BarHeight+FontHeight !
  8121.         moveq    #0,d3
  8122.         move.l    blanks(a4),a0
  8123.         bsr    blastline
  8124.         addq.w    #1,d2
  8125.         cmp.w    rows(a4),d2
  8126.         bcs.s    1$
  8127.         clr.w    currenty(a4)
  8128.         movem.l    (sp)+,d0-d6/a0-a3
  8129.         rts
  8130.  
  8131. createscreen    lea    buffer(a4),a2
  8132.         moveq    #80,d0
  8133.         moveq    #1,d1
  8134.         move.l    a2,a0
  8135.         sub.l    a1,a1
  8136.         RECALL    GetScreenData
  8137.         move.w    12(a2),nssize(a4)    ; width
  8138.         move.w    76(a2),nsviewmode(a4)
  8139.         tst.b    post_V34(a4)
  8140.         beq.s    1$
  8141.         suba.l    a0,a0            ; examine default pubscreen
  8142.         RECALL    LockPubScreen
  8143.         move.l    d0,a2
  8144.         move.l    a2,d0
  8145.         beq.s    1$
  8146.         move.l    a6,-(sp)
  8147.         lea    44(a2),a0
  8148.         CALL    GetVPModeID,gfxbase(a4)    ; for DisplayID !
  8149.         move.l    (sp)+,a6
  8150.         move.l    d0,nsdisplay+4(a4)
  8151.         suba.l    a0,a0
  8152.         move.l    a2,a1
  8153.         RECALL    UnlockPubScreen
  8154. 1$        lea    newscreen(a4),a0    ; Kick 2.0+ with ens_Extension
  8155.         RECALL    OpenScreen
  8156.         move.l    d0,screenptr(a4)
  8157.         move.l    d0,nwscreen(a4)
  8158.         beq.s    setupwindow
  8159.         move.l    d0,a0
  8160.         clr.l    newwindow(a4)
  8161.         move.l    12(a0),newwindow+4(a4)
  8162.         move.w    #$474,nwflgs+2(a4)    ; IDCMP
  8163.         move.l    #$11940,nwflgs+4(a4)    ; Flags
  8164.         move.w    #$f,nwtype(a4)
  8165.         st    ownscreen(a4)
  8166.         tst.b    post_V34(a4)
  8167.         beq.s    setupwindow
  8168.         moveq    #0,d0
  8169.         RECALL    PubScreenStatus        ; make screen public
  8170.  
  8171. setupwindow    tst.b    ownscreen(a4)
  8172.         bne.s    3$            ; don't setup wb window values
  8173.         move.l    window_l(a4),newwindow(a4)
  8174.         move.l    window_w(a4),newwindow+4(a4)
  8175.         move.w    #$676,nwflgs+2(a4)    ; IDCMP
  8176.         move.l    #$5104f,nwflgs+4(a4)    ; $40000 - WFLG_NW_EXTENDED
  8177.         move.w    #1,nwtype(a4)
  8178. 3$        lea    newwindow(a4),a0
  8179.         RECALL    OpenWindow        ; Kick 2.0+ with enw_Extension
  8180.         move.l    d0,wnptr(a4)
  8181.         beq    stopall            ; no window !!!
  8182.         move.l    d0,a0
  8183.         move.l    50(a0),rastport(a4)    ; wn->RPort
  8184.         move.l    86(a0),a1        ; wn->UserPort
  8185.         moveq    #0,d1
  8186.         move.b    15(a1),d1        ; MsgPort->SigBit
  8187.         move.w    d1,intuisig(a4)
  8188.  
  8189.         tst.b    ownscreen(a4)
  8190.         bne.s    2$
  8191.         tst.b    iconifyon(a4)
  8192.         beq.s    2$
  8193.         tst.b    post_V34(a4)
  8194.         bne.s    2$
  8195.         lea    iconifgad(a4),a1    ; a0 - still wnptr !
  8196.         moveq    #0,d0
  8197.         RECALL    AddGadget
  8198.  
  8199. 2$        bsr    setwintitle
  8200.         bsr    setreqfont        ; set requested font
  8201.         moveq    #0,d0
  8202.         bsr.s    setnewprop
  8203.  
  8204.         move.l    wnptr(a4),a0
  8205.         move.l    46(a0),a0        ; our scr ptr
  8206.         cmp.l    60(a6),a0        ; ib_FirstScreen
  8207.         beq.s    1$            ; our screen is frontmost
  8208.         RECALL    ScreenToFront
  8209.  
  8210. 1$        bsr    getcurpos
  8211.         bsr    putiline
  8212.         bsr    UpdateIArea
  8213.         bsr    starttimer
  8214.         bsr    showwhat
  8215.         rts
  8216.  
  8217. setnewprop    tst.b    propgadon(a4)        ; resize propgadget !
  8218.         beq.s    1$
  8219.         move.l    wnptr(a4),a0
  8220.         lea    sbgadget(a4),a1
  8221.         tst.w    d0
  8222.         beq.s    3$            ; no gadget !
  8223.         movem.l    a0/a1,-(sp)
  8224.         RECALL    RemoveGadget        ; remove gadget from window
  8225.         movem.l    (sp)+,a0/a1
  8226. 3$        move.w    txheight(a4),d0
  8227.         move.w    firstpos(a4),d1 
  8228.         sub.w    d0,d1            ; barheight:=firstpos-txheight
  8229.         addq.w    #1,d1
  8230.         move.w    d1,6(a1)        ; topedge
  8231.         add.w    d0,d1
  8232.         lsr.w    #1,d0
  8233.         add.b    57(a0),d0
  8234.         add.w    d0,d1            ; +FontHeight*1.5
  8235.         neg.w    d1
  8236.         move.w    d1,10(a1)        ; height
  8237.         moveq    #14,d1
  8238.         move.b    56(a0),d0
  8239.         beq.s    2$            ; use default value
  8240.         move.b    d0,d1
  8241. 2$        subq.w    #2,d1
  8242.         move.w    d1,8(a1)        ; with
  8243.         neg.w    d1
  8244.         move.w    d1,4(a1)        ; leftedge
  8245.         moveq    #0,d0
  8246.         RECALL    AddGadget
  8247. 1$        move.l    wnptr(a4),a0
  8248.         jmp    _LVORefreshWindowFrame(a6)
  8249.  
  8250. setreqfont    move.l    a6,-(sp)
  8251.         move.l    gfxbase(a4),a6
  8252.         tst.b    topaz(a4)        ; use 'old' system font ?
  8253.         beq.s    3$
  8254.         move.l    topazfont(a4),d0    ; already open ?
  8255.         bne.s    2$
  8256.         lea    tattr(a4),a0        ; try topaz/8
  8257.         RECALL    OpenFont
  8258.         move.l    d0,topazfont(a4)    ; got ?
  8259.         bne.s    2$
  8260. 3$        move.l    ownfont(a4),d0        ; own 'my' font ?
  8261.         bne.s    2$
  8262.         move.l    154(a6),d0        ; GfxBase->DefaultFont
  8263. 2$        move.l    d0,a0
  8264.         move.l    rastport(a4),a1
  8265.         RECALL    SetFont
  8266.         move.l    wnptr(a4),a0
  8267.         move.l    46(a0),a1        ; Window->Screen
  8268.         move.b    30(a1),d1        ; Screen->BarHeight
  8269.         ext.w    d1
  8270.         move.b    54(a0),bleft(a4)
  8271.         move.l    50(a0),a1        ; Window->RastPort
  8272.         move.w    58(a1),txheight(a4)
  8273.         move.w    60(a1),txwidth(a4)
  8274.         add.w    txheight(a4),d1
  8275.         move.w    d1,firstpos(a4)
  8276.         bsr.s    getwindowsize
  8277. 1$        move.l    (sp)+,a6
  8278.         rts
  8279.  
  8280. getwindowsize    bsr.s    freeblank
  8281.  
  8282.         move.l    wnptr(a4),a0
  8283.  
  8284.         move.w    txheight(a4),d0
  8285.         lsr.w    #1,d0            ; FontHeight*0.5
  8286.         add.b    57(a0),d0
  8287.         neg.w    d0
  8288.         add.w    10(a0),d0
  8289.         move.w    d0,ipos(a4)        ; input area position
  8290.  
  8291.         moveq    #0,d6
  8292.         move.w    txheight(a4),d6
  8293.         lsr.w    #1,d6
  8294.         add.w    firstpos(a4),d6
  8295.         neg.w    d6
  8296.         add.w    d0,d6            ; rows=(ipos-firstpos-0.5*txheight)/txheight
  8297.         divu    txheight(a4),d6
  8298.         move.w    d6,rows(a4)
  8299.  
  8300.         moveq    #0,d6
  8301.         move.b    54(a0),d6
  8302.         add.b    56(a0),d6
  8303.         bne.s    3$
  8304.         tst.b    propgadon(a4)
  8305.         beq.s    3$
  8306.         move.w    sbgadget+8(a4),d6
  8307. 3$        addq.w    #4,d6
  8308.         neg.w    d6
  8309.         add.w    8(a0),d6
  8310.         divu    txwidth(a4),d6        ; colms=(width-lborder-rborder)/txwidth
  8311.         move.w    d6,colms(a4)
  8312.  
  8313.         moveq    #0,d0
  8314.         move.w    d6,d0
  8315.         moveq    #0,d1
  8316.         CALL    AllocMem,sysbase(a4)
  8317.         move.l    d0,blanks(a4)
  8318.         move.l    d0,a0
  8319.         moveq    #' ',d0
  8320.         bra.s    1$
  8321. 2$        move.b    d0,(a0)+
  8322. 1$        dbra    d6,2$
  8323.         rts
  8324.  
  8325. freeblank    move.l    blanks(a4),d0
  8326.         beq.s    1$
  8327.         move.l    d0,a1
  8328.         moveq    #0,d0
  8329.         move.w    colms(a4),d0
  8330.         CALL    FreeMem,sysbase(a4)
  8331.         clr.l    blanks(a4)
  8332. 1$        rts
  8333.  
  8334. setwintitle    lea    winkeybuf(a4),a3    ; show hotkey in window title
  8335.         lea    defhotkey(a4),a2
  8336.         move.l    broker(a4),d0
  8337.         beq.s    2$            ; no commodity !
  8338.         move.l    d0,a0
  8339.         moveq    #0,d0
  8340.         tst.b    cxstate(a4)
  8341.         beq.s    4$            ; commodity off
  8342.         moveq    #1,d0
  8343.         lea    hotkeybuf(a4),a2
  8344. 4$        CALL    ActivateCxObj,cxbase(a4)
  8345. 3$        move.l    (a2),d1
  8346.         and.l    #$dfdfdfdf,d1
  8347.         cmp.l    #'RAWK',d1
  8348.         bne.s    2$            ; not rawkey as ieclass
  8349.         addq.l    #7,a2            ; skip ieclass (hopefully)
  8350. 2$        move.l    a2,-(sp)
  8351.         pea    copyright(a4)
  8352.         pea    verstring(a4)
  8353.         move.l    sp,a1
  8354.         lea    namefmt(a4),a0
  8355.         lea    sc_put(pc),a2
  8356.         CALL    RawDoFmt,sysbase(a4)    ; fill buffer
  8357.         lea    12(sp),sp
  8358.         move.l    wnptr(a4),a0
  8359.         move.l    a3,a1
  8360.         movea.w    #-1,a2
  8361.         tst.b    ownscreen(a4)
  8362.         beq.s    1$            ; don't change scr title
  8363.         suba.l    a1,a1
  8364.         move.l    a3,a2
  8365. 1$        move.l    intuibase(a4),a6
  8366.         jmp    _LVOSetWindowTitles(a6)    ; leave with intuibase in a6 !
  8367.  
  8368. sc_put        move.b    d0,(a3)+        ; for RawDoFmt()
  8369.         rts
  8370.  
  8371. usetopaz    lea    topaz(a4),a2
  8372.         bsr    onoff
  8373. usetopaz2    tst.l    infile(a4)
  8374.         bne.s    usetopaz-2        ; hack !
  8375.         bsr    setreqfont
  8376.         bra    setupscreen        ; rebuild all
  8377.  
  8378. usescreen    tst.b    ownscreen(a4)
  8379.         bne.s    1$
  8380.         tst.l    infile(a4)
  8381.         bne.s    2$
  8382.         moveq    #0,d0
  8383.         bsr.s    CloseGUI        ; close window
  8384.         bra    createscreen
  8385. 2$        st    ownscreen(a4)
  8386. 1$        rts
  8387.  
  8388. usewindow    tst.b    ownscreen(a4)
  8389.         beq.s    1$
  8390.         tst.l    infile(a4)
  8391.         bne.s    2$
  8392.         st    wantwindow(a4)
  8393.         moveq    #0,d0
  8394.         bsr.s    CloseGUI        ; close window & screen
  8395.         beq.s    1$            ; pubscreen still used
  8396.         clr.b    wantwindow(a4)
  8397. 2$        clr.b    ownscreen(a4)
  8398.         tst.l    infile(a4)
  8399.         bne.s    1$
  8400.         bsr    setupwindow        ; open our window
  8401. 1$        rts
  8402.  
  8403. CloseGUI    move.l    d0,d2
  8404.         bsr    replyintui        ; answer msg
  8405.         move.l    intuibase(a4),a6
  8406.         tst.b    ownscreen(a4)
  8407.         beq.s    8$
  8408.         bsr.s    SetPubStatus
  8409.         beq.s    1$            ; pubscreen still used
  8410. 8$        move.l    wnptr(a4),d0
  8411.         beq.s    6$
  8412.         move.l    d0,a0
  8413.         tst.b    ownscreen(a4)
  8414.         bne.s    7$
  8415.         move.l    4(a0),window_l(a4)
  8416.         move.l    8(a0),window_w(a4)
  8417. 7$        RECALL    CloseWindow
  8418.         clr.l    wnptr(a4)
  8419. 6$        move.l    screenptr(a4),d0
  8420.         beq.s    5$
  8421.         move.l    d0,a0
  8422.         RECALL    CloseScreen
  8423.         clr.l    screenptr(a4)
  8424. 5$        move.l    d2,d0
  8425.         beq.s    2$            ; don't close fonts
  8426.         move.l    ownfont(a4),a1
  8427.         bsr.s    3$            ; close font
  8428.         move.l    topazfont(a4),a1
  8429. 3$        move.l    a1,d1
  8430.         beq.s    2$            ; oops, no font
  8431.         move.l    a6,-(sp)
  8432.         CALL    CloseFont,gfxbase(a4)
  8433.         move.l    (sp)+,a6
  8434. 2$        moveq    #1,d0
  8435. 1$        rts
  8436.  
  8437. SetPubStatus    moveq    #1,d0
  8438.         tst.b    post_V34(a4)        ; no Kick 2.0+
  8439.         beq.s    1$
  8440.         move.l    screenptr(a4),d1
  8441.         beq.s    1$
  8442.         move.l    d1,a0            ; d0 - already one !!!
  8443.         move.l    intuibase(a4),a6
  8444.         RECALL    PubScreenStatus        ; make screen private
  8445.         tst.l    d0
  8446.         bne.s    1$
  8447.         tst.b    waitexit(a4)
  8448.         beq.s    1$            ; don't wait
  8449.         moveq    #0,d0
  8450.         move.w    nspubsig+6(a4),d1
  8451.         bset    d1,d0
  8452.         CALL    Wait,sysbase(a4)    ; wait until last win closed
  8453.         bra.s    SetPubStatus
  8454. 1$        tst.l    d0
  8455.         rts
  8456.  
  8457. ; support functions
  8458.  
  8459. CreatePort    movem.l    d2-d4/a2/a3/a6,-(sp)
  8460.         move.l    d0,d2            ; port-pri
  8461.         move.l    a0,d3            ; portname
  8462.         moveq    #-1,d0
  8463.         CALL    AllocSignal,sysbase(a4)
  8464.         move.l    d0,d4
  8465.         addq.l    #1,d0
  8466.         beq.s    crp4
  8467.         moveq    #34,d0
  8468.         move.l    #$10001,d1        ; MEMF_CLEAR|MEMF_PUBLIC
  8469.         RECALL    AllocMem
  8470.         movea.l    d0,a2
  8471.         move.l    a2,d0
  8472.         bne.s    crp1
  8473.         move.l    d4,d0
  8474.         RECALL    FreeSignal
  8475.         bra.s    crp3
  8476. crp1        lea    8(a2),a3
  8477.         move.b    #4,(a3)+        ; mp_Node.ln_Type=NT_MSGPORT
  8478.         move.b    d2,(a3)+        ; mp_Node.ln_Pri
  8479.         move.l    d3,(a3)+        ; mp_Node.ln_Name
  8480.         move.w    d4,(a3)+        ; mp_SigBit
  8481.         move.l    mytask(a4),(a3)+    ; mp_SigTask
  8482.         tst.l    d3
  8483.         beq.s    crp2
  8484.         movea.l    a2,a1
  8485.         RECALL    AddPort
  8486.         bra.s    crp3
  8487. crp2        move.l    a3,(a3)            ; mp_MsgList.Node.ln_Head
  8488.         addq.l    #4,(a3)
  8489.         move.l    a3,8(a3)        ; mp_MsgList.Node.ln_Pred
  8490. crp3        move.l    a2,d0            ; MsgPort
  8491. crp4        movem.l    (sp)+,d2-d4/a2/a3/a6
  8492.         rts
  8493.  
  8494. DeletePort    move.l    a2,-(sp)
  8495.         move.l    sysbase(a4),a6
  8496.         movea.l    d0,a2            ; port
  8497.         tst.l    10(a2)
  8498.         beq.s    dep1
  8499.         movea.l    a2,a1
  8500.         RECALL    RemPort
  8501. dep1        moveq    #-1,d0            ; Port unbrauchbar
  8502.         move.b    d0,8(a2)        ; machen
  8503.         move.l    d0,20(a2)
  8504.         moveq    #0,d0
  8505.         move.b    15(a2),d0
  8506.         RECALL    FreeSignal
  8507.         movea.l    a2,a1
  8508.         moveq    #34,d0
  8509.         RECALL    FreeMem
  8510.         move.l    (sp)+,a2
  8511.         rts
  8512.  
  8513. CreateStdIO    move.l    d2,-(sp)
  8514.         move.l    d0,d2            ; reply-port
  8515.         beq.s    csio1
  8516.         moveq    #48,d0
  8517.         move.l    #$10001,d1        ; MEMF_CLEAR|MEMF_PUBLIC
  8518.         CALL    AllocMem,sysbase(a4)
  8519.         movea.l    d0,a0
  8520.         move.l    a0,d0
  8521.         beq.s    csio1
  8522.         move.b    #5,8(a0)        ; NT_MESSAGE
  8523.         move.l    d2,14(a0)        ; ReplyPort
  8524. csio1        move.l    (sp)+,d2
  8525.         rts
  8526.  
  8527. DeleteStdIO    movea.l    d0,a1            ; io-block
  8528.         moveq    #-1,d0
  8529.         move.b    d0,8(a1)
  8530.         move.l    d0,20(a1)
  8531.         move.l    d0,24(a1)
  8532.         moveq    #48,d0
  8533.         CALL    FreeMem,sysbase(a4)
  8534.         rts
  8535.  
  8536. CreateTask    movem.l    d2-d5/a2/a3/a6,-(sp)
  8537.         link    a5,#-32
  8538.         addq.l    #3,d0
  8539.         moveq    #-4,d2
  8540.         and.l    d0,d2            ; stack adjusted
  8541.         move.l    d1,d3            ; pri
  8542.         move.l    a0,d4            ; name
  8543.         move.l    a1,d5            ; code
  8544.         lea    MemList(pc),a0
  8545.         move.l    sp,a1
  8546.         moveq    #6,d0
  8547. crt1        move.l    (a0)+,(a1)+        ; copy memlist
  8548.         dbra    d0,crt1
  8549.         move.l    d2,(a1)
  8550.         move.l    sp,a0
  8551.         CALL    AllocEntry,sysbase(a4)    ; alloc memory
  8552.         movea.l    d0,a2
  8553.         move.l    a2,d0
  8554.         beq.s    crt2
  8555.         move.l    16(a2),a3
  8556.         move.b    #1,8(a3)        ; ln_Type
  8557.         move.b    d3,9(a3)        ; ln_Pri
  8558.         move.l    d4,10(a3)        ; ln_Name
  8559.         move.l    24(a2),d0
  8560.         add.l    d0,d2
  8561.         move.l    d2,54(a3)        ; tc_SPReg
  8562.         move.l    d0,58(a3)        ; tc_SPLower
  8563.         move.l    d2,62(a3)        ; tc_SPUpper
  8564.         lea    74(a3),a0        ; tc_MemList
  8565.         move.l    a0,(a0)
  8566.         addq.l    #4,(a0)
  8567.         move.l    a0,8(a0)
  8568.         move.l    a2,a1
  8569.         RECALL    AddHead            ; store memlist
  8570.         move.l    a3,a1
  8571.         move.l    a1,d3
  8572.         move.l    d5,a2
  8573.         suba.l    a3,a3
  8574.         RECALL    AddTask            ; start task
  8575.         move.l    d3,d0
  8576. crt2        unlk    a5
  8577.         movem.l    (sp)+,d2-d5/a2/a3/a6
  8578.         rts
  8579.  
  8580. MemList        dc.l    0,0            ; Succ,Pred
  8581.         dc.b    0,0            ; Pri,Type
  8582.         dc.l    0            ; Name
  8583.         dc.w    2            ; NumEntries
  8584.         dc.l    $10001            ; MemType
  8585.         dc.l    92            ; Length
  8586.         dc.l    $10000            ; MemType
  8587. ;        dc.l    0            ; Length
  8588.  
  8589. killidle    bra.s    killidle
  8590.  
  8591.         cnop    0,4
  8592.  
  8593. ; data area
  8594.  
  8595. StpList        dc.l    *+4            ; frozen tasks list
  8596.         dc.l    0
  8597.         dc.l    StpList
  8598.  
  8599. FKeys        dc.l    *+4            ; function keys list
  8600.         dc.l    0
  8601.         dc.l    FKeys
  8602.  
  8603. History        dc.l    *+4            ; history lines list
  8604.         dc.l    0
  8605.         dc.l    History
  8606. CurHist        dc.l    0
  8607.  
  8608. NewBroker    dc.b    5,0            ; nb_Version, pad
  8609.         dc.l    NewName            ; nb_Name
  8610.         dc.l    VerString        ; nb_Title
  8611.         dc.l    Description        ; nb_Descr
  8612.         dc.w    1+2            ; nb_Unique = NBU_UNIQUE!NBU_NOTIFY
  8613.         dc.w    4            ; nb_Flags = COF_SHOW_HIDE
  8614.         dc.b    0,0             ; nb_Pri, pad
  8615.         dc.l    0            ; nb_Port
  8616.         dc.w    0            ; nb_ReservedChannel
  8617.  
  8618. InInterrupt    dc.l    0            ; ln_Succ
  8619.         dc.l    0            ; ln_Pred
  8620.         dc.b    2            ; ln_Type
  8621.         dc.b    60            ; ln_Pri
  8622.         dc.l    XopSleep        ; ln_Name
  8623.         dc.l    0            ; is_Data
  8624.         dc.l    keyhandler        ; is_Code()
  8625.  
  8626. IoCounter    dc.l    0            ; ln_Succ
  8627.         dc.l    0            ; ln_Pred
  8628.         dc.b    2            ; ln_Type
  8629.         dc.b    -1            ; ln_Pri
  8630.         dc.l    IOcntName        ; ln_Name
  8631.         dc.l    0            ; is_Data
  8632.         dc.l    countio            ; is_Code()
  8633.  
  8634. TAttr        dc.l    FontName
  8635.         dc.w    8
  8636.         dc.b    0,0
  8637.  
  8638. Window_l    dc.w    -550,1            ; initial window position
  8639. Window_w    dc.w    550,199
  8640.  
  8641. NewWindow    dc.w    0,0,0,0
  8642.         dc.b    0,1
  8643. NwFlgs        dc.l    0
  8644.         dc.l    0
  8645.         dc.l    0
  8646.         dc.l    0
  8647.         dc.l    0            ; title
  8648. NwScreen    dc.l    0
  8649.         dc.l    0
  8650.         dc.w    110,50
  8651.         dc.w    -1,-1
  8652. NwType        dc.w    0
  8653.         dc.l    NewWinTags        ; APTR enw_Extension
  8654.  
  8655. NewWinTags    dc.l    $80000090,1        ; WA_AutoAdjust,TRUE
  8656.         dc.l    0
  8657.  
  8658. NewScreen    dc.w    0,0
  8659. NsSize        dc.w    0,-1            ; ???,STDSCREENHEIGHT
  8660.         dc.w    1
  8661.         dc.b    0
  8662.         dc.b    1
  8663. NsViewMode    dc.w    0
  8664.         dc.w    $101f            ; $1000 - NS_EXTENDED
  8665.         dc.l    0
  8666.         dc.l    0            ; title
  8667.         dc.l    0,0
  8668.         dc.l    NewScrTags        ; APTR ens_Extension
  8669.  
  8670. NewScrTags    dc.l    $80000023,-1        ; SA_Width,STDSCREENWIDTH
  8671. NsAScroll    dc.l    $80000039,1        ; SA_AutoScroll,TRUE
  8672. NsDisplay    dc.l    $80000032,0        ; SA_DisplayID
  8673. NsPubName    dc.l    $8000002f,NewName    ; SA_PubName
  8674. NsPubSig    dc.l    $80000030,0        ; SA_PubSig
  8675. NsPubTask    dc.l    $80000031,0        ; SA_PubTask
  8676.          dc.l    0            ; TAG_DONE
  8677.  
  8678. IcnWindow    dc.w    40,170,72,28        ; sleep window
  8679.         dc.b    0,1
  8680.         dc.l    $20,$10800
  8681.         dc.l    Gadget,0,0,0,0
  8682.         dc.w    72,28,72,28
  8683.         dc.w    1
  8684.  
  8685. AppObj        dc.w    0,0            ; contains gadget
  8686.  
  8687. Gadget        dc.l    0
  8688.         dc.w    0,0,72,28,4,2,$20
  8689.         dc.l    Image
  8690.         dc.l    0,0,0,0
  8691.         dc.w    0
  8692.         dc.l    0
  8693.  
  8694.         dc.w    0
  8695.         dc.l    0,0
  8696.         dc.l    $80000000,$80000000
  8697.         dc.l    0,0,0
  8698.  
  8699. Image        dc.w    0,0,72,28
  8700.         dc.w    2
  8701.         dc.l    ImageData
  8702.         dc.b    3,0
  8703.         dc.l    0
  8704.  
  8705. IconifGad    dc.l    0            ; zip gadget for Kick 1.3
  8706.         dc.w    -83,0
  8707.         dc.w    31,10
  8708.         dc.w    $14,$41,1
  8709.         dc.l    IconImg
  8710.         dc.l    0,0,0,0
  8711.         dc.w    0
  8712.         dc.l    0
  8713. IconImg        dc.w    0,0,31,10
  8714.         dc.w    2
  8715.         dc.l    IconifData
  8716.         dc.b    3,0
  8717.         dc.l    0
  8718.  
  8719. SBGadget    dc.l    0            ; prop gadget
  8720.         dc.w    -14,11
  8721.         dc.w    14,-22
  8722.         dc.w    $10|$40
  8723.         dc.w    1|2|8|16
  8724.         dc.w    3
  8725.         dc.l    SBData,0,0,0,PropInfo
  8726.         dc.w    3
  8727.         dc.l    0
  8728. PropInfo    dc.w    1|4
  8729.         dc.w    0,0
  8730.         dc.w    -1,-1
  8731.         dc.w    0,0,0,0,0,0
  8732. SBData        dc.l    0,0,0,0
  8733.  
  8734. HexTab        dc.b    '0123456789abcdef'
  8735.  
  8736. Params        dc.b    'tfdlrempiscua'
  8737. parmnum        equ    *-Params
  8738. .parmnum    dc.b    0
  8739.  
  8740. cmdnum        set    0
  8741. Commds         ADDCMD    'time'            ; all commands we know
  8742.         ADDCMD    'taskpri'
  8743.         ADDCMD    'info'
  8744.         ADDCMD    'pri'
  8745.         ADDCMD    'flush'
  8746.         ADDCMD    'freeze'
  8747.         ADDCMD    'warm'
  8748.         ADDCMD    'signal'
  8749.         ADDCMD    'break'
  8750.         ADDCMD    'alert'
  8751.         ADDCMD    'lastalert'
  8752.         ADDCMD    'hold'
  8753.         ADDCMD    'exit'
  8754.         ADDCMD    'clear'
  8755.         ADDCMD    'cancel'
  8756.         ADDCMD    'taskports'
  8757.         ADDCMD    'hunks'
  8758.         ADDCMD    'devices'
  8759.         ADDCMD    'openlib'
  8760.         ADDCMD    'closelib'
  8761.         ADDCMD    'currentdir'
  8762.         ADDCMD    'cd'
  8763.         ADDCMD    'mypri'
  8764.         ADDCMD    'files'
  8765.         ADDCMD    'locks'
  8766.         ADDCMD    'unlock'
  8767.         ADDCMD    'screens'
  8768.         ADDCMD    'windows'
  8769.         ADDCMD    'closescreen'
  8770.         ADDCMD    'closewindow'
  8771.         ADDCMD    'fonts'
  8772.         ADDCMD    'windowfonts'
  8773.         ADDCMD    'lockdrive'
  8774.         ADDCMD    'freedrive'
  8775.         ADDCMD    'capture'
  8776.         ADDCMD    'clrcold'
  8777.         ADDCMD    'clrcool'
  8778.         ADDCMD    'clrwarm'
  8779.         ADDCMD    'snoopmem'
  8780.         ADDCMD    'usage'
  8781.         ADDCMD    'inputhandler'
  8782.         ADDCMD    'header'
  8783.         ADDCMD    'sort'
  8784.         ADDCMD    'hide'
  8785.         ADDCMD    'hidden'
  8786.         ADDCMD    'window'
  8787.         ADDCMD    'kill'
  8788.         ADDCMD    'iconify'
  8789.         ADDCMD    'historylines'
  8790.         ADDCMD    'minimumchars'
  8791.         ADDCMD    'showhistory'
  8792.         ADDCMD    'repeat'
  8793.         ADDCMD    'remresident'
  8794.         ADDCMD    'saveoutput'
  8795.         ADDCMD    'killhistory'
  8796.         ADDCMD    'backdropicon'
  8797.         ADDCMD    'myfont'
  8798.         ADDCMD    'setfont'
  8799.         ADDCMD    'trapguru'
  8800.         ADDCMD    'outputlines'
  8801.         ADDCMD    'usescreen'
  8802.         ADDCMD    'usewindow'
  8803.         ADDCMD    'usetopaz'
  8804.         ADDCMD    'timerio'
  8805.         ADDCMD    'diskchange'
  8806.         ADDCMD    'alias'
  8807.         ADDCMD    'remnode'
  8808.         ADDCMD    'setfkey'
  8809.         ADDCMD    'clicmd'
  8810.         ADDCMD    'taskinfo'
  8811.         ADDCMD    'coldreboot'
  8812.         ADDCMD    'reboot'
  8813.         ADDCMD    'zerotimer'
  8814.         ADDCMD    'propgad'
  8815.         ADDCMD    'iconpos'
  8816.         ADDCMD    'remport'
  8817.         ADDCMD    'remintserver'
  8818.         ADDCMD    'frags'
  8819.         ADDCMD    'traceopen'
  8820.         ADDCMD    'tracelock'
  8821.         ADDCMD    'cxhandler'
  8822.         ADDCMD    'popkey'
  8823.         ADDCMD    'pubscreens'
  8824.         ADDCMD    'smartpatch'
  8825.         ADDCMD    'lowmemhandler'
  8826.  
  8827.         IFNE    ((tasktime-cmdaddr)/4)-cmdnum
  8828.         ERROR    !! COMMAND NAME OR JUMP VECTOR MISSING !!
  8829.         ENDC
  8830.  
  8831. NewName        dc.b    'Xoper'
  8832. NoName        dc.b    0
  8833. XopCon        dc.b    'XopPackets',0
  8834. XopSleep    dc.b    'Xop-A-A-x',0
  8835. MemPortName    dc.b    'SnoopPort',0
  8836. IOcntName    dc.b    'Xop-I/O-Counter',0
  8837. KidleName    dc.b    'Xop-Idle-Killer',0
  8838. NameFmt        dc.b    '%s %s - <PopKey=%s>',0
  8839.         even                ; important for mc68000 !
  8840. DefHotkey    dc.b    'lcommand rcommand x',0
  8841.         dc.b    '$VER: '
  8842. VerString    VERSION
  8843. Copyright    dc.b    '© 1988/95 by W.Günther and G.Nikl',0
  8844. Description    dc.b    'A very powerful system monitor',0
  8845.  
  8846. T2Header    dc.b    '   ID     STATE  SIGALLOC SIGWAIT  SIGRECVD    PC    FPU  TASKNAME',0
  8847. T3Header    dc.b    '   ID     STATE  SIGALLOC SIGWAIT  SIGRECVD    PC    TASKNAME',0
  8848. T4Header    dc.b    '   ID     STATE    RUNNING    ACTIVE   NUM TASKNAME',0
  8849. THeader        dc.b    '   ID     TYPE      STATE   PRI  CPUSE NUM TASKNAME',0
  8850. LHeader        dc.b    '  NODE    CNT  VER  REV  FLAGS    ',0
  8851. LibNam        dc.b    'LIBRARY NAME',0
  8852. DevNam        dc.b    'DEVICE NAME',0
  8853. ResNam        dc.b    'RESOURCE NAME',0
  8854. MHeader        dc.b    ' LOWER    UPPER       FREE   ATTR  PRI HUNK NAME',0
  8855. IHeader        dc.b    '  NODE     DATA     CODE    PRI T S   TYPE     INTERRUPT NAME',0
  8856. InHeader    dc.b    '  NODE     DATA     CODE    PRI NAME',0
  8857. RHeader        dc.b    '  ADDR    PRI  FLAGS    VER   TYPE    RESIDENT NAME',0
  8858. PHeader        dc.b    '  NODE   PORTNAME         FLAGS SIGBT NUM SIGTASK',0
  8859. HunkHeader    dc.b    ' NUM  BCPL    DATA       LENGTH',0
  8860. DDHeader    dc.b    'DEVICE    HDS   SECTORS    TRACKS   BUFFERS STATE    HANDLER',0
  8861. CDHeader    dc.b    'PROCESSNAME          CURRENT DIRECTORY',0
  8862. OFHeader    dc.b    '  LOCK   ACCESS      SIZE PATH/FILENAME',0
  8863. ScrHeader    dc.b    'NUM   ADDR      SIZE   DPTH TITLE',0
  8864. MonitorID    dc.b    '    MonitorID: $',0
  8865. PScrHeader    dc.b    '  NODE   SCREENNAME         STATE CNT SBT SIGTASK',0
  8866. WnHeader    dc.b    ' ADDR    OWNERTASK     X    Y     SIZE    TITLE',0
  8867. FoHead        dc.b    '  NODE    CNT   Y    X  TYPE        LO  HI NAME',0
  8868. KickHead    dc.b    'START    END      LENGTH',0
  8869. SnoopHead    dc.b    'ACTION          REQUIREMENTS               LENGTH    FROM      TO     CALLER',0
  8870. StackHead    dc.b    'SPLower       SIZE      USED TASKNAME',0
  8871. CliComHead    dc.b    '   ID     STATE   TYPE MODE NUM PROCESSNAME       COMMAND',0
  8872. TioHead        dc.b    'IORQUEST  UNIT       SECS    REQUESTING TASK',0
  8873. DCHead        dc.b    '  NODE     DATA     CODE   UNIT TASK',0
  8874. ALHead        dc.b    'ALIAS NAME        COMMAND',0
  8875. SemHead        dc.b    '  NODE   OWNER         QUEUE NEST NAME',0
  8876. FragHead    dc.b    'HEX    SIZE    DEC     COUNT   LARGEST',0
  8877. FKHead        dc.b    'KEY  STRING',0
  8878. FilesHead    dc.b    '   TASK      HANDLE   MODE  FILENAME',0
  8879. TDDrives    dc.b    'DF : ',0
  8880. UnitMsg        dc.b    ' (Unit # )',0
  8881. TimerUnits    dc.b    'MicroHz ',0
  8882.         dc.b    'VBlank  ',0
  8883. FMode        dc.b    '  R/W  ',0
  8884. Access        dc.b    ' Read  ',0
  8885.         dc.b    ' Write ',0
  8886. RomFnt        dc.b    'Rom  ',0
  8887. DiskFnt        dc.b    'Disk ',0
  8888. FFixed        dc.b    'Fixed ',0
  8889. FProp        dc.b    'Propl ',0
  8890. Status        dc.b    'Added   ',0
  8891.         dc.b    'Running ',0
  8892.         dc.b    'Ready   ',0
  8893.         dc.b    'Waiting ',0
  8894.         dc.b    'Exeption',0
  8895.         dc.b    'Removed ',0
  8896.         dc.b    'Frozen  ',0
  8897.         dc.b    'Frozen  ',0
  8898. Type        dc.b    'Unknown   ',0
  8899. TaskType    dc.b    'Task      ',0
  8900.         dc.b    'Interrupt ',0
  8901.         dc.b    'Device    ',0
  8902.         dc.b    'Msgport   ',0
  8903.         dc.b    'Message   ',0
  8904.         dc.b    'Freemsg   ',0
  8905.         dc.b    'Replymsg  ',0
  8906.         dc.b    'Resource  ',0
  8907.         dc.b    'Library   ',0
  8908.         dc.b    'Memory    ',0
  8909. SoftIntType    dc.b    'Softint   ',0
  8910.         dc.b    'Font      ',0
  8911. ProcType    dc.b    'Process   ',0
  8912.         dc.b    'Semaphore ',0
  8913. Mp_Flags    dc.b    'Signal  ',0
  8914.         dc.b    'Softint ',0
  8915.         dc.b    'Ignore  ',0
  8916. PScr_State    dc.b    '  Public ',0
  8917.         dc.b    ' Private ',0
  8918. Infoh2        dc.b    'Dispat/Sec:',0
  8919. Infoh1        dc.b    'CPU:',0
  8920. Infoh3        dc.b    'CPU activity: ',0
  8921. Infoh6        dc.b    'Total:',0
  8922. Infoh4        dc.b    '% ',0
  8923. Infoh7        dc.b    'I/O Ints/Sec: ',0
  8924. CPU0        dc.b    '68000',0
  8925. CPU1        dc.b    '68010',0
  8926. CPU2        dc.b    '68020',0
  8927. CPU3        dc.b    '68030',0
  8928. CPU4        dc.b    '68040',0
  8929. CPU5        dc.b    '/68881',0
  8930. CPU6        dc.b    '/68882',0
  8931. NoFPU        dc.b    '---- ',0
  8932. NullState    dc.b    'NULL ',0
  8933. Idle        dc.b    'IDLE ',0
  8934. Busy        dc.b    'BUSY ',0
  8935. DontKnow    dc.b    '???? ',0
  8936. DevLoad        dc.b    'loaded   ',0
  8937. DevnLoad    dc.b    'unloaded ',0
  8938. IntEn        dc.b    'E ',0
  8939. IntDis         dc.b    'D ',0
  8940. IntServ        dc.b    'S ',0
  8941. IntHand        dc.b    'H ',0
  8942. NotFile        dc.b    '--- --------- --------- --------- ',0
  8943. LongLongNix    dc.b    '-'
  8944. LongNix        dc.b    '-----'
  8945. Nix        dc.b    '--- ',0
  8946. NoInfo        dc.b    'No Info on'
  8947. OneBlank    dc.b    ' ',0
  8948. Equal        dc.b    '=  ',0
  8949. OpenBrak    dc.b    '[ ',0
  8950. CloseBrak    dc.b    ' ]',0
  8951. NamErr        dc.b    'Unable to find ',0
  8952. FontErr        dc.b    "Can't open ",0
  8953. AdrErr        dc.b    'Address Error!',0
  8954. AliasErr    dc.b    'Single character alias names using "',0
  8955. AliasErr2    dc.b    '"',10,'are not allowed.',0
  8956. NoWorkbench    dc.b    "Workbench isn't active !",0
  8957. OpenErr        dc.b    'Could not open file ',0
  8958. ListErr        dc.b    'Unable to find ListHeader. Sort aborted.',0
  8959. WiwErr        dc.b    'Script file only',0
  8960. GuruTxt        dc.b    'Guru Meditation #',0
  8961. ClrTxt        dc.b    'Memory Hunks cleared.',0
  8962. CanErr0        dc.b    'Process is not a CLI-task',10
  8963.         dc.b    'Has it been started from Workbench ? (Y/N)',10,0
  8964. CanErr1        dc.b    'Process was created by CreateProc()',10
  8965.         dc.b    'Shall I UnLoad() ? (Y/N)',10,0
  8966. UnloadErr    dc.b    "Arrrgh.. can't find segments, aborting",0
  8967. NoProcs        dc.b    'Not a Process.',0
  8968. NotLoad        dc.b    'No program loaded.',0
  8969. CliProcs    dc.b    'CLI-Process',0
  8970. ProcLoaded    dc.b    'Loaded as a command: ',0
  8971. SegLoaded    dc.b    'Created by CreateProc()',0
  8972. ColdTxt        dc.b    'Cold Capture: ',0
  8973. CoolTxt        dc.b    'Cool Capture: ',0
  8974. WarmTxt        dc.b    'Warm Capture: ',0
  8975. KickTxt        dc.b    'KickMem     : ',0
  8976. Unset        dc.b    'unset',0
  8977. IntNames    dc.b    'Serial Out ',0
  8978.         dc.b    'Disk Block ',0
  8979.         dc.b    'SoftInt    ',0
  8980.         dc.b    'Ports      ',0
  8981.         dc.b    'Coper      ',0
  8982.         dc.b    'Vert.Blank ',0
  8983.         dc.b    'Blitter    ',0
  8984.         dc.b    'Audio Ch.0 ',0
  8985.         dc.b    'Audio Ch.1 ',0
  8986.         dc.b    'Audio Ch.2 ',0
  8987.         dc.b    'Audio Ch.3 ',0
  8988.         dc.b    'Serial In  ',0
  8989.         dc.b    'Disk Sync  ',0
  8990.         dc.b    'External   ',0
  8991.         dc.b    'SoftInt    ',0
  8992.         dc.b    'NMI        ',0
  8993. IntTyp        dc.b    0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1
  8994. MemNoExp    dc.b    'NOEXP ',0
  8995. MemRev        dc.b    'REV ',0
  8996. MemLarg        dc.b    'LARGEST ',0
  8997. MemClr        dc.b    'CLEAR ',0
  8998. MemKick        dc.b    'KICK ',0
  8999. MemDMA        dc.b    '24BIT ',0
  9000. MemLoc        dc.b    'LOCAL ',0
  9001. MemFast        dc.b    'FAST ',0
  9002. MemChip        dc.b    'CHIP ',0
  9003. MemPubl        dc.b    'PUBLIC ',0
  9004. Failed        dc.b    'Failed !',0
  9005. AllOk        dc.b    'ALLOC: ',0
  9006. Free        dc.b    'FREE: ',0
  9007. Backg        dc.b    'Bckg ',0
  9008. Foreg        dc.b    'Frgr ',0
  9009. Script        dc.b    'Batch ',0
  9010. Interact    dc.b    'Intct ',0
  9011. NameErr        dc.b    'Name or address is missing.',10
  9012. SynErr        dc.b    'Syntax Error, type "?" for help'
  9013. CR        dc.b    10,0
  9014. Dnotf        dc.b    'Directory not found',0
  9015. NotDir        dc.b    'Not a directory',0
  9016. NoMount        dc.b    ' not mounted.',0
  9017. DisHelp        dc.b    10,'Names are case sensitive and followed by a ":"',0
  9018. UnlErr        dc.b    'Lock not found',0
  9019. Unl1        dc.b    'Lock is on ',0
  9020. UnlTxt        dc.b    'Old lock was: ',0
  9021. UnlTxt2        dc.b    'Unlock ? (Y/N)',10,0
  9022. ScNoFound    dc.b    'Screen not found.',0
  9023. WinNoFound    dc.b    'Window not found.',0
  9024. StpErr        dc.b    'Task must be "READY" or "WAITING"',10,0
  9025. WaErr        dc.b    'Task must be "FROZEN"',10,0
  9026. WhatsThis    dc.b    '???.?',0
  9027. TooMuch        dc.b    '??? ',0
  9028. TimeNotSet    dc.b    ' disabled.',0
  9029. WhatTime    dc.b    'Refresh time in secs:',0
  9030. Stopped        dc.b    '<Break>',0
  9031. CapExited    dc.b    'Task ended',0
  9032. CapWait        dc.b    'Waiting for startup...',0
  9033. OnScr        dc.b    'On Screen: ',0
  9034. WhatNow        dc.b    'Kill, ignore (K/I)?',0
  9035. NoGuru        dc.b    'None found.',0
  9036. SoftFail    dc.b    'Software failure!',10,'Task: ',0
  9037. AddrsErr    dc.b    'Bad aligned address was: ',0
  9038. ProCount    dc.b    'PC: ',0
  9039. MemTyp        dc.b    'Memory type: ',0
  9040. NintrServ    dc.b    "Not a server. Can't restore vectors",0
  9041. OnStr        dc.b    'on',0
  9042. OffStr        dc.b    'off',0
  9043. UseTxt        dc.b    'DISPLAY:',10
  9044.         dc.b    '[T]asks    task[F]lags [L]ibraries  [D]evices    [R]esources',10
  9045.         dc.b    'r[E]sident [M]emory    [P]orts      [I]nterrupts [S]tack',10
  9046.         dc.b    '[C]litasks task[U]sage sem[A]phores [Q]uit',10,10
  9047.         dc.b    'OTHER SYSTEM LISTS:',10
  9048.         dc.b    'Windows  Screens  PubScreens  WindowFonts   Fonts',10
  9049.         dc.b    'Capture  TimerIO  DiskChange  InputHandler  Devices',10
  9050.         dc.b    'Locks    Files    CurrentDir  LowMemHandler Frags',10,10
  9051.         dc.b    'COMMANDS:',10
  9052.         dc.b    'Time         <secs>',10
  9053.         dc.b    'Mypri        <priority>',10
  9054.         dc.b    'Taskpri      <priority>  [processnum] <taskname>',10
  9055.         dc.b    'Signal       <mask(hex)> [processnum] <taskname>',10
  9056.         dc.b    'Break        [processnum] <taskname>',10
  9057.         dc.b    'Freeze|Warm  [processnum] <taskname>',10
  9058.         dc.b    'Kill/Cancel  [processnum] <taskname>',10
  9059.         dc.b    'SnoopMem     [processnum] <taskname>',10
  9060.         dc.b    'TraceOpen/TraceLock',10
  9061.         dc.b    'ZeroTimer    [processnum] <taskname>',10
  9062.         dc.b    'Hide         <taskname>',10
  9063.         dc.b    'Pri          <priority> <nodename>',10
  9064.         dc.b    'Info         <name>',10
  9065.         dc.b    'RemNode      <node address>',10
  9066.         dc.b    'RemPort      <port address>',10
  9067.         dc.b    'RemResident  <resident module name>',10
  9068.         dc.b    'RemIntServer <interrupt address>',10
  9069.         dc.b    'Clear        <longword(hex)>',10
  9070.         dc.b    'Hunks        [processnum] <procname>',10
  9071.         dc.b    'CD           <directory> [processnum] <procname>',10
  9072.         dc.b    'UnLock       <lock>',10
  9073.         dc.b    'OpenLib    | Closelib <libraryname>',10
  9074.         dc.b    'CloseWindow| Closescreen <title>',10
  9075.         dc.b    'MyFont       [size] <fontname> | '
  9076. DefFont        dc.b    'default',10
  9077.         dc.b    'SetFont      [size] <fontname> <windowtitle>',10
  9078.         dc.b    'LockDrive  | Freedrive   <drivename:>',10
  9079.         dc.b    'Window       <leftedge topedge width height> (scriptfile only) ',10
  9080.         dc.b    'IconPos      <leftedge topedge>',10
  9081.         dc.b    'OutputLines  <maximum # of lines>',10
  9082.         dc.b    'HistoryLines <maximum # of lines>',10
  9083.         dc.b    'MinimumChars <minimum # of characters>',10
  9084.         dc.b    'SaveOutput   <filename>',10
  9085.         dc.b    'PopKey       <description>',10
  9086.         dc.b    'Repeat       <Command line>',10
  9087.         dc.b    'SetFKey      <number> <string>',10
  9088.         dc.b    'Alias        [<aliasname> <commandname>]',10,10
  9089.         dc.b    'COMMANDS WITHOUT PARAMETERS:',10
  9090.         dc.b    'Alert      LastAlert ClrCool       ClrCold      ClrWarm',10
  9091.         dc.b    'TrapGuru   Flush     ShowHistory   KillHistory  ColdReboot',10
  9092.         dc.b    'Reboot     Hold      Exit',10,10
  9093.         dc.b    'OPTIONS:',10
  9094.         dc.b    'Sort       CLICmd    TaskInfo      TaskPorts    Hidden',10
  9095.         dc.b    'Usage      Header    UseScreen     UseWindow    UseTopaz',10
  9096.         dc.b    'PropGad    Iconify   BackDropIcon  SmartPatch   CxHandler',0
  9097. GfxName        dc.b    'graphics.library',0
  9098. IntName        dc.b    'intuition.library',0
  9099. CxName        dc.b    'commodities.library',0
  9100. WbName        dc.b    'workbench.library',0
  9101. DiskFont    dc.b    'diskfont.library',0
  9102. TdName        dc.b    'trackdisk.device',0
  9103. ConName        dc.b    'console.device',0
  9104. DeviceNam    dc.b    'input.device',0
  9105. TimerNam    dc.b    'timer.device',0
  9106. FontName    dc.b    'topaz.font',0
  9107. WbPortNam    dc.b    'Workbench',0
  9108. SetManNam    dc.b    'SetMan',0
  9109. StartupName
  9110.     IFND DEBUG
  9111.         dc.b    'ENV:Xoper.Startup',0
  9112.     ENDC
  9113.     IFD DEBUG
  9114.         dc.b    'ENV:Test.Startup',0
  9115.     ENDC
  9116.  
  9117.         cnop    0,4
  9118.  
  9119. dataarea
  9120.  
  9121. DosTable    equ    _DosTable-dataarea
  9122. StrCmp        equ    strcmp-dataarea
  9123. GetNum        equ    getnum-dataarea
  9124.  
  9125. stplist        equ    StpList-dataarea
  9126. fkeys        equ    FKeys-dataarea
  9127. history        equ    History-dataarea
  9128. curhist        equ    CurHist-dataarea
  9129.  
  9130. newbroker    equ    NewBroker-dataarea
  9131. ininterrupt    equ    InInterrupt-dataarea
  9132. iocounter    equ    IoCounter-dataarea
  9133. tattr        equ    TAttr-dataarea
  9134. window_l    equ    Window_l-dataarea
  9135. window_w    equ    Window_w-dataarea
  9136. newwindow    equ    NewWindow-dataarea
  9137. nwflgs        equ    NwFlgs-dataarea
  9138. nwscreen    equ    NwScreen-dataarea
  9139. nwtype        equ    NwType-dataarea
  9140. newscreen    equ    NewScreen-dataarea
  9141. nssize        equ    NsSize-dataarea
  9142. nsviewmode    equ    NsViewMode-dataarea
  9143. newscrtags    equ    NewScrTags-dataarea
  9144. nsdisplay    equ    NsDisplay-dataarea
  9145. nspubname    equ    NsPubName-dataarea
  9146. nspubsig    equ    NsPubSig-dataarea
  9147. nspubtask    equ    NsPubTask-dataarea
  9148.  
  9149. icnwindow    equ    IcnWindow-dataarea
  9150. appobj        equ    AppObj-dataarea
  9151. gadget        equ    Gadget-dataarea
  9152. image        equ    Image-dataarea
  9153. iconifgad    equ    IconifGad-dataarea
  9154. iconimg        equ    IconImg-dataarea
  9155.  
  9156. sbgadget    equ    SBGadget-dataarea
  9157. propinfo    equ    PropInfo-dataarea
  9158. sbdata        equ    SBData-dataarea
  9159.  
  9160. hextab        equ    HexTab-dataarea
  9161.  
  9162. params        equ    Params-dataarea
  9163.  
  9164. commds        equ    Commds-dataarea
  9165. newname        equ    NewName-dataarea
  9166. noname        equ    NoName-dataarea
  9167. xopcon        equ    XopCon-dataarea
  9168. xopsleep    equ    XopSleep-dataarea
  9169. memportname    equ    MemPortName-dataarea
  9170. IOcntname    equ    IOcntName-dataarea
  9171. kidlename    equ    KidleName-dataarea
  9172. namefmt        equ    NameFmt-dataarea
  9173. defhotkey    equ    DefHotkey-dataarea
  9174. verstring    equ    VerString-dataarea
  9175. copyright    equ    Copyright-dataarea
  9176. description    equ    Description-dataarea
  9177.  
  9178. t2header    equ    T2Header-dataarea
  9179. t3header    equ    T3Header-dataarea
  9180. t4header    equ    T4Header-dataarea
  9181. theader        equ    THeader-dataarea
  9182. lheader        equ    LHeader-dataarea
  9183. libnam        equ    LibNam-dataarea
  9184. devnam        equ    DevNam-dataarea
  9185. resnam        equ    ResNam-dataarea
  9186. mheader        equ    MHeader-dataarea
  9187. iheader        equ    IHeader-dataarea
  9188. inheader    equ    InHeader-dataarea
  9189. rheader        equ    RHeader-dataarea
  9190. pheader        equ    PHeader-dataarea
  9191. hunkheader    equ    HunkHeader-dataarea
  9192. ddheader    equ    DDHeader-dataarea
  9193. cdheader    equ    CDHeader-dataarea
  9194. ofheader    equ    OFHeader-dataarea
  9195. scrheader    equ    ScrHeader-dataarea
  9196. monitorid    equ    MonitorID-dataarea
  9197. pscrheader    equ    PScrHeader-dataarea
  9198. wnheader    equ    WnHeader-dataarea
  9199. fohead        equ    FoHead-dataarea
  9200. kickhead    equ    KickHead-dataarea
  9201. snoophead    equ    SnoopHead-dataarea
  9202. stackhead    equ    StackHead-dataarea
  9203. clicomhead    equ    CliComHead-dataarea
  9204. tiohead        equ    TioHead-dataarea
  9205. dchead        equ    DCHead-dataarea
  9206. alhead        equ    ALHead-dataarea
  9207. semhead        equ    SemHead-dataarea
  9208. fraghead    equ    FragHead-dataarea
  9209. fkhead        equ    FKHead-dataarea
  9210. fileshead    equ    FilesHead-dataarea
  9211. tddrives    equ    TDDrives-dataarea
  9212. unitmsg        equ    UnitMsg-dataarea
  9213. timerunits    equ    TimerUnits-dataarea
  9214. fmode        equ    FMode-dataarea
  9215. access        equ    Access-dataarea
  9216. romfnt        equ    RomFnt-dataarea
  9217. diskfnt        equ    DiskFnt-dataarea
  9218. ffixed        equ    FFixed-dataarea
  9219. fprop        equ    FProp-dataarea
  9220. status        equ    Status-dataarea
  9221. type        equ    Type-dataarea
  9222. tasktype    equ    TaskType-dataarea
  9223. softinttype    equ    SoftIntType-dataarea
  9224. proctype    equ    ProcType-dataarea
  9225. mp_flags    equ    Mp_Flags-dataarea
  9226. pscr_state    equ    PScr_State-dataarea
  9227. infoh2        equ    Infoh2-dataarea
  9228. infoh1        equ    Infoh1-dataarea
  9229. infoh3        equ    Infoh3-dataarea
  9230. infoh6        equ    Infoh6-dataarea
  9231. infoh4        equ    Infoh4-dataarea
  9232. infoh7        equ    Infoh7-dataarea
  9233. cpu0        equ    CPU0-dataarea
  9234. cpu1        equ    CPU1-dataarea
  9235. cpu2        equ    CPU2-dataarea
  9236. cpu3        equ    CPU3-dataarea
  9237. cpu4        equ    CPU4-dataarea
  9238. cpu5        equ    CPU5-dataarea
  9239. cpu6        equ    CPU6-dataarea
  9240. nofpu        equ    NoFPU-dataarea
  9241. nullstate    equ    NullState-dataarea
  9242. idle        equ    Idle-dataarea
  9243. busy        equ    Busy-dataarea
  9244. dontknow    equ    DontKnow-dataarea
  9245. devload        equ    DevLoad-dataarea
  9246. devnload    equ    DevnLoad-dataarea
  9247. inten        equ    IntEn-dataarea
  9248. intdis        equ    IntDis-dataarea
  9249. intserv        equ    IntServ-dataarea
  9250. inthand        equ    IntHand-dataarea
  9251. notfile        equ    NotFile-dataarea
  9252. longlongnix    equ    LongLongNix-dataarea
  9253. longnix        equ    LongNix-dataarea
  9254. nix        equ    Nix-dataarea
  9255. noinfo        equ    NoInfo-dataarea
  9256. oneblank    equ    OneBlank-dataarea
  9257. equal        equ    Equal-dataarea
  9258. openbrak    equ    OpenBrak-dataarea
  9259. closebrak    equ    CloseBrak-dataarea
  9260. namerr        equ    NameErr-dataarea
  9261. fonterr        equ    FontErr-dataarea
  9262. adrerr        equ    AdrErr-dataarea
  9263. aliaserr    equ    AliasErr-dataarea
  9264. aliaserr2    equ    AliasErr2-dataarea
  9265. noworkbench    equ    NoWorkbench-dataarea
  9266. openerr        equ    OpenErr-dataarea
  9267. listerr        equ    ListErr-dataarea
  9268. wiwerr        equ    WiwErr-dataarea
  9269. gurutxt        equ    GuruTxt-dataarea
  9270. clrtxt        equ    ClrTxt-dataarea
  9271. canerr0        equ    CanErr0-dataarea
  9272. canerr1        equ    CanErr1-dataarea
  9273. unloaderr    equ    UnloadErr-dataarea
  9274. noprocs        equ    NoProcs-dataarea
  9275. notload        equ    NotLoad-dataarea
  9276. cliprocs    equ    CliProcs-dataarea
  9277. procloaded    equ    ProcLoaded-dataarea
  9278. segloaded    equ    SegLoaded-dataarea
  9279. coldtxt        equ    ColdTxt-dataarea
  9280. cooltxt        equ    CoolTxt-dataarea
  9281. warmtxt        equ    WarmTxt-dataarea
  9282. kicktxt        equ    KickTxt-dataarea
  9283. unset        equ    Unset-dataarea
  9284. intnames    equ    IntNames-dataarea
  9285. inttyp        equ    IntTyp-dataarea
  9286.  
  9287. memnoexp    equ    MemNoExp-dataarea
  9288. memrev        equ    MemRev-dataarea
  9289. memlarg        equ    MemLarg-dataarea
  9290. memclr        equ    MemClr-dataarea
  9291. memkick        equ    MemKick-dataarea
  9292. memdma        equ    MemDMA-dataarea
  9293. memloc        equ    MemLoc-dataarea
  9294. memfast        equ    MemFast-dataarea
  9295. memchip        equ    MemChip-dataarea
  9296. mempubl        equ    MemPubl-dataarea
  9297.  
  9298. failed        equ    Failed-dataarea
  9299. allok        equ    AllOk-dataarea
  9300. free        equ    Free-dataarea
  9301. backg        equ    Backg-dataarea
  9302. foreg        equ    Foreg-dataarea
  9303. script        equ    Script-dataarea
  9304. interact    equ    Interact-dataarea
  9305. nameerr        equ    NameErr-dataarea
  9306. synerr        equ    SynErr-dataarea
  9307. cr        equ    CR-dataarea
  9308. dnotf        equ    Dnotf-dataarea
  9309. notdir        equ    NotDir-dataarea
  9310. nomount        equ    NoMount-dataarea
  9311. dishelp        equ    DisHelp-dataarea
  9312. unlerr        equ    UnlErr-dataarea
  9313. unl1        equ    Unl1-dataarea
  9314. unltxt        equ    UnlTxt-dataarea
  9315. unltxt2        equ    UnlTxt2-dataarea
  9316. scnofound    equ    ScNoFound-dataarea
  9317. winnofound    equ    WinNoFound-dataarea
  9318. stperr        equ    StpErr-dataarea
  9319. waerr        equ    WaErr-dataarea
  9320. whatsthis    equ    WhatsThis-dataarea
  9321. toomuch        equ    TooMuch-dataarea
  9322. timenotset    equ    TimeNotSet-dataarea
  9323. whattime    equ    WhatTime-dataarea
  9324. stopped        equ    Stopped-dataarea
  9325. capexited    equ    CapExited-dataarea
  9326. capwait        equ    CapWait-dataarea
  9327. onscr        equ    OnScr-dataarea
  9328. whatnow        equ    WhatNow-dataarea
  9329. noguru        equ    NoGuru-dataarea
  9330. softfail    equ    SoftFail-dataarea
  9331. addrserr    equ    AddrsErr-dataarea
  9332. procount    equ    ProCount-dataarea
  9333. memtyp        equ    MemTyp-dataarea
  9334. nintrserv    equ    NintrServ-dataarea
  9335. onstr        equ    OnStr-dataarea
  9336. offstr        equ    OffStr-dataarea
  9337. usetxt        equ    UseTxt-dataarea
  9338. gfxname        equ    GfxName-dataarea
  9339. intname        equ    IntName-dataarea
  9340. cxname        equ    CxName-dataarea
  9341. wbname        equ    WbName-dataarea
  9342. diskfont    equ    DiskFont-dataarea
  9343. tdname        equ    TdName-dataarea
  9344. conname        equ    ConName-dataarea
  9345. devicenam    equ    DeviceNam-dataarea
  9346. timernam    equ    TimerNam-dataarea
  9347. fontname    equ    FontName-dataarea
  9348. fontsuf        equ    fontname+5
  9349. wbportnam    equ    WbPortNam-dataarea
  9350. setmannam    equ    SetManNam-dataarea
  9351. deffont        equ    DefFont-dataarea
  9352. startupname    equ    StartupName-dataarea
  9353.  
  9354.         ds.b    gb_SIZEOF
  9355.  
  9356.         SECTION Images,DATA,CHIP
  9357.  
  9358. IconifData    dc.w    $7FFF,$FFFC,$601F,$FFFC,$6000,$000C,$607F,$FFCC
  9359.         dc.w    $6060,$00CC,$6067,$FCCC,$7E60,$00CC,$7E7F,$FFCC
  9360.         dc.w    $7E00,$000C,$7FFF,$FFFC,$0000,$0000,$1FE0,$0000
  9361.         dc.w    $1FFF,$FFF0,$1F80,$0030,$1F9F,$FF30,$1F98,$0330
  9362.         dc.w    $019F,$FF30,$0180,$0030,$01FF,$FFF0,$0000,$0000
  9363.  
  9364. ImageData    dc.w    $000F,$FFFF,$FFFF,$FFF8,$0000,$001F,$FFFF,$FFFF
  9365.         dc.w    $FFFC,$0000,$001F,$0000,$0000,$007C,$0000,$001F
  9366.         dc.w    $7FFF,$FFFF,$FF7C,$0000,$001F,$4A46,$0244,$557C
  9367.         dc.w    $0000,$001F,$5108,$D411,$817C,$0000,$001F,$7FFF
  9368.         dc.w    $FFFF,$FF7C,$0000,$001F,$0000,$0000,$007C,$0000
  9369.         dc.w    $001F,$30C0,$0000,$007C,$0000,$001F,$1980,$0000
  9370.         dc.w    $007C,$0000,$001F,$0F0F,$1F0F,$1F7C,$0000,$001F
  9371.         dc.w    $0619,$9999,$997C,$0000,$001F,$0F19,$999F,$987C
  9372.         dc.w    $0000,$001F,$1999,$9F18,$187C,$0000,$001F,$30CF
  9373.         dc.w    $180F,$187C,$0000,$001F,$0000,$1800,$007C,$0000
  9374.         dc.w    $001F,$0000,$0000,$007C,$0000,$001F,$FFFF,$FFFF
  9375.         dc.w    $FFFC,$0000,$000F,$FFFF,$FFFF,$FF18,$0000,$0000
  9376.         dc.w    $0000,$0000,$0000,$0000,$3FFF,$FFFF,$FFFF,$FFFF
  9377.         dc.w    $FC00,$FDFF,$FFFF,$FFFF,$FFFF,$FF00,$EBFF,$FFFF
  9378.         dc.w    $FFFF,$FFFF,$FF00,$F7FF,$FFFF,$FFFF,$F800,$0700
  9379.         dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FF00,$FFFF,$FFFF,$FFFF
  9380.         dc.w    $FFFF,$FF00,$FFFF,$FFFF,$FFFF,$FFFF,$FF00,$3FFF
  9381.         dc.w    $FFFF,$FFFF,$FFFF,$FC00,$0000,$0000,$0000,$0000
  9382.         dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$FFFF
  9383.         dc.w    $FFFF,$FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000
  9384.         dc.w    $0000,$FFFF,$FFFF,$FF80,$0000,$0000,$FFFF,$FFFF
  9385.         dc.w    $FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000,$0000
  9386.         dc.w    $FFFF,$FFFF,$FF80,$0000,$0000,$8000,$0000,$0080
  9387.         dc.w    $0000,$0000,$8000,$0000,$0080,$0000,$0000,$8000
  9388.         dc.w    $0000,$0080,$0000,$0000,$8000,$0000,$0080,$0000
  9389.         dc.w    $0000,$8000,$0000,$0080,$0000,$0000,$8000,$0000
  9390.         dc.w    $0080,$0000,$0000,$8000,$0000,$0080,$0000,$0000
  9391.         dc.w    $8000,$0000,$0080,$0000,$0000,$FFFF,$FFFF,$FF80
  9392.         dc.w    $0000,$0000,$0000,$0000,$00E0,$0000,$0000,$0000
  9393.         dc.w    $0000,$00E0,$0000,$0000,$1FFF,$FFFF,$F800,$0000
  9394.         dc.w    $0000,$0080,$0040,$0000,$0000,$0200,$0080,$0040
  9395.         dc.w    $0000,$0000,$1400,$0080,$0040,$003F,$0000,$0800
  9396.         dc.w    $0080,$0040,$07FF,$F800,$0000,$0080,$0040,$003F
  9397.         dc.w    $0000,$0000,$0080,$0040,$0000,$3800,$FFFF,$FFFF
  9398.         dc.w    $FFFF,$FFFF,$FE00,$0000,$0080,$0040,$0000,$0000
  9399.  
  9400. imagesize    equ    (((*-ImageData)>>2)-1)
  9401.  
  9402.         end
  9403.