;
;
        	INCLUDE	zel_ram.asm
;
;--------------------------------------------------------------------
;
;		PAL_ZELDA-3 (GERMAN)		1989.12.25(TUE)
;
;--------------------------------------------------------------------
;
		ORG	058000H
;
;=============================================== (zel_enmy2) ===========
		GLB	EVCHCKE,ENXSDN,ENYSDN,ENMSGEL
;----------------------------------------
		GLB	NOPPOMV,JIJI1MV,ONNAAMV,HIGEEMV,MAJOOMV
		GLB	JIJI2MV,SNTAKMV,BUBUUMV,MURONMV,MURYAMV
		GLB	MURMKMV,LINE0IT,LINE0MV,ESW02MV,BABA1MV
		GLB	YOSEIMJ,BARI0MV,HEIS0MV,TEKU0MV,HYUUUMV
		GLB	TAIHOMV,BRSDRS,NEZU0MV
		GLB	PSW01IT,PSW02IT,PINT1IT,PINT2IT
		GLB	PSW01MV,PSW02MV,PINT1MV,PINT2MV
		GLB	OYAGIST,OYAGIMV,OYAGIIT
;=============================================== (zel_enmy) ============
		EXT	EMOVE,RNDSET,BGDTRD2,ENDMST2,CROJCK2,ENCRST2
		EXT	ENBGCKL,CRENPLL,CRKNKNL,CRKNENL,OCHECKL,ENCLER
		EXT	ALOMCKL,ENIDSH,SADWSTL,SADWS2L,CRENPL2L
		EXT	PSERCHL,EN1CSTL,ESERCHL,SSERCH2,CACHCKL
;--- enmyno --
		EXT	TTN01,SKL01,SKHED,ESW01
		EXT	OCTA1,OCTA2,OCTA3,NYORO,BATTA,OCTBL,OCTSS
		EXT	IWAOO,SEKZ1,FOOD1,FOOD2,FOOD3,FOOD4,TARUH,TARUV
		EXT	KWAUS,KWAU1,SHIGE,SARU3,TOTUG,SARU1,SEKZ4,PONPK
		EXT	TAAM1,JAKIO,REBA1,KOKE1,ZOOL1,DRGN1,MANY1,OHYES
		EXT	JIJII,BABAA,HEITI,PENKI,NOKOG,KUTUU,GAKII,GAKI1
		EXT	NOPPO,JIJI1,ONNAA,HIGEE,MAJOO,JIJI2,SNTAK,BUBUU
		EXT	YATAM,MURON,MURYA,MURMK,LINE0,BABA1,ESW03,HEIS0
		EXT	TAIHO,HEIS1,HEYA0,HEYA1,HEYA2,KTOBJ,HEIS2,NEZU0,HEBI0,HEBI1
		EXT	KOMO0,PSW01,PSW02,PINT1,PINT2,HEBO0,MIHA0,OYAGI,ZAKO0
		EXT	HEIS3,SUNA0,USAG0
;--------------
		EXT	HEIT1
;-------------- item
                EXT     HART1,RUPYR,RUPYY,RUPYB,BOMB1,BOMB2,BOMB3,NIKU1
                EXT     NIKU2,OPTN1,TUBO1,TUBO2,CRYS1,TRYFR,TRYFY,TRYFB
                EXT     SPESR,SPESY,SPESB,YAAA1,YAAA2,YOSEI
;--------------
		EXT	HART1,PORT1,PORT2
		EXT	ESET0,ESET1,ESET2
		EXT	EFAIL,ECACH
;=============================================== (zel_endt) ============
									
		EXT	EXSTRA,ENEMY2
		EXT	SINDT2
;=============================================== (zel_main) ============
		EXT	GDCHCK,JSRSUB
;
		EXT	MD_title,MD_djint,MD_djply,MD_gdint,MD_gdply
		EXT	MD_fdout,MD_fdin,MD_etcpl
		EXT	MD_wpout,MD_wpin
;=============================================== (zel_play) ============
		EXT 	EATSET
		EXT 	YAMOV
		EXT	YAIMIT
		EXT	ATMSIT
;///////		EXT	RDCHCK
;=============================================== (zel_bg3) =============
		EXT	MTRSUB
;=============================================== (zel_init) =============
		EXT	p3_msge
;================================================(endt)=================
		EXT 	GRENST,EST0SB
;================================================(exst)=================
                EXT     BEAM1,BEAM2,BUME1,BOMBM,YAMOV,DTMOV     ;;;;,BOMBR
                EXT     DTMV1,DTMV2,OPMOV,WTMV0,HIBA2,SCPMV,DTMV3
;=======================================================================
;
		EXTEND
;
		MEM8
		IDX8
;=============================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
O2TEST		EQU	$	; oam set paramater set & display out check !
OAMCHK		EQU	$
		STZ	ENDSPL,X
;
		LDA	ENXPSH,X
		XBA
		LDA	ENXPSL,X
		MEM16
		REP	#00100000B
		SEC
		SBC	<SCCH2
		STA	<WORK0
		CLC
		ADC	#0040H
		CMP	#0170H
		MEM8
		SEP	#00100000B
		BCS	O2T010
;
		LDA	ENZPSL,X
		STA	<WORK2
		STZ	<WORK3
;
		LDA	ENYPSH,X
		XBA
		LDA	ENYPSL,X
		MEM16
		REP	#00100000B
		SEC
		SBC	<SCCV2
		SEC
		SBC	<WORK2
		STA	<WORK2
		CLC
		ADC	#0040H
		CMP	#0170H
		MEM8
		SEP	#00100000B
		BCS	O2T010
;
;;		LDA	ENXPSL,X
;;		SEC
;;		SBC	<SCCH2
;;		STA	<WORK0
;;		LDA	ENXPSH,X
;;		SBC	<SCCH21
;;		STA	<WORK1
;
;;                LDA     ENYPSL,X
;;;              SEC
;;                SBC     ENZPSL,X
;;;              PHP
;;                SEC
;;                SBC     <SCCV2
;;		STA	<WORK2
;;                LDA     ENYPSH,X
;;                SBC     <SCCV21
;;                PLP
;;                SBC     #00H
;;                PLP
;;                ADC     #00H
;;		STA	<WORK3
;
;;		LDA	<WORK0
;;		SEC
;;		SBC	#10H
;;		STA	ENDSYL
;
O2T038		EQU	$
		LDA	ENCLOR,X
		STA	<WORK5
		STZ	<WORK4
		LDA	<WORK0
		STA	ENDSXL
		LDA	<WORK2
		STA	ENDSYL
		LDY	#00H
		RTS
O2T010		EQU	$
		INC	ENDSPL,X
;;		LDA	SLMODE
;;		CMP	#MD_djply
;;		BEQ	O2T020
		JSL	>ENCLER
O2T020		EQU	$
		PLA
		PLA
		BRA	O2T038
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MSGCHK		EQU	$
		LDA	ENMOD0,X
		PHA
		LDA	#80H
		STA	ENMOD0,X
		LDA	ENMOD3,X
		PHA
		LDA	#07H
		STA	ENMOD3,X
		JSL	>CRENPL2L
		PLA
		STA	ENMOD3,X
		PLA
		STA	ENMOD0,X
		BCC	MSC010
;
		MEM16
		REP	#00100000B
;
		LDA	#0000H
		STA	MSGENOL
;
		LDA	PLSVX1
		STA	<PLXPS1
		LDA	PLSVY1
		STA	<PLYPS1
;
		MEM8
		SEP	#00100000B
;
		STZ	!MSGEFG
		STZ	!INITAL
		LDA	#p3_msge
		STA	<GAMEMD
		LDA	<SLMODE
		STA	!NXSLMD
		LDA	#MD_etcpl
		STA	<SLMODE
MSC010		EQU	$
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NEZU0MV		EQU	$
		PHB
		PHK
		PLB
		JSR	NZKMOV
		PLB
		RTL
;- - - - - - - - - - - - - - - - - - - - - - -
NZKMOV		EQU	$
		LDA	ENMYNO,X
		SEC
		SBC	#NEZU0
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	NZMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------------------
NZMVAD		EQU	$
		WORD	NEZU0M	; nezumi
		WORD	HEBI0M	; hebi move
		WORD	HEBI1M	; hebi toguro
		WORD	KOMO0M	; koumori
;============================================
NZPTDT		EQU	$
;;		 ENWRK0 0 1 2 3 4 5 6 7 8 9 A B C D E F
		BYTE	0,0,3,3,1,2,4,5,1,2,4,5,0,0,3,3
NZATDT		EQU	$
;;		 MUKI
		BYTE	00H,40H,00H,40H,00H,00H,00H,00H
		BYTE	40H,40H,40H,40H,80H,0C0H,80H,0C0H
;
NZSTPT		EQU	$
		BYTE	0AH,0BH
		BYTE	06H,07H
		BYTE	02H,03H
		BYTE	0EH,0FH
NZWKPT		EQU	$
		BYTE	08H,09H
		BYTE	04H,05H
		BYTE	00H,01H
		BYTE	0CH,0DH
;- - - - - - - - - - - - - - - - - - - - - - - -
NEZU0M		EQU	$
		LDY	ENWRK0,X
		LDA	NZPTDT,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	NZATDT,Y
		STA	ENCLOR,X
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		JSL	>CRKNENL
		JSL	>CRENPLL
		JSR	ENMVCL
		JSL	>ENBGCKL
;
		LDA	ENSTAT,X
		BNE	NZWALK
;;		JSL	>JSRSUB
;;		WORD	NZSTOP
;;		WORD	NZWALK
;;		RTS
;- - - - - - - -- - - - - - - - -- - - -
;
NZSTOP		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	NZST10
;
		JSL	>RNDSET
		PHA
		AND	#03H
		STA	ENMUKI,X
;
		INC	ENSTAT,X		
;
		PLA
		AND	#7FH
		ADC	#040H
;;		LDA	#80H
		STA	ENTIM0,X
NZST10		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	NZSTPT,Y
		STA	ENWRK0,X
		RTS
;-------------------------------------------------------
NZWKXS		EQU	$
		BYTE	010H,0F0H,000H,000H
NZWKYS		EQU	$
		BYTE	000H,000H,010H,0F0H
NZNXMK		EQU	$
		BYTE	2,3,1,0
;- - - - - - - - - - - - - - - - -
NZWALK		EQU	$
		LDA	ENTIM0,X
		BNE	NZWK10
		STZ	ENSTAT,X
		LDA	#50H
		STA	ENTIM0,X
NZWK10		EQU	$
		LDY	ENMUKI,X
;
		LDA	ENCBFG,X
		BEQ	NZWK18
		LDA	NZNXMK,Y
		STA	ENMUKI,X
		TAY
NZWK18		EQU	$
		LDA	NZWKXS,Y
		STA	ENXSPD,X
		LDA	NZWKYS,Y
		STA	ENYSPD,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	NZWKPT,Y
		STA	ENWRK0,X
		RTS
;===============================================
B0PTDT		EQU	$
;;		 ENWRK0 0 1 2 3 4 5 6 7 
		BYTE	0,0,2,3,2,3,1,1
B0ATDT		EQU	$
;;		 MUKI
		BYTE	00H,40H,00H,00H,40H,40H,00H,40H
;
;HBSTPT		EQU	$
;		BYTE	0AH,0BH
;		BYTE	06H,07H
;		BYTE	02H,03H
;		BYTE	0EH,0FH
HBWKPT		EQU	$
		BYTE	04H,05H
		BYTE	02H,03H
		BYTE	00H,01H
		BYTE	06H,07H
;- - - - - - - - - - - - - - - - - - - - - - - - - -
HEBI0M		EQU	$
		LDY	ENWRK0,X
		LDA	B0PTDT,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	B0ATDT,Y
		STA	ENCLOR,X
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		JSL	>CRKNENL
		JSL	>CRENPLL
		JSR	ENMVCL
		JSL	>ENBGCKL
;
		LDA	ENSTAT,X
		BNE	HBWALK
;
;;		WORD	HBSTOP
;;		WORD	HBWALK
;----------------------------------------
;
HBSTOP		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	HBST10
;
		JSL	>RNDSET
		PHA
		AND	#03H
		STA	ENMUKI,X
;
		INC	ENSTAT,X		
;
		PLA
		AND	#7FH
		ADC	#040H
;;		LDA	#80H
		STA	ENTIM0,X
HBST10		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	HBWKPT,Y
		STA	ENWRK0,X
		RTS
;-------------------------------------------------------
HBWKXS		EQU	$
		BYTE	008H,0F8H,000H,000H
HBWKYS		EQU	$
		BYTE	000H,000H,008H,0F8H
HBNXMK		EQU	$
		BYTE	2,3,1,0
;- - - - - - - - - - - - - - - - -
HBWALK		EQU	$
		LDA	ENTIM0,X
		BNE	HBWK10
		STZ	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
HBWK10		EQU	$
		LDY	ENMUKI,X
;
		LDA	ENCBFG,X
		BEQ	HBWK18
		LDA	HBNXMK,Y
		STA	ENMUKI,X
		TAY
HBWK18		EQU	$
		LDA	HBWKXS,Y
		STA	ENXSPD,X
		LDA	HBWKYS,Y
		STA	ENYSPD,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	HBWKPT,Y
		STA	ENWRK0,X
		RTS
;===============================================
HEBI1M		EQU	$
		JSR	HEBI1CS
;
		JSR	ENSTCK
		JSL	>CRENPLL
		JSL	>CRKNENL
;
		TXA
		ASL	A
		EOR	<FRCNT
		AND	#03H
		BNE	HB1010
;
		LDA	ENCHPT,X
		INC	A
		AND	#03H
		STA	ENCHPT,X
HB1010		EQU	$
		RTS

;- - -- - -- - - - - - - - - - - - - -- -
HB1XAD		EQU	$
		WORD	000H,0FFFFH
		WORD	000H,0FFFEH
		WORD	000H,0FFFFH
		WORD	000H,000H
HB1YAD		EQU	$
		WORD	000H,0FFFCH
		WORD	000H,0FFFCH
		WORD	000H,0FFFBH
		WORD	000H,0FFFBH
HB1CDT		EQU	$
		BYTE	0ACH,0AEH
		BYTE	0ACH,0AEH
		BYTE	0ACH,0AEH
		BYTE	0ACH,0AEH
;- - - - - - - - - - - - - - - - - - - - - - -
HEBI1CS		EQU	$
;;;;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
		PHX
		LDX	#01H
HB1C10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	HB1XAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	HB1YAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	HB1C18
		LDA	#00F0H
		STA	(<OAMADR),Y
HB1C18		EQU	$
		MEM8
		SEP	#00100000B
		PLX
		LDA	HB1CDT,X
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	HB1C10
;
		PLX
;;		LDY	#02H
;;		LDA	#01H
;;		JSL	>ALOMCKL
		RTS
;===============================================
KOMO0M		EQU	$
		JSL	>EN1CSTL
;
		JSR	ENSTCK
		JSL	>CRKNENL
		JSL	>CRENPLL
;
		JSR	ENMVCL
;
		LDA	ENSTAT,X
		BNE	KOMOVE
KOSTOP		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		ORA	ENTIM0,X
		BNE	KOS010
;
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#28H
		CMP	#50H
		BCS	KOS010
;
		LDA	<WORKF
		CLC
		ADC	#28H
		CMP	#50H
		BCS	KOS010
;
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#7FH
		ADC	#70H
		STA	ENTIM0,X
;
		STA	ENWRK0,X
		STA	ENWRK1,X
KOS010		EQU	$
		RTS
;-------------------------------------------------------
KOMAAD		EQU	$
		BYTE	001H,0FFH
KOMXSD		EQU	$
		BYTE	000H,008H,00BH,00EH,010H,00EH,00BH,008H
		BYTE	000H,-08H,-0BH,-0EH,-10H,-0EH,-0BH,-08H
KOMYSD		EQU	$
		BYTE	-10H,-0EH,-0BH,-08H,000H,008H,00BH,00EH
		BYTE	010H,00EH,00BH,008H,000H,-09H,-0BH,-0EH
;
KOMOVE		EQU	$
		LDA	ENTIM0,X
		BNE	KOM010
;
		STZ	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
;;;		LDA	#02H
		STZ	ENCHPT,X
		JSR	H0SDCL		; SPEED CLEAR !
		RTS
;- - - - - - - - - - - - - - - - - - - -
KOM010		EQU	$
		AND	#07H
		BNE	KOM020
;
		LDA	ENWRK1,X
		AND	#01H
		TAY
		LDA	ENWRK0,X
		CLC
		ADC	KOMAAD,Y
		STA	ENWRK0,X
;
		JSL	>RNDSET
		AND	#00000011B
		BNE	KOM020
;
		INC	ENWRK1,X
KOM020		EQU	$
		LDA	ENWRK0,X
		AND	#0FH
		TAY
		LDA	KOMXSD,Y
		STA	ENXSPD,X
		LDA	KOMYSD,Y
		STA	ENYSPD,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#01H
		INC	A
		STA	ENCHPT,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAIHOMV		EQU	$
		PHB
		PHK
		PLB
		JSR	TAIH00
		PLB
		RTL
;------------------------
;=================================================
TTAMAMV		EQU	$
		JSL	>EN1CSTL
;
		JSR	ENSTCK
		JSR	ENMVCL
;
		JSL	>CRENPLL
		JSL	>CRKNENL
;
		RTS
;
;=====================================================
KMCXAD		EQU	$
		BYTE	0FAH,00EH,0FAH,00EH
		BYTE	0FAH,00EH,0FAH,00EH
		BYTE	0FAH,00EH,0FAH,00EH
		BYTE	0FAH,00EH,0FAH,00EH
		BYTE	0FBH,00DH,0FBH,00DH
		BYTE	0FCH,00CH,0FCH,00CH
		BYTE	0FEH,00AH,0FEH,00AH
		BYTE	000H,008H,000H,008H
KMCYAD		EQU	$
		BYTE	0FAH,0FAH,00EH,00EH
		BYTE	0FAH,0FAH,00EH,00EH
		BYTE	0FAH,0FAH,00EH,00EH
		BYTE	0FAH,0FAH,00EH,00EH
		BYTE	0FBH,0FBH,00DH,00DH
		BYTE	0FCH,0FCH,00CH,00CH
		BYTE	0FEH,0FEH,00AH,00AH
		BYTE	000H,000H,008H,008H
KMCCDT		EQU	$
		BYTE	0A5H,0A5H,0A5H,0A5H
		BYTE	0A5H,0A5H,0A5H,0A5H
		BYTE	09BH,09BH,09BH,09BH
		BYTE	09BH,09BH,09BH,09BH
		BYTE	0A9H,0A9H,0A9H,0A9H
		BYTE	0A9H,0A9H,0A9H,0A9H
		BYTE	0A9H,0A9H,0A9H,0A9H
		BYTE	0A8H,0A8H,0B8H,0B8H
KMCADT		EQU	$
		BYTE	000H,040H,080H,0C0H
		BYTE	000H,040H,080H,0C0H
		BYTE	000H,040H,080H,0C0H
		BYTE	000H,040H,080H,0C0H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,040H,040H
KEMRIMV		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDA	ENTIM0,X
		BNE	KEM008
;
		STZ	ENMODE,X
KEM008		EQU	$
		LSR	A
		LSR	A
		AND	#07H
		ASL	A
		ASL	A
		STA	<WORK5
;
		PHX
		LDX	#03H
KMM010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK5
		TAX
		LDA	<WORK0
		CLC
		ADC	KMCXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	KMCYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	KMCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	KMCADT,X
		ORA	#24H
		INY
		STA	(<OAMADR),Y
		INY
		PLX
		DEX
		BPL	KMM010
;
		PLX
		LDY	#00H
		LDA	#03H
		JSL	>ALOMCKL
		RTS
;=====================================================
TAIH00		EQU	$
		LDA	ENWRK2,X
		BEQ	TAIH010		; tama ?
;					; yes !
		CMP	#02H
		BEQ	TAIH008
		JMP	TTAMAMV
TAIH008		EQU	$
		JMP	KEMRIMV
TAIH010		EQU	$
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	TH0010
;;;
;;		INC     ENCHPT,X
;;		LDA     ENCHPT,X
;;		CMP	#0CH
;;		BNE	TH0010
;;;
;;		STZ	ENCHPT,X
;;TH0010		EQU	$
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	TH0010
;;;
;;		DEC     ENCHPT,X
;;		BPL	TH0020
;;;
;;		LDA	#0BH
;;		STA	ENCHPT,X
;;TH0020		EQU	$
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	THM001
		LDA	H0TURN,Y
		STA	ENMUKI,X
THM001		EQU	$
		JSR	TAIHOCS
		PLA
		STA	ENMUKI,X
;
		JSR	ENSTCK
;;		JSL	>CRKNKNL
		JSL	>CRKNENL
		JSL	>CRENPLL
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	THMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
THMVAD		EQU	$
;;		LDA	ENSTAT,X
;;		JSL	>JSRSUB
		WORD	THWAIT
		WORD	THSHOT
		WORD	THSAGA
		WORD	THWAI2
		WORD	THRVSE
;;		RTS
;==========================================
THWAIT		EQU	$
		STZ	ENWRK0,X
		LDA	ENTIM0,X
		ORA	MIHAFG
		BNE	THW010
;
		INC	ENSTAT,X
		LDA	#060H
		STA	ENTIM0,X
;
PMSET		EQU	$
		LDA	ENMUKI,X
		PHA
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		PLA
		CMP	ENMUKI,X
		BEQ	THW010
		EOR	ENMUKI,X
		AND	#00000010B
		BNE	THW010
;
		LDA	#0CH
		STA	ENTIM1,X	; turn half pause set !
THW010		EQU	$
		RTS
;==========================================
THSHOT		EQU	$
		LDA	#00H
		LDY	ENTIM0,X
		BEQ	THS020
		CPY	#30H
		BCS	THS010
		LDA	#02H
THS010		EQU	$
		STA	ENWRK0,X
		RTS
;- - - - - - - - - - - - - - - -
THSXAL		EQU	$
		BYTE	010H,0F0H,000H,000H
THSXAH		EQU	$
		BYTE	000H,0FFH,000H,000H
THSYAL		EQU	$
		BYTE	000H,000H,008H,0F0H
THSYAH		EQU	$
		BYTE	000H,000H,000H,0FFH
THSXSD		EQU	$
		BYTE	018H,0E8H,000H,000H
THSYSD		EQU	$
		BYTE	000H,000H,018H,0E8H
;- - -- - - - -
THS020		EQU	$
		INC	ENSTAT,X
		LDA	#04H
		STA	ENTIM0,X
;- - - TAMA SET - - - - 
		LDA	#TAIHO
		JSL	>ENIDSH
		BMI	THS030
;
		LDA	#01H
		STA	ENWRK2,Y
;
		LDA	ENMUKI,X
		PHX
		TAX
                LDA     <WORK0
		CLC
		ADC	THSXAL,X
                STA     ENXPSL,Y
                LDA     <WORK1
		ADC	THSXAH,X
                STA     ENXPSH,Y
                LDA     <WORK2
		CLC
		ADC	THSYAL,X
                STA     ENYPSL,Y
                LDA     <WORK3
		ADC	THSYAH,X
		STA	ENYPSH,Y
		LDA	THSXSD,X
		STA	ENXSPD,Y
		LDA	THSYSD,X
		STA	ENYSPD,Y
;
         	LDA	ENMOD0,Y
		AND	#11110000B
		ORA	#00000001B
		STA	ENMOD0,Y
		LDA	ENMOD2,Y
		ORA	#01000111B
		STA	ENMOD2,Y
		PLX
THS030		EQU	$
;- - - KEMRI SET - - - - 
		LDA	#TAIHO
		JSL	>ENIDSH
		BMI	THS040
;
		LDA	#20H
		STA	ENTIM0,Y
;
		LDA	#02H
		STA	ENWRK2,Y
;
		LDA	ENMUKI,X
		PHX
		TAX
                LDA     <WORK0
		CLC
		ADC	THSXAL,X
                STA     ENXPSL,Y
                LDA     <WORK1
		ADC	THSXAH,X
                STA     ENXPSH,Y
                LDA     <WORK2
		CLC
		ADC	THSYAL,X
                STA     ENYPSL,Y
                LDA     <WORK3
		ADC	THSYAH,X
		STA	ENYPSH,Y
;
         	LDA	ENMOD0,Y
		AND	#11110000B
		ORA	#00000100B
		STA	ENMOD0,Y
		PLX
THS040		EQU	$
		RTS
;==========================================
THSGXS		EQU	$
		BYTE	0E0H,020H,000H,000H
THSGYS		EQU	$
		BYTE	000H,000H,0E0H,020H
;
THSAGA		EQU	$
		LDA	ENTIM0,X
		BNE	THSG10
;
		INC	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
THSG10		EQU	$
		LDY	ENMUKI,X
		LDA	THSGXS,Y
		STA	ENXSPD,X
		LDA	THSGYS,Y
		STA	ENYSPD,X
		JSR	ENMVCL
		RTS
;==========================================
THWAI2		EQU	$
		LDA	ENTIM0,X
		BNE	THW210
;
		INC	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
THW210		EQU	$
		RTS
;==========================================
THRVXS		EQU	$
		BYTE	008H,0F8H,000H,000H
THRVYS		EQU	$
		BYTE	000H,000H,008H,0F8H
;
THRVSE		EQU	$
		LDA	ENTIM0,X
		BNE	THRV10
		STZ	ENSTAT,X
		LDA	#080H
		STA	ENTIM0,X
THRV10		EQU	$
		LDY	ENMUKI,X
		LDA	THRVXS,Y
		STA	ENXSPD,X
		LDA	THRVYS,Y
		STA	ENYSPD,X
		JSR	ENMVCL
;
		LDA	<FRCNT
		LSR	A
		LSR 	A
		AND	#01H
		STA	ENWRK0,X
		RTS
;==========================================
;==========================================
;==========================================
;==========================================
THCXAD		EQU	$
		WORD	0FFFCH,004H,000H,000H,000H
		WORD	0FFFCH,004H,000H,000H,000H
		WORD	0FFFCH,004H,000H,000H,00CH
;
		WORD	004H,004H,0FFF8H,0FFF8H,0FFF8H
		WORD	004H,004H,0FFF8H,0FFF8H,0FFF8H
		WORD	004H,004H,0FFF8H,009H,009H
;
		WORD	000H,0FFFCH,004H,000H,000H
		WORD	000H,0FFFCH,004H,000H,000H
		WORD	000H,0FFFCH,004H,000H,0FFFBH
;
		WORD	0FFFCH,0FFFCH,008H,008H,008H
		WORD	0FFFCH,0FFFCH,008H,008H,008H
		WORD	0FFFCH,0FFFCH,008H,0FFFFH,0FFFFH
THCYAD		EQU	$
		WORD	000H,000H,0FFF7H,007H,007H
		WORD	000H,000H,0FFF7H,007H,007H
		WORD	000H,000H,0FFF7H,007H,0FFFDH
;
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
;
		WORD	0FFF4H,000H,000H,0FFF7H,0FFF7H
		WORD	0FFF4H,000H,000H,0FFF7H,0FFF7H
		WORD	0FFF4H,000H,000H,0FFF7H,0FFFDH
;
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
THCCDT		EQU	$
		BYTE	046H,046H,000H,024H,024H
		BYTE	048H,049H,000H,024H,024H
		BYTE	046H,006H,000H,024H,02FH
;
		BYTE	04EH,002H,026H,026H,026H
		BYTE	060H,002H,026H,026H,026H
		BYTE	008H,002H,026H,02FH,02FH
;
		BYTE	028H,064H,064H,004H,004H
		BYTE	028H,066H,067H,004H,004H
		BYTE	028H,00AH,064H,004H,02FH
;
		BYTE	04EH,002H,026H,026H,026H
		BYTE	060H,002H,026H,026H,026H
		BYTE	008H,002H,026H,02FH,02FH
THCADT		EQU	$
		BYTE	000H,040H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
;
		BYTE	000H,000H,040H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,040H,000H,040H
;
		BYTE	040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H
THCSBD		EQU	$	
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,000H
;
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,000H,000H
;
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,000H
;
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,000H,000H
;- - - - - -- -
THPTPT		EQU	$
		BYTE	09H,03H,00H,06H
;------------------
TAIHOCS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDY	ENMUKI,X
		LDA	THPTPT,Y
		CLC
		ADC	ENWRK0,X
		STA	<WORK6
;;;		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ADC	<WORK6
		STA	<WORK6
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		PHX
		LDX	#04H
		LDY	#00H
THC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	THCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	THCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	THC011
;
		LDA	#00F0H
		STA	(<OAMADR),Y
THC011		EQU	$
;
		MEM8
		SEP	#00100000B
		PLX
		LDA	THCCDT,X
		INY
		STA	(<OAMADR),Y
		SEC
		SBC	#24H
		CMP	#28H-24H+1
		LDA	THCADT,X
		ORA	<WORK5
		BCS	THC018		; TAIHO COLOR ?
		AND	#11110001B	; YES !
		ORA	#00000110B
;;		PHA
;;		LDA	THCXAD,X
;;		STA	ENKNXP
;;		LDA	THCYAD,X
;;		STA	ENKNYP
;;		PLA
THC018		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A	
		LSR	A
		TAY
		LDA	THCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	THC010
		PLX
