Category : Printer + Display Graphics
Archive   : PM.ZIP
Filename : PM-PS-BS.PAS

 
Output of file : PM-PS-BS.PAS contained in archive : PM.ZIP
{--------------------------------------------------------------}
{ BREAK-PM }
{ }
{ PRINTMASTER,PRINT SHOP,BASICA GRAPHIC CONVERTER }
{ }
{ Input: *.SDR or *.NAM [ Names of Shape ] }
{ *.SHP or *.DAT [ Shape file ] }
{ Output: "shape".BSG [BASIC file] }
{--------------------------------------------------------------}

{ This program will convert a PRINTMASTER graphic file into a
PRINT SHOP graphic file, or PRINT SHOP to PRINTMASTER. It will
also break up either one and convert them to BASICA graphic
arrays.

Printmaster graphic files consist of 2 seperate files. A
'name file' with the extension of .SDR and a 'graphic file'
with the extension of .SHP .

The name file is an ASCII text file containing the names
for each graphic in the shape file. A name consists of a
record with the length of 16 bytes. If a name is less then 16
bytes, the unused positions are filled with nuls ($00).

Printmaster graphics are 88 dots wide by 52 dots high. They
are stored in a binary file one after anouther. This takes up
572 bytes. Added to this are four bytes at the start of each
graphic and one byte at the end (or between each graphic) for
a total of 576 bytes per graphic. The first 4 bytes consist of
$0B (width in bytes of graphic), $34 (54 bits high), $58 (width
in bits) and $00 (nul byte). The last byte between graphics is
also a $00.

Print Shop's 'name file' is exactly the same as Printmaster's
but with the extension of .NAM . The Print Shop graphic file has
the extension of .DAT and is the same format as a .SHP file with
exceptions. The four bytes before each graphic and the last byte
between graphics is missing. In order for Print Shop to "see"
the files the filename must start with "GR". The program will add
"GR" to the front of the file name and chop off the end if greater-
than 8 characters. ie: the PRINTMASTER file STANDARD.SHP would
convert to a PRINT SHOP file GRSTANDA.DAT.

The BASICA format for the graphic is an array with the first
two bytes the width of the graphic in bits ($58,$00). The second
two bytes is the highth in bits ($34,$00). The rest of the array
is the graphic. This file can be used in BASIC program with the
PUT command. To use the graphic in FONTASY use the load block
function.

This software is placed into the public domain by:

John Paul Michalski
Infinity Engineering Services
322 W. Palomino Dr.
Chandler, AZ 85224
}



PROGRAM PM_TO_PS_TO_BASICA;

TYPE STRING80 = STRING[80];
STRING30 = STRING[30];
STRING16 = STRING[16];
STRING12 = STRING[12];
STRING8 = STRING[8];
STRING4 = STRING[4];
BINARY = FILE OF BYTE;


CONST ExtNamePM = '.SDR';
ExtGraphPM = '.SHP';
ExtNamePS = '.NAM';
ExtGraphPS = '.DAT';
OutExtFile = '.BSG';
RetMsg = 'Enter RETURN to Exit';
BlankEntry = ' '; {16 spaces}
InPutValid : set of CHAR = ['0'..'5'];
PunctLow : set of BYTE = [33..47];
PunctMid : set of BYTE = [58..64];
PunctHigh : set of BYTE = [91..96,123..132];
ConvrType : array[1..4] of STRING30 =
('Printmaster to Print Shop',
'Print Shop to Printmaster',
'Printmaster to BASICA block',
'Print Shop to BASICA block');


VAR TmpLine : STRING80;
InputLine : STRING16;
TEMPNAME : STRING16;
InFileName : STRING12;
InFileGraph : STRING12;
OutFileName : STRING12;
OutFileGraph : STRING12;
TEMPSTRING : STRING8;
InNameExt : STRING4;
OutNameExt : STRING4;
InGraphExt : STRING4;
OutGraphExt : STRING4;
OutNameText : TEXT;
InNameFile : BINARY;
InGraphFile : BINARY;
OutNameFile : BINARY;
OutGraphFile : BINARY;
ErrorLine : BYTE;
TypeConvr : INTEGER;
ErrorFlag : INTEGER;
CountGraph : INTEGER;
SizeFile : REAL;
GraphicPointer : REAL;
keyflag : BOOLEAN;



PROCEDURE CenterLast (VAR tmpline : STRING80);

VAR tmpcol : INTEGER;
VAR tmpnum : REAL;
VAR tmprow : INTEGER;

