home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff274.lzh / Xoper / Xoper.a < prev    next >
Text File  |  1989-11-16  |  142KB  |  6,236 lines

  1. ******************************************
  2. *                     *
  3. * Xoper 2.0 Copyright (C) Werner Gunther *
  4. *                     *
  5. ******************************************
  6. *    Written for the A68K Assembler     *
  7. *   (Fish 110) by Charlie Gibbs and      *
  8. *       Brian R. Anderson         *
  9. *                     *
  10. *  Do not use Smallcode/Smalldata when     *
  11. *          linking             *
  12. ******************************************
  13. ;DEBUG SET 1
  14.         XREF    _LVOSwitch
  15.         XREF    _LVOAddTask
  16.         XDEF    _SysBase
  17. sysbase     equ     4
  18.  
  19. CALL        MACRO
  20.         xref    _LVO\1
  21.         move.l  \2,a6
  22.         jsr     _LVO\1(a6)
  23.         ENDM
  24. LIBCALL     MACRO
  25.         xref    _\1
  26.         jsr     _\1
  27.         ENDM
  28.  
  29. ADDCMD        MACRO
  30. cmdnum        set     cmdnum+1
  31.         dc.b    \1,0
  32.         ENDM
  33.  
  34. ;Program startup. If called from DOS we
  35. ;use segment splitting to detach
  36. ;from our DOS-task.
  37. start        moveq   #3,d0
  38.         lea     dummyinput,a1
  39. getparm     move.b  (a0)+,(a1)+
  40.         dbf     d0,getparm
  41.         move.b  #10,in
  42.         lea     conname(PC),a1
  43.         move.l  sysbase,a0
  44.         lea     350(a0),a0
  45.         CALL    FindName,sysbase
  46.         move.l  d0,condev
  47.         lea     dosname(PC),a1
  48.         move.l  sysbase,a0
  49.         lea     378(a0),a0
  50.         move.l  a0,-(a7)
  51.         CALL    FindName,sysbase
  52.         move.l  d0,dosbase
  53.         move.l  0(a7),a0
  54.         lea     gfxname(PC),a1
  55.         CALL    FindName,sysbase
  56.         move.l  d0,gfxbase
  57.         move.l  (a7)+,a0
  58.         lea     intuiname(PC),a1
  59.         CALL    FindName,sysbase
  60.         move.l  d0,intuibase
  61.         move.l  d0,a0
  62.         move.l  $38(a0),a0
  63.         move.w  12(a0),d0
  64.         sub.w   #550,d0
  65.         move.w  d0,window_l
  66.  
  67.         move.l  sysbase,a4
  68.         move.l  276(a4),a4
  69.         tst.l   $ac(a4)
  70.         bne.s   notwb
  71.         lea     $5c(a4),a0
  72.         CALL    WaitPort,sysbase
  73.         lea     $5c(a4),a0
  74.         CALL    GetMsg,sysbase
  75.         move.l  d0,wbmsg
  76.         move.w  #$740a,in
  77. notwb:
  78.        IFND  DEBUG
  79.         lea     xopcon,a1
  80.         CALL    FindPort,sysbase
  81.         tst.l   d0
  82.         bne     oops
  83.        ENDC
  84.         tst.l   wbmsg
  85.         beq.s   fromdos
  86.         jmp     mainprg
  87.  
  88. fromdos:
  89.  
  90. starttask:
  91.  
  92.     IFND DEBUG
  93.         cmp.w   #'-b',dummyinput
  94.         bne.s   stt1
  95.         CALL    Output,dosbase
  96.         move.l  d0,-(a7)
  97.         move.l  #windowname,d2
  98.         move.l  d0,d1
  99.         moveq.l #newname-windowname-1,d3
  100.         CALL    Write,dosbase
  101.         move.l  #cr,d2
  102.         move.l  (a7)+,d1
  103.         moveq.l #1,d3
  104.         CALL    Write,dosbase
  105. stt1        lea     start(PC),a1
  106.         move.l  -4(a1),d3
  107.         move.l  d3,myseg
  108.  
  109.         move.l  #mainprg,d3
  110.         subq    #4,d3
  111.         lsr.l   #2,d3
  112.  
  113.         clr.l   -4(a1)
  114.         CALL    Forbid,sysbase
  115.         move.l  #newname,d1
  116.         clr.l   d2
  117.         move.l  #3500,d4
  118.         CALL    CreateProc,dosbase
  119.         CALL    Permit,sysbase
  120.         moveq   #0,d0
  121.         rts
  122. oops        suba.l  a0,a0
  123.         CALL    DisplayBeep,intuibase
  124.         CALL    Forbid,sysbase
  125.         move.l  wbmsg,d0
  126.         beq.s   leave
  127.         move.l  d0,a1
  128.         CALL    ReplyMsg,sysbase
  129.         moveq   #0,d0
  130. leave        rts
  131.  
  132. dosname     dc.b    'dos.library',0
  133. intuiname   dc.b    'intuition.library',0
  134. gfxname     dc.b    'graphics.library',0
  135. conname     dc.b    'console.device',0
  136.         EVEN
  137.  
  138. main        CODE    xoper
  139.     ENDC
  140. mainprg     move.l  sysbase,a0
  141.         move.l  a0,_SysBase
  142.         move.l  a7,realstack
  143.         move.l  276(a0),a0          ;ExecBase->ThisTask
  144.         move.l  a0,mytask
  145.         move.l  50(a0),oldproctrap  ;original AmigaDos Trap-Handler
  146.         move.l  #newname,10(a0)
  147.         pea     0
  148.         pea     xopcon
  149.         LIBCALL CreatePort
  150.         addq    #8,a7
  151.         move.l  d0,replyport
  152.         pea     0
  153.         pea     0
  154.         LIBCALL CreatePort
  155.         addq    #8,a7
  156.         move.l  d0,timerport
  157.         lea     timerio,a1
  158.         move.l  d0,14(a1)
  159.         move.l  d0,a2
  160.         move.b  15(a2),d0
  161.         ext.w   d0
  162.         move.w  d0,timersig
  163.         lea     timernam(PC),a0
  164.         moveq   #0,d1
  165.         moveq   #1,d0
  166.         CALL    OpenDevice,_SysBase(PC) ;open 'timer.device'
  167.  
  168. ;install a counter to determine the amount of CPU-time each
  169. ;Task uses.
  170.         move.l  _SysBase(PC),a1
  171.         move.l  #_LVOSwitch,a0
  172.         move.l  2(a1,a0),oldswitch
  173.         move.l  #myswitch,d0
  174.         CALL    SetFunction,_SysBase(PC)
  175. ;install a counter for PORT-Interrupts
  176.         lea     IOCounter(PC),a1
  177.         moveq   #3,d0
  178.         CALL    AddIntServer,_SysBase(PC)
  179.  
  180. ;Attempt to open a startup script
  181.         move.l  mytask(PC),a4      ;disable the 'please insert'
  182.         move.l  184(a4),-(a7)
  183.         move.l  #-1,184(a4)        ;requester
  184.         move.l  #startupname+2,d1  ;'Xoper.Startup'
  185.         move.l  #1005,d2
  186.         CALL    Open,dosbase(PC)
  187.         tst.l   d0
  188.         bne.s   7$
  189.         move.l  #startupname,d1    ;'S:Xoper.Startup'
  190.         move.l  #1005,d2
  191.         CALL    Open,dosbase(PC)
  192.  
  193. 7$        move.l  (a7)+,184(a4)      ;reenable the requester
  194.         move.l  d0,infile
  195.         beq.s   nostartup
  196.  
  197. 6$        move.b  #1,fromfile
  198.  
  199. 8$        lea     dummy,a5
  200.         moveq   #-1,d5
  201. 5$        addq.l  #1,d5
  202.         move.l  infile(PC),d1
  203.         move.l  a5,d2
  204.         add.l   d5,d2
  205.         moveq.l #1,d3
  206.         CALL    Read,dosbase(PC)
  207.         tst.l   d0
  208.         bgt.s   10$
  209.  
  210.         move.l  infile(PC),d1
  211.         CALL    Close,dosbase(PC)
  212.         clr.l   infile
  213.         tst     d5
  214.         beq.s   endstartup
  215.         bra.s   9$
  216.  
  217. 10$        cmp.b   #10,0(a5,d5)
  218.         beq.s   9$
  219.         cmp.b   #13,0(a5,d5)
  220.         bne.s   5$
  221.  
  222. 9$        move.l  d5,d0
  223.         addq    #1,d0
  224.         bsr     cli            ;execute the script as if typed in
  225.         tst.l   infile
  226.         bne.s   8$
  227.  
  228. endstartup  clr.b   fromfile
  229.  
  230. nostartup   tst.l   wbmsg
  231.         bne.s   noin
  232.         cmp.b   #10,dummyinput
  233.         beq.s   noin
  234.         cmp.w   #'-b',dummyinput   ;requested as a background task ?
  235.         beq.s   noin
  236.         move.l  dummyinput,in
  237.         move.b  #10,in+4
  238.         bra.s   nostartup2
  239. noin        cmp.b   #10,in
  240.         beq.s   default
  241.         tst.b   in
  242.         bne.s   nostartup2
  243.  
  244. default     move.w  #$740a,in           ;couldn't find defaults, defaults to
  245.                        ;tasks
  246.  
  247. nostartup2  cmp.w   #'-b',dummyinput
  248.         beq     instback
  249.  
  250. ;This code just opens a Window. Position
  251. ;and size are taken from window_l,window_t,
  252. ;window_w,window_h.
  253. restart     tst.b   ownscreen
  254.         beq.s   1$
  255.         bsr     createscreen
  256.         bra.s   2$
  257. 1$        bsr     setupwindow
  258.  
  259. 2$        move.l  mytask(PC),a0
  260.         clr.l   26(a0)              ;clear 'spurious' signals
  261.  
  262.         clr.l   ptr
  263.         tst.b   gotguru
  264.  
  265.         beq.s   3$
  266.         bsr     showguru
  267.         clr.b   gotguru
  268. 3$        bra     processmsgs
  269.  
  270. ;show a list. The string entered from keyboard is stored
  271. ;in 'in'.Every character is interpreted as one command
  272. ;i.e. 'rip' means 'resources'+'interrupts'+'ports'.
  273. ;search the command to be executed. If none is found,
  274. ;show a help message
  275.  
  276. showwhat    tst.b   fromfile
  277.         bne     endshow
  278.         move.w  cmdptr(PC),d7
  279.  
  280. input        lea     in,a0
  281.         move.b  0(a0,d7.w),d0
  282.         beq     endshow
  283.         addq.b  #1,d7
  284.         cmpi.b  #' ',d0
  285.         bne.s   1$
  286.  
  287.         bsr     testifend
  288.         beq     endshow
  289.         move.w  d2,cmdptr
  290.         bra     notfinished
  291.  
  292. 1$        cmpi.b  #10,d0
  293.         beq     endshow
  294.         or.b    #32,d0
  295.         cmpi.b  #'q',d0
  296.         beq     exit
  297.         lea     params(PC),a0
  298.         moveq   #0,d1
  299. i1        cmp.b   0(a0,d1),d0
  300.         beq.s   foundp
  301.         addq.b  #1,d1
  302.         cmpi.b  #parmnum,d1
  303.         bne.s   i1
  304.  
  305.         move.l  #usetxt,d0
  306.         move.b  #1,mnflag
  307.         bsr     putnam
  308.         clr.b   mnflag
  309.         bra     endshow
  310.  
  311. foundp        lsl.b   #2,d1
  312.         lea     subs(PC),a0
  313.         move.b  #1,mnflag
  314.         jsr     0(a0,d1)
  315.         clr.b   mnflag
  316.         bsr     testifend
  317.         beq     input
  318.         bsr     newline
  319.         bra     input
  320.  
  321. testifend   lea     in,a0
  322.         lea     0(a0,d7),a0
  323.         move.w  d7,d2
  324. 2$        move.b  (a0)+,d0
  325.         beq.s   1$
  326.         cmpi.b  #' ',d0
  327.         bne.s   3$
  328.         addq    #1,d2
  329.         bra.s   2$
  330. 3$        cmpi.b  #10,d0
  331. 1$        rts
  332.  
  333.  
  334. endshow     tst.b   fromfile
  335.         bne.s   nomore
  336.         clr.w   cmdptr
  337. notfinished bsr     starttimer
  338. nomore        tst.b   fromfile
  339.         bne.s   1$
  340.         clr.l   lastprinted
  341.         bsr     blastout
  342. 1$        rts
  343.  
  344. ;get the string from inputbuffer; search and execute
  345. ;the command, if any.
  346.  
  347. cli        lea     dummy,a0
  348.         subq    #1,d0
  349. cl2        subq    #1,d0
  350.         bmi.s   cl1
  351.         cmp.b   #' ',0(a0,d0)
  352.         beq.s   cl2
  353. cl1        addq    #1,d0
  354.         move.b  #10,0(a0,d0)
  355.         bsr     kllblnks
  356.         cmpi.b  #10,0(a0)
  357.         beq     showwhat
  358.         cmpi.b  #';',0(a0)
  359.         beq     nomore
  360.  
  361.         bsr     findcmd
  362.         tst.l   d2
  363.         bpl.s   okcmd
  364.         bsr     findalias
  365.         tst.l   d2
  366.         bmi.s   nm1
  367.  
  368. okcmd        clr.b   procnum
  369.         adda.w  d1,a0
  370.         bsr     kllblnks
  371.         lsl     #2,d2
  372.         lea     cmdaddr(PC),a1
  373.         jsr     0(a1,d2)
  374.         bra     nomore
  375.  
  376. nm1        lea     in,a1
  377.         lea     buffer,a2
  378. nm2        move.b  (a1)+,(a2)+
  379.         cmp.b   #10,-1(a1)
  380.         bne.s   nm2
  381.         lea     in,a1
  382. nm0        move.b  (a0)+,(a1)+
  383.         cmp.b   #10,-1(a1)
  384.         bne.s   nm0
  385.         lea     dummy,a2
  386.         lea     buffer,a1
  387. nm3        move.b  (a1)+,(a2)+
  388.         cmp.b   #10,-1(a1)
  389.         bne.s   nm3
  390.         clr.w   cmdptr
  391.         bra     showwhat
  392.  
  393. findcmd     bsr     strbuf
  394.         move.l  a0,a5
  395.         lea     commds(PC),a2
  396.         moveq   #0,d2
  397. 1$        lea     buffer,a0
  398.         move.l  a2,a1
  399.         bsr     strcmp
  400.         beq     3$
  401. 2$        tst.b   (a2)+
  402.         bne.s   2$
  403.         addq    #1,d2
  404.         cmp.w   #cmdnum,d2
  405.         bne.s   1$
  406.         moveq   #-1,d2
  407. 3$        move.l  a5,a0
  408.         rts
  409.  
  410. findalias   move.l  a0,a5
  411.         move.l  aliaslist(PC),d4
  412. 1$        beq.s   3$
  413.         move.l  d4,a4
  414.         lea     buffer,a0
  415.         lea     5(a4),a1
  416.         move.b  4(a4),d2
  417.         ext.w   d2
  418.         ext.l   d2
  419.         bsr     strcmp
  420.         beq     4$
  421.         move.l  0(a4),d4
  422.         bra.s   1$
  423. 3$        moveq   #-1,d2
  424. 4$        move.l  a5,a0
  425.         rts
  426.  
  427. subs        bra     showtask
  428.         bra     showaddr
  429.         bra     showdevs
  430.         bra     showlibs
  431.         bra     showres
  432.         bra     showresi
  433.         bra     showmem
  434.         bra     showprt
  435.         bra     showint
  436.         bra     stack
  437.         bra     clicomm
  438. cmdaddr     bra     settime
  439.         bra     taskpri
  440.         bra     info
  441.         bra     pri
  442.         bra     flush
  443.         bra     freeze
  444.         bra     warm
  445.         bra     signal
  446.         bra     break
  447.         bra     alert
  448.         bra     lastalert
  449.         bra     hold
  450.         bra     stopall
  451.         bra     clear
  452.         bra     cancel
  453.         bra     taskports
  454.         bra     hunks
  455.         bra     devices
  456.         bra     openlib
  457.         bra     closelib
  458.         bra     currentdir
  459.         bra     cd
  460.         bra     mypri
  461.         bra     openfiles
  462.         bra     locks
  463.         bra     unlock
  464.         bra     screens
  465.         bra     windows
  466.         bra     closescreen
  467.         bra     closewindow
  468.         bra     fonts
  469.         bra     windowfonts
  470.         bra     lockdrive
  471.         bra     freedrive
  472.         bra     capture
  473.         bra     clrcold
  474.         bra     clrcool
  475.         bra     clrwarm
  476.         bra     snoop
  477.         bra     usage
  478.         bra     inphand
  479.         bra     nohead
  480.         bra     sort
  481.         bra     hide
  482.         bra     hidden
  483.         bra     setwindow
  484.         bra     cancel
  485.         bra     iconifyoff
  486.         bra     historylines
  487.         bra     historylength
  488.         bra     showhistory
  489.         bra     repeatcmd
  490.         bra     remresident
  491.         bra     saveoutput
  492.         bra     killhistory
  493.         bra     iconbackdrp
  494.         bra     setfont
  495.         bra     trapguru
  496.         bra     outputlines
  497.         bra     usescreen
  498.         bra     usewindow
  499.         bra     grabtimerio
  500.         bra     dchange
  501.         bra     alias
  502.         bra     remnode
  503.  
  504. ;------ Task-Structures-----
  505.  
  506. showaddr    clr.b   tasktyp
  507.         bra.s   startask
  508. showtask    move.b  #1,tasktyp
  509. startask    tst.b   headon
  510.         beq     noheader1
  511.         move.l  #infoh1,d0
  512.         bsr     putstr
  513.         move.l  _SysBase(PC),a6
  514.         move.l  #cpu2,d0
  515.         btst    #1,297(a6)      ;SysBase->AttnFlags
  516.         bne.s   cpupr
  517.         move.l  #cpu1,d0
  518.         btst    #0,297(a6)
  519.         bne.s   cpupr
  520.         move.l  #cpu0,d0
  521. cpupr        bsr     putstr
  522.         move.l  _SysBase(PC),a6
  523.         btst    #2,297(a6)
  524.         beq.s   no881
  525.         move.l  #cpu3,d0
  526.         bsr     putstr
  527. no881        moveq   #20,d1
  528.         bsr     tab
  529.         move.l  #infoh3,d0
  530.         bsr     putstr
  531.  
  532. noheader1   move.l  _SysBase(PC),a6
  533.         move.w  #$4000,$dff09a
  534.         move.l  280(a6),d0
  535.         move.l  284(a6),d1
  536.         move.l  oldidl,d3
  537.         move.l  d0,oldidl
  538.         sub.l   d3,d0
  539.         move.l  olddisp,d3
  540.         move.l  d1,olddisp
  541.         sub.l   d1,d3
  542.         move.l  d0,d1
  543.         sub.l   d3,d1
  544.         move.l  d1,maxdisp
  545.         move.l  d3,-(a7)
  546.         movem.l d0-d3,-(a7)
  547.         moveq   #1,d5
  548.         bsr     getaskdat
  549.         move.l  a5,savedat
  550.         movem.l (a7)+,d0-d3
  551.         sub.l   d3,d0
  552.         neg.l   d3
  553.         tst.b   headon
  554.         beq.s   noheader2
  555.         bsr     prcent
  556.         bsr     newline
  557.         move.l  #infoh2,d0
  558.         bsr     putstr
  559. noheader2   move.l  (a7)+,d0
  560.         neg.l   d0
  561.         move.l  d0,dispatches
  562.         tst.b   headon
  563.         beq     noheader3
  564.         mulu    #100,d0
  565.         move.l  d0,-(a7)
  566.  
  567.         lea     secs(PC),a0
  568.         lea     mics(PC),a1
  569.         CALL    CurrentTime,intuibase(PC)
  570.         move.l  secs(PC),d3
  571.         lsl.l   #1,d3
  572.         move.l  d3,d1
  573.         lsl.l   #2,d3
  574.         add.l   d1,d3
  575.         move.l  mics(PC),d0
  576.         move.l  #100000,d1
  577.         bsr     div
  578.         add.l   d0,d3
  579.         move.l  time10(PC),d1
  580.         move.l  d3,time10
  581.         sub.l   d1,d3
  582.         move.l  (a7)+,d0
  583.         move.l  d3,-(a7)
  584.         move.l  d3,d1
  585.         bsr     div
  586.         moveq   #1,d5
  587.         bsr     putfrac
  588.  
  589.         moveq   #20,d1
  590.         bsr     tab
  591.         move.l  #infoh7,d0
  592.         bsr     putstr
  593.         move.l  iocount(PC),d0
  594.         clr.l   iocount
  595.         mulu    #100,d0
  596.         move.l  (a7)+,d3
  597.         move.l  d3,d1
  598.         bsr     div
  599.         moveq   #1,d5
  600.         bsr     putfrac
  601.  
  602.         bsr     newline
  603.         bsr     newline
  604. noheader3   lea     theader(PC),a0
  605.         tst.b   tasktyp
  606.         bne.s   phedder
  607.         lea     t2header(PC),a0
  608. phedder     bsr     puthead
  609.         move.l  savedat(PC),a5
  610.  
  611. pt1        tst.b   entries
  612.         beq     pt2
  613.         lea     -16(a5),a5
  614.         bsr     hideit
  615.         tst     d0
  616.         beq     ptend
  617.         move.l  0(a5),a4
  618.         move.l  a4,d0
  619.         move.l  d0,node
  620.         bsr     hexa
  621.         tst.b   tasktyp
  622.         beq.s   pt12
  623.         moveq   #0,d0
  624.         move.b  8(a4),d0
  625.         bsr     gettype
  626.  
  627. pt12        moveq   #0,d0
  628.         move.b  9(a5),d0
  629.         subq.b  #1,d0
  630.         mulu    #10,d0
  631.         move.l  #status,d1
  632.         add.l   d1,d0
  633.         bsr     putstr
  634.         tst.b   tasktyp
  635.         bne.s   pt13
  636.  
  637.         move.l  18(a4),d0
  638.         bsr     hexa
  639.         move.l  #longnix,d0
  640.         cmp.b   #4,9(a5)
  641.         beq.s   pt14
  642.         bsr     putstr
  643.         bra.s   pt15
  644. pt14        move.l  22(a4),d0
  645.         bsr     hexa
  646. pt15        move.l  26(a4),d0
  647.         bsr     hexa
  648.         move.l  54(a4),a1
  649.         move.l  0(a1),d0
  650.         cmp.b   #2,9(a5)
  651.         bne.s   pt16
  652.         move.l  #*,d0
  653. pt16        bsr     hexa
  654.         bra     pt4
  655.  
  656. pt13        move.b  10(a5),d3
  657.         bsr     plusmins
  658.  
  659.         move.l  dispatches(PC),d0
  660.         tst.b   usageflag
  661.         beq.s   pt37
  662.         move.l  maxdisp(PC),d0
  663. pt37        move.l  12(a5),d3
  664.         bsr     prcent
  665.  
  666.         clr.b   d3
  667.         cmpi.b  #13,8(a5)
  668.         bne.s   noproc
  669.         tst.l   172(a4)
  670.         beq.s   noproc
  671.         move.b  11(a5),d3
  672.         bsr     bytedec
  673.         bra.s   pt4
  674. noproc        move.l  #nix,d0
  675.         bsr     putstr
  676. pt4        move.l  4(a5),d0
  677.         bsr     putnam
  678. ptend        subq.b  #1,entries
  679.         bra     pt1
  680. pt2        rts
  681.  
  682. putlist     move.l  0(a4),a4
  683.         tst.l   0(a4)
  684.         beq.s   endlist
  685.         bsr     putdata
  686.         bra.s   putlist
  687. endlist     rts
  688.  
  689. putdata     move.l  a4,0(a5)
  690.         move.l  10(a4),4(a5)        ;task->ln_Name
  691.         move.b  8(a4),8(a5)         ;task->ln_Type
  692.         move.b  15(a4),9(a5)        ;task->tc_State
  693.         move.b  9(a4),10(a5)        ;task->ln_Pri
  694.         move.b  143(a4),11(a5)      ;Process->pr_Tasknum
  695.         clr.l   12(a5)
  696.         lea     cputime,a0
  697.         move.l  tasksnum(PC),d1
  698.         subq    #1,d1
  699.         bmi.s   pua1
  700. pua3        cmp.l   (a0)+,a4
  701.         dbeq    d1,pua3
  702.         tst     d1
  703.         bmi.s   pua1
  704. pua2        move.l  508(a0),12(a5)
  705. pua1        lea     16(a5),a5
  706.         addq.b  #1,entries
  707.         rts
  708.  
  709. gettype     and.l   #$f,d0
  710.         mulu    #11,d0
  711.         add.l   #type,d0
  712.         bra     putstr
  713.  
  714. getaskdat   move.l  d5,-(a7)
  715.         lea     buffer,a5
  716.         clr.b   entries
  717.         lea     stplist(PC),a4
  718.         bsr     putlist
  719.         move.l  _SysBase(PC),a4
  720.         lea     420(a4),a4          ;SysBase->TaskWait
  721.         bsr     putlist
  722.         move.l  _SysBase(PC),a4
  723.         lea     406(a4),a4          ;SysBase->TaskReady
  724.         bsr     putlist
  725.         move.l  _SysBase(PC),a4
  726.         move.l  276(a4),a4          ;SysBase->ThisTask
  727.         bsr     putdata
  728.         move.l  (a7)+,d5
  729.         beq.s   1$
  730.         clr.l   tasksnum
  731. 1$        move.w  #-$4000,$dff09a
  732.         moveq   #16,d2
  733.         lea     -32(a5),a2
  734.         bsr.s   sortlist
  735.         rts
  736.  
  737. sortlist    tst.b   sorton
  738.         beq.s   sort5
  739.         lea     buffer,a3
  740. sort1        lea     0(a3,d2),a4
  741. sort2        move.l  0(a3),d1
  742.         cmp.l   0(a4),d1
  743.         bge.s   sort3
  744.         move.l  d2,d1
  745.         subq    #1,d1
  746. sort4        move.b  0(a4,d1),d0
  747.         move.b  0(a3,d1),0(a4,d1)
  748.         move.b  d0,0(a3,d1)
  749.         dbf     d1,sort4
  750. sort3        lea     0(a4,d2),a4
  751.         cmp.l   a2,a4
  752.         ble.s   sort2
  753.         lea     0(a3,d2),a3
  754.         cmp.l   a2,a3
  755.         bne.s   sort1
  756. sort5        rts
  757.  
  758. prcent        lsl.l   #1,d3
  759.         move.l  d3,d1
  760.         lsl.l   #2,d3
  761.         add.l   d1,d3
  762.         lsl.l   #2,d3
  763.         move.l  d3,d1
  764.         lsl.l   #3,d3
  765.         move.l  d3,d2
  766.         lsl.l   #1,d3
  767.         add.l   d2,d3
  768.         add.l   d1,d3
  769.         move.l  d0,d1
  770.         move.l  d3,d0
  771.         bsr     div
  772.         moveq   #0,d5
  773.         bsr     putfrac
  774.         move.l  #infoh4,d0
  775.         bra     putstr
  776.  
  777. putfrac     divu    #10,d0
  778.         move    d0,d3
  779.         swap    d0
  780.         move    d0,d1
  781.         tst     d5
  782.         bne.s   1$
  783.         cmp.w   #100,d3
  784.         ble.s   1$
  785.         move.l  #whatsthis,d0
  786.         bra     putstr
  787. 1$        bsr     bytedec
  788.         lea     out,a0
  789.         move.b  #'.',-1(a0,d0)
  790.         or.b    #'0',d1
  791.         move    d1,d0
  792.         bra     putchar
  793.  
  794. hideit        tst.b   hideon
  795.         bne.s   pt73
  796. pt75        moveq   #1,d0
  797.         rts
  798. pt73        lea     hidestart(PC),a4
  799.         move.l  4(a5),a0
  800. pt74        tst.l   0(a4)
  801.         beq.s   pt75
  802.         move.l  0(a4),a4
  803.         lea     4(a4),a1
  804.         bsr     strcmp
  805.         tst     d0
  806.         beq     hideend
  807.         bra.s   pt74
  808. hideend     rts
  809. *-------- mem-hunks ------------
  810.  
  811. showmem     lea     mheader(PC),a0
  812.         bsr     puthead
  813.         move.l  _SysBase(PC),a5
  814.         lea     322(a5),a5          ;SysBase->MemList
  815.         moveq   #0,d5
  816. mem1        move.l  0(a5),a5            ;MemList->ln_Next
  817.         tst.l   0(a5)
  818.         beq.s   mem2
  819.         move.l  20(a5),d0           ;MemHeader->mh_Lower
  820.         bsr     hexa
  821.         move.l  24(a5),d0           ;MemHeader->mh_Upper
  822.         bsr     hexa
  823.         move.l  28(a5),d0           ;MemHeader->mh_Free
  824.         add.l   d0,d5
  825.         moveq   #1,d3
  826.         bsr     longdec
  827.         move.b  15(a5),d3           ;MemHeader->mh_Attributes
  828.         bsr     bytedec
  829.         move.b  9(a5),d3            ;MemHeader->ln_pri
  830.         bsr     plusmins
  831.         move.l  10(a5),d0           ;MemHeader->ln_Name
  832.         move.l  a5,node
  833.         bsr     putnam
  834.         bra.s   mem1
  835. mem2        move.l  #infoh6,d0
  836.         bsr     putstr
  837.         moveq   #19,d1
  838.         bsr     tab
  839.         moveq   #0,d3
  840.         move.l  d5,d0
  841.         bsr     longdec
  842. newline     move.l  #cr,d0
  843.         bra     putstr
  844.  
  845. *-------- Task-Stack ------------
  846.  
  847. stack        lea     stackhead(pc),a0
  848.         bsr     puthead
  849.         moveq   #0,d5
  850.         bsr     getaskdat
  851. sta1        tst.b   entries
  852.         beq     sta8
  853.         lea     -16(a5),a5
  854.         bsr     hideit
  855.         tst     d0
  856.         beq     sta9
  857.         move.l  0(a5),a1
  858.         cmp.b   #13,8(a1)               ;task->ln_Type
  859.         bne.s   sta6
  860.         move.l  172(a1),d0
  861.         beq.s   sta6
  862.         lsl.l   #2,d0
  863.         move.l  d0,a0
  864.         tst.l   60(a0)
  865.         beq.s   sta6
  866.         moveq   #1,d3
  867.         move.l  52(a0),d4
  868.         lsl.l   #2,d4
  869.         move.l  176(a1),d0
  870.         sub.l   d4,d0
  871.         bsr     hexa
  872.         move.l  d4,d0
  873.         bsr     longdec
  874.         move.l  176(a1),d0
  875.         sub.l   54(a1),d0
  876.         bra.s   sta7
  877.  
  878. sta6        move.l  58(a1),d0
  879.         bsr     hexa
  880.         moveq   #1,d3
  881.         move.l  62(a1),d0
  882.         sub.l   58(a1),d0
  883.         bsr     longdec
  884.         move.l  62(a1),d0
  885.         sub.l   54(a1),d0
  886. sta7        bsr     longdec
  887.         move.l  4(a5),d0
  888.         bsr     putnam
  889. sta9        subq.b  #1,entries
  890.         bra     sta1
  891. sta8        rts
  892.  
  893. clicomm     lea     clicomhead(pc),a0
  894.         bsr     puthead
  895.         moveq   #0,d5
  896.         bsr     getaskdat
  897. clic1        tst.b   entries
  898.         beq     clic8
  899.         lea     -16(a5),a5
  900.         bsr     hideit
  901.         tst     d0
  902.         beq     clic0
  903.         move.l  0(a5),a4
  904.         cmpi.b  #13,8(a4)
  905.         bne     clic0
  906.         tst.l   172(a4)
  907.         beq     clic0
  908.         move.l  140(a4),d3
  909.         beq     clic0
  910.         move.l  a4,d0
  911.         move.l  d0,node
  912.         bsr     hexa
  913.         moveq   #0,d0
  914.         move.b  9(a5),d0
  915.         subq    #1,d0
  916.         mulu    #10,d0
  917.         move.l  #status,d1
  918.         add.l   d1,d0
  919.         bsr     putstr
  920.         move.l  172(a4),a3
  921.         adda.l  a3,a3
  922.         adda.l  a3,a3
  923.         move.l  #script,d0
  924.         tst.l   40(a3)
  925.         beq.s   clic5
  926.         move.l  #interact,d0
  927. clic5        bsr     putstr
  928.         move.l  #backg,d0
  929.         tst.l   44(a3)
  930.         bne.s   clic6
  931.         move.l  #foreg,d0
  932. clic6        bsr     putstr
  933.         bsr     bytedec
  934.         move.l  4(a5),d0
  935.         bsr     putstr
  936.         moveq   #49,d1
  937.         bsr     tab
  938.         move.b  #' ',d0
  939.         bsr     putchar
  940.         move.l  128(a4),d0
  941.         beq.s   noprogloadc
  942. clic3        move.l  172(a4),d1
  943.         bne.s   clic4
  944. noprogloadc move.l  #longnix,d0
  945.         bsr     putnam
  946.         bra.s   clic0
  947. clic4        lsl.l   #2,d1
  948.         move.l  d1,a4
  949.         move.l  60(a4),d1
  950.         beq.s   noprogloadc
  951.         move.l  16(a4),d0
  952.         bsr     putbcpl
  953.         bsr     newline
  954.  
  955. clic0        subq.b  #1,entries
  956.         bne     clic1
  957. clic8        rts
  958.  
  959. *--------- interrupts ------------
  960. showint     lea     iheader(PC),a0
  961.         bsr     puthead
  962.         lea     intnames(PC),a5
  963.         lea     inttyp(PC),a4
  964.         moveq   #0,d1
  965.         moveq   #15,d5
  966.         move.l  _SysBase(PC),a3
  967.         lea     84(a3),a3           ;SysBase->IntVects[16]
  968.  
  969. si0        tst.b   0(a4,d1)
  970.         bne.s   si4
  971.         move.l  8(a3),a2            ;IntVector->iv_Node
  972.         bra.s   si5
  973. si4        move.l  0(a3),a2            ;Interrupt->is_Node
  974. si5        cmp.l   #0,a2
  975.         beq     nxtint
  976.         tst.b   0(a4,d1)
  977.         beq.s   si1
  978. si2        move.l  0(a2),a2            ;is_Node->ln_Next
  979.         tst.l   0(a2)
  980.         beq.s   nxtint
  981. si1        move.l  a2,d0
  982.         move.l  d0,node
  983.         bsr     hexa
  984.         move.l  14(a2),d0           ;Interrupt->is_Data
  985.         bsr     hexan
  986.         move.l  18(a2),d0           ;Interrupt->is_Code
  987.         bsr     hexan
  988.         move.b  9(a2),d3            ;Interrupt->ln_Pri
  989.         move.l  a3,-(a7)
  990.         bsr     plusmins
  991.         move.l  #intserv,d0
  992.         tst.b   0(a4,d1)
  993.         bne.s   1$
  994.         move.l  #inthand,d0
  995. 1$        bsr     putstr
  996.         move.l  #intdis,d0
  997.         move.w  $dff01c,d3
  998.         btst.w  d1,d3
  999.         beq.s   2$
  1000.         move.l  #inten,d0
  1001. 2$        bsr     putstr
  1002.         move.l  (a7)+,a3
  1003.         move.l  a5,d0
  1004.         bsr     putstr
  1005.         move.l  10(a2),d0           ;Interrupt->ln_Name
  1006.         bsr     putnam
  1007.         tst.b   0(a4,d1)
  1008.         bne.s   si2
  1009.         tst.l   0(a2)
  1010.         beq.s   nxtint
  1011.         move.l  0(a2),a2
  1012.         bra     si1
  1013. nxtint        addq    #1,d1
  1014.         lea     12(a5),a5
  1015.         lea     12(a3),a3
  1016.         dbf     d5,si0
  1017.         rts
  1018.  
  1019. *---------    resident ------------
  1020.  
  1021. showresi    lea     rheader(PC),a0
  1022.         bsr     puthead
  1023.         move.l  _SysBase(PC),a5
  1024.         move.l  300(a5),a5          ;SysBase->ResModules
  1025.  
  1026. r1        tst.l   0(a5)
  1027.         beq     r2
  1028.         move.l  0(a5),d0            ;Resident->ln_Next
  1029.         tst.l   d0
  1030.         bpl.s   r3
  1031.         bclr    #31,d0
  1032.         movea.l d0,a5
  1033.         bra.s   r1
  1034. r3        movea.l d0,a4
  1035.         move.l  d0,node
  1036.         bsr     hexa
  1037.         move.b  13(a4),d3           ;rt_Pri
  1038.         bsr     plusmins
  1039.         move.b  10(a4),d0           ;rt_Flags
  1040.         bsr     bin
  1041.         move.b  11(a4),d3           ;rt_Version
  1042.         bsr     bytedec
  1043.         move.b  12(a4),d0           ;rt_Type
  1044.         bsr     gettype
  1045.         move.l  14(a4),d0           ;rt_Name
  1046.         bsr     putnam
  1047. r4        addq    #4,a5
  1048.         bra     r1
  1049. r2        rts
  1050.  
  1051. *---------  ports  -------------
  1052.  
  1053. showprt     lea     pheader(PC),a0
  1054.         bsr     puthead
  1055.         move.l  _SysBase(PC),a4
  1056.         lea     392(a4),a4          ;SysBase->PortList
  1057.         lea     buffer,a5
  1058.         moveq   #0,d5
  1059.         CALL    Forbid,_SysBase(PC)
  1060.         move.w  #$4000,$dff09a
  1061. sp2        move.l  0(a4),a4            ;mp_Node.ln_Next
  1062.         tst.l   0(a4)
  1063.         beq.s   sp20
  1064.         bsr     getpdata
  1065.         bra.s   sp2
  1066. sp20        tst.b   tports
  1067.         bne.s   sp15
  1068.         move.l  _SysBase(PC),a4
  1069.         move.l  276(a4),a4          ;sysbase->ThisTask
  1070.         lea     92(a4),a4           ;process->pr_MsgPort
  1071.         bsr     getpdata
  1072.         move.l  _SysBase(PC),a2
  1073.         lea     406(a2),a2
  1074. sp11        move.l  0(a2),a2
  1075.         tst.l   0(a2)
  1076.         beq.s   sp14
  1077.         lea     92(a2),a4
  1078.         cmp.b   #13,8(a2)
  1079.         bne.s   sp11
  1080.         bsr     getpdata
  1081.         bra     sp11
  1082. sp14        move.l  _SysBase(PC),a2
  1083.         lea     420(a2),a2
  1084. sp12        move.l  0(a2),a2
  1085.         tst.l   0(a2)
  1086.         beq.s   sp15
  1087.         lea     92(a2),a4
  1088.         cmp.b   #13,8(a2)
  1089.         bne.s   sp12
  1090.         bsr     getpdata
  1091.         bra     sp12
  1092. sp15        move.w  #-$4000,$dff09a
  1093.         CALL    Permit,_SysBase(PC)
  1094.         lea     buffer,a5
  1095. sp3        tst.b   d5
  1096.         beq     sp6
  1097.         move.l  0(a5),d0
  1098.         move.l  d0,node
  1099.         bsr     hexa
  1100.         move.l  4(a5),d0
  1101.         bsr     putstr
  1102.         moveq   #25,d1
  1103.         bsr     tab
  1104.         move.b  8(a5),d0
  1105.         and.l   #3,d0
  1106.         mulu    #9,d0
  1107.         add.l   #mp_flags,d0
  1108.         bsr     putstr
  1109.         move.b  9(a5),d3
  1110.         bsr     bytedec
  1111.         move.b  14(a5),d3
  1112.         cmp.b   #255,d3
  1113.         bne.s   1$
  1114.         move.l  #toomuch,d0
  1115.         bsr     putstr
  1116.         bra.s   2$
  1117. 1$        bsr     bytedec
  1118. 2$        move.l  #longnix,d0
  1119.         move.l  10(a5),d1
  1120.         beq.s   sp8
  1121.         move.l  d1,a3
  1122.         move.l  10(a3),d0
  1123. sp8        bsr     putnam
  1124.         lea     16(a5),a5
  1125.         subq.b  #1,d5
  1126.         bra     sp3
  1127. sp6        rts
  1128.  
  1129. getpdata    move.l  a4,0(a5)
  1130.         move.l  10(a4),4(a5)        ;ln_Name
  1131.         move.b  14(a4),8(a5)        ;mp_Flags
  1132.         move.b  15(a4),9(a5)        ;mp_SigBit
  1133.         move.l  16(a4),10(a5)       ;mp_SigTask
  1134.         moveq   #0,d0
  1135.         movea.l 20(a4),a3           ;mp_MsgList
  1136. sp10        movea.l 0(a3),a3
  1137.         cmpa.l  #0,a3
  1138.         beq.s   sp9
  1139.         addq.b  #1,d0
  1140.         cmp.b   #255,d0
  1141.         bne.s   sp10
  1142. sp9        move.b  d0,14(a5)
  1143.         lea     16(a5),a5
  1144.         addq.b  #1,d5
  1145.         rts
  1146. *-------- resources ------------
  1147.  
  1148. showres     lea     lheader(PC),a0
  1149.         bsr     puthead1
  1150.         lea     resnam(PC),a0
  1151.         bsr     puthead2
  1152.         move.l  _SysBase(PC),d5
  1153.         add.l   #336,d5        ;SysBase->ResourceList
  1154.         bsr     show
  1155.         rts
  1156.  
  1157. *--------- devices  -------------
  1158.  
  1159. showdevs    lea     lheader(PC),a0
  1160.         bsr     puthead1
  1161.         lea     devnam(PC),a0
  1162.         bsr     puthead2
  1163.         move.l  _SysBase(PC),d5
  1164.         add.l   #350,d5        ;SysBase->DeviceList
  1165.         bsr     show
  1166.         rts
  1167.  
  1168. *-------- libraries -------------
  1169.  
  1170. showlibs    lea     lheader(PC),a0
  1171.         bsr     puthead1
  1172.         lea     libnam(PC),a0
  1173.         bsr     puthead2
  1174.         move.l  _SysBase(PC),d5
  1175.         add.l   #378,d5        ;SysBase->LibList
  1176.  
  1177. show        lea     buffer,a5
  1178.         clr.b   entries
  1179.         CALL    Forbid,_SysBase(PC)
  1180.         move.l  d5,a4
  1181. sl1        move.l  0(a4),a4            ;lib_Node.ln_Next
  1182.         tst.l   0(a4)
  1183.         beq.s   sl2
  1184.         addq.b  #1,entries
  1185.         move.l  a4,0(a5)
  1186.         move.l  10(a4),4(a5)        ;ln_Name
  1187.         move.b  33(a4),8(a5)        ;lib_OpenCnt
  1188.         move.b  21(a4),9(a5)        ;lib_Version
  1189.         move.b  23(a4),10(a5)       ;lib_Revision
  1190.         move.b  14(a4),11(a5)       ;lib_Flags
  1191.         lea     12(a5),a5
  1192.         bra.s   sl1
  1193. sl2        CALL    Permit,_SysBase(PC)
  1194.  
  1195.         lea     buffer,a5
  1196. dl3        tst.b   entries
  1197.         beq.s   sl4
  1198.         move.l  0(a5),d0
  1199.         move.l  d0,node
  1200.         bsr     hexa
  1201.         move.b  8(a5),d3
  1202.         bsr     bytedec
  1203.         move.b  9(a5),d3
  1204.         bsr     bytedec
  1205.         move.b  10(a5),d3
  1206.         bsr     bytedec
  1207.         move.b  11(a5),d0
  1208.         bsr     bin
  1209.         move.l  4(a5),d0
  1210.         bsr     putnam
  1211.         lea     12(a5),a5
  1212.         subq.b  #1,entries
  1213.         bra.s   dl3
  1214. sl4        rts
  1215.  
  1216. ;Remove a resident module from the list. Clears the rt_Matchword
  1217. ;to avoid being found and reinserted during the next reset
  1218. remresident bsr     nodenam2
  1219.         cmp.b   #'$',0(a5)
  1220.         bne.s   1$
  1221.         move.l  a5,a0
  1222.         bsr     readhex
  1223.         tst.b   d7
  1224.         bne.s   2$
  1225. 1$        move.l  a5,a1
  1226.         CALL    FindResident,_SysBase(PC)
  1227.         tst.l   d0
  1228.         beq     fn5
  1229.  
  1230. 2$        move.l  _SysBase(PC),a3
  1231.         move.l  300(a3),a3          ;SysBase->ResModules
  1232.  
  1233. 8$        move.l  (a3)+,d1
  1234.         beq     fn5
  1235.         bpl.s   3$
  1236.         bclr    #31,d1
  1237.         movea.l d1,a3
  1238.         bra.s   8$
  1239. 3$        cmp.l   d1,d0
  1240.         bne.s   8$
  1241.  
  1242. 4$        move.l  a3,a4
  1243. 5$        tst.l   (a4)+
  1244.         bgt.s   5$
  1245.  
  1246. 6$        move.l  d0,a1
  1247.         clr.w   0(a1)               ;rt_MatchTag
  1248.         move.l  a4,d0
  1249.         sub.l   a3,d0
  1250.         lsr     #2,d0
  1251.         subq    #1,d0
  1252.         lea     -4(a3),a1
  1253. 7$        move.l  (a3)+,(a1)+
  1254.         dbf     d0,7$
  1255.         rts
  1256.  
  1257. ;find the first entry in the device-list
  1258. ;returns a1 = pointer to first entry
  1259.  
  1260. devinfo     move.l  dosbase(PC),a1
  1261.         move.l  34(a1),a1
  1262.         move.l  24(a1),a1
  1263.         adda.l  a1,a1
  1264.         adda.l  a1,a1
  1265.         move.l  4(a1),a1
  1266.         rts
  1267.  
  1268. ;unlock a file
  1269. unlock        tst.b   fromfile
  1270.         bne     ul6
  1271.         bsr     readhex
  1272.         tst.b   d7
  1273.         beq     syntax
  1274.         move.l  d0,remembr
  1275.         move.l  d0,-(a7)
  1276.         moveq   #-1,d6
  1277.         bsr     of44
  1278.         tst.l   remembr
  1279.         beq.s   ul1
  1280.         move.l  #unlerr,d0
  1281.         bsr     putnam
  1282.         bra     ul4
  1283. ul1        bsr     ResumeOutput
  1284.         move.l  #unl1,d0
  1285.         bsr     putstr
  1286.         move.l  0(a7),d0
  1287.         bsr     getpath
  1288.         move.l  #unltxt2,d0
  1289.         bsr     putstr
  1290.         bsr     readline
  1291.         ori.b   #$20,inputbuffer
  1292.         cmp.b   #'y',inputbuffer
  1293.         bne.s   ul5
  1294.         move.l  0(a7),d1
  1295.         CALL    UnLock,dosbase
  1296. ul5        bsr     freefinfo
  1297. ul4        addq    #4,a7
  1298. ul6        rts
  1299. ;---------- Show all Locks------------
  1300. locks        moveq   #0,d6
  1301.         bra.s   of33
  1302.  
  1303. ;---------- Open Files-----------
  1304. openfiles   moveq   #1,d6
  1305. of33        move.l  mytask(PC),a4
  1306.         move.l  184(a4),inputbuffer
  1307.         move.l  #-1,184(a4)
  1308.         lea     ofheader(PC),a0
  1309.         bsr     puthead
  1310. of44        bsr     allocfinfo
  1311.         bsr     devinfo
  1312.         move.l  a1,a3
  1313. of1        adda.l  a3,a3
  1314.         adda.l  a3,a3
  1315.         cmp.l   #2,4(a3)
  1316.         bne     of2
  1317.         move.l  40(a3),d0
  1318.         lsl.l   #2,d0
  1319.         move.l  d0,a4
  1320.         moveq   #0,d3
  1321.         move.b  (a4)+,d3
  1322.         subq    #1,d3
  1323.         lea     buffer,a5
  1324. of22        move.b  (a4)+,(a5)+
  1325.         dbf     d3,of22
  1326.         move.b  #':',(a5)+
  1327.         clr.b   0(a5)
  1328.         cmp.l   #'RAM ',buffer
  1329.         bne.s   of5
  1330.         cmp.l   #'Disk',buffer+4
  1331.         bne.s   of5
  1332.         move.l  #$4d3a0000,buffer+2
  1333. of5        move.l  #buffer,d1
  1334.         move.l  #-2,d2
  1335.         CALL    Lock,dosbase(PC)
  1336.         tst.l   d0
  1337.         bne.s   of6
  1338.         move.l  #buffer,d0
  1339.         bsr     putstr
  1340.         move.l  #nomount,d0
  1341.         bsr     putnam
  1342.         bra     of2
  1343.  
  1344. of6        move.l  d0,-(a7)
  1345.         lsl.l   #2,d0
  1346.         move.l  d0,a5
  1347. of4        move.l  0(a5),d0
  1348.         cmp.l   #50,d0
  1349.         ble     of3
  1350.         move.l  d0,d5
  1351.         lsl.l   #2,d5
  1352.         move.l  d5,a5
  1353.         move.l  d0,d5
  1354.         tst     d6
  1355.         bpl.s   of45
  1356.  
  1357.         cmp.l   remembr(PC),d0
  1358.         bne.s   of4
  1359.         clr.l   remembr
  1360.         move.l  (a7)+,d1
  1361.         CALL    UnLock,dosbase(PC)
  1362.         bra     quitof
  1363.  
  1364. of45        move.l  8(a5),d4
  1365.         bsr     getfinfo
  1366.         move.l  finfoptr,a4
  1367.  
  1368.         tst.l   d6
  1369.         beq.s   of8
  1370.         bmi.s   of8
  1371.         tst.l   4(a4)
  1372.         bpl     of4
  1373. of8        move.l  d5,d0
  1374.         move.l  d0,node
  1375.         bsr     hexa
  1376.         move.l  #access,d0
  1377.         cmp     #-2,d4
  1378.         beq.s   of7
  1379.         addq    #8,d0
  1380. of7        bsr     putstr
  1381.         tst.l   4(a4)
  1382.         bmi.s   of9
  1383.         move.l  #longnix,d0
  1384.         bsr     putstr
  1385.         bra     of10
  1386. of9        move.l  124(a4),d0
  1387.         bsr     longdec
  1388. of10        move.l  d5,d0
  1389.         bsr     getpath
  1390.         bra     of4
  1391.  
  1392.         bsr     newline
  1393. of3        move.l  (a7)+,d1
  1394.         CALL    UnLock,dosbase(PC)
  1395. of2        move.l  0(a3),a3
  1396.         cmpa.l  #0,a3
  1397.         bne     of1
  1398.         bsr     freefinfo
  1399. quitof        move.l  mytask(PC),a4
  1400.         move.l  inputbuffer,184(a4)
  1401.         rts
  1402.  
  1403. ;---------- Dos Devices ----------
  1404.  
  1405. devices     lea     ddheader(PC),a0
  1406.         bsr     puthead
  1407.         bsr     devinfo
  1408. dev1        adda.l  a1,a1
  1409.         adda.l  a1,a1
  1410.         clr.b   d6
  1411.         tst.l   4(a1)
  1412.         bne     dev2
  1413.         move.l  40(a1),d0
  1414.         bsr     putbcpl
  1415.         moveq   #10,d1
  1416.         bsr     tab
  1417.         cmp.l   #20,28(a1)
  1418.         ble     dev9
  1419.         moveq   #1,d6
  1420.         move.l  28(a1),a3
  1421.         adda.l  a3,a3
  1422.         adda.l  a3,a3
  1423.         cmp.l   #20,8(a3)
  1424.         ble     dev9
  1425.         move.l  8(a3),a2
  1426.         adda.l  a2,a2
  1427.         adda.l  a2,a2
  1428.         move.l  12(a2),d3
  1429.         movem.l a1-a3,-(a7)
  1430.         bsr     bytedec
  1431.         movem.l (a7)+,a1-a3
  1432.         moveq   #1,d3
  1433.         move.l  20(a2),d0
  1434.         bsr     longdec
  1435.         move.l  40(a2),d0
  1436.         beq.s   devs20
  1437.         addq    #1,d0
  1438.         sub.l   36(a2),d0
  1439. devs20        bsr     longdec
  1440.         move.l  44(a2),d0
  1441.         bsr     longdec
  1442.         bra.s   dev8
  1443. dev9        move.l  #notfile,d0
  1444.         bsr     putstr
  1445. dev8        tst.l   8(a1)
  1446.         beq.s   dev6
  1447.         move.l  #devload,d0
  1448.         bra.s   dev5
  1449. dev6        move.l  #devnload,d0
  1450. dev5        bsr     putstr
  1451.         tst.b   d6
  1452.         beq.s   dev7
  1453.         move.l  4(a3),d0
  1454.         bne.s   dev4
  1455. dev7        move.l  16(a1),d0
  1456.         bne.s   dev4
  1457.         tst.l   8(a1)
  1458.         beq.s   dev11
  1459.         move.l  8(a1),a3
  1460.         move.l  -82(a3),d0
  1461.         bsr     putstr
  1462.         bra     dev11
  1463. dev4        bsr     putbcpl
  1464. dev11        bsr     newline
  1465. dev2        move.l  0(a1),a1
  1466.         cmpa.l  #0,a1
  1467.         bne     dev1
  1468.         rts
  1469.  
  1470. ; Check if a named dos-device is mounted
  1471. ; name in 'buffer'.
  1472. ; Result: d0 = 0(false) anything else(true).
  1473.  
  1474. finddev     bsr     devinfo
  1475. fdev1        adda.l  a1,a1
  1476.         adda.l  a1,a1
  1477.         clr.b   d6
  1478.         tst.l   4(a1)
  1479.         bne.s   fdev2
  1480.         move.l  40(a1),a2
  1481.         lea     buffer,a0
  1482.         bsr     strbcmp
  1483.         tst     d0
  1484.         bne.s   fdev3
  1485. fdev2        move.l  0(a1),a1
  1486.         cmpa.l  #0,a1
  1487.         bne.s   fdev1
  1488. fdev3        rts
  1489.  
  1490. ; Re-assign a drive to dos
  1491.  
  1492. freedrive   clr.l   dp_Arg1
  1493.         bra     ldr3
  1494.  
  1495. ; Inhibit a disk drive
  1496.  
  1497. lockdrive   move.l  #1,dp_Arg1
  1498. ldr3        bsr     getstr
  1499.         bsr     finddev
  1500.         bne.s   ldr1
  1501. ldr2        move.l  #buffer,d0
  1502.         bsr     putstr
  1503.         move.l  #nomount,d0
  1504.         bsr     putstr
  1505.         move.l  #dishelp,d0
  1506.         bra     putnam
  1507. ldr1        move.l  #buffer,d1
  1508.         CALL    DeviceProc,dosbase(PC)
  1509.         tst.l   d0
  1510.         beq.s   ldr2
  1511.         move.l  d0,a0
  1512.         move.l  #31,dp_Type
  1513.         bra     cons1
  1514.  
  1515. ;display the current directory of all processes,
  1516. ;except Workbench.(Worbench pr_CurrentDir is not a lock)
  1517.  
  1518. currentdir  lea     wbname(PC),a1
  1519.         CALL    FindTask,_SysBase(PC)
  1520.         move.l  d0,wbaddr
  1521.         lea     cdheader(PC),a0
  1522.         bsr     puthead
  1523.         bsr     allocfinfo
  1524.         moveq   #0,d5
  1525.         bsr     getaskdat
  1526.         lea     buffer,a5
  1527. cd2        tst.b   entries
  1528.         beq.s   cd6
  1529.         cmp.b   #13,8(a5)
  1530.         bne.s   cd5
  1531.         move.l  wbaddr(PC),d0
  1532.         cmp.l   0(a5),d0
  1533.         beq.s   cd5
  1534.         move.l  4(a5),d0
  1535.         bsr     putstr
  1536.         moveq   #15,d1
  1537.         bsr     tab
  1538.         move.l  0(a5),a4
  1539.         move.l  152(a4),d0
  1540. cd1        bsr     getpath
  1541. cd5        subq.b  #1,entries
  1542.         lea     16(a5),a5
  1543.         bra.s   cd2
  1544. cd6        bsr     freefinfo
  1545.         rts
  1546.  
  1547. ;Change the current directory setting of a process
  1548.  
  1549. cd        tst.b   fromfile
  1550.         bne     cd10
  1551.         move.l  a0,-(a7)
  1552.         lea     wbname(PC),a1
  1553.         CALL    FindTask,_SysBase(PC)
  1554.         move.l  d0,wbaddr
  1555.         move.l  (a7)+,a0
  1556.         bsr     getstr
  1557.         move.l  a0,-(a7)
  1558.         move.l  #buffer,d1
  1559.         move.l  #-2,d2
  1560.         CALL    Lock,dosbase(PC)
  1561.         move.l  (a7)+,a0
  1562.         tst.l   d0
  1563.         bne     cd16
  1564.         move.l  #dnotf,d0
  1565.         bra     putnam
  1566. cd16        move.l  d0,remembr
  1567.         move.l  a0,-(a7)
  1568.         bsr     allocfinfo
  1569.         move.l  remembr(PC),d0
  1570.         bsr     getfinfo
  1571.         move.l  finfoptr,a5
  1572.         move.l  (a7)+,a0
  1573.         tst.l   4(a5)
  1574.         bpl.s   cd11
  1575.         move.l  #notdir,d0
  1576.         bsr     putnam
  1577.         bra     cd18
  1578. cd11        bsr     nodenam
  1579.         moveq.l #2,d7
  1580.         lea     TRuNode(PC),a4
  1581.         bsr     findnam
  1582.         tst.b   d7
  1583.         beq.s   cd15
  1584.         move.l  d0,a5
  1585.         cmp.b   #13,8(a5)
  1586.         beq.s   cd15
  1587.         bsr     syntax
  1588.         bra     cd18
  1589. cd15        cmp.l   wbaddr,d0
  1590.         bne.s   cd13
  1591.         move.l  #wberr,d0
  1592.         bsr     putnam
  1593.         bra     cd12
  1594. cd13        move.l  152(a5),d1
  1595.         move.l  remembr,152(a5)
  1596.         move.l  d1,remembr
  1597. cd12        tst.l   remembr
  1598.         beq.s   cd14
  1599.         bsr     ResumeOutput
  1600.         move.l  #unltxt,d0
  1601.         bsr     putstr
  1602.         move.l  remembr(PC),d0
  1603.         bsr     getpath
  1604.         move.l  #unltxt2,d0
  1605.         bsr     putstr
  1606.         bsr     readline
  1607.         ori.b   #$20,inputbuffer
  1608.         cmp.b   #'y',inputbuffer
  1609.         bne.s   cd14
  1610. cd18        move.l  remembr(PC),d1
  1611.         beq.s   cd14
  1612.         CALL    UnLock,dosbase(PC)
  1613. cd14        bsr     freefinfo
  1614. cd10        rts
  1615.  
  1616. ;Display the list of inputhandlers. It adds a dummy
  1617. ;input handler, grabs the list header, and removes it
  1618.  
  1619. inphand     tst.b   background
  1620.         bne.s   inph1
  1621.         bsr     installh
  1622. inph1        move.l  #500,d4
  1623.         lea     InInterrupt(PC),a0
  1624. inph2        tst.l   4(a0)
  1625.         beq.s   inph3
  1626.         move.l  4(a0),a0
  1627.         dbf     d4,inph2
  1628. inph3        tst.b   background
  1629.         bne.s   inph4
  1630.         movem.l d4/a0,-(a7)
  1631.         bsr     removeh
  1632.         movem.l (a7)+,d4/a0
  1633. inph4        cmp.w   #-1,d4
  1634.         bne.s   inph5
  1635.         move.l  #failed,d0
  1636.         bra     putnam
  1637. inph5        move.l  a0,-(a7)
  1638.         lea     inheader(PC),a0
  1639.         bsr     puthead
  1640.         move.l  (a7)+,a5
  1641. inph6        move.l  0(a5),a5
  1642.         tst.l   0(a5)
  1643.         beq.s   inph7
  1644.         move.l  a5,d0
  1645.         move.l  d0,node
  1646.         bsr     hexa
  1647.         move.l  14(a5),d0
  1648.         bsr     hexa
  1649.         move.l  18(a5),d0
  1650.         bsr     hexa
  1651.         move.b  9(a5),d3
  1652.         bsr     plusmins
  1653.         move.l  10(a5),d0
  1654. inph8        bsr     putnam
  1655.         bra.s   inph6
  1656. inph7        rts
  1657.  
  1658. ;get all screen pointers.
  1659. ;result: d5=number of screens
  1660. ;     buffer+100 holds pointers.
  1661.  
  1662. getscr        lea     scrheader(PC),a0
  1663.         bsr     puthead
  1664. getscr2     move.l  intuibase(PC),a2
  1665.         move.l  60(a2),a2
  1666.         lea     buffer+100,a1
  1667.         move.w  #$4000,$dff09a
  1668.         moveq   #0,d5
  1669. sr1        move.l  a2,(a1)+
  1670.         move.l  0(a2),a2
  1671.         addq.l  #1,d5
  1672.         cmpa.l  #0,a2
  1673.         bne.s   sr1
  1674.         subq    #1,d5
  1675.         move.w  #-$4000,$dff09a
  1676.         rts
  1677.  
  1678. ;display screen addresses and titles
  1679.  
  1680. screens     bsr     getscr
  1681.         moveq   #1,d6
  1682.         lea     buffer+100,a1
  1683. sr2        move    d6,d3
  1684.         bsr     bytedec
  1685.         move.l  0(a1),d0
  1686.         move.l  d0,node
  1687.         bsr     hexa
  1688.         move.l  (a1)+,a2
  1689.         move.l  22(a2),d0
  1690.         bsr     putnam
  1691.         addq    #1,d6
  1692.         dbf     d5,sr2
  1693.         rts
  1694.  
  1695. ;display window addresses and titles
  1696.  
  1697. windows     clr.b   bool
  1698. windows1    bsr     getscr
  1699.         tst.b   bool
  1700.         beq.s   wn20
  1701.         move.l  d5,-(a7)
  1702.         lea     fohead(PC),a0
  1703.         bsr     puthead
  1704.         move.l  (a7)+,d5
  1705. wn20        lea     buffer+100,a4
  1706. wn2        move.l  #onscr,d0
  1707.         bsr     putstr
  1708.         move.l  (a4)+,a2
  1709.         move.l  22(a2),d0
  1710.         bsr     putnam
  1711.         move.l  4(a2),a1
  1712.         moveq   #0,d6
  1713. wn1        cmpa.l  #0,a1
  1714.         beq.s   wn3
  1715.         addq    #1,d6
  1716.         move.l  d6,d3
  1717.         bsr     bytedec
  1718.         move.l  a1,d0
  1719.         move.l  d0,node
  1720.         bsr     hexa
  1721.         move.l  32(a1),d0
  1722.         bsr     putnam
  1723.  
  1724.         tst.b   bool
  1725.         beq.s   wn21
  1726.         move.l  a1,-(a7)
  1727.         move.l  50(a1),a1
  1728.         move.l  52(a1),a1
  1729.         bsr     fontdata
  1730.         move.l  (a7)+,a1
  1731.  
  1732. wn21        move.l  0(a1),a1
  1733.         bra.s   wn1
  1734. wn3        dbf     d5,wn2
  1735.         rts
  1736.  
  1737. ;close a specified screen
  1738.  
  1739. closescreen bsr     getscr2
  1740.         moveq   #1,d6
  1741.         cmp.b   #'$',0(a0)
  1742.         bne.s   cs1
  1743.         bsr     readhex
  1744.         tst     d7
  1745.         beq     syntax
  1746.         move.l  d0,d4
  1747. csin        moveq   #0,d6
  1748. cs1        lea     buffer+100,a2
  1749. cs5        tst     d6
  1750.         bne.s   cs2
  1751.         cmp.l   (a2)+,d4
  1752.         beq.s   cs3
  1753.         bra.s   cs4
  1754. cs2        move.l  (a2)+,a1
  1755.         move.l  22(a1),a1
  1756.         bsr     strcmp
  1757.         tst     d0
  1758.         beq.s   cs3
  1759. cs4        dbf     d5,cs5
  1760.         move.l  #scnofound,d0
  1761.         bra     putnam
  1762. cs3        move.l  -4(a2),a0
  1763.         CALL    CloseScreen,intuibase(PC)
  1764.         rts
  1765.  
  1766. ;close a specified window
  1767. closewindow bsr     getwnptr
  1768. clw        move.l  a4,d0
  1769.         beq.s   cwend
  1770. cw3        tst.l   36(a4)
  1771.         beq.s   cw8
  1772.         move.l  36(a4),a0
  1773.         move.w  28(a0),d0
  1774.         and.w   #$4000,d0
  1775.         beq.s   cw9
  1776.         move.l  a4,a0
  1777.         CALL    FreeSysRequest,intuibase(PC)
  1778.         rts
  1779. cw9        move.l  a4,a1
  1780.         CALL    EndRequest,intuibase(PC)
  1781.         bra.s   cw3
  1782. cw8        move.l  a4,a0
  1783.         moveq   #0,d0
  1784.         CALL    ModifyIDCMP,intuibase(PC)
  1785.         move.l  a4,a0
  1786.         CALL    CloseWindow,intuibase(PC)
  1787. cwend        rts
  1788.  
  1789.  
  1790. getwnptr    bsr     getscr2
  1791.         moveq   #1,d6
  1792.         cmp.b   #'$',0(a0)
  1793.         bne.s   cw1
  1794.         bsr     readhex
  1795.         tst     d7
  1796.         bne.s   cwin
  1797.         bsr     syntax
  1798.         bra.s   cwerr
  1799. cwin        move.l  d0,d4
  1800.         moveq   #0,d6
  1801. cw1        lea     buffer+100,a2
  1802. cw5        move.l  (a2)+,a4
  1803.         move.l  4(a4),a4
  1804. cw6        cmpa.l  #0,a4
  1805.         beq.s   cw4
  1806.         tst     d6
  1807.         bne.s   cw2
  1808.         cmp.l   a4,d4
  1809.         beq.s   cw10
  1810.         bra.s   cw7
  1811. cw2        move.l  32(a4),a1
  1812.         bsr     strcmp
  1813.         tst     d0
  1814.         beq.s   cw10
  1815. cw7        move.l  0(a4),a4
  1816.         bra.s   cw6
  1817. cw4        dbf     d5,cw5
  1818.         move.l  #winnofound,d0
  1819.         bsr     putnam
  1820. cwerr        suba.l  a4,a4
  1821. cw10        rts
  1822.  
  1823. windowoff   movem.l d1-d7/a0-a6,-(a7)
  1824.         bsr     getscr2
  1825.         bsr     cwin
  1826.         move.l  a4,d1
  1827.         beq.s   woff1
  1828.         bsr     clw
  1829.         move.l  -(a2),a0
  1830.         move.l  a0,d4
  1831.         tst.l   4(a0)
  1832.         bne.s   woff1
  1833.         bsr     getscr2
  1834.         bsr     csin
  1835. woff1        movem.l (a7)+,d1-d7/a0-a6
  1836.         rts
  1837.  
  1838. closetskwin movem.l d1-d7/a0-a6,-(a7)
  1839. ctw0        bsr     getscr2
  1840.         lea     buffer+100,a2
  1841. ctw1        move.l  (a2)+,a4
  1842.         move.l  4(a4),a4
  1843. ctw6        cmpa.l  #0,a4
  1844.         beq.s   ctw4
  1845.         move.l  86(a4),a0
  1846.         move.l  16(a0),d1
  1847.         cmp.l   d0,d1
  1848.         bne.s   ctw7
  1849.         move.l  d0,d1
  1850.         move.l  a4,d0
  1851.         bsr     windowoff
  1852.         move.l  d1,d0
  1853.         bra     ctw0
  1854. ctw7        move.l  0(a4),a4
  1855.         bra.s   ctw6
  1856. ctw4        dbf     d5,ctw1
  1857.         movem.l (a7)+,d1-d7/a0-a6
  1858.         rts
  1859.  
  1860. ;Change the font from a specified Window
  1861.  
  1862. setfont     bsr     nodenam
  1863.         tst.b   0(a5)
  1864.         beq     syntax
  1865.         move.l  a5,a4
  1866. 1$        cmp.b   #33,(a4)+
  1867.         bge.s   1$
  1868.         tst.b   -1(a4)
  1869.         beq     syntax
  1870.         clr.b   -1(a4)
  1871.  
  1872.         lea     dummy,a0
  1873.         move.l  a5,0(a0)
  1874.         move.b  procnum(PC),d0
  1875.         ext.w   d0
  1876.         move.w  d0,4(a0)
  1877.         clr.w   6(a0)
  1878.         CALL    OpenFont,gfxbase(PC)
  1879.         tst.l   d0
  1880.         bne.s   2$
  1881.         lea     diskfont(PC),a1
  1882.         CALL    OpenLibrary,_SysBase(PC)
  1883.         move.l  d0,d5
  1884.         beq.s   4$
  1885.         move.l  d0,a6
  1886.         lea     dummy,a0
  1887.         XREF    _LVOOpenDiskFont
  1888.         jsr     _LVOOpenDiskFont(a6)
  1889.         move.l  d0,d4
  1890.         move.l  d5,a1
  1891.         CALL    CloseLibrary,_SysBase(PC)
  1892.         move.l  d4,d0
  1893.         bne.s   2$
  1894. 4$        move.l  #fonterr,d0
  1895.         bsr     putstr
  1896.         move.l  dummy,d0
  1897.         bra     putnam
  1898. 2$        move.l  d0,-(a7)
  1899.         move.l  a4,a0
  1900.         bsr     kllblnks
  1901.         bsr     getwnptr
  1902.         move.l  (a7)+,a0
  1903.         move.l  a4,d1
  1904.         bne.s   5$
  1905.         move.l  a0,a1
  1906.         CALL    CloseFont,gfxbase(PC)
  1907.         bra.s   3$
  1908. 5$        move.l  50(a4),a1
  1909.         CALL    SetFont,gfxbase(PC)
  1910.         move.l  a4,a0
  1911.         CALL    RefreshWindowFrame,intuibase(PC)
  1912. 3$        rts
  1913.  
  1914.  
  1915. ;display windows and associated fonts
  1916.  
  1917. windowfonts move.b  #1,bool
  1918.         bra     windows1
  1919.  
  1920. ;display loaded font names and definitions
  1921.  
  1922. fonts        lea     fohead(PC),a0
  1923.         bsr     puthead
  1924.         move.l  gfxbase(PC),a1
  1925.         move.l  $8c(a1),a1
  1926. fo1        tst.l   0(a1)
  1927.         beq.s   fo3
  1928.         bsr     fontdata
  1929.         move.l  0(a1),a1
  1930.         bra     fo1
  1931. fo3        rts
  1932.  
  1933. fontdata    move.l  a1,d0
  1934.         move.l  d0,node
  1935.         bsr     hexa
  1936.         move.w  30(a1),d3
  1937.         bsr     bytedec
  1938.         move.w  20(a1),d3
  1939.         bsr     bytedec
  1940.         move.w  24(a1),d3
  1941.         bsr     bytedec
  1942.         move.l  #romfnt,d0
  1943.         btst    #1,23(a1)
  1944.         beq.s   fod1
  1945.         move.l  #diskfnt,d0
  1946. fod1        bsr     putstr
  1947.         move.b  32(a1),d3
  1948.         bsr     bytedec
  1949.         move.b  33(a1),d3
  1950.         bsr     bytedec
  1951.         move.l  10(a1),d0
  1952.         bra     putnam
  1953.  
  1954. ;set update rate
  1955.  
  1956. settime     bsr     getnum
  1957.         tst.b   d7
  1958.         bne.s   st1
  1959.         move.b  timeout(PC),d3
  1960.         bne.s   1$
  1961.         move.l  #timenotset,d0
  1962.         bra.s   sy1
  1963. 1$        move.l  #whattime,d0
  1964.         bsr     putstr
  1965.         bsr     bytedec
  1966.         bra     newline
  1967. st1        move.b  d2,timeout
  1968.         rts
  1969. syntax        move.l  #synerr,d0
  1970. sy1        bra     putnam
  1971.  
  1972. ;copy a string from input to 'buffer'
  1973. ;a0 = pointer to string
  1974.  
  1975. getstr        lea     buffer,a5
  1976. gst2        cmp.b   #' ',0(a0)
  1977.         beq.s   gst1
  1978.         cmp.b   #10,0(a0)
  1979.         beq.s   gst1
  1980.         move.b  (a0)+,(a5)+
  1981.         bra.s   gst2
  1982. gst1        clr.b   0(a5)
  1983.         bra     kllblnks
  1984.  
  1985. ;read in a nodename or a processname
  1986.  
  1987. nodenam     bsr     isdec
  1988.         move.b  d2,procnum
  1989. nodenam2    bsr     kllblnks
  1990.         move.l  a0,a5
  1991. gno1        cmp.b   #10,(a0)+
  1992.         bne.s   gno1
  1993.         move.b  #0,-1(a0)
  1994.         rts
  1995.  
  1996. ;modify a task's priority
  1997.  
  1998. taskpri     bsr     getnum
  1999.         tst.b   d7
  2000.         beq     syntax
  2001.         move.b  d2,newpri
  2002.         bsr     nodenam
  2003.         moveq.l #2,d7
  2004.         lea     TRuNode(PC),a4
  2005.         bsr     findnam
  2006.         tst.b   d7
  2007.         beq.s   tp1
  2008.         move.l  d0,a1
  2009.         move.b  newpri,d0
  2010.         CALL    SetTaskPri,_SysBase(PC)
  2011. tp1        rts
  2012.  
  2013. ;set the priority of our task
  2014.  
  2015. mypri        bsr     getnum
  2016.         tst.b   d7
  2017.         beq     syntax
  2018.         move.l  _SysBase(PC),a1
  2019.         move.l  276(a1),a1
  2020.         move.l  d2,d0
  2021.         CALL    SetTaskPri,_SysBase(PC)
  2022.         rts
  2023.  
  2024. ;cancel a task or a process. The theory is quite simple:
  2025. ;(Process->ReturnAddr)-4 points to the return address on
  2026. ;the stack. Task->SPReg points to the next instruction
  2027. ;to be executed. We just need a
  2028. ; *(Task->SPReg) = *(Process->ReturnAddr-4).
  2029. ;If the process has been started from Dos (CLI) and
  2030. ;the process is doing disk I/O, the CLI will respond with
  2031. ;a GURU #87000004 (AsyncPKT=unexpected packed received).
  2032. ;Thats why the calling CLI is also canceled.
  2033.  
  2034.  
  2035. cancel        tst.b   fromfile
  2036.         beq.s   cancel1
  2037.         rts
  2038. cancel1     clr.l   remembr        ;used for CLI stdio
  2039.         clr.l   remembr2
  2040.         clr.b   bool
  2041.         bsr     nodenam
  2042. testagain   moveq.l #1,d7
  2043.         lea     TReNode(PC),a4
  2044.         bsr     findnam
  2045.         tst.b   d7
  2046.         bne.s   canok
  2047. cnerr        move.l  #stperr,d0
  2048.         bra     putnam
  2049.  
  2050. canok        move.l  d0,a1       ;d0=task
  2051.         move.l  d0,pointer
  2052.         cmp.b   #1,8(a1)       ;TASK ?
  2053.         bne.s   isproc
  2054.         CALL    RemTask,_SysBase(PC)
  2055.         move.l  pointer(PC),d0
  2056.         bra     closetskwin
  2057.  
  2058. isproc        movem.l d0-d7/a0-a6,-(a7)
  2059.         move.l  #-1,d0          ;needed for recursive killing tasks
  2060.         CALL    AllocSignal,_SysBase(PC)
  2061.         moveq   #0,d1
  2062.         bset    d0,d1
  2063.         move.l  d1,cancelbit
  2064.         move.l  d0,cancelbnum
  2065.         movem.l (a7)+,d0-d7/a0-a6
  2066.  
  2067.         moveq   #0,d5
  2068.         tst.l   $ac(a1)         ;pr_CLI
  2069.         beq.s   wascreproc
  2070.         move.l  $80(a1),a2      ;Seglist
  2071.         adda.l  a2,a2
  2072.         adda.l  a2,a2
  2073.         move.l  12(a2),d1       ;empty ?
  2074.         bne.s   wascreproc
  2075.         move.l  $ac(a1),a2      ;CommandLineInterface
  2076.         adda.l  a2,a2
  2077.         adda.l  a2,a2
  2078.         move.l  60(a2),d5       ;cli_Module
  2079.         tst.l   40(a2)          ;IsInteractive
  2080.         beq     dosreturn
  2081.         move.l  28(a2),remembr  ;yes,get Cli-Window locks
  2082.         move.l  56(a2),remembr2
  2083.         bra     dosreturn
  2084. wascreproc  tst.b   bool        ;it is not a CLI, ask what to do
  2085.         bne     unload
  2086.         move.b  #3,bool
  2087.         bsr     ResumeOutput
  2088.         move.l  #canerr0,d0     ;ask for Workbench
  2089.         bsr     putstr
  2090.         bsr     readline
  2091.         cmp.b   #'y',inputbuffer
  2092.         beq.s   andagain
  2093.         move.b  #2,bool
  2094.         bsr     ResumeOutput
  2095.         move.l  #canerr1,d0    ;ask for unload
  2096.         bsr     putstr
  2097.         bsr     readline
  2098.         cmp.b   #'y',inputbuffer
  2099.         bne.s   andagain
  2100.         move.b  #1,bool
  2101. andagain    move.l  pointer(PC),d0
  2102.         moveq.l #1,d7
  2103.         lea     TReNode(PC),a4
  2104.         bsr     tstnode
  2105.         tst     d5
  2106.         beq     cnerr
  2107.         bra     canok
  2108.  
  2109. unload        move.l  128(a1),d4 ;get Segmentlist
  2110.         beq.s   unl3
  2111.         lsl.l   #2,d4
  2112.         move.l  d4,a3
  2113.         move.l  12(a3),d4
  2114. unl3        tst.l   d4
  2115.         bne.s   unl4
  2116.         move.l  #unloaderr,d0 ;no Segments !?
  2117.         bra     putnam
  2118.  
  2119. unl4        cmp.b   #3,bool           ;Workbench Task
  2120.         bne.s   unl2
  2121.         move.l  a1,-(a7)
  2122.         moveq   #40,d0           ;build a copy of the
  2123.         move.l  #$10000,d1           ;Workbench startup-message
  2124.         CALL    AllocMem,_SysBase(PC)
  2125.         move.l  d0,startmess
  2126.         move.l  (a7)+,a1
  2127.         move.l  d0,a0
  2128.         move.b  #5,8(a0)
  2129.         move.w  #20,18(a0)
  2130.         move.l  d4,24(a0)
  2131.         move.l  a1,d0
  2132.         add.l   #92,d0
  2133.         move.l  d0,20(a0)
  2134.         movem.l a0-a1,-(a7)
  2135.         lea     wbname(PC),a1
  2136.         CALL    FindPort,_SysBase(PC)
  2137.         movem.l (a7)+,a0-a1
  2138.         move.l  d0,14(a0)
  2139.  
  2140. unl2        cmp.b   #1,bool
  2141.         bne.s   dosreturn
  2142.         move.l  a1,-(a7)           ;unload process manualy
  2143.         move.l  d4,d1
  2144.         CALL    UnLoadSeg,dosbase(PC)
  2145.         move.l  (a7)+,a1
  2146.  
  2147. dosreturn   move.l  140(a1),savedat ;Processnumber
  2148. dosret1     move.w  #$4000,$dff09a
  2149.         move.l  54(a1),a3
  2150.         move.l  #endtask,0(a3)
  2151.         move.l  #2,106(a1)
  2152.         move.l  mytask(PC),108(a1)
  2153.         cmp.b   #4,15(a1)        ;if waiting
  2154.         bne.s   doswait
  2155.         move.l  a1,d4
  2156.         CALL    Remove,_SysBase(PC)
  2157.         move.l  d4,a1
  2158.         lea     406(a6),a0       ; activate the task
  2159.         CALL    AddHead,_SysBase(PC)
  2160.         move.l  d4,a1
  2161. doswait     move.w  #-$4000,$dff09a
  2162.         tst.b   bool
  2163.         bne.s   endnodos
  2164.         tst.l   d5
  2165.         beq     endcanc
  2166.         move.l  $ac(a1),a2
  2167.         adda.l  a2,a2
  2168.         adda.l  a2,a2
  2169. dwa1        movem.l d0-d7/a0-a6,-(a7)
  2170.         move.l  cancelbit(PC),d0
  2171.         CALL    Wait,_SysBase(PC)
  2172.         movem.l (a7)+,d0-d7/a0-a6
  2173.         moveq   #0,d5
  2174.         bra     dosret1
  2175.  
  2176. endcanc     move.l  a1,-(a7)
  2177.         move.l  remembr(PC),d1    ;close CLI-Window
  2178.         beq.s   ecan1          ;if any
  2179.         CALL    Close,dosbase(PC)
  2180. ecan1        move.l  remembr2(PC),d1
  2181.         beq.s   ecan2
  2182.         CALL    Close,dosbase(PC)
  2183. ecan2        move.l  (a7)+,a1
  2184.  
  2185.         move.l  savedat(PC),d0   ;remove Task from
  2186.         move.l  dosbase(PC),a2   ;TaskArray
  2187.         move.l  34(a2),a2
  2188.         move.l  0(a2),a2
  2189.         adda.l  a2,a2
  2190.         adda.l  a2,a2
  2191.         lsl.l   #2,d0
  2192.         clr.l   0(a2,d0)
  2193.  
  2194. endnodos    move.l  a1,d0
  2195.         bsr     closetskwin
  2196.         move.l  cancelbnum(PC),d0      ;remove our Signal
  2197.         CALL    FreeSignal,_SysBase(PC)
  2198.         rts
  2199.  
  2200. ;This Code is (hopefully) excuted by the Process we want
  2201. ;to kill
  2202.  
  2203. endtask     CALL    Forbid,_SysBase(PC)
  2204.         CALL    Disable,_SysBase(PC)
  2205.         move.l  _SysBase(PC),a1
  2206.         move.l  276(a1),a1
  2207.         move.l  176(a1),a1          ;Process_ReturnAddr
  2208.         lea     -4(a1),a7           ;reset Process Stackptr
  2209.         tst.b   bool
  2210.         bne.s   et0
  2211.         movea.l mytask(PC),a1
  2212.         move.l  cancelbit(PC),d0    ;signal Xoper it
  2213.         CALL    Signal,_SysBase(PC) ;died
  2214. et0        cmp.b   #3,bool        ;Workbench Process ?
  2215.         bne.s   et1
  2216.         move.l  startmess(PC),a1
  2217.         CALL    ReplyMsg,_SysBase(PC) ;reply startup message
  2218. et1        rts
  2219.  
  2220. ;Stop a task (just queue it on a special list)
  2221.  
  2222. freeze        bsr     nodenam
  2223.         moveq.l #1,d7
  2224.         lea     TReNode(PC),a4
  2225.         bsr     findnam
  2226.         tst.b   d7
  2227.         bne.s   frok
  2228.         move.l  #stperr,d0
  2229.         bra     putstr
  2230. frok        move.w  #$4000,$dff09a
  2231.         move.l  d0,a1
  2232.         CALL    Remove,_SysBase(PC)
  2233.         move.w  #-$4000,$dff09a
  2234.         move.l  d0,a1
  2235.         move.l  d0,a5
  2236.         lea     stplist(PC),a0
  2237.         CALL    AddHead,_SysBase(PC)
  2238.         add.b   #4,15(a5)
  2239.         rts
  2240. ;put the task back on its list
  2241. warm        bsr     nodenam
  2242.         cmp.b   #'$',0(a5)
  2243.         bne.s   1$
  2244.         move.l  d7,d2
  2245.         move.l  a5,a0
  2246.         bsr     readhex
  2247.         tst.b   d7
  2248.         beq.s   1$
  2249.         move.l  stplist(PC),a3
  2250. 3$        tst.l   0(a3)
  2251.         beq.s   2$
  2252.         cmp.l   a3,d0
  2253.         beq.s   waok
  2254.         move.l  0(a3),a3
  2255.         bra.s   3$
  2256. 1$        lea     stplist(PC),a0
  2257.         movea.l a5,a1
  2258.         moveq   #0,d7
  2259.         bsr     fn4
  2260.         tst.b   d7
  2261.         bne.s   waok
  2262. 2$        move.l  #waerr,d0
  2263.         bra     putstr
  2264. waok        move.w  #$4000,$dff09a
  2265.         move.l  d0,a1
  2266.         CALL    Remove,_SysBase(PC)
  2267.         move.l  d0,a1
  2268.         move.l  d0,a5
  2269.         move.l  TReNode,a0
  2270.         cmp.b   #8,15(a1)
  2271.         bne.s   wa1
  2272.         move.l  TWaNode,a0
  2273. wa1        adda.l  _SysBase(PC),a0
  2274.         CALL    AddTail,_SysBase(PC)
  2275.         move.l  d0,a1
  2276.         subq.b  #4,15(a5)
  2277.         move.w  #-$4000,$dff09a
  2278.         move.l  18(a5),d0
  2279.         and.l   26(a5),d0
  2280.         beq.s   wa2
  2281.         movea.l a5,a1
  2282.         CALL    Signal,_SysBase(PC)
  2283. wa2        rts
  2284. ;show the hunks of a process
  2285. hunks        bsr     nodenam
  2286.         moveq.l #2,d7
  2287.         lea     TRuNode(PC),a4
  2288.         bsr     findnam
  2289.         tst.b   d7
  2290.         bne.s   hu1
  2291.         rts
  2292. hu1        move.l  d0,a4
  2293.         cmp.b   #13,8(a4)
  2294.         beq.s   hu2
  2295.         move.l  #noprocs,d0
  2296.         bra     putnam
  2297. hu2        move.l  128(a4),d0
  2298.         beq.s   noprogload
  2299.         lsl.l   #2,d0
  2300.         move.l  d0,a3
  2301.         move.l  12(a3),d1
  2302.         beq.s   hu3
  2303.         move.l  #segloaded,d0
  2304.         bsr     putnam
  2305.         bra     hu5
  2306. hu3        move.l  172(a4),d1
  2307.         bne.s   hu4
  2308. noprogload  move.l  #notload,d0
  2309.         bra     putnam
  2310. hu4        move.l  #cliprocs,d0
  2311.         bsr     putnam
  2312.         lsl.l   #2,d1
  2313.         move.l  d1,a4
  2314.         move.l  60(a4),d1
  2315.         beq.s   noprogload
  2316.         move.l  #procloaded,d0
  2317.         bsr     putstr
  2318.         move.l  16(a4),d0
  2319.         bsr     putbcpl
  2320.         bsr     newline
  2321. hu5        lea     hunkheader(PC),a0
  2322.         bsr     puthead
  2323.         moveq   #0,d5
  2324. hu6        move.l  d5,d3
  2325.         bsr     bytedec
  2326.         addq    #1,d5
  2327.         move.l  d1,d0
  2328.         bsr     hexa
  2329.         lsl.l   #2,d1
  2330.         move.l  d1,a4
  2331.         move.l  d1,d0
  2332.         addq.l  #4,d0
  2333.         bsr     hexa
  2334.         move.l  -4(a4),d0
  2335.         bsr     hexa
  2336.         bsr     newline
  2337.         move.l  0(a4),d1
  2338.         bne.s   hu6
  2339.         rts
  2340. ;change the priority of a node
  2341. pri        bsr     getnum
  2342.         tst.b   d7
  2343.         beq     syntax
  2344.         move.b  d2,newpri
  2345.         bsr     nodenam2
  2346.         moveq.l #5,d7
  2347.         lea     DevNode(PC),a4
  2348.         bsr     findnam
  2349.         tst.b   d7
  2350.         beq.s   pi1
  2351.         move.l  d0,a1
  2352.         move.b  newpri,9(a1)
  2353.         cmp.l   #SemNode,a4
  2354.         ble.s   pi2
  2355.         move.l  #listerr,d0
  2356.         bra     putnam
  2357. pi2        CALL    Forbid,_SysBase(PC)
  2358.         CALL    Remove,_SysBase(PC)
  2359.         move.l  d0,a1
  2360.         move.l  a4,a0
  2361.         move.l  0(a0),d6
  2362.         lea     0(a6,d6),a0
  2363.         CALL    Enqueue,_SysBase(PC)
  2364.         CALL    Permit,_SysBase(PC)
  2365. pi1        rts
  2366. ;set all break signals of a task
  2367. break        move.l  #$f000,d0
  2368.         bra     setthem
  2369.  
  2370. signal        bsr     readhex
  2371.         tst.b   d7
  2372.         beq     syntax
  2373. setthem     move.l  d0,savedat
  2374.         bsr     nodenam
  2375.         moveq.l #2,d7
  2376.         lea     TReNode(PC),a4
  2377.         bsr     findnam
  2378.         tst.b   d7
  2379.         beq.s   pi1
  2380.         move.l  d0,a1
  2381.         move.l  savedat,d0
  2382.         and.l   18(a1),d0
  2383.         CALL    Signal,_SysBase(PC)
  2384.         rts
  2385.  
  2386. ;set up a list of tasknames which should't be displayed
  2387.  
  2388. hide        cmp.b   #10,0(a0)
  2389.         bne.s   hid5
  2390.         bra     syntax
  2391. hid5        lea     hidestart(PC),a2
  2392.         move.l  a2,d3
  2393. hid0        tst.l   0(a2)
  2394.         beq.s   hid1
  2395.         move.l  0(a2),a2
  2396.         lea     4(a2),a1
  2397.         bsr     strcmp
  2398.         tst     d0
  2399.         beq.s   hid2
  2400.         move.l  a2,d3
  2401.         bra.s   hid0
  2402. hid1        move.l  a0,a4
  2403.         bsr     strlen2
  2404.         addq    #5,d0
  2405.         move.l  #65536,d1
  2406.         CALL    AllocMem,_SysBase(PC)
  2407.         tst.l   d0
  2408.         beq.s   hid4
  2409.         move.l  d0,a1
  2410.         move.l  d0,0(a2)
  2411.         addq    #4,a1
  2412. hid3        cmp.b   #10,0(a4)
  2413.         beq.s   hid4
  2414.         move.b  (a4)+,(a1)+
  2415.         bra.s   hid3
  2416. hid4        rts
  2417. hid2        move.l  d3,a3
  2418.         move.l  0(a2),0(a3)
  2419. freehidden  lea     4(a2),a0
  2420.         bsr     strlen
  2421.         addq    #5,d0
  2422.         move.l  a2,a1
  2423.         CALL    FreeMem,_SysBase(PC)
  2424.         rts
  2425.  
  2426. freehidmem  move.l  hidestart(PC),a4
  2427. fhm0        move.l  a4,d0
  2428.         beq.s   fhm1
  2429.         move.l  a4,a2
  2430.         move.l  0(a2),a4
  2431.         bsr     freehidden
  2432.         bra     fhm0
  2433. fhm1        rts
  2434.  
  2435. ;set up an ALIAS list
  2436. alias        cmp.b   #10,0(a0)
  2437.         beq     showalias
  2438.         bsr     strbuf
  2439.         move.l  a0,a5
  2440.         lea     buffer,a0
  2441.         bsr     strlen
  2442.         tst.l   d0
  2443.         beq     syntax
  2444.  
  2445.         moveq   #1,d1
  2446.         cmp     d1,d0
  2447.         bne.s   5$
  2448.         lea     params(PC),a0
  2449.         moveq   #parmnum-1,d1
  2450.         move.b  buffer,d2
  2451. 6$        cmp.b   (a0)+,d2
  2452.         dbeq    d1,6$
  2453.         tst.w   d1
  2454.         bmi.s   5$
  2455.         move.l  #aliaserr,d0
  2456.         bsr     putstr
  2457.         move.l  #params,d0
  2458.         bsr     putstr
  2459.         move.l  #aliaserr2,d0
  2460.         bra     putnam
  2461.  
  2462. 5$        move.l  d0,d5
  2463.         move.l  a5,a0
  2464.         adda.l  d0,a0
  2465.         bsr     kllblnks
  2466.         move.l  a5,-(a7)
  2467.         bsr     findcmd
  2468.         move.l  (a7)+,a5
  2469.         tst.l   d2
  2470.         bmi     syntax
  2471.         move.l  a5,a0
  2472.         bsr     strbuf
  2473.  
  2474.         addq    #6,d5
  2475.         move.l  d5,d0
  2476.         move.l  #65536,d1
  2477.         CALL    AllocMem,_SysBase(PC)
  2478.         tst.l   d0
  2479.         beq.s   1$
  2480.  
  2481.         move.l  aliaslist(PC),d1
  2482.         bne.s   2$
  2483.         move.l  d0,aliaslist
  2484.         bra.s   3$
  2485. 2$        move.l  d1,a0
  2486.         move.l  0(a0),d1
  2487.         bne.s   2$
  2488.         move.l  d0,0(a0)
  2489.  
  2490. 3$        move.l  d0,a0
  2491.         move.b  d2,4(a0)
  2492.  
  2493.         lea     5(a0),a0
  2494.         lea     buffer,a1
  2495. 4$        move.b  (a1)+,(a0)+
  2496.         bne.s   4$
  2497. 1$        rts
  2498.  
  2499. showalias   lea     alhead(PC),a0
  2500.         bsr     puthead
  2501.         move.l  aliaslist(PC),d0
  2502.         beq.s   1$
  2503. 2$        move.l  d0,a5
  2504.         addq    #5,d0
  2505.         bsr     putstr
  2506.         move.w  #15,d1
  2507.         bsr     tab
  2508.         move.l  #equal,d0
  2509.         bsr     putstr
  2510.         move.b  4(a5),d0
  2511.         ext.w   d0
  2512.         bsr     getcmdptr
  2513.         bsr     putnam
  2514.         move.l  0(a5),d0
  2515.         bne.s   2$
  2516. 1$        rts
  2517.  
  2518. freealias   move.l  aliaslist(PC),a4
  2519. 1$        move.l  a4,d0
  2520.         beq.s   2$
  2521.         move.l  a4,a2
  2522.         move.l  0(a2),a4
  2523.         lea     5(a2),a0
  2524.         bsr     strlen
  2525.         addq    #6,d0
  2526.         move.l  a2,a1
  2527.         CALL    FreeMem,_SysBase(PC)
  2528.         bra     1$
  2529. 2$        rts
  2530.  
  2531. getcmdptr   move.l  a0,-(a7)
  2532.         lea     commds(PC),a0
  2533. 2$        tst     d0
  2534.         beq.s   1$
  2535. 3$        tst.b   (a0)+
  2536.         bne.s   3$
  2537.         subq    #1,d0
  2538.         bra.s   2$
  2539. 1$        move.l  a0,d0
  2540.         move.l  (a7)+,a0
  2541.         rts
  2542.  
  2543.  
  2544. ;'flushlibs'
  2545. flush        move.l  #$ffffff,d0
  2546.         moveq   #0,d1
  2547.         CALL    AllocMem,_SysBase(PC)
  2548. flsh1        rts
  2549.  
  2550. ;display library->lib_IDString
  2551. info        bsr     nodenam2
  2552.         moveq.l #2,d7
  2553.         lea     DevNode(PC),a4
  2554.         bsr     findnam
  2555.         tst.b   d7
  2556.         beq.s   flsh1
  2557.         move.l  d0,a0
  2558.         move.l  24(a0),d0
  2559.         beq.s   if1
  2560.         move.l  d0,d1
  2561.         andi.l  #1,d1
  2562.         bne.s   if1
  2563.         bra     putnam
  2564. if1        move.l  #noinfo,d0
  2565.         bsr     putstr
  2566.         move.l  a5,d0
  2567.         bra     putnam
  2568.  
  2569. capture     move.l  _SysBase(PC),a1
  2570.         lea     42(a1),a0
  2571.         moveq   #2,d6
  2572.         lea     coldtxt,a4
  2573. cap0        move.l  a4,d0
  2574.         bsr     putstr
  2575.         move.l  0(a0),d0
  2576.         bne.s   cap1
  2577.         move.l  #unset,d0
  2578.         bsr     putstr
  2579.         bra     cap2
  2580. cap1        bsr     hexa
  2581. cap2        bsr     newline
  2582.         lea     15(a4),a4
  2583.         addq    #4,a0
  2584.         dbf     d6,cap0
  2585.  
  2586.         move.l  #kicktxt,d0
  2587.         bsr     putstr
  2588.         move.l  546(a1),a0
  2589.         cmpa.l  #0,a0
  2590.         bne.s   kickm3
  2591.         move.l  #unset,d0
  2592.         bra     putnam
  2593. kickm3        move.l  a0,-(a7)
  2594.         bsr     newline
  2595.         lea     kickhead(PC),a0
  2596.         bsr     puthead
  2597.         move.l  (a7)+,a0
  2598. kickm0        move.l  a0,d0
  2599.         beq     kickm4
  2600.         bpl.s   kickm1
  2601.         bclr    #31,d0
  2602.         move.l  d0,a0
  2603.         bra.s   kickm0
  2604. kickm1        move.w  14(a0),d6
  2605.         subq    #1,d6
  2606.         lea     16(a0),a2
  2607. kickm2        move.l  0(a2),d0
  2608.         bsr     hexa
  2609.         move.l  0(a2),d0
  2610.         move.l  4(a2),d4
  2611.         add.l   d4,d0
  2612.         bsr     hexa
  2613.         move.l  d4,d0
  2614.         clr.b   d3
  2615.         bsr     longdec
  2616.         bsr     newline
  2617.         addq    #8,a2
  2618.         dbf     d6,kickm2
  2619.         move.l  0(a0),a0
  2620.         bra     kickm0
  2621. kickm4        rts
  2622.  
  2623. clrcold     move.l  _SysBase,a0
  2624.         clr.l   42(a0)
  2625.         bra.s   chksum
  2626. clrcool     move.l  _SysBase,a0
  2627.         clr.l   46(a0)
  2628.         bra.s   chksum
  2629. clrwarm     move.l  _SysBase,a0
  2630.         clr.l   50(a0)
  2631.  
  2632. chksum        lea     34(a0),a1
  2633.         move    #22,d0
  2634. addchk        add     (a1)+,d1
  2635.         dbf     d0,addchk
  2636.         not     d1
  2637.         move.w  d1,82(a0)
  2638.         rts
  2639.  
  2640. ;Save the command line to be repeated. If this line doesn't produce
  2641. ;any output, don't repeat it at all
  2642. repeatcmd   tst.w   repeat
  2643.         bne.s   2$
  2644.         move.w  repeatlen(PC),d0
  2645.         subq    #7,d0
  2646.         move.w  d0,repeatlen
  2647.         lea     repeatbuffer,a1
  2648.         lea     dummy,a2
  2649.         move.w  d0,d1
  2650.         ext.l   d1
  2651. 1$        move.b  0(a0),(a1)+
  2652.         move.b  (a0)+,(a2)+
  2653.         dbf     d1,1$
  2654.  
  2655.         clr.l   lastprinted
  2656.         clr.b   printed
  2657.         move.w  #1,repeat
  2658.         bsr     cli
  2659.         tst.b   printed
  2660.         beq.s   2$
  2661.         bsr     starttimer
  2662.         rts
  2663. 2$        clr.w   repeat
  2664.         rts
  2665.  
  2666. ;save the parameters from a 'window x y width height' call
  2667. setwindow   tst.b   fromfile
  2668.         bne.s   wiw1
  2669. wiw3        move.l  #wiwerr,d0
  2670.         bra     putnam
  2671. wiw1        lea     window_l(PC),a3
  2672.         moveq   #3,d5
  2673. wiw0        bsr     getnum
  2674.         tst     d7
  2675.         beq.s   wiw2
  2676.         move.w  d2,0(a3)
  2677.         addq    #2,a3
  2678.         dbf     d5,wiw0
  2679. wiw2        rts
  2680.  
  2681. ;display ExecBase->LastAlert
  2682. lastalert   movem.l $100,d1-d2
  2683.         tst.l   d1
  2684.         bne.s   al1
  2685.         move.l  _SysBase(PC),a0
  2686.         movem.l 514(a0),d1-d2
  2687. al1        move.l  #gurutxt,d0
  2688.         bsr     putstr
  2689.         move.l  d1,d0
  2690.         bsr     hexa
  2691.         lea     out,a0
  2692.         move.l  ptr(PC),d0
  2693.         move.b  #'.',-1(a0,d0)
  2694.         move.l  d2,d0
  2695.         bsr     hexa
  2696.         bra     newline
  2697.  
  2698. ;toggle CPUSE task list
  2699. usage        bchg    #0,usageflag
  2700.         rts
  2701.  
  2702. ;toggle task-header display on/off
  2703. nohead        bchg    #0,headon
  2704.         rts
  2705.  
  2706. ;toggle hide entries on/off
  2707. hidden        bchg    #0,hideon
  2708.         rts
  2709.  
  2710. ;toggle sort on/off
  2711. sort       bchg    #0,sorton
  2712.        rts
  2713.  
  2714. ;toggle task-ports display on/off
  2715. taskports   bchg    #0,tports
  2716. clo1        rts
  2717.  
  2718. ;Open a library
  2719. openlib     bsr     nodenam2
  2720.         move.l  a5,a1
  2721.         moveq   #0,d0
  2722.         CALL    OpenLibrary,_SysBase(PC)
  2723.         tst.l   d0
  2724.         beq     fn5
  2725. opli1        rts
  2726.  
  2727.  
  2728. ;close it
  2729. closelib    bsr     nodenam2
  2730.         moveq   #0,d7
  2731.         lea     LibNode(PC),a4
  2732.         bsr     findnam
  2733.         tst.b   d7
  2734.         beq.s   clo1
  2735.         move.l  d0,a1
  2736.         CALL    CloseLibrary,_SysBase(PC)
  2737.         rts
  2738.  
  2739. remnode     bsr     nodenam2
  2740.         moveq   #7,d7
  2741.         lea     TReNode(PC),a4
  2742.         bsr     findnam
  2743.         tst.b   d7
  2744.         beq.s   1$
  2745.         CALL    Disable,_SysBase(PC)
  2746.         move.l  d0,a1
  2747.         CALL    Remove,_SysBase(PC)
  2748.         CALL    Enable,_SysBase(PC)
  2749. 1$        rts
  2750.  
  2751. ;end Xoper but stay in background
  2752. hold        addq    #4,a7
  2753.         bra.s   instback
  2754. quithold    lea     in,a0
  2755.         lea     dummy,a1
  2756. qh1        move.b  (a1)+,d0
  2757.         move.b  d0,(a0)+
  2758.         cmp.b   #10,d0
  2759.         bne.s   qh1
  2760.  
  2761. instback    tst.b   background
  2762.         bne.s   cleanit
  2763.         move.b  #1,background
  2764.         bsr     installh
  2765. cleanit     move.l  fileptr(PC),d1
  2766.         beq.s   ib1
  2767.         CALL    Close,dosbase(PC)
  2768.         clr.l   fileptr
  2769. ib1        clr.b   running
  2770.         bsr     killpage
  2771.         bsr     freeblank
  2772.         tst.l   wnptr
  2773.         beq.s   5$
  2774.         tst.b   ownscreen
  2775.         bne.s   6$
  2776.         move.l  wnptr(PC),a0
  2777.         move.l  4(a0),window_l
  2778.         move.l  8(a0),window_w
  2779. 6$        move.l  wnptr(PC),a0
  2780.         CALL    CloseWindow,intuibase(PC)
  2781.         clr.l   intuimsg
  2782.         clr.l   wnptr
  2783. 5$        tst.b   ownscreen
  2784.         beq.s   4$
  2785.         move.l  screenptr(PC),a0
  2786.         CALL    CloseScreen,intuibase(PC)
  2787.         clr.l   screenptr
  2788.  
  2789. 4$        tst.b   iconifyon
  2790.         beq.s   1$
  2791.         jsr     iconify
  2792.         bra.s   2$
  2793.  
  2794. 1$        move.l  mysignal(PC),d0
  2795.         or.l    trapsignal(PC),d0
  2796.         CALL    Wait,_SysBase(PC)
  2797. 2$        move.b  #1,running
  2798.         and.l   trapsignal(PC),d0
  2799.         beq.s   3$
  2800.         move.b  #1,gotguru
  2801. 3$        bra     restart
  2802.  
  2803. ;fill all unused memory-chunks with a longword
  2804. clear        moveq   #0,d0
  2805.         cmp.b   #10,0(a0)
  2806.         beq.s   clr5
  2807.         bsr     readhex
  2808.         tst.b   d7
  2809.         beq     syntax
  2810. clr5        move.l  _SysBase(PC),a0
  2811.         clr.l   parmtxt
  2812.         lea     322(a0),a0
  2813.         move.w  #$4000,$dff09a
  2814. clr1        move.l  0(a0),a0
  2815.         tst.l   0(a0)
  2816.         beq.s   clr4
  2817.         move.l  16(a0),a1
  2818. clr2        tst.l   0(a1)
  2819.         beq.s   clr1
  2820.         addq.l  #1,parmtxt
  2821.         move.l  4(a1),d1
  2822.         subq.l  #8,d1
  2823.         beq.s   clr31
  2824.         lsr.l   #2,d1
  2825.         subq.l  #1,d1
  2826.         lea     8(a1),a2
  2827. clr3        move.l  d0,(a2)+
  2828.         dbf     d1,clr3
  2829. clr31        move.l  0(a1),a1
  2830.         bra.s   clr2
  2831. clr4        move.w  #-$4000,$dff09a
  2832.         move.l  parmtxt(PC),d0
  2833.         bsr     bytedec
  2834.         move.l  #clrtxt,d0
  2835.         bra     putnam
  2836.  
  2837. ;change the number of maximum lines in the history buffer
  2838. historylines
  2839.         bsr     getnum
  2840.         tst.b   d7
  2841.         beq     syntax
  2842.         move.w  d2,maxhlines
  2843.         move.w  hnum(PC),d0
  2844. 1$        cmp.w   maxhlines(PC),d0
  2845.         ble.s   2$
  2846.         bsr     remhistline
  2847.         subq    #1,d0
  2848.         bra.s   1$
  2849. 2$        move.l  history+8,curhist
  2850.         move.w  d0,hnum
  2851.         rts
  2852. ;set the minimum number of characters a input line
  2853. ;must have to be added to the history buffer
  2854. historylength
  2855.         bsr     getnum
  2856.         tst.b   d7
  2857.         beq     syntax
  2858.         tst.b   d2
  2859.         bne.s   1$
  2860.         addq    #1,d2
  2861. 1$        move.w  d2,minnumchars
  2862.         rts
  2863. ;display all lines in the history buffer
  2864. showhistory move.l  history(PC),a5
  2865.         moveq   #1,d5
  2866. 1$        tst.l   0(a5)
  2867.         beq.s   2$
  2868.         move.l  d5,d3
  2869.         bsr     bytedec
  2870.         move.w  8(a5),d0
  2871.         ext.l   d0
  2872.         lea     10(a5),a0
  2873.         lea     inputbuffer,a1
  2874.         CALL    CopyMem,_SysBase(PC)
  2875.         move.w  8(a5),d0
  2876.         lea     inputbuffer,a1
  2877.         clr.b   0(a1,d0.w)
  2878.         move.l  a1,d0
  2879.         bsr     putnam
  2880.         addq    #1,d5
  2881.         move.l  0(a5),a5
  2882.         bra.s   1$
  2883. 2$        rts
  2884.  
  2885. ;set the maximum lines the output buffer may hold
  2886. outputlines bsr     getnum
  2887.         tst.b   d7
  2888.         beq     syntax
  2889.         moveq   #100,d3
  2890.         tst.l   d2
  2891.         bmi.s   2$
  2892.         cmp.l   d3,d2
  2893.         bge.s   1$
  2894. 2$        move.l  d3,d2
  2895. 1$        move.l  d2,maxlines
  2896.         rts
  2897.  
  2898. ;find a named node
  2899. ;d7 = number of lists to search through
  2900. ;a4 = pointer to the first entry in the
  2901. ;     list-offset-table
  2902. ;a5 = pointer to name
  2903. ;returns:
  2904. ;d7 = TRUE/FALSE 1/0
  2905. ;d0 = node
  2906.  
  2907. findnam     tst.b   0(a5)
  2908.         bne.s   1$
  2909.         move.l  #nameerr,d0
  2910.         bsr     putnam
  2911.         bra     fnerr
  2912. 1$        cmp.b   #'$',0(a5)
  2913.         bne.s   fn2
  2914.         move.l  d7,d2
  2915.         move.l  a5,a0
  2916.         bsr     readhex
  2917.         tst.b   d7
  2918.         beq.s   fn6
  2919.         move.l  d2,d7
  2920.         bsr     tstnode
  2921.         tst.l   d5
  2922.         bne.s   fn3
  2923.         bra     fn5
  2924. fn6        move.l  d2,d7
  2925. fn2        move.l  _SysBase(PC),a0
  2926.         adda.l  0(a4),a0
  2927.         move.l  a5,a1
  2928. fn4        CALL    FindName,_SysBase(PC)
  2929.         tst.l   d0
  2930.         bne.s   fn1
  2931.         addq    #4,a4
  2932.         dbf     d7,fn2
  2933. fn5        move.l  #namerr,d0
  2934.         bsr     putstr
  2935.         move.l  a5,d0
  2936.         bsr     putnam
  2937. fnerr        clr.b   d7
  2938.         rts
  2939. fn1        move.b  procnum(PC),d2
  2940.         beq.s   fn3
  2941.         move.l  d0,a0
  2942.         cmp.b   143(a0),d2
  2943.         bne.s   fn4
  2944. fn3        moveq.l #1,d7
  2945.         rts
  2946.  
  2947. ;list-offset-table
  2948. TRuNode     dc.l    276
  2949. TReNode     dc.l    406
  2950. TWaNode     dc.l    420
  2951. DevNode     dc.l    350
  2952. LibNode     dc.l    378
  2953. ResNode     dc.l    336
  2954. MemNode     dc.l    322
  2955. PorNode     dc.l    392
  2956. SemNode     dc.l    532
  2957.  
  2958. ;Node has been entered in hex. Check if this node exsists
  2959. tstnode     tst.b   fromfile
  2960.         bne.s   illegalhex
  2961.         move.l  d0,d1
  2962.         btst    #0,d1
  2963.         beq.s   inrange
  2964.         move.l  #adrerr,d0
  2965.         bsr     putnam
  2966. illegalhex  moveq   #0,d5
  2967.         rts
  2968. inrange     movem.l d7/a4,-(a7)
  2969.         cmp.l   #TRuNode,a4
  2970.         bne.s   inrange1
  2971.         move.l  _SysBase(PC),a0
  2972.         cmp.l   276(a0),d0
  2973.         beq.s   nodefound
  2974.         subq    #1,d7
  2975.         addq    #4,a4
  2976. inrange1    move.w  #$4000,$dff09a
  2977. getlist     move.l  _SysBase(PC),a0
  2978.         add.l   0(a4),a0
  2979. nxtnode     tst.l   0(a0)
  2980.         beq.s   nxtlist
  2981.         cmp.l   a0,d0
  2982.         beq.s   nodefound
  2983.         move.l  0(a0),a0
  2984.         bra.s   nxtnode
  2985. nxtlist     addq    #4,a4
  2986.         dbf     d7,getlist
  2987.         move.w  #-$4000,$dff09a
  2988.         movem.l d0/d7/a4,-(a7)
  2989.         bsr     ResumeOutput
  2990.         move.l  #noderr,d0
  2991.         bsr     putnam
  2992.         bsr     readline
  2993.         movem.l (a7)+,d0/d7/a4
  2994.         cmp.b   #'y',inputbuffer
  2995.         beq.s   nodefound1
  2996.         moveq   #0,d5
  2997.         movem.l (a7)+,d7/a4
  2998.         rts
  2999. nodefound   move.w  #-$4000,$dff09a
  3000. nodefound1  move.b  #1,d5
  3001. etst        movem.l (a7)+,d7/a0
  3002.         rts
  3003.  
  3004. ;allocate FileInfoBlock
  3005. allocfinfo  move.l  #260,d0
  3006.         moveq   #0,d1
  3007.         CALL    AllocMem,_SysBase(PC)
  3008.         move.l  d0,finfoptr
  3009.         rts
  3010.  
  3011. ;free FileInfoBlock
  3012. freefinfo   move.l  #260,d0
  3013.         move.l  finfoptr(PC),d1
  3014.         beq.s   1$
  3015.         move.l  d1,a1
  3016.         CALL    FreeMem,_SysBase(PC)
  3017. 1$        rts
  3018.  
  3019. ;Examine ,d0=Lock
  3020. getfinfo    move.l  d0,d1
  3021.         move.l  finfoptr,d2
  3022.         CALL    Examine,dosbase(PC)
  3023.         rts
  3024.  
  3025. ;construct a Pathname from a lock
  3026. ;d0=Lock ,resulting string is written to window
  3027. getpath     movem.l d1-d7/a0-a6,-(a7)
  3028.         move.l  d0,d1
  3029.         beq.s   1$
  3030.         CALL    DupLock,dosbase(PC)
  3031. 1$        lea     out,a4
  3032.         clr.b   -(a4)
  3033. gp0        move.l  d0,-(a7)
  3034.         bsr     getfinfo
  3035.         move.l  finfoptr,a0
  3036.         move.l  4(a0),d4
  3037.         addq    #8,a0
  3038.         bsr     strlen
  3039.         lea     -1(a4),a5
  3040.         tst.l   d4
  3041.         bmi.s   nodir
  3042.         move.b  #'/',-(a4)
  3043. nodir        subq    #1,d0
  3044.         bmi.s   nofnam
  3045. gp1        move.b  0(a0,d0),-(a4)
  3046.         dbf     d0,gp1
  3047. nofnam        move.l  0(a7),d1
  3048.         CALL    ParentDir,dosbase(PC)
  3049.         move.l  d0,d4
  3050.         move.l  (a7)+,d1
  3051.         beq.s   2$
  3052.         CALL    UnLock,dosbase(PC)
  3053. 2$        move.l  d4,d0
  3054.         bne     gp0
  3055. putall        cmp.b   #'/',0(a5)
  3056.         bne.s   gp2
  3057.         move.b  #':',0(a5)
  3058. gp2        move.l  a4,d0
  3059.         bsr     putnam
  3060.         movem.l (a7)+,d1-d7/a0-a6
  3061.         rts
  3062. strlen        move.l  a0,-(a7)
  3063.         move.l  #-1,d0
  3064. strl2        addq.l  #1,d0
  3065.         tst.b   (a0)+
  3066.         bne.s   strl2
  3067.         move.l  (a7)+,a0
  3068.         rts
  3069. strlen2     move.l  a0,-(a7)
  3070.         move.l  #-1,d0
  3071. strl22        addq.l  #1,d0
  3072.         cmp.b   #10,(a0)+
  3073.         bne.s   strl22
  3074.         move.l  (a7)+,a0
  3075.         rts
  3076.  
  3077. ;write a title and underline
  3078. ;a0 = pointer to text
  3079. puthead1    bsr     strlen
  3080.         move.l  d0,d5
  3081.         move.l  a0,d0
  3082.         bra     putstr
  3083.  
  3084. puthead2    bsr     strlen
  3085.         add.l   d0,d5
  3086.         bra.s   ph2
  3087.  
  3088. puthead     bsr     strlen
  3089.         move.l  d0,d5
  3090. ph2        move.l  a0,d0
  3091.         bsr     putnam
  3092.         lea     out,a0
  3093.         move.l  a0,d0
  3094. ph1        move.b  #'-',(a0)+
  3095.         dbf     d5,ph1
  3096.         move.b  #$0a,(a0)+
  3097.         clr.b   0(a0)
  3098.         bra     putstr
  3099.  
  3100. ;move cursor to a column
  3101. ;d0 = current position
  3102. ;d1 = column
  3103. tab        move.l  a3,-(a7)
  3104.         lea     out,a3
  3105. sp5        cmp.b   d1,d0
  3106.         bcc.s   sp4
  3107.         move.b  #' ',0(a3,d0)
  3108.         addq.b  #1,d0
  3109.         bra.s   sp5
  3110. sp4        move.l  d1,ptr
  3111.         move.l  (a7)+,a3
  3112.         rts
  3113.  
  3114. ;convert ascii to byte
  3115. ;a0 = pointer to text
  3116. ;d0 = byte
  3117. getnum        cmp.b   #'$',0(a0)
  3118.         bne.s   isdec
  3119.         bsr     readhex
  3120.         move.l  d0,d2
  3121.         rts
  3122. isdec        moveq   #0,d2
  3123.         move.l  d2,d3
  3124.         move.l  d2,d6
  3125.         move.l  d2,d7
  3126.         cmp.b   #'-',0(a0)
  3127.         bne.s   gn1
  3128.         addq    #1,a0
  3129.         moveq.l #1,d6
  3130. gn1        move.b  (a0)+,d3
  3131.         cmp.b   #'9',d3
  3132.         bhi.s   gn2
  3133.         cmp.b   #'0',d3
  3134.         bcs.s   gn2
  3135.         moveq   #1,d7
  3136.         and.b   #$f,d3
  3137.         muls    #10,d2
  3138.         add.l   d3,d2
  3139.         bra.s   gn1
  3140. gn2        tst.b   d6
  3141.         beq.s   gn3
  3142.         neg.l   d2
  3143. gn3        tst.b   d7
  3144.         bne.s   gn4
  3145.         subq    #1,a0
  3146. gn4        rts
  3147.  
  3148. ;convert hex to longword
  3149. ;a0 = pointer to text
  3150. ;returns d0=value
  3151. ;d7 = ok/error 1/0
  3152. readhex     movem.l d1-d6/a1-a5,-(a7)
  3153.         moveq   #1,d7
  3154.         cmp.b   #'$',0(a0)
  3155.         bne.s   rh3
  3156.         addq    #1,a0
  3157. rh3        moveq   #0,d0
  3158.         cmpi.b  #10,0(a0)
  3159.         beq.s   rherr
  3160.         lea     hextab(pc),a1
  3161. rh0        move.b  (a0)+,d3
  3162.         moveq.l #15,d2
  3163. rh1        cmp.b   0(a1,d2),d3
  3164.         beq.s   rh2
  3165.         dbf     d2,rh1
  3166.         bra     rhend
  3167. rh2        lsl.l   #4,d0
  3168.         or.b    d2,d0
  3169.         bra.s   rh0
  3170. rhend        tst.b   d3
  3171.         beq.s   rhok
  3172.         cmpi.b  #10,d3
  3173.         beq.s   rhok
  3174.         cmpi.b  #' ',d3
  3175.         beq.s   rhok
  3176. rherr        moveq   #0,d7
  3177. rhok        movem.l (a7)+,d1-d6/a1-a5
  3178.         rts
  3179.  
  3180. ;skip blanks
  3181. ;a0 pointer to text
  3182. ; returns a0 = new pointer position
  3183. kllblnks    cmpi.b  #' ',0(a0)
  3184.         bne.s   gn4
  3185.         addq    #1,a0
  3186.         bra.s   kllblnks
  3187.  
  3188. ; exit program. If background flag is set, wait for
  3189. ; amiga-amiga-x
  3190.  
  3191. stopall     addq    #4,a7
  3192.         bra     exitall
  3193.  
  3194. exit        tst.b   background
  3195.         bne     quithold
  3196. exitall     bsr     killpage
  3197.         bsr     freeblank
  3198.         bsr     killhistory
  3199.         move.l  stplist(PC),a3
  3200.         tst.l   0(a3)
  3201.         beq.s   ex0
  3202.         move.l  a3,d0
  3203.         bsr     waok
  3204.         bra.s   exitall
  3205.  
  3206. ex0        tst.b   background
  3207.         beq.s   ex1
  3208.         bsr     removeh
  3209.  
  3210. ex1        move.l  _SysBase(PC),a1
  3211.         move.l  #_LVOSwitch,a0
  3212.         move.l  oldswitch,d0
  3213.         CALL    SetFunction,_SysBase(PC)
  3214.         moveq   #3,d0
  3215.         lea     IOCounter(PC),a1
  3216.         CALL    RemIntServer,_SysBase(PC)
  3217.  
  3218.         move.l  replyport(PC),-(a7)
  3219.         LIBCALL DeletePort
  3220.         addq    #4,a7
  3221.         bsr     stoptimer
  3222.         lea     timerio,a1
  3223.         CALL    CloseDevice,_SysBase(PC)
  3224.         move.l  timerport(PC),-(a7)
  3225.         LIBCALL DeletePort
  3226.         addq    #4,a7
  3227.  
  3228.         bsr     restoretrap
  3229.  
  3230.         tst.l   wnptr
  3231.         beq.s   5$
  3232.         move.l  wnptr(PC),a0
  3233.         CALL    CloseWindow,intuibase(PC)
  3234. 5$        tst.b   ownscreen
  3235.         beq.s   6$
  3236.         move.l  screenptr(PC),a0
  3237.         CALL    CloseScreen,intuibase(PC)
  3238.         clr.l   screenptr
  3239.  
  3240. 6$        move.l  fileptr(PC),d1
  3241.         beq.s   ex11
  3242.         CALL    Close,dosbase(PC)
  3243. ex11        bsr     freehidmem
  3244.         bsr     freealias
  3245.         move.l  realstack(PC),a7
  3246.     IFND DEBUG
  3247.         CALL    Forbid,_SysBase(PC)
  3248.         move.l  wbmsg(PC),d0
  3249.         beq.s   todos
  3250.         move.l  d0,a1
  3251.         CALL    ReplyMsg,_SysBase(PC)
  3252.         moveq   #0,d0
  3253.         rts
  3254.  
  3255. todos        move.l  myseg(PC),d1
  3256.         CALL    UnLoadSeg,dosbase(PC)
  3257.     ENDC
  3258.         moveq   #0,d0
  3259.         rts
  3260.  
  3261. ;print a bcpl-string
  3262. ;d0 = bcpl-pointer to bcpl-string
  3263. putbcpl     movem.l d3/a0-a1,-(a7)
  3264.         tst.l   d0
  3265.         beq.s   pb1
  3266.         lsl.l   #2,d0
  3267.         move.l  d0,a1
  3268.         moveq   #0,d3
  3269.         move.b  (a1)+,d3
  3270.         subq    #1,d3
  3271.         move.l  ptr(PC),d0
  3272.         lea     out,a0
  3273. pb2        move.b  (a1)+,0(a0,d0)
  3274.         beq.s   1$
  3275.         addq.b  #1,d0
  3276.         dbf     d3,pb2
  3277. 1$        move.l  d0,ptr
  3278. pb1        movem.l (a7)+,d3/a0-a1
  3279.         rts
  3280.  
  3281. ;compare strings
  3282. ;a0/a1 = pointers to string
  3283. ;returns d0 = true(0) false(1), d1 = length
  3284. strcmp        movem.l a0-a1,-(a7)
  3285.         moveq   #0,d0
  3286.         move.l  d0,d1
  3287. src2        move.b  (a0)+,d0
  3288.         beq.s   src1
  3289.         cmp.b   #10,d0
  3290.         beq.s   src1
  3291.         addq    #1,d1
  3292.         cmp.b   (a1)+,d0
  3293.         beq.s   src2
  3294.         bra.s   src3
  3295. src1        move.b  0(a1),d0
  3296. src3        movem.l (a7)+,a0-a1
  3297.         rts
  3298.  
  3299. strbuf        movem.l d0/a1-a2,-(a7)
  3300.         move.l  a0,a1
  3301.         lea     buffer,a2
  3302. 1$        move.b  (a1)+,d0
  3303.         cmp.b   #10,d0
  3304.         beq.s   2$
  3305.         cmp.b   #' ',d0
  3306.         beq.s   2$
  3307.         or.b    #' ',d0
  3308.         beq.s   2$
  3309.         move.b  d0,(a2)+
  3310.         bra.s   1$
  3311. 2$        clr.b   (a2)+
  3312.         movem.l (a7)+,d0/a1-a2
  3313.         rts
  3314.  
  3315. ;compare bcpl string with string
  3316. ;a0 = pointer to string
  3317. ;a2 = bcpl-pointer to bcpl-string
  3318. ;returns d0 = true(0) false(1)
  3319. strbcmp     movem.l d1/a0/a2,-(a7)
  3320.         moveq   #0,d0
  3321.         moveq   #0,d1
  3322.         adda.l  a2,a2
  3323.         adda.l  a2,a2
  3324.         move.b  (a2)+,d1
  3325.         beq.s   stb1
  3326.         subq    #1,d1
  3327. stb2        cmp.b   (a2)+,(a0)+
  3328.         bne.s   stb1
  3329.         dbf     d1,stb2
  3330.         moveq   #1,d0
  3331. stb1        movem.l (a7)+,d1/a0/a2
  3332.         rts
  3333.  
  3334. ;convert long to decimal
  3335. ;d0 = value
  3336. ;d3 bit 0 = left/right justified
  3337. ;d3 bit 1 = write/leave
  3338. ;returns string in 'buffer'
  3339. longdec     movem.l d1-d2/a1-a2,-(a7)
  3340.         lea     binarea+8(PC),a1
  3341.         move.l  #'    ',-8(a1)
  3342.         move.l  #'    ',-4(a1)
  3343.         clr.b   0(a1)
  3344.         subq    #1,a1
  3345.         cmp     #2,d3
  3346.         bne.s   ld5
  3347.         clr.b   0(a1)
  3348. ld5        moveq   #1,d2
  3349. ld2        addq    #1,d2
  3350.         moveq   #$a,d1
  3351.         bsr     div
  3352.         addi.l  #$30,d1
  3353.         move.b  d1,-(a1)
  3354.         tst.l   d0
  3355.         bne.s   ld2
  3356.  
  3357.         btst    #0,d3
  3358.         bne.s   ld1
  3359.         lea     binarea(PC),a2
  3360.         cmpa.l  a2,a1
  3361.         bne.s   ld3
  3362.         subq.l  #1,ptr
  3363.         bra.s   ld1
  3364. ld3        move.b  0(a1),(a2)+
  3365.         move.b  #' ',(a1)+
  3366.         dbf     d2,ld3
  3367. ld1        cmp     #2,d3
  3368.         beq.s   ld4
  3369.         move.l  #binarea,d0
  3370.         bsr     putstr
  3371. ld4        movem.l (a7)+,d1-d2/a1-a2
  3372.         rts
  3373.  
  3374. ;write UBYTE
  3375. ;d3 = value
  3376. bytedec     bsr     dec
  3377.         move.l  #decimal,d0
  3378.         bra.s   pm1
  3379.  
  3380. ;write signed byte
  3381. ;d3 = value
  3382. plusmins    movem.l d5/a3,-(a7)
  3383.         move.w  #$2020,minus
  3384.         move.b  d3,d5
  3385.         bpl.s   2$
  3386.         neg.b   d3
  3387. 2$        bsr.s   dec
  3388.         tst.b   d5
  3389.         bpl.s   1$
  3390.         move.l  d0,a3
  3391.         move.b  #'-',-(a3)
  3392. 1$        movem.l (a7)+,d5/a3
  3393.         move.l  #minus+1,d0
  3394. pm1        bra     putstr
  3395.  
  3396. dec        movem.l d3/a3,-(a7)
  3397.         move.l  #$20202020,decimal
  3398.         and.l   #$ff,d3
  3399.         lea     decimal+3(PC),a3
  3400. bloop        tst.b   d3
  3401.         beq.s   bend
  3402.         divu    #10,d3
  3403.         swap    d3
  3404.         ori.b   #'0',d3
  3405.         move.b  d3,-(a3)
  3406.         clr.w   d3
  3407.         swap    d3
  3408.         bra.s   bloop
  3409. bend        cmpa.l  #decimal+3,a3
  3410.         bne     1$
  3411.         move.b  #'0',-(a3)
  3412. 1$        move.l  a3,d0
  3413.         movem.l (a7)+,d3/a3
  3414.         rts
  3415.  
  3416. ;write a string, move cursor into next line
  3417. ;d0 = pointer to text
  3418. putnam        bsr     putstr
  3419. putnam1     tst.b   d0
  3420.         beq.s   ncr
  3421.         bsr     newline
  3422. ncr        rts
  3423.  
  3424. ;write one char
  3425. ;d0 = char
  3426. putchar     movem.l d1/a0,-(a7)
  3427.         move.l  ptr(PC),d1
  3428.         lea     out,a0
  3429.         move.b  d0,0(a0,d1)
  3430.         addq.l  #1,ptr
  3431.         movem.l (a7)+,d1/a0
  3432.         rts
  3433.  
  3434. ;write a string, strings are only put into the output buffer when
  3435. ;a LF is detected
  3436. ;d0 = pointer to string
  3437. ;returns d0 = cursor position
  3438. putstr        movem.l d1-d7/a0-a6,-(a7)
  3439.         move.b  #1,printed
  3440.         move.l  d0,a2
  3441.         lea     out,a3
  3442.         move.l  ptr(PC),d0
  3443.         move.l  a2,d5
  3444.         bne     pst1
  3445.         lea     longnix(PC),a2
  3446.  
  3447. pst1        move.b  (a2)+,d1
  3448.         cmpi.b  #13,d1
  3449.         beq     pst1
  3450.         cmpi.b  #10,d1
  3451.         beq.s   lineend
  3452.         move.b  d1,0(a3,d0)
  3453.         beq     prend
  3454.         cmp     #100,d0
  3455.         bge.s   pst1
  3456.         addq    #1,d0
  3457.         bra.s   pst1
  3458.  
  3459. lineend     tst.b   fromfile
  3460.         beq.s   1$
  3461.         moveq   #0,d0
  3462.         bra     prend
  3463.  
  3464. 1$        tst.l   lastprinted
  3465.         bne.s   2$
  3466.         bsr     killpage
  3467.  
  3468. 2$        addq    #1,d0
  3469.         move.l  d0,-(a7)
  3470.         add     #14,d0
  3471.         moveq   #0,d1
  3472.         CALL    AllocMem,_SysBase(PC)
  3473.         move.l  (a7)+,d1
  3474.         tst.l   d0
  3475.         beq     prend
  3476.         move.l  d0,a0
  3477.         move.w  d1,12(a0)
  3478.         cmp.w   maxllength(PC),d1
  3479.         ble.s   7$
  3480.         move.w  d1,maxllength
  3481. 7$        move.l  node,8(a0)
  3482.         clr.l   node
  3483.         clr.l   0(a0)
  3484.  
  3485.         move.l  lastprinted(PC),d0
  3486.         move.l  d0,4(a0)
  3487.         bne.s   3$
  3488.         move.l  a0,outchain
  3489.         bra.s   4$
  3490. 3$        move.l  d0,a1
  3491.         move.l  a0,0(a1)
  3492. 4$        move.l  a0,lastprinted
  3493.         move.b  #' ',14(a0)
  3494.         subq    #1,d1
  3495.         lea     15(a0),a0
  3496.         lea     out,a1
  3497.         subq    #1,d1
  3498.         bmi.s   6$
  3499. 5$        move.b  (a1)+,(a0)+
  3500.         dbf     d1,5$
  3501. 6$        move.l  numlines(PC),d2
  3502.         cmp.l   maxlines(PC),d2
  3503.         ble.s   8$
  3504.  
  3505.         move.l  outchain(PC),a1
  3506.         move.l  0(a1),a2
  3507.         move.l  a2,outchain
  3508.         clr.l   4(a2)
  3509.         move.w  12(a1),d0
  3510.         add.w   #14,d0
  3511.         ext.l   d0
  3512.         CALL    FreeMem,_SysBase(PC)
  3513.         bra.s   9$
  3514.  
  3515. 8$        addq.l  #1,d2
  3516.         move.l  d2,numlines
  3517.  
  3518. 9$        moveq   #0,d0
  3519.         move.l  d0,d5
  3520.         tst.b   addlines
  3521.         beq     pst1
  3522.         bsr     addline
  3523.         bra     pst1
  3524. prend        move.l  d0,ptr
  3525.         movem.l (a7)+,d1-d7/a0-a6
  3526.         rts
  3527.  
  3528. ;Kill output buffer
  3529. killpage    movem.l d0-d7/a0-a6,-(a7)
  3530.         tst.l   outchain
  3531.         beq.s   2$
  3532.         move.l  outchain(PC),a1
  3533.         bsr     killlines
  3534.         clr.l   outchain
  3535.         clr.l   lastprinted
  3536.         clr.l   numlines
  3537.         clr.w   maxllength
  3538. 2$        movem.l (a7)+,d0-d7/a0-a6
  3539.         rts
  3540.  
  3541. ;kill the remainder of the output buffer
  3542. killlines   move.l  0(a1),-(a7)
  3543.         move.w  12(a1),d0
  3544.         ext.l   d0
  3545.         add     #14,d0
  3546.         CALL    FreeMem,_SysBase(PC)
  3547.         move.l  (a7)+,a1
  3548.         move.l  a1,d7
  3549.         bne.s   killlines
  3550.         rts
  3551.  
  3552. freeblank   move.l  blanks(PC),d0
  3553.         beq.s   1$
  3554.         move.l  d0,a1
  3555.         move.w  colms(PC),d0
  3556.         ext.l   d0
  3557.         CALL    FreeMem,_SysBase(PC)
  3558.         clr.l   blanks
  3559. 1$        rts
  3560.  
  3561. ;write a portion of the output buffer to the screen
  3562. blastout    move.l  rastport(PC),a1
  3563.         moveq   #1,d0
  3564.         CALL    SetAPen,gfxbase(PC)
  3565.         move.l  rastport(PC),a1
  3566.         moveq   #1,d0
  3567.         CALL    SetDrMd,gfxbase(PC)
  3568.         moveq   #0,d7
  3569.  
  3570.         move.w  loffset(PC),d2
  3571.         beq.s   7$
  3572.         move.w  colms(PC),d4
  3573.         add.w   d4,d2
  3574.         move.w  maxllength(PC),d3
  3575.         cmp.w   d3,d2
  3576.         ble.s   7$
  3577.         move.w  d3,d2
  3578.         sub.w   d4,d2
  3579.         bpl.s   8$
  3580.         moveq   #0,d2
  3581. 8$        move.w  d2,loffset
  3582.  
  3583. 7$        bsr     tstfirstlin
  3584.  
  3585. 1$        tst.l   outchain
  3586.         beq.s   3$
  3587.         bsr     findline
  3588.  
  3589. 2$        move.w  colms(PC),d5
  3590.         ext.l   d5
  3591.         move.w  loffset(PC),d4
  3592.         ext.l   d4
  3593.         moveq   #18,d6
  3594. 6$        lea     14(a5,d4),a0
  3595.         move.w  12(a5),d3
  3596.         ext.l   d3
  3597.         bsr     blastline
  3598.         bge.s   3$
  3599.         tst.l   0(a5)
  3600.         beq.s   5$
  3601.         move.l  0(a5),a5
  3602.         bra     6$
  3603. 5$        moveq   #0,d3
  3604.         bsr     blastline
  3605.         bcs.s   5$
  3606. 3$        rts
  3607.  
  3608. ;get a pointer to a line  (line # in d0)
  3609. findline    move.l  outchain(PC),d1
  3610.         beq     2$
  3611.         move.l  d1,a5
  3612. 1$        tst     d0
  3613.         beq.s   2$
  3614.         tst.l   0(a5)
  3615.         beq.s   2$
  3616.         move.l  0(a5),a5
  3617.         dbf     d0,1$
  3618. 2$        rts
  3619.  
  3620. ;check if the display is as 'full' as possible
  3621. tstfirstlin move.l  firstline(PC),d0
  3622.         move.l  d0,d2
  3623.         add.w   rows(PC),d2
  3624.         cmp.l   numlines(PC),d2
  3625.         bmi.s   1$
  3626.         move.l  numlines(PC),d2
  3627.         sub.w   rows(PC),d2
  3628.         bpl.s   4$
  3629.         moveq   #0,d2
  3630. 4$        move.l  d2,d0
  3631.         move.l  d2,firstline
  3632. 1$        rts
  3633.  
  3634. ;display one line, fill the gap between the end of the line and
  3635. ;the end of the window with spaces.
  3636. ;d6 = ypos, d5=colms, d3= linelength, d7= line # in window, a0 = text
  3637.  
  3638. blastline   move    d6,d1
  3639.         moveq   #6,d0
  3640.         move.l  rastport(PC),a1
  3641.         CALL    Move,gfxbase(PC)
  3642.         sub.w   d4,d3
  3643.         bpl.s   7$
  3644.         moveq   #0,d3
  3645.         bra.s   6$
  3646. 7$        cmp.w   d5,d3
  3647.         bmi.s   4$
  3648.         move.w  d5,d3
  3649. 4$        move.l  d3,d0
  3650.         beq.s   6$
  3651.         CALL    Text,gfxbase(PC)
  3652. 6$        move.l  d5,d0
  3653.         sub.l   d3,d0
  3654.         ble.s   5$
  3655.         move.l  blanks(PC),a0
  3656.         move.l  rastport(PC),a1
  3657.         CALL    Text,gfxbase(PC)
  3658. 5$        addq    #8,d6
  3659.         addq    #1,d7
  3660.         cmp.w   rows(PC),d7
  3661.         rts
  3662.  
  3663. ;Write pointer, display '-------' if empty
  3664. hexan        tst.l   d0
  3665.         bne.s   hexa
  3666.         bra     putstr
  3667.  
  3668. ;Write 8 byte hex value
  3669. ;d0 = value
  3670. hexa        bsr     gthex
  3671.         bra     putstr
  3672.  
  3673. gthex        movem.l d1-d7/a0-a6,-(a7)
  3674.         moveq.l #7,d5
  3675.         lea     hexarea(PC),a1
  3676.         lea     hextab(PC),a0
  3677.         moveq   #0,d2
  3678. hexloop     move.b  d0,d2
  3679.         and.b   #15,d2
  3680.         move.b  0(a0,d2),0(a1,d5)
  3681.         lsr.l   #4,d0
  3682.         dbf     d5,hexloop
  3683.         move.l  a1,d0
  3684.         movem.l (a7)+,d1-d7/a0-a6
  3685.         rts
  3686.  
  3687. ;Convert/write byte into binary string
  3688. ;d0 = value
  3689. bin        movem.l d1-d7/a0-a6,-(a7)
  3690.         lea     binarea(PC),a0
  3691.         move.w  #$2020,8(a0)
  3692.         moveq.l #7,d4
  3693. binloop     moveq.l #'0'/2,d1
  3694.         roxr.b  #1,d0
  3695.         roxl.b  #1,d1
  3696.         move.b  d1,0(a0,d4)
  3697.         dbf     d4,binloop
  3698.         move.l  a0,d0
  3699.         movem.l (a7)+,d1-d7/a0-a6
  3700.         bra     putstr
  3701.  
  3702. ;send a packet
  3703. ;a0 = msgport
  3704. ;dp_Type and dp_Arg1 have to be inizialized
  3705. cons1        movem.l d0-d7/a0-a6,-(a7)
  3706.         move.l  #dp_Link,LN_NAME
  3707.         move.l  #mypacket,dp_Link
  3708.         move.l  replyport(PC),dp_Port
  3709.         lea     mypacket,a1
  3710.         CALL    PutMsg,_SysBase(PC)
  3711.         move.l  replyport,a0
  3712.         CALL    WaitPort,_SysBase(PC)
  3713.         move.l  replyport(PC),a0
  3714.         CALL    GetMsg,_SysBase(PC)
  3715.         movem.l (a7)+,d0-d7/a0-a6
  3716.         rts
  3717.  
  3718. ;32-bit division
  3719. ;d0 / d1
  3720. ;returns d0
  3721. div        movem.l d2-d3,-(a7)
  3722.         tst.l   d1
  3723.         beq     div8
  3724.         swap    d1
  3725.         move.w  d1,d2
  3726.         bne.s   div1
  3727.         swap    d0
  3728.         swap    d1
  3729.         swap    d2
  3730.         move.w  d0,d2
  3731.         beq.s   div2
  3732.         divu    d1,d2
  3733.         move.w  d2,d0
  3734. div2        swap    d0
  3735.         move.w  d0,d2
  3736.         divu    d1,d2
  3737.         move.w  d2,d0
  3738.         swap    d2
  3739.         move.w  d2,d1
  3740.         bra     div8
  3741. div1        moveq   #$10,d3
  3742.         cmpi.w  #$80,d1
  3743.         bcc.s   div3
  3744.         rol.l   #8,d1
  3745.         subq.w  #8,d3
  3746. div3        cmpi.w  #$800,d1
  3747.         bcc.s   div4
  3748.         rol.l   #4,d1
  3749.         subq.w  #4,d3
  3750. div4        cmpi.w  #$2000,d1
  3751.         bcc.s   div5
  3752.         rol.l   #2,d1
  3753.         subq.w  #2,d3
  3754. div5        tst.w   d1
  3755.         bmi.s   div6
  3756.         rol.l   #1,d1
  3757.         subq.w  #1,d3
  3758. div6        move.w  d0,d2
  3759.         lsr.l   d3,d0
  3760.         swap    d2
  3761.         clr.w   d2
  3762.         lsr.l   d3,d2
  3763.         swap    d3
  3764.         divu    d1,d0
  3765.         move.w  d0,d3
  3766.         move.w  d2,d0
  3767.         move.w  d3,d2
  3768.         swap    d1
  3769.         mulu    d1,d2
  3770.         sub.l   d2,d0
  3771.         bcc.s   div7
  3772.         subq.w  #1,d3
  3773.         add.l   d1,d0
  3774. div7        moveq   #0,d1
  3775.         move.w  d3,d1
  3776.         swap    d3
  3777.         rol.l   d3,d0
  3778.         swap    d0
  3779.         exg     d1,d0
  3780. div8        movem.l (a7)+,d2-d3
  3781.         rts
  3782.  
  3783. ;install a input-handler
  3784. installh    pea     0
  3785.         pea     xopsleep
  3786.         LIBCALL CreatePort
  3787.         addq    #8,a7
  3788.         move.l  d0,InputMsg
  3789.         move.l  d0,-(a7)
  3790.         LIBCALL CreateStdIO
  3791.         addq    #4,a7
  3792.         move.l  d0,InRequest
  3793.         move.l  d0,a1
  3794.         lea     devicenam(PC),a0
  3795.         moveq   #0,d0
  3796.         moveq   #0,d1
  3797.         CALL    OpenDevice,_SysBase(PC)
  3798.         move.l  d0,devstatus
  3799.         movea.l InRequest(PC),a1
  3800.         move.l  #InInterrupt,40(a1)
  3801.         move.w  #9,28(a1)
  3802.         CALL    DoIO,_SysBase(PC)
  3803.         move.l  d0,iostatus
  3804.         move.l  #-1,d0
  3805.         CALL    AllocSignal,_SysBase(PC)
  3806.         moveq   #0,d1
  3807.         bset    d0,d1
  3808.         move.l  d1,mysignal
  3809.         rts
  3810.  
  3811. ;remove handler
  3812. removeh     movea.l InRequest(PC),a1
  3813.         move.l  #InInterrupt,40(a1)
  3814.         move.w  #10,28(a1)
  3815.         CALL    DoIO,_SysBase(PC)
  3816.         movea.l InRequest(PC),a1
  3817.         CALL    CloseDevice,_SysBase(PC)
  3818.         move.l  InRequest,-(a7)
  3819.         LIBCALL DeleteStdIO
  3820.         addq    #4,a7
  3821.         move.l  InputMsg,-(a7)
  3822.         LIBCALL DeletePort
  3823.         addq    #4,a7
  3824.         rts
  3825.  
  3826. ;this is the handler, it checks if amiga-amiga-x
  3827. ;has been pressed and signals it to our task
  3828. Keyhandler  tst.b   running
  3829.         bne.s   endhandler
  3830.         cmp.b   #1,4(a0)
  3831.         bne.s   endhandler
  3832.         move.w  8(a0),d0
  3833.         andi.w  #$c0,d0
  3834.         cmpi.w  #$c0,d0
  3835.         bne.s   endhandler
  3836.         cmp.w   #$32,6(a0)
  3837.         bne.s   endhandler
  3838. wakeup        move.l  a0,-(a7)
  3839.         movea.l mytask(PC),a1
  3840.         move.l  mysignal(PC),d0
  3841.         CALL    Signal,_SysBase(PC)
  3842.         move.l  (a7)+,a0
  3843.         clr.b   4(a0)
  3844. endhandler  move.l  a0,d0
  3845.         rts
  3846.  
  3847. snoop        bsr     cls
  3848.         bsr     nodenam
  3849.         moveq   #1,d7
  3850.         lea     TReNode(PC),a4
  3851.         bsr     findnam
  3852.         tst.b   d7
  3853.         bne.s   1$
  3854.         move.l  #stperr,d0
  3855.         bra     putnam
  3856. 1$        move.l  d0,captask
  3857.         pea     0
  3858.         pea     memportname
  3859.         LIBCALL CreatePort
  3860.         addq    #8,a7
  3861.         move.l  d0,snoopport
  3862.         beq     tm6
  3863.  
  3864.         bsr     replyintui
  3865.         move.b  #1,addlines
  3866.         lea     snoophead(PC),a0
  3867.         bsr     puthead
  3868.         move.l  _SysBase(PC),a1
  3869.         move.l  -196(a1),oldalloc
  3870.         move.l  -208(a1),oldfree
  3871.         move.l  #capmalloc,d0
  3872.         move.l  #-198,a0
  3873.         CALL    SetFunction,_SysBase(PC)
  3874.         move.l  _SysBase(PC),a1
  3875.         move.l  #capmfree,d0
  3876.         move.l  #-210,a0
  3877.         CALL    SetFunction,_SysBase(PC)
  3878.         clr.b   bool
  3879.         clr.b   cbreak
  3880.  
  3881. waitmem     move.l  snoopport(PC),a0
  3882.         moveq   #0,d1
  3883.         move.b  15(a0),d1
  3884.         bset    d1,d0
  3885.         move.l  d0,auxsig
  3886.         bsr     processmsgs
  3887.  
  3888. tm7        move.l  mytask(PC),a0
  3889.         move.l  snoopport(PC),a0
  3890.         CALL    GetMsg,_SysBase(PC)
  3891.         tst.l   d0
  3892.         bne     tm8
  3893.         tst.b   cbreak
  3894.         bne     snoopend
  3895.         bra     waitmem
  3896. tm8        move.l  d0,a3
  3897.         move.l  20(a3),d3
  3898.         btst    #31,d3
  3899.         beq     freed
  3900.         move.l  #allok,d0
  3901.         bsr     putstr
  3902.         lea     memname(PC),a2
  3903.         lea     membit(PC),a4
  3904.         moveq   #4,d5
  3905. tm2        move.l  0(a4),d4
  3906.         btst    d4,d3
  3907.         beq.s   tm1
  3908.         move.l  0(a2),d0
  3909.         bsr     putstr
  3910. tm1        addq    #4,a2
  3911.         addq    #4,a4
  3912.         dbf     d5,tm2
  3913.         moveq   #26,d1
  3914.         bsr     tab
  3915.         move.l  24(a3),d0
  3916.         move.l  d0,d3
  3917.         bsr     hexa
  3918.         move.l  28(a3),d0
  3919.         bne.s   tm3
  3920.         move.l  #failed,d0
  3921.         bsr     putstr
  3922.         moveq   #53,d1
  3923.         bsr     tab
  3924.         bra     tm4
  3925. tm3        bsr     hexa
  3926.         move.l  28(a3),d0
  3927.         add.l   d3,d0
  3928.         bsr     hexa
  3929.         bra     tm4
  3930.  
  3931. freed        move.l  #free,d0
  3932.         bsr     putstr
  3933.         move.b  #'-',d0
  3934.         moveq   #18,d1
  3935. tm9        bsr     putchar
  3936.         dbf     d1,tm9
  3937.         move.b  #' ',d0
  3938.         bsr     putchar
  3939.         move.l  d3,d0
  3940.         bsr     hexa
  3941.         move.l  24(a3),d0
  3942.         bsr     hexa
  3943.         move.l  24(a3),d0
  3944.         add.l   d3,d0
  3945.         bsr     hexa
  3946.  
  3947. tm4        move.l  32(a3),d0
  3948.         bsr     hexa
  3949.         bsr     newline
  3950.         move.w  18(a3),d0
  3951.         ext.l   d0
  3952.         move.l  a3,a1
  3953.         CALL    FreeMem,_SysBase(PC)
  3954.         bra     tm7
  3955.  
  3956. snoopend    move.l  _SysBase(PC),a1
  3957.         move.l  oldalloc(PC),d0
  3958.         move.l  #-198,a0
  3959.         CALL    SetFunction,_SysBase(PC)
  3960.         move.l  _SysBase(PC),a1
  3961.         move.l  oldfree,d0
  3962.         move.l  #-210,a0
  3963.         CALL    SetFunction,_SysBase(PC)
  3964.         move.l  snoopport,-(a7)
  3965.         LIBCALL DeletePort
  3966.         addq    #4,a7
  3967.         move.l  #stoped,d0
  3968.         bsr     putnam
  3969.         clr.b   addlines
  3970.         clr.l   auxsig
  3971. tm6        rts
  3972.  
  3973. memname     dc.l    memlarg,memclr,memfast,memchip,mempubl
  3974. membit        dc.l    17,16,2,1,0
  3975.  
  3976. capmalloc   movem.l d0-d7/a0-a6,-(a7)
  3977.         move.l  _SysBase(PC),a6
  3978.         move.l  276(a6),d4
  3979.         cmp.l   captask(PC),d4
  3980.         bne.s   capm1
  3981.         tst.b   bool
  3982.         bne     capm1
  3983.         move.b  #1,bool
  3984.         moveq   #36,d6
  3985.         bsr     allocmsg
  3986.         beq     capm2
  3987.         bset    #31,d1
  3988.         move.l  d1,20(a5)
  3989.         move.l  d0,24(a5)
  3990.         move.l  60(a7),32(a5)
  3991.         move.l  a5,remembr
  3992.         movem.l (a7)+,d0-d7/a0-a6
  3993.         bsr     memalloc
  3994.         movem.l d0-d7/a0-a6,-(a7)
  3995.         move.l  remembr(PC),a1
  3996.         move.l  d0,28(a1)
  3997.         move.l  snoopport,a0
  3998.         move.b  #5,8(a1)
  3999.         CALL    PutMsg,_SysBase(PC)
  4000.         clr.b   bool
  4001.         movem.l (a7)+,d0-d7/a0-a6
  4002.         rts
  4003. capm2        clr.b   bool
  4004. capm1        movem.l (a7)+,d0-d7/a0-a6
  4005. memalloc    dc.w    $4ef9
  4006. oldalloc    dc.l    0
  4007.  
  4008. capmfree    movem.l d0-d7/a0-a6,-(a7)
  4009.         move.l  _SysBase(PC),a6
  4010.         move.l  276(a6),d4
  4011.         cmp.l   captask(PC),d4
  4012.         bne.s   capf1
  4013.         tst.b   bool
  4014.         bne.s   capf1
  4015.         move.b  #1,bool
  4016.         moveq   #36,d6
  4017.         bsr     allocmsg
  4018.         beq.s   capf2
  4019.         move.l  d0,20(a5)
  4020.         move.l  a1,24(a5)
  4021.         move.l  60(a7),32(a5)
  4022.         move.l  snoopport,a0
  4023.         move.b  #5,8(a5)
  4024.         move.l  a5,a1
  4025.         CALL    PutMsg,_SysBase(PC)
  4026. capf2        clr.b   bool
  4027. capf1        movem.l (a7)+,d0-d7/a0-a6
  4028.         dc.w    $4ef9
  4029. oldfree     dc.l    0
  4030.  
  4031. allocmsg    movem.l d0-d1/a0-a1,-(a7)
  4032.         move.l  d6,d0
  4033.         move.l  #65536,d1
  4034.         bsr     memalloc
  4035.         tst.l   d0
  4036.         beq.s   alm1
  4037.         move.l  d0,a5
  4038.         move.w  d6,18(a5)
  4039. alm1        movem.l (a7)+,d0-d1/a0-a1
  4040.         move.l  a5,d6
  4041.         rts
  4042.  
  4043. myswitch    movem.l d0-d1/a0-a1,-(a7)
  4044.         move.l  _SysBase(PC),a0
  4045.         move.l  276(a0),d0
  4046.         move.l  tasksnum(PC),d1
  4047.         lea     cputime,a0
  4048.         subq.l  #1,d1
  4049.         bmi.s   swadd
  4050. sw0        cmp.l   (a0)+,d0
  4051.         dbeq    d1,sw0
  4052.         tst     d1
  4053.         bmi.s   swadd
  4054. swi1        add.l   #1,508(a0)
  4055. swgo        movem.l (a7)+,d0-d1/a0-a1
  4056.         dc.w    $4ef9
  4057. oldswitch   dc.l    0
  4058. swadd        cmp.l   #125,tasksnum
  4059.         bge.s   swgo
  4060.         addq.l  #1,tasksnum
  4061.         move.l  d0,0(a0)
  4062.         move.l  #1,512(a0)
  4063.         bra.s   swgo
  4064.  
  4065. countio     addq.l #1,iocount
  4066.         moveq  #0,d0
  4067. cio1        rts
  4068.  
  4069. iconbackdrp tst.b   iconifyon
  4070.         beq.s   1$
  4071.         lea     icnwindow,a0
  4072.         eor.l   #$100,14(a0)    ;wn_Flags
  4073. 1$        rts
  4074.  
  4075. iconifyoff  tst.b   iconifyon
  4076.         beq.s   cio1
  4077.         clr.b   iconifyon
  4078.         tst.b   fromfile
  4079.         bne.s   1$
  4080.         move.l  wnptr(PC),d0
  4081.         beq.s   1$
  4082.         move.l  d0,a0
  4083.         lea     iconifgad,a1
  4084.         CALL    RemoveGadget,intuibase(PC)
  4085.         move.l  wnptr(PC),a0
  4086.         CALL    RefreshWindowFrame,intuibase(PC)
  4087. 1$        move.l  #iconify,d0
  4088.  
  4089. killseg     movem.l d1-d2/a0-a4,-(a7)
  4090.         subq    #4,d0
  4091.         move.l  4,a6
  4092.         move.l  276(a6),a4
  4093.         move.l  128(a4),d1
  4094.         lsl.l   #2,d1
  4095.         move.l  d1,a3
  4096.         move.l  12(a3),d1
  4097.         bne.s   2$
  4098.         move.l  172(a4),d1
  4099.         lsl.l   #2,d1
  4100.         move.l  d1,a4
  4101.         move.l  60(a4),d1
  4102.  
  4103. 2$        lsl.l   #2,d1
  4104.         cmp.l   d0,d1
  4105.         beq.s   4$
  4106.         move.l  d1,a4
  4107.         move.l  0(a4),d1
  4108.         beq.s   5$
  4109.         bra.s   2$
  4110.  
  4111. 4$        move.l  d1,a0
  4112.         move.l  0(a0),0(a4)
  4113.         clr.l   0(a0)
  4114.         lsr.l   #2,d1
  4115.         CALL    UnLoadSeg,dosbase(PC)
  4116.         movem.l (a7)+,d1-d2/a0-a4
  4117. 5$        rts
  4118.  
  4119. alert        bsr     stoptimer
  4120.         move.l  excpttask(PC),d0
  4121.         bne.s   alert1
  4122.         move.l  #noguru,d0
  4123.         bra     putnam
  4124. alert1        move.l  #softfail,d0
  4125.         bsr     putstr
  4126.         move.l  excpttask(PC),a0
  4127.         move.l  10(a0),d0
  4128.         bsr     putnam
  4129.         cmp.l   #3,excpterror
  4130.         bne.s   1$
  4131.         move.l  #addrserr,d0
  4132.         bsr     putstr
  4133.         move.l  excptaddr(PC),d0
  4134.         bsr     hexa
  4135.         bsr     newline
  4136. 1$        move.l  #procount,d0
  4137.         bsr     putstr
  4138.         move.l  excptpc(PC),d0
  4139.         bsr     hexa
  4140.         bsr     newline
  4141.         move.l  #gurutxt,d0
  4142.         bsr     putstr
  4143.         move.l  excpterror(PC),d0
  4144.         bsr     hexa
  4145.         lea     out,a0
  4146.         move.l  ptr(PC),d0
  4147.         move.b  #'.',-1(a0,d0)
  4148.         move.l  excpttask(PC),d0
  4149.         bsr     hexa
  4150.         bra     newline
  4151.  
  4152. showguru    bsr     alert
  4153.         tst.b   ownscreen
  4154.         bne.s   5$
  4155.         move.l  wnptr(PC),a0
  4156.         CALL    WindowToFront,intuibase(PC)
  4157.         bra.s   2$
  4158. 5$        move.l  screenptr,a0
  4159.         CALL    ScreenToFront,intuibase(PC)
  4160. 2$        move.l  #whatnow,d0
  4161.         bsr     putnam
  4162.         clr.l   oldpageend
  4163.         bsr     readline
  4164.  
  4165.         cmp.b   #'i',inputbuffer
  4166.         beq.s   4$
  4167. 1$        cmp.b   #'k',inputbuffer
  4168.         bne.s   2$
  4169.         move.l  excpttask(PC),a1
  4170.         tst.l   22(a1)
  4171.         bne.s   3$
  4172.         CALL    RemTask,_SysBase(PC)
  4173.         bra.s   4$
  4174. 3$        move.l  a1,d0
  4175.         bsr     canok
  4176. 4$        clr.l   lastprinted
  4177.         rts
  4178.  
  4179. myaddtask   move.l  a3,-(a7)
  4180.         lea     mytrap(PC),a3
  4181.         move.l  50(a1),d0
  4182.         beq.s   1$
  4183.         cmp.l   oldtrap(PC),d0
  4184.         beq.s   1$
  4185.         lea     myproctrap(PC),a3
  4186.         cmp.l   oldproctrap(PC),d0
  4187.         bne.s   2$
  4188. 1$        move.l  a3,50(a1)
  4189. 2$        move.l  (a7)+,a3
  4190.         dc.w    $4ef9
  4191. OldAddTask  dc.l    0
  4192.  
  4193. myproctrap  bsr     traphandle
  4194.         dc.w    $4ef9
  4195. oldproctrap dc.l    0
  4196.  
  4197. mytrap        bsr     traphandle
  4198.         moveq   #0,d0
  4199.         CALL    Wait,_SysBase(PC)
  4200.         dc.w    $4ef9
  4201. oldtrap     dc.l    0
  4202.  
  4203. traphandle  movem.l d0-d7/a0-a6,$180
  4204.         move.l  4,a6
  4205.         move.l  276(a6),excpttask
  4206.         move.l  4(a7),d0
  4207.         cmp.l   #9,d0
  4208.         beq.s   2$
  4209.         move.l  d0,excpterror
  4210.         moveq   #10,d1
  4211.         cmp.l   #3,d0
  4212.         bne.s   1$
  4213.         move.l  0(a7,d1.w),excptaddr
  4214.         moveq   #18,d1
  4215. 1$        move.l  0(a7,d1.w),excptpc
  4216.         move.l  mytask(PC),a1
  4217.         move.l  trapsignal(PC),d0
  4218.         jsr     _LVOSignal(a6)
  4219. 2$        movem.l $180,d0-d7/a0-a6
  4220.         rts
  4221.  
  4222. trapguru    tst.b   wanttraps
  4223.         bne     restoretrap
  4224.         move.b  #1,wanttraps
  4225.  
  4226. addtraps    tst.b   wanttraps
  4227.         beq     5$
  4228.         move.l  304(a6),oldtrap         ;Original EXEC trap handler
  4229.         moveq   #-1,d0
  4230.         CALL    AllocSignal,_SysBase(PC)
  4231.         moveq   #0,d1
  4232.         bset    d0,d1
  4233.         move.l  d1,trapsignal
  4234.         move.l  #_LVOAddTask,a0        ;need a new AddTask() to change
  4235.         move.l  2(a6,a0),OldAddTask     ;AmigaDos's default trap handler
  4236.         move.l  a6,a1
  4237.         move.l  #myaddtask,d0
  4238.         CALL    SetFunction,_SysBase(PC)
  4239.         CALL    Forbid,_SysBase(PC)     ;change the trap handler of
  4240.         moveq   #0,d5            ;aleady running tasks
  4241.         bsr     getaskdat            ;get task stucture pointers
  4242. 1$        tst.b   entries
  4243.         beq.s   2$
  4244.         lea     -16(a5),a5
  4245.         move.l  0(a5),a4                ;pointer to a task structure
  4246.         lea     myproctrap(PC),a0
  4247.         move.l  50(a4),d0               ;Task->tc_TrapCode
  4248.         cmp.l   oldproctrap(PC),d0      ;AmigaDos Handler ?
  4249.         beq.s   3$
  4250.         lea     mytrap(PC),a0           ;EXEC Handler ?
  4251.         cmp.l   oldtrap(PC),d0
  4252.         bne.s   4$                ;must be a custom one, skip it
  4253. 3$        move.l  a0,50(a4)               ;replace it
  4254. 4$        subq.b  #1,entries
  4255.         bra.s   1$
  4256. 2$        CALL    Permit,_SysBase(PC)
  4257. 5$        rts
  4258.  
  4259. restoretrap tst.b   wanttraps
  4260.         beq.s   6$
  4261.         tst.b   fromfile
  4262.         bne.s   5$
  4263.         move.l  #_LVOAddTask,a0
  4264.         move.l  OldAddTask(PC),d0
  4265.         move.l  _SysBase(PC),a1
  4266.         CALL    SetFunction,_SysBase(PC)
  4267.         CALL    Forbid,_SysBase(PC)
  4268.         bsr     getaskdat
  4269. 1$        tst.b   entries
  4270.         beq.s   2$
  4271.         lea     -16(a5),a5
  4272.         move.l  0(a5),a4
  4273.         move.l  oldproctrap(PC),a0
  4274.         move.l  50(a4),d0
  4275.         cmp.l   #myproctrap,d0
  4276.         beq.s   3$
  4277.         move.l  oldtrap(PC),a0
  4278.         cmp.l   #mytrap,d0
  4279.         bne.s   4$
  4280. 3$        move.l  a0,50(a4)
  4281. 4$        subq.b  #1,entries
  4282.         bra.s   1$
  4283. 2$        CALL    Permit,_SysBase(PC)
  4284.         clr.l   trapsignal
  4285. 5$        clr.b   wanttraps
  4286. 6$        rts
  4287.  
  4288. ;save the contents of the output buffer
  4289. ;to a file
  4290. saveoutput  bsr     nodenam2
  4291.         tst.b   0(a5)
  4292.         beq     syntax
  4293.         move.l  a5,d1
  4294.         move.l  #1006,d2
  4295.         CALL    Open,dosbase(PC)
  4296.         move.l  d0,d5
  4297.         bne.s   1$
  4298.         move.l  #openerr,d0
  4299.         bsr     putstr
  4300.         move.l  a5,d0
  4301.         bra     putnam
  4302. 1$        move.l  outchain(PC),d0
  4303.         beq.s   3$
  4304. 2$        move.l  d0,a5
  4305.         move.w  12(a5),d3
  4306.         beq.s   4$
  4307.         ext.l   d3
  4308.         lea     14(a5),a1
  4309.         move.l  a1,d2
  4310.         move.l  d5,d1
  4311.         CALL    Write,dosbase(PC)
  4312.         tst.l   d0
  4313.         ble.s   3$
  4314. 4$        moveq   #1,d3
  4315.         move.l  d5,d1
  4316.         move.l  #cr,d2
  4317.         CALL    Write,dosbase(PC)
  4318.         tst.l   d0
  4319.         ble.s   3$
  4320.         move.l  0(a5),d0
  4321.         bne.s   2$
  4322. 3$        move.l  d5,d1
  4323.         CALL    Close,dosbase(PC)
  4324.         rts
  4325.  
  4326. grabtimerio lea     tiohead(PC),a0
  4327.         bsr     puthead
  4328.         move.b  timeout(PC),d4
  4329.         move.b  #255,timeout
  4330.         bsr     starttimer
  4331.         move.b  d4,timeout
  4332.         lea     timerio,a1
  4333.         CALL    Disable,_SysBase(PC)
  4334. 2$        move.l  0(a1),d2
  4335.         beq.s   1$
  4336.         move.l  d2,a1
  4337.         bra.s   2$
  4338. 1$        CALL    Enable,_SysBase(PC)
  4339.         lea     -4(a1),a5
  4340.         bsr     stoptimer
  4341.         lea     buffer,a4
  4342.         moveq   #1,d4
  4343.         bsr     gettrq
  4344.  
  4345.         lea     timerio,a0
  4346.         lea     dummy,a1
  4347.         moveq   #40,d0
  4348.         CALL    CopyMem,_SysBase(PC)
  4349.  
  4350.         lea     dummy,a1
  4351.         lea     timernam(PC),a0
  4352.         moveq   #0,d1
  4353.         moveq   #0,d0
  4354.         CALL    OpenDevice,_SysBase(PC)
  4355.  
  4356.         lea     dummy,a1
  4357.         move.l  #1<<30,32(a1)
  4358.         CALL    SendIO,_SysBase(PC)
  4359.  
  4360.         lea     dummy,a5
  4361.         CALL    Disable,_SysBase(PC)
  4362. 8$        move.l  0(a5),d2
  4363.         beq.s   7$
  4364.         move.l  d2,a5
  4365.         bra.s   8$
  4366. 7$        CALL    Enable,_SysBase(PC)
  4367.         lea     -4(a5),a5
  4368.  
  4369.         lea     dummy,a1
  4370.         CALL    AbortIO,_SysBase(PC)
  4371.         lea     timerio,a1
  4372.         CALL    WaitIO,_SysBase(PC)
  4373.         move.w  timersig,d0
  4374.         moveq   #0,d1
  4375.         bset    d0,d1
  4376.         moveq   #0,d0
  4377.         CALL    SetSignal,_SysBase(PC)
  4378.  
  4379.         moveq   #0,d4
  4380.         bsr     gettrq
  4381.  
  4382.         lea     dummy,a1
  4383.         CALL    CloseDevice,_SysBase(PC)
  4384.  
  4385.         clr.l   (a4)+
  4386.         lea     -22(a4),a2
  4387.         moveq   #18,d2
  4388.         bsr     sortlist
  4389.  
  4390.         lea     buffer,a5
  4391. 5$        move.l  (a5)+,d0
  4392.         beq.s   6$
  4393.         bsr     hexa
  4394.         move.w  (a5)+,d0
  4395.         ext.l   d0
  4396.         mulu    #9,d0
  4397.         add.l   #timerunits,d0
  4398.         bsr     putstr
  4399.         move.l  (a5)+,d3
  4400.         mulu    #10,d3
  4401.         move.l  (a5)+,d0
  4402.         move.l  #100000,d1
  4403.         bsr     div
  4404.         add.l   d3,d0
  4405.         cmp.l   #2559,d0
  4406.         ble.s   9$
  4407.         move.l  #whatsthis,d0
  4408.         bsr     putstr
  4409.         bra.s   10$
  4410. 9$        moveq   #1,d6
  4411.         bsr     putfrac
  4412. 10$        move.b  #' ',d0
  4413.         bsr     putchar
  4414.         move.l  (a5)+,a1
  4415.         move.l  10(a1),d0
  4416.         bsr     putnam
  4417.         bra.s   5$
  4418. 6$        rts
  4419.  
  4420. gettrq        CALL    Disable,_SysBase(PC)
  4421. 3$        move.l  0(a5),a5
  4422.         tst.l   0(a5)
  4423.         beq.s   4$
  4424.         move.l  a5,(a4)+
  4425.         move.w  d4,(a4)+
  4426.         move.l  32(a5),(a4)+
  4427.         move.l  36(a5),(a4)+
  4428.         move.l  14(a5),a1
  4429.         move.l  16(a1),(a4)+
  4430.         bra.s   3$
  4431. 4$        CALL    Enable,_SysBase(PC)
  4432.         rts
  4433.  
  4434.  
  4435. ;check if the timer is runnig, start it if not
  4436. starttimer  lea     timerio,a1
  4437.         cmp.b   #5,8(a1)
  4438.         beq.s   1$
  4439.         moveq   #0,d0
  4440.         move.l  d0,36(a1)
  4441.         move.b  timeout(PC),d0
  4442.         beq.s   1$
  4443.         move.l  d0,32(a1)
  4444.         move.w  #9,28(a1)
  4445.         CALL    SendIO,_SysBase(PC)
  4446. 1$        rts
  4447. ;Abort a timer request, if pending
  4448. stoptimer   lea     timerio,a1
  4449.         cmp.b   #5,8(a1)
  4450.         bne.s   1$
  4451.         CALL    AbortIO,_SysBase(PC)
  4452.         lea     timerio,a1
  4453.         CALL    WaitIO,_SysBase(PC)
  4454. 1$        move.w  timersig,d0
  4455.         moveq   #0,d1
  4456.         bset    d0,d1
  4457.         moveq   #0,d0
  4458.         CALL    SetSignal,_SysBase(PC)
  4459.         rts
  4460. ;Xoper main loop, process all incoming messages
  4461. processmsgs move.l  wnptr(PC),a0
  4462.         moveq   #0,d0
  4463.         move.w  intuisig(PC),d1
  4464.         bset    d1,d0
  4465.         move.w  timersig(PC),d1
  4466.         bset    d1,d0
  4467.         or.w    #4096,d0
  4468.         or.l    auxsig(PC),d0
  4469.         tst.l   auxsig
  4470.         bne.s   1$
  4471.         or.l    trapsignal(PC),d0
  4472. 1$        CALL    Wait,_SysBase(PC)
  4473.  
  4474.         move.l  d0,tasksigs
  4475.  
  4476.         move.l  trapsignal(PC),d1
  4477.         and.l   d0,d1
  4478.         beq.s   ctrl_c
  4479.         tst.b   gotguru
  4480.         bne.s   ctrl_c
  4481.         move.b  #1,gotguru
  4482.         bsr     showguru
  4483.         clr.b   gotguru
  4484.  
  4485. ctrl_c        move.q  #12,d1
  4486.         bsr     testsig
  4487.         bne     exit
  4488.  
  4489.  
  4490. timermsg    move.w  timersig(PC),d1
  4491.         bsr     testsig
  4492.         beq     intuimsgs
  4493.         tst.w   repeat
  4494.         bne.s   1$
  4495.         bsr     showwhat
  4496.         bra.s   intuimsgs
  4497. 1$        move.w  repeatlen,d0
  4498.         lea     repeatbuffer,a2
  4499.         lea     dummy,a1
  4500.         move.w  d0,d1
  4501. 2$        move.b  (a2)+,(a1)+
  4502.         dbf     d1,2$
  4503.         bsr     cli
  4504.         bsr     starttimer
  4505.  
  4506. intuimsgs   move.w  intuisig(PC),d1
  4507.         bsr     testsig
  4508.         beq     processnxtmsg
  4509. nextimsg    move.l  wnptr(PC),a0
  4510.         move.l  $56(a0),a0
  4511.         CALL    GetMsg,_SysBase(PC)
  4512.         tst.l   d0
  4513.         beq     processnxtmsg
  4514.         move.l  d0,intuimsg
  4515.  
  4516.         move.l  d0,a0
  4517.         move.l  20(a0),d0
  4518.  
  4519.         cmp.l   #$200,d0        ;CloseWindow
  4520.         bne.s   1$
  4521.         tst.b   addlines
  4522.         beq     exitall
  4523.         move.b  #1,cbreak
  4524.         bra     intuiend
  4525.  
  4526. 1$        cmp.l   #2,d0        ;ResizeWindow
  4527.         bne.s   2$
  4528.         bsr     setupscreen
  4529.         bra     intuiend
  4530.  
  4531. 2$        cmp.l   #4,d0        ;refresh
  4532.         bne.s   22$
  4533.         bsr     putiline
  4534.         bsr     blastout
  4535.         bsr     UpdateIArea
  4536.         bra     intuiend
  4537.  
  4538. 22$        tst.b   addlines
  4539.         bne     3$
  4540.         cmp.l   #$40,d0        ;gadgetup
  4541.         bne.s   3$
  4542.         tst.w   getanswer
  4543.         bne.s   3$
  4544.         bsr     replyintui
  4545.         bra     instback
  4546.  
  4547. 3$        cmp.l   #$400,d0        ;RawKey
  4548.         bne     notarawkey
  4549.         move.w  #$80,d0
  4550.         and.w   24(a0),d0
  4551.         bne     intuiend
  4552.         and.w   #$7f,24(a0)
  4553.         lea     ievent,a1
  4554.         move.b  #1,4(a1)
  4555.         move.l  24(a0),6(a1)
  4556.         move.w  26(a0),qualifier
  4557.         move.l  a1,a0
  4558.         lea     outevent,a1
  4559.         moveq   #20,d1
  4560.         suba.l  a2,a2
  4561.         CALL    RawKeyConvert,condev(PC)
  4562.         tst.l   d0
  4563.         beq     intuiend
  4564.         lea     inputbuffer,a1
  4565.         lea     outevent,a2
  4566.         move.w  curpos(PC),d4
  4567.         moveq   #0,d3
  4568.         tst.b   addlines
  4569.         bne     197$
  4570.  
  4571.         cmp.b   #$9b,0(a2)          ;CSI
  4572.         bne     110$
  4573.  
  4574.         cmp.b   #'?',1(a2)          ;help
  4575.         bne.s   399$
  4576.         tst.w   getanswer
  4577.         bne.s   399$
  4578.         bsr     stoptimer
  4579.         tst.w   bottomin
  4580.         bne.s   398$
  4581.         move.w  #1,bottomin
  4582.         clr.w   ibufferlen
  4583.         clr.w   curpos
  4584.         bsr     UpdateIArea
  4585. 398$        move.l  #usetxt,d0
  4586.         bsr     putnam
  4587.         clr.l   lastprinted
  4588.         bsr     blastout
  4589.         bra.s   420$
  4590.  
  4591. 399$        cmp.b   #'C',1(a2)          ;cursor right
  4592.         bne.s   400$
  4593.         cmp.w   ibufferlen(PC),d4
  4594.         bge.s   420$
  4595.         addq    #1,d4
  4596. 421$        move.w  d4,curpos
  4597. 420$        bra     100$
  4598.  
  4599. 400$        cmp.b   #'D',1(a2)          ;cursor left
  4600.         bne.s   401$
  4601.         subq    #1,d4
  4602.         bpl.s   421$
  4603.         bra.s   420$
  4604.  
  4605. 401$        cmp.b   #' ',1(a2)
  4606.         bne.s   402$
  4607.  
  4608.         cmp.b   #'@',2(a2)          ;shift right
  4609.         bne.s   403$
  4610.  
  4611. 404$        cmp.w   ibufferlen(PC),d4
  4612.         bge.s   421$
  4613.         addq    #1,d4
  4614.         cmp.b   #' ',0(a1,d4)
  4615.         bne.s   404$
  4616. 405$        cmp.w   ibufferlen(PC),d4
  4617.         bge.s   421$
  4618.         addq    #1,d4
  4619.         cmp.b   #' ',0(a1,d4)
  4620.         beq.s   405$
  4621.         bra.s   421$
  4622.  
  4623. 403$        cmp.b   #'A',2(a2)          ;shift left
  4624.         bne.s   420$
  4625. 406$        tst.w   d4
  4626.         beq.s   421$
  4627.         subq    #1,d4
  4628.         cmp.b   #' ',0(a1,d4)
  4629.         beq.s   406$
  4630. 407$        tst.w   d4
  4631.         beq.s   421$
  4632.         subq    #1,d4
  4633.         cmp.b   #' ',0(a1,d4)
  4634.         bne.s   407$
  4635.         addq    #1,d4
  4636.         bra.s   421$
  4637.  
  4638. 402$        cmp.b   #'A',1(a2)          ;cursor up
  4639.         bne.s   408$
  4640.         tst.w   bottomin
  4641.         bne.s   480$
  4642.         tst.w   curpos
  4643.         bne.s   480$
  4644.  
  4645.         clr.w   curpos
  4646.         clr.w   ibufferlen
  4647.         bsr     UpdateIArea
  4648.         bsr     clrcursor
  4649.         move.w  edline(PC),d3
  4650.         ext.l   d3
  4651.         tst.w   d3
  4652.         beq.s   481$
  4653.         subq    #1,d3
  4654.         cmp.l   firstline(PC),d3
  4655.         bge.s   481$
  4656.         move.l  d3,-(a7)
  4657.         subq.l  #1,firstline
  4658.         bsr     blastout
  4659.         move.l  (a7)+,d3
  4660. 481$        move.w  d3,edline
  4661.         bsr     getcurpos
  4662.         bsr     putcursor
  4663.         bra     intuiend
  4664. 480$        move.l  history(PC),a0
  4665.         tst.l   0(a0)
  4666.         beq.s   423$
  4667.         move.l  curhist(PC),a1
  4668.         cmp.l   a0,a1
  4669.         beq.s   409$
  4670.         move.l  4(a1),d0
  4671.         move.l  d0,curhist
  4672. 409$        move.l  a1,gothline
  4673.         bsr     copyhistory
  4674. 423$        bra     100$
  4675.  
  4676. 408$        cmp.b   #'B',1(a2)          ;cursor down
  4677.         bne     410$
  4678.         tst.w   bottomin
  4679.         bne.s   414$
  4680.         tst.w   curpos
  4681.         bne.s   414$
  4682.  
  4683.         clr.w   curpos
  4684.         clr.w   ibufferlen
  4685.         bsr     UpdateIArea
  4686.         bsr     clrcursor
  4687.         move.w  edline(PC),d3
  4688.         ext.l   d3
  4689.         move.l  numlines(PC),d4
  4690.         subq    #1,d4
  4691.         cmp.l   d4,d3
  4692.         beq.s   490$
  4693.         move.l  firstline(PC),d2
  4694.         add.w   rows(PC),d2
  4695.         subq    #1,d2
  4696.         addq    #1,d3
  4697.         cmp.w   d2,d3
  4698.         ble.s   490$
  4699.         move.l  d3,-(a7)
  4700.         addq.l  #1,firstline
  4701.         bsr     blastout
  4702.         move.l  (a7)+,d3
  4703. 490$        bra     481$
  4704. 414$        move.l  curhist(PC),d0
  4705.         beq.s   423$
  4706.         move.l  d0,a1
  4707.         move.l  0(a1),a1
  4708.         tst.l   0(a1)
  4709.         bne.s   411$
  4710.         clr.l   gothline
  4711.         clr.w   curpos
  4712.         clr.w   ibufferlen
  4713.         bra     423$
  4714. 411$        move.l  a1,curhist
  4715.         bra     409$
  4716.  
  4717. 410$        cmp.b   #'T',1(a2)          ;shift up
  4718.         bne.s   412$
  4719.         tst.w   hnum
  4720.         beq     423$
  4721.         move.l  history(PC),a1
  4722.         move.l  a1,curhist
  4723.         bra     409$
  4724.  
  4725. 412$        cmp.b   #'S',1(a2)          ;shift down
  4726.         bne     423$
  4727.         tst.w   hnum
  4728.         beq     423$
  4729.         move.l  history+8,curhist
  4730.         bra.s   414$
  4731.  
  4732. 110$        moveq   #0,d3
  4733. 101$        move.w  curpos(PC),d4
  4734.         tst     d0
  4735.         beq     100$
  4736.         cmp.b   #13,0(a2,d3)        ;return
  4737.         beq     got_enter
  4738.  
  4739.         cmp.b   #27,0(a2,d3)        ;esc
  4740.         bne     799$
  4741.         tst.w   getanswer
  4742.         bne     100$
  4743.         clr.b   insmode
  4744.         clr.w   ibufferlen
  4745.         move.w  #200,curpos
  4746.         bsr     UpdateIArea
  4747.         clr.w   curpos
  4748.         tst.w   bottomin
  4749.         bne.s   700$
  4750.         move.w  #1,bottomin
  4751.         bsr     getcurpos
  4752.         cmp.b   #5,timerstate
  4753.         bne.s   765$
  4754.         bsr     starttimer
  4755. 765$        bra     100$
  4756.  
  4757. 700$        move.b  timerio+8,timerstate
  4758.         bsr     stoptimer
  4759.         move.w  edline(PC),d0
  4760.         move.l  firstline(PC),d4
  4761.         cmp.w   d4,d0
  4762.         bmi.s   701$
  4763.         move.w  d4,d5
  4764.         add.w   rows(PC),d5
  4765.         cmp.w   d5,d0
  4766.         bmi.s   702$
  4767. 701$        move.w  rows(PC),d0
  4768.         lsr.w   #1,d0
  4769.         add.w   d4,d0
  4770. 702$        move.l  numlines(PC),d3
  4771.         subq    #1,d3
  4772.         cmp.w   d3,d0
  4773.         ble.s   703$
  4774.         move.w  d3,d0
  4775. 703$        move.w  d0,edline
  4776.         sub.w   d4,d0
  4777.         lsl.w   #3,d0
  4778.         add.w   #18,d0
  4779.         move.w  d0,cposy
  4780.         clr.w   bottomin
  4781.         tst.w   loffset
  4782.         beq.s   704$
  4783.         clr.w   loffset
  4784.         bsr     blastout
  4785. 704$        bra     100$
  4786.  
  4787. 799$        cmp.b   #8,0(a2,d3)         ;Backspace
  4788.         bne.s   114$
  4789.         tst.w   d4
  4790.         beq     102$
  4791.         bsr     delchar
  4792.         subq    #1,d4
  4793.         move.w  d4,curpos
  4794.         bra     102$
  4795.  
  4796. 114$        cmp.b   #127,0(a2,d3)       ;del
  4797.         bne.s   197$
  4798. 178$        cmp.w   ibufferlen(PC),d4
  4799.         bge     102$
  4800.         addq    #1,d4
  4801.         bsr     delchar
  4802.         bra     102$
  4803.  
  4804. 197$        cmp.b   #3,0(a2,d3)         ;ctrl c
  4805.         bne.s   104$
  4806.         move.b  #1,cbreak
  4807.  
  4808. 104$        tst.b   addlines
  4809.         bne     processnxtmsg
  4810.         cmp.b   #$18,0(a2,d3)       ;ctrl x
  4811.         bne.s   300$
  4812.         clr.w   ibufferlen
  4813.         clr.w   curpos
  4814.         bra     100$
  4815.  
  4816. 300$        cmp.b   #$19,0(a2,d3)       ;ctrl y
  4817.         bne.s   106$
  4818.         move.w  curpos,ibufferlen
  4819.         bra     100$
  4820.  
  4821. 106$        move.w  #$100,d5        ;NumPad
  4822.         and.w   qualifier(PC),d5
  4823.         beq     105$
  4824.         move.l  firstline(PC),d5
  4825.  
  4826.         cmp.b   #'7',0(a2,d3)       ;'Home'
  4827.         bne.s   200$
  4828.         moveq   #0,d5
  4829. 199$        move.l  d5,firstline
  4830.         bsr     blastout
  4831.         tst.w   bottomin
  4832.         bne.s   196$
  4833.         move.w  edline(PC),d0
  4834.         move.l  firstline(PC),d1
  4835.         cmp.w   d1,d0
  4836.         bmi.s   190$
  4837.         add.w   rows(PC),d1
  4838.         cmp.w   d1,d0
  4839.         bmi.s   192$
  4840. 190$        clr.w   curpos
  4841.         clr.w   ibufferlen
  4842.         move.w  rows(PC),d0
  4843.         lsr.w   #1,d0
  4844.         ext.l   d0
  4845.         add.l   firstline(PC),d0
  4846.         cmp.l   numlines(PC),d0
  4847.         bmi.s   191$
  4848.         move.l  numlines(PC),d0
  4849.         subq    #1,d0
  4850. 191$        move.w  d0,edline
  4851. 192$        bsr     getcurpos
  4852.         bsr     UpdateIArea
  4853. 196$        bra     100$
  4854.  
  4855. 200$        cmp.b   #'8',0(a2,d3)       ;'up arrow'
  4856.         bne.s   201$
  4857.         tst     d5
  4858.         beq     100$
  4859.         subq    #1,d5
  4860.         bra.s   199$
  4861.  
  4862. 201$        cmp.b   #'9',0(a2,d3)       ;'PgUp'
  4863.         bne.s   203$
  4864.         sub.w   rows(PC),d5
  4865.         bpl.s   199$
  4866.         moveq   #0,d5
  4867.         bra.s   199$
  4868.  
  4869. 203$        cmp.b   #'1',0(a2,d3)       ;'End'
  4870.         bne.s   205$
  4871. 222$        move.l  numlines(PC),d5
  4872.         sub.w   rows(PC),d5
  4873.         bpl     199$
  4874.         moveq   #0,d5
  4875. 204$        bra     199$
  4876.  
  4877. 205$        cmp.b   #'2',0(a2,d3)       ;'down arrow'
  4878.         bne.s   206$
  4879.         move.l  d5,d2
  4880.         add.w   rows(PC),d2
  4881.         cmp.l   numlines(PC),d2
  4882.         bge     100$
  4883.         addq    #1,d5
  4884.         bra     199$
  4885.  
  4886. 206$        cmp.b   #'3',0(a2,d3)       ;'PgDn'
  4887.         bne.s   500$
  4888.         add.w   rows(PC),d5
  4889.         move.l  d5,d2
  4890.         add.w   rows(PC),d2
  4891.         cmp.l   numlines(PC),d2
  4892.         bge.s   222$
  4893.         bra     199$
  4894.  
  4895. 500$        cmp.b   #'4',0(a2,d3)       ;left arrow
  4896.         bne.s   501$
  4897.         tst.w   bottomin
  4898.         beq     102$
  4899.         move.w  loffset(PC),d2
  4900.         sub.w   colms(PC),d2
  4901.         bpl.s   502$
  4902.         moveq   #0,d2
  4903. 502$        move.w  d2,loffset
  4904.         bsr     blastout
  4905.         bra     100$
  4906.  
  4907. 501$        cmp.b   #'6',0(a2,d3)       ;right arrow
  4908.         bne.s   170$
  4909.         tst.w   bottomin
  4910.         beq     102$
  4911.         move.w  loffset(PC),d2
  4912.         add.w   colms(PC),d2
  4913.         bra.s   502$
  4914.  
  4915. 170$        cmp.b   #'0',0(a2,d3)       ;Ins
  4916.         bne.s   177$
  4917.         eor.b   #1,insmode
  4918.         bra.s   102$
  4919.  
  4920. 177$        cmp.b   #'.',0(a2,d3)       ;Del
  4921.         beq     178$
  4922.  
  4923. 105$        tst.w   bottomin
  4924.         bne.s   777$
  4925.         tst.w   curpos
  4926.         bne.s   777$
  4927.         movem.l d0-d1,-(a7)
  4928.         move.w  edline(PC),d0
  4929.         bsr     findline
  4930.         movem.l (a7)+,d0-d1
  4931.         tst.l   8(a5)
  4932.         beq     intuiend
  4933. 777$        move.w  curpos(PC),d5
  4934.         ext.l   d5
  4935.         moveq   #79,d2
  4936.         cmp.w   d2,d5
  4937.         bge     102$
  4938.         tst.b   insmode
  4939.         beq.s   172$
  4940.         cmp.w   ibufferlen(PC),d5
  4941.         bmi.s   171$
  4942.         bra.s   173$
  4943. 172$        sub     d5,d2
  4944.         lea     80(a1),a4
  4945.         lea     79(a1),a3
  4946. 103$        move.b  -(a3),-(a4)
  4947.         dbf     d2,103$
  4948. 173$        addq.w  #1,ibufferlen
  4949. 171$        move.b  0(a2,d3),0(a1,d5)
  4950.         addq.w  #1,curpos
  4951. 102$        subq    #1,d0
  4952.         addq    #1,d3
  4953.         bra     101$
  4954.  
  4955. 100$        bsr     UpdateIArea
  4956.         bra     intuiend
  4957.  
  4958. got_enter   bsr     stoptimer
  4959.         bsr     puthist
  4960.         clr.b   insmode
  4961.         lea     dummy,a1
  4962.         lea     inputbuffer,a2
  4963.         move.w  ibufferlen(PC),d2
  4964.         beq.s   2$
  4965.         tst.w   bottomin
  4966.         bne.s   5$
  4967.         movem.l a1-a2,-(a7)
  4968.         move.w  edline(PC),d0
  4969.         bsr     findline
  4970.         move.l  8(a5),d0
  4971.         bsr     gthex
  4972.         lea     hexarea(PC),a0
  4973.         lea     0(a2,d2),a1
  4974.         move.b  #' ',(a1)+
  4975.         move.b  #'$',(a1)+
  4976.         moveq   #8,d0
  4977.         CALL    CopyMem,_SysBase(PC)
  4978.         move.w  ibufferlen(PC),d2
  4979.         add.w   #10,d2
  4980.         move.w  d2,ibufferlen
  4981.         movem.l (a7)+,a1-a2
  4982. 5$        subq    #1,d2
  4983. 1$        move.b  (a2)+,(a1)+
  4984.         dbf     d2,1$
  4985. 2$        move.b  #10,(a1)+
  4986.         move.w  ibufferlen(PC),d0
  4987.         ext.l   d0
  4988.         addq    #1,d0
  4989.         move.l  d0,-(a7)
  4990.         clr.w   ibufferlen
  4991.         tst.w   bottomin
  4992.         bne.s   4$
  4993.         move.w  #100,curpos
  4994.         bsr     UpdateIArea
  4995. 4$        clr.w   curpos
  4996.         move.w  #1,bottomin
  4997.         bsr     getcurpos
  4998.         bsr     UpdateIArea
  4999.         move.l  (a7)+,d0
  5000.         move.w  d0,repeatlen
  5001.         clr.w   repeat
  5002.         clr.b   printed
  5003.         tst.w   getanswer
  5004.         beq.s   6$
  5005.         rts
  5006. 6$        bsr     cli
  5007.         tst.b   printed
  5008.         bne.s   3$
  5009.         bsr     starttimer
  5010. 3$        bra     intuiend
  5011.  
  5012. notarawkey
  5013.  
  5014. intuiend    bsr.s   replyintui
  5015.         bra     nextimsg
  5016. processnxtmsg
  5017.         tst.b   addlines
  5018.         beq.s   1$
  5019.         rts
  5020. 1$        bra     processmsgs
  5021.  
  5022. replyintui  move.l  intuimsg(PC),d0
  5023.         beq.s   1$
  5024.         move.l  d0,a1
  5025.         CALL    ReplyMsg,_SysBase
  5026. 1$        clr.l   intuimsg
  5027.         rts
  5028.  
  5029. ;put an input line into the history buffer
  5030. puthist     move.w  ibufferlen(PC),d5
  5031.         move.l  d5,d0
  5032.         cmp.w   minnumchars(PC),d0
  5033.         bcs     1$
  5034.  
  5035.         move.l  gothline(PC),d1
  5036.         beq.s   5$
  5037.         move.l  d1,a2
  5038.         cmp.w   8(a2),d5
  5039.         bne.s   5$
  5040.         lea     10(a2),a2
  5041.         lea     inputbuffer,a1
  5042.         subq    #1,d0
  5043. 6$        cmp.b   (a2)+,(a1)+
  5044.         bne.s   5$
  5045.         dbf     d0,6$
  5046.         move.l  gothline,curhist
  5047.         bra.s   1$
  5048.  
  5049. 5$        move.w  d5,d0
  5050.         ext.l   d0
  5051.         add     #10,d0
  5052.         move.l  #$10000,d1         ;MEMF_CLEAR
  5053.         CALL    AllocMem,_SysBase(PC)
  5054.         tst.l   d0
  5055.         beq.s   1$
  5056.         move.l  d0,a0
  5057.         move.w  d5,8(a0)
  5058.         lea     10(a0),a2
  5059.         subq    #1,d5
  5060.         lea     inputbuffer,a1
  5061. 2$        move.b  (a1)+,(a2)+
  5062.         dbf     d5,2$
  5063.         move.w  hnum(PC),d5
  5064.         cmp.w   maxhlines(PC),d5
  5065.         bmi.s   3$
  5066.         bsr     remhistline
  5067.         bra.s   4$
  5068. 3$        addq    #1,d5
  5069.         move.w  d5,hnum
  5070. 4$        move.l  d0,a1
  5071.         move.l  d0,curhist
  5072.         lea     history(PC),a0
  5073.         CALL    AddTail,_SysBase(PC)
  5074. 1$        clr.l   gothline
  5075.         rts
  5076.  
  5077. ;copy a history line into the input buffer
  5078. copyhistory lea     inputbuffer,a0
  5079.         move.w  8(a1),d3
  5080.         ext.l   d3
  5081.         move.w  d3,curpos
  5082.         move.w  d3,ibufferlen
  5083.         subq    #1,d3
  5084.         lea     10(a1),a1
  5085. 1$        move.b  (a1)+,(a0)+
  5086.         dbf     d3,1$
  5087.         rts
  5088. ;remove one line from the history buffer
  5089. ;pointer to the line in A1, returns pointer to the next line in d1
  5090. remhistline move.l  d0,-(a7)
  5091.         lea     history(PC),a0
  5092.         move.l  0(a0),a5
  5093.         tst.l   0(a5)
  5094.         beq.s   1$
  5095.         CALL    RemHead,_SysBase(PC)
  5096.         move.l  a5,a1
  5097.         move.w  8(a1),d0
  5098.         add     #10,d0
  5099.         ext.l   d0
  5100.         CALL    FreeMem,_SysBase(PC)
  5101. 1$        move.l  (a7)+,d0
  5102.         rts
  5103.  
  5104. ;kill all history lines
  5105. killhistory bsr     remhistline
  5106.         move.l  history(PC),a0
  5107.         tst.l   0(a0)
  5108.         bne.s   killhistory
  5109. 2$        clr.w   hnum
  5110.         clr.l   curhist
  5111.         rts
  5112. ;delete one char from the input line
  5113. delchar     lea     inputbuffer,a3
  5114.         lea     0(a3,d4.w),a3
  5115.         lea     -1(a3),a4
  5116.         move    d4,d5
  5117. 1$        cmp.w   #78,d5
  5118.         bge.s   2$
  5119.         move.b  (a3)+,(a4)+
  5120.         addq    #1,d5
  5121.         bra.s   1$
  5122. 2$        subq.w  #1,ibufferlen
  5123.         rts
  5124.  
  5125. testsig     move.l  tasksigs(PC),d0
  5126.         btst    d1,d0
  5127.         rts
  5128.  
  5129. ;get the position of the input area
  5130. iareapos    move.l  wnptr(PC),a0
  5131.         move.w  10(a0),d0
  5132.         subq    #4,d0
  5133.         move.w  d0,ipos
  5134.         rts
  5135.  
  5136. ;Update the current position of the input line
  5137. getcurpos   tst.w   bottomin
  5138.         beq.s   1$
  5139.         move.w  ipos,cposy
  5140.         rts
  5141. 1$        move.w  edline(PC),d3
  5142.         sub.l   firstline(PC),d3
  5143.         lsl     #3,d3
  5144.         add.w   #18,d3
  5145.         move.w  d3,cposy
  5146.         rts
  5147. ;refresh the input area
  5148. UpdateIArea move.l  rastport(PC),a1
  5149.         move.l  #1,d0
  5150.         CALL    SetDrMd,gfxbase(PC)
  5151.         moveq   #6,d0
  5152.         move.w  cposy(PC),d1
  5153.         CALL    Move,gfxbase(PC)
  5154.         lea     inputbuffer,a0
  5155.         move.w  ibufferlen(PC),d0
  5156.         ext.l   d0
  5157.         move.w  colms(PC),d1
  5158.         sub.w   bottomin(PC),d1
  5159.         cmp.w   d1,d0
  5160.         bmi.s   1$
  5161.         move.w  d1,d0
  5162. 1$        move.w  d0,d2
  5163.         CALL    Text,gfxbase(PC)
  5164.  
  5165.         tst.w   bottomin
  5166.         bne.s   3$
  5167.         move.w  edline(PC),d0
  5168.         bsr     findline
  5169.         move.w  12(a5),d3
  5170.         sub.w   d2,d3
  5171.         bmi.s   3$
  5172.         move.w  colms(PC),d1
  5173.         sub.w   d2,d1
  5174.         bmi.s   2$
  5175.         cmp.w   d1,d3
  5176.         ble.s   4$
  5177.         move.w  d1,d3
  5178. 4$        move.w  d3,d0
  5179.         lea     14(a5,d2.w),a0
  5180.         move.l  rastport(PC),a1
  5181.         CALL    Text,gfxbase(PC)
  5182.         add.w   ibufferlen(PC),d3
  5183.         move.w  d3,d2
  5184.  
  5185. 3$        move.w  colms(PC),d0
  5186.         sub.w   bottomin(PC),d0
  5187.         move.l  blanks(PC),a0
  5188.         ext.l   d0
  5189.         sub.w   d2,d0
  5190.         bmi.s   2$
  5191.         lea     0(a0,d2.w),a0
  5192.         move.l  rastport(PC),a1
  5193.         CALL    Text,gfxbase(PC)
  5194. 2$        bsr     putcursor
  5195.         rts
  5196.  
  5197. clrcursor   moveq   #1,d7
  5198.         bra.s   ptc1
  5199. putcursor   moveq   #6,d7
  5200. ptc1        move.w  curpos(PC),d0
  5201.         move.w  colms(PC),d1
  5202.         subq    #1,d1
  5203.         sub.w   bottomin(PC),d1
  5204.         cmp.w   d0,d1
  5205.         bmi.s   1$
  5206.         move.l  rastport(PC),a1
  5207.         move.l  d7,d0
  5208.         CALL    SetDrMd,gfxbase(PC)
  5209.         move.w  cposy(PC),d1
  5210.         move.w  curpos(PC),d0
  5211.         lsl.w   #3,d0
  5212.         addq    #6,d0
  5213.         CALL    Move,gfxbase(PC)
  5214.         lea     oneblank(PC),a0
  5215.         moveq   #1,d0
  5216.         CALL    Text,gfxbase(PC)
  5217. 1$        rts
  5218. ;rebuild the window from scratch
  5219. setupscreen move.l  rastport(PC),a1
  5220.         moveq   #0,d0
  5221.         CALL    SetRast,gfxbase(PC)
  5222.         move.l  wnptr,a0
  5223.         CALL    RefreshWindowFrame,intuibase(PC)
  5224.         bsr     getwindowsize
  5225.         tst.w   bottomin
  5226.         bne.s   1$
  5227.         move.w  edline(PC),d0
  5228.         move.l  firstline(PC),d1
  5229.         move.w  rows(PC),d2
  5230.         move.w  d2,d4
  5231.         move.w  numlines(PC),d3
  5232.         add.w   d1,d2
  5233.         cmp.w   d2,d0
  5234.         bmi.s   2$
  5235.         lsr.w   #1,d4
  5236.         sub.w   d4,d0
  5237.         ext.l   d0
  5238.         move.l  d0,firstline
  5239. 2$        bsr     tstfirstlin
  5240. 1$        bsr     getcurpos
  5241.         bsr     putiline
  5242.         bsr     blastout
  5243.         bsr     UpdateIArea
  5244.         move.w  rows,currenty
  5245.         rts
  5246.  
  5247. putiline    move.l  rastport(PC),a1
  5248.         moveq   #1,d0
  5249.         CALL    SetAPen,gfxbase(PC)
  5250.         move.l  rastport(PC),a1
  5251.         moveq   #1,d0
  5252.         CALL    SetDrMd,gfxbase(PC)
  5253.         move.l  wnptr(PC),a5
  5254.         move.w  10(a5),d1
  5255.         sub.w   #12,d1
  5256.         moveq   #0,d0
  5257.         CALL    Move,gfxbase(PC)
  5258.         move.w  8(a5),d0
  5259.         move.w  d1,-(a7)
  5260.         CALL    Draw,gfxbase(PC)
  5261.         move.w  (a7)+,d1
  5262.         tst.b   ownscreen
  5263.         bne.s   1$
  5264.         move.w  8(a5),d0
  5265.         addq    #1,d1
  5266.         CALL    Move,gfxbase(PC)
  5267.         sub.w   #16,d0
  5268.         move.w  d1,-(a7)
  5269.         CALL    Draw,gfxbase(PC)
  5270.         move.w  (a7)+,d1
  5271.         move.w  8(a5),d0
  5272.         addq    #1,d1
  5273.         CALL    Move,gfxbase(PC)
  5274.         sub.w   #16,d0
  5275.         CALL    Draw,gfxbase(PC)
  5276. 1$        rts
  5277.  
  5278. getwindowsize
  5279.         bsr     freeblank
  5280.         move.l  wnptr(PC),a0
  5281.         move.w  10(a0),d0
  5282.         sub.w   #26,d0
  5283.         lsr.w   #3,d0
  5284.         move.w  d0,rows
  5285.         move.w  8(a0),d0
  5286.         sub.w   #12,d0
  5287.         lsr.w   #3,d0
  5288.         move.w  d0,colms
  5289.         ext.l   d0
  5290.         moveq   #0,d1
  5291.         move.l  d0,d6
  5292.         CALL    AllocMem,_SysBase(PC)
  5293.         move.l  d0,blanks
  5294.         move.l  d0,a0
  5295.         subq    #1,d6
  5296. 1$        move.b  #' ',(a0)+
  5297.         dbf     d6,1$
  5298.         bsr     iareapos
  5299.         rts
  5300.  
  5301. readline    move.b  #'n',inputbuffer
  5302.         tst.b   fromfile
  5303.         bne.s   1$
  5304.         move.l  #31000,firstline
  5305.         bsr     blastout
  5306.         move.w  #1,getanswer
  5307.         bsr     replyintui
  5308. 5$        bsr     processmsgs
  5309.         move.w  d0,d5
  5310.         bsr     replyintui
  5311.         subq    #1,d5
  5312.         beq.s   5$
  5313.         ori.b   #$20,inputbuffer
  5314.         clr.w   getanswer
  5315.         bsr     RestoreOutput
  5316. 1$        rts
  5317.  
  5318. ResumeOutput
  5319.         move.l  outchain(PC),d0
  5320.         move.l  d0,a1
  5321.         beq.s   2$
  5322.         move.l  numlines,oldnumlines
  5323.         move.l  firstline,oldfirstline
  5324. 4$        tst.l   0(a1)
  5325.         beq.s   3$
  5326.         move.l  0(a1),a1
  5327.         bra.s   4$
  5328. 3$        move.l  a1,lastprinted
  5329. 2$        move.l  a1,oldpageend
  5330.         rts
  5331.  
  5332. RestoreOutput
  5333.         move.l  oldpageend(PC),d3
  5334.         beq.s   1$
  5335.         move.l  oldnumlines(PC),numlines
  5336.         move.l  oldfirstline(PC),firstline
  5337.         move.l  oldlastprinted(PC),lastprinted
  5338.         move.l  d3,a1
  5339.         move.l  0(a1),a1
  5340.         bsr     killlines
  5341.         move.l  d3,a1
  5342.         clr.l   0(a1)
  5343.         bsr     blastout
  5344. 1$        rts
  5345.  
  5346. addline     movem.l d0-d6/a0-a3,-(a7)
  5347.         move.l  rastport(PC),a1
  5348.         moveq   #1,d0
  5349.         CALL    SetAPen,gfxbase(PC)
  5350.         move.l  rastport(PC),a1
  5351.         moveq   #1,d0
  5352.         CALL    SetDrMd,gfxbase(PC)
  5353.         move.w  currenty(PC),d6
  5354.         cmp.w   rows(PC),d6
  5355.         bmi.s   1$
  5356.         bsr     cls
  5357. 1$        move.l  lastprinted(PC),a0
  5358.         move.w  colms(PC),d5
  5359.         move.w  12(a0),d3
  5360.         lea     14(a0),a0
  5361.         move.w  currenty(PC),d6
  5362.         move    d6,d7
  5363.         lsl     #3,d6
  5364.         add.w   #18,d6
  5365.         moveq   #0,d4
  5366.         bsr     blastline
  5367.         addq.w  #1,currenty
  5368.         move.l  #31000,firstline
  5369.         movem.l (a7)+,d0-d6/a0-a3
  5370.         rts
  5371.  
  5372. cls        movem.l d0-d6/a0-a3,-(a7)
  5373.         move.l  rastport(PC),a1
  5374.         moveq   #1,d0
  5375.         CALL    SetAPen,gfxbase(PC)
  5376.         move.l  rastport(PC),a1
  5377.         moveq   #1,d0
  5378.         CALL    SetDrMd,gfxbase(PC)
  5379.         move.w  colms(PC),d5
  5380.         clr.w   d2
  5381. 1$        move.w  d2,d6
  5382.         move    d5,d7
  5383.         lsl     #3,d6
  5384.         add.w   #18,d6
  5385.         moveq   #0,d3
  5386.         move.l  blanks(PC),a0
  5387.         bsr     blastline
  5388.         addq    #1,d2
  5389.         cmp.w   rows(PC),d2
  5390.         bmi.s   1$
  5391.         clr.w   currenty
  5392.         movem.l (a7)+,d0-d6/a0-a3
  5393.         rts
  5394.  
  5395. createscreen moveq  #1,d1
  5396.         moveq   #80,d0
  5397.         lea     buffer,a0
  5398.         sub.l   a1,a1
  5399.         CALL    GetScreenData,intuibase(PC)
  5400.         move.w  buffer+76,nsviewmode
  5401.         move.l  buffer+12,nssize
  5402.         lea     newscreen(PC),a0
  5403.         CALL    OpenScreen,intuibase(PC)
  5404.         move.l  d0,screenptr
  5405.         move.l  d0,nwscreen
  5406.         move.w  #$f,nwtype
  5407.         beq.s   setupwindow
  5408.         tst.l   wnptr
  5409.         beq.s   1$
  5410.         move.l  wnptr(PC),a0
  5411.         move.l  4(a0),window_l
  5412.         move.l  8(a0),window_w
  5413.         CALL    CloseWindow,intuibase(PC)
  5414.         clr.l   intuimsg
  5415.         clr.l   wnptr
  5416. 1$        clr.l   newwindow
  5417.         move.l  buffer+12,newwindow+4
  5418.         move.l  wnscrflags(PC),nwflgs
  5419.         move.l  wnscrflags+4(PC),nwflgs+4
  5420.         move.b  #1,ownscreen
  5421.  
  5422. setupwindow tst.b   ownscreen
  5423.         bne.s   3$
  5424.         move.l  window_l(PC),newwindow
  5425.         move.l  window_w(PC),newwindow+4
  5426.         move.w  #1,nwtype
  5427.         move.l  wnnormflgs(PC),nwflgs
  5428.         move.l  wnnormflgs+4(PC),nwflgs+4
  5429. 3$        lea     newwindow(PC),a0
  5430.         CALL    OpenWindow,intuibase(PC)
  5431.         move.l  d0,wnptr
  5432.         beq     exit
  5433.         move.l  d0,a0
  5434.         move.l  50(a0),rastport    ;wn->RPort
  5435.         move.l  86(a0),a1          ;wn->UserPort
  5436.         move.b  15(a1),d1          ;MsgPort->SigBit
  5437.         ext.w   d1
  5438.         move.w  d1,intuisig
  5439.  
  5440.         tst.b   iconifyon
  5441.         beq.s   1$
  5442.         tst.b   ownscreen
  5443.         bne.s   1$
  5444.         lea     iconifgad,a1
  5445.         moveq   #0,d0
  5446.         CALL    AddGadget,intuibase(PC)
  5447.         move.l  wnptr(PC),a0
  5448.         CALL    RefreshWindowFrame,intuibase(PC)
  5449.  
  5450. 1$        lea     tattr(PC),a0
  5451.         CALL    OpenFont,gfxbase(PC)
  5452.         tst.l   d0
  5453.         beq.s   2$
  5454.         move.l  d0,a0
  5455.         move.l  rastport(PC),a1
  5456.         CALL    SetFont,gfxbase(PC)
  5457. 2$        bsr     getwindowsize
  5458.         bsr     getcurpos
  5459.  
  5460.         bsr     putiline
  5461.         bsr     UpdateIArea
  5462.         bsr     starttimer
  5463.         bsr     showwhat
  5464.         rts
  5465.  
  5466. usescreen   tst.b   fromfile
  5467.         bne.s   1$
  5468.         tst.b   ownscreen
  5469.         bne.s   1$
  5470.         bsr     createscreen
  5471. 1$        move.b  #1,ownscreen
  5472.         rts
  5473.  
  5474. usewindow   tst.b   fromfile
  5475.         beq.s   1$
  5476.         clr.b   ownscreen
  5477.         rts
  5478. 1$        tst.b   ownscreen
  5479.         beq.s   2$
  5480.         move.l  wnptr(PC),d0
  5481.         beq.s   3$
  5482.         move.l  d0,a0
  5483.         CALL    CloseWindow,intuibase(PC)
  5484.         clr.l   wnptr
  5485.         clr.l   intuimsg
  5486. 3$        move.l  screenptr(PC),d0
  5487.         beq.s   4$
  5488.         move.l  d0,a0
  5489.         CALL    CloseScreen,intuibase(PC)
  5490.         clr.l   screenptr
  5491.         clr.b   ownscreen
  5492. 4$        bra     setupwindow
  5493. 2$        rts
  5494.  
  5495. dchange     lea     dchead(PC),a0
  5496.         bsr     puthead
  5497.         lea     tdd(PC),a1
  5498.         move.l  _SysBase(PC),a0
  5499.         lea     350(a0),a0
  5500.         CALL    FindName,_SysBase(PC)
  5501.         tst.l   d0
  5502.         beq     R_T_S
  5503.         move.l  d0,a2
  5504.         lea     32(a2),a2
  5505.         moveq   #0,d5
  5506. 2$        lea     4(a2),a2
  5507.         move.l  0(a2),d0
  5508.         beq     3$
  5509.         move.l  d0,a0
  5510.         lea     $18e(a0),a0
  5511.         CALL    Disable,_SysBase(PC)
  5512. 5$        tst.l   0(a0)
  5513.         beq.s   6$
  5514.         move.l  0(a0),a0
  5515.         bra.s   5$
  5516. 6$        lea     -4(a0),a5
  5517.         lea     buffer+100,a3
  5518. 9$        move.l  0(a5),a5
  5519.         tst.l   0(a5)
  5520.         beq.s   11$
  5521.         move.l  a5,(a3)+
  5522.         bne.s   9$
  5523. 11$        clr.l   (a3)+
  5524.         CALL    Enable,_SysBase(PC)
  5525.         lea     buffer+100,a3
  5526. 7$        move.l  (a3)+,d0
  5527.         beq.s   3$
  5528.         move.l  d0,a5
  5529.         cmp.w   #20,28(a5)
  5530.         bne.s   7$
  5531.         move.l  40(a5),a4
  5532.         move.l  a4,d0
  5533.         move.l  d0,node
  5534.         bsr     hexan
  5535.         move.l  a4,d0
  5536.         beq.s   10$
  5537.         move.l  14(a4),d0
  5538.         bsr     hexan
  5539.         move.l  18(a4),d0
  5540.         bsr     hexan
  5541. 10$        move.l  d5,d3
  5542.         or.b    #48,d3
  5543.         move.b  d3,tddrives+2
  5544.         move.l  #tddrives,d0
  5545.         bsr     putstr
  5546.         move.l  14(a5),d0
  5547.         beq.s   8$
  5548.         move.l  d0,a0
  5549.         move.l  16(a0),d0
  5550.         beq.s   8$
  5551.         move.l  d0,a0
  5552.         move.l  10(a0),d0
  5553. 8$        bsr     putnam
  5554.         bra.s   7$
  5555. 3$        addq    #1,d5
  5556.         cmp.w   #4,d5
  5557.         bmi     2$
  5558. R_T_S        rts
  5559.  
  5560. dosbase     dc.l    0
  5561. intuibase   dc.l    0
  5562. gfxbase     dc.l    0
  5563. condev        dc.l    0
  5564. parmtxt     dc.l    0
  5565. fileptr     dc.l    0
  5566. infile        dc.l    0
  5567. ptr        dc.l    0
  5568. oldidl        dc.l    0
  5569. olddisp     dc.l    0
  5570. mysignal    dc.l    0
  5571. auxsig        dc.l    0
  5572. trapsignal  dc.l    0
  5573. iostatus    dc.l    -1
  5574. devstatus   dc.l    -1
  5575. tasksigs    dc.l    0
  5576. cancelbit   dc.l    0
  5577. cancelbnum  dc.l    0
  5578. _SysBase    dc.l    0
  5579. InputMsg    dc.l    0
  5580. InRequest   dc.l    0
  5581. startmess   dc.l    0
  5582. savedat     dc.l    0
  5583. wnptr        dc.l    0
  5584. aliaslist   dc.l    0
  5585. screenptr   dc.l    0
  5586. intuimsg    dc.l    0
  5587. mytask        dc.l    0
  5588. wbmsg        dc.l    0
  5589. pointer     dc.l    0
  5590. replyport   dc.l    0
  5591. timerport   dc.l    0
  5592. finfoptr    dc.l    0
  5593. myseg        dc.l    0
  5594. dispatches  dc.l    0
  5595. maxdisp     dc.l    0
  5596. deltadisp   dc.l    0
  5597. wbaddr        dc.l    0
  5598. node        dc.l    0
  5599. remembr     dc.l    0
  5600. remembr2    dc.l    0
  5601. captask     dc.l    0
  5602. snoopport   dc.l    0
  5603. tasksnum    dc.l    0
  5604. blanks        dc.l    0
  5605. hidestart   dc.l    0
  5606. dispnum     dc.l    0
  5607. iocount     dc.l    0
  5608. dummyinput  dc.l    0
  5609. rastport    dc.l    0
  5610. outchain    dc.l    0
  5611. firstline   dc.l    0
  5612. oldfirstline dc.l   0
  5613. numlines    dc.l    0
  5614. oldnumlines dc.l    0
  5615. gothline    dc.l    0
  5616. lastprinted dc.l    0
  5617. oldlastprinted dc.l 0
  5618. oldpageend  dc.l    0
  5619. maxlines    dc.l    500
  5620. realstack   dc.l    0
  5621.  
  5622.  
  5623. wnnormflgs  dc.l    $646
  5624.         dc.l    $1104f
  5625.  
  5626. wnscrflags  dc.l    $600
  5627.         dc.l    $31948
  5628.  
  5629. history     dc.l    *+4
  5630.         dc.l    0
  5631.         dc.l    history
  5632. curhist     dc.l    0
  5633.  
  5634.  
  5635. secs        dc.l    0
  5636. mics        dc.l    0
  5637. time10        dc.l    0
  5638.  
  5639. tattr        dc.l    fontname
  5640.         dc.w    8
  5641.         dc.w    0
  5642.  
  5643. stplist     dc.l    lh_tail
  5644. lh_tail     dc.l    0
  5645.         dc.l    stplist
  5646.         dc.b    1
  5647.         dc.b    0
  5648.  
  5649. InInterrupt dc.l    0        ;ln_Succ
  5650.         dc.l    0        ;ln_Pred
  5651.         dc.b    2        ;ln_Type
  5652.         dc.b    60        ;ln_Pri
  5653.         dc.l    xopsleep    ;ln_Name
  5654.         dc.l    0        ;is_Data
  5655.         dc.l    Keyhandler    ;is_Code()
  5656.  
  5657. IOCounter   dc.l    0        ;ln_Succ
  5658.         dc.l    0        ;ln_Pred
  5659.         dc.b    2        ;ln_Type
  5660.         dc.b    -1        ;ln_Pri
  5661.         dc.l    IOcntname    ;ln_Name
  5662.         dc.l    0        ;is_Data
  5663.         dc.l    countio    ;is_Code()
  5664.  
  5665. newwindow   dc.w    0,0
  5666.         dc.w    500,100
  5667.         dc.b    0,1
  5668. nwflgs        dc.l    $646
  5669.         dc.l    $1104f
  5670. wn_firstgad dc.l    0
  5671.         dc.l    0
  5672.         dc.l    windowname
  5673. nwscreen    dc.l    0
  5674.         dc.l    0
  5675.         dc.w    110,50
  5676.         dc.w    808,-1
  5677. nwtype        dc.w    1
  5678.  
  5679. newscreen   dc.w    0,0
  5680. nssize        dc.w    0,0
  5681.         dc.w    1
  5682.         dc.b    0
  5683.         dc.b    1
  5684. nsviewmode  dc.w    0
  5685.         dc.w    $1f
  5686.         dc.l    0
  5687.         dc.l    windowname
  5688.         dc.l    0,0
  5689.  
  5690. excpterror  dc.l    0
  5691. excpttask   dc.l    0
  5692. excptaddr   dc.l    0
  5693. excptpc     dc.l    0
  5694.  
  5695. window_l    dc.w    0
  5696. window_t    dc.w    0
  5697. window_w    dc.w    550
  5698. window_h    dc.w    200
  5699.  
  5700. colms        dc.w    0
  5701. timersig    dc.w    0
  5702. intuisig    dc.w    0
  5703. ibufferlen  dc.w    0
  5704. cposy        dc.w    0
  5705. curpos        dc.w    0
  5706. bottomin    dc.w    1
  5707. ipos        dc.w    0
  5708. hnum        dc.w    0
  5709. minnumchars dc.w    2
  5710. maxhlines   dc.w    10
  5711. qualifier   dc.w    0
  5712. rows        dc.w    0
  5713. maxllength  dc.w    0
  5714. loffset     dc.w    0
  5715. repeat        dc.w    0
  5716. repeatlen   dc.w    0
  5717. edline        dc.w    999
  5718. cmdptr        dc.w    0
  5719. getanswer   dc.w    0
  5720. currenty    dc.w    0
  5721.  
  5722. binarea     dc.b    '          ',0
  5723.         EVEN
  5724. minus        dc.b    '  '
  5725. decimal     dc.b    '    ',0
  5726. entries     dc.b    0
  5727. timeout     dc.b    5
  5728. procnum     dc.b    0
  5729. timerstate  dc.b    0
  5730. running     dc.b    0
  5731. newpri        dc.b    0
  5732. tasktyp     dc.b    0
  5733. background  dc.b    0
  5734. bool        dc.b    0
  5735. printed     dc.b    0
  5736. cbreak        dc.b    0
  5737. usageflag   dc.b    0
  5738. mnflag        dc.b    1
  5739. tports        dc.b    1
  5740. headon        dc.b    1
  5741. hideon        dc.b    1
  5742. sorton        dc.b    1
  5743. wanttraps   dc.b    0
  5744. addlines    dc.b    0
  5745. eof        dc.b    0
  5746. fromfile    dc.b    0
  5747. iconifyon   dc.b    1
  5748. gotguru     dc.b    0
  5749. ownscreen   dc.b    0
  5750. insmode     dc.b    0
  5751. params        dc.b    'tfdlrempisc'
  5752. parmnum     equ     *-params
  5753.         dc.b    0
  5754. t2header    dc.b    '   ID     STATE   SIGALLOC SIGWAIT  SIGRECVD    PC    TASKNAME',0
  5755. theader     dc.b    '   ID     TYPE      STATE    PRI  CPUSE NUM TASKNAME',0
  5756. lheader     dc.b    '  NODE   CNT VER REV  FLAGS    ',0
  5757. libnam        dc.b    'LIBRARY NAME',0
  5758. devnam        dc.b    'DEVICE NAME',0
  5759. resnam        dc.b    'RESOURCE NAME',0
  5760. mheader     dc.b    ' LOWER   UPPER      FREE ATTR  PRI HUNK NAME',0
  5761. cr        dc.b    10,0
  5762. iheader     dc.b    '  NODE     DATA     CODE    PRI T S   TYPE     INTERRUPT NAME',0
  5763. inheader    dc.b    '  NODE     DATA     CODE    PRI NAME',0
  5764. rheader     dc.b    '  ADDR    PRI  FLAGS     VER   TYPE    RESIDENT NAME',0
  5765. pheader     dc.b    '  NODE   PORTNAME        FLAGS SIGBT NUM SIGTASK',0
  5766. hunkheader  dc.b    ' NUM  BCPL    DATA     LENGTH',0
  5767. ddheader    dc.b    'DEVICE    HDS SECTORS  TRACKS BUFFERS STATE    HANDLER',0
  5768. cdheader    dc.b    'PROCESSNAME    CURRENT DIRECTORY',0
  5769. ofheader    dc.b    '  LOCK   ACCESS  SIZE   PATH/FILENAME',0
  5770. scrheader   dc.b    'NUM   ADDR   TITLE',0
  5771. fohead        dc.b    '  NODE   CNT  Y   X  TYPE  LO  HI NAME',0
  5772. kickhead    dc.b    'START    END      LENGTH',0
  5773. snoophead   dc.b    'ACTION REQUIREMENTS        LENGTH   FROM    TO       CALLER',0
  5774. stackhead   dc.b    'SPLower     SIZE    USED TASKNAME',0
  5775. clicomhead  dc.b    '   ID    STATE    TYPE  MODE NUM PROCESSNAME      COMMAND',0
  5776. tiohead     dc.b    'IORQUEST  UNIT   SECS  REQUESTING TASK',0
  5777. dchead        dc.b    '  NODE     DATA     CODE   UNIT TASK',0
  5778. alhead        dc.b    'ALIAS NAME        COMMAND',0
  5779. tdd        dc.b    'trackdisk.device',0
  5780. tddrives    dc.b    'DF : ',0
  5781. timerunits  dc.b    'MicroHz ',0
  5782.         dc.b    'VBlank  ',0
  5783. access        dc.b    ' Read  ',0
  5784.         dc.b    ' Write ',0
  5785. romfnt        dc.b    'Rom  ',0
  5786. diskfnt     dc.b    'Disk ',0
  5787. wbname        dc.b    'Workbench',0
  5788. status        dc.b    'Added    ',0
  5789.         dc.b    'Running  ',0
  5790.         dc.b    'Ready    ',0
  5791.         dc.b    'Waiting  ',0
  5792.         dc.b    'Exeption ',0
  5793.         dc.b    'Removed  ',0
  5794.         dc.b    'Frozen   ',0
  5795.         dc.b    'Frozen   ',0
  5796. type        dc.b    'Unknown   ',0
  5797. tasktype    dc.b    'Task      ',0
  5798.         dc.b    'Interrupt ',0
  5799.         dc.b    'Device    ',0
  5800.         dc.b    'Msgport   ',0
  5801.         dc.b    'Message   ',0
  5802.         dc.b    'Freemsg   ',0
  5803.         dc.b    'Replymsg  ',0
  5804.         dc.b    'Resource  ',0
  5805.         dc.b    'Library   ',0
  5806.         dc.b    'Memory    ',0
  5807. softinttype dc.b    'Softint   ',0
  5808.         dc.b    'Font      ',0
  5809. proctype    dc.b    'Process   ',0
  5810.         dc.b    'Semaphore ',0
  5811. mp_flags    dc.b    'Signal  ',0
  5812.         dc.b    'Softint ',0
  5813.         dc.b    'Ignore  ',0
  5814. windowname  dc.b    'Xoper V2.0  ) 1989 Werner G',$fc,'nther',0
  5815. newname     dc.b    'Xoper',0
  5816. memportname dc.b    'MemSnoop',0
  5817. xopcon        dc.b    'XopPackets',0
  5818. xopsleep    dc.b    'Xop-A-A-x',0
  5819. IOcntname   dc.b    'Xop-I/O-counter',0
  5820.  
  5821. cmdnum        set      0
  5822. commds        ADDCMD  'time'
  5823.         ADDCMD  'taskpri'
  5824.         ADDCMD  'info'
  5825.         ADDCMD  'pri'
  5826.         ADDCMD  'flush'
  5827.         ADDCMD  'freeze'
  5828.         ADDCMD  'warm'
  5829.         ADDCMD  'signal'
  5830.         ADDCMD  'break'
  5831.         ADDCMD  'alert'
  5832.         ADDCMD  'lastalert'
  5833.         ADDCMD  'hold'
  5834.         ADDCMD  'exit'
  5835.         ADDCMD  'clear'
  5836.         ADDCMD  'cancel'
  5837.         ADDCMD  'taskports'
  5838.         ADDCMD  'hunks'
  5839.         ADDCMD  'devices'
  5840.         ADDCMD  'openlib'
  5841.         ADDCMD  'closelib'
  5842.         ADDCMD  'currentdir'
  5843.         ADDCMD  'cd'
  5844.         ADDCMD  'mypri'
  5845.         ADDCMD  'files'
  5846.         ADDCMD  'locks'
  5847.         ADDCMD  'unlock'
  5848.         ADDCMD  'screens'
  5849.         ADDCMD  'windows'
  5850.         ADDCMD  'closescreen'
  5851.         ADDCMD  'closewindow'
  5852.         ADDCMD  'fonts'
  5853.         ADDCMD  'windowfonts'
  5854.         ADDCMD  'lockdrive'
  5855.         ADDCMD  'freedrive'
  5856.         ADDCMD  'capture'
  5857.         ADDCMD  'clrcold'
  5858.         ADDCMD  'clrcool'
  5859.         ADDCMD  'clrwarm'
  5860.         ADDCMD  'snoop'
  5861.         ADDCMD  'usage'
  5862.         ADDCMD  'inputhandler'
  5863.         ADDCMD  'header'
  5864.         ADDCMD  'sort'
  5865.         ADDCMD  'hide'
  5866.         ADDCMD  'hidden'
  5867.         ADDCMD  'window'
  5868.         ADDCMD  'kill'
  5869.         ADDCMD  'iconifyoff'
  5870.         ADDCMD  'historylines'
  5871.         ADDCMD  'minimumchars'
  5872.         ADDCMD  'showhistory'
  5873.         ADDCMD  'repeat'
  5874.         ADDCMD  'remresident'
  5875.         ADDCMD  'saveoutput'
  5876.         ADDCMD  'killhistory'
  5877.         ADDCMD  'backdropicon'
  5878.         ADDCMD  'setfont'
  5879.         ADDCMD  'trapguru'
  5880.         ADDCMD  'outputlines'
  5881.         ADDCMD  'usescreen'
  5882.         ADDCMD  'usewindow'
  5883.         ADDCMD  'timerio'
  5884.         ADDCMD  'diskchange'
  5885.         ADDCMD  'alias'
  5886.         ADDCMD  'remnode'
  5887. hexarea     dc.b    '         ',0
  5888. hextab        dc.b    '0123456789abcdef'
  5889. infoh2        dc.b    'Dispat/Sec:',0
  5890. infoh1        dc.b    'CPU:',0
  5891. infoh3        dc.b    'CPU activity: ',0
  5892. infoh6        dc.b    'Total:',0
  5893. infoh4        dc.b    '% ',0
  5894. infoh7        dc.b    'I/O Ints/Sec: ',0
  5895. cpu0        dc.b    '68000',0
  5896. cpu1        dc.b    '68010',0
  5897. cpu2        dc.b    '68020',0
  5898. cpu3        dc.b    '/68881',0
  5899. devload     dc.b    'loaded   ',0
  5900. devnload    dc.b    'unloaded ',0
  5901. inten        dc.b    'E ',0
  5902. intdis        dc.b    'D ',0
  5903. intserv     dc.b    'S ',0
  5904. inthand     dc.b    'H ',0
  5905. notfile     dc.b    '--- ------- ------- ------- ',0
  5906. longnix     dc.b    '-----'
  5907. nix        dc.b    '--- ',0
  5908. noinfo        dc.b    'No Info on'
  5909. oneblank    dc.b    ' ',0
  5910. equal        dc.b    '=  ',0
  5911. namerr        dc.b    'Unable to find ',0
  5912. fonterr     dc.b    "Can't open ",0
  5913. adrerr        dc.b    'Address Error!',0
  5914. aliaserr    dc.b    'Single character alias names using "',0
  5915. aliaserr2   dc.b    '"',10,'are not allowed.',0
  5916. openerr     dc.b    'Could not open file ',0
  5917. noderr        dc.b    "Can't find this Node. Continue anyway ? (Y/N)",0
  5918. listerr     dc.b    'Unable to find ListHeader. Sort aborted.',0
  5919. wiwerr        dc.b    'Script file only',0
  5920. gurutxt     dc.b    'Guru Meditation #',0
  5921. clrtxt        dc.b    'Memory Hunks cleared.',0
  5922. canerr0     dc.b    'Process is not a CLI-task',10
  5923.         dc.b    'Has it been started from Workbench ? (Y/N)',10,0
  5924. canerr1     dc.b    'Process was created by CreateProc()',10
  5925.         dc.b    'Shall I UnLoad() ? (Y/N)',10,0
  5926. unloaderr   dc.b    "Arrrgh.. can't find segments, aborting",0
  5927. noprocs     dc.b    'Not a Process.',0
  5928. notload     dc.b    'No program loaded.',0
  5929. cliprocs    dc.b    'Cli-Process',0
  5930. procloaded  dc.b    'Loaded as a command: ',0
  5931. segloaded   dc.b    'Created by CreateProc()',0
  5932. coldtxt     dc.b    'Cold Capture: ',0
  5933. cooltxt     dc.b    'Cool Capture: ',0
  5934. warmtxt     dc.b    'Warm Capture: ',0
  5935. kicktxt     dc.b    'KickMem     : ',0
  5936. unset        dc.b    'unset',0
  5937. intnames    dc.b    'Serial Out ',0
  5938.         dc.b    'Disk Block ',0
  5939.         dc.b    'SoftInt    ',0
  5940.         dc.b    'Ports      ',0
  5941.         dc.b    'Coper      ',0
  5942.         dc.b    'Vert.Blank ',0
  5943.         dc.b    'Blitter    ',0
  5944.         dc.b    'Audio Ch.0 ',0
  5945.         dc.b    'Audio Ch.1 ',0
  5946.         dc.b    'Audio Ch.2 ',0
  5947.         dc.b    'Audio Ch.3 ',0
  5948.         dc.b    'Serial In  ',0
  5949.         dc.b    'Disk Sync  ',0
  5950.         dc.b    'External   ',0
  5951.         dc.b    'SoftInt    ',0
  5952.         dc.b    'NMI        ',0
  5953. inttyp        dc.b    0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1
  5954. fontname    dc.b    'topaz.font',0
  5955. devicenam   dc.b    'input.device',0
  5956. timernam    dc.b    'timer.device',0
  5957. memlarg     dc.b    'LARGEST ',0
  5958. memclr        dc.b    'CLEAR ',0
  5959. memfast     dc.b    'FAST ',0
  5960. memchip     dc.b    'CHIP ',0
  5961. mempubl     dc.b    'PUBLIC ',0
  5962. failed        dc.b    'Failed !',0
  5963. allok        dc.b    'ALLOC: ',0
  5964. free        dc.b    'FREE: ',0
  5965. backg        dc.b    'Bckg ',0
  5966. foreg        dc.b    'Frgr ',0
  5967. script        dc.b    'Batch ',0
  5968. interact    dc.b    'Intct ',0
  5969. startupname dc.b    'S:Xoper.Startup',0
  5970. nameerr     dc.b    'Name or address is missing.',10
  5971. synerr        dc.b    'Syntax Error, type "?" for help',10,0
  5972. wberr        dc.b    "Can't examine Workbench locks",0
  5973. dnotf        dc.b    'Directory not found',0
  5974. notdir        dc.b    'Not a directory',0
  5975. nomount     dc.b    ' not mounted.',0
  5976. dishelp     dc.b    10,'Names are case sensitive and followed by a ":"',0
  5977. unlerr        dc.b    'Lock not found',0
  5978. unl1        dc.b    'Lock is on ',0
  5979. unltxt        dc.b    'Old lock was: ',0
  5980. unltxt2     dc.b    'Unlock ? (Y/N)',10,0
  5981. scnofound   dc.b    'Screen not found.',0
  5982. winnofound  dc.b    'Window not found.',0
  5983. stperr        dc.b    'Task must be "READY" or "WAITING"',10,0
  5984. waerr        dc.b    'Task must be "FROZEN"',10,0
  5985. whatsthis   dc.b    '???.?',0
  5986. toomuch     dc.b    '??? ',0
  5987. timenotset  dc.b    'Refresh disabled.',0
  5988. whattime    dc.b    'Refresh time in secs:',0
  5989. stoped        dc.b    '<Break>',0
  5990. onscr        dc.b    'On Screen: ',0
  5991. whatnow     dc.b    'Kill, ignore (K/I)?',0
  5992. noguru        dc.b    'None found.',0
  5993. softfail    dc.b    'Software failure!',10,'Task: ',0
  5994. addrserr    dc.b    'Bad alligned address was: ',0
  5995. procount    dc.b    'PC: ',0
  5996. diskfont    dc.b    'diskfont.library',0
  5997. usetxt        dc.b    'USAGE: Xoper [T] [F] [L] [D] [R] [E] [M] [P] [I] [S] [C]',10
  5998.         dc.b    'OR     Xoper -b',10
  5999.         dc.b    'DISPLAY:',10
  6000.         dc.b    '[T]asks    [F]=taskflags [L]ibraries [D]evices    [R]esources',10
  6001.         dc.b    'r[E]sident [M]emory      [P]orts     [I]nterrupts [S]tack',10
  6002.         dc.b    '[C]litasks [Q]uit',10,10
  6003.         dc.b    'OTHER SYSTEM LISTS:',10
  6004.         dc.b    'Windows    Screens      Fonts       WindowFonts  CurrentDir',10
  6005.         dc.b    'Files      Locks        Devices     InputHandler Capture',10
  6006.         dc.b    'TimerIO    DiskChange',10,10
  6007.         dc.b    'COMMANDS:',10
  6008.         dc.b    'Time         <secs>',10
  6009.         dc.b    'Taskpri      <priority>  [processnum] <taskname>',10
  6010.         dc.b    'Mypri        <priority>',10
  6011.         dc.b    'Signal       <mask(hex)> [processnum] <taskname>',10
  6012.         dc.b    'Break        [processnum] <taskname>',10
  6013.         dc.b    'Freeze|Warm  [processnum] <taskname>',10
  6014.         dc.b    'Kill         [processnum] <taskname>',10
  6015.         dc.b    'Snoop        [processnum] <taskname>',10
  6016.         dc.b    'Hide         <taskname>',10
  6017.         dc.b    'Pri          <priority> <nodename>',10
  6018.         dc.b    'Info         <name>',10
  6019.         dc.b    'RemResident  <resident module name>',10
  6020.         dc.b    'Clear        <longword(hex)>',10
  6021.         dc.b    'Hunks        [processnum] <procname>',10
  6022.         dc.b    'CD           <directory> [processnum] <procname>',10
  6023.         dc.b    'UnLock       <lock>',10
  6024.         dc.b    'OpenLib    | Closelib <libraryname>',10
  6025.         dc.b    'CloseWindow| Closescreen <title>',10
  6026.         dc.b    'SetFont      [size] <fontname> <windowtitle>',10
  6027.         dc.b    'LockDrive  | Freedrive   <drivename:>',10
  6028.         dc.b    'Window       <leftedge topedge width height> (scriptfile only) ',10
  6029.         dc.b    'OutputLines  <maximum # of lines>',10
  6030.         dc.b    'HistoryLines <maximum # of lines>',10
  6031.         dc.b    'MinimumChars <minimum # of characters>',10
  6032.         dc.b    'SaveOutput   <filename>',10
  6033.         dc.b    'Repeat       <Command line>',10
  6034.         dc.b    'Alias        [<aliasname> <commandname>]',10,10
  6035.         dc.b    'COMMADS WITHOUT PARAMETERS:',10
  6036.         dc.b    'Flush      LastAlert    ClrCool     ClrCold      ClrWarm',10
  6037.         dc.b    'TrapGuru',10,10
  6038.         dc.b    'OPTIONS:',10
  6039.         dc.b    'Sort       TaskPorts    Hidden      Usage        Header',10
  6040.         dc.b    'IconifyOff BackDropIcon ShowHistory KillHistory  UseScreen',10
  6041.         dc.b    'UseWindow',10
  6042.         dc.b    'Hold       Exit'
  6043. null        dc.b    0
  6044.  
  6045.     IFD DEBUG
  6046. dosname     dc.b    'dos.library',0
  6047. intuiname   dc.b    'intuition.library',0
  6048. gfxname     dc.b    'graphics.library',0
  6049. conname     dc.b    'console.device',0
  6050.         EVEN
  6051.     ENDC
  6052.  
  6053.         BSS     blabla
  6054. buffer        ds.b    2200
  6055. out        ds.b    100
  6056. dummy        ds.b    80
  6057. in        ds.b    80
  6058. cputime     ds.b    1000
  6059. ievent        ds.b    32
  6060. outevent    ds.b    20
  6061. inputbuffer ds.b    88
  6062. repeatbuffer ds.b   81
  6063.  
  6064. mypacket    BSS     standardpacket
  6065.  
  6066. LN_SUCC     ds.l    1
  6067. LN_PRED     ds.l    1
  6068. LN_TYPE     ds.b    1
  6069. LN_PRI        ds.b    1
  6070. LN_NAME     ds.l    1
  6071. MP_FLAGS    ds.b    1
  6072. MP_SIGBIT   ds.b    1
  6073. MP_SIGTASK  ds.l    1
  6074. MN_SIZE     ds.w    1
  6075. LH_HEAD     ds.l    1
  6076. LH_TAIL     ds.l    1
  6077. LH_TAILPRED ds.l    1
  6078. LH_TYPE     ds.b    1
  6079. LH_pad        ds.b    1
  6080. dp_Link     ds.l    1
  6081. dp_Port     ds.l    1
  6082. dp_Type     ds.l    1
  6083. dp_Res1     ds.l    1
  6084. dp_Res2     ds.l    1
  6085. dp_Arg1     ds.l    1
  6086. dp_Arg2     ds.l    1
  6087. dp_Arg3     ds.l    1
  6088. dp_Arg4     ds.l    1
  6089. dp_Arg5     ds.l    1
  6090. dp_Arg6     ds.l    1
  6091. dp_Arg7     ds.l    1
  6092.  
  6093. timerio     ds.b    40
  6094.  
  6095.         CODE ICONIFY,CHIP
  6096.  
  6097. iconify     lea     icnwindow,a0
  6098.         CALL    OpenWindow,intuibase
  6099.         move.l  d0,iconwindow
  6100.  
  6101. waitforcall move.l  iconwindow,a0
  6102.         move.l  $56(a0),a0              ;wn->UserPort
  6103.  
  6104.         moveq   #0,d1
  6105.         move.b  15(a0),d1               ;UserPort->SigBit
  6106.         bset    d1,d0
  6107.         move.l  d0,d6
  6108.         or.l    mysignal,d0
  6109.         or.l    trapsignal,d0
  6110.         CALL    Wait,_SysBase
  6111.         and.l   d0,d6
  6112.         bne.s   fromwindow
  6113.         move.l  mysignal,d1
  6114.         and.l   d0,d1
  6115.         bne.s   icondone
  6116.         and.l   trapsignal,d0
  6117.         beq.s   waitforcall
  6118.         move.b  #1,gotguru
  6119.         bra.s   icondone
  6120.  
  6121. fromwindow  move.l  iconwindow,a0
  6122.         move.l  $56(a0),a0              ;wn->UserPort
  6123.         CALL    GetMsg,_SysBase
  6124.         tst.l   d0
  6125.         beq.s   waitforcall
  6126.         move.l  d0,a1
  6127.         CALL    ReplyMsg,_SysBase
  6128.  
  6129.         lea     nsecs(PC),a0
  6130.         lea     nmics(PC),a1
  6131.         CALL    CurrentTime,intuibase
  6132.         movem.l osecs,d0-d3
  6133.         CALL    DoubleClick,intuibase
  6134.         tst.l   d0
  6135.         bne.s   icondone
  6136.         move.l  nsecs(PC),osecs
  6137.         move.l  nmics(PC),omics
  6138.         bra     waitforcall
  6139.  
  6140. icondone    move.l  iconwindow,a0
  6141.         move.l  4(a0),icnwindow         ;LeftEdge+TopEdge
  6142.         CALL    CloseWindow,intuibase
  6143.         rts
  6144.  
  6145. osecs        dc.l    0
  6146. omics        dc.l    0
  6147. nsecs        dc.l    0
  6148. nmics        dc.l    0
  6149.  
  6150. iconwindow  dc.l    0
  6151. icnwindow   dc.w    40,170,72,28
  6152.         dc.b    0,1
  6153.         dc.l    $20,$800
  6154.         dc.l    gadget,0,0,0,0
  6155.         dc.w    72,28,72,28
  6156.         dc.w    1
  6157.  
  6158. gadget        dc.l    0
  6159.         dc.w    0,0,72,28,4,2,$20
  6160.         dc.l    image
  6161.         dc.l    0,0,0,0
  6162.         dc.w    0
  6163.         dc.l    0
  6164.  
  6165. image        dc.w    0,0,72,28,2
  6166.         dc.l    imagedata
  6167.         dc.b    3,0
  6168.         dc.l    0
  6169.  
  6170. imagedata   dc.w    $000F,$FFFF,$FFFF,$FFF8,$0000,$001F,$FFFF,$FFFF
  6171.         dc.w    $FFFC,$0000,$001F,$0000,$0000,$007C,$0000,$001F
  6172.         dc.w    $7FFF,$FFFF,$FF7C,$0000,$001F,$4A46,$0244,$557C
  6173.         dc.w    $0000,$001F,$5108,$D411,$817C,$0000,$001F,$7FFF
  6174.         dc.w    $FFFF,$FF7C,$0000,$001F,$0000,$0000,$007C,$0000
  6175.         dc.w    $001F,$30C0,$0000,$007C,$0000,$001F,$1980,$0000
  6176.         dc.w    $007C,$0000,$001F,$0F0F,$1F0F,$1F7C,$0000,$001F
  6177.         dc.w    $0619,$9999,$997C,$0000,$001F,$0F19,$999F,$987C
  6178.         dc.w    $0000,$001F,$1999,$9F18,$187C,$0000,$001F,$30CF
  6179.         dc.w    $180F,$187C,$0000,$001F,$0000,$1800,$007C,$0000
  6180.         dc.w    $001F,$0000,$0000,$007C,$0000,$001F,$FFFF,$FFFF
  6181.         dc.w    $FFFC,$0000,$000F,$FFFF,$FFFF,$FF18,$0000,$0000
  6182.         dc.w    $0000,$0000,$0000,$0000,$3FFF,$FFFF,$FFFF,$FFFF
  6183.         dc.w    $FC00,$FDFF,$FFFF,$FFFF,$FFFF,$FF00,$EBFF,$FFFF
  6184.         dc.w    $FFFF,$FFFF,$FF00,$F7FF,$FFFF,$FFFF,$F800,$0700
  6185.         dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FF00,$FFFF,$FFFF,$FFFF
  6186.         dc.w    $FFFF,$FF00,$FFFF,$FFFF,$FFFF,$FFFF,$FF00,$3FFF
  6187.         dc.w    $FFFF,$FFFF,$FFFF,$FC00,$0000,$0000,$0000,$0000
  6188.         dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$FFFF
  6189.         dc.w    $FFFF,$FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000
  6190.         dc.w    $0000,$FFFF,$FFFF,$FF80,$0000,$0000,$FFFF,$FFFF
  6191.         dc.w    $FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000,$0000
  6192.         dc.w    $FFFF,$FFFF,$FF80,$0000,$0000,$8000,$0000,$0080
  6193.         dc.w    $0000,$0000,$8000,$0000,$0080,$0000,$0000,$8000
  6194.         dc.w    $0000,$0080,$0000,$0000,$8000,$0000,$0080,$0000
  6195.         dc.w    $0000,$8000,$0000,$0080,$0000,$0000,$8000,$0000
  6196.         dc.w    $0080,$0000,$0000,$8000,$0000,$0080,$0000,$0000
  6197.         dc.w    $8000,$0000,$0080,$0000,$0000,$FFFF,$FFFF,$FF80
  6198.         dc.w    $0000,$0000,$0000,$0000,$00E0,$0000,$0000,$0000
  6199.         dc.w    $0000,$00E0,$0000,$0000,$1FFF,$FFFF,$F800,$0000
  6200.         dc.w    $0000,$0080,$0040,$0000,$0000,$0200,$0080,$0040
  6201.         dc.w    $0000,$0000,$1400,$0080,$0040,$003F,$0000,$0800
  6202.         dc.w    $0080,$0040,$07FF,$F800,$0000,$0080,$0040,$003F
  6203.         dc.w    $0000,$0000,$0080,$0040,$0000,$3800,$FFFF,$FFFF
  6204.         dc.w    $FFFF,$FFFF,$FE00,$0000,$0080,$0040,$0000,$0000
  6205.  
  6206. iconifgad   dc.l    0
  6207.         dc.w    -83,0
  6208.         dc.w    31,10
  6209.         dc.w    $14
  6210.         dc.w    $41
  6211.         dc.w    1
  6212.         dc.l    iconifimg
  6213.         dc.l    0
  6214.         dc.l    0
  6215.         dc.l    0
  6216.         dc.l    0
  6217.         dc.w    0
  6218.         dc.l    0
  6219.  
  6220. iconifimg   dc.w    0,0
  6221.         dc.w    31,10
  6222.         dc.w    2
  6223.         dc.l    iconifdata
  6224.         dc.b    $0003,$0000
  6225.         dc.l    0
  6226.  
  6227. iconifdata  dc.w    $7FFF,$FFFC,$601F,$FFFC,$6000,$000C,$607F,$FFCC
  6228.         dc.w    $6060,$00CC,$6067,$FCCC,$7E60,$00CC,$7E7F,$FFCC
  6229.         dc.w    $7E00,$000C,$7FFF,$FFFC,$0000,$0000,$1FE0,$0000
  6230.         dc.w    $1FFF,$FFF0,$1F80,$0030,$1F9F,$FF30,$1F98,$0330
  6231.         dc.w    $019F,$FF30,$0180,$0030,$01FF,$FFF0,$0000,$0000
  6232.  
  6233.  
  6234.         END
  6235.  
  6236.