home *** CD-ROM | disk | FTP | other *** search
/ SMPD PC.1517: A86 Macro Assembler 3.22 / smpd_pc1517_a86_macro_asm.img / PIX.ZIP / PIXED.PAS < prev    next >
Pascal/Delphi Source File  |  1994-03-08  |  29KB  |  977 lines

  1. Program PixEd;  {* PIXel EDitor v1.5 copyright (c) 1994 Matias Nyrell *}
  2.   Uses
  3.     Crt, Dos, Graph;
  4.   Var
  5.     EditSize                    : Record
  6.                                     X, Y  : ShortInt;
  7.                                   End;
  8.     ChangeWith, HighLight,
  9.     NumAnswer, PositionX,
  10.     PositionY, OldPositionX,
  11.     OldPositionY, VideoMode     : ShortInt;
  12.     Ch, Ch2                     : Char;
  13.     Color, PixelColor,
  14.     I, J, ErrorCode             : Integer;
  15.     HighlightChange,
  16.     PositionChange, Draw,
  17.     DrawChange, RightChoose     : Boolean;
  18.     SaveFileName                : String[8];
  19.     StrColor                    : String[3];
  20.     Cursor                      : Pointer;
  21.     SaveFile                    : Text;
  22.  
  23.  
  24.   Procedure VariableInit;
  25.   Begin {VariableInit}
  26.     HighlightChange   := true;
  27.     PositionChange    := true;
  28.     DrawChange        := true;
  29.     Draw              := false;
  30.     RightChoose       := false;
  31.     EditSize.X        := 30;
  32.     EditSize.Y        := 30;
  33.     Color             := 0;
  34.     ChangeWith        := 1;
  35.     HighLight         := 1;
  36.     VideoMode         := 0;
  37.     SaveFileName      := '         ';
  38.   End; {VariableInit}
  39.  
  40.   Procedure GraphInit;
  41.     Var
  42.       GraphDriver, GraphMode  : Integer;
  43.  
  44. {$F+}
  45.     Function MyDetectVGA256 : Integer;
  46.     Begin
  47.       MyDetectVGA256 := 2;
  48.     End;
  49. {$F-}
  50.     
  51.     Begin {GraphInit}
  52.       If ParamStr(1)= '' then
  53.       Begin
  54.         ClrScr;
  55.         TextColor(7);
  56.         GotoXY(2,10);
  57.         Writeln('Please choose a graphic mode:');
  58.         GotoXY(5,11);
  59.         Writeln('       A - EGA mode(640*350*16)');
  60.         GotoXY(5,12);
  61.         Writeln('       B - VGA mode(640*400*256)');
  62.         GotoXY(5,13);
  63.         Writeln('       C - VGA mode(640*480*256)');
  64.         Ch:= ReadKey;
  65.         If (Ch= 'a') or (Ch= 'A') then
  66.         Begin
  67.           GraphDriver:= EGA;
  68.           GraphMode  := EGAHi;
  69.           VideoMode  := 0;
  70.           RightChoose:= true;
  71.         End;
  72.         If (Ch= 'b') or (Ch= 'B') then
  73.         Begin
  74.           GraphDriver:= InstallUserDriver('SVGA256', @MyDetectVGA256);
  75.           GraphMode  := 1;
  76.           VideoMode  := 1;
  77.           RightChoose:= true;
  78.         End;
  79.         If (Ch= 'c') or (Ch= 'C') then
  80.         Begin
  81.           GraphDriver:= InstallUserDriver('SVGA256', @MyDetectVGA256);
  82.           GraphMode  := 2;
  83.           VideoMode  := 1;
  84.           RightChoose:= true;
  85.         End;
  86.         If RightChoose= false then
  87.         Begin
  88.           TextColor(15);
  89.           Writeln;
  90.           Writeln('Error - please restart!');
  91.           TextColor(7);
  92.           Delay(500);
  93.           Halt(1);
  94.         End;
  95.       End;
  96.       If (ParamStr(1)= 'e') or (ParamStr(1)= 'E') or (ParamStr(1)= 'ega') or (ParamStr(1)= 'EGA') then
  97.       Begin
  98.         GraphDriver:= EGA;
  99.         GraphMode  := EGAHi;
  100.         VideoMode  := 0;
  101.       End;
  102.       If (ParamStr(1)= 'v1') or (ParamStr(1)= 'V1') or (ParamStr(1)= 'vga1') or (ParamStr(1)= 'VGA1') then
  103.       Begin
  104.         GraphDriver:= InstallUserDriver('SVGA256', @MyDetectVGA256);
  105.         GraphMode  := 1;
  106.         VideoMode  := 1;
  107.       End;
  108.       If (ParamStr(1)= 'v2') or (ParamStr(1)= 'V2') or (ParamStr(1)= 'vga2') or (ParamStr(1)= 'VGA2') then
  109.       Begin
  110.         GraphDriver:= InstallUserDriver('SVGA256', @MyDetectVGA256);
  111.         GraphMode  := 2;
  112.         VideoMode  := 1;
  113.       End;
  114.       InitGraph(GraphDriver,GraphMode,'');
  115.     End; {GraphInit}
  116.  
  117.   Procedure ImageInit;
  118.   Begin {ImageInit}
  119.     SetColor(15);
  120.     Rectangle(0, 0, 6, 6);
  121.     GetMem(Cursor, ImageSize(0, 0, 6, 6));
  122.     GetImage(0, 0, 6, 6, Cursor^);
  123.     SetColor(0);
  124.     Rectangle(0, 0, 6, 6);
  125.   End; {ImageInit}
  126.  
  127.   Procedure ScreenInit;
  128.   Begin {ScreenInit}
  129.     ClearDevice;
  130.  
  131.     PositionX         := 0;
  132.     PositionY         := 0;
  133.     OldPositionX      := 0;
  134.     OldPositionY      := 0;
  135.  
  136.     SetFillStyle(1,0);
  137.     Bar(0, 0, 640, 350);
  138.  
  139.     SetFillStyle(1,8);                 { Gröna delen till höger }
  140.     Bar(380, 0, 617, 191);
  141.  
  142.     SetColor(10);
  143.     Rectangle(374, -1, 623, 196);
  144.     SetColor(2);
  145.     Rectangle(373, -1, 624, 197);
  146.     Rectangle(375, -1, 622, 195);
  147.  
  148.     SetColor(0);
  149.     SetTextStyle(1, 0, 2);
  150.     OutTextXY(401, 11, 'Load picture');
  151.     SetColor(15);
  152.     OutTextXY(400, 9, 'Load picture');
  153.     SetColor(0);
  154.     SetTextStyle(1, 0, 2);
  155.     OutTextXY(401, 36, 'Save picture');
  156.     SetColor(15);
  157.     OutTextXY(400, 34, 'Save picture');
  158.     SetColor(0);
  159.     SetTextStyle(1, 0, 2);
  160.     OutTextXY(401, 61, 'Clear picture');
  161.     SetColor(15);
  162.     OutTextXY(400, 59, 'Clear picture');
  163.  
  164.     SetColor(0);
  165.     SetTextStyle(1, 0, 2);
  166.     OutTextXY(401, 96, 'Edit picture');
  167.     SetColor(15);
  168.     OutTextXY(400, 94, 'Edit picture');
  169.  
  170.     SetColor(0);
  171.     SetTextStyle(1, 0, 2);
  172.     OutTextXY(401, 131, 'Change picture size');
  173.     SetColor(15);
  174.     OutTextXY(400, 129, 'Change picture size');
  175.  
  176.     SetColor(0);
  177.     SetTextStyle(1, 0, 2);
  178.     OutTextXY(401, 156, 'Exit');
  179.     SetColor(15);
  180.     OutTextXY(400, 154, 'Exit');
  181.  
  182.     If HighLight=1 then
  183.     Begin
  184.       SetColor(14);
  185.       OutTextXY(400, 9, 'Load picture');
  186.     End;
  187.     If HighLight=2 then
  188.     Begin
  189.       SetColor(14);
  190.       OutTextXY(400, 34, 'Save picture');
  191.     End;
  192.     If HighLight=3 then
  193.     Begin
  194.       SetColor(14);
  195.       OutTextXY(400, 59, 'Clear picture');
  196.     End;
  197.     If HighLight=4 then
  198.     Begin
  199.       SetColor(14);
  200.       OutTextXY(400, 94, 'Edit picture');
  201.     End;
  202.     If HighLight=5 then
  203.     Begin
  204.       SetColor(14);
  205.       OutTextXY(400, 129, 'Change picture size');
  206.     End;
  207.     If HighLight=6 then
  208.     Begin
  209.       SetColor(14);
  210.       OutTextXY(400, 154, 'Exit');
  211.     End;
  212.  
  213.     SetColor(15);                      { Röda delen till vänster }
  214.     For I:= 0 to EditSize.X do
  215.       Line(I*10, 0, I*10, EditSize.Y*10);
  216.     For I:= 0 to EditSize.Y do
  217.       Line( 0, I*10, EditSize.X*10, I*10);
  218.  
  219.     SetColor(4);
  220.     Rectangle(-1, -1, 305, 304);
  221.     Rectangle(-1, -1, 307, 306);
  222.     SetColor(12);
  223.     Rectangle(-1, -1, 306, 305);
  224.  
  225.     SetColor(9);                       { Blå delen i mitten }
  226.     Line(306, 36, 374, 38);
  227.     Line(306, 27, 306, 45);
  228.     Line(374, 29, 374, 54);
  229.  
  230.     SetColor(1);
  231.     Line(307, 37, 373, 39);
  232.     Line(307, 35, 373, 37);
  233.     Line(307, 23, 307, 35);
  234.     Line(307, 37, 307, 50);
  235.     Line(373, 20, 373, 36);
  236.     Line(373, 37, 373, 60);
  237.  
  238.     SetColor(9);
  239.     Line(306, 207, 374, 196);
  240.     Line(306, 185, 306, 225);
  241.     Line(374, 180, 374, 196);
  242.     Line(374, 196, 385, 196);
  243.  
  244.     SetColor(1);
  245.     Line(307, 206, 373, 195);
  246.     Line(307, 208, 373, 197);
  247.     Line(307, 170, 307, 206);
  248.     Line(307, 208, 307, 250);
  249.     Line(373, 170, 373, 195);
  250.     Line(373, 197, 400, 197);
  251.  
  252.  
  253.     SetColor(7);
  254.     SetTextStyle(0, 0, 1);
  255.     OutTextXY(317, 45, 'Active');
  256.     OutTextXY(321, 55, 'Color');
  257.     SetFillStyle(1, Color);
  258.     Bar(315, 65, 365, 100);
  259.     SetColor(0);
  260.     Str(Color, StrColor);
  261.     OutTextXY(331, 78, StrColor);
  262.     SetColor(7);
  263.     OutTextXY(317, 105, 'Change');
  264.     OutTextXY(325, 115, 'With');
  265.     OutTextXY(312, 125, '+ and -');
  266.     OutTextXY(310, 140, 'F1:+- ');
  267.     OutTextXY(310, 150, 'F2:+- ');
  268.     OutTextXY(310, 160, 'F3:+- ');
  269.     OutTextXY(363, 140, '1');
  270.     OutTextXY(363, 150, '5');
  271.     OutTextXY(355, 160, '10');
  272.  
  273.     SetTextStyle(1, 0, 2);
  274.     SetColor(15);
  275.   End; {ScreenInit}
  276.  
  277.   Procedure EditMode;
  278.   Begin {EditMode}
  279.     Repeat
  280.       If HighLightChange= true then
  281.       Begin
  282.         SetTextStyle(1, 0, 2);
  283.         If HighLight= 1 then
  284.         Begin
  285.           SetColor(15);
  286.           OutTextXY(400, 154, 'Exit');
  287.           SetColor(14);
  288.           OutTextXY(400, 9, 'Load picture');
  289.           SetColor(15);
  290.           OutTextXY(400, 34, 'Save picture');
  291.         End;
  292.         If HighLight= 2 then
  293.         Begin
  294.           SetColor(15);
  295.           OutTextXY(400, 9, 'Load picture');
  296.           SetColor(14);
  297.           OutTextXY(400, 34, 'Save picture');
  298.           SetColor(15);
  299.           OutTextXY(400, 59, 'Clear picture');
  300.         End;
  301.         If HighLight= 3 then
  302.         Begin
  303.           SetColor(15);
  304.           OutTextXY(400, 34, 'Save picture');
  305.           SetColor(14);
  306.           OutTextXY(400, 59, 'Clear picture');
  307.           SetColor(15);
  308.           OutTextXY(400, 94, 'Edit picture');
  309.         End;
  310.         If HighLight= 4 then
  311.         Begin
  312.           SetColor(15);
  313.           OutTextXY(400, 59, 'Clear picture');
  314.           SetColor(14);
  315.           OutTextXY(400, 94, 'Edit picture');
  316.           SetColor(15);
  317.           OutTextXY(400, 129, 'Change picture size');
  318.         End;
  319.         If HighLight= 5 then
  320.         Begin
  321.           SetColor(15);
  322.           OutTextXY(400, 94, 'Edit picture');
  323.           SetColor(14);
  324.           OutTextXY(400, 129, 'Change picture size');
  325.           SetColor(15);
  326.           OutTextXY(400, 154, 'Exit');
  327.         End;
  328.         If HighLight= 6 then
  329.         Begin
  330.           SetColor(15);
  331.           OutTextXY(400, 129, 'Change picture size');
  332.           SetColor(14);
  333.           OutTextXY(400, 154, 'Exit');
  334.           SetColor(15);
  335.           OutTextXY(400, 9, 'Load picture');
  336.         End;
  337.         HighlightChange:= false;
  338.       End;
  339.  
  340.       Ch:= ReadKey;
  341.  
  342.       If Ch= Chr(72) then
  343.       Begin
  344.         HighLight:= HighLight-1;
  345.         If HighLight<1 then
  346.           HighLight:= 6;
  347.         HighlightChange:= true;
  348.       End;
  349.       If Ch= Chr(80) then
  350.       Begin
  351.         HighLight:= HighLight+1;
  352.         If HighLight>6 then
  353.           HighLight:= 1;
  354.         HighlightChange:= true;
  355.       End;
  356.       If Ch= Chr(59) then
  357.         ChangeWith:= 1;
  358.       If Ch= Chr(60) then
  359.         ChangeWith:= 5;
  360.       If Ch= Chr(61) then
  361.         ChangeWith:= 10;
  362.       If Ch= Chr(45) then
  363.       Begin
  364.         If VideoMode= 0 then
  365.         Begin
  366.           Color:= Color-ChangeWith;
  367.           If Color<0 then
  368.             Color:= 15;
  369.           SetFillStyle(1, Color);
  370.           Bar(315, 65, 365, 100);
  371.         End;
  372.         If VideoMode= 1 then
  373.         Begin
  374.           Color:= Color-ChangeWith;
  375.           If Color<0 then
  376.             Color:= 255;
  377.           SetFillStyle(1, Color);
  378.           Bar(315, 65, 365, 100);
  379.         End;
  380.         SetTextStyle(0, 0, 1);
  381.         SetColor(0);
  382.         Str(Color, StrColor);
  383.         OutTextXY(331, 78, StrColor);
  384.       End;
  385.       If Ch= Chr(43) then
  386.       Begin
  387.         If VideoMode= 0 then
  388.         Begin
  389.           Color:= Color+ChangeWith;
  390.           If Color>15 then
  391.             Color:= 0;
  392.           SetFillStyle(1, Color);
  393.           Bar(315, 65, 365, 100);
  394.         End;
  395.         If VideoMode= 1 then
  396.         Begin
  397.           Color:= Color+ChangeWith;
  398.           If Color>255 then
  399.             Color:= 0;
  400.           SetFillStyle(1, Color);
  401.           Bar(315, 65, 365, 100);
  402.         End;
  403.         SetTextStyle(0, 0, 1);
  404.         SetColor(0);
  405.         Str(Color, StrColor);
  406.         OutTextXY(331, 78, StrColor);
  407.       End;
  408.  
  409.       If Ch= Chr(13) then
  410.       Begin
  411.         If HighLight= 1 then
  412.         Begin
  413.           SaveFileName      := '         ';
  414.           For I:= 550 downto 250 do
  415.           Begin
  416.             SetColor(15);
  417.             Line(460, I, 460, I);
  418.             Line(461, I, 461, I);
  419.             Line(462, I, 462, I);
  420.             Line(463, I, 463, I);
  421.             Line(464, I, 464, I);
  422.             Line(465, I, 465, I);
  423.             Line(466, I, 466, I);
  424.             Line(467, I, 467, I);
  425.             Line(468, I, 468, I);
  426.             Line(469, I, 469, I);
  427.  
  428.             SetColor(11);
  429.             Line(455, I, 455, I);
  430.             Line(456, I, 456, I);
  431.             Line(457, I, 457, I);
  432.             Line(458, I, 458, I);
  433.             Line(459, I, 459, I);
  434.  
  435.             Line(470, I, 470, I);
  436.             Line(471, I, 471, I);
  437.             Line(472, I, 472, I);
  438.             Line(473, I, 473, I);
  439.             Line(474, I, 474, I);
  440.  
  441.             SetColor(9);
  442.             Line(453, I, 453, I);
  443.             Line(454, I, 454, I);
  444.             Line(455, I, 455, I);
  445.  
  446.             Line(475, I, 475, I);
  447.             Line(476, I, 476, I);
  448.             Line(477, I, 477, I);
  449.  
  450.             SetColor(1);
  451.             Line(451, I, 451, I);
  452.             Line(452, I, 452, I);
  453.  
  454.             Line(478, I, 478, I);
  455.             Line(479, I, 479, I);
  456.  
  457.             SetColor(6);
  458.             Rectangle(370, I-41, 567, I-4);
  459.             Rectangle(368, I-43, 569, I-2);
  460.  
  461.             SetColor(14);
  462.             Rectangle(369, I-42, 568, I-3);
  463.  
  464.             SetColor(0);
  465.             Line(371, I-40, 566, I-40);
  466.             Line(368, I-1, 569, I-1);
  467.  
  468.             Delay(2);
  469.           End;
  470.  
  471.           SetColor(13);
  472.           SetTextStyle(2,0,4);
  473.           OutTextXY(380, 212, 'Which file do you want to load?');
  474.           OutTextXY(443, 237, '--------');
  475.           I:= 443;
  476.           ErrorCode:=1;
  477.           Repeat
  478.             Ch:= ReadKey;
  479.             SetColor(13);
  480.             OutTextXY(I, 232, Ch);
  481.             If (Ch<> Chr(27)) or (Ch<> Chr(8)) or (Ch<> Chr(13)) then
  482.               SaveFileName[ErrorCode]:= Ch;
  483.             I:= I+6;
  484.             ErrorCode:= ErrorCode+1;
  485.             If Ch= Chr(8) then
  486.             Begin
  487.               ErrorCode:= ErrorCode-1;
  488.               I:= I-12;
  489.               Ch:= '█';
  490.               SetColor(0);
  491.               OutTextXY(I, 228, Ch);
  492.               OutTextXY(I, 233, Ch);
  493.             End;
  494.           Until (I= 491) or (Ch=Chr(13)) or (Ch=Chr(27));
  495.           If Ch<> Chr(27) then
  496.           Begin
  497.             For I:= 1 to 8 do
  498.             Begin
  499.               If SaveFileName[I]= Chr(13) then
  500.                 SaveFileName[I]:= ' ';
  501.             End;
  502.             Assign(SaveFile, SaveFileName+'.PIX');
  503.  
  504.             Reset(SaveFile);
  505.             Readln(SaveFile, EditSize.X);
  506.             Readln(SaveFile, EditSize.Y);
  507.             Screeninit;
  508.             I:= 0;
  509.             J:= 0;
  510.             SetFillStyle(1, Color);
  511.             While not EOF(SaveFile) do
  512.             Begin
  513.               Readln(SaveFile, PixelColor);
  514.               SetFillStyle(1, PixelColor);
  515.               Bar((I*10)+1, (J*10)+1, (I*10)+9, (J*10)+9);
  516.               PutPixel(I+325, J, PixelColor);
  517.               I:= I+1;
  518.               If I= EditSize.X then
  519.               Begin
  520.                 I:= 0;
  521.                 J:= J+1;
  522.               End;
  523.             End;
  524.           End;
  525.           For I:= 250 to 550 do
  526.           Begin
  527.             SetColor(6);
  528.             Rectangle(368, I-43, 569, I-2);
  529.             Rectangle(370, I-41, 567, I-4);
  530.  
  531.             SetColor(14);
  532.             Rectangle(369, I-42, 568, I-3);
  533.  
  534.             SetColor(0);
  535.             Line(368, I-44, 569, I-44);
  536.             Line(371, I-5, 566, I-5);
  537.             Delay(6);
  538.           End;
  539.           If Ch<> Chr(27) then
  540.             Close(SaveFile);
  541.         End;
  542.  
  543.         If Highlight= 2 then
  544.         Begin
  545.           SaveFileName      := '         ';
  546.           For I:= 550 downto 250 do
  547.           Begin
  548.             SetColor(15);
  549.             Line(460, I, 460, I);
  550.             Line(461, I, 461, I);
  551.             Line(462, I, 462, I);
  552.             Line(463, I, 463, I);
  553.             Line(464, I, 464, I);
  554.             Line(465, I, 465, I);
  555.             Line(466, I, 466, I);
  556.             Line(467, I, 467, I);
  557.             Line(468, I, 468, I);
  558.             Line(469, I, 469, I);
  559.  
  560.             SetColor(11);
  561.             Line(455, I, 455, I);
  562.             Line(456, I, 456, I);
  563.             Line(457, I, 457, I);
  564.             Line(458, I, 458, I);
  565.             Line(459, I, 459, I);
  566.  
  567.             Line(470, I, 470, I);
  568.             Line(471, I, 471, I);
  569.             Line(472, I, 472, I);
  570.             Line(473, I, 473, I);
  571.             Line(474, I, 474, I);
  572.  
  573.             SetColor(9);
  574.             Line(453, I, 453, I);
  575.             Line(454, I, 454, I);
  576.             Line(455, I, 455, I);
  577.  
  578.             Line(475, I, 475, I);
  579.             Line(476, I, 476, I);
  580.             Line(477, I, 477, I);
  581.  
  582.             SetColor(1);
  583.             Line(451, I, 451, I);
  584.             Line(452, I, 452, I);
  585.  
  586.             Line(478, I, 478, I);
  587.             Line(479, I, 479, I);
  588.             Delay(2);
  589.  
  590.             SetColor(6);
  591.             Rectangle(350, I-41, 597, I-4);
  592.             Rectangle(348, I-43, 599, I-2);
  593.  
  594.             SetColor(14);
  595.             Rectangle(349, I-42, 598, I-3);
  596.  
  597.             SetColor(0);
  598.             Line(351, I-40, 596, I-40);
  599.             Line(348, I-1, 599, I-1);
  600.           End;
  601.  
  602.           SetColor(13);
  603.           SetTextStyle(2,0,4);
  604.           OutTextXY(360, 212, 'What do you want to call the saved File?');
  605.           OutTextXY(443, 237, '--------');
  606.           I:= 443;
  607.           ErrorCode:=1;
  608.           Repeat
  609.             Ch:= ReadKey;
  610.             SetColor(13);
  611.             OutTextXY(I, 232, Ch);
  612.             If (Ch<> Chr(27)) or (Ch<> Chr(8)) or (Ch<> Chr(13)) then
  613.               SaveFileName[ErrorCode]:= Ch;
  614.             I:= I+6;
  615.             ErrorCode:= ErrorCode+1;
  616.             If Ch= Chr(8) then
  617.             Begin
  618.               ErrorCode:= ErrorCode-1;
  619.               I:= I-12;
  620.               Ch:= '█';
  621.               SetColor(0);
  622.               OutTextXY(I, 228, Ch);
  623.               OutTextXY(I, 233, Ch);
  624.             End;
  625.           Until (I= 491) or (Ch=Chr(13)) or (Ch=Chr(27));
  626.           If Ch<> Chr(27) then
  627.           Begin
  628.             For I:= 1 to 8 do
  629.             Begin
  630.               If SaveFileName[I]= Chr(13) then
  631.                 SaveFileName[I]:= ' ';
  632.             End;
  633.             Assign(SaveFile, SaveFileName+'.PIX');
  634.             Rewrite(SaveFile);
  635.             Writeln(SaveFile, EditSize.X);
  636.             Writeln(SaveFile, EditSize.Y);
  637.             For I:= 0 to EditSize.Y-1 do
  638.             Begin
  639.               For J:= 0 to EditSize.X-1 do
  640.               Begin
  641.                 PixelColor:= GetPixel((J*10)+2, (I*10)+2);
  642.                 Writeln(SaveFile, PixelColor);
  643.               End;
  644.             End;
  645.           End;
  646.  
  647.           For I:= 250 to 550 do
  648.           Begin
  649.             SetColor(6);
  650.             Rectangle(350, I-41, 597, I-4);
  651.             Rectangle(348, I-43, 599, I-2);
  652.  
  653.             SetColor(14);
  654.             Rectangle(349, I-42, 598, I-3);
  655.  
  656.             SetColor(0);
  657.             Line(348, I-44, 599, I-44);
  658.             Line(351, I-5, 596, I-5);
  659.             Delay(6);
  660.           End;
  661.           If Ch<> Chr(27) then
  662.             Close(SaveFile);
  663.         End;
  664.  
  665.  
  666.         If Highlight= 3 then
  667.           ScreenInit;
  668.         If Highlight= 4 then
  669.         Begin
  670.           Repeat
  671.             If PositionChange= true then
  672.               PutImage((PositionX*10)+2, (PositionY*10)+2, Cursor^, XorPut);
  673.             Ch:= ReadKey;
  674.             PositionChange:= false;
  675.  
  676.             If Ch= Chr(59) then
  677.               ChangeWith:= 1;
  678.             If Ch= Chr(60) then
  679.               ChangeWith:= 5;
  680.             If Ch= Chr(61) then
  681.               ChangeWith:= 10;
  682.             If Ch= Chr(62) then
  683.             Begin
  684.               If (Draw= false) and (DrawChange= true) then
  685.               Begin
  686.                 Draw:= true;
  687.                 DrawChange:= false;
  688.               End;
  689.               If (Draw= true) and (DrawChange= true) then
  690.               Begin
  691.                 Draw:= false;
  692.                 DrawChange:= false;
  693.               End;
  694.               DrawChange:= true;
  695.             End;
  696.  
  697.             If Ch= Chr(72) then
  698.             Begin
  699.               PositionY:= PositionY-1;
  700.               If PositionY<0 then
  701.                 PositionY:= EditSize.Y-1;
  702.               PositionChange:= true;
  703.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  704.             End;
  705.             If Ch= Chr(80) then
  706.             Begin
  707.               PositionY:= PositionY+1;
  708.               If PositionY>EditSize.Y-1 then
  709.                 PositionY:= 0;
  710.               PositionChange:= true;
  711.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  712.             End;
  713.             If Ch= Chr(75) then
  714.             Begin
  715.               PositionX:= PositionX-1;
  716.               If PositionX<0 then
  717.                 PositionX:= EditSize.X-1;
  718.               PositionChange:= true;
  719.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  720.             End;
  721.             If Ch= Chr(77) then
  722.             Begin
  723.               PositionX:= PositionX+1;
  724.               If PositionX>EditSize.X-1 then
  725.                 PositionX:= 0;
  726.               PositionChange:= true;
  727.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  728.             End;
  729.  
  730.             If Ch= Chr(71) then
  731.             Begin
  732.               PositionY:= PositionY-1;
  733.               PositionX:= PositionX-1;
  734.               If PositionY<0 then
  735.                 PositionY:= EditSize.Y-1;
  736.               If PositionX<0 then
  737.                 PositionX:= EditSize.X-1;
  738.               PositionChange:= true;
  739.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  740.             End;
  741.             If Ch= Chr(73) then
  742.             Begin
  743.               PositionY:= PositionY-1;
  744.               PositionX:= PositionX+1;
  745.               If PositionY<0 then
  746.                 PositionY:= EditSize.Y-1;
  747.               If PositionX>EditSize.X-1 then
  748.                 PositionX:= 0;
  749.               PositionChange:= true;
  750.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  751.             End;
  752.             If Ch= Chr(79) then
  753.             Begin
  754.               PositionY:= PositionY+1;
  755.               PositionX:= PositionX-1;
  756.               If PositionY> EditSize.Y-1 then
  757.                 PositionY:= 0;
  758.               If PositionX< 0 then
  759.                 PositionX:= EditSize.X-1;
  760.               PositionChange:= true;
  761.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  762.             End;
  763.             If Ch= Chr(81) then
  764.             Begin
  765.               PositionY:= PositionY+1;
  766.               PositionX:= PositionX+1;
  767.               If PositionY> EditSize.Y-1 then
  768.                 PositionY:= 0;
  769.               If PositionX> EditSize.X-1 then
  770.                 PositionX:= 0;
  771.               PositionChange:= true;
  772.               PutImage((OldPositionX*10)+2, (OldPositionY*10)+2, Cursor^, XorPut);
  773.             End;
  774.  
  775.  
  776.             If PositionChange= true then
  777.             Begin
  778.               OldPositionX:= PositionX;
  779.               OldPositionY:= PositionY;
  780.             End;
  781.  
  782.             If (Ch= Chr(32)) or (Draw= true) then
  783.             Begin
  784.               SetFillStyle(1, Color);
  785.               Bar((PositionX*10)+1, (PositionY*10)+1,
  786.                                     (PositionX*10)+9, (PositionY*10)+9);
  787.               PutImage((PositionX*10)+2, (PositionY*10)+2, Cursor^, XorPut);
  788.  
  789.               PutPixel(PositionX+325, PositionY, Color);
  790.             End;
  791.             If Ch= Chr(45) then
  792.             Begin
  793.               If VideoMode= 0 then
  794.               Begin
  795.                 Color:= Color-ChangeWith;
  796.                 If Color<0 then
  797.                   Color:= 15;
  798.                 SetFillStyle(1, Color);
  799.                 Bar(315, 65, 365, 100);
  800.               End;
  801.               If VideoMode= 1 then
  802.               Begin
  803.               Color:= Color-ChangeWith;
  804.                 If Color<0 then
  805.                   Color:= 255;
  806.                 SetFillStyle(1, Color);
  807.                 Bar(315, 65, 365, 100);
  808.               End;
  809.               SetTextStyle(0, 0, 1);
  810.               SetColor(0);
  811.               Str(Color, StrColor);
  812.               OutTextXY(331, 78, StrColor);
  813.             End;
  814.             If Ch= Chr(43) then
  815.             Begin
  816.               If VideoMode= 0 then
  817.               Begin
  818.                 Color:= Color+ChangeWith;
  819.                 If Color>15 then
  820.                   Color:= 0;
  821.                 SetFillStyle(1, Color);
  822.                 Bar(315, 65, 365, 100);
  823.               End;
  824.               If VideoMode= 1 then
  825.               Begin
  826.                 Color:= Color+ChangeWith;
  827.                 If Color>255 then
  828.                   Color:= 0;
  829.                 SetFillStyle(1, Color);
  830.                 Bar(315, 65, 365, 100);
  831.               End;
  832.               SetTextStyle(0, 0, 1);
  833.               SetColor(0);
  834.               Str(Color, StrColor);
  835.               OutTextXY(331, 78, StrColor);
  836.             End;
  837.           Until Ch= Chr(27);
  838.           PutImage((PositionX*10)+2, (PositionY*10)+2, Cursor^, XorPut);
  839.           PositionChange:= true;
  840.           Ch:= '0';
  841.         End;
  842.         If Highlight= 5 then
  843.         Begin
  844.           For I:= 550 downto 250 do
  845.           Begin
  846.  
  847.             SetColor(15);
  848.             Line(370, 480, 370, I);
  849.             Line(530, 480, 530, I);
  850.  
  851.             SetColor(11);
  852.             Line(369, 480, 369, I);
  853.             Line(371, 480, 371, I);
  854.  
  855.             Line(529, 480, 529, I);
  856.             Line(531, 480, 531, I);
  857.  
  858.             SetColor(9);
  859.             Line(367, 480, 367, I);
  860.             Line(368, 480, 368, I);
  861.             Line(372, 480, 372, I);
  862.             Line(373, 480, 373, I);
  863.  
  864.             Line(527, 480, 527, I);
  865.             Line(528, 480, 528, I);
  866.             Line(532, 480, 532, I);
  867.             Line(533, 480, 533, I);
  868.  
  869.             SetColor(1);
  870.             Line(366, 480, 366, I);
  871.             Line(374, 480, 374, I);
  872.  
  873.             Line(526, 480, 526, I);
  874.             Line(534, 480, 534, I);
  875.  
  876.             SetColor(2);
  877.             Rectangle(312, I-43, 590, I-2);
  878.             Rectangle(314, I-41, 588, I-4);
  879.             SetColor(3);
  880.             Rectangle(313, I-42, 589, I-3);
  881.  
  882.             SetColor(0);
  883.             Line(315, I-40, 587, I-40);
  884.             Line(312, I, 590, I);
  885.           End;
  886.           Line(312, I-1, 590, I-1);
  887.  
  888.           SetTextStyle(2, 0, 4);
  889.           SetColor(13);
  890.           OutTextXY(325, 211, 'Choose the length of the horizontal side:');
  891.           Repeat
  892.             SetColor(14);
  893.             Repeat
  894.               Ch:= ReadKey;
  895.               If (Ch< Chr(58)) and (Ch> Chr(47)) then
  896.                 OutTextXY(567, 211, Ch);
  897.             Until (Ch= Chr(27)) or (Ch< Chr(58)) or (Ch> Chr(47));
  898.             If Ch<> Chr(27) then
  899.             Begin
  900.               Repeat
  901.                 Ch2:= ReadKey;
  902.                 If (Ch2< Chr(58)) and (Ch2> Chr(47)) then
  903.                   OutTextXY(573, 211, Ch2);
  904.               Until (Ch2= Chr(27)) or (Ch2< Chr(58)) or (Ch2> Chr(47));
  905.             End;
  906.             Delay(30);
  907.             ErrorCode:= 0;
  908.             If (Ch<> Chr(27)) and (Ch2<> Chr(27)) then
  909.             Begin
  910.               Val((Ch+Ch2), NumAnswer, ErrorCode);
  911.               If NumAnswer<1 then
  912.                 NumAnswer:= 1;
  913.               If NumAnswer>30 then
  914.                 NumAnswer:= 30;
  915.               EditSize.X:= NumAnswer;
  916.             End;
  917.           Until (Ch=Chr(27)) or (Ch2=Chr(27)) or (Ch< Chr(58)) or (Ch> Chr(47)) or (Ch2< Chr(58)) or (Ch2> Chr(47));
  918.           If Ch2= Chr(27) then
  919.             Ch:= Ch2;
  920.  
  921.           If Ch<> Chr(27) then
  922.           Begin
  923.             SetColor(13);
  924.             OutTextXY(325, 228, 'Choose the length of the vertical   side:');
  925.             Repeat
  926.               SetColor(14);
  927.               Ch:= ReadKey;
  928.               If (Ch< Chr(58)) and (Ch> Chr(47)) then
  929.                 OutTextXY(567, 228, Ch);
  930.             Until (Ch= Chr(27)) or (Ch< Chr(58)) or (Ch> Chr(47));
  931.             If NOT (Ch= Chr(27)) then
  932.             Begin
  933.               Repeat
  934.                 Ch2:= ReadKey;
  935.                 If (Ch< Chr(58)) and (Ch> Chr(47)) then
  936.                   OutTextXY(573, 228, Ch2);
  937.               Until (Ch2= Chr(27)) or (Ch2< Chr(58)) or (Ch2> Chr(47));
  938.             End;
  939.             Delay(30);
  940.             If (Ch<> Chr(27)) and (Ch2<> Chr(27)) then
  941.             Begin
  942.               Val((Ch+Ch2), NumAnswer, ErrorCode);
  943.               If NumAnswer<1 then
  944.                 NumAnswer:= 1;
  945.               If NumAnswer>30 then
  946.                 NumAnswer:= 30;
  947.               EditSize.Y:= NumAnswer;
  948.             End;
  949.           End;
  950.           For I:= 250 to 550 do
  951.           Begin
  952.             SetColor(2);
  953.             Rectangle(312, I-43, 590, I-2);
  954.             Rectangle(314, I-41, 588, I-4);
  955.             SetColor(3);
  956.             Rectangle(313, I-42, 589, I-3);
  957.             SetColor(0);
  958.             Line(312, I-44, 590, I-44);
  959.             Line(315, I-5, 587, I-5);
  960.             Delay(3);
  961.           End;
  962.           ScreenInit;
  963.         End;
  964.         If Ch=Chr(27) then
  965.           Ch:= Chr(0);
  966.       End;
  967.     Until (Ch= Chr(13)) and (HighLight= 6);
  968.   End; {EditMode}
  969.  
  970.   Begin
  971.     VariableInit;
  972.     GraphInit;
  973.     ImageInit;
  974.     ScreenInit;
  975.     EditMode;
  976.     CloseGraph;
  977.   End.