| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- {$M 65520, 20000, 655360}
- {This version uses EMM Memory and my coolest keyboard handler}
- Uses Objects3,Graph,My_Mem,CoolKey;
- Procedure EGAVGADriver;external;
- Function KeyPressed:boolean;assembler;
- asm
- mov ah, 1
- int 16h
- mov al, 0
- jz @@2
- mov al, 1
- @@2:
- end;{KeyPressed}
- {----------------------}
- Function ReadKey:char;assembler;
- asm
- mov ah, 00
- int 16h
- cmp al, 0
- jnz @@1
- mov al, ah
- @@1:
- end;
- {ReadKey}
- var
- Wrld : PWorld;
- Timer : LongInt Absolute $0040:$006c;
- BegMem,MinMem : LongInt;
- Last,i,Beg : Longint;
- MyRAH : pRAH;
- MyStinger : pSting;
- MyExpl : pExpl;
- mP : TParams;
- Page : byte;
- gD,gM : integer;
- Key : char;
- begin
- BegMem := MaxAvail;MinMem := BegMem;
- if not InitEMM then
- Begin
- WriteLn('Sorry, can''t find EMM driver (probably there is no line in config.sys ''device=EMM386''');
- Halt(233);
- end;
- if not TestAllocEMM(300 shl 10) then
- Begin
- WriteLn('Sorry, no enought EMS, need ', 300 shl 10, ' get ', MaxEMM);
- Halt(233);
- end;
- TIME_FACTOR := 0.2;
- FPS := 1;
- FIELD_X := 600;
- GLOB_G := 0.1;
- Randomize;
- {$L EGAVGA.OBJ}
- RegisterBGIDriver(@EGAVGADriver);
- Gd:=VGA;
- Gm:=VGAMed;
- INitGraph(gD,gM,'');
- SIZE_Y := 350;
- New(Wrld,Init('BG2.dat'));
- Wrld^.Message('Move, rotate stinger with keys, change dAngle with Del/PgDown',1,Red);
- With mP do begin
- Pos.x:=75.0;
- Pos.y := 300.0;
- Speed.X := 5.0;
- Speed.Y := 0.0;
- Accel.X := 0.0;
- Accel.Y := 0.0;
- end;
- New(MyRAH,Init('rah-66-2.dat',mP,100));
- with MyRah^ do
- begin
- CountBase := 2;
- countVar := 2;
- SpeedBase:=10;
- SpeedVar := 3;
- TrapBase := 60;
- TrapVar := 10;
- NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
- end;
- Wrld^.AddObject(MyRAH);
- {
- With mP do begin
- Pos.x:=75.0;
- Pos.y := 200.0;
- Speed.X := 7.0;
- Speed.Y := 0.0;
- Accel.X := 0.0;
- Accel.Y := 0.0;
- end;
- New(MyRAH,Init('rah-66-2.dat',mP,105));
- with MyRah^ do
- begin
- CountBase := 5;
- countVar := 2;
- SpeedBase:=10;
- SpeedVar := 3;
- TrapBase := 30;
- TrapVar := 10;
- NextTrap := TrapBase + random(TrapVar) - (TrapVar shr 1);
- end;
- Wrld^.AddObject(MyRAH);
- }
- With mP do begin
- Pos.x:=520.0;
- Pos.y := 60.0;
- Speed.X := 10;
- Speed.Y := 0;
- Accel.X := 0.0;
- Accel.Y := 0.0;
- end;
- New(MyStinger,Init('stinger.dat',mP,10,110));
- Wrld^.AddObject(MyStinger);
- MyStinger^.ChangeAngle(90);
- Last := timeR;
- i:=0;
- page:=0;
- SetActivePage(0);
- Wrld^.Draw;
- SetActivePage(1);
- Wrld^.Draw;
- while not (Key = #27) do
- begin
- if MaxAvail < MinMem then MinMem := maxAvail;
- Key := #0;
- if KeyPressed then Key:=ReadKey;
- case key of
- #80: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
- MyStinger^.ChangeAngle(MyStinger^.Angle-1);
- #72: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then
- MyStinger^.ChangeAngle(MyStinger^.Angle+1);
- #75: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
- MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x-1;
- if MyStinger^.Params.Pos.X < (MyStinger^.xsize^[0] shr 1) then
- MyStinger^.Params.Pos.x :=MyStinger^.xsize^[0] shr 1;
- end;
- #77: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
- MyStinger^.Params.Pos.x := MyStinger^.Params.Pos.x+1;
- if MyStinger^.Params.Pos.X > (FIELD_X-MyStinger^.xsize^[0] shr 1) then
- MyStinger^.Params.Pos.x :=(FIELD_X-MyStinger^.xsize^[0] shr 1)
- end;
- #13: begin
- if MyStinger^.ObjType <> 'Stinger' then Key:=#27;
- if not MyRAH^.Started then
- begin
- Wrld^.StartObjects('RAH-66');
- Beg:=Timer;
- i:=0;
- end
- else if not MyStinger^.Started then
- begin
- Wrld^.StartObjects('Stinger');
- Wrld^.Message('',1,0);
- end;
- end;
- #81: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
- Dec(MyStinger^.dAngle);
- if MyStinger^.dAngle < 2 then MyStinger^.dAngle := 1;
- end;
- #83: if (not MyStinger^.started) and (MyStinger^.ObjType = 'Stinger') then begin
- Inc(MyStinger^.dAngle);
- if MyStinger^.dAngle > 180 then MyStinger^.dAngle := 180;
- end;
- end;
- if (MyRah^.Started or MyStinger^.Started or (Key<>#0)) then
- begin
- Inc(i);
- SetActivePage(Page);
- Wrld^.Draw;
- repeat until (Port[$03DA] and 8) <> 8;
- repeat until (Port[$03DA] and 8) = 8;
- SetVisualPage(Page);
- Page:=1-Page;
- end;
- if (MyRah^.Started or MyStinger^.Started) then
- begin
- repeat until (Timer-Last) <> 0;
- Wrld^.Frame(Timer-Last);
- end;
- Last := timeR;
- end;
- Beg := Timer - Beg;
- Dispose(Wrld,Done);
- CloseGraph;
- if MaxAvail <> BegMem then WriteLn('Suxx, losing memory: ', BegMem-MaxAvail);
- WriteLn('MaxMemory - ', BegMem - MinMem);
- WriteLn('Average FPS - ', i/(Beg*0.055):0:4);
- end.
|