* GPL Subprogram >27 - Set current pathname
*
* This procedure sets the current path
*
* Inputs:
*     >834C - Unit #
*     >834E - Pointer to path name
*
* Outputs:
*     >8350 - Error status
*                0 = No error
*            non 0 = Error
*

GPL27  ANDI R12,>FF00
       AI   R12,24
       LDCR @B02,4

       MOV  @>834C,R6        Get SCSI ID
       MOV  R6,R1
       ANDI R6,>0700
       JEQ  G27ERR

       LI   R0,40
       MOV  R6,R3
       SRL  R3,8
       DEC  R3
       MPY  R0,R3
       AI   R4,PATH

       MOV  @>834E,R2        Get pointer

* If the buffer is in VDP RAM, set the VDP read address

       ANDI R1,>8000
       JNE  GPL27A

       SWPB R2
       MOVB R2,@VDPWA
       SWPB R2
       MOVB R2,@VDPWA
       NOP
       MOVB @VDPRD,R3        Get path length
       JMP  GPL27B

GPL27A MOVB *R2+,R3          Get path length
GPL27B SRL  R3,8
       CI   R3,39            Check path length
       JH   G27ERR
       CI   R3,5
       JL   G27ERR
       AI   R3,-5
       S    R3,R0            Compute # of spaces to pad

* Make sure the path starts with "SCSx." and the unit
* corresponds to what is in R6

       CI   R1,0
       JNE  GPL27D

       MOVB @VDPRD,R1
       SWPB R1
       MOVB @VDPRD,R1
       SWPB R1
       CI   R1,'WD'
       JEQ  G27BOK
       CI   R1,'SC'
       JNE  G27ERR

G27BOK CB   @VDPRD,@ASCIIS
       JNE  G27ERR
       MOVB @VDPRD,R1
       AI   R1,->3000
       CB   R1,R6
       JNE  G27ERR
       CB   @VDPRD,@PERIOD
       JNE  G27ERR

* Now copy the path from the VDP buffer

       CI   R3,0
       JEQ  GPL27G
GPL27C MOVB @VDPRD,*R4+
       DEC  R3
       JNE  GPL27C
       JMP  GPL27G


* Here is the error routine.
*
G27ERR MOVB @B01,@>8350
       JMP  G27RET

GPL27D
       MOVB *R2+,R1
       SWPB R1
       MOVB *R2+,R1
       SWPB R1
       CI   R1,'WD'
       JEQ  G27DOK
       CI   R1,'SC'
       JNE  G27ERR

G27DOK CB   *R2+,@ASCIIS
       JNE  G27ERR
       MOVB *R2+,R1
       AI   R1,->3000
       CB   R1,R6
       JNE  G27ERR
       CB   *R2+,@PERIOD
       JNE  G27ERR

GPL27E CI   R3,0
       JEQ  GPL27G
GPL27F MOVB *R2+,*R4+
       DEC  R3
       JNE  GPL27F


* Now pad the rest of the path with space characters

GPL27G
       MOVB @SPACE,*R4+
       DEC  R0
       JNE  GPL27G

       MOVB @ZERO,@>8350
G27RET LDCR @ZERO,4
       ANDI R12,>FF00
       INCT R11
       RT

ASCIIS BYTE 'S'
