home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 3
/
CDPDIII.bin
/
pd
/
utilities
/
monitors
/
xoper
/
xoper.a
< prev
next >
Wrap
Text File
|
1991-12-15
|
197KB
|
8,437 lines
******************************************
* *
* Xoper 2.3 Copyright (C) Werner Gunther *
* (68881 code by Lothar English) *
* *
******************************************
* Written for the A68K V2.6 Assembler *
* by Charlie Gibbs and *
* Brian R. Anderson *
* *
* Do not use Smallcode/Smalldata when *
* linking *
******************************************
;DEBUG SET 1
XREF _LVOSwitch
XREF _LVOAddTask
XREF _LVORemTask
XREF _LVOFindTask
XDEF _SysBase
sysbase equ 4
mysignal equ 17
CALL MACRO
xref _LVO\1
move.l \2,a6
jsr _LVO\1(a6)
ENDM
RECALL MACRO
xref _LVO\1
jsr _LVO\1(a6)
ENDM
LIBCALL MACRO
xref _\1
jsr _\1
ENDM
ADDCMD MACRO
cmdnum set cmdnum+1
dc.b \1,0
ENDM
;Program startup. If called from DOS we
;use segment splitting to detach
;from our DOS-task.
start lea dataarea,a4
moveq #3,d0
lea dummyinput(a4),a1
getparm move.b (a0)+,(a1)+
dbf d0,getparm
move.b #$0a,in
lea conname(PC),a1
move.l sysbase,a0
cmp.w #36,20(a0)
blt.s 2$
addq.b #1,post_V34(a4)
2$ lea 350(a0),a0
CALL FindName,sysbase
move.l d0,condev(a4)
lea dosname(PC),a1
move.l sysbase,a0
lea 378(a0),a0
move.l a0,-(a7)
CALL FindName,sysbase
move.l d0,dosbase(a4)
move.l 0(a7),a0
lea gfxname(PC),a1
RECALL FindName
move.l d0,gfxbase(a4)
move.l (a7)+,a0
lea intuiname(PC),a1
RECALL FindName
move.l d0,intuibase(a4)
move.l d0,a0
move.l $38(a0),a0
move.w 12(a0),d0
sub.w #550,d0
move.w d0,window_l(a4)
cmp.l #'kill',dummyinput(a4)
bne.s nokill
; This code tries to remove Xoper from the System
; in case Xoper 'freezes' or crashes.
; It works as follows: Xoper leaves the address of its cleanup
; routine in the UserData field of its Task structure. EXEC's
; context-restore code leaves the current PC of a task in the
; first longword of the tasks stack. All we have to do is to
; copy the address of Xoper's cleanup routine to its stack and
; to rescedule Xoper (using Signal() in this case).
lea newname(a4),a1
move.l sysbase,a6
jsr _LVOFindTask(a6)
tst.l d0
beq.s 1$
move.l d0,a1
move.l $36(a1),d0 ;TC_SPReg: Xoper's stackptr
jsr getstackptr
move.l d0,a0
move.l $58(a1),d0 ;TC_UserData: address of the Exit() routine
move.l d0,0(a0) ;change Xoper's PC (first value on stack)
moveq #-1,d0
move.l sysbase,a6
jsr _LVOSignal(a6) ;force Xoper to be dispatched
1$ moveq #0,d0
rts
nokill move.l sysbase,a6
move.l 276(a6),a5
tst.l $ac(a5)
bne.s notwb
lea $5c(a5),a0
RECALL WaitPort
lea $5c(a5),a0
RECALL GetMsg
move.l d0,wbmsg(a4)
move.w #$740a,in
notwb:
IFND DEBUG
lea xopcon(a4),a1
RECALL FindPort
tst.l d0
bne oops
ENDC
tst.l wbmsg(a4)
beq.s fromdos
move.l 276(a6),a0 ;ExecBase->ThisTask
move.l #newname,10(a0)
jmp mainprg
fromdos:
IFND DEBUG
cmp.w #'-b',dummyinput(a4)
bne.s stt1
CALL Output,dosbase(a4)
move.l d0,-(a7)
move.l #dataarea+windowname,d2
move.l d0,d1
moveq.l #newname-windowname-1,d3
CALL Write,dosbase(a4)
move.l #cr+dataarea,d2
move.l (a7)+,d1
moveq.l #1,d3
RECALL Write
stt1 lea start(PC),a1
move.l -4(a1),d3
move.l d3,myseg(a4)
move.l #mainprg,d3
subq #4,d3
lsr.l #2,d3
clr.l -4(a1)
move.l 4,a0
move.l 276(a0),a0
move.l 152(a0),d1
CALL DupLock,dosbase(a4)
move.l d0,-(a7)
CALL Forbid,sysbase
move.l #newname+dataarea,d1
clr.l d2
move.l #3500,d4
CALL CreateProc,dosbase(a4)
move.l d0,a0
move.l (a7)+,d0
move.l d0,60(a0)
CALL Permit,sysbase
moveq #0,d0
rts
oops CALL Forbid,sysbase
lea newname(a4),a1
move.l sysbase,a0
lea 406(a0),a0
RECALL FindName
tst.l d0
bne.s 1$
lea newname(a4),a1
move.l sysbase,a0
lea 420(a0),a0
RECALL FindName
tst.l d0
beq.s 2$
1$ move.l d0,a1
move.l #(1<<mysignal),d0
RECALL Signal
2$ RECALL Permit
move.l wbmsg(a4),d0
beq.s leave
move.l d0,a1
RECALL ReplyMsg
moveq #0,d0
leave rts
dosname dc.b 'dos.library',0
intuiname dc.b 'intuition.library',0
gfxname dc.b 'graphics.library',0
conname dc.b 'console.device',0
EVEN
main CODE xoper
ENDC
mainprg lea dataarea,a4
tst.b post_V34(a4)
beq.s 1$
jsr reverseimage
1$ move.l sysbase,a0
move.l a0,SysBase(a4)
move.l a7,realstack(a4)
move.l 276(a0),a0 ;ExecBase->ThisTask
move.l a0,mytask(a4)
move.l 50(a0),oldproctrap ;original AmigaDos Trap-Handler
move.l #exitall,88(a0) ;leave a message for 'KillXoper'
move.l #newname+dataarea,10(a0)
pea 0
pea xopcon(a4)
LIBCALL CreatePort
addq #8,a7
move.l d0,replyport(a4)
pea 0
pea 0
LIBCALL CreatePort
addq #8,a7
move.l d0,timerport(a4)
lea timerio,a1
move.l d0,14(a1)
move.l d0,a2
move.b 15(a2),d0
ext.w d0
move.w d0,timersig(a4)
lea timernam(a4),a0
moveq #0,d1
moveq #1,d0
CALL OpenDevice,SysBase(a4) ;open 'timer.device'
lea timerio,a0
move.l 20(a0),timerbase(a4)
;install a counter to determine the amount of CPU-time each
;Task uses.
bsr starttasktimer
move.l SysBase(a4),a1
move.l #_LVOSwitch,a0
move.l 2(a1,a0.w),oldswitch
move.l #myswitch,d0
CALL SetFunction,SysBase(a4)
move.l #_LVOAddTask,a0
move.l 2(a6,a0.w),OldAddTask
move.l a6,a1
move.l #myaddtask,d0
RECALL SetFunction
;install a counter for PORT-Interrupts
lea IOCounter(a4),a1
moveq #3,d0
CALL AddIntServer,SysBase(a4)
pea 256 ;stack
pea killidle ;CODE
pea -127 ;pri
pea kidlename(a4) ;name
LIBCALL CreateTask
lea 16(a7),a7
move.l d0,idletask(a4)
tst.b post_V34(a4)
beq.s 12$
lea dummy,a0
move.l timerbase(a4),a6
jsr -$3c(a6)
lsr.l #8,d0
move.l d0,timerticks(a4)
move.l dummy+4,lasttime
bra.s 11$
12$ move.l #3906,timerticks(a4)
pea 0
pea 0
LIBCALL CreatePort
addq #8,a7
lea sampleio(a4),a1
move.l d0,14(a1)
lea timernam(a4),a0
moveq #0,d1
move.l d1,d0
CALL OpenDevice,SysBase(a4) ;open 'timer.device'
lea sampleio(a4),a1
move.l #3599999,32(a1)
move.w #9,28(a1)
CALL SendIO,SysBase(a4)
moveq #mysignal,d0
CALL AllocSignal,SysBase(a4)
11$ jsr gettdtasks
;Attempt to open a startup script
move.l mytask(a4),a5 ;disable the 'please insert'
move.l 184(a5),-(a7)
move.l #-1,184(a5) ;requester
move.l #dataarea+startupname+2,d1 ;'Xoper.Startup'
move.l #1005,d2
CALL Open,dosbase(a4)
tst.l d0
bne.s 7$
move.l #startupname+dataarea,d1 ;'S:Xoper.Startup'
move.l #1005,d2
CALL Open,dosbase(a4)
7$ move.w #$00ff,16(a5)
move.l (a7)+,184(a5) ;reenable the requester
move.l d0,infile(a4)
beq.s nostartup
move.b #1,fromfile(a4)
8$ lea dummy,a5
moveq #-1,d5
5$ addq.l #1,d5
move.l infile(a4),d1
move.l a5,d2
add.l d5,d2
moveq.l #1,d3
CALL Read,dosbase(a4)
tst.l d0
bgt.s 10$
move.l infile(a4),d1
CALL Close,dosbase(a4)
clr.l infile(a4)
tst d5
beq.s endstartup
bra.s 9$
10$ cmp.b #10,0(a5,d5)
beq.s 9$
cmp.b #13,0(a5,d5)
bne.s 5$
9$ move.l d5,d0
addq #1,d0
bsr cli ;execute the script as if typed in
tst.l infile(a4)
bne.s 8$
endstartup clr.b fromfile(a4)
nostartup
tst.l wbmsg(a4)
bne.s noin
cmp.b #10,dummyinput(a4)
beq.s noin
cmp.w #'-b',dummyinput(a4) ;requested as a background task ?
beq.s noin
move.l dummyinput(a4),in
move.b #10,in+4
bra.s nostartup2
noin cmp.b #10,in
beq.s default
tst.b in
bne.s nostartup2
default move.w #$740a,in ;couldn't find defaults, defaults to
;tasks
nostartup2 cmp.w #'-b',dummyinput(a4)
beq instback
;This code just opens a Window. Position
;and size are taken from window_l,window_t,
;window_w,window_h.
restart tst.b ownscreen(a4)
beq.s 1$
bsr createscreen
bra.s 2$
1$ bsr setupwindow
2$ move.l mytask(a4),a0
clr.l 26(a0) ;clear 'spurious' signals
clr.l ptr(a4)
tst.b gotguru(a4)
beq.s 3$
bsr showguru
clr.b gotguru(a4)
3$ bra processmsgs
;show a list. The string entered from keyboard is stored
;in 'in'. Every character is interpreted as one command
;i.e. 'rip' means 'resources'+'interrupts'+'ports'.
;search the command to be executed. If none is found,
;show a help message
showwhat tst.b fromfile(a4)
bne endshow
move.w cmdptr(a4),d7
input lea in,a0
move.b 0(a0,d7.w),d0
beq endshow
addq.b #1,d7
cmpi.b #' ',d0
bne.s 1$
bsr testifend
beq endshow
move.w d2,cmdptr(a4)
bra notfinished
1$ cmpi.b #10,d0
beq endshow
or.b #32,d0
cmpi.b #'q',d0
beq exit
lea params(a4),a0
moveq #0,d1
i1 cmp.b 0(a0,d1),d0
beq.s foundp
addq.b #1,d1
cmpi.b #parmnum,d1
bne.s i1
move.w #usetxt,d0
move.b #1,mnflag
bsr putnamw
clr.b mnflag(a4)
bra endshow
foundp lsl.b #2,d1
lea subs(PC),a0
move.b #1,mnflag(a4)
jsr 0(a0,d1)
clr.b mnflag(a4)
bsr testifend
beq input
bsr newline
bra input
testifend lea in,a0
lea 0(a0,d7),a0
move.w d7,d2
2$ move.b (a0)+,d0
beq.s 1$
cmpi.b #' ',d0
bne.s 3$
addq #1,d2
bra.s 2$
3$ cmpi.b #10,d0
1$ rts
endshow tst.b fromfile(a4)
bne.s nomore
clr.w cmdptr
notfinished bsr starttimer
nomore tst.b fromfile(a4)
bne.s 1$
clr.l lastprinted(a4)
bsr blastout
1$ rts
;get the string from inputbuffer; search and execute
;the command, if any.
cli lea dummy,a0
subq #1,d0
cl2 subq #1,d0
bmi.s cl1
cmp.b #' ',0(a0,d0)
beq.s cl2
cl1 addq #1,d0
move.b #10,0(a0,d0)
bsr kllblnks
cmpi.b #10,0(a0)
beq showwhat
cmpi.b #';',0(a0)
beq nomore
bsr findcmd
tst.l d2
bpl.s okcmd
bsr findalias
tst.l d2
bmi.s nm1
okcmd clr.b procnum(a4)
adda.w d1,a0
bsr kllblnks
lsl #2,d2
lea cmdaddr(PC),a1
jsr 0(a1,d2)
bra nomore
nm1 lea in,a1
lea buffer,a2
nm2 move.b (a1)+,(a2)+
cmp.b #10,-1(a1)
bne.s nm2
lea in,a1
nm0 move.b (a0)+,(a1)+
cmp.b #10,-1(a1)
bne.s nm0
lea dummy,a2
lea buffer,a1
nm3 move.b (a1)+,(a2)+
cmp.b #10,-1(a1)
bne.s nm3
clr.w cmdptr(a4)
bra showwhat
findcmd bsr strbuf
move.l a0,a5
lea commds(a4),a2
moveq #0,d2
1$ lea buffer,a0
move.l a2,a1
bsr strcmp
beq 3$
2$ tst.b (a2)+
bne.s 2$
addq #1,d2
cmp.w #cmdnum,d2
bne.s 1$
moveq #-1,d2
3$ move.l a5,a0
rts
findalias move.l a0,a5
move.l aliaslist(a4),d4
1$ beq.s 3$
move.l d4,a3
lea buffer,a0
lea 5(a3),a1
move.b 4(a3),d2
ext.w d2
ext.l d2
bsr strcmp
beq 4$
move.l 0(a3),d4
bra.s 1$
3$ moveq #-1,d2
4$ move.l a5,a0
rts
subs bra showtask
bra showaddr
bra showdevs
bra showlibs
bra showres
bra showresi
bra showmem
bra showprt
bra showint
bra stack
bra clicomm
bra tasktime
bra semaphores
cmdaddr bra settime
bra taskpri
bra info
bra pri
bra flush
bra freeze
bra warm
bra signal
bra break
bra alert
bra lastalert
bra instback
bra stopall
bra clear
bra cancel
bra taskports
bra hunks
bra devices
bra openlib
bra closelib
bra currentdir
bra cd
bra mypri
bra openfiles
bra locks
bra unlock
bra screens
bra windows
bra closescreen
bra closewindow
bra fonts
bra windowfonts
bra lockdrive
bra freedrive
bra capture
bra clrcold
bra clrcool
bra clrwarm
bra snoop
bra usage
bra inphand
bra nohead
bra sort
bra hide
bra hidden
bra setwindow
bra cancel
bra iconifyoff
bra historylines
bra historylength
bra showhistory
bra repeatcmd
bra remresident
bra saveoutput
bra killhistory
bra iconbackdrp
bra setfont
bra trapguru
bra outputlines
bra usescreen
bra usewindow
bra grabtimerio
bra dchange
bra alias
bra remnode
bra setfkey
bra clicmd
bra taskinfo
bra coldreboot
bra reboot
bra zerotimer
bra propgadoff
bra iconpos
bra remport
bra remintserver
bra frags
bra snoopfiles
bra snoop
bra tracelocks
;------ Task-Structures-----
tasktime move.b #-1,tasktyp(a4)
bra.s startask
showaddr clr.b tasktyp(a4)
bra.s startask
showtask move.b #1,tasktyp(a4)
startask bsr getdevhan
tst.b headon(a4)
beq noheader1
move.w #infoh1,d0
bsr putstrw
move.l SysBase(a4),a6
move.w #cpu3,d0
btst #2,297(a6) ;mc 68030 ?
bne.s cpupr
subq.w #cpu3-cpu2,d0
btst #1,297(a6) ;mc 68020 ?
bne.s cpupr
subq.w #cpu2-cpu1,d0
btst #0,297(a6) ;mc 68010 ?
bne.s cpupr
subq.w #cpu1-cpu0,d0 ;mc 68000
cpupr bsr putstrw
move.l d0,d1
move.w #cpu5,d0
btst #5,297(a6) ;mc 68882 ?
bne.s fpupr
move.l d1,d0
btst #4,297(a6) ;mc 68881 ?
beq.s no881
subq.w #cpu5-cpu4,d0
fpupr bsr putstrw
no881 moveq #20,d1
bsr tab
move.w #infoh3,d0
bsr putstrw
noheader1 move.l SysBase(a4),a6
moveq #1,d5
bsr getaskdat
move.l a5,savedat(a4)
bsr getstdio
moveq #0,d4
move.l d4,d3
move.l d4,d1
lea usedtime,a0
move.b entries(a4),d1
subq #1,d1
move.l idletask(a4),d2
1$ lea -16(a5),a5
move.l 12(a5),d5
add.l d5,d4
move.l 0(a5),d0
cmp.l d0,d2
bne.s 2$
move.l d5,d3
2$ bsr gettimeentry
add.l d5,0(a0,d0.w)
dbf.s d1,1$
move.l d4,maxdisp(a4)
sub.l d3,d4
move.l d4,dispatches(a4)
tst.b headon(a4)
beq.s noheader2
move.l maxdisp(a4),d0
move.l dispatches(a4),d3
bsr prcent
bsr newline
move.w #infoh2,d0
bsr putstrw
noheader2 move.l SysBase(a4),a0
move.l 284(a0),d0
move.l oldswitches(a4),d1
move.l d0,oldswitches(a4)
sub.l d1,d0
tst.b headon(a4)
beq noheader3
mulu #100,d0
move.l d0,-(a7)
lea secs(a4),a0
lea mics(a4),a1
CALL CurrentTime,intuibase(a4)
move.l secs(a4),d3
lsl.l #1,d3
move.l d3,d1
lsl.l #2,d3
add.l d1,d3
move.l mics(a4),d0
move.l #100000,d1
bsr div
add.l d0,d3
move.l time10(a4),d1
move.l d3,time10(a4)
sub.l d1,d3
move.l (a7)+,d0
move.l d3,-(a7)
move.l d3,d1
bsr div
moveq #1,d5
bsr putfrac
moveq #20,d1
bsr tab
move.w #infoh7,d0
bsr putstrw
move.l iocount(a4),d0
clr.l iocount(a4)
mulu #100,d0
move.l (a7)+,d3
move.l d3,d1
bsr div
moveq #1,d5
bsr putfrac
bsr newline
bsr newline
noheader3 lea t4header(a4),a0
tst.b tasktyp(a4)
bmi.s phedder
lea theader(a4),a0
tst.b tasktyp(a4)
bne.s phedder
lea t2header(a4),a0
move.l SysBase(a4),a6
btst #4,297(a6) ;AttnFlags FPU ?
bne.s phedder
lea t3header(a4),a0
phedder bsr puthead
move.l savedat(a4),a5
pt1 tst.b entries(a4)
beq pt2
lea -16(a5),a5
bsr hideit
tst d0
beq ptend
move.l idletask(a4),d0
cmp.l 0(a5),d0
beq ptend
move.l 0(a5),a3
move.l a3,d0
move.l d0,node(a4) ;ID = task address
bsr hexa
tst.b tasktyp(a4)
ble.s pt12
moveq #0,d0
move.b 8(a3),d0
bsr gettype
pt12 moveq #0,d0
move.b 9(a5),d0
subq.b #1,d0
mulu #9,d0
move.w #status,d1
add.w d1,d0
bsr putstrw ;state
tst.b tasktyp(a4)
beq pt345
bpl pt13
move.l 0(a5),d0
bsr gettimeentry
lea taskstamps,a0
lea 0(a0,d0.w),a0
move.l secs(a4),d0
sub.l 0(a0),d0
bsr putstamp
bsr putblank
move.l usedtime-taskstamps(a0),d0
move.l timerticks(a4),d1
bsr div
bsr putstamp
moveq #'.',d0
bsr putchar
move.l d1,d0
move.l timerticks(a4),d1
addq #5,d1
divu #10,d1
divu d1,d0
or.b #'0',d0
bsr putchar
bsr putblank
bra pt346
pt345 move.l 18(a3),d0 ;SigAlloc
bsr hexa
move.w #longnix,d0
cmp.b #4,9(a5) ;tc_state waiting ?
beq.s pt14
bsr putstrw
bra.s pt15
pt14 move.l 22(a3),d0 ;SigWait
bsr hexa
pt15 move.l 26(a3),d0 ;SigRecvd
bsr hexa
move.w #nofpu,d1 ;keine fpu annehmen
move.l SysBase(a4),a6
btst #4,297(a6) ;AttnFlags FPU ?
beq.s prt154
move.w #nullstate,d1 ;fpu im null state annehmen
prt154 move.l #*,d0
cmp.b #2,9(a5) ;tc_state running ?
beq.s pt16 ;kann nur xoper selbst sein
moveq #0,d0 ;0(sp) -> pc wenn keine fpu
move.l 54(a3),a1 ;tc_SPReg
btst #4,297(a6) ;AttnFlags FPU
beq.s prt151 ;keine FPU
tst.b (a1) ;NULL frame ?
beq.s prt150 ;ja
move.w (a1),d0 ;frame flag / format word
lea 110(a1),a1 ;offset fuer fpu regs
cmp.w #-1,d0
beq.s prt153
lea 12(a1),a1 ;3 longs mehr
prt153 moveq #0,d0
move.b 1(a1),d0 ;frame size
move.l 4(a1,d0),d0 ;pc
move.w #idle,d1
cmp.b #$18,1(a1) ;mc 68881 idle ?
beq.s pt16
addq.w #busy-idle,d1
cmp.b #$b4,1(a1) ;mc 68881 busy ?
beq.s pt16
prt152 addq.l #weissnicht-busy,d1 ;vielleicht mc 68882 ??
bra.s pt16
prt150 moveq #4,d0 ;offset NULL frame
prt151 move.l 0(a1,d0),d0 ;n(sp) -> pc
pt16 bsr hexa
move.l SysBase(a4),a6
btst #4,297(a6) ;AttnFlags FPU ?
beq.s pt4
move.w d1,d0 ;fpu state
bsr putstrw
bra.s pt4
pt13 move.b 10(a5),d3
bsr plusmins
move.l dispatches(a4),d0
tst.b usageflag(a4)
beq.s pt37
move.l maxdisp(a4),d0
pt37 move.l 12(a5),d3
bsr prcent
pt346 cmpi.b #13,8(a5)
bne.s noproc
tst.l 172(a3)
beq.s noproc
move.b 11(a5),d3
bsr bytedec
bra.s pt4
noproc move.w #nix,d0
bsr putstrw
pt4 bsr gettaskname
tst.b tinfo(a4)
beq pt223
tst.b cliexec(a4) ;display 'real' taskname if
beq.s 10$ ;it is a CLI
bsr putblank
move.l 4(a5),d0
bsr putstr
10$ lea tdtasks(a4),a1 ;check if the task is a trackdisk.device
moveq #3,d3
1$ cmp.l (a1)+,a3
dbeq.s d3,1$
bne.s pt224
eor.l #'0'+3,d3 ;print unit#
move.b d3,unitmsg+8(a4)
move.w #unitmsg,d0
bsr putstrw
pt224 moveq #0,d3 ;see if it is a device handler
lea buffer+2400,a2
lea 200(a2),a1
1$ move.l (a2)+,d0
beq.s pt222
move.l (a1)+,d2
cmp.l 0(a5),d0
bne.s 1$
2$ move.l #' {',d0 ;print dos devicename
bsr putlongascii
move.l d2,d0
bsr putbcpl
move.l #':}',d0
bsr putlongascii
pt222 lea buffer+2160,a1 ;is it a device handler for some
lea 160(a1),a2 ;CLI input/output ?
moveq #0,d5
3$ move.l (a1)+,d0
beq.s 4$
move.w (a2)+,d2
cmp.l 0(a5),d0
bne.s 3$
tst d5
bne.s 5$
move.l #' (',d0 ;print CLI#
bsr putlongascii
bra.s 6$
5$ move.l #'& ',d0
bsr putlongascii
6$ moveq #1,d5
moveq #'<',d0
tst.w d2
bmi.s 7$
moveq #'>',d0
7$ bsr putchar
move.l #'CLI ',d0
bsr putlongascii
moveq #0,d0
move.b d2,d0
moveq #0,d3
bsr longdec
bra.s 3$
4$ tst d5
beq.s pt223
subq.l #1,ptr(a4)
moveq #')',d0
bsr putchar
pt223 bsr newline
ptend subq.b #1,entries(a4)
bra pt1
pt2 rts
putlist move.l 0(a3),a3
tst.l 0(a3)
beq.s endlist
bsr putdata
bra.s putlist
endlist rts
putdata move.l a3,0(a5)
move.l 10(a3),4(a5) ;task->ln_Name
move.b 8(a3),8(a5) ;task->ln_Type
move.b 15(a3),9(a5) ;task->tc_State
move.b 9(a3),10(a5) ;task->ln_Pri
move.b 143(a3),11(a5) ;Process->pr_Tasknum
clr.l 12(a5)
lea cputime,a0
move.l tasksnum(a4),d1
subq #1,d1
bmi.s pua1
pua3 cmp.l (a0)+,a3
dbeq d1,pua3
tst d1
bmi.s pua1
pua2 move.l 508(a0),d1
move.l d1,12(a5)
pua1 lea 16(a5),a5
addq #1,d5
rts
gettype and.l #$f,d0
mulu #11,d0
add.w #type,d0
bra putstrw
getaskdat move.l d5,-(a7)
bsr.s getaskdat2
move.b d5,entries(a4)
move.l (a7)+,d5
beq.s 1$
clr.l tasksnum(a4)
1$ moveq #16,d2
lea -32(a5),a2
bsr sortlist
rts
getaskdat2 lea buffer,a5
getaskdat3 moveq #0,d5
move.w #$4000,$dff09a
lea stplist(a4),a3
bsr putlist
move.l SysBase(a4),a3
lea 420(a3),a3 ;SysBase->TaskWait
bsr putlist
move.l SysBase(a4),a3
lea 406(a3),a3 ;SysBase->TaskReady
bsr putlist
move.l SysBase(a4),a3
move.l 276(a3),a3 ;SysBase->ThisTask
bsr putdata
1$ move.w #-$4000,$dff09a
rts
getaskdat4 move.l #2800,d0
moveq #0,d1
CALL AllocMem,_SysBase(PC)
moveq #0,d5
tst.l d0
beq.s 1$
move.l d0,-(a7)
move.l d0,a5
bsr.s getaskdat3
move.l (a7)+,d0
1$ rts
freetaskbuf move.l a5,a1
move.l #2800,d0
CALL FreeMem,_SysBase(PC)
rts
cleanuptimers
bsr.s getaskdat4
move.l d0,a6
moveq #0,d1
move.l d1,d4
lea taskstampid,a1
1$ lea -16(a5),a5
move.l 0(a5),d0
bsr.s gettimeentry
lea taskstampid,a3
lea 0(a3,d0.w),a3
move.l 0(a3),d2
move.l 0(a1),0(a3)
move.l d2,(a1)
move.l taskstamps-taskstampid(a3),d2
move.l taskstamps-taskstampid(a1),taskstamps-taskstampid(a3)
move.l d2,taskstamps-taskstampid(a1)
move.l usedtime-taskstampid(a3),d2
move.l usedtime-taskstampid(a1),usedtime-taskstampid(a3)
move.l d2,usedtime-taskstampid(a1)
addq.l #4,a1
addq #1,d1
subq.b #1,d5
bne.s 1$
move.w d1,numtaskstimed+dataarea
bsr freetaskbuf
rts
gettimeentry
movem.l d1/a0,-(a7)
lea taskstampid,a0
move.w numtaskstimed(a4),d1
subq #1,d1
1$ cmp.l (a0)+,d0
dbeq.s d1,1$
move.l a0,d0
sub.l #taskstampid+4,d0
movem.l (a7)+,d1/a0
rts
sortlist tst.b sorton(a4)
beq.s sort5
lea buffer,a1
sort1 lea 0(a1,d2),a3
sort2 move.l 0(a1),d1
cmp.l 0(a3),d1
bge.s sort3
move.l d2,d1
subq #1,d1
sort4 move.b 0(a3,d1),d0
move.b 0(a1,d1),0(a3,d1)
move.b d0,0(a1,d1)
dbf d1,sort4
sort3 lea 0(a3,d2),a3
cmp.l a2,a3
ble.s sort2
lea 0(a1,d2),a1
cmp.l a2,a1
bne.s sort1
sort5 rts
prcent lsl.l #1,d3
move.l d3,d1
lsl.l #2,d3
add.l d1,d3
lsl.l #2,d3
move.l d3,d1
lsl.l #3,d3
move.l d3,d2
lsl.l #1,d3
add.l d2,d3
add.l d1,d3
move.l d0,d1
move.l d3,d0
bsr div
moveq #0,d5
bsr putfrac
move.w #infoh4,d0
bra putstrw
putfrac divu #10,d0
move d0,d3
swap d0
move d0,d1
tst d5
bne.s 1$
cmp.w #100,d3
ble.s 1$
move.w #whatsthis,d0
bra putstrw
1$ bsr bytedec
lea out,a0
move.b #'.',-1(a0,d0)
or.b #'0',d1
move d1,d0
bra putchar
hideit tst.b hideoff(a4)
beq.s pt73
pt75 moveq #1,d0
rts
pt73 lea hidestart(a4),a3
move.l 4(a5),a0
pt74 tst.l 0(a3)
beq.s pt75
move.l 0(a3),a3
lea 4(a3),a1
bsr strcmp
tst d0
beq hideend
bra.s pt74
hideend rts
getaskname2 movem.l a3/a5,-(a7)
link a2,#-10
move.l a7,a5
move.l d0,a3
tst.l d0
bne.s 2$
bsr putstr
bra.s 1$
2$ move.b 8(a3),8(a5)
move.l 10(a3),4(a5)
bsr gettaskname
1$ unlk a2
movem.l (a7)+,a3/a5
rts
gettaskname movem.l a1-a2,-(a7)
clr.b cliexec(a4)
tst.b cmdcli(a4)
beq.s 2$
cmpi.b #13,8(a5)
bne.s 2$
CALL Forbid,SysBase(a4)
tst.l 140(a3) ;pr_TaskNum
beq.s 1$
move.l 172(a3),d0 ;pr_CLI
beq.s 1$
move.l d0,a1
adda.l a1,a1
adda.l a1,a1
tst.l 60(a1) ;cli_Module
beq.s 1$
move.l 16(a1),a2
adda.l a2,a2
adda.l a2,a2
tst.b 0(a2)
beq.s 1$
move.w #openbrak,d0
bsr putstrw
move.l 16(a1),d0 ;cli_CommandName
CALL Permit,SysBase(a4)
bsr putbcpl
bset.b #1,cliexec(a4)
move.w #closebrak,d0
movem.l (a7)+,a1-a2
bra putstrw
1$ CALL Permit,SysBase(a4)
2$ move.l 4(a5),d0
movem.l (a7)+,a1-a2
bra putstr
getstdio tst.b tinfo(a4)
beq 4$
move.l a5,-(a7)
lea buffer+2160,a0
lea 160(a0),a1
moveq #40,d4
moveq #0,d3
move.b entries(a4),d3
subq #1,d3
3$ lea -16(a5),a5
cmpi.b #13,8(a5)
bne.s 1$
move.l 0(a5),a3
CALL Forbid,SysBase(a4)
move.b 143(a3),d2 ;pr_TaskNum
ext.w d2
beq.s 2$
move.l 172(a3),d0 ;pr_CLI
beq.s 2$
move.l 160(a3),d0 ;pr_COS
beq.s 2$
bsr.s 5$
or.w #$8000,d2
2$ move.l 156(a3),d0
beq.s 6$
bsr 5$
6$ RECALL Permit
tst d4
ble.s 7$
1$ dbf d3,3$
7$ clr.l (a0)+
move.l (a7)+,a5
4$ rts
5$ lsl.l #2,d0
move.l d0,a2
move.l 8(a2),d0 ;fh_Type
ble.s 8$ ;negative = plain file
move.l d0,a2
move.l 16(a2),d0 ;mp_SigTask
beq.s 8$
move.l d0,(a0)+
move.w d2,(a1)+
subq #1,d4
8$ rts
getdevhan tst.b tinfo(a4)
beq.s 4$
move.l a3,-(a7)
bsr devinfo
moveq #49,d3
lea buffer+2400,a2
lea 200(a2),a3
1$ adda.l a1,a1
adda.l a1,a1
tst.l 4(a1)
bne.s 3$
move.l 8(a1),d0
beq.s 3$
sub.l #92,d0
move.l d0,(a2)+
move.l 40(a1),(a3)+
subq #1,d3
beq.s 2$
3$ move.l 0(a1),d0
beq.s 2$
move.l d0,a1
bra.s 1$
2$ clr.l (a2)+
move.l (a7)+,a3
4$ rts
*-------- mem-hunks ------------
showmem lea mheader(a4),a0
bsr puthead
move.l SysBase(a4),a5
lea 322(a5),a5 ;SysBase->MemList
moveq #0,d5
mem1 move.l 0(a5),a5 ;MemList->ln_Next
tst.l 0(a5)
beq.s mem2
move.l 20(a5),d0 ;MemHeader->mh_Lower
bsr hexa
move.l 24(a5),d0 ;MemHeader->mh_Upper
bsr hexa
move.l 28(a5),d0 ;MemHeader->mh_Free
add.l d0,d5
moveq #1,d3
bsr longdec
move.b 15(a5),d3 ;MemHeader->mh_Attributes
bsr bytedec
move.b 9(a5),d3 ;MemHeader->ln_pri
bsr plusmins
move.l 10(a5),d0 ;MemHeader->ln_Name
move.l a5,node(a4)
bsr putnam
bra.s mem1
mem2 move.w #infoh6,d0
bsr putstrw
moveq #19,d1
bsr tab
moveq #0,d3
move.l d5,d0
bsr longdec
newline move.w #cr,d0
bra putstrw
frags move.l SysBase(a4),a5
lea 322(a5),a5 ;SysBase->MemList
1$ move.l 0(a5),a5 ;MemList->ln_Next
tst.l 0(a5)
bne.s 10$
rts
10$ move.w #memtyp,d0
bsr putstrw
move.l 10(a5),d0
bsr putnam
lea fraghead(a4),a0
bsr puthead
lea buffer,a1
move.l a1,a2
moveq #64,d0
9$ clr.l (a2)+
dbf d0,9$
lea 128(a1),a2
move.l 16(a5),d0 ;MemHeader->mh_First
beq.s 5$
move.l d0,a3
CALL Forbid,SysBase(a4)
2$ move.l 4(a3),d0
move.l d0,d5
moveq #31,d1
3$ lsl.l #1,d0
btst.l #31,d0
dbne d1,3$
lsl.l #2,d1
addq.l #1,0(a1,d1.w)
cmp.l 0(a2,d1.w),d5
ble.s 4$
move.l d5,0(a2,d1.w)
4$ move.l 0(a3),d0
beq.s 5$
move.l d0,a3
bra.s 2$
5$ CALL Permit,SysBase(a4)
moveq #0,d1
8$ move.l (a2)+,d5
move.l (a1)+,d2
beq.s 6$
moveq #0,d0
bset.l d1,d0
lsr.l #1,d0
move.l d0,d4
bsr hexa
move.l d4,d0
moveq #1,d3
bsr longdec
move.l d2,d0
bsr longdec
move.l d5,d0
bsr longdec
7$ bsr newline
6$ addq #1,d1
cmp.w #31,d1
ble.s 8$
bsr newline
bra 1$
*-------- Task-Stack ------------
stack lea stackhead(a4),a0
bsr puthead
moveq #0,d5
bsr getaskdat
sta1 tst.b entries(a4)
beq sta8
lea -16(a5),a5
bsr hideit
tst d0
beq sta9
move.l 0(a5),a1
cmp.b #13,8(a1) ;task->ln_Type
bne.s sta6
move.l 172(a1),d0 ;pr_CLI
beq.s sta6
lsl.l #2,d0
move.l d0,a0
tst.l 60(a0) ;cli_Module
beq.s sta6
moveq #1,d3
move.l 52(a0),d4 ;cli_DefaultStack
lsl.l #2,d4
move.l 176(a1),d0 ;pr_ReturnAddress
sub.l d4,d0
bsr hexa
move.l d4,d0
bsr longdec
move.l 176(a1),d0 ;pr_ReturnAddress
sub.l 54(a1),d0 ;tc_SPReg
bra.s sta7
sta6 move.l 58(a1),d0 ;tc_SPLower
bsr hexa
moveq #1,d3
move.l 62(a1),d0 ;tc_SPUpper
sub.l 58(a1),d0 ;tc_SPLower
bsr longdec
move.l 62(a1),d0 ;tc_SPUpper
sub.l 54(a1),d0 ;tc_SPReg
sta7 bsr longdec
move.l a1,a3
bsr gettaskname
bsr newline
sta9 subq.b #1,entries(a4)
bra sta1
sta8 rts
clicomm lea clicomhead(a4),a0
bsr puthead
moveq #0,d5
bsr getaskdat
clic1 tst.b entries(a4)
beq clic8
lea -16(a5),a5
bsr hideit
tst d0
beq clic0
move.l 0(a5),a2
cmpi.b #13,8(a2) ;ln_Type
bne clic0
tst.l 172(a2)
beq clic0
move.l 140(a2),d3 ;pr_TaskNum
beq clic0
move.l a2,d0
move.l d0,node(a4)
bsr hexa
moveq #0,d0
move.b 9(a5),d0
subq #1,d0
mulu #9,d0
move.w #status,d1
add.w d1,d0
bsr putstrw
move.l 172(a2),a3 ;pr_CLI
adda.l a3,a3
adda.l a3,a3
move.w #script,d0
tst.l 40(a3) ;cli_InterActive
beq.s clic5
addq.w #interact-script,d0
clic5 bsr putstrw
move.w #backg,d0
tst.l 44(a3) ;cli_Background
bne.s clic6
addq.w #foreg-backg,d0
clic6 bsr putstrw
bsr bytedec
move.l 4(a5),d0
bsr putstr
moveq #49,d1
bsr tab
bsr putblank
move.l 128(a2),d0 ;pr_SegList
beq.s noprogloadc
clic3 move.l 172(a2),d1 ;pr_CLI
bne.s clic4
noprogloadc move.w #longnix,d0
bsr putnamw
bra.s clic0
clic4 lsl.l #2,d1
move.l d1,a2
move.l 60(a2),d1 ;cli_Module
beq.s noprogloadc
move.l 16(a2),d0 ;cli_CommandName
bsr putbcpl
move.l 36(a2),d1 ;cli_CommandFile
beq.s 1$
move.l d1,d2
lsl.l #2,d1
move.l d1,a0
tst.b 0(a0)
beq.s 1$
bsr putblank
move.w #openbrak,d0
bsr putstrw
move.l d2,d0
bsr putbcpl
move.w #closebrak,d0
bsr putstrw
1$ bsr newline
clic0 subq.b #1,entries
bne clic1
clic8 rts
*--------- interrupts ------------
showint lea iheader(a4),a0
bsr puthead
lea intnames(a4),a5
lea inttyp(a4),a1
moveq #0,d6
findint lea inttyp(a4),a1
moveq #0,d1
moveq #15,d5
move.l SysBase(a4),a3
lea 84(a3),a3 ;SysBase->IntVects[16]
si0 tst.b 0(a1,d1)
bne.s si4
move.l 8(a3),a2 ;IntVector->iv_Node
bra.s si5
si4 move.l 0(a3),a2 ;Interrupt->is_Node
si5 cmp.l #0,a2
beq nxtint
tst.b 0(a1,d1)
beq.s si1
si2 move.l 0(a2),a2 ;is_Node->ln_Next
tst.l 0(a2)
beq nxtint
si1 tst d6
beq.s 3$
cmp.l a2,d4
bne.s 4$
rts
3$ move.l a2,d0
move.l d0,node(a4)
bsr hexa
move.l 14(a2),d0 ;Interrupt->is_Data
bsr hexan
move.l 18(a2),d0 ;Interrupt->is_Code
bsr hexan
move.b 9(a2),d3 ;Interrupt->ln_Pri
movem.l d6/a3,-(a7)
bsr plusmins
move.w #intserv,d0
tst.b 0(a1,d1)
bne.s 1$
move.w #inthand,d0
1$ bsr putstrw
move.w #intdis,d0
move.w $dff01c,d3
btst.w d1,d3
beq.s 2$
move.w #inten,d0
2$ bsr putstrw
movem.l (a7)+,d6/a3
move.l a5,d0
bsr putstr
move.l 10(a2),d0 ;Interrupt->ln_Name
bsr putnam
tst.b 0(a1,d1)
bne si2
4$ tst.l 0(a2)
beq.s nxtint
move.l 0(a2),a2
bra si1
nxtint addq #1,d1
lea 12(a5),a5
lea 12(a3),a3
dbf d5,si0
rts
*--------- resident ------------
showresi lea rheader(a4),a0
bsr puthead
move.l SysBase(a4),a5
move.l 300(a5),a5 ;SysBase->ResModules
r1 tst.l 0(a5)
beq r2
move.l 0(a5),d0 ;Resident->ln_Next
tst.l d0
bpl.s r3
bclr #31,d0
movea.l d0,a5
bra.s r1
r3 movea.l d0,a3
move.l d0,node(a4)
bsr hexa
move.b 13(a3),d3 ;rt_Pri
bsr plusmins
move.b 10(a3),d0 ;rt_Flags
bsr bin
move.b 11(a3),d3 ;rt_Version
bsr bytedec
move.b 12(a3),d0 ;rt_Type
bsr gettype
move.l 14(a3),d0 ;rt_Name
bsr putnam
r4 addq #4,a5
bra r1
r2 rts
*--------- ports -------------
showprt lea pheader(a4),a0
bsr puthead
move.l SysBase(a4),a6
lea 392(a6),a3 ;SysBase->PortList
lea buffer,a5
moveq #0,d5
RECALL Forbid
move.w #$4000,$dff09a
sp2 move.l 0(a3),a3 ;mp_Node.ln_Next
tst.l 0(a3)
beq.s sp20
bsr getpdata
bra.s sp2
sp20 tst.b tports(a4)
beq.s sp15
move.l SysBase(a4),a3
move.l 276(a3),a3 ;sysbase->ThisTask
lea 92(a3),a3 ;process->pr_MsgPort
bsr getpdata
move.l SysBase(a4),a2
lea 406(a2),a2 ;sysbase->TaskReady
sp11 move.l 0(a2),a2
tst.l 0(a2)
beq.s sp14
lea 92(a2),a3 ;pr_MsgPort
cmp.b #13,8(a2) ;ln_Type
bne.s sp11
bsr getpdata
bra sp11
sp14 move.l SysBase(a4),a2
lea 420(a2),a2 ;sysbase->TaskWait
sp12 move.l 0(a2),a2
tst.l 0(a2)
beq.s sp15
lea 92(a2),a3 ;pr_MsgPort
cmp.b #13,8(a2) ;ln_Type
bne.s sp12
bsr getpdata
bra sp12
sp15 move.w #-$4000,$dff09a
CALL Permit,SysBase(a4)
lea buffer,a5
sp3 tst.b d5
beq sp6
move.l 0(a5),d0
move.l d0,node(a4)
bsr hexa
move.l 4(a5),d0
bsr putstr
moveq #25,d1
bsr tab
move.b 8(a5),d0
and.l #3,d0
mulu #9,d0
add.w #mp_flags,d0
bsr putstrw
move.b 9(a5),d3
bsr bytedec
move.b 14(a5),d3
cmp.b #255,d3
bne.s 1$
move.w #toomuch,d0
bsr putstrw
bra.s 2$
1$ bsr bytedec
2$ move.l 10(a5),d0
bsr getaskname2
bsr newline
lea 16(a5),a5
subq.b #1,d5
bra sp3
sp6 rts
getpdata move.l a3,0(a5)
move.l 10(a3),4(a5) ;ln_Name
move.b 14(a3),8(a5) ;mp_Flags
move.b 15(a3),9(a5) ;mp_SigBit
move.l 16(a3),10(a5) ;mp_SigTask
moveq #0,d0
movea.l 20(a3),a1 ;mp_MsgList
sp10 movea.l 0(a1),a1
cmpa.l #0,a1
beq.s sp9
addq.b #1,d0
cmp.b #255,d0
bne.s sp10
sp9 move.b d0,14(a5)
lea 16(a5),a5
addq.b #1,d5
rts
*-------- resources ------------
showres lea lheader(a4),a0
bsr puthead1
lea resnam(a4),a0
bsr puthead2
move.l SysBase(a4),d5
add.l #336,d5 ;SysBase->ResourceList
bsr show
rts
*--------- devices -------------
showdevs lea lheader(a4),a0
bsr puthead1
lea devnam(a4),a0
bsr puthead2
move.l SysBase(a4),d5
add.l #350,d5 ;SysBase->DeviceList
bsr show
rts
*-------- libraries -------------
showlibs lea lheader(a4),a0
bsr puthead1
lea libnam(a4),a0
bsr puthead2
move.l SysBase(a4),d5
add.l #378,d5 ;SysBase->LibList
show lea buffer,a5
clr.b entries(a4)
CALL Forbid,SysBase(a4)
move.l d5,a3
sl1 move.l 0(a3),a3 ;lib_Node.ln_Next
tst.l 0(a3)
beq.s sl2
addq.b #1,entries(a4)
move.l a3,0(a5)
move.l 10(a3),4(a5) ;ln_Name
move.b 33(a3),8(a5) ;lib_OpenCnt
move.b 21(a3),9(a5) ;lib_Version
move.b 23(a3),10(a5) ;lib_Revision
move.b 14(a3),11(a5) ;lib_Flags
lea 12(a5),a5
bra.s sl1
sl2 RECALL Permit
lea buffer,a5
dl3 tst.b entries(a4)
beq.s sl4
move.l 0(a5),d0
move.l d0,node(a4)
bsr hexa
move.b 8(a5),d3
bsr bytedec
move.b 9(a5),d3
bsr bytedec
move.b 10(a5),d3
bsr bytedec
move.b 11(a5),d0
bsr bin
move.l 4(a5),d0
bsr putnam
lea 12(a5),a5
subq.b #1,entries(a4)
bra.s dl3
sl4 rts
;--------- Semaphores ---------
semaphores lea semhead(a4),a0
bsr puthead
move.l SysBase(a4),a0
move.l 532(a0),a1
bsr.s 1$
move.l intuibase(a4),a0
cmp.w #36,20(a0)
bge.s 5$
move.l 1010(a0),a1
bsr.s 1$
5$ rts
1$ move.w #$4000,$dff09a
moveq #0,d5
lea buffer,a2
8$ tst.l 0(a1)
beq.s 4$
move.l a1,(a2)+
move.l $28(a1),(a2)+
move.b $2d(a1),(a2)+
move.b $f(a1),(a2)+
move.l 10(a1),(a2)+
move.l 0(a1),a1
addq #1,d5
bra.s 8$
4$ move.w #-$4000,$dff09a
lea buffer,a2
6$ subq #1,d5
bmi.s 7$
move.l (a2)+,d0
bsr hexa
move.l (a2)+,d0
bsr getaskname2
moveq #24,d1
bsr tab
move.b (a2)+,d3
addq #1,d3
bsr plusmins
move.b (a2)+,d3
bsr plusmins
move.l (a2)+,d0
bsr putnam
move.l 0(a1),a1
bra.s 6$
7$ rts
;Remove a resident module from the list. Clears the rt_Matchword
;to avoid being found and reinserted during the next reset
remresident bsr nodenam2
cmp.b #'$',0(a5)
bne.s 1$
move.l a5,a0
bsr readhex
tst.b d7
bne.s 2$
1$ move.l a5,a1
CALL FindResident,SysBase(a4)
tst.l d0
beq fn5
2$ move.l SysBase(a4),a3
move.l 300(a3),a3 ;SysBase->ResModules
8$ move.l (a3)+,d1
beq fn5
bpl.s 3$
bclr #31,d1
movea.l d1,a3
bra.s 8$
3$ cmp.l d1,d0
bne.s 8$
4$ move.l a3,a5
5$ tst.l (a5)+
bgt.s 5$
6$ move.l d0,a1
clr.w 0(a1) ;rt_MatchTag
clr.l 22(a1) ;rt_Init
clr.b 10(a1) ;rt_Flags
move.l a5,d0
sub.l a3,d0
lsr #2,d0
subq #1,d0
lea -4(a3),a1
7$ move.l (a3)+,(a1)+
dbf d0,7$
rts
;find the first entry in the device-list
;returns a1 = pointer to first entry
devinfo move.l dosbase(a4),a1
move.l 34(a1),a1 ;dl_Root
move.l 24(a1),a1 ;RootNode->rn_Info
adda.l a1,a1
adda.l a1,a1
move.l 4(a1),a1 ;DosInfo->di_DevInfo
rts
;unlock a file
unlock tst.b fromfile(a4)
bne ul6
bsr readhex
tst.b d7
beq syntax
move.l d0,remembr(a4)
move.l d0,-(a7)
moveq #-1,d6
bsr of44
tst.l remembr(a4)
beq.s ul1
move.w #unlerr,d0
bsr putnamw
bra ul4
ul1 bsr ResumeOutput
move.w #unl1,d0
bsr putstrw
move.l 0(a7),d0
bsr getpath
move.w #unltxt2,d0
bsr putstrw
bsr readline
ori.b #$20,inputbuffer
cmp.b #'y',inputbuffer
bne.s ul5
move.l 0(a7),d1
CALL UnLock,dosbase(a4)
ul5 bsr freefinfo
ul4 addq #4,a7
ul6 rts
;---------- Show all Locks------------
locks moveq #0,d6
bra.s of33
;---------- Open Files-----------
openfiles moveq #1,d6
of33 lea ofheader(a4),a0
bsr puthead
of55 move.l mytask(a4),a5
move.l 184(a5),inputbuffer
move.l #-1,184(a5) ;disable 'please insert..' requester
of44 bsr allocfinfo
bsr devinfo ;get pointer to devicelist
move.l a1,a3
of1 move.l a3,devicelock(a4)
adda.l a3,a3
adda.l a3,a3
cmp.l #2,4(a3) ;DeviceList->dl_Type
bne of2 ;2 = DLT_VOLUME
move.l 40(a3),d0 ;dl_Name
lsl.l #2,d0
move.l d0,a2
moveq #0,d3
move.b (a2)+,d3
subq #1,d3
lea buffer,a5
of22 move.b (a2)+,(a5)+ ;hack to access the 'RAM Disk" as
dbf d3,of22 ;'RAM:' as the system may GURU
move.b #':',(a5)+ ;with KS1.2
clr.b 0(a5)
cmp.l #'RAM ',buffer
bne.s of5
cmp.l #'Disk',buffer+4
bne.s of5
move.l #$4d3a0000,buffer+2 ;="M:"
of5 move.l #buffer,d1
move.l #-2,d2
CALL Lock,dosbase(a4) ;get a lock to the device
tst.l d0 ;'not mounted' if fails
bne.s of6
move.l #buffer,d0
bsr putstr
move.w #nomount,d0
bsr putnamw
bra of2
of6 move.l d0,-(a7) ;d0 = FileLock
lsl.l #2,d0
move.l d0,a5
CALL Forbid,SysBase(a4)
lea buffer+40,a6 ;where to store the locks we find
of4 move.l 0(a5),d0 ;fl_Link
cmp.l #50,d0 ;zero or bogus ?
ble 1$ ;exit loop
tst d6 ;searching for a lock ?
bpl.s 3$
cmp.l remembr(a4),d0 ;yes, compare them
bne.s 3$
CALL Permit,SysBase(a4) ;exit if found
clr.l remembr(a4)
2$ move.l (a7)+,d1
CALL UnLock,dosbase(a4)
bra quitof
3$ move.l d0,(a6)+ ;put lock into buffer
clr.w (a6)+
tst.b post_V34(a4)
beq.s 5$
bsr IsBcplLock ;hack for KS2.0, see if BPTR isn't
bne.s 5$ ;really an APTR
move.w #1,-2(a6)
bra.s 4$
5$ lsl.l #2,d0 ;convert bptr into aptr
4$ move.l d0,a5
bra.s of4 ;get next lock
1$ clr.l (a6)+ ;end of buffer marker
CALL Permit,SysBase(a4)
tst d6 ;just searching for a lock ?
bmi of3 ;skip printing out info
of45 lea buffer+40,a2 ;a2-> array of locks
of46 move.l (a2)+,d0 ;get a lock
beq of3 ;end of list ?
tst.w (a2)+
beq.s 2$
lsr.l #2,d0
2$ move.l d0,d5
lsl.l #2,d0 ;bptr -> aptr
move.l d0,a5
move.l 8(a5),d4 ;fl_Access
move.l d5,d0
bsr getfinfo ;get fileinfo
move.l finfoptr(a4),a5
tst.l d6
beq.s of8
bmi.s of8 ;looking for open files ?
tst.l 4(a5) ;fib_DirEntryType
bpl of46 ;not a file
of8 move.l d5,d0
move.l d0,node(a4)
bsr hexa ;display lock
move.w #access,d0 ;access mode
cmp #-2,d4
beq.s of7
addq #8,d0
of7 bsr putstrw
tst.l 4(a5) ;size
bmi.s of9
move.w #longnix,d0
bsr putstrw
bra of10
of9 move.l 124(a5),d0
bsr longdec
of10 move.l d5,d0 ;path and filename
bsr getpath
bra of46
bsr newline
of3 move.l (a7)+,d1
CALL UnLock,dosbase(a4)
of2 move.l 0(a3),a3
cmpa.l #0,a3
bne of1
bsr freefinfo
quitof move.l mytask(a4),a5
move.l inputbuffer,184(a5)
rts
IsBcplLock movem.l d0/a0,-(a7)
btst #0,d0
bne.s 2$
move.l d0,a0
move.l 16(a0),d0
cmp.l devicelock(a4),d0
2$ movem.l (a7)+,d0/a0
rts
;---------- Dos Devices ----------
devices lea ddheader(a4),a0
bsr puthead
bsr devinfo
dev1 adda.l a1,a1
adda.l a1,a1
clr.b d6
tst.l 4(a1)
bne dev2
move.l 40(a1),d0
bsr putbcpl
moveq #10,d1
bsr tab
cmp.l #20,28(a1)
ble dev9
moveq #1,d6
move.l 28(a1),a3
adda.l a3,a3
adda.l a3,a3
cmp.l #20,8(a3)
ble dev9
move.l 8(a3),a2
adda.l a2,a2
adda.l a2,a2
move.l 12(a2),d3
movem.l a1-a3,-(a7)
bsr bytedec
movem.l (a7)+,a1-a3
moveq #1,d3
move.l 20(a2),d0
bsr longdec
move.l 40(a2),d0
beq.s devs20
addq #1,d0
sub.l 36(a2),d0
devs20 bsr longdec
move.l 44(a2),d0
bsr longdec
bra.s dev8
dev9 move.w #notfile,d0
bsr putstrw
dev8 tst.l 8(a1)
beq.s dev6
move.w #devload,d0
bra.s dev5
dev6 move.w #devnload,d0
dev5 bsr putstrw
tst.b d6
beq.s dev7
move.l 4(a3),d0
bne.s dev4
dev7 move.l 16(a1),d0
bne.s dev4
tst.l 8(a1)
beq.s dev11
move.l 8(a1),a3
move.l -82(a3),d0
bsr putstr
bra dev11
dev4 bsr putbcpl
dev11 bsr newline
dev2 move.l 0(a1),a1
cmpa.l #0,a1
bne dev1
rts
; Check if a named dos-device is mounted
; name in 'buffer'.
; Result: d0 = 0(false) anything else(true).
finddev bsr devinfo
fdev1 adda.l a1,a1
adda.l a1,a1
clr.b d6
tst.l 4(a1)
bne.s fdev2
move.l 40(a1),a2
lea buffer,a0
bsr strbcmp
tst d0
bne.s fdev3
fdev2 move.l 0(a1),a1
cmpa.l #0,a1
bne.s fdev1
fdev3 rts
; Re-assign a drive to dos
freedrive clr.l dp_Arg1
bra ldr3
; Inhibit a disk drive
lockdrive move.l #1,dp_Arg1
ldr3 bsr getstr
bsr finddev
bne.s ldr1
ldr2 move.l #buffer,d0
bsr putstr
move.w #nomount,d0
bsr putstrw
move.w #dishelp,d0
bra putnamw
ldr1 move.l #buffer,d1
CALL DeviceProc,dosbase(a4)
tst.l d0
beq.s ldr2
move.l d0,a0
move.l #31,dp_Type
bra cons1
;display the current directory of all processes,
currentdir lea cdheader(a4),a0
bsr puthead
bsr allocfinfo
bsr getaskdat4
beq cd7
move.l d0,a5
move.l a5,-(a7)
bsr getaskdat3
move.b d5,entries(a4)
move.l 0(a7),a5
cd2 tst.b entries(a4)
beq.s cd6
cmp.b #13,8(a5)
bne.s cd5
move.l 0(a5),a3
move.l a5,-(a7)
moveq #-1,d6
move.l 152(a3),remembr(a4)
bsr of55
move.l (a7)+,a5
tst.l remembr(a4)
bne.s cd5
move.l 0(a5),a3
move.l a3,node(a4)
bsr gettaskname
moveq #21,d1
bsr tab
move.l 0(a5),a3
move.l 152(a3),d0
cd1 bsr getpath
cd5 subq.b #1,entries(a4)
lea 16(a5),a5
bra.s cd2
cd6 bsr freefinfo
move.l (a7)+,a5
bsr freetaskbuf
cd7 rts
;Change the current directory setting of a process
cd tst.b fromfile(a4)
bne cd10
bsr getstr
move.l a0,-(a7)
move.l #buffer,d1
move.l #-2,d2
CALL Lock,dosbase(a4)
move.l (a7)+,a0
tst.l d0
bne cd16
move.w #dnotf,d0
bra putnamw
cd16 move.l d0,remembr2(a4)
move.l a0,-(a7)
bsr allocfinfo
move.l remembr2(a4),d0
bsr getfinfo
move.l finfoptr(a4),a5
move.l (a7)+,a0
tst.l 4(a5)
bpl.s cd11
move.w #notdir,d0
bsr putnamw
bra cd18
cd11 bsr nodenam
moveq.l #2,d7
lea TRuNode(PC),a3
bsr findnam
tst.b d7
beq.s cd15
move.l d0,a5
cmp.b #13,8(a5)
beq.s cd15
bsr syntax
bra cd18
cd15 move.l 152(a5),d0
beq.s cd13
movem.l a5,-(a7)
moveq #-1,d6
move.l d0,remembr(a4)
bsr of55
move.l (a7)+,a5
tst.l remembr(a4)
bne.s cd18
cd13 move.l 152(a5),d1
move.l remembr2(a4),152(a5)
move.l d1,remembr2(a4)
cd12 beq.s cd14
bsr ResumeOutput
move.w #unltxt,d0
bsr putstrw
move.l remembr2(a4),d0
bsr getpath
move.w #unltxt2,d0
bsr putstrw
bsr readline
ori.b #$20,inputbuffer
cmp.b #'y',inputbuffer
bne.s cd14
cd18 move.l remembr2(a4),d1
beq.s cd14
CALL UnLock,dosbase(a4)
cd14 bsr freefinfo
cd10 rts
;Display the list of inputhandlers. It adds a dummy
;input handler, grabs the list header, and removes the handler
inphand tst.b background(a4)
bne.s inph1
bsr installh
inph1 move.l #500,d4
lea InInterrupt(a4),a0
inph2 tst.l 4(a0)
beq.s inph3
move.l 4(a0),a0
dbf d4,inph2
inph3 tst.b background(a4)
bne.s inph4
movem.l d4/a0,-(a7)
bsr removeh
movem.l (a7)+,d4/a0
inph4 cmp.w #-1,d4
bne.s inph5
move.w #failed,d0
bra putnamw
inph5 move.l a0,-(a7)
lea inheader(a4),a0
bsr puthead
move.l (a7)+,a5
inph6 move.l 0(a5),a5
tst.l 0(a5)
beq.s inph7
move.l a5,d0
move.l d0,node(a4)
bsr hexa
move.l 14(a5),d0
bsr hexa
move.l 18(a5),d0
bsr hexa
move.b 9(a5),d3
bsr plusmins
move.l 10(a5),d0
inph8 bsr putnam
bra.s inph6
inph7 rts
;get all screen pointers.
;result: d5=number of screens
; buffer+100 holds pointers.
getscr lea scrheader(a4),a0
bsr puthead
getscr2 move.l d0,-(a7)
moveq #0,d0
CALL LockIBase,intuibase(a4)
move.l intuibase(a4),a2
move.l 60(a2),a2
lea buffer+100,a1
moveq #0,d5
sr1 move.l a2,(a1)+
move.l 0(a2),a2
addq.l #1,d5
cmpa.l #0,a2
bne.s sr1
subq #1,d5
move.l d0,a0
CALL UnlockIBase,intuibase(a4)
move.l (a7)+,d0
rts
;display screen addresses and titles
screens bsr getscr
moveq #1,d6
lea buffer+100,a1
sr2 move d6,d3
bsr bytedec
move.l 0(a1),d0
move.l d0,node(a4)
move.l d0,a2
bsr hexa
move.w 12(a2),d0
moveq #4,d3
bsr longdecn
moveq #'X',d0
bsr putchar
move.w 14(a2),d0
bsr longdecn
move.b 189(a2),d3
bsr bytedec
move.l (a1)+,a2
move.l 22(a2),d0
bsr putnam
addq #1,d6
dbf d5,sr2
rts
Screen
;display window addresses and titles
windows clr.b bool(a4)
windows1 bsr getscr2
move.l d5,-(a7)
lea wnheader(a4),a0
bsr puthead
move.l (a7)+,d5
tst.b bool(a4)
beq.s wn20
move.l d5,-(a7)
lea fohead(a4),a0
bsr puthead
move.l (a7)+,d5
wn20 lea buffer+100,a3
wn2 move.w #onscr,d0
bsr putstrw
move.l (a3)+,a2
move.l 22(a2),d0
bsr putnam
move.l 4(a2),a1
wn1 cmpa.l #0,a1
beq.s wn3
move.l a1,d0
move.l d0,node(a4)
bsr hexa
move.l 86(a1),d0 ;wn->UserPort
beq.s 1$
move.l d0,a0
move.l 16(a0),d0 ;SigTask
1$ bsr getaskname2
moveq #20,d1
bsr tab
bsr putblank
moveq #4,d3
moveq #2,d2
lea 4(a1),a0
2$ move.w (a0)+,d0
bsr longdecn
dbf d2,2$
moveq #'X',d0
bsr putchar
move.w 10(a1),d0
bsr longdecn
move.l 32(a1),d0
bsr putnam
tst.b bool(a4)
beq.s wn21
move.l a1,-(a7)
move.l 50(a1),a1
move.l 52(a1),a1
bsr fontdata
move.l (a7)+,a1
wn21 move.l 0(a1),a1
bra.s wn1
wn3 dbf d5,wn2
rts
;close a specified screen
closescreen bsr getscr2
moveq #1,d6
cmp.b #'$',0(a0)
bne.s cs1
bsr readhex
tst d7
beq syntax
move.l d0,d4
csin moveq #0,d6
cs1 lea buffer+100,a2
cs5 tst d6
bne.s cs2
cmp.l (a2)+,d4
beq.s cs3
bra.s cs4
cs2 move.l (a2)+,a1
move.l 22(a1),a1
bsr strcmp
tst d0
beq.s cs3
cs4 dbf d5,cs5
move.w #scnofound,d0
bra putnamw
cs3 move.l -4(a2),a0
CALL CloseScreen,intuibase(a4)
rts
;close a specified window
closewindow bsr getwnptr
clw move.l a3,d0
beq.s cwend
cw3 tst.l 36(a3)
beq.s cw8
move.l 36(a3),a0
move.w 28(a0),d0
and.w #$4000,d0
beq.s cw9
move.l a3,a0
CALL FreeSysRequest,intuibase(a4)
rts
cw9 move.l a3,a1
CALL EndRequest,intuibase(a4)
bra.s cw3
cw8 move.l a3,a0
moveq #0,d0
CALL ModifyIDCMP,intuibase(a4)
move.l a3,a0
CALL CloseWindow,intuibase(a4)
cwend rts
getwnptr bsr getscr2
moveq #1,d6
cmp.b #'$',0(a0)
bne.s cw1
bsr readhex
tst d7
bne.s cwin
bsr syntax
bra.s cwerr
cwin move.l d0,d4
moveq #0,d6
cw1 lea buffer+100,a2
cw5 move.l (a2)+,a3
move.l 4(a3),a3
cw6 cmpa.l #0,a3
beq.s cw4
tst d6
bne.s cw2
cmp.l a3,d4
beq.s cw10
bra.s cw7
cw2 move.l 32(a3),a1
bsr strcmp
tst d0
beq.s cw10
cw7 move.l 0(a3),a3
bra.s cw6
cw4 dbf d5,cw5
move.w #winnofound,d0
bsr putnamw
cwerr suba.l a3,a3
cw10 rts
windowoff movem.l d1-d7/a0-a6,-(a7)
bsr getscr2
bsr cwin
move.l a3,d1
beq.s woff1
bsr clw
move.l -(a2),a0
move.l a0,d4
tst.l 4(a0)
bne.s woff1
bsr getscr2
bsr csin
woff1 movem.l (a7)+,d1-d7/a0-a6
rts
closetskwin movem.l d1-d7/a0-a6,-(a7)
ctw0 bsr getscr2
lea buffer+100,a2
ctw1 move.l (a2)+,a3
move.l 4(a3),a3
ctw6 cmpa.l #0,a3
beq.s ctw4
move.l 86(a3),a0
move.l 16(a0),d1
cmp.l d0,d1
bne.s ctw7
move.l d0,d1
move.l a3,d0
bsr windowoff
move.l d1,d0
bra ctw0
ctw7 move.l 0(a3),a3
bra.s ctw6
ctw4 dbf d5,ctw1
movem.l (a7)+,d1-d7/a0-a6
rts
;Change the font of a specified Window
setfont bsr nodenam
tst.b 0(a5)
beq syntax
move.l a5,a3
1$ cmp.b #33,(a3)+
bge.s 1$
tst.b -1(a3)
beq syntax
clr.b -1(a3)
lea dummy,a0
move.l a5,0(a0)
move.b procnum(a4),d0
ext.w d0
move.w d0,4(a0)
clr.w 6(a0)
CALL OpenFont,gfxbase(a4)
tst.l d0
bne.s 2$
lea diskfont(a4),a1
CALL OpenLibrary,SysBase(a4)
move.l d0,d5
beq.s 4$
move.l d0,a6
lea dummy,a0
RECALL OpenDiskFont
move.l d0,d4
move.l d5,a1
CALL CloseLibrary,SysBase(a4)
move.l d4,d0
bne.s 2$
4$ move.w #fonterr,d0
bsr putstrw
move.l dummy,d0
bra putnam
2$ move.l d0,-(a7)
move.l a3,a0
bsr kllblnks
bsr getwnptr
move.l (a7)+,a0
move.l a3,d1
bne.s 5$
move.l a0,a1
CALL CloseFont,gfxbase(a4)
bra.s 3$
5$ move.l 50(a3),a1
CALL SetFont,gfxbase(a4)
move.l a3,a0
CALL RefreshWindowFrame,intuibase(a4)
3$ rts
;display windows and associated fonts
windowfonts move.b #1,bool(a4)
bra windows1
;display loaded font names and definitions
fonts lea fohead(a4),a0
bsr puthead
move.l gfxbase(a4),a1
move.l $8c(a1),a1
fo1 tst.l 0(a1)
beq.s fo3
bsr fontdata
move.l 0(a1),a1
bra fo1
fo3 rts
fontdata move.l a1,d0
move.l d0,node(a4)
bsr hexa
move.w 30(a1),d3
bsr bytedec
move.w 20(a1),d3
bsr bytedec
move.w 24(a1),d3
bsr bytedec
move.w #romfnt,d0
btst #1,23(a1)
beq.s fod1
addq #diskfnt-romfnt,d0
fod1 bsr putstrw
move.w #ffixed,d0
btst #5,23(a1)
beq.s 1$
addq #fprop-ffixed,d0
1$ bsr putstrw
move.b 32(a1),d3
bsr bytedec
move.b 33(a1),d3
bsr bytedec
move.l 10(a1),d0
bra putnam
;set update rate
settime bsr getfrac
tst.b d7
bne.s st1
move.w #whattime,d0
bsr putstrw
move.l timeoutm(a4),d0
move.l #100000,d1
bsr div
moveq #0,d1
move.b timeout(a4),d1
mulu #10,d1
add.l d1,d0
bne.s 1$
move.w #timenotset,d0
bra putnamw
1$ bsr putfrac
bra newline
st1 divs #10,d2
move.b d2,timeout(a4)
swap d2
ext.l d2
moveq #0,d3
subq #1,d2
bmi.s 1$
2$ add.l #100000,d3
dbf d2,2$
1$ move.l d3,timeoutm(a4)
rts
syntax move.w #synerr,d0
sy1 bra putnamw
;copy a string from input to 'buffer'
;a0 = pointer to string
getstr lea buffer,a5
gst2 cmp.b #' ',0(a0)
beq.s gst1
cmp.b #10,0(a0)
beq.s gst1
move.b (a0)+,(a5)+
bra.s gst2
gst1 clr.b 0(a5)
bra kllblnks
;read in a nodename or a processname
nodenam bsr isdec
move.b d2,procnum(a4)
nodenam2 bsr kllblnks
move.l a0,a5
gno1 cmp.b #10,(a0)+
bne.s gno1
move.b #0,-1(a0)
rts
zerotimer bsr nodenam
moveq.l #2,d7
lea TRuNode(PC),a3
bsr findnam
tst.b d7
beq.s 1$
bsr gettimeentry
lea usedtime,a0
clr.l 0(a0,d0)
1$ rts
;cancel a task or a process. The theory is quite simple:
;(Process->ReturnAddr)-4 points to the return address on
;the stack. Task->SPReg points to the next instruction
;to be executed. We just need a
; *(Task->SPReg) = *(Process->ReturnAddr-4).
;If the process has been started from Dos (CLI) and
;the process is doing disk I/O, the CLI will respond with
;a GURU #87000004 (AsyncPKT=unexpected packed received).
;Thats why the calling CLI is also canceled.
cancel tst.b fromfile(a4)
beq.s cancel1
rts
cancel1 clr.l remembr(a4) ;used for CLI stdio
clr.l remembr2(a4)
clr.b bool(a4)
bsr nodenam
testagain moveq.l #1,d7
lea TReNode(PC),a3
bsr findnam
tst.b d7
bne.s canok
cnerr move.w #stperr,d0
bra putnamw
canok move.l d0,a1 ;d0=task
move.l d0,pointer(a4)
cmp.b #1,8(a1) ;TASK ?
bne.s isproc
CALL RemTask,SysBase(a4)
move.l pointer(a4),d0
bsr closeports
move.l pointer(a4),d0
bra closetskwin
isproc movem.l d0-d7/a0-a6,-(a7)
moveq #-1,d0 ;needed for recursive killing tasks
CALL AllocSignal,SysBase(a4)
moveq #0,d1
bset d0,d1
move.l d1,cancelbit(a4)
move.l d0,cancelbnum(a4)
movem.l (a7)+,d0-d7/a0-a6
moveq #0,d5
tst.l $ac(a1) ;pr_CLI
beq.s wascreproc
move.l $80(a1),a2 ;Seglist
adda.l a2,a2
adda.l a2,a2
move.l 12(a2),d1 ;empty ?
bne.s wascreproc
move.l $ac(a1),a2 ;CommandLineInterface
adda.l a2,a2
adda.l a2,a2
move.l 60(a2),d5 ;cli_Module
tst.l 40(a2) ;IsInteractive
beq dosreturn
move.l 28(a2),remembr(a4) ;yes,get Cli-Window locks
move.l 56(a2),remembr2(a4)
bra dosreturn
wascreproc tst.b bool(a4) ;it is not a CLI, ask what to do
bne unload
move.b #3,bool(a4)
bsr ResumeOutput
move.w #canerr0,d0 ;ask for Workbench
bsr putstrw
bsr readline
cmp.b #'y',inputbuffer
beq.s andagain
move.b #2,bool(a4)
bsr ResumeOutput
move.w #canerr1,d0 ;ask for unload
bsr putstrw
bsr readline
cmp.b #'y',inputbuffer
bne.s andagain
move.b #1,bool(a4)
andagain move.l pointer(a4),d0
moveq.l #1,d7
lea TReNode(PC),a3
bsr tstnode
tst d5
beq cnerr
bra canok
unload move.l 128(a1),d4 ;get Segmentlist
beq.s unl3
lsl.l #2,d4
move.l d4,a3
cmp.l #100,0(a3)
bpl.s ulerr
move.l 12(a3),d4
unl3 tst.l d4
bne.s unl4
ulerr move.w #unloaderr,d0 ;no Segments !?
bra putnamw
unl4 cmp.b #3,bool(a4) ;Workbench Task
bne.s unl2
move.l a1,-(a7)
moveq #40,d0 ;build a copy of the
move.l #$10000,d1 ;Workbench startup-message
CALL AllocMem,SysBase(a4)
move.l d0,startmess(a4)
move.l (a7)+,a1
move.l d0,a0
move.b #5,8(a0)
move.w #20,18(a0)
move.l d4,24(a0)
move.l a1,d0
add.l #92,d0
move.l d0,20(a0)
movem.l a0-a1,-(a7)
lea wbname(a4),a1
CALL FindPort,SysBase(a4)
movem.l (a7)+,a0-a1
move.l d0,14(a0)
bne.s unl2
move.w #noworkbench,d0
bra putnamw
unl2 cmp.b #1,bool(a4)
bne.s dosreturn
move.l a1,-(a7) ;unload process manualy
move.l d4,d1
CALL UnLoadSeg,dosbase(a4)
move.l (a7)+,a1
dosreturn move.l 140(a1),savedat(a4) ;Processnumber
dosret1 move.w #$4000,$dff09a
move.l 54(a1),a3
move.l #endtask,0(a3)
tst.b gotguru(a4)
bne.s 1$
tst.b bool(a4)
bne.s 1$
move.b #2,106(a1) ;ignore messages
1$ cmp.b #4,15(a1) ;if waiting
bne.s doswait
move.l a1,d4
CALL Remove,SysBase(a4)
move.l d4,a1
lea 406(a6),a0 ; activate the task
RECALL AddHead
move.l d4,a1
doswait move.w #-$4000,$dff09a
tst.b bool(a4)
bne.s endnodos
tst.l d5
beq.s endcanc
move.l $ac(a1),a2
adda.l a2,a2
adda.l a2,a2
dwa1 movem.l d0-d7/a0-a6,-(a7)
move.l cancelbit(a4),d0
CALL Wait,SysBase(a4)
movem.l (a7)+,d0-d7/a0-a6
tst.b gotguru(a4)
bne.s endnodos
moveq #0,d5
bra dosret1
endcanc move.l a1,-(a7)
move.l remembr(a4),d1 ;close CLI-Window
beq.s ecan1 ;if any
CALL Close,dosbase(a4)
ecan1 move.l remembr2(a4),d1
beq.s ecan2
CALL Close,dosbase(a4)
ecan2 move.l (a7)+,a1
move.l savedat(a4),d0 ;remove Task from
move.l dosbase(a4),a2 ;TaskArray
move.l 34(a2),a2
move.l 0(a2),a2
adda.l a2,a2
adda.l a2,a2
lsl.l #2,d0
clr.l 0(a2,d0)
endnodos move.l a1,d0
bsr closetskwin
move.l a1,d0
bsr closeports
move.l cancelbnum(a4),d0 ;remove our Signal
CALL FreeSignal,SysBase(a4)
rts
;This Code is (hopefully) executed by the Process we want
;to kill
endtask move.l _SysBase(PC),a1
move.l 276(a1),a1
move.l 176(a1),a1 ;Process_ReturnAddr
lea -4(a1),a7 ;reset Process Stackptr
tst.b bool+dataarea
bne.s et0
movea.l mytask+dataarea(PC),a1
move.l cancelbit+dataarea(PC),d0 ;signal Xoper it
CALL Signal,_SysBase(PC) ;died
et0 cmp.b #3,bool+dataarea ;Workbench Process ?
bne.s et1
CALL Forbid,_SysBase(PC)
move.l startmess(a4),a1
CALL ReplyMsg,_SysBase(PC) ;reply startup message
et1 rts
;Stop a task (just queue it on a special list)
freeze bsr nodenam
moveq.l #1,d7
lea TReNode(PC),a3
bsr findnam
tst.b d7
bne.s frok
frerr move.w #stperr,d0
bra putstrw
frok move.l d0,a1
cmp.b #13,8(a1)
beq.s 1$
cmp.b #1,8(a1)
bne.s frerr
1$ move.w #$4000,$dff09a
CALL Remove,SysBase(a4)
move.w #-$4000,$dff09a
move.l d0,a1
move.l d0,a5
lea stplist(a4),a0
RECALL AddHead
add.b #4,15(a5)
rts
;put the task back on its list
warm bsr nodenam
cmp.b #'$',0(a5)
bne.s 1$
move.l d7,d2
move.l a5,a0
bsr readhex
tst.b d7
beq.s 1$
move.l stplist(a4),a3
3$ tst.l 0(a3)
beq.s 2$
cmp.l a3,d0
beq.s waok
move.l 0(a3),a3
bra.s 3$
1$ lea stplist(a4),a0
movea.l a5,a1
moveq #0,d7
bsr fn4
tst.b d7
bne.s waok
2$ move.w #waerr,d0
bra putstrw
waok move.w #$4000,$dff09a
move.l d0,a1
CALL Remove,SysBase(a4)
move.l d0,a1
move.l d0,a5
move.l TReNode,a0
cmp.b #8,15(a1)
bne.s wa1
move.l TWaNode,a0
wa1 adda.l SysBase(a4),a0
RECALL AddTail
move.l d0,a1
subq.b #4,15(a5)
move.w #-$4000,$dff09a
move.l 18(a5),d0
and.l 26(a5),d0
beq.s wa2
movea.l a5,a1
RECALL Signal
wa2 rts
;show register values of a task
regs bsr nodenam
moveq.l #2,d7
lea TRuNode(PC),a3
bsr findnam
tst.b d7
bne.s 1$
rts
1$
;show the hunks of a process
hunks bsr nodenam
moveq.l #2,d7
lea TRuNode(PC),a3
bsr findnam
tst.b d7
bne.s hu1
rts
hu1 move.l d0,a5
cmp.b #13,8(a5)
beq.s hu2
move.w #noprocs,d0
bra putnamw
hu2 move.l 128(a5),d0
beq.s noprogload
lsl.l #2,d0
move.l d0,a3
move.l 12(a3),d1
beq.s hu3
cmp.l #100,0(a3)
ble.s 1$
move.w #unloaderr,d0
bra.s huxx
1$ move.w #segloaded,d0
bsr putnamw
bra hu5
hu3 move.l 172(a5),d1
bne.s hu4
noprogload move.w #notload,d0
huxx bra putnam
hu4 move.w #cliprocs,d0
bsr putnamw
lsl.l #2,d1
move.l d1,a5
move.l 60(a5),d1
beq.s noprogload
move.w #procloaded,d0
bsr putstrw
move.l 16(a5),d0
bsr putbcpl
bsr newline
hu5 lea hunkheader(a4),a0
bsr puthead
moveq #0,d5
hu6 move.l d5,d3
bsr bytedec
addq #1,d5
move.l d1,d0
bsr hexa
lsl.l #2,d1
move.l d1,a5
move.l d1,d0
addq.l #4,d0
bsr hexa
move.l -4(a5),d0
moveq #1,d3
bsr longdec
move.l #'($',d0
bsr putlongascii
move.l -4(a5),d0
bsr hexa
moveq #')',d0
bsr putchar
bsr newline
move.l 0(a5),d1
bne.s hu6
rts
;change the priority of a node
pri bsr getnum
tst.b d7
beq syntax
move.b d2,newpri(a4)
bsr nodenam2
moveq.l #8,d7
lea TRuNode(PC),a3
bsr findnam
tst.b d7
beq.s pi1
move.l d0,a1
cmp.b #13,8(a1)
beq.s tp2
cmp.b #1,8(a1)
beq.s tp2
move.b newpri(a4),9(a1)
cmp.l #SemNode,a3
ble.s pi2
move.w #listerr,d0
bra putnamw
pi2 CALL Forbid,SysBase(a4)
RECALL Remove
move.l d0,a1
move.l a3,a0
move.l 0(a0),d6
lea 0(a6,d6),a0
RECALL Enqueue
RECALL Permit
pi1 rts
;modify a task's priority
taskpri bsr getnum
tst.b d7
beq syntax
move.b d2,newpri(a4)
bsr nodenam
moveq.l #2,d7
lea TRuNode(PC),a3
bsr findnam
tst.b d7
beq.s tp1
move.l d0,a1
tp2 move.b newpri(a4),d0
tp3 CALL SetTaskPri,SysBase(a4)
tp1 rts
;set the priority of our task
mypri bsr getnum
tst.b d7
beq syntax
move.l SysBase(a4),a1
move.l 276(a1),a1
move.l d2,d0
bra.s tp3
;set all break signals of a task
break move.l #$f000,d0
bra setthem
signal bsr readhex
tst.b d7
beq syntax
setthem move.l d0,savedat
bsr nodenam
moveq.l #2,d7
lea TReNode(PC),a3
bsr findnam
tst.b d7
beq.s pi1
move.l d0,a1
move.l savedat,d0
and.l 18(a1),d0
CALL Signal,SysBase(a4)
rts
;set up a list of tasknames which should't be displayed
hide cmp.b #10,0(a0)
bne.s hid5
bra syntax
hid5 lea hidestart(a4),a2
move.l a2,d3
hid0 tst.l 0(a2)
beq.s hid1
move.l 0(a2),a2
lea 4(a2),a1
bsr strcmp
tst d0
beq.s hid2
move.l a2,d3
bra.s hid0
hid1 move.l a0,a3
bsr strlen2
addq #5,d0
move.l #65536,d1
CALL AllocMem,SysBase(a4)
tst.l d0
beq.s hid4
move.l d0,a1
move.l d0,0(a2)
addq #4,a1
hid3 cmp.b #10,0(a3)
beq.s hid4
move.b (a3)+,(a1)+
bra.s hid3
hid4 rts
hid2 move.l d3,a3
move.l 0(a2),0(a3)
freehidden lea 4(a2),a0
bsr strlen
addq #5,d0
move.l a2,a1
CALL FreeMem,SysBase(a4)
rts
freehidmem move.l hidestart(a4),a3
fhm0 move.l a3,d0
beq.s fhm1
move.l a3,a2
move.l 0(a2),a3
bsr freehidden
bra fhm0
fhm1 rts
;set up an ALIAS list
alias cmp.b #10,0(a0)
beq showalias
bsr strbuf
move.l a0,a5
lea buffer,a0
bsr strlen
tst.l d0
beq syntax
moveq #1,d1
cmp d1,d0
bne.s 5$
lea params(a4),a0
moveq #parmnum-1,d1
move.b buffer,d2
6$ cmp.b (a0)+,d2
dbeq d1,6$
tst.w d1
bmi.s 5$
move.w #aliaserr,d0
bsr putstrw
move.w #params,d0
bsr putstrw
move.w #aliaserr2,d0
bra putnamw
5$ move.l d0,d5
move.l a5,a0
adda.l d0,a0
bsr kllblnks
move.l a5,-(a7)
bsr findcmd
move.l (a7)+,a5
tst.l d2
bmi syntax
move.l a5,a0
bsr strbuf
addq #6,d5
move.l d5,d0
move.l #65536,d1
CALL AllocMem,SysBase(a4)
tst.l d0
beq.s 1$
move.l aliaslist(a4),d1
bne.s 2$
move.l d0,aliaslist(a4)
bra.s 3$
2$ move.l d1,a0
move.l 0(a0),d1
bne.s 2$
move.l d0,0(a0)
3$ move.l d0,a0
move.b d2,4(a0)
lea 5(a0),a0
lea buffer,a1
4$ move.b (a1)+,(a0)+
bne.s 4$
1$ rts
showalias lea alhead(a4),a0
bsr puthead
move.l aliaslist(a4),d0
beq.s 1$
2$ move.l d0,a5
addq #5,d0
bsr putstr
move.w #15,d1
bsr tab
move.w #equal,d0
bsr putstrw
move.b 4(a5),d0
ext.w d0
bsr getcmdptr
bsr putnam
move.l 0(a5),d0
bne.s 2$
1$ rts
freealias move.l aliaslist(a4),a3
1$ move.l a3,d0
beq.s 2$
move.l a3,a2
move.l 0(a2),a3
lea 5(a2),a0
bsr strlen
addq #6,d0
move.l a2,a1
CALL FreeMem,SysBase(a4)
bra 1$
2$ rts
getcmdptr move.l a0,-(a7)
lea commds(a4),a0
2$ tst d0
beq.s 1$
3$ tst.b (a0)+
bne.s 3$
subq #1,d0
bra.s 2$
1$ move.l a0,d0
move.l (a7)+,a0
rts
;'flushlibs'
flush move.l #$ffffff,d0
moveq #0,d1
CALL AllocMem,SysBase(a4)
flsh1 rts
;display library->lib_IDString
info bsr nodenam2
moveq.l #2,d7
lea DevNode(PC),a3
bsr findnam
tst.b d7
beq.s flsh1
move.l d0,a0
move.l 24(a0),d0
beq.s if1
move.l #160,d1
move.l d0,a0
if3 tst.b (a0)+
dbeq.s d1,if3
beq.s if2
if1 move.w #noinfo,d0
bsr putstrw
move.l a5,d0
if2 bra putnam
capture move.l SysBase(a4),a1
lea 42(a1),a0
moveq #2,d6
lea coldtxt(a4),a3
cap0 move.l a3,d0
bsr putstr
move.l 0(a0),d0
bne.s cap1
move.w #unset,d0
bsr putstrw
bra cap2
cap1 bsr hexa
cap2 bsr newline
lea 15(a3),a3
addq #4,a0
dbf d6,cap0
move.w #kicktxt,d0
bsr putstrw
move.l 546(a1),a0
cmpa.l #0,a0
bne.s kickm3
move.w #unset,d0
bra putnamw
kickm3 move.l a0,-(a7)
bsr newline
lea kickhead(a4),a0
bsr puthead
move.l (a7)+,a0
kickm0 move.l a0,d0
beq kickm4
bpl.s kickm1
bclr #31,d0
move.l d0,a0
bra.s kickm0
kickm1 move.w 14(a0),d6
subq #1,d6
lea 16(a0),a2
kickm2 move.l 0(a2),d0
bsr hexa
move.l 0(a2),d0
move.l 4(a2),d4
add.l d4,d0
bsr hexa
move.l d4,d0
clr.b d3
bsr longdec
bsr newline
addq #8,a2
dbf d6,kickm2
move.l 0(a0),a0
bra kickm0
kickm4 rts
clrcold move.l SysBase(a4),a0
clr.l 42(a0)
bra.s chksum
clrcool move.l SysBase(a4),a0
clr.l 46(a0)
bra.s chksum
clrwarm move.l SysBase(a4),a0
clr.l 50(a0)
chksum lea 34(a0),a1
move #22,d0
addchk add (a1)+,d1
dbf d0,addchk
not d1
move.w d1,82(a0)
rts
;Save the command line to be repeated. If this line doesn't produce
;any output, don't repeat it at all
repeatcmd tst.w repeat(a4)
bne.s 2$
move.w repeatlen(a4),d0
subq #7,d0
move.w d0,repeatlen(a4)
lea repeatbuffer,a1
lea dummy,a2
move.w d0,d1
ext.l d1
1$ move.b 0(a0),(a1)+
move.b (a0)+,(a2)+
dbf d1,1$
clr.l lastprinted(a4)
clr.b printed(a4)
move.w #1,repeat(a4)
bsr cli
tst.b printed(a4)
beq.s 2$
bsr starttimer
rts
2$ clr.w repeat(a4)
rts
;save the parameters from a 'window x y width height' call
setwindow tst.b fromfile(a4)
bne.s wiw1
wiw3 move.w #wiwerr,d0
bra putnamw
wiw1 lea window_l(a4),a3
moveq #3,d5
wiw0 bsr getnum
tst d7
beq.s wiw2
move.w d2,0(a3)
addq #2,a3
dbf d5,wiw0
wiw2 rts
iconpos bsr getnum
tst d7
beq.s 1$
move.w d2,icnwindow
bsr getnum
tst d7
beq.s 1$
move.w d2,icnwindow+2
1$ rts
;display ExecBase->LastAlert
lastalert movem.l $100,d1-d2
tst.l d1
bne.s al1
move.l SysBase(a4),a0
movem.l 514(a0),d1-d2
al1 move.w #gurutxt,d0
bsr putstrw
move.l d1,d0
bsr hexa
subq.l #1,ptr
moveq #'.',d0
bsr putchar
move.l d2,d0
bsr hexa
bra newline
;test if 'on' or 'off' was entered
onoff bsr kllblnks
lea onstr(a4),a1
bsr strcmp
tst d0
bne.s 1$
bset.b #0,0(a2)
bra.s 3$
1$ lea offstr(a4),a1
bsr strcmp
tst d0
bne.s 2$
clr.b 0(a2)
bra.s 3$
2$ bchg.b #0,0(a2)
3$ rts
;toggle TaskInfo
taskinfo lea tinfo(a4),a2
bra.s onoff
;toggle CLI-Commands
clicmd lea cmdcli(a4),a2
bra.s onoff
;toggle task-header display on/off
nohead lea headon(a4),a2
bra.s onoff
;toggle hide entries on/off
hidden lea hideoff(a4),a2
bra.s onoff
;toggle sort on/off
sort lea sorton(a4),a2
bra.s onoff
;toggle task-ports display on/off
taskports lea tports(a4),a2
bra.s onoff
;toggle CPUSE task list
usage lea usageflag(a4),a2
bra.s onoff
;Open a library
openlib bsr nodenam2
move.l a5,a1
moveq #0,d0
CALL OpenLibrary,SysBase(a4)
tst.l d0
beq fn5
opli1 rts
;close it
closelib bsr nodenam2
moveq #0,d7
lea LibNode(PC),a3
bsr findnam
tst.b d7
beq.s opli1
move.l d0,a1
CALL CloseLibrary,SysBase(a4)
rts
remnode bsr nodenam2
moveq #7,d7
lea TReNode(PC),a3
bsr findnam
tst.b d7
beq.s 1$
CALL Disable,SysBase(a4)
move.l d0,a1
RECALL Remove
RECALL Enable
1$ rts
remport bsr nodenam2
moveq #0,d7
lea PorNode(PC),a3
bsr findnam
tst.b d7
beq.s 1$
move.l d0,a1
move.b #2,14(a1)
CALL RemPort,SysBase(a4)
1$ rts
remintserver
move.l a0,-(a7)
bsr readhex
tst.b d7
beq syntax
move.l d0,d4
moveq #1,d6
bsr findint
move.l (a7)+,a5
tst d5
bpl.s 1$
bra fn5
1$ tst.b 0(a3,d1)
bne.s 2$
move.w #nintrserv,d0
bra putnamw
2$ move.l d4,a1
move.w d1,d0
CALL RemIntServer,SysBase(a4)
rts
closeports movem.l d1-d6/a0-a6,-(a7)
move.l d0,d6
move.l SysBase(a4),a3
lea 392(a3),a3
1$ move.l 0(a3),a3
tst.l 0(a3)
beq.s 2$
cmp.l 16(a3),d6
bne.s 1$
move.b #2,14(a1)
move.l a3,a1
CALL RemPort,SysBase(a4)
bra.s 1$
2$ movem.l (a7)+,d1-d6/a0-a6
rts
;end Xoper but stay in background
quithold lea in,a0
lea dummy,a1
qh1 move.b (a1)+,d0
move.b d0,(a0)+
cmp.b #10,d0
bne.s qh1
instback tst.b background(a4)
bne.s cleanit
move.b #1,background(a4)
bsr installh
cleanit move.l infile(a4),d1
beq.s ib1
CALL Close,dosbase(a4)
clr.l infile(a4)
clr.b fromfile(a4)
ib1 clr.b running(a4)
bsr killpage
bsr freeblank
tst.l wnptr(a4)
beq.s 5$
tst.b ownscreen(a4)
bne.s 6$
move.l wnptr(a4),a0
tst.b post_V34(a4)
beq.s 7$
move.l minwsize(a4),d0
cmp.w 10(a0),d0
bgt.s 7$
swap d0
cmp.w 8(a0),d0
beq.s 6$
7$ move.l 4(a0),window_l(a4)
move.l 8(a0),window_w(a4)
6$ move.l wnptr(a4),a0
CALL CloseWindow,intuibase(a4)
clr.l intuimsg(a4)
clr.l wnptr(a4)
5$ move.l screenptr(a4),d0
beq.s 4$
move.l d0,a0
CALL CloseScreen,intuibase(a4)
clr.l screenptr(a4)
move.l realstack(a4),a7
4$ tst.b iconifyon(a4)
beq.s 1$
jsr iconify
bra.s 2$
1$ move.l #(1<<mysignal),d0
or.l trapsignal(a4),d0
CALL Wait,SysBase(a4)
2$ move.b #1,running(a4)
and.l trapsignal(a4),d0
beq.s 3$
move.b #1,gotguru(a4)
3$ bra restart
;fill all unused memory-chunks with a longword
clear moveq #0,d0
cmp.b #10,0(a0)
beq.s clr5
bsr readhex
tst.b d7
beq syntax
clr5 move.l SysBase(a4),a0
clr.l parmtxt(a4)
lea 322(a0),a0
move.w #$4000,$dff09a
clr1 move.l 0(a0),a0
tst.l 0(a0)
beq.s clr6
move.l 16(a0),a1
clr2 tst.l 0(a1)
beq.s clr1
addq.l #1,parmtxt(a4)
move.l 4(a1),d1
subq.l #8,d1
ble.s clr31
lsr.l #2,d1
subq.l #1,d1
bmi.s clr31
lea 8(a1),a2
clr3 move.l d0,(a2)+
dbf d1,clr3
clr31 move.l 0(a1),a1
bra.s clr2
clr6 move.w #-$4000,$dff09a
move.l parmtxt(a4),d0
bsr longdec
move.w #clrtxt,d0
bra putnamw
;change the number of maximum lines in the history buffer
historylines
bsr getnum
tst.b d7
beq syntax
move.w d2,maxhlines(a4)
move.w hnum(a4),d0
1$ cmp.w maxhlines(a4),d0
ble.s 2$
bsr remhistline
subq #1,d0
bra.s 1$
2$ move.l history+8(a4),curhist(a4)
move.w d0,hnum(a4)
rts
;set the minimum number of characters a input line
;must have to be added to the history buffer
historylength
bsr getnum
tst.b d7
beq syntax
tst.b d2
bne.s 1$
addq #1,d2
1$ move.w d2,minnumchars(a4)
rts
;display all lines in the history buffer
showhistory move.l history(a4),a5
moveq #1,d5
1$ tst.l 0(a5)
beq.s 2$
move.l d5,d3
bsr bytedec
move.w 8(a5),d0
ext.l d0
lea 10(a5),a0
lea inputbuffer,a1
CALL CopyMem,SysBase(a4)
move.w 8(a5),d0
lea inputbuffer,a1
clr.b 0(a1,d0.w)
move.l a1,d0
bsr putnam
addq #1,d5
move.l 0(a5),a5
bra.s 1$
2$ rts
;set the maximum lines the output buffer may hold
outputlines bsr getnum
tst.b d7
beq syntax
moveq #100,d3
tst.l d2
bmi.s 2$
cmp.l d3,d2
bge.s 1$
2$ move.l d3,d2
1$ move.l d2,maxlines(a4)
rts
;find a named node
;d7 = number of lists to search through
;a3 = pointer to the first entry in the
; list-offset-table
;a5 = pointer to name
;returns:
;d7 = TRUE/FALSE 1/0
;d0 = node
findnam tst.b 0(a5)
bne.s 1$
move.w #nameerr,d0
bsr putnamw
bra fnerr
1$ cmp.b #'$',0(a5)
bne.s fn2
move.l d7,d2
move.l a5,a0
bsr readhex
tst.b d7
beq.s fn6
move.l d2,d7
bsr tstnode
tst.l d5
bne.s fn3
bra fn5
fn6 move.l d2,d7
fn2 move.l SysBase(a4),a0
adda.l 0(a3),a0
move.l a5,a1
fn4 CALL FindName,SysBase(a4)
tst.l d0
bne.s fn1
addq #4,a3
dbf d7,fn2
fn5 move.w #namerr,d0
bsr putstrw
move.l a5,d0
bsr putnam
fnerr clr.b d7
rts
fn1 move.b procnum(a4),d2
beq.s fn3
move.l d0,a0
cmp.b 143(a0),d2
bne.s fn4
fn3 moveq.l #1,d7
rts
;list-offset-table
TRuNode dc.l 276
TReNode dc.l 406
TWaNode dc.l 420
DevNode dc.l 350
LibNode dc.l 378
ResNode dc.l 336
MemNode dc.l 322
PorNode dc.l 392
SemNode dc.l 532
;Node has been entered in hex. Check if this node exsists
tstnode tst.b fromfile(a4)
bne.s illegalhex
move.l d0,d1
btst #0,d1
beq.s inrange
move.w #adrerr,d0
bsr putnamw
illegalhex moveq #0,d5
rts
inrange movem.l d7/a3,-(a7)
cmp.l #TRuNode,a3
bne.s inrange1
move.l SysBase(a4),a0
cmp.l 276(a0),d0
beq.s nodefound
subq #1,d7
addq #4,a3
inrange1 move.w #$4000,$dff09a
getlist move.l SysBase(a4),a0
add.l 0(a3),a0
nxtnode tst.l 0(a0)
beq.s nxtlist
cmp.l a0,d0
beq.s nodefound
move.l 0(a0),a0
bra.s nxtnode
nxtlist addq #4,a3
dbf d7,getlist
move.w #-$4000,$dff09a
movem.l d0/d7/a3,-(a7)
bsr ResumeOutput
move.w #noderr,d0
bsr putnamw
bsr readline
movem.l (a7)+,d0/d7/a3
cmp.b #'y',inputbuffer
beq.s nodefound1
moveq #0,d5
movem.l (a7)+,d7/a3
rts
nodefound move.w #-$4000,$dff09a
nodefound1 move.b #1,d5
etst movem.l (a7)+,d7/a0
rts
;allocate FileInfoBlock
allocfinfo addq.b #1,finfopen(a4)
bne.s 1$
move.l #260,d0
moveq #0,d1
CALL AllocMem,SysBase(a4)
move.l d0,finfoptr(a4)
1$ rts
;free FileInfoBlock
freefinfo subq.b #1,finfopen(a4)
bpl.s 1$
move.l #260,d0
move.l finfoptr(a4),d1
beq.s 1$
move.l d1,a1
CALL FreeMem,SysBase(a4)
clr.l finfoptr(a4)
1$ rts
;Examine ,d0=Lock
getfinfo move.l d0,d1
move.l finfoptr(a4),d2
CALL Examine,dosbase(a4)
rts
;construct a Pathname from a lock
;d0=Lock ,resulting string is written to window
getpath movem.l d1-d7/a0-a6,-(a7)
move.l d0,d1
beq.s 1$
CALL DupLock,dosbase(a4)
1$ lea out,a3
clr.b -(a3)
gp0 move.l d0,-(a7)
bsr getfinfo
move.l finfoptr(a4),a0
move.l 4(a0),d4
addq #8,a0
bsr strlen
lea -1(a3),a5
tst.l d4
bmi.s nodir
move.b #'/',-(a3)
nodir subq #1,d0
bmi.s nofnam
gp1 move.b 0(a0,d0),-(a3)
dbf d0,gp1
nofnam move.l 0(a7),d1
CALL ParentDir,dosbase(a4)
move.l d0,d4
move.l (a7)+,d1
beq.s 2$
CALL UnLock,dosbase(a4)
2$ move.l d4,d0
bne.s gp0
cmp.b #'/',0(a5)
bne.s gp2
move.b #':',0(a5)
gp2 move.l a3,d0
bsr putnam
movem.l (a7)+,d1-d7/a0-a6
rts
strlen move.l a0,-(a7)
moveq #-1,d0
strl2 addq.l #1,d0
tst.b (a0)+
bne.s strl2
move.l (a7)+,a0
rts
strlen2 move.l a0,-(a7)
move.l #-1,d0
strl22 addq.l #1,d0
cmp.b #10,(a0)+
bne.s strl22
move.l (a7)+,a0
rts
;write a title and underline
;a0 = pointer to text
puthead1 bsr strlen
move.l d0,d5
move.l a0,d0
bra putstr
puthead2 bsr strlen
add.l d0,d5
bra.s ph2
puthead bsr strlen
move.l d0,d5
ph2 move.l a0,d0
bsr putnam
lea out,a0
move.l a0,d0
ph1 move.b #'-',(a0)+
dbf d5,ph1
move.b #$0a,(a0)+
clr.b 0(a0)
bra putstr
;move cursor to a column
;d0 = current position
;d1 = column
tab move.l a3,-(a7)
lea out,a3
sp5 cmp.b d1,d0
bcc.s sp4
move.b #' ',0(a3,d0)
addq.b #1,d0
bra.s sp5
sp4 move.l d1,ptr(a4)
move.l (a7)+,a3
rts
;convert ascii to byte
;a0 = pointer to text
;d0 = byte
getnum cmp.b #'$',0(a0)
bne.s isdec
bsr readhex
move.l d0,d2
rts
isdec moveq #0,d2
move.l d2,d3
move.l d2,d6
move.l d2,d7
cmp.b #'-',0(a0)
bne.s gn1
addq #1,a0
moveq.l #1,d6
gn1 move.b (a0)+,d3
cmp.b #'9',d3
bhi.s gn2
cmp.b #'0',d3
bcs.s gn2
moveq #1,d7
and.b #$f,d3
muls #10,d2
add.l d3,d2
bra.s gn1
gn2 tst.b d6
beq.s gn3
neg.l d2
gn3 tst.b d7
bne.s gn4
subq #1,a0
gn4 rts
getfrac cmp.b #'.',0(a0)
bne.s 2$
lea 1(a0),a0
bra.s 3$
2$ bsr isdec
muls #10,d2
cmp.b #'.',-1(a0)
bne.s 1$
3$ moveq #0,d0
move.b (a0)+,d1
cmp.b #10,d1
beq.s 1$
and.b #15,d1
add.l d1,d2
1$ rts
;convert hex to longword
;a0 = pointer to text
;returns d0=value
;d7 = ok/error 1/0
readhex movem.l d1-d6/a1-a5,-(a7)
moveq #1,d7
cmp.b #'$',0(a0)
bne.s rh3
addq #1,a0
rh3 moveq #0,d0
cmpi.b #10,0(a0)
beq.s rherr
lea hextab(a4),a1
rh0 move.b (a0)+,d3
moveq.l #15,d2
rh1 cmp.b 0(a1,d2),d3
beq.s rh2
dbf d2,rh1
bra rhend
rh2 lsl.l #4,d0
or.b d2,d0
bra.s rh0
rhend tst.b d3
beq.s rhok
cmpi.b #10,d3
beq.s rhok
cmpi.b #' ',d3
beq.s rhok
rherr moveq #0,d7
rhok movem.l (a7)+,d1-d6/a1-a5
rts
;skip blanks
;a0 pointer to text
; returns a0 = new pointer position
kllblnks cmpi.b #' ',0(a0)
bne.s gn4
addq #1,a0
bra.s kllblnks
; exit program. If background flag is set, wait for
; amiga-amiga-x
stopall addq #4,a7
bra exitall
exit tst.b background(a4)
bne quithold
exitall bsr killpage
bsr freeblank
bsr killhistory
move.l stplist(a4),a3
tst.l 0(a3)
beq.s ex0
move.l a3,d0
bsr waok
bra.s exitall
ex0 tst.b background(a4)
beq.s ex1
bsr removeh
ex1 move.l SysBase(a4),a1
move.l #_LVOSwitch,a0
move.l oldswitch,d0
CALL SetFunction,a1
moveq #3,d0
lea IOCounter(a4),a1
RECALL RemIntServer
move.l replyport(a4),-(a7)
LIBCALL DeletePort
addq #4,a7
bsr stoptimer
lea timerio,a1
CALL CloseDevice,SysBase(a4)
move.l timerport(a4),-(a7)
LIBCALL DeletePort
addq #4,a7
tst.b post_V34(a4)
bne.s 1$
lea sampleio(a4),a1
CALL AbortIO,SysBase(a4)
lea sampleio(a4),a1
move.l 14(a1),d7
CALL CloseDevice,SysBase(a4)
move.l d7,-(a7)
LIBCALL DeletePort
addq #4,a7
1$ move.l idletask(a4),a1
CALL RemTask,SysBase(a4)
move.l #_LVOAddTask,a0
move.l OldAddTask(PC),d0
move.l SysBase(a4),a1
CALL SetFunction,SysBase(a4)
bsr restoretrap
tst.l wnptr(a4)
beq.s 5$
move.l wnptr(a4),a0
CALL CloseWindow,intuibase(a4)
5$ move.l screenptr(a4),d0
beq.s 6$
move.l d0,a0
CALL CloseScreen,intuibase(a4)
clr.l screenptr(a4)
6$ move.l infile(a4),d1
beq.s ex11
CALL Close,dosbase(a4)
ex11 bsr freehidmem
bsr freealias
bsr clrfkeys
move.l realstack(a4),a7
IFND DEBUG
CALL Forbid,SysBase(a4)
move.l wbmsg(a4),d0
beq.s todos
move.l d0,a1
RECALL ReplyMsg
moveq #0,d0
rts
todos move.l mytask(a4),a0
move.l 152(a0),d1
CALL UnLock,dosbase(a4)
move.l myseg(a4),d1
CALL UnLoadSeg,dosbase(a4)
ENDC
moveq #0,d0
rts
;print a bcpl-string
;d0 = bcpl-pointer to bcpl-string
putbcpl movem.l d3/a0-a1,-(a7)
tst.l d0
beq.s 1$
lsl.l #2,d0
move.l d0,a1
moveq #0,d3
move.b (a1)+,d3
subq #1,d3
bmi.s 1$
2$ move.b (a1)+,d0
beq.s 1$
bsr putchar
dbf d3,2$
1$ move.l ptr(a4),d0
movem.l (a7)+,d3/a0-a1
rts
;compare strings
;a0/a1 = pointers to string
;returns d0 = true(0) false(1), d1 = length
strcmp movem.l a0-a1,-(a7)
moveq #0,d0
move.l d0,d1
src2 move.b (a0)+,d0
beq.s src1
cmp.b #10,d0
beq.s src1
addq #1,d1
cmp.b (a1)+,d0
beq.s src2
bra.s src3
src1 move.b 0(a1),d0
src3 movem.l (a7)+,a0-a1
rts
strbuf movem.l d0/a1-a2,-(a7)
move.l a0,a1
lea buffer,a2
1$ move.b (a1)+,d0
cmp.b #10,d0
beq.s 2$
cmp.b #' ',d0
beq.s 2$
or.b #' ',d0
beq.s 2$
move.b d0,(a2)+
bra.s 1$
2$ clr.b (a2)+
movem.l (a7)+,d0/a1-a2
rts
tolower movem.l d0-d1/a0,-(a7)
subq #1,d0
bmi.s 3$
1$ move.b 0(a0),d1
cmp.b #'A',d1
blt.s 2$
cmp.b #'Z',d1
bgt.s 2$
or.b #' ',d1
2$ move.b d1,(a0)+
dbf d0,1$
3$ movem.l (a7)+,d0-d1/a0
rts
;compare bcpl string with string
;a0 = pointer to string
;a2 = bcpl-pointer to bcpl-string
;returns d0 = true(0) false(1)
strbcmp movem.l d1/a0/a2,-(a7)
moveq #0,d0
moveq #0,d1
adda.l a2,a2
adda.l a2,a2
move.b (a2)+,d1
beq.s stb1
subq #1,d1
stb2 cmp.b (a2)+,(a0)+
bne.s stb1
dbf d1,stb2
moveq #1,d0
stb1 movem.l (a7)+,d1/a0/a2
rts
;add a fkey definition to the fkey list. Each entry
;looks like this: long Succ, long Pred, byte Key#, byte length,
; char text[]
showfkeys lea fkhead(a4),a0
bsr puthead
lea fkeys(a4),a1
1$ move.l 0(a1),a1
tst.l 0(a1)
beq.s 2$
moveq #'F',d0
bsr putchar
move.b 8(a1),d3
bsr bytedec
move.b 9(a1),d1
subq #1,d1
lea 10(a1),a2
3$ move.b (a2)+,d0
bsr putchar
dbf d1,3$
bsr newline
bra.s 1$
2$ rts
setfkey bsr nodenam
move.b procnum(a4),d5
beq.s showfkeys
cmp.b #21,d5
bge syntax
subq #1,d5
move.b d5,procnum(a4)
lea fkeys(a4),a1
1$ move.l 0(a1),a1
tst.l 0(a1)
beq.s 2$
cmp.b 8(a1),d5
bne.s 1$
move.l a1,d3
CALL Remove,SysBase(a4)
move.l d3,a1
bsr removefkey
2$ tst.b 0(a5)
beq.s 4$
move.l a5,a0
bsr strlen
move.l d0,d5
add.w #10,d0
moveq #0,d1
CALL AllocMem,SysBase(a4)
tst.l d0
beq.s 4$
move.l d0,a1
move.l d0,a3
move.b procnum(a4),8(a1)
move.b d5,9(a1)
lea fkeys(a4),a0
CALL AddHead,SysBase(a4)
lea 10(a3),a3
subq #1,d5
3$ move.b (a5)+,(a3)+
dbeq d5,3$
4$ rts
clrfkeys lea fkeys(a4),a0
CALL RemHead,SysBase(a4)
tst.l d0
beq.s 1$
move.l d0,a1
bsr removefkey
bra.s clrfkeys
1$ rts
removefkey move.b 0(a1),d0
ext.w d0
ext.l d0
add.w #10,d0
CALL FreeMem,SysBase(a4)
rts
;convert long to decimal
;d0 = value
;d3 bit 0 = left/right justified
;d3 bit 1 = write/leave
;returns string in 'buffer'
longdec movem.l d1-d2/a1-a2,-(a7)
tst.l d0
bmi.s 2$
cmp.l #9999999,d0
ble.s 1$
2$ move.w #smallnix,d0
bra.s ld6
1$ lea binarea+8(a4),a1
move.l #' ',-8(a1)
move.l #' ',-4(a1)
clr.b 0(a1)
subq #1,a1
cmp #2,d3
bne.s ld5
clr.b 0(a1)
ld5 moveq #1,d2
ld2 addq #1,d2
moveq #$a,d1
bsr div
addi.l #$30,d1
move.b d1,-(a1)
tst.l d0
bne.s ld2
btst #0,d3
bne.s ld1
lea binarea(a4),a2
cmpa.l a2,a1
bne.s ld3
subq.l #1,ptr(a4)
bra.s ld1
ld3 move.b 0(a1),(a2)+
move.b #' ',(a1)+
dbf d2,ld3
ld1 btst #1,d3
bne.s ld4
move.w #binarea,d0
ld6 bsr putstrw
ld4 movem.l (a7)+,d1-d2/a1-a2
rts
;write UBYTE
;d3 = value
bytedec bsr dec
move.w #decimal,d0
bra.s pm1
;write signed byte
;d3 = value
plusmins movem.l d5/a3,-(a7)
move.w #$2020,minus(a4)
move.b d3,d5
bpl.s 2$
neg.b d3
2$ bsr.s dec
tst.b d5
bpl.s 1$
move.l d0,a3
move.b #'-',-(a3)
1$ movem.l (a7)+,d5/a3
move.w #minus+1,d0
pm1 bra putstrw
dec movem.l d3/a3,-(a7)
move.l #$20202020,decimal(a4)
and.l #$ff,d3
lea decimal+3(a4),a3
bloop tst.b d3
beq.s bend
divu #10,d3
swap d3
ori.b #'0',d3
move.b d3,-(a3)
clr.w d3
swap d3
bra.s bloop
bend cmpa.l #decimal+3+dataarea,a3
bne 1$
move.b #'0',-(a3)
1$ move.l a3,d0
movem.l (a7)+,d3/a3
rts
;write a string, move cursor into next line
;d0 = pointer to text
putnamw bsr putstrw
bra.s putnam1
putnam bsr putstr
putnam1 tst.b d0
beq.s ncr
bsr newline
ncr rts
putblank moveq #' ',d0
;write one char
;d0 = char
putchar movem.l d1/a0,-(a7)
move.l ptr(a4),d1
lea out,a0
move.b d0,0(a0,d1)
addq.l #1,ptr(a4)
movem.l (a7)+,d1/a0
rts
;write a string, strings are only put into the output buffer when
;a LF is detected
;d0 = pointer to string
;returns d0 = cursor position
putstrw and.l #$0000ffff,d0
add.l #dataarea,d0
putstr movem.l d1-d7/a0-a6,-(a7)
move.b #1,printed(a4)
move.l d0,a2
lea out,a3
move.l ptr(a4),d0
move.l a2,d5
bne pst1
lea longnix(a4),a2
pst1 move.b (a2)+,d1
cmpi.b #13,d1
beq pst1
cmpi.b #10,d1
beq.s lineend
move.b d1,0(a3,d0)
beq prend
cmp #100,d0
bge.s pst1
addq #1,d0
bra.s pst1
lineend tst.b fromfile(a4)
beq.s 1$
moveq #0,d0
bra prend
1$ tst.l lastprinted(a4)
bne.s 2$
bsr killpage
2$ addq #1,d0
move.l d0,-(a7)
add #14,d0
moveq #0,d1
CALL AllocMem,SysBase(a4)
move.l (a7)+,d1
tst.l d0
beq prend
move.l d0,a0
move.w d1,12(a0)
cmp.w maxllength(a4),d1
ble.s 7$
move.w d1,maxllength(a4)
7$ move.l node(a4),8(a0)
clr.l node(a4)
clr.l 0(a0)
move.l lastprinted(a4),d0
move.l d0,4(a0)
bne.s 3$
move.l a0,outchain(a4)
bra.s 4$
3$ move.l d0,a1
move.l a0,0(a1)
4$ move.l a0,lastprinted(a4)
move.b #' ',14(a0)
subq #1,d1
lea 15(a0),a0
lea out,a1
subq #1,d1
bmi.s 6$
5$ move.b (a1)+,(a0)+
dbf d1,5$
6$ move.l numlines(a4),d2
cmp.l maxlines(a4),d2
ble.s 8$
move.l outchain(a4),a1
move.l 0(a1),a2
move.l a2,outchain(a4)
clr.l 4(a2)
move.w 12(a1),d0
add.w #14,d0
ext.l d0
CALL FreeMem,SysBase(a4)
bra.s 9$
8$ addq.l #1,d2
move.l d2,numlines(a4)
9$ moveq #0,d0
move.l d0,d5
tst.b addlines(a4)
beq pst1
bsr addline
bra pst1
prend move.l d0,ptr(a4)
movem.l (a7)+,d1-d7/a0-a6
rts
;Kill output buffer
killpage movem.l d0-d7/a0-a6,-(a7)
tst.l outchain(a4)
beq.s 2$
move.l outchain(a4),a1
bsr killlines
clr.l outchain(a4)
clr.l lastprinted(a4)
clr.l numlines(a4)
clr.w maxllength(a4)
2$ movem.l (a7)+,d0-d7/a0-a6
rts
;kill the remainder of the output buffer
killlines move.l 0(a1),-(a7)
move.w 12(a1),d0
ext.l d0
add #14,d0
CALL FreeMem,SysBase(a4)
move.l (a7)+,a1
move.l a1,d7
bne.s killlines
rts
freeblank move.l blanks(a4),d0
beq.s 1$
move.l d0,a1
move.w colms(a4),d0
ext.l d0
CALL FreeMem,SysBase(a4)
clr.l blanks(a4)
1$ rts
;write a portion of the output buffer to the screen
blastout move.l rastport(a4),a1
moveq #1,d0
CALL SetAPen,gfxbase(a4)
move.l rastport(a4),a1
moveq #1,d0
CALL SetDrMd,gfxbase(a4)
moveq #0,d7
move.w loffset(a4),d2
beq.s 7$
move.w colms(a4),d4
add.w d4,d2
move.w maxllength(a4),d3
cmp.w d3,d2
ble.s 7$
move.w d3,d2
sub.w d4,d2
bpl.s 8$
moveq #0,d2
8$ move.w d2,loffset(a4)
7$ bsr tstfirstlin
1$ tst.l outchain(a4)
beq.s 3$
bsr findline
2$ move.w colms(a4),d5
ext.l d5
move.w loffset(a4),d4
ext.l d4
moveq #18,d6
6$ lea 14(a5,d4),a0
move.w 12(a5),d3
ext.l d3
bsr blastline
blt.s 9$
move.w rows(a4),currenty(a4)
bra.s 5$
9$ tst.l 0(a5)
beq.s 5$
move.l 0(a5),a5
bra 6$
5$ cmp.w rows(a4),d7
bcc.s 3$
10$ moveq #0,d3
bsr blastline
bcs.s 10$
3$ bset.b #1,propupdate(a4)
rts
;get a pointer to a line (line # in d0)
findline move.l outchain(a4),d1
beq 2$
move.l d1,a5
1$ tst d0
beq.s 2$
tst.l 0(a5)
beq.s 2$
move.l 0(a5),a5
dbf d0,1$
2$ rts
;check if the display is as 'full' as possible
tstfirstlin move.l firstline(a4),d0
move.l d0,d2
add.w rows(a4),d2
cmp.l numlines(a4),d2
bmi.s 1$
move.l numlines(a4),d2
sub.w rows(a4),d2
bpl.s 4$
moveq #0,d2
4$ move.l d2,d0
move.l d2,firstline(a4)
1$ rts
;display one line, fill the gap between the end of the line and
;the end of the window with spaces.
;d6 = ypos, d5=colms, d3= linelength, d7= line # in window, a0 = text
blastline move d6,d1
moveq #6,d0
move.l rastport(a4),a1
CALL Move,gfxbase(a4)
sub.w d4,d3
bpl.s 7$
moveq #0,d3
bra.s 6$
7$ cmp.w d5,d3
bmi.s 4$
move.w d5,d3
4$ move.l d3,d0
beq.s 6$
move.l rastport(a4),a1
CALL Text,gfxbase(a4)
6$ move.l d5,d0
sub.l d3,d0
ble.s 5$
move.l blanks(a4),a0
move.l rastport(a4),a1
CALL Text,gfxbase(a4)
5$ addq #8,d6
addq #1,d7
cmp.w rows(a4),d7
rts
;Write pointer, display '-------' if empty
hexan tst.l d0
beq putstr
;Write 8 byte hex value
;d0 = value
hexa bsr gthex
bra putstr
gthex movem.l d1-d7/a0-a6,-(a7)
moveq.l #7,d5
lea hexarea(a4),a1
lea hextab(a4),a0
moveq #0,d2
hexloop move.b d0,d2
and.b #15,d2
move.b 0(a0,d2),0(a1,d5)
lsr.l #4,d0
dbf d5,hexloop
move.l a1,d0
movem.l (a7)+,d1-d7/a0-a6
rts
;Convert/write byte into binary string
;d0 = value
bin movem.l d1-d7/a0-a6,-(a7)
lea binarea(a4),a0
move.w #$2020,8(a0)
moveq.l #7,d4
binloop moveq.l #'0'/2,d1
roxr.b #1,d0
roxl.b #1,d1
move.b d1,0(a0,d4)
dbf d4,binloop
move.l a0,d0
movem.l (a7)+,d1-d7/a0-a6
bra putstr
;send a packet
;a0 = msgport
;dp_Type and dp_Arg1 have to be inizialized
cons1 movem.l d0-d7/a0-a6,-(a7)
move.l #dp_Link,LN_NAME
move.l #mypacket,dp_Link
move.l replyport(a4),dp_Port
lea mypacket,a1
CALL PutMsg,SysBase(a4)
move.l replyport(a4),a0
CALL WaitPort,SysBase(a4)
move.l replyport(a4),a0
CALL GetMsg,SysBase(a4)
movem.l (a7)+,d0-d7/a0-a6
rts
;32-bit division
;d0 / d1
;returns d0
div movem.l d2-d3,-(a7)
tst.l d1
beq div8
swap d1
move.w d1,d2
bne.s div1
swap d0
swap d1
swap d2
move.w d0,d2
beq.s div2
divu d1,d2
move.w d2,d0
div2 swap d0
move.w d0,d2
divu d1,d2
move.w d2,d0
swap d2
move.w d2,d1
bra div8
div1 moveq #$10,d3
cmpi.w #$80,d1
bcc.s div3
rol.l #8,d1
subq.w #8,d3
div3 cmpi.w #$800,d1
bcc.s div4
rol.l #4,d1
subq.w #4,d3
div4 cmpi.w #$2000,d1
bcc.s div5
rol.l #2,d1
subq.w #2,d3
div5 tst.w d1
bmi.s div6
rol.l #1,d1
subq.w #1,d3
div6 move.w d0,d2
lsr.l d3,d0
swap d2
clr.w d2
lsr.l d3,d2
swap d3
divu d1,d0
move.w d0,d3
move.w d2,d0
move.w d3,d2
swap d1
mulu d1,d2
sub.l d2,d0
bcc.s div7
subq.w #1,d3
add.l d1,d0
div7 moveq #0,d1
move.w d3,d1
swap d3
rol.l d3,d0
swap d0
exg d1,d0
div8 movem.l (a7)+,d2-d3
rts
;install a input-handler
installh pea 0
pea xopsleep(a4)
LIBCALL CreatePort
addq #8,a7
move.l d0,InputMsg(a4)
move.l d0,-(a7)
LIBCALL CreateStdIO
addq #4,a7
move.l d0,InRequest(a4)
move.l d0,a1
lea devicenam(a4),a0
moveq #0,d0
moveq #0,d1
CALL OpenDevice,SysBase(a4)
move.l d0,devstatus(a4)
movea.l InRequest(a4),a1
move.l #InInterrupt+dataarea,40(a1)
move.w #9,28(a1)
CALL DoIO,SysBase(a4)
move.l d0,iostatus(a4)
rts
;remove handler
removeh movea.l InRequest(a4),a1
move.l #InInterrupt+dataarea,40(a1)
move.w #10,28(a1)
CALL DoIO,SysBase(a4)
movea.l InRequest(a4),a1
CALL CloseDevice,SysBase(a4)
move.l InRequest(a4),-(a7)
LIBCALL DeleteStdIO
addq #4,a7
move.l InputMsg(a4),-(a7)
LIBCALL DeletePort
addq #4,a7
rts
;this is the handler, it checks if amiga-amiga-x
;has been pressed and signals it to our task
Keyhandler tst.b running+dataarea
bne.s endhandler
cmp.b #1,4(a0)
bne.s endhandler
move.w 8(a0),d0
andi.w #$c0,d0
cmpi.w #$c0,d0
bne.s endhandler
cmp.w #$32,6(a0)
bne.s endhandler
wakeup move.l a0,-(a7)
movea.l mytask+dataarea,a1
move.l #(1<<mysignal),d0
CALL Signal,_SysBase(PC)
move.l (a7)+,a0
clr.b 4(a0)
endhandler move.l a0,d0
rts
snoop bsr cls
bsr nodenam
moveq #1,d7
lea TReNode(PC),a3
bsr findnam
tst.b d7
bne.s 1$
move.w #stperr,d0
bra putnamw
1$ move.l d0,captask(a4)
pea 0
pea memportname(a4)
LIBCALL CreatePort
addq #8,a7
move.l d0,snoopport(a4)
beq tm6
bsr replyintui
move.b #1,addlines(a4)
lea snoophead(a4),a0
bsr puthead
move.l SysBase(a4),a1
move.l -196(a1),oldalloc
move.l -208(a1),oldfree
move.l #capmalloc,d0
move.l #-198,a0
CALL SetFunction,SysBase(a4)
move.l SysBase(a4),a1
move.l #capmfree,d0
move.l #-210,a0
CALL SetFunction,SysBase(a4)
clr.b bool(a4)
clr.b cbreak(a4)
clr.b capgone(a4)
clr.b capwaiting(a4)
clr.l capiscli(a4)
move.l captask(a4),a1
cmp.b #13,8(a1) ;ln_Type
bne.s waitmem
tst.l 140(a1)
beq.s waitmem
move.l 172(a1),d0 ;pr_CLI
beq.s waitmem
lsl.l #2,d0
move.l d0,a0
lea 60(a0),a0
move.l a0,capiscli(a4)
move.l 0(a0),d0
move.l d0,capseg(a4)
bne.s waitmem
move.w #capwait,d0
bsr putnamw
bset.b #1,capwaiting(a4)
waitmem move.l snoopport(a4),a0
moveq #0,d1
move.b 15(a0),d1
bset d1,d0
move.l d0,auxsig(a4)
bsr processmsgs
tm7 move.l mytask(a4),a0
move.l snoopport(a4),a0
CALL GetMsg,SysBase(a4)
tst.l d0
bne tm8
tst.b cbreak(a4)
bne snoopend
tst.b capgone(a4)
bne snoopend
bra waitmem
tm8 move.l d0,a3
tst.b capwaiting(a4)
beq.s tm15
move.l capiscli(a4),d7
beq.s tm15
move.l d7,a0
move.l 0(a0),capseg(a4)
beq tm12
clr.b capwaiting(a4)
tm15 move.l 20(a3),d3
btst #31,d3
beq freed
move.w #allok,d0
bsr putstrw
lea memname(PC),a2
lea membit(PC),a1
moveq #4,d5
tm2 move.l 0(a1),d4
btst d4,d3
beq.s tm1
move.w 0(a2),d0
bsr putstrw
tm1 addq #2,a2
addq #4,a1
dbf d5,tm2
moveq #26,d1
bsr tab
move.l 24(a3),d0
move.l d0,d3
bsr hexa
move.l 28(a3),d0
bne.s tm3
move.w #failed,d0
bsr putstrw
moveq #53,d1
bsr tab
bra tm4
tm3 bsr hexa
move.l 28(a3),d0
add.l d3,d0
bsr hexa
bra tm4
freed move.w #free,d0
bsr putstrw
move.b #'-',d0
moveq #18,d1
tm9 bsr putchar
dbf d1,tm9
bsr putblank
move.l d3,d0
bsr hexa
move.l 24(a3),d0
bsr hexa
move.l 24(a3),d0
add.l d3,d0
bsr hexa
tm4 move.l 32(a3),d0
bsr hexa
bsr newline
tm12 bsr freemsg
move.l captask(a4),a1
tm13 tst.b capwaiting(a4)
bne.s tm10
move.l capiscli(a4),d0
beq.s 1$
move.l d0,a0
move.l 0(a0),d0
cmp.l capseg(a4),d0
bne.s tm11
1$ move.b 15(a1),d0
cmp.b #5,d0
bge.s tm11
cmp.b #2,d0
bge.s tm10
tm11 bset.b #1,capgone(a4)
tm10 bra tm7
snoopend move.l SysBase(a4),a1
move.l oldalloc(PC),d0
move.l #-198,a0
CALL SetFunction,SysBase(a4)
move.l SysBase(a4),a1
move.l oldfree,d0
move.l #-210,a0
CALL SetFunction,SysBase(a4)
move.l snoopport(a4),-(a7)
LIBCALL DeletePort
addq #4,a7
tst.b cbreak(a4)
bne.s 1$
move.w #capexited,d0
bra.s 2$
1$ move.w #stoped,d0
2$ bsr putnamw
clr.b addlines(a4)
clr.l auxsig(a4)
tm6 rts
memname dc.w memlarg,memclr,memfast,memchip,mempubl
membit dc.l 17,16,2,1,0
capmalloc movem.l d0-d7/a0-a6,-(a7)
lea dataarea(PC),a4
move.l SysBase(a4),a6
move.l 276(a6),d4
cmp.l captask(a4),d4
bne.s capm1
tst.b bool(a4)
bne capm1
move.b #1,bool
moveq #36,d6
bsr allocmsg
beq capm2
bset #31,d1
move.l d1,20(a5)
move.l d0,24(a5)
move.l 60(a7),32(a5)
move.l a5,remembr(a4)
movem.l (a7)+,d0-d7/a0-a6
bsr memalloc
movem.l d0-d7/a0-a6,-(a7)
lea dataarea(PC),a4
move.l remembr(a4),a1
move.l d0,28(a1)
move.l snoopport(a4),a0
move.b #5,8(a1)
CALL PutMsg,SysBase(a4)
clr.b bool(a4)
movem.l (a7)+,d0-d7/a0-a6
rts
capm2 clr.b bool(a4)
capm1 movem.l (a7)+,d0-d7/a0-a6
memalloc dc.w $4ef9
oldalloc dc.l 0
capmfree movem.l d0-d7/a0-a6,-(a7)
lea dataarea(PC),a4
move.l SysBase(a4),a6
move.l 276(a6),d4
cmp.l captask(a4),d4
bne.s capf1
tst.b bool(a4)
bne.s capf1
move.b #1,bool(a4)
moveq #36,d6
bsr allocmsg
beq.s capf2
move.l d0,20(a5)
move.l a1,24(a5)
move.l 60(a7),32(a5)
move.l snoopport(a4),a0
move.b #5,8(a5)
move.l a5,a1
CALL PutMsg,SysBase(a4)
capf2 clr.b bool(a4)
capf1 movem.l (a7)+,d0-d7/a0-a6
dc.w $4ef9
oldfree dc.l 0
allocmsg movem.l d0-d1/a0-a1,-(a7)
move.l d6,d0
move.l #65536,d1
tst.l oldalloc
bne.s 1$
CALL AllocMem,_SysBase(PC)
bra.s 2$
1$ bsr memalloc
2$ tst.l d0
beq.s alm1
move.l d0,a5
move.w d6,18(a5)
alm1 movem.l (a7)+,d0-d1/a0-a1
move.l a5,d6
rts
freemsg move.w 18(a3),d0
ext.l d0
move.l a3,a1
CALL FreeMem,SysBase(a4)
rts
tracelocks move.l #_LVOLock,d0
moveq #-11,d1
bra.s tracedos
snoopfiles move.l #_LVOOpen,d0
moveq #-1,d1
tracedos move.w d0,patchwhat(a4)
move.w d1,dosoffset(a4)
pea 0
pea memportname(a4)
LIBCALL CreatePort
addq #8,a7
move.l d0,snoopport(a4)
beq 10$
bsr replyintui
move.b #1,addlines(a4)
bsr cls
lea fileshead(a4),a0
bsr puthead
move.w patchwhat(a4),a0
move.l dosbase(a4),a1
tst.b post_V34(a4)
beq.s 1$
move.l 2(a1,a0.w),oldopen
move.l #myopen,d0
CALL SetFunction,SysBase(a4)
bra.s 2$
1$ CALL Forbid,SysBase(a4)
move.w 0(a1,a0.w),-(a7)
move.l 2(a1,a0.w),-(a7)
move.w #$4ef9,0(a1,a0.w)
move.l #myopen,2(a1,a0.w)
move.l #$c09d6e-$c09d20,d0
add.l dosbase(a4),d0
move.l d0,oldopen
RECALL Permit
clr.b cbreak(a4)
2$ move.l snoopport(a4),a0
moveq #0,d1
move.b 15(a0),d1
bset d1,d0
move.l d0,auxsig(a4)
bsr processmsgs
3$ move.l mytask(a4),a0
move.l snoopport(a4),a0
CALL GetMsg,SysBase(a4)
tst.l d0
bne 10$
tst.b cbreak(a4)
bne 7$
bra.s 2$
10$ move.l d0,a3
move.l 20(a3),d0
bsr getaskname2
moveq #11,d1
bsr tab
moveq #' ',d0
bsr putchar
move.l 24(a3),d0
bne.s 6$
move.w #failed,d0
bsr putstrw
moveq #21,d1
bsr tab
bra.s 11$
6$ bsr hexa
11$ move.b 28(a3),d0
bmi.s 4$
cmp.b #2,d0
ble.s 12$
4$ move.w #type,d0
bsr putstrw
moveq #28,d1
bsr tab
bra.s 5$
12$ ext.w d0
lsl.w #3,d0
add.w #fmode,d0
bsr putstrw
5$ moveq #29,d0
add.l a3,d0
bsr putnam
bsr freemsg
bra 3$
7$ move.w patchwhat(a4),a0
move.l dosbase(a4),a1
tst.b post_V34(a4)
beq.s 8$
move.l oldopen,d0
CALL SetFunction,SysBase(a4)
bra.s 9$
8$ CALL Forbid,SysBase(a4)
move.l (a7)+,2(a1,a0)
move.w (a7)+,0(a1,a0)
RECALL Permit
9$ move.l snoopport(a4),-(a7)
LIBCALL DeletePort
addq #4,a7
move.w #stoped,d0
bsr putnamw
clr.b addlines(a4)
clr.l auxsig(a4)
rts
myopen movem.l d3-d7/a0-a6,-(a7)
movem.l d1-d2,-(a7)
move.l d1,a0
bsr strlen
move.l d0,d6
add.l #30,d6
bsr allocmsg
beq.s 1$
move.w .dosoffset(PC),d3
addq.w #1,d3
bne.s 2$
sub.w #1004,d2
bra.s 3$
2$ addq.w #3,d2
3$ move.b d2,28(a5)
move.l _SysBase(PC),a6
move.l 276(a6),20(a5)
lea 29(a5),a1
move.l d1,a0
RECALL CopyMem
1$ movem.l (a7)+,d1-d2
move.l a5,d6
move.w .dosoffset(PC),d0
ext.l d0
move.l .dosbase(pc),a6
jsr $bababa
oldopen equ *-4
move.l d0,d7
movem.l d1-d2,-(a7)
tst.l d6
beq.s 1$
move.l d6,a5
move.l d0,24(a5)
move.l snoopport+dataarea(PC),a0
move.b #5,8(a5)
move.l a5,a1
CALL PutMsg,_SysBase(PC)
1$ move.l d7,d0
movem.l (a7)+,d1-d2
movem.l (a7)+,d3-d7/a0-a6
rts
myswitch movem.l d0-d1/a0,-(a7)
move.l 4,a0
move.l 276(a0),d0
move.l .tasksnum(PC),d1
lea cputime,a0
subq.l #1,d1
bmi.s swadd
sw0 cmp.l (a0)+,d0
dbeq d1,sw0
bne.s swadd
swi1 tst.b .post_V34
beq.s 1$
bsr getV2.0time
move.l d0,d1
sub.l lasttime(PC),d0
bcs.s swgo2
move.l d1,lasttime
bra.s 2$
1$ move.l #999999,d0
move.l d0,d1
sub.l sampleio+36+dataarea(PC),d0
move.l d1,sampleio+36+dataarea
2$ lsr.l #8,d0
add.l d0,508(a0)
swgo2 movem.l (a7)+,d0-d1/a0
dc.w $4ef9
oldswitch dc.l 0
swadd cmp.l #125,tasksnum+dataarea
bge.s swgo2
addq.l #1,tasksnum+dataarea
move.l d0,0(a0)
addq.l #4,a0
clr.l 508(a0)
bra.s swi1
lasttime dc.l 0
getV2.0time movem.l d2/a0,-(a7)
move.w #$4000,$dff09a ;ReadEClock
lea $bfe001,a0
moveq #0,d0
move.l d0,d1
move.l d1,d2
move.b $700(a0),d0
move.b $600(a0),d1
move.b $700(a0),d2
cmp.b d0,d2
beq.s 1$
moveq #-1,d1
1$ lsl.w #8,d2
move.b d1,d2
addq #1,d2
neg.w d2
move.l .timerbase(PC),a0
move.l $50(a0),d0
move.w d2,d0
move.w #-$4000,$dff09a
movem.l (a7)+,d2/a0
rts
countio addq.l #1,iocount+dataarea
moveq #0,d0
rts
iconbackdrp tst.b iconifyon(a4)
beq.s cio1
lea icnwindow,a0
eor.l #$100,14(a0) ;wn_Flags
cio1 rts
iconifyoff tst.b iconifyon(a4)
beq.s cio1
clr.b iconifyon(a4)
tst.b fromfile(a4)
bne.s 1$
move.l wnptr(a4),d0
beq.s 1$
move.l d0,a0
lea iconifgad,a1
CALL RemoveGadget,intuibase(a4)
move.l wnptr(a4),a0
CALL RefreshWindowFrame,intuibase(a4)
1$ move.l #iconify,d0
bra.s killseg
propgadoff tst.b propgadon(a4)
beq.s cio1
clr.b propgadon(a4)
tst.b fromfile(a4)
bne.s 1$
move.l wnptr(a4),d0
beq.s 1$
move.l d0,a0
lea sbgadget,a1
CALL RemoveGadget,intuibase(a4)
move.l wnptr(a4),a0
CALL RefreshWindowFrame,intuibase(a4)
bsr setupscreen
1$ move.l #setprop,d0
killseg movem.l d1-d2/a0-a5,-(a7)
subq #4,d0
move.l 4,a6
move.l 276(a6),a5
move.l 128(a5),d1
lsl.l #2,d1
move.l d1,a3
move.l 12(a3),d1
bne.s 2$
move.l 172(a5),d1
lsl.l #2,d1
move.l d1,a5
move.l 60(a5),d1
2$ lsl.l #2,d1
cmp.l d0,d1
beq.s 4$
move.l d1,a5
move.l 0(a5),d1
beq.s 5$
bra.s 2$
4$ move.l d1,a0
move.l 0(a0),0(a5)
clr.l 0(a0)
lsr.l #2,d1
CALL UnLoadSeg,dosbase(a4)
movem.l (a7)+,d1-d2/a0-a5
5$ rts
alert bsr stoptimer
move.l excpttask(a4),d0
bne.s alert1
move.w #noguru,d0
bra putnamw
alert1 move.w #softfail,d0
bsr putstrw
move.l excpttask(a4),d0
bsr getaskname2
bsr newline
cmp.l #3,excpterror(a4)
bne.s 1$
move.w #addrserr,d0
bsr putstrw
move.l excptaddr(a4),d0
bsr hexa
bsr newline
1$ move.w #procount,d0
bsr putstrw
move.l excptpc(a4),d0
bsr hexa
bsr newline
move.w #gurutxt,d0
bsr putstrw
move.l excpterror(a4),d0
bsr hexa
lea out,a0
move.l ptr(a4),d0
move.b #'.',-1(a0,d0)
move.l excpttask(a4),d0
bsr hexa
bra newline
showguru bsr alert
tst.b ownscreen(a4)
bne.s 5$
move.l wnptr(a4),a0
CALL WindowToFront,intuibase(a4)
bra.s 2$
5$ move.l screenptr,a0
CALL ScreenToFront,intuibase(a4)
2$ move.w #whatnow,d0
bsr putnamw
clr.l oldpageend
bsr readline
cmp.b #'i',inputbuffer
beq.s 4$
1$ cmp.b #'k',inputbuffer
bne.s 2$
move.l excpttask(a4),a1
tst.l 22(a1)
bne.s 3$
CALL RemTask,SysBase(a4)
bra.s 4$
3$ move.l a1,d0
bsr canok
4$ clr.l lastprinted(a4)
rts
myaddtask movem.l d0/a0,-(a7)
tst.b wanttraps+dataarea
beq.s 2$
lea mytrap(PC),a0
move.l 50(a1),d0
beq.s 1$
cmp.l oldtrap(PC),d0
beq.s 1$
lea myproctrap(PC),a0
cmp.l oldproctrap(PC),d0
bne.s 2$
1$ move.l a0,50(a1)
2$ movem.l (a7)+,d0/a0
move.l a1,-(a7)
jsr $bababa
OldAddTask equ *-4
move.l (a7)+,d0
movem.l d1-d7/a0-a6,-(a7)
move.l d0,d7
lea tsecs+dataarea(PC),a0
lea tmics+dataarea(PC),a1
CALL CurrentTime,intuibase+dataarea(PC)
CALL Forbid,_SysBase(PC)
move.w numtaskstimed+dataarea(PC),d5
lsl.w #2,d5
lea taskstampid,a5
lea 0(a5,d5.w),a5
move.l d7,0(a5)
move.l tsecs+dataarea(PC),d0
move.l d0,taskstamps-taskstampid(a5)
clr.l usedtime-taskstampid(a5)
addq.w #1,numtaskstimed+dataarea
lea dataarea(PC),a4
bsr cleanuptimers
RECALL Permit
cmp.b #5,timerio+8
bne.s 3$
moveq #0,d0
move.w timersig+dataarea(PC),d1
bset d1,d0
move.l mytask+dataarea(PC),a1
RECALL Signal
3$ move.l d7,d0
movem.l (a7)+,d1-d7/a0-a6
rts
myproctrap bsr traphandle
dc.w $4ef9
oldproctrap dc.l 0
mytrap bsr traphandle
moveq #0,d0
CALL Wait,SysBase(a4)
dc.w $4ef9
oldtrap dc.l 0
coldreboot move.w #$4000,$dff09a
clr.l sysbase
reboot move.l SysBase(a4),a6
tst.b post_V34(a4)
beq.s 1$
jmp -726(a6) ;_LVOColdReboot
1$ lea 2$(PC),a5
RECALL Supervisor
2$ move.l $fc0004,a0
subq #2,a0
CNOP 0,4
reset
jmp 0(a0)
traphandle movem.l d0-d7/a0-a6,$180
move.l 4,a6
move.l 276(a6),.excpttask
move.l 4(a7),d0
cmp.l #9,d0
beq.s 2$
move.l d0,.excpterror
moveq #10,d1
cmp.l #3,d0
bne.s 1$
move.l 0(a7,d1.w),.excptaddr
moveq #18,d1
1$ move.l 0(a7,d1.w),.excptpc
move.l mytask+dataarea(PC),a1
move.l trapsignal+dataarea(PC),d0
RECALL Signal
2$ movem.l $180,d0-d7/a0-a6
rts
trapguru tst.b wanttraps(a4)
bne restoretrap
move.b #1,wanttraps(a4)
addtraps tst.b wanttraps(a4)
beq 5$
move.l 304(a6),oldtrap ;Original EXEC trap handler
moveq #-1,d0
CALL AllocSignal,SysBase(a4)
moveq #0,d1
bset d0,d1
move.l d1,trapsignal(a4)
RECALL Forbid ;change the trap handler of
moveq #0,d5 ;aleady running tasks
bsr getaskdat ;get task stucture pointers
1$ tst.b entries(a4)
beq.s 2$
lea -16(a5),a5
move.l 0(a5),a3 ;pointer to a task structure
lea myproctrap(PC),a0
move.l 50(a3),d0 ;Task->tc_TrapCode
cmp.l oldproctrap(PC),d0 ;AmigaDos Handler ?
beq.s 3$
lea mytrap(PC),a0 ;EXEC Handler ?
cmp.l oldtrap(PC),d0
bne.s 4$ ;must be a custom one, skip it
3$ move.l a0,50(a3) ;replace it
4$ subq.b #1,entries(a4)
bra.s 1$
2$ CALL Permit,SysBase(a4)
5$ rts
restoretrap tst.b wanttraps(a4)
beq.s 6$
tst.b fromfile(a4)
bne.s 5$
CALL Forbid,SysBase(a4)
bsr getaskdat
1$ tst.b entries(a4)
beq.s 2$
lea -16(a5),a5
move.l 0(a5),a3
move.l oldproctrap(PC),a0
move.l 50(a3),d0
cmp.l #myproctrap,d0
beq.s 3$
move.l oldtrap(PC),a0
cmp.l #mytrap,d0
bne.s 4$
3$ move.l a0,50(a3)
4$ subq.b #1,entries(a4)
bra.s 1$
2$ CALL Permit,SysBase(a4)
clr.l trapsignal(a4)
5$ clr.b wanttraps(a4)
6$ rts
;save the contents of the output buffer
;to a file, append the output if the file allready exists
saveoutput bsr nodenam2
tst.b 0(a5)
beq syntax
move.l a5,d1
move.l #1004,d2 ;mode_readwrite
CALL Open,dosbase(a4)
move.l d0,d5
beq.s 5$
moveq #1,d3
moveq #0,d2
move.l d0,d1
CALL Seek,dosbase(a4)
bra.s 1$
5$ move.l a5,d1
move.l #1006,d2 ;mode_newfile
CALL Open,dosbase(a4)
move.l d0,d5
bne.s 1$
move.w #openerr,d0
bsr putstrw
move.l a5,d0
bra putnam
1$ move.l outchain(a4),d0
beq.s 3$
2$ move.l d0,a5
move.w 12(a5),d3
beq.s 4$
ext.l d3
lea 14(a5),a1
move.l a1,d2
move.l d5,d1
CALL Write,dosbase(a4)
tst.l d0
ble.s 3$
4$ moveq #1,d3
move.l d5,d1
move.l #cr+dataarea,d2
CALL Write,dosbase(a4)
tst.l d0
ble.s 3$
move.l 0(a5),d0
bne.s 2$
3$ move.l d5,d1
CALL Close,dosbase(a4)
rts
grabtimerio lea tiohead(a4),a0
bsr puthead
move.b timeout(a4),d4
move.b #255,timeout(a4)
bsr starttimer
move.b d4,timeout(a4)
lea timerio,a1
CALL Disable,SysBase(a4)
2$ move.l 0(a1),d2
beq.s 1$
move.l d2,a1
bra.s 2$
1$ CALL Enable,SysBase(a4)
lea -4(a1),a5
bsr stoptimer
lea buffer,a3
moveq #1,d4
bsr gettrq
lea timerio,a0
lea dummy,a1
moveq #40,d0
CALL CopyMem,SysBase(a4)
lea dummy,a1
lea timernam(a4),a0
moveq #0,d1
moveq #0,d0
CALL OpenDevice,SysBase(a4)
lea dummy,a1
move.l #1<<30,32(a1)
CALL SendIO,SysBase(a4)
lea dummy,a5
CALL Disable,SysBase(a4)
8$ move.l 0(a5),d2
beq.s 7$
move.l d2,a5
bra.s 8$
7$ CALL Enable,SysBase(a4)
lea -4(a5),a5
lea dummy,a1
CALL AbortIO,SysBase(a4)
lea timerio,a1
CALL WaitIO,SysBase(a4)
move.w timersig(a4),d0
moveq #0,d1
bset d0,d1
moveq #0,d0
CALL SetSignal,SysBase(a4)
moveq #0,d4
bsr gettrq
lea dummy,a1
CALL CloseDevice,SysBase(a4)
clr.l (a3)+
lea -22(a3),a2
moveq #18,d2
bsr sortlist
lea buffer,a5
5$ move.l (a5)+,d0
beq.s 6$
bsr hexa
move.w (a5)+,d0
ext.l d0
mulu #9,d0
add.w #timerunits,d0
bsr putstrw
move.l (a5)+,d0
bsr putstamp
moveq #'.',d0
bsr putchar
move.l (a5)+,d0
move.l #100000,d1
bsr div
or.l #'0',d0
bsr putchar
10$ bsr putblank
move.l (a5)+,d0
bsr getaskname2
bsr newline
bra.s 5$
6$ rts
gettrq CALL Disable,SysBase(a4)
3$ move.l 0(a5),a5
tst.l 0(a5)
beq.s 4$
move.l a5,(a3)+
move.w d4,(a3)+
move.l 32(a5),(a3)+
move.l 36(a5),(a3)+
move.l 14(a5),a1
move.l 16(a1),(a3)+
bra.s 3$
4$ CALL Enable,SysBase(a4)
rts
;check if the timer is runnig, start it if not
starttimer lea timerio,a1
cmp.b #5,8(a1)
beq.s 1$
moveq #0,d0
move.b timeout(a4),d0
bne.s 2$
tst.l timeoutm(a4)
beq.s 1$
2$ move.l d0,32(a1)
move.l timeoutm(a4),36(a1)
move.w #9,28(a1)
CALL SendIO,SysBase(a4)
1$ rts
;Abort a timer request, if pending
stoptimer lea timerio,a1
cmp.b #5,8(a1)
bne.s 1$
CALL AbortIO,SysBase(a4)
lea timerio,a1
CALL WaitIO,SysBase(a4)
1$ move.w timersig(a4),d0
moveq #0,d1
bset d0,d1
moveq #0,d0
CALL SetSignal,SysBase(a4)
rts
;Xoper main loop, process all incoming messages
processmsgs move.l wnptr(a4),a0
moveq #0,d0
move.w intuisig(a4),d1
bset d1,d0
bset #mysignal,d0
move.w timersig(a4),d1
bset d1,d0
or.w #4096,d0
or.l auxsig(a4),d0
tst.l auxsig(a4)
bne.s 1$
or.l trapsignal(a4),d0
1$ CALL Wait,SysBase(a4)
move.l d0,tasksigs(a4)
move.l trapsignal(a4),d1
and.l d0,d1
beq.s ctrl_c
tst.b gotguru(a4)
bne.s ctrl_c
move.b #1,gotguru(a4)
bsr showguru
clr.b gotguru(a4)
ctrl_c moveq #12,d1
bsr testsig
bne exit
moveq #mysignal,d1
bsr testsig
beq.s timermsg
move.l d0,-(a7)
move.l screenptr(a4),d0
beq.s 1$
move.l d0,a0
CALL ScreenToFront,intuibase(a4)
bra.s 2$
1$ move.l wnptr(a4),d0
beq.s timermsg
move.l d0,a0
CALL WindowToFront,intuibase(a4)
2$ move.l (a7)+,d0
timermsg move.w timersig(a4),d1
bsr testsig
beq intuimsgs
btst.w #8,propinfo
bne.s 3$
tst.w repeat(a4)
bne.s 1$
bsr showwhat
bra.s intuimsgs
1$ move.w repeatlen(a4),d0
lea repeatbuffer,a2
lea dummy,a1
move.w d0,d1
2$ move.b (a2)+,(a1)+
dbf d1,2$
bsr cli
3$ bsr starttimer
intuimsgs move.w intuisig(a4),d1
bsr testsig
beq processnxtmsg
nextimsg move.l wnptr(a4),a0
move.l $56(a0),a0
CALL GetMsg,SysBase(a4)
tst.l d0
beq processnxtmsg
move.l d0,intuimsg(a4)
move.l d0,a0
move.l 20(a0),d0
cmp.l #$200,d0 ;CloseWindow
bne.s 1$
tst.b addlines(a4)
beq exitall
move.b #1,cbreak
bra intuiend
1$ cmp.l #2,d0 ;ResizeWindow
bne.s 1010$
tst.b post_V34(a4)
beq.s 3443$
move.l wnptr(a4),a0
move.l minwsize(a4),d0
cmp.w 10(a0),d0
bne.s 3443$
swap d0
cmp.w 8(a0),d0
bne.s 3443$
bsr replyintui ;window was 'zipped'
bsr stoptimer
bra instback
3443$ bsr setupscreen
bra intuiend
1010$ cmp.l #$10,d0
bne.s 2$
btst.w #8,propinfo
beq.s 1002$
jsr proppos
bra.s 1002$
2$ cmp.l #4,d0 ;refresh
bne.s 22$
bsr putiline
bsr blastout
bsr UpdateIArea
1002$ bra intuiend
22$ tst.b addlines(a4)
bne 3$
cmp.l #$20,d0 ;gadgetdown
bne.s 1000$
tst.w getanswer(a4)
bne.s 3$
move.l 28(a0),a1
cmp.w #3,38(a1) ;Slidebar
bne.s 1002$
tst.b propgadon(a4)
beq.s 1002$
jsr proppos
1004$ bra.s 1002$
1000$ cmp.l #$40,d0 ;gadgetup
bne.s 3$
move.l 28(a0),a1
cmp.w #3,38(a1) ;Slidebar ?
bne.s 1003$
bclr.w #8,propinfo ;clear 'knop hit' bit
bra.s 1004$
1003$ bsr replyintui ;iconify
bsr stoptimer
bra instback
3$ cmp.l #$400,d0 ;RawKey
bne notarawkey
move.w #$80,d0
and.w 24(a0),d0
bne intuiend
and.w #$7f,24(a0)
lea ievent,a1
move.b #1,4(a1)
move.l 24(a0),6(a1)
move.w 26(a0),qualifier(a4)
move.l a1,a0
lea outevent,a1
moveq #20,d1
suba.l a2,a2
CALL RawKeyConvert,condev(a4)
tst.l d0
beq intuiend
lea inputbuffer,a1
lea outevent,a2
move.w curpos(a4),d4
moveq #0,d3
tst.b addlines(a4)
bne 197$
sub.w #1,cmdcompflag(a4)
cmp.b #$9b,0(a2) ;SI code
bne 110$
cmp.b #'?',1(a2) ;help
bne.s 399$
tst.w getanswer(a4)
bne.s 399$
bsr stoptimer
tst.w bottomin(a4)
bne.s 398$
move.w #1,bottomin(a4)
clr.w ibufferlen(a4)
clr.w curpos(a4)
bsr UpdateIArea
398$ move.w #usetxt,d0
bsr putnamw
clr.l lastprinted(a4)
bsr blastout
bra.s 420$
399$ cmp.b #'C',1(a2) ;cursor right
bne.s 400$
cmp.w ibufferlen(a4),d4
bge.s 420$
addq #1,d4
421$ move.w d4,curpos(a4)
420$ bra 100$
400$ cmp.b #'D',1(a2) ;cursor left
bne.s 401$
subq #1,d4
bpl.s 421$
bra.s 420$
401$ cmp.b #' ',1(a2)
bne.s 402$
cmp.b #'@',2(a2) ;shift right
bne.s 403$
404$ cmp.w ibufferlen(a4),d4
bge.s 421$
addq #1,d4
cmp.b #' ',0(a1,d4)
bne.s 404$
405$ cmp.w ibufferlen(a4),d4
bge.s 421$
addq #1,d4
cmp.b #' ',0(a1,d4)
beq.s 405$
bra.s 421$
403$ cmp.b #'A',2(a2) ;shift left
bne.s 420$
406$ tst.w d4
beq.s 421$
subq #1,d4
cmp.b #' ',0(a1,d4)
beq.s 406$
407$ tst.w d4
beq.s 421$
subq #1,d4
cmp.b #' ',0(a1,d4)
bne.s 407$
addq #1,d4
bra.s 421$
402$ cmp.b #'A',1(a2) ;cursor up
bne.s 408$
tst.w bottomin(a4)
bne.s 480$
tst.w curpos(a4)
bne.s 480$
clr.w curpos(a4)
clr.w ibufferlen(a4)
bsr UpdateIArea
bsr clrcursor
move.w edline(a4),d3
ext.l d3
tst.w d3
beq.s 481$
subq #1,d3
cmp.l firstline(a4),d3
bge.s 481$
move.l d3,-(a7)
subq.l #1,firstline(a4)
bsr blastout
move.l (a7)+,d3
481$ move.w d3,edline(a4)
bsr getcurpos
bsr putcursor
bra intuiend
480$ move.l history(a4),a0
tst.l 0(a0)
beq.s 423$
move.l curhist(a4),a1
cmp.l a0,a1
beq.s 409$
move.l 4(a1),d0
move.l d0,curhist(a4)
409$ move.l a1,gothline(a4)
bsr copyhistory
423$ bra 100$
408$ cmp.b #'B',1(a2) ;cursor down
bne 410$
tst.w bottomin(a4)
bne.s 414$
tst.w curpos(a4)
bne.s 414$
clr.w curpos(a4)
clr.w ibufferlen(a4)
bsr UpdateIArea
bsr clrcursor
move.w edline(a4),d3
ext.l d3
move.l numlines(a4),d4
subq #1,d4
cmp.l d4,d3
beq.s 490$
move.l firstline(a4),d2
add.w rows(a4),d2
subq #1,d2
addq #1,d3
cmp.w d2,d3
ble.s 490$
move.l d3,-(a7)
addq.l #1,firstline(a4)
bsr blastout
move.l (a7)+,d3
490$ bra 481$
414$ move.l curhist(a4),d0
beq.s 423$
move.l d0,a1
move.l 0(a1),a1
tst.l 0(a1)
bne.s 411$
clr.l gothline(a4)
clr.w curpos(a4)
clr.w ibufferlen(a4)
bra 423$
411$ move.l a1,curhist(a4)
bra 409$
410$ cmp.b #'T',1(a2) ;shift up
bne.s 412$
tst.w hnum(a4)
beq 423$
move.l history(a4),a1
move.l a1,curhist(a4)
bra 409$
412$ cmp.b #'S',1(a2) ;shift down
bne.s 440$
tst.w hnum(a4)
beq 423$
move.l history+8(a4),curhist(a4)
bra.s 414$
440$ cmp.b #'0',1(a2) ;function keys
bmi 423$
cmp.b #'9',1(a2)
bgt 423$
lea 1(a2),a0
bsr getnum
lea fkeys(a4),a0
441$ move.l 0(a0),a0
tst.l 0(a0)
beq 100$
cmp.b 8(a0),d2
bne.s 441$
move.b 9(a0),d5
ext.w d5
subq #1,d5
lea 10(a0),a0
move.w curpos(a4),d4
lea inputbuffer,a2
moveq #0,d3
lea 0(a2,d4),a2
445$ move.b (a0)+,d0
cmp.b #'^',d0
bne.s 442$
moveq #1,d3
bra.s 443$
442$ cmp.b #'_',d0
bne.s 444$
move.b #' ',d0
444$ move.b d0,(a2)+
addq #1,d4
443$ dbf d5,445$
move.w d4,curpos(a4)
cmp.w ibufferlen(a4),d4
ble.s 446$
move.w d4,ibufferlen(a4)
446$ tst d3
beq 100$
bra got_fkey
110$ moveq #0,d3
101$ move.w curpos(a4),d4
tst d0
beq 100$
cmp.b #13,0(a2,d3) ;return
beq got_enter
cmp.b #27,0(a2,d3) ;esc
bne 799$
tst.w getanswer(a4)
bne 100$
clr.b insmode(a4)
clr.w ibufferlen(a4)
move.w #200,curpos(a4)
bsr UpdateIArea
clr.w curpos(a4)
tst.w bottomin(a4)
bne.s 700$
move.w #1,bottomin(a4)
bsr getcurpos
cmp.b #5,timerstate(a4)
bne.s 765$
bsr starttimer
765$ bra 100$
700$ move.b timerio+8,timerstate(a4)
bsr stoptimer
move.w edline(a4),d0
move.l firstline(a4),d4
cmp.w d4,d0
bmi.s 701$
move.w d4,d5
add.w rows(a4),d5
cmp.w d5,d0
bmi.s 702$
701$ move.w rows(a4),d0
lsr.w #1,d0
add.w d4,d0
702$ move.l numlines(a4),d3
subq #1,d3
cmp.w d3,d0
ble.s 703$
move.w d3,d0
703$ move.w d0,edline(a4)
sub.w d4,d0
lsl.w #3,d0
add.w #18,d0
move.w d0,cposy(a4)
clr.w bottomin(a4)
tst.w loffset(a4)
beq.s 704$
clr.w loffset(a4)
bsr blastout
704$ bra 100$
799$ cmp.b #8,0(a2,d3) ;Backspace
bne.s 114$
tst.w d4
beq 102$
bsr delchar
subq #1,d4
move.w d4,curpos(a4)
bra 102$
114$ cmp.b #127,0(a2,d3) ;del
bne.s 150$
178$ cmp.w ibufferlen(a4),d4
bge 102$
addq #1,d4
bsr delchar
bra 102$
150$ cmp.b #9,0(a2,d3) ;tab
bne 197$
move.w cmdcompflag(a4),d0
bpl.s 151$
lea inputbuffer,a0
move.w ibufferlen(a4),d0
bsr tolower
move.w curpos(a4),cmdcomplen(a4)
151$ move.w #1,cmdcompflag(a4)
155$ move.w cmdcompnr(a4),d0
bsr getcmdptr
move.l d0,a0
move.w cmdcomplen(a4),d4
lea inputbuffer,a1
subq #1,d4
152$ tst.b 0(a0)
beq.s 153$
cmp.b (a0)+,(a1)+
bne.s 153$
dbf d4,152$
move.l d0,a1
lea inputbuffer,a0
154$ move.b (a1)+,(a0)+
dbeq.s d4,154$
neg.w d4
subq #1,d4
move.w d4,curpos(a4)
move.w d4,ibufferlen(a4)
add.w #1,cmdcompnr(a4)
cmp.w #cmdnum,cmdcompnr(a4)
beq.s 156$
bra 100$
153$ move.w cmdcompnr(a4),d0
addq #1,d0
move.w d0,cmdcompnr(a4)
cmp.w #cmdnum,d0
bmi.s 155$
156$ clr.w cmdcompnr(a4)
bra 100$
197$ cmp.b #3,0(a2,d3) ;ctrl c
bne.s 104$
move.b #1,cbreak(a4)
104$ tst.b addlines(a4)
bne processnxtmsg
cmp.b #$18,0(a2,d3) ;ctrl x
bne.s 300$
clr.w ibufferlen(a4)
clr.w curpos(a4)
bra 100$
300$ cmp.b #$19,0(a2,d3) ;ctrl y
bne.s 106$
move.w curpos(a4),ibufferlen(a4)
bra 100$
106$ move.w #$100,d5 ;NumPad
and.w qualifier(a4),d5
beq 105$
move.l firstline(a4),d5
cmp.b #'7',0(a2,d3) ;'Home'
bne.s 200$
moveq #0,d5
199$ cmp.l firstline(a4),d5
beq.s 196$
move.l d5,firstline(a4)
bsr blastout
tst.w bottomin(a4)
bne.s 196$
move.w edline(a4),d0
move.l firstline(a4),d1
cmp.w d1,d0
bmi.s 190$
add.w rows(a4),d1
cmp.w d1,d0
bmi.s 192$
190$ clr.w curpos(a4)
clr.w ibufferlen(a4)
move.w rows(a4),d0
lsr.w #1,d0
ext.l d0
add.l firstline(a4),d0
cmp.l numlines(a4),d0
bmi.s 191$
move.l numlines(a4),d0
subq #1,d0
191$ move.w d0,edline(a4)
192$ bsr getcurpos
bsr UpdateIArea
196$ bra 100$
200$ cmp.b #'8',0(a2,d3) ;'up arrow'
bne.s 201$
tst d5
beq 100$
subq #1,d5
1990$ bra.s 199$
201$ cmp.b #'9',0(a2,d3) ;'PgUp'
bne.s 203$
sub.w rows(a4),d5
bpl.s 1990$
moveq #0,d5
bra.s 1990$
203$ cmp.b #'1',0(a2,d3) ;'End'
bne.s 205$
222$ move.l numlines(a4),d5
sub.w rows(a4),d5
bpl 199$
moveq #0,d5
204$ bra 199$
205$ cmp.b #'2',0(a2,d3) ;'down arrow'
bne.s 206$
move.l d5,d2
add.w rows(a4),d2
cmp.l numlines(a4),d2
bge 100$
addq #1,d5
bra 199$
206$ cmp.b #'3',0(a2,d3) ;'PgDn'
bne.s 500$
add.w rows(a4),d5
move.l d5,d2
add.w rows(a4),d2
cmp.l numlines(a4),d2
bge.s 222$
bra 199$
500$ cmp.b #'4',0(a2,d3) ;left arrow
bne.s 501$
tst.w bottomin(a4)
beq 102$
move.w loffset(a4),d2
sub.w colms(a4),d2
bpl.s 502$
moveq #0,d2
502$ move.w d2,loffset(a4)
bsr blastout
bra 100$
501$ cmp.b #'6',0(a2,d3) ;right arrow
bne.s 170$
tst.w bottomin(a4)
beq 102$
move.w loffset(a4),d2
add.w colms(a4),d2
bra.s 502$
170$ cmp.b #'0',0(a2,d3) ;Ins
bne.s 177$
bchg.b #0,insmode(a4)
bra.s 102$
177$ cmp.b #'.',0(a2,d3) ;Del
beq 178$
105$ tst.w bottomin(a4)
bne.s 777$
tst.w curpos(a4)
bne.s 777$
movem.l d0-d1,-(a7)
move.w edline(a4),d0
bsr findline
movem.l (a7)+,d0-d1
tst.l 8(a5)
beq intuiend
777$ move.w curpos(a4),d5
ext.l d5
moveq #79,d2
cmp.w d2,d5
bge 102$
tst.b insmode(a4)
beq.s 172$
cmp.w ibufferlen(a4),d5
bmi.s 171$
bra.s 173$
172$ sub d5,d2
lea 80(a1),a5
lea 79(a1),a3
103$ move.b -(a3),-(a5)
dbf d2,103$
173$ addq.w #1,ibufferlen(a4)
171$ move.b 0(a2,d3),0(a1,d5)
addq.w #1,curpos(a4)
102$ subq #1,d0
addq #1,d3
bra 101$
100$ bsr UpdateIArea
bra intuiend
got_enter bsr puthist
got_fkey bsr stoptimer
clr.b insmode(a4)
lea dummy,a1
lea inputbuffer,a2
move.w ibufferlen(a4),d2
beq.s 2$
tst.w bottomin(a4)
bne.s 5$
movem.l a1-a2,-(a7)
move.w edline(a4),d0
bsr findline
move.l 8(a5),d0
bsr gthex
lea hexarea(a4),a0
lea 0(a2,d2),a1
move.b #' ',(a1)+
move.b #'$',(a1)+
moveq #8,d0
CALL CopyMem,SysBase(a4)
move.w ibufferlen(a4),d2
add.w #10,d2
move.w d2,ibufferlen(a4)
movem.l (a7)+,a1-a2
5$ subq #1,d2
1$ move.b (a2)+,(a1)+
dbf d2,1$
2$ move.b #10,(a1)+
move.w ibufferlen(a4),d0
ext.l d0
addq #1,d0
move.l d0,-(a7)
clr.w ibufferlen(a4)
tst.w bottomin(a4)
bne.s 4$
move.w #100,curpos(a4)
bsr UpdateIArea
4$ clr.w curpos(a4)
move.w #1,bottomin(a4)
bsr getcurpos
bsr UpdateIArea
move.l (a7)+,d0
move.w d0,repeatlen(a4)
clr.w repeat(a4)
clr.b printed(a4)
tst.w getanswer(a4)
beq.s 6$
rts
6$ bsr cli
tst.b printed(a4)
bne.s 3$
bsr starttimer
3$ bra intuiend
notarawkey
intuiend bsr.s replyintui
bra nextimsg
processnxtmsg
tst.b addlines(a4)
beq.s 1$
rts
1$ tst.b propupdate(a4)
beq.s 2$
clr.b propupdate(a4)
tst.b propgadon(a4)
beq.s 2$
jsr setprop
2$ bra processmsgs
replyintui move.l intuimsg(a4),d0
beq.s 1$
move.l d0,a1
CALL ReplyMsg,SysBase(a4)
1$ clr.l intuimsg(a4)
rts
;put an input line into the history buffer
puthist move.w ibufferlen(a4),d5
move.l d5,d0
cmp.w minnumchars(a4),d0
bcs 1$
move.l gothline(a4),d1
beq.s 5$
move.l d1,a2
cmp.w 8(a2),d5
bne.s 5$
lea 10(a2),a2
lea inputbuffer,a1
subq #1,d0
6$ cmp.b (a2)+,(a1)+
bne.s 5$
dbf d0,6$
move.l gothline(a4),curhist(a4)
bra.s 1$
5$ move.w d5,d0
ext.l d0
add #10,d0
move.l #$10000,d1 ;MEMF_CLEAR
CALL AllocMem,SysBase(a4)
tst.l d0
beq.s 1$
move.l d0,a0
move.w d5,8(a0)
lea 10(a0),a2
subq #1,d5
lea inputbuffer,a1
2$ move.b (a1)+,(a2)+
dbf d5,2$
move.w hnum(a4),d5
cmp.w maxhlines(a4),d5
bmi.s 3$
bsr remhistline
bra.s 4$
3$ addq #1,d5
move.w d5,hnum(a4)
4$ move.l d0,a1
move.l d0,curhist(a4)
lea history(a4),a0
CALL AddTail,SysBase(a4)
1$ clr.l gothline(a4)
rts
;copy a history line into the input buffer
copyhistory lea inputbuffer,a0
move.w 8(a1),d3
ext.l d3
move.w d3,curpos(a4)
move.w d3,ibufferlen(a4)
subq #1,d3
lea 10(a1),a1
1$ move.b (a1)+,(a0)+
dbf d3,1$
rts
;remove one line from the history buffer
;pointer to the line in A1, returns pointer to the next line in d1
remhistline move.l d0,-(a7)
lea history(a4),a0
move.l 0(a0),a5
tst.l 0(a5)
beq.s 1$
CALL RemHead,SysBase(a4)
move.l a5,a1
move.w 8(a1),d0
add #10,d0
ext.l d0
CALL FreeMem,SysBase(a4)
1$ move.l (a7)+,d0
rts
;kill all history lines
killhistory bsr remhistline
move.l history(a4),a0
tst.l 0(a0)
bne.s killhistory
2$ clr.w hnum(a4)
clr.l curhist(a4)
rts
;delete one char from the input line
delchar lea inputbuffer,a3
lea 0(a3,d4.w),a3
lea -1(a3),a5
move d4,d5
1$ cmp.w #78,d5
bge.s 2$
move.b (a3)+,(a5)+
addq #1,d5
bra.s 1$
2$ subq.w #1,ibufferlen(a4)
rts
testsig move.l tasksigs(a4),d0
btst d1,d0
rts
;get the position of the input area
iareapos move.l wnptr(a4),a0
move.w 10(a0),d0
subq #4,d0
move.w d0,ipos(a4)
rts
;Update the current position of the input line
getcurpos tst.w bottomin(a4)
beq.s 1$
move.w ipos(a4),cposy(a4)
rts
1$ move.w edline(a4),d3
sub.l firstline(a4),d3
lsl #3,d3
add.w #18,d3
move.w d3,cposy(a4)
rts
;refresh the input area
UpdateIArea move.l rastport(a4),a1
move.l #1,d0
CALL SetDrMd,gfxbase(a4)
moveq #6,d0
move.w cposy(a4),d1
move.l rastport(a4),a1
CALL Move,gfxbase(a4)
lea inputbuffer,a0
move.w ibufferlen(a4),d0
ext.l d0
move.w colms(a4),d1
sub.w bottomin(a4),d1
cmp.w d1,d0
bmi.s 1$
move.w d1,d0
1$ move.w d0,d2
move.l rastport(a4),a1
CALL Text,gfxbase(a4)
tst.w bottomin(a4)
bne.s 3$
move.w edline(a4),d0
bsr findline
move.w 12(a5),d3
sub.w d2,d3
bmi.s 3$
move.w colms(a4),d1
sub.w d2,d1
bmi.s 2$
cmp.w d1,d3
ble.s 4$
move.w d1,d3
4$ move.w d3,d0
lea 14(a5,d2.w),a0
move.l rastport(a4),a1
CALL Text,gfxbase(a4)
add.w ibufferlen(a4),d3
move.w d3,d2
3$ move.w colms(a4),d0
sub.w bottomin(a4),d0
move.l blanks(a4),a0
ext.l d0
sub.w d2,d0
bmi.s 2$
lea 0(a0,d2.w),a0
move.l rastport(a4),a1
CALL Text,gfxbase(a4)
2$ bsr putcursor
rts
clrcursor moveq #1,d7
bra.s ptc1
putcursor moveq #6,d7
ptc1 move.w curpos(a4),d0
move.w colms(a4),d1
subq #1,d1
sub.w bottomin(a4),d1
cmp.w d0,d1
bmi.s 1$
move.l rastport(a4),a1
move.l d7,d0
CALL SetDrMd,gfxbase(a4)
move.w cposy(a4),d1
move.w curpos(a4),d0
lsl.w #3,d0
addq #6,d0
move.l rastport(a4),a1
CALL Move,gfxbase(a4)
lea oneblank(a4),a0
moveq #1,d0
move.l rastport(a4),a1
CALL Text,gfxbase(a4)
1$ rts
;rebuild the window from scratch
setupscreen move.l rastport(a4),a1
moveq #0,d0
CALL SetRast,gfxbase(a4)
move.l wnptr(a4),a0
CALL RefreshWindowFrame,intuibase(a4)
bsr getwindowsize
tst.w bottomin(a4)
bne.s 1$
move.w edline(a4),d0
move.l firstline(a4),d1
move.w rows(a4),d2
move.w d2,d4
move.w numlines(a4),d3
add.w d1,d2
cmp.w d2,d0
bmi.s 2$
lsr.w #1,d4
sub.w d4,d0
ext.l d0
move.l d0,firstline(a4)
2$ bsr tstfirstlin
1$ bsr getcurpos
bsr putiline
bsr blastout
bsr UpdateIArea
move.w rows(a4),currenty(a4)
rts
putiline move.l rastport(a4),a1
clr.l devicelock(a4)
moveq #1,d0
0$ CALL SetAPen,gfxbase(a4)
move.l rastport(a4),a1
moveq #1,d0
CALL SetDrMd,gfxbase(a4)
move.l wnptr(a4),a5
move.w 10(a5),d1
sub.w #12,d1
sub.l devicelock(a4),d1
moveq #0,d0
move.l rastport(a4),a1
CALL Move,gfxbase(a4)
move.w 8(a5),d0
move.w d1,-(a7)
move.l rastport(a4),a1
CALL Draw,gfxbase(a4)
move.w (a7)+,d1
tst.b ownscreen(a4)
bne.s 1$
tst.b post_V34(a4)
beq.s 2$
tst.l devicelock(a4)
bne.s 1$
addq.l #1,devicelock(a4)
moveq #2,d0
bra.s 0$
2$ move.w 8(a5),d0
addq #1,d1
move.l rastport(a4),a1
CALL Move,gfxbase(a4)
sub.w #16,d0
move.w d1,-(a7)
move.l rastport(a4),a1
CALL Draw,gfxbase(a4)
move.w (a7)+,d1
move.w 8(a5),d0
addq #1,d1
move.l rastport(a4),a1
CALL Move,gfxbase(a4)
sub.w #16,d0
move.l rastport(a4),a1
CALL Draw,gfxbase(a4)
1$ rts
getwindowsize
bsr freeblank
move.l wnptr(a4),a0
move.w 10(a0),d0
sub.w #26,d0
lsr.w #3,d0
move.w d0,rows(a4)
move.w 8(a0),d0
sub.w #12,d0
move.b post_V34(a4),d1
ext.w d1
sub.w d1,d0
lsr.w #3,d0
sub.b propgadon(a4),d0
sub.w d1,d0
move.w d0,colms(a4)
ext.l d0
moveq #0,d1
move.l d0,d6
CALL AllocMem,SysBase(a4)
move.l d0,blanks(a4)
move.l d0,a0
subq #1,d6
1$ move.b #' ',(a0)+
dbf d6,1$
bsr iareapos
rts
readline move.b #'n',inputbuffer
tst.b fromfile(a4)
bne.s 1$
move.l #31000,firstline(a4)
bsr blastout
move.w #1,getanswer(a4)
bsr replyintui
5$ bsr processmsgs
move.w d0,d5
bsr replyintui
subq #1,d5
beq.s 5$
ori.b #$20,inputbuffer
clr.w getanswer(a4)
bsr RestoreOutput
1$ rts
ResumeOutput
move.l outchain(a4),d0
move.l d0,a1
beq.s 2$
move.l numlines(a4),oldnumlines(a4)
move.l firstline(a4),oldfirstline(a4)
4$ tst.l 0(a1)
beq.s 3$
move.l 0(a1),a1
bra.s 4$
3$ move.l a1,lastprinted(a4)
2$ move.l a1,oldpageend(a4)
rts
RestoreOutput
move.l oldpageend(a4),d3
beq.s 1$
move.l oldnumlines(a4),numlines(a4)
move.l oldfirstline(a4),firstline(a4)
move.l oldlastprinted(a4),lastprinted(a4)
move.l d3,a1
move.l 0(a1),a1
bsr killlines
move.l d3,a1
clr.l 0(a1)
bsr blastout
1$ rts
addline movem.l d0-d6/a0-a3,-(a7)
move.l rastport(a4),a1
moveq #1,d0
CALL SetAPen,gfxbase(a4)
move.l rastport(a4),a1
moveq #1,d0
CALL SetDrMd,gfxbase(a4)
move.w currenty(a4),d6
cmp.w rows(a4),d6
bmi.s 1$
bsr cls
1$ move.l lastprinted(a4),a0
move.w colms(a4),d5
move.w 12(a0),d3
lea 14(a0),a0
move.w currenty(a4),d6
move d6,d7
lsl #3,d6
add.w #18,d6
moveq #0,d4
bsr blastline
addq.w #1,currenty(a4)
move.l #31000,firstline(a4)
movem.l (a7)+,d0-d6/a0-a3
rts
cls movem.l d0-d6/a0-a3,-(a7)
move.l rastport(a4),a1
moveq #1,d0
CALL SetAPen,gfxbase(a4)
move.l rastport(a4),a1
moveq #1,d0
move.l rastport(a4),a1
CALL SetDrMd,gfxbase(a4)
move.w colms(a4),d5
clr.w d2
1$ move.w d2,d6
move d5,d7
lsl #3,d6
add.w #18,d6
moveq #0,d3
move.l blanks(a4),a0
bsr blastline
addq #1,d2
cmp.w rows(a4),d2
bmi.s 1$
clr.w currenty(a4)
movem.l (a7)+,d0-d6/a0-a3
rts
createscreen moveq #1,d1
moveq #80,d0
lea buffer,a0
sub.l a1,a1
CALL GetScreenData,intuibase(a4)
move.w buffer+76,nsviewmode(a4)
move.l buffer+12,nssize(a4)
lea newscreen(a4),a0
CALL OpenScreen,intuibase(a4)
move.l d0,screenptr(a4)
move.l d0,nwscreen(a4)
move.w #$f,nwtype(a4)
beq.s setupwindow
tst.l wnptr(a4)
beq.s 1$
move.l wnptr(a4),a0
move.l 4(a0),window_l(a4)
move.l 8(a0),window_w(a4)
CALL CloseWindow,intuibase(a4)
clr.l intuimsg(a4)
clr.l wnptr(a4)
1$ clr.l newwindow(a4)
move.l buffer+12,newwindow+4(a4)
move.l wnscrflags(a4),nwflgs(a4)
move.l wnscrflags+4(a4),nwflgs+4(a4)
move.b #1,ownscreen(a4)
setupwindow tst.b ownscreen(a4)
bne.s 3$
move.l window_l(a4),newwindow(a4)
move.l window_w(a4),newwindow+4(a4)
move.w #1,nwtype(a4)
move.l wnnormflgs(a4),nwflgs(a4)
move.l wnnormflgs+4(a4),nwflgs+4(a4)
3$ lea newwindow(a4),a0
CALL OpenWindow,intuibase(a4)
move.l d0,wnptr(a4)
beq exit
move.l d0,a0
move.l 50(a0),rastport(a4) ;wn->RPort
move.l 86(a0),a1 ;wn->UserPort
move.b 15(a1),d1 ;MsgPort->SigBit
ext.w d1
move.w d1,intuisig(a4)
tst.b ownscreen(a4)
bne.s 1$
tst.b iconifyon(a4)
beq.s 1$
tst.b post_V34(a4)
bne.s 1$
lea iconifgad,a1
moveq #0,d0
CALL AddGadget,intuibase(a4)
1$ tst.b propgadon(A4)
beq.s 4$
lea sbgadget,a1
move.l wnptr(a4),a0
moveq #0,d0
CALL AddGadget,intuibase(a4)
4$ move.l wnptr(a4),a0
CALL RefreshWindowFrame,intuibase(a4)
lea tattr(a4),a0
CALL OpenFont,gfxbase(a4)
tst.l d0
beq.s 2$
move.l d0,a0
move.l rastport(a4),a1
CALL SetFont,gfxbase(a4)
2$ bsr getwindowsize
bsr getcurpos
bsr putiline
bsr UpdateIArea
bsr starttimer
bsr showwhat
rts
usescreen tst.b fromfile(a4)
bne.s 1$
tst.b ownscreen(a4)
bne.s 1$
bsr createscreen
1$ move.b #1,ownscreen(a4)
rts
usewindow tst.b fromfile(a4)
beq.s 1$
clr.b ownscreen(a4)
rts
1$ tst.b ownscreen(a4)
beq.s 2$
move.l wnptr(a4),d0
beq.s 3$
move.l d0,a0
CALL CloseWindow,intuibase(a4)
clr.l wnptr(a4)
clr.l intuimsg(a4)
3$ move.l screenptr(a4),d0
beq.s 4$
move.l d0,a0
CALL CloseScreen,intuibase(a4)
clr.l screenptr(a4)
clr.b ownscreen(a4)
4$ bra setupwindow
2$ rts
dchange lea dchead(a4),a0
bsr puthead
lea tdd(a4),a1
move.l SysBase(a4),a0
lea 350(a0),a0
CALL FindName,SysBase(a4)
tst.l d0
beq R_T_S
move.l d0,a2
lea 32(a2),a2
moveq #0,d5
2$ lea 4(a2),a2
move.l 0(a2),d0
beq 3$
move.l d0,a0
lea $18e(a0),a0
CALL Disable,SysBase(a4)
5$ tst.l 0(a0)
beq.s 6$
move.l 0(a0),a0
bra.s 5$
6$ lea -4(a0),a5
lea buffer+100,a3
9$ move.l 0(a5),a5
tst.l 0(a5)
beq.s 11$
move.l a5,(a3)+
bne.s 9$
11$ clr.l (a3)+
CALL Enable,SysBase(a4)
lea buffer+100,a3
7$ move.l (a3)+,d0
beq.s 3$
move.l d0,a5
cmp.w #20,28(a5)
bne.s 7$
move.l 40(a5),a3
move.l a3,d0
move.l d0,node(a4)
bsr hexan
move.l a3,d0
beq.s 10$
move.l 14(a3),d0
bsr hexan
move.l 18(a3),d0
bsr hexan
10$ move.l d5,d3
or.b #48,d3
move.b d3,tddrives+2(a4)
move.w #tddrives,d0
bsr putstrw
move.l 14(a5),d0
beq.s 8$
move.l d0,a0
move.l 16(a0),d0
8$ bsr getaskname2
bsr newline
bra.s 7$
3$ addq #1,d5
cmp.w #4,d5
bmi 2$
R_T_S rts
gettdtasks lea tdd(a4),a1
move.l SysBase(a4),a0
lea 350(a0),a0
CALL FindName,SysBase(a4)
tst.l d0
beq.s 2$
move.l d0,a3
lea 36(a3),a3
lea tdtasks(a4),a5
1$ move.l (a3)+,d0
beq.s 2$
move.l d0,a2
move.l 16(a2),(a5)+
bra.s 1$
2$ rts
putlongascii
movem.l d1/d2,-(a7)
moveq #2,d2
move.b d0,d1
3$ lsr.l #8,d0
lsl.l #8,d1
move.b d0,d1
dbf d2,3$
moveq #3,d2
1$ move.b d1,d0
beq.s 4$
bsr putchar
4$ lsr.l #8,d1
dbf d2,1$
2$ movem.l (a7)+,d1/d2
rts
putstamp movem.l d0-d1,-(a7)
move.l #3600,d1
bsr div
moveq #3,d3
bsr longdec
move.l binarea+4(a4),d0
lsr.l #8,d0
bsr.s putlongascii
moveq #':',d0
bsr putchar
move.l d1,d0
moveq #60,d1
bsr div
bsr.s write2digs
moveq #':',d0
bsr putchar
move.l d1,d0
bsr write2digs
movem.l (a7)+,d0-d1
rts
write2digs movem.l d0-d1,-(a7)
divu #10,d0
move.l d0,d1
or.b #'0',d0
bsr putchar
swap d1
or.b #'0',d1
move.b d1,d0
bsr putchar
movem.l (a7)+,d0-d1
rts
starttasktimer
lea tsecs(a4),a0
lea tmics(a4),a1
CALL CurrentTime,intuibase(a4)
bsr getaskdat2
move.l tsecs(a4),d0
lea taskstampid,a0
lea taskstamps,a1
lea usedtime,a2
moveq #0,d1
1$ subq.b #1,d5
bmi.s 2$
lea -16(a5),a5
move.l 0(a5),(a0)+
move.l d0,(a1)+
clr.l (a2)+
addq.w #1,d1
cmp.w #128,d1
bmi.s 1$
2$ move.w d1,numtaskstimed(a4)
rts
longdecn move.l d3,-(a7)
moveq #3,d3
bsr longdec
move.l (a7)+,d3
move.l #binarea+7+dataarea,d0
sub.l d3,d0
bra putstr
getstackptr move.l a1,-(a7)
move.l sysbase,a6
move.l d0,a1 ;original stackpointer
moveq #0,d0 ;offset 0 if no FPU
btst #4,297(a6) ;AttnFlags FPU
beq.s 1$ ;no FPU
tst.b (a1) ;NULL frame ?
beq.s 0$ ;yes
move.w (a1),d0 ;frame flag / format word
lea 110(a1),a1 ;offset to fpu regs
cmp.w #-1,d0
beq.s 3$
lea 12(a1),a1 ;add 3 longs
3$ moveq #0,d0
move.b 1(a1),d0 ;frame size
lea 4(a1,d0),a1 ;680xx frame
bra.s 2$
0$ moveq #4,d0 ;offset NULL frame
1$ lea 0(a1,d0),a1 ;680xx frame
2$ move.l a1,d0
move.l (a7)+,a1
rts
killidle bra.s killidle
dataarea:
dosbase EQU *-dataarea
.dosbase dc.l 0
intuibase EQU *-dataarea
.intuibase dc.l 0
gfxbase EQU *-dataarea
.gfxbase dc.l 0
condev EQU *-dataarea
.condev dc.l 0
parmtxt EQU *-dataarea
.parmtxt dc.l 0
infile EQU *-dataarea
.infile dc.l 0
ptr EQU *-dataarea
.ptr dc.l 0
auxsig EQU *-dataarea
.auxsig dc.l 0
trapsignal EQU *-dataarea
.trapsignal dc.l 0
iostatus EQU *-dataarea
.iostatus dc.l -1
devstatus EQU *-dataarea
.devstatus dc.l -1
tasksigs EQU *-dataarea
.tasksigs dc.l 0
cancelbit EQU *-dataarea
.cancelbit dc.l 0
cancelbnum EQU *-dataarea
.cancelbnum dc.l 0
SysBase EQU *-dataarea
_SysBase dc.l 0
InputMsg EQU *-dataarea
.InputMsg dc.l 0
InRequest EQU *-dataarea
.InRequest dc.l 0
startmess EQU *-dataarea
.startmess dc.l 0
savedat EQU *-dataarea
.savedat dc.l 0
wnptr EQU *-dataarea
.wnptr dc.l 0
aliaslist EQU *-dataarea
.aliaslist dc.l 0
screenptr EQU *-dataarea
.screenptr dc.l 0
intuimsg EQU *-dataarea
.intuimsg dc.l 0
mytask EQU *-dataarea
.mytask dc.l 0
wbmsg EQU *-dataarea
.wbmsg dc.l 0
pointer EQU *-dataarea
.pointer dc.l 0
replyport EQU *-dataarea
.replyport dc.l 0
timerport EQU *-dataarea
.timerport dc.l 0
finfoptr EQU *-dataarea
.finfoptr dc.l 0
myseg EQU *-dataarea
.myseg dc.l 0
dispatches EQU *-dataarea
.dispatches dc.l 0
maxdisp EQU *-dataarea
.maxdisp dc.l 0
deltadisp EQU *-dataarea
.deltadisp dc.l 0
node EQU *-dataarea
.node dc.l 0
remembr EQU *-dataarea
.remembr dc.l 0
remembr2 EQU *-dataarea
.remembr2 dc.l 0
captask EQU *-dataarea
.captask dc.l 0
snoopport EQU *-dataarea
.snoopport dc.l 0
tasksnum EQU *-dataarea
.tasksnum dc.l 0
blanks EQU *-dataarea
.blanks dc.l 0
hidestart EQU *-dataarea
.hidestart dc.l 0
iocount EQU *-dataarea
.iocount dc.l 0
dummyinput EQU *-dataarea
.dummyinput dc.l 0
rastport EQU *-dataarea
.rastport dc.l 0
outchain EQU *-dataarea
.outchain dc.l 0
firstline EQU *-dataarea
.firstline dc.l 0
oldfirstline EQU *-dataarea
.oldfirstline dc.l 0
timeoutm EQU *-dataarea
.timeoutm dc.l 0
numlines EQU *-dataarea
.numlines dc.l 0
oldnumlines EQU *-dataarea
.oldnumlines dc.l 0
gothline EQU *-dataarea
.gothline dc.l 0
lastprinted EQU *-dataarea
.lastprinted dc.l 0
oldlastprinted EQU *-dataarea
.oldlastprinted dc.l 0
oldpageend EQU *-dataarea
.oldpageend dc.l 0
maxlines EQU *-dataarea
.maxlines dc.l 500
realstack EQU *-dataarea
.realstack dc.l 0
capiscli EQU *-dataarea
.capiscli dc.l 0
capseg EQU *-dataarea
.capseg dc.l 0
tdtasks EQU *-dataarea
.tdtasks ds.l 4
idletask EQU *-dataarea
.idletask dc.l 0
oldswitches EQU *-dataarea
.oldswitches dc.l 0
tsecs EQU *-dataarea
.tsecs dc.l 0
tmics EQU *-dataarea
.tmics dc.l 0
devicelock EQU *-dataarea
.devicelock dc.l 0
timerbase EQU *-dataarea
.timerbase dc.l 0
timerticks EQU *-dataarea
.timerticks dc.l 0
wnnormflgs EQU *-dataarea
.wnnormflgs dc.l $646+$20+$10
dc.l $1104f
wnscrflags EQU *-dataarea
.wnscrflags dc.l $640+$20+$10
dc.l $31948
fkeys EQU *-dataarea
.fkeys dc.l *+4
dc.l 0
dc.l .fkeys
history EQU *-dataarea
.history dc.l *+4
dc.l 0
dc.l .history
curhist EQU *-dataarea
.curhist dc.l 0
secs EQU *-dataarea
.secs dc.l 0
mics EQU *-dataarea
.mics dc.l 0
time10 EQU *-dataarea
.time10 dc.l 0
tattr EQU *-dataarea
.tattr dc.l fontname+dataarea
dc.w 8
dc.w 0
stplist EQU *-dataarea
.stplist dc.l lh_tail
lh_tail EQU *-dataarea
.lh_tail dc.l 0
dc.l .stplist
dc.b 1
dc.b 0
InInterrupt EQU *-dataarea
.InInterrupt dc.l 0 ;ln_Succ
dc.l 0 ;ln_Pred
dc.b 2 ;ln_Type
dc.b 60 ;ln_Pri
dc.l xopsleep+dataarea ;ln_Name
dc.l 0 ;is_Data
dc.l Keyhandler ;is_Code()
IOCounter EQU *-dataarea
.IOCounter dc.l 0 ;ln_Succ
dc.l 0 ;ln_Pred
dc.b 2 ;ln_Type
dc.b -1 ;ln_Pri
dc.l IOcntname+dataarea ;ln_Name
dc.l 0 ;is_Data
dc.l countio ;is_Code()
newwindow EQU *-dataarea
.newwindow dc.w 0,0
dc.w 500,100
dc.b 0,1
nwflgs EQU *-dataarea
.nwflgs dc.l $646|$20
dc.l $1104f
wn_firstgad EQU *-dataarea
.wn_firstgad dc.l 0
dc.l 0
dc.l windowname+dataarea
nwscreen EQU *-dataarea
.nwscreen dc.l 0
dc.l 0
minwsize EQU *-dataarea
.minwsize dc.w 110,50
dc.w 808,-1
nwtype EQU *-dataarea
.nwtype dc.w 1
newscreen EQU *-dataarea
.newscreen dc.w 0,0
nssize EQU *-dataarea
.nssize dc.w 0,0
dc.w 1
dc.b 0
dc.b 1
nsviewmode EQU *-dataarea
.nsviewmode dc.w 0
dc.w $1f
dc.l 0
dc.l windowname+dataarea
dc.l 0,0
excpterror EQU *-dataarea
.excpterror dc.l 0
excpttask EQU *-dataarea
.excpttask dc.l 0
excptaddr EQU *-dataarea
.excptaddr dc.l 0
excptpc EQU *-dataarea
.excptpc dc.l 0
window_l EQU *-dataarea
.window_l dc.w 0
window_t EQU *-dataarea
.window_t dc.w 0
window_w EQU *-dataarea
.window_w dc.w 550
window_h EQU *-dataarea
.window_h dc.w 200
colms EQU *-dataarea
.colms dc.w 0
timersig EQU *-dataarea
.timersig dc.w 0
intuisig EQU *-dataarea
.intuisig dc.w 0
ibufferlen EQU *-dataarea
.ibufferlen dc.w 0
cposy EQU *-dataarea
.cposy dc.w 0
curpos EQU *-dataarea
.curpos dc.w 0
bottomin EQU *-dataarea
.bottomin dc.w 1
ipos EQU *-dataarea
.ipos dc.w 0
hnum EQU *-dataarea
.hnum dc.w 0
minnumchars EQU *-dataarea
.minnumchars dc.w 2
maxhlines EQU *-dataarea
.maxhlines dc.w 10
qualifier EQU *-dataarea
.qualifier dc.w 0
rows EQU *-dataarea
.rows dc.w 0
maxllength EQU *-dataarea
.maxllength dc.w 0
loffset EQU *-dataarea
.loffset dc.w 0
repeat EQU *-dataarea
.repeat dc.w 0
repeatlen EQU *-dataarea
.repeatlen dc.w 0
edline EQU *-dataarea
.edline dc.w 999
cmdptr EQU *-dataarea
.cmdptr dc.w 0
getanswer EQU *-dataarea
.getanswer dc.w 0
currenty EQU *-dataarea
.currenty dc.w 0
cmdcompnr EQU *-dataarea
.cmdcompnr dc.w 0
cmdcomplen EQU *-dataarea
.cmdcomplen dc.w -1
cmdcompflag EQU *-dataarea
.cmdcompflag dc.w 0
numtaskstimed EQU *-dataarea
.numtaskstimed dc.w 0
patchwhat EQU *-dataarea
.patchwhat dc.w 0
dosoffset EQU *-dataarea
.dosoffset dc.w 0
sampleio EQU *-dataarea
.sampleio ds.b 40
binarea EQU *-dataarea
.binarea dc.b ' ',0
EVEN
minus EQU *-dataarea
.minus dc.b ' '
decimal EQU *-dataarea
.decimal dc.b ' ',0
entries EQU *-dataarea
.entries dc.b 0
timeout EQU *-dataarea
.timeout dc.b 5
procnum EQU *-dataarea
.procnum dc.b 0
timerstate EQU *-dataarea
.timerstate dc.b 0
running EQU *-dataarea
.running dc.b 0
newpri EQU *-dataarea
.newpri dc.b 0
tasktyp EQU *-dataarea
.tasktyp dc.b 0
background EQU *-dataarea
.background dc.b 0
bool EQU *-dataarea
.bool dc.b 0
printed EQU *-dataarea
.printed dc.b 0
cbreak EQU *-dataarea
.cbreak dc.b 0
usageflag EQU *-dataarea
.usageflag dc.b 0
mnflag EQU *-dataarea
.mnflag dc.b 1
tports EQU *-dataarea
.tports dc.b 0
headon EQU *-dataarea
.headon dc.b 1
hideoff EQU *-dataarea
.hideoff dc.b 0
sorton EQU *-dataarea
.sorton dc.b 1
wanttraps EQU *-dataarea
.wanttraps dc.b 0
addlines EQU *-dataarea
.addlines dc.b 0
fromfile EQU *-dataarea
.fromfile dc.b 0
iconifyon EQU *-dataarea
.iconifyon dc.b 1
gotguru EQU *-dataarea
.gotguru dc.b 0
ownscreen EQU *-dataarea
.ownscreen dc.b 0
insmode EQU *-dataarea
.insmode dc.b 0
cmdcli EQU *-dataarea
.cmdcli dc.b 1
capgone EQU *-dataarea
.capgone dc.b 0
capwaiting EQU *-dataarea
.capwaiting dc.b 0
tinfo EQU *-dataarea
.tinfo dc.b 1
cliexec EQU *-dataarea
.cliexec dc.b 0
propgadon EQU *-dataarea
.propgadon dc.b 1
propupdate EQU *-dataarea
.propupdate dc.b 1
finfopen EQU *-dataarea
.finfopen dc.b -1
post_V34 EQU *-dataarea
.post_V34 dc.b 0
params EQU *-dataarea
.params dc.b 'tfdlrempiscua'
parmnum equ *-dataarea-params
.parmnum dc.b 0
t2header EQU *-dataarea
.t2header dc.b ' ID STATE SIGALLOC SIGWAIT SIGRECVD PC FPU TASKNAME',0
t3header EQU *-dataarea
.t3header dc.b ' ID STATE SIGALLOC SIGWAIT SIGRECVD PC TASKNAME',0
t4header EQU *-dataarea
.t4header dc.b ' ID STATE RUNNING ACTIVE NUM TASKNAME',0
theader EQU *-dataarea
.theader dc.b ' ID TYPE STATE PRI CPUSE NUM TASKNAME',0
lheader EQU *-dataarea
.lheader dc.b ' NODE CNT VER REV FLAGS ',0
libnam EQU *-dataarea
.libnam dc.b 'LIBRARY NAME',0
devnam EQU *-dataarea
.devnam dc.b 'DEVICE NAME',0
resnam EQU *-dataarea
.resnam dc.b 'RESOURCE NAME',0
mheader EQU *-dataarea
.mheader dc.b ' LOWER UPPER FREE ATTR PRI HUNK NAME',0
cr EQU *-dataarea
.cr dc.b 10,0
iheader EQU *-dataarea
.iheader dc.b ' NODE DATA CODE PRI T S TYPE INTERRUPT NAME',0
inheader EQU *-dataarea
.inheader dc.b ' NODE DATA CODE PRI NAME',0
rheader EQU *-dataarea
.rheader dc.b ' ADDR PRI FLAGS VER TYPE RESIDENT NAME',0
pheader EQU *-dataarea
.pheader dc.b ' NODE PORTNAME FLAGS SIGBT NUM SIGTASK',0
hunkheader EQU *-dataarea
.hunkheader dc.b ' NUM BCPL DATA LENGTH',0
ddheader EQU *-dataarea
.ddheader dc.b 'DEVICE HDS SECTORS TRACKS BUFFERS STATE HANDLER',0
cdheader EQU *-dataarea
.cdheader dc.b 'PROCESSNAME CURRENT DIRECTORY',0
ofheader EQU *-dataarea
.ofheader dc.b ' LOCK ACCESS SIZE PATH/FILENAME',0
scrheader EQU *-dataarea
.scrheader dc.b 'NUM ADDR SIZE DPTH TITLE',0
wnheader EQU *-dataarea
.wnheader dc.b ' ADDR OWNERTASK X Y SIZE TITLE',0
fohead EQU *-dataarea
.fohead dc.b ' NODE CNT Y X TYPE LO HI NAME',0
kickhead EQU *-dataarea
.kickhead dc.b 'START END LENGTH',0
snoophead EQU *-dataarea
.snoophead dc.b 'ACTION REQUIREMENTS LENGTH FROM TO CALLER',0
stackhead EQU *-dataarea
.stackhead dc.b 'SPLower SIZE USED TASKNAME',0
clicomhead EQU *-dataarea
.clicomhead dc.b ' ID STATE TYPE MODE NUM PROCESSNAME COMMAND',0
tiohead EQU *-dataarea
.tiohead dc.b 'IORQUEST UNIT SECS REQUESTING TASK',0
dchead EQU *-dataarea
.dchead dc.b ' NODE DATA CODE UNIT TASK',0
alhead EQU *-dataarea
.alhead dc.b 'ALIAS NAME COMMAND',0
semhead EQU *-dataarea
.semhead dc.b ' NODE OWNER QUEUE NEST NAME',0
fraghead EQU *-dataarea
.fraghead dc.b 'HEX SIZE DEC COUNT LARGEST',0
fkhead EQU *-dataarea
.fkhead dc.b 'KEY STRING',0
fileshead EQU *-dataarea
.fileshead dc.b ' TASK HANDLE MODE FILENAME',0
tdd EQU *-dataarea
.tdd dc.b 'trackdisk.device',0
tddrives EQU *-dataarea
.tddrives dc.b 'DF : ',0
onstr EQU *-dataarea
.onstr dc.b 'on',0
offstr EQU *-dataarea
.offstr dc.b 'off',0
unitmsg EQU *-dataarea
.unitmsg dc.b ' (Unit # )',0
timerunits EQU *-dataarea
.timerunits dc.b 'MicroHz ',0
dc.b 'VBlank ',0
fmode EQU *-dataarea
dc.b ' R/W ',0
access EQU *-dataarea
.access dc.b ' Read ',0
dc.b ' Write ',0
romfnt EQU *-dataarea
.romfnt dc.b 'Rom ',0
diskfnt EQU *-dataarea
.diskfnt dc.b 'Disk ',0
ffixed EQU *-dataarea
.ffixed dc.b 'Fixed ',0
fprop EQU *-dataarea
.fprop dc.b 'Propl ',0
status EQU *-dataarea
.status dc.b 'Added ',0
dc.b 'Running ',0
dc.b 'Ready ',0
dc.b 'Waiting ',0
dc.b 'Exeption',0
dc.b 'Removed ',0
dc.b 'Frozen ',0
dc.b 'Frozen ',0
type EQU *-dataarea
.type dc.b 'Unknown ',0
tasktype EQU *-dataarea
.tasktype dc.b 'Task ',0
dc.b 'Interrupt ',0
dc.b 'Device ',0
dc.b 'Msgport ',0
dc.b 'Message ',0
dc.b 'Freemsg ',0
dc.b 'Replymsg ',0
dc.b 'Resource ',0
dc.b 'Library ',0
dc.b 'Memory ',0
softinttype EQU *-dataarea
.softinttype dc.b 'Softint ',0
dc.b 'Font ',0
proctype EQU *-dataarea
.proctype dc.b 'Process ',0
dc.b 'Semaphore ',0
mp_flags EQU *-dataarea
.mp_flags dc.b 'Signal ',0
dc.b 'Softint ',0
dc.b 'Ignore ',0
windowname EQU *-dataarea
.windowname dc.b 'Xoper V2.3',$a9,' 1991 Werner G',$fc,'nther',0
newname EQU *-dataarea
.newname dc.b 'Xoper ',0
memportname EQU *-dataarea
.memportname dc.b 'SnoopPort',0
xopcon EQU *-dataarea
.xopcon dc.b 'XopPackets',0
xopsleep EQU *-dataarea
.xopsleep dc.b 'Xop-A-A-x',0
IOcntname EQU *-dataarea
.IOcntname dc.b 'Xop-I/O-counter',0
kidlename EQU *-dataarea
.kidlename dc.b 'Xop-Idle-Killer',0
cmdnum set 0
commds EQU *-dataarea
.commds ADDCMD 'time'
ADDCMD 'taskpri'
ADDCMD 'info'
ADDCMD 'pri'
ADDCMD 'flush'
ADDCMD 'freeze'
ADDCMD 'warm'
ADDCMD 'signal'
ADDCMD 'break'
ADDCMD 'alert'
ADDCMD 'lastalert'
ADDCMD 'hold'
ADDCMD 'exit'
ADDCMD 'clear'
ADDCMD 'cancel'
ADDCMD 'taskports'
ADDCMD 'hunks'
ADDCMD 'devices'
ADDCMD 'openlib'
ADDCMD 'closelib'
ADDCMD 'currentdir'
ADDCMD 'cd'
ADDCMD 'mypri'
ADDCMD 'files'
ADDCMD 'locks'
ADDCMD 'unlock'
ADDCMD 'screens'
ADDCMD 'windows'
ADDCMD 'closescreen'
ADDCMD 'closewindow'
ADDCMD 'fonts'
ADDCMD 'windowfonts'
ADDCMD 'lockdrive'
ADDCMD 'freedrive'
ADDCMD 'capture'
ADDCMD 'clrcold'
ADDCMD 'clrcool'
ADDCMD 'clrwarm'
ADDCMD 'snoop'
ADDCMD 'usage'
ADDCMD 'inputhandler'
ADDCMD 'header'
ADDCMD 'sort'
ADDCMD 'hide'
ADDCMD 'hidden'
ADDCMD 'window'
ADDCMD 'kill'
ADDCMD 'iconifyoff'
ADDCMD 'historylines'
ADDCMD 'minimumchars'
ADDCMD 'showhistory'
ADDCMD 'repeat'
ADDCMD 'remresident'
ADDCMD 'saveoutput'
ADDCMD 'killhistory'
ADDCMD 'backdropicon'
ADDCMD 'setfont'
ADDCMD 'trapguru'
ADDCMD 'outputlines'
ADDCMD 'usescreen'
ADDCMD 'usewindow'
ADDCMD 'timerio'
ADDCMD 'diskchange'
ADDCMD 'alias'
ADDCMD 'remnode'
ADDCMD 'setfkey'
ADDCMD 'clicmd'
ADDCMD 'taskinfo'
ADDCMD 'coldreboot'
ADDCMD 'reboot'
ADDCMD 'zerotimer'
ADDCMD 'propgadoff'
ADDCMD 'iconpos'
ADDCMD 'remport'
ADDCMD 'remintserver'
ADDCMD 'frags'
ADDCMD 'traceopen'
ADDCMD 'snoopmem'
ADDCMD 'tracelock'
IFNE ((tasktime-cmdaddr)/4)-cmdnum
ERROR !! COMMAND NAME OR JUMP VECTOR MISSING !!
ENDIF
hexarea EQU *-dataarea
.hexarea dc.b ' ',0
hextab EQU *-dataarea
.hextab dc.b '0123456789abcdef'
infoh2 EQU *-dataarea
.infoh2 dc.b 'Dispat/Sec:',0
infoh1 EQU *-dataarea
.infoh1 dc.b 'CPU:',0
infoh3 EQU *-dataarea
.infoh3 dc.b 'CPU activity: ',0
infoh6 EQU *-dataarea
.infoh6 dc.b 'Total:',0
infoh4 EQU *-dataarea
.infoh4 dc.b '% ',0
infoh7 EQU *-dataarea
.infoh7 dc.b 'I/O Ints/Sec: ',0
cpu0 EQU *-dataarea
.cpu0 dc.b '68000',0
cpu1 EQU *-dataarea
.cpu1 dc.b '68010',0
cpu2 EQU *-dataarea
.cpu2 dc.b '68020',0
cpu3 EQU *-dataarea
.cpu3 dc.b '68030',0
cpu4 EQU *-dataarea
.cpu4 dc.b '/68881',0
cpu5 EQU *-dataarea
.cpu5 dc.b '/68882',0
nofpu EQU *-dataarea
.nofpu dc.b '---- ',0
nullstate EQU *-dataarea
.nullstate dc.b 'NULL ',0
idle EQU *-dataarea
.idle dc.b 'IDLE ',0
busy EQU *-dataarea
.busy dc.b 'BUSY ',0
weissnicht EQU *-dataarea
.weissnicht dc.b '???? ',0
devload EQU *-dataarea
.devload dc.b 'loaded ',0
devnload EQU *-dataarea
.devnload dc.b 'unloaded ',0
inten EQU *-dataarea
.inten dc.b 'E ',0
intdis EQU *-dataarea
.intdis dc.b 'D ',0
intserv EQU *-dataarea
.intserv dc.b 'S ',0
inthand EQU *-dataarea
.inthand dc.b 'H ',0
notfile EQU *-dataarea
.notfile dc.b '--- ------- ------- ------- ',0
longnix EQU *-dataarea
.longnix dc.b '-'
smallnix EQU *-dataarea
.smallnix dc.b '----'
nix EQU *-dataarea
.nix dc.b '--- ',0
noinfo EQU *-dataarea
.noinfo dc.b 'No Info on'
oneblank EQU *-dataarea
.oneblank dc.b ' ',0
equal EQU *-dataarea
.equal dc.b '= ',0
openbrak EQU *-dataarea
.openbrak dc.b '[ ',0
closebrak EQU *-dataarea
.closebrak dc.b ' ]',0
namerr EQU *-dataarea
.namerr dc.b 'Unable to find ',0
fonterr EQU *-dataarea
.fonterr dc.b "Can't open ",0
adrerr EQU *-dataarea
.adrerr dc.b 'Address Error!',0
aliaserr EQU *-dataarea
.aliaserr dc.b 'Single character alias names using "',0
aliaserr2 EQU *-dataarea
.aliaserr2 dc.b '"',10,'are not allowed.',0
noworkbench EQU *-dataarea
.noworkbench dc.b "Workbench isn't active !",0
openerr EQU *-dataarea
.openerr dc.b 'Could not open file ',0
noderr EQU *-dataarea
.noderr dc.b "Can't find this Node. Continue anyway ? (Y/N)",0
listerr EQU *-dataarea
.listerr dc.b 'Unable to find ListHeader. Sort aborted.',0
wiwerr EQU *-dataarea
.wiwerr dc.b 'Script file only',0
gurutxt EQU *-dataarea
.gurutxt dc.b 'Guru Meditation #',0
clrtxt EQU *-dataarea
.clrtxt dc.b 'Memory Hunks cleared.',0
canerr0 EQU *-dataarea
.canerr0 dc.b 'Process is not a CLI-task',10
dc.b 'Has it been started from Workbench ? (Y/N)',10,0
canerr1 EQU *-dataarea
.canerr1 dc.b 'Process was created by CreateProc()',10
dc.b 'Shall I UnLoad() ? (Y/N)',10,0
unloaderr EQU *-dataarea
.unloaderr dc.b "Arrrgh.. can't find segments, aborting",0
noprocs EQU *-dataarea
.noprocs dc.b 'Not a Process.',0
notload EQU *-dataarea
.notload dc.b 'No program loaded.',0
cliprocs EQU *-dataarea
.cliprocs dc.b 'Cli-Process',0
procloaded EQU *-dataarea
.procloaded dc.b 'Loaded as a command: ',0
segloaded EQU *-dataarea
.segloaded dc.b 'Created by CreateProc()',0
coldtxt EQU *-dataarea
.coldtxt dc.b 'Cold Capture: ',0
cooltxt EQU *-dataarea
.cooltxt dc.b 'Cool Capture: ',0
warmtxt EQU *-dataarea
.warmtxt dc.b 'Warm Capture: ',0
kicktxt EQU *-dataarea
.kicktxt dc.b 'KickMem : ',0
unset EQU *-dataarea
.unset dc.b 'unset',0
wbname EQU *-dataarea
.wbname dc.b 'Workbench',0
intnames EQU *-dataarea
.intnames dc.b 'Serial Out ',0
dc.b 'Disk Block ',0
dc.b 'SoftInt ',0
dc.b 'Ports ',0
dc.b 'Coper ',0
dc.b 'Vert.Blank ',0
dc.b 'Blitter ',0
dc.b 'Audio Ch.0 ',0
dc.b 'Audio Ch.1 ',0
dc.b 'Audio Ch.2 ',0
dc.b 'Audio Ch.3 ',0
dc.b 'Serial In ',0
dc.b 'Disk Sync ',0
dc.b 'External ',0
dc.b 'SoftInt ',0
dc.b 'NMI ',0
inttyp EQU *-dataarea
.inttyp dc.b 0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1
fontname EQU *-dataarea
.fontname dc.b 'topaz.font',0
devicenam EQU *-dataarea
.devicenam dc.b 'input.device',0
timernam EQU *-dataarea
.timernam dc.b 'timer.device',0
memlarg EQU *-dataarea
.memlarg dc.b 'LARGEST ',0
memclr EQU *-dataarea
.memclr dc.b 'CLEAR ',0
memfast EQU *-dataarea
.memfast dc.b 'FAST ',0
memchip EQU *-dataarea
.memchip dc.b 'CHIP ',0
mempubl EQU *-dataarea
.mempubl dc.b 'PUBLIC ',0
failed EQU *-dataarea
.failed dc.b 'Failed !',0
allok EQU *-dataarea
.allok dc.b 'ALLOC: ',0
free EQU *-dataarea
.free dc.b 'FREE: ',0
backg EQU *-dataarea
.backg dc.b 'Bckg ',0
foreg EQU *-dataarea
.foreg dc.b 'Frgr ',0
script EQU *-dataarea
.script dc.b 'Batch ',0
interact EQU *-dataarea
.interact dc.b 'Intct ',0
IFND DEBUG
startupname EQU *-dataarea
.startupname dc.b 'S:Xoper.Startup',0
ENDC
IFD DEBUG
startupname EQU *-dataarea
.startupname dc.b 'S:Test.Startup',0
ENDC
nameerr EQU *-dataarea
.nameerr dc.b 'Name or address is missing.',10
synerr EQU *-dataarea
.synerr dc.b 'Syntax Error, type "?" for help',10,0
dnotf EQU *-dataarea
.dnotf dc.b 'Directory not found',0
notdir EQU *-dataarea
.notdir dc.b 'Not a directory',0
nomount EQU *-dataarea
.nomount dc.b ' not mounted.',0
dishelp EQU *-dataarea
.dishelp dc.b 10,'Names are case sensitive and followed by a ":"',0
unlerr EQU *-dataarea
.unlerr dc.b 'Lock not found',0
unl1 EQU *-dataarea
.unl1 dc.b 'Lock is on ',0
unltxt EQU *-dataarea
.unltxt dc.b 'Old lock was: ',0
unltxt2 EQU *-dataarea
.unltxt2 dc.b 'Unlock ? (Y/N)',10,0
scnofound EQU *-dataarea
.scnofound dc.b 'Screen not found.',0
winnofound EQU *-dataarea
.winnofound dc.b 'Window not found.',0
stperr EQU *-dataarea
.stperr dc.b 'Task must be "READY" or "WAITING"',10,0
waerr EQU *-dataarea
.waerr dc.b 'Task must be "FROZEN"',10,0
whatsthis EQU *-dataarea
.whatsthis dc.b '???.?',0
toomuch EQU *-dataarea
.toomuch dc.b '??? ',0
timenotset EQU *-dataarea
.timenotset dc.b ' disabled.',0
whattime EQU *-dataarea
.whattime dc.b 'Refresh time in secs:',0
stoped EQU *-dataarea
.stoped dc.b '<Break>',0
capexited EQU *-dataarea
.capexited dc.b 'Task ended',0
capwait EQU *-dataarea
.capwait dc.b 'Waiting for startup...',0
onscr EQU *-dataarea
.onscr dc.b 'On Screen: ',0
whatnow EQU *-dataarea
.whatnow dc.b 'Kill, ignore (K/I)?',0
noguru EQU *-dataarea
.noguru dc.b 'None found.',0
softfail EQU *-dataarea
.softfail dc.b 'Software failure!',10,'Task: ',0
addrserr EQU *-dataarea
.addrserr dc.b 'Bad aligned address was: ',0
procount EQU *-dataarea
.procount dc.b 'PC: ',0
memtyp EQU *-dataarea
.memtyp dc.b 'Memory type: ',0
diskfont EQU *-dataarea
.diskfont dc.b 'diskfont.library',0
nintrserv EQU *-dataarea
.nintrserv dc.b "Not a server. Can't restore vectors",0
regnam EQU *-dataarea
.regnam dc.b "PCD0D1D2D3D4D5D6D7A0A1A2A3A4A5A6SP"
usetxt EQU *-dataarea
.usetxt dc.b 'USAGE: Xoper [T] [F] [L] [D] [R] [E] [M] [P] [I] [S] [C] [U] [A]',10
dc.b 'OR Xoper -b',10
dc.b 'DISPLAY:',10
dc.b '[T]asks task[F]lags [L]ibraries [D]evices [R]esources',10
dc.b 'r[E]sident [M]emory [P]orts [I]nterrupts [S]tack',10
dc.b '[C]litasks task[U]sage sem[A]phores [Q]uit',10,10
dc.b 'OTHER SYSTEM LISTS:',10
dc.b 'Windows Screens Fonts WindowFonts CurrentDir',10
dc.b 'Files Locks Devices InputHandler Capture',10
dc.b 'TimerIO DiskChange Frags TraceOpen TraceLock',10,10
dc.b 'COMMANDS:',10
dc.b 'Time <secs>',10
dc.b 'Taskpri <priority> [processnum] <taskname>',10
dc.b 'Mypri <priority>',10
dc.b 'Signal <mask(hex)> [processnum] <taskname>',10
dc.b 'Break [processnum] <taskname>',10
dc.b 'Freeze|Warm [processnum] <taskname>',10
dc.b 'Kill [processnum] <taskname>',10
dc.b 'SnoopMem [processnum] <taskname>',10
dc.b 'ZeroTimer [processnum] <taskname>',10
dc.b 'Hide <taskname>',10
dc.b 'Pri <priority> <nodename>',10
dc.b 'Info <name>',10
dc.b 'RemResident <resident module name>',10
dc.b 'RemIntServer <interrupt address>',10
dc.b 'Clear <longword(hex)>',10
dc.b 'Hunks [processnum] <procname>',10
dc.b 'CD <directory> [processnum] <procname>',10
dc.b 'UnLock <lock>',10
dc.b 'OpenLib | Closelib <libraryname>',10
dc.b 'CloseWindow| Closescreen <title>',10
dc.b 'SetFont [size] <fontname> <windowtitle>',10
dc.b 'LockDrive | Freedrive <drivename:>',10
dc.b 'Window <leftedge topedge width height> (scriptfile only) ',10
dc.b 'IconPos <leftedge topedge>',10
dc.b 'OutputLines <maximum # of lines>',10
dc.b 'HistoryLines <maximum # of lines>',10
dc.b 'MinimumChars <minimum # of characters>',10
dc.b 'SaveOutput <filename>',10
dc.b 'Repeat <Command line>',10
dc.b 'SetFKey <number> <string>',10
dc.b 'Alias [<aliasname> <commandname>]',10,10
dc.b 'COMMANDS WITHOUT PARAMETERS:',10
dc.b 'Flush LastAlert ClrCool ClrCold ClrWarm',10
dc.b 'TrapGuru',10,10
dc.b 'OPTIONS:',10
dc.b 'Sort TaskPorts Hidden Usage Header',10
dc.b 'IconifyOff BackDropIcon ShowHistory KillHistory UseScreen',10
dc.b 'UseWindow CLICmd TaskInfo PropGadOff',10
dc.b 'Hold Exit'
null EQU *-dataarea
.null dc.b 0
IFD DEBUG
dosname
.dosname dc.b 'dos.library',0
intuiname
.intuiname dc.b 'intuition.library',0
gfxname
.gfxname dc.b 'graphics.library',0
conname
.conname dc.b 'console.device',0
EVEN
ENDC
BSS Data
mypacket
LN_SUCC ds.l 1
LN_PRED ds.l 1
LN_TYPE ds.b 1
LN_PRI ds.b 1
LN_NAME ds.l 1
MP_FLAGS ds.b 1
MP_SIGBIT ds.b 1
MP_SIGTASK ds.l 1
MN_SIZE ds.w 1
LH_HEAD ds.l 1
LH_TAIL ds.l 1
LH_TAILPRED ds.l 1
LH_TYPE ds.b 1
LH_pad ds.b 1
dp_Link ds.l 1
dp_Port ds.l 1
dp_Type ds.l 1
dp_Res1 ds.l 1
dp_Res2 ds.l 1
dp_Arg1 ds.l 1
dp_Arg2 ds.l 1
dp_Arg3 ds.l 1
dp_Arg4 ds.l 1
dp_Arg5 ds.l 1
dp_Arg6 ds.l 1
dp_Arg7 ds.l 1
buffer ds.b 2800
out ds.b 100
dummy ds.b 80
in ds.b 80
cputime ds.b 1000
taskstampid ds.l 128
taskstamps ds.l 128
usedtime ds.l 128
ievent ds.b 32
outevent ds.b 20
inputbuffer ds.b 88
timerio ds.b 40
repeatbuffer ds.b 81
CODE ICONIFY,CHIP
iconify lea icnwindow(PC),a0
CALL OpenWindow,intuibase(a4)
move.l d0,iconwindow
waitforcall move.l iconwindow(PC),a0
move.l $56(a0),a0 ;wn->UserPort
moveq #0,d1
move.l d1,d0
move.b 15(a0),d1 ;UserPort->SigBit
bset d1,d0
move.l d0,d6
or.l #(1<<mysignal),d0
or.l trapsignal(a4),d0
CALL Wait,SysBase(a4)
and.l d0,d6
bne.s fromwindow
move.l #(1<<mysignal),d1
and.l d0,d1
bne icondone
and.l trapsignal(a4),d0
beq.s waitforcall
move.b #1,gotguru(a4)
bra.s icondone
fromwindow move.l iconwindow,a0
move.l $56(a0),a0 ;wn->UserPort
CALL GetMsg,SysBase(a4)
tst.l d0
beq.s waitforcall
move.l d0,a1
CALL ReplyMsg,SysBase(a4)
move.l iconwindow(PC),a0
move.l 4(a0),d5
cmp.l icnwindow(PC),d5
bne.s 1$
lea nsecs(PC),a0
lea nmics(PC),a1
CALL CurrentTime,intuibase(a4)
movem.l osecs,d0-d3
CALL DoubleClick,intuibase(a4)
tst.l d0
bne.s icondone
move.l nsecs(PC),osecs
move.l nmics(PC),omics
1$ move.l d5,icnwindow
bra waitforcall
icondone move.l iconwindow(PC),a0
move.l 4(a0),icnwindow ;LeftEdge+TopEdge
tst.l iconwindow
beq.s 1$
CALL CloseWindow,intuibase(a4)
1$ rts
reverseimage
move #((imageend-imagedata)/4)-1,d0
lea imagedata(PC),a3
2$ eor.l #-1,(a3)+
dbf d0,2$
rts
osecs dc.l 0
omics dc.l 0
nsecs dc.l 0
nmics dc.l 0
iconwindow dc.l 0
icnwindow dc.w 40,170,72,28
dc.b 0,1
dc.l $20,$800
dc.l gadget,0,0,0,0
dc.w 72,28,72,28
dc.w 1
gadget dc.l 0
dc.w 0,0,72,28,4,2,$20
dc.l image
dc.l 0,0,0,0
dc.w 0
dc.l 0
image dc.w 0,0,72,28,2
dc.l imagedata
dc.b 3,0
dc.l 0
imagedata dc.w $000F,$FFFF,$FFFF,$FFF8,$0000,$001F,$FFFF,$FFFF
dc.w $FFFC,$0000,$001F,$0000,$0000,$007C,$0000,$001F
dc.w $7FFF,$FFFF,$FF7C,$0000,$001F,$4A46,$0244,$557C
dc.w $0000,$001F,$5108,$D411,$817C,$0000,$001F,$7FFF
dc.w $FFFF,$FF7C,$0000,$001F,$0000,$0000,$007C,$0000
dc.w $001F,$30C0,$0000,$007C,$0000,$001F,$1980,$0000
dc.w $007C,$0000,$001F,$0F0F,$1F0F,$1F7C,$0000,$001F
dc.w $0619,$9999,$997C,$0000,$001F,$0F19,$999F,$987C
dc.w $0000,$001F,$1999,$9F18,$187C,$0000,$001F,$30CF
dc.w $180F,$187C,$0000,$001F,$0000,$1800,$007C,$0000
dc.w $001F,$0000,$0000,$007C,$0000,$001F,$FFFF,$FFFF
dc.w $FFFC,$0000,$000F,$FFFF,$FFFF,$FF18,$0000,$0000
dc.w $0000,$0000,$0000,$0000,$3FFF,$FFFF,$FFFF,$FFFF
dc.w $FC00,$FDFF,$FFFF,$FFFF,$FFFF,$FF00,$EBFF,$FFFF
dc.w $FFFF,$FFFF,$FF00,$F7FF,$FFFF,$FFFF,$F800,$0700
dc.w $FFFF,$FFFF,$FFFF,$FFFF,$FF00,$FFFF,$FFFF,$FFFF
dc.w $FFFF,$FF00,$FFFF,$FFFF,$FFFF,$FFFF,$FF00,$3FFF
dc.w $FFFF,$FFFF,$FFFF,$FC00,$0000,$0000,$0000,$0000
dc.w $0000,$0000,$0000,$0000,$0000,$0000,$0000,$FFFF
dc.w $FFFF,$FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000
dc.w $0000,$FFFF,$FFFF,$FF80,$0000,$0000,$FFFF,$FFFF
dc.w $FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000,$0000
dc.w $FFFF,$FFFF,$FF80,$0000,$0000,$8000,$0000,$0080
dc.w $0000,$0000,$8000,$0000,$0080,$0000,$0000,$8000
dc.w $0000,$0080,$0000,$0000,$8000,$0000,$0080,$0000
dc.w $0000,$8000,$0000,$0080,$0000,$0000,$8000,$0000
dc.w $0080,$0000,$0000,$8000,$0000,$0080,$0000,$0000
dc.w $8000,$0000,$0080,$0000,$0000,$FFFF,$FFFF,$FF80
dc.w $0000,$0000,$0000,$0000,$00E0,$0000,$0000,$0000
dc.w $0000,$00E0,$0000,$0000,$1FFF,$FFFF,$F800,$0000
dc.w $0000,$0080,$0040,$0000,$0000,$0200,$0080,$0040
dc.w $0000,$0000,$1400,$0080,$0040,$003F,$0000,$0800
dc.w $0080,$0040,$07FF,$F800,$0000,$0080,$0040,$003F
dc.w $0000,$0000,$0080,$0040,$0000,$3800,$FFFF,$FFFF
dc.w $FFFF,$FFFF,$FE00,$0000,$0080,$0040,$0000,$0000
imageend
iconifgad dc.l 0
dc.w -83,0
dc.w 31,10
dc.w $14
dc.w $41
dc.w 1
dc.l iconifimg
dc.l 0
dc.l 0
dc.l 0
dc.l 0
dc.w 0
dc.l 0
iconifimg dc.w 0,0
dc.w 31,10
dc.w 2
dc.l iconifdata
dc.b $0003,$0000
dc.l 0
iconifdata dc.w $7FFF,$FFFC,$601F,$FFFC,$6000,$000C,$607F,$FFCC
dc.w $6060,$00CC,$6067,$FCCC,$7E60,$00CC,$7E7F,$FFCC
dc.w $7E00,$000C,$7FFF,$FFFC,$0000,$0000,$1FE0,$0000
dc.w $1FFF,$FFF0,$1F80,$0030,$1F9F,$FF30,$1F98,$0330
dc.w $019F,$FF30,$0180,$0030,$01FF,$FFF0,$0000,$0000
CODE SCROLLBAR
setprop btst.w #8,propinfo ;update slider position and
bne.s 8$ ;and size
moveq #0,d0
CALL LockIBase,intuibase(a4)
move.l d0,d5
move.l wnptr(a4),d0 ;see if the user hit the
beq.s 7$ ;scrollbar in the meantime
move.l d0,a0
move.l 86(a0),a0 ;wn->UserPort
lea 20(a0),a0 ;Userport->MsgList
5$ move.l 0(a0),d0
beq.s 6$ ;no more pending messages
move.l d0,a0
cmp.l #$20,20(a0) ;gadgetdown ?
bne.s 5$
move.l 28(a0),a1
cmp.w #3,38(a1) ;scrollbar ?
beq.s 7$
bra.s 5$
7$ move.l d5,a0
CALL UnlockIBase,intuibase(a4)
8$ rts
6$ move.l d5,a0
CALL UnlockIBase,intuibase(a4)
moveq #0,d2 ;VertPot = firstline*MAXPOT/(numlines-rows)
move.l numlines(a4),d3
sub.w rows(a4),d3
ble.s 1$
move.l firstline(a4),d2
mulu #65535,d2
divu d3,d2
1$ moveq #-1,d4 ;VertBody = rows*MAXBODY/numlines
move.w rows(a4),d5
ext.l d5
cmp.l numlines(a4),d5
bge.s 2$
mulu #$ffff,d5
move.l numlines(a4),d0
divu d0,d5
move.l d5,d4
2$ cmp.w propinfo+8(PC),d4 ;did something change ?
bne.s 3$
cmp.w propinfo+4(PC),d2
beq.s 4$
3$ lea sbgadget(PC),a0
move.l wnptr(a4),d0
beq.s 4$
move.l d0,a1
suba.l a2,a2
moveq #-1,d3
moveq #0,d1
moveq #1|4,d0
moveq #1,d5
CALL NewModifyProp,intuibase(a4)
4$ rts
proppos move.w propinfo+4(PC),d0 ;get slider position and update
move.l numlines(a4),d1 ;our window if necessary
sub.w rows(a4),d1
ble.s 1$
move.l #$ffff,d3 ;firstline=VertPot/(MAXPOT/numlines-rows)
divu d1,d3
divu d3,d0
ext.l d0
cmp.l firstline(a4),d0
beq.s 1$
move.l d0,firstline(a4)
jsr blastout
1$ rts
sbgadget dc.l 0
dc.w -14,9
dc.w 14,-20
dc.w $10|$40
dc.w 1|2|8|$10
dc.w 3
dc.l sbdata,0,0,0,propinfo
dc.w 3
dc.l 0
propinfo dc.w 1|4
dc.w 0,0
dc.w -1,-1
dc.w 0,0,0,0,0,0
sbdata ds.l 4
END