BEGIN
tmprow := 15;
GotoXY(1,tmprow);
ClrEol;
tmpcol := 35 - Trunc(LENGTH(TmpLine)/2); {Center Mesage}
GotoXY(tmpcol,tmprow);
TextColor(12);
Write(TmpLine);
END;


PROCEDURE OpenFile (VAR FileType : BINARY;
VAR FileName : STRING12;
VAR errorflag : INTEGER;
InOutFlag : BYTE);

BEGIN
errorflag := 0;
ASSIGN(FileType,FileName);
IF InOutFlag = 0 THEN {input flag}
BEGIN
{$I-}
RESET(FileType); {start at beginning}
{$I+}
errorflag := IORESULT;
END
ELSE
REWRITE(FileType); {clear for output}
END;


PROCEDURE CenterLast1 (VAR tmpline : STRING80;
endrow : BYTE);

VAR tmpcol : INTEGER;
VAR tmpnum : REAL;

BEGIN
GotoXY(1,endrow);
ClrEol;
tmpcol := 35 - Trunc(LENGTH(TmpLine)/2); {Center Mesage}
GotoXY(tmpcol,endrow);
TextColor(12);
Write(TmpLine);
END;


PROCEDURE ClrError;

BEGIN
GotoXY(1,errorline);
ClrEol;
END;


PROCEDURE ErrorMsg (VAR TmpLine : STRING80);

BEGIN
CenterLast(TmpLine);
DELAY(1200);
ClrError;
TextColor(3);
END;


FUNCTION UpperCase (tempname : STRING8): STRING8;

VAR point : integer;

BEGIN
FOR point := 1 to LENGTH(tempname) DO
tempname[point] := UpCase(tempname[point]);
UpperCase := tempname
END;


PROCEDURE WriteEntry (colplace : INTEGER;
rowplace : INTEGER;
filename : STRING16;
tempname : STRING16);

BEGIN
GotoXY(colplace,rowplace);
Write(filename);
GotoXY(colplace+40,rowplace);
Write(tempname);
END;


PROCEDURE GetFileName (VAR FileInName : STRING12;
VAR FileInGraph : STRING12;
VAR FileOutName : STRING12;
VAR FileOutGraph : STRING12;
VAR errorflag : INTEGER);

VAR tempstring : STRING80;
VAR namestring : STRING8;
VAR temppoint : INTEGER;


BEGIN
errorflag := 0;
tempstring := 'Enter File ( RETURN to Exit)';
CenterLast(tempstring);
WriteEntry(18,4,BlankEntry,BlankEntry); {clear line}
WriteEntry(18,5,BlankEntry,BlankEntry); {clear line}
TextColor(2);
GotoXY(18,4);
ReadLn(tempstring);
IF Length(tempstring) = 0 THEN
BEGIN
errorflag := 99;
EXIT;
END;
namestring := Copy(tempstring,1,8);
namestring := UpperCase(namestring);
temppoint := POS('.',namestring)-1;
IF temppoint >= 0 THEN
namestring := Copy(namestring,1,temppoint);
FileInName := namestring+InNameExt;
FileInGraph := namestring+InGraphExt;
IF TypeConvr = 1 THEN
Insert('GR',namestring,1);
FileOutName := namestring+OutNameExt;
FileOutGraph := namestring+OutGraphExt;
WriteEntry(18,4,BlankEntry,BlankEntry);
WriteEntry(18,4,FileInName,FileInGraph);
IF (TypeConvr = 3) OR (TypeConvr = 4) THEN
WriteEntry(18,5,FileOutName,BlankEntry)
ELSE
WriteEntry(18,5,FileOutName,FileOutGraph);
END;



PROCEDURE SetScrn (typeconvr : integer);

BEGIN
TextMode(3);
TextBackGround(0);
TextColor(14);
ClrScr;
GotoXY(20,2);
WriteLn(ConvrType[TypeConvr]);
TextColor(3);
GotoXY(1,4);
IF (typeconvr = 1) OR (typeconvr = 3) THEN
BEGIN
WriteLn('Source file.SDR: Source file.SHP: ');
InNameExt := '.SDR';
InGraphExt := '.SHP';
END;
IF (typeconvr = 2) OR (typeconvr = 4) THEN
BEGIN
WriteLn('Source file.NAM: Source file.DAT: ');
InNameExt := '.NAM';
InGraphExt := '.DAT';
END;
IF typeconvr = 1 THEN
BEGIN
WriteLn('Output file.NAM: Output file.DAT: ');
OutGraphExt := '.DAT';
OutNameExt := '.NAM';
END;
IF typeconvr = 2 THEN
BEGIN
WriteLn('Output file.SDR: Output file.SHP: ');
OutGraphExt := '.SHP';
OutNameExt := '.SDR';
END;
IF (typeconvr = 3) OR (typeconvr = 4) THEN
BEGIN
WriteLn('Output file.BTX: ');
OutGraphExt := '.BSG';
OutNameExt := '.BTX';
END;
WriteLn(' ');
WriteLn(' ');
WriteLn(' Converting of Graphics');
WriteLn(' ');
Write(' Graphic Name: ');
IF (typeconvr = 3) OR (typeconvr = 4) THEN