;
;;		LDA	#04H
;;		LDY	#0FFH
;;		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	        ON MAP FAILY                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HYUUUMV		EQU	$
		PHB
		PHK
		PLB
		JSR	HYU000
		PLB
		RTL
;------------------------
HYU000		EQU	$
		JSL	>EN1CSTL
;
		JSR	ENSTCK		; scroll : not return !
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
        	AND	#001H
		STA	ENCHPT,X
;
		JSL	>CRENPLL	;PL BODY ATARI?
		BCC	HYUUU10
;					;GET !!
		STZ	ENMODE,X
;
		LDA	#020H		;LIFE UP
		CLC
		ADC	>UPLFCT
		STA	>UPLFCT
		LDA	#000H
		ADC	>UPLFCT+1
		STA	>UPLFCT+1
;
HYUUU10		EQU	$
;					;MOVE
		LDA	ENZPSL,X	;Z MOVE
		BMI	HYUUU20
		CMP	#005H
		BCC	HYUUU20
		DEC	ENZSPD,X
		BRA	HYUUU30
HYUUU20		EQU	$
		INC	ENZSPD,X
HYUUU30		EQU	$
		JSR	ENZCLC
;					;X Y MOVE
		LDA	<FRCNT
		BNE	M7MEMMY16
		LDA	MEMSTT+0FH
		INC	A
		STA	MEMSTT+0FH
M7MEMMY16	EQU	$
		LDA	MEMSTT+0FH
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		BEQ	M7MEMMY11	;R
		CMP	#001H
		BEQ	M7MEMMY12	;D
		CMP	#002H
		BEQ	M7MEMMY13	;L
		BRA	M7MEMMY14	;U
M7MEMMY11	EQU	$
		LDA	MEMXPSL+0FH	;MAP MOVE
		CLC
		ADC	#001H
		STA	MEMXPSL+0FH
		LDA	MEMXPSH+0FH
		ADC	#000H
		AND	#00FH
		STA	MEMXPSH+0FH
;
		BRA	M7MEMMY15
M7MEMMY12	EQU	$
		LDA	MEMYPSL+0FH	;MAP MOVE
		CLC
		ADC	#001H
		STA	MEMYPSL+0FH
		LDA	MEMYPSH+0FH
		ADC	#000H
		AND	#00FH
		STA	MEMYPSH+0FH
;
		BRA	M7MEMMY15
M7MEMMY13	EQU	$
		LDA	MEMXPSL+0FH	;MAP MOVE
		SEC
		SBC	#001H
		STA	MEMXPSL+0FH
		LDA	MEMXPSH+0FH
		SBC	#000H
		AND	#00FH
		STA	MEMXPSH+0FH
;
		BRA	M7MEMMY15
M7MEMMY14	EQU	$
		LDA	MEMYPSL+0FH	;MAP MOVE
		SEC
		SBC	#001H
		STA	MEMYPSL+0FH
		LDA	MEMYPSH+0FH
		SBC	#000H
		AND	#00FH
		STA	MEMYPSH+0FH
;
M7MEMMY15	EQU	$
		LDA	MEMXPSL+0FH
		STA	ENXPSL,X
		LDA	MEMXPSH+0FH
		STA	ENXPSH,X
		LDA	MEMYPSL+0FH
		STA	ENYPSL,X
		LDA	MEMYPSH+0FH
		STA	ENYPSH,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Tekkyu  heishi                         		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TEKU0MV  	EQU	$
		PHB
		PHK
		PLB
		JSR	TEK000
        	PLB
		RTL
;--------------------------------------------
TKSPIN		EQU	$
		BYTE	22H,10H
;
TEK000		EQU	$
		JSR	TEKU0CS
;
		LDA	ENSTAT,X
		CMP	#02H
		BCS	TEKD00
;
		LDA	#80H
		STA	ENKNXP
TEKD00		EQU	$
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	TEK010
;;;
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#14H
;;		BNE	TEK010
;;		STZ	ENCHPT,X
;;TEK010		EQU	$
;;
;;		LDA	<KEYA2
;;		AND	#80H
;;		BEQ	TEK020
;;;
;;		LDA	ENTIM2,X
;;		BNE	TEK020
;;;
;;		LDA	#1FH
;;		STA	ENTIM2,X
;;TEK020		EQU	$
		JSR	ENSTCK
;
		LDY	ENSTAT,X
		LDA	TKSPIN-2,Y
		CLC
		ADC	ENWRK0,X
		STA	ENWRK0,X
		LDA	ENWRK1,X
		ADC	#00H
		AND	#01H
		STA	ENWRK1,X
;
		JSR	ENHNSB
;
		JSL	>ENBGCKL
		JSR	ENMVCL
;
		JSL	>CRKNKNL
		JSL	>CRENPLL
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	TKM0000
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
TKM0000		EQU	$
;
;;		LDA	ENSTAT,X
;;		JSL	>JSRSUB
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	TKMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
TKMVAD		EQU	$
		WORD	TKWALK
		WORD	TKWAIT
		WORD	TKATWT
		WORD	TKATCK
;=====================================================
TKWALK		EQU	$
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	TKWK10
;
;;		JSR	EPXYCK
;;		TYA
		LDA	ENKBMK,X
		STA	ENMUKI,X
;
		LDA	<WORKE
		CLC
		ADC	#40H
		CMP	#068H
		BCS	TKWK08
		LDA	<WORKF
		CLC
		ADC	#30H
		CMP	#060H
		BCS	TKWK08		; hani ok ?
;					; Go atack !
		INC	ENSTAT,X
		LDA	#18H
		STA	ENTIM0,X
		RTS
TKWK08		EQU	$
		LDA	#08H
		JSL	>PSERCHL
TKWK10		EQU	$
TKWKST		EQU	$
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#07H
		ORA	<WORK0
		TAY
		LDA	TKWKPT,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - -
TKWKPT		EQU	$
		BYTE	10H,11H,12H,13H,10H,11H,12H,13H
		BYTE	6,7,8,9,6,7,8,9
		BYTE	0,1,2,3,0,1,4,5
		BYTE	0AH,0BH,0CH,0DH,0AH,0BH,0EH,0FH
;=====================================================
TKWAIT		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	TKW010
;
		LDA	#30H
		STA	ENTIM0,X
		INC	ENSTAT,X
TKW010		EQU	$
		RTS
;===================================
TKATWT		EQU	$
		LDA	ENTIM0,X
		BNE	TKA010
;
		INC	ENSTAT,X
		LDA	#1FH
		STA	ENTIM2,X
TKA010		EQU	$
		INC	ENCONT,X
		JSR	TKWKST
		RTS
;=====================================================
TKATCK		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM2,X
		BNE	TKAC10
;
		STZ	ENSTAT,X
TKAC10		EQU	$
		INC	ENCONT,X
		JSR	TKWKST
		RTS
;===============================================
;===============================================
;===============================================
TEKU0CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		JSR	TKHDCS		; head set 
		JSR	TKBDCS		; body set 
		JSR	TKWPCS		; wepon set 
;
;;		LDY	#0FFH
;;		LDA	#08H
;;		JSL	>ALOMCKL
		RTS
;==============================
TKHDCD		EQU	$
		BYTE	002H,002H,000H,004H
TKHDAD		EQU	$
		BYTE	040H,000H,000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - -
TKHDCS		EQU	$
		LDY	#18H
TKHDC2		EQU	$
;;		LDY	#04H
		PHX
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		SEC
		SBC	#09H
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	TH2C11
		LDA	#00F0H
		STA	(<OAMADR),Y
TH2C11		EQU	$
		MEM8
		SEP	#00100000B
		LDA	TKHDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	TKHDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
		RTS
;==============================
;==============================
TKCXAD		EQU	$
		WORD	0FFFCH,004H,00CH	;0
		WORD	0FFFCH,004H,00DH	;1
		WORD	0FFFCH,004H,00DH	;2
		WORD	0FFFCH,004H,00DH	;3
		WORD	0FFFCH,004H,00DH	;4
		WORD	0FFFCH,004H,00DH	;5
;
		WORD	000H,000H,004H	;6
		WORD	000H,000H,005H	;7
		WORD	000H,000H,006H	;8
		WORD	000H,000H,004H	;9
;
		WORD	0FFFCH,004H,0FFFAH	;A
		WORD	0FFFCH,004H,0FFFBH	;B
		WORD	0FFFCH,004H,0FFFBH	;C
		WORD	0FFFCH,004H,0FFFAH	;D
		WORD	0FFFCH,004H,0FFFBH	;E
		WORD	0FFFCH,004H,0FFFAH	;F
;
		WORD	000H,000H,004H	;10
		WORD	000H,000H,003H	;11
		WORD	000H,000H,002H	;12
		WORD	000H,000H,004H	;13
;-- for ya shot
		WORD	000H,000H,000H	;14
		WORD	000H,000H,000H	;15
		WORD	0FFFCH,004H,004H	;16
		WORD	0FFFCH,004H,004H	;17
TKCYAD		EQU	$
		WORD	000H,000H,0FFFCH	
		WORD	000H,000H,0FFFCH	
		WORD	000H,000H,0FFFDH
		WORD	000H,000H,0FFFEH
		WORD	000H,000H,0FFFDH
		WORD	000H,000H,0FFFEH
;
		WORD	000H,000H,001H
		WORD	000H,000H,001H
		WORD	000H,000H,002H
		WORD	000H,000H,002H
;
		WORD	000H,000H,0FFFEH
		WORD	000H,000H,0FFFEH
		WORD	000H,000H,0FFFFH
		WORD	000H,000H,0FFFFH
		WORD	000H,000H,0FFFFH
		WORD	000H,000H,0FFFFH
;
		WORD	000H,000H,001H
		WORD	000H,000H,001H
		WORD	000H,000H,002H
		WORD	000H,000H,002H
;-- YA
		WORD	000H,000H,000H
		WORD	000H,000H,000H
		WORD	000H,000H,000H
		WORD	000H,000H,000H
TKCCDT		EQU	$
		BYTE	046H,006H,02FH
		BYTE	046H,006H,02FH
		BYTE	048H,00DH,02FH
		BYTE	048H,00DH,02FH
		BYTE	049H,00CH,02FH
		BYTE	049H,00CH,02FH
;
		BYTE	008H,008H,02FH
		BYTE	008H,008H,02FH
		BYTE	022H,022H,02FH
		BYTE	022H,022H,02FH
;
		BYTE	00AH,064H,02FH
		BYTE	00AH,064H,02FH
		BYTE	02CH,067H,02FH
		BYTE	02CH,067H,02FH
		BYTE	02DH,066H,02FH
		BYTE	02DH,066H,02FH
;
		BYTE	008H,008H,02FH
		BYTE	008H,008H,02FH
		BYTE	022H,022H,02FH
		BYTE	022H,022H,02FH
;
		BYTE	062H,062H,062H
		BYTE	062H,062H,062H
		BYTE	046H,04BH,04BH
		BYTE	069H,064H,064H
TKCADT		EQU	$
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	040H,040H,000H
		BYTE	040H,040H,000H
;
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
;
		BYTE	000H,040H,040H
		BYTE	000H,040H,040H
		BYTE	000H,000H,040H
		BYTE	000H,000H,040H
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
;
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
;
		BYTE	040H,040H,040H
		BYTE	000H,000H,000H
		BYTE	000H,040H,040H
		BYTE	000H,040H,040H
TKCSBD		EQU	$
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
;==================================================
TKBSID		EQU	$
		BYTE	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
		BYTE	1,1,1,1
TKBSI2		EQU	$
		BYTE	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
		BYTE	8,8,8,8
;
TKBDCS		EQU	$
		LDY	#14H
TKBDC2		EQU	$
;
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
;
		PHX
		LDA	ENCHPT,X
		TAX
		TYA
		CLC
		ADC	TKBSI2,X
		TAY
		LDA	TKBSID,X
		TAX
;;;		LDX	#02H
TEKC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	TKCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	TKCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	TEKC12
;
		LDA	#00F0H
		STA	(<OAMADR),Y
TEKC12		EQU	$
		MEM8
		SEP	#00100000B
;
		PLX
		LDA	TKCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	TKCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	TKCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		CPX	#02H
		BNE	TKC030	; next head set ?
		INY		; index entry !
		INY
		INY
		INY
TKC030		EQU	$
		DEX
		BPL	TEKC10
;
		PLX
		RTS
;====================================
TKWPAD		EQU	$
		BYTE	10H,12H,14H,16H,18H,1AH,1CH,1EH
		BYTE	20H,22H,24H,26H,28H,2AH,2CH,2EH
		BYTE	30H,2EH,2CH,2AH,28H,26H,24H,22H
		BYTE	20H,1EH,1CH,1AH,18H,16H,14H,12H
;
TKHDXD		EQU	$
		BYTE	04H,04H,0CH,0FBH
TKHDYD		EQU	$
		BYTE	0FEH,0FEH,0FAH,0FCH
;- - - - -- - - -
TKWPCS		EQU	$
		LDA	<WORK0
		STA	ENDSXL
		LDA	<WORK2
		STA	ENDSYL
;
                LDA	ENWRK0,X
		STA	<WORK0
		LDA	ENWRK1,X
		STA	<WORK1		; angle
;
		LDA	#00H
		LDY	ENSTAT,X
		CPY	#02H
		BCC	TKSP10
;
		LDA	ENTIM2,X
		NOP
		NOP
		TAY
		LDA	TKWPAD,Y
TKSP10		EQU	$
		STA	<WORKF		; hankei
;
		LDY	ENMUKI,X
		LDA	TKHDXD,Y
		STA	<WORKC
		LDA	TKHDYD,Y
		STA	<WORKD
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0
		AND	#01FFH
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORKA
;
		LDA	<WORK0
		CLC
		ADC	#0080H
		AND	#01FFH
		STA	<WORK2
;
		LDA	<WORK0
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK4
;
		LDA	<WORK2
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK6
		MEM8
		IDX8
		SEP	#00110000B		
		PLX
;
		LDA	<WORK4
		STA	4202H
		LDA	<WORKF 	    ; Hankei
		LDY	<WORK5
		BNE	KSF0
		STA	4203H
		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		ASL	4216H
		LDA	4217H
		ADC	#00H
KSF0		EQU	$
		STA	<WORKE
		LSR	<WORK1
		BCC	KS00
		EOR	#0FFH
		INC	A
KS00		EQU	$
		STA	<WORK4		; XAD
;
		LDA	<WORK6
		STA	4202H
		LDA	<WORKF
		LDY	<WORK7
		BNE	KS08
		STA	4203H
		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		ASL	4216H
		LDA	4217H
		ADC	#00H
KS08		EQU	$
		STA	<WORKF
		LSR	<WORK3
		BCC	KS10
		EOR	#0FFH
		INC	A
KS10		EQU	$
		STA	<WORK6		; YAD
;-- oam set -
		LDY	#00H
;
		LDA	<WORK4
		SEC
		SBC	#04H
		CLC
		ADC	<WORKC
		STA	ENKNXP
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
;
		LDA	<WORK6
		SEC
		SBC	#04H
		CLC
		ADC	<WORKD
		STA	ENKNYP
		CLC
		ADC	ENDSYL
		INY
		STA	(<OAMADR),Y		
		LDA	#02AH
		INY
		STA	(<OAMADR),Y
		LDA	#00100111B
		INY
		STA	(<OAMADR),Y
		LDA	#02H
		STA	(<OSBADR)
;--- Chaine set ------
		LDY	#04H
		PHX
		LDX	#03H
TWC000		EQU	$
		LDA	<WORKE
		STA	4202H
		LDA	TKBYDT,X
		STA	4203H
		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		LDA	<WORK4
		ASL	A
		LDA	4217H
		BCC	TWC010
		EOR	#0FFH
		INC	A
TWC010		EQU	$
		CLC
		ADC	ENDSXL
		CLC
		ADC	<WORKC
		STA	(<OAMADR),Y
;
		LDA	<WORKF
		STA	4202H
		LDA	TKBYDT,X
		STA	4203H
		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		LDA	<WORK6
		ASL	A
		LDA	4217H
		BCC	TWC020
		EOR	#0FFH
		INC	A
TWC020		EQU	$
		CLC
		ADC	ENDSYL
		CLC
		ADC	<WORKD
		INY
		STA	(<OAMADR),Y
;;		LDA	#02AH
		LDA	#03FH
		INY
		STA	(<OAMADR),Y
		LDA	#00100111B
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#00H
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	TWC000
		PLX
;
		LDY	#0FFH
		LDA	#04H
		JSL	>ALOMCKL
		RTS
;- - - -
TKBYDT		EQU	$
		BYTE	33H,66H,99H,0CCH
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Heishi 0                               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HEIS0MV  	EQU	$
		PHB
		PHK
		PLB
		JSR	HEI000
        	PLB
		RTL
;=========================================
;HTESTD		EQU	$
;		BYTE	2,2,2,2,1,1,1,3,3,3,3,0,0,0
H0TURN		EQU	$
		BYTE	3,2,0,1
H0TUR2		EQU	$
		BYTE	08H,00H,0CH,05H
;
HEI000		EQU	$
		LDA	ENMYNO,X
		SEC
		SBC	#HEIS0
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	HEMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
HEMVAD		EQU	$
		WORD	HEIS0M
		WORD	HEIS1M
		WORD	HEIS2M
		WORD	HEIS3M
		WORD	HEYA0M
		WORD	HEYA1M
		WORD	HEYA2M
		WORD	HEBO0M
		WORD	MIHA0M
		WORD	ZAKO0M
		WORD	SUNA0M
		WORD	USAG0M
;
;==== SUNA OTOKO ============
SUNA0M		EQU	$
;
;
;
;
;
;
;
;
;==== USAGI MODOKI  ============
USAG0M		EQU	$
		RTS
;==== ZAKO HEISHI ============
ZKXSDT		EQU	$
		HEX	08,F8,00,00
ZKYSDT		EQU	$
		HEX	00,00,08,F8
ZKCHPT		EQU	$
		HEX	00,02,04,06
		HEX	01,03,05,07
;
;;		HEX	00,01
;;		HEX	02,03
;;		HEX	04,05
;;		HEX	05,06
;--------------------------------------
ZAKO0M		EQU	$
		JSR	ZAKO0CS
;
		JSR	ENSTCK
		JSL	>CRENPLL
		JSL	>CRKNENL
;
		JSR	ENMVCL
		JSL	>ENBGCKL
;
		LDA	ENSTAT,X
		BNE	ZKWALK
;
		LDA	ENTIM0,X
		BNE	ZKS010
;
		JSL	>RNDSET
		AND	#3FH
		ADC	#30H
		STA	ENTIM0,X
		INC	ENSTAT,X
;
		LDA	ENKBMK,X
		STA	ENMUKI,X
;
		TAY
		LDA	ZKXSDT,Y
		STA	ENXSPD,X
		LDA	ZKYSDT,Y
		STA	ENYSPD,X
ZKS010		EQU	$
		RTS
;============================================
ZKNXMK		EQU	$
		HEX	2,3,2,3,0,1,0,1
;
ZKWALK		EQU	$
		LDA	#10H
;
		LDY	ENCBFG,X
		BNE	ZKW008
;
		LDA	ENTIM0,X
		BNE	ZKW010
;
		LDA	#30H
ZKW008		EQU	$
		STA	ENTIM0,X
;
		JSR	H0SDCL
;
;;		LDA	#30H
;;		STA	ENTIM0,X
;
		JSL	>RNDSET
		AND	#01H
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ORA	<WORK0
		TAY
		LDA	ZKNXMK,Y
		STA	ENKBMK,X
;
		STZ	ENSTAT,X
ZKW010		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#00001000B
		LSR	A
		ADC	ENMUKI,X
		TAY
		LDA	ZKCHPT,Y
		STA	ENCHPT,X		
		RTS
;- - - - - - - - - - - - - - - - - - - - -
Z0HDCD		EQU	$
		BYTE	082H,082H,080H,084H
Z0HDAD		EQU	$
		BYTE	040H,000H,000H,000H
;
ZKCXAD		EQU	$
		WORD	02,02,0FFFEH,0FFFEH,00,00,00,00
;;ZKCYAD		EQU	$
;;		WORD	00,00,00,00,00,00,00,00
ZKCCDT		EQU	$
		HEX	8A,8C,8A,8C,86,88,8E,A0
ZKCADT		EQU	$
		HEX	40,40,00,00,00,00,00,00
ZAKO0CS	        EQU	$
;- - - - - - - - - - - - - - - - - - - - - - - -
;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDA	ENCHPT,X
;;		ASL	A
		STA	<WORK6
;- head -
		PHX
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		SEC
		SBC	#0BH
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	ZKC012
		LDA	#00F0H
		STA	(<OAMADR),Y
ZKC012		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	H0HDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	H0HDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
;
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR)
;- Body --
		LDA	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0 
		CLC
		ADC	ZKCXAD,X
		INY
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
;;		CLC
;;		ADC	ZKCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	ZKBC10
;
		LDA	#00F0H
		STA	(<OAMADR),Y
ZKBC10		EQU	$
		MEM8
		SEP	#00100000B
;
		PLX
		LDA	ZKCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	ZKCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
;
		LDY	#01H
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
;;		LDY	#02H
;;		LDA	#01H
;;		JSL	>ALOMCKL
		RTS
;
;
;
;
;
;-----Mihari heishi---------------------------------
MHMKDT		EQU	$
		HEX 	0,2,1,3
;
MIHA0M		EQU	$
		JSR	MIHA0CS
;
		JSR	ENSTCK
;
		JSR	>CRENPLL
;
		LDA	ENSTAT,X
		CMP	#03H
		BNE	MHM000		; found player ?
;					; yes !
		LDA	<FRCNT
		AND	#0FH
		BNE	MHM0F0
;
		LDA	ENMUKI,X
		INC	A
		AND	#03H
		STA	ENMUKI,X
		STA	ENCHPT,X
		STA	ENKBMK,X
		STZ	MIHAFG
MHM0F0		EQU	$
		RTS
;- -- - - - - - - - - - - - - - - - - - - - - - - - - - -
MHM000		EQU	$
		CMP	#00H
		BNE	MHM050
;
		LDA	ENTIM0,X
		BNE	MHW010
;
		LDA	#0A0H
		STA	ENTIM0,X
		INC	ENSTAT,X
;
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#03H
		TAY
		LDA	MHMKDT,Y
		STA	ENMUKI,X
		STA	ENCHPT,X
MHM010		EQU	$
MHW010		EQU	$
		RTS
;- - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - -
MHM050		EQU	$
		LDA	ENTIM0,X
		BNE	MHKY10
;
		LDA	#20H
		STA	ENTIM0,X
		STZ	ENSTAT,X
		RTS
;
MHKY10		EQU	$
         	JSR	H0SERC		; player serch !
;
		LDA	ENTIM0,X
		NOP
		LSR	A
		LSR	A
		LSR	A
		AND	#00000111B
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	H0KKBD,Y
		STA	ENKBMK,X
;		
		RTS
;- - - - - - - - - - - - - - - - - - - -
MHCXAD		EQU	$
		WORD	00,00,00
;
		WORD	00,00,00
;
		WORD	0FFFCH,04,04
;
		WORD	0FFFCH,04,04
MHCYAD		EQU	$
		WORD	00,00,00
;
		WORD	00,00,00
;
		WORD	00,00,00
;
		WORD	00,00,00
MHCCDT		EQU	$
		HEX	08,08,08
;
		HEX	08,08,08
;
		HEX	46,46,46
;
		HEX	64,64,64
MHCADT		EQU	$
		HEX	40,40,40
;
		HEX	00,00,00
;
		HEX	00,40,40
;
		HEX	00,40,40
MHCSBD		EQU	$
		HEX	02,02,02
;
		HEX	02,02,02
;
		HEX	02,02,02
;
		HEX	02,02,02
;- - - - - - - - - - - - - - - - - - - - - - - - - - -
MIHA0CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		JSR	H0HDCS
;
		LDY	#04H
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		PHX
		LDX	#02H
MHC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	MHCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	MHCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	MHC012
;
		LDA	#00F0H
		STA	(<OAMADR),Y
MHC012		EQU	$
		MEM8
		SEP	#00100000B
		PLX
		LDA	MHCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	MHCADT,X
		INY
		ORA	<WORK5
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR 	A
		LSR	A
		TAY
		LDA	MHCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	MHC010
;
		PLX
;;		LDY	#0FFH
;;		LDA	#03H
;;		JSL	>ALOMCKL
		RTS
;-----Bakudan heishi---------------------------------
HEBO0M		EQU	$
		LDA	ENWRK2,X
		BNE	BOMBMV
;
		JMP	BOM0F0		; bomb ?
;					; yes !
BOMBMV		EQU	$
		CMP	#02H
		BNE	BB0010
;
		LDY	#ENNO-1
CIE010		EQU	$
        	CPY	ENINDX
		BEQ	CIE020		; myself ?
;
		LDA	ENMODE,Y	; no !
		CMP	#EMOVE
		BCC	CIE020
		TYA
		EOR	<FRCNT
		AND     #07H
		ORA	ENFLSH,Y
		BNE	CIE020
;
		JSR	CIESUB
CIE020		EQU	$
		DEY
		BPL	CIE010
CIE0RT		EQU	$
		JSR	BBBRCS
;
		LDA	ENTIM1,X
		BNE	BBR010
;
		STZ	ENMODE,X
BBR010		EQU	$
		JSL	>CRENPLL
 		RTS
;------------------------------------
CIESUB		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<WORK0
		LDA	ENXPSH,X
		SBC	#00H
		STA	<WORK8
		LDA	#30H
		STA	<WORK2
		STA	<WORK3
		LDA	ENYPSL,X
		SEC
		SBC	#10H
		STA	<WORK1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<WORK9
;
		PHX
		TYX
		JSL	>ENCRST2
          	PLX
		JSL	>CROJCK2
		BCC	CIE090
;
		PHX
		TYX
		JSL	>ENDMST2
		PLX
CIE090		EQU	$
		RTS
;
;- - - - - - - - - - - - -- - - -- - -- --
BB0010		EQU	$
 		JSL	>EN1CSTL
;
		LDA	ENTIM1,X
		CMP	#40H
		BCS	BOMBF0
;
		CMP	#01H
		BNE	BOMBE0		; Bakuhatsu time ?
;					; yes !
		INC	ENWRK2,X
;
		LDA	#09H
		STA	ENMOD3,X
;
		LDA	#20H
		STA	ENTIM1,X
;
;;		LDA	ENMODE,X
;;		CMP	#ECACH
;;		BNE	BOMBD8
;;;		CACH CLEAR !
		LDA	#EFAIL
		STA	ENMODE,X
BOMBD8		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - -
BOMBE0		EQU	$
		LSR	A
		AND	#00001110B
		STA	<WORK0
;
		LDA	ENCLOR,X
		AND	#11110001B
		ORA	<WORK0
		STA	ENCLOR,X
;;;		RTS
;
BOMBF0		EQU	$
		JSR	ENSTCK
;
		JSL	>CACHCKL
;
		JSR	ENBDCL
;
;;		LDA	ENXSPD,X
;;		ORA	ENYSPD,X
;;		BNE	BOMB00		; stop ?
;;;
;;		LDA	#40H		; yes ! bakuhatsu time set !
;;		STA	ENTIM0,X
BOMB00		EQU	$
		RTS
;
;===========================================================
ENBDCL		EQU	$
		JSR	ENMVCL
;
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	EIC008
		STZ	ENZPSL,X
;
		LDA	ENZSPD,X
		EOR	#0FFH
		INC	A
		LSR	A
		NOP	
		CMP	#06H
		BCS	EIC003
		LDA	#00H
EIC003		EQU	$
		STA	ENZSPD,X
		LDA	ENXSPD,X
		ASL	A
		ROR	ENXSPD,X
		LDA	ENXSPD,X
		CMP	#0FFH
		BNE	EIC005
		STZ	ENXSPD,X	
EIC005	 	EQU	$
		LDA	ENYSPD,X
		ASL	A
		ROR	ENYSPD,X
		LDA	ENYSPD,X
		CMP	#0FFH
		BNE	EIC008
		STZ	ENYSPD,X	
EIC008		EQU	$
ENIC10		EQU	$
		RTS
;
;========================================================================
BOM0F0		EQU	$
		JSR	HEBO0CS
;
		JSR	ENSTCK
;
		LDA	MIHAFG
		BNE	BOM000
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
;
		LDA	ENSTAT,X
		BNE	BOM010
;
		LDA	ENTIM0,X
		BNE	BOM000
;
		INC	ENSTAT,X
BOMFFF		EQU	$
		LDA	#70H
		STA	ENTIM0,X
BOM000		EQU	$
		RTS
;====================================================================
BOM010		EQU	$
		LDA	ENTIM0,X
		BNE	BO0010
;
		STZ	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
		RTS
BO0010		EQU	$
		STZ	ENCONT,X
		CMP	#050H
		BCC	BO0018
		INC	ENCONT,X
BO0018		EQU	$
		CMP	#20H
		BNE	BO0020
		PHA
;
		JSR	BOMBSET
		PLA
BO0020		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		CLC
		ADC	#Y2PT1-Y2PT0
		TAY
		LDA	HYYPTD,Y
		STA	ENCHPT,X
		RTS
;==========================================
BBSXAL		EQU	$
		BYTE	000H,001H,009H,0F8H
BBSXAH		EQU	$
		BYTE	000H,000H,000H,0FFH
