;************************************************************************
;*									*
;*	title name	: "yossy"					*
;*	proccess	: enemy sub.1					*
;*	file name	: ys_boss2					*
;*									*
;************************************************************************
;
;
		SALL
;
		include		ys_header.inc
		include		ys_unit.h
		include		ys_pld.h
		include		ys_presno.h
		include		ys_color.h
		include		ys_ename.h
;
		XALL
;
;
;------------------------------------------------------------------------
;-		global symbol						-
;------------------------------------------------------------------------
		GLB	MPACKIN,MPACHIN,MPACWIN
;
		GLB	MPACKMV,MPACHMV,MPACWMV
;
;------------------------------------------------------------------------
;-		extern symbol						-
;------------------------------------------------------------------------
;
;-------------< ys_main >------------------------------------------------
		EXT	BS_SCRE
		EXT	SOUND_3_ON
;
;-------------< ys_rpro >------------------------------------------------
		EXT	JSRSUB
		EXT	CHIPON
;
;-------------< ys_play >------------------------------------------------
		EXT	EBSTAT
		EXT	PFAL,PSTP,PMOV,PDEM,PGOL
		EXT	PFLP
;
;-------------< ys_bgsc >------------------------------------------------
;
;-------------< ys_enmy >------------------------------------------------
		EXT	ENEMY,ENINSB
		EXT	ENCLEAR,ENCLEAR_NORETN,DISPCK0,DISPCK2
		EXT	ENINSR,ENINSR2,EEXCHK,EEYCHK,EEXYCK,ESTATST
		EXT	ENINSR_I,ENINSR2_I
		EXT	SCOREST
		EXT	ENMDCK,XSDOWN,EPCRCK,MUKEOR,XSPEOR,MKEOR2,PLFLST
		EXT	PLFLST_2
		EXT	FUSENST
		EXT	SHOT_EN_KILL,SHOT_EN_KILL_S
;
		EXT	EINIT,EFAIL,EMOVE,EEATM,ENOSE,EBABL
;
		EXT	EATMXS,NOSWT
;
		EXT	EGGKILL_ALL
;
		EXT	FSMK0_SET2
;
		EXT	TROBJ_CANCEL
		EXT	TROBJ_SR_2x2,TROBJ_SR_4x4,TROBJ_SR_8x8
		EXT	TROBJ_SR_2x2_CL,TROBJ_SR_4x4_CL,TROBJ_SR_8x8_CL
		EXT	TROBJ_OAM_2x2,TROBJ_OAM_4x4,TROBJ_OAM_8x8
		EXT	TROBJ_OAM_2x2_I,TROBJ_OAM_4x4_I,TROBJ_OAM_8x8_I
		EXT	TROBJ_CLEAR
		EXT	TROBJ_PLOT_X,TROBJ_PLOT_Y
;
;-------------< ys_enmy2 >------------------------------------------------
		EXT	NMZ_HOSEI
;
;-------------< ys_enmy3 >------------------------------------------------
		EXT	BSCLW_SET_B,BSCLW_SET_M,BSCLW_SET_B_T
		EXT	BOSS_CLEAR
		EXT	BOSS_EN_CHANGE
;
;-------------< ys_enmy4 >------------------------------------------------
		EXT	MPACK_DEMO_ED
;
;-------------< ys_enmy6 >------------------------------------------------
		EXT	LOCKON_TARGET,LOCKON_TARGET2
;
;-------------< ys_exst >------------------------------------------------
		EXT	EXINSR
;
;-------------< ys_unit >------------------------------------------------
		EXT	UNDTADD,UNDATA,RUTDATA
;
;-------------< ys_init >------------------------------------------------
		EXT	UNCOMPRES,VRAMDX_ST,VRAMDX_H_ST,VRAMDX_L_ST,VRAMDX_L_C_ST
		EXT	M_DMA_BFST
;
;-------------< ys_play >------------------------------------------------
		EXT	TIMEUP_SET
;
;-------------< ys_game >------------------------------------------------
		EXT	BS1_MSG
;
;-------------< ys_data >------------------------------------------------
		EXT	SIN,COS
;
;
;------------------------------------------------------------------------
;-		define symbol						-
;------------------------------------------------------------------------
BABY_INDEX	EQU	00
;
;
;
;************************************************************************
;*									*
;*		program start						*
;*									*
;************************************************************************
;
		EXTEND
;
		MEM16
		IDX8
;
		DPAGE	EN0RAM
;
Group_2		GROUP	Boss2_pro
Boss2_pro	SECT	REL
;
;
;****************************************************************
;*		ダミールーチン					*
;****************************************************************
DUMMY_SUB	EQU	$
		TYX
		RTS
;
;****************************************************************
;*		initial ( まざーぱっくん )			*
;****************************************************************
MPACH_I_XPOS	EQU	$
		WORD	0FFE0H,00020H
;
MPACKIN		EQU	$			;-- mpackin --
		STX	MPACKIDX

		INC	<ENWRK0,X		;回転エリアドローフラグ初期セット

		LDA	#001FFH			;初期たて倍率セット
		STA	ENWRK6,X
;;;;;;;;		LDA	#001FFH			;初期よこ倍率セット
		STA	ENWRKA,X
		LDA	#0001CH			;頭の付け根から頭の中心までの距離初期セット
		STA	MPACKFWD
		LDA	#00006H			;キャラパターンインデックスセット
		STA	<ENWRK4,X

		DEC	MPACKMUK		;あたりの向き初期セット

		LDY	#MPACK_RMODE07
		STY	<ENWRK2,X

		LDA	#00003			;ダメージカウンターセット
		STA	MPACKDMG		;
		LDA	#00388H			;ポジションセット
		STA	ENXPSL,X		;
		LDA	ENYPSL,X		;最低Ｙ　ＰＯＳ．セット
		STA	MPACKYLW		;
		CLC				;
		ADC	#00060H			;
		STA	ENYPSL,X		;

		LDA	#00070H			;頭の回転角セット
		STA	ENWRK8,X
		LDA	#0FFC0H			;頭の位置計算用回転角補正値初期セット
		STA	MPACKARV

		LDA	#ZPACK
		TXY
		JSL	>ENINSR2
		LDA	#00388H
		STA	ENXPSL,Y
		LDA	#00780H
		STA	ENYPSL,Y
		LDA	#1011110000000000B	;チェックされない
		STA	ENMOD0,Y
		LDA	ENMOD1,Y		;敵じゃない
		ORA	#0010000000000000B	;
		STA	ENMOD1,Y		;
		LDA	#0010110000000001B	;範囲外クリアなし
		STA	ENMOD2,Y
		LDA	#00001H
		STA	ENCHPT,Y
		M8
		LDA	#02CH
		STA	ENCLOR,Y

		STY	ZPACKIDX
;
		STZ	BG1TYP			;
;
;		LDA	BOSS_RETRY		;２回目以降 ?
;		BEQ	MPACKIN0300		;  no: MPACKIN0300
;
;		LDA	#0FFH
;		STA	ENYUSN,Y
;
;		LDA	#010H
;		BRA	MPACKIN0400
;
;MPACKIN0300	EQU	$
		LDA	#008H

MPACKIN0400	EQU	$
		STA	ENWRK2,Y
		LDA	#0FFH
		STA	ENWTSP,Y
		M16
		STZ	BOSS0FLG

		LDX	#(010H-1)*2

MPACKIN0500	EQU	$
		LDA	>MOTOCOL+(09H*10H+00)*2,X
		STA	>DATACOL+(0EH*10H+00)*2,X
		DEX
		DEX
		BPL	MPACKIN0500

		RTL
;
;****************************************************************
;*		move	( まざーぱっくん )			*
;****************************************************************
;		ENWRK0	回転エリアドローフラグ
;		ENWRK2	ROUTINE MODE INDEX
;B		ENWRK4	キャラパターンインデックス
;B		ENWRK5	フェイスキャラパターンインデックス
;		ENWRK6	たて倍率
;		ENWRK8	回転角
;		ENWRKA	よこ倍率
;		ENWRKC	カウントチェック
;
;		ENCONT		フェイスキャラパターンインデックスのインデックス
;		ENCONT+1	キャラパターンインデックスのインデックス
;
;		ENTIM0	ストップタイマー
;		ENTIM1	キャラパターンチェンジタイマー
;		ENTIM2	フェイスキャラパターンチェンジタイマー
;		ENTIM3	無敵タイマー
;
;		MPACKIDX ボディーの敵インデックス
;		MPACKDTX フェイスキャラデータＸ　ＰＯＳ．
;		MPACKDTY	 ”	     Ｙ　ＰＯＳ．
;		MPACKDT0 cos * β
;		MPACKDT1 sin * α
;		MPACKDT2 cos * α
;		MPACKDT3 -sin * β
;		MPACKFWD 頭の付け根から頭の中心までの距離
;		MPACKFCX 頭の付け根のＸ　ＰＯＳ．
;		MPACKFCY 頭の付け根のＹ　ＰＯＳ．
;		NPACKMUK あたりの向き
;		MPACKARV 頭の位置計算用回転角補正値
;		MPACKYLW 最低Ｙ　ＰＯＳ．
;		MPACHLID 左の触手の敵インデックス
;		MPACHRID 右の触手の敵インデックス
;		MPACKRID ボディーの振り返り処理の後のリターンルーチンモードインデックス
;		MPACHLRI 左の触手のリターンルーチンモードインデックス
;		MPACHRRI 右の触手のリターンルーチンモードインデックス
;		MPACKDMG ダメージカウンター
;		MPACKOAM ＯＡＭセットしない数
;		MPACKATT 攻撃方法データ
;		MPACKSCT サウンドセットカウンター
;		ZPACKIDX スタートデモ用ZPACKの ROUTINE INDEX
;
;		MPACK_TIMER	触手攻撃タイマー
;
;		EWORKC	頭の中心Ｘ　ＰＯＳ．
;		EWORKE	頭の中心Ｙ　ＰＯＳ．
;
MPACK_SUB	EQU	$
MPACK_00	EQU	$
		WORD	MPACK_SUB00		;
MPACK_07	EQU	$
		WORD	MPACK_SUB07		;イニシャルデモ（イニシャルセット）
MPACK_10	EQU	$
		WORD	MPACK_SUB10		;イニシャルデモ（上昇）
MPACK_11	EQU	$
		WORD	MPACK_SUB11		;イニシャルデモ（面を水平に上げる）
MPACK_12	EQU	$
		WORD	MPACK_SUB12		;イニシャルデモ（面を上に上げる）
MPACK_13	EQU	$
		WORD	MPACK_SUB13		;イニシャルデモ（笑う）
MPACK_14	EQU	$
		WORD	MPACK_SUB14		;イニシャルデモ（攻撃体制に）
MPACK_20	EQU	$
		WORD	MPACK_SUB20		;綿毛攻撃（発射角度に）
MPACK_21	EQU	$
		WORD	MPACK_SUB21		;綿毛攻撃（縦に膨らむ）
MPACK_22	EQU	$
		WORD	MPACK_SUB22		;綿毛攻撃（綿毛を吐きだす）
MPACK_23	EQU	$
		WORD	MPACK_SUB23		;綿毛攻撃（待ち）
MPACK_24	EQU	$
		WORD	MPACK_SUB24		;綿毛攻撃（元に戻る）
MPACK_30	EQU	$
		WORD	MPACK_SUB30		;触手攻撃中
MPACK_40	EQU	$
		WORD	MPACK_SUB40		;だまし頭突き（準備）
MPACK_41	EQU	$
		WORD	MPACK_SUB41		;だまし頭突き（プレイヤー＆壁チェック）
MPACK_42	EQU	$
		WORD	MPACK_SUB42		;だまし頭突き（停止チェック）
MPACK_43	EQU	$
		WORD	MPACK_SUB43		;だまし頭突き（後方移動）
MPACK_44	EQU	$
		WORD	MPACK_SUB44		;だまし頭突き（元に、面を水平に上げる）
MPACK_45	EQU	$
		WORD	MPACK_SUB45		;だまし頭突き（頭回転、面を上に上げる）
MPACK_46	EQU	$
		WORD	MPACK_SUB46		;だまし頭突き（大笑い）
MPACK_47	EQU	$
		WORD	MPACK_SUB47		;だまし頭突き（元に）
MPACK_50	EQU	$
		WORD	MPACK_SUB50		;頭突き（準備）
MPACK_51	EQU	$
		WORD	MPACK_SUB51		;頭突き（壁チェック）
MPACK_52	EQU	$
		WORD	MPACK_SUB52		;頭突き（頭、縮み）
MPACK_53	EQU	$
		WORD	MPACK_SUB53		;頭突き（頭、伸び）
MPACK_54	EQU	$
		WORD	MPACK_SUB54		;頭突き（元に）
MPACK_60	EQU	$
		WORD	MPACK_SUB60		;ふりかえる（パターン待ち）
MPACK_61	EQU	$
		WORD	MPACK_SUB61		;ふりかえる
MPACK_80	EQU	$
		WORD	MPACK_SUB80		;やられ（面を水平に上げる）
MPACK_81	EQU	$
		WORD	MPACK_SUB81		;やられ（面を上に上げる）
MPACK_82	EQU	$
		WORD	MPACK_SUB82		;やられ（面を水平に）
MPACK_83	EQU	$
		WORD	MPACK_SUB83		;やられ（身構える＆触手待ち）
MPACK_90	EQU	$
		WORD	MPACK_SUB90		;やられ（面を水平に上げる）
MPACK_91	EQU	$
		WORD	MPACK_SUB91		;やられ（面を上に上げる）
MPACK_92	EQU	$
		WORD	MPACK_SUB92		;やられ（ＢＧ３効果セット）
MPACK_93	EQU	$
		WORD	MPACK_SUB93		;やられ（カラーフェード＆頭ズームダウン）
MPACK_94	EQU	$
		WORD	MPACK_SUB94		;やられ（崩れる）
MPACK_95	EQU	$
		WORD	MPACK_SUB95		;やられ（待ち）
;
MPACK_RMODE00	EQU	(MPACK_00-MPACK_SUB)/2
MPACK_RMODE07	EQU	(MPACK_07-MPACK_SUB)/2
MPACK_RMODE10	EQU	(MPACK_10-MPACK_SUB)/2
MPACK_RMODE11	EQU	(MPACK_11-MPACK_SUB)/2
MPACK_RMODE12	EQU	(MPACK_12-MPACK_SUB)/2
MPACK_RMODE13	EQU	(MPACK_13-MPACK_SUB)/2
MPACK_RMODE14	EQU	(MPACK_14-MPACK_SUB)/2
MPACK_RMODE20	EQU	(MPACK_20-MPACK_SUB)/2
MPACK_RMODE21	EQU	(MPACK_21-MPACK_SUB)/2
MPACK_RMODE22	EQU	(MPACK_22-MPACK_SUB)/2
MPACK_RMODE23	EQU	(MPACK_23-MPACK_SUB)/2
MPACK_RMODE30	EQU	(MPACK_30-MPACK_SUB)/2
MPACK_RMODE40	EQU	(MPACK_40-MPACK_SUB)/2
MPACK_RMODE41	EQU	(MPACK_41-MPACK_SUB)/2
MPACK_RMODE42	EQU	(MPACK_42-MPACK_SUB)/2
MPACK_RMODE43	EQU	(MPACK_43-MPACK_SUB)/2
MPACK_RMODE44	EQU	(MPACK_44-MPACK_SUB)/2
MPACK_RMODE45	EQU	(MPACK_45-MPACK_SUB)/2
MPACK_RMODE46	EQU	(MPACK_46-MPACK_SUB)/2
MPACK_RMODE47	EQU	(MPACK_47-MPACK_SUB)/2
MPACK_RMODE50	EQU	(MPACK_50-MPACK_SUB)/2
MPACK_RMODE51	EQU	(MPACK_51-MPACK_SUB)/2
MPACK_RMODE52	EQU	(MPACK_52-MPACK_SUB)/2
MPACK_RMODE53	EQU	(MPACK_53-MPACK_SUB)/2
MPACK_RMODE54	EQU	(MPACK_54-MPACK_SUB)/2
MPACK_RMODE60	EQU	(MPACK_60-MPACK_SUB)/2
MPACK_RMODE61	EQU	(MPACK_61-MPACK_SUB)/2
MPACK_RMODE80	EQU	(MPACK_80-MPACK_SUB)/2
MPACK_RMODE81	EQU	(MPACK_81-MPACK_SUB)/2
MPACK_RMODE82	EQU	(MPACK_82-MPACK_SUB)/2
MPACK_RMODE83	EQU	(MPACK_83-MPACK_SUB)/2
MPACK_RMODE90	EQU	(MPACK_90-MPACK_SUB)/2
MPACK_RMODE91	EQU	(MPACK_91-MPACK_SUB)/2
MPACK_RMODE92	EQU	(MPACK_92-MPACK_SUB)/2
MPACK_RMODE93	EQU	(MPACK_93-MPACK_SUB)/2
MPACK_RMODE94	EQU	(MPACK_94-MPACK_SUB)/2
MPACK_RMODE95	EQU	(MPACK_95-MPACK_SUB)/2
;
MPACKMV		EQU	$			;-- mpackmv --
		JSR	MPACK_OAM_SET

		JSL	>ENMDCK

		LDY	<ENWRK0,X		;回転エリア転送する ?
		BMI	MPACKMV0500		; yes: MPACKMV0500

		TXY
		LDA	<ENWRK2,X
		ASL	A
		TAX
		JSR	(MPACK_SUB,X)

		LDY	ENYUSN,X		;姿が見える ?
		BMI	MPACKMV0800		;  no: MPACKMV0800

		LDY	MPACKOAM		;
		BNE	MPACKMV0800		;

		JSR	MPACK_FACE_DAT

		LDY	<ENWRK2,X		;ラストダメージ ?
		CPY	#MPACK_RMODE90		;
		BPL	MPACKMV0500		; yes: MPACKMV0500

		JSR	MPACK_ENCHK
		JSR	MPACK_PLCHK

MPACKMV0500	EQU	$
		JSR	MPACK_ROT_SET

		LDA	ENTIM3,X		;無敵 ?
		BEQ	MPACKMV0800		;  no: MPACKMV0800
		AND	#00003			;フラッシングする ?
		BNE	MPACKMV0800		;  no: MPACKMV0800

		LDA	ENCLOR,X
		EOR	#002
		STA	ENCLOR,X

