home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / SVGADC30 / SVGAMAP.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-03  |  19KB  |  733 lines

  1. program SVGA_Bitmap_Maker;
  2.  
  3. {  Use mouse to choose color and draw image      }
  4. {  The followig keys can be used as follows      }
  5. {  'Q' - No nonsense quit                        }
  6. {  'S' - Save image to disk.  Will be prompted   }
  7. {        for a filename.                         }
  8. {  'L' - Load image from disk. Will be prompted  }
  9. {        for a filename.                         }
  10. {  'P' - Change width of each pixel element of   }
  11. {        drawing. Range 1..9                     }
  12. {  'N' - New image. Clears present image from    }
  13. {        memory.  Prompts for 'Y' or 'N'         }
  14. {  'C' - Change image size.  Will delete present }
  15. {        image from memory and start with new    }
  16. {        sized image.  Image dimensions are      }
  17. {        measured in pixels.  If not enough      }
  18. {        memory on heap image size will not      }
  19. {        be allowed.                             }
  20. {  'M' - Move image around screen to get at      }
  21. {        hard to reach places.  Press escape     }
  22. {        when done.                              }
  23. {  'X' - Load a palette from disk.  Prompts for  }
  24. {        filename.                               }
  25. {  'E' - Left over from development of this      }
  26. {        program.  Simply puts image to screen   }
  27. {        whereever mouse pointer is.             }
  28. {  If you want to exit from 'load' , 'save' etc  }
  29. {  without the program doing anything simply     }
  30. {  press enter with no input i.e. null string '' }
  31.  
  32. uses SVGA, Crt;
  33.  
  34. type YPtr = ^YType;
  35.      YType = record
  36.                Col1, Col2, Col3, Col4 : byte; { Due to TP's memory }
  37.                NextY : YPtr;                  { memory management }
  38.              end;                             { pointers are multiples}
  39.      XPtr = ^XType;                           { of 8 bytes }
  40.      XType = record
  41.                NextX : XPtr;
  42.                Y : YPtr;
  43.              end;
  44.  
  45. var GM : GraphicMouse;
  46.     Vx, Vy, PixelWidth, XPos, YPos, Btn, TX, TY, Bx, By : integer;
  47.     ActiveColor, MaxHeight, MaxWidth : byte;
  48.     XCoord, YCoord, resp, ImageName, PaletteName : string;
  49.     Quit : boolean;
  50.     Ch : char;
  51.     Image : XPtr;
  52.     HeapMem : longint;
  53.  
  54. procedure PutImage( x, y : integer; Img : XPtr );
  55.  
  56.   var xx, yy : integer;
  57.       Offset, bank : longint;
  58.  
  59.  
  60.   procedure TraverseYPtr( Yp : YPtr );
  61.  
  62.     begin
  63.       if Yp <> nil then
  64.         begin
  65.  
  66.           Bank := Offset shr 16;
  67.           if Bank <> PresentSeg then LoadWriteBank( Bank );
  68.           MEM[$A000:Offset] := Yp^.Col1;
  69.  
  70.           inc( Offset, Bytes_per_line );
  71.           Bank := Offset shr 16;
  72.           if Bank <> PresentSeg then LoadWriteBank( Bank );
  73.           MEM[$A000:Offset] := Yp^.Col2;
  74.  
  75.           inc( Offset, Bytes_per_line );
  76.           Bank := Offset shr 16;
  77.           if Bank <> PresentSeg then LoadWriteBank( Bank );
  78.           MEM[$A000:Offset] := Yp^.Col3;
  79.  
  80.           inc( Offset, Bytes_per_line );
  81.           Bank := Offset shr 16;
  82.           if Bank <> PresentSeg then LoadWriteBank( Bank );
  83.           MEM[$A000:Offset] := Yp^.Col4;
  84.  
  85.           inc( Offset, Bytes_per_line );
  86.           inc( yy, 4 );
  87.           TraverseYPtr( Yp^.NextY );
  88.         end;
  89.     end;
  90.  
  91.   procedure TraverseXPtr( Xp : XPtr );
  92.  
  93.     begin
  94.       if Xp <> nil then
  95.         begin
  96.           Offset := (longint(yy)*Bytes_per_line)+xx;
  97.           TraverseYPtr( Xp^.Y );
  98.           yy := y;
  99.           inc( xx );
  100.           TraverseXPtr( Xp^.NextX );
  101.         end;
  102.     end;
  103.  
  104.   begin
  105.     xx := x;
  106.     yy := y;
  107.     TraverseXPtr( Img );
  108.   end;
  109.  
  110. procedure SaveImage( Img : XPtr );
  111.  
  112.   var f : file of byte;
  113.  
  114.   procedure TraverseYPtr( Yp : YPtr );
  115.  
  116.     begin
  117.       if Yp <> nil then
  118.         begin
  119.           write( f, Yp^.Col1 );
  120.           write( f, Yp^.Col2 );
  121.           write( f, Yp^.Col3 );
  122.           write( f, Yp^.Col4 );
  123.           TraverseYPtr( Yp^.NextY );
  124.         end;
  125.     end;
  126.  
  127.   procedure TraverseXPtr( Xp : XPtr );
  128.  
  129.     begin
  130.       if Xp <> nil then
  131.         begin
  132.           TraverseYPtr( Xp^.Y );
  133.           TraverseXPtr( Xp^.NextX );
  134.         end;
  135.     end;
  136.  
  137.   begin
  138.     assign( f, imagename );
  139.     rewrite( f );
  140.     write( f, MaxWidth, MaxHeight );
  141.     TraverseXPtr( Img );
  142.     close( f );
  143.   end;
  144.  
  145. procedure DrawImage;
  146.  
  147.   var xx, yy, vvx, vvy : integer;
  148.  
  149.   procedure TraverseYPtr( Yp : YPtr );
  150.  
  151.     procedure PlotCol( c : byte; x: integer; var y : integer );
  152.  
  153.       begin
  154.         if yy < By then
  155.           begin
  156.             RectFill( x*PixelWidth, y*PixelWidth, x*PixelWidth+PixelWidth-1,
  157.                       y*PixelWidth+PixelWidth-1, c );
  158.             if (500+x < GetMaxX) and (300+y < GetmaxY) then
  159.                 Plot( 500+x, 300+y, c );
  160.             inc( y );
  161.           end;
  162.       end;
  163.  
  164.     begin
  165.       if vvy >= Vy then
  166.         begin
  167.           if (Yp <> nil) then
  168.             begin
  169.               PlotCol( Yp^.Col1, xx, yy );
  170.               PlotCol( Yp^.Col2, xx, yy );
  171.               PlotCol( Yp^.Col3, xx, yy );
  172.               PlotCol( Yp^.Col4, xx, yy );
  173.               TraverseYPtr( Yp^.NextY );
  174.             end;
  175.         end
  176.       else
  177.         begin
  178.           inc( vvy, 4 );
  179.           if Yp <> nil then TraverseYPtr( Yp^.NextY );
  180.         end
  181.     end;
  182.  
  183.   procedure TraverseXPtr( Xp : XPtr );
  184.  
  185.     begin
  186.       if vvx >= Vx then
  187.         begin
  188.           if (Xp <> nil) and (xx < Bx) then
  189.             begin
  190.               TraverseYPtr( Xp^.Y );
  191.               yy := 0; vvy := 0;
  192.               inc( xx );
  193.               TraverseXPtr( Xp^.NextX );
  194.             end;
  195.         end
  196.       else
  197.         begin
  198.           inc( vvx );
  199.           if Xp <> nil then TraverseXPtr( Xp^.NextX );
  200.         end;
  201.     end;
  202.  
  203.   begin
  204.     GM.Show( False );
  205.     ClearPort( 0, 0, GetMaxX-140, GetMaxY );
  206.     RectFill( 500,300,GetMaxX, GetMaxY, 0 );
  207.     xx := 0; vvx := 0;
  208.     yy := 0; vvy := 0;
  209.     TraverseXPtr( Image );
  210.     GM.Show( True );
  211.   end;
  212.  
  213. procedure LoadImage( var ImagePtr : XPtr );
  214.  
  215.   var f : file of byte;
  216.       Col1, Col2, Col3, Col4, th : byte;
  217.  
  218.   procedure ReadY( var Yp : YPtr );
  219.  
  220.     var TmpY : YPtr;
  221.  
  222.     begin
  223.       new( TmpY );
  224.       read( f, Col1, Col2, Col3, Col4 );
  225.       TmpY^.Col1 := Col1;
  226.       TmpY^.Col2 := Col2;
  227.       TmpY^.Col3 := Col3;
  228.       TmpY^.Col4 := Col4;
  229.       inc( th, 4 );
  230.       if th < MaxHeight then
  231.         ReadY( TmpY^.NextY )
  232.       else
  233.         TmpY^.NextY := nil;
  234.       Yp := TmpY;
  235.     end;
  236.  
  237.   procedure ReadX( var Xp : XPtr );
  238.  
  239.     var TmpX : XPtr;
  240.  
  241.     begin
  242.       if not eof( f ) then
  243.         begin
  244.           new( TmpX );
  245.           ReadY( TmpX^.Y );
  246.           th := 1;
  247.           ReadX( TmpX^.NextX );
  248.           Xp := TmpX;
  249.         end
  250.       else
  251.         Xp := nil;
  252.     end;
  253.  
  254.   begin
  255.     assign( f, ImageName );
  256.     reset( f );
  257.     read( f, MaxWidth, MaxHeight );
  258.     th := 1;
  259.     ReadX( ImagePtr );
  260.     close( f );
  261.   end;
  262.  
  263. procedure SetImageCol( x, y, NewCol : byte; var Img : XPtr );
  264.  
  265.   var xx, yy : byte;
  266.  
  267.   procedure TraverseYPtr( var Yp : YPtr );
  268.  
  269.     function ic( var t : byte ): byte;
  270.  
  271.       begin
  272.         inc( t );
  273.         ic := t;
  274.       end;
  275.  
  276.     begin
  277.       if Yp <> nil then
  278.         begin
  279.            if yy = y then Yp^.Col1 := NewCol
  280.              else if ic(yy) = y then Yp^.Col2 := NewCol
  281.                else if ic(yy) = y then Yp^.Col3 := NewCol
  282.                  else if ic(yy) = y then Yp^.Col4 := NewCol
  283.                    else
  284.                      begin
  285.                        inc( yy );
  286.                        TraverseYPtr( Yp^.NextY );
  287.                      end;
  288.         end;
  289.     end;
  290.  
  291.   procedure TraverseXPtr( var Xp : XPtr );
  292.  
  293.     begin
  294.       if Xp <> nil then
  295.         begin
  296.           if xx = x then
  297.             TraverseYPtr( Xp^.Y )
  298.           else
  299.             begin
  300.               inc( xx );
  301.               TraverseXPtr( Xp^.NextX );
  302.             end
  303.         end;
  304.     end;
  305.  
  306.   begin
  307.     xx := 0;
  308.     yy := 0;
  309.     TraverseXPtr( Img );
  310.   end;
  311.  
  312. procedure ClearMemory( var Img : XPtr );
  313.  
  314.   procedure TraverseYPtr( Yp : YPtr );
  315.  
  316.     begin
  317.       if Yp <> nil then
  318.         begin
  319.           Yp^.Col1 := 0;
  320.           Yp^.Col2 := 0;
  321.           Yp^.Col3 := 0;
  322.           Yp^.Col4 := 0;
  323.           TraverseYPtr( Yp^.NextY );
  324.         end;
  325.     end;
  326.  
  327.   procedure TraverseXPtr( Xp : XPtr );
  328.  
  329.     begin
  330.       if Xp <> nil then
  331.         begin
  332.           TraverseYPtr( Xp^.Y );
  333.           TraverseXPtr( Xp^.NextX );
  334.         end;
  335.     end;
  336.  
  337.   begin
  338.     TraverseXPtr( Img );
  339.   end;
  340.  
  341. procedure InitImage( var ImagePtr : XPtr );
  342.   { Make image of w x h dimensions }
  343.  
  344.   var tw, th : integer; s: string;
  345.  
  346.   procedure InitY( var Yp : YPtr );
  347.  
  348.     var TmpY : YPtr;
  349.  
  350.     begin
  351.       if th <= MaxHeight then
  352.         begin
  353.           new( TmpY );
  354.           inc( th, 4 );
  355.           InitY( TmpY^.NextY )
  356.         end
  357.       else
  358.         TmpY := nil;
  359.       Yp := TmpY;
  360.     end;
  361.  
  362.   procedure InitX( var Xp : XPtr );
  363.  
  364.     var TmpX : XPtr;
  365.  
  366.     begin
  367.       if tw <= MaxWidth then
  368.         begin
  369.           new( TmpX );
  370.           InitY( TmpX^.Y );
  371.           th := 1;
  372.           inc( tw );
  373.           InitX( TmpX^.NextX );
  374.           Xp := TmpX;
  375.         end
  376.       else
  377.         Xp := nil;
  378.     end;
  379.  
  380.   begin
  381.     tw := 1;
  382.     th := 1;
  383.     InitX( ImagePtr );
  384.     ClearMemory( ImagePtr );
  385.   end;
  386.  
  387. procedure DisposeImage( var Img : XPtr );
  388.  
  389.   procedure TraverseYPtr( Yp : YPtr );
  390.  
  391.     begin
  392.       if Yp <> nil then
  393.         begin
  394.           TraverseYPtr( Yp^.NextY );
  395.           Dispose( Yp );
  396.         end;
  397.     end;
  398.  
  399.   procedure TraverseXPtr( Xp : XPtr );
  400.  
  401.     begin
  402.       if Xp <> nil then
  403.         begin
  404.           TraverseXPtr( Xp^.NextX );
  405.           TraverseYPtr( Xp^.Y );
  406.         end;
  407.     end;
  408.  
  409.   begin
  410.     TraverseXPtr( Img );
  411.     Img := nil;
  412.   end;
  413.  
  414.  
  415. procedure SetUp;
  416.  
  417.   var i, j : integer;
  418.  
  419.   begin
  420.     SetMode( SVGA6448 );
  421.     LoadFont( StandardFont );
  422.     SetFontColor( 253, 0, false );
  423.     LoadPalette( 'Pal002.pal' );
  424.     for i := 0 to 7 do
  425.       for j := 0 to 31 do
  426.         RectFill( 500+i*15, j*7, 500+i*15+14, j*7+7, i*32+j );
  427.     Quit := False;
  428.     ActiveColor := 45;
  429.     MaxWidth := 10;
  430.     MaxHeight := 10;
  431.     Bx := MaxWidth;
  432.     By := MaxHeight;
  433.     Image := nil;
  434.     InitImage( Image );
  435.     PixelWidth := 4;
  436.     HeapMem := MemAvail;
  437.     Vx := 0;
  438.     Vy := 0;
  439.     ImageName := '';
  440.     GM.Initialize;
  441.   end;
  442.  
  443. procedure Message2( Note : string );
  444.  
  445.   begin
  446.     ClearPort( 500, 225, GetMaxX, GetMaxY );
  447.     OutTextXY( 510, 235, Note );
  448.   end;
  449.  
  450. function Message( Note : string ) : string;
  451.  
  452.    var TempStr : string;
  453.        Ch : char;
  454.  
  455.    begin
  456.       TempStr := '';
  457.       ClearPort( 500, 225, GetMaxX, 280 );
  458.       OutTextXY( 510, 235, Note );
  459.       repeat
  460.          ClearPort( 500, 250, GetMaxX, 260 );
  461.          OutTextXY( 510, 250, TempStr );
  462.          Ch := ReadKey;
  463.          case upcase(Ch) of
  464.             'A'..'Z',
  465.             '0'..'9',
  466.             '\', ':',
  467.             '.', '_'  : TempStr := TempStr+ upcase(Ch);
  468.             #$7F,#$08 : if ord( TempStr[0] ) > 0 then
  469.                         TempStr[0] := chr( ord( TempStr[0] ) - 1 );
  470.          end;
  471.       until Ch = #$0D;
  472.       ClearPort( 500, 225, GetMaxX, 280 );
  473.       Message := TempStr;
  474.    end;
  475.  
  476. procedure GetBxBy;
  477.  
  478.   begin
  479.     if PixelWidth*(MaxWidth-Vx) > (GetMaxX-140) then Bx := ((GetMaxX-140) div PixelWidth)-1
  480.       else Bx := MaxWidth - Vx;
  481.     if PixelWidth*(MaxHeight-Vy) > GetMaxY then By := (GetMaxY div PixelWidth)-1
  482.       else By := MaxHeight - Vy;
  483.   end;
  484.  
  485. procedure ChangePixelWidth;
  486.  
  487.   var w : string;
  488.  
  489.   begin
  490.     repeat
  491.       w := Message( 'Pixel Width' );
  492.       PixelWidth :=  ord(w[1]) - ord('0');
  493.     until PixelWidth in [1..9];
  494.     GetBxBy;
  495.     DrawImage;
  496.   end;
  497.  
  498. procedure ChangeImageSize;
  499.  
  500.   var sx, sy : string;
  501.        px, py, txx, tyy : integer;
  502.       M : Position;
  503.       done : boolean;
  504.       hp, x,y : longint;
  505.  
  506.   begin
  507.     GM.Show( False );
  508.     done := false;
  509.     Message2( 'Image Size' );
  510.     ClearPort( 0, 0, GetMaxX-140, GetMaxY );
  511.     GM.QueryBtnDn( 0, M );
  512.     MaxHeight := 80;
  513.     MaxWidth := 80;
  514.     Rectangle( 0, 0, MaxWidth, MaxHeight, 253 );
  515.     GM.SetPosition( 80, 80 );
  516.     x := 20; px := 20;
  517.     y := 20; py := 20;
  518.     repeat
  519.       repeat
  520.         GM.QueryBtnDn( 0, M );
  521.         GM.ReadMove( txx, tyy );
  522.         if (x + txx) > 63 then x := 63
  523.             else if (x + txx) < 1 then x := 1
  524.               else x := x + txx;
  525.         if (y + tyy) > 63 then y := 63
  526.             else if (y + tyy) < 1 then y := 1
  527.               else y := y + tyy;
  528.         y := y;
  529.         x := x;
  530.         if (x <> px) or (y <> py) then
  531.           begin
  532.             Rectangle( 0, 0, px*4, py*4, 0 );
  533.             Rectangle( 0, 0, x*4, y*4, 253 );
  534.             str( x*4, sx );
  535.             str( y*4, sy );
  536.             OutTextXY( 525, 260, sx+'  ' );
  537.             OutTextXY( 575, 260, sy+'  ' );
  538.             str( MemAvail, sy );
  539.             OutTextXY( 400,400, sy );
  540.           end;
  541.         px := x;
  542.         py := y;
  543.       until M.OpCount > 0;
  544.       hp := x*4*(y*4+1)*8;
  545.       if hp < HeapMem then done := true
  546.         else
  547.           begin
  548.             sound(3200); delay( 40 );
  549.             sound(2200); delay( 50 );
  550.             sound(4000);delay( 40 );
  551.             nosound;
  552.           end;
  553.     until done;
  554.     MaxHeight := y*4;
  555.     MaxWidth := x*4;
  556.     ClearPort( 500, 225, GetMaxX, 280 );
  557.     GM.Show( True );
  558.   end;
  559.  
  560. procedure MoveImage;
  561.  
  562.   const i = 20;
  563.  
  564.   var p1, p2 : integer;
  565.  
  566.   procedure minus( var v : integer);
  567.  
  568.     begin
  569.       if (v-i) < 0 then v := 0
  570.         else v := v - i;
  571.     end;
  572.  
  573.   procedure plus( var v : integer; max : integer );
  574.  
  575.     begin
  576.       if (v+i) > max then v := max
  577.         else v := v + i;
  578.     end;
  579.  
  580.   begin
  581.     GM.Show( False );
  582.     Message2( 'Move Image' );
  583.     p1 := Vx; p2 := Vy;
  584.     repeat
  585.       Ch := ReadKey;
  586.       if (Ch = #0) then
  587.         begin
  588.           Ch := ReadKey;
  589.           case ch of
  590.             'K' : minus( Vx );
  591.             'M' : plus( Vx, MaxWidth );
  592.             'H' : minus( Vy );
  593.             'P' : plus( Vy, MaxHeight );
  594.             'G' : begin
  595.                     minus( Vx );
  596.                     minus( Vy );
  597.                   end;
  598.             'I' : begin
  599.                     plus( Vx, MaxWidth );
  600.                     minus( Vy );
  601.                   end;
  602.             'O' : begin
  603.                     minus( Vx );
  604.                     plus( Vy, MaxHeight );
  605.                   end;
  606.             'Q' : begin
  607.                     plus( Vx, MaxWidth );
  608.                     plus( Vy, MaxHeight);
  609.                   end;
  610.           end;
  611.           if (Vx <> p1) or (Vy <> p2) then
  612.             begin
  613.               GetBxBy;
  614.               DrawImage;
  615.               GM.Show( False );
  616.             end;
  617.           p1 := Vx; p2 := Vy;
  618.         end;
  619.     until (Ch = #27);
  620.     ClearPort( 500, 225, GetMaxX, 280 );
  621.     GetBxBy;
  622.     GM.Show( True );
  623.   end;
  624.  
  625. procedure LoadPal;
  626.  
  627.   begin
  628.     resp := Message( 'Pallette?' );
  629.     if Resp <> '' then
  630.         LoadPalette( resp );
  631.   end;
  632.  
  633. begin
  634.   SetUp;
  635.   DrawImage;
  636.   repeat
  637.     GM.CheckMouse;
  638.     GM.GetPosition( Btn, XPos, YPos );
  639.     TX := ( XPos div PixelWidth );
  640.     TY := ( YPos div PixelWidth );
  641.     if (XPos < (MaxWidth+1)*PixelWidth ) AND (YPos < (MaxHeight+1)*PixelWidth)
  642.        and (XPos < Bx*PixelWidth) and (YPos < By*PixelWidth) then
  643.       begin
  644.         str( (XPos div PixelWidth)+Vx, XCoord );
  645.         str( (YPos div PixelWidth)+Vy, YCoord );
  646.         OutTextXY( 525, 260, XCoord+'  ' );
  647.         OutTextXY( 575, 260, YCoord+'  ' );
  648.       end;
  649.     if ( XPos > 500 ) and ( Xpos < 620 ) AND ( Btn AND $01 = $01 )
  650.         AND ( YPos < 224 ) then
  651.       begin
  652.         GM.Show( False );
  653.         for TX := 0 to 7 do
  654.           for TY := 0 to 31 do
  655.             RectFill( 500+TX*15, TY*7, 500+TX*15+14, TY*7+7, TX*32+TY );
  656.         TX := ((XPos-500) div 15);
  657.         TY := (YPos div 7 );
  658.         Rectangle( 500+TX*15, TY*7, 500+TX*15+14, TY*7+7, 255 );
  659.         Rectangle( 500+TX*15+1, TY*7+1, 500+TX*15+13, TY*7+6, 252 );
  660.         GM.Show( True );
  661.         ActiveColor := TX*32 + TY;
  662.       end;
  663.     if ( XPos < (MaxWidth+1)*PixelWidth) and (Btn AND $03 <> 0)
  664.         and (YPos < (MaxHeight+1)*PixelWidth)
  665.         and (XPos < Bx*PixelWidth)
  666.         and (YPos < By*PixelWidth)  then
  667.       begin
  668.         GM.Show( False );
  669.         SetImageCol( TX+Vx, TY+Vy, ActiveColor, Image );
  670.         RectFill( TX * PixelWidth, TY * PixelWidth,
  671.                   TX * PixelWidth+ PixelWidth-1,
  672.                   TY * PixelWidth+ PixelWidth-1, ActiveColor );
  673.         if ((500+tx) <= GetMaxX) and ((300+ty) <= GetMaxY) then
  674.           Plot( 500+TX, 300+TY, ActiveColor );
  675.         GM.Show( True );
  676.       end;
  677.     if keypressed then
  678.       begin
  679.         Ch := ReadKey;
  680.         case Ch of
  681.             'q','Q' : Quit := True;
  682.             's','S' : begin
  683.                         resp := Message( 'Save Image' );
  684.                         if resp <> '' then
  685.                           begin
  686.                             ImageName := resp;
  687.                             SaveImage( Image );
  688.                           end;
  689.                       end;
  690.             'l','L' : begin
  691.                         resp := Message( 'Load Image' );
  692.                         if resp <> '' then
  693.                           begin
  694.                             ImageName := resp;
  695.                             DisposeImage( Image );
  696.                             LoadImage( Image );
  697.                             GetBxBy;
  698.                             Vx := 0; Vy := 0;
  699.                             DrawImage;
  700.                           end;
  701.                       end;
  702.             'p','P' : ChangePixelWidth;
  703.             'n','N' : begin
  704.                         resp := Message( 'New Image?' );
  705.                         if resp[1] in ['Y','y'] then
  706.                           begin
  707.                             Clearmemory( Image );
  708.                             DrawImage;
  709.                           end
  710.                       end;
  711.             'c','C' : begin
  712.                         DisposeImage( Image );
  713.                         ChangeImageSize;
  714.                         InitImage( Image );
  715.                         PixelWidth := 4;
  716.                         GetBxBy;
  717.                         Vx := 0; Vy := 0;
  718.                         DrawImage;
  719.                       end;
  720.             'm','M' : MoveImage;
  721.             'x','X' : LoadPal;
  722.             'e','E' : begin
  723.                         GM.Show( False );
  724.                         PutImage( XPos, YPos, Image );
  725.                         Gm.Show( True );
  726.                       end;
  727.         end;
  728.       end;
  729.     until Quit;
  730.   ExitGraphics;
  731.   GM.ExitSVGA;
  732.   DisposeImage( Image );
  733. end.