BBSYAL		EQU	$
		BYTE	0F4H,0F4H,0F1H,0F3H
BBSYAH		EQU	$
		BYTE	0FFH,0FFH,0FFH,0FFH
;BBSXSD		EQU	$
;		BYTE	010H,0F0H,000H,000H
;BBSYSD		EQU	$
;		BYTE	000H,000H,010H,0F0H
;
;- - - - --- - --- - -- - - - --- - - - --
BOMBSET		EQU	$
		LDA	#HEBO0
		JSL	>ENIDSH
		BMI	BBS010
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	<WORK0
		CLC
		ADC	BBSXAL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	BBSXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	BBSYAL,X
		STA	ENYPSL,Y
		LDA	<WORK3	
		ADC	BBSYAH,X
		STA	ENYPSH,Y
;
		TYX
		LDA	#10H
		JSL	>PSERCHL
;;		LDA	BBSXSD,X
;;		STA	ENXSPD,Y
;;		LDA	BBSYSD,X
;;		STA	ENYSPD,Y
		LDA	#01H
		STA	ENWRK2,X
;
		LDA	#030H
		STA	ENZSPD,X
;
		LDA	ENMOD2,X
		AND	#11101110B
		ORA	#00011000B
		STA	ENMOD2,X
		LDA	#08H
		STA	ENCLOR,X
		LDA	#0FFH
		STA	ENTIM1,X
		PLX
BBS010		EQU	$
		RTS
;=========================================
HEBO0CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	#04H+04H
		JSR	TKHDC2		; head set 
		LDY	#00H+04H
		JSR	TKBDC2		; body set 
		LDA	ENCHPT,X
		CMP	#14H
		BCS	B0C098		; with BOMB ?
;;;					; yes !
		JSR	B0WPCS
B0C098		EQU	$
;
;;		LDY	#0FFH
;;		LDA	#04H
;;		JSL	>ALOMCKL
		RTS
;- - - - - - - - - - - -
BWCXAD		EQU	$
		WORD	00FFFFH,01
		WORD	02,00
		WORD	09,09
		WORD	0FFF8H,0FFF8H
BWCYAD		EQU	$
		WORD	0FFF4H,0FFF4H
		WORD	0FFF4H,0FFF4H
		WORD	0FFF0H,0FFF2H
		WORD	0FFF4H,0FFF2H
;
B0WPCS		EQU	$
		PHX
		LDA	ENMUKI,X
		ASL	A
		ORA	ENCONT,X
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	BWCXAD,X
		LDY	#00H
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	BWCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	B0WC10
;
		LDA	#00F0H
		STA	(<OAMADR),Y
B0WC10		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	#40H
		INY
		STA	(<OAMADR),Y
		INY
		LDA	#28H
		STA	(<OAMADR),Y
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR)
		PLX
		RTS
;
;=========================================
BBBRXD		EQU	$
		HEX	F4,0C,F4,0C
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	00,00,00,00
BBBRYD		EQU	$
		HEX 	F4,F4,0C,0C
		HEX 	F8,F8,08,08
		HEX 	F8,F8,08,08
		HEX 	00,00,00,00
BBBRCD		EQU	$
		HEX 	88,88,88,88
		HEX 	8A,8A,8A,8A
		HEX 	84,84,84,84
		HEX 	86,86,86,86
BBBRAD		EQU	$
		HEX 	00,40,80,C0
		HEX 	00,40,80,C0
		HEX 	00,40,80,C0
		HEX 	00,00,00,00
;
BBBRCS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDA	ENTIM1,X
		LSR	A
		AND	#00001100B
		STA	<WORK6
;
		PHX
		LDX	#03H
BBBC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	BBBRXD,X
		STA	(<OAMADR),Y
;
		LDA	<WORK2
		CLC
		ADC	BBBRYD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	BBBRCD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	BBBRAD,X
		ORA	#22H
		INY
		STA	(<OAMADR),Y
		INY
		PLX
		DEX
		BPL	BBBC10
		PLX
;
		LDY	#02H
		LDA	#03H
		JSL	>ALOMCKL
		RTS
;
;----------------------------------------------------
HEIS0M		EQU	$
HEIS1M		EQU	$
		LDA	ENWRK2,X
		BNE	HA0F00
		JMP	HEI001	; serch beam ?
HA0F00		EQU	$
;				; yes !
		LDY	#00H
		LDA	ENXSPD,X
		BPL	HA0100
		DEY
HA0100		EQU	$
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,X
		TYA
		ADC	ENXPSH,X
		STA	ENXPSH,X
;		
		LDY	#00H
		LDA	ENYSPD,X
		BPL	HA0200
		DEY
HA0200		EQU	$
		CLC
		ADC	ENYPSL,X
		STA	ENYPSL,X
		TYA
		ADC	ENYPSH,X
		STA	ENYPSH,X
;
		LDY	ENWRK2,X
		LDA	ENMYNO-1,Y
		CMP	#MIHA0
		BEQ	HA0208
;
		JSL	>ENBGCKL
		LDA	ENCBFG,X
		BNE	HEI002
;
HA0208		EQU	$
		JSL	>CRENPL2L
		BCC	HA0280		; find player ?
;					; yes !
		LDA	ENWRK2,X
		DEC	A
		PHX
		TAX
		LDA	#03H
		STA	ENSTAT,X	; go atack !
		LDA	#10H
		STA	ENTIM0,X
		STZ	ENCONT,X
		PLX
		BRA	HEI002
HA0280		EQU	$
		LDA	ENXPSL,X
		CMP	<SCCH2
		LDA	ENXPSH,X
		SBC	<SCCH2+1
		BNE	HEI002
		LDA	ENYPSL,X
		CMP	<SCCV2
		LDA	ENYPSH,X
		SBC	<SCCV2+1
		BEQ	HEI003
;
;;		JSR	OAMCHK
;;		LDA	ENDSYL
;;		CMP	#0F8H
;;		BCS	HEI002
;;		LDA	ENDSXL
;;		CMP	#0F8H
;;		BCC	HEI003
HEI002		EQU	$
		STZ	ENMODE,X
HEI003		EQU	$
;;		LDA	ENDSXL
;;		STA	(<OAMADR),Y
;;		INY
;;		LDA	ENDSYL
;;		STA	(<OAMADR),Y
;;		INY
;;		LDA	#00H
;;		STA	(<OAMADR),Y
;;		INY
;;		LDA	#30H
;;		STA	(<OAMADR),Y
;;		LDY	#00H
;;		LDA	#00H
;;		STA	(<OSBADR),Y
		RTS		
;
;=================================================
HEI001		EQU	$
;		LDA	<KEYA2
;		AND	#08H
;		BEQ	HEI010
;		INC	ENCHPT,X
;		LDA	ENCHPT,X
;		CMP	#0EH
;		BNE	HEI010
;;
;		STZ	ENCHPT,X
;HEI010		EQU	$
;		LDY	ENCHPT,X
;		LDA	HTESTD,Y
;		STA	ENMUKI,X
;;
;		LDA	<KEYA2
;		AND	#004H
;		BEQ	HEI020
;		LDA	ENKBMK,X
;		INC	A
;		AND	#03H
;		STA	ENKBMK,X
;HEI020		EQU	$
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	H0M001
		LDA	H0TURN,Y
		STA	ENMUKI,X
		LDA	H0TUR2,Y
		STA	ENCHPT,X
H0M001		EQU	$
		JSR	HEIS0CS
		PLA
		STA	ENMUKI,X
;
		JSR	ENSTCK
;
		LDA	ENHNFG,X
		BEQ	H00000
;
		LDA	#04H
		STA	ENSTAT,X
		LDA	#080H
		STA	ENTIM0,X
;
		STZ	HEMODE,X
H00000		EQU	$
		JSR	ENHNSB
;
		LDA	HEMODE,X
		AND	#00000111B
		CMP	#00000101B
		BCS	H00001
;
		STZ	ENMOD3,X
		JSL	>ENBGCKL
H00001		EQU	$
		JSR	ENMVCL
;
		JSL	>CRKNKNL
		JSL	>CRENPLL
;
;		WORD	H0WKWT	;0
;		WORD	H0WALK	;1
;		WORD	H0KYRO	;2
;		WORD	H0ATWT	;3
;		WORD	H0ATCK	;4
;		LDA	ENHNFG,X
;		BNE	H00RTS
;
;;		LDA	ENSTAT,X
;;		JSL	>JSRSUB
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	H0MVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
H0MVAD		EQU	$
		WORD	H0WKWT	;0
		WORD	H0WALK	;1
		WORD	H0KYRO	;2
		WORD	H0ATWT	;3
		WORD	H0ATCK	;4
;;----------------------
;H00RTS		EQU	$
;		LDA	#04H
;		STA	ENSTAT,X
;		LDA	#0FFH
;		STA	ENTIM0,X
;		RTS
;- - - - - - - - - - - - - - - - - -
H0WKTM		EQU	$
		HEX	60,C0,FF,40
;
;;		HEX     20,30,40,50
;
H0WKWT		EQU	$
		JSR	H0SDCL
		LDA	ENTIM0,X
		BNE	HWW010
;
		INC	ENSTAT,X
;
		LDA	HEMODE,X
		BEQ	H0WW10
;- - - kotei move - - - - - - -
		AND	#00000111B
		CMP	#00000101B
		BCS	H0WW10		; L R or U D move ?
;					; yes !
		LDA	HEMODE,X
		LSR	A
		LSR	A
		LSR	A
		AND	#00000011B
		TAY
		LDA	H0WKTM,Y
		STA	ENTIM0,X	; move range set !
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
		STZ	ENCONT,X
		BRA	H0TUST
;- - - normal move - - - - 
H0WW10		EQU	$
		JSL	>RNDSET
		AND	#03FH
;
        	ADC	#028H
		STA	ENTIM0,X
;
		LDA	ENMUKI,X
		PHA
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X
		PLA
		CMP	ENMUKI,X
		BEQ	HWW010
		EOR	ENMUKI,X
		AND	#00000010B
		BNE	HWW010
;
H0TUST		EQU	$
		LDA	#0CH
		STA	ENTIM1,X	; turn half pause set !
HWW010		EQU	$
		RTS
;---------------------------------
H0WXSD		EQU	$
		BYTE	008H,0F8H,000H,000H
H0WYSD		EQU	$
		BYTE	000H,000H,008H,0F8H
H0WKPT		EQU	$
Y0WKPT		EQU	$
YWP1		EQU	$
		BYTE	0BH,0CH,0DH,0CH
		BYTE	04H,05H,06H,05H
		BYTE	00H,01H,02H,03H
		BYTE	07H,08H,09H,0AH
YWP0		EQU	$
		BYTE	11H,12H,11H,12H
		BYTE	07H,08H,07H,08H
		BYTE	03H,04H,03H,04H
		BYTE	0DH,0EH,0DH,0EH
;====================================================================
KBCBXS		EQU	$
		HEX	01,01,FF,FF,FF,FF,01,01
KBCBYS		EQU	$
		HEX	FF,01,01,FF,FF,01,01,FF
KBMVXS		EQU	$
		HEX	08,00,F8,00,F8,00,08,00
KBMVYS		EQU	$
		HEX	00,08,00,F8,00,08,00,F8
KBMVMK		EQU	$
		HEX	0,2,1,3,1,2,0,3
KBCBCK		EQU	$
		HEX	1,4,2,8,2,4,1,8
KBCBC2		EQU	$
		BYTE	8,1,4,2,8,2,4,1
KBNXMK		EQU	$
		BYTE	1,2,3,0,5,6,7,4
KBNXM2		EQU	$
		BYTE	3,0,1,2,7,4,5,6
;- - - - - - - - - - - - - - - - - - - - - - - -
KABEMV		EQU	$
		LDY	ENWRK1,X
		LDA	KBCBXS,Y
		STA	ENXSPD,X
		LDA	KBCBYS,Y
		STA	ENYSPD,X
;
                JSL	>ENBGCKL		
;
		LDA	ENTIM2,X
		BEQ	KBM010
;
		CMP	#2CH
		BNE	KBM020
;
		LDY	ENWRK1,X
		LDA	KBNXM2,Y
		STA	ENWRK1,X
		BRA	KBM020
;
KBM010		EQU	$
;;		LDY	ENWRK1,X
;;		LDA	KBCBXS,Y
;;		STA	ENXSPD,X
;;		LDA	KBCBYS,Y
;;		STA	ENYSPD,X
;;;
;;;             JSL	>ENBGCKL		
;
		LDY	ENWRK1,X
		LDA	ENCBFG,X
		AND	KBCBC2,Y
		BNE	KBM020
;
		LDA	#58H
		STA	ENTIM2,X
;;		BRA	KBM030
KBM020		EQU	$
		LDY	ENWRK1,X
		LDA	ENCBFG,X
		AND	KBCBCK,Y
		BEQ	KBM030
;
		LDA	KBNXMK,Y
		STA	ENWRK1,X
KBM030		EQU	$
         	LDY	ENWRK1,X
		LDA	KBMVXS,Y
		STA	ENXSPD,X
		LDA	KBMVYS,Y
		STA	ENYSPD,X
		LDA	KBMVMK,Y
		STA	ENMUKI,X
		STA	ENKBMK,X
;
		JMP	H0WKPS
;
;
;
;
;
;
;
;
;====================================================================
H0WALK		EQU	$
		JSR	H0SER2
;
		LDA	HEMODE,X
		AND	#00000111B
		CMP	#00000101B
		BCC	H0W000
;
		JMP	KABEMV			; kabe soi move !
;
H0W000		EQU	$
		LDA	ENTIM0,X
		BNE	H0W010
;
;;		STZ	ENXSPD,X
;;		STZ	ENYSPD,X
;;		JSR	H0SDCL
;
GOKYRO		EQU	$
		JSR	H0SDCL
;
		LDA	#02H
		STA	ENSTAT,X
;
;;		JSL	>RNDSET
;;		AND	#3FH
;
        	LDA	#0A0H
		STA	ENTIM0,X
		RTS
H0W010		EQU	$
		LDA	ENCONT,X
		AND	#01H
		BNE	HOW011
;
		INC	ENTIM0,X	; long timer !
HOW011		EQU	$
		LDA	ENCBFG,X
		AND	#0FH
		BEQ	H0W018
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
;;		LDA	#0AH
;;		STA	ENTIM1,X	; turn half pause set !
		JSR	H0TUST
H0W018		EQU	$
		LDY	ENMUKI,X
		LDA	H0WXSD,Y
		STA	ENXSPD,X
		LDA	H0WYSD,Y
		STA	ENYSPD,X
		TYA
		STA	ENKBMK,X
;
H0WKPS		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ADC	<WORK0
		TAY
		LDA	H0WKPT,Y
		STA	ENCHPT,X
		RTS
;-----------------------
H0KKBD		EQU	$
		BYTE	0,2,2,2,0,3,3,3
		BYTE	1,3,3,3,1,2,2,2
		BYTE	2,0,0,0,2,1,1,1
		BYTE	3,1,1,1,3,0,0,0
;
H0KYRO		EQU	$
		JSR	H0SDCL
		JSR	H0SERC		; player serch !
;
;-- TEST --
;		LDA	<KEYA2
;		AND	#10000000B
;		BEQ	HTS10
;		LDA	#03H
;		STA	ENSTAT,X
;		LDA	#10H
;		STA	ENTIM0,X
;		STZ	ENCONT,X
;		RTS
;HTS10		EQU	$
;-------------------
		LDA	ENTIM0,X
		BNE	H0K010
;
		LDA	#20H
		STA	ENTIM0,X
		LDA	#00H
		STA	ENSTAT,X		
		RTS
H0K010		EQU	$
;;                LSR	A
		NOP
		LSR	A
		LSR	A
		LSR	A
		AND	#00000111B
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	H0KKBD,Y
		STA	ENKBMK,X
		RTS
;===========================================
H0ATWT		EQU	$
		JSR	H0SDCL
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;
		LDA	ENTIM0,X
		BNE	H0AW10
;
		LDA	#04H
		STA	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
		STZ	HEMODE,X
H0AW10		EQU	$
		RTS
;===========================================
H0ATCK		EQU	$
		LDA	ENTIM0,X
		BNE	H0AT08
;
		BRL	GOKYRO
;;		LDA	#0A0H
;;		STA	ENTIM0,X
;;		LDA	#02H
;;		STA	ENSTAT,X
H0SDCL		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		RTS
;
H0AT08		EQU	$
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	H0AT10
;
		TXA
		AND	#03H
		TAY
;;		LDA	#12H
		LDA	H0SHSD,Y
		JSL	>PSERCHL
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
H0AT10		EQU	$
		INC	ENCONT,X
		JSR	H0WKPS
H0AT50		EQU	$
		RTS
;- - - - -- - -- - --
H0SHSD		EQU	$
		BYTE	0CH,0EH,0EH,10H
;===========================================
;#################################################
H0SHXD		EQU	$
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
		BYTE	0F0H,0F2H,0F4H,0F6H,0F8H,0FAH,0FCH,0FEH
;
		BYTE	000H,002H,004H,006H,008H,00AH,00CH,00EH
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
;
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
		BYTE	00EH,00CH,00AH,008H,006H,004H,002H,000H
;
		BYTE	0FEH,0FCH,0FAH,0F8H,0F6H,0F4H,0F2H,0F0H
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
H0SHYD		EQU	$
		BYTE	000H,002H,004H,006H,008H,00AH,00CH,00EH
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
;
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
		BYTE	00EH,00CH,00AH,008H,006H,004H,002H,000H
;
		BYTE	0FEH,0FCH,0FAH,0F8H,0F6H,0F4H,0F2H,0F0H
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
;
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
		BYTE	0F2H,0F4H,0F6H,0F8H,0FAH,0FCH,0FEH,000H
;===========================================
;#################################################
H0SEDT		EQU	$
		BYTE	10H,30H,00H,20H
;===============================
H0SER2		EQU	$	; walking find
		TXA
		CLC
		ADC	<FRCNT
		STA	<WORKF
		AND	#03H
		ORA	ENDSPL,X
		BNE	H0S010
;
		LDA	<WORKF
		LSR	A
		LSR	A
		AND	#0FH
		LDY	ENMUKI,X
		CLC
		ADC	H0SEDT,Y
		CLC
		ADC	#08H
		AND	#03FH
		STA	<WORKF
		BRA	H0SER00
;=============================
H0SERC		EQU	$	; kyoro kyoro find
		TXA
		CLC
		ADC	<FRCNT
		STA	<WORKF
		AND	#03H
		ORA	ENDSPL,X
		BNE	H0S010
;
		LDA	<WORKF
		LSR	A
		LSR	A
		LDY	ENMUKI,X
		CLC
		AND	#01FH
		ADC	H0SEDT,Y
		AND	#03FH
		STA	<WORKF
;- - - -- - - - - - - - - - - - - - - - - - - -
H0SER00		EQU	$
		LDA	#HEIS0
		JSL	>ENIDSH
		BMI	H0S010
;
                LDA     <WORK0
                STA     ENXPSL,Y
                LDA     <WORK1
                STA     ENXPSH,Y
                LDA     <WORK2
                STA     ENYPSL,Y
                LDA     <WORK3
		STA	ENYPSH,Y
		PHX
		LDX	<WORKF
		LDA	H0SHXD,X
		STA	ENXSPD,Y
		LDA	H0SHYD,X
		STA	ENYSPD,Y
		LDA	ENMOD0,Y
		AND	#11110000B
		ORA	#10100000B
		STA	ENMOD0,Y
		PLX
		TXA
		INC	A
		STA	ENWRK2,Y
		STA	ENNOCR,Y
H0S010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - - - - -
HEIS0CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		JSR	H0HDCS		; head set 
		JSR	H0BDCS		; body set 
		JSR	H0WPCS		; wepon set 
;
;;		LDY	#0FFH
;;		LDA	#06H
;;		JSL	>ALOMCKL
		RTS
;==========================
H0HDCD		EQU	$
		BYTE	042H,042H,040H,044H
H0HDAD		EQU	$
		BYTE	040H,000H,000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - -
H0HDCS		EQU	$
		LDY	#00H
HEHDCS		EQU	$
		PHX
;;		LDA	ENCONT,X
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		NOP
;;		NOP
;;		EOR	#01H
;;		LSR	A
;
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
        	SEC
		SBC	#07H
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	HC0010
		LDA	#00F0H
		STA	(<OAMADR),Y
HC0010		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	H0HDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	H0HDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
		RTS
;=======================================
H0BDXD		EQU	$
		WORD	0FFFCH,004H,00AH,00AH
		WORD	0FFFCH,004H,00AH,00AH
		WORD	0FFFCH,004H,00AH,00AH
		WORD	0FFFCH,004H,00AH,00AH
;
		WORD	0FFFCH,0FFFCH,000H,000H
		WORD	0FFFCH,0FFFCH,000H,000H
		WORD	0FFFDH,0FFFDH,000H,000H
;
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
;
		WORD	00CH,00CH,000H,000H
		WORD	00CH,00CH,000H,000H
		WORD	00BH,00BH,000H,000H
;
		WORD	0FFFCH,004H,000H,000H	; ya
		WORD	0FFFCH,004H,000H,000H	 
		WORD	0FFFCH,004H,000H,000H	 
;
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
;
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFCH,004H,000H,000H
;
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
H0BDYD		EQU	$
		WORD	000H,000H,002H,00AH
		WORD	000H,000H,002H,00AH
		WORD	000H,000H,001H,009H
		WORD	000H,000H,002H,00AH
;
		WORD	0FFFEH,006H,001H,001H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,001H,001H
;
		WORD	0FFFBH,003H,000H,000H
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFBH,003H,000H,000H
;
		WORD	0FFFEH,006H,001H,001H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,001H,001H
;
		WORD	000H,000H,008H,008H	; YA
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
;
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
;
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
;
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
H0BDCD		EQU	$
		BYTE	048H,049H,06DH,07DH
		BYTE	049H,048H,06DH,07DH
		BYTE	046H,046H,06DH,07DH
		BYTE	04BH,046H,06DH,07DH
;
		BYTE	04DH,05DH,04EH,04EH
		BYTE	04DH,05DH,060H,060H
		BYTE	04DH,05DH,062H,062H
;
		BYTE	06DH,07DH,064H,064H
		BYTE	06DH,07DH,066H,067H
		BYTE	06DH,07DH,067H,066H
		BYTE	06DH,07DH,064H,069H
;
		BYTE	04DH,05DH,04EH,04EH
		BYTE	04DH,05DH,060H,060H
		BYTE	04DH,05DH,062H,062H
;
		BYTE	002H,003H,020H,020H
		BYTE	002H,00CH,020H,020H
		BYTE	002H,00CH,020H,020H
;
		BYTE	008H,008H,020H,020H
		BYTE	00EH,00EH,020H,020H
		BYTE	00EH,00EH,020H,020H
;
		BYTE	005H,006H,020H,020H
		BYTE	022H,006H,020H,020H
		BYTE	022H,006H,020H,020H
;
		BYTE	008H,008H,020H,020H
		BYTE	00EH,00EH,020H,020H
		BYTE	00EH,00EH,020H,020H
H0BDAD		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	040H,040H,000H,000H
		BYTE	000H,040H,000H,000H
		BYTE	000H,040H,000H,000H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	000H,000H,000H,040H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,040H,040H
		BYTE	000H,000H,000H,040H
;
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
H0BDSD		EQU	$
		BYTE	002H,002H,000H,000H
		BYTE	002H,002H,000H,000H
		BYTE	002H,002H,000H,000H
		BYTE	002H,002H,000H,000H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
H0BDID		EQU	$
		BYTE	0CH,0CH,0CH,04H
;
H0BDCS		EQU	$
		LDY	ENMUKI,X
		LDA	H0BDID,Y
		TAY
;
HEBDCS		EQU	$
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORK7
;
		LDA	ENMYNO,X
		STA	<WORK8
;
		PHX
		LDX	#03H
H0B010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK7
		TAX
		STX	<WORK6
;
		LDA	<WORK8
		CMP	#HEYA0
		BCC	H0B011		; ya heishi ?
;					; yes !
		LDA	H0BDSD,X
		BEQ     H0B055		; body set  ? (seeld not set )
;
		LDA	H0BDCD,X
		PLX
		PHX
		CPX	#03H
		BNE	H0B011
		CMP	#20H
		BEQ	H0B055		;kusa 1ko dake (only 3)  
H0B011		EQU	$
		LDA	<WORK6		; yes !
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	H0BDXD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	H0BDYD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	BC0010
		LDA	#00F0H
		STA	(<OAMADR),Y
BC0010		EQU	$
		MEM8
		SEP	#00100000B
;
		LDX	<WORK6
		LDA	H0BDCD,X
		INY
		STA	(<OAMADR),Y
		CMP	#20H
		BNE	H0B012	; kusa set ?
;				; yes !
		LDA	<WORK8
		CMP	#HEYA0
		CLC
		BNE	H0B013	; walk heishi ?
;				; yes !
		DEY
		LDA	#0F0H		; kusa clear !
		STA	(<OAMADR),Y
		INY
		BRA	H0B013
H0B012		EQU	$
		LDA	H0BDSD,X
		CMP	#01H
H0B013		EQU	$
		LDA	H0BDAD,X
		ORA	<WORK5
		BCS	H0B020
;
		AND	#11110001B
		ORA	#00000010B	; tate & kusa color !
H0B020		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	H0BDSD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
H0B055		EQU	$
		PLX
		DEX
		BMI	H0B090
		JMP	H0B010
;
H0B090		EQU	$
		PLX
		RTS
;=======================================
H0WPXD		EQU	$
		WORD	0FFFDH,0FFFDH
		WORD	0FFFCH,0FFFCH
		WORD	0FFFCH,0FFFCH
		WORD	0FFFCH,0FFFCH
;
		WORD	0FFF5H,0FFFDH
		WORD	0FFF5H,0FFFDH
		WORD	0FFF0H,0FFF8H
;
		WORD	00CH,00CH
		WORD	00CH,00CH
		WORD	00CH,00CH
		WORD	00CH,00CH
;
		WORD	015H,00DH
		WORD	015H,00DH
		WORD	018H,010H
H0WPYD		EQU	$
		WORD	00BH,00BH+8
		WORD	00BH,00BH+8
		WORD	00AH,00AH+8
		WORD	00EH,00EH+8
;
		WORD	008H,008H
		WORD	008H,008H
		WORD	006H,006H
;
		WORD	0FFF6H,0FFFEH
		WORD	0FFF7H,0FFFFH
		WORD	0FFF7H,0FFFFH
		WORD	0FFF0H,0FFF8H
;
		WORD	008H,008H
		WORD	008H,008H
		WORD	006H,006H
H0WPCD		EQU	$
		BYTE	07BH,06BH
		BYTE	07BH,06BH
		BYTE	07BH,06BH
		BYTE	07BH,06BH
;
		BYTE	06CH,07CH
		BYTE	06CH,07CH
		BYTE	06CH,07CH
;
		BYTE	06BH,07BH
		BYTE	06BH,07BH
		BYTE	06BH,07BH
		BYTE	06BH,07BH
;
		BYTE	06CH,07CH
		BYTE	06CH,07CH
		BYTE	06CH,07CH
H0WPAD		EQU	$
		BYTE	080H,080H
		BYTE	080H,080H
		BYTE	080H,080H
		BYTE	080H,080H
;
		BYTE	000H,000H
		BYTE	000H,000H
		BYTE	000H,000H
;
		BYTE	000H,000H
		BYTE	000H,000H
		BYTE	000H,000H
		BYTE	000H,000H
;
		BYTE	040H,040H
		BYTE	040H,040H
		BYTE	040H,040H
H0WPID		EQU	$
		BYTE	04H,04H,04H,14H
;- - - - - - - - - - - - - - - - - 
H0WPCS		EQU	$
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
;
		LDA	ENMYNO,X
		SEC
		SBC	#HEIS0
		STA	<WORK8
;
		LDY	ENMUKI,X
		LDA	H0WPID,Y
		TAY
;
		PHX
		LDX	#01H
H0WC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	H0WPXD,X
		CLC
		ADC	<WORK0 
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	H0WPYD,X
		CLC
		ADC	<WORK2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	WC0010
;
		LDA	#00F0H
		STA	(<OAMADR),Y
WC0010		EQU	$
		MEM8
		SEP	#00100000B
;
;
		LDA	H0WPXD,X
		STA	ENKNXP
		LDA	H0WPYD,X
		STA	ENKNYP
;
;
		PLX
		LDA	<WORK8
		CMP	#01H
		LDA	H0WPCD,X
		BCS	H0WC12
		ADC	#03H    ;-1
H0WC12		EQU	$
		INY
		STA	(<OAMADR),Y
		LDA	H0WPAD,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	H0WC10
;
		PLX
		RTS
;=======================================
;=======================================
HEIS3M		EQU	$
		JSR	HEIS0CS
;
		JSR	ENSTCK
;
		JSR	ENHNSB
;
		JSL	>ENBGCKL
		JSR	ENMVCL
;
		JSL	>CRKNKNL
		JSL	>CRENPLL
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	H3WK10
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
		STA	ENMUKI,X
;
		TXA
		AND	#03H
		TAY
		LDA	H0SHSD,Y
		JSL	>PSERCHL
H3WK10		EQU	$
		INC	ENCONT,X
		JSR	H0WKPS
		RTS
;
;=====================================================
;=======================================
HEIS2M		EQU	$
		JSR	HEIS2CS
