home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / games / mineswpr.zip / LOGIC.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-31  |  22KB  |  1,226 lines

  1. program logic;
  2.  
  3. uses
  4.  
  5.   DOS,Crt,Graph;
  6.  
  7.   procedure EgaVgaDriverProc; external;
  8.  
  9.   {$L EGAVGA.OBJ }
  10.  
  11. type
  12.  
  13.   grid = array [0..49] of array [0..15] of integer;
  14.  
  15. var
  16.  
  17.   map : grid;
  18.  
  19.   tag : grid;
  20.  
  21.   regs : Registers;
  22.  
  23.   old  : Registers;
  24.  
  25.   GraphDriver : integer;
  26.  
  27.   GraphMode   : integer;
  28.  
  29.   ErrorCode   : integer;
  30.  
  31.   a,b,c,d,e   : integer;
  32.  
  33.   j,k         : integer;
  34.  
  35.   x,y,xx,yy   : integer;
  36.  
  37.   row,col     : integer;
  38.  
  39.   count,runid  : integer;
  40.  
  41.   mines,score : integer;
  42.  
  43.   mapx,mapy   : integer;
  44.  
  45.   idle1,idle2 : integer;
  46.  
  47.   oldxx,oldyy : integer;
  48.  
  49.   goodx,goody : integer;
  50.  
  51.   flags       : integer;
  52.  
  53.   size : word;
  54.  
  55.   s    : string[15];
  56.  
  57.   bang : pointer;
  58.  
  59. { ----- procedure for drawing blank buttons ----- }
  60.  
  61.  
  62. procedure button(bx,by : integer);
  63.  
  64. begin
  65.  
  66.   bx := mapx + (bx*10);
  67.  
  68.   by := mapy + (by*10);
  69.  
  70.   setfillstyle(1,7);
  71.  
  72.   bar(bx,by,bx+9,by+9);
  73.  
  74.   setcolor(15);
  75.  
  76.   line(bx,by,bx+9,by);
  77.  
  78.   line(bx+9,by+1,bx+9,by+8);
  79.  
  80.   setcolor(8);
  81.  
  82.   line(bx,by+1,bx,by+9);
  83.  
  84.   line(bx+1,by+9,bx+9,by+9);
  85.  
  86. end;
  87.  
  88.  
  89. { ----- procedure for drawing exposed buttons (tiles) ----- }
  90.  
  91.  
  92. procedure tile(tx,ty : integer);
  93.  
  94. var
  95.  
  96.   loc,lx,ly : integer;
  97.  
  98. begin
  99.  
  100.   loc := map[tx][ty];
  101.  
  102.   lx := mapx + (tx*10);
  103.  
  104.   ly := mapy + (ty*10);
  105.  
  106.   setfillstyle(1,7);
  107.  
  108.   bar(lx,ly,lx+9,ly+9);
  109.  
  110.   setcolor(8);
  111.  
  112.   line(lx,ly,lx+9,ly);
  113.  
  114.   line(lx,ly,lx,ly+9);
  115.  
  116.   if (tag[tx][ty] = 2) and (loc < 9) then   { you blew it! }
  117.  
  118.     begin
  119.  
  120.       setcolor(0);
  121.  
  122.       outtextxy(lx+2,ly+2,'*');
  123.  
  124.       setcolor(12);
  125.  
  126.       outtextxy(lx+2,ly+2,'/');
  127.  
  128.     end
  129.  
  130.   else
  131.  
  132.       case loc of
  133.  
  134.         0:
  135.  
  136.           begin
  137.  
  138.             setcolor(4);
  139.  
  140.             outtextxy(lx+2,ly+2,'·');
  141.  
  142.           end;
  143.  
  144.         1..8:
  145.  
  146.           begin
  147.  
  148.             setcolor(4);
  149.  
  150.             str(loc,s);
  151.  
  152.             outtextxy(lx+2,ly+2,s);
  153.  
  154.           end;
  155.  
  156.         9:
  157.  
  158.           begin
  159.  
  160.             setcolor(0);
  161.  
  162.             outtextxy(lx+2,ly+2,'*');
  163.  
  164.           end;
  165.  
  166.       end;
  167.  
  168. end;
  169.  
  170.  
  171. { ----- procedure for a recursive search of the playing field ----- }
  172.  
  173.  
  174. procedure search(sx,sy : integer);
  175.  
  176. begin
  177.  
  178.   e := 0;
  179.  
  180.   if (sx < 0) or (sy < 0) then e := 1;
  181.  
  182.   if (sx = col) or (sy = row) then e := 1;
  183.  
  184.   if e = 0 then
  185.  
  186.     begin
  187.  
  188.       if tag[sx][sy] = 0 then
  189.  
  190.         begin
  191.  
  192.           tag[sx][sy] := 1;
  193.  
  194.           tile(sx,sy);
  195.  
  196.           if map[sx][sy] = 0 then
  197.  
  198.             begin
  199.  
  200.               search(sx-1,sy);
  201.  
  202.               search(sx+1,sy);
  203.  
  204.               search(sx,sy-1);
  205.  
  206.               search(sx,sy+1);
  207.  
  208.               search(sx-1,sy-1);
  209.  
  210.               search(sx+1,sy-1);
  211.  
  212.               search(sx-1,sy+1);
  213.  
  214.               search(sx+1,sy+1);
  215.  
  216.             end;
  217.  
  218.         end; { if location is untagged }
  219.  
  220.     end;     { if coordinates are valid }
  221.  
  222. end;         { end procedure search }
  223.  
  224.  
  225. { ----- begining of main procedure ----- }
  226.  
  227.  
  228. begin
  229.  
  230.   { seed random number generator  and clear screen }
  231.  
  232.   Randomize;
  233.  
  234.   ClrScr;
  235.  
  236.   { register graphics driver }
  237.  
  238.   if RegisterBGIdriver(@EGAVGADriverProc) < 0 then halt(3);
  239.  
  240.   GraphDriver := VGA; GraphMode := 0; InitGraph(GraphDriver,GraphMode,'');
  241.  
  242.   { say, setting graphmode to 2 doubles your screen height }
  243.  
  244.   ErrorCode:=GraphResult;
  245.  
  246.   if ErrorCode <> grOK then
  247.  
  248.     begin
  249.  
  250.         WriteLn('Unknown graphics mode.');
  251.  
  252.         Halt(1);
  253.  
  254.     end;
  255.  
  256.   { call interrupt 033h with a zero and check for a mouse driver }
  257.  
  258.   regs.AX := 0; intr(51,regs);
  259.  
  260.   if regs.AX = 0 then
  261.  
  262.     begin
  263.  
  264.         closegraph;
  265.  
  266.         writeln('Mouse driver not detected.');
  267.  
  268.         Halt(2);
  269.  
  270.     end;
  271.  
  272.   size := imagesize(300,90,320,110);
  273.  
  274.   getmem(bang,size);
  275.  
  276.   setcolor(7);
  277.  
  278.   line(310,97,310,103);
  279.  
  280.   line(305,100,315,100);
  281.  
  282.   getimage(300,90,320,110,bang^);
  283.  
  284.   putimage(300,90,bang^,1);
  285.  
  286.   setvisualpage(1);
  287.  
  288.   setactivepage(1);
  289.  
  290.   setfillstyle(1,0); bar(0,0,639,199); { clear spare page }
  291.  
  292.   setvisualpage(0);
  293.  
  294.   setactivepage(0);
  295.  
  296.   setfillstyle(1,1); bar(0,0,639,199); { clear screen to blue and draw playing grid }
  297.  
  298.   if paramcount > 0 then outtextxy(300,2,paramstr(1));
  299.  
  300.   setfillstyle(1,2); bar(538,  8,639, 32); setcolor(15); outtextxy(540,10,'New');
  301.  
  302.   setfillstyle(1,3); bar(538, 38,639, 62); setcolor(15); outtextxy(540,40,'Beginner');
  303.  
  304.   setfillstyle(1,4); bar(538, 68,639, 92); setcolor(15); outtextxy(540,70,'Intermediate');
  305.  
  306.   setfillstyle(1,5); bar(538, 98,639,122); setcolor(15); outtextxy(540,100,'Expert');
  307.  
  308.   setfillstyle(1,6); bar(538,128,639,152); setcolor(15); outtextxy(540,130,'Custom');
  309.  
  310.   setfillstyle(1,8); bar(538,178,639,199); setcolor(15); outtextxy(540,180,'Quit?');
  311.  
  312.   { initialize global values, arrays and graphics }
  313.  
  314.   idle1 := 0;    { left button idle time counter }
  315.  
  316.   idle2 := 0;    { right button idle time counter }
  317.  
  318.   mines := 10;   { initial number of mines }
  319.  
  320.   row   := 10;   { starting grid size }
  321.  
  322.   col   := 10;
  323.  
  324. repeat { this is the main loop }
  325.  
  326.   runid  := 0;    { runid 0 = play, 1 = quit, 2 = win, 3 = restart }
  327.  
  328.   mapx  := trunc((50 - col)/2)*10 + 10; { starting grid offsets }
  329.  
  330.   mapy  := trunc((18 - row)/2)*10 + 10;
  331.  
  332.   for a := 0 to (col-1) do
  333.  
  334.     for b := 0 to (row-1) do
  335.  
  336.       map[a][b] := 0;        { clear map of random data }
  337.  
  338.   for a := 0 to (col-1) do
  339.  
  340.     for b := 0 to (row-1) do
  341.  
  342.       tag[a][b] := 0;        { array used to determine end }
  343.  
  344.   for count := 1 to mines do { place mines on map, allow no overlaps }
  345.  
  346.     begin
  347.  
  348.       b := 0;
  349.  
  350.       repeat
  351.  
  352.         x := random(col);
  353.  
  354.         y := random(row);
  355.  
  356.         if map[x][y] = 9 then
  357.  
  358.           b := 0
  359.  
  360.         else
  361.  
  362.           b := 1;
  363.  
  364.         map[x][y] := 9;
  365.  
  366.       until b = 1;
  367.  
  368.       for c := -1 to 1 do
  369.  
  370.         for d := -1 to 1 do
  371.  
  372.           begin
  373.  
  374.             a := x + c;
  375.  
  376.             b := y + d;
  377.  
  378.             e := 0;
  379.  
  380.             if (c = 0) and (d = 0) then e := 1;
  381.  
  382.             if (a < 0) or  (b < 0) then e := 1;
  383.  
  384.             if (a = col) or  (b = row) then e := 1;
  385.  
  386.             if (e = 0) and (map[a][b] < 9) then map[a][b] := map[a][b] +1;
  387.  
  388.           end;
  389.  
  390.     end; { end of mine creation routine }
  391.  
  392.   setfillstyle(1,1); bar(0,0,537,199); { clear screen to blue }
  393.  
  394.   for a := 0 to (col-1) do
  395.  
  396.     for b := 0 to (row-1) do
  397.  
  398.       button(a,b);
  399.  
  400.   e := 0;
  401.  
  402.   repeat
  403.  
  404.     goodx := random(col);
  405.  
  406.     goody := random(row);
  407.  
  408.     if map[goodx][goody] = 0 then e := 1;
  409.  
  410.   until e = 1;
  411.  
  412.   tile(goodx,goody);
  413.  
  414.   regs.AX:=3; intr(51,regs);      { ask driver for mouse status }
  415.  
  416.   xx := regs.CX;                  { copy to working variables & check }
  417.  
  418.   yy := regs.DX;                  { for a change in mouse variables }
  419.  
  420.   if xx < 10 then xx := 10;
  421.  
  422.   if yy < 10 then yy := 10;
  423.  
  424.   if xx > 629 then xx := 629;
  425.  
  426.   if yy > 189 then yy := 189;
  427.  
  428.   putimage(xx-10,yy-10,bang^,1);
  429.  
  430.   old.bx := regs.bx;              { draw cursor and save registers }
  431.  
  432.   oldxx  := xx;
  433.  
  434.   oldyy  := yy;
  435.  
  436.   score := 0;                     { reset score }
  437.  
  438.   flags := 0;
  439.  
  440.   repeat { iterative loop for user input }
  441.  
  442.     regs.AX := 3; intr(51,regs);    { ask driver for mouse status }
  443.  
  444.     xx := regs.CX;                  { copy to working variables & check }
  445.  
  446.     yy := regs.DX;                  { for a change in mouse variables }
  447.  
  448.     if xx < 10 then xx := 10;
  449.  
  450.     if yy < 10 then yy := 10;
  451.  
  452.     if xx > 629 then xx := 629;
  453.  
  454.     if yy > 189 then yy := 189;
  455.  
  456.     if idle1 > 0 then idle1 := idle1 -1;
  457.  
  458.     if idle2 > 0 then idle2 := idle1 -1;
  459.  
  460.     if (old.bx <> regs.bx) or (oldxx <> xx) or (oldyy <> yy) then
  461.  
  462.       begin
  463.  
  464.         putimage(oldxx-10,oldyy-10,bang^,1);  { erase cursor }
  465.  
  466.         old.bx := regs.bx;                      { save registers }
  467.  
  468.         oldxx  := xx;
  469.  
  470.         oldyy  := yy;
  471.  
  472.         putimage(xx-10,yy-10,bang^,1);          { draw new cursor }
  473.  
  474.         if ((xx mod 10)>0)and((yy mod 10)>0)and(xx>mapx)and(xx<(mapx+(col*10)))and(yy>mapy)and(yy<(mapy+(row*10))) then
  475.  
  476.           begin
  477.  
  478.             x := trunc(int((xx-mapx) / 10));
  479.  
  480.             y := trunc(int((yy-mapy) / 10));
  481.  
  482.           end  { test for vaild locations }
  483.  
  484.         else
  485.  
  486.           begin
  487.  
  488.             x := -1;
  489.  
  490.             y := -1;
  491.  
  492.           end; { flag bad locations }
  493.  
  494.         if (regs.BX = 1) and (xx>537) and (idle1 < 1) then
  495.  
  496.           begin
  497.  
  498.             idle1 := 5;
  499.  
  500.              case yy of
  501.  
  502.                8 .. 32:
  503.  
  504.                  begin
  505.  
  506.                  c := col; d := row; runid := 3;
  507.  
  508.                  end;
  509.  
  510.                38 .. 62:
  511.  
  512.                  begin
  513.  
  514.                  c := col; d := row; row := 10; col := 10; mines := 10; runid := 3;
  515.  
  516.                  end;
  517.                68 .. 92:
  518.  
  519.                  begin
  520.  
  521.                  c := col; d := row; row := 16; col := 16; mines := 40; runid := 3;
  522.  
  523.                  end;
  524.  
  525.                98 ..122:
  526.  
  527.                  begin
  528.  
  529.                  c := col; d := row; row := 16; col := 30; mines := 99; runid := 3;
  530.  
  531.                  end;
  532.  
  533.                128 ..152:
  534.  
  535.                  begin
  536.  
  537.                  c := col; d := row; runid := 4;
  538.  
  539.                  end;
  540.  
  541.                178 ..199:
  542.  
  543.                  begin
  544.  
  545.                  runid := 1; c := col; d := row;
  546.  
  547.                  end;
  548.  
  549.              end; { end of case }
  550.  
  551.            end;   { end of if button one }
  552.  
  553.         if (regs.BX = 1) and (((x+1)*(y+1)) > 0) and (idle1 < 1) then
  554.  
  555.           begin
  556.  
  557.             idle1 := 5;
  558.  
  559.             putimage(xx-10,yy-10,bang^,1);
  560.  
  561.             case map[x][y] of
  562.  
  563.               0:
  564.  
  565.                 begin
  566.  
  567.                 if tag[x][y] = 0 then
  568.  
  569.                   begin
  570.  
  571.                     setcolor(4);
  572.  
  573.                     setfillstyle(1,3);
  574.  
  575.                     search(x,y);
  576.  
  577.                     score := 0;
  578.  
  579.                     for a := 0 to (col-1) do
  580.  
  581.                       for b := 0 to (row-1) do
  582.  
  583.                         if tag[a][b] = 1 then score := score + tag[a][b];
  584.  
  585.                    setfillstyle(1,1);
  586.  
  587.                    bar(0,0,50,12);
  588.  
  589.                    setcolor(15);
  590.  
  591.                    str(score,s);
  592.  
  593.                    outtextxy(2,2,s);
  594.  
  595.                    if score + mines = (row * col) then
  596.  
  597.                       begin
  598.  
  599.                         runid := 2;
  600.  
  601.                         c := col;
  602.  
  603.                         d := row;
  604.  
  605.                       end; { end test for end-runid }
  606.  
  607.                   end;     { end test for tagged locations }
  608.  
  609.                 end;
  610.  
  611.               9:
  612.  
  613.                 begin
  614.  
  615.                 if tag[x][y] = 0 then
  616.  
  617.                   begin
  618.  
  619.                     setcolor(13);
  620.  
  621.                     setRGBpalette(1,254,254,254);
  622.  
  623.                     delay(5);
  624.  
  625.                     outtextxy(20,182,'BANG!  You are dead.');
  626.  
  627.                     delay(5);
  628.  
  629.                     SetRGBPalette(1,0,0,48);
  630.  
  631.                     setfillstyle(1,1);
  632.  
  633.                     bar(20,182,500,192);
  634.  
  635.                     c := col;
  636.  
  637.                     d := row;
  638.  
  639.                     runid := 1;
  640.  
  641.                   end; { end test for tagged location }
  642.  
  643.                 end;
  644.  
  645.               else { else case! }
  646.  
  647.                 begin
  648.  
  649.                 if tag[x][y] = 0 then
  650.  
  651.                   begin
  652.  
  653.                     tile(x,y);
  654.  
  655.                     tag[x][y] := 1;
  656.  
  657.                     score := score + 1;
  658.  
  659.                     setfillstyle(1,1);
  660.  
  661.                     bar(0,0,50,12);
  662.  
  663.                     setcolor(15);
  664.  
  665.                     str(score,s);
  666.  
  667.                     outtextxy(2,2,s);
  668.  
  669.                     if score + mines = (row * col) then
  670.  
  671.                       begin
  672.  
  673.                       runid := 2;
  674.  
  675.                       c := col;
  676.  
  677.                       d := row;
  678.  
  679.                       end;
  680.  
  681.                   end; { test tagged location }
  682.  
  683.                 end;  { end of the case's else statement }
  684.  
  685.             end; { end of the case }
  686.  
  687.             putimage(xx-10,yy-10,bang^,1);
  688.  
  689.           end; { end of select location if statement }
  690.  
  691.           if (regs.BX = 2) and (((x+1)*(y+1)) > 0) and (idle2 < 1) then
  692.  
  693.             begin
  694.  
  695.               idle2 := 15;
  696.  
  697.               putimage(xx-10,yy-10,bang^,1);
  698.  
  699.               case tag[x][y] of
  700.  
  701.                 0:
  702.  
  703.                   begin
  704.  
  705.                     tag[x][y] := 2;
  706.  
  707.                     setcolor(0);
  708.  
  709.                     outtextxy((x*10)+mapx+2,(y*10)+mapy+2,'*');
  710.  
  711.                     flags := flags + 1;
  712.  
  713.                     setfillstyle(1,1);
  714.  
  715.                     bar(50,0,80,12);
  716.  
  717.                     setcolor(15);
  718.  
  719.                     str(flags,s);
  720.  
  721.                     outtextxy(52,2,s);
  722.  
  723.                   end;
  724.  
  725.                 2:
  726.  
  727.                   begin
  728.  
  729.                     tag[x][y] := 0;
  730.  
  731.                     flags := flags - 1;
  732.  
  733.                     setfillstyle(1,1);
  734.  
  735.                     bar(50,0,80,12);
  736.  
  737.                     setcolor(15);
  738.  
  739.                     str(flags,s);
  740.  
  741.                     outtextxy(52,2,s);
  742.  
  743.                     button(x,y);
  744.  
  745.                   end;
  746.  
  747.               end;  { end of case }
  748.  
  749.               putimage(xx-10,yy-10,bang^,1);
  750.  
  751.             end; { end of button 2 testing }
  752.  
  753.         end; { end of if mouse is active statement }
  754.  
  755.         if keypressed then
  756.  
  757.           begin
  758.  
  759.             e := 0;
  760.  
  761.             s := readkey;
  762.  
  763.             setvisualpage(2);
  764.  
  765.             s := readkey;
  766.  
  767.             if s = chr(27) then
  768.  
  769.               begin
  770.  
  771.                 closegraph;
  772.  
  773.                 halt(1);
  774.  
  775.               end;
  776.  
  777.             setvisualpage(0);
  778.  
  779.  
  780.           end;
  781.  
  782.     until (runid > 0); { end iterative play loop }
  783.  
  784. { clean-up and end-runid options }
  785.  
  786.   putimage(xx-10,yy-10,bang^,1);
  787.  
  788.   setfillstyle(1,3);
  789.  
  790.   for a := 0 to (c-1) do
  791.  
  792.     for b := 0 to (d-1) do
  793.  
  794.       tile(a,b);
  795.  
  796.   if runid = 2 then
  797.  
  798.     begin
  799.  
  800.       setcolor(11);
  801.  
  802.       outtextxy(20,180,'Congrats, you win.');
  803.  
  804.       for a := 1 to 16 do
  805.  
  806.         begin
  807.  
  808.           setRGBpalette(1,random(256),random(256),random(256));
  809.  
  810.           delay(60);
  811.  
  812.         end;
  813.  
  814.       SetRGBpalette(1,0,0,48);
  815.  
  816.     end;
  817.  
  818.   if runid <> 3 then
  819.  
  820.     begin
  821.  
  822.       if runid = 4 then
  823.  
  824.           begin
  825.  
  826.             setcolor(15);
  827.  
  828.             setfillstyle(1,1);
  829.  
  830.             bar(200,70,390,144);
  831.  
  832.             line(200,70,390,70);
  833.  
  834.             line(390,70,390,144);
  835.  
  836.             line(390,144,200,144);
  837.  
  838.             line(200,144,200,70);
  839.  
  840.             for a := 0 to 2 do
  841.  
  842.               begin
  843.  
  844.                 setfillstyle(1,a+2); bar(368,74+(a*24),378,82+(a*24));
  845.  
  846.                 setfillstyle(1,a+2); bar(368,84+(a*24),378,92+(a*24));
  847.  
  848.               end;
  849.  
  850.             outtextxy(210, 80,'Col   [1..50]');
  851.  
  852.             outtextxy(210,103,'Rows  [1..16]');
  853.  
  854.             outtextxy(210,127,'Mines [1..');
  855.  
  856.             str((row*col),s);
  857.  
  858.             outtextxy(290,127,s+']');
  859.  
  860.             for a := 0 to 2 do outtextxy(370,75+(a*24),'>');
  861.  
  862.             for a := 0 to 2 do outtextxy(370,85+(a*24),'<');
  863.  
  864.             setfillstyle(1,1);
  865.  
  866.             str(col,s); outtextxy(335,80,s);
  867.  
  868.             str(row,s); outtextxy(335,103,s);
  869.  
  870.             str(mines,s); outtextxy(335,127,s);
  871.  
  872.           end
  873.  
  874.         else
  875.  
  876.           delay(500);
  877.  
  878.         putimage(xx-10,yy-10,bang^,1);
  879.  
  880.         repeat
  881.  
  882.           regs.AX:=3;
  883.  
  884.           intr(51,regs);
  885.  
  886.           xx := regs.CX;
  887.  
  888.           yy := regs.DX;
  889.  
  890.           if xx < 10 then xx := 10;
  891.  
  892.           if yy < 10 then yy := 10;
  893.  
  894.           if xx > 629 then xx := 629;
  895.  
  896.           if yy > 189 then yy := 189;
  897.  
  898.           if (old.bx <> regs.bx)or(oldxx <> regs.cx)or(oldyy <> regs.dx) then
  899.  
  900.             begin
  901.  
  902.               putimage(oldxx-10,oldyy-10,bang^,1);
  903.  
  904.               old.bx := regs.bx;
  905.  
  906.               oldxx  := xx;
  907.  
  908.               oldyy  := yy;
  909.  
  910.               putimage(xx-10,yy-10,bang^,1);
  911.  
  912.             end;
  913.  
  914.           if (regs.BX = 1) and (runid = 4) then
  915.  
  916.             case yy of
  917.  
  918.               74.. 82:
  919.  
  920.                 if (xx > 367) and (xx < 379) then
  921.  
  922.                   begin
  923.  
  924.                   regs.BX := 0;
  925.  
  926.                   col := col +1;
  927.  
  928.                   if col > 50 then col := 50;
  929.  
  930.                   bar(335,80,365,90);
  931.  
  932.                   str(col,s); outtextxy(335,80,s);
  933.  
  934.                   bar(290,127,330,137);
  935.  
  936.                   str((row*col),s); outtextxy(290,127,s+']');
  937.  
  938.                   delay(100);
  939.  
  940.                   end;
  941.  
  942.               84.. 92:
  943.  
  944.                 if (xx > 367) and (xx < 379) then
  945.  
  946.                   begin
  947.  
  948.                   regs.BX := 0;
  949.  
  950.                   col := col -1;
  951.  
  952.                   if col < 1 then col := 1;
  953.  
  954.                   bar(335,80,365,90);
  955.  
  956.                   str(col,s);
  957.  
  958.                   outtextxy(335,80,s);
  959.  
  960.                   bar(290,127,330,137);
  961.  
  962.                   str((row*col),s);
  963.  
  964.                   outtextxy(290,127,s+']');
  965.  
  966.                   delay(100);
  967.  
  968.                   end;
  969.  
  970.               98..106:
  971.  
  972.                 if (xx > 367) and (xx < 379) then
  973.  
  974.                   begin
  975.  
  976.                   regs.BX := 0;
  977.  
  978.                   row := row +1;
  979.  
  980.                   if row > 16 then row := 16;
  981.  
  982.                   bar(335,103,365,113);
  983.  
  984.                   str(row,s);
  985.  
  986.                   outtextxy(335,103,s);
  987.  
  988.                   bar(290,127,330,137);
  989.  
  990.                   str((row*col),s);
  991.  
  992.                   outtextxy(290,127,s+']');
  993.  
  994.                   delay(100);
  995.  
  996.                   end;
  997.  
  998.               108..116:
  999.  
  1000.                 if (xx > 367) and (xx < 379) then
  1001.  
  1002.                   begin
  1003.  
  1004.                   regs.BX := 0;
  1005.  
  1006.                   row := row -1;
  1007.  
  1008.                   if row < 1 then row := 1;
  1009.  
  1010.                   bar(335,103,365,113);
  1011.  
  1012.                   str(row,s);
  1013.  
  1014.                   outtextxy(335,103,s);
  1015.  
  1016.                   bar(290,127,330,137);
  1017.  
  1018.                   str((row*col),s);
  1019.  
  1020.                   outtextxy(290,127,s+']');
  1021.  
  1022.                   delay(100);
  1023.  
  1024.                   end;
  1025.  
  1026.               122..130:
  1027.  
  1028.                 if (xx > 367) and (xx < 379) then
  1029.  
  1030.                   begin
  1031.  
  1032.                   regs.BX := 0;
  1033.  
  1034.                   mines := mines +1;
  1035.  
  1036.                   if mines > (row*col) then mines := (row*col);
  1037.  
  1038.                   bar(335,127,365,137);
  1039.  
  1040.                   str(mines,s);
  1041.  
  1042.                   outtextxy(335,127,s);
  1043.  
  1044.                   delay(50);
  1045.  
  1046.                   end;
  1047.  
  1048.               132..140:
  1049.  
  1050.                 if (xx > 367) and (xx < 379) then
  1051.  
  1052.                   begin
  1053.  
  1054.                   regs.BX := 0;
  1055.  
  1056.                   mines := mines -1;
  1057.  
  1058.                   if mines < 1 then mines := 1;
  1059.  
  1060.                   bar(335,127,365,137);
  1061.  
  1062.                   str(mines,s);
  1063.  
  1064.                   outtextxy(335,127,s);
  1065.  
  1066.                   delay(50);
  1067.  
  1068.                   end;
  1069.  
  1070.             end;
  1071.  
  1072.           if (regs.BX = 1) and (xx>537) then
  1073.  
  1074.             begin
  1075.  
  1076.               idle1 := 5;
  1077.  
  1078.                case yy of
  1079.  
  1080.                  8 .. 32:
  1081.  
  1082.                    begin
  1083.  
  1084.                    c := col; d := row; runid := 3;
  1085.  
  1086.                    end;
  1087.  
  1088.                  38 .. 62:
  1089.  
  1090.                    begin
  1091.  
  1092.                    c := col; d := row; row := 10; col := 10; mines := 10; runid := 3;
  1093.  
  1094.                    end;
  1095.  
  1096.                  68 .. 92:
  1097.  
  1098.                    begin
  1099.  
  1100.                    c := col; d := row; row := 16; col := 16; mines := 40; runid := 3;
  1101.  
  1102.                    end;
  1103.  
  1104.                  98 ..122:
  1105.  
  1106.                    begin
  1107.  
  1108.                    c := col; d := row; row := 16; col := 30; mines := 99; runid := 3;
  1109.  
  1110.                    end;
  1111.  
  1112.                  128 ..152:
  1113.  
  1114.                    begin
  1115.  
  1116.                    c := col; d := row; regs.BX := 0;  runid := 4;
  1117.  
  1118.                    setcolor(15);
  1119.  
  1120.                    setfillstyle(1,1);
  1121.  
  1122.                    bar(200,70,390,144);
  1123.  
  1124.                    line(200,70,390,70);
  1125.  
  1126.                    line(390,70,390,144);
  1127.  
  1128.                    line(390,144,200,144);
  1129.  
  1130.                    line(200,144,200,70);
  1131.  
  1132.                    for a := 0 to 2 do
  1133.  
  1134.                      begin
  1135.  
  1136.                        setfillstyle(1,a+2); bar(368,74+(a*24),378,82+(a*24));
  1137.  
  1138.                        setfillstyle(1,a+2); bar(368,84+(a*24),378,92+(a*24));
  1139.  
  1140.                      end;
  1141.  
  1142.                    outtextxy(210, 80,'Col   [1..50]');
  1143.  
  1144.                    outtextxy(210,103,'Rows  [1..16]');
  1145.  
  1146.                    outtextxy(210,127,'Mines [1..');
  1147.  
  1148.                    str((row*col),s);
  1149.  
  1150.                    outtextxy(290,127,s+']');
  1151.  
  1152.                    for a := 0 to 2 do outtextxy(370,75+(a*24),'>');
  1153.  
  1154.                    for a := 0 to 2 do outtextxy(370,85+(a*24),'<');
  1155.  
  1156.                    setfillstyle(1,1);
  1157.  
  1158.                    str(col,s); outtextxy(335,80,s);
  1159.  
  1160.                    str(row,s); outtextxy(335,103,s);
  1161.  
  1162.                    str(mines,s); outtextxy(335,127,s);
  1163.  
  1164.                    end;
  1165.  
  1166.                  178 ..199:
  1167.  
  1168.                    begin
  1169.  
  1170.                    runid := 1; c := col; d := row;
  1171.  
  1172.                    end;
  1173.  
  1174.                end;
  1175.  
  1176.              end;
  1177.  
  1178.         if keypressed then
  1179.  
  1180.           begin
  1181.  
  1182.             e := 0;
  1183.  
  1184.             s := readkey;
  1185.  
  1186.             setvisualpage(1);
  1187.  
  1188.             s := readkey;
  1189.  
  1190.             if s = chr(27) then
  1191.  
  1192.               begin
  1193.  
  1194.                 closegraph;
  1195.  
  1196.                 halt(1);
  1197.  
  1198.               end;
  1199.  
  1200.             setvisualpage(0);
  1201.  
  1202.           end;
  1203.  
  1204.         until (regs.bx > 0);
  1205.  
  1206.         if runid <> 1 then
  1207.  
  1208.             runid := 0;
  1209.  
  1210.         putimage(xx-10,yy-10,bang^,1);
  1211.  
  1212.       end;
  1213.  
  1214.   if mines > (row*col) then mines := (row*col);
  1215.  
  1216.   setfillstyle(1,1);
  1217.  
  1218.   bar(0,0,510,199);
  1219.  
  1220. until (runid = 1);
  1221.  
  1222. closegraph;
  1223.  
  1224. end.
  1225.  
  1226.