home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PINBSRC.ZIP / FLIPPER2.PAS < prev    next >
Pascal/Delphi Source File  |  1996-02-02  |  37KB  |  1,156 lines

  1. { FLIPPER2.PAS   - (c) Ansgar Scherp, Joachim Gelhaus
  2.   All rights reserved / vt'95
  3.  
  4.   1 Parameter = as FLIPPER1.PAS
  5.  
  6.   }
  7.  
  8. {$M 65520,0,655360}
  9. {$P+,G+}
  10. uses dos,crt,soundkit,audiotpu;
  11.  
  12. const N1 = ' PCS-PINBALL  - Version 1.1 written by A.Scherp and J.Gelhaus ';
  13.       N2 = ' (c)opyrights reserved by PC Spiel and vIRTUAL tECHNOLOGIES GbR';
  14.  
  15. const
  16.       Bits       : array[0..9] of byte = (128,64,32,16,8,4,2,1,0,0);
  17.       VSeg       : word = $A000;
  18.       speedmaxy  : byte = 100;
  19.  
  20.       tnr  : char = '2';
  21.  
  22.       ArmBreiteLinks : byte = 56;
  23.       ArmHoeheLinks  : byte = 48;
  24.       ArmXLinks      : word = 79+5;
  25.       ArmYLinks      : word = 400+135+14;
  26.  
  27.       ArmBreiteRechts : byte = 56;
  28.       ArmHoeheRechts  : byte = 48;
  29.       ArmXRechts      : word = 159-4;
  30.       ArmYRechts      : word = 400+135+14;
  31.  
  32.       FederBreite     : word = 8;
  33.       FederX          : word = 302;
  34.  
  35.       no         : boolean = false;
  36.       yes        : boolean = true;
  37.       rahmen     : byte = 255;
  38.       arm        : byte = 128;
  39.  
  40. const snd1 = 1;
  41.       snd2 = 2;
  42.       snd3 = 3;
  43.       snd4 = 4;
  44.       snd5 = 5;
  45.       snd6 = 6;
  46.       snd7 = 7;
  47.       snd8 = 8;
  48.       snd9 = 9;
  49.       snd10 = 10;
  50.       snd11 = 11;
  51.       snd12 = 12;
  52.       snd13 = 13;
  53.       snd14 = 14;
  54.  
  55.       SetSprite_VGAADR : array[0..6] of word = (258,514,1026,2050,258,514,1026);
  56.       GetSprite_VGAADR : array[0..6] of word = ($4,$104,$204,$304,$04,$104,$204);
  57.  
  58.       MaxBalls = 4;
  59.  
  60.  
  61. {*** TYPE ******************************************************************}
  62.  
  63. type ttableground1=array[0..319,0..199] of byte;
  64. type ttableground2=array[0..319,200..399] of byte;
  65. type ttableground3=array[0..319,400..599] of byte;
  66. type reihe = array[1..15360] of byte;
  67.  
  68.  
  69.  
  70. var  OldHeapLimit: pointer;
  71.      OldHeapSize : Longint;
  72.  
  73.      ledseg,
  74.      armlinksseg,armrechtsseg,
  75.      armlinks_mskseg,armrechts_mskseg,
  76.      ballseg,
  77.      groundseg,
  78.      ballspriteseg,
  79.      undergroundseg,
  80.      tablegroundseg,federseg:word;
  81.  
  82.      led_display,
  83.      ball,
  84.      ground,
  85.      ball_sprite,
  86.      underground,
  87.      tableground,feder:pointer;
  88.      arm_links           : ^reihe;
  89.      arm_rechts          : ^reihe;
  90.  
  91.      arm_links_msk       : ^reihe;
  92.      arm_rechts_msk      : ^reihe;
  93.  
  94.  
  95.      tableground1:^ttableground1;
  96.      tableground2:^ttableground2;
  97.      tableground3:^ttableground3;
  98.  
  99.      ch:char;
  100.  
  101.      led_hoehe:byte;
  102.      led_color_1, led_color_2:byte;
  103.      led_funktion, led_parameter,led_timer,led_x,led_Y,led_status:word;
  104.      led_anzeige_text:string;
  105.      led_f_status_1,led_f_status_2:byte;
  106.  
  107.      Fseg,Fofs : word;
  108.  
  109.      Fdata : array[1..4096] of byte;
  110.  
  111.      arm_links_status, arm_rechts_status:byte;
  112.      arm_links_old_status, arm_rechts_old_status:byte;
  113.  
  114.  
  115.      ballx,bally,bx_old,by_old:integer;
  116.  
  117.      ballspeed_y,ballspeed_x:integer;
  118.  
  119.  
  120.      ran255:array[0..255] of byte;
  121.      ran255z:byte;
  122.  
  123.      l1,l2,r1,r2,u1,u2,o1,o2 : byte;
  124.  
  125.      fu,fo,fl,fr,fm : byte;
  126.      fh : byte;
  127.  
  128.      kraft : integer;
  129.  
  130.      overscan, highres : boolean;
  131.  
  132.      UseSound  : boolean;
  133.      sounds:array[1..14] of pointer;
  134.      soundlength:array[1..14] of word;
  135.  
  136.      score:array [1..6] of longint;
  137.  
  138.      StartPow  : word ;
  139.  
  140.      NormalPos : integer;
  141.      CurrentPos : integer;
  142.  
  143.      path : string;
  144.  
  145.      MAXfarbe: byte;
  146.  
  147.      OldFileMode : byte;
  148.  
  149.      VideoMode : char;
  150.  
  151.      bende  : boolean;
  152.  
  153.      pal : array[0..255] of record
  154.              r : byte;
  155.              g : byte;
  156.              b : byte;
  157.            end;
  158.  
  159.      ruetteln : byte;
  160.  
  161.      FederY : word;
  162.      FederHoehe : word;
  163.  
  164.      hilfsb:byte;
  165.  
  166.  
  167. {*** TABLE2 *************************************************************** }
  168.  
  169.      RAT : array[24..26] of byte; {R, A, T}
  170.      PHASER : array[233..238] of byte; {P, H, A, S, E, R}
  171.      RL : boolean; {RELAUNCH}
  172.      PFEIL : byte; {2x,4x,6x}
  173.      Felder1 : byte; {5k,3k,1k top left}
  174.      Felder2 : byte; {500,1000,1500}
  175.      Felder3 : byte; {10.000,20.000,30.000,50.000}
  176.      Locked : byte; { 0 - > no Ball locked // 1 - > Ball locked //
  177.                       2 - > locked ball already released!!! }
  178.      Counter : Byte;
  179.  
  180.      Balls    : array[1..6] of integer;
  181.      MaxPlayer   : byte;
  182.      ActPlayer : byte;
  183.  
  184. const TischGrad : byte = 2;
  185. var   grad : byte;
  186.  
  187. procedure calc_page_pos_of_ballpos; forward;
  188. procedure display(t : string); forward;
  189. procedure check_flipper_arms; forward;
  190. procedure analyse_arms; forward;
  191. procedure senk_arms; forward;
  192. procedure move_ball; forward;
  193. procedure IncScore(points:word); forward;
  194.  
  195.  
  196. {*** FONTS **************************************************************** }
  197. {$F+}
  198. procedure font; external;
  199. {$L FONTS\thin8X8.OBJ}
  200. {$F-}
  201.  
  202. {*** INCLUDEN ************************************************************* }
  203. {$I _RANDOM .PAS} {short random number list}
  204. {$I _VIDEO  .PAS} {all video functions // // and arm_draw}
  205. {$I _LOADPRC.PAS}
  206. {I _GRAPH  .PAS} {ball and ground draw routines Kann weg:-) }
  207. {$I _LEDANZ .PAS} {all routines for the led}
  208. {$I _AUTODRA.PAS} {procedure for automatic-draw // chose the right plane}
  209. {$I _KEYS   .PAS}
  210. {$I _SOUND2 .PAS} {soundkit}
  211. {$I _INI_CLO.PAS} {init_all & close}
  212. {I _INTEGRI.PAS} {check for integrity // read volumelabel of cd-rom}
  213. {$I _CDPLAYR.PAS} {audio-cd-player-routines}
  214. {$I _TISCH2 .PAS}
  215.  
  216. procedure senk_arms;
  217.   var t : byte;
  218. begin
  219.   for t := 5 downto 0 do begin
  220.        if arm_rechts_status>1 then dec(arm_rechts_status);
  221.        if arm_links_status>1 then dec(arm_links_status);
  222.        Check_Flipper_Arms;
  223.        arm_links_old_status:=arm_links_status;
  224.        arm_rechts_old_status:=arm_rechts_status;
  225.      end;
  226.   draw_ground_auto;
  227. end;
  228.  
  229. procedure move_left;
  230.   var alt : byte;
  231.       a : word;
  232. begin
  233.   alt := led_funktion;
  234.   led_anzeige_6_init;
  235.   for a := 0 to 80 do begin led_anzeige; retrace; end;
  236.   led_funktion := alt;
  237. end;
  238.  
  239. procedure IncScore(points:word);
  240. begin
  241.  score[actplayer] := score[actplayer] + points;
  242.  led_anzeige_5_init(0,0,'Score'+IntToStr1(score[actplayer])+
  243.                         ' Ball '+inttostr(balls[ActPlayer]));
  244. end;
  245.  
  246. procedure display(t : string);
  247.   var a : byte;
  248.       z : string[20];
  249. begin
  250.  z := '                     ';
  251.  for a := 1 to length(t) do z[a + 10 - length(t) div 2 ] := t[a];
  252.  led_anzeige_5_init(0,0,z);
  253. end;
  254.  
  255. procedure Check_Ball; forward;
  256.  
  257. procedure move_ball;
  258. begin
  259.   draw_ground_auto; get_ground_auto; draw_ball_auto;
  260.   bx_old:=ballx; by_old:=bally;
  261. end;
  262.  
  263. procedure calc_page_pos_of_ballpos;
  264. var y2:word; {longint;}
  265. begin
  266.   {y2:=bally-100;}
  267.   asm mov ax, bally; sub ax, 100; mov y2, ax; end;
  268. {  if y2<1 then y2:=1;} if y2 > 1000 then y2 := 1;
  269.   if y2>421 then y2:=421;
  270.   { y2:=y2+48;}
  271.   asm mov ax,y2; add ax,48; mov y2,ax; end;
  272.   if HighRes then if y2> 270 then y2 := 270;
  273.   {80*y2}
  274.   asm mov ax,y2; mov bx,80; mul bx; mov y2,ax; end;
  275.   setaddress(y2);
  276. end;
  277.  
  278. procedure Check_Flipper_Arms;
  279.  
  280. begin
  281.   {check if left flipper-arm is moved}
  282.   if arm_links_old_status<>arm_links_status then
  283.     if (bally+16>armYlinks) and (bally<armYlinks+armHoeheLinks) and
  284.        (ballx+16>armXlinks) and (ballx<armXlinks+armBreitelinks) then begin
  285.         draw_ground_auto;{}
  286.         draw_arm_links;
  287.         get_ground_auto;{}
  288.         draw_ball_auto;
  289.       end else draw_arm_links;
  290.   {check if right flipper-arm is moved}
  291. if (arm_rechts_old_status<>arm_rechts_status) then
  292.     if (bally+16>armYrechts) and (bally<armYrechts+armHoeherechts) and
  293.        (ballx+16>armXrechts) and (ballx<armXrechts+armBreiterechts) then begin
  294.         draw_ground_auto;
  295.         draw_arm_rechts;
  296.         get_ground_auto;
  297.         draw_ball_auto;
  298.       end else draw_arm_rechts;
  299. end;
  300.  
  301. procedure analyse_arms;
  302.  var w : byte;
  303. begin
  304.   if abs(ballspeed_x) > 4 then w := 0 else w := 3;
  305.  
  306.   if (fo > 0) and (ballspeed_y < 0) then begin
  307.       ballspeed_y := abs(ballspeed_y);
  308.       kraft := 0;
  309.       exit;
  310.     end;
  311.   if ballx < 142{152} then begin
  312.     if arm_links_old_status < arm_links_status then begin
  313.         draw_arm_links;
  314.         Check_Ball;
  315.         ballspeed_y := - abs(Ballx+4 - ArmXLinks);
  316.       if ballspeed_y < - 50 then ballspeed_y := -50;
  317.         bally := bally + ballspeed_y;
  318.         kraft := abs(ballspeed_y)-10;
  319.         case arm_links_status of
  320.           1 : inc(ballspeed_x,7+random(4)); {5/2}
  321.           2 : inc(ballspeed_x,5+random(4));
  322.           4 : dec(ballspeed_x,5+random(4));
  323.           5 : dec(ballspeed_x,7+random(4));
  324.         end;
  325.       end else begin
  326.         case arm_links_status of
  327.           1 : inc(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  328.           2 : inc(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  329.           4 : dec(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  330.           5 : dec(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  331.         end;
  332.         inc(ballspeed_y,2);
  333.       end;
  334.   end else
  335.     if arm_rechts_old_status < arm_rechts_status then begin
  336.         draw_arm_rechts;
  337.         Check_Ball;
  338.         kraft := 50;
  339.         ballspeed_y := - abs(ArmBreiteRechts - (Ballx+4{+8} - ArmXRechts));
  340.        if ballspeed_y < - 50 then ballspeed_y := -50;
  341.         bally := bally + ballspeed_y;
  342.         kraft := abs(ballspeed_y)-10;
  343.       case arm_rechts_status of
  344.         1 : dec(ballspeed_x,7+random(4));
  345.         2 : dec(ballspeed_x,5+random(4));
  346.         4 : inc(ballspeed_x,5+random(4));
  347.         5 : inc(ballspeed_x,7+random(4));
  348.       end;
  349.     end else begin
  350.         case arm_rechts_status of
  351.           1 : dec(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  352.           2 : dec(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  353.           4 : inc(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  354.           5 : inc(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  355.         end;
  356.         inc(ballspeed_y,2);
  357.       end;
  358.   fl := 0; fr := 0; fu := 0; fo := 0;
  359. end;
  360.  
  361. { *** EVENTS ***************************************************************}
  362.  
  363. procedure analyse_crash;
  364. var fg,a,b,c,d,w:byte;
  365. begin
  366.   if fr>0 then fg:=fr;
  367.   if fl>0 then fg:=fl;
  368.   if fo>0 then fg:=fo;
  369.   if fu>0 then fg:=fu;
  370.   case fg of
  371.     254 : begin
  372.             incscore(100);
  373.             if ballspeed_y > 0 then ballspeed_x := abs(ballspeed_y)
  374.                                else ballspeed_x := -abs(ballspeed_y);
  375.             if ballspeed_x > 0 then ballspeed_y := abs(ballspeed_x) div 2
  376.                                         + random(5)
  377.                                else ballspeed_y := -abs(ballspeed_x) div 2;
  378.             play(snd14);
  379.           end;
  380.      253 : begin
  381.           { ballspeed_x := ballspeed_x - 10;}
  382.             if abs(ballspeed_x) > 4 then w := 0 else w := 1;
  383.             dec(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  384.             inc(ballspeed_y,2);
  385.           end;
  386.     252 : begin
  387.            {ballspeed_x := ballspeed_x + 10;}
  388.             if abs(ballspeed_x) > 4 then w := 0 else w := 1;
  389.             inc(ballspeed_x,(abs(ballspeed_y)+w) div 4);
  390.             inc(ballspeed_y,2);
  391.           end;
  392.     250,251 : begin
  393.             if ballx < 160 then begin
  394.                 if RL then begin
  395.                     play(snd12);
  396.                     ballspeed_y := -30-random(15);
  397.                     inc(ballspeed_x,6);
  398.                     kraft := 100;
  399.                   end
  400.                end else if RL then begin
  401.                             play(snd12);
  402.                             ballspeed_y := -30-random(15);
  403.                             inc(ballspeed_x,4+random(3));
  404.                             kraft := 100;
  405.                           end;
  406.           end;
  407.     249 : begin
  408.             incscore(100);
  409.             if ballspeed_y < 0 then ballspeed_x := abs(ballspeed_y)
  410.                                else ballspeed_x := -abs(ballspeed_y);
  411.             if ballspeed_x < 0 then ballspeed_y := abs(ballspeed_x) div 2
  412.                                else ballspeed_y := -abs(ballspeed_x) div 2;
  413.             play(snd14);
  414.           end;
  415.     248 : begin
  416.             incscore(100);
  417.             ballspeed_y := ballspeed_y div 2;
  418.             dec(ballspeed_x,ballspeed_y);
  419.             play(snd1);
  420.           end;
  421.     247 : begin
  422.           play(snd4);
  423.           HilfsProc2;
  424.           counter := 10; set_rgb_color(247,60,30,20);
  425.           end;
  426.     246 : begin
  427.           play(snd4);
  428.           HilfsProc2;
  429.           counter := 10; set_rgb_color(246,60,30,20);
  430.           end;
  431.     245 : begin
  432.           play(snd4);
  433.           HilfsProc2;
  434.           counter := 10; set_rgb_color(245,60,30,20);
  435.           end;
  436.     244 : begin
  437.           play(snd4);
  438.           HilfsProc2;
  439.           counter := 10; set_rgb_color(244,60,30,20);
  440.           end;
  441.     243 : begin
  442.           incscore(50);
  443.           {if ballspeed_x < 0 then ballspeed_x := -15;
  444.           if ballspeed_x > 0 then ballspeed_x := 15;}
  445.           if ballspeed_x < 0 then ballspeed_x := -8-random(4);
  446.           if ballspeed_x > 0 then ballspeed_x := 8+random(4);
  447.           if ballspeed_y < 0 then ballspeed_y := -8-random(4);
  448.           if ballspeed_y > 0 then ballspeed_y := 8+random(4);
  449.           if ballx < 160 then begin
  450.               counter := 10; set_rgb_color(96,60,30,20); play(snd3);
  451.             end else begin
  452.               counter := 10; set_rgb_color(97,60,30,20); play(snd13);
  453.               end;
  454.        end;
  455.     242 : begin
  456.            display('>-BALL-<>-LOST-<');
  457.            play(snd9);
  458.            repeat led_anzeige; until led_status=0;
  459.            senk_arms;
  460.            asm cli end;
  461.            delay(1000);
  462.            move_left;
  463.            {LOCKED BALL RELEASEN WHEN EXISTANCE}
  464.            if locked = 1 then begin
  465.                display('RELEASE LOCKED BALL!');
  466.  
  467.                repeat led_anzeige; until led_status = 0;
  468.                draw_ground_auto;
  469.                delay(1000);
  470.                move_left;
  471.                init_ball_values;
  472.                for a := 99 to 101 do
  473.                    set_rgb_color(a,pal[a].r,pal[a].g,pal[a].b);
  474.                PFEIL := 0;
  475.                locked := 0;
  476.                exit;
  477.              end;
  478.  
  479.            {RAT-Bonus}
  480.            if (RAT[24] = 1) and (RAT[25] = 1) and (RAT[26] =1) then begin
  481.                 display('RAT-BONUS: 50000');
  482.                 repeat led_anzeige; until led_status = 0;
  483.                 delay(500);
  484.                 move_left;
  485.                 inc(score[actplayer],50000);
  486.               end;
  487.  
  488.            {phaser bonus}
  489.            if felder3 > 0 then begin
  490.                 display('PHASER - BONUS');
  491.                 repeat led_anzeige; until led_status=0;
  492.                 delay(1000);
  493.                 inc(score[actplayer],felder3*10000);
  494.                 display('< < < '+inttostr(felder3*10000)+' > > >');
  495.                 repeat led_anzeige; until led_status=0;
  496.                 delay(1000);
  497.                 move_left;
  498.               end;
  499.  
  500.            {Rampen-Bonus}
  501.            if felder1 > 0 then begin
  502.                display('RAMP-HIT : 25000');
  503.                inc(score[actplayer],25000);
  504.                repeat led_anzeige; until led_status=0;
  505.                delay(1000);
  506.                move_left;
  507.              end;
  508.  
  509.            {death-bonus}
  510.            if felder2 > 0 then begin
  511.                 display('DEATH BONUS '+inttostr(felder2*500)+'x5');
  512.                 repeat led_anzeige; until led_status=0;
  513.                 inc(score[actplayer],felder2*500*5);
  514.                 delay(1000);
  515.                 move_left;
  516.               end;
  517.  
  518.            {total}
  519.            display('Total '+inttostr(score[actplayer]));
  520.            repeat led_anzeige; until led_status = 0;
  521.            delay(1000);
  522.            move_left;
  523.  
  524.            inc(balls[Actplayer]);
  525.            if balls[actplayer] = MaxBalls then begin
  526.                  display('* G A M E  O V E R *');
  527.                  repeat led_anzeige; until led_status = 0;
  528.                  delay(1000);
  529.                  bende := true;
  530.                end;
  531.            inc(actplayer);
  532.            if actplayer > Maxplayer then actplayer := 1;
  533.            if balls[actplayer] < MaxBalls then
  534.              if MaxPlayer > 1 then
  535.               begin
  536.                 display('Next Player '+inttostr(actplayer));
  537.                 repeat led_anzeige; until led_status=0;
  538.                 delay(1000);
  539.                 move_left;
  540.                 display('Ball '+inttostr(balls[actplayer]));
  541.                 repeat led_anzeige; until led_status=0;
  542.                 delay(1000);
  543.                 move_left;
  544.                 bende := false;
  545.               end;
  546.            init_ball_values;
  547.            init_tisch2;
  548.            for a := 0 to 250 do begin
  549.                 CTRL_Shift_Keys;
  550.                 arm_links_old_status:=arm_links_status;
  551.                 arm_rechts_old_status:=arm_rechts_status;
  552.                 Check_Flipper_Arms;
  553.               end;
  554.             senk_arms;
  555.           end;
  556.  
  557.     241 : begin
  558.             dec(ballx,2); ballspeed_x := -1;
  559.             ballspeed_y := abs(ballspeed_y);
  560.           end;
  561.  
  562.     240 : begin
  563.             {if ballspeed_x < 4 then inc(ballspeed_x,3);}
  564.             ballspeed_x := 4;
  565.            { play(snd1);}
  566.             inc(ballx);
  567.             dec(ballspeed_y);
  568.           end;
  569.     233..238 : begin
  570.         if phaser[fg] = 0 then begin
  571.             play(snd11);
  572.             phaser[fg] := 1;
  573.             set_rgb_color(238-fg+109,50,30,20);
  574.             inc(ballspeed_x,20);
  575.             inc(score[actplayer],1000);
  576.  
  577.             if (phaser[233] = 1)and(phaser[234] = 1)and(phaser[235] = 1)and
  578.                (phaser[236] = 1)and(phaser[237] = 1)and(phaser[238] = 1)then
  579.                begin
  580.                 case Felder3 of
  581.                   0 : begin
  582.                         felder3 := 1;
  583.                         display('>>> 10000  BONUS <<<');
  584.                         repeat led_anzeige; until led_status = 0;
  585.                         inc(score[actplayer],10000);
  586.                         set_rgb_color(105,60,30,20);
  587.                       end;
  588.                   1 : begin
  589.                         felder3 := 2;
  590.                         display('>>> 20000  BONUS <<<');
  591.                         repeat led_anzeige; until led_status = 0;
  592.                         inc(score[actplayer],20000);
  593.                         set_rgb_color(106,60,30,20);
  594.                       end;
  595.                   2 : begin
  596.                         felder3 := 3;
  597.                         display('>>> 30000  BONUS <<<');
  598.                         repeat led_anzeige; until led_status = 0;
  599.                         inc(score[actplayer],30000);
  600.                         set_rgb_color(107,60,30,20);
  601.                       end;
  602.                   3 : begin
  603.                         felder3 := 5;
  604.                         display('>>> 50000  BONUS <<<');
  605.                         repeat led_anzeige; until led_status = 0;
  606.                         inc(score[actplayer],50000);
  607.                         set_rgb_color(108,60,30,20);
  608.                       end;
  609.                   end;
  610.                 if Felder3 < 5 then begin
  611.                     for fg := 109 to 114 do
  612.                         set_rgb_color(fg,pal[fg].r,pal[fg].g,pal[fg].b);
  613.                     PHASER[233] := 0; PHASER[234] := 0; PHASER[235] := 0;
  614.                     PHASER[236] := 0; PHASER[237] := 0; PHASER[238] := 0;
  615.                   end;
  616.                 end;
  617.           end;
  618.       end;
  619.   end;
  620. end;
  621.  
  622. { *** AREAS *************************************************************** }
  623.  
  624. procedure analyse_boden;
  625. var fg:byte;
  626.     h1,h2 :  byte;
  627. begin
  628.   case fm of
  629.        1 : begin
  630.              play(snd7);
  631.              display('Sure Shot 25000');
  632.              repeat led_anzeige; until led_status = 0;
  633.              draw_ground_auto;
  634.              repeat
  635.                inc(bally,2);
  636.                calc_page_pos_of_ballpos; retrace;
  637.              until bally > 320;
  638.              ballx := 5;
  639.              ballspeed_x := 0; ballspeed_y := 0; kraft := 0;
  640.              delay(350);
  641.              inc(score[actplayer],25000);
  642.            end;
  643.        2 : begin
  644.              inc(ballspeed_y,4);
  645.            end;
  646.        3 : begin
  647.              play(snd7);
  648.              case pfeil of
  649.                0 : begin
  650.                      pfeil := 2;
  651.                      set_rgb_color(99,63,20,0);
  652.                    end;
  653.                2 : begin
  654.                      pfeil := 4;
  655.                      set_rgb_color(100,63,20,0);
  656.                    end;
  657.                4 : begin
  658.                      pfeil := 6;
  659.                      set_rgb_color(101,63,20,0);
  660.                    end;
  661.                6 : begin
  662.                      if locked = 0 then begin
  663.                          locked := 1;
  664.                          display('BALL LOCKED!');
  665.                          repeat led_anzeige; until led_status = 0;
  666.                          draw_ground_auto;
  667.                          delay(1000);
  668.                          init_ball_values;
  669.                          exit;
  670.                        end;
  671.                      display('BALL ALREADY LOCKED!');
  672.                          repeat led_anzeige; until led_status = 0;
  673.                          delay(500);
  674.                    end;
  675.              end;
  676.              inc(score[actplayer],pfeil*2000);
  677.              display('Lock door : '+inttostr(pfeil)+'x2000');
  678.              repeat led_anzeige; until led_status = 0;
  679.              delay(1000);
  680.            end;
  681.        5 : begin
  682.              display('KILL THE RAT!');
  683.            end;
  684.        6 : begin
  685.              play(snd7);
  686.              h1 := MAXFarbe;
  687.              MAXFarbe := 209;
  688.              display('RAMP BONUS:');
  689.              play(snd12);
  690.              repeat led_anzeige; until led_status = 0;
  691.              delay(500);
  692.              draw_ground_auto;
  693.              delay(1000);
  694.              case felder1 of
  695.                0 : begin
  696.                      set_rgb_color(95, 63,20,0);
  697.                      felder1 := 1;
  698.                    end;
  699.                1 : begin
  700.                      set_rgb_color(94, 63,20,0);
  701.                      felder1 := 3;
  702.                    end;
  703.                3 : begin
  704.                      set_rgb_color(93, 63,20,0);
  705.                      felder1 := 5;
  706.                    end;
  707.              end;
  708.              display('-._ '+inttostr(felder1)+'000 * 5 _.-');
  709.              repeat led_anzeige; until led_status = 0;
  710.              play(snd11);
  711.              ballx := 15; bally := 106;
  712.              inc(score[actplayer],felder1*1000*5);
  713.              ballspeed_x := 0; ballspeed_y := 0;
  714.              for bally := bally to 136 do begin
  715.                  retrace; move_ball;
  716.                  calc_page_pos_of_ballpos; {readkey;}
  717.                end;
  718.              for bally := bally to 145 do begin
  719.                  retrace; move_ball;
  720.                  calc_page_pos_of_ballpos; {readkey;}
  721.                  inc(ballx);
  722.                end;
  723.              for bally := bally to 223+random(3) do begin
  724.                  retrace; move_ball;
  725.                  calc_page_pos_of_ballpos; {readkey;}
  726.                  if bally mod 6 = 0 then inc(ballx) else inc(ballx,2);
  727.                end;
  728.              repeat
  729.                retrace; move_ball;
  730.                calc_page_pos_of_ballpos; {readkey;}
  731.                inc(bally,2);
  732.              until bally > 250;
  733.              draw_ground_auto;
  734.              delay(500);
  735.              MAXFarbe := h1;
  736.              {zufall}
  737.              h1 := random(4)+13;
  738.              ballspeed_y := 0;
  739.              ballspeed_x := 0;
  740.              case h1 of
  741.                13 : begin
  742.                       ballx := 170; bally := 233;
  743.                       ballspeed_y := -random(15)-15;
  744.                     end;
  745.                14 : begin
  746.                       ballx := 189; bally := 250;
  747.                       ballspeed_x := random(15)+15;
  748.                     end;
  749.                15 : begin
  750.                       ballx := 170; bally := 269;
  751.                       ballspeed_y := random(15)+15;
  752.                     end;
  753.                16 : begin
  754.                       ballx := 151; bally := 250;
  755.                       ballspeed_x := -random(15)-15;
  756.                     end;
  757.              end;
  758.            end;
  759.        7 : begin
  760.              display('NO RAMP!');
  761.            end;
  762.        8 : begin
  763.              play(snd7);
  764.              display('RAT HOLE 3000');
  765.              repeat led_anzeige; until led_status = 0;
  766.              draw_ground_auto;
  767.              inc(score[actplayer],3000);
  768.              for bally := bally downto 40 do begin
  769.                  retrace; calc_page_pos_of_ballpos; end;
  770.              HilfsProc1;
  771.            end;
  772.      10 : begin
  773.             if ballspeed_y > 0 then begin
  774.                 play(snd10);
  775.                 rl := not rl;
  776.                 if rl then set_rgb_color(115,pal[115].r,pal[115].g,pal[115].b)
  777.                       else set_rgb_color(115,20,10,10);
  778.                 if rl then display('RELAUNCH ON!')
  779.                       else display('RELAUNCH OFF!');
  780.               end;
  781.             if felder2 < 3 then begin
  782.                 inc(felder2);
  783.                 display('DEATH BONUS '+inttostr(felder2*500));
  784.                 set_rgb_color(102+felder2-1,20,30,60);
  785.               end;
  786.           end;
  787.      11 : begin
  788.             play(snd10);
  789.             if ballspeed_y < 0 then begin
  790.                 ballspeed_y := ballspeed_y div 4;
  791.                 ballspeed_x := 8;
  792.               end;
  793.           end;
  794.        12 : begin
  795.               if balls[actplayer] < maxballs then display('>Hit SPACE to start<');
  796.             end;
  797.       13..16 : begin
  798.                  repeat h1 := random(4)+13; until h1 <> fm;
  799.                  {delay(150);}
  800.                  draw_ground_auto;
  801.                  delay(400);
  802.                  ballspeed_y := 0;
  803.                  ballspeed_x := 0;
  804.                  case h1 of
  805.                    13 : begin
  806.                           ballx := 170; bally := 233;
  807.                           ballspeed_y := -random(15)-15;
  808.                         end;
  809.                    14 : begin
  810.                           ballx := 189; bally := 250;
  811.                           ballspeed_x := random(15)+15;
  812.                         end;
  813.                    15 : begin
  814.                           ballx := 170; bally := 269;
  815.                           ballspeed_y := random(15)+15;
  816.                         end;
  817.                    16 : begin
  818.                           ballx := 151; bally := 250;
  819.                           ballspeed_x := -random(15)-15;
  820.                         end;
  821.                  end;
  822.                  move_ball;
  823.                  {delay(500);}
  824.                  inc(score[actplayer],1000);
  825.                  play(snd1);
  826.            end;
  827.       17 : begin
  828.             {inc(ballspeed_x);}
  829.            end;
  830.       23 : begin
  831.              dec(ballspeed_x);
  832.            end;
  833.       24..26 : begin
  834.           if ballspeed_y < 0 then exit;
  835.           play(snd10);
  836.           if RAT[fm] = 0 then begin
  837.               set_rgb_color(fm-24+90,63,20,0);
  838.               RAT[fm] := 1;
  839.               inc(score[actplayer],1000);
  840.             end;
  841.           if (rat[24] = 0) or (rat[25] = 0) or (rat[26] = 0) then
  842.             display('RAT is incomplete') else begin
  843.                 display('RAT is COMPLETE!');
  844.                 inc(score[actplayer],10000);
  845.               end;
  846.         end;
  847.   end;
  848. end;
  849.  
  850. function gettablepixel(x,y:word):byte;
  851. begin
  852.   if y<200 then gettablepixel:=tableground1^[x,y]
  853.     else if y<400 then gettablepixel:=tableground2^[x,y]
  854.         else if y < 600 then gettablepixel:=tableground3^[x,y];
  855. end;
  856.  
  857. procedure check_ball_oben;
  858. var x,y,z:integer;
  859.     contact:boolean;
  860. begin
  861.   y:=bally;
  862.   contact:=false;
  863.   repeat                         {gut}
  864.     {0&16 / 1&15 / 2&14 / 3&13 / 4&12 / 5&11 / 6&10 / 7&9 / 8&8}
  865.     for x:=ballx+ 4 to ballx+12 do begin
  866.         if gettablepixel(x,y)>127 then begin
  867.            contact:=true;
  868.            if x <= ballx+8 then inc(o1) else inc(o2);
  869.            fo := gettablepixeL(x,y);
  870.          end;
  871.       end;
  872.     dec(y);
  873.   until (y<=bally+ballspeed_y div 2) or (contact);
  874.   inc(y); bally:=y;
  875. end;
  876.  
  877. procedure check_ball_unten;
  878. var x,y,z:integer;
  879.     contact:boolean;
  880. begin
  881.   y:=bally;
  882.   contact:=false;
  883.   repeat
  884.     for x:=ballx+ 4 to ballx+12 do
  885.     begin
  886.       if gettablepixel(x,y+14)>127 then begin
  887.           contact:=true;
  888.           if x <= ballx+8 then inc(u1) else inc(u2);
  889.           fu := gettablepixeL(x,y+14);
  890.         end;
  891.     end;
  892.     inc(y);
  893.   until (y>=bally+ballspeed_y div 2) or (contact);
  894.   dec(y); bally:=y;
  895. end;
  896.  
  897. procedure check_ball_links;
  898. var x,y,z:integer;
  899.     contact:boolean;
  900. begin
  901.   x:=ballx;
  902.   contact:=false;
  903.   repeat
  904.     for y:=bally+ 4 to bally+12 do
  905.     begin
  906.       if gettablepixel(x,y)>127 then begin
  907.           contact:=true;
  908.           if y <= bally+8 then inc(l1) else inc(l2);
  909.           fl :=  gettablepixeL(x,y);
  910.         end;
  911.     end;
  912.     dec(x);
  913.     if (x<0) then begin x:=0; contact:=true; end;
  914.   until (x<=ballx+ballspeed_x div 2) or (contact);
  915.   inc(x); ballx:=x;
  916. end;
  917.  
  918. procedure check_ball_rechts;
  919. var x,y,z:integer;
  920.     contact:boolean;
  921. begin
  922.   x:=ballx;
  923.   contact:=false;
  924.   repeat
  925.     for y:=bally+ 4 to bally+12 do
  926.     begin
  927.       if gettablepixel(x+14,y)>127 then begin
  928.           contact:=true;
  929.           if y <= bally+8 then inc(r1) else inc(r2);
  930.           fr :=  gettablepixeL(x,y+14);
  931.         end;
  932.     end;
  933.     inc(x);
  934.     if (x>304) then begin x:=304; contact:=true; end;
  935.  
  936.   until (x>=ballx+ballspeed_x div 2) or (contact);
  937.   dec(x); ballx:=x;
  938. end;
  939.  
  940. procedure Check_Ball;
  941. begin
  942.   o1 := 0; o2 := 0; u1 := 0; u2 := 0;
  943.   l1 := 0; l2 := 0; r1 := 0; r2 := 0;
  944.  
  945.   fu := 0; fo := 0; fl := 0; fr := 0;
  946.  
  947.   if ballspeed_y < 0 then begin
  948.       check_ball_oben;
  949.       if (o1 + o2 > 0) then begin
  950.           dec(kraft);
  951.           if kraft < 0 then
  952.            ballspeed_y := -(ballspeed_y{+abs(ballspeed_y)div 2) div 4}div 2);
  953.         end;
  954.       if (o1 > 0) and (o2 = 0) then if ballspeed_x < 4 then inc(ballspeed_x);
  955.       if (o1 = 0) and (o2 > 0) then if ballspeed_x > -4 then dec(ballspeed_x);
  956.     end;
  957.   if ballspeed_y >= 0 then begin
  958.       check_ball_unten;
  959.       if (u1 + u2 > 0) then begin
  960.           ballspeed_y := -(ballspeed_y{+abs(ballspeed_y)div 2) div 4}div 2);
  961.           kraft := abs(ballspeed_y div 2);
  962.         end;                                         {4}
  963.       if (u1 > 0) and (u2 = 0) then if ballspeed_x < 4 then
  964.           begin if random > 0.3 then inc(ballspeed_x) else inc(ballx); end;
  965.       if (u1 = 0) and (u2 > 0) then if ballspeed_x > -4 then
  966.           begin if random > 0.3 then dec(ballspeed_x) else dec(ballx); end;
  967.     end;
  968.   if ballspeed_x <= 0 then begin
  969.       check_ball_links;
  970.       if (l1 + l2 > 0) then begin
  971.           ballspeed_x := abs((ballspeed_x+abs(ballspeed_y)div 3) div 4){+1};
  972.           {if ballspeed_x < 4 then inc(ballspeed_x,2);}
  973.         end;
  974.       if (l1 > 0) and (l2 = 0) then inc(ballspeed_y);
  975.       if (l1 = 0) and (l2 > 0) then dec(ballspeed_y);
  976.     end;
  977.   if ballspeed_x >= 0 then begin
  978.       check_ball_rechts;
  979.       if (r1 + r2 > 0) then begin
  980.           ballspeed_x := -((ballspeed_x+abs(ballspeed_y)div 2) div 4){-1};
  981.           {if ballspeed_x > -4 then dec(ballspeed_x,2);}
  982.         end;
  983.       if (r1 > 0) and (r2 = 0) then inc(ballspeed_y);
  984.       if (r1 = 0) and (r2 > 0) then dec(ballspeed_y);
  985.     end;
  986.  
  987.   if (l2 > 0) and (l1 = 0) then
  988.       if (u1 > 0) or (u2=0) then if ballspeed_x <= 0 then begin
  989.               inc(ballspeed_y); inc(ballspeed_x); end;
  990.   if (r2 > 0) and (r1 = 0) then
  991.       if (u1 = 0) and (u2>0) then if ballspeed_x >= 0 then
  992.           begin inc(ballspeed_y); dec(ballspeed_x); end;
  993.  
  994.   if (l1 > 0) and (l2 = 0) then
  995.       if (o1 > 0) or (o2=0) then if ballspeed_x >= 0 then begin
  996.               {inc(bally);} dec(ballx); end;
  997.   if (r1 > 0) and (r2 = 0) then
  998.       if (o1 = 0) and (o2>0) then if ballspeed_x <= 0 then begin
  999.               {inc(bally);} inc(ballx); end;
  1000.  
  1001. {}  if grad = TischGrad then grad := 0
  1002.                       else begin inc(ballspeed_y); inc(grad); end; {}
  1003. {  inc(ballspeed_y); {}
  1004.   if ballspeed_y > speedmaxy then ballspeed_y := speedmaxy;
  1005.  
  1006. end;
  1007.  
  1008.   var a,b,c,d : byte;
  1009.  
  1010. begin
  1011.   asm cli end;
  1012.   checkbreak := false;
  1013.   if (paramcount <> 1) or (length(paramstr(1)) <> 3) then halt(0);
  1014.   {detect soundblaster and initialize the values}
  1015.   textcolor(black);
  1016.   textbackground(black);
  1017.   detect_soundblaster;
  1018.  
  1019.   Init_All;
  1020.   Init_Tisch2;
  1021.  
  1022.   repeat
  1023.  
  1024.     keyboard; ch := upcase(CH);
  1025.     case ch of
  1026.       'K' : begin
  1027.               ballspeed_y := ballspeed_y - 10;
  1028.               ballspeed_x := ballspeed_x - 6 + random(12);
  1029.               inc(ruetteln);
  1030.               display('DER '+inttostr(ruetteln)+'.RÜTTLER!');
  1031.               if ruetteln = 5 then begin
  1032.                   bende := true;
  1033.                   display('T I L T !');
  1034.                 end;
  1035.               repeat led_anzeige; until led_status = 0;
  1036.               delay(200);
  1037.             end;
  1038.       'P' : StartCDPlayer;
  1039.       'Q',#27 :
  1040.           if NormalPos =  CurrentPos then begin
  1041.               Display('Are you a coward ?');
  1042.               repeat led_anzeige; until led_status = 0;
  1043.               repeat keyboard; ch := upcase(ch);
  1044.               until (ch = 'Y') or (ch = 'N') or (ch = 'Z');
  1045.               case ch of
  1046.                 'N' : begin
  1047.                     bende := false;
  1048.                     Display('No!');
  1049.                     repeat led_anzeige; until led_status = 0;
  1050.                   end;
  1051.                 'Y','Z' : begin
  1052.                     bende := true;
  1053.                     Display('Yes!');
  1054.                     repeat led_anzeige; until led_status = 0;
  1055.                   end;
  1056.               end;
  1057.           end;
  1058.       ' ' : if (fm = 12) and (normalpos = currentpos) and (balls[actplayer] < MaxBalls)then begin
  1059.                 display('Release to start!');
  1060.                 repeat led_anzeige; until led_status = 0;
  1061.                 StartPow := 0;
  1062.                 repeat
  1063.                   if startpow < 75 then begin
  1064.                       inc(startpow,2);
  1065.                       FederY:=400+205+startpow div 5;
  1066.                       FederHoehe:=40-startpow div 5;
  1067.                       retrace;
  1068.                       Set_Feder;
  1069.                       move_ball;
  1070.                     end else play(snd1);
  1071.                   if keypressed then readkey;
  1072.                   Check_Flipper_Arms;
  1073.                 until port[$60] <> 57;
  1074.  
  1075.                 repeat
  1076.                   dec(FederY,2);
  1077.                   if FederHoehe<39 then inc(FederHoehe,2);
  1078.                   Set_Feder;
  1079.                   retrace;
  1080.                 until FederY<=400+205;
  1081.                 Ballspeed_y := -StartPow div 4 - 30 - 19; kraft := 90;
  1082.                 display('GET THE SPACE-RAT');
  1083.                 repeat led_anzeige; until led_status = 0;
  1084.               end;
  1085.     end;
  1086.     {get extended key}
  1087.     CTRL_Shift_Keys;
  1088.     {arms}
  1089.     Check_Flipper_Arms;
  1090.     {calc_new_ball_pos // check border etc. // main proc}
  1091.     Check_Ball;
  1092.     {if (fr=arm) or (fl=arm) or (fu=arm) or (fo=arm) or
  1093.        (fm=arm) or (fh=arm) then analyse_arms;}
  1094.     asm
  1095.       mov al,arm;  cmp al,fr; jz @analyse;
  1096.       mov al,arm;  cmp al,fl; jz @analyse;
  1097.       mov al,arm;  cmp al,fu; jz @analyse;
  1098.       mov al,arm;  cmp al,fo; jz @analyse;
  1099.       mov al,arm;  cmp al,fm; jz @analyse;
  1100.       mov al,arm;  cmp al,fh; jz @analyse;
  1101.       jmp @ende
  1102.     @analyse: call analyse_arms
  1103.     @ende:
  1104.     end;
  1105.  
  1106.     arm_links_old_status:=arm_links_status;
  1107.     arm_rechts_old_status:=arm_rechts_status;
  1108.  
  1109.     {final check routine}
  1110.     if CurrentPos > NormalPos then begin
  1111.         if (ballx = bx_old) and (bally = by_old) then retrace;
  1112.         dec(CurrentPos); SetLineComp(CurrentPos);
  1113.       end;
  1114.     if (ballx <> bx_old) or (bally <> by_old) then begin
  1115.          retrace;
  1116.  
  1117.         {set ball}
  1118.         calc_page_pos_of_ballpos;
  1119.         move_ball;
  1120.         {}
  1121.         if bally > 581 then fu := 242;
  1122.         if (fr>0) or (fl>0) or (fu>0) or (fo>0) then analyse_crash;
  1123.         if bende then break;
  1124.         fh := gettablepixel(ballx+8,bally+8);
  1125.         if fh <> fm then begin
  1126.             if (fh>0) and (fh<128) then begin fm := fh; analyse_boden; end
  1127.                       else if fh = 0 then fm := 0;
  1128.           end;
  1129.       end;
  1130.      asm cli end;
  1131.  
  1132.     led_anzeige;
  1133.  
  1134.     case counter of
  1135.        0 : begin end;
  1136.        1 : begin
  1137.              for a := 96 to 98 do
  1138.                  set_rgb_color(a,pal[a].r,pal[a].g,pal[a].b);
  1139.              for a := 116 to 119 do
  1140.                  set_rgb_color(a,pal[a].r,pal[a].g,pal[a].b);
  1141.              dec(counter);
  1142.            end;
  1143.        else dec(counter);
  1144.     end;
  1145.   until bende = true;
  1146.  
  1147.   for b := 0 to 63 do
  1148.     for a := 0 to 255 do begin
  1149.         if pal[a].r > 0 then dec(pal[a].r);
  1150.         if pal[a].g > 0 then dec(pal[a].g);
  1151.         if pal[a].b > 0 then dec(pal[a].b);
  1152.         set_rgb_color(a,pal[a].r,pal[a].g,pal[a].b);
  1153.       end;
  1154.   Close_All;
  1155.   asm sti end;
  1156. end.