STINGER4.PAS 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. ifExit : boolean;
  37. KT : PKeyTable;
  38. begin
  39. BegMem := MaxAvail;MinMem := BegMem;
  40. if not InitEMM then
  41. Begin
  42. WriteLn('Sorry, can''t find EMM driver (probably there is no line in config.sys ''device=EMM386''');
  43. Halt(233);
  44. end;
  45. if not TestAllocEMM(300 shl 10) then
  46. Begin
  47. WriteLn('Sorry, no enought EMS, need ', 300 shl 10, ' get ', MaxEMM);
  48. Halt(233);
  49. end;
  50. TIME_FACTOR := 0.2;
  51. FPS := 1;
  52. FIELD_X := 600;
  53. GLOB_G := 0.1;
  54. Randomize;
  55. {$L EGAVGA.OBJ}
  56. RegisterBGIDriver(@EGAVGADriver);
  57. Gd:=VGA;
  58. Gm:=VGAMed;
  59. INitGraph(gD,gM,'');
  60. SIZE_Y := 350;
  61. New(Wrld,Init('BG2.dat'));
  62. Wrld^.Message('Move, rotate stinger with keys, change dAngle with Del/PgDown',1,Red);
  63. With mP do begin
  64. Pos.x:=75.0;
  65. Pos.y := 300.0;
  66. Speed.X := 5.0;
  67. Speed.Y := 0.0;
  68. Accel.X := 0.0;
  69. Accel.Y := 0.0;
  70. end;
  71. New(MyRAH,Init('rah-66-2.dat',mP,100));
  72. with MyRah^ do
  73. begin
  74. CountBase := 2;
  75. countVar := 2;
  76. SpeedBase:=10;
  77. SpeedVar := 3;
  78. TrapBase := 60;
  79. TrapVar := 10;
  80. NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
  81. end;
  82. Wrld^.AddObject(MyRAH);
  83. {
  84. With mP do begin
  85. Pos.x:=75.0;
  86. Pos.y := 200.0;
  87. Speed.X := 7.0;
  88. Speed.Y := 0.0;
  89. Accel.X := 0.0;
  90. Accel.Y := 0.0;
  91. end;
  92. New(MyRAH,Init('rah-66-2.dat',mP,105));
  93. with MyRah^ do
  94. begin
  95. CountBase := 5;
  96. countVar := 2;
  97. SpeedBase:=10;
  98. SpeedVar := 3;
  99. TrapBase := 30;
  100. TrapVar := 10;
  101. NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
  102. end;
  103. Wrld^.AddObject(MyRAH);
  104. }
  105. With mP do begin
  106. Pos.x:=520.0;
  107. Pos.y := 60.0;
  108. Speed.X := 10;
  109. Speed.Y := 0;
  110. Accel.X := 0.0;
  111. Accel.Y := 0.0;
  112. end;
  113. New(MyStinger,Init('stinger.dat',mP,10,110));
  114. Wrld^.AddObject(MyStinger);
  115. MyStinger^.ChangeAngle(90);
  116. Last := timeR;
  117. i:=0;
  118. page:=0;
  119. SetActivePage(0);
  120. Wrld^.Draw;
  121. SetActivePage(1);
  122. Wrld^.Draw;
  123. KT := InitKeyboard;
  124. ifExit := false;
  125. while not ifExit do
  126. begin
  127. if KT^[SC_ESCAPE] then ifExit := true;
  128. if MaxAvail < MinMem then MinMem := maxAvail;
  129. if KT^[SC_UP] and (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
  130. MyStinger^.ChangeAngle(MyStinger^.Angle-1);
  131. if KT^[SC_DOWN] and (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
  132. MyStinger^.ChangeAngle(MyStinger^.Angle+1);
  133. if KT^[SC_LEFT] and (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  134. MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x-1;
  135. if MyStinger^.Params.Pos.X < (MyStinger^.xsize^[0] shr 1) then
  136. MyStinger^.Params.Pos.x :=MyStinger^.xsize^[0] shr 1;
  137. end;
  138. if KT^[SC_RIGHT] and (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  139. MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x+1;
  140. if MyStinger^.Params.Pos.X > (FIELD_X-MyStinger^.xsize^[0] shr 1) then
  141. MyStinger^.Params.Pos.x :=(FIELD_X-MyStinger^.xsize^[0] shr 1)
  142. end;
  143. if KT^[SC_ENTER] then begin
  144. if MyStinger^.ObjType <> 'Stinger' then ifExit := true;
  145. if not MyRAH^.Started then
  146. begin
  147. Wrld^.StartObjects('RAH-66');
  148. Beg:=Timer;
  149. i:=0;
  150. end
  151. else if not MyStinger^.Started then
  152. begin
  153. Wrld^.StartObjects('Stinger');
  154. Wrld^.Message('',1,0);
  155. end;
  156. end;
  157. if KT^[SC_DELETE] and (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  158. Dec(MyStinger^.dAngle);
  159. if MyStinger^.dAngle < 2 then MyStinger^.dAngle := 1;
  160. end;
  161. if KT^[SC_PGDN] and (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
  162. Inc(MyStinger^.dAngle);
  163. if MyStinger^.dAngle > 180 then MyStinger^.dAngle := 180;
  164. end;
  165. { if (MyRah^.Started or MyStinger^.Started) a 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. CloseKeyboard;
  189. end.