
;************************************************************************
;*									*
;*	title name	: "yossy"					*
;*	proccess	: enemy sub					*
;*	file name	: ys_enmy14					*
;*									*
;************************************************************************
;
;
		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
		include		../union/ys_bgcheck.h
;
		XALL
;
;
;------------------------------------------------------------------------
;-		global symbol						-
;------------------------------------------------------------------------
		GLB	QSPAKIN
		GLB	QSPAKMV
		GLB	PUCHGIN
		GLB	PUCHBIN
		GLB	BOSSQIN
		GLB	BOSSKIN
;;		  GLB	  SESAWIN
;
		GLB	PUCHGMV
		GLB	PUCHBMV
		GLB	BOSSQMV,B_LOOP
		GLB	BOSSKMV
;;;		   GLB	   SESAWMV
;---- lavel ---
		GLB	PBBY
;------------------------------------------------------------------------
;-		extern symbol						-
;------------------------------------------------------------------------
;
;-------------< ys_main >------------------------------------------------
		EXT	SOUND_1_ON
		EXT	SOUND_3_ON
		EXT	GO_NEXTGOTO
		EXT	BS_SCRE
;-------------< ys_rpro >------------------------------------------------
		EXT	JSRSUB
		EXT	CHIPON
;
;-------------< ys_play >------------------------------------------------
		EXT	PFAL,PSTP,PMOV,PDEM,PGOL
		EXT	PFLP,PBSQ,PBQ7
;
;-------------< 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	COS,SIN
;
		EXT	EATMXS,NOSWT
;
		EXT	EGGKILL_ALL
;
		EXT	COLBL_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,TROBJ_SR_8x4,TROBJ_OAM_8x4_I
		EXT	TROBJ_PLOT_X,TROBJ_PLOT_Y
		EXT	KAMC2COLRESET_L,Kati
;
;-------------< ys_enmy2 >------------------------------------------------
		EXT	PUCHACONT_CK2
;-------------< ys_enmy3 >------------------------------------------------
		EXT	BOSS_CLEAR_M,BOSS_CLEAR
		EXT	BSCLW_SET_B,BSCLW_SET_M
		EXT	BOSS_EN_CHANGE,BSCLW_SET_B_T
;
;-------------< ys_enmy9 >------------------------------------------------
		EXT	DOROBOUCANCEL
;
;-------------< ys_exst >------------------------------------------------
		EXT	EXINSR
		EXT	BSQKR,TEN_2
;
;-------------< ys_init >------------------------------------------------
		EXT	UNCOMPRES,VRAMDX_ST,VRAMDX_H_ST,VRAMDX_L_ST,VRAMDX_L_C_ST
		EXT	M_DMA_BFST
;
;-------------< ys_game >------------------------------------------------
		EXT	BOSSQ_MD7_SET
;
;------------------------------------------------------------------------
;-		define symbol						-
;------------------------------------------------------------------------
SANGLE		EQU	BSWRK5
SAPOWR		EQU	BSWRK3
SAPOWR2		EQU	BSWRK4
BSASPD2		EQU	BSWRK2
;************************************************************************
;*									*
;*		program start						*
;*									*
;************************************************************************
;
		EXTEND
;
		MEM16
		IDX8
;
		DPAGE	EN0RAM
;
Group_F		GROUP	Morita_pro
Morita_pro	SECT	REL
;
;
;************************************************************************
;*		initial ( ジャイアント プチプチ )			*
;************************************************************************
PUCHGIN		EQU	$
;
;-------------- ジャイアントプチプチの転送エリア確保 --------------------
		JSL	>TROBJ_SR_8x4
		BCS	PCGI010		;エリア確保？ ( yes:PCGI010)
;
		JMP	>ENCLEAR
;
PCGI010		EQU	$
;
		JSR	PGCHTR	  ; Chr TR. initial
;
		LDA	#100H
		STA	ENWRKA,X  ; 倍率  x
		STA	ENWRKC,X  ; 倍率  y
;
		RTL
;************************************************************************
;*		move	( ジャイアント プチプチ )			*
;************************************************************************
PUCHGMV		EQU	$
;
		STZ	ENSHOT,X
;
;-------------- ジャイアントプチプチのＯＡＭセット ----------------------
;
		I16
;
		LDA	ENOAML,X
		BMI	PCGC010		   ;ＯＡＭセットＯＫ？ ( no:PCBC010 )
;
		CLC
		ADC	#6*8
		PHA			;(A) save
		TAY
		JSL	>TROBJ_OAM_8x4_I
;
		I16
;
		PLA			;(A) load
		CLC
		ADC	#8*8
		TAY
		JSL	>TROBJ_OAM_8x4_I
;
PCGC010		EQU	$
;
		I8
;
		LDA	ENTIM2,X
		BNE	PCGC020		; Protect time !
;
		LDA	<ENWRK2,X
		CMP	#PGFL
		BEQ	PCGC020
;
		JSR	CRPGEGG
;
		JSL	>EPCRCK2
		JSR	PGFLCK
PCGC020		EQU	$
		JSL	>ENMDCK
;
		JSR	PGMOVE	; move sub
;
		JSR	CRENEN	; Vs enemy check
;
		JSR	ENBGCK
;
		JSR	PGCHTR	 ; Chr TR.
		RTL
;-------------------------------------------------
EPCRCK2		EQU	$
		JSL	>EPCRCK
		RTL
;=================================================
;=						 =
;=================================================
ENBCXR		EQU	$
		WORD	0FFFFH,00001H
;
ENBGCK		EQU	$
		M8
;
		LDA	ENCBFG,X
		AND	#00001100B
		M16
		BEQ	EBCK010
;
		LSR	A
		LSR	A
		AND	#02H
		TAY
		LDA	ENXPSL,X
		CLC
		ADC	ENBCXR,Y
		STA	ENXPSL,X
;
		LDA	<ENWRK2,X
		CMP	#PBBY
		BNE	PGTUST
;
		LDA	ENWRK6,X
		BEQ	PGTUST	 ; High speed hanekaeri ?
;				 ; yes !
		LDA	ENXSPD,X
		EOR	#0FFFFH
		INC	A
		STA	ENXSPD,X
		BRA	EBCK010
;
PGTUST		EQU	$
		LDA	<ENWRK2,X
		CMP	#PGBY
		BNE	PGTS010
;
		STZ	ENXSPD,X
		BRA	EBCK010
;
PGTS010		EQU	$
		LDA	#PGTU
		STA	<ENWRK2,X
;
		LDA	#04H*06
		STA	ENTIM0,X
;
		LDY	ENMUKI,X
		LDA	PGTXSD,Y
		STA	ENXSPD,X
;
EBCK010		EQU	$
		RTS
;=================================================
;=						 =
;=================================================
PGTXSD		EQU	$
		WORD	00020H,0FFE0H
;
CREE090J	EQU	$
		RTS
;
CRENEN		EQU	$
;;		  RTS
;
		LDY	ECRSFG,X
		BEQ	CREE090J
		BMI	CREE090J
		DEY
;
		LDA	ENMYNO,Y
		CMP	#PUCHG
		BEQ	CREE010
		CMP	#PUCHB
		BNE	CREE090J
;
CREE010		EQU	$
		STZ	<EWORK0
;
		LDA	ENXPSL,X
		SEC
		SBC	ENXPSL,Y
		BPL	CREE012
;
		INC	<EWORK0
		INC	<EWORK0
CREE012		EQU	$
		LDA	<ENWRK2,X
		CMP	#PGWK
		BEQ	CREE013
		CMP	#PGBY
		BNE	CREE020
;
		LDA	ENWRK6,X
		BEQ	CREE020
;
		STZ	ENWRK6,X
;
		LDA	ENXSPD,X
		STZ	ENXSPD,X
		STA	ENXSPD,Y
;
		JSR	PGBYST
;
		LDA	#PGBY
		STA	ENWRK2,Y
;
		LDA	#01H
		STA	ENWRK6,Y
;
		LDA	#0FFH
		STA	ENTIM0,Y
;
		BRA	CREE020
CREE013		EQU	$
;;		  CMP	  #PGTU
;;		  BCS	  CREE020
;
		LDA	ENCBFG,X
		AND	#01H
		BNE	CREE018
;
		LDA	#0FD00H
		STA	ENYSPD,X
;
		LDA	ENXSPD,X
		EOR	#0FFFFH
		INC	A
		STA	ENXSPD,X
;
		DEC	ENYPSL,X
		DEC	ENYPSL,X
;
;;		  PHY
		JSR	PGBYST
;;		  PLY
;
		PHX
		TYX
		JSR	PGBYST
		PLX
		BRA	CREE090
;
CREE018		EQU	$
		LDA	ENMUKI,X
		CMP	<EWORK0
		BNE	CREE020
;
		PHY
		JSR	PGTUST
		PLY
;
CREE020		EQU	$
		LDA	ENWRK2,Y
		CMP	#PGWK
		BEQ	CREE030
;
		CMP	#PGBY
		BNE	CREE090
;
		LDA	ENWRK6,Y
		BEQ	CREE090
;
		LDA	ENXSPD,Y
		STA	ENXSPD,X
;
		LDA	#01H
		STA	ENWRK6,X
;
		LDA	#PGBY
		STA	<ENWRK2,X
;
		LDA	#0FFH
		STA	ENTIM0,X
;
		LDA	#00H
		STA	ENWRK6,Y
		STA	ENXSPD,Y
;
		PHX
		TYX
		JSR	PGBYST
		PLX
		BRA	CREE090
CREE030		EQU	$
;;		  CMP	  #PGTU
;;		  BCS	  CREE090
;
CREE050		EQU	$
		LDA	ENMUKI,Y
		CMP	<EWORK0
		BEQ	CREE090
;
		PHX
		TYX
		JSR	PGTUST
		PLX
CREE090		EQU	$
		RTS
;=================================================
;=						 =
;=================================================
PGMOVE		EQU	$
;		 M8
;;
;		 LDA	 KEYA2L
;		 AND	 #010H
;		 BEQ	 PGM010
;;
;		 LDA	 <ENWRK2,X
;		 CMP	 #PGFL
;		 BEQ	 PGM010
;;
;;		  LDA	  #PGBY
;;		  STA	  <ENWRK2,X
;;;
;;		  LDA	  #020H
;;		  STA	  ENTIM0,X
;;
;		 STZ	 ENCONT,X
;;
;		 LDA	 #PGFL
;		 STA	 <ENWRK2,X
;;
;PGM010		 EQU	 $
;		 M16
;
		LDA	<ENWRK2,X
		ASL	A
		TXY
		TAX
		JMP	(PGADRS,X)
;= = = = = = = = = = = = = = = = = = = = = = = = =
PGADRS		EQU	$
		WORD	PGWALK
		WORD	PGTURN
		WORD	PGBYON
		WORD	PGFAIL
;- - - - - - - - - - - - - - - - - - - - -
PGWK		EQU	00
PGTU		EQU	01
PGBY		EQU	02
PGFL		EQU	03
;=================================================
PGWXSD		EQU	$
		WORD	0FF80H,0080H
PGWPTD		EQU	$
		HEX	0,1,2,3,4,5,4,3,2,1
;
PGWALK		EQU	$
		TYX
;
		LDA	ENCBFG,X
		AND	#001H
		BEQ	PGW000
;
		LDY	ENMUKI,X
		LDA	PGWXSD,Y
		STA	ENXSPD,X
;
PGW000		EQU	$
		M8
;;		  LDA	  FRCNT
		DEC	ENWRK8,X
		BPL	PGW010
;
		LDA	#07H
		STA	ENWRK8,X
;
		INC	<ENCONT,X
		LDA	<ENCONT,X
		CMP	#0AH
		BNE	PGW010
;
		STZ	<ENCONT,X
PGW010		EQU	$
		LDY	<ENCONT,X
		LDA	PGWPTD,Y
		STA	ENCHPT,X
;
;		 CMP	 #00H
;		 BNE	 PGW020
;;
;		 JSR	 EPXCHK
;		 TYA
;		 CMP	 ENMUKI,X
;		 BEQ	 PGW020
;;
;		 LDA	 #PGTU
;		 STA	 <ENWRK2,X
;;
;		 LDA	 #04H*06
;		 STA	 ENTIM0,X
PGW020		EQU	$
		M16
		RTS
;=================================================
PGTUPT		EQU	$
		HEX	0,6,7,7,6,0,0
;- - - - - - - - - - - - - - - - - - - - - -
PGTURN		EQU	$
		TYX
;
;;		  STZ	  ENXSPD,X
;
		LDA	ENTIM0,X
		BNE	PGT010
;
PGWKST		EQU	$
		LDA	#PGWK
		STA	<ENWRK2,X
;
		STZ	<ENCONT,X  ; walk counter clear
		RTS
PGT010		EQU	$
		M8
;
		CMP	#0BH
		BNE	PGT020
;
		PHA
		LDA	ENMUKI,X
		EOR	#02H
		STA	ENMUKI,X
		PLA
PGT020		EQU	$
		LSR	A
		LSR	A
		TAY
		LDA	PGTUPT,Y
		STA	ENCHPT,X
;
		M16
		RTS
;=================================================
PGBYXA		EQU	$
		WORD	0100H,0108H,0110H,0118H
		WORD	0118H,0110H,0108H,0100H
;;		  WORD	  0100H,00F8H,00F0H,00E8H
;;		  WORD	  00E8H,00F0H,00E8H,0100H
PGBYYA		EQU	$
		WORD	0100H,00F8H,00F0H,00E8H
		WORD	00E8H,00F0H,00E8H,0100H
		WORD	0100H,0108H,0110H,0118H
		WORD	0118H,0110H,0108H,0100H
;
PGBYON		EQU	$
		TYX
;
		LDA	ENCBFG,X
		AND	#01H
		BEQ	PGBY008
;
;;		  STZ	  ENXSPD,X
		JSR	BSXDOWN2
		JSR	BSXDOWN2
		JSR	BSXDOWN2
		JSR	BSXDOWN2
PGBY008		EQU	$
		LDA	ENTIM0,X
		BNE	PGBY010
;
PGRET		EQU	$
		LDA	#0100H
		STA	ENWRKA,X
		STA	ENWRKC,X
;
		JMP	PGWKST
PGBY010		EQU	$
		NOP
		NOP
		AND	#07H
		ASL	A
		ASL	A
		TAY
		LDA	PGBYXA,Y
		STA	ENWRKA,X
		LDA	PGBYYA,Y
		STA	ENWRKC,X
;
		I16
		LDA	ENOAML,X
		TXY
		CLC
		ADC	#018H
		TAX
;
		LDA	ENTIM0,Y
		BIT	#02H
		BEQ	PGBY060
		AND	#04H
		BEQ	PGBY050
;
		INC	SOAM_DX+002H,X
		INC	SOAM_DX+00AH,X
		INC	SOAM_DX+012H,X
		BRA	PGBY060
PGBY050		EQU	$
		DEC	SOAM_DX+002H,X
		DEC	SOAM_DX+00AH,X
		DEC	SOAM_DX+012H,X
PGBY060		EQU	$
		I8
		LDX	<ENINDX
		RTS
;=================================================
PGFLXA		EQU	$
		WORD	107H
		WORD	10EH
		WORD	115H
		WORD	11CH
		WORD	123H
		WORD	12AH
		WORD	131H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
PGFLYA		EQU	$
		WORD	0E9H
		WORD	0D2H
		WORD	0BBH
		WORD	0A4H
		WORD	08DH
		WORD	076H
		WORD	05FH
		WORD	048H
		WORD	048H
		WORD	048H
		WORD	048H
		WORD	048H
		WORD	048H
		WORD	048H
		WORD	048H
PGFLYD		EQU	$
		WORD	000H
		WORD	004H
		WORD	005H
		WORD	008H
		WORD	00BH
		WORD	00DH
		WORD	010H
		WORD	014H
		WORD	014H
		WORD	014H
		WORD	014H
		WORD	014H
		WORD	014H
		WORD	014H
		WORD	014H
;
PGFLPT		EQU	$
		WORD	8,8,9,0AH,0AH,0BH,0CH
		WORD	0CH
		WORD	0CH
		WORD	0CH
		WORD	0CH
		WORD	0CH
		WORD	0CH
		WORD	0CH
		WORD	0CH
;
PGFLPY		EQU	$
		WORD	0FFD8H
		WORD	0FFDCH
		WORD	0FFE0H
		WORD	0FFE4H
		WORD	0FFE8H
		WORD	0FFECH
		WORD	0FFF2H
		WORD	0FFF7H
		WORD	0FFF7H
		WORD	0FFF7H
		WORD	0FFF7H
		WORD	0FFF7H
		WORD	0FFF7H
		WORD	0FFF7H
		WORD	0FFF7H
PGFAIL		EQU	$
		TYX
;
		STZ	ENXSPD,X
;
		LDY	<ENCONT,X
		CPY	#(08H+7)*2
		BEQ	PGF020
;
		LDA	FRCNT
		AND	#01H
		BNE	PGF010
;
		INC	<ENCONT,X
		INC	<ENCONT,X
PGF010		EQU	$
		LDA	PGFLXA,Y
		STA	ENWRKA,X
		LDA	PGFLYA,Y
		STA	ENWRKC,X
		LDA	PGFLPT,Y
		STA	ENCHPT,X
;
		LDA	ENYPSL,X
		CLC
		ADC	PGFLPY,Y
		STA	PLYPSL
;
		STZ	PLYSPD
;
		LDA	PGFLYD,Y
		STA	<EWORK0
;
		I16
;
		LDA	#00FH
		STA	<EWORK2
;
		LDY	ENOAML,X
PGF018		EQU	$
		LDA	SOAM_DX+002H+(6*8),Y
		CLC
		ADC	<EWORK0
		STA	SOAM_DX+002H+(6*8),Y
;
		TYA
		CLC
		ADC	#0008H
		TAY
;
		DEC	<EWORK2
		BPL	PGF018
;
		I8
		RTS
;- - - - - - - - - - - - -
PGF020		EQU	$
		STZ	PLDOSN
;
		LDA	#86H
		JSL	>SOUND_3_ON	;(S)
;
		JSR	PUCHBST
;
		JSL	>ENCLEAR_NORETN
;
;
;
;
;
;
		RTS
;		 LDA	 #20H
;		 STA	 ENTIM2,X
;;
;		 JMP	 PGRET
;=================================================
PBSXSD		EQU	$
		WORD	0100H,0FF00H
PBSXAD		EQU	$
		WORD	0010H,0FFF0H
PBSMKI		EQU	$
		WORD	0002H,00000H
;
PUCHBST		EQU	$
		LDA	#BG3EX
		JSL	>ENINSR
		BCC	PCBS002
;
		LDA	#02H
		STA	ENCONT,Y
;
		LDA	#01H
		STA	ENWRK2,Y
;
		LDA	ECENTX,X
		STA	ENXPSL,Y
;
		LDA	ECENTY,X
		STA	ENYPSL,Y
PCBS002		EQU	$
		LDA	ECENTX,X
		STA	R1
		LDA	ECENTY,X
		STA	R2
		LDA	#0050H
		STA	R10
		LDA	#0400H
		STA	CCWORK0
		LDA	#0FC00H
		STA	CCWORK1
;
		M_CHIP	PONTA_BOMB     ; Bakuhatsu hit check !
		LDX	<ENINDX
;
		LDA	#03BH
		JSL	>SOUND_3_ON    ;(S)
;
		LDA	#02H
		STA	<EWORK8
;
		LDA	ENXPSL,X
		STA	<EWORK0
		LDA	ENYPSL,X
		STA	<EWORK2
;
PCBS010		EQU	$
		LDA	#PUCHB
		JSL	>ENINSR
		BCC	PCBS090
;
		LDX	<EWORK8
;
		LDA	<EWORK0
		CLC
		ADC	PBSXAD,X
		STA	ENXPSL,Y
;
		LDA	PBSXSD,X
		STA	ENXSPD,Y
;
		LDA	PBSMKI,X
		STA	ENMUKI,Y
;
		LDA	#0FD00H
		STA	ENYSPD,Y
;
		LDA	<EWORK2
		CLC
		ADC	#000H
		STA	ENYPSL,Y
;
		LDA	#20H
		STA	ENTIM2,Y	; protect time !
;
		LDA	#030H
		STA	ENTIM0,Y
;
;		 LDA	 #PBBY
;		 STA	 ENWRK2,Y
;
		LDA	ENMOD2,Y
		AND	#1111111111110011B
		STA	ENMOD2,Y
;
		LDX	<ENINDX
;
		DEC	<EWORK8
		DEC	<EWORK8
		BPL	PCBS010
PCBS090		EQU	$
		RTS