WriteLn(' Graphic File.BSG: ');
END;


PROCEDURE GetGraphName (VAR FILENAME : STRING16);

VAR loop : INTEGER;
VAR tempchr : BYTE;
VAR tempname : STRING16;
VAR colplace : INTEGER;
VAR rowplace : INTEGER;

BEGIN
colplace := 18;
rowplace := 10;
tempname := '';
FILENAME := '';
WriteEntry(colplace,rowplace,BlankEntry,BlankEntry);
FOR loop := 1 TO 16 DO
BEGIN
READ(InNameFile,tempchr);
tempname := tempname+Chr(tempchr);
IF tempchr IN PunctLow THEN {Avoid punctuation}
tempchr := tempchr+64;
IF tempchr IN PunctMid THEN
tempchr := tempchr+40;
IF tempchr IN PunctHigh THEN
tempchr := tempchr-7;
IF tempchr > 32 THEN
FILENAME := FILENAME+Chr(tempchr);
END;
DELETE(FILENAME,9,8); {shorten to file name size}
filename := UpperCase(filename);
Filename := filename+'.BSG';
WriteEntry(colplace,rowplace,tempname,filename);
END;


PROCEDURE LoadGraphic (VAR GraphicPointer : REAL;
VAR keyflag : BOOLEAN);

VAR loop : INTEGER;
VAR waste : BYTE;
VAR temp : string8;

BEGIN
waste := 88;
WRITE(OutGraphFile,waste); {BASIC File Header}
waste := 0;
WRITE(OutGraphFile,waste);
waste := 52;
WRITE(OutGraphFile,waste);
waste := 0;
WRITE(OutGraphFile,waste);
IF TypeConvr = 3 THEN
GraphicPointer := GraphicPointer+4; {Printmaster Skip first 4 bytes}
LongSeek(InGraphFile,GraphicPointer);
FOR loop := 0 TO 571 DO
BEGIN
READ(InGraphFile,waste);
WRITE(OutGraphFile,waste);
keyflag := KeyPressed; {Check for Exit}
END;
GraphicPointer := GraphicPointer+572; {point to next record}
IF TypeConvr = 3 THEN
GraphicPointer := GraphicPointer+1; {skip Printmaster nul byte}
END;


PROCEDURE DispExitMsg;

BEGIN
TmpLine :='Hit Any Key to Exit Conversion';
CenterLast(TmpLine);
TextColor(14);
END;


PROCEDURE BreakCheck ( VAR errorflag : INTEGER;
VAR keyflag : BOOLEAN);

VAR tempchr : CHAR;
VAR templine : STRING80;
VAR tmpcol : INTEGER;

BEGIN
errorflag := 0;
IF keyflag THEN
BEGIN
GotoXY(1,15);
ClrEol;
TmpLine := 'Are You Sure? (Y) ';
CenterLast(TmpLine);
Read(tempchr);
keyflag := FALSE;
GotoXY(1,15);
ClrEol;
IF UpperCase(tempchr) = 'Y' THEN
BEGIN
errorflag :=1;
EXIT;
END;
DispExitMsg;
END;
END;


PROCEDURE SetOpenScreen (VAR intype : INTEGER);

VAR tempchr : CHAR;

BEGIN
TextMode(3);
TextBackGround(0);
TextColor(14);
ClrScr;
GotoXY(14,2);
WriteLn('PrintMaster - Print Shop - BASICA Graphic Converter');
GotoXY(1,10);
TextColor(13);
WriteLn(' 1: ',ConvrType[1]);
WriteLn(' 2: ',ConvrType[2]);
WriteLn(' 3: ',ConvrType[3]);
WriteLn(' 4: ',ConvrType[4]);
WriteLn(' ');
WriteLn(' 0: Exit to DOS');
WriteLn(' ');
WriteLn(' Which conversion? (1-4): ');
REPEAT
BEGIN
GotoXY(48,17);
ClrEol;
Read(tempchr);
END;
UNTIL tempchr IN InPutValid;
intype := ORD(tempchr)-48;
END;



PROCEDURE UpdateCount (VAR countgraph : INTEGER);

