;
		INCLUDE	zel_ram.asm
;
;-----------------------------------------------------------------------
;
;		PAL_ZELDA-3 (FRANCE)		1992.05.28(THU)
;
;------------------------------------------------------------------------
;
		ORG	00CF00H
;
;=============================================== (zel_char0) ============
		GLB	CHSCHNG,CHSCHN0,CHSCHN1,CHSCHN2,CHRCHNG,CHRCBS0,CHRCBS1,CHRCBSZ
		GLB	CCBFIT,KNCBFST,TTCBFST,WTRCBFS0,WTRCBFS1,OPTCBFST
		GLB	ITMCBFST,ITMCBFST1,BGCHCNG,OJCHCNG,SPOJCNG
		GLB	MPICBST,WGBGCNG,M7CHST,MSGVRMS,ENDGVRMS
;
		GLB	spoj0,spoj1,spoj2,spoj3,spoj4,spoj5,spoj6,spoj7,spoj8,spoj9
;
		GLB	PICCPT,BGCBDT0
;
		GLB	C_0A0,C_4C0
		GLB	C_1X0,C_1Y0,C_2R1,C_2U0,C_2W0
		GLB	C_1W0,C_1Y1,C_1Z0,C_1Z1,C_2V0,C_2A0
;=============================================== (zel_char1) ============
		EXT	CHITEMST,CHITEMS0
;=============================================== (zel_vma) ==============
		EXT	PCHDT0,PCHDT1,PCHDT2
;
		EXT	bgwB,bgwC,bgwD,bgwE,bgwF,bgw10,bgw11,bgw12,bgw13,bgw14
;=============================================== (zel_init) =============
		EXT	KGBG000,KGBG100,KGBG200,BCKG800
;=============================================== (zel_play) =============
		EXT	RABHEN,prnce
;========================================================================
		EXT	MOJIFNT
;========================================================================
;
		EXTEND
		MEM8
		IDX8
;
;
;
;=====================================================================
DCP000		EQU	108000H
DCB000		EQU	10F000H
DCB001		EQU	10F600H
DCB002		EQU	10FC00H
DCB003		EQU	118200H
DCB004		EQU	118800H
DCB005		EQU	118E00H
DCB006		EQU	119400H
DCB007		EQU	119A00H
DCB008		EQU	11A000H
DCB009		EQU	11A600H
DCB00A		EQU	11AC00H
DCB00B		EQU	11B200H
DCB00C		EQU	11B800H
DCB00D		EQU	11BCE2H
DCB00E		EQU	11C15FH
DCB00F		EQU	11C675H
DCB010		EQU	11CB84H
DCB011		EQU	11CF4CH
DCB012		EQU	11D2CEH
DCB013		EQU	11D726H
DCB014		EQU	11D9CFH
DCB015		EQU	11DEC4H
DCB016		EQU	11E393H
DCB017		EQU	11E893H
DCB018		EQU	11ED7DH
DCB019		EQU	11F283H
DCB01A		EQU	11F746H
DCB01B		EQU	11FC21H
DCB01C		EQU	11FFF2H
DCB01D		EQU	128498H
DCB01E		EQU	128A0EH
DCB01F		EQU	128F30H
DCB020		EQU	129326H
DCB021		EQU	129804H
DCB022		EQU	129D5BH
DCB023		EQU	12A272H
DCB024		EQU	12A6F9H
DCB025		EQU	12AA72H
DCB026		EQU	12AD7EH
DCB027		EQU	12B162H
DCB028		EQU	12B518H
DCB029		EQU	12B83BH
DCB02A		EQU	12BD4FH
DCB02B		EQU	12C1C4H
DCB02C		EQU	12C738H
DCB02D		EQU	12CC81H
DCB02E		EQU	12D193H
DCB02F		EQU	12D6ACH
DCB030		EQU	12DB65H
DCB031		EQU	12E0E5H
DCB032		EQU	12E6B8H
DCB033		EQU	12EB4CH
DCB034		EQU	12F130H
DCB035		EQU	12F6C0H
DCB036		EQU	12FC6CH
DCB037		EQU	138124H
DCB038		EQU	13868EH
DCB039		EQU	138BA8H
DCB03A		EQU	139112H
DCB03B		EQU	139604H
DCB03C		EQU	139B1CH
DCB03D		EQU	13A06FH
DCB03E		EQU	13A614H
DCB03F		EQU	13AB26H
DCB040		EQU	13B007H
DCB041		EQU	13B4F0H
DCB042		EQU	13B9E6H
DCB043		EQU	13BEBAH
DCB044		EQU	13C3C9H
DCB045		EQU	13C812H
DCB046		EQU	13CB63H
DCB047		EQU	13CFB0H
DCB048		EQU	13D45BH
DCB049		EQU	13D8BDH
DCB04A		EQU	13DD75H
DCB04B		EQU	13E261H
DCB04C		EQU	13E7AAH
DCB04D		EQU	13ECE0H
DCB04E		EQU	13F240H
DCB04F		EQU	13F6EBH
DCB050		EQU	13FC2BH
DCB051		EQU	1480E4H
DCB052		EQU	148636H
DCB053		EQU	148A77H
DCB054		EQU	148F25H
DCB055		EQU	149341H
DCB056		EQU	1497E8H
DCB057		EQU	149CBDH
DCB058		EQU	14A16EH
DCB059		EQU	14A618H
DCB05A		EQU	14AB48H
DCB05B		EQU	14B06EH
DCB05C		EQU	14B4A8H
DCB05D		EQU	14B939H
DCB05E		EQU	14BDF9H
DCB05F		EQU	14C27CH
DCB060		EQU	14C79CH
DCB061		EQU	14CCC6H
DCB062		EQU	14D1BDH
DCB063		EQU	14D69FH
DCB064		EQU	14DB59H
DCB065		EQU	14DEB3H
DCB066		EQU	14E28EH
DCB067		EQU	14E736H
DCB068		EQU	14EB90H
DCB069		EQU	14EF30H
DCB06A		EQU	14F2EBH
DCB06B		EQU	14F6D6H
DCB06C		EQU	14FA37H
DCB06D		EQU	14FF6EH
DCB06E		EQU	14FF75H
DCB06F		EQU	14FF7CH
DCB070		EQU	14FF83H
DCB071		EQU	14FF8AH
DCB072		EQU	14FF91H
DCB073		EQU	14FF98H
DCB074		EQU	14FF9FH
DCB075		EQU	14FFA6H
DCB076		EQU	14FFADH
DCB077		EQU	14FFB4H
DCB078		EQU	14FFBBH
DCB079		EQU	14FFC2H
DCB07A		EQU	14FFC9H
DCB07B		EQU	14FFD0H
DCB07C		EQU	14FFD7H
DCB07D		EQU	14FFDEH
DCB07E		EQU	1585B6H
DCB07F		EQU	158A98H
DCB080		EQU	158FA0H
DCB081		EQU	1593DAH
DCB082		EQU	159988H
DCB083		EQU	159F14H
DCB084		EQU	15A3B9H
DCB085		EQU	15A8D3H
DCB086		EQU	15AEA8H
DCB087		EQU	15B3FAH
DCB088		EQU	15B929H
DCB089		EQU	15BEB2H
DCB08A		EQU	15C42BH
DCB08B		EQU	15C957H
DCB08C		EQU	15CE5EH
DCB08D		EQU	15D376H
DCB08E		EQU	15D88EH
DCB08F		EQU	15DDA2H
DCB090		EQU	15E32EH
DCB091		EQU	15E8CAH
DCB092		EQU	15EE13H
DCB093		EQU	15F388H
DCB094		EQU	15F90FH
DCB095		EQU	15FE9CH
DCB096		EQU	1682E1H
DCB097		EQU	1688C2H
DCB098		EQU	168E23H
DCB099		EQU	1692C1H
DCB09A		EQU	169865H
DCB09B		EQU	169CB2H
DCB09C		EQU	16A250H
DCB09D		EQU	16A257H
DCB09E		EQU	16A769H
DCB09F		EQU	16A848H
DCB0A0		EQU	16ACDFH
DCB0A1		EQU	16B241H
DCB0A2		EQU	16B6C0H
DCB0A3		EQU	16BCADH
DCB0A4		EQU	16BF7FH
DCB0A5		EQU	16C45BH
DCB0A6		EQU	16C9FDH
DCB0A7		EQU	16CF33H
DCB0A8		EQU	16D483H
DCB0A9		EQU	16D79CH
DCB0AA		EQU	16DBDBH
DCB0AB		EQU	16E0BAH
DCB0AC		EQU	16E5A2H
DCB0AD		EQU	16EB67H
DCB0AE		EQU	16F051H
DCB0AF		EQU	16F4F9H
DCB0B0		EQU	16F8A1H
DCB0B1		EQU	16FB6BH
DCB0B2		EQU	17800FH
DCB0B3		EQU	1784CFH
DCB0B4		EQU	1789A4H
DCB0B5		EQU	178E17H
DCB0B6		EQU	179369H
DCB0B7		EQU	17978DH
DCB0B8		EQU	179CE9H
DCB0B9		EQU	17A150H
DCB0BA		EQU	17A647H
DCB0BB		EQU	17AB3AH
DCB0BC		EQU	17B0E4H
DCB0BD		EQU	17B63BH
DCB0BE		EQU	17BAD5H
DCB0BF		EQU	17C079H
DCB0C0		EQU	17C5D0H
DCB0C1		EQU	17CB97H
DCB0C2		EQU	17D0FEH
DCB0C3		EQU	17D671H
DCB0C4		EQU	17DB2EH
DCB0C5		EQU	17E00EH
DCB0C6		EQU	17E1ADH
DCB0C7		EQU	17E684H
DCB0C8		EQU	17E97AH
DCB0C9		EQU	17EB9AH
DCB0CA		EQU	17EEAEH
DCB0CB		EQU	17F33FH
DCB0CC		EQU	17F87BH
DCB0CD		EQU	17FDC8H
DCB0CE		EQU	18829EH
DCB0CF		EQU	1887E3H
DCB0D0		EQU	188BA6H
DCB0D1		EQU	188FDFH
DCB0D2		EQU	189452H
DCB0D3		EQU	1896B9H
DCB0D4		EQU	189986H
DCB0D5		EQU	189C34H
DCB0D6		EQU	189EA1H
DCB0D7		EQU	18A34FH
DCB0D8		EQU	18A61CH
DCB0D9		EQU	18AD41H
DCB0DA		EQU	18AD6FH
DCB0DB		EQU	18B39BH
DCB0DC		EQU	18B765H
DCB0DD		EQU	18BDDFH
;
PICCPT          EQU     DCB0DA
;=====================================================================
;
;
;
BCADB		EQU	$
		BYTE	BANK DCB00C,BANK DCB00D,BANK DCB00E,BANK DCB00F
		BYTE	BANK DCB010,BANK DCB011,BANK DCB012,BANK DCB013
		BYTE	BANK DCB014,BANK DCB015,BANK DCB016,BANK DCB017
		BYTE	BANK DCB018,BANK DCB019,BANK DCB01A,BANK DCB01B
		BYTE	BANK DCB01C,BANK DCB01D,BANK DCB01E,BANK DCB01F
		BYTE	BANK DCB020,BANK DCB021,BANK DCB022,BANK DCB023
		BYTE	BANK DCB024,BANK DCB025,BANK DCB026,BANK DCB027
		BYTE	BANK DCB028,BANK DCB029,BANK DCB02A,BANK DCB02B
		BYTE	BANK DCB02C,BANK DCB02D,BANK DCB02E,BANK DCB02F
		BYTE	BANK DCB030,BANK DCB031,BANK DCB032,BANK DCB033
		BYTE	BANK DCB034,BANK DCB035,BANK DCB036,BANK DCB037
		BYTE	BANK DCB038,BANK DCB039,BANK DCB03A,BANK DCB03B
		BYTE	BANK DCB03C,BANK DCB03D,BANK DCB03E,BANK DCB03F
		BYTE	BANK DCB040,BANK DCB041,BANK DCB042,BANK DCB043
		BYTE	BANK DCB044,BANK DCB045,BANK DCB046,BANK DCB047
		BYTE	BANK DCB048,BANK DCB049,BANK DCB04A,BANK DCB04B
		BYTE	BANK DCB04C,BANK DCB04D,BANK DCB04E,BANK DCB04F
		BYTE	BANK DCB050,BANK DCB051,BANK DCB052,BANK DCB053
		BYTE	BANK DCB054,BANK DCB055,BANK DCB056,BANK DCB057
		BYTE	BANK DCB058,BANK DCB059,BANK DCB05A,BANK DCB05B
		BYTE	BANK DCB05C,BANK DCB05D,BANK DCB05E,BANK DCB05F
		BYTE	BANK DCB060,BANK DCB061,BANK DCB062,BANK DCB063
		BYTE	BANK DCB064,BANK DCB065,BANK DCB066,BANK DCB067
		BYTE	BANK DCB068,BANK DCB069,BANK DCB06A,BANK DCB06B
		BYTE	BANK DCB06C,BANK DCB06D,BANK DCB06E,BANK DCB06F
		BYTE	BANK DCB070,BANK DCB071,BANK DCB072,BANK DCB073
		BYTE	BANK DCB074,BANK DCB075,BANK DCB076,BANK DCB077
		BYTE	BANK DCB078,BANK DCB079,BANK DCB07A,BANK DCB07B
		BYTE	BANK DCB07C
		BYTE	BANK DCB0DB,BANK DCB0DC
;
OCADB		EQU	$
		BYTE	BANK DCB000,BANK DCB001,BANK DCB002,BANK DCB003
		BYTE	BANK DCB004,BANK DCB005,BANK DCB006,BANK DCB007
		BYTE	BANK DCB008,BANK DCB009,BANK DCB00A,BANK DCB00B
		BYTE	BANK DCB07D,BANK DCB07E,BANK DCB07F,BANK DCB080
		BYTE	BANK DCB081,BANK DCB082,BANK DCB083,BANK DCB084
		BYTE	BANK DCB085,BANK DCB086,BANK DCB087,BANK DCB088
		BYTE	BANK DCB089,BANK DCB08A,BANK DCB08B,BANK DCB08C
		BYTE	BANK DCB08D,BANK DCB08E,BANK DCB08F,BANK DCB090
		BYTE	BANK DCB091,BANK DCB092,BANK DCB093,BANK DCB094
		BYTE	BANK DCB095,BANK DCB096,BANK DCB097,BANK DCB098
		BYTE	BANK DCB099,BANK DCB09A,BANK DCB09B,BANK DCB09C
		BYTE	BANK DCB09D,BANK DCB09E,BANK DCB09F,BANK DCB0A0
		BYTE	BANK DCB0A1,BANK DCB0A2,BANK DCB0A3,BANK DCB0A4
		BYTE	BANK DCB0A5,BANK DCB0A6,BANK DCB0A7,BANK DCB0A8
		BYTE	BANK DCB0A9,BANK DCB0AA,BANK DCB0AB,BANK DCB0AC
		BYTE	BANK DCB0AD,BANK DCB0AE,BANK DCB0AF,BANK DCB0B0
		BYTE	BANK DCB0B1,BANK DCB0B2,BANK DCB0B3,BANK DCB0B4
		BYTE	BANK DCB0B5,BANK DCB0B6,BANK DCB0B7,BANK DCB0B8
		BYTE	BANK DCB0B9,BANK DCB0BA,BANK DCB0BB,BANK DCB0BC
		BYTE	BANK DCB0BD,BANK DCB0BE,BANK DCB0BF,BANK DCB0C0
		BYTE	BANK DCB0C1,BANK DCB0C2,BANK DCB0C3,BANK DCB0C4
		BYTE	BANK DCB0C5,BANK DCB0C6,BANK DCB0C7,BANK DCB0C8
		BYTE	BANK DCB0C9,BANK DCB0CA,BANK DCB0CB,BANK DCB0CC
		BYTE	BANK DCB0CD,BANK DCB0CE,BANK DCB0CF,BANK DCB0D0
		BYTE	BANK DCB0D1,BANK DCB0D2,BANK DCB0D3,BANK DCB0D4
		BYTE	BANK DCB0D5,BANK DCB0D6,BANK DCB0D7,BANK DCB0D8
		BYTE	BANK DCB0D9,BANK DCB0DA,BANK DCB0DB,BANK DCB0DC
;
;
BCADH		EQU	$
		BYTE	HIGH DCB00C,HIGH DCB00D,HIGH DCB00E,HIGH DCB00F
		BYTE	HIGH DCB010,HIGH DCB011,HIGH DCB012,HIGH DCB013
		BYTE	HIGH DCB014,HIGH DCB015,HIGH DCB016,HIGH DCB017
		BYTE	HIGH DCB018,HIGH DCB019,HIGH DCB01A,HIGH DCB01B
		BYTE	HIGH DCB01C,HIGH DCB01D,HIGH DCB01E,HIGH DCB01F
		BYTE	HIGH DCB020,HIGH DCB021,HIGH DCB022,HIGH DCB023
		BYTE	HIGH DCB024,HIGH DCB025,HIGH DCB026,HIGH DCB027
		BYTE	HIGH DCB028,HIGH DCB029,HIGH DCB02A,HIGH DCB02B
		BYTE	HIGH DCB02C,HIGH DCB02D,HIGH DCB02E,HIGH DCB02F
		BYTE	HIGH DCB030,HIGH DCB031,HIGH DCB032,HIGH DCB033
		BYTE	HIGH DCB034,HIGH DCB035,HIGH DCB036,HIGH DCB037
		BYTE	HIGH DCB038,HIGH DCB039,HIGH DCB03A,HIGH DCB03B
		BYTE	HIGH DCB03C,HIGH DCB03D,HIGH DCB03E,HIGH DCB03F
		BYTE	HIGH DCB040,HIGH DCB041,HIGH DCB042,HIGH DCB043
		BYTE	HIGH DCB044,HIGH DCB045,HIGH DCB046,HIGH DCB047
		BYTE	HIGH DCB048,HIGH DCB049,HIGH DCB04A,HIGH DCB04B
		BYTE	HIGH DCB04C,HIGH DCB04D,HIGH DCB04E,HIGH DCB04F
		BYTE	HIGH DCB050,HIGH DCB051,HIGH DCB052,HIGH DCB053
		BYTE	HIGH DCB054,HIGH DCB055,HIGH DCB056,HIGH DCB057
		BYTE	HIGH DCB058,HIGH DCB059,HIGH DCB05A,HIGH DCB05B
		BYTE	HIGH DCB05C,HIGH DCB05D,HIGH DCB05E,HIGH DCB05F
		BYTE	HIGH DCB060,HIGH DCB061,HIGH DCB062,HIGH DCB063
		BYTE	HIGH DCB064,HIGH DCB065,HIGH DCB066,HIGH DCB067
		BYTE	HIGH DCB068,HIGH DCB069,HIGH DCB06A,HIGH DCB06B
		BYTE	HIGH DCB06C,HIGH DCB06D,HIGH DCB06E,HIGH DCB06F
		BYTE	HIGH DCB070,HIGH DCB071,HIGH DCB072,HIGH DCB073
		BYTE	HIGH DCB074,HIGH DCB075,HIGH DCB076,HIGH DCB077
		BYTE	HIGH DCB078,HIGH DCB079,HIGH DCB07A,HIGH DCB07B
		BYTE	HIGH DCB07C
		BYTE	HIGH DCB0DB,HIGH DCB0DC
;
OCADH		EQU	$
		BYTE	HIGH DCB000,HIGH DCB001,HIGH DCB002,HIGH DCB003
		BYTE	HIGH DCB004,HIGH DCB005,HIGH DCB006,HIGH DCB007
		BYTE	HIGH DCB008,HIGH DCB009,HIGH DCB00A,HIGH DCB00B
		BYTE	HIGH DCB07D,HIGH DCB07E,HIGH DCB07F,HIGH DCB080
		BYTE	HIGH DCB081,HIGH DCB082,HIGH DCB083,HIGH DCB084
		BYTE	HIGH DCB085,HIGH DCB086,HIGH DCB087,HIGH DCB088
		BYTE	HIGH DCB089,HIGH DCB08A,HIGH DCB08B,HIGH DCB08C
		BYTE	HIGH DCB08D,HIGH DCB08E,HIGH DCB08F,HIGH DCB090
		BYTE	HIGH DCB091,HIGH DCB092,HIGH DCB093,HIGH DCB094
		BYTE	HIGH DCB095,HIGH DCB096,HIGH DCB097,HIGH DCB098
		BYTE	HIGH DCB099,HIGH DCB09A,HIGH DCB09B,HIGH DCB09C
		BYTE	HIGH DCB09D,HIGH DCB09E,HIGH DCB09F,HIGH DCB0A0
		BYTE	HIGH DCB0A1,HIGH DCB0A2,HIGH DCB0A3,HIGH DCB0A4
		BYTE	HIGH DCB0A5,HIGH DCB0A6,HIGH DCB0A7,HIGH DCB0A8
		BYTE	HIGH DCB0A9,HIGH DCB0AA,HIGH DCB0AB,HIGH DCB0AC
		BYTE	HIGH DCB0AD,HIGH DCB0AE,HIGH DCB0AF,HIGH DCB0B0
		BYTE	HIGH DCB0B1,HIGH DCB0B2,HIGH DCB0B3,HIGH DCB0B4
		BYTE	HIGH DCB0B5,HIGH DCB0B6,HIGH DCB0B7,HIGH DCB0B8
		BYTE	HIGH DCB0B9,HIGH DCB0BA,HIGH DCB0BB,HIGH DCB0BC
		BYTE	HIGH DCB0BD,HIGH DCB0BE,HIGH DCB0BF,HIGH DCB0C0
		BYTE	HIGH DCB0C1,HIGH DCB0C2,HIGH DCB0C3,HIGH DCB0C4
		BYTE	HIGH DCB0C5,HIGH DCB0C6,HIGH DCB0C7,HIGH DCB0C8
		BYTE	HIGH DCB0C9,HIGH DCB0CA,HIGH DCB0CB,HIGH DCB0CC
		BYTE	HIGH DCB0CD,HIGH DCB0CE,HIGH DCB0CF,HIGH DCB0D0
		BYTE	HIGH DCB0D1,HIGH DCB0D2,HIGH DCB0D3,HIGH DCB0D4
		BYTE	HIGH DCB0D5,HIGH DCB0D6,HIGH DCB0D7,HIGH DCB0D8
		BYTE	HIGH DCB0D9,HIGH DCB0DA,HIGH DCB0DB,HIGH DCB0DC
