< -->

Program TextGame;
{$E-,G+,N+}
Uses MGame;
{$L C:\PROGRA~2\BP70\FONTS\for_game.obj}
{$L C:\PROGRA~2\BP70\FONTS\shyar1.obj}
{$L C:\PROGRA~2\BP70\FONTS\shyar2.obj}
{$L C:\PROGRA~2\BP70\FONTS\gamface1.obj}
Procedure Picts; External;
Procedure Intro1; External;
Procedure Intro2; External;
Procedure GFace; External;
const
 Black  =      0;
 Blue   =      1;
 Green  =      2;
 Cyan   =      3;
 Red    =      4;
 Magenta  =    5;
 Brown  =      6;
 LightGray =   7;
 DarkGray  =    8;
 LightBlue =    9;
 LightGreen =  10;
 LightCyan  =  11;
 LightRed   =  12;
 LightMagenta= 13;
 Yellow   =    14;
 White   =     15;
 Blink   =    128;
const
  CurPgOffset : Word = 0;
  flag : Word = 0;
  Counter : Word = 0;
  TimerBeg = 16384;
  Timer : Word = TimerBeg;
  muslength : Word = 2220;
  oldml : Word = 2220;
  LifeValue : Word = $FFFF;
  OldInt1Ch : Pointer = NIL;

var
  PPal : Pointer;
  Font : Pointer;
  i : Word;
  PrevLife : Word;
  Mn : Integer;
Procedure SetFont;Assembler;
asm
    push es
    les  ax, Font {Óñòàíîâêà øðèôòà}
    push bp
    mov  bp, ax
    mov  ax,1100h       {ôóíêöèÿ: al = [00h, 10h] - óñòàíîâèòü}
    mov  bx,1000h       {ðàçìåð}
    mov  cx,256         {êîë-âî ñèìá}
    xor  dx,dx
    int  10h
    mov  ah,1           {Óñòàíîâèòü êóðñîð}
    mov  cx,1000h
    int  10h
    pop  bp
    pop	 es
end;
Procedure Sound(Freq : Word);Assembler;
asm
	mov	bx, sp
	mov	bx, ss:[bx+4]
	mov	ax, 34DDh
	mov	dx, 12h
	cmp	dx, bx
	jnb	@1
	div	bx
	mov	bx, ax
	in	al, 61h
	test	al, 3
	jnz	@2
	or	al, 3
	out	61h, al
	mov	al, 0B6h
	out	43h, al
@2:
	mov	al, bl
	out	42h, al
	mov	al, bh
	out	42h, al
@1:
end;
{------------------------}
Procedure NoSound;Assembler;
asm
	in	al, 61h
	and	al, 0FCh
	out	61h, al
end;
Procedure SetCurPage(Pg : Byte);
begin
  CurPgOffset := Pg*4000;
end;
Procedure SetViewPage(Pg : Byte);Assembler;
asm
  mov   al, byte ptr Pg
  mov   ah, 5
  int   10h
end;
Procedure CursorOff;Assembler;
asm
 mov ah, 1
 mov ch, $20
 int $10
end;
{------------------}
Procedure CursorOn;Assembler;
asm
 mov ah, 1
 mov ch, 6
 mov cl, 7
 int $10
end;
Procedure SetColorPal(Attr : Word); Assembler;
asm
  mov  ah, 0Bh
  mov  bx, word ptr Attr
  int  10h
end;
Procedure SetPalReg(reg, col : Byte);Assembler;
asm
  mov   ax, 1000h
  mov   bl, byte ptr reg
  mov   bh, byte ptr col
end;
Procedure SetBorderColReg(col : Byte);Assembler;
asm
  mov   ax, 1001h
  mov   bh, byte ptr col
end;
Procedure ToggleIntense_Blink(b : Byte);Assembler;
asm
  mov   bl, byte ptr b
  mov   ax, 1003h
  int   10h
end;
Procedure SetWidth8;Assembler;
asm
  mov   dx, 03C4h
  mov   al, 01h
  out   dx, al
  inc   dx
  in    al, dx
  and   al, 11111011b
  or    al, 00000001b
  out   dx, al
end;
Procedure SetWidth9;Assembler;
asm
  mov   dx, 03C4h
  mov   al, 01h
  out   dx, al
  inc   dx
  in    al, dx
  and   al, 0FEh
  out   dx, al
end;
Function KeyPressed : Boolean;Assembler;
asm
 mov ah, $0B
 int $21
end;
Procedure WaitRetrace;Assembler;
asm
	     mov  dx, 03DAh
@VRTL1:
	     in   al, dx
	     test al, 8
	     jnz  @VRTL1
@VRTL2:
	     in al, dx
	     test   al, 8
	     jnz     @VRTL2 {jnz ?}
	     ret
end;
Procedure ResetTimer; Assembler;
asm
    mov      cx, 0
    mov      dx, 1
    mov      ah, $86
    int      $15
    jnc       @1
    mov ah, 83h
    mov al, 1
    int 15h
