home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
301-325
/
apd301
/
defender
/
defender.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1991-06-29
|
14KB
|
606 lines
Rem ************************************
Rem ** DEFENDER V1.0 by David Boucher **
Rem ** (C) 1991 RIPOFFWARE Software **
Rem ** 25/8/91 **
Rem ** Read the .doc file! **
Rem ************************************
Dim LEVEL(160)
Break Off
Global LEVEL(),ALIEN$,BULLET$,SHOT$,STARSHELL$,STAR$,NOA,TNOA,AMAX,NOB,LASER
Global RLASER,DLASER,SHIELD,MX_SHIELD,DSHIELD,ALIEN,STAGE,FIN,PROB,FUSE
Global FSEQ$,BSEQ$,SCORE,BONUS,HISC,OHS,LHSC,HT$
Procedure MAINLOOP
SETUP
HISC_LOAD
SET_STRINGS
Do
TITLE
GAME_SETUP
Do
LEVEL_SETUP
Do
Add ALIEN,1,1 To NOA
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
ALIEN_MOVE
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
DROP_BOMB
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
STARSHELL
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
NEW_ALIEN
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
LASER_FIRE
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
PANEL
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
GAME_END
If Mouse Click=2 Then PAUSE
If FIN>0 Then Exit
Loop
If Amreg(4)=1 Then SFX[2] : Amreg(4)=0
LEVEL_END
Exit If Param=1
Loop
Loop
End Proc
Procedure SETUP
Request Off
Randomize Timer
Led Off
If Exist(":") Then HT$=Dir$+"DEF.HSC" Else HT$=":DEF.HSC"
For L=0 To 160
LEVEL(L)=Peek(Start(9)+L)
Next
Wait 100
End Proc
Procedure SET_STRINGS
ALIEN$="Let R7=1 A: Pause; Let R7=R7+1; If R7=4 Jump E; Jump F; H:"
ALIEN$=ALIEN$+"If R6=1 Jump I; Let X=X+R8; Let Y=Y+R9; If X>10 Jump B;"
ALIEN$=ALIEN$+"Let R8=1; B: If X<310 Jump C;Let R8=-1 C: If Y>10 Jump D:"
ALIEN$=ALIEN$+"Let R9=1; D: If Y<120 Jump A; Let R9=-1;Jump A;"
ALIEN$=ALIEN$+"E: Let R7=1;F : If R9<1 Jump G;Let A=R7+5; Jump H;"
ALIEN$=ALIEN$+"G: Let A=R7+8; Jump H;"
ALIEN$=ALIEN$+"I: Anim 1,(12,3)(13,3)(14,3)(15,3)(16,3)(17,3)(21,1);"
ALIEN$=ALIEN$+"J: Pause; If A<21 Jump J; Let X=-10;"
BULLET$="A: Pause; Let Y=Y+R8 If R6=1 Jump B; If Y<R9 Jump A;"
BULLET$=BULLET$+"If RA>0 Jump B; If R9=190 Jump B; Let R9=190; Jump A; B:"
BULLET$=BULLET$+"Anim 1,(18,3)(19,3)(20,3)(21,1); C: Pause; If A<21 Jump C;"
BULLET$=BULLET$+"Let X=-10; If R6=1 Jump D; Let RA=RA-1; Let RE=1;"
BULLET$=BULLET$+"If R9<190 Jump D; Let RB=1; D:"
SHOT$="A: Pause; If K1=0 Jump B; If RC=0 Jump B; Let R9=1; Let RC=RC-1;"
SHOT$=SHOT$+"Let A=A+1; If A<5 Jump C; Let A=4; B: Let A=2; Let R9=0;"
SHOT$=SHOT$+"C: Let X=XS(0,XM); Let Y=YS(0,YM); If R6=0 Jump A; Let X=-10"
STARSHELL$="Let R5=1; A 1,(21,2)(22,2)(23,2)(24,2)(25,2)(26,2); A: Pause;"
STARSHELL$=STARSHELL$+"If A<24 Jump A; C: Pause; If R6=1 Jump D;"
STARSHELL$=STARSHELL$+"If R9=0 Jump D; If RD=1 Jump D; Let R9=R9-1; Jump C;"
STARSHELL$=STARSHELL$+"D: A 1,(26,2)(25,2)(24,2)(23,2)(22,2)(21,2); E:"
STARSHELL$=STARSHELL$+"If A>21 Jump E; Let X=-10;"
STAR$="If X=340 Jump B; A: Pause; Let A=28; Move 360,0,180; B:"
STAR$=STAR$+"Let A=27; Move -360,0,180; Jump A;"
FSEQ$="(100,5)(300,3)(500,3)(700,3)(900,3)(B00,3)(D00,3)"
FSEQ$=FSEQ$+"(F00,7)(D00,3)(B00,3)(900,3)(700,3)(500,3)(300,3)"
BSEQ$="(100,5)(300,3)(500,3)(700,3)(900,3)(B00,3)(D00,3)"
BSEQ$=BSEQ$+"(F00,7)(D00,3)(B00,3)(900,3)(700,3)(500,3)(300,3)(000,1000)"
End Proc
Procedure TITLE
Clear Key
Unpack 10 To 0
Palette 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Ink 0
Paper 0
Double Buffer
Autoback 1
Flash Off
Curs Off
Hide
Priority Reverse On
MESSAGE["--CLICK TO CONTINUE--",76,118]
DIGIT[SCORE,6,73,228]
DIGIT[HISC,6,183,228]
STAR[1,3,1]
STAR[2,56,2]
Fade 1 To -2
Music 1
Wait 30
Flash 15,FSEQ$
M$=Space$(40)
M$=M$+"welcome to ripoffware's latest game: defender! written in amos by"
M$=M$+" david boucher. press left mouse button to start, right to "
M$=M$+"quit."
MSCROLL[M$,247]
Flash Off
Fade 1
For V=63 To 0 Step -1
Mvolume V
Wait Vbl
Next
Music Off
Mvolume 63
Bob Off
If Param=2
Autoback 2
Cls 0
Autoback 1
HISC_SAVE
Led On
Screen Close 0
End
End If
Bar 0,0 To 319,125
PANEL_NOTE[""]
For STARS=1 To 50
X=Rnd(319)
LEVEL[X]
Y=Rnd(Param-5)
Plot X,Y,1
Next
Fade 1 To -2
Wait 30
End Proc
Procedure GAME_SETUP
Update Every 2
Change Mouse 4
Colour 17,$FFF
Show On
Limit Mouse
STAGE=0
SCORE=0
RLASER=4
LASER=64
AMAX=3
NOA=5
NOB=9
BONUS=30
PROB=25
FUSE=200
OHS=HISC
FIN=0
End Proc
Procedure LEVEL_SETUP
Inc STAGE
TNOA=3+STAGE*2
MX_SHIELD=BONUS+STAGE*7+20
MX_SHIELD=(MX_SHIELD/15)*15
SHIELD=MX_SHIELD
DSHIELD=MX_SHIELD/15
DLASER=LASER/15
DIGIT[SCORE,6,73,228]
DIGIT[STAGE,2,150,228]
DIGIT[HISC,6,183,228]
For ALIEN=1 To NOA
Bob ALIEN,Rnd(320),Rnd(20)-30,6
Channel ALIEN To Bob ALIEN
Amal ALIEN,ALIEN$
Dec TNOA
Next
For BULLET=6 To NOB+6
Bob BULLET,-10,-10,18
Channel BULLET To Bob BULLET
Next
Bob 0,-10,-10,2
Channel 0 To Bob 0
Amal 0,SHOT$
Amreg(0)=SHIELD
Amreg(1)=0
Amreg(2)=LASER
Amreg(3)=0
Amal On
Colour 15,(SHIELD/DSHIELD)*256
ALIEN=0
FIN=0
End Proc
Procedure ALIEN_MOVE
X=Amreg(ALIEN,8)
Y=Amreg(ALIEN,9)
X=X+Rnd(2)-1
If Abs(X)>AMAX Then X=AMAX*Sgn(X)
Y=Y+Rnd(2)-1
If Abs(Y)>AMAX Then Y=AMAX*Sgn(Y)
Amreg(ALIEN,8)=X
Amreg(ALIEN,9)=Y
End Proc
Procedure DROP_BOMB
BF=0
For BC=6 To NOB+6
If X Bob(BC)=-10 Then BF=BC
Next
If Rnd(100)>50 and BF>0
X=X Bob(ALIEN)
Y=Y Bob(ALIEN)
If X>10 and X<310 and Y>10
Bob BF,X,Y+3,18
Amal BF,BULLET$
Amreg(BF,8)=Rnd(1)+1
LEVEL[X]
Amreg(BF,9)=Param
Amal On
End If
End If
End Proc
Procedure STARSHELL
BF=0
For BC=6 To NOB+6
If X Bob(BC)=-10 Then BF=BC
Next
If BF>0 and Rnd(10000)<PROB
Dec PROB
Bob BF,Rnd(300)+10,Rnd(100)+10,21
Amal BF,STARSHELL$
Amreg(BF,9)=Rnd(FUSE)+100
Amal On BF
SFX[4]
End If
End Proc
Procedure NEW_ALIEN
For NEW=1 To NOA
If X Bob(NEW)=-10 and TNOA>0
Bob NEW,Rnd(320),Rnd(20)-30,6
Amal NEW,ALIEN$
Amal On NEW
Dec TNOA
End If
Next
End Proc
Procedure LASER_FIRE
If Amreg(0,9)=1
SFX[1]
If Bob Col(0)
For DEAD=1 To 15
If Col(DEAD)
If Amreg(DEAD,6)=0
Amreg(DEAD,6)=1
SFX[3]
If DEAD<=NOA
Add SCORE,STAGE*10
Else
If Amreg(DEAD,5)=0
Add SCORE,STAGE*5
Else
Add SCORE,STAGE*20
Flash 0,BSEQ$
SMART
End If
End If
SCD=1
End If
End If
Next
End If
Else
If Amreg(2)<LASER
Amreg(2)=Amreg(2)+RLASER
If Amreg(2)>LASER : Amreg(2)=LASER : End If
End If
End If
If SCD=1 Then SCORE
End Proc
Procedure PANEL
If Colour(0)=0 Then Flash Off
SHIELD=Amreg(0)
If SHIELD<0 Then SHIELD=0
SCOL=SHIELD/DSHIELD
If SCOL>15 Then SCOL=15
Colour 15,SCOL*256
V=Amreg(2)/DLASER
If V>15 Then V=15
Colour 17,V*17+3840
METER[1,V]
METER[2,SCOL]
End Proc
Procedure GAME_END
OK=1
For FIN=1 To 15
If X Bob(FIN)>-10
If Amreg(FIN,5)=0
OK=0
End If
End If
Next
If TNOA>0 Then OK=0
FIN=0
If Amreg(1)=1 Then FIN=1
If OK=1 Then FIN=2
End Proc
Procedure LEVEL_END
If FIN=1
Amreg(3)=1
SFX[7]
For OFF=0 To 15
If X Bob(OFF)>0 : Amreg(OFF,6)=1 : End If
Next
Flash Off
Colour 0,0
C=$F00
Fade 2,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C
Wait 30
Fade 2
Wait 30
Amal Off
Bob Off
Hide
Autoback 2
Cls 0
Autoback 1
MESSAGE["GAME OVER",124,30]
MESSAGE["THE CITY HAS BEEN DESTROYED!",48,50]
MESSAGE["YOUR SCORE:",116,70]
DIGIT[SCORE,6,128,85]
If OHS<HISC
MESSAGE["THIS IS A NEW HIGH SCORE, WELL DONE!",16,110]
End If
MESSAGE["CLICK TO CONTINUE..",84,130]
Fade 1 To -2
Wait 30
CLICK
Fade 1
Wait 30
Screen Close 0
DEAD=1
Else
Amreg(3)=1
Amreg(0,6)=1
SFX[6]
For AD=1 To 20
SFX[9]
Add SCORE,STAGE*5
SCORE
Next
If STAGE<20
BONUS=SHIELD
SH=SHIELD/DSHIELD
LA=Amreg(2)/DLASER
Do
Amreg(0)=SH*DSHIELD
Amreg(2)=LA*DLASER
PANEL
If SH<16 : Inc SH : Add SCORE,STAGE : SFX[9] : End If
If LA<16 : Inc LA : End If
SCORE
Exit If SH>15 and LA>15
Loop
Else
WIN
DEAD=1
End If
End If
End Proc[DEAD]
Procedure SFX[N]
If N=1
Sample 1 To 1
P=20+(Amreg(2)/DLASER)
Play 1,P,0
End If
If N=2
Sample 2 To 2
P=25+Rnd(5)
Play 2,P,0
End If
If N=3
Sample 3 To 3
P=30+Rnd(5)
Play 3,P,0
End If
If N=4
Sample 4 To 4
Play 4,35,0
End If
If N=5
Sample 5 To 4
Play 4,25,0
End If
If N=6
Sample 6 To 14
Play 14,15,75
End If
If N=7
Sample 7 To 15
Play 15,20,0
End If
If N=8
Sample 8 To 15
Play 15,35,0
End If
If N=9
Sample 9 To 15
Play 15,20,2
End If
End Proc
Procedure WIN
Fade 1
Wait 20
Amal Off
Bob Off
Hide
SCORE=SCORE*2
If HISC<SCORE Then HISC=SCORE
Unpack 10 To 0
Palette 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DIGIT[SCORE,6,73,228]
DIGIT[STAGE,2,150,228]
DIGIT[HISC,6,183,228]
STAR[1,85,1]
STAR[2,123,2]
Ink 0
Bar 0,0 To 319,58
Bar 0,87 To 319,125
Screen Copy 0,0,58,319,87 To 0,0,90
Bar 0,58 To 319,87
MESSAGE["CONGRATULATIONS!",96,10]
MESSAGE["YOU HAVE SAVED THE CITY",68,30]
MESSAGE["FROM THE ALIEN HORDES",76,40]
MESSAGE["YOU HAVE TRULY EARNED THE TITLE:",32,70]
PANEL_NOTE["CLICK TO CONTINUE"]
Fade 1 To -2
SFX[8]
Wait 30
Flash 15,FSEQ$
CLICK
Flash Off
Fade 1
Wait 30
Screen Close 0
End Proc
Procedure PAUSE
Amal Freeze
X=X Mouse
Y=Y Mouse
Hide
Sprite 1,X Mouse,Y Mouse,1
PANEL_NOTE["PAUSED - LEFT MOUSE BUTTON TO UNPAUSE"]
CLICK
PANEL_NOTE[""]
Sprite Off 1
X Mouse=X
Y Mouse=Y
Show
Amal On
End Proc
Procedure SCORE
DIGIT[SCORE,6,73,228]
If SCORE>HISC
HISC=SCORE
DIGIT[HISC,6,183,228]
End If
End Proc
Procedure SMART
For OFF=1 To 15
If X Bob(OFF)>0 : Amreg(OFF,6)=1 : Add SCORE,STAGE : End If
Next
SFX[5]
SCORE
End Proc
Procedure LEVEL[L]
If L<161 Then V=LEVEL(L) Else V=LEVEL(160-(L-160))
End Proc[V]
Procedure METER[M,V]
If V=16 Then V=15
V=77+(15-V)
If M=1
Paste Icon 6,232,V
Else
Paste Icon 250,232,Hrev(V)
End If
End Proc
Procedure DIGIT[NUMBER,L,X,Y]
Shared NUM$
If NUMBER<0
NUM$=String$(":",L)
Else
NUM$=Right$(String$("0",L)+Str$(NUMBER)-" ",L)
End If
For DIGIT=1 To L
Paste Icon X,Y,Asc(Mid$(NUM$,DIGIT,1))-47
Add X,11
Next
End Proc
Procedure MSCROLL[MESSAGE$,Y]
MESSAGE$=Upper$(MESSAGE$)
EPOS=Len(MESSAGE$)
POS=1
Def Scroll 1,0,Y To 320,Y+10,-4,0
Do
OFS=Varptr(MESSAGE$)-1
Paste Icon 309,Y,Peek(OFS+POS)-20
Add POS,1,1 To EPOS
SCR=0
Do
Inc SCR
Scroll 1
Wait Vbl
Exit If SCR=2
MICE=Mouse Click
Exit If MICE>0,2
Loop
Loop
End Proc[MICE]
Procedure MESSAGE[MESSAGE$,X,Y]
MESSAGE$=Upper$(MESSAGE$)
For POS=1 To Len(MESSAGE$)
Paste Icon X,Y,Asc(Mid$(MESSAGE$,POS,1))-20
Add X,8
Next
End Proc
Procedure PANEL_NOTE[MESSAGE$]
Ink 0
Bar 0,247 To 319,255
If MESSAGE$="" Then Pop Proc
X=(320-(Len(MESSAGE$)*8))/2
MESSAGE[MESSAGE$,X,247]
End Proc
Procedure STAR[N,Y,D]
Update Every 1
If D=1 Then Bob N,-20,Y,27 Else Bob N,340,Y,28
Channel N To Bob N
Amal N,STAR$
Amal On N
End Proc
Procedure CLICK
While MICE<>1
MICE=Mouse Click
Wend
SFX[4]
End Proc
Procedure HISC_LOAD
On Error Goto FAULT1
If Exist(HT$)
Open In 1,HT$
Input #1,HI
Close 1
On Error Goto 0
If HI>0 and HI<1000000
HISC=HI
LHSC=HI
End If
End If
ABORT1:
Pop Proc
FAULT1:
Resume ABORT1
End Proc
Procedure HISC_SAVE
On Error Goto FAULT2
If HISC>LHSC
Open Out 1,HT$
On Error Goto 0
Print #1,HISC
Close 1
Wait 300
End If
ABORT2:
Pop Proc
FAULT2:
If Errn=84 or Errn=86
If Errn=84
MESSAGE["THIS DISK IS WRITE PROTECTED!",44,30]
MESSAGE["WRITE ENABLE YOUR DISK AND SELECT",28,90]
Else
MESSAGE["CAN'T FIND THE GAME DISK!",60,30]
MESSAGE["INSERT GAME DISK AND SELECT",52,90]
End If
MESSAGE["DO YOU WANT TO SAVE THE HIGH SCORE?",20,60]
MESSAGE["RETRY IF YOU DO,",96,100]
MESSAGE["OTHERWISE SELECT CANCEL",68,110]
MESSAGE[" LEFT MOUSE-RETRY RIGHT MOUSE-CANCEL ",0,150]
Fade 1 To -2
Wait 30
MICE=0
While MICE=0
MICE=Mouse Click
Wend
Fade 1
Wait 30
Cls 0
If MICE=2 : Resume ABORT2 : End If
Resume
End If
MESSAGE["CAN'T SAVE THE HIGH SCORE!",56,60]
MESSAGE["CLICK TO CONTINUE",92,90]
Fade 1 To -2
Wait 30
CLICK
Fade 1
Wait 30
Cls 0
Resume ABORT2
End Proc
MAINLOOP