;		JSR	MPACK_FLASH

MPACKMV0800	EQU	$
		LDA	ENXSPD,X
		BPL	MPACKMV0900

		EOR	#0FFFFH
		INC	A

MPACKMV0900	EQU	$
		CLC
		ADC	MPACKSCT
		CMP	#02000H
		BMI	MPACKMV0A00

		SEC
		SBC	#02000H
		PHA
		LDA	#0005FH			;［Ｓ］
		JSL	>SOUND_3_ON
		PLA

MPACKMV0A00	EQU	$
		STA	MPACKSCT

		RTL
;
;MPACK_DMG_COL	EQU	$
;		WORD	07F26H,07FFFH,06F35H,00000H
;		WORD	07F26H,0477FH,0323FH,07FFFH
;		WORD	036DBH,0D57AH,01016H,0AC4DH
;		WORD	00D6CH,02CD0H,05CACH,03012H
;;
;MPACK_FLASH	EQU	$
;		DEC	A
;		BNE	MPACK_FLASH1000
;
;		LDX	#000
;
;MPACK_FLASH0100	EQU	$
;		LDA	>MOTOCOL+006H*20H+008H*20H,X
;		STA	>DATACOL+006H*20H+008H*20H,X
;
;		INX
;		INX
;		CPX	#010H*2
;		BMI	MPACK_FLASH0100
;
;		LDX	<ENINDX
;		RTS
;
;MPACK_FLASH1000	EQU	$
;		AND	#0001FH
;		TAY
;		LDX	#000
;
;MPACK_FLASH1100	EQU	$
;		LDA	!MPACK_DMG_COL,Y
;		STA	>DATACOL+006H*20H+008H*20H,X
;
;		INY
;		INY
;		INX
;		INX
;		CPX	#010H*2
;		BMI	MPACK_FLASH1100
;
;		LDX	<ENINDX
;		RTS
;
MPACK_OAM_SET	EQU	$
		LDY	ENYUSN,X
		BMI	MPACK_O_SET0800

		JSL	>TROBJ_OAM_8x8

		LDA	MPACKFWD		;CCWORK0 <- 頭の付け根から頭の中心までの距離
		STA	CCWORK0
		LDA	ENWRK8,X		;CCWORK1 <- 回転角
		STA	CCWORK1
		LDA	MPACKFCX		;CCWORK2 <- 頭の付け根のＸ　ＰＯＳ．
		STA	CCWORK2
		LDA	MPACKFCY		;CCWORK3 <- 頭の付け根のＹ　ＰＯＳ．
		STA	CCWORK3
		LDA	MPACKARV		;CCWORK4 <- 頭の位置計算用回転角補正値
		STA	CCWORK4
		LDA	ENWRK6,X		;CCWORK5 <- 縦倍率
		LSR	A
		STA	CCWORK5
		LDA	ENWRKA,X		;CCWORK6 <- 横倍率
		LSR	A
		STA	CCWORK6
		LDA	MPACKOAM		;CCWORKF <- ＯＡＭセットしない数
		STA	CCWORKF

		LDA	ENDSXL,X		;ENDSXL
		STA	R1
		LDA	ENDSYL,X		;ENDSYL
		STA	R2
		LDA	ENMUKI,X
		STA	R8
		TXA				;(R10) <- ルーチンインデックス
		STA	R10			;
		LDA	#BANK MPACK_CHAR
		STA	R0
		LDY	<ENWRK4,X
		TYA
		ASL	A
		STA	R5
		LDA	#MPACK_CHAR_ADR
		STA	R14

		M_CHIP	M_MPACK_OAMSET

		LDX	<ENINDX

		LDA	R1
		STA	<EWORKC
		LDA	R2
		STA	<EWORKE

MPACK_O_SET0800 EQU	$

		RTS
;
MPACK_FACE_CX	EQU	$
;ENWRK4 =		 [0]	[1]    [2]    [3]    [4]    [5]
		WORD	00009H,00008H,00007H,00008H,0000CH,0000CH
;ENWRK4 =		 [6]	[7]    [8]    [9]    [A]    [B]
		WORD	00010H,0000FH,0000EH,00010H,0000FH,0000EH
MPACK_FACE_CY	EQU	$
		WORD	0FFDAH,0FFD1H,0FFD7H,0FFD8H,0FFD7H,0FFD6H
		WORD	0FFDAH,0FFD9H,0FFD7H,0FFDAH,0FFD9H,0FFD7H
;
MPACK_FACE_DAT	EQU	$
		LDA	<ENWRK4,X
		AND	#000FFH
		ASL	A
		TAY

		LDA	!MPACK_FACE_CY,Y
		CLC
		ADC	MPACKFCY
		CMP	#08000H
		ROR	A
		STA	MPACKFCY

		LDA	!MPACK_FACE_CX,Y
		LDY	ENMUKI,X
		BEQ	MPACK_F_DAT0700

		EOR	#0FFFFH
		INC	A

MPACK_F_DAT0700 EQU	$
		CLC
		ADC	MPACKFCX
		CMP	#08000H
		ROR	A
		STA	MPACKFCX

		RTS
;
MPACK_FACE_CHAR EQU	$
		WORD	CIPCHD+60E0H+001	;くちとじ
		WORD	CIPCHD+20A0H+001	;くち半あけ
		WORD	CIPCHD+60C0H+001	;くちあけ
		WORD	CIPCHD+20C0H+001	;ふりかえり
;
MPACK_ROT_SET	EQU	$
		LDY	<ENWRK5,X
		LDA	#BANK CIPCHD+20A0H+001	;chara data bank set
		STA	R13
		LDA	!MPACK_FACE_CHAR,Y	;chara data address set
		STA	R12

		LDY	<ENWRK0,X		;回転エリア転送する
		BMI	MPACK_R_SET0500		; yes: MPACK_R_SET0500

		LDA	ENWRKA,X		;(R6) <- 横倍率セット
		STA	R6			;

		LDA	ENWRK6,X		;(R11) <- 縦倍率セット
		STA	R11			;

		LDA	ENWRK8,X		;(R5) <- 回転角セット
		STA	R5			;

;		LDA	#00000			;回転エリアＸ　ＰＯＳ．セット
		STZ	R3			;
;		LDA	#00000			;回転エリアＹ　ＰＯＳ．セット
		STZ	R2			;

		M_CHIP	C_64_RZ_32_XY_0

		LDX	<ENINDX
		LDA	R10
		STA	MPACKDTX
		LDA	R11
		STA	MPACKDTY
		LDA	CCWORK0
		STA	MPACKDT0
		LDA	CCWORK1
		STA	MPACKDT1
		LDA	CCWORK2
		STA	MPACKDT2
		LDA	CCWORK3
		STA	MPACKDT3
		BRA	MPACK_R_SET0600

MPACK_R_SET0500 EQU	$
		LDA	MPACKDTX		;(R10) <- データＸ　ＰＯＳ．
		STA	R10
		LDA	MPACKDTY		;(R11) <- データＹ　ＰＯＳ．
		STA	R11
		LDA	MPACKDT0
		STA	CCWORK0
		LDA	MPACKDT1
		STA	CCWORK1
		LDA	MPACKDT2
		STA	CCWORK2
		LDA	MPACKDT3
		STA	CCWORK3

		LDA	#00064			;回転エリアＸ　ＰＯＳ．セット
		STA	R3			;
;		LDA	#00000			;回転エリアＹ　ＰＯＳ．セット
		STZ	R2			;

		M_CHIP	C_64_RZ_32_XY_1

		LDX	<ENINDX

		INC	OBM7WF			;mode 7 OBJ chara DMA "ON"

MPACK_R_SET0600 EQU	$
		LDA	<ENWRK0,X
		EOR	#000FFH
		STA	<ENWRK0,X

MPACK_ENCHK0000 EQU	$

		RTS
;
MPACK_ENCHK	EQU	$
		LDA	ENOAML,X		;ファーストフレーム ?
		BMI	MPACK_ENCHK0000		; yes: MPACK_ENCHK0000

;弱点チェック
		LDY	ECRSFG,X		;投げられた敵にあたった ?
		DEY				;
		BMI	MPACK_ENCHK0050		;
		LDA	ENMODE,Y		;
		CMP	#EMOVE			;
		BNE	MPACK_ENCHK0050		;
		LDA	ENSHOT,Y		;
		BNE	MPACK_ENCHK0080		;  no: MPACK_ENCHK1000

MPACK_ENCHK0050 EQU	$
		JMP	MPACK_ENCHK1000

MPACK_ENCHK0080 EQU	$
		LDA	ENTIM3,X		;無敵中 ?
		BEQ	MPACK_ENCHK0090		;  no:MPACK_ENCHK0090

MPACK_ENCHK0088 EQU	$
		JMP	MPACK_ENCHK0800		; yes: MPACK_ENCHK0800

MPACK_ENCHK0090 EQU	$
		LDA	ECENTX,Y		;前からあたってきた ?
		SEC				;
		SBC	ECENTX,X		;
		EOR	MPACKMUK		;
		BMI	MPACK_ENCHK0088		;  no: MPACK_ENCHK0088

		LDY	<ENWRK2,X
		CPY	#MPACK_RMODE41
		BMI	MPACK_ENCHK0100
		CPY	#MPACK_RMODE43+1
		BMI	MPACK_ENCHK0088
		CPY	#MPACK_RMODE51
		BMI	MPACK_ENCHK0100
		CPY	#MPACK_RMODE53+1
		BMI	MPACK_ENCHK0088

MPACK_ENCHK0100 EQU	$
		LDA	#00409H
		STA	<ENWRK4,X
		STZ	ENXSPD,X
		STZ	ENXPOW,X
		STZ	ENYSPD,X
		LDA	#0FFFFH			;無敵タイマーセット
		STA	ENTIM3,X		;

		LDA	MPACKDMG
		DEC	A
		ASL	A
		TAY
		LDA	!MPACK_S00_ATT,Y
		STA	MPACKATT
		STZ	MPACK_TIMER		;触手攻撃タイマークリア

		DEC	MPACKDMG		;まだまだいける ?
		BNE	MPACK_ENCHK0140		; yes: MPACK_ENCHK0140

		JSL	>BOSS_EN_CHANGE

		LDA	#00080H			;［Ｓ］
		PHA
		LDA	#MPACH_RMODE90
		LDY	#MPACK_RMODE90
		BRA	MPACK_ENCHK0180

MPACK_ENCHK0140 EQU	$
		LDA	#00078H			;［Ｓ］
		PHA
		LDA	#MPACH_RMODE80
		LDY	#MPACK_RMODE80

MPACK_ENCHK0180 EQU	$
		STA	<EWORK0
		STY	<EWORK2
		PLA
		JSL	>SOUND_3_ON
		LDX	#000			;触手のルーチンモードインデックスをセット
		LDY	MPACHLID		;
						;
MPACK_ENCHK0200 EQU	$			;
		LDA	ENWRK2,Y		;
		STA	MPACHLRI,X		;
		LDA	<EWORK0			;
		STA	ENWRK2,Y		;
						;
		CPY	MPACHLID		;
		BNE	MPACK_ENCHK0260		;
		INX				;
		INX				;
		LDY	MPACHRID		;
		BRA	MPACK_ENCHK0200		;

MPACK_ENCHK0260 EQU	$
		LDX	ENINDX
		LDY	<EWORK2
		STY	<ENWRK2,X
		STZ	ENTIM0,X
		LDA	#001FFH			;縦、横倍率初期化
		STA	ENWRK6,X		;
		STA	ENWRKA,X		;

MPACK_ENCHK0800 EQU	$
		LDY	ECRSFG,X
		TYX
		DEX
		JSL	>SHOT_EN_KILL

		LDA	#0000BH			;［Ｓ］
		JSL	>SOUND_3_ON

		RTS

MPACK_ENCHK1000 EQU	$
		TXA
		STA	R1
		M_CHIP	SHOTENSR
		LDX	<ENINDX
		LDY	R1
		BMI	MPACK_ENCHK1800

		LDA	ENMODE,Y
		CMP	#EMOVE
		BNE	MPACK_ENCHK1800
		LDA	ENSHOT,Y
		BNE	MPACK_ENCHK2000

MPACK_ENCHK1800 EQU	$

		RTS
;
MPACK_ENCHK2000 EQU	$
;頭ＶＳ敵
		LDA	ENYPSL,X
		CLC
		ADC	#00008
		SEC
		SBC	ECENTY,Y
		STA	<EWORKA

		LDA	ENXPSL,X
		CLC
		ADC	#00008
		SEC
		SBC	ECENTX,Y
		STA	<EWORK8
		CLC
		ADC	<EWORKC
		CLC
		ADC	#00018H
		CMP	#00030H
		BCS	MPACK_ENCHK3000

		LDA	<EWORKA
		CLC
		ADC	<EWORKE
		CLC
		ADC	#00018H
		CMP	#00030H
		BCS	MPACK_ENCHK3000

MPACK_ENCHK2800 EQU	$
		TYX
		JSL	>SHOT_EN_KILL

		LDA	#0000BH			;［Ｓ］
		JSL	>SOUND_3_ON
;;;;;;;;		LDA	#00003			;［Ｓ］
;;;;;;;;		STA	SOUND0

		RTS

MPACK_ENCHK3000 EQU	$
;茎ＶＳ敵
		LDA	<EWORK8			;
		CLC				;
		ADC	#00008			;
		CMP	#00010H			;
		BCS	MPACK_ENCHK4000		;

		LDA	<EWORKA			;
		SEC				;
		SBC	#00020H-00028H		;
		CMP	#00050H			;
		BCC	MPACK_ENCHK2800		;

MPACK_ENCHK4000 EQU	$

		RTS
;
MPACK_PLCHK	EQU	$
		LDY	<ENWRK2,X		;無敵中 ?
		CPY	#MPACK_RMODE80		;
		BPL	MPACK_PLCHK3000		; yes: MPACK_PLCHK3000

;頭ＶＳプレイヤー
		LDA	ENYPSL,X
		CLC
		ADC	#00008
		SEC
		SBC	PCENTY
		STA	<EWORKA

		LDA	ENXPSL,X
		CLC
		ADC	#00008
		SEC
		SBC	PCENTX
		STA	<EWORK8
		CLC
		ADC	<EWORKC
		CLC
		ADC	#00018H
		CMP	#00030H
		BCS	MPACK_PLCHK2000

		LDA	<EWORKA
		CLC
		ADC	<EWORKE
		CLC
		ADC	#00018H
		CMP	#00030H
		BCS	MPACK_PLCHK2000

MPACK_PLCHK1800 EQU	$
		JSL	>PLFLST

		RTS

MPACK_PLCHK2000 EQU	$
;茎ＶＳプレイヤー
		LDA	<EWORK8			;
		CLC				;
		ADC	#00008			;
		CMP	#00010H			;
		BCS	MPACK_PLCHK3000		;

		LDA	<EWORKA			;
		SEC				;
		SBC	#00020H-00028H		;
		CMP	#00050H			;
		BCC	MPACK_PLCHK1800		;

MPACK_PLCHK3000 EQU	$
MPACK_SUB00000	EQU	$

		RTS
;
MPACK_S00_XSPD	EQU	$
		WORD	00080H,0FF80H
;
;		00...触手 01...頭突き 10...綿毛 11...だまし
;
MPACK_S00_ATT	EQU	$-2
;		WORD	1011010110011001B	;２ダメージ
;		WORD	0100101101011001B	;１ダメージ
;		WORD	0001110001110101B	;ノーダメージ
		WORD	0110110101100101B	;２ダメージ
		WORD	1101100011101101B	;１ダメージ
		WORD	0110001011011001B	;ノーダメージ
;
MPACK_SUB00	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACK_SUB00000		; yes: MPACK_SUB00000

		LDA	ENTIM1,X		;ボディキャラパターンチェンジ ?
		BEQ	MPACK_SUB00100		; yes: MPACK_SUB00100
		JMP	MPACK_SUB00800		;  no: MPACK_SUB00800

MPACK_SUB00100	EQU	$
		LDY	<ENWRK4,X		;攻撃してもいいボディパターン ?
		BNE	MPACK_SUB00200		;  no: MPACK_SUB00200

		LDY	ENWRKC,X		;攻撃に移っていい ?
		BEQ	MPACK_SUB00300		; yes: MPACK_SUB00300

		DEC	ENWRKC,X

MPACK_SUB00200	EQU	$
		JMP	MPACK_SUB00700

MPACK_SUB00300	EQU	$
		LDY	MPACHLID		;触手もＯＫ ?
		LDA	ENWRK2,Y		;
		LDY	MPACHRID		;
		ORA	ENWRK2,Y		;
		BNE	MPACK_SUB00200		;  no: MPACK_SUB00200

MPACK_SUB00380	EQU	$
		LDA	MPACKATT		;攻撃方法データまだある ?
		INC	A			;
		BNE	MPACK_SUB00400		; yes: MPACK_SUB00400

		LDA	MPACKDMG
		ASL	A
		TAY
		LDA	!MPACK_S00_ATT,Y
		STA	MPACKATT

MPACK_SUB00400	EQU	$
		LDA	MPACKATT
		SEC				;頭突き攻撃する ?
		ROR	A			;
		BCC	MPACK_SUB00600		;  no: MPACK_SUB00600

		LDY	#MPACK_RMODE40
		SEC				;だまし ?
		ROR	A			;
		BCS	MPACK_SUB00500		; yes: MPACK_SUB00500

		LDY	#MPACK_RMODE50

MPACK_SUB00500	EQU	$
		STY	<ENWRK2,X
		STA	MPACKATT
		LDY	ENMUKI,X		;
		LDA	!MPACK_S00_XSPD,Y	;
		STA	ENXSPD,X		;
		LDA	#00006			;
		STA	<ENWRK4,X		;
		LDA	#00040H			;
		STA	ENYSPD,X		;

MPACH_DUSH_INIT EQU	$
		LDY	MPACHLID		;触手の攻撃モードセット
		LDA	#0FFFFH			;
		STA	ENCONT,Y		;
		LDA	#MPACH_RMODE20		;
		STA	ENWRK2,Y		;
		LDY	MPACHRID		;
		STA	ENWRK2,Y		;
		LDA	#0FFFFH			;
		STA	ENCONT,Y		;

		RTS

