
 TTL PRINT.CMD
 OPT PAG
 PAG
*
* THIS IS THE PRINT COMMAND THAT WILL SET UP
* .OUT FILES INTO THE QUEUE TO PRINTED.
*
MA02C  EQU $A02C
MA032  EQU $A032
*
* SPOOLER LINKAGE ADDRESSES
*
MA706  EQU $A706
QUEPTR  EQU $A717 QUEUE POINTER
QUECNT EQU $A71B NUMBER OF FILES IN QUEUE
QSTART  EQU $A810 BEGINING OF PRINT QUEUE
*
* FLEX LINKAGE ADDRESSESS
*
FCB    EQU $A840
EOL    EQU $AC02
TEMP   EQU $AC0D
LSTTRM EQU $AC11
PINIT  EQU $ACC0
POUT   EQU $ACE4
PFLAG  EQU $ACFC
MACFE  EQU $ACFE
WARMS  EQU $AD03
PSTRNG EQU $AD1E
NXTCHR EQU $AD27
GETFIL EQU $AD2D
LOAD   EQU $AD30
SETEXT EQU $AD33
RPTERR EQU $AD3F
INDEC  EQU $AD48
FMS    EQU $B406
MPTADR EQU $BEA9
*
 ORG $A100
*
START BRA BEGIN
VERS FCB $1
*
MA103 FCB $00
MA104 FCB $00
*
BEGIN LDAA QUECNT
 CMPA #12 IS QUEUE FULL?
 BNE NOTFUL NOPE
 JMP QUEFUL YUP - SO DO IT
*
NOTFUL LDAA POUT
 CMPA #$39 IS PRINT.SYS LOADED?
 BNE LOADED YES IT IS.....
 LDX #FCB NO - SO LOAD IT.
 LDAA #$01
 STAA $00,X
 JSR FMS
 BEQ NOERR1 NO ERRORS
 LDAA $01,X GET ERROR CODE.
 CMPA #$04 IS ERROR = FILE NOT FOUND?
 BEQ FNFERR YES
 JMP ERROR OTHER TYPE OF ERROR
*
FNFERR LDX #FNFMSG FILE NOT FOUND
 JMP SHWMSG
*
NOERR1 LDAA #$FF
 STAA $3B,X SPACE COMPRESS FLAG
 JSR LOAD
*
LOADED LDX #FCB
 LDAA #$01
 STAA TEMP
 JSR GETFIL GET FILE NAME FROM LINBUF
 BCS ERROR .TO BE SPOOLED.
 LDAA #$0B
 JSR SETEXT SET EXT = .OUT
 LDAA #$01
 STAA $00,X SET FUNCT = OPEN FOR READ
 JSR FMS
 BNE ERROR
 LDAA #$04 SET FUNCT = CLOSE FILE
 STAA $00,X .ONLY REMOVES IT FROM CHAIN
 JSR FMS .OF OPENED FILES
 BNE ERROR
 LDAA $03,X GET DRIVE NUMBER
 PSHA SAVE IT FOR NOW
 LDAA $11,X STARTING DISK ADDR OF FILE
 LDAB $12,X
 LDX QUEPTR
 CLR $03,X QUE ACTIVITY FLAG
 STAA $01,X FILE TRACK NUMBER
 STAB $02,X FILE SECTOR NUMBER
 PULA  RESTORE DRIVE NUMBER
 STAA $00,X FILE DRIVE NUMBER
 LDAA LSTTRM
*
MA172 CMPA #$0D
 BEQ MA194 FOUND END OF COMMAND
 CMPA EOL
 BEQ MA194 SAME-O SAME-O
 CMPA #$2B
 BEQ MA184
 JSR NXTCHR GET NEXT CHAR FROM LINBUF
 BRA MA172
*
MA184 JSR INDEC
 BCS MA1BB
 STX MA103
 LDAA MA104
 LDX QUEPTR
 STAA $03,X
*
MA194 INX
 INX 
 INX 
 INX 
 CPX #FCB
 BNE MA1A0 NOT FULL YET.
 LDX #QSTART
*
MA1A0 STX QUEPTR
 INC QUECNT
 TST PFLAG
 BEQ MA1C4
*
EXIT JMP WARMS
*
QUEFUL LDX #PQFMSG
*
SHWMSG JSR PSTRNG
 BRA EXIT
*
ERROR JSR RPTERR
 BRA EXIT
*
MA1BB LDX #FCB
 LDAB #$1A
 STAB $01,X
 BRA ERROR
*
* START THE TIMER
*
MA1C4 NOP
 SEI 
 LDX MPTADR
 LDAA #$FF
 STAA $00,X
 DEX 
 DEX 
 LDAA $02,X
 CMPA $00,X
 BEQ MA205
 INX 
 INX 
 LDAA #$3C
 STAA $01,X
 LDAA #$8F
 STAA $00,X
 LDAA $00,X
 LDAA #$3D
 STAA $01,X
 JSR PINIT INITIALIZE PRINTER PORT
 LDX #MA02C
 STX MACFE
 LDX #MA706
 STX MA032
 LDAA #$01
 STAA PFLAG
 LDAA #$04
 LDX MPTADR
 STAA $00,X
 NOP 
 CLI 
 JMP WARMS
*
* SET ERROR #28 = WRONG HARDWARE CONFIG
*
MA205 LDX #FCB
 LDAB #$1C
 STAB $01,X
 JMP ERROR
*
* NOW FOR THE STRINGS AND THINGS
*
PQFMSG FCC /PRINT QUEUE IS FULL - TRY LATER/
 FCB $4
*
FNFMSG FCC /"PRINT.SYS" NOT FOUND/
 FCB $4
*
 ORG $A843
*
MA843 FCB $FF
 FCC /PRINT/
 FDB $0000
 FCB $00
 FCC /SYS/
*
 END START
