Unit Burn;

Interface

Procedure Init (method : word);

Procedure Burnit (image,dest : word);

Procedure Deinit;

Implementation

uses crt,gfx3,makes;

var
i,back2,backpage : word;
qeen : word;
peek : byte;


procedure fire(Video : Word);assembler;
asm
  mov ax,Video
  mov es,ax
  mov di,1*320
  mov cx,320*198
    @fl1:
    xor bx,bx
    mov bl,byte ptr es:[di]
    mov ax,bx
    mov bl,byte ptr es:[di-1]
    add ax,bx
    mov bl,byte ptr es:[di+1]
    add ax,bx
    mov bl,byte ptr es:[di+320]
    add ax,bx
    shr ax,2
    jz @fl2
    dec al
    @fl2:
    stosb
    dec cx
  jnz @fl1
end;

procedure firelineupleft(Video,a,s : word);assembler;
asm
  mov ax,Video
  mov es,ax
  mov di,a
  mov cx,s
    @fl1:
    xor bx,bx
    mov bl,byte ptr es:[di]
    mov ax,bx
    mov bl,byte ptr es:[di-1]
    add ax,bx
    mov bl,byte ptr es:[di+1]
    add ax,bx
    mov bl,byte ptr es:[di+320]
    add ax,bx
    shr ax,2
    jz @fl2
    dec al
    @fl2:
    stosb
    dec cx
  jnz @fl1
end;

procedure firelineupright(Video,a,s : word);assembler;
asm
  mov ax,Video
  mov es,ax
  mov di,a
  mov cx,s
    @fl1:
    xor bx,bx
    mov bl,byte ptr es:[di]
    mov ax,bx
    mov bl,byte ptr es:[di-1]
    add ax,bx
    mov bl,byte ptr es:[di  ]
    add ax,bx
    mov bl,byte ptr es:[di+320]
    add ax,bx
    shr ax,2
    jz @fl2
    dec al
    @fl2:
    stosb
    dec cx
  jnz @fl1
end;


procedure firelinedownright(Video,a,s : word);assembler;
asm
  mov ax,Video
  mov es,ax
  mov di,a
  mov cx,s
    @fl1:
    xor bx,bx
    mov bl,byte ptr es:[di]
    mov ax,bx
    mov bl,byte ptr es:[di-1]
    add ax,bx
    mov bl,byte ptr es:[di ]
    add ax,bx
    mov bl,byte ptr es:[di-320]
    add ax,bx
    shr ax,2
    jz @fl2
    dec al
    @fl2:
    stosb
    dec cx
  jnz @fl1
end;

procedure firelinedownleft(Video,a,s : word);assembler;
asm
  mov ax,Video
  mov es,ax
  mov di,a
  mov cx,s
    @fl1:
    xor bx,bx
    mov bl,byte ptr es:[di]
    mov ax,bx
    mov bl,byte ptr es:[di]
    add ax,bx
    mov bl,byte ptr es:[di+1]
    add ax,bx
    mov bl,byte ptr es:[di-320]
    add ax,bx
    shr ax,2
    jz @fl2
    dec al
    @fl2:
    stosb
    dec cx
  jnz @fl1
end;

Procedure hboxclipasm(x,y,s,ys,xd,yd : integer;source,dest : word);
var
rSI,rDI         : word;
i,i2,size,Xoffs : integer;

Begin
Xoffs:=0;
size:=s;

if (xd<320) and ((xd+s)>0) then Begin

if xd<0 then Begin
             XOffs:=-xd;
             size:=s-Xoffs;
            End;

if xd+s>320 then Begin
                 Xoffs:=0;
                 Size:=320-xd;
                End;

{for i2:=0 to ys-1 do begin
rsi:=(y+i2)*320+x+Xoffs;
rdi:=(yd+i2)*320+xd+xoffs;

for i:=0 to size-1 do mem [dest:rdi+i]:=mem[source:rsi+i];
end;}
asm
push ds

mov ds,source
mov es,dest

mov cx,ys
mov bx,y
mov dx,yd

@loopa:
  mov si,bx
  add si,x
  add si,xoffs

  mov di,dx
  add di,xd
  add di,xoffs

  push cx
  mov cx,size

@loopb:
  {mov es,source}
  mov al,ds:[si]

  cmp al,0
  je @skip

  {mov es,dest}
  mov es:[di],al

  @skip:
  inc si
  inc di
loop @loopb
  pop cx

  add bx,320
  add dx,320
loop @loopa
pop ds
end;
end;
End;



function malloc (s : word):Word;
var
ptemp:pointer;

Begin
Getmem (Ptemp,s);
malloc:=Seg(Ptemp^);
End;


Procedure Init (method : word);
Begin
backpage:=malloc($ffff);
back2:=malloc ($ffff);

{for i:=0 to 319 do mem[image:i]:=0;
for i:=0 to 319 do mem[image:199*320+i]:=0;}

case method of
1 : makesurf1 (backpage,256-64);
2 : makesurf2 (backpage,256-64);
3 : makesurf3 (backpage,256-64);
4 : makesurf4 (backpage,256-64);
5 : makesurf5 (backpage,256-64);
6 : makesurf6 (backpage,256-64);
End;
qeen:=0;
End;

Procedure Burnit (image,dest : word);
Begin
if qeen<260 then inc (qeen);

for i:=1 to 99 do Begin
                    firelineupLEFT    (back2,i*320,160);
                    firelineupRIGHT   (back2,i*320+160,160);
                    firelinedownLEFT  (back2,i*320+31680,160);
                    firelinedownRIGHT (back2,i*320+31680+160,160);
                   End;

asm
       mov es,backpage
       mov di,i
       mov al,es:[di]
       mov peek,al
       mov cx,64000
       xor di,di

@loopa:
       mov es,backpage
       xor ah,ah
       mov al,es:[di]
       add ax,0
       cmp ax,qeen
jb @skip                                {if peek>q+30 then}
       mov es,image
       mov al,es:[di]
       mov es,back2
       mov es:[di],al
@skip:
      inc di
loop @loopa
end;


flip32 (back2,dest);
end;

Procedure DEInit;
Begin
freemem (ptr(back2,0),$ffff);
freemem (ptr(backpage,0),$ffff);
End;


Begin
ENd.
