;-----------------------------------------------------------------
;
;ZZZZZZZZ   OOOOOO   M      M  BBBBBBB   III  EEEEEEEE   SSSSSS
;      Z   O      O  MM    MM  B      B   I   E         S      S
;     Z    O      O  M M  M M  B      B   I   E         S
;    Z     O      O  M  MM  M  BBBBBBB    I   EEEEE      SSSSSS
;   Z      O      O  M      M  B      B   I   E                S
;  Z       O      O  M      M  B      B   I   E                S
; Z        O      O  M      M  B      B   I   E         S      S
;ZZZZZZZZ   OOOOOO   M      M  BBBBBBB   III  EEEEEEEE   SSSSSS
;
;                              22222222
; Written By                          2      AGA ONLY!!!
;   Paul Andrews                      2     (BUY A 1200!)
;                              22222222
;    In                        2
;   Blitz ][                   2
;    (shock horror!!)          22222222
;
;
;
;Release Version Of source code - Rude bits and cheat modes hidden
;-----------------------------------------------------------------


WBStartup
rad.f=Pi/180
;------------------------------------------------------------
.inittypes

NEWTYPE.coor
    x.w
    y.w
End NEWTYPE

NEWTYPE .dribble
    go.w
    x.q
    y.q
    life.w
End NEWTYPE

NEWTYPE .blood
    go.w
    life.w
    x.q
    y.q
    vx.q
    vy.q
    bot.w
    do.w
End NEWTYPE

NEWTYPE .zombie
    here.w
    x.q     ;top left
    y.w
    w.w
    h.w
    vx.q
    hits.q
    typ.w   ;type..
    tim.w
    fr.w    ;current frame
    spd.w   ;frame count speed
    cnt.w
End NEWTYPE

;------------------------------------------------------------
.initmacs

Runerrsoff

Function.w getred{num.w,copaddr.l}

    UNLK a4
    MOVEM.l a0-a2,-(a7)
    MOVE.l  d1,a0       ;a0=coplist type
    MOVE.l  8(a0),a1    ;start of colours (106,..,180,...)
    MOVE.w  38(a0),d2   ;length of 1 bank (hi/lo)
    MOVE.w  d2,d3       ;keep for later
    MOVE.w  d0,d1       ;num
    LSR.w   #5,d1       ;bank #
    MULU    d1,d2       ;offset to correct bank
    ADD.l   d2,a1       ;start of correct bank (106,..,180,..)
    AND.w   #31,d0      ;colour in this bank
    MOVE.l  a1,a2
    ADDQ.l  #4,a1       ;hi bank colour 0 (skip 106)
    LSR.w   #1,d3       ;half a bank
    ADD.w   d3,a2       ;lo bank start
    ADDQ.l  #4,a2       ;lo bank colour 0 (skip 106)
    LSL.w   #2,d0       ;offset to colour..
    ADD.w   d0,a1       ;colour hi
    ADD.w   d0,a2       ;colour lo

    MOVEQ   #0,d0
    MOVE.w  2(a1),d0    ;hi
    MOVEQ   #0,d1
    MOVE.w  2(a2),d1    ;lo

    AND.w   #$0f00,d0
    AND.w   #$0f00,d1
    LSR.w   #4,d0
    LSR.w   #8,d1
    OR.w    d1,d0


    MOVEM.l (a7)+,a0-a2
    RTS
End Function
;-----------------
Function.w getgreen{num.w,copaddr.l}

    UNLK a4
    MOVEM.l a0-a2,-(a7)
    MOVE.l  d1,a0       ;a0=coplist type
    MOVE.l  8(a0),a1    ;start of colours (106,..,180,...)
    MOVE.w  38(a0),d2   ;length of 1 bank (hi/lo)
    MOVE.w  d2,d3       ;keep for later
    MOVE.w  d0,d1       ;num
    LSR.w   #5,d1       ;bank #
    MULU    d1,d2       ;offset to correct bank
    ADD.l   d2,a1       ;start of correct bank (106,..,180,..)
    AND.w   #31,d0      ;colour in this bank
    MOVE.l  a1,a2
    ADDQ.l  #4,a1       ;hi bank colour 0 (skip 106)
    LSR.w   #1,d3       ;half a bank
    ADD.w   d3,a2       ;lo bank start
    ADDQ.l  #4,a2       ;lo bank colour 0 (skip 106)
    LSL.w   #2,d0       ;offset to colour..
    ADD.w   d0,a1       ;colour hi
    ADD.w   d0,a2       ;colour lo

    MOVEQ   #0,d0
    MOVE.w  2(a1),d0    ;hi
    MOVEQ   #0,d1
    MOVE.w  2(a2),d1    ;lo

    AND.w   #$00f0,d0
    AND.w   #$00f0,d1
    LSR.w   #4,d1
    OR.w    d1,d0

    MOVEM.l (a7)+,a0-a2
    RTS
End Function
;-----------------
Function.w getblue{num.w,copaddr.l}

    UNLK a4
    MOVEM.l a0-a2,-(a7)
    MOVE.l  d1,a0       ;a0=coplist type
    MOVE.l  8(a0),a1    ;start of colours (106,..,180,...)
    MOVE.w  38(a0),d2   ;length of 1 bank (hi/lo)
    MOVE.w  d2,d3       ;keep for later
    MOVE.w  d0,d1       ;num
    LSR.w   #5,d1       ;bank #
    MULU    d1,d2       ;offset to correct bank
    ADD.l   d2,a1       ;start of correct bank (106,..,180,..)
    AND.w   #31,d0      ;colour in this bank
    MOVE.l  a1,a2
    ADDQ.l  #4,a1       ;hi bank colour 0 (skip 106)
    LSR.w   #1,d3       ;half a bank
    ADD.w   d3,a2       ;lo bank start
    ADDQ.l  #4,a2       ;lo bank colour 0 (skip 106)
    LSL.w   #2,d0       ;offset to colour..
    ADD.w   d0,a1       ;colour hi
    ADD.w   d0,a2       ;colour lo

    MOVEQ   #0,d0
    MOVE.w  2(a1),d0    ;hi
    MOVEQ   #0,d1
    MOVE.w  2(a2),d1    ;lo

    AND.w   #$000f,d0
    AND.w   #$000f,d1
    LSL.w   #4,d0
    OR.w    d1,d0

    MOVEM.l (a7)+,a0-a2
    RTS
End Function
;-----------------
Statement setrgb{num.w,copaddr.l,r.w,g.w,b.w}

    UNLK a4
    MOVEM.l d5-d7/a0-a2,-(a7)

    MOVE.w  d2,d5
    MOVE.w  d3,d6
    MOVE.w  d4,d7       ;save rgb..

    MOVE.l  d1,a0       ;a0=coplist type
    MOVE.l  8(a0),a1    ;start of colours (106,..,180,...)
    MOVE.w  38(a0),d2   ;length of 1 bank (hi/lo)
    MOVE.w  d2,d3       ;keep for later
    MOVE.w  d0,d1       ;num
    LSR.w   #5,d1       ;bank #
    MULU    d1,d2       ;offset to correct bank
    ADD.l   d2,a1       ;start of correct bank (106,..,180,..)
    AND.w   #31,d0      ;colour in this bank
    MOVE.l  a1,a2
    ADDQ.l  #4,a1       ;hi bank colour 0 (skip 106)
    LSR.w   #1,d3       ;half a bank
    ADD.w   d3,a2       ;lo bank start
    ADDQ.l  #4,a2       ;lo bank colour 0 (skip 106)
    LSL.w   #2,d0       ;offset to colour..
    ADD.w   d0,a1       ;colour hi
    ADD.w   d0,a2       ;colour lo

    MOVEQ   #0,d0
    MOVEQ   #0,d1

    MOVE.w  d5,d2       ;red
    AND.w   #$f0,d2     ;hi part
    MOVE.w  d5,d3
    AND.w   #$f,d3      ;lo part
    LSL.w   #4,d2
    LSL.w   #8,d3
    OR.w    d2,d0
    OR.w    d3,d1

    MOVE.w  d6,d2       ;green
    AND.w   #$f0,d2     ;hi part
    MOVE.w  d6,d3
    AND.w   #$f,d3      ;lo part
    LSL.w   #4,d3
    OR.w    d2,d0
    OR.w    d3,d1

    MOVE.w  d7,d2       ;blue
    AND.w   #$f0,d2     ;hi part
    MOVE.w  d7,d3
    AND.w   #$f,d3      ;lo part
    LSR.w   #4,d2
    OR.w    d2,d0
    OR.w    d3,d1

    MOVE.w  d0,2(a1)    ;hi
    MOVE.w  d1,2(a2)    ;lo


    MOVEM.l (a7)+,d5-d7/a0-a2
    RTS
End Statement
;-----------------
Function.w  getkey{}

    MOVEQ   #0,d0
    MOVE.b  $bfec01,d0
    NOT.b   d0
    ROR.b   #1,d0

    RTS
End Function
;-----------------

Statement ReadJoy32{}

    LEA $bfe001,a0
    LEA $dff016,a1

    MOVE.w  porty,d0

    TST.w   d0
    BEQ     readjoy0

readjoy1:
    MOVEM.l d2-d4,-(a7)
    MOVEQ   #0,d0
    MOVEQ   #7,d3
    MOVE    #$4000,d4

    BSET    d3,$200(a0)
    BCLR    d3,(a0)
    MOVE    #$2000,$dff034
    MOVEQ   #6,d1
loop0:
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    MOVE    (a1),d2
    BSET    d3,(a0)
    BCLR    d3,(a0)
    AND     d4,d2
    BNE     skip0
    BSET    d1,d0
skip0:
    DBF     d1,loop0
    MOVE    #0,$dff034
    BCLR    d3,$200(a0)
    ADD     d0,d0
    SWAP    d0

    MOVE    $dff00c,d1
    MOVE    d1,d0
    LSR     #1,d0
    EOR     d0,d1
    AND     #$101,d1
    AND     #$101,d0
    ROR.b   #1,d0
    ROR.b   #1,d1
    LSR     #7,d0
    LSR     #5,d1
    OR      d1,d0
    MOVE.l  d0,joystatus1
    MOVEM.l (a7)+,d2-d4
    RTS
readjoy0:
    MOVEM.l d2-d4,-(a7)
    MOVEQ   #6,d3
    MOVE    #$400,d4

    BSET    d3,$200(a0)
    BCLR    d3,(a0)
    MOVE    #$200,$dff034
    MOVEQ   #6,d1
loop:
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    TST.b   (a0)
    MOVE    (a1),d2
    BSET    d3,(a0)
    BCLR    d3,(a0)
    AND     d4,d2
    BNE     skip
    BSET    d1,d0
skip:
    DBF     d1,loop
    MOVE    #0,$dff034
    BCLR    d3,$200(a0)
    ADD     d0,d0
    SWAP    d0

    MOVE    $dff00a,d1
    MOVE    d1,d0
    LSR     #1,d0
    EOR     d0,d1
    AND     #$101,d1
    AND     #$101,d0
    ROR.b   #1,d1
    ROR.b   #1,d0
    LSR     #5,d1
    LSR     #7,d0
    OR      d1,d0
    MOVE.l  d0,joystatus
    MOVEM.l (a7)+,d2-d4
    RTS

porty:   Dc.w    1

End Statement
;----------------
Statement GetJoy32{}
    MOVE.l  joystatus1,d7   ;d0/d1/d2/d3

doitgj32:
    MOVEQ   #1,d2
    MOVEQ   #1,d3
    MOVEQ   #1,d4

    BTST    #22,d7      ;red button
    BEQ     nored
    MOVEQ   #0,d2
nored:
    BTST    #23,d7      ;blue? - (grn=20/yel=21)
    BEQ     noblue
    MOVEQ   #0,d3
noblue:
    BTST    #20,d7      ;grn? - (grn=20/yel=21)
    BEQ     nogrn
    MOVEQ   #0,d4
nogrn:

    MOVEQ   #0,d0
    MOVEQ   #0,d1

    BTST    #0,d7   ;right?
    BEQ     nori
    MOVE.w  #1,d0
nori:
    BTST    #1,d7   ;left?
    BEQ     nole
    MOVE.w  #-1,d0
nole:
    BTST    #2,d7   ;down?
    BEQ     nodn
    MOVE.w  #1,d1
nodn:
    BTST    #3,d7   ;up?
    BEQ     noup
    MOVE.w  #-1,d1
noup:

    MOVE.w  d0,xjoy
    MOVE.w  d1,yjoy
    MOVE.w  d2,rbut
    MOVE.w  d3,bbut
    MOVE.w  d4,gbut


    RTS

joystatus:   Dc.l    0   ;up down fire etc
joystatus1:  Dc.l    0
joyport:     Dc.w    1   ;port #

xjoy:        Dc.w    0
yjoy:        Dc.w    0
rbut:        Dc.w    0
bbut:        Dc.w    0
gbut:        Dc.w    0

End Statement
;-----------------
Function.w getjoyx{}
    MOVE.w  xjoy,d0
    RTS
End Function
;-----------------
Function.w getjoyy{}
    MOVE.w  yjoy,d0
    RTS
End Function
;-----------------
Function.w getjb{}
    MOVEQ   #0,d0
    TST.w   rbut
    BNE     norb
    MOVEQ   #1,d0
norb:
    TST.w   bbut
    BNE.w   nobb
    MOVEQ   #2,d0
nobb:
    TST.w   gbut
    BNE.w   nogg
    MOVEQ   #3,d0
nogg:
    RTS

End Function
;-----------------

;Runerrson

;------------------------------------------------------------
.initvars

Dim polly.coor(3,5)
Dim pollyd.coor(5)
Dim melt.w(320)
Dim melty.q(320)

Dim hiscore.l(10)
Dim hiname$(10)

hiname$(1)="BOB"
hiname$(2)="PAUL"
hiname$(3)="ZOMB1"
hiname$(4)="ZOMB2"
hiname$(5)="ZOMB3"
hiname$(6)="ZOMB4"
hiname$(7)="ZOMB5"
hiname$(8)="ZOMB6"

hiscore(1)=83205950
hiscore(2)=13765825
hiscore(3)=250000
hiscore(4)=100000
hiscore(5)=50000
hiscore(6)=40000
hiscore(7)=20000
hiscore(8)=10000

Dim zomb.zombie(11)
Dim spray.blood(60)
Dim drib.dribble(50)
Dim drib2.dribble(50)

Dim ebar.w(8)
ebar(0)=17
ebar(1)=17
ebar(2)=16
ebar(3)=23
ebar(4)=22
ebar(5)=21
ebar(6)=9
ebar(7)=10
ebar(8)=11

INCLUDE "zNumberInc.bb"

hit.q=0
ti.l=0
count.l=0
;------------------------------------------------------------
.initdisplay

BitMap 4,320+64,256+32,7
BitMap 5,320+64,256+32,7

BitMap 6,320+64,256+32,7    ;spare!!

BitPlanesBitMap 4,0,%0111111    ;main 6 planes ...
BitPlanesBitMap 5,1,%0111111
BitPlanesBitMap 4,2,%1000000    ;overlay red...
BitPlanesBitMap 5,3,%1000000

tp.l=$10000+$3000+$400+$7

InitCopList 0,44,256,tp,8,128,0

Buffer 0,60000
Buffer 1,60000

InitCopList 1,44,256,0,0,0,0
;------------------------------------------------------------
.loadstuff

gameon=0

LoadBlitzFont 0,"zombie.font"

LoadShape 0,"pointer.iff"
GetaSprite 0,0
LoadShape 898,"II.IFF"

LoadBitMap 0,"titlescreen.iff",0    ;title screen palette
CopyBitMap 4,5
CopyBitMap 4,6
;LoadPalette 1,"titlescreen.iff"
LoadPalette 4,"titlescreen.iff"

LoadSound 0,"chaingun.sfx"
LoadSound 1,"reload.sfx"

For l=1 To 11
    LoadSound 4+l,"die"+Str$(l)+".sfx"  ;5-15
Next
For l=1 To 8
    LoadSound 19+l,"splat"+Str$(l)+".sfx"  ;20-27
Next

For l=1 To 4
    LoadSound 29+l,"rico"+Str$(l)+".sfx"  ;30-33
Next

LoadSound 2,"missile.sfx"
LoadSound 3,"explosion.sfx"

LoadShapes 900,"font16.shp"

LoadShapes 700,"powerups.shp"
LoadShapes 800,"blooddrop.shp"
LoadShapes 810,"bloodsplat.shp"
LoadShapes 820,"bodyparts.shp"
LoadShapes 840,"bloodsplat2.shp"
LoadShapes 850,"smoke.shp"      ;850-856
LoadShapes 860,"explosion.shp"  ;860-879

LoadShapes 0,"zombies.shp"

LoadMedModule 0,"zombie2.mod"

LoadPalette 5,"backdrop1.iff"

BLITZ
BlitzKeys On
CreateDisplay 0
DisplayBitMap 0,4
DisplayPalette 0,0
copaddr.l=Addr CopList(0)

players=1
cheat=0

Mouse On
;MouseII On
MouseArea 0,0,320,200
;MouseAreaII 0,0,320,200

SetInt 5
    Gosub DoInt
End SetInt

BitMapOutput 0
Use BitMap 0

db=0

;--------------------------------------------------------------------
Statement blitprint{x,y,t$}

    If t$<>""
        For l=1 To Len(t$)
            a$=Mid$(t$,l,1)
            a$=UCase$(a$)
            If a$=>"A" AND a$<="Z"
                bn=Asc(a$)-Asc("A")
            EndIf
            If a$=>"0" AND a$<="9"
                bn=Asc(a$)-Asc("0")+26
            EndIf

            Blit 900+bn,x,y
            x+ShapeWidth(900+bn)+2

        Next
    EndIf
End Statement
;--------------------------------------------------------------------
Statement cblitprint{y,t$}

    If t$<>""
        ww=0
        For l=1 To Len(t$)
            a$=Mid$(t$,l,1)
            a$=UCase$(a$)
            If a$=>"A" AND a$<="Z"
                bn=Asc(a$)-Asc("A")
            EndIf
            If a$=>"0" AND a$<="9"
                bn=Asc(a$)-Asc("0")+26
            EndIf
            If a$=" " Then bn=0

            ww+ShapeWidth(900+bn)+2
        Next

        x=(320-ww)/2

        For l=1 To Len(t$)
            a$=Mid$(t$,l,1)
            a$=UCase$(a$)
            If a$=>"A" AND a$<="Z"
                bn=Asc(a$)-Asc("A")
            EndIf
            If a$=>"0" AND a$<="9"
                bn=Asc(a$)-Asc("0")+26
            EndIf
            If a$=" "
                bn=0
            Else
                Blit 900+bn,x,y
            EndIf
            x+ShapeWidth(900+bn)+2
        Next

    EndIf

End Statement
;--------------------------------------------------------------------
;Goto initgame
;--------------------------------------------------------------------
.frontend

MouseArea 0,0,320,200

StartMedModule 0
SetMedVolume 64
music=1

For l=64 To 127
    AGAPalRGB 4,l,100,100,100
Next
AGAPalRGB 4,65,101,102,103

dofe:

Use BitMap 4
Cls
Scroll 0,0,320,256,0,0,6
Use BitMap 5
Cls
Scroll 0,0,320,256,0,0,6

DisplayPalette 0,4
VWait 35
Gosub dotitlescale

For l=1 To 260
    VWait
    If Joyb(0)<>0 OR Joyb(1)<>0
        Pop For
        fade=6
        Goto initgame
    EndIf
Next
Gosub meltscreen
fade=6
While fade<>0
    VWait
Wend
If startgame=1 Then Goto initgame


Gosub creditspage
If startgame=1 Then Goto initgame

Gosub howtopage
If startgame=1 Then Goto initgame

DisplayPalette 0,0
Gosub drawhitable
If startgame=1 Then Goto initgame

plasma=1
plascol.q=Rnd(1)
plccc=0
For lll=0 To 450
    VWait
    If Joyb(0)<>0 OR Joyb(1)<>0 Then startgame=1:Pop For:Goto opik
Next

opik:
plasma=0
fadered=8
While fadered<>0
    VWait
Wend
fade=8
While fade<>0
    VWait
Wend
If startgame=1 Then Goto initgame

Goto dofe

;--------------------------------------------------------------------
.initgame

control=0       ;mouse!!
If Joyb(1)<>0 Then control=1    ;crappy joypad!!! SUX SUX SUX!!

gameon=0

nextpow.w=Int(Rnd(10))MOD 5

While fade<>0
    VWait
Wend

music=0:VWait 2
StopMed

clips1=5        ;how many machine gun clips?
numperclip1=200
bullets1=200     ;how many bullets in this clip??
loaded1=0       ;reloaded??
missiles1=0
grenades1=0

gunpower1.q=.5

clips2=5        ;how many machine gun clips?
numperclip2=150
bullets2=0     ;how many bullets in this clip??
loaded2=0       ;reloaded??

level=0

energy1=16
energy2=16
score1.l=0
score2.l=0
nextfree.l=100000


numperfect.q=0

If cheat=1
    level=15
    clips1=500
    grenades1=500
    missiles1=500
    energy1=500
    gunpower1=5
EndIf

lenergy1=16
lenergy2=16

Volume 15,64,64,64,64

Use BitMap 4
Cls
Use BitMap 5
Cls

lastback.w=9999

;--------------------------------------------------------------------
.startlevel

gameon=0
cheat2=0
cheat3=0
;load stuff..

back.w=Int((level/3))
back=back&3     ;0-3
back+1

If back<>lastback
    QAMIGA
    VWait 10
    LoadBitMap 0,"backdrop"+Str$(back)+".iff",0
    CopyBitMap 4,5
    WaitBlit_
    VWait 25
    BLITZ
    BlitzKeys On
    lastback=back
    Use BitMap 0
    GetaShape 950,0,4,9*16,24       ;to replace score..
    Use BitMap 2
    Cls
    Use BitMap 3
    Cls
Else
    Use BitMap 4
    Scroll 0,0,320,256,0,0,5
    WaitBlit_
EndIf

DisplayPalette 0,0
For cll.w=64 To 127
    r.w=getred{cll-64,copaddr}
    g.w=getgreen{cll-64,copaddr}
    b.w=getblue{cll-64,copaddr}
    r.w=Int((r+g+b)/3)
    r.w=r.w+64:If r>255 Then r=255
    setrgb{cll,copaddr,r,0,0}
Next

For l=0 To 10
    zomb(l)\here=0
Next
numzombies.w=0
numkilled.w=0
addzom.w=0
For l=0 To 60
    spray(l)\go=0
Next
For l=0 To 50
    drib(l)\go=0
Next
dribdrib.q=0

gameon=1:ti.l=0
lasthitx1=-1:lasthity1=-1
lasthitx2=-1:lasthity2=-1

expx=-1:expy=-1:expfr.q=0
missx=-1
mess$="":messc.w=0
drawenergy1=2
shake=0

tokill=(level*4)+5
gameon=1
paused=0

powx.q=-1
powy.q=-1
powvx.q=-1
powvy.q=-1
powfr.w=-1
powhit.w=-1
numgren=0
addpow=400+Int(Rnd(300))

senergy1=energy1

;--------------------------------------------------------------------
.Frame:
VWait
If ti=1 Then VWait
setrgb{0,copaddr,0,0,0}
ti=0
DisplayBitMap 0,db+4

db=1-db
Use BitMap db
BitMapOutput db

If energy1<=0 Then Goto gameover

UnBuffer db

If lenergy1<>energy1
    setrgb{0,copaddr,255,0,0}
    lenergy1=energy1
    drawenergy1=2
EndIf

If drawenergy1>0
    Boxf 300,0,310,4+32,0
    Box  300,0,310,4+32,1
    e=energy1:If e<0 Then e=0
    If e>16 Then e=16
    Boxf 302,4+30,308,4+30-(e*2),ebar(e/2)
    drawenergy1-1
EndIf

If shake>0
    shake-1
EndIf

Gosub updateremains
Gosub updatedribble2
Gosub updatedribble
Gosub addzombies
Gosub updatezombies
Gosub drawzombies

WaitBlit_
Gosub shootplayer1
Gosub updatespray
Gosub updatemissile1
Gosub updateexplosion
Gosub updatemessage
Gosub updatepowerups

key.w=getkey{}
If key=$45 Then End

If key=$19      ;p down
    VWait
    gameon=0
    paused=1
    While getkey{}=$19:VWait:Wend
    Use BitMap 0
    Colour 1
    Locate 17,25:Print "PAUSED"
    Use BitMap 1
    Colour 1
    Locate 17,25:Print "PAUSED"
    While getkey{}<>$19
        VWait
        BitMapOutput 0
        Colour 1
        Locate 17,25:Print "PAUSED"
        BitMapOutput 1
        Colour 1
        Locate 17,25:Print "PAUSED"
    Wend
    While getkey{}=$19:VWait:Wend
    gameon=1
    paused=0
    Use BitMap 0
    Boxf 0,200,319,208,0
    Use BitMap 1
    Boxf 0,200,319,208,0
    Use BitMap db
    gameon=1
EndIf


Block 950,0,4        ;clear old one
tt$="00000000"+Str$(score1)
tt$=Right$(tt$,7)
blitprint{10,4,tt$}


If numkilled>tokill      ;finished!!
    num=0
    For l=0 To 10
        If zomb(l)\here=1 Then num+1
    Next

    If powx<>-1
        If powx<128 Then num+1
    EndIf

    If num=0
        donecount+1
        gameon=0
        If donecount>100
            Goto completelevel
        EndIf
    EndIf
Else
    donecount=0
EndIf

If score1=>nextfree
    nextfree+100000
    mess$="EXTRA ENERGY"
    messc=50
    If energy1<16
        energy1+3
        If energy1>16 Then energy1=16
    EndIf
EndIf

Goto Frame
;--------------------------------------------------------------------
.gameover

gameon=0
fadered=2
While fadered<>0:VWait:Wend

VWait 80
fade=8
While fade<>0:VWait:Wend

UnBuffer 0
UnBuffer 1

hit=-1
For l=1 To 8
    If score1=>hiscore(l) Then hit=l:Pop For:Goto lpok
Next
lpok:
If hit<>-1
    hnum=hit
    For l=7 To hnum Step -1
        hiname$(l+1)=hiname$(l)
        hiscore(l+1)=hiscore(l)
    Next
    Gosub entername1
EndIf

Goto frontend
;--------------------------------------------------------------------
.completelevel
VWait
setrgb{0,copaddr,0,0,0}
DisplayBitMap 0,db+4
db=1-db
Use BitMap db
BitMapOutput db
UnBuffer db
Use BitMap db+2
Cls
VWait
setrgb{0,copaddr,0,0,0}
DisplayBitMap 0,db+4
db=1-db
Use BitMap db
BitMapOutput db
UnBuffer db
Use BitMap db+2
Cls

VWait
Use BitMap 0
DisplayBitMap 0,4

cblitprint{60,"LEVEL "+Str$(level+1)}
cblitprint{60+20,"COMPLETE"}

Sound 0,15
VWait 30

bon.l=0
If energy1=16
    cblitprint{60+50,"PERFECT"}
    cblitprint{60+70,"BONUS 20000"}
    score1+20000
    numperfect+1
    bon.l=20000
    Sound 0,15
    VWait 30
Else
    If senergy1=energy1
        bon.l=1000*Int(energy1)
        cblitprint{60+50,"PERFECT"}
        cblitprint{60+70,"BONUS "+Str$(bon)}
        score1+bon
        numperfect+1
    Sound 0,15
    VWait 30
    EndIf
EndIf


If bon.l=0 Then numperfect=0

np.q=numperfect
np=(np/5)

If numperfect>0 AND np=Int(np)
    bon.l=numperfect*5000
    cblitprint{160,Str$(numperfect)+" PERFECTS"}
    cblitprint{180,"BONUS "+Str$(bon)}
    score1+bon
    Sound 0,15
    VWait 30
EndIf

Block 950,0,4        ;clear old one
tt$="00000000"+Str$(score1)
tt$=Right$(tt$,7)
blitprint{10,4,tt$}
Sound 0,15

VWait 150
fade=8

While fade<>0:VWait:Wend

UnBuffer 0
UnBuffer 1

level+1
Goto startlevel
;--------------------------------------------------------------------
.updateexplosion

If expx<0 Then Return

BBlit db,860+expfr,expx,expy
expfr+1
If expfr>19 Then expx=-1

Return
;--------------------------------------------------------------------
.drawzombies

For l=0 To 10
    If zomb(l)\here=1
        BBlit db,zomb(l)\fr,zomb(l)\x,zomb(l)\y
    EndIf
Next

Return
;--------------------------------------------------------------------
.updatezombies

For l=0 To 10
    If zomb(l)\here=1

        If zomb(l)\typ=30 OR zomb(l)\typ=50 OR zomb(l)\typ=70 OR zomb(l)\typ=20    ;walk right
            zomb(l)\x+zomb(l)\vx
            If zomb(l)\x>310 Then zomb(l)\here=0:numzombies-1:energy1-1
            zomb(l)\cnt-1
            If zomb(l)\cnt<0
                zomb(l)\cnt=zomb(l)\spd
                zomb(l)\fr+1
                If zomb(l)\typ=30
                    If zomb(l)\fr>zomb(l)\typ+3 Then zomb(l)\fr=zomb(l)\typ
                Else
                    If zomb(l)\fr>zomb(l)\typ+6 Then zomb(l)\fr=zomb(l)\typ
                EndIf
            EndIf
        EndIf

        If zomb(l)\typ=40 OR zomb(l)\typ=60 OR zomb(l)\typ=80    ;walk left
            zomb(l)\x+zomb(l)\vx
            If zomb(l)\x<0 Then zomb(l)\here=0:numzombies-1:energy1-1
            zomb(l)\cnt-1
            If zomb(l)\cnt<0
                zomb(l)\cnt=zomb(l)\spd
                zomb(l)\fr+1
                If zomb(l)\typ=40
                    If zomb(l)\fr>zomb(l)\typ+3 Then zomb(l)\fr=zomb(l)\typ
                Else
                    If zomb(l)\fr>zomb(l)\typ+6 Then zomb(l)\fr=zomb(l)\typ
                EndIf
            EndIf
        EndIf

        If zomb(l)\typ=10   ;me gun

            zomb(l)\tim+1
            If zomb(l)\tim<25 Then zomb(l)\fr=10
            If zomb(l)\tim>25 AND zomb(l)\tim<28 Then zomb(l)\fr=11
            If zomb(l)\tim>28 AND zomb(l)\tim<32 Then zomb(l)\fr=12
            If zomb(l)\tim>32 AND zomb(l)\tim<35 Then zomb(l)\fr=13
            If zomb(l)\tim>60 Then zomb(l)\here=0:numzombies-1:Goto qaz

            If zomb(l)\tim=52 AND zomb(l)\hits>2 ;fire gun....
                energy1-1
            EndIf

            If zomb(l)\hits<=2 AND zomb(l)\hits>-1
                zomb(l)\hits=2
                If zomb(l)\fr<14 Then zomb(l)\fr=14:zomb(l)\cnt=4
                zomb(l)\cnt-1
                If zomb(l)\cnt<0
                    zomb(l)\cnt=zomb(l)\spd
                    zomb(l)\fr+1
                    If zomb(l)\fr=18 Then zomb(l)\hits=-1
                EndIf
            EndIf
        EndIf


        If zomb(l)\typ=0   ;bob gun

            zomb(l)\tim+1
            t=zomb(l)\tim
            If t<4 Then zomb(l)\fr=0
            If t=>4 AND t<8 Then zomb(l)\fr=1
            If t=>8 AND t<20 Then zomb(l)\fr=2
            If t=>20 AND t<40 Then zomb(l)\fr=3
            If t=>40 AND t<60 Then zomb(l)\fr=4
            If t=>60 AND t<75 Then zomb(l)\fr=3
            If t=>75 Then zomb(l)\here=0

            If zomb(l)\tim=60 AND zomb(l)\hits>3 ;fire gun....
                energy1-1
            EndIf

        EndIf




        If zomb(l)\hits<0
            zomb(l)\here=0:numzombies-1:numkilled+1
            sprx.q=zomb(l)\x+(zomb(l)\w/2)
            spry.q=zomb(l)\y+(zomb(l)\h/2)
            s=Int(Rnd(11))+5     ;die 5-15
            Sound s,8+4

            For lq=0 To 10
                rx=Rnd(8)-4
                ry=Rnd(8)-4
                rb=Rnd(2)-1
                sprayx=sprx+rx
                sprayy=spry+ry
                spraybot.w=zomb(l)\y+zomb(l)\h+rb
                Gosub addspray
                If (Rnd(1)<.3 AND hit<>-1)
                    cunt.l=(count ASR 1)+lq+rx
                    cunt=cunt MOD 6             ;0-5
                    spray(hit)\go=3+cunt
                    spray(hit)\life-30
                EndIf
                If shake>18 AND hit<>-1
                    cunt.l=(count ASR 1)+lq+rx
                    cunt=cunt MOD 6             ;0-5
                    spray(hit)\go=3+cunt
                    spray(hit)\life-50
                    spray(hit)\vy*1.5
                EndIf
            Next
        EndIf

qaz:
    EndIf
Next

Return
;--------------------------------------------------------------------
.addzombies

max=Int(level/2)+2
If max>7 Then max=7

If numkilled>tokill Then max=0   ;dont add any more!!


If numzombies<max
    gameon=1
    rrrr=Rnd(1)
    dz=(20-(level*2)):If dz<0 Then dz=0
    dzz=200-(level*8)
    If dzz<10 Then dzz=10
    If addzom>dzz Then rrrr=0
    If addzom<20+dz Then rrrr=9
    If rrrr<.04

        hit=-1
        For l=0 To 10
            If zomb(l)\here=0
                hit=l
            EndIf
        Next
        If hit<>-1
            numzombies+1
            zomb(hit)\here=1
            addzom=0
            ttt=Int(Rnd(10))
            If ttt<2 AND level<10 Then ttt=999
            If ttt=8 AND level<4 Then ttt=999
            rr=Rnd(2)-1
            Select ttt

                Case 0              ;aaron right
                    zomb(hit)\typ=30
                    zomb(hit)\fr=30
                    zomb(hit)\y=156-ShapeHeight(30)
                    zomb(hit)\x=0
                    zomb(hit)\vx=2+Int(level/20)+rr
                    zomb(hit)\h=ShapeHeight(30)
                    zomb(hit)\w=ShapeWidth(30)
                    zomb(hit)\hits=6+Int(level/6)
                    zomb(hit)\spd=4
                Case 1              ;aaron left
                    zomb(hit)\typ=40
                    zomb(hit)\fr=40
                    zomb(hit)\y=156-ShapeHeight(40)
                    zomb(hit)\x=310
                    zomb(hit)\vx=-(2+Int(level/20))+rr
                    zomb(hit)\h=ShapeHeight(40)
                    zomb(hit)\w=ShapeWidth(40)
                    zomb(hit)\hits=6+Int(level/6)
                    zomb(hit)\spd=4
                Case 2              ;bob right
                    zomb(hit)\typ=50
                    zomb(hit)\fr=50
                    zomb(hit)\y=156-ShapeHeight(50)
                    zomb(hit)\x=0
                    zomb(hit)\vx=(2+Int(level/20))+rr
                    zomb(hit)\h=ShapeHeight(50)
                    zomb(hit)\w=ShapeWidth(50)
                    zomb(hit)\hits=5+Int(level/6)
                    zomb(hit)\spd=3
                Case 3              ;bob left
                    zomb(hit)\typ=60
                    zomb(hit)\fr=60
                    zomb(hit)\y=156-ShapeHeight(60)
                    zomb(hit)\x=310
                    zomb(hit)\vx=-(2+Int(level/20))+rr
                    zomb(hit)\h=ShapeHeight(60)
                    zomb(hit)\w=ShapeWidth(60)
                    zomb(hit)\hits=5+Int(level/6)
                    zomb(hit)\spd=3
                Case 4              ;me gun
                    zomb(hit)\typ=10
                    zomb(hit)\fr=10
                    zomb(hit)\y=200-ShapeHeight(10)
                    zomb(hit)\x=80+(Rnd(12)*10)
                    zomb(hit)\tim=0
                    zomb(hit)\h=ShapeHeight(10)
                    zomb(hit)\w=ShapeWidth(10)
                    zomb(hit)\hits=5+Int(level/6)
                    zomb(hit)\spd=3
                    zomb(hit)\cnt=0
                Case 5              ;bob right 2
                    zomb(hit)\typ=70
                    zomb(hit)\fr=70
                    zomb(hit)\y=156-ShapeHeight(70)
                    zomb(hit)\x=0
                    zomb(hit)\vx=(2+Int(level/22))+rr
                    zomb(hit)\h=ShapeHeight(70)
                    zomb(hit)\w=ShapeWidth(70)
                    zomb(hit)\hits=5+Int(level/8)
                    zomb(hit)\spd=3
                Case 6              ;bob left 2
                    zomb(hit)\typ=80
                    zomb(hit)\fr=80
                    zomb(hit)\y=156-ShapeHeight(80)
                    zomb(hit)\x=310
                    zomb(hit)\vx=-(2+Int(level/2))+rr
                    zomb(hit)\h=ShapeHeight(80)
                    zomb(hit)\w=ShapeWidth(80)
                    zomb(hit)\hits=5+Int(level/8)
                    zomb(hit)\spd=3
                Case 7              ;bob nolegs right
                    zomb(hit)\typ=20
                    zomb(hit)\fr=20
                    zomb(hit)\y=156-ShapeHeight(20)
                    zomb(hit)\x=0
                    zomb(hit)\vx=(2+Int(level/22))+rr
                    zomb(hit)\h=ShapeHeight(20)
                    zomb(hit)\w=ShapeWidth(20)
                    zomb(hit)\hits=6+Int(level/10)
                    zomb(hit)\spd=3
                Case 8              ;bobby got a gun
                    zomb(hit)\typ=0
                    zomb(hit)\fr=0
                    zomb(hit)\y=200-ShapeHeight(0)
                    zomb(hit)\x=80+(Rnd(12)*10)
                    zomb(hit)\vx=0
                    zomb(hit)\h=ShapeHeight(0)
                    zomb(hit)\w=ShapeWidth(0)
                    zomb(hit)\hits=6+Int(level/8)
                    zomb(hit)\tim=0


                Default
                    zomb(hit)\here=0
                    numzombies-1
                    addzom=190

            End Select

        EndIf
    EndIf
EndIf

Return
;--------------------------------------------------------------------
.shootplayer1

ccp=Point(mx1,my1)
lasthitx1=-1:lasthity1=-1
If Joyb(0)=1 AND loaded1=0 AND shoot1=1

    INCLUDE "zShootInc.bb"

    If ccp<32 AND ccp>0        ;zombie??
        For l=0 To 10
            If zomb(l)\here=1
                If mx1>zomb(l)\x AND mx1<zomb(l)\x+zomb(l)\w
                    If my1>zomb(l)\y AND my1<zomb(l)\y+zomb(l)\h
                        score1+25
                        zomb(l)\hits-gunpower1
                        sprayx.q=mx1:sprayy.q=my1
                        spraybot.w=zomb(l)\y+zomb(l)\h

                        If Rnd(1)<.9
                            s=Int(Rnd(8))+20    ;splat sound 20-27
                            Sound s,4
                        EndIf

                        If (count&3)<2 AND Rnd(1)<.24
                            Gosub addspray
                        Else
                            Gosub addsplat
                        EndIf
                        lasthitx1=mx1:lasthity1=my1
                        Pop For:Goto dfgg
                    EndIf
                EndIf
            EndIf
        Next

;not a zombie...
        If (count ASR 4)&3=<2
            sprayx.q=mx1:sprayy.q=my1
            spraybot.w=9999
            If Rnd(1)<.9
                s=Int(Rnd(8))+20    ;splat sound 20-27
                Sound s,4
            EndIf
            Gosub addsplat
        EndIf

    EndIf


dfgg:
    If Rnd(1)<.07
        s=Rnd(4)+30     ;rico 30-33
        Sound s,8
    EndIf

EndIf

Return
;--------------------------------------------------------------------
.updateplayer1:

shoot1=0

If Joyb(0)=1 AND loaded1=0 AND bullets1>0
    If sp1>3
        Sound 0,1
        sp1=0
    Else
        sp1+1
    EndIf

    firec.w=0
    bullets1-1
    shoot1=1
    If bullets1<=0 AND clips1>0  ;re-load!!
        Sound 1,1
        loaded1=20
        bullets1=numperclip1
        clips1-1
        If mess$=""
            mess$=Str$(clips1)+" CLIP"
            If clips1<>1 Then mess$+"S"
            mess$+" REMAINING"
            messc=20
        EndIf
    EndIf
EndIf

If Joyb(0)=1 AND bullets1=0 AND clips1=0
    mess$="NO AMMO"
    messc=25
    firec+1
    If firec=>25
        firec=0
        Sound 0,1
        shoot1=1
    EndIf
EndIf


If Joyb(0)=2 AND missx.q=-1 AND missiles1>0  ;missile!!!!
    missx.q=0:missy.q=190
    If mx1>160 Then missx=319
    misshx=mx1:misshy=my1
    missvx.q=(misshx-missx)/40
    missvy.q=(misshy-missy)/40
    missax.q=(misshx-missx)/200
    missay.q=(misshy-missy)/200
    Sound 2,8
    missiles1-1
    If mess$=""
        mess$=Str$(missiles1)+" MISSILE"
        If missiles1<>1 Then mess$+"S"
        mess$+" REMAINING"
        messc=20
    EndIf
EndIf

If Joyb(0)=2 AND missiles1=0
    mess$="NO MISSILES"
    messc=25
EndIf

If Joyb(0)=3 AND grenades1>0 AND shake=0
    grenades1-1
    Sound 3,15
    shake=20
    numgren=0

    If mess$=""
        mess$=Str$(grenades1)+" GRENADE"
        If grenades1<>1 Then mess$+"S"
        mess$+" REMAINING"
        messc=20
    EndIf
EndIf

If Joyb(0)=3 AND grenades1=0
    mess$="NO GRENADES"
    messc=25
EndIf

If shake>10
    For las=0 To 10
        If zomb(las)\here=1 AND zomb(las)\hits>-1
            zomb(las)\hits=-1
            numgren+1
        EndIf
    Next
EndIf

If shake=1
    If numgren>1

        If numgren=8 Then numgren+Int(Rnd(3))

        If numgren>10 Then numgren=10
        bonus.l=numgren*1500
        If numgren=10 Then bonus=1000000
        mess$=number$(numgren)+" WHAMMY BONUS-"+Str$(bonus)
        messc=50
        score1+bonus
        numgren=0
    EndIf
EndIf


Return
;--------------------------------------------------------------------
.updatemissile1

If missx=-1 Then Return

missx+missvx
missy+missvy
missvx+missax
missvy+missay

If missx>misshx-4 AND missx<misshx+4
    If missy>misshy-4 AND missy<misshy+4

        ccp=Point(missx,missy)
        takeout=0
        headshot=0

        If ccp<32 AND ccp>0        ;zombie??
            For l=0 To 10
                If zomb(l)\here=1
                    If missx>zomb(l)\x AND missx<zomb(l)\x+zomb(l)\w
                        If missy>zomb(l)\y AND missy<zomb(l)\y+zomb(l)\h
                            score1+50
                            If zomb(l)\hits>-1 Then takeout+1
                            If Abs(missy-zomb(l)\y)<16 Then headshot+1
                            zomb(l)\hits=-1
                            sprayx.q=missx:sprayy.q=missy
                            spraybot.w=zomb(l)\y+zomb(l)\h

                            If Rnd(1)<.9
                                s=Int(Rnd(8))+20    ;splat sound 20-27
                                Sound s,4
                            EndIf
                            For gore=1 To 4
                                Gosub addspray
                                If hit<>-1
                                    cunt.l+(count ASR 1)+lq+rx
                                    cunt=cunt MOD 6             ;0-5
                                    spray(hit)\go=3+cunt
                                    spray(hit)\life-30
                                    spray(hit)\vy*1.8
                                    spray(hit)\vx*1.8
                                EndIf
                            Next
                        EndIf
                    EndIf
                EndIf
            Next
        EndIf

        expx=missx-16
        expy=missy-16
        expfr=0
        missx=-1
        Sound 3,2
        If takeout>1 AND takeout>headshot
            If mess$=""
                mess$=number$(takeout)+" MISSILE DEATH BONUS -"+Str$(takeout*takeout*1000)+"!"
                messc=45
            EndIf
            score1+(takeout*takeout*1000)
        EndIf
        If headshot>0
            If headshot=>4 Then headshot+5
            If headshot>10 Then headshot=10
            bonus.l=(headshot*headshot*headshot+1)*1000
            If mess$=""
                mess$=number$(headshot)+" HEAD-SHOT BONUS-"+Str$(bonus)
                messc=50
            EndIf
            score1+bonus
        EndIf


    EndIf
EndIf

xx=missx
yy=missy
xv=missvx*.75
yv=missvy*.75
For l=850 To 856
    If xx>0 AND yy<199 AND xx<300 AND yy>0
        BBlit db,l,xx,yy
    EndIf
    xx-xv
    yy-yv
Next


Return
;--------------------------------------------------------------------
.updateremains
For l=0 To 40
    If spray(l)\go>2
        sdd=ShapeHeight(820+spray(l)\go-3)
        If spray(l)\y=>spray(l)\bot-sdd AND spray(l)\bot-sdd<194

            If spray(l)\vy>4
                spray(l)\vy=-(spray(l)\vy/2)
                spray(l)\vx=(spray(l)\vx/2)
                spray(l)\y=spray(l)\bot-sdd-1
                spray(l)\life-15
                s=Rnd(3)+20:Sound s,8
                sprayx=spray(l)\x:sprayy=spray(l)\y
                Gosub addbitspray
                Goto farty
            EndIf

            If spray(l)\x>0 AND spray(l)\x<300 AND spray(l)\bot-sdd>0 AND spray(l)\go>2 AND spray(l)\y>0
                Blit 820+spray(l)\go-3,spray(l)\x,spray(l)\bot-sdd
            EndIf
            spray(l)\vy=0:spray(l)\vx=0
            spray(l)\do+1
            If spray(l)\do=2
                s=Rnd(3)+20:Sound s,8
                spray(l)\go=0
                hit=-1
                For zl=0 To 50
                    If drib(zl)\go=0 Then hit=zl:Pop For:Goto qwe
                Next
qwe:            If hit<>-1
                    drib(hit)\go=1
                    drib(hit)\x=Int(spray(l)\x+Rnd(7))
                    drib(hit)\y=Int(spray(l)\y+sdd-3)
                    drib(hit)\life=(40+Rnd(30))&$fffc
                EndIf
            EndIf
        EndIf
    EndIf
farty:
Next
Return
;--------------------------------------------------------------------
.updatedribble

dd=Int(dribdrib.q)
For l=dd*10 To (dd*10)+9
    If drib(l)\go=1
        Plot drib(l)\x,drib(l)\y,17+(l&3)
        drib(l)\life-1
        If (drib(l)\life&3)=0 AND drib(l)\life>8
            drib(l)\y+.8
            If drib(l)\y>199 Then drib(l)\y=199
            drib(l)\x+(Rnd(3)-1)
        EndIf
        If drib(l)\life<0 Then drib(l)\go=0
    EndIf
Next

dribdrib.q=dribdrib+.5
If dribdrib=5 Then dribdrib=0   ;0,1,2,3,4

Return
;--------------------------------------------------------------------
.updatedribble2

dd=Int(dribdrib.q)
For l=dd*10 To (dd*10)+9
    If drib2(l)\go=1
        Use BitMap db+2
        Plot drib2(l)\x,drib2(l)\y,1
        Plot drib2(l)\x,drib2(l)\y+1,1
        drib2(l)\life-1
        If (drib2(l)\life&3)=0 AND drib2(l)\life>8
            drib2(l)\y+1.8
            drib2(l)\x+(Rnd(2)-1)
        EndIf
        If drib2(l)\life<0 Then drib2(l)\go=0
    EndIf
Next

Use BitMap db
Return
;--------------------------------------------------------------------
.updatespray

For l=0 To 40
    If spray(l)\go=1 OR spray(l)\go>2
        spray(l)\x+spray(l)\vx
        spray(l)\y+spray(l)\vy
        spray(l)\vy+.3
        spray(l)\life+1
        If spray(l)\life>24 Then spray(l)\go=0:Goto www
        If spray(l)\x<0 OR spray(l)\x>320 Then spray(l)\go=0:Goto www
        If spray(l)\y>255 Then spray(l)\go=0:Goto www
        ll=Int(spray(l)\life)/5
        If ll>4 Then ll=4
        If ll<0 Then ll=0
        If spray(l)\y>0
            gg=spray(l)\go
            If gg=1
                BBlit db,800+ll,spray(l)\x,spray(l)\y
            EndIf
            If gg>2
                BBlit db,820+gg-3,spray(l)\x,spray(l)\y
            EndIf
        EndIf
www:
    EndIf

    If spray(l)\go=2
        spray(l)\x+spray(l)\vx
        spray(l)\y+spray(l)\vy
        spray(l)\life+1
        If spray(l)\x<0 OR spray(l)\x>320 Then spray(l)\go=0:Goto www2
        If spray(l)\y>255 Then spray(l)\go=0:Goto www2
        If spray(l)\life>9 Then spray(l)\go=0:Goto www2
        ll=Int(spray(l)\life/2)
        If spray(l)\y>0
            BBlit db,810+ll,spray(l)\x,spray(l)\y
        EndIf
www2:
    EndIf
Next
Return
;--------------------------------------------------------------------
.updatemessage

If mess$<>""
    If tmess$<>"" AND tmessc.w>10 Then Goto ddfg
    If tmess$<>""
        Use BitMap 1-db
        Boxf 0,200,319,208,0
        Use BitMap db
        Boxf 0,200,319,208,0
    EndIf
    tmess$=mess$
    tmessc.w=messc
    mess$=""
EndIf

If tmess$="" Then Return

ddfg:
tmessc-1
If tmessc<2
    Boxf 0,200,319,208,0
Else

    If (tmessc&3)=0
        xx=40-Len(tmess$)
        xx=xx/2
        Colour 1
        cc=(tmessc&7)
        If cc>3 Then Colour 5
        Locate xx,25
        Print tmess$
    EndIf
EndIf

If tmessc<0 Then tmess$="":Colour 1

Return
;--------------------------------------------------------------------
.updatepowerups

nextpow=(nextpow+1) MOD 5

If powx=-1
    tttt.q=Rnd
    If addpow>800 Then tttt=0
    If tttt<.01

        addpow=Int(Rnd(80))
        powy=0
        powx=Rnd(39)*8
        powvx=0
        powvy=2
        powfr=nextpow ;Int(Rnd(12)/2)
        If powfr=1 AND level<5 Then powfr=0
        If powfr=2 Then powfr=0
        powhit=-1
        If clips1<3
            powfr=0
        EndIf

    EndIf
Else

    If powhit<>1 AND Joyb(0)=1 AND loaded=0
        If mx1>powx AND mx1<powx+16
            If my1>powy AND my1<powy+16

                powhit=1
                powvy=-6
                powvx=(Rnd(6)-3)*2
                Sound 30+Rnd(2),15

                Select powfr
                    Case 0
                        clips1+1
                        bullets1+1
                    Case 1
                        missiles1+5
                    Case 2

                    Case 3
                        grenades1+5
                    Case 4
                        gunpower1+.1
                End Select
            EndIf
        EndIf
    EndIf

    powx+powvx
    powy+powvy

    If powhit=1
        powvy+.3
    EndIf

    If powy>199 Then powx=-1
    If powx<0 OR powx>319 Then powx=-1

    If powx<>-1 AND powy>0
        BBlit db,700+powfr,powx,powy
    EndIf
EndIf

Return
;--------------------------------------------------------------------
.addspray
hit=-1
For lh=0 To 40
    If spray(lh)\go=0 Then hit=lh:Pop For:Goto ppp
Next
ppp:
If hit<>-1
    spray(hit)\go=1
    spray(hit)\do=0
    spray(hit)\life=0
    spray(hit)\vx=Rnd(6)-3
    spray(hit)\vy=-(Rnd(4)+1)
    spray(hit)\bot=spraybot
    rx=Rnd(6)-3
    ry=Rnd(6)-3
    spray(hit)\x=sprayx+rx
    spray(hit)\y=sprayy+rx
    zzzz=hit

    If Rnd(1)<.2
        hit=-1
        For zl=0 To 30
            If drib2(zl)\go=0 Then hit=zl:Pop For:Goto qz
        Next
qz:     If hit<>-1
            drib2(hit)\go=1
            drib2(hit)\x=Int(spray(zzzz)\x+Rnd(7))
            drib2(hit)\y=Int(spray(zzzz)\y)
            drib2(hit)\life=(30+Rnd(10))&$fffc

            rr=Int(Rnd(3))
            Use BitMap 2
            Blit 840+rr,drib2(hit)\x-4,drib2(hit)\y-4
            Use BitMap 3
            Blit 840+rr,drib2(hit)\x-4,drib2(hit)\y-4
            Use BitMap db

        EndIf
    EndIf

EndIf
Return
;--------------------------------------------------------------------
.addbitspray
For fucks_sake=1 To 2
    hit=-1
    For lh=20 To 40
        If spray(lh)\go=0 Then hit=lh:Pop For:Goto ppp2
    Next
    ppp2:
    If hit<>-1
        spray(hit)\go=1
        spray(hit)\do=0
        spray(hit)\life=9
        spray(hit)\vx=Rnd(6)-3
        spray(hit)\vy=-(Rnd(4)+1)
        spray(hit)\bot=spraybot
        rx=Rnd(6)-3
        ry=Rnd(6)-3
        spray(hit)\x=sprayx+rx
        spray(hit)\y=sprayy+rx
        zzzz=hit
    EndIf
Next
Return
;--------------------------------------------------------------------
.addsplat
hit=-1
For lh=0 To 40
    If spray(lh)\go=0 Then hit=lh:Pop For:Goto ppp2z
Next
ppp2z:
If hit<>-1
    spray(hit)\go=2
    spray(hit)\do=0
    spray(hit)\life=0
    rx=Rnd(4)-2
    ry=Rnd(4)-2
    spray(hit)\x=sprayx+rx-8
    spray(hit)\y=sprayy+ry-8
    spray(hit)\vx=0
    spray(hit)\vy=0
    spray(hit)\bot=9999
EndIf
Return
;--------------------------------------------------------------------
.DoInt

ti.l+1
count.l+1
addzom+1
addpow+1

;ReadJoy32{}
;GetJoy32{}

If control=0
    jb.w=Joyb(0)
Else
    jb=getjb{}
EndIf

If paused=0
    mx1=MouseX
    my1=MouseY
    DisplaySprite 0,0,mx1-7,my1-7,4
EndIf
If loaded1>0 Then loaded1-1

If gameon=1
    Gosub updateplayer1
EndIf

If fade<>0
    tot.l=0
    For l=0 To 127
        r.w=getred{l,copaddr}
        g.w=getgreen{l,copaddr}
        b.w=getblue{l,copaddr}
        r=r-fade:b=b-fade:g=g-fade
        If r<0 Then r=0
        If g<0 Then g=0
        If b<0 Then b=0
        setrgb{l,copaddr,r,g,b}
        tot+r+b+g
    Next
    If tot=0 Then fade=0
EndIf

If fadered<>0
    tot.l=128
    For l=0 To 127
        r.w=getred{l,copaddr}
        g.w=getgreen{l,copaddr}
        b.w=getblue{l,copaddr}
        r=r+fadered:b=b-fadered:g=g-fadered
        If r>255 Then r=255
        If g<0 Then g=0
        If b<0 Then b=0
        setrgb{l,copaddr,r,g,b}
        If r=255 AND g=0 AND b=0 Then tot-1
    Next
    If tot=0 Then fadered=0
EndIf

If music=1
    PlayMed
EndIf

If plasma=1
    plccc=plcc
    For lqw=32 To 63
        r.w=0:g.w=0:b.w=0
        If plascol<.6 Then r=plccc*2
        If plascol=>.6 AND plascol<.7 Then g=plccc*2
        If plascol=>.7 AND plascol<.8 Then b=plccc*2
        If plascol=>.8 AND plascol<.9 Then r=plccc*2:b=plccc*2
        If plascol=>.9 Then g=plccc*2:b=plccc*2
        setrgb{lqw,copaddr,r,g,b}
        plccc+1:If plccc=64 Then plccc=32
    Next
    plcc+1:If plcc=64 Then plcc=32
EndIf

Return
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
.dotitlescale

polly(0,0)\x=-30,25     ;top bar
polly(0,1)\x=30,25
polly(0,2)\x=30,15
polly(0,3)\x=-30,15

polly(1,0)\x=-30,-25     ;bottom bar
polly(1,1)\x=30,-25
polly(1,2)\x=30,-15
polly(1,3)\x=-30,-15

polly(2,0)\x=-20,15     ;vert bar 1
polly(2,1)\x=-10,15
polly(2,2)\x=-10,-15
polly(2,3)\x=-20,-15

polly(3,0)\x=20,15     ;vert bar 2
polly(3,1)\x=10,15
polly(3,2)\x=10,-15
polly(3,3)\x=20,-15

cx=160
cy=100
numc=4
nump=4
db=0

For k=20 To 0 Step -.45
    VWait
    DisplayBitMap 0,db+4
    db=1-db
    Use BitMap db+2
    BitMapOutput db+2
    Cls
    kk=k:If kk<1 Then kk=1

    For pp=0 To nump-1

        For l=0 To numc-1
            pollyd(l)\x=polly(pp,l)\x*kk+cx
            pollyd(l)\y=polly(pp,l)\y*kk+cy
        Next
        Polyf numc,&pollyd(0),1,1
    Next
Next

For l=0 To 1
    VWait
    DisplayBitMap 0,db+4
    db=1-db
    Use BitMap db+2
    BitMapOutput db+2
    Cls
    Use BitMap db+4
    BitMapOutput db+4
    Blit 898,130,75
Next

Return
;--------------------------------------------------------------------
.meltscreen:

;set colours 64-127 to red...
;DisplayPalette 0,0

For cll.w=64 To 127
    r.w=getred{cll-64,copaddr}
    g.w=getgreen{cll-64,copaddr}
    b.w=getblue{cll-64,copaddr}

    r.w=Int((r+g+b)/3)
    r.w=r.w+64:If r>255 Then r=255
    setrgb{cll,copaddr,r,0,0}
Next

For l=0 To 319
    melt(l)=l
    melty(l)=0
Next

gg=0
For l=0 To 640
    a=gg
    b=Rnd(320)
    While a=b
        b=Int(Rnd(320))
    Wend
    t=melt(a)
    melt(a)=melt(b)
    melt(b)=t
    gg+1:gg=gg MOD 320
Next

Use BitMap 2
DisplayBitMap 0,4

startgame=0

domelt:
    go=0
    For gg=0 To 319
        xx=melt(gg)
        If melty(xx)<255
            go=1
            lzz=Rnd(4)
            Line xx,melty(xx),xx,melty(xx)+lzz,1
            melty(xx)+lzz
        EndIf
        If Joyb(0)<>0 OR Joyb(1)<>0 Then Pop For:startgame=1:Return
    Next
If go=1 Then Goto domelt

VWait 50

Return
;--------------------------------------------------------------------
.drawhitable
Use BitMap 4
Cls
Use BitMap 5
Cls
DisplayBitMap 0,4
BitMapOutput 0
Use BitMap 0

DisplayPalette 0,5
VWait
For l=64 To 127
    setrgb{l,copaddr,0,0,0}
Next

For l=32 To 63
    setrgb{l,copaddr,0,0,0}
Next

setrgb{8,copaddr,0,0,0}

VWait
stoppy=1

Locate 8,0
NPrint "ALL-TIME BIGGEST LOSERS"

startgame=0

drawhitable2:

;----------------------
CreateDisplay 1
bh=256+31:bw=320+63
kp.q=rad

If Int(Rnd*10)>5
    sadd.q=Rnd*2                 ;plasmax 0.9,1.5,0.9
    ssize.q=Int(Rnd*40)*2+2     ;xsize  70,40,70
    sadd1.q=Int(Rnd*180)+1       ;2.5       ;plasmay 2.5,12.5,182.5
    ssize1.q=Int(Rnd*40)*2+6    ;ysize  30,20,70
    thick=Int(Rnd*2)+1           ;1,2,3,4..
Else
    sadd.q=(Rnd*5)+1.5            ;plasmax 0.9,1.5,0.9
    ssize.q=Int(Rnd*10)*4+12       ;xsize  70,40,70
    sadd1.q=(Rnd*8)+2.5                  ;plasmay 2.5,12.5,182.5
    ssize1.q=Int(Rnd*10)*3+7    ;ysize  30,20,70
    thick=Int(Rnd*1)+1           ;1,2,3,4..
EndIf

col=0
coladd=1
If Rnd<.5 Then coladd=-1
For lz=10 To bh-1 Step thick
    Boxf 0,lz,bw-1,lz+thick,col+32
    col=col+coladd
    If col>31 Then col=0
    If col<0 Then col=31
Next
sval.q=0
For x=0 To bw-1
    ss=Int((Sin(sval*kp)*ssize)+ssize)
    ss+10
    Scroll x,ss,1,bh-ss,x,10
    sval=sval+sadd
Next
sval=0
For y=10 To bh-1
    ss=Int((Sin(sval*kp)*ssize1)+ssize1)
    Scroll ss,y,bw-ss,1,0,y
    sval=sval+sadd1
Next

VWait
CreateDisplay 0
;----------------------

yy=32:yy2=256
For l=1 To 8
    xx=8

    Use BitMap 2
    Boxf 4,yy,314,yy+18,1
    Use BitMap 0
    Blit 900+l+26,xx,yy     ;number..
    xx=42
    blitprint{xx,yy,hiname$(l)}
    xx=176
    t$="00000000"+Str$(hiscore(l))
    t$=Right$(t$,8)
    blitprint{xx,yy,t$}


    If Int(l/2)*2=l
        Use BitMap 2
        For g=0 To 320
            For y=yy To yy+18
                xm=Rnd(2)
                Scroll 4,y,320,1,4-xm,y
            Next
            If (Joyb(0)<>0 OR Joyb(1)<>0) AND stoppy=1
                stoppy=2
            EndIf
        Next
    Else
        Use BitMap 2
        For g=0 To 320
            For y=yy To yy+18
                xm=Rnd(2)*2
                Scroll 0,y,320,1,xm,y
            Next
            If (Joyb(0)<>0 OR Joyb(1)<>0) AND stoppy=1
                stoppy=2
            EndIf
        Next
    EndIf

    yy+20
    If stoppy=2 Then Pop For:startgame=1:Return
Next
dddd:

Return
;--------------------------------------------------------------------
.entername1

MouseArea 0,0,320,256

Use BitMap 4
Cls
Use BitMap 5
Cls
DisplayBitMap 0,4
BitMapOutput 0
Use BitMap 0
DisplayPalette 0,5

For l=0 To 31
    setrgb{l+32,copaddr,0,0,0}
Next
For l=32 To 63
    setrgb{l,copaddr,0,0,0}
Next
For l=64 To 127
    setrgb{l,copaddr,0,0,0}
Next

hiname$(hnum)=""
hiscore(hnum)=score1

;show table..
stoppy=0
Gosub drawhitable2

Boxf 0,0,319,8,0
Locate 7,0
NPrint "PLAYER ONE GOT A HI-SCORE!"

Locate 13,31
NPrint "PRESS RIGHT BUTTON TO END."

Use BitMap 4
xx=0:yy=200
For l=0 To 26+10-1
    Blit 900+l,xx,yy
    xx+20:If xx>300 Then xx=0:yy+20
Next

;For l=64 To 127
;    AGAPalRGB 0,l,0,0,0
;Next
;AGAPalRGB 0,0,0,0,0
;AGAPalRGB 0,1,255,255,255
;DisplayPalette 0,0

plasma=1
plascol.q=Rnd(1)
plccc=0

lx=42:ly=32+((hnum-1)*20)     ;next letter pos...
lnum=0
nn$=""

glet:
While Joyb(0)=0 AND Joyb(1)=0
    VWait
Wend

If Joyb(0)=2 Then Goto donenn

If my1<200 Then Goto glet

Sound 0,15   ;shot..

mx=mx1
my=my1
my-200
mx=Int(mx/20)
my=Int(my/20)

letter=my*16+mx
lw=ShapeWidth(letter+900)

VWait
Use BitMap 0
Blit 900+letter,lx,ly

If letter<26
    nn$=nn$+Chr$(Asc("A")+letter)
Else
    nn$=nn$+Chr$(Asc("0")+(letter-26))
EndIf

VWait 12

Sound 1,15   ;reload

VWait 20

lnum+1
lx+lw+2
If lnum<5 Then Goto glet

donenn:
hiname$(hnum)=nn$

INCLUDE "zhiinc.bb"

VWait 10
plasma=0
fade=2
While fade<>0
    VWait
Wend

Return
;--------------------------------------------------------------------
.creditspage
Use BitMap 4
Cls
Use BitMap 5
Cls
DisplayBitMap 0,4
BitMapOutput 0
Use BitMap 0
DisplayPalette 0,5
For l=32 To 63
    setrgb{l,copaddr,0,0,0}
Next
For l=64 To 127
    setrgb{l,copaddr,0,0,0}
Next
setrgb{8,copaddr,0,0,0}

;----------------------
CreateDisplay 1
bh=256+31:bw=320+63
kp.q=rad

If Int(Rnd*10)>5
    sadd.q=Rnd*5+7                 ;plasmax 0.9,1.5,0.9
    ssize.q=Int(Rnd*40)*2+2     ;xsize  70,40,70
    sadd1.q=Int(Rnd*18)+20       ;2.5       ;plasmay 2.5,12.5,182.5
    ssize1.q=Int(Rnd*40)*2+6    ;ysize  30,20,70
    thick=Int(Rnd*2)+1           ;1,2,3,4..
Else
    sadd.q=(Rnd*5)+9.5            ;plasmax 0.9,1.5,0.9
    ssize.q=Int(Rnd*10)*4+12       ;xsize  70,40,70
    sadd1.q=(Rnd*8)+4.5                  ;plasmay 2.5,12.5,182.5
    ssize1.q=Int(Rnd*10)*3+9    ;ysize  30,20,70
    thick=Int(Rnd*1)+1           ;1,2,3,4..
EndIf

col=0
coladd=1
If Rnd<.5 Then coladd=-1

For lz=0 To bw-1 Step thick
    Boxf lz,0,lz+thick,bh-1,col+32
    col=col+coladd
    If col>31 Then col=0
    If col<0 Then col=31
Next
sval.q=0
For y=00 To bh-1
    ss=Int((Cos(sval*kp)*ssize1)+ssize1)
    Scroll ss,y,bw-ss,1,0,y
    sval=sval+sadd1
Next
sval.q=0
For x=0 To bw-1
    ss=Int((Sin(sval*kp)*ssize)+ssize)
    Scroll x,ss,1,bh-ss,x,0
    sval=sval+sadd
Next

VWait
CreateDisplay 0
;----------------------

Restore cdat

yy=8

rew:
Read a$
If a$="XXX" Then Goto wert
If a$<>""
    cblitprint{yy,a$}
    yy+18
Else
    yy+9
EndIf
Goto rew

wert:
plasma=1
plascol.q=Rnd(1)
plccc=0

For l=0 To 500
    VWait
    If Joyb(0)<>0 OR Joyb(1)<>0 Then startgame=1:Pop For:Goto qazx
Next

qazx:
plasma=0
fade=6
While fade<>0:VWait:Wend

Return
cdat:

Data$ "CLEVER BITS"
Data$ "PAUL ANDREWS"
Data$ ""
Data$ "PRETTY BITS"
Data$ "RODNEY SMITH"
Data$ ""
Data$ "NOISY BITS"
Data$ "BLAIR ZUPPICICH"
Data$ ""
Data$ "PRODUCED BY"
Data$ "VISION SOFTWARE"
Data$ "FOR ACID SOFTWARE"
Data$ "WRITTEN IN"
Data$ "BLITZ BASIC 2"
Data$ "XXX"
;--------------------------------------------------------------------
.howtopage
Use BitMap 4
Cls
Use BitMap 5
Cls
DisplayBitMap 0,4
BitMapOutput 0
Use BitMap 0
DisplayPalette 0,5
For l=32 To 63
    setrgb{l,copaddr,0,0,0}
Next
For l=64 To 127
    setrgb{l,copaddr,0,0,0}
Next
setrgb{8,copaddr,0,0,0}

;----------------------
CreateDisplay 1
bh=256+31:bw=320+63
kp.q=rad

If Int(Rnd*10)>5
    sadd.q=Rnd*5+7                 ;plasmax 0.9,1.5,0.9
    ssize.q=Int(Rnd*40)+2     ;xsize  70,40,70
    sadd1.q=Rnd*5+7             ;2.5       ;plasmay 2.5,12.5,182.5
    ssize1.q=Int(Rnd*40)+2    ;ysize  30,20,70
Else
    sadd.q=(Rnd*10)+10            ;plasmax 0.9,1.5,0.9
    ssize.q=Int(Rnd*10)*4+12       ;xsize  70,40,70
    sadd1.q=(Rnd*10)+10                  ;plasmay 2.5,12.5,182.5
    ssize1.q=Int(Rnd*10)*4+12    ;ysize  30,20,70
EndIf

col=0
coladd=1
If Rnd<.5 Then coladd=-1

For lz=0 To (bw*2)-1
    Line lz,0,0,lz,col+32
    col=col+coladd
    If col>31 Then col=0
    If col<0 Then col=31
Next
sval.q=0
For y=00 To bh-1
    ss=Int((Cos(sval*kp)*ssize1)+ssize1)
    Scroll ss,y,bw-ss,1,0,y
    sval=sval+sadd1
Next
sval.q=0
For x=0 To bw-1
    ss=Int((Sin(sval*kp)*ssize)+ssize)
    Scroll x,ss,1,bh-ss,x,0
    sval=sval+sadd
Next

VWait
CreateDisplay 0
;----------------------

Restore cdat2

yy=8

rew2:
Read a$
If a$="XXX" Then Goto wert2
If a$<>""
    cblitprint{yy,a$}
    yy+18
Else
    yy+9
EndIf
Goto rew2

wert2:
Blit 700+0,64,143+9
Blit 700+3,64,161+9
Blit 700+1,64,179+9
Blit 700+4,64,197+9

plasma=1
plascol.q=(Rnd(1)*.5)+.61
plccc=0

For l=0 To 500
    VWait
    If Joyb(0)<>0 OR Joyb(1)<>0 Then startgame=1:Pop For:Goto qazx2
Next

qazx2:
plasma=0
fade=6
While fade<>0:VWait:Wend

Return
cdat2:

Data$ "HOW TO PLAY"             ;8
Data$ ""                        ;26
Data$ "SHOOT THE ZOMBIES"       ;35
Data$ ""                        ;53
Data$ "LMB   GUN"               ;62
Data$ "RMB   MISSILE"           ;80
Data$ "BOTH  GRENADE"           ;98
Data$ ""                        ;116
Data$ "COLLECT POWERUPS"        ;125
Data$ ""
Data$ "   AMMO"                 ;143
Data$ "   GRENADES"             ;161
Data$ "   MISSILES"             ;179
Data$ "   GUN POWER"            ;197
Data$ "XXX"
;--------------------------------------------------------------------
