;  LOGPPN.SBR - SUBROUTINE TO GET CURRENT LOG IN DRIVE AND PPN
;  USE - XCALL LOGPPN,string
;        WHERE string  is at least 15 characters long.
;
;  Written by: Doug Azzarito
;  TECHNOLOGY CONSULTANTS
;  5480 Eagle Lake Drive
;  Palm Beach Gardens, FL
;
;  Updated by Dave Heyliger - AMUS Staff to make it work if HEX set
;	      (dkh)


	SEARCH	SYS
	SEARCH	SYSSYM
	SEARCH	AAA			;dkh
 
;	AUTOEXTERN			;dkh - don't need this

	OBJNAM	LOGPPN.SBR

	VMAJOR=1.
	VMINOR=0.
	VSUB=1.
	VEDIT=100.
	VWHO=1.

;registers

	BASIC=A3				; BASIC PARAMETERS
	FREMEM=A4				; FREE MEMORY POINTER
	JOBSYS=A5				; JCB POINTER

; offsets from A3 for BASCI parameters

	PARMS=0
	TYP.1=2
	ADD.1=4
	SIZE.1=10

	PHDR	-1,PV$RSM,PH$REE!PH$REU

	BR	START
	ASCII	/ LOGPPN.SBR - TECHNOLOGY CONSULTANTS (1985)/
	EVEN	
START:
	CMPW	PARMS(BASIC),#1			; Check for at least 1 param
	JLT	ABORT				; user goofed!
	ANDW	#17,TYP.1(BASIC)		; Mask type
	CMPW	TYP.1(BASIC),#2     		; See if it's a string
	JNE	ABORT				; No, he goofed
	MOV	SIZE.1(BASIC),D1		; get the string length
	CMP	D1,#15.				; is it long enough?	
	JLT	ABORT				; no, get out

;
	JOBIDX	A6				;dkh - get yourself
	LEA	A6,JOBTYP(A6)			;dkh - get your job stuff
	PUSHW	@A6				;dkh - save job stuff
	OCTAL					;dkh - set octal

	JOBIDX	JOBSYS				; find JCB
	LEA	A1,JOBDEV(JOBSYS)		; get DEVICE
	MOV	ADD.1(BASIC),A2			; point to BASIC string
	UNPACK					; and put DEVICE there
	MOVW	JOBDRV(JOBSYS),D1		; Get log'ed drive
	DCVT	0,OT$MEM			; convert
	MOVB	#72,(A2)			; add a colon
	INC	A2			
	MOVB	#133,(A2)			; add a '[' if you want
	INC	A2
	MOVW    JOBUSR(JOBSYS),D1		; get PPN
	RORW	D1,#8.				; we just want P
	AND	#377,D1
	OCVT	0,OT$MEM			; convert it
	MOVB	#54,(A2)			; add a ','
	INC	A2
	MOVW    JOBUSR(JOBSYS),D1		; now get PN
	AND	#377,D1
	OCVT	0,OT$MEM			; convert that
	MOVB	#135,(A2)			; add ']'
	INC	A2

	JOBIDX	A6				;dkh - get yourself
	LEA	A6,JOBTYP(A6)			;dkh - get your job stuff
	POPW	@A6				;dkh - restore job status

	RTN					; back to BASIC
ABORT:	TYPECR	?PARAMETER ERROR IN LOGPPN.SBR
	EXIT					; go BOOM!
	END