;---------------------------------------------------------------------
;NOSPOOL.ASM program to unhook SPOOLER RSX from system
;For CP/M+ Print Spooler v1.3.
;(c) March 1989 by Andy Metcalfe.
;---------------------------------------------------------------------
;
getdir	equ	43
bugoff	equ	46
;
	extrn cstrng
;
	jp	gonosp
;
	db	'NOSPOOL v1.3 '
	db	'(c) Andy Metcalfe, March 1989. '
;
gonosp:	ld	sp,stack
	ld	c,getver
	call	bdos		; Version check
	cp	31h
	ld	de,noplus
	jp	c,error		; No go if V2.2 or earlier
;
	ld	a,getdir
	ld	(rsxpb),a
	ld	de,rsxpb
	ld	c,calrsx
	call	bdos		; Ask RSX for the location of its directory
	ld	a,h
	ld	(splusr),a	; User
	ld	a,l
	ld	(spldrv),a	; Drive
	ld	a,bugoff
	ld	(rsxpb),a
	ld	de,rsxpb
	ld	c,calrsx
	call	bdos		; Ask RSX to uninstall
	call	delall		; Delete all SPOOLED.nnn files
				; In spool directory
	ld	c,wboot
	jp	bdos		; Reboot
;
;---------------------------------------------------------------------
;	Flag error & reboot
;
error:	call	cstrng
	ld	c,wboot
	jp	bdos
;
;---------------------------------------------------------------------
;	Erase all SPOOLED.nnn files in the spool directory
;
delall:	call	gousr		; Go to spool user area
	ld	a,(spldrv)
	ld	(ifcb),a	; Setup drive of fcb
	ld	hl,ifcb+9	; HL addresses filetype entry of fcb
	ld	a,'?'
	ld	(hl),a
	inc	hl
	ld	(hl),a
	inc	hl
	ld	(hl),a		; Set up wildcard type
	ld	de,ifcb
	ld	c,delete
	call	bdos		; Erase spooled files
	call	bakusr		; Back to original user area
	ret
;
rsxpb:	db	46
;
;---------------------------------------------------------------------
;	Save current user no in [userno], and set user area to that of
;	the spool directory.
;
gousr:	ld	c,user
	ld	e,0ffh
	call	bdos		; Get current user no
	ld	(userno),a	; Saved
	ld	a,(splusr)	; User no to set for spool directory
	ld	e,a
	ld	c,user
	call	bdos		; Go there
	ret
;
;---------------------------------------------------------------------
;	Restore user no stored by gousr
;
bakusr:	ld	a,(userno)
	ld	e,a
	ld	c,user
	call	bdos
	ret
;
;---------------------------------------------------------------------
;	Program messages
;
noplus:	db	'Sorry, this program requires CP/M+',cr,lf,'$'
;
;---------------------------------------------------------------------
;	Scratch pad area
;
userno:	ds	1
spldrv:	ds	1
splusr:	ds	1
ifcb:	db	0,'SPOOLED ???'
	ds	36-12
;
	ds	50
stack	equ	$
;
	end