;
		JSR	ENSTCK
;
		JSR	ENHNSB
;
		JSL	>ENBGCKL
		JSR	ENMVCL
;
		JSL	>CRKNKNL
		JSL	>CRENPLL
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	H2WK10
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;H20000		EQU	$
;;= = = = = = = = == = = = = = = = = = = = = = = =
;		LDA	ENSTAT,X
;		MEM16
;		IDX16
;		REP	#00110000B
;		PHY
;		AND	#00FFH
;		ASL	A
;		TAY
;		LDA	H2MVAD,Y
;		PLY
;		DEC	A
;		PHA
;		MEM8
;		IDX8
;		SEP	#00110000B
;		RTS
;;============================================
;H2MVAD		EQU	$
;		WORD	H2WALK
;		WORD	H2ATWT
;		WORD	H2ATCK
;;=====================================================
;H2WALK		EQU	$
;		TXA
;		EOR	<FRCNT
;		AND	#0FH
;		BNE	H2WK10
;
;;;;		JSR	EPXYCK
;;;;		TYA
;		LDA	ENKBMK,X
		STA	ENMUKI,X
;
;;		LDA	#0EH
		TXA
		AND	#03H
		TAY
		LDA	H0SHSD,Y
		JSL	>PSERCHL
H2WK10		EQU	$
;H2WKST		EQU	$
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
;;		LSR	A
		AND	#07H
		ORA	<WORK0
		TAY
		LDA	TKWKPT,Y
		STA	ENCHPT,X
		RTS
;=====================================================
;=======================================
HEIS2CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	#04H+08H
		JSR	TKHDC2		; head set 
		LDY	#00H+08H
		JSR	TKBDC2		; body set 
		JSR	H2WPCS		; wepon set 
;
;;		LDY	#0FFH
;;		LDA	#05H
;;		JSL	>ALOMCKL
		RTS
;=======================================
H2WXAD		EQU	$
		WORD	010H,008H
		WORD	014H,00CH
;
		WORD	0FFF8H,000H
		WORD	0FFF4H,0FFFCH
;
		WORD	00DH,00DH
		WORD	00DH,00DH
;
		WORD	0FFFCH,0FFFCH
		WORD	0FFFCH,0FFFCH
H2WYAD		EQU	$
		WORD	0FFFEH,0FFFEH
		WORD	0FFFEH,0FFFEH
;
		WORD	0FFFEH,0FFFEH
		WORD	0FFFEH,0FFFEH
;
		WORD	008H,000H
		WORD	00CH,004H
;
		WORD	0FFF2H,0FFFAH
		WORD	0FFEEH,0FFF6H
H2WCDT		EQU	$
		BYTE	06FH,07FH
		BYTE	06FH,07FH
;
		BYTE	06FH,07FH
		BYTE	06FH,07FH
;
		BYTE	06EH,07EH
		BYTE	06EH,07EH
;
		BYTE	06EH,07EH
		BYTE	06EH,07EH
H2WADT		EQU	$
		BYTE	040H,040H
		BYTE	040H,040H
;
		BYTE	000H,000H
		BYTE	000H,000H
;
		BYTE	080H,080H
		BYTE	080H,080H
;
		BYTE	000H,000H
		BYTE	000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Y2WPCS		EQU	$
		LDA	ENCONT,X
		LSR	A
		LSR	A
		BRA	H2W012
;-  -  -  -  -  -  -  -  -  -  -  -  -  
H2WPCS		EQU	$
		LDA	ENCONT,X
H2W012		EQU	$
		LSR	A
		AND	#02H
		STA	<WORK6
;
		LDA	ENMYNO,X
		STA	<WORK8
;
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ORA	<WORK6
		STA	<WORK6
;
		PHX
		LDX	#01H
		LDY	#00H
H2WC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	H2WXAD,X
		CLC
		ADC	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	H2WYAD,X
		CLC
		ADC	<WORK2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	H2WC12
		LDA	#00F0H
		STA	(<OAMADR),Y
H2WC12		EQU	$
		MEM8
		SEP	#00100000B
		PLX
;
		LDA	H2WXAD,X
		STA	ENKNXP
		LDA	H2WYAD,X
		STA	ENKNYP
;
;
		LDA	<WORK8
		CMP	#HEYA2
		LDA	H2WCDT,X
		BCC	H2WC11
		SBC	#03H
H2WC11		EQU	$
		INY
		STA	(<OAMADR),Y
		LDA	H2WADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PLX
		PHY
		TXY
;;		LDA	#00H
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	H2WC10
		PLX
		RTS
;=======================================
;=======================================
Y2TURN		EQU	$
		BYTE	0CH,00H,12H,08H
;=======================================
HEYA2M		EQU	$
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	HY2001
		LDA	H0TURN,Y
		STA	ENMUKI,X
		LDA	Y2TURN,Y
		STA	ENCHPT,X
HY2001		EQU	$
		JSR	HEYA2CS
		BRA	HYM010
;=======================================
HEYA0M		EQU	$
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	HY0001
		LDA	H0TURN,Y
		STA	ENMUKI,X
		LDA	H0TUR2,Y
		STA	ENCHPT,X
HY0001		EQU	$
		JSR	HEYA0CS
HYM010		EQU	$
		PLA
		STA	ENMUKI,X
;
		JSR	ENSTCK
;
		LDA	ENHNFG,X
		BEQ	HY0000
;
		JSR	HYGOAT
HY0000		EQU	$
		JSR	ENHNSB
;
		JSL	>ENBGCKL
		JSR	ENMVCL
;
		JSL	>CRKNENL
		JSL	>CRENPLL
;
;		LDA	ENHNFG,X
;		BNE	HY0RTS		; yarare -> fury !
;
;;              LDA	ENSTAT,X
;;		JSL	>JSRSUB
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	HYMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
HYMVAD		EQU	$
		WORD	HY0WWT	;0
		WORD	HY0WLK  ;1
		WORD	HY0KYR  ;2
		WORD	HY0ATW	;3
		WORD	HY0ATC	;4
		WORD	HY0YAA	;5
;- - - - - - - - - - - - - - - - - - - - - - -
;HY0RTS		EQU	$		; fury !!
;		JMP	HYGOAT
;- - - - - - - - - - - - - - - - - -
HY0WWT		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	Y0WT10
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#07FH
;
        	ADC	#050H
		STA	ENTIM0,X
;
		LDA	ENMUKI,X
		PHA
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X
		PLA
		CMP	ENMUKI,X
		BEQ	Y0WT10
		EOR	ENMUKI,X
		AND	#00000010B
		BNE	Y0WT10
;
		LDA	#0CH
		STA	ENTIM1,X	; turn half pause set !
Y0WT10		EQU	$
		RTS
;---------------------------------
;
HY0WLK		EQU	$
		LDA	ENTIM0,X
		BNE	Y0W010
;
		LDA	#02H
		STA	ENSTAT,X
;
        	LDA	#0A0H
		STA	ENTIM0,X
		RTS
Y0W010		EQU	$
		JSR	H0SER2
;
		LDA	ENCBFG,X
		AND	#0FH
		BEQ	Y0W018
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
;;		LDA	#0AH
;;		STA	ENTIM1,X	; turn half pause set !
		JSR	H0TUST
Y0W018		EQU	$
		LDY	ENMUKI,X
		LDA	H0WXSD,Y
		STA	ENXSPD,X
		LDA	H0WYSD,Y
		STA	ENYSPD,X
		TYA
		STA	ENKBMK,X
;- - - - - - - - - - - - - - - - - - - - - 
Y0WKPS		EQU	$
                INC     ENCONT,X
                LDA     ENCONT,X
                AND     #07H
                BNE     Y0W020
                INC     ENWRK0,X
                LDA     ENWRK0,X
                CMP     #03H
                BNE     Y0W020
                STZ     ENWRK0,X
Y0W020          EQU     $
                LDA     ENMUKI,X
                ASL     A
                ASL     A
                ADC     ENWRK0,X
		LDY	ENMYNO,X
		CPY	#HEYA2
		BNE	Y0W030
		CLC
		ADC	#YWP0-YWP1
Y0W030		EQU	$
                TAY
                LDA     Y0WKPT,Y
                STA     ENCHPT,X
                RTS             
;---------------------------------------------------------------
HY0KYR		EQU	$
		JSR	H0SDCL
		JSR	H0SERC
;
		LDA	ENTIM0,X
		BNE	Y0K010
;
		LDA	#20H
		STA	ENTIM0,X
		LDA	#00H
		STA	ENSTAT,X		
		RTS
Y0K010		EQU	$
;;                LSR	A
		NOP
		LSR	A
		LSR	A
		LSR	A
		AND	#00000111B
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	H0KKBD,Y
		STA	ENKBMK,X
		RTS
;===========================================
HY0ATW		EQU	$
		JSR	H0SDCL
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;
		LDA	ENTIM0,X
		BNE	Y0AW10
;
HYGOAT		EQU	$
		LDA	#04H
		STA	ENSTAT,X
		LDA	#083H
		STA	ENTIM0,X
		STZ	ENCONT,X
Y0AW10		EQU	$
		RTS
;===========================================
Y0SHXL		EQU	$
		BYTE	0B0H,050H,000H,0F8H
		BYTE	0B0H,050H,000H,008H
Y0SHXH		EQU	$
		BYTE	0FFH,000H,000H,0FFH
		BYTE	0FFH,000H,000H,000H
Y0SHYL		EQU	$
		BYTE	008H,008H,0B0H,050H
		BYTE	008H,008H,0B0H,050H
Y0SHYH		EQU	$
		BYTE	000H,000H,0FFH,000H
		BYTE	000H,000H,0FFH,000H
;- - - - - - - - - -
ATCKMK		EQU	$
		BYTE	00000011B
		BYTE	00000011B
		BYTE	00001100B
		BYTE	00001100B
;- - - - -
HY0ATC		EQU	$
		LDY	ENMUKI,X
		LDA	ENCBFG,X
		AND	ATCKMK,Y
		BNE	GOYAAA
;
		LDA	ENTIM0,X
		BNE	Y0AT08
;
GOYAAA		EQU	$
		INC	ENSTAT,X
		LDA	#60H
		STA	ENTIM0,X
		RTS
;;		JMP	GOKYRO
;
Y0AT08		EQU	$
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	Y0AT10
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
;		
		LDA	ENMYNO,X
		CMP	#HEYA2
		BNE	Y0AT09
		INY
		INY
		INY
		INY
Y0AT09		EQU	$
		LDA	<PLXPS1
		CLC
		ADC	Y0SHXL,Y
		STA	<WORK4
		LDA	<PLXPS0
		ADC	Y0SHXH,Y
		STA	<WORK5
		LDA	<PLYPS1
		CLC
		ADC	Y0SHYL,Y
		STA	<WORK6
		LDA	<PLYPS0
		ADC	Y0SHYH,Y
		STA	<WORK7
;
		LDA	#10H
		JSL	>ESERCHL
;
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		LDA	<WORKE
		CLC
		ADC	#04H
		CMP	#08H
		BCS	Y0AT10
		LDA	<WORKF
		CLC
		ADC	#04H
		CMP	#08H
		BCC	GOYAAA
;
Y0AT10		EQU	$
		INC	ENCONT,X
		JSR	Y0WKPS
Y0AT50		EQU	$
		RTS
;=========================================================
HYYPTD		EQU	$
Y2PT0		EQU	$
		BYTE	19H,19H,18H,18H,17H,17H,17H,17H
		BYTE	13H,13H,12H,12H,11H,11H,11H,11H
		BYTE	10H,10H,0FH,0FH,0EH,0EH,0EH,0EH
		BYTE	16H,16H,15H,15H,14H,14H,14H,14H
Y2PT1		EQU	$
		BYTE	14H,14H,12H,12H,12H,10H,10H,10H
		BYTE	15H,15H,08H,08H,08H,06H,06H,06H
		BYTE	16H,16H,04H,04H,04H,03H,03H,03H
		BYTE	17H,17H,0FH,0FH,0FH,0BH,0BH,0BH
;
HY0YAA		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	HYY010
;
		JMP	GOKYRO
HYY010		EQU	$
		STZ	ENCONT,X	; for ya no ichi !
		CMP	#050H
		BCC	HYY018
		DEC	ENCONT,X
HYY018		EQU	$
		CMP	#20H
		BNE	HYY020
		PHA
;
		JSR	HYAASET
		PLA
HYY020		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		LDY	ENMYNO,X
		CPY	#HEYA2
		BNE	HYY030
		CLC
		ADC	#Y2PT1-Y2PT0
HYY030		EQU	$
		TAY
		LDA	HYYPTD,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - -- - - - - -- -
HYSXAL		EQU	$
		BYTE	008H,0F8H,003H,00BH
		BYTE	00CH,0FCH,00CH,0FCH
HYSXAH		EQU	$
		BYTE	000H,0FFH,000H,000H
		BYTE	000H,0FFH,000H,0FFH
HYSYAL		EQU	$
		BYTE	002H,002H,008H,0F8H
		BYTE	0FEH,0FEH,002H,0F8H
HYSYAH		EQU	$
		BYTE	000H,000H,000H,0FFH
		BYTE	0FFH,0FFH,000H,0FFH
HYSXSD		EQU	$
		BYTE	020H,0E0H,000H,000H
		BYTE	020H,0E0H,000H,000H
HYSYSD		EQU	$
		BYTE	000H,000H,020H,0E0H
		BYTE	000H,000H,020H,0E0H
HYSMKD		EQU	$
		BYTE	3,2,1,0
		BYTE	3,2,1,0
;
YACRDT		EQU	$		; OBJ hit size
		BYTE	6,6,5,5
;
HYAASET		EQU	$
		LDA	#YATAM
		JSL	>ENIDSH
		BMI	HYS010
		PHX
		LDA	ENMYNO,X
		CMP	#HEYA2
		LDA	ENMUKI,X
		BCC	HYS030
		CLC
		ADC	#04H
HYS030		EQU	$
		TAX
		LDA	<WORK0
		CLC
		ADC	HYSXAL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	HYSXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	HYSYAL,X
		STA	ENYPSL,Y
		LDA	<WORK3	
		ADC	HYSYAH,X
		STA	ENYPSH,Y
;
		LDA	HYSXSD,X
		STA	ENXSPD,Y
		LDA	HYSYSD,X
		STA	ENYSPD,Y
		LDA	HYSMKD,X
		STA	ENMUKI,Y
		TAX
		LDA	ENMOD3,Y
		AND	#0F0H
		ORA	YACRDT,X
		STA	ENMOD3,Y
		PLX
		LDA	ENMYNO,X
		CMP	#HEYA2
		LDA	#01H
		BCC	HYS00E
		INC	A
HYS00E		EQU	$
		STA	ENWRK0,Y
HYS010		EQU	$
		RTS
;===============================================
HEYA2CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	#04H+08H
		JSR	TKHDC2		; head set 
		LDY	#00H+08H
		JSR	TKBDC2		; body set 
		LDA	ENCHPT,X
		CMP	#14H
		BCS	Y2C098		; yari with ?
;					; yes !
		JSR	Y2WPCS		; wepon set 
Y2C098		EQU	$
;
;;		LDY	#0FFH
;;		LDA	#05H
;;		JSL	>ALOMCKL
		RTS
;=========================================================
HEYA1M		EQU	$
		LDA	ENSTAT,X
		BEQ	HY1020
;
		LDA	ENCHPT,X
		CMP	#0EH
		BCC	HY1010
		JSR	HEYA1CS
		BRA	HY1020
HY1010		EQU	$
		JSR	HEYA1C2		; gasa gasa set !
HY1020		EQU	$
		JSR	ENSTCK
;
		JSL	>CRKNENL
		JSL	>CRENPLL
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	H1MVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
H1MVAD		EQU	$
		WORD	Y1WAIT	;0
		WORD	Y1SET   ;1
		WORD	Y1YAAA	;2
		WORD	Y1END	;3
;===========================================
Y1WAIT		EQU	$
		LDA	ENTIM0,X
		BNE	Y1W010
;
		INC	ENSTAT,X
		LDA	#80H
		STA	ENTIM0,X
Y1W010		EQU	$
		RTS
;===========================================
Y1STPT		EQU	$
		BYTE	5,5,5,4,6,6,6,4
		BYTE	4,3,2,1,0,1,0,1
		BYTE	0,1,0,1,0,1,0,1
		BYTE	0,1,0,1,0,1,0,1
;
Y1SET		EQU	$
		LDA	ENTIM0,X
		BNE	Y1ST10
;
		INC	ENSTAT,X
;
		LDA	#60H
		STA	ENTIM0,X
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
		RTS
Y1ST10		EQU	$
		CMP	#060H
		BNE	Y1ST20
		PHA
		JSR	Y1KUSA		; Parapara set !
		PLA
Y1ST20		EQU	$
		LSR	A
		LSR	A
		LSR	A
		NOP
		NOP
		TAY
		LDA	Y1STPT,Y
		STA	ENCHPT,X
		RTS	
;- - -- - - - -
Y1KUSA		EQU	$
		LDA	#KTOBJ
		JSL	>ENIDSH
		BMI	Y1KS10
;
		LDA	<WORK0
		STA	ENXPSL,Y
		LDA	<WORK1
		STA	ENXPSH,Y
		LDA	<WORK2
		STA	ENYPSL,Y
		LDA	<WORK3
		STA	ENYPSH,Y
		LDA	#EFAIL
		STA	ENMODE,Y
		LDA	#20H
		STA	ENTIM0,Y
;
		LDA	ENMOD0,Y
		CLC
		ADC	#03H
		STA	ENMOD0,Y
;
		LDA	#02H
		STA	ENWRK2,Y	; kusa !
Y1KS10		EQU	$
		RTS		
;===========================================
Y1YAAA		EQU	$
		LDA	ENTIM0,X
		BNE	Y1Y010
;
		INC	ENSTAT,X
		LDA	#80H
		STA	ENTIM0,X
		RTS
Y1Y010		EQU	$
		CMP	#020H
		BNE	Y1Y020
		PHA
;
		JSR	HYAASET
		PLA
Y1Y020		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	HYYPTD,Y
		STA	ENCHPT,X
		RTS
;===========================================
Y1EPTD		EQU	$
		BYTE	0,1,0,1,0,1,0,1
		BYTE	0,1,0,1,0,2,3,4
;
Y1END		EQU	$
		LDA	ENTIM0,X
		BNE	Y1E010
		STZ	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
		RTS
Y1E010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	Y1EPTD,Y
		STA	ENCHPT,X
		RTS
;===========================================
Y12CYD		EQU	$
		WORD	000H+08H,000H+08H	;0
		WORD	000H+08H,000H+08H	;1
		WORD	0FFFAH+08H,000H+08H	;2
		WORD	0FFF8H+08H,000H+08H	;3
		WORD	0FFF5H+08H,000H+08H	;4
		WORD	0FFF5H+08H,000H+08H	;5
		WORD	0FFF5H+08H,000H+08H	;6
Y12CCD		EQU	$
		BYTE	020H,020H
		BYTE	020H,020H
		BYTE	040H,020H
		BYTE	040H,020H
		BYTE	040H,020H
		BYTE	042H,020H
		BYTE	042H,020H
Y12CAD		EQU	$
		BYTE	009H,003H
		BYTE	049H,043H
		BYTE	009H,003H
		BYTE	049H,043H
		BYTE	009H,003H
		BYTE	049H,043H
		BYTE	009H,003H
HEYA1C2		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
;
		PHX
		LDX	#01H
HY1C10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	Y12CYD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	HY2C12
;
		LDA	#00F0H
		STA	(<OAMADR),Y
HY2C12		EQU	$
		MEM8
		SEP	#00100000B
;
		PLX
		LDA	Y12CCD,X
		INY
		STA	(<OAMADR),Y
		LDA	Y12CAD,X
		ORA	#20H
		PLX
		BNE	HY1C20
		AND	#11110001B
		ORA	<WORK5
HY1C20		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	HY1C10
		PLX
;
;;		LDY	#02H
;;		LDA	#01H
;;		JSL	>ALOMCKL
		RTS
;
;
;
;
;===========================================
HYHDID		EQU	$
		BYTE	10H,10H,10H,00H
HYBDID		EQU	$
		BYTE	14H,14H,14H,04H
HYWPID		EQU	$
		BYTE	00H,00H,00H,10H
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HEYA0CS		EQU	$
HEYA1CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	ENMUKI,X
		LDA	HYHDID,Y
		TAY
		JSR	HEHDCS		; head set 
		LDY	ENMUKI,X
		LDA	HYBDID,Y
		TAY
		JSR	HEBDCS		; body set 
		LDY	ENMUKI,X
		LDA	HYWPID,Y
		TAY
		JSR	HYWPCS		; wepon set 
;
;;		LDY	#0FFH
;;		LDA	#07H
;;		JSL	>ALOMCKL
		RTS
;-------------
HYWXAD		EQU	$
		WORD	0FFFFH,007H,003H,003H
		WORD	0FFFFH,007H,003H,003H
		WORD	0FFFFH,007H,007H,007H
;
		WORD	0FFFBH,0FFFBH,0FFF6H,0FFFEH
		WORD	0FFFCH,0FFFCH,0FFFAH,002H
		WORD	0FFFBH,0FFFBH,0FFFBH,0FFFBH
;
		WORD	006H,00EH,00BH,00BH
		WORD	006H,00EH,00BH,00BH
		WORD	006H,00EH,00EH,00EH
;
		WORD	00BH,00BH,012H,00AH
		WORD	00CH,00CH,00EH,006H
		WORD	00BH,00BH,00BH,00BH
HYWYAD		EQU	$
		WORD	007H,007H,003H,00BH
		WORD	006H,006H,001H,009H
		WORD	007H,007H,007H,007H
;
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,006H,006H
;
		WORD	0FFFAH,0FFFAH,0FFF4H,0FFFCH
		WORD	0FFFBH,0FFFBH,0FFF6H,0FFFEH
		WORD	0FFFAH,0FFFAH,0FFFAH,0FFFAH
;
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,006H,006H
HYWCDT		EQU	$
		BYTE	00AH,00AH,02AH,02BH
		BYTE	01AH,01AH,02AH,02BH
		BYTE	00AH,00AH,00AH,00AH
;
		BYTE	00BH,00BH,03DH,03AH
		BYTE	01BH,01BH,03DH,03AH
		BYTE	00BH,00BH,00BH,00BH
;
		BYTE	00AH,00AH,02BH,02AH
		BYTE	00AH,00AH,02BH,02AH
		BYTE	00AH,00AH,00AH,00AH
;
		BYTE	00BH,00BH,03DH,03AH
		BYTE	01BH,01BH,03DH,03AH
		BYTE	00BH,00BH,00BH,00BH
HYWADT		EQU	$
		BYTE	007H,047H,008H,008H
		BYTE	007H,047H,008H,008H
		BYTE	007H,047H,047H,047H
;
		BYTE	007H,087H,048H,048H
		BYTE	007H,087H,048H,048H
		BYTE	007H,087H,087H,087H
;
		BYTE	087H,0C7H,088H,088H
		BYTE	087H,0C7H,088H,088H
		BYTE	087H,0C7H,0C7H,0C7H
;
		BYTE	047H,0C7H,008H,008H
		BYTE	047H,0C7H,008H,008H
		BYTE	047H,0C7H,0C7H,0C7H
;-----------------------------------------------------------
HYWMKD		EQU	$
		BYTE	17H-0EH,11H-0EH,0EH-0EH,14H-0EH
;
HYWPCS		EQU	$
		LDA	ENCHPT,X
		SEC
		SBC	#0EH
		BCS	HWC010
;
		PHY
		LDY	ENMUKI,X
		LDA	HYWMKD,Y
		PLY
HWC010		EQU	$
		ASL	A
		ASL	A
		STA	<WORK6
;
		PHX
		LDX	#03H
HYW010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	HYWXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	HYWYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	HYW012
;
		LDA	#00F0H
		STA	(<OAMADR),Y
HYW012		EQU	$
		MEM8
		SEP	#00100000B
		PLX
;
		LDA	HYWCDT,X
		INY
		STA	(<OAMADR),Y
;;        	CMP	#20H
        	LDA	HYWADT,X
		ORA	#00100000B
;;		BCS	HWC020
;;		ORA	#01H
;;HWC020		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	HYW010
;
		PLX
		RTS
;====================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Barikade knight                        		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BARI0MV  	EQU	$
		PHB
		PHK
		PLB
		JSR	BR00
		PLB
		RTL
;======================================
BRMKDT		EQU	$
		BYTE	2,1,0,3
;
BR00		EQU	$
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	BRM001
		LDA	H0TURN,Y
		STA	ENMUKI,X
BRM001		EQU	$
		LDY	ENMUKI,X
		LDA	BRMKDT,Y
		STA	ENCHPT,X
		JSR	BARI0CS
		PLA
		STA	ENMUKI,X
;
		JSR	ENSTCK
;
		JSL	>MSGCHK
;
		JSL	>CRKNENL
;;		JSL	>CRKNKNL
		JSL	>CRENPLL
;
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	BRM010
;
		JSR	PMSET		; muki -> player 
BRM010		EQU	$
		RTS
;================================
BRCXAD		EQU	$	
		WORD	004H,000H,0FFFAH,0FFFAH,0FFFAH+8
		WORD	000H,000H,0FFF9H,0FFF9H,0FFF9H
		WORD	000H,000H,00FH,00FH,00FH
		WORD	006H,006H+8,0FFFCH,004H,000H
BRCYAD		EQU	$
		WORD	000H,0FFF6H,0FFFCH,00CH,00CH
		WORD	000H,0FFF7H,0FFF5H,0FFF5H+8,0FFF5H+10H
		WORD	000H,0FFF7H,0FFF5H,0FFF5H+8,0FFF5H+10H
		WORD	0FFF5H,0FFF5H+10H,000H,000H,0FFF7H
BRCCDT		EQU	$
		BYTE	046H,040H,000H,028H,029H
		BYTE	04EH,042H,039H,02AH,03AH
		BYTE	04EH,042H,039H,02AH,03AH
		BYTE	026H,038H,064H,064H,044H
BRCADT		EQU	$
		BYTE	040H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	040H,040H,040H,040H,040H
		BYTE	000H,040H,000H,040H,000H
BRCSBD		EQU	$
		BYTE	002H,002H,002H,000H,000H
		BYTE	002H,002H,000H,000H,000H
		BYTE	002H,002H,000H,000H,000H
		BYTE	002H,000H,002H,002H,002H
BARI0CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
		PHX
		LDX	#04H
BRC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	BRCXAD,X
		CLC
		ADC	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	BRCYAD,X
		CLC
		ADC	<WORK2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	BRC012
;
		LDA	#00F0H
		STA	(<OAMADR),Y
BRC012		EQU	$
		MEM8
		SEP	#00100000B
		PLX
;
		LDA	BRCCDT,X
		INY
		STA	(<OAMADR),Y
		CMP	#40H
		LDA	BRCADT,X
		ORA	<WORK5
		BCS	BRC020
;
;;		PHA
;;		LDA	BRCXAD,X
;;		STA	ENKNXP
;;		LDA	BRCYAD,X
;;		STA	ENKNYP
;;;
;;		PLA
		AND	#11110001B
		ORA	#00000110B
BRC020		EQU	$
		INY		
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	BRCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	BRC010
		PLX
;;		LDY	#0FFH
;;		LDA	#04H
;;		JSL	>ALOMCKL
		RTS
;=============================================================
BRSDXL		EQU	$
		BYTE	00CH,0F8H,0F8H,008H
BRSDXH		EQU	$
		BYTE	000H,0FFH,0FFH,000H
BRSDXA		EQU	$
		BYTE	00CH,00CH,010H,010H
BRSDYL		EQU	$
		BYTE	0F8H,0F8H,0FEH,0F8H
BRSDYH		EQU	$
		BYTE	0FFH,0FFH,0FFH,0FFH
BRSDYA		EQU	$
		BYTE	018H,018H,018H,018H
;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
BRSDRS		EQU	$
		PHB
		PHK
		PLB
;
		LDY	ENMUKI,X
;
		LDA	ENXPSL,X
		CLC
		ADC	BRSDXL,Y
		STA	<WORK4
		LDA	ENXPSH,X
		ADC	BRSDXH,Y
		STA	<WORKA
;
		LDA	ENYPSL,X
		CLC
		ADC	BRSDYL,Y
		STA	<WORK5
		LDA	ENYPSH,X
		ADC	BRSDYH,Y
		STA	<WORKB
;
		LDA	BRSDXA,Y
		STA	<WORK6
		LDA	BRSDYA,Y
		STA	<WORK7
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Only pull swich                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ESW02MV		EQU	$
		PHB
		PHK
		PLB
		LDA	ENMYNO,X
		CMP	#ESW03
		BNE	ESWFFF
;
		JSR	ES3000
		PLB
		RTL
;- - - - - - - - - - - - - -  - - -
ESWFFF		EQU	$
		JSR	ES2000
		PLB
		RTL
;======================================
ES3000		EQU	$
		JSR	CRS3PL
;
		LDY	ENCHPT,X
		BEQ	S30010
		CPY	#0BH
		BEQ	S30020
;
		LDA	S3PLPT-1,Y
		STA	HIKUFG
		LDA	ENYPSL,X
		SEC
		SBC	#10H
;;		SBC	S3PLYL-1,Y
		STA	<PLYPS1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<PLYPS0
