home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / SCNDSIGN.ZIP / GENERAL.INC < prev    next >
Encoding:
Text File  |  1987-03-29  |  9.4 KB  |  355 lines

  1. (*This is the General.inc file which will be included with the files
  2.   generated by the ScnDsign program*)
  3. Type
  4.   AnyString = String[30];
  5.   FileName = String[14];
  6.   TotScn = Array[1..25,1..80,1..2] of byte;
  7. Var
  8.   AttributeSeg       : integer;
  9.   AttributeOfs       : integer;
  10.   ScnFile            : file of byte;
  11.   Ch1,Ch2,ch         : char;
  12.   Row,Col,count,max  : integer;
  13.   ScnImage           : TotScn absolute $B000:0000;
  14.  
  15. {----------------------------------------------------------}
  16.  
  17. Procedure InitMonoSPFX;
  18. {Find the location of the attribute byte by changing the video
  19.  attribute, then checking for differences}
  20. {My thanks to Dr. R. L. Wulffson of Santa Ana, Calif. for this procedure}
  21. Const
  22.    MaxOffset = $0900;
  23.  
  24. Var
  25.    A         : integer;
  26.    Found     : boolean;
  27.    Attribute : byte;
  28.  
  29. {----------------------------------------------}
  30.  
  31. Procedure FindAttribute;
  32.  
  33. Begin
  34.   Repeat
  35.    LowVideo;
  36.    Attribute := Mem[AttributeSeg:AttributeOfs];
  37.    NormVideo;
  38.    If Mem[AttributeSeg:AttributeOfs] <> Attribute
  39.      then Found := True
  40.      else AttributeOfs := Succ(AttributeOfs)
  41.   until Found or (AttributeOfs > MaxOffset);
  42. end;
  43.  
  44. {----------------------------------------------}
  45.  
  46. Begin {InitMonoSPFX}
  47.    Found := false;
  48.    AttributeSeg := DSeg;
  49.    AttributeOfs := 0;
  50.    FindAttribute;
  51.    If Not Found
  52.      Then
  53.        Begin
  54.          AttributeSeg := CSeg;
  55.          AttributeOfs := 0;
  56.          FindAttribute;
  57.        end;
  58. end; {InitMonoSPFX}
  59.  
  60. {-----------------------------------------------}
  61.  
  62. Procedure Reverse;
  63.  
  64. Begin
  65.    Mem[AttributeSeg:AttributeOfs] :=  $70;
  66. end;
  67.  
  68. {-------------------------------}
  69.  
  70. Procedure ReverseBlink;
  71.  
  72. Begin
  73.    Mem[AttributeSeg:AttributeOfs] :=  $F0;
  74. end;
  75.  
  76. {-------------------------------}
  77.  
  78. Procedure Blink;
  79.  
  80. Begin
  81.    Mem[AttributeSeg:AttributeOfs] := $87;
  82. end;
  83.  
  84. {----------------------------------}
  85.  
  86. Procedure UnBlink;
  87.  
  88. Begin
  89.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] and $7F;
  90. end;
  91.  
  92. {----------------------------------}
  93.  
  94. Procedure UnderLine;
  95.  
  96. Begin
  97.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] and $88;
  98.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] or $01;
  99. end;
  100.  
  101. {----------------------------------}
  102.  
  103. Procedure HiInt;
  104.  
  105. Begin
  106.    Mem[AttributeSeg:AttributeOfs] := $0F;
  107. end;
  108.  
  109. {-----------------------------------}
  110.  
  111. Procedure LoInt;
  112.  
  113. Begin
  114.    Mem[AttributeSeg:AttributeOfs] := Mem[AttributeSeg:AttributeOfs] and $F7;
  115. end;
  116.  
  117. {------------------------------------}
  118.  
  119. Procedure Normal;
  120.  
  121. Begin
  122.    Mem[AttributeSeg:AttributeOfs] :=  $07;
  123. end;
  124.  
  125. {----------------------------------------------------------}
  126.  
  127. Procedure IncrementScnPos;
  128. begin
  129.   Col := Col + 1;
  130.   if Col > 80 then
  131.     begin
  132.       Row := Row +1;
  133.       Col := 1;
  134.     end;
  135. end;
  136.  
  137. {------------------------------------------------------------------}
  138.  
  139. Procedure ReadScnFile(ScnName:FileName;var WhereToPutScn:TotScn);
  140. Var
  141.    Attr,bt,ByteValue,NextChar : byte;
  142. Begin
  143.    Attr := 7;{normal attribute}
  144.    Row:= 1;Col := 1;{Start writing to screen at upper
  145.                                  left corner}
  146.  
  147.    Assign(ScnFile,ScnName);
  148.    Reset(ScnFile);
  149.    While not eof(ScnFile) do
  150.  
  151.     begin
  152.       read(ScnFile,bt);
  153.       case bt of
  154.          $FF  :begin
  155.                  Read(ScnFile,Attr);
  156.                end;
  157.          $00  :begin
  158.                  Read(ScnFile,ByteValue);{number of times next ASC11 value
  159.                                            is to be repeated}
  160.                  Read(ScnFile,NextChar);
  161.                  for count := 1 to ByteValue do
  162.                    begin
  163.                      WhereToPutScn[Row,Col,1] := NextChar;
  164.                      WhereToPutScn[Row,Col,2] := Attr;
  165.                      IncrementScnPos;
  166.                    end;
  167.                end
  168.                else begin
  169.                       WhereToPutScn[Row,Col,1] := bt;
  170.                       WhereToPutScn[Row,Col,2] := Attr;
  171.                       IncrementScnPos;
  172.                     end;
  173.       end;
  174.     end;
  175.    Close(ScnFile);
  176. end;
  177.  
  178. {------------------------------------------------------------------}
  179.  
  180. Procedure String_Entry(var Str_In:AnyString; Max:Integer);
  181.  
  182. Const
  183.    StringSet : set of char = [#8,#13,#27,#32..#126];
  184.  
  185. Var
  186.    Pos                                    : integer;
  187.    Answ                                   : AnyString;
  188.  
  189. Begin
  190.  
  191.      Ch1 := ' ';
  192.      Ch2 := ' ';
  193.      Answ:='';
  194.      col:=WhereX;row:=WhereY;
  195.      Pos:=0;
  196.      Reverse;
  197.      Repeat
  198.         Repeat read(kbd,Ch1) until Ch1 in StringSet;
  199.         if Ch1=#27  then read(kbd,Ch2);
  200.            {check to see if it is two character code}
  201.            {if so then read the second character}
  202.         case Ch1 of
  203.            ^H:if pos>0 then
  204.                    begin
  205.                      write(^H,' ',^H);
  206.                      delete(Answ,pos,1);
  207.                      pos:=pos-1;
  208.                      Str_In := Answ;
  209.                    end;
  210.             #32..#126:begin
  211.                        if pos=0 then
  212.                           begin
  213.                             for count:=1 to max do write(chr(32));
  214.                             for count:=1 to max do write(^H);
  215.                           end;
  216.                        if pos<max then
  217.                           begin
  218.                             pos:=pos+1;
  219.                             write(Ch1);
  220.                             Answ:=Answ+Ch1;
  221.                             Str_In := Answ;
  222.                           end
  223.                           else write(^G);
  224.                      end;
  225.         end;
  226.      until (Ch1 = ^M);
  227.      GotoXY(col,row);
  228.      Normal;
  229.      For count:= 1 to Max do write(chr(32));
  230.      GotoXY(col,row);
  231.      Write(Str_In:Max);
  232. end;
  233.  
  234. {-------------------------------------------------------------------------}
  235.  
  236. Procedure Integer_Entry(var Int_In:Integer;Max:Integer);
  237.  
  238. Const
  239.    IntSet    : set of char = [#8,#13,#27,#48..#57];
  240.  
  241. Var
  242.    Pos,code                               : integer;
  243.    Answ                                   : AnyString;
  244.  
  245. Begin
  246.  
  247.      Ch1 := ' ';
  248.      Ch2 := ' ';
  249.      Answ:='';
  250.      col:=WhereX;row:=WhereY;
  251.      Pos:=0;
  252.      Reverse;
  253.      Repeat
  254.         Repeat read(kbd,Ch1) until Ch1 in IntSet;
  255.         if Ch1=#27  then read(kbd,Ch2);
  256.            {check to see if it is two character code}
  257.            {if so then read the second character}
  258.         case Ch1 of
  259.            ^H:if pos>0 then
  260.                    begin
  261.                      write(^H,' ',^H);
  262.                      delete(Answ,pos,1);
  263.                      pos:=pos-1;
  264.                      Val(Answ,Int_In,code);
  265.                    end;
  266.             #32..#126:begin
  267.                        if pos=0 then
  268.                           begin
  269.                             for count:=1 to max do write(chr(32));
  270.                             for count:=1 to max do write(^H);
  271.                           end;
  272.                        if pos<max then
  273.                           begin
  274.                             pos:=pos+1;
  275.                             write(Ch1);
  276.                             Answ:=Answ+Ch1;
  277.                             Val(Answ,Int_In,code);
  278.                           end
  279.                           else write(^G);
  280.                      end;
  281.         end;
  282.      until (Ch1 = ^M);
  283.      GotoXY(col,row);
  284.      Normal;
  285.      For count:= 1 to max do write(chr(32));
  286.      GotoXY(col,row);
  287.      Write(Int_In:max);
  288. end;
  289.  
  290. {-------------------------------------------------------------------------}
  291.  
  292. Procedure Real_Entry(var Rl_In:Real;Max:Integer;NumDec:Integer);
  293.  
  294. Const
  295.    RealSet   : set of char = [#8,#13,#27,#46,#48..#57];
  296. Var
  297.    Pos,code,kount                         : integer;
  298.    Answ                                   : AnyString;
  299.  
  300. Begin
  301.  
  302.      Ch1 := ' ';
  303.      Ch2 := ' ';
  304.      Answ:='';
  305.      col:=WhereX;row:=WhereY;
  306.      Pos:=0;
  307.      Reverse;
  308.      Repeat
  309.         Repeat read(kbd,Ch1) until Ch1 in RealSet;
  310.         if Ch1=#27  then read(kbd,Ch2);
  311.            {check to see if it is two character code}
  312.            {if so then read the second character}
  313.         case Ch1 of
  314.            ^H:if pos>0 then
  315.                    begin
  316.                      write(^H,' ',^H);
  317.                      delete(Answ,pos,1);
  318.                      pos:=pos-1;
  319.                      Val(Answ,Rl_In,code);
  320.                    end;
  321.             #32..#126:begin
  322.                        if pos=0 then
  323.                           begin
  324.                             for kount:=1 to max do write(chr(32));
  325.                             for kount:=1 to max do write(^H);
  326.                           end;
  327.                        if pos<max then
  328.                           begin
  329.                             pos:=pos+1;
  330.                             write(Ch1);
  331.                             Answ:=Answ+Ch1;
  332.                             Val(Answ,Rl_In,code);
  333.                           end
  334.                           else write(^G);
  335.                      end;
  336.         end;
  337.      until (Ch1 = ^M);
  338.      GotoXY(col,row);
  339.      Normal;
  340.      For kount:= 1 to max do write(chr(32));
  341.      GotoXY(col,row);
  342.      Write(Rl_In:max:NumDec);
  343. end;
  344.  
  345. {------------------------------------------------------------------------}
  346.  
  347. Procedure Bol_Entry(var Bol_In:boolean);
  348. Begin
  349.   Repeat read(kbd,ch) until UpCase(ch) in['Y','N'];
  350.   if UpCase(ch) = 'Y' then Bol_In := true
  351.   else Bol_In := false;
  352.   if Bol_In = true then Write('Y') else Write('N');
  353. end;
  354.  
  355. {-------------------------------------------------------------------------}