;=================================================
;=================================================
;=================================================
;=================================================
;=================================================
;=================================================
CRPGEGG		EQU	$
		LDY	ECRSFG,X
;;		  BMI	  PGP010
		DEY
		BMI	CPG010
;
		LDA	ENMODE,Y
		CMP	#EMOVE
		BNE	CPG010
;
		LDA	ENSHOT,Y
		BEQ	CPG010
;
		LDA	<ENWRK2,X
		CMP	#PGBY  ;(PBBY)
		BEQ	CPG010
;
		LDA	#PGBY  ;(PBBY)
		STA	<ENWRK2,X
;
		PHY
		LDA	#34H
		JSL	>SOUND_3_ON	;(S)
		PLY
;
		LDA	#020H
		STA	ENTIM0,X
;
		LDA	ENMYNO,X
		CMP	#PUCHB
		BNE	CPG008
;
		LDA	ENXSPD,Y
		STA	ENXSPD,X
		LDA	ENYSPD,Y
		STA	ENYSPD,X
;
		LDA	#0FFH
		STA	ENTIM0,X
;
		INC	ENWRK6,X  ; Bottobi !
;
CPG008		EQU	$
;;		  M16
;
		LDY	ECRSFG,X
		DEY
		TYX
		JSL	>SHOT_EN_KILL
;
		LDX	<ENINDX
CPG010		EQU	$
		RTS
;;----------------------------------------------
;PGP010		 EQU	 $
;		 JSL	 >PLFLST
;		 RTS
;=================================================
PGFLCK		EQU	$
		LDA	ENMODE,X
		CMP	#EFAIL
		BNE	PGFC90
;
		LDA	#EMOVE
		STA	ENMODE,X
;
		LDA	PLDOSN
		BNE	PGFC10
;
		LDA	#PGBY
		STA	<ENWRK2,X
;
		LDA	#020H
		STA	ENTIM0,X
;
		LDA	#0FB00H
		STA	PLYSPD
;
PGBYST		EQU	$
		LDA	#PGBY
		STA	<ENWRK2,X
;
		LDA	#020H
		STA	ENTIM0,X
;
		PHY
		LDA	#34H
		JSL	>SOUND_3_ON	;(S)
		PLY
PGFC90		EQU	$
		RTS
;
PGFC10		EQU	$
		STZ	<ENCONT,X
;
		LDA	#PGFL
		STA	<ENWRK2,X
;
		LDA	ENMOD0,X
		AND	#1111100111111111B ; Obj hit noth.
		STA	ENMOD0,X
		RTS