;
;;;;;;		JSR	S3PLDW		; player pos revise !
;
		LDA	ENXPSL,X
		STA	<PLXPS1
		LDA	ENXPSH,X
		STA	<PLXPS0
;
		LDA	ENTIM0,X
		BNE	S30010
;
		INC	ENCHPT,X
		LDY	ENCHPT,X
		CPY	#0BH
		BNE	S30018
;
		STZ	HIKUFG
;
                LDA     #01H
                STA     SWCHFG
S30018		EQU	$
		LDA	S3TIME-2,Y
		STA	ENTIM0,X
		BRA	S30010
;
S30020		EQU	$
;;		STZ	HIKUFG
S30010		EQU	$
		JSR	ESW03CS
		RTS
;-  - - - - -
S3TIME		EQU	$
		BYTE	8,18H,4,4,4,4,4,4,2,0AH
;;		BYTE	006H,006H,008H,006H,006H,008H,008H,30H                 
S3PLPT		EQU	$
		BYTE	6,7,8,8,8,8,8,9,9,9
;;		BYTE    8,9,7,6,9,7,6,0AH,0BH              
;;S3PLYL		EQU	$
;;		BYTE	10H,10H,10H,10H,10H,10H                                   
;=======================================
;---------------------------------------------------
CRS3PL		EQU	$
		JSL	>CRENPL2L
		BCC	CRS310
;
		STZ	<PLYSPD
		STZ	<PLXSPD
		STZ	DASHFG
;
		LDA	PLYPS1
		SEC
		SBC	ENYPSL,X
		CMP	#002H
		BPL	CRS3DW
		CMP	#0F2H
		BMI	CRS3UP
		LDA	PLXPS1
		CMP	ENXPSL,X
		BPL	CRS3RG
CRS3LF		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<PLXPS1
		LDA	ENXPSH,X
		SBC	#00H
		STA	<PLXPS0
;
		RTS
;
CRS3RG		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#0EH
		STA	<PLXPS1
		LDA	ENXPSH,X
		ADC	#00H
		STA	<PLXPS0
;
CRS310		EQU	$
		RTS
;
CRS3UP		EQU	$
		INC	KINSHI		; Not "X" key check !
;
		STZ	HIKUFG
;
		LDA	<KEYA1L
		AND	#10000000B
		BEQ	CRS3RT
;
		STZ	HIKUFG
;
		LDA	<KEYA1
		AND	#00000011B
		BNE	CRS3RT		; side move ?
;					; no
		LDA	ENCHPT,X
		BNE	CRS3RT		; move start !
;
		INC	ENCHPT,X
		LDA	#08H
		STA	ENTIM0,X
;
CRS3RT		EQU	$
		LDA	ENYPSL,X
		SEC
		SBC	#15H
		STA	<PLYPS1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<PLYPS0
		RTS
CRS3DW		EQU	$
S3PLDW		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	#09H
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		STA	<PLYPS0
;
		RTS
;========================
E3CXAD		EQU	$
		BYTE	0FCH,00CH,000H,0FCH,004H,004H
E3CYAD		EQU	$
		BYTE	0FDH,0FDH,000H,005H,005H,005H
E3CCDT		EQU	$
		BYTE	012H+0C0H,012H+0C0H,004H+0C0H,024H+0C0H,024H+0C0H,024H+0C0H
E3CADT		EQU	$
		BYTE	040H,000H,000H,040H,000H,000H
E3CSBD		EQU	$
		BYTE	000H,000H,002H,002H,002H,002H
E3CYRV		EQU	$
		BYTE	0,1,2,3,4,5,5
E3CHPT		EQU	$
		BYTE	0,0,1,1,2,2,3,3,4,5,5,5
;;		BYTE	0,0,1,1,2,2,3,3,4,5,5
;
ESW03CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		JSL	>OCHECKL
;
		LDY	ENCHPT,X
		LDA	E3CHPT,Y
		TAY
		LDA	E3CYRV,Y
		STA	<WORK6
;
		PHX
		LDX	#04H
		LDY	#00H
E3C010		EQU	$
		LDA	<WORK0
		CLC
		ADC	E3CXAD,X
		STA	(<OAMADR),Y
;
		LDA	<WORK2
		CLC
		ADC	E3CYAD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	E3CCDT,X
		INY
		STA	(<OAMADR),Y
;
		LDA	E3CADT,X
		ORA	#21H
		INY
		STA	(<OAMADR),Y
		PHY
		CPX	#02H
		BNE	E3C020
;
		DEY
		DEY
		LDA	(<OAMADR),Y
		SEC
		SBC	<WORK6
		STA	(<OAMADR),Y
E3C020		EQU	$
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	E3CSBD,X
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	E3C010
;
		PLX
		LDY	#0FFH
		LDA	#04H
		JSL	>ALOMCKL
		RTS
;======================================
ES2000		EQU	$
		JSR	CRS2PL
;
		LDY	ENCHPT,X
		BEQ	S20010
		CPY	#0DH
		BEQ	S20020
;
		LDA	S2PLPT-1,Y
		STA	HIKUFG
		LDA	ENYPSL,X
		CLC
		ADC	S2PLYL-1,Y
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		STA	<PLYPS0
;
;;		JSR	S2PLDW		; player pos revise !
;
		LDA	ENXPSL,X
		STA	<PLXPS1
		LDA	ENXPSH,X
		STA	<PLXPS0
;
		LDA	ENTIM0,X
		BNE	S20010
;
		INC	ENCHPT,X
		LDY	ENCHPT,X
		CPY	#0DH
		BNE	S20018
;
                LDA     #01H
                STA     SWCHFG
;
		STZ	HIKUFG		
S20018		EQU	$
		LDA	S2TIME-2,Y
		STA	ENTIM0,X
		BRA	S20010
;
S20020		EQU	$
;;		STZ	HIKUFG
S20010		EQU	$
		JSR	ESW02CS
		RTS
;-  - - - - -
S2TIME		EQU	$
;;		BYTE	10H,0CH,10H,08H,08H,04H,04H,04H,04H,12H
		BYTE	5,5,5,5,5,5,5,5,5,5,5,5
S2PLPT		EQU	$
;;		BYTE	2,3,2,3,2,3,4,5,5,5,5,1
		BYTE	1,1,2,2,3,3,1,1,4,4,5,5
S2PLYL		EQU	$
;;;		BYTE	09H,09H,09H,09H,09H,09H,09H,09H+8,09H+8,09H+8,09H+8,09H+8
		BYTE	9,9,10,10,11,11,12,12,13,13,14,14
;========================================
ES2YDT		EQU	$
;;		BYTE	03H,04H,05H,06H,07H,08H,08H
		BYTE	1,1,2,3,2,3,4,5,6,7,6,7,7,7
;
ESW02CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
		JSL	>OCHECKL
;
		LDY	ENCHPT,X
		LDA	ES2YDT,Y
		STA	<WORK6
;
		LDY	#04H
		LDA	<WORK0
		STA	(<OAMADR),Y
		LDY	#00H
		STA	(<OAMADR),Y
		LDA	<WORK2
		DEC	A
		LDY	#01H
		STA	(<OAMADR),Y
		CLC
		ADC	<WORK6
		LDY	#05H
		STA	(<OAMADR),Y
		LDA	#0EH+0C0H
		LDY	#06H
		STA	(<OAMADR),Y
		LDA	#2EH+0C0H
		LDY	#02H
		STA	(<OAMADR),Y
		LDA	#21H
		LDY	#03H
		STA	(<OAMADR),Y
		LDY	#07H
		STA	(<OAMADR),Y
;
		LDY	#02H
		LDA	#01H
		JSL	>ALOMCKL
		RTS
;---------------------------------------------------
CRS2PL		EQU	$
		JSL	>CRENPL2L
		BCC	CRSL10
;
		STZ	<PLYSPD
		STZ	<PLXSPD
		STZ	DASHFG
;
		LDA	PLYPS1
		SEC
		SBC	ENYPSL,X
		CMP	#002H
		BPL	CRSWDW
		CMP	#0F2H
		BMI	CRSWUP
		LDA	PLXPS1
		CMP	ENXPSL,X
		BPL	CRSWRG
CRSWLF		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<PLXPS1
		LDA	ENXPSH,X
		SBC	#00H
		STA	<PLXPS0
;
CRSL10		EQU	$
		RTS
;
CRSWRG		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#0EH
		STA	<PLXPS1
		LDA	ENXPSH,X
		ADC	#00H
		STA	<PLXPS0
;
CRSR10		EQU	$
		RTS
;
CRSWUP		EQU	$
		LDA	ENYPSL,X
		SEC
		SBC	#15H
		STA	<PLYPS1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<PLYPS0
		RTS
CRSWDW		EQU	$
		INC	KINSHI		; Not "X" key check !
;
		STZ	HIKUFG
;
		LDA	<KEYA1L
		AND	#10000000B
		BEQ	CRSWRT
;
		STZ	HIKUFG
;
		LDA	<KEYA1
		AND	#00000011B
		BNE	CRSWRT		; side move ?
;					; no
;;;		LDA	#01H
		INC	HIKUFG		; Kamae set !
;
		LDA	<KEYA1
		AND	#00000100B
		BEQ	CRSWRT		; Down key in ?
;					; yes !
		LDA	ENCHPT,X
		BNE	CRSWRT		; move start !
;
		INC	ENCHPT,X
		LDA	#0CH
		STA	ENTIM0,X
CRSWRT		EQU	$
S2PLDW		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	#09H
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		STA	<PLYPS0
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      OYAGI INIT                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OYAGIIT		EQU	$
		PHB
		PHK
		PLB
		JSR	OYAGI00_I
		PLB
		RTL
;========================================
OYAGI00_I	EQU	$
		LDA	#030H		;INIT TIME
		STA	ENTIM0,X
;
		LDA	#-004		;INIT SPD
		STA	ENYSPD,X
;
		LDA	ENXPSL,X	;INIT POSITION SET
		SEC
		SBC	#008H
		STA	ENXPSL,X
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,X
;
		RTS
;
OYGSTXD		EQU	$
		WORD	00978H
OYGSTYD		EQU	$
		WORD	021F0H
OYAGIST		EQU	$
		LDA	#OYAGI
		JSL	>ENIDSH
		BMI	OYGST10
;
		LDA	>OYGSTXD+0
		STA	ENXPSL,Y
		LDA	>OYGSTXD+1
		STA	ENXPSH,Y
		LDA	>OYGSTYD+0
		STA	ENYPSL,Y
		LDA	>OYGSTYD+1
		STA	ENYPSH,Y
;
		LDA	#030H		;INIT TIME
		STA	ENTIM0,Y
;
		LDA	#-004		;INIT SPD
		STA	ENYSPD,Y
;
OYGST10		EQU	$
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      OYAGI MOVE                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OYAGIMV		EQU	$
		PHB
		PHK
		PLB
		JSR	OYAGI00
		PLB
		RTL
;========================================
KENCPD		EQU	$
		BYTE	008H,008H,008H,008H,008H,008H
		BYTE	000H,008H,004H,004H
TATCPD		EQU	$
		BYTE	002H,002H,002H,002H,002H,002H
		BYTE	002H,002H,004H,000H
OYAGI00		EQU	$
		LDY	ENCHPT,X
		LDA	KENCPD,Y	;KEN CHAR NO SET
		STA	KENCPT
		LDA	TATCPD,Y	;TATE CHAR NO SET
		STA	TATCPT
		JSR	OYAGICS
		JSR	ENSTCK          ; scroll : not return !
		JSR	ENMVCL		; xclc,yclc !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	OYAGIM0
		WORD	OYAGIM1
		WORD	OYAGIM2
		WORD	OYAGIM3
		WORD	OYAGIM4
;
;----------------------------------------
OYAGIM0		EQU	$		; UP onry move
		LDA	ENTIM0,X
		BNE	OYGM010
		INC	ENSTAT,X
;
		LDA	#-003
		STA	ENXSPD,X
OYGM010		EQU	$
		RTS
;----------------------------------------
OYGM1SX		EQU	$
		BYTE	-001,0001
OYGM1MX		EQU	$
		BYTE	-002,0002
OYAGIM1		EQU	$
;
		LDA	ENTIM0,X	;X speed
		BNE	OYGM140
		INC	ENWRK2,X	;MOVE CNT(kyori)
		LDA	ENWRK2,X
		CMP	#008H
		BCC	OYGM180
		INC	ENSTAT,X	;NEXT MOVE
		STZ	ENXSPD,X	;STOP SPEED
		STZ	ENYSPD,X
		RTS
OYGM180		EQU	$
		LDA	#028H
		STA	ENTIM0,X
;
		LDY	ENWRK3,X
		BEQ	OYGM130
;
		LDA	ENXSPD,X
		BMI	OYGM120
		CMP	OYGM1MX,Y
		BCC	OYGM120
		BRA	OYGM110
OYGM130		EQU	$
		LDA	ENXSPD,X
		BPL	OYGM120
		CMP	OYGM1MX,Y
		BCS	OYGM120
;		BRA	OYGM110
OYGM110		EQU	$
		LDA	ENWRK3,X
		EOR	#001H
		STA	ENWRK3,X
		TAY
OYGM120		EQU	$
		LDA	ENXSPD,X
		CLC
		ADC	OYGM1SX,Y
		STA	ENXSPD,X
;
OYGM140		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENXSPD,X
		CLC
		ADC	#004H
		CMP	#004H+004H+001H
		BCS	OYGM150
		LDA	#002H
		BRA	OYGM170
OYGM150		EQU	$
		LDA	ENXSPD,X
		BMI	OYGM160
		LDA	#004H
OYGM170		EQU	$
		ORA	ENCHPT,X
		STA	ENCHPT,X
OYGM160		EQU	$
		RTS
;----------------------------------------
OYGM2TD		EQU	$
		BYTE	0010,0004,0004,0FFH
OYGM2CD		EQU	$
		BYTE	0002,0006,0007,0008
OYAGIM2		EQU	$
		LDA	ENTIM0,X
		BNE	OYGM210
;
		LDY	ENWRK1,X
		LDA	OYGM2TD,Y
		CMP	#0FFH
		BNE	OYGM220
		INC	ENSTAT,X
OYGM220		EQU	$
		STA	ENTIM0,X
		LDA	OYGM2CD,Y
		STA	ENCHPT,X
;
		INC	ENWRK1,X
;
OYGM210		EQU	$
		RTS
;----------------------------------------
OYGM3CD		EQU	$
		BYTE	0008
OYAGIM3		EQU	$
		LDA	OYGM3CD
		STA	ENCHPT,X
;
		LDA	#000H			;msge no set
		JSL	>ENMSG2L		;? msge write
		BCC	OYGM310
		INC	ENSTAT,X
;
OYGM310		EQU	$
		RTS
;----------------------------------------
OYGM4CD		EQU	$
		BYTE	0009
OYAGIM4		EQU	$
		LDA	OYGM4CD
		STA	ENCHPT,X
;
		LDA	<KEYA2
		BEQ	OYGM410
;
		LDA	#001H
		STA	!STDMFG
		LDY	#000H
		JSL	>ATMSIT
		BCS	OYGM410
		STZ	ENMODE,X
;
OYGM410		EQU	$
		RTS
;----------------------------------------
OYAGICD		EQU	$			;CHAR DATA
		BYTE	-001,-010,000H,00EH	;0
		BYTE	0000,0000,002H,000H
		BYTE	-006,-010,005H,001H
		BYTE	-006,-002,015H,001H
		BYTE	0006,-006,007H,001H
		BYTE	0006,-006,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	-001,-009,000H,00EH	;1
		BYTE	0000,0001,004H,000H
		BYTE	-006,-009,005H,001H
		BYTE	-006,-001,015H,001H
		BYTE	0006,-005,007H,001H
		BYTE	0006,-005,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	0000,-010,000H,00EH	;0
		BYTE	0000,0000,002H,000H
		BYTE	-006,-010,005H,001H
		BYTE	-006,-002,015H,001H
		BYTE	0006,-006,007H,001H
		BYTE	0006,-006,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	0000,-009,000H,00EH	;1
		BYTE	0000,0001,004H,000H
		BYTE	-006,-009,005H,001H
		BYTE	-006,-001,015H,001H
		BYTE	0006,-005,007H,001H
		BYTE	0006,-005,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	0001,-010,000H,00EH	;0
		BYTE	0000,0000,002H,000H
		BYTE	-006,-010,005H,001H
		BYTE	-006,-002,015H,001H
		BYTE	0006,-006,007H,001H
		BYTE	0006,-006,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	0001,-009,000H,00EH	;1
		BYTE	0000,0001,004H,000H
		BYTE	-006,-009,005H,001H
		BYTE	-006,-001,015H,001H
		BYTE	0006,-005,007H,001H
		BYTE	0006,-005,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	0003,-003,005H,001H	;2
		BYTE	0003,0005,015H,001H
		BYTE	0000,-010,000H,00EH
		BYTE	0000,0000,002H,000H
		BYTE	0006,-005,007H,001H
		BYTE	0006,-005,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	0000,-009,000H,00EH	;3
		BYTE	0012,-003,005H,041H
		BYTE	0012,0005,015H,041H
		BYTE	0000,0001,004H,040H
		BYTE	0006,-004,007H,001H
		BYTE	0006,-004,007H,001H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	0000,-008,008H,00EH	;4
		BYTE	-013,-004,007H,041H
		BYTE	0017,-002,006H,041H
		BYTE	0025,-002,005H,041H
		BYTE	-008,-001,006H,000H
		BYTE	0008,0000,006H,040H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
		BYTE	-009,-008,007H,041H	;5
		BYTE	-009,-008,007H,041H
		BYTE	-009,-008,007H,041H
		BYTE	-009,-008,007H,041H
		BYTE	0017,-002,006H,041H
		BYTE	0025,-002,005H,041H
		BYTE	0000,0000,000H,000H	;D
		BYTE	0000,0000,000H,000H	;D
;
OYAGISD		EQU	$			;SB DATA
		BYTE	002H,002H,000H,000H	;0
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,002H,000H,000H	;1
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,002H,000H,000H	;0
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,002H,000H,000H	;1
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,002H,000H,000H	;0
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,002H,000H,000H	;1
		BYTE	002H,002H,000H,000H
;
		BYTE	000H,000H,002H,002H	;2
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,000H,000H,002H	;3
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,002H,000H,000H	;4
		BYTE	002H,002H,000H,000H
;
		BYTE	002H,002H,002H,002H	;5
		BYTE	000H,000H,000H,000H
;
OYAGICS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
;
		LDA	ENCHPT,X
;
		MEM16
		IDX16
		REP	#00110000B
		AND	#000FFH
		ASL	A
		ASL	A
		ASL	A
		STA	<WORKC		;OAM SB DATA READ POINT (L)
		ASL	A
		ASL	A
;
		TAX
		LDY	<OAMADR
		LDA	#00005H
		STA	<WORKE
;
OYGIC10		EQU	$
		LDA	OYAGICD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	OYAGICD+2,X
		EOR	<WORK4
		STA	OAM-OAM+2,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	OYGIC10
;
		LDY	<OSBADR		;OAM SB SET
;
		LDX	<WORKC		;OAM SB READ POINT 
;
		LDA	#00003H		;KAZU
		STA	<WORKE
;
OYGIC20		EQU	$
		LDA	OYAGISD,X
		STA	OAMSB-OAMSB,Y
		INX
		INX
		INY
		INY
		DEC	<WORKE
		BPL	OYGIC20
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#007H
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      SETOAML		                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	<WORKB,C <---- KAZU (8BYTE = 1) (0 = NOT TENSOU)
;	<WORKD,E,F <--- TFR MOTO
;
SETOAML		EQU	$
;
		LDA	<WORKB
		ORA	<WORKC
		BEQ	STOAM10		;?KAZU = 0
;					;n
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	#00000H		;DATA READ POINT
;
STOAM20		EQU	$
;
		LDX	OAMADR		;OAM ADR
;
		LDA	[<WORKD],Y	;X pos set
		CLC
		ADC	<WORK0
		STA	OAM-OAM,X
		AND	#00100H		;OAMSB DATA SET(JUNBI)
		STA	<WORK9
;
		INY			;NEXT READ POINT
		INY
;
		LDA	[<WORKD],Y	;Y pos set
		CLC
		ADC	<WORK2
		STA	OAM-OAM+1,X
		CLC
		ADC	#00010H
		CMP	#00100H
		BCC	STOAM30		;!(0FFF0H - 000F0H) = CLS
		LDA	#000F0H		;Y pos cls
		STA	OAM-OAM+1,X
;
STOAM30		EQU	$
		INY			;NEXT READ POINT
		INY
;
		LDA	[<WORKD],Y	;CHAR and ATR SET
		EOR	<WORK4
		STA	OAM-OAM+2,X
;
		INY			;NEXT READ POINT
		INY
;
		LDA	[<WORKD],Y
		ORA	<WORK9
;
		INY			;NEXT READ POINT
		INY
;
		MEM8
		SEP	#00100000B
;
		LDX	OSBADR		;OAM SB SET
		XBA
		STA	OAMSB-OAMSB,X
		INX
		STX	OSBADR
;
		MEM16
		REP	#00100000B
;
		LDA	OAMADR		;NEXT OAM ADR
		CLC
		ADC	#00004H
		STA	OAMADR
;
		DEC	<WORKB		;? ALL OVRE
		BNE	STOAM20
;					;Y
STOAM10		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW01IT		EQU	$
		PHB
		PHK
		PLB
;		JSR
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW02IT		EQU	$
		PHB
		PHK
		PLB
;		JSR
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT1IT		EQU	$
		PHB
		PHK
		PLB
		JSR	PINT100_I
		PLB
		RTL
;========================================
PINT100_I	EQU	$
		JSR	PINT1UC		;ENWRK0 - 3 <--- UNIT NO
;
		JSR	PINT1CK		;UNIT CHK.
PNT1I10		EQU	$
		RTS
;----------------------------------------
PT1UD10		EQU	$		;master unit (UL = 000H)
;			UL   UR   DL   DR
		BYTE	000H,002H,000H,001H
		BYTE	000H,002H,001H,001H
		BYTE	000H,000H,001H,002H
		BYTE	000H,001H,000H,002H
		BYTE	000H,001H,002H,001H
		BYTE	000H,000H,002H,001H
PT1UD11		EQU	$		;master unit (UL = 001H)
		BYTE	001H,002H,001H,000H
		BYTE	001H,002H,000H,000H
		BYTE	001H,001H,000H,002H
		BYTE	001H,000H,001H,002H
		BYTE	001H,000H,002H,000H
		BYTE	001H,001H,002H,000H
PT1UD12		EQU	$		;master unit (UL = 002H)
		BYTE	002H,001H,000H,001H
		BYTE	002H,000H,001H,000H
		BYTE	002H,000H,001H,001H
		BYTE	002H,001H,000H,000H
PT1UD13		EQU	$		;master unit (keisan you)
;-  -  -  -  -  -  -  -  -  -  -  -  -  -
PT1UD20		EQU	$		;chenge unit (UL = 000H)
;			U.No not  not  not
		BYTE	001H,000H,000H,000H
		BYTE	004H,000H,000H,000H
		BYTE	007H,000H,000H,000H
		BYTE	009H,000H,000H,000H
		BYTE	00AH,000H,000H,000H
		BYTE	00FH,000H,000H,000H
PT1UD21		EQU	$		;chenge unit (UL = 001H)
		BYTE	000H,000H,000H,000H
		BYTE	005H,000H,000H,000H
		BYTE	006H,000H,000H,000H
		BYTE	008H,000H,000H,000H
		BYTE	00BH,000H,000H,000H
		BYTE	00EH,000H,000H,000H
PT1UD22		EQU	$		;chenge unit (UL = 002H)
		BYTE	002H,000H,000H,000H
		BYTE	003H,000H,000H,000H
		BYTE	00CH,000H,000H,000H
		BYTE	00DH,000H,000H,000H
PT1UD23		EQU	$		;chenge unit (keisan you)
;-  -  -  -  -  -  -  -  -  -  -  -  -  -
PINT1CK		EQU	$
		LDA	ENWRK0,X
		CMP	#000H
		BNE	PT1CK10
		LDY	#PT1UD11-PT1UD10-4
PT1CK40		EQU	$
		LDA	ENWRK1,X		;unit 1 - 3 chk.
		CMP	PT1UD10+1,Y
		BNE	PT1CK50
		LDA	ENWRK2,X
		CMP	PT1UD10+2,Y
		BNE	PT1CK50
		LDA	ENWRK3,X
		CMP	PT1UD10+3,Y
		BNE	PT1CK50
;						;all ok !
		LDA	PT1UD20,Y
		STA	ENSTAT,X
		RTS
PT1CK50		EQU	$
		DEY
		DEY
		DEY
		DEY
		BPL	PT1CK40			;? not unit
;						;y
		BRA	PT1CK30
;
PT1CK10		EQU	$
		CMP	#001H
		BNE	PT1CK20
		LDY	#PT1UD12-PT1UD11-4
PT1CK60		EQU	$
		LDA	ENWRK1,X		;unit 1 - 3 chk.
		CMP	PT1UD11+1,Y
		BNE	PT1CK70
		LDA	ENWRK2,X
		CMP	PT1UD11+2,Y
		BNE	PT1CK70
		LDA	ENWRK3,X
		CMP	PT1UD11+3,Y
		BNE	PT1CK70
;						;all ok !
		LDA	PT1UD21,Y
		STA	ENSTAT,X
		RTS
PT1CK70		EQU	$
		DEY
		DEY
		DEY
		DEY
		BPL	PT1CK60			;? not unit
;						;y
		BRA	PT1CK30
;
PT1CK20		EQU	$
		CMP	#002H
		BNE	PT1CK30
		LDY	#PT1UD13-PT1UD12-4
PT1CK80		EQU	$
		LDA	ENWRK1,X		;unit 1 - 3 chk.
		CMP	PT1UD12+1,Y
		BNE	PT1CK90
		LDA	ENWRK2,X
		CMP	PT1UD12+2,Y
		BNE	PT1CK90
		LDA	ENWRK3,X
		CMP	PT1UD12+3,Y
		BNE	PT1CK90
;						;all ok !
		LDA	PT1UD22,Y
		STA	ENSTAT,X
		RTS
PT1CK90		EQU	$
		DEY
		DEY
		DEY
		DEY
		BPL	PT1CK80			;? not unit
;						;y
;		BRA	PT1CK30
;
PT1CK30		EQU	$
		STZ	ENMODE,X	;not unit
		RTS


;----------------------------------------
PT1YPDT		EQU	$		;UNIT POINT Y
		BYTE	000,000,008,008
PT1XPDT		EQU	$		;UNIT POINT X
		BYTE	000,008,000,008
PINT1UC		EQU	$
		LDY	#003H
PT1UC10		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	PT1YPDT,Y
		STA	<WORK0
		LDA	ENYPSH,X
		ADC	#000H
		STA     <WORK1
		LDA	ENXPSL,X
		CLC
		ADC	PT1XPDT,Y
		STA	<WORK2
		LDA	ENXPSH,X
		ADC	#000H
		STA	<WORK3
		LDA	#000H		;1 kai or 2 kai (level)
		JSL	>BGDTRD2
;					
		LDA	UNITNO
		STA	WORKC,Y
;
		DEY
		BPL	PT1UC10		;? 4 UNIT END
;					;Y
		LDA	<WORKC		;UNIT NO ---> ENWRK0 - 3
		STA	ENWRK0,X
		LDA	<WORKD
		STA	ENWRK1,X
		LDA	<WORKE
		STA	ENWRK2,X
		LDA	<WORKF
		STA	ENWRK3,X
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT2IT		EQU	$
		PHB
		PHK
		PLB
;		JSR
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW01MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PSW0100_M
		PLB
		RTL
;========================================
PSW0100_M	EQU	$
		JSR	PSW01CS
		JSR	ENSTCK          ; scroll : not return !
;
		JSL	>CRKNENL
		BCC	PSW0110		;? any atari
		LDA	AITMBT		;y
		AND	#00AH
		BEQ	PSW0110		;? HANMER atari
;					;y
;					;HANMER atari
		LDA	>KRXBUF		;ATARI !!
		EOR	#001H
		STA	>KRXBUF+1
		LDA	#001H
		STA	>KRXBUF
		RTS
PSW0110		EQU	$
		LDA	#000H
		STA	>KRXBUF
		STA	>KRXBUF+1
		RTS
;----------------------------------------
PSW01CS		EQU	$
		JSR	OAMCHK
;
		LDA	#000H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW02MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PSW0200_M
		PLB
		RTL
;========================================
PSW0200_M	EQU	$
		JSR	PSW02CS
		JSR	ENSTCK          ; scroll : not return !
;
		JSL	>CRKNENL
		BCC	PSW2110		;? any atari
		LDA	AITMBT		;y
		AND	#00AH
		BEQ	PSW2110		;? HANMER atari
;					;y
;					;HANMER atari
		LDA	>KRXBUF+2		;ATARI !!
		EOR	#001H
		STA	>KRXBUF+3
		LDA	#001H
		STA	>KRXBUF+2
		RTS
PSW2110		EQU	$
		LDA	#000H
		STA	>KRXBUF+2
		STA	>KRXBUF+3
		RTS
;----------------------------------------
PSW02CS		EQU	$
		JSR	OAMCHK
;
		LDA	#001H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT1MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PINT100_M
		PLB
		RTL
