; Aeolianation ver0.28
; Main Script



; 初期準備		■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*first
	randomize : rnd trnd,10000
	buffer 7,600,400,1
	picload "title.bmp",1		; タイトル画像描写
	sndload "select.wav",0,0	; 「カッ」
	sndload "exp.wav",1,0		; 「ボカーン」
	sndload "kan.wav",2,0		; 「カンッ」
	sndload "kin.wav",3,0		; 「キンッ」
	sndload "start.wav",4,0		; 「バヒュンヒュン・・・」
	sndload "chi.wav",5,0		; 「チッ」
	sndload "get.wav",6,0		; 「ポピュンッ」
	sndload "menu.wav",7,0
	sndload "title.mid",100,1
	sndload "boss.mid",200,1
	sndload "forward.mid",201,1
	sndload "fan.mid",202,0

	buffer 3,600,600,1		; 背景用バッファ確保
	buffer 4,600,600,1		; ボス用画像描きこみバッファ確保

	stagelimit=5														; 完成しているステージ

; 星の準備		●●●●●●●●●●
	smax=50				; smax		星の最大値
	dim stx,smax		; stx		星のx軸座標
	dim sty,smax		; sty		星のy軸座標
	dim stc,smax		; stc		星の明るさ
	dim sts,smax		; sts		星の移動速度
	repeat smax
		rnd stx.cnt,400
		rnd sty.cnt,550
		rnd stc.cnt,8 : sts.cnt=stc.cnt/2+1 : stc.cnt=stc.cnt*32+31
	loop

	dim scorerank,11,12

; ■■■ファイルの有無をチェック■■■
	alloc chkdir,5000 : str chkdir
	dirlist chkdir,"highscore.dat"
	if stat=1 : gosub *highscoreload : else : gosub *highdat

	dirlist chkdir,"config.dat"
	if stat=1 : gosub *configload : else : gosub *configborn

	alloc chkdir,64

; 全ステージ共通設定準備		●●●●●●●●●●
*restart
	screen 0,400,550,1,200,0 : title "Aeolianation ver0.28"
	gsel 0,1 : palcopy 7
	menuposition=0		; menuposition	メニューポジション初期位置
	cnfgposition=0		; cnfgposition	コンフィグポジション初期位置
	stage=1				; stage		ステージ数
	ending=0			; ending	ステージセレクトを使ったかどうか(0:未使用)
	ttly=100			; ttly		タイトル画像y軸
	ttlyv=1				; ttlyv		タイトル画像運動量
	score=0				; score		ゲームスコア
	itembonus=10		; itembonus	アイテムボーナス初期値
	menuposition=0		; menuposition	メニューポジション初期位置
	cnfgposition=0		; cnfgposition	コンフィグポジション初期位置
	stage=1				; stage		ステージ数
	ending=0			; ending	ステージセレクトを使ったかどうか(0:未使用)
	ttly=100			; ttly		タイトル画像y軸
	ttlyv=1				; ttlyv		タイトル画像運動量
	wrshot=0			; wrshot	右ショット(ノーマル)
	wlshot=0			; wlshot	左ショット(ノーマル)

	gettime mtime,5 : gettime stime,6 : gettime mstime,7 : btime=(mtime*100000)+(stime*1000)+mstime

	if gamebgm=1 : snd 100

; タイトルメニュー	■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*titlemenu
	frame++						; 描き変え回数カウント
	redraw 2
	color 16 : boxf 0,0,400,550			; 画面クリア
	highscore=scorerank.0.level			; highscore	ハイスコア

; ウェポンセレクト
	getkey wselect1,49
	getkey wselect2,50
	getkey wselect3,51
	getkey wselect4,52
	getkey wselect5,53
	getkey wselect6,54
	if wselect1=1 : wrshot=1 : wlshot=1
	if wselect2=1 : wrshot=2 : wlshot=2
	if wselect3=1 : wrshot=3 : wlshot=3
	if wselect4=1 : wrshot=4 : wlshot=4
	if wselect5=1 : wrshot=5 : wlshot=5
	if wselect6=1 : wrshot=6 : wlshot=6

	stick pat,85
	gosub *titlestar				; タイトルバック描写
	gosub *titletext				; メニューテキスト描写
	gosub *titleselect				; キー入力処理
	gosub *gamefps					; FPS表示

	if (pat=32)&(menuposition=0) : goto  *before
	if (pat=32)&(menuposition=1) : gosub *showscore : menuposition=0
	if (pat=32)&(menuposition=2) : gosub *config    : menuposition=0
	getkey returntop,121 : if returntop=1 : end ; 強制終了(F10)

	await gamewait
	redraw 1
goto *titlemenu


; タイトル背景描写	●●●●●●●●●●
*titlestar
	repeat smax
		color stc.cnt,stc.cnt,stc.cnt
		stx.cnt=stx.cnt-sts.cnt : if stx.cnt<0  : stx.cnt=400
		sty.cnt=sty.cnt-sts.cnt : if sty.cnt<0  : sty.cnt=550
		pset stx.cnt,sty.cnt
	loop
	pos 0,50 : gmode 2 : gcopy 7,0,0,400,24			; タイトル画像描写
	if ttly>110 : ttlyv=-1
	if ttly<90  : ttlyv=1
	if frame\2=0 : ttly=ttly+ttlyv
	pos 88,ttly : gmode 2 : gcopy 7,0,26,224,172		; タイトル画像描写
return


; タイトルテキスト描写	●●●●●●●●●●
*titletext
	font "MSゴシック",12,1
	pos 170,35 : color 128,128,128 : mes "Star Ship I"
	font "Times New Roma",12,1
	pos 10,5  : color 255,255,255 : mes "HIGHSCORE  "+highscore

	font "MSゴシック",15,1
	pos 150,300 : color 128,128,128 : mes   "GAME START"
	pos 130,330 : color 128,128,128 : mes "SHOW HIGHSCORE"
	pos 170,360 : color 128,128,128 : mes     "CONFIG"
	pos  50,450 : color 192,0,192   : mes "SELECT MENU AND PUSH RETURN KEY"
return


; タイトルメニュー動作	●●●●●●●●●●
*titleselect
	if pat&8>0 : menuposition++ : if gamesnd=1 : snd 0
	if menuposition>2 : menuposition=0
	if pat&2>0 : menuposition-- : if gamesnd=1 : snd 0
	if menuposition<0 : menuposition=2

	if menuposition=0 : pos 148,298 : color 255,255,255 : mes   "GAME START"
	if menuposition=1 : pos 128,328 : color 255,255,255 : mes "SHOW HIGHSCORE"
	if menuposition=2 : pos 168,358 : color 255,255,255 : mes     "CONFIG"

	if (pat=80)or(pat=81)or(pat=84) : pos 170,500 : color 255,255,0 : mes "STAGE "+stage
	if pat=84 : stage++ : await 150 : if gamesnd=1 : snd 0
	if stage>stagelimit : stage=stagelimit
	if pat=81 : stage-- : await 150 : if gamesnd=1 : snd 0
	if stage<1  : stage=1
	if stage=1 : ending=0 : else : ending=1
return


; FPS表示		●●●●●●●●●●
*gamefps
	gettime mtime,5 : gettime stime,6 : gettime mstime,7 : ntime=(mtime*100000)+(stime*1000)+mstime
	time=ntime-btime
	if (time>1200)or(time<0) : gettime mtime,5 : gettime stime,6 : gettime mstime,7 : btime=(mtime*100000)+(stime*1000)+mstime : frameb=frame :return
	if (time<1200)&(time>1000) : fps=frame-frameb : frameb=frame : btime=ntime
	if fps<1 : return
	totalfps=totalfps+fps : fpstime++ : fratfps=totalfps/fpstime
	font "times new roman bold",12 : color 255,255,255 : pos 350,530 : mes "FPS "+fps
	if (fratfps<15)&(fps<15) : gamewait-- : if gamewait<1 : gamewait=1
return


; コンフィグ処理	●●●●●●●●●●
*config
	if gamebgm=1 : sndoff : wait 10
	if gamesnd=1 : snd 7
	if gamebgm=1 : snd 201
	repeat
		redraw 2
		stick pat,15 : frame++ : frameb=frame
		color 0,0,0 : boxf 10,100,390,500
		color 255,255,255 : pos 10,100
		line 390,100 : line 390,500 : line 10,500 : line 10,100

		if level=0 : levelmes="SUPER EASY LEVEL"
		if level=1 : levelmes="EASY LEVEL"
		if level=2 : levelmes="NORMAL LEVEL"
		if level=3 : levelmes="HARD LEVEL"
		if level=4 : levelmes="MANIA LEVEL"
		if level=5 : levelmes="NORMAL SHOT LIMITED"
		if level=6 : levelmes="V-BEAM LIMITED"
		if level=7 : levelmes="NAPARM LIMITED"
		if level=8 : levelmes="WIDE SHOT LIMITED"
		if level=9 : levelmes="LASER LIMITED"
		if level=10: levelmes="AUTO SHOT LIMITED"
		if level=11: levelmes="HUNTER LIMITED"

		if gamebgm=0 : bgm="Off"
		if gamebgm=1 : bgm="On"

		if gamesnd=0 : gsnd="Off"
		if gamesnd=1 : gsnd="On"

		if shotkey=16 : shotkeymes="SHIFT"
		if shotkey=17 : shotkeymes="CTRL"
		if shotkey=32 : shotkeymes="SPACE"

		if slowdown=0 : sldw="Off"
		if slowdown=1 : sldw="On"

		font "MSゴシック",20,1
		pos 170,150 : color 255,255,255 : mes "CONFIG"

		font "MSゴシック",15,1				; メニュー描写
		pos 50,200 : color 128,128,0 : mes "GAME SPEED"
		pos 50,230 : color 128,128,0 : mes "GAME LEVEL"
		pos 50,260 : color 128,128,0 : mes "BGM"
		pos 50,290 : color 128,128,0 : mes "SOUND EFFECT"
		pos 50,320 : color 128,128,0 : mes "SHOT KEY"
		pos 50,350 : color 128,128,0 : mes "SLOW DOWN"

		pos 200,200 : color 0,128,0 : mes gamewait
		pos 200,230 : color 0,128,0 : mes levelmes
		pos 200,260 : color 0,128,0 : mes bgm
		pos 200,290 : color 0,128,0 : mes gsnd
		pos 200,320 : color 0,128,0 : mes shotkeymes
		pos 200,350 : color 0,128,0 : mes sldw

		pos 130,450 : color 255,0,255 : mes "PUSH RETURN KEY"

		if pat&8>0 : cnfgposition++ : wait 5 : if gamesnd=1 : snd 0
		if cnfgposition>5 : cnfgposition=0
		if pat&2>0 : cnfgposition-- : wait 5 : if gamesnd=1 : snd 0
		if cnfgposition<0 : cnfgposition=5

		if (cnfgposition=0)&(pat&4>0) : gamewait++ : wait 1 : if gamesnd=1 : snd 0
		if gamewait>60 : gamewait=60
		if (cnfgposition=0)&(pat&1>0) : gamewait-- : wait 1 : if gamesnd=1 : snd 0
		if gamewait<1 : gamewait=1

		if (cnfgposition=1)&(pat&4>0) : level++ : wait 10 : if gamesnd=1 : snd 0
		if level>11: level=11
		if (cnfgposition=1)&(pat&1>0) : level-- : wait 10 : if gamesnd=1 : snd 0
		if level<0 : level=0 

		if (cnfgposition=2)&(pat&4>0) : gamebgm++ : wait 10 : if gamesnd=1 : snd 0
		if gamebgm>1 : gamebgm=0
		if (cnfgposition=2)&(pat&1>0) : gamebgm-- : wait 10 : if gamesnd=1 : snd 0
		if gamebgm<0 : gamebgm=1

		if (cnfgposition=3)&(pat&4>0) : gamesnd++ : wait 10 : if gamesnd=1 : snd 0
		if gamesnd>1 : gamesnd=0
		if (cnfgposition=3)&(pat&1>0) : gamesnd-- : wait 10 : if gamesnd=1 : snd 0
		if gamesnd<0 : gamesnd=1

		if (cnfgposition=4)&(pat&4>0) : shotkey++ : wait 10 : if gamesnd=1 : snd 0
		if shotkey>17 : shotkey=32
		if (cnfgposition=4)&(pat&1>0) : shotkey-- : wait 10 : if gamesnd=1 : snd 0
		if (shotkey<32)&(shotkey>16)  : shotkey=17
		if shotkey<16 : shotkey=16

		if (cnfgposition=5)&(pat&4>0) : slowdown++ : wait 10 : if gamesnd=1 : snd 0
		if slowdown>1 : slowdown=0
		if (cnfgposition=5)&(pat&1>0) : slowdown-- : wait 10 : if gamesnd=1 : snd 0
		if slowdown<0 : slowdown=1

		if cnfgposition=0 : pos  48,198 : color 255,255,0 : mes "GAME SPEED"   : pos 198,198 : color 0,255,0 : mes gamewait
		if cnfgposition=1 : pos  48,228 : color 255,255,0 : mes "GAME LEVEL"   : pos 198,228 : color 0,255,0 : mes levelmes
		if cnfgposition=2 : pos  48,258 : color 255,255,0 : mes "BGM"          : pos 198,258 : color 0,255,0 : mes bgm
		if cnfgposition=3 : pos  48,288 : color 255,255,0 : mes "SOUND EFFECT" : pos 198,288 : color 0,255,0 : mes gsnd
		if cnfgposition=4 : pos  48,318 : color 255,255,0 : mes "SHOT KEY"     : pos 198,318 : color 0,255,0 : mes shotkeymes
		if cnfgposition=5 : pos  48,348 : color 255,255,0 : mes "SLOW DOWN"    : pos 198,348 : color 0,255,0 : mes sldw

		getkey spat,shotkey
		if (pat=32)or(spat>0) : break
		getkey returntop,121 : if returntop=1 : end ; 強制終了(F10)
		await 1
		redraw 1
	loop
	sndoff : wait 10
	if gamesnd=1 : snd 7
	if gamebgm=1 : snd 100
	gettime mtime,5 : gettime stime,6 : gettime mstime,7 : btime=(mtime*100000)+(stime*1000)+mstime : frameb=frame
	gosub *configsave
return


; ハイスコアを見る!の巻(笑)
*showscore
	if gamebgm=1 : sndoff : wait 10
	if gamesnd=1 : snd 7
	if gamebgm=1 : snd 201
	meslevel=level

	repeat
		redraw 2

		color 0,0,0 : boxf 10,100,390,500
		color 255,255,255 : pos 10,100
		line 390,100 : line 390,500 : line 10,500 : line 10,100
		font "MSゴシック",20,1
		pos 150,120 : color 255,255,255 : mes "HIGHSCORE"

		if meslevel=0 : dmlevel="SUPER EASY LEVEL RANKING"
		if meslevel=1 : dmlevel="EASY LEVEL RANKING"
		if meslevel=2 : dmlevel="NORMAL LEVEL RANKING"
		if meslevel=3 : dmlevel="HARD LEVEL RANKING"
		if meslevel=4 : dmlevel="MANIA LEVEL RANKING"
		if meslevel=5 : dmlevel="NORMAL SHOT LIMITED RANKING"
		if meslevel=6 : dmlevel="V-BEAM LIMITED RANKING"
		if meslevel=7 : dmlevel="NAPARM LIMITED RANKING"
		if meslevel=8 : dmlevel="WIDE SHOT LIMITED RANKING"
		if meslevel=9 : dmlevel="LASER LIMITED RANKING"
		if meslevel=10: dmlevel="AUTO SHOT LIMITED RANKING"
		if meslevel=11: dmlevel="HUNTER LIMITED RANKING"

		font "MSゴシック",15,1
		pos 100,170 : color 128,128,0 : mes dmlevel
		pos  99,168 : color 255,255,0 : mes dmlevel

		scorepos=220
		repeat 10
			drank=scorerank.cnt.meslevel
			str drank,9
			pos 100,scorepos   : color 0,128,128 : mes cnt+1
			pos 98,scorepos-2  : color 0,255,255 : mes cnt+1
			pos 135,scorepos   : color 0,128,128 : mes "--------------"
			pos 133,scorepos-2 : color 0,255,255 : mes "--------------"
			pos 250,scorepos   : color 0,128,128 : mes drank
			pos 248,scorepos-2 : color 0,255,255 : mes drank
			scorepos=scorepos+20
		loop

		pos 130,450 : color 255,0,255 : mes "PUSH RETURN KEY"
		stick pat,5
		getkey spat,shotkey
		if (pat=32)or(spat>0) : break
		if pat=1 : meslevel-- : wait 10 : if gamesnd=1 : snd 0
		if meslevel<0 : meslevel=0
		if pat=4 : meslevel++ : wait 10 : if gamesnd=1 : snd 0
		if meslevel>11: meslevel=11
		getkey returntop,121 : if returntop=1 : end ; 強制終了(F10)
		await 1
		redraw 1
	loop

	gettime mtime,5 : gettime stime,6 : gettime mstime,7 : btime=(mtime*100000)+(stime*1000)+mstime : frameb=frame

	if gamebgm=1 : sndoff : wait 10
	if gamesnd=1 : snd 7
	if gamebgm=1 : snd 100
return