@1:
end;
Procedure SetInt1Ch; Assembler;
asm
 push   es

 mov    ax, 351Ch
 int    21h
 mov    word ptr OldInt1Ch, bx
 mov    word ptr OldInt1Ch+2, es
 mov    word ptr @OI1Ch, bx
 mov    word ptr @OI1Ch+2, es

 pop    es

 mov    ax, 251Ch

 push   ds

 mov    dx, seg @int1Ch
 mov    ds, dx
 mov    dx, offset @int1Ch
 int    21h

 pop    ds

 ret

@int1Ch:
 push   ds
 push   ax

 mov    ax, seg flag
 mov    ds, ax
 add    word ptr flag, 800h
 inc    word ptr Counter
 dec    word ptr Timer
 dec    word ptr muslength
 jnz    @itsall
 mov    ax, oldml
 mov    muslength, ax
@itsall:
 pop    ax
 pop    ds
       db 02Eh, 0EAh {cs:jmp 00000000}
@OI1Ch :
 dd     0
{ iret}
end;
Procedure RestoreInt1Ch; Assembler;
asm
  push  ds
  lds   dx, OldInt1Ch
  mov   ax, 251Ch
  int   21h
  pop   ds
end;
Procedure SetFrame(c0, c1, c2, c3, c4, c5, c6, c7 : Byte); Assembler;
asm
  push  ds
  mov   ax, Seg CurPgOffset
  mov   ds, ax
  mov   di, word ptr CurPgOffset
  pop   ds
  push  es
  mov   ax, 0B800h
  mov   es, ax
  mov   al, 9
  mov   ah, c0
  stosw
  mov   al, 10
  mov   ah, c1
  mov   cx, 78
  rep   stosw
  mov   al, 11
  mov   ah, c2
  stosw
  push  di
  mov   al, 1Ah
  mov   ah, c7
  mov   cx, 23
@lp:
  stosw
  add   di, 2*(80-1)
  loop  @lp
  pop   di
  mov   al, 12
  mov   ah, c3
  mov   cx, 23
@lp1:
  add   di, 2*(80-1)
  stosw
  loop  @lp1
  mov   al, 15
  mov   ah, c6
  stosw
  mov  al, 14
  mov  ah, c5
  mov  cx, 78
  rep  stosw
  mov  al, 13
  mov  ah, c4
  stosw
  pop   es
end;
Function ReadKey : Byte; assembler;
asm
    xor ax,ax
    int 16h
end;
Procedure SetTxPoint(X,Y,ColorTx,BkColorTx:Byte;C:Char);Assembler;
asm
        mov     si, word ptr CurPgOffset
        push ds
        mov ax, $B800
        mov ds, ax

        xor ah, ah
	xor bh, bh
        mov bl, byte ptr x
	cmp bx, 80
	ja  @1

	mov al, byte ptr y
        cmp ax, 25
	ja  @1

        dec ax
	mov cl, 80
        mul cl
        dec bx
	add bx, ax

        mov cl, byte ptr ColorTx
        and cl, $8F
        mov dl, BkColorTx
        mov al, dl
        and dl, $7
	shl dl, 4
        and al, $80
	or  dl, al
	or  dl, cl

	mov al, byte ptr C
        mov ah, dl
	shl bx, 1
        add bx, si
        mov ds:[bx], ax
@1:
	pop ds
end;
Function ScanKey : Byte; Assembler;
asm
   in   al, 60h
end;
Procedure LineTx(X1, Y1, X2, Y2 : Byte; ColorTX, BkColor : Byte; C : Char);
var
  i : Integer;
  dx, dy, D : Real;
begin
  D := sqrt(sqr(X1-X2)+sqr(Y1-Y2));
  dX := (X2-X1)/D;
  dY := (Y2-Y1)/D;
  for i := 0 to Round(D) do
    SetTxPoint(X1 + Round(dX*i), Y1 + Round(dY*i), ColorTx, BkColor, C)
end;
Procedure FillBarTx(X1, Y1, X2, Y2, ChColor, BkChColor, FillChColor,
                    FillBkChColor : Byte; C, FillC : Char);
var
  i, j, X, Y : Byte;