;========================================
PINT100_M	EQU	$
		JSR	PINT1CS
		JSR	ENSTCK          ; scroll : not return !
;
		RTS
;----------------------------------------
PINT1CS		EQU	$
		JSR	OAMCHK
;
		LDA	#002H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT2MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PINT200_M
		PLB
		RTL
;========================================
PINT200_M	EQU	$
		JSR	PINT2CS
		JSR	ENSTCK          ; scroll : not return !
;
		RTS
;----------------------------------------
PINT2CS		EQU	$
		JSR	OAMCHK
;
		LDA	#003H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	LINE0 INITIAL	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LINE0IT		EQU	$
		PHB
		PHK
		PLB
		JSR	LLBGRD
		STA	ENWRK3,X	;INIT unit set
;
		LDY	ENMUKI,X	;SPEED	set
		LDA	LINE0SX,Y
		STA	ENXSPD,X
		LDA	LINE0SY,Y
		STA	ENYSPD,X
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	LINE0 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LINE0MV		EQU	$
		PHB
		PHK
		PLB
		JSR	L00000
		PLB
		RTL
;=========================================
LINE0SX		EQU	$
		BYTE	000,016,016,016,000,-16,-16,-16
LINE0SY		EQU	$
		BYTE	-16,-16,000,016,016,016,000,-16
;
L00000		EQU	$
		JSR	LINE0CS
		JSR	ENSTCK          ; scroll : not return !
;
		LDA	ENSTAT,X
;;;TEST;;;		BNE	LINE010		;? no line
;
		JSR	LLBGRD		;bg chk.
		CMP	ENWRK3,X	;? unit !=
		BEQ	LINE010
;					;y
		STA	ENWRK3,X	;unit save
		JSR	LINE0MK		; muki kae
;
		LDA	ENXSPD,X	;POSITION bake
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		LDA	ENYSPD,X	;POSITION bake
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		JSR	ENMVCL		; xclc,yclc !
;
		LDY	ENMUKI,X	;SPEED	set
		LDA	LINE0SX,Y
		STA	ENXSPD,X
		LDA	LINE0SY,Y
		STA	ENYSPD,X
LINE010		EQU	$
		JSR	ENMVCL		; xclc,yclc !
		RTS
;-------------------------------------------------
LLBGRD		EQU	$
		LDA	ENYPSL,X
		STA	<WORK0
		LDA	ENYPSH,X
		STA     <WORK1
		LDA	ENXPSL,X
		STA	<WORK2
		LDA	ENXPSH,X
		STA	<WORK3
		LDA	#000H		;1 kai or 2 kai (level)
		JSL	>BGDTRD2
;					
		LDA	UNITNO
;
		CMP	#063H		;unit chyotto saiku
		BNE	LLBGRD00
		LDA	#062H		;unit 063h --> 062h
		STA	UNITNO
		RTS
LLBGRD00	EQU	$
		CMP	#065H
		BNE	LLBGRD10
		LDA	#064H		;unit 065h --> 064h
		STA	UNITNO
LLBGRD10	EQU	$
		RTS
;
;----------------------------------------
;
LINE0CD		EQU	$
		BYTE	003H
LINE0CS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		LDA	LINE0CD
		STA	<WORK4
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		SEC
		SBC	#00010H
		STA	OAM-OAM,Y
		LDA	ENDSXL+1
		SEC
		SBC	#00010H
		STA	OAM-OAM+1,Y
		LDA	<WORK4
		STA	OAM-OAM+2,Y
;
		LDA	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	ENDSXL+1
		SEC
		SBC	#00010H
		STA	OAM-OAM+5,Y
		LDA	<WORK4
		ORA	#04000H
		STA	OAM-OAM+6,Y
;
		LDA	ENDSXL
		SEC
		SBC	#00010H
		STA	OAM-OAM+8,Y
		LDA	ENDSXL+1
		STA	OAM-OAM+9,Y
		LDA	<WORK4
		ORA	#08000H
		STA	OAM-OAM+10,Y
;
		LDA	ENDSXL
		STA	OAM-OAM+12,Y
		LDA	<WORK4
		ORA	#0C000H
		STA	OAM-OAM+14,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#003H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;----------------------------------------
;
LINE0MK		EQU	$
		LDA	UNITNO
		CMP	#066H		;? STOPER
		BNE	LINE0MK1
		LDA	ENMUKI,X	; MUKI = !MUKI
		EOR	#004H
		STA	ENMUKI,X
		RTS
LINE0MK1	EQU	$
		LDA	ENMUKI,X
		JSL	>JSRSUB
		WORD	LN0MK00
		WORD	LN0MK01
		WORD	LN0MK02
		WORD	LN0MK03
		WORD	LN0MK04
		WORD	LN0MK05
		WORD	LN0MK06
		WORD	LN0MK07
;
;----------------------------------------
;			R    L
L0M0UD0		EQU	$
		BYTE	062H,064H
L0M0MKD		EQU	$
		BYTE	001H,007H
;
LN0MK00		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M0UD0,Y	;? unit ok
		BEQ	LN0M000
;					;n
		INY
		CMP	L0M0UD0,Y	;? unit ok
		BEQ	LN0M000
;					;NO !
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M000		EQU	$		;OK !
		LDA	L0M0MKD,Y
		STA	ENMUKI,X
;
		LDA	ENXPSL,X	;HOSEI X
		AND	#0F8H
		ORA	#003H
		STA	ENXPSL,X
;
		RTS
;
;----------------------------------------
;			L    R
L0M1UD0		EQU	$
		BYTE	060H,061H
L0M1MKD		EQU	$
		BYTE	000H,002H
;
LN0MK01		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M1UD0,Y	;? unit ok
		BEQ	LN0M100
;					;n
		INY
		CMP	L0M1UD0,Y	;? unit ok
		BEQ	LN0M100
;					;NO
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M100		EQU	$		;OK
		LDA	L0M1MKD,Y
		STA	ENMUKI,X
		RTS
;
;----------------------------------------
;			L    R
L0M2UD0		EQU	$
		BYTE	062H,064H
L0M2MKD		EQU	$
		BYTE	001H,003H
;
LN0MK02		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M2UD0,Y	;? unit ok
		BEQ	LN0M200
;					;n
		INY
		CMP	L0M2UD0,Y	;? unit ok
		BEQ	LN0M200
;					;NO !
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M200		EQU	$		;OK !
		LDA	L0M2MKD,Y
		STA	ENMUKI,X
;
		LDA	ENYPSL,X	;HOSEI Y
		AND	#0F8H
		ORA	#003H
		STA	ENYPSL,X
;
		RTS
;
;----------------------------------------
;
L0M3UD0		EQU	$
		BYTE	061H,060H
L0M3MKD		EQU	$
		BYTE	002H,004H
;
LN0MK03		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M3UD0,Y	;? unit ok
		BEQ	LN0M300
;					;n
		INY
		CMP	L0M3UD0,Y	;? unit ok
		BEQ	LN0M300
;					;NO !
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M300		EQU	$		;OK !
		LDA	L0M3MKD,Y
		STA	ENMUKI,X
		RTS
;
;----------------------------------------
;
L0M4UD0		EQU	$
		BYTE	064H,062H
L0M4MKD		EQU	$
		BYTE	003H,005H
;
LN0MK04		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M4UD0,Y	;? unit ok
		BEQ	LN0M400
;					;n
		INY
		CMP	L0M4UD0,Y	;? unit ok
		BEQ	LN0M400
;					;NO !
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M400		EQU	$		;OK !
		LDA	L0M4MKD,Y
		STA	ENMUKI,X
;
		LDA	ENXPSL,X	;HOSEI X
		AND	#0F8H
		ORA	#003H
		STA	ENXPSL,X
;
		RTS
;
;----------------------------------------
;
L0M5UD0		EQU	$
		BYTE	060H,061H
L0M5MKD		EQU	$
		BYTE	004H,006H
;
LN0MK05		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M5UD0,Y	;? unit ok
		BEQ	LN0M500
;					;n
		INY
		CMP	L0M5UD0,Y	;? unit ok
		BEQ	LN0M500
;					;NO !
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M500		EQU	$		;OK !
		LDA	L0M5MKD,Y
		STA	ENMUKI,X
		RTS
;
;----------------------------------------
;			L    R
L0M6UD0		EQU	$
		BYTE	062H,064H
L0M6MKD		EQU	$
		BYTE	005H,007H
;
LN0MK06		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M6UD0,Y	;? unit ok
		BEQ	LN0M600
;					;n
		INY
		CMP	L0M6UD0,Y	;? unit ok
		BEQ	LN0M600
;					;NO !
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M600		EQU	$		;OK !
		LDA	L0M6MKD,Y
		STA	ENMUKI,X
;
		LDA	ENYPSL,X	;HOSEI Y
		AND	#0F8H
		ORA	#003H
		STA	ENYPSL,X
;
		RTS
;
;----------------------------------------
;			L    R
L0M7UD0		EQU	$
		BYTE	061H,060H
L0M7MKD		EQU	$
		BYTE	006H,000H
;
LN0MK07		EQU	$
		LDY	#000H
		LDA	UNITNO
		CMP	L0M7UD0,Y	;? unit ok
		BEQ	LN0M700
;					;n
		INY
		CMP	L0M7UD0,Y	;? unit ok
		BEQ	LN0M700
;					;NO !
		LDA	#001H
		STA	ENSTAT,X
		RTS
LN0M700		EQU	$		;OK !
		LDA	L0M7MKD,Y
		STA	ENMUKI,X
		RTS
;
;----------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	NOPPO move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NOPPOMV		EQU	$
		PHB
		PHK
		PLB
		JSR	NP0000
		PLB
		RTL
NP0000		EQU	$
		JSR	NOPPOCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#000H
		JSL	>ENMSGEL
		STA	ENWRK0,X	; PL. miru!
		STA	ENMUKI,X	; PL. miru!
		BCC	MURAAMV		;
		STZ	ENSTAT,X	; PL. miru!
;
MURAAMV		EQU	$
		JSR	ENMVCL		; xclc,yclc,BG check !
		JSL	>ENBGCKL		; BG check sub !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	NOPPOM0
		WORD	NOPPOM1
;----------------------------------------
NOPPOSX		EQU	$
		BYTE	000H,000H,0F4H,00BH
NOPPOSY		EQU	$
		BYTE	0F4H,00BH,000H,000H
NOPPOM0		EQU	$
		LDA	ENTIM0,X
		BNE	NOPM010
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#040H
		STA	ENTIM0,X
;
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
NOPM010		EQU	$
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	NOPM020
		INC	ENSTAT,X
		LDA	#060H
		STA	ENTIM0,X
NOPM020		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDY	ENMUKI,X
		LDA	NOPPOSX,Y
		STA	ENXSPD,X
		LDA	NOPPOSY,Y
		STA	ENYSPD,X
		TYA
		STA	ENWRK0,X
;
		RTS
;----------------------------------------
NOPPOM1		EQU	$
		LDA	ENTIM0,X
		BNE	NOPM120
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#060H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
NOPM120		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	<WORK0
		AND	#001H
		BNE	NOPM110
		LDA	<WORK0
		LSR	A
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENWRK0,X
		RTS
;
NOPM110		EQU	$
		LDA	ENMUKI,X
		STA	ENWRK0,X
		RTS
;----------------------------------------
NOPPOHD		EQU	$
		BYTE	000H,000H,006H,000H ;0
		BYTE	000H,000H,004H,000H ;1
		BYTE	000H,000H,008H,000H ;2
		BYTE	000H,000H,008H,040H ;3
;
NOPPOBD		EQU	$
		BYTE	000H,00CH,022H,000H ;0
		BYTE	000H,00CH,022H,040H ;0
		BYTE	000H,00CH,00AH,000H ;1
		BYTE	000H,00CH,00AH,040H ;1
		BYTE	000H,00CH,00CH,000H ;2
		BYTE	000H,00CH,00EH,000H ;2
		BYTE	000H,00CH,00CH,040H ;3
		BYTE	000H,00CH,00EH,040H ;3
;
NOPPOCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
		LDA	ENMUKI,X
		STA	<WORK2
		STZ	<WORK3
		LDA	ENCHPT,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	<GAMEMD
		BNE	NOPPC10
		LDA	ENSTAT,X
		BNE	NOPPC10
		TXA			;UP DOWN
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		CLC
		ADC	ENDSYL
		STA	ENDSYL
;
NOPPC10		EQU	$
		LDA	ENWRK0,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	NOPPOHD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	NOPPOHD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
;
		LDA	<WORK2
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		TAX
;
		LDA	NOPPOBD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	NOPPOBD+2,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;----------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	ENMSGE		                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
ENMSGEL		EQU	$		;PUSH DO BOTON
;
		STA	!MSGENOL	;msge no set(test)
		STZ	!MSGENOH
		JSL	>CRENPL2L
		BCC	ENMSG10
;
		LDA	<KEYA2L		;DO boton?
		AND	#080H
		BEQ	ENMSG10
;
		STZ	!MSGEFG
		STZ	!INITAL
		LDA	#p3_msge
		STA	<GAMEMD
		LDA	<SLMODE
		STA	!NXSLMD
		LDA	#MD_etcpl
		STA	<SLMODE
;
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		SEC
		RTL
ENMSG10		EQU	$
		LDA	ENMUKI,X
		CLC
		RTL
;----------------------------------------
ENMSG2L		EQU	$		;NO BOTON
;
		STA	!MSGENOL	;msge no set(test)
		STZ	!MSGENOH
		JSL	>CRENPL2L
		BCC	ENMS210
;
		STZ	!MSGEFG
		STZ	!INITAL
		LDA	#p3_msge
		STA	<GAMEMD
		LDA	<SLMODE
		STA	!NXSLMD
		LDA	#MD_etcpl
		STA	<SLMODE
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	PLSVX1		;PL. POS. recover
		STA	<PLXPS1
		LDA	PLSVY1
		STA	<PLYPS1
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		SEC
		RTL
ENMS210		EQU	$
		LDA	ENMUKI,X
		CLC
		RTL
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	JIJI1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JIJI1MV		EQU	$
		PHB
		PHK
		PLB
		JSR	JIJI100
		PLB
		RTL
JIJI100		EQU	$
		JSR	JIJI1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		STA	ENWRK0,X	; PL. miru!
		STA	ENMUKI,X	; PL. miru!
		BCC	JIJI110		;
		STZ	ENSTAT,X	; PL. miru!
;
JIJI110		EQU	$
		JSR	ENMVCL		; xclc,yclc,BG check !
		JSL	>ENBGCKL		; BG check sub !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JIJI1M0
		WORD	JIJI1M1
;----------------------------------------
JIJI1SX		EQU	$
		BYTE	000H,000H,0FCH,003H
JIJI1SY		EQU	$
		BYTE	0FCH,003H,000H,000H
JIJI1M0		EQU	$
		LDA	ENTIM0,X
		BEQ	JI1M010
;
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	JI1M020
JI1M010		EQU	$
		INC	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
JI1M020		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDY	ENMUKI,X
		LDA	JIJI1SX,Y
		STA	ENXSPD,X
		LDA	JIJI1SY,Y
		STA	ENYSPD,X
		TYA
		STA	ENWRK0,X
;
		RTS
;----------------------------------------
JIJI1M1		EQU	$
		LDA	ENTIM0,X
		BNE	JI1M120
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#0E0H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
JI1M120		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	<WORK0
		AND	#001H
		BNE	JI1M110
		LDA	<WORK0
		LSR	A
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENWRK0,X
		RTS
;
JI1M110		EQU	$
		LDA	ENMUKI,X
		STA	ENWRK0,X
		RTS
;--------------------------------------
JIJI1HD		EQU	$
		BYTE	000H,000H,02AH,000H ;0
		BYTE	000H,000H,084H,000H ;1
		BYTE	000H,000H,024H,000H ;2
		BYTE	000H,000H,024H,040H ;3
;
JIJI1BD		EQU	$
		BYTE	000H,008H,02CH,000H ;0
		BYTE	000H,008H,02EH,000H ;0
		BYTE	000H,008H,0AAH,000H ;1
		BYTE	000H,008H,0ACH,000H ;1
		BYTE	003H,008H,026H,000H ;2
		BYTE	003H,008H,028H,000H ;2
		BYTE	0FDH,008H,026H,040H ;3
		BYTE	0FDH,008H,028H,040H ;3
;
JIJI1CS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
		LDA	ENMUKI,X
		STA	<WORK2
		STZ	<WORK3
		LDA	ENCHPT,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	<GAMEMD
		BNE	JIJ1C10
		LDA	ENSTAT,X
		BNE	JIJ1C10
		TXA			;UP DOWN
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		CLC
		ADC	ENDSYL
		STA	ENDSYL
;
JIJ1C10		EQU	$
		LDA	ENWRK0,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	JIJI1HD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	JIJI1HD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
;
		LDA	<WORK2
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		TAX
;
		LDA	JIJI1BD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	JIJI1BD+2,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	ONNAA move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ONNAAMV		EQU	$
		PHB
		PHK
		PLB
		JSR	ONNAA00
		PLB
		RTL
ONNAA00		EQU	$
		JSR	ONNAACS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		STA	ENWRK0,X	; PL. miru!
		STA	ENMUKI,X	; PL. miru!
		BCC	ONNAA10
		STZ	ENSTAT,X	; PL. miru!
;
ONNAA10		EQU	$
		JSR	MURAAMV
;
		RTS
;--------------------------------------
ONNAAHD		EQU	$
		BYTE	000H,000H,046H,000H ;0
		BYTE	000H,000H,044H,000H ;1
		BYTE	000H,000H,048H,000H ;2
		BYTE	000H,000H,048H,040H ;3
;
ONNAAUD		EQU	$
		BYTE	004H,00EH,05FH,000H ;2
		BYTE	002H,00DH,07CH,000H ;2
		BYTE	004H,00EH,05FH,040H ;3
		BYTE	006H,00DH,07CH,040H ;3
;
ONNAABD		EQU	$
		BYTE	000H,008H,06AH,000H ;0
		BYTE	000H,008H,06AH,040H ;0
		BYTE	000H,008H,068H,000H ;1
		BYTE	000H,008H,068H,040H ;1
		BYTE	000H,008H,04CH,000H ;2
		BYTE	000H,008H,04CH,000H ;2
		BYTE	000H,008H,04CH,040H ;3
		BYTE	000H,008H,04CH,040H ;3
;
ONNAACS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
		LDA	ENMUKI,X
		STA	<WORK2
		STZ	<WORK3
		LDA	ENCHPT,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	<GAMEMD
		BNE	ONNAC10
		LDA	ENSTAT,X
		BNE	ONNAC10
		TXA			;UP DOWN
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		CLC
		ADC	ENDSYL
		STA	ENDSYL
;
ONNAC10		EQU	$
		LDA	ENWRK0,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	ONNAAHD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	ONNAAHD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
;
		LDA	<WORK2
		CMP	#00002H
		BCC	ONNAC20
		AND	#00001H
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		TAX
;
		LDA	ONNAAUD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	ONNAAUD+2,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
ONNAC20		EQU	$
		LDA	<WORK2
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		TAX
;
		LDA	ONNAABD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+8,Y
		LDA	ONNAABD+2,X
		ORA	<WORK2
		STA	OAM-OAM+0AH,Y
;
		LDY	<OSBADR
		LDA	#0002H
		STA	OAMSB-OAMSB,Y
		LDA	#0002H
		STA	OAMSB-OAMSB+2,Y
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#002H
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	HIGEE move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HIGEEMV		EQU	$
		PHB
		PHK
		PLB
		JSR	HIGEE00
		PLB
		RTL
HIGEE00		EQU	$
		JSR	HIGEECS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		STA	ENWRK0,X	; PL. miru!
		STA	ENMUKI,X	; PL. miru!
		BCC	HIGEE10
		STZ	ENSTAT,X	; PL. miru!
;
HIGEE10		EQU	$
		JSR	MURAAMV
;
		RTS
;--------------------------------------
HIGEEHD		EQU	$
		BYTE	000H,000H,060H,000H ;0
		BYTE	000H,000H,040H,000H ;1
		BYTE	000H,000H,062H,000H ;2
		BYTE	000H,000H,062H,040H ;3
;
HIGEEBD		EQU	$
		BYTE	000H,008H,06EH,000H ;0
		BYTE	000H,008H,06EH,040H ;0
		BYTE	000H,008H,042H,000H ;1
		BYTE	000H,008H,042H,040H ;1
		BYTE	000H,008H,064H,000H ;2
		BYTE	000H,008H,066H,000H ;2
		BYTE	000H,008H,064H,040H ;3
		BYTE	000H,008H,066H,040H ;3
;
HIGEECS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
		LDA	ENMUKI,X
		STA	<WORK2
		STZ	<WORK3
		LDA	ENCHPT,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	<GAMEMD
		BNE	HIGEC10
		LDA	ENSTAT,X
		BNE	HIGEC10
		TXA			;UP DOWN
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		CLC
		ADC	ENDSYL
		STA	ENDSYL
;
HIGEC10		EQU	$
		LDA	ENWRK0,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	HIGEEHD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	HIGEEHD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
;
		LDA	<WORK2
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		TAX
;
		LDA	HIGEEBD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	HIGEEBD+2,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MAJOO move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MAJOOMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MAJOO00
		PLB
		RTL
MAJOO00		EQU	$
		JSR	MAJOOCS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
;
		LDA	<FRCNT
		BNE	MAJOO20
;
		JSL	>RNDSET
		AND	#001H
		CLC
		ADC	#002H
		STA	ENWRK0,X
;
MAJOO20		EQU	$
		LDA	ENWRK0,X
		STA	<WORK0
		LDA	<FRCNT
MAJOO10		EQU	$
		LSR	A
		DEC	<WORK0
		BPL	MAJOO10
		AND	#007H
		STA	ENCHPT,X
		RTS
;---------------------------------------
MAJOCUD		EQU	$
		BYTE	-003,0008,0AEH,000H	;0
		BYTE	-003,0016,0BEH,000H
		BYTE	-002,0008,0AEH,000H	;1
		BYTE	-002,0016,0BEH,000H
		BYTE	-001,0008,0AFH,000H	;2
		BYTE	-001,0016,0BFH,000H
		BYTE	0000,0009,0AFH,000H	;3
		BYTE	0000,0017,0BFH,000H
		BYTE	0001,0010,0AFH,000H	;4
		BYTE	0001,0018,0BFH,000H
		BYTE	0000,0011,0AFH,000H	;5
		BYTE	0000,0019,0BFH,000H
		BYTE	-001,0010,0AEH,000H	;6
		BYTE	-001,0018,0BEH,000H
		BYTE	-003,0009,0AEH,000H	;7
		BYTE	-003,0017,0BEH,000H
MAJOCAD		EQU	$
		BYTE	000H,-004,080H,000H	;ATAMA
		BYTE	-011,00FH,086H,002H	;TUBO
		BYTE	-003,00FH,086H,042H	;TUBO
MAJOCBD		EQU	$
		BYTE	0000,0004,084H,000H
		BYTE	0000,0004,082H,000H
;
MAJOOCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		LDA	ENCHPT,X
		STA	<WORK1
		STZ	<WORK0
;
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		ASL	A
		ASL	A
		ASL	A
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	MAJOCUD,X		;UDE SET
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	MAJOCUD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
		LDA	MAJOCUD+4,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	MAJOCUD+6,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
		LDX	#00000H
		LDA	#00002H
		STA	<WORKE
MJOCS10		EQU	$
		LDA	MAJOCAD,X		;ATAMA TUBO SET
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+8,Y
		LDA	MAJOCAD+2,X
		ORA	<WORK4
		STA	OAM-OAM+10,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	MJOCS10
;
		LDA	<WORK0
		SEC
		SBC	#00003H
		CMP	#00003H
		BCC	MJOCS20
		LDX	#00000H
		BRA	MJOCS30
MJOCS20		EQU	$
		LDX	#00004H
MJOCS30		EQU	$
;
		LDA	MAJOCBD,X		;KARADA SET
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+8,Y
		LDA	MAJOCBD+2,X
		ORA	<WORK4
		STA	OAM-OAM+10,Y
;
		LDY	<OSBADR
		LDA	#0000H
		STA	OAMSB-OAMSB,Y
		LDA	#0202H
		STA	OAMSB-OAMSB+2,Y
		STA	OAMSB-OAMSB+4,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#005H
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;----------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	JIJI2 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JIJI2MV		EQU	$
		PHB
		PHK
		PLB
		JSR	JIJI200
		PLB
		RTL
JIJI200		EQU	$
		JSR	JIJI2CS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
;
		LDA	<FRCNT
		LSR	A
		ORA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		RTS
;--------------------------------------
JIJI2CD		EQU	$
		BYTE	001H,008H,030H,000H
		BYTE	001H,013H,031H,000H
		BYTE	000H,008H,010H,000H
		BYTE	008H,008H,010H,040H
		BYTE	000H,000H,000H,000H
		BYTE	008H,000H,000H,040H
;
		BYTE	002H,009H,030H,000H
		BYTE	002H,014H,031H,000H
		BYTE	000H,007H,002H,000H
		BYTE	008H,007H,002H,040H
		BYTE	000H,0FFH,000H,000H
		BYTE	008H,0FFH,000H,040H
;
JIJI2CS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
;
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
		LDA	#00005H
		STA	<WORKE
;
JIJ2C10		EQU	$
		LDA	JIJI2CD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	JIJI2CD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	JIJ2C10
;
		LDY	<OSBADR
;
		LDA	#0000H
		STA	OAMSB-OAMSB,Y
		LDA	#0202H
		STA	OAMSB-OAMSB+2,Y
		STA	OAMSB-OAMSB+4,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#005H
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SNTAK move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SNTAKMV		EQU	$
		PHB
		PHK
		PLB
		JSR	SNTAK00
		PLB
		RTL
SNTAK00		EQU	$
		JSR	SNTAKCS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SNTAKM0
		WORD	SNTAKM1
;----------------------------------------
SNTAKM0		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		JSL	>RNDSET
		AND	#03FH
		BNE	SNTM010
;
		INC	ENSTAT,X
		STZ	ENWRK0,X
		LDA	#020H
		STA	ENTIM0,X
;
SNTM010		EQU	$
		RTS
;
;----------------------------------------
SNTM1DT		EQU	$
		BYTE	2,6,3,4,5,6,3,4,5,6,2
SNTM1TT		EQU	$-1
		BYTE	008H,012H,004H,004H,00CH,004H,004H
		BYTE	004H,00CH,010H
SNTAKM1		EQU	$
		LDA	ENTIM0,X
		BNE	SNTM120
		INC	ENWRK0,X
		LDA	ENWRK0,X
		CMP	#00BH
		BCC	SNTM110
		STZ	ENWRK0,X
		STZ	ENSTAT,X
SNTM110		EQU	$
		LDY	ENWRK0,X
		LDA	SNTM1TT,Y
		STA	ENTIM0,X
		LDA	SNTM1DT,Y
		STA	ENCHPT,X
SNTM120		EQU	$
;
		RTS
;
;----------------------------------------
SNTAKCD		EQU	$
		BYTE	0001,0014,07CH,000H
		BYTE	-005,0014,06DH,000H
		BYTE	-005,0022,07DH,000H
		BYTE	0000,0001,048H,000H
		BYTE	0000,0008,04AH,000H
;
		BYTE	0002,0014,06CH,000H
		BYTE	-004,0012,06DH,000H
		BYTE	-004,0020,07DH,000H
		BYTE	0000,0001,048H,000H
		BYTE	0000,0008,04AH,000H
;
		BYTE	0001,0014,07CH,000H
		BYTE	-005,0013,06DH,000H
		BYTE	-005,0021,07DH,000H
		BYTE	0000,0000,048H,000H
		BYTE	0000,0008,04CH,000H
;
		BYTE	0000,0011,05EH,000H
		BYTE	-005,0007,04FH,080H
		BYTE	-013,0007,04EH,080H
		BYTE	0000,0000,048H,000H
		BYTE	0000,0008,04CH,000H
;
		BYTE	0000,0011,05EH,000H
		BYTE	-005,0010,04FH,000H
		BYTE	-013,0010,04EH,000H
		BYTE	0000,0000,048H,000H
		BYTE	0000,0008,04CH,000H
;
		BYTE	0001,0014,07CH,000H
		BYTE	-004,0014,04FH,000H
		BYTE	-012,0014,04EH,000H
		BYTE	0000,0000,048H,000H
		BYTE	0000,0008,04CH,000H
;
		BYTE	0001,0014,07CH,000H
		BYTE	-004,0013,04FH,080H
		BYTE	-012,0013,04EH,080H
		BYTE	0000,0000,048H,000H
		BYTE	0000,0008,04CH,000H
;
SNTAKCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
		LDA	#00004H
		STA	<WORKE
;
SNTKC10		EQU	$
		LDA	SNTAKCD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	SNTAKCD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	SNTKC10
;
		LDY	<OSBADR
;
		LDA	#0000H
		STA	OAMSB-OAMSB,Y
		LDA	#0200H
		STA	OAMSB-OAMSB+2,Y
		LDA	#0202H
		STA	OAMSB-OAMSB+4,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#004H
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BUBUU move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BUBUUMV		EQU	$
		PHB
		PHK
		PLB
		JSR	BUBUU00
		PLB
		RTL