; ゲーム前準備		■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*before
	randomize trnd
	mx=184 : my=400		; mx,my		自機の初期配置
	mf=10				; mf		自機の初期シールド量
	bfmf=10				; bfmf		ステージ開始時のシールド量(1面スタート時は10)
	shtimer=3			; shtimer	右自機弾発射間隔
	shtimel=3			; shtimel	左自機弾発射間隔
	move=6				; move		自機移動速度
	wmax=12				; wmax		自機弾最大数(左右合計)
	emax=100			; emax		敵の最大数
	pmax=20				; pmax		爆発の最大数
	tmax=300			; tmax		敵弾最大数
	ibmax=20			; ibmax		アイテム・ボーナス最大数
	gtime=0				; gtime		経過時間
	stageend=0			; stageend	ステージの終わりフラグ(1:終了)
	frame=0

	gamelevel=level : if gamelevel>4 : gamelevel=2

	if (ending=0)&(wrshot!6) : wrshot=0 : wlshot=0

	buffer 2,600,400,1
	picload "myship.bmp",1	; 全ステージ共有画像の読みこみ

	dim wrfix,6			; wrfix		右故障中(0:使用可能)
	dim wlfix,6			; wlfix		左故障中(0:使用可能)

; 面データロード		■■■■■■■■■■■■■■■■■■■■■■■■ 武器セレクト終了後はここへジャンプ
*stagedataload
	if level=5 : wrshot=0 : wlshot=0
	if level=6 : wrshot=1 : wlshot=1
	if level=7 : wrshot=2 : wlshot=2
	if level=8 : wrshot=3 : wlshot=3
	if level=9 : wrshot=4 : wlshot=4
	if level=10: wrshot=5 : wlshot=5
	if level=11: wrshot=6 : wlshot=6

	if (ending=1)&(stage>2) : move=8
	if (ending=1)&(stage>4) : move=10

; 自機弾用配列変数の準備(要素番号0〜5は右、6〜11は左)
	dim wx,wmax			; wx		自機弾x軸座標
	dim wy,wmax			; wy		自機弾y軸座標
	dim wf,wmax			; wf		自機弾on/off(0:off)
	dim wb,wmax			; wb		爆風表示等のフラグ(0:off)
	dim wd,wmax			; wd		自機弾ダメージ量
	dim wxv,wmax		; wxv		自機弾x方向運動量
	dim wyv,wmax		; wyv		自機弾y方向運動量
	dim wxc,wmax		; wxc		wxから中心までの距離
	dim wyc,wmax		; wyc		wyから中心までの距離
	dim wxw,wmax		; wxw		中心からのx方向当り判定範囲
	dim wyw,wmax		; wyw		中心からのy方向当り判定範囲
	dim wxg,wmax		; wxg		画像x位置
	dim wyg,wmax		; wyg		画像y位置

; 敵弾用配列変数の準備
	dim tx,tmax			; tx		敵弾x軸座標
	dim ty,tmax			; ty		敵弾y軸座標
	dim tf,tmax			; tf		敵弾on/off
	dim txv,tmax		; txv		敵弾x方向運動量
	dim tyv,tmax		; tyv		敵弾y方向運動量
	dim txc,tmax		; txc		敵弾中心点x
	dim tyc,tmax		; tyc		敵弾中心点y
	dim txw,tmax		; txw		敵弾x方向当り判定範囲
	dim tyw,tmax		; tyw		敵弾y方向当り判定範囲
	dim ts,tmax			; ts		敵弾速度
	dim tgx,tmax		; tgx		敵弾グラフィックx位置
	dim tgy,tmax		; tgy		敵弾グラフィックy位置
	dim tgxw,tmax		; tgxw		敵弾グラフィック幅x
	dim tgyw,tmax		; tgyw		敵弾グラフィック幅y

; 敵用配列変数の準備
	dim ex,emax			; ex		敵x軸座標
	dim ey,emax			; ey		敵y軸座標
	dim ef,emax			; ef		敵固さ・生死
	dim exv,emax		; exv		敵x方向運動量
	dim eyv,emax		; eyv		敵y方向運動量
	dim exc,emax		; exc		敵中心点x
	dim eyc,emax		; eyc		敵中心点y
	dim exw,emax		; exw		敵x方向当り判定範囲
	dim eyw,emax		; eyw		敵y方向当り判定範囲
	dim em,emax			; em		敵の種類
	dim et,emax			; et		生成されてからの時間
	dim ep,emax			; ep		爆発パターン
	dim es,emax			; es		スコア

; 爆発アニメ用配列変数
	dim px,pmax			; px		爆発x座標
	dim py,pmax			; py		爆発y座標
	dim pxv,pmax		; pxv		爆発x方向運動量
	dim pyv,pmax		; pyv		爆発y方向運動量
	dim pf,pmax			; pf		爆発アニメ総枚数
	dim pm,pmax			; pm		爆発パターン

; アイテム用配列変数
	dim ibx,ibmax		; ibx		アイテムx軸座標
	dim iby,ibmax		; iby		アイテムy軸座標
	dim ibyv,ibmax		; ibyv		アイテム運動量
	dim ibf,ibmax		; ibf		得点表示時間・on/off
	dim ibm,ibmax		; ibm		ボーナス(0)かアイテム(1)か
	sdim ibs,10,ibmax	; ibs		表示されるスコア等(文字列型)


	gsel 0 : redraw 1 : color 0,0,0 : boxf 0,0,400,550
	pos 100,250 : color 255,255,0 : font "MSゴシック",15,1
	mes "Now Loading Stage "+stage+" Data"
	if gamebgm=1 : sndoff : wait 10
	if gamesnd=1 : snd 4

	alloc data,10000

	if stage=1 : gosub *stagedata01
	if stage=2 : gosub *stagedata02
	if stage=3 : gosub *stagedata03
	if stage=4 : gosub *stagedata04
	if stage=5 : gosub *stagedata05
	if stage=6 : gosub *stagedata06
	if stage=7 : gosub *stagedata07
	if stage=8 : gosub *stagedata08
	if stage=9 : gosub *stagedata09
	if stage=10: gosub *stagedata10
	if stage=11: gosub *stagedata11
	if stage=12: gosub *stagedata12
	if stage=13: gosub *stagedata13
	if stage=14: gosub *stagedata14
	if stage=15: gosub *stagedata15
	if stage=16: gosub *stagedata16
	if stage=17: gosub *stagedata17
	if stage=18: gosub *stagedata18
	if stage=19: gosub *stagedata19
	if stage=20: gosub *stagedata20

	notesel data			; data		面データテキスト格納用変数
	notemax nmax			; nmax		面データ行数
	sdim dmmy,20,nmax		; dmmy		一行毎の一時保管変数
	dim bt,nmax				; bt		出現時間
	dim be,nmax				; be		出現させる敵番号(0:なし)
	dim bx,nmax				; bx		出現位置x座標
	dim by,nmax				; by		出現位置y座標
	repeat nmax
		noteget dmmy.cnt,cnt		;dataの一行 → dmmy.cntに代入

		getstr dbt,dmmy.cnt,idx,44	;一時保管変数dbtに出現タイミングを読み出し
		int dbt						;文字列型→整数型に変更
		bt.cnt=dbt					;実際利用するbt.cntに代入

		idx=idx+strsize				;読み出し位置の変更
		getstr dbe,dmmy.cnt,idx,44	;敵ナンバー読み出し
		int dbe
		be.cnt=dbe

		idx=idx+strsize
		getstr dbx,dmmy.cnt,idx,44	;敵初期出現x位置読み出し
		int dbx
		bx.cnt=dbx

		idx=idx+strsize
		getstr dby,dmmy.cnt,idx		;敵初期出現y位置読み出し
		int dby
		by.cnt=dby

		idx=0						;読み出し位置の初期化
	loop

	step=0							;敵呼び出し番号初期化

	gsel 0 : gmode 2
	alloc data,64

	gettime mtime,5 : gettime stime,6 : gettime mstime,7 : btime=(mtime*100000)+(stime*1000)+mstime : frameb=frame
	gtime=0 : damage=0 : stageend=0 : bgcolor=16


; メインルーチン		■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*main
	redraw 2
	gtime++ : damage-- : frame++
	color bgcolor : boxf 0,0,400,550
	if damage<28 : bgcolor=16

	gosub *haikei								; 背景処理
	if gtime=stageboss : gosub *bossborn		; ボス出現処理
	if gtime=bt.step   : gosub *enemyborn		; 敵生成
	gosub *enemymove							; 敵移動
	gosub *jikimove								; 自機移動処理
	gosub *jikitama								; 自機弾処理
	gosub *explosion							; 爆発アニメ表示
	gosub *itemget								; アイテム獲得判定
	gosub *tekitamamove							; 敵弾移動
	gosub *gamescore							; スコア等表示
	gosub *gamefps								; fps表示
	if pat&128>0 : gosub *pausegame				; ポーズ
	getkey returntop,116 : if returntop=1 : mf=0; 自爆(F5)
	getkey returntop,121 : if returntop=1 : end ; 強制終了(F10)
	if mf<1 : goto *gameover					; ゲームオーバー処理
	if gtime>(stageboss*3) : stageend=2
	if stageend>0 : goto *stageclear			; ステージクリア
	await gamewait
	if (slowdown=1)&(fratfps>15)&(fps>(fratfps*8/10)) : await tcnt/30 : tcnt=0
	redraw 1
	palette 16,stagebgcr,stagebgcg,stagebgcb

goto *main


; 背景描写ルーチン		■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*haikei
	if stage=1 : gosub *haikei01
	if stage=2 : gosub *haikei02
	if stage=3 : gosub *haikei03
	if stage=4 : gosub *haikei04
	if stage=5 : gosub *haikei05
	if stage=6 : gosub *haikei06
return


; 自機移動ルーチン				●●●●●●●●●●
*jikimove
	stick pat,15 : getkey spat,shotkey
	shotr=0 : shotl=0 : shtimer-- : shtimel--
	if (shtimer<0)&(spat>0) : shotr=1			; 右弾発射フラグ
	if (shtimel<0)&(spat>0) : shotl=1			; 左弾発射フラグ
	xv=(pat>>2&1)-(pat&1)
	yv=(pat>>3&1)-(pat>>1&1)
	if mf<3 : rnd mmx,3 : rnd mmy,3 : mmx-- : mmy--		; ヤラれる直前のヨレヨレ
	mx=xv*move+mx+mmx : my=yv*move+my+mmy : mmx=0 : mmy=0
	if mx<-8  : mx=-8
	if mx>376 : mx=376
	if my<100 : my=100
	if my>490 : my=490
	if damage<1  : pos mx,my : gcopy 2,xv*32+32,gtime\2*40,32,40
	if frame\2=0 : pos mx,my : gcopy 2,xv*32+32,gtime\2*40,32,40
return


; 自機弾発射・移動						●●●●●●●●●●
*jikitama
	if wrshot=0 : gosub *r_normal
	if wlshot=0 : gosub *l_normal
	if wrshot=1 : gosub *r_vbeam
	if wlshot=1 : gosub *l_vbeam
	if wrshot=2 : gosub *r_naparm
	if wlshot=2 : gosub *l_naparm
	if wrshot=3 : gosub *r_wide
	if wlshot=3 : gosub *l_wide
	if wrshot=4 : gosub *r_laser
	if wlshot=4 : gosub *l_laser
	if wrshot=5 : gosub *r_auto
	if wlshot=5 : gosub *l_auto
	if wrshot=6 : gosub *r_guided
	if wlshot=6 : gosub *l_guided
return