begin
  if X1 360 then z := True else z := False;
    if z then
    begin
      A := Pi/2;
      Ya := Round(Y + RadY*sin(A));
      Yb := Round(Y + RadY*sin(Grad*180+A));
      for i := 0 to 180 do
       begin
        X1 := Round(X + RadX*cos(Grad*i+A));
	Y1 := Round(Y + RadY*sin(Grad*i+A));
        if (Y1>Yb) and (Y1 0 do;
   While flag = 0 do;
   Font := @Intro2;
   if KeyPressed then Break;
   if Random(65535) and 1 = 1 then
     MakeThreePhotos(17, 5);
   WaitRetrace;
   SetFont;
   While flag <> 0 do;
   While flag = 0 do;
   Font := @Intro1;
   WaitRetrace;
   SetFont;
  end;
  While KeyPressed do ReadKey;
  SetColorPal(0);{3, 6, 8 !}
  Font := @Intro2;
  WaitRetrace;
  SetFont;
  While not KeyPressed do
  begin
    if Counter and 4 = 4 then
       begin
	 Photo(Random(63) + 1, Random(11));
	 inc(Counter, 4);
       end;
  end;
  While KeyPressed do ReadKey;
end;
const
  Clor: Byte = LightRed;
  BkClor : Byte = Black+Blink;
  FrmClr : Byte = Red+Blink;
  Ydot : Byte = 0;

  GmOv : array[0..13] of Char = '(#0 N'' *.-7%- ';{èãðà çàêîí÷åíà}
  Prigf : array[0..16] of Char = '/0%$12 "+?%2'#0'(#03';{ÏÐÅÄÑÒÀÂËßÅÒ ÈÃÐÓ}
  Fantannik : array [0..12] of Char =#28#0'4 -2 --(*'#0#28;{" ÔÀÍÒÀÍÍÈÊ "}
  YourWish : array[0..16] of Char = '/.'#0'" 8%,3'#0'&%+ -(>';{ÏÎ ÂÀØÅÌÓ ÆÅËÀÍÈÞ}
  BgNewG : array[0..16] of Char = '- 7 2<'#0'-."3>'#0'(#03';{ÍÀ×ÀÒÜ ÍÎÂÓÞ ÈÃÐÓ}
  LoadG : array[0..13] of Char = ''' #03''(2<'#0'(#03';{ÇÀÃÐÓÇÈÒÜ ÈÃÐÓ}
  SaveG : array[0..13] of Char = '1.50 -(2<'#0'(#03';{ÑÎÕÐÀÍÈÒÜ ÈÃÐÓ}
  Pswd : array[0..5] of Char = '/ 0.+<';{ÏÀÐÎËÜ}
  ExitG : array[0..12] of Char = '";)2('#0'('''#0'(#0;';{ÂÛÉÒÈ ÈÇ ÈÃÐÛ}
  AreYouSure : array[0..17] of Char = '";'#0'3"%0%-;'#0#3'$'#0'-'#0#3'';{ÂÛ ÓÂÅÐÅÍÛ(Ä Í)?}
  {  WriteText(32, 14, 17, AreYouSure);
}
  ParG : array[0..13] of Char = '/ 0 ,%20;'#0'(#0;';{ÏÀÐÀÌÅÒÐÛ ÈÃÐÛ}
  HistG : array[0..6] of Char = '(12.0(?';{ÈÑÒÎÐÈß}
  AboutG : array[0..6] of Char = '.!'#0'(#0%';{ÎÁ ÈÃÐÅ}
  DemoG : array[0..3] of Char = '$%,.';{ÄÅÌÎ}
  CreG : array[0..108] of Char =
  '(#0 '#0'"'#0'4 -2 --(*'#0'"'#0'1.''$ - '#0'- '#0+
  '.1-."%'#0'"..!0 & %,;5'#0'/%01.- &%)'#0'"'#0'* 7%12"%'#0'-%!.+<8.)'#0'/0 *2(*('#0'"'#0'/0.#0 ,,(0." -((';
  {ÈÃÐÀ " ÔÀÍÒÀÍÍÈÊ " ÑÎÇÄÀÍÀ ÍÀ ÎÑÍÎÂÅ ÂÎÎÁÐÀÆÀÅÌÛÕ ÏÅÐÑÎÍÀÆÅÉ Â ÊÀ×ÅÑÒÂÅ ÍÅÁÎËÜØÎÉ ÏÐÀÊÒÈÊÈ Â ÏÐÎÃÐÀÌÌÈÐÎÂÀÍÈÈ}
  CprtG: array[0..12] of Char = ''#0'#.$'#0'8( 0';{2003 ÃÎÄ ØÈÀÐ}
{  WriteText(2, 15, 108, CreG);}
{  WriteText(2, 16, 12, CprtG);}
  RL : array[0..15] of Char = #9#10#11#12#13#14#15#26#27#28#29#30#26#27#28;
  {Ïàðàìåòðû èãðû:
  [Çâóê]
  [Óïðàâëåíèå]
  [?]}
Procedure WriteText(x, y, N : Byte;var S : array of Char);
var
  ij : Byte;
begin
  for ij := 0 to N do
    SetTxPoint(x+ij, y, Clor, BkClor, S[ij]);
end;
Procedure ChangeL; Assembler;
asm
	push ds
	push es
	mov  bl, byte ptr Ydot
	mov  ax, 0B800h
	mov  ds, ax
	mov  es, ax
	mov  al, 80*2
	mul  bl
	add  ax, 10*80*2+60
	cld
	mov  cx, 23
	mov  si, ax
	mov  di, ax
@next_char:
	lodsw
	xor  ah, 08h
	stosw
	loop @next_char
	pop  es
	pop  ds
end;

Procedure Markiz; Forward;
Function Menu : Integer;
var
  Sel : Integer;
begin
  SetColorPal(6);{3, 6, 8 !}
  SetFrame(FrmClr, FrmClr, FrmClr, FrmClr, FrmClr, FrmClr, FrmClr, FrmClr);
  FillBarTx(2, 2, 79, 24, LightGreen, Black, Brown, Blue, #27, #27);
  FillBarTx(30, 2, 50, 6, LightMagenta, Magenta, Brown, Black, #29, #29);
  FillBarTx(25, 8, 55, 21, Green, LightMagenta, Brown, Black+Blink, #29, #0);
  FillBarTx(25, 7, 55, 9, Green, LightMagenta, Green, LightMagenta, #29, #29);
  FillBarTx(15, 22, 65, 23, LightRed, Cyan, Green, LightMagenta, #29, #29);
  BkClor := Black;
  Clor := Yellow;
  WriteText(34, 3, 12, CprtG);
  Clor := Red;
  WriteText(32, 4, 16, Prigf);
  Clor := LightRed;
  WriteText(34, 5, 12, Fantannik);

  BkClor := Black+Blink;Clor := LightGreen;
  WriteText(32, 8, 16, YourWish);
  Clor := Magenta;
  WriteText(32, 11, 16, BgNewG);
  WriteText(32, 12, 13, LoadG);
  WriteText(32, 13, 13, SaveG);
  WriteText(32, 14, 5, Pswd);
  WriteText(32, 15, 13, ParG);
  WriteText(32, 16, 6, HistG);
  WriteText(32, 17, 6, AboutG);
  WriteText(32, 18, 3, DemoG);
  WriteText(32, 19, 12, ExitG);
  FadeIn;
  ChangeL;
  While KeyPressed do ReadKey;
  Clor := LightCyan;
  Sel := -1;
  Repeat
    SetTxPoint(28, Ydot+11, Clor, BkClor, RL[Counter shr 2 and $0F]);
    SetTxPoint(29, Ydot+11, Clor, BkClor, RL[Counter shr 1 and $0F]);
    SetTxPoint(30, Ydot+11, Clor, BkClor, RL[Counter and $07]);
    if Counter and 8 = 8 then
    begin
      SetColorPal(Random(16));{3, 6, 8 !}
      FrmClr := Random(16);
      SetFrame(FrmClr, FrmClr, FrmClr, FrmClr, FrmClr, FrmClr, FrmClr, FrmClr);
      inc(Counter, 8);
    end;
    if Counter and 32 = 32 then
    begin
      inc(Counter, 32);
    end;
    if KeyPressed then
    begin
     SetTxPoint(28, Ydot+11, Clor, BkClor, #0);
     SetTxPoint(29, Ydot+11, Clor, BkClor, #0);
     SetTxPoint(30, Ydot+11, Clor, BkClor, #0);
     case ScanKey of
      72{Up}:
       begin
	ChangeL;
	if Ydot=0 then Ydot := 8 else dec(Ydot);
	ChangeL;
       end;
      80{Down}:
       begin
	ChangeL;
	if Ydot=8 then Ydot := 0 else	inc(Ydot);
	ChangeL;
       end;
      28{Enter}: Sel := Ydot;
      60:{F2}Sel := 1;
      61:{F3}Sel := 2;
      68{F10}: Sel := 8;
      1{Esc}: Sel := 8;
     end;
     While KeyPressed do ReadKey;
    end;
  Until Sel<>-1;
  Menu := Sel;
  FadeOut;
end;
const
 S1: array [0..20] of Char = ' ---==÷ Øèàð ÷==--- ';
 S2: array [0..8] of Char = 'ÔÀÍÒÀÍÍÈÊ';
 Cp1: array [0..46] of Char = '  ÞÛßßÛÜ  ÞßÛ    ÜÜÛßßßßßÛÜÜÜÜ      ÜÜÜ    ÜÜÜÜ';
 Cp2: array [0..49] of Char = '  Û     ß ÞÞÛ ÜÛßß        Ü  ßßÛÜ    ÛÛÛÜÜÛß  ßßßÛ';
 Cp3: array [0..40] of Char = '  ßÛ      ÝÞÛ     ÞÛÜ    ÞÛÝ    ÛÛÜÜ  ßÛÜ';
 Cp4: array [0..42] of Char = '   ßÛÜÜ   ÝÞÛßßÛÜ   ÛÜ   ÜÛÝ  ÜÛß  ßÛÜ  ßÛÜ';
 Cp5: array [0..42] of Char = 'Ü     ßÛÜ ÝÞÛ   ßÛ   ÛÜÜÜÛß  ÜÛ      Û   ßÛ';
 Cp6: array [0..43] of Char = 'ßÛ      Û  ÞÛ    Û      ÜÛ  ÜÛ       Û    ÛÜ';
 Cp7: array [0..45] of Char = ' ßÛ  ÜÜÛß  ÞÛ    Û     ÜÛ   ßÛÜ      ÛÜ    ßÛÜ';
 Cp8: array [0..45] of Char = '  ßßßß  ÜÜÜ ß    ßß   ÜÛ      ßßÛÜÜÛßßßÛÜÜÛ ÜÛ';
 Cp9: array [0..22] of Char = '          ßßßßßßÛÜÜÛßßß';
Procedure PostScriptum;
begin
  ToggleIntense_Blink(0);
  FillBarTx(1, 1, 80, 25, Green, Black, Green, Black, #219, #219);
  FillBarTx(12, 7, 67, 21, LightRed, Green, LightGreen, Black, #219, #219);
  FillBarTx(13, 8, 66, 20, Yellow, Green, LightGreen, Black, #219, #219);
  FillBarTx(14, 9, 65, 19, LightRed, Green, LightGreen, Black, #177, #219);
  LineTx(2, 2, 79, 2, White, Green, #196);
  LineTx(2, 4, 79, 4, White, Green, #196);
  LineTx(2, 2, 2, 4, White, Green, #179);
  LineTx(79, 2, 79, 4, White, Green, #179);
  SetTxPoint(2, 2, White, Green, #218);
  SetTxPoint(2, 4, White, Green, #192);
  SetTxPoint(79, 2, White, Green, #191);
  SetTxPoint(79, 4, White, Green, #217);
  Clor := LightBlue; BkClor := Green+Blink;
  WriteText(31, 3, 20, S1);
  Clor := LightRed; BkClor := LightGray+Blink;
  WriteText(36, 5, 8, S2);
  Clor := Blue; BkClor := LightGreen+Blink;
  WriteText(15, 10, 46, Cp1);
  WriteText(15, 11, 49, Cp2);
  WriteText(15, 12, 40, Cp3);
  WriteText(15, 13, 42, Cp4);
  WriteText(15, 14, 42, Cp5);
  WriteText(15, 15, 43, Cp6);
  WriteText(15, 16, 45, Cp7);
  WriteText(15, 17, 45, Cp8);
  WriteText(15, 18, 22, Cp9);
  FadeIn;
end;
Procedure GameOver;
var
  ij : Word;
begin
  for ij := 20 downto 1 do
    begin
      Sound(ij*256);
      flag := 0;
      While flag = 0 do;
    end;
  NoSound;
  FillBarTx(32, 11, 49, 15, Cyan, Black+Blink, Brown, Black+Blink, #30, #0);{Life Field}
  for ij := 0 to 13 do
    SetTxPoint(34+ij, 13, LightRed, Black+Blink, GmOv[ij]);
  While KeyPressed do ReadKey;
  ReadKey;
  While KeyPressed do ReadKey;
end;
Procedure Life;
begin {0E1h}
  if LifeValue<>PrevLife then
   asm
      mov  ax, word ptr LifeValue
      mov  word ptr PrevLife, ax
      mov  cx, ax
      mov  dx, ax
      shr  dx, 8
      and  dl, 07h
      inc  dl
      shr  cx, 11
      mov  bl, 1Fh
      sub  bl, cl

      push es
      mov  ax, 0B800h
      mov  es, ax
      mov  di, 2*(80*22+23)
      mov  ax, 04A08h
      push cx
      rep stosw
      mov  al, dl
      stosw
      mov  cl, bl
      xor  al, al
      rep  stosw
      pop  cx

      add  di, 96
      mov  ax, 0CA08h
      rep stosw
      mov  al, dl
      stosw
      mov  cl, bl
      xor  al, al
      rep  stosw
      pop  es
   end;
end;
Procedure Traven; Assembler;
asm
   push ds
   push cs
   pop ds

   mov cx, 1000
@begna:
   mov al, 7
   call @doing
   mov al, 0
   call @doing
   loop @begna
{   mov ah, 1
   int 16h

   jz @begna
   mov ah, 0
   int 16h}

{   cmp al, 1Bh
   jnz @begna}
   pop ds
   ret

@doing:
   push ax
   mov dx, 3DAh
   in al, dx
   mov dx, 3C0h
   mov al, 13h
   out dx, al
   pop ax
   out dx, al
   mov dx, 3DAh
   in al, dx
   mov dx, 3C0h
   mov al, 20h
   out dx, al

   retn
end;
Procedure Waver; Assembler;
asm
	jmp	@loc_0_117

@sub_0_103:
		push	ax
		mov	dx, bx
		in	al, dx
		mov	dx, si
		mov	al, 13h
		out	dx, al
		pop	ax
		out	dx, al
		mov	dx, bx
		in	al, dx
		mov	dx, si
		mov	al, 20h
		out	dx, al
		retn	

@loc_0_117:
		push	dx
		push	cx
		push	ax
		push	si
		push	bx
		mov	si, 3C0h
		mov	bx, 3DAh
		mov	ch, bh

@loc_0_124:
		push	cx
		mov	al, 7
		call	@sub_0_103
		mov	cx, 3E8h
		push	cx

@loc_0_12E:
		loop	@loc_0_12E
		mov	al, 0
		call	@sub_0_103
		pop	cx

@loc_0_136:
		loop	@loc_0_136
		pop	cx
		loop	@loc_0_124
		pop	bx
		pop	si
		pop	ax
		pop	cx
		pop	dx
{		mov	ah, 0
		int	16h}

                ret
end;
Procedure Markiz; Assembler;
asm
                push    ds
@start:
		push	cs
		pop	ds
		mov	ax, 1130h
		sub	cx, cx
		int	10h

{		cmp	cl, 0Eh
		jnb	@loc_0_117}
                jmp	@loc_0_117

@loc_0_10E:
                pop     ds
{@_loc_0_10E:
                pop     ds}
                retn                     {Âûõîä èç ïðîöåäóðû â èãðó}

@loc_0_117:
		call	@sub_0_27C
		mov	byte ptr cs:@byte_0_294, cl
		mov	ah, 0Fh
		int	10h

		or	bh, bh
		jz	@loc_0_12A
		jmp	@loc_0_1BB

@loc_0_12A:
		xor	ah, 50h
		jz	@loc_0_132
		jmp	@loc_0_1BB

@loc_0_132:
		sub	al, 4
		js	@loc_0_139
		jmp	@loc_0_1BB

@loc_0_139:
		mov	byte ptr @byte_0_292, 1
		mov	dx, 3D4h
		push	dx
		mov	ax, 9

@loc_0_148:
		xor	cx, cx
		cmp	byte ptr @byte_0_293, 40h
		jnz	@loc_0_164
		mov	byte ptr @byte_0_293, 0
		sub	word ptr @word_0_26E, 0FFh
		cmp	word ptr @word_0_26E, 0FFh
		jbe	@loc_0_1B1

@loc_0_164:
		inc	byte ptr @byte_0_293
		cmp	byte ptr @byte_0_292, 1
		jz	@loc_0_17A
		dec	ah
		jnz	@loc_0_186
		mov	byte ptr @byte_0_292, 1
		jmp	@loc_0_186

@loc_0_17A:
		inc	ah
		cmp	ah, 20h
		jb	@loc_0_186
		mov	byte ptr @byte_0_292, 0

@loc_0_186:
		push	dx
		push	cx
		xor	dx, dx
		mov	dl, ah
		mov	cl, 5
		shl	dx, cl
		call	@sub_0_233
		pop	cx
		pop	dx
		out	dx, ax
		call	@loc_0_266
		call	@sub_0_25D
{		push	ax}
{		mov	ah, 1
		int	16h}

{		jz	@loc_0_1AE}
{		xor	ax, ax
		int	16h

		cmp	al, 1Bh}
{		jmp	@loc_0_1AE}
{		jnz	@loc_0_1AE}
{		jmp	@_loc_0_10E}

@loc_0_1AE:
{		pop	ax}
		loop	@loc_0_148

@loc_0_1B1:
		mov	ah, byte ptr @byte_0_294
		dec	ah
		mov	al, 9
		pop	dx
		out	dx, ax

@loc_0_1BB:
		call	@sub_0_227
		call	@sub_0_27C
		jmp	@start


@loc_0_1FB:
		lodsb
		cmp	al, 0FFh
		jz	@loc_0_225
		or	al, al
		jnz	@loc_0_20C
		add	bx, 0A0h
		mov	di, bx
		jmp	@loc_0_222

@loc_0_20C:
		cmp	al, 10h
		jnb	@loc_0_222
		cmp	al, 2
		jnz	@loc_0_216
		xor	al, al

@loc_0_216:
		xchg	ah, al
		lodsb
		cmp	si, 2EEh
		jnb	@loc_0_222
		or	ah, 50h

@loc_0_222:
		stosw
		jmp	@loc_0_1FB

@loc_0_225:
		pop	bx
		retn

@sub_0_227:
{Çàêîììåíòèðîâàííûé êóñîê êîäà îòâå÷àåò çà öèêë äî íàæàòèÿ êëàâèøè Esc}
{		xor	ax, ax
		int	16h

		cmp	al, 1Bh
		jnz	@locret_0_232}
                pop     ax {ïîñëå call}
		jmp	@loc_0_10E {jmp to Exit}

@locret_0_232:
		retn


@sub_0_233:
		push	ax
		push	bx
		push	dx
		mov	bx, dx
		mov	ax, 34DDh
		mov	dx, 12h
		cmp	dx, bx
		jnb	@loc_0_259
		div	bx
		mov	bx, ax
		in	al, 61h
		or	al, 3
		out	61h, al

		mov	al, 0Bh
		mov	dx, 43h
		out	dx, al
		dec	dx
		mov	al, bl
		out	dx, al
		mov	al, bh
		out	dx, al

@loc_0_259:
		pop	dx
		pop	bx
		pop	ax
		retn

@sub_0_25D:
		push	ax
		in	al, 61h
		and	al, 0FCh
		out	61h, al
		pop	ax
		retn	


@loc_0_266:
		push	ax
		push	cx
		push	dx
		mov	ah, 86h
		xor	cx, cx

		db 0BAh
@word_0_26E:	dw 1000h
		db  52h
		db 0CDh
		db  15h
		db  59h
		db  90h
		db  90h
		db 0E2h
		db 0FCh
		db  5Ah
		db  59h
		db  58h
		db 0C3h


@sub_0_27C:
		mov	byte ptr cs:@byte_0_291, 0FAh
		mov	byte ptr cs:@byte_0_293, 0
		mov	word ptr cs:@word_0_26E, 1000h
		retn

		db  9Fh
@byte_0_291:	db 0FAh
@byte_0_292:	db 0
@byte_0_293:	db 0
@byte_0_294:	db 8
end;
Procedure Game;
begin
  PrevLife := 0;
  LifeValue := $FFFF;
  SetColorPal(8);{3, 6, 8 !}
  SetFrame(LightRed+Blink, LightRed+Blink, LightRed+Blink, LightRed+Blink,
	    LightRed+Blink, LightRed+Blink, LightRed+Blink, LightRed+Blink);

  FillBarTx(2, 2, 79, 17, 0, LightBlue+Blink, 0, LightBlue+Blink, #0, #0);

  LineTx(2, 18, 79, 18, Green+Blink, LightBlue, #29);
  FillBarTx(2, 19, 79, 24, Brown, Black+Blink, Brown, Black+Blink, #30, #30);
  FillBarTx(23, 22, 56, 25, Cyan, Black+Blink, Brown, Black+Blink, #28, #0);{Life Field}
  Sun(75, 4);
{  SetColorPal(256+0);}
  ZX := Random(70)+3;
  ZY := Random(6)+12;
  ZbX := Random(78)+2;
  ZbY := Random(2)+16;
  dZX := 0;
  dZY := 0;
  dZbX := 0;
  dZbY := 0;
  FadeIn;
  Timer := TimerBeg;
  While ScanKey <> $81 do
  begin
    SunRays(75, 4);
    case ScanKey of
     75: dZX := -1;
     77: dZX := 1;
     72: dZY := -1;
     80: dZY := 1;
     75+$80:dZX := 0;
     77+$80:dZX := 0;
     72+$80:dZY := 0;
     80+$80:dZY := 0;
    end;
     dZbX := Round(8.05*Random-4);
     dZbY := Round(4.025*Random-2);
     if (Abs(ZbX-ZX)<2) and (Abs(ZbY-ZY)<5) then if LifeValue<>0 then dec(LifeValue);
    if Counter>=1 then
    begin
      Time;
      PlayMusic;
      Counter := 0;

{      Waver;
      Traven;}

      FillBarTx(ZX-1, ZY-3, ZX+1, ZY, 0, LightBlue+Blink, 0, LightBlue+Blink, #0, #0);
      FillBarTx(ZbX-1, ZbY-3, ZbX+1, ZbY, 0, LightBlue+Blink, 0, LightBlue+Blink, #0, #0);
{      ZX := ZX+ Round(8*Random-4)dZX;
      ZY := ZY+ Round(8*Random-4)dZY;}
      if (ZX+dZX<79) and (ZX+dZX>=3) then ZX := ZX+dZX;
      if (ZY+dZY<18) and (ZY+dZY>9) then ZY := ZY+dZY;
      if (ZbX+dZbX<79) and (ZbX+dZbX>=3) then ZbX := ZbX+dZbX;
      if (ZbY+dZbY<18) and (ZbY+dZbY>9) then ZbY := ZbY+dZbY;
      ZMan(ZbX, ZbY);
      ZMan(ZX, ZY);
      Life;
      if LifeValue=0 then
	begin
	 GameOver;
	 Break;
	end;
      if LifeValue<>65535 then if (dZX or dZY)=0 then
	if (65535-LifeValue>=100) then inc(LifeValue, 100)
	  else LifeValue := 65535;
    end;
    if KeyPressed then ReadKey;
  end;
  NoSound;
  FadeOut;
end;
begin
  asm
    mov ax, 3h
    int 10h
  end;
  Randomize;
  ResetTimer;
  CursorOff;
  GetMem(PPal, 256*6);
  SetInt1Ch;
  SetWidth8;
{  Set80x30;}
{  SetViewPage(0);
  SetCurPage(0);}
  ToggleIntense_Blink(0);
  ReadPalette(0);
  ReadPalette($300);
  Intro;
  Markiz;
  Markiz;
  Markiz;
  FadeOut;
{  SetWidth8;}
{  Set80x30;}
{  SetViewPage(0);
  SetCurPage(0);}
  Font := @Picts;
  SetFont;
  Repeat
   Mn := Menu;
   case Mn of
     0 : Game;
   end;
  Until Mn=8;
  RestoreInt1Ch;
  FadeOut;
{  WritePalette($300);}
  FreeMem(PPal, 256*6);
  SetWidth9;
  CursorOn;
  asm
    mov ax, 03h
    int 10h
  end;
  PostScriptum;
  Markiz;
end.
(*
Âíèìàíèå! Íåîáõîäèìî Numlock ïåðåâîäèòü â ñîñòîÿíèå OFF! Ïðîãðàììíî!

ßçûê ÐóÑè (Ðóñü)
Îäèí ñêðèïò íà íåñêîëüêî îáúåêòîâ
Ýêðàí : ñâÿçü ñ äðóãèìè, íîìåð øðèôòà äëÿ îáúåêòîâ.
Îáúåêò : Ñâîéñòâà, èçîáðàæåíèå, äëÿ äèíàìè÷åñêèõ - äâèæåíèå è êîìàíäû.
[äåðåâî, ñòîë, ñòóë, ëåñòíèöà, ðàçäâ. ìîñò, òåëåãà êàòÿùàÿñÿ, êàíàòû, ïóëè, äâåðè,
"ðàçóìíûå" îáúåêòû], îïàñíîñòü (ëè), åñëè îïàñíûå - ñêîëüêî ïðè âç/ä îòíèìàþò
ýíåðãèè, çàïàñ ýíåðãèè ó ñàìèõ (æèâûõ èëè ëîìàþùèõñÿ) îáúåêòîâ,
íà÷àëüíîå íàïðàâëåíèå(ì. çàäàâàòü êîìàíäàìè äð îáúåêòîâ! - ÏÓËß)
îðóæèå, ïåðåíîñèìûå îáúåêòû - êëþ÷è è ò.ï.

Ïðèìåð íà ÐóÑè :

Îáúåêò(Ëåñòíèöà){
}

Îáúåêò(ÓìíàÿÏóëÿ){
	ïîêà/*ïîâòîðÿòü äî*/(ýíåðãèÿ...) //-ì á îäíà êîìàíäà ñ âîçâðàòîì
	//('ïîâòîðÿòü')
	îáíàðóæèòü_îáúåêò(ãåðîé);
''	ïîâò''
	øàã '' 5 ðàç;//âîçìîæíî âûïîëíåíèå â âèäå îäíîé èëè 2-õ êìä - 1 - 2 "òàêòà"
}
Îáúåêò(ÃëóïàÿÏóëÿ){	// ñîñòîèò èç îäíîãî ñèìâîëà - ðèñóíêà
	ïîêà(ýíåðãèÿ>0){//ïðåäïîëàãàþ, ÷òî ïðè ñòîëêíîâåíèè ñ äðóãèìè îáúåêàìè
	//(èëè òîëüêî ãåðîåì) ýíåðãèÿ óáûâàåò
	øàã;
	}(!! îáÿçàòåëüíà ãèáåëü îáúåêòà ñðàçó æå ïîñëå òîãîÞ êàê ýíåðãèÿ=0!)
}

-=-=-=-=-=-=-=-=-=-Äîïîëíåíèå-=-=-=-=-=-=-=-=-=-=-

ñêðèïò{
	ïîèñê();
	øàã();
	æäè(4);//æäàòü
//	.....
}

ñêðèïò ÷åë1{
	ôîðìàíà÷();
//	...
	ì¸ðòâôîðì();
}
óìí_ïóëÿ{
	ïîèñê();
	ïîêà íå ïîïàë {		//ïîêà íå öåëü...
		ïîèñê();
		øàã();
	};
}
ãëóï_ïóëÿ{
	ïîèñê();
	øàã();
//	ïîêà ...
//	...
}

{
	ïîèñê();
	ñîçäîáúåêò(ãëóï_ïóëÿ);
//	...
}

//ñëåäôîðìà();
//åñëè ...; ïîêà ...; äî...
//ïîêà [?îáúåêò_èìÿîáúåêòà].æèçíü>0	...

îáúåêò ïóëÿ{
//...
}

ÓñòàíîÂðåìÿ(){...}
ÎñòàíîÂðåìÿ(){...}
è ò. ï.
++++++++++++++
Îäèí êîä - äëÿ ÏÎÂÒÎÐ, ÄÎ ÆÈÇÍÜ=0 è ò.ï.
îòíîñèòåëüíûé ïåðåõîä-ñëîâî, 3 áàéòà

îäèí è òîò æå ñêðèïò â ïàìÿòè-äëÿ ðàçíûõ îáúåêòîâ ("áîòîâ")
Ðàçíûå óêàçàòåëè ñìåùåíèÿ â êîäå, ðàçíûå ÿ÷åéêè
áåðóòñÿ èç [.sle, .sma]-ôàéëîâ.
*)

Íàçàä