Category : Printer Utilities
Archive   : SIDEPRNT.ZIP
Filename : SIDEPRNT.PAS

 
Output of file : SIDEPRNT.PAS contained in archive : SIDEPRNT.ZIP
(*
SIDEPRNT: Sideways (rotated) printing. PC World July 1986
Star-Dot-Star, by John T. Bagwell, Jr.

Uses character tables in the BIOS ROM to do a simple form of
sideways printing. Character values above 127 aren't supported.
FormFeed (Control-L) acts as a 'page' eject, even in the middle
of a line; a line ends at CR/LF, FF, or end-of-file.

This program is designed for the Epson FX-80 or FX-85 printer.

The font data may be stored in different locations on some
'compatible' computers, but on the PC it resides at address
F000:FA6E.

SIDEPRNT reads a text file to accumulate pages of 53 lines and
prints the text sideways, 9 characters to the inch. This process
continues until the entire document has been printed.

Each character's bit map is 8 bytes long, defining the character
in an 8-by-8 matrix. Because most characters don't fill the entire
matrix, space is left between displayed characters. SIDEPRNT also
adds a miniscule space between lines to improve readability. The
size of this space is controlled by the program variable BitsPerChar.

Run the compiled program from the DOS prompt by typing: SIDEPRNT
filename followed by an optional /D switch. The switch causes each
line to be printed twice, the second pass offset slightly to further
enhance print quality. Using the switch, of course, doubles the
printing time.

If you have DOS 3.00 or later, you can use its GRAFTABL program and
modify SIDEPRNT to check interrupt vector 1F for the table. The
control characters (those below ASCII 32) are printed except for
Control-J, Control-L, Control-M, and Control-Z which have other
purposes.

Of the various graphics modes available on the FX-80 printer,
mode 0 seems most suitable. Program comments tell you how to
modify the program and try the other modes, or, if you are so
inclined, how to improve the program by adding your own font or
changing it to work with another printer.

SIDEPRNT.PAS is also a good tutorial for anyone interested in
learning how to write Pascal programs that process characters
and graphics data.
*)

program SidePrint;
const
PrintMultipleSpacing = #27'3';
JiggleDown= #13#27'J'#1;
NormalSpacing = #27'2';
GraphicsPrint = #27'*';
LineFeed = ^J;
FormFeed = ^L;
{ ... possible choices ... }
BitsPerChar = 9; { 9 8 9 8 9 8 9 8 }
ModeCode = #0; {#0 #0 #4 #4 #5 #5 #6 #6 }
MaxLinesPerPage = 53; {53 60 71 80 64 72 80 90 }
MaxLineLen = 1000; {adjust to match max lines and available space}
type
BitMap = array [0..7] of char;
Line = array [1..MaxLineLen] of char;
var
Paper: array [1..MaxLinesPerPage] of Line;
Infile: text;
InChar: char;
LineNo, CharNo, i, j, k, BitsPerPage, LineLen: integer;
Cindex, PrintMultiple: byte;
CharTable: array [0..127] of BitMap absolute $F000:$FA6E; {BIOS Table}


(*---------------------------------*)
(* Read One 'Page' *)
(*---------------------------------*)

procedure ReadOnePage;
var
LineSize: array [1..91] of integer; {big enough for all options}
eject: Boolean;
begin
LineNo := 1;
CharNo := 0;
LineLen := 0;
eject := FALSE;

for i := 1 to MaxLinesPerPage do {erase old lines}
LineSize[i] := 0;
repeat
{accumulate a line...}
while (not eoln(InFile)) AND (not eject) do
begin
read(InFile,InChar);
if InChar = FormFeed then {watch for page ejects}
if (LineNo = 1) AND (CharNo = 0) then
{ignore redundant page ejects}
else
eject := TRUE
else
if CharNo <= MaxLineLen then {build a line}
begin
CharNo := CharNo + 1;
Paper[LineNo,CharNo] := InChar;
end;
end;

{at end of each line ...}
if CharNo > LineLen then {save longest line length}
LineLen := CharNo;
LineSize[LineNo] := CharNo;
LineNo := LineNo + 1;
CharNo := 0;
if eoln(InFile) then
readln(InFile); {get the end-of-line mark}

{force eject when page is full ...}
if LineNo > MaxLinesPerPage then
eject := TRUE;

until eof(InFile) OR (eject);

(* make each line the same length *)

for i:= 1 to MaxLinesPerPage do
for j:=LineSize[i]+1 to LineLen do
Paper[i,j] := ' ';
end;

(*-----------------------------------*)
(* Print One 'Page' *)
(*-----------------------------------*)

procedure PrintOnePage;
begin
for j := 1 to LineLen do {each rotated 'line'...actually each character}
begin
for LineNo := 1 to PrintMultiple do
begin
write(LST,GraphicsPrint,ModeCode,
char(lo(BitsPerPage)),char(hi(BitsPerPage)));
for i := MaxLinesPerPage downto 1 do {lines in reverse order}
begin
Cindex := ord(Paper[i,j]);
if BitsPerChar = 9 then {FOR loop (9 to ...) req'd if it is > 9}
write(LST,#0);
for k := 7 downto 0 do
write(LST,CharTable[Cindex][k]); {bottom up each char}
end;
write(LST,JiggleDown); {C/R + microspace down}
end;
write(LST,LineFeed); {next 'line'}
end;
end;

(* ------ MAIN PROGRAM ------ *)

begin

(* GET FILE PARAM *)
if paramcount < 1 then
begin
writeln(^G'Missing file name on command');
halt;
end;
assign(InFile,paramstr(1)); {OPEN the file}
{$I-}
reset (InFile);
{$I+}
if IOResult <> 0 then
begin
writeln('File "',paramstr(1),'" not found.');
halt;
end;

(* GET /D DOUBLE-PRINT OPTION *)
PrintMultiple := 1;
if paramcount >=2 then
if (paramstr(2) = '/d') OR (paramstr(2) = '/D') then
PrintMultiple := 2;

(* SET-UP *)
BitsPerPage := BitsPerChar * MaxLinesPerPage;
write(LST,PrintMultipleSpacing,char(24-PrintMultiple)); {nn/216th inch}

(* MAIN LOOP *)
repeat {do one "page" at a time}
ReadOnePage;
PrintOnePage;
write(LST,FormFeed); {do a page eject to line up properly}
until eof(InFile);

(* ALL DONE *)
close(InFile);
write(LST,NormalSpacing); {resume normal spacing vertically}
end.


  3 Responses to “Category : Printer Utilities
Archive   : SIDEPRNT.ZIP
Filename : SIDEPRNT.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/