Imagen Apollo Dviimp change file @x \font\ninerm=cmr9 \let\mc=\ninerm % medium caps for names like PASCAL \def\PASCAL{{\mc PASCAL}} \let\swap=\leftrightarrow \font\logo=logo10 % font used for the METAFONT logo \def\MF{{\logo META}\-{\logo FONT}} @y \let\mc=\ninerm % medium caps for names like PASCAL \def\PASCAL{{\mc PASCAL}} \let\swap=\leftrightarrow \font\logo=manfnt % font used for the METAFONT logo \def\MF{{\logo META}\-{\logo FONT}} @z @x \centerline{(Version 0.99, April 1986)} @y \centerline{(Imagen Apollo Version 0.99A, April 1986)} @z @x @d banner=='This is DVIIMP, Version 0.99' {printed when the program starts} @y @d banner=='This is DVIIMP, Imagen Apollo Version 0.99A' {printed when the progr @d integer==integer32 @z @x @d random== {change this to `$\\{random}\equiv\null$` for random access} @d modnar== {change this to `$\\{modnar}\equiv\null$` for random access} @d not_random==@{ @d modnar_ton==@t@>@} @f random == begin @f modnar == end @f not_random == begin @f modnar_ton == end @d othercases == others: {default for cases not listed explicitly} @d endcases == @+end {follows the default case in an extended |case| statement} @y @d random==@{ {change this to `$\\{random}\equiv\null$` for random access} @d modnar==@t@>@} {change this to `$\\{modnar}\equiv\null$` for random access} @d not_random== @d modnar_ton== @f random == begin @f modnar == end @f not_random == begin @f modnar_ton == end @d othercases == otherwise {default for cases not listed explicitly} @d endcases == @+;end {follows the default case in an extended |case| statement} @z @x @p program DVI_IMP(@!dvi_file,@!im_file,@!output); @y @p program DVI_IMP(@!dvi_file,@!im_file,@!term_out,@!term_in); %include '/sys/ins/base.ins.pas'; %include '/sys/ins/pgm.ins.pas'; @z @x begin print_ln(banner);@/ @y begin print_ln(banner);@/ @@/ @z @x @d one_sixty_five_cases(#)== sixty_four_cases(#), sixty_four_cases(#+64), thirty_seven_cases(#+128) @y @d one_sixty_five_cases(#)==sixty_four_cases(#) {Apollo allows 127 cases} @d two_sixty_five_cases(#)==sixty_four_cases(#+64) @d three_sixty_five_cases(#)==thirty_seven_cases(#+128) @z @x @d text_char == char {the data type of characters in text files} @d first_text_char=0 {ordinal number of the smallest element of |text_char|} @d last_text_char=127 {ordinal number of the largest element of |text_char|} @= @!text_file=packed file of text_char; @y @d text_char == char {the data type of characters in text files} @d first_text_char=0 {ordinal number of the smallest element of |text_char|} @d last_text_char=127 {ordinal number of the largest element of |text_char|} @= @!text_file=text; @z @x @!byte_file=packed file of eight_bits; {files that contain binary data} @y @!byte_file=text_file; {files that contain binary data} @z @x @!dvi_file:byte_file; {the stuff we are transcribing to the IMAGEN} @!gf_file:byte_file; {a generic font file} @!tfm_file:byte_file; {a generic font file} @!im_file:byte_file; {the output file} @y @!dvi_file:file of block; {the stuff we are transcribing to the IMAGEN} @!gf_file:file of block; {a generic font file} @!tfm_file:file of block; {a generic font file} @!im_file:byte_file; {the output file} @z @x @d close_file(#)== @y @d close_file(#)==close(#) @z @x @p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|} begin reset(dvi_file); cur_loc:=0; end; @y @p procedure open_dvi_file; {prepares to read packed bytes in |dvi_file|} begin reset(dvi_file); dvi_count:=AP_block_length; end; @z @x function open_gf_file:boolean; {prepares to read packed bytes in |gf_file|} begin reset(gf_file,cur_name); cur_gf_loc:=0; if eof(gf_file) then open_gf_file:=false else open_gf_file:=true; end; @y function open_gf_file:boolean; {prepares to read packed bytes in |gf_file|} begin gf_count := AP_block_length; open(gf_file,cur_name,'OLD',iostatus); if iostatus <= 0 then begin reset(gf_file); open_gf_file:=true end else open_gf_file:=false; end; @z @x function open_tfm_file:boolean; {prepares to read packed bytes in |tfm_file|} begin reset(tfm_file,cur_name); if eof(tfm_file) then open_tfm_file:=false else open_tfm_file:=true; end; @y function open_tfm_file:boolean; {prepares to read packed bytes in |tfm_file|} begin tfm_count := AP_block_length; open(tfm_file,cur_name,'OLD',iostatus); if iostatus <= 0 then begin reset(tfm_file); open_tfm_file:=true; end else open_tfm_file:=false; end; @z @x @d gf_read(#)==begin read(gf_file,#); end @p function gf_byte:integer; {returns the next byte, unsigned} var b:eight_bits; begin if eof(gf_file) then gf_byte:=0 else begin gf_read(b); incr(cur_gf_loc); gf_byte:=b; end; end; @y @d gf_read(#)==begin #:=gf_byte; end @p function gf_byte:integer; begin @ end; @z @x @p procedure read_tfm_word; begin read(tfm_file,b0); read(tfm_file,b1); read(tfm_file,b2); read(tfm_file,b3); end; @y @p procedure read_tfm_word; @ @z @x @d dvi_byte(#)==begin read(dvi_file,#); end @y @d dvi_byte(#)==begin #:= get_byte; end @z @x @p function get_byte:integer; {returns the next byte, unsigned} var b:eight_bits; begin if eof(dvi_file) then get_byte:=0 else begin dvi_byte(b); incr(cur_loc); get_byte:=b; end; end; @y @p function get_byte:integer; @ @z @x @d im_byte(#)==begin write(im_file,#); incr(im_byte_no); end @p procedure im_halfword(@!w:integer); @y @p procedure im_byte(@!w:integer); var b:char; begin b:=chr(w); write(im_file,b); incr(im_byte_no); end; @# procedure im_halfword(@!w:integer); @z @x @d dflt_res_name=='/rd/tools/tex/iftexplgen/' @d dflt_res_name_length=25 @d resfile_name=='resident' @d resfile_length=8 @y @d dflt_res_name=='/rd/tools/tex/resident/' @d dflt_res_name_length=23 @d resfile_name=='resident' @d resfile_length=8 @z @x @p function open_res_file:boolean; {prepares to read text from |res_file|} begin reset(res_file,cur_name); if eof(res_file) then open_res_file:=false else open_res_file:=true; end; @y @p function open_res_file:boolean; {prepares to read text from |res_file|} begin open(res_file,cur_name,'OLD',iostatus); if iostatus <= 0 then begin reset(res_file); open_res_file:=true; end else open_res_file:=false; end; @z @x while not eof(gf_file) do m:=gf_byte; {to close out file} @y @z @x @!mm_store:packed array [0..m1_max,4..m2_max] of eight_bits; @y @!mm_store:array [0..m1_max,4..m2_max] of eight_bits; @z @x one_sixty_five_cases(new_row_0):; @y one_sixty_five_cases(new_row_0): ; two_sixty_five_cases(new_row_0): ; {Apollo allows 127 cases} three_sixty_five_cases(new_row_0): ; {Apollo allows 127 cases} @z @x @d update_terminal == break(term_out) {empty the terminal output buffer} @y @d update_terminal == {empty the terminal output buffer} @z @x @d default_directory_name=='TeXGFs:' {change this to the correct name} @d default_directory_name_length=7 {change this to the correct length} @d dflt_tfm_directory_name=='TeXfonts:' {change this to the correct name} @d dflt_tfm_directory_name_length=9 {change this to the correct length} @y @d default_directory_name=='/rd/tools/tex/gf/' {change this to the correct name} @d default_directory_name_length=17 {change this to the correct length} @d dflt_tfm_directory_name=='/rd/tools/tex/fonts/' {change this to the correct n @d dflt_tfm_directory_name_length=20 {change this to the correct length} @z @x h_org:=resolution; v_org:=resolution; @y h_org:=0; v_org:=0; @z @x sixty_four_cases(set_char_0),sixty_four_cases(set_char_0+64): first_par:=o-set_char_0; @y sixty_four_cases(set_char_0): first_par:=o-set_char_0; sixty_four_cases(set_char_0+64): first_par:=o-set_char_0; @z @x close_file(im_file); @y { kludge necessary because an Apollo won't flush output buffer} write_ln(im_file); close_file(im_file); @z @x @* System-dependent changes. This section should be replaced, if necessary, by changes to the program that are necessary to make \.{DVIIMP} work at a particular installation. It is usually best to design your change file so that all changes to previous sections preserve the section numbering; then everybody's version will be consistent with the printed program. More extensive changes, which introduce new sections, can be inserted here; then only the index itself will get a new section number. @^system dependencies@> @y @* System-dependent changes. Here are the changes to the program that are necessary to make \.{DVIIMP} work on Apollo. First, all instances of |one_sixty_five_cases| had to be split into three portions. The \.{APOLLO} case statement does not allow more than 127 items per individual case. Second, the |eight_bits| definition (0..255) defines a type integer, instead of the intended character. This causes problems with the input and output of single bytes. Third, the \.{APOLLO} does not have |random| access facilities on basic text files. Therefore random access is not used. Fourth, the only type of variables that may be packed are type char or records. @ This code is done before the initialization of variables, and is used to read in the filename off the command line. If no file is given there, it will prompt the user for the \.{DVI} and \.{IMPRESS} filenames. @== @!file_name,@!def_file_name:array[1..300] of char; @!command_line:packed array[1..300] of char; @!cmd_len:integer; @!ask,@!got_file_name: boolean; @!i:integer; status:@=status_$t@>; iostatus:integer32; @ @= open(term_out,'-STDOUT'); open(term_in,'-STDIN'); cmd_len := @=pgm_$get_arg@> ( 1, command_line, status, 300 ); if status.all = @=pgm_$no_arg @> then cmd_len := 0; got_file_name := cmd_len <> 0; if got_file_name then for i:= 1 to cmd_len do def_file_name[i] := command_line[i]; if got_file_name then begin for i:= 1 to 300 do file_name[i] := ' '; for i:= 1 to cmd_len do file_name[i] := def_file_name[i]; file_name[cmd_len+1] := '.'; file_name[cmd_len+2] := 'd'; file_name[cmd_len+3] := 'v'; file_name[cmd_len+4] := 'i'; dvi_count :=AP_block_length; open(dvi_file,file_name,'OLD', iostatus); ask := iostatus > 0; if ask then write_ln('Couldn''t open ', file_name); end else ask:=true; while ask do begin got_file_name:=false; write('DVI file: '); if eof then goto final_end; read_ln(file_name); open(dvi_file,file_name,'OLD',iostatus); ask := iostatus > 0; if ask then write_ln('Couldn''t open ',file_name); end; if got_file_name then begin for i:= 1 to 300 do file_name[i] := ' '; for i:= 1 to cmd_len do file_name[i] := def_file_name[i]; file_name[cmd_len+1] := '.'; file_name[cmd_len+2] := 'i'; file_name[cmd_len+3] := 'm'; file_name[cmd_len+4] := 'p'; open(im_file,file_name,'UNKNOWN',iostatus); ask := iostatus > 0; if ask then write_ln('Couldn''t open ',file_name); end else ask:=true; while ask do begin write('imPress file: '); if eof then goto final_end; read_ln(file_name); open(im_file,file_name,'UNKNOWN',iostatus); ask := iostatus > 0; if ask then write_ln('Couldn''t open ',file_name); end; rewrite(im_file); @ Byte oriented file access. The \.{GF}, \.{DVI}, and \.{TFM} files are all created as record files of blocks of 512 sixteen bit integers (as per the Yale distribution tape). These integer are then converted into bytes. @ @== @!AP_block_length = 512; @!AP_half_block_length = 256; @ @== @!block=array[0..AP_half_block_length-1] of sixteen_bits; @!wordrec = packed record case boolean of true: (wordin:sixteen_bits); false: (hibyte : char ; lowbyte:char); end; @ @== @!tfm_buf:packed array [0..AP_block_length-1] of char; @!tfm_count: integer; @!dvi_buf:packed array [0..AP_block_length-1] of char; @!dvi_count: integer; @!gf_buf:packed array [0..AP_block_length-1] of char; @!gf_count: integer; @!transfer:wordrec; @ On the Apollo, an entire block of the |gf| file is read at a time. This code will return the next byte of that file. @= if gf_count=AP_block_length then begin { transfer to buffer } gf_count := 0; while true do begin transfer.wordin := gf_file^[gf_count div 2]; gf_buf[gf_count] := transfer.hibyte; gf_buf[gf_count+1] := transfer.lowbyte; gf_count := gf_count + 2; if gf_count >= AP_block_length then exit; end; gf_count:=0; get(gf_file); end; gf_byte := ord(gf_buf[gf_count]); incr(gf_count); @ On the Apollo, an entire block of the |tfm| file is read at a time. This code will return the next 4 bytes of that file. @= begin if tfm_count=AP_block_length then begin { transfer to buffer } tfm_count := 0; while true do begin transfer.wordin := tfm_file^[tfm_count div 2]; tfm_buf[tfm_count] := transfer.hibyte; tfm_buf[tfm_count+1] := transfer.lowbyte; tfm_count := tfm_count + 2; if tfm_count >= AP_block_length then exit; end; tfm_count:=0; get(tfm_file); end; b0:=ord(tfm_buf[tfm_count]); b1:=ord(tfm_buf[tfm_count+1]); b2:=ord(tfm_buf[tfm_count+2]); b3:=ord(tfm_buf[tfm_count+3]); tfm_count:=tfm_count + 4; end; @ On the Apollo, an entire block of the |dvi| file is read at a time. This code will return the next byte of that file. @= begin if dvi_count=AP_block_length then begin { transfer to buffer } dvi_count := 0; while true do begin transfer.wordin := dvi_file^[dvi_count div 2]; dvi_buf[dvi_count] := transfer.hibyte; dvi_buf[dvi_count+1] := transfer.lowbyte; dvi_count := dvi_count + 2; if dvi_count >= AP_block_length then exit; end; dvi_count:=0; get(dvi_file); end; get_byte := ord(dvi_buf[dvi_count]); incr(dvi_count); end; @z