 NAM CP68DRIVER (STRUBAL +)
*
 CMN BLANK,101
 CMN .EOF,2
 CMN .ERR,2
 CMN .CURIO,2
*
 ENT OPEN
 ENT CLOSE
 ENT REWIND
 ENT GETB
 ENT OUTB
 ENT MONTOR
 ENT BUILD
 ENT ENLARGE
 ENT LOCATE
 ENT PLACE
 ENT DELETE
*
 EXT .RTBL
 EXT CREATE
 EXT ROPEN
 EXT RCLOSE
 EXT RREAD
 EXT RWRITE
 EXT POSITION
 EXT EXPAND
*
DESCRA EQU $20
CUCHAR EQU $23
RC EQU $25
CLASS EQU $26
*
FCBGDT EQU 2
FCBSTA EQU 5
FCBDTT EQU 6
FCBDBA EQU 7
FCBTYP EQU 29
FCBACS EQU 30
FCBSCF EQU 41
FCBRNM EQU 42
FCBRSZ EQU 44
FCBRCD EQU 46
FCBPOS EQU 48
*
OPEN STX CUCHAR
 LDX .CURIO
 CLR FCBSTA,X
 SWI CALL CP/68
 FCB 44
 TST FCBSTA,X
 BNE SETER2
 LDAA #$FF
 STAA FCBSCF,X
 CLR FCBDTT,X
 CLR FCBACS,X
 CLR FCBTYP,X
 CLR .EOF
 CLR .EOF+1
 LDAA #'D
 STAA FCBGDT,X
 LDAA #'S
 STAA FCBGDT+1,X
 LDAA #'K
 STAA FCBGDT+2,X
 LDAB #42
 SWI CALL CP/68
 FCB 10
 SWI CALL CP/68
 FCB 2
 LDX .CURIO
 STAA FCBDBA,X
 STAB FCBDBA+1,X
 SWI CALL CP/68
 FCB 47
 LDAA CLASS
 CMPA #4
 BNE SETERR
 SWI CALL CP/68
 FCB 47
 LDAB RC
 CMPB #1
 BNE SETERR
 LDX DESCRA
 LDAA 0,X
 CMPA #'I
 BNE OPEN3
OPEN1 LDX .CURIO
 SWI CALL CP/68
 FCB 20
OPEN2 TST FCBSTA,X
 BNE SETER2
 RTS
OPEN3 CMPA #'O
 BNE OPEN4
 LDX .CURIO
 COM FCBDTT,X
 BRA OPEN1
OPEN4 CMPA #'R
 BNE SETERR
 LDX .CURIO
 LDAB #170
 SWI CALL CP/68
 FCB 10
 SWI CALL CP/68
 FCB 2
 LDX .CURIO
 STAA FCBDBA,X
 STAB FCBDBA+1,X
 JSR ROPEN
 BRA OPEN2
*
SETERR LDAA #21
 LDX .CURIO
 STAA FCBSTA,X
SETER2 SWI CALL CP/68
 FCB 30
 LDX #$FFFF
 STX .ERR
 RTS
*
CLOSE LDX .CURIO
 CLR FCBSTA,X
 LDAA FCBTYP,X
 CMPA #2
 BNE CLOSE2
 JSR RCLOSE
 BRA CLOSE3
CLOSE2 SWI CALL CP/68
 FCB 21
CLOSE3 TST FCBSTA,X
 BNE SETER2
 RTS
*
REWIND LDX .CURIO
 LDAA FCBTYP,X
 CMPA #2
 BNE REW2
 LDAA #18
 STAA FCBSTA,X
 BRA SETER2
REW2 CLR FCBSTA,X
 SWI CALL CP/68
 FCB 22
 TST FCBSTA,X
 BNE SETER2
 RTS
*
MONTOR SWI CAL CP/68
 FCB 31
*
GETB PSHB
 SWI CALL CP/68
 FCB 5
 LDX .CURIO
 LDAB FCBTYP,X
 CMPB #2
 BNE GETB00
 JSR RREAD
 LDAB FCBSTA,X
 CMPB #$F
 BEQ GETB0
 CMPB #$8
 BNE GETB2
GETB0 SEC
 BRA GETB1
GETB00 SWI CALL CP/68
 FCB 24
 LDAB FCBSTA,X
 CMPB #8
 BNE GETB2
 SEC
GETB1 SWI CALL CP/68
 FCB 6
 PULB
 RTS
GETB2 TSTB
 BNE GETB3
 CLC
 BRA GETB1
GETB3 BSR SETER2
 BRA GETB1