;
;
BCADL		EQU	$
		BYTE	LOW DCB00C,LOW DCB00D,LOW DCB00E,LOW DCB00F
		BYTE	LOW DCB010,LOW DCB011,LOW DCB012,LOW DCB013
		BYTE	LOW DCB014,LOW DCB015,LOW DCB016,LOW DCB017
		BYTE	LOW DCB018,LOW DCB019,LOW DCB01A,LOW DCB01B
		BYTE	LOW DCB01C,LOW DCB01D,LOW DCB01E,LOW DCB01F
		BYTE	LOW DCB020,LOW DCB021,LOW DCB022,LOW DCB023
		BYTE	LOW DCB024,LOW DCB025,LOW DCB026,LOW DCB027
		BYTE	LOW DCB028,LOW DCB029,LOW DCB02A,LOW DCB02B
		BYTE	LOW DCB02C,LOW DCB02D,LOW DCB02E,LOW DCB02F
		BYTE	LOW DCB030,LOW DCB031,LOW DCB032,LOW DCB033
		BYTE	LOW DCB034,LOW DCB035,LOW DCB036,LOW DCB037
		BYTE	LOW DCB038,LOW DCB039,LOW DCB03A,LOW DCB03B
		BYTE	LOW DCB03C,LOW DCB03D,LOW DCB03E,LOW DCB03F
		BYTE	LOW DCB040,LOW DCB041,LOW DCB042,LOW DCB043
		BYTE	LOW DCB044,LOW DCB045,LOW DCB046,LOW DCB047
		BYTE	LOW DCB048,LOW DCB049,LOW DCB04A,LOW DCB04B
		BYTE	LOW DCB04C,LOW DCB04D,LOW DCB04E,LOW DCB04F
		BYTE	LOW DCB050,LOW DCB051,LOW DCB052,LOW DCB053
		BYTE	LOW DCB054,LOW DCB055,LOW DCB056,LOW DCB057
		BYTE	LOW DCB058,LOW DCB059,LOW DCB05A,LOW DCB05B
		BYTE	LOW DCB05C,LOW DCB05D,LOW DCB05E,LOW DCB05F
		BYTE	LOW DCB060,LOW DCB061,LOW DCB062,LOW DCB063
		BYTE	LOW DCB064,LOW DCB065,LOW DCB066,LOW DCB067
		BYTE	LOW DCB068,LOW DCB069,LOW DCB06A,LOW DCB06B
		BYTE	LOW DCB06C,LOW DCB06D,LOW DCB06E,LOW DCB06F
		BYTE	LOW DCB070,LOW DCB071,LOW DCB072,LOW DCB073
		BYTE	LOW DCB074,LOW DCB075,LOW DCB076,LOW DCB077
		BYTE	LOW DCB078,LOW DCB079,LOW DCB07A,LOW DCB07B
		BYTE	LOW DCB07C
		BYTE	LOW DCB0DB,LOW DCB0DC
;
OCADL		EQU	$
		BYTE	LOW DCB000,LOW DCB001,LOW DCB002,LOW DCB003
		BYTE	LOW DCB004,LOW DCB005,LOW DCB006,LOW DCB007
		BYTE	LOW DCB008,LOW DCB009,LOW DCB00A,LOW DCB00B
		BYTE	LOW DCB07D,LOW DCB07E,LOW DCB07F,LOW DCB080
		BYTE	LOW DCB081,LOW DCB082,LOW DCB083,LOW DCB084
		BYTE	LOW DCB085,LOW DCB086,LOW DCB087,LOW DCB088
		BYTE	LOW DCB089,LOW DCB08A,LOW DCB08B,LOW DCB08C
		BYTE	LOW DCB08D,LOW DCB08E,LOW DCB08F,LOW DCB090
		BYTE	LOW DCB091,LOW DCB092,LOW DCB093,LOW DCB094
		BYTE	LOW DCB095,LOW DCB096,LOW DCB097,LOW DCB098
		BYTE	LOW DCB099,LOW DCB09A,LOW DCB09B,LOW DCB09C
		BYTE	LOW DCB09D,LOW DCB09E,LOW DCB09F,LOW DCB0A0
		BYTE	LOW DCB0A1,LOW DCB0A2,LOW DCB0A3,LOW DCB0A4
		BYTE	LOW DCB0A5,LOW DCB0A6,LOW DCB0A7,LOW DCB0A8
		BYTE	LOW DCB0A9,LOW DCB0AA,LOW DCB0AB,LOW DCB0AC
		BYTE	LOW DCB0AD,LOW DCB0AE,LOW DCB0AF,LOW DCB0B0
		BYTE	LOW DCB0B1,LOW DCB0B2,LOW DCB0B3,LOW DCB0B4
		BYTE	LOW DCB0B5,LOW DCB0B6,LOW DCB0B7,LOW DCB0B8
		BYTE	LOW DCB0B9,LOW DCB0BA,LOW DCB0BB,LOW DCB0BC
		BYTE	LOW DCB0BD,LOW DCB0BE,LOW DCB0BF,LOW DCB0C0
		BYTE	LOW DCB0C1,LOW DCB0C2,LOW DCB0C3,LOW DCB0C4
		BYTE	LOW DCB0C5,LOW DCB0C6,LOW DCB0C7,LOW DCB0C8
		BYTE	LOW DCB0C9,LOW DCB0CA,LOW DCB0CB,LOW DCB0CC
		BYTE	LOW DCB0CD,LOW DCB0CE,LOW DCB0CF,LOW DCB0D0
		BYTE	LOW DCB0D1,LOW DCB0D2,LOW DCB0D3,LOW DCB0D4
		BYTE	LOW DCB0D5,LOW DCB0D6,LOW DCB0D7,LOW DCB0D8
		BYTE	LOW DCB0D9,LOW DCB0DA,LOW DCB0DB,LOW DCB0DC
;
;
;
;
;
C_0A0		EQU	000H
C_0A1		EQU	001H
C_0B0		EQU	002H
C_0B1		EQU	003H
C_0C0		EQU	004H
C_0C1		EQU	005H
C_0D0		EQU	006H
C_0D1		EQU	007H
C_0E0		EQU	008H
C_0E1		EQU	009H
C_0F0		EQU	00AH
C_0F1		EQU	00BH
C_0G0		EQU	00CH
C_0G1		EQU	00DH
C_0H0		EQU	00EH
C_0H1		EQU	00FH
C_0I0		EQU	010H
C_0I1		EQU	011H
C_0J0		EQU	012H
;;;;;;;;C_0J1		EQU	013H
C_0K0		EQU	013H
C_0K1		EQU	014H
C_0L0		EQU	015H
;;;;;;;;C_0L1		EQU	017H
C_0M0		EQU	016H
C_0M1		EQU	017H
C_0N0		EQU	018H
C_0N1		EQU	019H
C_0O0		EQU	01AH
C_0O1		EQU	01BH
C_0P0		EQU	01CH
;;;;;;;;C_0P1		EQU	01FH
;;;;;;;;C_0Q0		EQU	020H
;;;;;;;;C_0Q1		EQU	021H
C_0R0		EQU	01DH
C_0R1		EQU	01EH
C_0S0		EQU	01FH
C_0S1		EQU	020H
C_0T0		EQU	021H
C_0T1		EQU	022H
C_0U0		EQU	023H
C_0U1		EQU	024H
C_0V0		EQU	025H
C_0V1		EQU	026H
C_0W0		EQU	027H
C_0W1		EQU	028H
C_0X0		EQU	029H
C_0X1		EQU	02AH
C_0Y0		EQU	02BH
C_0Y1		EQU	02CH
C_0Z0		EQU	02DH
C_0Z1		EQU	02EH
C_1A0		EQU	02FH
C_1A1		EQU	030H
C_1B0		EQU	031H
C_1B1		EQU	032H
C_1C0		EQU	033H
C_1C1		EQU	034H
C_1D0		EQU	035H
C_1D1		EQU	036H
C_1E0		EQU	037H
C_1E1		EQU	038H
;;;;;;;;C_1F0		EQU	03EH
C_1F1		EQU	039H
C_1G0		EQU	03AH
C_1G1		EQU	03BH
C_1H0		EQU	03CH
C_1H1		EQU	03DH
C_1I0		EQU	03EH
C_1I1		EQU	03FH
C_1J0		EQU	040H
C_1J1		EQU	041H
C_1K0		EQU	042H
C_1K1		EQU	043H
C_1L0		EQU	044H
C_1L1		EQU	045H
C_1M0		EQU	046H
;;;;;;;;C_1M1		EQU	047H
C_1N0		EQU	047H
C_1N1		EQU	048H
;;;;;;;;C_1O0		EQU	050H
C_1O1		EQU	049H
C_1P0		EQU	04AH
C_1P1		EQU	04BH
C_1Q0		EQU	04CH
C_1Q1		EQU	04DH
C_1R0		EQU	04EH
C_1R1		EQU	04FH
C_1S0		EQU	050H
C_1S1		EQU	051H
C_1T0		EQU	052H
C_1T1		EQU	053H
C_1U0		EQU	054H
C_1U1		EQU	055H
C_1V0		EQU	056H
C_1V1		EQU	057H
C_1W0		EQU	058H
C_1W1		EQU	059H
C_1X0		EQU	05AH
C_1X1		EQU	05BH
C_1Y0		EQU	05CH
C_1Y1		EQU	05DH
C_1Z0		EQU	05EH
C_1Z1		EQU	05FH
C_2A0		EQU	060H
;;;;;;;;C_2A1		EQU	069H
;;;;;;;;C_2B0		EQU	06AH
;;;;;;;;C_2B1		EQU	06BH
;;;;;;;;C_2C0		EQU	06CH
;;;;;;;;C_2C1		EQU	06DH
;;;;;;;;C_2D0		EQU	06EH
;;;;;;;;C_2D1		EQU	06FH
C_2E0		EQU	061H	;070H
C_2E1		EQU	062H	;071H
C_2F0		EQU	063H	;072H
C_2F1		EQU	064H	;073H
C_2G0		EQU	065H	;074H
C_2G1		EQU	066H	;075H
C_2H0		EQU	067H	;076H
C_2H1		EQU	068H	;077H
C_2I0		EQU	069H	;078H
C_2I1		EQU	06AH	;079H
C_2J0		EQU	06BH	;07AH
C_2J1		EQU	06CH	;07BH
C_2K0		EQU	06DH	;07CH
C_2K1		EQU	06EH	;07DH
C_2L0		EQU	06FH	;07EH
C_2L1		EQU	070H	;07FH		; BG. char.
C_4R0		EQU	071H	;080H	;0E8H	; Map BG.
C_4R1		EQU	072H	;081H	;0E9H	; Map BG.
;
;;;;C_2M		EQU	000H
;;;;C_2N		EQU	000H
;;;;C_2O		EQU	000H
;;;;C_2P		EQU	000H
;;;;C_2Q		EQU	000H	; Player char. BANK
C_2R0		EQU	000H	;080H
C_2R1		EQU	001H	;081H
C_2S0		EQU	002H	;082H
C_2S1		EQU	003H	;083H
C_2T0		EQU	004H	;084H
C_2T1		EQU	005H	;085H
C_2U0		EQU	006H	;086H
C_2U1		EQU	007H	;087H
C_2V0		EQU	008H	;088H
C_2V1		EQU	009H	;089H
C_2W0		EQU	00AH	;08AH
C_2W1		EQU	00BH	;08BH
C_2X0		EQU	00CH	;08CH
C_2X1		EQU	00DH	;08DH
C_2Y0		EQU	00EH	;08EH
C_2Y1		EQU	00FH	;08FH
C_2Z0		EQU	010H	;090H
C_2Z1		EQU	011H	;091H
C_3A0		EQU	012H	;092H
C_3A1		EQU	013H	;093H
C_3B0		EQU	014H	;094H
C_3B1		EQU	015H	;095H
C_3C0		EQU	016H	;096H
C_3C1		EQU	017H	;097H
C_3D0		EQU	018H	;098H
C_3D1		EQU	019H	;099H
C_3E0		EQU	01AH	;09AH
C_3E1		EQU	01BH	;09BH
C_3F0		EQU	01CH	;09CH
C_3F1		EQU	01DH	;09DH
C_3G0		EQU	01EH	;09EH
C_3G1		EQU	01FH	;09FH
C_3H0		EQU	020H	;0A0H
C_3H1		EQU	021H	;0A1H
C_3I0		EQU	022H	;0A2H
C_3I1		EQU	023H	;0A3H
C_3J0		EQU	024H	;0A4H
C_3J1		EQU	025H	;0A5H
C_3K0		EQU	026H	;0A6H
C_3K1		EQU	027H	;0A7H
C_3L0		EQU	028H	;0A8H
C_3L1		EQU	029H	;0A9H
C_3M0		EQU	02AH	;0AAH
C_3M1		EQU	02BH	;0ABH
C_3N0		EQU	02CH	;0ACH
C_3N1		EQU	02DH	;0ADH
C_3O0		EQU	02EH	;0AEH
C_3O1		EQU	02FH	;0AFH
C_3P0		EQU	030H	;0B0H
C_3P1		EQU	031H	;0B1H
C_3Q0		EQU	032H	;0B2H
C_3Q1		EQU	033H	;0B3H
C_3R0		EQU	034H	;0B4H
C_3R1		EQU	035H	;0B5H
C_3S0		EQU	036H	;0B6H
C_3S1		EQU	037H	;0B7H
;;;C_3T0		EQU	038H	;0B8H
;;;C_3T1		EQU	039H	;0B9H
;;;C_3U0		EQU	03AH	;0BAH
;;;C_3U1		EQU	03BH	;0BBH
C_3V0		EQU	038H	;03CH	;0BCH
C_3V1		EQU	039H	;03DH	;0BDH
C_3W0		EQU	03AH	;03EH	;0BEH
C_3W1		EQU	03BH	;03FH	;0BFH
C_3X0		EQU	03CH	;040H	;0C0H
C_3X1		EQU	03DH	;041H	;0C1H
C_3Y0		EQU	03EH	;042H	;0C2H
C_3Y1		EQU	03FH	;043H	;0C3H
C_3Z0		EQU	040H	;044H	;0C4H
C_3Z1		EQU	041H	;045H	;0C5H
C_4A0		EQU	042H	;046H	;0C6H
C_4A1		EQU	043H	;047H	;0C7H
C_4B0		EQU	044H	;048H	;0C8H
C_4B1		EQU	045H	;049H	;0C9H
C_4C0		EQU	046H	;04AH	;0CAH
C_4C1		EQU	047H	;04BH	;0CBH
C_4D0		EQU	048H	;04CH	;0CCH
C_4D1		EQU	049H	;04DH	;0CDH
C_4E0		EQU	04AH	;04EH	;0CEH
C_4E1		EQU	04BH	;04FH	;0CFH
C_4F0		EQU	04CH	;050H	;0D0H
C_4F1		EQU	04DH	;051H	;0D1H
C_4G0		EQU	04EH	;052H	;0D2H
C_4G1		EQU	04FH	;053H	;0D3H
C_4H0		EQU	050H	;054H	;0D4H
C_4H1		EQU	051H	;055H	;0D5H
C_4I0		EQU	052H	;056H	;0D6H
C_4I1		EQU	053H	;057H	;0D7H
C_4J0		EQU	054H	;058H	;0D8H
C_4J1		EQU	055H	;059H	;0D9H
C_4K0		EQU	056H	;05AH	;0DAH
C_4K1		EQU	057H	;05BH	;0DBH
C_4L0		EQU	058H	;05CH	;0DCH
C_4L1		EQU	059H	;05DH	;0DDH
C_4M0		EQU	05AH	;05EH	;0DEH
C_4M1		EQU	05BH	;05FH	;0DFH
C_4N0		EQU	05CH	;060H	;0E0H
C_4N1		EQU	05DH	;061H	;0E1H
C_4O0		EQU	05EH	;062H	;0E2H
C_4O1		EQU	05FH	;063H	;0E3H
C_4P0		EQU	060H	;064H	;0E4H
;;;;;;;;C_4P1		EQU	061H	;065H	;0E5H
C_4Q0		EQU	061H	;066H	;0E6H
C_4Q1		EQU	062H	;067H	;0E7H
;// 02.10.23 //C_4R0		EQU	068H	;0E8H
;// 02.10.23 //C_4R1		EQU	069H	;0E9H
C_4R2		EQU	063H	;068H	;0E8H		; Map obj.
C_4R3		EQU	064H	;069H	;0E9H		; Map obj.
;
C_4S0		EQU	065H	;06AH	;0EAH
C_4S1		EQU	066H	;06BH	;0EBH
;
C_4T		EQU	067H	;06CH	;0ECH
C_4U		EQU	068H	;06DH	;0EDH
C_4V		EQU	069H	;06EH	;0EEH
C_4W		EQU	06AH	;06FH	;0EFH
C_4X		EQU	06BH	;070H	;0F0H		; BG.3 char.
;
;
;
;
;************************************************************************
;*		Change char. buffer initial set		(CCBFIT)	*
;************************************************************************
BYCDPD		EQU	$		; [B],[Y] char. data pointer
;			     loot     hammer      arrow      skope
		WORD	00018H*00H,00018H*0BH,00018H*08H,00018H*26H
;			 zzz,onpu       kona    bow-gun        ami
		WORD	00018H*2AH,00018H*2DH,00018H*22H,00018H*03H
;			 soromon        book
		WORD	00018H*21H,00018H*2EH
;
;
CCBFIT		EQU	$
;---------------------------------------- [B],[Y] item char.buffer set
		PHB
		PHK
		PLB			; (DBR) push
;
		MEM16
		REP	#00100000B	; memory 16bit mode
;
		STZ	<WORKA
		STZ	<WORKC
		LDA	#IMCHBF-CNGCHBF
		STA	<WORK6
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;
		LDA	#007H
		JSR	CCBIS000	; loot char. buffer set
;
		LDA	#007H
		JSR	CCBIS000	; hammer char. buufer set
;
		LDA	#003H
		JSR	CCBIS000	; arrow char. buufer set
;
		LDY	#C_4O1
		LDA	#004H
		JSR	CCBIS100	; skope char. buufer set
;
;// 02.10.23 //		LDY	#C_2S0
;// 02.10.23 //		LDA	#003H
;// 02.10.23 //		JSR	CCBIS040	; zzz,onpu char. buffer set
		LDA	#003H
		JSR	CCBIS140	; zzz,onpu char. buffer set
;
		LDA	#001H
		JSR	CCBIS140	; kona char. buffer set
;
		LDA	#004H
		JSR	CCBIS000	; bow-gun char. buufer set
;
		LDY	#C_4P0
		LDA	#00EH
		JSR	CCBIS100	; ami char. buufer set
;
		LDA	#007H
		JSR	CCBIS140	; soromon char. buufer set
;
		LDY	#C_4O1
		LDA	#002H
		JSR	CCBIS100	; book char. buufer set
;
;---------------------------------------- block char. buffer set
		LDY	#C_4J0
		JSR	CADWKST2	; Obj. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDX	#BKCHBF-CNGCHBF
		PHA			; (A) push
		LDY	#00008H
		JSR	CCBIS420	; block char. set
;// 02.10.30 //		JSR	CCBIS200	; block char. set
;
		PLA			; (A) pull
		CLC
		ADC	#00180H
		LDY	#00008H
		JSR	CCBIS420	; block char. set