MPACK_SUB00600	EQU	$
		SEC				;綿毛攻撃
		ROR	A			;
		BCS	MPACK_SUB00680		; yes: MPACK_SUB00680

		STA	MPACKATT

;;;;;;;;		LDA	#P_KUN			;プチぱっくんいる ?
;;;;;;;;		STA	R4			;
;;;;;;;;		INC	A			;
;;;;;;;;		STA	R5			;
;;;;;;;;		M_CHIP	TARGET_COUNTER		;
;;;;;;;;		LDX	<ENINDX			;
;;;;;;;;		LDY	R6			;
;;;;;;;;		BNE	MPACK_SUB00380		; yes: MPACK_SUB00380

		LDA	#040H*(10H+3)		;攻撃時間セット
		STA	MPACK_TIMER
		STZ	<ENWRK4,X		;ボディ＆フェイスキャラパターンインデックスクリア
		LDY	#MPACK_RMODE30
		STY	<ENWRK2,X

		LDY	MPACHLID		;触手の触手攻撃イニシャル
		LDA	#00040H			;
		STA	ENTIM0,Y		;
		LDA	#MPACH_RMODE30		;
		STA	ENWRK2,Y		;
		LDY	MPACHRID		;
		STA	ENWRK2,Y		;
		LDA	#00040H*3		;
		STA	ENTIM0,Y		;

		RTS

MPACK_SUB00680	EQU	$
		STA	MPACKATT

		LDY	#000			;フェイスキャラパターンインデックスセーブ
		STY	<ENWRK5,X
		LDA	#00010H
		STA	ENTIM0,X
		LDY	#MPACK_RMODE20
		STY	<ENWRK2,X

		RTS

MPACK_SUB00700	EQU	$
		JSR	MPACK_KUNE_KUNE

MPACK_SUB00800	EQU	$
		JSR	MPACK_FACE_CHG

		LDY	EPXMUK,X
		TYA
		CMP	ENMUKI,X
		BEQ	MPACK_SUB00A00

		STZ	MPACKRID
		LDY	#MPACK_RMODE60
		STY	<ENWRK2,X

MPACK_SUB00A00	EQU	$

		RTS
;
MPACK_S00_CHPT	EQU	$
		HEX	00,01,02,01
;
MPACK_KUNE_KUNE EQU	$
		LDA	ENTIM1,X
		BNE	MPACK_K_K0800

		LDA	<ENCONT+1,X
		INC	A
		AND	#0FF03H
		STA	<ENCONT+1,X
		TAY
		LDA	!MPACK_S00_CHPT,Y
		TAY
		STY	<ENWRK4,X

		LDA	#00008
		STA	ENTIM1,X

MPACK_K_K0800	EQU	$

		RTS
;
MPACK_S00_F_CPT EQU	$
		HEX	00,02,04,02
;
MPACK_FACE_CHG	EQU	$
		LDA	ENTIM2,X
		BNE	MPACK_F_C0800

		LDA	<ENCONT,X
		INC	A
		AND	#0FF03H
		STA	<ENCONT,X
		TAY
		LDA	!MPACK_S00_F_CPT,Y
		TAY
		STY	<ENWRK5,X
		CPY	#004			;口開けポーズ ?
		BNE	MPACK_F_C0500		;  no: MPACK_F_C0500

		LDA	#0007BH			;［Ｓ］
		JSL	>SOUND_3_ON

MPACK_F_C0500	EQU	$
		LDA	<RANDM0
		AND	#00006
		CLC
		ADC	#00004
		STA	ENTIM2,X

MPACK_F_C0800	EQU	$

		RTS
;
MPACK_SUB07	EQU	$
		TYX

		LDY	BOSS0FLG		;登場してもいい ?
		CPY	#002			;
		BPL	MPACK_SUB07100		; yes: MPACK_SUB07100

;		LDY	ZPACKIDX
;		LDA	ENMODE,Y		;ZPACK生きてる ?
;		CMP	#EMOVE			;
;		BEQ	MPACK_SUB07020		;
;
		LDY	ZPACKIDX
		LDA	ENWRK2,Y		;ZPACK生きてる ?
		CMP	#MPACK_DEMO_ED		;
		BNE	MPACK_SUB07020		; yes: MPACK_SUB07020

		LDA	#PDEM
		STA	PLMODE
;
		LDA	ENXPSL,Y
		STA	<EWORK0

		LDA	#KAMCS
		JSL	>ENINSR
		LDA	ESCCH1
		CLC
		ADC	#00140H
		STA	ENXPSL,Y
		LDA	ESCCV1
		CLC
		ADC	#00040H
		STA	ENYPSL,Y
		LDA	#0FC00H
		STA	ENXSPD,Y
		LDA	#00010H
		STA	ENXPOW,Y
		LDA	<EWORK0
		STA	ENWRK4,Y
		JSL	>BOSS_EN_CHANGE
		STZ	TROBJ_ARIA
		PLA
		JMP	>ENCLEAR_NORETN
;
;
;
;		LDA	ENXPSL,Y
;		STA	<EWORK0
;		LDA	ENYPSL,Y
;		STA	<EWORK2
;		JSL	>BSCLW_SET_B
;		JSL	>BOSS_EN_CHANGE
;		STZ	TROBJ_ARIA
;		PLA
;		JMP	>ENCLEAR_NORETN
;
MPACK_SUB07020	EQU	$
		STZ	ATSCRL_H
		LDA	#002B0H
		CMP	SCCH1
		BPL	MPACK_SUB07040

		INC	A
		STA	ATSCRL_SCCH1
		INC	ATSCRL_H

MPACK_SUB07040	EQU	$

		RTS

MPACK_SUB07100	EQU	$
		JSL	>TROBJ_CANCEL
		STZ	ENTROB,X
		JSR	MPACH_SET

		STZ	ENMUKI,X

		LDA	#000C0H			;ストップタイマーセット
		STA	ENTIM0,X		;

		LDA	#MPACK_RMODE10
		STA	<ENWRK2,X

		LDA	#0110001011011001B	;攻撃方法データセット
		STA	MPACKATT		;
		LDA	#00001H
		STA	ENWRKC,X
;;;;;;;;		LDA	#00001
		STA	ENYUSN,X
;;;;;;;;		LDA	#00016H			;［Ｓ］
;;;;;;;;		STA	SOUND2

		RTS
;
MPACH_SET	EQU	$
		LDA	#00002
		STA	<EWORK0

		LDA	#MPACH_I_XPOS
		STA	<EWORK2

		LDA	#MPACHLID
		STA	<EWORK4

MPACH_SET0100	EQU	$
		LDA	#MPACH
		JSL	>ENINSR

		LDA	(EWORK2)
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,Y
		LDA	ENYPSL,X
		STA	ENYPSL,Y
		LDA	#00000
		STA	ENCHPT,Y
		STA	ENXSPD,Y
		LDA	#0FF80H
		STA	ENYSPD,Y
		LDA	#MPACH_RMODE18
		STA	ENWRK2,Y

		TYA
		STA	(EWORK4)

		JSR	MPACW_SET

		INC	<EWORK2
		INC	<EWORK2
		INC	<EWORK4
		INC	<EWORK4

		DEC	<EWORK0
		BNE	MPACH_SET0100

		RTS
;
MPACW_SET	EQU	$
		LDA	#MPACW
		JSL	>ENINSR

		LDA	ENXPSL,X
		STA	ENXPSL,Y
		LDA	ENYPSL,X
		CLC
		ADC	#00010H-60H
		STA	ENYPSL,Y
		LDA	#00005
		STA	ENWRK2,Y

		LDA	(EWORK4)
		STA	ENWRK0,Y

		RTS
;
MPACK_SUB10	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACK_SUB10800		; yes: MPACK_SUB10800

		LDA	#0FFC0H
		STA	ENYSPD,X

		LDA	MPACKYLW
		CMP	ENYPSL,X
		BMI	MPACK_SUB10800

		STA	ENYPSL,X
		STZ	ENYSPD,X
		STZ	<ENWRK4,X
		INC	<ENWRK2,X

MPACK_SUB10800	EQU	$

		RTS
;
MPACK_S11_ARV	EQU	$
MPACK_S11_ANG	EQU	$
		WORD	0FFFCH,00004H
MPACK_S11_FWD	EQU	$
		WORD	0FFFFH,00001H
;
MPACK_SUB11	EQU	$
MPACK_SUB14	EQU	$
MPACK_SUB24	EQU	$
MPACK_SUB44	EQU	$
MPACK_SUB47	EQU	$
MPACK_SUB54	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BEQ	MPACK_SUB11000
		JMP	MPACK_SUB11B00		; yes: MPACK_SUB11B00

MPACK_SUB11000	EQU	$
		LDA	ENTIM2,X		;フェイスキャラパターンチェンジ ?
		BNE	MPACK_SUB11080		;  no: MPACK_SUB11080

		M8
		LDA	<ENWRK5,X
		LSR	A
		AND	#0FEH
		STA	<ENWRK5,X
		M16

		LDA	#00004
		STA	ENTIM2,X

MPACK_SUB11080	EQU	$
		LDY	#004
		STY	<EWORK0

		LDY	#000
		LDA	MPACKARV
		SEC
		SBC	#0FFC0H-00004H
		CMP	#00008
		BCS	MPACK_SUB11100

		DEC	<EWORK0
		LDA	#0FFC0H
		BRA	MPACK_SUB11300

MPACK_SUB11100	EQU	$
		BPL	MPACK_SUB11200

		INY
		INY

MPACK_SUB11200	EQU	$
		LDA	MPACKARV
		CLC
		ADC	!MPACK_S11_ARV,Y

MPACK_SUB11300	EQU	$
		STA	MPACKARV

		LDY	#000
		LDA	MPACKFWD
		SEC
		SBC	#00024H-00001
		CMP	#00002
		BCS	MPACK_SUB11400

		DEC	<EWORK0
		LDA	#00024H
		BRA	MPACK_SUB11600

MPACK_SUB11400	EQU	$
		BPL	MPACK_SUB11500

		INY
		INY

MPACK_SUB11500	EQU	$
		LDA	MPACKFWD
		CLC
		ADC	!MPACK_S11_FWD,Y

MPACK_SUB11600	EQU	$
		STA	MPACKFWD

		LDY	#000
		LDA	ENWRK8,X		;頭回転
		CLC				;
		ADC	#00004			;
		CMP	#00008			;
		BCS	MPACK_SUB11700		;
						;
MPACK_SUB11680	EQU	$			;
		DEC	<EWORK0			;
		LDA	#00000			;
		BRA	MPACK_SUB11900		;
						;
MPACK_SUB11700	EQU	$			;
		CMP	#00100H-00004		;
		BMI	MPACK_SUB11800		;
						;
		INY				;
		INY				;
						;
MPACK_SUB11800	EQU	$			;
		LDA	ENWRK8,X		;
		CLC				;
		ADC	!MPACK_S11_ANG,Y	;
		AND	#001FEH			;
						;
MPACK_SUB11900	EQU	$			;
		STA	ENWRK8,X		;

		LDA	#0FFC0H
		STA	ENYSPD,X
		LDA	MPACKYLW		;元の高さに戻る
		CMP	ENYPSL,X		;
		BMI	MPACK_SUB11980		;
						;
		STA	ENYPSL,X		;
		STZ	ENYSPD,X		;
		DEC	<EWORK0			;
						;
MPACK_SUB11980	EQU	$
		LDY	<EWORK0
		BNE	MPACK_SUB11B00

		LDY	<ENWRK2,X
		CPY	#MPACK_RMODE44		;だまし攻撃 ?
		BEQ	MPACK_SUB11A80		; yes: MPACK_SUB11A80
		CPY	#MPACK_RMODE11		;デモ中 ?
		BEQ	MPACK_SUB11A00		; yes: MPACK_SUB11A80
		CPY	#MPACK_RMODE14		;デモ中 ?
		BNE	MPACK_SUB11990		;  no: MPACK_SUB11990

		STZ	ATSCRL_H
		STZ	PLMODE

MPACK_SUB11990	EQU	$
		STZ	<ENCONT,X
		LDA	#00003
		STA	ENWRKC,X
		STZ	<ENWRK2,X

		RTS

MPACK_SUB11A00	EQU	$
		LDA	#00040H
		STA	ENTIM0,X

MPACK_SUB11A80	EQU	$
		INC	<ENWRK2,X

		RTS

MPACK_SUB11B00	EQU	$
		LDY	<ENWRK2,X
		CPY	#MPACK_RMODE54
		BNE	MPACK_SUB11C00

		LDA	ENXSPD,X
		CLC
		ADC	#00040H
		CMP	#00080H
		BCS	MPACK_SUB11C00

		STZ	ENXSPD,X
		STZ	ENXPOW,X

MPACK_SUB11C00	EQU	$

		RTS
;
MPACK_SUB20	EQU	$
		LDA	#001A0H
		BRA	MPACK_SUB20000

MPACK_SUB12	EQU	$
MPACK_SUB45	EQU	$
MPACK_SUB80	EQU	$
MPACK_SUB90	EQU	$
		LDA	#001C0H

MPACK_SUB20000	EQU	$
		STA	<EWORK2
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACK_SUB20800		; yes: MPACK_SUB20800

		LDY	#002
		STY	<EWORK0

		LDA	MPACKARV		;回転角の補正値計算
		CLC				;
		ADC	#00008			;
		CMP	#0FFE0H			;
		BMI	MPACK_SUB20100		;
						;
		DEC	<EWORK0			;
		LDA	#0FFE0H			;
						;
MPACK_SUB20100	EQU	$			;
		STA	MPACKARV		;

		LDA	MPACKFWD		;
		CLC				;
		ADC	#00026H			;
		INC	A			;
		LSR	A			;
		STA	MPACKFWD		;

		LDA	ENWRK8,X		;頭の回転角計算
		SEC				;
		SBC	#00010H			;
		AND	#001FEH			;
		CMP	<EWORK2			;
		BPL	MPACK_SUB20500		;
						;
		DEC	<EWORK0			;
		LDA	<EWORK2			;
						;
MPACK_SUB20500	EQU	$			;
		STA	ENWRK8,X		;

		LDY	<EWORK0
		BNE	MPACK_SUB20800

		STZ	<ENCONT,X
		LDA	#00004			;口ぱく回数セット
		LDY	<ENWRK2,X		;
		CPY	#MPACK_RMODE90		;	;ラストダメージ中 ?
		BNE	MPACK_SUB20600		;	;  no: MPACK_SUB20700
						;
		LDA	#00001H			;
		BRA	MPACK_SUB20700		;
						;
MPACK_SUB20600	EQU	$			;
		CPY	#MPACK_RMODE12		;	;イニシャルデモの高笑い ?
		BNE	MPACK_SUB20700		;	;  no: MPACK_SUB12700
						;
		LDA	#0000CH			;
						;
MPACK_SUB20700	EQU	$			;
		STA	ENWRKC,X		;
		INC	<ENWRK2,X

MPACK_SUB20800	EQU	$

		RTS
;
MPACK_SUB21	EQU	$
		TYX

		LDA	ENWRKA,X		;縮み終わった ?
		SEC				;
		SBC	#00010H			;
		CMP	#0017FH+1		;
		BPL	MPACK_SUB21500		;  no: MPACK_SUB21500

		LDA	#00008H			;ストップタイマーセット
		STA	ENTIM0,X		;
		INC	<ENWRK2,X
		LDA	#0017FH

MPACK_SUB21500	EQU	$
		STA	ENWRKA,X

MPACK_SUB22000	EQU	$

		RTS
;
MPACK_S22_XSPD	EQU	$-2
		WORD	0FF38H,0FE78H,0FDC8H
MPACK_S22_YSPD	EQU	$-2
		WORD	0FC14H,0FC4CH,0FCACH
;
MPACK_SUB22	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACK_SUB22000		; yes: MPACK_SUB22000

		LDA	ENWRKA,X		;元に戻った ?
		CLC				;
		ADC	#00010H			;
		CMP	#001FFH			;
		BMI	MPACK_SUB22800		;  no: MPACK_SUB22800

		LDA	ENXPSL,X
		CLC
		ADC	<EWORKC
		STA	<EWORK0
		LDA	ENYPSL,X
		CLC
		ADC	<EWORKE
		STA	<EWORK2

		LDA	#00083H			;［Ｓ］
		JSL	>SOUND_3_ON

		LDA	#00003*2
		STA	<EWORKA

MPACK_SUB22300	EQU	$
		LDY	<EWORKA
		LDA	!MPACK_S22_YSPD,Y
		STA	<EWORK8
		LDA	!MPACK_S22_XSPD,Y
		LDY	ENMUKI,X
		BEQ	MPACK_SUB22400

		EOR	#0FFFFH
		INC	A

MPACK_SUB22400	EQU	$
		STA	<EWORK6

		LDA	#P_KUN
		JSL	>ENINSR
		BCC	MPACK_SUB22700

		LDA	<EWORK0
		STA	ENXPSL,Y
		LDA	<EWORK2
		STA	ENYPSL,Y
		LDA	<EWORK6
		STA	ENXSPD,Y
		LDA	<EWORK8
		STA	ENYSPD,Y
		LDA	#00001
		STA	ENWRK6,Y
		ASL	A
		ASL	A
;;;;;;;;		LDA	#00004
		STA	ENCONT,Y
		STA	ENXPOW,Y
		LDA	ENMOD2,Y		;範囲クリアなし
		AND	#0FFF3H
		STA	ENMOD2,Y

		DEC	<EWORKA
		DEC	<EWORKA
		BNE	MPACK_SUB22300

MPACK_SUB22700	EQU	$
		LDA	#00010H
		STA	ENTIM0,X
		INC	<ENWRK2,X
		LDA	#001FFH

MPACK_SUB22800	EQU	$
		STA	ENWRKA,X
		LDY	#000			;フェイスキャラパターンインデックスセット
		CMP	#001B0H			;
		BMI	MPACK_SUB22900		;
		LDY	#002			;
		CMP	#001E0H			;
		BMI	MPACK_SUB22900		;
						;
		LDY	#004			;
						;