*
OUTB PSHB
 SWI CALL CP/68
 FCB 5
 LDX .CURIO
 CLR FCBSTA,X
 LDAB FCBTYP,X
 CMPB #2
 BNE OUTB2
 JSR RWRITE
 BRA OUTB3
OUTB2 SWI CALL CP/68
 FCB 25
OUTB3 TST FCBSTA,X
 BNE GETB3
 BRA GETB1
*
LOCATE JSR .RTBL
 FCB 240
 BRA *+10
LFCB RMB 2
LRECNO RMB 2
LBYTE RMB 2
 FDB $FFFF
 CLR .ERR
 CLR .ERR+1
 LDX LFCB
 LDAA FCBTYP,X
 CMPA #2
 BEQ LOC2
 LDAA #18
 STAA FCBSTA,X
 JMP SETER2
LOC2 LDAA FCBRCD,X
 LDAB FCBRCD+1,X
 LDX LRECNO
 STAA 0,X
 STAB 1,X
 LDX LFCB
 LDAA FCBPOS,X
 LDAB FCBPOS+1,X
 LDX LBYTE
 STAA 0,X
 STAB 1,X
 RTS
*
PLACE JSR .RTBL
 FCB 240
 BRA *+8
PFCB RMB 2
PREC RMB 2
 FDB $FFFF
 CLR .ERR
 CLR .ERR+1
 LDX PFCB
 LDAA FCBTYP,X
 CMPA #2
 BEQ PLACE2
 LDAA #18
 STAA FCBSTA,X
 JMP SETER2
PLACE2 LDX PREC
 LDAA 0,X
 LDAB 1,X
 LDX PFCB
 STAA FCBRCD,X
 STAB FCBRCD+1,X
 JSR POSITION
 JMP OPEN2
*
BUILD JSR .RTBL
 FCB 240
 BRA *+12
BFCB RMB 2
BNAME RMB 2
BRECNO RMB 2
BRECSZ RMB 2
 FDB $FFFF
 CLR .ERR
 CLR .ERR+1
 LDX BFCB
 LDAA #'D
 STAA FCBGDT,X
 LDAA #'S
 STAA FCBGDT+1,X
 LDAA #'K
 STAA FCBGDT+2,X
 LDAB #170
 SWI CALL CP/68
 FCB 10
 SWI CALL CP/68
 FCB 2
 LDX BFCB
 CLR FCBSTA,X
 STAA FCBDBA,X
 STAB FCBDBA+1,X
 LDX BNAME
 STX CUCHAR
 LDX BFCB
 SWI CALL CP/68
 FCB 44
 TST FCBSTA,X
 BEQ *+5
 JMP SETERR
 LDX BRECNO
 LDAA 0,X
 LDAB 1,X
 LDX BFCB
 STAA FCBRNM,X
 STAB FCBRNM+1,X
 LDX BRECSZ
 LDAA 0,X
 LDAB 1,X
 LDX BFCB
 STAA FCBRSZ,X
 STAB FCBRSZ+1,X
 JSR CREATE
 JMP OPEN2
*
ENLARGE JSR .RTBL
 FCB 240
 BRA *+8
EFCB RMB 2
ERECNO RMB 2
 FCB $FFFF
 CLR .ERR
 CLR .ERR+1
 LDX EFCB
 LDAA FCBTYP,X
 CMPA #2
 BEQ ENLRG2
 LDAA #18
 STAA FCBSTA,X
 JMP SETER2
ENLRG2 LDX ERECNO
 LDAA 0,X
 LDAB 1,X
 LDX EFCB
 STAA FCBRCD,X
 STAB FCBRCD+1,X
 JSR EXPAND
 JMP OPEN2
*
DELETE JSR .RTBL
 FCB 240
 BRA *+8
DFCB RMB 2
DNAME RMB 2
 FDB $FFFF
 CLR .ERR
 CLR .ERR+1
 LDX DNAME
 STX CUCHAR
 LDX DFCB
 LDAA #'D
 STAA FCBGDT,X
 LDAA #'S
 STAA FCBGDT+1,X
 LDAA #'K
 STAA FCBGDT+2,X
 LDAB #42
 SWI CALL CP/68
 FCB 10
 SWI CALL CP/68
 FCB 2
 LDX DFCB
 STAA FCBDBA,X
 STAB FCBDBA+1,X
 SWI CALL CP/68
 FCB 44
 TST FCBSTA,X
 BEQ *+5
 JMP SETERR
 SWI CALL CP/68
 FCB 28
 JMP OPEN2
*
 END