;// 02.10.30 //		JSR	CCBIS200	; block char. set
;
;
;;;;;;;;;---------------------------------------- water char. buffer set
;;;;;;;;		MEM8
;;;;;;;;		IDX8
;;;;;;;;		SEP	#00110000B	; memory,index 8bit mode
;;;;;;;;;
;;;;;;;;		LDY	#C_1F0
;;;;;;;;		JSR	CADWKST0	; Bg.. char. address work set
;;;;;;;;;
;;;;;;;;		MEM16
;;;;;;;;		IDX16
;;;;;;;;		REP	#00110000B	; memory,index 16bit mode
;;;;;;;;;
;;;;;;;;		LDA	<WORK0
;;;;;;;;		LDY	#(16+4)*3
;;;;;;;;		LDX	#WTRCHBF-CNGCHBF
;;;;;;;;		JSR	CCBIS320	; water char. buffer set
;;;;;;;;;
;;;;;;;;		MEM8
;;;;;;;;		IDX8
;;;;;;;;		SEP	#00110000B	; memory,index 8bit mode
;
;
;---------------------------------------- enemy out item char. buffer set
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		LDY	#C_4P0
		JSR	CADWKST2	; Obj. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDX	#EICHBF-CNGCHBF
		LDY	#00003H
		PHA			; (A) push
		JSR	CCBIS420	; enemy out item(rupy) char. buffer set
;
		PLA			; (A) pull
		CLC
		ADC	#00180H
		LDY	#00003H
		JSR	CCBIS420	; enemy out item(rupy) char. buffer set
;
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
;// 03.07.03 //;// 02.10.23 //		LDY	#C_2T0
;// 03.07.03 //;// 02.10.23 //		JSR	CADWKST		; char. address work set
;// 03.07.03 //		LDA	#BANK MPCHBF
;// 03.07.03 //		STA	<WORK2
;// 03.07.03 //		STA	<WORK5
;// 03.07.03 //;
;// 03.07.03 //		MEM16
;// 03.07.03 //		IDX16
;// 03.07.03 //		REP	#00110001B	; memory,index 16bit mode & CLC
;// 03.07.03 //;
;// 03.07.03 //		LDA	#MPCHBF
;// 03.07.03 //;// 02.10.23 //		LDA	<WORK0
;// 03.07.03 //		ADC	#00018H*3
;// 03.07.03 //		LDX	#(EICHBF-CNGCHBF)+20H*6
;// 03.07.03 //		LDY	#(2*3)*3
;// 03.07.03 //		PHA			; (A) push
;// 03.07.03 //		JSR	CCBIS420	; enemy out item char. buffer set
;// 03.07.03 //;
;// 03.07.03 //		PLA			; (A) pull
;// 03.07.03 //		CLC
;// 03.07.03 //		ADC	#00180H
;// 03.07.03 //		LDY	#(2*3)*3
;// 03.07.03 //		JSR	CCBIS420	; enemy out item char. buffer set
;// 03.07.03 //;
;// 03.07.03 //		MEM8
;// 03.07.03 //		IDX8
;// 03.07.03 //		SEP	#00110000B	; memory,index 8bit mode
;
		JSR	TMYKCBST	; tama-yuka char.buffer set
;;;;;;;;		JSR	TRICBFST	; tori character buffer set
;;;;;;;;		JSR	SWYCBFST	; swich-yuka character buffer set
;
		PLB			; (DBR) pull
		RTL
;
;
;
;
;
;
;************************************************************************
;*		Sword char. buffer initial set		(KNCBFST)	*
;************************************************************************
KNCDPD		EQU	$		; sword char. data pointer
		WORD	00018H*0CH*0,00018H*0CH*0,00018H*0CH*1,00018H*0CH*1,00018H*0CH*1
;
;
KNCBFST		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDY	#C_4O1
		JSR	CADWKST3	; Obj. char. address work set
		LDY	#C_4O0
		JSR	CADWKST2	; Obj. char. address work set
;
		MEM16
		REP	#00100001B	; memory 16bit mode & CLC
;
		LDA	>ITMTBL6
		AND	#000FFH
		ASL	A
		TAY
		LDA	<WORK0
		ADC	KNCDPD,Y
;
		IDX16
		REP	#00010000B	; index 16bit mode
;
		LDX	#KNCHBF-CNGCHBF
		LDY	#0000CH
		PHA			; (A) push
		JSR	CCBIS420	; sword char. buffer set
;
		PLA			; (A) pull
		CLC
		ADC	#00180H
		LDY	#0000CH
		JSR	CCBIS420	; sword char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		PLB			; (DBR) reset
		RTL
;
;
;
;************************************************************************
;*		Shild char. buffer initial set		(TTCBFST)	*
;************************************************************************
TTCDPD		EQU	$		; shild char. data pointer
		WORD	00018H*44H,00018H*44H,00018H*4AH,00018H*60H
;
;
TTCBFST		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDY	#C_4O1
		JSR	CADWKST3	; Obj. char. address work set
		LDY	#C_4O0
		JSR	CADWKST2	; Obj. char. address work set
;
		MEM16
		REP	#00100001B	; memory 16bit mode & CLC
;
		LDA	>ITMTBL7
		ASL	A
		TAY
		LDA	<WORK0
		ADC	TTCDPD,Y
;
		IDX16
		REP	#00010000B	; index 16bit mode
;
		LDX	#TTCHBF-CNGCHBF
		PHA			; (A) push
		JSR	CCBIS400	; shild char. buffer set
;
		PLA			; (A) pull
		CLC
		ADC	#00180H
		JSR	CCBIS400	; shild char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		PLB			; (DBR) reset
		RTL
;
;
;
;************************************************************************
;*		Water Character buffer set 		(WTRCBFS0)	*
;*		[in]	(Y)	<-- chara. pointer			*
;************************************************************************
WTRCBFS0	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		JSR	CADWKST0	; Bg. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDY	#(10H+10H+10H)
		LDX	#WTRCHBF-CNGCHBF
		JSR	CCBIS320	; water char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		LDY	#C_1Y0
		JSR	CADWKST0	; Bg. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDY	#(10H+10H+10H)
		LDX	#WTRCHBF-CNGCHBF+((10H+10H+10H)*20H)
		JSR	CCBIS320	; water char. buffer set
;
		LDX	#00000H
WTRCS020	EQU	$
		LDA	>WTRCHBF+(10H*20H)*1,X
		PHA			; (A) push
		LDA	>WTRCHBF+(10H*20H)*3,X
		STA	>WTRCHBF+(10H*20H)*1,X
		LDA	>WTRCHBF+(10H*20H)*4,X
		STA	>WTRCHBF+(10H*20H)*3,X
		LDA	>WTRCHBF+(10H*20H)*2,X
		STA	>WTRCHBF+(10H*20H)*4,X
		PLA			; (A) pull
		STA	>WTRCHBF+(10H*20H)*2,X
		INX
		INX
		CPX	#00010H*20H
		BNE	WTRCS020	; move end ?
;					; yes
		LDA	#03B00H
		STA	!WTRADR
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		PLB			; (DBR) reset
		RTL
;
;
;
;************************************************************************
;*		Water Character buffer set 		(WTRCBFS1)	*
;*		[in]	(Y)	<-- chara. pointer			*
;************************************************************************
WTRCBFS1	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		PHY			; (Y) push
;
		JSR	CADWKST0	; Bg. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDY	#(10H+10H)*2
		LDX	#WTRCHBF-CNGCHBF
		JSR	CCBIS320	; water char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		PLY			; (Y) pull
		INY
		JSR	CADWKST0	; Bg. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDY	#(10H+10H)*1
		LDX	#WTRCHBF-CNGCHBF+((10H+10H)*20H*2)
		JSR	CCBIS320	; water char. buffer set
;
		LDA	#03C00H
		STA	!WTRADR
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		PLB			; (DBR) reset
		RTL
;
;
;
;
;************************************************************************
;*		Tama-yuka Character buffer		(TMYKCBST)	*
;************************************************************************
TMYKCBST	EQU	$
		LDY	#C_0H1
		JSR	CADWKST0	; BG. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDY	#00010H
		LDX	#TYCHBF-CNGCHBF
		JSR	CCBIS320	; tama-yuka char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
;
;************************************************************************
;*		Warp-tori Character buffer set 		(TRICBFST)	*
;************************************************************************
TRICBFST	EQU	$
		LDY	#C_4L0
		JSR	CADWKST2	; OBJ. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		LDY	#(10H+10H)
		LDX	#TRICHBF-CNGCHBF
		JSR	CCBIS320	; tori char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
;************************************************************************
;*		Swich-yuka Character buffer		(SWYCBFST)	*
;************************************************************************
SWYCBFST	EQU	$
		LDY	#C_0C1
		JSR	CADWKST0	; BG. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		CLC
		ADC	#00018H*30H
		LDY	#00002H
		LDX	#SWYCHBF-CNGCHBF
		JSR	CCBIS320	; swich-yuka char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTS
;
;
;
;
;************************************************************************
;*		Option Character buffer set 		(OPTCBFST)	*
;*		[in]	(Y)	<-- chara. pointer			*
;************************************************************************
OPTDPT		EQU	$
;			   not     queen     jiji     jiji
		WORD	018H*00H,018H*40H,018H*20H,018H*20H
;			   jiji   dammy      girl  kajiya(ura)
		WORD	018H*20H,0000000H,018H*00H,018H*60H
;			 kajiya    oyaji   monky    monky
		WORD	018H*40H,018H*40H,018H*60H,018H*60H
;			 takara     bomb
		WORD	018H*40H,018H*60H
;
;
OPTCBFST	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDY	#C_4R3
		LDA	>OPMODE
		CMP	#prnce
		BEQ	OPTCS20		; zelda-queen ?
;					; no
		LDY	#C_4S1
		LDA	>OPMODE
		CMP	#009H
		BCC	OPTCS20		; queen,jiji,baba,kajiya ?
;					; no
		LDY	#C_4L1
		CMP	#00CH
		BCC	OPTCS20		; oyaji,monky ?
;					; no
		LDY	#C_4L0		; takara,bomb
OPTCS20		EQU	$
		JSR	CADWKST3	; Obj. char. address work set
		LDY	#C_4S0
		JSR	CADWKST2	; OBJ. char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	>OPMODE
		AND	#000FFH
		ASL	A
		TAX
		LDA	<WORK0
		CLC
		ADC	>OPTDPT,X
		LDY	#(10H+10H)*1
		LDX	#OPTCHBF-CNGCHBF
		JSR	CCBIS320	; option char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		PLB			; (DBR) reset
		RTL
;
;
;************************************************************************
;*		Item char. buffer set			(ITMCBFST)	*
;************************************************************************
ITMCPTD		EQU	$
;			   bin       bomb*3     ya*10        life
		WORD	00018H*68H,00018H*02H,00018H*04H,00018H*06H
;			   fuku      yumi        ken       tsue
		WORD	00018H*08H,00018H*20H,00018H*21H,00018H*22H
;			 buw-gun      lot      nummer      kona
		WORD	00018H*23H,00018H*24H,00018H*25H,00018H*26H
;			  okarina   tebukuro      hon       key
		WORD	00018H*62H,00018H*2AH,00018H*2CH,00018H*2EH
;			 buumeran     ashi     kagami      bomb
		WORD	00018H*2FH,00018H*40H,00018H*42H,00018H*44H
;			   lamp      kakure    jisyaku     tama
		WORD	00018H*46H,00018H*48H,00018H*4AH,00018H*4CH
;			  sp-ken     skope    sp-thunder  sp-fire
		WORD	00018H*4EH,00018H*4FH,00018H*60H,00018H*62H
;			 sp-jishin  kara-bin    kinoko     kusuri
		WORD	00018H*64H,00018H*66H,00018H*6AH,00018H*00H
;			   tate        map      sp-key    pendanto
		WORD	00018H*0AH,00018H*6CH,00018H*6EH,00018H*44H
;			  rupy1      rupy2      rupy3       ami
		WORD	00018H*40H,00018H*41H,00018H*42H,00018H*43H
;			  polygon   L1-yumiya  L2-yumiya yousei-bin
		WORD	00018H*45H,00018H*49H,00018H*47H,00018H*4BH
;			hachi-bin  small-tate miror-tate heart-kakera
		WORD	00018H*4DH,00018H*4FH,00018H*64H,00018H*60H
;			   bomb10     haert   smalltubo       ya-1
		WORD	00018H*28H,00018H*66H,00018H*67H,00018H*68H
;			  rupy100     rupy50    rupy300     rupy20
		WORD	00018H*69H,00018H*6BH,00018H*6DH,00018H*40H
;			    kutsu
		WORD	00018H*42H
;
;
ITMCBFST1	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		PHA			; (A) push
;;;;;;;;		LDA	#LOW MPCHBF
		STZ	<WORK0
		LDA	#HIGH MPCHBF
		STA	<WORK1
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		BRA	ITMCBS60
;
ITMCBFST	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		PHA			; (A) push
;
		LDY	#C_4N1
		CMP	#023H
		BEQ	ITMCBS40	;
;					;
		CMP	#037H
		BCS	ITMCBS40	;
;					;
		LDY	#C_4N0
		CMP	#00CH
		BEQ	ITMCBS40	;
;					;
		CMP	#024H
		BCS	ITMCBS40	;
;					;
		LDY	#C_4M1
ITMCBS40	EQU	$
		JSR	CADWKST3	; Obj. char. address work set
		LDY	#C_4M0
		JSR	CADWKST2	; Obj. char. address work set
;
ITMCBS60	EQU	$
		PLA			; (A) pull
;
		MEM16
		REP	#00100001B	; memory 16bit mode & CLC
;
		AND	#000FFH
		ASL	A
		TAX
		LDA	<WORK0
		ADC	ITMCPTD,X
;
		IDX16
		REP	#00010000B	; index 16bit mode
;
		LDX	#ITMCHBF-CNGCHBF
		LDY	#00002H
		PHA			; (A) push
		JSR	CCBIS420	; item char. buffer set
;
		PLA			; (A) pull
		CLC
		ADC	#00180H
		LDY	#00002H
		JSR	CCBIS420	; item char. buffer set
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		PLB			; (DBR) reset
		RTL
;
;
;
;
;
;************************************************************************
;*		Character buffer set sub.		(CCBIS000)	*
;************************************************************************
CCBIS000	EQU	$
		STA	<WORKA
		LDY	#C_2R0
		LDA	OCADB,Y 
		STA	<WORK2
		STA	<WORK5
		LDA	OCADH,Y
		STA	<WORK1
		LDA	OCADL,Y
		STA	<WORK0
		BRA	CCBIS180
;
;
;************************************************************************
;*		Character buffer set sub.		(CCBIS100)	*
;************************************************************************
CCBIS100	EQU	$
		PHA			; (A) push
;
		JSR	CADWKST2	; Obj. char. address work set
;
		PLA			; (A) pull
CCBIS140	EQU	$
		STA	<WORKA
;
;// 03.05.31 //		LDA	#LOW MPCHBF
		STZ	<WORK0
		LDA	#HIGH MPCHBF
		STA	<WORK1
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
CCBIS180	EQU	$
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDY	<WORKC
		LDA	<WORK0
		ADC	BYCDPD,Y
		LDX	<WORK6
		LDY	<WORKA
		PHA			; (A) push
		JSR	CCBIS420	; character buffer set
;
		PLA			; (A) pull
		CLC
		ADC	#00180H
		LDY	<WORKA
		JSR	CCBIS420	; character buffer set
;
		INC	<WORKC
		INC	<WORKC
;
		STX	<WORK6
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTS
;
;
		MEM16
		IDX16
;************************************************************************
;*		Character buffer set sub.		(CCBIS200)	*
;************************************************************************
CCBIS200	EQU	$
		LDY	#00008H
CCBIS220	EQU	$
		STY	<WORKE
CCBIS240	EQU	$
		STA	<WORK0
		CLC
		ADC	#00010H
		STA	<WORK3
;
		LDY	#00007H
CCBIS260	EQU	$
		LDA	[<WORK0]
		STA	>CNGCHBF,X
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	>CNGCHBF+010H,X
		INC	<WORK3
		INX
		INX
		DEY
		BPL	CCBIS260	; 1-char. set end ?
;					; yes
		TXA
		CLC
		ADC	#00010H
		TAX
		LDA	<WORK3
		AND	#00078H
		BNE	CCBIS280	; next ?
;					; yes
		LDA	<WORK3
		CLC
		ADC	#00180H
		STA	<WORK3
CCBIS280	EQU	$
		LDA	<WORK3
		DEC	<WORKE
		BNE	CCBIS240	; set end ?
;					; yes
		RTS
;
;
;************************************************************************
;*		Character buffer set sub.		(CCBIS300)	*
;************************************************************************
CCBIS300	EQU	$
		LDY	#00008H
CCBIS320	EQU	$
		STY	<WORKE
CCBIS340	EQU	$
		STA	<WORK0
		CLC
		ADC	#00010H
		STA	<WORK3
;
		LDY	#00007H/2
CCBIS360	EQU	$
		LDA	[<WORK0]
		STA	>CNGCHBF,X
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	>CNGCHBF+010H,X
		INC	<WORK3
		INX
		INX
		LDA	[<WORK0]
		STA	>CNGCHBF,X
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	>CNGCHBF+010H,X
		INC	<WORK3
		INX
		INX
		DEY
		BPL	CCBIS360	; 1-char. set end ?
;					; yes
		TXA
		CLC
		ADC	#00010H
		TAX
		LDA	<WORK3
		DEC	<WORKE
		BNE	CCBIS340	; set end ?
;					; yes
		RTS
;
;
;************************************************************************
;*		Character buffer set sub.		(CCBIS400)	*
;************************************************************************
CCBIS400	EQU	$
		LDY	#00006H
CCBIS420	EQU	$
		STY	<WORKE
CCBIS440	EQU	$
		STA	<WORK0
		CLC
		ADC	#00010H
		STA	<WORK3
;
		LDY	#00007H
CCBIS460	EQU	$
		LDA	[<WORK0]
		STA	>CNGCHBF,X
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<WORK8
		INC	<WORK0
		INC	<WORK0
;
		LDA	[<WORK3]
		AND	#000FFH
		STA	<WORKZ
		ORA	<WORK8
		XBA
		ORA	<WORKZ
		STA	>CNGCHBF+010H,X
		INC	<WORK3
		INX
		INX
		DEY
		BPL	CCBIS460	; 1-char. set end ?
;					; yes
		TXA
		CLC
		ADC	#00010H
		TAX
		LDA	<WORK3
		AND	#00078H
		BNE	CCBIS480	; next ?
;					; yes
		LDA	<WORK3
		CLC
		ADC	#00180H
		STA	<WORK3
CCBIS480	EQU	$
		LDA	<WORK3
		DEC	<WORKE
		BNE	CCBIS440	; set end ?
;					; yes
		RTS
;
;
;
;
		MEM8
		IDX8
;************************************************************************
;*		BG. OBJ change character buffer set	(CHRCBS0)	*
;************************************************************************
CHRCBS0		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
;// 03.05.31 //		LDA	#LOW CHCHBF
		STZ	<WORK0
		LDA	#HIGH CHCHBF
		STA	<WORK1
		LDA	#BANK CHCHBF
		STA	<WORK2
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	!RBGCPT
		AND	#000FFH
		ASL	A
		ASL	A
		STA	<WORKE
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;
		LDX	<WORKE
		LDA	RBGCHDT+0,X
		BEQ	CHCB010		; character change ?
;					; yes
		STA	>CHCHTB+0
;
		SEP	#00010000B	; index 8bit mode
;
		TAY
		JSR	CADWS100	; char.data buffer set
CHCB010		EQU	$
		SEP	#00010000B	; index 8bit mode
;
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		REP	#00010000B	; index 16bit mode
;
		LDX	<WORKE
		LDA	RBGCHDT+1,X
		BEQ	CHCB020		; character change ?
;					; yes
		STA	>CHCHTB+1
;
		SEP	#00010000B	; index 8bit mode
;
		TAY
		JSR	CADWS100	; char.data buffer set
CHCB020		EQU	$
		SEP	#00010000B	; index 8bit mode
;
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		REP	#00010000B	; index 16bit mode
;
		LDX	<WORKE
		LDA	RBGCHDT+2,X
		BEQ	CHCB030		; character change ?
;					; yes
		STA	>CHCHTB+2
;
		SEP	#00010000B	; index 8bit mode
;
		TAY
		JSR	CADWS100	; char.data buffer set
CHCB030		EQU	$
		SEP	#00010000B	; index 8bit mode
;
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		REP	#00010000B	; index 16bit mode
;
		LDX	<WORKE
		LDA	RBGCHDT+3,X
		BEQ	CHCB040		; character change ?
;					; yes
		STA	>CHCHTB+3
;
		SEP	#00010000B	; index 8bit mode
;
		TAY
		JSR	CADWS100	; char.data buffer set
CHCB040		EQU	$
		SEP	#00010000B	; index 8bit mode
;
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		BRA	CHCB100
;
;
;
;************************************************************************
;*		OBJ change character buffer set		(CHRCBS1)	*
;************************************************************************
CHRCBS1		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
;// 03.05.31 //		LDA	#LOW CHCHBF+600H*4
		STZ	<WORK0
		LDA	#HIGH CHCHBF+600H*4
		STA	<WORK1
		LDA	#BANK CHCHBF+600H*4
		STA	<WORK2
CHCB100		EQU	$
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	!ROBJCPT
		AND	#000FFH
		ASL	A
		ASL	A
		STA	<WORKE
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;
		LDX	<WORKE
		LDA	ROBCHDT+0,X
		BEQ	CHCB110		; character change ?
;					; yes
		STA	>CHCHTB+4+0
CHCB110		EQU	$
		IDX8
		SEP	#00010000B	; index 8bit mode
;
		LDA	>CHCHTB+4+0
		TAY
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		IDX16
		REP	#00010000B	; index 16bit mode
