
; ***************************************************
; ****                                           ****
; ****              RECONTROL V1.2               ****
; ****                                           ****
; ****                                           ****
; ****       By:   Orlando Budelacci             ****
; ****             Birmannsgasse 34              ****
; ****             CH-4055 Basle                 ****
; ****             Switzerland                   ****
; ****                                           ****
; ****    Source published in Zine issue #8      ****
; ****                                           ****
; ****             by BRAINSTORM!                ****
; ****                ญญญญญญญญญญญ                ****
; ****                                           ****
; ****         Written with AsmOne V1.0          ****
; ****                                           ****
; ****                                           ****
; ****     as always... 100% pc-relative!!!      ****
; ****      (like every program should be!)      ****
; ****                                           ****
; ****                                           ****
; ****  Note: Don't start the program from the   ****
; ****        assembler! Write object file 'wo'  ****
; ****        and start it from the cli!!!       ****
; ****                                           ****
; ***************************************************


Output		= -60
OpenLib		= -408
CloseLib	= -414
Write		= -48

	lea	parameter(pc),a3
	move.l	a0,(a3)
	bne.s	go
	lea	optionflag(pc),a4
	move.b	#1,(a4)

go:
	move.l	4.w,a6
	lea	dosname(pc),a1
	jsr	OpenLib(a6)
	lea	dosbase(pc),a3
	move.l	d0,(a3)
	beq.w	exit
	move.l	dosbase(pc),a6
	jsr	Output(a6)
	lea	windowhandle(pc),a3
	move.l	d0,(a3)
	beq.b	exit
	lea	optionflag(pc),a4
	tst.b	(a4)
	beq.s	ok
	lea	infotext(pc),a1
	bsr.s	print
	bra.s	end

ok:	
	move.l	parameter(pc),a0
	move.b	(a0),d0
	bset	#5,d0
	moveq	#'o',d7
	cmp.b	d7,d0
	bne.w	error
	move.b	1(a0),d0
	bset	#5,d0
	moveq	#'n',d7
	cmp.b	d7,d0
	bne.s	test_off
	moveq	#-1,d5	
	bra.s	do_it

test_off:
	cmp.b	#'f',d0
	bne.s	error
	move.b	2(a0),d0
	bset	#5,d0
	moveq	#'f',d7
	cmp.b	d7,d0
	bne.s	error
	moveq	#0,d5
	lea	statustext(pc),a5
	moveq	#'F',d7
	move.b	d7,(a5)
	move.b	d7,1(a5)	

do_it:	lea	text(pc),a1
	bsr.s	print

	move.l	4.w,a6
	sub.l	a1,a1
	jsr	-294(a6)
	move.l	d0,a0
	beq.s	no_task_found
	move.l	d5,184(a0)	;pr_windowptr

end:
	move.l	4.w,a6
	move.l	dosbase(pc),a1
	jsr	CloseLib(a6)

exit:	moveq	#0,d0
	rts

no_task_found:
	lea	notasktext(pc),a1
	bsr.s	print
	bra.s	end

; -------------------------------------------
; ----             SUBROUTINES           ----
; -------------------------------------------

; *** Prints any ascii text in the current window ***
; *** Pointer to text must be in >>> a1 <<< ***
; *** Output handle must be stored in >>> windowhandle <<<<
; *** all registers saved and written back ***

print:
	movem.l	d0-d3/a1/a6,-(sp)
	move.l	a1,d2			;pointer to text
	moveq	#0,d3			;counter for chars

Endsearch:				;end of text is $00
	tst.b	(a1)+
	beq.s	EndFound
	addq.l	#1,d3
	dbf	d1,endsearch

Endfound:
	move.l	windowhandle(pc),d1
	move.l	dosbase(pc),a6	
	jsr	Write(a6)
	movem.l	(sp)+,d0-d3/a1/a6
	rts

Error:
	lea	infotext(pc),a1
	bsr.s	print
	bra.s	end

; -------------------------------------------
; ----                DATA               ----
; -------------------------------------------

dosname:	dc.b	'dos.library',0
		even

parameter:	dc.l	0
windowhandle:	dc.l	0
dosbase:	dc.l	0
optionflag:	dc.b	0

; -------------------------------------------
; ----           ASCII MESSAGES          ----
; -------------------------------------------

text:
 dc.b $9b,'1;33;40m'
 dc.b 'ReqControl V1.21 '
 dc.b $9b,'0;31;40m'
 dc.b '- by Orlando Budelacci, December 1990, Public domain. ',$a
 dc.b 'Status : O'
 statustext:
 dc.b 'N ',$a,0

infotext:
 dc.b 'ReqControl disables the poping up of the windows '
 dc.b 'from the Cli-process',$a
  dc.b 'Usage: Reqcontrol [On] [Off]',$a,$a
 dc.b 'The source of this program was published in '
 dc.b $9b,'0;33;40m'
 dc.b 'ZINE #8 by BRAINSTORM.'
 dc.b $9b,'0;31;40m',$a,$a
 dc.b 'Written by: ',$a
 dc.b ' Orlando Budelacci',$a
 dc.b ' Birmannsgasse 34',$a
 dc.b ' CH-4055 Basle',$a,$a
 dc.b 0

notasktext:
 dc.b 'HARD ERROR!!!',$a
 dc.b 'Task not found!!!',$a,$a
 dc.b 0