*r_normal		; ノーマルショット右	▼▼▼▼▼ 0 ▼▼▼▼▼
	repeat 6
		if wb.cnt=1 : pos wx.cnt-4,wy.cnt-4 : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if (shotr=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx+21 : wy.cnt=my+8 : shotr=0 : shtimer=2
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,0,80,8,8
		wxv.cnt=0 : wyv.cnt=-16
		wxc.cnt=4 : wyc.cnt=4
		wxw.cnt=4 : wyw.cnt=4
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt>400 : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<0   : wf.cnt=0
	loop
return


*l_normal		; ノーマルショット左	▼▼▼▼▼ 0 ▼▼▼▼▼
	repeat 6,6
		if wb.cnt=1 : pos wx.cnt-4,wy.cnt-4 : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if (shotl=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx+2 : wy.cnt=my+8 : shotl=0 : shtimel=2
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,0,80,8,8
		wxv.cnt=0 : wyv.cnt=-16
		wxc.cnt=4 : wyc.cnt=4
		wxw.cnt=4 : wyw.cnt=4
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt>400 : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<0   : wf.cnt=0
	loop
return


*r_vbeam		; Vビーム右			▼▼▼▼▼ 1 ▼▼▼▼▼
	wxv.0=1   : wxv.1=1   : wxv.2=1   : wxv.3=6   : wxv.4=6   : wxv.5=6
	wyv.0=-16 : wyv.1=-16 : wyv.2=-16 : wyv.3=-15 : wyv.4=-15 : wyv.5=-15
	if (shotr=1)&(wf.0<1)&(wf.3<1) : wf.0=1 : wx.0=mx+21 : wy.0=my+8 : wf.3=1 : wx.3=mx+21 : wy.3=my+8 : shotr=0 : shtimer=3
	if (shotr=1)&(wf.1<1)&(wf.4<1) : wf.1=1 : wx.1=mx+21 : wy.1=my+8 : wf.4=1 : wx.4=mx+21 : wy.4=my+8 : shotr=0 : shtimer=3
	if (shotr=1)&(wf.2<1)&(wf.5<1) : wf.2=1 : wx.2=mx+21 : wy.2=my+8 : wf.5=1 : wx.5=mx+21 : wy.5=my+8 : shotr=0 : shtimer=3
	repeat 6
		if wb.cnt=1 : pos wx.cnt-4,wy.cnt-4 : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,0,80,8,8
		wxc.cnt=4 : wyc.cnt=4
		wxw.cnt=4 : wyw.cnt=4
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt>400 : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<0   : wf.cnt=0
	loop
return


*l_vbeam		; Vビーム左			▼▼▼▼▼ 1 ▼▼▼▼▼
	wxv.6=-1  : wxv.7=-1   : wxv.8=-1  : wxv.9=-6  : wxv.10=-6  : wxv.11=-6
	wyv.6=-16 : wyv.7=-16  : wyv.8=-16 : wyv.9=-15 : wyv.10=-15 : wyv.11=-15
	if (shotl=1)&(wf.6<1)&(wf.9<1)  : wf.6=1 : wx.6=mx+2 : wy.6=my+8 : wf.9=1  : wx.9=mx+2  : wy.9=my+8  : shotl=0 : shtimel=3
	if (shotl=1)&(wf.7<1)&(wf.10<1) : wf.7=1 : wx.7=mx+2 : wy.7=my+8 : wf.10=1 : wx.10=mx+2 : wy.10=my+8 : shotl=0 : shtimel=3
	if (shotl=1)&(wf.8<1)&(wf.11<1) : wf.8=1 : wx.8=mx+2 : wy.8=my+8 : wf.11=1 : wx.11=mx+2 : wy.11=my+8 : shotl=0 : shtimel=3
	repeat 6,6
		if wb.cnt=1 : pos wx.cnt-4,wy.cnt-4 : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,0,80,8,8
		wxc.cnt=4 : wyc.cnt=4
		wxw.cnt=4 : wyw.cnt=4
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt<-8 : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<0  : wf.cnt=0
	loop
return


*r_naparm		; ナパーム右		▼▼▼▼▼ 2 ▼▼▼▼▼
	repeat 3
		wn=cnt+3
		if wb.cnt=1 : wb.cnt=0 : wf.cnt-- : wf.wn=12 : wx.wn=wx.cnt-21 : wy.wn=wy.cnt-17
		if (shotr=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx+22 : wy.cnt=my+4 : shotr=0 : shtimer=4
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,0,96,8,16
		wxv.cnt=0 : wyv.cnt=-12
		wxc.cnt=4 : wyc.cnt=8
		wxw.cnt=4 : wyw.cnt=8
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt>400 : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<-32 : wf.cnt=0
	loop

	repeat 3,3
		if wf.cnt<1 : continue
		wxc.cnt=24 : wyc.cnt=24
		wd.cnt=1
		pos wx.cnt,wy.cnt
		if wf.cnt>8              : gcopy 2,100,0,48,48  : wxw.cnt=22 : wyw.cnt=22
		if (wf.cnt>4)&(wf.cnt<9) : gcopy 2,100,48,48,48 : wxw.cnt=18 : wyw.cnt=18
		if (wf.cnt>0)&(wf.cnt<5) : gcopy 2,100,96,48,48 : wxw.cnt=14 : wyw.cnt=14
		if frame\2=0 : wf.cnt--
		wy.cnt--
	loop
return


*l_naparm		; ナパーム左		▼▼▼▼▼ 2 ▼▼▼▼▼
	repeat 3,6
		wn=cnt+3
		if wb.cnt=1 : wb.cnt=0 : wf.cnt-- : wf.wn=12 : wx.wn=wx.cnt-21 : wy.wn=wy.cnt-17
		if (shotl=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx+2 : wy.cnt=my+4 : shotl=0 : shtimel=4
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,0,96,8,16
		wxv.cnt=0 : wyv.cnt=-12
		wxc.cnt=4 : wyc.cnt=8
		wxw.cnt=4 : wyw.cnt=8
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt<0   : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<-32 : wf.cnt=0
	loop

	repeat 3,9
		if wf.cnt<1 : continue
		wd.cnt=1
		pos wx.cnt,wy.cnt
		if wf.cnt>8              : gcopy 2,100,0,48,48  : wxw.cnt=22 : wyw.cnt=22
		if (wf.cnt>4)&(wf.cnt<9) : gcopy 2,100,48,48,48 : wxw.cnt=18 : wyw.cnt=18
		if (wf.cnt>0)&(wf.cnt<5) : gcopy 2,100,96,48,48 : wxw.cnt=14 : wyw.cnt=14
		if frame\2=0 : wf.cnt--
		wy.cnt--
	loop
return


*r_wide			; ワイドショット右	▼▼▼▼▼ 3 ▼▼▼▼▼
	wxv.0=6  : wyv.0=-20 : wxg.0=80 : wyg.0=112
	wxv.1=10 : wyv.1=-19 : wxg.1=76 : wyg.1=360
	wxv.2=20 : wyv.2=-2  : wxg.2=80 : wyg.2=128
	wxv.3=20 : wyv.3=2   : wxg.3=80 : wyg.3=128
	wxv.4=6  : wyv.4=20  : wxg.4=64 : wyg.4=128
	wxv.5=10 : wyv.5=19  : wxg.5=76 : wyg.5=376
	if (shotr=1)&(wf.0<1)&(wf.1<1) : wf.0=1 : wx.0=mx+10 : wy.0=my+10 : wf.1=1 : wx.1=mx+10 : wy.1=my+10 : shotr=0 : shtimer=1
	if (shotr=1)&(wf.2<1)&(wf.3<1) : wf.2=1 : wx.2=mx+12 : wy.2=my+14 : wf.3=1 : wx.3=mx+12 : wy.3=my+14 : shotr=0 : shtimer=1
	if (shotr=1)&(wf.4<1)&(wf.5<1) : wf.4=1 : wx.4=mx+10 : wy.4=my+18 : wf.5=1 : wx.5=mx+10 : wy.5=my+18 : shotr=0 : shtimer=1
	repeat 6
		if wb.cnt=1 : pos wx.cnt,wy.cnt : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,wxg.cnt,wyg.cnt,16,16
		wxc.cnt=8 : wyc.cnt=8
		wxw.cnt=12: wyw.cnt=12
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if (wx.cnt>400)or(wx.cnt<-16) : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if (wy.cnt<-16)or(wy.cnt>550) : wf.cnt=0
	loop
return


*l_wide			; ワイドショット左	▼▼▼▼▼ 3 ▼▼▼▼▼
	wxv.6=-6  : wyv.6=-20 : wxg.6=80  : wyg.6=112
	wxv.7=-10 : wyv.7=-19 : wxg.7=60  : wyg.7=360
	wxv.8=-20 : wyv.8=-2  : wxg.8=64  : wyg.8=112
	wxv.9=-20 : wyv.9=2   : wxg.9=64  : wyg.9=112
	wxv.10=-6 : wyv.10=20 : wxg.10=64 : wyg.10=128
	wxv.11=-10: wyv.11=19 : wxg.11=60 : wyg.11=376
	if (shotl=1)&(wf.6<1)&(wf.7<1)   : wf.6=1  : wx.6=mx+4  : wy.6=my+10  : wf.7=1  : wx.7=mx+4  : wy.7=my+10  : shotl=0 : shtimel=1
	if (shotl=1)&(wf.8<1)&(wf.9<1)   : wf.8=1  : wx.8=mx+2  : wy.8=my+14  : wf.9=1  : wx.9=mx+2  : wy.9=my+14  : shotl=0 : shtimel=1
	if (shotl=1)&(wf.10<1)&(wf.11<1) : wf.10=1 : wx.10=mx+4 : wy.10=my+18 : wf.11=1 : wx.11=mx+4 : wy.11=my+18 : shotl=0 : shtimel=1
	repeat 6,6
		if wb.cnt=1 : pos wx.cnt,wy.cnt : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,wxg.cnt,wyg.cnt,16,16
		wxc.cnt=8 : wyc.cnt=8
		wxw.cnt=12: wyw.cnt=12
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if (wx.cnt>400)or(wx.cnt<-16) : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if (wy.cnt<-16)or(wy.cnt>550) : wf.cnt=0
	loop
return


*r_laser		; レーザー右		▼▼▼▼▼ 4 ▼▼▼▼▼
	repeat 2
		if wb.cnt=1 : pos wx.cnt-6,wy.cnt-16 : gcopy 2,8,96,16,16 : wb.cnt=0
		if (shotr=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx+22 : wy.cnt=my-8 : shotr=0 : shtimer=3
		if wf.cnt<1 : continue
		wxv.cnt=0 : wyv.cnt=-32
		wxc.cnt=4 : wyc.cnt=24
		wxw.cnt=2 : wyw.cnt=24
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt>400 : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<-32 : wf.cnt=0
		pos wx.cnt,wy.cnt : gcopy 2,96,0,4,48
	loop
return


*l_laser		; レーザー左		▼▼▼▼▼ 4 ▼▼▼▼▼
	repeat 2,6
		if wb.cnt=1 : pos wx.cnt-6,wy.cnt-16 : gcopy 2,8,96,16,16 : wb.cnt=0
		if (shotl=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx+6 : wy.cnt=my-8 : shotl=0 : shtimel=3
		if wf.cnt<1 : continue
		wxv.cnt=0 : wyv.cnt=-32
		wxc.cnt=4 : wyc.cnt=24
		wxw.cnt=2 : wyw.cnt=24
		wd.cnt=5
		wx.cnt=wx.cnt+wxv.cnt : if wx.cnt<0   : wf.cnt=0
		wy.cnt=wy.cnt+wyv.cnt : if wy.cnt<-32 : wf.cnt=0
		pos wx.cnt,wy.cnt : gcopy 2,96,0,4,48
	loop
return


*r_auto			; オートショット右	▼▼▼▼▼ 5 ▼▼▼▼▼
	if wb.0=1 : pos wx.0-8,wy.0-8 : gcopy 2,8,96,16,16 : wb.0=0 : wf.0=0
	if shotr=0 : return
	demax=emax-dd
	repeat demax,dd
		if ef.cnt<1 : continue
		wx.0=ex.cnt+exc.cnt
		wy.0=ey.cnt+eyc.cnt 
		wd.0=1     : wf.0=1
		dd=cnt+1 : if dd>99 : dd=0
		pos mx+24,my+18 : color 255,0,0 : line wx.0,wy.0 : shotr=0 : shtimer=2 : break
	loop
	if (dd=0)or(shotr=0) : return
	repeat dd
		if ef.cnt<1 : continue
		wx.0=ex.cnt+exc.cnt
		wy.0=ey.cnt+eyc.cnt 
		wd.0=1     : wf.0=1
		dd=cnt+1 : if dd>99 : dd=0
		pos mx+24,my+18 : color 255,0,0 : line wx.0,wy.0 : shotr=0 : shtimer=2 : break
	loop
return

*l_auto			; オートショット左	▼▼▼▼▼ 5 ▼▼▼▼▼
	if wb.6=1 : pos wx.6-8,wy.6-8 : gcopy 2,8,96,16,16 : wb.6=0 : wf.6=0
	if shotl=0 : return
	demax=emax-dd
	repeat demax,dd
		if ef.cnt<1 : continue
		wx.6=ex.cnt+exc.cnt
		wy.6=ey.cnt+eyc.cnt 
		wd.6=1     : wf.6=1
		dd=cnt+1 : if dd>99 : dd=0
		pos mx+7,my+18 : color 255,0,0 : line wx.6,wy.6 : shotl=0 : shtimel=2 : break
	loop
	if (dd=0)or(shotl=0) : return
	repeat dd
		if ef.cnt<1 : continue
		wx.6=ex.cnt+exc.cnt
		wy.6=ey.cnt+eyc.cnt 
		wd.6=1     : wf.6=1
		dd=cnt+1 : if dd>99 : dd=0
		pos mx+7,my+18 : color 255,0,0 : line wx.6,wy.6 : shotl=0 : shtimel=2 : break
	loop
return


*r_guided		; 自力誘導弾右		▼▼▼▼▼ 6 ▼▼▼▼▼
	repeat 6
		if wb.cnt=1 : pos wx.cnt,wy.cnt : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if (shotr=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx+16 : wy.cnt=my+4 : wxv.cnt=1 : wyv.cnt=-3 : shotr=0 : shtimer=2 : gosub *hunting
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,80,80,16,16
		wxc.cnt=8 : wyc.cnt=8
		wxw.cnt=8 : wyw.cnt=8
		wd.cnt=2
		wx.cnt=wx.cnt+wxv.cnt : wy.cnt=wy.cnt+wyv.cnt
		if (wx.cnt>400)or(wx.cnt<-16) : wf.cnt=0
		if (wy.cnt<-16)or(wy.cnt>550) : wf.cnt=0
		if ef.hunt<1 : gosub *hunting : if dmax=1000 : continue
		dx=(wx.cnt+8)-(ex.hunt+exc.hunt) : dy=(wy.cnt+8)-(ey.hunt+eyc.hunt)
		if dx<0 : wxv.cnt=wxv.cnt+5 : if wxv.cnt>20  : wxv.cnt=20
		if dx>0 : wxv.cnt=wxv.cnt-5 : if wxv.cnt<-20 : wxv.cnt=-20
		if dy<0 : wyv.cnt=wyv.cnt+5 : if wyv.cnt>20  : wyv.cnt=20
		if dy>0 : wyv.cnt=wyv.cnt-5 : if wyv.cnt<-20 : wyv.cnt=-20
	loop
return


*l_guided		; 自力誘導弾左		▼▼▼▼▼ 6 ▼▼▼▼▼
	repeat 6,6
		if wb.cnt=1 : pos wx.cnt,wy.cnt : gcopy 2,8,96,16,16 : wb.cnt=0 : wf.cnt--
		if (shotl=1)&(wf.cnt<1) : wf.cnt=1 : wx.cnt=mx : wy.cnt=my+4 : wxv.cnt=-1: wyv.cnt=-3 : shotl=0 : shtimel=2 : gosub *hunting
		if wf.cnt<1 : continue
		pos wx.cnt,wy.cnt : gcopy 2,80,80,16,16
		wxc.cnt=8 : wyc.cnt=8
		wxw.cnt=8 : wyw.cnt=8
		wd.cnt=2
		wx.cnt=wx.cnt+wxv.cnt : wy.cnt=wy.cnt+wyv.cnt
		if (wx.cnt>400)or(wx.cnt<-16) : wf.cnt=0
		if (wy.cnt<-16)or(wy.cnt>550) : wf.cnt=0
		if ef.hunt<1 : gosub *hunting : if dmax=1000 : continue
		dx=(wx.cnt+8)-(ex.hunt+exc.hunt) : dy=(wy.cnt+8)-(ey.hunt+eyc.hunt)
		if dx<0 : wxv.cnt=wxv.cnt+5 : if wxv.cnt>20  : wxv.cnt=20
		if dx>0 : wxv.cnt=wxv.cnt-5 : if wxv.cnt<-20 : wxv.cnt=-20
		if dy<0 : wyv.cnt=wyv.cnt+5 : if wyv.cnt>20  : wyv.cnt=20
		if dy>0 : wyv.cnt=wyv.cnt-5 : if wyv.cnt<-20 : wyv.cnt=-20
	loop
return

; 自分に最も近い敵を探す
*hunting
	dmax=1000
	repeat emax
		if ef.cnt<1 : continue
		dx=(mx+8)-(ex.cnt+exc.cnt) : if dx<0 : dx=-dx
		dy=(my+8)-(ey.cnt+eyc.cnt) : if dy<0 : dy=-dy
		dsum=dx+dy : if dsum>dmax : continue
		dmax=dsum : hunt=cnt
	loop
return



; 爆発生成
*explosionborn
		px.next=ex.cnt+exc.cnt : py.next=ey.cnt+eyc.cnt : pxv.next=exv.cnt/2 : pyv.next=eyv.cnt/2 : pm.next=ep.cnt
		if pm.next=0 : px.next=px.next-8  : py.next=py.next-8  : pf.next=9 : if gamesnd=1 : snd 5
		if pm.next=1 : px.next=px.next-16 : py.next=py.next-16 : pf.next=9 : if gamesnd=1 : snd 1
		if pm.next=2 : px.next=px.next-50 : py.next=py.next-50 : pf.next=9 : if gamesnd=1 : snd 1
		next++ : if next=pmax : next=0

		if es.cnt>9 : dib++ : if dib\4=0 : gosub *itemborn : dib=0

		if (gamelevel>2)&(es.cnt>1) : gosub *tamaborn0
		if (gamelevel=4)&(es.cnt>9) : gosub *tamaborn6
return


; アイテム生成
*itemborn
	dx=ex.cnt+exc.cnt-8
	if dx<0   : dx=0
	if dx>384 : dx=384
	dy=ey.cnt+eyc.cnt-8
	repeat ibmax
		if ibf.cnt>1 : continue
		ibx.cnt=dx
		iby.cnt=dy
		ibxv.cnt=0
		ibyv.cnt=-8
		ibf.cnt=20
		dibm++ : ibm.cnt=0 : ddd=5
		if gamelevel=1 : ddd=4
		if gamelevel=0 : ddd=3
		if dibm\ddd=0 : ibm.cnt=1 : dibm=0
		break
	loop
return


; 爆発アニメ					●●●●●●●●●●
*explosion
	repeat pmax
		if pf.cnt<1 : continue
		pf.cnt--
		px.cnt=px.cnt+pxv.cnt
		py.cnt=py.cnt+pyv.cnt
		pos px.cnt,py.cnt
		if (pm.cnt=0)&(pf.cnt<3) : gcopy 2,80,96,12,12  : continue
		if (pm.cnt=0)&(pf.cnt<6) : gcopy 2,68,96,12,12  : continue
		if (pm.cnt=0)&(pf.cnt<9) : gcopy 2,56,96,12,12  : continue
		if (pm.cnt=1)&(pf.cnt<3) : gcopy 2,64,144,32,32 : continue
		if (pm.cnt=1)&(pf.cnt<6) : gcopy 2,32,144,32,32 : continue
		if (pm.cnt=1)&(pf.cnt<9) : gcopy 2,0,144,32,32  : continue
		if (pm.cnt=2)&(pf.cnt<3) : gcopy 2,250,300,100,100 : continue
		if (pm.cnt=2)&(pf.cnt<6) : gcopy 2,250,200,100,100 : continue
		if (pm.cnt=2)&(pf.cnt<9) : gcopy 2,250,100,100,100 : continue
	loop
return


; ダメージ処理					●●●●●●●●●●未完成○○○
*hit
	if damage>0 : return
	damage=30 : bgcolor=36

	mf=mf-1 : if gamesnd=1 : snd 2
return


; スコア・シールド表示ルーチン			●●●●●●●●●●
*gamescore
	if score>highscore : highscore=score
	font "times new roman",12,1
	pos 250,5 : color 255,255,255 : mes "SCORE  "+score
	pos 10,5  : color 255,255,255 : mes "HIGHSCORE  "+highscore

;	pos 300,530 : mes gtime

	pos 0,526 : gcopy 2,250,51,111,20
	mfx1=-4 : rrr=192 : ggg=0
	repeat mf
		mfx1=mfx1+10 : mfx2=mfx1+8 
		if cnt>0 : rrr=255 : ggg=0
		if cnt>1 : rrr=255 : ggg=64
		if cnt>2 : rrr=255 : ggg=128
		if cnt>3 : rrr=255 : ggg=192
		if cnt>4 : rrr=255 : ggg=255
		if cnt>5 : rrr=192 : ggg=255
		if cnt>6 : rrr=128 : ggg=255
		if cnt>7 : rrr=64  : ggg=255
		if cnt>8 : rrr=0   : ggg=255
		if cnt>9 : rrr=0   : ggg=192
		color rrr,ggg,0 : boxf mfx1,530,mfx2,540
	loop
return



; ポーズ処理					●●●●●●●●●●
*pausegame
	redraw 1
	font "times new roman",20,1 : color 0,255,255
	pos 168,250 : mes "PAUSE"
	stick pat : if pat&128>0 : gettime mtime,5 : gettime stime,6 : gettime mstime,7 : btime=(mtime*100000)+(stime*1000)+mstime : frameb=frame: return
	getkey returntop,121 : if returntop=1 : end ; 強制終了(F10)
	await gamewait
goto *pausegame


; ゲームオーバー処理			●●●●●●●●●●未完成○○○
*gameover
	sndoff : wait 10
	repeat
		redraw 1
		font "MSゴシック",15,1
		pos 155,250 : color 255,0,0   : mes "GAME OVER"
		pos 130,300 : color 255,0,255 : mes "PUSH RETURN KEY"
		stick pat : getkey spat,shotkey
		if (pat&32>0)or(spat>0) : break
		getkey returntop,121 : if returntop=1 : end ; 強制終了(F10)
		await 1
	loop

	gosub *highscoresave

	wait 10
	gettime mtime,5 : gettime stime,6 : gettime mstime,7 : btime=(mtime*100000)+(stime*1000)+mstime : frameb=frame

goto *restart


; 真のエンディング				●●●●●●●●●●未処理●●●
; 偽エンディング				●●●●●●●●●●未処理●●●
*dummyend
	sndoff : wait 10
	repeat
		redraw 1
		font "MSゴシック",15,1
		pos 170,200 : color 255,0,0     : mes "おしまい"
		pos 165,250 : color 0,255,255   : mes "5面限定版"
		pos 120,300 : color 255,255,0   : mes "YOUR SCORE IS "+score
		pos 130,350 : color 255,0,255   : mes "PUSH RETURN KEY"
		stick pat   : if pat&32>0 : break
		getkey returntop,121 : if returntop=1 : end ; 強制終了(F10)
		await 1
	loop

	gosub *highscoresave

	wait 10
goto *restart


; アイテム移動・獲得判定ルーチン		●●●●●●●●●●
*itemget
	repeat ibmax
		if ibf.cnt<1 : continue

		rnd icr,8 : icr=icr*32+31
		rnd icg,8 : icg=icg*32+31
		rnd icb,8 : icb=icb*32+31
		font "MSゴシック",10,1
		pos ibx.cnt,iby.cnt
		ibx.cnt=ibx.cnt+ibxv.cnt : iby.cnt=iby.cnt+ibyv.cnt
		if (ibf.cnt=20)&(ibm.cnt=0) : gcopy 2,40,80,16,16
		if (ibf.cnt=20)&(ibm.cnt=1) : gcopy 2,56,80,16,16
		if ibf.cnt<20 : color icr,icg,icb : mes ibs.cnt : ibf.cnt--

		dx=(mx+16)-(ibx.cnt+8) : px=dx : if dx<0 : dx=-dx
		dy=(my+16)-(iby.cnt+8) : py=dy : if dy<0 : dy=-dy
		dv=dx : if dv<dy : dv=dy

		if (ibf.cnt=20)&(dx>=0)&(dx<20)&(dy>=0)&(dy<20) : ibf.cnt-- : gosub *item

		if frame\7=0  : ibyv.cnt++ : if ibyv.cnt>3 : ibyv.cnt=3
		if (ibf.cnt=20)&(ibyv.cnt<0) : ibxv.cnt=px*8/dv
		if ibyv.cnt=3 : ibxv.cnt=0
		if ibf.cnt<20 : ibxv.cnt=0 : ibyv.cnt=-2
		if (iby.cnt>550)&(ibm.cnt=0) : ibf.cnt=0 : itembonus=10
	loop
return

; アイテム獲得後処理ルーチン
*item
	if ibm.cnt=0 : ibs.cnt=""+itembonus : score=score+itembonus
	if (ibm.cnt=1)&(mf=10) : score=score+1000 : ibs.cnt="1000"
	if (ibm.cnt=1)&(mf<10) : mf++ : ibs.cnt="REPAIR"
	itembonus=itembonus+10 : if itembonus>1000 : itembonus=1000
	if gamesnd=1 : snd 6
return


; 敵弾移動・自機との当り判定ルーチン		●●●●●●●●●●未完成○○○
*tekitamamove
	repeat tmax
		if tf.cnt<1 : continue
		tcnt++									; 処理落ちカウント
		tx.cnt=tx.cnt+txv.cnt
		ty.cnt=ty.cnt+tyv.cnt
		if tx.cnt>400 : tf.cnt=0 : continue
		if tx.cnt<0   : tf.cnt=0 : continue
		if ty.cnt>550 : tf.cnt=0 : continue
		if ty.cnt<0   : tf.cnt=0 : continue
		pos tx.cnt,ty.cnt : gcopy 2,tgx.cnt,tgy.cnt,tgxw.cnt,tgyw.cnt
		dx=(mx+16)-(tx.cnt+txc.cnt) : if dx<0 : dx=-dx
		dy=(my+16)-(ty.cnt+tyc.cnt) : if dy<0 : dy=-dy
		if (dx>=0)&(dx<(txw.cnt+1))&(dy>=0)&(dy<(tyw.cnt+4)) : tf.cnt-- : gosub *hit

		if (tgx.cnt=96)&(tgy.cnt=80)  : tyw.cnt=16: tyc.cnt=16: tgy.cnt=48  : tgyw.cnt=32
		if (tgx.cnt=96)&(tgy.cnt=108) : tyw.cnt=14: tyc.cnt=14: tgy.cnt=80  : tgyw.cnt=28
		if (tgx.cnt=96)&(tgy.cnt=132) : tyw.cnt=12: tyc.cnt=12: tgy.cnt=108 : tgyw.cnt=24
		if (tgx.cnt=96)&(tgy.cnt=152) : tyw.cnt=10: tyc.cnt=10: tgy.cnt=132 : tgyw.cnt=20
		if (tgx.cnt=96)&(tgy.cnt=168) : tyw.cnt=8 : tyc.cnt=8 : tgy.cnt=152 : tgyw.cnt=16
		if (tgx.cnt=96)&(tgy.cnt=180) : tyw.cnt=6 : tyc.cnt=6 : tgy.cnt=168 : tgyw.cnt=12
		if (tgx.cnt=96)&(tgy.cnt=188) : tyw.cnt=4 : tyc.cnt=4 : tgy.cnt=180 : tgyw.cnt=8

		if (tgx.cnt=240)&(tgy.cnt=260): tyw.cnt=26: tyc.cnt=26: tgy.cnt=308 : tgyw.cnt=52
		if (tgx.cnt=240)&(tgy.cnt=216): tyw.cnt=24: tyc.cnt=24: tgy.cnt=260 : tgyw.cnt=48
		if (tgx.cnt=240)&(tgy.cnt=176): tyw.cnt=22: tyc.cnt=22: tgy.cnt=216 : tgyw.cnt=44
		if (tgx.cnt=240)&(tgy.cnt=140): tyw.cnt=20: tyc.cnt=20: tgy.cnt=176 : tgyw.cnt=40
		if (tgx.cnt=240)&(tgy.cnt=108): tyw.cnt=18: tyc.cnt=18: tgy.cnt=140 : tgyw.cnt=36
		if (tgx.cnt=240)&(tgy.cnt=80) : tyw.cnt=16: tyc.cnt=16: tgy.cnt=108 : tgyw.cnt=32
		if (tgx.cnt=240)&(tgy.cnt=56) : tyw.cnt=14: tyc.cnt=14: tgy.cnt=80  : tgyw.cnt=28
		if (tgx.cnt=240)&(tgy.cnt=36) : tyw.cnt=12: tyc.cnt=12: tgy.cnt=56  : tgyw.cnt=24
		if (tgx.cnt=240)&(tgy.cnt=20) : tyw.cnt=10: tyc.cnt=10: tgy.cnt=36  : tgyw.cnt=20
		if (tgx.cnt=240)&(tgy.cnt=8)  : tyw.cnt=8 : tyc.cnt=8 : tgy.cnt=20  : tgyw.cnt=16
		if (tgx.cnt=240)&(tgy.cnt=0)  : tyw.cnt=6 : tyc.cnt=6 : tgy.cnt=8   : tgyw.cnt=12
	loop
return

; 敵弾の性格決定ルーチン群		■■■■■■■■■■■■■■■■■■■■■■■■■

; 狙い通常弾							▼▼▼▼▼ 00 ▼▼▼▼▼
*tamaborn0
	dx=mx+16-(ex.cnt+exc.cnt) : px=dx : if dx<0 : dx=0-dx
	dy=my+16-(ey.cnt+eyc.cnt) : py=dy : if dy<0 : dy=0-dy
	dv=dy : if dv<dx : dv=dx
	edx=ex.cnt+exc.cnt-4 : edy=ey.cnt+eyc.cnt-4
	repeat tmax
		if tf.cnt>0 : continue
		tf.cnt=1
		tx.cnt=edx : ty.cnt=edy
		txw.cnt=4 : tyw.cnt=4
		txc.cnt=4 : tyc.cnt=4
		rnd ds,4 : ds=ds+gamelevel+8
		tyv.cnt=py*ds/dv
		txv.cnt=px*ds/dv
		tgx.cnt=0 : tgy.cnt=88
		tgxw.cnt=8 : tgyw.cnt=8 : break
	loop
return

; レーザー(直進のみ)					▼▼▼▼▼ 01 ▼▼▼▼▼
*tamaborn1
	repeat tmax
		if tf.cnt>0 : continue
		tf.cnt=255
		tx.cnt=edx : ty.cnt=edy
		txw.cnt=2  : tyw.cnt=2
		txc.cnt=2  : tyc.cnt=2
		txv.cnt=0  : tyv.cnt=4+gamelevel
		tgx.cnt=96 : tgy.cnt=188
		tgxw.cnt=4 : tgyw.cnt=4 : break
	loop
return

; レーザー太め(直進のみ)				▼▼▼▼▼ 02 ▼▼▼▼▼
*tamaborn2
	repeat tmax
		if tf.cnt>0 : continue
		tf.cnt=255
		tx.cnt=edx : ty.cnt=edy
		txw.cnt=4  : tyw.cnt=4
		txc.cnt=4  : tyc.cnt=4
		txv.cnt=0  : tyv.cnt=8+gamelevel
		tgx.cnt=240 : tgy.cnt=0
		tgxw.cnt=8 : tgyw.cnt=8 : break
	loop
return


; 狙いレーザー							▼▼▼▼▼ 03 ▼▼▼▼▼
*tamaborn3
	dx=mx+16-(ex.cnt+exc.cnt) : px=dx : if dx<0 : dx=0-dx
	dy=my+16-(ey.cnt+eyc.cnt) : py=dy : if dy<0 : dy=0-dy
	dv=dx : if dv<dy : dv=dy
	repeat tmax
		if tf.cnt>0 : continue
		tf.cnt=255
		tx.cnt=edx : ty.cnt=edy
		txw.cnt=4 : tyw.cnt=4
		txc.cnt=8 : tyc.cnt=8
		txv.cnt=px*10/dv : tyv.cnt=py*10/dv
		if px=0                                 : tgx.cnt=192 : tgy.cnt=48	; 上下
		if py=0                                 : tgx.cnt=192 : tgy.cnt=32	; 左右
		if (dx<dy)&(dx!0)&(px>0)&(py>0) : if (dy/dx)=1 : tgx.cnt=208 : tgy.cnt=16	; 右下
		if (dx<dy)&(dx!0)&(px>0)&(py>0) : if (dy/dx)>1 : tgx.cnt=208 : tgy.cnt=48	; 右下左
		if (dx<dy)&(dx!0)&(px>0)&(py>0) : if (dy/dx)>3 : tgx.cnt=192 : tgy.cnt=48	; 上下
		if (dx>dy)&(dy!0)&(px>0)&(py>0) : if (dx/dy)=1 : tgx.cnt=208 : tgy.cnt=16	; 右下
		if (dx>dy)&(dy!0)&(px>0)&(py>0) : if (dx/dy)>1 : tgx.cnt=208 : tgy.cnt=32	; 右下右
		if (dx>dy)&(dy!0)&(px>0)&(py>0) : if (dx/dy)>3 : tgx.cnt=192 : tgy.cnt=32	; 左右
		if (dx<dy)&(dx!0)&(px>0)&(py<0) : if (dy/dx)=1 : tgx.cnt=176 : tgy.cnt=16	; 右上
		if (dx<dy)&(dx!0)&(px>0)&(py<0) : if (dy/dx)>1 : tgx.cnt=176 : tgy.cnt=48	; 右上左
		if (dx<dy)&(dx!0)&(px>0)&(py<0) : if (dy/dx)>3 : tgx.cnt=192 : tgy.cnt=48	; 上下
		if (dx>dy)&(dy!0)&(px>0)&(py<0) : if (dx/dy)=1 : tgx.cnt=176 : tgy.cnt=16	; 右上
		if (dx>dy)&(dy!0)&(px>0)&(py<0) : if (dx/dy)>1 : tgx.cnt=176 : tgy.cnt=32	; 右上右
		if (dx>dy)&(dy!0)&(px>0)&(py<0) : if (dx/dy)>3 : tgx.cnt=192 : tgy.cnt=32	; 左右

		if (dx<dy)&(dx!0)&(px<0)&(py>0) : if (dy/dx)=1 : tgx.cnt=176 : tgy.cnt=16	; 左下
		if (dx<dy)&(dx!0)&(px<0)&(py>0) : if (dy/dx)>1 : tgx.cnt=176 : tgy.cnt=48	; 左下右
		if (dx<dy)&(dx!0)&(px<0)&(py>0) : if (dy/dx)>3 : tgx.cnt=192 : tgy.cnt=48	; 上下
		if (dx>dy)&(dy!0)&(px<0)&(py>0) : if (dx/dy)=1 : tgx.cnt=176 : tgy.cnt=16	; 右下
		if (dx>dy)&(dy!0)&(px<0)&(py>0) : if (dx/dy)>1 : tgx.cnt=176 : tgy.cnt=32	; 右下右
		if (dx>dy)&(dy!0)&(px<0)&(py>0) : if (dx/dy)>3 : tgx.cnt=192 : tgy.cnt=32	; 左右
		if (dx<dy)&(dx!0)&(px<0)&(py<0) : if (dy/dx)=1 : tgx.cnt=208 : tgy.cnt=16	; 右上
		if (dx<dy)&(dx!0)&(px<0)&(py<0) : if (dy/dx)>1 : tgx.cnt=208 : tgy.cnt=48	; 右上左
		if (dx<dy)&(dx!0)&(px<0)&(py<0) : if (dy/dx)>3 : tgx.cnt=192 : tgy.cnt=48	; 上下
		if (dx>dy)&(dy!0)&(px<0)&(py<0) : if (dx/dy)=1 : tgx.cnt=208 : tgy.cnt=16	; 右上
		if (dx>dy)&(dy!0)&(px<0)&(py<0) : if (dx/dy)>1 : tgx.cnt=208 : tgy.cnt=32	; 右上右
		if (dx>dy)&(dy!0)&(px<0)&(py<0) : if (dx/dy)>3 : tgx.cnt=192 : tgy.cnt=32	; 左右

		tgxw.cnt=16 : tgyw.cnt=16 : break
	loop
return

; 下のみ狙い通常弾						▼▼▼▼▼ 04 ▼▼▼▼▼
*tamaborn4
	dx=mx+16-(ex.cnt+exc.cnt) : px=dx : if dx<0 : dx=0-dx
	dy=my+16-(ey.cnt+eyc.cnt) : py=dy : if dy<0 : dy=0-dy
	dv=dx : if dv<dy : dv=dy
	if py<0 : py=0-py
	edx=ex.cnt+exc.cnt-4 : edy=ey.cnt+eyc.cnt-4
	repeat tmax
		if tf.cnt>0 : continue
		tf.cnt=1
		tx.cnt=edx : ty.cnt=edy
		txw.cnt=4 : tyw.cnt=4
		txc.cnt=4 : tyc.cnt=4
		txv.cnt=px*(4+gamelevel)/dv
		tyv.cnt=py*(4+gamelevel)/dv+5
		tgx.cnt=0 : tgy.cnt=88
		tgxw.cnt=8 : tgyw.cnt=8 : break
	loop
return

; 上のみ狙い通常弾						▼▼▼▼▼ 05 ▼▼▼▼▼
*tamaborn5
	dx=mx+16-(ex.cnt+exc.cnt) : px=dx : if dx<0 : dx=0-dx
	dy=my+16-(ey.cnt+eyc.cnt) : py=dy : if dy<0 : dy=0-dy
	dv=dx : if dv<dy : dv=dy
	if py>0 : py=0-py
	edx=ex.cnt+exc.cnt-4 : edy=ey.cnt+eyc.cnt-4
	repeat tmax
		if tf.cnt>0 : continue
		tf.cnt=1
		tx.cnt=edx : ty.cnt=edy
		txw.cnt=4 : tyw.cnt=4
		txc.cnt=4 : tyc.cnt=4
		txv.cnt=px*(4+gamelevel)/dv
		tyv.cnt=py*(4+gamelevel)/dv
		tgx.cnt=0 : tgy.cnt=88
		tgxw.cnt=8 : tgyw.cnt=8 : break
	loop
return


; 16方向							▼▼▼▼▼ 06 ▼▼▼▼▼
*tamaborn6
	edx=ex.cnt+exc.cnt-4 : edy=ey.cnt+eyc.cnt-4
	dt=1
	repeat tmax
		if tf.cnt>0 : continue
		tf.cnt=1
		tx.cnt=edx : ty.cnt=edy
		txw.cnt=4  : tyw.cnt=4
		txc.cnt=4  : tyc.cnt=4
		tgx.cnt=0  : tgy.cnt=88
		tgxw.cnt=8 : tgyw.cnt=8
		if dt=1 : txv.cnt=0  : tyv.cnt=-7
		if dt=2 : txv.cnt=3  : tyv.cnt=-6
		if dt=3 : txv.cnt=5  : tyv.cnt=-5
		if dt=4 : txv.cnt=6  : tyv.cnt=-3
		if dt=5 : txv.cnt=7  : tyv.cnt=0
		if dt=6 : txv.cnt=6  : tyv.cnt=3
		if dt=7 : txv.cnt=5  : tyv.cnt=5
		if dt=8 : txv.cnt=3  : tyv.cnt=6
		if dt=9 : txv.cnt=0  : tyv.cnt=7
		if dt=10: txv.cnt=-3 : tyv.cnt=6
		if dt=11: txv.cnt=-5 : tyv.cnt=5
		if dt=12: txv.cnt=-6 : tyv.cnt=3
		if dt=13: txv.cnt=-7 : tyv.cnt=0
		if dt=14: txv.cnt=-6 : tyv.cnt=-3
		if dt=15: txv.cnt=-5 : tyv.cnt=-5
		if dt=16: txv.cnt=-3 : tyv.cnt=-6
		dt++ : if dt>16 : break
	loop
return


; 敵出現フラグチェック		■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
*enemyborn
	if be.step=7  : gosub *born07 : return
	if be.step=8  : gosub *born08 : return
	if be.step=9  : gosub *born09 : return
	if be.step=10 : gosub *born10 : return
	if be.step=11 : gosub *born11 : return
	if be.step=12 : gosub *born12 : return
	if be.step=13 : gosub *born13 : return
	if be.step=14 : gosub *born14 : return
	if be.step=15 : gosub *born15 : return
	if be.step=16 : gosub *born16 : return
	if be.step=17 : gosub *born17 : return
	if be.step=18 : gosub *born18 : return
	if be.step=19 : gosub *born19 : return
	if be.step=20 : gosub *born20 : return
	if be.step=21 : gosub *born21 : return
	if be.step=22 : gosub *born22 : return
	if be.step=23 : gosub *born23 : return
	if be.step=24 : gosub *born24 : return
	if be.step=25 : gosub *born25 : return

	if be.step=50 : gosub *born50 : return
return


; ボスキャラBGM・生成処理			●●●●●●●●●●
*bossborn
	if gamebgm=1 : sndoff : wait 10
	if gamebgm=1 : snd 200
	if stage=1   : gosub *boss01born : return
	if stage=2   : gosub *boss02born : return
	if stage=3   : gosub *boss03born : return
	if stage=4   : gosub *boss04born : return
	if stage=5   : gosub *boss05born : return

						; ボスを増やす毎に行を増やす	●●●●●●●●●●●●●●●●●●●
return


; 敵移動ルーチン				●●●●●●●●●●
*enemymove
	repeat emax
		if em.cnt>100 : if gtime>stageboss : if ef.cnt<1 : stageend=1							; ボスを倒したフラグ
		if em.cnt>100 : dbossx=ex.cnt : dbossy=ey.cnt : dbossxc=exc.cnt*2 : dbossyc=eyc.cnt*2	; ヤラレボス表示用
		if ef.cnt<1 : continue

		en=cnt			; 自機弾との当り判定処理
		repeat wmax
			if wf.cnt<1 : continue
			dx=(ex.en+exc.en)-(wx.cnt+wxc.cnt) : if dx<0 : dx=-dx
			dy=(ey.en+eyc.en)-(wy.cnt+wyc.cnt) : if dy<0 : dy=-dy
			if (dx>=0)&(dx<(exw.en+wxw.cnt))&(dy>=0)&(dy<(eyw.en+wyw.cnt)) : ef.en=ef.en-wd.cnt : wb.cnt=1
		loop

		if ef.cnt<1 : score=score+es.cnt : gosub *explosionborn : continue

		dx=(ex.cnt+exc.cnt)-(mx+16) : if dx<0 : dx=-dx
		dy=(ey.cnt+eyc.cnt)-(my+16) : if dy<0 : dy=-dy
		if (dx>=0)&(dx<(exw.cnt+2))&(dy>=0)&(dy<(eyw.cnt+4)) : ef.cnt-- : gosub *hit
		if ef.cnt<1 : score=score+es.cnt : gosub *explosionborn : continue
;■敵移動パターン
		if em.cnt=0  : gosub *move00		; 消せる弾
		if em.cnt=1  : gosub *move01		; 3way消せる弾
		if em.cnt=2  : gosub *move02		; 誘導ミサイル
		if em.cnt=3  : gosub *move03		; 浮遊後狙い体当たり
		if em.cnt=4  : gosub *move04		; ほぼ直進ミサイル
		if em.cnt=5  : gosub *move05		; アステロイド大
		if em.cnt=6  : gosub *move06		; アステロイド小
		if em.cnt=7  : gosub *move07		; 要塞内部障害物
		if em.cnt=8  : gosub *move08		; 要塞内部上向き(赤)
		if em.cnt=9  : gosub *move09		; 要塞内部下向き(白)
		if em.cnt=10 : gosub *move10		; 丸雑魚接近(前)
		if em.cnt=11 : gosub *move11		; Uミサイル
		if em.cnt=12 : gosub *move12		; 丸雑魚退避(後)
		if em.cnt=13 : gosub *move13		; x軸合わせ
		if em.cnt=14 : gosub *move14		; 削岩機
		if em.cnt=15 : gosub *move15		; U通常弾
		if em.cnt=16 : gosub *move16		; 貼りつき
		if em.cnt=17 : gosub *move17		; サインカーブ
		if em.cnt=18 : gosub *move18		; Uレーザー
		if em.cnt=19 : gosub *move19		; 直進特攻
		if em.cnt=20 : gosub *move20		; 後ろからx軸合わせ
		if em.cnt=21 : gosub *move21		; 周りから体当たり遅柔
		if em.cnt=22 : gosub *move22		; 周りから体当たり速固
		if em.cnt=23 : gosub *move23		; 静止体当たり
		if em.cnt=24 : gosub *move24		; 周囲でバウンド
		if em.cnt=25 : gosub *move25		; 画面下でバウンド

		if em.cnt=50 : gosub *move50		; 中ボス:16way+5連

		if em.cnt=101 : gosub *boss01
		if em.cnt=102 : gosub *boss02
		if em.cnt=103 : gosub *boss03
		if em.cnt=104 : gosub *boss04
		if em.cnt=105 : gosub *boss05
						; ボスを増やす毎に行を増やす	●●●●●●●●●●●●●●●●●●●

	loop
return


; 敵の性格決定ルーチン群		■■■■■■■■■■■■■■■■■■■■■■■■■
; 00〜09 敵から・ランダム発生系	■■■■■■■■■■■■■■■■■■■■■■■■■

; 消せる弾(敵から発生)				▼▼▼▼▼ 00 ▼▼▼▼▼
*born00
	dx=mx-ex.cnt : px=dx : if dx<0 : dx=0-dx
	dy=my-ey.cnt : py=dy : if dy<0 : dy=0-dy
	dv=dx : if dv<dy : dv=dy
	bx=ex.cnt+exc.cnt-8 : by=ey.cnt+eyc.cnt
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=0		; 敵番号
		ef.cnt=1		; 固さ
		ex.cnt=bx		; 初期出現位置x軸
		ey.cnt=by		; 初期出現位置y軸
		rnd ds,4 : ds=ds+gamelevel+6
		exv.cnt=px*ds/dv	; x方向運動量
		eyv.cnt=py*ds/dv	; y方向運動量
		exc.cnt=8		; 中心x
		eyc.cnt=8		; 中心y
		exw.cnt=8		; 大きさx
		eyw.cnt=8		; 大きさy
		ep.cnt=0		; 爆発パターン
		es.cnt=1		; スコア
		break
	loop
return

*move00
	et.cnt++
	pos ex.cnt,ey.cnt : if et.cnt\2=0 : gcopy 2,8,80,16,16 : else : gcopy 2,24,80,16,16
	ex.cnt=ex.cnt+exv.cnt
	ey.cnt=ey.cnt+eyv.cnt
	if (ex.cnt<-16)or(ey.cnt<-16) : ef.cnt=0
	if (ex.cnt>400)or(ey.cnt>550) : ef.cnt=0
return


; 消せる弾(3way)(敵から発生)					▼▼▼▼▼ 01 ▼▼▼▼▼
*born01
	kosu=0
	bx=ex.cnt+exc.cnt-8 : by=ey.cnt+eyc.cnt
	repeat emax
		if ef.cnt>0 : continue
		kosu++ : if kosu=4 : break
		et.cnt=0		; 生成時間リセット
		em.cnt=1		; 敵番号
		ef.cnt=1		; 固さ
		ex.cnt=bx		; 初期出現位置x軸
		ey.cnt=by		; 初期出現位置y軸
		exc.cnt=8		; 中心x
		eyc.cnt=8		; 中心y
		exw.cnt=8		; 大きさx
		eyw.cnt=8		; 大きさy
		ep.cnt=0		; 爆発パターン
		es.cnt=1		; スコア
		if kosu=1 : exv.cnt=2+gamelevel   : eyv.cnt=7+gamelevel 
		if kosu=2 : exv.cnt=-2-gamelevel  : eyv.cnt=6+gamelevel 
		if kosu=3 : exv.cnt=0             : eyv.cnt=8+gamelevel
	loop
return

*move01
	et.cnt++
	pos ex.cnt,ey.cnt : if et.cnt\2=0 : gcopy 2,8,80,16,16 : else : gcopy 2,24,80,16,16
	ex.cnt=ex.cnt+exv.cnt
	ey.cnt=ey.cnt+eyv.cnt
	if (ex.cnt<-16)or(ey.cnt<-16) : ef.cnt=0
	if (ex.cnt>400)or(ey.cnt>550) : ef.cnt=0
return


; 誘導ミサイル(敵から発生)						▼▼▼▼▼ 02 ▼▼▼▼▼
*born02
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=2		; 敵番号
		ef.cnt=2		; 固さ
		ex.cnt=bx		; 初期出現位置x軸・・・bxは予め用意すること
		ey.cnt=by		; 初期出現位置y軸・・・byは予め用意すること
		exv.cnt=0		; x方向運動量
		eyv.cnt=0		; y方向運動量
		exc.cnt=8		; 中心x
		eyc.cnt=8		; 中心y
		exw.cnt=8		; 大きさx
		eyw.cnt=8		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=1		; スコア
		break
	loop
return

*move02
	et.cnt++
	dx=mx-ex.cnt+8 : px=dx : if px<0 : px=0-px
	dy=my-ey.cnt+8 : py=dy : if py<0 : py=0-py

	pos ex.cnt,ey.cnt
	if (dx>0)&(dy>0)&(px>py) : gcopy 2,224,48,16,16		; 右下右
	if (dx>0)&(dy>0)&(px<py) : gcopy 2,208,64,16,16		; 右下左
	if (dx>0)&(dy<0)&(px>py) : gcopy 2,224,16,16,16		; 右上右
	if (dx>0)&(dy<0)&(px<py) : gcopy 2,208,0,16,16		; 右上左
	if (dx<0)&(dy<0)&(px>py) : gcopy 2,160,16,16,16		; 左上左
	if (dx<0)&(dy<0)&(px<py) : gcopy 2,176,0,16,16		; 左上右
	if (dx<0)&(dy>0)&(px>py) : gcopy 2,160,48,16,16		; 左下左
	if (dx<0)&(dy>0)&(px<py) : gcopy 2,176,64,16,16		; 左下右
	if (dx>0)&(dy>0)&(px=py) : gcopy 2,224,64,16,16		; 右下
	if (dx>0)&(dy<0)&(px=py) : gcopy 2,224,0,16,16		; 右上
	if (dx<0)&(dy<0)&(px=py) : gcopy 2,160,0,16,16		; 左上
	if (dx<0)&(dy>0)&(px=py) : gcopy 2,160,64,16,16		; 左下
	if (dx=0)&(dy>0)         : gcopy 2,192,64,16,16		; 下
	if (dx=0)&(dy<0)         : gcopy 2,192,0,16,16		; 上
	if (dx>0)&(dy=0)         : gcopy 2,224,32,16,16		; 右
	if (dx<0)&(dy=0)         : gcopy 2,160,32,16,16		; 左

	if gtime\(10-gamelevel)=0 : if dx>0 : exv.cnt++ : if exv.cnt>4  : exv.cnt=4
	if gtime\(10-gamelevel)=0 : if dx<0 : exv.cnt-- : if exv.cnt<-4 : exv.cnt=-4
	if gtime\(10-gamelevel)=0 : if dy>0 : eyv.cnt++ : if eyv.cnt>4  : eyv.cnt=4
	if gtime\(10-gamelevel)=0 : if dy<0 : eyv.cnt-- : if eyv.cnt<-4 : eyv.cnt=-4

	ex.cnt=exv.cnt+ex.cnt : ey.cnt=eyv.cnt+ey.cnt

	if (ex.cnt<-64)or(ey.cnt<-64) : ef.cnt=0
	if (ex.cnt>448)or(ey.cnt>598) : ef.cnt=0
return


; ゆっくり後退→一定時間後体当たり直進(敵から発生)	▼▼▼▼▼ 03 ▼▼▼▼▼
*born03
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=3		; 敵番号
		ef.cnt=5		; 固さ
		ex.cnt=bx		; 初期出現位置x軸
		ey.cnt=by		; 初期出現位置y軸
		rnd dsx,5 : dsx=dsx-2
		exv.cnt=dsx		; x方向運動量
		eyv.cnt=-2		; y方向運動量
		exc.cnt=16		; 中心x
		eyc.cnt=16		; 中心y
		exw.cnt=10		; 大きさx
		eyw.cnt=10		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=2		; スコア
		break
	loop
return

*move03
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,32,272,32,46
	dx=mx-ex.cnt : px=dx : if dx<0 : dx=0-dx
	dy=my-ey.cnt : py=dy : if dy<0 : dy=0-dy
	dv=dx : if dv<dy : dv=dy
	if et.cnt=30 : exv.cnt=px*(8+gamelevel)/dv : eyv.cnt=py*(8+gamelevel)/dv
	ex.cnt=ex.cnt+exv.cnt
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return


; ほぼ直進ミサイル(敵から発生)					▼▼▼▼▼ 04 ▼▼▼▼▼
*born04
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=4		; 敵番号
		ef.cnt=15		; 固さ
		ex.cnt=bx		; 初期出現位置x軸			; bx,byは予め用意すること
		ey.cnt=by		; 初期出現位置y軸			
		exv.cnt=mx-bx+8 : exv.cnt=exv.cnt/(100-(gamelevel*5))		; x方向運動量
		eyv.cnt=8+gamelevel		; y方向運動量
		exc.cnt=8		; 中心x
		eyc.cnt=8		; 中心y
		exw.cnt=8		; 大きさx
		eyw.cnt=8		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=1		; スコア
		break
	loop
return

*move04
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,72,80,8,16
	ex.cnt=ex.cnt+exv.cnt
	ey.cnt=ey.cnt+eyv.cnt
	if (ex.cnt<-16)or(ey.cnt<-16) : ef.cnt=0
	if (ex.cnt>400)or(ey.cnt>550) : ef.cnt=0
return


; アステロイド(大)							▼▼▼▼▼ 05 ▼▼▼▼▼
*born05
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=5		; 敵番号
		ef.cnt=21		; 固さ
		rnd ex.cnt,368		; 初期出現位置x軸
		ey.cnt=-32			; 初期出現位置y軸
		exv.cnt=0		; x方向運動量
		rnd dsy,4 : dsy=dsy+2
		eyv.cnt=dsy		; y方向運動量
		exc.cnt=16		; 中心x
		eyc.cnt=16		; 中心y
		exw.cnt=16		; 大きさx
		eyw.cnt=16		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=1		; スコア
		break
	loop
return

*move05
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,0,112,32,32
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return


; アステロイド(小)							▼▼▼▼▼ 06 ▼▼▼▼▼
*born06
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=6		; 敵番号
		ef.cnt=6		; 固さ
		rnd ex.cnt,384		; 初期出現位置x軸
		ey.cnt=-16			; 初期出現位置y軸
		exv.cnt=0		; x方向運動量
		rnd dsy,4 : dsy=dsy+4
		eyv.cnt=dsy		; y方向運動量
		exc.cnt=8		; 中心x
		eyc.cnt=8		; 中心y
		exw.cnt=8		; 大きさx
		eyw.cnt=8		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=1		; スコア
		break
	loop
return

*move06
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,40,96,16,16
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return


; 要塞内部障害物								▼▼▼▼▼ 07 ▼▼▼▼▼
*born07
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=7		; 敵番号
		ef.cnt=10000	; 固さ
		ex.cnt=bx.step	; 初期出現位置x軸
		ey.cnt=by.step	; 初期出現位置y軸
		exv.cnt=0		; x方向運動量
		eyv.cnt=6		; y方向運動量
		exc.cnt=64		; 中心x
		eyc.cnt=25		; 中心y
		exw.cnt=64		; 大きさx
		eyw.cnt=25		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=1		; スコア
		if step<nmax : step++
		break
	loop
return

*move07
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,250,0,128,51
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return

; 要塞内部上向き(赤)								▼▼▼▼▼ 08 ▼▼▼▼▼
*born08
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=8		; 敵番号
		ef.cnt=30		; 固さ
		ex.cnt=bx.step	; 初期出現位置x軸
		ey.cnt=by.step	; 初期出現位置y軸
		exv.cnt=0		; x方向運動量
		eyv.cnt=6		; y方向運動量
		exc.cnt=32		; 中心x
		eyc.cnt=50		; 中心y
		exw.cnt=32		; 大きさx
		eyw.cnt=40		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=200		; スコア
		if step<nmax : step++
		break
	loop
return

*move08
	et.cnt++
	if et.cnt>30 : gosub *tamaborn5
	if et.cnt>(30+gamelevel) : et.cnt=0
	pos ex.cnt,ey.cnt : gcopy 2,165,242,64,90
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return

; 要塞内部下向き(白)								▼▼▼▼▼ 09 ▼▼▼▼▼
*born09
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=9		; 敵番号
		ef.cnt=40		; 固さ
		ex.cnt=bx.step	; 初期出現位置x軸
		ey.cnt=by.step	; 初期出現位置y軸
		exv.cnt=0		; x方向運動量
		eyv.cnt=6		; y方向運動量
		exc.cnt=32		; 中心x
		eyc.cnt=40		; 中心y
		exw.cnt=32		; 大きさx
		eyw.cnt=40		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=100		; スコア
		if step<nmax : step++
		break
	loop
return

*move09
	et.cnt++
	if et.cnt>25 : gosub *tamaborn4
	if et.cnt>(25+gamelevel) : et.cnt=0
	pos ex.cnt,ey.cnt : gcopy 2,165,150,64,90
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return


; 10〜99 通常の敵				■■■■■■■■■■■■■■■■■■■■■■■■■

; 前から出現→自機の方向に移動→ぐるっと一周して去る	▼▼▼▼▼ 10 ▼▼▼▼▼
*born10
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=10			; 敵番号
		ef.cnt=3			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=ex.cnt-mx : if dx<0 : exv.cnt=8 : else : exv.cnt=-8					; x方向運動量
		eyv.cnt=8			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=16			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=16			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=10			; スコア
		if step<nmax : step++
		break
	loop
return

*move10
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,0,200,32,32
	if (ex.cnt<50)&(frame\2=0)  : exv.cnt++ : if exv.cnt>8  : exv.cnt=8
	if (ex.cnt>318)&(frame\2=0) : exv.cnt-- : if exv.cnt<-8 : exv.cnt=-8
	if ey.cnt>500 : eyv.cnt-- : if eyv.cnt<-8 : eyv.cnt=-8
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<-32 : ef.cnt=0
return


; 前から出現→自機の方向に移動→ミサイルを撃ちつつ逃げる	▼▼▼▼▼ 11 ▼▼▼▼▼
*born11
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=11			; 敵番号
		ef.cnt=30			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=ex.cnt-mx : if dx<0 : exv.cnt=4 : else : exv.cnt=-4					; x方向運動量
		eyv.cnt=12			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=16			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=16			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=30			; スコア
		if step<nmax : step++
		break
	loop
return

*move11
	et.cnt++
	pos ex.cnt,ey.cnt : if exv.cnt>0 : gcopy 2,32,200,32,32 : else : gcopy 2,64,200,32,32
	dx=ex.cnt-mx
	if (frame\2=0)&(dx>-64)and(dx<64) : eyv.cnt-- : if eyv.cnt<-4  : eyv.cnt=-4
	if ey.cnt>150 : eyv.cnt-- : if eyv.cnt<-4  : eyv.cnt=-4
	if eyv.cnt<0 : if frame\(15-gamelevel)=0 : bx=ex.cnt+16 : by=ey.cnt+24 : gosub *born04
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<-32 : ef.cnt=0
	if (exv.cnt>0)&(ex.cnt>400) : ef.cnt=0
	if (exv.cnt<0)&(ex.cnt<-32) : ef.cnt=0
return


; 後ろから出現→自機と逆方向に移動→ぐるっと一周(10の逆)	▼▼▼▼▼ 12 ▼▼▼▼▼
*born12
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=12			; 敵番号
		ef.cnt=3			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=ex.cnt-mx : if dx>0 : exv.cnt=8 : else : exv.cnt=-8					; x方向運動量
		eyv.cnt=-8			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=16			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=16			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=10			; スコア
		if step<nmax : step++
		break
	loop
return

*move12
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,0,200,32,32
	if (ex.cnt<50)&(frame\2=0)  : exv.cnt++ : if exv.cnt>8  : exv.cnt=8
	if (ex.cnt>318)&(frame\2=0) : exv.cnt-- : if exv.cnt<-8 : exv.cnt=-8
	if ey.cnt<100 : eyv.cnt++ : if eyv.cnt>8 : eyv.cnt=8
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return


; 自機近くでx軸合わせ	▼▼▼▼▼ 13 ▼▼▼▼▼
*born13
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=13			; 敵番号
		ef.cnt=5			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		exv.cnt=0			; x方向運動量
		eyv.cnt=8			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=20			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=20			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=10			; スコア
		if step<nmax : step++
		break
	loop
return

*move13
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,0,232,32,40
	dx=ex.cnt-mx : dy=my-ey.cnt
	if dy<80 : eyv.cnt-- : if eyv.cnt<0 : eyv.cnt=0
	if (dy<80)&(dy>60) : if dx>0 : exv.cnt=-6 : else : exv.cnt=6
	if (dy<80)&(dy>60) : if dx<0
	if exv.cnt!0 : if et.cnt\(15-gamelevel)=0 : gosub *tamaborn0
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if (ex.cnt>400)or(ex.cnt<-32) : ef.cnt=0
return


; 前進→静止(消せる弾乱射)→ 後退			▼▼▼▼▼ 14 ▼▼▼▼▼
*born14
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=14			; 敵番号
		ef.cnt=50			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		exv.cnt=0			; x方向運動量
		eyv.cnt=4			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=32			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=32			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=20			; スコア
		if step<nmax : step++
		break
	loop
return

*move14
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,0,272,32,64
	if (et.cnt>60)&(et.cnt<90) : exv.cnt=0 : eyv.cnt=0 : if gtime\3=0 : gosub *born00
	if et.cnt>=90 : exv.cnt=0 : eyv.cnt=-4
	if et.cnt\(30-gamelevel)=0 : gosub *tamaborn0
	ex.cnt=ex.cnt+exv.cnt
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<-64 : ef.cnt=0
return


; 前から出現→自機の方向に移動→狙う弾を撃ちつつ逃げる	▼▼▼▼▼ 15 ▼▼▼▼▼
*born15
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=15			; 敵番号
		ef.cnt=15			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=ex.cnt-mx : if dx<0 : exv.cnt=6 : else : exv.cnt=-6					; x方向運動量
		eyv.cnt=12			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=16			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=16			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=20			; スコア
		if step<nmax : step++
		break
	loop
return

*move15
	et.cnt++
	pos ex.cnt,ey.cnt : if exv.cnt>0 : gcopy 2,32,200,32,32 : else : gcopy 2,64,200,32,32
	dx=ex.cnt-mx
	if (dx>-64)and(dx<64) : eyv.cnt-- : if eyv.cnt<-4  : eyv.cnt=-4
	if ey.cnt>200 : eyv.cnt-- : if eyv.cnt<-4  : eyv.cnt=-4
	if et.cnt\(15-gamelevel)=0 : gosub *tamaborn0
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<-32 : ef.cnt=0
	if (exv.cnt>0)&(ex.cnt>400) : ef.cnt=0
	if (exv.cnt<0)&(ex.cnt<-32) : ef.cnt=0
return


; 目前にへばりつく^^;									▼▼▼▼▼ 16 ▼▼▼▼▼
*born16
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=16			; 敵番号
		ef.cnt=500			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		exv.cnt=0			; x方向運動量
		eyv.cnt=0			; y方向運動量
		exc.cnt=28			; 中心x
		eyc.cnt=16			; 中心y
		exw.cnt=18			; 大きさx
		eyw.cnt=8			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=100			; スコア
		if step<nmax : step++
		break
	loop
return

*move16
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,0,336,58,34
	dx=(mx+16)-(ex.cnt+29)
	dy=(my+16)-(ey.cnt+17)
	exv.cnt=0 : eyv.cnt=0
	if dx<-2 : exv.cnt=-4
	if dx>2  : exv.cnt=4
	if dy<50 : eyv.cnt=-8
	if dy>55 : eyv.cnt=8


	if et.cnt>=500 : exv.cnt=0 : eyv.cnt=-4
	ex.cnt=ex.cnt+exv.cnt
	ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<-64 : ef.cnt=0
return


; サインカーブっぽい奴										▼▼▼▼▼ 17 ▼▼▼▼▼
*born17
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=17			; 敵番号
		ef.cnt=4			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=mx-ex.cnt
		if dx>0 : exv.cnt=-8 : else : exv.cnt=8			; x方向運動量
		eyv.cnt=6			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=20			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=18			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=10			; スコア
		if step<nmax : step++
		break
	loop
return

*move17
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,32,232,32,40
	if et.cnt\(20-gamelevel)=0 : gosub *tamaborn0
	if ex.cnt<50  : exv.cnt++ : if exv.cnt>8  : exv.cnt=8
	if ex.cnt>318 : exv.cnt-- : if exv.cnt<-8 : exv.cnt=-8
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>550 : ef.cnt=0
return


; 前から出現→自機の方向に移動→レーザーを撃ちつつ逃げる	▼▼▼▼▼ 18 ▼▼▼▼▼
*born18
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=18			; 敵番号
		ef.cnt=30			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=ex.cnt-mx : if dx<0 : exv.cnt=8 : else : exv.cnt=-8				; x方向運動量
		eyv.cnt=2			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=16			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=16			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=20			; スコア
		if step<nmax : step++
		break
	loop
return

*move18
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,64,232,32,32
	if (ey.cnt>100)&(et.cnt\3=0) : eyv.cnt-- : if eyv.cnt<0  : eyv.cnt=0
	if et.cnt\(7-gamelevel)=0 : edx=ex.cnt+12 : edy=ey.cnt+32 : gosub *tamaborn1
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<-32 : ef.cnt=0
	if (exv.cnt>0)&(ex.cnt>400) : ef.cnt=0
	if (exv.cnt<0)&(ex.cnt<0)   : ef.cnt=0
return


; 前から出現→ひたすら直進^^;		▼▼▼▼▼ 19 ▼▼▼▼▼
*born19
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=19			; 敵番号
		ef.cnt=5			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		exv.cnt=0			; x方向運動量
		eyv.cnt=16			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=24			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=20			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=10			; スコア
		if step<nmax : step++
		break
	loop
return

*move19
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,64,264,32,48
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt>600 : ef.cnt=0
return


; 後ろから出現→自機近くでx軸合わせ	▼▼▼▼▼ 20 ▼▼▼▼▼
*born20
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=20			; 敵番号
		ef.cnt=5			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		exv.cnt=0			; x方向運動量
		eyv.cnt=-6			; y方向運動量
		exc.cnt=16			; 中心x
		eyc.cnt=20			; 中心y
		exw.cnt=16			; 大きさx
		eyw.cnt=20			; 大きさy
		ep.cnt=1			; 爆発パターン
		es.cnt=10			; スコア
		if step<nmax : step++
		break
	loop
return

*move20
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,64,312,32,40
	dx=ex.cnt-mx : dy=ey.cnt-my
	if dy<80 : eyv.cnt++ : if eyv.cnt>0 : eyv.cnt=0
	if (dy<80)&(dy>60) : if dx>0 : exv.cnt=-4 : else : exv.cnt=4
	if exv.cnt!0 : if et.cnt\(20-gamelevel)=0 : gosub *tamaborn0
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if (ex.cnt>400)or(ex.cnt<-32) : ef.cnt=0
return


; 体当たり直進(まわりから発生)遅柔	▼▼▼▼▼ 21 ▼▼▼▼▼
*born21
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=21		; 敵番号
		ef.cnt=5		; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=mx-ex.cnt : px=dx : if dx<0 : dx=0-dx
		dy=my-ey.cnt : py=dy : if dy<0 : dy=0-dy
		dv=dx : if dv<dy : dv=dy
		exv.cnt=px*(8+gamelevel)/dv		; x方向運動量
		eyv.cnt=py*(8+gamelevel)/dv		; y方向運動量
		exc.cnt=16		; 中心x
		eyc.cnt=16		; 中心y
		exw.cnt=14		; 大きさx
		eyw.cnt=14		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=10		; スコア
		if step<nmax : step++
		break
	loop
return

*move21
	et.cnt++
	pos ex.cnt,ey.cnt
	if et.cnt\4=0 : gcopy 2,383,100,32,32
	if et.cnt\4=1 : gcopy 2,383,132,32,32
	if et.cnt\4=2 : gcopy 2,383,164,32,32
	if et.cnt\4=3 : gcopy 2,383,196,32,32
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ex.cnt<-64 : ef.cnt=0
	if ex.cnt>432 : ef.cnt=0
	if ey.cnt<-64 : ef.cnt=0
	if ey.cnt>582 : ef.cnt=0
return


; 体当たり直進(まわりから発生)速固	▼▼▼▼▼ 22 ▼▼▼▼▼
*born22
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=22		; 敵番号
		ef.cnt=10		; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=mx-ex.cnt : px=dx : if dx<0 : dx=0-dx
		dy=my-ey.cnt : py=dy : if dy<0 : dy=0-dy
		dv=dx : if dv<dy : dv=dy
		exv.cnt=px*(12+gamelevel)/dv		; x方向運動量
		eyv.cnt=py*(12+gamelevel)/dv		; y方向運動量
		exc.cnt=16		; 中心x
		eyc.cnt=16		; 中心y
		exw.cnt=14		; 大きさx
		eyw.cnt=14		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=10		; スコア
		if step<nmax : step++
		break
	loop
return

*move22
	et.cnt++
	pos ex.cnt,ey.cnt
	if et.cnt\4=0 : gcopy 2,383,250,32,32
	if et.cnt\4=1 : gcopy 2,383,282,32,32
	if et.cnt\4=2 : gcopy 2,383,314,32,32
	if et.cnt\4=3 : gcopy 2,383,346,32,32
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ex.cnt<-64 : ef.cnt=0
	if ex.cnt>432 : ef.cnt=0
	if ey.cnt<-64 : ef.cnt=0
	if ey.cnt>582 : ef.cnt=0
return


; 一定時間静止後狙い体当たり		▼▼▼▼▼ 23 ▼▼▼▼▼
*born23
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=23		; 敵番号
		ef.cnt=30		; 固さ
		ex.cnt=bx.step	; 初期出現位置x軸
		ey.cnt=by.step	; 初期出現位置y軸
		dx=mx-ex.cnt : px=dx : if dx<0 : dx=0-dx
		dy=my-ey.cnt : py=dy : if dy<0 : dy=0-dy
		dv=dx : if dv<dy : dv=dy
		exv.cnt=px*4/dv	; x方向運動量
		eyv.cnt=py*4/dv	; y方向運動量
		exc.cnt=16		; 中心x
		eyc.cnt=16		; 中心y
		exw.cnt=12		; 大きさx
		eyw.cnt=12		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=50		; スコア
		if step<nmax : step++
		break
	loop
return

*move23
	et.cnt++ : if et.cnt>30 : exv.cnt=0 : eyv.cnt=0
	if (et.cnt>40)&(et.cnt<70) : if et.cnt\(5-gamelevel)=0  : edx=ex.cnt+8 : edy=ey.cnt+8 : gosub *tamaborn3
	dx=mx-ex.cnt : px=dx : if dx<0 : dx=0-dx
	dy=my-ey.cnt : py=dy : if dy<0 : dy=0-dy
	dv=dx : if dv<dy : dv=dy
	if et.cnt=80 : exv.cnt=px*4/dv
	if et.cnt=80 : eyv.cnt=py*4/dv : et.cnt=0
	pos ex.cnt,ey.cnt
	if et.cnt\4=0 : gcopy 2,350,100,32,32
	if et.cnt\4=1 : gcopy 2,350,132,32,32
	if et.cnt\4=2 : gcopy 2,350,164,32,32
	if et.cnt\4=3 : gcopy 2,350,196,32,32
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ex.cnt<-32 : ef.cnt=0
	if ex.cnt>400 : ef.cnt=0
	if ey.cnt<-32 : ef.cnt=0
	if ey.cnt>550 : ef.cnt=0
return


; 画面内バウンド		▼▼▼▼▼ 24 ▼▼▼▼▼
*born24
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=24		; 敵番号
		ef.cnt=15		; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		dx=ex.cnt-mx : if dx<0 : exv.cnt=6 : else : exv.cnt=-6				; x方向運動量
		dy=ey.cnt-my : if dy<0 : eyv.cnt=6 : else : eyv.cnt=-6				; y方向運動量
		exc.cnt=16		; 中心x
		eyc.cnt=16		; 中心y
		exw.cnt=14		; 大きさx
		eyw.cnt=14		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=20		; スコア
		if step<nmax : step++
		break
	loop
return

*move24
	et.cnt++
	pos ex.cnt,ey.cnt
	if et.cnt\4=0 : gcopy 2,350,250,32,32
	if et.cnt\4=1 : gcopy 2,350,282,32,32
	if et.cnt\4=2 : gcopy 2,350,314,32,32
	if et.cnt\4=3 : gcopy 2,350,346,32,32
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if (ex.cnt<0)&(et.cnt>30)   : exv.cnt=6  : gosub *tamaborn0
	if (ex.cnt>368)&(et.cnt>30) : exv.cnt=-6 : gosub *tamaborn0
	if (ey.cnt<0)&(et.cnt>30)   : eyv.cnt=6  : gosub *tamaborn0
	if (ey.cnt>518)&(et.cnt>30) : eyv.cnt=-6 : gosub *tamaborn0
return


; 画面下バウンド		▼▼▼▼▼ 24 ▼▼▼▼▼
*born25
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=25		; 敵番号
		ef.cnt=15	; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		exv.cnt=0			; x方向運動量
		eyv.cnt=0			; y方向運動量
		exc.cnt=16		; 中心x
		eyc.cnt=16		; 中心y
		exw.cnt=14		; 大きさx
		eyw.cnt=14		; 大きさy
		ep.cnt=1		; 爆発パターン
		es.cnt=30		; スコア
		if step<nmax : step++
		break
	loop
return

*move25
	et.cnt++
	pos ex.cnt,ey.cnt
	if et.cnt\4=0 : gcopy 2,416,100,32,32
	if et.cnt\4=1 : gcopy 2,416,132,32,32
	if et.cnt\4=2 : gcopy 2,416,164,32,32
	if et.cnt\4=3 : gcopy 2,416,196,32,32
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<450 : eyv.cnt++ : if eyv.cnt>16 : eyv.cnt=16
	if ey.cnt>518 : eyv.cnt=-eyv.cnt : dx=ex.cnt-mx : if dx<0 : exv.cnt=4 : else : exv.cnt=-4
	if ex.cnt<-32 : ef.cnt=0
	if ex.cnt>400 : ef.cnt=0
return



; 中ボス16Way弾+5連弾				▼▼▼▼▼ 50 ▼▼▼▼▼
*born50
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0			; 生成時間リセット
		em.cnt=50			; 敵番号
		ef.cnt=300			; 固さ
		ex.cnt=bx.step		; 初期出現位置x軸
		ey.cnt=by.step		; 初期出現位置y軸
		exv.cnt=0			; x方向運動量
		eyv.cnt=4			; y方向運動量
		exc.cnt=32			; 中心x
		eyc.cnt=35			; 中心y
		exw.cnt=28			; 大きさx
		eyw.cnt=26			; 大きさy
		ep.cnt=2			; 爆発パターン
		es.cnt=100			; スコア
		if step<nmax : step++
		break
	loop
return

*move50
	et.cnt++
	pos ex.cnt,ey.cnt : gcopy 2,100,200,64,69
	if et.cnt>50  : exv.cnt=0 : eyv.cnt=0
	if et.cnt>50  : if gtime\(50-gamelevel)=0 : gosub *tamaborn6
	if et.cnt>50  : if gtime\(20-gamelevel)=0 : gosub *born00
	if et.cnt>50  : if gtime\(20-gamelevel)=1 : gosub *tamaborn0
	if et.cnt>50  : if gtime\(20-gamelevel)=2 : gosub *born00
	if et.cnt>50  : if gtime\(20-gamelevel)=3 : gosub *tamaborn0
	if et.cnt>50  : if gtime\(20-gamelevel)=4 : gosub *born00
	if et.cnt>300 : exv.cnt=0 : eyv.cnt=-4
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	if ey.cnt<-70 : ef.cnt=0
return


; ステージ別データを以下で読みこみ	■■■■■■■■■■■■■■■■■■■■■■■■■

; ステージ1基本設定			■■■■■■■■■■■■■■■■■■■■■■■■■
*stagedata01
	stageboss=2000						; ボス出現時間
	sndload "stage01.mid",101,1			; BGM
	if gamebgm=1 : snd 101
	bload "stage01.txt",data			; 敵出現パターン

	gsel 3
	picload "station.bmp",1 : roll=-400		; 背景画像読みこみ

	gsel 4
	picload "stage01.bmp",1				; ボス画像読みこみ

	repeat smax
		rnd stx.cnt,400
		rnd sty.cnt,550
		rnd stc.cnt,8 : sts.cnt=stc.cnt/2+1 : stc.cnt=stc.cnt*32+31
	loop
return

; ステージ1背景				●●●●●●●●●●
*haikei01
	pos 20,roll : gcopy 3,0,0,360,300
	if gtime\2=0 : roll++
	repeat smax
		color stc.cnt,stc.cnt,stc.cnt
		sty.cnt=sty.cnt+sts.cnt
		if sty.cnt>550 : sty.cnt=0
		pset stx.cnt,sty.cnt
	loop
return

; ステージ1ボス				●●●●●●●●●●
*boss01born
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=101		; 敵番号
		ef.cnt=800		; 固さ
		ex.cnt=137		; 初期出現位置x軸
		ey.cnt=-170		; 初期出現位置y軸
		exv.cnt=4		; x方向運動量
		eyv.cnt=0		; y方向運動量
		exc.cnt=61		; 中心x
		eyc.cnt=110		; 中心y
		exw.cnt=20		; 大きさx
		eyw.cnt=40		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=1000		; スコア
		break
	loop
return
*boss01
	et.cnt++
	if et.cnt\(20-gamelevel)=0 : bx=ex.cnt+exc.cnt-16 : by=ey.cnt+eyc.cnt-100 : gosub *born03
	if et.cnt\(25-gamelevel)=0 : gosub *born01
	if eyv.cnt>0 : if et.cnt\(15-gamelevel)=0 : gosub *tamaborn0
	if eyv.cnt<0 : if et.cnt\(ef.cnt/20+5-gamelevel)=0 : gosub *tamaborn6
	if ey.cnt>120 : eyv.cnt-- : if eyv.cnt<-8 : eyv.cnt=-8
	if ey.cnt<40  : eyv.cnt++ : if eyv.cnt>8  : eyv.cnt=8
	if ex.cnt>284 : exv.cnt=-exv.cnt
	if ex.cnt<-10 : exv.cnt=-exv.cnt
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	pos ex.cnt,ey.cnt : gcopy 4,0,0,126,168
return



; ステージ2基本設定			■■■■■■■■■■■■■■■■■■■■■■■■■
*stagedata02
	stageboss=2000
	sndload "stage01.mid",101,1

	if gamebgm=1 : snd 101
	bload "stage02.txt",data

	gsel 3
	picload "jupiter.bmp",1 : roll=-200		; 背景画像読みこみ

	gsel 4
	picload "stage02.bmp",1				; ボス画像読みこみ

	repeat smax
		rnd stx.cnt,400
		rnd sty.cnt,550
		rnd stc.cnt,8 : sts.cnt=stc.cnt/2+1 : stc.cnt=stc.cnt*32+31
	loop
return

; ステージ2背景				●●●●●●●●●●
*haikei02
	pos 100,roll : gcopy 3,0,0,300,433
	if gtime\3=0 : roll++
	repeat smax
		color stc.cnt,stc.cnt,stc.cnt
		sty.cnt=sty.cnt+sts.cnt
		if sty.cnt>550 : sty.cnt=0
		pset stx.cnt,sty.cnt
	loop
return

; ステージ2ボス				●●●●●●●●●●
*boss02born
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=102		; 敵番号
		ef.cnt=800		; 固さ
		ex.cnt=136		; 初期出現位置x軸
		ey.cnt=-130		; 初期出現位置y軸
		exv.cnt=-12		; x方向運動量-12
		eyv.cnt=2		; y方向運動量
		exc.cnt=64		; 中心x
		eyc.cnt=32		; 中心y
		exw.cnt=48		; 大きさx
		eyw.cnt=20		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=1000		; スコア
		break
	loop
return
*boss02
	et.cnt++
	if eyv.cnt>0 : if et.cnt\(25-gamelevel)=0 : gosub *tamaborn0
	if eyv.cnt>0 : if et.cnt\(10-gamelevel)=0 : gosub *born00
	if eyv.cnt>0 : if et.cnt\(6-gamelevel)=0  : edx=ex.cnt+62 : edy=ey.cnt+40 : gosub *tamaborn1
	if eyv.cnt<0 : if et.cnt\(25-gamelevel)=0 : bx=ex.cnt+4   : by=ey.cnt+64  : gosub *born04
	if eyv.cnt<0 : if et.cnt\(25-gamelevel)=0 : bx=ex.cnt+116 : by=ey.cnt+64  : gosub *born04
	if eyv.cnt<0 : if et.cnt\(ef.cnt/20+5-gamelevel)=0 : gosub *tamaborn6

	if (ey.cnt>200)&(frame\2=0) : eyv.cnt-- : if eyv.cnt<-2 : eyv.cnt=-2
	if (ey.cnt<0)&(frame\2=0)   : eyv.cnt++ : if eyv.cnt>2  : eyv.cnt=2
	if ex.cnt>272 : exv.cnt-- : if exv.cnt<-8 : exv.cnt=-8
	if ex.cnt<0   : exv.cnt++ : if exv.cnt<-8 : exv.cnt=-8
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	pos ex.cnt,ey.cnt : gcopy 4,0,0,128,124
return


; ステージ3基本設定				●●●●●●●●●●
*stagedata03
	stageboss=2000
	sndload "stage01.mid",101,1
	if gamebgm=1 : snd 101
	bload "stage03.txt",data

	gsel 3
	picload "stone.bmp",1					; 背景画像読みこみ
	roll1=0 : roll2=300 : roll3=-200

	gsel 4
	picload "stage03.bmp",1					; ボス画像読みこみ

	repeat smax
		rnd stx.cnt,400
		rnd sty.cnt,550
		rnd stc.cnt,8 : sts.cnt=stc.cnt/2+1 : stc.cnt=stc.cnt*32+31
	loop
return

; ステージ3背景				●●●●●●●●●●
*haikei03
	pos 0,roll1   : gcopy 3,0,0,192,224
	pos 250,roll2 : gcopy 3,192,0,142,116
	pos 135,roll3 : gcopy 3,192,116,128,108
	roll1++
	if (gtime<stageboss)&(roll1>600) : roll1=-250
	roll2=roll2+2
	if (gtime<stageboss)&(roll2>600) : roll2=-120
	roll3=roll3+3
	if (gtime<stageboss)&(roll3>600) : roll3=-110
	repeat smax
		color stc.cnt,stc.cnt,stc.cnt
		sty.cnt=sty.cnt+sts.cnt
		if sty.cnt>550 : sty.cnt=0
		pset stx.cnt,sty.cnt
	loop
	if (gtime<stageboss)&(gtime\30=0) : gosub *born05
	if (gtime<stageboss)&(gtime\20=0) : gosub *born06
return

; ステージ3ボス				●●●●●●●●●●
*boss03born
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=103		; 敵番号
		ef.cnt=1200		; 固さ
		ex.cnt=136		; 初期出現位置x軸
		ey.cnt=-180		; 初期出現位置y軸
		exv.cnt=0		; x方向運動量
		eyv.cnt=0		; y方向運動量
		exc.cnt=64		; 中心x
		eyc.cnt=64		; 中心y
		exw.cnt=20		; 大きさx
		eyw.cnt=20		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=1500		; スコア
		break
	loop
return
*boss03
	et.cnt++
	if eyv.cnt<0 : if et.cnt\(ef.cnt/20+5-gamelevel)=0 : gosub *tamaborn6
	if eyv.cnt<0 : if et.cnt\(10-gamelevel)=0 : gosub *born01
	if eyv.cnt<0 : if et.cnt\(20-gamelevel)=0 : edx=ex.cnt+60  : edy=ey.cnt+100 : gosub *tamaborn2
	if eyv.cnt>0 : if et.cnt\(15-gamelevel)=0 : gosub *tamaborn0
	if eyv.cnt>0 : if et.cnt\(20-gamelevel)=0 : edx=ex.cnt+22  : edy=ey.cnt+90  : gosub *tamaborn1
	if eyv.cnt>0 : if et.cnt\(20-gamelevel)=0 : edx=ex.cnt+102 : edy=ey.cnt+90  : gosub *tamaborn1
	if ey.cnt>150 : eyv.cnt--  : if eyv.cnt<-2 : eyv.cnt=-2
	if ey.cnt<10  : eyv.cnt++  : if eyv.cnt>2  : eyv.cnt=2
	if et.cnt\3=0 : if (mx+16)>(ex.cnt+exc.cnt) : exv.cnt++ : else : exv.cnt--
	if exv.cnt>8  : exv.cnt=8
	if exv.cnt<-8 : exv.cnt=-8
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	pos ex.cnt,ey.cnt : gcopy 4,0,0,128,172
return


; ステージ4基本設定				●●●●●●●●●●
*stagedata04
	stageboss=2000
	sndload "stage01.mid",101,1
	if gamebgm=1 : snd 101
	bload "stage04.txt",data

	gsel 3
	picload "saturn.bmp",1 : roll=-100		; 背景画像読みこみ

	gsel 4
	picload "stage04.bmp",1				; ボス画像読みこみ

return

; ステージ4背景				●●●●●●●●●●
*haikei04
	pos -50,roll : gcopy 3,0,0,434,319
	if gtime\3=0 : roll++
	repeat smax
		color stc.cnt,stc.cnt,stc.cnt
		sty.cnt=sty.cnt+sts.cnt
		if sty.cnt>550 : sty.cnt=0
		pset stx.cnt,sty.cnt
	loop
return

; ステージ4ボス				●●●●●●●●●●
*boss04born
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=104		; 敵番号
		ef.cnt=1000		; 固さ
		ex.cnt=0		; 初期出現位置x軸
		ey.cnt=550		; 初期出現位置y軸
		exv.cnt=0		; x方向運動量
		eyv.cnt=-6		; y方向運動量
		exc.cnt=64		; 中心x
		eyc.cnt=120		; 中心y
		exw.cnt=50		; 大きさx
		eyw.cnt=60		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=1500		; スコア
		break
	loop
return
*boss04
	et.cnt++
	if et.cnt\(40-gamelevel)=0 : bx=ex.cnt+24 : by=ey.cnt+64 : gosub *born02
	if et.cnt\(40-gamelevel)=15: bx=ex.cnt+86 : by=ey.cnt+64 : gosub *born02
	if exv.cnt!0 : if et.cnt\(20-gamelevel)=0 : gosub *tamaborn0
	if exv.cnt!0 : if et.cnt\(5-gamelevel)=0  : edx=ex.cnt+56 : edy=ey.cnt+120 : gosub *tamaborn3
	if exv.cnt=0 : if et.cnt\(10-gamelevel)=0 : gosub *born00
	if exv.cnt=0 : if et.cnt\(ef.cnt/20+5-gamelevel)=0 : gosub *tamaborn6

	if (ex.cnt<6)&(ey.cnt<10)   : exv.cnt=3  : eyv.cnt=0
	if (ex.cnt>266)&(ey.cnt<50) : exv.cnt=0  : eyv.cnt=6
	if (ex.cnt>266)&(ey.cnt>347): exv.cnt=-3 : eyv.cnt=0
	if (ex.cnt<6)&(ey.cnt>347)  : exv.cnt=0  : eyv.cnt=-6
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	pos ex.cnt,ey.cnt : gcopy 4,0,0,128,193
return


; ステージ5基本設定				●●●●●●●●●●
*stagedata05
	stageboss=2000
	sndload "stage01.mid",101,1
	if gamebgm=1 : snd 101
	bload "stage05.txt",data

	gsel 3
	picload "inside.bmp",1					; 背景画像読みこみ
	roll=-200

	gsel 4
	picload "stage03.bmp",1					; ボス画像読みこみ

	repeat 4
		stx.cnt=0
		sty.cnt=roll
		sts.cnt=5
		roll=roll+200
	loop
return

; ステージ5背景				●●●●●●●●●●
*haikei05
	repeat 4
		pos stx.cnt,sty.cnt : gcopy 3,0,0,400,200
		sty.cnt=sty.cnt+sts.cnt
		if (sty.cnt=600)&(stageend=0) : sty.cnt=-200
	loop
return

; ステージ5ボス				●●●●●●●●●●
*boss05born
	repeat emax
		if ef.cnt>0 : continue
		et.cnt=0		; 生成時間リセット
		em.cnt=105		; 敵番号
		ef.cnt=1500		; 固さ
		ex.cnt=272		; 初期出現位置x軸
		ey.cnt=-180		; 初期出現位置y軸
		exv.cnt=-4		; x方向運動量
		eyv.cnt=8		; y方向運動量
		exc.cnt=64		; 中心x
		eyc.cnt=64		; 中心y
		exw.cnt=20		; 大きさx
		eyw.cnt=20		; 大きさy
		ep.cnt=2		; 爆発パターン
		es.cnt=2000		; スコア
		break
	loop
return
*boss05
	et.cnt++
	if eyv.cnt>0 : if et.cnt\(10-gamelevel)=0 : gosub *tamaborn0
	if eyv.cnt<0 : if et.cnt\(ef.cnt/20+5-gamelevel)=0  : gosub *tamaborn6
	if ey.cnt<20  : if et.cnt\(15-gamelevel)=0 : gosub *born01
	if et.cnt\(10-gamelevel)=0  : edx=ex.cnt+22  : edy=ey.cnt+90 : gosub *tamaborn1
	if et.cnt\(10-gamelevel)=0  : edx=ex.cnt+102 : edy=ey.cnt+90 : gosub *tamaborn1
	if (ef.cnt<500)&(ey.cnt<20)  : if et.cnt\(5-gamelevel)=0  : edx=ex.cnt+60 : edy=ey.cnt+100 : gosub *tamaborn2
	if (ef.cnt<1000)&(eyv.cnt=-8): if et.cnt\(5-gamelevel)=0  : edx=ex.cnt+60 : edy=ey.cnt+90  : gosub *tamaborn3
	if (ef.cnt<1000)&(eyv.cnt=8) : if et.cnt\(15-gamelevel)=0 : bx=ex.cnt+60  : by=ey.cnt+90   : gosub *born02
	if ey.cnt>150 : eyv.cnt-- : if eyv.cnt<-8 : eyv.cnt=-8
	if ey.cnt<50  : eyv.cnt++ : if eyv.cnt>8  : eyv.cnt=8
	if ex.cnt>272 : exv.cnt-- : if exv.cnt<-4 : exv.cnt=-4
	if ex.cnt<0   : exv.cnt++ : if exv.cnt>4  : exv.cnt=4
	ex.cnt=ex.cnt+exv.cnt : ey.cnt=ey.cnt+eyv.cnt
	pos ex.cnt,ey.cnt : gcopy 4,0,0,128,172
return


; ワープ+基地へ帰還					●●●●●●●●●●
*stageclear
	dx=184-mx : px=dx : if dx<0 : dx=0-dx
	dy=400-my : py=dy : if dy<0 : dy=0-dy
	dv=dx : if dv<dy : dv=dy
	if dv=0 : dv=1
	mxv=px*90/dv : myv=py*90/dv

	repeat pmax : pxv.cnt=0 : pyv.cnt=0 : loop

	pfade=0 : spat=0

	repeat
		redraw 2
		stick pat : gtime++
		if gtime>50 : getkey spat,shotkey
		color pfade,pfade,pfade : boxf 0,0,400,550
		gosub *haikei
		gosub *nigeruboss
		rnd dexp,10 : dexp++
		if stageend=1 : if frame\dexp=0 : if gamesnd=1 : snd 1
		mx=mx+(mxv/30) : if (mx>180)and(mx<188) : mxv=0
		my=my+(myv/30) : if (my>396)and(my<404) : myv=0
		pos mx,my : gcopy 2,32,frame\2*40,32,40
		if (stageend=1)&(gtime\2)=0 : gosub *clearexpborn
		if stageend=1 : gosub *explosion
		font "MSゴシック",15,1
		if stageend=2 : color 255,0,255 : pos 125,200 : mes "THE ENEMY ESCAPE!"
		gosub *gamescore
		getkey returntop,121 : if returntop=1 : end
		await gamewait
		if (pat=32)or(spat>0) : pfade=pfade+10 : spat=0
		palfade pfade,0,254
		pfade=pfade+2 : if pfade>255 : break
		redraw 1
	loop

	palfade 0 
	if gamebgm=1 : sndoff : wait 20
	my=400 : myv=0 : gtime=0 : starline=1
	repeat smax
		rnd stx.cnt,400
		rnd sty.cnt,550
		rnd stc.cnt,8 : sts.cnt=stc.cnt/2+1 : stc.cnt=stc.cnt*32+31
	loop

	clearbonus=mf*1000
	if gamebgm=1 : snd 202

	repeat
		redraw 2
		stick pat : gtime++
		getkey spat,shotkey
		color bgcolor : boxf 0,0,400,550
		if gtime>300 : if gtime\3=0 : starline++
		gosub *warp
		if starline>20 : myv--
		my=my+myv
		pos 184,my : gcopy 2,32,gtime\2*40,32,40
		font "MSゴシック",15,1
		pos 135,250 : color 255,255,0 : mes "STAGE "+stage+" CLEARED !"
		if (gtime<100)&((pat=32)or(spat>0))             : gtime=100 : spat=0
		if (gtime>100)&(gtime<200)&((pat=32)or(spat>0)) : gtime=200 : spat=0
		if (gtime>200)&(gtime<300)&((pat=32)or(spat>0)) : gtime=300 : spat=0
		if gtime>200 : pos 120,300 : color 0,255,0 : mes "LEFTED SHIELD BONUS"
		if gtime>300 : pos 125,320 : color 255,0,0 : mes "1000 point ×"+mf+" = "+clearbonus
		if gtime=300 : score=score+clearbonus
		if (gtime>300)&((pat=32)or(spat>0))             : gtime=500 : spat=0

		gosub *gamescore
		getkey returntop,121 : if returntop=1 : end
		await gamewait
		redraw 1
		if gtime>500 : break
	loop
	goto *selectweapon


; ワープ効果									●●●●●●●●●●
*warp
	repeat smax
		color stc.cnt,stc.cnt,stc.cnt
		sty.cnt=sty.cnt+sts.cnt
		if sty.cnt>550 : sty.cnt=0-starline : rnd stx.cnt,400
		pos stx.cnt,sty.cnt+starline
		line stx.cnt,sty.cnt
	loop
return

; ステージクリア時の爆風効果					●●●●●●●●●●
*clearexpborn
	repeat pmax
		if pf.cnt>0 : continue
		rnd px.cnt,dbossxc : if (dbossxc/2)>px.cnt : pxv.cnt=-1 : else : pxv.cnt=1
		px.cnt=px.cnt+dbossx-50
		rnd py.cnt,dbossyc : if (dbossyc/2)>py.cnt : pyv.cnt=-1 : else : pyv.cnt=1
		py.cnt=py.cnt+dbossy-50
		pm.cnt=2 : pf.cnt=9 : break
	loop
return


; ステージクリア時に表示するヤラレボス					●●●●●●●●●●
*nigeruboss
	pos dbossx,dbossy
	if stage=1 : gcopy 4,0,0,126,168
	if stage=2 : gcopy 4,0,0,128,124
	if stage=3 : gcopy 4,0,0,128,172
	if stage=4 : gcopy 4,0,0,128,193
	if stage=5 : gcopy 4,0,0,128,172
										; ボスを追加する毎に行を追加
	if stageend=1 : dbossy=dbossy+4
	if stageend=2 : dbossy=dbossy-2
return


; 武器選択ルーチン(武器設定込み)		■■■■■■■■■■■■■■■■■■■■■■■■■
*selectweapon
	drx=210 : dlx=190 : dry=205 : dly=335
	repeat
		redraw 2
		drx=drx+4 : dlx=dlx-4 : dry=dry-4 : dly=dly+4
		color 0,0,0 : boxf dlx,dry,drx,dly
		color 255,255,255 : pos dlx,dry : line drx,dry : line drx,dly : line dlx,dly : line dlx,dry
		redraw 1
		if dly>550 : break
	loop

	if gamebgm=1 : sndoff : wait 20
	if ending=1 : goto *restart

	stage++
	if stage>stagelimit : goto *dummyend
	if stage=2  : nextstage="惑星上空"
	if stage=3  : nextstage="隕石地帯"
	if stage=4  : nextstage="惑星上空"
	if stage=5  : nextstage="敵基地内"

	damage=bfmf-mf : efix=0

	repeat 6
		wrfix.cnt-- : if wrfix.cnt<0 : wrfix.cnt=0
		wlfix.cnt-- : if wlfix.cnt<0 : wlfix.cnt=0
	loop

	if (wrshot=1)&(damage>5) : wrfix.1=1			; 使えない武器の設定
	if (wrshot=2)&(damage>4) : wrfix.2=1
	if (wrshot=3)&(damage>3) : wrfix.3=1
	if (wrshot=4)&(damage>2) : wrfix.4=1
	if (wrshot=4)&(damage>5) : wrfix.4=2			; 6ダメージ以上で2ステージ使用不可
	if (wrshot=5)&(damage>1) : wrfix.5=1
	if (wrshot=5)&(damage>3) : wrfix.5=2			; 4ダメージ以上で2ステージ使用不可
	if (wrshot=5)&(damage>5) : wrfix.5=3			; 6ダメージ以上で3ステージ使用不可
	if (wlshot=1)&(damage>5) : wlfix.1=1
	if (wlshot=2)&(damage>4) : wlfix.2=1
	if (wlshot=3)&(damage>3) : wlfix.3=1
	if (wlshot=4)&(damage>2) : wlfix.4=1
	if (wlshot=4)&(damage>5) : wlfix.4=2
	if (wlshot=5)&(damage>1) : wlfix.5=1
	if (wlshot=5)&(damage>3) : wlfix.5=2
	if (wlshot=5)&(damage>5) : wlfix.5=3
	if (move=8)&(damage>6)   : efix=8
	if (move=10)&(damage>4)  : efix=10

	mf=mf+(6-gamelevel) : if mf>10 : mf=10
	bfmf=mf

	rlimit=0 : llimit=0 : elimit=6
	if stage>1 : rlimit=1						; 利用可能になった武器の設定(by STAGE)
	if stage>1 : llimit=1
	if stage>2 : rlimit=2
	if stage>2 : llimit=2
	if stage>3 : rlimit=3
	if stage>3 : llimit=3
	if stage>4 : rlimit=4
	if stage>4 : llimit=4
	if stage>5 : rlimit=5
	if stage>5 : llimit=5
	if stage>2 : elimit=8
	if stage>4 : elimit=10

	wrshot=0 : wlshot=0 : selectposition=0
	if level>4 : selectposition=2
	mx=184 : my=300

	repeat wmax : wf.cnt=0 : loop
	repeat pmax : pf.cnt=0 : loop
	repeat emax : ef.cnt=0 : loop
	repeat tmax : tf.cnt=0 : loop

	if gamebgm=1 : snd 201
	gtime=0

	repeat
		redraw 2
		stick pat,15 : gtime++
		getkey spat,shotkey
		color 0,0,0 : boxf 0,0,400,550

		pos mx,my : gcopy 2,32,gtime\2*40,32,40
		if gtime\3=0 : shotr=1 : shotl=1
		gosub *selectenemy
		gosub *jikitama
		gosub *explosion

		font "MSゴシック",15,1
		pos 90,30  : color 0,255,255 : mes "SELECT WEAPONS & ENGINE"
		font "MSゴシック",12,2
		pos 110,50 : color 255,255,255 : mes "↓↑  SELECT WEAPON OR ENGINE"
		pos 110,65 : color 255,255,255 : mes "SHOT  SETTLEMENT"

		if spat>0 : selectposition++ : await 100 : if gamesnd=1 : snd 7
		if selectposition>2 : selectposition=0

		font "MSゴシック",15,1
		pos 32,102  : color 0,128,0 : mes "LEFT WEAPON"
		pos 252,102 : color 0,128,0 : mes "RIGHT WEAPON"
		pos 172,352 : color 0,128,0 : mes "ENGINE"

		if selectposition=0 : pos 30,100  : color 0,255,0 : mes "LEFT WEAPON"
		if selectposition=1 : pos 250,100 : color 0,255,0 : mes "RIGHT WEAPON"
		if selectposition=2 : pos 170,350 : color 0,255,0 : mes "ENGINE"

		if (selectposition=0)&(pat&8>0) : wlshot++ : await 100 : if gamesnd=1 : snd 0
		if wlshot>llimit : wlshot=0
		if wlfix.wlshot>0 : wlshot++
		if wlshot>llimit : wlshot=0
		if (selectposition=0)&(pat&2>0) : wlshot-- : await 100 : if gamesnd=1 : snd 0
		if wlshot<0 : wlshot=llimit
		if wlfix.wlshot>0 : wlshot--
		if wlshot<0 : wlshot=llimit

		if (selectposition=1)&(pat&8>0) : wrshot++ : await 100 : if gamesnd=1 : snd 0
		if wrshot>rlimit : wrshot=0
		if wrfix.wrshot>0 : wrshot++
		if wrshot>rlimit : wrshot=0
		if (selectposition=1)&(pat&2>0) : wrshot-- : await 100 : if gamesnd=1 : snd 0
		if wrshot<0 : wrshot=rlimit
		if wrfix.wrshot>0 : wrshot--
		if wrshot<0 : wrshot=rlimit

		if (selectposition=2)&(pat&8>0) : move=move+2 : await 100 : if gamesnd=1 : snd 0
		if (move=efix)&(move!6) : move=move+2
		if move>elimit : move=6
		if (selectposition=2)&(pat&2>0) : move=move-2 : await 100 : if gamesnd=1 : snd 0
		if (move=efix)&(move!6) : move=move-2
		if move<6 : move=elimit

		pos 42,132  : color 128,128,0 : mes "NORMAL SHOT"
		if wlshot=0 : pos 40,130 : color 255,255,0 : mes "NORMAL SHOT"
		mr=128 : mg=128 : mb=0 : if wlfix.1>0 : mg=0 : mb=0
		if llimit<1 : mr=64 : mg=64 : mb=64
		pos 42,162  : color mr,mg,mb : mes "V BEAM"
		if wlshot=1 : pos 40,160  : color 255,255,0 : mes "V BEAM"
		mr=128 : mg=128 : mb=0 : if wlfix.2>0 : mg=0
		if llimit<2 : mr=64 : mg=64 : mb=64
		pos 42,192  : color mr,mg,mb : mes "NAPARM"
		if wlshot=2 : pos 40,190  : color 255,255,0 : mes "NAPARM"
		mr=128 : mg=128 : mb=0 : if wlfix.3>0 : mg=0
		if llimit<3 : mr=64 : mg=64 : mb=64
		pos 42,222  : color mr,mg,mb : mes "WIDE SHOT"
		if wlshot=3 : pos 40,220  : color 255,255,0 : mes "WIDE SHOT"
		mr=128 : mg=128 : mb=0 : if wlfix.4>0 : mg=0
		if llimit<4 : mr=64 : mg=64 : mb=64
		pos 42,252  : color mr,mg,mb : mes "LASER"
		if wlshot=4 : pos 40,250  : color 255,255,0 : mes "LASER"
		mr=128 : mg=128 : mb=0 : if wlfix.5>0 : mg=0
		if llimit<5 : mr=64 : mg=64 : mb=64
		pos 42,282  : color mr,mg,mb : mes "AUTO SHOT"
		if wlshot=5 : pos 40,280  : color 255,255,0 : mes "AUTO SHOT"

		pos 262,132 : color 128,128,0 : mes "NORMAL SHOT"
		if wrshot=0 : pos 260,130 : color 255,255,0 : mes "NORMAL SHOT"
		mr=128 : mg=128 : mb=0 : if wrfix.1>0 : mg=0 : mb=0
		if rlimit<1 : mr=64 : mg=64 : mb=64
		pos 262,162 : color mr,mg,mb : mes "V BEAM"
		if wrshot=1 : pos 260,160 : color 255,255,0 : mes "V BEAM"
		mr=128 : mg=128 : mb=0 : if wrfix.2>0 : mg=0 : mb=0
		if rlimit<2 : mr=64 : mg=64 : mb=64
		pos 262,192 : color mr,mg,mb : mes "NAPARM"
		if wrshot=2 : pos 260,190 : color 255,255,0 : mes "NAPARM"
		mr=128 : mg=128 : mb=0 : if wrfix.3>0 : mg=0 : mb=0
		if rlimit<3 : mr=64 : mg=64 : mb=64
		pos 262,222 : color mr,mg,mb : mes "WIDE SHOT"
		if wrshot=3 : pos 260,220 : color 255,255,0 : mes "WIDE SHOT"
		mr=128 : mg=128 : mb=0 : if wrfix.4>0 : mg=0 : mb=0
		if rlimit<4 : mr=64 : mg=64 : mb=64
		pos 262,252 : color mr,mg,mb : mes "LASER"
		if wrshot=4 : pos 260,250 : color 255,255,0 : mes "LASER"
		mr=128 : mg=128 : mb=0 : if wrfix.5>0 : mg=0 : mb=0
		if rlimit<5 : mr=64 : mg=64 : mb=64
		pos 262,282 : color mr,mg,mb : mes "AUTO SHOT"
		if wrshot=5 : pos 260,280 : color 255,255,0 : mes "AUTO SHOT"

		pos 132,382 : color 128,128,0 : mes "NORMAL ENGINE"
		if move=6 : pos 130,380 : color 255,255,0 : mes "NORMAL ENGINE"
		mr=128 : mg=128 : mb=0 : if efix=8 : mg=0 : mb=0
		if elimit<8 : mr=64 : mg=64 : mb=64
		pos 132,412 : color mr,mg,mb : mes "POWERUP ENGINE"
		if move=8: pos 130,410 : color 255,255,0 : mes "POWERUP ENGINE"
		mr=128 : mg=128 : mb=0 : if efix=10: mg=0 : mb=0
		if elimit<10: mr=64 : mg=64 : mb=64
		pos 132,442 : color mr,mg,mb : mes "LIMITED ENGINE"
		if move=10: pos 130,440 : color 255,255,0 : mes "LIMITED ENGINE"

		pos 50,480 : color 255,0,255 : mes "IF YOU ARE READY,PUSH RETURN KEY"
		pos 100,510 : color 255,255,0 : mes "NEXT STAGE IS "+nextstage

		if pat=32 : gettime htime,4 : gettime mtime,5 : gettime stime,6 : ntime=htime*1000+mtime*100+stime : break
		getkey returntop,121 : if returntop=1 : end
		gosub *gamescore
		await gamewait
		redraw 1
	loop
	if gamebgm=1 : sndoff : wait 20
	repeat wmax  : wf.cnt=0  : loop
	repeat pmax  : pf.cnt=0  : loop
	repeat emax  : ef.cnt=0  : loop
	repeat ibmax : ibf.cnt=0 : loop
	repeat tmax  : tf.cnt=0  : loop
	goto *stagedataload


; 武器選択画面で出てくる敵の処理
*selectenemy
	repeat 3
		if ef.cnt<1 : ef.cnt=5 : rnd ex.cnt,200 : ex.cnt=ex.cnt+100 : ey.cnt=-32
		exv.cnt=0 : eyv.cnt=8
		exc.cnt=16 : eyc.cnt=16 : exw.cnt=16 : eyw.cnt=16 : ep.cnt=1
		en=cnt
		repeat wmax
			if wf.cnt<1 : continue
			dx=(ex.en+exc.en)-(wx.cnt+wxc.cnt) : if dx<0 : dx=-dx
			dy=(ey.en+eyc.en)-(wy.cnt+wyc.cnt) : if dy<0 : dy=-dy
			if (dx>=0)&(dx<(exw.en+wxw.cnt))&(dy>=0)&(dy<(eyw.en+wyw.cnt)) : ef.en=ef.en-wd.cnt : wb.cnt=1
		loop
		if ef.cnt<1 : gosub *explosionborn
		pos ex.cnt,ey.cnt : gcopy 2,0,200,32,32
		ey.cnt=ey.cnt+eyv.cnt : if ey.cnt>550 : ef.cnt=0
	loop

	repeat 3,3
		if ef.cnt<1 : ef.cnt=5 : ex.cnt=-32 : rnd ey.cnt,300 : ey.cnt=ey.cnt+150
		exv.cnt=8 : eyv.cnt=0
		exc.cnt=16 : eyc.cnt=16 : exw.cnt=16 : eyw.cnt=16 : ep.cnt=1
		en=cnt
		repeat wmax
			if wf.cnt<1 : continue
			dx=(ex.en+exc.en)-(wx.cnt+wxc.cnt) : if dx<0 : dx=-dx
			dy=(ey.en+eyc.en)-(wy.cnt+wyc.cnt) : if dy<0 : dy=-dy
			if (dx>=0)&(dx<(exw.en+wxw.cnt))&(dy>=0)&(dy<(eyw.en+wyw.cnt)) : ef.en=ef.en-wd.cnt : wb.cnt=1
		loop
		if ef.cnt<1 : gosub *explosionborn
		pos ex.cnt,ey.cnt : gcopy 2,0,200,32,32
		ex.cnt=ex.cnt+exv.cnt : if ex.cnt>400 : ef.cnt=0
	loop
return


; ■■■読み出し・解読■■■
*highscoreload
	;秘密
return


; ■■■highscore.datの作成■■■
*highdat
	;秘密
return


; ■■■ソート・暗号化・出力■■■
*highscoresave
	;秘密
return


; コンフィグ読み出し
*configload
	;秘密
return


; コンフィグ書き出し
*configsave
	;秘密
return


; コンフィグ作成
*configborn
	秘密
return