;
		LDX	<WORKE
		LDA	ROBCHDT+1,X
		BEQ	CHCB120		; character change ?
;					; yes
		STA	>CHCHTB+4+1
CHCB120		EQU	$
		IDX8
		SEP	#00010000B	; index 8bit mode
;
		LDA	>CHCHTB+4+1
		TAY
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		IDX16
		REP	#00010000B	; index 16bit mode
;
		LDX	<WORKE
		LDA	ROBCHDT+2,X
		BEQ	CHCB130		; character change ?
;					; yes
		STA	>CHCHTB+4+2
CHCB130		EQU	$
		IDX8
		SEP	#00010000B	; index 8bit mode
;
		LDA	>CHCHTB+4+2
		TAY
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		IDX16
		REP	#00010000B	; index 16bit mode
;
		LDX	<WORKE
		LDA	ROBCHDT+3,X
		BEQ	CHCB140		; character change ?
;					; yes
		STA	>CHCHTB+4+3
CHCB140		EQU	$
		IDX8
		SEP	#00010000B	; index 8bit mode
;
		LDA	>CHCHTB+4+3
		TAY
		JSR	CADWS300	; char.data buffer set
;
		STZ	!CCHGPT
;///////		LDA	#008H
;///////		STA	!CCHGPT
		PLB			; (DBR) reset
		RTL
;
;
;
;
		MEM8
		IDX8
;************************************************************************
;*		BG. OBJ change character buffer set	(CHRCBSZ)	*
;************************************************************************
CHRCBSZ		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
;// 03.05.31 //		LDA	#LOW CHCHBF
		STZ	<WORK0
		LDA	#HIGH CHCHBF
		STA	<WORK1
		LDA	#BANK CHCHBF
		STA	<WORK2
;
		LDA	>CHCHTB+0
		TAY
		JSR	CADWS100	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+1
		TAY
		JSR	CADWS100	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+2
		TAY
		JSR	CADWS100	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+3
		TAY
		JSR	CADWS100	; char.data buffer set
;
;
;// 03.05.31 //		LDA	#LOW CHCHBF+600H*4
		STZ	<WORK0
		LDA	#HIGH CHCHBF+600H*4
		STA	<WORK1
		LDA	#BANK CHCHBF+600H*4
		STA	<WORK2
;
		LDA	>CHCHTB+4+0
		TAY
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+4+1
		TAY
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+4+2
		TAY
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+4+3
		TAY
		JSR	CADWS300	; char.data buffer set
;
		STZ	!CCHGPT
;
		PLB			; (DBR) reset
		RTL
;
;
;
;************************************************************************
;*		Message picture buffer set		(MPICBST)	*
;************************************************************************
MPICBST		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
;// 03.05.31 //		LDA	#LOW MPCHBF
		STZ	<WORK0
		LDA	#HIGH MPCHBF
		STA	<WORK1
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		LDA	#C_4T
		STA	<WORKE
MPCB140		EQU	$
		LDY	<WORKE
		JSR	CADWS300	; char.data buffer set
MPCB180		EQU	$
		LDA	<WORK1
		CLC
		ADC	#008H
		STA	<WORK1
		INC	<WORKE
		LDA	<WORKE
		CMP	#C_4V
		BNE	MPCB140		; Message picture buffer set end ?
;					; yes
		PLB			; (DBR) reset
		RTL
;
;
;
;************************************************************************
;*		Warp Ground Basic character change	(WGBGCNG)	*
;************************************************************************
WGBGTBLL	EQU	$
		BYTE	LOW  WGBG000	; dammy
		BYTE	LOW  BGCBFS0	; BG. change - 0
		BYTE	LOW  BGCBFS01	;            - 1
		BYTE	LOW  BGCBFS1	;            - 2
		BYTE	LOW  BGCBFS11	;            - 3
		BYTE	LOW  WGBG100	; new BG. write
		BYTE	LOW  WGBG300	; new BG. write
		BYTE	LOW  WGBG150	; new BG. write
		BYTE	LOW  WGBG200	; new BG. write
		BYTE	LOW  WGBG300	; new BG. write
		BYTE	LOW  WGBG400	; change char.
		BYTE	LOW  BGCBFS2	; Obj. change - 0
		BYTE	LOW  BGCBFS21	;             - 1
		BYTE	LOW  BGCBFS22	;             - 2
		BYTE	LOW  WGBGRTS
;
WGBGTBLH	EQU	$
		BYTE	HIGH WGBG000
		BYTE	HIGH BGCBFS0
		BYTE	HIGH BGCBFS01
		BYTE	HIGH BGCBFS1
		BYTE	HIGH BGCBFS11
		BYTE	HIGH WGBG100
		BYTE	HIGH WGBG300
		BYTE	HIGH WGBG150
		BYTE	HIGH WGBG200
		BYTE	HIGH WGBG300
		BYTE	HIGH WGBG400
		BYTE	HIGH BGCBFS2
		BYTE	HIGH BGCBFS21
		BYTE	HIGH BGCBFS22
		BYTE	HIGH WGBGRTS
;
;
BGWTBL		EQU	$
		BYTE	0000,bgwE,bgwF,bgw10,bgw11,0000,0000,0000
		BYTE	0000,0000,0000,bgw12,bgw13,bgw14,0000
;
;
WGBGCNG		EQU	$
;// 03.05.31 //		LDA	#LOW MPCHBF
		STZ	<WORK0
		LDA	#HIGH MPCHBF
		STA	<WORK1
;
		LDX	!ITEMMD
		LDA	>BGWTBL,X
		STA	<BGWTFG
		STA	!GMAPDF
;
		LDA	>WGBGTBLL,X
		STA	<WORKE
		LDA	>WGBGTBLH,X
		STA	<WORKF
;
		LDX	#000H
		LDA	<MPDTNO
		AND	#01000000B
		BEQ	WGBG20		;
;					;
		LDX	#008H
WGBG20		EQU	$
		INC	!ITEMMD
		JMP	(WORKE)
;
;
WGBG000		EQU	$
		INC	!KGCHCT
		LDA	!KGCHCT
;// 03.09.17 //		CMP	#01CH+008H
		CMP	#01CH+004H
		BEQ	WGBG040		; next go ?
;					; no
		STZ	!ITEMMD
		RTL
;
WGBG040		EQU	$
		JSL	>BCKG800	; shisai clear kagerou-fade check
		RTL
;
;
WGBG100		EQU	$
		JSL	>KGBG000
		DEC	<GAMEMD
		LDA	#bgwC
		STA	<BGWTFG
		STA	!GMAPDF
		RTL
;
;
WGBG150		EQU	$
		JSL	>KGBG100
		INC	!GMAPDF
		RTL
;
;
WGBG200		EQU	$
		JSL	>KGBG200	; new BG. set
;
		LDA	#bgwC
		STA	<BGWTFG
		STA	!GMAPDF
		RTL
;
;
WGBG300		EQU	$
		LDA	#bgwD
		STA	<BGWTFG
		STA	!GMAPDF
		RTL
;
;
WGBGRTS		EQU	$
		LDA	#00EH
		STA	!ITEMMD
		RTL
;
;
;
;---------------------	Change char.  -----------------------------------
WGBG400		EQU	$
;// 03.05.21 //		LDA	>BGCBDT0+7,X
;// 03.05.21 //		TAY
		LDY	#C_1W0
		LDA	<MPDTNO
		AND	#10111111B
		CMP	#003H
		BEQ	WGBG440		; yama ?
;					; no
		CMP	#005H
		BEQ	WGBG440		; yama ?
;					; no
		CMP	#007H
		BEQ	WGBG440		; yama ?
;					; no
;// 03.05.17 //		CMP	#040H
;// 03.05.17 //		BCS	MPI2130		; ura ?
;// 03.05.17 //;					; no
		LDY	#C_1X0
WGBG440		EQU	$
		JSL	>WTRCBFS1	; water char. buffer set
		RTL
;
;
;
;---------------------	BG. change - 0  ---------------------------------
BGCBDT0		EQU	$
;			   0     1     2     3     6     7
		BYTE	C_1G0,C_1G1,C_1H0,C_1H1,C_1I0,C_1X1,C_2R1,C_1X0
		BYTE	C_1K0,C_1K1,C_1L0,C_1L1,C_1I1,C_1W1,C_2W1,C_1X0
;
;
BGCBFS0		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		PHX			; (X) push
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	!CHIKNO
		AND	#000FFH
		ASL	A
		ASL	A
		ASL	A
		TAX
		LDA	!RBGCPT
		AND	#000FFH
		ASL	A
		ASL	A
		TAY
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;
		LDA	RBGCHDT+0,Y
		BNE	BGCF10		; character change ?
;					; yes
		LDA	BGCHDAT+3,X
BGCF10		EQU	$
		STA	>CHCHTB+0
;
		LDA	RBGCHDT+1,Y
		BNE	BGCF11		; character change ?
;					; yes
		LDA	BGCHDAT+4,X
BGCF11		EQU	$
		STA	>CHCHTB+1
;
		LDA	RBGCHDT+2,Y
		BNE	BGCF12		; character change ?
;					; yes
		LDA	BGCHDAT+5,X
BGCF12		EQU	$
		STA	>CHCHTB+2
;
		LDA	RBGCHDT+3,Y
		BNE	BGCF13		; character change ?
;					; yes
		LDA	BGCHDAT+6,X
BGCF13		EQU	$
		STA	>CHCHTB+3
;
		MEM16
		REP	#00100000B	; memory 16bit mode
;
		LDA	!ROBJCPT
		AND	#000FFH
		ASL	A
		ASL	A
		TAY
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
BGCF20		EQU	$
		LDA	ROBCHDT+0,Y
		BEQ	BGCF21		; character change ?
;					; yes
		STA	>CHCHTB+4+0
BGCF21		EQU	$
		LDA	ROBCHDT+1,Y
		BEQ	BGCF22		; character change ?
;					; yes
		STA	>CHCHTB+4+1
BGCF22		EQU	$
		LDA	ROBCHDT+2,Y
		BEQ	BGCF23		; character change ?
;					; yes
		STA	>CHCHTB+4+2
BGCF23		EQU	$
		LDA	ROBCHDT+3,Y
		BEQ	BGCF24		; character change ?
;					; yes
		STA	>CHCHTB+4+3
BGCF24		EQU	$
		IDX8
		SEP	#00010000B	; index 8bit mode
;
		PLX			; (X) pull
;
		LDA	>BGCBDT0+1,X
		STA	<WORK8
		LDA	>BGCBDT0+0,X
		TAY
;
		LDA	#BANK MPCHBF
		JSR	CADWS040	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDY	<WORK8
		JSR	CADWS100	; char.data buffer set
;
		PLB			; (DBR) reset
;
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*2
		LDA	#MPCHBF
		JSR	BCHC000		; character buffer set-0
		LDY	#00010H*2*2
		LDA	<WORK3
		JSR	BCHC100		; character buffer set-1
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;---------------------	BG. change - 1  ---------------------------------
BGCBFS01	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	>BGCBDT0+3,X
		STA	<WORK8
		LDA	>BGCBDT0+2,X
		TAY
;
		LDA	#BANK MPCHBF
		JSR	CADWS040	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDY	<WORK8
		JSR	CADWS100	; char.data buffer set
;
		PLB			; (DBR) reset
;
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*2
		LDA	#MPCHBF
		JSR	BCHC100		; character buffer set-1
		LDY	#00010H*2*2
		LDA	<WORK3
		JSR	BCHC000		; character buffer set-0
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;---------------------	BG. change - 2  ---------------------------------
BGCBFS1		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	>CHCHTB+1
		TAY
		LDA	#BANK MPCHBF
		JSR	CADWS040	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+2
		TAY
		JSR	CADWS100	; char.data buffer set
;
		PLB			; (DBR) reset
;
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*4
		LDA	#MPCHBF
		JSR	BCHC000		; character buffer set-1
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;---------------------	BG. change - 3  ---------------------------------
BGCBFS11	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	>BGCBDT0+5,X
		STA	<WORK8
		LDA	>BGCBDT0+4,X
		TAY
;
		LDA	#BANK MPCHBF
		JSR	CADWS040	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDY	<WORK8
		JSR	CADWS100	; char.data buffer set
;
		PLB			; (DBR) reset
;
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*4
		LDA	#MPCHBF
		JSR	BCHC100		; character buffer set-1
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;---------------------	OBJ change - 0  ---------------------------------
BGCBFS2		EQU	$
		STZ	<DPSUB
		LDA	<MPDTNO
		BEQ	KCLS40		; mori ?
;					; no
		CMP	#070H
		BEQ	KCLS40		; ura-numa ?
;					; no
		CMP	#040H
		BEQ	KCLS40		; ura-mori ?
;					; no
		CMP	#05BH
		BEQ	KCLS40		; piramido ?
;					; no
		CMP	#003H
		BEQ	KCLS20		; yama ?
;					; no
		CMP	#005H
		BEQ	KCLS20		; yama ?
;					; no
		CMP	#007H
		BEQ	KCLS20		; yama ?
;					; no
		CMP	#043H
		BEQ	KCLS20		; yama ?
;					; no
		CMP	#045H
		BEQ	KCLS20		; yama ?
;					; no
		CMP	#047H
		BNE	KCLS80		; yama ?
;					; no
KCLS20		EQU	$
KCLS40		EQU	$
		LDA	#00000001B
		STA	<DPSUB