BEGIN
CountGraph := CountGraph+1;
GotoXY(23,8);
Str(CountGraph,tempstring);
Write(tempstring:3); {update file count}
END;


PROCEDURE PmPsToBSG;

VAR temperror : INTEGER;
VAR filename : STRING16;

BEGIN
Close(OutNameFile);
ASSIGN(OutNameText,OutFileName);
REWRITE(OutNameText);
REPEAT {Convert each file}
BEGIN
BreakCheck(errorflag,keyflag);
IF errorflag = 0 THEN
BEGIN
UpdateCount(CountGraph);
GetGraphName(filename);
OutFileGraph := filename;
WriteLn(OutNameText,OutFileGraph);
OpenFile(OutGraphFile,OutFileGraph,temperror,1);
LoadGraphic(GraphicPointer,keyflag);
Close(OutGraphFile);
IF (FilePos(InNameFile)+16) > FileSize(InNameFile) THEN
errorflag := 1;
END;
END;
UNTIL errorflag = 1;
Close(OutNameText);
END;


PROCEDURE PmToPS;

VAR tempchr : BYTE;
VAR tempname : STRING16;
VAR loop : INTEGER;
VAR count : INTEGER;

BEGIN
OpenFile(OutGraphFile,OutFileGraph,errorflag,1);
REPEAT {Convert each file}
BreakCheck(errorflag,keyflag);
IF errorflag = 0 THEN
BEGIN
GotoXY(18,10);
ClrEol;
Tempname := '';
FOR loop := 1 TO 16 DO
BEGIN
Read(InNameFile,tempchr);
Tempname := Tempname+Chr(tempchr);
Write(OutNameFile,tempchr);
END;
Write(tempname);
UpdateCount(CountGraph);
IF TypeConvr = 2 THEN
BEGIN
tempchr := $0B;
Write(OutGraphFile,tempchr); {Printmaster header}
tempchr := $34;
Write(OutGraphFile,tempchr);
tempchr := $58;
Write(OutGraphFile,tempchr);
tempchr := $00;
Write(OutGraphFile,tempchr);
END;
IF TypeConvr = 1 THEN
BEGIN
Read(InGraphFile,tempchr); {dump Printmaster header}
Read(InGraphFile,tempchr);
Read(InGraphFile,tempchr);
Read(InGraphFile,tempchr);
END;
FOR loop := 0 TO 571 DO
BEGIN
Read(InGraphFile,tempchr);
Write(OutGraphFile,tempchr);
keyflag := KeyPressed; {Check for Exit}
END;
IF TypeConvr = 1 THEN
Read(InGraphFile,tempchr); {dump last byte}
IF TypeConvr = 2 THEN
BEGIN
tempchr := $00;
Write(OutGraphFile,tempchr); {add last byte}
END;
IF EOF(InNameFile) THEN
errorflag := 1;
END;
UNTIL errorflag = 1;
Close(OutGraphFile);
Close(OutNameFile);
END;


BEGIN {Main Program}
REPEAT {Keep coming back to begining}
ErrorLine := 15;
SetOpenScreen(TypeConvr);
IF TypeConvr = 0 THEN
BEGIN
ClrScr;
EXIT;
END;
SetScrn(TypeConvr);
REPEAT
tmpline := 'Source file not found';
GetFileName(InFileName,InFileGraph,OutFileName,OutFileGraph,errorflag);
IF errorflag = 0 THEN {Exit if >0}
BEGIN
OpenFile(InGraphFile,InFileGraph,errorflag,0);
IF errorflag = 0 THEN
OpenFile(InNameFile,InFileName,errorflag,0);
IF errorflag > 0 THEN
ErrorMsg(tmpline);
END;
UNTIL (errorflag = 0) OR (errorflag = 99);
IF errorflag <> 99 THEN {Not return to first menu}
BEGIN
ClrError;
sizefile := LongFileSize(InNameFile);
Str(TRUNC(SizeFile/16),tempstring);
GotoXY(32,8);
IF Length(tempstring) < 3 THEN
GotoXY(33,8);
TextColor(14);
Write(tempstring);
CountGraph := 0;
OpenFile(OutNameFile,OutFileName,errorflag,1);
keyflag := FALSE;
DispExitMsg;
GraphicPointer := 0;
IF (TypeConvr = 3) OR (TypeConvr = 4) THEN
PmPsToBsg;
IF (TypeConvr = 1) OR (TypeConvr = 2) THEN
PmToPs;
Close(InNameFile);
END
UNTIL 1<>1 {Force back to begining}
END.





  3 Responses to “Category : Printer + Display Graphics
Archive   : PM.ZIP
Filename : PM-PS-BS.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/