.Title TK_LABELS ;tk-labels.mar .ident "V1.0" ; ;**************************************************************************** ;* ;* A program to format labels to fit the label window of a TK50/70 tape ;* cartridge. ;* ;* Digital Equipment Computer Users Society (DECUS) ;* This program may be freely distributed or modified by any party, including ;* but not limited to DECUS and anyone within DECUS. ;* USE AT YOUR OWN RISK ;* DECUS, DECUServe and the author make NO warranties whatsoever, including ;* without limitation, all implied warranties of merchantability and fitness. ;* ;* Author: Jack Harvey September 21, 1991 ;* GWA Information Systems ;* (617)890-1838 ;* ;**************************************************************************** ; $fabdef ;define the offsets $rabdef .psect tk_labels_data,pic,con,wrt,noexe,shr,long ; input_file is a logical pointing to a file containing the label texts. ;select input_file assign to input_file input_file:$fab fnm = ,- ;defined by command file dnm = ;default if broken input_file_rab: $rab fab = input_file,- ubf = input_rec,- ;input/output buffer usz = 512 input_rec: .blkb 512 input_rec_size = input_file_rab+rab$w_rsz ;equates to ease the code references record_size = input_rec_size status = input_file_rab+rab$l_sts ; output_file logical is the formated text to send to the LN03 printer. output_file:$fab fnm = ,- ;logical defined by command file dnm = ,- ;default if broken fac = put,- rat = cr ;so it will TYPE nicely output_file_rab: $rab fab = output_file output_rec_size = output_file_rab+rab$w_rsz ;equates to ease the code references output_rec = output_file_rab+rab$l_rbf input_count: .long 0 records_read: .long 0 output_count: .long 0 work1: .quad 0 ;used for error reporting ctrstr: .ascid/label count: !ZL/ outlen: outbuf: .word 80,0 .address 1$ 1$: .blkb 80 ; Macro to convert long to four ascii digits, leading zeros .macro adigit4 src,dst movl src,digit4l ;get the long value bsbw digit4 ;convert to ascii movc3 #4,digit4a,dst ;move ascii to destination .end adigit4 digit4l: .long 0 ;binary value placed here digit4d:.ascid / / ;binary to ascii four digit result to here digit4a = digit4d +8 ;address of four digit ascii string ; Note: x and y are the LN03 page coordinates, with the origin (0,0) ; being the upper left corner. Increasing x moves the position to the ; right. Increasing y moves the position down the page. The units are ; decipoints. There are 720 decipoints per inch. ; The following are constants. ; x0 and y0 are the upper left corner of first label on sheet. x0: .long 669 y0: .long 826 ; height and width are the size of a label box. height: .long 585 width: .long 1600 normal_spacing: .long 100 ; normal spacing ; margin is the minimum top and bottom margins for text in box. margin: .long 50 ; These are variables, applying to the current label box. ; xbox and ybox are the coordinates of the upper left corner ; of the current label box. current_spacing is text line spacing ; in this box. xbox: .long 0 ybox: .long 0 current_spacing: .long 0 form_feed: .byte ^X0C esc = ^X1B escape: .byte esc ; in the following is ASCII escape character: escape. ; setup is used to initialize the LN03 printer. This sets origin ; to upper left, position units, decipoint and the type font to ; Courier 6.7 point, 13.6 pitch. setup: .ascii "[?52h""[11h""[2 |""[15m" ; vector is used by horizontal-bar and vertical-bar to draw ; a label box line. bar-x, bar-y and bar-length determine the ; starting x,y position and length of the line. vector-direction ; is set by them to determine direction line goes from x,y. vector: .ascii "[" vector_direction: .byte 0 .ascii ";" bar_x: .blkb 4 ;pic 9999 .ascii ";" bar_y: .blkb 4 ;pic 9999. .ascii ";" bar_length: .blkb 4 ;pic 9999. .ascii ";1!|" ; text_line is used to position and print a line of text in a label box. ; text_x and text_y are the position of the first character of the line. text_line: .ascii "[" text_x: .blkb 4 ;pic 9999. .ascii "`""[" text_y: .blkb 4 ;pic 9999. .ascii "d" txt_line: .blkb 30 text_yl: .long 0 ;binary value for text_y saved here ; This is used to store a complete label text prior to printing. ; line_pointer is the current line. line_count is to total lines ; in this label. line_pointer: .long 0 line_count: .long 0 line_current: .long 0 line_buffer: .blkb 320 .psect tk_labels_code,exe,nowrt,pic,shr,long .entry tk_labels ^M<> ;main entry point 10$: $open fab = input_file ;label input movzbl input_file+fab$b_fns,R9 movl input_file+fab$l_fna,R8 bsbw check_status ;report if not normal successful $connect rab = input_file_rab bsbw check_status ;report if not normal successful $create fab = output_file ;formated label output movzbl output_file+fab$b_fns,R9 movl output_file+fab$l_fna,R8 bsbw check_status ;report if not normal successful $connect rab = output_file_rab bsbw check_status ;report if not normal successful ; Initialization, setup LN03 printer movl x0,xbox movl y0,ybox movl normal_spacing,current_spacing movw #21,output_rec_size ;setup to initialize moval setup,output_rec ;the printer $put rab = output_file_rab bsbw load_label ;get first label 90$: cmpl status,#33 ; main loop - end job? beql windup ;br if end bsbw make_label brb 90$ ;main loop of protram windup: $faol_s ctrstr,outlen,outbuf,output_count bsbw print_outbuf $exit_s ;stop run load_label: clrl line_count bsbw read_input 20$: tstw input_rec_size ;loop until record size is zero bneq 25$ brw 100$ 25$: cmpw input_rec_size,#30 ;line too long? blequ 30$ $faol_s 110$,outlen,outbuf,120$;yes, display it bsbw print_outbuf movw #30,input_rec_size ;and truncate it 30$: cmpl line_count,#9 ;check current line count bgtru 50$ ;br if too many mull3 line_count,#32,R0 moval line_buffer,R8;point to label buffer addl2 R0,R8 movw input_rec_size,(R8) ;store line length movc3 input_rec_size,input_rec,2(R8);store the line incl line_count brb 60$ 50$: movzwl input_rec_size,work1 ;build a record descriptor moval input_rec,work1+4 $faol_s 130$,outlen,outbuf,work1;format message bsbw print_outbuf ;display it 60$: bsbw read_input brw 20$ 100$: rsb 110$:.ascid /Line too long, truncated: !AD/ 120$: .long 30 .address input_rec 130$:.ascid /Too man lines, dropped: !AD/ print_outbuf:pushal outbuf calls #1,G^lib$put_output ;print $FAO message movw #80,outlen ;reset buffer length rsb ; Label text is in the line-buffer array. Now create the box and ; send it all to the print file. make_label: ; First, see if we have filled a page. mull3 #10,height,R0 addl y0,R0 ;calculate length of page cmpl ybox,R0 bleq 10$ ;br if not full movw #1,output_rec_size moval form_feed,output_rec ;kick out the page $put rab = output_file_rab movl x0,xbox ;reset to top of next page movl y0,ybox 10$: cmpl y0,ybox bneq 20$ ;br if not top of box adigit4 xbox,bar_x ;make xbox ascii adigit4 ybox,bar_y bsbw horizontal_bar 20$: cmpl x0,xbox bneq 30$ ;br if not left end of box adigit4 xbox,bar_x adigit4 ybox,bar_y bsbw vertical_bar 30$: bsbw insert_label_text ;make right end of box, which is left end of next box to right. addl3 width,xbox,R0 adigit4 R0,bar_x adigit4 ybox,bar_y bsbw vertical_bar ;make bottom of box, which is top of next box down the page. adigit4 xbox,bar_x addl3 height,ybox,R0 adigit4 R0,bar_y bsbw horizontal_bar ;a label is complete. Now advance to the next position on page. incl output_count ;Labels advance left to right across page, and then down. addl width,xbox subl3 width,#6000,R0 cmpl xbox,R0 blequ 40$ ; Another label won't fit across this page, start a ; new set of labels across page. movl x0,xbox addl height,ybox 40$: cmpl #rms$_eof,status ;end of file? beql 50$ ;br if end bsbw load_label ;no, read in another label text rsb ;end of make_label 50$: movl #33,status ;set end-job flag rsb ;End of job insert_label_text: ;first figure out what the line spacing is going to be. cmpl line_count,#5 bgequ 10$ movl normal_spacing,current_spacing brb 20$ 10$: ;current_spacing = (height - (2 * margin)) / line_count mull3 #2,margin,R0 subl3 R0,height,R0 divl3 line_count,R0,current_spacing 20$: ; Now calculate the vertical position of the first line. ; text_y = ybox + ((height - ((line_count - 1) * current_spacing))/2)+25 subl3 #1,line_count,R0 mull2 current_spacing,R0 subl3 R0,height,R0 divl2 #2,R0 addl2 #25,R0 addl3 R0,ybox,text_yl adigit4 text_yl,text_y ;text_y calculated and ascii-ed clrl line_pointer ;Initialize to first line of the text ;This is the loop which will insert each line of text into the label box. ;Note that if line_count is zero, it will exit immediately. 30$: cmpl line_pointer,line_count bneq 40$ ;br if non-blank label rsb ;label done, exit insert_label_text ; text_x = xbox + ((width - (line-size(line-pointer) * 53))/2) + 3 40$: mull3 line_pointer,#32,R0 moval line_buffer,R8 ;point to buffer addl2 R0,R8 ;point to line movzwl (R8),R7 ;line-size mull3 #53,R7,R0 subl3 R0,width,R0 divl2 #2,R0 addl2 #3,R0 addl3 R0,xbox,R0 adigit4 R0,text_x ; Insert the text and write the control sequence to file. movc5 R7,2(R8),#^A/ /,#30,txt_line addl3 R7,#14,output_rec_size moval text_line,output_rec $put rab = output_file_rab ; Advance vertical position down the page. addl current_spacing,text_yl adigit4 text_yl,text_y incl line_pointer brw 30$ digit4::pushl #4 ;convert digit4l to four digits in digit4a: .ascii /1234/ pushal digit4d ;descriptor of output string pushal digit4l ;binary value to convert calls #3,G^ots$cvt_l_tu ;convert binary to ascii rsb read_input: ;read an input record, return with R8 pointer, R9=size $get rab = input_file_rab cmpl R0,#rms$_eof ;end of file? beql 50$ ;no status check if eof bsbw check_status ;exit with message if error incl input_count rsb 50$: clrw input_rec_size ;end flag $faol_s 70$,outlen,outbuf,input_count bsbw print_outbuf rsb 70$: .ascid "end input at !ZL" horizontal_bar: ; Line goes from left to right, movb #^A/0/,vector_direction ; with a length equal to width of box movl width,digit4l bsbw digit4 movc3 #4,digit4a,bar_length movw #22,output_rec_size moval vector,output_rec $put rab = output_file_rab rsb vertical_bar: ; Line goes down from bar_x, bar_y movb #^A/1/,vector_direction ; with a length equal to height of box movl height,digit4l bsbw digit4 movc3 #4,digit4a,bar_length movw #22,output_rec_size moval vector,output_rec $put rab = output_file_rab rsb check_status: ;report the RMS status message to sys$output cmpl R0,#RMS$_SUC ;normal successful completion? beql 50$ ;just exit if normal movl #1,work1 ;setup for error display movl R0,work1+4 $putmsg_s msgvec = work1 ;display error text to terminal movzbl R9,work1 ;build a descriptor of the movl R8,work1+4 ;filespec text pushal work1 ;point to the descriptor calls #1,G^lib$put_output ;output file name to terminal $exit_s ;abort job 50$: rsb .end tk_labels