stinger3.pas 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. {$M 65520, 20000, 655360}
  2. {This version uses EMM Memory and my coolest keyboard handler}
  3. Uses Objects3,Graph,My_Mem,CoolKey;
  4. Procedure EGAVGADriver;external;
  5. Function KeyPressed:boolean;assembler;
  6. asm
  7. mov ah, 1
  8. int 16h
  9. mov al, 0
  10. jz @@2
  11. mov al, 1
  12. @@2:
  13. end;{KeyPressed}
  14. {----------------------}
  15. Function ReadKey:char;assembler;
  16. asm
  17. mov ah, 00
  18. int 16h
  19. cmp al, 0
  20. jnz @@1
  21. mov al, ah
  22. @@1:
  23. end;
  24. {ReadKey}
  25. var
  26. Wrld : PWorld;
  27. Timer : LongInt Absolute $0040:$006c;
  28. BegMem,MinMem : LongInt;
  29. Last,i,Beg : Longint;
  30. MyRAH : pRAH;
  31. MyStinger : pSting;
  32. MyExpl : pExpl;
  33. mP : TParams;
  34. Page : byte;
  35. gD,gM : integer;
  36. Key : char;
  37. begin
  38. BegMem := MaxAvail;MinMem := BegMem;
  39. if not InitEMM then
  40. Begin
  41. WriteLn('Sorry, can''t find EMM driver (probably there is no line in config.sys ''device=EMM386''');
  42. Halt(233);
  43. end;
  44. if not TestAllocEMM(300 shl 10) then
  45. Begin
  46. WriteLn('Sorry, no enought EMS, need ', 300 shl 10, ' get ', MaxEMM);
  47. Halt(233);
  48. end;
  49. TIME_FACTOR := 0.2;
  50. FPS := 1;
  51. FIELD_X := 600;
  52. GLOB_G := 0.1;
  53. Randomize;
  54. {$L EGAVGA.OBJ}
  55. RegisterBGIDriver(@EGAVGADriver);
  56. Gd:=VGA;
  57. Gm:=VGAMed;
  58. INitGraph(gD,gM,'');
  59. SIZE_Y := 350;
  60. New(Wrld,Init('BG2.dat'));
  61. Wrld^.Message('Move, rotate stinger with keys, change dAngle with Del/PgDown',1,Red);
  62. With mP do begin
  63. Pos.x:=75.0;
  64. Pos.y := 300.0;
  65. Speed.X := 5.0;
  66. Speed.Y := 0.0;
  67. Accel.X := 0.0;
  68. Accel.Y := 0.0;
  69. end;
  70. New(MyRAH,Init('rah-66-2.dat',mP,100));
  71. with MyRah^ do
  72. begin
  73. CountBase := 2;
  74. countVar := 2;
  75. SpeedBase:=10;
  76. SpeedVar := 3;
  77. TrapBase := 60;
  78. TrapVar := 10;
  79. NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
  80. end;
  81. Wrld^.AddObject(MyRAH);
  82. {
  83. With mP do begin
  84. Pos.x:=75.0;
  85. Pos.y := 200.0;
  86. Speed.X := 7.0;
  87. Speed.Y := 0.0;
  88. Accel.X := 0.0;
  89. Accel.Y := 0.0;
  90. end;
  91. New(MyRAH,Init('rah-66-2.dat',mP,105));
  92. with MyRah^ do
  93. begin
  94. CountBase := 5;
  95. countVar := 2;
  96. SpeedBase:=10;
  97. SpeedVar := 3;
  98. TrapBase := 30;
  99. TrapVar := 10;
  100. NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
  101. end;
  102. Wrld^.AddObject(MyRAH);
  103. }
  104. With mP do begin
  105. Pos.x:=520.0;
  106. Pos.y := 60.0;
  107. Speed.X := 10;
  108. Speed.Y := 0;
  109. Accel.X := 0.0;
  110. Accel.Y := 0.0;
  111. end;
  112. New(MyStinger,Init('stinger.dat',mP,10,110));
  113. Wrld^.AddObject(MyStinger);
  114. MyStinger^.ChangeAngle(90);
  115. Last := timeR;
  116. i:=0;
  117. page:=0;
  118. SetActivePage(0);
  119. Wrld^.Draw;
  120. SetActivePage(1);
  121. Wrld^.Draw;
  122. while not (Key = #27) do
  123. begin
  124. if MaxAvail < MinMem then MinMem := maxAvail;
  125. Key := #0;
  126. if KeyPressed then Key:=ReadKey;
  127. case key of
  128. #80: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
  129. MyStinger^.ChangeAngle(MyStinger^.Angle-1);
  130. #72: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
  131. MyStinger^.ChangeAngle(MyStinger^.Angle+1);
  132. #75: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  133. MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x-1;
  134. if MyStinger^.Params.Pos.X < (MyStinger^.xsize^[0] shr 1) then
  135. MyStinger^.Params.Pos.x :=MyStinger^.xsize^[0] shr 1;
  136. end;
  137. #77: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  138. MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x+1;
  139. if MyStinger^.Params.Pos.X > (FIELD_X-MyStinger^.xsize^[0] shr 1) then
  140. MyStinger^.Params.Pos.x :=(FIELD_X-MyStinger^.xsize^[0] shr 1)
  141. end;
  142. #13: begin
  143. if MyStinger^.ObjType <> 'Stinger' then Key:=#27;
  144. if not MyRAH^.Started then
  145. begin
  146. Wrld^.StartObjects('RAH-66');
  147. Beg:=Timer;
  148. i:=0;
  149. end
  150. else if not MyStinger^.Started then
  151. begin
  152. Wrld^.StartObjects('Stinger');
  153. Wrld^.Message('',1,0);
  154. end;
  155. end;
  156. #81: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  157. Dec(MyStinger^.dAngle);
  158. if MyStinger^.dAngle < 2 then MyStinger^.dAngle := 1;
  159. end;
  160. #83: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  161. Inc(MyStinger^.dAngle);
  162. if MyStinger^.dAngle > 180 then MyStinger^.dAngle := 180;
  163. end;
  164. end;
  165. if (MyRah^.Started or MyStinger^.Started or (Key<>#0)) then
  166. begin
  167. Inc(i);
  168. SetActivePage(Page);
  169. Wrld^.Draw;
  170. repeat until (Port[$03DA] and 8) <> 8;
  171. repeat until (Port[$03DA] and 8) = 8;
  172. SetVisualPage(Page);
  173. Page:=1-Page;
  174. end;
  175. if (MyRah^.Started or MyStinger^.Started) then
  176. begin
  177. repeat until (Timer-Last) <> 0;
  178. Wrld^.Frame(Timer-Last);
  179. end;
  180. Last := timeR;
  181. end;
  182. Beg := Timer - Beg;
  183. Dispose(Wrld,Done);
  184. CloseGraph;
  185. if MaxAvail <> BegMem then WriteLn('Suxx, losing memory: ', BegMem-MaxAvail);
  186. WriteLn('MaxMemory - ', BegMem - MinMem);
  187. WriteLn('Average FPS - ', i/(Beg*0.055):0:4);
  188. end.