KCLS80		EQU	$
		PHB
		PHK
		PLB			; (DBR0 set
;
		LDA	>BGCBDT0+6,X
		TAY
		LDA	OCADL,Y
		STA	<WORK0
		LDA	OCADH,Y
		STA	<WORK1
		LDA	OCADB,Y
		STA	<WORK2
		STA	<WORK5
;
		PLB			; (DBR) reset
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*2
		LDA	<WORK0
		JSR	BCHC000		; character buffer set-0
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;---------------------	OBJ change - 1  ---------------------------------
BGCBFS21	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	>CHCHTB+4
		TAY
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+5
		TAY
		JSR	CADWS300	; char.data buffer set
;
		PLB			; (DBR) reset
;
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*2
		LDA	>CHCHTB+4
		CMP	#C_4I0
		BEQ	BGCF2120	; 8~F color ?
;					; no
		CMP	#C_4I1
		BEQ	BGCF2120	; 8~F color ?
;					; no
		CMP	#C_4M0
		BEQ	BGCF2120	; 8~F color ?
;					; no
		CMP	#C_4M1
		BNE	BGCF2140	; 8~F color ?
;					; yes
BGCF2120	EQU	$
		LDA	#MPCHBF
		JSR	BCHC000		; character buffer set-0
		BRA	BGCF2160
;
BGCF2140	EQU	$
		LDA	#MPCHBF
		JSR	BCHC100		; character buffer set-1
BGCF2160	EQU	$
		LDY	#00010H*2*2
		LDA	<WORK3
		JSR	BCHC100		; character buffer set-1
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;---------------------	OBJ change - 2  ---------------------------------
BGCBFS22	EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	>CHCHTB+6
		TAY
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
		JSR	CADWS300	; char.data buffer set
		LDA	<WORK1
		CLC
		ADC	#006H
		STA	<WORK1
;
		LDA	>CHCHTB+7
		TAY
		JSR	CADWS300	; char.data buffer set
;
		PLB			; (DBR) reset
;
		LDA	#BANK MPCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*4
		LDA	#MPCHBF
		JSR	BCHC100		; character buffer set-1
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		JSL	>RABHEN		; rabit change check
		RTL
;
;
;
;************************************************************************
;*		BG. OBJ character change		(CHRCHNG)	*
;************************************************************************
ROBCHDT		EQU	$		; reset OBJ. char. data
		BYTE	00000,C_4D1,00000,00000	; 00 : ground
		BYTE	C_4C0,C_4D1,C_2X0,C_3F1	; 01 
		BYTE	C_4D0,C_4D1,C_3A1,C_3F1	; 02 
		BYTE	C_4C0,C_4D1,C_3A1,C_2Y0	; 03 
		BYTE	C_4D0,C_4D1,C_2X0,C_2Z1	; 04
		BYTE	C_4D0,C_4D1,C_2X0,C_2Z0	; 05
		BYTE	C_4G1,C_4D1,C_4E0,C_4H0	; 06
		BYTE	C_2Y0,C_4D1,C_4E0,C_2Z1	; 07
		BYTE	C_4C0,C_4D1,C_3A0,00000	; 08
		BYTE	00000,C_4D1,00000,C_4H0	; 09
		BYTE	00000,C_4D1,00000,C_2Z1	; 0A
		BYTE	C_4D0,C_4D1,C_2X0,00000	; 0B
		BYTE	00000,00000,C_3S1,C_3S0	; 0C
		BYTE	C_4D0,C_4D1,C_4F0,C_2Z1	; 0D
		BYTE	C_4N1,C_3N0,C_2X0,C_4B0	; 0E
		BYTE	00000,00000,C_4G0,00000	; 0F
;
		BYTE	C_2Y1,00000,C_3A0,C_2Z0	; 10 : ground
		BYTE	00000,00000,00000,C_4F0	; 11 
		BYTE	00000,C_2X1,C_3C1,00000	; 12 
		BYTE	C_3C0,C_2X1,C_3C1,C_3E1	; 13 
		BYTE	C_3C0,C_2X1,C_3C1,C_3B0	; 14
		BYTE	C_3B1,C_2X1,C_3C1,C_3B1	; 15
		BYTE	C_3C0,C_2X1,C_3D0,C_3D1	; 16
		BYTE	C_3C0,C_2X1,C_3C1,C_3D1	; 17
		BYTE	C_3C0,C_2X1,00000,00000	; 18
		BYTE	C_3C0,C_2X1,C_3D0,C_3E1	; 19
		BYTE	C_2Y1,C_4D1,C_4E0,C_2Z1	; 1A
		BYTE	C_4E1,C_3M0,C_4N0,C_3B1	; 1B
		BYTE	C_3C0,C_4D1,C_3C1,C_3F1	; 1C
		BYTE	00000,00000,00000,C_3B1	; 1D
		BYTE	C_3C0,C_2X1,C_3C1,C_2Z0	; 1E
		BYTE	C_3C0,C_4D1,C_3A0,00000	; 1F
;
		BYTE	C_3C0,C_4D1,C_2X0,C_2Z1	; 20 : ground
		BYTE	00000,00000,C_3A0,C_2Z0	; 21 
		BYTE	C_3C0,C_2X1,00000,C_2Z1	; 22 
		BYTE	C_3C0,C_4D1,C_2X0,00000	; 23 
		BYTE	C_3C0,C_2X1,C_4F0,C_2Z1	; 24
		BYTE	C_2Y0,C_2X1,C_4E0,C_2Z1	; 25
		BYTE	C_3C0,C_3E0,C_3C1,C_3E1	; 26
		BYTE	C_4G1,C_3R0,C_4E0,C_4H0	; 27
		BYTE	C_3R1,C_4F1,C_4S0,C_3S0	; 28
		BYTE	C_4E0,C_3R0,C_4G0,00000	; 29
		BYTE	C_2Y0,C_3R0,C_4E0,C_2Z1	; 2A
		BYTE	C_4H1,C_3R0,C_4N1,C_4L1	; 2B
		BYTE	C_4E1,C_4D1,C_4F0,C_2Z1	; 2C
		BYTE	C_3N1,00000,00000,00000	; 2D
		BYTE	C_4N1,00000,C_3A0,C_4L1	; 2E
		BYTE	00000,00000,00000,00000	; 2F
;
		BYTE	00000,00000,00000,00000	; 30 : ground
		BYTE	00000,00000,00000,00000	; 31 
		BYTE	00000,00000,00000,00000	; 32 
		BYTE	00000,00000,00000,00000	; 33 
		BYTE	00000,00000,00000,00000	; 34
		BYTE	00000,00000,00000,00000	; 35
		BYTE	00000,00000,00000,00000	; 36
		BYTE	00000,00000,00000,00000	; 37
		BYTE	00000,00000,00000,00000	; 38
		BYTE	00000,00000,00000,00000	; 39
		BYTE	00000,00000,00000,00000	; 3A
		BYTE	00000,00000,00000,00000	; 3B
		BYTE	00000,00000,00000,00000	; 3C
		BYTE	00000,00000,00000,00000	; 3D
		BYTE	00000,00000,00000,00000	; 3E
		BYTE	00000,00000,00000,00000	; 3F
;
		BYTE	C_4C1,C_4D1,C_3M1,C_3N1	; 40 : danjyon
		BYTE	C_4C0,C_4D1,C_3F0,C_4I0	; 41 
		BYTE	00000,C_4D1,C_3F0,C_4I0	; 42 
		BYTE	C_4N1,C_4D1,00000,C_4I0	; 43 
		BYTE	C_4C0,C_4D1,C_3A1,C_4I0	; 44 
		BYTE	C_4E1,C_4F1,C_4E0,C_4M0	; 45
;;		BYTE	C_4C1,C_4D1,C_3V1,C_4I0	; 46  TEST Morita !
		BYTE	C_4C1,C_4D1,C_3F0,C_4I0	; 46
		BYTE	C_4E1,C_4F1,C_3V1,C_3S0	; 47
		BYTE	C_3G1,C_3N0,C_3O0,C_4I0	; 48
		BYTE	C_3G1,C_3N0,C_3O0,C_3F1	; 49
		BYTE	C_3O1,C_3N0,C_3O0,C_4I0	; 4A
		BYTE	C_3O1,C_3N0,C_3O0,C_3P1	; 4B
		BYTE	C_3G1,C_3G0,C_3P0,C_4I0	; 4C
		BYTE	C_4H1,C_4D1,C_3A1,00000	; 4D
		BYTE	C_4G1,C_4D1,C_3A1,C_4H0	; 4E
		BYTE	C_4G1,C_4F1,C_4E0,C_4H0	; 4F
;
		BYTE	C_4E1,C_4D1,C_4F0,C_3M1	; 50 : danjyon
		BYTE	C_3G1,C_3H0,C_3I0,C_4I1	; 51 
		BYTE	C_4J1,C_3X1,C_4A0,C_4A1	; 52 : shisai room !
		BYTE	C_3G1,C_3G0,C_3I1,C_4I0	; 53 
		BYTE	C_3G1,C_3G0,C_3V1,C_3W0	; 54
		BYTE	C_3G1,C_3G0,C_3W0,C_3Y0	; 55
		BYTE	C_3G1,C_3G0,C_3X0,C_3X1	; 56
		BYTE	C_3Z0,C_3G0,C_3K1,C_3Y1	; 57
		BYTE	C_4J1,C_3E0,C_4A0,C_4A1	; 58
		BYTE	C_3G1,C_3G0,C_3M0,C_4I0	; 59
		BYTE	C_3G1,C_3G0,C_3V0,C_4I0	; 5A
		BYTE	C_3G1,C_3H0,C_3L0,C_4I0	; 5B
		BYTE	C_3G1,C_3H0,C_3K0,C_4I0	; 5C
		BYTE	C_3G1,C_3N0,C_3J1,C_4I0	; 5D
		BYTE	C_3G1,C_3H0,C_3K1,C_4I0	; 5E
		BYTE	C_3G1,C_3G0,C_3L1,C_4I0	; 5F
;
		BYTE	C_3G1,C_3N0,C_3W1,C_4I0	; 60 : danjyon
		BYTE	C_4C0,C_4D1,C_3J0,C_4I0	; 61 
		BYTE	C_3H1,C_3Z1,C_4B1,C_3Q1	; 62 
		BYTE	C_3G1,C_3N0,C_3L0,C_3P1	; 63 
		BYTE	C_3G1,C_2X1,C_3L1,C_4I0	; 64
		BYTE	C_3G1,C_3G0,C_3K1,C_4I0	; 65
		BYTE	C_3G1,C_3H0,C_3K1,C_4I1	; 66
		BYTE	C_4D0,C_4D1,C_3A1,C_4I0	; 67
		BYTE	C_2Y0,C_3G0,C_4E0,C_4H0	; 68
		BYTE	C_3G1,C_3H0,C_3K0,C_4I1	; 69
		BYTE	C_3B1,00000,00000,00000	; 6A
		BYTE	C_3G1,00000,C_3M0,C_4I0	; 6B
		BYTE	00000,00000,00000,00000	; 6C
		BYTE	00000,00000,00000,00000	; 6D
		BYTE	00000,00000,00000,00000	; 6E
		BYTE	00000,00000,00000,00000	; 6F
;
		BYTE	00000,00000,00000,00000	; 70 : danjyon
		BYTE	00000,00000,00000,00000	; 71 
		BYTE	00000,00000,00000,00000	; 72 
		BYTE	00000,00000,00000,00000	; 73 
		BYTE	00000,00000,00000,00000	; 74
		BYTE	00000,00000,00000,00000	; 75
		BYTE	00000,00000,00000,00000	; 76
		BYTE	00000,00000,00000,00000	; 77
		BYTE	00000,00000,00000,00000	; 78
		BYTE	00000,00000,00000,00000	; 79
		BYTE	00000,00000,00000,00000	; 7A
		BYTE	00000,00000,00000,00000	; 7B
		BYTE	00000,00000,00000,00000	; 7C
		BYTE	C_3Q0,00000,00000,C_2V0	; 7D : title
		BYTE	C_4N1,C_4D1,00000,C_4I0	; 7E : title demo (gyokuza)
		BYTE	C_4J1,C_4D1,C_4A0,C_4A1	; 7F :            (rou-ya , shisai-room)
;
;						; Danjyon map
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 80 (00)chapel
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 81 (02)shiro
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 82 (04)shinden
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 83 (06)sabaku-shinden
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 84 (08)shisai-tower
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 85 (0A)ura-danjyon (mizu hiki)
		BYTE	C_4Q0,C_4K0,C_4K1,C_4H0	; 86 (0C)ura-danjyon (ura shinden)
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 87 (0E)ura-danjyon (numa)
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 88 (10)ura-danjyon (mori shita)
		BYTE	C_4Q0,C_4K0,C_4K1,C_4H0	; 89 (12)ura-danjyon (ice tower)
		BYTE	C_4Q0,C_4K0,C_4R2,C_4H0	; 8A (14)yama-tower
		BYTE	C_4Q0,C_4K0,C_4K1,C_4H0	; 8B (16)ura-danjyon (ura machi)
		BYTE	C_4Q0,C_4K0,C_3Q1,C_4H0	; 8C (18)ura-danjyon (kame-iwa)
		BYTE	C_4Q0,C_4K0,C_4K1,C_4H0	; 8D (1A)ura-danjyon (yama tower)
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 8E (1C)
		BYTE	C_4Q0,C_4Q1,C_4R2,C_4H0	; 8F (1E)
;
;
;
RBGCHDT		EQU	$		;       BG.
;						; Danjyon
		BYTE	C_0D0,00000,C_0S0,C_0N0	; 00 shiro
		BYTE	C_0E0,00000,C_0T1,C_0O1	;  1         under
		BYTE	C_0D0,00000,C_0S0,C_0N0	;  2 shisai-room
		BYTE	C_0D1,00000,C_0U0,C_0P0	;  3 minka
		BYTE	C_0D1,00000,C_0T0,C_0N0	;  4 chapel
		BYTE	C_0E1,00000,C_0S1,C_0N1	;  5 shinden
		BYTE	C_0F1,00000,C_0T0,C_0O0	;  6 doukutsu
		BYTE	C_0G0,00000,C_0U1,C_0N1	;  7 ura-danjyon (shinden)
		BYTE	C_0E0,00000,C_0T1,C_0O1	;  8 ura-danjyon (mizu hiki)
		BYTE	C_0G0,00000,C_0V0,C_0O1	;  9 ura-danjyon (mori-shita)
		BYTE	C_0G0,00000,C_0V1,C_0O1	;  A ura-danjyon (machi-shita)
		BYTE	C_0F0,00000,C_0W0,C_0R0	;  B ura-danjyon (ice tower)
		BYTE	C_0F0,00000,C_0W1,C_0R1	;  C ura-danjyon (numa)
		BYTE	C_0F1,00000,C_0X0,C_0M0	;  D ura-danjyon (kame-iwa)
		BYTE	C_0G1,00000,C_0X1,C_0N0	;  E ura-danjyon (tower)
		BYTE	C_0D1,00000,C_0U0,C_0P0	;  F shinden-jiji
;
		BYTE	C_0D1,00000,C_0C0,C_0C1	; 10 shiro-nukemichi
		BYTE	C_0D1,00000,C_0C0,C_0C1	;  1 ura-minka (kaji-ya)
		BYTE	C_0E1,00000,C_0S1,C_0O1	;  2 sabaku
		BYTE	C_0E1,00000,C_0X1,C_0M1	;  3 piramido
		BYTE	C_0F1,00000,C_0T0,C_0P0	;  4 doukutsu jiji
		BYTE	C_0E1,00000,C_0S1,C_0N1	;  5
		BYTE	C_0F1,00000,C_0T0,C_0O0	;  6
		BYTE	C_0E1,00000,C_0U1,C_0O1	;  7
		BYTE	C_0E0,00000,C_0T1,C_0O1	;  8
		BYTE	C_0E1,00000,C_0V0,C_0O1	;  9
		BYTE	C_0E1,00000,C_0V1,C_0O1	;  A
		BYTE	C_0F0,00000,C_0W0,C_0R0	;  B
		BYTE	C_0E1,00000,C_0W1,C_0R1	;  C
		BYTE	C_0G0,00000,C_0X0,C_0M0	;  D
		BYTE	C_0G1,00000,C_0X1,C_0M1	;  E
		BYTE	C_4R1,00000,C_0Y0,C_1Y1	;  F
;
		BYTE	00000,00000,00000,00000	; 20 : ground
		BYTE	00000,C_1V1,C_1Q0,00000	;  1
		BYTE	00000,C_1V0,C_1R1,00000	;  2
		BYTE	00000,C_1T1,C_1Q1,00000	;  3
		BYTE	00000,C_1T0,C_1O1,00000	;  4
		BYTE	00000,C_1U1,C_1P0,00000	;  5
		BYTE	00000,C_1T1,C_1U0,00000	;  6
		BYTE	00000,C_1S1,C_1R0,00000	;  7
		BYTE	00000,00000,00000,00000	;  8
		BYTE	00000,C_1S0,C_1P1,00000	;  9
		BYTE	00000,C_1T1,C_1Q1,00000	;  A
		BYTE	00000,C_1U1,C_1U0,00000	;  B
		BYTE	00000,00000,00000,00000	;  C
		BYTE	00000,00000,00000,00000	;  D
		BYTE	00000,00000,00000,00000	;  E
		BYTE	00000,C_1N0,C_1N1,00000	;  F
;
		BYTE	00000,00000,00000,00000	; 30 : ground (URA)
		BYTE	00000,C_1V1,C_1Q0,00000	;  1
		BYTE	00000,C_1V0,C_1R1,00000	;  2
		BYTE	00000,C_1T1,C_1Q1,00000	;  3
		BYTE	00000,C_1T0,C_1O1,00000	;  4
		BYTE	00000,C_1U1,C_1P0,00000	;  5
		BYTE	00000,C_1T1,C_1U0,00000	;  6
		BYTE	00000,C_1S1,C_1R0,00000	;  7
		BYTE	00000,00000,00000,00000	;  8
		BYTE	00000,C_1S0,C_1P1,00000	;  9
		BYTE	00000,C_1T1,00000,00000	;  A
		BYTE	00000,C_1D0,C_1D1,00000	;  B
		BYTE	00000,C_2A0,C_1C1,00000	;  C
		BYTE	00000,C_0Y0,C_0Y1,00000	;  D
		BYTE	00000,C_0Z0,C_0Z1,00000	;  E
		BYTE	00000,C_1A0,C_1A1,00000	;  F
;
		BYTE	00000,C_1E0,C_1E1,00000	; 40 : ground (URA)
		BYTE	00000,C_1C0,C_1C1,00000	;  1
		BYTE	00000,C_1B0,C_1B1,00000	;  2
		BYTE	00000,00000,00000,00000	;  3
		BYTE	00000,00000,00000,00000	;  4
		BYTE	00000,00000,00000,00000	;  5
		BYTE	00000,00000,00000,00000	;  6
		BYTE	00000,00000,00000,00000	;  7
		BYTE	00000,00000,00000,00000	;  8
		BYTE	00000,00000,00000,00000	;  9
		BYTE	00000,00000,00000,00000	;  A
		BYTE	00000,00000,00000,00000	;  B
		BYTE	00000,00000,00000,00000	;  C
		BYTE	00000,00000,00000,00000	;  D
		BYTE	00000,00000,00000,00000	;  E
		BYTE	00000,00000,00000,00000	;  F
;
		BYTE	C_4R1,C_4R0,C_4R1,C_4R0	; 50 MAP
		BYTE	C_0M1,C_1J0,C_1J1,C_1F1	; 51 Title
;
;
;
;;;;;;;;CRCHTBLL	EQU	$		; table(L)
;;;;;;;;		BYTE	LOW CHRCHG2	; Bg. - 0 : 0
;;;;;;;;		BYTE	LOW CHRCHG2	;     - 0 : 1
;;;;;;;;		BYTE	LOW CHRCHG3	;     - 1 : 2
;;;;;;;;		BYTE	LOW CHRCHG3	;     - 1 : 3
;;;;;;;;		BYTE	LOW CHRCHG3	;     - 2 : 4
;;;;;;;;		BYTE	LOW CHRCHG3	;     - 2 : 5
;;;;;;;;		BYTE	LOW CHRCHG4	;     - 3 : 6
;;;;;;;;		BYTE	LOW CHRCHG4	;     - 3 : 7
;;;;;;;;		BYTE	LOW CHRCHG0	; Obj - 0 : 8
;;;;;;;;		BYTE	LOW CHRCHG0	;     - 0 : 9
;;;;;;;;		BYTE	LOW CHRCHG1	;     - 1 : A
;;;;;;;;		BYTE	LOW CHRCHG1	;     - 1 : B
;;;;;;;;		BYTE	LOW CHRCHG1	;     - 2 : C
;;;;;;;;		BYTE	LOW CHRCHG1	;     - 2 : D
;;;;;;;;		BYTE	LOW CHRCHG1	;     - 3 : E
;;;;;;;;		BYTE	LOW CHRCHG1	;     - 3 : F
;;;;;;;;		BYTE	LOW CHRCHG9	; Rts     :10
;;;;;;;;;
;;;;;;;;CRCHTBLH	EQU	$		; table(H)
;;;;;;;;		BYTE	HIGH CHRCHG2
;;;;;;;;		BYTE	HIGH CHRCHG2
;;;;;;;;		BYTE	HIGH CHRCHG3
;;;;;;;;		BYTE	HIGH CHRCHG3
;;;;;;;;		BYTE	HIGH CHRCHG3
;;;;;;;;		BYTE	HIGH CHRCHG3
;;;;;;;;		BYTE	HIGH CHRCHG4
;;;;;;;;		BYTE	HIGH CHRCHG4
;;;;;;;;		BYTE	HIGH CHRCHG0
;;;;;;;;		BYTE	HIGH CHRCHG0
;;;;;;;;		BYTE	HIGH CHRCHG1
;;;;;;;;		BYTE	HIGH CHRCHG1
;;;;;;;;		BYTE	HIGH CHRCHG1
;;;;;;;;		BYTE	HIGH CHRCHG1
;;;;;;;;		BYTE	HIGH CHRCHG1
;;;;;;;;		BYTE	HIGH CHRCHG1
;;;;;;;;		BYTE	HIGH CHRCHG9
;;;;;;;;;
;;;;;;;;VMAADRD		EQU	$
;;;;;;;;		BYTE	02CH,02EH,030H,032H
;;;;;;;;		BYTE	034H,036H,038H,03AH
;;;;;;;;		BYTE	050H,052H,054H,056H
;;;;;;;;		BYTE	058H,05AH,05CH,05EH
;;;;;;;;;
;;;;;;;;DTADDDT		EQU	$
;;;;;;;;		BYTE	000H,003H,000H,003H
;;;;;;;;		BYTE	000H,003H,000H,003H
;;;;;;;;		BYTE	000H,003H,000H,003H
;;;;;;;;		BYTE	000H,003H,000H,003H
;;;;;;;;;
;;;;;;;;BFWKDT		EQU	$
;;;;;;;;		BYTE	HIGH CHCHBF+600H*0,HIGH CHCHBF+600H*0,HIGH CHCHBF+600H*1,HIGH CHCHBF+600H*1
;;;;;;;;		BYTE	HIGH CHCHBF+600H*2,HIGH CHCHBF+600H*2,HIGH CHCHBF+600H*3,HIGH CHCHBF+600H*3
;;;;;;;;		BYTE	HIGH CHCHBF+600H*4,HIGH CHCHBF+600H*4,HIGH CHCHBF+600H*5,HIGH CHCHBF+600H*5
;;;;;;;;		BYTE	HIGH CHCHBF+600H*6,HIGH CHCHBF+600H*6,HIGH CHCHBF+600H*7,HIGH CHCHBF+600H*7
;;;;;;;;;
;;;;;;;;;
;
VMAADRD		EQU	$
		BYTE	050H,051H,052H,053H,054H,055H,056H,057H
		BYTE	058H,059H,05AH,05BH,05CH,05DH,05EH,05FH
;
BFWKDT		EQU	$
		BYTE	HIGH RSETCBF+0000H,HIGH RSETCBF+0200H
		BYTE	HIGH RSETCBF+0400H,HIGH RSETCBF+0600H
		BYTE	HIGH RSETCBF+0800H,HIGH RSETCBF+0A00H
		BYTE	HIGH RSETCBF+0C00H,HIGH RSETCBF+0E00H
		BYTE	HIGH RSETCBF+1000H,HIGH RSETCBF+1200H
		BYTE	HIGH RSETCBF+1400H,HIGH RSETCBF+1600H
		BYTE	HIGH RSETCBF+1800H,HIGH RSETCBF+1A00H
		BYTE	HIGH RSETCBF+1C00H,HIGH RSETCBF+1E00H
;
;
CHRCHNG		EQU	$
		LDX	!CCHGPT
		CPX	#010H
		BEQ	CHRCN90		; character write ?
;					; yes
		LDA	>VMAADRD,X
		STA	<OBCCFG
		STZ	!CHADRF
		LDA	>BFWKDT,X
		STA	!CHADRF+1
;
		INC	!CCHGPT
CHRCN90		EQU	$
		RTL
;
;
;;;;;;;;		PHB
;;;;;;;;		PHK
;;;;;;;;		PLB			; (DBR) set
;;;;;;;;;
;;;;;;;;		LDA	!ROBJCPT
;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		STA	<WORKE
;;;;;;;;		LDA	!RBGCPT
;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		STA	<WORKF
;;;;;;;;;
;;;;;;;;		LDX	!CCHGPT
;;;;;;;;		LDA	#LOW CHCHBF
;;;;;;;;		STA	<WORK0
;;;;;;;;		LDA	BFWKDT,X
;;;;;;;;		STA	<WORK1
;;;;;;;;		LDA	#BANK CHCHBF
;;;;;;;;		STA	<WORK2
;;;;;;;;		STA	<WORK5
;;;;;;;;;
;;;;;;;;		LDA	CRCHTBLL,X
;;;;;;;;		STA	<WORK6
;;;;;;;;		LDA	CRCHTBLH,X
;;;;;;;;		STA	<WORK7
;;;;;;;;;
;;;;;;;;		LDA	DTADDDT,X
;;;;;;;;		STA	<WORK9
;;;;;;;;		LDA	DTADDD1,X	
;;;;;;;;		STA	<WORK8		; (work8,9) <-- point add. data
;;;;;;;;;
;;;;;;;;		LDA	VMAADRD,X	; (A) <-- VMA address
;;;;;;;;		JMP	(!WORK6)
;;;;;;;;;
;;;;;;;;;
;;;;;;;;;
;;;;;;;;CHRCHG0		EQU	$
;;;;;;;;		STA	<OBCCFG		; OBJ. BG. character change flag on
;;;;;;;;		INC	!CCHGPT
;;;;;;;;		LDA	>CHCHTB,X
;;;;;;;;		CMP	#C_4I0
;;;;;;;;		BEQ	CRCH010		; 8~F color ?
;;;;;;;;;					; no
;;;;;;;;		CMP	#C_4I1
;;;;;;;;		BEQ	CRCH010		; 8~F color ?
;;;;;;;;;					; no
;;;;;;;;		CMP	#C_4M0
;;;;;;;;		BEQ	CRCH010		; 8~F color ?
;;;;;;;;;					; no
;;;;;;;;		CMP	#C_4M1
;;;;;;;;		BEQ	CRCH010		; 8~F color ?
;;;;;;;;;					; no
;;;;;;;;		BRA	CRCH110
;;;;;;;;;
;;;;;;;;;
;;;;;;;;CHRCHG3		EQU	$
;;;;;;;;		LDY	!RBGCPT
;;;;;;;;		CPY	#010H
;;;;;;;;		BCC	CHRCHG1		; danjyon ?
;;;;;;;;;					; no
;;;;;;;;CHRCHG2		EQU	$		;// 02.11.13 //
;;;;;;;;		INC	!CCHGPT
;;;;;;;;CRCH000		EQU	$
;;;;;;;;		STA	<OBCCFG		; OBJ. BG. character change flag on
;;;;;;;;CRCH010		EQU	$
;;;;;;;;		MEM16
;;;;;;;;		IDX16
;;;;;;;;		REP	#00110001B	; memory,index 16bit mode & CLC
;;;;;;;;;
;;;;;;;;		LDA	<WORK0
;;;;;;;;		ADC	<WORK8
;;;;;;;;		LDY	#00010H*1
;;;;;;;;		STY	<WORKC
;;;;;;;;		LDX	#00000H
;;;;;;;;CRCH020		EQU	$
;;;;;;;;		STA	<WORK0
;;;;;;;;		CLC
;;;;;;;;		ADC	#00010H
;;;;;;;;		STA	<WORK3
;;;;;;;;;
;;;;;;;;		LDY	#00007H
;;;;;;;;CRCH040 	EQU	$
;;;;;;;;		LDA	[<WORK0]
;;;;;;;;		STA	!VRAMD+2,X
;;;;;;;;		XBA
;;;;;;;;		ORA	[<WORK0]
;;;;;;;;		AND	#000FFH
;;;;;;;;		STA	<WORK8
;;;;;;;;		INC	<WORK0
;;;;;;;;		INC	<WORK0
;;;;;;;;;
;;;;;;;;		LDA	[<WORK3]
;;;;;;;;		AND	#000FFH
;;;;;;;;		STA	<WORKA
;;;;;;;;		ORA	<WORK8
;;;;;;;;		XBA
;;;;;;;;		ORA	<WORKA
;;;;;;;;		STA	!VRAMD+2+010H,X
;;;;;;;;		INC	<WORK3
;;;;;;;;		INX
;;;;;;;;		INX
;;;;;;;;		DEY
;;;;;;;;		BPL	CRCH040		; 1char. end ?
;;;;;;;;;					; yes
;;;;;;;;		TXA
;;;;;;;;		CLC
;;;;;;;;		ADC	#00010H
;;;;;;;;		TAX
;;;;;;;;		LDA	<WORK3
;;;;;;;;		DEC	<WORKC
;;;;;;;;		BNE	CRCH020		; end ?
;;;;;;;;;					; yes
;;;;;;;;		MEM8
;;;;;;;;		IDX8
;;;;;;;;		SEP	#00110000B	; memory,index 8bit mode
;;;;;;;;CHRCHG9		EQU	$
;;;;;;;;		PLB			; (DBR) reset
;;;;;;;;		RTL
;;;;;;;;;
;;;;;;;;;
;;;;;;;;;
;;;;;;;;;// 02.11.13 //CHRCHG2		EQU	$
;;;;;;;;;// 02.11.13 //		LDY	!RBGCPT
;;;;;;;;;// 02.11.13 //		CPY	#010H
;;;;;;;;;// 02.11.13 //		BCC	CHRCHG0		; danjyon ?
;;;;;;;;;// 02.11.13 //;					; yes
;;;;;;;;;;;;;;;;CHRCHG4		EQU	$
;;;;;;;;CHRCHG1		EQU	$
;;;;;;;;		INC	!CCHGPT
;;;;;;;;CRCH100		EQU	$
;;;;;;;;		STA	<OBCCFG		; OBJ. BG. character change flag on
;;;;;;;;CRCH110		EQU	$
;;;;;;;;		MEM16
;;;;;;;;		IDX16
;;;;;;;;		REP	#00110001B	; memory,index 16bit mode & CLC
;;;;;;;;;
;;;;;;;;		LDA	<WORK0
;;;;;;;;		ADC	<WORK8
;;;;;;;;		LDY	#00010H*1
;;;;;;;;		STY	<WORKC
;;;;;;;;		LDX	#00000H
;;;;;;;;CRCH120		EQU	$
;;;;;;;;		STA	<WORK0
;;;;;;;;		CLC
;;;;;;;;		ADC	#00010H
;;;;;;;;		STA	<WORK3
;;;;;;;;;
;;;;;;;;		LDY	#00007H
;;;;;;;;CRCH140 	EQU	$
;;;;;;;;		LDA	[<WORK0]
;;;;;;;;		STA	!VRAMD+2,X
;;;;;;;;		INC	<WORK0
;;;;;;;;		INC	<WORK0
;;;;;;;;;
;;;;;;;;		LDA	[<WORK3]
;;;;;;;;		AND	#000FFH
;;;;;;;;		STA	!VRAMD+2+010H,X
;;;;;;;;		INC	<WORK3
;;;;;;;;		INX
;;;;;;;;		INX
;;;;;;;;		DEY
;;;;;;;;		BPL	CRCH140		; 1char. end ?
;;;;;;;;;					; yes
;;;;;;;;		TXA
;;;;;;;;		CLC
;;;;;;;;		ADC	#00010H
;;;;;;;;		TAX
;;;;;;;;		LDA	<WORK3
;;;;;;;;		DEC	<WORKC
;;;;;;;;		BNE	CRCH120		; end ?
;;;;;;;;;					; yes
;;;;;;;;		MEM8
;;;;;;;;		IDX8
;;;;;;;;		SEP	#00110000B	; memory,index 8bit mode
;;;;;;;;		PLB			; (DBR) reset
;;;;;;;;		RTL
;
;
;
;
;************************************************************************
;*		BG. character change			(BGCHCNG)	*
;************************************************************************
BGCHCNG		EQU	$
		LDA	#BANK CHCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDY	#00010H*2*2
		LDA	#CHCHBF
		JSR	BCHC000		; character buffer set-0
;
		LDY	#00010H*2*6
		LDA	!RBGCPT
		AND	#000FFH
		CMP	#00020H
		BCC	BCHCH20		; danjyon ?
;					; yes
		LDY	#00010H*2*4
		LDA	<WORK3
		JSR	BCHC000		; character buffer set-1
		LDY	#00010H*2*2
BCHCH20		EQU	$
		LDA	<WORK3
		JSR	BCHC100		; character buffer set-1
;
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
BCHC000		EQU	$
		STY	<WORKC
BCHC020		EQU	$
		STA	<WORK0
		CLC
		ADC	#00010H
		STA	<WORK3
;
		LDY	#00007H/2
BCHC040 	EQU	$
		LDA	[<WORK0]
		STA	>RSETCBF,X
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<WORK8
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	<WORKA
		ORA	<WORK8
		XBA
		ORA	<WORKA
		STA	>RSETCBF+010H,X
		INC	<WORK3
		INX
		INX
;
		LDA	[<WORK0]
		STA	>RSETCBF,X
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<WORK8
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	<WORKA
		ORA	<WORK8
		XBA
		ORA	<WORKA
		STA	>RSETCBF+010H,X
		INC	<WORK3
		INX
		INX
		DEY
		BPL	BCHC040		; 1char. end ?
;					; yes
		TXA
		CLC
		ADC	#00010H
		TAX
		LDA	<WORK3
		DEC	<WORKC
		BNE	BCHC020		; end ?
;					; yes
		RTS
;
;
BCHC100		EQU	$
		STY	<WORKC
BCHC120		EQU	$
		STA	<WORK0
		CLC
		ADC	#00010H
		STA	<WORK3
;
		LDY	#00007H/4
BCHC140 	EQU	$
		LDA	[<WORK0]
		STA	>RSETCBF,X
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	>RSETCBF+010H,X
		INC	<WORK3
		INX
		INX
;
		LDA	[<WORK0]
		STA	>RSETCBF,X
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	>RSETCBF+010H,X
		INC	<WORK3
		INX
		INX
;
		LDA	[<WORK0]
		STA	>RSETCBF,X
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	>RSETCBF+010H,X
		INC	<WORK3
		INX
		INX
;
		LDA	[<WORK0]
		STA	>RSETCBF,X
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK3]
		AND	#000FFH
		STA	>RSETCBF+010H,X
		INC	<WORK3
		INX
		INX
		DEY
		BPL	BCHC140		; 1char. end ?