MPACK_SUB22900	EQU	$			;
		STY	<ENWRK5,X		;

		RTS
;
MPACK_SUB23	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACK_SUB23800		; yes: MPACK_SUB23800

		LDY	#000			;フェイスキャラパターンインデックスセット
		STY	<ENWRK5,X		;
		LDA	#00100H
		STA	ENTIM0,X
		INC	<ENWRK2,X

MPACK_SUB23800	EQU	$

		RTS
;
MPACK_SUB30	EQU	$
		TYX

		LDY	MPACHLID		;攻撃終わった ?
		LDA	ENWRK2,Y		;
		LDY	MPACHRID		;
		ORA	ENWRK2,Y		;
		BNE	MPACK_SUB30500		;  no: MPACK_SUB30500

		LDA	#00003
		STA	ENWRKC,X
		STZ	<ENWRK2,X

		RTS

MPACK_SUB30500	EQU	$
		JSR	MPACK_KUNE_KUNE

		JSR	MPACK_FACE_CHG

		LDY	EPXMUK,X		;プレイヤーに背後をとられた ?
		TYA				;
		CMP	ENMUKI,X		;
		BEQ	MPACK_SUB30800		;  no: MPACK_SUB30800

		LDY	#MPACK_RMODE30		;ボディーの振り返り処理の後のリターンルーチンモードインデックス
		STY	MPACKRID		;
		LDY	#MPACK_RMODE60
		STY	<ENWRK2,X

MPACK_SUB30800	EQU	$

		RTS
;
MPACK_SUB42	EQU	$
		TYX

		LDA	ENXSPD,X		;止まった ?
		CLC				;
		ADC	#00018H			;
		CMP	#00030H			;
		BCS	MPACK_SUB42800		;  no: MPACK_SUB42800

		STZ	ENXPOW,X
		STZ	ENXSPD,X
		LDA	#00040H
		STA	ENTIM0,X
		INC	<ENWRK2,X

		RTS

MPACK_SUB42800	EQU	$
		JSR	MPACK_SUB51400

		RTS
;
MPACK_S43_XMAX	EQU	$
		WORD	00100H,0FF00H
		WORD	00200H,0FE00H
MPACK_S43_XLIM	EQU	$
		WORD	003B0H,002E0H
;
MPACK_SUB43	EQU	$
		TYX

		LDA	ENTIM0,X
		BNE	MPACK_SUB43800

		LDY	ENMUKI,X
		TYA
		DEC	A
		EOR	EPWIDX,X
		BMI	MPACK_SUB43300

		TYA
		CLC
		ADC	#00004
		TAY

MPACK_SUB43300	EQU	$
		LDA	!MPACK_S43_XMAX,Y
		STA	ENXMAX,X
		LDA	#00008H
		STA	ENXPOW,X
		LDY	ENMUKI,X
		LDA	ENXPSL,X		;後退移動
		SEC				;
		SBC	!MPACK_S43_XLIM,Y	;
		STA	<EWORK2			;
		TYA				;
		DEC	A			;
		EOR	<EWORK2			;
		BPL	MPACK_SUB43800		;
						;
MPACK_SUB43500	EQU	$			;
		LDA	!MPACK_S43_XLIM,Y	;
		STA	ENXPSL,X		;
		STZ	ENXSPD,X		;
		STZ	ENXPOW,X		;
						;
		INC	<ENWRK2,X

MPACK_SUB43800	EQU	$

		RTS
;
MPACK_S46_CHPT	EQU	$
		WORD	00009H,0020AH,0040BH,0020AH
;
MPACK_SUB13	EQU	$
MPACK_SUB46	EQU	$
MPACK_SUB81	EQU	$
MPACK_SUB91	EQU	$
		TYX

		LDA	ENTIM1,X		;本体パターンチェンジ ?
		BNE	MPACK_SUB46800		;  no: MPACK_SUB46800

		LDA	#00004
		STA	ENTIM1,X
		LDA	<ENCONT,X
		INC	A
		INC	A
		AND	#00006H
		STA	<ENCONT,X
		TAY
		LDA	!MPACK_S46_CHPT,Y
		STA	<ENWRK4,X
		CPY	#004			;口を開けたポーズ ?
		BNE	MPACK_SUB46800		;  no: MPACK_SUB46800

		LDA	#0007BH			;［Ｓ］
		JSL	>SOUND_3_ON

		DEC	ENWRKC,X		;ぱくぱく終わり ?
		BNE	MPACK_SUB46800		;  no: MPACK_SUB46800

		INC	<ENWRK2,X
		LDY	<ENWRK2,X		;だまし攻撃 ?
		CPY	#MPACK_RMODE46+1	;
		BEQ	MPACK_SUB46800		; yes: MPACK_SUB46800

		LDA	#00040H*2		;イニシャルデモ ?
		CPY	#MPACK_RMODE13+1	;
		BEQ	MPACK_SUB46700		; yes: MPACK_SUB46700

		CPY	#MPACK_RMODE91+1	;ラストダメージ中 ?
		BNE	MPACK_SUB46600		;  no: MPACK_SUB46600

		LDA	#0001BH
		STA	<ENCONT,X

MPACK_SUB46600	EQU	$
		LDA	#00040H

MPACK_SUB46700	EQU	$
		STA	ENTIM0,X

MPACK_SUB46800	EQU	$

		RTS
;
MPACK_S50_XLIM	EQU	$
		WORD	003B0H,002E0H
;
MPACK_SUB40	EQU	$
MPACK_SUB50	EQU	$
MPACK_SUB83	EQU	$
		TYX

		LDY	#005
		STY	<EWORK0

		LDA	MPACKARV		;頭の位置計算用回転角補正値計算
		SEC				;
		SBC	#00004			;
		CMP	#0FF80H+1		;	;終わり ?
		BPL	MPACK_SUB50100		;	;  no: MPACK_SUB50100
						;
		DEC	<EWORK0			;
		LDA	#0FF80H			;
						;
MPACK_SUB50100	EQU	$			;
		STA	MPACKARV		;

		LDA	MPACKFWD		;頭の付け根から頭の中心までの距離計算
		DEC	A			;
		CMP	#0001CH+1		;	;終わり ?
		BPL	MPACK_SUB50200		;	;  no: MPACK_SUB50200
						;
		DEC	<EWORK0			;
		LDA	#0001CH			;
						;
MPACK_SUB50200	EQU	$			;
		STA	MPACKFWD		;

		LDA	ENWRK8,X		;頭回転角計算
		CLC				;
		ADC	#00004H			;
		CMP	#00070H			;	;終わり ?
		BMI	MPACK_SUB50300		;	;  no: MPACK_SUB50300
						;
		DEC	<EWORK0			;
		LDA	#00070H			;
						;
MPACK_SUB50300	EQU	$			;
		STA	ENWRK8,X		;

;		LDA	ENMUKI,X
;		LDY	<ENWRK2,X
;		CPY	#MPACK_RMODE40
;		BNE	MPACK_SUB50400
;
;		CLC
;		ADC	#00004
;
;MPACK_SUB50400 EQU	$
;		TAY

		LDY	ENMUKI,X
		LDA	ENXSPD,X		;移動終わってる ?
		BEQ	MPACK_SUB50500		; yes: MPACK_SUB50500

		LDA	ENXPSL,X		;後退移動
		SEC				;
		SBC	!MPACK_S50_XLIM,Y	;
		STA	<EWORK2			;
		TYA				;
		DEC	A			;
		EOR	<EWORK2			;
		BPL	MPACK_SUB50600		;
						;
MPACK_SUB50500	EQU	$			;
		DEC	<EWORK0			;
		LDA	!MPACK_S50_XLIM,Y	;
		STA	ENXPSL,X		;
		STZ	ENXSPD,X		;
						;
MPACK_SUB50600	EQU	$
		LDA	MPACKYLW		;少し沈み込む
		CLC				;
		ADC	#00010H			;
		CMP	ENYPSL,X		;
		BPL	MPACK_SUB50700		;
						;
		INC	A			;
		STA	ENYPSL,X		;
		STZ	ENYSPD,X		;
		DEC	<EWORK0			;

MPACK_SUB50700	EQU	$
		LDY	<EWORK0			;準備ＯＫ ?
		BNE	MPACK_SUB50800		;  no: MPACK_SUB50800

		LDY	<ENWRK2,X		;ダメージ後 ?
		CPY	#MPACK_RMODE83		;
		BEQ	MPACK_SUB50900		; yes: MPACK_SUB50900

		INC	<ENWRK2,X

MPACK_DUSH_INIT EQU	$
		STZ	<ENCONT,X
		STZ	ENWRKC,X
		LDA	#00020H			;ダッシュまでのストップタイマーセット
		STA	ENTIM0,X

MPACK_SUB50800	EQU	$

		RTS
;
MPACK_SUB50900	EQU	$
		LDA	ENCLOR,X		;カラー固定
		AND	#0FFF0H			;
		ORA	#0000CH			;
		STA	ENCLOR,X		;
		STZ	ENTIM3,X		;無敵タイマークリア

		LDY	MPACHLID		;触手もＯＫ ?
		LDA	ENWRK2,Y		;
		LDY	MPACHRID		;
		ORA	ENWRK2,Y		;
		BNE	MPACK_SUB50800		;  no: MPACK_SUB50800

		LDY	#MPACK_RMODE51
		STY	<ENWRK2,X
		JSR	MPACK_DUSH_INIT
		JMP	MPACH_DUSH_INIT
;
MPACK_S51_XMAX	EQU	$
		WORD	0FD00H,00300H
MPACK_S51_CHPT	EQU	$
		HEX	06,07,08,07
MPACK_S51_XLIM	EQU	$
		WORD	002E8H,003A4H
MPACK_S51_P	EQU	$
		WORD	MPACK_P_PACK0
		WORD	MPACK_P_PACK1
		WORD	MPACK_P_PACK2
		WORD	MPACK_P_PACK3
MPACK_P_PACK0	EQU	$
		WORD	00010H,00040H,00080H,000B0H
		WORD	0FFF0H,0FFE0H,0FFE8H,0FFD0H
MPACK_P_PACK1	EQU	$
		WORD	00010H,00040H,00080H,000B0H
		WORD	0FFF0H,0FFE0H,0FFE8H,0FFD0H
MPACK_P_PACK2	EQU	$
		WORD	00010H,00040H,00080H,000B0H
		WORD	0FFF0H,0FFE0H,0FFE8H,0FFD0H
MPACK_P_PACK3	EQU	$
		WORD	00010H,00040H,00080H,000B0H
		WORD	0FFF0H,0FFE0H,0FFE8H,0FFD0H
MPACK_S51_XSPD	EQU	$
		WORD	00100H,0FF00H
;
MPACK_SUB41	EQU	$
MPACK_SUB51	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACK_SUB51300		; yes: MPACK_SUB51300

		LDY	ENMUKI,X
		LDA	!MPACK_S51_XMAX,Y
		STA	ENXMAX,X
		LDA	#00010H
		STA	ENXPOW,X

		LDA	ENTIM1,X		;本体キャラパターンチェンジ ?
		BNE	MPACK_SUB51300		;  no: MPACK_SUB51300

		LDA	<ENCONT,X
		INC	A
		AND	#00003
		STA	<ENCONT,X
		TAY
		LDA	!MPACK_S51_CHPT,Y
		TAY
		STY	<ENWRK4,X

		LDA	#00008H
		STA	ENTIM1,X

MPACK_SUB51300	EQU	$
		LDY	<ENWRK2,X		;だまし ?
		CPY	#MPACK_RMODE51		;
		BEQ	MPACK_SUB51400		;  no: MPACK_SUB51400

		LDA	ENXPSL,X		;画面の中央まで来た ?
		SEC				;
		SBC	#00350H-30H		;
		CMP	#00060H			;
		BCS	MPACK_SUB51400		;  no: MPACK_SUB51400

		STZ	ENXMAX,X
		LDA	#00018H
		STA	ENXPOW,X
		INC	<ENWRK2,X

		RTS

MPACK_SUB51400	EQU	$
		LDY	ENMUKI,X		;壁にぶつかった ?
		LDA	ENXPSL,X		;
		SEC				;
		SBC	!MPACK_S51_XLIM,Y	;
		STA	<EWORK2			;
		TYA				;
		DEC	A			;
		EOR	<EWORK2			;
		BMI	MPACK_SUB51450		;  no: MPACK_SUB51450

		LDA	!MPACK_S51_XLIM,Y
		STA	ENXPSL,X
		LDY	#006
		STY	<ENWRK4,X

		LDA	ENXSPD,X
		CLC
		ADC	#00100H
		CMP	#00200H
		BCS	MPACK_SUB51480

		LDA	#00040H
		STA	ENTIM0,X
		LDY	ENMUKI,X
		LDA	!MPACK_S51_XSPD,Y
		STA	ENXSPD,X
		LDA	#00008H
		STA	ENXPOW,X
		LDY	#MPACK_RMODE54
		STY	<ENWRK2,X

MPACK_SUB51450	EQU	$

		RTS

MPACK_SUB51480	EQU	$
		STZ	ENXPOW,X
		STZ	ENXSPD,X
		LDA	#00047H			;［Ｓ］
		JSL	>SOUND_3_ON
;;;;;;;;		LDA	#00016H			;［Ｓ］
;;;;;;;;		STA	SOUND3
		LDA	#00020H
		STA	TILTCT2
		LDY	#MPACK_RMODE52
		STY	<ENWRK2,X

;;;;;;;;		LDA	#P_KUN
;;;;;;;;		STA	R4
;;;;;;;;		INC	A
;;;;;;;;		STA	R5
;;;;;;;;		M_CHIP	TARGET_COUNTER
;;;;;;;;		LDX	<ENINDX
;;;;;;;;		LDA	#00004H
;;;;;;;;		SEC
;;;;;;;;		SBC	R6
;;;;;;;;		STA	<EWORK0
;;;;;;;;		BEQ	MPACK_SUB51800
;;;;;;;;
;;;;;;;;		LDA	<RANDM0
;;;;;;;;		AND	#00006
;;;;;;;;		TAY
;;;;;;;;		LDA	!MPACK_S51_P,Y
;;;;;;;;		STA	<EWORK2
;;;;;;;;		CLC
;;;;;;;;		ADC	#00002*4
;;;;;;;;		STA	<EWORK4
;;;;;;;;
;;;;;;;;MPACK_SUB51500	EQU	$
;;;;;;;;		LDA	#P_KUN
;;;;;;;;		JSL	>ENINSR_I
;;;;;;;;		BCC	MPACK_SUB51800
;;;;;;;;
;;;;;;;;		LDA	(EWORK2)
;;;;;;;;		CLC
;;;;;;;;		ADC	ESCCH1
;;;;;;;;		STA	ENXPSL,Y
;;;;;;;;		LDA	(EWORK4)
;;;;;;;;		CLC
;;;;;;;;		ADC	ESCCV1
;;;;;;;;		STA	ENYPSL,Y
;;;;;;;;		LDA	#00001
;;;;;;;;		STA	ENWRK6,Y
;;;;;;;;
;;;;;;;;		INC	<EWORK2
;;;;;;;;		INC	<EWORK2
;;;;;;;;		INC	<EWORK4
;;;;;;;;		INC	<EWORK4
;;;;;;;;
;;;;;;;;		DEC	<EWORK0
;;;;;;;;		BNE	MPACK_SUB51500

MPACK_SUB51800	EQU	$

		RTS
;
MPACK_SUB52	EQU	$
		TYX

		LDA	ENWRK6,X
		SEC
		SBC	#00060H
		CMP	#00140H
		BPL	MPACK_SUB52300

		INC	<ENWRK2,X
		LDA	#00140H

MPACK_SUB52300	EQU	$
		STA	ENWRK6,X
		LSR	A
		STA	R6
		LDA	#00018H
		STA	R0
		M_CHIP	MULTIPLY
		LDX	<ENINDX
		LDA	#00018H
		SEC
		SBC	R0
		LDY	ENMUKI,X
		BNE	MPACK_SUB52500

		EOR	#0FFFFH
		INC	A

MPACK_SUB52500	EQU	$
		ASL	A
		CLC
		ADC	!MPACK_S51_XLIM,Y
		STA	ENXPSL,X

		RTS
;
MPACK_S53_XSPD	EQU	$
		WORD	00200H,0FE00H
;
MPACK_SUB53	EQU	$
		TYX

		LDA	ENWRK6,X
		CLC
		ADC	#00040H
		CMP	#001FFH
		BMI	MPACK_SUB52300

		LDY	ENMUKI,X
		LDA	!MPACK_S53_XSPD,Y
		STA	ENXSPD,X
		LDA	#00010H
		STA	ENXPOW,X
		ASL	A
		ASL	A
;;;;;;;;		LDA	#00040H
		STA	ENTIM0,X
		INC	<ENWRK2,X
		LDA	#001FFH
		BRA	MPACK_SUB52300
