.TITLE PRTFAX Facsimile image spooler .NLIST BEX .ENABL LC ; ; Facsimile image spooler ; ; This module is part of the spooler daemon. It copies files to a ; Dacom 450 digital facsimile transceiver. ; ; External symbols ; .GLOBL QUELST,FILBUF,FILBLK ;sharp pointers .GLOBL BITFAX ;conversion routine ; ; Entry symbols ; .GLOBL PRTFAX ;bitmap spooler .GLOBL BINP,BOUT ;word i/o ; ; System definitions ; .ASECT .MCALL .COM,.CHR,.PRT,.MSG ;dcnlib macros .MCALL .ENTER,.PURGE,.READW,.WRITW ;rt-11 macroni .MCALL CALL,FORMAT ;netlib macros .COM ;define common data .CHR ;define ascii character codes .PRT ;define queue file entry format ; ; Module definitions ; MAXSIZ = 4 ;max blocks input buffer ; ; Dacom 450 facsimile frame format ; . = 0 FM.CNT: .BLKB 1 ;frame count (octets) FM.COD: .BLKB 1 ;frame code FC.SET = 070 ;setup frame FC.DAT = 071 ;data frame FC.EOF = 072 ;eof frame FM.DAT: .BLKB 74. ;data field (585 bits) SYCOD1 = ^B01000110 ;sync codes (inverted) SYCOD2 = ^B10011110 SYCOD3 = ^B00011011 SSRCRF = ^B00000100 FM.LEN = . ;end of frame ; ; Sun image file header ; (32-bit byte-swapped doublewords) ; . = 0 RS.MAG: .BLKW 2 ;(ras_magic) magic number RS.WID: .BLKW 2 ;(ras_width) width (pels) of image RS.HGH: .BLKW 2 ;(ras_height) height (pels) of image RS.DPT: .BLKW 2 ;(ras_depth) depth (1,8,24 bits) of pel RS.IMG: .BLKW 2 ;(ras_length) length (bytes) of image RS.TYP: .BLKW 2 ;(ras_type) type of file RS.COL: .BLKW 2 ;(ras_maptype) type of colormap RS.MAP: .BLKW 2 ;(ras_maplength) length (bytes) of color map RS.LEN = . ;length of header ; ; Procedure segment ; .PSECT $BOSI,RO,I ; ; Facsimile image spooler ; ; There are two file formats supported, Dacom facsimile and Sun bitmap. Files ; in Dacom formats are copied as-is to the device. Files in Sun formats are ; converted in this module to Dacom format, then re-spooled to show up again ; in this module. ; PRTFAX: CLR BLOCK ;initialize MOV #BUFFER,BUFPTR .READW #ARGBLK,#3,#FILBUF,#MAXSIZ*256.,FILBLK ;read first block BCS 3$ ;branch if error CMP FILBUF,FAXMGC ;is this facsimile file BNE DACOM ;branch if no 1$: MOV R0,R2 ;yes. write segment .WRITW #ARGBLK,#0,#FILBUF,R2,BLOCK BCC 2$ ;branch if ok FORMAT #COM12,#QUELST ;output device error BR 4$ ; 2$: ADD #MAXSIZ,FILBLK ;read next segment .READW #ARGBLK,#3,#FILBUF,#MAXSIZ*256.,FILBLK BCC 1$ ;branch if ok 3$: TSTB @#52 ;error. is it eof BEQ 4$ ;branch if yes FORMAT #COM14,#QUELST ;file read error 4$: CLC RTS PC ; ; Translate Sun format to Dacom format ; DACOM: MOV R0,NWORDS ;set pointers ADD #MAXSIZ,FILBLK MOV #FILBUF,FILPTR CLR RESCOD ;set defaults CLR LPMODE CLR XMODE .PURGE #0 ;open spool file .ENTER #ARGBLK,#0,#FAXNAM BCS 4$ ;branch if error FORMAT #COM13,#FILBUF ;converting to compressed format .MSG <#^RLOG> ;flush buffer CALL BITFAX,RESCOD,XMODE,LPMODE ;convert the thing ASL R0 BEQ 1$ ;branch if ok FORMAT COMTAB(R0),#QUELST ;display error comment BR 4$ ; 1$: MOV BUFPTR,R1 ;is buffer empty SUB #BUFFER,R1 BEQ 4$ ;branch if yes BIT #777,R1 ;no. is this block boundary BEQ 2$ ;branch if yes CLR R0 ;no. zero-fill remainder JSR PC,BOUT BCS 4$ BR 2$ ; 2$: ASR R1 ;write last buffer .WRITW #ARGBLK,#0,#BUFFER,R1,BLOCK BCC 4$ ;branch if ok 3$: FORMAT #COM12,#QUELST ;output device error 4$: CLC ;normal return RTS PC ; ; Subroutine to read buffer ; Returns r0 = word, returns c(cc) = 1 if error or eof ; BINP: TST NWORDS ;is buffer empty BNE 1$ ;branch if no .READW #ARGBLK,#3,#FILBUF,#MAXSIZ*256.,FILBLK ;yes. read next buffer BCS 2$ ;branch if error MOV R0,NWORDS ;ok. update pointers ADD #MAXSIZ,FILBLK MOV #FILBUF,FILPTR 1$: MOV @FILPTR,R0 ;read word ADD #2,FILPTR DEC NWORDS CLC 2$: RTS PC ; ; Subroutine to write buffer ; R0 = word, returns c(cc) = 1 if error ; BOUT: MOV R0,@BUFPTR ;stash word CMP BUFPTR,#BUFEND-2 ;is buffer full BLO 1$ ;branch if no .WRITW #ARGBLK,#0,#BUFFER,#MAXSIZ*256.,BLOCK ;yes. write block BCS 2$ ;branch if error ADD #MAXSIZ,BLOCK ;initialize pointers MOV #BUFFER-2,BUFPTR 1$: ADD #2,BUFPTR CLC 2$: RTS PC ; ; Data segment ; .PSECT $BOSD,RO,D ; FAXMGC: .WORD 034114 ;facsimile file identifer FAXNAM: .RAD50 'FAX ' ;logical name of facsimile device COMTAB: .WORD 0,COM22,COM14,COM12 ;bitfax error vector COM22: .ASCIZ '?PRTQ-F-Invalid file format ^F' COM14: .ASCIZ '?PRTQ-F-File read error ^F' COM12: .ASCIZ '?PRTQ-F-Output device error ^F' COM13: .ASCII '?PRTQ-I-Converting to compressed format ^XI' .ASCIZ ' x ^XI' .EVEN ; ; Variables ; STOBGN = . ;format fence ; RESCOD: .BLKW 1 ;resolution code LPMODE: .BLKW 1 ;image mode (landscape/portrait) XMODE: .BLKW 1 ;invert switch ; ARGBLK: .BLKW 5 ;rt-11 argument block FILPTR: .BLKW 1 ;input buffer pointer NWORDS: .BLKW 1 ;bytes remaining BLOCK: .BLKW 1 ;output file block BUFPTR: .BLKW 1 ;output buffer pointer BUFFER: .BLKW MAXSIZ*256. ;output buffer BUFEND = . ;end of output buffer ; .END