;					; yes
		TXA
		CLC
		ADC	#00010H
		TAX
		LDA	<WORK3
		DEC	<WORKC
		BNE	BCHC120		; end ?
;					; yes
		RTS
;
;
;
;
		MEM8
		IDX8
;************************************************************************
;*		OBJ. character change			(OJCHCNG)	*
;************************************************************************
OJCHCNG		EQU	$
		LDA	#BANK CHCHBF
		STA	<WORK2
		STA	<WORK5
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDX	#00000H
		LDA	#CHCHBF+1800H
		LDY	#00010H*2*6
		JSR	BCHC100		; character buffer set-1
;
		LDY	#00010H*2*2
		LDA	>CHCHTB+7
		AND	#000FFH
		CMP	#C_4I0
		BEQ	OCHCH40		; 8~F color ?
;					; no
		CMP	#C_4I1
		BEQ	OCHCH40		; 8~F color ?
;					; no
		CMP	#C_4M0
		BEQ	OCHCH40		; 8~F color ?
;					; no
		CMP	#C_4M1
		BNE	OCHCH60		; 8~F color ?
;					; no
OCHCH40		EQU	$
		LDA	<WORK3
		JSR	BCHC000		; character buffer set-0
;
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
OCHCH60		EQU	$
		LDA	<WORK3
		JSR	BCHC100		; character buffer set-1
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;
;
;
;************************************************************************
;*		BG. OBJ character change		(CHSCHNG)	*
;************************************************************************
; <<<<<<  BG   >>>>>>>> 
BGCHDAT 	EQU	$ 
		BYTE	C_0A0,C_0A1,C_0I0,C_0D0,C_0H0,C_0S0,C_0N0,C_0H1	; 00 shiro
		BYTE	C_0A0,C_0A1,C_0I0,C_0E0,C_0H0,C_0T1,C_0O1,C_0H1	;  1         under
		BYTE	C_0A0,C_0A1,C_0I0,C_0D0,C_0H0,C_0S0,C_0N0,C_0H1	;  2 shisai-room
		BYTE	C_0A0,C_0A1,C_0K0,C_0D1,C_0H0,C_0U0,C_0P0,C_0H1	;  3 minka
		BYTE	C_0A0,C_0A1,C_0I0,C_0D1,C_0H0,C_0T0,C_0N0,C_0H1	;  4 chapel
		BYTE	C_0A0,C_0A1,C_0I0,C_0E1,C_0H0,C_0S1,C_0N1,C_0H1	;  5 shinden
		BYTE	C_0B0,C_0B1,C_0J0,C_0F1,C_0H0,C_0T0,C_0O0,C_0H1	;  6 doukutsu
		BYTE	C_0A0,C_0A1,C_0I1,C_0G0,C_0H0,C_0U1,C_0O1,C_0H1	;  7 ura-danjyon (shinden)
		BYTE	C_0A0,C_0A1,C_0I1,C_0E0,C_0H0,C_0T1,C_0O1,C_0H1	;  8 ura-danjyon (mizu hiki)
		BYTE	C_0A0,C_0A1,C_0I1,C_0G0,C_0H0,C_0V0,C_0O0,C_0H1	;  9 ura-danjyon (mori-shita)
		BYTE	C_0A0,C_0A1,C_0I1,C_0G0,C_0H0,C_0V1,C_0O1,C_0H1	;  A ura-danjyon (machi-shita)
		BYTE	C_0A0,C_0A1,C_0K1,C_0F0,C_0H0,C_0W0,C_0R0,C_0H1	;  B ura-danjyon (ice tower)
		BYTE	C_0A0,C_0A1,C_0I1,C_0F0,C_0H0,C_0W1,C_0R1,C_0H1	;  C ura-danjyon (numa)
		BYTE	C_0B0,C_0B1,C_0J0,C_0F1,C_0H0,C_0X0,C_0M0,C_0H1	;  D ura-danjyon (kame-iwa)
		BYTE	C_0A0,C_0A1,C_0L0,C_0G1,C_0H0,C_0X1,C_0N0,C_0H1	;  E ura-danjyon (tower)
		BYTE	C_0A0,C_0A1,C_0I0,C_0D1,C_0H0,C_0U0,C_0P0,C_0H1	;  F shinden-jiji
;
		BYTE	C_0A0,C_0A1,C_0K0,C_0D1,C_0H0,C_0C0,C_0C1,C_0H1	; 10 shiro-nukemichi
		BYTE	C_0A0,C_0A1,C_0K0,C_0D1,C_0H0,C_0C0,C_0C1,C_0H1	;  1 ura-minka (kaji-ya)
		BYTE	C_0A0,C_0A1,C_0I0,C_0E1,C_0H0,C_0S1,C_0O1,C_0H1	;  2 sabaku
		BYTE	C_0A0,C_0A1,C_0I0,C_0E1,C_0H0,C_0X1,C_0M1,C_0H1	;  3 piramido
		BYTE	C_0B0,C_0B1,C_0J0,C_0F1,C_0H0,C_0T0,C_0P0,C_0H1	;  4 doukutsu jiji
		BYTE	C_0A0,C_0E0,C_0I1,C_0O1,C_0T1,C_0Z1,C_1Y1,C_1X1	;  5 
		BYTE	C_0A0,C_0E0,C_0I0,C_0N0,C_0S1,C_0Y0,C_1Y1,C_1X1	;  6
		BYTE	C_0A0,C_0E0,C_0I0,C_0N0,C_0S1,C_0Y0,C_1Y1,C_1X1	;  7
		BYTE	C_1G0,C_1G1,C_1H0,C_1H1,C_1T1,C_1Q1,C_1I0,C_1X1	;  8
		BYTE	C_1K0,C_1K1,C_1L0,C_1L1,C_0S1,C_0Y0,C_1I1,C_1Y1	;  9
		BYTE	C_0A0,C_0E0,C_0I0,C_0N0,C_0S1,C_0Y0,C_1Y1,C_1X1	;  A
		BYTE	C_0A0,C_0E0,C_0I0,C_0N0,C_0S1,C_0Y0,C_1Y1,C_1X1	;  B
		BYTE	C_0A0,C_0E0,C_0I0,C_0N0,C_0S1,C_0Y0,C_1Y1,C_1X1	;  C
		BYTE	C_0A0,C_0E0,C_0I0,C_0N0,C_0S1,C_0Y0,C_1Y1,C_1X1	;  D
		BYTE	C_0A0,C_0E0,C_0I0,C_0N0,C_0S1,C_0Y0,C_1Y1,C_1X1	;  E
		BYTE	C_4R0,C_4R1,C_4R0,C_4R1,C_0S1,C_0Y0,C_1Y1,C_1X1	;  F 
;
		BYTE	C_1G0,C_1G1,C_1H0,C_1H1,C_1T1,C_1Q1,C_1I0,C_1X1	; 20 ground
		BYTE	C_1K0,C_1K1,C_1L0,C_1L1,C_0S1,C_0Y0,C_1I1,C_1W1	;  1        (URA)
;
		BYTE	C_0A0,C_4R1,C_4R0,C_4R1,C_0S1,C_0Y0,C_1Y1,C_0H1	; 22 MAP
		BYTE	C_0M0,C_1F1,C_0R0,C_0M1,C_1J0,C_1J1,C_1F1,C_0R1	; 23 TITLE
		BYTE	C_0A0,C_1M0,C_1F1,C_4R1,C_1J0,C_1J1,C_1F1,C_0H1	; 24 end-polygon
;
;
;// 02.12.13 //;<<<<<< OBJ >>>>>>> 
;// 02.12.13 //OBCHDAT 	EQU	$ 
;// 02.12.13 //		BYTE	C_4I0,C_2X1,C_2X0,C_3C0	; 00 danjyon
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  1 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  2 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  3 
;// 02.12.13 //		BYTE	C_4I0,C_3H1,C_2X0,C_2X1 ;  4
;// 02.12.13 //		BYTE	C_4I0,C_3H0,C_2X0,C_4I1	;  5 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  6 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  7 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  8 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  9 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  A 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  B 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  C 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  D 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  E 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  F 
;// 02.12.13 //;
;// 02.12.13 //		BYTE	C_2X0,C_2X1,C_4H0,C_4H1	; 10 ground 
;// 02.12.13 //		BYTE	C_3B0,C_3B1,C_2X0,C_2X1	;  1 
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  2
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  3
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  4
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  5
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  6
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  7
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  8
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  9
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  A
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  B
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  C
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  D
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  E
;// 02.12.13 //		BYTE	C_4I0,C_3B0,C_3B1,C_2X0	;  F
;// 02.12.13 //; 
;// 02.12.13 //		BYTE	C_4R3,C_4R3,C_2X0,C_4H0	; 20 select map
;// 02.12.13 //;
; 
;
;
CHSCHNG		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	#10000000B
		STA	2115H		; inc. mode
;
;<<<<<  Basic  obj. 4bit set >>>>>>
		STZ	2116H
		LDA	#044H
		STA	2117H		; Vram address (04400H)
;
		JSR	CHSET1
;
;
;<<<<< Change obj. 3bit set >>>>>>
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
;// 03.05.10 //		LDY	#00003H
;// 03.05.10 //		LDX	#00000H
;// 03.05.10 //CHCH010		EQU	$
;// 03.05.10 //		LDA	>CHCHTB+4,X
;// 03.05.10 //		STA	WORK+6,Y
;// 03.05.10 //		INX
;// 03.05.10 //		DEY
;// 03.05.10 //		BPL	CHCH010		;
;// 03.05.10 //;					;
;// 03.05.10 //		LDX	#00003H
;// 02.10.03 //		LDA	!CHARBK
		LDA	!ROBJCPT
		AND	#000FFH
		ASL	A
		ASL	A
		TAY
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;// 03.05.10 //CHCH020	 	EQU	$
;// 03.05.10 //;// 02.10.03 //		LDA	OBCHDAT,Y
;// 03.05.10 //		LDA	ROBCHDT,Y
;// 03.05.10 //		BNE	CHCH030		;
;// 03.05.10 //;					;
;// 03.05.10 //;// 03.03.25 //		MEM16
;// 03.05.10 //;// 03.03.25 //		REP	#00100000B	; memory 16bit mode
;// 03.05.10 //;// 03.03.25 //		PHY			; (Y) push
;// 03.05.10 //;// 03.03.25 //		PHX			; (X) push
;// 03.05.10 //;// 03.03.25 //		TYA
;// 03.05.10 //;// 03.03.25 //		AND	#00003H
;// 03.05.10 //;// 03.03.25 //		TAX
;// 03.05.10 //;// 03.03.25 //		MEM8
;// 03.05.10 //;// 03.03.25 //		SEP	#00100000B	; memory 8bit mode
;// 03.05.10 //;// 03.03.25 //;
;// 03.05.10 //;// 03.03.25 //		LDA	>CHCHTB+4,X
;// 03.05.10 //;// 03.03.25 //		PLX			; (X) pull
;// 03.05.10 //;// 03.03.25 //		PLY			; (Y) pull
;// 03.05.10 //CHCH030		EQU	$
;// 03.05.10 //		STA	<WORK6,X
;// 03.05.10 //		INY
;// 03.05.10 //		DEX
;// 03.05.10 //		BPL	CHCH020
		LDA	ROBCHDT+0,Y
		BEQ	CHCH010		;
;					;
		STA	>CHCHTB+4+0
CHCH010		EQU	$
		LDA	>CHCHTB+4+0
		STA	<WORK6+3
;
		LDA	ROBCHDT+1,Y
		BEQ	CHCH012		;
;					;
		STA	>CHCHTB+4+1
CHCH012		EQU	$
		LDA	>CHCHTB+4+1
		STA	<WORK6+2
;
		LDA	ROBCHDT+2,Y
		BEQ	CHCH014		;
;					;
		STA	>CHCHTB+4+2
CHCH014		EQU	$
		LDA	>CHCHTB+4+2
		STA	<WORK6+1
;
		LDA	ROBCHDT+3,Y
		BEQ	CHCH016		;
;					;
		STA	>CHCHTB+4+3
CHCH016		EQU	$
		LDA	>CHCHTB+4+3
		STA	<WORK6+0
;
		IDX8
		SEP	#00010000B	; index 8bit mode
;
;// 02.10.03 //		LDA	!ROBJCPT
;// 02.10.03 //		ASL	A
;// 02.10.03 //		ASL	A
;// 02.10.03 //		TAX
;// 02.10.03 //		LDA	ROBCHDT,X
;// 02.10.03 //		STA	<WORK7
;// 02.10.03 //		LDA	ROBCHDT+1,X
;// 02.10.03 //		STA	<WORK6
;
;// 03.05.28 //		LDA	#003H
;// 03.05.28 //		STA	<WORKF
		LDY	<WORK6+3
		LDA	#BANK CHCHBF+0600H*4
		STA	<WORK2
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*4
		LDX	#HIGH CHCHBF+0600H*4
		JSR	CHSET
;// 03.05.28 //		DEC	<WORKF
		LDY	<WORK6+2
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*5
		LDX	#HIGH CHCHBF+0600H*5
		JSR	CHSET
;// 03.05.28 //		DEC	<WORKF
		LDY	<WORK6+1
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*6
		LDX	#HIGH CHCHBF+0600H*6
		JSR	CHSET
;// 03.05.28 //		DEC	<WORKF
		LDY	<WORK6+0
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*7
		LDX	#HIGH CHCHBF+0600H*7
		JSR	CHSET
;
;
CHCH100		EQU	$
;<<<<< BG charcter set >>>>>>
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	#02000H
		STA	2116H		; Vram address (02000H)
;
;// 03.05.16 //		LDX	#00007H
		LDA	!CHIKNO
		AND	#000FFH
		ASL	A
		ASL	A
		ASL	A
		TAY
;
;// 03.05.16 //		MEM8
;// 03.05.16 //		SEP	#00100000B	; memory 8bit mode
;// 03.05.16 //CHCH100 	EQU	$
;// 03.05.16 //		LDA	BGCHDAT,Y
;// 03.05.16 //		STA	<WORK6,X
;// 03.05.16 //		INY
;// 03.05.16 //		DEX
;// 03.05.16 //		BPL	CHCH100
;// 03.05.16 //;
;// 03.05.16 //		MEM16
;// 03.05.16 //		REP	#00100000B	; index 16bit mode
;
		LDA	!RBGCPT
		AND	#000FFH
		ASL	A
		ASL	A
		TAX
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;
		LDA	BGCHDAT+0,Y
		STA	<WORK6+7
;
		LDA	BGCHDAT+1,Y
		STA	<WORK6+6
