.TITLE GT grafix output driver .PSECT GT .ENABL LC ; ; These subroutines attach/deattach, accept & buffer and flush output ; to a logical unit. The main purpose is to accept strings of graphics ; commands and buffer them for more effecient output to the graphics ; terminal (GT:). ; ; FORTRAN calling sequence: ; ; CALL GTATT(LUN) attach/deattach the loon ; ; LUN is the logical unit to attach. ; if LUN < 0, deattach -LUN. ; ; CALL (STRING[,LEN]) buffer & output/flush ; ; STRING is the string to write ; LEN is the length of the string to write ; if not specified, the string is ASCIZ ; if LEN <= 0, flush the buffer ; ; CALL GTF flush the buffer ; ; ; ASSEMBLY entry points: ; ; CALL GTA buffer and output (R0,R1 destroyed) ; ; R0 length of the string ; R1 points to the string ; ; CALL GTF flush the buffer (R0 destroyed) ; ; h gregg 2/83 ; ; modified 5/83 hg added ASCIZ string stuff ; ;-------------------------------------------------------------------------- ; .PAGE .MCALL DIR$,QIOW$ O.LUN = 2 O.STR = 2 O.LEN = 4 ; GTLUN:: .WORD 0 ; place to store the graphics loon BUFLEN= 80. BUFFER: .BLKB BUFLEN ; for buffering our output POINTR: .WORD BUFFER ; where are we in the buffer? DETACH: .WORD 0 ; do we detach when done? ; WRITE: QIOW$ IO.WAL,,2,,IOSB,, Q.ATT: QIOW$ IO.ATT,,2,,IOSB Q.DET: QIOW$ IO.DET,,2,,IOSB IOSB: .BLKW 2 ; ; Error handling suboutine ; ERR: CMPB #IS.SUC,IOSB ; successful? BEQ DONE ; yup - do a normal return ERROR: ; problem - ignore for now. DONE: RETURN ; and return ; .PAGE ; ; initialize, check for flush buffer command ; GT:: MOV O.STR(R5),R1 ; get the head of the string CMPB #2,(R5) ; check for proper number of arguments BNE GTASCZ ; must be an ASCIZ string MOV @O.LEN(R5),R0 ; get the length BLE GTF ; flush buffer command? go do it. ; ; move the data to our buffer ; GTA:: MOV POINTR,R2 ; get the pointer into our buffer 10$: CMP #BUFFER+BUFLEN,R2 ; check for buffer overflow BHI 20$ ; still room left CALL GTFLSH ; buffer full - go flush it 20$: MOVB (R1)+,(R2)+ ; move the string SOB R0,10$ ; and continue MOV R2,POINTR ; save our place RETURN ; all moved - just leave. ; ; passed an ASCIZ string - continue to move characters until we ; see a zero byte. ; GTASCZ: MOV POINTR,R2 ; first, get the pointer in the buffer 10$: CMP #BUFFER+BUFLEN,R2 ; check for buffer overflow BHI 20$ ; there is room yet ... CALL GTFLSH ; full up - flush the buffer 20$: MOVB (R1)+,(R2)+ ; move a byte BNE 10$ ; if not a zero, continue DEC R2 ; get back past the zero byte MOV R2,POINTR ; save our place RETURN ; and leave ; ; buffer full - must flush it and continue ; GTFLSH: MOV #BUFLEN,WRITE+Q.IOPL+2 ; set the buffer size DIR$ #WRITE,ERROR ; issue the print command CALL ERR ; check for errors MOV #BUFFER,R2 ; reset our pointer RETURN ; and continue ; ; flush buffer command ; GTF:: MOV POINTR,R0 ; get the pointer SUB #BUFFER,R0 ; R0 = length of buffer BLE 10$ ; nothing (or less) here - just leave MOV R0,WRITE+Q.IOPL+2 ; set the buffer size DIR$ #WRITE,ERROR ; ship it out CALL ERR ; check for errors 10$: MOV #BUFFER,POINTR ; reset the pointer RETURN ; and leave. ; .PAGE ; ; attach the terminal ; GTATT:: CMPB #1,(R5) ; check for the LUN argument BNE ERROR ; problem - go solve it TST @O.LUN(R5) ; check the LUN BLE 10$ ; less than 0, deattach MOV @O.LUN(R5),GTLUN ; get and save our loon MOV GTLUN,Q.ATT+Q.IOLU ; set the loon DIR$ #Q.ATT,ERROR ; attach it CLR DETACH ; deattach flag: clear ==> we deattach CMPB #IS.SUC,IOSB ; check for a normal attach BEQ 5$ ; all normal - we attached CMPB #IE.DAA,IOSB ; already attached? BNE ERROR ; nope - must have another error INC DETACH ; deattach flag: set ==> don't detach 5$: MOV @O.LUN(R5),WRITE+Q.IOLU ; set up the loon for the writes RETURN ; and head home ; ; deattach the terminal ; 10$: TST DETACH ; should we deattach? BNE 20$ ; nope - leave it alone MOV @O.LUN(R5),Q.DET+Q.IOLU ; set the loon NEG Q.DET+Q.IOLU ; make it positive DIR$ #Q.DET,ERROR ; detach CALL ERR ; check for errors 20$: RETURN ; and go home .END