BUBUU00		EQU	$
		JSR	BUBUUCS
		JSR	ENSTCK		; scroll : not return !
;
;
;		LDA	<KEYA2
;		AND	#080H
;		BEQ	BUBUU20
;		LDA	ENCHPT,X
;		INC	A
;		AND	#003H
;		STA	ENCHPT,X
;BUBUU20		EQU	$
;		LDA	<KEYA2
;		AND	#040H
;		BEQ	BUBUU30
;		LDA	ENMUKI,X
;		INC	A
;		AND	#003H
;		STA	ENMUKI,X
;BUBUU30		EQU	$
;		RTS
;
		JSR	ENHNSB          ; hanekaeri 
;
		JSL	>CRKNKNL		; Vs PL ken check
		JSL	>CRENPLL		; Vs PL body check
;
		TXA
		EOR	<FRCNT
		AND	#007H
		BNE	BUBUU10
                JSL	>ENBGCKL		; BG check sub !
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	BUBUU10
		LDA	ENMUKI,X
		EOR	#001H
		STA	ENMUKI,X
BUBUU10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BUBUUM0		;stop		
		WORD	BUBUUM1		;move		
		WORD	BUBUUM2		;yari		
		WORD	BUBUUM3		;yari nasi		
;
;----------------------------------------
BUBUUM0		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		STZ	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	BUUM010
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#003H
		STA	ENMUKI,X
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#080H
		STA	ENTIM0,X
;
BUUM010		EQU	$
		RTS
;----------------------------------------
BUUM1SX		EQU	$
		BYTE	000H,000H,0F3H,00CH
BUUM1SY		EQU	$
		BYTE	0F3H,00CH,000H,000H
BUBUUM1		EQU	$
		LDY	ENMUKI,X
		LDA	BUUM1SX,Y
		STA	ENXSPD,X
		LDA	BUUM1SY,Y
		STA	ENYSPD,X
		JSR	ENMVCL		; xclc,yclc
;
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		STA	ENZPSL,X
;
		LDA	ENTIM0,X
		BNE	BUUM110
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#00FH
		CLC
		ADC	#010H
		STA	ENTIM0,X
;
BUUM110		EQU	$
		RTS
;----------------------------------------
BUBUUM2		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		LDA	#002H
		STA	ENCHPT,X
;
		LDA 	ENTIM0,X
		BNE	BUUM210
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#01FH
		ADC	#020H
		STA	ENTIM0,X
;
		JSR	BUYTMST		;YATAM ENTRY
;
BUUM210		EQU	$
		RTS
;----------------------------------------
BUBUUM3		EQU	$
		LDA	#003H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	BUUM310
;
		STZ	ENSTAT,X
		JSL	>RNDSET
		AND	#00FH
		CLC
		ADC	#010H
		STA	ENTIM0,X
;
BUUM310		EQU	$
		RTS
;====================			;YATAM
BUYTMSX		EQU	$
		BYTE	000H,000H,0E0H,020H
BUYTMSY		EQU	$
		BYTE	0E0H,020H,000H,000H
BUYTMST		EQU	$
		LDA	#YATAM
		JSL	>ENIDSH
		BMI	BUYTS80
		PHX
		LDA	ENMUKI,X
		STA	ENMUKI,Y
		TAX
;
		LDA	ENMOD3,Y
		AND	#0F0H
		ORA	YACRDT,X
		STA	ENMOD3,Y
;
		LDA	<WORK0
		CLC
		ADC	BUUYAX,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	BUUYAXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	BUUYAY,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	BUUYAYH,X
		STA	ENYPSH,Y
		LDA	<WORK4
		STA	ENZPSL,Y
;
		LDA	BUYTMSX,X
		STA	ENXSPD,Y
		LDA	BUYTMSY,X
		STA	ENYSPD,Y
;
		PLX
BUYTS80		EQU	$
		RTS
;----------------------------------------
BUUYAY          EQU     $
                BYTE    0002,0002,0006,0006
;
BUUYAYH         EQU     $
                BYTE    0000,0000,0000,0000
;
BUUYAX          EQU     $
                BYTE    -003,0011,0002,-002
;
BUUYAXH         EQU     $
                BYTE    -001,0000,0000,-001
;
;--------------------------------------
BUBUUCD		EQU	$
		BYTE	0000,-008,044H,000H		;0
		BYTE	0000,0000,060H,000H
		BYTE	-003,0000,052H,080H
		BYTE	-003,0008,042H,080H
;
		BYTE	0000,-008,044H,000H
		BYTE	0000,0000,060H,040H
		BYTE	-002,0002,052H,080H
		BYTE	-002,0010,042H,080H
;
		BYTE	0002,0002,041H,080H
		BYTE	0000,-008,044H,000H
		BYTE	0000,0000,04EH,000H
		BYTE	-006,-006,040H,080H
;
		BYTE	0000,-008,044H,000H
		BYTE	0000,0000,060H,000H
		BYTE	0004,0003,08EH,000H;D
		BYTE	0000,-008,084H,000H;D
;
;
;
		BYTE	0011,0007,052H,000H		;1
		BYTE	0000,-008,046H,000H
		BYTE	0000,0000,04CH,040H
		BYTE	0004,0003,08BH,000H;D
;
		BYTE	0011,0009,052H,000H
		BYTE	0000,-008,046H,000H
		BYTE	0000,0000,04CH,000H
		BYTE	0004,0003,08AH,040H;D
;
		BYTE	0012,0001,040H,040H
		BYTE	0000,-008,046H,000H
		BYTE	0000,0000,04AH,000H
		BYTE	0004,0002,065H,000H;D
;
		BYTE	0000,-008,046H,000H
		BYTE	0000,0000,04CH,000H
		BYTE	0004,0003,08AH,040H;D
		BYTE	0000,-008,084H,000H;D
;
;
;
		BYTE	-001,0007,050H,000H		;2
		BYTE	0007,0007,051H,000H
		BYTE	0000,-008,048H,000H
		BYTE	0000,0000,066H,000H
;
		BYTE	-004,0005,050H,000H
		BYTE	0004,0005,051H,000H
		BYTE	0000,-008,048H,000H
		BYTE	0000,0000,064H,000H
;
		BYTE	0002,-002,050H,000H
		BYTE	0010,-002,051H,000H
		BYTE	0000,-008,048H,000H
		BYTE	0000,0000,062H,000H
;
		BYTE	0000,-008,048H,000H
		BYTE	0000,0000,064H,000H
		BYTE	0004,0003,08EH,000H;D
		BYTE	0000,-008,084H,000H;D
;
;
;
		BYTE	0001,0007,051H,040H		;3
		BYTE	0009,0007,050H,040H
		BYTE	0000,-008,048H,040H
		BYTE	0000,0000,066H,040H
;
		BYTE	0004,0005,051H,040H
		BYTE	0012,0005,050H,040H
		BYTE	0000,-008,048H,040H
		BYTE	0000,0000,064H,040H
;
		BYTE	-002,-002,051H,040H
		BYTE	0006,-002,050H,040H
		BYTE	0000,-008,048H,040H
		BYTE	0000,0000,062H,040H
;
		BYTE	0000,-008,048H,040H
		BYTE	0000,0000,064H,040H
		BYTE	0004,0003,08EH,040H;D
		BYTE	0000,-008,084H,040H;D
;
;
;
BUBUUKD		EQU	$
		BYTE	003H,003H,003H,001H		;KAZU
		BYTE	002H,002H,002H,001H
		BYTE	003H,003H,003H,001H
		BYTE	003H,003H,003H,001H
;
;
;
BUBUUSD		EQU	$
		BYTE	002H,002H,000H,000H		;OAMSB
		BYTE	002H,002H,000H,000H
		BYTE	000H,002H,002H,000H
		BYTE	002H,002H,000H,000H
;
		BYTE	000H,002H,002H,000H
		BYTE	000H,002H,002H,000H
		BYTE	000H,002H,002H,000H
		BYTE	002H,002H,000H,000H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	002H,002H,000H,000H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	002H,002H,000H,000H
;
BUBUUCS		EQU	$
		JSR	OAMCHK
;
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ADC	ENCHPT,X
		TAY
		LDA	BUBUUKD,Y
		STA	<WORKD		;KAZU OBOERU
		STA	<WORKE
		STZ	<WORKF
;
		LDA	ENMUKI,X
		STA	<WORK1
		STZ	<WORK0
		LDA	ENCHPT,X
		STA	<WORK2
		STZ	<WORK3
;
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0
		ASL	A
		ASL	A
		ADC	<WORK2
		ASL	A
		ASL	A
		STA	<WORK6
		ASL	A
		ASL	A
		TAY
;
		LDX	<OAMADR
;
BUBUUC1		EQU	$
		LDA	BUBUUCD,Y
		CLC
		ADC	ENDSXL
		STA	<OAM-OAM,X
		INX
		INX
		INY
		INY
		LDA	BUBUUCD,Y
		ORA	<WORK4
		STA	<OAM-OAM,X
		INX
		INX
		INY
		INY
		DEC	<WORKE
		BPL	BUBUUC1
;
		LDY	<WORK6
;
		LDX	<OSBADR
		LDA	BUBUUSD,Y
		STA	<OAMSB-OAMSB,X
		LDA	BUBUUSD+2,Y
		STA	<OAMSB-OAMSB+2,X
;
		MEM8
		IDX8
		SEP	#00110000B
		PLX
;
		JSL	>SADWSTL		;KAGE SET
;
		LDA	<WORKD
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;
;----------------------------------------
ENXSDN		EQU	$
		LDA	ENXSPD,X
		BEQ	ENXDN10
;
		BPL	ENXDN20
		INC	A
		BRA	ENXDN10
ENXDN20		EQU	$
		DEC	A
ENXDN10		EQU	$
		STA	ENXSPD,X
		RTL
;---------------------------------------
ENYSDN		EQU	$
		LDA	ENYSPD,X
		BEQ	ENYDN10
;
		BPL	ENYDN20
		INC	A
		BRA	ENYDN10
ENYDN20		EQU	$
		DEC	A
ENYDN10		EQU	$
		STA	ENYSPD,X
		RTL
;---------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MURON move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MURONTM		EQU	$
		BYTE	060H,03CH,010H,008H,00CH,010H,00CH,020H
MURONDT		EQU	$
		BYTE	000H,001H,002H,001H,003H,001H,002H,001H
MURONMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MURON00
		PLB
		RTL
MURON00		EQU	$
		JSR	MURONCS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
;
		LDA	ENATCT,X
		BNE	MURON60		;MAKI SET OK?
;
		LDA	MURONTM		;Y
		STA	ENTIM0,X
		STZ	ENCHPT,X
;
MURON60		EQU	$
		LDA	ENTIM0,X
		BNE	MURON10
;
		LDA	ENWRK0,X
		INC	A
		AND	#007H
		STA	ENWRK0,X
		STA	ENATCT,X
		TAY
		LDA	MURONTM,Y
		STA	ENTIM0,X
		LDA	MURONDT,Y
		STA	ENCHPT,X
		BNE	MURON10
		JSL	>MURMKST
;
MURON10		EQU	$
		LDA	ENCHPT,X
		BNE	MURON20
;
		STZ	ENWRK1,X
		STZ	ENWRK2,X
		STZ	ENSTAT,X
;
		LDA	#0FAH
		STA	ENMUKI,X
		STZ	ENCMKI,X
		RTS
;
MURONKI		EQU	$		;MAKI JAMP
		BYTE	006,003
;			0   1
MURON20		EQU	$		;MAKI TOBI
		LDA	<FRCNT
		AND	#003H
		BNE	MURON30
		DEC	ENWRK1,X		;MAKI12 X
MURON30		EQU	$
		LDA	<FRCNT
		AND	#007H
		BNE	MURON40
		INC	ENMUKI,X		;MAKI12 Z
		LDY	ENCMKI,X
		LDA	ENMUKI,X
		CMP	MURONKI,Y
		BNE	MURON40
		LDA	#0FDH
		STA	ENMUKI,X
		LDA	#001H
		STA	ENCMKI,X
MURON40		EQU	$
		LDA	<FRCNT
		AND	#001H
		BNE	MURON50
		LDA	ENSTAT,X		;MAKI2 Y
		SEC
		ADC	ENMUKI,X
		STA	ENSTAT,X
		LDA	ENWRK2,X		;MAKI1 Y
		CLC
		ADC	ENMUKI,X
		DEC	A
		STA	ENWRK2,X
MURON50		EQU	$
		RTS
;----------------------------------------
MURONCD		EQU	$
		BYTE	-022,-001,0C2H,000H
		BYTE	-028,-013,0C4H,000H
		BYTE	-016,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0E6H,000H
		BYTE	0004,0009,0E6H,000H
;
		BYTE	-014,0006,0E4H,000H
		BYTE	0000,0008,0C6H,000H
		BYTE	-014,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0EEH,0C0H
		BYTE	0004,0009,0EEH,000H
;
		BYTE	-015,0005,0E4H,000H
		BYTE	-001,0007,0C6H,000H
		BYTE	-015,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0EEH,0C0H
		BYTE	0004,0009,0EEH,000H
;
		BYTE	-014,0007,0E4H,000H
		BYTE	0000,0009,0C6H,000H
		BYTE	-015,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0EEH,0C0H
		BYTE	0004,0009,0EEH,000H
;
MURONCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
		LDA	ENCLOR,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	ENATCT,X		;MAKI SET ?
		STA	<WORKC
		STZ	<WORKD
;
		LDA	ENWRK1,X		;MAKI1 X
		STA	<WORK2
		LDA	ENWRK2,X		;MAKI1 Y
		STA	<WORK3
		LDA	ENWRK1,X		;MAKI2 X
		EOR	#0FFH
		INC	A
		STA	<WORK4
		LDA	ENSTAT,X		;MAKI2 Y
		STA	<WORK5
;
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
		LDA	#00004H
		STA	<WORKE
;
MUONC10		EQU	$
		LDA	MURONCD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	MURONCD+1,X
		CLC
		ADC	ENDSYL
		STA	OAM-OAM+1,Y
		LDA	MURONCD+2,X
		ORA	<WORK0
		STA	OAM-OAM+2,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	MUONC10
;
		LDA	<WORKC			;MAKI SET OK ?
		BEQ	MUONC20
;						;Y
		LDA	MURONCD,X		;MAKI1
		CLC
		ADC	ENDSXL
		CLC
		ADC	<WORK2
		STA	OAM-OAM,Y
		LDA	MURONCD+2,X
		ORA	<WORK0
		STA	OAM-OAM+2,Y
;
		LDA	MURONCD+4,X		;MAKI2
		CLC
		ADC	ENDSXL
		CLC
		ADC	<WORK4
		STA	OAM-OAM+4,Y
		LDA	MURONCD+6,X
		ORA	<WORK0
		STA	OAM-OAM+6,Y
MUONC20		EQU	$
;
;		LDY	<OSBADR
;
;		LDA	#0202H
;		STA	OAMSB-OAMSB,Y
;		STA	OAMSB-OAMSB+2,Y
;		STA	OAMSB-OAMSB+4,Y
;		STA	OAMSB-OAMSB+5,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#006H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;--------------------------------------
MURMKST		EQU	$			;MAKI HAKOBI SET
		LDA	#MURMK
		JSL	>ENIDSH
		BMI	MRMKS80
;
		TYA
		STA	ENCTFG,X
		TXA
		STA	ENCTFG,Y
;
		LDA	<WORK0
		CLC
		ADC	#00FH
		STA	ENXPSL,Y
;
		LDA	<WORK1
		ADC	#000H
		STA	ENXPSH,Y
;
		LDA	<WORK2
		CLC
		ADC	#080H
		STA	ENYPSL,Y
;
		LDA	<WORK3
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	<WORK4
		STA	ENZPSL,Y
;
		LDA	#000H
		STA	ENMUKI,Y
		STA	ENCHPT,Y
;
MRMKS80		EQU	$
		RTL
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MURYA move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MURYATM		EQU	$
		BYTE	000H,010H,030H,050H
MURYADT		EQU	$
		BYTE	000H,001H,002H,000H
MURYAMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MURYA00
		PLB
		RTL
MURYA00		EQU	$
		JSR	MURYACS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
;
		LDA	<KEYA2
		ROR	A
		AND	#001H
		BEQ	MURYA10		;LEFT ?
;
		LDA	#002H		;Y
		STA	ENMUKI,X
;
MURYA10		EQU	$
		BCC	MURYA20		;RIGHT ?
;
		LDA	#003H		;Y
		STA	ENMUKI,X
;
MURYA20		EQU	$
		LDA	<KEYA2
		AND	#0C0H
		BEQ	MURYA30		; A B ?
;
		INC	ENWRK0,X	;Y
;
MURYA30		EQU	$
		LDA	ENWRK0,X
		BNE	MURYA80
;
		STZ	ENCHPT,X
		STZ	ENTIM0,X
		LDA	#003H
		STA	ENWRK1,X
;
		RTS
;
MURYA80		EQU	$
		LDA	ENTIM0,X
		BNE	MURYA90
;
		LDA	ENWRK1,X
		INC	A
		AND	#003H
		STA	ENWRK1,X
		TAY
		CMP	#003H
		BNE	MURYAA0
		JSR	MURYAST
		DEC	ENWRK0,X
		LDY	ENWRK1,X
MURYAA0		EQU	$
		LDA	MURYATM,Y
		STA	ENTIM0,X
		LDA	MURYADT,Y
		STA	ENCHPT,X
;
MURYA90		EQU	$
		RTS
;----------------------------------------
MRYSTMK		EQU	$
		BYTE	000H,002H,004H,006H
MURYAST		EQU	$		;YA SET(PLY)
		LDA	ENXPSL,X
		STA	<BMWORK+2
		LDA	ENXPSH,X
		STA	<BMWORK+3
		LDA	ENYPSL,X
		STA	<BMWORK+0
		LDA	ENYPSH,X
		STA	<BMWORK+1
;
		PHX
		LDY	ENMUKI,X
		LDX	MRYSTMK,Y
		LDY	#004H		;KAZU
		LDA	#YAMOV
		JSL	>YAIMIT
		PLX
		RTS
;----------------------------------------
MURYACD		EQU	$
		BYTE	-002,0008,0E3H,000H
		BYTE	-002,0016,0E3H,080H
		BYTE	0000,0000,0ECH,000H
		BYTE	0000,0012,0EAH,000H
		BYTE	-010,0009,0E1H,000H;D
		BYTE	0004,0009,0E6H,000H;D
;
		BYTE	-007,0011,03BH,045H
		BYTE	0001,0012,038H,045H
		BYTE	-004,0008,0E3H,000H
		BYTE	-004,0016,0E3H,080H
		BYTE	0000,0000,0ECH,000H
		BYTE	-001,0011,0A6H,000H
;
		BYTE	-003,0011,03BH,045H
		BYTE	0005,0012,038H,045H
		BYTE	-004,0008,0CEH,000H
		BYTE	0000,0000,0ECH,000H
		BYTE	0000,0012,0EAH,000H
		BYTE	0004,0009,0EEH,0C0H;D
;
;
		BYTE	0010,0008,0E3H,040H
		BYTE	0010,0016,0E3H,0C0H
		BYTE	0000,0000,0ECH,040H
		BYTE	0000,0012,0EAH,040H
		BYTE	-010,0009,0E1H,040H;D
		BYTE	0004,0009,0E6H,040H;D
;
		BYTE	0015,0012,03BH,005H
		BYTE	0007,0012,038H,005H
		BYTE	0012,0008,0E3H,040H
		BYTE	0012,0016,0E3H,0C0H
		BYTE	0000,0000,0ECH,040H
		BYTE	0001,0012,0A6H,040H
;
		BYTE	0012,0012,03BH,005H
		BYTE	0004,0012,038H,005H
		BYTE	0004,0008,0CEH,040H
		BYTE	0000,0000,0ECH,040H
		BYTE	0000,0012,0EAH,040H
		BYTE	0004,0009,0EEH,080H;D
;
;
MRYACKD		EQU	$
		BYTE	003H,005H,004H
;
;
MURYASD		EQU	$
		BYTE	000H,000H,002H,002H,002H,002H
		BYTE	000H,000H,000H,000H,002H,002H
		BYTE	000H,000H,002H,002H,002H,002H
MURYACS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
                LDY     ENCHPT,X
                LDA     MRYACKD,Y
                STA     <WORK2
		TYA
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		STA	<WORK7
		STZ	<WORK8
;
                LDA     ENCLOR,X
                STA     <WORK1
                STZ     <WORK0
                LDA     ENMUKI,X
		AND	#001H
                STA     <WORK3
                STZ     <WORK4
                LDA     ENCHPT,X
                STA     <WORK5
                STZ     <WORK6
;
                PHX
                MEM16
                IDX16
                REP     #00110000B
;
                LDA     <WORK3
                ASL     A
                ASL     A
                ADC     <WORK5
                ASL     A
                ADC     <WORK3
                ADC     <WORK5
                ASL     A
                ASL     A
                ASL     A
                TAX
;
                LDA     <WORK2
                AND     #000FFH
                STA     <WORKE
;
                LDY     <OAMADR
MUYAC10		EQU	$
		LDA	MURYACD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	MURYACD+2,X
		EOR	<WORK0
		STA	OAM-OAM+2,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	MUYAC10
;
                LDX     <WORK7
;
                LDY     <OSBADR
                LDA     MURYASD,X
                STA     OAMSB-OAMSB,Y
                LDA     MURYASD+2,X
                STA     OAMSB-OAMSB+2,Y
                LDA     MURYASD+4,X
                STA     OAMSB-OAMSB+4,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	<WORK2
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MURMK move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MURMKDT		EQU	$-1
		BYTE	000H,004H,000H,005H
MURMKTT		EQU	$-1
		BYTE	0C8H,028H,0FFH,000H
;
MURMKMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MURMK00
		PLB
		RTL
MURMK00		EQU	$
		JSR	MURMKCS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
;
		LDA	ENTIM0,X	;TIME ?
		BNE	MURMK10
;
		INC	ENWRK0,X	;NEXT MODE
		LDY	ENWRK0,X
		LDA	MURMKDT,Y
		STA	ENSTAT,X
		LDA	MURMKTT,Y
		STA	ENTIM0,X
;
MURMK10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
;
		WORD	MURMKM0		;UP MOVE
		WORD	MURMKM1		;DOWN
		WORD	MURMKM2		;LEFT
		WORD	MURMKM3		;RIGHT
		WORD	MURMKM4		;MAKI SET
		WORD	MURMKM5		;KILL I
;----------------------------------------
MRMKSXD		EQU	$
		BYTE	000,000,-10,010
MRMKSYD		EQU	$
		BYTE	-10,010,000,000
MURMKM0		EQU	$
MURMKM1		EQU	$
MURMKM2		EQU	$
MURMKM3		EQU	$
		LDA	ENSTAT,X
		STA	ENMUKI,X
		TAY
		LDA	MRMKSXD,Y
		STA	ENXSPD,X
		LDA	MRMKSYD,Y
		STA	ENYSPD,X
		JSR	ENMVCL		; xclc,yclc
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001
		STA	ENCHPT,X
		RTS
;----------------------------------------
MURMKM4		EQU	$		;MAKI SET
		LDA	#002H		;MUKI
		STA	ENMUKI,X
;
		LDY	ENCTFG,X
		LDA	#001H
		STA	ENATCT,Y
;
		RTS
;----------------------------------------
MURMKM5		EQU	$		;KILL I
		STZ	ENMODE,X
		RTS
;----------------------------------------
MURMKCD		EQU	$
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,000H
;
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,040H
;
;
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,000H
;
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,040H
;
;
		BYTE	000H,000H,0ECH,000H
		BYTE	000H,008H,0C8H,000H
;
		BYTE	000H,000H,0ECH,000H
		BYTE	000H,008H,0C8H,000H
;
;
		BYTE	000H,000H,0ECH,040H
		BYTE	000H,008H,0C8H,040H
;
		BYTE	000H,000H,0ECH,040H
		BYTE	000H,008H,0C8H,040H
;
;
MURMKCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
;
		LDA	ENMUKI,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
;
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
;
		LDY	<OAMADR
;
		LDA	#00001
		STA	<WORK0
MURMC10		EQU	$
		LDA	ENDSXL
		CLC
		ADC	MURMKCD,X
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		LDA	MURMKCD,X
		ORA	<WORK4
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		DEC	<WORK0
		BPL	MURMC10
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;---------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BABA1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BABA1MV		EQU	$
		PHB
		PHK
		PLB
		JSR	BABA100
		PLB
		RTL
BABA100		EQU	$
		JSR	BABA1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#000H		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		STA	ENWRK0,X	; PL. miru!
		STA	ENMUKI,X	; PL. miru!
		BCC	BABA110		;
		STZ	ENSTAT,X	; PL. miru!
;
BABA110		EQU	$
		JMP	MURAAMV
;
		RTS
;--------------------------------------
BABA1HD		EQU	$
		BYTE	000H,000H,0E0H,000H ;0
		BYTE	000H,000H,0C0H,000H ;1
		BYTE	000H,000H,0E2H,000H ;2
		BYTE	000H,000H,0E2H,040H ;3
;
BABA1BD		EQU	$
		BYTE	000H,008H,0E8H,000H ;0
		BYTE	000H,008H,0E8H,040H ;0
		BYTE	000H,008H,0C2H,000H ;1
		BYTE	000H,008H,0C2H,040H ;1
		BYTE	000H,008H,0E4H,000H ;2
		BYTE	000H,008H,0E6H,000H ;2
		BYTE	000H,008H,0E4H,040H ;3
		BYTE	000H,008H,0E6H,040H ;3
;
BABA1CS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
		LDA	ENMUKI,X
		STA	<WORK2
		STZ	<WORK3
		LDA	ENCHPT,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	<GAMEMD
		BNE	BAB1C10
		LDA	ENSTAT,X
		BNE	BAB1C10
		TXA			;UP DOWN
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		CLC
		ADC	ENDSYL
		STA	ENDSYL
;
BAB1C10		EQU	$
		LDA	ENWRK0,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	BABA1HD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	BABA1HD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
;
		LDA	<WORK2
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		TAX
;
		LDA	BABA1BD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	BABA1BD+2,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	YOSEI move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
YOSXSPD         EQU     $
                BYTE    001H,0FFH
                BYTE    002H,0FEH
;
YOSYSPD         EQU     $
                BYTE    001H,0FFH
                BYTE    002H,0FEH
;
YOSXSLM         EQU     $
                BYTE    010H,0F1H
                BYTE    010H,0F1H
;
YOSYSLM         EQU     $
                BYTE    010H,0F1H
                BYTE    010H,0F1H
;
YOSEIMJ		EQU	$
		PHB
		PHK
		PLB
		JSR	YOSEI00
		PLB
		RTL
YOSEI00		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		JSR	ENMVCL		;xclc,yclc
		JSR	ENZCLC		;zclc
;
		TXA
		EOR	<FRCNT
		AND	#003H
		BEQ	YOSEIC0
		RTS
YOSEIC0		EQU	$
		JSL	>RNDSET
		AND	#03FH
		BNE	YOSEIB0
		LDA	ENWRK2,X
		EOR	#002H
		STA	ENWRK2,X
		JSL	>RNDSET
		AND	#001H
		STA	ENWRK0,X
		JSL	>RNDSET
		AND	#001H
		STA	ENMUKI,X
YOSEIB0		EQU	$
;
		LDA	ENWRK0,X	;X SPD SET
		ORA	ENWRK2,X
		TAY
		AND	#001H
		BEQ	YOSEI10
;
		LDA	ENXSPD,X
		BPL	YOSEI20
		CMP	YOSXSLM,Y
		BCC	YOSEI30
		BRA	YOSEI20
;
YOSEI10		EQU	$
		LDA	ENXSPD,X
		BMI	YOSEI20
		CMP	YOSXSLM,Y
		BCS	YOSEI30
		BRA	YOSEI20
;
YOSEI30		EQU	$
		LDA	ENWRK0,X
		EOR	#001H
		STA	ENWRK0,X
		BRA	YOSEI40
;
YOSEI20		EQU	$
		CLC
		ADC	YOSXSPD,Y
		STA	ENXSPD,X
;
YOSEI40		EQU	$
		LDA	ENMUKI,X	;Y SPD SET
		ORA	ENWRK2,X
		TAY
		AND	#001H
		BEQ	YOSEI50
;
		LDA	ENYSPD,X
		BPL	YOSEI60
		CMP	YOSYSLM,Y
		BCC	YOSEI70
		BRA	YOSEI60
;
YOSEI50		EQU	$
		LDA	ENYSPD,X
		BMI	YOSEI60
		CMP	YOSYSLM,Y
		BCS	YOSEI70
		BRA	YOSEI60
;
YOSEI70		EQU	$
		LDA	ENMUKI,X
		EOR	#001H
		STA	ENMUKI,X
		BRA	YOSEI80
;
YOSEI60		EQU	$
		CLC
		ADC	YOSYSPD,Y
		STA	ENYSPD,X
;
YOSEI80		EQU	$
		LDA	ENZPSL,X
		BMI	YOSEI90
		CMP	#005H
		BCC	YOSEI90
		DEC	ENZSPD,X
		BRA	YOSEIA0
YOSEI90		EQU	$
		INC	ENZSPD,X
YOSEIA0		EQU	$
		RTS