;
MPACK_SUB60	EQU	$
		TYX

		LDA	<ENWRK4,X		;パターン待ち終わり ?
		BNE	MPACK_SUB60300		;  no: MPACK_SUB60300

		STZ	<ENCONT,X
		LDA	#00003
		STA	ENTIM1,X
		INC	A	;[ LDA	#00004H ]
		STA	<ENWRK4,X
		INC	<ENWRK2,X

		RTS

MPACK_SUB60300	EQU	$
		LDY	<ENWRK4,X		;本体のパターン合ってる ?
		BEQ	MPACK_SUB60500		; yes: MPACK_SUB60500

		LDA	ENTIM1,X		;パターンチェンジ ?
		BNE	MPACK_SUB60500		;  no: MPACK_SUB60500

		LDA	<ENWRK4,X
		INC	A
		AND	#0FF03H
		STA	<ENWRK4,X

		LDA	#00004
		STA	ENTIM1,X

MPACK_SUB60500	EQU	$
		LDY	<ENWRK5,X		;顔のパターン合ってる ?
		BEQ	MPACK_SUB60800		; yes: MPACK_SUB60800

		LDA	ENTIM2,X		;フェイスパターンチェンジ ?
		BNE	MPACK_SUB60800		;  no: MPACK_SUB60800

		LDA	<ENCONT,X
		INC	A
		AND	#00003
		STA	<ENCONT,X
		TAY
		LDA	!MPACK_S00_F_CPT,Y
		TAY
		STY	<ENWRK5,X
		CPY	#004			;口開けポーズ ?
		BNE	MPACK_SUB60700		;  no: MPACK_SUB60700

		LDA	#0007BH			;［Ｓ］
		JSL	>SOUND_3_ON

MPACK_SUB60700	EQU	$
		LDA	#00004
		STA	ENTIM2,X

MPACK_SUB60800	EQU	$

		RTS
;
MPACK_S61_B_CPT EQU	$-2
		WORD	00604H,00605H,00605H,00604H,00003H
;
;MPACK_FACE_AREV	EQU	$
;		WORD	0FFC0H,0FFC0H,0FFC0H,0FFC0H,0FFB0H,0FFA8H
;		WORD	0FF80H,0FF80H,0FF80H,0FFE0H,0FFE0H,0FFE0H
;MPACK_FACE_WIDE	EQU	$
;		WORD	00024H,00024H,00024H,00024H,00024H,00020H
;		WORD	0001CH,0001CH,0001CH,00026H,00026H,00026H
MPACK_S61_FAREV EQU	$-2
		WORD	0FFB0H,0FFA8H,0FFA8H,0FFB0H,0FFC0H
MPACK_S61_FWIDE EQU	$-2
		WORD	00024H,00020H,00020H,00024H,00024H
;
MPACK_SUB61	EQU	$
		TYX

		LDA	ENTIM1,X
		BNE	MPACK_SUB61500

		INC	<ENCONT,X
		INC	<ENCONT,X
		LDY	<ENCONT,X
		CPY	#00CH
		BMI	MPACK_SUB61100

		LDA	MPACKMUK		;あたりの向き反転
		EOR	#0FFFFH			;
		STA	MPACKMUK		;

		STZ	<ENWRK4,X
		STZ	<ENCONT,X
		LDY	MPACKRID
		STY	<ENWRK2,X

		RTS

MPACK_SUB61100	EQU	$
		LDA	!MPACK_S61_B_CPT,Y
		STA	<ENWRK4,X
		LDA	!MPACK_S61_FAREV,Y
		STA	MPACKARV
		LDA	!MPACK_S61_FWIDE,Y
		STA	MPACKFWD
		CPY	#006
		BNE	MPACK_SUB61300

		LDA	ENMUKI,X		;向き反転
		EOR	#00002			;
		STA	ENMUKI,X		;

MPACK_SUB61300	EQU	$
		LDA	#00004
		STA	ENTIM1,X

MPACK_SUB61500	EQU	$
MPACK_SUB82000	EQU	$

		RTS
;
MPACK_SUB82	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACK_SUB82000		; yes: MPACK_SUB82000

		LDY	<ENWRK5,X		;頭のキャラパターンチェンジ
		TYA				;
		LSR	A			;
		AND	#000FEH			;
		STA	<EWORK0			;
		LDA	<ENWRK5,X		;
		AND	#0FF00H			;
		ORA	<EWORK0			;
		STA	<ENWRK5,X		;

		LDY	#002
		STY	<EWORK0

		LDA	ENWRK8,X		;頭の回転角計算
		CMP	#00010H			;	;回転終わり ?
		BPL	MPACK_SUB82100		;	;  no: MPACK_SUB82100
						;
		DEC	<EWORK0			;
		BRA	MPACK_SUB82200		;
						;
MPACK_SUB82100	EQU	$			;
		CLC				;
		ADC	#00004H			;
		AND	#001FEH			;
		STA	ENWRK8,X		;

MPACK_SUB82200	EQU	$
		LDY	#000			;頭の位置計算用回転角補正値計算
		LDA	MPACKARV		;
		SEC				;
		SBC	#0FFC0H-00004H		;
		CMP	#00008			;	;終わり ?
		BCS	MPACK_SUB82300		;	;  no: MPACK_SUB82300
						;
		DEC	<EWORK0			;
		LDA	#0FFC0H			;
		BRA	MPACK_SUB82500		;
						;
MPACK_SUB82300	EQU	$			;
		BPL	MPACK_SUB82400		;
						;
		INY				;
		INY				;
						;
MPACK_SUB82400	EQU	$			;
		LDA	MPACKARV		;
		CLC				;
		ADC	!MPACK_S11_ARV,Y	;
						;
MPACK_SUB82500	EQU	$			;
		STA	MPACKARV		;

		LDY	<EWORK0			;頭元に戻った ?
		BNE	MPACK_SUB82800		;  no: MPACK_SUB82800

		LDX	#000			;触手のリターンルーチンモードインデックスセット
		LDY	MPACHLID		;
MPACK_SUB82600	EQU	$			;
		LDA	MPACHLRI,X		;
		STA	ENWRK2,Y		;
		INX				;
		INX				;
		CPY	MPACHLID		;
		BNE	MPACK_SUB82700		;
						;
		LDY	MPACHRID		;
		BRA	MPACK_SUB82600		;
						;
MPACK_SUB82700	EQU	$			;
		LDX	<ENINDX			;

		LDY	ENMUKI,X		;
		LDA	!MPACK_S00_XSPD,Y	;
		STA	ENXSPD,X		;
		LDA	#00006			;キャラパターンインデックス＆フェイスキャラパターンインデックスセット
		STA	<ENWRK4,X		;
		LDA	#00040H			;潜航スピードセット
		STA	ENYSPD,X		;
		INC	<ENWRK2,X

MPACK_SUB82800	EQU	$

		RTS
;
MPACK_SUB92	EQU	$
		TYX

		LDA	ENTIM0,X
		BNE	MPACK_SUB92800

		LDA	<EWORKC
		CLC
		ADC	ENXPSL,X
		STA	<EWORK0
		LDA	<EWORKE
		CLC
		ADC	ENYPSL,X
		STA	<EWORK2
;		LDA	#00400H
		LDA	#00340H
		JSL	>BSCLW_SET_B_T

		LDA	#00040H*2
		STA	ENTIM0,X
		INC	<ENWRK2,X

MPACK_SUB92800	EQU	$

		RTS
;
MPACK_SUB93	EQU	$
		TYX

		LDA	ENTIM0,X
		BNE	MPACK_SUB93800

		LDA	ENTIM3,X
		BEQ	MPACK_SUB93080

		LDA	#00001
		STA	ENTIM3,X		;無敵タイマークリア

MPACK_SUB93080	EQU	$
		LDA	ENCLOR,X
		AND	#0FFF0H
		ORA	#0000CH
		STA	ENCLOR,X

		LDA	MPACKARV
		BEQ	MPACK_SUB93100
		LDA	ENTIM2,X
		BNE	MPACK_SUB93100

		INC	MPACKARV

		LDA	#00004
		STA	ENTIM2,X

MPACK_SUB93100	EQU	$
		LDA	ENWRK6,X
		SEC
;		SBC	#00004H
		SBC	#00008H
		STA	ENWRK6,X
		STA	ENWRKA,X
		CMP	#000C0H
		BPL	MPACK_SUB93300

;		LDA	#00040H
		LDA	#00030H
		STA	ENTIM0,X
		INC	<ENWRK2,X

MPACK_SUB93300	EQU	$
		LDA	#00180H
		SEC
		SBC	ENWRK6,X
		BMI	MPACK_SUB93800

		AND	#001E0H
		ASL	A
		ASL	A
		ASL	A
		XBA
		STA	MPAC_COL
		CMP	<ENCONT,X
		BEQ	MPACK_SUB93800

		STA	<ENCONT,X
		JSR	MPAC_COLFID
		LDX	<ENINDX

MPACK_SUB93800	EQU	$

		RTS
;
MPACK_OAML	EQU	$-1
		BYTE	02*8,03*8,00*8,01*8,04*8
;
MPACK_SUB94	EQU	$
		TYX

		LDA	ENTIM0,X
		BNE	MPACK_SUB94200

		LDY	MPACKOAM		;頭消去 ?
		BNE	MPACK_SUB94100		;  no: MPACK_SUB94100

		LDA	ENXPSL,X
		CLC
		ADC	<EWORKC
		CLC
		ADC	#00008
		STA	<EWORK0
		LDA	ENYPSL,X
		CLC
		ADC	<EWORKE
		CLC
		ADC	#00008
		STA	<EWORK2

		LDA	#FSMK0		;(A) <-- 効果Ｎｏ．
		JSL	>EXINSR		;効果エリア確保
;
		LDA	<EWORK0
		STA	EXXPSL,Y
		LDA	<EWORK2
		STA	EXYPSL,Y
		LDA	#00004H
		STA	EXTIM0,Y
		ASL	A
		DEC	A
;;;;;;;;		LDA	#00007H
		STA	EXCHPT,Y
		STA	EXWRK0,Y

		LDY	#04*4
		STY	MPACKOAM
		LDA	#00020H
		STA	ENTIM0,X

		RTS

MPACK_SUB94100	EQU	$
		CPY	#04*4+5			;ＯＡＭ消去終わり ?
		BMI	MPACK_SUB94300		;  no: MPACK_SUB94300

;		LDA	#00100H
		LDA	#00040H
		STA	ENTIM0,X

		INC	<ENWRK2,X

MPACK_SUB94200	EQU	$

		RTS

MPACK_SUB94300	EQU	$
		INC	MPACKOAM
		LDA	MPACKOAM
		SEC
		SBC	#004*4
		TAY
		I16
		LDA	!MPACK_OAML,Y
		AND	#000FFH
		CLC
		ADC	ENOAML,X
		CLC
		ADC	#004*4*8
		TAY
		LDA	SOAM_DX+0+8*0,Y
		CLC
		ADC	ESCCH1
		CLC
		ADC	#00008
		STA	<EWORK0
		LDA	SOAM_DX+2+8*0,Y
		CLC
		ADC	ESCCV1
		CLC
		ADC	#00008
		STA	<EWORK2
		I8

		JSR	MPACK_MPKBR_SET

;		LDA	#00010H
		LDA	#00008H
		STA	ENTIM0,X

MPACK_SUB94800	EQU	$
MPACK_SUB95000	EQU	$

		RTS
;
MPACK_SUB95	EQU	$
		TYX

		LDA	ENTIM0,X
		BNE	MPACK_SUB95000
;;;;;;;;		BNE	MPACK_SUB95300

		STZ	TROBJ_ARIA
		PLA
		JMP	>ENCLEAR_NORETN
;;;;;;;;		JMP	>BOSS_CLEAR

MPACK_SUB95300	EQU	$
;;;;;;;;		CMP	#00040H
;;;;;;;;		BNE	MPACK_SUB95000
;;;;;;;;
;;;;;;;;		LDA	#00005			;［Ｓ］
;;;;;;;;		STA	SOUND_0
;;;;;;;;
;;;;;;;;		RTS
;
MPACK_MPKBR_SET EQU	$
		LDA	#MPKBR
		JSL	>EXINSR

		LDA	<EWORK0		;Ｘ座標セット
		AND	#0FFF0H
		STA	EXXPSL,Y
		LDA	<EWORK2		;Ｙ座標セット
		AND	#0FFF0H
		STA	EXYPSL,Y
		LDA	#0000FH		;初期パターンＮｏ．セット
		STA	EXCHPT,Y
		LDA	#00004H		;初期タイマーセット
		STA	EXTIM0,Y

		LDA	#0000AH			;［Ｓ］
		JSL	>SOUND_3_ON

		RTS
;
;****************************************************************
;*								*
;*		マザーパックン　カラーフェード			*
;*								*
;****************************************************************
		DPAGE	WORK0
;
MPAC_COL_DAT	EQU	$
		WORD	COL_ADDRESS+MTHCOL0,COL_ADDRESS+MTHCOL1
		WORD	COL_ADDRESS+MTHCOL2,COL_ADDRESS+MTHCOL3
		WORD	COL_ADDRESS+MTHCOL4,COL_ADDRESS+MTHCOL5
		WORD	COL_ADDRESS+MTHCOL6
;
MPAC_COLFID	EQU	$
		PHD
		LDA	#WORK0
		TCD
		LDA	!MPAC_COL
		ASL	A
		TAX
		LDA	MPAC_COL_DAT,X
		STA	<WORK0
		PHB
		LDX	#BANK DATACOL
		PHX
		PLB
		LDX	#BANK COL_ADDRESS
		STX	<WORK2
		LDY	#000
MPAC_COLFID_LOP EQU	$
		LDA	[<WORK0],Y
		STA	!DATACOL+100H+006*20H+2*2,Y
		INY
		INY
		CPY	#00EH*2
		BCC	MPAC_COLFID_LOP
		PLB
		PLD
		RTS
;
		DPAGE	EN0RAM
;
;
;****************************************************************
;*		initial ( まざーぱっくんの手 )			*
;****************************************************************
MPACHIN		EQU	$			;-- mpachin --
		RTL
;
;****************************************************************
;*		move	( まざーぱっくんの手 )			*
;****************************************************************
;		ENWRK0	触手攻撃の攻撃回数
;		ENWRK2	ROUTINE MODE INDEX
;		ENWRK4	ＯＡＭセットしない数
;		ENWRK6
;		ENWRK8	崩れるときの基本タイマー
;		ENWRKA	わっかの ROUTINE INDEX
;		ENWRKC	わっかの動作モード
;
;		ENCONT	触手のキャラパターンインデックス加算値
;
;		ENCHPT	触手のキャラパターンインデックス
;
;		ENTIM0	ストップタイマー
;		ENTIM1
;		ENTIM2	触手のキャラパターンチェンジタイマー
;		ENTIM3
;
MPACH_RIGHT_LIM EQU	03B0H
MPACH_LEFT_LIM	EQU	02D0H
;
MPACH_SUB	EQU	$
MPACH_00	EQU	$
		WORD	MPACH_SUB00		;待機中
MPACH_18	EQU	$
		WORD	MPACH_SUB18		;イニシャルデモ
MPACH_20	EQU	$
		WORD	MPACH_SUB20		;綿毛攻撃（本体を追いかける）
MPACH_21	EQU	$
		WORD	MPACH_SUB21		;綿毛攻撃（元通り）
MPACH_30	EQU	$
		WORD	MPACH_SUB30		;触手攻撃（触手沈む）
MPACH_31	EQU	$
		WORD	MPACH_SUB31		;触手攻撃（触手ちょっと上昇）
MPACH_32	EQU	$
		WORD	MPACH_SUB32		;触手攻撃（触手移動）
MPACH_320	EQU	$
		WORD	MPACH_SUB320		;触手攻撃（触手ため）
MPACH_33	EQU	$
		WORD	MPACH_SUB33		;触手攻撃（触手急上昇）
MPACH_34	EQU	$
		WORD	MPACH_SUB34		;触手攻撃（触手おどる）
MPACH_35	EQU	$
		WORD	MPACH_SUB35		;触手攻撃（触手沈む）
MPACH_36	EQU	$
		WORD	MPACH_SUB36		;触手攻撃（触手上昇）
MPACH_37	EQU	$
		WORD	MPACH_SUB37		;触手攻撃（触手上昇チェック）
MPACH_38	EQU	$
		WORD	MPACH_SUB38		;触手攻撃（触手ちょっと沈む）
MPACH_80	EQU	$
		WORD	DUMMY_SUB		;全体でやられた
MPACH_90	EQU	$
		WORD	MPACH_SUB90		;ラストダメージ（伸び切る）
MPACH_91	EQU	$
		WORD	MPACH_SUB91		;ラストダメージ（消去）
MPACH_92	EQU	$
		WORD	DUMMY_SUB
;
MPACH_RMODE00	EQU	(MPACH_00-MPACH_SUB)/2
MPACH_RMODE18	EQU	(MPACH_18-MPACH_SUB)/2
MPACH_RMODE20	EQU	(MPACH_20-MPACH_SUB)/2
MPACH_RMODE21	EQU	(MPACH_21-MPACH_SUB)/2
MPACH_RMODE30	EQU	(MPACH_30-MPACH_SUB)/2
MPACH_RMODE31	EQU	(MPACH_31-MPACH_SUB)/2
MPACH_RMODE32	EQU	(MPACH_32-MPACH_SUB)/2
MPACH_RMODE320	EQU	(MPACH_320-MPACH_SUB)/2
MPACH_RMODE33	EQU	(MPACH_33-MPACH_SUB)/2
MPACH_RMODE34	EQU	(MPACH_34-MPACH_SUB)/2
MPACH_RMODE35	EQU	(MPACH_35-MPACH_SUB)/2
MPACH_RMODE36	EQU	(MPACH_36-MPACH_SUB)/2
MPACH_RMODE37	EQU	(MPACH_37-MPACH_SUB)/2
MPACH_RMODE38	EQU	(MPACH_38-MPACH_SUB)/2
MPACH_RMODE80	EQU	(MPACH_80-MPACH_SUB)/2
MPACH_RMODE90	EQU	(MPACH_90-MPACH_SUB)/2
MPACH_RMODE91	EQU	(MPACH_91-MPACH_SUB)/2
MPACH_RMODE92	EQU	(MPACH_92-MPACH_SUB)/2
;
MPACHMV		EQU	$			;-- mpachmv --
		JSR	MPACH_OAM_SET

		LDY	MPACKIDX
		LDA	ENCLOR,Y
		STA	ENCLOR,X

		JSL	>ENMDCK

		TXY
		LDA	<ENWRK2,X
		ASL	A
		TAX
		JSR	(MPACH_SUB,X)

		JSR	MPACH_PLCHK

		LDY	<ENWRK2,X
		CPY	#MPACH_RMODE80
		BNE	MPACHMV0500

		LDA	ENXPSL,X
		SEC
		SBC	ENMOVX,X
		STA	ENXPSL,X
		LDA	ENYPSL,X
		SEC
		SBC	ENMOVY,X
		STA	ENYPSL,X

		RTL

MPACHMV0500	EQU	$
		JSR	MPACH_ENMOD2_ST		;ＯＡＭセット数変更

		JSR	MPACH_XLIM_CHK		;Ｘ範囲チェック

		RTL
;
MPACH_OAM_SET	EQU	$
		TXA				;(R10) <- 敵のインデックス
		STA	R10			;
		LDA	#BANK MPACH_CHAR_ADR	;(R0) <-- ＯＡＭセットデータバンク
		STA	R0			;
		LDA	#MPACH_CHAR_ADR		;(R14) <- ＯＡＭセットデータアドレス
		STA	R14			;

		LDY	ENMOD2+1,X		;(R12) <- 触手のＯＡＭセット数
		TYA				;
		LSR	A			;
		LSR	A			;
		LSR	A			;
		STA	R12			;

		LDA	<ENWRK4,X		;WRKF <- ＯＡＭセットしない数
		STA	CCWORKF			;

		LDA	ENDSXL,X
		STA	R1
		LDA	ENDSYL,X
		STA	R2
		LDA	ENMUKI,X
		STA	R8

		M_CHIP	M_MPACH_OAMSET
		LDX	<ENINDX

		RTS
;
MPACH_CH_YREV	EQU	$
;ENCHPT =		[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [A] [B] [C] [D] [E] [F]
		HEX	000,001,003,005,007,009,00A,00B,00C,00D,00E,00F,011,012,014,015
;ENCHPT =		[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [A] [B] [C] [D] [E] [F]
		HEX	017,018,019,019,01B,01B,01B,01B,01A,019
;
MPACH_PLCHK	EQU	$
		LDY	<ENWRK2,X		;ダメージ中 ?
		CPY	#MPACH_RMODE80		;
		BPL	MPACH_PLCHK1800		; yes: MPACH_PLCHK1800

MPACH_PLCHK0100 EQU	$
		LDA	ENOAML,X		;ファーストフレーム ?
		BMI	MPACH_PLCHK1800		; yes: MPACH_PLCHK1800

MPACH_PLCHK1000 EQU	$
;触手ＶＳプレイヤー
		LDA	PWIDEX
		CLC
		ADC	#00006
		ASL	A
		STA	<EWORK0
		LSR	A
		CLC
		ADC	EPWIDX,X
		CMP	<EWORK0
		BCS	MPACH_PLCHK1800

		LDY	ENCHPT,X
		LDA	!MPACH_CH_YREV,Y
		AND	#000FFH
		STA	<EWORK0

		CLC
		ADC	#00008-2
		CLC
		ADC	PWIDEY
		ASL	A
		STA	<EWORK2

		LSR	A
		CLC
		ADC	EPWIDY,X
		SEC
		SBC	<EWORK0
		CMP	<EWORK2
		BCS	MPACH_PLCHK1800

		JSL	>PLFLST

MPACH_PLCHK1800 EQU	$

		RTS
;
MPACH_ENMODE2	EQU	$
;ENCHPT =		[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [A] [B] [C] [D] [E] [F]
		HEX	018,018,010,010,020,020,018,018,020,028,028,020,020,020,028,028
		HEX	028,028,028,028,028,028,028,028,028,028
;
MPACH_ENMOD2_ST EQU	$
		LDY	ENCHPT,X
		LDA	!MPACH_ENMODE2,Y
		TAY
		TYA
		STA	<EWORK0
		LDA	ENMOD2+1,X
		AND	#0FF07H
		ORA	<EWORK0
		STA	ENMOD2+1,X

		RTS
;
MPACH_SUB00	EQU	$
MPACH_SUB37	EQU	$
		TYX

		LDA	MPACKYLW		;水面まで出た ?
		CMP	ENYPSL,X		;
		BMI	MPACH_SUB00300		;  no: MPACH_SUB00300

		STA	ENYPSL,X
		STZ	ENYSPD,X
		STZ	<ENWRK2,X

MPACH_SUB00300	EQU	$
		JMP	MPACH_KUNE_KUNE
;
MPACH_XLIM_CHK	EQU	$
		LDA	ENXPSL,X		;移動制限チェック
		CMP	#MPACH_RIGHT_LIM	;
		BMI	MPACH_X_CHK0100		;
						;
		LDA	#MPACH_RIGHT_LIM-1	;
		BRA	MPACH_X_CHK0200		;
						;
MPACH_X_CHK0100 EQU	$			;
		CMP	#MPACH_LEFT_LIM		;
		BPL	MPACH_X_CHK0300		;
						;
		LDA	#MPACH_LEFT_LIM		;
						;
MPACH_X_CHK0200 EQU	$			;
		STA	ENXPSL,X		;
		LDA	ENXSPD,X		;
		EOR	#0FFFFH			;
		INC	A			;
		STA	ENXSPD,X		;

MPACH_X_CHK0300 EQU	$

		RTS
;
MPACH_SUB18	EQU	$
MPACH_SUB34	EQU	$
		TYX

MPACH_SUB18000	EQU	$
		LDA	MPACKYLW		;水面まで出た ?
		CMP	ENYPSL,X		;
		BMI	MPACH_SUB18100		;  no: MPACH_SUB18100

		STA	ENYPSL,X
		STZ	ENYSPD,X

MPACH_SUB18100	EQU	$
		JSR	MPACH_KUNE_KUNE

		LDY	<ENWRK2,X		;イニシャルデモ ?
		CPY	#MPACH_RMODE18		;
		BNE	MPACH_SUB18500		;  no: MPACH_SUB18500

		LDY	MPACKIDX		;本体イニシャルデモ中 ?
		LDA	ENWRK2,Y		;
		BNE	MPACH_SUB18300		; yes: MPACH_SUB18300

		STZ	<ENWRK2,X

MPACH_SUB18300	EQU	$

		RTS

MPACH_SUB18500	EQU	$
		LDY	ENCHPT,X		;縮んでもいいパターン ?
		CPY	#012H			;
		BNE	MPACH_SUB18800		;  no: MPACH_SUB18800

		LDA	ENTIM1,X		;くねくね終わり ?
		BNE	MPACH_SUB18800		;  no: MPACH_SUB18800

		INC	<ENWRK2,X
		LDA	MPACK_TIMER		;触手攻撃終わり ?
		BEQ	MPACH_SUB18800		; yes: MPACH_SUB18800

		LDY	#MPACH_RMODE38
		STY	<ENWRK2,X

MPACH_SUB18800	EQU	$

		RTS
;
MPACH_S10_CHPT	EQU	$
		HEX	012,013,014,015,016,017,018,019
		HEX	019,018,017,016,015,014,013,012
;
MPACH_KUNE_KUNE EQU	$
		LDA	ENTIM2,X		;触手のキャラパターンチェンジ ?
		BNE	MPACH_K_K0800		;  no: MPACH_K_K0800

		LDA	<ENCONT,X
		INC	A
		AND	#0000FH
		STA	<ENCONT,X
		TAY
		LDA	!MPACH_S10_CHPT,Y
		TAY
		TYA
		STA	ENCHPT,X

		LDY	<ENWRK2,X		;
		CPY	#MPACH_RMODE34		;
		BEQ	MPACH_K_K0300
		CPY	#MPACH_RMODE80		;ダメージ中 ?
		BMI	MPACH_K_K0400		;  no: MPACH_K_K0400

MPACH_K_K0300	EQU	$
		LDA	#00002H
		STA	ENTIM2,X

		RTS

MPACH_K_K0400	EQU	$
		LDA	<RANDM0
		AND	#00005
;		CLC
;		ADC	#00001
		STA	ENTIM2,X

MPACH_K_K0800	EQU	$

		RTS
;
MPACH_S20_BXPOS EQU	$
		WORD	00020H,0FFE0H
MPACH_S20_CHADD EQU	$
		WORD	00001H,0FFFFH
MPACH_S20_XLIM	EQU	$
		WORD	MPACH_RIGHT_LIM
		WORD	MPACH_LEFT_LIM
;
MPACH_SUB20	EQU	$
		TYX

		LDA	ENTIM2,X		;キャラパターンチェンジ ?
		BNE	MPACH_SUB20200		;  no: MPACH_SUB20200

		LDY	#000
		LDA	ENCHPT,X
		CLC
		ADC	<ENCONT,X
		CMP	#00001
		BMI	MPACH_SUB20100

		INY
		INY
		CMP	#00004
		BMI	MPACH_SUB20180

MPACH_SUB20100	EQU	$
		PHA
		LDA	!MPACH_S20_CHADD,Y
		STA	<ENCONT,X
		PLA

MPACH_SUB20180	EQU	$
		STA	ENCHPT,X

		LDA	<RANDM0
		AND	#00003
		CLC
		ADC	#00004
		STA	ENTIM2,X

MPACH_SUB20200	EQU	$
		LDY	#000
		CPX	MPACHLID
		BNE	MPACH_SUB20210

		INY
		INY

MPACH_SUB20210	EQU	$
		TYA
		DEC	A
		STA	<EWORK6
		LDA	!MPACH_S20_XLIM,Y
		STA	<EWORK4
		LDA	!MPACH_S20_BXPOS,Y
		LDY	MPACKIDX
		CLC
		ADC	ENXPSL,Y
		STA	<EWORK2
		SEC
		SBC	ENXPSL,X
		STA	<EWORK0
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		PHP
		CMP	#00300H
		BMI	MPACH_SUB20300

		LDA	#00300H

MPACH_SUB20300	EQU	$
		CMP	#0FD00H
		BPL	MPACH_SUB20400

		LDA	#0FD00H

MPACH_SUB20400	EQU	$
		STA	ENXMAX,X
		PLP
		BPL	MPACH_SUB20500

		EOR	#0FFFFH
		INC	A

MPACH_SUB20500	EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	ENXPOW,X

MPACH_SUB20700	EQU	$
		LDY	MPACKIDX		;移動終了チェック
		LDA	ENWRK2,Y		;
		CMP	#MPACK_RMODE40		;
		BMI	MPACH_SUB20710		;
		CMP	#MPACK_RMODE45		;
		BMI	MPACH_SUB20800		;
		CMP	#MPACK_RMODE50		;
		BMI	MPACH_SUB20710		;
		CMP	#MPACK_RMODE54+1	;
		BMI	MPACH_SUB20800		;
						;
MPACH_SUB20710	EQU	$			;
		LDA	<EWORK2
		SEC
		SBC	<EWORK4
		EOR	<EWORK6
		BPL	MPACH_SUB20720

		LDA	<EWORK4
		BRA	MPACH_SUB20780

MPACH_SUB20720	EQU	$
		LDA	<EWORK0			;
		CLC				;
		ADC	#00004			;
		CMP	#00008			;
		BCS	MPACH_SUB20800		;
						;
		LDA	ENXPSL,Y		;
		LDY	#000
		CPX	MPACHLID
		BNE	MPACH_SUB20760

		INY
		INY

MPACH_SUB20760	EQU	$
		CLC				;
		ADC	!MPACH_S20_BXPOS,Y	;

MPACH_SUB20780	EQU	$
		STA	ENXPSL,X		;
		STZ	ENXSPD,X		;
		STZ	ENXPOW,X		;
						;
		INC	<ENWRK2,X		;

MPACH_SUB20800	EQU	$

		RTS
;
MPACH_SUB21	EQU	$
		TYX

		LDA	ENTIM2,X		;キャラパターンチェンジ ?
		BNE	MPACH_SUB21700		;  no: MPACH_SUB21700

		LDA	ENCHPT,X		;キャラパターンセット
		INC	A			;
		CMP	#00012H			;
		BMI	MPACH_SUB21300		;
						;
		STZ	<ENWRK2,X		;
		LDA	#00012H			;
						;
MPACH_SUB21300	EQU	$			;
		STA	ENCHPT,X		;

		LDA	<RANDM0
		AND	#00001
;		CLC
;		ADC	#00002
		INC	A
		INC	A
		STA	ENTIM2,X

MPACH_SUB21700	EQU	$
MPACH_SUB30000	EQU	$

		RTS
;
MPACH_SUB30	EQU	$
MPACH_SUB35	EQU	$
MPACH_SUB38	EQU	$
		TYX

		LDA	MPACK_TIMER		;触手攻撃終わり ?
		BNE	MPACH_SUB30200		;  no: MPACH_SUB30200

		LDY	#MPACH_RMODE35
		STY	<ENWRK2,X
		BRA	MPACH_SUB30280

MPACH_SUB30200	EQU	$
		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACH_SUB30500		; yes: MPACH_SUB30500

MPACH_SUB30280	EQU	$
		LDY	ENCHPT,X		;縮みパターンに移っていい ?
		CPY	#013H			;
		BPL	MPACH_SUB30500		;  no: MPACH_SUB30500

		LDA	ENTIM2,X		;触手、キャラパターンチェンジ ?
		BNE	MPACH_SUB30500		;  no: MPACH_SUB30500

		LDA	ENCHPT,X		;触手、縮み切った ?
		DEC	A			;
		BPL	MPACH_SUB30300		;  no: MPACH_SUB30300

		LDA	MPACKYLW		;位置固定
		CLC				;
		ADC	#00010H			;
		STA	ENYPSL,X		;
		LDA	#00040H			;ストップタイマーセット
		STA	ENTIM0,X		;

		INC	<ENWRK2,X
		STZ	ENYSPD,X
		STZ	<ENCONT,X
		LDA	#00000
		BRA	MPACH_SUB30400

MPACH_SUB30300	EQU	$
		LDY	<ENWRK2,X		;触手攻撃から復帰 ?
		CPY	#MPACH_RMODE38		;
		BNE	MPACH_SUB30380		;  no: MPACH_SUB30380

		CMP	#00005			;完全に沈む手前 ?
		BPL	MPACH_SUB30400		;  no: MPACH_SUB30400

		STA	ENCHPT,X
		LDA	<RANDM0
		AND	#0003FH
		CLC
		ADC	#00040H*2
		STA	ENTIM0,X
		LDA	#00001
		STA	<ENCONT,X
		LDY	#MPACH_RMODE32
		STY	<ENWRK2,X

		RTS

MPACH_SUB30380	EQU	$
		CMP	#00006			;沈むポーズの最後 ?
		BPL	MPACH_SUB30400		;  no: MPACH_SUB30400

		PHA
		LDA	#00040H
		STA	ENYSPD,X
		PLA

MPACH_SUB30400	EQU	$
		STA	ENCHPT,X

		LDA	#00002
		STA	ENTIM2,X

		RTS

MPACH_SUB30500	EQU	$
		JMP	MPACH_KUNE_KUNE
;
MPACH_SUB31	EQU	$
		TYX

		LDA	MPACK_TIMER		;触手攻撃終わり ?
		BNE	MPACH_SUB31300		;  no: MPACH_SUB31300

		LDY	#MPACH_RMODE35
		STY	<ENWRK2,X
		RTS

MPACH_SUB31300	EQU	$
		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACH_SUB31800		; yes: MPACH_SUB31800

		LDY	<ENCONT,X		;触手伸びてる（瞬間移動終わり） ?
		BNE	MPACH_SUB31400		; yes: MPACH_SUB31400

		INC	<ENCONT,X
		LDA	PLXPSL			;瞬間移動
		STA	ENXPSL,X		;

MPACH_SUB31400	EQU	$
		LDA	ENTIM2,X		;触手、キャラパターンチェンジ ?
		BNE	MPACH_SUB31800		;  no: MPACH_SUB31800

		INC	ENCHPT,X		;
		LDY	ENCHPT,X		;
		CPY	#003H			;
		BMI	MPACH_SUB31500		;  no: MPACH_SUB31500

		LDA	<RANDM0			;プレイヤーサーチタイマーセット
		AND	#0001FH			;
		CLC				;
		ADC	#00040H			;
		STA	ENTIM0,X		;
		INC	<ENWRK2,X		;

MPACH_SUB31500	EQU	$
		LDA	#00003
		STA	ENTIM2,X

MPACH_SUB31800	EQU	$

		RTS
;
MPACH_S32_XPOS	EQU	$
		WORD	00004H,0FFFCH
MPACH_S32_XMAX	EQU	$
		WORD	0FFC0H,00040H
;
MPACH_SUB32	EQU	$
		TYX

		LDA	MPACK_TIMER		;触手攻撃終わり ?
		BNE	MPACH_SUB32080		;  no: MPACH_SUB32080

		STZ	ENXPOW,X
		STZ	ENXSPD,X
		LDY	#MPACH_RMODE35
		STY	<ENWRK2,X
		RTS

MPACH_SUB32080	EQU	$
		LDA	ENTIM0,X		;移動終わり ?
		BNE	MPACH_SUB32100		;  no: MPACH_SUB32100

		LDA	EPWIDX,X		;プレイヤーの近くに来た ?
		CLC				;
		ADC	#00008H			;
		CMP	#00010H			;
		BCS	MPACH_SUB32100		;  no: MPACH_SUB32100

		STZ	ENXSPD,X		;止まる
		STZ	ENXPOW,X		;
		INC	<ENWRK2,X

		RTS

MPACH_SUB32100	EQU	$
		LDY	#000			;マックススピードセット
		CPX	MPACHLID		;
		BEQ	MPACH_SUB32200		;
						;
		INY				;
		INY				;
						;
MPACH_SUB32200	EQU	$			;
		LDA	!MPACH_S32_XPOS,Y	;
		LDY	#000			;
		CLC				;
		ADC	EPWIDX,X		;
		BPL	MPACH_SUB32300		;
						;
		INY				;
		INY				;
						;
MPACH_SUB32300	EQU	$			;
		LDA	!MPACH_S32_XMAX,Y	;
		STA	ENXMAX,X		;

		LDA	#00010H
		STA	ENXPOW,X

MPACH_SUB32500	EQU	$
		LDA	ENTIM2,X		;触手のキャラパターンチェンジ ?
		BNE	MPACH_SUB32800		;  no: MPACH_SUB32800

		LDA	ENCHPT,X		;
		CLC				;
		ADC	<ENCONT,X		;
		STA	ENCHPT,X		;
		CMP	#00003			;
		BEQ	MPACH_SUB32600		;
		CMP	#00005			;
		BMI	MPACH_SUB32700		;

MPACH_SUB32600	EQU	$
		LDA	<ENCONT,X		;
		EOR	#0FFFFH			;
		INC	A			;
		STA	<ENCONT,X		;

MPACH_SUB32700	EQU	$
		LDA	#00008
		STA	ENTIM2,X

MPACH_SUB32800	EQU	$

		RTS
;
MPACH_SUB320	EQU	$
		TYX

		LDA	MPACK_TIMER		;触手攻撃終わり ?
		BNE	MPACH_SUB320100		;  no: MPACH_SUB320100

		LDY	#MPACH_RMODE35
		STY	<ENWRK2,X
		RTS

MPACH_SUB320100 EQU	$
		LDY	ENCHPT,X		;縮み切った ?
		BNE	MPACH_SUB320300		;  no: MPACH_SUB320300

		LDA	#00020H			;ストップタイマーセット
		STA	ENTIM0,X		;
		STZ	<ENCONT,X		;効果セットロックフラグクリア
;
		INC	<ENWRK2,X

MPACH_WTUP0_SET EQU	$
		LDA	#WTUP0
		JSL	>EXINSR
		LDA	ENXPSL,X
		STA	EXXPSL,Y
		LDA	MPACKYLW
		STA	EXYPSL,Y
		LDA	#WUP0P			;pattern counter set
		STA	EXWRK0,Y
		LDA	#03H
		STA	EXTIM0,Y		;timer set
;;;;;;;;		LDA	#00003H			;［Ｓ］
		JSL	>SOUND_3_ON
;
		RTS

MPACH_SUB320300 EQU	$
		DEC	ENCHPT,X

		RTS
;
MPACH_SUB33	EQU	$
		TYX

		LDA	MPACK_TIMER		;触手攻撃終わり ?
		BNE	MPACH_SUB33100		;  no: MPACH_SUB33100

		LDY	#MPACH_RMODE35
		STY	<ENWRK2,X
		RTS

MPACH_SUB33100	EQU	$
		LDA	ENTIM0,X		;上昇待ち ?
		BNE	MPACH_SUB33700		; yes: MPACH_SUB33700

		LDY	<ENCONT,X		;効果すでにセットした ?
		BNE	MPACH_SUB33500		; yes: MPACH_SUB33500

		INC	<ENCONT,X
		JSR	MPACH_WTUP0_SET
;
MPACH_SUB33500	EQU	$
		INC	ENCHPT,X
		LDY	ENCHPT,X		;触手、伸び切った ?
		CPY	#012H			;
		BMI	MPACH_SUB33700		;  no: MPACH_SUB33700

		LDA	#00040H
		STA	ENTIM1,X
		INC	<ENWRK2,X

MPACH_SUB33700	EQU	$

		RTS
;
MPACH_S36_XPOS	EQU	$
		WORD	00020H,0FFE0H
;
MPACH_SUB36	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACH_SUB36800		; yes: MPACH_SUB36800

		LDY	<ENCONT,X		;触手伸びてる ?
		BNE	MPACH_SUB36400		; yes: MPACH_SUB36400

		LDA	#0FFC0H
		STA	ENYSPD,X
		INC	<ENCONT,X

		CPX	MPACHLID
		BNE	MPACH_SUB36300

		INY
		INY

MPACH_SUB36300	EQU	$
		LDA	!MPACH_S36_XPOS,Y
		LDY	MPACKIDX
		CLC
		ADC	ENXPSL,Y
		STA	ENXPSL,X

MPACH_SUB36400	EQU	$
		LDA	ENTIM2,X		;触手、キャラパターンチェンジ ?
		BNE	MPACH_SUB36800		;  no: MPACH_SUB36800

		INC	ENCHPT,X
		LDY	ENCHPT,X		;触手、伸び切った ?
		CPY	#012H			;
		BMI	MPACH_SUB36500		;  no: MPACH_SUB36500

		LDA	#0FF80H
		STA	ENYSPD,X
		INC	<ENWRK2,X

MPACH_SUB36500	EQU	$
		LDA	#00004
		STA	ENTIM2,X

MPACH_SUB36800	EQU	$

		RTS
;
MPACH_S90_YSPD	EQU	$
		WORD	00040H,0FFC0H
;
MPACH_SUB90	EQU	$
		TYX

		STZ	ENXSPD,X
		STZ	ENXPOW,X
		STZ	ENYSPD,X
		STZ	ENGPOW,X

		LDA	ENTIM2,X
		BNE	MPACH_SUB90800

		LDY	ENCHPT,X		;伸び切ったのパターンになった ?
		CPY	#012H			;
		BEQ	MPACH_SUB90500		; yes: MPACH_SUB90500
		BPL	MPACH_SUB90200

		INC	ENCHPT,X
		BRA	MPACH_SUB90300

MPACH_SUB90200	EQU	$
		DEC	ENCHPT,X

MPACH_SUB90300	EQU	$
		LDA	#00004H
		STA	ENTIM2,X

		RTS

MPACH_SUB90500	EQU	$
		LDY	#000
		LDA	MPACKYLW
		CMP	ENYPSL,X
		BEQ	MPACH_SUB90700
		BPL	MPACH_SUB90600

		INY
		INY

MPACH_SUB90600	EQU	$
		LDA	!MPACH_S90_YSPD,Y
		STA	ENYSPD,X

		RTS

MPACH_SUB90700	EQU	$
		LDY	MPACKIDX		;本体、崩れさった ?
		LDA	ENWRK2,Y		;
		CMP	#MPACK_RMODE95		;
		BNE	MPACH_SUB90800		;  no: MPACH_SUB90800

		LDA	#00010H
		STA	ENWRK8,X

MPACW_BREAK_TIM EQU	$
		DEC	A		;[ LDA	#0FH ]
		AND	<RANDM0
;		LDA	<RANDM0
;		AND	#0000FH
		CLC
		ADC	#00018H
		STA	ENTIM0,X
		INC	<ENWRK2,X

MPACH_SUB90800	EQU	$

		RTS
;
MPACH_OAML	EQU	$
		BYTE	04*8,00*8,03*8,02*8,01*8
;
MPACH_SUB91	EQU	$
		TYX

		LDA	ENTIM0,X
		BNE	MPACH_SUB91800

		LDY	<ENWRK4,X
		CPY	#005
		BNE	MPACH_SUB91500

		INC	<ENWRK2,X

		RTS

MPACH_SUB91500	EQU	$
		INC	<ENWRK4,X

		LDY	<ENWRK4,X
		I16
		LDA	!MPACH_OAML-1,Y
		AND	#000FFH
		CLC
		ADC	ENOAML,X
		TAY
		LDA	SOAM_DX+0+8*0,Y
		CLC
		ADC	ESCCH1
		CLC
		ADC	#00008
		STA	<EWORK0
		LDA	SOAM_DX+2+8*0,Y
		CLC
		ADC	ESCCV1
		CLC
		ADC	#00008
		STA	<EWORK2
		I8

		JSR	MPACK_MPKBR_SET

		LDA	<RANDM0
;		AND	#0000FH
		AND	#00007H
		CLC
		ADC	ENWRK8,X
		STA	ENTIM0,X
		LDA	ENWRK8,X
		LSR	A
		STA	ENWRK8,X

MPACH_SUB91800	EQU	$

		RTS
;
;****************************************************************
;*		initial ( まざーぱっくんのわっか )		*
;****************************************************************
MPACWIN		EQU	$			;-- mpacwin --
		RTL
;
;****************************************************************
;*		move	( まざーぱっくんのわっか )		*
;****************************************************************
;		ENWRK0	触手の ROUTINE INDEX
;		ENWRK2	ROUTINE MODE INDEX
;		ENWRK4	G POW セットフラグ
;		ENWRK6	キャラパターンチェンジタイマーデータ
;		ENWRK8	ＯＡＭセットしない数
;		ENWRKA	崩れるときの基本タイマー
;		ENWRKC
;
;		ENCONT
;
;		ENTIM0
;		ENTIM1
;		ENTIM2
;		ENTIM3
;
MPACW_RIGHT_LIM EQU	03A0H
MPACW_LEFT_LIM	EQU	02F0H
;
MPACW_SUB	EQU	$
		WORD	MPACW_SUB0		;判断
		WORD	MPACW_SUB1		;水上チェック
		WORD	MPACW_SUB2		;ラストダメージ（伸び切り）
		WORD	MPACW_SUB3		;ラストダメージ（消去）
		WORD	DUMMY_SUB		;
		WORD	MPACW_SUB5		;イニシャルデモ（判断）
		WORD	MPACW_SUB6		;イニシャルデモ（水上チェック）
;
MPACW_LAST_YSPD EQU	$
		WORD	00000H,00040H,0FFC0H
;
MPACWMV		EQU	$			;-- mpacwmv --
		LDY	MPACKIDX
		LDA	ENCLOR,Y
		STA	ENCLOR,X

		JSR	MPACW_OAM_CLR

		JSL	>ENMDCK

		LDY	MPACKIDX		;本体、ダメージを受けてる ?
		LDA	ENWRK2,Y		;
		CMP	#MPACK_RMODE80		;
		BMI	MPACWMV0200		;  no: MPACWMV0200
		CMP	#MPACK_RMODE83		;ダメージ終わり ?
		BNE	MPACWMV0010		;  no: MPACWMV0010

		LDY	MPACHLID		;触手ＯＫ ?
		LDA	ENWRK2,Y		;
		LDY	MPACHRID		;
		ORA	ENWRK2,Y		;
		BEQ	MPACWMV0080		; yes: MPACWMV0080
		BRA	MPACWMV0200		;  no: MPACWMV0080

MPACWMV0010	EQU	$
		CMP	#MPACK_RMODE90		;ラストダメージ ?
		BMI	MPACWMV0080		;  no: MPACWMV0080

		LDY	<ENWRK2,X
		CPY	#002
		BPL	MPACWMV0300

		LDY	#002
		STY	<ENWRK2,X

		LDY	#000
		LDA	MPACKYLW		;所定の位置まで来た ?
		CMP	ENYPSL,X		;
		BEQ	MPACWMV0030		; yes: MPACWMV0030

		PHP
		INY
		INY
		PLP
		BPL	MPACWMV0030		;

		INY
		INY

MPACWMV0030	EQU	$
		LDA	!MPACW_LAST_YSPD,Y
		STA	ENYSPD,X
		STZ	ENGPOW,X

		LDA	#00004H
		STA	ENWRK6,X
		BRA	MPACWMV0300

MPACWMV0080	EQU	$
		LDA	ENGPOW,X
		BEQ	MPACWMV0100

		STA	<ENWRK4,X

MPACWMV0100	EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		STZ	ENGPOW,X
		BRA	MPACWMV0600

MPACWMV0200	EQU	$
		LDA	<ENWRK4,X		;ダメージからの復帰 ?
		BEQ	MPACWMV0300		;  no: MPACWMV0300

		STA	ENGPOW,X
		STZ	<ENWRK4,X

MPACWMV0300	EQU	$
		TXY
		LDA	<ENWRK2,X
		ASL	A
		TAX
		JSR	(MPACW_SUB,X)

		JSR	MPACW_CHPT_CHG

		JSR	MPACW_PLCHK

		JSR	MPACW_XLIM_CHK		;Ｘ範囲チェック

		LDY	MPACKIDX		;本体、突撃中 ?
		LDA	ENWRK2,Y		;
		CMP	#MPACK_RMODE41		;  yes: MPACWMV0500
		BEQ	MPACWMV0500		;   no: MPACWMV0600
		CMP	#MPACK_RMODE51		;
		BMI	MPACWMV0600		;
		CMP	#MPACK_RMODE53+1	;
		BPL	MPACWMV0600		;

MPACWMV0500	EQU	$
		LDA	#00100H
		STA	ENGMAX,X
		LDA	<RANDM0
		AND	#0000FH
		CLC
		ADC	#00010H
		STA	ENGPOW,X

MPACWMV0600	EQU	$

		RTL
;
MPACW_OAML	EQU	$
		BYTE	03*8,01*8,00*8,02*8
;
MPACW_OAM_CLR	EQU	$
		LDA	ENWRK8,X
		BEQ	MPACW_O_CLR0800

		STA	<EWORK2

		I16
		LDA	ENOAML,X
		STA	<EWORK0

MPACW_O_CLR0100 EQU	$
		LDY	<EWORK2
		LDA	MPACW_OAML-1,Y
		AND	#000FFH
		CLC
		ADC	<EWORK0
		TAY

		LDA	#08000H
		STA	SOAM_DX+0+8*0,Y

		DEC	<EWORK2
		BNE	MPACW_O_CLR0100

		I8

MPACW_O_CLR0800 EQU	$

		RTS
;
MPACW_CHPT_CHG	EQU	$
		LDA	ENTIM1,X
		BNE	MPACW_C_CHG0800

		LDA	ENCHPT,X
		INC	A
		AND	#00003H
		STA	ENCHPT,X

		LDA	ENWRK6,X
		STA	ENTIM1,X

MPACW_C_CHG0800 EQU	$

		RTS
;
MPACW_PLCHK	EQU	$
		LDY	<ENWRK2,X		;ラストダメージｏｒイニシャルデモ ?
		CPY	#002			;
		BPL	MPACW_PLCHK0800		; yes: MPACW_PLCHK0800

		LDY	ECRSFG,X
		BPL	MPACW_PLCHK0800

		JSL	>PLFLST

MPACW_PLCHK0800 EQU	$

		RTS
;
MPACW_XLIM_CHK	EQU	$
		LDY	<ENWRK2,X		;イニシャルデモ中 ?
		CPY	#005			;
		BPL	MPACW_X_CHK0300		; yes: MPACW_X_CHK0300

		LDA	ENXPSL,X		;移動制限チェック
		CMP	#MPACW_RIGHT_LIM	;
		BMI	MPACW_X_CHK0100		;
						;
		LDA	#MPACW_RIGHT_LIM-1	;
		BRA	MPACW_X_CHK0200		;
						;
MPACW_X_CHK0100 EQU	$			;
		CMP	#MPACW_LEFT_LIM		;
		BPL	MPACW_X_CHK0300		;
						;
		LDA	#MPACW_LEFT_LIM		;
						;
MPACW_X_CHK0200 EQU	$			;
		STA	ENXPSL,X		;
		LDA	ENXSPD,X		;
		EOR	#0FFFFH			;
		INC	A			;
		STA	ENXSPD,X		;

MPACW_X_CHK0300 EQU	$

		RTS
;
MPACW_S00_SUB	EQU	$
		WORD	MPACW_S0_S0		;00  待機中
		WORD	MPACW_S0_S0		;18  イニシャルデモ
		WORD	MPACW_S0_S1		;20  綿毛攻撃（本体を追いかける）
		WORD	MPACW_S0_S1		;21  綿毛攻撃（元通り）
		WORD	MPACW_S0_S1		;30  触手攻撃（触手沈む）
		WORD	MPACW_S0_S1		;31  触手攻撃（触手ちょっと上昇）
		WORD	MPACW_S0_S1		;32  触手攻撃（触手移動）
		WORD	MPACW_S0_S1		;320 触手攻撃（触手ため）
		WORD	MPACW_S0_S1		;33  触手攻撃（触手急上昇）
		WORD	MPACW_S0_S1		;34  触手攻撃（触手おどる）
		WORD	MPACW_S0_S1		;35  触手攻撃（触手沈む）
		WORD	MPACW_S0_S1		;36  触手攻撃（触手上昇）
		WORD	MPACW_S0_S1		;37  触手攻撃（触手上昇チェック）
		WORD	MPACW_S0_S1		;38  触手攻撃（触手ちょっと沈む）
;
MPACW_SUB0	EQU	$
MPACW_SUB5	EQU	$
		TYX

		LDA	ENTIM0,X		;ストップ ?
		BNE	MPACW_SUB0800		; yes: MPACW_SUB0800

		LDY	<ENWRK0,X
		LDA	ENWRK2,Y
		ASL	A
		TXY
		TAX
		JSR	(MPACW_S00_SUB,X)

MPACW_SUB0800	EQU	$

		RTS
;
MPACW_S0_S0	EQU	$
		CPX	#001*2
		BMI	MPACW_S0_S0040
		CPX	#005*2
		BMI	MPACW_S0_S0080

MPACW_S0_S0040	EQU	$
		TYX
		STZ	<ENWRK2,X

MPACW_S0_S0080	EQU	$
		TYX

		STZ	ENMUKI,X
		LDY	MPACKIDX
		LDA	<RANDM0
		PHA
		AND	#0007FH
		SEC
		SBC	#00040H
		BPL	MPACW_S0_S0100

		INC	ENMUKI,X
		INC	ENMUKI,X

MPACW_S0_S0100	EQU	$
		CLC
		ADC	ENXPSL,Y
		STA	ENXPSL,X

		PLA
		PHA
		XBA
		AND	#0001FH		;FF70-FF8F
		CLC
		ADC	#0FF70H
		STA	ENYSPD,X
		LDA	#00080H
		STA	ENGMAX,X
		LDA	#00002H
		STA	ENGPOW,X

		PLA
		XBA
		AND	#00003H
		CLC
		ADC	#00004
		STA	ENWRK6,X

		INC	<ENWRK2,X

		RTS
;
MPACW_S01_XREV	EQU	$
		WORD	00010H,00030H
;
MPACW_S0_S1	EQU	$
		TYX

		STZ	ENMUKI,X
		LDA	<RANDM0
		AND	#0003FH
		CLC
		ADC	#00040H
		LDY	<ENWRK0,X
		LDA	ENXSPD,Y
		STA	R0
		M_CHIP	MULTIPLY
		LDX	<ENINDX
		LDA	R0
		CMP	#00400H
		BMI	MPACW_S0_S1040

		LDA	#00400H

MPACW_S0_S1040	EQU	$
		CMP	#0FC00H
		BPL	MPACW_S0_S1080

		LDA	#0FC00H

MPACW_S0_S1080	EQU	$
		STA	ENXSPD,X
		BMI	MPACW_S0_S1100

		LDA	#00002
		STA	ENMUKI,X

MPACW_S0_S1100	EQU	$
		LDX	#000
		LDA	ENXPSL,Y
		LDY	MPACKIDX
		SEC
		SBC	ENXPSL,Y
		BPL	MPACW_S0_S1200

		INX
		INX

MPACW_S0_S1200	EQU	$
		LDA	<RANDM0
		PHA
		AND	#0003FH
		SEC
		SBC	!MPACW_S01_XREV,X
		LDX	<ENINDX
		LDY	<ENWRK0,X
		CLC
		ADC	ENXPSL,Y
		STA	ENXPSL,X

		LDY	MPACKIDX
		LDA	ENWRK2,Y
		CMP	#MPACK_RMODE41
		BEQ	MPACW_S0_S1500
		CMP	#MPACK_RMODE51
		BMI	MPACW_S0_S1600
		CMP	#MPACK_RMODE53+1
		BPL	MPACW_S0_S1600

MPACW_S0_S1500	EQU	$
		PLA
		LDA	#0FE80H
		STA	ENYSPD,X
		LDA	#00003
		STA	ENWRK6,X
		LSR	A		;[ LDA	#00001 ]
		STA	ENXPOW,X

		INC	<ENWRK2,X

		RTS

MPACW_S0_S1600	EQU	$
		PLA
		PHA
		XBA
		AND	#0003FH
		CLC
		ADC	#0FF20H
		STA	ENYSPD,X
		LDA	#00100H
		STA	ENGMAX,X
		LDA	#00004H
		STA	ENGPOW,X

		PLA
		AND	#00003H
;		CLC
;		ADC	#00002
		INC	A
		INC	A
		STA	ENWRK6,X

		INC	<ENWRK2,X

		RTS
;
MPACW_SUB1	EQU	$
MPACW_SUB6	EQU	$
		TYX

		LDY	ENYSPD+1,X
		BMI	MPACW_SUB1800

		LDA	MPACKYLW		;水中に隠れた ?
		CLC				;
		ADC	#00018H			;
		CMP	ENYPSL,X		;
		BPL	MPACW_SUB1800		;  no: MPACW_SUB1800

		STA	ENYPSL,X

		LDA	ENGPOW,X
		CMP	#00010H
		BPL	MPACW_SUB1100

		LDA	<RANDM0			;次に出現するまでのストップタイマーセット
;		AND	#0003FH			;
;		CLC				;
;		ADC	#00030H			;
		AND	#0007FH			;
		CLC				;
		ADC	#00020H			;
		CMP	#00060H			;
		BMI	MPACW_SUB1010		;
						;
		LDA	#00060H			;
						;
MPACW_SUB1010	EQU	$			;
		STA	ENTIM0,X		;

MPACW_SUB1100	EQU	$
		STZ	ENYSPD,X
		STZ	ENGPOW,X
		STZ	ENXSPD,X
		STZ	ENXPOW,X

		STZ	<ENWRK2,X

MPACW_SUB1800	EQU	$
MPACW_SUB2000	EQU	$

		RTS
;
MPACW_SUB2	EQU	$
		TYX

		LDA	MPACKYLW		;所定の位置まで来た ?
		CMP	ENYPSL,X		;
		BNE	MPACW_SUB2000		; yes: MPACW_SUB2000

		STZ	ENYSPD,X

		LDY	ENCHPT,X
		BNE	MPACW_SUB2000

		LDA	#0FFFFH
		STA	ENTIM1,X

		LDY	MPACKIDX		;本体、崩れさった ?
		LDA	ENWRK2,Y		;
		CMP	#MPACK_RMODE95		;
		BMI	MPACW_SUB2000		;  no: MPACW_SUB2000

		LDA	#00010H
		STA	ENWRKA,X
		JMP	MPACW_BREAK_TIM
;
MPACW_SUB3	EQU	$
		TYX

		LDA	ENTIM0,X
		BNE	MPACW_SUB3800

		LDY	ENWRK8,X
		CPY	#004
		BNE	MPACW_SUB3500

		INC	<ENWRK2,X

		RTS

MPACW_SUB3500	EQU	$
		INC	ENWRK8,X

		LDY	ENWRK8,X
		I16
		LDA	!MPACW_OAML-1,Y
		AND	#000FFH
		CLC
		ADC	ENOAML,X
		TAY
		LDA	SOAM_DX+0+8*0,Y
		CLC
		ADC	ESCCH1
		CLC
		ADC	#00008
		STA	<EWORK0
		LDA	SOAM_DX+2+8*0,Y
		CLC
		ADC	ESCCV1
		CLC
		ADC	#00008
		STA	<EWORK2
		I8

		JSR	MPACK_MPKBR_SET

		LDA	<RANDM0
;		AND	#0000FH
		AND	#00007H
		CLC
		ADC	ENWRKA,X
		STA	ENTIM0,X
		LDA	ENWRKA,X
		LSR	A
		STA	ENWRKA,X

MPACW_SUB3800	EQU	$

		RTS
;
;****************************************************************
;*			ＯＡＭデータ				*
;****************************************************************
MPACK_CHAR_ADR	EQU	$
		WORD	MPACK_C_0
		WORD	MPACK_C_1
		WORD	MPACK_C_2
		WORD	MPACK_C_3
		WORD	MPACK_C_4
		WORD	MPACK_C_5
		WORD	MPACK_C_6
		WORD	MPACK_C_7
		WORD	MPACK_C_8
		WORD	MPACK_C_9
		WORD	MPACK_C_A
		WORD	MPACK_C_B
;
MPACK_CHAR	EQU	$
MPACK_C_0	EQU	$
		BYTE	0F6H,0FCH	;[00]
		HEX	20,00,02
		BYTE	000H,004H
		HEX	08,C0,02
		BYTE	000H,0F4H
		HEX	08,40,02
		BYTE	009H,0EAH
		HEX	08,80,02
		BYTE	009H,0DAH
		HEX	08,00,02
;
MPACK_C_1	EQU	$
		BYTE	0F7H,0FBH	;[01]
		HEX	0E,00,02
		BYTE	001H,0F4H
		HEX	28,C0,02
		BYTE	008H,0D9H
		HEX	28,80,02
		BYTE	008H,0E9H
		HEX	28,00,02
		BYTE	001H,004H
		HEX	28,40,02
;
MPACK_C_2	EQU	$
		BYTE	0F8H,0FAH	;[02]
		HEX	2C,00,02
		BYTE	002H,0F4H
		HEX	22,40,02
		BYTE	007H,0D7H
		HEX	22,00,02
		BYTE	007H,0E7H
		HEX	22,80,02
		BYTE	002H,004H
		HEX	22,C0,02
;
MPACK_C_3	EQU	$
		BYTE	0F8H,0FBH	;[03]
		HEX	20,00,02
		BYTE	001H,0F4H
		HEX	28,C0,02
		BYTE	008H,0D9H
		HEX	28,80,02
		BYTE	008H,0E9H
		HEX	28,00,02
		BYTE	001H,004H
		HEX	28,40,02
;
MPACK_C_4	EQU	$
		BYTE	0FCH,0FAH	;[04]
		HEX	2E,00,02
		BYTE	002H,0F4H
		HEX	22,40,02
		BYTE	007H,0D7H
		HEX	22,00,02
		BYTE	007H,0E7H
		HEX	22,80,02
		BYTE	002H,004H
		HEX	22,C0,02
;
MPACK_C_5	EQU	$
		BYTE	001H,0FAH	;[05]
		HEX	2E,00,02
		BYTE	004H,0F4H
		HEX	24,40,02
		BYTE	005H,0D6H
		HEX	24,00,02
		BYTE	005H,0E6H
		HEX	24,80,02
		BYTE	004H,004H
		HEX	24,C0,02
;
MPACK_C_6	EQU	$
		BYTE	0F5H,0FCH	;[06]
		HEX	20,00,02
		BYTE	0FFH,004H
		HEX	08,C0,02
		BYTE	0FFH,0F4H
		HEX	08,40,02
		BYTE	008H,0EAH
		HEX	08,80,02
		BYTE	008H,0DAH
		HEX	08,00,02
;
MPACK_C_7	EQU	$
		BYTE	0F6H,0FBH	;[07]
		HEX	0E,00,02
		BYTE	000H,0F4H
		HEX	28,C0,02
		BYTE	007H,0D9H
		HEX	28,80,02
		BYTE	007H,0E9H
		HEX	28,00,02
		BYTE	000H,004H
		HEX	28,40,02
;
MPACK_C_8	EQU	$
		BYTE	0F7H,0FAH	;[08]
		HEX	2C,00,02
		BYTE	001H,0F4H
		HEX	22,40,02
		BYTE	006H,0D7H
		HEX	22,00,02
		BYTE	006H,0E7H
		HEX	22,80,02
		BYTE	001H,004H
		HEX	22,C0,02
;
MPACK_C_9	EQU	$
		BYTE	0F5H,0FCH	;[09]
		HEX	20,00,02
		BYTE	0FFH,004H
		HEX	08,C0,02
		BYTE	0FFH,0F4H
		HEX	08,40,02
		BYTE	008H,0EAH
		HEX	08,80,02
		BYTE	008H,0DAH
		HEX	08,00,02
;
MPACK_C_A	EQU	$
		BYTE	0F6H,0FBH	;[0A]
		HEX	0E,00,02
		BYTE	000H,0F4H
		HEX	28,C0,02
		BYTE	007H,0D9H
		HEX	28,80,02
		BYTE	007H,0E9H
		HEX	28,00,02
		BYTE	000H,004H
		HEX	28,40,02
;
MPACK_C_B	EQU	$
		BYTE	0F7H,0FAH	;[0B]
		HEX	2C,00,02
		BYTE	001H,0F4H
		HEX	22,40,02
		BYTE	006H,0D7H
		HEX	22,00,02
		BYTE	006H,0E7H
		HEX	22,80,02
		BYTE	001H,004H
		HEX	22,C0,02
;
;
MPACH_CHAR_ADR	EQU	$
		WORD	MPACH_C_00
		WORD	MPACH_C_01
		WORD	MPACH_C_02
		WORD	MPACH_C_03
		WORD	MPACH_C_04
		WORD	MPACH_C_05
		WORD	MPACH_C_06
		WORD	MPACH_C_07
		WORD	MPACH_C_08
		WORD	MPACH_C_09
		WORD	MPACH_C_0A
		WORD	MPACH_C_0B
		WORD	MPACH_C_0C
		WORD	MPACH_C_0D
		WORD	MPACH_C_0E
		WORD	MPACH_C_0F
		WORD	MPACH_C_10
		WORD	MPACH_C_11
		WORD	MPACH_C_12
		WORD	MPACH_C_13
		WORD	MPACH_C_14
		WORD	MPACH_C_15
		WORD	MPACH_C_16
		WORD	MPACH_C_17
		WORD	MPACH_C_18
		WORD	MPACH_C_19
;
MPACH_C_00	EQU	$
		BYTE	001H,000H	;[00]
		HEX	26,00,02
		BYTE	000H,00CH
		HEX	3B,40,00
		BYTE	008H,00CH
		HEX	3A,40,00
;
MPACH_C_01	EQU	$
		BYTE	000H,0FEH	;[01]
		HEX	26,00,02
		BYTE	000H,00CH
		HEX	0D,C0,00
		BYTE	008H,00CH
		HEX	0C,C0,00
;
MPACH_C_02	EQU	$
		BYTE	000H,0FBH	;[02]
		HEX	26,00,02
		BYTE	000H,004H
		HEX	0A,C0,02
;
MPACH_C_03	EQU	$
		BYTE	0FFH,0F6H	;[03]
		HEX	26,00,02
		BYTE	000H,004H
		HEX	2A,40,02
;
MPACH_C_04	EQU	$
		BYTE	0FFH,0F2H	;[04]
		HEX	26,00,02
		BYTE	000H,0FCH
		HEX	1D,40,00
		BYTE	008H,0FCH
		HEX	1C,40,00
		BYTE	000H,004H
		HEX	0C,C0,02
;
MPACH_C_05	EQU	$
		BYTE	0FFH,0EEH	;[05]
		HEX	26,00,02
		BYTE	008H,0FCH
		HEX	2A,C0,00
		BYTE	000H,0FCH
		HEX	2B,C0,00
		BYTE	000H,004H
		HEX	0A,C0,02
;
MPACH_C_06	EQU	$
		BYTE	000H,0ECH	;[06]
		HEX	26,00,02
		BYTE	000H,004H
		HEX	08,C0,02
		BYTE	000H,0F4H
		HEX	08,40,02
;
MPACH_C_07	EQU	$
		BYTE	002H,0E9H	;[07]
		HEX	26,00,02
		BYTE	000H,004H
		HEX	2A,40,02
		BYTE	000H,0F4H
		HEX	0A,40,02
;
MPACH_C_08	EQU	$
		BYTE	005H,0E7H	;[08]
		HEX	26,00,02
		BYTE	000H,0F4H
		HEX	0C,40,02
		BYTE	00FH,0F3H
		HEX	0B,80,00
		BYTE	000H,004H
		HEX	0C,C0,02
;
MPACH_C_09	EQU	$
		BYTE	006H,0E5H	;[09]
		HEX	26,00,02
		BYTE	011H,0F2H
		HEX	0B,80,00
		BYTE	009H,0F2H
		HEX	0A,80,00
		BYTE	000H,004H
		HEX	0A,C0,02
		BYTE	000H,0F4H
		HEX	2A,C0,02
;
MPACH_C_0A	EQU	$
		BYTE	008H,0E3H	;[0A]
		HEX	26,00,02
		BYTE	000H,004H
		HEX	08,C0,02
		BYTE	000H,0F4H
		HEX	08,40,02
		BYTE	011H,0F2H
		HEX	09,80,00
		BYTE	009H,0F2H
		HEX	08,80,00
;
MPACH_C_0B	EQU	$
		BYTE	000H,0F4H	;[0B]
		HEX	0A,40,02
		BYTE	009H,0E1H
		HEX	26,00,02
		BYTE	009H,0EAH
		HEX	2A,00,02
		BYTE	000H,004H
		HEX	2A,40,02
;
MPACH_C_0C	EQU	$
		BYTE	00AH,0DEH	;[0C]
		HEX	26,00,02
		BYTE	009H,0EAH
		HEX	0C,80,02
		BYTE	000H,004H
		HEX	0C,C0,02
		BYTE	000H,0F4H
		HEX	0C,40,02
;
MPACH_C_0D	EQU	$
		BYTE	00AH,0DBH	;[0D]
		HEX	26,00,02
		BYTE	009H,0EAH
		HEX	0A,80,02
		BYTE	000H,004H
		HEX	0A,C0,02
		BYTE	000H,0F4H
		HEX	2A,C0,02
;
MPACH_C_0E	EQU	$
		BYTE	00AH,0D8H	;[0E]
		HEX	26,00,02
		BYTE	009H,0EAH
		HEX	08,80,02
		BYTE	009H,0E2H
		HEX	18,00,02
		BYTE	000H,004H
		HEX	08,C0,02
		BYTE	000H,0F4H
		HEX	08,40,02
;
MPACH_C_0F	EQU	$
		BYTE	009H,0D5H	;[0F]
		HEX	26,00,02
		BYTE	009H,0EAH
		HEX	2A,00,02
		BYTE	009H,0E2H
		HEX	1A,00,02
		BYTE	000H,004H
		HEX	2A,40,02
		BYTE	000H,0F4H
		HEX	0A,40,02
;
MPACH_C_10	EQU	$
		BYTE	009H,0EAH	;[10]
		HEX	0C,80,02
		BYTE	008H,0D2H
		HEX	26,00,02
		BYTE	000H,004H
		HEX	0C,C0,02
		BYTE	000H,0F4H
		HEX	0C,40,02
		BYTE	009H,0DAH
		HEX	0C,00,02
;
MPACH_C_11	EQU	$
		BYTE	009H,0EAH	;[11]
		HEX	0A,80,02
		BYTE	006H,0CFH
		HEX	26,00,02
		BYTE	000H,004H
		HEX	0A,C0,02
		BYTE	000H,0F4H
		HEX	2A,C0,02
		BYTE	009H,0DAH
		HEX	2A,80,02
;
MPACH_C_12	EQU	$
		BYTE	000H,0F4H	;[12]
		HEX	08,40,02
		BYTE	004H,0CDH
		HEX	26,00,02
		BYTE	009H,0DAH
		HEX	08,00,02
		BYTE	009H,0EAH
		HEX	08,80,02
		BYTE	000H,004H
		HEX	08,C0,02
;
MPACH_C_13	EQU	$
		BYTE	004H,0CCH	;[13]
		HEX	26,00,02
		BYTE	001H,004H
		HEX	28,40,02
		BYTE	001H,0F4H
		HEX	28,C0,02
		BYTE	008H,0D9H
		HEX	28,80,02
		BYTE	008H,0E9H
		HEX	28,00,02
;
MPACH_C_14	EQU	$
		BYTE	004H,0CAH	;[14]
		HEX	26,00,02
		BYTE	002H,004H
		HEX	22,C0,02
		BYTE	002H,0F4H
		HEX	22,40,02
		BYTE	007H,0D7H
		HEX	22,00,02
		BYTE	007H,0E7H
		HEX	22,80,02
;
MPACH_C_15	EQU	$
		BYTE	004H,0C9H	;[15]
		HEX	26,00,02
		BYTE	004H,004H
		HEX	24,C0,02
		BYTE	004H,0F4H
		HEX	24,40,02
		BYTE	005H,0D6H
		HEX	24,00,02
		BYTE	005H,0E6H
		HEX	24,80,02
;
MPACH_C_16	EQU	$
		BYTE	004H,0C9H	;[16]
		HEX	26,40,02
		BYTE	004H,004H
		HEX	24,80,02
		BYTE	004H,0F4H
		HEX	24,00,02
		BYTE	003H,0D6H
		HEX	24,40,02
		BYTE	003H,0E6H
		HEX	24,C0,02
;
MPACH_C_17	EQU	$
		BYTE	004H,0CAH	;[17]
		HEX	26,40,02
		BYTE	006H,004H
		HEX	22,80,02
		BYTE	006H,0F4H
		HEX	22,00,02
		BYTE	001H,0D7H
		HEX	22,40,02
		BYTE	001H,0E7H
		HEX	22,C0,02
;
MPACH_C_18	EQU	$
		BYTE	004H,0CCH	;[18]
		HEX	26,40,02
		BYTE	007H,004H
		HEX	28,00,02
		BYTE	007H,0F4H
		HEX	28,80,02
		BYTE	000H,0D9H
		HEX	28,C0,02
		BYTE	000H,0E9H
		HEX	28,40,02
;
MPACH_C_19	EQU	$
		BYTE	0FFH,0EAH	;[19]
		HEX	08,C0,02
		BYTE	004H,0CDH
		HEX	26,40,02
		BYTE	008H,004H
		HEX	08,80,02
		BYTE	008H,0F4H
		HEX	08,00,02
		BYTE	0FFH,0DAH
		HEX	08,40,02
;
		END
;
;
;
;
;
;
;
;