;
		LDA	BGCHDAT+2,Y
		STA	<WORK6+5
;
		LDA	RBGCHDT+0,X
		BNE	CHCH110		; set ?
;					; yes
		LDA	BGCHDAT+3,Y
CHCH110		EQU	$
		STA	>CHCHTB+0
		STA	<WORK6+4
;
		LDA	RBGCHDT+1,X
		BNE	CHCH120		; set ?
;					; yes
		LDA	BGCHDAT+4,Y
CHCH120		EQU	$
		STA	>CHCHTB+1
		STA	<WORK6+3
;
		LDA	RBGCHDT+2,X
		BNE	CHCH130		; set ?
;					; yes
		LDA	BGCHDAT+5,Y
CHCH130		EQU	$
		STA	>CHCHTB+2
		STA	<WORK6+2
;
		LDA	RBGCHDT+3,X
		BNE	CHCH140		; set ?
;					; yes
		LDA	BGCHDAT+6,Y
CHCH140		EQU	$
		STA	>CHCHTB+3
		STA	<WORK6+1
;
		LDA	BGCHDAT+7,Y
		STA	<WORK6+0
;
		IDX8
		SEP	#00010000B	; index 8bit mode
;
		LDA	#007H
		STA	<WORKF
		LDY	<WORK6+7
		JSR	CHSET0
;
		DEC	<WORKF
		LDY	<WORK6+6
		JSR	CHSET0
;
		DEC	<WORKF
		LDY	<WORK6+5
		JSR	CHSET0
;
		DEC	<WORKF
		LDY	<WORK6+4
		LDA	#BANK CHCHBF+0600H*0
;// 03.05.31 //		STA	<WORK2
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*0
		LDX	#HIGH CHCHBF+0600H*0
		JSR	CHS0000
;
		DEC	<WORKF
		LDY	<WORK6+3
		LDA	#BANK CHCHBF+0600H*1
;// 03.05.31 //		STA	<WORK2
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*1
		LDX	#HIGH CHCHBF+0600H*1
		JSR	CHS0000
;
		DEC	<WORKF
		LDY	<WORK6+2
		LDA	#BANK CHCHBF+0600H*2
;// 03.05.31 //		STA	<WORK2
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*2
		LDX	#HIGH CHCHBF+0600H*2
		JSR	CHS0000
;
		DEC	<WORKF
		LDY	<WORK6+1
		LDA	#BANK CHCHBF+0600H*3
;// 03.05.31 //		STA	<WORK2
;// 03.05.31 //		LDA	#LOW CHCHBF+0600H*3
		LDX	#HIGH CHCHBF+0600H*3
		JSR	CHS0000
;
		DEC	<WORKF
		LDY	<WORK6+0
		JSR	CHSET0
;
		PLB			; (DBR) reset
		RTL
;
;
;
; 
;************************************************************************
;*		BG.3 character set			(CHSCHN0)	*
;************************************************************************
CHSCHN0		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	#10000000B
		STA	2115H		; inc. mode
;
;// 03.05.17 //		LDY	#C_2R0
		LDA	OCADB
		STA	<WORK2
		LDA	OCADH
		STA	<WORK1
		LDA	OCADL
		STA	<WORK0
;
		MEM16
		REP	#00100000B	; memory 16bit mode
;
		LDA	#04000H
		STA	2116H		; Vram address (04000H)
;
		LDY	#040H
CHS1100 	EQU	$
		LDX	#00EH
CHS1140 	EQU	$
		LDA	[<WORK0]
		STA	2118H
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<BFP000,X
		INC	<WORK0
		INC	<WORK0
		DEX
		DEX
		BPL	CHS1140
;
		LDX	#00EH
CHS1180 	EQU	$
		LDA	[<WORK0]
		AND	#000FFH
		STA	<WORKZ
		ORA	<BFP000,X
		XBA
		ORA	<WORKZ
		STA	2118H
		INC	<WORK0
		DEX
		DEX
		BPL	CHS1180
;
		DEY
		BNE	CHS1100		; 0-7 char. ?
;					; yes
;
;<<<<< BG. 2bit set (BG3) >>>>>
		LDA	#06000H
		STA	2116H		; Vram address (06000H)
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;
		LDY	#C_4W
		JSR	CHCHN200	; character set
;
		LDY	#C_4X
		JSR	CHCHN200	; character set
;
		LDY	#C_4V
		JSR	CHCHN200	; character set
;
		PLB			; (DBR) RESET
;
		RTL
;
;
CHCHN200	EQU	$
		JSR	CADWKST2	; char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDX	#003FEH/4
CHCHN260 	EQU	$
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		DEX
		BPL	CHCHN260
;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTS
;
;
;
; 
;************************************************************************
;*		Title-demo BG.3 character set		(CHSCHN1)	*
;************************************************************************
CHSCHN1		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	#10000000B
		STA	2115H		; inc. mode
;
;<<<<< BG. 2bit set (BG3) >>>>>
		STZ	2116H
		LDA	#068H
		STA	2117H		; Vram address (06800H)
;
		LDY	#C_4T
		JSR	CHCHN200	; character set
;
		PLB			; (DBR) reset
		RTL
; 
;
;
;************************************************************************
;*		Title-demo OBJ. character set		(CHSCHN2)	*
;************************************************************************
CHSCHN2		EQU	$
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	#10000000B
		STA	2115H		; inc. mode
;
;<<<<<  Basic  obj. 4bit set >>>>>>
		STZ	2116H
		LDA	#044H
		STA	2117H		; Vram address (04400H)
;
		JSR	CHSET1
;
		PLB			; (DBR) reset
		RTL
;
;
;
;
;************************************************************************
;*		Mode<7> character set			(M7CHST)	*
;************************************************************************
M7CHST		EQU	$
		LDA	#018H
		STA	<WORK2		; mode<7> char B address
;
		LDA	#10000000B
		STA	2115H
		STZ	2116H
		STZ	2117H		; Vram address
;
		IDX16
		REP	#00010000B	; index 16bit mode
;
		LDY	#0C000H
		STY	<WORK0		; mode<7> char L,H address
;
		LDY	#000000H
M7CH400		EQU	$
		LDA	[<WORK0],Y
		STA	2119H		; Vram charcter set
		INY
		LDA	[<WORK0],Y
		STA	2119H		; Vram charcter set
		INY
		LDA	[<WORK0],Y
		STA	2119H		; Vram charcter set
		INY
		LDA	[<WORK0],Y
		STA	2119H		; Vram charcter set
		INY
		CPY	#04000H
		BNE	M7CH400		; set end ?
;					; yes
		IDX8
		SEP	#00010000B	; index 8bit mode
SPOJC90		EQU	$
		RTL
;
;
;
;
;************************************************************************
;*		Spacial OBJ character change		(SPOJCNG)	*
;************************************************************************
spoj0		EQU	001H		; reset
spoj1		EQU	003H		; fire
spoj2		EQU	005H		; ice
spoj3		EQU	007H		; flower
spoj4		EQU	009H		; thunder
spoj5		EQU	00BH		; bomber
spoj6		EQU	00DH		; jishin
spoj7		EQU	00FH		; "GAME OVER"
spoj8		EQU	011H+1		; tori
spoj9		EQU	013H		; 'Nintendo presents'
;
;
;// 02.10.24 //SPOADT		EQU	$-1
;// 02.10.24 //		BYTE	000H,003H,000H,003H,000H,003H
;
SPOPTD		EQU	$-1
		BYTE	C_2R1,C_2R1,C_2V0,C_2V0
		BYTE	C_2V1,C_2V1,C_2S0,C_2S0
		BYTE	C_2S0,C_2S0,C_2S1,C_2S1
		BYTE	C_2T0,C_2T0,C_2T1,C_2T1
		BYTE	C_2V0,C_2V0,C_2V0,C_2V0
;
SPOCGD		EQU	$-1
;			  reset      fire
		BYTE	00AH,0FFH,003H,0FFH
;			   ice      flower
		BYTE	000H,0FFH,0FFH,0FFH
;			 thunder    bomber
		BYTE	001H,0FFH,002H,0FFH
;			 jishin   "Game over"
		BYTE	000H,0FFH,0FFH,0FFH
;			  tori
		BYTE	0FFH,0FFH,0FFH,0FFH
;
;// 02.10.24 //SPOADR		EQU	$-1
;// 02.10.24 //		BYTE	044H,046H,044H,046H,044H,046H
;
;
SPOJCNG		EQU	$
		LDX	!SPOJFG
		BEQ	SPOJC90		; spacial OBJ set ?
;					; yes
		PHB
		PHK
		PLB			; (DBR) set
;
		LDA	SPOCGD,X
		BMI	SPOJ20		; CG. set ?
;					; yes
		STA	!CHITEMJC
		CPX	#001H
		BNE	SPOJ10		; reset ?
;					; yes
;// 03.06.04 //		LDA	<GMMODE
;// 03.06.04 //		BNE	SPOJ05		; ground ?
;// 03.06.04 //;					; yes
;// 03.06.04 //		LDA	#006H
;// 03.06.04 //		STA	!CHITEMJC
;// 03.06.04 //		LDA	<MPDTNO
;// 03.06.04 //		AND	#01000000B
;// 03.06.04 //		BEQ	SPOJ10		; ura ?
;// 03.06.04 //;					; yes
;// 03.06.04 //		LDA	#008H
;// 03.06.04 //		STA	!CHITEMJC
		LDA	#00AH
		STA	!CHITEMJC
		LDA	#002H
		STA	!CGSTPT+1	; (CGWORK) set
		JSL	>CHITEMST	; special CG. set
		INC	<CGVMAF
		BRA	SPOJ20
;
SPOJ10		EQU	$
		LDA	#002H
		STA	!CGSTPT+1	; (CGWORK) set
		JSL	>CHITEMS0	; special CG. set
		INC	<CGVMAF
SPOJ20		EQU	$
		LDX	!SPOJFG
		LDY	#044H
		STZ	<WORK8
		STZ	<WORK9
		INC	!SPOJFG
		LDA	!SPOJFG
		LSR	A
		BCC	SPOJ40		; end ?
;					; yes
		STZ	!SPOJFG
		CPX	#spoj8
		BEQ	SPOJ40		; tori ?
;					; yes
		LDA	#003H
		STA	<WORK9
		LDY	#046H
		CPX	#spoj0+1
		BNE	SPOJ40		; reset ?
;					; yes
		STZ	!SPMCFG
SPOJ40		EQU	$
		STY	!NXBWFG		; OBJ. BG. character change flag on
		LDA	#bgwB
		STA	<BGWTFG
;
		LDY	SPOPTD,X	; (Y) <-- file pointer
		CPY	#C_2R1
		BNE	SPOJ50		; reset ?
;					; yes
		LDY	!OJBSPT
;// 03.06.04 //		LDA	<MPDTNO
;// 03.06.04 //		AND	#01000000B
;// 03.06.04 //		BEQ	SPOJ50		; ura ?
;// 03.06.04 //;					; yes
;// 03.06.04 //		LDY	#C_2W1
SPOJ50		EQU	$
		LDA	OCADB,Y 
		STA	<WORK2
		STA	<WORK5
		LDA	OCADH,Y
		STA	<WORK1
		LDA	OCADL,Y
		STA	<WORK0
;
;// 03.03.13 //		CPX	#003H
;// 03.03.13 //		BCS	SPOJ200		; 8-F color ?
;// 03.03.13 //;					; no
;// 03.03.13 //		MEM16
;// 03.03.13 //		IDX16
;// 03.03.13 //		REP	#00110001B	; memory,index 16bit mode & CLC
;// 03.03.13 //;
;// 03.03.13 //		LDY	#00010H*2
;// 03.03.13 //		STY	<WORKC
;// 03.03.13 //		LDX	#00000H
;// 03.03.13 //		LDA	<WORK0
;// 03.03.13 //		ADC	<WORK8
;// 03.03.13 //SPOJ100		EQU	$
;// 03.03.13 //		STA	<WORK0
;// 03.03.13 //		CLC
;// 03.03.13 //		ADC	#00010H
;// 03.03.13 //		STA	<WORK3
;// 03.03.13 //;
;// 03.03.13 //		LDY	#00007H
;// 03.03.13 //SPOJ120 	EQU	$
;// 03.03.13 //		LDA	[<WORK0]
;// 03.03.13 //		STA	>RSETCBF+1000H,X
;// 03.03.13 //		INC	<WORK0
;// 03.03.13 //		INC	<WORK0
;// 03.03.13 //		BNE	SPOJ160		; bank change ?
;// 03.03.13 //;					; yes
;// 03.03.13 //		LDA	#08000H
;// 03.03.13 //		STA	<WORK0
;// 03.03.13 //		LDA	#08010H
;// 03.03.13 //		STA	<WORK3
;// 03.03.13 //		INC	<WORK2
;// 03.03.13 //		INC	<WORK5
;// 03.03.13 //SPOJ160		EQU	$
;// 03.03.13 //		LDA	[<WORK3]
;// 03.03.13 //		AND	#000FFH
;// 03.03.13 //		STA	>RSETCBF+1010H,X
;// 03.03.13 //		INC	<WORK3
;// 03.03.13 //		BNE	SPOJ180		; bank change ?
;// 03.03.13 //;					; yes
;// 03.03.13 //		LDA	#08000H
;// 03.03.13 //		STA	<WORK0
;// 03.03.13 //		LDA	#08010H
;// 03.03.13 //		STA	<WORK3
;// 03.03.13 //		INC	<WORK2
;// 03.03.13 //		INC	<WORK5
;// 03.03.13 //SPOJ180		EQU	$
;// 03.03.13 //		INX
;// 03.03.13 //		INX
;// 03.03.13 //		DEY
;// 03.03.13 //		BPL	SPOJ120		; 1char. end ?
;// 03.03.13 //;					; yes
;// 03.03.13 //		TXA
;// 03.03.13 //		CLC
;// 03.03.13 //		ADC	#00010H
;// 03.03.13 //		TAX
;// 03.03.13 //		LDA	<WORK3
;// 03.03.13 //		DEC	<WORKC
;// 03.03.13 //		BNE	SPOJ100		; end ?
;// 03.03.13 //;					; yes
;// 03.03.13 //		MEM8
;// 03.03.13 //		IDX8
;// 03.03.13 //		SEP	#00110000B	; memory,index 8bit mode
;// 03.03.13 //		PLB			; (DBR) reset
;// 03.03.13 //		RTL
;// 03.03.13 //;
;// 03.03.13 //SPOJ200		EQU	$
;
		MEM16
		IDX16
		REP	#00110001B	; memory,index 16bit mode & CLC
;
		LDY	#00010H*2
		STY	<WORKC
		LDX	#00000H
		LDA	<WORK0
		ADC	<WORK8
SPOJ220		EQU	$
		STA	<WORK0
		CLC
		ADC	#00010H
		BNE	SPOJ230		; bank change ?
;					; yes
		LDA	#08000H
		INC	<WORK5
SPOJ230		EQU	$
		STA	<WORK3
;
		LDY	#00007H
SPOJ240 	EQU	$
		LDA	[<WORK0]
		STA	>RSETCBF+1000H,X
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<WORK8
		INC	<WORK0
		INC	<WORK0
		BNE	SPOJ260		; bank change ?
;					; yes
		LDA	<WORK3
		INC	A
		STA	<WORK0
		INC	<WORK2
		LDA	<WORK2
		STA	<WORK5
SPOJ260		EQU	$
		LDA	[<WORK3]
		AND	#000FFH
		STA	<WORKA
		ORA	<WORK8
		XBA
		ORA	<WORKA
		STA	>RSETCBF+1010H,X
		INC	<WORK3
		BNE	SPOJ280		; bank change ?
;					; yes
		LDA	#08000H
		STA	<WORK0
		LDA	#08010H
		STA	<WORK3
		INC	<WORK2
		INC	<WORK5
SPOJ280		EQU	$
		INX
		INX
		DEY
		BPL	SPOJ240		; 1char. end ?
;					; yes
		TXA
		CLC
		ADC	#00010H
		TAX
		LDA	<WORK3
		DEC	<WORKC
		BNE	SPOJ220		; end ?
;					; yes
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		PLB			; (DBR) reset
		RTL
;
;
;
;
;
;
;
; 
		MEM8
		IDX8
;************************************************************************
;*		Message char. Vramd set			(MSGVRMS)	*
;************************************************************************
MSGVRMS		EQU	$
		LDA	#00000010B
		STA	2101H		; obj size,address set
		LDA	#10000000B
		STA	2115H		; inc. mode
;
;
;<<<<< OBJ. 3bit set  >>>>>
		STZ	2116H
		LDA	#050H
		STA	2117H		; Vram address (05000H)
;
		PHB
		PHK
		PLB			; (DBR) set
;
		LDY	#C_4O0
		JSR	CADWKST2	; char. address work set
		REP	#00100000B	; memory 16bit mode
		LDY	#03FH
		JSR	CHST800		; ken,tate set
;
		LDY	#C_4O1
		JSR	CADWKST2	; char. address work set
		REP	#00100000B	; memory 16bit mode
		LDY	#03FH
		JSR	CHST800		; ken,tate set
;
		PLB			; (DBR) reset
;
;
;<<<<< BG. 2bit set (BG3) >>>>>
;// 03.10.18 //		LDA	#BANK GDBUF0
;// 03.10.18 //		STA	<WORK2
;// 03.10.18 //;
;// 03.10.18 //		MEM16
;// 03.10.18 //		IDX16
;// 03.10.18 //		REP	#00110000B	; memory,index 16bit mode
;// 03.10.18 //;
;// 03.10.18 //		LDA	#07000H
;// 03.10.18 //		STA	2116H		; Vram address (07000H)
;// 03.10.18 //;
;// 03.10.18 //		LDA	#GDBUF0
;// 03.10.18 //		STA	<WORK0
;// 03.10.18 //;
;// 03.10.18 //		LDX	#(0100H+00A0H)*10H/2-1
;// 03.10.18 //MVMS40	 	EQU	$
;// 03.10.18 //		LDA	[<WORK0]
;// 03.10.18 //		STA	2118H
;// 03.10.18 //		INC	<WORK0
;// 03.10.18 //		INC	<WORK0
;// 03.10.18 //		DEX
;// 03.10.18 //		BPL	MVMS40
;// 03.10.18 //;
;
		LDA	#BANK MOJIFNT
		STA	<WORK2
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	#06000H
		STA	2116H		; Vram address (06000H)
;
		LDA	#MOJIFNT
		STA	<WORK0
;
		LDX	#(00100H*10H)/2-1
MVMS40		EQU	$
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		DEX
		BPL	MVMS40		;
;					;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		PHB
		PHK
		PLB			; (DBR) set
;
		LDY	#C_4X
		JSR	CADWKST2	; char. address work set
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDX	#(0100H-00A0H)*10H/2-1
MVMS80		EQU	$
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		DEX
		BPL	MVMS80		; set end ?
;					; yes
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
;
		PLB			; (DBR) reset
		RTL
;
;
;
;
; 
;************************************************************************
;*		Ending char. Vramd set			(ENDGVRMS)	*
;************************************************************************
ENDGVRMS	EQU	$
		LDA	#00000010B
		STA	2101H		; obj size,address set
		LDA	#10000000B
		STA	2115H		; inc. mode
;
;
;<<<<< BG. 2bit set (BG3) >>>>>
;// 03.10.18 //		LDA	#BANK GDBUF0
;// 03.10.18 //		STA	<WORK2
;// 03.10.18 //;
;// 03.10.18 //		MEM16
;// 03.10.18 //		IDX16
;// 03.10.18 //		REP	#00110000B	; memory,index 16bit mode
;// 03.10.18 //;
;// 03.10.18 //		LDA	#07000H
;// 03.10.18 //		STA	2116H		; Vram address (07000H)
;// 03.10.18 //;
;// 03.10.18 //		LDA	#GDBUF0
;// 03.10.18 //		STA	<WORK0
;// 03.10.18 //;
;// 03.10.18 //		LDX	#(0100H+0100H)*10H/2-1
;// 03.10.18 //EVMS40	 	EQU	$
;// 03.10.18 //		LDA	[<WORK0]
;// 03.10.18 //		STA	2118H
;// 03.10.18 //		INC	<WORK0
;// 03.10.18 //		INC	<WORK0
;// 03.10.18 //		DEX
;// 03.10.18 //		BPL	EVMS40
;// 03.10.18 //;
;
		LDA	#BANK MOJIFNT
		STA	<WORK2
;
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	#06000H
		STA	2116H		; Vram address (06000H)
;
		LDA	#MOJIFNT
		STA	<WORK0
;
		LDX	#(00200H*10H)/2-1
EVMS40		EQU	$
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		DEX
		BPL	EVMS40		;
;					;
		MEM8
		IDX8
		SEP	#00110000B	; memory,index 8bit mode
		RTL