;=================================================
;=================================================
;=================================================
;=================================================
;=						 =
;=================================================
PGCHTR		EQU	$
;-------------- ジャイアントプチプチの胴体上キャラクターセット ----------
;;		  LDA	  #0100H
		LDA	ENWRKA,X
		STA	R6		;(R6)  <-- Ｘ倍率
		LDA	ENWRKC,X ;#0100H
		STA	R11		;(R11) <-- Ｙ倍率
		LDA	#01FH
		STA	R8		;(R8)  <-- 中心＿Ｘ
		STA	R9		;(R9)  <-- 中心＿Ｙ
		LDA	#CIPCHD4+00A0H
		STA	R12		;(R12) <-- キャラクターアドレス（Ｌ，Ｈ）
		LDA	#BANK CIPCHD4
		STA	R13		;(R13) <-- キャラクターアドレス(Ｂ）
		LDY	ENTROB,X
		TYX
		LDA	>TROBJ_PLOT_Y,X
		STA	R2		;(R2)  <-- ビットマップ座標＿Ｙ
		LDA	>TROBJ_PLOT_X,X
		STA	R3		;(R3)  <-- ビットマップ座標＿Ｘ
		M_CHIP	C_32_ZOOM_XY
;
		LDX	<ENINDX
;
;-------------- ジャイアントプチプチの胴体下キャラクターセット ----------
;;		  LDA	  #0100H
		LDA	ENWRKA,X
		STA	R6		;(R6)  <-- Ｘ倍率
		LDA	ENWRKC,X ;#0100H
		STA	R11		;(R11) <-- Ｙ倍率
		LDA	#01FH
		STA	R8		;(R8)  <-- 中心＿Ｘ
		STZ	R9		;(R9)  <-- 中心＿Ｙ
		LDA	#CIPCHD4+00C0H
		STA	R12		;(R12) <-- キャラクターアドレス（Ｌ，Ｈ）
		LDA	#BANK CIPCHD4
		STA	R13		;(R13) <-- キャラクターアドレス(Ｂ）
		LDY	ENTROB,X
		TYX
		LDA	>TROBJ_PLOT_Y,X
		STA	R2		;(R2)  <-- ビットマップ座標＿Ｙ
		LDA	>TROBJ_PLOT_X,X
		CLC
		ADC	#020H
		STA	R3		;(R3)  <-- ビットマップ座標＿Ｘ
		M_CHIP	C_32_ZOOM_XY
;
		INC	OBM7WF		;転送フラグ”ＯＮ”
;
		LDX	<ENINDX
		RTS
;************************************************************************
;*		initial ( ビッグ プチプチ )				*
;************************************************************************
PUCHBIN		EQU	$
;
		RTL
;************************************************************************
;*		move	( ビッグ プチプチ )				*
;************************************************************************
PUCHBMV		EQU	$
;		 LDA	 ENSHOT,X
;		 BNE	 PCBC020
;
		STZ	ENSHOT,X
;
		LDA	<ENWRK2,X
		CMP	#PBFL
		BNE	PCB010
;
		JSR	PBCSET
		JSL	>ENMDCK
;
		JSR	PBMOVE	; move sub
;
		JSR	PBCHTR
		RTL
;- - - - - - - - - - - - - - - - - - - - - - - -
PCB010		EQU	$
		LDA	ENTIM2,X
		BNE	PCBC020		; Protect time !
;
		JSR	CRPGEGG
;
		JSL	>EPCRCK2
		JSR	PBFLCK
PCBC020		EQU	$
		JSL	>ENMDCK
;
		JSR	PBMOVE	; move sub
;
		JSR	CRENEN	; Vs enemy check
;
		JSR	ENBGCK
;
		RTL
;=================================================
PBFLCK		EQU	$
		LDA	ENMODE,X
		CMP	#EFAIL
		BNE	PBFC90
;
		LDA	#EMOVE
		STA	ENMODE,X
;
		LDA	PLDOSN
		BNE	PBFC10
;
		LDA	#PBBY
		STA	<ENWRK2,X
;
		LDA	#020H
		STA	ENTIM0,X
;
		LDA	#0FB00H
		STA	PLYSPD
;
		STZ	ENWRK6,X
PBFC90		EQU	$
		RTS
;
PBFC10		EQU	$
		STZ	<ENCONT,X
;
		LDA	#PBFL
		STA	<ENWRK2,X
;
		LDA	#02H
		STA	ENCHPT,X
;
		LDA	ENMOD2,X
		AND	#001FFH
		ORA	#04000H
		STA	ENMOD2,X
;
		JSL	>PBCHIN
		JSR	PBCSET
		RTS
;=================================================
;=================================================
;=						 =
;=================================================
PBMOVE		EQU	$
		LDA	<ENWRK2,X
		ASL	A
		TXY
		TAX
		JMP	(PBADRS,X)
;= = = = = = = = = = = = = = = = = = = = = = = = =
PBADRS		EQU	$
		WORD	PBWALK
		WORD	PBTURN
		WORD	PBBYON
		WORD	PBFAIL
;- - - - - - - - - - - - - - - - - - - - -
PBWK		EQU	00
PBTU		EQU	01
PBBY		EQU	02
PBFL		EQU	03
;=================================================
PBWXSD		EQU	$
		WORD	0FF80H,0080H
PBWPTD		EQU	$
		HEX	0,1,2,3,6,3,2,1
;
PBWALK		EQU	$
		TYX
;
		LDA	ENMOD2,X
		AND	#001FFH
		ORA	#02000H
		STA	ENMOD2,X
;
		LDA	ENCBFG,X
		AND	#01H
		BEQ	PBW000
;
		LDY	ENMUKI,X
		LDA	PBWXSD,Y
		STA	ENXSPD,X
;
PBW000		EQU	$
		M8
;;		  LDA	  FRCNT
		DEC	ENWRK8,X
		BPL	PBW010
;
		LDA	#07H
		STA	ENWRK8,X
;
		INC	<ENCONT,X
		LDA	<ENCONT,X
		CMP	#08H
		BNE	PBW010
;
		STZ	<ENCONT,X
PBW010		EQU	$
		LDY	<ENCONT,X
		LDA	PBWPTD,Y
		STA	ENCHPT,X
;
;		 CMP	 #06H
;		 BNE	 PBW020
;;
;		 JSR	 EPXCHK
;		 TYA
;		 CMP	 ENMUKI,X
;		 BEQ	 PBW020
;;
;		 LDA	 ENMUKI,X
;		 EOR	 #02H
;		 STA	 ENMUKI,X
PBW020		EQU	$
		M16
;
		LDA	ENTIM0,X
		BNE	PBYPTST
;
		RTS
;=================================================
PBTUPT		EQU	$
		HEX	1,2,3,6,3,2,1
;- - - - - - - - - - - - - - - - - - - - - -
PBTURN		EQU	$
		TYX
;
		LDA	ENTIM0,X
		BNE	PBT010
;
		JMP	PBWKST
PBT010		EQU	$
		M8
;
		CMP	#0BH
		BNE	PBT020
;
		PHA
		LDA	ENMUKI,X
		EOR	#02H
		STA	ENMUKI,X
		PLA
PBT020		EQU	$
		LSR	A
		LSR	A
		TAY
		LDA	PBTUPT,Y
		STA	ENCHPT,X
;
		M16
		RTS
;=================================================
;
PBBYON		EQU	$
		TYX
;
;		 LDA	 #00H
;		 STA	 ENSHOT,X
;
		LDA	ENCBFG,X
		AND	#01H
		BEQ	PBBY00C
;
		LDA	ENWRK6,X
		BEQ	PBB000		; Buttobi ?
;					; YES !
		LDY	#1FH
PBB0F0		EQU	$
		JSR	BSXDOWN2
		DEY
		BPL	PBB0F0
;
		LDA	ENXSPD,X
		BEQ	PBWKST
		BNE	PBBY00C
PBB000		EQU	$
		STZ	ENXSPD,X
;
PBBY00C		EQU	$
		LDA	ENTIM0,X
		BNE	PBBY010
;
PBRET		EQU	$
PBWKST		EQU	$
		LDA	#PBWK
		STA	<ENWRK2,X
;
		STZ	<ENCONT,X  ; walk counter clear
		RTS
;-----------------------------------------
PBYPTST		EQU	$
PBBY010		EQU	$
		I16
		LDA	ENOAML,X
		TXY
		TAX
;
		LDA	FRCNT
		AND	#04H
		BNE	PBBY020
;
		LDA	ENMUKI,Y
		BEQ	PBBY018
;
		INC	SOAM_DX+000H,X
		INC	SOAM_DX+010H,X
		DEC	SOAM_DX+008H,X
		DEC	SOAM_DX+018H,X
		BRA	PBBY050
;
PBBY018		EQU	$
		DEC	SOAM_DX+000H,X
		DEC	SOAM_DX+010H,X
		INC	SOAM_DX+008H,X
		INC	SOAM_DX+018H,X
		BRA	PBBY050
;
PBBY020		EQU	$
		DEC	SOAM_DX+002H,X
		DEC	SOAM_DX+00AH,X
		INC	SOAM_DX+012H,X
		INC	SOAM_DX+01AH,X
PBBY050		EQU	$
;
		I8
		LDX	<ENINDX
		RTS
;
;
;
;
;
;
;
;
;=================================================
PBFLXA		EQU	$
		WORD	107H
		WORD	10EH
		WORD	115H
		WORD	11CH
		WORD	123H
		WORD	12AH
		WORD	131H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
		WORD	138H
PBFLYA		EQU	$
		WORD	0E9H
		WORD	0D2H
		WORD	0BBH
		WORD	0A4H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
		WORD	088H
;
PBFLPY		EQU	$
		WORD	0FFE0H
		WORD	0FFE4H
		WORD	0FFE6H
		WORD	0FFE4H
		WORD	0FFE6H
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
		WORD	0FFEAH
;- - - - - - - - - - - - - - - - - - - - - - - -
PBFAIL		EQU	$
		TYX
;
		STZ	ENXSPD,X
;
		LDY	<ENCONT,X
		CPY	#(08H+7)*2
		BEQ	PBF020
;
		LDA	FRCNT
		AND	#00H
		BNE	PBF010
;
		INC	<ENCONT,X
		INC	<ENCONT,X
PBF010		EQU	$
		LDA	PBFLXA,Y
		STA	ENWRKA,X
		LDA	PBFLYA,Y
		STA	ENWRKC,X
		LDA	#02H
		STA	ENCHPT,X
;
		LDA	ENYPSL,X
		CLC
		ADC	PBFLPY,Y
		STA	PLYPSL
;
		STZ	PLYSPD
		RTS
;- - - - - - - - - - - - -
PBF020		EQU	$
		STZ	PLDOSN
;
		LDA	#86H
		JSL	>SOUND_3_ON	;(S)
;
		JSR	PUCHSST
;
		JSL	>ENCLEAR_NORETN
;
		RTS
;=================================================
PSSYSD		EQU	$
		WORD	0FD00H,0FD00H
		WORD	0FC00H,0FC00H
PSSXSD		EQU	$
		WORD	01C0H,0FE40H
		WORD	0100H,0FF00H
PSSXAD		EQU	$
		WORD	0010H,0FFF0H
		WORD	0008H,0FFF8H
PSSMKI		EQU	$
		WORD	0002H,00000H
		WORD	0002H,00000H
;
PUCHSST		EQU	$
		LDA	#PONBR
		JSL	>EXINSR
		LDA	ECENTX,X
		STA	EXXPSL,Y
		LDA	ECENTY,X
		STA	EXYPSL,Y
		LDA	#00002
		STA	EXTIM0,Y
		LDA	#00008
		STA	EXCHPT,Y
;
		LDA	ECENTX,X
		STA	R1
		LDA	ECENTY,X
		STA	R2
		LDA	#0040H
		STA	R10
		LDA	#0300H
		STA	CCWORK0
		LDA	#0FD00H
		STA	CCWORK1
;
		M_CHIP	PONTA_BOMB     ; Bakuhatsu hit check !
		LDX	<ENINDX
;
		LDA	#03BH
		JSL	>SOUND_3_ON    ;(S)
;
		LDA	#06H
		STA	<EWORK8
;
		LDA	#020H
		STA	PLFLSH
;
		LDA	ENXPSL,X
		STA	<EWORK0
		LDA	ENYPSL,X
		STA	<EWORK2
;
PCSS010		EQU	$
		LDA	#PONTA
		JSL	>ENINSR
		BCC	PCSS060
;
		LDX	<EWORK8
;
		LDA	<EWORK0
		CLC
		ADC	PSSXAD,X
		STA	ENXPSL,Y
;
		LDA	PSSXSD,X
		STA	ENXSPD,Y
;
		LDA	PSSMKI,X
		STA	ENMUKI,Y
;
		LDA	PSSYSD,X
		STA	ENYSPD,Y
;
		LDA	<EWORK2
		CLC
		ADC	#000H
		STA	ENYPSL,Y
;
		LDA	#01H
		STA	ENCONT,Y
;
;;;		STA	ENSHOT,Y
;
;		 LDA	 ENMOD0,Y
;		 AND	 #1111100111111111B
;		 STA	 ENMOD0,Y
;
		LDA	ENMOD2,Y
		AND	#1111111111110011B
		STA	ENMOD2,Y
		STA	ENWRKA,Y
		BRA	PCSS070
;
PCSS060		EQU	$
;;		  INC	  PUCHACONT
		JSL	>PUCHACONT_CK2
;
PCSS070		EQU	$
		LDX	<ENINDX
;
		DEC	<EWORK8
		DEC	<EWORK8
		BPL	PCSS010
PCSS090		EQU	$
		RTS
;=================================================
;=================================================
;=================================================
;=================================================
;
;
;
;
;
;
;
PBCHIN		EQU	$
;-------------- ビッグプチプチの転送エリア確保 --------------------------
		JSL	>TROBJ_SR_4x4
		BCS	PCBI010		;エリア確保？ ( yes:PCBI010 )
		JMP	>ENCLEAR
;
PCBI010		EQU	$
		RTL
;
;
;
;
;
;
;
;
;
;
;
;
;
;
PBCSET		EQU	$
;-------------- ビッグプチプチのＯＡＭセット ----------------------------
		JSL	>TROBJ_OAM_4x4
;
		I16
;
		LDA	ENOAML,X
		CLC
		ADC	#4*8
		TAY
		JSL	>TROBJ_OAM_4x4_I
;
		IDX8
		RTS
;
;
;
PBCHTR		EQU	$
;-------------- ビッグプチプチの胴体キャラクターセット ------------------
		LDA	ENWRKA,X
		STA	R6		;(R6)  <-- Ｘ倍率
		LDA	ENWRKC,X
		STA	R11		;(R11) <-- Ｙ倍率
		LDA	#01FH
		STA	R8		;(R8)  <-- 中心＿Ｘ
		STA	R9		;(R9)  <-- 中心＿Ｙ
		LDA	#CIPCHD4+00E0H
		STA	R12		;(R12) <-- キャラクターアドレス（Ｌ，Ｈ）
		LDA	#BANK CIPCHD4
		STA	R13		;(R13) <-- キャラクターアドレス(Ｂ）
		LDY	ENTROB,X
		TYX
		LDA	>TROBJ_PLOT_Y,X
		STA	R2		;(R2)  <-- ビットマップ座標＿Ｙ
		LDA	>TROBJ_PLOT_X,X
		STA	R3		;(R3)  <-- ビットマップ座標＿Ｘ
		M_CHIP	C_32_ZOOM_XY
;
		INC	OBM7WF		;mode 7 OBJ chara DMA "ON"
;
		LDX	<ENINDX
;
		RTS
;
;




;************************************************************************
;*		initial ( ボスカチカチ君 )				*
;************************************************************************
BOSSKIN		EQU	$
		JSL	>TROBJ_SR_8x8	;転送エリア確保（８×８）
;
		LDA	#0000H
		STA	ENGPOW,X
;
		LDA	#0018H
		STA	ENBGYP,X
;
		LDA	#0010001010000000B
		STA	ENMOD1,X
;
		STZ	BSWRK0
		STZ	BSWRK6
		STZ	BSWRK7
;
		LDA	ENYPSL,X
		CLC
		ADC	#010H
		STA	ENYPSL,X
;
		LDA	#0058H
		STA	BSXSIZ
;
		LDA	#0040H
		STA	ENTIM0,X
;
		LDA	#06H+0FH
		STA	ENCHPT,X
;
		LDA	MAPOINT
		AND	#00FFH
		CMP	#0064-1
		BNE	BSKI010
;
		LDY	#Kati
		JSL	>KAMC2COLRESET_L
;
;		 M8
;		 JSR	 BKWSET
;		 M16
BSKI010		EQU	$
		RTL
;
;************************************************************************
;*		move	( ボスカチカチ君 )				*
;************************************************************************
BOSSKMV		EQU	$
;
;------------------------------------------------------------------------
;-		ＯＡＭセット						-
;------------------------------------------------------------------------
;
		M8
;
;		 LDA	 KEYA2L
;		 AND	 #010H
;		 BEQ	 BKTE010
;;
;		 JSR	 BKYUPST
;
;		 LDA	 BSXSIZ
;		 CMP	 #0FFH
;		 BEQ	 BKTE010
;;
;		 INC	 BSXSIZ
;;
;BKTE010	 EQU	 $
;		 LDA	 KEYA1L
;		 AND	 #020H
;		 BEQ	 BKTE020
;;
;		 LDA	 BSXSIZ
;		 CMP	 #058H
;		 BEQ	 BKTE020
;;
;		 DEC	 BSXSIZ
;BKTE020	 EQU	 $
;
;
;
		JSR	KTSUB	 ; Character revise
;
		M16
;
		JSL	>ENMDCK
;
		JSR	BKCHTR
;
		M8
;
		JSR	BKMOVE
;
		LDA	ENWATR,X
		CMP	#WT+MG	;08H
		BNE	BKTE020
;
		LDA	#07AH
		JSL	>SOUND_3_ON	;(S)
;
		LDA	#0F0H
		STA	SOUND_0 ;(S)
;
		STZ	ENWATR,X
;
		JSR	BKYUPST
;
		LDA	#BEND0
		STA	BSSTAT
;
		M16
;
		LDA	ENMOD0,X
		AND	#1111100111011111B     ; OBJ hit noth.
		STA	ENMOD0,X
;
		LDA	ENMOD1,X
		AND	#1111111111100000B     ; BG check noth.
		STA	ENMOD1,X
;
		STZ	ENGPOW,X
BKTE020		EQU	$
		M16
		IDX8
;
		RTL
;
;
;=============================================================
		MEM8
;
BKMOVE		EQU	$
		JSR	BKTEST	; Test controle
;
		LDA	BSTIM0
		BEQ	BKM0000
;
		DEC	BSTIM0
BKM0000		EQU	$
		LDA	BSTIM1
		BEQ	BKM0001
;
		DEC	BSTIM1
BKM0001		EQU	$
		LDA	BSTIM2
		BEQ	BKM0002
;
		DEC	BSTIM2
BKM0002		EQU	$
		JSR	BKBGCK
;
;;		  JSR	  KTSUB
;
		JSR	BKSUB
;
		LDA	ENCBFG,X
		AND	#01H
		STA	BSWRK8
;
;		 LDA	 BSMUKI
;		 ASL	 A
;		 STA	 ENMUKI,X
;
;		 JSR	 BKSSRV	   ; Seesow angle revise
;
;		 M16
;
;		 LDA	 BSXSPD
;		 CLC
;		 ADC	 <EWORK0   ; Seesow angle revise speed
;		 TAY
;		 TYA
;		 ASL	 A
;		 ASL	 A
;		 ASL	 A
;		 ASL	 A
;		 CPY	 #00H
;		 BPL	 BKSD010
;		 ORA	 #0F000H
;BKSD010	 EQU	 $
;		 STA	 ENXSPD,X
;
;		 LDY	 BSYSPD
;		 TYA
;		 ASL	 A
;		 ASL	 A
;		 ASL	 A
;		 ASL	 A
;		 CPY	 #00H
;		 BPL	 BKSD020
;		 ORA	 #0F000H
;BKSD020	 EQU	 $
;		 STA	 ENYSPD,X
;
		LDA	MAPOINT
		CMP	#64-1
		BEQ	BKDC010
;
		M16
;
		LDA	ENYPSL,X
		SEC
		SBC	SCCV1
		CMP	#0120H
		BCC	BKDC010
		BMI	BKDC010
;
		LDA	SCCV1
		SEC
		SBC	#0040H
		STA	ENYPSL,X
;
		LDA	SCCH1
		CLC
		ADC	#0180H
		STA	ENXPSL,X
;
BKDC010		EQU	$
		MEM8
		SEP	#00100000B
		RTS
;
;================================================================
;BKSSRSD	 EQU	 $
;;;			  0  1	2  3  4	 5  6  7  8  9	A  B  C	 D  E  F
;		 HEX	 00,FF,FE,00,00,00,00,00,00,00,00,00,00,00,00,00 ;0
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;1
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;2
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;3
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;4
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;5
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;6
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;7
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;8
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;9
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;A
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;B
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;C
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;D
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ;E
;		 HEX	 00,00,00,00,00,00,00,00,00,00,00,00,00,00,02,01 ;F
;;
BKSSAAD		EQU	$
;;			 0  1  2  3  4	5  6  7	 8  9  A  B  C	D  E  F
		HEX	00,10,20,30,40,50,60,70,70,70,70,70,70,70,70,70
		HEX	70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70
;		 HEX	 00,01,03,06,0A,0F,15,1C,24,2D,37,42,4E,5C,69,78 ;
;		 HEX	 88,99,AB,BE,D2,E7,FD,FF,FF,FF,FF,FF,FF,FF,FF,FF ;
;
BKSSRV		EQU	$
		LDA	SANGLE
		BPL	SSS
;
		EOR	#0FFH
		INC	A
SSS		EQU	$
		TAY
		LDA	BKSSAAD,Y
		STA	4202H
;
		LDA	BSASPD
		ASL	A
		ASL	A
		BPL	BKSR010
;
		EOR	#0FFH
		INC	A
BKSR010		EQU	$
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	4212H
;
		LDA	ENXPSL,X
;		 CLC
;		 ADC	 #008H
		SEC
		SBC	#080H-8
		BPL	WWW
		EOR	#0FFH
		INC	A
WWW		EQU	$
		ASL	A
		NOP
		STA	4213H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	4212H
;
		LDY	BSASPD
		BMI	QQQ
;
		EOR	#0FFH
		INC	A
QQQ		EQU	$
		NOP
		NOP
;;;		ASL	A
		STA	<EWORK0
;
;
;
;
;		LDY	BSASPD	; Seesow speed
;		LDA	BKSSRSD,Y
;		STA	<EWORK0
		RTS
;================================================================
;BKSSSPD	 EQU	 $
;;;			    0	  1	2     3	    4	  5	6     7
;		 WORD	 0000H,0020H,0040H,0060H,0080H,0080H,0080H,0080H
;;;			    8	  9	A     B	    C	  D	E     F
;		 WORD	 0080H,0080H,0080H,0080H,0080H,0080H,0080H,0080H
;;;			    0	  1	2     3	    4	  5	6     7
;		 WORD	 0000H,0020H,0040H,0060H,0080H,0080H,0080H,0080H
;;;			    8	  9	A     B	    C	  D	E     F
;		 WORD	 0080H,0080H,0080H,0080H,0080H,0080H,0080H,0080H
;- - - - - - - - - - - - - - -
;BKBC010B	 EQU	 $
;		 JMP	 BKBC010
;- - - - - - - - - - - - - - -
;
BKBGCK		EQU	$
		LDA	ENCBFG,X
		AND	#01H
		BEQ	B2BC010
;
		STZ	ENYSPD,X
		STZ	ENYSPD+1,X
;
		LDA	ENSLOP,X
		LDY	BSWRK8
		BEQ	B2BC070
		CMP	BSANGL1
		BEQ	B2BC008
;
		BMI	B2BC003
;
		INC	BSANGL1
		INC	BSANGL1
		BRA	B2BC010
B2BC003		EQU	$
		DEC	BSANGL1
		DEC	BSANGL1
B2BC008		EQU	$
B2BC010		EQU	$
		RTS
B2BC070		EQU	$
		STA	BSANGL1
		RTS
;-------------------------------------------
;BKBC010	 EQU	 $
;		 LDA	 FRCNT
;		 AND	 #01H
;		 BNE	 BKBC070
;;
;		 LDA	 BSANGL1
;		 BEQ	 BKBC070
;		 BPL	 BKBC060
;		 INC	 BSANGL1
;		 BRA	 BKBC070
;BKBC060	 EQU	 $
;		 DEC	 BSANGL1
;BKBC070	 EQU	 $
;		 RTS
;;		  M8
;		 RTS
;=====================================================================
BKSUB		EQU	$
		JSR	EPCRCKS
;
		TXY
;
		M16
;
		LDA	BOSS_START
		BMI	BKSB010
;		 CMP	 #01H
;		 BEQ	 BKSB020
		BNE	BKSB020
;
BKSB010		EQU	$
		M8
;
		LDA	BSSTAT
		ASL	A
		TAX
		JMP	(BKADRS,X)
;
BKSB020		EQU	$
		M8
;
		LDA	#040H
		STA	ENTIM0,X
		RTS
;-------------------------------------------------
BKMD1ST		EQU	$
		LDA	ENMOD1+1,X
		AND	#11111100B
		ORA	#00000010B
		STA	ENMOD1+1,X
;
		RTS
;-------------------------------------------------
BKADRS		EQU	$
		WORD	BKDEMO0
		WORD	BKDEMO05
		WORD	BKDEMO1
		WORD	BKDEMO15
BKD2		WORD	BKDEMO2
;-------------------------------------------------
BKW		WORD	BKWALK
BKT		WORD	BKTURN
BKJWW		WORD	BKJWAI
BKJ		WORD	BKJUMP
BKJS		WORD	BKJSTOP
BKSPP		WORD	BKSPIN
BKSPSS		WORD	BKSPINS
BKSPP2		WORD	BKSPIN2
BKP		WORD	BKPINCH
BKE0		WORD	BKEND0
		WORD	BKEND1
		WORD	BKEND2
BKE		WORD	BKENDS
;- - - - - - - - - - - - - - - - - - - - -
BKWK		EQU	(BKW-BKADRS)/2
BKTU		EQU	(BKT-BKADRS)/2
BKJW		EQU	(BKJWW-BKADRS)/2
BKJP		EQU	(BKJ-BKADRS)/2
BKJST		EQU	(BKJS-BKADRS)/2
BKSP		EQU	(BKSPP-BKADRS)/2
BKSPS		EQU	(BKSPSS-BKADRS)/2
BKSP2		EQU	(BKSPP2-BKADRS)/2
BKPI		EQU	(BKP-BKADRS)/2
BEND0		EQU	(BKE0-BKADRS)/2
BKEND		EQU	(BKE-BKADRS)/2
BKDE2		EQU	(BKD2-BKADRS)/2
;================================================================
BKDEMO0		EQU	$
		TYX
;
		LDA	MAPOINT
		CMP	#64-1
		BEQ	BKD0002		; WORLD 6-4 ?
;					; no
		LDA	#06H
		STA	BSCHPT
		STA	BSWRK1
;
		STZ	ENCHPT,X
;
;;;		JSR	BKCHTR
;
		LDA	#0FFH
		STA	BSXSIZ
;
		LDA	#040H
		STA	ENGPOW,X
;
		LDA	#040H
		STA	ENTIM0,X
;
		LDA	#BKDE2
		STA	BSSTAT
;
		LDA	#40H
		STA	ENTIM0,X
;
		LDA	#10000001B
		STA	ENMOD1,X    ; BG check on !
;
		LDA	#0E8H
		STA	ENMOD2+1,X
;
		RTS
;
BKD0002		EQU	$
		LDA	ENTIM0,X
		BNE	BKD0010
;
		INC	BSSTAT
;
		M16
		LDA	#0001H
		STA	BOSS_START
;
		M8
BKD0010		EQU	$
		RTS
;================================================================
BKDEMO05	EQU	$
		TYX
;
		M16
;
		LDA	ENTIM0,X
		BNE	BKD05010
;
		LDA	#0FC00H
		STA	ENYSPD,X
;
		LDA	#0018H
		STA	ENGPOW,X
;
		STZ	BOSS_START
;
		M8
;
		LDA	#16H
		STA	ENCHPT,X
;
		LDA	#0CH
		STA	ENTIM0,X
;
		INC	BSSTAT
;
BKD05010	EQU	$
		M8
		RTS
;
;================================================================
BKDEMO1		EQU	$
		TYX
;
		M8
;
		LDA	ENTIM0,X
		BEQ	BKD1001
;
		CMP	#01H
		BNE	BKD1000
;
		LDA	ENYPSL,X
		CLC
		ADC	#00H
		STA	ENYPSL,X
;
		STZ	ENCHPT,X
;
		LDA	#0E8H
		STA	ENMOD2+1,X
;
		LDA	#12H
		STA	BSCHPT
;
		JSR	BKCHTR
BKD1000		EQU	$
		BRA	BKD1050
;
BKD1001		EQU	$
		LDA	BSXSIZ
		CMP	#0FFH
		BEQ	BKD1002
		CLC
		ADC	#06H
		STA	BSXSIZ
		BCS	BKD1002
		BRA	BKD1003
;
BKD1002		EQU	$
		LDA	#0FFH
		STA	BSXSIZ
BKD1003		EQU	$
		LDA	BSANGL1
		CLC
		ADC	#08H
		STA	BSANGL1
		BEQ	BKD1010
;
		RTS
;
BKD1010		EQU	$
		LDA	#0FFH
		STA	ENGPOW,X
;
		LDA	#06H
		STA	BSCHPT
;
		LDA	#00H
		STA	ENYSPD,X
		LDA	#00H
		STA	ENYSPD+1,X
;
		LDA	#10000001B
		STA	ENMOD1,X    ; BG check on !
;
		INC	BSSTAT
BKD1050		EQU	$
		RTS
;================================================================
BKDEMO15	EQU	$
		TYX
;
		M8
;
		LDA	ENCBFG,X
		AND	#01H
		BEQ	BD15010
;
		LDA	#06H
		STA	BSCHPT
		STA	BSWRK1
;
		LDA	#47H
		JSL	>SOUND_3_ON    ;(S)
;
		LDA	#018H
		STA	TILTCT
;
		LDA	#040H
		STA	ENGPOW,X
;
		LDA	#0A0H
		STA	ENTIM0,X
;
		STZ	PLMODE
;
		INC	BSSTAT
BD15010		EQU	$
		RTS
;================================================================
BKDEMO2		EQU	$
		TYX
;
		M8
;
		LDA	ENTIM0,X
		BNE	BKD2010
;
		JSR	BKWSET
BKD2010		EQU	$
		RTS
;================================================================
;================================================================
;================================================================
;================================================================
;================================================================
BKWKPT		EQU	$
		HEX	0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
BKXSDT		EQU	$
;;		  HEX	  F0,10
		WORD	0FF00H,0100H
		WORD	0FE80H,0180H
;
BKTUPT		EQU	$
BKTM
		HEX	1F,1F,1F,1F
		HEX	20,20,20,20,20,20,20,20
		HEX	1F,1F,1F,1F,1F
BKTME
;-------------------------------------------------
BKWALK		EQU	$
		TYX
;
		LDA	#0040H
		STA	ENGPOW,X
;
		JSR	BKMD1ST
;
		LDA	BSTIM1
		BNE	BKW010
;
		DEC	BSWRK0
		BPL	BKW010
;
		LDA	#01H
		STA	BSWRK0
;
		LDA	BSWRK1
		INC	A
		AND	#0FH
		STA	BSWRK1
;
		LDY	BSWRK1
		LDA	BKWKPT,Y
		STA	BSCHPT
;
		DEC	A
		AND	#07H
		BNE	BKW002
;
		JSR	BKWKXSS
BKW002		EQU	$
		LDA	BSCHPT
		AND	#07H
		BNE	BKW010
BKW008		EQU	$
		LDA	#0CH
		STA	TILTCT
		LDA	#10H
		STA	BSTIM1
;
		LDA	#84H
		JSL	>SOUND_3_ON    ;(S)
;
		STZ	ENXSPD,X
		STZ	ENXSPD+1,X
;
BKW010		EQU	$
		LDA	ENCBFG,X
		AND	#00001100B
		STA	BSWRK3
		BNE	BKWK001
;
		LDA	ENCBFG,X
		AND	#01H
;;		BRA	BKWK002
		BNE	BKWK002
;
		LDA	BSWRK8
		BEQ	BKWK002
;
BKWK001		EQU	$
		JMP	BKJPST	  ; JUMP  set !
;
BKWK002		EQU	$
;
		LDA	BSCHPT
		BEQ	BKW018
		CMP	#01H
		BEQ	BKW018
		CMP	#0EH
		BEQ	BKW018
		CMP	#0FH
		BNE	BKW020	; Turn check timing ?
;
BKW018		EQU	$
BKTUCK		EQU	$
		JSR	EPXCHK
;
		TYA
		CMP	ENMUKI,X ;BSMUKI
		BEQ	BKW050
;
		LDA	FRCNT
		AND	#00H
		BNE	BKW020
;
		LDA	#BKTU
		STA	BSSTAT
;
		LDA	#BKTME-BKTM-1
		STA	BSTIM0
BKW020		EQU	$
		RTS
;-------------------------------------------
BKW050		EQU	$
;		 RTS
;
		M16
		LDA	<EWORKE
		CLC
		ADC	#0050H
		CMP	#00A0H
		M8
		BCS	BKW060
;
;		 M16
;		 LDY	 #000H
;		 LDA	 ENXPSL,X
;		 SEC
;		 SBC	 #000E0H
;		 CMP	 #00220H-0E0H
;		 M8
;		 BCC	 BKW058
;;
;		 BPL	 BKW053
;		 LDY	 #002H
;BKW053		 EQU	 $
;		 TYA
;		 CMP	 ENMUKI,X
;		 BNE	 BKW060
;;
;BKW058		 EQU	 $
BKJPST		EQU	$
		LDA	#BKJW
		STA	BSSTAT
;
		STZ	<ENCONT,X
BKW060		EQU	$
		RTS
;================================================================
;
BKTURN		EQU	$
		TYX
;
		LDA	#0040H
		STA	ENGPOW,X
;
		JSR	BKMD1ST
;
		STZ	ENXSPD,X ;BSXSPD
		STZ	ENXSPD+1,X ;BSXSPD
;
		LDY	BSTIM0
		BEQ	BKWSET
;
		LDA	BKTUPT,Y
		STA	BSCHPT
;
		CPY	#(BKTME-BKTM)/2
		BNE	BKTU010
;
		LDA	ENMUKI,X ;BSMUKI
		EOR	#02H
		STA	ENMUKI,X ;BSMUKI
BKTU010		EQU	$
		RTS
BKWSET		EQU	$
		LDA	#BKWK
		STA	BSSTAT
;
		STZ	BSWRK0
		STZ	BSWRK1
;		 LDA	 BSMUKI
;		 ASL	 A
;		 TAY
BKWKXSS		EQU	$
		LDY	ENMUKI,X
;
		LDA	MAPOINT
		CMP	#64-1
		BEQ	BKWS010
		INY
		INY
		INY
		INY
BKWS010		EQU	$
		M16
		LDA	BKXSDT,Y
		STA	ENXSPD,X
		M8
		RTS
;================================================================
BKJPXS		EQU	$
		WORD	0FE00H,0200H
		WORD	0FF00H,0100H
;;		  HEX	  E8,18
BKJWPT		EQU	$
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	0F,0F,0F,0F
		HEX	0F,0F,0F,0F
		HEX	0F,0F,0F,0F
		HEX	0F,0F,0F,0F
		HEX	FF
;
BKJWAI		EQU	$
		TYX
;
;
		LDA	#0040H
		STA	ENGPOW,X
;
		JSR	BKMD1ST
;;		  STZ	  BSXSPD
		STZ	ENXSPD,X
		STZ	ENXSPD+1,X
;
		LDY	<ENCONT,X
		INC	<ENCONT,X
		LDA	BKJWPT,Y
		BMI	BKJNEXT
		STA	BSCHPT
;
		RTS
;
BKJNEXT		EQU	$
		LDA	#13H
		JSL	>SOUND_3_ON    ;(S)
;
		LDA	#000H
		STA	ENYSPD,X
		LDA	#0F9H
		STA	ENYSPD+1,X
;
		LSR	ENCBFG,X
		ASL	ENCBFG,X
;
		INC	BSSTAT
;
		STZ	<ENCONT,X
BKJPXSS		EQU	$
;		 LDA	 BSMUKI
;		 ASL	 A
;		 TAY
		LDY	ENMUKI,X
		LDA	BSWRK3
		BEQ	BKJS010	 ; Side BG hit ?
		INY		 ; yes !
		INY
		INY
		INY
BKJS010		EQU	$
		M16
		LDA	BKJPXS,Y
		STA	ENXSPD,X
		M8
;;		  STA	  BSXSPD
;
		RTS
;================================================================
BKJPPT		EQU	$
BKJD		HEX	10,10
		HEX	11,11,11,11,11,11,11,11
		HEX	11,11,11,11,11,11,11,11
		HEX	11,11,11,11,11,11,11,11
;		 HEX	 11,11,11,11,11,11,11,11
;		 HEX	 11,11,11,11,11,11,11,11
;		 HEX	 11,11,11,11,11,11,11,11
;		 HEX	 11,11,11,11,11,11,11,11
;		 HEX	 11,11,11,11,11,11,11,11
		HEX	10,10
BKJE		HEX	10,10
;
BKJUMP		EQU	$
		TYX
;
		LDA	#0040H
		STA	ENGPOW,X
;
		JSR	BKMD1ST
;
		LDA	ENCBFG,X
		AND	#00001100B
		BNE	BKJP008
;
		JSR	BKJPXSS
;
BKJP008		EQU	$
		LDY	<ENCONT,X
		CPY	#BKJE-BKJD
		BCS	BKJP010
;
		INC	<ENCONT,X
;
BKJP010		EQU	$
		LDA	BKJPPT,Y
		STA	BSCHPT
;
;;		  LDA	  BSWRK8   ; On foot
		LDA	ENCBFG,X
		AND	#01H
		BEQ	BKJP020
;
		LDA	#18H
		STA	TILTCT
;
		LDA	#47H
		JSL	>SOUND_3_ON    ;(S)
;
		STZ	ENYSPD,X
		STZ	ENYSPD+1,X
;
		LDA	#BKJST
		STA	BSSTAT
;
		STZ	<ENCONT,X
;
BKJP020		EQU	$
		RTS
;================================================================
BKJSPT		EQU	$
		HEX	0F,0F,0F,0F
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	FF
;
BKJSTOP		EQU	$
		TYX
;
;
		LDA	#0040H
		STA	ENGPOW,X
;
		JSR	BKMD1ST
;;		  STZ	  BSXSPD
		STZ	ENXSPD,X
		STZ	ENXSPD+1,X
;
		LDY	<ENCONT,X
		INC	<ENCONT,X
		LDA	BKJSPT,Y
		BMI	BKSTEND
;
		STA	BSCHPT
		RTS
;
BKSTEND		EQU	$
		JSR	BKWSET
		JSR	BKTUCK
BKST010		EQU	$
		RTS
;================================================================
BKSPIN		EQU	$
		TYX
;
		LDA	#0040H
		STA	ENGPOW,X
;
		LDA	#12H
		STA	BSCHPT
;
;		 LDA	 BSWRK8
;		 BNE	 BKSP002
;		 CMP	 <ENWRK1,X
;		 BEQ	 BKSP002  ; BG on -> off ?
		LDA	ENCBFG,X
		AND	#01H
		BNE	BKSP002
;
		LDA	ENYPSL,X
		CMP	#0A0H
		BCS	BKSP002
;
		LDA	BSWRK8
		BEQ	BKSP002
;
		JMP	BKPISET	  ; Pinch set !
;
BKSP002		EQU	$
;
		LDA	BSWRK7
		CLC
		ADC	BSWRK6
		STA	BSWRK7
		LDY	BSTIM0
		BNE	BKSP010 ; Protect time !
;
		LDA	BSWRK7
		CMP	#000H
		BNE	BKSP010
;
BKSP2SET	EQU	$
		STZ	BSWRK7
;
		STZ	<ENCONT,X
;
;;		  INC	  BSSTAT
		LDA	#BKSP2
		STA	BSSTAT
BKSP010		EQU	$
		RTS
;================================================================
BKSPSPT		EQU	$
		HEX	16,16,16,16
		HEX	15,15,15,15
		HEX	14,14,14,14
		HEX	12,12,12,12
		HEX	12,12,12,12
		HEX	12,12,12,12
		HEX	12,12,12,12
		HEX	12,12,12,12
		HEX	12,12,12,12
		HEX	12,12,12,12
		HEX	FF
;
BKSPINS		EQU	$
		TYX
;
		LDA	#0040H
		STA	ENGPOW,X
;
		JSR	BSXDOWN
		HEX	EA,EA,EA
		HEX	EA,EA,EA
;
		LDY	<ENCONT,X
		INC	<ENCONT,X
		LDA	BKSPSPT,Y
		BMI	BKSPSEND
;
		STA	BSCHPT
;
		RTS
BKSPSEND	EQU	$
		JMP	BKSP2SET
;================================================================
BKSP2PT		EQU	$
SP20		HEX	12,12,12,12,12
		HEX	12,12,12,12,12
		HEX	12,12,12,12,12
		HEX	12,12,12,12,12
		HEX	13,13,13,13,13
		HEX	13,13,13,13,13
		HEX	12,12,12,12
		HEX	13,13,13,13,13
		HEX	13,13,13,13,13
SP21		HEX	14,14,14,14
SP2J		HEX	15,15,15,15
		HEX	16,16,16,16
SP22		HEX	00,00,00,00
		HEX	0F,0F,0F,0F
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	FF
BKSP2XS		EQU	$
		WORD	00000H,0000H
;;		  WORD	  0FF00H,0100H
;
BKSPIN2		EQU	$
		TYX
;
		LDA	#0040H
		STA	ENGPOW,X
;
		JSR	BSXDOWN
		HEX	EA,EA,EA
		HEX	EA,EA,EA
;
		LDY	<ENCONT,X
		INC	<ENCONT,X
		LDA	BKSP2PT,Y
		BMI	BKSP2END
;
		STA	BSCHPT
;
		CPY	#SP2J-SP20
		BNE	BKSP2008
;
		LDA	#80H
		STA	ENYSPD,X
		LDA	#0FDH
		STA	ENYSPD+1,X
;
		LSR	ENCBFG,X
		ASL	ENCBFG,X
BKSP2008	EQU	$
		CPY	#SP21-SP20
		BCC	BKSP2010
		CPY	#SP22-SP20
		BCS	BKSP2010
;
;		 LDA	 BSMUKI
;		 ASL	 A
;		 TAY
		LDY	ENMUKI,X
		M16
		LDA	BKSP2XS,Y
;;		  STA	  BSXSPD
		STA	ENXSPD,X
		M8
BKSP2010	EQU	$
		RTS
BKSP2END	EQU	$
;--END
BKWSETJ		EQU	$
		JSR	BKWSET
		RTS
;------------------------------------
BKPISET		EQU	$
		LDA	#BKPI
		STA	BSSTAT
;
		STZ	<ENCONT,X
;
		RTS
;================================================================
BKPHDT		EQU	$
		HEX	17,17
		HEX	18,18
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	1A,1A,1A,1A
		HEX	19,19,19,19
		HEX	18,18,18,18
		HEX	17,17,17,17
		HEX	FF
;
BKPIXS		EQU	$
		WORD	0100H,0FF00H,0100H
;
BKPINCH		EQU	$
		TYX
;
		LDA	ENMOD1+1,X
		AND	#11111100B
		STA	ENMOD1+1,X
;
;;		  STZ	  BSXSPD
;		 STZ	 ENXSPD,X
;		 STZ	 ENXSPD+1,X
;
		LDA	BSWRK7
		BNE	BKPH010
;
		LDA	<ENCONT,X
		LSR	A
		LSR	A
		NOP
		NOP
		NOP
		NOP
		ASL	A
		AND	#02H
		CLC
		ADC	ENMUKI,X
		TAY
		M16
		LDA	BKPIXS,Y
		STA	ENXSPD,X
;
		STZ	ENYSPD,X
		STZ	ENGPOW,X
		M8
;
		LDY	<ENCONT,X
		INC	<ENCONT,X
		LDA	BKPHDT,Y
		BPL	BKCH003
;
;		 LDA	 ENMOD1+1,X
;		 AND	 #11111100B
;		 ORA	 #00000010B
;		 STA	 ENMOD1+1,X
		JMP	BKWSET
BKCH003		EQU	$
		PHA
;
		LDA	#000H
		LDY	BSWRK6
		BMI	BKCH008
		LDA	#002H
;;		  INY
BKCH008		EQU	$
		PLY
		CMP	ENMUKI,X ;BSMUKI
		BNE	BKCH00C
;
;;		CLC
;;		ADC	#04H
		INY
		INY
		INY
		INY
BKCH00C		EQU	$
		STY	BSCHPT
;
		RTS
BKPH010		EQU	$
		CLC
		ADC	BSWRK6
		STA	BSWRK7
;
		LDA	#12H
		STA	BSCHPT
		RTS
;======================================================
BKE0YS		EQU	$
		WORD	0080H,0FF80H
BKYGYS		EQU	$
		WORD	0FF60H
		WORD	0FF80H
		WORD	0FF70H
		WORD	0FF80H
;
BKEND0		EQU	$
		TYX
;
		LDA	#12H
		STA	BSCHPT
;
		LDA	ENYPSL,X
		CMP	#00D0H
		BCC	BKSB018
;
		INC	BSSTAT
;
		LDA	#060H
		STA	ENTIM0,X
BKSB018		EQU	$
		LDA	BSWRK7
		BEQ	BKSB019
		CLC
		ADC	BSWRK6
		STA	BSWRK7
;
BKSB019		EQU	$
		LDY	#01H
;
		LDA	FRCNT
		BIT	#03H
		BNE	BKSB01C
		AND	#020H
		BEQ	BKSB01A
;
		LDY	#0FFH
BKSB01A		EQU	$
		TYA
		CLC
		ADC	BSANGL1
		STA	BSANGL1
BKSB01C		EQU	$
;
		M16
;
		STZ	ENXSPD,X
;
		LDA	FRCNT
		LSR	A
		LSR	A
		NOP
		NOP
		NOP
		AND	#02H
		TAY
		LDA	BKE0YS,Y
		CLC
		ADC	#0040H
		STA	ENYSPD,X
;
BKYGST		EQU	$
		M16
;
		LDA	FRCNT
		AND	#003H
		BNE	BKE0010
;
		LDA	<RANDM0
		AND	#003FH
		CLC
		ADC	#0FFE0H
		STA	<EWORK0
		ASL	A
		ASL	A
		NOP
		STA	<EWORK2
;
		LDA	<RANDM0
		AND	#03H
		ASL	A
		TAY
		LDA	BKYGYS,Y
		STA	<EWORK4
;
;		 LDA	 #YOGN0
;		 JSL	 >EXINSR
;;
;		 LDA	 <RANDM0
;		 AND	 #02H
;		 STA	 !EXMUKI,Y
;;
;		 LDA	 ENXPSL,X
;		 CLC
;		 ADC	 <EWORK0
;		 STA	 !EXXPSL,Y
;		 LDA	 #07B0H
;		 STA	 !EXYPSL,Y
;		 LDA	 <EWORK2 ;#0000H
;		 STA	 !EXXSPD,Y
;		 LDA	 <EWORK4 ;#-0300H
;		 STA	 !EXYSPD,Y
;		 LDA	 #00010H
;		 STA	 !EXTIM0,Y
;		 LDA	 #0002
;		 STA	 !EXCHPT,Y
;;
		LDA	#YGUP0		;(A) <-- exstra no.
		JSL	>EXINSR		;exstra index search
;
		LDA	ENXPSL,X
		CLC
		ADC	<EWORK0
		STA	EXXPSL,Y	;X pos set
		LDA	#07C0H
		STA	EXYPSL,Y	;Y pos set
		LDA	<EWORK2 ;#0000H
		STA	!EXXSPD,Y
		LDA	<EWORK4 ;#0FF40H
		STA	EXYSPD,Y	;Y speed set
		LDA	#4*12
		STA	EXTIM0,Y	;timer set
;
		LDA	#SMK02
		JSL	>EXINSR
;
		LDA	ENXPSL,X
		CLC
		ADC	<EWORK0
		STA	EXXPSL,Y
		LDA	#07C0H
		STA	EXYPSL,Y
		LDA	#0000CH
		STA	EXTIM0,Y
		LDA	#00002H
		STA	EXWRK0,Y
;
BKE0010		EQU	$
		M8
;
		JSR	BKENDSDS	;(S)
		RTS
;==================================================
BKYUXD		EQU	$
		WORD	-0010H
		WORD	-000CH
		WORD	-0008H
		WORD	-0004H
		WORD	00004H
		WORD	00008H
		WORD	0000CH
		WORD	00010H
;
		WORD	-0010H-2
		WORD	-000CH-2
		WORD	-0008H-2
		WORD	-0004H-2
		WORD	00004H+2
		WORD	00008H+2
		WORD	0000CH+2
		WORD	00010H+2
BKYUXS		EQU	$
		WORD	-0100H
		WORD	-00C0H
		WORD	-0080H
		WORD	-0040H
		WORD	00040H
		WORD	00080H
		WORD	000C0H
		WORD	00100H
;
		WORD	-0100H+20H
		WORD	-00C0H+20H
		WORD	-0080H+20H
		WORD	-0040H+20H
		WORD	00040H-20H
		WORD	00080H-20H
		WORD	000C0H-20H
		WORD	00100H-20H
;
BKYUYS		EQU	$
		WORD	-01E0H
		WORD	-0200H
		WORD	-01C0H
		WORD	-01F0H
		WORD	-0210H
		WORD	-0208H
		WORD	-01D0H
		WORD	-01A0H
;
		WORD	-01A8H
		WORD	-01D8H
		WORD	-0210H
		WORD	-0218H
		WORD	-01F8H
		WORD	-01C8H
		WORD	-0208H
		WORD	-01E8H
;
BKYUTM		EQU	$
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
;
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
		WORD	4*12
;
BKYUPST		EQU	$
		M16
;
		LDA	ENXPSL,X
		STA	<EWORK0
;
		LDA	#0FH*2
		STA	<EWORK8
BKYU010		EQU	$
		LDA	#YGUP0		;(A) <-- exstra no.
		JSL	>EXINSR		;exstra index search
;
		LDX	<EWORK8
;
		LDA	<EWORK0
		CLC
		ADC	BKYUXD,X
		STA	EXXPSL,Y	;X pos set
;
		LDA	#07C0H
		STA	EXYPSL,Y	;Y pos set
;
		LDA	BKYUXS,X
		STA	EXXSPD,Y
;
		LDA	BKYUYS,X
		STA	EXYSPD,Y	;Y speed set
;
		LDA	BKYUTM,X
		STA	EXTIM0,Y	;timer set
;
		LDA	#0020H
		STA	EXGPOW,Y
;
		LDX	<ENINDX
;
		DEC	<EWORK8
		DEC	<EWORK8
		BPL	BKYU010
;
		M8
		RTS
;======================================================
BKE1YS		EQU	$
		WORD	0080H,0FF00H
BKEND1		EQU	$
		TYX
;
		JSR	BKYGST
;
		LDA	ENTIM0,X
		BNE	BKD1008
;
		INC	BSSTAT
BKD1008		EQU	$
		LDY	#012H
		LDA	FRCNT
		AND	#018H
		BEQ	BKE1010
		INY
BKE1010		EQU	$
		STY	BSCHPT
;
		LDY	#01H
;
		LDA	FRCNT
		BIT	#00H
		BNE	BKE101C
		AND	#08H
		BEQ	BKE101A
;
		LDY	#0FFH
BKE101A		EQU	$
		TYA
		CLC
		ADC	BSANGL1
		STA	BSANGL1
BKE101C		EQU	$
;
		M16
		LDA	FRCNT
		LSR	A
		LSR	A
		NOP
		NOP
		AND	#02H
		TAY
		LDA	BKE1YS,Y
		STA	ENYSPD,X
BKENDSDS	EQU	$
		M8
;
		LDA	FRCNT
		AND	#001FH
		BNE	BKESS010
;
		LDA	#062H
		JSL	>SOUND_3_ON	;(S)
;
BKESS010	EQU	$
		RTS
;==================================================
BKE2AD		EQU	$
		HEX	FF,01
;
BKEND2		EQU	$
		TYX
;
		JSR	BKYGST
;
		LDA	#040H
		STA	ENYSPD,X
		STZ	ENYSPD+1,X
;
		LDA	FRCNT
		AND	#03H
		BNE	BKE2008
;
		LDA	ENMUKI,X
		LSR	A
		TAY
		LDA	BKE2AD,Y
		CLC
		ADC	BSWRK7
		STA	BSWRK7
;
BKE2008		EQU	$
		LDA	ENYPSH,X
		CMP	#08H
		BCC	BKE2010
;
		LDA	#BKEND
		STA	BSSTAT
;
		LDA	#020H	;#0FFH
		STA	ENTIM0,X
;
		M16
;
		JSL	>BOSS_EN_CHANGE
;
;;		LDA	#05H
;;		STA	!SOUND_0    ; (S)
;
		LDA	ENXPSL,X
		CLC
		ADC	#000H
		STA	<EWORK0
;
		LDA	ENYPSL,X
		CLC
		ADC	#000H
		STA	<EWORK2
		JSL	>BSCLW_SET_M   ;
		M8
BKE2010		EQU	$
		JSR	BKENDSDS	;(S)
		RTS
;
;======================================================
BKENDS		EQU	$
		TYX
;
		LDA	ENTIM0,X
		BNE	BKED010
;
;;		  LDA	  #BS_SCRE
;;		  STA	  !MODENO
		M16
;;		JSL	>BOSS_CLEAR_M  ; Boss clear !
		JSL	>ENCLEAR_NORETN	 ;
		M8
BKED010		EQU	$
		RTS
;----------------------------------------------------------
BSXDOWN		EQU	$
		M16
;
		LDA	ENXSPD,X ;BSXSPD
		BEQ	BSXD010
		BPL	BSXD008
		CLC
		ADC	#0010H	 ;INC	  BSXSPD
		BRA	BSXD010
BSXD008		EQU	$
;;		  DEC	  BSXSPD
		SEC
		SBC	#0010H
BSXD010		EQU	$
		STA	ENXSPD,X
		M8
		RTS
;----------------------------------------------------------
BSXDOWN2	EQU	$
		M16
;
		LDA	ENXSPD,X ;BSXSPD
		BEQ	BSXD0102
		BPL	BSXD0082
		CLC
		ADC	#0002H	 ;INC	  BSXSPD
		BRA	BSXD0102
BSXD0082	EQU	$
;;		  DEC	  BSXSPD
		SEC
		SBC	#0002H
BSXD0102	EQU	$
		STA	ENXSPD,X
		RTS
;----------------------------------------------------------
EPXCHK		EQU	$
		M16
;
		LDY	#00H
		LDA	ENXPSL,X
		SEC
		SBC	PLXPSL
		STA	<EWORKE
		BPL	EPX010
;
		LDY	#02H
EPX010		EQU	$
		M8
		RTS
;----------------------------------------------------------
BKTSDT		EQU	$
		HEX	F8,08
BKTSXS		EQU	$
; Tyobi
		WORD	00100H,0FF00H
		WORD	00200H,0FE00H
; Max
		WORD	00100H,0FF00H
		WORD	00200H,0FE00H
;
;;		  HEX	  18,E8
;
BKTEST		EQU	$
		M16
;
		LDY	ECRSFG,X
		DEY
		BPL	BKT010B
;
BKT010J		EQU	$
		JMP	BKT010
;
BKT010B		EQU	$
		LDA	BSTIM2
		BNE	BKT010J	 ; protect time ?
;
		LDA	ENMODE,Y
		CMP	#EMOVE
		BNE	BKT010J
;
		LDA	ENSHOT,Y
		BEQ	BKT010J
;
		LDA	ENGPOW,Y
		STA	<EWORK0
;		 CMP	 #003FH
;		 BEQ	 BKT010	    ; High power ?
;
		LDA	ENXSPD,Y
		ASL	A
;
		M8
;
		LDY	#00
		BCC	BKT008
		INY
BKT008		EQU	$
		LDA	#BKSPS
		STA	BSSTAT
;
		STZ	<ENCONT,X
;
		LDA	BKTSDT,Y
		STA	BSWRK6
;
		ROR	A
		EOR	ENSLOP,X
		BPL	BKT00C
;
		INY
		INY
BKT00C		EQU	$
		LDA	<EWORK0
		CMP	#00H
		BNE	BKT00E	; High power ?
		INY		; yes !
		INY
		INY
		INY
;
		LDA	#BKSP
		STA	BSSTAT
BKT00E		EQU	$
		TYA
		ASL	A
		TAY
		M16
		LDA	BKTSXS,Y
		STA	ENXSPD,X
;;;		   STA	   BSXSPD
		M8
;
;;		  LDA	  BSWRK8
		LDA	ENCBFG,X
		AND	#01H
		BNE	BKT00A	     ; flying ?
;
;;		  STZ	  BSXSPD
;		 STZ	 ENXSPD,X
;		 STZ	 ENXSPD+1,X
;
		LDY	ECRSFG,X
		DEY
		M16
		LDA	ENXSPD,Y
		STA	ENXSPD,X
		ASL	A
		PHP
		PHP
		ROR	ENXSPD,X
		PLP
		ROR	ENXSPD,X
		PLP
		ROR	ENXSPD,X
		M8
;
		LDA	#00H
		STA	ENYSPD,X
		LDA	#0FEH
		STA	ENYSPD+1,X
;
		LSR	ENCBFG,X
		ASL	ENCBFG,X
BKT00A		EQU	$
		LDA	#02EH
		JSL	>SOUND_3_ON	;(S)
;
		LDA	#20H
		STA	BSTIM2
;		 LDA	 #BKSP
;		 STA	 BSSTAT
;;
;		 LDA	 #04H
;		 STA	 BSTIM0
;
		M16
;
;
		LDY	ECRSFG,X
		DEY
		TYX
		STZ	ENSHOT,X
		JSL	>SHOT_EN_KILL
		LDX	<ENINDX
BKT010		EQU	$
		M8
		RTS
;
;		 LDA	 KEYA2L
;		 LSR	 A
;		 LSR	 A
;		 LSR	 A
;		 LSR	 A
;		 AND	 #03H
;		 BEQ	 BKTS0E0
;;
;		 TAY
;		 LDA	 BKTSDT,Y
;		 STA	 <EWORK6
;		 LDA	 BKTSXS,Y
;		 STA	 BSXSPD
;;
;		 LDA	 #BKSP
;		 STA	 BSSTAT
;;
;		 LDA	 #04H
;		 STA	 BSTIM0
;BKTS0E0	 EQU	 $
;		 RTS
;
;
;------------------------------------------------------------------------
;-		回転キャラクター作成					-
;------------------------------------------------------------------------
BOSSK_CHR_ADR	EQU	$
		WORD	CIPCHD3+4080H+1 ;顔１
		WORD	CIPCHD3+40A0H+1 ;顔２
		WORD	CIPCHD3+6080H+1 ;顔３
		WORD	CIPCHD3+60A0H+1 ;足
;
BKCHTR		EQU	$
		M16
;
		LDA	ENCHPT,X
		BNE	BKTR020
;
		LDA	FRCNT
		AND	#01H
		BNE	BKTR010
;---
		LDA	<ENWRK9,X  ; Kao puturn
		AND	#0FH
		ASL	A
		STA	<EWORK2
;
		LDA	#040H		;<-- 顔
		STA	<EWORK0
;
		LDA	BSANGL1
		CLC
		ADC	BSWRK7
		JSR	BKCHSUB
;
		BRA	BKTR020
;
BKTR010		EQU	$
		LDA	#03H*2
		STA	<EWORK2
;---
		LDA	#060H		;<-- 足
		STA	<EWORK0
;
		LDA	BSANGL2
		CLC
		ADC	BSWRK7
		JSR	BKCHSUB
;---
		JSR	BKCHSUBB	;<-- BODY
;
BKTR020		EQU	$
		M8
		RTS
;====================================================
BKCHSUB		EQU	$
		MEM16
;
;;;		   LDA	   BSANGL2
		LDY	ENMUKI,X
		BEQ	BOSSKMV_0010
		EOR	#00FFH
		INC	A
BOSSKMV_0010	EQU	$
		AND	#00FFH
		STA	R5		;(R5) <-- 回転角度
;
		LDA	BSXSIZ ;#0100H
		INC	A
		STA	R6		;(R6)  <-- Ｘ倍率
;
		LDY	<EWORK2
		LDA	!BOSSK_CHR_ADR,Y
		STA	R12		;(R12) <-- キャラクターアドレス（Ｌ，Ｈ）
;
		LDA	#BANK CIPCHD3
		STA	R13		;(R13) <--	   ”		(Ｂ）
;
		LDA	<EWORK0
		STA	R3		;(R3)  <-- ビットマップ座標＿Ｘ
		LDA	#000H
		STA	R2		;(R2)  <--	  ”	   ＿Ｘ
		M_CHIP	C_32_ROTZOM
;
		INC	OBM7WF		;mode 7 OBJ chara DMA "ON"
;
		LDX	<ENINDX
		RTS
;
;====================================================
BKCHSUBB	EQU	$
		MEM16
;
		LDY	BSWRK7
		TYA
		CLC
		ADC	BSANGL1
		LDY	ENMUKI,X
		BEQ	BOSSKMB_0010
		EOR	#00FFH
		INC	A
BOSSKMB_0010	EQU	$
		AND	#00FFH
		STA	R5		;(R5) <-- 回転角度
;
		LDA	BSXSIZ ;#0100H
		INC	A
		STA	R6		;(R6)  <-- Ｘ倍率
;
		LDY	<EWORK2
		LDA	#CIPCHD3+00C0H+1
		STA	R12		;(R12) <-- キャラクターアドレス（Ｌ，Ｈ）
;
		LDA	#BANK CIPCHD3	;
		STA	R13		;(R13) <--	   ”		(Ｂ）
;
		LDA	#000H
		STA	R3		;(R3)  <-- ビットマップ座標＿Ｘ
		STA	R2		;(R2)  <--	  ”	   ＿Ｘ
		M_CHIP	C_64_ROTZOM_V64
;
		INC	OBM7WF		;mode 7 OBJ chara DMA "ON"
;
		LDX	<ENINDX
		RTS
;



		MEM8
;
;=========================================================================
;=========================================================================
KTANGDTD	EQU	$  ; Buhin angle data
   HEX	   b0,98,05,f7,b0,98,09,f5,b0,98,0a,f2,b0,98,0d,ef    ;................
   HEX	   b0,98,0f,ec,b0,98,11,e9,b0,98,17,e9,b1,98,18,e8    ;................
   HEX	   b0,98,17,e9,b0,98,17,ee,b0,98,f0,14,b0,98,12,f4    ;................
   HEX	   b0,98,10,f7,b0,98,0c,f9,b0,98,05,f8,b0,98,06,f6    ;................
   HEX	   b0,98,06,f9,b0,98,09,fd,b0,98,df,d7,b0,98,df,d7    ;...............
   HEX	   b0,98,e6,db,b0,98,f0,e2,b0,98,fb,ee,b0,98,12,fb    ;...............
   HEX	   b0,98,1c,fb,b0,98,29,03,b0,98,29,02,b0,98,06,ec    ;.....)...).....
   HEX	   b0,98,03,e0,b0,98,02,d9,b0,98,fd,d6		       ;...............
   HEX	   ac,98,10,f0,a0,98,17,e9
;
KTHNKDTD	EQU	$  ; Buhin hankei data
  HEX	   17,0a,19,1a,17,0a,1d,18,17,0a,1f,1a,17,0a,20,19    ;.............. .
  HEX	   17,0a,22,1b,17,0a,20,1c,17,0a,1f,1f,17,0a,1e,1e    ;.."... .........
  HEX	   17,0a,1e,1e,17,0a,1c,20,17,0a,21,1b,17,0a,19,20    ;....... ..!....
  HEX	   17,0a,19,20,17,0a,1a,1e,17,0a,19,1a,17,0a,17,18    ;... ............
  HEX	   17,0a,20,20,17,0a,24,25,17,0a,13,1a,17,0a,13,1a    ;.  ..$%........
  HEX	   17,0a,14,1a,17,0a,16,1a,17,0a,19,1b,17,0a,1d,1e    ;...............
  HEX	   17,0a,1c,23,17,0a,20,26,17,0a,1e,25,17,0a,1f,1d    ;..#.. &...%....
  HEX	   17,0a,23,1e,17,0a,25,1b,17,0a,26,1f		      ;.#...%...&.....
  HEX	   13,0a,1c,1c,0c,0a,1e,1e
;
AADATA		EQU	$      ; Asi angle !
		HEX	00 ;00
		HEX	00 ;01
		HEX	00 ;02
		HEX	00 ;03
		HEX	00 ;04
		HEX	00 ;05
		HEX	00 ;06
		HEX	00 ;07
		HEX	00 ;08
		HEX	00 ;09
		HEX	00 ;0A
		HEX	00 ;0B
		HEX	00 ;0C
		HEX	00 ;0D
		HEX	00 ;0E
		HEX	00 ;0F
		HEX	03 ;10
		HEX	06 ;11
		HEX	1A ;12
		HEX	1A ;13
		HEX	1C ;14
		HEX	1D ;15
		HEX	1F ;16
		HEX	02 ;17
		HEX	05 ;18
		HEX	09 ;19
		HEX	08 ;1A
		HEX	03 ;1B
		HEX	06 ;1C
		HEX	08 ;1D
		HEX	07 ;1E
;
		HEX	00 ;1F
		HEX	00 ;20
;
KAOCHDT		EQU	$      ; KAO ch no.
		HEX	00 ;00
		HEX	00 ;01
		HEX	00 ;02
		HEX	00 ;03
		HEX	00 ;04
		HEX	00 ;05
		HEX	00 ;06
		HEX	00 ;07
		HEX	00 ;08
		HEX	00 ;09
		HEX	00 ;0A
		HEX	00 ;0B
		HEX	00 ;0C
		HEX	00 ;0D
		HEX	00 ;0E
		HEX	00 ;0F
		HEX	00 ;10
		HEX	00 ;11
		HEX	01 ;12
		HEX	02 ;13
		HEX	02 ;14
		HEX	02 ;15
		HEX	02 ;16
		HEX	02 ;17
		HEX	02 ;18
		HEX	02 ;19
		HEX	02 ;1A
		HEX	02 ;1B
		HEX	02 ;1C
		HEX	02 ;1D
		HEX	02 ;1E
;
		HEX	00 ;1F
		HEX	00 ;20
;------------------------------------
KTSUB		EQU	$
		LDA	ENCHPT,X
		BEQ	KTS0000
;
KTSRTS		EQU	$
		RTS
KTS0000		EQU	$
		LDA	ENOAML+1,X
		BMI	KTSRTS
;
		LDY	BSCHPT
;
		LDA	KAOCHDT,Y
		STA	<ENWRK9,X	; Kao pt.
;
		LDA	AADATA,Y
		ASL	A
		ASL	A
		ASL	A
		LDY	ENMUKI,X ;BSMUKI
		BEQ	KTS002
		EOR	#0FFH
		INC	A
KTS002		EQU	$
		CLC
		ADC	BSANGL1
		STA	BSANGL2	 ; asi angle
;;;;		    JSR	    KTBDYCS
;
		LDA	#03H
		STA	<EWORKA
KTS010		EQU	$
		LDA	BSCHPT
		ASL	A
		ASL	A
		CLC
		ADC	<EWORKA
		TAY
		LDA	KTHNKDTD,Y
		STA	4202H
;
		PHX
;
		LDX	BSXSIZ
		INX
		STX	4203H
		BEQ	KTS011
;
		HEX	EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
KTS011		EQU	$
		STA	<EWORKE
;
		PLX
;
		LDA	KTANGDTD,Y
		LDY	ENMUKI,X ;BSMUKI
		BEQ	KTS012
		EOR	#0FFH
		INC	A
KTS012		EQU	$
		STA	<EWORK0
;
		JSR	KTCLC
;
		DEC	<EWORKA
		BPL	KTS010
;
		LDY	BSCHPT
;
		LDA	BKRVYD,Y  ; Display ypos revise
		CLC
		ADC	#000H
		PHA
		BPL	KTS088
		EOR	#0FFH
		INC	A
KTS088		EQU	$
		STA	<EWORKE
;
		LDA	BSANGL1
;;		  CLC
;;		  ADC	  BSWRK7     ; KAOangle !
		CLC
		ADC	#080H
;		 LDY	 BSMUKI
;		 BEQ	 KTS08A
;		 EOR	 #0FFH
;		 INC	 A
;KTS08A		 EQU	 $
		STA	<EWORKC
		JSR	YTCSET2
;
		PLY
;
		M16
;
		LDA	<EWORK2
		CPY	#00H
		BPL	KTS090
		EOR	#0FFFFH
		INC	A
KTS090		EQU	$
		STA	R1
;
		LDA	<EWORK0
		CPY	#00H
		BPL	KTS0A0
		EOR	#0FFFFH
		INC	A
KTS0A0		EQU	$
		STA	R2
;
		LDA	ENOAML,X
		STA	R3
;
		M_CHIP	BK_OAM_RV
;
		M8
		LDX	<ENINDX
		RTS
;
;=============================================
BKRVYD		EQU	$
		HEX	00 ;00
		HEX	03 ;01
		HEX	05 ;02
		HEX	05 ;03
		HEX	07 ;04
		HEX	04 ;05
		HEX	01 ;06
		HEX	00 ;07
		HEX	00 ;08
		HEX	04 ;09
		HEX	06 ;0A
		HEX	06 ;0B
		HEX	06 ;0C
		HEX	05 ;0D
		HEX	00 ;0E
		HEX	FE ;0F
;
		HEX	02 ;10
		HEX	04 ;11
		HEX	00 ;12
		HEX	00 ;13
		HEX	00 ;14
		HEX	00 ;15
		HEX	00 ;16
		HEX	06 ;17
		HEX	0E ;18
		HEX	0F ;19
		HEX	0E ;1A
		HEX	06 ;1B
		HEX	0E ;1C
		HEX	0F ;1D
		HEX	0E ;1E
;
		HEX	00 ;1F
		HEX	00 ;20
;=============================================
KTCLC		EQU	$
		LDA	BSANGL1	 ; Siisoo angle !
		CLC
		ADC	BSWRK7
		CLC
		ADC	<EWORK0
		STA	<EWORKC
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#00000110B
		TAX
		JMP	(KTCADRS,X)
KTCADRS		EQU	$
		WORD	KTC000
		WORD	KTC001
		WORD	KTC002
		WORD	KTC003
;----------------------------------------------------------
KTC000		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK0	  ; Y POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK2	  ; X POS
		JMP	KTCSET
;----------------------------------------------------------
KTC001		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK2	  ; X POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK0	  ; Y POS
		JMP	KTCSET
;----------------------------------------------------------
KTC002		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK0	  ; Y POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK2	  ; X POS
		JMP	KTCSET
;----------------------------------------------------------
KTC003		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK2	  ; X POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK0	  ; Y POS
		JMP	KTCSET
;=========================================================================
KTOMID		EQU	$
		HEX	00,48,08,28
;
KTCSET		EQU	$
		LDX	<ENINDX
;
		STZ	<EWORK1
		LDA	<EWORK0
		BPL	KTCS000
		DEC	<EWORK1
KTCS000		EQU	$
		STZ	<EWORK3
		LDA	<EWORK2
		BPL	KTCS001
		DEC	<EWORK3
KTCS001		EQU	$	   ; EWORK0=Y pos EWORK2 XPOS
		STZ	<EWORKB
;
		LDA	<EWORKA
;;		BNE	KTCS002
;
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FH
		TAY
;
		CPY	#01H
		BCC	KTCS018
;
		LDA	ENMUKI,X ;BSMUKI
		AND	#0FFH
		BEQ	KTCS018
;
		LDA	KTOMID,Y
		AND	#0FFH
		CLC
		ADC	ENOAML,X
		TAY
		LDA	SOAM_DX+000H,Y
		CLC
		ADC	<EWORK2
		CLC
		ADC	#0000H
		STA	SOAM_DX+000H,Y
;
		STA	SOAM_DX+010H,Y
		CLC
		ADC	#0FFF0H
		STA	SOAM_DX+008H,Y
		STA	SOAM_DX+018H,Y
		BRA	KTCS020
;------------------------------------------------
KTCS018		EQU	$
		LDA	KTOMID,Y
		AND	#0FFH
		CLC
		ADC	ENOAML,X
		TAY
		LDA	SOAM_DX+000H,Y
		CLC
		ADC	<EWORK2
		STA	SOAM_DX+000H,Y
;
		LDX	<EWORKA
		BEQ	KTCS020
;
		STA	SOAM_DX+010H,Y
		CLC
		ADC	#0010H
		STA	SOAM_DX+008H,Y
		STA	SOAM_DX+018H,Y
;
KTCS020		EQU	$
		LDA	SOAM_DX+2,Y
		CLC
		ADC	<EWORK0
		STA	SOAM_DX+2,Y
;
		LDX	<EWORKA
		BEQ	KTCS002
;
		STA	SOAM_DX+00AH,Y
		CLC
		ADC	#0010H
		STA	SOAM_DX+012H,Y
		STA	SOAM_DX+01AH,Y
KTCS002		EQU	$
		LDA	<ENINDX
		AND	#0FFH
		TAX
		LDY	ENOAML,X
;
		LDA	BSXSIZ
		AND	#00FFH
		SEC
		SBC	#0050H
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		ASL	A
		TAX
;
		LDA	SOAM_DX+004H,Y
		AND	#1111111100000000B
		ORA	BKHANACD,X ;#010EH
		STA	SOAM_DX+004H,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDX	<ENINDX
		RTS
;
;----------------------------------------------------------------------
;KTBDYCS	 EQU	 $
;		 RTS
;----------------------------------------------------------------------
;----------------------------------------------------------------------


BKHANACD	EQU	$
		HEX	08,0 ;5
		HEX	08,0 ;6
		HEX	08,0 ;7
		HEX	08,0 ;8
		HEX	0A,0 ;9
		HEX	0A,0 ;A
		HEX	0A,0 ;B
		HEX	0A,0 ;C
		HEX	0C,0 ;D
		HEX	0C,0 ;E
		HEX	0E,0 ;F
















		M16
		I8






;************************************************************************
;*		initial ( ボスＱちゃん spark)				*
;************************************************************************
QSPAKIN		EQU	$
;
		RTL
;
;************************************************************************
;*		move	( ボスＱちゃん spark)				*
;************************************************************************
QSPKAD		EQU	$
		WORD	00003H,0FFFDH
;
QSPCDT		EQU	$
		BYTE	00H,00H,00H,00H
		BYTE	04H,04H,04H,04H
		HEX	FF
QSPAKMV		EQU	$
		JSL	>ENMDCK ;
;
		M8
;
		LDA	#047H
		STA	>SOUND_1	;(S)
;
		LDA	ENWRK8,X
		BEQ	QSM002
;
		LDY	ENWRKA,X
		INC	ENWRKA,X
		LDA	QSPCDT,Y
		BMI	QSM00C
;
		STA	ENCHPT,X
;
		LDA	ENMOD2,X
		AND	#11111100B
		STA	ENMOD2,X
;
		M16
		RTL
;
		MEM8
QSM002		EQU	$
		LDY	ENMUKI,X
		LDA	ENWRK2,X
		CLC
		ADC	QSPKAD,Y
		STA	ENWRK2,X
;
		CLC
		ADC	ENWRK0,X
		STA	<EWORK0
;
		LDA	#38H
		STA	<EWORKE
		JSR	B_LOOPS
;
		LDA	FRCNT
		AND	#03H
		CLC
		ADC	ENWRK4,X
		STA	ENCHPT,X
;
		LDA	FRCNT
		AND	#00H
		BNE	QSM030
;
		LDA	ENWRK6,X
		CLC
		ADC	#01H   ;QSPKAD+00H  ;#03H
		STA	ENWRK6,X
		CMP	#080H
		BCC	QSM030
;
		INC	ENWRK8,X
QSM030		EQU	$
		JSR	EPCRCKS
		M16
		RTL
;=========================================
QSM00C		EQU	$
		M16
		JSL	>ENCLEAR
		RTL
;************************************************************************
;*		QSPAK SET						*
;************************************************************************
QSPADT		EQU	$
		WORD	0FFF8H,00008H
QSPADT2		EQU	$
		WORD	0FFF0H,00010H
;
QSPAKSET	EQU	$
		M8
		LDA	BSMUKI
		PHA
		M16
;
		LDA	#47H
		JSL	>SOUND_3_ON    ;(S)
;
		LDA	#018H
		STA	TILTCT
;
		M8
;
		STZ	BSMUKI
		JSR	QSPAKSETS
		LDA	#02H
		STA	BSMUKI
		JSR	QSPAKSETS
		PLA
		STA	BSMUKI
		RTS
;================================================================
QSPAKSETS	EQU	$
		M16
;
		LDA	#QSPAK
		JSL	>ENINSR
		M8
		BCC	QSPS010
;
		LDA	BSANGL1
		STA	ENWRK0,Y
;
		LDA	BSMUKI
		STA	ENMUKI,Y
;
		LDA	#00H
		STA	ENWRK4,Y  ; DAI
;
		LDA	#05H
		STA	ENYUSN,Y
QSPS010		EQU	$
;
		M16
		LDA	#QSPAK
		JSL	>ENINSR
		M8
		BCC	QSPS020
;
		LDX	BSMUKI
		TXA
		STA	ENMUKI,Y
;
		LDA	BSANGL1
		CLC
		ADC	QSPADT,X
		STA	ENWRK0,Y
;
		LDA	#00H
		STA	ENWRK4,Y  ;CYUU
;
		LDA	ENMOD2,Y
		AND	#11111100B
		STA	ENMOD2,Y
;
		LDA	#06H
		STA	ENYUSN,Y
;
		LDA	#04H
		STA	ENWRKA,Y
;
		LDX	<ENINDX
QSPS020		EQU	$
;
		M16
		LDA	#QSPAK
		JSL	>ENINSR
		M8
		BCC	QSPS030
;
		LDX	BSMUKI
		TXA
		STA	ENMUKI,Y
;
		LDA	BSANGL1
		CLC
		ADC	QSPADT2,X
		STA	ENWRK0,Y
;
		LDA	#04H
		STA	ENWRK4,Y  ;SYOU
;
		LDA	ENMOD2,Y
		AND	#11111100B
		STA	ENMOD2,Y
;
		LDA	#07H
		STA	ENYUSN,Y
;
		LDA	#06H
		STA	ENWRKA,Y
;
		LDX	<ENINDX
QSPS030		EQU	$
		M8
		RTS
;
		MEM16
;************************************************************************
;*		initial ( ボスＱちゃん )				*
;************************************************************************
BOSSQIN		EQU	$
		JSR	YENINIT
;
		RTL
;
;************************************************************************
;*		move	( ボスＱちゃん )				*
;************************************************************************
BOSSQ_CHR_ADR	EQU	$
		WORD	CIPCHD3+0080H+1
		WORD	CIPCHD3+00C0H+1
;
BOSSQMV		EQU	$
		LDA	DSPMOD
		CMP	#09H
		BNE	BSQ010	; Mode 7 ?
;------------------------------------------------------------------------
;-		モード７設定						-
;------------------------------------------------------------------------
		JSL	>BOSSQ_MD7_SET
BSQ010		EQU	$
;------------------------------------------------------------------------
;-		ＯＡＭセット						-
;------------------------------------------------------------------------
		LDA	ENCHPT,X
		BEQ	BSQ020
;
		LDA	ENMOD2,X
		AND	#0000011111111111B
		ORA	#0010000000000000B
		STA	ENMOD2,X
;
		JSL	>TROBJ_OAM_4x4	;ＯＡＭセット
		BRA	BSQ030
;
BSQ020		EQU	$
;		 LDA	 ENMOD2,X
;		 AND	 #0000011111111111B
;		 ORA	 #1000000000000000B
;		 STA	 ENMOD2,X
;
		JSL	>TROBJ_OAM_8x8	;ＯＡＭセット
;
BSQ030		EQU	$
;;		JSL	>ENMDCK
;
;------------------------------------------------------------------------
;-		回転キャラクター作成					-
;------------------------------------------------------------------------
		LDA	ENCHPT,X
		BNE	BQCHTR2
;
		LDA	BSANGL2
		LDY	ENMUKI,X
		BEQ	BOSSQMV_0010
		EOR	#00FFH
		INC	A
BOSSQMV_0010	EQU	$
		AND	#00FFH
		STA	R5		;(R5) <-- 回転角度
;
		LDA	BSXSIZ
		AND	#0FFH
		INC	A
		STA	R6		;(R6)  <-- Ｘ倍率
		LDA	BSYSIZ
		AND	#0FFH
		INC	A
		STA	R11		;(R11) <-- Ｙ倍率
;
		LDY	#000H
		LDA	!BOSSQ_CHR_ADR,Y
		STA	R12		;(R12) <-- キャラクターアドレス（Ｌ，Ｈ）
		LDA	#BANK CIPCHD3
		STA	R13		;(R13) <--	   ”		(Ｂ）
		LDY	ENTROB,X
		TYX
		LDA	>TROBJ_PLOT_X,X
		STA	R3		;(R3)  <-- ビットマップ座標＿Ｘ
		LDA	>TROBJ_PLOT_Y,X
		STA	R2		;(R2)  <--	  ”	   ＿Ｘ
		M_CHIP	C_64_RTZ_64_XY
;
		INC	OBM7WF		;mode 7 OBJ chara DMA "ON"
;
		LDX	<ENINDX
		BRA	BQCTR090
;

BQCHTR2		EQU	$
		JSR	BQCHTR2S
BQCTR090	EQU	$
		JSL	>ENMDCK
;------------------------------------------------------------------------
;    MOVE !!
;-									-
;------------------------------------------------------------------------
		LDA	DSPMOD
		CMP	#09H
		BNE	BQMOVE2	  ; Mode 7 ?
;				  ; yes !
		JSR	YENMOVE
		RTL
;-------------------------------------------------
BQMOVE2		EQU	$
		JSR	BQ2SUB
		RTL
;-------------------------------------------------
BQ2CHAD		EQU	$
		WORD	CIPCHD3+4080H ;4
		WORD	CIPCHD3+40A0H ;
;---------------------------
BQCHTR2S	EQU	$
		LDA	BSANGL2
		AND	#0FFH
		STA	R5
;
		LDA	#0100H
		STA	R6		;(R6)  <-- Ｘ倍率
		LDA	#000H
		STA	R8		;(R8)  <-- 中心＿Ｘ
		STA	R9		;(R9)  <-- 中心＿Ｙ
;;		  LDA	  #CIPCHD3+00E0H
		LDA	BSWRK2	;FRCNT
		LSR	A
		LSR	A
		AND	#02H
		TAY
		LDA	BQ2CHAD,Y
		STA	R12		;(R12) <-- キャラクターアドレス（Ｌ，Ｈ）
		LDA	#BANK CIPCHD3
		STA	R13		;(R13) <-- キャラクターアドレス(Ｂ）
		LDY	ENTROB,X
		TYX
		LDA	>TROBJ_PLOT_Y,X
		STA	R2		;(R2)  <-- ビットマップ座標＿Ｙ
		LDA	>TROBJ_PLOT_X,X
		STA	R3		;(R3)  <-- ビットマップ座標＿Ｘ
		M_CHIP	C_32_ROTZOM
;
		INC	OBM7WF		;mode 7 OBJ chara DMA "ON"
;
		LDX	<ENINDX
		RTS
;-------------------------------------------------------
BQ2SUB		EQU	$
		LDA	BOSS_START
		BMI	BQM2002		; Demo end ?
;;		CMP	#01H
;;		BEQ	BQM2010
		BNE	BQM2010
;
BQM2002		EQU	$
;					; yes !
		LDA	<ENWRK0,X
		ASL	A
		TXY
		TAX
		JMP	(BQ2ADRS,X)
BQM2010		EQU	$
		LDA	#040H
		STA	ENTIM0,X
;
		LDA	BSWRK4
		BNE	BQ2W023
;
		LDY	#(ENNO-1)*4
BQ2W022		EQU	$
		LDA	ENMYNO,Y
		CMP	#KAMC2
		BNE	BQ2W028	 ; Kamec ?
;
		LDA	ENMODE,Y
		BEQ	BQ2W028
;
		LDA	ENTIM1,Y
		CMP	#030H
		BCC	BQ2W023
;
		LDA	#02H
		STA	ENTIM1,Y   ; Kamec start timer clear !
		STA	BSWRK4
BQ2W023		EQU	$
		RTS
BQ2W028		EQU	$
		DEY
		DEY
		DEY
		DEY
		BPL	BQ2W022
		RTS
;-------------------------------------------------------
BQ2ADRS		EQU	$
		WORD	BQ2DOWN
		WORD	BQ2SPIN
		WORD	BQ2LEFT
		WORD	BQ2WAIT
		WORD	BQ2SET
		WORD	BQ2SET2
		WORD	BQ2BIG
		WORD	BQ2DROP
		WORD	BQ2ATK
		WORD	BQ2ATK2
;-------------------------------------------------------
BQ2DOWN		EQU	$
		TYX
;
		INC	BSWRK2
		INC	BSWRK2
;
		LDA	ENTIM0,X
		BNE	BQ2D010
;
		LDA	#0200H
		STA	ENYSPD,X
;
		LDA	ENYPSL,X
		CMP	#048EH
		BCC	BQ2D010
;
;;		  AND	  #0FFF0H
;;		  STA	  ENYPSL,X
;
		INC	<ENWRK0,X
;
		STZ	ENYSPD,X
BQ2D010		EQU	$
		RTS
;-------------------------------------------------------
BQ2SPIN		EQU	$
		TYX
;
		M8
;
		INC	BSWRK2
		INC	BSWRK2
;
		LDA	BSANGL2
		SEC
		SBC	#08H
		STA	BSANGL2
		BNE	BQ2SP010
;
		INC	<ENWRK0,X
BQ2SP010	EQU	$
		M16
		RTS
;-------------------------------------------------------
BQ2LEFT		EQU	$
		TYX
;
		INC	BSWRK2
		INC	BSWRK2
;
		LDA	#0FE00H
		STA	ENXSPD,X
;
		LDA	ENXPSL,X
		AND	#0FFH
		CMP	#0A0H
		BCS	BQ2L010
;
		LDA	#0FFH
		STA	BSWRK2
;
		INC	<ENWRK0,X
;
		STZ	ENXSPD,X
;
;;		  LDA	  #01H
;;		  STA	  BOSS_START
;
;;		LDA	#0FFH
		LDA	#040H
		STA	ENTIM0,X
BQ2L010		EQU	$
		RTS
;-------------------------------------------------------
BQ2WAIT		EQU	$
		TYX
;
		LDA	ENTIM0,X
		BNE	BQ2W010
;
		INC	<ENWRK0,X
;
		LDA	#01H
		STA	BOSS_START
		RTS
BQ2W010		EQU	$
		M8
;
;		CMP	#002H
;		BEQ	BQ2W018
;		CMP	#032H
;		BNE	BQ2W020
;;
;BQ2W018		EQU	$
;		LDA	ENMUKI,X
;		EOR	#02H
;		STA	ENMUKI,X
;BQ2W020		EQU	$
;		M16
;		LDA	ENTIM0,X
;		CMP	#01AH
;		BNE	BQ2W030
;;
;		LDA	#0FB00H
;		STA	ENYSPD,X
;;
;		LDA	#0100H
;		STA	ENGPOW,X
;		RTS
;;
;BQ2W030		EQU	$
		M16
;
		LDA	ENYPSL,X
		CMP	#048EH
		BCC	BQ2W040
;
		LDA	#048EH
		STA	ENYPSL,X
;
		STZ	ENYSPD,X
		STZ	ENGPOW,X
BQ2W040		EQU	$
		RTS
;-------------------------------------------------------
BQ2SET		EQU	$
		TYX
;
;
		LDA	ENTIM0,X
		BNE	BQ2S010
;
		M8
;
		INC	<ENWRK0,X
;
		LDA	ENYPSL,X
		CLC
		ADC	#010H
		STA	ENYPSL,X
;
		LDA	#40H
		STA	ENTIM0,X
;
		STZ	ENCHPT,X
;
		M16
;
		LDA	ENMOD2,X
		AND	#0000011111111111B
		ORA	#1000000000000000B
		STA	ENMOD2,X
;
		JSL	>TROBJ_OAM_8x8	;ＯＡＭセット
;
;
		STZ	BOSS_START
;
;		 M16
;		 STZ	 TROBJ_ARIA
;		 JSL	 >TROBJ_SR_8x8	 ;転送エリア確保（８×８）
;;
;		 M8
BQ2S010		EQU	$
		RTS
;-------------------------------------------------------
BQ2SET2		EQU	$
		TYX
;
		M8
;
		LDA	ENTIM0,X
		BNE	BQ2S0102
;
		LDA	#013H
		JSL	>SOUND_3_ON	;(S)
;
		INC	<ENWRK0,X
;
		LDA	#0C0H
		STA	ENYSPD,X
		LDA	#0FCH
		STA	ENYSPD+1,X
;
		LDA	#018H
		STA	ENGPOW,X
BQ2S0102	EQU	$
		AND	#03H
		BNE	BQ2S020
;
		LDA	BSXSIZ
		EOR	#08H
		STA	BSXSIZ
		STA	BSYSIZ
BQ2S020		EQU	$
		M16
		RTS
;-------------------------------------------------------
BQ2BDTX		EQU	$
		HEX	80,84,88,8C,90,94,98,9C
		HEX	A0,98,94,90,8C,88,84,84
BQ2BDTY		EQU	$
		HEX	A0,98,94,90,8C,88,84,84
		HEX	80,84,88,8C,90,94,98,9C
;
BQ2BIG		EQU	$
		TYX
;
		M8
;
		LDA	BSANGL2
		CLC
		ADC	#008H
		STA	BSANGL2
;
		LDA	<ENWRK6,X
		CMP	#080H
		BEQ	BQ2B010
		CLC
		ADC	#04H
		STA	<ENWRK6,X
;
		LDA	FRCNT
		HEX	EA,EA,EA,EA
		AND	#0FH
		TAY
		LDA	BQ2BDTX,Y
		CLC
		ADC	<ENWRK6,X
		BCC	BQ2B008
		LDA	#0FFH
BQ2B008		EQU	$
		STA	BSXSIZ
;
		LDA	BQ2BDTY,Y
		CLC
		ADC	<ENWRK6,X
		BCC	BQ2B00C
		LDA	#0FFH
BQ2B00C		EQU	$
		STA	BSYSIZ
;
		M16
		RTS
BQ2B010		EQU	$
		mem8
;
		LDA	#0FFH
		STA	BSXSIZ
		STA	BSYSIZ
;
		STZ	BSANGL2
;
		M16
;
		STZ	ENGPOW,X
		STZ	ENYSPD,X
;
		INC	<ENWRK0,X
;
		LDA	#020H
		STA	ENTIM0,X
		RTS
;
;		 JSL	 >GO_NEXTGOTO
;		 RTS
;-------------------------------------------------------
BQ2DROP		EQU	$
		TYX
;
		LDA	ENTIM0,X
		BNE	BQ2DP010
;
;		LDA	#0100H
;		STA	ENGPOW,X
;
		LDA	#0800H
		STA	ENYSPD,X
;
		LDA	ENYPSL,X
		CMP	#0493H
		BCC	BQ2DP010
;
		LDA	#0493H
		STA	ENYPSL,X
;
		STZ	ENYSPD,X
		STZ	ENGPOW,X
;
		INC	<ENWRK0,X
;
		LDA	#020H
		STA	ENTIM0,X
;
		LDA	#47H
		JSL	>SOUND_3_ON    ;(S)
;
		LDA	#018H
		STA	TILTCT
;
BQ2DP010	EQU	$
		RTS
;-------------------------------------------------------
BQ2ATK		EQU	$
		TYX
;
		M8
;
		LDA	FRCNT
		HEX	EA,EA,EA
		AND	#07H
		TAY
		LDA	YTWZOOMX,Y
		STA	BSXSIZ
		LDA	YTWZOOMY,Y
		STA	BSYSIZ
;
		M16
;
		LDY	ENTIM0,X
		BNE	BQ2DP010  ;BQ2A020
;
		LDA	FRCNT
		AND	#001H
		BNE	BQ2A010
;
		LDA	#DSMK0
		JSL	>EXINSR
;
		LDA	ENXPSL,X
		CLC
		ADC	#0010H
		STA	EXXPSL,Y
;
		LDA	ENYPSL,X
		CLC
		ADC	#0012H
		STA	EXYPSL,Y
;
		LDA	#05H
		STA	EXWRK0,Y	;初期カウンターセット
;;;;		    LDA	    #05H
		STA	EXCHPT,Y	;初期パターンＮｏ．セット
		LDA	#04H
		STA	EXTIM0,Y	;初期タイマーセット
		LDA	#00H
		STA	EXYUSN,Y	;優先順位セット
BQ2A010		EQU	$
		LDA	#0FB80H
		STA	ENXSPD,X
;
		LDY	ECRSFG,X
		BPL	BQ2A020
;
		STZ	ENXSPD,X
;;		  JSL	  >GO_NEXTGOTO
		LDA	#PBSQ
		STA	PLMODE
		JSL	>EGGKILL_ALL
;
		LDA	#0FC00H
		STA	PLXSPD
		LDA	#0FE00H
		STA	PLYSPD
;
		INC	<ENWRK0,X
;
		LDA	#13H
		JSL	>SOUND_3_ON ;(S)
;
		LDA	#FSMK0
		JSL	>EXINSR
;
		LDA	PLXPSL
		CLC
		ADC	#0008H
		STA	EXXPSL,Y
		LDA	PLYPSL
		CLC
		ADC	#0008H
		STA	EXYPSL,Y

		LDA	#0004H
		STA	EXTIM0,Y

		LDA	#0007H
		STA	EXCHPT,Y
		STA	EXWRK0,Y
BQ2A020		EQU	$
		RTS
;-------------------------------------------------------
BQ2ATK2		EQU	$
		TYX
		RTS
;- - - - - - - - - - - - - - - - -
;=====================================================================
BSHANKD		EQU	042H	; Base loop hankei
;
YENINIT		EQU	$
		M16
		JSL	>TROBJ_SR_8x8	;転送エリア確保（８×８）
;
		M8
;
		LDA	DSPMOD
		CMP	#09H
		BEQ	BQI010
;
		LDA	#40H
		STA	BSANGL2
;
		LDA	#7FH
		STA	BSXSIZ
		STA	BSYSIZ
;
		STZ	<ENWRK6,X
;
		STZ	BSWRK4
		STZ	BSWRK4+1
;
		LDA	#04H
		STA	ENCHPT,X
;
		LDA	#040H
		STA	ENTIM0,X
;
		M16
;
		STZ	PLCMKI
;
		LDA	ENYPSL,X
		SEC
		SBC	#008H
		STA	ENYPSL,X
;
		STZ	ENGPOW,X
		STZ	ENYSPD,X
;
		JSR	BQCHTR2S	; TENSOU
		RTS
;-------------------------------------------------
BQI010		EQU	$
		M8
;
;;		  LDA	  #00101100B
;;		  STA	  ENCLOR,X
;
		LDA	#080H
		STA	BSANGL1	      ; POS ANGLE
		STA	BSANGL2	      ; CHR ANGLE
;
		LDA	#007H
		STA	ENWRKA,X ;BSSPED
;
		LDA	#060H
		STA	BSHANK
;
		LDA	#50H
		STA	BSXSIZ
		STA	BSYSIZ
;
		LDA	#00H
		STA	<ENWRK9,X	 ; Chr angle add !
;
		DEC	A   ; FF
		STA	<ENWRK2,X	 ; Color %
		STZ	<ENWRK2+1,X	   ; Color %
;
		LDA	#80H
		STA	BQSCCV3
;
		M16
;
		LDA	#140H
		STA	ENXPSL,X
;
		LDA	ENMOD0,X
		AND	#1100011111111111B
		STA	ENMOD0,X
;
;
		JSL	>DOROBOUCANCEL
		RTS
;
		MEM8
YTITSB		EQU	$
		LDA	#BSHANKD
		STA	BSHANK	      ; Hankei
;
		LDA	#0FFH
		STA	BSXSIZ
		STA	BSYSIZ
		RTS
;=====================================================================
YENMOVE		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	BQSCCV3
;;		AND	#0FEH
		CMP	#80H
		BEQ	YEM0F0
;
		BCS	YEM0E0
		INC	BQSCCV3
		INC	BQSCCV3
YEM0E0		EQU	$
		DEC	BQSCCV3
YEM0F0		EQU	$
		LDA	ESCCV3
;;		AND	#0FEH
		CMP	BQSCCV3
		BEQ	YEM0FA
;;		LDA	ESCCV3
		BCS	YEM0F5
		INC	A
		INC	A
YEM0F5		EQU	$
		DEC	A
YEM0F8		EQU	$
		STA	ESCCV3
YEM0FA		EQU	$
		LDA	<ENWRK6,X
		BEQ	YEM0FC
		DEC	<ENWRK6,X
YEM0FC		EQU	$
		AND	#02H
		CLC
		ADC	ESCCV3
		STA	ESCCV3
;
		LDA	BSMUKI
		STA	ENMUKI,X
;
		LDA	BSTIM0
		BEQ	YEM0000
;
		DEC	BSTIM0
YEM0000		EQU	$
		LDA	BSTIM1
		BEQ	YEM0001
;
		DEC	BSTIM1
YEM0001		EQU	$
		JSR	YTORIMV
;
		LDA	BSHANK
		CLC
		ADC	BSWRK8
		STA	<EWORKE	 ; Hankei
;
		STZ	BSWRK8
;
		JSR	YTCSET
;
		JSR	TTEST
;
		JSR	BQCGST
;
		REP	#00100000B
		RTS
;
;
;-----------------------------------------------
BQCGCK		EQU	$
		LDA	<ENWRK2,X
		CMP	#0FFH
		BEQ	BQCC010
;
		TYA
		CLC
		ADC	<ENWRK2,X
		STA	<ENWRK2,X
		BCS	BQCC010
		RTS
BQCC010		EQU	$
		LDA	#0FFH
		STA	<ENWRK2,X
;
		LDA	<ENCONT,X
		ASL	A
		TAY
		LDA	BQCGAD,Y
		STA	<EWORK0
		LDA	BQCGAD+1,Y
		STA	<EWORK0+1
		LDA	#BANK COL_ADDRESS+TORI_COL_0
		STA	<EWORK0+2
;
		PHX
;
		LDX	#00H
		TXY
BQCC020		EQU	$
		LDA	[<EWORK0],Y
		STA	>MOTOCOL+1C0H+2,X
		INY
		INX
		CPX	#1EH
		BNE	BQCC020
;
		PLX
		RTS
;
;-----------------------------------------------
BQCGST		EQU	$
;
;-------------- カラーフェード ----------------------------------
;
		M16
;
		LDA	<ENCONT,X
		ASL	A
		TAY
		LDA	BQCGAD,Y
		STA	R14		;(R14) <-- 先カラーデータアドレス（Ｌ，Ｈ）
		LDA	#BANK COL_ADDRESS+TORI_COL_0
		STA	R0		;(R0) <-- 先カラーデータアドレス（Ｂ）
;
		LDA	<ENWRK2,X ; %	#0100H
		AND	#00FFH
		INC	A
		STA	R6
;
		LDA	#080H+61H
		STA	R8		;(R8) <-- カラーポインター（０〜ＦＦ）
		LDA	#15
		STA	R12		;(R12) <-- カラー数
;
		M_CHIP	COL_MORF_B
;
		MEM8
		IDX8
		SEP	#00110000B
		LDX	<ENINDX
		RTS
;-----------------------------------------------
BQCGAD		EQU	$
		WORD	COL_ADDRESS+TORI_COL_0
		WORD	COL_ADDRESS+TORI_COL_1
		WORD	COL_ADDRESS+TORI_COL_2
		WORD	COL_ADDRESS+TORI_COL_3
		WORD	COL_ADDRESS+TORI_COL_4
		WORD	COL_ADDRESS+TORI_COL_5
		WORD	COL_ADDRESS+TORI_COL_6
		WORD	COL_ADDRESS+TORI_COL_7
		WORD	COL_ADDRESS+TORI_COL_8
		WORD	COL_ADDRESS+TORI_COL_9
;-----------------------------------------------
;
TTEST		EQU	$
;
		LDA	KEYA1L
		AND	#010H
		BRA	TDT010
;;		BEQ	TDT010
;
		LDA	#00H
		STA	<ENCONT,X
;
		JSR	YENINIT
		SEP	#00100000B
;
		STZ	BSSTAT
TDT010		EQU	$
		RTS
;-----------------------------------------------
EPCRCKS		EQU	$
		M16
;
		LDY	ECRSFG,X
		BPL	EPS010
;
		JSL	>PLFLST
;
EPS010		EQU	$
		M8
		RTS
;-----------------------------------------------
EPCRCKQ		EQU	$
		M16
;
		JSL	>EPCRCK2
;
		M8
;
		LDA	ENMODE,X
		CMP	#EFAIL
		BNE	YFCK010
;
		LDA	#EMOVE
		STA	ENMODE,X
;
		LDA	#YBYON
		STA	BSSTAT
;
		LDA	#034H
		JSL	>SOUND_3_ON	;(S)
;
		LDA	#020H
		STA	ENTIM0,X
;
		LDA	#000H
		STA	PLYSPD
		LDA	#0FCH
		STA	PLYSPD+1
		PLA
		PLA
YFCK010		EQU	$
;
		RTS
;-----------------------------------------------
YTADRS		EQU	$
YT0
		WORD	YTDEMO0
		WORD	YTDEMO1
		WORD	YTDEMO2
		WORD	YTDEMO3
		WORD	YTDEMO4
YTW		WORD	YTWALK
YTS		WORD	YTSTOP
		WORD	YTKYOR
		WORD	YTSTOP2
YTP		WORD	YTSPARK
		WORD	YTSPARK2
YTJ		WORD	YTJUMP
YTBY		WORD	YTBYON
YTE0		WORD	YTEND0
		WORD	YTEND05
		WORD	YTEND1
		WORD	YTEND2
		WORD	YTEND3
		WORD	YTEND4
		WORD	YTEND45
		WORD	YTEND5
;
YTWK		EQU	(YTW-YT0)/2
YTJP		EQU	(YTJ-YT0)/2
YTST		EQU	(YTS-YT0)/2
YBYON		EQU	(YTBY-YT0)/2
YTSP		EQU	(YTP-YT0)/2
YTED0		EQU	(YTE0-YT0)/2
;- - - - - - - - - - - - - - - - - - -
YTORIMV		EQU	$
		LDA	BOSSQ_KUI_ON
		BEQ	BQ0010
;
		STZ	BOSSQ_KUI_ON
;
		LDA	BSANGL1
		CLC
		ADC	MD7_ANGL
		CLC
		ADC	#080H
		CLC
		ADC	#0EH
		CMP	#0EH+0EH   ; F2->0E
		BCS	BQ0010
;
		LDA	BSHANK
		CMP	#BSHANKD+2
		BCS	BQ0010
;
;		 LDA	 #020H
;		 STA	 SOUND0	 :[♪]
		LDA	#078H
		JSL	>SOUND_3_ON    ;(S)
;
		LDA	ENWRKA,X
		CMP	#01H
		BNE	BQ0002
;
		LDA	#YTED0
		STA	BSSTAT
;
		LDA	#0A0H
		STA	BSTIM0
		LDA	#0A0H  ;20
		STA	BSTIM1
;
		M16
		LDA	#PDEM
		STA	PLMODE		; PLAYER STOP
		STZ	P_KEYC1L
		STZ	P_KEYC2L
		M8
;
		BRA	BQ0010
;
BQ0002		EQU	$
		LDA	#YTJP
		STA	BSSTAT
;
		LDA	#08H
		STA	BSWRK0
;
		LDA	#0A0H
		STA	BSYSIZ
;
		STZ	BSTIM0
;
		LDA	#18H
		STA	BSTIM1
BQ0010		EQU	$
		TXY
		LDA	BSSTAT
		ASL	A
		TAX
		JMP	(YTADRS,X)
;-----------------------------------------------
YTDEMO0		EQU	$
		TYX
;
		LDA	FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	BSCHPT
;
		LDA	PLMODE
		CMP	#PBQ7
		BEQ	YTD0010	  ;Player demo end ?
;					; yes !
		INC	BSSTAT
;
		LDA	#050H
		STA	BSTIM0
YTD0010		EQU	$
		RTS
;-----------------------------------------------
YTDEMO1		EQU	$
		TYX
;
		LDA	FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	BSCHPT
;
;		LDA	MD7_ANGL
;		AND	#0F8H
;		CMP	#38H
;		BNE	YTD1010
;;
		LDA	BSTIM0
		BNE	YTD1010
;
		LDA	#01H
		STA	PLSTFG
;
		STZ	PLXSPD
		STZ	PLXSPD+1
		STZ	PLMVSP
		STZ	PLMVSP+1
;
		INC	BSSTAT
;
		LDA	#0A0H
		STA	BSTIM0
YTD1010		EQU	$
		RTS
;-----------------------------------------------
YTDEMO2		EQU	$
		TYX
;
		JSR	BQSCRL
;
		LDA	BSTIM0
		BEQ	YTD2020
;
		CMP	#30H
		BCC	YTD2010
		AND	#0FH
		BNE	YTD2010
;
		LDA	BSMUKI
		EOR	#02H
		STA	BSMUKI
YTD2010		EQU	$
		RTS
YTD2020		EQU	$
		INC	BSSTAT
;
;		 LDA	 #30H
;		 STA	 <ENWRK1,X
		LDA	#00H
		STA	BSASPD
;
		LDA	#50H
		STA	BSTIM0
;
		LDA	#089H
		JSL	>SOUND_3_ON    ;(S)
		RTS
;----------------------------------------
YTDEMO3		EQU	$
		TYX
;
		JSR	BQSCRL
;
		LDA	FRCNT
		AND	#03H
		BEQ	YTD3002
;
		LDA	<ENWRK2,X
		BEQ	YTD3002
		SEC
		SBC	#01H
		STA	<ENWRK2,X
YTD3002		EQU	$
		LDA	FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	BSCHPT
;
;		 LDA	 <ENWRK0,X
;		 CLC
;		 ADC	 <ENWRK1,X
;		 STA	 <ENWRK0,X
;		 BCC	 YTD3008
;;
;		 LDA	 BSANGL1
;		 CLC
;		 ADC	 #001H
;		 STA	 BSANGL1
;
		LDA	FRCNT
		AND	#07H
		BNE	YTD3003
;
		INC	BSASPD
YTD3003		EQU	$
		JSR	BSACLC
;
;		 LDA	 <ENWRK9,X
;		 CLC
;		 ADC	 #0FFH
;		 STA	 <ENWRK9,X
;
YTD3008		EQU	$
;		 LDA	 FRCNT
;		 AND	 #00H
;		 BNE	 YTD300C
;;
;		 LDA	 <ENWRK1,X
;		 CMP	 #0FFH
;		 BEQ	 YTD300C
;;
;		 INC	 <ENWRK1,X
;;
;YTD300C	 EQU	 $
		LDA	BSTIM0
		AND	#01H
		BNE	YTD3010
;
		LDA	BSXSIZ
		CMP	#0F8H
		BEQ	YTD3010
		INC	A
		STA	BSXSIZ
		STA	BSYSIZ
YTD3010		EQU	$
		LDA	BSANGL1
		AND	#0FEH
		CMP	#7EH
		BNE	YTD3030
;
		LDA	#80H
		STA	BSANGL1

		INC	BSSTAT
;
;		 LDA	 #80H
;		 STA	 <ENWRK9,X
;
		LDA	#030H
		STA	BSTIM0
;
		STZ	BSWRK0
YTD3030		EQU	$
		RTS
;----------------------------------------
;----------------------------------------
BSACLC		EQU	$
		LDA	BSASPD
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	BSASDR
		STA	BSASDR
;
		LDA	BSASPD
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		PLP
		BPL	BSAC010
		ORA	#11110000B
BSAC010		EQU	$
		ADC	BSANGL1
		STA	BSANGL1
		RTS
;----------------------------------------
BQSCRL		EQU	$
		M16
;
		LDA	ENYPSL,X
		SEC
		SBC	#0B8H
		LSR	A
		LSR	A
;		 LSR	 A
;		 LSR	 A
		NOP
		NOP
		CLC
		ADC	#076H
		STA	BQSCCV3
		M8
;;
;		 CMP	 BQSCCV3
;		 BCS	 BQSC010
;;
;		 DEC	 BQSCCV3
;		 DEC	 BQSCCV3
;;
;		 RTS
;BQSC010	 EQU	 $
;		 INC	 BQSCCV3
;		 INC	 BQSCCV3
;
		RTS
;---------------------------------------
YTDEMO4		EQU	$
		TYX
;
		JSR	BQSCRL
;
		LDA	<ENWRK9,X
		AND	#0FEH
		CMP	#80H
		BEQ	YTD4010
;
		CLC
		ADC	#08H
		STA	<ENWRK9,X
		RTS
YTD4010		EQU	$
		STA	<ENWRK9,X
;
		LDA	BSTIM0
		BNE	YTD4020
;
		LDA	BSHANK
		CLC
		ADC	BSWRK0
		STA	BSHANK
;
		DEC	BSWRK0
		DEC	BSWRK0
;
		LDA	BSHANK
		CMP	#BSHANKD
		BCC	YTDEND
;
YTD4020		EQU	$
		RTS
;
;
;----------------------------------------
YTDEND		EQU	$
		JSR	YTSSET
;
		LDA	#80H
		STA	BSTIM0
;
		LDA	#80H
		STA	<ENWRK9,X
;
		LDA	#20H
		STA	<ENWRK6,X
;;		  STA	  TILTCT
;
;		 LDA	 #16H
;		 STA	 SOUND3	 ;(S)
		LDA	#47H
		JSL	>SOUND_3_ON ;(S)
;
		PHX
;
		LDX	#00H
YTE010		EQU	$
		LDA	>COL_ADDRESS+TORI_COL_6,X
		STA	>MOTOCOL+1C0H+2,X
		INX
		CPX	#1EH
		BNE	YTE010
;
		PLX
;
		LDA	#0FFH
		STA	<ENWRK2,X	; Color %
;
		LDA	#06H
		STA	<ENCONT,X	; Color No.
;
		JSR	YTITSB
		RTS
;
;-----------------------------------------------
ANGADD		EQU	$
		WORD	0001H,00FFH
YTWZOOMX	EQU	$
		HEX	FF,F0,E0,D0,D0,E0,F0,FF
YTWZOOMY	EQU	$
		HEX	E8,F0,F8,FF,FF,F8,F0,E8
YTWHANK		EQU	$
		HEX	FD,FE,FF,00,00,FF,FE,FD
;
YTWALK		EQU	$
		TYX
;
;
		JSR	EPCRCKQ
;
;;		JSR	BQASEST ; Ase set ''''
;
		LDY	#08H
		JSR	BQCGCK
;
		LDA	BSWRK0
		BPL	YTW0E0
;
		LDA	BSHANK
		CMP	#BSHANKD+1
		BCC	YTW000
;
YTW0E0		EQU	$
		LDA	BSHANK
		CLC
		ADC	BSWRK0
		STA	BSHANK
		CMP	#BSHANKD+1
		BCC	YTW000
;
		DEC	BSWRK0
;
		RTS
YTW000		EQU	$
		LDA	#BSHANKD
		STA	BSHANK
;
		LDA	BSTIM0
		BNE	YTW010
;
		LDA	BSANGL1
		CLC
		ADC	#000H
		AND	#01FH
		BNE	YTW010
;
YTSSET		EQU	$
		LDA	#14H
		STA	BSTIM0
;
		LDA	#YTST
		STA	BSSTAT
		RTS
YTW010		EQU	$
		LDA	BSANGL1
;;		  LSR	  A
		NOP
		NOP
		NOP
;		 LSR	 A
;		 LSR	 A
;		 AND	 #01H
;		 STA	 BSCHPT
		AND	#07H
		TAY
		LDA	YTWZOOMX,Y
		STA	BSXSIZ
		LDA	YTWZOOMY,Y
		STA	BSYSIZ
		LDA	YTWHANK,Y
		STA	BSWRK8
;
;		LDA	FRCNT
;		AND	#03H
;		BNE	YEM010
YEM000		EQU	$
		LDY	BSMUKI
;
		LDA	ENWRKA,X ;BSSPED
		CMP	#07H
		BEQ	YTACLC
;
		AND	FRCNT
		BNE	YTACLC
;
		JSR	YTACLC
;
YTACLC		EQU	$
		LDA	BSANGL1
		CLC
		ADC	ANGADD,Y
		STA	BSANGL1
;
YEM010		EQU	$
		RTS
;-----------------------------------------------
YTSTOP		EQU	$
		TYX
;
		JSR	EPCRCKQ
;
		JSR	YTGCLC
;
;
		LDA	BSTIM0
		BNE	YTS010
;
		INC	BSSTAT
;
		LDA	<RANDM0
		AND	#30H
		ADC	#40H
		STA	BSTIM0
YTS010		EQU	$
		RTS
;-----------------------------------------------
YTKYOR		EQU	$
		TYX
;
		JSR	EPCRCKQ
;
		JSR	YTGCLC
;
;
		LDA	BSTIM0
		BEQ	YTK010
;
		CMP	#28H
		BNE	YTK003
;
		LDA	BSANGL2
		CLC
		ADC	#040H
		BMI	YTK003
;
		LDA	BSANGL2
		ASL	A
		ROL	A
		ROL	A
		AND	#02H
		EOR	#02H
		STA	BSMUKI
;
		LDA	#08H
		STA	BSWRK0
;
		BRA	YTK010
;
YTK003		EQU	$
		LDA	BSTIM0
		AND	#0FH
		BNE	YTK008
;
		LDA	BSMUKI
		EOR	#02H
		STA	BSMUKI
YTK008		EQU	$
		RTS
YTK010		EQU	$
		INC	BSSTAT
;
		LDA	#14H
		STA	BSTIM0
;
		RTS
;-----------------------------------------------
YTSTOP2		EQU	$
		TYX
;
		JSR	EPCRCKQ
;
		JSR	YTGCLC
;
;
		LDY	#10H
		JSR	BQCGCK
;
		LDA	BSTIM0
		BNE	YTS210
;
		LDA	PLSTFG
		BNE	YTS202
;
		LDA	ENWRKA,X
		NOP
		NOP
		STA	<EWORK0
;
		LDA	<RANDM0
		AND	<EWORK0	 ; 7,3,1  #03H
		BNE	YTS202
;
		LDA	#YTSP
		STA	BSSTAT
;
		LDA	#08H
		STA	BSWRK0
;
		RTS
;
YTS202		EQU	$
		STZ	PLSTFG
		STZ	PLMODE
;
YTWSET		EQU	$
		LDA	#YTWK
		STA	BSSTAT
;
		LDA	<RANDM0
		AND	#7FH
		ADC	#080H
		STA	BSTIM0
YTS210		EQU	$
		RTS
;-----------------------------------------------
YTJXSZ		EQU	$
		HEX	D0,D6,DC,E2,E8,EE,F4,FF
YTJYSZ		EQU	$
		HEX	FF,F4,EE,E8,E2,DC,D6,D0
;
;;		  HEX	  FF,F8,F4,F0,EC,E8,E4,E0
YTJUMP		EQU	$
		TYX
;
		LDA	BSTIM1
		LSR	A
		AND	#02H
		ORA	#2CH
		STA	ENCLOR,X
;
		LDA	BSTIM0
		BEQ	YTJ008
;
		CMP	#01H
		BEQ	YTJEND
;		 LSR	 A
;		 LSR	 A
		NOP
		NOP
		AND	#07H
		TAY
		LDA	YTJXSZ,Y
		STA	BSXSIZ
		LDA	YTJYSZ,Y
		STA	BSYSIZ
		RTS
;
YTJ008		EQU	$
		JSR	YTGCLC
;
;		 LDA	 BSHANK
;		 CLC
;		 ADC	 BSWRK0
;		 STA	 BSHANK
;;
;		 DEC	 BSWRK0
;		 DEC	 BSWRK0
;;
;		 LDA	 BSHANK
;		 CMP	 #BSHANKD
;		 BCS	 YTJ010
;
		LDA	BSHANK
		CMP	#BSHANKD
		BNE	YTJ010
;
		LDA	#30H
		STA	BSTIM0
;
		JSR	YTITSB
;
		RTS
YTJ010		EQU	$
		RTS
;
YTJEND		EQU	$
		LSR	ENWRKA,X ;BSSPED
;
		INC	<ENWRK3,X
		LDY	<ENWRK3,X
		LDA	YTCGNOD,Y
		STA	<ENCONT,X
;
		STZ	<ENWRK2,X  ; CG %
;
		JSR	YTITSB
		JMP	YTSSET
;-----------------------------------------------
YTBXSZ		EQU	$
		HEX	E4,E8,EC,F0,F4,F8,FC,FF
YTBYSZ		EQU	$
		HEX	FF,FC,F8,F4,F0,EC,E8,E4
YTBYON		EQU	$
		TYX
;
		JSR	EPCRCKQ
;
		JSR	YTGCLC
;
		LDA	ENTIM0,X
		BNE	YTBY010
;
		LDA	#0FFH
		STA	BSXSIZ
		STA	BSYSIZ
;
		JMP	YTSSET
YTBY010		EQU	$
		AND	#07H
		TAY
		LDA	YTBXSZ,Y
		STA	BSXSIZ
		LDA	YTBYSZ,Y
		STA	BSYSIZ
		RTS
;-----------------------------------------------
YTGCLC		EQU	$
		LDA	BSHANK
		CLC
		ADC	BSWRK0
		STA	BSHANK
;
		DEC	BSWRK0
		DEC	BSWRK0
;
		LDA	BSHANK
		CMP	#BSHANKD
		BCS	YTG010
;
		LDA	#BSHANKD
		STA	BSHANK
;
		STZ	BSWRK0
YTG010		EQU	$
		RTS
;----------------------------------------------------
YTSPARK		EQU	$
		TYX
;
		JSR	EPCRCKQ
;
		JSR	YTGCLC
;
		LDA	BSHANK
		CMP	#BSHANKD
		BNE	YTSP010
;
		JSR	QSPAKSET
;
		INC	BSSTAT
;
		LDA	#40H
		STA	BSTIM0
YTSP010		EQU	$
		RTS
;----------------------------------------------------
YTSPARK2	EQU	$
		TYX
;
		JSR	EPCRCKQ
;
		LDA	BSTIM0
		BNE	YTSP210
;
		JSR	YTWSET
YTSP210		EQU	$
		RTS
;-----------------------------------------------
YTCGNOD		EQU	$
		HEX	06,08,09
		HEX	09,09,09,09,09
;-----------------------------------------------
YTJXSZ2		EQU	$
		HEX	A0,AC,B8,C4,D0,DC,E8,FF
		HEX	FF,E8,DC,D0,C4,B8,AC,A0
YTJYSZ2		EQU	$
		HEX	FF,E8,DC,D0,C4,B8,AC,A0
		HEX	A0,AC,B8,C4,D0,DC,E8,FF
;
YTEND0		EQU	$
		TYX
;
		JSR	BQSCRL
;
		LDA	BSTIM0
		BNE	YTE0010
;
		INC	BSSTAT
;
		STZ	<ENWRK2,X
;
		LDA	#01H
		STA	<ENCONT,X
;
;		 LDA	 #0FFH
;		 STA	 BSXSIZ
;		 STA	 BSYSIZ
;
;		 LDA	 #0FFH
;		 STA	 BSTIM1
;
		LDA	#30H
		STA	BSASPD
;;		  RTS
;
		LDA	#82H
		JSL	>SOUND_3_ON	;(S)
;
YTE0010		EQU	$
		LDA	<ENWRK9,X
		CLC
		ADC	#00H
		STA	<ENWRK9,X
;
		LDA	BSTIM1
		LSR	A
		AND	#02H
		ORA	#2CH
		STA	ENCLOR,X
;
		LDA	BSTIM0
;;;		LSR	A
		AND	#0FH
		TAY
		LDA	YTJXSZ2,Y
		STA	BSXSIZ
		LDA	YTJYSZ2,Y
		STA	BSYSIZ
;
		LDA	BSTIM0
		CMP	#09CH
		BNE	YTE0080	 ; BAKUHATSU KOUKA !
;
		M16
;
		LDA	ENXPSL,X
		CLC
		ADC	#000H
		STA	<EWORK0
;
		LDA	ENYPSL,X
		CLC
		ADC	#000H
		STA	<EWORK2
;
		JSL	>BOSS_EN_CHANGE
;
		LDA	#0FFFFH
		JSL	>BSCLW_SET_B_T;
;
		M8
;
YTE0080		EQU	$
		RTS
;-----------------------------------------------
YTEND05		EQU	$
		TYX
;
;
		JSR	BQSCRL
;
		LDA	BSXSIZ
		CMP	#0FEH
		BCS	YTE05008
;
		INC	BSXSIZ
		INC	BSXSIZ
YTE05008	EQU	$
		JSR	BSACLC
;
		LDA	BSANGL1
		AND	#0FCH
		CMP	#0D8H
		BNE	YTE05010
;
		INC	BSSTAT
;
		LDA	#030H
		STA	BSTIM1
YTE05010	EQU	$
		INC	<ENWRK9,X
		INC	<ENWRK9,X
;
		LDA	FRCNT
		AND	#01H
		BNE	YTE1010
;
		LDA	BSHANK
		CMP	#60H
		BEQ	YTE1010
		INC	BSHANK
YTE1010		EQU	$
		RTS
;-----------------------------------------------
YTEND1		EQU	$
		TYX
;
;
		JSR	BQSCRL
;
;
;
;		 LDY	 #01H
;		 JSR	 BQCGCK
;
;		 LDA	 FRCNT
;		 AND	 #01H
;		 BNE	 YTE1010
;;
;		 LDA	 BSHANK
;		 CMP	 #60H
;		 BEQ	 YTE1010
;		 INC	 BSHANK
;YTE1010	 EQU	 $
;
		JSR	YTE05010
;
;		LDA	FRCNT
;		AND	#01H
;		BNE	YTE1020
;
		LDA	BSXSIZ
		CMP	#040H
		BEQ	YTE1020
		SEC
		SBC	#01H
		STA	BSXSIZ
		STA	BSYSIZ
YTE1020		EQU	$
		LDA	FRCNT
		AND	#01H
;;		  ORA	  BSTIM1
		BNE	YTE1030
;
		LDA	<ENWRK2,X
		CMP	#0A0H
		BEQ	YTE1030
;
		INC	<ENWRK2,X
YTE1030		EQU	$
;		LDA	<ENWRK9,X
;		CLC
;		ADC	#02H
;		STA	<ENWRK9,X
;
		JSR	BSACLC
;
;		 LDA	 BSTIM1
;		 BNE	 YTE1040
;
;		 LDA	 BSANGL1
;		 CMP	 #080H
;		 BCC	 YTE1040
;
		LDA	FRCNT
		AND	#03H
		BNE	YTE1040
;
		LDA	BSASPD
		CMP	#04H
		BCC	YTE1040
;
		DEC	BSASPD
;
YTE1040		EQU	$
		LDA	BSANGL1
;		 CLC
;		 ADC	 #01
;		 STA	 BSANGL1
		LDY	BSTIM1
		BNE	YTE1050
		AND	#0FEH
		CMP	#04H
		BNE	YTE1050
;
		INC	BSSTAT
;
		STZ	BSTIM0
YTE1050		EQU	$
		RTS
;-----------------------------------------------
YTEND2		EQU	$
		TYX
;
;
		JSR	BQSCRL
;
		LDY	#01H
		JSR	BQCGCK
;
		LDA	BSTIM0
		BEQ	YTE2020
		CMP	#01H
		BEQ	YTE2060
		CMP	#08H
		BEQ	BQKRST
		RTS
;
YTE2020		EQU	$
		LDA	<ENWRK2,X
		CMP	#0FFH
		BEQ	YTE2050
;
		INC	<ENWRK2,X
;
		INC	<ENWRK9,X
		RTS
YTE2050		EQU	$
		LDA	#30H
		STA	BSTIM0
;
		LDA	#80H
		STA	<ENWRK9,X
		RTS
;====================================
BQKRST		EQU	$
;- - Obj kirakira set - -
;
		M16
;
		LDA	#BSQKR
		JSL	>EXINSR
;
		LDA	#05H
		STA	EXCHPT,Y
		LDA	#04H
		STA	EXTIM0,Y
;
		LDA	ENXPSL,X
		SEC
		SBC	#0FFFEH
		STA	EXXPSL,Y
;
		LDA	ENYPSL,X
		SEC
		SBC	#0004H
		STA	EXYPSL,Y
;
		M8
;
		LDA	#018H
		JSL	>SOUND_3_ON    ;(S)
		RTS
;
YTE2060		EQU	$
		LDA	#02H
		STA	<ENCONT,X
;
		LDA	#0A0H
		STA	BSXSIZ
		STA	BSYSIZ
;
		INC	BSSTAT
;
		LDA	#50H
		STA	BSTIM0
;
		STZ	ENCLOR,X  ; PRIOLITY OFF!  5/8
		RTS
;-----------------------------------------------
YTEND3		EQU	$
		TYX
;
;
		JSR	BQSCRL
;
		LDY	#01H
		JSR	BQCGCK
;
		LDA	BSTIM0
		BNE	YTE3020
;
		LDA	#05H
		STA	<ENCONT,X
;
		STZ	<ENWRK2,X
		STZ	<ENWRK2+1,X
;
;;;;iw		      LDA     #00005H
;;;;iw		      STA     !SOUND_0	  ; (S) サウンド セット!!（
;
		INC	BSSTAT
YTE3020		EQU	$
		RTS
;-----------------------------------------------
YTEND4		EQU	$
		TYX
;
;
		JSR	BQSCRL
;
;		 LDY	 #01H
;		 JSR	 BQCGCK
;;
		JSR	BQBGCGCK1
;
		LDA	<ENWRK2,X
		CLC
		ADC	#08H
		STA	<ENWRK2,X
;
;;;		CMP	#0FEH
		BEQ	YTE4050
;
;;		INC	<ENWRK2,X
;;		INC	<ENWRK2,X
		RTS
;
YTE4050		EQU	$
		INC	BSSTAT
;
		STZ	<ENWRK2,X
		STZ	<ENWRK2+1,X
;		 LDA	 #0A0H
;		 STA	 ENTIM0,X
		RTS
;-----------------------------------------------
;-----------------------------------------------
YTEND45		EQU	$
		TYX
;
;
		JSR	BQSCRL
;
;		 LDY	 #01H
;		 JSR	 BQCGCK
;;
		JSR	BQBGCGCK2
;
		LDA	<ENWRK2,X
		CMP	#0FEH
		BEQ	YTE4550
;
		INC	<ENWRK2,X
		INC	<ENWRK2,X
		RTS
;
YTE4550		EQU	$
		INC	BSSTAT
;
		LDA	#02H
		STA	ENTIM0,X
		RTS
;-----------------------------------------------
;-----------------------------------------------
;-----------------------------------------------
BQBGCGCK1	EQU	$
		M16
;
		LDA	#024A0H
		STA	R1
;
		LDA	#05FFFH
		STA	R2
;
		LDA	<ENWRK2,X
		INC	A
		STA	R6
;
		M_CHIP	 COL_MORF
		LDX	<ENINDX
;
		LDA	R3
		STA	>MOTOCOL+07EH
		STA	>DATACOL+07EH
;
		M8
		RTS
;-----------------------------------------------
BQBGCGCK2	EQU	$
		M16
;
		LDA	#024A0H
		STA	R1
;
		LDA	#07E60H
		STA	R2
;
		LDA	<ENWRK2,X
		INC	A
		STA	R6
;
		M_CHIP	 COL_MORF
		LDX	<ENINDX
;
		LDA	R3
		STA	>MOTOCOL+07CH
		STA	>DATACOL+07CH
;
		M8
		RTS
;-----------------------------------------------
;-----------------------------------------------
YTEND5		EQU	$
		TYX
;
		LDA	ENTIM0,X
		BNE	YTE5010
;
;;		  LDA	  #BS_SCRE
;;		  STA	  !MODENO
		M16
;
		LDA	#00005H	    ;iw
		STA	!SOUND_0    ; (S) サウンド セット!!（
;
		JSL	>BOSS_CLEAR    ; Boss clear !
		M8
YTE5010		EQU	$
		RTS
;-----------------------------------------------
;BQASEST		EQU	$
;		RTS
;
;		LDA	FRCNT
;		AND	#07H
;		BNE	BQAS010
;;
;		LDA	BSHANK
;		CLC
;		ADC	#018H
;		STA	<EWORKE
;;
;		LDA	BSANGL1
;		CLC
;		ADC	#000H
;		STA	<EWORK0
;		JSR	B_LOOPS
;;
;		M16
;;
;		LDA	#TEN_2
;		JSL	>EXINSR
;;
;		LDA	#10H
;		STA	EXTIM0,Y
;;
;		LDA	<RANDM0
;		AND	#007H
;		SEC
;		SBC	#004H
;;
;		CLC
;		ADC	ENXPSL,X
;		STA	EXXPSL,Y
;;
;		LDA	<RANDM0
;		AND	#007H
;		SEC
;		SBC	#004H
;;
;		CLC
;		ADC	ENYPSL,X
;		STA	EXYPSL,Y
;;
;		M8
;BQAS010		EQU	$
;		RTS
;-----------------------------------------------
;=============================================
B_LOOP		EQU	$
		PHB
		PHK
		PLB
		JSR	B_LOOPS
		PLB
		RTL
;=============================================
B_LOOPS		EQU	$
		LDA	<EWORK0
		CLC
		ADC	MD7_ANGL
		CLC
		ADC	#080H
		STA	<EWORKC
		BRA	YTCSET2
;=============================================
YTCSET		EQU	$
		LDA	BSANGL1
		CLC
		ADC	MD7_ANGL
		CLC
		ADC	#080H
		STA	<EWORKC
;
;		 LDY	 PLSTFG
;		 BEQ	 YTCS010
;;
;		 BRA	 YTCSET2
;;
;YTCS010	 EQU	 $
		PHA
		CLC
		ADC	ENWRK9,X   ; Chr angle add !
		STA	BSANGL2
		PLA
YTCSET2		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#00000110B
		TAX
		JMP	(YTCADRS,X)
;;		  JSL	  >JSRSUB
YTCADRS		EQU	$
		WORD	YEN000
		WORD	YEN001
		WORD	YEN002
		WORD	YEN003
;----------------------------------------------------------
YEN000		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK0	  ; Y POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK2	  ; X POS
		JMP	YENCST
;----------------------------------------------------------
YEN001		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK2	  ; X POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK0	  ; Y POS
		JMP	YENCST
;----------------------------------------------------------
YEN002		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK0	  ; Y POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK2	  ; X POS
		JMP	YENCST
;----------------------------------------------------------
YEN003		EQU	$
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		TAY
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		EOR	#0FFH
		INC	A
		STA	<EWORK2	  ; X POS
;
		LDA	<EWORKC ;ENWRK0,X
		AND	#03FH
		STA	<EWORKF
		LDA	#040H
		SEC
		SBC	<EWORKF
;;		  AND	  #03FH
		TAY
;
		LDA	YSINDT,Y
		STA	4202H
;
		LDA	<EWORKE ;#0030H
		STA	4203H
;
		HEX	EA,EA,EA,EA
;
		LDA	4217H
		ASL	4216H
		ADC	#00H
		STA	<EWORK0	  ; Y POS
		JMP	YENCST
;===========================================================
YENCST		EQU	$
		LDX	<ENINDX
;
		STZ	<EWORK1
		LDA	<EWORK0
		BPL	YEC010
		DEC	<EWORK1
YEC010		EQU	$
		STZ	<EWORK3
		LDA	<EWORK2
		BPL	YEC020
		DEC	<EWORK3
YEC020		EQU	$
		LDA	ENMYNO,X
		CMP	#BOSSK
		BEQ	YEC030
;
		MEM16
		REP	#00100000B
;
		LDA	<EWORK0
		CLC
		ADC	#0120H-8
		STA	ENYPSL,X
;
		LDA	PLMODE
		CMP	#PBQ7
		BEQ	YEC028
;
		LDA	<EWORK2
		CLC
		ADC	PLXPSL
;;		  ADC	  #08H
		STA	ENXPSL,X
;
YEC028		EQU	$
		MEM8
		SEP	#00100000B
YEC030		EQU	$
		RTS
;
;=========================================================================
YSINDT		EQU	$
;;	       64  63  62  61  60  59  58  57  56  55  54  53  52  51  50
      BYTE    255,255,255,255,254,254,253,252,251,250,248,247,245,243,241
;;	       49  48  47  46  45  44  43  42  41  40
      BYTE    239,237,234,231,229,226,223,220,216,213
;;	       39  38  37  36  35  34  33  32  31  30
      BYTE    209,206,202,198,194,190,185,181,177,172
;;	       29  28  27  26  25  24  23  22  21  20
      BYTE    167,162,157,152,147,142,137,132,126,121
;;	       19  18  17  16  15  14  13  12  11  10
      BYTE    115,109,104,098,092,086,080,074,068,062
;;	       09  08  07  06  05  04  03  02  01  00
      BYTE    056,050,044,038,031,025,019,013,006,000
;----------------------------------------------------------------------
;YTANDT		 EQU	 $
;;;					    32	31  30
;      BYTE				   255,243,232
;;;		29  28	27  26	25  24	23  22	21  20
;      BYTE    221,210,200,190,180,171,162,153,145,137
;;;		19  18	17  16	15  14	13  12	11  10
;      BYTE    129,121,113,106,099,092,085,078,071,064
;;;		09  08	07  06	05  04	03  02	01  00
;      BYTE    056,051,044,038,032,025,019,013,006,000
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
		END




;- X display check - -
;- Y point check - - -
		LDA	BSWRK8
		STA	<ENWRK1,X
;
		STZ	BSWRK8
;
		LDA	ENYPSH,X
		CMP	#07H
		BCC	BKBC010B
;
		LDA	ENYSPD+1,X
		BMI	BKBC010B
;
		M16
;
		LDA	#BG3_POLYGON_DT+00FH*4
		STA	R1
		LDA	#BG3_POLYGON_DT+000H
		STA	R2
		LDA	ENXPSL,X
		CLC
		ADC	#008H
		AND	#00FFH
		STA	R5
		LDA	SANGLE	; SEESOW ANGLE
		AND	#00FFH
		STA	R7
;
		M_CHIP	BG3_SEESAW_HCK
;
		LDX	<ENINDX
;
		M8
;
		LDA	R0
		BNE	BKBC002
;
		LDA	#0A8H
BKBC002		EQU	$
		STA	<EWORK0
;;		  BEQ	  BKBC010   ; In hanni ?
;
		LDA	ENYPSL,X
		CLC
		ADC	#008H
		CMP	<EWORK0
		BCC	BKBC010
;
		LDA	<EWORK0
		SEC
		SBC	#000H
		STA	ENYPSL,X
;
		M16
;
		LDA	ENYSPD,X
		CMP	#0080H
		BCS	BKBC008
		LDA	#0000H
BKBC008		EQU	$
		LSR	A
		NOP
		NOP
		EOR	#0FFFFH
		INC	A
		STA	ENYSPD,X
;
		M8
;
		LDY	#00H
;
		LDA	R0
		BEQ	BKBC00A
;
		LDY	SANGLE
BKBC00A		EQU	$
		STY	BSANGL1
;
		INC	BSWRK8
;
		LDA	R0
		BEQ	BKBC070
;
		LDA	ENXPSL,X
		SEC
		SBC	#78H
		TAY
		BPL	BKBC00B
		EOR	#0FFH
		INC	A
BKBC00B		EQU	$
		M16
		AND	#00FFH
;;		  ASL	  A
		ASL	A
		NOP
;		 LSR	 A
;		 LSR	 A
;		 LSR	 A
;;;		   LSR	   A
;		 ASL	 A
;		 TAY
;		 LDA	 BKSSSPD,Y
;		 PLY
		CPY	#00H
		BMI	BKBC00C
		EOR	#0FFFFH
		INC	A
BKBC00C		EQU	$
		STA	SAPOWR
		M8
		RTS


;************************************************************************
;*		initial ( シーソー )					*
;************************************************************************
SESAWIN		EQU	$
		RTL
;
;************************************************************************
;*		move	( シーソー )					*
;************************************************************************
SESAWMV		EQU	$
		JSL	>ENMDCK
;
		JSR	SESOSUB
;
		M16
;
		LDA	#BANK BG3SEE_SAW_DT	;(R0) <- データバンク
		STA	R1			;
		LDA	#BG3SEE_SAW_DT		;(R1) <- データアドレス
		STA	R2			;
		LDA	SANGLE			;(R2) <- 角度
		AND	#00FFH
		STA	R3			;
		LDA	#080H
		STA	CREG0			; X POS
		LDA	#0A0H
		STA	CREG1			; Y POS
;
		M_CHIP	BG3_SEESAW_SET
;
		I16
;
;--------------< data trans. >-----------------
		JSL	>M_DMA_BFST
		LWORD	HDMABUF		;to address set
		LWORD	HDMABF		;from address set
		WORD	0B2H*2*2	;number of byte set

;--------------< config. set >-------------------
		MI8
		LDA	#004H
		STA	SUBSEL
		LDA	#022H
		STA	WIND30
		LDA	#063H
		STA	SUBADF
		LDA	#00011000B
		TSB	HD420C
		M16
		LDX	<ENINDX
		RTL
;
BG3SEE_SAW_DT	EQU	$
		HEX	10
		HEX	74,E0, 75,E1, 76,E3, 77,E6
		HEX	77,FA, 76,FD, 75,FF, 74,00
		HEX	8C,00, 8B,FF, 8A,FD, 89,FA
		HEX	89,E6, 8A,E3, 8B,E1, 8C,E0
;;		HEX	10
;;		HEX	74,F0,75,F1,76,F3,77,F6
;;		HEX	77,0A,76,0D,75,0F,74,10
;;		HEX	8C,10,8B,0F,8A,0D,89,0A
;;		HEX	89,F6,8A,F3,8B,F1,8C,F0
;
;************************************************************************
;*		move	( シーソー	 )				*
;************************************************************************
SESOSUB		EQU	$
		M8
		JSR	SSACLC
;
		LDA	BSASPD2
		CLC
		ADC	SAPOWR
		STA	BSASPD2
;
		LDA	SAPOWR2
		ADC	BSASPD
		STA	BSASPD
;
;;		  BEQ	  SS005
		TAY
;
		LDA	SANGLE
		BPL	SS001
		CMP	#0F1H
		BCS	SS005
;
		CPY	#00H
		BPL	SS005
		LDA	#0F0H
		BRA	SS003
SS001		EQU	$
		CMP	#10H
		BCC	SS005
;
		CPY	#00H
		BMI	SS005
		LDA	#10H
SS003		EQU	$
		STZ	SAPOWR
		STZ	SAPOWR2
		STZ	BSASPD
		STA	SANGLE
SS005		EQU	$
		LDA	FRCNT
		AND	#03H
		BNE	SS0010
;
		LDA	BSASPD
		BEQ	SS0010
		BPL	SS000E
		INC	BSASPD
		INC	BSASPD
SS000E		EQU	$
		DEC	BSASPD
SS0010		EQU	$
		STZ	SAPOWR
		STZ	SAPOWR+1
;
;
		M16
		RTS
;----------------------------------------
;----------------------------------------
		MEM8
;
SSACLC		EQU	$
		LDA	BSASPD
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	BSASDR
		STA	BSASDR
;
		LDA	BSASPD
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		PLP
		BPL	SSAC010
		ORA	#11110000B
SSAC010		EQU	$
		ADC	SANGLE
		STA	SANGLE
		RTS
;
		MEM16
