;************************************************************************
;*									*
;*	title name	: "yossy"					*
;*	proccess	: course BG write sub.1				*
;*	file name	: ys_bgsc0					*
;*									*
;************************************************************************
;
;
		SALL
;
;;;;		include		ys_header.inc
;;;;		include		ys_unit.h
;
;
;
;
		include		yst_header.inc
		include		../../../JPN/sfc/ys_unit.h
;
		XALL
;
;
;----------------------------------------------------------------
;-		global symbol					-
;----------------------------------------------------------------
		GLB	BG_FLOOR0,BG_FLOOR1,FLOOR_RND
		GLB	FLORLFT,FLORRIT,FLRLFT_RND,FLR225
		GLB	FLORUPDWN0,FLORUPDWN1
		GLB	KABELFT,KABERIT
		GLB	TBOUST,YBOUST
		GLB	LIFT30,LIFT45,LIFTST,TONNEL,KUMOKUMO
		GLB	WTRWTR,WTRGRND,WTRLAND,WTRROCK,WTRBRIDGEH
		GLB	WTRBRIDGEV,WTRLIFT,WTRKINOKO,WTRHANA
		GLB	YOGAN,YOGAN_KYOTU
		GLB	JNGL_FOOR,JNGL_LEFT,JNGL_RIGHT,JNGL_DORO
		GLB	JNGL_DR_LT,JNGL_DR_RT,JNGL_LDRU,JNGL_LURD
		GLB	JNGL_KS_UP0,JNGL_KS_UP1,JNGL_KUI,JNGL_STNE
		GLB	JNGL_TULU0,JNGL_TULU1,JNGL_WOOD,JNGL_TLUP0
		GLB	JNGL_TLUP1,JNGL_BLOCK0,JNGL_BLOCK1,JNGL_WRTKS
		GLB	JUNGLE_WTR,HN_ATR_HS,YGN_IWA_BIG,YGN_IWA_SML
		GLB	KUSAANAURU60,KUSAANAURD60,TTDOKAN
		GLB	SNOWKUMO,SNOWBOUSD
		GLB	YOGANHARI
		GLB	KABEHBLOCK,KABEVBLOCK,KABEVBLOCK2,KBKABE,KABEUPDWN
		GLB	KABEYOGAN,KABEYUKA_L,KABEYUKA_R,KABEWINDOW
		GLB	BLOKSLM
		GLB	KUSAETABG,KUSABLKBG
		GLB	KABESENROVH,KABESENROS,KABEYUKABOU,KABESAKBOU
		GLB	KUSAHANHAS,KUSAOVHANG
		GLB	KUSAANARD30,KUSAANARD45,KUSAANARD60
		GLB	KUSAANAURU30,KUSAANAURU45,KUSAANAURD30,KUSAANAURD45
		GLB	RED_YLW_GRN,SNOW_BLCK,GIMEN,BGCOIN,FRWR_GIMEN
		GLB	HEKOMU,GOMU
		GLB	GOALYUKA,KABEBLOCK
		GLB	CHKCHG_DAT0,CHKCHG_DAT1,CHKCHG_DAT2
		GLB	CHKCHG_DAT3,CHKCHG_DAT4
		GLB	TOGEBOWSET,COLRBLK
		GLB	TATTURU,ZASSOU1,ZASSOU2,ZASSOU3,TURUKUS
		GLB	TURUKUSS,TURUKUSL,TURUKUSR,TURUKUSC,NANAMTURU
		GLB	KAIDAN,KABE1,KABE2,KABE3,KABEKS,KABEANA
		GLB	KBNANAUP,KBNANADWN,BLUECOIN,BLUECOIN_NNM_SB
		GLB	KUSAANAU60R,KUSAANAU60L
		GLB	KUSAJARI,DWNBLK,BKTKABE,HNTULU
		GLB	CHKWBIG,BRKUI30,BRKUI45,BRKUIEDA0,BRKUIEDA1
		GLB	YMARASI,CONTBLCK,CHKTK,CHKTKIWA
		GLB	CHKBIGWOD,CHKSMLWOD0,CHKSMLWOD1
		GLB	HNIWABLCK,CHKWSML_SB,NRR_TAMA
		GLB	COLR_BLCK,BRK_BLCK,DOKAN,TGBLKST,TGBLKCR
		GLB	NRMLBOW,MOVE_DOKAN
		GLB	DKNUPST,DKNDNST,DKNLFST,DKNRIST
		GLB	DKNTTST,DKNYKST,DKNTYST,DKNHNST
		GLB	DKRIUP0,DKRIUP1,DKRIUP2,DKRIUP3
		GLB	DKLFUP0,DKLFUP1,DKLFUP2,DKLFUP3
		GLB	DUPENST,DDNENST,DLFENST,DRIENST
		GLB	DKWHSST,DKWTTST,DKWLFST,DKWRIST,DKWLDST,DKWRDST
		GLB	COINXPS,COINYPS,COINNPS,DKWTRST,KBRIUST,KBLFUST
		GLB	KBWAKST,HANA_DWN45,HANA_DWN22,HANA_DWN10
		GLB	HANA_TT,HANA_YK
		GLB	DKN_ROMKB,DKN_ROMTWKL,DKN_ROMTWKR
		GLB	DKN_ROMTWKU,DKN_ROMTWKD,SORA_MRT
		GLB	NAZO_BLCK,SNOW_YK,SNOW_WTR,CK2_ICEFOR
		GLB	CK2_ICIW,CK2_YOGAN0,CK2_YOGAN1,CK2_TANAKN
		GLB	SORA_HSR,SNOW_ANA,FLOWER_YK,FLWR_LDRU22
		GLB	FLWR_LDRU45,FLWR_LDRU60,FLWR_LURD22,FLWR_LURD45
		GLB	FLWR_LURD60,FLWR_LTRT,YGN_UPBLK,YGN_YUKA
		GLB	TOGE2,KAMEC_BLK
;
;
;----------------------------------------------------------------
;-		extern symbol					-
;----------------------------------------------------------------
		EXT	RND_RND
		EXT	UPCHK_SB,DWNCHK_SB,LFTCHK_SB,RITCHK_SB
;
;---------------< ys_bgsc2 >-------------------------------------
		EXT	HBLOCK
;
;---------------< ys_game >--------------------------------------
		EXT	BGCOIN_SETCHK
;
;----------------------------------------------------------------
;-		define symbol					-
;----------------------------------------------------------------
;;;;		EQU
;
;
;****************************************************************
;*								*
;*		program start					*									*
;*								*
;****************************************************************
;
;
		EXTEND
;
;
		MEM8
		IDX8
;
Group_13	GROUP	Bgsc1_pro
Bgsc1_pro	SECT	REL
;
;
;
;
;****************************************************************
;*								*
;*	床 BG left set						*
;*								*
;****************************************************************
BG_FLOOR0	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT3900
		BEQ	BG_FLOOR05
		JSR	FLOR_SUB
		LDA	FLOOR0DT,Y
		BRA	BG_FLOOREND
BG_FLOOR05	EQU	$
		JSR	BG_FLOORSB	; 床 ＢＧ サブ ルーチン
		BRA	BG_FLOOREND
;
;
;****************************************************************
;*								*
;*	床 BG right set						*
;*								*
;****************************************************************
BG_FLOOR1	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT3900
		BEQ	BG_FLOOR15
		JSR	FLOR_SUB
		LDA	FLOOR1DT,Y
		BRA	BG_FLOOREND
BG_FLOOR15	EQU	$
		JSR	BG_FLOORSB	; 床 ＢＧ サブ ルーチン
;
BG_FLOOREND	EQU	$
		TAY
		LDA	0,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
FLOOR0DT	EQU	$
		WORD	RUT2A00,RUT3912,RUT3914,RUT3918
;
FLOOR1DT	EQU	$
		WORD	RUT2A01,RUT3913,RUT3915,RUT3919
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		床 ＢＧ 影チェック			+
;+				in			+
;+				Y  : set data index	+
;+				out			+
;+				Y  : set data index	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FLOR_SUB	EQU	$
		CPY	#(FLOOR1DT-FLOOR0DT)/2
		BNE	FLOR_SUB_900
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	RUT3907
		BEQ	FLOR_SUB_100
		CMP	RUT3908
		BNE	FLOR_SUB_900
FLOR_SUB_100	EQU	$
		INY
		INY
FLOR_SUB_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	床 ＢＧ サブ ルーチン				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BG_FLOORSB	EQU	$
		M8			; memory 8bit mode
		LDA	<XSIZE
		BNE	FLOORSB50
		M16			; memory 16bit mode
		LDA	<NOWUNIT
		CMP	RUT3923
		BNE	FLOORSB40
		LDA	#RUT3938
		BRA	FLOORSB90
FLOORSB40	EQU	$
		JSR	FLOR_SUB
		LDA	FLORSB0DT,Y
		BRA	FLOORSB90
;
FLOORSB50	EQU	$
		M16			; memory 16bit mode
		LDA	<NOWUNIT
		CMP	RUT3922
		BNE	FLOORSB70
		LDA	#RUT3937
		BRA	FLOORSB90
FLOORSB70	EQU	$
		JSR	FLOR_SUB
		LDA	FLORSB1DT,Y
FLOORSB90	EQU	$
		RTS
;
FLORSB0DT	EQU	$	; left side data
		WORD	RUT392B,RUT3907,RUT3914,RUT3918
;
FLORSB1DT	EQU	$	; right side data
		WORD	RUT392A,RUT3908,RUT3915,RUT3919
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	床 ＢＧ ランダム ルーチン				*
;*								*
;****************************************************************
FLOOR_RND	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		CMP	RUT3932
		BEQ	FLOOR_RND999
		CMP	RUT3933
		BEQ	FLOOR_RND999
		CMP	RUT3922
		BCC	FLOOR_RND005
		CMP	RUT392C
		BCC	FLOOR_RND999
FLOOR_RND005	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	FLOOR_RND50
		LDA	<NOWUNIT
		CMP	RUT3912
		BEQ	FLOOR_RND00
		CMP	RUT3913
		BEQ	FLOOR_RND00
		CMP	RUT3918
		BEQ	FLOOR_RND999
		CMP	RUT3919
		BEQ	FLOOR_RND999
		CMP	RUT391C
		BEQ	FLOOR_RND999
		CMP	RUT391D
		BEQ	FLOOR_RND999
		BRA	FLOOR_RND50
;
FLOOR_RND00	EQU	$
		LDA	#RUT390D
		STA	<WORK2
		JSR	FLOOR_RNDRL2	; 左右 床 チェック ＆ セット ２
		LDY	<WORK2
		BRA	FLOOR_RND99
;
FLOOR_RND50	EQU	$
		JSR	FLOOR_RNDRL1	; 左右 床 チェック ＆ セット １
		JSL	>RND_RND
		AND	#00007H
		ASL	A
		TAY
		LDA	FLOR_RNDDT,Y
		TAY
FLOOR_RND99	EQU	$
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
FLOOR_RND999	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
FLOR_RNDDT	EQU	$
		WORD	RUT390E,RUT390F,RUT3910,RUT3911
		WORD	RUT392C,RUT392D,RUT390E,RUT390F
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	左右 床 チェック ＆ セット １		+
;++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
FLOOR_RNDRL1	EQU	$
		JSL	>LFTCHK_SB	; left	point check
		LDA	>BGUNIT,X
		CMP	RUT390D
		BNE	RNDRTLF150
		LDA	RUT391C
		STA	>BGUNIT,X
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB	; down	point check
		LDA	RUT3919
		STA	>BGUNIT,X
RNDRTLF150	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	RUT390D
		BNE	RNDRTLF190
		LDA	RUT391D
		STA	>BGUNIT,X
		JSL	>DWNCHK_SB	; down	point check
		LDA	RUT3918
		STA	>BGUNIT,X
RNDRTLF190	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	左右 床 チェック ＆ セット ２		+
;++++++++++++++++++++++++++++++++++++++++++++++++
FLOOR_RNDRL2	EQU	$
		JSL	>LFTCHK_SB		; left	point check
		LDA	>BGUNIT,X
		CMP	RUT392C
		BEQ	RNDRTLF210
		CMP	RUT392D
		BEQ	RNDRTLF210
		CMP	RUT390E
		BCC	RNDRTLF250
		CMP	RUT3912
		BCS	RNDRTLF250
RNDRTLF210	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB	; down	point check
		LDA	RUT3918
		STA	>BGUNIT,X
		LDA	#RUT391D
		BRA	RNDRTLF280
;
RNDRTLF250	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	RUT392C
		BEQ	RNDRTLF260
		CMP	RUT392D
		BEQ	RNDRTLF260
		CMP	RUT390E
		BCC	RNDRTLF290
		CMP	RUT3912
		BCS	RNDRTLF290
RNDRTLF260	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB	; down	point check
		LDA	RUT3919
		STA	>BGUNIT,X
		LDA	#RUT391C
RNDRTLF280	EQU	$
		STA	<WORK2
RNDRTLF290	EQU	$
		RTS
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	床 left , right side BG set				*
;*								*
;****************************************************************
FLORLFT		EQU	$
FLORRIT		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	FLRLFT_050
		LDA	<YSIZE
		BNE	FLRLFT_050
		LDA	<XYCPBF
		STA	<YSIZECP
FLRLFT_050	EQU	$
		LDA	<STUNTNO
		AND	#00001H
		ASL	A
		ORA	<XSIZE
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		ASL	A
		ORA	<WORK0
		ASL	A
		TAY
		LDX	FLRLFTDT,Y
		BEQ	FLRLFT_900
		CPY	#FLRLFTDT_CK-FLRLFTDT
		BCC	FLRLFT_080
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	FLRLFT_060
		CMP	RUT2A01
		BNE	FLRLFT_070
FLRLFT_060	EQU	$
		INY
		INY
		INY
		INY
FLRLFT_070	EQU	$
		LDX	FLRLFTDT,Y
FLRLFT_080	EQU	$
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
FLRLFT_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
FLRLFTDT	EQU	$
		WORD	RUT3B00,RUT2A01,RUT2A01,RUT3B01
		WORD	RUT3B02,RUT3920,RUT3921,RUT3B03
FLRLFTDT_CK	EQU	$
		WORD	00000H, RUT3922,RUT3923
		WORD		RUT3937,RUT3938
;
;
;****************************************************************
;*								*
;*	床 サイド ＢＧ ランダム ルーチン			*
;*								*
;****************************************************************
FLRLFT_RND	EQU	$
		MI16			; memory , index 16bit mode
		JSL	>RND_RND
		AND	#00003H
		STA	<WORK0
		LDA	<STUNTNO
		AND	#00001H
		STA	<WORKA
		ASL	A
		ASL	A
		ORA	<WORK0
		ASL	A
		TAY
		LDA	FLRLFT_RNDDT,Y
		STA	<WORK0
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	SIDRND300
		CMP	RUT2A01
		BEQ	SIDRND300
		CMP	RUT390D
		BEQ	SIDRND200
		CMP	RUT3912
		BEQ	SIDRND200
		CMP	RUT3913
		BNE	SIDRND400
;
SIDRND200	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	RUT3937
		BEQ	SIDRND250
		CMP	RUT3938
		BEQ	SIDRND250
		LDA	<STUNTNO
		AND	#00001
		CLC
		ADC	RUT392A
		STA	>BGUNIT,X
SIDRND250	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	FLRLFT_RNDSB	; 床 サイド ＢＧ check
		BRA	SIDRND400
;
SIDRND300	EQU	$
		LDA	RUT392A
		CLC
		ADC	<WORKA
		BRA	SIDRND500
;
SIDRND400	EQU	$
		LDA	(<WORK0)
SIDRND500	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
SIDRND900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
FLRLFT_RNDDT	EQU	$
		WORD	RUT3924,RUT3926,RUT3928,RUT3924
		WORD	RUT3925,RUT3927,RUT3929,RUT3925
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	床 サイド ＢＧ check				+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
FLRLFT_RNDSB	EQU	$
		LDA	<WORKA
		BNE	FLR_RNDSB500
		JSL	>RITCHK_SB	; right check
		LDA	#RUT390B
		STA	<WORK0
		LDA	>BGUNIT,X
		CMP	RUT390D
		BEQ	FLR_RNDSB900
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	RUT3919
		STA	>BGUNIT,X
		LDA	#RUT3908
		STA	<WORK0
		BRA	FLR_RNDSB900
;
FLR_RNDSB500	EQU	$
		JSL	>LFTCHK_SB	; left check
		LDA	#RUT390C
		STA	<WORK0
		LDA	>BGUNIT,X
		CMP	RUT390D
		BEQ	FLR_RNDSB900
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	RUT3918
		STA	>BGUNIT,X
		LDA	#RUT3907
		STA	<WORK0
FLR_RNDSB900	EQU	$
		RTS
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		床  22.5ﾟ坂セット				*
;*								*
;****************************************************************
FLR225_ADR	EQU	$
		WORD	FLR225_RT,FLR225_LT
;
;
FLR225		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		ASL	A
		TAY
		CPY	#00008
		BCC	FLR225_500
		JSL	>FLOOR_RND
		BRA	FLR225_990
;
FLR225_500	EQU	$
		STZ	<LKFLG
		LDA	<XSIZE
		AND	#00001
		ASL	A
		TAX
		JSR	(FLR225_ADR,X)
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
FLR225_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FLR225_RT_DT0	EQU	$
		WORD	RUT2A02,RUT0F00,RUT1300,RUT390E
;
FLR225_RT_DT1	EQU	$
		WORD	RUT2A04,RUT0C00,RUT0E00,RUT3919
;
;
FLR225_RT	EQU	$
		LDA	<STUNTNO
		BNE	FLR225_RT_200
		LDX	FLR225_RT_DT0,Y
		BRA	FLR225_RT_900
;
FLR225_RT_200	EQU	$
		LDX	FLR225_RT_DT1,Y
;
FLR225_RT_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FLR225_LT_DT0	EQU	$
		WORD	RUT2A03,RUT1000,RUT1100,RUT3918
;
FLR225_LT_DT1	EQU	$
		WORD	RUT2A05,RUT0D00,RUT1200,RUT390F
;
;
FLR225_LT	EQU	$
		INC	<LKFLG
		LDA	<STUNTNO
		BNE	FLR225_LT_200
		LDX	FLR225_LT_DT0,Y
		BRA	FLR225_LT_900
;
FLR225_LT_200	EQU	$
		LDX	FLR225_LT_DT1,Y
;
FLR225_LT_900	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		床 坂 右下がり 45ﾟ , 67.5ﾟ 偶数ラインセット	*
;*								*
;****************************************************************
FLORUPDWN0	EQU	$
		MI16			; memory , index 16bit mode
		STZ	<LKFLG
		LDA	<STUNTNO
		CMP	#00006H
		BCS	FLORUPDWN1
		INC	<LKFLG
UPDWN0100	EQU	$
		AND	#00001H
		ASL	A
		ASL	A
		ORA	<YSIZE
		ASL	A
		TAY
		LDX	UPDWN0DT,Y
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
UPDWN0DT	EQU	$
		WORD	RUT2A02,RUT0F00,RUT1300,00000H
		WORD	RUT0C00,RUT0E00,RUT3919
;
;
;****************************************************************
;*								*
;*		床 坂 右下がり 45ﾟ , 67.5ﾟ 奇数ラインセット	*
;*								*
;****************************************************************
FLORUPDWN1	EQU	$
		MI16			; memory , index 16bit mode
		STZ	<LKFLG
		LDA	<STUNTNO
		CMP	#00004H
		BEQ	UPDWN1000
		CMP	#00005H
		BEQ	UPDWN1000
		INC	<LKFLG
UPDWN1000	EQU	$
		DEC	A
		DEC	A
		DEC	A
		DEC	A
		ASL	A
		TAX
		LDA	UPDWN1DT,X
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	(<WORK0),Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
UPDWN1DT	EQU	$
		WORD	UPDWN1DT0,DWNUP1DT0
		WORD	UPDWN1DT1,DWNUP1DT1
		WORD	UPDWN1DT2,DWNUP1DT2
;
UPDWN1DT0	EQU	$
		WORD	RUT1000,RUT1100,RUT3918
UPDWN1DT1	EQU	$
		WORD	RUT2A07,RUT0A00,RUT0B00,RUT3916
UPDWN1DT2	EQU	$
		WORD	RUT2A08,RUT0500,RUT0600,RUT0700,RUT392E
;
DWNUP1DT0	EQU	$
		WORD	RUT2A05,RUT0D00,RUT1200
DWNUP1DT1	EQU	$
		WORD	RUT2A06,RUT0800,RUT0900,RUT3917
DWNUP1DT2	EQU	$
		WORD	RUT2A09,RUT0200,RUT0300,RUT0400,RUT392F
;
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	壁 left , right side BG set				*
;*								*
;****************************************************************
KABELFT		EQU	$
KABERIT		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<STUNTNO
		AND	#00001H
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	KABEDAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
KABEDAT		EQU	$
		WORD	RUT3909,RUT390A
;
;
;****************************************************************
;*								*
;*	半あたり 縦棒  set					*
;*								*
;****************************************************************
TBOUST		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<STUNTNO
		AND	#00003H
		ASL	A
		TAY
		LDA	<YSIZE
		BEQ	TBOUST100
		INC	A
		CMP	<YSIZECP
		BEQ	TBOUST200
		LDA	TBOUST0DT,Y
		BRA	TBOUST900
;
TBOUST100	EQU	$
		LDA	TBOUST1DT,Y
		BRA	TBOUST900
;
TBOUST200	EQU	$
		LDA	TBOUST2DT,Y
;
TBOUST900	EQU	$
		TAY
		LDA	0,Y
		JMP	YBOUST900
;
;
TBOUST0DT	EQU	$		; center data
		WORD	RUT6B01
		WORD	00000H
		WORD	DRUT0A5,DRUT0A4
;
TBOUST1DT	EQU	$		; up data
		WORD	RUT6B00
		WORD	00000H
		WORD	DRUT0A1,DRUT0A0
;
TBOUST2DT	EQU	$		; down data
		WORD	RUT6B02
		WORD	00000H
		WORD	RUT2A0B,RUT2A0A
;
DRUT0A0		EQU	$
		WORD	UT00A0
;
DRUT0A1		EQU	$
		WORD	UT00A1
;
DRUT0A4		EQU	$
		WORD	UT00A4
;
DRUT0A5		EQU	$
		WORD	UT00A5
;
;
;****************************************************************
;*								*
;*	半あたり 横棒  set					*
;*								*
;****************************************************************
YBOUST		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT3800
		BEQ	YBOUST010
YBOUST000	EQU	$
		LDA	<XSIZE
		BEQ	YBOUST100
		INC	A
		CMP	<XSIZECP
		BEQ	YBOUST200
YBOUST010	EQU	$
		LDA	RUT3801		; center set
		BRA	YBOUST900
;
YBOUST100	EQU	$		; left set
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT3900
		BNE	YBOUST120
		LDA	RUT3904
		BRA	YBOUST900
YBOUST120	EQU	$
		LDA	RUT3800
		BRA	YBOUST900
;
YBOUST200	EQU	$		; right set
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT3900
		BNE	YBOUST220
		LDA	RUT3903
		BRA	YBOUST900
YBOUST220	EQU	$
		LDA	RUT3802
;
YBOUST900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
YBOUST990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		雪コース リフト 30ﾟ				*
;*								*
;****************************************************************
LIFT30_DAT0	EQU	$
		WORD	UT00AC,UT00AB
		WORD	UT00AA,00000H
		WORD	UT00A3,UT00A2
;
LIFT30_DAT1	EQU	$
		WORD	UT00AD,UT00AE
		WORD	UT00AF,00000H
		WORD	UT00A2,UT00A3
;
MUKI_DAT	EQU	$
		WORD	00001H,0FFFFH
;
DWN_LFG_DAT	EQU	$
		WORD	08000H,00000H
;
;
LIFT30		EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<XSIZECP
		BPL	LIFT30_000
		INY
		INY
LIFT30_000	EQU	$
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
		TAX
		LDA	<XSIZE		; 書き始め ?
		BEQ	LIFT30_100	;	YES -> LIFT30_100
		CLC
		ADC	MUKI_DAT,Y
		CMP	<XSIZECP	; 書き終わり？
		BNE	LIFT30_200	;	NO -> LIFT30_200
LIFT30_100	EQU	$
		LDA	<YSIZE
		BNE	LIFT30_990
		LDA	<NOWUNIT
		CMP	#UT00C4
		BEQ	LIFT30_130
		CMP	#UT00B7
		BNE	LIFT30_150
LIFT30_130	EQU	$
		LDA	#UT00B7
		BRA	LIFT30_900
LIFT30_150	EQU	$
		TXA
		ORA	#00008
		STA	<WORK0
		AND	#00002
		BEQ	LIFT30_230
;
LIFT30_200	EQU	$
		LDA	DWN_LFG_DAT,X
		STA	<LKFLG
LIFT30_230	EQU	$
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
;;;;K;;;;		CLC
		ADC	<WORK0
		TAY
		LDA	<XSIZECP
		BMI	LIFT30_250
		LDA	LIFT30_DAT0,Y
		BEQ	LIFT30_990
		BRA	LIFT30_900
LIFT30_250	EQU	$
		LDA	LIFT30_DAT1,Y
		BEQ	LIFT30_990
;
LIFT30_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
LIFT30_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
LIFT301_1DT	EQU	$
		WORD	UT00AB,UT00AE
;
;
;****************************************************************
;*								*
;*	雪コース リフト 45ﾟ 60ﾟ					*
;*								*
;****************************************************************
LIFT45		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#08000H
		STA	<LKFLG
		LDY	#00000H
		LDA	<XSIZECP
		BPL	LIFT45_00
		INY
		INY
LIFT45_00	EQU	$
		LDA	<XSIZE		; start ?
		BEQ	LIFT45_10	;	YES -> LIFT45_10
		CLC
		ADC	MUKI_DAT,Y
		CMP	<XSIZECP	; end ?
		BEQ	LIFT45_30	;	YES -> LIFT45_30
;
		LDA	<YSIZE
		ASL	A
		STA	<WORK0
		LDA	<STUNTNO
		AND	#00002H
		ASL	A
		ADC	<WORK0
		ASL	A
		STA	<WORK0
		TYA
		ORA	<WORK0
		TAY
		LDA	LIFT45_DT,Y
		BRA	LIFT45_90
;
LIFT45_10	EQU	$
		STZ	<LKFLG
		LDA	<YSIZE
		BNE	LIFT45_99
		LDA	<NOWUNIT
		CMP	#UT00C4
		BEQ	LIFT45_103
		CMP	#UT00B7
		BNE	LIFT45_105
LIFT45_103	EQU	$
		LDA	#UT00B7
		BRA	LIFT45_90
LIFT45_105	EQU	$
		LDA	LIFT30_DAT0+8,Y
		BRA	LIFT45_90
;
LIFT45_30	EQU	$
		LDA	<YSIZE
		BNE	LIFT45_99
		LDA	<NOWUNIT
		CMP	#UT00C4
		BEQ	LIFT45_303
		CMP	#UT00B7
		BNE	LIFT45_305
LIFT45_303	EQU	$
		LDA	#UT00B7
		BRA	LIFT45_90
LIFT45_305	EQU	$
		LDA	LIFT30_DAT1+8,Y
;
LIFT45_90	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
LIFT45_99	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
LIFT45_DT	EQU	$
		WORD	UT00A7,UT00A8
		WORD	UT00A6,UT00A9
;
		WORD	UT00B5,UT00B0
		WORD	UT00B3,UT00B2
		WORD	UT00B4,UT00B1
;
;
;****************************************************************
;*								*
;*	雪コース リフト						*
;*								*
;****************************************************************
LIFTST		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<NOWUNIT
		CMP	#UT00C4
		BEQ	LIFTST_05
		CMP	#UT00B7
		BNE	LIFTST_08
LIFTST_05	EQU	$
		LDA	#UT00B7
		BRA	LIFTST_90
;
LIFTST_08	EQU	$
		LDA	<XSIZE
		BEQ	LIFTST_10
		INC	A
		CMP	<XSIZECP
		BEQ	LIFTST_20
		LDA	#UT00B6
		BRA	LIFTST_90
;
LIFTST_10	EQU	$
;
LIFTST_15	EQU	$
		LDA	#UT00A3
		BRA	LIFTST_90
;
LIFTST_20	EQU	$
		LDA	#UT00A2
;
LIFTST_90	EQU	$
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	トンネル BG set						*
;*								*
;****************************************************************
TONNEL		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XYPOINT
		STA	<WORKE
		LDX	<UNITPOS
		STZ	<XYCPBF
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT1D00
		BNE	TONNEL000
		LDA	<NOWUNIT
		AND	#000FFH
		INC	A
		ASL	A
		STA	<XYCPBF
TONNEL000	EQU	$
		LDA	<XSIZECP
		DEC	A
		BEQ	TONNEL100	; goto v-line set
		LDA	<YSIZECP
		DEC	A
		BEQ	TONNEL200	; goto h-line set
;
		JSR	TONNELBOX	; BOX type set
		BRA	TONNEL900
;
TONNEL100	EQU	$
		JSR	TONNELV		; V line set
		BRA	TONNEL900
;
TONNEL200	EQU	$
		JSR	TONNELH		; H line set
;
TONNEL900	EQU	$
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	トンネル V line set				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TONNELV		EQU	$
		LDA	<YSIZE
		BEQ	TNLV100
		INC	A
		CMP	<YSIZECP
		BEQ	TNLV200
;
TNLV000		EQU	$		; center BG set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLV0DAT,Y
		BRA	TNLV900
;
TNLV100		EQU	$		; up BG set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLV1DAT,Y
		BRA	TNLV900
;
TNLV200		EQU	$		; down BG set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLV2DAT,Y
;
TNLV900		EQU	$
		TAY
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	トンネル H line set				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TONNELH		EQU	$
		LDA	<XSIZE
		BEQ	TNLH100
		INC	A
		CMP	<XSIZECP
		BEQ	TNLH200
;
TNLH000		EQU	$		; center BG set
		LDY	<XYCPBF
		LDA	TNLH0DAT,Y
		BRA	TNLH900
;
TNLH100		EQU	$		; left BG set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLH1DAT,Y
		BRA	TNLH900
;
TNLH200		EQU	$		; right BG set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLH2DAT,Y
;
TNLH900		EQU	$
		TAY
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	トンネル BOX type set				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TONNELBOX	EQU	$
		LDA	<XSIZE
		BNE	TNLBX000
		LDA	<YSIZE
		BEQ	TNLBX100	; goto left up set
		INC	A
		CMP	<YSIZECP
		BNE	TNLBX200	; goto left center set
		BRA	TNLBX300	; goto left down set
TNLBX000	EQU	$
		INC	A
		CMP	<XSIZECP
		BEQ	TNLBX010
		LDA	<YSIZE
		BEQ	TNLBX400	; goto center up set
		INC	A
		CMP	<YSIZECP
		BNE	TNLBX500	; goto center set
		BRA	TNLBX600	; goto center down set
TNLBX010	EQU	$
		LDA	<YSIZE
		BEQ	TNLBX700	; goto right up set
		INC	A
		CMP	<YSIZECP
		BNE	TNLBX020
		JMP	TNLBX900	; goto right down set
TNLBX020	EQU	$
		JMP	TNLBX800	; goto right center set
;
TNLBX100	EQU	$		; left up set
		JSR	TNLINOUT	;  トンネル in,out check
		PHY
		LDY	#00000H
		JSR	BGUPNUKI	; up character nu-ki set
		PLY
		LDA	TNLBX1DAT,Y
		JMP	TNLBX999
;
TNLBX200	EQU	$		; left center set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLBX2DAT,Y
		BRA	TNLBX999
;
TNLBX300	EQU	$		; left down set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLBX3DAT,Y
		BRA	TNLBX999
;
TNLBX400	EQU	$		; center up set
		JSR	TNLINOUT	;  トンネル in,out check
		PHY
		LDY	#00002H
		JSR	BGUPNUKI	; up character nu-ki set
		PLY
		LDA	TNLBX4DAT,Y
		BRA	TNLBX999
;
TNLBX500	EQU	$		; center set
		LDA	#RUT1D13
		BRA	TNLBX999
;
TNLBX600	EQU	$		; center down set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLBX6DAT,Y
		BRA	TNLBX999
;
TNLBX700	EQU	$		; right up set
		JSR	TNLINOUT	;  トンネル in,out check
		PHY
		LDY	#00004H
		JSR	BGUPNUKI	; up character nu-ki set
		PLY
		LDA	TNLBX7DAT,Y
		BRA	TNLBX999
;
TNLBX800	EQU	$		; right center set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLBX8DAT,Y
		BRA	TNLBX999
;
TNLBX900	EQU	$		; right down set
		JSR	TNLINOUT	;  トンネル in,out check
		LDA	TNLBX9DAT,Y
;
TNLBX999	EQU	$
		TAY
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	トンネル in,out check			+
;+		out				+
;+		data read index ---> Y		+
;++++++++++++++++++++++++++++++++++++++++++++++++
TNLINOUT	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT1D00
		BEQ	TNLEND
		LDY	#00000H
		LDA	<NOWUNIT
TNLLOP		EQU	$
		LDX	INOUTCMP,Y
		CMP	0,X
		BEQ	TNLPAS
		INY
		INY
		CPY	#TNLV0DAT-INOUTCMP
		BCC	TNLLOP
		STZ	<XYCPBF
		BRA	TNLEND
TNLPAS		EQU	$
		TYA
		CLC
		ADC	#00014H*2
		STA	<XYCPBF
TNLEND		EQU	$
		LDY	<XYCPBF
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	up character nu-ki set			+
;++++++++++++++++++++++++++++++++++++++++++++++++
BGUPNUKI	EQU	$
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	RUT2A00
		BEQ	NUKI000
		CMP	RUT2A01
		BNE	NUKI050
NUKI000		EQU	$
		LDA	UT39DT,Y
		STA	>BGUNIT,X
NUKI050		EQU	$
		RTS
		MEM8
		IDX8
;
UT39DT		EQU	$
		WORD	UT008C,UT0000,UT008D
;
TNLVNK0		EQU	$
		WORD	UT008B
;
;------------------------- in , out comper data
INOUTCMP	EQU	$
		WORD	RUT3912,RUT3913		; in,out center data
		WORD	RUT2A00,RUT2A01		; in,out up data
		WORD	RUT3931,RUT3934		; in,out down data
		WORD	RUT3924,RUT3926,RUT3928 ; in,out left data
;
		WORD	RUT1D00,RUT1D00,RUT1D00
		WORD	RUT1D00
;
		WORD	RUT3925,RUT3927,RUT3929 ; in,out right data
		WORD	RUT392A,RUT392B
;
;------------------------- V line center BG change data
TNLV0DAT	EQU	$
		WORD	RUT1D00
		WORD	RUT1D00,RUT1D20,RUT1D20,RUT1D20,RUT1D09,RUT1D08,RUT1D09,RUT1D08	; 00-07
		WORD	RUT1D08,RUT1D09,	RUT1D20,RUT1D13,RUT1D0D,RUT1D0E,RUT1D0D	; 08-0F
		WORD	RUT1D2D,RUT1D0D,RUT1D0E,RUT1D13,RUT1D14,	RUT1D14,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D20,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D09,RUT1D08	; 28-2F
		WORD	RUT1D00,RUT1D00							; 30-31
;
;------------------------- V line up BG change data
TNLV1DAT	EQU	$
		WORD	RUT1D30
		WORD	RUT1D00,RUT1D20,RUT1D02,RUT1D02,RUT1D09,RUT1D05,RUT1D06,RUT1D08	; 00-07
		WORD	RUT1D05,RUT1D06,	RUT1D0B,RUT1D13,RUT1D0D,RUT1D0E,RUT1D0F	; 08-0F
		WORD	RUT1D10,RUT1D0D,RUT1D0E,RUT1D13,RUT1D14,	RUT1D14,TNLVNK0	; 10-17
		WORD	TNLVNK0,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D20,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 23-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D06,RUT1D05	; 28-2F
		WORD	RUT1D30,RUT1D00							; 30-31
;
;------------------------- V line down BG change data
TNLV2DAT	EQU	$
		WORD	RUT1D31
		WORD	RUT1D00,RUT1D01,RUT1D20,RUT1D21,RUT1D04,RUT1D08,RUT1D09,RUT1D07	; 00-07
		WORD	RUT1D07,RUT1D04,	RUT1D20,RUT1D0C,RUT1D0D,RUT1D0E,RUT1D0D	; 08-0F
		WORD	RUT1D2D,RUT1D12,RUT1D12,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D2A,RUT1D2A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D04,RUT1D07	; 28-2F
		WORD	RUT1D00,RUT1D31							; 30-31
;
;------------------------- H line center BG change data
TNLH0DAT	EQU	$
		WORD	RUT1D03
		WORD	RUT1D20,RUT1D01,RUT1D02,RUT1D03,RUT1D21,RUT1D02,RUT1D02,RUT1D21	; 00-07
		WORD	RUT1D20,RUT1D20,	RUT1D0B,RUT1D0C,RUT1D20,RUT1D13,RUT1D02	; 08-0F
		WORD	RUT1D0B,RUT1D21,RUT1D0C,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D03,RUT1D03	; 28-2F
		WORD	RUT1D02,RUT1D01							; 30-31
;
;------------------------- H line left BG change data
TNLH1DAT	EQU	$
		WORD	RUT1D2E
		WORD	RUT1D09,RUT1D04,RUT1D06,RUT1D03,RUT1D04,RUT1D02,RUT1D06,RUT1D21	; 00-07
		WORD	RUT1D20,RUT1D09,	RUT1D0B,RUT1D0C,RUT1D0D,RUT1D13,RUT1D0F	; 08-0F
		WORD	RUT1D0B,RUT1D0C,RUT1D0C,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D16,RUT1D16,RUT1D16			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D32	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D2E,RUT1D03	; 28-2F
		WORD	RUT1D06,RUT1D04							; 30-31
;
;------------------------- H line right BG change data
TNLH2DAT	EQU	$
		WORD	RUT1D2F
		WORD	RUT1D08,RUT1D07,RUT1D05,RUT1D03,RUT1D21,RUT1D05,RUT1D02,RUT1D07	; 00-07
		WORD	RUT1D08,RUT1D20,	RUT1D0B,RUT1D0C,RUT1D20,RUT1D0E,RUT1D0B	; 08-0F
		WORD	RUT1D10,RUT1D21,RUT1D12,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D17,RUT1D17,RUT1D17,RUT1D27	; 20-27
		WORD	RUT1D33,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D03,RUT1D2F	; 28-2F
		WORD	RUT1D05,RUT1D07							; 30-31
;
;-------------------------  box type left up BG data
TNLBX1DAT	EQU	$
		WORD	RUT1D0F
		WORD	RUT1D0D,RUT1D20,RUT1D0B,RUT1D02,RUT1D0D,RUT1D0B,RUT1D0F,RUT1D20	; 00-07
		WORD	RUT1D20,RUT1D0D,	RUT1D0B,RUT1D13,RUT1D0D,RUT1D13,RUT1D0F	; 08-0F
		WORD	RUT1D0B,RUT1D0D,RUT1D13,RUT1D13,RUT1D24,	RUT1D24,RUT1D24	; 10-17
		WORD	RUT1D24,RUT1D19,RUT1D1A,RUT1D1A,RUT1D1A,RUT1D1A			; 18-1F
		WORD	RUT1D20,RUT1D20,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D0F,RUT1D0B	; 28-2F
		WORD	RUT1D0F,RUT1D0D							; 30-31
;
;------------------------- box type left center BG data
TNLBX2DAT	EQU	$
		WORD	RUT1D0D
		WORD	RUT1D0D,RUT1D0D,RUT1D20,RUT1D20,RUT1D0D,RUT1D20,RUT1D0D,RUT1D20	; 00-07
		WORD	RUT1D20,RUT1D0D,	RUT1D20,RUT1D13,RUT1D0D,RUT1D13,RUT1D0D	; 08-0F
		WORD	RUT1D20,RUT1D0D,RUT1D13,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D18,RUT1D18,RUT1D18			; 18-1F
		WORD	RUT1D20,RUT1D20,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D0D,RUT1D20	; 28-2F
		WORD	RUT1D0D,RUT1D0D							; 30-31
;
;------------------------- box type left down BG data
TNLBX3DAT	EQU	$
		WORD	RUT1D11
		WORD	RUT1D0D,RUT1D21,RUT1D20,RUT1D21,RUT1D11,RUT1D13,RUT1D0D,RUT1D21	; 00-07
		WORD	RUT1D20,RUT1D0D,	RUT1D20,RUT1D0C,RUT1D0D,RUT1D13,RUT1D0D	; 08-0F
		WORD	RUT1D20,RUT1D11,RUT1D0C,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D27,RUT1D1A,RUT1D1C,RUT1D1C,RUT1D1C			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D27,RUT1D27,RUT1D27,RUT1D34	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D11,RUT1D21	; 28-2F
		WORD	RUT1D0D,RUT1D11							; 30-31
;
;------------------------- box type center up BG data
TNLBX4DAT	EQU	$
		WORD	RUT1D0B
		WORD	RUT1D20,RUT1D20,RUT1D0B,RUT1D0B,RUT1D20,RUT1D0B,RUT1D0B,RUT1D20	; 00-07
		WORD	RUT1D20,RUT1D20,	RUT1D0B,RUT1D13,RUT1D20,RUT1D13,RUT1D0B	; 08-0F
		WORD	RUT1D0B,RUT1D20,RUT1D13,RUT1D13,RUT1D25,	RUT1D25,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D20,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D0B,RUT1D0B	; 28-2F
		WORD	RUT1D0B,RUT1D20							; 30-31
;
;------------------------- box type center down BG data
TNLBX6DAT	EQU	$
		WORD	RUT1D0C
		WORD	RUT1D13,RUT1D0C,RUT1D13,RUT1D0C,RUT1D0C,RUT1D13,RUT1D13,RUT1D0C	; 00-07
		WORD	RUT1D13,RUT1D13,	RUT1D13,RUT1D0C,RUT1D13,RUT1D13,RUT1D13	; 08-0F
		WORD	RUT1D13,RUT1D0C,RUT1D0C,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D28,RUT1D28,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D13,RUT1D0C,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D0C,RUT1D0C	; 28-2F
		WORD	RUT1D13,RUT1D0C							; 30-31
;
;------------------------- box type right up BG data
TNLBX7DAT	EQU	$
		WORD	RUT1D10
		WORD	RUT1D2D,RUT1D20,RUT1D20,RUT1D0B,RUT1D20,RUT1D10,RUT1D0B,RUT1D2D	; 00-07
		WORD	RUT1D2D,RUT1D20,	RUT1D0B,RUT1D13,RUT1D20,RUT1D0E,RUT1D0B	; 08-0F
		WORD	RUT1D0B,RUT1D20,RUT1D0E,RUT1D13,RUT1D26,	RUT1D26,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D19			; 18-1F
		WORD	RUT1D13,RUT1D20,RUT1D22,RUT1D23,RUT1D1B,RUT1D1B,RUT1D1B,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D0B,RUT1D10	; 28-2F
		WORD	RUT1D10,RUT1D2D							; 30-31
;
;------------------------- box type right center BG data
TNLBX8DAT	EQU	$
		WORD	RUT1D0E
		WORD	RUT1D0E,RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D0E,RUT1D13,RUT1D0E	; 00-07
		WORD	RUT1D0E,RUT1D13,	RUT1D13,RUT1D13,RUT1D13,RUT1D0E,RUT1D13	; 08-0F
		WORD	RUT1D0E,RUT1D13,RUT1D0E,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D13,RUT1D13,RUT1D22,RUT1D23,RUT1D19,RUT1D19,RUT1D19,RUT1D27	; 20-27
		WORD	RUT1D1D,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D13,RUT1D0E	; 28-2F
		WORD	RUT1D0E,RUT1D0E							; 30-31
;
;------------------------- box type right down BG data
TNLBX9DAT	EQU	$
		WORD	RUT1D12
		WORD	RUT1D0E,RUT1D0C,RUT1D13,RUT1D0C,RUT1D0C,RUT1D0E,RUT1D13,RUT1D12	; 00-07
		WORD	RUT1D0E,RUT1D13,	RUT1D13,RUT1D0C,RUT1D13,RUT1D0E,RUT1D13	; 08-0F
		WORD	RUT1D0E,RUT1D0C,RUT1D12,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D29,RUT1D29,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D13,RUT1D21,RUT1D22,RUT1D23,RUT1D1D,RUT1D1D,RUT1D1D,RUT1D27	; 20-27
		WORD	RUT1D35,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D0C,RUT1D12	; 28-2F
		WORD	RUT1D0E,RUT1D12							; 30-31
;
;
;****************************************************************
;*								*
;*		ＢＧ１乗れる雲					*
;*								*
;****************************************************************
KUMOKUMO_DAT	EQU	$
		WORD	UT00F0,UT00F2,UT00F1,00000H
		WORD	UT1513,UT1515,UT1514
;
;
KUMOKUMO	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		BEQ	KMKM_0500
		INC	<WORK0
		INC	A
		CMP	<XSIZECP
		BNE	KMKM_0500
		INC	<WORK0
KMKM_0500	EQU	$
		LDA	<WORK0
		ASL	A
		TAY
		LDA	KUMOKUMO_DAT,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	水中 BG set						*
;*								*
;****************************************************************
WTRWTR		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		BNE	WTRWTR_END
		LDX	<UNITPOS
		LDA	#UT1600
		STA	>BGUNIT,X
WTRWTR_END	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	水中 草付き岩 BG set					*
;*								*
;****************************************************************
WTRGRND		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XYPOINT
		STA	<WORKE
		STZ	<WORKA
		LDX	<UNITPOS
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT1600
		BNE	WTRGRND_010
		LDA	#00008H
		STA	<WORKA
WTRGRND_010	EQU	$
		LDA	<YSIZE
		BNE	WTRGRND_200
;
WTRGRND_100	EQU	$
		LDA	<WORKA
		BNE	WTRGRND_900
		LDY	#00000H
		JSR	WTRGRND_1000	; top line set
		BRA	WTRGRND_900
;
WTRGRND_200	EQU	$
		INC	A
		CMP	<YSIZECP
		BEQ	WTRGRND_500
		CMP	#00002H
		BNE	WTRGRND_300
		LDA	<WORKA
		BNE	WTRGRND_250
		LDY	#00002H
		JSR	WTRGRND_1000	; top line set
		BRA	WTRGRND_900
;
WTRGRND_250	EQU	$		; 2 line set
		JSR	WTRGRND_SB	; line set index
		LDA	WTRGRND_26DT,Y
		STA	>BGUNIT,X
		BRA	WTRGRND_900
;
WTRGRND_300	EQU	$		; center line set
		JSR	WTRGRND_SB	; line set index
		TYA
		ORA	<WORKA
		TAY
		LDA	WTRGRND_30DT,Y
		STA	>BGUNIT,X
		BRA	WTRGRND_900
;
WTRGRND_500	EQU	$		; down line set
		JSR	WTRGRND_SB	; line set index
		TYA
		ORA	<WORKA
		TAY
		LDA	WTRGRND_50DT,Y
		STA	>BGUNIT,X
;
WTRGRND_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
WTRGRND_26DT	EQU	$
		WORD	UT0125,UT0126,UT0127
;
WTRGRND_30DT	EQU	$
		WORD	UT0122,UT0123,UT0124,00000H
		WORD	UT0128,UT0129,UT012A
;
WTRGRND_50DT	EQU	$
		WORD	UT0144,UT0145,UT0146,00000H
		WORD	UT0141,UT0142,UT0143
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	line set index					+
;+			out				+
;+			 Y <- read index		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
WTRGRND_SB	EQU	$
		LDY	#00000H
		LDA	<XSIZE
		BEQ	WTRGRND_SB0
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	WTRGRND_SB0
		INY
		INY
WTRGRND_SB0	EQU	$
		RTS
		MEM8
		IDX8
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	top line set					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
WTRGRND_1000	EQU	$
		LDA	<XSIZE
		AND	#00001H
		CLC
		ADC	WTRGRND_10DT,Y
		STA	>BGUNIT,X
;
		LDA	<YSIZE
		BNE	WTRGRND_1105
		JSL	>DWNCHK_SB	; down check
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT1600
		BEQ	WTRGRND_190
		LDA	<XYPOINT
		STA	<WORKE
;
WTRGRND_1105	EQU	$
		LDA	<XSIZE
		BNE	WTRGRND_110
		JSL	>LFTCHK_SB	; left check
		LDA	>BGUNIT,X
		BNE	WTRGRND_190
		LDA	WTRGRND_11DT,Y
		STA	>BGUNIT,X
		BRA	WTRGRND_190
WTRGRND_110	EQU	$
		INC	A
		CMP	<XSIZECP
		BNE	WTRGRND_190
		JSL	>RITCHK_SB	; right check
		LDA	>BGUNIT,X
		BNE	WTRGRND_190
		LDA	WTRGRND_12DT,Y
		STA	>BGUNIT,X
WTRGRND_190	EQU	$
		RTS
		MEM8
		IDX8
;
WTRGRND_10DT	EQU	$
		WORD	UT0028,UT0120
;
WTRGRND_11DT	EQU	$
		WORD	UT0027,UT0026
;
WTRGRND_12DT	EQU	$
		WORD	UT002A,UT002B
;
;
;****************************************************************
;*								*
;*	水中 岩 BG set						*
;*								*
;****************************************************************
WTRLAND		EQU	$
		MI16			; memory , index 16bit mode
		STZ	<WORKA
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT1600
		BNE	WTRLAND_000
		LDA	#WTRLANDDTSB-WTRLANDDT
		STA	<WORKA
WTRLAND_000	EQU	$
		LDY	#00000H
		LDA	<YSIZE
		BEQ	WTRLAND_050
		LDY	#00006H
		INC	A
		CMP	<YSIZECP
		BNE	WTRLAND_050
		LDY	#0000CH
WTRLAND_050	EQU	$
		LDA	<XSIZE
		BEQ	WTRLAND_100
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	WTRLAND_100
		INY
		INY
;
WTRLAND_100	EQU	$
		TYA
		CLC
		ADC	<WORKA
		TAY
		LDX	<UNITPOS
		LDA	WTRLANDDT,Y
		STA	>BGUNIT,X
;
WTRLAND_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
WTRLANDDT	EQU	$
		WORD	UT012B,UT012C,UT012D
		WORD	UT012E,UT012F,UT0130
		WORD	UT0131,UT0132,UT0133
;
WTRLANDDTSB	EQU	$
		WORD	UT0134,UT0135,UT0136
		WORD	UT0137,UT0138,UT0139
		WORD	UT013A,UT013B,UT0140
;
;
;****************************************************************
;*								*
;*	水中 丸岩 BG set					*
;*								*
;****************************************************************
WTRROCK		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<YSIZE
		CMP	#00003H
		BCS	WTRROCK_500
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00003H
		ASL	A
		ORA	<WORK0
		TAY
		LDA	WTRROCK_DT,Y
		BRA	WTRROCK_900
;
WTRROCK_500	EQU	$
		LDA	<YSIZE
		EOR	#00001H
		AND	#00001H
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00003H
		ASL	A
		ORA	<WORK0
		TAY
		LDA	WTRROCK_DTSB,Y
;
WTRROCK_900	EQU	$
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
WTRROCK_DT	EQU	$
		WORD	UT1601,UT1602,UT1603,UT1604
		WORD	UT1605,UT1606,UT1607,UT1608
		WORD	UT1609,UT160A,UT160B,UT160C
;
WTRROCK_DTSB	EQU	$
		WORD	UT160D,UT160E,UT160F,UT1610
		WORD	UT1611,UT1612,UT1613,UT1614
;
;
;****************************************************************
;*								*
;*	水中 橋 BG set						*
;*								*
;****************************************************************
WTRBRIDGEH	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		AND	#00001H
		STA	<WORK0
		LDA	<XSIZE
		BNE	WTRBRIDGEH_100
		LDA	#UT1505
		BRA	WTRBRIDGEH_900
;
WTRBRIDGEH_100	EQU	$
		INC	A
		CMP	<XSIZECP
		BEQ	WTRBRIDGEH_200
		LDA	<NOWUNIT
		CMP	#UT0020
		BNE	WTRBRIDGEH_110
		LDA	#UT1509
		BRA	WTRBRIDGEH_900
WTRBRIDGEH_110	EQU	$
		LDA	#UT1501
		CLC
		ADC	<WORK0
		BRA	WTRBRIDGEH_900
;
WTRBRIDGEH_200	EQU	$
		LDA	#UT1506
;
WTRBRIDGEH_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	水中 柱 BG set						*
;*								*
;****************************************************************
WTRBRIDGEV	EQU	$
		MI16			; memory , index 16bit mode
		STZ	<WORKA
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT1600
		BNE	WTRBRIDGEV_000
		LDA	#00006H
		STA	<WORKA
WTRBRIDGEV_000	EQU	$
		LDA	<NOWUNIT
		CMP	#UT1501
		BEQ	WTRBRIDGEV_010
		CMP	#UT1502
		BNE	WTRBRIDGEV_020
WTRBRIDGEV_010	EQU	$
		LDA	#0000CH
		STA	<WORKA
WTRBRIDGEV_020	EQU	$
		LDY	#00000H
		LDA	<YSIZE
		BEQ	WTRBRIDGEV_100
		INY
		INY
		INC	A
		CMP	<YSIZECP
		BNE	WTRBRIDGEV_100
		INY
		INY
WTRBRIDGEV_100	EQU	$
		TYA
		CLC
		ADC	<WORKA
		TAY
		LDA	WTRBRIDGEV_DT,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
WTRBRIDGEV_DT	EQU	$
		WORD	UT1500,UT0020,UT0021
		WORD	UT1400,UT1615,UT1616
		WORD	00000H,UT1509
;
;
;****************************************************************
;*								*
;*	水中 ぶら下がり 丸太 BG set				*
;*								*
;****************************************************************
WTRLIFT		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<XSIZE
		ASL	A
		TAY
		LDA	<YSIZE
		BEQ	WTRLIFT_500
		INC	A
		CMP	<YSIZECP
		BEQ	WTRLIFT_100
		TYA
		ORA	#00004H
		TAY
		BRA	WTRLIFT_500
;
WTRLIFT_100	EQU	$
		TYA
		ORA	#00008H
		TAY
;
WTRLIFT_500	EQU	$
		LDA	WTRLIFT_DT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
WTRLIFT_DT	EQU	$
		WORD	UT1507,UT1508
		WORD	UT0022,UT0023
		WORD	UT1503,UT1504
;
;
;****************************************************************
;*								*
;*	水中 きのこ BG set					*
;*	水中 花 BG set						*
;*								*
;****************************************************************
WTRKINOKO	EQU	$
WTRHANA		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<STUNTNO
		AND	#00002H
		TAY
		LDA	KINOKOHANADT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
KINOKOHANADT	EQU	$
		WORD	UT0024,UT0025
;
;
;****************************************************************
;*								*
;*	溶岩 BG set						*
;*								*
;****************************************************************
YOGAN		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<XSIZE
		AND	#00001H
		BNE	YOGAN_100
		LDA	YOGAN_DAT0,Y
		BRA	YOGAN_500
YOGAN_100	EQU	$
		LDA	YOGAN_DAT1,Y
;
YOGAN_500	EQU	$
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
YOGAN_DAT0	EQU	$
		WORD	UT0033,UT002F,UT9100,UT7E03,UT7E06
;
YOGAN_DAT1	EQU	$
		WORD	UT0034,UT002F,UT9101,UT7E04,UT7E06
;
;
;****************************************************************
;*								*
;*	溶岩 共通 BG set					*
;*								*
;****************************************************************
YOGAN_KYOTU	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	#UT7E05
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース 床				*
;*								*
;****************************************************************
JNGL_FOR_CMP	EQU	$
		WORD	UT908A,UT908B
		WORD	UT9097,UT90A7
		WORD	UT90BA,UT90BB
;
JNGL_FOR_DAT0	EQU	$
		WORD	UT9200,UT9098,UT90A8
;
JNGL_FOR_DAT1	EQU	$
		WORD	UT9080,UT9081,UT9082,UT9085
		WORD	UT9083,UT9083,UT9084,UT9085
		WORD	UT9086,UT9087,UT9088,UT9085
		WORD	UT9089,UT9085,UT9085,UT9085
;
;
JNGL_FOOR	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00003
		BCS	JNGL_FOR_500
		ASL	A
		TAY
		BNE	JNGL_FOR_150
		JSL	>RND_RND
		AND	#00003
		STA	<XYCPBF
JNGL_FOR_150	EQU	$
		LDA	<YSIZE
		BNE	JNGL_FOR_155
		JSR	JNGL_FOR_SID
		BRA	JNGL_FOR_158
JNGL_FOR_155	EQU	$
		LDA	<YSIZE
		CMP	#00001
		BNE	JNGL_FOR_190
		JSR	JNGL_FOR_SD
JNGL_FOR_158	EQU	$
		TXA
		CPX	#0FFFFH
		BNE	JNGL_FOR_900
JNGL_FOR_190	EQU	$
		LDX	#00000
JNGL_FOR_195	EQU	$
		LDA	<NOWUNIT
		CMP	JNGL_FOR_CMP,X
		BEQ	JNGL_FOR_990
		INX
		INX
		CPX	#JNGL_FOR_DAT0-JNGL_FOR_CMP
		BCC	JNGL_FOR_195
;
		LDA	<XYCPBF
		CLC
		ADC	JNGL_FOR_DAT0,Y
		BRA	JNGL_FOR_900
;
JNGL_FOR_500	EQU	$
		JSL	>RND_RND
		ADC	<YSIZE
		AND	#0001EH
		TAY
		LDA	JNGL_FOR_DAT1,Y
;
JNGL_FOR_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
JNGL_FOR_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		坂チェック				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_FOR_DAT	EQU	$
		WORD	UT3311,UT351B
;
JNGL_FOR_DT0	EQU	$
		WORD	UT9204,UT9205
;
JNGL_FOR_DT1	EQU	$
		WORD	UT90A7,UT9097
;
JNGL_FOR_DT2	EQU	$
		WORD	UT964E,UT964F
;
;
JNGL_FOR_SD	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		LDX	#00000
		CMP	#UT9400		; 坂が あったか ?
		BEQ	JNGL_FOR_SD_10	;	YES -> JNGL_FOR_SD_10
		INX			;	NO  -> JNGL_FOR_SD_90
		INX			;
		CMP	#UT9500		;
		BEQ	JNGL_FOR_SD_10	;
		LDX	#0FFFFH
		BRA	JNGL_FOR_SD_90
JNGL_FOR_SD_10	EQU	$
		LDA	JNGL_FOR_DAT,X
		STA	<WORK4
;
		LDX	#00000H
		LDA	<XSIZE
		BEQ	JNGL_FOR_SD_30
		INC	A
		CMP	<XSIZECP
		BNE	JNGL_FOR_SD_90
		INX
		INX
JNGL_FOR_SD_30	EQU	$
		STX	<WORKC
		LDA	JNGL_FOR_DT0,X
		STA	<WORK6
		LDA	JNGL_FOR_DT1,X
		STA	<WORK8
		LDA	JNGL_FOR_DT2,X
		STA	<WORKA
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	<WORK6
		STA	>BGUNIT,X
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	<WORK8
		STA	>BGUNIT,X
		LDA	<XYPOINT
		STA	<WORKE
		LDX	<WORKC
		BNE	JNGL_FOR_SD_35
		JSL	>LFTCHK_SB
		BRA	JNGL_FOR_SD_38
JNGL_FOR_SD_35	EQU	$
		JSL	>RITCHK_SB
JNGL_FOR_SD_38	EQU	$
		LDA	<WORKA
		STA	>BGUNIT,X
;
		LDX	<WORK4
;
JNGL_FOR_SD_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		坂チェック その２			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_FOR_SID_D0	EQU	$
		WORD	UT9500,UT9402
;
JNGL_FOR_SID_D1	EQU	$
		WORD	UT90BB,UT90BA
;
JNGL_FOR_SID_D2	EQU	$
		WORD	UT908B,UT908A
;
;
JNGL_FOR_SID	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		LDX	#00000
		CMP	#UT9400		; 坂が あったか ?
		BEQ	JNGL_FOR_SID_10	;	YES -> JNGL_FOR_SID_10
		INX			;	NO  -> JNGL_FOR_SID_90
		INX			;
		CMP	#UT9500		;
		BEQ	JNGL_FOR_SID_10
		BRA	JNGL_FOR_SID_19
JNGL_FOR_SID_10	EQU	$
		LDX	#00000H
		LDA	<XSIZE
		BEQ	JNGL_FOR_SID_30
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BEQ	JNGL_FOR_SID_30
JNGL_FOR_SID_19	EQU	$
		LDX	#0FFFFH
		BRA	JNGL_FOR_SID_90
;
JNGL_FOR_SID_30	EQU	$
		LDA	JNGL_FOR_SID_D0,X
		STA	<WORK4
		LDA	JNGL_FOR_SID_D1,X
		STA	<WORK6
		LDA	JNGL_FOR_SID_D2,X
		STA	<WORK8
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	<WORK6
		STA	>BGUNIT,X
;
		LDA	<XYPOINT
		AND	#0F0F0H
		CLC
		ADC	#00010H
		AND	#0F0F0H
		STA	<WORK0
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	<WORK8
		STA	>BGUNIT,X
;
		LDX	<WORK4
;
JNGL_FOR_SID_90	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ジャングル コース 床の左端			*
;*								*
;****************************************************************
JNGL_LT_DAT	EQU	$
		WORD	UT9204,UT3311,UT90B4
;
JNGL_LT_DAT_SB	EQU	$
		WORD	UT90B8,UT90BA,UT908A
;
;
JNGL_LEFT	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BNE	JNGL_LT_500
		LDA	<YSIZE
		CMP	#00001
		BNE	JNGL_LT_990
		LDA	#UT964E
		BRA	JNGL_LT_900
;
JNGL_LT_500	EQU	$
		LDA	<YSIZE
		CMP	#00003
		BCS	JNGL_LT_600
		ASL	A
		TAY
		LDA	JNGL_LT_DAT,Y
		BRA	JNGL_LT_900
;
JNGL_LT_600	EQU	$
		JSL	>RND_RND
		AND	#00001
		CLC
		ADC	#UT90B6
		STA	<WORKA
		JSR	JNGL_KS_CHK
		TYA
		BMI	JNGL_LT_690
		LDA	JNGL_LT_DAT_SB,Y
		STA	<WORKA
JNGL_LT_690	EQU	$
		LDA	<WORKA
;
JNGL_LT_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
JNGL_LT_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース 床の右端			*
;*								*
;****************************************************************
JNGL_RT_DAT	EQU	$
		WORD	UT9205,UT351B,UT90B5
;
JNGL_RT_DAT_SB	EQU	$
		WORD	UT90B9,UT90BB,UT908B
;
;
JNGL_RIGHT	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	JNGL_RT_500
		LDA	<YSIZE
		CMP	#00001
		BNE	JNGL_RT_990
		LDA	#UT964F
		BRA	JNGL_RT_900
;
JNGL_RT_500	EQU	$
		LDA	<YSIZE
		CMP	#00003
		BCS	JNGL_RT_600
		ASL	A
		TAY
		LDA	JNGL_RT_DAT,Y
		STA	<WORKA
		BRA	JNGL_RT_900
;
JNGL_RT_600	EQU	$
		JSL	>RND_RND
		AND	#00001
		CLC
		ADC	#UT907A
		STA	<WORKA
		JSR	JNGL_KS_CHK
		TYA
		BMI	JNGL_RT_690
		LDA	JNGL_RT_DAT_SB,Y
		STA	<WORKA
JNGL_RT_690	EQU	$
		LDA	<WORKA
;
JNGL_RT_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
JNGL_RT_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ジャンクルコース 草チェック		+
;+				out			+
;+				Y : インデックス	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_KS_CHK	EQU	$
		LDY	#00000
		LDA	<NOWUNIT
		CMP	#UT9200
		BCC	JNGL_KS_020
		CMP	#UT9203+1
		BCC	JNGL_KS_080
JNGL_KS_020	EQU	$
		INY
		INY
		CMP	#UT9098
		BCC	JNGL_KS_040
		CMP	#UT909B+1
		BCC	JNGL_KS_080
JNGL_KS_040	EQU	$
		INY
		INY
		CMP	#UT90A8
		BCC	JNGL_KS_070
		CMP	#UT90AB+1
		BCC	JNGL_KS_080
JNGL_KS_070	EQU	$
		LDY	#0FFFFH
JNGL_KS_080	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ジャングル コース どろ床			*
;*								*
;****************************************************************
JNGL_DR_DAT	EQU	$
		WORD	UT9608,UT9300
;
;
JNGL_DORO	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002H
		BCC	JNGL_DR_500
		JMP	JNGL_FOR_500
;
JNGL_DR_500	EQU	$
		JSL	>RND_RND
		AND	#00003H
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<WORK0
		CLC
		ADC	JNGL_DR_DAT,Y
;
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース どろ床の左端			*
;*		ジャングル コース どろ床の右端			*
;*								*
;****************************************************************
JNGL_DR_LR_DT	EQU	$
		WORD	UT9400,UT9502
;
JNGL_DR_LR_ADR	EQU	$
		WORD	JNGL_LT_600,JNGL_RT_600
;
JNGL_DR_LR	EQU	$
		WORD	JNGL_DR_L_ST,JNGL_DR_R_ST
;
;
JNGL_DR_LT	EQU	$
JNGL_DR_RT	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<STUNTNO
		LDA	<YSIZE
		BEQ	JNGL_DR_LR_500
		JMP	(JNGL_DR_LR_ADR,X)
;
JNGL_DR_LR_500	EQU	$
		JSR	(JNGL_DR_LR,X)
;
		LDX	<STUNTNO
		LDA	JNGL_DR_LR_DT,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左端					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_DR_L_ST	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	#UT90A8
		BCC	JNGL_DR_L_990
		CMP	#UT90AB+1
		BCS	JNGL_DR_L_990
;
		LDA	#UT90A7
		STA	>BGUNIT,X
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	#UT964E
		STA	>BGUNIT,X
;
		LDA	<XYPOINT
		AND	#0F0F0H
		SEC
		SBC	#00010H
		AND	#0F0F0H
		STA	<WORK0
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>RITCHK_SB
		LDA	#UT3311
		STA	>BGUNIT,X
;
		LDA	<XYPOINT
		AND	#0F0F0H
		SEC
		SBC	#00020H
		AND	#0F0F0H
		STA	<WORK0
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>RITCHK_SB
		LDA	#UT9204
		STA	>BGUNIT,X
;
JNGL_DR_L_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右端					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_DR_R_ST	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT90A8
		BCC	JNGL_DR_R_990
		CMP	#UT90AB+1
		BCS	JNGL_DR_R_990
;
		LDA	#UT9097
		STA	>BGUNIT,X
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	#UT964F
		STA	>BGUNIT,X
;
		LDA	<XYPOINT
		AND	#0F0F0H
		SEC
		SBC	#00010H
		AND	#0F0F0H
		STA	<WORK0
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>LFTCHK_SB
		LDA	#UT351B
		STA	>BGUNIT,X
;
		LDA	<XYPOINT
		AND	#0F0F0H
		SEC
		SBC	#00020H
		AND	#0F0F0H
		STA	<WORK0
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>LFTCHK_SB
		LDA	#UT9205
		STA	>BGUNIT,X
;
JNGL_DR_R_990	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ジャングル コース どろ斜め床			*
;*					(左下)			*
;****************************************************************
JNGL_LDRU_DT	EQU	$
		WORD	UT9400,UT9070
;
JNGL_LDRU_5DT	EQU	$
		WORD	UT9402,UT90BA,UT908A
;
;
JNGL_LDRU	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#00001
		STA	<LKFLG
		LDA	<YSIZE
		CMP	#00003
		BCC	JNGL_LDRU_100
		JMP	JNGL_FOR_500
;
JNGL_LDRU_100	EQU	$
		LDA	<XSIZE
		BNE	JNGL_LDRU_300
		LDA	<NOWUNIT
		CMP	#UT9098
		BCC	JNGL_LDRU_130
		CMP	#UT909B+1
		BCC	JNGL_LDRU_150
JNGL_LDRU_130	EQU	$
		CMP	#UT90A8
		BCC	JNGL_LDRU_300
		CMP	#UT90AB+1
		BCC	JNGL_LDRU_200
		BRA	JNGL_LDRU_300
JNGL_LDRU_150	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	#UT9204
		STA	>BGUNIT,X
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	#UT964E
		STA	>BGUNIT,X
		LDA	#UT3311
		BRA	JNGL_LDRU_900
;
JNGL_LDRU_200	EQU	$
		LDA	#UT90A7
		BRA	JNGL_LDRU_900
;
JNGL_LDRU_300	EQU	$
		JSL	>RND_RND
		AND	#00001
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	JNGL_LDRU_DT,Y
		CLC
		ADC	<WORK0
		STA	<WORKA
		LDA	<XSIZE
		DEC	A
		CMP	<XSIZECP
		BNE	JNGL_LDRU_590
;
		JSR	JNGL_KS_CHK
		TYA
		BMI	JNGL_LDRU_590
		LDA	JNGL_LDRU_5DT,Y
		STA	<WORKA
		BRA	JNGL_LDRU_800
JNGL_LDRU_590	EQU	$
		LDA	<YSIZE
		CMP	#00002
		BNE	JNGL_LDRU_800
		JMP	JNGL_FOR_500
;
JNGL_LDRU_800	EQU	$
		LDA	<WORKA
JNGL_LDRU_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース どろ斜め床			*
;*					(右下)			*
;****************************************************************
JNGL_LURD_DT	EQU	$
		WORD	UT9501,UT9072
;
JNGL_LURD_5DT	EQU	$
		WORD	UT9500,UT90BB,UT908B
;
;
JNGL_LURD	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#00001
		STA	<LKFLG
		LDA	<YSIZE
		CMP	#00003
		BCC	JNGL_LURD_100
		JMP	JNGL_FOR_500
;
JNGL_LURD_100	EQU	$
		LDA	<XSIZE
		BNE	JNGL_LURD_300
		LDA	<NOWUNIT
		CMP	#UT9098
		BCC	JNGL_LURD_130
		CMP	#UT909B+1
		BCC	JNGL_LURD_150
JNGL_LURD_130	EQU	$
		CMP	#UT90A8
		BCC	JNGL_LURD_300
		CMP	#UT90AB+1
		BCC	JNGL_LURD_200
		BRA	JNGL_LURD_300
JNGL_LURD_150	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	#UT9205
		STA	>BGUNIT,X
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	#UT964F
		STA	>BGUNIT,X
		LDA	#UT351B
		BRA	JNGL_LURD_900
;
JNGL_LURD_200	EQU	$
		LDA	#UT9097
		BRA	JNGL_LURD_900
;
JNGL_LURD_300	EQU	$
		JSL	>RND_RND
		AND	#00001
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	JNGL_LURD_DT,Y
		CLC
		ADC	<WORK0
		STA	<WORKA
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	JNGL_LURD_590
;
		JSR	JNGL_KS_CHK
		TYA
		BMI	JNGL_LURD_590
		LDA	JNGL_LURD_5DT,Y
		STA	<WORKA
		BRA	JNGL_LURD_800
JNGL_LURD_590	EQU	$
		LDA	<YSIZE
		CMP	#00002
		BNE	JNGL_LURD_800
		JMP	JNGL_FOR_500
;
JNGL_LURD_800	EQU	$
		LDA	<WORKA
JNGL_LURD_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース 草天井			*
;*								*
;****************************************************************
KS_UP_LT_DT0	EQU	$
		WORD	UT9B01,UT9B00
		WORD	UT9639,UT9638
		WORD	UT9629,UT9628
		WORD	UT9631,UT9630
		WORD	UT961B,UT9620
;
KS_UP_LT_DT1	EQU	$
		WORD	UT961D,UT961C
		WORD	UT963D,UT963C
		WORD	UT962D,UT962C
		WORD	UT9635,UT9634
		WORD	UT961B,UT9624
;
KS_UP_RT_DT0	EQU	$
		WORD	UT960E,UT960F
		WORD	UT963A,UT963B
		WORD	UT962A,UT962B
		WORD	UT9632,UT9633
		WORD	UT961B,UT9623
;
KS_UP_RT_DT1	EQU	$
		WORD	UT9B02,UT9B03
		WORD	UT963E,UT963F
		WORD	UT962E,UT962F
		WORD	UT9636,UT9637
		WORD	UT961B,UT9627
;
KS_UP_LT_RT	EQU	$
		WORD	KS_UP_LT_DT0,KS_UP_LT_DT1
		WORD	KS_UP_RT_DT0,KS_UP_RT_DT1
;
;
JNGL_KS_UP0	EQU	$
JNGL_KS_UP1	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
		BNE	JNGL_KS_UP_200
		STZ	<LKFLG
		LDA	<YSIZE
		BNE	JNGL_KS_UP_250
		JSL	>RND_RND
		AND	#00002
		STA	<XYCPBF
		BRA	JNGL_KS_UP_250
JNGL_KS_UP_200	EQU	$
		LDA	#00001
		STA	<LKFLG
JNGL_KS_UP_250	EQU	$
		LDA	<YSIZE
		EOR	#0FFFFH
		INC	A
		CMP	#00005
		BCS	JNGL_KS_UP_500
		ASL	A
;;;;K;;;;		CLC
		ADC	<WORK0
		ASL	A
		TAY
		LDA	<XYCPBF
		ORA	<STUNTNO
		TAX
		LDA	KS_UP_LT_RT,X
		STA	<WORK0
		LDA	(<WORK0),Y
		BRA	JNGL_KS_UP_900
;
JNGL_KS_UP_500	EQU	$
		LDA	#UT961B
;
JNGL_KS_UP_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース 杭				*
;*								*
;****************************************************************
JNGL_KUI	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<YSIZE
		BEQ	JNGL_KUI_500
		INY
		INC	A
		CMP	<YSIZECP
		BNE	JNGL_KUI_500
		INY
JNGL_KUI_500	EQU	$
		TYA
		CLC
		ADC	RUT6B00
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		LDA	<YSIZECP
		DEC	A
		BNE	JNGL_KUI_990
		LDA	RUT6B03
		STA	>BGUNIT,X
JNGL_KUI_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース 縦石				*
;*								*
;****************************************************************
JNGL_STN_DT0	EQU	$
		WORD	UT3312,UT351A
;
;
JNGL_STNE	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	JNGL_STN_200
		LDA	<XSIZE
		ASL	A
		TAY
		LDA	JNGL_STN_DT0,Y
		BRA	JNGL_STN_900
;
JNGL_STN_200	EQU	$
		LDA	<XSIZE
		BNE	JNGL_STN_300
		JSL	>RND_RND
		AND	#00006
		CLC
		ADC	#UT90F8
		BRA	JNGL_STN_900
;
JNGL_STN_300	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		INC	A
;
JNGL_STN_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース つる				*
;*					(地面の中)		*
;****************************************************************
JNGL_TL0_ADR	EQU	$
		WORD	JNGL_TL0_LT,JNGL_TL0_RT
;
JNGL_TL0_DT0	EQU	$
		WORD	UT90AC,UT909C
;
JNGL_TL0_DT1	EQU	$
		WORD	UT90A6,UT9096
;
JNGL_TL0_DAT	EQU	$
		WORD	JNGL_TL0_DT0,JNGL_TL0_DT1
;
JNGL_TL0_DT2	EQU	$
		WORD	UT907C,UT908C,UT907C
;
;
JNGL_TULU0	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<XYCPBF
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		CMP	#00002
		BCC	JNGL_TL0_500
		LDA	<YSIZE
		CMP	#00004
		BCS	JNGL_TL0_400
		ASL	A
		TAY
		JSR	(JNGL_TL0_ADR,X)
		BRA	JNGL_TL0_900
;
JNGL_TL0_400	EQU	$
		AND	#00001
		ASL	A
;;;;K;;;;		CLC
		ADC	<XYCPBF
		TAY
		LDA	JNGL_TL0_DT2,Y
		BRA	JNGL_TL0_900
;
JNGL_TL0_500	EQU	$
		ASL	A
		TAY
		LDA	JNGL_TL0_DAT,X
		STA	<WORK0
		LDA	(<WORK0),Y
;
JNGL_TL0_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左より					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_TL0_LT_DT	EQU	$
		WORD	UT9212,UT907D,UT908D,UT909D
;
;
JNGL_TL0_LT	EQU	$
		LDA	<YSIZE
		BNE	JNGL_TL0_LT_00
		LDA	<NOWUNIT
		CMP	#UT9215
		BNE	JNGL_TL0_LT_00
		LDA	#UT9214
		BRA	JNGL_TL0_LT_50
JNGL_TL0_LT_00	EQU	$
		LDA	JNGL_TL0_LT_DT,Y
JNGL_TL0_LT_50	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右より					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_TL0_RT_DT	EQU	$
		WORD	UT9213,UT9090,UT90A0,UT9091
;
;
JNGL_TL0_RT	EQU	$
		LDA	<YSIZE
		BNE	JNGL_TL0_RT_00
		LDA	<NOWUNIT
		CMP	#UT9215
		BNE	JNGL_TL0_RT_00
		LDA	#UT9217
		BRA	JNGL_TL0_RT_50
JNGL_TL0_RT_00	EQU	$
		LDA	JNGL_TL0_RT_DT,Y
JNGL_TL0_RT_50	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ジャングル コース つる				*
;*					(横３キャラ)		*
;****************************************************************
JNGL_TULU1	EQU	$
		JSL	>JNGL_TULU0
		LDA	<YSIZE
		CMP	#004
		BCC	JNGL_TL1_990
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		CMP	#002
		BCC	JNGL_TL1_990
		MI16			; memory , index 16bit mode
		JSL	>RND_RND
		AND	#00002
		BEQ	JNGL_TL1_900
		LDA	<XYPOINT
		STA	<WORKE
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		CMP	#UT907C
		BNE	JNGL_TL1_400
		JSL	>LFTCHK_SB
		LDA	#UT9092
		STA	>BGUNIT,X
		LDA	#UT9093
		BRA	JNGL_TL1_800
;
JNGL_TL1_400	EQU	$
		JSL	>RITCHK_SB
		LDA	#UT90A2
		STA	>BGUNIT,X
		LDA	#UT90A1
;
JNGL_TL1_800	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
JNGL_TL1_900	EQU	$
		MI8			; memory , index 8bit mode
JNGL_TL1_990	EQU	$
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングル コース 木				*
;*								*
;****************************************************************
JNGL_WOD_DT0	EQU	$
		WORD	UT9670,UT153B
;
JNGL_WOD_DT1	EQU	$
		WORD	UT9671,UT9A00
;
JNGL_WOD_DT2	EQU	$
		WORD	UT9672,UT153C
;
;
JNGL_WOOD	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002
		BCS	JNGL_WOD_500
		ASL	A
		TAY
;
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	JNGL_WOD_DT0,Y
		STA	>BGUNIT,X
;
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	JNGL_WOD_DT2,Y
		STA	>BGUNIT,X
;
		LDA	JNGL_WOD_DT1,Y
		BRA	JNGL_WOD_900
;
JNGL_WOD_500	EQU	$
		INC	A
		CMP	<YSIZECP
		BEQ	JNGL_WOD_800
		CMP	#00003
		BNE	JNGL_WOD_600
		LDA	#UT990C
		BRA	JNGL_WOD_900
;
JNGL_WOD_600	EQU	$
		JSL	>RND_RND
		AND	#00002
		LSR	A
;;;;K;;;;		CLC
		ADC	#UT990D
		BRA	JNGL_WOD_900
;
JNGL_WOD_800	EQU	$
		LDA	#UT9206
;
JNGL_WOD_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	ジャングルコース 上からぶらさがっている つる		*
;*						(葉っぱなし)	*
;****************************************************************
JNGL_TLUP0_5DT	EQU	$
		WORD	UT9214,UT9215,UT9214,UT9217
;
;
JNGL_TLUP0	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	JNGL_TLUP0_200
		LDA	<NOWUNIT
		CMP	#UT9B00
		BCC	JNGL_TLUP0_100
		CMP	#UT9B03+1
		BCS	JNGL_TLUP0_100
		JMP	JNGL_TLUP0_990
;
JNGL_TLUP0_100	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDY	#00000
		LDA	>BGUNIT,X
		CMP	#UT963B
		BEQ	JNGL_TLUP0_150
		INY
		CMP	#UT963C
		BEQ	JNGL_TLUP0_150
		INY
		CMP	#UT960E
		BEQ	JNGL_TLUP0_150
		INY
		CMP	#UT961D
		BNE	JNGL_TLUP0_200
JNGL_TLUP0_150	EQU	$
		TYA
		CLC
		ADC	#UT9B04
		STA	>BGUNIT,X
;
JNGL_TLUP0_200	EQU	$
		LDY	#00000
		LDA	<NOWUNIT
		CMP	#UT960F
		BEQ	JNGL_TLUP0_250
		INY
		CMP	#UT961C
		BNE	JNGL_TLUP0_400
JNGL_TLUP0_250	EQU	$
		TYA
		CLC
		ADC	#UT9900
		BRA	JNGL_TLUP0_930
;
JNGL_TLUP0_400	EQU	$
		JSL	>RND_RND
		AND	#00001
		STA	<WORK0
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BEQ	JNGL_TLUP0_500
		LDA	<WORK0
		CLC
		ADC	#UT9908
		BRA	JNGL_TLUP0_900
;
JNGL_TLUP0_500	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT9200
		BNE	JNGL_TLUP0_700
		LDA	<NOWUNIT
		CMP	#UT9210
		BCS	JNGL_TLUP0_550
		LDA	#UT9216
		BRA	JNGL_TLUP0_930
JNGL_TLUP0_550	EQU	$
		SBC	#UT9210
		ASL	A
		TAY
		LDA	JNGL_TLUP0_5DT,Y
		BRA	JNGL_TLUP0_930
;
JNGL_TLUP0_700	EQU	$
		LDA	<WORK0
		CLC
		ADC	#UT00BC
		LDX	<XYCPBF
		BEQ	JNGL_TLUP0_930
		LDA	<WORK0
		CLC
		ADC	#UT00BE
		BRA	JNGL_TLUP0_930
;
JNGL_TLUP0_900	EQU	$
		CLC
		ADC	<XYCPBF
JNGL_TLUP0_930	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
JNGL_TLUP0_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	ジャングルコース 上からぶらさがっている つる		*
;*						(葉っぱあり)	*
;****************************************************************
JNGL_TLUP1_ADR	EQU	$
		WORD	JNGL_TLUP1_LR
		WORD	JNGL_TLUP1_L,JNGL_TLUP1_R
;
;
JNGL_TLUP1	EQU	$
		JSL	>JNGL_TLUP0
		LDA	<YSIZE
		BEQ	JNGL_TLUP1_990
		CMP	#00001
		BEQ	JNGL_TLUP1_990
		INC	A
		CMP	<YSIZECP
		BEQ	JNGL_TLUP1_990
		MI16			; memory , index 16bit mode
		JSL	>RND_RND
		AND	#00007
		CMP	#00006
		BCS	JNGL_TLUP1_950
		STA	<WORKA
;;;;K;;;;		CLC
		ADC	#UT9902
		CLC
		ADC	<XYCPBF
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		LDA	<WORKA
		AND	#0000EH
		TAX
		JSR	(JNGL_TLUP1_ADR,X)
;
JNGL_TLUP1_950	EQU	$
		MI8			; memory , index 8bit mode
JNGL_TLUP1_990	EQU	$
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左右に葉っぱ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_TLUP1_LR	EQU	$
		JSR	JNGL_TLUP1_L
		JSR	JNGL_TLUP1_R
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左に葉っぱ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_TLUP1_L_DT	EQU	$
		WORD	UT9676,UT9678
;
;
JNGL_TLUP1_L	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	<WORKA
		AND	#00001
		ASL	A
		TAY
		LDA	JNGL_TLUP1_L_DT,Y
		LDY	<XYCPBF
		BEQ	JNGL_TLUP1_L99
		INC	A
		INC	A
		INC	A
		INC	A
JNGL_TLUP1_L99	EQU	$
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右に葉っぱ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_TLUP1_R_DT	EQU	$
		WORD	UT9677,UT9679
;
;
JNGL_TLUP1_R	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	<WORKA
		AND	#00001
		ASL	A
		TAY
		LDA	JNGL_TLUP1_R_DT,Y
		LDY	<XYCPBF
		BEQ	JNGL_TLUP1_R99
		INC	A
		INC	A
		INC	A
		INC	A
JNGL_TLUP1_R99	EQU	$
		STA	>BGUNIT,X
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ジャングルコース ブロック			*
;*						(模様あり)	*
;****************************************************************
JNGL_BLCK0_ADR	EQU	$
		WORD	JNGL_BLCK0_UP,JNGL_BLCK_MID,JNGL_BLCK_DWN
;
;
JNGL_BLOCK0	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000
		LDA	<YSIZE
		BEQ	JNGL_BLCK0_180
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BNE	JNGL_BLCK0_180
		INX
		INX
JNGL_BLCK0_180	EQU	$
		JSR	(JNGL_BLCK0_ADR,X)
;
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		模様ブロック 上				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_BLCK0_UP	EQU	$
		LDA	#UT90C0
		LDY	<XSIZE
		BEQ	JNGL_BLK0_UP_90
		INC	A
		INY
		CPY	<XSIZECP
		BEQ	JNGL_BLK0_UP_90
;
		JSL	>RND_RND
		AND	#00001
		CLC
		ADC	#UT90DA
;
JNGL_BLK0_UP_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		中					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JL_BK_MD_ADR	EQU	$
		WORD	JL_BK_MD_LFT,JL_BK_MD_MID,JL_BK_MD_RIT
;
;
JNGL_BLCK_MID	EQU	$
		JSL	>RND_RND
		AND	#00007
		TAY
		LDX	#00000
		LDA	<XSIZE
		BEQ	JNGL_BLK_MID_20
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	JNGL_BLK_MID_20
		INX
		INX
JNGL_BLK_MID_20	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(JL_BK_MD_ADR,X)
		LDA	<WORK4
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		左				+
;++++++++++++++++++++++++++++++++++++++++++++++++
JL_BK_MD_LFT	EQU	$
		TYA
		AND	#00003
		CLC
		ADC	#UT90D0
		STA	<WORK4
		JSL	>LFTCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT90E0
		BEQ	JL_BK_MD_LFT_50
		CMP	#UT90E1
		BEQ	JL_BK_MD_LFT_50
		CMP	#UT90E2
		BEQ	JL_BK_MD_LFT_50
		CMP	#UT90E3
		BNE	JL_BK_MD_LFT_90
JL_BK_MD_LFT_50	EQU	$
		LDA	<WORK4
		INC	A
		INC	A
		INC	A
		INC	A
		STA	<WORK4
;
JL_BK_MD_LFT_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		中				+
;++++++++++++++++++++++++++++++++++++++++++++++++
JL_BK_MD_MID	EQU	$
		TYA
		CLC
		ADC	#UT90F0
		STA	<WORK4
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		右				+
;++++++++++++++++++++++++++++++++++++++++++++++++
JL_BK_MD_RIT	EQU	$
		TYA
		AND	#00003
		CLC
		ADC	#UT90E0
		STA	<WORK4
		JSL	>RITCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT90D0
		BEQ	JL_BK_MD_RIT_50
		CMP	#UT90D1
		BEQ	JL_BK_MD_RIT_50
		CMP	#UT90D2
		BEQ	JL_BK_MD_RIT_50
		CMP	#UT90D3
		BNE	JL_BK_MD_RIT_90
JL_BK_MD_RIT_50	EQU	$
		LDA	<WORK4
		INC	A
		INC	A
		INC	A
		INC	A
		STA	<WORK4
;
JL_BK_MD_RIT_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_BLCK_DWN	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT9200		; 草の上か ?
		BNE	JL_BK_DWN_500	;	NO -> JL_BK_DWN_500
		LDA	#UT90EA
		LDX	<XSIZE		; 左下 ?
		BEQ	JL_BK_DWN_900	;	YES -> JL_BK_DWN_900
		INC	A
		INX
		CPX	<XSIZECP	; 右下 ?
		BEQ	JL_BK_DWN_900	;	YES -> JL_BK_DWN_900
		JSL	>RND_RND
		AND	#00003
		CLC
		ADC	#UT90EC
		BRA	JL_BK_DWN_900
;
JL_BK_DWN_500	EQU	$
		LDA	#UT90C7
		LDX	<XSIZE
		BEQ	JL_BK_DWN_900
		INC	A
		INX
		CPX	<XSIZECP
		BEQ	JL_BK_DWN_900
		JSL	>RND_RND
		AND	#00003
		CLC
		ADC	#UT90CC
;
JL_BK_DWN_900	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ジャングルコース ブロック			*
;*						(模様なし)	*
;****************************************************************
JNGL_BLCK1_ADR	EQU	$
		WORD	JNGL_BLCK1_UP,JNGL_BLCK_MID,JNGL_BLCK_DWN
;
;
JNGL_BLOCK1	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000
		LDA	<YSIZE
		BEQ	JNGL_BLCK1_180
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BNE	JNGL_BLCK1_180
		INX
		INX
JNGL_BLCK1_180	EQU	$
		JSR	(JNGL_BLCK1_ADR,X)
;
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JNGL_BLCK1_UP	EQU	$
		LDA	#UT90C2
		LDX	<XSIZE
		BEQ	JNGL_BLK1_UP_90
		INC	A
		INX
		CPX	<XSIZECP
		BEQ	JNGL_BLK1_UP_90
		JSL	>RND_RND
		AND	#00003
		CLC
		ADC	#UT90DC
;
JNGL_BLK1_UP_90	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ジャングルコース 水面草				*
;*								*
;****************************************************************
JNGL_WRTKS_DT0	EQU	$
		WORD	UT9640,UT9650
;
JNGL_WRTKS_DT1	EQU	$
		WORD	UT9641,UT9651
;
JNGL_WRTKS_DT2	EQU	$
		WORD	UT9642,UT9652
;
JNGL_WRTKS_DT3	EQU	$0
		WORD	UT9643,UT9653
;
JNGL_WRTKS_DT4	EQU	$
		WORD	UT9644,UT9654
;
JNGL_WRTKS_DT5	EQU	$
		WORD	UT9645,UT9655
;
JNGL_WRTKS_DT6	EQU	$
		WORD	UT9646,UT9656
;
JNGL_WRTKS_DT7	EQU	$
		WORD	UT9647,UT9657
;
JNGL_WRTKS_DT8	EQU	$
		WORD	UT9648,UT9658
;
JNGL_WRTKS_DT9	EQU	$
		WORD	UT9649,UT9659
;
JNGL_WRTKS_DTA	EQU	$
		WORD	UT964A,UT965A
;
JNGL_WRTKS_DTB	EQU	$
		WORD	UT964B,UT965B
;
JNGL_WRTKS_DTC	EQU	$
		WORD	00000H,UT965C
;
JNGL_WRTKS_DTD	EQU	$
		WORD	00000H,UT965D
;
JNGL_WRTKS_DTE	EQU	$
		WORD	00000H,UT965E
;
JNGL_WRTKS_DTF	EQU	$
		WORD	00000H,UT965F
;
JNGL_WRTKS_DAT	EQU	$
		WORD	JNGL_WRTKS_DT0,JNGL_WRTKS_DT1,JNGL_WRTKS_DT2
		WORD	JNGL_WRTKS_DT3,JNGL_WRTKS_DT4,JNGL_WRTKS_DT5
		WORD	JNGL_WRTKS_DT6,JNGL_WRTKS_DT7,JNGL_WRTKS_DT8
		WORD	JNGL_WRTKS_DT9,JNGL_WRTKS_DTA,JNGL_WRTKS_DTB
		WORD	JNGL_WRTKS_DTC,JNGL_WRTKS_DTD,JNGL_WRTKS_DTE
		WORD	JNGL_WRTKS_DTF
;
;
JNGL_WRTKS	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	JNGL_WRTKS_500
		JSL	>RND_RND
		AND	#0000FH*2
		STA	<XYCPBF
;
JNGL_WRTKS_500	EQU	$
		LDA	<YSIZE
		ASL	A
		TAY
		LDX	<XYCPBF
		LDA	JNGL_WRTKS_DAT,X
		STA	<WORK0
		LDA	(<WORK0),Y
		BEQ	JNGL_WRTKS_990
		STA	<WORK0
		LDX	<UNITPOS
;
		LDY	<YSIZE
		BEQ	JNGL_WRTKS_900
		LDA	>BGUNIT,X
		CMP	#UT9608
		BEQ	JNGL_WRTKS_550
		CMP	#UT9609
		BEQ	JNGL_WRTKS_550
		CMP	#UT960A
		BEQ	JNGL_WRTKS_550
		CMP	#UT960B
		BNE	JNGL_WRTKS_900
JNGL_WRTKS_550	EQU	$
		LDA	<WORK0
		CLC
		ADC	#00010H
		STA	<WORK0
;
JNGL_WRTKS_900	EQU	$
		LDA	<WORK0
		STA	>BGUNIT,X
JNGL_WRTKS_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ジャングルコース 水				*
;*								*
;****************************************************************
JNGL_WTR_DT0	EQU	$
		WORD	UT161C,UT161D
		WORD	UT162C,UT162D
;
JNGL_WTR_DT1	EQU	$
		WORD	UT161E,UT161F
		WORD	UT162E,UT162E
;
JNGL_WTR_DAT	EQU	$
		WORD	JNGL_WTR_DT1,JNGL_WTR_DT0
		WORD	JNGL_WTR_DT1,JNGL_WTR_DT1
;
JNGL_WTR_DT_SB	EQU	$
		WORD	UT90B0,UT90B1,UT90B2,UT90B0
;
;
JUNGLE_WTR	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
;
		LDA	<YSIZE
		BEQ	JNGL_WTR_400
		CMP	#00002
		BCC	JNGL_WTR_500
		LDA	#UT162E
		BRA	JNGL_WTR_600
;
JNGL_WTR_400	EQU	$
		LDA	<WORK0
		BNE	JNGL_WTR_500
		JSL	>RND_RND
		AND	#00006
		STA	<STUNTNO
;
JNGL_WTR_500	EQU	$
		LDX	<STUNTNO
		LDA	JNGL_WTR_DAT,X
		STA	<WORK2
;
		LDA	<YSIZE
		ASL	A
;;;;K;;;;		CLC
		ADC	<WORK0
		ASL	A
		TAY
		LDA	(<WORK2),Y
;
JNGL_WTR_600	EQU	$
		STA	<WORK0
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT6B00
		BEQ	JNGL_WTR_610
		CMP	#UT9300
		BEQ	JNGL_WTR_610
		CMP	#UT9000
		BNE	JNGL_WTR_800
JNGL_WTR_610	EQU	$
		STZ	<STUNTNO
		LDA	<YSIZE
		BNE	JNGL_WTR_630
		LDA	#UT9079
		BRA	JNGL_WTR_850
JNGL_WTR_630	EQU	$
		CMP	#00002
		BCS	JNGL_WTR_650
		JSL	>RND_RND
		AND	#00006
		TAY
		LDA	JNGL_WTR_DT_SB,Y
		BRA	JNGL_WTR_850
JNGL_WTR_650	EQU	$
		LDA	#UT90B3
		BRA	JNGL_WTR_850
;
JNGL_WTR_800	EQU	$
		CMP	#UT9400
		BEQ	JNGL_WTR_820
		CMP	#UT9500
		BNE	JNGL_WTR_900
		LDA	#UT9800
		BRA	JNGL_WTR_840
JNGL_WTR_820	EQU	$
		LDA	#UT9700
JNGL_WTR_840	EQU	$
		LDY	<YSIZE
		BEQ	JNGL_WTR_850
		INC	A
;
JNGL_WTR_850	EQU	$
		STA	<WORK0
;
JNGL_WTR_900	EQU	$
		LDA	<WORK0
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		半当たりの 橋					*
;*								*
;****************************************************************
HN_ATR_HS	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		BNE	HN_ATR_HS_990
		LDA	#UT1516
		LDX	<UNITPOS
		STA	>BGUNIT,X
HN_ATR_HS_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		溶岩コース 大きい岩				*
;*								*
;****************************************************************
YG_IWA_BIG_DT0	EQU	$
		WORD	UT9D00,UT9D01,UT9D02,UT9D03
		WORD	UT9D10,UT9D11,UT9D12,UT9D13
		WORD	UT9D20,UT9D21,UT9D22,UT9D23
;
YG_IWA_BIG_DT1	EQU	$
		WORD	UT9D30,UT9D31,UT9D32,UT9D33
		WORD	UT9D40,UT9D41,UT9D42,UT9D43
		WORD	UT9D50,UT9D51,UT9D52,UT9D53
;
YG_BIG_DAT	EQU	$
		BYTE	LOW UT9D04,LOW UT9D05,LOW UT9D06,LOW UT9D07
		BYTE	LOW UT9D04,LOW UT9D05,LOW UT9D06,LOW UT9D07
		BYTE	LOW UT9D08,LOW UT9D09
		BYTE	LOW UT9D14,LOW UT9D11,LOW UT9D12,LOW UT9D17
		BYTE	LOW UT9D14,                      LOW UT9D17
		BYTE	LOW UT9D28,LOW UT9D29
		BYTE	LOW UT9D24,LOW UT9D25,LOW UT9D26,LOW UT9D27
		BYTE	LOW UT9D24,LOW UT9D25,LOW UT9D26,LOW UT9D27
		BYTE	LOW UT9D28,LOW UT9D29
		BYTE	LOW UT9D34,LOW UT9D35,LOW UT9D36,LOW UT9D37
		BYTE	LOW UT9D34,LOW UT9D35,LOW UT9D36,LOW UT9D37
		BYTE	LOW UT9D44,LOW UT9D41,LOW UT9D42,LOW UT9D47
		BYTE	LOW UT9D44,                      LOW UT9D47
		BYTE	LOW UT9D54,LOW UT9D55,LOW UT9D56,LOW UT9D57
		BYTE	LOW UT9D54,LOW UT9D55,LOW UT9D56,LOW UT9D57
;
YG_IWA_BIG_ADR	EQU	$
		WORD	YG_BIG_000,YG_BIG_100,YG_BIG_200,YG_BIG_300
		WORD	YG_BIG_400,YG_BIG_500,YG_BIG_600,YG_BIG_700
		WORD	YG_BIG_800,YG_BIG_900,YG_BIG_A00,YG_BIG_B00
;
;
YGN_IWA_BIG	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BEQ	YG_IWA_BIG_050
		INC	A
		CMP	<YSIZECP
		BEQ	YG_IWA_BIG_040
		LDA	#00001
		BRA	YG_IWA_BIG_050
YG_IWA_BIG_040	EQU	$
		LDA	#00002
YG_IWA_BIG_050	EQU	$
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		BEQ	YG_IWA_BIG_080
		INC	A
		CMP	<XSIZECP
		BNE	YG_IWA_BIG_070
		LDA	#00003
		BRA	YG_IWA_BIG_080
YG_IWA_BIG_070	EQU	$
		AND	#00001
		INC	A
YG_IWA_BIG_080	EQU	$
		ORA	<WORK0
		ASL	A
		TAY
;
		LDA	<STUNTNO
		BNE	YG_IWA_BIG_250
		LDA	YG_IWA_BIG_DT0,Y
		BRA	YG_IWA_BIG_280
YG_IWA_BIG_250	EQU	$
		LDA	YG_IWA_BIG_DT1,Y
YG_IWA_BIG_280	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		TYX
		JSR	(YG_IWA_BIG_ADR,X)
;
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左上チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_000	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		STX	<WORK4
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 上ＯＫ ?
		BNE	YG_BIG_090	;	NO -> YG_BIG_090
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORK6
;
		JSR	LEFT_CHK	; 左ブロック チェック
		STX	<WORK8
		AND	#0FF00H
		CMP	#UT9D00		; 左ＯＫ ?
		BNE	YG_BIG_090	;	NO -> YG_BIG_090
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORKA
;
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 左上ＯＫ ?
		BNE	YG_BIG_090	;	NO -> YG_BIG_090
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<WORK4
		LDA	<WORK6
		JSR	YG_BIG_CHNG
		LDX	<WORK8
		LDA	<WORKA
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 左上ＯＫ ?
		BNE	YG_BIG_090	;	NO -> YG_BIG_090
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_090	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_100	EQU	$
YG_BIG_200	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK4
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK4
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 左上ＯＫ ?
		BNE	YG_BIG_12_90	;	NO -> YG_BIG_12_90
;
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK4
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 右上ＯＫ ?
		BNE	YG_BIG_12_90	;	NO -> YG_BIG_12_90
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 上ＯＫ ?
		BNE	YG_BIG_12_90	;	NO -> YG_BIG_12_90
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00
		BNE	YG_BIG_12_90
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_12_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右上チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_300	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		STX	<WORK4
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 上ＯＫ ?
		BNE	YG_BIG_390	;	NO -> YG_BIG_390
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORK6
;
		JSR	RIGT_CHK	; 右ブロック チェック
		STX	<WORK8
		AND	#0FF00H
		CMP	#UT9D00		; 右ＯＫ ?
		BNE	YG_BIG_390	;	NO -> YG_BIG_390
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORKA
;
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 右上ＯＫ ?
		BNE	YG_BIG_390	;	NO -> YG_BIG_390
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<WORK4
		LDA	<WORK6
		JSR	YG_BIG_CHNG
		LDX	<WORK8
		LDA	<WORKA
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00
		BNE	YG_BIG_390
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_390	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_400	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK8
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK8
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 左上ＯＫ ?
		BNE	YG_BIG_490	;	NO -> YG_BIG_490
;
		LDA	<XYPOINT
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK8
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 左下ＯＫ ?
		BNE	YG_BIG_490	;	NO -> YG_BIG_490
;
		JSR	LEFT_CHK	; 左ブロック チェック
		AND	#0FF00H
		CMP	#UT9D00		; 左ＯＫ ?
		BNE	YG_BIG_490	;	NO -> YG_BIG_490
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00
		BNE	YG_BIG_490
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_490	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		なし					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_500	EQU	$
YG_BIG_600	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_700	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK8
		TXA
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK8
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 右上ＯＫ ?
		BNE	YG_BIG_790	;	NO -> YG_BIG_790
;
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK8
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 右下ＯＫ ?
		BNE	YG_BIG_790	;	NO -> YG_BIG_790
;
		JSR	RIGT_CHK	; 右ブロック チェック
		AND	#0FF00H
		CMP	#UT9D00		; 右ＯＫ ?
		BNE	YG_BIG_790	;	NO -> YG_BIG_790
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00
		BNE	YG_BIG_790
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_790	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左下チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_800	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		STX	<WORK4
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 下ＯＫ ?
		BNE	YG_BIG_890	;	NO -> YG_BIG_890
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORK6
;
		JSR	LEFT_CHK	; 左ブロック チェック
		STX	<WORK8
		AND	#0FF00H
		CMP	#UT9D00		; 左ＯＫ ?
		BNE	YG_BIG_890	;	NO -> YG_BIG_890
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORKA
;
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 左下ＯＫ ?
		BNE	YG_BIG_890	;	NO -> YG_BIG_890
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<WORK4
		LDA	<WORK6
		JSR	YG_BIG_CHNG
		LDX	<WORK8
		LDA	<WORKA
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00
		BNE	YG_BIG_890
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_890	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_900	EQU	$
YG_BIG_A00	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK8
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK8
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 左下ＯＫ ?
		BNE	YG_BIG_9A_90	;	NO -> YG_BIG_9A_90
;
		LDA	<XYPOINT
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK8
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 右下ＯＫ ?
		BNE	YG_BIG_9A_90	;	NO -> YG_BIG_9A_90
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 下ＯＫ ?
		BNE	YG_BIG_9A_90	;	NO -> YG_BIG_9A_90
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00
		BNE	YG_BIG_9A_90
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_9A_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右下チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_B00	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		STX	<WORK4
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 下ＯＫ ?
		BNE	YG_BIG_B90	;	NO -> YG_BIG_B90
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORK6
;
		JSR	RIGT_CHK	; 右ブロック チェック
		STX	<WORK8
		AND	#0FF00H
		CMP	#UT9D00		; 右ＯＫ ?
		BNE	YG_BIG_B90	;	NO -> YG_BIG_B90
		LDA	>BGUNIT,X
		AND	#000FFH
		STA	<WORKA
;
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00		; 右下ＯＫ ?
		BNE	YG_BIG_B90	;	NO -> YG_BIG_B90
		LDA	>BGUNIT,X
		AND	#000FFH
;
		JSR	YG_BIG_CHNG
		LDX	<WORK4
		LDA	<WORK6
		JSR	YG_BIG_CHNG
		LDX	<WORK8
		LDA	<WORKA
		JSR	YG_BIG_CHNG
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT9D00
		BNE	YG_BIG_B90
		LDA	>BGUNIT,X
		AND	#000FFH
		JSR	YG_BIG_CHNG
;
YG_BIG_B90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		ユニット チェンジ !!		+
;++++++++++++++++++++++++++++++++++++++++++++++++
YG_BIG_CHNG	EQU	$
		TAY
		LDA	YG_BIG_DAT,Y
		AND	#000FFH
		ORA	#UT9D00
		STA	>BGUNIT,X
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		溶岩コース 小さい岩				*
;*								*
;****************************************************************
YGN_IWA_SML_DAT	EQU	$
		WORD	UT9D08,UT9D09
		WORD	UT9D18,UT9D19
;
YGN_IWA_SML_ADR	EQU	$
		WORD	YG_BIG_000,YG_BIG_300
		WORD	YG_BIG_800,YG_BIG_B00
;
;
YGN_IWA_SML	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00001
		ORA	<WORK0
		ASL	A
		TAY
		LDA	YGN_IWA_SML_DAT,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		TYX
		JSR	(YGN_IWA_SML_ADR,X)
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右上がり逆坂 60ﾟ 			*
;*								*
;****************************************************************
ANAURU60_DAT	EQU	$
		WORD	RUTA200,RUTA100
;
;
KUSAANAURU60	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	ANAURU60_100
		LDA	<YSIZE
		BNE	ANAURU60_100
		DEC	<YSIZECP
		DEC	<YSIZECP
		BEQ	ANAURU60_050
		BPL	ANAURU60_100
ANAURU60_050	EQU	$
		LDA	#00001
		STA	<YSIZECP
;
ANAURU60_100	EQU	$
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		BEQ	ANAURU60_500
		CMP	#00001
		BEQ	ANAURU60_500
		JSR	ANATUTI		; 土 セット
		BRA	ANAURU60_900
;
ANAURU60_500	EQU	$
		ASL	A
		TAY
		LDX	ANAURU60_DAT,Y
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
ANAURU60_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右下がり逆坂 60ﾟ 			*
;*								*
;****************************************************************
ANAURD60_DAT	EQU	$
		WORD	RUTA000,RUT9F00
;
;
KUSAANAURD60	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	ANAURD60_100
		LDA	<YSIZE
		BNE	ANAURD60_100
		INC	<YSIZECP
		INC	<YSIZECP
;
ANAURD60_100	EQU	$
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		BEQ	ANAURD60_500
		CMP	#00001
		BEQ	ANAURD60_500
		JSR	ANATUTI		; 土 セット
		BRA	ANAURD60_900
;
ANAURD60_500	EQU	$
		ASL	A
		TAY
		LDX	ANAURD60_DAT,Y
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
ANAURD60_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		常駐縦ドカン					*
;*								*
;****************************************************************
TTDKN_UPDWN	EQU	$
		WORD	UT7D09
		WORD	UT9D60
		WORD	UT9D62
;
TTDKN_UPDWN_SB	EQU	$
		WORD	UT79FA
		WORD	UT79FC
		WORD	UT79FE
;
TTDKN_DWNUP	EQU	$
		WORD	UT7D0B
		WORD	UT9D60
		WORD	UT9D64
;
TTDKN_DWNUP_SB	EQU	$
		WORD	UT79AE
		WORD	UT79FC
		WORD	UT79A5
;
TTDKN_ADD	EQU	$
		WORD	00001H,0FFFFH
;
;
TTDOKAN		EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000H
		LDA	<YSIZECP
		BPL	TTDKN_000
		INX
		INX
;
TTDKN_000	EQU	$
		LDY	#00000H
		LDA	<YSIZE
		BEQ	TTDKN_100
		INY
		INY
		CLC
		ADC	TTDKN_ADD,X
		CMP	<YSIZECP
		BNE	TTDKN_100
		INY
		INY
TTDKN_100	EQU	$
		TXA
		BNE	TTDKN_500
		LDA	<STUNTNO
		BNE	TTDKN_150
		LDA	TTDKN_UPDWN,Y
		BRA	TTDKN_800
TTDKN_150	EQU	$
		LDA	TTDKN_UPDWN_SB,Y
		BRA	TTDKN_800
;
TTDKN_500	EQU	$
		LDA	<STUNTNO
		BNE	TTDKN_550
		LDA	TTDKN_DWNUP,Y
		BRA	TTDKN_800
TTDKN_550	EQU	$
		LDA	TTDKN_DWNUP_SB,Y
TTDKN_800	EQU	$
		CLC
		ADC	<XSIZE
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	雪 コース 雲						*
;*								*
;****************************************************************
SNOWKUMO	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<YSIZE
		BEQ	SNOWKUMO_050
		INY
		INY
		INC	A
		CMP	<YSIZECP
		BNE	SNOWKUMO_050
		INY
		INY
SNOWKUMO_050	EQU	$
		LDA	<XSIZE
		BEQ	SNOWKUMO_100
		INC	A
		CMP	<XSIZECP
		BNE	SNOWKUMO_200
		BRA	SNOWKUMO_300
;
SNOWKUMO_100	EQU	$		; right side data set
		LDA	<NOWUNIT
		CMP	#UT00B8
		BEQ	SNOWKUMO_110
		CMP	#UT00B9
		BNE	SNOWKUMO_120
SNOWKUMO_110	EQU	$
		INY
		INY
		INY
		INY
		INY
		INY
SNOWKUMO_120	EQU	$
		LDA	SNOWKUMO_1DT,Y
		BRA	SNOWKUMO_900
;
SNOWKUMO_200	EQU	$		; center line data set
		LDA	<XSIZE
		EOR	#00001H
		AND	#00001H
		STA	<WORK0
		LDA	SNOWKUMO_2DT,Y
		CLC
		ADC	<WORK0
		BRA	SNOWKUMO_900
;
SNOWKUMO_300	EQU	$		; left side data set
		LDA	SNOWKUMO_3DT,Y
;
SNOWKUMO_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
SNOWKUMO_1DT	EQU	$
		WORD	UT00C6,UT3C00,UT00BB
		WORD	UT00B7,UT3C00,UT00BB
;
SNOWKUMO_2DT	EQU	$
		WORD	UT00B8,UT3C01,UT00C0
;
SNOWKUMO_3DT	EQU	$
		WORD	UT00BA,UT3C03,UT00C2
;
;
;****************************************************************
;*								*
;*	雪 コース ２本セットの細い棒				*
;*								*
;****************************************************************
SNOWBOUSD	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<NOWUNIT
		CMP	#UT00A2
		BEQ	SNOWBOUSD_100
		CMP	#UT00A3
		BEQ	SNOWBOUSD_100
		CMP	#UT00B6
		BNE	SNOWBOUSD_200
SNOWBOUSD_100	EQU	$
		LDA	#UT00B7
		BRA	SNOWBOUSD_900
;
SNOWBOUSD_200	EQU	$
		LDY	#00000H
		LDA	<YSIZE
		BEQ	SNOWBOUSD_500
		INY
		INY
		INC	A
		CMP	<YSIZECP
		BNE	SNOWBOUSD_500
		INY
		INY
SNOWBOUSD_500	EQU	$
		LDA	SNOWBOUSD_DAT,Y
		TAY
		LDA	0,Y
SNOWBOUSD_900	EQU	$
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
SNOWBOUSD_DAT	EQU	$
		WORD	UTUTC3,UTUTC4,RUT2A0C
;
UTUTC3		EQU	$
		WORD	UT00C3
;
UTUTC4		EQU	$
		WORD	UT00C4
;
;
;****************************************************************
;*								*
;*	溶岩 コース 針壁 (右)					*
;*	溶岩 コース 針壁 (左)					*
;*								*
;****************************************************************
YOGANHARI	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<STUNTNO
		AND	#00006H
		TAY
		LDA	<YSIZE
		BEQ	YOGANHARI_100
		INY
		INY
YOGANHARI_100	EQU	$
		LDA	<NOWUNIT
		BEQ	YOGANHARI_200
		INY
		INY
YOGANHARI_200	EQU	$
		LDX	<UNITPOS
		LDA	YOGANHARI_DT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
YOGANHARI_DT	EQU	$
		WORD	UT0119,UT2904,UT2906	; right data
		WORD	UT011A,UT2905,UT2907	; left data
;
;
;****************************************************************
;*								*
;*	カベ コース 横ならび ブロック				*
;*								*
;****************************************************************
KABEHBLOCK_ADR	EQU	$
		WORD	KAGE_YKSTRT,KAGE_YOKO
;
;
KABEHBLOCK	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<XSIZECP
		ORA	<YSIZECP
		DEC	A
		BNE	KABEHBLOCK_100
		LDA	#UT0163
		STA	>BGUNIT,X
		JSR	KAGE_YKSTRT
		JSR	KAGE_TTSTRT
		JSR	KAGE_END
		BRA	KABEHBLOCK_900
;
KABEHBLOCK_100	EQU	$
		LDY	#00000
		LDA	<XSIZE
		BEQ	KABEHBLOCK_150
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	KABEHBLOCK_150
		INY
		INY
KABEHBLOCK_150	EQU	$
		LDA	KABEHBLOCK_DAT,Y
		STA	>BGUNIT,X
;
		LDX	#00000
		LDA	<XSIZE
		BEQ	KABEHBLOCK_300
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BEQ	KABEHBLOCK_500
KABEHBLOCK_300	EQU	$
		JSR	(KABEHBLOCK_ADR,X)
		BRA	KABEHBLOCK_900
;
KABEHBLOCK_500	EQU	$
		JSR	KAGE_TTSTRT
		JSR	KAGE_YOKO
		JSR	KAGE_END
;
KABEHBLOCK_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABEHBLOCK_DAT	EQU	$
		WORD	UT0160,UT0161,UT0162
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	横のはじめの影チェック ＆ セット		+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KAGE_STED_CMP	EQU	$
		WORD	UT00D5,UT00D6,UT00D7,UT00D8
		WORD	UT00D9,UT00DA,UT150F,UT1510
		WORD	UT00E4
;
KAGE_YKSTAT_DT	EQU	$
		WORD	UT00D6,UT00D6,UT00E8,UT00E8
		WORD	UT00D9,UT00D9,UT1521,UT1521
		WORD	UT00D6
;
;
KAGE_YKSTRT	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		LDY	#00000
KAGE_YKSTRT_10	EQU	$
		CMP	KAGE_STED_CMP,Y
		BEQ	KAGE_YKSTRT_50
		INY
		INY
		CPY	#KAGE_YKSTAT_DT-KAGE_STED_CMP
		BCC	KAGE_YKSTRT_10
		BRA	KAGE_YKSTRT_90
;
KAGE_YKSTRT_50	EQU	$
		LDA	KAGE_YKSTAT_DT,Y
		STA	>BGUNIT,X
KAGE_YKSTRT_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	縦のはじめの影チェック ＆ セット		+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KAGE_TTSTRT_DT	EQU	$
		WORD	UT00D7,UT00E8,UT00D7,UT00D8
		WORD	UT00E8,UT00D8,UT1521,UT1521
		WORD	UT00D7
;
;
KAGE_TTSTRT	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		LDY	#00000
KAGE_TTSTRT_10	EQU	$
		CMP	KAGE_STED_CMP,Y
		BEQ	KAGE_TTSTRT_50
		INY
		INY
		CPY	#KAGE_YKSTAT_DT-KAGE_STED_CMP
		BCC	KAGE_TTSTRT_10
		BRA	KAGE_TTSTRT_90
;
KAGE_TTSTRT_50	EQU	$
		LDA	KAGE_TTSTRT_DT,Y
		STA	>BGUNIT,X
KAGE_TTSTRT_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+		横の影チェック ＆ セット		+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KAGE_CMP	EQU	$
		WORD	UT00D1,UT00D2,UT00D3,UT00D4
		WORD	UT00D5,UT00D6,UT00D7,UT00D8
		WORD	UT00D9,UT00DA,UT00DC,UT00DD
		WORD	UT00DE,UT00DF,UT00E9,UT00EA
		WORD	UT150F,UT1510,UT00E4
KAGE_CMP_CK	EQU	$
;
KAGE_YOKO_DAT	EQU	$
		WORD	UT77E6,UT77E7,UT77E8,UT77E9
		WORD	UT00D9,UT00D9,UT00E8,UT00E8
		WORD	UT00D9,UT00D9,UT77E2,UT77E3
		WORD	UT77E4,UT77E5,UT77E0,UT77E1
		WORD	UT1520,UT1520,UT00D9
;
;
KAGE_YOKO	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		LDY	#00000
KAGE_YOKO_200	EQU	$
		CMP	KAGE_CMP,Y
		BEQ	KAGE_YOKO_400
		INY
		INY
		CPY	#KAGE_CMP_CK-KAGE_CMP
		BCC	KAGE_YOKO_200
		BRA	KAGE_YOKO_900
;
KAGE_YOKO_400	EQU	$
		LDA	KAGE_YOKO_DAT,Y
		STA	>BGUNIT,X
;
KAGE_YOKO_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+		縦の影チェック ＆ セット		+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KAGE_TATE_CMP	EQU	$-(KAGE_CMP_CK-KAGE_CMP)
KAGE_TATE_DTSB	EQU	$
		WORD	UT0093,UT0094,UT0095,UT0096,UT0097
KAGE_TATE_CMPCK	EQU	$
		WORD	UT0098,UT0099,UT009A,UT009B,UT009C
;
;
KAGE_TATE_DAT	EQU	$
		WORD	UT77EF,UT77F1,UT77F0,UT77EE
		WORD	UT00D8,UT00E8,UT00D8,UT00D8
		WORD	UT00E8,UT00D9,UT77ED,UT77EB
		WORD	UT77EA,UT77EC,UT77E0,UT77E1
		WORD	UT1521,UT1521,UT00D8
;
;
KAGE_TATE	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		LDY	#00000
KAGE_TATE_200	EQU	$
		CMP	KAGE_CMP,Y
		BEQ	KAGE_TATE_400
		INY
		INY
		CPY	#KAGE_CMP_CK-KAGE_CMP
		BCC	KAGE_TATE_200
		CMP	#UT0037
		BNE	KAGE_TATE_250
		LDA	#UT0038
		BRA	KAGE_TATE_405
;
KAGE_TATE_250	EQU	$
		CMP	KAGE_TATE_CMP,Y
		BEQ	KAGE_TATE_300
		INY
		INY
		CPY	#KAGE_TATE_DAT-KAGE_TATE_CMP
		BCC	KAGE_TATE_250
		BRA	KAGE_TATE_900
;
KAGE_TATE_300	EQU	$
		CPY	#KAGE_TATE_CMPCK-KAGE_TATE_CMP
		BCS	KAGE_TATE_900
		LDA	<YSIZE
		CMP	#00001
		BNE	KAGE_TATE_350
		JSL	>RND_RND
		AND	#00006
		TAY
		LDA	KAGE_TATE_DTSB,Y
		BRA	KAGE_TATE_405
;
KAGE_TATE_350	EQU	$
		LDA	#UT003A
		BRA	KAGE_TATE_405
;
KAGE_TATE_400	EQU	$
		LDA	KAGE_TATE_DAT,Y
KAGE_TATE_405	EQU	$
		STA	>BGUNIT,X
;
KAGE_TATE_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+		おわりの影チェック ＆ セット		+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KAGE_END_DT	EQU	$
		WORD	UT00DA,UT00D9,UT00D8,UT00D8
		WORD	UT00D9,UT00DA,UT1521,UT1521
		WORD	UT00DA
;
;
KAGE_END	EQU	$
		LDA	<XYPOINT
		PHA
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		STA	<WORKE
		PLA
		AND	#0F0F0H
		ORA	<WORKE
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		LDY	#00000
KAGE_END_10	EQU	$
		CMP	KAGE_STED_CMP,Y
		BEQ	KAGE_END_50
		INY
		INY
		CPY	#KAGE_YKSTAT_DT-KAGE_STED_CMP
		BCC	KAGE_END_10
		BRA	KAGE_END_90
;
KAGE_END_50	EQU	$
		LDA	KAGE_END_DT,Y
		STA	>BGUNIT,X
KAGE_END_90	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	カベ コース 縦ならび ブロック				*
;*								*
;****************************************************************
KBVBLCK_DT0	EQU	$
		WORD	UT00C9,UT00CB
;
KBVBLCK_DT1	EQU	$-2
		WORD	UT00CD,UT00CC,UT00C9
;
;
KABEVBLOCK	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT7E00		; 溶岩の中 ?
		BEQ	KBVBLCK_990	;	YES -> KBVBLCK_990
		LDA	<YSIZECP
		SEC
		SBC	<YSIZE
		CMP	#00004H
		BCC	KBVBLCK_140
		LDA	<YSIZE
		AND	#00001
		ASL	A
		TAY
		LDA	KBVBLCK_DT0,Y
		BRA	KBVBLCK_160
;
KBVBLCK_140	EQU	$
		ASL	A
		TAY
		LDA	KBVBLCK_DT1,Y
;
KBVBLCK_160	EQU	$
		JMP	BVBLCK_KAGE
;
KBVBLCK_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		カベコース 縦ならび ブロック２			*
;*								*
;****************************************************************
KBVBLCK2_DT	EQU	$
		WORD	UT00C9,UT00CA,UT00CB
;
KBVBLK_YGDT	EQU	$
		WORD	UT779A,UT779B,UT779C
		WORD	UT779A,UT779A
;
;
KABEVBLOCK2	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	#UT7E00		; 溶岩の中 ?
		BEQ	KBVBLCK_KAGE_90	;	YES -> KBVBLCK_KAGE_90
		LDY	#00000H
		LDA	<YSIZE
		BEQ	KBVBLCK2_100
		INY
		INY
		INC	A
		CMP	<YSIZECP
		BNE	KBVBLCK2_100
		INY
		INY
KBVBLCK2_100	EQU	$
		LDA	KBVBLCK2_DT,Y
;
BVBLCK_KAGE	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		SEC
		SBC	#UT00C9
		ASL	A
		TAY
		LDA	<NOWUNIT
		CMP	#UT003B		; 溶岩の表面 ?
		BEQ	BVBLCK_KG_50	;	YES -> BVBLCK_KG_50
		CMP	#UT0093		;	NO --> BVBLCK_KG_60
		BCC	BVBLCK_KG_60
		CMP	#UT009C+1
		BCS	BVBLCK_KG_60
BVBLCK_KG_50	EQU	$
		LDA	KBVBLK_YGDT,Y
		STA	>BGUNIT,X
BVBLCK_KG_60	EQU	$
		LDA	<YSIZE
		BNE	KBVBLCK_KAGE_20
		JSR	KAGE_TTSTRT
		BRA	KBVBLCK_KAGE_90
KBVBLCK_KAGE_20 EQU	$
		JSR	KAGE_TATE
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	KBVBLCK_KAGE_90
		JSR	KAGE_YKSTRT
		JSR	KAGE_END
;
KBVBLCK_KAGE_90 EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;
;****************************************************************
;*								*
;*	カベ コース カベ					*
;*								*
;****************************************************************
KBKABE_ADR	EQU	$
		WORD	KBKABE_LFT,KBKABE_RIT
;
;
KBKABE		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	#UT00D5
		STA	>BGUNIT,X
;
		LDX	#0000H
		LDA	<XSIZE
		BEQ	KBKABE_100
		INC	A
		CMP	<XSIZECP
		BNE	KBKABE_200
		INX
		INX
KBKABE_100	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(KBKABE_ADR,X)
;
		LDA	<XSIZE
		BNE	KBKABE_200
		JSR	KBKABE_LF_KG
;
KBKABE_200	EQU	$
		LDA	<YSIZE
		BNE	KBKABE_900
		JSR	KBKABE_UP
KBKABE_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側チェック＆セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBKABE_LFT	EQU	$
		JSL	>LFTCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0167
		BEQ	KBKABE_SD_SET
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	KBKABE_SD_PAS
		LDA	<XYPOINT
		STA	<WORKE
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側チェック＆セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBKABE_RIT	EQU	$
		JSL	>RITCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0168
		BNE	KBKABE_SD_PAS
KBKABE_SD_SET	EQU	$
		SEC
		SBC	#UT0167
		EOR	#00001
		CLC
		ADC	#UT015D
		STA	>BGUNIT,X
KBKABE_SD_PAS	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側チェック＆影セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TATE_KAGE_DAT	EQU	$
		WORD	UT00D7,UT00D8,UT00DA
;
;
KBKABE_LF_KG	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT015D
		BEQ	KBKB_LF_KG_100
		CMP	#UT015E
		BEQ	KBKB_LF_KG_100
		CMP	#UT0160
		BCC	KBKB_LF_KG_050
		CMP	#UT016D+1
		BCC	KBKB_LF_KG_100
KBKB_LF_KG_050	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT00D8
		BNE	KBKB_LF_KG_500
		LDY	#00002H*2
		BRA	KBKB_LF_KG_230
;
KBKB_LF_KG_100	EQU	$
		LDY	#00000H
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT015D
		BEQ	KBKB_LF_KG_150
		CMP	#UT015E
		BEQ	KBKB_LF_KG_150
		CMP	#UT0160
		BCC	KBKB_LF_KG_130
		CMP	#UT016D+1
		BCC	KBKB_LF_KG_150
KBKB_LF_KG_130	EQU	$
		CMP	#UT00D5
		BEQ	KBKB_LF_KG_230
		CMP	#UT77EE
		BEQ	KBKB_LF_KG_230
		CMP	#UT77EF
		BEQ	KBKB_LF_KG_230
		BRA	KBKB_LF_KG_200
KBKB_LF_KG_150	EQU	$
		LDA	#UT00E8
		BRA	KBKB_LF_KG_250
KBKB_LF_KG_200	EQU	$
		INY
		INY
KBKB_LF_KG_230	EQU	$
		LDA	TATE_KAGE_DAT,Y
KBKB_LF_KG_250	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
KBKB_LF_KG_500	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上側チェック＆セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBKABE_UP_DAT	EQU	$
		WORD	UT00D6,UT00D9,UT00D9,UT00DA
;
;
KBKABE_UP	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT015D
		BEQ	KBKABE_UP_100
		CMP	#UT015E
		BEQ	KBKABE_UP_100
		CMP	#UT0160
		BCC	KBKABE_UP_050
		CMP	#UT016D+1
		BCC	KBKABE_UP_100
KBKABE_UP_050	EQU	$
		LDA	<XYCPBF
		BEQ	KBKABE_UP_500
		TAY
		STZ	<XYCPBF
		BRA	KBKABE_UP_300
KBKABE_UP_100	EQU	$
		LDY	#00001H*2
		LDA	<XYCPBF
		BNE	KBKABE_UP_300
		LDA	#00003H*2
		STA	<XYCPBF
		LDY	#00000H
KBKABE_UP_300	EQU	$
		LDX	<UNITPOS
		TYA
		BNE	KBKABE_UP_350
		LDA	>BGUNIT,X	; 今までに何が
		CMP	#UT00E8		;	セットさてているか ?
		BEQ	KBKABE_UP_500
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT00D9
		BNE	KBKABE_UP_350
		LDY	#00001H*2
KBKABE_UP_350	EQU	$
		LDX	<UNITPOS
		LDA	KBKABE_UP_DAT,Y
		STA	>BGUNIT,X
KBKABE_UP_500	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	カベ コース カベ右下がり斜面 45ﾟ			*
;*								*
;****************************************************************
KABEUPDWN	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#00001H
		STA	<LKFLG
		LDX	<UNITPOS
		LDA	<STUNTNO
		AND	#00002H
		ASL	A
		STA	<WORK0
		LDA	<YSIZE
		AND	#00001H
		ASL	A
		ORA	<WORK0
		TAY
		BNE	KABEUPDWN_100
		LDA	<NOWUNIT
		CMP	#UT00E9
		BEQ	KABEUPDWN_200
		CMP	#UT00EA
		BEQ	KABEUPDWN_200
		CMP	#UT77E0
		BEQ	KABEUPDWN_200
		CMP	#UT77E1
		BEQ	KABEUPDWN_200
KABEUPDWN_100	EQU	$
		LDA	KABEUPDWN_DT,Y
		STA	>BGUNIT,X
;
KABEUPDWN_200	EQU	$
		LDA	<YSIZE
		BEQ	KABEUPDWN_400
		DEC	A
		BNE	KABEUPDWN_500
		JSR	KABEUPDWN_LFCHK
		BRA	KABEUPDWN_450
KABEUPDWN_400	EQU	$
		JSR	KABEUPDWN_UPCHK
KABEUPDWN_450	EQU	$
		TAX
		BEQ	KABEUPDWN_500
		LDX	<UNITPOS
		STA	>BGUNIT,X
		BRA	KABEUPDWN_900
;
KABEUPDWN_500	EQU	$
		JSR	KBKABE_LF_KG
		BRA	KABEUPDWN_900
;
KABEUPDWN_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABEUPDWN_DT	EQU	$
		WORD	UT00D4,UT00D3
		WORD	UT00D1,UT00D2
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+		影上チェック ＆ セット			+
;+				out			+
;+				A ＝ 0 : セットしない	+
;+				A ≠ 0 : セットする	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABEUPDWN_UP_DT EQU	$
		WORD	UT77E9,UT77EE	;左上坂
		WORD	UT77E6,UT77EF	;右上坂
;
;
KABEUPDWN_UPCHK EQU	$
		LDY	#00000
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0167
		BEQ	KABEUPDWN_UP_ST
		CMP	#UT0168
		BEQ	KABEUPDWN_UP_ST
		CMP	#UT015D
		BEQ	KABEUPDWN_UP_ST
		CMP	#UT015E
		BEQ	KABEUPDWN_UP_ST
;
		INY
		INY
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT0167
		BEQ	KABEUPDWN_UP_ST
		CMP	#UT0168
		BEQ	KABEUPDWN_UP_ST
		CMP	#UT015D
		BEQ	KABEUPDWN_UP_ST
		CMP	#UT015E
		BEQ	KABEUPDWN_UP_ST
		LDA	#00000H
		BRA	KABEUPDWN_UP_PS
KABEUPDWN_UP_ST EQU	$
		LDA	<STUNTNO
		AND	#00002
		BEQ	KABEUPDWN_UP_00
		INY
		INY
		INY
		INY
KABEUPDWN_UP_00 EQU	$
		LDA	KABEUPDWN_UP_DT,Y
KABEUPDWN_UP_PS EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+		影左チェック ＆ セット			+
;+				out			+
;+				A ＝ 0 : セットしない	+
;+				A ≠ 0 : セットする	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABEUPDWN_LF_DT EQU	$
		WORD	UT77F0	;左上坂
		WORD	UT77F1	;右上坂
;
;
KABEUPDWN_LFCHK EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT0167
		BEQ	KABEUPDWN_LF_ST
		CMP	#UT0168
		BEQ	KABEUPDWN_LF_ST
		CMP	#UT015D
		BEQ	KABEUPDWN_LF_ST
		CMP	#UT015E
		BEQ	KABEUPDWN_LF_ST
;
		LDA	#0000H
		BRA	KABEUPDWN_LF_PS
KABEUPDWN_LF_ST EQU	$
		LDA	<STUNTNO
		AND	#00002
		TAY
		LDA	KABEUPDWN_LF_DT,Y
KABEUPDWN_LF_PS EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	カベ コース 溶岩					*
;*								*
;****************************************************************
KBYGN_DAT	EQU	$
		WORD	UT0093,UT0094,UT0094,UT0095
		WORD	UT0093,UT0095,UT0096,UT0097
;
KBYGN_SIDE	EQU	$
		WORD	KBYGN_LF,KBYGN_RT
;
;
KABEYOGAN	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE		; 波の部分セット ?
		BNE	KABEYOGAN_300	;	NO -> KABEYOGAN_300
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	#00005
		STA	<WORK0
		LDY	#00000H
		LDA	>BGUNIT,X	; ゆらゆらセット ?
		CMP	#UT00D5		;	YES -> KABEYOGAN_130
		BEQ	KABEYOGAN_130	;	NO --> KABEYOGAN_200
		INY
		CMP	#UT00D8
		BEQ	KABEYOGAN_130
		INY
		CMP	#UT00D7
		BNE	KABEYOGAN_200
KABEYOGAN_130	EQU	$
		TYA
		CLC
		ADC	#UT0037
		STA	>BGUNIT,X
		STZ	<WORK0
		TYA			; 影付きゆらゆら ?
		BEQ	KABEYOGAN_200	;	NO -> KABEYOGAN_200
		LDA	#UT003A
		BRA	KABEYOGAN_500
;
KABEYOGAN_200	EQU	$
		JSL	>RND_RND
		AND	#00007*2
		TAY
		LDA	KBYGN_DAT,Y
		CLC
		ADC	<WORK0
		BRA	KABEYOGAN_500
;
KABEYOGAN_300	EQU	$
		LDA	<XSIZE
		AND	#00001
		CLC
		ADC	#UT7E00
;
KABEYOGAN_500	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		LDX	#00000
		LDA	<XSIZE
		BEQ	KABEYOGAN_510
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	KABEYOGAN_600
KABEYOGAN_510	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		LDY	#00000H
		JSR	(KBYGN_SIDE,X)
;
KABEYOGAN_600	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	KABEYOGAN_700
		JSR	KBYGN_DW
;
KABEYOGAN_700	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側ブロック セット＆チェック		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBYGN_LF_DT	EQU	$
		WORD	UT01BB,UT01B9,UT01BB,UT01BB
;
KBYGN_BLK_CMP	EQU	$
		WORD	UT0167,UT0168,UT015D,UT015E
;
;
KBYGN_LF	EQU	$
		JSL	>LFTCHK_SB
		LDA	>BGUNIT,X
KBYGN_LF_000	EQU	$
		CMP	KBYGN_BLK_CMP,Y
		BEQ	KBYGN_LF_100
		INY
		INY
		CPY	#00004H*2
		BCC	KBYGN_LF_000
		BRA	KBYGN_DW_990
;
KBYGN_LF_100	EQU	$
		LDA	KBYGN_LF_DT,Y
		BRA	KBYGN_DW_900
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側ブロック セット＆チェック		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBYGN_RT_DT	EQU	$
		WORD	UT01BA,UT01BC,UT01BC,UT01BC
;
;
KBYGN_RT	EQU	$
		JSL	>RITCHK_SB
		LDA	>BGUNIT,X
KBYGN_RT_000	EQU	$
		CMP	KBYGN_BLK_CMP,Y
		BEQ	KBYGN_RT_100
		INY
		INY
		CPY	#00004H*2
		BCC	KBYGN_RT_000
		BRA	KBYGN_DW_990
;
KBYGN_RT_100	EQU	$
		LDA	KBYGN_RT_DT,Y
		BRA	KBYGN_DW_900
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下側ブロック セット＆チェック		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBYGN_DW_DT	EQU	$
		WORD	UT01BD,UT01BE,UT01BD,UT01BE
;
;
KBYGN_DW	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDY	#00000H
		LDA	>BGUNIT,X
KBYGN_DW_000	EQU	$
		CMP	KBYGN_BLK_CMP,Y
		BEQ	KBYGN_DW_100
		INY
		INY
		CPY	#00004H*2
		BCC	KBYGN_DW_000
		BRA	KBYGN_DW_990
;
KBYGN_DW_100	EQU	$
		LDA	KBYGN_DW_DT,Y
;
KBYGN_DW_900	EQU	$
		STA	>BGUNIT,X
KBYGN_DW_990	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	カベ コース 床 左側					*
;*								*
;****************************************************************
KABEYUKA_LDT	EQU	$
		WORD	UT0167,UT0168,UT015D
;
KBYK_L_ADR	EQU	$
		WORD	KBYK_L_000,KBYK_L_200
;
;
KABEYUKA_L	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00004
		LDA	<XSIZECP
		DEC	A
		BEQ	KABEYUKA_L400
;
KABEYUKA_L000	EQU	$
		JSR	KABEYPOS	; Ｙ座標 セット
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(KBYK_L_ADR,X)	; 右側 チェック or 左側 チェック
;
KABEYUKA_L400	EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	KABEYUKA_L450
		CPY	#(KBYK_L_ADR-KABEYUKA_LDT)-2
		BNE	KABEYUKA_L450
		LDA	#UT015E
		BRA	KABEYUKA_L490
KABEYUKA_L450	EQU	$
		LDA	KABEYUKA_LDT,Y
KABEYUKA_L490	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		LDA	<XSIZE
		BEQ	KABEYUKA_L493
		INC	A
		CMP	<XSIZECP
		BNE	KABEYUKA_L498
		DEY
		DEY
		JSR	KABEYUKA_R500
		BRA	KABEYUKA_L498
;
KABEYUKA_L493	EQU	$
		JSR	KABEYUKA_L500
KABEYUKA_L498	EQU	$
		JSR	KABEYUKA_UP
;
		JMP	KABEYUKA_R900
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側 チェック				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBYK_L_000	EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	KBYK_L_250
		JSL	>RITCHK_SB
		LDA	>BGUNIT,X
		CMP	KABEYUKA_LDT+2
		BEQ	KBYK_L_250
		CMP	KABEYUKA_LDT+4	; 正方形ブロック ?
		BNE	KBYK_L_220	;	NO -> KBYK_L_220
		LDA	KABEYUKA_LDT+2
		STA	>BGUNIT,X
		BRA	KBYK_L_250
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側 チェック				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBYK_L_200	EQU	$
		LDA	<XSIZE
		BNE	KBYK_L_250
		JSL	>LFTCHK_SB
		LDA	>BGUNIT,X
		CMP	KABEYUKA_RDT+4	; 正方形ブロック ?
		BNE	KBYK_L_220	;	NO -> KBYK_L_220
		LDA	KABEYUKA_LDT
		STA	>BGUNIT,X
		BRA	KBYK_L_250
;
KBYK_L_220	EQU	$
		LDY	#00004
KBYK_L_250	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側 溶岩チェック			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABEYUKA_L5DT	EQU	$
		WORD	UT01BA,UT01BC,UT01BC
;
;
KABEYUKA_L500	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT0037
		BCC	KABEYUKA_L590
		CMP	#UT003B+1
		BCC	KABEYUKA_L550
		CMP	#UT0093
		BCC	KABEYUKA_L590
		CMP	#UT009C+1
		BCC	KABEYUKA_L550
		CMP	#UT7E00
		BEQ	KABEYUKA_L550
		CMP	#UT7E01
		BNE	KABEYUKA_L590
;
KABEYUKA_L550	EQU	$
		LDX	<UNITPOS
		LDA	KABEYUKA_L5DT,Y
		STA	>BGUNIT,X
KABEYUKA_L590	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	カベ コース 床 右側					*
;*								*
;****************************************************************
KABEYUKA_RDT	EQU	$
		WORD	UT0168,UT0167,UT015E
;
;
KABEYUKA_R	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00004
		LDA	<XSIZECP
		DEC	A
		BEQ	KABEYUKA_R400
;
KABEYUKA_R000	EQU	$
		JSR	KABEYPOS	; Ｙ座標 セット
		TXA
		BEQ	KABEYUKA_R400
		JSR	KBYK_R_200	; 右側 チェック
;
KABEYUKA_R400	EQU	$
		LDX	<UNITPOS
		LDA	KABEYUKA_RDT,Y
		STA	>BGUNIT,X
;
		JSR	KABEYUKA_R500
		JSR	KABEYUKA_UP
;
KABEYUKA_R900	EQU	$		; 影チェック ＆ セット
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	KBYUKA_KG_20
		LDA	<XSIZE
		BNE	KBYUKA_KG_10
		JSR	KAGE_YKSTRT
		BRA	KBYUKA_KG_20
KBYUKA_KG_10	EQU	$
		JSR	KAGE_YOKO
;
KBYUKA_KG_20	EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	KBYUKA_KG_90
		LDA	<YSIZE
		BNE	KBYUKA_KG_30
		JSR	KAGE_TTSTRT
		BRA	KBYUKA_KG_35
KBYUKA_KG_30	EQU	$
		JSR	KAGE_TATE
KBYUKA_KG_35	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	KBYUKA_KG_90
		JSR	KAGE_END
;
KBYUKA_KG_90	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側 チェック				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBYK_R_200	EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	KBYK_R_250
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	KABEYUKA_RDT
		BEQ	KBYK_R_250
		CMP	KABEYUKA_RDT+4	; 正方形ブロック ?
		BNE	KBYK_R_220	;	NO -> KBYK_R_220
		LDA	KABEYUKA_RDT
		STA	>BGUNIT,X
		BRA	KBYK_R_250
;
KBYK_R_220	EQU	$
		LDY	#00004
KBYK_R_250	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	Ｙ座標 セット					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABEYPOS	EQU	$
		LDA	<XYPOINT
		CLC
		ADC	<XSIZE
		AND	#00001H
		STA	<WORK0
		LDA	<XYPOINT
		AND	#00010H
		LSR	A
		LSR	A
		LSR	A
		LSR	A
;;;;K;;;;		CLC
		ADC	<YSIZE
		AND	#00001H
		EOR	<WORK0
		ASL	A
		TAX
		TXY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側 溶岩チェック			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABEYUKA_R5DT	EQU	$
		WORD	UT01B9,UT01BB,UT01BB
;
;
KABEYUKA_R500	EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	KABEYUKA_R590
;
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	#UT0037
		BCC	KABEYUKA_R590
		CMP	#UT003B+1
		BCC	KABEYUKA_R550
		CMP	#UT0093
		BCC	KABEYUKA_R590
		CMP	#UT009C+1
		BCC	KABEYUKA_R550
		CMP	#UT7E00
		BEQ	KABEYUKA_R550
		CMP	#UT7E01
		BNE	KABEYUKA_R590
;
KABEYUKA_R550	EQU	$
		LDX	<UNITPOS
		LDA	KABEYUKA_R5DT,Y
		STA	>BGUNIT,X
KABEYUKA_R590	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上側 溶岩チェック			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABEYUKA_UP	EQU	$
		LDA	<YSIZE
		BNE	KABEYUKA_UP_90
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDY	#00000H
		LDA	>BGUNIT,X
		CMP	#UT7E00
		BEQ	KABEYUKA_UP_50
		CMP	#UT7E01
		BNE	KABEYUKA_UP_90
KABEYUKA_UP_50	EQU	$
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		SEC
		SBC	#UT0167
		CLC
		ADC	#UT01BD
		STA	>BGUNIT,X
;
KABEYUKA_UP_90	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	カベ コース 窓						*
;*								*
;****************************************************************
KABEWINDOW	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDY	#00000H
		LDA	<YSIZE
		BEQ	KABEWINDOW_100
		INY
		INY
KABEWINDOW_100	EQU	$
		LDA	<XSIZE
		ASL	A
		ASL	A
		STA	<WORK0
		TYA
		ORA	<WORK0
		TAY
		LDA	<STUNTNO
		AND	#00002H
		ASL	A
		ASL	A
		STA	<WORK0
		TYA
		ORA	<WORK0
		TAY
		LDA	KABEWINDOW_DT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
KABEWINDOW_DT	EQU	$
		WORD	UT00DB,UT00E1
		WORD	UT00E0,UT00E2
		WORD	UT00E6,UT00E6
		WORD	UT00E7,UT00E7
;
;
;****************************************************************
;*								*
;*	カベ コース ブロック スライム				*
;*								*
;****************************************************************
BLOKSLM		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<XSIZE
		ASL	A
		STA	<WORKE
		LDA	<STUNTNO
		AND	#00007H
		DEC	A
		DEC	A
		DEC	A
		ASL	A
		TAY
		LDA	<WORKE
		CLC
		ADC	BLOKSLM_DT,Y
		TAY
		LDA	<YSIZE
		BEQ	BLOKSLM_100
		INC	A
		CMP	<YSIZECP
		BNE	BLOKSLM_200
		BRA	BLOKSLM_300
;
BLOKSLM_100	EQU	$		; up data set
		LDA	BLOKSLM4_DT0,Y
		BRA	BLOKSLM_900
;
BLOKSLM_200	EQU	$		; center data set
		LDA	BLOKSLM4_DT1,Y
		BRA	BLOKSLM_900
;
BLOKSLM_300	EQU	$		; down data set
		LDA	BLOKSLM4_DT2,Y
;
BLOKSLM_900	EQU	$
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
BLOKSLM_DT	EQU	$
		WORD	BLOKSLM4_DT0-BLOKSLM4_DT0
		WORD	BLOKSLM6_DT0-BLOKSLM4_DT0
		WORD	BLOKSLM8_DT0-BLOKSLM4_DT0
;
;------------------------- up data
BLOKSLM4_DT0	EQU	$
		WORD	UT0181,UT0182,UT0182,UT0185
;
BLOKSLM6_DT0	EQU	$
		WORD	UT0181,UT0182,UT0182,UT0182
		WORD	UT0183,UT0185
;
BLOKSLM8_DT0	EQU	$
		WORD	UT0181,UT0182,UT0182,UT0182
		WORD	UT0182,UT0182,UT0184,UT0185
;
;------------------------- center data
BLOKSLM4_DT1	EQU	$
		WORD	UT0186,UT0187,UT0187,UT018A
;
BLOKSLM6_DT1	EQU	$
		WORD	UT0186,UT0187,UT0187,UT0187
		WORD	UT0188,UT018A
;
BLOKSLM8_DT1	EQU	$
		WORD	UT0186,UT0187,UT0187,UT0187
		WORD	UT0187,UT0187,UT0189,UT018A
;
;------------------------- down data
BLOKSLM4_DT2	EQU	$
		WORD	UT018B,UT018C,UT018C,UT018F
;
BLOKSLM6_DT2	EQU	$
		WORD	UT018B,UT018C,UT018C,UT018C
		WORD	UT018D,UT018F
;
BLOKSLM8_DT2	EQU	$
		WORD	UT018B,UT018C,UT018C,UT018C
		WORD	UT018C,UT018C,UT018E,UT018F
;
;
;****************************************************************
;*								*
;*	草 コース 食べれるＢＧ					*
;*								*
;****************************************************************
KUSAETABG	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<NOWUNIT	; character check !!
		AND	#0FF00H
		CMP	RUT1B00
		BEQ	KSETA010
;
		LDA	<NOWUNIT	; character check !!
		CMP	#UT0000		;
		BEQ	KSETA010	;
		CMP	#UT00D5		;
		BEQ	KSETA010	;
		INY			;
		INY			;
KSETA000	EQU	$		;
		LDX	ETACMP,Y	;
		CMP	0,X		;
		BEQ	KSETA010	;
		INY			;
		INY			;
		CPY	#ONESTDT-ETACMP ;
		BCC	KSETA000	;
;
		BRA	KSETA999_99
;
KSETA010	EQU	$
		LDA	<XSIZECP
		DEC	A
		BNE	KSETA050
		LDA	<YSIZECP
		DEC	A
		BEQ	KSETA200	; goto 1 point set
		BRA	KSETA400	; goto v-line set
KSETA050	EQU	$
		LDA	<YSIZECP
		DEC	A
		BEQ	KSETA600	; goto h-line set
;
KSETA800	EQU	$
		JSR	BOXSET		; box type set
		BRA	KSETA999
;
KSETA200	EQU	$
		LDA	ONESTDT,Y	; 1 point set
		TAY
		BRA	KSETA999
;
KSETA400	EQU	$
		JSR	VLINEST		; v-line set
		BRA	KSETA999
;
KSETA600	EQU	$
		JSR	HLINEST		; h-line set
;
KSETA999	EQU	$
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
KSETA999_99	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	v-line set				+
;++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
VLINEST		EQU	$
		LDA	<YSIZE
		BEQ	VLINE00
		INC	A
		CMP	<YSIZECP
		BEQ	VLINE20
;					; center
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	VLINE005
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(VCENTER,X)	; goto box type up line
VLINE005	EQU	$
		LDA	VLINDT1,Y
		BRA	VLINE99
;
VLINE00		EQU	$		; up
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	VLINE05
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(VUP,X)		; goto box type up line
VLINE05		EQU	$
		LDA	VLINDT0,Y
		BRA	VLINE99
;
VLINE20		EQU	$		; down
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	VLINE25
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(VDOWN,X)	; goto box type left down
VLINE25		EQU	$
		LDA	VLINDT2,Y
VLINE99		EQU	$
		TAY
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	h-line set				+
;++++++++++++++++++++++++++++++++++++++++++++++++
HLINEST		EQU	$
		LDA	<XSIZE
		BEQ	HLINE00
		INC	A
		CMP	<XSIZECP
		BEQ	HLINE20
;
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	HLINE005
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(HCENTER,X)	; goto box type up line
HLINE005	EQU	$
		LDA	HLINDT1,Y	; center
		BRA	HLINE99
;
HLINE00		EQU	$
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	HLINE05
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(HRIGHT,X)	; goto box type up line
HLINE05		EQU	$
		LDA	HLINDT0,Y	; left side
		BRA	HLINE99
;
HLINE20		EQU	$
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	HLINE25
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(HLEFT,X)	; goto box type up line
HLINE25		EQU	$
		LDA	HLINDT2,Y	; right side
HLINE99		EQU	$
		TAY
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	box type set				+
;++++++++++++++++++++++++++++++++++++++++++++++++
BOXSET		EQU	$
		LDA	<XSIZE
		BNE	BOX000
		LDA	<YSIZE
		BEQ	BOX100
		INC	A
		CMP	<YSIZECP
		BNE	BOX200
		BRA	BOX300
BOX000		EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BEQ	BOX010
		LDA	<YSIZE
		BEQ	BOX400
		INC	A
		CMP	<YSIZECP
		BNE	BOX500
		JMP	BOX600
BOX010		EQU	$
		LDA	<YSIZE
		BNE	BOX020
		JMP	BOX700
BOX020		EQU	$
		INC	A
		CMP	<YSIZECP
		BEQ	BOX030
		JMP	BOX800
BOX030		EQU	$
		JMP	BOX900
;
BOX100		EQU	$		; left up
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX105
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(BOXLTUP,X)
BOX105		EQU	$
		LDA	BOXDAT0,Y
		JMP	BOX999
;
BOX200		EQU	$		; left side
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX205
		JSR	CRSCHNG		; cross change check
		JMP	BOX505
BOX205		EQU	$
		LDA	BOXDAT1,Y
		JMP	BOX999
;
BOX300		EQU	$		; left down
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX305
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(BOXLTDN,X)
BOX305		EQU	$
		LDA	BOXDAT2,Y
		JMP	BOX999
;
BOX400		EQU	$		; center up
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX405
		JSR	CRSCHNG		; cross change check
		JMP	BOX505
BOX405		EQU	$
		LDA	BOXDAT3,Y
		JMP	BOX999
;
BOX500		EQU	$		; center
		M16			; memory 16bit mode
		TYA
		BNE	BOX505
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT1B00
		BNE	BOX505
		LDA	<NOWUNIT
		AND	#000FFH
		CMP	#00010H
		BCC	BOX505
		INY
		INY
BOX505		EQU	$
		LDA	BOXDAT4,Y
		JMP	BOX999
;
BOX600		EQU	$		; center down
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX605
		JSR	CRSCHNG		; cross change check
		JMP	BOX505
BOX605		EQU	$
		LDA	BOXDAT5,Y
		JMP	BOX999
;
BOX700		EQU	$		; right up
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX705
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(BOXRTUP,X)
BOX705		EQU	$
		LDA	BOXDAT6,Y
		JMP	BOX999
;
BOX800		EQU	$		; right side
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX805
		JSR	CRSCHNG		; cross change check
		JMP	BOX505
BOX805		EQU	$
		LDA	BOXDAT7,Y
		JMP	BOX999
;
BOX900		EQU	$		; right down
		M16			; memory 16bit mode
		JSR	CROSCHK		; character cross check
		BIT	#00001H
		BEQ	BOX905
		JSR	CRSCHNG		; cross change check
		LDA	<WORK0
		ASL	A
		TAX
		JMP	(BOXRTDN,X)
BOX905		EQU	$
		LDA	BOXDAT8,Y
;
BOX999		EQU	$
		TAY
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++
;+	character cross check		+
;+			out		+
;+			ON  -> 1	+
;+			OFF -> 0	+
;++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
CROSCHK		EQU	$
		STZ	<WORK0
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT1B00
		BNE	CROSPSS
		INC	<WORK0
CROSPSS		EQU	$
		LDA	<WORK0
		RTS
;
;++++++++++++++++++++++++++++++++++++++++
;+	cross change check		+
;++++++++++++++++++++++++++++++++++++++++
CRSCHNG		EQU	$
		LDA	<NOWUNIT
		LDY	#00000H
CRSLOP		EQU	$
		LDX	ONESTDT,Y
		CMP	0,X
		BEQ	CRSPAS
		INY
		INY
		CPY	#BOXDAT9-ONESTDT
		BCC	CRSLOP
;
CRSPAS		EQU	$
		LDX	<UNITPOS
		STZ	<WORK0
CRSPSS		EQU	$		; goto index set !!
		TYA
		CMP	#VLINDT0-ONESTDT
		BCC	CRSEND
		SEC
		SBC	#VLINDT0-ONESTDT
		TAY
		INC	<WORK0
		BRA	CRSPSS
CRSEND		EQU	$
		RTS
;
		MEM8
		IDX8
;
;
ETACMP		EQU	$
		WORD	UT0000, RUT1D13,RUT1D0D,RUT1D09,RUT1D0E,RUT1D00
		WORD	RUT1D0B,RUT1D02,RUT1D0C,RUT1D03,RUT1D0F,RUT1D06
		WORD	RUT1D10,RUT1D05,RUT1D11,RUT1D04,RUT1D12,RUT1D21
		WORD	RUT1D01,RUT1D20,RUT1D08,RUT1D07
		WORD	RUT2A00,RUT2A01,RUT1D2B,RUT1D2C
		WORD	RUT1D2D,RUT1D2E,RUT1D2F
		WORD	RUT1D30,RUT1D31
;
ONESTDT		EQU	$
		WORD	RUT1B0F,RUT1B1F,RUT1B25,RUT1BB5,RUT1B35,RUT1B2C
		WORD	RUT1B47,RUT1BC7,RUT1B57,RUT1B3E,RUT1B63,RUT1BBD
		WORD	RUT1B68,RUT1BCD,RUT1B6D,RUT1BDD,RUT1B73,RUT1B79
		WORD	RUT1BD3,RUT1B81,RUT1B95,RUT1B4E
		WORD	RUT1BAB,RUT1BAB,RUT1BA3,RUT1B5C
		WORD	RUT1BE5,RUT1BF1,RUT1BF4
		WORD	RUT1BF7,RUT1BFA
;
VLINDT0		EQU	$		; up side
		WORD	RUT1B0C,RUT1B1C,RUT1B21,RUT1BB1,RUT1B31,RUT1B2B
		WORD	RUT1B46,RUT1BC6,RUT1B0C,RUT1B0C,RUT1B61,RUT1BBB
		WORD	RUT1B66,RUT1BCB,RUT1B0C,RUT1B0C,RUT1B0C,RUT1B0C
		WORD	RUT1B0C,RUT1B87,RUT1B91,RUT1B0C
		WORD	RUT1BAC,RUT1BAC,RUT1BA1,RUT1B5B
		WORD	RUT1BE1,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
VLINDT1		EQU	$		; center
		WORD	RUT1B0D,RUT1B1D,RUT1B24,RUT1BB4,RUT1B34,RUT1B2D
		WORD	RUT1B0D,RUT1B0D,RUT1B0D,RUT1B0D,RUT1B0D,RUT1B0D
		WORD	RUT1B0D,RUT1B0D,RUT1B0D,RUT1B0D,RUT1B0D,RUT1B0D
		WORD	RUT1B0D,RUT1BFE,RUT1B94,RUT1B0D
		WORD	RUT1BAB,RUT1BAB,RUT1BA1,RUT1B5B
		WORD	RUT1BE4,RUT1BF1,RUT1BF4
		WORD	RUT1BF6,RUT1BF9
;
VLINDT2		EQU	$		; down side
		WORD	RUT1B0E,RUT1B1E,RUT1B27,RUT1BB7,RUT1B37,RUT1B2E
		WORD	RUT1B0E,RUT1B0E,RUT1B56,RUT1B0E,RUT1B0E,RUT1B0E
		WORD	RUT1B0E,RUT1B0E,RUT1B6B,RUT1BDB,RUT1B71,RUT1B7D
		WORD	RUT1BD7,RUT1B86,RUT1B97,RUT1B4C
		WORD	RUT1BAB,RUT1BAB,RUT1BA1,RUT1B5B
		WORD	RUT1BF7,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
HLINDT0		EQU	$		; left side
		WORD	RUT1B09,RUT1B19,RUT1B22,RUT1BB2,RUT1B09,RUT1B09
		WORD	RUT1B43,RUT1BC3,RUT1B53,RUT1B3B,RUT1B62,RUT1BBC
		WORD	RUT1B09,RUT1B09,RUT1B6C,RUT1BDC,RUT1B09,RUT1B77
		WORD	RUT1BD1,RUT1B09,RUT1B09,RUT1B09
		WORD	RUT1BAD,RUT1BAD,RUT1BA2,RUT1B5C
		WORD	RUT1BE2,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
HLINDT1		EQU	$		; center
		WORD	RUT1B0A,RUT1B1A,RUT1B0A,RUT1B0A,RUT1B0A,RUT1B0A
		WORD	RUT1B44,RUT1BC4,RUT1B54,RUT1B3C,RUT1B0A,RUT1B0A
		WORD	RUT1B0A,RUT1B0A,RUT1B0A,RUT1B0A,RUT1B0A,RUT1B7C
		WORD	RUT1BD6,RUT1B0A,RUT1B0A,RUT1B0A
		WORD	RUT1BAE,RUT1BAE,RUT1BA2,RUT1B5C
		WORD	RUT1BE2,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
HLINDT2		EQU	$		; right side
		WORD	RUT1B0B,RUT1B1B,RUT1B0B,RUT1B0B,RUT1B32,RUT1B0B
		WORD	RUT1B0B,RUT1B0B,RUT1B0B,RUT1B3D,RUT1B0B,RUT1B0B
		WORD	RUT1B67,RUT1BCC,RUT1B0B,RUT1B0B,RUT1B72,RUT1B78
		WORD	RUT1BD2,RUT1B0B,RUT1B92,RUT1B4D
		WORD	RUT1BAF,RUT1BAF,RUT1BA2,RUT1B5C
		WORD	RUT1BE2,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT0		EQU	$		; left up
		WORD	RUT1B00,RUT1B10,RUT1B20,RUT1BB0,RUT1B00,RUT1B00
		WORD	RUT1B40,RUT1BC0,RUT1B00,RUT1B00,RUT1B60,RUT1BBA
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B82,RUT1B00,RUT1B00
		WORD	RUT1BAB,RUT1BAB,RUT1BA0,RUT1B5B
		WORD	RUT1BE0,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT1		EQU	$		; left side
		WORD	RUT1B03,RUT1B13,RUT1B23,RUT1BB3,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B84,RUT1B00,RUT1B00
		WORD	RUT1BAB,RUT1BAB,RUT1BA0,RUT1B5B
		WORD	RUT1BE0,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT2		EQU	$		; left down
		WORD	RUT1B06,RUT1B16,RUT1B26,RUT1BB7,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B50,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B6A,RUT1BDA,RUT1B00,RUT1B7A
		WORD	RUT1BD4,RUT1B88,RUT1B00,RUT1B00
		WORD	RUT1B9B,RUT1B9B,RUT1BA0,RUT1B5B
		WORD	RUT1BE0,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT3		EQU	$		; center up
		WORD	RUT1B01,RUT1B11,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B41,RUT1BC1,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B8B,RUT1B00,RUT1B00
		WORD	RUT1BAC,RUT1BAC,RUT1BA0,RUT1B5B
		WORD	RUT1BE0,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT4		EQU	$		; center
		WORD	RUT1B04,RUT1B14,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B80,RUT1B00,RUT1B00
		WORD	RUT1BAC,RUT1BAC,RUT1BA0,RUT1B5B
		WORD	RUT1BE0,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT5		EQU	$		; center down
		WORD	RUT1B07,RUT1B17,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B51,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B76
		WORD	RUT1BD0,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B9C,RUT1B9C,RUT1BA0,RUT1B5B
		WORD	RUT1BE0,RUT1BF0,RUT1BF3
		WORD	RUT1BF3,RUT1BF6
;
BOXDAT6		EQU	$		; right up
		WORD	RUT1B02,RUT1B12,RUT1B00,RUT1B00,RUT1B30,RUT1B00
		WORD	RUT1B42,RUT1BC2,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B65,RUT1BCA,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B83,RUT1B90,RUT1B00
		WORD	RUT1BAF,RUT1BAF,RUT1BA0,RUT1B5B
		WORD	RUT1BE0,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT7		EQU	$		; right side
		WORD	RUT1B05,RUT1B15,RUT1B00,RUT1B00,RUT1B33,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B7B
		WORD	RUT1BD5,RUT1B85,RUT1B93,RUT1B00
		WORD	RUT1B9D,RUT1B9D,RUT1BA0,RUT1B5B
		WORD	RUT1BE3,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT8		EQU	$		; right down
		WORD	RUT1B08,RUT1B18,RUT1B00,RUT1B00,RUT1B36,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B52,RUT1B00,RUT1B00,RUT1B00
		WORD	RUT1B00,RUT1B00,RUT1B00,RUT1B00,RUT1B70,RUT1B7B
		WORD	RUT1BD5,RUT1B89,RUT1B96,RUT1B4B
		WORD	RUT1B9D,RUT1B9D,RUT1BA0,RUT1B5B
		WORD	RUT1BE6,RUT1BF0,RUT1BF3
		WORD	RUT1BF6,RUT1BF9
;
BOXDAT9		EQU	$
;
VUP		EQU	$-8
		WORD	BOX105,BOX405,BOX705,BOX105
		WORD	BOX505,BOX205,BOX505,BOX505
		WORD	BOX505,BOX505,BOX505,BOX805
;
VCENTER		EQU	$-8
		WORD	BOX205,BOX505,BOX805,BOX205
		WORD	BOX205,BOX205
;
VDOWN		EQU	$-8
		WORD	BOX305,BOX605,BOX905,BOX205
		WORD	BOX505,BOX305,BOX505,BOX505
		WORD	BOX605,BOX805,BOX805,BOX905
;
HRIGHT		EQU	$-2
		WORD	       BOX105,BOX205,BOX305
		WORD	BOX505,BOX505,BOX505,BOX505
		WORD	BOX505,BOX505,BOX505,BOX505
		WORD	BOX505,BOX405,BOX505,BOX605
;
HCENTER		EQU	$-2
		WORD	       BOX405,BOX505,BOX605
;
HLEFT		EQU	$-2
		WORD	       BOX705,BOX805,BOX905
		WORD	BOX505,BOX505,BOX505,BOX405
		WORD	BOX505,BOX605
;
BOXLTUP		EQU	$-4
		WORD		      BOX205,BOX205
		WORD	BOX505,BOX505,BOX405,BOX505
		WORD	BOX505,BOX205,BOX505,BOX505
		WORD	BOX505,BOX405,BOX505,BOX505
;
BOXLTDN		EQU	$-2
		WORD	       BOX205,BOX205,BOX305
		WORD	BOX505,BOX505,BOX605,BOX205
		WORD	BOX505,BOX505,BOX505,BOX505
		WORD	BOX505,BOX505,BOX505,BOX605
;
BOXRTUP		EQU	$-6
		WORD			     BOX805
		WORD	BOX405,BOX505,BOX505,BOX405
		WORD	BOX505,BOX505,BOX505,BOX505
		WORD	BOX505,BOX505,BOX505,BOX805
;
BOXRTDN		EQU	$-2
		WORD	       BOX805,BOX505,BOX505
		WORD	BOX605,BOX505,BOX505,BOX505
		WORD	BOX505,BOX605,BOX505,BOX505
		WORD	BOX805,BOX805,BOX905,BOX905
;
;
;****************************************************************
;*								*
;*	草 コース 食べれるＢＧ					*
;*								*
;****************************************************************
KUSABLKBG	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XYPOINT
		STA	<WORKE		; up check & set
		JSL	>UPCHK_SB
		LDA	#CHKCHG_DAT0
		STA	<WORKA
		JSR	BLKBK_CHKCHG
;
DOWNCHG		EQU	$		; down check & set
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	#CHKCHG_DAT1
		STA	<WORKA
		JSR	BLKBK_CHKCHG
;
RTGHTCHG	EQU	$		; right check & set
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	#CHKCHG_DAT2
		STA	<WORKA
		JSR	BLKBK_CHKCHG
;
LEFTCHG		EQU	$		; left check & set
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	#CHKCHG_DAT3
		STA	<WORKA
		JSR	BLKBK_CHKCHG
;
ENDCHG		EQU	$
		LDA	<NOWUNIT
		AND	#000FFH
		ASL	A
		TAY
		LDA	CHKCHG_DAT4,Y
		BEQ	ENDCHG10
		TAY
		LDA	0,Y
ENDCHG10	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+						+
;+	bleak block unit check & change		+
;+						+
;++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
BLKBK_CHKCHG	EQU	$
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	RUT1B00
		BNE	CHKCHG_END
		LDA	>BGUNIT,X
		AND	#000FFH
		ASL	A
		TAY
		LDA	(<WORKA),Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
;
CHKCHG_END	EQU	$
		RTS
;
		MEM8
		IDX8
;
;---------------- up
CHKCHG_DAT0	EQU	$
		WORD	RUT1B09,RUT1B0A,RUT1B0B,RUT1B06,RUT1B07 ; 00
		WORD	RUT1B08,RUT1B06,RUT1B07,RUT1B08,RUT1B09 ;
		WORD	RUT1B0A,RUT1B0B,RUT1B0F,RUT1B0E,RUT1B0E ;
		WORD	RUT1B0F					;
;
		WORD	RUT1B19,RUT1B1A,RUT1B1B,RUT1B16,RUT1B17 ; 10
		WORD	RUT1B18,RUT1B16,RUT1B17,RUT1B18,RUT1B19 ;
		WORD	RUT1B1A,RUT1B1B,RUT1B1F,RUT1B1E,RUT1B1E ;
		WORD	RUT1B1F					;
;
		WORD	RUT1B22,RUT1B25,RUT1B22,RUT1B26,RUT1B27 ; 20
		WORD	RUT1B25,RUT1B26,RUT1B27,RUT1B2C,RUT1B2C ;
		WORD	RUT1B2E,RUT1B2E				;
;
		WORD	RUT1B32,RUT1B35,RUT1B32,RUT1B36,RUT1B37 ; 30
		WORD	RUT1B35,RUT1B36,RUT1B37,RUT1B3B,RUT1B3C ;
		WORD	RUT1B3D,RUT1B3E				;
;
		WORD	RUT1B43,RUT1B44,RUT1B45,RUT1B43,RUT1B44 ; 40
		WORD	RUT1B45,RUT1B47,RUT1B47,RUT1B4B,RUT1B4C ;
		WORD	RUT1B4D,RUT1B4E				;
;
		WORD	RUT1B50,RUT1B51,RUT1B52,RUT1B53,RUT1B54 ; 50
		WORD	RUT1B55,RUT1B56,RUT1B57,RUT1B5B,RUT1B5C ;
;
		WORD	RUT1B62,RUT1B63,RUT1B62,RUT1B63,RUT1B67 ; 60
		WORD	RUT1B68,RUT1B67,RUT1B68,RUT1B6A,RUT1B6B ;
		WORD	RUT1B6C,RUT1B6D				;
;
		WORD	RUT1B70,RUT1B71,RUT1B72,RUT1B73,RUT1B76 ; 70
		WORD	RUT1B77,RUT1B78,RUT1B79,RUT1B7A,RUT1B7B ;
		WORD	RUT1B7C,RUT1B7D				;
;
		WORD	RUT1B8A,RUT1B81,RUT1B8C,RUT1B8E,RUT1B88 ; 80
		WORD	RUT1B89,RUT1B86,RUT1B81,RUT1B88,RUT1B89 ;
		WORD	RUT1B8A,RUT1B8D,RUT1B8C,RUT1B8D,RUT1B8E ;
		WORD	RUT1B86					;
;
		WORD	RUT1B92,RUT1B95,RUT1B92,RUT1B96,RUT1B97 ; 90
		WORD	RUT1B95,RUT1B96,RUT1B97,RUT1B9B,RUT1B9C ;
		WORD	RUT1B9D					;
;
		WORD	RUT1BA2,RUT1BA3,RUT1BA2,RUT1BA3,RUT1BAB ; A0
		WORD	RUT1BAC,RUT1BAD,RUT1BAE,RUT1BAF
;
		WORD	RUT1BB2,RUT1BB5,RUT1BB2,RUT1BB6,RUT1BB7 ; B0
		WORD	RUT1BB5,RUT1BB6,RUT1BB7,RUT1BBC,RUT1BBD ;
		WORD	RUT1BBC,RUT1BBD				;
;
		WORD	RUT1BC3,RUT1BC4,RUT1BC5,RUT1BC3,RUT1BC4 ; C0
		WORD	RUT1BC5,RUT1BC7,RUT1BC7,RUT1BCC,RUT1BCD ;
		WORD	RUT1BCC,RUT1BCD				;
;
		WORD	RUT1BD0,RUT1BD1,RUT1BD2,RUT1BD3,RUT1BD4 ; D0
		WORD	RUT1BD5,RUT1BD6,RUT1BD7,RUT1BDA,RUT1BDB ;
		WORD	RUT1BDC,RUT1BDD				;
;
		WORD	RUT1BE2,RUT1BE5,RUT1BE2,RUT1BE6,RUT1BE7 ; E0
		WORD	RUT1BE5,RUT1BE6,RUT1BE7			;
;
		WORD	RUT1BF0,RUT1BF1,RUT1BF3,RUT1BF4,RUT1BF7 ; F0
		WORD	RUT1BF7,RUT1BF9,RUT1BFA,RUT1BFE		;
;
;---------------- down
CHKCHG_DAT1	EQU	$
		WORD	RUT1B00,RUT1B01,RUT1B02,RUT1B00,RUT1B01 ; 00
		WORD	RUT1B02,RUT1B09,RUT1B0A,RUT1B0B,RUT1B09 ;
		WORD	RUT1B0A,RUT1B0B,RUT1B0C,RUT1B0C,RUT1B0F ;
		WORD	RUT1B0F					;
;
		WORD	RUT1B10,RUT1B11,RUT1B12,RUT1B10,RUT1B11 ; 10
		WORD	RUT1B12,RUT1B19,RUT1B1A,RUT1B1B,RUT1B19 ;
		WORD	RUT1B1A,RUT1B1B,RUT1B1C,RUT1B1C,RUT1B1F ;
		WORD	RUT1B1F					;
;
		WORD	RUT1B20,RUT1B21,RUT1B22,RUT1B20,RUT1B21 ; 20
		WORD	RUT1B25,RUT1B22,RUT1B25,RUT1B2B,RUT1B2C ;
		WORD	RUT1B2B,RUT1B2C				;
;
		WORD	RUT1B30,RUT1B31,RUT1B32,RUT1B30,RUT1B31 ; 30
		WORD	RUT1B35,RUT1B32,RUT1B35,RUT1B3B,RUT1B3C ;
		WORD	RUT1B3D,RUT1B3E				;
;
		WORD	RUT1B40,RUT1B41,RUT1B42,RUT1B43,RUT1B44 ; 40
		WORD	RUT1B45,RUT1B46,RUT1B47,RUT1B4D,RUT1B4E ;
		WORD	RUT1B4D,RUT1B4E				;
;
		WORD	RUT1B53,RUT1B54,RUT1B55,RUT1B53,RUT1B54 ; 50
		WORD	RUT1B55,RUT1B57,RUT1B57,RUT1B5B,RUT1B5C ;
;
		WORD	RUT1B60,RUT1B61,RUT1B62,RUT1B63,RUT1B65 ; 60
		WORD	RUT1B66,RUT1B67,RUT1B68,RUT1B6C,RUT1B6D ;
		WORD	RUT1B6C,RUT1B6D				;
;
		WORD	RUT1B72,RUT1B73,RUT1B72,RUT1B73,RUT1B7C ; 70
		WORD	RUT1B77,RUT1B78,RUT1B79,RUT1B77,RUT1B78 ;
		WORD	RUT1B7C,RUT1B79				;
;
		WORD	RUT1B8B,RUT1B81,RUT1B82,RUT1B83,RUT1B82 ; 80
		WORD	RUT1B83,RUT1B81,RUT1B87,RUT1B8C,RUT1B8E ;
		WORD	RUT1B8D,RUT1B8B,RUT1B8C,RUT1B8D,RUT1B8E ;
		WORD	RUT1B87					;
;
		WORD	RUT1B90,RUT1B91,RUT1B92,RUT1B90,RUT1B91 ; 90
		WORD	RUT1B95,RUT1B92,RUT1B95,RUT1BAD,RUT1BAE ;
		WORD	RUT1BAF					;
;
		WORD	RUT1BA0,RUT1BA1,RUT1BA2,RUT1BA3,RUT1BAC ; A0
		WORD	RUT1BAC,RUT1BAD,RUT1BAE,RUT1BAF
;
		WORD	RUT1BB0,RUT1BB1,RUT1BB2,RUT1BB0,RUT1BB1 ; B0
		WORD	RUT1BB5,RUT1BB2,RUT1BB5,RUT1BBA,RUT1BBB ;
		WORD	RUT1BBC,RUT1BBD				;
;
		WORD	RUT1BC0,RUT1BC1,RUT1BC2,RUT1BC3,RUT1BC4 ; C0
		WORD	RUT1BC5,RUT1BC6,RUT1BC7,RUT1BCA,RUT1BCB ;
		WORD	RUT1BCC,RUT1BCD				;
;
		WORD	RUT1BD6,RUT1BD1,RUT1BD2,RUT1BD3,RUT1BD1 ; D0
		WORD	RUT1BD2,RUT1BD6,RUT1BD3,RUT1BDC,RUT1BDD ;
		WORD	RUT1BDC,RUT1BDD				;
;
		WORD	RUT1BE0,RUT1BE1,RUT1BE2,RUT1BE0,RUT1BE1 ; E0
		WORD	RUT1BE5,RUT1BE2,RUT1BE5			;
;
		WORD	RUT1BF0,RUT1BF1,RUT1BF3,RUT1BF4,RUT1BF6 ; F0
		WORD	RUT1BF7,RUT1BFA,RUT1BFA,RUT1BFE		;
;
;---------------- right
CHKCHG_DAT2	EQU	$
		WORD	RUT1B00,RUT1B00,RUT1B0C,RUT1B03,RUT1B03 ; 00
		WORD	RUT1B0D,RUT1B06,RUT1B06,RUT1B0E,RUT1B09 ;
		WORD	RUT1B09,RUT1B0F,RUT1B0C,RUT1B0D,RUT1B0E ;
		WORD	RUT1B0F					;
;
		WORD	RUT1B10,RUT1B10,RUT1B1C,RUT1B13,RUT1B13 ; 10
		WORD	RUT1B1D,RUT1B16,RUT1B16,RUT1B1E,RUT1B19 ;
		WORD	RUT1B19,RUT1B1F,RUT1B1C,RUT1B1D,RUT1B1E ;
		WORD	RUT1B1F					;
;
		WORD	RUT1B20,RUT1B21,RUT1B22,RUT1B23,RUT1B24 ; 20
		WORD	RUT1B25,RUT1B26,RUT1B27,RUT1B2B,RUT1B2C ;
		WORD	RUT1B2D,RUT1B2E				;
;
		WORD	RUT1B31,RUT1B31,RUT1B35,RUT1B34,RUT1B34 ; 30
		WORD	RUT1B35,RUT1B37,RUT1B37,RUT1B3B,RUT1B3B ;
		WORD	RUT1B3E,RUT1B3E				;
;
		WORD	RUT1B40,RUT1B40,RUT1B46,RUT1B43,RUT1B43 ; 40
		WORD	RUT1B47,RUT1B46,RUT1B47,RUT1B4C,RUT1B4C ;
		WORD	RUT1B4E,RUT1B4E				;
;
		WORD	RUT1B50,RUT1B50,RUT1B56,RUT1B53,RUT1B53 ; 50
		WORD	RUT1B57,RUT1B56,RUT1B57,RUT1B5C,RUT1B5C ;
;
		WORD	RUT1B60,RUT1B61,RUT1B62,RUT1B63,RUT1B66 ; 60
		WORD	RUT1B66,RUT1B68,RUT1B68,RUT1B6A,RUT1B6B ;
		WORD	RUT1B6C,RUT1B6D				;
;
		WORD	RUT1B71,RUT1B71,RUT1B73,RUT1B73,RUT1B7A ; 70
		WORD	RUT1B77,RUT1B79,RUT1B79,RUT1B7A,RUT1B7D ;
		WORD	RUT1B77,RUT1B7D				;
;
		WORD	RUT1B84,RUT1B81,RUT1B82,RUT1B87,RUT1B84 ; 80
		WORD	RUT1B8F,RUT1B86,RUT1B87,RUT1B88,RUT1B86 ;
		WORD	RUT1B88,RUT1B82,RUT1B8C,RUT1B8C,RUT1B81 ;
		WORD	RUT1B8F					;
;
		WORD	RUT1B91,RUT1B91,RUT1B95,RUT1B94,RUT1B94 ; 90
		WORD	RUT1B95,RUT1B97,RUT1B97,RUT1B9B,RUT1B9B ;
		WORD	RUT1BAB					;
;
		WORD	RUT1BA1,RUT1BA1,RUT1BA3,RUT1BA3,RUT1BAB ; A0
		WORD	RUT1BAC,RUT1BAD,RUT1BAD,RUT1BAC
;
		WORD	RUT1BB0,RUT1BB1,RUT1BB2,RUT1BB3,RUT1BB4 ; B0
		WORD	RUT1BB5,RUT1BB6,RUT1BB7,RUT1BBA,RUT1BBB ;
		WORD	RUT1BBC,RUT1BBD				;
;
		WORD	RUT1BC0,RUT1BC0,RUT1BC6,RUT1BC3,RUT1BC3 ; C0
		WORD	RUT1BC7,RUT1BC6,RUT1BC7,RUT1BCB,RUT1BCB ;
		WORD	RUT1BCD,RUT1BCD				;
;
		WORD	RUT1BD1,RUT1BD1,RUT1BD3,RUT1BD3,RUT1BD4 ; D0
		WORD	RUT1BD7,RUT1BD1,RUT1BD7,RUT1BDA,RUT1BDB ;
		WORD	RUT1BDC,RUT1BDD				;
;
		WORD	RUT1BE1,RUT1BE1,RUT1BE5,RUT1BE4,RUT1BE4 ; E0
		WORD	RUT1BE5,RUT1BE7,RUT1BE7			;
;
		WORD	RUT1BF0,RUT1BF1,RUT1BF4,RUT1BF4,RUT1BF6 ; F0
		WORD	RUT1BF7,RUT1BF9,RUT1BFA,RUT1BFE		;
;
;---------------- left
CHKCHG_DAT3	EQU	$
		WORD	RUT1B0C,RUT1B02,RUT1B02,RUT1B0D,RUT1B05 ; 00
		WORD	RUT1B05,RUT1B0E,RUT1B08,RUT1B08,RUT1B0F ;
		WORD	RUT1B0B,RUT1B0B,RUT1B0C,RUT1B0D,RUT1B0E ;
		WORD	RUT1B0F
;
		WORD	RUT1B1C,RUT1B12,RUT1B12,RUT1B1D,RUT1B15 ; 10
		WORD	RUT1B15,RUT1B1E,RUT1B18,RUT1B18,RUT1B1F ;
		WORD	RUT1B1B,RUT1B1B,RUT1B1C,RUT1B1D,RUT1B1E ;
		WORD	RUT1B1F
;
		WORD	RUT1B21,RUT1B21,RUT1B25,RUT1B24,RUT1B24 ; 20
		WORD	RUT1B25,RUT1B27,RUT1B27,RUT1B2B,RUT1B2C ;
		WORD	RUT1B2D,RUT1B2E				;
;
		WORD	RUT1B30,RUT1B31,RUT1B32,RUT1B33,RUT1B34 ; 30
		WORD	RUT1B35,RUT1B36,RUT1B37,RUT1B3E,RUT1B3D ;
		WORD	RUT1B3D,RUT1B3E				;
;
		WORD	RUT1B46,RUT1B42,RUT1B42,RUT1B47,RUT1B45 ; 40
		WORD	RUT1B45,RUT1B46,RUT1B47,RUT1B4B,RUT1B4C ;
		WORD	RUT1B4D,RUT1B4E				;
;
		WORD	RUT1B56,RUT1B52,RUT1B52,RUT1B57,RUT1B55 ; 50
		WORD	RUT1B55,RUT1B56,RUT1B57,RUT1B5B,RUT1B5C ;
;
		WORD	RUT1B61,RUT1B61,RUT1B63,RUT1B63,RUT1B65 ; 60
		WORD	RUT1B66,RUT1B67,RUT1B68,RUT1B6B,RUT1B6B ;
		WORD	RUT1B6D,RUT1B6D				;
;
		WORD	RUT1B70,RUT1B71,RUT1B72,RUT1B73,RUT1B7B ; 70
		WORD	RUT1B79,RUT1B78,RUT1B79,RUT1B7D,RUT1B7B ;
		WORD	RUT1B78,RUT1B7D				;
;
		WORD	RUT1B85,RUT1B81,RUT1B87,RUT1B83,RUT1B8F ; 80
		WORD	RUT1B85,RUT1B86,RUT1B87,RUT1B86,RUT1B89 ;
		WORD	RUT1B89,RUT1B83,RUT1B81,RUT1B8E,RUT1B8E ;
		WORD	RUT1B8F					;
;
		WORD	RUT1B90,RUT1B91,RUT1B92,RUT1B93,RUT1B94 ; 90
		WORD	RUT1B95,RUT1B96,RUT1B97,RUT1BAB,RUT1B9D ;
		WORD	RUT1BAB					;
;
		WORD	RUT1BA0,RUT1BA1,RUT1BA2,RUT1BA3,RUT1BAB ; A0
		WORD	RUT1BAC,RUT1BAC,RUT1BAF,RUT1BAF
;
		WORD	RUT1BB1,RUT1BB1,RUT1BB5,RUT1BB4,RUT1BB4 ; B0
		WORD	RUT1BB5,RUT1BB7,RUT1BB7,RUT1BBB,RUT1BBB ;
		WORD	RUT1BBD,RUT1BBD				;
;
		WORD	RUT1BC6,RUT1BC2,RUT1BC2,RUT1BC7,RUT1BC5 ; C0
		WORD	RUT1BC5,RUT1BC6,RUT1BC7,RUT1BCA,RUT1BCB ;
		WORD	RUT1BCC,RUT1BCD				;
;
		WORD	RUT1BD5,RUT1BD3,RUT1BD2,RUT1BD3,RUT1BD7 ; D0
		WORD	RUT1BD5,RUT1BD2,RUT1BD7,RUT1BDB,RUT1BDB ;
		WORD	RUT1BDD,RUT1BDD				;
;
		WORD	RUT1BE0,RUT1BE1,RUT1BE2,RUT1BE3,RUT1BE4 ; E0
		WORD	RUT1BE5,RUT1BE6,RUT1BE7			;
;
		WORD	RUT1BF1,RUT1BF1,RUT1BF3,RUT1BF4,RUT1BF6 ; F0
		WORD	RUT1BF7,RUT1BF9,RUT1BFA,RUT1BFE		;
;
CHKCHG_DAT4	EQU	$

		WORD	UT0000, UT0000, UT0000, UT0000, UT0000, UT0000, UT0000, UT0000	;[00-0F]
		WORD	UT0000, UT0000, UT0000, UT0000, UT0000, UT0000, UT0000, UT0000
;
		WORD	RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13 ;[10-1F]
		WORD	RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13,RUT1D13
;
		WORD	RUT1D0D,RUT1D0D,RUT1D0D,RUT1D0D,RUT1D0D,RUT1D0D,RUT1D0D,RUT1D0D ;[20-27]
;
		WORD				RUT1D00,RUT1D00,RUT1D00,RUT1D00		;[2B-2E]
;
		WORD	RUT1D0E,RUT1D0E,RUT1D0E,RUT1D0E,RUT1D0E,RUT1D0E,RUT1D0E,RUT1D0E ;[30-37]
;
		WORD				RUT1D03,RUT1D03,RUT1D03,RUT1D03		;[3B-3E]
;
		WORD	RUT1D0B,RUT1D0B,RUT1D0B,RUT1D0B,RUT1D0B,RUT1D0B,RUT1D0B,RUT1D0B ;[40-47]
;
		WORD				RUT1D07,RUT1D07,RUT1D07,RUT1D07		;[4B-4E]
;
		WORD	RUT1D0C,RUT1D0C,RUT1D0C,RUT1D0C,RUT1D0C,RUT1D0C,RUT1D0C,RUT1D0C ;[50-57]
;
		WORD	RUT1D2C,RUT1D2C							;[58-59]
;
		WORD	RUT1D0F,RUT1D0F,RUT1D0F,RUT1D0F					;[60-63]
;
		WORD						RUT1D10,RUT1D10,RUT1D10 ;[65-68]
		WORD	RUT1D10
;
		WORD			RUT1D11,RUT1D11,RUT1D11,RUT1D11			;[6A-6D]
;
		WORD	RUT1D12,RUT1D12,RUT1D12,RUT1D12					;[70-73]
;
		WORD							RUT1D21,RUT1D21 ;[76-7D]
		WORD	RUT1D21,RUT1D21,RUT1D21,RUT1D21,RUT1D21,RUT1D21
;
		WORD	RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20 ;[80-8F]
		WORD	RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20,RUT1D20
;
		WORD	RUT1D08,RUT1D08,RUT1D08,RUT1D08,RUT1D08,RUT1D08,RUT1D08,RUT1D08 ;[90-97]
;
		WORD				RUT2A00,RUT2A01,RUT2A00			;[9B-9D]
;
		WORD	RUT1D2B,RUT1D2B,RUT1D2B,RUT1D2B					;[A0-A3]
;
		WORD				RUT2A00,RUT2A01,RUT2A00,RUT2A01,RUT2A00 ;[AB-AF]
;
		WORD	RUT1D09,RUT1D09,RUT1D09,RUT1D09,RUT1D09,RUT1D09,RUT1D09,RUT1D09 ;[B0-B7]
;
		WORD			RUT1D06,RUT1D06,RUT1D06,RUT1D06			;[BA-BD]
;
		WORD	RUT1D02,RUT1D02,RUT1D02,RUT1D02,RUT1D02,RUT1D02,RUT1D02,RUT1D02 ;[C0-C7]
;
		WORD			RUT1D05,RUT1D05,RUT1D05,RUT1D05			;[CA-CD]
;
		WORD	RUT1D01,RUT1D01,RUT1D01,RUT1D01,RUT1D01,RUT1D01,RUT1D01,RUT1D01 ;[D0-D7]
;
		WORD			RUT1D04,RUT1D04,RUT1D04,RUT1D04			;[DA-DD]
;
		WORD	RUT1D2D,RUT1D2D,RUT1D2D,RUT1D2D,RUT1D2D,RUT1D2D,RUT1D2D,RUT1D2D ;[E0-E7]
;
		WORD	RUT1D2E,RUT1D2E,	RUT1D2F,RUT1D2F,	RUT1D30,RUT1D30 ;[F0-F7]
;
		WORD		RUT1D31,RUT1D31				RUT1D20		;[F9-FF]
;
;
;****************************************************************
;*								*
;*	カベ コース 縦書き線路					*
;*	カベ コース 横書き線路					*
;*								*
;****************************************************************
KABESENROVH	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<STUNTNO
		AND	#00001H
		ASL	A
		TAY
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	KABESENROVH_30
		CMP	RUT2A01
		BEQ	KABESENROVH_30
		CMP	RUT6805
		BEQ	KABESENROVH_30
		CMP	RUT6806
		BNE	KABESENROVH_50
KABESENROVH_30	EQU	$
		LDY	#RUT1F01
		BRA	KABESENROVH_90
KABESENROVH_50	EQU	$
		LDA	KABESENRO_DT,Y
		TAY
KABESENROVH_90	EQU	$
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
KABESENRO_DT	EQU	$
		WORD	RUT1F00,RUT2400
;
;
;****************************************************************
;*								*
;*	カベ コース 斜め書き線路				*
;*								*
;****************************************************************
KABESENROS	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#00001H
		STA	<LKFLG
		LDA	<YSIZE
		CMP	#00002H
		BCS	KABESENROS_990
		ASL	A
		TAY
		LDA	<XSIZECP
		BPL	KABESENROS_100
		TYA
		ORA	#00004H
		TAY
KABESENROS_100	EQU	$
		LDX	<UNITPOS
		LDA	KABESENROS_DT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
KABESENROS_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABESENROS_DT	EQU	$
		WORD	RUT2300,RUT2200
		WORD	RUT2000,RUT2100
;
;
;****************************************************************
;*								*
;*	カベ コース 半当たり横棒				*
;*								*
;****************************************************************
KABEYUKABOU	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		CMP	#UT00D5
		BCC	KBYKBOU_990
		CMP	#UT00DA+1
		BCS	KBYKBOU_990
		CMP	#UT150F
		BEQ	KBYKBOU_990
		CMP	#UT1510
		BEQ	KBYKBOU_990
;
		LDY	#00000H
		LDA	<XSIZE
		BEQ	KBYKBOU_150
		INC	A
		CMP	<XSIZECP
		BNE	KBYKBOU_130
		LDY	#00006H
		BRA	KBYKBOU_150
KBYKBOU_130	EQU	$
		INY
		INY
		AND	#00001H
		BEQ	KBYKBOU_150
		INY
		INY
;
KBYKBOU_150	EQU	$
		LDA	<XSIZE
		BEQ	KBYKBOU_160
		INC	A
		CMP	<XSIZECP
		BNE	KBYKBOU_190
KBYKBOU_160	EQU	$
		LDA	<NOWUNIT
		CMP	RUT0200
		BCC	KBYKBOU_170
		CMP	RUT1200
		BCC	KBYKBOU_990
KBYKBOU_170	EQU	$
		CMP	#UT00E4
		BEQ	KBYKBOU_180
		CMP	#UT00E5
		BNE	KBYKBOU_190
KBYKBOU_180	EQU	$
		LDY	#00002
KBYKBOU_190	EQU	$
		LDA	KBYKBOU_DT,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		LDA	<NOWUNIT
		CMP	#UT00D7
		BCC	KBYKBOU_990
		CMP	#UT00DA+1
		BCS	KBYKBOU_990
		LDA	<XSIZE
		BEQ	KBYKBOU_990
		LDA	<NOWUNIT
		SEC
		SBC	#UT00D7
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	KBYKBOU_KAGE_DT,Y
		STA	>BGUNIT,X
		BRA	KBYKBOU_990
;
KBYKBOU_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KBYKBOU_DT	EQU	$
		WORD	UT00E4,UT150F,UT1510,UT00E5
;
KBYKBOU_KAGE_DT EQU	$
		WORD	UT1521,UT1521,00000H,UT1520
;
;
;****************************************************************
;*								*
;*	カベ コース 半当たり斜め棒				*
;*								*
;****************************************************************
KABESAKBOU	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<XSIZECP
		BPL	KABESAKBOU_000
		INC	A
		INC	A
KABESAKBOU_000	EQU	$
		STA	<WORK0
		LDA	<XSIZE		; start ?
		BEQ	KABESAKBOU_100	;	YES -> KABESAKBOU_100
		INY
		INY
		INC	A
		CMP	<WORK0		; end ?
		BEQ	KABESAKBOU_100	;	YES -> KABESAKBOU_100
		LDA	<STUNTNO
		AND	#00003H
		ASL	A
		TAX
		JSR	(KABESAKBOU_SET,X)
		BRA	KABESAKBOU_900
;
KABESAKBOU_100	EQU	$		; start & end data set
		LDA	<YSIZE
		BNE	KABESAKBOU_900
		LDA	<NOWUNIT
		CMP	RUT0200
		BCC	KABESAKBOU_110
		CMP	RUT1200
		BCC	KABESAKBOU_900
;
KABESAKBOU_110	EQU	$
		CMP	#UT150F
		BEQ	KABESAKBOU_900
		CMP	#UT1510
		BEQ	KABESAKBOU_900
		CMP	#UT00E4
		BEQ	KABESAKBOU_120
		CMP	#UT00E5
		BNE	KABESAKBOU_130
		INY
		INY
KABESAKBOU_120	EQU	$
		LDA	KABESAKBOU_1DT0,Y
		BRA	KABESAKBOU_190
KABESAKBOU_130	EQU	$
		LDA	<XSIZECP
		BPL	KABESAKBOU_150
		TYA
		EOR	#00002H
		TAY
KABESAKBOU_150	EQU	$
		LDA	<YSIZE
		BNE	KABESAKBOU_900
		LDA	<NOWUNIT
		CMP	#UT00D8
		BNE	KABESAKBOU_180
		LDY	#00004
KABESAKBOU_180	EQU	$
		LDA	KABESAKBOU_1DT,Y
KABESAKBOU_190	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
KABESAKBOU_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABESAKBOU_1DT	EQU	$
		WORD	UT00E4,UT00E5,UT1521
;
KABESAKBOU_1DT0 EQU	$
		WORD	UT150F,UT1510,UT150F
;
KABESAKBOU_SET	EQU	$
		WORD	KABESAKBOU_200
		WORD	KABESAKBOU_300
		WORD	KABESAKBOU_400
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	半当たり斜め棒 30ﾟ				+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
KABESAKBOU_200	EQU	$
		LDA	<YSIZE
		CMP	#00002H
		BCS	KABESAKBOU_299
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		EOR	#00001H
		AND	#00001H
		STA	<LKFLG
		ASL	A
		ASL	A
		TAY
		LDA	<XSIZECP
		BPL	KABESAKBOU_220
		TYA
		ORA	#00008H
		TAY
KABESAKBOU_220	EQU	$
		TYA
		ORA	<WORK0
		TAY
		LDX	<UNITPOS
		LDA	KABESAKBOU_2DT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
KABESAKBOU_299	EQU	$
		RTS
;
KABESAKBOU_2DT	EQU	$
		WORD	RUT0F00,RUT1300,RUT1000,RUT1100
		WORD	RUT0D00,RUT1200,RUT0C00,RUT0E00
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	半当たり斜め棒 45ﾟ				+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABESAKBOU_300	EQU	$
		LDA	#00001H
		STA	<LKFLG
		LDA	<YSIZE
		CMP	#00002H
		BCS	KABESAKBOU_399
		ASL	A
		TAY
		LDA	<XSIZECP
		BPL	KABESAKBOU_320
		TYA
		ORA	#00004H
		TAY
KABESAKBOU_320	EQU	$
		LDX	<UNITPOS
		LDA	KABESAKBOU_3DT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
KABESAKBOU_399	EQU	$
		RTS
;
KABESAKBOU_3DT	EQU	$
		WORD	RUT0A00,RUT0B00
		WORD	RUT0800,RUT0900
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	半当たり斜め棒 60ﾟ				+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABESAKBOU_400	EQU	$
		LDA	#00001H
		STA	<LKFLG
		LDA	<YSIZE
		CMP	#00003H
		BCS	KABESAKBOU_499
		ASL	A
		TAY
		LDA	<XSIZECP
		BPL	KABESAKBOU_420
		TYA
		CLC
		ADC	#00006H
		TAY
KABESAKBOU_420	EQU	$
		LDX	<UNITPOS
		LDA	KABESAKBOU_4DT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
KABESAKBOU_499	EQU	$
		RTS
		MEM8
		IDX8
;
KABESAKBOU_4DT	EQU	$
		WORD	RUT0500,RUT0600,RUT0700
		WORD	RUT0200,RUT0300,RUT0400
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の 半あたり 台			*
;*								*
;****************************************************************
KUSAHANHAS	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<XSIZE		; 左端か ?
		BEQ	HANHAS_100	;	YES -> HANHAS_100
		INY
		INY
		INC	A
		CMP	<XSIZECP	; 右端か ?
		BNE	HANHAS_800	;	NO -> HANHAS_800
		INY
		INY
		BRA	HANHAS_200
;
HANHAS_100	EQU	$
		LDA	<NOWUNIT	; 左端ユニット チェック !!
		CMP	RUT1D0D
		BNE	HANHAS_800
		BRA	HANHAS_700
;
HANHAS_200	EQU	$
		LDA	<NOWUNIT	; 右端ユニット チェック !!
		CMP	RUT1D0E
		BNE	HANHAS_800
;
HANHAS_700	EQU	$
		TYA
		ORA	#00008H
		TAY
;
HANHAS_800	EQU	$
		LDA	<STUNTNO
		CMP	#00057H
		BEQ	HANHAS_850
		LDA	HANHAS_DT1,Y
		BRA	HANHAS_900
HANHAS_850	EQU	$
		LDA	HANHAS_DT0,Y
;
HANHAS_900	EQU	$
		TAY
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
HANHAS_DT0	EQU	$
		WORD	RUT3F00,RUT3F01,RUT3F02,00000H
		WORD	RUT3F03,RUT3F01,RUT3F04
;
HANHAS_DT1	EQU	$
		WORD	RUT3809,RUT380A,RUT380B,00000H
		WORD	RUT3809,RUT380A,RUT380B
;
;
;****************************************************************
;*								*
;*	草コース オーバーハング					*
;*								*
;****************************************************************
KUSAOVHANG	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000H
		LDA	<XSIZE
		BEQ	OVHANG090
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	OVHANG090
		INX
		INX
OVHANG090	EQU	$
		JSR	(OVHANGSET,X)
		MI8			; memory , index 8bit mode
		RTL
;
OVHANGSET	EQU	$
		WORD	OVHANG100	; left side data set
		WORD	OVHANG200	; center data set
		WORD	OVHANG300	; right side data set
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	left side data set				+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
OVHANG100	EQU	$
		LDA	<XYCPBF
		BPL	OVHANG100_00
		JMP	OVHANG100_90
OVHANG100_00	EQU	$
		LDA	<XYCPBF
		BNE	OVHANG100_10
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB	; down point check
		LDA	>BGUNIT,X
		CMP	RUT392C
		BEQ	OVHANG100_10
		CMP	RUT392D
		BEQ	OVHANG100_10
		CMP	RUT390E
		BCC	OVHANG100_50
		CMP	RUT391C
		BCS	OVHANG100_50
OVHANG100_10	EQU	$
		LDA	#00001H
		STA	<XYCPBF
		LDA	<YSIZE
		BEQ	OVHANG100_20
		LDA	#00001H
		STA	<STUNTNO
		JSL	>FLRLFT_RND
;
		MI16			; memory , index 16bit mode
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	#UT008B
		BEQ	OVHANG100_15
		CMP	#UT008C
		BEQ	OVHANG100_15
		CMP	RUT2A00
		BEQ	OVHANG100_15
		CMP	RUT2A01
		BNE	OVHANG100_19
OVHANG100_15	EQU	$
		LDX	<UNITPOS
		LDA	RUT392B
		STA	>BGUNIT,X
OVHANG100_19	EQU	$
		BRA	OVHANG100_90
;
OVHANG100_20	EQU	$
		LDA	RUT3933
		BRA	OVHANG100_55
;
OVHANG100_50	EQU	$
		LDA	<YSIZE
		BNE	OVHANG100_90
		LDA	<NOWUNIT
		CMP	RUT3930
		BEQ	OVHANG100_51
		CMP	RUT3931
		BEQ	OVHANG100_51
		CMP	RUT3932
		BEQ	OVHANG100_51
		CMP	RUT3933
		BEQ	OVHANG100_51
		CMP	RUT3934
		BEQ	OVHANG100_51
		CMP	RUT3935
		BNE	OVHANG100_53
OVHANG100_51	EQU	$
		LDA	RUT3931
		BRA	OVHANG100_55
OVHANG100_53	EQU	$
		LDA	#08000H
		STA	<XYCPBF
		LDA	<NOWUNIT
		CMP	RUT1D28
		BEQ	OVHANG100_90
		CMP	RUT1D0C
		BNE	OVHANG100_54
		LDA	RUT1D28
		BRA	OVHANG100_55
OVHANG100_54	EQU	$
		LDA	RUT3930
OVHANG100_55	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
OVHANG100_90	EQU	$
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	center data set					+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
OVHANG200	EQU	$
		STZ	<XYCPBF
		LDA	<YSIZE
		BNE	OVHANG2_99
		LDA	<NOWUNIT
		CMP	RUT1D28
		BEQ	OVHANG2_99
		LDY	#00000H
OVHANG2_10	EQU	$
		LDX	OVHANG2_CPDT,Y
		CMP	0,X
		BEQ	OVHANG2_20
		INY
		INY
		CPY	#OVHANG2_STDT-OVHANG2_CPDT
		BCC	OVHANG2_10
		LDA	RUT3931
		BRA	OVHANG2_90
;
OVHANG2_20	EQU	$
		LDX	OVHANG2_STDT,Y
		LDA	0,X
OVHANG2_90	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
OVHANG2_99	EQU	$
		RTS
;
OVHANG2_CPDT	EQU	$
		WORD	RUT1D01,RUT1D03,RUT1D04,RUT1D07,RUT1D0C
		WORD	RUT1D11,RUT1D12
		WORD	RUT1D21,RUT1D2C,RUT1D2E,RUT1D2F
		WORD	RUT1D31
;
OVHANG2_STDT	EQU	$
		WORD	RUT1D28,RUT1D28,RUT1D27,RUT1D29,RUT1D28
		WORD	RUT1D27,RUT1D29
		WORD	RUT1D28,RUT1D29,RUT1D27,RUT1D29
		WORD	RUT1D2A
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	right side data set				+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
OVHANG300	EQU	$
		LDA	<XYCPBF
		BPL	OVHANG300_00
		JMP	OVHANG300_90
OVHANG300_00	EQU	$
		LDA	<XYCPBF
		BNE	OVHANG300_10
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB	; down point check
		LDA	>BGUNIT,X
		CMP	RUT392C
		BEQ	OVHANG300_10
		CMP	RUT392D
		BEQ	OVHANG300_10
		CMP	RUT390E
		BCC	OVHANG300_50
		CMP	RUT391C
		BCS	OVHANG300_50
OVHANG300_10	EQU	$
		LDA	#00001H
		STA	<XYCPBF
		LDA	<YSIZE
		BEQ	OVHANG300_20
		STZ	<STUNTNO
		JSL	>FLRLFT_RND
;
		MI16			; memory , index 16bit mode
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT008B
		BEQ	OVHANG300_15
		CMP	#UT008D
		BEQ	OVHANG300_15
		CMP	RUT2A00
		BEQ	OVHANG300_15
		CMP	RUT2A01
		BNE	OVHANG300_19
OVHANG300_15	EQU	$
		LDX	<UNITPOS
		LDA	RUT392A
		STA	>BGUNIT,X
OVHANG300_19	EQU	$
		BRA	OVHANG300_90
;
OVHANG300_20	EQU	$
		LDA	RUT3932
		BRA	OVHANG300_55
;
OVHANG300_50	EQU	$
		LDA	<YSIZE
		BNE	OVHANG300_90
		LDA	<NOWUNIT
		CMP	RUT3930
		BEQ	OVHANG300_51
		CMP	RUT3931
		BEQ	OVHANG300_51
		CMP	RUT3932
		BEQ	OVHANG300_51
		CMP	RUT3933
		BEQ	OVHANG300_51
		CMP	RUT3934
		BEQ	OVHANG300_51
		CMP	RUT3935
		BNE	OVHANG300_53
OVHANG300_51	EQU	$
		LDA	RUT3931
		BRA	OVHANG300_55
OVHANG300_53	EQU	$
		LDA	#08000H
		STA	<XYCPBF
		LDA	<NOWUNIT
		CMP	RUT1D28
		BEQ	OVHANG300_90
		CMP	RUT1D0C
		BNE	OVHANG300_54
		LDA	RUT1D28
		BRA	OVHANG300_55
OVHANG300_54	EQU	$
		LDA	RUT3935
OVHANG300_55	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
OVHANG300_90	EQU	$
		RTS
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右下がり坂 30ﾟ			*
;*	草コース トンネル内の右上がり坂 30ﾟ			*
;*								*
;****************************************************************
KUSAANARD30	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	ANARD30_100
		INC	A
		CMP	<XSIZECP
		BNE	ANARD30_200
		LDA	<STUNTNO
		AND	#00004H
		BNE	ANARD30_050
		LDA	<YSIZE
		BEQ	ANARD30_090
ANARD30_050	EQU	$
		JSR	ANASAKRIT	; トンネル内の右側 影付き壁
ANARD30_090	EQU	$
		BRA	ANARD30_990
;
ANARD30_100	EQU	$
		JSR	ANASAKLFT	; トンネル内の左側 壁
		LDA	<STUNTNO
		AND	#00004H
		STA	<LKFLG
		BRA	ANARD30_990
;
ANARD30_200	EQU	$
		LDA	<YSIZE
		CMP	#00002H
		BCS	ANARD30_300
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00001H
		EOR	#00001H
		STA	<LKFLG
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	<STUNTNO
		AND	#00004H
		ASL	A
		STA	<WORK0
		TYA
		ORA	<WORK0
		TAY
		LDA	<NOWUNIT
		CMP	RUT3932
		BEQ	ANARD30_990
		CMP	RUT3933
		BEQ	ANARD30_990
		LDA	ANARD30_DAT,Y	; 斜面 セット
		TAY
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
		BRA	ANARD30_990
;
ANARD30_300	EQU	$
		JSR	ANATUTI		; 土 セット
;
ANARD30_990	EQU	$
		LDA	<XSIZE
		INC	A
		INC	A
		CMP	<XSIZECP
		BNE	ANARD30_999
		STZ	<LKFLG
ANARD30_999	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
ANARD30_DAT	EQU	$
		WORD	RUT4400,RUT3910,RUT4500,RUT3911
		WORD	RUT4000,RUT3910,RUT4100,RUT3911
;;;;K;;;;		WORD	RUT4400,RUT4600,RUT4500,RUT4700
;;;;K;;;;		WORD	RUT4000,RUT4200,RUT4100,RUT4300
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右下がり坂 45ﾟ			*
;*	草コース トンネル内の右上がり坂 45ﾟ			*
;*								*
;****************************************************************
KUSAANARD45	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	ANARD45_100
		INC	A
		CMP	<XSIZECP
		BNE	ANARD45_200
		LDA	<STUNTNO
		AND	#00004H
		BNE	ANARD45_050
		LDA	<YSIZE
		BEQ	ANARD45_090
ANARD45_050	EQU	$
		JSR	ANASAKRIT	; トンネル内の右側 影付き壁
ANARD45_090	EQU	$
		BRA	ANARD45_990
;
ANARD45_100	EQU	$
		JSR	ANASAKLFT	; トンネル内の左側 壁
		LDA	<STUNTNO
		AND	#00004H
		STA	<LKFLG
		BRA	ANARD45_990
;
ANARD45_200	EQU	$
		LDA	<YSIZE
		CMP	#00002H
		BCS	ANARD45_300
		ASL	A
		STA	<WORK0
		LDA	<STUNTNO
		AND	#00004H
		ORA	<WORK0
		TAY
		LDA	#00001H
		STA	<LKFLG
		LDA	<NOWUNIT
		CMP	RUT3932
		BEQ	ANARD45_990
		CMP	RUT3933
		BEQ	ANARD45_990
		LDA	ANARD45_DAT,Y	; 斜面 セット
		TAY
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
		BRA	ANARD45_990
;
ANARD45_300	EQU	$
		JSR	ANATUTI		; 土 セット
;
ANARD45_990	EQU	$
		LDA	<XSIZE
		INC	A
		INC	A
		CMP	<XSIZECP
		BNE	ANARD45_999
		STZ	<LKFLG
ANARD45_999	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
ANARD45_DAT	EQU	$
		WORD	RUT5000,RUT3910
		WORD	RUT4E00,RUT3911
;;;;K;;;		WORD	RUT5000,RUT5100
;;;;K;;;		WORD	RUT4E00,RUT4F00
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右下がり坂 60ﾟ			*
;*	草コース トンネル内の右上がり坂 60ﾟ			*
;*								*
;****************************************************************
KUSAANARD60	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	ANARD60_100
		INC	A
		CMP	<XSIZECP
		BNE	ANARD60_200
		LDA	<STUNTNO
		AND	#00004H
		BNE	ANARD60_050
		LDA	<YSIZE
		BEQ	ANARD60_090
		CMP	#00001H
		BEQ	ANARD60_090
ANARD60_050	EQU	$
		JSR	ANASAKRIT	; トンネル内の右側 影付き壁
ANARD60_090	EQU	$
		BRA	ANARD60_990
;
ANARD60_100	EQU	$
		JSR	ANASAKLFT	; トンネル内の左側 壁
		LDA	<STUNTNO
		AND	#00004H
		STA	<LKFLG
		BRA	ANARD60_990
;
ANARD60_200	EQU	$
		LDA	<YSIZE
		CMP	#00003H
		BCS	ANARD60_300
		ASL	A
		STA	<WORK0
		LDA	<STUNTNO
		AND	#00004H
		ASL	A
		ORA	<WORK0
		TAY
		LDA	#00001H
		STA	<LKFLG
		LDA	<NOWUNIT
		CMP	RUT3932
		BEQ	ANARD60_990
		CMP	RUT3933
		BEQ	ANARD60_990
		LDA	ANARD60_DAT,Y	; 斜面 セット
		TAY
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
		BRA	ANARD60_990
;
ANARD60_300	EQU	$
		JSR	ANATUTI		; 土 セット
;
ANARD60_990	EQU	$
		LDA	<XSIZE
		INC	A
		INC	A
		CMP	<XSIZECP
		BNE	ANARD60_999
		STZ	<LKFLG
ANARD60_999	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
ANARD60_DAT	EQU	$
		WORD	RUT4B00,RUT4C00,RUT3910,00000H
		WORD	RUT4800,RUT4900,RUT3911
;;;;K;;;;		WORD	RUT4B00,RUT4C00,RUT4D00,00000H
;;;;K;;;;		WORD	RUT4800,RUT4900,RUT4A00
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右上がり逆坂 30ﾟ			*
;*	草コース トンネル内の右上がり逆坂 45ﾟ			*
;*								*
;****************************************************************
KUSAANAURU30	EQU	$
KUSAANAURU45	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<STUNTNO
		AND	#00020H
		LSR	A
		STA	<WORK2
		LDA	<XSIZE
		BEQ	ANAURU30_100
		INC	A
		CMP	<XSIZECP
		BNE	ANAURU30_200
;
		LDA	<WORK2
		BEQ	ANAURU30_030
		LDA	<YSIZE
		BNE	ANAURU30_030
		DEC	<YSIZECP
ANAURU30_030	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BEQ	ANAURU30_050
		JSR	ANASAKRIT	; トンネル内の右側 影付き壁
		STZ	<XYCPBF
		JMP	ANAURU30_990
;
ANAURU30_050	EQU	$
		LDA	<XYCPBF
		BNE	ANAURU30_090
		LDA	<NOWUNIT
		CMP	RUT1D13
		BNE	ANAURU30_090
		LDA	RUT1D23
		STA	>BGUNIT,X
ANAURU30_090	EQU	$
		JMP	ANAURU30_990
;
ANAURU30_100	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BCS	ANAURU30_190
ANAURU30_180	EQU	$
		JSR	ANASAKLFT	; トンネル内の左側 壁
ANAURU30_190	EQU	$
		JMP	ANAURU30_990
;
ANAURU30_200	EQU	$
		LDA	<WORK2
		BEQ	ANAURU30_205
		LDA	<YSIZE
		BNE	ANAURU30_205
		LDA	<XSIZE
		CMP	#00001H
		BEQ	ANAURU30_205
		DEC	<YSIZECP
		LDA	<YSIZECP
		CMP	#00002H
		BNE	ANAURU30_205
		LDA	#00002H
		BRA	ANAURU30_230
ANAURU30_205	EQU	$
		LDA	<XSIZE
		INC	A
		INC	A
		CMP	<XSIZECP
		BNE	ANAURU30_220
		LDA	<YSIZE
		BNE	ANAURU30_220
		LDA	<YSIZECP
		CMP	#00003H
		BCS	ANAURU30_220
		DEC	<XSIZECP
ANAURU30_210	EQU	$
		LDA	<XSIZECP
		CMP	#00002H
		BEQ	ANAURU30_230
		LDA	#00001H
		BRA	ANAURU30_230
ANAURU30_220	EQU	$
		LDA	<YSIZE
		INC	A
		INC	A
		CMP	<YSIZECP
		BCC	ANAURU30_300
		LDA	<YSIZECP
ANAURU30_230	EQU	$
		CLC
		SBC	<YSIZE
		BMI	ANAURU30_990
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00001H
		EOR	#00001H
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		ORA	<WORK2
		STA	<WORK0
		TAY
		LDA	!BG1TYP
		CMP	#00008
		BNE	ANAURU30_250
		LDA	ANAURU30_DT_SB,Y
		BEQ	ANAURU30_990
		BRA	ANAURU30_255
ANAURU30_250	EQU	$
		LDA	ANAURU30_DAT,Y	; 斜面 セット
ANAURU30_255	EQU	$
		TAY
		LDA	0,Y
		CMP	RUT1D23
		BNE	ANAURU30_280
		LDA	<NOWUNIT
		CMP	RUT1D20
		BEQ	ANAURU30_280
		CMP	RUT1D13
		BNE	ANAURU30_990
ANAURU30_280	EQU	$
		LDA	0,Y
		STA	>BGUNIT,X
		LDA	<WORK0
		AND	#00008H
		STA	<XYCPBF
		BRA	ANAURU30_990
;
ANAURU30_300	EQU	$
		JSR	ANATUTI		; 土 セット
		LDA	<WORK2
		BNE	ANAURU30_990
		LDA	<YSIZE
		BNE	ANAURU30_990
		LDA	<XSIZE
		AND	#00001H
		BNE	ANAURU30_990
		DEC	<YSIZECP
;
ANAURU30_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
ANAURU30_DAT	EQU	$
		WORD	RUT1D23,RUT5700,RUT3910,00000H
		WORD	RUT5900,RUT3911,00000H, 00000H
;
		WORD	RUT1D23,RUT5D00,RUT3910,00000H
		WORD	RUT1D23,RUT5D00,RUT3911,00000H
;
ANAURU30_DT_SB	EQU	$
		WORD	00000H, RRR5711,RUT3910,00000H
		WORD	RRR5911,RUT3911,00000H, 00000H
;
		WORD	00000H,RRR5D11,RUT3910,00000H
		WORD	00000H,RRR5D11,RUT3911,00000H
;
RRR5711 EQU	$
	WORD	UT5711
RRR5911 EQU	$
	WORD	UT5911
RRR5D11 EQU	$
	WORD	UT5D11
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右下がり逆坂 30ﾟ			*
;*	草コース トンネル内の右下がり逆坂 45ﾟ			*
;*								*
;****************************************************************
KUSAANAURD30	EQU	$
KUSAANAURD45	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<STUNTNO
		AND	#00002H
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK2
		LDA	<XSIZE
		BEQ	ANAURD30_100
		INC	A
		CMP	<XSIZECP
		BNE	ANAURD30_200
;
		LDA	<YSIZE
		BNE	ANAURD30_030
		INC	<YSIZECP
ANAURD30_030	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BEQ	ANAURD30_090
		INC	A
		CMP	<YSIZECP
		BEQ	ANAURD30_050
		JSR	ANASAKRIT	; トンネル内の右側 影付き壁
		STZ	<XYCPBF
		JMP	ANAURD30_990
;
ANAURD30_050	EQU	$
		LDA	<XYCPBF
		BNE	ANAURD30_090
		LDA	<NOWUNIT
		CMP	RUT1D13
		BNE	ANAURD30_090
		LDX	<UNITPOS
		LDA	RUT1D23
		STA	>BGUNIT,X
ANAURD30_090	EQU	$
		JMP	ANAURD30_990
;
ANAURD30_100	EQU	$
		LDA	<YSIZECP
		CMP	#00001H
		BEQ	ANAURD30_190
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BEQ	ANAURD30_190
		JSR	ANASAKLFT	; トンネル内の左側 壁
ANAURD30_190	EQU	$
		JMP	ANAURD30_990
;
ANAURD30_200	EQU	$
		LDA	<WORK2
		BNE	ANAURD30_203
		LDA	<XSIZE
		AND	#00001H
		BNE	ANAURD30_210
ANAURD30_203	EQU	$
		LDA	<YSIZE
		BNE	ANAURD30_210
		INC	<YSIZECP
ANAURD30_210	EQU	$
		LDA	<YSIZE
		INC	A
		INC	A
		CMP	<YSIZECP
		BCC	ANAURD30_300
		LDA	<YSIZECP
		SEC
		SBC	<YSIZE
		BMI	ANAURD30_990
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00001H
		EOR	#00001H
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		ORA	<WORK2
		TAY
		LDX	<UNITPOS
		LDA	!BG1TYP
		CMP	#00008
		BNE	ANAURD30_250
		LDA	ANAURD30_DT_SB,Y
		BEQ	ANAURD30_990
		BRA	ANAURD30_255
ANAURD30_250	EQU	$
		LDA	ANAURD30_DAT,Y	; 斜面 セット
ANAURD30_255	EQU	$
		TAY
		LDA	0,Y
		CMP	RUT1D22
		BNE	ANAURD30_280
		LDA	<NOWUNIT
		CMP	RUT1D13
		BEQ	ANAURD30_280
		CMP	RUT1D0E
		BEQ	ANAURD30_290
		CMP	RUT1D12
		BEQ	ANAURD30_295
		BRA	ANAURD30_990
ANAURD30_280	EQU	$
		LDA	0,Y
		STA	>BGUNIT,X
		BRA	ANAURD30_990
;
ANAURD30_290	EQU	$
		LDA	RUT1D2B
		STA	>BGUNIT,X
		BRA	ANAURD30_990
;
ANAURD30_295	EQU	$
		LDA	RUT1D2C
		STA	>BGUNIT,X
		BRA	ANAURD30_990
;
ANAURD30_300	EQU	$
		JSR	ANATUTI		; 土 セット
;
ANAURD30_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
ANAURD30_DAT	EQU	$
		WORD	RUT1D22,RUT5300,RUT3910,00000H
		WORD	RUT1D22,RUT1D22,RUT5500,RUT3911
;
		WORD	RUT1D22,RUT1D22,RUT5B00,RUT3910
		WORD	RUT1D22,RUT1D22,RUT5B00,RUT3911
;
ANAURD30_DT_SB	EQU	$
		WORD	00000H,RRR5311,RUT3910,00000H
		WORD	00000H,00000H, RRR5511,RUT3911
;
		WORD	00000H,00000H,RRR5B11,RUT3910
		WORD	00000H,00000H,RRR5B11,RUT3911
;
RRR5311 EQU	$
	WORD	UT5311
RRR5511 EQU	$
	WORD	UT5511
RRR5B11 EQU	$
	WORD	UT5B11
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	土 セット					+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
ANATUTI		EQU	$
		JSL	>RND_RND
		AND	#00007H
		ASL	A
		TAY
		LDX	FLOR_RNDDT,Y
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	トンネル内の左側 壁				+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANASAKLFT	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT1D00
		BNE	ANASAKLFT_990
		LDA	<NOWUNIT
		AND	#000FFH
		ASL	A
		TAY
		LDA	ANASAKLFT_DAT,Y
		TAY
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
ANASAKLFT_990	EQU	$
		RTS
;
ANASAKLFT_DAT	EQU	$
		WORD	RUT1D00,RUT1D07,RUT1D05,RUT1D2F,RUT1D31,RUT1D05,RUT1D30,RUT1D07	; 00-07
		WORD	RUT1D08,RUT1D00,	RUT1D10,RUT1D12,RUT1D00,RUT1D0E,RUT1D30	; 08-0F
		WORD	RUT1D10,RUT1D31,RUT1D12,RUT1D0E,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D2D,RUT1D07,RUT1D2B,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	トンネル内の右側 影付き壁			+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANASAKRIT	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT1D00
		BNE	ANASAKRIT_990
		LDA	<NOWUNIT
		AND	#000FFH
		ASL	A
		TAY
		LDA	ANASAKRIT_DAT,Y
		TAY
		LDA	0,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
ANASAKRIT_990	EQU	$
		RTS
		MEM8
		IDX8
;
ANASAKRIT_DAT	EQU	$
		WORD	RUT1D00,RUT1D04,RUT1D06,RUT1D2E,RUT1D04,RUT1D30,RUT1D06,RUT1D31	; 00-07
		WORD	RUT1D00,RUT1D09,	RUT1D0F,RUT1D11,RUT1D0D,RUT1D00,RUT1D0F	; 08-0F
		WORD	RUT1D30,RUT1D11,RUT1D31,RUT1D0D,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D0D,RUT1D11,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D00,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
;
;****************************************************************
;*								*
;*		赤 黄 緑 の台					*
;*								*
;****************************************************************
RED_YLW_GRN_DT	EQU	$
		WORD	UT1526,UT1527,UT1528,00000H
;;;;K;;;;		WORD	UT1529,UT152A,UT152B,00000H
;;;;K;;;;		WORD	UT152C,UT152D,UT152E
;
;
RED_YLW_GRN	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000
		LDA	<XSIZE
		BEQ	RED_YLW_GRN_20
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	RED_YLW_GRN_20
		INY
		INY
RED_YLW_GRN_20	EQU	$
;;;;K;;;;		TYA
;;;;K;;;;		ORA	<STUNTNO
;;;;K;;;;		TAY
		LDA	RED_YLW_GRN_DT,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		雪コース 氷のブロック				*
;*								*
;****************************************************************
SNOW_BLCK	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
		LDA	<YSIZE
		AND	#00001
		ASL	A
;;;;K;;;;		CLC
		ADC	<WORK0
		CLC
		ADC	#UT8900
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	地面 (トンネル) BG set					*
;*								*
;****************************************************************
GIMEN		EQU	$
		MI16			; memory , index 16bit mode
		JSR	ANATUTI		; 土 セット
;
		LDA	<XSIZE		;
		BNE	GIMEN_100	; 左上 セット ＯＫ ?
		LDA	<YSIZE		;	NO -> GIMEN_100
		BNE	GIMEN_100	;
		JSR	GIMEN_LU
;
GIMEN_100	EQU	$
		LDA	<XSIZE		; 左側 セット ＯＫ ?
		BNE	GIMEN_200	;	NO -> GIMEN_200
		JSR	GIMEN_LT
;
GIMEN_200	EQU	$
		LDA	<XSIZE		;
		BNE	GIMEN_300	; 左下 セット ＯＫ ?
		LDA	<YSIZE		;	NO -> GIMEN_300
		INC	A		;
		CMP	<YSIZECP	;
		BNE	GIMEN_300	;
		JSR	GIMEN_LD
;
GIMEN_300	EQU	$
		LDA	<YSIZE		; 上 セット ＯＫ ?
		BNE	GIMEN_400	;	NO -> GIMEN_400
		JSR	GIMEN_UP
;
GIMEN_400	EQU	$
		LDA	<YSIZE		;
		INC	A		; 下 セット ＯＫ ?
		CMP	<YSIZECP	;	NO -> GIMEN_500
		BNE	GIMEN_500	;
		JSR	GIMEN_DN
;
GIMEN_500	EQU	$
		LDA	<YSIZE		;
		BNE	GIMEN_600	; 右上 セット ＯＫ ?
		LDA	<XSIZE		;	NO -> GIMEN_600
		INC	A		;
		CMP	<XSIZECP	;
		BNE	GIMEN_600	;
		JSR	GIMEN_RU
;
GIMEN_600	EQU	$
		LDA	<XSIZE		;
		INC	A		; 右側 セット ＯＫ ?
		CMP	<XSIZECP	;	NO -> GIMEN_700
		BNE	GIMEN_700	;
		JSR	GIMEN_RT
;
GIMEN_700	EQU	$
		LDA	<XSIZE		;
		INC	A		; 右下 セット ＯＫ ?
		CMP	<XSIZECP	;	NO -> GIMEN_800
		BNE	GIMEN_800	;
		LDA	<YSIZE		;
		INC	A		;
		CMP	<YSIZECP	;
		BNE	GIMEN_800	;
		JSR	GIMEN_RD
;
GIMEN_800	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
LEFTUP_DAT	EQU	$		; left up check & set data
		WORD	RUT1D00,RUT1D01,RUT1D02,RUT1D03,RUT1D04,RUT1D05,RUT1D06,RUT1D07	; 00-07
		WORD	RUT1D08,RUT1D09,	RUT1D0B,RUT1D0C,RUT1D0D,RUT1D0E,RUT1D06	; 08-0F
		WORD	RUT1D10,RUT1D11,RUT1D12,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
LEFYDWN_DAT	EQU	$		; left down check & set data
		WORD	RUT1D00,RUT1D01,RUT1D02,RUT1D03,RUT1D04,RUT1D05,RUT1D06,RUT1D07	; 00-07
		WORD	RUT1D08,RUT1D09,	RUT1D0B,RUT1D0C,RUT1D0D,RUT1D0E,RUT1D0F	; 08-0F
		WORD	RUT1D10,RUT1D11,RUT1D12,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D01,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
ANASAKUP_DAT	EQU	$		; up check & set data
		WORD	RUT1D31,RUT1D01,RUT1D03,RUT1D03,RUT1D04,RUT1D2F,RUT1D2E,RUT1D07	; 00-07
		WORD	RUT1D07,RUT1D04,	RUT1D03,RUT1D0C,RUT1D11,RUT1D12,RUT1D2E	; 08-0F
		WORD	RUT1D2F,RUT1D11,RUT1D12,RUT1D0C,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D21,RUT1D21,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2C,RUT1D2C,RUT1D07,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
ANASAKDWN_DAT	EQU	$		; down check & set data
		WORD	RUT1D30,RUT1D03,RUT1D02,RUT1D03,RUT1D2E,RUT1D05,RUT1D06,RUT1D2F	; 00-07
		WORD	RUT1D05,RUT1D06,	RUT1D0B,RUT1D03,RUT1D0F,RUT1D10,RUT1D0F	; 08-0F
		WORD	RUT1D10,RUT1D2E,RUT1D2F,RUT1D0B,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D0B,RUT1D03,RUT1D0B,RUT1D0B,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D10,RUT1D2F,RUT1D10,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
RIGHTUP_DAT	EQU	$		; right up check & set data
		WORD	RUT1D00,RUT1D01,RUT1D02,RUT1D03,RUT1D04,RUT1D05,RUT1D06,RUT1D07	; 00-07
		WORD	RUT1D08,RUT1D09,	RUT1D02,RUT1D0C,RUT1D0D,RUT1D0E,RUT1D0F	; 08-0F
		WORD	RUT1D05,RUT1D11,RUT1D12,RUT1D13,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
RIGHTDWN_DAT	EQU	$		; right down check & set data
		WORD	RUT1D00,RUT1D01,RUT1D02,RUT1D03,RUT1D04,RUT1D05,RUT1D06,RUT1D07	; 00-07
		WORD	RUT1D08,RUT1D09,	RUT1D0B,RUT1D21,RUT1D0D,RUT1D2D,RUT1D0F	; 08-0F
		WORD	RUT1D10,RUT1D11,RUT1D07,RUT1D20,RUT1D14,	RUT1D16,RUT1D17	; 10-17
		WORD	RUT1D18,RUT1D19,RUT1D1A,RUT1D1B,RUT1D1C,RUT1D1D			; 18-1F
		WORD	RUT1D20,RUT1D21,RUT1D22,RUT1D23,RUT1D24,RUT1D25,RUT1D26,RUT1D27	; 20-27
		WORD	RUT1D28,RUT1D29,RUT1D2A,RUT1D2B,RUT1D2C,RUT1D2D,RUT1D2E,RUT1D2F	; 28-2F
		WORD	RUT1D30,RUT1D31							; 30-31
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左上 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_LU	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_LU_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	LEFTUP_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_LU_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_LT	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_LT_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	ANASAKLFT_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_LT_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左下 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_LD	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_LD_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	LEFYDWN_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_LD_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_UP	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_UP_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	ANASAKUP_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_UP_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_DN	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_DN_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	ANASAKDWN_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_DN_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右上 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_RU	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_RU_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	RIGHTUP_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_RU_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_RT	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_RT_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	ANASAKRIT_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_RT_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右下 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GIMEN_RD	EQU	$
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORK0
		TXA
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		ORA	<WORK0
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		TAY
		AND	#0FF00H
		CMP	RUT1D00
		BNE	GIMEN_RD_990
		TYA
		AND	#000FFH
		ASL	A
		TAY
		LDA	RIGHTDWN_DAT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
GIMEN_RD_990	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		フラワー コース (土だけ)			*
;*								*
;****************************************************************
FRWR_GIMEN	EQU	$
		MI16			; memory , index 16bit mode
		JSL	>RND_RND
		AND	#0003FH
		CMP	#0000BH
		BCC	FRWR_GMN_500
		LDA	#UT79E6
		BRA	FRWR_GMN_900
;
FRWR_GMN_500	EQU	$
		CLC
		ADC	#UT79C1
;
FRWR_GMN_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	BGコイン set						*
;*								*
;****************************************************************
BGCOIN_DAT	EQU	$
		WORD	UT6000,UT7400
;
;
BGCOIN		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		JSL	>BGCOIN_SETCHK
		BNE	BGCOIN_900
		LDA	<STUNTNO
		AND	#00002
		TAY
		LDA	BGCOIN_DAT,Y
		STA	>BGUNIT,X
BGCOIN_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	へこむ床 set						*
;*								*
;****************************************************************
HEKOMU		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDY	#00000H
		LDA	<XSIZE
		BEQ	HEKOMU_010
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	HEKOMU_010
		INY
		INY
HEKOMU_010	EQU	$
		LDA	<YSIZE
		BEQ	HEKOMU_100
		INC	A
		CMP	<YSIZECP
		BNE	HEKOMU_200
		BRA	HEKOMU_300
;
HEKOMU_100	EQU	$		; up line data set
		LDA	HEKOMU_DT1,Y
		BRA	HEKOMU_400
;
HEKOMU_200	EQU	$		; center line data set
		LDA	HEKOMU_DT2,Y
		BRA	HEKOMU_400
;
HEKOMU_300	EQU	$		; down line data set
		LDA	HEKOMU_DT3,Y
HEKOMU_400	EQU	$
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
HEKOMU_DT1	EQU	$
		WORD	UT6100,UT6101,UT6102
;
HEKOMU_DT2	EQU	$
		WORD	UT0193,UT0194,UT0195
;
HEKOMU_DT3	EQU	$
		WORD	UT6106,UT6107,UT6108
;
;
;****************************************************************
;*								*
;*	ゴム床 BG set						*
;*								*
;****************************************************************
GOMU		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDY	#UT6400
		LDA	<XSIZE
		BEQ	GOMU_100
		INY
		INC	A
		CMP	<XSIZECP
		BNE	GOMU_100
		INY
GOMU_100	EQU	$
		TYA
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	ゴール床 BG set						*
;*								*
;****************************************************************
GOALYUKA	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	GOALYUKA_000
		LDA	<XSIZE
		BNE	GOALYUKA_900
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	RUT2A00		; 左側 草 ?
		BEQ	GOALYUKA_005	;	NO -> GOALYUKA_900
		CMP	RUT2A01
		BNE	GOALYUKA_900
GOALYUKA_005	EQU	$
		LDA	RUT3B01		; 草 左端 セット
		BRA	GOALYUKA_300
;
GOALYUKA_000	EQU	$
		LDY	#00000H
		LDA	<XSIZE
		BEQ	GOALYUKA_100
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	GOALYUKA_100
		INY
		INY
;
GOALYUKA_100	EQU	$
		LDA	<YSIZE
		CMP	#00001H
		BNE	GOALYUKA_200
		LDA	<XSIZE
		BNE	GOALYUKA_150
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	RUT3912
		BEQ	GOALYUKA_130
		CMP	RUT3913
		BEQ	GOALYUKA_130
		CMP	RUT3921
		BEQ	GOALYUKA_130
		CMP	RUT392B
		BNE	GOALYUKA_150
GOALYUKA_130	EQU	$
		LDA	RUT3936
		BRA	GOALYUKA_300
GOALYUKA_150	EQU	$
		LDA	GOALYUKA_DT0,Y
		BRA	GOALYUKA_300
;
GOALYUKA_200	EQU	$
		LDA	GOALYUKA_DT1,Y
;
GOALYUKA_300	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
GOALYUKA_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
GOALYUKA_DT0	EQU	$
		WORD	UT0196,UT0197,UT0198
;
GOALYUKA_DT1	EQU	$
		WORD	UT0199,UT019A,UT019B
;
;
;****************************************************************
;*								*
;*	壁コース ブロック BG set				*
;*								*
;****************************************************************
KABEBLOCK	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	#UT0192
		STA	>BGUNIT,X
;
		JMP	KABEYUKA_R900
;
;
;****************************************************************
;*								*
;*	草コース とげ杭 BG set					*
;*								*
;****************************************************************
TOGEBOWSET	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<YSIZE
		BEQ	TOGEBOWSET_50
		INY
		INY
		INC	A
		CMP	<YSIZECP
		BNE	TOGEBOWSET_50
		INY
		INY
;
TOGEBOWSET_50	EQU	$
		LDX	<UNITPOS
		LDA	TOGEBOWSET_DT,Y
		TAY
		LDA	0,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
TOGEBOWSET_DT	EQU	$
		WORD	RUT6C00,RUT6B01,RUT6B02
;
;
;****************************************************************
;*								*
;*		カラフル ブロック セット			*
;*								*
;****************************************************************
COLRBLK		EQU	$
		MI16			; memory , index 16bit mode
		JSL	>RND_RND	; ランダム
		AND	#00007H
		ASL	A
		TAY
		LDA	<STUNTNO
		AND	#000FFH
		CMP	#0008BH
		BNE	COLRBLK_PAS
		LDY	#00010H
COLRBLK_PAS	EQU	$
		LDX	<UNITPOS
		LDA	COLRBLK_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
COLRBLK_DAT	EQU	$
		WORD	UT01B0,UT01B1,UT01B2,UT01B3
		WORD	UT01B4,UT01B5,UT01B6,UT01B7
		WORD	UT7300
;
;
;****************************************************************
;*								*
;*		垂直に伸びる つる セット			*
;*								*
;****************************************************************
TATTURU		EQU	$
		LDX	#000H
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	TATTURU_000
		LDX	#002H
TATTURU_000	EQU	$
		JSR	(TATTURU_SET,X)
		RTL
;
TATTURU_SET	EQU	$
		WORD	TATTURU_100,TATTURU_200
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	垂直に伸びる つる つるの茎			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TATTURU_100	EQU	$
		MI16			; memory , index 16bit mode
		JSL	>RND_RND	; ランダム
		AND	#00003H
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	TATTURU_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTS
;
TATTURU_DAT	EQU	$
		WORD	UT3D46,UT3D47,UT3D56,UT3D57
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	垂直に伸びる つるの茎				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TATTURU_200	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	TATTURU_210
		CMP	RUT2A01
		BNE	TATTURU_100
TATTURU_210	EQU	$
		LDX	<UNITPOS
		LDA	#UT3D58
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTS
;
;
;****************************************************************
;*								*
;*		草の上の雑草 セット				*
;*								*
;****************************************************************
ZASSOU1		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#ZASSOU1_DAT
		STA	<WORK0
		JSR	ZASSOU_SUB
		MI8			; memory , index 8bit mode
		RTL
;
ZASSOU1_DAT	EQU	$
		WORD	UT3D40,UT3D41
		WORD	UT3D50,UT3D51
;
;
;****************************************************************
;*								*
;*		草の下の雑草 セット				*
;*								*
;****************************************************************
ZASSOU2		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#ZASSOU2_DAT
		STA	<WORK0
		JSR	ZASSOU_SUB
		MI8			; memory , index 8bit mode
		RTL
;
ZASSOU2_DAT	EQU	$
		WORD	UT014C,UT014D
		WORD	UT014E,UT014F
;
;
;****************************************************************
;*								*
;*		土の中の雑草 セット				*
;*								*
;****************************************************************
ZASSOU3		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#ZASSOU3_DAT
		STA	<WORK0
		JSR	ZASSOU_SUB
		MI8			; memory , index 8bit mode
		RTL
;
ZASSOU3_DAT	EQU	$
		WORD	UT3D44,UT3D45
		WORD	UT3D54,UT3D55
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		雑草 セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
ZASSOU_SUB	EQU	$
		M8			; memory 8bit mode
		LDA	<XSIZE
		AND	#001H
		STA	<WORK2
		LDA	<YSIZE
		ASL	A
		ORA	<WORK2
		ASL	A
		M16			; memory 16bit mode
		AND	#000FFH
		TAY
		LDX	<UNITPOS
		LDA	(<WORK0),Y
		STA	>BGUNIT,X
		RTS
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		つる 両側に付いている大草 セット		*
;*								*
;****************************************************************
TURUKUS		EQU	$
		MI16			; memory , index 16bit mode
		LDY	<XSIZE
		LDA	<YSIZE
		AND	#00001H
		BEQ	TURUKUS_000
		INY
		INY
		INY
TURUKUS_000	EQU	$
		TYA
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	TURUKUS_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
TURUKUS_DAT	EQU	$
		WORD	UT3D4D,UT3D4E,UT3D4F
		WORD	UT3D5D,UT3D5E,UT3D5F
;
;
;****************************************************************
;*								*
;*		つる 両側に付いている小草 セット		*
;*								*
;****************************************************************
TURUKUSS	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	TURUKUSS_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
TURUKUSS_DAT	EQU	$
		WORD	UT3D60,UT3D61,UT3D62
;
;
;****************************************************************
;*								*
;*		つる 両側に付いている左草 セット		*
;*								*
;****************************************************************
TURUKUSL	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	TURUKUSL_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
TURUKUSL_DAT	EQU	$
		WORD	UT3D60,UT3D64
;
;
;****************************************************************
;*								*
;*		つる 両側に付いている右草 セット		*
;*								*
;****************************************************************
TURUKUSR	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	TURUKUSR_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
TURUKUSR_DAT	EQU	$
		WORD	UT3D63,UT3D62
;
;
;****************************************************************
;*								*
;*		つる 両側に付いている中草 セット		*
;*								*
;****************************************************************
TURUKUSC	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	#UT3D65
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		斜めつる セット					*
;*								*
;****************************************************************
NANAMTURU	EQU	$
		LDA	#LOW NANAMTURU_DAT
		STA	<WORK0
		LDA	#HIGH NANAMTURU_DAT
		STA	<WORK1
		JSR	NANAME_SUB	; 斜め セット
		RTL
;
NANAMTURU_DAT	EQU	$
		WORD	UT3D49,UT3D48	; 右下がりデータ
		WORD	UT3D4A,UT3D4B	; 左下がりデータ
;
;
;****************************************************************
;*								*
;*		横棒階段セット					*
;*								*
;****************************************************************
KAIDAN		EQU	$
		LDA	#LOW KAIDAN_DAT
		STA	<WORK0
		LDA	#HIGH KAIDAN_DAT
		STA	<WORK1
		JSR	NANAME_SUB	; 斜め セット
		RTL
;
KAIDAN_DAT	EQU	$
		WORD	UT3D67,UT6700
		WORD	UT3D66,UT6600
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		斜め セット				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
NANAME_SUB	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CLC
		ROR	A
		ROR	A
		STA	<LKFLG		; Y point down flag ON & OFF
		LDA	<XSIZE		; start data set ?
		BNE	NANAMTURU_000	;	NO -> NANAMTURU_000
		STZ	<LKFLG
		LDA	<YSIZE
		BNE	NANAMTURU_900
		LDY	#00001H
		LDA	<XSIZECP
		BPL	NANAMTURU_150
		LDY	#00003H
		BRA	NANAMTURU_150
NANAMTURU_000	EQU	$
		BPL	NANAMTURU_010
		DEC	A
		BRA	NANAMTURU_020
NANAMTURU_010	EQU	$
		INC	A
NANAMTURU_020	EQU	$
		CMP	<XSIZECP
		BNE	NANAMTURU_100
		LDA	<YSIZE
		BNE	NANAMTURU_900
;
NANAMTURU_100	EQU	$		; data set !!
		LDA	<YSIZE
		TAY
		LDA	<XSIZECP
		BPL	NANAMTURU_150
		INY
		INY
NANAMTURU_150	EQU	$
		TYA
		ASL	A
		TAY
;;;;K;;;;		LDA	NANAMTURU_DAT,Y
		LDA	(<WORK0),Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
NANAMTURU_900	EQU	$
		MI8			; memory , index 8bit mode
		RTS
;
;
;****************************************************************
;*								*
;*		地下カベ セット					*
;*								*
;****************************************************************
KABE1		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		AND	#00001H
		ASL	A
		TAY
		LDA	<NOWUNIT
		STA	<WORK0
		LDX	#00000H
		LDA	<YSIZE
		BEQ	KABE1_100
		LDX	#00006H
		INC	A
		CMP	<YSIZECP
		BNE	KABE1_100
		LDX	#0000CH
KABE1_100	EQU	$
		LDA	<XSIZE
		BEQ	KABE1_500
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	KABE1_500
		INX
		INX
		BRA	KABE1_500
;
KABE1_500	EQU	$
		JSR	(KABE1_SET,X)
;
		TXA
		BMI	KABE1_900
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
KABE1_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABE1_SET	EQU	$
		WORD	KABE1_SB1,KABE1_SB2,KABE1_SB3	; 上
		WORD	KABE1_SB4,KABE1_SB5,KABE1_SB6	; 中
		WORD	KABE1_SB7,KABE1_SB8,KABE1_SB9	; 下
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左上ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB1	EQU	$
		LDA	<WORK0
		CMP	RUT6803
		BEQ	KABE1_SB1_10
		CMP	RUT6811
		BNE	KABE1_SB1_50
KABE1_SB1_10	EQU	$
		LDX	#RUT680A
		BRA	KABE1_SB1_90
KABE1_SB1_50	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB	; down point check
		LDA	>BGUNIT,X
		CMP	RUT6809
		BNE	KABE1_SB1_80
		LDX	#0FFFFH
		BRA	KABE1_SB1_90
KABE1_SB1_80	EQU	$
		LDX	#RUT6812
KABE1_SB1_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		中上ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB2	EQU	$
		LDX	#RUT6812
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右上ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB3	EQU	$
		LDA	<WORK0
		CMP	RUT6800
		BEQ	KABE1_SB3_10
		CMP	RUT6810
		BNE	KABE1_SB3_50
KABE1_SB3_10	EQU	$
		LDX	#RUT6809
		BRA	KABE1_SB3_90
KABE1_SB3_50	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB	; down point check
		LDA	>BGUNIT,X
		CMP	RUT680A
		BNE	KABE1_SB3_80
		LDX	#0FFFFH
		BRA	KABE1_SB3_90
KABE1_SB3_80	EQU	$
		LDX	#RUT6812
KABE1_SB3_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB4	EQU	$
		LDX	KABE1_SB4_DT,Y
		LDA	<WORK0
		CMP	RUT6801
		BEQ	KABE1_SB5
		CMP	RUT6802
		BEQ	KABE1_SB5
		CMP	RUT6803
		BEQ	KABE1_SB5
		CMP	RUT6811
		BEQ	KABE1_SB5
		CMP	RUT6809
		BEQ	KABE1_SB4_00
		CMP	RUT680A
		BEQ	KABE1_SB4_00
		CMP	RUT680D
		BEQ	KABE1_SB4_00
		CMP	RUT680C
		BEQ	KABE1_SB4_90
		CMP	RUT6812
		BNE	KABE1_SB4_90
		LDX	#RUT6809
		BRA	KABE1_SB4_90
KABE1_SB4_00	EQU	$
		LDX	#0FFFFH
KABE1_SB4_90	EQU	$
		RTS
;
KABE1_SB4_DT	EQU	$
		WORD	RUT6800,RUT6810
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		内側ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB5	EQU	$
		LDX	KABE1_SB5_DT,Y
		RTS
;
KABE1_SB5_DT	EQU	$
		WORD	RUT6801,RUT6802
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB6	EQU	$
		LDX	KABE1_SB6_DT,Y
		LDA	<WORK0
		CMP	RUT6800
		BEQ	KABE1_SB5
		CMP	RUT6801
		BEQ	KABE1_SB5
		CMP	RUT6802
		BEQ	KABE1_SB5
		CMP	RUT6810
		BEQ	KABE1_SB5
		CMP	RUT6809
		BEQ	KABE1_SB5_00
		CMP	RUT680A
		BEQ	KABE1_SB5_00
		CMP	RUT680E
		BEQ	KABE1_SB5_00
		CMP	RUT680F
		BEQ	KABE1_SB5_90
		CMP	RUT6812
		BNE	KABE1_SB5_90
		LDX	#RUT680A
		BRA	KABE1_SB5_90
KABE1_SB5_00	EQU	$
		LDX	#0FFFFH
KABE1_SB5_90	EQU	$
		RTS
;
KABE1_SB6_DT	EQU	$
		WORD	RUT6803,RUT6811
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左下ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB7	EQU	$
		LDX	#RUT6804
		LDA	<WORK0
		CMP	RUT6805
		BEQ	KABE1_SB8
		CMP	RUT6806
		BEQ	KABE1_SB8
		CMP	RUT6807
		BEQ	KABE1_SB8
		CMP	RUT6803
		BEQ	KABE1_SB7_80
		CMP	RUT6811
		BEQ	KABE1_SB7_80
		CMP	RUT680C
		BNE	KABE1_SB7_90
		LDX	#0FFFFH
		BRA	KABE1_SB7_90
KABE1_SB7_80	EQU	$
		LDX	#RUT680E
KABE1_SB7_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		中下ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB8	EQU	$
		LDX	KABE1_SB8_DT,Y
		LDA	<WORK0
		CMP	#UT0000
		BNE	KABE1_SB8_90
		LDX	#RUT6813
KABE1_SB8_90	EQU	$
		RTS
;
KABE1_SB8_DT	EQU	$
		WORD	RUT6805,RUT6806
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右下ユニットセット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE1_SB9	EQU	$
		LDX	#RUT6807
		LDA	<WORK0
		CMP	RUT6804
		BEQ	KABE1_SB8
		CMP	RUT6805
		BEQ	KABE1_SB8
		CMP	RUT6806
		BEQ	KABE1_SB8
		CMP	RUT6800
		BEQ	KABE1_SB9_80
		CMP	RUT6810
		BEQ	KABE1_SB9_80
		CMP	RUT680F
		BNE	KABE1_SB9_90
		LDX	#0FFFFH
		BRA	KABE1_SB9_90
KABE1_SB9_80	EQU	$
		LDX	#RUT680D
KABE1_SB9_90	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		地下斜めカベ セット				*
;*								*
;****************************************************************
KABE2		EQU	$
		LDA	#001H
		STA	<LKFLG
		MI16			; memory , index 16bit mode
		LDY	#0FFFFH
		LDX	#KABE2_DT0
		LDA	<XSIZECP	; 左斜め下ユニットセット?
		BMI	KABE2_000	;	YES -> KABE2_000
		LDY	#00001H
		LDX	#KABE2_DT1
KABE2_000	EQU	$
		STX	<WORK0
		STY	<WORK2
;
		LDX	#00000H
		LDA	<YSIZE
		BEQ	KABE2_050
		INX
		INX
		CMP	#00001H
		BEQ	KABE2_050
		INX
		INX
		INC	A
		CMP	YSIZECP
		BNE	KABE2_050
		INX
		INX
;
KABE2_050	EQU	$
		JSR	(KABE2_2ADR,X)
;
		TYA
		BMI	KABE2_090
		LDA	(<WORK0),Y
		TAY
		LDA	0,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
KABE2_090	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABE2_2ADR	EQU	$
		WORD	KABE2_100	; 上 ユニットセット チェック
		WORD	KABE2_200	; 二番 ユニットセット チェック
		WORD	KABE2_300	; 中 ユニットセット チェック
		WORD	KABE2_400	; 下 ユニットセット チェック
;
KABE2_DT0	EQU	$		; 左ユニットデータ
		WORD	RUT6808,RUT6809 ; 上
		WORD	RUT6800,RUT6810 ; 左側
		WORD	RUT6801,RUT6802 ; 中
		WORD	RUT6805,RUT6806 ; 下
		WORD	RUT6804		; 左下(草付き)
;
KABE2_DT1	EQU	$		; 右ユニットデータ
		WORD	RUT680B,RUT680A ; 上
		WORD	RUT6803,RUT6811 ; 右側
		WORD	RUT6801,RUT6802 ; 中
		WORD	RUT6805,RUT6806 ; 下
		WORD	RUT6807		; 右下(草付き)
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		一番上 ユニットセット チェック		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE2_100	EQU	$
		LDY	#00000H
		LDA	<NOWUNIT
		CMP	RUT6812
		BEQ	KABE2_190
		AND	#0FF00H
		CMP	RUT6800
		BNE	KABE2_190
		DEY
KABE2_190	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		二番上 ユニットセット チェック		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE2_200	EQU	$
		LDY	#00002H
		LDA	<XSIZE
		CLC
		ADC	<WORK2
		CMP	<XSIZECP	; カベの横側 ?
		BNE	KABE2_250	;	NO -> KABE2_250
		LDA	<NOWUNIT
		CMP	RUT6812
		BEQ	KABE2_290
		LDY	#00006H
KABE2_250	EQU	$
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	KABE2_280
		CMP	RUT2A01
		BEQ	KABE2_280
		CMP	RUT6804
		BEQ	KABE2_280
		CMP	RUT6807
		BEQ	KABE2_280
		CMP	RUT6801
		BEQ	KABE2_270
		CMP	RUT6802
		BEQ	KABE2_270
		CMP	RUT6809
		BEQ	KABE2_270
		CMP	RUT680A
		BNE	KABE2_290
KABE2_270	EQU	$
		LDY	#0FFFFH
		BRA	KABE2_290
KABE2_280	EQU	$
		LDY	#00010H
KABE2_290	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		中 ユニットセット チェック		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE2_300	EQU	$
		LDA	<XSIZE
		AND	#00001H
		ASL	A
		ADC	#00008H
		TAY
		LDA	<XSIZE
		CLC
		ADC	<WORK2
		CMP	<XSIZECP	; カベの横側 ?
		BNE	KABE2_390	;	NO -> KABE2_390
		LDA	<NOWUNIT
		CMP	RUT6800
		BEQ	KABE2_390
		CMP	RUT6810
		BEQ	KABE2_390
		CMP	RUT6803
		BEQ	KABE2_390
		CMP	RUT6811
		BEQ	KABE2_390
		CMP	RUT6801
		BEQ	KABE2_390
		CMP	RUT6802
		BEQ	KABE2_390
		CMP	RUT6809
		BEQ	KABE2_350
		CMP	RUT680A
		BEQ	KABE2_350
		CMP	RUT6812
		BNE	KABE2_380
		LDY	#00002H
		BRA	KABE2_390
KABE2_350	EQU	$
		LDY	#0FFFFH
		BRA	KABE2_390
KABE2_380	EQU	$
		DEY
		DEY
		DEY
		DEY
KABE2_390	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下 ユニットセット チェック		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABE2_400	EQU	$
		LDA	<XSIZE
		AND	#00001H
		ASL	A
		ADC	#0000CH
		TAY
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	KABE2_450
		CMP	RUT2A01
		BEQ	KABE2_450
		CMP	RUT6804
		BEQ	KABE2_450
		CMP	RUT6805
		BEQ	KABE2_450
		CMP	RUT6806
		BEQ	KABE2_450
		CMP	RUT6807
		BEQ	KABE2_450
KABE2_430	EQU	$
		DEY
		DEY
		DEY
		DEY
KABE2_450	EQU	$
		LDA	<XSIZE
		CLC
		ADC	<WORK2
		CMP	<XSIZECP	; カベの横側 ?
		BNE	KABE2_490	;	NO -> KABE2_490
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	KABE2_480
		CMP	RUT2A01
		BEQ	KABE2_480
		AND	#0FF00H
		CMP	RUT6800
		BEQ	KABE2_490
		LDY	#00006H
		BRA	KABE2_490
KABE2_480	EQU	$
		LDY	#00010H
KABE2_490	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		地下斜め上カベ セット				*
;*								*
;****************************************************************
KABE3		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	KABE3_000
		LDA	<XSIZE
		BEQ	KABE3_000
		DEC	<YSIZECP
KABE3_000	EQU	$
		LDA	#KABE3_DT0
		LDX	<XSIZECP
		BMI	KABE3_050
		LDA	#KABE3_DT1
KABE3_050	EQU	$
		STA	<WORK0
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP	; Ｙ軸の一番下か ?
		BEQ	KABE3_100	;	YES -> KABE3_100
		INC	A
		CMP	<YSIZECP	; Ｙ軸の下から二番目か ?
		BNE	KABE3_200	;	NO -> KABE3_200
		LDY	#00002H
		BRA	KABE3_900
;
KABE3_100	EQU	$
		LDA	<NOWUNIT
		CMP	RUT6804
		BEQ	KABE3_130
		CMP	RUT6807
		BEQ	KABE3_130
		AND	#0FF00H
		CMP	RUT6800
		BEQ	KABE3_950
KABE3_130	EQU	$
		LDY	#00000H
		BRA	KABE3_900
;
KABE3_200	EQU	$
		LDA	<YSIZE
		AND	#00001H
		INC	A
		INC	A
		ASL	A
		STA	<WORK2
		LDA	<XSIZE
		AND	#00001H
		ASL	A
		EOR	<WORK2
		TAY
;
KABE3_900	EQU	$
		LDA	(<WORK0),Y
		TAX
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
KABE3_950	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABE3_DT0	EQU	$		; 左ユニットデータ
		WORD	RUT680C,RUT680D
		WORD	RUT6801,RUT6802
;
KABE3_DT1	EQU	$		; 右ユニットデータ
		WORD	RUT680F,RUT680E
		WORD	RUT6801,RUT6802
;
;
;****************************************************************
;*								*
;*		カベ乗れる半当たり草 セット			*
;*								*
;****************************************************************
KABEKS		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#KABEKS_DT0
		STA	<WORK0
		LDA	<NOWUNIT
		CMP	RUT6801
		BEQ	KABEKS_0005
		CMP	RUT6802
		BNE	KABEKS_000
KABEKS_0005	EQU	$
		LDA	#KABEKS_DT1
		STA	<WORK0
;
KABEKS_000	EQU	$
		LDY	#00000H
		LDA	<XSIZE
		BEQ	KABEKS_100
		AND	#00001H
		EOR	#00001H
		INC	A
		ASL	A
		TAY
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	KABEKS_100
		LDY	#00006H
;
KABEKS_100	EQU	$
		LDA	<YSIZE
		BEQ	KABEKS_200
		TYA
		ORA	#00008H
		TAY
;
KABEKS_200	EQU	$
		LDA	<NOWUNIT
		CMP	RUT6800
		BEQ	KABEKS_250
		CMP	RUT6810
		BEQ	KABEKS_250
		CMP	RUT6803
		BEQ	KABEKS_250
		CMP	RUT6811
		BNE	KABEKS_300
KABEKS_250	EQU	$
		TYA
		ORA	#00010H
		TAY
;
KABEKS_300	EQU	$
		LDA	(<WORK0),Y
		TAY
		LDX	<UNITPOS
		LDA	0,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
KABEKS_DT0	EQU	$
		WORD	RUT6A00,RUT6A01,RUT6A02,RUT6A03
		WORD	RUT3803,RUT3805,RUT3806,RUT3808
		WORD	RUT6A04,RUT6A04,RUT6A05,RUT6A05
		WORD	RUT3804,RUT3805,RUT3806,RUT3807
;
KABEKS_DT1	EQU	$
		WORD	RUT6A06,RUT6A07,RUT6A08,RUT6A09
		WORD	RUT3803,RUT3805,RUT3806,RUT3808
		WORD	RUT6A04,RUT6A04,RUT6A05,RUT6A05
		WORD	RUT3804,RUT3805,RUT3806,RUT3807
;
;
;****************************************************************
;*								*
;*		ついたて ＆ トンネル内 の穴あけ			*
;*								*
;****************************************************************
KABEANA		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<NOWUNIT
		CMP	#UT0000
		BEQ	KABEANA_090
		AND	#0FF00H
		CMP	RUT1D00
		BNE	KABEANA_010
		JSR	KABEANA_500
		BRA	KABEANA_090
KABEANA_010	EQU	$
		CMP	RUT6800
		BNE	KABEANA_090
;
		LDA	<NOWUNIT
		AND	#000FFH
		ASL	A
		TAY
;
		LDX	#00000H
		LDA	<YSIZE
		BEQ	KABEANA_030
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BNE	KABEANA_030
		INX
		INX
;
KABEANA_030	EQU	$
		LDA	<XSIZE
		BEQ	KABEANA_050
		INX
		INX
		INX
		INX
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	KABEANA_050
		INX
		INX
		INX
		INX
		INX
		INX
;
KABEANA_050	EQU	$
		LDA	KABEANA_ADR,X
		STA	<WORK0
		LDA	(<WORK0),Y
		TAY
		LDA	0,Y
		BMI	KABEANA_090
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
KABEANA_090	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KABEANA_ADR	EQU	$
		WORD	KABEANA_1DT,KABEANA_2DT,KABEANA_3DT
		WORD	KABEANA_4DT,KABEANA_5DT,KABEANA_6DT
		WORD	KABEANA_7DT,KABEANA_8DT,KABEANA_9DT
;
KABEANA_1DT	EQU	$				; 左上
		WORD	RUT680C,RUT680E,RUT680E,RUT6803
		WORD	PSRUT68,PSRUT68,PSRUT68,PSRUT68
		WORD	PSRUT68,PSRUT68,RUT6811,PSRUT68
		WORD	PSRUT68,RUT6813,RUT680E,PSRUT68
		WORD	RUT680C,RUT6811,RUT680B,RUT6813
;
KABEANA_2DT	EQU	$				; 左側
		WORD	NKRUT68,RUT6803,RUT6811,RUT6803
		WORD	RUT2A00,RUT6807,RUT6807,RUT2A01
		WORD	NKRUT68,RUT680B,RUT6811,NKRUT68
		WORD	NKRUT68,RUT680F,RUT6803,PSRUT68
		WORD	NKRUT68,RUT6811,RUT680B,RUT680F
;
KABEANA_3DT	EQU	$				; 左下
		WORD	RUT6808,RUT680A,RUT680A,RUT6803
		WORD	RUT2A00,RUT6807,RUT6807,RUT2A01
		WORD	RUT680A,RUT6812,RUT680A,RUT680A
		WORD	NKRUT68,NKRUT68,RUT6811,PSRUT68
		WORD	RUT6808,RUT6811,PSRUT68,RUT680F
;
KABEANA_4DT	EQU	$				; 中上
		WORD	RUT680C,RUT6813,RUT6813,RUT680F
		WORD	PSRUT68,PSRUT68,PSRUT68,PSRUT68
		WORD	NKRUT68,RUT680C,RUT680F,NKRUT68
		WORD	PSRUT68,RUT6813,RUT6813,PSRUT68
		WORD	RUT680C,RUT680F,NKRUT68,RUT6813
;
KABEANA_5DT	EQU	$				; 中
		WORD	NKRUT68,NKRUT68,NKRUT68,NKRUT68
		WORD	RUT2A00,RUT2A01,RUT2A00,RUT2A01
		WORD	NKRUT68,NKRUT68,NKRUT68,NKRUT68
		WORD	NKRUT68,NKRUT68,NKRUT68,NKRUT68
		WORD	NKRUT68,NKRUT68,NKRUT68,NKRUT68
;
KABEANA_6DT	EQU	$				; 中下
		WORD	RUT6808,RUT6812,RUT6812,RUT680B
		WORD	RUT2A00,RUT2A01,RUT2A00,RUT2A01
		WORD	NKRUT68,RUT6812,RUT6812,NKRUT68
		WORD	NKRUT68,RUT6808,RUT680B,NKRUT68
		WORD	RUT6808,RUT680B,RUT6812,NKRUT68
;
KABEANA_7DT	EQU	$				; 右上
		WORD	RUT6800,RUT680D,RUT680D,RUT680E
		WORD	PSRUT68,PSRUT68,PSRUT68,PSRUT68
		WORD	PSRUT68,RUT6800,NKRUT68,NKRUT68
		WORD	PSRUT68,RUT680D,RUT6813,PSRUT68
		WORD	RUT6810,RUT680E,RUT6808,RUT6813
;;;;K;;;;		WORD	RUT6810,RUT680E,NKRUT68,RUT6813
;
KABEANA_8DT	EQU	$				; 右側
		WORD	RUT6800,RUT6800,RUT6810,NKRUT68
		WORD	RUT2A00,RUT6804,RUT6804,RUT2A01
		WORD	NKRUT68,RUT6810,RUT6808,NKRUT68
		WORD	PSRUT68,RUT6800,RUT680C,NKRUT68
		WORD	RUT6810,NKRUT68,RUT6808,RUT680C
;
KABEANA_9DT	EQU	$				; 右下
		WORD	RUT6800,RUT6809,RUT6809,RUT680B
		WORD	RUT2A00,RUT6804,RUT6804,RUT2A01
		WORD	PSRUT68,RUT6809,RUT6812,PSRUT68
		WORD	RUT680C,RUT6810,PSRUT68,NKRUT68
		WORD	RUT6810,RUT6811,RUT6812,PSRUT68
;
PSRUT68		EQU	$
		WORD	0FFFFH
;
NKRUT68		EQU	$
		WORD	UT0000
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+		トンネル内の 穴あけ			+
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KABEANA_5_DT0	EQU	$
		WORD	RUT680E,RUT6813,RUT680D
		WORD	RUT6811,NKRUT68,RUT6810
		WORD	RUT680A,RUT6812,RUT6809
;
KABEANA_5_DT1	EQU	$
		WORD	RUT680C,RUT6813,RUT680F
		WORD	NKRUT68,NKRUT68,NKRUT68
		WORD	RUT6808,RUT6812,RUT680B
;
;
KABEANA_500	EQU	$
		LDY	#00000H
		LDA	<XSIZE
		BEQ	KABEANA_520
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	KABEANA_520
		INY
		INY
KABEANA_520	EQU	$
		LDX	<YSIZE
		BEQ	KABEANA_540
		TYA
		CLC
		ADC	#00006
		TAY
		INX
		CPX	<YSIZECP
		BNE	KABEANA_540
		TYA
		CLC
		ADC	#00006
		TAY
KABEANA_540	EQU	$
		LDA	<NOWUNIT
		CMP	RUT1D18
		BEQ	KABEANA_560
		CMP	RUT1D19
		BNE	KABEANA_580
KABEANA_560	EQU	$
		LDA	KABEANA_5_DT1,Y
		BRA	KABEANA_590
KABEANA_580	EQU	$
		LDA	KABEANA_5_DT0,Y
KABEANA_590	EQU	$
		TAY
		LDA	0,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	ついたて ＆ トンネル内 の斜め穴あけ			*
;*				上				*
;****************************************************************
KBNANAUP	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	KBNANAUP_000
		LDA	<XSIZE
		BEQ	KBNANAUP_000
		DEC	<YSIZECP
;
KBNANAUP_000	EQU	$
		LDX	#00000H
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BEQ	KBNANAUP_010
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BEQ	KBNANAUP_010
		INX
		INX
KBNANAUP_010	EQU	$
		JSR	(KBNANAUP_ADR,X)
;
		TYA
		BMI	KBNANAUP_090
		LDX	<UNITPOS
		STA	>BGUNIT,X
KBNANAUP_090	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KBNANAUP_ADR	EQU	$
		WORD	KBNANAUP_100	; 一番下
		WORD	KBNANAUP_200	; 下から二番目
		WORD	KBNANAUP_300	; 中
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		一番下					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBNANAUP_100	EQU	$
		LDY	RUT680F
		LDA	<XSIZECP
		BPL	KBNANAUP_150
		LDY	RUT680C
KBNANAUP_150	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT6800
		BNE	KBNANAUP_190
		LDY	#0FFFFH
KBNANAUP_190	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下から二番目				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBNANAUP_200	EQU	$
		LDY	RUT680E
		LDA	<XSIZECP
		BPL	KBNANAUP_250
		LDY	RUT680D
KBNANAUP_250	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		中					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBNANAUP_300	EQU	$
		LDA	<NOWUNIT
		CMP	#UT0000
		BEQ	KBNANAUP_310
		AND	#0FF00H
		CMP	RUT6800
		BEQ	KBNANAUP_310
		LDY	#0FFFFH
		BRA	KBNANAUP_390
KBNANAUP_310	EQU	$
		LDA	<XSIZE
		AND	#00001H
		ASL	A
		TAY
		LDX	KBNANAUP_3DT,Y
		LDA	0,X
		TAY
KBNANAUP_390	EQU	$
		RTS
;
KBNANAUP_3DT	EQU	$
		WORD	RUT6801,RUT6802
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	ついたて ＆ トンネル内 の斜め穴あけ			*
;*				下				*
;****************************************************************
KBNANADWN	EQU	$
		LDA	#001H
		STA	<LKFLG
		MI16			; memory , index 16bit mode
;
		LDX	#00000H
		LDA	<YSIZE
		BEQ	KBNANADWN_050
		INX
		INX
		CMP	#00001H
		BEQ	KBNANADWN_050
		INX
		INX
;
KBNANADWN_050	EQU	$
		JSR	(KBNANADWN_ADR,X)
;
		TYA
		BMI	KBNANADWN_090
		LDX	<UNITPOS
		STA	>BGUNIT,X
KBNANADWN_090	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
KBNANADWN_ADR	EQU	$
		WORD	KBNANADWN_100	; 一番上
		WORD	KBNANADWN_200	; 上から二番目
		WORD	KBNANAUP_300	; 中
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		一番上					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBNANADWN_100	EQU	$
		LDY	RUT680B
		LDA	<XSIZECP
		BPL	KBNANADWN_150
		LDY	RUT6808
KBNANADWN_150	EQU	$
		LDA	<NOWUNIT
		AND	#0FF00H
		CMP	RUT6800
		BNE	KBNANADWN_190
		LDY	#0FFFFH
KBNANADWN_190	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上から二番目				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBNANADWN_200	EQU	$
		LDY	RUT680A
		LDA	<XSIZECP
		BPL	KBNANADWN_250
		LDY	RUT6809
KBNANADWN_250	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		スペシャル コイン				*
;*								*
;****************************************************************
BLUECOIN	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		JSL	>BGCOIN_SETCHK	; ユニット セット チェック
		BNE	BLUECOIN_990
		LDA	<STUNTNO
		AND	#00001
		BEQ	BLUECOIN_500
		LDA	<XSIZE
		AND	#00001
		BNE	BLUECOIN_990
;
BLUECOIN_500	EQU	$
		LDX	<UNITPOS
		LDA	#UTA400
		STA	>BGUNIT,X
BLUECOIN_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		スペシャル コイン				*
;*					(斜め)			*
;****************************************************************
BLUECOIN_NNM_SB	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		JSL	>BGCOIN_SETCHK	; ユニット セット チェック
		BNE	BLCIN_NNM_SB_90
		LDA	#0FFFFH
		STA	<LKFLG
		LDA	<XSIZE
		AND	#00001
		BNE	BLCIN_NNM_SB_90
;
		LDX	<UNITPOS
		LDA	#UTA400
		STA	>BGUNIT,X
BLCIN_NNM_SB_90	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右上がり逆坂 60ﾟ 			*
;*								*
;****************************************************************
ANAU60R_DAT	EQU	$
		WORD	RUTA202,RUTA102
;
;
KUSAANAU60R	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	ANAU60R_100
		LDA	<YSIZE
		BNE	ANAU60R_100
		DEC	<YSIZECP
		DEC	<YSIZECP
		BEQ	ANAU60R_050
		BPL	ANAU60R_100
ANAU60R_050	EQU	$
		LDA	#00001
		STA	<YSIZECP
;
ANAU60R_100	EQU	$
		LDA	<XSIZE
		BNE	ANAU60R_150
		JSR	GIMEN_LT
ANAU60R_150	EQU	$
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		BEQ	ANAU60R_500
		CMP	#00001
		BEQ	ANAU60R_500
		JSR	ANATUTI		; 土 セット
		LDA	<XSIZE
		INC	A
		CMP	>XSIZECP
		BNE	ANAU60R_900
		JSR	GIMEN_RT
		BRA	ANAU60R_900
;
ANAU60R_500	EQU	$
		ASL	A
		TAY
		LDX	ANAU60R_DAT,Y
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		TYA
		BNE	ANAU60R_600
		LDA	<XYPOINT
		JSR	ANA_LTUP
;
		LDA	<XYPOINT
		TAX
		AND	#0F0F0H
		STA	<WORKE
		TXA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		ORA	<WORKE
		JSR	ANA_RTUP
		BRA	ANAU60R_900
;
ANAU60R_600	EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	ANAU60R_900
		JSR	RIGT_CHK
		LDA	RUT3B0E
		STA	>BGUNIT,X
;
ANAU60R_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*	草コース トンネル内の右下がり逆坂 60ﾟ 			*
;*								*
;****************************************************************
ANAU60L_DAT	EQU	$
		WORD	RUTA002,RUT9F02
;
;
KUSAANAU60L	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		BEQ	ANAU60L_100
		LDA	<YSIZE
		BNE	ANAU60L_100
		INC	<YSIZECP
		INC	<YSIZECP
;
ANAU60L_100	EQU	$
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	ANAU60L_150
		JSR	GIMEN_RT
ANAU60L_150	EQU	$
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		BEQ	ANAU60L_500
		CMP	#00001
		BEQ	ANAU60L_500
		JSR	ANATUTI		; 土 セット
;
		LDA	<XSIZE
		BNE	ANAU60L_900
		JSR	GIMEN_LT
		BRA	ANAU60L_900
;
ANAU60L_500	EQU	$
		ASL	A
		TAY
		LDX	ANAU60L_DAT,Y
		LDA	0,X
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
		TYA
		BNE	ANAU60L_900
		LDA	<XYPOINT
		JSR	ANA_RTUP
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP
		BNE	ANAU60L_900
		LDA	<XYPOINT
		TAX
		AND	#00F0FH
		ORA	#000F0H
		INC	A
		AND	#00F0FH
		STA	<WORKE
		TXA
		AND	#0F0F0H
		ORA	<WORKE
		JSR	ANA_LTUP
;
ANAU60L_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANA_RTUP	EQU	$
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		CMP	RUT1D13
		BNE	ANA_RTUP_990
		LDA	RUT3B0D
		STA	>BGUNIT,X
ANA_RTUP_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANA_LTUP	EQU	$
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		CMP	RUT1D13
		BNE	ANA_LTUP_990
		LDA	RUT3B0E
		STA	>BGUNIT,X
ANA_LTUP_990	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		草床のじゃり道					*
;*								*
;****************************************************************
KUSAJARI_DAT0	EQU	$
		WORD	UT0151,UT0152,UT0153,UT0154
		WORD	UT0159,UT015A,UT0159,UT015A
;
KUSAJARI_DAT1	EQU	$
		WORD	RUT3B01,RUT3B00
		WORD	UT0150,UT015B
;
;
KUSAJARI	EQU	$
		MI16			; memory , index 16bit mode
;
KUSAJARI_200	EQU	$
		LDY	#00000H
		LDA	<XSIZE		; 左側 ?
		BEQ	KUSAJARI_210	;	YES -> KUSAJARI_210
		INY
		INY
		INC	A		; 右側 ?
		CMP	<XSIZECP	;	NO -> KUSAJARI_300
		BNE	KUSAJARI_300
KUSAJARI_210	EQU	$
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	KUSAJARI_220
		CMP	RUT2A01
		BEQ	KUSAJARI_220
		CMP	RUT3912
		BEQ	KUSAJARI_220
		CMP	RUT3913
		BNE	KUSAJARI_300
KUSAJARI_220	EQU	$
		LDA	<YSIZE
		BEQ	KUSAJARI_230
		TYA
		ORA	#00004
		TAY
KUSAJARI_230	EQU	$
		LDA	KUSAJARI_DAT1,Y
		CPY	#00004
		BCS	KUSAJARI_900
		TAY
		LDA	0,Y
		BRA	KUSAJARI_900
;
KUSAJARI_300	EQU	$
		LDA	<YSIZE		;１ライン目 ?
		BNE	KUSAJARI_400	;	NO -> KUSAJARI_400
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	KUSAJARI_350
		CMP	RUT2A01
		BNE	KUSAJARI_950
KUSAJARI_350	EQU	$
		LDA	#UT0000
		BRA	KUSAJARI_900
;
KUSAJARI_400	EQU	$
		JSL	>RND_RND
		AND	#00003
		ASL	A
		STA	<WORK0
		LDA	<STUNTNO
		AND	#00008H
		ORA	<WORK0
		TAY
		LDA	KUSAJARI_DAT0,Y
;
KUSAJARI_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
KUSAJARI_950	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		のるとおちるブロック				*
;*								*
;****************************************************************
DWNBLK_ADR	EQU	$
		WORD	DWNBLK_100	; １ユニット セット
		WORD	DWNBLK_200	; 横長ユニット セット
		WORD	DWNBLK_300	; 縦長ユニット セット
		WORD	DWNBLK_400	; 四角形ユニット セット
;
;
DWNBLK		EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000H
		TXY
		LDA	<YSIZECP
		DEC	A
		BNE	DWNBLK_020
		LDA	<XSIZECP
		DEC	A
		BEQ	DWNBLK_080
		INX
		INX
		BRA	DWNBLK_080
DWNBLK_020	EQU	$
		INX
		INX
		INX
		INX
		LDA	<XSIZECP
		DEC	A
		BEQ	DWNBLK_080
		INX
		INX
DWNBLK_080	EQU	$
		JSR	(DWNBLK_ADR,X)
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		１ユニット セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DWNBLK_100	EQU	$
		LDA	#UT720D
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		横長ユニット セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DWNBLK_2DT	EQU	$
		WORD	UT7209,UT720A,UT720B
;
;
DWNBLK_200	EQU	$
		LDA	<XSIZE
		BEQ	DWNBLK_290
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	DWNBLK_290
		INY
		INY
DWNBLK_290	EQU	$
		LDA	DWNBLK_2DT,Y
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		縦長ユニット セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DWNBLK_3DT	EQU	$
		WORD	UT720C,UT720E,UT7213,UT720F
;
;
DWNBLK_300	EQU	$
		LDA	<YSIZE
		BEQ	DWNBLK_390
		LDY	#00006
		INC	A
		CMP	<YSIZECP
		BEQ	DWNBLK_390
		AND	#00001
		ASL	A
		TAY
		INY
		INY
DWNBLK_390	EQU	$
		LDA	DWNBLK_3DT,Y
		RTS
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		四角形ユニット セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DWNBLK_4DT	EQU	$
		WORD	UT7200,UT7201,UT7202
		WORD	UT7203,UT7204,UT7205
		WORD	UT7210,UT7211,UT7212
		WORD	UT7206,UT7207,UT7208
;
;
DWNBLK_400	EQU	$
		LDA	<YSIZE
		BEQ	DWNBLK_410
		LDY	#00012H
		INC	A
		CMP	<YSIZECP
		BEQ	DWNBLK_410
		LDY	#00006H
		AND	#00001
		BEQ	DWNBLK_410
		LDY	#0000CH
DWNBLK_410	EQU	$
		LDA	<XSIZE
		BEQ	DWNBLK_490
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	DWNBLK_490
		INY
		INY
DWNBLK_490	EQU	$
		LDA	DWNBLK_4DT,Y
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		バケツリレーのカベ				*
;*								*
;****************************************************************
BKTKABE_DAT0	EQU	$
		WORD	UT017C,UT017D
		WORD	UT017E,UT017F
;
;
BKTKABE		EQU	$
		MI16			; memrory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002
		BCC	BKTKABE_500
		LDA	<NOWUNIT
		CMP	#UT00D6		; 斜めの影が あるか ?
		BEQ	BKTKABE_150	;	YES -> BKTKABE_150
		CMP	#UT00DA		; 角の影が あるか ?
		BEQ	BKTKABE_180	;	YES -> BKTKABE_180
		CMP	#UT00D8		; 縦の影が あるか ?
		BEQ	BKTKABE_190	;	YES -> BKTKABE_190
		CMP	#UT00D5		; 影付けるか ?
		BNE	BKTKABE_900	;	NO -> BKTKABE_900
		BRA	BKTKABE_180
BKTKABE_150	EQU	$
		LDA	<XSIZE
		BEQ	BKTKABE_900
BKTKABE_180	EQU	$
		LDA	#UT00D9
		BRA	BKTKABE_580
;
BKTKABE_190	EQU	$
		LDA	#UT00E8
		BRA	BKTKABE_580
;
BKTKABE_500	EQU	$
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00001
		ASL	A
		ORA	<WORK0
		TAY
		LDA	<NOWUNIT
		CMP	#UT00C9		;
		BEQ	BKTKABE_900	; 柱が あるか ?
		CMP	#UT00CA		;	YES -> BKTKABE_900
		BEQ	BKTKABE_900	;
		CMP	#UT00CB		;
		BEQ	BKTKABE_900	;
		CMP	#UT00CC		;
		BEQ	BKTKABE_900	;
		CMP	#UT00CD		;
		BEQ	BKTKABE_900	;
		LDA	BKTKABE_DAT0,Y
BKTKABE_580	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
BKTKABE_900	EQU	$
		MI8			; memrory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		花コース 蔓の茎					*
;*								*
;****************************************************************
HNTULU_DAT	EQU	$
		WORD	UT3D81,UT3DB8,UT3D80
;
;
HNTULU		EQU	$
		I16			; index 16bit mode
		LDX	<UNITPOS
		LDY	#00002
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BEQ	HNTULU_500
		JSL	>RND_RND
		AND	#001
		TAY
HNTULU_500	EQU	$
		M16			; memrory 16bit mode
		TYA
		AND	#00003
		ASL	A
		TAY
		LDA	HNTULU_DAT,Y
		STA	>BGUNIT,X
		MI8			; memrory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ちくわブロック 大				*
;*								*
;****************************************************************
CHKWBIG_DAT	EQU	$
		WORD	UT7500,UT7501
		WORD	UT3DBB,UT3DBC
;
;
CHKWBIG		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	CHKWBIG_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		草 第二 ボロボロ杭 ３０゜			*
;*								*
;****************************************************************
;			  左	  右
BRKUI30_DT0	EQU	$
		WORD	RUT0806,RUT0A06
		WORD	UT3DD3, UT3DD2
		WORD	UT3DF1, UT3DF0
;
BRKUI30_DT1	EQU	$
		WORD	RUT0F02,RUT0D01
		WORD	UT3DD4, UT3DD1
		WORD	RUT0F03,RUT0D02
		WORD	UT3DF2, UT3DEF
;
BRKUI30_DT2	EQU	$
		WORD	RUT1003,RUT0C01
		WORD	UT3DD5, UT3DD0
		WORD	UT3DD3, UT3DD2
;
BRKUI30_DT2_SB	EQU	$
		WORD	RUT1004,RUT0C04
		WORD	UT3DF3, UT3DEE
		WORD	UT3DF1, UT3DF0
;
BRKUI30_SET	EQU	$
		WORD	BRKUI30_SET0,BRKUI30_SET1,BRKUI30_SET2
;
;
BRKUI30		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00003
		BCS	BRKUI30_990
		ASL	A
		ASL	A
		TAY
		LDA	<XSIZECP
		BPL	BRKUI30_020
		INY
		INY
BRKUI30_020	EQU	$
		STZ	<WORK0
		LDA	<NOWUNIT
		BEQ	BRKUI30_100
		CMP	RUT2A00
		BEQ	BRKUI30_050
		CMP	RUT2A01
		BEQ	BRKUI30_050
		CMP	#UT3DC4
		BEQ	BRKUI30_030
		CMP	#UT3DC5
		BEQ	BRKUI30_030
		CMP	#UT3DCD
		BEQ	BRKUI30_030
		CMP	#UT3DCE
		BEQ	BRKUI30_030
		CMP	RUT0805
		BEQ	BRKUI30_100
		CMP	RUT0A01
		BEQ	BRKUI30_100
		INC	<WORK0
BRKUI30_030	EQU	$
		INC	<WORK0
BRKUI30_050	EQU	$
		INC	<WORK0
;
BRKUI30_100	EQU	$
		LDX	#00000H
		LDA	<XSIZE
		BEQ	BRKUI30_150
		INX
		INX
		AND	#00001
		BNE	BRKUI30_150
		INX
		INX
BRKUI30_150	EQU	$
		JSR	(BRKUI30_SET,X)
		TYA
		BEQ	BRKUI30_990
		LDX	<UNITPOS
		STA	>BGUNIT,X
BRKUI30_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ボロボロ杭 ３０゜ 端			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BRKUI30_SET0	EQU	$
		STZ	<LKFLG
		LDA	<YSIZE
		CMP	#00002
		BCC	BRKUI30_SET0_10
		LDA	#0000
		BRA	BRKUI30_SET0_90
BRKUI30_SET0_10 EQU	$
		LDA	<WORK0
		BEQ	BRKUI30_SET0_20
		TYA
		CLC
		ADC	#00004
		TAY
BRKUI30_SET0_20 EQU	$
		LDA	BRKUI30_DT0,Y
		LDX	<YSIZE
		BNE	BRKUI30_SET0_90
		TAX
		LDA	0,X
BRKUI30_SET0_90 EQU	$
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ボロボロ杭 ３０゜ その１		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BRKUI30_SET1	EQU	$
		STZ	<LKFLG
		LDA	<YSIZE
		CMP	#00002
		BCC	BRKUI30_SET1_10
		LDA	#0000
		BRA	BRKUI30_SET1_90
BRKUI30_SET1_10 EQU	$
		LDA	>WORK0
		BEQ	BRKUI30_SET1_20
		CMP	#00002
		BCC	BRKUI30_SET1_15
		LDA	#00000H
		BRA	BRKUI30_SET1_90
BRKUI30_SET1_15 EQU	$
		TYA
		CLC
		ADC	#00008
		TAY
BRKUI30_SET1_20 EQU	$
		LDA	BRKUI30_DT1,Y
		LDX	<YSIZE
		BNE	BRKUI30_SET1_90
		TAX
		LDA	0,X
BRKUI30_SET1_90 EQU	$
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ボロボロ杭 ３０゜ その２		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BRKUI30_SET2_SB EQU	$
		WORD	BRKUI30_SET2_00
		WORD	BRKUI30_SET2_10
		WORD	BRKUI30_SET2_20
		WORD	BRKUI30_SET2_20
;
;
BRKUI30_SET2	EQU	$
		LDA	#00001
		STA	<LKFLG
		LDA	<WORK0
		ASL	A
		TAX
		JSR	(BRKUI30_SET2_SB,X)
		LDY	<WORK2
		LDX	<YSIZE
		BNE	BRKUI30_SET2_90
		LDA	0,Y
		TAY
BRKUI30_SET2_90 EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		普通				+
;++++++++++++++++++++++++++++++++++++++++++++++++
BRKUI30_SET2_00 EQU	$
		LDA	BRKUI30_DT2,Y
		STA	<WORK2
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		草付き				+
;++++++++++++++++++++++++++++++++++++++++++++++++
BRKUI30_SET2_10 EQU	$
		LDA	BRKUI30_DT2_SB,Y
		STA	<WORK2
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		なし				+
;++++++++++++++++++++++++++++++++++++++++++++++++
BRKUI30_SET2_20 EQU	$
		STZ	<WORK2
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		草 第二 ボロボロ杭 ４５゜			*
;*								*
;****************************************************************
;			  左	  右
BRKUI45_DT0	EQU	$
		WORD	RUT0805,RUT0A01
		WORD	UT3DC5, UT3DC4
		WORD	UT3DCA, UT3DC9
;
BRKUI45_DT1	EQU	$
		WORD	RUT0A04,RUT0802
		WORD	UT3DCF, UT3DCC
		WORD	UT3DCE, UT3DCD
;
;
BRKUI45		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00003
		BCS	BRKUI45_990
		LDA	#00001
		STA	<LKFLG
		STZ	<WORK0
		LDA	<XSIZECP
		BPL	BRKUI45_000
		LDA	#00002H
		STA	<WORK0
;
BRKUI45_000	EQU	$
		LDA	<YSIZE
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	<XSIZE		; 端 ?
		BNE	BRKUI45_100	;	NO -> BRKUI45_100
		STZ	<LKFLG
		LDA	<NOWUNIT
		BEQ	BRKUI45_050
		CMP	RUT2A00
		BEQ	BRKUI45_020
		CMP	RUT2A01
		BNE	BRKUI45_990
BRKUI45_020	EQU	$
		TYA
		CLC
		ADC	#00004
		TAY
BRKUI45_050	EQU	$
		JSR	BRKUI45_HASI
		BRA	BRKUI45_900
;
BRKUI45_100	EQU	$
		JSR	BRKUI45_SET
;
BRKUI45_900	EQU	$
		TYA
		BEQ	BRKUI45_990
		LDX	<UNITPOS
		STA	>BGUNIT,X
BRKUI45_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ボロボロ杭 ４５゜ 端			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
BRKUI45_HASI	EQU	$
		LDA	<YSIZE
		CMP	#00002
		BCC	BRKUI45_HASI_10
		LDA	#00000
		BRA	BRKUI45_HASI_90
BRKUI45_HASI_10 EQU	$
		LDA	BRKUI45_DT0,Y
		LDX	<YSIZE
		BNE	BRKUI45_HASI_90
		TAX
		LDA	0,X
BRKUI45_HASI_90 EQU	$
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ボロボロ杭 ４５゜			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BRKUI45_SET_DT	EQU	$
		WORD	RUT0A05,RUT0801
		WORD	UT3DCB, UT3DC8
		WORD	UT3DCA, UT3DC9
;
;
BRKUI45_SET	EQU	$
		LDA	<NOWUNIT
		BEQ	BRKUI45_SET_50
		CMP	RUT2A00
		BEQ	BRKUI45_SET_10
		CMP	RUT2A01
		BEQ	BRKUI45_SET_10
		LDA	#00000H
		BRA	BRKUI45_SET_90
;
BRKUI45_SET_10	EQU	$
		LDA	BRKUI45_SET_DT,Y
		BRA	BRKUI45_SET_80
;
BRKUI45_SET_50	EQU	$
		LDA	BRKUI45_DT1,Y
BRKUI45_SET_80	EQU	$
		LDX	<YSIZE
		BNE	BRKUI45_SET_90
		TAX
		LDA	0,X
BRKUI45_SET_90	EQU	$
		TAY
		RTS
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		草 第二 ボロボロ杭の枝 １			*
;*								*
;****************************************************************
BRKUIEDA0_0_DT	EQU	$
		WORD	UT3DD6,UT3DD7,UT3DD8,00000H
		WORD	UT3DDC,UT3DDD,UT3DDE
;
;
BRKUIEDA0	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002
		BCS	BRKUIEDA0_500
		LDA	<XSIZE
		ASL	A
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	BRKUIEDA0_0_DT,Y
		BRA	BRKUIEDA0_900
;
BRKUIEDA0_500	EQU	$
		LDA	<XSIZE
		BEQ	BRKUIEDA0_990
		INC	A
		CMP	<XSIZECP
		BEQ	BRKUIEDA0_990
		LDA	#UT3DC6
		LDY	<YSIZE
		INY
		CPY	<YSIZECP
		BNE	BRKUIEDA0_900
		LDY	RUT0804
		LDA	<NOWUNIT
		CMP	RUT0802
		BEQ	BRKUIEDA0_700
		LDY	RUT0C03
		CMP	RUT0C01
		BEQ	BRKUIEDA0_700
		LDY	#UT3DC0
BRKUIEDA0_700	EQU	$
		TYA
BRKUIEDA0_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
BRKUIEDA0_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		草 第二 ボロボロ杭の枝 ２			*
;*								*
;****************************************************************
BRKUIEDA1_0_DT	EQU	$
		WORD	UT3DD9,UT3DDA,UT3DDB,00000H
		WORD	UT3DDF,UT3DC2,UT3DC3
;
;
BRKUIEDA1	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002
		BCS	BRKUIEDA1_500
		LDA	<XSIZE
		ASL	A
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	BRKUIEDA1_0_DT,Y
		BRA	BRKUIEDA1_900
;
BRKUIEDA1_500	EQU	$
		LDA	<XSIZE
		BEQ	BRKUIEDA1_990
		INC	A
		CMP	<XSIZECP
		BEQ	BRKUIEDA1_990
		LDA	#UT3DC7
		LDY	<YSIZE
		INY
		CPY	<YSIZECP
		BNE	BRKUIEDA1_900
		LDY	RUT0A02
		LDA	<NOWUNIT
		CMP	RUT0A04
		BEQ	BRKUIEDA1_700
		LDY	RUT1001
		CMP	RUT1003
		BEQ	BRKUIEDA1_700
		LDY	#UT3DC1
BRKUIEDA1_700	EQU	$
		TYA
BRKUIEDA1_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
BRKUIEDA1_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		草コース 山嵐のような葉っぱ			*
;*								*
;****************************************************************
YMARASI_DT	EQU	$
		WORD	UT3DE3,UT3DE4,UT3DE5,00000H
		WORD	UT3DE6,UT3DE7,UT3DE8,UT3DE9
;
;
YMARASI		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<YSIZE
		CMP	#00002
		BCS	YMARASI_500
		LDA	<XSIZE
		ASL	A
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	YMARASI_DT,Y
		BEQ	YMARASI_990
		BRA	YMARASI_900
;
YMARASI_500	EQU	$
		LDA	<XSIZE
		BEQ	YMARASI_990
		INC	A
		CMP	<XSIZECP
		BEQ	YMARASI_990
		LDY	<YSIZE
		INY
		CPY	<YSIZECP
		BEQ	YMARASI_600
		CMP	#00003
		BCS	YMARASI_990
		LDA	#UT3DEA
		BRA	YMARASI_900
;
YMARASI_600	EQU	$
		AND	#00001
		CLC
		ADC	#UT3DEB
;
YMARASI_900	EQU	$
		STA	>BGUNIT,X
YMARASI_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		カウント ダウン ブロック セット			*
;*								*
;****************************************************************
CONTBLCK_DAT	EQU	$
		WORD	UT7600,UT7601
		WORD	UT7778,UT7779
;
		WORD	UT7602,UT7603
		WORD	UT777A,UT777B
;
		WORD	UT7604,UT7605
		WORD	UT777C,UT777D
;
		WORD	UT7606,UT7607
		WORD	UT777E,UT777F
;
;
CONTBLCK	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<STUNTNO
		AND	#00003
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00001
		ASL	A
		ORA	<WORK0
		STA	<WORK0
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	CONTBLCK_DAT,Y
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		地下コース 滝					*
;*								*
;****************************************************************
CHKTK_ADR	EQU	$
		WORD	CHKTK_SB_000,CHKTK_SB_100,CHKTK_SB_200
;
;
CHKTK		EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000H
		LDA	<XSIZE
		AND	#00001
		ASL	A
		TAY
		LDA	<YSIZE
		BEQ	CHKTK_200
		INX
		INX
		CMP	#00001
		BEQ	CHKTK_200
		INX
		INX
;
CHKTK_200	EQU	$
		JSR	(CHKTK_ADR,X)
;
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		滝セット (一番上)			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKTK_DAT0	EQU	$
		WORD	UT7750,UT7754
;
CHKTK_SB_000	EQU	$
		LDA	CHKTK_DAT0,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		滝セット (二番目)			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKTK_DAT1	EQU	$
		WORD	UT7800,UT7801,UT7802,UT7803
;
CHKTK_SB_100	EQU	$
		LDA	<XSIZECP
		CMP	#00001
		BNE	CHKTK_SB_120
		LDA	#UT7804
		BRA	CHKTK_SB_190
CHKTK_SB_120	EQU	$
		LDA	<XSIZE
		BEQ	CHKTK_SB_150
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	CHKTK_SB_150
		LDY	#00006
;
CHKTK_SB_150	EQU	$
		LDA	CHKTK_DAT1,Y
CHKTK_SB_190	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		滝セット (三番目以降)			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKTK_DAT2	EQU	$
		WORD	UT01D1,UT01D2
;
CHKTK_SB_200	EQU	$
		LDA	<YSIZE
		CLC
		ADC	<XSIZE
		AND	#00001
		ASL	A
		TAY
		LDA	CHKTK_DAT2,Y
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		地下コース 滝岩					*
;*								*
;****************************************************************
CHKTKIWA_DAT0	EQU	$
		WORD	UT01D3,UT01D4,UT01D5,00000H
		WORD	UT01D6,UT01D7,UT01D8
;
;
CHKTKIWA	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002
		BCC	CHKTKIWA_100
		LDA	<XSIZE
		BEQ	CHKTKIWA_990
		INC	A
		CMP	<XSIZECP
		BEQ	CHKTKIWA_990
		JSL	>FLOOR_RND
		BRA	CHKTKIWA_990
;
CHKTKIWA_100	EQU	$
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		ASL	A
		ORA	<WORK0
		TAY
		LDA	CHKTKIWA_DAT0,Y
;
CHKTKIWA_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
CHKTKIWA_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		地下コース 怪しい木 (大)			*
;*								*
;****************************************************************
CHKBIGWODR_TOP	EQU	$
		WORD	00000H,UT7701,UT7702,UT7703
		WORD	UT7710,UT7711,UT7712,UT7713
;
CHKBIGWODL_TOP	EQU	$
		WORD	UT7730,UT7731,UT7732,00000H
		WORD	UT7740,UT7741,UT7742,UT7743
;
CHKBIGWODR_MID0 EQU	$
		WORD	UT7700,UT7704,UT7708,UT770C
;
CHKBIGWODR_MID1 EQU	$
		WORD	UT7733,UT7737,UT773B,UT773F
;
CHKBIGWODR_DWN	EQU	$
		WORD	UT7723,UT7727,UT772B,UT772F
;
CHKBIGWODR_ADR	EQU	$
		WORD	CHKBIGWODR_100,CHKBIGWODR_400
		WORD	CHKBIGWODR_200,CHKBIGWODR_300
;
CHKBIGWODL_ADR	EQU	$
		WORD	CHKBIGWODL_100,CHKBIGWODL_400
		WORD	CHKBIGWODL_300,CHKBIGWODL_200
;
;
CHKBIGWOD	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
;
		LDX	#00000H
		LDA	<YSIZE
		CMP	#00002
		BCC	CHKBIGWODR_000
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BEQ	CHKBIGWODR_000
		INX
		INX
		AND	#00001
		BNE	CHKBIGWODR_000
		INX
		INX
CHKBIGWODR_000	EQU	$
		LDA	<YSIZECP
		AND	#00001
		BEQ	CHKBIGWODR_050
		JSR	(CHKBIGWODR_ADR,X)
		BRA	CHKBIGWODR_900
;
CHKBIGWODR_050	EQU	$
		JSR	(CHKBIGWODL_ADR,X)
;
CHKBIGWODR_900	EQU	$
		TYA
		BEQ	CHKBIGWODR_990
		LDX	<UNITPOS
		STA	>BGUNIT,X
CHKBIGWODR_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左向き トップ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODR_100	EQU	$
		LDA	<XSIZE
		ASL	A
		ORA	<WORK0
		TAY
		LDA	CHKBIGWODR_TOP,Y
		BEQ	CHKBIGWODR_150
		CLC
		ADC	<STUNTNO
		ADC	<STUNTNO
		ADC	<STUNTNO
		ADC	<STUNTNO
CHKBIGWODR_150	EQU	$
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左向き ＭＩＤ０				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODR_200	EQU	$
		LDA	<XSIZE
		CMP	#00002
		BNE	CHKBIGWODR_290
		LDA	<XYCPBF
		TAY
		LDA	CHKBIGWODR_MID0,Y
		TAY
		RTS
;
CHKBIGWODR_290	EQU	$
		LDY	#00000H
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左向き ＭＩＤ１				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODR_300	EQU	$
		LDA	<XSIZE
		CMP	#00002
		BNE	CHKBIGWODR_290
		LDA	<XYCPBF
		TAY
		LDA	CHKBIGWODR_MID1,Y
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左向き ＤＯＷＮ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODR_400	EQU	$
		LDA	<XSIZE
		CMP	#00002
		BNE	CHKBIGWODR_290
		LDA	<XYCPBF
		TAY
		LDA	!CHKBIGWODR_DWN,Y
		TAY
		RTS
;
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右向き トップ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODL_100	EQU	$
		LDA	<XSIZE
		ASL	A
		ORA	<WORK0
		TAY
		LDA	CHKBIGWODL_TOP,Y
		BEQ	CHKBIGWODL_150
		CLC
		ADC	<STUNTNO
		ADC	<STUNTNO
		ADC	<STUNTNO
		ADC	<STUNTNO
CHKBIGWODL_150	EQU	$
		TAY
		RTS
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右向き ＭＩＤ０				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODL_200	EQU	$
		LDA	<XSIZE
		CMP	#00001
		BNE	CHKBIGWODL_290
		LDA	<XYCPBF
		TAY
		LDA	CHKBIGWODR_MID0,Y
		TAY
		RTS
;
CHKBIGWODL_290	EQU	$
		LDY	#00000H
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右向き ＭＩＤ１				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODL_300	EQU	$
		LDA	<XSIZE
		CMP	#00001
		BNE	CHKBIGWODL_290
		LDA	<XYCPBF
		TAY
		LDA	CHKBIGWODR_MID1,Y
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右向き ＤＯＷＮ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKBIGWODL_400	EQU	$
		LDA	<XSIZE
		CMP	#00001
		BNE	CHKBIGWODL_290
		LDA	<XYCPBF
		TAY
		LDA	!CHKBIGWODR_DWN,Y
		TAY
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		地下コース 怪しい木 (小)			*
;*								*
;****************************************************************
CHKSMLWOD0_RADR EQU	$
		WORD	CHKSMLWODR_100,CHKSMLWOD_400
		WORD	CHKSMLWOD_200,CHKSMLWOD_300
;
CHKSMLWOD0_LADR EQU	$
		WORD	CHKSMLWODL_100,CHKSMLWOD_400
		WORD	CHKSMLWOD_300,CHKSMLWOD_200
;
CHKSMLWODR_DAT	EQU	$
		WORD	UT7722,UT7724,UT7728,UT772C
;
CHKSMLWODL_DAT	EQU	$
		WORD	UT7751,UT7757,UT775A,UT775D
;
;
CHKSMLWOD0	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<STUNTNO
		ASL	A
		TAY
;
		LDX	#00000H
		LDA	<YSIZE
		BEQ	CHKSMLWOD_000
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BEQ	CHKSMLWOD_000
		INX
		INX
		AND	#00001
		BEQ	CHKSMLWOD_000
		INX
		INX
CHKSMLWOD_000	EQU	$
		LDA	<YSIZECP
		AND	#00001
		BNE	CHKSMLWOD_050
		JSR	(CHKSMLWOD0_RADR,X)
		TAY
		JMP	CHKBIGWODR_900
;
CHKSMLWOD_050	EQU	$
		JSR	(CHKSMLWOD0_LADR,X)
		TAY
		JMP	CHKBIGWODR_900
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左向き トップ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWODR_100	EQU	$
		LDA	CHKSMLWODR_DAT,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右向き トップ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWODL_100	EQU	$
		LDA	CHKSMLWODL_DAT,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ＭＩＤ０				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWOD_200	EQU	$
		LDA	<XYCPBF
		TAY
		LDA	CHKBIGWODR_MID0,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ＭＩＤ１				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWOD_300	EQU	$
		LDA	<XYCPBF
		TAY
		LDA	CHKBIGWODR_MID1,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ＤＯＷＮ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWOD_400	EQU	$
		LDA	<XYCPBF
		TAY
		LDA	CHKBIGWODR_DWN,Y
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		地下コース 怪しい木 (右向き小)			*
;*								*
;****************************************************************
CHKSMLWOD1_RADR EQU	$
		WORD	CHKSMLWODR1_100,CHKSMLWODR1_150
		WORD	CHKSMLWOD_400
		WORD	CHKSMLWOD_200,CHKSMLWOD_300
;
CHKSMLWOD1_LADR EQU	$
		WORD	CHKSMLWODL1_100,CHKSMLWODL1_150
		WORD	CHKSMLWOD_400
		WORD	CHKSMLWOD_300,CHKSMLWOD_200
;
;
CHKSMLWODR1_DT0 EQU	$
		WORD	UT7753,UT7756,UT7759,UT775C
;
CHKSMLWODR1_DT1 EQU	$
		WORD	UT7752,UT7755,UT7758,UT775B
;
CHKSMLWODL1_DT0 EQU	$
		WORD	UT7720,UT7725,UT7729,UT772D
;
CHKSMLWODL1_DT1 EQU	$
		WORD	UT7721,UT7726,UT772A,UT772E
;
;
CHKSMLWOD1	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<STUNTNO
		ASL	A
		TAY
;
		LDX	#00000H
		LDA	<YSIZE
		BEQ	CHKSMLWOD1_000
		INX
		INX
		CMP	#00001
		BEQ	CHKSMLWOD1_000
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BEQ	CHKSMLWOD1_000
		INX
		INX
		AND	#00001
		BEQ	CHKSMLWOD1_000
		INX
		INX
CHKSMLWOD1_000	EQU	$
		LDA	<YSIZECP
		AND	#00001
		BNE	CHKSMLWOD1_050
		JSR	(CHKSMLWOD1_RADR,X)
		TAY
		JMP	CHKBIGWODR_900
;
CHKSMLWOD1_050	EQU	$
		JSR	(CHKSMLWOD1_LADR,X)
		TAY
		JMP	CHKBIGWODR_900
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左向き トップ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWODR1_100 EQU	$
		LDA	CHKSMLWODR1_DT0,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左向き 二番目				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWODR1_150 EQU	$
		LDA	CHKSMLWODR1_DT1,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右向き トップ				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWODL1_100 EQU	$
		LDA	CHKSMLWODL1_DT0,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右向き 二番目				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHKSMLWODL1_150 EQU	$
		LDA	CHKSMLWODL1_DT1,Y
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		花コース 第２ 落ちない床			*
;*								*
;****************************************************************
HNIWABLCK_DT0	EQU	$
		WORD	UT7900,UT7901,UT7902
;
HNIWABLCK_DT1	EQU	$
		WORD	UT7903,UT7904,UT7905
;
HNIWABLCK_DT2	EQU	$
		WORD	UT7906,UT7907,UT7908
;
HNIWABLCK_DT3	EQU	$
		WORD	UT7909,UT790A,UT790B
;
HNIWABLCK_DT4	EQU	$
		WORD	UT790C,UT790D,UT790E
;
HNIWABLCK_ADR	EQU	$
		WORD	HNIWABLCK_TOP,HNIWABLCK_DWN
		WORD	HNIWABLCK_MD0,HNIWABLCK_MD1
;
;
HNIWABLCK	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#00000H
		LDA	<XSIZE
		BEQ	HNIWABLCK_100
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	HNIWABLCK_100
		INY
		INY
;
HNIWABLCK_100	EQU	$
		LDX	#00000H
		LDA	<YSIZE
		BEQ	HNIWABLCK_200
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BEQ	HNIWABLCK_200
		INX
		INX
		AND	#00001
		BEQ	HNIWABLCK_200
		INX
		INX
;
HNIWABLCK_200	EQU	$
		JSR	(HNIWABLCK_ADR,X)
;
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HNIWABLCK_TOP	EQU	$
		LDA	HNIWABLCK_DT0,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HNIWABLCK_MD0	EQU	$
		LDA	HNIWABLCK_DT1,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HNIWABLCK_MD1	EQU	$
		LDA	HNIWABLCK_DT2,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HNIWABLCK_DWN	EQU	$
		LDA	<NOWUNIT
		CMP	RUT2A00
		BEQ	HNIWABLCK_DWN_0
		CMP	RUT2A01
		BNE	HNIWABLCK_DWN_1
HNIWABLCK_DWN_0 EQU	$
		TYA
		CLC
		ADC	#00006
		TAY
HNIWABLCK_DWN_1 EQU	$
		LDA	HNIWABLCK_DT3,Y
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		チクワ ブロック (小)				*
;*								*
;****************************************************************
CHKWSML_SB	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	#UT7505
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		乗れる玉					*
;*								*
;****************************************************************
NRR_TAMA_DAT	EQU	$
		WORD	UT3309,UT3509
		WORD	UT0005,UT0006
;
;
NRR_TAMA	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		AND	#00002
		BNE	NRR_TAMA_990
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
;
		LDX	<UNITPOS
		LDA	NRR_TAMA_DAT,Y
		STA	>BGUNIT,X
NRR_TAMA_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		赤 黄 緑 カラーブロック				*
;*								*
;****************************************************************
COLR_DAT	EQU	$
		WORD	UT7A00,UT7A01
;
;
COLR_BLCK	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<XSIZE
		AND	#00001
		ASL	A
		TAY
		LDA	COLR_DAT,Y
		CLC
		ADC	<STUNTNO
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		卵で壊れるブロック				*
;*								*
;****************************************************************
BRK_BLCK_DT0	EQU	$
		WORD	UT7B00,UT7B01
		WORD	UT7B02,UT7B03
;
;
BRK_BLCK	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	BRK_BLCK_DT0,Y
		CLC
		ADC	<STUNTNO
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ドカン						*
;*								*
;****************************************************************
DOKAN_SET	EQU	$
		WORD	DOKAN_TATE,DOKAN_YOKO
		WORD	YGN_DKN_TT,YGN_DKN_YK
;
;
DOKAN		EQU	$
		MI16			; memory , index 16bit mode
		LDX	<STUNTNO
		JSR	(DOKAN_SET,X)
		TYA
		BEQ	DOKAN_900
		LDX	<UNITPOS
		STA	>BGUNIT,X
DOKAN_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ドカン 縦				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_TATE_ADR	EQU	$
		WORD	DOKAN_TATE_000
		WORD	DOKAN_TATE_100
		WORD	DOKAN_TATE_200
;
;
DOKAN_TATE	EQU	$
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
		TAY
		LDX	#00000H
		LDA	<YSIZE
		BEQ	DOKAN_TATE_SET
		INX
		INX
		INC	A
		CMP	<YSIZECP
		BNE	DOKAN_TATE_SET
		INX
		INX
DOKAN_TATE_SET	EQU	$
		JSR	(DOKAN_TATE_ADR,X)
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		上				+
;++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_TT_DT0	EQU	$
		WORD	UT7D02,UT7D03
;
;
DOKAN_TATE_000	EQU	$
		LDA	<NOWUNIT
		BEQ	DOKAN_TATE_010
		CMP	#UT1600
		BEQ	DOKAN_TATE_010
		BRA	DOKAN_TATE_050
DOKAN_TATE_010	EQU	$
		LDA	DOKAN_TT_DT0,Y
		BRA	DOKAN_TATE_090
;
DOKAN_TATE_050	EQU	$
		LDA	#00000H
DOKAN_TATE_090	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		中				+
;++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_TT_DT1	EQU	$
		WORD	UT01E6,UT01E7
		WORD	UT01E4,UT01E5
;
;
DOKAN_TATE_100	EQU	$
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	DOKAN_TT_DT1,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		下				+
;++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_TT_DT2	EQU	$
		WORD	UT7D06,UT7D07
;
;
DOKAN_TATE_200	EQU	$
		LDA	<NOWUNIT
		BEQ	DOKAN_TATE_210
		CMP	#UT1600
		BEQ	DOKAN_TATE_210
		BRA	DOKAN_TATE_250
DOKAN_TATE_210	EQU	$
		LDA	DOKAN_TT_DT2,Y
		BRA	DOKAN_TATE_290
;
DOKAN_TATE_250	EQU	$
		LDA	#00000H
DOKAN_TATE_290	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		ドカン 横				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_YOKO_ADR	EQU	$
		WORD	DOKAN_YOKO_000
		WORD	DOKAN_YOKO_100
		WORD	DOKAN_YOKO_200
;
;
DOKAN_YOKO	EQU	$
		LDA	<YSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
		TAY
		LDX	#00000H
		LDA	<XSIZE
		BEQ	DOKAN_YOKO_SET
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	DOKAN_YOKO_SET
		INX
		INX
DOKAN_YOKO_SET	EQU	$
		JSR	(DOKAN_YOKO_ADR,X)
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		左				+
;++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_YK_DT0	EQU	$
		WORD	UT7D00
		WORD	UT7D01
;
;
DOKAN_YOKO_000	EQU	$
		LDA	<NOWUNIT
		BEQ	DOKAN_YOKO_010
		CMP	#UT1600
		BEQ	DOKAN_YOKO_010
		BRA	DOKAN_YOKO_050
DOKAN_YOKO_010	EQU	$
		LDA	DOKAN_YK_DT0,Y
		BRA	DOKAN_YOKO_090
;
DOKAN_YOKO_050	EQU	$
		LDA	#00000H
DOKAN_YOKO_090	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		中				+
;++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_YK_DT1	EQU	$
		WORD	UT01E1,UT01E0
		WORD	UT01E2,UT01E3
;
;
DOKAN_YOKO_100	EQU	$
		ASL	<WORK0
		LDA	<XSIZE
		AND	#00001
		ASL	A
		ORA	<WORK0
		TAY
		LDA	DOKAN_YK_DT1,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		右				+
;++++++++++++++++++++++++++++++++++++++++++++++++
DOKAN_YK_DT2	EQU	$
		WORD	UT7D04
		WORD	UT7D05
;
;
DOKAN_YOKO_200	EQU	$
		LDA	<NOWUNIT
		BEQ	DOKAN_YOKO_210
		CMP	#UT1600
		BEQ	DOKAN_YOKO_210
		BRA	DOKAN_YOKO_250
DOKAN_YOKO_210	EQU	$
		LDA	DOKAN_YK_DT2,Y
		BRA	DOKAN_YOKO_290
;
DOKAN_YOKO_250	EQU	$
		LDA	#00000H
DOKAN_YOKO_290	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		溶岩コース 横ドカン			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_DKN_YK_ADR	EQU	$
		WORD	YGN_DKN_YK_000,YGN_DKN_YK_100,YGN_DKN_YK_200
;
;
YGN_DKN_YK	EQU	$
		LDA	<YSIZE
		ASL	A
		TAY
		LDX	#00000H
		LDA	<XSIZE
		BEQ	YGN_DKN_YK_SET
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	YGN_DKN_YK_SET
		INX
		INX
;
YGN_DKN_YK_SET	EQU	$
		JSR	(YGN_DKN_YK_ADR,X)
		TAY
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		左				+
;++++++++++++++++++++++++++++++++++++++++++++++++
YGN_DKN_YK_DT0	EQU	$
		WORD	UT3D34
		WORD	UT7D23
		WORD	UT7D24
		WORD	UT9066
;
YGN_DKN_YK_000	EQU	$
		LDA	YGN_DKN_YK_DT0,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		中				+
;++++++++++++++++++++++++++++++++++++++++++++++++
YGN_DKN_YK_DT1	EQU	$
		WORD	UT3D35,UT3D36
		WORD	UT9062,UT9063
		WORD	UT9064,UT9065
		WORD	UT9067,UT9068
;
YGN_DKN_YK_100	EQU	$
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
		LDA	<YSIZE
		ASL	A
		ORA	<WORK0
		ASL	A
		TAY
		LDA	YGN_DKN_YK_DT1,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+		右				+
;++++++++++++++++++++++++++++++++++++++++++++++++
YGN_DKN_YK_DT2	EQU	$
		WORD	UT3D37
		WORD	UT7D25
		WORD	UT7D26
		WORD	UT9069
;
YGN_DKN_YK_200	EQU	$
		LDA	YGN_DKN_YK_DT2,Y
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		溶岩コース 縦ドカン			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_DKN_TT_DAT	EQU	$
		WORD	UT906A	;上
		WORD	UT3D32	;下
		WORD	UT7D21	;下２
		WORD	UT9060	;中
;
;
YGN_DKN_TT	EQU	$
		LDY	#0000
		LDA	<YSIZE
		BEQ	YGN_DKN_TT_000
		INY
		INC	A
		CMP	<YSIZECP
		BEQ	YGN_DKN_TT_000
		INY
		INC	A
		CMP	<YSIZECP
		BEQ	YGN_DKN_TT_000
		INY
YGN_DKN_TT_000	EQU	$
		TYA
		ASL	A
		TAY
		LDA	YGN_DKN_TT_DAT,Y
		CLC
		ADC	<XSIZE
		TAY
		RTS
;
		MEM8
		IDX8
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		TGBLKST		( とげブロックセットルーチン )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TGUNTDT		EQU	$
		WORD	00000H,UT7784,00000H
		WORD	UT7782,UT7C00,UT7781
		WORD	00000H,UT7788,00000H
;
;
TGBLKST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDX	#00000
		LDA	<XSIZE
		BEQ	TGBLKST_050	; Ｘポイント左端　？
;					; No !!
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	TGBLKST_050	; Ｘポイント真ん中　？
;					; No !!
		INX
		INX
;
TGBLKST_050	EQU	$
		STX	<WORK0
		LDX	#00000H
		LDA	<YSIZE
		BEQ	TGBLKST_100	; Ｙポイント上　？
;					; No !!
		LDX	#00006H
		INC	A
		CMP	<YSIZECP
		BNE	TGBLKST_100	; Ｙポイント真ん中　？
;					; No !!
		LDX	#0000CH
;
TGBLKST_100	EQU	$
		TXA
		CLC
		ADC	<WORK0
		STA	<WORK0
		TAY
		LDA	!TGUNTDT,Y
		STA	<WORK4
		BEQ	TGBLKST_END	; ユニットＮｏ．　０　？
;					; No !!
		CMP	#UT7C00
		BEQ	TGBLKST_150	; ユニットＮｏ．チェック　？
;					; Yes !!
		LDA	<NOWUNIT
		BEQ	TGBLKST_150	; ユニットＮｏ．ヌキ　？
;					; No !!
		SEC
		SBC	#UT7781-1
		STA	<WORK2
		DEC	A
		CMP	#0000FH
		BCS	TGBLKST_END	; とげユニット　？
;					; Yes !!
		LDA	<WORK4
		SEC
		SBC	#UT7781-1
		ORA	<WORK2
		CLC
		ADC	#UT7781-1
		STA	<WORK4
;
TGBLKST_150	EQU	$
		LDX	<UNITPOS
		LDA	<WORK4
		STA	>BGUNIT,X	; とげユニットセット
;
TGBLKST_END	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
		MEM8
		IDX8
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		TGBLKCR		( とげブロッククリアールーチン )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TGBLKCR		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDX	#00000
		LDA	<XSIZE
		BEQ	TGBLKCR_050	; Ｘポイント左端　？
;					; No !!
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	TGBLKCR_050	; Ｘポイント真ん中　？
;					; No !!
		INX
		INX
;
TGBLKCR_050	EQU	$
		STX	<WORK0
		LDX	#00000H
		LDA	<YSIZE
		BEQ	TGBLKCR_100	; Ｙポイント上　？
;					; No !!
		LDX	#00006H
		INC	A
		CMP	<YSIZECP
		BNE	TGBLKCR_100	; Ｙポイント真ん中　？
;					; No !!
		LDX	#0000CH
;
TGBLKCR_100	EQU	$
		TXA
		CLC
		ADC	<WORK0
		STA	<WORK6
		TAY
		LDA	!TGUNTDT,Y
		STA	<WORK4
		BEQ	TGBLKCR_END	; ユニットＮｏ．　０　？
;					; No !!
		CMP	#UT7C00
		BNE	TGBLKCR_150	; ユニットＮｏ．チェック　？
;					; Yes !!
		JSR	UTDELCK		; ユニットＮｏ．チェックサブルーチン
		BRA	TGBLKCR_200
;
TGBLKCR_150	EQU	$
		LDA	<NOWUNIT
		CMP	#UT7C00
		BEQ	TGBLKCR_END	; ユニットＮｏ．とげの真ん中　？
;					; No !!
		SEC
		SBC	#UT7781-1
		STA	<WORK2
		DEC	A
		CMP	#0000FH
		BCS	TGBLKCR_END	; とげユニット　？
;					; Yes !!
		LDA	<WORK4
		SEC
		SBC	#UT7781-1
		STA	<WORK4
		AND	<WORK2
		BEQ	TGBLKCR_END
;
		LDA	<WORK4
		EOR	<WORK2
		BEQ	TGBLKCR_250
;
		CLC
		ADC	#UT7781-1
		STA	<WORK4
;
TGBLKCR_200	EQU	$
		LDA	<WORK4
;
TGBLKCR_250	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X	; とげユニットセット
;
TGBLKCR_END	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		JSR	UTDELCK ( ユニットＮｏ．チェックサブルーチン )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		MEM16
		IDX16
;
;
UTDELCK		EQU	$
		STZ	<WORK4
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT7C00
		BNE	UTDELCK_050
;
		LDA	#00008
		STA	<WORK4
;
UTDELCK_050	EQU	$
		LDA	<YSIZE
		INC	A
		INC	A
		CMP	<YSIZECP
		BNE	UTDELCK_100
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT7C00
		BNE	UTDELCK_100
;
		LDA	#00004
		TSB	<WORK4
;
UTDELCK_100	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT7C00
		BNE	UTDELCK_150
;
		LDA	#00001
		TSB	<WORK4
;
UTDELCK_150	EQU	$
		LDA	<XSIZE
		INC	A
		INC	A
		CMP	<XSIZECP
		BNE	UTDELCK_200
;
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	#UT7C00
		BNE	UTDELCK_200
;
		LDA	#00002
		TSB	<WORK4
;
UTDELCK_200	EQU	$
		LDA	<WORK4
		BEQ	UTDELCK_250
;
		CLC
		ADC	#UT7781-1
		STA	<WORK4
;
UTDELCK_250	EQU	$
		RTS
;
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		草コース 普通の棒				*
;*								*
;****************************************************************
NRMLBOW		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#UT0091
		LDA	<NOWUNIT
		BEQ	NRMLBOW_050
;
		LDY	RUT2A0E
		CMP	RUT2A00
		BEQ	NRMLBOW_050
;
		CMP	RUT2A01
		BNE	NRMLBOW_100
;
NRMLBOW_050	EQU	$
		LDX	<UNITPOS
		TYA
		STA	>BGUNIT,X
;
NRMLBOW_100	EQU	$
		MI8			; memory,index 8 bit mode !!
		RTL
;
;
;****************************************************************
;*								*
;*		溶岩コース 移動用ドカン				*
;*								*
;****************************************************************
MV_DKN_ADR	EQU	$
		WORD	MV_DKN_UP,MV_DKN_MID,MV_DKN_DWN
;
;
MOVE_DOKAN	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000H
		LDA	<YSIZE
		BNE	MV_DKN_050
		STZ	<XYCPBF
MV_DKN_050	EQU	$
		CMP	#00004		; 上の出入り口ドカン セット ?
		BCC	MV_DKN_200
		INX
		INX
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		CMP	#00003		; 下の出入り口ドカン セット ?
		BCS	MV_DKN_200
		INX
		INX
MV_DKN_200	EQU	$
		JSR	(MV_DKN_ADR,X)
;
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MV_DKN_UP_DT	EQU	$
		WORD	UT3D38,UT7D27,UT0115,UT0117
;
;
MV_DKN_UP	EQU	$
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	MV_DKN_UP_DT,Y
		BRA	MV_DKN_PAS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MV_DKN_MID_DT	EQU	$
		WORD	UT3D3A
		WORD	UT3D1B
		WORD	UT3D3C
;
;
MV_DKN_MID	EQU	$
		LDA	<XYCPBF
		INC	A
		CMP	#00003
		BCC	MV_DKN_MID_000
		LDA	#00000
MV_DKN_MID_000	EQU	$
		STA	<XYCPBF
		ASL	A
		TAY
		LDA	MV_DKN_MID_DT,Y
		BRA	MV_DKN_PAS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MV_DKN_DWN_DT	EQU	$
		WORD	UT0115
		WORD	UT7D27
		WORD	UT3D3E
;
;
MV_DKN_DWN	EQU	$
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		ASL	A
		TAY
		LDA	MV_DKN_DWN_DT,Y
MV_DKN_PAS	EQU	$
		CLC
		ADC	<XSIZE
		RTS
;
		MEM8
		IDX8
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKNUPST		( 土管上ユニットセット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKNUPDT		EQU	$
		WORD	UT7916,UT7917
		WORD	UT77B0,UT77B1
;
;
DKNUPST		EQU	$
		LDA	!BG1TYP
		CMP	#00BH
		BEQ	DKNUPST_000
		JMP	>HBLOCK		;たまごに変身するブロック セット
;
DKNUPST_000	EQU	$
		MI16			; memory,index 16 bit mode !!
		LDY	#00000
		LDA	<XSIZE
		CMP	#00002
		BCC	DKNUPST_050	; ユニット最初　？
;					; No !!
		LDY	#00004
		INC	A
		STA	<WORK0
		LDA	<XSIZECP
		SEC
		SBC	<WORK0
		CMP	#00002
		BCS	DKNUPST_050	; ユニット最後　？
;					; Yes !!
		LDY	#00002
;
DKNUPST_050	EQU	$
		STY	<WORK2
;
DKNUPST_100	EQU	$
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
;
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	!DKNUPDT,Y
		STA	<WORK0
;
		JSR	DKNCHEK
;
		LDA	<WORK0
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKNDNST		 ( 土管下ユニットセット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKNDNDT		EQU	$
		WORD	UT77B6,UT77B7
		WORD	UT7926,UT7927
;
;
DKNDNST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<XSIZE
		CMP	#00002
		BCC	DKNDNST_050	; ユニット最初　？
;					; No !!
		LDY	#00004
		INC	A
		STA	<WORK0
		LDA	<XSIZECP
		SEC
		SBC	<WORK0
		CMP	#00002
		BCS	DKNDNST_050	; ユニット最後　？
;					; Yes !!
		LDY	#00002
;
DKNDNST_050	EQU	$
		STY	<WORK2
;
DKNDNST_100	EQU	$
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
;
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	!DKNDNDT,Y
		STA	<WORK0
;
		JSR	DKNCHEK
;
		LDA	<WORK0
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKNLFST		( 土管左ユニットセット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKNLFDT		EQU	$
		WORD	UT7910,UT77A0
		WORD	UT7920,UT77A1
;
;
DKNLFST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<YSIZE
		CMP	#00002
		BCC	DKNLFST_050	; ユニット最初　？
;					; No !!
		LDY	#00004
		INC	A
		STA	<WORK0
		LDA	<YSIZECP
		SEC
		SBC	<WORK0
		CMP	#00002
		BCS	DKNLFST_050	; ユニット最後　？
;					; Yes !!
		LDY	#00002
;
DKNLFST_050	EQU	$
		STY	<WORK2
;
DKNLFST_100	EQU	$
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
;
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	!DKNLFDT,Y
		STA	<WORK0
;
		JSR	DKNCHEK
;
		LDA	<WORK0
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKNRIST		( 土管右ユニットセット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKNRIDT		EQU	$
		WORD	UT77A6,UT7911
		WORD	UT77A7,UT7921
;
;
DKNRIST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<YSIZE
		CMP	#00002
		BCC	DKNRIST_050	; ユニット最初　？
;					; No !!
		LDY	#00004
		INC	A
		STA	<WORK0
		LDA	<YSIZECP
		SEC
		SBC	<WORK0
		CMP	#00002
		BCS	DKNRIST_050	; ユニット最後　？
;					; Yes !!
		LDY	#00002
;
DKNRIST_050	EQU	$
		STY	<WORK2
;
DKNRIST_100	EQU	$
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
;
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	!DKNRIDT,Y
		STA	<WORK0
;
		JSR	DKNCHEK
;
		LDA	<WORK0
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		JSR	DKNCHEK ( 土管ユニットチェックサブルーチン )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		MEM16
		IDX16
;
;
CHEKDAT		EQU	$
		WORD	UT7916,UT7917,UT7926,UT7927,UT7910,UT7920,UT7911,UT7921
		WORD	UT77B0,UT77B1,UT77B6,UT77B7,UT77A0,UT77A1,UT77A6,UT77A7
;
CHEKAR1		EQU	$
		WORD	CHEKDT0
		WORD	CHEKDT0
		WORD	CHEKDT1
		WORD	CHEKDT1
		WORD	CHEKDT0
		WORD	CHEKDT0
		WORD	CHEKDT1
		WORD	CHEKDT1
;
CHEKAR2		EQU	$
		WORD	CHEKED0
		WORD	CHEKED1
		WORD	CHEKED2
		WORD	CHEKED3
		WORD	CHEKED4
		WORD	CHEKED5
		WORD	CHEKED6
		WORD	CHEKED7
;
CHEKDT0		EQU	$
		WORD	UT7910,UT7920,UT7911,UT7921,UT77A0,UT77A1,UT77A6,UT77A7
;
CHEKDT1		EQU	$
		WORD	UT7916,UT7917,UT7926,UT7927,UT77B0,UT77B1,UT77B6,UT77B7
;
;
CHEKED0		EQU	$
		WORD	UT7932,UT792D,UT792D,00000H,UT792C,UT7932,UT792C,00000H
		WORD	UT792F,00000H,00000H,00000H,00000H,UT792E,00000H,00000H
;
CHEKED1		EQU	$
		WORD	UT7932,UT791D,UT791D,00000H,UT791C,UT7932,UT791C,00000H
		WORD	UT791F,00000H,00000H,00000H,00000H,UT791E,00000H,00000H
;
CHEKED2		EQU	$
		WORD	UT7932,UT792D,UT792D,00000H,UT791D,UT7932,UT791D,00000H
		WORD	UT792F,00000H,00000H,00000H,00000H,UT791F,00000H,00000H
;
CHEKED3		EQU	$
		WORD	UT7932,UT792C,UT792C,00000H,UT791C,UT7932,UT791C,00000H
		WORD	UT792E,00000H,00000H,00000H,00000H,UT791E,00000H,00000H
;
CHEKED4		EQU	$
		WORD	UT792F,0FFFFH,0FFFFH,0FFFFH,0FFFFH,UT792E,0FFFFH,0FFFFH
		WORD	UT5D30,UT77C0,UT77C0,00000H,UT77D3,UT5B31,UT77D3,00000H
;
CHEKED5		EQU	$
		WORD	UT791F,0FFFFH,0FFFFH,0FFFFH,0FFFFH,UT791E,0FFFFH,0FFFFH
		WORD	UT0A52,UT77C2,UT77C2,00000H,UT77C1,UT0850,UT77C1,00000H
;
CHEKED6		EQU	$
		WORD	UT792F,0FFFFH,0FFFFH,0FFFFH,0FFFFH,UT791F,0FFFFH,0FFFFH
		WORD	UT5D30,UT77C0,UT77C0,00000H,UT77C2,UT0A52,UT77C2,00000H
;
CHEKED7		EQU	$
		WORD	UT792E,0FFFFH,0FFFFH,0FFFFH,0FFFFH,UT791E,0FFFFH,0FFFFH
		WORD	UT5B31,UT77D3,UT77D3,00000H,UT77C1,UT0850,UT77C1,00000H
;
;
DKNCHEK		EQU	$
		LDA	<NOWUNIT
		BEQ	DKNCHEK_END	; ユニットをひいている　？
;					; Yes !!
		LDY	#(CHEKAR1-CHEKDAT)-2
		LDA	<WORK0
;
DKNCHEK_050	EQU	$
		CMP	!CHEKDAT,Y
		BEQ	DKNCHEK_100
;
		DEY
		DEY
		BRA	DKNCHEK_050
;
DKNCHEK_100	EQU	$
		TYA
		LSR	A
		AND	#0000EH
		TAY
		LDA	!CHEKAR1,Y
		STA	<WORK4
		LDA	!CHEKAR2,Y
		STA	<WORK6
		LDY	#(CHEKDT1-CHEKDT0)-2
		LDA	<NOWUNIT
;
DKNCHEK_150	EQU	$
		CMP	(<WORK4),Y
		BEQ	DKNCHEK_200
;
		DEY
		DEY
		BPL	DKNCHEK_150
;
		BRA	DKNCHEK_END
;
DKNCHEK_200	EQU	$
		TYA
		AND	#0000CH
		ASL	A
		ORA	<WORK2
		TAY
		LDA	(<WORK6),Y
		CMP	#0FFFFH
		BEQ	DKNCHEK_END
;
		CMP	#00000
		BNE	DKNCHEK_250
;
		LDA	<NOWUNIT
;
DKNCHEK_250	EQU	$
		STA	<WORK0
;
DKNCHEK_END	EQU	$
		LDX	<UNITPOS
		RTS
;
;
		MEM8
		IDX8
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKNTTST		( 土管の中縦模様セット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKNTTDT		EQU	$
		WORD	UT77A2,UT77A4
		WORD	UT77A3,UT77A5
;
;
DKNTTST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
;
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDX	<UNITPOS
		LDA	!DKNTTDT,Y
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKNYKST		( 土管の中横模様セット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKNYKDT		EQU	$
		WORD	UT77B2,UT77B3
		WORD	UT77B4,UT77B5
;
;
DKNYKST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<XSIZE
		AND	#00001
		ASL	A
		STA	<WORK0
;
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDX	<UNITPOS
		LDA	!DKNYKDT,Y
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKNTYST		( 土管の中縦横模様セット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKNTYDT		EQU	$
		WORD	UT77B2,UT77B2,UT77B3,UT77D5
		WORD	UT77A2,UT77A4,UT77A5,UT77A4
		WORD	UT77A3,UT77B4,UT77B5,UT77B4
		WORD	UT77D5,UT77A4,UT77A5,UT77A4
;
;
DKNTYST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<XSIZE
		BEQ	DKNTYST_050
;
		LDY	#00006
		INC	A
		CMP	<XSIZECP
		BEQ	DKNTYST_050
;
		LDA	<XSIZE
		AND	#00001
		ASL	A
		CLC
		ADC	#00002
		TAY
;
DKNTYST_050	EQU	$
		STY	<WORK0
;
		LDY	#00000
		LDA	<YSIZE
		BEQ	DKNTYST_100
;
		LDY	#00018H
		INC	A
		CMP	<YSIZECP
		BEQ	DKNTYST_100
;
		LDA	<YSIZE
		AND	#00001
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	#00008
		TAY
;
DKNTYST_100	EQU	$
		TYA
		ORA	<WORK0
		TAY
		LDA	<NOWUNIT
		BNE	DKNTYST_150
;
		LDX	<UNITPOS
		LDA	!DKNTYDT,Y
		STA	>BGUNIT,X
;
DKNTYST_150	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;****************************************************************
;*								*
;*		土管の半当たりのユニットセット			*
;*								*
;****************************************************************
DKNHN_CMP	EQU	$
		WORD	UT77C0,UT77C2,UT77D0,UT77D3
		WORD	UT8100,UT8101,UT8102,UT8103
		WORD	UT8550,UT8551,UT8552,UT8553
;
DKNHN_DT0	EQU	$
		WORD	UT151E,UT151E,UT151E,UT151E
		WORD	UT151C,UT151C,UT151C,UT151C
		WORD	UT1523,UT1524,UT1524,UT1524
;
DKNHN_DT1	EQU	$
		WORD	UT1518,UT1519,UT151A,UT151B
		WORD	00000H,00000H,00000H,00000H
		WORD	UT1518,UT1519,UT151D,UT151B
;
;
DKNHNST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<NOWUNIT
		CMP	#UT77C0
		BCC	DKNHNST_500
;
		LDY	#00000H
DKNHNST_150	EQU	$
		CMP	DKNHN_CMP,Y
		BEQ	DKNHNST_200
		INY
		INY
		CPY	#DKNHN_DT0-DKNHN_CMP
		BCC	DKNHNST_150
		BRA	DKNHNST_990
;
DKNHNST_200	EQU	$
		LDA	DKNHN_DT0,Y
		BRA	DKNHNST_900
;
DKNHNST_500	EQU	$
		SEC
		SBC	#UT77A0
		AND	#0000EH
		TAY
		LDA	DKNHN_DT1,Y
;
DKNHNST_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
DKNHNST_990	EQU	$
		MI8			; memory,index 8 bit mode !!
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKRIUP0		( 土管右上がりユニットセット 縦３ )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKRIUD0		EQU	$
		WORD	UT792F,UT5D30,UT77C0,UT77B2
;
DKRIUP0		EQU	$
DKRIUP2		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		BNE	DKRIUP0_050
;
		LDX	<UNITPOS
		LDA	!DKRIUD0,Y
		STA	>BGUNIT,X
;
DKRIUP0_050	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKRIUP1		( 土管右上がりユニットセット 縦３ )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKRIUD1		EQU	$
		WORD	UT77C1,UT0850,UT791E
;
;
DKRIUP1		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		BNE	DKRIUP1_050
;
		LDX	<UNITPOS
		LDA	!DKRIUD1,Y
		STA	>BGUNIT,X
;
DKRIUP1_050	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKRIUP3		( 土管右上がりユニットセット 縦３ )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKRIUD2		EQU	$
		WORD	UT77B5,UT77C1,UT0850,UT791E
;
;
DKRIUP3		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		BNE	DKRIUP3_050
;
		LDX	<UNITPOS
		LDA	!DKRIUD2,Y
		STA	>BGUNIT,X
;
DKRIUP3_050	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKLFUP0		( 土管左上がりユニットセット 縦３ )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKLFUD0		EQU	$
		WORD	UT792E,UT5B30,UT77D0,UT77B3
;
;
DKLFUP0		EQU	$
DKLFUP2		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		BNE	DKLFUP0_150
;
		LDA	!DKLFUD0,Y
		STA	<WORK2
		CMP	#UT5B30
		BNE	DKLFUP0_100
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT77A6
		BEQ	DKLFUP0_050
;
		CMP	#UT77A7
		BNE	DKLFUP0_100
;
DKLFUP0_050	EQU	$
		LDA	#UT5B31
		STA	<WORK2
;
DKLFUP0_100	EQU	$
		LDX	<UNITPOS
		LDA	<WORK2
		STA	>BGUNIT,X
;
DKLFUP0_150	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKLFUP1		( 土管左上がりユニットセット 縦３ )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKLFUD2		EQU	$
		WORD	UT77D1,UT0A51,UT791F
;
;
DKLFUP1		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		BNE	DKLFUP1_150
;
		LDA	!DKLFUD2,Y
		STA	<WORK2
		CMP	#UT0A51
		BNE	DKLFUP1_100
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT77A0
		BEQ	DKLFUP1_050
;
		CMP	#UT77A1
		BNE	DKLFUP1_100
;
DKLFUP1_050	EQU	$
		LDA	#UT0A52
		STA	<WORK2
;
DKLFUP1_100	EQU	$
		LDX	<UNITPOS
		LDA	<WORK2
		STA	>BGUNIT,X
;
DKLFUP1_150	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKLFUP3		( 土管左上がりユニットセット 縦４ )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKLFUD4		EQU	$
		WORD	UT77B4,UT77D1,UT0A51,UT791F
;
;
DKLFUP3		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		ASL	A
		TAY
		LDA	<NOWUNIT
		BNE	DKLFUP3_150
;
		LDA	!DKLFUD4,Y
		STA	<WORK2
		CMP	#UT0A51
		BNE	DKLFUP3_100
;
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT77A0
		BEQ	DKLFUP3_050
;
		CMP	#UT77A1
		BNE	DKLFUP3_100
;
DKLFUP3_050	EQU	$
		LDA	#UT0A52
		STA	<WORK2
;
DKLFUP3_100	EQU	$
		LDX	<UNITPOS
		LDA	<WORK2
		STA	>BGUNIT,X
;
DKLFUP3_150	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DUPENST		( 土管上行き止まりユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DUPENDT		EQU	$
		WORD	UT7930,UT7916,UT7917,UT7931
;
;
DUPENST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<XSIZE
		BEQ	DUPENST_050
;
		LDY	#00006
		INC	A
		CMP	<XSIZECP
		BEQ	DUPENST_050
;
		DEC	A
		AND	#00001
		ASL	A
		CLC
		ADC	#00002
		TAY
;
DUPENST_050	EQU	$
		LDX	<UNITPOS
		LDA	!DUPENDT,Y
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DDNENST		( 土管下行き止まりユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DDNENDT		EQU	$
		WORD	UT7933,UT7926,UT7927,UT7934
;
;
DDNENST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<XSIZE
		BEQ	DDNENST_050
;
		LDY	#00006
		INC	A
		CMP	<XSIZECP
		BEQ	DDNENST_050
;
		DEC	A
		AND	#00001
		ASL	A
		CLC
		ADC	#00002
		TAY
;
DDNENST_050	EQU	$
		LDX	<UNITPOS
		LDA	!DDNENDT,Y
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DLFENST		( 土管左行き止まりユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DLFENDT		EQU	$
		WORD	UT7930,UT7910,UT7920,UT7933
;
;
DLFENST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<YSIZE
		BEQ	DLFENST_050
;
		LDY	#00006
		INC	A
		CMP	<YSIZECP
		BEQ	DLFENST_050
;
		DEC	A
		AND	#00001
		ASL	A
		CLC
		ADC	#00002
		TAY
;
DLFENST_050	EQU	$
		LDX	<UNITPOS
		LDA	!DLFENDT,Y
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DRIENST		( 土管右行き止まりユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DRIENDT		EQU	$
		WORD	UT7931,UT7911,UT7921,UT7934
;
;
DRIENST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#00000
		LDA	<YSIZE
		BEQ	DRIENST_050
;
		LDY	#00006
		INC	A
		CMP	<YSIZECP
		BEQ	DRIENST_050
;
		DEC	A
		AND	#00001
		ASL	A
		CLC
		ADC	#00002
		TAY
;
DRIENST_050	EQU	$
		LDX	<UNITPOS
		LDA	!DRIENDT,Y
		STA	>BGUNIT,X
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKWHSST		( 土管配水管ユニットセット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKWHSD0		EQU	$
		WORD	UT77A0,UT77A1,UT77A2,UT77A3,UT77A4,UT77A5,UT77A6,UT77A7
		WORD	UT77A8,UT77A9,UT77AA,UT77AB,UT77AC,UT77AD,UT77AE,UT77AF
		WORD	UT77B0,UT77B1,UT77B2,UT77B3,UT77B4,UT77B5,UT77B6,UT77B7
		WORD	UT77B8,UT77B9,UT77BA,UT77BB,UT77BC,UT77BD,UT77BE,UT77BF
		WORD	UT77C0,UT77C1,UT77C2,UT77C5,UT77D0,UT77D1,UT77D3,UT77D5
		WORD	UT8550,UT8551,UT8552,UT8553
;
DKWHSD1		EQU	$
		WORD	UT77D6,UT77D6,UT77D6,UT77D6,UT77CF,UT77CF,UT77CF,UT77CF
		WORD	UT77D6,UT77D6,UT77CF,UT77CF,UT77D6,UT77D6,UT77CF,UT77CF
		WORD	UT77D6,UT77D6,UT77D6,UT77D6,UT77CF,UT77CF,UT77CF,UT77CF
		WORD	UT77D6,UT77D6,UT77CF,UT77CF,UT77D6,UT77D6,UT77CF,UT77CF
		WORD	UT77D6,UT77CF,UT77D6,UT77D6,UT77D6,UT77CF,UT77D6,UT77D6
		WORD	UT8554,UT8554,UT8554,UT8554
;
DKWHSD2		EQU	$
		WORD	UT7926,UT7927,UT7928,UT7929,UT792A,UT792B,UT791C,UT791D
		WORD	UT7966,UT7967,UT796A,UT796C,UT796D,UT796E,UT7971,UT7973
		WORD	UT797C,UT797D,UT7980,UT7981,UT7937,UT7938,UT793A,UT793C
;
DKWHSD3		EQU	$
		WORD	UT7806,UT7807,UT7808,UT7809,UT780A,UT780B,UT780C,UT780D
		WORD	UT780E,UT780F,UT7810,UT7811,UT7812,UT7813,UT7814,UT7815
		WORD	UT7816,UT7817,UT7818,UT7819
;
DKWHSD4		EQU	$
		WORD	UT1518,UT1519,UT151A,UT151B,UT151D,UT151E
;
DKWHSDE		EQU	$
;
;
DKWHSST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		BNE	DKWHSST_150	; 最初のユニット　？
;					; Yes !!
		LDY	#(DKWHSD1-DKWHSD0)-2
		LDA	<NOWUNIT
;
DKWHSST_050	EQU	$
		CMP	!DKWHSD0,Y
		BEQ	DKWHSST_100	; 該当するものがあった　？
;					; No !!
		DEY
		DEY
		BPL	DKWHSST_050	; チェック終わり　？
;					; Yes !!
		BRA	DKWHSST_END
;
DKWHSST_100	EQU	$
		LDA	!DKWHSD1,Y
		BRA	DKWHSST_500
;
DKWHSST_150	EQU	$
		INC	A
		INC	A
		CMP	<YSIZECP
		BNE	DKWHSST_200	; 床の上　？
;					; Yes !!
		LDY	#(DKWTTD1-DKWTTD0)-2
		LDA	<NOWUNIT
;
DKWHSST_270	EQU	$
		CMP	!DKWTTD0,Y
		BEQ	DKWHSST_280
;
		DEY
		DEY
		BPL	DKWHSST_270
;
		LDA	#UT8103
		BRA	DKWHSST_500
;
DKWHSST_280	EQU	$
		LDA	!DKWTTD1,Y
		BRA	DKWHSST_500
;
DKWHSST_200	EQU	$
		DEC	A
		CMP	<YSIZECP
		BNE	DKWHSST_350	; 最後のユニット　？
;					; Yes !!
		LDY	#(DKWHSD3-DKWHSD2)-2
		LDA	<NOWUNIT
;
DKWHSST_250	EQU	$
		CMP	!DKWHSD2,Y
		BEQ	DKWHSST_300	; 該当するものがあった　？
;					; No !!
		DEY
		DEY
		BPL	DKWHSST_250	; チェック終わり　？
;					; Yes !!
		BRA	DKWHSST_END
;
DKWHSST_300	EQU	$
		LDA	!DKWHSD3,Y
		BRA	DKWHSST_500
;
DKWHSST_350	EQU	$
		LDY	#(DKWHSDE-DKWHSD4)-2
		LDA	<NOWUNIT
;
DKWHSST_400	EQU	$
		CMP	!DKWHSD4,Y
		BEQ	DKWHSST_450	; 該当するものがあった　？
;					; No !!
		DEY
		DEY
		BPL	DKWHSST_400	; チェック終わり　？
;					; Yes !!
		LDA	#UT8101
		BRA	DKWHSST_500
;
DKWHSST_450	EQU	$
		LDA	#UT151C
;
DKWHSST_500	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
DKWHSST_END	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKWTTST		( 土管の中の滝ユニットセット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKWTTD0		EQU	$
		WORD	UT7926,UT7927,UT7928,UT7929,UT792A,UT792B,UT791C,UT791D
		WORD	UT0850,UT0851,UT0A50,UT0A51,UT0A52,UT0A53
;
DKWTTD1		EQU	$
		WORD	UT7806,UT7807,UT7808,UT7809,UT780A,UT780B,UT780C,UT780D
		WORD	UT7F01,UT7F01,UT8001,UT8001,UT8001,UT8001
;
;
DKWTTST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		BNE	DKWTTST_050	; 最初のユニット　？
;					; Yes !!
		LDY	#UT77C6
		LDA	<NOWUNIT
		CMP	#UT77C1
		BEQ	DKWTTST_040	; 左に流れている　？
;					; No !!
		LDY	#UT77C7
		AND	#0FF00H
		CMP	#UT8500
		BNE	DKWTTST_040
		JMP	DKWTTST_END	; セットしない !!
;
DKWTTST_040	EQU	$
		JMP	DKWTTST_600
;
DKWTTST_050	EQU	$
		CMP	#00001
		BNE	DKWTTST_100	; ２番目のユニット　？
;					; Yes !!
		LDY	#UT8100
		LDA	<NOWUNIT
		CMP	#UT77A6
		BEQ	DKWTTST_040	; 左に流れている　？
;					; No !!
		CMP	#UT77A7
		BEQ	DKWTTST_600	; 左に流れている　？
;					; No !!
		LDY	#UT151C
		CMP	#UT1518
		BEQ	DKWTTST_600
;
		CMP	#UT151B
		BEQ	DKWTTST_600
;
		LDY	#UT8102
		BRA	DKWTTST_600
;
DKWTTST_100	EQU	$
		INC	A
		CMP	<YSIZECP
		BNE	DKWTTST_250	; 最後のユニット　？
;					; Yes !!
		LDY	#(DKWTTD1-DKWTTD0)-2
		LDA	<NOWUNIT
;
DKWTTST_150	EQU	$
		CMP	!DKWTTD0,Y
		BEQ	DKWTTST_200
;
		DEY
		DEY
		BPL	DKWTTST_150
;
		LDY	#(DKWHSD3-DKWHSD2)-2
;
DKWTTST_170	EQU	$
		CMP	!DKWHSD2,Y
		BEQ	DKWTTST_180	; 該当するものがあった　？
;					; No !!
		DEY
		DEY
		BPL	DKWTTST_170	; チェック終わり　？
;					; Yes !!
		BRA	DKWTTST_500
;
DKWTTST_180	EQU	$
		LDA	!DKWHSD3,Y
		TAY
		BRA	DKWTTST_600
;
DKWTTST_200	EQU	$
		LDA	!DKWTTD1,Y
		TAY
		BRA	DKWTTST_600
;
DKWTTST_250	EQU	$
		INC	A
		CMP	<YSIZECP
		BNE	DKWTTST_400	; 最後から二番目のユニット　？
;					; Yes !!
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDY	#(DKWHSD3-DKWHSD2)-2
		LDA	>BGUNIT,X
;
DKWTTST_300	EQU	$
		CMP	!DKWHSD2,Y
		BEQ	DKWTTST_350
;
		DEY
		DEY
		BPL	DKWTTST_300
;
		LDY	#UT8101
		BRA	DKWTTST_600
;
DKWTTST_350	EQU	$
;;;;;;;;		LDA	!DKWHSD3,Y
;;;;;;;;		TAY
		LDY	#UT8103
		BRA	DKWTTST_600
;
DKWTTST_400	EQU	$
		LDY	#(DKWHSDE-DKWHSD4)-2
		LDA	<NOWUNIT
;
DKWTTST_450	EQU	$
		CMP	!DKWHSD4,Y
		BEQ	DKWTTST_550
;
		DEY
		DEY
		BPL	DKWTTST_450
;
DKWTTST_500	EQU	$
		LDY	#UT8101
		BRA	DKWTTST_600
;
DKWTTST_550	EQU	$
		LDY	#UT151C
;
DKWTTST_600	EQU	$
		LDX	<UNITPOS
		TYA
		STA	>BGUNIT,X
;
DKWTTST_END	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKWLFST		( 土管で左に流れる川ユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKWLFD0		EQU	$
		WORD	UT77B6,UT77B7,UT77BB,UT77BF,UT77CD,UT77CE,UT0850,UT0A51
		WORD	UT0A52,UT8550,UT8551,UT8552,UT8553
;
DKWLFD1		EQU	$
		WORD	UT77C9,UT77CA,UT77D9,UT77DA,UT77DD,UT77DE,UT0851,UT0A50
		WORD	UT0A53,UT8560,UT8561,UT8562,UT8563
;
DKWLFD2		EQU	$
		WORD	UT8200,UT8201,UT8202,UT8203,UT8204,UT8205,UT8206,UT8207
		WORD	UT8208,UT8209,UT820A,UT820B,UT820C,UT820D,UT820E,UT820F
		WORD	UT8210,UT8211,UT8212,UT8213,UT8215,UT8215,UT8214,UT8214
;
;
DKWLFST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDX	<UNITPOS
		LDA	<YSIZE
		BNE	DKWLFST_250	; 床書換え　？
;
		LDA	<NOWUNIT
		CMP	#UT854F
		BNE	DKWLFST_020
		LDA	#UT8556
		BRA	DKWLFST_400
;
DKWLFST_020	EQU	$
		LDA	<XSIZE
		BNE	DKWLFST_050	; 最初のユニット　？
;					; Yes !!
		JSR	LEFT_CHK	; 左ブロック チェック
		LDX	<UNITPOS
		CMP	#UT8101
		BNE	DKWLFST_100
;
		LDA	<NOWUNIT
		SEC
		SBC	#UT8550
		CMP	#00004
		BCS	DKWLFST_030
		CLC
		ADC	#UT855C
		BRA	DKWLFST_400
;
DKWLFST_030	EQU	$
		LDA	#UT77F4
		BRA	DKWLFST_400
;
DKWLFST_050	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	#UT8101
		BNE	DKWLFST_100
;
		LDA	<NOWUNIT
		SEC
		SBC	#UT8550
		CMP	#00004
		BCS	DKWLFST_080
		CLC
		ADC	#UT8570
		BRA	DKWLFST_400
;
DKWLFST_080	EQU	$
		LDA	#UT77D7
		BRA	DKWLFST_400
;
DKWLFST_100	EQU	$
		LDY	#(DKWLFD1-DKWLFD0)-2
		LDA	<NOWUNIT
;
DKWLFST_150	EQU	$
		CMP	!DKWLFD0,Y
		BEQ	DKWLFST_200
;
		DEY
		DEY
		BPL	DKWLFST_150
;
		BRA	DKWLFST_END
;
DKWLFST_200	EQU	$
		LDA	!DKWLFD1,Y
		BRA	DKWLFST_400
;
DKWLFST_250	EQU	$
		LDY	#(DKWHSD3-DKWHSD2)-2
		LDA	<NOWUNIT
;
DKWLFST_300	EQU	$
		CMP	!DKWHSD2,Y
		BEQ	DKWLFST_350
;
		DEY
		DEY
		BPL	DKWLFST_300
;
		BRA	DKWLFST_END
;
DKWLFST_350	EQU	$
		LDA	!DKWLFD2,Y
;
DKWLFST_400	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
DKWLFST_END	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKWRIST		( 土管で右に流れる川ユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKWRID1		EQU	$
		WORD	UT77CB,UT77CC,UT77DC,UT77DB,UT77DD,UT77DE,UT0851,UT0A50
		WORD	UT0A53,UT8564,UT8565,UT8566,UT8567
;
DKWRID2		EQU	$
		WORD	UT8300,UT8301,UT8302,UT8303,UT8304,UT8305,UT8306,UT8307
		WORD	UT8308,UT8309,UT830A,UT830B,UT830C,UT830D,UT830E,UT830F
		WORD	UT8310,UT8311,UT8312,UT8313,UT8315,UT8315,UT8314,UT8314
;
;
DKWRIST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDX	<UNITPOS
		LDA	<YSIZE
		BNE	DKWRIST_250	; 床書換え　？
;					; No !!
		LDA	<NOWUNIT
		CMP	#UT854B
		BNE	DKWRIST_020
		LDA	#UT8557
		BRA	DKWRIST_400
;
DKWRIST_020	EQU	$
		LDA	<XSIZE
		BNE	DKWRIST_050	; 最初のユニット　？
;					; Yes !!
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT8101
		BNE	DKWRIST_100
;
		LDA	<NOWUNIT
		SEC
		SBC	#UT8550
		CMP	#00004
		BCS	DKWRIST_030
		CLC
		ADC	#UT8574
		BRA	DKWRIST_400
;
DKWRIST_030	EQU	$
		LDA	#UT77D8
		BRA	DKWRIST_400
;
DKWRIST_050	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	#UT8101
		BNE	DKWRIST_100
;
		LDA	<NOWUNIT
		SEC
		SBC	#UT8550
		CMP	#00004
		BCS	DKWRIST_080
		CLC
		ADC	#UT8558
		BRA	DKWRIST_400
;
DKWRIST_080	EQU	$
		LDA	#UT77D7
		BRA	DKWRIST_400
;
DKWRIST_100	EQU	$
		LDY	#(DKWLFD1-DKWLFD0)-2
		LDA	<NOWUNIT
;
DKWRIST_150	EQU	$
		CMP	!DKWLFD0,Y
		BEQ	DKWRIST_200
;
		DEY
		DEY
		BPL	DKWRIST_150
;
		BRA	DKWRIST_END
;
DKWRIST_200	EQU	$
		LDA	!DKWRID1,Y
		BRA	DKWRIST_400
;
DKWRIST_250	EQU	$
		LDY	#(DKWHSD3-DKWHSD2)-2
		LDA	<NOWUNIT
;
DKWRIST_300	EQU	$
		CMP	!DKWHSD2,Y
		BEQ	DKWRIST_350
;
		DEY
		DEY
		BPL	DKWRIST_300
;
		BRA	DKWRIST_END
;
DKWRIST_350	EQU	$
		LDA	!DKWRID2,Y
;
DKWRIST_400	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
DKWRIST_END	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKWLDST		( 土管で左下に流れる川ユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKWLDD0		EQU	$
		WORD	UT0850,UT0851
;
DKWLDST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#UT77C6
		LDA	<YSIZE
		BEQ	DKWLDST_150
;
		LDY	#(DKWLDST-DKWLDD0)-2
		LDA	<NOWUNIT
;
DKWLDST_050	EQU	$
		CMP	!DKWLDD0,Y
		BEQ	DKWLDST_100
;
		DEY
		DEY
		BPL	DKWLDST_050
;
		BRA	DKWLDST_END
;
DKWLDST_100	EQU	$
		LDY	#UT7F00
;
DKWLDST_150	EQU	$
		LDX	<UNITPOS
		TYA
		STA	>BGUNIT,X
;
DKWLDST_END	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKWRDST		( 土管で右下に流れる川ユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKWRDD0		EQU	$
		WORD	UT0A50,UT0A51,UT0A52,UT0A53
;
;
DKWRDST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDY	#UT77C7
		LDA	<YSIZE
		BEQ	DKWRDST_150
;
		LDY	#(DKWRDST-DKWRDD0)-2
		LDA	<NOWUNIT
;
DKWRDST_050	EQU	$
		CMP	!DKWRDD0,Y
		BEQ	DKWRDST_100
;
		DEY
		DEY
		BPL	DKWRDST_050
;
		BRA	DKWRDST_END
;
DKWRDST_100	EQU	$
		LDY	#UT8000
;
DKWRDST_150	EQU	$
		LDX	<UNITPOS
		TYA
		STA	>BGUNIT,X
;
DKWRDST_END	EQU	$
		LDA	#0FFFFH
		STA	<LKFLG
;
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;****************************************************************
;*								*
;*		はぬけセットコイン				*
;*					(横方向)		*
;****************************************************************
COINXPS		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		AND	#00001
		BEQ	COINPS_800
		BRA	COINPS_900
;
;
;****************************************************************
;*								*
;*		はぬけセットコイン				*
;*					(縦方向)		*
;****************************************************************
COINYPS		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		AND	#00001
		BEQ	COINPS_800
		BRA	COINPS_900
;
;
;****************************************************************
;*								*
;*		はぬけセットコイン				*
;*					(斜め方向)		*
;****************************************************************
COINNPS		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#0FFFFH
		STA	<LKFLG
		LDA	<XSIZE
		AND	#00001
		BEQ	COINPS_800
		BRA	COINPS_900
;
COINPS_800	EQU	$
		LDX	<UNITPOS
		JSL	>BGCOIN_SETCHK
		BNE	COINPS_900
		LDA	<STUNTNO
		AND	#00002
		TAY
		LDA	BGCOIN_DAT,Y
		STA	>BGUNIT,X
;
COINPS_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		DKWTRST		( 土管の中の水中ユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DKWTRD0		EQU	$
		WORD	00000H,00000H,UT77C3,UT77C3,UT77C4,UT77C4,00000H,00000H
		WORD	00000H,00000H,00000H,00000H,00000H,00000H,00000H,00000H
		WORD	00000H,00000H,UT77C3,UT77C3,UT77C4,UT77C4,00000H,00000H
		WORD	00000H,00000H,00000H,00000H,00000H,00000H,00000H,00000H
		WORD	UT77C3,UT77C4,UT77C3,UT77C3,UT77C3,UT77C4,UT77C3,UT77C3
		WORD	UT8578,UT8579,UT857A,UT857B
;
DKWTRD1		EQU	$
		WORD	00000H,00000H,UT77D2,UT77D2,UT77D4,UT77D4,00000H,00000H
		WORD	00000H,00000H,00000H,00000H,00000H,00000H,00000H,00000H
		WORD	00000H,00000H,UT77D2,UT77D2,UT77D4,UT77D4,00000H,00000H
		WORD	00000H,00000H,00000H,00000H,00000H,00000H,00000H,00000H
		WORD	UT77D2,UT77D4,UT77D2,UT77D2,UT77D2,UT77D4,UT77D2,UT77D2
		WORD	UT857C,UT857D,UT857E,UT857F
;
DKWTRAR		EQU	$
		WORD	DKWTRD0
		WORD	DKWTRD1
;
;
;
DKWTRST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDA	<YSIZE
		BNE	DKWTRST_050	; 最初の段のユニット　？
;					; Yes !!
		LDY	#UT8103
		LDA	<NOWUNIT
		CMP	#UT8101
		BEQ	DKWTRST_250	; 滝がある　？
;					; No !!
		JSR	LEFT_CHK	; 左ブロック チェック
		LDY	#00002
		CMP	#UT8103
		BEQ	DKWTRST_100	; 左に滝がある　？
;					; No !!
		JSR	RIGT_CHK	; 右ブロック チェック
		LDY	#00000
		CMP	#UT8103
		BEQ	DKWTRST_100	; 右に滝がある　？
;					; No !!
		CMP	#UT8101
		BEQ	DKWTRST_100
;
		BRA	DKWTRST_END
;
DKWTRST_050	EQU	$
		LDY	#UT1623
		CMP	#00001
		BEQ	DKWTRST_250	; ２段目のユニット　？
;					; No !!
		LDY	#UT1624
		BRA	DKWTRST_250
;
DKWTRST_100	EQU	$
		LDA	!DKWTRAR,Y
		STA	<WORK0
		LDY	#(DKWHSD1-DKWHSD0)-2
		LDA	<NOWUNIT
;
DKWTRST_150	EQU	$
		CMP	!DKWHSD0,Y
		BEQ	DKWTRST_200
;
		DEY
		DEY
		BPL	DKWTRST_150
;
		BRA	DKWTRST_END
;
DKWTRST_200	EQU	$
		LDA	(<WORK0),Y
		TAY
		BEQ	DKWTRST_END
;
DKWTRST_250	EQU	$
		LDX	<UNITPOS
		TYA
		STA	>BGUNIT,X
;
DKWTRST_END	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		KBRIUST		( 壁模様右上がりユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
KBRIUST_DT	EQU	$
		WORD	UT00DF,UT00DE,UT00D5
;
;
KBRIUST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDX	<UNITPOS
		LDY	#0000
		LDA	<YSIZE		; 最初のユニット　？
		BEQ	KBRIUST_050	;	YES -> KBRIUST_050
		INY
		INY
		CMP	#0FFFFH		; ２番目のユニット　？
		BEQ	KBRIUST_050	;	YES -> KBRIUST_050
		INY
		INY
;
KBRIUST_050	EQU	$
		LDA	KBRIUST_DT,Y
		CPY	#00000
		BNE	KBRIUST_100
;
		LDA	<NOWUNIT
		BNE	KBRIUST_150
;
KBRIUST_100	EQU	$
		LDA	KBRIUST_DT,Y
		STA	>BGUNIT,X
;
KBRIUST_150	EQU	$
		LDA	#00001
		STA	<LKFLG
;
		CPY	#00002H*2
		BCC	KBRIUST_500
		LDA	<XSIZE
		BNE	KBRIUST_600
		JSR	KBRIUST_0_SB
		BRA	KBRIUST_600
;
KBRIUST_500	EQU	$
		JSR	KBRIUST_5_SB
		BRA	KBRIUST_900
;
KBRIUST_600	EQU	$
		LDA	<YSIZE
		DEC	A
		CMP	<YSIZECP
		BNE	KBRIUST_900
		LDA	<NOWUNIT
		CMP	#UT00E8
		BNE	KBRIUST_630
		STZ	<XYCPBF
		BRA	KBRIUST_650
KBRIUST_630	EQU	$
		LDA	<XYPOINT
		PHA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		STA	<WORKE
		PLA
		AND	#0F0F0H
		ORA	<WORKE
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0160
		BCC	KBRIUST_650
		CMP	#UT016D+1
		BCS	KBRIUST_650
		LDA	#00003H*2
		STA	<XYCPBF
KBRIUST_650	EQU	$
		JSR	KBKABE_UP
;
KBRIUST_900	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		影のかどチェック ＆ セット		+
;+		左側チェック ＆ セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBRIUST_0_SB	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT0160
		BCC	KBRIUST_0_10
		CMP	#UT016D+1
		BCC	KBRIUST_0_50
KBRIUST_0_10	EQU	$
		LDA	<XYPOINT
		PHA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		STA	<WORKE
		PLA
		AND	#0F0F0H
		ORA	<WORKE
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0160
		BCC	KBRIUST_0_50
		CMP	#UT016D+1
		BCS	KBRIUST_0_50
		LDX	<UNITPOS
		LDA	#UT00DA
		STA	>BGUNIT,X
;
KBRIUST_0_50	EQU	$
		JSR	KBKABE_LF_KG
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+	右上がり斜め チェック ＆ セット			+
;+				in			+
;+				Y : read data index	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KBRIUST_5_SBD0	EQU	$
		WORD	UT77E5,UT77E4,UT77E2,UT77E3
;
KBRIUST_5_SBD1	EQU	$
		WORD	UT77EC,UT77EA,UT77ED,UT77EB
;
;
KBRIUST_5_SB	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0160
		BCC	KBRIUST_550
		CMP	#UT016D+1
		BCS	KBRIUST_550
		LDA	KBRIUST_5_SBD0,Y
		BRA	KBRIUST_590
;
KBRIUST_550	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT0160
		BCC	KBRIUST_599
		CMP	#UT016D+1
		BCS	KBRIUST_599
		LDA	KBRIUST_5_SBD1,Y
;
KBRIUST_590	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
KBRIUST_599	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		KBLFUST		( 壁模様左上がりユニットセット )	x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
KBLFUST_DT	EQU	$
		WORD	UT00DC,UT00DD,UT00D5
;
;
KBLFUST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDX	<UNITPOS
		LDY	#0000
		LDA	<YSIZE		; 最初のユニット　？
		BEQ	KBLFUST_050	;	YES -> KBLFUST_050
		INY
		INY
		CMP	#0FFFFH		; ２番目のユニット　？
		BEQ	KBLFUST_050	;	YES -> KBLFUST_050
		INY
		INY
;
KBLFUST_050	EQU	$
		LDA	KBLFUST_DT,Y
		CPY	#00000
		BNE	KBLFUST_100
;
		LDA	<NOWUNIT
		BNE	KBLFUST_150
;
KBLFUST_100	EQU	$
		LDA	KBLFUST_DT,Y
		STA	>BGUNIT,X
;
KBLFUST_150	EQU	$
		LDA	#00001
		STA	<LKFLG
;
		CPY	#00002H*2
		BCC	KBLFUST_500
		LDA	<XSIZE
		DEC	A
		CMP	<XSIZECP
		BNE	KBLFUST_600
		JSR	KBRIUST_0_SB
		BRA	KBLFUST_600
;
KBLFUST_500	EQU	$
		TYA
		ORA	#00004
		TAY
		JSR	KBRIUST_5_SB
		BRA	KBLFUST_900
;
KBLFUST_600	EQU	$
		LDA	<YSIZE
		DEC	A
		CMP	<YSIZECP
		BNE	KBLFUST_900
		LDA	<NOWUNIT
		CMP	#UT00E8
		BNE	KBLFUST_630
		BRA	KBLFUST_650
KBLFUST_630	EQU	$
		LDA	<XYPOINT
		PHA
		AND	#00F0FH
		DEC	A
		AND	#00F0FH
		STA	<WORKE
		PLA
		AND	#0F0F0H
		ORA	<WORKE
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0160
		BCC	KBLFUST_650
		CMP	#UT016D+1
		BCS	KBLFUST_650
		LDA	#00003H*2
		STA	<XYCPBF
		BRA	KBLFUST_680
KBLFUST_650	EQU	$
		STZ	<XYCPBF
KBLFUST_680	EQU	$
		JSR	KBKABE_UP
;
KBLFUST_900	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x		KBWAKST		( 壁模様枠付きユニットセット )		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
KBWAKST_DT	EQU	$
		WORD	UT00E9,UT00D5,UT00EA
;
KBWAKST_DT_SB	EQU	$
		WORD	UT77E0,00000H,UT77E1
;
;
KBWAKST		EQU	$
		MI16			; memory,index 16 bit mode !!
;
		LDX	<UNITPOS
		LDY	#00000
		LDA	<XSIZE		; 左枠のユニット　？
		BEQ	KBWAKST_050	;	YES -> KBWAKST_050
		INY
		INY
		INC	A
		CMP	<XSIZECP	; 右枠のユニット　？
		BNE	KBWAKST_050	;	YES -> KBWAKST_050
		INY
		INY
;
KBWAKST_050	EQU	$
		LDA	KBWAKST_DT,Y
		STA	>BGUNIT,X
;
		LDA	<YSIZE		; 影チェック ＆ セット ?
		BNE	KBWAKST_900	;	NO -> KBWAKST_900
		CPY	#00002
		BEQ	KBWAKST_200
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	>BGUNIT,X
		CMP	#UT0160
		BCC	KBWAKST_200
		CMP	#UT016D+1
		BCS	KBWAKST_200
KBWAKST_100	EQU	$
		LDX	<UNITPOS
		LDA	KBWAKST_DT_SB,Y
		STA	>BGUNIT,X
		LDA	#00003H*2
		STA	<XYCPBF
		BRA	KBWAKST_900
;
KBWAKST_200	EQU	$
		JSR	KBKABE_UP
;
KBWAKST_900	EQU	$
		MI8			; memory,index 8 bit mode !!
;
		RTL
;
;
;****************************************************************
;*								*
;*		花コース 第２ 左下 右下 ４５゜			*
;*								*
;****************************************************************
HANA_DWN45	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#0FFFFH
		STA	<LKFLG
		LDX	<UNITPOS
		LDA	<STUNTNO
		CLC
		ADC	#UT8700
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		花コース 第２ 左下 右下 ２２.５゜		*
;*								*
;****************************************************************
HANA_DWN22_DAT	EQU	$
		WORD	UT8702,UT8704
;
;
HANA_DWN22	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDY	<STUNTNO
		STZ	<LKFLG
		LDA	<XSIZE
		AND	#00001
		BEQ	HANA_DWN22_50
		DEC	<LKFLG
;
HANA_DWN22_50	EQU	$
		CLC
		ADC	HANA_DWN22_DAT,Y
		BRA	HANA_TT_YK
;
;
;****************************************************************
;*								*
;*		花コース 第２ 左下 右下 １０゜			*
;*								*
;****************************************************************
HANA_DWN10_DAT	EQU	$
		WORD	UT8706,UT870A
;
;
HANA_DWN10	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDY	<STUNTNO
		STZ	<LKFLG
		LDA	<XSIZE
		BPL	HANA_DWN10_10
		EOR	#0FFFFH
		INC	A
HANA_DWN10_10	EQU	$
		AND	#00003
		CMP	#00003
		BNE	HANA_DWN10_50
		DEC	<LKFLG
HANA_DWN10_50	EQU	$
		CLC
		ADC	HANA_DWN10_DAT,Y
		BRA	HANA_TT_YK
;
;
;****************************************************************
;*								*
;*		花コース 第２ 縦ライン				*
;*								*
;****************************************************************
HANA_TT		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#UT870F
		BRA	HANA_TT_YK
;
;
;****************************************************************
;*								*
;*		花コース 第２ 横ライン				*
;*								*
;****************************************************************
HANA_YK		EQU	$
		MI16			; memory , index 16bit mode
		LDA	#UT870E
;
HANA_TT_YK	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		ドカンコース 部屋のカベ				*
;*								*
;****************************************************************
DKN_ROMKB	EQU	$
		MI16			; memory , index 16bit mode
		JSR	DKN_ROOM_CHK
		CLC
		ADC	#UT8550
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+							+
;+		部屋のカベ セット チェック		+
;+				out			+
;+				A : set data index	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROOM_CHK	EQU	$
		LDA	<XYPOINT
		AND	#00003
		STA	<WORK0
		LDA	<YSIZE
		AND	#00001
		ASL	A
;;;;K;;;;		CLC
		ADC	<WORK0
		AND	#00003
;
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ドカンコース 部屋の左側 縦ワク			*
;*								*
;****************************************************************
DKN_ROMTWKL_ST	EQU	$
		WORD	DKN_ROMTWKL_00,DKN_ROMTWKL_99
;
DKN_ROMTWKL_DT	EQU	$
		WORD	UT7945,UT794B,UT7945,UT794B
		WORD	UT7944,UT794A,UT7940,UT7947
;
DKN_ROMTWKL_SB	EQU	$-4*2
		WORD	UT7943,UT7949,UT7932,UT7946
;
DKN_ROMTWKL_CP	EQU	$
		WORD	UT7916,UT7917
		WORD	UT77B0,UT77B1
		WORD	UT77B2,UT77B3
		WORD	UT77B4,UT77B5
		WORD	UT77B6,UT77B7
		WORD	UT7926,UT7927
;
DKN_ROMTWKL_CH	EQU	$
		WORD	UT7939,UT7939
		WORD	UT8548,UT8548
		WORD	UT8549,UT8549
		WORD	UT854A,UT854A
		WORD	UT854B,UT854B
		WORD	UT793A,UT793A
;
;
DKN_ROMTWKL	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000
		LDA	<YSIZE		;
		BEQ	DKN_ROMTWKL_100 ; スタート ｏｒ エンド セット ?
		INX			;	YES -> DKN_ROMTWKL_100
		INX			;	NO --> DKN_ROMTWKL_400
		INC	A		;
		CMP	<YSIZECP	;
		BNE	DKN_ROMTWKL_400 ;
DKN_ROMTWKL_100 EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(DKN_ROMTWKL_ST,X)
		BRA	DKN_ROMTWKL_900
;
DKN_ROMTWKL_400 EQU	$
		LDX	<UNITPOS
		LDY	#00000
		LDA	<NOWUNIT
DKN_ROMTWKL_440 EQU	$		;部屋の出入り口 チェック＆セット
		CMP	DKN_ROMTWKL_CP,Y
		BEQ	DKN_ROMTWKL_460
		INY
		INY
		CPY	#DKN_ROMTWKL_CH-DKN_ROMTWKL_CP
		BCC	DKN_ROMTWKL_440
		BRA	DKN_ROMTWKL_500
DKN_ROMTWKL_460 EQU	$
		STZ	<XYCPBF
		LDA	DKN_ROMTWKL_CH,Y
		BRA	DKN_ROMTWKL_780
;
DKN_ROMTWKL_500 EQU	$
		LDY	<XYCPBF
		BEQ	DKN_ROMTWKL_600
		JSR	DKN_ROMTWKL_50
		STZ	<XYCPBF
		BRA	DKN_ROMTWKL_900
;
DKN_ROMTWKL_600 EQU	$
		JSL	>RND_RND
		AND	#00007
		ASL	A
		TAY
		CPY	#00006H*2
		BCC	DKN_ROMTWKL_650
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		DEC	A
		BNE	DKN_ROMTWKL_650
		TYA
		AND	#00007
		TAY
DKN_ROMTWKL_650 EQU	$
		LDA	DKN_ROMTWKL_DT,Y
		STA	>BGUNIT,X
		CPY	#00004H*2	; １ユニット セット ?
		BCC	DKN_ROMTWKL_900 ;	YES -> DKN_ROMTWKL_900
		CPY	#00006H*2	; 横２ユニット セット ?
		BCC	DKN_ROMTWKL_700 ;	YES -> DKN_ROMTWKL_700
		STY	<XYCPBF
;
DKN_ROMTWKL_700 EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	DKN_ROMTWKL_SB,Y
DKN_ROMTWKL_780 EQU	$
		STA	>BGUNIT,X
;
DKN_ROMTWKL_900 EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側 縦ワクの端の上			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKL_00	EQU	$
		JSL	>UPCHK_SB
		LDA	#UT7984
		STA	>BGUNIT,X
;
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	#UT7985
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT7986
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側 縦ワクの端の下			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKL_99	EQU	$
		JSL	>DWNCHK_SB
		LDA	#UT798C
		STA	>BGUNIT,X
;
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	#UT798A
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT798B
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側 ４ユニットの下 セット		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKL_5_S EQU	$-6*2
		WORD	UT7942,UT7948
;
;
DKN_ROMTWKL_50	EQU	$
		LDX	<UNITPOS
		LDA	DKN_ROMTWKL_5_S,Y
		STA	>BGUNIT,X
		CPY	#00007H*2
		BCS	DKN_ROMTWKL_59
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	#UT7941
		STA	>BGUNIT,X
;
DKN_ROMTWKL_59	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ドカンコース 部屋の右側 縦ワク			*
;*								*
;****************************************************************
DKN_ROMTWKR_ST	EQU	$
		WORD	DKN_ROMTWKR_00,DKN_ROMTWKR_99
;
DKN_ROMTWKR_DT	EQU	$
		WORD	UT7951,UT7957,UT7951,UT7957
		WORD	UT794F,UT7955,UT7952,UT794C
;
DKN_ROMTWKR_SB	EQU	$-4*2
		WORD	UT7950,UT7956,UT7932,UT794D
;
DKN_ROMTWKR_CH	EQU	$
		WORD	UT793B,UT793B
		WORD	UT854C,UT854C
		WORD	UT854D,UT854D
		WORD	UT854E,UT854E
		WORD	UT854F,UT854F
		WORD	UT793C,UT793C
;
;
DKN_ROMTWKR	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000
		LDA	<YSIZE		;
		BEQ	DKN_ROMTWKR_100 ; スタート ｏｒ エンド セット ?
		INX			;	YES -> DKN_ROMTWKR_100
		INX			;	NO --> DKN_ROMTWKR_400
		INC	A		;
		CMP	<YSIZECP	;
		BNE	DKN_ROMTWKR_400 ;
DKN_ROMTWKR_100 EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(DKN_ROMTWKR_ST,X)
		BRA	DKN_ROMTWKR_900
;
DKN_ROMTWKR_400 EQU	$
		LDX	<UNITPOS
		LDY	#00000
		LDA	<NOWUNIT
DKN_ROMTWKR_440 EQU	$		;部屋の出入り口 チェック＆セット
		CMP	DKN_ROMTWKL_CP,Y
		BEQ	DKN_ROMTWKR_460
		INY
		INY
		CPY	#DKN_ROMTWKL_CH-DKN_ROMTWKL_CP
		BCC	DKN_ROMTWKR_440
		BRA	DKN_ROMTWKR_500
DKN_ROMTWKR_460 EQU	$
		STZ	<XYCPBF
		LDA	DKN_ROMTWKR_CH,Y
		BRA	DKN_ROMTWKR_780
;
DKN_ROMTWKR_500 EQU	$
		LDY	<XYCPBF
		BEQ	DKN_ROMTWKR_600
		JSR	DKN_ROMTWKR_50
		STZ	<XYCPBF
		BRA	DKN_ROMTWKR_900
;
DKN_ROMTWKR_600 EQU	$
		JSL	>RND_RND
		AND	#00007
		ASL	A
		TAY
		CPY	#00006H*2
		BCC	DKN_ROMTWKR_650
		LDA	<YSIZECP
		CLC
		SBC	<YSIZE
		DEC	A
		BNE	DKN_ROMTWKR_650
		TYA
		AND	#00007
		TAY
DKN_ROMTWKR_650 EQU	$
		LDA	DKN_ROMTWKR_DT,Y
		STA	>BGUNIT,X
		CPY	#00004H*2	; １ユニット セット ?
		BCC	DKN_ROMTWKR_900 ;	YES -> DKN_ROMTWKL_900
		CPY	#00006H*2	; 横２ユニット セット ?
		BCC	DKN_ROMTWKR_700 ;	YES -> DKN_ROMTWKL_700
		STY	<XYCPBF
;
DKN_ROMTWKR_700 EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	DKN_ROMTWKR_SB,Y
DKN_ROMTWKR_780 EQU	$
		STA	>BGUNIT,X
;
DKN_ROMTWKR_900 EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側 縦ワクの端の上			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKR_00	EQU	$
		JSL	>UPCHK_SB
		LDA	#UT7987
		STA	>BGUNIT,X
;
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	#UT7989
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT7988
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側 縦ワクの端の下			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKR_99	EQU	$
		JSL	>DWNCHK_SB
		LDA	#UT798F
		STA	>BGUNIT,X
;
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	#UT798E
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT798D
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側 ４ユニットの下 セット		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKR_5_S EQU	$-6*2
		WORD	UT7953,UT794E
;
;
DKN_ROMTWKR_50	EQU	$
		LDX	<UNITPOS
		LDA	DKN_ROMTWKR_5_S,Y
		STA	>BGUNIT,X
		CPY	#00007H*2
		BCS	DKN_ROMTWKR_59
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	#UT7954
		STA	>BGUNIT,X
;
DKN_ROMTWKR_59	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ドカンコース 部屋の上側 横ワク			*
;*								*
;****************************************************************
DKN_ROMTWKU_ST	EQU	$
		WORD	DKN_ROMTWKU_00,DKN_ROMTWKU_99
;
DKN_ROMTWKU_DT	EQU	$
		WORD	UT795E,UT7965,UT795E,UT7965
		WORD	UT795D,UT7964,UT795A,UT7961
;
DKN_ROMTWKU_SB	EQU	$-4*2
		WORD	UT795C,UT7963,UT7958,UT795F
;
DKN_ROMTWKU_CP	EQU	$
		WORD	UT7910,UT7920
		WORD	UT77A0,UT77A1
		WORD	UT77A2,UT77A3
		WORD	UT77A4,UT77A5
		WORD	UT77A6,UT77A7
		WORD	UT7911,UT7921
		WORD	UT77D5
;
DKN_ROMTWKU_CH	EQU	$
		WORD	UT7935,UT7935
		WORD	UT8540,UT8540
		WORD	UT8541,UT8541
		WORD	UT8542,UT8542
		WORD	UT8543,UT8543
		WORD	UT7936,UT7936
		WORD	UT8541
;
;
DKN_ROMTWKU	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000
		LDA	<XSIZE		;
		BEQ	DKN_ROMTWKU_100 ; スタート ｏｒ エンド セット ?
		INX			;	YES -> DKN_ROMTWKU_100
		INX			;	NO --> DKN_ROMTWKU_400
		INC	A		;
		CMP	<XSIZECP	;
		BNE	DKN_ROMTWKU_400 ;
DKN_ROMTWKU_100 EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(DKN_ROMTWKU_ST,X)
		BRA	DKN_ROMTWKU_900
;
DKN_ROMTWKU_400 EQU	$
		LDX	<UNITPOS
		LDY	#00000
		LDA	<NOWUNIT
DKN_ROMTWKU_440 EQU	$		;部屋の出入り口 チェック＆セット
		CMP	DKN_ROMTWKU_CP,Y
		BEQ	DKN_ROMTWKU_460
		INY
		INY
		CPY	#DKN_ROMTWKU_CH-DKN_ROMTWKU_CP
		BCC	DKN_ROMTWKU_440
		BRA	DKN_ROMTWKU_500
DKN_ROMTWKU_460 EQU	$
		STZ	<XYCPBF
		LDA	DKN_ROMTWKU_CH,Y
		BRA	DKN_ROMTWKU_780
;
DKN_ROMTWKU_500 EQU	$
		LDY	<XYCPBF
		BEQ	DKN_ROMTWKU_600
		JSR	DKN_ROMTWKU_50
		STZ	<XYCPBF
		BRA	DKN_ROMTWKU_900
;
DKN_ROMTWKU_600 EQU	$
		JSL	>RND_RND
		AND	#00007
		ASL	A
		TAY
		CPY	#00006H*2
		BCC	DKN_ROMTWKU_650
		LDA	<XSIZECP
		CLC
		SBC	<XSIZE
		DEC	A
		BNE	DKN_ROMTWKU_650
		TYA
		AND	#00007
		TAY
DKN_ROMTWKU_650 EQU	$
		LDA	DKN_ROMTWKU_DT,Y
		STA	>BGUNIT,X
		CPY	#00004H*2	; １ユニット セット ?
		BCC	DKN_ROMTWKU_900 ;	YES -> DKN_ROMTWKU_900
		CPY	#00006H*2	; 横２ユニット セット ?
		BCC	DKN_ROMTWKU_700 ;	YES -> DKN_ROMTWKU_700
		STY	<XYCPBF
;
DKN_ROMTWKU_700 EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	DKN_ROMTWKU_SB,Y
DKN_ROMTWKU_780 EQU	$
		STA	>BGUNIT,X
;
DKN_ROMTWKU_900 EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上側 横ワクの端の左			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKU_00	EQU	$
		JSL	>UPCHK_SB
		LDA	#UT7984
		STA	>BGUNIT,X
;
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	#UT7985
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT7986
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上側 横ワクの端の右			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKU_99	EQU	$
		JSL	>UPCHK_SB
		LDA	#UT7987
		STA	>BGUNIT,X
;
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	#UT7989
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT7988
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		上側 ４ユニットの右 セット		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKU_5_S EQU	$-6*2
		WORD	UT795B,UT7962
;
DKN_ROMTWKU_5_B EQU	$-6*2
		WORD	UT7959,UT7960
;
;
DKN_ROMTWKU_50	EQU	$
		LDX	<UNITPOS
		LDA	DKN_ROMTWKU_5_S,Y
		STA	>BGUNIT,X
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	DKN_ROMTWKU_5_B,Y
		STA	>BGUNIT,X
;
DKN_ROMTWKU_59	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		ドカンコース 部屋の下側 横ワク			*
;*								*
;****************************************************************
DKN_ROMTWKD_ST	EQU	$
		WORD	DKN_ROMTWKD_00,DKN_ROMTWKD_99
;
DKN_ROMTWKD_DT	EQU	$
		WORD	UT796C,UT7973,UT796C,UT7973
		WORD	UT796A,UT7971,UT7966,UT796D
;
DKN_ROMTWKD_SB	EQU	$-4*2
		WORD	UT796B,UT7972,UT7968,UT796F
;
DKN_ROMTWKD_CH	EQU	$
		WORD	UT7937,UT7937
		WORD	UT8544,UT8544
		WORD	UT8545,UT8545
		WORD	UT8546,UT8546
		WORD	UT8547,UT8547
		WORD	UT7938,UT7938
		WORD	UT8545
;
;
DKN_ROMTWKD	EQU	$
		MI16			; memory , index 16bit mode
		LDX	#00000
		LDA	<XSIZE		;
		BEQ	DKN_ROMTWKD_100 ; スタート ｏｒ エンド セット ?
		INX			;	YES -> DKN_ROMTWKD_100
		INX			;	NO --> DKN_ROMTWKD_400
		INC	A		;
		CMP	<XSIZECP	;
		BNE	DKN_ROMTWKD_400 ;
DKN_ROMTWKD_100 EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(DKN_ROMTWKD_ST,X)
		BRA	DKN_ROMTWKD_900
;
DKN_ROMTWKD_400 EQU	$
		LDX	<UNITPOS
		LDY	#00000
		LDA	<NOWUNIT
DKN_ROMTWKD_440 EQU	$		;部屋の出入り口 チェック＆セット
		CMP	DKN_ROMTWKU_CP,Y
		BEQ	DKN_ROMTWKD_460
		INY
		INY
		CPY	#DKN_ROMTWKU_CH-DKN_ROMTWKU_CP
		BCC	DKN_ROMTWKD_440
		BRA	DKN_ROMTWKD_500
DKN_ROMTWKD_460 EQU	$
		STZ	<XYCPBF
		LDA	DKN_ROMTWKD_CH,Y
		BRA	DKN_ROMTWKD_780
;
DKN_ROMTWKD_500 EQU	$
		LDY	<XYCPBF
		BEQ	DKN_ROMTWKD_600
		JSR	DKN_ROMTWKD_50
		STZ	<XYCPBF
		BRA	DKN_ROMTWKD_900
;
DKN_ROMTWKD_600 EQU	$
		JSL	>RND_RND
		AND	#00007
		ASL	A
		TAY
		CPY	#00006H*2
		BCC	DKN_ROMTWKD_650
		LDA	<XSIZECP
		CLC
		SBC	<XSIZE
		DEC	A
		BNE	DKN_ROMTWKD_650
		TYA
		AND	#00007
		TAY
DKN_ROMTWKD_650 EQU	$
		LDA	DKN_ROMTWKD_DT,Y
		STA	>BGUNIT,X
		CPY	#00004H*2	; １ユニット セット ?
		BCC	DKN_ROMTWKD_900 ;	YES -> DKN_ROMTWKD_900
		CPY	#00006H*2	; 横２ユニット セット ?
		BCC	DKN_ROMTWKD_700 ;	YES -> DKN_ROMTWKD_700
		STY	<XYCPBF
;
DKN_ROMTWKD_700 EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	DKN_ROMTWKD_SB,Y
DKN_ROMTWKD_780 EQU	$
		STA	>BGUNIT,X
;
DKN_ROMTWKD_900 EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下側 横ワクの端の左			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKD_00	EQU	$
		JSL	>DWNCHK_SB
		LDA	#UT798C
		STA	>BGUNIT,X
;
		JSR	LEFT_CHK	; 左ブロック チェック
		LDA	#UT798A
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT798B
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下側 横ワクの端の右			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKD_99	EQU	$
		JSL	>DWNCHK_SB
		LDA	#UT798F
		STA	>BGUNIT,X
;
		JSR	RIGT_CHK	; 右ブロック チェック
		LDA	#UT798E
		STA	>BGUNIT,X
;
		LDX	<UNITPOS
		LDA	#UT798D
		STA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		下側 ４ユニットの右 セット		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DKN_ROMTWKD_5_S EQU	$-6*2
		WORD	UT7967,UT796E
;
DKN_ROMTWKD_5_B EQU	$-6*2
		WORD	UT7969,UT7970
;
;
DKN_ROMTWKD_50	EQU	$
		LDX	<UNITPOS
		LDA	DKN_ROMTWKD_5_S,Y
		STA	>BGUNIT,X
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>DWNCHK_SB
		LDA	DKN_ROMTWKD_5_B,Y
		STA	>BGUNIT,X
;
DKN_ROMTWKD_59	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		空コース 丸太					*
;*								*
;****************************************************************
SORA_MRT_DAT	EQU	$
		WORD	UT84D6,UT84D7
		WORD	UT330E,UT3517
		WORD	UT84D8,UT84D9
		WORD	UT84DA,UT84DB
;
		WORD	UT84DC,UT84DC
		WORD	UT8600,UT8600
		WORD	UT84DD,UT84DD
;
;
SORA_MRT	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	<YSIZE
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		AND	#00001
		ASL	A
		ORA	<STUNTNO
;;;;K;;;;		CLC
		ADC	<WORK0
		TAY
		LDA	SORA_MRT_DAT,Y
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		？ブロック					*
;*								*
;****************************************************************
NAZO_BLCK	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#UT8A00
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		雪コース すべる床				*
;*								*
;****************************************************************
SNOW_YK_DAT0	EQU	$
		WORD	00000H,UT001C,00000H,UT001D
;
SNOW_YK_DAT1	EQU	$
		WORD	UT8C01
		WORD	UT8C05
		WORD	UT8C09
;
;
SNOW_YK		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	SNOW_YK_100
		LDA	<NOWUNIT
		BNE	SNOW_YK_990
		JSL	>RND_RND
		AND	#00006
		TAY
		LDA	SNOW_YK_DAT0,Y
		BEQ	SNOW_YK_990
		BRA	SNOW_YK_900
;
SNOW_YK_100	EQU	$
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
		LDA	<YSIZE
		DEC	A
		ASL	A
		CMP	#00003*2
		BCC	SNOW_YK_150
		LDA	#UT8C0D
		BRA	SNOW_YK_900
SNOW_YK_150	EQU	$
		TAY
		LDA	SNOW_YK_DAT1,Y
		CLC
		ADC	<WORK0
;
SNOW_YK_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
SNOW_YK_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		雪コース 水					*
;*								*
;****************************************************************
SNW_WTR_DAT0	EQU	$
		WORD	UT8C03,UT0000,UT8C00
;
SNW_WTR_DAT1	EQU	$-2*02H
		WORD	UT8C07,UT8C04
		WORD	UT8C0B,UT8C08
		WORD	UT8C0E,UT8C0C
		WORD	UT8C0E,UT8C0C
;
SNW_WTR_DAT2	EQU	$-2*02H
		WORD	UT001A,UT001B
		WORD	UT1626,UT1627
		WORD	UT1628,UT1629
		WORD	UT162A,UT162A
;
;
SNOW_WTR	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	SNW_WTR_500
		LDY	#00000H
		LDA	<XSIZE
		BEQ	SNW_WTR_100
		INY
		INY
		INC	A
		CMP	<XSIZECP
		BNE	SNW_WTR_100
		INY
		INY
SNW_WTR_100	EQU	$
		CPY	#00001H*2
		BNE	SNW_WTR_150
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	#UT0000
		STA	>BGUNIT,X
SNW_WTR_150	EQU	$
		LDA	SNW_WTR_DAT0,Y
		BRA	SNW_WTR_900
;
SNW_WTR_500	EQU	$
		ASL	A
		ASL	A
		TAY
		LDA	<YSIZE
		CMP	#00004
		BCC	SNW_WTR_530
		LDY	#00008H*2
SNW_WTR_530	EQU	$
		STY	<WORK0
		LDA	<XSIZE
		BEQ	SNW_WTR_550
		INC	A
		CMP	<XSIZECP
		BNE	SNW_WTR_600
		INY
		INY
SNW_WTR_550	EQU	$
		LDA	SNW_WTR_DAT1,Y
		BRA	SNW_WTR_900
;
SNW_WTR_600	EQU	$
		LDA	<XSIZE
		AND	#00001
		ASL	A
		CLC
		ADC	<WORK0
		TAY
		LDA	SNW_WTR_DAT2,Y
;
SNW_WTR_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
SNW_WTR_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		地下コース第２ 氷の床				*
;*								*
;****************************************************************
CK2_ICEFOR_ADR	EQU	$
		WORD	CK2_ICEFOR_LFT,CK2_ICEFOR_RIT
;
CK2_ICEFOR_DAT	EQU	$
		WORD	UT8C10,UT8C11,UT8C12,UT8C11,UT8C12,UT8C13,UT8C10,UT8C11
		WORD	UT7991,UT7992,UT7993,UT7992,UT7994,UT7995,UT7991,UT7995
		WORD	UT7996,UT7997,UT7996,UT7998,UT7999,UT799C,UT799C,UT799C
		WORD	UT799C,UT799C,UT799C,UT799C,UT799C,UT799A,UT799B,UT7999
		WORD	UT799A,UT799B,UT799C,UT799C,UT799C,UT799C,UT799C,UT799C
;
;
CK2_ICEFOR	EQU	$
		MI16			; memory , index 8bit mode
		LDA	<YSIZE
		BNE	CK2_ICEFOR_100
		LDA	<XSIZE
		AND	#00001
		CLC
		ADC	#UT8DA0
		BRA	CK2_ICEFOR_900
CK2_ICEFOR_100	EQU	$
		LDX	#00000H
		LDA	<XSIZE
		BEQ	CK2_ICEFOR_150
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	CK2_ICEFOR_200
CK2_ICEFOR_150	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSR	(CK2_ICEFOR_ADR,X)
		STA	>BGUNIT,X
;
CK2_ICEFOR_200	EQU	$
		LDA	<YSIZE
		CMP	#00006
		BCS	CK2_ICEFOR_300
		DEC	A
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	<XSIZE
		CLC
		ADC	<STUNTNO
		AND	#00007
		CLC
		ADC	<WORK0
		ASL	A
		TAY
		LDA	CK2_ICEFOR_DAT,Y
		BRA	CK2_ICEFOR_900
;
CK2_ICEFOR_300	EQU	$
		LDA	#UT799C
;
CK2_ICEFOR_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左側チェック＆セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CK2_ICEFOR_LFT	EQU	$
		JSL	>LFTCHK_SB
		LDA	#UT799D
		STA	<WORK0
		BRA	CK2_ICEFOR_RTLF
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右側チェック＆セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CK2_ICEFOR_RIT	EQU	$
		JSL	>RITCHK_SB
		LDA	#UT799F
		STA	<WORK0
CK2_ICEFOR_RTLF EQU	$
		LDA	<YSIZE
		DEC	A
		BEQ	CK2_ICEFOR_RT90
		INC	<WORK0
		BRA	CK2_ICEFOR_RT90
;
CK2_ICEFOR_RT90 EQU	$
		LDA	<WORK0
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		地下コース第２ 氷の床の岩			*
;*								*
;****************************************************************
CK2_ICIW_DT0	EQU	$
		WORD	UT79A9
		WORD	UT79AB
;
CK2_ICIW_DT1	EQU	$
		WORD	UT79A0,UT799E
;
;
CK2_ICIW	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XSIZE
		ASL	A
		TAY
		LDA	<YSIZE
		CMP	#00002
		BCS	CK2_ICIW_500
		ASL	A
		TAY
		LDA	CK2_ICIW_DT0,Y
		CLC
		ADC	<XSIZE
		BRA	CK2_ICIW_900
;
CK2_ICIW_500	EQU	$
		LDA	CK2_ICIW_DT1,Y
;
CK2_ICIW_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		地下コース第２ 溶岩				*
;*								*
;****************************************************************
CK2_YGN0_DAT	EQU	$
		WORD	UT8DA6,UT8DA4,UT8DA5,UT8DA7
		WORD	UTA602,UTA600,UTA601,UTA603
;
;
CK2_YOGAN0	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		ASL	A
		ASL	A
		STA	<WORK0
		STZ	<WORK2
		LDA	<XSIZE
		BEQ	CK2_YGN0_000
		INC	A
		CMP	<XSIZECP
		BNE	CK2_YGN0_100
		INC	<WORK2
		INC	<WORK2
		INC	<WORK2
CK2_YGN0_000	EQU	$
		LDA	<WORK2
		BRA	CK2_YGN0_150
;
CK2_YGN0_100	EQU	$
		AND	#00001
		CLC
		ADC	#00001
CK2_YGN0_150	EQU	$
		CLC
		ADC	<WORK0
		ASL	A
		TAY
		LDA	CK2_YGN0_DAT,Y
		LDY	<NOWUNIT
		CMP	#UT8D35
		BCC	CK2_YGN0_900
		CMP	#UT8D38+1
		BCS	CK2_YGN0_900
		TYA
		CLC
		ADC	#00004
;
CK2_YGN0_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		地下コース第２ 溶岩 (縦)			*
;*								*
;****************************************************************
CK2_YOGAN1	EQU	$
		MI16			; memory , index 16bit mode
		LDY	#UTA605
		LDA	<YSIZE
		BEQ	CK2_YOGAN1_900
		INY
CK2_YOGAN1_900	EQU	$
		TYA
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		地下コース第２ 台キノコ				*
;*								*
;****************************************************************
CK2_TNKN_DAT0	EQU	$
		WORD	UT2C0F,UT1530,UT2F0E,00000H
		WORD	UT2C11,UT1531,UT2F10,00000H
		WORD	UT2C13,UT1532,UT2F12
;
CK2_TNKN_DAT1	EQU	$
		WORD	UT8D31,UT8D32,UT8D33,UT8D34
;
;
CK2_TANAKN	EQU	$
		MI16			; memory , index 16bit mode
		LDA	YSIZE
		BNE	CK2_TANAKN_500
		LDA	<XYCPBF
		ASL	A
;;;;K;;;;		CLC
		ADC	<STUNTNO
		TAY
		LDA	CK2_TNKN_DAT0,Y ; 台の部分セット
		LDX	<NOWUNIT
		CPX	#UT8D31
		BCC	CK2_TANAKN_900
		CPX	#UT8D34+1
		BCS	CK2_TANAKN_900
		INC	A
		BRA	CK2_TANAKN_900
;
CK2_TANAKN_500	EQU	$
		LDA	<XYCPBF
		AND	#00001
		BEQ	CK2_TANAKN_990
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BEQ	CK2_TANAKN_600
		CMP	#00002
		BNE	CK2_TANAKN_550
		LDA	#UT8D30
		BRA	CK2_TANAKN_900
;
CK2_TANAKN_550	EQU	$
		LDA	<YSIZE
		DEC	A
		DEC	A
		AND	#00003
		ASL	A
		TAY
		LDA	CK2_TNKN_DAT1,Y ; 茎の部分セット
		BRA	CK2_TANAKN_900
;
CK2_TANAKN_600	EQU	$
		LDA	<YSIZE		; 根元セット
		AND	#00003
		EOR	#00002
		CLC
		ADC	#UT8D35
		LDY	<NOWUNIT
		CPY	#UT8DA4
		BCC	CK2_TANAKN_900
		CPY	#UT8DA7+1
		BCS	CK2_TANAKN_900
		CLC
		ADC	#00004
;
CK2_TANAKN_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
;
CK2_TANAKN_990	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	CK2_TANAKN_999
		LDA	<XYCPBF
		INC	A
		CMP	#00003
		BCC	CK2_TANAKN_995
		LDA	#00000
CK2_TANAKN_995	EQU	$
		STA	<XYCPBF
CK2_TANAKN_999	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		空コース 岩柱					*
;*								*
;****************************************************************
SR_HSR_UP_DAT	EQU	$
		WORD	00000H,UT8DB4,UT8DB5,00000H
		WORD	00000H,UT8DC4,UT8DC5,00000H
		WORD	00000H,UT8DD4,UT8DD5,00000H
		WORD	00000H,UT8DE4,UT8DE5,00000H
		WORD	UT8DB6,UT8DB7,UT8DB8,UT8DB9
		WORD	UT8DC6,UT8DC7,UT8DC8,UT8DC9
		WORD	UT8DD6,UT8DD7,UT8DD8,UT8DD9
		WORD	UT8DE6,UT8DE7,UT8DE8,UT8DE9
;
SR_HSR_DW_DAT	EQU	$
		WORD	UT8DB4,UT8DBA,UT8DBA,UT8DB5
		WORD	UT8DC4,UT8DCA,UT8DCA,UT8DC5
		WORD	UT8DD4,UT8DDA,UT8DDA,UT8DD5
		WORD	UT8DE4,UT8DEA,UT8DEA,UT8DE5
		WORD	UT8DBB,UT8DBC,UT8DBD,UT8DBE
		WORD	UT8DCB,UT8DCC,UT8DCD,UT8DCE
		WORD	UT8DDB,UT8DDC,UT8DDD,UT8DDE
		WORD	UT8DEB,UT8DEC,UT8DED,UT8DEE
;
;
SORA_HSR	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		AND	#00007
		ASL	A
		ASL	A
;;;;K;;;;		CLC
		ADC	<XSIZE
		ASL	A
		TAY
		LDA	<YSIZE
		CMP	#00008
		BCS	SR_HSR_500
		LDA	SR_HSR_UP_DAT,Y
		BEQ	SR_HSR_990
		BRA	SR_HSR_900
;
SR_HSR_500	EQU	$
		LDA	SR_HSR_DW_DAT,Y
;
SR_HSR_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
SR_HSR_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		雪コース 氷の穴					*
;*								*
;****************************************************************
SNW_ANA_DAT	EQU	$
		WORD	UT8C00,UT8C04,UT8C08
;
;
SNOW_ANA	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002
		BCC	SNW_ANA_050
		LDA	#00002
SNW_ANA_050	EQU	$
		ASL	A
		TAY
		STZ	<WORK0
		LDX	#00003H
		LDA	<XSIZE
		BEQ	SNW_ANA_200
		INC	A
		CMP	<XSIZECP
		BNE	SNW_ANA_500
		DEX
		DEX
		DEX
SNW_ANA_200	EQU	$
		TXA
		CLC
		ADC	SNW_ANA_DAT,Y
		BRA	SNW_ANA_900
;
SNW_ANA_500	EQU	$
		LDA	#UT0000
;
SNW_ANA_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		LDA	<YSIZE
		BNE	SNW_ANA_990
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>UPCHK_SB
		LDA	#UT0000
		STA	>BGUNIT,X
SNW_ANA_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		フラワーコース 床				*
;*								*
;****************************************************************
FLWR_YK_DT0	EQU	$
		WORD	00000H,00000H
		WORD	UT85B0,UT85B1
		WORD	UT79E0,UT79E1
;
FLWR_YK_DT1	EQU	$
		WORD	00000H,00000H
		WORD	UT85B6,UT85B7
		WORD	UT79E3,UT79E4
;
FLWR_YK_DT2	EQU	$
		WORD	00000H,00000H
		WORD	UT85B0,UT85B2
		WORD	UT79E3,UT79E4
;
FLWR_YK_DT3	EQU	$
		WORD	00000H,00000H
		WORD	UT85B6,UT85B8
		WORD	UT79E3,UT79E5
;
FLWR_YK_DT4	EQU	$
		WORD	00000H,00000H
		WORD	UT85B0,UT85B1
		WORD	UT79E2,UT79E1
;
FLWR_YK_DT5	EQU	$
		WORD	00000H,00000H
		WORD	UT85B9,UT85B7
		WORD	UT79E3,UT79E2
;
FLWR_YK_DT6	EQU	$
		WORD	00000H,UT85E4
		WORD	UT85B9,UT85B3
		WORD	UT79E0,UT79B2
;
FLWR_YK_DT7	EQU	$
		WORD	UT85E7,00000H
		WORD	UT85BA,UT85BB
		WORD	UT79B3,UT79B5
;
FLWR_YK_DT8	EQU	$
		WORD	UT85E5,UT85E6
		WORD	UT85B4,UT85B3
		WORD	UT79E2,UT79E1
;
FLWR_YK_DT9	EQU	$
		WORD	UT85E7,UT85E4
		WORD	UT85BA,UT85BB
		WORD	UT79E2,UT79BC
;
FLWR_YK_DAT	EQU	$
		WORD	FLWR_YK_DT9,FLWR_YK_DT8,FLWR_YK_DT7,FLWR_YK_DT6
		WORD	FLWR_YK_DT5,FLWR_YK_DT4,FLWR_YK_DT3,FLWR_YK_DT2
		WORD	FLWR_YK_DT1,FLWR_YK_DT0,FLWR_YK_DT8,FLWR_YK_DT6
		WORD	FLWR_YK_DT4,FLWR_YK_DT2,FLWR_YK_DT1,FLWR_YK_DT0
;
;
FLOWER_YK	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00003
		BCC	FLWR_YK_100
		DEC	A
		DEC	A
		DEC	A
		ASL	A
		STA	<WORK0
		JSR	FLWR_FLWR
		BRA	FLWR_YK_990
FLWR_YK_100	EQU	$
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
		BNE	FLWR_YK_200
		LDA	<YSIZE
		BNE	FLWR_YK_200
		JSL	>RND_RND
		AND	#0000FH
		ASL	A
		STA	<XYCPBF
;
FLWR_YK_200	EQU	$
		LDA	<YSIZE
		ASL	A
;;;;K;;;;		CLC
		ADC	<WORK0
		ASL	A
		TAY
;
		LDX	<XYCPBF
		LDA	FLWR_YK_DAT,X
		STA	<WORK0
;
		LDA	(<WORK0),Y
		BEQ	FLWR_YK_990
;
FLWR_YK_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
FLWR_YK_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		フラワーコース 地面			+
;+				in			+
;+				wrk0 : Ｙポイント	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		MEM16
		IDX16
FLWR_FLWR_DT	EQU	$
		WORD	UT79C1,UT79C2,UT79C3,UT79C4
		WORD	UT79C5,UT79C6,UT79C7,UT79C8
		WORD	UT79C9,UT79CA,UT79E6,UT79E6
		WORD	UT79E6,UT79E6,UT79E6,UT79E6
FLWR_FLWR_ED	EQU	$
;
;
FLWR_FLWR	EQU	$
		JSL	>RND_RND
		AND	#0000FH
		CLC
		ADC	<WORK0
		CMP	#(FLWR_FLWR_ED-FLWR_FLWR_DT)/2
		BCC	FLWR_FLWR_100
		LDA	#((FLWR_FLWR_ED-FLWR_FLWR_DT)/2)-1
FLWR_FLWR_100	EQU	$
		ASL	A
		TAY
		LDX	<UNITPOS
		LDA	FLWR_FLWR_DT,Y
		STA	>BGUNIT,X
		RTS
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		フラワーコース 左下右上２２.５゜		*
;*								*
;****************************************************************
FLWRLDRU22_DT0	EQU	$
		WORD	00000H,00000H
		WORD	UT85C0,UT85BF
		WORD	UT0D21,UT0C22
		WORD	UT79B3,UT79B2
;
FLWRLDRU22_DT1	EQU	$
		WORD	00000H,00000H
		WORD	UT85C0,UT85BF
		WORD	UT0D22,UT0C22
		WORD	UT79BC,UT79B4
;
FLWRLDRU22_DT2	EQU	$
		WORD	00000H,00000H
		WORD	UT85C0,UT85BE
		WORD	UT0D22,UT0C21
		WORD	UT79C3,UT79B4
;
FLWRLDRU22_DT3	EQU	$
		WORD	UT85E1,00000H
		WORD	UT85C1,UT85BE
		WORD	UT0D22,UT0C22
		WORD	UT79B3,UT79B5
;
FLWRLDRU22_DT4	EQU	$
		WORD	UT85E2,UT85E0
		WORD	UT85C2,UT85BD
		WORD	UT0D22,UT0C22
		WORD	UT79B7,UT79B6
;
FLWRLDRU22_DT	EQU	$
		WORD	FLWRLDRU22_DT0,FLWRLDRU22_DT1
		WORD	FLWRLDRU22_DT2,FLWRLDRU22_DT3
		WORD	FLWRLDRU22_DT4,FLWRLDRU22_DT4
		WORD	FLWRLDRU22_DT3,FLWRLDRU22_DT0
;
;
FLWR_LDRU22	EQU	$
		MI16			; memory , index 16bit mode
		STZ	<LKFLG
;
		LDA	<YSIZE
		CMP	#00001H
		BNE	FLWR_LDRU22_010
		LDA	<XSIZE		; 右かど チェック ＆ セット ?
		BNE	FLWR_LDRU22_000	;	NO -> FLWR_LDRU22_000
		JSR	FWR_R_KADO
		BRA	FLWR_LDRU22_000
;
FLWR_LDRU22_010	EQU	$
		CMP	#00002H
		BNE	FLWR_LDRU22_000
		LDA	<XSIZE
		DEC	A
		CMP	<XSIZECP	; 左かど チェック ＆ セット ?
		BNE	FLWR_LDRU22_000	;	NO -> FLWR_LDRU22_000
		JSR	FWR_L_KADO
;
FLWR_LDRU22_000	EQU	$
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
		BEQ	FLWR_LDRU22_100
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	FLWR_LDRU22_100
		INC	<LKFLG
;
FLWR_LDRU22_100	EQU	$
		LDA	<WORK0
		BNE	FLWR_LDRU22_200
		LDA	<YSIZE
		BNE	FLWR_LDRU22_200
		JSL	>RND_RND
		AND	#00007
		ASL	A
		STA	<XYCPBF
		CMP	#00002*2
		BEQ	FLWR_LDRU22_150
		CMP	#00004*2
		BNE	FLWR_LDRU22_200
FLWR_LDRU22_150	EQU	$
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		CMP	#UT9000
		BCC	FLWR_LDRU22_200
		CMP	#UT905E+1
		BCS	FLWR_LDRU22_200
		STZ	<XYCPBF
;
FLWR_LDRU22_200	EQU	$
		LDX	<XYCPBF
		LDA	FLWRLDRU22_DT,X
		STA	<WORK2
		JMP	FLWR_LURD22_ST
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		フラワーコース 左下右上４５゜			*
;*								*
;****************************************************************
FLWRLDRU45_DT0	EQU	$
		WORD	00000H,UT85D4,UT0822,UT79B0
;
FLWRLDRU45_DT1	EQU	$
		WORD	00000H,UT85D5,UT0823,UT79B0
;
FLWRLDRU45_DT2	EQU	$
		WORD	00000H,UT85D4,UT0824,UT79B1
;
FLWRLDRU45_DT3	EQU	$
		WORD	UT85E0,UT85D6,UT0824,UT79B1
;
FLWRLDRU45_DT4	EQU	$
		WORD	UT85E1,UT85D7,UT0822,UT79BC
;
FLWRLDRU45_DT	EQU	$
		WORD	FLWRLDRU45_DT0,FLWRLDRU45_DT1
		WORD	FLWRLDRU45_DT2,FLWRLDRU45_DT3
		WORD	FLWRLDRU45_DT4,FLWRLDRU45_DT4
		WORD	FLWRLDRU45_DT3,FLWRLDRU45_DT0
;
;
FLWR_LDRU45	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002H
		BNE	FLWR_LDRU45_100
		LDA	<XSIZE
		DEC	A
		CMP	<XSIZECP	; 左かど チェック ＆ セット ?
		BNE	FLWR_LDRU45_100	;	NO -> FLWR_LDRU45_100
		JSR	FWR_L_KADO
;
FLWR_LDRU45_100	EQU	$
		LDA	#00001
		STA	<LKFLG
		LDA	<YSIZE
		BNE	FLWR_LDRU45_200
		JSL	>RND_RND
		AND	#00007
		ASL	A
		STA	<XYCPBF
;
FLWR_LDRU45_200	EQU	$
		LDX	<XYCPBF
		LDA	FLWRLDRU45_DT,X
		STA	<WORK0
		JMP	FLWR_LR_SET
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*	フラワーコース 左下右上６０゜				*
;*								*
;****************************************************************
FLWRLDRU60_DT0	EQU	$
		WORD	UT85BF,UT0222,UT0323,UT79BF
;
FLWRLDRU60_DT1	EQU	$
		WORD	UT85BF,UT0222,UT0323,UT79B2
;
FLWRLDRU60_DT2	EQU	$
		WORD	UT85BE,UT0223,UT0323,UT79BF
;
FLWRLDRU60_DT3	EQU	$
		WORD	UT85BF,UT0222,UT0323,UT79BC
;
FLWRLDRU60_DT4	EQU	$
		WORD	UT85CD,UT0222,UT0323,UT79BF
;
FLWRLDRU60_DT	EQU	$
		WORD	FLWRLDRU60_DT4,FLWRLDRU60_DT3
		WORD	FLWRLDRU60_DT2,FLWRLDRU60_DT1
		WORD	FLWRLDRU60_DT0,FLWRLDRU60_DT3
		WORD	FLWRLDRU60_DT1,FLWRLDRU60_DT0
;
;
FLWR_LDRU60	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#00001
		STA	<LKFLG
;
		LDA	<YSIZE
		BNE	FLWR_LDRU60_200
		JSL	>RND_RND
		AND	#00007
		ASL	A
		STA	<XYCPBF
;
FLWR_LDRU60_200	EQU	$
		LDX	<XYCPBF
		LDA	FLWRLDRU60_DT,X
		STA	<WORK0
		JMP	FLWR_LR_SET
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左かど チェック ＆ セット		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FWR_L_KADO	EQU	$
		JSR	LEFT_CHK	; 左ブロック チェック
		CMP	#UT79DE
		BEQ	FWR_L_KADO_50
		CMP	#UT79DF
		BNE	FWR_L_KADO_90
FWR_L_KADO_50	EQU	$
		LDA	#UT79CF
		STA	>BGUNIT,X
;
FWR_L_KADO_90	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右かど チェック ＆ セット		+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FWR_R_KADO	EQU	$
		JSR	RIGT_CHK	; 右ブロック チェック
		CMP	#UT79DC
		BEQ	FWR_R_KADO_50
		CMP	#UT79DD
		BNE	FWR_R_KADO_90
FWR_R_KADO_50	EQU	$
		LDA	#UT79CE
		STA	>BGUNIT,X
;
FWR_R_KADO_90	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		フラワーコース 左上右下２２.５゜		*
;*								*
;****************************************************************
FLWRLURD22_DT0	EQU	$
		WORD	00000H,00000H
		WORD	UT85C6,UT85CA
		WORD	UT0F23,UT1022
		WORD	UT79B8,UT79C4
;
FLWRLURD22_DT1	EQU	$
		WORD	00000H,00000H
		WORD	UT85C6,UT85CA
		WORD	UT0F22,UT1022
		WORD	UT79B5,UT79BD
;
FLWRLURD22_DT2	EQU	$
		WORD	00000H,00000H
		WORD	UT85C6,UT85CB
		WORD	UT0F22,UT1023
		WORD	UT79B9,UT79BA
;
FLWRLURD22_DT3	EQU	$
		WORD	UT85E2,00000H
		WORD	UT85C7,UT85CA
		WORD	UT0F22,UT1022
		WORD	UT79C8,UT79BC
;
FLWRLURD22_DT4	EQU	$
		WORD	UT85E1,UT85E2
		WORD	UT85C8,UT85C9
		WORD	UT0F23,UT1022
		WORD	UT79B8,UT79C4
;
FLWRLURD22_DT	EQU	$
		WORD	FLWRLURD22_DT0,FLWRLURD22_DT1
		WORD	FLWRLURD22_DT2,FLWRLURD22_DT3
		WORD	FLWRLURD22_DT4,FLWRLURD22_DT4
		WORD	FLWRLURD22_DT3,FLWRLURD22_DT0
;
;
FLWR_LURD22	EQU	$
		MI16			; memory , index 16bit mode
		STZ	<LKFLG
;
		LDA	<YSIZE
		CMP	#00001H
		BNE	FLWR_LURD22_010
		LDA	<XSIZE		; 左かど チェック ＆ セット ?
		BNE	FLWR_LURD22_000	;	NO -> FLWR_LURD22_000
		JSR	FWR_L_KADO
		BRA	FLWR_LURD22_000
;
FLWR_LURD22_010	EQU	$
		CMP	#00002H
		BNE	FLWR_LURD22_000
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP	; 右かど チェック ＆ セット ?
		BNE	FLWR_LURD22_000	;	NO -> FLWR_LURD22_000
		JSR	FWR_R_KADO
;
FLWR_LURD22_000	EQU	$
		LDA	<XSIZE
		AND	#00001
		STA	<WORK0
		BEQ	FLWR_LURD22_100
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	FLWR_LURD22_100
		INC	<LKFLG
;
FLWR_LURD22_100	EQU	$
		LDA	<WORK0
		BNE	FLWR_LURD22_200
		LDA	<YSIZE
		BNE	FLWR_LURD22_200
		JSL	>RND_RND
		AND	#00007
		ASL	A
		STA	<XYCPBF
		CMP	#00002*2
		BEQ	FLWR_LURD22_150
		CMP	#00004*2
		BNE	FLWR_LURD22_200
FLWR_LURD22_150	EQU	$
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		CMP	#UT9000
		BCC	FLWR_LURD22_200
		CMP	#UT905E+1
		BCS	FLWR_LURD22_200
		STZ	<XYCPBF
;
FLWR_LURD22_200	EQU	$
		LDX	<XYCPBF
		LDA	FLWRLURD22_DT,X
		STA	<WORK2
;
FLWR_LURD22_ST	EQU	$
		LDA	<YSIZE
		CMP	#00004
		BCS	FLWR_LURD22_500
		ASL	A
;;;;K;;;		CLC
		ADC	<WORK0
		ASL	A
		TAY
;
		LDA	(<WORK2),Y
		BEQ	FLWR_LURD22_990
		LDX	<UNITPOS
		STA	>BGUNIT,X
		BRA	FLWR_LURD22_990
;
FLWR_LURD22_500	EQU	$
		DEC	A
		DEC	A
		DEC	A
		DEC	A
		ASL	A
		STA	<WORK0
		JSR	FLWR_FLWR
;
FLWR_LURD22_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		フラワーコース 左上右下４５゜			*
;*								*
;****************************************************************
FLWRLURD45_DT0	EQU	$
		WORD	00000H,UT85D9,UT0A23,UT79BD
;
FLWRLURD45_DT1	EQU	$
		WORD	00000H,UT85DB,UT0A24,UT79BD
;
FLWRLURD45_DT2	EQU	$
		WORD	00000H,UT85D9,UT0A25,UT79BE
;
FLWRLURD45_DT3	EQU	$
		WORD	UT85E2,UT85DA,UT0A25,UT79BE
;
FLWRLURD45_DT4	EQU	$
		WORD	UT85E3,UT85DC,UT0A23,UT79B5
;
FLWRLURD45_DT	EQU	$
		WORD	FLWRLURD45_DT0,FLWRLURD45_DT1
		WORD	FLWRLURD45_DT2,FLWRLURD45_DT3
		WORD	FLWRLURD45_DT4,FLWRLURD45_DT4
		WORD	FLWRLURD45_DT3,FLWRLURD45_DT0
;
;
FLWR_LURD45	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		CMP	#00002H
		BNE	FLWR_LURD45_100
		LDA	<XSIZE
		INC	A
		CMP	<XSIZECP	; 左かど チェック ＆ セット ?
		BNE	FLWR_LURD45_100	;	NO -> FLWR_LURD45_100
		JSR	FWR_R_KADO
;
FLWR_LURD45_100	EQU	$
		LDA	#00001
		STA	<LKFLG
		LDA	<YSIZE
		BNE	FLWR_LURD45_200
		JSL	>RND_RND
		AND	#00007
		ASL	A
		STA	<XYCPBF
;
FLWR_LURD45_200	EQU	$
		LDX	<XYCPBF
		LDA	FLWRLURD45_DT,X
		STA	<WORK0
		JMP	FLWR_LR_SET
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		フラワーコース 左上右下６０゜			*
;*								*
;****************************************************************
FLWRLURD60_DT0	EQU	$
		WORD	UT85D2,UT0523,UT0623,UT79C0
;
FLWRLURD60_DT1	EQU	$
		WORD	UT85D2,UT0523,UT0623,UT79B2
;
FLWRLURD60_DT2	EQU	$
		WORD	UT85D1,UT0522,UT0623,UT79C0
;
FLWRLURD60_DT3	EQU	$
		WORD	UT85D0,UT0523,UT0623,UT79B5
;
FLWRLURD60_DT4	EQU	$
		WORD	UT85D0,UT0523,UT0623,UT79C0
;
FLWRLURD60_DT	EQU	$
		WORD	FLWRLURD60_DT4,FLWRLURD60_DT3
		WORD	FLWRLURD60_DT2,FLWRLURD60_DT1
		WORD	FLWRLURD60_DT0,FLWRLURD60_DT3
		WORD	FLWRLURD60_DT1,FLWRLURD60_DT0
;
;
FLWR_LURD60	EQU	$
		MI16			; memory , index 16bit mode
		LDA	#00001
		STA	<LKFLG
;
		LDA	<YSIZE
		BNE	FLWR_LURD60_200
		JSL	>RND_RND
		AND	#00007
		ASL	A
		STA	<XYCPBF
;
FLWR_LURD60_200	EQU	$
		LDX	<XYCPBF
		LDA	FLWRLURD60_DT,X
		STA	<WORK0
;
FLWR_LR_SET	EQU	$
		LDA	<YSIZE
		CMP	#00004
		BCS	FLWR_LR_SET_200
		ASL	A
		TAY
		LDA	(<WORK0),Y
		BEQ	FLWR_LR_SET_990
		LDX	<UNITPOS
		STA	>BGUNIT,X
		BRA	FLWR_LR_SET_990
;
FLWR_LR_SET_200	EQU	$
		DEC	A
		DEC	A
		DEC	A
		DEC	A
		ASL	A
		STA	<WORK0
		JSR	FLWR_FLWR
;
FLWR_LR_SET_990	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		フラワーコース 床の左右の端			*
;*								*
;****************************************************************
FLWR_LTRT_ADR	EQU	$
		WORD	FLWR_LT_ADR,FLWR_RT_ADR
;
FLWR_LTRT_DAT	EQU	$
		WORD	UT79B3,UT79B4,UT79BB,UT79E3
;
FLWR_LTRT_CMP	EQU	$
		WORD	UT0300,UT0600,UT0800,UT0A00,UT0C00,UT1000
FLWR_LTRT_CP_ED	EQU	$
;
;
FLWR_LTRT	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<XYPOINT
		STA	<WORKE
		LDX	<STUNTNO
		JSR	(FLWR_LTRT_ADR,X)
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左端 セット＆チェック			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FLWR_LT_ADR	EQU	$
		LDA	<YSIZE
		CMP	#00003
		BCS	FLWR_LT_200
		JSL	>FLWR_LDRU60
		BRA	FLWR_LT_900
;
FLWR_LT_200	EQU	$
		LDA	<YSIZE
		AND	#00001
		CLC
		ADC	#UT79DC
		LDX	<UNITPOS
		STA	>BGUNIT,X
		JSL	>RITCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT7900
		BNE	FLWR_LT_300
		STX	<WORK0
		JSL	>RND_RND
		AND	#00006
		TAY
		LDX	<WORK0
		LDA	FLWR_LTRT_DAT,Y
		STA	>BGUNIT,X
;
FLWR_LT_300	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	FLWR_LT_900
		JSR	LEFT_CHK	; 左ブロック チェック
		LDY	#00000H
		AND	#0FF00H
FLWR_LT_330	EQU	$
		CMP	FLWR_LTRT_CMP,Y
		BEQ	FLWR_LT_350
		INY
		INY
		CPY	#FLWR_LTRT_CP_ED-FLWR_LTRT_CMP
		BCC	FLWR_LT_330
		LDA	>BGUNIT,X
		CMP	#UT85C0
		BCC	FLWR_LT_900
		CMP	#UT85C8+1
		BCS	FLWR_LT_900
FLWR_LT_350	EQU	$
		LDX	<UNITPOS
		LDA	#UT79CE
		STA	>BGUNIT,X
;
FLWR_LT_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右端 セット＆チェック			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FLWR_RT_ADR	EQU	$
		LDA	<YSIZE
		CMP	#00003
		BCS	FLWR_RT_200
		JSL	>FLWR_LURD60
		BRA	FLWR_RT_900
;
FLWR_RT_200	EQU	$
		LDA	<YSIZE
		AND	#00001
		CLC
		ADC	#UT79DE
		LDX	<UNITPOS
		STA	>BGUNIT,X
		JSL	>LFTCHK_SB
		LDA	>BGUNIT,X
		AND	#0FF00H
		CMP	#UT7900
		BNE	FLWR_RT_300
		STX	<WORK0
		JSL	>RND_RND
		AND	#00006
		TAY
		LDX	<WORK0
		LDA	FLWR_LTRT_DAT,Y
		STA	>BGUNIT,X
;
FLWR_RT_300	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	FLWR_RT_900
		JSR	RIGT_CHK	; 右ブロック チェック
		LDY	#00000H
		AND	#0FF00H
FLWR_RT_330	EQU	$
		CMP	FLWR_LTRT_CMP,Y
		BEQ	FLWR_RT_350
		INY
		INY
		CPY	#FLWR_LTRT_CP_ED-FLWR_LTRT_CMP
		BCC	FLWR_RT_330
		LDA	>BGUNIT,X
		CMP	#UT85C0
		BCC	FLWR_RT_900
		CMP	#UT85C8+1
		BCS	FLWR_RT_900
FLWR_RT_350	EQU	$
		LDX	<UNITPOS
		LDA	#UT79CF
		STA	>BGUNIT,X
;
FLWR_RT_900	EQU	$
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		溶岩コース 天井岩				*
;*								*
;****************************************************************
YGN_UPBLK_ADR	EQU	$
		WORD	YGN_UPBLK_LFT,YGN_UPBLK_MID,YGN_UPBLK_RIT
;
YGN_UPBLK_DAT	EQU	$
		WORD	00000H,00003H,00006H
;
;
YGN_UPBLK	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		EOR	#0FFFFH
		INC	A
		CMP	#00005
		BCC	YGN_UPBLK_150
		LDA	#00004
YGN_UPBLK_150	EQU	$
		AND	#00006
		TAY
		LDA	YGN_UPBLK_DAT,Y
		STA	<WORK0
		CMP	#00006H
		BCS	YGN_UPBLK_200
		LDA	<YSIZE
		AND	#00001
		BEQ	YGN_UPBLK_200
		JSL	>RND_RND
		AND	#00002
		BEQ	YGN_UPBLK_200
		INC	<WORK0
		INC	<WORK0
		INC	<WORK0
;
YGN_UPBLK_200	EQU	$
		LDA	<YSIZE
		EOR	<XSIZE
		EOR	<STUNTNO
		AND	#00001
		ASL	A
		TAY
;
		LDX	#00000H
		LDA	<XSIZE
		BEQ	YGN_UPBLK_350
		INX
		INX
		INC	A
		CMP	<XSIZECP
		BNE	YGN_UPBLK_350
		INX
		INX
YGN_UPBLK_350	EQU	$
		JSR	(YGN_UPBLK_ADR,X)
;
		LDY	<YSIZE
		BNE	YGN_UPBLK_900
		LDA	<WORK2
		SEC
		SBC	#UT79F0
		CLC
		ADC	#UT3D0C
;
YGN_UPBLK_900	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左サイド				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_LFT_DAT	EQU	$
		WORD	UT79F1,UT79F0
;
;
YGN_UPBLK_LFT	EQU	$
		LDA	YGN_LFT_DAT,Y
		BRA	YGN_UPBLK_PAS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		中					+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_UPBLK_MID	EQU	$
		LDA	#UT79F1
		BRA	YGN_UPBLK_CHK
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右サイド				+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_UPBLK_RIT	EQU	$
		LDA	#UT79F0
YGN_UPBLK_CHK	EQU	$
		TYX
		BEQ	YGN_UPBLK_PAS
		JSR	LEFT_CHK	; 左ブロック チェック
		SEC
		SBC	#UT79F1
		STA	<WORK0
		LDA	#UT79F2
;
YGN_UPBLK_PAS	EQU	$
		STA	<WORK2
		CLC
		ADC	<WORK0
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		溶岩コース グラデーション床			*
;*								*
;****************************************************************
YGN_YK_ADR	EQU	$
		WORD	YGN_YK_LEFT,YGN_YK_RIGT
;
;
YGN_YUKA	EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		ASL	A
		TAY
		CPY	#00003H*2
		BCS	YGN_YK_500
		JSR	YGN_YK_FKN
		BRA	YGN_YK_700
;
YGN_YK_500	EQU	$
		LDA	<YSIZE
		EOR	<XYCPBF
		AND	#00001
		CLC
		ADC	#UT0108
		STA	<WORK4
		LDX	#00000
		LDA	<XSIZE
		BEQ	YGN_YK_530
		INC	A
		CMP	<XSIZECP
		BNE	YGN_YK_600
		INX
		INX
YGN_YK_530	EQU	$
		LDA	<WORK4
		JSR	(YGN_YK_ADR,X)
;
YGN_YK_600	EQU	$
		LDA	<STUNTNO
		BEQ	YGN_YK_700
		JSR	YGN_YK_GRD
		LDA	<STUNTNO
		BMI	YGN_YK_700
		JSR	YGN_NO_HIT
;
YGN_YK_700	EQU	$
		LDA	<YSIZE
		INC	A
		CMP	<YSIZECP
		BNE	YGN_YK_900
		LDA	<XYCPBF
		EOR	#00001
		STA	<XYCPBF
;
YGN_YK_900	EQU	$
		LDA	<WORK4
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
		MEM16
		IDX16
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		フカンブロック セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_YK_FKN_DT	EQU	$
		WORD	UT0030,UT0100,UT0103
;
YGN_YK_FKN_SB	EQU	$
		WORD	UT0035,UT010A,UT0105
;
YGN_YK_FKN_D0	EQU	$
		WORD	UT0030,UT9C00,UT0103
;
YGN_YK_FKN_D1	EQU	$
		WORD	UT0035,UT9C03,UT0105
;
;
YGN_YK_FKN	EQU	$
		LDA	YGN_YK_FKN_DT,Y
		CLC
		ADC	<XYCPBF
		STA	<WORK4
		LDA	<XSIZE
		BEQ	YGN_YK_FKN_230
		INC	A
		CMP	<XSIZECP
		BNE	YGN_YK_FKN_220
;
		JSR	LEFT_CHK	;左側チェック !!
		CMP	#UT0031
		BEQ	YGN_YK_FKN_280
		CMP	#UT0035
		BEQ	YGN_YK_FKN_280
		CMP	#UT0101
		BEQ	YGN_YK_FKN_280
		CMP	#UT010A
		BEQ	YGN_YK_FKN_280
		CMP	#UT0104
		BEQ	YGN_YK_FKN_280
		CMP	#UT0105
		BEQ	YGN_YK_FKN_280
		INC	A
		BRA	YGN_YK_FKN_285
;
YGN_YK_FKN_220	EQU	$
		LDA	<STUNTNO
		CMP	#08000H
		BEQ	YGN_YK_FKN_235
		BRA	YGN_YK_FKN_900
;
YGN_YK_FKN_230	EQU	$
		LDA	<STUNTNO
		CMP	#08000H
		BNE	YGN_YK_FKN_240
YGN_YK_FKN_235	EQU	$
		LDA	YGN_YK_FKN_D0,Y
		CLC
		ADC	<XYCPBF
		BRA	YGN_YK_FKN_285
;
YGN_YK_FKN_240	EQU	$
		LDA	<XYCPBF
		BEQ	YGN_YK_FKN_900
;
YGN_YK_FKN_280	EQU	$
		LDA	<STUNTNO
		CMP	#08000H
		BNE	YGN_YK_FKN_283
		LDA	YGN_YK_FKN_D1,Y
		BRA	YGN_YK_FKN_285
;
YGN_YK_FKN_283	EQU	$
		LDA	YGN_YK_FKN_SB,Y
YGN_YK_FKN_285	EQU	$
		STA	<WORK4
;
YGN_YK_FKN_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		左端 チェック＆セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_YK_LEFT	EQU	$
		CMP	#UT0109
		BNE	YGN_YK_RT_900
		JSR	LEFT_CHK
		CMP	#UT0108
		BEQ	YGN_YK_RT_900
		BRA	YGN_YK_RT_800
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+		右端 チェック＆セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_YK_RIGT	EQU	$
		CMP	#UT0108
		BNE	YGN_YK_RT_900
		JSR	RIGT_CHK
		CMP	#UT0109
		BEQ	YGN_YK_RT_900
YGN_YK_RT_800	EQU	$
		LDA	#UT0106
		STA	<WORK4
YGN_YK_RT_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	グラデーション ブロック セット			+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_YK_GRD_DT	EQU	$-3*2
		WORD	UT0108,UT0108
		WORD	UT0108,UT79E9
		WORD	UT79E9,UT79EC
		WORD	UT79EC,UT79EE
YGN_YK_GRD_DTA	EQU	$
;
YGN_YK_GRD_1DT	EQU	$
		WORD	UT0106,UT79E8,UT79EB,UT79EE
;
;
YGN_YK_GRD	EQU	$
		LDA	<WORK4
		CMP	#UT0106
		BEQ	YGN_YK_GRD_200
		CMP	#UT0109
		BEQ	YGN_YK_GRD_000
		CMP	#UT79EA
		BEQ	YGN_YK_GRD_000
		CMP	#UT79ED
		BNE	YGN_YK_GRD_400
YGN_YK_GRD_000	EQU	$
		JSR	LEFT_CHK
		CMP	#UT0000
		BEQ	YGN_YK_GRD_480
		CMP	#UT79EE
		BEQ	YGN_YK_GRD_480
		INC	A
		BRA	YGN_YK_GRD_480
;
YGN_YK_GRD_200	EQU	$
		LDA	<YSIZE
		DEC	A
		DEC	A
		DEC	A
		CMP	#00003*2
		BCC	YGN_YK_GRD_250
		JSL	>RND_RND
		AND	#00002
		CLC
		ADC	#00002*2
YGN_YK_GRD_250	EQU	$
		AND	#00006
		TAY
		LDA	YGN_YK_GRD_1DT,Y
		BRA	YGN_YK_GRD_480
;
YGN_YK_GRD_400	EQU	$
		JSL	>RND_RND
		AND	#00003H
		CLC
		ADC	<YSIZE
		ASL	A
		CMP	#YGN_YK_GRD_DTA-YGN_YK_GRD_DT
		BCC	YGN_YK_GRD_450
		JSL	>RND_RND
		AND	#00002
		CLC
		ADC	#(YGN_YK_GRD_DTA-YGN_YK_GRD_DT)-4
YGN_YK_GRD_450	EQU	$
		TAY
		LDA	YGN_YK_GRD_DT,Y
YGN_YK_GRD_480	EQU	$
		STA	<WORK4
;
YGN_YK_GRD_900	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+	当たりなし グラデーション ブロック セット	+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
YGN_NO_HIT_DAT	EQU	$
		WORD	UT7797,UT7798,UT0000
;
;
YGN_NO_HIT	EQU	$
		LDX	#00000H
		LDA	<WORK4
		AND	#0FF00H
		CMP	#UT7700
		BEQ	YGN_NO_HIT_990
		LDA	<WORK4
		CMP	#UT0000
		BEQ	YGN_NO_HIT_990
		CMP	#UT0106
		BEQ	YGN_NO_HIT_990
		CMP	#UT0108
		BEQ	YGN_NO_HIT_100
		INX
		INX
		CMP	#UT0109
		BEQ	YGN_NO_HIT_100
		INX
		INX
		CMP	#UT79EE
		BNE	YGN_NO_HIT_200
YGN_NO_HIT_100	EQU	$
		LDA	YGN_NO_HIT_DAT,X
		BRA	YGN_NO_HIT_900
;
YGN_NO_HIT_200	EQU	$
		SEC
		SBC	#UT79E8
		CLC
		ADC	#UT7791
;
YGN_NO_HIT_900	EQU	$
		STA	<WORK4
YGN_NO_HIT_990	EQU	$
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	左ブロック チェック			+
;+			out			+
;+			A : ユニットＮｏ	+
;++++++++++++++++++++++++++++++++++++++++++++++++
LEFT_CHK	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>LFTCHK_SB
		LDA	>BGUNIT,X
		RTS
;
;++++++++++++++++++++++++++++++++++++++++++++++++
;+	右ブロック チェック			+
;+			out			+
;+			A : ユニットＮｏ	+
;++++++++++++++++++++++++++++++++++++++++++++++++
RIGT_CHK	EQU	$
		LDA	<XYPOINT
		STA	<WORKE
		JSL	>RITCHK_SB
		LDA	>BGUNIT,X
		RTS
;
		MEM8
		IDX8
;
;
;****************************************************************
;*								*
;*		トゲ						*
;*								*
;****************************************************************
TOGE2		EQU	$
		MI16			; memory , index 16bit mode
		LDA	<YSIZE
		BNE	TOGE2_500
		LDA	#UT8417
		BRA	TOGE2_800
TOGE2_500	EQU	$
		LDA	#UT2914
TOGE2_800	EQU	$
		LDX	<UNITPOS
		STA	>BGUNIT,X
		MI8			; memory , index 8bit mode
		RTL
;
;
;****************************************************************
;*								*
;*		カメック通路 ブロック				*
;*								*
;****************************************************************
KAMEC_BLK	EQU	$
		MI16			; memory , index 16bit mode
		LDX	<UNITPOS
		LDA	>BGUNIT,X
		BNE	KMC_BLK_900
		LDA	#UT9DC7
		STA	>BGUNIT,X
KMC_BLK_900	EQU	$
		MI8			; memory , index 8bit mode
		RTL
;
;
;
;
		MEM8
		IDX8
;
;
;
;
;
;
;
;
;
		END
