Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (02/01/90)
Submitted-by: Werner Guenther <G35%DHDURZ1.BITNET@CUNYVM.CUNY.EDU> Posting-number: Volume 90, Issue 038 Archive-name: kernel/xoper-2.2/part03 #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 3 (of 4)." # Contents: Xoper.a.ab # Wrapped by tadguy@xanth on Wed Jan 31 22:31:35 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Xoper.a.ab' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Xoper.a.ab'\" else echo shar: Extracting \"'Xoper.a.ab'\" \(53365 characters\) sed "s/^X//" >'Xoper.a.ab' <<'END_OF_FILE' Xsignal bsr readhex X tst.b d7 X beq syntax Xsetthem move.l d0,savedat X bsr nodenam X moveq.l #2,d7 X lea TReNode(PC),a4 X bsr findnam X tst.b d7 X beq.s pi1 X move.l d0,a1 X move.l savedat,d0 X and.l 18(a1),d0 X CALL Signal,_SysBase(PC) X rts X X;set up a list of tasknames which should't be displayed X Xhide cmp.b #10,0(a0) X bne.s hid5 X bra syntax Xhid5 lea hidestart(PC),a2 X move.l a2,d3 Xhid0 tst.l 0(a2) X beq.s hid1 X move.l 0(a2),a2 X lea 4(a2),a1 X bsr strcmp X tst d0 X beq.s hid2 X move.l a2,d3 X bra.s hid0 Xhid1 move.l a0,a4 X bsr strlen2 X addq #5,d0 X move.l #65536,d1 X CALL AllocMem,_SysBase(PC) X tst.l d0 X beq.s hid4 X move.l d0,a1 X move.l d0,0(a2) X addq #4,a1 Xhid3 cmp.b #10,0(a4) X beq.s hid4 X move.b (a4)+,(a1)+ X bra.s hid3 Xhid4 rts Xhid2 move.l d3,a3 X move.l 0(a2),0(a3) Xfreehidden lea 4(a2),a0 X bsr strlen X addq #5,d0 X move.l a2,a1 X CALL FreeMem,_SysBase(PC) X rts X Xfreehidmem move.l hidestart(PC),a4 Xfhm0 move.l a4,d0 X beq.s fhm1 X move.l a4,a2 X move.l 0(a2),a4 X bsr freehidden X bra fhm0 Xfhm1 rts X X;set up an ALIAS list Xalias cmp.b #10,0(a0) X beq showalias X bsr strbuf X move.l a0,a5 X lea buffer,a0 X bsr strlen X tst.l d0 X beq syntax X X moveq #1,d1 X cmp d1,d0 X bne.s 5$ X lea params(PC),a0 X moveq #parmnum-1,d1 X move.b buffer,d2 X6$ cmp.b (a0)+,d2 X dbeq d1,6$ X tst.w d1 X bmi.s 5$ X move.l #aliaserr,d0 X bsr putstr X move.l #params,d0 X bsr putstr X move.l #aliaserr2,d0 X bra putnam X X5$ move.l d0,d5 X move.l a5,a0 X adda.l d0,a0 X bsr kllblnks X move.l a5,-(a7) X bsr findcmd X move.l (a7)+,a5 X tst.l d2 X bmi syntax X move.l a5,a0 X bsr strbuf X X addq #6,d5 X move.l d5,d0 X move.l #65536,d1 X CALL AllocMem,_SysBase(PC) X tst.l d0 X beq.s 1$ X X move.l aliaslist(PC),d1 X bne.s 2$ X move.l d0,aliaslist X bra.s 3$ X2$ move.l d1,a0 X move.l 0(a0),d1 X bne.s 2$ X move.l d0,0(a0) X X3$ move.l d0,a0 X move.b d2,4(a0) X X lea 5(a0),a0 X lea buffer,a1 X4$ move.b (a1)+,(a0)+ X bne.s 4$ X1$ rts X Xshowalias lea alhead(PC),a0 X bsr puthead X move.l aliaslist(PC),d0 X beq.s 1$ X2$ move.l d0,a5 X addq #5,d0 X bsr putstr X move.w #15,d1 X bsr tab X move.l #equal,d0 X bsr putstr X move.b 4(a5),d0 X ext.w d0 X bsr getcmdptr X bsr putnam X move.l 0(a5),d0 X bne.s 2$ X1$ rts X Xfreealias move.l aliaslist(PC),a4 X1$ move.l a4,d0 X beq.s 2$ X move.l a4,a2 X move.l 0(a2),a4 X lea 5(a2),a0 X bsr strlen X addq #6,d0 X move.l a2,a1 X CALL FreeMem,_SysBase(PC) X bra 1$ X2$ rts X Xgetcmdptr move.l a0,-(a7) X lea commds(PC),a0 X2$ tst d0 X beq.s 1$ X3$ tst.b (a0)+ X bne.s 3$ X subq #1,d0 X bra.s 2$ X1$ move.l a0,d0 X move.l (a7)+,a0 X rts X X X;'flushlibs' Xflush move.l #$ffffff,d0 X moveq #0,d1 X CALL AllocMem,_SysBase(PC) Xflsh1 rts X X;display library->lib_IDString Xinfo bsr nodenam2 X moveq.l #2,d7 X lea DevNode(PC),a4 X bsr findnam X tst.b d7 X beq.s flsh1 X move.l d0,a0 X move.l 24(a0),d0 X beq.s if1 X move.l d0,d1 X andi.l #1,d1 X bne.s if1 X bra putnam Xif1 move.l #noinfo,d0 X bsr putstr X move.l a5,d0 X bra putnam X Xcapture move.l _SysBase(PC),a1 X lea 42(a1),a0 X moveq #2,d6 X lea coldtxt,a4 Xcap0 move.l a4,d0 X bsr putstr X move.l 0(a0),d0 X bne.s cap1 X move.l #unset,d0 X bsr putstr X bra cap2 Xcap1 bsr hexa Xcap2 bsr newline X lea 15(a4),a4 X addq #4,a0 X dbf d6,cap0 X X move.l #kicktxt,d0 X bsr putstr X move.l 546(a1),a0 X cmpa.l #0,a0 X bne.s kickm3 X move.l #unset,d0 X bra putnam Xkickm3 move.l a0,-(a7) X bsr newline X lea kickhead(PC),a0 X bsr puthead X move.l (a7)+,a0 Xkickm0 move.l a0,d0 X beq kickm4 X bpl.s kickm1 X bclr #31,d0 X move.l d0,a0 X bra.s kickm0 Xkickm1 move.w 14(a0),d6 X subq #1,d6 X lea 16(a0),a2 Xkickm2 move.l 0(a2),d0 X bsr hexa X move.l 0(a2),d0 X move.l 4(a2),d4 X add.l d4,d0 X bsr hexa X move.l d4,d0 X clr.b d3 X bsr longdec X bsr newline X addq #8,a2 X dbf d6,kickm2 X move.l 0(a0),a0 X bra kickm0 Xkickm4 rts X Xclrcold move.l _SysBase,a0 X clr.l 42(a0) X bra.s chksum Xclrcool move.l _SysBase,a0 X clr.l 46(a0) X bra.s chksum Xclrwarm move.l _SysBase,a0 X clr.l 50(a0) X Xchksum lea 34(a0),a1 X move #22,d0 Xaddchk add (a1)+,d1 X dbf d0,addchk X not d1 X move.w d1,82(a0) X rts X X;Save the command line to be repeated. If this line doesn't produce X;any output, don't repeat it at all Xrepeatcmd tst.w repeat X bne.s 2$ X move.w repeatlen(PC),d0 X subq #7,d0 X move.w d0,repeatlen X lea repeatbuffer,a1 X lea dummy,a2 X move.w d0,d1 X ext.l d1 X1$ move.b 0(a0),(a1)+ X move.b (a0)+,(a2)+ X dbf d1,1$ X X clr.l lastprinted X clr.b printed X move.w #1,repeat X bsr cli X tst.b printed X beq.s 2$ X bsr starttimer X rts X2$ clr.w repeat X rts X X;save the parameters from a 'window x y width height' call Xsetwindow tst.b fromfile X bne.s wiw1 Xwiw3 move.l #wiwerr,d0 X bra putnam Xwiw1 lea window_l(PC),a3 X moveq #3,d5 Xwiw0 bsr getnum X tst d7 X beq.s wiw2 X move.w d2,0(a3) X addq #2,a3 X dbf d5,wiw0 Xwiw2 rts X X;display ExecBase->LastAlert Xlastalert movem.l $100,d1-d2 X tst.l d1 X bne.s al1 X move.l _SysBase(PC),a0 X movem.l 514(a0),d1-d2 Xal1 move.l #gurutxt,d0 X bsr putstr X move.l d1,d0 X bsr hexa X lea out,a0 X move.l ptr(PC),d0 X move.b #'.',-1(a0,d0) X move.l d2,d0 X bsr hexa X bra newline X X;toggle CLI-Commands Xclicmd bchg #0,cmdcli X rts X X;toggle CPUSE task list Xusage bchg #0,usageflag X rts X X;toggle task-header display on/off Xnohead bchg #0,headon X rts X X;toggle hide entries on/off Xhidden bchg #0,hideon X rts X X;toggle sort on/off Xsort bchg #0,sorton X rts X X;toggle task-ports display on/off Xtaskports bchg #0,tports Xclo1 rts X X;Open a library Xopenlib bsr nodenam2 X move.l a5,a1 X moveq #0,d0 X CALL OpenLibrary,_SysBase(PC) X tst.l d0 X beq fn5 Xopli1 rts X X X;close it Xcloselib bsr nodenam2 X moveq #0,d7 X lea LibNode(PC),a4 X bsr findnam X tst.b d7 X beq.s clo1 X move.l d0,a1 X CALL CloseLibrary,_SysBase(PC) X rts X Xremnode bsr nodenam2 X moveq #7,d7 X lea TReNode(PC),a4 X bsr findnam X tst.b d7 X beq.s 1$ X CALL Disable,_SysBase(PC) X move.l d0,a1 X CALL Remove,_SysBase(PC) X CALL Enable,_SysBase(PC) X1$ rts X X;end Xoper but stay in background Xquithold lea in,a0 X lea dummy,a1 Xqh1 move.b (a1)+,d0 X move.b d0,(a0)+ X cmp.b #10,d0 X bne.s qh1 X Xinstback tst.b background X bne.s cleanit X move.b #1,background X bsr installh Xcleanit move.l infile(PC),d1 X beq.s ib1 X CALL Close,dosbase(PC) X clr.l infile X clr.b fromfile Xib1 clr.b running X bsr killpage X bsr freeblank X tst.l wnptr X beq.s 5$ X tst.b ownscreen X bne.s 6$ X move.l wnptr(PC),a0 X move.l 4(a0),window_l X move.l 8(a0),window_w X6$ move.l wnptr(PC),a0 X CALL CloseWindow,intuibase(PC) X clr.l intuimsg X clr.l wnptr X5$ move.l screenptr(PC),d0 X beq.s 4$ X move.l d0,a0 X CALL CloseScreen,intuibase(PC) X clr.l screenptr X X move.l realstack(PC),a7 X X4$ tst.b iconifyon X beq.s 1$ X jsr iconify X bra.s 2$ X X1$ move.l mysignal(PC),d0 X or.l trapsignal(PC),d0 X CALL Wait,_SysBase(PC) X2$ move.b #1,running X and.l trapsignal(PC),d0 X beq.s 3$ X move.b #1,gotguru X3$ bra restart X X;fill all unused memory-chunks with a longword Xclear moveq #0,d0 X cmp.b #10,0(a0) X beq.s clr5 X bsr readhex X tst.b d7 X beq syntax Xclr5 move.l _SysBase(PC),a0 X clr.l parmtxt X lea 322(a0),a0 X move.w #$4000,$dff09a Xclr1 move.l 0(a0),a0 X tst.l 0(a0) X beq.s clr6 X move.l 16(a0),a1 Xclr2 tst.l 0(a1) X beq.s clr1 X addq.l #1,parmtxt X move.l 4(a1),d1 X subq.l #8,d1 X ble.s clr31 X lsr.l #2,d1 X subq.l #1,d1 X bmi.s clr31 X lea 8(a1),a2 Xclr3 move.l d0,(a2)+ X dbf d1,clr3 Xclr31 move.l 0(a1),a1 X bra.s clr2 Xclr6 move.w #-$4000,$dff09a X move.l parmtxt(PC),d0 X bsr longdec X move.l #clrtxt,d0 X bra putnam X X;change the number of maximum lines in the history buffer Xhistorylines X bsr getnum X tst.b d7 X beq syntax X move.w d2,maxhlines X move.w hnum(PC),d0 X1$ cmp.w maxhlines(PC),d0 X ble.s 2$ X bsr remhistline X subq #1,d0 X bra.s 1$ X2$ move.l history+8,curhist X move.w d0,hnum X rts X;set the minimum number of characters a input line X;must have to be added to the history buffer Xhistorylength X bsr getnum X tst.b d7 X beq syntax X tst.b d2 X bne.s 1$ X addq #1,d2 X1$ move.w d2,minnumchars X rts X;display all lines in the history buffer Xshowhistory move.l history(PC),a5 X moveq #1,d5 X1$ tst.l 0(a5) X beq.s 2$ X move.l d5,d3 X bsr bytedec X move.w 8(a5),d0 X ext.l d0 X lea 10(a5),a0 X lea inputbuffer,a1 X CALL CopyMem,_SysBase(PC) X move.w 8(a5),d0 X lea inputbuffer,a1 X clr.b 0(a1,d0.w) X move.l a1,d0 X bsr putnam X addq #1,d5 X move.l 0(a5),a5 X bra.s 1$ X2$ rts X X;set the maximum lines the output buffer may hold Xoutputlines bsr getnum X tst.b d7 X beq syntax X moveq #100,d3 X tst.l d2 X bmi.s 2$ X cmp.l d3,d2 X bge.s 1$ X2$ move.l d3,d2 X1$ move.l d2,maxlines X rts X X;find a named node X;d7 = number of lists to search through X;a4 = pointer to the first entry in the X; list-offset-table X;a5 = pointer to name X;returns: X;d7 = TRUE/FALSE 1/0 X;d0 = node X Xfindnam tst.b 0(a5) X bne.s 1$ X move.l #nameerr,d0 X bsr putnam X bra fnerr X1$ cmp.b #'$',0(a5) X bne.s fn2 X move.l d7,d2 X move.l a5,a0 X bsr readhex X tst.b d7 X beq.s fn6 X move.l d2,d7 X bsr tstnode X tst.l d5 X bne.s fn3 X bra fn5 Xfn6 move.l d2,d7 Xfn2 move.l _SysBase(PC),a0 X adda.l 0(a4),a0 X move.l a5,a1 Xfn4 CALL FindName,_SysBase(PC) X tst.l d0 X bne.s fn1 X addq #4,a4 X dbf d7,fn2 Xfn5 move.l #namerr,d0 X bsr putstr X move.l a5,d0 X bsr putnam Xfnerr clr.b d7 X rts Xfn1 move.b procnum(PC),d2 X beq.s fn3 X move.l d0,a0 X cmp.b 143(a0),d2 X bne.s fn4 Xfn3 moveq.l #1,d7 X rts X X;list-offset-table XTRuNode dc.l 276 XTReNode dc.l 406 XTWaNode dc.l 420 XDevNode dc.l 350 XLibNode dc.l 378 XResNode dc.l 336 XMemNode dc.l 322 XPorNode dc.l 392 XSemNode dc.l 532 X X;Node has been entered in hex. Check if this node exsists Xtstnode tst.b fromfile X bne.s illegalhex X move.l d0,d1 X btst #0,d1 X beq.s inrange X move.l #adrerr,d0 X bsr putnam Xillegalhex moveq #0,d5 X rts Xinrange movem.l d7/a4,-(a7) X cmp.l #TRuNode,a4 X bne.s inrange1 X move.l _SysBase(PC),a0 X cmp.l 276(a0),d0 X beq.s nodefound X subq #1,d7 X addq #4,a4 Xinrange1 move.w #$4000,$dff09a Xgetlist move.l _SysBase(PC),a0 X add.l 0(a4),a0 Xnxtnode tst.l 0(a0) X beq.s nxtlist X cmp.l a0,d0 X beq.s nodefound X move.l 0(a0),a0 X bra.s nxtnode Xnxtlist addq #4,a4 X dbf d7,getlist X move.w #-$4000,$dff09a X movem.l d0/d7/a4,-(a7) X bsr ResumeOutput X move.l #noderr,d0 X bsr putnam X bsr readline X movem.l (a7)+,d0/d7/a4 X cmp.b #'y',inputbuffer X beq.s nodefound1 X moveq #0,d5 X movem.l (a7)+,d7/a4 X rts Xnodefound move.w #-$4000,$dff09a Xnodefound1 move.b #1,d5 Xetst movem.l (a7)+,d7/a0 X rts X X;allocate FileInfoBlock Xallocfinfo move.l #260,d0 X moveq #0,d1 X CALL AllocMem,_SysBase(PC) X move.l d0,finfoptr X rts X X;free FileInfoBlock Xfreefinfo move.l #260,d0 X move.l finfoptr(PC),d1 X beq.s 1$ X move.l d1,a1 X CALL FreeMem,_SysBase(PC) X1$ rts X X;Examine ,d0=Lock Xgetfinfo move.l d0,d1 X move.l finfoptr,d2 X CALL Examine,dosbase(PC) X rts X X;construct a Pathname from a lock X;d0=Lock ,resulting string is written to window Xgetpath movem.l d1-d7/a0-a6,-(a7) X move.l d0,d1 X beq.s 1$ X CALL DupLock,dosbase(PC) X1$ lea out,a4 X clr.b -(a4) Xgp0 move.l d0,-(a7) X bsr getfinfo X move.l finfoptr,a0 X move.l 4(a0),d4 X addq #8,a0 X bsr strlen X lea -1(a4),a5 X tst.l d4 X bmi.s nodir X move.b #'/',-(a4) Xnodir subq #1,d0 X bmi.s nofnam Xgp1 move.b 0(a0,d0),-(a4) X dbf d0,gp1 Xnofnam move.l 0(a7),d1 X CALL ParentDir,dosbase(PC) X move.l d0,d4 X move.l (a7)+,d1 X beq.s 2$ X CALL UnLock,dosbase(PC) X2$ move.l d4,d0 X bne gp0 Xputall cmp.b #'/',0(a5) X bne.s gp2 X move.b #':',0(a5) Xgp2 move.l a4,d0 X bsr putnam X movem.l (a7)+,d1-d7/a0-a6 X rts Xstrlen move.l a0,-(a7) X moveq #-1,d0 Xstrl2 addq.l #1,d0 X tst.b (a0)+ X bne.s strl2 X move.l (a7)+,a0 X rts Xstrlen2 move.l a0,-(a7) X move.l #-1,d0 Xstrl22 addq.l #1,d0 X cmp.b #10,(a0)+ X bne.s strl22 X move.l (a7)+,a0 X rts X X;write a title and underline X;a0 = pointer to text Xputhead1 bsr strlen X move.l d0,d5 X move.l a0,d0 X bra putstr X Xputhead2 bsr strlen X add.l d0,d5 X bra.s ph2 X Xputhead bsr strlen X move.l d0,d5 Xph2 move.l a0,d0 X bsr putnam X lea out,a0 X move.l a0,d0 Xph1 move.b #'-',(a0)+ X dbf d5,ph1 X move.b #$0a,(a0)+ X clr.b 0(a0) X bra putstr X X;move cursor to a column X;d0 = current position X;d1 = column Xtab move.l a3,-(a7) X lea out,a3 Xsp5 cmp.b d1,d0 X bcc.s sp4 X move.b #' ',0(a3,d0) X addq.b #1,d0 X bra.s sp5 Xsp4 move.l d1,ptr X move.l (a7)+,a3 X rts X X;convert ascii to byte X;a0 = pointer to text X;d0 = byte Xgetnum cmp.b #'$',0(a0) X bne.s isdec X bsr readhex X move.l d0,d2 X rts Xisdec moveq #0,d2 X move.l d2,d3 X move.l d2,d6 X move.l d2,d7 X cmp.b #'-',0(a0) X bne.s gn1 X addq #1,a0 X moveq.l #1,d6 Xgn1 move.b (a0)+,d3 X cmp.b #'9',d3 X bhi.s gn2 X cmp.b #'0',d3 X bcs.s gn2 X moveq #1,d7 X and.b #$f,d3 X muls #10,d2 X add.l d3,d2 X bra.s gn1 Xgn2 tst.b d6 X beq.s gn3 X neg.l d2 Xgn3 tst.b d7 X bne.s gn4 X subq #1,a0 Xgn4 rts X Xgetfrac bsr isdec X muls #10,d2 X cmp.b #'.',-1(a0) X bne.s 1$ X moveq #0,d0 X move.b (a0)+,d1 X cmp.b #10,d1 X beq.s 1$ X and.b #15,d1 X add.l d1,d2 X1$ rts X X;convert hex to longword X;a0 = pointer to text X;returns d0=value X;d7 = ok/error 1/0 Xreadhex movem.l d1-d6/a1-a5,-(a7) X moveq #1,d7 X cmp.b #'$',0(a0) X bne.s rh3 X addq #1,a0 Xrh3 moveq #0,d0 X cmpi.b #10,0(a0) X beq.s rherr X lea hextab(pc),a1 Xrh0 move.b (a0)+,d3 X moveq.l #15,d2 Xrh1 cmp.b 0(a1,d2),d3 X beq.s rh2 X dbf d2,rh1 X bra rhend Xrh2 lsl.l #4,d0 X or.b d2,d0 X bra.s rh0 Xrhend tst.b d3 X beq.s rhok X cmpi.b #10,d3 X beq.s rhok X cmpi.b #' ',d3 X beq.s rhok Xrherr moveq #0,d7 Xrhok movem.l (a7)+,d1-d6/a1-a5 X rts X X;skip blanks X;a0 pointer to text X; returns a0 = new pointer position Xkllblnks cmpi.b #' ',0(a0) X bne.s gn4 X addq #1,a0 X bra.s kllblnks X X; exit program. If background flag is set, wait for X; amiga-amiga-x X Xstopall addq #4,a7 X bra exitall X Xexit tst.b background X bne quithold Xexitall bsr killpage X bsr freeblank X bsr killhistory X move.l stplist(PC),a3 X tst.l 0(a3) X beq.s ex0 X move.l a3,d0 X bsr waok X bra.s exitall X Xex0 tst.b background X beq.s ex1 X bsr removeh X Xex1 move.l _SysBase(PC),a1 X move.l #_LVOSwitch,a0 X move.l oldswitch,d0 X CALL SetFunction,_SysBase(PC) X moveq #3,d0 X lea IOCounter(PC),a1 X CALL RemIntServer,_SysBase(PC) X X move.l replyport(PC),-(a7) X LIBCALL DeletePort X addq #4,a7 X bsr stoptimer X lea timerio,a1 X CALL CloseDevice,_SysBase(PC) X move.l timerport(PC),-(a7) X LIBCALL DeletePort X addq #4,a7 X X bsr restoretrap X X tst.l wnptr X beq.s 5$ X move.l wnptr(PC),a0 X CALL CloseWindow,intuibase(PC) X5$ move.l screenptr(PC),d0 X beq.s 6$ X move.l d0,a0 X CALL CloseScreen,intuibase(PC) X clr.l screenptr X X6$ move.l infile(PC),d1 X beq.s ex11 X CALL Close,dosbase(PC) Xex11 bsr freehidmem X bsr freealias X bsr clrfkeys X move.l realstack(PC),a7 X IFND DEBUG X CALL Forbid,_SysBase(PC) X move.l wbmsg(PC),d0 X beq.s todos X move.l d0,a1 X CALL ReplyMsg,_SysBase(PC) X moveq #0,d0 X rts X Xtodos move.l mytask(PC),a0 X move.l 152(a0),d1 X CALL UnLock,dosbase(PC) X move.l myseg(PC),d1 X CALL UnLoadSeg,dosbase(PC) X ENDC X moveq #0,d0 X rts X X;print a bcpl-string X;d0 = bcpl-pointer to bcpl-string Xputbcpl movem.l d3/a0-a1,-(a7) X tst.l d0 X beq.s pb1 X lsl.l #2,d0 X move.l d0,a1 X moveq #0,d3 X move.b (a1)+,d3 X subq #1,d3 X move.l ptr(PC),d0 X lea out,a0 Xpb2 move.b (a1)+,0(a0,d0) X beq.s 1$ X addq.b #1,d0 X dbf d3,pb2 X1$ move.l d0,ptr Xpb1 movem.l (a7)+,d3/a0-a1 X rts X X;compare strings X;a0/a1 = pointers to string X;returns d0 = true(0) false(1), d1 = length Xstrcmp movem.l a0-a1,-(a7) X moveq #0,d0 X move.l d0,d1 Xsrc2 move.b (a0)+,d0 X beq.s src1 X cmp.b #10,d0 X beq.s src1 X addq #1,d1 X cmp.b (a1)+,d0 X beq.s src2 X bra.s src3 Xsrc1 move.b 0(a1),d0 Xsrc3 movem.l (a7)+,a0-a1 X rts X Xstrbuf movem.l d0/a1-a2,-(a7) X move.l a0,a1 X lea buffer,a2 X1$ move.b (a1)+,d0 X cmp.b #10,d0 X beq.s 2$ X cmp.b #' ',d0 X beq.s 2$ X or.b #' ',d0 X beq.s 2$ X move.b d0,(a2)+ X bra.s 1$ X2$ clr.b (a2)+ X movem.l (a7)+,d0/a1-a2 X rts X X;compare bcpl string with string X;a0 = pointer to string X;a2 = bcpl-pointer to bcpl-string X;returns d0 = true(0) false(1) Xstrbcmp movem.l d1/a0/a2,-(a7) X moveq #0,d0 X moveq #0,d1 X adda.l a2,a2 X adda.l a2,a2 X move.b (a2)+,d1 X beq.s stb1 X subq #1,d1 Xstb2 cmp.b (a2)+,(a0)+ X bne.s stb1 X dbf d1,stb2 X moveq #1,d0 Xstb1 movem.l (a7)+,d1/a0/a2 X rts X X;add a fkey definition to the fkey list. Each entry X;looks like this: long Succ, long Pred, byte Key#, byte length, X; char text[] X Xsetfkey bsr nodenam X move.b procnum(PC),d5 X beq syntax X cmp.b #21,d5 X bge syntax X subq #1,d5 X move.b d5,procnum X lea fkeys(PC),a1 X1$ move.l 0(a1),a1 X tst.l 0(a1) X beq.s 2$ X cmp.b 8(a1),d5 X bne.s 1$ X move.l a1,d3 X CALL Remove,_SysBase(PC) X move.l d3,a1 X bsr removefkey X2$ tst.b 0(a5) X beq.s 4$ X move.l a5,a0 X bsr strlen X move.l d0,d5 X add.w #10,d0 X moveq #0,d1 X CALL AllocMem,_SysBase(PC) X tst.l d0 X beq.s 4$ X move.l d0,a1 X move.l d0,a4 X move.b procnum(PC),8(a1) X move.b d5,9(a1) X lea fkeys(PC),a0 X CALL AddHead,_SysBase(PC) X lea 10(a4),a4 X subq #1,d5 X3$ move.b (a5)+,(a4)+ X dbeq d5,3$ X4$ rts X Xclrfkeys lea fkeys(PC),a0 X CALL RemHead,_SysBase(PC) X tst.l d0 X beq.s 1$ X move.l d0,a1 X bsr removefkey X bra.s clrfkeys X1$ rts X Xremovefkey move.b 0(a1),d0 X ext.w d0 X ext.l d0 X add.w #10,d0 X CALL FreeMem,_SysBase(PC) X rts X X;convert long to decimal X;d0 = value X;d3 bit 0 = left/right justified X;d3 bit 1 = write/leave X;returns string in 'buffer' Xlongdec movem.l d1-d2/a1-a2,-(a7) X tst.l d0 X bmi.s 2$ X cmp.l #9999999,d0 X ble.s 1$ X2$ move.l #smallnix,d0 X bra.s ld6 X1$ lea binarea+8(PC),a1 X move.l #' ',-8(a1) X move.l #' ',-4(a1) X clr.b 0(a1) X subq #1,a1 X cmp #2,d3 X bne.s ld5 X clr.b 0(a1) Xld5 moveq #1,d2 Xld2 addq #1,d2 X moveq #$a,d1 X bsr div X addi.l #$30,d1 X move.b d1,-(a1) X tst.l d0 X bne.s ld2 X X btst #0,d3 X bne.s ld1 X lea binarea(PC),a2 X cmpa.l a2,a1 X bne.s ld3 X subq.l #1,ptr X bra.s ld1 Xld3 move.b 0(a1),(a2)+ X move.b #' ',(a1)+ X dbf d2,ld3 Xld1 cmp #2,d3 X beq.s ld4 X move.l #binarea,d0 Xld6 bsr putstr Xld4 movem.l (a7)+,d1-d2/a1-a2 X rts X X;write UBYTE X;d3 = value Xbytedec bsr dec X move.l #decimal,d0 X bra.s pm1 X X;write signed byte X;d3 = value Xplusmins movem.l d5/a3,-(a7) X move.w #$2020,minus X move.b d3,d5 X bpl.s 2$ X neg.b d3 X2$ bsr.s dec X tst.b d5 X bpl.s 1$ X move.l d0,a3 X move.b #'-',-(a3) X1$ movem.l (a7)+,d5/a3 X move.l #minus+1,d0 Xpm1 bra putstr X Xdec movem.l d3/a3,-(a7) X move.l #$20202020,decimal X and.l #$ff,d3 X lea decimal+3(PC),a3 Xbloop tst.b d3 X beq.s bend X divu #10,d3 X swap d3 X ori.b #'0',d3 X move.b d3,-(a3) X clr.w d3 X swap d3 X bra.s bloop Xbend cmpa.l #decimal+3,a3 X bne 1$ X move.b #'0',-(a3) X1$ move.l a3,d0 X movem.l (a7)+,d3/a3 X rts X X;write a string, move cursor into next line X;d0 = pointer to text Xputnam bsr putstr Xputnam1 tst.b d0 X beq.s ncr X bsr newline Xncr rts X X;write one char X;d0 = char Xputchar movem.l d1/a0,-(a7) X move.l ptr(PC),d1 X lea out,a0 X move.b d0,0(a0,d1) X addq.l #1,ptr X movem.l (a7)+,d1/a0 X rts X X;write a string, strings are only put into the output buffer when X;a LF is detected X;d0 = pointer to string X;returns d0 = cursor position Xputstr movem.l d1-d7/a0-a6,-(a7) X move.b #1,printed X move.l d0,a2 X lea out,a3 X move.l ptr(PC),d0 X move.l a2,d5 X bne pst1 X lea longnix(PC),a2 X Xpst1 move.b (a2)+,d1 X cmpi.b #13,d1 X beq pst1 X cmpi.b #10,d1 X beq.s lineend X move.b d1,0(a3,d0) X beq prend X cmp #100,d0 X bge.s pst1 X addq #1,d0 X bra.s pst1 X Xlineend tst.b fromfile X beq.s 1$ X moveq #0,d0 X bra prend X X1$ tst.l lastprinted X bne.s 2$ X bsr killpage X X2$ addq #1,d0 X move.l d0,-(a7) X add #14,d0 X moveq #0,d1 X CALL AllocMem,_SysBase(PC) X move.l (a7)+,d1 X tst.l d0 X beq prend X move.l d0,a0 X move.w d1,12(a0) X cmp.w maxllength(PC),d1 X ble.s 7$ X move.w d1,maxllength X7$ move.l node,8(a0) X clr.l node X clr.l 0(a0) X X move.l lastprinted(PC),d0 X move.l d0,4(a0) X bne.s 3$ X move.l a0,outchain X bra.s 4$ X3$ move.l d0,a1 X move.l a0,0(a1) X4$ move.l a0,lastprinted X move.b #' ',14(a0) X subq #1,d1 X lea 15(a0),a0 X lea out,a1 X subq #1,d1 X bmi.s 6$ X5$ move.b (a1)+,(a0)+ X dbf d1,5$ X6$ move.l numlines(PC),d2 X cmp.l maxlines(PC),d2 X ble.s 8$ X X move.l outchain(PC),a1 X move.l 0(a1),a2 X move.l a2,outchain X clr.l 4(a2) X move.w 12(a1),d0 X add.w #14,d0 X ext.l d0 X CALL FreeMem,_SysBase(PC) X bra.s 9$ X X8$ addq.l #1,d2 X move.l d2,numlines X X9$ moveq #0,d0 X move.l d0,d5 X tst.b addlines X beq pst1 X bsr addline X bra pst1 Xprend move.l d0,ptr X movem.l (a7)+,d1-d7/a0-a6 X rts X X;Kill output buffer Xkillpage movem.l d0-d7/a0-a6,-(a7) X tst.l outchain X beq.s 2$ X move.l outchain(PC),a1 X bsr killlines X clr.l outchain X clr.l lastprinted X clr.l numlines X clr.w maxllength X2$ movem.l (a7)+,d0-d7/a0-a6 X rts X X;kill the remainder of the output buffer Xkilllines move.l 0(a1),-(a7) X move.w 12(a1),d0 X ext.l d0 X add #14,d0 X CALL FreeMem,_SysBase(PC) X move.l (a7)+,a1 X move.l a1,d7 X bne.s killlines X rts X Xfreeblank move.l blanks(PC),d0 X beq.s 1$ X move.l d0,a1 X move.w colms(PC),d0 X ext.l d0 X CALL FreeMem,_SysBase(PC) X clr.l blanks X1$ rts X X;write a portion of the output buffer to the screen Xblastout move.l rastport(PC),a1 X moveq #1,d0 X CALL SetAPen,gfxbase(PC) X move.l rastport(PC),a1 X moveq #1,d0 X CALL SetDrMd,gfxbase(PC) X moveq #0,d7 X X move.w loffset(PC),d2 X beq.s 7$ X move.w colms(PC),d4 X add.w d4,d2 X move.w maxllength(PC),d3 X cmp.w d3,d2 X ble.s 7$ X move.w d3,d2 X sub.w d4,d2 X bpl.s 8$ X moveq #0,d2 X8$ move.w d2,loffset X X7$ bsr tstfirstlin X X1$ tst.l outchain X beq.s 3$ X bsr findline X X2$ move.w colms(PC),d5 X ext.l d5 X move.w loffset(PC),d4 X ext.l d4 X moveq #18,d6 X6$ lea 14(a5,d4),a0 X move.w 12(a5),d3 X ext.l d3 X bsr blastline X bge.s 3$ X tst.l 0(a5) X beq.s 5$ X move.l 0(a5),a5 X bra 6$ X5$ moveq #0,d3 X bsr blastline X bcs.s 5$ X3$ rts X X;get a pointer to a line (line # in d0) Xfindline move.l outchain(PC),d1 X beq 2$ X move.l d1,a5 X1$ tst d0 X beq.s 2$ X tst.l 0(a5) X beq.s 2$ X move.l 0(a5),a5 X dbf d0,1$ X2$ rts X X;check if the display is as 'full' as possible Xtstfirstlin move.l firstline(PC),d0 X move.l d0,d2 X add.w rows(PC),d2 X cmp.l numlines(PC),d2 X bmi.s 1$ X move.l numlines(PC),d2 X sub.w rows(PC),d2 X bpl.s 4$ X moveq #0,d2 X4$ move.l d2,d0 X move.l d2,firstline X1$ rts X X;display one line, fill the gap between the end of the line and X;the end of the window with spaces. X;d6 = ypos, d5=colms, d3= linelength, d7= line # in window, a0 = text X Xblastline move d6,d1 X moveq #6,d0 X move.l rastport(PC),a1 X CALL Move,gfxbase(PC) X sub.w d4,d3 X bpl.s 7$ X moveq #0,d3 X bra.s 6$ X7$ cmp.w d5,d3 X bmi.s 4$ X move.w d5,d3 X4$ move.l d3,d0 X beq.s 6$ X move.l rastport(PC),a1 X CALL Text,gfxbase(PC) X6$ move.l d5,d0 X sub.l d3,d0 X ble.s 5$ X move.l blanks(PC),a0 X move.l rastport(PC),a1 X CALL Text,gfxbase(PC) X5$ addq #8,d6 X addq #1,d7 X cmp.w rows(PC),d7 X rts X X;Write pointer, display '-------' if empty Xhexan tst.l d0 X bne.s hexa X bra putstr X X;Write 8 byte hex value X;d0 = value Xhexa bsr gthex X bra putstr X Xgthex movem.l d1-d7/a0-a6,-(a7) X moveq.l #7,d5 X lea hexarea(PC),a1 X lea hextab(PC),a0 X moveq #0,d2 Xhexloop move.b d0,d2 X and.b #15,d2 X move.b 0(a0,d2),0(a1,d5) X lsr.l #4,d0 X dbf d5,hexloop X move.l a1,d0 X movem.l (a7)+,d1-d7/a0-a6 X rts X X;Convert/write byte into binary string X;d0 = value Xbin movem.l d1-d7/a0-a6,-(a7) X lea binarea(PC),a0 X move.w #$2020,8(a0) X moveq.l #7,d4 Xbinloop moveq.l #'0'/2,d1 X roxr.b #1,d0 X roxl.b #1,d1 X move.b d1,0(a0,d4) X dbf d4,binloop X move.l a0,d0 X movem.l (a7)+,d1-d7/a0-a6 X bra putstr X X;send a packet X;a0 = msgport X;dp_Type and dp_Arg1 have to be inizialized Xcons1 movem.l d0-d7/a0-a6,-(a7) X move.l #dp_Link,LN_NAME X move.l #mypacket,dp_Link X move.l replyport(PC),dp_Port X lea mypacket,a1 X CALL PutMsg,_SysBase(PC) X move.l replyport,a0 X CALL WaitPort,_SysBase(PC) X move.l replyport(PC),a0 X CALL GetMsg,_SysBase(PC) X movem.l (a7)+,d0-d7/a0-a6 X rts X X;32-bit division X;d0 / d1 X;returns d0 Xdiv movem.l d2-d3,-(a7) X tst.l d1 X beq div8 X swap d1 X move.w d1,d2 X bne.s div1 X swap d0 X swap d1 X swap d2 X move.w d0,d2 X beq.s div2 X divu d1,d2 X move.w d2,d0 Xdiv2 swap d0 X move.w d0,d2 X divu d1,d2 X move.w d2,d0 X swap d2 X move.w d2,d1 X bra div8 Xdiv1 moveq #$10,d3 X cmpi.w #$80,d1 X bcc.s div3 X rol.l #8,d1 X subq.w #8,d3 Xdiv3 cmpi.w #$800,d1 X bcc.s div4 X rol.l #4,d1 X subq.w #4,d3 Xdiv4 cmpi.w #$2000,d1 X bcc.s div5 X rol.l #2,d1 X subq.w #2,d3 Xdiv5 tst.w d1 X bmi.s div6 X rol.l #1,d1 X subq.w #1,d3 Xdiv6 move.w d0,d2 X lsr.l d3,d0 X swap d2 X clr.w d2 X lsr.l d3,d2 X swap d3 X divu d1,d0 X move.w d0,d3 X move.w d2,d0 X move.w d3,d2 X swap d1 X mulu d1,d2 X sub.l d2,d0 X bcc.s div7 X subq.w #1,d3 X add.l d1,d0 Xdiv7 moveq #0,d1 X move.w d3,d1 X swap d3 X rol.l d3,d0 X swap d0 X exg d1,d0 Xdiv8 movem.l (a7)+,d2-d3 X rts X X;install a input-handler Xinstallh pea 0 X pea xopsleep X LIBCALL CreatePort X addq #8,a7 X move.l d0,InputMsg X move.l d0,-(a7) X LIBCALL CreateStdIO X addq #4,a7 X move.l d0,InRequest X move.l d0,a1 X lea devicenam(PC),a0 X moveq #0,d0 X moveq #0,d1 X CALL OpenDevice,_SysBase(PC) X move.l d0,devstatus X movea.l InRequest(PC),a1 X move.l #InInterrupt,40(a1) X move.w #9,28(a1) X CALL DoIO,_SysBase(PC) X move.l d0,iostatus X move.l #-1,d0 X CALL AllocSignal,_SysBase(PC) X moveq #0,d1 X bset d0,d1 X move.l d1,mysignal X rts X X;remove handler Xremoveh movea.l InRequest(PC),a1 X move.l #InInterrupt,40(a1) X move.w #10,28(a1) X CALL DoIO,_SysBase(PC) X movea.l InRequest(PC),a1 X CALL CloseDevice,_SysBase(PC) X move.l InRequest,-(a7) X LIBCALL DeleteStdIO X addq #4,a7 X move.l InputMsg,-(a7) X LIBCALL DeletePort X addq #4,a7 X rts X X;this is the handler, it checks if amiga-amiga-x X;has been pressed and signals it to our task XKeyhandler tst.b running X bne.s endhandler X cmp.b #1,4(a0) X bne.s endhandler X move.w 8(a0),d0 X andi.w #$c0,d0 X cmpi.w #$c0,d0 X bne.s endhandler X cmp.w #$32,6(a0) X bne.s endhandler Xwakeup move.l a0,-(a7) X movea.l mytask(PC),a1 X move.l mysignal(PC),d0 X CALL Signal,_SysBase(PC) X move.l (a7)+,a0 X clr.b 4(a0) Xendhandler move.l a0,d0 X rts X Xsnoop bsr cls X bsr nodenam X moveq #1,d7 X lea TReNode(PC),a4 X bsr findnam X tst.b d7 X bne.s 1$ X move.l #stperr,d0 X bra putnam X1$ move.l d0,captask X pea 0 X pea memportname X LIBCALL CreatePort X addq #8,a7 X move.l d0,snoopport X beq tm6 X X bsr replyintui X move.b #1,addlines X lea snoophead(PC),a0 X bsr puthead X move.l _SysBase(PC),a1 X move.l -196(a1),oldalloc X move.l -208(a1),oldfree X move.l #capmalloc,d0 X move.l #-198,a0 X CALL SetFunction,_SysBase(PC) X move.l _SysBase(PC),a1 X move.l #capmfree,d0 X move.l #-210,a0 X CALL SetFunction,_SysBase(PC) X clr.b bool X clr.b cbreak X Xwaitmem move.l snoopport(PC),a0 X moveq #0,d1 X move.b 15(a0),d1 X bset d1,d0 X move.l d0,auxsig X bsr processmsgs X Xtm7 move.l mytask(PC),a0 X move.l snoopport(PC),a0 X CALL GetMsg,_SysBase(PC) X tst.l d0 X bne tm8 X tst.b cbreak X bne snoopend X bra waitmem Xtm8 move.l d0,a3 X move.l 20(a3),d3 X btst #31,d3 X beq freed X move.l #allok,d0 X bsr putstr X lea memname(PC),a2 X lea membit(PC),a4 X moveq #4,d5 Xtm2 move.l 0(a4),d4 X btst d4,d3 X beq.s tm1 X move.l 0(a2),d0 X bsr putstr Xtm1 addq #4,a2 X addq #4,a4 X dbf d5,tm2 X moveq #26,d1 X bsr tab X move.l 24(a3),d0 X move.l d0,d3 X bsr hexa X move.l 28(a3),d0 X bne.s tm3 X move.l #failed,d0 X bsr putstr X moveq #53,d1 X bsr tab X bra tm4 Xtm3 bsr hexa X move.l 28(a3),d0 X add.l d3,d0 X bsr hexa X bra tm4 X Xfreed move.l #free,d0 X bsr putstr X move.b #'-',d0 X moveq #18,d1 Xtm9 bsr putchar X dbf d1,tm9 X move.b #' ',d0 X bsr putchar X move.l d3,d0 X bsr hexa X move.l 24(a3),d0 X bsr hexa X move.l 24(a3),d0 X add.l d3,d0 X bsr hexa X Xtm4 move.l 32(a3),d0 X bsr hexa X bsr newline X move.w 18(a3),d0 X ext.l d0 X move.l a3,a1 X CALL FreeMem,_SysBase(PC) X bra tm7 X Xsnoopend move.l _SysBase(PC),a1 X move.l oldalloc(PC),d0 X move.l #-198,a0 X CALL SetFunction,_SysBase(PC) X move.l _SysBase(PC),a1 X move.l oldfree,d0 X move.l #-210,a0 X CALL SetFunction,_SysBase(PC) X move.l snoopport,-(a7) X LIBCALL DeletePort X addq #4,a7 X move.l #stoped,d0 X bsr putnam X clr.b addlines X clr.l auxsig Xtm6 rts X Xmemname dc.l memlarg,memclr,memfast,memchip,mempubl Xmembit dc.l 17,16,2,1,0 X Xcapmalloc movem.l d0-d7/a0-a6,-(a7) X move.l _SysBase(PC),a6 X move.l 276(a6),d4 X cmp.l captask(PC),d4 X bne.s capm1 X tst.b bool X bne capm1 X move.b #1,bool X moveq #36,d6 X bsr allocmsg X beq capm2 X bset #31,d1 X move.l d1,20(a5) X move.l d0,24(a5) X move.l 60(a7),32(a5) X move.l a5,remembr X movem.l (a7)+,d0-d7/a0-a6 X bsr memalloc X movem.l d0-d7/a0-a6,-(a7) X move.l remembr(PC),a1 X move.l d0,28(a1) X move.l snoopport,a0 X move.b #5,8(a1) X CALL PutMsg,_SysBase(PC) X clr.b bool X movem.l (a7)+,d0-d7/a0-a6 X rts Xcapm2 clr.b bool Xcapm1 movem.l (a7)+,d0-d7/a0-a6 Xmemalloc dc.w $4ef9 Xoldalloc dc.l 0 X Xcapmfree movem.l d0-d7/a0-a6,-(a7) X move.l _SysBase(PC),a6 X move.l 276(a6),d4 X cmp.l captask(PC),d4 X bne.s capf1 X tst.b bool X bne.s capf1 X move.b #1,bool X moveq #36,d6 X bsr allocmsg X beq.s capf2 X move.l d0,20(a5) X move.l a1,24(a5) X move.l 60(a7),32(a5) X move.l snoopport,a0 X move.b #5,8(a5) X move.l a5,a1 X CALL PutMsg,_SysBase(PC) Xcapf2 clr.b bool Xcapf1 movem.l (a7)+,d0-d7/a0-a6 X dc.w $4ef9 Xoldfree dc.l 0 X Xallocmsg movem.l d0-d1/a0-a1,-(a7) X move.l d6,d0 X move.l #65536,d1 X bsr memalloc X tst.l d0 X beq.s alm1 X move.l d0,a5 X move.w d6,18(a5) Xalm1 movem.l (a7)+,d0-d1/a0-a1 X move.l a5,d6 X rts X Xmyswitch movem.l d0-d1/a0-a1,-(a7) X move.l _SysBase(PC),a0 X move.l 276(a0),d0 X move.l tasksnum(PC),d1 X lea cputime,a0 X subq.l #1,d1 X bmi.s swadd Xsw0 cmp.l (a0)+,d0 X dbeq d1,sw0 X tst d1 X bmi.s swadd Xswi1 add.l #1,508(a0) Xswgo movem.l (a7)+,d0-d1/a0-a1 X dc.w $4ef9 Xoldswitch dc.l 0 Xswadd cmp.l #125,tasksnum X bge.s swgo X addq.l #1,tasksnum X move.l d0,0(a0) X move.l #1,512(a0) X bra.s swgo X Xcountio addq.l #1,iocount X moveq #0,d0 Xcio1 rts X Xiconbackdrp tst.b iconifyon X beq.s 1$ X lea icnwindow,a0 X eor.l #$100,14(a0) ;wn_Flags X1$ rts X Xiconifyoff tst.b iconifyon X beq.s cio1 X clr.b iconifyon X tst.b fromfile X bne.s 1$ X move.l wnptr(PC),d0 X beq.s 1$ X move.l d0,a0 X lea iconifgad,a1 X CALL RemoveGadget,intuibase(PC) X move.l wnptr(PC),a0 X CALL RefreshWindowFrame,intuibase(PC) X1$ move.l #iconify,d0 X Xkillseg movem.l d1-d2/a0-a4,-(a7) X subq #4,d0 X move.l 4,a6 X move.l 276(a6),a4 X move.l 128(a4),d1 X lsl.l #2,d1 X move.l d1,a3 X move.l 12(a3),d1 X bne.s 2$ X move.l 172(a4),d1 X lsl.l #2,d1 X move.l d1,a4 X move.l 60(a4),d1 X X2$ lsl.l #2,d1 X cmp.l d0,d1 X beq.s 4$ X move.l d1,a4 X move.l 0(a4),d1 X beq.s 5$ X bra.s 2$ X X4$ move.l d1,a0 X move.l 0(a0),0(a4) X clr.l 0(a0) X lsr.l #2,d1 X CALL UnLoadSeg,dosbase(PC) X movem.l (a7)+,d1-d2/a0-a4 X5$ rts X Xalert bsr stoptimer X move.l excpttask(PC),d0 X bne.s alert1 X move.l #noguru,d0 X bra putnam Xalert1 move.l #softfail,d0 X bsr putstr X move.l excpttask(PC),a0 X move.l 10(a0),d0 X bsr putnam X cmp.l #3,excpterror X bne.s 1$ X move.l #addrserr,d0 X bsr putstr X move.l excptaddr(PC),d0 X bsr hexa X bsr newline X1$ move.l #procount,d0 X bsr putstr X move.l excptpc(PC),d0 X bsr hexa X bsr newline X move.l #gurutxt,d0 X bsr putstr X move.l excpterror(PC),d0 X bsr hexa X lea out,a0 X move.l ptr(PC),d0 X move.b #'.',-1(a0,d0) X move.l excpttask(PC),d0 X bsr hexa X bra newline X Xshowguru bsr alert X tst.b ownscreen X bne.s 5$ X move.l wnptr(PC),a0 X CALL WindowToFront,intuibase(PC) X bra.s 2$ X5$ move.l screenptr,a0 X CALL ScreenToFront,intuibase(PC) X2$ move.l #whatnow,d0 X bsr putnam X clr.l oldpageend X bsr readline X X cmp.b #'i',inputbuffer X beq.s 4$ X1$ cmp.b #'k',inputbuffer X bne.s 2$ X move.l excpttask(PC),a1 X tst.l 22(a1) X bne.s 3$ X CALL RemTask,_SysBase(PC) X bra.s 4$ X3$ move.l a1,d0 X bsr canok X4$ clr.l lastprinted X rts X Xmyaddtask move.l a3,-(a7) X lea mytrap(PC),a3 X move.l 50(a1),d0 X beq.s 1$ X cmp.l oldtrap(PC),d0 X beq.s 1$ X lea myproctrap(PC),a3 X cmp.l oldproctrap(PC),d0 X bne.s 2$ X1$ move.l a3,50(a1) X2$ move.l (a7)+,a3 X dc.w $4ef9 XOldAddTask dc.l 0 X Xmyproctrap bsr traphandle X dc.w $4ef9 Xoldproctrap dc.l 0 X Xmytrap bsr traphandle X moveq #0,d0 X CALL Wait,_SysBase(PC) X dc.w $4ef9 Xoldtrap dc.l 0 X Xtraphandle movem.l d0-d7/a0-a6,$180 X move.l 4,a6 X move.l 276(a6),excpttask X move.l 4(a7),d0 X cmp.l #9,d0 X beq.s 2$ X move.l d0,excpterror X moveq #10,d1 X cmp.l #3,d0 X bne.s 1$ X move.l 0(a7,d1.w),excptaddr X moveq #18,d1 X1$ move.l 0(a7,d1.w),excptpc X move.l mytask(PC),a1 X move.l trapsignal(PC),d0 X jsr _LVOSignal(a6) X2$ movem.l $180,d0-d7/a0-a6 X rts X Xtrapguru tst.b wanttraps X bne restoretrap X move.b #1,wanttraps X Xaddtraps tst.b wanttraps X beq 5$ X move.l 304(a6),oldtrap ;Original EXEC trap handler X moveq #-1,d0 X CALL AllocSignal,_SysBase(PC) X moveq #0,d1 X bset d0,d1 X move.l d1,trapsignal X move.l #_LVOAddTask,a0 ;need a new AddTask() to change X move.l 2(a6,a0),OldAddTask ;AmigaDos's default trap handler X move.l a6,a1 X move.l #myaddtask,d0 X CALL SetFunction,_SysBase(PC) X CALL Forbid,_SysBase(PC) ;change the trap handler of X moveq #0,d5 ;aleady running tasks X bsr getaskdat ;get task stucture pointers X1$ tst.b entries X beq.s 2$ X lea -16(a5),a5 X move.l 0(a5),a4 ;pointer to a task structure X lea myproctrap(PC),a0 X move.l 50(a4),d0 ;Task->tc_TrapCode X cmp.l oldproctrap(PC),d0 ;AmigaDos Handler ? X beq.s 3$ X lea mytrap(PC),a0 ;EXEC Handler ? X cmp.l oldtrap(PC),d0 X bne.s 4$ ;must be a custom one, skip it X3$ move.l a0,50(a4) ;replace it X4$ subq.b #1,entries X bra.s 1$ X2$ CALL Permit,_SysBase(PC) X5$ rts X Xrestoretrap tst.b wanttraps X beq.s 6$ X tst.b fromfile X bne.s 5$ X move.l #_LVOAddTask,a0 X move.l OldAddTask(PC),d0 X move.l _SysBase(PC),a1 X CALL SetFunction,_SysBase(PC) X CALL Forbid,_SysBase(PC) X bsr getaskdat X1$ tst.b entries X beq.s 2$ X lea -16(a5),a5 X move.l 0(a5),a4 X move.l oldproctrap(PC),a0 X move.l 50(a4),d0 X cmp.l #myproctrap,d0 X beq.s 3$ X move.l oldtrap(PC),a0 X cmp.l #mytrap,d0 X bne.s 4$ X3$ move.l a0,50(a4) X4$ subq.b #1,entries X bra.s 1$ X2$ CALL Permit,_SysBase(PC) X clr.l trapsignal X5$ clr.b wanttraps X6$ rts X X;save the contents of the output buffer X;to a file Xsaveoutput bsr nodenam2 X tst.b 0(a5) X beq syntax X move.l a5,d1 X move.l #1006,d2 X CALL Open,dosbase(PC) X move.l d0,d5 X bne.s 1$ X move.l #openerr,d0 X bsr putstr X move.l a5,d0 X bra putnam X1$ move.l outchain(PC),d0 X beq.s 3$ X2$ move.l d0,a5 X move.w 12(a5),d3 X beq.s 4$ X ext.l d3 X lea 14(a5),a1 X move.l a1,d2 X move.l d5,d1 X CALL Write,dosbase(PC) X tst.l d0 X ble.s 3$ X4$ moveq #1,d3 X move.l d5,d1 X move.l #cr,d2 X CALL Write,dosbase(PC) X tst.l d0 X ble.s 3$ X move.l 0(a5),d0 X bne.s 2$ X3$ move.l d5,d1 X CALL Close,dosbase(PC) X rts X Xgrabtimerio lea tiohead(PC),a0 X bsr puthead X move.b timeout(PC),d4 X move.b #255,timeout X bsr starttimer X move.b d4,timeout X lea timerio,a1 X CALL Disable,_SysBase(PC) X2$ move.l 0(a1),d2 X beq.s 1$ X move.l d2,a1 X bra.s 2$ X1$ CALL Enable,_SysBase(PC) X lea -4(a1),a5 X bsr stoptimer X lea buffer,a4 X moveq #1,d4 X bsr gettrq X X lea timerio,a0 X lea dummy,a1 X moveq #40,d0 X CALL CopyMem,_SysBase(PC) X X lea dummy,a1 X lea timernam(PC),a0 X moveq #0,d1 X moveq #0,d0 X CALL OpenDevice,_SysBase(PC) X X lea dummy,a1 X move.l #1<<30,32(a1) X CALL SendIO,_SysBase(PC) X X lea dummy,a5 X CALL Disable,_SysBase(PC) X8$ move.l 0(a5),d2 X beq.s 7$ X move.l d2,a5 X bra.s 8$ X7$ CALL Enable,_SysBase(PC) X lea -4(a5),a5 X X lea dummy,a1 X CALL AbortIO,_SysBase(PC) X lea timerio,a1 X CALL WaitIO,_SysBase(PC) X move.w timersig,d0 X moveq #0,d1 X bset d0,d1 X moveq #0,d0 X CALL SetSignal,_SysBase(PC) X X moveq #0,d4 X bsr gettrq X X lea dummy,a1 X CALL CloseDevice,_SysBase(PC) X X clr.l (a4)+ X lea -22(a4),a2 X moveq #18,d2 X bsr sortlist X X lea buffer,a5 X5$ move.l (a5)+,d0 X beq.s 6$ X bsr hexa X move.w (a5)+,d0 X ext.l d0 X mulu #9,d0 X add.l #timerunits,d0 X bsr putstr X move.l (a5)+,d3 X mulu #10,d3 X move.l (a5)+,d0 X move.l #100000,d1 X bsr div X add.l d3,d0 X cmp.l #2559,d0 X ble.s 9$ X move.l #whatsthis,d0 X bsr putstr X bra.s 10$ X9$ moveq #1,d6 X bsr putfrac X10$ move.b #' ',d0 X bsr putchar X move.l (a5)+,d0 X bsr getaskname2 X bsr newline X bra.s 5$ X6$ rts X Xgettrq CALL Disable,_SysBase(PC) X3$ move.l 0(a5),a5 X tst.l 0(a5) X beq.s 4$ X move.l a5,(a4)+ X move.w d4,(a4)+ X move.l 32(a5),(a4)+ X move.l 36(a5),(a4)+ X move.l 14(a5),a1 X move.l 16(a1),(a4)+ X bra.s 3$ X4$ CALL Enable,_SysBase(PC) X rts X X X;check if the timer is runnig, start it if not Xstarttimer lea timerio,a1 X cmp.b #5,8(a1) X beq.s 1$ X moveq #0,d0 X move.b timeout(PC),d0 X bne.s 2$ X tst.l timeoutm X beq.s 1$ X2$ move.l d0,32(a1) X move.l timeoutm(PC),36(a1) X move.w #9,28(a1) X CALL SendIO,_SysBase(PC) X1$ rts X;Abort a timer request, if pending Xstoptimer lea timerio,a1 X cmp.b #5,8(a1) X bne.s 1$ X CALL AbortIO,_SysBase(PC) X lea timerio,a1 X CALL WaitIO,_SysBase(PC) X1$ move.w timersig,d0 X moveq #0,d1 X bset d0,d1 X moveq #0,d0 X CALL SetSignal,_SysBase(PC) X rts X;Xoper main loop, process all incoming messages Xprocessmsgs move.l wnptr(PC),a0 X moveq #0,d0 X move.w intuisig(PC),d1 X bset d1,d0 X move.w timersig(PC),d1 X bset d1,d0 X or.w #4096,d0 X or.l auxsig(PC),d0 X tst.l auxsig X bne.s 1$ X or.l trapsignal(PC),d0 X1$ CALL Wait,_SysBase(PC) X X move.l d0,tasksigs X X move.l trapsignal(PC),d1 X and.l d0,d1 X beq.s ctrl_c X tst.b gotguru X bne.s ctrl_c X move.b #1,gotguru X bsr showguru X clr.b gotguru X Xctrl_c moveq #12,d1 X bsr testsig X bne exit X X Xtimermsg move.w timersig(PC),d1 X bsr testsig X beq intuimsgs X tst.w repeat X bne.s 1$ X bsr showwhat X bra.s intuimsgs X1$ move.w repeatlen,d0 X lea repeatbuffer,a2 X lea dummy,a1 X move.w d0,d1 X2$ move.b (a2)+,(a1)+ X dbf d1,2$ X bsr cli X bsr starttimer X Xintuimsgs move.w intuisig(PC),d1 X bsr testsig X beq processnxtmsg Xnextimsg move.l wnptr(PC),a0 X move.l $56(a0),a0 X CALL GetMsg,_SysBase(PC) X tst.l d0 X beq processnxtmsg X move.l d0,intuimsg X X move.l d0,a0 X move.l 20(a0),d0 X X cmp.l #$200,d0 ;CloseWindow X bne.s 1$ X tst.b addlines X beq exitall X move.b #1,cbreak X bra intuiend X X1$ cmp.l #2,d0 ;ResizeWindow X bne.s 2$ X bsr setupscreen X bra intuiend X X2$ cmp.l #4,d0 ;refresh X bne.s 22$ X bsr putiline X bsr blastout X bsr UpdateIArea X bra intuiend X X22$ tst.b addlines X bne 3$ X cmp.l #$40,d0 ;gadgetup X bne.s 3$ X tst.w getanswer X bne.s 3$ X bsr replyintui X bsr stoptimer X bra instback X X3$ cmp.l #$400,d0 ;RawKey X bne notarawkey X move.w #$80,d0 X and.w 24(a0),d0 X bne intuiend X and.w #$7f,24(a0) X lea ievent,a1 X move.b #1,4(a1) X move.l 24(a0),6(a1) X move.w 26(a0),qualifier X move.l a1,a0 X lea outevent,a1 X moveq #20,d1 X suba.l a2,a2 X CALL RawKeyConvert,condev(PC) X tst.l d0 X beq intuiend X lea inputbuffer,a1 X lea outevent,a2 X move.w curpos(PC),d4 X moveq #0,d3 X tst.b addlines X bne 197$ X X sub.w #1,cmdcompflag X X cmp.b #$9b,0(a2) ;CSI X bne 110$ X X cmp.b #'?',1(a2) ;help X bne.s 399$ X tst.w getanswer X bne.s 399$ X bsr stoptimer X tst.w bottomin X bne.s 398$ X move.w #1,bottomin X clr.w ibufferlen X clr.w curpos X bsr UpdateIArea X398$ move.l #usetxt,d0 X bsr putnam X clr.l lastprinted X bsr blastout X bra.s 420$ X X399$ cmp.b #'C',1(a2) ;cursor right X bne.s 400$ X cmp.w ibufferlen(PC),d4 X bge.s 420$ X addq #1,d4 X421$ move.w d4,curpos X420$ bra 100$ X X400$ cmp.b #'D',1(a2) ;cursor left X bne.s 401$ X subq #1,d4 X bpl.s 421$ X bra.s 420$ X X401$ cmp.b #' ',1(a2) X bne.s 402$ X X cmp.b #'@',2(a2) ;shift right X bne.s 403$ X X404$ cmp.w ibufferlen(PC),d4 X bge.s 421$ X addq #1,d4 X cmp.b #' ',0(a1,d4) X bne.s 404$ X405$ cmp.w ibufferlen(PC),d4 X bge.s 421$ X addq #1,d4 X cmp.b #' ',0(a1,d4) X beq.s 405$ X bra.s 421$ X X403$ cmp.b #'A',2(a2) ;shift left X bne.s 420$ X406$ tst.w d4 X beq.s 421$ X subq #1,d4 X cmp.b #' ',0(a1,d4) X beq.s 406$ X407$ tst.w d4 X beq.s 421$ X subq #1,d4 X cmp.b #' ',0(a1,d4) X bne.s 407$ X addq #1,d4 X bra.s 421$ X X402$ cmp.b #'A',1(a2) ;cursor up X bne.s 408$ X tst.w bottomin X bne.s 480$ X tst.w curpos X bne.s 480$ X X clr.w curpos X clr.w ibufferlen X bsr UpdateIArea X bsr clrcursor X move.w edline(PC),d3 X ext.l d3 X tst.w d3 X beq.s 481$ X subq #1,d3 X cmp.l firstline(PC),d3 X bge.s 481$ X move.l d3,-(a7) X subq.l #1,firstline X bsr blastout X move.l (a7)+,d3 X481$ move.w d3,edline X bsr getcurpos X bsr putcursor X bra intuiend X480$ move.l history(PC),a0 X tst.l 0(a0) X beq.s 423$ X move.l curhist(PC),a1 X cmp.l a0,a1 X beq.s 409$ X move.l 4(a1),d0 X move.l d0,curhist X409$ move.l a1,gothline X bsr copyhistory X423$ bra 100$ X X408$ cmp.b #'B',1(a2) ;cursor down X bne 410$ X tst.w bottomin X bne.s 414$ X tst.w curpos X bne.s 414$ X X clr.w curpos X clr.w ibufferlen X bsr UpdateIArea X bsr clrcursor X move.w edline(PC),d3 X ext.l d3 X move.l numlines(PC),d4 X subq #1,d4 X cmp.l d4,d3 X beq.s 490$ X move.l firstline(PC),d2 X add.w rows(PC),d2 X subq #1,d2 X addq #1,d3 X cmp.w d2,d3 X ble.s 490$ X move.l d3,-(a7) X addq.l #1,firstline X bsr blastout X move.l (a7)+,d3 X490$ bra 481$ X414$ move.l curhist(PC),d0 X beq.s 423$ X move.l d0,a1 X move.l 0(a1),a1 X tst.l 0(a1) X bne.s 411$ X clr.l gothline X clr.w curpos X clr.w ibufferlen X bra 423$ X411$ move.l a1,curhist X bra 409$ X X410$ cmp.b #'T',1(a2) ;shift up X bne.s 412$ X tst.w hnum X beq 423$ X move.l history(PC),a1 X move.l a1,curhist X bra 409$ X X412$ cmp.b #'S',1(a2) ;shift down X bne.s 440$ X tst.w hnum X beq 423$ X move.l history+8,curhist X bra.s 414$ X X440$ cmp.b #'0',1(a2) ;function keys X bmi 423$ X cmp.b #'9',1(a2) X bgt 423$ X lea 1(a2),a0 X bsr getnum X lea fkeys(PC),a0 X441$ move.l 0(a0),a0 X tst.l 0(a0) X beq 100$ X cmp.b 8(a0),d2 X bne.s 441$ X X move.b 9(a0),d5 X ext.w d5 X subq #1,d5 X lea 10(a0),a0 X move.w curpos(PC),d4 X lea inputbuffer,a2 X moveq #0,d3 X lea 0(a2,d4),a2 X445$ move.b (a0)+,d0 X cmp.b #'^',d0 X bne.s 442$ X moveq #1,d3 X bra.s 443$ X442$ cmp.b #'_',d0 X bne.s 444$ X move.b #' ',d0 X444$ move.b d0,(a2)+ X addq #1,d4 X443$ dbf d5,445$ X move.w d4,curpos X cmp.w ibufferlen(PC),d4 X ble.s 446$ X move.w d4,ibufferlen X446$ tst d3 X beq 100$ X bra got_fkey X X110$ moveq #0,d3 X101$ move.w curpos(PC),d4 X tst d0 X beq 100$ X cmp.b #13,0(a2,d3) ;return END_OF_FILE if test 53365 -ne `wc -c <'Xoper.a.ab'`; then echo shar: \"'Xoper.a.ab'\" unpacked with wrong size! fi # end of 'Xoper.a.ab' fi echo shar: End of archive 3 \(of 4\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 4 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 4 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to: amiga@cs.odu.edu or amiga@xanth.cs.odu.edu ( obsolescent mailers may need this address ) or ...!uunet!xanth!amiga ( very obsolescent mailers need this address ) Comments, questions, and suggestions s should be addressed to ``amiga-request'' (only use ``amiga'' for submissions) at the above addresses.