;
;
;
;
;// 03.06.27 //;
;// 03.06.27 //;************************************************************************
;// 03.06.27 //;*		Message char. Vramd set			(MSGVRMS1)	*
;// 03.06.27 //;************************************************************************
;// 03.06.27 //MSGVRMS1	EQU	$
;// 03.06.27 //		LDA	#00000010B
;// 03.06.27 //		STA	2101H		; obj size,address set
;// 03.06.27 //		LDA	#10000000B
;// 03.06.27 //		STA	2115H		; inc. mode
;// 03.06.27 //;
;// 03.06.27 //;<<<<< BG. 2bit set (BG3) >>>>>
;// 03.06.27 //		LDA	#BANK GDBUF0
;// 03.06.27 //		STA	<WORK2
;// 03.06.27 //;
;// 03.06.27 //		MEM16
;// 03.06.27 //		REP	#00100000B	; memory 16bit mode
;// 03.06.27 //;
;// 03.06.27 //		LDA	#07000H
;// 03.06.27 //		STA	2116H		; Vram address (07000H)
;// 03.06.27 //;
;// 03.06.27 //		LDA	#GDBUF0
;// 03.06.27 //		STA	<WORK0
;// 03.06.27 //;
;// 03.06.27 //		LDA	[<WORK0]
;// 03.06.27 //		STA	2118H
;// 03.06.27 //;
;// 03.06.27 //		MEM8
;// 03.06.27 //		SEP	#00100000B	; memory 8bit mode
;// 03.06.27 //		RTL
;// 03.06.27 //;
;
;
;=========================================================================
;=========================================================================
;=========================================================================
;
		MEM8
		IDX8
;*************************************************************************
;*	 Y ----- flg  0~						 *
;*************************************************************************
CHSET		EQU	$
		STZ	<WORK0
		STX	<WORK1
;
		PHY			; (Y) push
;// 03.05.29 //		JSR	CADWKST2	; char. address work set
		JSR	CADWS300	; char. address work set
;
		MEM16
		REP	#00100000B	; memory 16bit mode
;
		LDY	#03FH
		PLX			; (X) <-- (Y) pull
;// 03.05.28 //CHST000 	EQU	$
;// 03.05.28 //		LDX	<WORKF
;// 03.05.28 //;// 03.03.19 //		LDA	>CHCHTB+4,X
;// 03.05.28 //;// 03.03.19 //		AND	#000FFH
;// 03.05.28 //		LDA	<WORK6,X
;// 03.05.28 //		AND	#000FFH
;// 03.05.28 //		CMP	#C_4I0
		CPX	#C_4I0
		BEQ	CHST800		; 8~F color ?
;					; no
;// 03.05.28 //		CMP	#C_4I1
		CPX	#C_4I1
		BEQ	CHST800		; 8~F color ?
;					; no
;// 03.05.28 //		CMP	#C_4M0
		CPX	#C_4M0
		BEQ	CHST800		; 8~F color ?
;					; no
;// 03.05.28 //		CMP	#C_4M1
		CPX	#C_4M1
		BEQ	CHST800		; 8~F color ?
;					; no
		CPX	#C_4N0
		BEQ	CHST800		; 8~F color ?
;					; no
;// 03.05.28 //		CMP	#C_4O0
		CPX	#C_4O0
		BEQ	CHST800		; 8~F color ?
;					; no
;// 03.05.28 //		CMP	#C_4O1
		CPX	#C_4O1
		BEQ	CHST800		; 8~F color ?
;					; no
;// 03.05.31 //CHST050		EQU	$
		JMP	CHS0100
;// 03.05.17 //		LDX	#000H
;// 03.05.17 //CHST100 	EQU	$
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		DEX
;// 03.05.17 //		BPL	CHST100
;// 03.05.17 //;
;// 03.05.17 //		LDX	#000H
;// 03.05.17 //CHST500 	EQU	$
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		AND	#00FFH
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		AND	#00FFH
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		AND	#00FFH
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		AND	#00FFH
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		DEX
;// 03.05.17 //		BPL	CHST500
;// 03.05.17 //;
;// 03.05.17 //		DEY
;// 03.05.17 //		BPL	CHST050		; end ?
;// 03.05.17 //;					; yes
;// 03.05.17 //		MEM8
;// 03.05.17 //		SEP	#00100000B	; memory 8bit mode
;// 03.05.17 //		RTS
;
		MEM16
CHS0300 	EQU	$
CHST800 	EQU	$
		LDX	#00EH
CHST820 	EQU	$
		LDA	[<WORK0]
		STA	2118H
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<BFP000,X
		INC	<WORK0
		INC	<WORK0
		DEX
		DEX
		LDA	[<WORK0]
		STA	2118H
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<BFP000,X
		INC	<WORK0
		INC	<WORK0
		DEX
		DEX
		BPL	CHST820
;
		LDX	#00EH
CHST860 	EQU	$
		LDA	[<WORK0]
		AND	#000FFH
		STA	<WORKZ
		ORA	<BFP000,X
		XBA
		ORA	<WORKZ
		STA	2118H
		INC	<WORK0
		DEX
		DEX
		LDA	[<WORK0]
		AND	#000FFH
		STA	<WORKZ
		ORA	<BFP000,X
		XBA
		ORA	<WORKZ
		STA	2118H
		INC	<WORK0
		DEX
		DEX
		BPL	CHST860
;
		DEY
		BPL	CHST800		; end ?
;					; yes
		MEM8
		SEP	#00100000B	; memory 8bit mode
		RTS
;
;
;*************************************************************************
;*	 Y ----- flg  0~						 *
;*************************************************************************
CHSET0		EQU	$
		LDA	#BANK MPCHBF
		LDX	#HIGH MPCHBF
;// 03.05.31 //		LDA	#LOW MPCHBF
CHS0000		EQU	$
		STZ	<WORK0		; LOW
		STX	<WORK1		; HIGH
		STA	<WORK2		; BANK
;
		JSR	CADWS100	; char. address work set
CHS0010		EQU	$
		MEM16
		REP	#00100000B	; memory 16bit mode
;
		LDY	#03FH 
		LDX	!CHIKNO
;// 03.05.31 //		CPX	#020H
;// 03.05.31 //		BNE	CHS0020		; select-map ?
;// 03.05.31 //;					; yes
;// 03.05.31 //		LDX	<WORKF
;// 03.05.31 //		CPX	#004H
;// 03.05.31 //		BEQ	CHS0030		; 8-F character ?
;// 03.05.31 //;					; no
;// 03.05.31 //		CPX	#003H
;// 03.05.31 //		BEQ	CHS0030		; 8-F character ?
;// 03.05.31 //;					; no
;// 03.05.31 //		BRA	CHS0100
;// 03.05.31 //;
;// 03.05.31 //CHS0020		EQU	$
		CPX	#020H
		BCC	CHS0040		; ground ?
;					; yes
		LDX	<WORKF
		CPX	#007H
		BEQ	CHS0300		; 8-F character ?
;					; no
		CPX	#002H
		BEQ	CHS0300		; 8-F character ?
;					; no
		CPX	#004H
		BEQ	CHS0300		; 8-F character ?
;					; no
		CPX	#003H
		BNE	CHS0100		; 8-F character ?
;					; yes
CHS0030		EQU	$
		JMP	CHS0300
;
CHS0040		EQU	$
		LDX	<WORKF
;// 03.07.09 //		CPX	#007H
;// 03.07.09 //		BEQ	CHS0030		; 8-F character ?
;// 03.07.09 //;					; no
;// 03.07.09 //		CPX	#006H
;// 03.07.09 //		BEQ	CHS0030		; 8-F character ?
;// 03.07.09 //;					; no
;// 03.07.09 //		CPX	#005H
;// 03.07.09 //		BEQ	CHS0030		; 8-F character ?
;// 03.07.09 //;					; no
;// 03.07.09 //		CPX	#004H
;// 03.07.09 //		BEQ	CHS0030		; 8-F character ?
		CPX	#004H
		BCS	CHS0030		; 8-F character ?
;					; no
CHS0100 	EQU	$
;// 03.05.17 //		LDX	#000H
;// 03.05.17 //CHS0120 	EQU	$
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
		LDA	[<WORK0]
		STA	2118H
		INC	<WORK0
		INC	<WORK0
;// 03.05.17 //		DEX
;// 03.05.17 //		BPL	CHS0120
;
		LDX	#001H
CHS0160 	EQU	$
		LDA	[<WORK0]
		AND	#000FFH
		STA	2118H
		INC	<WORK0
		LDA	[<WORK0]
		AND	#000FFH
		STA	2118H
		INC	<WORK0
		LDA	[<WORK0]
		AND	#000FFH
		STA	2118H
		INC	<WORK0
		LDA	[<WORK0]
		AND	#000FFH
		STA	2118H
		INC	<WORK0
		DEX
		BPL	CHS0160
;
		DEY
		BPL	CHS0100
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
		RTS
;
;
;// 03.05.17 //		MEM16
;// 03.05.17 //CHS0300 	EQU	$
;// 03.05.17 //		LDX	#00EH
;// 03.05.17 //CHS0320 	EQU	$
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		XBA
;// 03.05.17 //		ORA	[<WORK0]
;// 03.05.17 //		AND	#000FFH
;// 03.05.17 //		STA	<BFP000,X
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		DEX
;// 03.05.17 //		DEX
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		XBA
;// 03.05.17 //		ORA	[<WORK0]
;// 03.05.17 //		AND	#000FFH
;// 03.05.17 //		STA	<BFP000,X
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		DEX
;// 03.05.17 //		DEX
;// 03.05.17 //		BPL	CHS0320
;// 03.05.17 //;
;// 03.05.17 //		LDX	#0EH
;// 03.05.17 //CHS0360 	EQU	$
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		AND	#000FFH
;// 03.05.17 //		STA	<WORKZ
;// 03.05.17 //		ORA	<BFP000,X
;// 03.05.17 //		XBA
;// 03.05.17 //		ORA	<WORKZ
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		DEX
;// 03.05.17 //		DEX
;// 03.05.17 //		LDA	[<WORK0]
;// 03.05.17 //		AND	#000FFH
;// 03.05.17 //		STA	<WORKZ
;// 03.05.17 //		ORA	<BFP000,X
;// 03.05.17 //		XBA
;// 03.05.17 //		ORA	<WORKZ
;// 03.05.17 //		STA	2118H
;// 03.05.17 //		INC	<WORK0
;// 03.05.17 //		DEX
;// 03.05.17 //		DEX
;// 03.05.17 //		BPL	CHS0360
;// 03.05.17 //;
;// 03.05.17 //		DEY
;// 03.05.17 //		BPL	CHS0300		; end ?
;// 03.05.17 //;					; yes
;// 03.05.17 //		MEM8
;// 03.05.17 //		SEP	#00100000B	; memory 8bit mode
;// 03.05.17 //		RTS
;// 03.05.17 //;
;
;
;
;*************************************************************************
;*    obj 2bit CH set							*
;*************************************************************************
CHSET1		EQU	$
		LDY	!OJBSPT
		LDA	OCADB,Y 
		STA	<WORK2
		LDA	OCADH,Y
		STA	<WORK1
		LDA	OCADL,Y
		STA	<WORK0
;
		MEM16
		REP	#00100000B	; memory 16bit mode
;
		LDY	#040H
CHS1200 	EQU	$
		LDX	#00EH
CHS1240 	EQU	$
		LDA	[<WORK0]
		STA	2118H
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<BFP000,X
		INC	<WORK0
		INC	<WORK0
		DEX
		DEX
		LDA	[<WORK0]
		STA	2118H
		XBA
		ORA	[<WORK0]
		AND	#000FFH
		STA	<BFP000,X
		INC	<WORK0
		INC	<WORK0
		DEX
		DEX
		BPL	CHS1240
;
		LDX	#00EH
CHS1280 	EQU	$
		LDA	[<WORK0]
		AND	#000FFH
		STA	<WORKZ
		ORA	<BFP000,X
		XBA
		ORA	<WORKZ
		STA	2118H
		INC	<WORK0
		DEX
		DEX
		LDA	[<WORK0]
		AND	#000FFH
		STA	<WORKZ
		ORA	<BFP000,X
		XBA
		ORA	<WORKZ
		STA	2118H
		INC	<WORK0
		DEX
		DEX
		BPL	CHS1280
;
		DEY
		BNE	CHS1200		; 0-7 char. ?
;					; yes
;
		MEM8
		SEP	#00100000B	; memory 8bit mode
;
		LDA	<SLMODE
		CMP	#001H
		BEQ	TCHSET1		; select-gamen ?
;					; no
		LDY	#C_2U0
		LDA	OCADB,Y 
		STA	<WORK2
		LDA	OCADH,Y
		STA	<WORK1
		LDA	OCADL,Y
		STA	<WORK0
;
		MEM16
		REP	#00100000B	; memory 16bit mode
;
;// 03.05.20 //		LDY	#080H
		LDY	#07FH
		JMP	CHS0100
;// 03.05.20 //CHS1300 	EQU	$
;// 03.05.20 //		LDX	#007H
;// 03.05.20 //CHS1340 	EQU	$ 
;// 03.05.20 //		LDA	[<WORK0]
;// 03.05.20 //		STA	2118H
;// 03.05.20 //		INC	<WORK0
;// 03.05.20 //		INC	<WORK0
;// 03.05.20 //;// 03.02.28 //		BNE	CHS1360		; bank change ?
;// 03.05.20 //;// 03.02.28 //;					; yes
;// 03.05.20 //;// 03.02.28 //		LDA	#08000H
;// 03.05.20 //;// 03.02.28 //		STA	<WORK0
;// 03.05.20 //;// 03.02.28 //		INC	<WORK2
;// 03.05.20 //;// 03.02.28 //CHS1360		EQU	$
;// 03.05.20 //;// 03.02.28 //		DEX
;// 03.05.20 //		DEX
;// 03.05.20 //		BPL	CHS1340
;// 03.05.20 //;
;// 03.05.20 //		LDX	#007H
;// 03.05.20 //CHS1380 	EQU	$
;// 03.05.20 //		LDA	[<WORK0]
;// 03.05.20 //		AND	#000FFH
;// 03.05.20 //		STA	2118H
;// 03.05.20 //		INC	<WORK0
;// 03.05.20 //;// 03.02.28 //		BNE	CHS1390		; bank change ?
;// 03.05.20 //;// 03.02.28 //;					; yes
;// 03.05.20 //;// 03.02.28 //		LDA	#08000H
;// 03.05.20 //;// 03.02.28 //		STA	<WORK0
;// 03.05.20 //;// 03.02.28 //		INC	<WORK2
;// 03.05.20 //;// 03.02.28 //CHS1390		EQU	$
;// 03.05.20 //;// 03.02.28 //		DEX
;// 03.05.20 //		DEX
;// 03.05.20 //		BPL	CHS1380
;// 03.05.20 //;
;// 03.05.20 //		DEY
;// 03.05.20 //		BNE	CHS1300 	; end ?
;// 03.05.20 //;					; yes
;// 03.05.20 //		MEM8
;// 03.05.20 //		SEP	#00100000B	; memory 8bit mode
;// 03.05.20 //		RTS
;
;
;
		MEM8
TCHSET1		EQU	$
		STZ	<WORKF
		LDY	#C_4O0
		STY	<WORK6
		LDA	#BANK MPCHBF
		STA	<WORK2
;// 03.05.31 //		LDA	#LOW MPCHBF
		LDX	#HIGH MPCHBF
		JSR	CHSET
;
		LDY	#C_4O1
		STY	<WORK6
;// 03.05.31 //		LDA	#LOW MPCHBF
		LDX	#HIGH MPCHBF
		JMP	CHSET
;
;
;
;
;;;;;;;;;;;
;;;;;;;;;;;************************************************************************
;;;;;;;;;;;*		Map data buffer set			(MPDTBFST)	*
;;;;;;;;;;;************************************************************************
;;;;;;;;;;MPDTBFST	EQU	$
;;;;;;;;;;		JSR	CHREAD
;;;;;;;;;;		RTL
;;;;;;;;;;;
;
;
;************************************************************************
;*		OBJ. Character data address work set	(CADWKST3)	*
;************************************************************************
CADWKST3	EQU	$
;// 03.05.31 //		LDA	#LOW MPCHBF+600H
		STZ	<WORK0
		LDA	#HIGH MPCHBF+600H
		STA	<WORK1
		LDA	#BANK MPCHBF+600H
		BRA	CADWS40
;
;
;************************************************************************
;*		OBJ. Character data address work set	(CADWKST2)	*
;************************************************************************
CADWKST2	EQU	$
;// 03.05.31 //		LDA	#LOW MPCHBF
		STZ	<WORK0
		LDA	#HIGH MPCHBF
		STA	<WORK1
		LDA	#BANK MPCHBF
CADWS40		EQU	$
		STA	<WORK2
		STA	<WORK5
CADWS300	EQU	$
		LDA	OCADB,Y 
		STA	<CWORK2
		LDA	OCADH,Y
		STA	<CWORK1
		LDA	OCADL,Y
		STA	<CWORK0
		BRA	CHREAD
;
;
;************************************************************************
;*		BG. Character data address work set	(CADWKST0)	*
;************************************************************************
CADWKST0	EQU	$
;// 03.05.31 //		LDA	#LOW MPCHBF
		STZ	<WORK0
		LDA	#HIGH MPCHBF
		STA	<WORK1
		LDA	#BANK MPCHBF
CADWS040	EQU	$
		STA	<WORK2
		STA	<WORK5
CADWS100	EQU	$
		LDA	BCADB,Y 
		STA	<CWORK2
		LDA	BCADH,Y
		STA	<CWORK1
		LDA	BCADL,Y
		STA	<CWORK0
;
;************************************************************************
;*		Character buffer set			(CHRREAD)	*
;*		[in]	(cwork0,1,2)	<-- char. bit    address	*
;*			(work0,1,2)	<-- char. data   address	*
;************************************************************************
CHREAD		EQU	$
		IDX16
		REP	#00010000B	; index 16 bit mode
;
		LDY	#00000H		; (Y) <-- chara data buffer index
GTCODE		EQU	$
		JSR	GET1DT		; 1 data read
		CMP	#0FFH
		BNE	GTCOD1		; end ?
;					; yes
		SEP	#00010000B	; index 8 bit mode 
		RTS
;
GTCOD1		EQU	$
		STA	<CWORK5
		AND	#0E0H
		CMP	#0E0H
		BEQ	GT2COD		; 2 byte code ?
;					; no
		PHA			; (A) push : data type save
		LDA	<CWORK5
;
		MEM16
		REP	#00100000B	; memory 16 bit mode
;
		AND	#0001FH
		BRA	GT2CD2
;
		MEM8
GT2COD		EQU	$
		LDA	<CWORK5
		ASL	A
		ASL	A
		ASL	A
		AND	#0E0H
		PHA			; (A) push : data type save
		LDA	<CWORK5
		AND	#003H
		XBA
		JSR	GET1DT		; 1 data read
;
		MEM16
		REP	#00100000B	; memory 16 bit mode
GT2CD2		EQU	$
		INC	A
		STA	<CWORK3
;
		MEM8
		SEP	#00100000B	; memory 8 bit mode
GTCDEN		EQU	$
		PLA			; (A) pull : data type load
		BEQ	NORM		; [ CMP #000H ] = ?
;					; no
		BMI	REF		; [ CMP #1xxH ] > ?
;					; no
		ASL	A
		BPL	REN1		; [ CMP #020H ] > ?
;					; no
		ASL	A
		BPL	REN2		; [ CMP #040H ] > ?
;					; no
REN12		EQU	$
		JSR	GET1DT		; 1 data read
		LDX	<CWORK3
REN121		EQU	$
		STA	[<WORK],Y
		INC	A
		INY
		DEX
		BNE	REN121		; end ?
;					; yes
		BRA	GTCODE
;
NORM		EQU	$
		JSR	GET1DT		; 1 data read
		STA	[<WORK],Y
		INY
		LDX	<CWORK3
		DEX
		STX	<CWORK3
		BNE	NORM		; end ?
;					; yes
		BRA	GTCODE
;
REN1		EQU	$
		JSR	GET1DT		; 1 data read
		LDX	<CWORK3
REN11		EQU	$
		STA	[<WORK],Y
		INY
		DEX
		BNE	REN11		; end ?
;					; yes
		BRA	GTCODE
;
REN2		EQU	$
		JSR	GET1DT		; 1 data read
		XBA
		JSR	GET1DT		; 1 data read
		LDX	<CWORK3
REN21		EQU	$
		XBA
		STA	[<WORK],Y
		INY
		DEX
		BEQ	REN22		; end ?
;					; no
		XBA
		STA	[<WORK],Y
		INY
		DEX
		BNE	REN21 
REN22		EQU	$
		JMP	GTCODE
;
REF		EQU	$
		JSR	GET1DT		; 1 data read
		XBA
		JSR	GET1DT		; 1 data read
		XBA		; /03.07.30/ test //
		TAX
REF1		EQU	$
		PHY
		TXY
		LDA	[<WORK],Y
		TYX
		PLY
		STA	[<WORK],Y
		INY
		INX
;
		MEM16
		REP	#00100000B	; memory 16 bit mode 
;
		DEC	<CWORK3
;
		MEM8
		SEP	#00100000B	; memory 8 bit mode
;
		BNE	REF1		; end ?
;					; yes
		JMP	GTCODE
;
GET1DT		EQU	$
		LDA	[<CWORK0]
		LDX	<CWORK0
		INX
		BNE	GT1DT1		; (c) on ?
;					; yes
		LDX	#08000H
		INC	<CWORK2
GT1DT1		EQU	$
		STX	<CWORK0
		RTS
;
;
;
;
;
;
;
; 
		END