;--------------------------------------
;---------------------------------------
;---------------------------------------
;---------------------------------------
;---------------------------------------
EPXYCK		EQU	$
		JSR	EPXCHK
		STY	<WORK0
		JSR	EPYCHK
		STY	<WORK1
		LDA	<WORKE
		BPL	EXY000
		EOR	#0FFH
		INC	A
EXY000		EQU	$
		STA	ENHELP
		LDA	<WORKF
		BPL	EXY010
		EOR	#0FFH
		INC	A
EXY010		EQU	$
		CMP	ENHELP
		BCC	EXY020
		LDY	<WORK0
		RTS
EXY020		EQU	$
		LDA	<WORK1
		INC	A
		INC	A
		TAY
		RTS
;================================================================
EPXCHK		EQU	$
		LDY	#00H
		LDA	<PLXPS1
		SEC
		SBC	ENXPSL,X
		STA	    <WORKF
		LDA	<PLXPS0
		SBC	ENXPSH,X
		BPL	EPX010
		INY
EPX010		EQU	$
		RTS
;
;=================================================================
EPYCHK		EQU	$
		LDY	#00H
		LDA	<PLYPS1
         	CLC
		ADC	ENZPSL,X
		PHP
		SEC
		SBC	ENYPSL,X
		STA	<WORKE
		LDA	<PLYPS0
		SBC	ENYPSH,X
		PLP
		ADC	#00H
		BPL	EPY010
		INY
EPY010		EQU	$
		RTS
;================================================================
EEXCHK		EQU	$
		LDY	#00H
		LDA	<WORK4
		SEC
		SBC	ENXPSL,X
		STA	<WORKF
		LDA	<WORK5
		SBC	ENXPSH,X
		BPL	EEX010
		INY
EEX010		EQU	$
		RTS
;================================================================
EEYCHK		EQU	$   
        	LDY	#00H
		LDA	<WORK6
		SEC
		SBC	ENYPSL,X
		STA	<WORKE
		LDA	<WORK7
		SBC	ENYPSH,X
		BPL	EEY010
		INY
EEY010		EQU	$
		RTS
;========================================================
PLHNCK		EQU	$
;;			TXA
;;			EOR		<FRCNT
;;			AND		#07H
		LDA	ENDSPL,X
		BNE	PLHN10
;
;;;			STZ		HANIFG
;
		JSR	EPXYCK
		STY	<WORK0
;;			JSR		EPXCHK
		LDA	<WORKF
		CLC
		ADC	#30H
		CMP	#60H
		BCS	PLHN10
;;			JSR		EPYCHK
		LDA	<WORKE
		CLC
		ADC	#30H
		CMP	#60H
		BCS	PLHN10		; Player atack area ?
;;;;			JSR		EPXYCK		; yes !
;
;;		LDY	<WORK0
;;		LDA	PLMKCK,Y
;;		CMP	PLMKCH
;;		BNE	PLHN10		; Muki ok ?
;								; yes !
		INC	HANIFG		; Player in !
PLHN10		EQU	$
		RTS
;===========================================
ENSTCK		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	ESTC08
ENSTCK2		EQU	$
		JSR	PLHNCK		; player hani flag set 
;
		LDA	ENSTFG
		BNE	ESTC08		; enemy all stop !
;
		LDA	<GAMEMD
		BEQ	ESTC10		; game stop ?
ESTC08		EQU	$
		PLA			; yes ! don't sub return 
		PLA
ESTC10		EQU	$
		RTS
;=====================================================
TNHNTM		EQU	$
		BYTE	03,01,00,00
ENHNSB		EQU	$	; for Knight 
		LDA	ENHNFG,X
		BEQ	ENHB90
;
		LDA	ENYSPD,X
		PHA
		LDA	ENXSPD,X
		PHA
		DEC	ENHNFG,X
		LDA	ENHNFG,X
		LSR 	A
		LSR 	A
		LSR 	A
		TAY
		LDA	<FRCNT
		AND	TNHNTM,Y
		BNE	ENHB08																
		LDA	ENHNYS,X
		STA	ENYSPD,X
		LDA	ENHNXS,X
		STA	ENXSPD,X
;
		LDA	ENMOD4,X
		BMI	ENHB10		; BG check ?
; 					; Yes !
 		JSL	>ENBGCKL
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	ENHB10
;
		STZ	ENHNFG,X
		BRA	ENHB08
ENHB10		EQU	$
		JSR	ENMVCL
ENHB08		EQU	$
		PLA
		STA	ENXSPD,X
		PLA
		STA	ENYSPD,X
		PLA
		PLA
ENHB90		EQU	$
		RTS
;=========================================================
ENMVCL		EQU	$
;;;;;		LDA	ENHNFG,X
;;;;;		BNE	ENMC00
;
		JSR	ENXCLC
		JSR	ENYCLC
ENMC00		EQU	$
		RTS
;
ENXCLC		EQU	$
		TXA
		CLC
		ADC	#10H
		TAX
		JSR	ENYCLC
		LDX	ENINDX
		    RTS
;============================================
ENYCLC		EQU	    $
		LDA	ENYSPD,X
		BEQ	EYCRTS
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENYSDR,X
		STA	ENYSDR,X
;
		LDA	ENYSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDY	#00H
		PLP
		BPL	ENCY60
;
		ORA	#11110000B
		DEY
ENCY60		EQU	$
		ADC	ENYPSL,X
		STA	ENYPSL,X
;
		TYA
		ADC	ENYPSH,X
		STA	ENYPSH,X
EYCRTS		EQU	$
		RTS
;============================================
ENZCLC		EQU	    $
		LDA	ENZSPD,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENZSDR,X
		STA	ENZSDR,X
;
		LDA	ENZSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		PLP
		BPL	ENCZ60
;
		ORA	#11110000B
ENCZ60		EQU	$
		ADC	ENZPSL,X
		STA	ENZPSL,X
;
		RTS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;OAMCHK		EQU	$
;		STZ	ENDSPL,X
;		LDA	ENYPSL,X
;		SEC
;		SBC	ENZPSL,X
;		SEC
;		SBC	<SCCV2
;		STA	ENDSYL
;;
;               LDA     ENYPSL,X
;               CLC
;                ADC     #10H
;                PHP
;                SEC
;                SBC     ENZPSL,X
;                PHP
;                SEC
;                SBC     <SCCV2
;                LDA     ENYPSH,X
;                SBC     <SCCV21
;                PLP
;                SBC     #00H
;                PLP
;                ADC     #00H
;		BEQ 	OMCK10
;
;OMCK0F		EQU	$
;		PLA
;		PLA
;		BRA	OMCK18
;OMCK10		EQU	$
;		LDA	ENXPSH,X
;		XBA
;		LDA	ENXPSL,X
;		MEM16
;		REP	#00100000B
;		SEC
;		SBC	<SCCH2
;		CLC
;		ADC	#0040H
;		CMP	#0180H
;		MEM8
;		SEP	#00100000B
;		BCS	OMCK0F
;;
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		STA	ENDSXL
;		LDA	ENXPSH,X
;		SBC	<SCCH21
;		BEQ	OMCK20
;OMCK18		EQU	$
;		INC	ENDSPL,X
;OMCK20		EQU	$
;;;;		LDY	ENOMID,X
;;		LDY	#00H
;;		RTS
;		BRA	OMCS20
;-----------------------------------------------------
;OAMCHKS		EQU	$
;		STZ	ENDSPL,X
;		LDA	ENYPSL,X
;		SEC
;		SBC	ENZPSL,X
;		CLC
;		ADC	#04H
;		SEC
;		SBC	<SCCV2
;		STA	ENDSYL
;;
;                LDA     ENYPSL,X
;                CLC
;                ADC     #14H
;                PHP
;                SEC
;                SBC     ENZPSL,X
;                PHP
;                SEC
;                SBC     <SCCV2
;                LDA     ENYPSH,X
;                SBC     <SCCV21
;                PLP
;                SBC     #00H
;                PLP
;                ADC     #00H
;		BEQ 	OMCS10
;OMCS0F		EQU	$
;		PLA
;		PLA
;		BRA	OMCS18
;OMCS10		EQU	$
;		LDA	ENXPSH,X
;		XBA
;		LDA	ENXPSL,X
;		MEM16
;		REP	#00100000B
;		SEC
;		SBC	<SCCH2
;		CLC
;		ADC	#0040H
;		CMP	#0180H
;		MEM8
;		SEP	#00100000B
;		BCS	OMCS0F
;;
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		PHP
;		CLC
;		ADC	#04H
;		STA	ENDSXL
;		LDA	ENXPSH,X
;		ADC	#00H
;		PLP
;		SBC	<SCCH21
;		BEQ	OMCS20
;OMCS18		EQU	$
;		INC	ENDSPL,X
;OMCS20		EQU	$
;;;		LDY	ENOMID,X
;		LDY	#00H 
;		LDA	ENCLOR,X
;		STA	<WORK3
;		STZ	<WORK2
;		RTS
;----------------------------------------
EVCHCKE		EQU	$		;UNIT CHK
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		SEC
		SBC	!GCCKY0
		AND	!GCCKY1
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK6
;
		LDA	<WORK2
		SEC
		SBC	!GCCKX0
		AND	!GCCKX1
		CLC
		ADC	<WORK6
;// 02.12.11 //		CMP	#01000H
;// 02.12.11 //		BCC	EVCK40		; buffer-0 ?
;// 02.12.11 //;					; no
;// 02.12.11 //		SBC	#01000H
;// 02.12.11 //		ORA	#02000H
;// 02.12.11 //EVCK40		EQU	$
		TAX
		LDA	>GDBUF0,X
		TAX
		LDA	>GRNDCHK,X
		MEM8
		IDX8
		SEP	#00110000B
		RTL
;----------------------------------------
GRNDCHK		EQU	$
		BYTE	001H,001H,001H,002H,002H,002H,002H,001H
		BYTE	001H,001H,001H,001H,001H,001H,002H,002H
		BYTE	001H,002H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,002H,001H,001H
		BYTE	001H,001H,002H,002H,001H,002H,002H,001H
		BYTE	001H,002H,001H,001H,001H,001H,001H,002H
		BYTE	002H,001H,002H,002H,002H,002H,002H,002H
		BYTE	048H,048H,048H,002H,050H,002H,002H,001H
		BYTE	048H,048H,002H,048H,002H,002H,002H,000H
		BYTE	002H,002H,048H,002H,002H,002H,001H,002H
		BYTE	001H,000H,002H,002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,001H,001H,001H,001H
		BYTE	001H,001H,001H,000H,001H,002H,048H,002H
		BYTE	002H,002H,048H,048H,002H,002H,048H,002H
		BYTE	001H,002H,048H,002H,002H,048H,002H,002H
		BYTE	002H,002H,002H,001H,001H,001H,048H,048H
		BYTE	048H,002H,001H,001H,002H,002H,001H,002H
		BYTE	002H,002H,001H,001H,000H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H,002H,001H,002H
		BYTE	002H,048H,048H,002H,002H,002H,002H,001H
		BYTE	002H,002H,048H,000H,048H,000H,000H,048H
		BYTE	000H,000H,000H,000H,048H,001H,048H,048H
		BYTE	000H,048H,048H,000H,000H,000H,048H,001H
		BYTE	048H,001H,001H,048H,001H,048H,048H,048H
		BYTE	001H,001H,001H,001H,001H,002H,001H,02AH
		BYTE	011H,001H,001H,001H,001H,001H,001H,002H
		BYTE	000H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,002H,002H,001H,001H,001H,001H
		BYTE	002H,02DH,029H,000H,001H,001H,001H,001H
		BYTE	001H,002H,001H,002H,002H,002H,002H,002H
		BYTE	002H,002H,011H,001H,002H,002H,002H,002H
		BYTE	002H,002H,048H,048H,001H,001H,048H,002H
		BYTE	002H,001H,001H,001H,048H,002H,002H,001H
		BYTE	002H,002H,002H,002H,001H,001H,001H,002H
		BYTE	001H,001H,001H,001H,002H,002H,002H,001H
		BYTE	001H,001H,002H,001H,001H,048H,002H,002H
		BYTE	048H,048H,001H,002H,001H,048H,048H,001H
		BYTE	001H,001H,001H,001H,001H,048H,002H,048H
		BYTE	002H,002H,002H,002H,002H,002H,048H,048H
		BYTE	002H,054H,000H,048H,013H,01BH,01BH,000H
		BYTE	048H,001H,048H,013H,048H,048H,002H,048H
		BYTE	001H,02CH,001H,000H,002H,001H,002H,020H
		BYTE	001H,001H,002H,020H,002H,002H,000H,001H
		BYTE	002H,002H,000H,000H,001H,000H,000H,002H
		BYTE	001H,001H,002H,002H,002H,002H,001H,002H
		BYTE	000H,000H,001H,001H,001H,002H,001H,000H
		BYTE	001H,002H,002H,001H,002H,002H,002H,002H
		BYTE	002H,002H,002H,001H,002H,001H,048H,000H
		BYTE	000H,000H,002H,002H,048H,029H,048H,002H
		BYTE	02FH,02DH,002H,002H,002H,002H,001H,018H
		BYTE	002H,001H,002H,02DH,001H,001H,02AH,048H
		BYTE	048H,013H,01BH,02CH,02CH,04FH,002H,04FH
		BYTE	001H,04FH,001H,018H,018H,02BH,001H,002H
		BYTE	008H,008H,002H,002H,002H,001H,002H,001H
		BYTE	000H,000H,001H,002H,02FH,000H,000H,02DH
		BYTE	001H,001H,000H,000H,000H,000H,001H,000H
		BYTE	000H,001H,002H,002H,002H,011H,018H,002H
		BYTE	02AH,018H,008H,008H,002H,002H,022H,002H
		BYTE	022H,001H,002H,02AH,008H,008H,008H,02AH
		BYTE	008H,008H,002H,002H,008H,008H,008H,01BH
		BYTE	019H,000H,028H,002H,002H,002H,028H,048H
		BYTE	000H,048H,048H,001H,000H,048H,012H,048H
		BYTE	002H,02EH,001H,002H,048H,048H,000H,001H
		BYTE	001H,002H,000H,000H,008H,048H,048H,028H
		BYTE	002H,002H,048H,001H,002H,002H,002H,002H
		BYTE	001H,002H,002H,048H,000H,000H,048H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,002H,002H,002H,002H,000H,001H
		BYTE	002H,048H,048H,02FH,048H,001H,002H,001H
		BYTE	048H,000H,000H,048H,048H,052H,000H,000H
		BYTE	002H,000H,000H,000H,048H,048H,013H,002H
		BYTE	01BH,002H,001H,001H,001H,001H,002H,002H
		BYTE	001H,001H,001H,002H,002H,002H,002H,001H
		BYTE	001H,002H,002H,001H,02BH,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,002H,001H,001H,001H,002H,002H
		BYTE	002H,022H,022H,002H,002H,02BH,013H,002H
		BYTE	002H,002H,002H,002H,048H,048H,048H,040H
		BYTE	002H,002H,048H,048H,048H,001H,048H,02DH
		BYTE	048H,048H,048H,048H,02BH,029H,02FH,002H
		BYTE	001H,002H,002H,000H,048H,002H,001H,002H
		BYTE	001H,002H,002H,002H,048H,048H,000H,001H
		BYTE	001H,048H,012H,02FH,011H,002H,028H,028H
		BYTE	048H,048H,012H,001H,001H,01BH,02CH,001H
		BYTE	01BH,002H,048H,02AH,001H,018H,02AH,011H
		BYTE	002H,02AH,02AH,02AH,002H,012H,048H,001H
		BYTE	013H,013H,001H,048H,012H,048H,048H,048H
		BYTE	02BH,048H,048H,048H,048H,002H,029H,002H
		BYTE	01BH,002H,02FH,048H,002H,002H,002H,001H
		BYTE	048H,002H,048H,000H,000H,000H,000H,002H
		BYTE	048H,000H,048H,013H,001H,000H,000H,001H
		BYTE	000H,001H,002H,002H,002H,000H,000H,02AH
		BYTE	02AH,001H,002H,001H,001H,001H,002H,002H
		BYTE	002H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,002H,002H,001H
		BYTE	028H,001H,001H,002H,002H,002H,002H,002H
		BYTE	002H,002H,001H,000H,000H,002H,002H,001H
		BYTE	002H,000H,002H,002H,002H,002H,002H,001H
		BYTE	002H,001H,001H,002H,001H,001H,001H,002H
		BYTE	002H,001H,002H,001H,002H,048H,001H,001H
		BYTE	001H,002H,002H,002H,002H,002H,002H,002H
		BYTE	048H,002H,022H,048H,000H,000H,000H,000H
		BYTE	002H,002H,001H,001H,001H,001H,002H,001H
		BYTE	000H,000H,002H,002H,001H,001H,001H,001H
		BYTE	002H,001H,002H,001H,002H,001H,002H,002H
		BYTE	002H,001H,001H,001H,002H,002H,002H,002H
		BYTE	002H,022H,002H,048H,000H,048H,000H,000H
		BYTE	000H,002H,002H,002H,002H,002H,000H,000H
		BYTE	000H,002H,002H,002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H,002H,002H,002H
		BYTE	001H,001H,001H,001H,048H,001H,001H,001H
		BYTE	001H,001H,001H,001H,022H,001H,001H,001H
		BYTE	001H,001H,001H,001H,048H,002H,000H,000H
		BYTE	001H,001H,048H,002H,001H,048H,018H,048H
		BYTE	048H,048H,048H,048H,000H,000H,000H,000H
		BYTE	048H,048H,013H,001H,002H,048H,000H,000H
		BYTE	000H,000H,000H,001H,002H,002H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H,000H,000H
		BYTE	000H,001H,001H,001H,048H,000H,048H,001H
		BYTE	002H,002H,028H,001H,002H,001H,013H,001H
		BYTE	019H,002H,001H,012H,000H,002H,001H,001H
		BYTE	002H,002H,002H,001H,002H,002H,002H,002H
		BYTE	002H,002H,000H,002H,002H,002H,002H,001H
		BYTE	002H,002H,002H,000H,02AH,001H,001H,001H
		BYTE	002H,000H,000H,000H,001H,000H,013H,001H
		BYTE	001H,002H,001H,001H,022H,000H,028H,001H
		BYTE	029H,001H,002H,002H,002H,001H,000H,008H
		BYTE	029H,001H,001H,001H,001H,001H,001H,001H
		BYTE	000H,001H,000H,001H,001H,000H,000H,002H
		BYTE	000H,000H,000H,002H,000H,002H,002H,000H
		BYTE	002H,001H,001H,001H,000H,002H,001H,000H
		BYTE	001H,001H,000H,048H,048H,048H,048H,048H
		BYTE	048H,048H,048H,000H,000H,000H,000H,048H
		BYTE	002H,002H,048H,001H,001H,048H,048H,001H
		BYTE	002H,002H,048H,002H,002H,048H,048H,002H
		BYTE	002H,022H,048H,048H,048H,048H,001H,001H
		BYTE	001H,048H,048H,001H,001H,001H,048H,048H
		BYTE	001H,001H,001H,048H,001H,001H,001H,001H
		BYTE	002H,001H,001H,013H,001H,001H,002H,001H
		BYTE	002H,001H,001H,001H,002H,048H,002H,002H
		BYTE	002H,002H,001H,048H,012H,048H,029H,002H
		BYTE	001H,002H,001H,002H,001H,002H,002H,001H
		BYTE	001H,002H,002H,001H,001H,001H,002H,001H
		BYTE	001H,013H,048H,002H,048H,048H,048H,048H
		BYTE	000H,000H,000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,008H,000H,008H,008H,008H
		BYTE	002H,002H,048H,048H,048H,048H,028H,001H
		BYTE	000H,000H,000H,048H,000H,001H,000H,000H
		BYTE	000H,000H,000H,001H,048H,02FH,048H,048H
		BYTE	000H,000H,048H,048H,048H,048H,000H,000H
		BYTE	048H,000H,000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,048H,000H,000H,001H
		BYTE	048H,002H,002H,002H,012H,002H,002H,002H
		BYTE	002H,011H,002H,018H,048H,000H,000H,002H
		BYTE	001H,048H,001H,002H,002H,011H,048H,028H
		BYTE	048H,048H,028H,002H,000H,048H,048H,050H
		BYTE	048H,048H,002H,002H,048H,048H,048H,048H
		BYTE	002H,048H,002H,001H,001H,001H,048H,002H
		BYTE	048H,002H,001H,001H,001H,048H,048H,002H
		BYTE	001H,001H,001H,048H,048H,048H,002H,001H
		BYTE	048H,000H,048H,048H,048H,000H,002H,048H
		BYTE	000H,048H,001H,002H,001H,008H,002H,002H
		BYTE	02FH,000H,01BH,048H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,002H
		BYTE	002H,002H,002H,054H,000H,000H,02FH,002H
		BYTE	02AH,013H,002H,002H,002H,001H,002H,048H
		BYTE	002H,02FH,02FH,001H,000H,000H,000H,002H
		BYTE	048H,000H,002H,002H,000H,000H,02AH,001H
		BYTE	001H,002H,001H,001H,001H,001H,001H,002H
		BYTE	001H,001H,001H,002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,01BH,002H,018H,011H,002H
		BYTE	000H,029H,029H,02FH,02FH,018H,02FH,018H
		BYTE	02CH,001H,001H,02BH,001H,001H,001H,02AH
		BYTE	001H,048H,048H,000H,048H,02BH,001H,02CH
		BYTE	002H,002H,001H,02AH,001H,001H,001H,000H
		BYTE	001H,000H,001H,001H,001H,002H,002H,001H
		BYTE	002H,001H,022H,022H,048H,048H,000H,000H
		BYTE	048H,029H,029H,048H,000H,001H,02FH,001H
		BYTE	02DH,000H,000H,02EH,018H,001H,001H,000H
		BYTE	050H,048H,02EH,018H,048H,001H,048H,048H
		BYTE	000H,040H,040H,000H,001H,001H,000H,040H
		BYTE	000H,02EH,001H,001H,000H,001H,048H,048H
		BYTE	02CH,001H,048H,048H,001H,02CH,001H,048H
		BYTE	002H,002H,000H,048H,002H,002H,048H,048H
		BYTE	02AH,001H,001H,02BH,001H,001H,048H,001H
		BYTE	001H,002H,002H,002H,001H,001H,001H,000H
		BYTE	000H,002H,002H,001H,001H,001H,002H,028H
		BYTE	048H,001H,002H,019H,019H,018H,001H,000H
		BYTE	001H,001H,001H,002H,001H,001H,000H,001H
		BYTE	001H,001H,001H,001H,001H,001H,000H,001H
		BYTE	001H,001H,002H,002H,000H,002H,002H,000H
		BYTE	000H,000H,000H,000H,012H,000H,000H,000H
		BYTE	02EH,000H,02DH,029H,019H,001H,001H,018H
		BYTE	001H,001H,01AH,028H,048H,000H,000H,000H
		BYTE	000H,000H,000H,000H,02AH,052H,048H,048H
		BYTE	001H,002H,002H,002H,002H,001H,001H,001H
		BYTE	002H,048H,001H,001H,001H,048H,012H,048H
		BYTE	002H,002H,001H,001H,001H,002H,002H,012H
		BYTE	001H,001H,002H,02BH,001H,029H,019H,001H
		BYTE	048H,048H,048H,000H,048H,002H,002H,000H
		BYTE	002H,002H,000H,000H,048H,048H,048H,000H
		BYTE	001H,001H,001H,001H,001H,001H,001H,013H
		BYTE	001H,001H,048H,048H,000H,000H,001H,001H
		BYTE	002H,002H,048H,048H,048H,002H,002H,002H
		BYTE	002H,048H,048H,002H,002H,000H,001H,002H
		BYTE	000H,001H,028H,02AH,048H,048H,001H,000H
		BYTE	000H,02AH,001H,001H,001H,001H,002H,001H
		BYTE	001H,001H,000H,002H,02FH,000H,000H,000H
		BYTE	000H,000H,002H,002H,048H,002H,002H,000H
		BYTE	002H,01BH,000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H,000H,000H
		BYTE	000H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,000H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,020H,020H,020H,020H,020H
		BYTE	002H,002H,002H,002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H,002H,002H,002H
		BYTE	002H,022H,000H,002H,002H,002H,002H,002H
		BYTE	002H,022H,000H,002H,000H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H,000H,000H,002H
		BYTE	002H,002H,002H,002H,002H,000H,002H,002H
		BYTE	002H,000H,000H,002H,002H,001H,001H,001H
		BYTE	001H,002H,000H,002H,002H,001H,001H,001H
		BYTE	002H,002H,000H,002H,002H,000H,048H,048H
		BYTE	002H,002H,002H,001H,001H,001H,002H,002H
		BYTE	000H,000H,001H,001H,001H,001H,002H,002H
		BYTE	040H,040H,002H,002H,002H,002H,050H,002H
		BYTE	002H,002H,002H,002H,040H,040H,050H,002H
		BYTE	002H,002H,002H,002H,040H,040H,048H,002H
		BYTE	002H,002H,002H,002H,052H,002H,018H,000H
		BYTE	000H,04AH,002H,002H,052H,002H,010H,002H
		BYTE	002H,002H,048H,002H,002H,002H,000H,002H
		BYTE	020H,001H,001H,001H,002H,002H,000H,000H
		BYTE	001H,001H,001H,001H,002H,002H,000H,000H
		BYTE	002H,002H,002H,000H,000H,002H,001H,001H
		BYTE	001H,001H,002H,002H,000H,000H,001H,001H
		BYTE	001H,001H,002H,002H,002H,002H,002H,000H
		BYTE	002H,048H,002H,000H,000H,048H,002H,002H
		BYTE	048H,02BH,001H,001H,001H,002H,002H,002H
		BYTE	02BH,001H,001H,001H,001H,02CH,02DH,02FH
		BYTE	002H,002H,002H,002H,002H,001H,018H,001H
		BYTE	001H,02EH,02CH,04EH,04FH,001H,001H,001H
		BYTE	001H,002H,000H,002H,048H,048H,002H,002H
		BYTE	022H,022H,022H,002H,002H,022H,001H,002H
		BYTE	002H,012H,002H,000H,000H,001H,001H,002H
		BYTE	002H,01AH,048H,000H,000H,002H,022H,022H
		BYTE	022H,000H,002H,010H,010H,002H,002H,002H
		BYTE	048H,000H,000H,002H,002H,001H,002H,002H
		BYTE	002H,002H,000H,002H,002H,001H,001H,001H
		BYTE	002H,000H,001H,001H,001H,001H,002H,002H
		BYTE	002H,000H,002H,001H,001H,001H,002H,002H
		BYTE	000H,001H,001H,001H,001H,002H,002H,002H
		BYTE	000H,002H,002H,002H,002H,002H,002H,022H
		BYTE	000H,002H,002H,002H,002H,002H,002H,022H
		BYTE	000H,048H,002H,002H,002H,002H,002H,002H
		BYTE	000H,000H,002H,002H,002H,002H,002H,002H
		BYTE	000H,002H,002H,001H,002H,000H,002H,002H
		BYTE	001H,001H,001H,002H,002H,000H,002H,048H
		BYTE	002H,001H,001H,001H,002H,002H,000H,000H
		BYTE	001H,001H,001H,001H,002H,002H,040H,040H
		BYTE	000H,002H,002H,050H,002H,002H,002H,002H
		BYTE	040H,040H,050H,002H,002H,002H,002H,002H
		BYTE	040H,040H,048H,002H,002H,002H,052H,002H
		BYTE	018H,000H,000H,04AH,002H,002H,052H,002H
		BYTE	010H,002H,002H,002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H,008H,008H,000H
		BYTE	000H,000H,000H,000H,002H,002H,002H,000H
		BYTE	000H,000H,000H,000H,008H,020H,002H,001H
		BYTE	001H,002H,002H,000H,008H,002H,002H,020H
		BYTE	001H,001H,001H,002H,002H,000H,000H,001H
		BYTE	001H,001H,001H,002H,002H,000H,000H,001H
		BYTE	001H,001H,001H,002H,002H,000H,000H,001H
		BYTE	001H,001H,001H,002H,002H,002H,002H,02BH
		BYTE	001H,001H,001H,001H,002H,002H,002H,02BH
		BYTE	001H,001H,001H,001H,02CH,02DH,02FH,048H
		BYTE	002H,001H,018H,001H,001H,02EH,02CH,04EH
		BYTE	04FH,001H,001H,001H,001H,002H,000H,002H
		BYTE	022H,001H,002H,002H,012H,002H,000H,000H
		BYTE	001H,001H,002H,002H,01AH,048H,000H,000H
		BYTE	048H,000H,010H,010H,002H,002H,002H,048H
		BYTE	000H,000H,002H,002H,001H,002H,002H,002H
		BYTE	002H,000H,001H,001H,001H,001H,002H,002H
		BYTE	002H,000H,001H,001H,001H,001H,002H,002H
		BYTE	002H,000H,001H,001H,001H,001H,002H,002H
		BYTE	002H,000H,001H,001H,001H,001H,002H,002H
		BYTE	002H,000H,002H,002H,002H,002H,002H,002H
		BYTE	048H,000H,000H,048H,002H,000H,002H,000H
		BYTE	002H,001H,002H,002H,001H,000H,001H,002H
		BYTE	000H,000H,04AH,000H,000H,000H,000H,020H
		BYTE	000H,000H,000H,000H,000H,000H,000H,000H
;
		END
