;
         	INCLUDE	zel_ram.asm
;
;--------------------------------------------------------------------
;
;		ZELDA-3		1991.04.16(TUE)
;
;--------------------------------------------------------------------
;
;;;;			ORG		0AC00H
		ORG	068000H
;
;=============================================== (zel_enmy) =========
		GLB	EPXYCK2,EPXCHK2,EPYCHK2,PSSAVE2,BOMBST,SINDT2
;
		GLB	ENEMY,BGDTRD2,EXBCHK2,OAMCHKL,ENMAINL
		GLB	ENDMST,ENDMST2,ENCRST2
		GLB	ITMGET,CRENPL2L,PSERC2L,PKNCRS2,CRENPL3L
		GLB	CROJCK2,EINIT,EMOVE,EICE,EFAIL,ECACH 
		GLB	ALENDM,KATOBJ,KUSAST,CRTLCK,ESERCHL,EBAKU
		GLB	ENBGCKL,CRENPLL,CRKNKNL,CRKNENL,OCHECKL,ALOMCKL
		GLB	SADWSTL,SADWS2L,PSERCHL,EN1CSTL,EFLSST,CACHCKL,ENBDSBL
		GLB	EN1CSSL,ENDMST3,EHOLE,BIKRST2,PLFLSTL,ENMOVE2,ENDMST4
		GLB	EFLSST2,EN12CSL,EEXYCKL,FILSETL,ITGSDT,ENFLIS2
;--- enmyno --
		GLB	SKHED,ZOOL2,PENGI,BARI1,KARAS,HAGE0,DARUM
		GLB	OCTA1,OCTA2,OCTA3,NYORO,PAKKN,OCTBL,OCTSS
		GLB	HINO0,BUTA0,PLHIN,TARUV,GAYK0,GAYK1,GAYK2,GAYK3
		GLB	KWAUS,KWAU1,SHIGE,HAYAM,GOST0,KAJIY,SEKZ4,TAAMA
		GLB	SINUB,NAME0,REBA1,LOPAA,ZOOL1,WOOD1,MANY1,IWABO
		GLB	JIJII,BABAA,SLEEP,PENKI,NOKOG,KUTUU,MEIR0,MEIR1
		GLB	NOPPO,PLHIK,ONNAA,HIGEE,MAJOO,PLCHK,KIANA,SAKAS
		GLB	YATAM,DEMON,BOOK0,TKBOY,LINE0,LINE1,LINE2,LINE3,BABA1,ESW02,ESW03
		GLB	ISHI0,BARI0,HEIS0,TEKU0,HYUUU,TAIHO,HEIS1,HEYA0,HEYA1,HEI00
		GLB	HEIS2,OOISU,HEYA2,HEBO0,NEZU0,HEBI0,KOMO0,BEECK
		GLB	MONOR,OYAGI,HEIS3,ZAKO0,SUNA0,USAG0,HANA0,HANA1
		GLB	HEYA3,HESET,NIWAT,ITEMN,DOOOR,TAMA0,DOZOO,TAMS0,TAMS1
		GLB	BOUSI,SYOBY,HELP0,ZORAB,NOMOS,RANEM,ZORAS,SEKMV,BABUL
		GLB	MJSY1,JITON,ESW04,BIGBL,KANI0,TORI0,RISU0,SPARK
		GLB	ZORA2,CHAN0,CHAN1,CHAN2,CHAN3,MEDUS,NL777,ATARS,RIVER
		GLB	ARI00,ARI01,JOHBB,YASAN,HODIR,HODIL,HODID,HODIU,BWAKO
		GLB     MOTS0,MOTS1,HACHI,ENMY3,SHSAI,POLIW,TELSA,SHTAM,BABU2
		GLB	TRAP0,BAAR0,BAAR1,HBTAM,RINGO,BOSET,AMENB,MEDAM,SKELT
		GLB	CHIBI,CHFIR,HELP1,D_0_9,PATAR,PATAM,KAM01,SLIME,SLST0
		GLB	HANDS,HNDST,SKELB,MOTSB,MOTAM,SPARL,BYOYN,AYASI,AYAS0,AYAS1,AYAS2,AYAS3
		GLB	MEMER,MEMEL,MEMED,MEMEU,FISH0,TILST,MAGIC,MGSET,KUROS
		GLB	ICMAN,ICBOS,ICTAM,ICEBG,DOKN0,DOKN1,DOKN2,DOKN3,MEDA2
		GLB	TEKI0,TEKI1,SKEL2,JOHOY,PATA0,PATA1,LIKE0,BEE00
		GLB	SEKBN,TAKAR,BAKDN,SARKK,TEKBB,ENMY4,EYEBS,EYETM,EYEBM
		GLB	NAMAZ,SDEMO,HAYAB,IWAGO,IWAST,AMEBA,Theft,BGBM0,BGBM1
		GLB	IZUMI,SITO0,TEKTA,WANWAN,KAMBS,KAMBR,KAMBB,UZUMK,CTBOS
		GLB	SAMTM,MDARM,GANON,GANO2,RINEL,RYOKI,DOOMO,JFISH,ABATA
		GLB	ANAHO 
;---------
		GLB	ULANI,ESW12,KUROR,KUROD,DACHO,USAGI,OOOMU,SKCHK,SKCH2
;-------------- item

		GLB	HART1,RUPYR,RUPYY,RUPYB,BOMB1,BOMB2,BOMB3
		GLB	TUBO1,TUBO2,PTATE
		GLB	YAAA1,YAAA2,YOSEI,KTOBJ,KAGI0
		GLB	KINOK,SUKAS,UTUWA,UTUBK,KAGI1,SKST0,SKST1,HEBST,BIGKO,BCONT
		GLB	BKFIR,HARI0,MIIRA,YKDW0,YKDW1,BMBST
;--------------
		GLB	EWATR,EICFL
		GLB	ESET0,ESET1,ESET2,NOMCT
		GLB	BSSTXD,BSSTYD
;=============================================== (zel_enmy2) =========
		EXT	EVCHCKE,ENXSDN,ENYSDN,ENMSG2L,ENMSGEL,ENMSGSL
		EXT	SETOAML,SETOAML2,ENMKIST,MKCK16,BSITEM,EFLCHK
		EXT	SETOAML22,ENSDMV
;--------------
		EXT	NOPPOMV,PLHIKMV,ONNAAIT,ONNAAMV,HIGEEMV,MAJOOMV
		EXT	PLCHKMV,KIANAMV,DEMONMV,BOOK0MV,HIGEEIT
		EXT	TKBOYMV,LINE0MV,LINE0IT,ESW02MV
		EXT	BABA1MV,BABA1IT,RANEMIT,JITONIT,JITONMV
		EXT	BARI0MV,HEIS0MV
		EXT	BRSDRS
;		EXT	PSW01IT,PSW01MV,PSW02IT,PSW02MV
;		EXT	PINT1IT,PINT1MV,MONORIT,MONORMV
		EXT	MONORIT,MONORMV
		EXT	OYAGIMV,OYAGIIT,YASANIT
		EXT	BOUSIIT,BOUSIMV,SYOBYIT,SYOBYMV,HELP0IT,HELP0MV
		EXT	KINOKIT,KINOKMV,SUKASIT,SUKASMV,MJSY1IT,MJSY1MV
		EXT	UTUWAIT,UTUWAMV,JOHBBIT,JOHBBMV,MSGSET
		EXT	UTUBKIT,UTUBKMV,SITO2ST,PLHINMV
;- DATA -
		EXT	KOMXSD,KOMYSD
;=============================================== (zel_enmy3) =========
		EXT	YOSEIMJ,ENMY3MV,ENFIRE
		EXT	POLIWCG,BABU2IT
		EXT	HELP1IT,PATAMCTL,BINCHKL
		EXT	ICEFLST,MOTSBIT
		EXT	ENPLATR
		EXT	SMM10ST
		EXT	SMM10,SMM20,SMM30,SMM40,SMM50,SMM60,SMM70
;=============================================== (zel_enmy5) =========
		EXT	OOTSUCK,GRITMCK
;=============================================== (zel_enmy4) =========
		EXT	HAYABIT,WANWANITJ,KAMBSIT,CTBOSIT,MDARMIT,GANONIT,HAYAMIT
		EXT	ENMY4MV,EYEBSIT,ENMYSV,KARASMV,HAGE0MV,SDEMOIT,HAYABMV,HAYAMCS
		EXT	BABULCSL,ENTUCKL,BGCRDT,ENIDSH,ENIDSH2,BLTSUB,DBUGSB
		EXT	WOOD1MV,WOEYEST
;=============================================== (zel_endt) =========
		EXT	EXSTRA,ENEMY2,ENBTON,ENIDPS,ENCLER
		EXT	ENEMY20
		EXT	MEIR0MV,MEIR1MV,ULANIMV,PENKIMV
		EXT	JIJIIMV,BABAAMV,NOKOGMV
;
		EXT	KSFL
;=============================================== (zel_end2) =========
                EXT     ENMDD0,ENMDD1,ENMDD2,ENMDD3,ENMDD4,ENMDD5,ENMDD6,ENMDD7
		EXT	ENRMCL.ENCLST,ENMDST,RNDSET
                EXT     OAMENT,OAMENT2,OAMENT3
                EXT     OAMENT1,OAMENT4,OAMENT5,OAMENT6
                EXT     ATCKDT
                EXT     SDLRCE,SDLRCP,SDLRE1,SDLRE2,SDLRE3
                EXT     KUTUUCS,KUTU1CS,ULANIST,SINUBCS
;=============================================== (zel_bgwt) =========
;=============================================== (zel_main) =========
		EXT	JSRSUB,MGMCGRS2,GDCHCK 
;
		EXT	MD_title,MD_djint,MD_djply,MD_gdint,MD_gdply
		EXT	MD_fdout,MD_fdin,MD_etcpl
		EXT	MD_wpout,MD_wpin
;=============================================== (zel_play) =========
		EXT 	EATSET,OPTNMV,DASHON,DASCLR1,PLYCLR1
		EXT 	TKNAG,TKGINT,ATMSIT,PLOTCK
		EXT 	TAKVMAD,ITMCBFST,TAKASBD,TAKAATR,MCNINT
		EXT 	WPMSCK
;///////		EXT	RDCHCK
;=============================================== (INIT) =========
		EXT	p1_tmyk
;=============================================== (zel_bg3) =========
		EXT	MTRSUB,ITEM0ST
		EXT	BOMBMAP,BOMBMAX,YAAAMAP,YAAAMAX
;================================================(CHAR)====================
		EXT	PWTRCGS2,PWTRCGS3,ITMCBFST,PWTRCGS1,PWTRCGS0
;================================================(COMN)====================
		EXT	MGMCGRS0,MGMCGRS1,MGMCGCNG,ICECGRST
;================================================(exst)====================
		EXT	RAOPIT,RAOPIT1,hnoji,OPTCBFST,ENALFL,WAPMV,KNBMCLR
;================================================(endt)====================
		EXT 	GRENST,EST0SB,KTCRDT,ENBAKU
		EXT	nashi,prnce,jjmov,jjwat,jjsmv,mesmv,prnc1,kajy1
		EXT	kajya,hnoji,monky,monwt,takar,bakud
;================================================(polygon)=================
;-----< obj_poly >-------------------------------------------------------

		extern		INITIAL_POLYGON

;------------------------------------------------------------------------
		extern		polygon_flag
		extern		shading_switch
		extern		object_size
		extern		object_type
		extern		rotate_angle_x
		extern		rotate_angle_y
		extern		center_point_x
		extern		center_point_y
		extern		center_point_z
		extern		stack_pointer
		extern		transfer_flag

;
;================================================(msge)=================
;---------------MSGE NO.-----------------
		EXT	MS_0000,MS_0001,MS_0002,MS_0003,MS_0004,MS_0005,MS_0006,MS_0007
		EXT	MS_0008,MS_0009,MS_000A,MS_000B,MS_000C,MS_000D,MS_000E,MS_000F
		EXT	MS_0010,MS_0011,MS_0012,MS_0013,MS_0014,MS_0015,MS_0016,MS_0017
		EXT	MS_0018,MS_0019,MS_001A,MS_001B,MS_001C,MS_001D,MS_001E,MS_001F
		EXT	MS_0020,MS_0021,MS_0022,MS_0023,MS_0024,MS_0025,MS_0026,MS_0027
		EXT	MS_0028,MS_0029,MS_002A,MS_002B,MS_002C,MS_002D,MS_002E,MS_002F
		EXT	MS_0030,MS_0031,MS_0032,MS_0033,MS_0034,MS_0035,MS_0036,MS_0037
		EXT	MS_0038,MS_0039,MS_003A,MS_003B,MS_003C,MS_003D,MS_003E,MS_003F
		EXT	MS_0040,MS_0041,MS_0042,MS_0043,MS_0044,MS_0045,MS_0046,MS_0047
		EXT	MS_0048,MS_0049,MS_004A,MS_004B,MS_004C,MS_004D,MS_004E,MS_004F
		EXT	MS_0050,MS_0051,MS_0052,MS_0053,MS_0054,MS_0055,MS_0056,MS_0057
		EXT	MS_0058,MS_0059,MS_005A,MS_005B,MS_005C,MS_005D,MS_005E,MS_005F
		EXT	MS_0060,MS_0061,MS_0062,MS_0063,MS_0064,MS_0065,MS_0066,MS_0067
		EXT	MS_0068,MS_0069,MS_006A,MS_006B,MS_006C,MS_006D,MS_006E,MS_006F
		EXT	MS_0070,MS_0071,MS_0072,MS_0073,MS_0074,MS_0075,MS_0076,MS_0077
		EXT	MS_0078,MS_0079,MS_007A,MS_007B,MS_007C,MS_007D,MS_007E,MS_007F
		EXT	MS_0080,MS_0081,MS_0082,MS_0083,MS_0084,MS_0085,MS_0086,MS_0087
		EXT	MS_0088,MS_0089,MS_008A,MS_008B,MS_008C,MS_008D,MS_008E,MS_008F
		EXT	MS_0090,MS_0091,MS_0092,MS_0093,MS_0094,MS_0095,MS_0096,MS_0097
		EXT	MS_0098,MS_0099,MS_009A,MS_009B,MS_009C,MS_009D,MS_009E,MS_009F
		EXT	MS_00A0,MS_00A1,MS_00A2,MS_00A3,MS_00A4,MS_00A5,MS_00A6,MS_00A7
		EXT	MS_00A8,MS_00A9,MS_00AA,MS_00AB,MS_00AC,MS_00AD,MS_00AE,MS_00AF
		EXT	MS_00B0,MS_00B1,MS_00B2,MS_00B3,MS_00B4,MS_00B5,MS_00B6,MS_00B7
		EXT	MS_00B8,MS_00B9,MS_00BA,MS_00BB,MS_00BC,MS_00BD,MS_00BE,MS_00BF
		EXT	MS_00C0,MS_00C1,MS_00C2,MS_00C3,MS_00C4,MS_00C5,MS_00C6,MS_00C7
		EXT	MS_00C8,MS_00C9,MS_00CA,MS_00CB,MS_00CC,MS_00CD,MS_00CE,MS_00CF
		EXT	MS_00D0,MS_00D1,MS_00D2,MS_00D3,MS_00D4,MS_00D5,MS_00D6,MS_00D7
		EXT	MS_00D8,MS_00D9,MS_00DA,MS_00DB,MS_00DC,MS_00DD,MS_00DE,MS_00DF
		EXT	MS_00E0,MS_00E1,MS_00E2,MS_00E3,MS_00E4,MS_00E5,MS_00E6,MS_00E7
		EXT	MS_00E8,MS_00E9,MS_00EA,MS_00EB,MS_00EC,MS_00ED,MS_00EE,MS_00EF
		EXT	MS_00F0,MS_00F1,MS_00F2,MS_00F3,MS_00F4,MS_00F5,MS_00F6,MS_00F7
		EXT	MS_00F8,MS_00F9,MS_00FA,MS_00FB,MS_00FC,MS_00FD,MS_00FE,MS_00FF
;
		EXT	MS_0100,MS_0101,MS_0102,MS_0103,MS_0104,MS_0105,MS_0106,MS_0107
		EXT	MS_0108,MS_0109,MS_010A,MS_010B,MS_010C,MS_010D,MS_010E,MS_010F
		EXT	MS_0110,MS_0111,MS_0112,MS_0113,MS_0114,MS_0115,MS_0116,MS_0117
		EXT	MS_0118,MS_0119,MS_011A,MS_011B,MS_011C,MS_011D,MS_011E,MS_011F
		EXT	MS_0120,MS_0121,MS_0122,MS_0123,MS_0124,MS_0125,MS_0126,MS_0127
		EXT	MS_0128,MS_0129,MS_012A,MS_012B,MS_012C,MS_012D,MS_012E,MS_012F
		EXT	MS_0130,MS_0131,MS_0132,MS_0133,MS_0134,MS_0135,MS_0136,MS_0137
		EXT	MS_0138,MS_0139,MS_013A,MS_013B,MS_013C,MS_013D,MS_013E,MS_013F
		EXT	MS_0140,MS_0141,MS_0142,MS_0143,MS_0144,MS_0145,MS_0146,MS_0147
		EXT	MS_0148,MS_0149,MS_014A,MS_014B,MS_014C,MS_014D,MS_014E,MS_014F
		EXT	MS_0150,MS_0151,MS_0152,MS_0153,MS_0154,MS_0155,MS_0156,MS_0157
		EXT	MS_0158,MS_0159,MS_015A,MS_015B,MS_015C,MS_015D,MS_015E,MS_015F
		EXT	MS_0160,MS_0161,MS_0162,MS_0163,MS_0164,MS_0165,MS_0166,MS_0167
		EXT	MS_0168,MS_0169,MS_016A,MS_016B,MS_016C,MS_016D,MS_016E,MS_016F
		EXT	MS_0170,MS_0171,MS_0172,MS_0173,MS_0174,MS_0175,MS_0176,MS_0177
		EXT	MS_0178,MS_0179,MS_017A,MS_017B,MS_017C,MS_017D,MS_017E,MS_017F
		EXT	MS_0180,MS_0181,MS_0182,MS_0183,MS_0184,MS_0185,MS_0186,MS_0187
		EXT	MS_0188,MS_0189,MS_018A,MS_018B,MS_018C,MS_018D,MS_018E,MS_018F
		EXT	MS_0190,MS_0191,MS_0192,MS_0193,MS_0194,MS_0195,MS_0196,MS_0197
		EXT	MS_0198,MS_0199,MS_019A,MS_019B,MS_019C,MS_019D,MS_019E,MS_019F
		EXT	MS_01A0,MS_01A1,MS_01A2,MS_01A3,MS_01A4,MS_01A5,MS_01A6,MS_01A7
		EXT	MS_01A8,MS_01A9,MS_01AA,MS_01AB,MS_01AC,MS_01AD,MS_01AE,MS_01AF
		EXT	MS_01B0,MS_01B1,MS_01B2,MS_01B3,MS_01B4,MS_01B5,MS_01B6,MS_01B7
		EXT	MS_01B8,MS_01B9,MS_01BA,MS_01BB,MS_01BC,MS_01BD,MS_01BE,MS_01BF
		EXT	MS_01C0,MS_01C1,MS_01C2,MS_01C3,MS_01C4,MS_01C5,MS_01C6,MS_01C7
		EXT	MS_01C8,MS_01C9,MS_01CA,MS_01CB,MS_01CC,MS_01CD,MS_01CE,MS_01CF
		EXT	MS_01D0,MS_01D1,MS_01D2,MS_01D3,MS_01D4,MS_01D5,MS_01D6,MS_01D7
		EXT	MS_01D8,MS_01D9,MS_01DA,MS_01DB,MS_01DC,MS_01DD,MS_01DE,MS_01DF
		EXT	MS_01E0,MS_01E1,MS_01E2,MS_01E3,MS_01E4,MS_01E5,MS_01E6,MS_01E7
		EXT	MS_01E8,MS_01E9,MS_01EA,MS_01EB,MS_01EC,MS_01ED,MS_01EE,MS_01EF
		EXT	MS_01F0,MS_01F1,MS_01F2,MS_01F3,MS_01F4,MS_01F5,MS_01F6,MS_01F7
		EXT	MS_01F8,MS_01F9,MS_01FA,MS_01FB,MS_01FC,MS_01FD,MS_01FE,MS_01FF
;
		EXT	MS_0200,MS_0201,MS_0202,MS_0203,MS_0204,MS_0205,MS_0206,MS_0207
		EXT	MS_0208,MS_0209,MS_020A,MS_020B,MS_020C,MS_020D,MS_020E,MS_020F
		EXT	MS_0210,MS_0211,MS_0212,MS_0213,MS_0214,MS_0215,MS_0216,MS_0217
		EXT	MS_0218,MS_0219,MS_021A,MS_021B,MS_021C,MS_021D,MS_021E,MS_021F
		EXT	MS_0220,MS_0221,MS_0222,MS_0223,MS_0224,MS_0225,MS_0226,MS_0227
		EXT	MS_0228,MS_0229,MS_022A,MS_022B,MS_022C,MS_022D,MS_022E,MS_022F
		EXT	MS_0230,MS_0231,MS_0232,MS_0233,MS_0234,MS_0235,MS_0236,MS_0237
		EXT	MS_0238,MS_0239,MS_023A,MS_023B,MS_023C,MS_023D,MS_023E,MS_023F
		EXT	MS_0240,MS_0241,MS_0242,MS_0243,MS_0244,MS_0245,MS_0246,MS_0247
		EXT	MS_0248,MS_0249,MS_024A,MS_024B,MS_024C,MS_024D,MS_024E,MS_024F
		EXT	MS_0250,MS_0251,MS_0252,MS_0253,MS_0254,MS_0255,MS_0256,MS_0257
		EXT	MS_0258,MS_0259,MS_025A,MS_025B,MS_025C,MS_025D,MS_025E,MS_025F
		EXT	MS_0260,MS_0261,MS_0262,MS_0263,MS_0264,MS_0265,MS_0266,MS_0267
		EXT	MS_0268,MS_0269,MS_026A,MS_026B,MS_026C,MS_026D,MS_026E,MS_026F
		EXT	MS_0270,MS_0271,MS_0272,MS_0273,MS_0274,MS_0275,MS_0276,MS_0277
		EXT	MS_0278,MS_0279,MS_027A,MS_027B,MS_027C,MS_027D,MS_027E,MS_027F
		EXT	MS_0280,MS_0281,MS_0282,MS_0283,MS_0284,MS_0285,MS_0286,MS_0287
		EXT	MS_0288,MS_0289,MS_028A,MS_028B,MS_028C,MS_028D,MS_028E,MS_028F
		EXT	MS_0290,MS_0291,MS_0292,MS_0293,MS_0294,MS_0295,MS_0296,MS_0297
		EXT	MS_0298,MS_0299,MS_029A,MS_029B,MS_029C,MS_029D,MS_029E,MS_029F
		EXT	MS_02A0,MS_02A1,MS_02A2,MS_02A3,MS_02A4,MS_02A5,MS_02A6,MS_02A7
		EXT	MS_02A8,MS_02A9,MS_02AA,MS_02AB,MS_02AC,MS_02AD,MS_02AE,MS_02AF
		EXT	MS_02B0,MS_02B1,MS_02B2,MS_02B3,MS_02B4,MS_02B5,MS_02B6,MS_02B7
		EXT	MS_02B8,MS_02B9,MS_02BA,MS_02BB,MS_02BC,MS_02BD,MS_02BE,MS_02BF
		EXT	MS_02C0,MS_02C1,MS_02C2,MS_02C3,MS_02C4,MS_02C5,MS_02C6,MS_02C7
		EXT	MS_02C8,MS_02C9,MS_02CA,MS_02CB,MS_02CC,MS_02CD,MS_02CE,MS_02CF
		EXT	MS_02D0,MS_02D1,MS_02D2,MS_02D3,MS_02D4,MS_02D5,MS_02D6,MS_02D7
		EXT	MS_02D8,MS_02D9,MS_02DA,MS_02DB,MS_02DC,MS_02DD,MS_02DE,MS_02DF
		EXT	MS_02E0,MS_02E1,MS_02E2,MS_02E3,MS_02E4,MS_02E5,MS_02E6,MS_02E7
		EXT	MS_02E8,MS_02E9,MS_02EA,MS_02EB,MS_02EC,MS_02ED,MS_02EE,MS_02EF
		EXT	MS_02F0,MS_02F1,MS_02F2,MS_02F3,MS_02F4,MS_02F5,MS_02F6,MS_02F7
		EXT	MS_02F8,MS_02F9,MS_02FA,MS_02FB,MS_02FC,MS_02FD,MS_02FE,MS_02FF
;
		EXT	MS_0300,MS_0301,MS_0302,MS_0303,MS_0304,MS_0305,MS_0306,MS_0307
		EXT	MS_0308,MS_0309,MS_030A,MS_030B,MS_030C,MS_030D,MS_030E,MS_030F
		EXT	MS_0310,MS_0311,MS_0312,MS_0313,MS_0314,MS_0315,MS_0316,MS_0317
		EXT	MS_0318,MS_0319,MS_031A,MS_031B,MS_031C,MS_031D,MS_031E,MS_031F
		EXT	MS_0320,MS_0321,MS_0322,MS_0323,MS_0324,MS_0325,MS_0326,MS_0327
		EXT	MS_0328,MS_0329,MS_032A,MS_032B,MS_032C,MS_032D,MS_032E,MS_032F
		EXT	MS_0330,MS_0331,MS_0332,MS_0333,MS_0334,MS_0335,MS_0336,MS_0337
		EXT	MS_0338,MS_0339,MS_033A,MS_033B,MS_033C,MS_033D,MS_033E,MS_033F
		EXT	MS_0340,MS_0341,MS_0342,MS_0343,MS_0344,MS_0345,MS_0346,MS_0347
		EXT	MS_0348,MS_0349,MS_034A,MS_034B,MS_034C,MS_034D,MS_034E,MS_034F
		EXT	MS_0350,MS_0351,MS_0352,MS_0353,MS_0354,MS_0355,MS_0356,MS_0357
		EXT	MS_0358,MS_0359,MS_035A,MS_035B,MS_035C,MS_035D,MS_035E,MS_035F
		EXT	MS_0360,MS_0361,MS_0362,MS_0363,MS_0364,MS_0365,MS_0366,MS_0367
		EXT	MS_0368,MS_0369,MS_036A,MS_036B,MS_036C,MS_036D,MS_036E,MS_036F
		EXT	MS_0370,MS_0371,MS_0372,MS_0373,MS_0374,MS_0375,MS_0376,MS_0377
		EXT	MS_0378,MS_0379,MS_037A,MS_037B,MS_037C,MS_037D,MS_037E,MS_037F
		EXT	MS_0380,MS_0381,MS_0382,MS_0383,MS_0384,MS_0385,MS_0386,MS_0387
		EXT	MS_0388,MS_0389,MS_038A,MS_038B,MS_038C,MS_038D,MS_038E,MS_038F
		EXT	MS_0390,MS_0391,MS_0392,MS_0393,MS_0394,MS_0395,MS_0396,MS_0397
		EXT	MS_0398,MS_0399,MS_039A,MS_039B,MS_039C,MS_039D,MS_039E,MS_039F
		EXT	MS_03A0,MS_03A1,MS_03A2,MS_03A3,MS_03A4,MS_03A5,MS_03A6,MS_03A7
		EXT	MS_03A8,MS_03A9,MS_03AA,MS_03AB,MS_03AC,MS_03AD,MS_03AE,MS_03AF
		EXT	MS_03B0,MS_03B1,MS_03B2,MS_03B3,MS_03B4,MS_03B5,MS_03B6,MS_03B7
		EXT	MS_03B8,MS_03B9,MS_03BA,MS_03BB,MS_03BC,MS_03BD,MS_03BE,MS_03BF
		EXT	MS_03C0,MS_03C1,MS_03C2,MS_03C3,MS_03C4,MS_03C5,MS_03C6,MS_03C7
		EXT	MS_03C8,MS_03C9,MS_03CA,MS_03CB,MS_03CC,MS_03CD,MS_03CE,MS_03CF
		EXT	MS_03D0,MS_03D1,MS_03D2,MS_03D3,MS_03D4,MS_03D5,MS_03D6,MS_03D7
		EXT	MS_03D8,MS_03D9,MS_03DA,MS_03DB,MS_03DC,MS_03DD,MS_03DE,MS_03DF
		EXT	MS_03E0,MS_03E1,MS_03E2,MS_03E3,MS_03E4,MS_03E5,MS_03E6,MS_03E7
		EXT	MS_03E8,MS_03E9,MS_03EA,MS_03EB,MS_03EC,MS_03ED,MS_03EE,MS_03EF
		EXT	MS_03F0,MS_03F1,MS_03F2,MS_03F3,MS_03F4,MS_03F5,MS_03F6,MS_03F7
		EXT	MS_03F8,MS_03F9,MS_03FA,MS_03FB,MS_03FC,MS_03FD,MS_03FE,MS_03FF
;
		EXT	MS_0400,MS_0401,MS_0402,MS_0403,MS_0404,MS_0405,MS_0406,MS_0407
		EXT	MS_0408,MS_0409,MS_040A,MS_040B,MS_040C,MS_040D,MS_040E,MS_040F
		EXT	MS_0410,MS_0411,MS_0412,MS_0413,MS_0414,MS_0415,MS_0416,MS_0417
		EXT	MS_0418,MS_0419,MS_041A,MS_041B,MS_041C,MS_041D,MS_041E,MS_041F
		EXT	MS_0420,MS_0421,MS_0422,MS_0423,MS_0424,MS_0425,MS_0426,MS_0427
		EXT	MS_0428,MS_0429,MS_042A,MS_042B,MS_042C,MS_042D,MS_042E,MS_042F
		EXT	MS_0430,MS_0431,MS_0432,MS_0433,MS_0434,MS_0435,MS_0436,MS_0437
		EXT	MS_0438,MS_0439,MS_043A,MS_043B,MS_043C,MS_043D,MS_043E,MS_043F
		EXT	MS_0440,MS_0441,MS_0442,MS_0443,MS_0444,MS_0445,MS_0446,MS_0447
		EXT	MS_0448,MS_0449,MS_044A,MS_044B,MS_044C,MS_044D,MS_044E,MS_044F
		EXT	MS_0450,MS_0451,MS_0452,MS_0453,MS_0454,MS_0455,MS_0456,MS_0457
		EXT	MS_0458,MS_0459,MS_045A,MS_045B,MS_045C,MS_045D,MS_045E,MS_045F
		EXT	MS_0460,MS_0461,MS_0462,MS_0463,MS_0464,MS_0465,MS_0466,MS_0467
		EXT	MS_0468,MS_0469,MS_046A,MS_046B,MS_046C,MS_046D,MS_046E,MS_046F
		EXT	MS_0470,MS_0471,MS_0472,MS_0473,MS_0474,MS_0475,MS_0476,MS_0477
		EXT	MS_0478,MS_0479,MS_047A,MS_047B,MS_047C,MS_047D,MS_047E,MS_047F
		EXT	MS_0480,MS_0481,MS_0482,MS_0483,MS_0484,MS_0485,MS_0486,MS_0487
		EXT	MS_0488,MS_0489,MS_048A,MS_048B,MS_048C,MS_048D,MS_048E,MS_048F
		EXT	MS_0490,MS_0491,MS_0492,MS_0493,MS_0494,MS_0495,MS_0496,MS_0497
		EXT	MS_0498,MS_0499,MS_049A,MS_049B,MS_049C,MS_049D,MS_049E,MS_049F
		EXT	MS_04A0,MS_04A1,MS_04A2,MS_04A3,MS_04A4,MS_04A5,MS_04A6,MS_04A7
		EXT	MS_04A8,MS_04A9,MS_04AA,MS_04AB,MS_04AC,MS_04AD,MS_04AE,MS_04AF
		EXT	MS_04B0,MS_04B1,MS_04B2,MS_04B3,MS_04B4,MS_04B5,MS_04B6,MS_04B7
		EXT	MS_04B8,MS_04B9,MS_04BA,MS_04BB,MS_04BC,MS_04BD,MS_04BE,MS_04BF
		EXT	MS_04C0,MS_04C1,MS_04C2,MS_04C3,MS_04C4,MS_04C5,MS_04C6,MS_04C7
		EXT	MS_04C8,MS_04C9,MS_04CA,MS_04CB,MS_04CC,MS_04CD,MS_04CE,MS_04CF
		EXT	MS_04D0,MS_04D1,MS_04D2,MS_04D3,MS_04D4,MS_04D5,MS_04D6,MS_04D7
		EXT	MS_04D8,MS_04D9,MS_04DA,MS_04DB,MS_04DC,MS_04DD,MS_04DE,MS_04DF
		EXT	MS_04E0,MS_04E1,MS_04E2,MS_04E3,MS_04E4,MS_04E5,MS_04E6,MS_04E7
		EXT	MS_04E8,MS_04E9,MS_04EA,MS_04EB,MS_04EC,MS_04ED,MS_04EE,MS_04EF
		EXT	MS_04F0,MS_04F1,MS_04F2,MS_04F3,MS_04F4,MS_04F5,MS_04F6,MS_04F7
		EXT	MS_04F8,MS_04F9,MS_04FA,MS_04FB,MS_04FC,MS_04FD,MS_04FE,MS_04FF
;
		EXT	MS_0500,MS_0501,MS_0502,MS_0503,MS_0504,MS_0505,MS_0506,MS_0507
		EXT	MS_0508,MS_0509,MS_050A,MS_050B,MS_050C,MS_050D,MS_050E,MS_050F
		EXT	MS_0510,MS_0511,MS_0512,MS_0513,MS_0514,MS_0515,MS_0516,MS_0517
		EXT	MS_0518,MS_0519,MS_051A,MS_051B,MS_051C,MS_051D,MS_051E,MS_051F
		EXT	MS_0520,MS_0521,MS_0522,MS_0523,MS_0524,MS_0525,MS_0526,MS_0527
		EXT	MS_0528,MS_0529,MS_052A,MS_052B,MS_052C,MS_052D,MS_052E,MS_052F
		EXT	MS_0530,MS_0531,MS_0532,MS_0533,MS_0534,MS_0535,MS_0536,MS_0537
		EXT	MS_0538,MS_0539,MS_053A,MS_053B,MS_053C,MS_053D,MS_053E,MS_053F
		EXT	MS_0540,MS_0541,MS_0542,MS_0543,MS_0544,MS_0545,MS_0546,MS_0547
		EXT	MS_0548,MS_0549,MS_054A,MS_054B,MS_054C,MS_054D,MS_054E,MS_054F
		EXT	MS_0550,MS_0551,MS_0552,MS_0553,MS_0554,MS_0555,MS_0556,MS_0557
		EXT	MS_0558,MS_0559,MS_055A,MS_055B,MS_055C,MS_055D,MS_055E,MS_055F
		EXT	MS_0560,MS_0561,MS_0562,MS_0563,MS_0564,MS_0565,MS_0566,MS_0567
		EXT	MS_0568,MS_0569,MS_056A,MS_056B,MS_056C,MS_056D,MS_056E,MS_056F
		EXT	MS_0570,MS_0571,MS_0572,MS_0573,MS_0574,MS_0575,MS_0576,MS_0577
		EXT	MS_0578,MS_0579,MS_057A,MS_057B,MS_057C,MS_057D,MS_057E,MS_057F
		EXT	MS_0580,MS_0581,MS_0582,MS_0583,MS_0584,MS_0585,MS_0586,MS_0587
		EXT	MS_0588,MS_0589,MS_058A,MS_058B,MS_058C,MS_058D,MS_058E,MS_058F
		EXT	MS_0590,MS_0591,MS_0592,MS_0593,MS_0594,MS_0595,MS_0596,MS_0597
		EXT	MS_0598,MS_0599,MS_059A,MS_059B,MS_059C,MS_059D,MS_059E,MS_059F
		EXT	MS_05A0,MS_05A1,MS_05A2,MS_05A3,MS_05A4,MS_05A5,MS_05A6,MS_05A7
		EXT	MS_05A8,MS_05A9,MS_05AA,MS_05AB,MS_05AC,MS_05AD,MS_05AE,MS_05AF
		EXT	MS_05B0,MS_05B1,MS_05B2,MS_05B3,MS_05B4,MS_05B5,MS_05B6,MS_05B7
		EXT	MS_05B8,MS_05B9,MS_05BA,MS_05BB,MS_05BC,MS_05BD,MS_05BE,MS_05BF
		EXT	MS_05C0,MS_05C1,MS_05C2,MS_05C3,MS_05C4,MS_05C5,MS_05C6,MS_05C7
		EXT	MS_05C8,MS_05C9,MS_05CA,MS_05CB,MS_05CC,MS_05CD,MS_05CE,MS_05CF
		EXT	MS_05D0,MS_05D1,MS_05D2,MS_05D3,MS_05D4,MS_05D5,MS_05D6,MS_05D7
		EXT	MS_05D8,MS_05D9,MS_05DA,MS_05DB,MS_05DC,MS_05DD,MS_05DE,MS_05DF
		EXT	MS_05E0,MS_05E1,MS_05E2,MS_05E3,MS_05E4,MS_05E5,MS_05E6,MS_05E7
		EXT	MS_05E8,MS_05E9,MS_05EA,MS_05EB,MS_05EC,MS_05ED,MS_05EE,MS_05EF
		EXT	MS_05F0,MS_05F1,MS_05F2,MS_05F3,MS_05F4,MS_05F5,MS_05F6,MS_05F7
		EXT	MS_05F8,MS_05F9,MS_05FA,MS_05FB,MS_05FC,MS_05FD,MS_05FE,MS_05FF
;
;================================================(exst)====================
                EXT     BEAM1,BEAM2,BUME1,BOMBM,YAMOV,DTMOV     ;;;;,BOMBR
                EXT     DTMV1,DTMV2,OPMOV,WTMV0,HIBA2,SCPMV,DTMV3
		EXT	BMCRDT
;====================================================================
;
		EXTEND
;
;
;- - - - - - - - - - - - 
;HPW03		EQU	04H/2   		; Hanekairi power !
;HPW05		EQU	08H/2   		; Hanekairi power !
;HPW10		EQU	10H/2
;HPW15		EQU	18H/2   		; Hanekairi power !
;HPW20		EQU	20H/2
;HPW30		EQU	30H/2
HPW03		EQU	04H   		; Hanekairi power !
HPW05		EQU	08H   		; Hanekairi power !
HPW10		EQU	10H
HPW15		EQU	18H   		; Hanekairi power !
HPW20		EQU	20H
HPW30		EQU	30H
HPW40		EQU	40H
HPW60		EQU	60H-10H
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
;-Enemy no. - - - - - - - - - - - 
TARUV           EQU	017H	; NO USE (DAMMY)
KWAUS		EQU	019H
KWAU1		EQU	01AH
MANY1		EQU	029H
;==================================
KARAS		EQU	000H
HAGE0		EQU	001H
SKHED		EQU	002H
;;;;;		EQU	003H	; swich !
ESW02		EQU	004H	; swich shita only pull !
ESW03		EQU	005H	; swich ue  pull !
ESW12		EQU	006H	; swich shita hazure !
ESW04		EQU	007H	; swich ue  pull  2
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
;- ground -
OCTA1		EQU	008H
OCTA2		EQU	009H
HAYAB		EQU	009H	; Sorry..
OCTA3		EQU	00AH
NIWAT		EQU	00BH
OCTAM		EQU	00CH
NYORO		EQU	00DH
PAKKN		EQU	00EH
OCTBL           EQU	00FH
OCTSS           EQU	010H
HINO0           EQU	011H
BUTA0           EQU	012H
MOTS1           EQU	013H    ;sorry
PLHIN           EQU	014H
BABUL		EQU	015H	;sorry...
JITON		EQU	016H	;sorry...
SHIGE		EQU	017H
HAYAM		EQU	018H	
GOST0		EQU	019H	
KAJIY		EQU	01AH
YATAM		EQU	01BH
SEKZ4		EQU	01CH
BEECK		EQU	01DH
TAAMA		EQU	01EH
SINUB		EQU	01FH
NAME0		EQU	020H	;       
REBA1		EQU	021H	;reba
LOPAA		EQU	022H
ZOOL1		EQU	023H
ZOOL2		EQU	024H
WOOD1		EQU	025H
MOTS0		EQU	026H	;sorry
IWABO		EQU	027H	        
JOHOY		EQU	028H
JIJII		EQU	029H
BABAA		EQU	02AH
SLEEP		EQU	02BH
NOKOG		EQU	02CH
PENKI		EQU	02DH
KUTUU		EQU	02EH
MEIR0		EQU	02FH	
MEIR1		EQU	030H	
ULANI		EQU	031H
NOPPO		EQU	032H
PLHIK		EQU	033H
ONNAA		EQU	034H
HIGEE		EQU	035H
MAJOO		EQU	036H
PLCHK		EQU	037H
KIANA		EQU	038H
SAKAS		EQU	039H
DEMON		EQU	03AH
BOOK0		EQU	03BH
TKBOY		EQU	03CH
BABA1		EQU	03DH
ISHI0		EQU	03EH
BARI0		EQU	03FH
BARI1		EQU	040H
HEIS0		EQU	041H
HEI00		EQU	042H
HEIS1		EQU	043H
HEIS2		EQU	044H
HEIS3		EQU	045H
HEYA0		EQU	046H
HEYA1		EQU	047H
HEYA2		EQU	048H
HEYA3		EQU	049H
HEBO0		EQU	04AH
ZAKO0		EQU	04BH
SUNA0		EQU	04CH
USAG0		EQU	04DH
HANA0		EQU	04EH
HANA1		EQU	04FH
TAMA0		EQU	050H
DOZOO		EQU	051H
ZORAB		EQU	052H
NOMOS		EQU	053H
RANEM		EQU	054H
ZORAS		EQU	055H
ZORA2		EQU	056H
SEKMV		EQU	057H
KANI0		EQU	058H
TORI0		EQU	059H
RISU0		EQU	05AH
SPARK		EQU	05BH
SPARL		EQU	05CH
CHAN0		EQU	05DH
CHAN1		EQU	05EH
CHAN2		EQU	05FH
CHAN3		EQU	060H
MEDUS		EQU	061H
NL777		EQU	MEDUS
ATARS		EQU	062H
ARI00		EQU	063H
ARI01		EQU	064H
YASAN		EQU	065H
HODIR		EQU	066H
HODIL		EQU	067H
HODID		EQU	068H
HODIU		EQU	069H
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
TEKU0		EQU	06AH
TAIHO		EQU	06BH
HYUUU		EQU	06CH
NEZU0		EQU	06DH
HEBI0		EQU	06EH
KOMO0		EQU	06FH
MOTAM		EQU	070H
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
RIVER		EQU	071H
BWAKO		EQU	072H
OYAGI		EQU	073H
BOUSI		EQU	074H
SYOBY		EQU	075H
HELP0		EQU	076H
BIGBL		EQU	077H
JOHBB		EQU	078H
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - - - - -
;- - - - - - - - - -
ENMY3		EQU	079H
HACHI		EQU	ENMY3
SHSAI		EQU	07AH   
SHTAM		EQU	07BH   
TELSA		EQU	07CH   
TRAP0		EQU	07DH   
BAAR0		EQU	07EH   
BAAR1		EQU	07FH   
HBTAM		EQU	080H   
AMENB		EQU	081H   
BABU2		EQU	082H   
MEDAM		EQU	083H   
MEDA2		EQU	084H   
SKELT		EQU	085H   
CHIBI		EQU	086H
CHFIR		EQU	087H
BIGKO		EQU	088H
BKFIR		EQU	089H
HARI0		EQU	08AH
MIIRA		EQU	08BH
PATAR		EQU	08CH
PATAM		EQU	08DH
KAM01		EQU	08EH
SLIME		EQU	08FH
HANDS		EQU	090H
SKELB		EQU	091H
MOTSB		EQU	092H
BYOYN		EQU	093H
AYASI		EQU	094H
MEMER		EQU	095H
MEMEL		EQU	096H
MEMED		EQU	097H
MEMEU		EQU	098H
PENGI		EQU	099H
FISH0		EQU	09AH
MAGIC		EQU	09BH
KUROR		EQU	09CH
KUROD		EQU	09DH
DACHO		EQU	09EH
USAGI		EQU	09FH
OOOMU		EQU	0A0H
ICMAN		EQU	0A1H
ICBOS		EQU	0A2H
ICEBG		EQU	0A3H
ICTAM		EQU	0A4H
TEKI0		EQU	0A5H
TEKI1		EQU	0A6H
SKEL2		EQU	0A7H
PATA0		EQU	0A8H
PATA1		EQU	0A9H
LIKE0		EQU	0AAH
POLIW		EQU	0ABH   
RINGO		EQU	0ACH   
HELP1		EQU	0ADH   
DOKN0		EQU	0AEH   
DOKN1		EQU	0AFH   
DOKN2		EQU	0B0H   
DOKN3		EQU	0B1H   
BEE00		EQU	0B2H
SEKBN		EQU	0B3H
TAKAR		EQU	0B4H
BAKDN		EQU	0B5H
SARKK		EQU	0B6H
TEKBB		EQU	0B7H
D_0_9		EQU	0B8H
SITO0		EQU	0B9H
UZUMK		EQU	0BAH
SAMTM		EQU	0BBH
RYOKI		EQU	0BCH
;---------------------------------------   
ENMY4		EQU	0BDH
EYEBS		EQU	0BDH
EYETM		EQU	0BEH
EYEBM		EQU	0BFH
NAMAZ		EQU	0C0H
SDEMO		EQU	0C1H
IWAGO		EQU	0C2H
AMEBA		EQU	0C3H
Theft		EQU	0C4H
BGBM0		EQU	0C5H
BGBM1		EQU	0C6H
DARUM		EQU	0C7H
IZUMI		EQU	0C8H
TEKTA		EQU	0C9H
WANWAN		EQU	0CAH
KAMBS		EQU	0CBH
KAMBR		EQU	0CCH
KAMBB		EQU	0CDH
CTBOS		EQU	0CEH
MDARM		EQU	0CFH
RINEL		EQU	0D0H
DOOMO		EQU	0D1H
JFISH		EQU	0D2H
ABATA		EQU	0D3H
ANAHO		EQU	0D4H
GANON		EQU	0D5H
GANO2		EQU	0D6H
;--- not enemy --- item ---
ITEMD		EQU	0D7H   
HART1		EQU	ITEMD+000H
BOSET		EQU	HART1		; Sorry ....
RUPYR		EQU	ITEMD+001H
RUPYY		EQU	ITEMD+002H
RUPYB		EQU	ITEMD+003H
BOMB1		EQU	ITEMD+004H
BOMB2		EQU	ITEMD+005H
BOMB3		EQU	ITEMD+006H
;;;NIKU1		EQU	ITEMD+007H
;;;NIKU2		EQU	ITEMD+008H
;;;OPTN1		EQU	ITEMD+009H
TUBO1		EQU	ITEMD+007H
TUBO2		EQU	ITEMD+008H
;;;CRYS1		EQU	ITEMD+00CH
;;;TRYFR		EQU	ITEMD+00DH
;;;TRYFY		EQU	ITEMD+00EH
;;;TRYFB		EQU	ITEMD+00FH
;;;SPESR		EQU	ITEMD+010H
;;;SPESY		EQU	ITEMD+011H
;;;SPESB		EQU	ITEMD+012H
YAAA1		EQU	ITEMD+009H
YAAA2		EQU	ITEMD+00AH
YOSEI		EQU	ITEMD+00BH
KAGI0		EQU	ITEMD+00CH
KAGI1		EQU	ITEMD+00DH
PTATE		EQU	ITEMD+00EH
KINOK		EQU	ITEMD+00FH
SUKAS		EQU	ITEMD+010H
MJSY1		EQU	ITEMD+011H
UTUWA		EQU	ITEMD+012H
UTUBK		EQU	ITEMD+013H
ITEMN		EQU	UTUBK+1
;== BG->OBJ ====
KTOBJ		EQU	ITEMN 
;-- line move -- 
LINE0		EQU	KTOBJ+1
OOISU		EQU	LINE0+1
LINE1		EQU	OOISU+1
LINE2		EQU	LINE1+1
LINE3		EQU	LINE2+1
MONOR		EQU	LINE3+1
;-- enemy set position in -- Ground -
DOOOR		EQU	MONOR+1
IWAST		EQU	DOOOR+1
;-- enemy set position in -- Danjyon -
ESET0		EQU	02H 	; 1:DOOOR
TAMS0		EQU	ESET0 
TAMS1		EQU	TAMS0+1
SKST0		EQU	TAMS1+1
SKST1		EQU	SKST0+1
HEBST		EQU	SKST1+1
BCONT		EQU	HEBST+1
SLST0		EQU	BCONT+1
HNDST		EQU	SLST0+1
YKDW0		EQU	HNDST+1
YKDW1		EQU	YKDW0+1
GAYK0		EQU	YKDW1+1
GAYK1		EQU	GAYK0+1
GAYK2		EQU	GAYK1+1
GAYK3		EQU	GAYK2+1
AYAS0		EQU	GAYK3+1
AYAS1		EQU	AYAS0+1
AYAS2		EQU	AYAS1+1
AYAS3		EQU	AYAS2+1
TILST		EQU	AYAS3+1
MGSET		EQU	TILST+1
KUROS		EQU	MGSET+1
SKCHK		EQU	KUROS+1
SKCH2		EQU	SKCHK+1
NOMCT		EQU	SKCH2+1
BMBST		EQU	NOMCT+1
;
;NOT USE !
ESET1		EQU	ESET0+1
ESET2		EQU	ESET1+1
HESET		EQU	ESET2+1
;-----------------------------------
RUPY1		EQU	RUPYR
RUPY5		EQU	RUPYY
RUPYO		EQU	RUPYB
		MEM8
		IDX8
;============================================
CTLXAL		EQU	$
		BYTE	0E0H,0E0H,0E0H,010H
CTLXAH		EQU	$
		BYTE	0FFH,0FFH,0FFH,000H
CTLYAL		EQU	$
		BYTE	0E0H,020H,0E8H,0E8H
CTLYAH		EQU	$
		BYTE	0FFH,000H,0FFH,0FFH
CTLXAD		EQU	$
		BYTE	050H,050H,020H,020H
CTLYAD		EQU	$
		BYTE	020H,020H,050H,050H
;- - - - - - - - - - - - - - - - - - - - -
CRTLCK		EQU	$	; player tilt item hit check !
		PHB
		PHK
		PLB
		LDA	<PLMKCH
		LSR	A
		TAY
		LDA	<PLXPS1
		CLC
		ADC	CTLXAL,Y
		STA	<WORK0
		LDA	<PLXPS0
		ADC	CTLXAH,Y
		STA	<WORK8
		LDA	<PLYPS1
;;		CLC
		ADC	CTLYAL,Y
		STA	<WORK1
		LDA	<PLYPS0
		ADC	CTLYAH,Y
		STA	<WORK9
;;		LDA	#30H
		LDA	CTLXAD,Y
		STA	<WORK2
		LDA	CTLYAD,Y
		STA	<WORK3
;
;;;		LDA	#01H
		JSR	CRIT00
		PLB
		RTL

;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
;;KUSADT		EQU	$
;;		BYTE	02H,03H,01H,1,1,1,1   ; ,00H
;
KUSAST		EQU	$	; kusa parapara set !
;;		TAY
;
;		LDY	OSETFG
;		CPY	#05H
;		BCC	KUS008		; Nagatara deru yatsu ?
;;					; yes! not set !
;		STZ	OSETFG
KUS008		EQU	$
		LDY	CACHOK		; for player 
		PHY
		LDY	WCACHOK		; for player 
		PHY
;- - - - - -
		PHB
		PHK
		PLB
;;		LDA	KUSADT,Y		; kusa !
		JSL	>KATOBJ2
		BMI	KUS010
;
		JSR	KTOSUB
KUS010		EQU	$
		PLB
;- - - - - -
		PLA
		STA	WCACHOK		; for player 
		PLA
		STA	CACHOK		; for player 
		RTL
;------------------------------------
KATOBJ		EQU	$	; obj katsugi set !
;		LDY	OSETFG
;		CPY	#03H
;		BEQ	KAT001
;		CPY	#04H
;		BNE	KAT002
;KAT001		EQU	$
;		STZ	OSETFG
KAT002		EQU	$
		PHA
		JSL	>SDLRCP
		ORA	#1DH
		STA	SOUND2	;(S)
		PLA
;- - - - - - - - - - - - - - - - - - - - - - -
KATOBJ2		EQU	$	; obj katsugi set !
		LDX	#ENNO-1
KTO010		EQU	$
		LDY	ENMODE,X
		BEQ	KTO020
		DEX
		BPL	KTO010
		RTL	
;- - - - - - - - - - - - - - - - - - - - -
KTO020		EQU	$
		PHA
		LDA	#ECACH
		STA	ENMODE,X
		LDA	#KTOBJ
		STA	ENMYNO,X
		LDA	<WORK0
;;		AND	#0F0H
		STA	ENXPSL,X
		LDA	<WORK1
		STA	ENXPSH,X
		LDA	<WORK2
;;		AND	#0F0H
		STA	ENYPSL,X
		LDA	<WORK3
		STA	ENYPSH,X
		JSL	>ENMDST
;
		LDA	<PLBGCKF
		STA	ENKAIF,X
;
		PLA
		STA	ENWRK2,X
;
		CMP	#06H
		BCC	KTS002
;
		PHA
;;		LDA	ENMOD0,X
;;		AND	#11110000B
		LDA	#10100110B		;06H
		STA	ENMOD0,X
;
		PLA
KTS002		EQU	$
		CMP	#02H
		BNE	KTS010
;
		LDA	<DJFLG
		BEQ	KTS010	; Danjyon tubo ?
;				; yes 
		LDA	#80H
		STA	ENCLOR,X	; V flip !
KTS010		EQU	$
;
		PHB
		PHK
		PLB
		TAY
		LDA	KTOADT,Y
		STA	ENCLOR,X
;
		LDA	#EMOVE
		STA	>ENCAMD,X
;;		STA	ENWRK0,X
		LDA	#02H
		STA	CACHOK		; for player 
		STA	WCACHOK		; for player 
;
		LDA	#10H
		STA	ENTIM0,X
;
		LDA	<PLBGCKF
		STA	ENKAIF,X
;
		STZ	ENCHPT,X
;
		LDA	OSETFG
		ORA	<DJFLG
		BNE	OSS097		; Ground & nothing ?
;					; yes !
		LDA	ENWRK2,X
		DEC	A
		DEC	A
		CMP	#04H-2
		BCS	OSS097		; Kusa 1,2 ?
;				; yes !
		JSL	>GRITMCK
OSS097		EQU	$
		LDA	OSETFG
		BPL	KS0010  	; Tubo hanmer ?
;;		BPL	OSS098 	; Tubo hanmer ?
		AND	#7FH	; yes !
;		BRA	OSS099
;OSS098		EQU	$
;		CMP	#05H
;		BCC	KS0010		; Nagete kowaretara item set ?
;		CMP	#07H
;		BCS	KS0010
;;			
;;;		SEC				
;;;		SBC	#04H		
;OSS099		EQU	$
		STA	ENCHPT,X	; yes ! (Koware Item set )
;
		STZ	OSETFG
KS0010		EQU	$
;;;;;		JSR	CRITCK		; item see thru hit check !
		JSR	OSETCK		; Item set check !
		PLB
		RTL
;=================================================
OSSTNO		EQU	$
OSTA0		EQU	$
;;;;			    1     2     3     4     5     6     7
		BYTE	RUPYR,ISHI0,HACHI,RUPYR,BOMB1,HART1,RUPYY
;		            8     9     A     B     C     D     E
		BYTE	KAGI0,YAAA1,BOMB1,HART1,TUBO1,TUBO2,NIWAT
;			    F    10
		BYTE	HEIS0,ABATA
OSTA1		EQU	$
;;; For randam              
		BYTE	RUPYR,YOSEI,HART1,0000H
;
;
;;;;;;			    1     2     3     4     5     6     7
;;		BYTE	RUPYR,ISHI0,HACHI,RUPYR,YOSEI,HART1,HART1
;;;
;;		BYTE	BOMB1,HART1
OSSTST		EQU	$
		BYTE	00000,00001,00001,00000,00000,00000,00000
		BYTE	00000,00000,00000,00003,00000,00000,00001
		HEX	00000,00000
		HEX	00000,00000,00000,00000
OSSTXA		EQU	$
		BYTE	00004,00000,00004,00004,00000,00004,00004
		BYTE	00004,00004,00000,00004,00004,00004,00000
		HEX	00000,00000
		HEX	00004,00000,00004,00004
OSSTNC		EQU	$
		BYTE	00001,00000,00000,00001,00001,00001,00001
		BYTE	00001,00001,00001,00001,00001,00001,00000
		HEX	00000,00000
		BYTE	00001,00001,00001,00001
OSSTZS		EQU	$
		BYTE	0010H,00000,00000,0010H,00000,00000,0010H
		BYTE	0010H,0010H,0010H,0000H,0010H,00010,0010H
		HEX	00000,00000
		BYTE	0010H,0000H,0000H,0000H
;- - - - - - - - - - - - - - - - - - - - - - 
OSCKRT		EQU	$
		CLC
		RTS
;
OSETCK		EQU	$
		LDA	<DJFLG
		BNE	OSCK01		; Ground ?
;					; yes !
		JSL	>RNDSET
		AND	#08H
		BNE	OSCKRT		;1/2 set !
;
OSCK01		EQU	$
;
		LDY	OSETFG
		BEQ	OSCKRT
;
		CPY	#04H
		BNE	OSCK10		;Randam set ?
;					; yes !
		JSL	>RNDSET
		AND	#03H
		CLC
		ADC	#OSTA1-OSTA0+1
;;		ADC	#0EH
		TAY
OSCK10		EQU	$
		STY	<WORKD
		LDA	OSSTNO-1,Y
		BEQ	OSCKRT
		JSL	>ENIDSH
		BMI	OSCKRT
;
		PHX
;
		LDX	<WORKD
		LDA	OSSTST-1,X
		STA	ENSTAT,Y
		LDA	OSSTNC-1,X
		STA	ENNOCR,Y
		LDA	OSSTZS-1,X
		STA	ENZSPD,Y
;
		LDA	<WORK0
		CLC
		ADC	OSSTXA-1,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#00H
		STA	ENXPSH,Y
		LDA	<WORK2
		STA	ENYPSL,Y
		LDA	<WORK3
		STA	ENYPSH,Y	
		LDA	<WORK4
		STA	ENZPSL,Y	
;
		LDA	#00H
		STA	ENCHPT,Y
;
		LDA	#20H
		STA	ENTIM3,Y	; Hit protect !
;
		LDA	#30H
		STA	ENTIM2,Y	; Oam yuusen > tubo !
;
		LDX	ENMYNO,Y
		CPX	#KAGI0
		BNE	OSCK78
;
		PHX
		TYX
		JSR	KAGI0IT
		PLX
OSCK78		EQU	$
		CPX	#ISHI0
		BNE	OSCK80
;
 		LDA	ENMOD2,Y	; Damege on !
		AND	#10111111B
		STA	ENMOD2,Y
OSCK80		EQU	$
		CPX	#HEIS0
		BNE	CSCK88
;
		LDA	#00H
		STA	ENDMPW,Y
		LDA	#20H+080H	; Damage protect !
		STA	ENFLSH,Y
		BRA	OSCK90
CSCK88		EQU	$
		LDA	#0FFH
		STA	ENSTTM,Y	; Clear time !
OSCK90		EQU	$
		SEC
		PLX
		RTS
;********************************************************************
;*			ENEMY SUB    							(		)		*
;********************************************************************
ENEMY		EQU	$
		JSL	>DBUGSB		; Debug mode set !
;
;
;
;
;
;
;;		STZ	DJFLG
;
;// 03.04.16 //		LDA	<SLMODE
;// 03.04.16 //		CMP	#MD_djply
;// 03.04.16 //		BNE	E00000		; danjyon ?
;// 03.04.16 //;					; Y
;;		LDA	<GMMODE
;;		BEQ	E00000		; danjyon ?
;;;					; yes
;;		INC	DJFLG
;;		BRA	E10000
;;
;;E00000		EQU	$
		JSL	>GRENST		; ground enemy scrool set !
;
;;		LDA	>MODTBL0
;;		CMP	#01H
;;		BNE	E10000
;;;
;;		LDA	<FRCNT
;;		AND	#0FH
;;		ORA	<GAMEMD
;;		BRA	E10000
;;;
;;		LDX	#00H
;;		JSL	>ENIDSH
;;		BMI	E10000
;;		LDA	#EAME
;;		STA	ENMODE,Y
;;		LDA	#07H
;;		STA	ENTIM0,Y
;;		JSL	>RNDSET
;;		AND	#07H
;;		CLC
;;		ADC	#03H
;;		CLC
;;		ADC	<PLXPS1
;;		STA	ENXPSL,Y
;;		LDA	<PLXPS0
;;		ADC	#00H
;;		STA	ENXPSH,Y
;;		JSL	>RNDSET
;;		AND	#03H
;;		CLC
;;		ADC	<PLYPS1
;;		STA	ENYPSL,Y
;;		LDA	<PLYPS0
;;		ADC	#00H
;;		STA	ENYPSH,Y
;;		LDA	#00H
;;		STA	ENMOD0,Y
;;		STA	ENMOD2,Y
;
E10000		EQU	$
;
;;		LDA	#0FH
;;		STA	02100H		; timer over tset !
;		HEX	EA,EA,EA
;
;;		LDA	!NXSLMD		; danjon 2, chjoo 4
;;		CMP	#MD_djply
;;		BEQ	E0010		; ground ?
;;		LDA	DJFLG
;;		BNE	E0010
;;;					; yes !
;;		JSL	>GRENST		; ground enemy scrool set !
;;;
;;E0010		EQU	$
;
		PHB
		PHK
		PLB
;========================
		LDY	#00H
		LDA	>GDTRPF
		BEQ	EE0D8	; URA ?
;				; YES !
		INY
EE0D8		EQU	$
		STY	URAFLG
;
		LDA	<GAMEMD
		BNE	E0011
;
		STZ	PLXMVD		; Player move flag !
		STZ	PLXMVD+1		; Player move flag !
		STZ	PLYMVD		; Player move flag !
		STZ	PLYMVD+1		; Player move flag !
;
;;		LDA	PLSTTM
;;		BEQ	E0011		; Player stop cont.
;;;
;;		LDA	<FRCNT
;;		AND	#01H
;;		BNE	E00E0
;;		DEC	PLSTTM
;;E00E0		EQU	$
;;		LDY	#01H
;;		LDA	PLSTTM
;;		BNE	E00F0
;;		DEY
;;E00F0		EQU	$
;;		STY	PYALSP		
E0011		EQU	$
		JSR	OEINIT		; OAM index entry initial !
;
		JSL	>ENEMY20		; many many obj !!
		JSL	>OPTNMV		; Player option move !
;
		LDA	CACHOK
		STA	WCACHOK
;
		STZ	CACHOK		; player cach ok flag !
		LDA 	#80H
		STA	ENKNXP		; enemy cros data reset !
;
  		LDA	<HANIFG		; Player hani flag clear !
		AND	#7FH
		BEQ	E1105
		DEC	<HANIFG
		BRA	E1106
E1105		EQU	$
		STZ	<HANIFG
E1106		EQU	$
		STZ	KINSHI		; Not "X" key check 
		STZ	HIKUFG		; Hiku flag ! 
		STZ	PLSTOP		; Player stop flag !
;
		LDA	OTOFLG
		BEQ	E1112
;
		DEC	OTOFLG		; Oto hannou time !
E1112		EQU	$
;==================
		JSL	>EXSTRA		; Tama etc.
		JSL	>EST0SB		; enemy set positionin !
;==================
		STZ	YAAOFF		; ya not shot reset !
;
;;		LDA	ENITFG
;;		BNE	ENM000
;;		JSR	!ENITST		; TEST !!!
;;ENM000		EQU	$              
;;			LDX		#10-1
		LDX	#ENNO-1
ENM010		EQU	$
		STX	ENINDX
;;;;;		JSR 	ENSUB0
		JSR	ENMAIN
		DEX
		BPL	ENM010
;
		JSL	>ENEMY2		; many many obj !!
;
;------------------------ TEST ----
;;		BIT	KEYA2
;;		BVC	T000000
;;		LDA	#BEAM2
;;		JSL	>BEAMS2
;;T000000		EQU	$
		STZ	SCRMVX
		STZ	SCRMVY
;
;;;;		STZ	INTEKI		; Player inori flag !!
;
  		PLB
;;		LDA	#0FH
;;		STA	02100H		; timer over tset !
;
;		LDA	#0FH
;// 03.06.28 //		STA	02100H		; timer over tset !
;		HEX	EA,EA,EA
		JSL	>ENMYSV		; Enemy save c set ! for danjyon !
;
		LDA	SPOJFG
		BEQ	ENM111		; Bank chenge ?
;					; yes !
		STA	OJBKFG		; Save !
ENM111		EQU	$
		RTL
;;----------------------------------------
;ENRMCL		EQU	$
;		STZ	ENDSPL,X
;		STZ	ENATCT,X
;		STZ	ENXSPD,X
;		STZ	ENYSPD,X
;		STZ	ENSTAT,X
;		STZ	ENCHPT,X
;		STZ	ENMUKI,X
;		STZ	ENTIM0,X	;
;		STZ	ENTIM1,X	;
;		STZ	ENTIM2,X	;
;		STZ	ENTIM3,X	;
;		STZ	ENCMKI,X
;		STZ	ENCTFG,X
;		STZ	ENCTCT,X
;		STZ	ENFLSH,X	;
;		STZ	ENCBFG,X
;		STZ	ENZPSL,X	;
;		STZ	ENLIFE,X	;
;		STZ	ENHNFG,X
;		STZ	ENZSPD,X
;		STZ	ENWRK0,X
;		STZ	ENWRK1,X
;		STZ	ENWRK2,X
;		STZ	ENCRTM,X	;
;		STZ	ENCONT,X
;		STZ	ENNOCR,X	;
;		RTL
;-------------------------------------------------
OEITDT		EQU	$
;;;		WORD	0060H,0000H,01C0H,0000H,01B0H
		WORD	0030H,01D0H,0000H,0030H,0120H,0140H
;
OEINIT		EQU	$
		LDY	#00H
		MEM16
		REP	#00100000B
OEI010		EQU	$
		LDA	OEITDT,Y
		STA	NXINDX,Y
		INY
		INY
		CPY	#0AH+1
		BCC	OEI010
		MEM8
		SEP	#00100000B
		RTS
;=======================================================
CROJCK2		EQU	$
		JSR	CROJCK
		RTL
ENCRST2		EQU	$
		PHB
		PHK
		PLB
		JSR	ENCRST
		PLB
		RTL
;=================================================================
;;ENOMDT		EQU	$
;;		BYTE	038H,04CH,060H,074H,088H,09CH,0B0H,0C4H,0D8H,0ECH
;ENOMRG		EQU	$	; use oam range !
;		BYTE	005H*4
;		BYTE	005H*4
;		BYTE	005H*4
;		BYTE	005H*4
;		BYTE	005H*4
;		BYTE	005H*4
;
;
ENSUB0		EQU	$
		JSR	PSSAVE
;
;L        	LDA	<SLMODE		; danjon 2, chjoo 4
;L		CMP	#MD_djply
;L		BNE	ES0010		; ground ?
;L;;;					; no.
;L;;		JSR	ENCLCK		; mode clear check !
;L		BRA	ES0020
;L;	
;LES0010		EQU	$
;L		LDA	ENMYNO,X
;L		CMP	#HYUUU
;L		BEQ	ES0020
;L;
;L		JSR	ENSAVE		; enemy scroll clear & data reset !
;LES0020		EQU	$
;;		LDA	ENOMDT,X
;;		STA	ENOMID,X
;;		LDY	ENMYNO,X
;;		LDA	ENOMRG,Y
;
;;		LDA	ENDSPL,X
;;		BNE	NOOAM
;
		LDA	ENMOD0,X
		AND	#1FH
		INC	A
		ASL	A
		ASL	A
		LDY	OAMTYP
		BEQ	ES0022		; cross road room ?
;					; yes ! kai check !
		LDY	ENKAIF,X
		BEQ	ES0021
;
		JSL	>OAMENT6
		BRA	ES0023
ES0021		EQU	$
		JSL	>OAMENT4
		BRA	ES0023
ES0022		EQU	$
		JSL	>OAMENT1
ES0023		EQU	$
NOOAM		EQU	$
;;		TYA
;;		STA	ENOMID,X
;
;;		LDA	ENXPSL,X
;;		SEC
;;		SBC	<SCCH2
;;		STA	ENDSXL
;;		LDA	ENYPSL,X
;;		SEC
;;		SBC	ENZPSL,X
;;		SEC
;;		SBC	<SCCV2
;;		STA	ENDSYL
;
		LDA	<GAMEMD
		ORA	ENSTFG
;;;		ORA	ENHNFG,X
		BEQ	ENS050N
		JMP	ENS050
;
ENS050N		EQU	$
		LDA	ENTIM0,X
		BEQ	ENS000
		DEC	ENTIM0,X
ENS000		EQU	$
		LDA	ENTIM1,X
		BEQ	ENS010
		DEC	ENTIM1,X
ENS010		EQU	$
		LDA	ENTIM2,X
		BEQ	ENS020
		DEC	ENTIM2,X
ENS020		EQU	$
		LDA	ENTUTM,X
		BEQ	ENS030
		DEC	ENTUTM,X
ENS030		EQU	$
		LDA	ENFLSH,X
		AND	#01111111B
		BEQ	ENS040
;;		CMP	#01H
;;		BNE	ENS034		; end ?
;;		PHX
;;		LDA	ENMYNO,X
;;		TAX
;;		LDA	>ENMDD2,X
;;		PLX
;;		AND	#0FH
;;		STA	ENCLOR,X
;;		BRA	ENS03C
;;ENS034		EQU	$
		LDY	ENMODE,X
		CPY	#EMOVE
		BCC	ENS038
		CMP	#01FH
		BNE	ENS037
;
		PHA
;
		LDA	ENMYNO,X
		CMP	#SHSAI
		BNE	ENDMSSS
;
		LDA	URAFLG
		BNE	ENDMSSS
;
		LDA	ENLIFE,X
		SEC	
		SBC	ENDMPW,X
		BEQ	ENDMSSW
;
		BCS	ENDMSSS		; Shisai fail ?
;					; yes !
ENDMSSW		EQU	$
		LDA	#MS_04D3	; msg set !
		STA	MSGENOL
		LDA	#HIGH MS_04D3
		STA	MSGENOL+1
		JSL	>MSGSET
ENDMSSS		EQU	$
		PLA
ENS037		EQU	$
		CMP	#018H
		BNE	ENS038		; life check ?
;;		PHA			; yes !
		JSR	ENDMS0
;;		PLA
ENS038		EQU	$
;;		LDA	ENMODE,X
;;		CMP	#EICE
		LDA	ENDMPW,X
		CMP	#0FBH
		BCS	ENS03C		; Enemy stop ?
;					; no !
		LDA	ENFLSH,X
		ASL	A
		AND	#00001110B
		STA	ENFLCL,X		; flash color save !
;;		EOR	ENCLOR,X
;;		STA	ENCLOR,X	; color pikapika
ENS03C		EQU	$
		DEC	ENFLSH,X
		BRA	ENS043
;;;		BNE	ENS040		; end ?
;;;;
;;;		JSL	>ENCLST		; yes ! color revise !
ENS040		EQU	$
		STZ	ENFLSH,X
;;ENS041		EQU	$
		STZ	ENFLCL,X
;
ENS043		EQU	$
		LDA	ENTIM3,X
		BEQ	ENS050
		DEC	ENTIM3,X
ENS050		EQU	$
		LDY	<PLBGCKF
		CPY	#03H
		BEQ	ENS058
		LDY	ENKAIF,X
;;		LDA	ENZPSL,X
;;		CMP	#10H
;;		BCC	ENS058
;;		LDY	#00H
ENS058		EQU	$
		LDA	ENFLCL,X
		AND	#11001111B
		ORA	ENPRDT,Y
		STA	ENFLCL,X
;
ENS05A		EQU	$
;;		LDA	ENCLOR,X
;;		AND	#11001111B
;;		ORA	ENPRDT,Y
;;;;;		ORA	ENCLOR,X
;		STA	ENCLOR,X
		RTS
; - - - - - - - - - - - - - - - - - - - - - - - - - - -
ENPRDT		EQU	$
;;;		BG YUUSEN  0    1   2   3 
		BYTE	020H,010H,030H,30H
;===========================
PSSAVE2		EQU	$
		JSR	PSSAVE
		RTL
;- - - - - - - - - - - - - - - - - -
PSSAVE		EQU	$
                LDA     ENXPSL,X
                STA     ENXP2L
                LDA     ENXPSH,X
                STA     ENXP2H
                LDA     ENYPSL,X
                STA     ENYP2L
                LDA     ENYPSH,X
                STA     ENYP2H
		RTS
;=================================================================
ENMAINL		EQU	$
		PHB
		PHK
		PLB
		JSR	ENMAIN
		PLB
		RTL
;=================================================================
ENMAIN		EQU	$
		LDA	ENMODE,X
		BEQ	ENNOTH	
;
		PHA
		JSR	ENSUB0
;
		PLA
		CMP	#EMOVE
		BEQ	ENMOVEJ
;
		JSL	>JSRSUB
EM00   		WORD	ENNOTH
EM005		WORD	00 ;;ENICFL		; ICE flash !
EM006		WORD	ENICBR		; ICE break !
EM007		WORD	ENWATR		; Mizu shinuki !
EM008		WORD	ENBAKUJ		; Boss bakuhatsu ! 
EM01		WORD	ENHOLE
EM02		WORD	ENFAIL
EM025		WORD	ENFIREJ
EM03		WORD	ENINIT
EM04		WORD	ENMOVE
EM05		WORD    ENCACH
EM06		WORD	ENICE
ENMOVEJ		EQU	$
		JMP	ENMOVE
ENRETN		EQU	$
		RTS
ENNOTH		EQU	$
		LDA	<DJFLG
		BNE	ENNN10
		TXA
		ASL	A
		TAY
		LDA	#0FFH
		STA	ENSWAD,Y
		STA	ENSWAD+1,Y
ENNN10		EQU	$
		LDA	#0FFH
		STA	ENSWAD,X
		RTS
;- - - - - - - - - - - - - - - -
ENMOVE2		EQU	$
		PHB
		PHK
		PLB
		JSR	ENMOVE
		PLB
		RTL
;- - - - - - - - - - - - - - - - - - - -
EICFL		EQU	(EM005-EM00)/2
EICBR		EQU	(EM006-EM00)/2
EHOLE		EQU	(EM01-EM00)/2
EFAIL		EQU	(EM02-EM00)/2
EINIT		EQU	(EM03-EM00)/2
EMOVE		EQU	(EM04-EM00)/2
ECACH		EQU	(EM05-EM00)/2
EICE		EQU	(EM06-EM00)/2
EWATR		EQU	(EM007-EM00)/2
EFIRE		EQU	(EM025-EM00)/2
EBAKU		EQU	(EM008-EM00)/2
;=================================================================
ENFIREJ		EQU	$
		JSL	>ENFIRE
		RTS
;
ENBAKUJ		EQU	$
		JSL	>ENBAKU
		RTS
;==============================================
;==============================================
;==============================================
;==============================================
;ENWXAD		EQU	$
;		HEX	F8,08
;		HEX	F8,08
;       	HEX	F8,08
;		HEX	FC,04
;		HEX	FC,04
;		HEX	00,00
;		HEX	00,00
;		HEX	00,00
;ENWYAD		EQU	$
;		HEX	FE,FE
;		HEX	FE,FE
;		HEX	FE,FE
;		HEX	FE,FE
;		HEX	FE,FE
;		HEX	FE,FE
;		HEX	00,00
;		HEX	00,00
;ENWCDT		EQU	$
 ;		HEX	AE,AE
;		HEX	AE,AE
;		HEX	AE,AE
;		HEX	AE,AE
;		HEX	AE,AE
;		HEX	AC,AC
;		HEX	AC,AC
;		HEX	AC,AC
;ENWADT		EQU	$
;		BYTE	024H,064H
;		BYTE	024H,064H
;		BYTE	024H,064H
;		BYTE	024H,064H
;		BYTE	024H,064H
;		BYTE	024H,064H
;		BYTE	064H,064H
;		BYTE	024H,024H
;;- - - - - - - - - - - - - - - - - - - - - - -
EWATRCD		EQU	$
		WORD	0FFF9H,0FFF9H
		HEX	80,04,00,00
		WORD	0000EH,0FFFAH
		HEX	83,04,00,00
;
		WORD	0FFFAH,0FFFAH
		HEX	CF,04,00,00
		WORD	0000DH,0FFFBH
		HEX	DF,04,00,00
;
		WORD	0FFFCH,0FFFCH
		HEX	AE,04,00,00
		WORD	0000CH,0FFFCH
		HEX	AF,44,00,00
;
		WORD	00000H,00000H
		HEX	E7,04,00,02
		WORD	00000H,00000H
		HEX	E7,04,00,02
;
;--Part 2-----
EWATDT		EQU	$
		HEX	00,40,C0,80
EWFPTD		EQU	$
		HEX	C0,C0,C0,C0,CD,CD,CD,CB,CB,CB,CB
;--------------------------------------------------------
;- - - - - -- - - - - - - -
ENWATR		EQU	$
		LDA	ENSTAT,X
		BEQ	EWF020
;
		LDA	ENWRK0,X
		CMP	#06H
		BNE	EW7000		; mae ?
;					; yes !
		LDA	#04H*2
		JSL	>OAMENT3
EW7000		EQU	$
		JSR	EN1CST
;
;;		LDA	<GAMEMD
;;		BNE	EW0010
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	EWATDT,Y
		STA	<WORK5
;
		LDA	ENTIM0,X
		CMP	#01H
                BNE     EWF800 
		STZ	ENMODE,X
EWF800		EQU	$
;
		PHX
		LDA	#08AH
		BCC	EWF900
		LDA	ENTIM0,X
		LSR	A
		TAX
		STZ	<WORK5
		LDA	EWFPTD,X
EWF900		EQU	$
		LDY	#02H
		STA	(<OAMADR),Y
		INY
		LDA	#24H
		ORA	<WORK5
		STA	(<OAMADR),Y
		PLX
;--------------------------
EWF000		EQU	$		
		LDA	ENTIM0,X
		BNE	EW0010
;
		JSR	ENSTCK2
;
		INC	ENCONT,X
		JSR	ENMVCL
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	EW0010
;
		STZ	ENZPSL,X
		LDA	#09H*2  
		STA	ENTIM0,X
EW0010		EQU	$
		RTS
;--------------------------------------------------------
;
;
;
;
;--------------------------------------------------------
EWF020		EQU	$
		JSR	ENSTCK2
;
		LDA	<FRCNT
		AND	#01H
		BNE	EWF023
;
		INC	ENTIM0,X
EWF023		EQU	$
		STZ	ENCLOR,X
		STZ	ENFLSH,X
;
		LDA	#00H
		XBA
		LDA	ENTIM0,X
		BNE	EWF028
		STZ	ENMODE,X
EWF028		EQU	$
;;		LSR	A
;;		LSR	A
		MEM16
		REP	#00100000B
;;		ASL	A
;;		ASL	A
		ASL	A
		AND	#11111000B
;
		ASL	A
		ADC	#EWATRCD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
		JSL	>SETOAML22
		RTS
;
;
;L;		JSR	OAMCHK
;L;;
;L;		LDA	ENTIM0,X
;L;		BEQ	ENWT090
;L;;;		LSR	A
;L;		NOP
;L;		AND	#00001110B
;L;		STA	<WORK6
;L;		PHX
;L;		LDX	#01H
;L;EWTC010		EQU	$
;L;		PHX
;L;		TXA
;L;		CLC
;L;		ADC	<WORK6
;L;		TAX
;L;		LDA	<WORK0
;L;		CLC
;L;		ADC	ENWXAD,X
;L;		STA	(<OAMADR),Y		
;L;		LDA	<WORK2
;L;		CLC
;L;		ADC	ENWYAD,X
;L;		INY
;L;		STA	(<OAMADR),Y
;L;		LDA	ENWCDT,X
;L;		INY
;L;		STA	(<OAMADR),Y
;L;		LDA	ENWADT,X
;L;		INY
;L;		STA	(<OAMADR),Y
;L;		INY
;L;		PLX
;L;		DEX
;L;		BPL	EWTC010
;L;		PLX
;L;		LDY	#02H
;L;		LDA	#01H
;L;		JSR	ALOMCK
;L;		RTS
;L;ENWT090		EQU	$
;L;		STZ	ENMODE,X
;L;		RTS
;;=================================================================
;ENMDST		EQU	$
;		JSL	>ENRMCL
;		PHY
;		PHB
;		PHK
;		PLB
;		LDY	ENMYNO,X
;		LDA	ENMDD0,Y
;		STA	ENMOD0,X
;		LDA	ENMDD1,Y
;		STA	ENMOD1,X	;(ENLIFE)
;		LDA	ENMDD3,Y
;		STA	ENMOD3,X
;		LDA	ENMDD4,Y
;		STA	ENMOD4,X
;		LDA	ENMDD5,Y
;		STA	ENMOD5,X
;		LDA	ENMDD6,Y
;		STA	ENMOD6,X
;;
;		LDA	GRNDNO
;;
;		LDY	DJFLG
;		BEQ	ENMS00
;;
;		LDA	ERXYCT
;ENMS00		EQU	$
;		STA	ENGRNO,X	; now ground no set !
;		PLB
;		PLY
;;;;		RTL
;ENCLST		EQU	$
;		PHY
;		PHB
;		PHK
;		PLB
;;
;		LDY	ENMYNO,X
;		LDA	ENMDD2,Y
;		STA	ENMOD2,X
;		AND	#0FH
;		STA	ENCLOR,X
;		PLB
;		PLY
;		RTL
;----------------------------------------------
ENINIT		EQU	$
		JSL	>ENMDST
		INC	ENMODE,X
;
		LDA	ENMYNO,X
		JSL	>JSRSUB
		WORD	KARASIT
		WORD	HAGE0IT
		WORD	SKHEDIT
;----------------------------------------------
		WORD	00H    
		WORD	ESW02IT
		WORD	ESW03IT
		WORD	ESW12IT
		WORD	ESW04IT
;---------------------------------------
		WORD	OCTA1IT
;;		WORD	OCTA2IT
		WORD	HAYABITJ
		WORD	OCTA3IT
		WORD	NIWATIT
		WORD	OCTAMIT
		WORD	NYOROIT
		WORD	PAKKNIT
		WORD	OCTBLIT
		WORD	OCTSSIT
		WORD	HINO0IT
		WORD	BUTA0IT
		WORD	MOTS1IT
		WORD	PLHINIT
		WORD	BABULIT ;KWAUSIT
		WORD	JITONITJ	;KWAU1IT
		WORD	SHIGEIT
		WORD	HAYAMITJ
		WORD	GOST0IT
		WORD	KAJIYIT
		WORD	YATAMIT
		WORD	SEKZ4IT
		WORD	BEECKIT
		WORD	TAAMAIT
		WORD	SINUBIT
		WORD	NAME0IT
		WORD	REBA1IT
		WORD	LOPAAIT
		WORD	ZOOL1IT
		WORD	ZOOL2IT
		WORD	WOOD1IT
		WORD	MOTS0IT
		WORD	IWABOIT
		WORD	JOHOYIT
		WORD	JIJIIIT
		WORD	BABAAIT
		WORD	SLEEPIT
		WORD	NOKOGIT
		WORD	PENKIIT
		WORD	KUTUUIT
		WORD	MEIR0IT
		WORD	MEIR1IT
		WORD	ULANIIT
		WORD	NOPPOIT
		WORD	PLHIKIT
		WORD	ONNAAITJ
		WORD	HIGEEITJ
		WORD	MAJOOIT
		WORD	PLCHKIT
		WORD	KIANAIT
		WORD	SAKASIT
		WORD	DEMONIT
		WORD	BOOK0IT
		WORD	TKBOYIT
		WORD	BABA1ITJ
		WORD	ISHI0IT
		WORD	BARI0IT
		WORD	BARI1IT
		WORD	HEIS0IT
		WORD	HEI00IT
		WORD	HEIS1IT
		WORD	HEIS2IT
		WORD	HEIS3IT
		WORD	HEYA0IT
		WORD	HEYA1IT
		WORD	HEYA2IT
		WORD	HEYA3IT
		WORD	HEBO0IT
		WORD	ZAKO0IT
		WORD	SUNA0IT
		WORD	USAG0IT
		WORD	HANA0IT
		WORD	HANA1IT
		WORD	TAMA0IT
		WORD	DOZOOIT
		WORD	ZORABIT
		WORD	NOMOSIT
		WORD	RANEMITJ
		WORD	ZORASIT
		WORD	ZORA2IT
		WORD	SEKMVIT
		WORD	KANI0IT
		WORD	TORI0IT
		WORD	RISU0IT
		WORD	SPARKIT
		WORD	SPARLIT
		WORD	CHAN0IT
		WORD	CHAN1IT
		WORD	CHAN2IT
		WORD	CHAN3IT
		WORD	MEDUSIT
		WORD	ATARSIT
		WORD	ARI00IT
		WORD	ARI01IT
		WORD	YASANITJ
		WORD	HODIRIT
		WORD	HODILIT
		WORD	HODIDIT
		WORD	HODIUIT
		WORD	TEKU0IT
		WORD	TAIHOIT
		WORD	HYUUUIT
		WORD	NEZU0IT
		WORD	HEBI0IT
		WORD	KOMO0IT
		WORD	MOTAMIT
;
		WORD	RIVERIT
		WORD	BWAKOIT
		WORD	OYAGIITJ
		WORD	BOUSIITJ
		WORD	SYOBYITJ
		WORD	HELP0ITJ
		WORD	BIGBLIT 
		WORD	JOHBBITJ 
		WORD	HACHIIT 
		WORD	SHSAIIT
		WORD	SHTAMIT
		WORD	TELSAIT
		WORD	TRAP0IT
		WORD	BAAR0IT
		WORD	BAAR1IT
		WORD	HBTAMIT
		WORD	AMENBIT
		WORD	BABU2ITJ
		WORD	MEDAMIT
		WORD	MEDA2IT
		WORD	SKELTIT
		WORD	CHIBIIT
		WORD	CHFIRIT
		WORD	BIGKOIT
		WORD	BKFIRIT
		WORD	HARI0IT
		WORD	MIIRAIT
		WORD	PATARIT
		WORD	PATAMIT
		WORD	KAM01IT
		WORD	SLIMEIT
		WORD	HANDSIT
		WORD	SKELBIT
		WORD	MOTSBITJ
		WORD	BYOYNIT
		WORD	AYASIIT
		WORD	MEMERIT
		WORD	MEMELIT
		WORD	MEMEDIT
		WORD	MEMEUIT
		WORD	PENGIIT
		WORD	FISH0IT
		WORD	MAGICIT
		WORD	KURORIT
		WORD	KURODIT
		WORD	DACHOIT
		WORD	USAGIIT
		WORD	OOOMUIT
		WORD	ICMANIT
		WORD	ICBOSIT
		WORD	ICEBGIT
		WORD	ICTAMIT
		WORD	TEKI0IT
		WORD	TEKI1IT
		WORD	SKEL2IT
		WORD	PATA0IT
		WORD	PATA1IT
		WORD	LIKE0IT
		WORD	POLIWIT
		WORD	RINGOIT
		WORD	HELP1ITJ
		WORD	DOKN0ITJ
		WORD	DOKN1ITJ
		WORD	DOKN2ITJ
		WORD	DOKN3ITJ
		WORD	BEE00IT
		WORD	SEKBNIT
		WORD	TAKARIT
		WORD	BAKDNIT
		WORD	SARKKIT
		WORD	TEKBBIT
		WORD	D_0_9IT
		WORD	SITO0IT
		WORD	UZUMKIT
		WORD	SAMTMIT
		WORD	RYOKIIT
		WORD	EYEBSITJ
		WORD	EYETMIT
		WORD	EYEBMIT
		WORD	NAMAZIT
		WORD	SDEMOITJ
		WORD	IWAGOIT
		WORD	AMEBAIT
		WORD	TheftIT
		WORD	BGBM0IT
		WORD	BGBM1IT
		WORD	DARUMIT
		WORD	IZUMIIT
		WORD	TEKTAIT
		WORD	WANWANIT
		WORD	KAMBSITJ
		WORD	KAMBRITJ
		WORD	KAMBBITJ
		WORD	CTBOSITJ 
		WORD	MDARMITJ 
		WORD	RINELIT  
		WORD	DOOMOIT  
		WORD	JFISHIT  
		WORD	ABATAIT  
		WORD	ANAHOIT  
		WORD	GANONITJ 
		WORD	GANONITJ 
;
		WORD	ITEM1IT	;0
		WORD	ITEM1IT ;1
		WORD	ITEM1IT ;2
		WORD	ITEM1IT ;3
		WORD	ITEM1IT ;4
		WORD	ITEM1IT ;5
		WORD	ITEM1IT ;6
;;		WORD	ITEM1IT ;7	NIKI1
;;		WORD	ITEM1IT ;8	NIKU2
;;		WORD	ITEM1IT ;9	OPTN1
		WORD	ITEM1IT ;A
		WORD	ITEM1IT ;B
;;		WORD	ITEM1IT ;C	CRYS1
;;		WORD	ITEM1IT ;D	TRYFR
;;		WORD	ITEM1IT ;E	TRYFY
;;		WORD	ITEM1IT ;F	TRYFB
;;		WORD	ITEM1IT ;0	SPESR
;;		WORD	ITEM1IT ;1	SPESY
;;		WORD	ITEM1IT ;2	SPESB
		WORD	ITEM1IT ;3	
		WORD	ITEM1IT ;4
		WORD	YOSEIIT
		WORD	KAGI0IT
		WORD	KAGI1IT
		WORD	PTATEIT
		WORD	KINOKITJ
		WORD	SUKASITJ
		WORD	MJSY1ITJ
		WORD	UTUWAITJ
		WORD	UTUBKITJ
		WORD	ENRETN		; KTOBJ
		WORD	LINE0ITJ
		WORD	OOISUIT
		WORD	LINE1ITJ
		WORD	LINE2ITJ
		WORD	LINE3ITJ
		WORD	MONORITJ
;==============================
;OIIXAD		EQU	$
;		HEX	08,30
;
OOISUIT		EQU	$
;		LDA	>MODTBL1
;		AND	#00000001B
;		STA	ENSTAT,X
;		TAY
;
		LDA	ENYPSL,X
		CLC
		ADC	#03H
		STA	ENYPSL,X
;;		DEC	ENNOCR,X
;
;--------------------------------------------
;;		JMP	XRVS
;
XRVS		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#08H
;;;;;;;;;;;		ADC	OIIXAD,Y
		STA	ENXPSL,X
;K;
;K;;		LDA	ENXPSH,X
;K;;		ADC	#00H
;K;;		STA	ENXPSH,X
;K;
;K;
		RTS
;K;;		JMP	NOST
;K;;		RTS
;--------------------------------------------------
MONORITJ	EQU	$
		JSL	>MONORIT
		RTS
;
;LINE0ITJ	EQU	$
;LINE1ITJ	EQU	$
;LINE2ITJ	EQU	$
;LINE3ITJ	EQU	$
;DOKN0ITJ	EQU	$
;DOKN1ITJ	EQU	$
;DOKN2ITJ	EQU	$
;DOKN3ITJ	EQU	$
;		JSL	>LINE0IT
;		RTS
ESW02IT		EQU	$
ESW12IT		EQU	$
		LDA	ERXYCT
		CMP	#0CEH
		BEQ	SWI000
		CMP	#04H
		BEQ	SWI000
		CMP	#3FH
		BNE	SWI010
SWI000		EQU	$
		LDA	#06H*2+1
		STA	ENCLOR,X
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#08H
;;		STA	ENXPSL,X
;;		LDA	ENYPSL,X
;;		ADC	#08H
;;		STA	ENYPSL,X
SWI010		EQU	$
ESW04IT		EQU	$
		RTS
BABA1ITJ	EQU	$
		JSL	>BABA1IT
		RTS
;---------------
SKHEDIT		EQU	$
ESW03IT		EQU	$
NIWATIT		EQU	$
OCTAMIT		EQU	$
NYOROIT		EQU	$
PAKKNIT		EQU	$
OCTSSIT		EQU	$
HINO0IT		EQU	$
BUTA0IT		EQU	$
KWAUSIT		EQU	$
KWAU1IT		EQU	$
SHIGEIT		EQU	$
YATAMIT		EQU	$
NAME0IT		EQU	$
LOPAAIT		EQU	$
IWABOIT		EQU	$
ISHI0IT		EQU	$
BARI0IT		EQU	$
TEKU0IT		EQU	$
TAIHOIT		EQU	$
HYUUUIT		EQU	$
TAMA0IT		EQU	$
KANI0IT		EQU	$
MEDUSIT		EQU	$
AYASIIT		EQU	$
PENGIIT		EQU	$
MAGICIT		EQU	$
D_0_9IT		EQU	$
EYEBMIT		EQU	$
IWAGOIT		EQU	$
TheftIT		EQU	$
KIANAIT		EQU	$
RINELIT		EQU	$
DOOMOIT		EQU	$
LINE0ITJ	EQU	$
LINE1ITJ	EQU	$
LINE2ITJ	EQU	$
LINE3ITJ	EQU	$
DOKN0ITJ	EQU	$
DOKN1ITJ	EQU	$
DOKN2ITJ	EQU	$
DOKN3ITJ	EQU	$
;;		RTS
;;;
		RTS
;---------------
NEZU0AT		EQU	$
		HEX	0,5
NEZU0LF		EQU	$
		HEX	2,8
;
NEZU0IT		EQU	$
		LDY	URAFLG
		LDA	NEZU0AT,Y
		STA	ENMOD6,X
		LDA	NEZU0LF,Y
		STA	ENLIFE,X
		RTS
;==============================
KOMO0AT		EQU	$
		HEX	80,85
KOMO0LF		EQU	$
		HEX	1,4
KOMO0IM		EQU	$
		HEX	0,7
;
KOMO0IT 	EQU	$
		LDY	URAFLG
		LDA	KOMO0AT,Y
		STA	ENMOD6,X
		LDA	KOMO0LF,Y
		STA	ENLIFE,X
		LDA	KOMO0IM,Y
		STA	ENMOD4,X
		RTS
;===========================================
HEBI0AT		EQU	$
		HEX	1,5
HEBI0LF		EQU	$
		HEX	4,8
HEBI0IM		EQU	$
		HEX	1,7
;
HEBI0IT		EQU	$
		LDY	URAFLG
		LDA	HEBI0AT,Y
		STA	ENMOD6,X
		LDA	HEBI0LF,Y
		STA	ENLIFE,X
		LDA	HEBI0IM,Y
		STA	ENMOD4,X
		RTS
;===========================================
MDARMITJ	EQU	$
		JSL	>MDARMIT
		JMP	XI01 
;===========================================
CTBOSITJ	EQU	$
		JSR	BOSSIT
;
		JSL	>CTBOSIT
		RTS
;===========================================
;===========================================
GANONITJ	EQU	$
		JSR	BOSSIT
;
		JSL	>GANONIT
		RTS
;===========================================
DRIXSD		EQU	$
		HEX	10,F0,10,F0
DRIYSD		EQU	$
		HEX	10,10,F0,F0
;
DARUMIT		EQU	$
		LDA	#03H
		STA	ENWRK0,X
		LDA	#08H
		STA	ENWRK1,X
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	DRIXSD,Y
		STA	ENXSPD,X
		LDA	DRIYSD,Y
		STA	ENYSPD,X
		RTS
;===========================================
EYETMIT		EQU	$
		JSR	BOSSIT
		RTS
;===========================================
AMEBAIT		EQU	$
		LDA	#10H
		STA	ENZPSL,X
		LDA	#08H
		STA	ENCTCT,X	; Tama life !
		RTS
;===========================================
OCBITM		EQU	$
		HEX	C0,D0,E0,F0
OCTBLIT		EQU	$
		TXA
		AND	#03H
		TAY
		LDA	OCBITM,Y
		STA	ENTIM0,X	; Break time !
		RTS
;===========================================
BARI1IT		EQU	$
		PHX
		LDX	<MPDTNO
		LDA	>GNDTBL,X
		PLX
		AND	#01000000B
		BEQ	B1I010	
;
		LDA	#04H
		STA	ENCHPT,X
;
B1I010		EQU	$
;
NAMAZIT		EQU	$
		JSR	XYRVS
;
		LDA	ENYPSL,X
		SEC
		SBC	#04H+8
		STA	ENYPSL,X
;
		JMP	NOST
;	RTS
;-----------------------
SDEMOITJ	EQU	$
		LDA	!EMYSTT+1
		AND	#01000000B
		BEQ	SDI010		; Seted ?
;					; yes ! not move !
		STZ	ENMODE,X
		RTS
SDI010		EQU	$
		JSL	>SDEMOIT
		JMP	NOST
;	RTS
;===========================================
EYEBSITJ		EQU	$
		JSR	BOSSIT
;
		JSR	XYRVS
;
		LDA	ENYPSL,X
		SEC
		SBC	#10H
		STA	ENYPSL,X
;
		JSL	>EYEBSIT
		JMP	NOST
;;		RTS
;---------------
KARASAT		EQU	$
		HEX	81,88
KARASLF		EQU	$
		HEX	4,8
KARASIM		EQU	$
		HEX	6,2
;
KARASIT		EQU	$
		LDY	URAFLG
		LDA	KARASAT,Y
		STA	ENMOD6,X
		LDA	KARASLF,Y
		STA	ENLIFE,X
		LDA	KARASIM,Y
		STA	ENMOD4,X
HAGE0IT		EQU	$
		LDA	#00H
		STA	ENZPSL,X
;
		LDA	ENXPSL,X
		AND	#00010000B
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	ENWRK0,X
		BRA	BGNOST
;;		RTS
;- - -
GOST0IT		EQU	$
		LDA	#0CH
		STA	ENZPSL,X
BGNOST		EQU	$
		LDA	#0FEH
		STA	HEMODE,X	; BG check noth.
;;		RTS
;- - -
LIKE0IT		EQU	$
		RTS
;---------------------------
TEKBBIT		EQU	$
		LDA	>DJNTBL+0ACH*2+1
		AND	#008H
		BNE	TKBIT10		;? BOSS KILLED
;					;N
		INC	ENNOCR,X	;beem thru

		LDA	>OPMODE
		CMP	#nashi
		BNE	TKBIT10
		LDA	#prnc1		;PL. BOMB MODE
		STA	>OPMODE
;
		PHX
		STZ	OPNOSI
		JSL	>OPTCBFST
		JSL	>RAOPIT		;PL. OPTION INIT
		PLX
;
		LDA	#nashi
		STA	>OPMODE
;
		RTS
;
TKBIT10		EQU	$
		STZ	ENMODE,X
		RTS
;---------------------------
HAYAMITJ	EQU	$
		JSL	>HAYAMIT
		RTS
;
;============================
PATA0IT		EQU	$
PATA1IT		EQU	$
		LDA	#10H
		STA	ENZPSL,X
		BRA	BGNOST
;- - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - -
;- - - - - - - - - - - - - - -
BAKDNIT		EQU	$
		INC	ENNOCR,X	; beem thru
;
		LDA	#BAKDN
		JSL	>ENIDSH
		BMI	BKNIT10
;
		LDA	<WORK0
		SEC
		SBC	#018H
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#000H
		STA	ENXPSH,Y
;
		LDA	<WORK2
		SEC
		SBC	#018H
		STA	ENYPSL,Y
		LDA	<WORK3
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	#001H		;S BOMB SET
		STA	ENCONT,Y
		STA	ENNOCR,Y	;beem thru
BKNIT10		EQU	$
		LDA	>ITMTBL3
		AND	#005H		;? DANJON CLS
		CMP	#005H
		BNE	BKNIT20
;
		LDA	>MODTBL4
		AND	#020H
		BEQ	BKNIT20
;
		LDA	#BAKDN
		JSL	>ENIDSH
		BMI	BKNIT20
;
		LDA	<WORK0
		SEC
		SBC	#038H
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#000H
		STA	ENXPSH,Y
;
		LDA	<WORK2
		SEC
		SBC	#018H
		STA	ENYPSL,Y
		LDA	<WORK3
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	#002H		;BIG BOMB SET
		STA	ENCONT,Y
		STA	ENNOCR,Y	;beem thru
BKNIT20		EQU	$
		RTS
;- - - - - - - - - - - - - - -
SITO0IT		EQU	$
		JSL	>SITO2ST
		INC	ENNOCR,X	; beem thru
		RTS
;- - - - - - - - - - - - - - -
TAKARIT		EQU	$
		LDA	>OPMODE
		CMP	#takar
		BEQ	TKRIT10
;
		LDA	>MODTBL4
		AND	#010H		;? TAKAR OPEN
		BNE	TKRIT10
;
		LDA	>MODTBL4	;? KAJIY END
		AND	#020H
		BEQ	TKRIT10
;
;		LDA	#takar		;TAKARA BOX
;		STA	>OPMODE
;
;		PHX
;		JSL	>OPTCBFST
;		PLX
;
;		LDA	#nashi		;KILL BOX
;		STA	>OPMODE
;
		INC	ENNOCR,X	; beem thru
;
		RTS
;
TKRIT10		EQU	$
KJYIT50		EQU	$
		STZ	ENMODE,X	;KILL I
		RTS
;- - - - - - - - - - - - - - -
KAJIYIT		EQU	$
		INC	ENNOCR,X	; beem thru
;
		LDA	>GDTRPF
		AND	#040H
		BEQ	KJYIT30
;					;URA 1 MAN KAJIY
		LDA	>MODTBL4
		AND	#020H
		BNE	KJYIT50
;
		LDA	>OPMODE
		CMP	#nashi
		BNE	KJYIT50
;
		LDA	#002H
		STA	ENCONT,X
;
;		LDA	#kajya		;PL. BOMB MODE
;		STA	>OPMODE
;
;		PHX
;		JSL	>OPTCBFST
;		JSL	>RAOPIT		;PL. OPTION INIT
;		PLX
;
;		LDA	#nashi
;		STA	>OPMODE
;
		RTS
;
KJYIT30		EQU	$
		JSL	>ULANIST	;ATARI SET
;
		LDA	>MODTBL4
		AND	#020H
		BNE	KJYIT40
		LDA	ENXPSL,X
		CLC
		ADC	#002H
		STA	ENXPSL,X
		LDA	ENYPSL,X
		SEC
		SBC	#003H
		STA	ENYPSL,X
;
		RTS
;
KJYIT40		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#002H
		STA	ENXPSL,X
		LDA	ENYPSL,X
		SEC
		SBC	#003H
		STA	ENYPSL,X
;
		JSR	KAJIYST		;KAJIY SET
		PHX
		PHY
		TYX
		JSL	>ULANIST	;ATARI SET
		PLY
		PLX
;
		TYA
		STA	ENWRK3,X
		TXA
		STA	ENWRK3,Y
		LDA	>MODTBL4
		AND	#080H
		BEQ	KJYIT10
;
		LDA	#005H		;KEN WATASU MODE
		STA	ENSTAT,X
		STA	ENSTAT,Y
;		RTS
;
KJYIT10		EQU	$
		LDA	>MODTBL4
		AND	#040H
		BEQ	KJYIT20
;
		LDA	#007H		;TATE WATASU MODE
		STA	ENSTAT,X
		STA	ENSTAT,Y
KJYIT20		EQU	$
		RTS
;----------------------------------------
KURODIT		EQU	$
		JSR	YPSRVS		; Ypos +8
KURORIT		EQU	$
		LDA	ENMYNO,X
		SEC
		SBC	#KUROR
		ASL	A
		STA	ENMUKI,X	; 0 or 2		
;
		DEC	ENCHPT,X	; Not chr init!
		RTS
;===========================================
MMDUYD		EQU	$
MMDUXD		EQU	$
		HEX	F8,08
;- - - - - - - - - - - - - - - - - - - - - -
MEMEDIT		EQU	$
MEMEUIT		EQU	$
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#08H
;;		STA	ENXPSL,X
		JSR	XRVS
;
		LDA	ENMYNO,X
		SEC
		SBC	#MEMER
		STA	ENMUKI,X
		TAY
;
		LDA	ENXPSL,X
		AND	#00010000B
		EOR	#00010000B
		STA	ENKBMK,X
;
		BNE	MDUI10
;
		LDA	ENYPSL,X
		CLC
		ADC	MMDUYD-2,Y
		STA	ENYPSL,X		
;
MDUI10		EQU	$
		RTS
;
;
MEMERIT		EQU	$
MEMELIT		EQU	$
		LDA	ENMYNO,X
		SEC
		SBC	#MEMER
		STA	ENMUKI,X
		TAY
;
		LDA	ENYPSL,X
		AND	#00010000B
		STA	ENKBMK,X
;
		BNE	MRLI10
;
		LDA	ENXPSL,X
		CLC
		ADC	MMDUXD,Y
		STA	ENXPSL,X		
;
MRLI10		EQU	$
		RTS
;- - - - - - - - - - - - - - -
HANA0IT		EQU	$
		LDA	#07H		; fast 
		BRA	HNI010
HANA1IT		EQU	$
		LDA	#0FH		; slow
HNI010		EQU	$
		STA	ENWRK1,X	; Move timing !(speed)
		RTS
;- - - - - - - - - - - - - - - - - -
SEKZ4IT		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	#007H
		STA	ENYPSL,X
;		LDA	ENYPSH,X
;		ADC	#000H
;		STA	ENYPSH,X
		RTS
;- - - - - - - - - - - - - - - - - -
ZOOL1IT		EQU	$
ZOOL2IT		EQU	$
		LDA	#06H
		STA	ENZPSL,X
;
		LDA	ERXYCT
		CMP	#0CEH
		BNE	ZLI1010		; Block in ?
;					; yes !
		DEC	ENWRK2,X
ZLI1010		EQU	$
		JMP	ZL0050	; TIM1 set !
;- - - - - - - - - - - - - - - - - -
TELSAIT		EQU	$
		LDA	#09H
		STA	ENZPSL,X
		RTS
;- - - - - - - - - - - - - - - - - -
REBA1IT		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	#005H
		STA	ENYPSL,X
;		LDA	ENYPSH,X
;		ADC	#000H
;		STA	ENYPSH,X
		RTS
;----------------------------------------
ARI01IT		EQU	$
		LDA	#ARI00
		STA	ENMYNO,X
		JSL	>ENMDST
;
		DEC	ENCTCT,X
;
;;		LDA	#EINIT
;;		STA	ENMODE,X
;
ARI00IT		EQU	$
		INC	ENCTCT,X
;
		LDA	#000H
		STA	ENTIM0,X
		LDA	#06H
		STA	ENCHPT,X
		JSR	NOST
;
;ARMSIST		EQU	$
;		LDA	ENTIM0,X
;		BNE	ARS010
;		LDA	#0FFH
;		STA	ENTIM0,X
;
		LDA	#ARI01
		JSL	>ENIDSH
		BMI	ARS010
;
		JSL	>ENIDPS
;
		LDA	#060H
		STA	ENTIM0,Y
;;		LDA	#01H
;;		STA	ENWRK0,Y
;;		LDA	#00H
;;		STA	ENCLOR,Y
;;		
		TYA
		STA	ENKBMK,X
;
		LDA	ENCTCT,X
		STA	ENCTCT,Y
		PHX
		TAX
		LDA	ARMSCL,X
		STA	ENCLOR,Y
		PLX
ARS010		EQU	$
		RTS
;
ARMSCL		EQU	$
		HEX	06,08
;- - - - - - - - - - - - - - - - - -
ZAKO0IT		EQU	$
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X
		STA	ENKBMK,X
;
		LDA	#10H
		STA	ENTIM0,X
;
		RTS
;- - - - - - - - - - - - - - - - - -
HODIRIT		EQU	$
HODILIT		EQU	$
HODIDIT		EQU	$
HODIUIT		EQU	$
		LDA	ENMYNO,X
		SEC
		SBC	#HODIR
		STA	ENMUKI,X	; chr muki
		AND	#02H
		STA	ENWRK0,X	; move muki
		RTS
;- - - - - - - - - - - - - - - - - -
YASANITJ	EQU	$
		JSL	>YASANIT
		RTS
;- - - - - - - - - - - - -- - - - 
NOCRST		EQU	$
BABAAIT		EQU	$
PENKIIT		EQU	$
MEIR0IT		EQU	$
MEIR1IT		EQU	$
NOPPOIT		EQU	$
MAJOOIT		EQU	$
PLCHKIT		EQU	$
TKBOYIT		EQU	$
SYOBYITJ        EQU     $
BWAKOIT		EQU	$
RYOKIIT		EQU	$
BEECKIT		EQU	$
JFISHIT		EQU	$
BGBM0IT		EQU	$
BGBM1IT		EQU	$
NOST		EQU	$
		INC	ENNOCR,X	; beem thru
		RTS
;;ARI00IT		EQU	$
;;		LDA	#000H
;;		STA	ENTIM0,X
;;		LDA	#06H
;;		STA	ENCHPT,X
;;		BRA	NOST
;
USAGIIT		EQU	$
OOOMUIT		EQU	$
		JSR	EPXCHK
		TYA
		STA	ENMUKI,X
DACHOIT		EQU	$
		LDA	>ITEMR13
		CMP	#02H
		BCC	DI0010	; Okarina have ?
;				; yes !
		STZ	ENMODE,X
DI0010		EQU	$
		BRA	NOST
;- - - - - - - - - - - - - - - - - -
ANAHOIT		EQU	$
		LDA	ENYPSL,X
		STA	<WORK0
		LDA	ENYPSH,X
		STA	<WORK1
		MEM16
		IDX8
		REP	#00100000B
		LDA	<PLYPS1
		CMP	<WORK0
		MEM8
		IDX8
		SEP	#00110000B
		BCS	AAOIT10
		LDA	#005H
		STA	ENSTAT,X
		LDA	ENXPSL,X
		SEC
		SBC	#009H
		STA	ENXPSL,X
		LDA	#001H
		STA	ENCHPT,X
AAOIT10		EQU	$
		INC	ENNOCR,X	; beem thru
		RTS
;- - - - - - - - - - - - - - - - - -
PLHINIT		EQU	$
		LDA	>GNDTBL+058H
		AND	#020H
		BEQ	PHNIT10
		STZ	ENMODE,X	;KILL I
PHNIT10		EQU	$
PLHIKIT		EQU	$
		INC	ENNOCR,X	; beem thru
		LDA	ENXPSL,X
		SEC
		SBC	#008H
		STA	ENXPSL,X
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,X
		RTS
;- - - - - - - - - - - - - - - - - -
SAMTMDT		EQU	$
		BYTE	00FH,010H,000H,006H,018H,012H,01EH,0FFH,01FH,023H
		BYTE	024H,025H,027H
;
SAMTMIT		EQU	$
		INC	ENNOCR,X	; beem thru
;
		LDA	ENMOD0,X
		ORA	#002H
		STA	ENMOD0,X
;
		LDA	ENCLOR,X	;COLOR SET
		ORA	#00CH
		STA	ENCLOR,X
;
		LDA	ENMOD2,X	;KAGE SET
		ORA	#010H
		STA	ENMOD2,X
;
		LDA	<RMXYCT
		LDY	#000H
SMMIT20		EQU	$
		CMP	SAMTMDT,Y
		BEQ	SMMIT10
		INY
		BNE	SMMIT20
SMMIT10		EQU	$
		TYA
		JSL	>JSRSUB
		WORD	SAMTMM0
		WORD	SAMTMM1
		WORD	SAMTMM2
		WORD	SAMTMM3
		WORD	SAMTMM4
		WORD	SAMTMM5
		WORD	SAMTMM6
		WORD	SAMTMM5
		WORD	SAMTMM5
		WORD	SAMTMM6
		WORD	SAMTMM7
		WORD	SAMTMM8
		WORD	SAMTMM6
;--
SAMTMM0		EQU	$		;A
		LDA	#000H		;POS 0
		LDY	#SMM10
		JSL	>SMM10ST
		LDA	#001H		;POS 1
		LDY	#SMM20
		JSL	>SMM10ST
		LDA	#002H		;POS 2
		LDY	#SMM60
		JSL	>SMM10ST
		RTS
SAMTMM1		EQU	$		;B
		LDA	#000H		;POS 0
		LDY	#SMM30
		JSL	>SMM10ST
		LDA	#001H		;POS 1
		LDY	#SMM70
		JSL	>SMM10ST
		LDA	#002H		;POS 2
		LDY	#SMM50
		JSL	>SMM10ST
		RTS
SAMTMM2		EQU	$		;MAN 100 TAKARA YA(1)
		LDA	#004H
		BRA	SMMM410
;--
SAMTMM3		EQU	$		;MAN TAKARA YA(2)
		LDA	#001H
		STA	ENCHPT,X
		BRA	SMMM410
;--
SAMTMM4		EQU	$		;MAN 20 TAKARA YA(1)
		LDA	#003H
SMMM410		EQU	$
		STA	ENCONT,X
		LDA	#0FFH
		STA	ATBXCT		;TAKARA CLOSE
		RTS
;--
SAMTMM5		EQU	$		;C
		LDA	#000H		;POS 0
		LDY	#SMM10
		JSL	>SMM10ST
		LDA	#001H		;POS 1
		LDY	#SMM40
		JSL	>SMM10ST
		LDA	#002H		;POS 1
		LDY	#SMM50
		JSL	>SMM10ST
		RTS
;--
SAMTMM6		EQU	$		;MAN 300
		LDA	#002H
SMMM610		EQU	$
		STA	ENCONT,X
		RTS
;--
SAMTMM7		EQU	$		;MAN MSGE 1
		LDA	#005H
		BRA	SMMM610
;--
SAMTMM8		EQU	$		;MAN MSGE 2
		LDA	#006H
		BRA	SMMM610
;- - - - - - - - - - - - - - - - - -
JOHOYDT		EQU	$
		BYTE	00EH,00EH,012H,01AH,014H
JOHOYIT		EQU	$
		INC	ENNOCR,X	; beem thru
;
		LDA	<RMXYCT
		LDY	#000H
JHYIT20		EQU	$
		CMP	JOHOYDT,Y
		BEQ	JHYIT10
		INY
		BNE	JHYIT20
JHYIT10		EQU	$
		TYA
		STA	ENCONT,X
		BNE	JHYIT30
		LDA	ENXPSH,X
		AND	#001H
		BEQ	JHYIT30
		INC	ENCONT,X
JHYIT30		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
JJIITDT		EQU	$
		BYTE	003H,0E1H,019H
JIJIIIT		EQU	$
		INC	ENNOCR,X	; beem thru
;
		LDA	<RMXYCT
		LDY	#000H
JJIIT20		EQU	$
		CMP	JJIITDT,Y
		BEQ	JJIIT10
		INY
		BNE	JJIIT20
JJIIT10		EQU	$
		TYA
		STA	ENCONT,X
		RTS
;- - - - - - - - - - - - - - - - - -
UZUMKIT		EQU	$
		INC	ENNOCR,X	; beem thru
		LDA	#001H
		STA	ENWRK0,X
		RTS
;- - - - - - - - - - - - - - - - - -
JITONITJ        EQU     $
		LDA	<RMXYCT
		CMP	#00AH
		BNE	JTNTJ10
		INC	ENCONT,X
		LDA	#00BH
		STA	ENCLOR,X
JTNTJ10		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
BOOK0DT		EQU	$
		BYTE	040H,020H
;
BOOK0IT		EQU	$
		LDA	<DJFLG
		BEQ	BO0IT40
;
		LDA	#002H		;TAKASA SET
		STA	ENKAIF,X
;
		LDA	<RMXYCT
		CMP	#007H
		BNE	BO0IT20
		LDA	<RMXYCT+1
		CMP	#001H
		BNE	BO0IT20
;
		LDA	>ITEMR15	;BOOK0
		BEQ	BO0IT10
		STZ	ENMODE,X
		RTS
;
BO0IT10		EQU	$
		PHX
		LDA	#00EH
		JSL	>ITMCBFST	;CHAR SET
		PLX
		RTS
;
BO0IT20		EQU	$		;KEY
		LDA	KAGIID		;KEY INDEX SET
		STA	KAGIFG,X
		TAY
;
		INC	KAGIID
;
		LDA	EMYSTT+1	;SAVE RAM SET
		AND	BOOK0DT,Y
		BEQ	BO0IT30
		STZ	ENMODE,X	;KILL I
;
BO0IT30		EQU	$
		INC	ENCHPT,X	;KEY MODE
		LDA	#008H
		STA	ENCLOR,X
		LDA	ENMOD2,X
		ORA	#020H
		STA	ENMOD2,X
;
		RTS
;
BO0IT40		EQU	$		;KIIII SET
		LDA	#002H
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - - - - - -
SARKKIT		EQU	$
		INC	ENNOCR,X	; beem thru
		PHX
		LDX	<MPDTNO		;? SET OK
		LDA	>GNDTBL,X
		PLX
		AND	#020H
		BEQ	SRKIT10		;? DOOR OPEN
		STZ	ENMODE,X	;KILL I
SRKIT10		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
SAKASIT		EQU	$
		INC	ENNOCR,X	; beem thru
;
		LDA	>OPMODE
		CMP	#hnoji
		BNE	SKSIT30
		STZ	ENMODE,X
		RTS
SKSIT30		EQU	$
;
;		LDA	>OPMODE
		CMP	#takar
		BNE	SKSIT10
;
		LDA	#002H		;TAKARA BOX OPEN MODE
		STA	ENSTAT,X
;
SKSIT10		EQU	$
		LDA	>MODTBL4
		AND	#010H
		BEQ	SKSIT20
		LDA	#004H		;BOX OPEN AFTER MODE
		STA	ENSTAT,X
SKSIT20		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
SINUBIT		EQU	$
		LDA	>ITEMR14
		BEQ	SNBIT10
;
		LDA	#003H
		STA	ENSTAT,X
;
SNBIT10		EQU	$
		INC	ENNOCR,X	; beem thru
		RTS
;- - - - - - - - - - - - - - - - - -
;;NOKOGIT		EQU	$
;;DEMONIT		EQU	$
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#008
;;		STA	ENXPSL,X
;;		INC	ENNOCR,X	; beem thru
;;		RTS
;- - - - - - - - - - - - - - - - - -
TEKTACL		EQU	$
		HEX	09,07
TEKTALF		EQU	$
		BYTE	08,12
TEKTAAT		EQU	$
		HEX	03,5
;
TEKTAIT		EQU	$
		LDA	ENXPSL,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	ENWRK0,X
		TAY
		LDA	TEKTACL,Y
		STA	ENCLOR,X
;
		LDA	TEKTALF,Y
		STA	ENLIFE,X
		LDA	TEKTAAT,Y
		STA	ENMOD6,X
		LDA	#10H
		JSR	PSERCH
		LDA	#20H
		STA	ENZSPD,X
		INC	ENSTAT,X
;
		RTS
;- - - - - - - - - - - - - - - - - -
WANWANIT	EQU	$
		JSL	>WANWANITJ
		RTS
;- - - - - - - - - - - - - - - - - -
IZUMIIT		EQU	$
		LDA	#18H
		STA	ENZPSL,X
		JSR	XYRVS
		JMP	NOST
;- - - - - - - - - - - - - - - - - -
JOHBBITJ        EQU     $
		LDA	ENYPSL,X
		CLC
		ADC	#008H
		STA	ENYPSL,X
NOKOGIT		EQU	$
DEMONIT		EQU	$
XRNST		EQU	$
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#008H
;;		STA	ENXPSL,X
		JSR	XRVS
		JMP	NOST
;
;;		INC	ENNOCR,X	; beem thru
;;		RTS
;- - - - - - - - - - - - - - - - - -
ULANIIT		EQU	$
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#008H
;;		STA	ENXPSL,X
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	#008H
;;		STA	ENYPSL,X
		JSR	XYRVS
;
		INC	ENNOCR,X	; beem thru
;		JSL	>ULANIST	;ATARI SET (KAJIY USE)
		RTS
;- - - - - - - - - - - - - - - - - -
RVCLDT		EQU	$
		HEX	0A,02
;
RIVERIT		EQU	$
		LDA	ENXPSL,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	ENWRK0,X
		TAY
		LDA	RVCLDT,Y
		STA	ENCLOR,X
		RTS
;- - - - - - - - - - - - - - - - - -
SLEEPIT		EQU	$
		LDY	#00FH
SLPIT10		EQU	$
		PHY
		JSR	SLEEPST
		PLY
		DEY
		BNE	SLPIT10
;
		LDY	#00FH
SLPIT20		EQU	$
		LDA	ENMYNO,Y
		CMP	#SLEEP
		BNE	SLPIT40
		LDA	#000H
		STA	ENMODE,Y
SLPIT40		EQU	$
		DEY
		BNE	SLPIT20
;
		JSR	HIIIIST
;
		TXY
		LDA	>MODTBL4		;SAVE RAM SET
		AND	#001H
		BEQ	SLPIT30
		LDA	#003H
		STA	ENSTAT+00
SLPIT30		EQU	$
		TYX
		LDA	#001H
		STA	ENNOCR+00	; beem thru
		RTS
;----------------------------------------
ATARSIT		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#06H
		STA	ENXPSL,X
		LDA	ENYPSL,X
		ADC	#06H
		STA	ENYPSL,X
		RTS
;- - - - - - - - - - - - - - - - - -
CHAN2IT		EQU	$
		LDY	#00H
		BRA	C23010
CHAN3IT		EQU	$
		LDY	#01H
C23010		EQU	$
		LDA	ENXPSL,X
        	EOR	#00010000B
		BRA	CHAI00
;- - - - - - - - - - - - - - - - - -
CHAN0IT		EQU	$
		LDY	#02H
		BRA	C01010
CHAN1IT		EQU	$
		LDY	#03H
C01010		EQU	$
		LDA	ENYPSL,X
CHAI00		EQU	$
		AND	#00010000B
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	ENSTAT,X
		BEQ	CHAI10		; big size ?
;					; yes !
		INC	ENMOD3,X
CHAI10		EQU	$
		TYA
		STA	ENMUKI,X
		RTS
;- - - - - - - - - - - - - - - - - -
;SPIMKD		EQU	$
;		HEX	1,3,2,0
;		HEX	5,7,4,6
;
;;		HEX	04,06
;;		HEX	00,02
;- - - - - - - - - - - - - - - - - -
;===================================================
CHIBIIT		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#04H
		STA	ENXPSL,X
;
		LDA	ENYPSL,X
		SEC
		SBC	#05H
		STA	ENYPSL,X
;
		LDA	ENYPSH,X
		SBC	#00H
		STA	ENYPSH,X
;;		RTS
SPARKIT		EQU	$
SPARLIT		EQU	$
;		LDA	#01H
;		STA	ENYSPD,X
;		STA	ENXSPD,X
;;
;		JSR	ENBGCK
;;
;		LDA	ENCBFG,X
;		CMP	#00000100B
;		BCS	SI0020
;;
;		LDY	#00H
;		AND	#00000010B
;		BEQ	SI0010
;		INY
;SI0010		EQU	$
;		BRA	SI0030
;;- - - - - - - - - - - - - - - - -
;SI0020		EQU	$
;		LDY	#02H
;		AND	#00001000B
;		BEQ	SI0030
;		INY
;SI0030		EQU	$
;		LDA	ENMYNO,X
;		CMP	#SPARL
;		BEQ	SI0050
;		INY
;		INY
;		INY
;		INY
;SI0050		EQU	$
;
;		LDA	ENXPSL,X
;		AND	#00010000B
;		LSR	A
;		LSR	A
;		LSR	A
;		ORA	<WORK0
;		TAY
;		LDA	SPIMKD,Y
;		STA	ENMUKI,X
;
		DEC	HEMODE,X	;BG check hosei nashi ! (FF)
		RTS
;- - - - - - - - - - - - - - - - - -
TRIXAL		EQU	$
		HEX	00,E0,F8,18,E8,18,D0,30,E8,18,E0,F8,18,00
;;		HEX	E0,F0,20,28
TRIXAH		EQU	$
		HEX	00,FF,FF,00,FF,00,FF,00,FF,00,FF,FF,00,00
;;		HEX	FF,FF,0,0
TRIYAL		EQU	$
		HEX	C0,D0,D8,D0,F0,F0,00,00,10,10,28,30,30,40
;;		HEX	E0,10,F0,20
TRIYAH		EQU	$
		HEX	FF,FF,FF,FF,FF,FF,00,00,00,00,00,00,00,00
;;		HEX	FF,0,FF,0
;- - - - - - - - - - - - - - - - - - - - - - - 
TORI0IT		EQU	$
		JSL	>RNDSET
		AND	#1FH
		SEC
		SBC	#10H
		STA	ENZSPD,X
        	LDA	#40H
		STA	ENZPSL,X
RISU0IT		EQU	$
;		LDA	#0EH
;		STA	ENHELP
;TRI000		EQU	$
;		LDA	#TORI0
;		JSL	>ENIDSH
;		PHX
;		LDX	ENHELP
;		LDA	<WORK0
;		CLC
;		ADC	TRIXAL,X
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		ADC	TRIXAH,X
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		CLC
;		ADC	TRIYAL,X
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		ADC	TRIYAH,X
;		STA	ENYPSH,Y
;		TYX
;		JSR	TRISUB
;		PLX
;		DEC	ENHELP
;		BPL	TRI000
;- - - - - - - - - - - - - - - - - - - - - - 
TRISUB		EQU	$
		JSR	EPXCHK
;
		LDA	#010H
;;		LDY	SCRMVX
		CPY	#00H
		BEQ	TRI010
		LDA	#0F0H
TRI010		EQU	$
		STA	ENXSPD,X
		LDA	#0FCH
		LDY	SCRMVY
		BPL	TRI020
		LDA	#004H
TRI020		EQU	$
		STA	ENYSPD,X
		STA	ENNOCR,X
;
;;		LDA	#40H
;;		STA	ENTIM1,X
		RTS
;- - - - - - - - - - - - - - - - - -
BBIXSD		EQU	$
		HEX	10,F0
;
BABULIT		EQU	$
;		INC	ENKBMK,X
;
;;		LDA	#10H
;;		STA	ENZPSL,X
BIGBLIT		EQU	$
		LDA	ENXPSL,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		TAY
		LDA	BBIXSD,Y
		STA	ENXSPD,X
		LDA	#0F0H
		STA	ENYSPD,X
		RTS
;- - - - - - - - - - - - - - - - - -
ICTAMIT		EQU	$
		JSR	BOSSIT
		INC	ENNOCR,X
		RTS
;- - - - - - - - - - - - - - - - - -
ZORABIT		EQU	$
		LDA	>ITEMR23
		BEQ	ZBI000		; Player Already ashihire have ?
;					; yes ! not set !
		STZ	ENMODE,X
		RTS
;- - - - - - - - - - - - - - - - - - - -
;;		CPX	#00H
;;		BEQ	ZBI000
;;;
;;		STZ	ENMODE,X
;;;
;;		LDA	#ZORAB
;;		LDY	#00H
;;		JSL	>ENIDSH2
;;;
;;		LDA	#EINIT
;;		STA	ENMODE
;;		LDA	<WORK0
;;		STA	ENXPSL
;;		LDA	<WORK1
;;		STA	ENXPSH
;;		LDA	<WORK2
;;		STA	ENYPSL
;;		LDA	<WORK3
;;		STA	ENYPSH
;;;
;;		RTS
;
ZBI000		EQU	$
;7/23			JSR	BOSSIT
;
;;		LDA	#0A0H
;;		STA	ENTIM0,X
		JMP	NOST
;;;		RTS
;- - - - - - - - - - - - - - - - - -
BOSSIT		EQU	$	; Boss initial check 
		LDA	EMYSTT+1
		BPL	BSI010	; BOSS FAILED ?
		PLA		; YES ! DONT MOVE !
		PLA
		STZ	ENMODE,X
		RTS
BSI010		EQU	$
;- - - - - - - - - - - - - - - - - - - - - -
		LDY	#ENNO-1
BSI020		EQU	$
		PHX
		LDX	ENMYNO,Y
		LDA	>ENMDD6,X
;;;		LDA	ENMOD6,Y
		PLX
		AND	#00010000B
		BNE	BSI030
;
;		LDA	ENMYNO,Y
;		CMP	#DOMOO
;		BEQ	BSI030
;		CMP	#BGBM0
;		BEQ	BSI030
;		CMP	#ICTAM
;		BEQ	BSI030
;		CMP	#ICEBG
;		BEQ	BSI030
;		CMP	#ICBOS
;		BEQ	BSI030
;		CMP	#PATAM
;		BEQ	BSI030
;		CMP	#PATAR
;		BEQ	BSI030
;		CMP	#KAMBS
;		BEQ	BSI030
;		CMP	#KAMBB
;		BEQ	BSI030
;		CMP	#KAMBR
;		BEQ	BSI030
;		CMP	#YOSEI
;		BEQ	BSI030
;		CMP	ENMYNO,X
;		BEQ	BSI030		; Teki nokori ?
;					; YES ! CLEAR !
		LDA	#00H
		STA	ENMODE,Y
BSI030		EQU	$
		DEY
		BPL	BSI020
		RTS
;- - - - - - - - - - - - - - - - - -
NOMOSIT		EQU	$
		JSR	BOSSIT
;
		LDA	#0FFH
		STA	ENTIM0,X
;
		INC	NMFLCT	; Set count !
;
		JMP	XYRVS
;-----------------------------------------
SEKMVIT		EQU	$
		LDA	MDBMCT
		STA	ENWRK0,X
		INC	MDBMCT
;
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	#08H
;;		STA	ENYPSL,X
;;;
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#08H
;;		STA	ENXPSL,X
;
		JSR	XYRVS
;
		LDA	ENXPSL,X
		LDY	#01H
		CMP	#030H
		BCC	SKI010		
;
		INY
		CMP	#0E0H
		BCS	SKI010
		INY
SKI010		EQU	$
		TYA
		STA	ENMUKI,X
DOZOOIT		EQU	$
;;		LDA	ENCLOR,X
;;		AND	#11110001B
;;		LDA	#00001101B
;;		STA	ENCLOR,X
		RTS
;- - - - - - - - - - - - - - - - - -
OCTA1AT		EQU	$
OCTA3AT		EQU	$
		HEX	3,5
OCTA1LF		EQU	$
		HEX	2,4
OCTA3LF		EQU	$
		HEX	4,8
;
OCTA1IT		EQU	$
		LDY	URAFLG
		LDA	OCTA1LF,Y
		BRA	OCIT10
OCTA2IT		EQU	$
OCTA3IT		EQU	$
		LDY	URAFLG
		LDA	OCTA3LF,Y
OCIT10		EQU	$
		STA	ENLIFE,X
;
		LDA	OCTA3AT,Y
		STA	ENMOD6,X
;
		JSL	>RNDSET
		AND	#7FH
		STA	ENTIM0,X
		RTS
;- - - - - - - - - - - - - - - - - -
HAYABITJ	EQU	$
		JSR	BOSSIT
;
		INC	ENNOCR,X
;
		JSL	>HAYABIT
		RTS
;- - - - - - - - - - - - - - - - - -
RANEMITJ	EQU	$
		JSR	BOSSIT
;
		JSL	>RANEMIT
		RTS
;- - - - - - - - - - - -- - - - - - - -
;- - - - - - - - - - - -
TRAP0IT		EQU	$
		JSR	XYRVS
		BRA	XI01
;
ZORASIT		EQU	$
		LDA	#40H
		STA	ENTIM0,X
SUNA0IT		EQU	$
;XRVS		EQU	$
		LDA	#08H
XI00		EQU	$
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,X
;
;- - - - - - - - - - - - - - - - - - - 
USAG0IT		EQU	$
FISH0IT		EQU	$
XI01		EQU	$
		LDA	ENXPSL,X
		STA	ENWRK0,X
		LDA	ENXPSH,X
		STA	ENWRK1,X
		LDA	ENYPSL,X
		STA	ENWRK2,X
		LDA	ENYPSH,X
		STA	ENKBMK,X
		RTS
;- - - - - - - - - - - - - - - - - - - 
;USAG0IT		EQU	$
;		LDA	#00H
;		BRA	XI00
;- - - - - - - - - - - - - - - - - - - 
ZORA2IT		EQU	$
		LDA	#60H
		STA	ENTIM0,X
		RTS
;- - - - - - - - - - - -- - - - - - - -
ZIRTS		EQU	$
		ASL	ENMOD4,X	; Hole check on !!
		LSR	ENMOD4,X
		RTS
;- - - - - - - - - - - -- - - - - - - -
;;HEIMKD		EQU	$
;;		BYTE	01H,03H
;
;H0ITPT		EQU	$
;		HEX	0B,04,00,07
;
HEIS0IT		EQU	$
HEI00IT		EQU	$
HEIS1IT		EQU	$
;;		JSL	>RNDSET
;;		AND	#1FH
;;		STA	ENTIM0,X
;;		AND	#01H
;;		STA	ENSTAT,X
		LDA	HEMODE,X
		BEQ	HEI010
		LDY	#00H
		AND	#00000111B
		CMP	#00000101B
		BCS	HEI030
		DEC	A
		EOR	#00000001B
		STA	ENMUKI,X
;
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		TAY
;;		LDA	HEIMKD-1,Y
;;		STA	ENMUKI,X
HEI010		EQU	$
                LDA     <DJFLG
                BNE     ZIRTS   ; Chijyo ?
;;                BNE     HEI020  ; Chijyo ?
;                               ; yes ! muki -> player initial !
                LDA     #01H
                STA     ENSTAT,X
                LDA     #70H
                STA     ENTIM0,X
;
                JSR     EPXYCK
                TYA
                STA     ENMUKI,X
                STA     ENKBMK,X
;
;                LDA     H0ITPT,Y
;                STA     ENCHPT,X
HEI020          EQU     $
;
HEYA0IT		EQU	$
HEYA1IT		EQU	$
HEYA2IT		EQU	$
HEYA3IT		EQU	$
HEBO0IT		EQU	$
HEIS2IT		EQU	$
HEIS3IT		EQU	$
;;		LDA	SLMODE
;;		CMP	#MD_djply
;;		BNE	HI0010		; Danjyon ?
;		LDA	<DJFLG
;		BEQ	HI0010
;;					; yes ! center BG check ari !
;		ASL	ENMOD4,X
;		LSR	ENMOD4,X
;HI0010		EQU	$
		BRA	HEIST
;;		RTS
; - -kabemawari set -- 
HEI030		EQU	$
		BEQ	HEI040
		LDY	#04H
HEI040		EQU	$
		LDA	HEMODE,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		STA	<WORK0
		TYA
		ORA	<WORK0
		TAY
		LDA	HEIMKD,Y
		STA	ENWRK1,X
;
		LDA	ENMOD7,X	;BG hit range set !
		AND	#0FH
		ORA	#50H
		STA	ENMOD7,X
HEIST		EQU	$
		LDA	<GAMEMD
		PHA
		STZ	<GAMEMD
		SEC
		ROR	ENMOD5,X
		JSR	ENMOVE
		JSR	ENMOVE
;;		HEX	EA,EA,EA
		ASL	ENMOD5,X
		PLA
		STA	<GAMEMD
		RTS
;- - - - - - - - -
HEIMKD		EQU	$
		BYTE	0,2,1,3
		BYTE	6,4,5,7
;----------------------------------------
WOOD1IT		EQU	$
		INC	ENNOCR,X	; beem thru
		LDA	ENXPSL,X
		SEC
		SBC	#008H
		STA	ENXPSL,X
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,X
;
		LDA	#000H		;EYE
		JSL	>WOEYEST
		LDA	#001H		;EYE
		JSL	>WOEYEST
		RTS
;----------------------------------------
TAAMAIT		EQU	$
		LDA	>TAMAFLG
		AND	#001H
		TAY
		LDA	TAAMACL,Y
		ORA	ENCLOR,X
		STA	ENCLOR,X
		RTS
;----------------------------------------
MURONIT		EQU	$
;		LDA	#007H
;		STA	ENWRK0,X
;		LDA	#001H
;		STA	ENATCT,X
;		RTS
;----------------------------------------
KUTUUIT		EQU	$
		INC	ENNOCR,X	;beem thru
;
		LDA	>GDTRPF		;URA OR OMOTE
		ASL	A
		ROL	A
		ROL	A
		AND	#001H
		STA	ENCONT,X
		BEQ	KTUIT10
;
		LDA	>MODTBL4
		AND	#008H
		BNE	KTUIT50
;
		LDA	>ITEMR13
		CMP	#002H
		BCC	KTUIT30
		BEQ	KTUIT40
;
KTUIT50		EQU	$
		LDA	#003H
		STA	ENCHPT,X
;
		LDA	#005H
		STA	ENSTAT,X
		BRA	KTUIT30
;
KTUIT40		EQU	$
		LDA	#001H
		STA	ENCHPT,X
KTUIT30		EQU	$
;
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#008H
;;		STA	ENXPSL,X
		JSR	XRVS
		LDA	ENYPSL,X
		SEC
		SBC	#008H
		STA	ENYPSL,X
		RTS
KTUIT10		EQU	$
		LDA	>ITEMR13
		CMP	#002
		BCC	KTUIT20
		STZ	ENMODE,X
		RTS
KTUIT20		EQU	$
SKNIT10		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#007H
		STA	ENXPSL,X
		RTS
;
ICMANIT		EQU	$
YPSRVS		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	#008H
		STA	ENYPSL,X
;;		LDA	ENYPSH,X
;;		ADC	#000H
;;		STA	ENYPSH,X
TEKI0IT		EQU	$
TEKI1IT		EQU	$
		RTS
;============================
SEKBNIT		EQU	$
		INC	ENNOCR,X
;
		LDA	<MPDTNO
		CMP	#030H
		BEQ	SKNIT10
		RTS
;============================
SKEL2IT		EQU	$
		LDA	ENXPSL,X
		AND	#00010000B
		STA	HEMODE,X	; Hone shot on off !
		BEQ	SK2I10
;
		LDA	#07H
		STA	ENCLOR,X
SK2I10		EQU	$
		RTS
;============================
ICEBGIT		EQU	$
		JSR	BOSSIT
;
		LDA	#0C0H
		STA	ENTIM1,X
		BRA	XYRVS
;============================
ICBOSIT		EQU	$
		JSR	BOSSIT
;
		LDA	#03H
		STA	ENSTAT,X
;
		JSR	NOST
;
;;		PHX
;;		JSL	>ICECGRST
;;		PLX
		BRA	XYRVS
;----------------------------------------
BYOYNIT		EQU	$
		JSR	NOST
;
XYRVS		EQU	$
		PHX
		TXA
		CLC
		ADC	#ENNO
		TAX
		JSR	YPSRVS	;X
		PLX
		BRA	YPSRVS	;Y
;----------------------------------------
;=========================================
;=========================================
MNICLD		EQU	$
		HEX	06,08
MNILFD		EQU	$
		BYTE	032,06
MNISDT		EQU	$
		HEX	10,0C 
MNISHS		EQU	$		; SERCH SPEED
		HEX	01,03	
MNIITS		EQU	$
		HEX	2,6
MNIATD		EQU	$
		HEX	5,3
;- - - - - - - - - - - - - - -
MOTS0IT		EQU	$
;;		PHX
;;		LDA	ENXPSL,X
;;		LDX	#00H
;;MN1I10		EQU	$
;;		STA	>KRXBUF,X
;;		DEX
;;		BNE	MN1I10
;;;
;;		LDA	ENYPSL,X
;;MN1I20		EQU	$
;;		STA	>KRYBUF,X
;;		DEX
;;		BNE	MN1I20
;;		PLX
		LDY	#00H
		LDA	ENXPSL,X
		AND	#00010000B
		BEQ	MNI010
		INY
MNI010		EQU	$
		LDA	MNICLD,Y
		STA	ENCLOR,X
;;		LDA	MNIATD,Y
;;		LDA     #01H
;;		STA	ENMOD6,X
		LDA	MNILFD,Y
		STA	ENMOD1,X
		LDA	MNISDT,Y
		STA	ENWRK0,X
		LDA	MNISHS,Y
		STA	ENSTAT,X
		LDA	MNIITS,Y
		STA	ENMOD4,X
		LDA	MNIATD,Y
		STA	ENMOD6,X
		RTS
;- - - - - - - - - - - - - - - -
MOTS1IT		EQU	$
		LDA	#10H
		STA	ENWRK0,X
		LDA	#01H
		STA	ENSTAT,X
		RTS
;=========ITEM INITIAL =====================
;;ITCSMP		EQU	$
;;		BYTE	0,0,0,0,0,0,0,0,0,0,0,0,4,2,2,2
;;		BYTE	0,0,0,0,0,0,0
;----------------------------------------
YOSEIIT		EQU	$
		JSL	>RNDSET
		AND	#001H
		STA	ENWRK0,X
		EOR	#001H
		STA	ENMUKI,X
;;		BRA	ITEM1IT
ITEM1IT		EQU	$
;;		LDY	ENMYNO,X
;;		LDA	ITCSMP-HART1,Y
;;		STA	EIPONT
;
		LDA	<DJFLG
		BNE	II0010		; chijyou ?
;					; yes !
HACHIIT		EQU	$
RINGOIT		EQU	$
		INC	ENWRK3,X	; init see thru
		INC	ENNOCR,X	; beem thru
;
;;		TXA
;;		AND	#03H
;;		ASL	A
;;		ADC	ENXPSL,X
;;		STA	ENXPSL,X
II0010		EQU	$
PTATEIT		EQU	$
		RTS
;----------------------------------------
BEE00IT		EQU	$
		LDA	>BINCT0
		ORA	>BINCT1
		ORA	>BINCT2
		ORA	>BINCT3
		AND	#008H
		BEQ	BE0IT10
		STZ	ENMODE,X
BE0IT10		EQU	$
		INC	ENWRK3,X	; init see thru
		INC	ENNOCR,X	; beem thru
		RTS
;===================================================
SHCLDT		EQU	$
		HEX	0B,07
;
SHSAIIT		EQU	$
;		PHX
;		JSL	>MGMCGRS2	; CG initial !
;		PLX
;
		JSR	BOSSIT
;
;;;		LDA	#10H
		LDA	#00H
		STA	ENCHPT,X
		LDA	#03H
		STA	ENMUKI,X
;
		JSR	XYRVS
;
		LDY	URAFLG
		LDA	SHCLDT,Y
		STA	ENCLOR,X
SHTAMIT		EQU	$
HBTAMIT		EQU	$
AMENBIT		EQU	$
SKELTIT		EQU	$
CHFIRIT		EQU	$
BKFIRIT		EQU	$
MIIRAIT		EQU	$
KAM01IT		EQU	$
HANDSIT		EQU	$
SKELBIT		EQU	$
MOTAMIT		EQU	$
		RTS
;===================================================
MEDAMIT		EQU	$
MEDA2IT		EQU	$
                LDA     ERXYCT
                CMP     #00CH
                BEQ     MTEF0
                CMP     #01BH
                BEQ     MTEF0
                CMP     #04BH
                BEQ     MTEF0
                CMP     #06BH
                BNE     MTEF8
MTEF0		EQU	$
		INC	ENWRK1,X	; Copy medaman set !
;
		LDA	ENMYNO,X
		CMP	#MEDAM
		BNE	MTEF8
;
		STZ	ENMOD5,X
MTEF8		EQU	$
		RTS
;===================================================
BAAR0IT		EQU	$
BAAR1IT		EQU	$
		INC	ENWRK1,X
		JMP	NOST
;;		RTS
;===================================================
;
KAMBSITJ	EQU	$
KAMBRITJ	EQU	$
KAMBBITJ	EQU	$
		JSR	BOSSIT
;
		JSL	>KAMBSIT
;
		JSR	ESRSET
		RTS
;-------------------------------------
MOTSBITJ	EQU	$
		JSR	BOSSIT
;
;;		LDA	#02H
;;		STA	ENCHPT,X
;;		LDA	#080H
;;		STA	ENTIM0,X
;
		JSL	>MOTSBIT
;;		LDA	#40H
;;		STA	MTHANK
;;;
;;		LDA	#00H
;;		STA	MTANGL
;;		LDA	#01H
;;		STA	MTANGL+1
;
ESRSET		EQU	$
		LDY	#ENNO-1
		LDA	#00H
MBI010		EQU	$
		STA	ENMODES,Y
		DEY
		BPL	MBI010
;
		RTS
;===================================================
HARI0IT		EQU	$
		LDA	#020H
		STA	ENXSPD,X
;
ABATAIT		EQU	$
		LDA	#0F0H		; -1 dot riveise !
		STA	ENYSPD,X
		JSR	ENYCLC
		STZ	ENYSPD,X
		RTS
;===================================================
SLIMEIT		EQU	$
		LDA	#04H
		STA	ENCHPT,X
;
		JSR	NOST
		RTS
PATARIT		EQU	$
		JSR	BOSSIT
;
		STZ	PTHANK		; Hankei !
		STZ	PTATTM		; Atack time !
;
		LDA	#20H
		STA	ENZPSL,X
		JSL	>PATAMCTL
;
;;		INC	ENNOCR,X
		RTS
;===================================================
PATAMIT		EQU	$
		JSR	BOSSIT
;
		JSL	>RNDSET
		STA	ENCONT,X
;
		LDA	PTBFXL,X
		STA	ENXPSL,X
		LDA	PTBFXH,X
		STA	ENXPSH,X
		LDA	PTBFYL,X
		STA	ENYPSL,X
		LDA	PTBFYH,X
		STA	ENYPSH,X
		RTS
;===================================================
BIGKOIT		EQU	$
;;		CPX	#00H
;;		BNE	BKI010
;;;
;;		STZ	ENMODE,X
;;;
;;		LDA	#BIGKO		; For OAM Yuusen ! index chenge !
;;		JSL	>ENIDSH
;;;
;;		LDA	#EINIT
;;		STA	ENMODE,Y
;;;
;;		LDA	<WORK0
;;		STA	ENXPSL,Y
;;		LDA	<WORK1
;;		STA	ENXPSH,Y
;;		LDA	<WORK2
;;		STA	ENYPSL,Y
;;		LDA	<WORK3
;;		STA	ENYPSH,Y
;;		RTS
;;; - - - - - - - - - - - - - - - - -
;;BKI010		EQU	$
		JSR	BOSSIT
;
		LDA	#50H
		STA	ENTIM0,X
		INC	ENNOCR,X
		LDA	#02H
		STA	ENCHPT,X
		INC	BG1MFG
;
		LDA	#070H
		STA	ENWRK2,X	; Toge set start time set !
		RTS
;===================================================
BABU2ITJ	EQU	$
		JSL	>BABU2IT
		RTS
;===================================================
POLIWIT		EQU	$
;		JSL	>INITIAL_POLYGON	;POLYGON INIT
;		JSL	>POLIWCG		;POLYGON COLOR SET
		RTS
;===================================================
KAGI1IT		EQU	$
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#08H
;;		STA	ENXPSL,X
		JSR	XRVS
;
		LDA	#0FFH 
		STA	HEMODE,X
KAGI1I2		EQU	$
                PHX
                PHY
                LDA     #22H
                JSL     >ITMCBFST       ;Key character TR.
                PLY
                PLX
		BRA	KAGI0IT2
;-----------------------------------------------------
KAGI0IT		EQU	$
		LDA	#0FFH 
		STA	HEMODE,X
KAGI0IT2	EQU	$
		LDA	KAGIID
		STA	KAGIFG,X
;
		INC	KAGIID
;
		RTS
;=================================================================
ENMOVE		EQU	$
;;		STZ	EFLCHF		; All fail check ok !
;
;;		LDA	DJFLG
;;		BEQ	ENMV99
;;;
;;		LDA	<GAMEMD
;;		BNE	ENMV99
;;;
;;		LDA	ENGRNO,X
;;		CMP	ERXYCT
;;		BEQ	ENMV99
;;;
;;		STZ	ENMODE,X
;;		RTS
;;ENMV99		EQU	$
;;		LDA	ENMYNO,X
;;		CMP	#KTOBJ
;;		BEQ	ENMV98
;;;
;;		STZ	EFLCHF
;;ENMV98		EQU	$
;
		LDA	ENMYNO,X
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#00FFH
		ASL	A
		TAY
		LDA	ENMVAD,Y
		DEC	A
		PHA
		IDX8
		MEM8
		SEP	#00110000B
		RTS
;
;;		JSL	>JSRSUB
;- - - - - - - - - - - - - - - - - - - - - - - -
ENMVAD		EQU	$
;- casle -
		WORD	KARASMVJ
		WORD	HAGE0MVJ
		WORD	SKHEDMV
		WORD	00H    
		WORD	ESW02MVJ
		WORD	ESW03MVJ
		WORD	ESW12MVJ
		WORD	ESW04MVJ
;- ground -
		WORD	OCTA1MV
;;		WORD	OCTA2MV
		WORD	HAYABMVJ
		WORD	OCTA3MV
		WORD	NIWATMV
		WORD	OCTAMMV
		WORD	NYOROMV
		WORD	PAKKNMV
		WORD	OCTBLMV
		WORD	OCTSSMV
		WORD	HINO0MV
		WORD	BUTA0MV
		WORD	MOTS1MV
		WORD	PLHINMVJ
		WORD	BABULMV ;KWAUSMV
		WORD	JITONMVJ	;KWAU1MV
		WORD	SHIGEMV
		WORD	HAYAMMV
		WORD	GOST0MV
		WORD	KAJIYMV
		WORD	YATAMMV
		WORD	SEKZ4MV
		WORD	BEECKMV
		WORD	TAAMAMV
		WORD	SINUBMV
		WORD	NAME0MV
		WORD	REBA1MV
		WORD	LOPAAMV
                WORD	ZOOL1MV
                WORD	ZOOL2MV
		WORD	WOOD1MVJ
		WORD	MOTS0MV
		WORD	IWABOMV
		WORD	JOHOYMV
		WORD	JIJIIMVJ
		WORD	BABAAMVJ
		WORD	SLEEPMV
		WORD	NOKOGMVJ
		WORD	PENKIMVJ
		WORD	KUTUUMV
		WORD	MEIR0MVJ
		WORD	MEIR1MVJ
		WORD	ULANIMVJ
		WORD	NOPPOMVJ
		WORD	PLHIKMVJ
		WORD	ONNAAMVJ
		WORD	HIGEEMVJ
		WORD	MAJOOMVJ
		WORD	PLCHKMVJ
		WORD	KIANAMVJ
		WORD	SAKASMV
		WORD	DEMONMVJ
		WORD	BOOK0MVJ
		WORD	TKBOYMVJ
		WORD	BABA1MVJ
		WORD	ISHI0MV
		WORD	BARI0MVJ
		WORD	BARI1MVJ
		WORD	HEIS0MVJ
		WORD	HEI00MVJ
		WORD	HEIS1MVJ
		WORD	HEIS2MVJ
		WORD	HEIS3MVJ
		WORD	HEYA0MVJ
		WORD	HEYA1MVJ
		WORD	HEYA2MVJ
		WORD	HEYA3MVJ
		WORD	HEBO0MVJ
		WORD	ZAKO0MVJ
		WORD	SUNA0MVJ
		WORD	USAG0MVJ
		WORD	HANA0MVJ
		WORD	HANA1MVJ
		WORD	TAMA0MVJ
		WORD	DOZOOMVJ
		WORD	ZORABMVJ
		WORD	NOMOSMVJ
		WORD	RANEMMVJ
		WORD	ZORASMVJ
		WORD	ZORA2MVJ
		WORD	SEKMVMVJ
		WORD	KANI0MVJ
		WORD	TORI0MVJ
		WORD	RISU0MVJ
		WORD	SPARKMVJ
		WORD	SPARLMVJ
		WORD	CHAN0MVJ
		WORD	CHAN1MVJ
		WORD	CHAN2MVJ
		WORD	CHAN3MVJ
		WORD	MEDUSMVJ
		WORD	ATARSMVJ
		WORD	ARI00MVJ
		WORD	ARI01MVJ
		WORD	YASANMVJ
		WORD	HODIRMVJ
		WORD	HODILMVJ
		WORD	HODIDMVJ
		WORD	HODIUMVJ
		WORD	TEKU0MVJ
		WORD	TAIHOMVJ
		WORD	HYUUUMVJ
		WORD	NEZU0MVJ
		WORD	HEBI0MVJ
		WORD	KOMO0MVJ
		WORD	MOTAMMVJ
;
		WORD	RIVERMV
		WORD	BWAKOMV
		WORD	OYAGIMVJ
		WORD	BOUSIMVJ
		WORD	SYOBYMVJ
		WORD	HELP0MVJ
		WORD	BIGBLMV 
		WORD	JOHBBMVJ 
		WORD	HACHIMVJ 
		WORD	SHSAIMVJ 
		WORD	SHTAMMVJ 
		WORD	TELSAMVJ
		WORD	TRAP0MVJ
		WORD	BAAR0MVJ
		WORD	BAAR1MVJ
		WORD	HBTAMMVJ
		WORD	AMENBMVJ
		WORD	BABU2MVJ
		WORD	MEDAMMVJ
		WORD	MEDA2MVJ
		WORD	SKELTMVJ
		WORD	CHIBIMVJ
		WORD	CHFIRMVJ
		WORD	BIGKOMVJ
		WORD	BKFIRMVJ
		WORD	HARI0MVJ
		WORD	MIIRAMVJ
		WORD	PATARMVJ
		WORD	PATAMMVJ
		WORD	KAM01MVJ
		WORD	SLIMEMVJ
		WORD	HANDSMVJ
		WORD	SKELBMVJ
		WORD	MOTSBMVJ
		WORD	BYOYNMVJ
		WORD	AYASIMVJ
		WORD	MEMERMVJ
		WORD	MEMELMVJ
		WORD	MEMEDMVJ
		WORD	MEMEDMVJ
		WORD	PENGIMVJ
		WORD	FISH0MVJ
		WORD	MAGICMVJ
		WORD	KURORMVJ
		WORD	KURODMVJ
		WORD	DACHOMVJ
		WORD	USAGIMVJ
		WORD	OOOMUMVJ
		WORD	ICMANMVJ
		WORD	ICBOSMVJ
		WORD	ICEBGMVJ
		WORD	ICTAMMVJ
		WORD	TEKI0MVJ
		WORD	TEKI1MVJ
		WORD	SKEL2MVJ
		WORD	PATA0MVJ
		WORD	PATA1MVJ
		WORD	LIKE0MVJ
		WORD	POLIWMVJ 
		WORD	RINGOMVJ 
		WORD	HELP1MVJ 
		WORD	DOKN0MVJ 
		WORD	DOKN1MVJ 
		WORD	DOKN2MVJ 
		WORD	DOKN3MVJ 
		WORD	BEE00MVJ 
		WORD	SEKBNMVJ 
		WORD	TAKARMVJ 
		WORD	BAKDNMVJ 
		WORD	SARKKMVJ 
		WORD	TEKBBMVJ 
		WORD	D_0_9MVJ 
		WORD	SITO0MVJ 
		WORD	UZUMKMVJ 
		WORD	SAMTMMVJ 
		WORD	RYOKIMVJ 
		WORD	EYEBSMVJ 
		WORD	EYETMMVJ 
		WORD	EYEBMMVJ 
		WORD	NAMAZMVJ 
		WORD	SDEMOMVJ 
		WORD	IWAGOMVJ 
		WORD	AMEBAMVJ 
		WORD	TheftMVJ
		WORD	BGBM0MVJ
		WORD	BGBM1MVJ
		WORD	DARUMMVJ
		WORD	IZUMIMVJ
		WORD	TEKTAMVJ
		WORD	WANWANMVJ
		WORD	KAMBSMVJ
		WORD	KAMBRMVJ
		WORD	KAMBBMVJ
		WORD	CTBOSMVJ
		WORD	MDARMMVJ
		WORD	RINELMVJ
		WORD	DOOMOMVJ
		WORD	JFISHMVJ
		WORD	ABATAMVJ
		WORD	ANAHOMVJ
		WORD	GANONMVJ
		WORD	GANO2MVJ
;-- ITEM --
		WORD	HART1MV
        	WORD	RUPYRMV
		WORD	RUPYYMV
		WORD	RUPYBMV
		WORD	BOMB1MV
		WORD	BOMB2MV
		WORD	BOMB3MV
;;;   		WORD	NIKU1MV
;;;		WORD	NIKU2MV
;;;		WORD	OPTN1MV
		WORD	TUBO1MV
		WORD	TUBO2MV
;;;		WORD	CRYS1MV
;;;		WORD	TRYFRMV
;;;		WORD	TRYFYMV
;;;		WORD	TRYFBMV
;;;		WORD	SPESRMV
;;;		WORD	SPESYMV
;;;		WORD	SPESBMV
		WORD	YAAA1MV
		WORD	YAAA2MV
		WORD	YOSEIMV
		WORD	KAGI0MV
		WORD	KAGI1MV
		WORD	PTATEMV
		WORD	KINOKMVJ
		WORD	SUKASMVJ
		WORD	MJSY1MVJ
		WORD	UTUWAMVJ
		WORD	UTUBKMVJ
;----------------------------------------
		WORD	KTOBJMV
		WORD	LINE0MVJ
		WORD	OOISUMV
		WORD	LINE1MVJ
		WORD	LINE2MVJ
		WORD	LINE3MVJ
		WORD	MONORMVJ
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Hayamushi boss                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HAYABMVJ	EQU	$
		JSL	>HAYABMV
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Karas 		                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KARASMVJ	EQU	$
		JSL	>KARASMV
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Hagetaka 		                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HAGE0MVJ	EQU	$
		JSL	>HAGE0MV
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Iwaboo  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
IBCHPT		EQU	$
		HEX	0,1,0,1,2,2,3,3,4
IBCLDT		EQU	$
		HEX	40,40,00,00,00,40,00,40,00
;- - - - - - - - - - - - - - - - - - - -
IWABOMV		EQU	$
		LDA	ENTIM2,X
		BEQ	IB0000
;
		AND	#04H
		BNE	IB0F00
;
IB0E00		EQU	$
		LDY	#08H
		BRA	IB0001
;
IB0000		EQU	$
		LDA	ENSTAT,X
		CMP	#02H
		BEQ	IB0E00
IB0F00		EQU	$
		LDY	ENWRK0,X
IB0001		EQU	$
		LDA	IBCHPT,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	IBCLDT,Y	
		STA	ENCLOR,X
		JSR	EN1CST
;
		JSR	ENSTCK
;
		LDA	ENHNFG,X
		BNE	IB0012
;
		JSR	CRKNEN
		BCC	IB0012
;
		LDA	SOUND2
		BNE	IB0012
;
;;		JSL	>SDLRCE
;;		ORA	#0BH
;;		STA	SOUND2	;(S)
		LDA	#0BH
		JSL	>SDLRE2	;(S)
IB0012		EQU	$
		JSR	CRENPL2
		BCC	IB0015
;
		JSL	>PLOTCK
;
;		MEM16
;		REP	#00100000B
;		LDA	PLSVX1
;		STA	<PLXPS1
;		LDA	PLSVY1
;		STA	<PLYPS1
;		MEM8
;		SEP	#00100000B
;
		JSL	>DASHON		; Player dash reset !
IB0015		EQU	$
		LDA	ENHNFG,X
		CMP	#0EH
		BNE	IB0002
;
		LDA	#02H
		STA	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM1,X
		LDA	#40H
		STA	ENTIM2,X
IB0002		EQU	$
;;		LDA	ENSTAT,X
;;		CMP	#02H
;;		BEQ	IB0005
;
		JSR	ENHNSB
;
IB0005		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	IBSTOP
		WORD	IBWALK
		WORD	IBISHI
;-----------------------------------------------
IBWKXS		EQU	$
		HEX	20,E0  ;,00,00
IBWKYS		EQU	$
		HEX	00,00,20,E0
;- - - - -
IBSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	IBS010
;
		ASL	ENMOD0,X
		LSR	ENMOD0,X
		LDA	ENMOD5,X
		AND	#11111011B
		STA	ENMOD5,X
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
;
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#1FH
		ADC	#20H
		STA	ENTIM0,X
;
		INC	ENWRK1,X
		LDA	ENWRK1,X
		CMP	#04H
		BNE	IBS008
;
		STZ	ENWRK1,X
;
		JSR	EPXYCK
		TYA
		BRA	IBS00C
IBS008		EQU	$
		JSL	>RNDSET
		AND	#03H
IBS00C		EQU	$
		STA	ENMUKI,X
		TAY
		LDA	IBWKXS,Y
		STA	ENXSPD,X
		LDA	IBWKYS,Y
		STA	ENYSPD,X
;
IBS010		EQU	$
		RTS
;-----------------------------------------------
;
IBWALK		EQU	$
		LDA	ENTIM0,X
		BNE	IBW010
;
		STZ	ENSTAT,X
;
		LDA	#20H
		STA	ENTIM0,X
		RTS
IBW010		EQU	$
		JSR	ENMVCL
		JSR	ENBGCK
		LDA	ENCBFG,X
		BEQ	IBW020
;
		LDA	ENMUKI,X
		EOR	#01H
		BRA	IBS00C		
IBW020		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#01H
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ORA	<WORK0
		STA	ENWRK0,X
		RTS
;-------------------------------------------------
IBISHI		EQU	$
		LDA	ENMOD0,X
		ORA	#10000000B
		STA	ENMOD0,X
		LDA	ENMOD5,X
		ORA	#00000100B
		STA	ENMOD5,X
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X
;
		LDA	<FRCNT
		AND	#01H
		BNE	IBS030
;
		LDA	ENTIM1,X
		BNE	IBS020
;
		STZ	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
		RTS
IBS020		EQU	$
		CMP	#020H
		BNE	IBS028
;
		LDA	#40H
		STA	ENTIM2,X
IBS028		EQU	$
		RTS
IBS030		EQU	$
		INC	ENTIM1,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	NAME0 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NMCHPT		EQU	$
		HEX	0,1,0,1,2,3,4,5
NMCLDT		EQU	$
		HEX	40,40,00,00,00,00,00,00
;
NAME0MV		EQU	$
		LDA	ENCONT,X
		AND	#08H
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ORA	<WORK0
		TAY
		LDA	NMCHPT,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	NMCLDT,Y
		STA	ENCLOR,X
;
		JSR	EN1CST
		JSR	ENSTCK
		JSR	ENHNSB
;
		JSR	CREKEK
;;		JSR	CRKNEN
;;		JSR	CRENPL
;
		INC	ENCONT,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	NMSTOP
		WORD	NMWALK
;================================================
NMWKXS		EQU	$
;;		HEX	10,F0   ;,00,00
BTXSDT		EQU	$
;;		HEX	10,F0  ;,00,00
RVM2XS		EQU	$
		HEX	10,F0  ;,00,00
;
NMWKYS		EQU	$
;;		HEX	00,00,10,F0
BTYSDT		EQU	$
;;		HEX	00,00,10,F0
RVM2YS		EQU	$
		HEX	00,00,10,F0
;
;NMWKXS		EQU	$
;		HEX	10,F0   ;,00,00
;NMWKYS		EQU	$
;		HEX	00,00,10,F0
;
NMSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	NMS010
;
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#1FH
		ADC	#20H
		STA	ENTIM0,X
		AND	#03H
		STA	ENMUKI,X
NMSDST		EQU	$
		TAY
		LDA	NMWKXS,Y
		STA	ENXSPD,X
		LDA	NMWKYS,Y
		STA	ENYSPD,X
		RTS
NMS010		EQU	$
		CMP	#10H
		BNE	NMS030
;
		JSL	>RNDSET
;;		AND	#01H
		LSR	A
		BCS	NMS030
;
		JMP	NMBOST
;
;-----------------------------------------
NMWALK		EQU	$
		LDA	ENTIM0,X
		BNE	NMW010
;
		STZ	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
;
NMW010		EQU	$
		JSR	ENMVCL
		JSR	ENBGCK
		LDA	ENCBFG,X
		BEQ	NMW020
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
		JMP	NMSDST
NMW020		EQU	$
NMS030		EQU	$
		RTS
;========================================
NMBOST		EQU	$
		LDA	#HEBO0
		LDY	#0BH
		JSL	>ENIDSH2
		BMI	NBS010
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;
		JSL	>BOMBST
;
NBS010		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		GOST0 set                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GSTCLD		EQU	$
		HEX	40,00
;
GOST0MV		EQU	$
		LDA	ENXSPD,X
		ASL	A
		ROL	A
		AND	#01H
		STA	ENMUKI,X
		TAY
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	GSTCLD,Y
		STA	ENCLOR,X
;
		LDA	ENWRK3,X
		BNE	GST011
;
		LDA	ENFLCL,X
		ORA	#00110000B
		STA	ENFLCL,X	; Most pri !
;
GST011		EQU	$
		JSR	GSFLST		; Lanp set 
;
		MEM16
		REP	#20H
;M
		LDA	<OAMADR
		CLC
		ADC	#0004H
		STA	<OAMADR
		INC	<OSBADR
;M
		MEM8
		SEP	#20H
;
		DEC	ENMOD0,X
		JSR	EN1CST
		INC	ENMOD0,X
;
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	ENWRK3,X
		BEQ	GST018
;
		INC	ENZPSL,X
		LDA	ENZPSL,X
		CMP	#0CH
		BNE	GST017
		STZ	ENWRK3,X		
GST017		EQU	$
		RTS
;
GST018		EQU	$
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		INC	ENCONT,X
;
		JSR	ENMVCL
;
		LDA	<FRCNT
		LSR	A
		BCS	GSFL10
;
		LDA	ENCTCT,X
		AND	#01H
		TAY
		LDA	ENZSPD,X
		CLC
		ADC	GSZSAD,Y
		STA	ENZSPD,X
		CMP	GSZSLM,Y
		BNE	GSFL10
;
		INC	ENCTCT,X
GSFL10		EQU	$
		JSR	ENZCLC
;
		STZ	ENYSPD,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	GSFLY
		WORD	GSTURN		
;- - - - - - - - - - - - -
GSZSAD		EQU	$
GSTSAD		EQU	$
		HEX	01,FF
		HEX	02,FE
GSTSLM		EQU	$
		HEX	10,F0
		HEX	1C,E4
GSZSLM		EQU	$
		HEX	08,F8 
;-- -- -- -- -- -- --
GSFLY		EQU	$
		LDA	ENTIM0,X
		BNE	GSFL08
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#00001100B
		BNE	GSFL03
		JSR	EPYCHK
		TYA
		BRA	GSFL05
GSFL03		EQU	$
		JSL	>RNDSET
		AND	#01H
GSFL05		EQU	$
		STA	ENKBMK,X
GSFL08		EQU	$
		RTS
;- - - - - - - - - - - - - - - -
GSTYSD		EQU	$
		HEX	08,F8
;
GSTURN		EQU	$
		LDA	FRCNT
		LSR	A
		BCS	GST010
;
		LDA	ENCTFG,X
		AND	#01H
		CLC
		ADC	URAFLG
		ADC	URAFLG
		TAY
		LDA	ENXSPD,X
		CLC
		ADC	GSTSAD,Y
		STA	ENXSPD,X
		CMP	GSTSLM,Y
		BNE	GST010
;
		INC	ENCTFG,X
		STZ	ENSTAT,X
		JSL	>RNDSET
		AND	#1FH
		ADC	#10H
		STA	ENTIM0,X
GST010		EQU	$
		LDY	ENKBMK,X
		LDA	GSTYSD,Y
		STA	ENYSPD,X
		RTS
;=================================================
GSFLXD		EQU	$
		WORD	00009H,0FFFFH
GSFLCD		EQU	$
		HEX	7C,80,B7,80
;
GSFLST		EQU	$
		JSR	OAMCHK
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		STA	<WORK6
;
		LDA	ENMUKI,X
		ASL	A
		PHX
		TAX
		MEM16
		REP	#20H
;
		LDA	<WORK0
		CLC
		ADC	GSFLXD,X
		STA	(<OAMADR),Y
		CLC
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	#0009H
		INY
		STA	(<OAMADR),Y		
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	GSFS10
;
		LDA	#0F0H
		STA	(<OAMADR),Y
GSFS10		EQU	$
		LDX	<WORK6
		LDA	GSFLCD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORK5
		AND	#11110000B
		ORA	#00000010B
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORKF
		STA	(<OSBADR)
		PLX
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Haya mushi                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HYMXSD		EQU	$
		HEX	18,16,11,09
		HEX	00,F7,EF,EA
		HEX	E8,EA,EF,F7
		HEX	00,09,11,16
HYMYSD		EQU	$
		HEX	00,09,11,16
		HEX	18,16,11,09
		HEX	00,F7,EF,EA
		HEX	E8,EA,EF,F7
HYTRMK		EQU	$
		HEX	8,9,A,B,C,D,E,F,0,1,2,3,4,5,6,7
;
HAYAMMV		EQU	$
		JSL	>HAYAMCS
;
		JSR	ENSTCK
;
		LDA	ENHNFG,X
		BEQ	HM0000
;
		JSR	HAYAMITJ		; Shippo pos. rivise !
;
HM0000		EQU	$
		JSR	ENHNSB
;
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		INC	ENCONT,X
;
		LDY	ENMUKI,X
		LDA	HYMXSD,Y
		STA	ENXSPD,X
		LDA	HYMYSD,Y
		STA	ENYSPD,X
		JSR	ENMVCL
;
		JSR	ENBGCK
		LDA	ENCBFG,X
		BEQ	HYMF00
;
		JSL	>RNDSET
		LSR	A
		BCC	HYMFF0
;
		LDA	ENKBMK,X
		EOR	#0FFH
		INC	A
		STA	ENKBMK,X
;
HYMFF0		EQU	$
		LDY	ENMUKI,X
		LDA	HYTRMK,Y
		STA	ENMUKI,X
;
HYMF00		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HYMOVE
		WORD	HYTURN
		WORD	HYPTUR
;--------------------------------------------
HYMOVE		EQU	$
		LDA	ENTIM0,X
		BNE	HYM010
;
;;		LDA	#01H
		INC	A
		INC	ENCTCT,X
		LDY	ENCTCT,X
		CPY	#06H
		BNE	HYM008
;
		STZ	ENCTCT,X
;;		LDA	#02H
		INC	A
HYM008		EQU	$
		STA	ENSTAT,X
;
		JSL	>RNDSET
		AND	#02H
		DEC	A
		STA	ENKBMK,X
;
		JSL	>RNDSET
		AND	#1FH
		ADC	#20H
		STA	ENTIM0,X
HYM010		EQU	$
		RTS
;---------------------------------------------
HYTURN		EQU	$
		LDA	ENTIM0,X
		BNE	HYT010
;
		JSL	>RNDSET
		AND	#0FH
		ADC	#08H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
		RTS
HYT010		EQU	$
		AND	#03H
		BNE	HYT020
;
		LDA	ENMUKI,X
		CLC
		ADC	ENKBMK,X
		AND	#0FH
		STA	ENMUKI,X
HYT020		EQU	$
		RTS
;----------------------------------------------
HYPTUR		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	HYPT50
;
		LDA	#1FH
		JSR	PSERCH
		JSL	>MKCK16
;;		CLC
;;		ADC	#0CH
;;		AND	#0FH
		CMP	ENMUKI,X
		BNE	HYPT10			
;
		STZ	ENSTAT,X
		LDA	#30H
		STA	ENTIM0,X
		RTS
;
HYPT10		EQU	$
		PHP
		LDA	ENMUKI,X
		PLP
		BMI	HYPT20
		INC	A
		INC	A
HYPT20		EQU	$
		DEC	A
HYPT30		EQU	$
		AND	#0FH
		STA	ENMUKI,X
HYPT50		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%				  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BTCHPT		EQU	$
		HEX	6,4,0,2
BUTA0MV		EQU	$
;;		LDA	ENWRK1,X
;;		BEQ	TK1M01
;;;-;; - -  Tama - - - 
;;		JSR	BUTAMCS
;;;
;;		JSR	ENSTCK
;;;
;;		JSR	CRENPL
;;;
;;		JSR	ENMVCL
;;;
;;		JSR	ENBGCK
;;;
;;		LDA	ENCBFG,X
;;		BEQ	TTM010
;;;
;;		STZ	ENMODE,X
;;TTM010		EQU	$
;;		RTS
;;;- - -  Master - - - 
;;TK1M01		EQU	$
		JSR	BUTA0CS
;
		JSR	ENSTCK
;
		JSR	ENHNSB
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		JSR	ENMVCL
		JSR	ENBGCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BTSTOP
		WORD	BTWALK
		WORD	BTSHOT
;================================
;
BTWKTM		EQU	$
		HEX	10,20,30,40
;
BTSTOP		EQU	$
;- - - stop - - -
		LDA	ENTIM0,X
		BNE	ZKS010
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	BTWKTM,Y
		STA	ENTIM0,X
		INC	ENSTAT,X
;
ZKSDST		EQU	$
		LDA	ENKBMK,X
		STA	ENMUKI,X
;
		TAY
		LDA	BTXSDT,Y
		STA	ENXSPD,X
		LDA	BTYSDT,Y
		STA	ENYSPD,X
ZKS010		EQU	$
		RTS
;============================================
BTNXMK		EQU	$
		HEX	2,3,2,3,0,1,0,1
;
BTWALK		EQU	$
		LDA	ENCONT,X
		AND	#00000001B
		LDY	ENMUKI,X
		CLC
		ADC	BTCHPT,Y
		STA	ENCHPT,X		
;
		LDA	#0CH
;
		LDY	ENCBFG,X
		BNE	ZKW008
;
		LDA	ENTIM0,X
		BNE	ZKW010
;
		JSR	EPXYCK
		TYA
		CMP	ENMUKI,X
		BNE	ZKW018		; muki->player ?
;					; yes !
		INC	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
;
		BRA	ENSDCL
;- - - - - - - - - -
ZKW018		EQU	$
		LDA	#10H
ZKW008		EQU	$
		STA	ENTIM0,X
;
		JSL	>RNDSET
		AND	#01H
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ORA	<WORK0
		TAY
		LDA	BTNXMK,Y
		STA	ENKBMK,X
;
		STZ	ENSTAT,X
;
		INC	ENWRK2,X
		LDA	ENWRK2,X
		CMP	#04H
		BNE	ZKW00A		; Player serch time ?
;					; yes !
		STZ	ENWRK2,X
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;
;;		LDA	#10H
;;		STA	ENTIM0,X
ENSDCL		EQU	$
ZKW00A		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
ZKW00C		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - -
ZKW010		EQU	$
		DEC	ENWRK3,X
		BPL	ZKW020
;
		LDA	#0BH
		STA	ENWRK3,X
;
		INC	ENCONT,X
ZKW020		EQU	$
		RTS
;===================================
BTSHPT		EQU	$
		HEX	0B,0A,08,09
		HEX	07,05,00,02
;
BTSHOT		EQU	$
		LDY	ENMUKI,X
		LDA	ENTIM0,X
		BNE	BTS008
;
		STZ	ENSTAT,X
BTS008		EQU	$
		CMP	#10H
		BCS	BTS010
		CMP	#0FH
		BNE	BTS00A
;
		PHY
		JSR	BUTAMST
		PLY
;
		LDA	#20H
		STA	ENTIM1,X
BTS00A		EQU	$
		INY
		INY
		INY
		INY
BTS010		EQU	$
		LDA	BTSHPT,Y
		STA	ENCHPT,X
		RTS
;--------------------------------------
BYSXAL		EQU	$
		HEX	0B,FE,FD,0B
;BYSXAH		EQU	$
;		HEX	00,FF,FF,00
BYSYAL		EQU	$
		HEX	FD,FD,03,F5
BYSYAH		EQU	$
		HEX	FF,FF,00,FF
;- - - - -
BYSXSD		EQU	$
		HEX	20,E0  ;,00,00
BYSYSD		EQU	$
		HEX	00,00,20,E0
;- - - - - -
BUTAMST		EQU	$
		LDA	#YATAM
		JSL	>ENIDSH
		BMI	BYS090
;
		LDA	#03H
		STA	ENWRK0,Y
;
		PHX
		LDA	ENMUKI,X
		STA	ENMUKI,Y
		TAX
		LDA	<WORK0
		CLC
		ADC	BYSXAL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	BYSXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	BYSYAL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	BYSYAH,X
		STA	ENYPSH,Y
;
		LDA	BYSXSD,X
		STA	ENXSPD,Y
		LDA	BYSYSD,X
		STA	ENYSPD,Y
		PLX
;
BYS090		EQU	$
		RTS		
;===================================
BUTA0CD		EQU	$
;0
		WORD	0FFFEH,00003H
		HEX	91,80,00,00
		WORD	0FFFEH,0000BH
		HEX	90,80,00,00
		WORD	00000H,0FFF6H
		HEX	86,00,00,02
		WORD	00000H,00000H
		HEX	8A,00,00,02
;1
		WORD	0FFFEH,00007H
		HEX	91,80,00,00
		WORD	0FFFEH,0000FH
		HEX	90,80,00,00
		WORD	00000H,0FFF6H
		HEX	86,00,00,02
		WORD	00000H,00000H
		HEX	8A,40,00,02
;2
		WORD	00000H,0FFF7H
		HEX	84,00,00,02
		WORD	00000H,00000H
		HEX	A0,00,00,02
		WORD	0000BH,0FFFBH
		HEX	90,00,00,00
		WORD	0000BH,00003H
		HEX	91,00,00,00
;3
		WORD	00000H,0FFF7H
		HEX	84,00,00,02
		WORD	00000H,00000H
		HEX	A0,40,00,02
		WORD	0000BH,0FFF8H
		HEX	90,00,00,00
		WORD	0000BH,00000H
		HEX	91,00,00,00
;4
		WORD	0FFFCH,00008H
		HEX	80,00,00,00
		WORD	00004H,00008H
		HEX	81,00,00,00
		WORD	00000H,0FFF7H
		HEX	88,00,00,02
		WORD	00000H,00000H
		HEX	A6,00,00,02
;5
		WORD	0FFF7H,00006H
		HEX	80,00,00,00
		WORD	0FFFFH,00006H
		HEX	81,00,00,00
		WORD	00000H,0FFF8H
		HEX	88,00,00,02
		WORD	00000H,00000H
		HEX	A4,00,00,02
;6
		WORD	0000CH,00008H
		HEX	80,40,00,00
		WORD	00004H,00008H
		HEX	81,40,00,00
		WORD	00000H,0FFF7H
		HEX	88,40,00,02
		WORD	00000H,00000H
		HEX	A6,40,00,02
;7
		WORD	00011H,00006H
		HEX	80,40,00,00
		WORD	00009H,00006H
		HEX	81,40,00,00
		WORD	00000H,0FFF8H
		HEX	88,40,00,02
		WORD	00000H,00000H
		HEX	A4,40,00,02
;8
		WORD	0FFFDH,0FFFBH
		HEX	91,80,00,00
		WORD	0FFFDH,00003H
		HEX     90,80,00,00		
		WORD	00000H,0FFF6H
		HEX	86,00,00,02
		WORD	00000H,00000H
		HEX	A8,00,00,02
;9
		WORD	0000BH,0FFF5H
		HEX	90,00,00,00
		WORD	0000BH,0FFFDH
		HEX	91,00,00,00
		WORD	00000H,0FFF7H
		HEX	84,00,00,02
		WORD	00000H,00000H
		HEX	82,40,00,02
;A
		WORD	0FFFEH,0FFFDH
		HEX	80,00,00,00
		WORD	00006H,0FFFDH
		HEX	81,00,00,00
		WORD	00000H,0FFF7H
		HEX	88,00,00,02
		WORD	00000H,00000H
		HEX	A2,00,00,02
;B
		WORD	0000AH,0FFFDH
		HEX	80,40,00,00
		WORD	00002H,0FFFDH
		HEX	81,40,00,00
		WORD	00000H,0FFF7H
		HEX	88,40,00,02
		WORD	00000H,00000H
		HEX	A2,40,00,02
;- - - -
BTKBID		EQU	$
		HEX	8,8,0,0,8,8,8,8,8,8,8,8
BTKBCD		EQU	$
		HEX	88,88,86,84
BTKBAD		EQU	$
		HEX	40,00,00,00
;--------------------------------
BUTA0CS		EQU	$
                LDA     #00H
                XBA
                LDA     ENCHPT,X
                MEM16
                REP     #00100000B
                ASL     A
                ASL     A
                ASL     A
;
                ASL     A
                ASL     A
                ADC     #BUTA0CD
                STA     <WORK8
;
                MEM8
                SEP     #00100000B
;
                LDA     #04H
;;                STA     <WORK6
  ;;              STZ     <WORK7
;
                JSL     >SETOAML22
;
		LDA	ENTIM1,X
		BEQ	BTC090		; Yari clear ?
;					; YES !
		LDY	#03H
BTC088		EQU	$
		LDA	(<OSBADR),Y
		AND	#00000010B
		BNE	BTC070
;
		PHY
		TYA
		ASL	A
		ASL	A
		TAY
		INY
		LDA	#0F0H
		STA	(<OAMADR),Y
		PLY
;
BTC070		EQU	$
		DEY
		BPL	BTC088
;
BTC090		EQU	$
		LDY	ENCHPT,X
		LDA	BTKBID,Y
		TAY
                PHX
                LDA     ENKBMK,X
                TAX
                LDA     BTKBCD,X
		INY
		INY
                STA     (<OAMADR),Y
                INY
                LDA     (<OAMADR),Y
                AND     #10111111B
                ORA     BTKBAD,X
                STA     (<OAMADR),Y
                PLX
;
		JMP	SADWST
;	RTS
;===================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%				  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PKMKCD		EQU	$
		HEX	4,0,6,2
;
PAKKNMV		EQU	$
		LDY	ENMUKI,X
		LDA	ENWRK1,X
		CLC
		ADC	PKMKCD,Y
		STA	ENCHPT,X
		JSR	PAKKNCS
;
		JSR	ENSTCK
		JSR	ENHNSB
;
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		STZ	ENWRK1,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	PKSTOP
		WORD	PKWALK
;-------------------------------------------
PKWKXS		EQU	$
		HEX	08,F8,08,F8
		HEX	10,F0,10,F0
PKWKYS		EQU	$
		HEX	08,08,F8,F8
		HEX	10,10,F0,F0
PKWKTM		EQU	$
		HEX	20,30,40,50
;
PKSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	PKS010
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#00001100B
		LSR	A
		LSR	A
		TAY
		LDA	PKWKTM,Y
		STA	ENTIM0,X		
;
		DEC	ENWRK0,X
		BPL	PKS008
;
		LDA	#03H
		STA	ENWRK0,X
;
		LDA	#60H
		STA	ENTIM0,X
;
		INC	ENWRK2,X
;
		JSR	EPYCHK
		TYA
		ASL	A
		STA	<WORK0
		JSR	EPXCHK
		TYA
		ORA	<WORK0
		BRA	PKS00C
PKS008		EQU	$
		JSL	>RNDSET
		AND	#03H
PKS00C		EQU	$
		STA	ENMUKI,X
;
		RTS
PKS010		EQU	$
		AND	#00011000B
		BEQ	PKS020
		INC	ENWRK1,X
PKS020		EQU	$
		RTS
;-----------------------------------------------
PKWALK		EQU	$
		INC	ENWRK1,X
;
		JSR	ENMVCL
		JSR	ENBGCK
;
		LDA	ENCBFG,X
		BEQ	PKW020
;
		LDA	ENMUKI,X
		EOR	#03H
		STA	ENMUKI,X
PKW020		EQU	$
		LDY	ENMUKI,X
		LDA	ENWRK2,X
		BEQ	PKW028
		INY
		INY
		INY
		INY
PKW028		EQU	$
		LDA	PKWKXS,Y
		STA	ENXSPD,X
		LDA	PKWKYS,Y
		STA	ENYSPD,X
;
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#04H
		STA	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	PKW030
;
		STZ	ENZPSL,X
;
		LDA	ENTIM0,X
		BNE	PKW010
;
		STZ	ENSTAT,X
		STZ	ENWRK2,X
;
		LDA	#3FH
		STA	ENTIM0,X
		RTS	
;- - - - - - - - - - - - -
PKW010		EQU	$
		LDA	#14H
		STA	ENZSPD,X
;
PKW030		EQU	$
		RTS
;======================================================
PAKKNCD		EQU	$
;0
		WORD	00004H,0FFF8H
		HEX	8F,00,00,00
		WORD	0000CH,0FFF8H
		HEX	9F,00,00,00
		WORD	0FFFCH,00000H
		HEX	8C,00,00,02
		WORD	00004H,00000H
		HEX	8D,00,00,02
;1
		WORD	00004H,0FFF8H
		HEX	2B,00,00,00
		WORD	0000CH,0FFF8H
		HEX	3B,00,00,00
		WORD	0FFFCH,00000H
		HEX	28,00,00,02
		WORD	00004H,00000H
		HEX	29,00,00,02
;2
		WORD	0FFFCH,0FFF8H
		HEX	3C,00,00,00
		WORD	00004H,0FFF8H
		HEX	3D,00,00,00
		WORD	0FFFCH,00000H
		HEX	AA,00,00,02
		WORD	00004H,00000H
		HEX	AB,00,00,02
;3
		WORD	0FFFCH,0FFF8H
		HEX	3E,00,00,00
		WORD	00004H,0FFF8H
		HEX	3F,00,00,00
		WORD	0FFFCH,00000H
		HEX	AD,00,00,02
		WORD	00004H,00000H
		HEX	AE,00,00,02
;4
		WORD	0FFFCH,0FFF8H
		HEX	9F,40,00,00
		WORD	00004H,0FFF8H
		HEX	8F,40,00,00
		WORD	0FFFCH,00000H
		HEX	8D,40,00,02
		WORD	00004H,00000H
		HEX	8C,40,00,02
;5
		WORD	0FFFCH,0FFF8H
		HEX	3B,40,00,00
		WORD	00004H,0FFF8H
		HEX	2B,40,00,00
		WORD	0FFFCH,00000H
		HEX	29,40,00,02
		WORD	00004H,00000H
		HEX	28,40,00,02
;6
		WORD	00004H,0FFF8H
		HEX	3D,40,00,00
		WORD	0000CH,0FFF8H
		HEX	3C,40,00,00
		WORD	0FFFCH,00000H
		HEX	AB,40,00,02
		WORD	00004H,00000H
		HEX	AA,40,00,02
;7
		WORD	00004H,0FFF8H
		HEX	3F,40,00,00
		WORD	0000CH,0FFF8H
		HEX	3E,40,00,00
		WORD	0FFFCH,00000H
		HEX	AE,40,00,02
		WORD	00004H,00000H
		HEX	AD,40,00,02
;- - - - - - - - - - - - - - - -
PAKKNCS		EQU	$
                LDA     #00H
                XBA
                LDA     ENCHPT,X
                MEM16
                REP     #00100000B
                ASL     A
                ASL     A
                ASL     A
;
                ASL     A
                ASL     A
                ADC     #PAKKNCD
                STA     <WORK8
;
                MEM8
                SEP     #00100000B
;
                LDA     #04H
;;                STA     <WORK6
  ;;              STZ     <WORK7
;
                JSL     >SETOAML22
;
		JMP	SADWST
;	RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%				  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LOPAAMV		EQU	$
		JSR	LOPAACS
;
		JSR	ENSTCK
		JSR	ENHNSB
;
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		INC	ENCONT,X
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		STA	ENCHPT,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	LPSTOP
		WORD	LPJUMP
;---------------------------------
LPSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	LPS010
;
		LDA	#10H
		JSR	PSERCH
;
		JSL	>RNDSET
		AND	#0FH
		ADC	#14H
		STA	ENZSPD,X
;
		INC	ENSTAT,X
LPS010		EQU	$
		RTS
;---------------------------------
LPJUMP		EQU	$
		JSR	ENMVCL
		JSR	ENBGCK
;
		LDA	ENCBFG,X
		BEQ	LPJ008
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
LPJ008		EQU	$
		JSR	ENZCLC
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	LPJ010
;
		STZ	ENZPSL,X
;
		LDA	#30H
		STA	ENTIM0,X
		STZ	ENSTAT,X
LPJ010		EQU	$
		RTS
;=========================================
LOPAACD		EQU	$
;0
		WORD	00000H,0FFF8H
		HEX	26,00,00,00
		WORD	00008H,0FFF8H
		HEX	27,00,00,00
		WORD	00000H,00000H
		HEX	08,00,00,02
;1
		WORD	00000H,0FFF8H
		HEX	36,00,00,00
		WORD	00008H,0FFF8H
		HEX	37,00,00,00
		WORD	00000H,00000H
		HEX	0A,00,00,02
;2
		WORD	00000H,0FFF8H
		HEX	27,40,00,00
		WORD	00008H,0FFF8H
		HEX	26,40,00,00
		WORD	00000H,00000H
		HEX	08,40,00,02
;3
		WORD	00000H,0FFF8H
		HEX	37,40,00,00
		WORD	00008H,0FFF8H
		HEX	36,40,00,00
		WORD	00000H,00000H
		HEX	08,40,00,02
;- - - - - - - - - - - - - - - - - - - - -
LOPAACS		EQU	$
                LDA     #00H
                XBA
                LDA     ENCHPT,X
                MEM16
                REP     #00100000B
                ASL     A
                ASL     A
                ASL     A
		STA	<WORK0
;
                ASL     A
		ADC	<WORK0
                ADC     #LOPAACD
                STA     <WORK8
;
                MEM8
                SEP     #00100000B
;
                LDA     #03H
;;                STA     <WORK6
  ;;              STZ     <WORK7
;
                JSL     >SETOAML22
;
		JMP	SADWST
;	RTS
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%				  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HINO0MV		EQU	$
		JSR	HINO0CS
;
;;		LDA	<KEYA2
;;		AND	#0CH
;;		BEQ	HN0010
;;;
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#0CH
;;		BNE	HN0010
;;;
;;		STZ	ENCHPT,X
;;;
;;HN0010		EQU	$
;;		RTS
;
		JSR	ENSTCK
;
		LDA	ENHNFG,X
		BEQ	HN1000		; Damege ?
;					; yes ! fury !
		JSR	HNPLSH
		LDA	#02H
		STA	ENSTAT,X
		LDA	#30H
		STA	ENTIM0,X
HN1000		EQU	$
		JSR	ENHNSB
;
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HNSTOP
		WORD	HNWALK
		WORD	HNSHOT 
;=======================================================
HNSCPT		EQU	$
		HEX	B,A,8,9
		HEX	7,5,1,3
;
HNSHXL		EQU	$
		HEX	08,F8,F3,0D
HNSHXH		EQU	$
BYSXAH		EQU	$
NWATPS		EQU	$
;;		HEX	00,FF
		HEX	00,FF,FF,00
;;		HEX	00,FF,FF,00
HNSHYL		EQU	$
		HEX	F5,F5,F0,F0
;;HNSHYH		EQU	$
;;		HEX	FF,FF,FF,FF
;
HNSHXS		EQU	$
		HEX	18,E8  ;,00,00
HNSHYS		EQU	$
		HEX	00,00,18,E8
;
HNSHOT		EQU	$
		LDA	ENTIM0,X
		BNE	HNSH10
;
		STZ	ENSTAT,X
		LDA	#02H
		STA	ENTIM0,X
		RTS
;
HNSH10		EQU	$
		CMP	#20H
		BNE	HNSH20
;
		LDA	#HEBO0
		JSL	>ENIDSH
		BMI	HNSH18
;
		JSL	>BOMBST
;
		LDA	#40H
		STA	ENTIM1,Y
;
		PHX
		LDA	ENMUKI,X
		TAX
;
		LDA	<WORK0
		CLC
		ADC	HNSHXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	HNSHXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	HNSHYL,X
		STA	ENYPSL,Y
		LDA	<WORK3
;;		ADC	HNSHYH,X
		ADC	#0FFH
		STA	ENYPSH,Y
;
		LDA	HNSHXS,X
		STA	ENXSPD,Y
		LDA	HNSHYS,X
		STA	ENYSPD,Y
		PLX
		LDA	#28H
		STA	ENZSPD,Y
HNSH18		EQU	$
		RTS
HNSH20		EQU	$
		LDY	ENMUKI,X
		BCS	HNSH30
		INY
		INY
		INY
		INY
HNSH30		EQU	$
		LDA	HNSCPT,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - - - - - - - -
;HNNXMK		EQU	$
;		HEX	6 ;,7,0,1
;		HEX	7 ;,0,1,2
;		HEX	0 ;,1,2,3
;		HEX	1 ;,2,3,4
;		HEX	2 ;,3,4,5
;		HEX	3 ;,4,5,6
;		HEX	4 ;,5,6,7
;		HEX	5 ;,6,7,0
;------------------------------
HNXSDT		EQU	$
		HEX	08,F8  ;,00,00
;
;;		HEX	08,06,00,FA,F8,FA,00,06
HNYSDT		EQU	$
		HEX	00,00,08,F8
;
;;		HEX	00,06,08,06,00,FA,F8,FA
;;HNSHMK		EQU	$
;;		HEX	0,4,2,6
;
HNSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	HNS010
;
		JSL	>RNDSET
		AND	#03H
		BNE	HNSF00		; Bomb shot ?
;					; yes !
		LDA	#02H
		STA	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
		RTS
HNSF00		EQU	$
		INC	ENWRK2,X
		LDA	ENWRK2,X
		CMP	#04H
		BNE	HNS000		; Player serch time ?
;					; yes !
		STZ	ENWRK2,X
;
HNPLSH		EQU	$
		JSR	EPXYCK
;;		LDA	HNSHMK,Y
		TYA
		JSR	HNS008
		ASL	ENXSPD,X
		ASL	ENYSPD,X
;
		RTS
;- - - - - - - - - - - - - - -
HNNXMK		EQU	$
		HEX	2,3
		HEX	3,2
		HEX	0,1
		HEX	1,0
;
;;		HEX	2,6
;;		HEX	0,4
;;		HEX	2,6
;;		HEX	0,4
;
HNS000		EQU	$
;
;;		JSL	>RNDSET
;;		AND	#03H
;;;
;;		LDY	ENMUKI,X
;;		CLC
;;		ADC	HNNXMK,Y
;;		AND	#07H
;;HNS008		EQU	$
;;		STA	ENMUKI,X
		JSL	>RNDSET
;;		AND	#01H
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	HNNXMK,Y
HNS008		EQU	$
		STA	ENMUKI,X
;		
		JSL	>RNDSET
		AND	#3FH
		ADC	#60H
		STA	ENTIM0,X
;
		INC	ENSTAT,X
HNSDST		EQU	$
		LDY	ENMUKI,X
		LDA	HNXSDT,Y
;;		NOP	
		STA	ENXSPD,X
;
		LDA	HNYSDT,Y
;;		NOP
		STA	ENYSPD,X
;
HNS010		EQU	$
		RTS
;------------------------------
;;HNMKDT		EQU	$
;;		HEX	0,0,2,2,1,1,3,3,2,2
HNWKPT		EQU	$
		HEX	6,4,0,2
;
HNWALK		EQU	$
		LDA	ENTIM0,X
		BNE	HNW010
;
HNSTST		EQU	$
		LDA	#10H
		STA	ENTIM0,X
		STZ	ENSTAT,X
;
		RTS
HNW010		EQU	$
		DEC	ENWRK0,X
		BPL	HNW018
;
		LDA	#0BH
		STA	ENWRK0,X
;
		INC	ENCONT,X
HNW018		EQU	$
;;		LDA	ENCONT,X
;;		AND	#01H
;;		BNE	HNW020
;		
		JSR	ENMVCL
		JSR	ENBGCK
;
		LDA	ENCBFG,X
		BEQ	HNW020
;
;;		LDA	ENMUKI,X
;;		CLC
;;		ADC	#04H
;;		AND	#07H
;;		STA	ENMUKI,X
;;;
;;		LDA	#06H
;;		STA	ENTIM0,X
;;;
;;		JSR	HNSDST
;;		JSR	ENMVCL
;;		JSR	ENMVCL
		BRA	HNSTST 		
HNW020		EQU	$
		LDA	ENCONT,X
		AND	#01H
		STA	<WORK0
;
		LDY	ENMUKI,X
;;		LDA	HNMKDT,Y
;;		TAY
		LDA	HNWKPT,Y
		CLC
		ADC	<WORK0
		STA	ENCHPT,X
		RTS
;========================================
HINO0CD		EQU	$
;0
HINO0C0		EQU	$
		WORD	00000H,0FFF3H
		HEX	00,06,00,02
		WORD	0FFF8H,0FFFBH
		HEX	24,06,00,02
		WORD	00008H,0FFFBH
		HEX	24,46,00,02
		WORD	00000H,00001H
		HEX	06,06,00,02
;1
HINO0C1		EQU	$
		WORD	00000H,0FFF3H
		HEX	00,06,00,02
		WORD	0FFF8H,0FFFBH
		HEX	24,06,00,02
		WORD	00008H,0FFFBH
		HEX	24,46,00,02
		WORD	00000H,00001H
		HEX	06,46,00,02
;2
HINO0C2		EQU	$
		WORD	0FFF8H,0FFFAH
		HEX	24,06,00,02
		WORD	00008H,0FFFAH
		HEX	24,46,00,02
		WORD	00000H,00000H
		HEX	06,06,00,02
		WORD	00000H,0FFF3H
		HEX	04,06,00,02
;3
HINO0C3		EQU	$
		WORD	0FFF8H,0FFFAH
		HEX	24,06,00,02
		WORD	00008H,0FFFAH
		HEX	24,46,00,02
		WORD	00000H,00000H
		HEX	06,46,00,02
		WORD	00000H,0FFF3H
		HEX	04,06,00,02
;4
HINO0C4		EQU	$
		WORD	0FFFDH,0FFF3H
		HEX	02,06,00,02
		WORD	00000H,0FFF8H
		HEX	0C,06,00,02
		WORD	00000H,00000H
		HEX	1C,06,00,02		
;5
HINO0C5		EQU	$
		WORD	0FFFDH,0FFF4H
		HEX	02,06,00,02
		WORD	00000H,0FFF8H
		HEX	0E,06,00,02
		WORD	00000H,00000H
		HEX	1E,06,00,02		
;6
HINO0C6		EQU	$
		WORD	00003H,0FFF3H
		HEX	02,46,00,02
		WORD	00000H,0FFF8H
		HEX	0C,46,00,02
		WORD	00000H,00000H
		HEX	1C,46,00,02		
;7
HINO0C7		EQU	$
		WORD	00003H,0FFF4H
		HEX	02,46,00,02
		WORD	00000H,0FFF8H
		HEX	0E,46,00,02
		WORD	00000H,00000H
		HEX	1E,46,00,02		
HINO0C8		EQU	$
		WORD	0FFF3H,0FFF3H-03H
		HEX	6E,05,00,02
		WORD	00000H,0FFF3H
		HEX	00,06,00,02
		WORD	0FFF8H,0FFFBH
		HEX	20,06,00,02
		WORD	00008H,0FFFBH
		HEX	24,46,00,02
		WORD	00000H,00001H
		HEX	06,06,00,02
HINO0C9		EQU	$
		WORD	0FFF8H,0FFFBH
		HEX	24,06,00,02
		WORD	00008H,0FFFBH
		HEX	20,46,00,02
		WORD	00000H,00001H
		HEX	06,06,00,02
		WORD	00000H,0FFF3H
		HEX	04,06,00,02
		WORD	0000DH,0FFF3H-03H
		HEX	6E,05,00,02
HINO0CA		EQU	$
		WORD	0FFF8H,0FFF5H
		HEX	6E,05,00,02
		WORD	0FFFDH,0FFF3H
		HEX	02,06,00,02
		WORD	00000H,00000H
		HEX	22,06,00,02		
		WORD	00000H,0FFF8H
		HEX	0C,06,00,02
HINO0CB		EQU	$
		WORD	00008H,0FFF5H
		HEX	6E,05,00,02
		WORD	00003H,0FFF3H
		HEX	02,46,00,02
		WORD	00000H,00000H
		HEX	22,46,00,02		
		WORD	00000H,0FFF8H
		HEX	0C,46,00,02
;- - - - - - - - - - - - - - - - - - - - - - - - - -
HINO0AD		EQU	$
		WORD	HINO0C0
		WORD	HINO0C1
		WORD	HINO0C2
		WORD	HINO0C3
		WORD	HINO0C4
		WORD	HINO0C5
		WORD	HINO0C6
		WORD	HINO0C7
		WORD	HINO0C8
		WORD	HINO0C9
		WORD	HINO0CA
		WORD	HINO0CB
HINO0NO		EQU	$
		HEX	4,4,4,4,3,3,3,3,5,5,4,4
HINO0CS		EQU	$
		LDA	ENCHPT,X
                PHA
                ASL     A
                TAY
                MEM16
                REP     #20H
                LDA     HINO0AD,Y
                STA     <WORK8
                MEM8
                SEP     #20H
                PLY
                LDA     HINO0NO,Y
                JSL     >SETOAML22
;
;;                LDA     #00H
;;                XBA
;;                LDA     ENCHPT,X
;;                MEM16
;;                REP     #00100000B
;;                ASL     A
;;                ASL     A
;;                ASL     A
;;;
;;                ASL     A
;;                ASL     A
;;                ADC     #HINO0CD
;;                STA     <WORK8
;;;
;;                MEM8
;;                SEP     #00100000B
;;;
;;                LDA     #04H
;;;;                STA     <WORK6
;;  ;;              STZ     <WORK7
;;;
;;                JSL     >SETOAML22
;;;
                JMP     SADWST
;               RTS
;		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%				  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KOMAAD          EQU     $
JHYFESZ		EQU	$
HAXSDT		EQU	$
                BYTE    001H,0FFH
ZLMXSD          EQU     $
                BYTE    000H,008H,00BH,00EH,010H,00EH,00BH,008H
                BYTE    000H,-08H,-0BH,-0EH,-10H,-0EH,-0BH,-08H
ZLMYSD          EQU     $
                BYTE    -10H,-0EH,-0BH,-08H,000H,008H,00BH,00EH
                BYTE    010H,00EH,00BH,008H,000H,-09H,-0BH,-0EH
;
ZLSTXL		EQU	$
		HEX	00,08
ZLSTXS		EQU	$
		HEX	E0,20
ZLXRVS		EQU	$
		HEX	08,F8 
ZLCHAD		EQU	$
		HEX	00,03
ZOOL1MV		EQU	$
ZOOL2MV		EQU	$
		LDA	ENWRK2,X
		BEQ     ZL0MOV
		BPL	ZS0010		; Initial BG in ?
;					
		LDA	ENKBMK,X
		CMP	#10H
		BNE	ZS0009
;
		LDA	#0FFH
		STA	ENXSPD,X
		STA	HEMODE,X
		JSR	ENBGCK
		STZ	HEMODE,X
;;		LDA	ENCBFG,X
		LDA	UNITNO
		BNE	ZS0008		; BG out ?
;					; yes ! doomo !
		STZ	ENWRK2,X
		JMP	ZL0050		
ZS0008		EQU	$
		RTS
ZS0009		EQU	$
		INC	ENKBMK,X
		RTS
;
;
ZS0010		EQU	$
;
		JSR	EN1CSS
		BRA	ZL0000
ZL0MOV		EQU	$
		LDA	ENCHPT,X
		CMP	#02H
		BCC	ZL0F00
		JSR	EN1CST
		BRA	ZL0000
ZL0F00		EQU	$
		JSR	ZOOL1CS
ZL0000		EQU	$
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	ENTIM2,X
		BNE	ZL0038
;
		LDA	ENSTAT,X
		CMP	#02H
		BNE	ZL0001
;- - -Fail - -
		STA	ENNOCR,X
;
		LDA	<FRCNT
		LSR	A
		AND	#01H
		TAY
		LDA	ZLXRVS,Y
		STA	ENXSPD,X
		JSR	ENXCLC
;
		LDA	ENTIM0,X
		BNE	ZL00F0
;
		JSR	ZOOL1ST
;
		STZ	ENMODE,X
ZL00F0		EQU	$
		RTS
;- - -Move - -
ZL0001		EQU	$
;;		JSR	CRENPL
;;		JSR	CRKNEN
		JSR	CREKEK
;
		TXA
		EOR	<FRCNT
                AND     #0FH
                BNE     KOM020
;
                LDA     ENWRK1,X
                AND     #01H
                TAY
                LDA     ENWRK0,X
                CLC
                ADC     KOMAAD,Y
                STA     ENWRK0,X
;
                JSL     >RNDSET
                AND     #00000011B
                BNE     KOM020
;
                INC     ENWRK1,X
KOM020          EQU     $
                LDA     ENWRK0,X
                AND     #0FH
                TAY
                LDA     ZLMXSD,Y
                STA     ENXSPD,X
                LDA     ZLMYSD,Y
                STA     ENYSPD,X
;
		TXA
		EOR	<FRCNT
		AND	#03H
		ORA	ENTIM0,X
		BNE	ZL0020
;
ZL0038		EQU	$
		LDA	ENCBFG,X
		BNE	ZL0022
;
		JSR	ENMVCL
ZL0022		EQU	$
		JSR	ENBGCK
ZL0020		EQU	$
		LDY	ENWRK2,X
;
                LDA     <FRCNT
                LSR     A
                LSR     A
                LSR     A
                AND     #01H
		CLC
		ADC	ZLCHAD,Y
                STA     ENCHPT,X	;(0,1)
;
		LDA	ENSTAT,X
		BEQ	ZL0030
;
		LDA	ENTIM0,X
		BNE	ZL0028
;
		STZ	ENSTAT,X
		BRA	ZL0050
ZL0028		EQU	$
;
                LDA     <FRCNT
                LSR     A
		AND	#02H
		CLC
		ADC	ZLCHAD,Y
                STA     ENCHPT,X	;(0,2)
		RTS
;- - - - - - - - - - - - - - - - - - - -
ZL0030		EQU	$
		LDA	ENTIM1,X
		BNE	ZL0060
;
		JSL	>RNDSET
		AND	#01H
		BNE	ZL0050		; Biri biri set ?
;
		LDA	#80H		; yes ! 
		STA	ENTIM0,X		
		INC	ENSTAT,X
		RTS
ZL0050		EQU	$
		JSL	>RNDSET
		AND	#3FH
		ADC	#80H
		STA	ENTIM1,X
;
ZL0060		EQU	$
                RTS
;====================================
ZOOL1ST		EQU	$
		LDA	#01H
		STA	ENHELP
ZLS010		EQU	$
		LDA	#ZOOL1
		JSL	>ENIDSH
		BMI	ZL00E0
;
		JSL	>ENIDPS
;
		LDA	#00110011B
		STA	ENMOD2,Y
		LDA	#00000011B
		STA	ENCLOR,Y
		LDA	#01H
		STA	ENMOD3,Y	; Obj size !
;;		LDA	#01H	
		STA	ENWRK2,Y
		PHX
		LDX	ENHELP
		LDA	<WORK0
		CLC
		ADC	ZLSTXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#00H
		STA	ENXPSH,Y
;;		LDA	<WORK2
;;		STA	ENYPSL,Y
;;		LDA	<WORK3
;;		STA	ENYPSH,Y
;;		LDA	#06H
;;		STA	ENZPSL,Y
		LDA	ZLSTXS,X
		STA	ENXSPD,Y
		LDA	#08H
		STA	ENTIM2,Y
		LDA	#40H
		STA	ENTIM1,Y
		PLX
ZL00E0		EQU	$
		DEC	ENHELP
		BPL	ZLS010
		RTS
;==========================================
ZOOL1CD2	EQU	$
		WORD	00000H,00000H
		HEX	22,00,00,00
		WORD	00008H,00000H
		HEX	22,40,00,00
		WORD	00000H,00008H
		HEX	32,00,00,00
		WORD	00008H,00008H
		HEX	32,40,00,00
;
		WORD	00000H,00000H
		HEX	23,00,00,00
		WORD	00008H,00000H
		HEX	23,40,00,00
		WORD	00000H,00008H
		HEX	33,00,00,00
		WORD	00008H,00008H
		HEX	33,40,00,00
;
ZOOL1CS		EQU	$
                LDA     #00H
                XBA
                LDA     ENCHPT,X
                MEM16
                REP     #00100000B
                ASL     A
                ASL     A
                ASL     A
;
                ASL     A
                ASL     A
                ADC     #ZOOL1CD2
                STA     <WORK8
;
                MEM8
                SEP     #00100000B
;
                LDA     #04H
;;                STA     <WORK6
  ;;              STZ     <WORK7
;
                JSL     >SETOAML22
;
		JMP	SADWST
;	RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Bound game enemy              		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MT1CDT		EQU	$
		HEX	03,04
		HEX	03,04
		HEX	02,02
		HEX	05,05
MT1ADT		EQU	$
		HEX	40,40
		HEX	00,00
		HEX	00,40
		HEX	40,00
;
MOTS1MV		EQU	$
		LDA	ENMUKI,X
		ASL	A
		STA	<WORK0
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#01H
		ORA	<WORK0
		TAY
		LDA	MT1CDT,Y
		STA	ENCHPT,X
;
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	MT1ADT,Y
		STA	ENCLOR,X		
;- - - - Speed -> muki - - -
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	M1M020
;
		LDA	ENXSPD,X
		BPL	M1M010
		EOR	#0FFH
		INC	A
M1M010		EQU	$
		STA	<WORK0
		LDA	ENYSPD,X
		BPL	M1M012
		EOR	#0FFH
		INC	A
M1M012		EQU	$
		STA	<WORK1
;
		LDA	<WORK0
		CMP	<WORK1
		LDA	#00H
		LDY	ENXSPD,X
		BCS	M1M013
		LDA	#02H
		LDY	ENYSPD,X
M1M013		EQU	$
		BPL	M1M015
		INC	A
M1M015		EQU	$		
		STA	ENMUKI,X
M1M020		EQU	$
		JSR	EN1CST
		BRA	MM0010
;- - - - - - - - - - - - - - - - - - - - -
MOTS0MV		EQU	$
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
		JSR	MOTS0CS
;
MM0010		EQU	$
		JSR	ENSTCK
		INC	ENCONT,X
		JSR	ENHNSB
;
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		LDA	ENCBFG,X
		AND	#0FH	
		BEQ	MM0011
;
		AND	#03H
		BEQ	MM00111
		STZ	ENXSPD,X
MM00111		EQU	$
		STZ	ENYSPD,X
		BRA	MM0012
MM0011		EQU	$
;
;
		JSR	ENMVCL
MM0012		EQU	$
		JSR	ENBGCK
;
;;		JSL	>ENSDMV
;
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	MNY010
;
		LDA	ENWRK0,X
		JSR	PSERC2
		LDA	<WORK0
		STA	ENWRK1,X	
		LDA	<WORK1
		STA	ENWRK2,X	
MNY010		EQU	$
		TXA
		EOR	<FRCNT
		AND	ENSTAT,X	; serch speed !
		BNE	MNY023
;
		LDA	ENYSPD,X
		CMP	ENWRK1,X
		BPL	MNY020
		INC	ENYSPD,X
		BRA	MNY022
MNY020		EQU	$		
		DEC	ENYSPD,X
MNY022		EQU	$		
		LDA	ENXSPD,X
		CMP	ENWRK2,X
		BPL	MNY021
		INC	ENXSPD,X
		BRA	MNY023
MNY021		EQU	$		
		DEC	ENXSPD,X
MNY023		EQU	$
		RTS
;
;
;
;
;
;
;
;
;--------------------------------------
MOTS0CD		EQU	$
		WORD	0000H,0FFFAH
		HEX	40,01,00,02
		WORD	0000H,0000H
		HEX	42,01,00,02
;
		WORD	0000H,0FFF9H
		HEX	40,01,00,02
		WORD	0000H,0000H
		HEX	44,01,00,02
;- - - - - - - - - - - - - - - - - - - - - - -
MOTS0CS		EQU	$
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ADC	#LOW MOTS0CD
		STA	<WORK8
		LDA	#HIGH MOTS0CD
		ADC	#00H
		STA	<WORK9
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JSL	>SETOAML22
		RTS
;=======================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		BABUL                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;================================================
;BABULCD		EQU	$
;		WORD	00004H,0FFFDH
;		HEX	E3,00,00,00
;		WORD	0000BH,00004H
;		HEX	E3,00,00,00
;		WORD	00004H,0000BH
;		HEX	E3,00,00,00
;		WORD	0FFFDH,00004H
;		HEX	E3,00,00,00
;;
;		WORD	0FFFFH,0FFFFH
;		HEX	E3,00,00,00
;		WORD	00009H,0FFFFH
;		HEX	E3,00,00,00
;		WORD	0FFFFH,00009H
;		HEX	E3,00,00,00
;		WORD	00009H,00009H
;		HEX	E3,00,00,00
;;
;BABULCSL	EQU	$
;		PHB
;		PHK
;		PLB
;;
;		LDA	#00H
;		XBA
;		LDA	ENCONT,X
;		LSR	A
;		LSR	A
;		AND	#01H
;		MEM16
;		REP	#00100000B
;		ASL	A
;		ASL	A
;		ASL	A
;;
;		ASL	A
;		ASL	A
;		ADC	#BABULCD  
;		STA	<WORK8
;;
;		MEM8
;		SEP	#00100000B
;;
;		LDA	#04H
;;;		STA	<WORK6
;;		STZ	<WORK7
;;
;;		JSL	>SETOAML22
;		PLB
;		RTL
;-----------------------------------------------
;BBLPTD		EQU	$
;		HEX	0,1,0,1 
;BBLADT		EQU	$
;		HEX	0,40,80,C0
BABULMV		EQU	$
BIGBLMV		EQU	$
;;		LDA	ENMYNO,X
;;		CMP	#BIGBL
;;		BNE	BBM010
;;		JSR	BIGBLCS
;;		JSR	ENSTCK
;;		INC	ENCONT,X
;;		LDA	ENCONT,X
;;;;		LSR	A
;;		LSR	A
;;		AND	#07H
;;		STA	ENCHPT,X
;;		BRA	BBL018
;;;---------------------------------------
;;BBM010		EQU	$
;;		JSR	EN1CST
		JSL	>BABULCSL
;
		JSR	ENSTCK
;
;;		LDA	ENCONT,X
;;		LSR	A
;;;;		LSR	A
;;		AND	#03H
;;		TAY
;;;;		LDA	BBLPTD,Y
;;;;		STA	ENCHPT,X
;;		LDA	ENCLOR,X
;;		AND	#10111111B
;;		ORA	BBLADT,Y
;;		STA	ENCLOR,X
;
;;		LDA	ENMYNO,X
;;		CMP	#BIGBL
;-		LDA	ENKBMK,X
;-		BNE	BBL018
;-;
;-		LDA	<FRCNT
;-		AND	#03H
;-		BNE	BBL018
;-;
;-		LDA	ENCLOR,X
;-		EOR	#00001100B
;-		STA	ENCLOR,X
;-BBL018		EQU	$
;
		JSR	CRENPL
		BCC	BBL019
;
		LDA	ENTIM0,X
		BNE	BBL019
;
		LDA	#10H
		STA	ENTIM0,X
;
		LDA	>MPNWCT		; Magic power dec !
		SEC
		SBC	#08
		BCS	BBL0185
		LDA	#00H
		BRA	BBL0190
BBL0185		EQU	$
;
		LDY	#1DH
		STY	SOUND3	;(S)
BBL0190		EQU	$
		STA	>MPNWCT
;
;;		LDA	ENMYNO,X
;;		CMP	#BIGBL
;		LDA	ENKBMK,X
;		BNE	BBL019		; Ken power dec !
;;- BIGBL
;		LDA	>ITMTBL6
;		CMP	#04H
;		BEQ	BBL019
;		CMP	#03H
;		BCC	BBL019
;		DEC	A
;		STA	>ITMTBL6
BBL019		EQU	$
		JSR	ENMVCL
		JSL	>ENTUCKL
		RTS
;
;		JSR	ENBGCK
;		LDA	ENCBFG,X
;		AND	#00000011B
;		BEQ	BBM020
;;
;		LDA	ENXSPD,X
;		EOR	#0FFH
;		INC	A
;		STA	ENXSPD,X
;		BRA	BBM020
;BBM020		EQU	$
;		LDA	ENCBFG,X
;		AND	#00001100B
;		BEQ	BBM030
;;
;		LDA	ENYSPD,X
;		EOR	#0FFH
;		INC	A
;		STA	ENYSPD,X
;BBM030		EQU	$
;		RTS
;===================================================
BBCXAD		EQU	$
		WORD	00FFE8H,00FFF8H,08H,18H
		WORD	00FFE8H,00FFF8H,08H,18H
		WORD	00FFE8H,00FFF8H,08H,18H
		WORD	00FFE8H,00FFF8H,08H,18H
;
		WORD	00FFEAH,00FFF9H,07H,16H
		WORD	00FFEAH,00FFF9H,07H,16H
		WORD	00FFEAH,00FFF9H,07H,16H
		WORD	00FFEAH,00FFF9H,07H,16H
;
;	WORD	02,11H,1FH,2EH
;	WORD	02,11H,1FH,2EH
;	WORD	02,11H,1FH,2EH
;	WORD	02,11H,1FH,2EH
;
BBCYAD		EQU	$
		WORD	0FFE8H,0FFE8H,0FFE8H,0FFE8H 
		WORD	0FFF8H,0FFF8H,0FFF8H,0FFF8H
		WORD	08H,08H,08H,08H
		WORD	18H,18H,18H,18H
;
		WORD	0FFEAH,0FFEAH,0FFEAH,0FFEAH 
		WORD	0FFF9H,0FFF9H,0FFF9H,0FFF9H
		WORD	07H,07H,07H,07H
		WORD	16H,16H,16H,16H
;
;
;	WORD	00,00,00,00
;	WORD	10H,10H,10H,10H
;	WORD	20H,20H,20H,20H
;	WORD	30H,30H,30H,30H
;
;	WORD	02H,02H,02H,02H
;	WORD	11H,11H,11H,11H
;	WORD	1FH,1FH,1FH,1FH
;	WORD	2EH,2EH,2EH,2EH
;
;BBCCDT		EQU	$
;		HEX	80,82,82,80
;		HEX	A0,A2,A2,A0
;		HEX	A0,A2,A2,A0
;		HEX	80,82,82,80
;;
;		HEX	84,86,86,84
;		HEX	A4,A6,A6,A4
;		HEX	A4,A6,A6,A4
;		HEX	84,86,86,84
;;
;BBCADT		EQU	$
;		HEX	02,02,42,42
;		HEX	02,02,42,42
;		HEX	82,82,C2,C2
;		HEX	82,82,C2,C2
;;
;		HEX	04,04,44,44
;		HEX	04,04,44,44
;		HEX	84,84,C4,C4
;		HEX	84,84,C4,C4
;
;-----------------------------------
;BIGBLCS		EQU	$
;		JSR	OAMCHK
;		LDA	ENCHPT,X
;		STA	<WORK6
;;
;		PHX
;		LDX	#0FH
;BBC010		EQU	$
;		PHX
;;
;		TXA
;		ASL	A
;		TAX
;		LDA	<WORK6
;		CMP	#04H
;		BCC	BBC012
;;
;		TXA
;		CLC
;		ADC	#010H*2
;		TAX
;BBC012		EQU	$
;		MEM16
;		REP	#20H
;		LDA	<WORK0
;		CLC
;		ADC	BBCXAD,X 
;		STA	(<OAMADR),Y
;		AND	#0100H
;		STA	<WORKE
;		LDA	<WORK2
;		CLC
;		ADC	BBCYAD,X
;		INY
;		STA	(<OAMADR),Y
;		CLC
;		ADC	#0010H
;		CMP	#0100H
;		MEM8
;		SEP	#20H
;		BCC	BBL020
;		LDA	#0F0H
;		STA	(<OAMADR),Y
;BBL020		EQU	$
;		PLX
;		PHX
;;
;		LDA	<WORK6
;		AND	#00000010B
;		BEQ	BBL023
;;
;		TXA
;		CLC
;		ADC	#010H
;		TAX
;BBL023		EQU	$
;;
;		LDA	BBCCDT,X
;		INY
;		STA	(<OAMADR),Y
;;
;		PLX
;		PHX
;		LDA	<WORK6
;		AND	#00000001B
;		BEQ	BBL025
;		TXA
;		CLC
;		ADC	#0010H
;		TAX
;BBL025		EQU	$
;		LDA	BBCADT,X
;		EOR	<WORK5
;		INY
;		STA	(<OAMADR),Y
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDA	#02H
;		ORA	<WORKF
;		STA	(<OSBADR),Y
;		PLY
;		INY
;		PLX
;		DEX
;		BPL	BBC010
;		PLX
;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Sometimes move                 		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NWMKDT		EQU	$
		HEX	40,00
;NWATPS		EQU	$
;		HEX	00,FF
;
NIWATMV		EQU	$
		LDA	ENXSPD,X
		BEQ	NWM010
		ASL	A
		ROL	A
		AND	#01H
		TAY
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	NWMKDT,Y
		STA	ENCLOR,X
NWM010		EQU	$
		JSR	EN1CST
;
		JSR	ENSTCK
;
		LDA	ENWRK2,X
		BEQ	NW0018
;
		LDA	ENCLOR,X
		ORA	#10H
		STA	ENCLOR,X
;
		JSR	ENMVCL
		LDA	#0CH
		STA	ENZPSL,X
		STA	ENNOCR,X
;
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	NW20
;
		JSR	CRENPL
NW20		EQU	$
                JMP     NWW010		
;- - - - -- - -- - - - -
;- - - - -- - -- - - - -
;- - - - -- - -- - - - -
;- - - - -- - -- - - - -
;- - - - -- - -- - - - -
NW0018		EQU	$
		LDA	#0FFH
		STA	ENLIFE,X
;
		LDA	ENWRK1,X
		CMP	#35 
		BCC	NW0014
;
		JSR	NWATCK
NW0014		EQU	$
		LDA	ENHNFG,X
		BEQ	NWM020
;
		STZ	ENHNFG,X
		LDA	ENWRK1,X
		CMP	#35 
		BCS	NW0019
;
		INC	ENWRK1,X
;
;;		JSL	>SDLRCE
;;		ORA	#30H
;;		STA	SOUND2	;(S)
		LDA	#030H
		JSL	>SDLRE2	;(S)
NW0019		EQU	$
		LDA	#02H
		STA	ENSTAT,X
		STA	ENNOCR,X
NWM020		EQU	$
		JSR	CRKNEN
;
		LDA	ENSTAT,X
;;;;		JSL	>JSRSUB
		BEQ	NWSTOP	
		CMP	#01H
		BEQ	NWWALK
		JMP	NWDUSH
;---------------------------------------------
NWSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	NWS010
;
		JSL	>RNDSET
		AND	#0FH
		PHX
		TXY
		TAX
		LDA	>KOMXSD,X
		STA	ENXSPD,Y
		LDA	>KOMYSD,X
		STA	ENYSPD,Y
		PLX
		JSL	>RNDSET
		AND	#1FH
		ADC	#10H
		STA	ENTIM0,X
		INC	ENSTAT,X
NWS010		EQU	$
		STZ	ENCHPT,X
;;		JSR	NWPTST
		RTS
;-----------------------------------------------
NWWALK		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		BCC	NWW0E0
;
		JSR	ENMVCL
;
		JSR	ENBGCK
		LDA	ENCBFG,X
		BEQ	NWW0F0
;
		STZ	ENSTAT,X
		RTS		
;
NWW0E0		EQU	$
NWW0F0		EQU	$
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	NWW010
		STZ	ENZPSL,X
;
		LDA	ENTIM0,X
		BNE	NWW000
		LDA	#20H
		STA	ENTIM0,X
		STZ	ENSTAT,X
		RTS
NWW000		EQU	$
		LDA	#0AH
		STA	ENZSPD,X
NWW010		EQU	$
		INC	ENCONT,X
		INC	ENCONT,X
		INC	ENCONT,X
NWPTST		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
         	LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
		RTS
;-----------------------------------------------
NWDUSH		EQU	$
		JSR	ENMVCL
;
		JSR	ENBGCK
;
		STZ	ENZPSL,X
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	NWD010
;
		LDA	#10H
		JSR	PSERC2
		LDA	<WORK0
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
NWD010		EQU	$
;
;
;
		INC	ENCONT,X
		JSR	NWW010
;--bikkuri set --
		JSR	OAMCHK
		JSL	>BIKRST2
		RTS
;
BIKRST2		EQU	$
		LDA	<FRCNT
		STA	<WORK6
BIKRST		EQU	$
		LDA	#04*4
		JSL	>OAMENT1
;
		LDA	<WORK6
		AND	#00011000B
		BEQ	NBC090
;
		PHX
		LDX	#03H
		LDY	#00H
NBC010		EQU	$
		PHX
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	>NBCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	>NBCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	NBC020
		LDA	#0F0H
		STA	(<OAMADR),Y
NBC020		EQU	$
		PLX
		LDA	#83H
		INY
		STA	(<OAMADR),Y
		LDA	#22H
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	NBC010
		PLX
NBC090		EQU	$
		RTL
;----------------------------------------
NBCXAD		EQU	$
		WORD	0FFFDH,2,7,0BH    
NBCYAD		EQU	$
		WORD	0FFFBH,0FFF9H,0FFF9H,0FFFBH       
;
;==================================================
NWATCK		EQU	$
		TXA
		EOR	<FRCNT
		AND	#0FH
		ORA	<GAMEMD
		ORA	<DJFLG
		BNE	NWA010
;
		LDA	#NIWAT
		LDY	#0AH
		JSL	>ENIDSH2
		BMI	NWA010
;
		PHX
		TYX
;
		LDA	#30H
		JSL	>SDLRE2	;(S)
		LDA	#1EH
		JSL	>SDLRE3	;(S)
;
;		JSL	>SDLRCE
;		PHA
;		ORA	#30H
;		STA	SOUND2	;(S)
;		PLA
;		ORA	#1EH
;		STA	SOUND3	;(S)
		PLX
;
		LDA	#01H
		STA	ENWRK2,Y
;
		PHX
;
		JSL	>RNDSET
		STA	<WORKF
		AND	#02H
		BEQ	QQQQ
;-- UD		
		LDA	<WORKF
		ADC	<SCCH2
		STA	ENXPSL,Y
		LDA	<SCCH2+1
		ADC	#00H
		STA	ENXPSH,Y
		LDA	<WORKF
		AND	#01H
		TAX
		LDA	NWATPS,X
		ADC	<SCCV2
		STA	ENYPSL,Y
		LDA	<SCCV2+1
		ADC	#00H
		STA	ENYPSH,Y
		BRA	TTTT
QQQQ		EQU	$
		LDA	<WORKF
		ADC	<SCCV2
		STA	ENYPSL,Y
		LDA	<SCCV2+1
		ADC	#00H
		STA	ENYPSH,Y
		LDA	<WORKF
		AND	#01H
		TAX
		LDA	NWATPS,X
		ADC	<SCCH2
		STA	ENXPSL,Y
		LDA	<SCCH2+1
		ADC	#00H
		STA	ENXPSH,Y
;
TTTT		EQU	$
		TYX
		LDA	#20H
		JSR	PSERCH
		PLX
NWA010		EQU	$
		RTS
;- - - - -- - -- - - - -
;

		RTS
;-----------------------------------------------
;-----------------------------------------------
;-----------------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Kings room isu                 		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OOISUMV		EQU	$
;;		JSR	OCHECK
		JSR	OOISUCS
;
		JSR	ENSTCK
;
		JSR	CRENPL2
		BCC	OIM008
;
;;		MEM16
;;		REP	#00100000B
;;		LDA	PLSVX1
;;		STA	<PLXPS1
;;		LDA	PLSVY1
;;		STA	<PLYPS1
;;		MEM8
;;		SEP	#00100000B
		JSL	>PLOTCK
;
		JSL	>DASHON		; Player dash reset !
;
		LDA	>OPMODE
		CMP	#01H
		BNE	OIM008		; Hime with ?
;					; yes !
;;		LDA	ENSTAT,X
;;		BNE	OIM008
;
		LDA	>ITEMR11	; Kantera have !!
		BEQ	OIM008
;
		LDA	DASHFG
		BNE	OIM008
;
		LDA	ENCTCT,X
		CMP	#090H
		BEQ	OIM008
;
		LDA	<PLXSPD
		CMP	#18H
		BMI	OIM008
;
;;		INC	ENSTAT,X
;
		LDA	#04H
		STA	>MODTBL3
;
;;		LDA	<FRCNT
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#01H
		BNE	OIM085
;
		INC	ENCTCT,X
;
OIM085		EQU	$
		LDA	ENCTCT,X
		CMP	#08H
		BCC	OIM009
;
;;L		INC	ENSTAT,X
;
;;L		LDA	#1BH
;;L		STA	SOUND3	;(S)	; Fanfale !
;
		LDA	SOUND2	
		BNE	OIM007		
;
		LDA	#22H
		STA	SOUND2	;(S)
OIM007		EQU	$
		LDA	#02H
		STA	ENXSPD,X
		JSR	ENXCLC
OIM008		EQU	$
;;L		STZ	ENCTCT,X
OIM009		EQU	$
		RTS
;--- move ---
;
;;L		LDA	ENSTAT,X
;;L		BEQ	OIM030		 ;move ?
;;L		CMP	#02H
;;L		BEQ	OIM030
;;L;;;		EOR	#01H
;;L		STA	PYALSP
;;L;
;;L;;		LDA	>MODTBL1	 ; yes !
;;L;;		ORA	#00000001B
;;L;;		STA	>MODTBL1
;;L;
;;L		LDY	ENCONT,X
;;L		CPY	#090H
;;L		BEQ	OIM020
;;L;
;;L		LDA	<FRCNT
;;L		LSR	A
;;L		BCC	OIM010
;;L		INC	ENCONT,X
;;L;
;;L		CPY	#02H
;;L		BNE	OIM010
;;L;		
;;L		LDA	#18H
;;L		STA	SOUND3	;(S)	Gogogogo
;;L;
;;LOIM010		EQU	$
;;L		LDA	#02H
;;L		STA	ENXSPD,X
;;L		JMP	ENXCLC
;;LOIM020		EQU	$
;;L		INC	ENSTAT,X	; Move end !
;;L		STZ	PYALSP
;;L;
;;L		LDA	#04H
;;L		STA	>MODTBL3
;;LOIM030		EQU	$
;;L		RTS
;
;
;= = = = = = = = = = = = = = = = = =
OISCXA		EQU	$
		HEX	00,10,20,00,10,20
OISCYA		EQU	$
		HEX	00,00,00,10,10,10
OISCCD		EQU	$
		HEX	0C,0E,0C,2C,2E,2C
OISCAD		EQU	$
		HEX	31,31,71,31,31,71
;============================================
OOISUCS		EQU	$
		LDA	#08H*4
		JSL	>OAMENT2
;;		JSR	OCHECK2
		JSR	OAMCHK
;
		PHX
		LDX	#05H
OICS10		EQU	$
		LDA	<WORK0
		CLC
		ADC	OISCXA,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	OISCYA,X
		INY
		STA	(<OAMADR),Y
		LDA	OISCCD,X
		INY
		STA	(<OAMADR),Y
		LDA	OISCAD,X
		INY
		STA	(<OAMADR),Y
		INY
		DEX
		BPL	OICS10
		PLX
		LDY	#02H
		LDA	#05H
		JSR	ALOMCK
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		ishi in teki                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ISWKPT		EQU	$
		BYTE	3,4,5,4
ISWKXS		EQU	$
		BYTE	0F4H,00CH,000H,000H
ISWKYS		EQU	$
		BYTE	000H,000H,0F4H,00CH
IS2XSD		EQU	$
		HEX	F0,10,F0,10
;;		HEX	F0,10,0,0
IS2YSD		EQU	$
		HEX	F0,F0,10,10
;;		HEX	0,0,F0,10
;
ISHI0MV		EQU	$
SHIGEMV		EQU	$
		LDA	ENSTAT,X
		BEQ	ISM0F0
		JMP	ISM200		; in ishi ?
ISM0F0		EQU	$
;- - - - in ishi ---			; yes !
		JSR	ISHI0CS
		JSR	ENSTCK
;
		STZ	ENCHPT,X
;
		JSR	EPXYCK
;
		LDA	ENTIM0,X
		BNE	ISM00C
;
		LDA	<WORKE
		CLC
		ADC	#30H
		CMP	#60H
		BCS	ISM010
		LDA	<WORKF
		CLC
		ADC	#20H
		CMP	#40H
		BCS	ISM010
;
		LDA	#20H
		STA	ENTIM0,X
;
ISM00C		EQU	$
		LDA	ISWKXS,Y
		STA	ENXSPD,X
		LDA	ISWKYS,Y
		STA	ENYSPD,X
;
		LDA	ENCBFG,X
		BNE	IS00D
;
		JSR	ENMVCL
IS00D		EQU	$
		JSR	ENBGCK
		JSR	CRKNEN
;
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
;;;;;		LSR	A
		AND	#03H
		TAY
		LDA	ISWKPT,Y
		STA	ENCHPT,X
;;		LDA	ENCBFG,X
;;		AND	#0FH
;;		BNE	ISM010
;
ISM010		EQU	$
		LDA	ENMYNO,X
		CMP	#ISHI0
		BNE	ISM111		; ishi ?
;					; yes !
		LDA	>ITEMR21
		CMP	#01H
		BCC	ISM112		; blue grouv ?
;					; yes ! ok !
ISM111		EQU	$
		JSL	>CACHCKL
;
ISM112		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BEQ	ISM020		; CHACHED ?
;					; YES !
		LDA	#01H
		LDY	ENMYNO,X
		CPY	#SHIGE
		BNE	ISM011		; ishi or kusa !
;
		INC	A
ISM011		EQU	$
		STA	ENWRK2,X
;
		LDA	#KTOBJ
		STA	ENMYNO,X
;
		LSR	ENCLOR,X
		ASL	ENCLOR,X
;
		STZ	ENCHPT,X	; Nagetara deru item reset !
;
		LDA	#ISHI0		; jyunior set !
		JSL	>ENIDSH
		BMI	ISM020
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;
		LDA	ENMOD2,Y
		AND	#10111111B
		ORA	#01H
		STA	ENMOD2,Y
		STA	ENSTAT,Y
		LDA	ENMOD0,Y
		ASL	A
		LSR	A
		STA	ENMOD0,Y
		LDA	#80H
		STA	ENTIM2,Y
		LDA	#09H
		STA	ENCLOR,Y
ISM020		EQU	$
		RTS
;------------------------------------------
ISM200   	EQU	$
		JSR	EN1CST
		JSR	ENSTCK
		JSR	ENHNSB
		JSR	CRKNEN
		LDA	ENTIM2,X
		BNE	IS1070
		JSR	CRENPL
;
IS1070		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
;;		LSR	A
		AND	#03H
		TAY
		LDA	IS2PTD,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	IS2ADT,Y
		STA	ENCLOR,X
;
		LDA	ENCBFG,X
		BEQ	IS1078
;
		LDA	#10H
		STA	ENTIM3,X
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	IS2XSD,Y
		STA	ENXSPD,X
		LDA	IS2YSD,Y
		STA	ENYSPD,X
		BRA	IS1080
IS1078		EQU	$
		JSR	ENMVCL
IS1080		EQU	$
		JSR	ENBGCK
;
		LDA	ENTIM3,X
		BNE	IS2000
;
;;		LDA	ENTIM0,X
;;		BNE	IS2000
;;		LDA	#30H
;;		STA	ENTIM0,X
;;		JSL	>RNDSET
;;		AND	#03H
;;		TAY
;;		LDA	IS2XSD,Y
;;		STA	ENXSPD,X
;;		LDA	IS2YSD,Y
;;		STA	ENYSPD,X
;
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	IS2000
;
		LDA	#10H
		JSR	PSERC2
		LDA	<WORK0
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
IS2000		EQU	$
		LDA	<FRCNT
		AND	#01H
		BNE	IS3000
;
		INC	ENCTCT,X
		LDA	ENCTCT,X
		CMP	#0C0H
		BNE	IS2800
;
		LDA	#0FH
		JSR	ENFLS2
;
		LDY	#01H
;;		LDA	#RUPY1
		BRA	IS2200
;
;
IS2800		EQU	$
		LDA	ENCTCT,X
		AND	#0FH
		BNE	IS3000
;
		LDY	#00H
;
		LDA	ENKBMK,X
		CMP	#006H
		BNE	IS2200
;
		LDA	#RUPYO
		BRA	IS2300
IS2200		EQU	$
		LDA	#RUPY1
IS2300		EQU	$
		JSL	>ENIDSH2
		BMI	IS3000
;
		INC	ENKBMK,X
		JSL	>ENIDPS
;
		LDA	<WORK0
		CLC
		ADC	#08H
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#00H
		STA	ENXPSH,Y
;
		LDA	#20H
		STA	ENZSPD,Y
		LDA	#10H
		STA	ENTIM3,Y
		PHX
		TYX
		LDA	#010H
		JSR	PSERCH
		LDA	<WORK0
		EOR	#0FFH
		STA	ENYSPD,X
		LDA	<WORK1
		EOR	#0FFH
		STA	ENXSPD,X
		PLX
;
;;		JSL	>SDLRCE
;;		ORA	#30H
;;		STA	SOUND3	;(S)
		LDA	#30H
		JSL	>SDLRE3	;(S)
IS3000		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - -
IS2PTD		EQU	$
		HEX	0,1,0,1
IS2ADT		EQU	$
		HEX	00,00,40,00		
;------------------------------------------
CACHCKL		EQU	$
		PHB
		PHK
		PLB
		JSR	CACHC02
		PLB
		RTL
;- - - - - - - - - - - - - - -
CACHC02		EQU	$
		JSR	CACHC0
		RTS
;=====================================================================
ISCYAD		EQU	$
		WORD	000H,000H	;0
		WORD	000H,0FFFDH	;1
		WORD	000H,0FFFBH	;2
		WORD	000H,0FFFAH	;3
		WORD	000H,0FFFAH	;4
		WORD	000H,0FFFAH	;5	
ISCCDT		EQU	$
		BYTE	044H,044H
		BYTE	0E8H,044H
		BYTE	0E8H,044H
		BYTE	0E6H,044H
		BYTE	0E8H,044H
		BYTE	0E6H,044H
ISCADT		EQU	$
		BYTE	000H,00CH
		BYTE	003H,00CH
		BYTE	003H,00CH
		BYTE	003H,00CH
		BYTE	003H,00CH
		BYTE	043H,00CH
;
ISHI0CS		EQU	$
		JSR	OAMCHK
;
		LDA	OJBKFG
		CMP	#03H
		BCS	ISC090		; Special magic using ?
;					; No !
		STZ	<WORK7
		LDA	ENMYNO,X
		CMP	#SHIGE
		BNE	ISC00C
		LDA	#02H
		STA	<WORK7
ISC00C		EQU	$
;
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
		PHX
		LDX	#01H
ISC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	ISCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	ISC011
		LDA	#0F0H
		STA	(<OAMADR),Y
ISC011		EQU	$
		PLX
		LDA	ISCCDT,X
		CMP	#044H
		BNE	ISC012		; ishi Or kusa !
		CLC
		ADC	<WORK7
ISC012		EQU	$
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORK5
		AND	#0FEH
		ORA	ISCADT,X
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	ISC010
;
		PLX
;;		LDY	#02H
;;		LDA	#01H
;;		JSR	ALOMCK
ISC090		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Katsugu obj                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KTOCDT		EQU	$
;;;;;			0;KANBAN  1;ISHI    2;KUSA    3;SKUSA 4;KUSA2   5;ISHI2
		BYTE	0E4H-0A2H,0E6H-0A2H,0E8H-0A2H,0,0E8H-0A2H,0E6H-0A2H
		BYTE	0E4H-0A2H,0E6H-0A2H,0E6H-0A2H,0,0E8H-0A2H,0E6H-0A2H
KTOADT		EQU	$
		BYTE	00CH,00CH,00CH,0,000H,000H
KTOMDT		EQU	$
		WORD	OAM+00B0H
		WORD	OAM+00B4H
		WORD	OAM+00B8H
		WORD	OAM+00BCH
KTSBDT		EQU	$
		WORD	OAMSB+00B0H/4
		WORD	OAMSB+00B4H/4
		WORD	OAMSB+00B8H/4
		WORD	OAMSB+00BCH/4
;
KTOBJMV		EQU	$
		LDA	OJBKFG
		CMP	#03H
		BCS	KT0112		; Special magic using ?
;					; No.
		LDA	OAMTYP
		BEQ	KOS010
;
		LDA	ENKAIF,X
		BEQ	KOS010		; Cross load lower set ?
;					; yes !
		TXA
		AND	#03H
		ASL	A
		TAY
		MEM16
		REP	#20H		
		LDA	KTOMDT,Y	; Pri. Player > Enemy
		STA	<OAMADR
		LDA	KTSBDT,Y
		STA	<OSBADR
		MEM8
		SEP	#20H
KOS010		EQU	$
;
;;		LDA	ENCONT,X
;;		BNE	KOM010
;;;
;;		INC	ENCONT,X
;;;
;;		LDA	ENYPSL,X
;;		STA	<WORK0
;;		LDA	ENYPSH,X
;;		STA	<WORK1
;;		LDA	ENXPSL,X
;;		STA	<WORK2
;;		LDA	ENXPSH,X
;;		STA	<WORK3
;;;
;;		PHX
;;		JSL	>PLREWRT
;;		PLX
;;KOM010		EQU	$
		LDA	ENMODE,X
		STA	ENNOCR,X	; NOT BEAM CHECK !
;		CMP	#ECACH
;		BEQ	KTO000
;;
;		JSR	OCHECK
;
;KTO000		EQU	$
		LDA	ENWRK2,X
		CMP	#06H
		BCC	KT0111		; Big iwa ?
;					; yes !
		JSR	DKIWACS		
		BRA	KT0112
KT0111		EQU	$
;		LDA	ENTIM3,X
;		BEQ	KT0211		; Shot now ?
;;					; yes !
;		LDA	#04H*2
;		JSL	>OAMENT3
;;
;KT0211		EQU	$
		JSR	EN1CST
;
		PHX
		LDA	<DJFLG
		CLC
		ADC	URAFLG
		CMP	#02H
		LDA	ENWRK2,X
		PHA
		BCC	KTO112
;
		ADC	#06H-1		; Ura danjyon !!
KTO112		EQU	$
		TAX
		LDA	KTOCDT,X
		LDY	#02H
		STA	(<OAMADR),Y
		INY
		LDA	(<OAMADR),Y
		AND	#11110000B
		PLX
		ORA	KTOADT,X
		STA	(<OAMADR),Y
		PLX
		AND	#0FH
		STA	<WORK0
;
		LDA	ENCLOR,X
		AND	#11000000B
		ORA	<WORK0
		STA	ENCLOR,X
;
KT0112		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	KTO001
;
;;;;		JSR	CRKNEN
		JSR	ENSTCK
;
		JSR	KTBDCL
KTO001		EQU	$
		RTS
;==============================================
DKCXAD		EQU	$
		WORD	0FFF8H,08H,0FFF8H,08H
DKCYAD		EQU	$
		WORD	0FFF2H,0FFF2H,02H,02H
DKCADT		EQU	$
		HEX	00,40,80,C0
;- - - - - - - - - - - - - - - - - - - - - - - - - -
DKKXAD		EQU	$
		WORD	0FFFAH,00,06
DKIWACL		EQU	$
		HEX	0C,00
;- - - - - - - - - - - - - - - - - - - - - - - - - -
DKIWACS		EQU	$
		LDY	ENWRK2,X
		LDA	DKIWACL-6,Y
		STA	ENCLOR,X
;
		JSR	OAMCHK
;
		PHX
		LDX	#03H
DKC010		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	DKCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	DKCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	DKC020
		LDA	#0F0H
		STA	(<OAMADR),Y
DKC020		EQU	$
		PLX
		LDA	#4AH 
		INY
		STA	(<OAMADR),Y
		LDA	DKCADT,X
		INY
;;		ORA	#2CH
		ORA	<WORK5
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	DKC010
;-------------------------------------------------
		PLX
;- - Kage set - -
		LDA	#03H*4
		JSL	>OAMENT2
		LDY	#00H
;
		LDA	ENYPSL,X
		SEC
		SBC	<SCCV2
		STA	<WORK2
		LDA	ENYPSH,X
		SBC	<SCCV2+1
		STA	<WORK3
		PHX
;
		LDX	#02H
DKC030		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	DKKXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	#0CH 
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	DKC040
		LDA	#0F0H
		STA	(<OAMADR),Y
DKC040		EQU	$	
		PLX
		LDA	#06CH
		INY
		STA	(<OAMADR),Y
		LDA	#24H
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	DKC030
		PLX
		RTS
;-------------------------------------------------
;-------------------------------------------------
;==============================================
;==============================================
;- - - - -- - - - - 
KDFXAD		EQU	$
		HEX	F8,08,F8,08
KDFXAH		EQU	$
		HEX	FF,00,FF,00
KDFYAD		EQU	$
		HEX	F8,F8,08,08
KDFYAH		EQU	$
		HEX	FF,FF,00,00
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KTOFIL		EQU	$
		LDA	ENWRK2,X
		BMI	KF0000
		CMP	#06H
		BCC	KF0000		; big iwa ?
;					; yes ! 
;;		JSL	>SDLRCE
;;		ORA	#30H
;;		STA	SOUND3	;(S)
;
		LDA	#03H
		STA	<WORKD
KF00D0		EQU	$
		LDA	#KTOBJ
		JSL	>ENIDSH
		BMI	KF00F0
;
		LDA	ENZPSL,X
		STA	ENZPSL,Y
;
		PHX
		LDX	<WORKD
		LDA	<WORK0
		CLC
		ADC	KDFXAD,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	KDFXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	KDFYAD,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	KDFYAH,X
		STA	ENYPSH,Y
;
;;		LDA	KDFXSD,X
;;		STA	ENXSPD,Y
;;		LDA	KDFYSD,X
;;		STA	ENYSPD,Y
;;		LDA	#000H
;;		STA	ENZSPD,Y
		LDA	#01H
		STA	ENWRK2,Y
;
		TYX
		JSR	ENFLST
;
		PLX
		LDA	ENWRK2,X
		CMP	#07H
		LDA	#00H
		BCS	DKFS90
		LDA	#0CH
DKFS90		EQU	$
		STA	ENCLOR,Y
;
KF00F0		EQU	$
		DEC	<WORKD
		BPL	KF00D0
		STZ	ENMODE,X
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
KF0000		EQU	$
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
		STZ	ENMODE,X
;
		JSR	OAMCHK
;
		PHX
;
		TXY
		LDX	#E2NO-1
KFS010		EQU	$
		LDA	>E2MODE,X
		BEQ	KFS090
		DEX
		BPL	KFS010
		INX
;
KFS090		EQU	$
		LDA	#KSFL
		STA	>E2MODE,X
		STA	EN2FLG
		LDA	ENXPSL,Y
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		STA	>E2XPSH,X
		LDA	ENYPSL,Y
		SEC
		SBC	ENZPSL,Y
		PHP
		CLC
		ADC	#010H
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		ADC	#00H
		PLP
		SBC	#00H
		STA	>E2YPSH,X
;
		LDA	<WORK5
		STA	>E2CHPT,X	; color !
;
		LDA	ENKAIF,Y
		STA	>E2WRK0,X
;
		LDA	#1FH
		STA	>E2TIM0,X
;
		LDA	ENWRK2,Y
		STA	>E2STAT,X
;
		PLX
		RTS
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
;==============================================
;==============================================
;==============================================
;CRITCK		EQU	$
;		LDA	ENXPSL,X
;		STA	<WORK0
;		LDA	ENXPSH,X
;		STA	<WORK8
;		LDA	#0FH
;		STA	<WORK2
;		LDA	ENYPSL,X
;		STA	<WORK1
;		LDA	ENYPSH,X
;		STA	<WORK9
;		LDA	#0FH
;		STA	<WORK3
;;
;		LDA	#00H
CRIT00		EQU	$
;		STA	<WORKD
;
		LDY	#ENNO-1
CRIC10		EQU	$
		LDA	ENMOD5,Y
		AND	#00000010B
		BEQ	CRIC90
;
;;		LDA	ENMYNO,Y
;;		CMP	#ITEMD
;;		BCC	CRIC90
;;		CMP	#ITEMN
;;		BCS	CRIC90		; item in ?
;					; Yes !
		LDA	ENWRK3,Y
		BEQ	CRIC90		; See thru ?
;					; yes !
		LDA	OJBKFG
		CMP	#0EH
		BEQ	CRIC88		; Zishin Magic !
;
		PHX
		TYX
		JSR	ENCRST
		PLX
		JSR	CROJCK
		BCC	CRIC90
;
CRIC88		EQU	$
		LDA	#00H
		STA	ENWRK3,Y	; item move start !
;
		LDA	#30H
		STA	SOUND3	;(S)	
;
;;		LDA	<WORKD
;;		BEQ	CRIC90		; Wood tilt ?
;					; yes !
		LDA	#30H
		STA	ENZSPD,Y
		LDA	#10H
		STA	ENXSPD,Y
;
		LDA	#30H
		STA	ENTUTM,Y
;
		LDA	#0FFH
		STA	ENSTTM,Y
;
		LDA	ENMYNO,Y
		CMP	#BOSET
		BNE	CRIC90		; HART1:Bakudan ?
;					; YES !
		JSL	>BOMBST
CRIC90		EQU	$
		DEY
		BPL	CRIC10
		RTS
;===================================
BOMBST		EQU	$
		LDA	#HEBO0
		STA	ENMYNO,Y
		LDA	#01H
		STA	ENWRK2,Y
		LDA	#0FFH
		STA	ENTIM1,Y
		LDA	#00011000B
		STA	ENMOD2,Y
		LDA	#00001000B
		STA	ENCLOR,Y
		LDA	#00H
		STA	ENLIFE,Y
		RTL
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		JOHOY SET                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JOHOYMV		EQU	$
		JSR	JOHOYCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENTIM0,X
		BNE	JHYMV10
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
JHYMV10		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	JOHOYFA		;A
		WORD	JOHOYFB		;B
		WORD	JOHOYFC		;C
		WORD	JOHOYFD		;D
		WORD	JOHOYFE		;E
;========================================
JOHOYFA		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JHYFAM0
		WORD	JHYFAM1
		WORD	JHYFAM2
;----------------------------------------
JHYFAM0		EQU	$
JHYFBM0		EQU	$
JHYFCM0		EQU	$
JHYFEM0		EQU	$
		LDA	#LOW  MS_03D0		; MSGE NO. SET
		LDY	#HIGH MS_03D0		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
		BCC	JYAM010
		INC	ENSTAT,X
JYAM010		EQU	$
		RTS
;----------------------------------------
JHYFAM2		EQU	$
JHYFBM2		EQU	$
JHYFCM2		EQU	$
JHYFEM2		EQU	$
		LDA	#0A0H
		STA	>UPLFCT
		STZ	ENSTAT,X
		RTS
;----------------------------------------
JHYFAM1		EQU	$
		LDA	MSG_RTS
		BNE	JYAM110
;
		JSR	JOHOYYN		;? COIN OK
		BCC	JYAM110
;
		LDA	#LOW  MS_03D1
		LDY	#HIGH MS_03D1
JYAM1MS		EQU	$
		JSL	>ENMSGSL		; MEGE ?
		INC	ENSTAT,X
		RTS
;
JYAM110		EQU	$			; NO & NOT COIN
		LDA	#LOW  MS_03D2		; MSGE NO. SET
		LDY	#HIGH MS_03D2		; MSGE NO. SET
		JSL	>ENMSGSL		; MEGE ?
		STZ	ENSTAT,X
		RTS
;========================================
JOHOYFB		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JHYFBM0
		WORD	JHYFBM1
		WORD	JHYFBM2
;----------------------------------------
JHYFBM1		EQU	$
		LDA	MSG_RTS
		BNE	JYBM110
;
		JSR	JOHOYYN		;? COIN OK
		BCC	JYBM110
;
		LDA	#LOW  MS_03D3
		LDY	#HIGH MS_03D3
		BRA	JYAM1MS
;
JYBM110		EQU	$			; NO & NOT COIN
		LDA	#LOW  MS_03D2		; MSGE NO. SET
		LDY	#HIGH MS_03D2		; MSGE NO. SET
		JSL	>ENMSGSL		; MEGE ?
		STZ	ENSTAT,X
		RTS
;========================================
JOHOYFC		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JHYFCM0
		WORD	JHYFCM1
		WORD	JHYFCM2
;----------------------------------------
JHYFCM1		EQU	$
		LDA	MSG_RTS
		BNE	JYCM110
;
		JSR	JOHOYYN		;? COIN OK
		BCC	JYCM110
;
		LDA	#LOW  MS_03D4
		LDY	#HIGH MS_03D4
		JMP	JYAM1MS
;
JYCM110		EQU	$			; NO & NOT COIN
		LDA	#LOW  MS_03D2		; MSGE NO. SET
		LDY	#HIGH MS_03D2		; MSGE NO. SET
		JSL	>ENMSGSL		; MEGE ?
		STZ	ENSTAT,X
		RTS
;========================================
JOHOYFD		EQU	$
		LDA	ENTIM0,X
		BNE	JHYFD10
;		LDA	ENCLOR,X
;		AND	#03FH
;		STA	<WORK0
;		LDA	<FRCNT
;		ASL	A
;		AND	#040H
;		ORA	<WORK0
;		STA	ENCLOR,X
		LDA	<FRCNT
		AND	#00111111B
		BNE	JHYF08
		LDA	ENCLOR,X
		EOR	#40H
		STA	ENCLOR,X
JHYF08		EQU	$
;
		JSL	>RNDSET
		BNE	JHYFD10
		LDA	#020H
		STA	ENTIM0,X
JHYFD10		EQU	$
;
		LDA	#LOW  MS_0500		; MSGE NO. SET
		LDY	#HIGH MS_0500		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		RTS
;========================================
;JHYFESZ		EQU	$
;		BYTE	001H,0FFH
;
JOHOYFE		EQU	$
		LDA	<FRCNT
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		JSR	ENZCLC
		LDA	ENZPSL,X
		BPL	JHYFE10
		STZ	ENZPSL,X
JHYFE10		EQU	$
		LDA	ENZPSL,X
		CMP	#004H
		ROL	A
		AND	#001H
		TAY
		LDA	ENZSPD,X
		CLC
		ADC	JHYFESZ,Y
		STA	ENZSPD,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JHYFEM0
		WORD	JHYFEM1
		WORD	JHYFEM2
;----------------------------------------
JHYFEM1		EQU	$
		LDA	MSG_RTS
		BNE	JYEM110
;
		JSR	JOHOYYN		;? COIN OK
		BCC	JYEM110
;
		LDA	#LOW  MS_03D5
		LDY	#HIGH MS_03D5
		JMP	JYAM1MS
;
JYEM110		EQU	$			; NO & NOT COIN
		LDA	#LOW  MS_03D2		; MSGE NO. SET
		LDY	#HIGH MS_03D2		; MSGE NO. SET
		JSL	>ENMSGSL		; MEGE ?
		STZ	ENSTAT,X
		RTS
;========================================
JOHOYYN		EQU	$
		MEM16
		IDX8
		REP	#00100000B		;? COIN OK
		LDA	>CONCNT
		CMP	#00020
		BCC	JHYYN10
;
		LDA	>CONCNT
		SEC
		SBC	#00020
		STA	>CONCNT
		MEM8
		IDX8
		SEP	#00110000B
		SEC
		RTS
;
;
JHYYN10		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		CLC
		RTS
;========================================
JOHOYCD		EQU	$
		WORD	00000,00000		;A
		BYTE	04AH,00AH,000H,002H
		WORD	00000,00000
		BYTE	06EH,04AH,000H,002H
;
		WORD	00000,00000		;B
		BYTE	024H,00AH,000H,002H
		WORD	00000,00000
		BYTE	024H,04AH,000H,002H
;
		WORD	00000,00000		;C
		BYTE	004H,008H,000H,002H
		WORD	00000,00000
		BYTE	004H,048H,000H,002H
;
		WORD	00000,00000		;D
		BYTE	06AH,00AH,000H,002H
		WORD	00000,00000
		BYTE	06CH,00AH,000H,002H
;
		WORD	00000,00000		;E
		BYTE	00EH,00AH,000H,002H
		WORD	00000,00000
		BYTE	02EH,00AH,000H,002H
;
JOHOYCS		EQU	$
;
		LDA	ENCONT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  JOHOYCD
		STA	<WORK8
		LDA	#HIGH JOHOYCD
		ADC	#000H
		STA	<WORK9
;
		LDA	#001H		;KAZU
		STA	<WORK6
		STZ	<WORK7
;
		JSL	>SETOAML
;
		JMP	SADWST
;	RTS
;========================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	KUTUU move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KUTUUMV		EQU	$
		LDA	ENCMKI,X
		JSL	>JSRSUB
		WORD	KUTUU00
		WORD	ONPUU00
;----------------------------------------
KUTUU00		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	KUTUUF0		;NISE MONO
		WORD	KUTUUF1		;HON  MONO
;----------------------------------------
KUTUUF0		EQU	$
;		LDA	ENSTAT,X
;		BEQ	KUTUU20
;		LDA	#001H
;		STA	PYALSP		;PL. STOP
KUTUU20		EQU	$
;
		LDA	ENSTAT,X
		CMP	#003H
		BEQ	KUTUU10
		JSL	>KUTUUCS
		LDA	<WORK1
		ORA	<WORK3
		STA	ENWRK2,X
KUTUU10		EQU	$
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENWRK2,X
		BNE	KUTUU30
		LDA	ENWRK1,X
		BNE	KUTUU30
		LDA	#00BH		;OTO
		STA	SOUND1
;// 03.09.16 //		STA	SVSND1
		STA	ENWRK1,X
KUTUU30		EQU	$
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KTUF0M0
		WORD	KTUF0M1
		WORD	KTUF0M2
		WORD	KTUF0M3
;----------------------------------------
KTUF0M0		EQU	$
		LDA	>ITEMR13
		CMP	#002
		BCS	KTU0030
		JSR	KUTUUPL		;PL. BODY CHK
		BCS	KTU0010
KTU0030		EQU	$
		INC	ENSTAT,X
		INC	ENMUKI,X
		INC	CALFLG
		LDA	#0B0H
		STA	ENTIM0,X
		LDA	#001H		;PL. STOP
		STA	PYALSP
KTU0010		EQU	$
		LDA	ENTIM0,X
		BNE	KTU0020
		LDA	#019H
		STA	ENTIM0,X
		JSR	ONPUUST
KTU0020		EQU	$
		RTS
;----------------------------------------
KTUF0M1		EQU	$
		LDA	#001H		;PL. STOP
		STA	PYALSP
;
		LDA	ENTIM0,X
		BNE	KTU0120
;
		LDA	#002H
		STA	<DPSUB
		LDA	#030H
		STA	<WD2131
		LDA	#000H
		STA	>CCNGCT
		STA	>CCNGFG
		PHX
		JSL	>PWTRCGS2
		PLX
		INC	ENSTAT,X
		LDA	#080H		;OTO
		STA	SOUND1
;// 03.09.16 //		STA	SVSND1
;;		JSL	>SDLRCE
;;		ORA	#033H		;OTO
;;		STA	SOUND2
		LDA	#33H
		JSL	>SDLRE2	;(S)
KTU0120		EQU	$
		RTS
;----------------------------------------
KTUF0M2		EQU	$
		LDA	<FRCNT
		AND	#00FH
		BNE	KTU0210
		PHX
		JSL	>MGMCGCNG
		PLX
		LDA	>CCNGCT
		BNE	KTU0210
		INC	ENSTAT,X
KTU0210		EQU	$
		RTS
;----------------------------------------
KTUF0M3		EQU	$
		PHX
		JSL	>MGMCGRS1
		JSL	>PWTRCGS3
		PLX
		STZ	ENMODE,X	;KILL I
		STZ	PYALSP		;PL. MOVE
		RTS
;----------------------------------------
KUTU1MD		EQU	$
		BYTE	001H,001H,001H	;STOP TIME
;
		BYTE	001H,002H,001H,002H,001H,002H,001H,002H
		BYTE	003H,002H,003H,002H,003H,002H,003H,002H
		BYTE	0FFH
KUTU1TD		EQU	$
		BYTE	0FFH,0FFH,0FFH	;STOP TIME
;
		BYTE	010H,002H,00CH,006H,008H,00AH,004H,00EH
		BYTE	002H,00AH,006H,006H,00AH,002H,00EH,002H
;
KUTUUF1		EQU	$
		JSL	>KUTU1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KUTU1M0
		WORD	KUTU1M1
		WORD	KUTU1M2
		WORD	KUTU1M3
		WORD	KUTU1M4
		WORD	KUTU1M5
;----------------------------------------
KUTU1M0		EQU	$
		LDA	>ITEMR13
		AND	#003H
		JSL	>JSRSUB
		WORD	K11M010
		WORD	K11M020
		WORD	K11M030
		WORD	K11M040
;
;
K11M010		EQU	$
		LDA	#LOW  MS_0390	;MSGE NO
		LDY	#HIGH MS_0390	;MSGE NO
		JSL	>ENMSGEL
		BCC	K11M011
		INC	ENSTAT,X
K11M011		EQU	$
		RTS
;
K11M020		EQU	$
		LDA	#LOW  MS_0393	;MSGE NO
		LDY	#HIGH MS_0393	;MSGE NO
		JSL	>ENMSGEL
		RTS
;
K11M030		EQU	$
		LDA	#001H		;E SET
		STA	ENCHPT,X
		LDA	#LOW  MS_0394	;MSGE NO
		LDY	#HIGH MS_0394	;MSGE NO
		JSL	>ENMSGEL
		BCC	K11M031
		LDA	#003H
		STA	ENSTAT,X
K11M031		EQU	$
		RTS
;
K11M040		EQU	$
		LDA	#003H		;E SET
		STA	ENCHPT,X
		RTS
;----------------------------------------
KUTU1M1		EQU	$
		LDA	MSG_RTS
		BNE	K11M110
;
		LDA	#LOW  MS_0391
		LDY	#HIGH MS_0391
		JSL	>ENMSGSL
		INC	ENSTAT,X
		RTS
;
K11M110		EQU	$
		LDA	#LOW  MS_0392
		LDY	#HIGH MS_0392
		JSL	>ENMSGSL
		STZ	ENSTAT,X
		RTS
;----------------------------------------
KUTU1M2		EQU	$
		STZ	!ITMVFG
		LDY	#013H
		PHX
		JSL	>ATMSIT
		PLX
		STZ	ENSTAT,X
		RTS
;----------------------------------------
KUTU1M3		EQU	$
		LDA	GETITM0
		CMP	#013
		BNE	K11M310
;
		BIT	<KEYA1
		BVC     K11M310
;
		INC	ENSTAT,X
;
		LDA	#0F2H
		STA	SOUND0		;OTO KESU
		STZ	SOUND2		;OKARINA OFF
		LDA	#017H		;OTO
		STA	SOUND1
;
		INC	PYALSP		;PL. STOP
;
K11M310		EQU	$
		RTS
;----------------------------------------
KUTU1M4		EQU	$
		LDA	ENTIM0,X	;E SET
		BNE	K11M410
;
		LDA	ENWRK0,X
		CMP	#003H
		BCC	K11M430
		LDA	#33H		;OTO
		JSL	>SDLRE2	;(S)
K11M430		EQU	$
;
		LDA	ENWRK0,X
		TAY
		INC	A
		STA	ENWRK0,X
		LDA	KUTU1MD,Y
		BMI	K11M420
		STA	ENCHPT,X
		LDA	KUTU1TD,Y
		STA	ENTIM0,X
;
K11M410		EQU	$
		RTS
K11M420		EQU	$
		LDA	#0F3H		;OTO
		STA	SOUND0
;
		INC	ENSTAT,X
		STZ	PYALSP		;PL. STOP
		RTS
;----------------------------------------
KUTU1M5		EQU	$
		LDA	#003H
		STA	ENCHPT,X
;
		LDA	>MODTBL4
		ORA	#008H
		STA	>MODTBL4
		RTS
;----------------------------------------
KUTUUPL		EQU	$
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK2
		SEC
		SBC	#00010H
		STA	<WORK2
;
		LDA	<PLXPS1
		SBC	<WORK0
		BPL	KUTPL10
		EOR	#0FFFFH
KUTPL10		EQU	$
		STA	<WORK0
;
		LDA	<PLYPS1
		SBC	<WORK2
		BPL	KUTPL20
		EOR	#0FFFFH
KUTPL20		EQU	$
		STA	<WORK2
;
		LDA	<WORK0
		CMP	#00030H
		BCS	KUTPL30
		LDA	<WORK2
		CMP	#00030H
KUTPL30		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		RTS

;----------------------------------------
ONPUUSX		EQU	$
		BYTE	001,-01
ONPUU00		EQU	$
		JSR	EN1CSS
		JSR	ENSTCK		; scroll : not return !
;
		JSR	ENMVCL		;xclc,yclc
		JSR	ENZCLC		;zclc
;
		LDA	ENTIM0,X
		BNE	ONPUU10
		STZ	ENMODE,X	;KILL I
ONPUU10		EQU	$
		LDA	<FRCNT
		AND	#001H
		BNE	ONPUU20
;;		STX	<WORK0
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		EOR	ENINDX
;;		EOR	<WORK0
		AND	#001H
		TAY
		LDA	ENXSPD,X
		CLC
		ADC	ONPUUSX,Y
		STA	ENXSPD,X
ONPUU20		EQU	$
		RTS
;----------------------------------------
ONPUUST		EQU	$
		LDA	#KUTUU
		JSL	>ENIDSH
		BMI	ONPST10
;
		LDA	<WORK0
		CLC
		ADC	#004H
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#000H
		STA	ENXPSH,Y
;
		LDA	<WORK2
		SEC
		SBC	#004H
		STA	ENYPSL,Y
		LDA	<WORK3
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	#001H		;ONPUU MODE
		STA	ENCMKI,Y
		LDA	#008H		;Z SPEED SET
		STA	ENZSPD,Y
		LDA	#060H		;TIME SET
		STA	ENTIM0,Y
		STA	ENNOCR,Y	;beem thru
ONPST10		EQU	$
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		KAJIY                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KAJIYMD		EQU	$
		BYTE	000H,001H,002H,003H,003H,002H,001H,000H
KAJIYTD		EQU	$
		BYTE	018H,004H,001H,010H,010H,005H,00AH,010H
;
KAJIYMV		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	KAJIY00		;KAJIY 1 OR 2 MAN WAIT
		WORD	HIBANMV		;HIBANA
		WORD	KAJIY01		;1 MAN HITTUKU
		WORD	KAJIY02		;1 MAN MOVE 
;----------------------------------------
KAJIY02		EQU	$
		JSR	KAJ01CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KJY02M0
		WORD	KJY02M1
		WORD	KJY02M2
;----------------------------------------
KY2M0TD		EQU	$
		BYTE	068H,00CH
KY2M0MD		EQU	$
		BYTE	000H,002H,0FFH
;
KAJIYSX		EQU	$
		BYTE	000,000,-13,013
KAJIYSY		EQU	$
		BYTE	-13,013,000,000
;
KJY02M0		EQU	$
		JSR	ENMVCL		;xclc,yclc
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	KY2M010
;
		LDA	ENWRK0,X
		TAY
		INC	A
		STA	ENWRK0,X
;
		LDA	KY2M0TD,Y
		STA	ENTIM0,X
;
		LDA	KY2M0MD,Y
		BMI	KY2M020
;
		STA	ENMUKI,X
		TAY
		LDA	KAJIYSX,Y
		STA	ENXSPD,X
		LDA	KAJIYSY,Y
		STA	ENYSPD,X
;
KY2M010		EQU	$
		RTS
;
KY2M020		EQU	$
		INC	ENSTAT,X
		RTS
;----------------------------------------
KJY02M1		EQU	$
		LDA	#LOW  MS_038E
		LDY	#HIGH MS_038E
		JSL	>ENMSGEL
;
		STZ	PYALSP		;PL. MOVE
;
		LDA	#001H
		STA	ENMUKI,X
;
		LDA	>MODTBL4	;SAVE RAM
		ORA	#020H
		STA	>MODTBL4
;
		RTS
;----------------------------------------
KJY02M2		EQU	$
;----------------------------------------
KAJIY01		EQU	$
		JSR	KAJ02CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
		JSR	ENZCLC		;zclc
;
		LDA	ENZPSL,X
		BPL	KJY0110
		STZ	ENZPSL,X
		LDA	#010H
		STA	ENZSPD,X
KJY0110		EQU	$
;
		LDA	ENSTAT,X
		BNE	KJY0130
;
		LDA	#001H
		STA	ENMUKI,X
;
		LDA	#LOW  MS_038C
		LDY	#HIGH MS_038C
		JSL	>ENMSGEL
		BCC	KJY0120
		INC	ENSTAT,X
;
KJY0120		EQU	$
;
		RTS
;----------------------------------------
KJY0130		EQU	$
		LDA	#kajy1
		STA	>OPMODE
;
		PHX
		JSL	>OPTCBFST
		JSL	>RAOPIT1		;PL. OPTION INIT
		PLX
;
		STZ	ENMODE,X
;
		RTS
;----------------------------------------
KAJ01CD		EQU	$
		WORD	00000,00000		;0
		BYTE	022H,041H,000H,002H
		WORD	00000,00000
		BYTE	022H,001H,000H,002H
;
		WORD	00000,00000		;1
		BYTE	022H,041H,000H,002H
		WORD	00000,00000
		BYTE	022H,001H,000H,002H
;
		WORD	00000,00000		;2
		BYTE	022H,001H,000H,002H
		WORD	00000,00000
		BYTE	022H,001H,000H,002H
;
		WORD	00000,00000		;3
		BYTE	022H,041H,000H,002H
		WORD	00000,00000
		BYTE	022H,041H,000H,002H
;
KAJ01CN		EQU	$
		BYTE	0C0H		;0
		BYTE	0C0H
;
		BYTE	0A0H		;1
		BYTE	0A0H
;
		BYTE	080H		;2
		BYTE	060H
;
		BYTE	080H		;3
		BYTE	060H
;
KAJ01CS		EQU	$
		LDA	#001H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENMUKI,X
		ASL	A
		ADC	ENCHPT,X
		TAY
;
		LDA	KAJ01CN,Y		;OBJ CNG NO SET
		STA	OPTBPT
;
		TYA
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  KAJ01CD
		STA	<WORK8
		LDA	#HIGH KAJ01CD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JMP	SADWST
;	RTS
;----------------------------------------
KAJ02CD		EQU	$
		WORD	00000,00000		;0
		BYTE	0C8H,000H,000H,002H
;
KAJ02CS		EQU	$
		LDA	#001H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW  KAJ02CD
		STA	<WORK8
		LDA	#HIGH KAJ02CD
		STA	<WORK9
;
		JSL	>SETOAML
;
		JMP	SADWST
;		RTS
;----------------------------------------
;
KAJIY00		EQU	$
		JSR	KAJIYCS
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
		JSR	ENZCLC		;zclc
		LDA	ENZPSL,X
		BPL	KAJIY20
		STZ	ENZPSL,X
		STZ	ENZSPD,X
KAJIY20		EQU	$
		JSR	ENSTCK		; scroll : not return !
;
		LDY	ENWRK3,X	;? STOP
		LDA	ENSTAT,Y
		CMP	#005H
		BEQ	KAJIY40
		CMP	#007H
		BEQ	KAJIY40
		CMP	#009H
		BEQ	KAJIY40
		ORA	ENSTAT,X
		BEQ	KAJIY40
		LDA	ENSTAT,X
		CMP	#005H
		BEQ	KAJIY40
		CMP	#007H
		BEQ	KAJIY40
		CMP	#009H
		BNE	KAJIY30
		
;
KAJIY40		EQU	$		;N
		LDA	ENWRK1,X	;E SET
		DEC	ENWRK1,X
		CMP	#000H
		BNE	KAJIY30
;
		LDA	ENWRK0,X
		TAY
		INC	A
		AND	#007H
		STA	ENWRK0,X
		LDA	KAJIYMD,Y
		STA	ENCHPT,X
		LDA	KAJIYTD,Y
		STA	ENWRK1,X
;
		CPY	#001H		;JMP SET
		BNE	KAJIY10
		LDA	#010H
		STA	ENZSPD,X
KAJIY10		EQU	$
;
		CPY	#003H		;HIBANA SET
		BNE	KAJIY30
		JSR	HIBANST
;;		JSL	>SDLRCE
;;		ORA	#005H
;;		STA	SOUND2
		LDA	#05H
		JSL	>SDLRE2	;(S)
;
KAJIY30		EQU	$
;					; MSGE
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KAJIYM0		;AZUKARU
		WORD	KAJIYM1
		WORD	KAJIYM2
		WORD	KAJIYM3
		WORD	KAJIYM4
;
		WORD	KAJIYM5		;AZUKATTE IRU
		WORD	KAJIYM6
		WORD	KAJIYM7
		WORD	KAJIYM8
		WORD	KAJIYM9
;
		WORD	KAJIYMA		;KAJIY SET
		WORD	KAJIYMB		;KAJIY SET
;----------------------------------------
KAJIYM0		EQU	$
		STZ	ENWRK2,X
;
		LDA	>OPMODE
		CMP	#kajya		;PL. KAJIY MODE
		BEQ	KJYM030
;
		LDA	ENTIM1,X
		BNE	KJYM028
		LDA	GETITM0
		CMP	#012
		BNE	KJYM028
		LDA	AITMBT
		AND	#002H
		BEQ	KJYM028
		LDA	AITMMD
		CMP	#002H
		BNE	KJYM028
		JSR	CRENPL2
		BCC	KJYM028
		LDA	#LOW  MS_038F	;HANMER USE
		LDY	#HIGH MS_038F
		JSL	>ENMSGSL
		LDA	#060H
		STA	ENTIM1,X
		INC	ENWRK2,X
		RTS
;
KJYM028		EQU	$
		LDA	>MODTBL4
		AND	#020H
		BEQ	KJYM020
;
		LDA	#LOW  MS_0380
		LDY	#HIGH MS_0380
		JSL	>ENMSGEL
		BCC	KJYM010
		INC	ENSTAT,X
		INC	ENWRK2,X
KJYM010		EQU	$
;
		RTS
;
KJYM020		EQU	$
		LDA	#LOW  MS_038A
		LDY	#HIGH MS_038A
		JSL	>ENMSGEL
		RTS
;
KJYM030		EQU	$
		LDA	<PLYPS1
		CMP	#0C2H
		BCS	KJYM040
		LDA	#LOW  MS_038B
		LDY	#HIGH MS_038B
		JSL	>ENMSGSL
		LDA	#00AH		;KAJIY SET
		STA	ENSTAT,X
		INC	PYALSP		;PL. STOP
KJYM040		EQU	$
		RTS
;
;----------------------------------------
KAJIYM1		EQU	$
		LDA	MSG_RTS
		BNE	KJYM110
;
		LDA	#LOW  MS_0381
		LDY	#HIGH MS_0381
		JSL	>ENMSGSL
		INC	ENSTAT,X
		RTS
;
KJYM110		EQU	$
		LDA	#LOW  MS_0385
		LDY	#HIGH MS_0385
		JSL	>ENMSGSL
		STZ	ENSTAT,X
		RTS
;----------------------------------------
KAJIYM2		EQU	$
		LDA	MSG_RTS
		BNE	KJYM210
;
;
;
		LDA	>ITMTBL6		;KEN CHK
		CMP	#003H
		BCS	KJYM220
;
		LDA	#LOW  MS_0382
		LDY	#HIGH MS_0382
		JSL	>ENMSGSL
		INC	ENSTAT,X
		RTS
;
KJYM220		EQU	$
		LDA	#LOW  MS_0384
		LDY	#HIGH MS_0384
		JSL	>ENMSGSL
		STZ	ENSTAT,X
		RTS
;
;
;
KJYM210		EQU	$
;;;		LDA	>ITMTBL7		;SHILD CHK
;;;		CMP	#002H
;;;		BCS	KJYM230
;;;;
;;;		LDA	#LOW  MS_0383
;;;		LDY	#HIGH MS_0383
;;;		JSL	>ENMSGSL
;;;		LDA	#004H
;;;		STA	ENSTAT,X
;;;		RTS
;;;;
KJYM230		EQU	$
		LDA	#LOW  MS_0385
		LDY	#HIGH MS_0385
		JSL	>ENMSGSL
		STZ	ENSTAT,X
		RTS
;
;----------------------------------------
KAJIYM3		EQU	$
		LDA	MSG_RTS
		BEQ	KJYM310
;
;
;
		LDA	#LOW  MS_0385
		LDY	#HIGH MS_0385
		JSL	>ENMSGSL
		STZ	ENSTAT,X		;KEN AZUKARANAI
		RTS
;
KJYM310		EQU	$			;    AZUKARU
		MEM16
		IDX8
		REP	#00100000B
		LDA	>CONCNT			;? OKANE OK
		CMP	#00010
		MEM8
		IDX8
		SEP	#00110000B
		BCS	KJYM320
		LDA	#LOW  MS_0385
		LDY	#HIGH MS_0385
		JSL	>ENMSGSL
		STZ	ENSTAT,X
		RTS
;
KJYM320		EQU	$
		MEM16
		IDX8
		REP	#00100000B
		LDA	>CONCNT
		SEC
		SBC	#00010
		STA	>CONCNT
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#LOW  MS_0386
		LDY	#HIGH MS_0386
		JSL	>ENMSGSL
		LDY	ENWRK3,X
		LDA	#005H
		STA	ENSTAT,Y
		STA	ENSTAT,X
		STZ	SCLSFG			;SCR CLS
		LDA	#0FFH
		STA	>ITMTBL6		;KATANA OFF
		LDA	>MODTBL4		;SAVE RAM SET
		ORA	#080H
		STA	>MODTBL4
		RTS
;----------------------------------------
KAJIYM4		EQU	$
;		LDY	#049H
;		STZ	!ITMVFG
;		PHX
;		JSL	>ATMSIT
;		PLX
;		LDA	>MODTBL4		;SAVE RAM SET
;		ORA	#080H
;		STA	>MODTBL4
;		INC	ENSTAT,X
;		RTS
;----------------------------------------
KAJIYM5		EQU	$			;KEN WATASU
		LDA	SCLSFG
		BEQ	KJYM510
		LDA	#LOW  MS_0388
		LDY	#HIGH MS_0388
		JSL	>ENMSGEL
		BCC	KJYM520
		INC	ENSTAT,X
		LDA	#004H
		STA	ENCHPT,X
KJYM520		EQU	$
		RTS
;
KJYM510		EQU	$
		LDA	#LOW  MS_038D
		LDY	#HIGH MS_038D
		JSL	>ENMSGEL
		RTS
;----------------------------------------
KAJIYM6		EQU	$
		LDY	ENWRK3,X
		LDA	#009H
		STA	ENSTAT,X
		STA	ENSTAT,Y
		LDY	#002H			;KEN UP
		STZ	!ITMVFG
		PHX
		JSL	>ATMSIT			;PL. DEMO SET
		PLX
		LDA	>MODTBL4		;SAVE CLS
		AND	#07FH
		STA	>MODTBL4
		RTS
;----------------------------------------
KAJIYM7		EQU	$			;TATE WATASU
;;;		LDA	SCLSFG
;;;		BEQ	KJYM710
;;;		LDA	#LOW  MS_0389
;;;		LDY	#HIGH MS_0389
;;;		JSL	>ENMSGEL
;;;		BCC	KJYM720
;;;		INC	ENSTAT,X
;;;		LDA	#004H
;;;		STA	ENCHPT,X
;;;KJYM720		EQU	$
;;;		RTS
;;;KJYM710		EQU	$
;;;		LDA	#LOW  MS_038D
;;;		LDY	#HIGH MS_038D
;;;		JSL	>ENMSGEL
;;;		RTS
;----------------------------------------
KAJIYM8		EQU	$
;;;		LDY	ENWRK3,X
;;;		LDA	#009H
;;;		STA	ENSTAT,X
;;;		STA	ENSTAT,Y
;;;		LDY	#005H			;TATE UP
;;;		PHX
;;;		JSL	>ATMSIT			;PL. DEMO SET
;;;		PLX
;;;		LDA	>MODTBL4		;SAVE CLS
;;;		AND	#0BFH
;;;		STA	>MODTBL4
;;;		RTS
;----------------------------------------
KAJIYM9		EQU	$
;		LDA	#LOW  MS_0380
;		LDY	#HIGH MS_0380
;		JSL	>ENMSGEL
		RTS
;----------------------------------------
KAJIYMA		EQU	$
		LDA	#KAJIY
		JSL	>ENIDSH
		BMI	KJYMA10
;
		LDA	<PLXPS1
		STA	ENXPSL,Y
		LDA	<PLXPS0
		STA	ENXPSH,Y
;
		LDA	<PLYPS1
		STA	ENYPSL,Y
		LDA	<PLYPS0
		STA	ENYPSH,Y
;
		LDA	#003H		;1 MAN KAJIY MOVE
		STA	ENCONT,Y
;
KJYMA10		EQU	$
		INC	ENSTAT,X
;
		LDA	#nashi		;PL. OPTION KILL
		STA	>OPMODE
;
		LDA	#004H		;MAE MUKI
		STA	ENCHPT,X
;
		RTS
;----------------------------------------
KAJIYMB		EQU	$
		LDA	#LOW  MS_038E
		LDY	#HIGH MS_038E
		JSL	>ENMSGEL
		RTS
;----------------------------------------
KAJIYST		EQU	$
		LDA	#KAJIY
		JSL	>ENIDSH
		BMI	KJYST10
;
		LDA	<WORK0
		CLC
		ADC	#02CH
		STA	ENXPSL,Y
		LDA	<WORK1
		STA	ENXPSH,Y
;
		LDA	<WORK2
		STA	ENYPSL,Y
		LDA	<WORK3
		STA	ENYPSH,Y
;
		LDA	#001H		;MUKI
		STA	ENMUKI,Y
		LDA	#004H		;ZURE
		STA	ENWRK0,Y
;
		STA	ENNOCR,Y	; beem thru
KJYST10		EQU	$
		RTS
;----------------------------------------
KAJIYCD		EQU	$
		WORD	00001,0000
		BYTE	040H,040H,000H,002H
		WORD	-0011,-0010
		BYTE	060H,040H,000H,002H
;
		WORD	-0001,0000
		BYTE	040H,000H,000H,002H
		WORD	00011,-0010
		BYTE	060H,000H,000H,002H
;
;
;
		WORD	00001,0000
		BYTE	040H,040H,000H,002H
		WORD	-0003,-0014
		BYTE	044H,040H,000H,002H
;
		WORD	-0001,0000
		BYTE	040H,000H,000H,002H
		WORD	00003,-0014
		BYTE	044H,000H,000H,002H
;
;
;
		WORD	00001,0000
		BYTE	042H,040H,000H,002H
		WORD	00011,-0010
		BYTE	060H,000H,000H,002H
;
		WORD	-0001,0000
		BYTE	042H,000H,000H,002H
		WORD	-0011,-0010
		BYTE	060H,040H,000H,002H
;
;
;
		WORD	00001,0000
		BYTE	042H,040H,000H,002H
		WORD	00013,00002
		BYTE	062H,040H,000H,002H
;
		WORD	-0001,0000
		BYTE	042H,000H,000H,002H
		WORD	-0013,00002
		BYTE	062H,000H,000H,002H
;
;
;
		WORD	00001,00000
		BYTE	064H,040H,000H,002H
		WORD	00001,00000
		BYTE	062H,040H,000H,002H
;
		WORD	-0001,00000
		BYTE	064H,000H,000H,002H
		WORD	-0001,00000
		BYTE	064H,000H,000H,002H
;
;
;
KAJIYCS		EQU	$
		LDA	#002H		;TFR KAZU
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENCHPT,X	;ADD SET
		ASL	A
		ADC	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  KAJIYCD
		STA	<WORK8
		LDA	#HIGH KAJIYCD
		ADC	#000H
		STA	<WORK9
		JSL	>SETOAML
;
		JSR	SADWST		;KAGE SET
KJYCS10		EQU	$
		RTS
;----------------------------------------
HIBANMD		EQU	$
		BYTE	000H,001H,002H,001H,002H,001H,0FFH
HIBANTD		EQU	$
		BYTE	004H,001H,003H,002H,001H,001H
;
HIBANMV		EQU	$
		JSR	HIBANCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENTIM0,X
		BNE	HIBAN10
;
		LDA	ENWRK0,X
		TAY
		INC	A
		AND	#007H
		STA	ENWRK0,X
		LDA	HIBANMD,Y
		BMI	HIBAN20
		STA	ENCHPT,X
		LDA	HIBANTD,Y
		STA	ENTIM0,X
;
HIBAN10		EQU	$
		RTS
HIBAN20		EQU	$
		STZ	ENMODE,X	;KILL I
		RTS
;----------------------------------------
HBNSTDT		EQU	$
		BYTE	00FH,0F1H
HIBANST		EQU	$
		LDA	#KAJIY
		JSL	>ENIDSH
		BMI	HBNST10
;
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	<WORK0
		CLC
		ADC	HBNSTDT,X
		STA	ENXPSL,Y
		LDA	<WORK1
		STA	ENXPSH,Y
;
		LDA	<WORK2
		CLC
		ADC	#002H
		STA	ENYPSL,Y
		LDA	<WORK3
		STA	ENYPSH,Y
;
		LDA	#001H		;HIBAN MODE
		STA	ENCONT,Y
		PLX
HBNST10		EQU	$
		RTS
;----------------------------------------
HIBANCD		EQU	$
		WORD	00000,00003
		BYTE	0AAH,041H,000H,002H
		WORD	00000,-0001
		BYTE	0AAH,041H,000H,002H
;
		WORD	-0004,00000
		BYTE	090H,001H,000H,000H
		WORD	00012,00000
		BYTE	090H,041H,000H,000H
;
		WORD	-0005,-0002
		BYTE	091H,001H,000H,000H
		WORD	00013,-0002
		BYTE	091H,001H,000H,000H
;
;
HIBANCS		EQU	$
		LDA	#2*4
		JSL	>OAMENT2
;
		LDA	ENCHPT,X	;ADD SET
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  HIBANCD
		STA	<WORK8
		LDA	#HIGH HIBANCD
		ADC	#000H
		STA	<WORK9
;
		LDA	#002H		;TFR KAZU
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JSL	>SETOAML22
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		YATAM set                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
YTXRVS		EQU	$
;;		HEX	00,00,10,10
;;		HEX	00,00,F0,F0
		HEX	00,00
YTYRVS		EQU	$
		HEX	10,10,00,00
		HEX	F0,F0,00,00
YATAMMV		EQU	$
		JSR	YATAMCS
;
		JSR	ENSTCK2		; scroll : not return !
;
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	YATAM80
;
		LDA	ENTIM0,X
		BEQ	YATAM08		; BG ?
;
		DEC	A		; yes !
		BNE	YATAM05
;
		STZ	ENMODE,X
		RTS
YATAM05		EQU	$
		CMP	#20H
		BCC	YATAM06
;
		AND	#01H
		BNE	YATAM06
		LDA	<FRCNT
		ASL	A
		AND	#00000100B
		ORA	ENMUKI,X
		TAY
		LDA	YTXRVS,Y
		STA	ENXSPD,X			
		LDA	YTYRVS,Y
		STA	ENYSPD,X			
		JSR	ENMVCL
YATAM06		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
YATAM08		EQU	$
;;		JSR	CRKNEN		; Vs PL ken check
		JSR	CRENPL2		; Vs PL body check
;;		BCS	YATAM30
;
YATAM10		EQU	$
;;		TXA
;;		EOR	<FRCNT
;;		AND	#003H
;;		BNE	YATAM20
;
		LDA	ENATCT,X
		BNE	YATAM20
;
                JSR	ENBGCK		; BG check sub !
		LDA	ENCBFG,X
;;		AND	#00FH
		BEQ	YATAM20
;
		LDY	ENWRK0,X
		BEQ	YATAM03		; ya ?
;
		JSL	>YAFLST		; Yari ! 
		RTS
;
;		JSR	ENFLST		; Yari !
;KINSDST		EQU	$
;		JSL	>SDLRCE
;		ORA	#05H
;		STA	SOUND2
;		RTS
;
YATAM03		EQU	$		; yes !
		LDA	#30H
		STA	ENTIM0,X	; BG sasari !
		LDA	#02H
		STA	ENWRK0,X	
;;		JSL	>SDLRCE
;;		ORA	#08H
;;		STA	SOUND2	;(S)
		LDA	#08H
		JSL	>SDLRE2	;(S)
		RTS
YATAM30		EQU	$
		STZ	ENMODE,X
		JSL	>EFLSST
;
YATAM20		EQU	$
		JMP	ENMVCL
;;		LDA	ENXSPD,X
;;		BEQ	YATAM50
;;		JMP	ENXCLC
;;YATAM50		EQU	$
;;		JMP	ENYCLC
;
;----------------------------------------;ATARI
YATAMCP		EQU	$
		BYTE	0,2,1,3
YATAM80		EQU	$
		LDA	ENSTAT,X
		BNE	YATAMC0
;
;;		LDA	ENXSPD,X
;;		EOR	#0FFH
;;		INC	A
;;		STA	ENXSPD,X
;;;
;;		LDA	ENYSPD,X
;;		EOR	#0FFH
;;		INC	A
;;		STA	ENYSPD,X
;
		JSR	SDBUND		; speed eor !
;
		LDA	#018H
		STA	ENZSPD,X
;
		LDA	#0FFH
		STA	ENTIM0,X
		INC	ENSTAT,X
		STZ	ENFLSH,X
;
YATAMC0		EQU	$
		LDA	ENTIM0,X
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		TAY
		LDA	YATAMCP,Y
		STA	ENMUKI,X
		JSR	ENZCLC
		JSR	ENMVCL
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	YATAMD0
		STZ	ENMODE,X
YATAMD0		EQU	$
		RTS
;;		JSL	>ENXSDN
;;		JSL	>ENYSDN
;;		LDA	ENZSPD,X
;;		CMP	#0E0H
;;		BNE	YATAMD0
;;		LDA	#008H
;;YATAMD0		EQU	$
;;		DEC	A
;;		STA	ENZSPD,X
		RTS
;----------------------------------------
YTMXAD		EQU	$
		WORD	0FFF8H,00H
		WORD	00H,008H
		WORD	00H,00H
		WORD	00H,00H
YTMYAD		EQU	$
		WORD	00,00
		WORD	00,00
		WORD	0FFF8H,00H
		WORD	00H,008H
YTMCDT		EQU	$
;ya
		HEX	3A,3D
		HEX	3D,3A
		HEX	2A,2B
		HEX	2B,2A
;yari
		HEX	7C,6C
		HEX	6C,7C
		HEX	7B,6B
		HEX	6B,7B
;ya BG sasari
		HEX	3A,3B
		HEX	3B,3A
		HEX	2A,3C
		HEX	3C,2A
;BUTA0 yari
		HEX	81,80
		HEX	80,81
		HEX	91,90
		HEX	90,91
YTMADT		EQU	$
		HEX	08H,08H
		HEX	48H,48H
		HEX	08H,08H
		HEX	88H,88H
;
		HEX	09H,49H
		HEX	09H,49H
		HEX	09H,89H
		HEX	09H,89H
;
		HEX	08H,88H
		HEX	C8H,48H
		HEX	08H,08H
		HEX	88H,88H
;
		HEX	49,49
		HEX	09,09
		HEX	89,89
		HEX	09,09
YATAMCS		EQU	$
		JSR	OAMCHK
		LDA	ENMUKI,X
		ASL	A
		STA	<WORK6
		LDA	ENWRK0,X
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK7		
;
		PHX
		LDX	#01H
YTC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	YTMXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	YTMYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	YTC020
		LDA	#0F0H
		STA	(<OAMADR),Y
YTC020		EQU	$
		PLA
		CLC
		ADC	<WORK7
		TAX
		LDA	YTMCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	YTMADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	YTC010
		PLX
		RTS
;
;
;
;
;
;
;
;
;YATAMCD		EQU	$
;YAC00		EQU	$
;		BYTE	000H,000H,052H,0ABH;0
;		BYTE	000H,008H,042H,0ABH
;;
;		BYTE	000H,0F8H,042H,02BH;1
;		BYTE	000H,000H,052H,02BH
;;
;		BYTE	000H,000H,050H,02BH
;		BYTE	008H,000H,051H,02BH;2
;;
;		BYTE	0F8H,0FFH,051H,06BH;3
;		BYTE	000H,000H,050H,06BH
;;
;YAC01		EQU	$
;		BYTE	000H,000H,02BH,0A8H;0
;		BYTE	000H,008H,02AH,0A8H
;;
;		BYTE	000H,0F8H,02AH,028H;1
;		BYTE	000H,000H,02BH,028H
;;
;		BYTE	000H,000H,03DH,068H
;		BYTE	008H,000H,03AH,068H;2
;;
;		BYTE	0F8H,0FFH,03AH,028H;3
;		BYTE	000H,000H,03DH,028H
;;
;YAC02		EQU	$
;		BYTE	000H,000H,06BH,029H;0
;		BYTE	000H,008H,07BH,029H
;;
;		BYTE	000H,0F8H,07BH,0A9H;1
;		BYTE	000H,000H,06BH,0A9H
;;
;		BYTE	000H,000H,06CH,029H
;		BYTE	008H,000H,07CH,029H;2
;;
;		BYTE	0F8H,0FFH,07CH,069H;3
;		BYTE	000H,000H,06CH,069H
;
;YAC03		EQU	$
;		BYTE	000H,000H,02CH,0A8H;0
;		BYTE	000H,008H,02AH,0A8H
;;
;		BYTE	000H,0F8H,02AH,028H;1
;		BYTE	000H,000H,02CH,028H
;;
;		BYTE	000H,000H,03BH,068H
;		BYTE	008H,000H,03AH,068H;2
;;
;		BYTE	0F8H,0FFH,03AH,028H;3
;		BYTE	000H,000H,03BH,028H
;;
;YTCIAD		EQU	$
;		BYTE	YAC00-YAC00
;		BYTE	YAC01-YAC00
;		BYTE	YAC02-YAC00
;		BYTE	YAC03-YAC00
;;------------------------------------------
;YATAMCS		EQU	$
;		JSR	OAMCHK
;;
;		PHX
;		LDA	ENMUKI,X
;		ASL	A
;		ASL	A
;		ASL	A
;;
;		LDY	ENWRK0,X
;;;;             BEQ	YTC010		; bank 0 ya ?
;		CLC			; yes !
;;;		ADC	#YAC01-YAC00
;		ADC	YTCIAD,Y
;YTC010		EQU	$
;		MEM16
;		IDX16
;		REP	#00110000B
;;
;		AND	#000FFH
;		TAY
;		LDX	<OAMADR
;;
;		LDA	YATAMCD,Y
;		CLC
;		ADC	ENDSXL
;		STA	<OAM-OAM,X
;		LDA	YATAMCD+2,Y
;		STA	<OAM-OAM+2,X
;;
;		LDA	YATAMCD+4,Y
;		CLC
;		ADC	ENDSXL
;		STA	<OAM-OAM+4,X
;		LDA	YATAMCD+5,Y
;		CLC
;		ADC	ENDSYL
;		STA	<OAM-OAM+5,X
;		LDA	YATAMCD+6,Y
;		STA	<OAM-OAM+6,X
;;
;;		LDX	<OSBADR
;;		LDA	#0000H
;;		STA	<OAMSB-OAMSB,X
;;
;		MEM8
;		IDX8
;		SEP	#00110000B
;;
;		PLX
;;
;		LDA	#001H
;		LDY	#000H
;		JMP	ALOMCK
;;
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	TAAMA move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAAMACL		EQU	$
		BYTE	002H,004H
;
;
TAAMAMV		EQU	$
		LDA	ENCLOR,X
		AND	#0F1H
		STA	ENCLOR,X
		LDA	>TAMAFLG
		AND	#001H
		TAY
		LDA	TAAMACL,Y
		ORA	ENCLOR,X
		STA	ENCLOR,X
;
		JSR	OCHECK
		JSR	EN1CST
		JSR	ENSTCK		; scroll : not return !
;
		JSR	CRENPL2
		BCC	TAAMA50
		JSL	>PLOTCK		;ATARI CHK
		STZ	<PYSPFG
		JSL	>DASHON
TAAMA50		EQU	$
;
		LDA	ENTIM0,X
		BNE	TAAMA20
;
		LDA	<FRCNT		;KILA KILA SET
		AND	#007H
		STA	<WORK0
		STZ	<WORK1
		JSL	>RNDSET
		AND	#007H
		STA	<WORK2
		STZ	<WORK3
		JSL	>ICEFLST
;
		LDA	#01FH
		STA	ENTIM0,X
;
TAAMA20		EQU	$
		LDA	ENHNFG,X	;? ATARI
		BNE	TAAMA30
;
		LDA	<KENMD
		DEC	A
		CMP	#008H
		BPL	TAAMA40
		JSR	CRKNEN
TAAMA40		EQU	$
		RTS
TAAMA30		EQU	$
		DEC	ENHNFG,X
		CMP	#00BH
		BNE	TAAMA10
		LDA	>TAMAFLG	;Y
		EOR	#001H
		STA	>TAMAFLG
		LDA	#p1_tmyk
		STA	<GAMEMD		;MODE CNG
;;		JSL	>SDLRCE
;;		ORA	#025H
;;		STA	SOUND3
		LDA	#25H
		JSL	>SDLRE3	;(S)
TAAMA10		EQU	$
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SINUB move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SINUBMV		EQU	$
		JSL	>SINUBCS
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>WPMSCK
		BCC	SINUB10
		RTS
;
SINUB10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SINUBM0
		WORD	SINUBM1
		WORD	SINUBM2
		WORD	SINUBM3
;----------------------------------------
SINUBM0		EQU	$
		JSR	CRENPL2
		BCC	SNBM010
;
;		PHX
;		JSL	>PLOTCK		;PL. POS. recover
;		STZ	<PYSPFG		;DASH STOP
;		JSL	>DASCLR1
;		PLX
;
		LDA	>BINCT0
		ORA	>BINCT1
		ORA	>BINCT2
		ORA	>BINCT3
		CMP	#002H
		BCC	SNBM020		;? BIN GET
		INC	ENSTAT,X	;Y
		INC	PYALSP		;PL. STOP
SNBM010		EQU	$
		RTS
;
SNBM020		EQU	$
		LDA	#LOW  MS_03E0
		LDY	#HIGH MS_03E0
		JSL	>ENMSGEL
		RTS
;----------------------------------------
SNBM1CD		EQU	$
		BYTE	000H,001H,000H,001H,000H,001H,002H,0FFH
SNBM1TD		EQU	$
		BYTE	008H,00CH,008H,00CH,008H,060H,010H
;
SINUBM1		EQU	$
		LDA	ENTIM0,X
		BNE	SNBM110
;
		LDY	ENWRK0,X
		LDA	SNBM1CD,Y
		BMI	SNBM120
		STA	ENCHPT,X
		LDA	SNBM1TD,Y
		STA	ENTIM0,X
		INC	ENWRK0,X
SNBM110		EQU	$
		RTS
SNBM120		EQU	$
		LDA	#LOW  MS_03E1
		LDY	#HIGH MS_03E1
		JSL	>ENMSGSL
		INC	ENSTAT,X
		RTS
;----------------------------------------
SINUBM2		EQU	$
		LDY	#021H
		STZ	!ITMVFG
		PHX
		JSL	>ATMSIT
		PLX
		INC	ENSTAT,X
		STZ	PYALSP		;PL. MOVE
		RTS
;----------------------------------------
SINUBM3		EQU	$
		LDA	#001
		STA	ENCHPT,X
;
		LDA	#LOW  MS_03E2
		LDY	#HIGH MS_03E2
		JSL	>ENMSGEL
;
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	REBA1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
REBA1FR		EQU	$
		BYTE	40,6,3,3,3,5,1,1,3,12
REBA1CT		EQU	$
		BYTE	0,1,2,3,4,5,5,6,7,6
REBA1MV		EQU	$
		JSR	REBA1CS
;
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENSTAT,X
		CMP	#002
		BEQ	REBA1MR
		JSL	>JSRSUB
;
		WORD	REBA1M0
		WORD	REBA1M1
;
REBA1MR		EQU	$
		RTS
;----------------------------------------
REBA1M0		EQU	$
		LDA	ENWRK2,X        ; Vs PL body check
		BEQ	RB1M030
;
		DEC	ENWRK1,X
		LDA	ENWRK1,X
		BNE	RB1M010
;
		INC	ENSTAT,X
;
RB1M010		EQU	$
		LDA	<FRCNT
		AND	#003H
		BNE	RB1M020
		LDA	#022H		;OTO
		JSL	>SDLRE2
RB1M020		EQU	$
		RTS
RB1M030		EQU	$
		LDA	#030H
		STA	ENWRK1,X
		RTS
;----------------------------------------
REBA1M1		EQU	$
		LDA	ENTIM0,X
		BNE	REBA110
;
		INC	ENWRK0,X
		LDY	ENWRK0,X
		CPY	#010
		BNE	REBA120
		INC	ENSTAT,X
		INC	SWCHFG
		LDA	#025H		;OTO
		JSL	>SDLRE3
		RTS
REBA120		EQU	$
;
		LDA	REBA1FR,Y
		STA	ENTIM0,X
;
		LDA	REBA1CT,Y
		STA	ENMUKI,X
;
		LDA	#022H		;OTO
		JSL	>SDLRE2
REBA110		EQU	$
		RTS
;----------------------------------------
REBA1DT		EQU	$
		BYTE	0004,0020,0DCH,020H
		BYTE	0004,0012,0DDH,020H
		BYTE	0004,0012,0DDH,020H
		BYTE	0004,0012,0DDH,020H
		BYTE	0000,0000,0CAH,020H
;
		BYTE	0003,0012,0DDH,020H
		BYTE	0003,0020,0DCH,020H
		BYTE	0003,0020,0DCH,020H
		BYTE	0003,0020,0DCH,020H
		BYTE	0000,0000,0CAH,020H
;
		BYTE	-008,0008,0EAH,020H
		BYTE	-000,0008,0EBH,020H
		BYTE	-008,0016,0FAH,020H
		BYTE	-000,0016,0FBH,020H
		BYTE	0000,0000,0CAH,020H
;
		BYTE	-012,0004,0CCH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	0000,0000,0CAH,020H
;
		BYTE	-010,0004,0CCH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	0000,0000,0CAH,020H
;
		BYTE	-008,0004,0CCH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	0000,0000,0CAH,020H
;
		BYTE	0004,0003,0E2H,020H
		BYTE	-006,0004,0CCH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	0000,0000,0CAH,020H
;
		BYTE	0004,0003,0F1H,020H
		BYTE	-006,0004,0CCH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	-004,0004,0CDH,020H
		BYTE	0000,0000,0CAH,020H
;
REBA1D1		EQU	$
		BYTE	8,6
		BYTE	16,16
		BYTE	16,8
		BYTE	16,8
		BYTE	16,8
		BYTE	16,8
		BYTE	16,3
		BYTE	16,8
REBA1AD		EQU	$
		WORD	REBA1DT
		WORD	REBA1DT+014H
		WORD	REBA1DT+028H
		WORD	REBA1DT+03CH
		WORD	REBA1DT+050H
		WORD	REBA1DT+064H
		WORD	REBA1DT+078H
		WORD	REBA1DT+08CH
;
REBA1CS		EQU	$
;		LDA	ENKAIF,X
;		CMP	<PLBGCKF
;		BNE	RB1CSE0		;KAI != ?
;;
;		JSR	EPXYCK		; PL point get
;		LDA	<WORK+0FH
;		CLC
;		ADC	#01CH
;		CMP	#01CH+01CH
;		BCS	RB1CSE0
;		LDA	<WORK+0EH
;		CLC
;		ADC	#011H
;		CMP	#011H+011H
;		BCS	RB1CSE0		; PL chikai?
;		LDA	<PLYPS1
;		CMP	ENYPSL,X
;		BCC	RB1CSE0
;		LDA	ENMOD0,X
;		AND	#01FH
;		JSL	>OAMENT2
;		BRA	RB1CSD0
;;
RB1CSE0		EQU	$
		JSR	OCHECK
;		JSR	EN1CST
		JSR	OAMCHK
;
RB1CSD0		EQU	$
;
		LDA	ENCLOR,X
		LDY	PCGCKF
		BEQ	RB1CS90
		ORA	#00EH
		BRA	RB1CS95
RB1CS90		EQU	$
		AND	#0F1H
RB1CS95		EQU	$
		STA	ENCLOR,X
		STA	<WORK2
;
;
		LDA	ENWRK1,X
		LSR	A
		LSR	A
		AND	#003H
		STA	<WORK1
		LDA	#000H
		XBA
		LDA	ENMUKI,X
		ASL	A
;
		PHX
;
		MEM16
		IDX16
		REP	#00110001B
;
		PHB
;
		TAY
		LDX	REBA1AD,Y
;
		LDA	<OAMADR
		ADC	#004
		STA	<OAMADR
		TAY			;tfr saki
;
		INC	<OSBADR
;
		LDA	#013H		;tfr ro
;
		MVN	#BANK REBA1DT,#BANK OAM
;
		PLB
;
		SEP	#00100000B
		MEM8
		IDX16
;
		LDY	<OAMADR
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		CLC
		ADC	ENDSXL		;X set
		TAX
		CLC
		ADC	OAM-OAM+0,Y
		STA	OAM-OAM+0,Y
		TXA
		CLC
		ADC	OAM-OAM+4,Y
		STA	OAM-OAM+4,Y
		TXA
		CLC
		ADC	OAM-OAM+8,Y
		STA	OAM-OAM+8,Y
		TXA
		CLC
		ADC	OAM-OAM+12,Y
		STA	OAM-OAM+12,Y
		LDA	ENDSXL
		CLC
		ADC	OAM-OAM+16,Y
		STA	OAM-OAM+16,Y
;
		LSR	<WORK1
		LDA	ENDSYL		;Y set
		SEC
		SBC	<WORK1
		TAX
		CLC
		ADC	OAM-OAM+1,Y
		STA	OAM-OAM+1,Y
		TXA
		CLC
		ADC	OAM-OAM+5,Y
		STA	OAM-OAM+5,Y
		TXA
		CLC
		ADC	OAM-OAM+9,Y
		STA	OAM-OAM+9,Y
		TXA
		CLC
		ADC	OAM-OAM+13,Y
		STA	OAM-OAM+13,Y
		LDA	ENDSYL
		CLC
		ADC	OAM-OAM+17,Y
		STA	OAM-OAM+17,Y
;
		LDA	<WORK2		;ATR set
		ORA	OAM-OAM+3,Y
		STA	OAM-OAM+3,Y
		LDA	<WORK2		;ATR set
		ORA	OAM-OAM+7,Y
		STA	OAM-OAM+7,Y
		LDA	<WORK2		;ATR set
		ORA	OAM-OAM+11,Y
		STA	OAM-OAM+11,Y
		LDA	<WORK2		;ATR set
		ORA	OAM-OAM+15,Y
		STA	OAM-OAM+15,Y
		LDA	<WORK2		;ATR set
		ORA	OAM-OAM+19,Y
		STA	OAM-OAM+19,Y

		MEM16
		IDX16
		REP	#00110001B

		LDA	#00000H
		TAY
		STA	(<OSBADR),Y
		INY
		INY
		STA	(<OSBADR),Y
		LDA	#0200H
		INY
		STA	(<OSBADR),Y

		SEP	#00110000B
		MEM8
		IDX8
;
		PLX
;
		LDY	#0FFH		; obj clc?
		LDA	#004H
		JSR	ALOMCK
;
		LDA	ENKAIF,X
		CMP	<PLBGCKF
		BEQ	RB1CS80		;KAI != ?
		JMP	RB1CS10
;
RB1CS80		EQU	$
		STZ	ENWRK2,X
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		TAY
;
		LDA	REBA1DT,Y
		CLC
		ADC	ENXPSL,X
		STA	<WORK4		;X L
		STZ	<WORKA
		LDA	REBA1DT,Y
		BPL	RB1CS40
		DEC	<WORKA
RB1CS40		EQU	$
		LDA	<WORKA
		ADC	ENXPSH,X
		STA	<WORKA		;X H
;
		LDA	REBA1DT+1,Y
		CLC
		ADC	ENYPSL,X
		STA	<WORK5		;Y L
		STZ	<WORKB
		LDA	REBA1DT+1,Y
		BPL	RB1CS50
		DEC	<WORKB
RB1CS50		EQU	$
		LDA	<WORKB
		ADC	ENYPSH,X
		STA	<WORKB		;Y H
;
		LDA     ENMUKI,X
		ASL	A
		TAY
		LDA	REBA1D1,Y
		STA	<WORK6		;X hani
		LDA	REBA1D1+1,Y
		STA	<WORK7		;Y hani
;
		JSR	PLCRST1		;PL data set
		JSR	CROJCK		;PL atari? (c)
		BCC	RB1CS60
;
		LDA	ENYPSL,X
		PHA
		CLC
		ADC	#013H
		STA	ENYPSL,X
		LDA	ENYPSH,X
		PHA
		ADC	#000H
		STA	ENYPSH,X
;
		JSR	EPXYCK		; PL point get
;
		PLA
		STA	ENYPSH,X
		PLA
		STA	ENYPSL,X
;
		CPY	#000H
		BNE	RB1CS70
		LDA	<PLMKCH
		CMP	#004
		BNE	RB1CS70
		INC	ENWRK2,X
		BRA	RB1CS70
RB1CS60		EQU	$
;
		JSR	CRENPL2          ; Vs PL body check
		BCC	RB1CS10
;
RB1CS70		EQU	$
		JSL	>PLOTCK
		STZ	<PYSPFG
		JSL	>DASHON		;HANEKAERI
;
;;		MEM16
;;		REP	#00100000B
;;		LDA	<PLYMVC		;Y move?
;;		AND	#000FFH
;;		BEQ	RB1CS20
;;		CMP	#00080H		;y
;;		BCC	RB1CS00		;PL tome
;;		ORA	#0FF00H
;;RB1CS00		EQU	$
;;		EOR	#0FFFFH
;;		INC	A
;;		CLC
;;		ADC	<PLYPS1
;;		STA	<PLYPS1
;;		STA	<PLYHN0
;;		LDA	<PLYMVC
;;		AND	#0FF00H
;;		STA	<PLYMVC
;;;
;;RB1CS20		EQU	$
;;		LDA	<PLXMVC		;X move
;;		AND	#000FFH
;;		BEQ	RB1CS10
;;		CMP	#00080H		;y
;;		BCC	RB1CS24		;PL tome
;;		ORA	#0FF00H		
;;RB1CS24		EQU	$
;;		EOR	#0FFFFH
;;		INC	A
;;		CLC
;;		ADC	<PLXPS1
;;		STA	<PLXPS1
;;		STA	<PLXHN0
;;		LDA	<PLXMVC
;;		AND	#0FF00H
;;		STA	<PLXMVC
;;;
RB1CS10		EQU	$
;;		MEM8
;;		SEP	#00100000B
		RTS

;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SAKAS move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SAKASMV		EQU	$
		JSR	SAKASCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
SOYCK30		EQU	$
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SAKASM0		;HEN MODE
		WORD	SAKASM1
		WORD	SAKASM2		;BOX OPEN MODE
		WORD	SAKASM3
		WORD	SAKASM4
;----------------------------------------
SAKASM0		EQU	$
		LDA	#LOW  MS_03F0		; MSGE NO. SET
		LDY	#HIGH MS_03F0		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
;
		LDA	>OPMODE
		CMP	#nashi
		BNE	SKSM030
;
;		LDA	ENXPSH,X
;		PHA
		LDA	ENXPSL,X
		PHA
		SEC
		SBC	#010H
		STA	ENXPSL,X
;		LDA	ENXPSH,X
;		SBC	#000H
;		STA	ENXPSH,X
		JSR	PSSAVE		;Position buffer set
		LDA	#001H
		STA	ENXSPD,X
		STA	ENYSPD,X
		JSL	>ENBGCKL
		BNE	SKSM020
		INC	ENSTAT,X
SKSM020		EQU	$
		PLA
		STA	ENXPSL,X
;		PLA
;		STA	ENXPSH,X
SKSM030		EQU	$
		RTS
		
;----------------------------------------
SAKASM1		EQU	$
		LDA	#hnoji		;PL. SAKAS MODE
		STA	>OPMODE
;
		PHX
		STZ	OPNOSI
		JSL	>OPTCBFST
		JSL	>RAOPIT		;PL. OPTION INIT
		PLX
;
		LDA	#040H		;INIT MSGE TIME
		STA	OPMTIM
		STZ	OPMTIM+1
;
		STZ	ENMODE,X	;KILL I
;
		RTS
;----------------------------------------
SAKASM2		EQU	$
		JSL	>WPMSCK
		BCS	SKSM210
;
		LDA	OPKYFG
		BEQ	SKSM220
;
		LDA	#LOW  MS_03F2		; MSGE NO. SET
		LDY	#HIGH MS_03F2		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BCC	SKSM210
		BRA	SKSM230
;
SKSM220		EQU	$
		LDA	#LOW  MS_03F2		; MSGE NO. SET
		LDY	#HIGH MS_03F2		; MSGE NO. SET
		JSL	>ENMSG2L	; MEGE ?
		BCC	SKSM210
SKSM230		EQU	$
		INC	ENSTAT,X
SKSM210		EQU	$
		RTS
;----------------------------------------
SAKASM3		EQU	$
		LDA	MSG_RTS
		BNE	SKSM310
;
		LDA	OPKYFG
		BEQ	SKSM320
;					;TAKARA NASI
		LDA	#LOW  MS_03F5		; MSGE NO. SET
		LDY	#HIGH MS_03F5		; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		LDA	#002H
		STA	ENSTAT,X
		RTS
;
SKSM320		EQU	$		;TAKARA ARI
		LDY	#016H
		STZ	!ITMVFG
		JSL	>ATMSIT
;
		LDA	>MODTBL4	;TAKAR BOX OPEN SAVE
		ORA	#010H
		STA	>MODTBL4
;
		INC	ENSTAT,X
;
		LDA	#nashi
		STA	>OPMODE
		RTS
;
SKSM310		EQU	$
		LDA	#LOW  MS_03F3		; MSGE NO. SET
		LDY	#HIGH MS_03F3		; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		LDA	#002H
		STA	ENSTAT,X
		RTS
;----------------------------------------
SAKASM4		EQU	$
		LDA	#LOW  MS_03F4		; MSGE NO. SET
		LDY	#HIGH MS_03F4		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		RTS
;----------------------------------------
SAKASCX		EQU	00
SAKASCY		EQU	00
SAKASCD		EQU	$
		WORD	00000+SAKASCX,-0008+SAKASCY
		BYTE	0EAH,000H,000H,002H
		WORD	00000+SAKASCX,00000+SAKASCY
		BYTE	0ECH,000H,000H,002H
;
SAKASCS		EQU	$
		LDA	#002H		;TFR KAZU
		STA	<WORK6
		STZ	<WORK7

		LDA	#LOW  SAKASCD	;ADD SET
		STA	<WORK8
		LDA	#HIGH SAKASCD
		STA	<WORK9
		JSL	>SETOAML
		JMP	SADWST
;	RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SLEEP move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SLEEPMV		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	SLEEP00
		WORD	AWAAA00
		WORD	HIIII00
		WORD	KEMUR00
;----------------------------------------
SLEEP00		EQU	$
		JSR	SLEEPCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#003H
		STA	ENMOD3,X
		JSR	CRENPL2
		BCC	SLEEP10
		JSL	>PLOTCK		;PL. POS. recover
		STZ	<PYSPFG
		JSL	>DASCLR1
SLEEP10		EQU	$
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SLEEPM0
		WORD	SLEEPM1
		WORD	SLEEPM2
		WORD	SLEEPM3
;----------------------------------------
SLEEPM0		EQU	$
		LDA	#007H
		STA	ENMOD3,X
		JSR	CRENPL2
		BCC	SLPM010
;
		LDA	<KEYA2L
		BPL	SLPM010
;
		INC	ENSTAT,X
		LDY	ENWRK3,X
		LDA	#004H
		STA	ENTIM0,Y	;KILL AWA
		LDA	#001H
		STA	PYALSP
SLPM010		EQU	$
		LDA	ENTIM2,X
		BNE	SLPM020
		LDA	#0A0H
		STA	ENTIM2,X
		JSR	AWAAAST
		TYA
		STA	ENWRK3,X
SLPM020		EQU	$
		RTS
;----------------------------------------
SLPM1DT		EQU	$
		BYTE	000,001,000,001,000,001,002,0FFH
SLPM1TD		EQU	$
		BYTE	006,002,006,006,002,100,030
;
SLEEPM1		EQU	$
		LDA	ENTIM0,X
		BNE	SLPM110
;
		LDY	ENWRK0,X
		LDA	SLPM1DT,Y
		BMI	SLPM120
		STA	ENCHPT,X
		LDA	SLPM1TD,Y
		STA	ENTIM0,X
		INC	ENWRK0,X
SLPM110		EQU	$
		RTS
SLPM120		EQU	$
		LDA	#LOW  MS_0370
		LDY	#HIGH MS_0370
		JSL	>ENMSGSL
		INC	ENSTAT,X
		RTS
;----------------------------------------
SLEEPM2		EQU	$
		INC	ENSTAT,X
		LDA	#001
		STA	ENCHPT,X
		PHX
		LDX	<MPDTNO		;SAVE RAM SET
		LDA	>GNDTBL,X
		ORA	#020H
		STA	>GNDTBL,X
		LDY	#016H		;BIN KARA
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
		LDA	>MODTBL4	;SAVE RAM SET
		ORA	#001H
		STA	>MODTBL4
		PLX
		RTS
;----------------------------------------
SLEEPM3		EQU	$
		STZ	PYALSP
		STZ	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	SLPM310
		LDA	#0A0H
		STA	ENTIM0,X
		JSR	AWAAAST
SLPM310		EQU	$
		RTS
;----------------------------------------
SLEEPST		EQU	$
		LDA	#SLEEP
		JSL	>ENIDSH
		BMI	SLPST10
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;;
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;
		LDA	#000H		;SLEEP MODE
		STA	ENCONT,Y
		STA	ENNOCR,Y	;beem thru
SLPST10		EQU	$
		RTS
;----------------------------------------
SLEECDX		EQU	-05
SLEECDY		EQU	003
SLEPCD		EQU	$
		WORD	00000+SLEECDX,00000+SLEECDY
		BYTE	0A6H,000H,000H,002H
		WORD	00008+SLEECDX,00000+SLEECDY
		BYTE	0A7H,000H,000H,002H
		WORD	00000+SLEECDX,00000+SLEECDY
		BYTE	0A6H,000H,000H,002H
		WORD	00008+SLEECDX,00000+SLEECDY
		BYTE	0A7H,000H,000H,002H
;
		WORD	00000+SLEECDX,00000+SLEECDY
		BYTE	0ABH,000H,000H,000H
		WORD	00008+SLEECDX,00000+SLEECDY
		BYTE	0A7H,000H,000H,002H
		WORD	00000+SLEECDX,00000+SLEECDY
		BYTE	0A6H,000H,000H,002H
		WORD	00008+SLEECDX,00000+SLEECDY
		BYTE	0A7H,000H,000H,002H
;
		WORD	00010+SLEECDX,-0014+SLEECDY
		BYTE	08AH,000H,000H,002H
		WORD	00000+SLEECDX,00000+SLEECDY
		BYTE	0ABH,000H,000H,000H
		WORD	00008+SLEECDX,00000+SLEECDY
		BYTE	088H,000H,000H,002H
		WORD	00000+SLEECDX,00000+SLEECDY
		BYTE	0A6H,000H,000H,002H
;
SLEEPCS		EQU	$
		LDA	#004H		;TFR KAZU
		STA	<WORK6
		STZ	<WORK7

		LDA	ENCHPT,X	;ADD SET
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  SLEPCD
		STA	<WORK8
		LDA	#HIGH SLEPCD
		ADC	#000H
		STA	<WORK9
		JSL	>SETOAML
		RTS
;----------------------------------------
AWAAASX		EQU	$
		BYTE	001,-01
AWAAA00		EQU	$
;;;		JSR	AWAAACS
		LDA	#1*4
		JSL	>OAMENT3
		JSR	EN1CSS
;
		JSR	ENSTCK		; scroll : not return !
;
		LDA	<FRCNT		;HANA NI TUITERU
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		INC	A
		INC	A
		STA	ENCHPT,X
;
		LDA	ENTIM1,X
		BNE	AWAAA10
;
		INC	ENCHPT,X	;HUWA HUWA
;
		JSR	ENZCLC		;zclc
;
		LDA	ENTIM0,X
		BNE	AWAAA10
		STZ	ENMODE,X	;KILL I
AWAAA10		EQU	$
		LDA	ENTIM0,X
		CMP	#004H
		BCS	AWAAA20
		LDA	#003H		;WARERU
		STA	ENCHPT,X
AWAAA20		EQU	$
		RTS
;----------------------------------------
;AWAAACD		EQU	$
;		WORD	00000,00000
;		BYTE	0A9H,000H,000H,000H
;		WORD	00000,00000
;		BYTE	0B9H,000H,000H,000H
;		WORD	00000,00000
;		BYTE	0AAH,000H,000H,000H
;		WORD	00000,00000
;		BYTE	0BAH,000H,000H,000H
;;
;;
;AWAAACS		EQU	$
;		LDA	#1*4
;		JSL	>OAMENT3
;;
;		LDA	ENCHPT,X	;ADD SET
;		ASL	A
;		ASL	A
;		ASL	A
;		ADC	#LOW  AWAAACD
;		STA	<WORK8
;		LDA	#HIGH AWAAACD
;		ADC	#000H
;		STA	<WORK9
;;
;AWACS10		EQU	$
;		LDA	#001H		;TFR KAZU
;;;		STA	<WORK6
;;;		STZ	<WORK7
;;
;		JSL	>SETOAML22
;		RTS
;----------------------------------------
AWAAAST		EQU	$
		LDA	#SLEEP
		JSL	>ENIDSH
		BMI	AWAST10
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;;
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;
		LDA	#001H		;AWAAA MODE
		STA	ENCONT,Y
		LDA	#002H		;Z SPEED SET
		STA	ENZSPD,Y
		LDA	#060H		;TIME SET
		STA	ENTIM0,Y
		LSR	A
		STA	ENTIM1,Y
		STA	ENNOCR,Y	;beem thru
CLMOD0_Y	EQU	$
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
AWAST10		EQU	$
		RTS
;----------------------------------------
HIIII00		EQU	$
		JSR	EN1CSS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	<WORK0
		AND	#001H
		STA	ENCHPT,X
		LDA	<WORK0
		ASL	A
		ASL	A
		ASL	A
		ASL	A
;		ASL	A
		AND	#040H
		STA	<WORK
		LDA	ENCLOR,X
		AND	#0BFH
		ORA	<WORK0
		STA	ENCLOR,X
;
		LDA	ENTIM0,X
		BNE	HIIII10
		JSR	KEMURST
		LDA	#02FH
		STA	ENTIM0,X
HIIII10		EQU	$
		RTS
;----------------------------------------
HIIIIST		EQU	$
		LDA	#SLEEP
		JSL	>ENIDSH
		BMI	HIIST10
;
		LDA	#094H
		STA	ENXPSL,Y
		LDA	#001H
		STA	ENXPSH,Y
;
		LDA	#03FH
		STA	ENYPSL,Y
		LDA	#000H
		STA	ENYPSH,Y
;
		LDA	#002H		;HIIII MODE
		STA	ENCONT,Y
		STA	ENNOCR,Y	;beem thru
;;		LDA	#000H
;;		STA	ENMOD0,Y	;OAM KAZU
		JSR	CLMOD0_Y
;
		LDA	ENCLOR,Y	;COLOR SET
		AND	#0F1H
		ORA	#002H
		STA	ENCLOR,Y
HIIST10		EQU	$
		RTS
;----------------------------------------
KMMKDT		EQU	$
		HEX	00,40,80,C0
;
KEMUR00		EQU	$
;;		JSR	KEMURCS
		LDA	#06H
		STA	ENCHPT,X
		JSR	EN1CSS
		JSR	ENSTCK		; scroll : not return !
;
		JSR	ENMVCL		;xclc,yclc
		JSR	ENZCLC		;zclc
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		TAY
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	KMMKDT,Y
		STA	ENCLOR,X
;;		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	KEMUR10
		STZ	ENMODE,X	;KILL I
KEMUR10		EQU	$
		RTS
;----------------------------------------
KEMURST		EQU	$
		LDA	#SLEEP
		JSL	>ENIDSH
		BMI	KEMST10
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;
		LDA	<WORK2
		SEC
		SBC	#004H
		STA	ENYPSL,Y
		LDA	<WORK3
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	#003H		;KEMUR MODE
		STA	ENCONT,Y
		LDA	#007H		;Z SPEED SET
		STA	ENZSPD,Y
		LDA	#060H		;TIME SET
		STA	ENTIM0,Y
		STA	ENNOCR,Y	;beem thru
;;		LDA	#000H
;;		STA	ENMOD0,Y	;OAM KAZU
		JSR	CLMOD0_Y
KEMST10		EQU	$
		RTS
;----------------------------------------
;KEMURCD		EQU	$
;		WORD	00000,00000
;		BYTE	0BCH,000H,000H,000H
;		WORD	00000,00000
;		BYTE	0BCH,040H,000H,000H
;		WORD	00000,00000
;		BYTE	0BCH,080H,000H,000H
;		WORD	00000,00000
;		BYTE	0BCH,0C0H,000H,000H
;;
;;
;KEMURCS		EQU	$
;		LDA	ENCHPT,X	;ADD SET
;		ASL	A
;		ASL	A
;		ASL	A
;		ADC	#LOW  KEMURCD
;		STA	<WORK8
;		LDA	#HIGH KEMURCD
;		ADC	#000H
;		STA	<WORK9
;;
;		JMP	AWACS10
;----------------------------------------
;JSL BANK GAI
;----------------------------------------
;NEZU0MVJ	EQU	$
;HEBI0MVJ	EQU	$
;HEBI1MVJ	EQU	$
;KOMO0MVJ	EQU	$
;		JSL	>NEZU0MV
;		RTS
;----------------------------------------
OYAGIMVJ	EQU	$
		JSL	>OYAGIMV
		RTS
;----------------------------------------
OYAGIITJ	EQU	$
		JSL	>OYAGIIT
		RTS
;;----------------------------------------
;HYUUUMVJ	EQU	$
;		JSL	>HYUUUMV
;		RTS
;;----------------------------------------
;TAIHOMVJ	EQU	$
;		JSL	>TAIHOMV
;		RTS
;;----------------------------------------
;TEKU0MVJ	EQU	$
;		JSL	>TEKU0MV
;		RTS
;--ENMY2 MOVE--------------------------------------
HEIS0MVJ	EQU	$
HEI00MVJ	EQU	$
HEIS1MVJ	EQU	$
HEIS2MVJ	EQU	$
HEIS3MVJ	EQU	$
HEYA0MVJ	EQU	$
HEYA1MVJ	EQU	$
HEYA2MVJ	EQU	$
HEYA3MVJ	EQU	$
HEBO0MVJ	EQU	$
ZAKO0MVJ	EQU	$
SUNA0MVJ	EQU	$
USAG0MVJ	EQU	$
HANA0MVJ	EQU	$
HANA1MVJ	EQU	$
TAMA0MVJ	EQU	$
DOZOOMVJ	EQU	$
ZORABMVJ	EQU	$
NOMOSMVJ	EQU	$
RANEMMVJ	EQU	$
ZORASMVJ	EQU	$
ZORA2MVJ	EQU	$
SEKMVMVJ	EQU	$
KANI0MVJ	EQU	$
TORI0MVJ	EQU	$
RISU0MVJ	EQU	$
SPARKMVJ	EQU	$
SPARLMVJ	EQU	$
CHAN0MVJ	EQU	$
CHAN1MVJ	EQU	$
CHAN2MVJ	EQU	$
CHAN3MVJ	EQU	$
MEDUSMVJ	EQU	$
ATARSMVJ	EQU	$
ARI00MVJ	EQU	$
ARI01MVJ	EQU	$
YASANMVJ	EQU	$
HODIRMVJ	EQU	$
HODILMVJ	EQU	$
HODIDMVJ	EQU	$
HODIUMVJ	EQU	$
TEKU0MVJ	EQU	$
TAIHOMVJ	EQU	$
HYUUUMVJ	EQU	$
NEZU0MVJ	EQU	$
HEBI0MVJ	EQU	$
KOMO0MVJ	EQU	$
MOTAMMVJ	EQU	$
;- - - - - - - - - - - - - - - - - -
;;RIVERMVJ	EQU	$
		JSL	>HEIS0MV
		RTS
;--ENMY3 MOVE--------------------------------------
HACHIMVJ	EQU	$
SHSAIMVJ	EQU	$
SHTAMMVJ	EQU	$
TELSAMVJ	EQU	$
TRAP0MVJ	EQU	$
BAAR0MVJ	EQU	$
BAAR1MVJ	EQU	$
HBTAMMVJ	EQU	$
AMENBMVJ	EQU	$
BABU2MVJ	EQU	$
MEDAMMVJ	EQU	$
MEDA2MVJ	EQU	$
SKELTMVJ	EQU	$
CHIBIMVJ	EQU	$
CHFIRMVJ	EQU	$
BIGKOMVJ	EQU	$
BKFIRMVJ	EQU	$
HARI0MVJ	EQU	$
MIIRAMVJ	EQU	$
PATARMVJ	EQU	$
PATAMMVJ	EQU	$
KAM01MVJ	EQU	$
SLIMEMVJ	EQU	$
HANDSMVJ	EQU	$
SKELBMVJ	EQU	$
MOTSBMVJ	EQU	$
BYOYNMVJ	EQU	$
AYASIMVJ	EQU	$
MEMERMVJ	EQU	$
MEMELMVJ	EQU	$
MEMEDMVJ	EQU	$
MEMEUMVJ	EQU	$
PENGIMVJ	EQU	$
FISH0MVJ	EQU	$
MAGICMVJ	EQU	$
KURORMVJ	EQU	$
KURODMVJ	EQU	$
DACHOMVJ	EQU	$
USAGIMVJ	EQU	$
OOOMUMVJ	EQU	$
ICMANMVJ	EQU	$
ICBOSMVJ	EQU	$
ICEBGMVJ	EQU	$
ICTAMMVJ	EQU	$
TEKI0MVJ	EQU	$
TEKI1MVJ	EQU	$
SKEL2MVJ	EQU	$
PATA0MVJ	EQU	$
PATA1MVJ	EQU	$
LIKE0MVJ	EQU	$
POLIWMVJ	EQU	$
RINGOMVJ	EQU	$
HELP1MVJ	EQU	$
DOKN0MVJ	EQU	$
DOKN1MVJ	EQU	$
DOKN2MVJ	EQU	$
DOKN3MVJ	EQU	$
BEE00MVJ	EQU	$
SEKBNMVJ	EQU	$
TAKARMVJ	EQU	$
BAKDNMVJ	EQU	$
SARKKMVJ	EQU	$
TEKBBMVJ	EQU	$
D_0_9MVJ	EQU	$
SITO0MVJ	EQU	$
UZUMKMVJ	EQU	$
SAMTMMVJ	EQU	$
RYOKIMVJ	EQU	$
		JSL	>ENMY3MV
		RTS
;--ENMY4 MOVE--------------------------------------
EYEBSMVJ	EQU	$
EYETMMVJ	EQU	$
EYEBMMVJ	EQU	$
NAMAZMVJ	EQU	$
SDEMOMVJ	EQU	$
IWAGOMVJ	EQU	$
AMEBAMVJ	EQU	$
TheftMVJ	EQU	$
BGBM0MVJ	EQU	$
BGBM1MVJ	EQU	$
DARUMMVJ	EQU	$
IZUMIMVJ	EQU	$
TEKTAMVJ	EQU	$
WANWANMVJ	EQU	$
KAMBSMVJ	EQU	$
KAMBRMVJ	EQU	$
KAMBBMVJ	EQU	$
CTBOSMVJ	EQU	$
MDARMMVJ	EQU	$
RINELMVJ	EQU	$
DOOMOMVJ	EQU	$
JFISHMVJ	EQU	$
ABATAMVJ	EQU	$
ANAHOMVJ	EQU	$
GANONMVJ	EQU	$
GANO2MVJ	EQU	$
		JSL	>ENMY4MV
		RTS
;----------------------------------------
HELP1ITJ	EQU	$
		JSL	>HELP1IT
		RTS
;----------------------------------------
BARI0MVJ	EQU	$
BARI1MVJ	EQU	$
		JSL	>BARI0MV
		RTS
;----------------------------------------
ESW02MVJ	EQU	$
ESW03MVJ	EQU	$
ESW12MVJ	EQU	$
ESW04MVJ	EQU	$
		JSL	>ESW02MV
		RTS
;----------------------------------------
LINE0MVJ	EQU	$
LINE1MVJ	EQU	$
LINE2MVJ	EQU	$
LINE3MVJ	EQU	$
		JSL	>LINE0MV
		RTS
;----------------------------------------
MONORMVJ	EQU	$
		JSL	>MONORMV
		RTS
;----------------------------------------
NOPPOMVJ	EQU	$
		JSL	>NOPPOMV
		RTS
;----------------------------------------
PLHIKMVJ	EQU	$
		JSL	>PLHIKMV
		RTS
;----------------------------------------
PLHINMVJ	EQU	$
		JSL	>PLHINMV
		RTS
;----------------------------------------
ONNAAMVJ	EQU	$
		JSL	>ONNAAMV
		RTS
;----------------------------------------
ONNAAITJ	EQU	$
		JSL	>ONNAAIT
		RTS
;----------------------------------------
HIGEEMVJ	EQU	$
		JSL	>HIGEEMV
		RTS
;----------------------------------------
HIGEEITJ	EQU	$
		JSL	>HIGEEIT
		RTS
;----------------------------------------
MAJOOMVJ	EQU	$
		JSL	>MAJOOMV
		RTS
;----------------------------------------
PLCHKMVJ	EQU	$
		JSL	>PLCHKMV
		RTS
;----------------------------------------
KIANAMVJ	EQU	$
		JSL	>KIANAMV
		RTS
;----------------------------------------
DEMONMVJ	EQU	$
		JSL	>DEMONMV
		RTS
;----------------------------------------
BOOK0MVJ	EQU	$
		JSL	>BOOK0MV
		RTS
;----------------------------------------
TKBOYMVJ	EQU	$
		JSL	>TKBOYMV
		RTS
;----------------------------------------
BABA1MVJ	EQU	$
		JSL	>BABA1MV
		RTS
;----------------------------------------
BOUSIMVJ	EQU	$
		JSL	>BOUSIMV
		RTS
;----------------------------------------
BOUSIITJ	EQU	$
		JSL	>BOUSIIT
		RTS
;----------------------------------------
SYOBYMVJ	EQU	$
		JSL	>SYOBYMV
		RTS
;----------------------------------------
;SYOBYITJ	EQU	$
;		JSL	>SYOBYIT
;		RTS
;----------------------------------------
HELP0MVJ	EQU	$
		JSL	>HELP0MV
		RTS
;----------------------------------------
HELP0ITJ	EQU	$
		JSL	>HELP0IT
		RTS
;----------------------------------------
JOHBBMVJ	EQU	$
		JSL	>JOHBBMV
		RTS
;----------------------------------------
;JOHBBITJ	EQU	$
;		JSL	>JOHBBIT
;		RTS
;----------------------------------------
KINOKMVJ	EQU	$
		JSL	>KINOKMV
		RTS
;----------------------------------------
KINOKITJ	EQU	$
		JSL	>KINOKIT
		RTS
;----------------------------------------
SUKASMVJ	EQU	$
		JSL	>SUKASMV
		RTS
;----------------------------------------
SUKASITJ	EQU	$
		JSL	>SUKASIT
		RTS
;----------------------------------------
JITONMVJ	EQU	$
		JSL	>JITONMV
		RTS
;----------------------------------------
;JITONITJ	EQU	$
;		JSL	>JITONIT
;		RTS
;----------------------------------------
MJSY1MVJ	EQU	$
		JSL	>MJSY1MV
		RTS
;----------------------------------------
MJSY1ITJ	EQU	$
		JSL	>MJSY1IT
		RTS
;----------------------------------------
UTUWAMVJ	EQU	$
		JSL	>UTUWAMV
		RTS
;----------------------------------------
UTUWAITJ	EQU	$
		JSL	>UTUWAIT
		RTS
;----------------------------------------
UTUBKMVJ	EQU	$
		JSL	>UTUBKMV
		RTS
;----------------------------------------
UTUBKITJ	EQU	$
		JSL	>UTUBKIT
		RTS
;----------------------------------------
KUTUUMVJ	EQU	$
		JSL	>KUTUUMV
		RTS
;----------------------------------------
PENKIMVJ	EQU	$
		JSL	>PENKIMV
		RTS
;----------------------------------------
JIJIIMVJ	EQU	$
		JSL	>JIJIIMV
		RTS
;----------------------------------------
BABAAMVJ	EQU	$
		JSL	>BABAAMV
		RTS
;----------------------------------------
NOKOGMVJ	EQU	$
		JSL	>NOKOGMV
		RTS
;----------------------------------------
ULANIMVJ	EQU	$
		JSL	>ULANIMV
		RTS
;----------------------------------------
MEIR0MVJ	EQU	$
		JSL	>MEIR0MV
		RTS
;----------------------------------------
MEIR1MVJ	EQU	$
		JSL	>MEIR1MV
		RTS
;----------------------------------------
WOOD1MVJ	EQU	$
		JSL	>WOOD1MV
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		SEKZ4					  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SEKZ4MK		EQU	$
		BYTE	4,6,0,2
SEKZ4KY		EQU	$
		BYTE	1,2,4,8
SEKZ4SX		EQU	$
		BYTE	-16,016;,000,000
;		BYTE	-08,008,000,000
SEKZ4SY		EQU	$
		BYTE	000,000,-16,016
;		BYTE	000,000,-08,008
SEKZ4MV		EQU	$
		LDA	ENMUKI,X
		BEQ	SEKZ420			;? HANARETA
		STZ	ENMUKI,X		;Y
		STZ	<PYSPFG			;OSU
		STZ	<HANIFG1		;OSU
SEKZ420		EQU	$
;
		LDA	ENTIM0,X
		BEQ	S4M010
;
		LDA	#001H
		STA	ENMUKI,X		;OSAWARI FLG SET
;
		LDA	#081H			;PL. PUSH E
		STA	<HANIFG1
		LDA	#008H
		STA	<PYSPFG
;
S4M010		EQU	$
		JSR	SEKZ4CS
		JSR	ENSTCK			;SCROLL NOT RTS
		JSR	CRSKEN		; VS enemy hit check !
		STZ	SWCHFG			;SWITCH OFF
		JSR	SEKZ4BK			;SWITCH CHK.(BG CHK)
		BCC	SEKZ430			;? SWITCH
;						;Y
		LDA	#001H			;SWITCH ON
		STA	SWCHFG
SEKZ430		EQU	$
;
		JSR	CRENPL2
		BCC	SEKZ410			;? PL. NOT TUCH
;
		LDA	#07H
		STA	ENTIM0,X						;N
;
		JSL	>DASHON			;PL. DASH OFF
;
		LDA	ENTIM1,X
		BNE	SEKZ490			;? SEKZ4 STOP
;						;N
		JSR	EPXYCK			;PL. MUKI
		LDA	SEKZ4SX,Y		;SPEED SET
		STA	ENXSPD,X
		LDA	SEKZ4SY,Y
		STA	ENYSPD,X
;
SEKZ450		EQU	$
		JSR	ENMVCL			;XCLC YCLC
		JSR	PSSAVE		; Position buffer save !
		JSR	ENBGCK			;BG check sub
;
		LDA	DODMBT
		AND	#002H
		BNE	SEKZ470		;? PL. HIKU
		JSL	>PLOTCK
SEKZ470		EQU	$
;
		LDA	ENCBFG,X
		AND	#00FH
		BNE	SEKZ460
		LDA	ENTIM3,X
		BNE	SEKZ460
;;		JSL	>SDLRCE
;;		ORA	#022H		;OTO
;;		STA	SOUND2
		LDA	#22H
		JSL	>SDLRE2	;(S)
;
		LDA	#008H
		STA	ENTIM3,X
;
SEKZ460		EQU	$
		RTS
SEKZ490		EQU	$
		JSL	>PLOTCK
		RTS
SEKZ410		EQU	$
		LDA	ENTIM0,X
		BNE	SEKZ4A0
		LDA	#00DH		;PUSH STOP TIME
		STA	ENTIM1,X
SEKZ4A0		EQU	$
;
;		PULL SYSTEM
;
		MEM16
		IDX8
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	<PLXPS1
		CLC
		ADC	#00010H
		CMP	#00023H
		BCS	SEKZ440
		LDA	ENYP2L
		SEC
		SBC	<PLYPS1
		CLC
		ADC	#0000CH
		CMP	#00024H
		BCS	SEKZ440
		MEM8
		IDX8
		SEP	#00110000B
		JSR	EPXYCK			;PL. MUKI
		LDA	<PLMKCH
		CMP	SEKZ4MK,Y
		BNE	SEKZ440
		LDA	DASHFG
		BNE	SEKZ440
;
		LDA	#001H
		STA	DZHKOK			;PL. SIKU MOVE
		LDA	#001H
		STA	ENWRK0,X		;OSAWARI FLG SET
;
		LDA	DODMBT
		AND	#002H
		BEQ	SEKZ480			;? PL. HIKU
		LDA	<KEYA1			;Y
		AND	SEKZ4KY,Y
		BEQ	SEKZ480
		LDA	<PLYMVC
		ORA	<PLXMVC
		BEQ	SEKZ480
		TYA
		EOR	#001H
		TAY
		LDA	SEKZ4SX,Y		;SPEED SET
		STA	ENXSPD,X
		LDA	SEKZ4SY,Y
		STA	ENYSPD,X
;
		JMP	SEKZ450
SEKZ440		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		LDA	ENWRK0,X
		BEQ	SEKZ480
		STZ	ENWRK0,X
		STZ	<PYSPFG			;HIKU
		STZ	DODMBT			;HIKU
		STZ	DZHKOK			;HIKU
		LDA	<PYMKFG
		AND	#0FEH
		STA	<PYMKFG			;HIKU
SEKZ480		EQU	$
		RTS
;----------------------------------------
SZ4BPXL		EQU	$
		BYTE	003H,00CH,003H,00CH
;SZ4BPXH		EQU	$
;		BYTE	000H,000H,000H,000H
SZ4BPYL		EQU	$
		BYTE	003H,003H,00CH,00CH
;SZ4BPYH		EQU	$
;		BYTE	000H,000H,000H,000H
;
SEKZ4SW		EQU	$
		BYTE	023H,024H,025H,03BH
;
SEKZ4BK		EQU	$		;SWITCH SERCH
		LDY	#003H
SZ4BK10		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	SZ4BPYL,Y
		STA	<WORK0
		LDA	ENYPSH,X
		ADC	#000H		;SZ4BPYH,Y
		STA	<WORK1
		LDA	ENXPSL,X
		CLC
		ADC	SZ4BPXL,Y
		STA	<WORK2
		LDA	ENXPSH,X
		ADC	#000H		;SZ4BPXH,Y
		STA	<WORK3
		LDA	ENKAIF,X		;1 OR 2 KAI FLG
		PHY
		JSL	>BGDTRD2
		PLY
		LDA	UNITNO
		CMP	SEKZ4SW+0
		BEQ	SZ4BK30
		CMP	SEKZ4SW+1
		BEQ	SZ4BK30
		CMP	SEKZ4SW+2
		BEQ	SZ4BK30
		CMP	SEKZ4SW+3
		BNE	SZ4BK20
SZ4BK30		EQU	$
		DEY
		BPL	SZ4BK10
		SEC			;SWITCH OK
		RTS
SZ4BK20		EQU	$
		CLC			;SWITCH BUT
		RTS
;----------------------------------------
SEKZ4CD		EQU	$
		WORD	00000,-0008
		BYTE	0C2H,000H,000H,000H
		WORD	00008,-0008
		BYTE	0C2H,040H,000H,000H
		WORD	00000,00000
		BYTE	0C0H,000H,000H,002H
;
SEKZ4CS		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#SEKZ4CD		;TFR MOTO
		STA	<WORK8
;
		LDA	#003H			;KAZU
		STA	<WORK6
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSL	>SETOAML		;SET OAM
;
		RTS
;======================================
CRSKEN		EQU	$
		LDY	#ENNO-1
BCR010		EQU	$
		LDA	ENMYNO,Y
		CMP	#SEKZ4
		BEQ	BCR020
;
		CPY	ENINDX
		BEQ	BCR020
;
		TYA
		EOR	<FRCNT
		AND	#01H
		BNE	BCR020
;
		LDA	ENMODE,Y
		CMP	#EMOVE
		BCC	BCR020
;
;		LDA	ENXPSL,X	; position (L) set
;		STA	<WORK0
;		LDA	ENXPSH,X	; position (H) set
;		STA	<WORK1
;		LDA	ENYPSL,X	; position (L) set
;		STA	<WORK2
;		LDA	ENYPSH,X	; position (H) set
;		STA	<WORK3
;
		LDA	ENXPSL,Y
		STA	<WORK4
		LDA	ENXPSH,Y
		STA	<WORK5
		LDA	ENYPSL,Y
		STA	<WORK6
		LDA	ENYPSH,Y
		STA	<WORK7
;
		MEM16
		REP	#00100000B
;
		LDA	ENXP2L ;<WORK0
		SEC
		SBC	<WORK4
		CLC
		ADC	#000CH
		CMP	#0018H
		BCS	BCR020
		LDA	ENYP2L  ;<WORK2
		SEC
		SBC	<WORK6
		CLC
		ADC	#000CH
		CMP	#0024H
		BCS	BCR020
		MEM8
		SEP	#00100000B
;
		LDA	#04H
		STA	ENHNFG,Y
;
		PHY
		LDA	#20H
		JSR	ESERCH
		PLY
		LDA	<WORK0
		STA	ENHNYS,Y
		LDA	<WORK1
		STA	ENHNXS,Y
BCR020		EQU	$
		MEM8
		SEP	#00100000B
		DEY
		BPL	BCR010
;
		RTS
;- - - - - - - - - - - - - - - - -
;========================================
;	BEECK ( BEE00 CHK)
;========================================
BEECKMV		EQU	$
		JSR	OAMCH2
		JSR	ENSTCK
;
		LDA	<MPDTNO
		CMP	#018H
		BNE	BEKMV20
;
		LDA	>ITEMR13	;? OKARINA GET
		CMP	#003H
		BNE	BEKMV30
		STZ	ENMODE,X	;Y
BEKMV30		EQU	$
		RTS
;
BEKMV20		EQU	$
		LDA	>ITEMR13	;? OKARINA GET
		AND	#002H
		BEQ	BEKMV10
		STZ	ENMODE,X	;Y
BEKMV10		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSSTXD		EQU	$
		HEX	00,04,08,0C,10,14,18,00
BSSTYD		EQU	$
		HEX	00,08,10,18,20,28,04,24
;-----------------------------------------------
BWAKOMV		EQU	$
		LDA	ENWRK0,X
		BNE	BWSTAR
;
		LDA	ENWRK1,X
		BNE	BWM020
;
		JSR	OAMCH2
		JMP	BWCHK
BWM020		EQU	$
		JSR	BWAKOCS
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
		LDA	<FRCNT
		AND	#00FH
		BNE	BWM010		; Hoshi kirakira set !
;
		LDA	#BWAKO
		JSL	>ENIDSH
		BMI	BWM010
;
		PHX
		JSL	>RNDSET
		AND	#07H
		TAX
		LDA	<WORK0
		CLC
		ADC	BSSTXD,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#00H
		STA	ENXPSH,Y
		JSL	>RNDSET
		AND	#07H
		TAX
		LDA	<WORK2
		CLC
		ADC	BSSTYD,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#00H
		STA	ENYPSH,Y
		LDA	#1FH
		STA	ENWRK2,Y
		STA	ENWRK0,Y
;;		LDA	#00H
;;		STA	ENMOD0,Y
		JSR	CLMOD0_Y
		LDA	#01001000B
		STA	ENMOD2,Y
		AND	#0FH
		STA	ENCLOR,Y
		LDA	#001H		;BIWAKO MODE
		STA	ENWRK1,Y
;
		PLX
BWM010		EQU	$
		RTS
;============================================
BWSTAR		EQU	$
		DEC	ENWRK2,X
;;		LDA	ENTIM0,X		
		BNE	BWST10
;
		STZ	ENMODE,X
BWST10		EQU	$
		LDA	ENWRK2,X
		LSR	A
		LSR	A
		LSR	A
		STA	ENCHPT,X
		LDA	#04H
		JSL	>OAMENT3
		JSR	EN1CSS
		RTS
;============================================
ITEME01		EQU	$-1
		BYTE	03AH,03AH,03BH,03BH
ITEME02		EQU	$-1
		BYTE	00CH,02AH
ITEME03		EQU	$-1
		BYTE	00AH
ITEME04		EQU	$-1
		BYTE	027H
ITEME05		EQU	$-1
		BYTE	029H,00DH
ITEME06		EQU	$-1
		BYTE	007H
ITEME07		EQU	$-1
		BYTE	008H
ITEME08		EQU	$-1
		BYTE	00FH
ITEME09		EQU	$-1
		BYTE	010H
ITEME10		EQU	$-1
		BYTE	011H
ITEME11		EQU	$-1
		BYTE	012H
ITEME12		EQU	$-1
		BYTE	009H
ITEME13		EQU	$-1
		BYTE	013H,014H,04AH
ITEME14		EQU	$-1
		BYTE	021H
ITEME15		EQU	$-1
		BYTE	01DH
ITEME16		EQU	$-1
ITEME17		EQU	$-1
		BYTE	015H
ITEME18		EQU	$-1
		BYTE	018H
ITEME19		EQU	$-1
		BYTE	019H
ITEME20		EQU	$-1
		BYTE	031H,01AH,01AH
ITEME21		EQU	$-1
		BYTE	01BH,01CH
ITEME22		EQU	$-1
		BYTE	04BH
ITEME23		EQU	$-1
		BYTE	01EH
ITEME24		EQU	$-1
		BYTE	01FH
ITEME25		EQU	$-1
ITEME26		EQU	$-1
		BYTE	049H,001H,002H,003H
ITEME27		EQU	$-1
		BYTE	004H,005H,006H
ITEME28		EQU	$-1
		BYTE	022H,023H
ITEME29		EQU	$-1
ITEME30		EQU	$-1
ITEME31		EQU	$-1
ITEME32		EQU	$-1
		BYTE	029H,016H,02BH,02CH,02DH,03DH,03CH,048H
;ITEME33		EQU	$-1
;		BYTE	034H
;
BWAKOIM		EQU	$
		WORD	ITEME01,ITEME02,ITEME03,ITEME04,ITEME05,ITEME06
		WORD	ITEME07,ITEME08,ITEME09,ITEME10,ITEME11,ITEME12
		WORD	ITEME13,ITEME14,ITEME15,ITEME16,ITEME17,ITEME18
		WORD	ITEME19,ITEME20,ITEME21,ITEME22,ITEME23,ITEME24
		WORD	ITEME25,ITEME26,ITEME27,ITEME28,ITEME29,ITEME30
		WORD	ITEME31,ITEME32;;;,ITEME33
;
BWCHK		EQU	$
		JSR	BWCHKCS
		JSR	ENSTCK
;
		LDA	<RMXYCT
		CMP	#015H
		BEQ	BWCHK10
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BWCHKM0
		WORD	BWCHKM1
		WORD	BWCHKM2
		WORD	BWCHKM3
		WORD	BWCHKM4
		WORD	BWCHKM5
		WORD	BWCHKM6
		WORD	BWCHKM7
		WORD	BWCHKM8
		WORD	BWCHKM9
		WORD	BWCHKMA
		WORD	BWCHKMB
		WORD	BWCHKMC
		WORD	BWCHKMD
;
BWCHK10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BWCKM00
		WORD	BWCKM01
		WORD	BWCKM02
		WORD	BWCKM03
		WORD	BWCKM04
		WORD	BWCKM05
		WORD	BWCKM06
		WORD	BWCKM07
		WORD	BWCKM08
		WORD	BWCKM09
		WORD	BWCKM0A
		WORD	BWCKM0B
		WORD	BWCKM0C
		WORD	BWCKM0D		;URANAI
		WORD	BWCKM0E		;URANAI
;----------------------------------------
BWCHKD1		EQU	$
		WORD	00032,-0064
		BYTE	024H,000H,000H,000H
		WORD	00032,-0056
		BYTE	034H,000H,000H,000H
		WORD	00032,-0064
		BYTE	024H,000H,000H,000H
		WORD	00032,-0056
		BYTE	034H,000H,000H,000H
;
BWCHKD2		EQU	$
		WORD	00032,-0064
		BYTE	024H,000H,000H,002H
		WORD	00032,-0064
		BYTE	024H,000H,000H,002H
		WORD	00032,-0064
		BYTE	024H,000H,000H,002H
		WORD	00032,-0064
		BYTE	024H,000H,000H,002H
;
BWCHKTB		EQU	$
		WORD	BWCHKD1,BWCHKD2
;
BWCHKCS		EQU	$
		LDA	<RMXYCT
		CMP	#015H
		BEQ	BCKCS10
;
		LDA	ENSTAT,X
		CMP	#005H
		BEQ	BCKCS20
		CMP	#006H
		BEQ	BCKCS20
		CMP	#00BH
		BEQ	BCKCS20
		CMP	#00CH
		BEQ	BCKCS20
		BRA	BCKCS10
BCKCS20		EQU	$
		PHX
		TXY
		LDA	ENCHPT,Y		;ITEM KAKIKAE
		TAX
;;		LDA	>TAKVMAD,X
;;		PHX
;;		PHY
;;		TXY
;;		JSL	>ITMCBFST
;;		PLY
;;		PLX
;
;		LDA	ENCLOR,Y		;COLOR SET
;		AND	#0F0H
;		STA	ENCLOR,Y
		LDA	>TAKAATR,X
		CMP	#0FFH
		BNE	BCKCS30
		LDA	#005H
BCKCS30		EQU	$
		AND	#007H
		ASL	A
;		ORA	ENCLOR,Y
		STA	ENCLOR,Y
;
		LDA	>TAKASBD,X		;? OAM BIG
		TAY
		LDA	BWCHKTB,Y		;TFR ADD SET
		STA	<WORK8
		LDA	BWCHKTB+1,Y
		STA	<WORK9
;
		LDA	#004H			;KAZU SET
;;		STA	<WORK6
;;		STZ	<WORK7
;
		PLX
		JSL	>SETOAML22
;
BCKCS10		EQU	$
		RTS
;
;----------------------------------------
BWCKM00		EQU	$
		STZ	PYALSP		;PL. MOVE
;
		LDA	ENTIM0,X
		BNE	BCM0010
;
		JSL	>WPMSCK
		BCS	BCM0010		;? NANIKA MOTEIRU
;					;N
		LDA	#LOW  MS_0140	;MSGE NO SET
		LDY	#HIGH MS_0140
		JSL	>ENMSG2L	;TUCH MSGE
		BCC	BCM0010
		INC	ENSTAT,X
		JSL	>PLYCLR1
		JSL	>KNBMCLR
		STZ	<PLMKCH		;PL. MUKI SET
BCM0010		EQU	$
		RTS
;----------------------------------------
BCM01CD		EQU	$
		BYTE	0005,0020,0025,0050
BCM01CP		EQU	$
		BYTE	005H,020H,025H,050H
;
BWCKM01		EQU	$
		LDA	MSG_RTS		;MSGE YES OR NO
		BNE	BCM0110
;					;YES
		LDA	>ITEMR49
		ORA	>ITEMR50
		BEQ	BCM0120
		LDA	#002H
BCM0120		EQU	$
		STA	ENCHPT,X	;OKANE SAVE
		TAY
		LDA	BCM01CP+0,Y
		STA	MSG_SU0
		LDA	BCM01CP+1,Y
		STA	MSG_SU1
		LDA	#LOW  MS_0514	;MSGE NO SET
		LDY	#HIGH MS_0514
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		LDA	#001H
		STA	PYALSP		;PL. STOP
		RTS
;
BCM0220		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
;
BCM0110		EQU	$		;NO
		LDA	#LOW  MS_0512	;MSGE NO SET
		LDY	#HIGH MS_0512
		JSL	>ENMSGSL
		STZ	ENSTAT,X	;START INIT
		LDA	#0FFH
		STA	ENTIM0,X
		RTS
;----------------------------------------
BWCKM02		EQU	$
		LDA	MSG_RTS		;MSGE YES OR NO
		CLC
		ADC	ENCHPT,X
		TAY
		LDA	BCM01CP,Y
		STA	MSG_SU1
;
		MEM16
		IDX8
		REP	#00100000B
		LDA	BCM01CD,Y
		AND	#000FFH
		STA	<WORK0
		LDA	>CONCNT
		CMP	<WORK0
		BCC	BCM0220		;? COIN ARU
;
		MEM8			;Y
		IDX8
		SEP	#00110000B
;
		LDA	<WORK0
		STA	ENMUKI,X	;MAISU SAVE
		TYA
		STA	ENCMKI,X
;
		INC	ENSTAT,X
		RTS
;
;----------------------------------------
BWCKM03		EQU	$
		LDA	#050H
		STA	ENTIM0,X
;
		LDA	ENMUKI,X
		STA	<WORK0
		STZ	<WORK1
;
		MEM16
		IDX8
		REP	#00100000B
		LDA	>CONCNT
		SEC
		SBC	<WORK0
		STA	>CONCNT
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	>ITEMR43
		CLC
		ADC	<WORK0
		STA	>ITEMR43
;
;		LDA	<KENKY		;KEN CLS
;		AND	#07FH
;		STA	<KENKY
;		STZ	<KENMD
;		LDA	<PYMKFG
;		AND	#0FEH
;		STA	<PYMKFG
;
		PHX
		LDA	ENCMKI,X
		JSL	>MCNINT		;COIN NAGE
		PLX
BCM0310		EQU	$
;
		LDA	>ITEMR43
		CMP	#0100
		BCC	BCM0330		;? MEGAMI COIN 100
		SBC	#0100		;Y
		STA	>ITEMR43	
		LDA	#005H		;MEGAMI SET
		STA	ENSTAT,X
		RTS
;
BCM0330		EQU	$
		LDA	>ITEMR43
		STZ	<WORK2
BCM0350		EQU	$
		CMP	#0010
		BCC	BCM0360
		SBC	#0010
		INC	<WORK2
		BRA	BCM0350
BCM0360		EQU	$
		ASL	<WORK2
		ASL	<WORK2
		ASL	<WORK2
		ASL	<WORK2
		ORA	<WORK2
		STA	MSG_SU0
		INC	ENSTAT,X
;
		RTS
;----------------------------------------
BWCKM04		EQU	$
		LDA	ENTIM0,X
		BNE	BCM0410
		LDA	#LOW  MS_014B	;MSGE NO SET
		LDY	#HIGH MS_014B
		JSL	>ENMSGSL
		LDA	#00DH
		STA	ENSTAT,X
BCM0410		EQU	$
		RTS
;----------------------------------------
BWCKM05		EQU	$
		LDA	ENTIM0,X
		BNE	BCM0510
		LDA	#BWAKO		;BWAKO SET
		JSL	>ENIDSH
		LDA	#01BH
		STA	SOUND0
		STZ	SVCKF0
;// 03.09.16 //		STA	SVSND0
;		BMI	BWKIT10
;
		LDA	<WORK0
		SEC
		SBC	BWKITPX
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#00H
		STA	ENXPSH,Y
		LDA	<WORK2
		SEC
		SBC	BWKITPY
		STA	ENYPSL,Y
		LDA	<WORK3
		SBC	#00H
		STA	ENYPSH,Y
;
		LDA	#001H		;BIWAKO MODE
		STA	ENWRK1,Y
;
		INC	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
;
		PHX
		JSL	>PWTRCGS2	;PL. COLOR CNG
		JSL	>MGMCGRS0	;F IN F OUT INIT
		PLX
;
		TYA
		STA	ENWRK3,X
;
BCM0510		EQU	$
		RTS
;----------------------------------------
BWCKM06		EQU	$
;					;F IN F OUT
		LDA	<FRCNT
		AND	#007H
		BNE	BCM0610
		PHX
		JSL	>MGMCGCNG
		PLX
		LDA	>CCNGCT		;? IRO CNG END
		BNE	BCM0610
		INC	ENSTAT,X
		LDA	#LOW  MS_014C	;MSGE NO SET
		LDY	#HIGH MS_014C
		JSL	>ENMSGSL	;MSGE SET
;
		PHX
		JSL	>PWTRCGS3
		STZ	<DPSUB
		LDA	#00100000B
		STA	<WD2131
		INC	<CGVMAF
		PLX
BCM0610		EQU	$
		RTS
;----------------------------------------
BWCKM07		EQU	$
		LDA	MSG_RTS
		BNE	BCM0710
;					;BOMB UP
		INC	ENSTAT,X
;
		RTS
BCM0710		EQU	$		;YAAA UP
		LDA	#00CH
		STA	ENSTAT,X
		RTS
;----------------------------------------
BWCKM08		EQU	$		;BOMB UP
		INC	ENSTAT,X
;
		LDA	>ITEMR49
		CMP	#007		;? MAX
		BEQ	BCM0810
		INC	A
		STA	>ITEMR49
		PHX
		TAX
		LDA	>BOMBMAP,X
		STA	MSG_SU0
		STA	>UPBMCT
		PLX
		LDA	#LOW  MS_014D	;MSGE NO SET
		LDY	#HIGH MS_014D
		JSL	>ENMSGSL	;MSGE SET
		RTS
;
BCM0810		EQU	$
		LDA	#LOW  MS_014F	;MSGE NO SET
		LDY	#HIGH MS_014F
		JSL	>ENMSGSL	;MSGE SET
		JMP	KAESU
;
;		MEM16
;		IDX8
;		REP	#00100000B
;		LDA	>CONCNT		;OKANE KAESU
;		CLC
;		ADC	#00100
;		STA	>CONCNT
;		MEM8
;		IDX8
;		SEP	#00110000B
;		RTS
;----------------------------------------
BWCKM09		EQU	$
		INC	ENSTAT,X
;
		PHX
		JSL	>PWTRCGS2
		LDA	#002H
		STA	<DPSUB
		LDA	#00110000B
		STA	<WD2131
		INC	CGVMAF
		PLX
		RTS
;----------------------------------------
BWCKM0A		EQU	$
		LDA	<FRCNT
		AND	#007H
		BNE	BCM0A10
		PHX
		JSL	>MGMCGCNG
		PLX
		LDA	>CCNGCT		;? IRO CNG END
		CMP	#01EH
		BNE	BCM0A20
		LDA	ENWRK3,X
		TAY
		LDA	#000H
		STA	ENMODE,Y	;KILL YOU
		BRA	BCM0A10
BCM0A20		EQU	$
		CMP	#000H
		BNE	BCM0A10
;
		INC	ENSTAT,X
BCM0A10		EQU	$
		RTS
;----------------------------------------
BWCKM0B		EQU	$
		PHX
		JSL	>MGMCGRS1
		JSL	>PWTRCGS3
		PLX
;
		STZ	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
;
		RTS
;----------------------------------------
BWCKM0C		EQU	$		;YAAA UP
		LDA	#009H
		STA	ENSTAT,X
;
		LDA	>ITEMR50
		CMP	#007		;? MAX
		BEQ	BCM0C10
		INC	A
		STA	>ITEMR50
		PHX
		TAX
		LDA	>YAAAMAP,X
		STA	MSG_SU0
		STA	>UPAWCT
		PLX
		LDA	#LOW  MS_014E	;MSGE NO SET
		LDY	#HIGH MS_014E
		JSL	>ENMSGSL	;MSGE SET
		RTS
;
BCM0C10		EQU	$
		LDA	#LOW  MS_014F	;MSGE NO SET
		LDY	#HIGH MS_014F
		JSL	>ENMSGSL	;MSGE SET
KAESU		EQU	$
		MEM16
		IDX8
		REP	#00100000B
		LDA	>CONCNT		;OKANE KAESU
		CLC
		ADC	#00100
		STA	>CONCNT
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------
BWCKM0D		EQU	$
		LDA	#LOW  MS_051A	;MSGE NO SET
		LDY	#HIGH MS_051A
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;----------------------------------------
BCM0EML		EQU	$
		BYTE	LOW  MS_0516
		BYTE	LOW  MS_0517
		BYTE	LOW  MS_0518
		BYTE	LOW  MS_0519
BCM0EMH		EQU	$
		BYTE	HIGH MS_0516
		BYTE	HIGH MS_0517
		BYTE	HIGH MS_0518
		BYTE	HIGH MS_0519
;
BCM0EUN		EQU	$
		BYTE	1,0,0,2
;
BWCKM0E		EQU	$
		JSL	>RNDSET
		AND	#003H
		TAY
		LDA	BCM0EUN,Y
		STA	URANAIF
		STZ	URANAIC
;
		LDA	BCM0EML,Y
		XBA
		LDA	BCM0EMH,Y
		TAY
		XBA
		JSL	>ENMSGSL	;MSGE SET
		STZ	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
		RTS
;----------------------------------------
;----------------------------------------
;----------------------------------------
;----------------------------------------
BWCHKM0		EQU	$
		STZ	PYALSP		;PL. MOVE
;
		LDA	ENTIM0,X
		BNE	BWCM010
;
		JSL	>WPMSCK
		BCS	BWCM010		;? NANIKA MOTEIRU
;					;N
		LDA	#LOW  MS_0510	;MSGE NO SET
		LDY	#HIGH MS_0510
		JSL	>ENMSG2L	;TUCH MSGE
		BCC	BWCM010
		INC	ENSTAT,X
		JSL	>PLYCLR1
		STZ	<PLMKCH		;PL. MUKI SET
		STZ	ENCMKI,X	;NEXT MSGE NO SET(ENSTAT = A)
;
BWCM010		EQU	$
		RTS
;----------------------------------------
BWCHKM1		EQU	$
		LDA	MSG_RTS		;MSGE YES OR NO
		BNE	BWCM110
;					;YES
		LDA	#LOW  MS_0141	;MSGE NO SET
		LDY	#HIGH MS_0141
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		LDA	#001H
		STA	PYALSP		;PL. STOP
;
		RTS
;
BWCM110		EQU	$		;NO
		LDA	#LOW  MS_0511	;MSGE NO SET
		LDY	#HIGH MS_0511
		JSL	>ENMSGSL
		STZ	ENSTAT,X	;START INIT
		LDA	#0FFH
		STA	ENTIM0,X
		RTS
;----------------------------------------
BWCHKM2		EQU	$
		INC	ENSTAT,X
;					;PL. DEMO START
		PHX
		LDA	MSG_RTS		;MSGE ITEM NO
		STA	ENWRK2,X
		TAX
		ASL	A
		TAY
		LDA	BWAKOIM,Y
		STA	<WORK0
		LDA	BWAKOIM+1,Y
		STA	<WORK1
		LDA	>ITEMR01,X
		PHA			;ITEM SAVE(BG3)
		CPX	#033-1
		BEQ	BWCM220
		CPX	#004-1
		BNE	BWCM210
BWCM220		EQU	$
		LDA	#001H
BWCM210		EQU	$
		TAY
		LDA	#000H		;ITEM CLS(BG3)
		STA	>ITEMR01,X
		LDA	(<WORK0),Y
		PHA			;ITEM SAVE(OBJ)
		TAX
;
;		LDA	<KENKY		;KEN CLS
;		AND	#07FH
;		STA	<KENKY
;		STZ	<KENMD
;		LDA	<PYMKFG
;		AND	#0FEH
;		STA	<PYMKFG

		LDY	#004H
		LDA	#TKNAG
		JSL	>TKGINT
		JSL	>ITEM0ST	;ITEM WRITE
		PLA
		PLY
		PLX
		STA	ENCHPT,X	;ITEM SAVE(OBJ)
		TYA
		STA	ENMUKI,X	;ITEM SAVE(BG3)
		LDA	#0FFH
		STA	ENTIM0,X
		RTS
;----------------------------------------
BWKITPX		EQU	$
		BYTE	000H
BWKITPY		EQU	$
		BYTE	050H
BWCHKM3		EQU	$
		LDA	ENTIM0,X
		BNE	BCKM310
;
		LDA	#BWAKO		;BWAKO SET
		JSL	>ENIDSH
		LDA	#01BH
		STA	SOUND0
		STZ	SVCKF0
;// 03.09.16 //		STA	SVSND0
;		BMI	BWKIT10
;
		LDA	<WORK0
		SEC
		SBC	BWKITPX
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#00H
		STA	ENXPSH,Y
		LDA	<WORK2
		SEC
		SBC	BWKITPY
		STA	ENYPSL,Y
		LDA	<WORK3
		SBC	#00H
		STA	ENYPSH,Y
;
		LDA	#001H		;BIWAKO MODE
		STA	ENWRK1,Y
;
		INC	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
;
		PHX
		JSL	>PWTRCGS2	;PL. COLOR CNG
		JSL	>MGMCGRS0	;F IN F OUT INIT
		PLX
;
		TYA
		STA	ENWRK3,X
;
BCKM310		EQU	$
		RTS
;----------------------------------------
BWCHKM4		EQU	$
;					;F IN F OUT
		LDA	<FRCNT
		AND	#007H
		BNE	BWCM410
		PHX
		JSL	>MGMCGCNG
		PLX
		LDA	>CCNGCT		;? IRO CNG END
		BNE	BWCM410
		INC	ENSTAT,X
		LDA	#LOW  MS_0142	;MSGE NO SET
		LDY	#HIGH MS_0142
		JSL	>ENMSGSL	;MSGE SET
;
		PHX
		JSL	>PWTRCGS3
		STZ	<DPSUB
		LDA	#00100000B
		STA	<WD2131
		INC	<CGVMAF
		PLX
BWCM410		EQU	$
		RTS
;----------------------------------------
BWCHKM5		EQU	$
		LDA	MSG_RTS
		BNE	BWCM510
		INC	ENSTAT,X
		RTS
BWCM510		EQU	$
		LDA	#00BH
		STA	ENSTAT,X
		RTS
;----------------------------------------
BWCHKM6		EQU	$
		INC	ENSTAT,X
;
		LDA	>GDTRPF
		BNE	BCKM610		;? URA OMOTE
;
		LDA	ENCHPT,X	;OMOTE
		CMP	#00CH		;BUMERN
		BNE	BCKM620
		LDA	#02AH
		STA	ENCHPT,X
		LDA	#001H
		STA	ENCMKI,X
		BRA	BCKM6E0
BCKM620		EQU	$
		CMP	#004H		;TATE
		BNE	BCKM630
		LDA	#005H
		STA	ENCHPT,X
		LDA	#002H
		STA	ENCMKI,X
		BRA	BCKM6E0
BCKM630		EQU	$
		CMP	#016H		;BIN
		BNE	BCKM640
		LDA	#02CH
		STA	ENCHPT,X
		LDA	#003H
		STA	ENCMKI,X
		BRA	BCKM6E0
BCKM640		EQU	$
		BRA	BCKM6F0
;--
BCKM610		EQU	$		;URA
		LDA	ENCHPT,X
		CMP	#03AH		;YAAAA
		BNE	BCKM650
		LDA	#03BH
		STA	ENCHPT,X
		LDA	#004H
		STA	ENCMKI,X
		LDA	#LOW  MS_0515	;MSGE NO SET
		LDY	#HIGH MS_0515
		JSL	>ENMSGSL	;MSGE SET
		RTS
BCKM650		EQU	$
		CMP	#002H		;KEN3
		BNE	BCKM660
		LDA	#003H
		STA	ENCHPT,X
		LDA	#005H
		STA	ENCMKI,X
		BRA	BCKM6E0
BCKM660		EQU	$
		CMP	#016H		;BIN
		BNE	BCKM670
		LDA	#02CH
		STA	ENCHPT,X
		LDA	#003H
		STA	ENCMKI,X
		BRA	BCKM6E0
BCKM670		EQU	$
		BRA	BCKM6F0
;--
BCKM6E0		EQU	$
		LDA	#LOW  MS_0143	;MSGE NO SET
		LDY	#HIGH MS_0143
		JSL	>ENMSGSL	;MSGE SET
;
		RTS
;
BCKM6F0		EQU	$
		LDA	#LOW  MS_0513	;MSGE NO SET
		LDY	#HIGH MS_0513
		JSL	>ENMSGSL	;MSGE SET
;
		RTS
;----------------------------------------
BWCHKM7		EQU	$
;					;PL. DEMO
		LDA	ENMUKI,X	;ITEM NANI O MOTEITAKA
		TAY
		LDA	ENWRK2,X
		PHX
		TAX
		TYA
		CPX	#004-1
		BNE	BCKM710
		STA	>ITEMR01,X	;ITEM SAVE(BG3)
BCKM710		EQU	$
		PLX
		INC	ENSTAT,X
;
		PHX
		JSL	>PWTRCGS2
		LDA	#002H
		STA	<DPSUB
		LDA	#00110000B
		STA	<WD2131
		INC	CGVMAF
		PLX
		RTS
;----------------------------------------
BWCHKM8		EQU	$
		LDA	<FRCNT
		AND	#007H
		BNE	BWCM810
		PHX
		JSL	>MGMCGCNG
		PLX
		LDA	>CCNGCT		;? IRO CNG END
		CMP	#01EH
		BNE	BWCM820
		LDA	ENWRK3,X
		TAY
		LDA	#000H
		STA	ENMODE,Y	;KILL YOU
		BRA	BWCM810
BWCM820		EQU	$
		CMP	#000H
		BNE	BWCM810
;
		INC	ENSTAT,X
BWCM810		EQU	$
		RTS
;----------------------------------------
BWCHKM9		EQU	$
		INC	ENSTAT,X
;
		PHX
		JSL	>MGMCGRS1
		JSL	>PWTRCGS3
		PLX
;
		PHX
		LDA	#002H		;PL. GET ITEM
		STA	ITMVFG
		LDA	ENCHPT,X
		TAY
		JSL	>ATMSIT
		PLX
;
		RTS
;----------------------------------------
BCKMAML		EQU	$
		BYTE	LOW  MS_0146
		BYTE	LOW  MS_0147
		BYTE	LOW  MS_0149
		BYTE	LOW  MS_0148
		BYTE	LOW  MS_014A
;
BCKMAMH		EQU	$
		BYTE	HIGH MS_0146
		BYTE	HIGH MS_0147
		BYTE	HIGH MS_0149
		BYTE	HIGH MS_0148
		BYTE	HIGH MS_014A
;
BWCHKMA		EQU	$
		LDA	ENCMKI,X
		BEQ	BCKMA10		;? POWER UP ITEM
;
		DEC	A		;Y
		TAY
		LDA	BCKMAML,Y
		XBA
		LDA	BCKMAMH,Y
		TAY
		XBA
		JSL	>ENMSGSL	;MSGE SET
;
BCKMA10		EQU	$
		STZ	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
		RTS
;----------------------------------------
BWCHKMB		EQU	$
		INC	ENSTAT,X
		LDA	#LOW  MS_0144	;MSGE NO SET
		LDY	#HIGH MS_0144
		JSL	>ENMSGSL	;MSGE SET
		RTS
;----------------------------------------
BWCHKMC		EQU	$
		LDA	MSG_RTS
		BNE	BCKMC10
;
		INC	ENSTAT,X
		RTS
;
BCKMC10		EQU	$
		LDA	#006H
		STA	ENSTAT,X
		RTS
;----------------------------------------
BWCHKMD		EQU	$
		LDA	#LOW  MS_0145	;MSGE NO SET
		LDY	#HIGH MS_0145
		JSL	>ENMSGSL	;MSGE SET
;
		LDA	#007H
		STA	ENSTAT,X
;					;F IN F OUT
		RTS
;----------------------------------------
;----------------------------------------
;============================================
;============================================
BWCXAD		EQU	$
		HEX	00,10
		HEX	00,08,10,18
		HEX	00,08,10,18
		HEX	00,10
;
		HEX	00,10
		HEX	00,08,10,18
		HEX	00,08,10,18
		HEX	00,10
BWCYAD		EQU	$
		HEX	00,00
		HEX	10,10,10,10
		HEX	18,18,18,18
		HEX	20,20
;
		HEX	00,00
		HEX	10,10,10,10
		HEX	18,18,18,18
		HEX	20,20
BWCCDT		EQU	$
		HEX	C7,C7
		HEX	CF,CA,CA,CF
		HEX	DF,DA,DA,DF
		HEX	CB,CB
;
		HEX	CD,CD
		HEX	C9,CA,CA,C9
		HEX	D9,DA,DA,D9
		HEX	CB,CB
BWCADT		EQU	$
		HEX	00,40
		HEX	00,00,40,40
		HEX	00,00,40,40
		HEX	00,40
;
		HEX	00,40
		HEX	00,00,40,40
		HEX	00,00,40,40
		HEX	00,40
BWCSBD		EQU	$
		HEX	02,02
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	02,02
;
		HEX	02,02
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	02,02
;---------------------------------------------------
BAOCDPX		EQU	000
BAOCDPY		EQU	000
;
BAOCD10		EQU	$
		WORD	00000+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,000H,000H,002H
		WORD	00016+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,040H,000H,002H
		WORD	00000+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,000H,000H,002H
		WORD	00016+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,040H,000H,002H
;
		WORD	00000+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,000H,000H,002H
		WORD	00016+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,040H,000H,002H
		WORD	00000+BAOCDPX,00016+BAOCDPY
		BYTE	0EBH,000H,000H,002H
		WORD	00016+BAOCDPX,00016+BAOCDPY
		BYTE	0EBH,040H,000H,002H
		WORD	00000+BAOCDPX,00032+BAOCDPY
		BYTE	0EDH,000H,000H,002H
		WORD	00016+BAOCDPX,00032+BAOCDPY
		BYTE	0EDH,040H,000H,002H
;
		WORD	00000+BAOCDPX,00000+BAOCDPY
		BYTE	0EFH,000H,000H,000H
		WORD	00024+BAOCDPX,00000+BAOCDPY
		BYTE	0EFH,040H,000H,000H
		WORD	00000+BAOCDPX,00008+BAOCDPY
		BYTE	0FFH,000H,000H,000H
		WORD	00024+BAOCDPX,00008+BAOCDPY
		BYTE	0FFH,040H,000H,000H
;
		WORD	00000+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,000H,000H,002H
		WORD	00016+BAOCDPX,00000+BAOCDPY
		BYTE	0E9H,040H,000H,002H
		WORD	00000+BAOCDPX,00016+BAOCDPY
		BYTE	0EBH,000H,000H,002H
		WORD	00016+BAOCDPX,00016+BAOCDPY
		BYTE	0EBH,040H,000H,002H
		WORD	00000+BAOCDPX,00032+BAOCDPY
		BYTE	0EDH,000H,000H,002H
		WORD	00016+BAOCDPX,00032+BAOCDPY
		BYTE	0EDH,040H,000H,002H
;
;---------------------------------------------------
BWAKOCS		EQU	$
		LDA	>GDTRPF
		BNE	BAOCS10
;
		JSR	OAMCHK
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORKD		; x4
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	<WORKD		; x4 + x8 = x12
		STA	<WORK6
		PHX
		LDX	#0BH
BWC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	BWCXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	BWCYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	BWCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	BWCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA	
		LSR	A
		LSR	A
		TAY
		LDA	BWCSBD,X
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	BWC010
		PLX
;
		LDY	#0FFH
		LDA	#0BH
		JSR	ALOMCK
		RTS
;----------------------------------------
BAOCS10		EQU	$
		LDA	#00AH
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
;
		ADC	#LOW  BAOCD10
		STA	<WORK8
		LDA	#HIGH BAOCD10
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML2
;
		RTS
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RIVERMV		EQU	$
		LDA	ENSTAT,X
		BEQ	RVM000
		JSR	RIVERCS
		BRA	RVM001
RVM000		EQU	$
		JSR	OAMCH2
RVM001		EQU	$
		LDA	ENDSPL,X
		BEQ	RVM002
;
;;		STZ	ENCHPT,X
;;		STZ	ENSTAT,X
;;		LDA	#20H
;;		STA	ENTIM0,X
;;;
;;		LDA	#EMOVE
;;		STA	ENMODE,X
		LDA	#EINIT
		STA	ENMODE,X
RVM002		EQU	$
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#00FFH
		ASL	A
		TAY
		LDA	RVMVAD,Y
;;		DEC	A
		PHA
		IDX8
		MEM8
		SEP	#00110000B
		RTS
;;		LDA	ENSTAT,X
;;		JSL	>JSRSUB
RVMVAD		EQU	$
		WORD	RVMOV2-1H
		WORD	RVUP-1H
		WORD	RVMOVE-1H
		WORD	RVDOWN-1H
;===============================================
;- - - - - - -
RVMOV2		EQU	$		; In floor move !
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	RVM210
		INC	ENSTAT,X
		LDA	#7FH
		STA	ENTIM0,X
		RTS
RVM210		EQU	$
;;		LDA	ENTIM1,X
;;		BNE	RVM220
;;		LDA	#10H
;;		STA	ENTIM1,X
;;		JSL	>RNDSET
;;		AND	#03H
;;		STA	ENMUKI,X
;;RVM220		EQU	$
;;		LDY	ENMUKI,X
;;		LDA	RVM2XS,Y
;;		STA	ENXSPD,X
;;		LDA	RVM2YS,Y
;;		STA	ENYSPD,X
;
		LDA	#10H
		JSR	PSERCH
;
		JSR	ENMVCL
		JSR	ENBGCK
		RTS
;===============================================
RVWAIT		EQU	$		;
		LDA	ENTIM0,X
		BNE	RVW010
;
		INC	ENSTAT,X
		LDA	#7FH
		STA	ENTIM0,X
RVW010		EQU	$
		RTS
;===============================================
RVUDPT		EQU	$
		HEX	0A,09,08,07,06,05,04,03
		HEX	02,01,02,01,02,01,00,00
;
RVUP		EQU	$
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	RVU010
;
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#3FH
		ADC	#0A0H
		STA	ENTIM0,X
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		RTS
RVU010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	RVUDPT,Y
		STA	ENCHPT,X
		RTS
;===============================================
RVMVPT		EQU	$
		HEX	09,0A,0B;,0C
RVSHSD		EQU	$
		HEX	0C,08
;
RVMOVE		EQU	$
;;		JSR	CRENPL
;;		JSR	CRKNEN
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	RVM010
RVM008		EQU	$
		INC	ENSTAT,X
		LDA	#07FH
		STA	ENTIM0,X
		RTS
RVM010		EQU	$
		LDA	ENCONT,X
		AND	#07H
		BNE	RVM012
;
		LDY	ENWRK0,X
		LDA	RVSHSD,Y
		JSR	PSERCH
RVM012		EQU	$
		JSR	ENMVCL
		JSR	ENBGCK
		LDA	ENCBFG,X
		BNE	RVM008
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	RVMVPT,Y
		STA	ENCHPT,X
		RTS
;===============================================
RVDWPT		EQU	$
		HEX	0A,09,08,07,06,05,04,03
		HEX	02,01,02,01,02,01,00,00
;
RVDOWN		EQU	$
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	RVD010
;
		STZ	ENSTAT,X
		JSL	>RNDSET
		AND	#1FH
		ADC	#040H
		STA	ENTIM0,X
		RTS
RVD010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		EOR	#0FH
		TAY
		LDA	RVDWPT,Y
		STA	ENCHPT,X
		RTS
;===============================================
;
;
;
;
;
;
;
;
;
;
;		LDA	<KEYA2
;		AND	#08H
;		BEQ	RVM010
;		INC	ENCHPT,X
;		LDA	ENCHPT,X
;		CMP	#0EH
;		BNE	RVM010
;		STZ	ENCHPT,X
;RVM010		EQU	$
;		LDA	<KEYA2
;		AND	#04H
;		BEQ	RVM020
;		DEC	ENCHPT,X
;		BPL	RVM020
;		LDA	#0DH
;		STA	ENCHPT,X
;RVM020		EQU	$
		RTS
;==============================================
;==============================================
RVCXAD		EQU	$
		WORD	002H,006H,006H,006H
		WORD	000H,008H,008H,008H
		WORD	000H,008H,008H,008H
		WORD	000H,008H,000H,008H
		WORD	000H,008H,000H,008H
		WORD	000H,000H,000H,008H
		WORD	000H,000H,000H,008H
		WORD	000H,000H,000H,008H
		WORD	000H,000H,000H,008H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
RVCYAD		EQU	$
		WORD	008H,008H,008H,008H
		WORD	008H,008H,008H,008H
		WORD	008H,008H,008H,008H
		WORD	005H,005H,008H,008H
		WORD	005H,005H,008H,008H
		WORD	002H,002H,008H,008H
		WORD	001H,001H,008H,008H
		WORD	000H,000H,008H,008H
		WORD	0FFFFH,0FFFFH,08H,08H
		WORD	08H,0FFFEH,0FFFEH,0
		WORD	08H,0FFFEH,0FFFEH,0
		WORD	08H,0FFFEH,0FFFEH,0
		WORD	08H,0FFFEH,0FFFEH,0
		WORD	08H,0FFFEH,0FFFEH,0
RVCCDT		EQU	$
		HEX	28,28,28,28
		HEX	28,28,28,28
		HEX	38,38,38,38
		HEX	08,09,28,28
		HEX	08,09,D9,D9
		HEX	08,08,D8,D8
		HEX	08,08,DA,DA
		HEX	06,06,D9,D9
		HEX	26,26,D8,D8
		HEX	6C,06,06,0
		HEX	6C,26,26,0
		HEX	6C,06,06,0
		HEX	6C,26,26,0
		HEX	6C,08,08,0
RVCADT		EQU	$
		HEX	01,41,41,41	
        	HEX	01,41,41,41
		HEX	01,41,41,41
		HEX	01,01,01,41
		HEX	01,01,00,40
		HEX	01,01,00,40
		HEX	01,01,00,40
		HEX	01,01,00,40
		HEX	00,01,00,40
		HEX	06,41,41,0
		HEX	06,41,41,0
		HEX	06,01,01,0
		HEX	06,01,01,0
		HEX	06,01,01,0
RVCSBD		EQU	$
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	02,02,00,00
		HEX	02,02,00,00
		HEX	02,02,00,00
		HEX	02,02,00,00
		HEX	02,02,02,0
		HEX	02,02,02,0
		HEX	02,02,02,0
		HEX	02,02,02,0
		HEX	02,02,02,0
;-------------------------------------------
RVCIDX		EQU	$
		HEX	1,1,1,3,3,3,3,3,3
		HEX	1,1,1,1,1
;
RIVERCS		EQU	$
		JSR	OAMCHK
		LDA	ENCHPT,X
		TAY
		ASL	A
		ASL	A
		STA	<WORK6
		PHX
		LDX	RVCIDX,Y
		LDY	#00H
RVC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	RVCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	RVCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	RVC020
;
		LDA	#0F0H
		STA	(<OAMADR),Y
RVC020		EQU	$
		PLX
;
		LDA	<WORK5
		PHA
;
		LDA	RVCCDT,X
		INY
		STA	(<OAMADR),Y
;
		CMP	#060H
		BCS	RVC028
		CMP	#28H
		BEQ	RVC028
		CMP	#38H
		BNE	RVC030		; Tichi color ?
RVC028		EQU	$		; yes !
		LDA	<WORK5
		AND	#11110000B
		STA	<WORK5
RVC030		EQU	$
		LDA     RVCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
;
		PLA
		STA	<WORK5
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	RVCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	RVC010		
		PLX
		RTS
;
;
;
;
;
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	the hart move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HART1MV		EQU	$
;;		JSR	ITCLCK		; Item timer clear check !
;
		JSR	ITEMCS		;OAM set
;
		JSR	ENSTCK		;scroll : not return !
;
		JSR	CRITPL		;item hit check
;
		JSR	BUMECK		; buumeran kuttuki check !
;
		JSR	ENMVCL		;xclc,yclc
		JSR	ENZCLC		;zclc
		LDA	ENZPSL,X
		BPL	HART110		;tuita?
		STZ	ENZPSL,X	;y
		INC	ENSTAT,X
		STZ	ENCHPT,X
HART110		EQU	$
;
		LDA	ENCLOR,X
		AND	#0BFH
		STA	ENCLOR,X
		LDA	ENXSPD,X
		BMI	HART120
		LDA	ENCLOR,X
		EOR	#040H
		STA	ENCLOR,X
;
HART120		EQU	$
;		JSR	ENBGCK		;BG check sub
;		LDA	ENCBFG,X
;		AND	#00001111B
;		BEQ	HART130		;atari?
;		STZ	ENXSPD,X	;y
;		INC	ENMUKI,X
HART130		EQU	$
;
;;		JSR	CRITPL		;item hit check
;
		LDA	ENSTAT,X
		CMP	#003H
		BCC	HART140
		LDA	#003H
HART140		EQU	$
		JSL	>JSRSUB
;
		WORD	HART1M0		;init
		WORD	HART1M1		;up
		WORD	HART1M2		;stop
		WORD	HART1M3		;down
;----------------------------------------
HART1M0		EQU	$
		INC	ENSTAT,X
		LDA	#012H
		STA	ENTIM0,X
		LDA	#014H
		STA	ENZSPD,X
		LDA	#001H
		STA	ENCHPT,X
		STZ	ENMUKI,X
;
		RTS
;----------------------------------------
HART1M1		EQU	$
		LDA	ENTIM0,X
		BNE	HAM1010
;
		INC	ENSTAT,X
		LDA	#0FDH
		STA	ENZSPD,X
		STZ	ENXSPD,X
;
		RTS
;
HAM1010		EQU	$
		DEC	ENZSPD,X
		RTS
;----------------------------------------
;HAXSDT		EQU	$
;		BYTE	001H,0FFH
;
HAXSD1		EQU	$
		BYTE	00AH,0F6H
;
HART1M2		EQU	$
		LDA	ENTIM0,X
		BNE	HAM2010
;
		LDA	ENMUKI,X
		AND	#001H
		TAY
		LDA	ENXSPD,X
		CLC
		ADC	HAXSDT,Y
		STA	ENXSPD,X
		CMP	HAXSD1,Y
		BNE	HAM2010
		INC	ENMUKI,X
		LDA	#008H
		STA	ENTIM0,X
;
HAM2010		EQU	$
		RTS
;----------------------------------------
HART1M3		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		STZ	ENZSPD,X
;
		RTS
;====================================================
BUMECK		EQU	$
		LDA	ENWRK1,X
		BEQ	BCK010
		TAY
		DEY
;
		LDA	BMMODE,Y
		BEQ	BCK020		; buumeran aru ?
;					; yes ! kuttsuki !
		LDA	BMXPSL,Y
		STA	ENXPSL,X
		LDA	BMXPSH,Y
		STA	ENXPSH,X
		LDA	BMYPSL,Y
		STA	ENYPSL,X
		LDA	BMYPSH,Y
		STA	ENYPSH,X
		STZ	ENZPSL,X
BCK008		EQU	$
		PLA
		PLA
BCK010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - - - -
BCK020		EQU	$
;;		STZ	ENMODE,X
;;		JSR	HART1GT
		JSL	>ITMGET
		BRA	BCK008
;========================================
YOSEIMV		EQU	$
		LDA	#001H
		STA	ENNOCR,X
;;		JSR	ITCLCK		; Item timer clear check !
;
		LDA	ENSTAT,X
		BNE	YSIMV10
		JSR	ITEMCS		;OAM set
YSIMV10		EQU	$
;
		JSR	YOSEI1T		;1 TIME GET 1
;
		JSR	ENSTCK		;scroll : not return !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	YOSEIM0
		WORD	YOSEIM1
;----------------------------------------
YOSEIM0		EQU	$
		LDA	ENTIM3,X
		BNE	YOSEI10		; Hit protect ?
;					; yes !
		JSR	CRENPL
		BCC	YOSEI20
		JSL	>ITMGET
		BRA	YOSEI10
;
YOSEI20		EQU	$
		JSR	CRKNEN		;PL. KEN CHK
		BEQ	YOSEI10
;
		INC	ENSTAT,X
		LDA	#LOW  MS_0341	;MSGE NO
		LDY	#HIGH MS_0341	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		RTS
;
YOSEI10		EQU	$
;
		JSR	BUMECK		; buumeran kuttuki check !
;
		JSL	>YOSEIMJ
		RTS
;----------------------------------------
YOSEIM1		EQU	$
		LDA	MSG_RTS
		BNE	YSIM110
;
		JSL	>BINCHKL	;BIN AKI CHK
		BMI	YSIM120
		PHX
		TAX
		LDA	#006H
		STA	>BINCT0,X
		JSL	>ITEM0ST
		PLX
		STZ	ENMODE,X	;KILL I
		RTS
YSIM120		EQU	$
		LDA	#LOW  MS_0342	;MSGE NO
		LDY	#HIGH MS_0342	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
;
YSIM110		EQU	$
		LDA	#030H
		STA	ENTIM3,X
		STZ	ENSTAT,X
		RTS
;----------------------------------------
YOSEI1T		EQU	$
		LDA	<GAMEMD
		CMP	#002H
		BNE	YSI1T10
;
                MEM16
                IDX8
		REP	#00100000B
;
		LDA	MSGENOL
		CMP	#MS_0341
		BEQ	YSI1T20
		CMP	#MS_0342
		BNE	YSI1T10
YSI1T20		EQU	$
		MEM8
                IDX8
		SEP	#00110000B
		LDA	#028H
		STA	ENTIM3,X
YSI1T10		EQU	$
                MEM8
                IDX8
		SEP	#00110000B
                RTS
;----------------------------------------
;========================================
KGIDCK		EQU	$
		BYTE	01000000B	;Item 1 save Data !
		BYTE	00100000B	;     2
;
KAGI0MV		EQU	$
KAGI1MV		EQU	$
;;		PHX
;;		LDA	<RMXYCT
;;		ASL	A
;;		TAX
;;		LDA	>DJNTBL+1,X
;;		PLX
;;		AND	#00000100B
;
		LDY	KAGIFG,X
;
		LDA	!EMYSTT+1
		AND	KGIDCK,Y
;;		AND	#01000000B
		BEQ	KGM000		; Kono room kagi cach ?
;					; yes ! not move !
		STZ	ENMODE,X
		RTS
KGM000		EQU	$
		JSR	ITEMC22
		BRA	KGM010
;================================================
PTATEMV		EQU	$
RUPYRMV		EQU	$
RUPYYMV		EQU	$
RUPYBMV		EQU	$
BOMB1MV		EQU	$
BOMB2MV		EQU	$
BOMB3MV		EQU	$
;;NIKU1MV		EQU	$
;;NIKU2MV		EQU	$
;;OPTN1MV		EQU	$
TUBO1MV		EQU	$
TUBO2MV		EQU	$
;;CRYS1MV		EQU	$
;;TRYFRMV		EQU	$
;;TRYFYMV		EQU	$
;;TRYFBMV		EQU	$
;;SPESRMV		EQU	$
;;SPESYMV		EQU	$
;;SPESBMV		EQU	$
YAAA1MV		EQU	$
YAAA2MV		EQU	$
;;		JSR	ITCLCK		; Item timer clear check !
;;KGM010		EQU	$
		JSR	ITEMCS
KGM010		EQU	$
;
		JSR	ENSTCK
;
;;		JSR	ENXCLC
		JSR	ENZCLC
;
;;		LDA	<DJFLG
;;		BNE	IM0010
;
		JSR	ENMVCL
;
		LDA	ENTUTM,X
		BNE	IM0018
;
		JSR	ENBGCK
;
		JSR	ENTUCK
;
IM0018		EQU	$
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	IM0030
;
		STZ	ENZPSL,X
;
		LDA	ENXSPD,X
		ASL	A
		ROR	ENXSPD,X
;
		LDA	ENYSPD,X
		ASL	A
		ROR	ENYSPD,X
;
		LDA	ENZSPD,X
		EOR	#0FFH
		INC	A
		LSR	A
;;		NOP	
		CMP	#09H
		BCS	IM0020
;
		LDA	#00H
		STA	ENYSPD,X
		STA	ENXSPD,X
IM0020		EQU	$
		STA	ENZSPD,X
;
IM0030		EQU	$
		JSR	BUMECK		; buumeran kuttuki check !
;
		JSR	CRITPL	; item hit check !
		RTS
;------------------------------------
ITCLCK		EQU	$
		LDA	ENSTTM,X
		BEQ	KGM00E		; Clear time check !
;
		LDA	<GAMEMD
		ORA	ENSTFG
		BNE	KGM00E
;
		LDA	<FRCNT
		LSR	A
		BCS	KGM008
;
		DEC	ENSTTM,X
KGM008		EQU	$
		LDA	ENSTTM,X
		BNE	KGM00C
;
		STZ	ENMODE,X
KGM00C		EQU	$
		CMP	#28H
		BCS	KGM00E
		AND	#01H
		BNE	KGM00E
;
		JSR	OAMCH2
		PLA
		PLA
KGM00E		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - -
;==========================================================================
CRITPL		EQU	$
		LDA	ENTIM3,X
		BNE	CIP000		; Hit protect ?
;					; yes !
		JSR	CRENPL4
		BCC	CIP000
;
		JSL	>ITMGET
CIP000		EQU	$
		RTS
;----------------------------------------
ITMGET		EQU	$		; Cach item !
		PHB
		PHK
		PLB
		JSR	ITG000
		PLB
		RTL
;- - - - - - -
ITGSDT		EQU	$
;;			0 1 2 3 4 5 6 7 8 9 A B  C  D E     F 0 1 2 3 4 5 6 7
		HEX	B,A,A,A,B,B,B,B,B,B,B,B,2F,2F,B
;;;		HEX	B,A,A,A,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B
ITG000		EQU	$
;
		STZ	ENMODE,X	; item cls
		LDA	ENMYNO,X
		SEC
		SBC	#HART1
		TAY
;		JSL	>SDLRCE
;		ORA	ITGSDT,Y
;		STA	SOUND3		; (S)
;
		LDA	ITGSDT,Y
		JSL	>SDLRE3	;(S)
ITG001		EQU	$
		TYA
		JSL	>JSRSUB
		WORD	HART1GT
		WORD	RUPYRGT
		WORD	RUPYYGT
		WORD	RUPYBGT
		WORD	BOMB1GT
		WORD	BOMB2GT
		WORD	BOMB3GT
		WORD	TUBO1GT
		WORD	TUBO2GT
		WORD	YAAA1GT
		WORD	YAAA2GT
		WORD	YOSEIGT
		WORD	KAGI0GT
		WORD	KAGI1GT
		WORD	PTATEGT
;
;----------------------------------------
PTATEGT		EQU	$
;;		LDA	#02H
		LDA	HEMODE,X	; Tate recover !
		STA	>ITMTBL7
		RTS
;----------------------------------------
;KAGI1DT		EQU	$
;		WORD	1000000000000000B
;		WORD	0100000000000000B
;		WORD	0010000000000000B
;		WORD	0001000000000000B
;		WORD	0000100000000000B
;		WORD	0000010000000000B
;		WORD	0000001000000000B
;		WORD	0000000100000000B
;		WORD	0000000010000000B
;		WORD	0000000001000000B
;		WORD	0000000000100000B
;		WORD	0000000000010000B
;		WORD	0000000000001000B
;		WORD	0000000000000100B
;		WORD	0000000000000010B
;		WORD	0000000000000001B
;
KAGI1GT		EQU	$
;;		MEM16
;;		REP	#00100000B
;;		LDY	DJNNO
;;		LDA	KAGI1DT,Y
;;		ORA	>KEYCNT
;;		STA	>KEYCNT
;;		MEM8
;;		SEP	#00100000B
;;		BRA	KGI000
		STZ	ITMVFG
		LDY	#032H
		PHX
		JSL	>ATMSIT
		PLX
;;		RTS
		BRA	KGI000
;- - - - - -
KAGI0GT		EQU	$
		LDA	>ITMTBL9
		INC	A
		STA	>ITMTBL9
;
KGI000		EQU	$
;;		PHX
;;		LDA	<RMXYCT
;;		ASL	A
;;		TAX
;;		LDA	>DJNTBL+1,X
;;		ORA	#00000100B
;;		STA	>DJNTBL+1,X	; Save data bit on !
;;		PLX
		LDA	HEMODE,X
		STA	ENSWAD,X
;
		LDY	KAGIFG,X
		LDA	!EMYSTT+1
		ORA	KGIDCK,Y
;;		ORA	#01000000B
		STA	!EMYSTT+1
;
		JSL	>ENBTON
		RTS
;----------------------------------------
YOSEIGT		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#31H
;;		STA	SOUND2	;(S)
		LDA	#31H
		JSL	>SDLRE2	;(S)
;
		LDA	#038H
		BRA	HA1G010
HART1GT		EQU	$
		LDA	#008H
HA1G010		EQU	$		;life kaihuku
		CLC
		ADC	>UPLFCT
		STA	>UPLFCT
;
		RTS
;
;----------------------------------------
RUPYDAT		EQU	$		; coin cnt
		BYTE	001,005,020
;			r   y   b
RUPYRGT		EQU	$
RUPYYGT		EQU	$
RUPYBGT		EQU	$
		LDY	ENMYNO,X
		LDA	#00H
		XBA
		LDA	RUPYDAT-RUPYR,Y
		MEM16
		REP	#20H
		CLC
		ADC	>CONCNT
		STA	>CONCNT
		MEM8
		SEP	#20H
;		
;;		CLC
;;		ADC	>UPCNCT
;;		STA	>UPCNCT
;;		LDA	#000H
;;		ADC	>UPCNCT+1
;;		STA	>UPCNCT+1
;
		RTS
;
;----------------------------------------
BOMBDAT		EQU	$		; bomb cnt
		BYTE	001,004,008
;			s   m   l
BOMB1GT		EQU	$
BOMB2GT		EQU	$
BOMB3GT		EQU	$
		LDY	ENMYNO,X
		LDA	BOMBDAT-BOMB1,Y
		CLC
		ADC	>UPBMCT
		STA	>UPBMCT
;
		RTS
;
;;;----------------------------------------
;;NIKU1GT		EQU	$		;life cnt
;;		LDA	#010H
;;		BRA	HA1G010
;;NIKU2GT		EQU	$
;;		LDA	#020H
;;		BRA	HA1G010
;;;
;;;----------------------------------------
;;OPTN1GT		EQU	$
;----------------------------------------
TUBO1GT		EQU	$		;mp cnt
		LDA	>UPMPCT
		CLC
		ADC	#016
		BRA	TB1GT10
;
TUBO2GT		EQU	$		;max kaihuku
		LDA	#128 
TB1GT10		EQU	$
		STA	>UPMPCT
;
		RTS
;
;----------------------------------------
;;CRYS1GT		EQU	$
;;;----------------------------------------
;;TRYFRGT		EQU	$
;;TRYFYGT		EQU	$
;;TRYFBGT		EQU	$
;;;----------------------------------------
;;SPESRGT		EQU	$
;;SPESYGT		EQU	$
;;SPESBGT		EQU	$
;----------------------------------------
;;YAAADAT		EQU	$		;ya cnt
;;		BYTE	005,010
YAAA1GT		EQU	$
		LDA	ENKBMK,X
		BNE	YAG010		; 1 pon ya ?
		LDA	#05
		BRA	YAG010
YAAA2GT		EQU	$
;;		LDY	ENMYNO,X
;;		LDA	YAAADAT-YAAA1,Y
		LDA	#10
YAG010		EQU	$
		CLC
		ADC	>UPAWCT
		STA	>UPAWCT
;
		RTS
;----------------------------------------
;=======================================================
ITCSMD		EQU	$
;;;;                    0 1 2 3 4 5 6       A B        
		HEX	0,1,1,1,2,2,2      ,0,1        
		HEX 	      1,2,2,1,2,2
ITCSM2		EQU	$
;;;;                    0 1 2 3 4 5 6       A B        
		HEX	0,0,0,0,1,2,3      ,0,0        
		HEX	      4,5,0,0,0,0
;
CRYCLD		EQU	$
		BYTE	2,4,6,2
;
ITEMCS		EQU	$
		JSR	ITCLCK		; Item clear check !
;
ITEMC22		EQU	$
		LDA	OAMTYP
		BNE	ICC010
;
		LDA	#30H
		STA	ENFLCL,X
ICC010		EQU	$
		LDA	OJBKFG
		CMP	#03H
		BCS	ITC0A0		; Bank ok ?
;					; yes !
		LDA	ENTIM2,X
		BEQ	IC0F0
;
		LDA	#03H*4
		JSL	>OAMENT3
;
IC0F0		EQU	$
;
;;;;		JSR	R00
;
		LDA	ENWRK3,X
		BNE	ITC090		; move ok ?
;					; yes !
;;		LDA	ENMOD6,X	; KIN HACHI SARCH OFF
;;		ORA	#040H
;;		STA	ENMOD6,X
;;		RTS
R00		EQU	$
;;		LDA	ENWRK3,X
;;		BNE	ITC090		; move ok ?
;					; yes !
;
		LDY	ENMYNO,X
		LDA	ITCSM2-HART1,Y
		BEQ	ITCSE0
;
		JMP	ITEMCS2
;
ITCSE0		EQU	$
;;		CPY	#CRYS1
;;		BNE	ITCSF0
;;;
;;		LDA	<FRCNT
;;		LSR	A
;;		LSR	A
;;		AND	#03H
;;		PHY
;;		TAY
;;		LDA	CRYCLD,Y
;;		STA	ENCLOR,X
;;		PLY
;;ITCSF0		EQU	$
		LDA	ITCSMD-HART1,Y
		BNE	ITCS00
		JMP	EN1CSS
ITCS00		EQU	$
		CMP	#02H
		BNE	ITCS10
;
		LDA	ENMYNO,X
		CMP	#PTATE
		BNE	ITCS01
;
		LDA	HEMODE,X
		CMP	#01H
		BEQ	ITCS10
;
		LDA	#01H
		STA	ENCHPT,X
ITCS01		EQU	$
		JMP	EN1CST
ITCS10		EQU	$
		JMP	EN12CS
;
ITC090		EQU	$
		PLA
		PLA
ITC0A0		EQU	$
		RTS
;==================================================
;==================================================
ITC2XD		EQU	$
		WORD	0000,0000,0008	;BOMB1 x1
		WORD	0000,0000,0008	;    2 x4
		WORD	0000,0000,0008	;    3 x8
;
		WORD	0000,0000,0002	;YAAA1 x5
		WORD	0000,0000,0002	;    2 x10
		WORD	0000,0000,0000	;    1 (x1)
ITC2YD		EQU	$
		WORD	0000,0000,0008
		WORD	0000,0000,0008
		WORD	0000,0000,0008
;
		WORD	0000,0008,0008
		WORD	0000,0008,0008
		WORD	0000,0008,0008
ITC2CD		EQU	$
		HEX	6E,6E,68
		HEX	6E,6E,78
		HEX	6E,6E,79
;
		HEX	63,73,69
		HEX	63,73,6A
		HEX	63,73,73
ITC2SD		EQU	$
		HEX	2,2,0
		HEX	2,2,0
		HEX	2,2,0
;
		HEX	0,0,0
		HEX	0,0,0
		HEX	0,0,0
ITEMCS2		EQU	$
		DEC	A
		STA	<WORK6
		JSR	OAMCHK
;
		LDA	<WORK6
		ASL	A
		ADC	<WORK6
		STA	<WORK6
;
		PHX
		LDA	ENKBMK,X
		CMP	#01H
		LDX	#02H
		BCC	ITC200	; Only 1 ?
		DEX		; Yes ! small No. noth.
ITC200		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	ITC2XD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	ITC2YD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	ITC220
;
		LDA	#0F0H
		STA	(<OAMADR),Y
ITC220		EQU	$
		PLX
		LDA	ITC2CD,X
		INY
		STA	(<OAMADR),Y
		INY
		LDA	<WORK5				
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	ITC2SD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	ITC200
		PLX
;
		JMP	SADWST
;	RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Octarock	         		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OCTURN		EQU	$
		HEX 	3,2,0,1
OCTXSD	 	EQU	$
		BYTE	018H,0E8H,000H,000H
;;		BYTE	008H,0F8H,000H,000H
OCTYSD	 	EQU	$
		BYTE	000H,000H,018H,0E8H
;;		BYTE	000H,000H,008H,0F8H
OCBGCD		EQU	$
		BYTE	01H,02H,04H,08H
OCSTTD		EQU	$
		BYTE	3CH,80H,0A0H,080H
;;  		BYTE	60H,80H,0A0H,080H
OCMKAD		EQU	$
		HEX	40,00,00,00
;--------------------------------------
;
OCTA1MV		EQU	$
OCTA2MV		EQU	$
OCTA3MV		EQU	$
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	OCM000
		LDA	OCTURN,Y
		STA	ENMUKI,X
OCM000		EQU	$
		STZ	<WORK0
		LDA	ENCHPT,X
		CMP	#07H
		BNE	OCM111
;
;;		LDA	ENMUKI,X
;;		CMP	#02H
;;		BCC	OCM111
		LDA	#40H
		STA	<WORK0
OCM111		EQU	$
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	OCMKAD,Y
		ORA	<WORK0
		STA	ENCLOR,X
;
		JSR	OCTA1CS
		PLA
		STA	ENMUKI,X
;
		JSR	ENSTCK
;
		JSR	ENHNSB
		JSR	ENMVCL
;
;;		JSR	CRKNEN		;Vs PL ken
;;		JSR	CRENPL		;Vs PL body
		JSR	CREKEK
;
		LDA	ENSTAT,X
		AND	#01H
		BNE	OCSTOP
;;		JSL	>JSRSUB
;;		WORD	OCWALK
;;		WORD	OCSTOP
;----------------------------------------
OCWALK		EQU	$
		LDA	ENMUKI,X
		AND	#02H
		ASL	A
		STA	<WORK0
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		ORA	<WORK0
		STA	ENCHPT,X
;
;;;		JSR	ENPTST
;
		LDA	ENTIM0,X
		BNE	OCW010
OCW008		EQU	$
		INC	ENSTAT,X
		LDY	ENMYNO,X
		LDA	OCSTTD-OCTA1,Y
                STA	ENTIM0,X
OCTRTS		EQU	$
		RTS
OCW010		EQU	$
		LDY	ENMUKI,X
		LDA	OCTXSD,Y
		STA	ENXSPD,X
		LDA	OCTYSD,Y
		STA	ENYSPD,X
;
		JSR	ENBGCK
;;		LDY	ENMUKI,X
		LDA	ENCBFG,X
;;		AND	OCBGCD,Y
;;;		AND	#00001111B
		BEQ	OCW030
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
;;		LDA	#08H
;;		STA	ENTIM1,X
		BRA	OCS00C		; half pause set !
OCW030		EQU	$
		RTS
;----------------------------------------
;
OCSTOP		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		LDA	ENTIM0,X
		BNE	OCS010
		INC	ENSTAT,X
;
;
		LDA	ENMUKI,X
		PHA
		JSL	>RNDSET
;;		AND	#7FH
;;		ORA	#80H
		AND	#3FH
		ADC	#30H
		STA	ENTIM0,X
		AND	#03H
		STA	ENMUKI,X
		PLA
		CMP	ENMUKI,X
		BEQ	OCS00C
		EOR	ENMUKI,X
		BNE	OCS00C
;
OCS008		EQU	$
		LDA	#08H		; turn half pause time set !
		STA	ENTIM1,X
OCS00C		EQU	$
		RTS
OCS010		EQU	$
;--- Tama set ----------
		LDA	ENMYNO,X
		SEC
		SBC	#OCTA1
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#00FFH
		ASL	A
		TAY
		LDA	OCMVAD,Y
		DEC	A
		PHA
		IDX8
		MEM8
		SEP	#00110000B
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - -
;;		LDA	ENMYNO,X
;;		SEC
;;		SBC	#OCTA1
;;		JSL	>JSRSUB
OCMVAD		EQU	$
		WORD	OCT100	; normal
;;		WORD	OCT200	; rensya
		WORD	00
		WORD	OCT300	; spin shot 
OCS020		EQU	$		
		RTS
;----normal----------------------------------	
OC1SHP		EQU	$
		HEX	0,2,2,2,1,1,1,0,0,0,0,0
OC2SHP		EQU	$
		HEX	2,2,2,2,2,1,1,0        
OC3SHP		EQU	$
		HEX	2,2,2,2,2,2,2,2,1,0
;
OCT100		EQU	$
		LDA	ENTIM0,X
		CMP	#1CH 
		BNE	OT1010
		PHA
		JSR	OCTAMST
		PLA
OT1010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	OC1SHP,Y
		STA	ENWRK2,X	; kuchi paturn !
		RTS
;----rensya---------------------------------	
;OCT200		EQU	$
;		LDA	ENTIM0,X
;		PHA
;		SEC
;		SBC	#10H
;		CMP	#50H-10H
;		BCS	OCT250
;		AND	#0FH
;		BNE	OCT250
;		JSR	OCTAMST
;OCT250		EQU	$
;		PLA
;OCT380		EQU	$
;		LSR	A
;		LSR	A
;		LSR	A
;		LSR	A
;		TAY
;		LDA	OC2SHP,Y
;		STA	ENWRK2,X	; kuchi paturn !
;		RTS
;;;-----tame uchi---------------------------------	
;;OCT400		EQU	$
;;		BRA	OCT100	
;-----spin uchi---------------------------------
OCSPMK		EQU	$
;;		BYTE	2,3,1,0
		HEX	2,3,1,0
;
OCT300		EQU	$
		LDA	ENTIM0,X
		PHA
		CMP	#80H
		BCS	OCT480
		AND	#0FH
		BNE	OCT450		; spin time ?
;
		PHA			; yes !
		LDY	ENMUKI,X
		LDA	OCSPMK,Y
		STA	ENMUKI,X
		PLA
OCT450  	EQU	$
		CMP	#08H
		BNE	OCT480		; shot time ?
;
		JSR	OCTAMST		; yes !
OCT480		EQU	$
		PLA
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	OC3SHP,Y
		STA	ENWRK2,X	; kuchi paturn !
		RTS
;--------------------------------------	
;===============================================
OCTSXL		EQU	$
		BYTE	00CH,0F4H,000H,000H
OCTSXH		EQU	$
		BYTE	0,0FFH,0,0
OCTSYL		EQU	$
		BYTE	004H,004H,00CH,0F4H
OCTSYH		EQU	$
		BYTE	0,0,0,0FFH
OCTMXS		EQU	$
		BYTE	02CH,0D4H,000H,000H
OCTMYS		EQU	$
                BYTE	000H,000H,02CH,0D4H
;
OCTAMST		EQU	$
		LDA	#07H
		JSL	>SDLRE2	;(S)
;
		LDA	#OCTAM
		JSL	>ENIDSH
		BMI	OCTS90
;;;;;;;;		STA	ENMYNO,Y
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	<WORK0
		CLC
		ADC	OCTSXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	OCTSXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	OCTSYL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	OCTSYH,X
		STA	ENYPSH,Y
;
		LDA	ENMUKI,Y
		TAX
		LDA	OCTMXS,X
		STA	ENXSPD,Y
		LDA	OCTMYS,X
		STA	ENYSPD,Y
		PLX
OCTS90		EQU	$
		RTS
;============================================================
;
OCTCSX		EQU	$
		WORD	008H,000H,004H
		WORD	008H,000H,004H
		WORD	009H,0FFFFH,004H
OCTCSY		EQU	$
		WORD	006H,006H,009H
		WORD	006H,006H,009H
		WORD	006H,006H,009H
OCCCDT		EQU	$
		HEX	BB,BB,BA
		HEX	AB,AB,AA
		HEX	A9,A9,B9
;
;;		BYTE	0A9H,0BBH,000H,0
;;		BYTE	0BBH,0BBH,000H,0
;;		BYTE	0BBH,0BBH,000H,0
OCCADT		EQU	$
		BYTE	065H,025H,025H
		BYTE	065H,025H,025H
		BYTE	065H,025H,025H
OCTA1CS		EQU	$
;-- face set -----
		JSR	OAMCHK
;
		LDA	ENMUKI,X
		CMP	#03H
		BEQ	OCC012
;
		LDA	ENWRK2,X
		ASL	A
		ADC	ENWRK2,X
		ADC	ENMUKI,X
		STA	<WORK7
;
		PHX
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	OCTCSX,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	OCTCSY,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	OCC010
;
		LDA	#0F0H
		STA	(<OAMADR),Y
OCC010		EQU	$
		PLX
;;		CLC
;;		ADC	<WORK7
;;		TAX
		LDA	OCCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	OCCADT,X
		INY
		ORA	<WORK5
		STA	(<OAMADR),Y
;
		LDA	<WORKF
		STA	(<OSBADR)
		PLX
OCC012		EQU	$
;- - - - body set --
		MEM16
		REP	#00100000B
		LDA	<OAMADR
		CLC
		ADC	#004H
		STA	<OAMADR
		INC	<OSBADR
		MEM8
		SEP	#00100000B
;
		DEC	ENMOD0,X
		LDY	#00H
		JSR	EN1C50
		INC	ENMOD0,X
;
;;		LDY	#01H
;;		LDA	ENCHPT,X
;;		CLC
;;		ADC	(<OAMADR),Y
;;		STA	(<OAMADR),Y	; up down swing !
OCC090		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Octarock	tama         		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;- - - - - - - - - - - - - - - - - - - - -
OCTAMMV		EQU	$
		LDA	ENMODE,X
		CMP	#EFAIL
		BNE	OCTM08		; Break ?
;					; Yes !
		JSR	OCTAMBR
;
		JSR	ENSTCK2
;
		LDA	ENTIM0,X
		CMP	#1EH
		BNE	OTM900
;
		LDA	#1FH
		JSL	>SDLRE2	;(S)
OTM900		EQU	$
		RTS
;
;;;;		BRA	OCTM0C
OCTM08		EQU	$
		JSR	EN1CST
;;		JSR	EN1CSS
;;		LDA	ENOMID,X
;;		LSR	A
;;		LSR	A
;;		TAY
;;		LDA	OAMSB,Y
;;		AND	#11111101B
;;		STA	OAMSB,Y
OCTM0C		EQU	$
		JSR	ENSTCK
;;;;;		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		;Vs PL body
;		
		JSR	ENMVCL
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	OCTM10
;
		JSR	ENBGCK		; onry 1 point check !
		LDA	ENCBFG,X
;;;;		AND	#00001111B
		BEQ	OCTM10
;
;;;		STZ	ENMODE,X	;(haretsu)
;;		LDA	#EFAIL
;;		STA	ENMODE,X
		JSR	OCTAMFL		;(Timer set)
OCTM10		EQU	$
		RTS
;===================================
OBCXAD		EQU	$
		WORD	000H,008H,000H,008H
		WORD	0FFF8H,010H,0FFF8H,010H
		WORD	0FFF4H,014H,0FFF4H,014H
		WORD	0FFF2H,016H,0FFF2H,016H
OBCYAD		EQU	$
		WORD	000H,000H,008H,008H
		WORD	0FFF8H,0FFF8H,010H,010H
		WORD	0FFF4H,0FFF4H,014H,014H
		WORD	0FFF2H,0FFF2H,016H,016H
OBCADT		EQU	$
		HEX	00,40,80,C0
		HEX	00,40,80,C0
		HEX	00,40,80,C0
		HEX	00,40,80,C0
;;		BYTE	0C0H,000H,040H,080H
;;		BYTE	0C0H,000H,040H,080H
;;		BYTE	0C0H,000H,040H,080H
;;		BYTE	0C0H,000H,040H,080H
OCTAMBR		EQU	$
		JSR	OAMCHK
;
		PHX
		LDA	#03H
		STA	<WORK6
		LDA	ENTIM0,X
		LSR	A
		AND	#00001100B
		EOR	#00001100B
		CLC
		ADC	<WORK6
		TAX
OBC010		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
         	CLC
		ADC	OBCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	OBCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	OBC013
		LDA	#0F0H
		STA	(<OAMADR),Y
OBC013		EQU	$
		PLX
		LDA	#0BCH
		INY
		STA	(<OAMADR),Y
		LDA	OBCADT,X
		ORA	#2CH+1
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		DEC	<WORK6
		BPL	OBC010
		PLX
;;		LDA	#03H
;;		LDY	#00H
;;		JSR	ALOMCK
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Octa fuusen              		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OBZPDT		EQU	$
		BYTE	10H,11H,12H,13H,14H,13H,12H,11H
;
OCTBLMV		EQU	$
		LDA	ENCONT,X
		LSR	A
		LSR	A
                LSR	A
		AND	#00000111B
		TAY
		LDA	OBZPDT,Y
		STA	ENZPSL,X
		JSR	OCTBLCS
		JSR	ENSTCK
;
		LDA	ENTIM0,X
		BNE	OCBM0C
;
		LDA	#03H
		STA	ENTIM0,X	; Wait !
;
		LDY	#ENNO-1
OCBM08		EQU	$
		LDA	ENMODE,Y
		BEQ	OCBM0A
;
		LDA	ENMYNO,Y
		CMP	#OCTSS
		BEQ	OCBM0C
;
OCBM0A		EQU	$
		DEY
		BPL	OCBM08
;
		LDA	#EFAIL
		STA	ENMODE,X
		JMP	OCTBLFS		; Break !
;--------------------------------------------------------
OCBM0C		EQU	$
		JSR	ENHNSB
;
		INC	ENCONT,X
;
		TXA
		EOR	<FRCNT
		AND	#0FH     ; ajast !!
		BNE	OCBM50
;
		LDA	#04H
         	JSR	PSERC2
		LDA	ENYSPD,X
		CMP	<WORK0
		BEQ	OCBM30
		BPL	OCBM10
		INC	ENYSPD,X
		BRA	OCBM30
OCBM10		EQU	$
		DEC	ENYSPD,X
OCBM30		EQU	$
		LDA	ENXSPD,X
		CMP	<WORK1
		BEQ	OCBM50
		BPL	OCBM40
		INC	ENXSPD,X
		BRA	OCBM50
OCBM40		EQU	$
		DEC	ENXSPD,X
OCBM50		EQU	$
		JSR	ENMVCL
;
		JSR	CRENPL		;Vs PL body
		BCC	OCBM58
;
		JSR	OCBBND		; Bound
OCBM58		EQU	$
		JSR	CRKNEN
		JSR	ENBGCK
;;		LDA	ENCBFG,X
;;		AND	#0FH
;;		BEQ	OCBM60
;;		JSR	ENTURN
		JSR	ENTUCK
OCBM60		EQU	$
		RTS
;=========================================
OCBBND		EQU	$
		LDA	<HANEFG
		BNE	OBD010
;
		LDA	#04H
		STA	<HANEFG
		LDA	#HPW10
		JSR	PLHNST
		JSR	ENTURN
OBD010		EQU	$
		RTS
;=============================================
OCBCXD		EQU	$
		WORD 	0FFFCH,04H,0FFFCH,04H
		WORD 	0FFF8H,08H,0FFF8H,08H
		WORD 	0FFFCH,04H,0FFFCH,04H
OCBCYD		EQU	$
		WORD    0FFFCH,0FFFCH,004H,004H
		WORD 	0FFF8H,0FFF8H,008H,008H
		WORD 	0FFFCH,0FFFCH,004H,004H
OCBCCD		EQU	$
		BYTE	08CH,08CH,09CH,09CH
		BYTE	086H,086H,086H,086H
		BYTE	086H,086H,086H,086H
OCBCAD		EQU	$
		BYTE	00H,40H,00H,40H
		BYTE	00H,40H,080H,0C0H
		BYTE	00H,40H,080H,0C0H
;- - - - - - - - - - - - - - - - - -
OCTBLCS		EQU	$
;
;;;		LDY	ENOMID,X
;
;;;		LDA	ENZPSL,X
;;;		STA	<WORK8
;;;		LDA	ENCLOR,X
;;;		STA	<WORK9
;
;;;		LDA     ENXPSL,X
;;;		SEC
;;;		SBC	<SCCH2
;;;		STA	ENDSXL
;;;		LDA	ENYPSL,X
;;;		SEC
;;;		SBC	<SCCV2
;;;		STA	ENDSYL
		STZ	<WORKA
;
		LDA	ENMODE,X
		CMP	#EFAIL
		BNE	OCBCF0
;
;;		PHY
		LDA	ENTIM0,X
		CMP	#06H
		BNE	OCBCE0
		LDA	<GAMEMD
		BNE	OCBCE0
		JSR	OCTSSST		; 6 of junior set !
OCBCE0		EQU	$
;;		PLY
;		
		LDA	ENTIM0,X
		LSR	A
;;;		LSR	A
		AND	#00000100B
		CLC
		ADC	#01H*4
		STA	<WORKA
OCBCF0		EQU	$
		JSR	OAMCHK		;don't ypos check !
		PHX
		LDA	#03H
		STA	<WORKB
		CLC
		ADC	<WORKA
		TAX
;;;		LDY	#00H
OCBC00		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
         	CLC
		ADC	OCBCXD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
;;		SEC
;;		SBC	<WORK8
		CLC
		ADC	OCBCYD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	OCBC01
		LDA	#0F0H
		STA	(<OAMADR),Y
OCBC01		EQU	$
		PLX
;
		LDA	OCBCCD,X
		INY
		STA	(<OAMADR),Y
		LDA	OCBCAD,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		DEC	<WORKB
		BPL	OCBC00
		PLX
;;		LDA	#03H
;;		LDY	#02H
;;		JSR	ALOMCK
;
		JMP	SADWST
;
;	RTS
;==============================================
OCSSXS		EQU	$
;;		BYTE	0CH,09H,0F7H,0F4H,0F7H,09H,0CH,07H
		BYTE	10H,0BH,0F5H,0F0H,0F5H,0BH
OCSSYS		EQU	$
		BYTE	00H,0BH,0BH,00H,0F5H,0F5H
;;		BYTE	00H,09H,09H,00H,0F7H,0F7H,09H,09H
;- - -- - - - - - - -- - - - - -
OCTSSST		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#0CH
;;		STA	SOUND2	;(S)
		LDA	#0CH
		JSL	>SDLRE2	;(S)
;
		LDA	#05H
		STA	<WORKD
OCSS10		EQU	$
		LDA	#OCTSS
		JSL	>ENIDSH
		BMI	OCSS90
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
		PHX
		LDX	<WORKD
;;;             JSL	>RNDSET
;;;		AND	#0FH
;;;		TAX
		LDA	OCSSXS,X  ;>KOMXSD,X
		STA	ENXSPD,Y
;;		JSL	>RNDSET
;;		AND	#07H
;;		TAX
		LDA	OCSSYS,X  ;>KOMYSD,X
		STA	ENYSPD,Y
		LDA	#30H
		STA	ENZSPD,Y
		LDA	#0FFH
		STA	ENCONT,Y
		PLX
OCSS90		EQU	$
		DEC	<WORKD
		BPL	OCSS10
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		octa small       		      %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OCSYAD		EQU	$
		BYTE	00H,03H,05H,08H,0AH,0CH,0DH,0EH
		BYTE	0FH,0EH,0DH,0CH,0AH,08H,05H,03H
;- - - -- - - - - - - - - - - - -
OCTSSMV		EQU	$
		LDA	ENCONT,X
		BNE	OSS010
;
		STZ	ENMODE,X
OSS010		EQU	$
		CMP	#40H
		BCS	OSS020
		AND	#01H
		BNE	OSS022
OSS020		EQU	$
		JSR	EN1CSS
OSS022		EQU	$
		JSR	ENSTCK
;
;;		LDA	<FRCNT
;;		AND	#01H
;;		BNE	OSS023
;
		DEC	ENCONT,X
OSS023		EQU	$
;
		JSR	ENHNSB
;;		LDA	<FRCNT
;;		LSR	A
;;;;;;            LSR	A;
;;		BYTE	0EAH,0EAH
;;		CLC
;;		ADC	ENINDX
;;		AND	#0FH
;;		TAY
;;		LDA	OCSYAD,Y
;;		STA	ENZPSL,X
		DEC	ENZSPD,X
		JSR	ENZCLC
		LDA	ENZPSL,X
		BPL	OCSM08
		STZ	ENZPSL,X
		LDA	#010H
		STA	ENZSPD,X
OCSM08		EQU	$
;
		JSR	ENMVCL
		JSR	ENBGCK
;;		LDA	ENCBFG,X
;;		AND	#00001111B
;;		BEQ	OCSM10
;;		JSR	ENTURN
		JSR	ENTUCK
OCSM10		EQU	$
CREKEK		EQU	$
		JSR	CRKNEN
		JSR	CRENPL		;Vs PL body
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		NYORO                                 %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NYOCDT		EQU	$
;;		BYTE	0,1,0,1
		BYTE	0,1,0,2
;NYOMDT		EQU	$
;		BYTE	00H,00H,40H,00H
;
NYCLDT		EQU	$
		BYTE	5*2+0,1*2  ;+1
		BYTE	4*2+0,1*2  ;+1
;
NYOROMV		EQU	$
		LDA	ENTIM1,X
		BEQ	NY0110
		LSR	A
;;		NOP
		AND	#03H
		TAY
;;		LDA	ENCLOR,X
		LDA	ENFLCL,X
		AND	#11110001B
		ORA	NYCLDT,Y
;;		STA	ENCLOR,X
		STA	ENFLCL,X
NY0110		EQU	$
		JSL	>OOTSUCK
		JSR	NYOROCS
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
;;		BYTE	0EAH,0EAH
		AND	#00000011B
		TAY
		LDA	NYOCDT,Y
		LDY	ENTIM1,X
		BEQ	NY0123
		INC	A
		INC	A
		INC	A
NY0123		EQU	$
		STA	ENCHPT,X
;;;===for SEKZ1=============================================
SLOWMV		EQU	$
		JSR	ENSTCK
		JSR	ENHNSB
;
		INC	ENCONT,X
;;		LDA	ENCLOR,X
;;		AND	#10111111B
;;		ORA	NYOMDT,Y
;;		STA	ENCLOR,X
;
		LDA	ENTIM0,X
		BNE	NYOM80		; Muki chenge ?
;					; yes !
;;		JSL	>RNDSET
;;		AND	#3FH
;;		ADC	#40H
;;		STA	ENTIM0,X
		JSR	NYSDST
NYOM80		EQU	$
		LDA	ENTIM1,X
		BNE	NYOM88
;
		JSR	ENMVCL
NYOM88		EQU	$
		JSR	ENBGCK
;;		LDA	ENCBFG,X
;;		AND	#00001111B
;;		BEQ	NYOM90
;;		JSR	ENTURN
		JSR	ENTUCK
NYOM90  	EQU	$
;;		JSR	CRENPL		;Vs PL body
;;		JSR	CRKNEN
		JMP	CREKEK
;;		RTS
;-----------------------------------
NYORXS		EQU	$
		BYTE	03H,02H,0FEH,0FDH,0FEH,02H,000H,000H
NYORYS		EQU	$
		BYTE	00H,02H,02H,00H,0FEH,0FEH,00H,000H
NYOTMD		EQU	$
		BYTE	30H,30H,30H,30H,30H,30H,40H,40H
;- - - - - - - - - 
NYSDST		EQU	$
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	NYORXS,Y
		STA	ENXSPD,X
		LDA	NYORYS,Y
		STA	ENYSPD,X	
		LDA	NYOTMD,Y
		STA	ENTIM0,X
		RTS
;==========================================
;NYCIDX		EQU	$
;		BYTE	2,0,0,2,2,2
;
NYCXAD		EQU	$
		WORD	000H,008H,000H
NYCYAD		EQU	$
		WORD	0FFF8H,0FFF8H,000H
NYCCDT		EQU	$
		BYTE	070H+80H,070H+80H,061H+80H
		BYTE	0,0,04EH+80H
		BYTE	0,0,04EH+80H
		BYTE	063H+80H,063H+80H,04AH+80H
		BYTE	064H+80H,065H+80H,04CH+80H
		BYTE	065H+80H,064H+80H,04CH+80H
NYCADT		EQU	$
		BYTE	000H,040H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,040H
		BYTE	000H,040H,000H
		BYTE	000H,000H,000H
		BYTE	040H,040H,040H
NYCSBD		EQU	$
		BYTE	0,0,2
;- - - - - - - - - - - - - - - - - - - - - - -
NYOROCS		EQU	$
		JSR	OAMCHK
;
		PHX
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
;
		LDX	#02H
NYC010		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	NYCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	NYCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	NYC023
		LDA	#0F0H
		STA	(<OAMADR),Y
NYC023		EQU	$
		PLX
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		INY
		LDA	NYCCDT,X
		STA	(<OAMADR),Y
		BNE	NYC018		; nothing ?
		DEY
		LDA	#0F0H		; head clear !
		STA	(<OAMADR),Y
		INY
NYC018		EQU	$
		LDA	NYCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PLX
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	NYCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	NYC010
		PLX
;
;;		LDA	#02H
;;		LDY	#0FFH
;;		JSR	ALOMCK
;
		JMP	SADWST
;	RTS
;============================================================================
;		JSR	EN1CST
;;
;		LDA	ENCHPT,X
;		BEQ	NYC090		; head ?
;;					; yes !
;		LDA	ENOMID,X
;		CLC
;		ADC	#04H
;		STA	ENOMID,X
;		TAY
;		LDA	ENDSXL
;		STA	OAM+00H,Y
;		CLC
;		ADC	#08H
;		STA	OAM+04H,Y
;		LDA	ENDSYL
;		SEC
;		SBC	#08H
;		STA	OAM+01H,Y
;		STA	OAM+05H,Y
;		LDA	#070H
;		STA	OAM+02H,Y
;		STA	OAM+06H,Y
;		LDA	#20H
;		ORA	ENCLOR,X
;		STA	OAM+03H,Y
;		ORA	#40H
;		STA	OAM+07H,Y
;;
;		LDY	#00H
;		LDA	#01H
;		JSR	ALOMCK
;NYC090		EQU	$
;		RTS
;=============================================
ENTUCK		EQU	$
		LDA	ENCBFG,X
		AND	#00000011B
		BEQ	ETUC10
;
		JSR	ENXTUR
ETUC10		EQU	$
		LDA	ENCBFG,X
		AND	#00001100B
		BEQ	ETUC20
;
		JSR	ENYTUR
ETUC20		EQU	$
		RTS
;=======================================
ENTURN		EQU	$
		JSR	ENYTUR
;
ENXTUR		EQU	$
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		RTS
ENYTUR		EQU	$
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		RTS
;================================================
ENSTCK		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	ESTC08
ENSTCK2		EQU	$
;;		JSR	PLHNCK		; player hani flag set 
;
		LDA	ENSTFG
		BNE	ESTC08		; enemy all stop !
;
		LDA	<GAMEMD
		BNE	ESTC08
;
		LDA	ENMOD5,X
		BMI	ESTC10
;
		LDA	ENDSPL,X
		BEQ	ESTC10		; game stop ?
;
ESTC08		EQU	$
		PLA			; yes ! don't sub return 
		PLA
ESTC10		EQU	$
		RTS
;=====================================================
ENCD00		EQU	$
OCTA1CD		EQU	$
OCTA2CD		EQU	$
OCTA3CD		EQU	$
		HEX	A0,A2,A0,A2,80,82,80,82
;;		BYTE	80H,82H
NIWATCD		EQU	$
		HEX	EA,EC
OCTAMCD		EQU	$
;;		BYTE	0F2H
		BYTE	084H
NYOROCD		EQU	$
		BYTE	4EH,61H
;;BATTACD		EQU	$
;;;		BYTE	0C4H,0C6H,0C8H
OCTSSCD		EQU	$
                BYTE	0BDH
CHFIRCD		EQU	$
		BYTE	08CH   ;;;,0CCH
;KWAUSCD		EQU	$
;BABULCD		EQU	$
;BABU2CD		EQU	$
;BIGBLCD		EQU	$
;;;		HEX	44,46
;		HEX	AA
;;;		BYTE	024H,026H
KWAU1CD		EQU	$
HEYA3CD		EQU	$
		BYTE	020H,022H
SHIGECD		EQU	$
		BYTE	0C0H,0C2H
;;;SARU3CD		EQU	$
GOST0CD		EQU	$
		HEX	E6
TAAMACD		EQU	$
		BYTE	0E4H
NAME0CD		EQU	$
		HEX	82,AA,84,AC,80,A0
REBA1CD		EQU	$
		BYTE	0CAH
KUTUUCD		EQU	$
		BYTE	0AFH
;
;
;
HART1CD		EQU	$
		BYTE	029H,039H
RUPYRCD		EQU	$
RUPYYCD		EQU	$
RUPYBCD		EQU	$
		BYTE	00BH
BOMB1CD		EQU	$
;;		BYTE	060H
BOMB2CD		EQU	$
;;		BYTE	064H
BOMB3CD		EQU	$
		HEX	6E
;;		BYTE	066H
;;NIKU1CD		EQU	$
;;		HEX	70
;;;;		BYTE	061H
;;NIKU2CD		EQU	$
;;		HEX	61  
;;;;		BYTE	068H
;;OPTN1CD		EQU	$
;;		BYTE	000H
TUBO1CD		EQU	$
		HEX	60
;;		BYTE	062H
TUBO2CD		EQU	$
		HEX	62
;;		BYTE	06AH
;;CRYS1CD		EQU	$
;;TRYFRCD		EQU	$
;;TRYFYCD		EQU	$
;;TRYFBCD		EQU	$
;;SPESRCD		EQU	$
;;SPESYCD		EQU	$
;;SPESBCD		EQU	$
;;		BYTE	00CH
YAAA1CD		EQU	$
;;		BYTE	063H
YAAA2CD		EQU	$
		HEX	63
;;		BYTE	06CH
HYUUUCD		EQU	$
		BYTE	04CH
YOSEICD		EQU	$
;;IZUMICD		EQU	$
		BYTE	0EAH,0ECH
BOOK0CD		EQU	$
		BYTE	024H
KAGI0CD		EQU	$
		HEX	6B
KINOKCD		EQU	$
		BYTE	024H
ZOOL1CD		EQU	$
ZOOL2CD		EQU	$
		HEX	22,24,26,20,30,21
;
;;		BYTE	062H,064H,066H
;;		BYTE	06AH,06CH,06EH
TAIHOCD		EQU	$
		BYTE	02AH,24H
NEZU0CD		EQU	$
		BYTE	086H,088H,08AH,08CH,08EH,0A2H
HEBI0CD		EQU	$
		BYTE	0A4H,0A6H,0A8H   ;,0AAH
BKFIRCD		EQU	$
		HEX	AA
KOMO0CD		EQU	$
		HEX	84,80,82     ;;,84
HEBO0CD		EQU	$
		HEX	6E	; Bomb chr !
HANA0CD		EQU	$
HANA1CD		EQU	$
		HEX	40,42
ISHI0CD		EQU	$
HARI0CD		EQU	$
		HEX	E6,E8
TAMA0CD		EQU	$
		HEX	80,82
ZORA2CD		EQU	$
		HEX	C8	; ko ZORA ! (From BOSS)
ZORASCD		EQU	$
		HEX	8D  ;;,A6,B7,B6,80
TORI0CD		EQU	$
		HEX	E3,E5
RISU0CD		EQU	$
		HEX	C5,E1
YASANCD		EQU	$
		HEX	04,24
HODIRCD		EQU	$
HODILCD		EQU	$
HODIDCD		EQU	$
HODIUCD		EQU	$
		HEX	0E,2E
		HEX	0C,0A
BWAKOCD		EQU	$
		HEX	9C,C7,B6,B7
MOTS1CD		EQU	$
		HEX	60,62,64,66,68,6A
HACHICD		EQU	$
BEE00CD		EQU	$
		BYTE	0E4H,0F4H
TELSACD		EQU	$
		HEX	02,02,00,04
;;		HEX	06             ;;,08,0A,0C,0E
SHTAMCD		EQU	$
		HEX	C6,CC,CE
HBTAMCD		EQU	$
SPARKCD		EQU	$
SPARLCD		EQU	$
		HEX	28
AMENBCD		EQU	$
		HEX	84,82,80
RINGOCD		EQU	$
		BYTE	0E5H
KAGI1CD		EQU	$
NAMAZCD		EQU	$
		HEX	24
SKHEDCD		EQU	$
		HEX	00,02,04
;;;		HEX	80,82,84
CHIBICD		EQU	$
		HEX	A0,AA,A4,A6,AC,A2,A8
;;		HEX	E0,EA,E4,E6,EC,E2,EE
PATAMCD		EQU	$
MAGICCD		EQU	$
		HEX	A6,88,86
KAM01CD		EQU	$
		HEX	8E,AE,8A
SLIMECD		EQU	$
		HEX	42,44,42,44   
MOTAMCD		EQU	$
		HEX	CC,CC,CA
;;		HEX	DF,CC,CA
AYASICD		EQU	$
		HEX	87,97,8E,AE,AC
		HEX	8C,8E,AA,AC
MEMERCD		EQU	$
MEMELCD		EQU	$
MEMEDCD		EQU	$
MEMEUCD		EQU	$
		HEX	D2,F3
ATARSCD		EQU	$
		BYTE	084H,0A2H,084H,0A4H,0E7H
FISH0CD		EQU	$
		HEX	8A,A8,8A,A8,88,A0,A4,A2,A6,A6,A6,A6
;;		HEX	A0,A4,A2,8A,88,A8
;;MAGICCD		EQU	$
;;		HEX	A6
KURORCD		EQU	$
		HEX	7E,7F
USAGICD		EQU	$
		HEX	8A,88,8C,A6
OOOMUCD		EQU	$
		HEX	86,8E,AC,86
SLEEPCD		EQU	$
		BYTE	0BBH,0ACH	; Hii
		HEX	A9,B9,AA,BA	; Awaa
		HEX	BC		; Kemuri
;;ICBOSCD		EQU	$
;;		HEX	86,8A,A8
ICTAMCD		EQU	$
		HEX	8A,8E,8A,86
;;		HEX	8E,88,8A
TEKI1CD		EQU	$
		HEX	0A
;
IWABOCD		EQU	$
		HEX	C2,C4,E2,E4,C6
DEMONCD		EQU	$
		BYTE	0EAH,0ECH
PATA0CD		EQU	$
		HEX	FF	; Beam !
EYETMCD		EQU	$
		HEX	E6,C6
EYEBMCD		EQU	$
		HEX	CC,EC,CE,EE
		HEX	4C,6C,4E,6E
KARASCD		EQU	$
		HEX	C8,C4,C6
HAYABCD		EQU	$
		HEX	88,8C
UTUWACD		EQU	$
		BYTE	024H
UTUBKCD		EQU	$
		BYTE	0E0H
MOTSBCD		EQU	$
		HEX	AE,C0,C8,C4,C6		; Mask break no.
		HEX	E2,E0
TAKARCD		EQU	$
		BYTE	0EEH
AMEBACD		EQU	$
		HEX	AE
DARUMCD		EQU	$
		HEX	A0,80
UZUMKCD		EQU	$
		BYTE	0EEH
SITO0CD		EQU	$
		BYTE	0C0H,0C2H,0BFH
WANWANCD	EQU	$
		HEX	8C,AA,86,A8,A6
KAMBSCD		EQU	$
		HEX	2C,28,06
BAKDNCD		EQU	$
		BYTE	0DFH,0CFH,0A9H
SAMTMCD		EQU	$
		BYTE	046H,046H
;;CTBOSCD		EQU	$
;;		HEX	80,82,84,86,88,8A,8C
;;		HEX	61,71,70,60
MDARMCD		EQU	$
		HEX	EA,C0,C2
		HEX	E0,E8,E2,E6,E4
KIANACD		EQU	$
;		BYTE	0AEH,09CH,09DH,09DH,08DH,08DH
PLHIKCD		EQU	$
		BYTE	00BH
GANONCD		EQU	$
		HEX     8E,A0
;;		HEX	68,AC,AE
PTATECD		EQU	$
		HEX	EC,EA
WOOD1CD		EQU	$
		BYTE	0E9H
RNTAMCD		EQU	$
		HEX	48,58		; Ranemora tama !
;--------------------------------------
ENCDAD		EQU	$
		BYTE	KARASCD-ENCD00		;KARAS
		BYTE	00H-00H			;HAGE0
		BYTE	SKHEDCD-ENCD00		;SKHED
		BYTE	00H-00H			;     
		BYTE	00H-00H			;ESW02
		BYTE	00H-00H			;ESW03
		BYTE	00H-00H			;ESW12
		BYTE	00H-00H			;ESW04
		BYTE	OCTA1CD-ENCD00          ;OCTA1
;;		BYTE	OCTA2CD-ENCD00  	;OCTA2
		BYTE	HAYABCD-ENCD00  	;HAYAB
		BYTE	OCTA3CD-ENCD00  	;OCTA3
		BYTE	NIWATCD-ENCD00         	;NIWAT
		BYTE	OCTAMCD-ENCD00  	;OCTAM
		BYTE	NYOROCD-ENCD00  	;NYORO
		BYTE	00              	;PAKKN
		BYTE	000H             	;OCTBL
		BYTE	OCTSSCD-ENCD00   	;OCTSS
		BYTE	00H              	;HINO0
		BYTE	00H			;BUTA0
		BYTE	MOTS1CD-ENCD00		;MOTS1
		BYTE	00			;PLHIN
		BYTE	00 ;BABULCD-ENCD00		;BABUL
;;;;;;;;		BYTE	KWAUSCD-ENCD00		;KWAUS
		BYTE	KWAU1CD-ENCD00		;JITON
;;		BYTE	00			;KWAU1
		BYTE	SHIGECD-ENCD00		;SHIGE
		BYTE	00          		;HAYAM
		BYTE	GOST0CD-ENCD00		;GOST0
		BYTE	00			;KAJIY
		BYTE	00			;YATAM
		BYTE	00			;SEKZ4
		BYTE	00			;BEECK
		BYTE	TAAMACD-ENCD00		;TAAMA
		BYTE	00			;SINUB
		BYTE	NAME0CD-ENCD00		;NAME0
		BYTE	REBA1CD-ENCD00		;REBA1
		BYTE	00          		;LOPAA
		BYTE	ZOOL1CD-ENCD00 		;ZOOL1
		BYTE	ZOOL2CD-ENCD00 		;ZOOL2
		BYTE	WOOD1CD-ENCD00		;WOOD1
		BYTE	00        		;MOTS0
		BYTE	IWABOCD-ENCD00		;IWABO
		BYTE	00			;JOHOY
		BYTE	00        		;JIJII
		BYTE	00        		;BABAA
		BYTE	SLEEPCD-ENCD00		;SLEEP
		BYTE	00        		;NOKOG
		BYTE	00        		;PENKI
		BYTE	KUTUUCD-ENCD00 		;KUTUU
		BYTE	00        		;MEIR0
		BYTE	00        		;MEIR1
		BYTE	00        		;ULANI
		BYTE	00        		;NOPPO
		BYTE	00        		;PLHIK
		BYTE	00        		;ONNAA
		BYTE	00        		;HIGEE
		BYTE	00        		;MAJOO
		BYTE	PLHIKCD-ENCD00       		;PLCHK
		BYTE	KIANACD-ENCD00		;KIANA
		BYTE	00        		;SAKAS
		BYTE	DEMONCD-ENCD00		;DEMON
		BYTE	BOOK0CD-ENCD00		;BOOK0
		BYTE	00        		;TKBOY
		BYTE	00        		;BABA1
		BYTE	ISHI0CD-ENCD00 		;ISHI0
		BYTE	00        		;BARI0
		BYTE	00        		;BARI1
		BYTE	00        		;HEIS0
		BYTE	00        		;HEI00
		BYTE	00        		;HEIS1
		BYTE	00        		;HEIS2
		BYTE	00        		;HEIS3
		BYTE	00        		;HEYA0
		BYTE	00        		;HEYA1
		BYTE	00        		;HEYA2
		BYTE	HEYA3CD-ENCD00 		;HEYA3
		BYTE	HEBO0CD-ENCD00          ;HEBO0
		BYTE	00                      ;ZAKO0
		BYTE	00                      ;SUNA0
		BYTE	00                      ;USAG0
		BYTE	HANA0CD-ENCD00          ;HANA0
		BYTE	HANA1CD-ENCD00          ;HANA1
		BYTE	TAMA0CD-ENCD00          ;TAMA0
		BYTE	00                      ;DOZOO
		BYTE	00                      ;ZORAB
		BYTE	00                      ;NOMOS
		BYTE	00                      ;RANEM
		BYTE	ZORASCD-ENCD00          ;ZORAS
		BYTE	ZORA2CD-ENCD00          ;ZORA2
		BYTE	00        		;SEKMV
		BYTE	00        		;KANI0
		BYTE	TORI0CD-ENCD00 		;TORI0
		BYTE	RISU0CD-ENCD00  	;RISU0
		BYTE	SPARKCD-ENCD00 		;SPARK
		BYTE	SPARLCD-ENCD00 		;SPARL
		BYTE	00        		;CHAN0
		BYTE	00        		;CHAN1
		BYTE	00        		;CHAN2
		BYTE	00        		;CHAN3
		BYTE	00        		;MEDUS
		BYTE	ATARSCD-ENCD00 		;ATARS
		BYTE	00        		;ARI00
		BYTE	00        		;ARI01
		BYTE	YASANCD-ENCD00 		;YASAN
		BYTE	HODIRCD-ENCD00 		;HODIR
		BYTE	HODILCD-ENCD00 		;HODIL
		BYTE	HODIDCD-ENCD00 		;HODID
		BYTE	HODIUCD-ENCD00 		;HODIU
		BYTE	00        		;TEKU0
		BYTE	TAIHOCD-ENCD00 		;TAIHO
		BYTE	HYUUUCD-ENCD00		;HYUUU
		BYTE	NEZU0CD-ENCD00		;NEZU0
		BYTE	HEBI0CD-ENCD00		;HEBI0
		BYTE	KOMO0CD-ENCD00 		;KOMO0
		BYTE	MOTAMCD-ENCD00		;MOTAM
;
		BYTE	00        		;RIVER
		BYTE	BWAKOCD-ENCD00 		;BWAKO
		BYTE	000H	 		;OYAGI
		BYTE	000H	 		;BOUSI
		BYTE	000H	 		;SYOBY
		BYTE	000H	 		;HELP0
		BYTE	00H ;BIGBLCD-ENCD00 		;BIGBL
		BYTE	000H	 		;JOHBB
		BYTE	HACHICD-ENCD00 		;HACHI
		BYTE	00			;SHSAI
		BYTE	SHTAMCD-ENCD00		;SHTAM
		BYTE	TELSACD-ENCD00		;TELSA
		BYTE	00			;TRAP0
		BYTE	00			;BAAR0
		BYTE	00			;BAAR1
		BYTE	HBTAMCD-ENCD00		;HBTAM
		BYTE	AMENBCD-ENCD00		;AMENB
		BYTE	00H ;BABU2CD-ENCD00		;BABU2
		BYTE	00			;MEDAM
		BYTE	00			;MEDA2
		BYTE	00			;SKELT
		BYTE	CHIBICD-ENCD00		;CHIBI
		BYTE	CHFIRCD-ENCD00		;CHFIR
		BYTE	00        		;BIGKO
		BYTE	BKFIRCD-ENCD00		;BKFIR
		BYTE	HARI0CD-ENCD00		;HARI0
		BYTE	00            		;MIIRA
		BYTE	00			;PATAR
		BYTE	PATAMCD-ENCD00		;PATAM
		BYTE	KAM01CD-ENCD00		;KAM01
		BYTE	SLIMECD-ENCD00		;SLIME
		BYTE	00			;HANDS
		BYTE	00			;SKELB
		BYTE	MOTSBCD-ENCD00		;MOTSB
		BYTE	00			;BYOYN
		BYTE	AYASICD-ENCD00		;AYASI
		BYTE	MEMERCD-ENCD00		;MEMER
		BYTE	MEMELCD-ENCD00		;MEMEL
		BYTE	MEMEDCD-ENCD00		;MEMED
		BYTE	MEMEUCD-ENCD00		;MEMEU
		BYTE	00			;PENGI
		BYTE	FISH0CD-ENCD00		;FISH0
		BYTE	MAGICCD-ENCD00		;MAGIC
		BYTE	KURORCD-ENCD00		;KUROR
		BYTE	00			;KUROD
		BYTE	00         		;DACHO
		BYTE	USAGICD-ENCD00		;USAGI
		BYTE	OOOMUCD-ENCD00		;OOOMU
		BYTE	00			;ICMAN
		BYTE	00  ;ICBOSCD-ENCD00 		;ICBOS
		BYTE	00			;ICEBG
		BYTE	ICTAMCD-ENCD00		;ICTAM
		BYTE	00			;TEKI0
		BYTE	TEKI1CD-ENCD00		;TEKI1 (TAMA)
		BYTE	00			;SKEL2
		BYTE	PATA0CD-ENCD00		;PATA0
		BYTE	00			;PATA1
		BYTE	00			;LIKE0
		BYTE	00			;POLIW
		BYTE	RINGOCD-ENCD00		;RINGO
		BYTE	00			;HELP1
		BYTE	00			;DOKN0
		BYTE	00			;DOKN1
		BYTE	00			;DOKN2
		BYTE	00			;DOKN3
		BYTE	BEE00CD-ENCD00		;BEE00
		BYTE	00			;SEKBN
		BYTE	TAKARCD-ENCD00		;TAKAR
		BYTE	BAKDNCD-ENCD00		;BAKDN
		BYTE	00			;SARKK
		BYTE	00			;TEKBB
		BYTE	00			;D_0_9
		BYTE	SITO0CD-ENCD00		;SITO0
		BYTE	UZUMKCD-ENCD00		;UZUMK
		BYTE	SAMTMCD-ENCD00		;SAMTM
		BYTE	00			;RYOKI
		BYTE	00			;EYEBS
		BYTE	EYETMCD-ENCD00		;EYETM
		BYTE	EYEBMCD-ENCD00		;EYEBM
		BYTE	NAMAZCD-ENCD00		;NAMAZ
		BYTE	0             		;SDEMO
		BYTE	RNTAMCD-ENCD00 		;IWAGO
		BYTE	AMEBACD-ENCD00 		;AMEBA
		BYTE	0			;Theft
		BYTE	0			;BGBM0
		BYTE	0			;BGBM1
		BYTE	DARUMCD-ENCD00		;DARUM
		BYTE	00H ;;IZUMICD-ENCD00		;IZUMI
		BYTE	00H      		;TEKTA
		BYTE	WANWANCD-ENCD00		;WANWAN
		BYTE	KAMBSCD-ENCD00		;KAMBS
		HEX	00			;KAMBR
		HEX	00			;KAMBB
		BYTE	00  ;CTBOSCD-ENCD00		;CTBOS
		BYTE	MDARMCD-ENCD00		;MDARM 
		BYTE	00H      		;RINEL 
		BYTE	00H      		;DOOMO 
		BYTE	00H      		;JFISH 
		BYTE	00H      		;ABATA 
		BYTE	00H      		;ANAHO 
		BYTE	GANONCD-ENCD00		;GANON
		BYTE	GANONCD-ENCD00		;GANO2
;- - - - - -
		BYTE	HART1CD-ENCD00		;HART1
		BYTE	RUPYRCD-ENCD00		;RUPYR
		BYTE	RUPYYCD-ENCD00		;RUPYY
		BYTE	RUPYBCD-ENCD00		;RUPYB
		BYTE	BOMB1CD-ENCD00		;BOMB1
		BYTE	BOMB2CD-ENCD00		;BOMB2
		BYTE	BOMB3CD-ENCD00		;BOMB3
;;		BYTE	NIKU1CD-ENCD00		;NIKU1
;;		BYTE	NIKU2CD-ENCD00		;NIKU2
;;		BYTE	OPTN1CD-ENCD00		;OPTN1
		BYTE	TUBO1CD-ENCD00		;TUBO1
		BYTE	TUBO2CD-ENCD00		;TUBO2
;;		BYTE	CRYS1CD-ENCD00		;CRYS1
;;		BYTE	TRYFRCD-ENCD00		;TRYFR
;;		BYTE	TRYFYCD-ENCD00		;TRYFY
;;		BYTE	TRYFBCD-ENCD00		;TRYFB
;;		BYTE	SPESRCD-ENCD00		;SPESR
;;		BYTE	SPESYCD-ENCD00		;SPESY
;;		BYTE	SPESBCD-ENCD00		;SPESB
		BYTE	YAAA1CD-ENCD00		;YAAA1
		BYTE	YAAA2CD-ENCD00		;YAAA2
		BYTE	YOSEICD-ENCD00		;YOSEI
		BYTE	KAGI0CD-ENCD00		;KAGI0
		BYTE	KAGI1CD-ENCD00		;KAGI1
		BYTE	PTATECD-ENCD00		;PTATE
		BYTE	KINOKCD-ENCD00		;KINOK
		BYTE	000H	 		;SUKAS
		BYTE	000H	 		;MJSY1
		BYTE	UTUWACD-ENCD00 		;UTUWA
		BYTE	UTUBKCD-ENCD00 		;UTUBK
;-------------------------------------------------------
;================================================
EN1CSTL		EQU	$
		PHB
		PHK
		PLB
		JSR	EN1CST
		PLB
		RTL
;================================================
EN1CSSL		EQU	$
		PHB
		PHK
		PLB
		JSR	EN1CSS
		PLB
		RTL
;================================================
SWXADT		EQU	$
		BYTE	0,0,1,1,1,2,2,2,2,3,3,3,3,3,3,3
;
EN1CST		EQU	$
		JSR	OAMCHK	
;;		LDY	ENOMID,X
EN1C50		EQU	$
		LDA	<WORK0
		STA	(<OAMADR),Y
		LDA	<WORK1
		CMP	#01H
;
		LDA	#01H
		ROL	A
;;;;		ORA	ENDSPL,X
		STA	(<OSBADR)
;		
		MEM16
		REP	#00100000B
		LDA	<WORK2
		INY
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCS	SADWS0
;
		SBC	#010H-1
		STA	(<OAMADR),Y
		PHY
;
		LDY	ENMYNO,X
		LDA	ENCDAD,Y
		CLC
		ADC	ENCHPT,X
		TAY
		LDA	ENCD00,Y
		PLY
		INY
		STA	(<OAMADR),Y
;
;;		LDA	#20H
;;		LDA	ENCLOR,X
		LDA	<WORK5
		INY
		STA	(<OAMADR),Y
SADWS0		EQU	$
		LDA	ENMOD2,X
		AND	#00010000B
		BNE	SADWST		; shadow set ?
		RTS
;					; yes !
;==============================================
;==============================================
SADWSTL		EQU	$
		PHB
		PHK
		PLB
		JSR	SADWST
		PLB
		RTL
;--------------------------------------------
SADWS2L		EQU	$
		PHB
		PHK
		PLB
		JSR	SADWS2
		PLB
		RTL
;--------------------------------------------
SADWST		EQU	$
		LDA	#0AH
SADWS2		EQU	$
		CLC
		ADC	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		ADC	#00H
		STA	<WORK3
;
		LDA	ENDSPL,X
		BNE	SDSRTS
;
		LDA	ENMODE,X
		CMP	#ECACH
		BNE	SDS001
;
		LDA	>ENCACT,X
		CMP	#03H
		BEQ	SDSRTS		; Player chach up ! not kage !
;
SDS001		EQU	$
		MEM16
		REP	#00100000B
		LDA	<WORK2
		SEC
		SBC	<SCCV2
		STA	<WORK2
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCS	E1C010		; ypos out ?
;					; no
;;		STZ	<WORK6
;;		LDA	ENXPSL,X
;;		CMP	<SCCH2
;;		LDA	ENXPSH,X
;;		SBC	<SCCH2+1
;;		BEQ	SDS001		; x out ?
;;;
;;		INC	<WORK6		; yes !
;;SDS001   	EQU	$
;
		LDA	ENMOD0,X
		AND	#1FH
;;;;		INC	A
		ASL	A
		ASL	A
		TAY
		LDA	<WORK0
		STA	(<OAMADR),Y
;
		LDA	ENMOD2,X
		AND	#00100000B
		BEQ	SDS010		; size ?
;					; small !
		INY
		LDA	(<OAMADR),Y
		LDA	<WORK2
		INC	A
		STA	(<OAMADR),Y
		INY
		LDA	#38H
		STA	(<OAMADR),Y
		LDA	<WORK5
		AND	#00110000B
		ORA	#08H
		INY
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY		
		LDA	<WORK1
		AND	#01H
		STA	(<OSBADR),Y
SDSRTS		EQU	$
		RTS
;- - - - - - - - - - - - - - -
SDS010          EQU	$
		LDA	<WORK2
;;		SEC
;;		SBC	<SCCV2
		INY
		STA	(<OAMADR),Y
		LDA	#06CH
		INY
		STA	(<OAMADR),Y
;;		LDA	ENCLOR,X
		LDA	<WORK5
		AND	#00110000B
		ORA	#08H
		INY
		STA	(<OAMADR),Y
;
		TYA	
		LSR	A
		LSR	A
		TAY
		LDA	<WORK1
		AND	#01H
		ORA	#02H
;;		ORA	<WORK6
		STA	(<OSBADR),Y
;
;
E1C010		EQU	$
E1C055		EQU	$
		RTS	
;==============================================
;====================================================
;================================================
EN1CSS		EQU	$		; Small size 1 set 
		JSR	OAMCHKS	
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		LDA	<WORK1
		CMP	#01H
;
		LDA	#00H
		ROL	A
		STA	(<OSBADR)
;		
		MEM16
		REP	#00100000B
		LDA	<WORK2
		INY
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCS	ECSS00
;
		SBC	#010H-1
		STA	(<OAMADR),Y
		PHY
;
		LDY	ENMYNO,X
		LDA	ENCDAD,Y
		CLC
		ADC	ENCHPT,X
		TAY
		LDA	ENCD00,Y
		PLY
		INY
		STA	(<OAMADR),Y
;
;;		LDA	ENCLOR,X
		LDA	<WORK5
		INY
		STA	(<OAMADR),Y
;
ECSS00		EQU	$
		LDA	ENMOD2,X
		AND	#00010000B
		BEQ	ECSS10		; shadow set ?
;
		LDA	#02H
		JMP	SADWS2
ECSS10		EQU	$
		RTS
;					; yes !
;;;		JSR	EN1C50		;******
;;;
;;		LDA	(<OSBADR)
;;		AND	#11111101B
;;		STA     (<OSBADR)
;;		RTS
;
;;;;			JSR		TTN01MV
;;;;			RTS
;======================================================================
EN12CSL		EQU	$
		PHB
		PHK
		PLB
		JSR	EN12CS
		PLB
		RTL
;======================================================================
EN12CS		EQU	$
		JSR	OAMCHK
;;;		LDY	#00H	
		LDA	<WORK0
		STA	(<OAMADR),Y
		LDY	#04H
		STA	(<OAMADR),Y
;
		LDA	<WORK1
		CMP	#01H
		LDA	#00H
;;;		ORA	ENDSPL,X
		ROL	A
		LDY	#00H
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y

;
		MEM16
		REP	#00100000B
		LDA	<WORK2
		LDY	#01H
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	E12C12
		LDA	#00F0H
		STA	(<OAMADR),Y
E12C12		EQU	$
		LDA	<WORK2
		CLC
		ADC	#0008H
		LDY	#05H
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	E12C13
		LDA	#00F0H
		STA	(<OAMADR),Y
E12C13		EQU	$
		MEM8
		SEP	#00100000B
;
		LDY	ENMYNO,X
		LDA	ENCDAD,Y
		CLC
		ADC	ENCHPT,X
		TAY
		LDA	ENCD00,Y
		LDY	#02H
		STA	(<OAMADR),Y
		CLC
		ADC	#10H
		LDY	#06H
		STA	(<OAMADR),Y
;
;;		LDA	#20H
;;		LDA	ENCLOR,X
		LDA	<WORK5
		LDY	#03H
		STA	(<OAMADR),Y
		LDY	#07H
		STA	(<OAMADR),Y
		JMP	SADWS0		; kage set !
;;==========================================
;ENPTST		EQU	$
;		INC	ENCONT,X
;		LDA	ENCONT,X
;		LSR	A
;		LSR	A
;		LSR	A
;		AND	#00000001B
;		STA	ENCHPT,X
;		RTS
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+														+
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SKHADT		EQU	$
		HEX	00,00,00,40
SKHCDT		EQU	$
		HEX	00,01,02,01
SKHEDMV		EQU	$
		LDA	<PLBGCKF
		STA	ENKAIF,X
;
		LDA	ENTIM1,X
		BEQ	SHM010
		LDA	#02H*4
		JSL	>OAMENT3
SHM010		EQU	$
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	SKHADT,Y
		STA	ENCLOR,X
		LDA	SKHCDT,Y
		STA	ENCHPT,X
;
		LDA	#30H
		STA	ENFLCL,X
;
		JSR	EN1CST
;
		JSR	ENSTCK
;
		JSR	ENHNSB
;
;;		JSR	CRKNEN
;;		JSR	CRENPL
		JSR	CREKEK
;
		LDA	ENHNFG,X
		BEQ	SHM011
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
SHM011		EQU	$
		JSR	ENMVCL
;
		INC	ENCONT,X
;
		LDA	ENTIM0,X
		BEQ	SHM070
;
		AND	#01H
		BNE	SHM020
;
		LDA	#10H
		JSR	PSERC2
;
SHS00C		EQU	$
		LDA	ENYSPD,X
		CMP	<WORK0
		BEQ	SHS030
		BPL	SHS010
		INC	ENYSPD,X
		BRA	SHS030
SHS010		EQU	$
		DEC	ENYSPD,X
SHS030		EQU	$
		LDA	ENXSPD,X
		CMP	<WORK1
		BEQ	SHS050
		BPL	SHS040
		INC	ENXSPD,X
		BRA	SHS050
SHS040		EQU	$
		DEC	ENXSPD,X
SHS050		EQU	$
SHM020		EQU	$
		RTS
;- - - Go away - -
SHM070		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	SHM020
;
		LDA	#10H
		JSR	PSERC2
		LDA	<WORK0
		EOR	#0FFH
		INC	A
		STA	<WORK0
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	<WORK1
		BRA	SHS00C
;-------------------------------------------------------
;-------------------------------------------------------
;-------------------------------------------------------
;-------------------------------------------------------
;TTN01MV		EQU	$
;;		RTS
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;LPLHNCK		EQU	$
;L;;			TXA
;L;;			EOR		<FRCNT
;L;;			AND		#07H
;L		LDA	ENDSPL,X
;L		BNE	PLHN10
;L;
;L;;;			STZ		HANIFG
;L;
;L		JSR	EPXYCK
;L		STY	<WORK0
;L;;			JSR		EPXCHK
;L		LDA	<WORKF
;L		CLC
;L		ADC	#20H
;L		CMP	#40H
;L		BCS	PLHN10
;L;;			JSR		EPYCHK
;L		LDA	<WORKE
;L		CLC
;L		ADC	#20H
;L		CMP	#40H
;L		BCS	PLHN10		; Player atack area ?
;L;;;;			JSR		EPXYCK		; yes !
;L;
;L;;		LDY	<WORK0
;L;;		LDA	PLMKCK,Y
;L;;		CMP	PLMKCH
;L;;		BNE	PLHN10		; Muki ok ?
;L;								; yes !
;L		INC	HANIFG		; Player in !
;LPLHN10		EQU	$
;L		RTS
;===========================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		enemy player cached			   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ENCAXL		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	0F3H,0F6H,0FBH,000H
		BYTE	00DH,00AH,005H,000H
ENCAXH		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	0FFH,0FFH,0FFH,000H
		BYTE	000H,000H,000H,000H
ENCAZL		EQU	$
		BYTE	00DH,00EH,00FH,010H
		BYTE	000H,00AH,016H,010H
		BYTE	008H,00BH,00EH,010H
                BYTE	008H,00BH,00EH,010H
;- - - - - - - - - - - - - - - - - - - -
ECAYRV		EQU	$
		HEX	3,2,1,3,2,1      
;- - - - - - - - - - - - - - - - - - - -
ENCACH		EQU	$
;;		JSR	ECACHCS
;
;;;             JSR	ENMOVE		; for c set !
;;		LDA	<GAMEMD
;;		BNE	ECA090
		LDA	GRNDNO
		STA	ENGRNO,X
;
;;		LDA	ENSTAT,X
;;		LDA	ENWRK3,X
		LDA	>ENCACT,X
		CMP	#03H
		BEQ	ECA050
		LDA	ENTIM0,X
		BNE	ECA020
		LDA	#04H
		LDY	ENWRK2,X
		CPY	#06H
		BNE	ECA019
		LDA	#08H
ECA019		EQU	$
		STA	ENTIM0,X
;
		LDA	>ENCACT,X
		INC	A
		STA	>ENCACT,X
;;		INC	ENWRK3,X
;;		INC	ENSTAT,X
ECA020		EQU	$
		BRA	ECA055
;- - - - - - - - - - - - - - - - - - - - -
ECA050		EQU	$
		LDA	ENMOD2,X
		AND	#11101111B
		STA	ENMOD2,X	; sadow clear !
ECA055		EQU	$
		STZ	<WORK0
		LDA	ENTIM3,X
		DEC	A
		CMP	#40H-1
		BCS	ECA056
		AND	#02H
		BEQ	ECA056
		INC	<WORK0
ECA056		EQU	$
		LDA	<PLMKCH
;;		LSR	A
		ASL	A
		CLC
		ADC	>ENCACT,X
;;		ADC	ENWRK3,X
;;		ADC	ENSTAT,X
		TAY
		LDA	<PLXPS1
		CLC
		ADC	ENCAXL,Y
		PHP
		ADC	<WORK0
		STA	ENXPSL,X
		LDA	<PLXPS0
		ADC	#00H
		PLP
		ADC	ENCAXH,Y
		STA	ENXPSH,X
;;		LDA	PLYPS1
;;		CLC
		LDA     ENCAZL,Y
		STA	ENZPSL,X
;
		LDY	<PYCRCH
		CPY	#06H
		BCC	ECA234
;
		LDY	#00H
ECA234		EQU	$
		LDA	<PLZPS1
;;		INC	A
		CLC
		ADC	ECAYRV,Y
		STA	<WORK0
		LDA	<PLYPS1		;TEST !
		SEC
		SBC	<WORK0
		PHP
		CLC
		ADC	#08H
		STA	ENYPSL,X
		LDA	<PLYPS0
		ADC	#00H
		PLP
		SBC	#00H
		STA	ENYPSH,X
;
		LDA	<PLBGCKF
		STA	ENKAIF,X	; 91/7/5
;
;;		LDA	ENSTAT,X
;;		CMP	#03H
;;		BNE	ECA090
;
		JSR	CAOFCK		; cach off check !
;
ECA090		EQU	$
;;		RTS
;=====================================
ECACHCS		EQU	$
		JSR	PSSAVE		; position recover !!
;
		LDA	>ENCAMD,X
;;		LDA	ENWRK0,X
		CMP	#EICE
		BEQ	ECA0A0
;
		JSR	ENMOVE		; for c set !
;- - For KAM01 - - Move back - -
		LDA	ENTIM3,X
		DEC	A
		BNE	ECC000
;
		LDA	#EMOVE
		STA	ENMODE,X
		STZ	ENWRK1,X
		LDA	#60H
		STA	ENTIM3,X
		LDA	#20H
		STA	ENZSPD,X
;
		LDA	ENMOD2,X	; Sadow reover !
		ORA	#00010000B
		STA	ENMOD2,X
		LDA	#02H
		STA	PYDMBT1		; Shot !
ECC000		EQU	$
		RTS
ECA0A0		EQU	$
		JSR	ENICECS		; kirakira ! ! !
COCK90R		EQU	$
		RTS
;========================================
CASHXS		EQU	$
		BYTE	000H,000H,0C2H,03FH
;;        	BYTE	000H,000H,0D0H,030H
CASHYS		EQU	$
		BYTE	0C2H,03FH,000H,000H
;;		BYTE	0D0H,030H,000H,000H
CASHZS		EQU	$
		BYTE	004H,004H,004H,004H
;;		BYTE	010H,010H,010H,010H
;
;CAOKXS		EQU	$
;		BYTE	000H,000H,0F8H,008H
;CAOKYS		EQU	$
;		BYTE	0F8H,008H,000H,000H
;- - - - - - - - - - - - - 
CAOFCK		EQU	$
;;		LDA	<GAMEMD
;;		ORA	ENSTFG
		LDA	SLMODE
		CMP	#MD_etcpl
		BEQ	COCK90R		; In game ?
;					; yes !
		LDA	<HOLEFG2
		CMP	#02H
		BEQ	COC0D0		; Hole down !
;
		LDA	<DIEFG
		AND	#01H
		LDY	MRTKFG
		BNE	COF090
;
		ORA	HANEFG
COF090		EQU	$
		ORA	WATRFG
		ORA	RABFLG		; Usagi !!
		ORA	ATMTHK		; Item mochiage !
		BNE	COC0D0	 	; in water
;
		LDA	>ENCACT,X
;;		LDA	ENWRK3,X
;;		LDA	ENSTAT,X
		CMP	#03H
		BNE	COCK90		; kanzen katsugi ?
;					; yes !
;;		LDA	PYDMBT
;;		BPL	COC0D0		; pause
;
;;		LDA	YPSHMD
;;		CMP	#07H
;;		BNE	COCK90		; CACH MODE ?
;
		LDA	<KEYA2 		; yes 
		ORA	<KEYA2L		; yes 
;;		AND	#10000000B
		BPL	COCK90		; key in ?
;
		STZ	<KEYA2L
COC0D0		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#13H
;;		STA	SOUND3		;(S)
		LDA	#13H
		JSL	>SDLRE3	;(S)
;
		LDA	#02H
		STA	PYDMBT1		; Shot !
;
;;		LDA	ENWRK0,X
		LDA	>ENCAMD,X
		STA	ENMODE,X
		STZ	ENZSPD,X
		LDA	#00H
		STA	>ENCACT,X
;;		STZ	ENWRK3,X
;;		STZ	ENSTAT,X
;
		PHX
		LDA	ENMYNO,X
		TAX
		LDA	>ENMDD2,X
		PLX
		AND	#00010000B
		STA	<WORK0
		LDA	ENMOD2,X
		AND	#11101111B
		ORA	<WORK0
		STA	ENMOD2,X	; sadow recover !
;
		LDA	<PLMKCH
		LSR	A
		TAY
;;		LDA	<KEYA1
;;		AND	#00001111B
;;		BEQ	COCK50
;;;
;;		INY
;;		INY
;;		INY
;;		INY
;;COCK50		EQU	$
		LDA	CASHXS,Y
		STA	ENXSPD,X
		LDA	CASHYS,Y
		STA	ENYSPD,X	
		LDA	CASHZS,Y
		STA	ENZSPD,X
;
;;		LDA	#08H
		LDA	#00H
		STA	ENTIM3,X
;
;		RTS
;
;		LDA	CAOKXS,Y
;		STA	ENXSPD,X
;		LDA	CAOKYS,Y
;		STA	ENYSPD,X
;		LDA	#10H
;		STA	ENZSPD,X
COCK90		EQU	$
		RTS
;;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;EIFCDT		EQU	$
;;;		BYTE	0AAH,0A3H,0A2H,0B3H,0,0,00,0,0,0
;		BYTE	083H,080H,0B6H,0B7H,0,0,00,0,0,0
;;
;ENICFL		EQU	$
;		LDA	ENTIM0,X
;		BNE	EIF010
;		STZ	ENMODE,X
;EIF010		EQU	$
;		JSR	OAMCHK
;		LDA	ENDSPL,X
;		BNE	EIF090		; display in ?
;;					; yes !
;		LDA	#01H*4
;		LDY	ENKAIF,X
;		BEQ	EIF012
;		JSL	>OAMENT5
;		BRA	EIF013
;EIF012		EQU	$
;		JSL	>OAMENT3
;;;;;		BCS	EIF090		; index entry ?
;;					; yes !
;EIF013		EQU	$
;		LDY	#00H
;		MEM16
;		REP	#20H
;		LDA	<WORK0
;		STA	(<OAMADR),Y
;		AND	#0100H
;		STA	<WORKE
;;
;		LDA	<WORK2
;		INY
;		STA	(<OAMADR),Y
;		CLC
;		ADC	#0010H
;		CMP	#0100H
;		MEM8
;		SEP	#20H
;		BCC	EIF015
;		LDA	#0F0H
;		STA	(<OAMADR),Y
;EIF015		EQU	$
;		LDA 	ENTIM0,X
;		LSR	A
;		LSR	A
;		LSR	A
;		PHX
;		TAX
;		LDA	EIFCDT,X
;		INY
;		STA	(<OAMADR),Y
;		PLX
;		LDA	#00100100B
;		INY
;		STA	(<OAMADR),Y
;;;;		LDY	#00H
;		LDA	<WORKF
;		STA	(<OSBADR)    ;,Y
;EIF090		EQU	$
;		RTS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;===========================================================
ENBDSBL		EQU	$
		PHB
		PHK
		PLB
		JSR	ENBDSB
		PLB
		RTL
;- - - - - - - - - - - - - - - - - - - - - -
ENICE		EQU	$
		JSR	ENICECS
;
		JSR	ENSTCK2
;
		LDA	ENHNFG,X
		BEQ	EIC0F0
		BPL	EIC0E8
;
		STZ	ENHNFG,X
EIC0E8		EQU	$
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
EIC0F0		EQU	$
		LDA	ENTIM0,X
		CMP	#20H
		BCS	EIC001		;  cros ken ok ?
;					;  yes !
		JSR	CRKNEN
EIC001		EQU	$
		JSR	ENHNSB
;
;;		LDA	<GAMEMD
;;		BNE	EIF090    
;
;===========================================================
;;;ENBDCL		EQU	$
		JSR	ENMVCL
;
		LDA	ENATCT,X
		BNE	EIC002		; Tobiori read ?
;					; NO !
		JSR	ENBGCK
		LDA	ENMODE,X
		BEQ	EICRTS	;F090 
;
ENBDSB		EQU	$
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	EIC002
;
;;		LDA	ENXSPD,X
;;		BEQ	EIC015		; yoko move?
;;			
;;		LDA	ENZPSL,X	; jump ?
;;		BNE	EIC002
EIC015		EQU	$		; no !
		JSR	SDBUND
EIC002		EQU	$
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
;
		LDA	ENZPSL,X
		DEC	A
;;		BMI	EIC003
		CMP	#0F0H
		BCS	EIC003
		JMP	EIC008
EIC003		EQU	$
		STZ	ENZPSL,X
;
		LDA	ENMYNO,X
		CMP	#SUKAS
		BNE	EIC004		; suka ken ?
;					; yes !
		LDA	ENZSPD,X
		CMP	#0E8H
		BPL	EIC004
;
		LDA	#EFAIL
		STA	ENMODE,X
		LDA	#08H
		STA	ENTIM0,X
S3MOD0_X	EQU	$
		LDA	#03H		; haretsu !
		STA	ENMOD0,X	; OAM suu !
EICRTS		EQU	$
		RTS
;- - - - - - - - - - - - - -- - -
EIC004		EQU	$
;;		LDA	ENATCT,X
;;		BEQ	EIC025		; Takai tokokara ochita ?
;					; yes !
		JSR	KTOCHK		; kowareru check !
;
		LDY	#BC1-BC0		; BG MANNAKA  check 
		JSR	UNITR2
		LDA	UNITNO
		CMP	#09H
		BNE	EIC01E		; asase ?
;					; yes !
		LDA	ENZSPD,X
		STZ	ENZSPD,X
		CMP	#0F0H
		BPL	EIC022
;
		LDA	#KTOBJ
		JSL	>ENIDSH
		BMI	EIC022
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
		PHX
		TYX
		JSR	ENWTST
		PLX
;
		BRA	EIC022
;
EIC01E		EQU	$
		CMP	#08H
		BNE	EIC022		; water in 
;					; yes !
		LDA	ENMYNO,X
		CMP	#JFISH
		BEQ	EIC01F
;
		JSL	>RNDSET
		LSR	A
		BCC	KMZS20 
;
		LDA	URAFLG
		BNE	KMZS20
;
EIC01F		EQU	$
		JSR	JFISHST
;
KMZS20		EQU	$
ENWTST		EQU	$
		JSL	>SDLRCE
		ORA	#28H
		STA	SOUND2	; (S)	; Yuusen !
;;		LDA	#28H
;;		JSL	>SDLRE2	;(S)
;
		LDA	#EWATR		; TEST TEST ! 
		STA	ENMODE,X
		LDA	#00001111B
		STA	ENTIM0,X
		STZ	ENSTAT,X
;
		JSL	>RNDSET
		AND	#01H
;;		LDA	#03H
;;		STA	ENMOD0,X
;;		RTS
		JMP	S3MOD0_X
;
EIC022		EQU	$
EIC025		EQU	$
		LDA	ENZSPD,X
		BPL	EIC034
		EOR	#0FFH
		INC	A
		LSR	A
;;		NOP	
		CMP	#09H
		BCS	EIC033
		LDA	#00H
EIC033		EQU	$
		STA	ENZSPD,X
EIC034		EQU	$
		LDA	ENXSPD,X
		ASL	A
		ROR	ENXSPD,X
		LDA	ENXSPD,X
		CMP	#0FFH
		BNE	EIC005
		STZ	ENXSPD,X	
EIC005	 	EQU	$
		LDA	ENYSPD,X
		ASL	A
		ROR	ENYSPD,X
		LDA	ENYSPD,X
		CMP	#0FFH
		BNE	EIC008
		STZ	ENYSPD,X	
EIC008		EQU	$
		LDA	ENMODE,X
		CMP	#EICE
		BNE	EIC009
;
		LDA	>ENICMD,X
;;		LDA	ENWRK2,X
		BEQ	ENIC10		; enemy stop ?
;					; no !
EIC009		EQU	$
		JSR	CACHCK		; ICE !!
;
		LDA	ENMYNO,X
		CMP	#HEBO0
		BEQ	ENIC10		; heishi bomb ?
;					; no.!
		JSR	CRICEN		; VS enemy 
ENIC10		EQU	$
		RTS
;-----------------------------
KTBDCL		EQU	$
		JSR	ENMVCL
;
		LDA	ENATCT,X
		BNE	KTB010
;
		JSR	ENBGCK
KTB010		EQU	$		
		JSR	ENBDSB
		RTS
;===============================================
CRICEN		EQU	$
		LDA	ENTIM3,X
		BNE	CIE0RT
;
		LDA	ENXSPD,X
		ORA	ENYSPD,X
		BEQ	CIE0RT
;
		LDY	#ENNO-1
CIE010		EQU	$
		PHY
		CPY	ENINDX
		BEQ	CIE020		; myself ?
;
		LDA	ENMYNO,X
		CMP	#JFISH
		BEQ	CIE020
;
		LDA	ENMODE,Y	; no !
		CMP	#EMOVE
		BCC	CIE020
		TYA
		EOR	<FRCNT
		AND     #03H
		ORA	ENNOCR,Y
		ORA	ENFLSH,Y
		BNE	CIE020
;
		LDA	ENKAIF,X
		CMP	ENKAIF,Y
		BNE	CIE020
;
		JSR	CIESUB
CIE020		EQU	$
		PLY
		DEY
		BPL	CIE010
CIE0RT		EQU	$
		RTS
;------------------------------------
;KTHTNO		EQU	$
;;;			0 1 2 3 4 5 6  
;		HEX	1,A,1,0,1,A,A 
;------------------------------------
CIESUB		EQU	$
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK8
		LDA	#0FH
		STA	<WORK2
		LDA	ENYPSL,X
		SEC
		SBC	ENZPSL,X
		PHP
		CLC
		ADC	#08H
		STA	<WORK1
		LDA	ENYPSH,X
		ADC	#00H
		PLP
		SBC	#00H
		STA	<WORK9
		LDA	#08H
		STA	<WORK3
;
		PHX
		TYX
		JSR	ENCRST
		PLX
		JSR	CROJCK
		BCC	CIE0RT
;
		LDA	ENMYNO,Y
		CMP	#BARI0
		BNE	CIE088
;
		JSL	>EFLSST
		BRA	SDBUND
CIE088		EQU	$
;
;;		LDA	#03H
		LDA	#0AH
		PHA
;;;		STA	<WORK0
;;
		LDA	ENMYNO,X
		CMP	#KTOBJ
		BNE	CKH010
;;
		LDA	ENWRK2,X
		CMP	#02H
		BNE	CKH010		; Kusa ?
;					; yes !
		LDA	<DJFLG
		BNE	CKH010
;
		PLA
		LDA	#01H
		PHA
;;;		PHY
;;;		LDY	ENWRK2,X
;;;		LDA	KTHTNO,Y
;		LDA	#0AH
;		STA	<WORK0
;;;		PLY
CKH010		EQU	$
		PLA
;;;;		LDA	<WORK0
		PHX
		TYX
		PHY
		JSL	>ENDMST3
		PLY
		PLX
		LDA	ENXSPD,X
		ASL	A
		STA	ENHNXS,Y
		LDA	ENYSPD,X
		ASL	A
		STA	ENHNYS,Y
;
		LDA	#10H
		STA	ENTIM3,X
;=====================================
SDBUND		EQU	$		; speed 1/4
		JSR	ENTURN
;
		LDA	ENXSPD,X
		ASL	A
		ROR	ENXSPD,X
;
		LDA	ENYSPD,X
		ASL	A
		ROR	ENYSPD,X
;
;;		STZ	ENXSPD,X
;;		STZ	ENYSPD,X
;- -  - - - - - - -
KTOCHK		EQU	$
		LDA	ENMYNO,X
		CMP	#KTOBJ
		BNE	CIE090		; moteru mono ?
;					; yes !
;;		LDA	ENWRK2,X
;;		CMP	#00H
;;		BEQ	CIE090		; kusa or ishi ?
;					; yes !
		STZ	FLMODE
;
;;		CMP	#01H
;;		BNE	KTOSUB
;;		BIT	GRNDNO
;;		BVC	KTOSUB		; omote ?
;;;					; URA !!
;;		LDA	ENZPSL,X
;;		BNE	CIE090		; on zimen ?
;					; yes !
KTOSUB		EQU	$
		LDA	ENCHPT,X
		BEQ	KSB020		; In item ?
;					; yes !
;;		CLC
;;		ADC	#04H
		STA	OSETFG		; 0;BOMB1 1;HART1
;
		JSR	OSETCK
;
		STZ	OSETFG
;
		BCC	KSB020
;
;;		JSL	>SDLRCE
;;		ORA	#30H
;;		STA	SOUND3	;(S)
		LDA	#30H
		JSL	>SDLRE3	;(S)
;
KSB020		EQU	$
;
		LDY	ENWRK2,X
		LDA	<DJFLG
		BEQ	KSB021
		TYA
		CLC
		ADC	#09H
		TAY
KSB021		EQU	$
;;		JSL	>SDLRCE
;;		ORA	KSBSND,Y
;;		STA	SOUND2		; (S)
		STZ	SOUND2		; (S)
		LDA	KSBSND,Y
		JSL	>SDLRE2	;(S)
;
ENFLST		EQU	$
		LDA	#1FH
ENFLS2		EQU	$
		STA	ENTIM0,X
;
		LDA	#EFAIL
		STA	ENMODE,X
;
		LDA	ENMOD0,X
		CLC
		ADC	#04H
		STA	ENMOD0,X
CIE090		EQU	$		
		RTS
;- - - - - - - -
KSBSND		EQU	$	;Sound data !
		HEX	1F,1F,1E,1E,1E,1F,1F,1F,1F
		HEX	1F,1F,1F,1E,1E,1F,1E,1E,1F
;==================================================
JFISHST		EQU	$
		LDA	#JFISH 
		JSL	>ENIDSH
		BMI	JFS010
;
;;		LDA	<WORK0
;		CLC
;		ADC	#04H
;		STA	<WORK0
;		LDA	<WORK1
;		ADC	#00H
;		STA	<WORK1
;
		JSL	>ENIDPS
;
		LDA	#02H
		STA	ENSTAT,Y
		LDA	#30H
		STA	ENTIM0,Y
;
		LDA	ENMYNO,X
		CMP	#JFISH
		BNE	JFS010
;
		STA	ENWRK0,Y
JFS010		EQU	$
		RTS
;==================================================
EISTXD		EQU	$
EISTYD		EQU	$
		BYTE	0FCH,0CH,03H,08H
EISTXH		EQU	$
EISTYH		EQU	$
		BYTE	0FFH,00H,00H,00H
EISTMD		EQU	$
		BYTE	7FH,0FH,03H,01H,0,0,0
;-----------------------------------------------
ENICECS		EQU	$
		JSR	ENMOVE		; for cset
;
		LDA	>ENICMD,X
;;		LDA	ENWRK2,X
		BEQ	EIST90		; Ice ?
;					; yes !
		LDA	ENTIM0,X
		CMP	#20H
		BCS	EISC00
		LDA	ENCLOR,X
		AND	#11110001B
		ORA	#00000100B
		STA	ENCLOR,X
EISC00		EQU	$ 
		LDA	ENTIM0,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
;;		BYTE	0EAH,0EAH,0EAH,0EAH
		TAY
		TXA
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		EOR	<FRCNT
		ORA	<GAMEMD
		AND	EISTMD,Y
		BNE	EIST10
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	EISTXD,Y
		STA	<WORK0 
		LDA	EISTXH,Y
		STA	<WORK1 
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	EISTYD,Y
		STA	<WORK2
		LDA	EISTYH,Y
		STA	<WORK3
;
		JSL	>ICEFLST
;
;		JSL	>ENIDSH
;		BMI	EIST10
;;
;		LDA	#EICFL
;		STA	ENMODE,Y
;		PHX
;		JSL	>RNDSET
;		AND	#03H
;		TAX
;		LDA	<WORK0
;		CLC
;		ADC	EISTXD,X
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		ADC	EISTXH,X
;		STA	ENXPSH,Y
;		JSL	>RNDSET
;		AND	#03H
;		TAX
;		LDA	<WORK2
;		CLC
;		ADC	EISTYD,X
;		PHP
;		SBC	<WORK4		; zpos
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		SBC	#00H
;		PLP
;		ADC	EISTYH,X
;		STA	ENYPSH,Y
;		LDA	#1FH
;		STA	ENTIM0,Y
;		PLX
EIST10		EQU	$
		RTS
;- - -Normal stop - - 
EIST90		EQU	$
		LDA	<FRCNT
		AND	#01H
		ORA	<GAMEMD
		ORA	ENSTFG
		BNE	EISTA0
;
		LDA	ENSTTM,X
		BEQ	EISTB0
		DEC	ENSTTM,X
;
		CMP	#038H
		BCS	EISTA0
;
;	NOP
;	LSR	A
		AND	#01H
		TAY
		LDA	EISTXS,Y
		STA	ENXSPD,X
		JSR	ENXCLC
EISTA0		EQU	$
		RTS
;- - - - - move back - - - - - - - -
EISTB0		EQU	$
		LDA	#EMOVE
		STA	ENMODE,X
;
		STZ	ENHNXS,X
		STZ	ENHNYS,X
;;		STZ	ENXSPD,X
;;		STZ	ENYSPD,X
;
		RTS
;- - - -
EISTXS		EQU	$
		HEX	08,F8
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
EIBRXD		EQU	$
		BYTE	0FAH,00AH,001H,00DH
		BYTE	0FAH,00AH,001H,00DH
        	BYTE	0F9H,004H,0FBH,006H
		BYTE	0FFH,001H,0FEH,000H
EIBRYD		EQU	$
		BYTE	0FAH,0FCH,00AH,009H
		BYTE	0FAH,0FCH,00AH,009H
		BYTE	0F8H,0F6H,004H,003H
		BYTE	0FFH,0FEH,000H,001H
EIBRCD		EQU	$
		BYTE	09BH,09BH,09BH,09BH
		BYTE	0B3H,0B3H,0B3H,0B3H
		BYTE	08AH,08AH,08AH,08AH
		BYTE	08AH,08AH,08AH,08AH
EIBRAD		EQU	$
		BYTE	024H,0A4H,024H,0A4H
		BYTE	0E4H,064H,0A4H,024H
		BYTE	024H,0E4H,0E4H,0E4H
		BYTE	024H,0E4H,0E4H,0E4H
;;;		BYTE	024H,024H,024H,024H
EIBRSD		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
ENICBR		EQU	$
		LDA	ENTIM0,X
		BNE	EIBR08
;
;;		STZ	ENMODE,X
;;		JSR	FILSET		; fail & item set !
;
		LDA	KAGIFG,X
		BNE	EIBR07
;
		LDY	#02H
		JMP	ENFLIS		; Mujyouken item set !
EIBR07		EQU	$
		JMP	FILSET
;- - - - - - - - - - - - - - - - - - - - - -
EIBR08		EQU	$
		JSR	EICBRCS
		RTS
;
EICBRCS		EQU	$
		JSR	OAMCHK
;
		LDA	ENTIM0,X
		LSR	A
		AND	#11111100B
		STA	<WORK0
		PHX
		LDX	#03H
EIBR10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK0
		TAX
		LDA	ENDSXL
		CLC
		ADC	EIBRXD,X
		STA	(<OAMADR),Y
		LDA	ENDSYL
		CLC
		ADC	EIBRYD,X
		INY
		STA	(<OAMADR),Y
		LDA	EIBRCD,X
		INY
		STA	(<OAMADR),Y
		LDA	EIBRAD,X
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	EIBRSD,X
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	EIBR10
		PLX
		LDY	#0FFH
		LDA	#03H
		JSR	ALOMCK
		RTS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OAMCHKL		EQU	$
		JSR	OAMCH2
		RTL
;- - - - - - - - - - - - - - - - - - - - -
OAMCH2		EQU	$
		JSR	OAMCHK
		RTS
;- - - - - - - - - - - - - - - - - -
O2TEST		EQU	$	; oam set paramater set & display out check !
OAMCHK		EQU	$
OAMCHKS		EQU	$
		STZ	ENDSPL,X
;
;;		LDA	ENXPSH,X
;;		XBA
;;		LDA	ENXPSL,X
		MEM16
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	<SCCH2
		STA	<WORK0
		CLC
		ADC	#0040H
		CMP	#0170H
		MEM8
		SEP	#00100000B
		BCS	O2T010
;
		LDA	ENZPSL,X
		STA	<WORK4
		STZ	<WORK5
;
;;		LDA	ENYPSH,X
;;		XBA
;;		LDA	ENYPSL,X
		MEM16
		REP	#00100000B
		LDA	ENYP2L
		SEC
		SBC	<SCCV2
		PHA
		SEC
		SBC	<WORK4
		STA	<WORK2
		PLA
		CLC
		ADC	#0040H
		CMP	#0170H
		MEM8
		SEP	#00100000B
		BCC	O2T022
;
		LDA	ENMOD3,X
		AND	#00100000B
		BNE	O2T022		 ; Nagai yatsu ?
;					 ; no.
		BRA	O2T010
;
O2T022		EQU	$
		CLC
;;		LDA	ENXPSL,X
;;		SEC
;;		SBC	<SCCH2
;;		STA	<WORK0
;;		LDA	ENXPSH,X
;;		SBC	<SCCH21
;;		STA	<WORK1
;
;;                LDA     ENYPSL,X
;;;              SEC
;;                SBC     ENZPSL,X
;;;              PHP
;;                SEC
;;                SBC     <SCCV2
;;		STA	<WORK2
;;                LDA     ENYPSH,X
;;                SBC     <SCCV21
;;                PLP
;;                SBC     #00H
;;                PLP
;;                ADC     #00H
;;		STA	<WORK3
;
;;		LDA	<WORK0
;;		SEC
;;		SBC	#10H
;;		STA	ENDSYL
;
O2T038		EQU	$
		LDA	ENCLOR,X
		EOR	ENFLCL,X
		STA	<WORK5
		STZ	<WORK4
		LDA	<WORK0
		STA	ENDSXL
		LDA	<WORK2
		STA	ENDSYL
		LDY	#00H
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
O2T010		EQU	$
		INC	ENDSPL,X
;;		LDA	SLMODE
;;		CMP	#MD_djply
;;		BEQ	O2T020
;
		LDA	ENMOD5,X
		BMI	O2T020
;
		JSL	>ENCLER
O2T020		EQU	$
		PLA
		PLA
		SEC
		BRA	O2T038
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;OAMCHK		EQU	$
;		STZ	ENDSPL,X
;		LDA	ENYPSL,X
;		SEC
;		SBC	ENZPSL,X
;		SEC
;		SBC	<SCCV2
;		STA	ENDSYL
;;
;		LDA	ENYPSL,X
;		CLC
;		ADC	#10H
;		PHP
;		SEC
;		SBC	ENZPSL,X
;		PHP
;		SEC
;		SBC	<SCCV2
;		LDA	ENYPSH,X
;		SBC	<SCCV21
;		PLP
;		SBC	#00H
;		PLP
;		ADC	#00H
;		BEQ 	OMCK10
;OMCK0F		EQU	$
;		PLA
;		PLA
;		BRA	OMCK18
;OMCK10		EQU	$
;		LDA	ENXPSH,X
;		XBA
;		LDA	ENXPSL,X
;		MEM16
;		REP	#00100000B
;		SEC
;		SBC	<SCCH2
;		CLC
;		ADC	#0040H
;		CMP	#0180H
;		MEM8
;		SEP	#00100000B
;		BCS	OMCK0F
;;
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		STA	ENDSXL
;		LDA	ENXPSH,X
;		SBC	<SCCH21
;		BEQ	OMCK20
;OMCK18		EQU	$
;		INC	ENDSPL,X
;OMCK20		EQU	$
;;;;		LDY	ENOMID,X
;;		LDY	#00H
;;		RTS
;		BRA	OMCS20
;-----------------------------------------------------
;OAMCHKS		EQU	$
;		JMP	OAMCHK
;;
;		STZ	ENDSPL,X
;		LDA	ENYPSL,X
;		SEC
;		SBC	ENZPSL,X
;		CLC
;		ADC	#04H
;		SEC
;		SBC	<SCCV2
;		STA	ENDSYL
;		LDA	ENYPSL,X
;		CLC
;		ADC	#14H
;		PHP
;		SEC
;		SBC	ENZPSL,X
;		PHP
;		SEC
;		SBC	<SCCV2
;		LDA	ENYPSH,X
;		SBC	<SCCV21
;		PLP
;		SBC	#00H
;		PLP
;		ADC	#00H
;
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	#14H
;;		PHP
;;		SEC
;;		SBC	<SCCV2
;;		LDA	ENYPSH,X
;;		SBC	<SCCV21
;;		PLP
;;		ADC	#00H
;		BEQ 	OMCS10
;OMCS0F		EQU	$
;		PLA
;		PLA
;		BRA	OMCS18
;OMCS10		EQU	$
;		LDA	ENXPSH,X
;		XBA
;		LDA	ENXPSL,X
;		MEM16
;		REP	#00100000B
;		SEC
;		SBC	<SCCH2
;		CLC
;		ADC	#0040H
;		CMP	#0180H
;		MEM8
;		SEP	#00100000B
;		BCS	OMCS0F
;;
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		PHP
;		CLC
;		ADC	#04H
;		STA	ENDSXL
;		LDA	ENXPSH,X
;		ADC	#00H
;		PLP
;		SBC	<SCCH21
;		BEQ	OMCS20
;OMCS18		EQU	$
;		INC	ENDSPL,X
;OMCS20		EQU	$
;;;		LDY	ENOMID,X
;		LDY	#00H 
;		LDA	ENCLOR,X
;		STA	<WORK3
;		STZ	<WORK2
;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%          ENEMY BG CHECK 									 %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    	
ENBGCKL		EQU	$
		PHB
		PHK
		PLB
		JSR	ENBGCK
		PLB
		LDA	ENCBFG,X
		RTL
;--------------------------------------------------------
BC10101		EQU	$
;;;		STZ	ENKAIF,X
		LDA	ENHELP2
		STA	ENKAIF,X
		RTS
EBC000J		EQU	$
		JMP	EBC000
;
ENBGCK		EQU	$
		STZ	ENCBFG,X
;
		LDA	ENMOD3,X
		BMI	EBC000J		; BG 2 only check ?
;					; no.
		LDA	BGALCKF
		BEQ	EBC000J		; 2 Of BG check ?
;					; yes !
;;		TXA
;;		EOR	<FRCNT
;;		LSR	A
;;		BCS	EBC020
;----
;		CMP	#03H
;		MEM16
;		REP	#00100000B
;		BCC	B2CK10		; belt ?
;					; yes ! BG1=BG2 !
;		STZ	<WORKC
;		STZ	<WORKE
;		BRA	B2CK20
;B2CK10		EQU	$
;		LDA	<SCCH1
;		SEC
;		SBC	<SCCH2
;		STA	<WORKC
;		LDA	<SCCV1
;		SEC
;		SBC	<SCCV2
;		STA	<WORKE
;B2CK20		EQU	$
;		MEM8
;		SEP	#00100000B
;		LDA	ENXPSL,X
;		CLC
;		ADC	<WORKC
;		STA	ENXPSL,X
;		LDA	ENXPSH,X
;		ADC	<WORKD
;		STA	ENXPSH,X
;		LDA	ENYPSL,X
;		CLC
;		ADC	<WORKE
;		STA	ENYPSL,X
;		LDA	ENYPSH,X
;		ADC	<WORKF
;       	STA	ENYPSH,X
;;
		LDA	ENKAIF,X
		STA	ENHELP2
		LDA	#01H
		STA	ENKAIF,X	
;
		JSR	EBC000		;;;;;;;;;;;;;;;;
;
		LDA	BGALCKF
		CMP	#04H
		BEQ	BC10101
;
		STZ	ENKAIF,X
;		LDA	ENXPSL,X
;		SEC
;		SBC	<WORKC
;		STA	ENXPSL,X
;		LDA	ENXPSH,X
;		SBC	<WORKD
;		STA	ENXPSH,X
;		LDA	ENYPSL,X
;		SEC
;		SBC	<WORKE
;		STA	ENYPSL,X
;		LDA	ENYPSH,X
;		SBC	<WORKF
;        	STA	ENYPSH,X
;
;;;		BRA	EBC020
EBC0011		EQU	$
		JSR	EBC020
;
		LDA	UNITNO
		STA	>ENBG2NO,X	; BG 2 center unit no save (for beltconver check )
		RTS
;====================================================================
EBC000		EQU	$
;;		TXA
;;		EOR	<FRCNT
;;		AND	#01H
;;       	ORA	ENHNFG,X
;;		BEQ	EBC220		; hanekairi ?
;					; yes ! normal check !
EBC020		EQU	$
		LDA	ENMOD0,X
		AND	#00100000B
		BEQ	EBC080
;;;;;		BRL	ENBGCK1		; onry 1 point check !
;==========================================
ENBGCK1		EQU	$
		LDY	#BC2-BC0
		JSR	UNITR2
		BCC	BC1010
;
		INC	ENCBFG,X
BC1010		EQU	$
		RTS
;==========================================
EBC080		EQU	$
		LDA	ENMOD3,X
		BMI	EBC088
;
		LDA	BGALCKF
		BNE	EBCALL		; normal BG check ?
;
EBC088		EQU	$
		LDY	#00H	        ; yes !
		LDA	ENYSPD,X
		BEQ	EBC100
		BMI	EBC090
		INY
EBC090		EQU	$
		JSR	EBGYRV
;
;;EBGYRV		EQU	$
;;		JSR	UNITRD
;;		BCC	EBC100
;;
;;		LDA	ENBCBT,Y
;;		ORA	ENCBFG,X
;;		STA	ENCBFG,X
;;;
;;		LDA	HEMODE,X
;;		AND	#00000111B
;;		CMP	#00000101B
;;		BCS	EBC100		; hosei ok ? (heishi kabe check)
;;;					; yes !
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	ENBCRV,Y
;;		STA	ENYPSL,X
;;		LDA	ENYPSH,X
;;		ADC	ENBCRH,Y
;;		STA	ENYPSH,X
EBC100		EQU	$
;;		RTS
;
		LDY	#02
		LDA	ENXSPD,X
		BEQ	EBC200
		BMI	EBC190
		INY
EBC190		EQU	$
		JSR	EBGXRV
;
;;EBGXRV		EQU	$
;;		JSR	UNITRD
;;		BCC	EBC200
;;		LDA	ENBCBT,Y
;;		ORA	ENCBFG,X
;;		STA	ENCBFG,X
;;;
;;		LDA	HEMODE,X
;;		AND	#00000111B
;;		CMP	#00000101B
;;		BCS	EBC200
;;;
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	ENBCRV,Y
;;		STA	ENXPSL,X
;;		LDA	ENXPSH,X
;;		ADC	ENBCRH,Y
;;		STA	ENXPSH,X   
EBC200		EQU	$
		BRA	EBC222
;======ALL POINT BG CHECK=================
EBCALL		EQU	$
;-- U D check --
		LDY	#01H
EBC790		EQU	$
		JSR	EBGYRV
;
;;		JSR	UNITRD
;;		BCC	EBC800
;;		LDA	ENBCBT,Y
;;		ORA	ENCBFG,X
;;		STA	ENCBFG,X
;;;
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	ENBCRV,Y
;;		STA	ENYPSL,X
;;		LDA	ENYPSH,X
;;		ADC	ENBCRH,Y
;;		STA	ENYPSH,X
;;EBC800		EQU	$
		DEY
		BPL	EBC790
;-- L R check --
		LDY	#03H
EBC890		EQU	$
		JSR	EBGXRV
;
;;		JSR	UNITRD
;;		BCC	EBCA00
;;		LDA	ENBCBT,Y
;;		ORA	ENCBFG,X
;;		STA	ENCBFG,X
;;;
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	ENBCRV,Y
;;		STA	ENXPSL,X
;;		LDA	ENXPSH,X
;;		ADC	ENBCRH,Y
;;		STA	ENXPSH,X   
;;EBCA00		EQU	$
		DEY
		CPY	#01H
		BNE	EBC890
EBC222		EQU	$
;;; floor check 
;;		LDA	ENMOD4,X
;;		AND	#01000000B
;;		BNE	EBC223
;
		LDA	ENMOD4,X
		BMI	EBC220
;					; yes !
		LDA	ENZPSL,X
		BNE	EBC220		; On floor ?
;
EBC223		EQU	$
		LDY	#BC1-BC0		; BG MANNAKA  check 
		JSR	UNITR2
		LDA	UNITNO
;
		CMP	#20H			; Hole check
		BNE	EBC230
;
		LDA	ENMOD7,X
		AND	#01H
		BEQ	EBC240		; hole check ok ?
;					; yes !
		LDA	#EHOLE
		STA	ENMODE,X
;
;;		LDA	#01H
;;		STA	ENKAIF,X
;
		LDA	#3FH+20H
;
		LDY	ENMYNO,X
		CPY	#MOTS1
		BEQ	EBC2289
		CPY	#MOTS0
		BNE	EBC229
EBC2289		EQU	$
		LSR	ENCLOR,X
		ASL	ENCLOR,X	; J 
		LDA	#3FH 
EBC229		EQU	$
		STA	ENTIM0,X
;
;;		LDA	ENMDD0,X
;;		AND	#11011111B	; Only 1 point check !
;;		STA	ENMOD0,X
;
;
;
;;		LDA	ENHNYS,X
;;		STA	ENYSPD,X
;;		LDA	ENHNXS,X
;;		STA	ENXSPD,X
;
;;		LDA	ENCBFG,X
;;		ORA	#00010000B
;;		STA	ENCBFG,X
		RTS
;;		BRA	EBC220
EBC230		EQU	$
		CMP	#00CH
		BNE	EBC240		; BG 1 belt ?
;					; yes !
		LDA	>ENBG2NO,X
		CMP	#1CH
		BNE	EBC220		; BG 2 nuki ?
;					; yes !
		JSR	BLTCNB		; Belt move !
		LDA	ENCBFG,X
		ORA     #00100000B
		STA	ENCBFG,X
		RTS
;;;;		BRA	EBC220
EBC240		EQU	$
		CMP	#68H
		BCC	EBC228
		CMP	#6CH
		BCS	EBC220		; 4 way belt 
;					; yes !
EBC248		EQU	$
		TAY
;
		JSL	>BLTSUB		; Belt conb sub !
;
		RTS
;
;;		CMP	#08H
;;		BNE	EBC250		; Water ?
;;;
;;		STZ	ENMODE,X
;;		BRA	EBC220
;;EBC250		EQU	$
EBC228		EQU	$
		CMP	#08H
		BNE	EBC220		; Water ?
;					; yes !
		LDA	BGALCKF
		CMP	#04H
		BNE	EBC220		; Nagare ?
;					; yes !
		LDA	#68H+2		; Left way !
		BRA	EBC248
EBC220		EQU	$
		RTS
;========================================
;========================================
;========================================
;========================================
;========================================
;========================================
EBGXRV		EQU	$
		JSR	UNITRD
		BCC	EBX200
;
		LDA	ENBCBT,Y
		ORA	ENCBFG,X
		STA	ENCBFG,X
;
		LDA	HEMODE,X
		AND	#00000111B
		CMP	#00000101B
		BCS	EBX200
;
		LDA	ENHNFG,X
		BEQ	EBX100
;
		JSR	EBX100
		JSR	EBX100
EBX100		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	ENBCRV,Y
		STA	ENXPSL,X
		LDA	ENXPSH,X
		ADC	ENBCRH,Y
		STA	ENXPSH,X   
EBX200		EQU	$
		RTS
;========================================
EBGYRV		EQU	$
		JSR	UNITRD
		BCC	EBY200
;
		LDA	ENBCBT,Y
		ORA	ENCBFG,X
		STA	ENCBFG,X
;
		LDA	HEMODE,X
		AND	#00000111B
		CMP	#00000101B
		BCS	EBY200		; hosei ok ? (heishi kabe check)
					; yes !
		LDA	ENHNFG,X
		BEQ	EBY100
;
		JSR	EBY100
		JSR	EBY100
EBY100		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	ENBCRV,Y
		STA	ENYPSL,X
		LDA	ENYPSH,X
		ADC	ENBCRH,Y
		STA	ENYPSH,X
EBY200		EQU	$
		RTS
;========================================
BLTCNB		EQU	$		;BELTCONBER 
		LDA	BG1VMC		;y pos set
		CLC
		ADC	ENYPSL,X
		STA	ENYPSL,X
		LDA	BG1VMC+1
		ADC	ENYPSH,X
		STA	ENYPSH,X
;
		LDA	BG1HMC		;x pos set
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,X
		LDA	BG1HMC+1
		ADC	ENXPSH,X
		STA	ENXPSH,X
;
		RTS
;=============================================================
;=          UNIT DATA READ                                   = 
;=============================================================
ENBCXL		EQU	$
BC0		EQU	$
;;;			 U   D    L   R
		WORD	08H,08H,002H,00EH ;0 ; normal size
		WORD	08H,08H,0FFFEH,0AH	  ;1 ;small (skhead,OCTSS)
		WORD	08H,08H,01H,0EH	  ;2 ;OCTBL
		WORD	04H,04H,04H,04H	  ;3 ; onry 1 point !
		WORD	04H,04H,0FFFEH,0AH  ;4 ; laser
		WORD	08H,08H,0FFE7H,028H ;5 ; kabemawari heishi 
		WORD	08H,08H,002H,00EH ;6 heishi 
		WORD	08H,08H,0FFF8H,0017H	;7 SEKMV
		WORD	08H,08H,0FFECH,024H	;8 BIGBL
		WORD	08H,08H,0FFFFH,010H	;9 SPARK
		WORD	08H,08H,0FFFFH,010H	;A KUROD
		WORD	08H,08H,0FFF8H,018H	;B CHIBI
		WORD	08H,08H,0FFF8H,018H	;C BIGKO
BC1		EQU	$
		WORD	0008H		;center (hole check)
BC2		EQU	$
		WORD	0003H
ENBCYL		EQU	$
		WORD	06H,14H,0DH,0DH
;;		WORD	08H,10H,0CH,0CH
		WORD	00H,08H,04H,04H
		WORD	01H,0EH,08H,08H
		WORD	04H,04H,04H,04H
		WORD	0FFFEH,0AH,04H,04H
		WORD	0FFE7H,028H,08H,08H
		WORD	03H,10H,0AH,0AH
		WORD	0FFF8H,0019H,08H,08H
		WORD	0FFECH,024H,08H,08H
		WORD	0FFFFH,010H,08H,08H
		WORD	0EH,03H,08H,08H
		WORD	0FFF8H,018H,08H,08H
		WORD	0FFF8H,020H,08H,08H
;
		WORD	000CH
		WORD	0004H
;-- OLD -----
;ENBCXL		EQU	$
;BC0		EQU	$
;		BYTE	08H,08H,002H,00EH ;0 ;night & skelton
;		BYTE	08H,08H,04H,0CH	  ;1 ;small (skhead,OCTSS)
;		BYTE	08H,08H,00H,10H	  ;2 ;OCTBL
;		BYTE	04H,04H,04H,04H	  ;3 ; onry 1 point !
;		BYTE	04H,04H,0FEH,0AH  ;4 ; laser
;		BYTE	08H,08H,0E7H,028H ;5 ; kabemawari heishi 
;BC1		EQU	$
;		BYTE	08H		;center (hole check)
;BC2		EQU	$
;		BYTE	04H
;ENBCXH		EQU	$
;		BYTE	00H,00H,000H,00H
;		BYTE	00H,00H,00H,00H
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0FFH,0
;		BYTE	0,0,0FFH,0
;		BYTE	00H
;		BYTE	00H
;ENBCYL		EQU	$
;		BYTE	08H,10H,0CH,0CH
;		BYTE	00H,08H,04H,04H
;;;              BYTE	0AH,18H,14H,14H
;;;		BYTE	04H,0CH,08H,08H
;		BYTE	00H,10H,08H,08H
;		BYTE	04H,04H,04H,04H
;		BYTE	0FEH,0AH,04H,04H
;		BYTE	0E7H,028H,08H,08H
;		BYTE	0CH
;		BYTE	04H
;ENBCYH		EQU	$
;		BYTE	00H,00H,00H,00H
;		BYTE	00H,00H,00H,00H
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0FFH,0,0,0
;		BYTE	0FFH,0,0,0
;		BYTE	00H
;		BYTE	00H
ENBCBT		EQU	$
		BYTE	08H,04H,02H,01H
ENBCRV		EQU	$
		BYTE	01H,0FFH,01H,0FFH
ENBCRH		EQU	$
		BYTE	00H,0FFH,00H,0FFH
;-------------------------------------------------
UNITRD		EQU	$
		STY	<WORK8
;
		LDA	ENMOD7,X
;;		LDA	ENMOD3,X
		AND	#11110000B
		LSR	A
		LSR	A
		ADC	<WORK8
		ASL	A
		TAY
UNITR2		EQU	$
		MEM16
		REP	#00100000B
		LDA	ENYP2L
		CLC
		ADC	ENBCYL,Y
		STA	<WORK0
		SEC
		SBC	GRRMYL
		CMP	GRRMLY
		BCS	UNR0381B
;
		LDA	ENXP2L
		CLC
		ADC	ENBCXL,Y
		STA	<WORK2
		SEC
		SBC	GRRMXL
		CMP	GRRMLX
UNR0381B	EQU	$
		MEM8
		SEP	#00100000B
;
		BCC	UNR03811
;
		JMP	UNR0381
UNR03811	EQU	$
;
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	ENBCYL,Y
;;		STA	<WORK0
;;		LDA	ENYPSH,X
;;		ADC	ENBCYH,Y
;;		STA     <WORK1
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	ENBCXL,Y
;;		STA	<WORK2
;;		LDA	ENXPSH,X
;;		ADC	ENBCXH,Y
;;		STA	<WORK3
;
;;		LDA	<SLMODE		; danjon 2, chjoo 4
;;		CMP	#MD_djply
;;		BEQ	UNR012
;;;					; chijyou display limit check !
;;		MEM16
;;		REP	#00100000B
;;		LDA	<WORK2
;;		SEC
;;		SBC	GRRMXL
;;		CMP	GRRMLX
;;		BCS	UNR038
;;;
;;		LDA	<WORK0
;;		SEC
;;		SBC	GRRMYL
;;		CMP	GRRMLY
;;		BCS	UNR038
;
;;		MEM16
;;		REP	#00100000B
;;		LDA	<WORK0
;;		SEC
;;		SBC	<SCCV2
;;		SEC
;;		SBC	#0010H
;;		CMP	#00D0H-0010H
;;		BCS	UNR038
;;;
;;		LDA	<WORK2
;;		SEC
;;		SBC	<SCCH2
;;		SEC
;;		SBC	#0008H
;;		CMP	#0100H-0008H
;;		BCS	UNR038	
;;;
;;		MEM8
;;		SEP	#00100000B
;
UNR012		EQU	$
		JSR	BGDTRD
		TAY
;
		LDA	ENMOD5,X
		AND	#00001000B
		BEQ	KBG010
;;		LDA	ENMYNO,X
;;		CMP	#KTOBJ
;;		BNE	KBG010
;- - -katsygi  enemy BG check -(BEAM to onazi)-	
		PHX
		TYX
		LDY	<WORK8
		LDA	>KTCRDT,X
		PLX
		CMP	#04H     ;;+1
		BEQ	KBG00F
		CMP	#01H
		BCC	UNR050B
;
		LDA	UNITNO
		CMP	#10H
		BCC	KTBC10
		CMP	#14H
		BCS	KTBC10		; 45. ?
;					; Yes !
		JSR	EXBCHK
		JMP	UNR055
KTBC10		EQU	$
		JMP	UNR038
;
KBG00F		EQU	$
;;LDA	#01H
		STA	ENATCT,X
UNR050B		EQU	$
		JMP	UNR050
;- - -normal enemy BG check --	
KBG010   	EQU	$
		LDA	ENMOD4,X
		ASL	A
		BPL	ABG010	; BG check tokusyu ?
;					; yes !
		LDA	ENMYNO,X
		CMP	#JFISH
		BEQ	HBG011 
		CMP	#HARI0
		BNE	KBG011
;
HBG011		EQU	$
		CPY	#09H
		BEQ	UNR050E		
KBG011		EQU	$
		CMP	#AYASI
		BNE	YBG011
;
		LDA	ENWRK3,X
		BEQ	KBG0111
		BRA	ABG010
YBG011		EQU	$
		CMP	#PATAR 
		BEQ	KBG0111 	; PATAR !
		CMP	#FISH0
		BEQ	KBG0111 	; FISH !
		CMP	#AMENB
		BNE	ABG010		; Amenbo check !!
;
;;		TYA
KBG0111		EQU	$
		CPY	#08H
		BEQ	UNR050
		CPY	#09H
UNR050E		EQU	$
		BEQ	UNR050
		BRA	UNR038		; Not water -> Atari !
;- - - - - - - - - - - - - - - - -
ABG010		EQU	$
		PHX
		TYX
		LDA	>BGCRDT,X
		PLX
		LDY	<WORK8
		CMP	#00H
;;		PHA
;;		LDY	<WORK8
;;		CMP	#0FFH
;;		BNE	BCR0W0
;;
;;		LDA	ENMYNO,X
;;		CMP	#KTOBJ
;;		BNE	BCR0W0
;;;
;;		LDA	#01H
;;		STA	ENATCT,X
;;		PLA
;;		BRA	UNR050		; test !
;;;
BCR0W0		EQU	$
;;		PLA
;;		CMP	#00H
		BEQ	UNR050		; hit ?
;					; yes !
		LDA	UNITNO
;;		CMP	#00H
;;		BEQ	UNR050
		CMP	#10H
;;		CMP	#18H
		BCC	UNR010
		CMP	#14H
;;		CMP	#1CH
		BCS	UNR010		; 45. ?
;					; Yes !
;;                PHY
		JSR	EXBCHK
		BRA	UNR055
;;		PLY
;;		RTS
UNR010		EQU	$
		CMP	#44H
		BNE	UNR112		; Toge block ?
;					; yes !
		LDA	ENHNFG,X
		BEQ	UNR038		; hanekairi ?
;					; yes ! enemy damege !
		LDA	ENDMPW,X
		BMI	UNR0111		; Magic power ?
;					; no !
		LDA	#04H		; Max ken power !damege !
		JSL	>ENDMST3
;
		LDA	ENFLSH,X
		BEQ	UNR0111
;
		LDA	#80H+19H	; Ken power !! 80H:next ken cros protect !
		STA	ENFLSH,X	; Sugu yarare !!
UNR0111		EQU	$
		BRA	UNR038
;- - - - - - - - - - - - - - - - - - - 
UNR0381		EQU	$		; no.
		JSR	UNR038
		LDA	ENMOD0,X
		ASL	A
		BPL	UNR0382		; BG DATA LIMIT CLEAR !
;
		STZ	ENMODE,X
		CLC
		RTS
UNR0382		EQU	$		; no.
		SEC
		RTS
;- - - --			
UNR112		EQU	$
		CMP	#20H
		BNE	UNR038		; Hole ?
;					; yes !
		LDA	ENMOD7,X
		AND	#01H
		BEQ	UNR038
;
		LDA	ENHNFG,X
		BNE	UNR050		; Hanekairi move ?
UNR038		EQU	$		; no.
		SEC
		MEM8
		SEP	#00100001B
		BRA	UNR055
;;		RTS
;- - - - - - - - - - - - - - - - - - - 
UNR050		EQU	$
		CLC
UNR055		EQU	$
		LDY	<WORK8
		RTS
;============================================
BGDTRD2		EQU	$
		PHB
		PHK
		PLB
		JSR	BGDTR2		;(A) 0:BG1 1:BG2
		PLB
		RTL
;--------------------------------------
BGDTRD		EQU	$
		LDA	ENKAIF,X
BGDTR2		EQU	$
		CMP	#01H
		MEM16
		IDX16
		REP	#00110000B
		STZ	<WORK5
		BCC	BGR002		; Another BG ?
;					; Yes !
		LDA	#1000H
		STA	<WORK5
BGR002		EQU	$
		MEM8
		SEP	#00100000B
;;		LDA	<SLMODE		; danjon 2, chjoo 4
;;		CMP	#MD_djply
		LDA	<DJFLG
		MEM16
		REP	#00100000B
;;		BEQ	BGR004
		BEQ	BGDCIK
;BGR004		EQU	$
		LDA	<WORK2
   		AND	#01FFH
		LSR	A
		LSR	A
		LSR	A
;;;		ASL	A
		STA	<WORK4
		LDA	<WORK0
		AND	#01F8H
		ASL	A
		ASL	A
		ASL	A
;;;		ASL	A
         	CLC
		ADC	<WORK4
		CLC
		ADC	<WORK5
		PHX
		TAX
;;		LDA	>ROOMBF,X
;;		JSL	    >RDCHCK      ; Unit No cross check
		LDA	>READBF,X
		STA	UNITNO
		PLX
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;---------------------------------------
BGDCIK		EQU	$		; chijoo BG no set ----> A
		MEM16
		LDA	<WORK2		; x-pos / 8
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK2
;
		IDX8
		SEP	#00010000B
		PHX
		PHY
;
                JSL     >GDCHCK
;
		MEM8
		IDX8
		SEP	#00110000B
;
		STA	UNITNO
;
		PLY
		PLX
		RTS	
;;---------------------------------------
;BGDCIK          EQU     $               ; chijoo BG no set ----> A
;                MEM16
;                IDX16
;                PHX
;                PHY
;;;;;;;;;;               LDA     <WORK0          ; y-pos / 8
;;;;;;;;;;               LSR     A
;;;;;;;;;;               LSR     A
;;;;;;;;;;               LSR     A
;;;;;;;;;;               STA     <WORK0
;                LDA     <WORK2          ; x-pos / 8
;                LSR     A
;                LSR     A
;                LSR     A
;                STA     <WORK2
;                MEM8
;                IDX8
;                SEP     #00110000B
;                JSL     >EVCHCKE                ; chijoo
;                MEM8
;                IDX16
;                REP     #00010000B
;                STA     UNITNO
;                STZ     UNITNO+1
;                PLY
;                PLX
;                MEM8
;                IDX8
;                SEP     #00110000B
;                RTS
;		
;============================================
;============================================
ENSKDT		EQU	$   		; Saka hosei data. 
		BYTE	07,06,05,04,03,02,01,00
		BYTE	00,01,02,03,04,05,06,07
		BYTE	00,01,02,03,04,05,06,07
		BYTE	07,06,05,04,03,02,01,00
;-------------------------------------------------
EXBCHK2		EQU	$
		PHB
		PHK
		PLB
		JSR	EXBCHK
		PLB
;
		RTL
;-----------------------------------------------
EXBCHK		EQU	$
;;			MEM16
;;			REP		#00100000B
;;			LDY		#00H
;;			LDA		UNITNO
;;			CMP		#10F1H
;;			BEQ		EXB010
;;			INY
;;			CMP		#08F0H
;;			BEQ		EXB010
;;			INY
;;			CMP		#88F0H
;;			BEQ     EXB010
;;			INY
;;			CMP		#0C8F0H
;;			BNE		BGRRTS
;;EXB010		EQU		$	
;;			STY		<WORK6
;;			MEM8
;;			SEP		#00100000B
		LDA	<WORK0
		AND	#00000111B
		STA	<WORK4
		LDA	<WORK2
		AND	#00000111B
		STA	<WORK5
;
		LDA	UNITNO
		SEC
		SBC	#10H
;;;;;		TAY
		STA	<WORK6
;;;;;		TYA
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	<WORK5
		TAY
		LDA	<WORK6
		CMP	#02H
		BCC	EXB060
		LDA	<WORK4
		CMP	ENSKDT,Y
		BRA	EXB070
EXB060		EQU	$
		LDA	ENSKDT,Y
		CMP	<WORK4
EXB070		EQU	$
		RTS
;LBGRRTS		EQU	$
;L		CLC
;L;;			MEM8
;L;;			SEP		#00100000B
;L		RTS             
;
;';+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;'ENCLCK		EQU	$
;';;		LDA	<GAMEMD
;';;		BNE	ENCLA0		; Scroll ?
;';
;'		LDA	ENXPSH,X	; no!
;'		AND	#11111110B
;'		CMP	NOWRMX
;'		BNE	ENCL80
;'		LDA	ENYPSH,X
;'		AND	#11111110B
;'		CMP     NOWRMY
;'		BEQ	ENCL90
;'ENCL80		EQU	$
;'		STZ	ENMODE,X
;'ENCL90		EQU	$
;';;		RTS
;';- - - - - - - - - - - - - - - - - - - -
;'ENCLA0		EQU	$
;';;		LDA	ENDSPL,X
;';;		BNE	ENCL80
;'ENCLA8		EQU	$
;'		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%          Move calc   									 %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ENMVCL		EQU	$
;;;;;		LDA	ENHNFG,X
;;;;;		BNE	ENMC00
;
		JSR	ENXCLC
		JSR	ENYCLC
ENMC00		EQU	$
		RTS
;
ENXCLC		EQU	$
		TXA
		CLC
		ADC	#10H
		TAX
		JSR	ENYCLC
		LDX	ENINDX
		    RTS
;============================================
ENYCLC		EQU	    $
		LDA	ENYSPD,X
		BEQ	ENYRTS
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENYSDR,X
		STA	ENYSDR,X
;
		LDA	ENYSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDY	#00H
		PLP
		BPL	ENCY60
;
		ORA	#11110000B
		DEY
ENCY60		EQU	$
		ADC	ENYPSL,X
		STA	ENYPSL,X
;
		TYA
		ADC	ENYPSH,X
		STA	ENYPSH,X
ENYRTS		EQU	$
		RTS
;============================================
ENZCLC		EQU	    $
		LDA	ENZSPD,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENZSDR,X
		STA	ENZSDR,X
;
		LDA	ENZSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		PLP
		BPL	ENCZ60
;
		ORA	#11110000B
ENCZ60		EQU	$
		ADC	ENZPSL,X
		STA	ENZPSL,X
;
		RTS
;			
;-----------------------------------------
PS2000		EQU	$
		STZ	<WORK0
		RTS
;
PSERC2		EQU	$
		STA	<WORK1
		CMP	#00H
		BEQ	PS2000
		PHX
		PHY
;
		JSR	    EPYCHK
		STY	<WORK2
;
		LDA	<WORKE
		BPL	PS00
		EOR	#0FFH
		INC	A
PS00		EQU	$
		STA	<WORKC
;
		JSR	EPXCHK
		STY	<WORK3
;
		LDA	<WORKF
		BPL	PS10
		EOR	#0FFH
		INC	A
PS10		EQU	$
		STA	<WORKD
;
		LDY	#00H
		LDA	<WORKD
		CMP	<WORKC
		BCS	PS20
		INY
		PHA
		LDA	<WORKC
		STA	<WORKD
		PLA
		STA	<WORKC
PS20		EQU	$
		STZ	<WORKB
		STZ	<WORK0
;
		LDX	<WORK1		; Base speed
PS30		EQU	$
		LDA	<WORKB
		CLC
		ADC	<WORKC
		CMP	<WORKD
		BCC	PS40
;
		SBC	<WORKD
		INC	<WORK0
PS40		EQU	$
		STA	<WORKB
		DEX
		BNE	PS30
;
		TYA
		BEQ	PS50
;
		LDA	<WORK0
		PHA
		LDA	<WORK1
		STA	<WORK0
		PLA
		STA	<WORK1
PS50		EQU	$
		LDA	<WORK0
		LDY	<WORK2
		BEQ	PS60
		EOR	#0FFH
 		INC	A
		STA	<WORK0
PS60		EQU	$
		LDA	<WORK1
		LDY	<WORK3
		BEQ	PS70
		EOR	#0FFH
		INC	A
		STA	<WORK1
PS70		EQU	$
		PLY
		PLX
		RTS
;----------------------------
PSERCH		EQU	$
		JSR	PSERC2
;----------------------------
PS80		EQU	$
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
		RTS
;=====================================
PSERCHL		EQU	$
		PHB
		PHK
		PLB
		JSR	PSERCH
		PLB
		RTL
;=====================================
PSERC2L 	EQU	$
		PHB
		PHK
		PLB
		JSR	PSERC2
		PLB
		RTL
;=====================================
ESERCHL		EQU	$
		PHB
		PHK
		PLB
		JSR	ESERCH
		PLB
		RTL
;- - - - - - - - - - - - - - - - - - - -
ESC090		EQU	$
		STZ	<WORK0
		RTS
;
ESERCH		EQU	$
		STA	<WORK1
		CMP	#00H
		BEQ	ESC090
		PHX
		PHY
;
		JSR	EEYCHK
		STY	<WORK2
;
		LDA	<WORKE
		BPL	ES00
		EOR	#0FFH
		INC	A
ES00		EQU	$
		STA	<WORKC
;
		JSR	EEXCHK
		STY	<WORK3
;
		LDA	<WORKF
		BPL	ES10
		EOR	#0FFH
		INC	A
ES10		EQU	$
		STA	<WORKD
;
		LDY	#00H
		LDA	<WORKD
		CMP	<WORKC
		BCS	ES20
		INY
		PHA
		LDA	<WORKC
		STA	<WORKD
		PLA
		STA	<WORKC
ES20		EQU	$
		STZ	<WORKB
		STZ	<WORK0
;
		LDX	<WORK1		; Base speed
ES30		EQU	$
		LDA	<WORKB
		CLC
		ADC	<WORKC
		CMP	<WORKD
		BCC	ES40
;
		SBC	<WORKD
		INC	<WORK0
ES40		EQU	$
		STA	<WORKB
		DEX
		BNE	ES30
;
		TYA
		BEQ	ES50
;
		LDA	<WORK0
		PHA
		LDA	<WORK1
		STA	<WORK0
		PLA
		STA	<WORK1
ES50		EQU	$
		LDA	<WORK0
		LDY	<WORK2
		BEQ	ES60
		EOR	#0FFH
 		INC	A
		STA	<WORK0
ES60		EQU	$
		LDA	<WORK1
		LDY	<WORK3
		BEQ	ES70
		EOR	#0FFH
		INC	A
		STA	<WORK1
ES70		EQU	$
		PLY
		PLX
		RTS
;================================================================
EPXYCK2		EQU	$
		JSR	EPXYCK
		RTL
;- - - - - - - - - - - - - - - - -
EPXYCK		EQU	$
		JSR	EPXCHK
		STY	<WORK0
		JSR	EPYCHK
		STY	<WORK1
		LDA	<WORKE
		BPL	EXY000
		EOR	#0FFH
		INC	A
EXY000		EQU	$
		STA	ENHELP
		LDA	<WORKF
		BPL	EXY010
		EOR	#0FFH
		INC	A
EXY010		EQU	$
		CMP	ENHELP
		BCC	EXY020
		LDY	<WORK0
		RTS
EXY020		EQU	$
		LDA	<WORK1
		INC	A
		INC	A
		TAY
		RTS
;================================================================
EPXCHK2		EQU	$
		JSR	EPXCHK
		RTL
;- - - - -
EPXCHK		EQU	$
		LDY	#00H
		LDA	<PLXPS1
		SEC
		SBC	ENXPSL,X
		STA	    <WORKF
		LDA	<PLXPS0
		SBC	ENXPSH,X
		BPL	EPX010
		INY
EPX010		EQU	$
		RTS
;
;=================================================================
EPYCHK2		EQU	$
		JSR	EPYCHK
		RTL
;- - - - - - - - - - - - - - -
EPYCHK		EQU	$
		LDY	#00H
		LDA	<PLYPS1
		CLC
		ADC	#08H
		PHP
         	CLC
		ADC	ENZPSL,X
		PHP
		SEC
		SBC	ENYPSL,X
		STA	<WORKE
		LDA	<PLYPS0
		SBC	ENYPSH,X
		PLP
		ADC	#00H
		PLP
		ADC	#00H
		BPL	EPY010
		INY
EPY010		EQU	$
		RTS
;================================================================
EEXCHK		EQU	$
		LDY	#00H
		LDA	<WORK4
		SEC
		SBC	ENXPSL,X
		STA	<WORKF
		LDA	<WORK5
		SBC	ENXPSH,X
		BPL	EEX010
		INY
EEX010		EQU	$
		RTS
;================================================================
EEYCHK		EQU	$   
        	LDY	#00H
		LDA	<WORK6
		SEC
		SBC	ENYPSL,X
		STA	<WORKE
		LDA	<WORK7
		SBC	ENYPSH,X
		BPL	EEY010
		INY
EEY010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - -
EEXYCKL		EQU	$
		PHB
		PHK
		PLB
;
		JSR	EEXCHK
		STY	<WORK0
		JSR	EEYCHK
		STY	<WORK1
		LDA	<WORKE
		BPL	EEE000
		EOR	#0FFH
		INC	A
EEE000		EQU	$
		STA	ENHELP
		LDA	<WORKF
		BPL	EEE010
		EOR	#0FFH
		INC	A
EEE010		EQU	$
		CMP	ENHELP
		BCC	EEE020
		LDY	<WORK0
;
		PLB
		RTL
;
EEE020		EQU	$
		LDA	<WORK1
		INC	A
		INC	A
		TAY
;
		PLB
		RTL
;========================================================
CRKNKNL		EQU	$
		PHB
		PHK
		PLB
		JSR	CRKNKN
		PLB
		RTL
;--------------------------------------------
ENHNDT		EQU	$
		BYTE	0FH,0FH,18H,0FH,0FH,13H,0FH,0FH
PLHNDT		EQU	$
		BYTE	06H,06H,06H,0CH,06H,06H,06H,0FH
CRKNKN		EQU	$
		LDA	<PLBGCKF
		CMP	ENKAIF,X
		BNE	CKK070N
;;			LDA		ENCTFG,X
;;			BEQ		CKK070		; enemy cut ?
;								; yes !
;		TXA
;		EOR	<FRCNT
;		AND	#01H
		LDA	<HANEFG
;;		ORA	ENHNFG,X
;;		ORA	ENDSPL,X
;;		ORA	ENFLSH,X
		ORA	<DIEFG		;  player damage check !
CKK070N		EQU	$
		BNE	CKK070
;
		LDA	ENFLSH,X
		BMI	CKK070
;
		JSR	EKNCRS
;
		LDA	AITMBT1
		AND	#00010000B
		BNE	CKK080J		; Ami ?
;					; no !
		LDA	<KNCRYP
		CMP	#80H
		BEQ	CKK080J		; player cut ?
;								; yes !
		JSR	PKNCRS
;
		LDA	<KENMD
		BMI	CKK060 		; Spin ken not check !
;
		JSR	CROJCK
		BCC	CKK060
;
		LDA	ENMYNO,X
		CMP	#TEKU0
		BEQ	CKKK000		; Tekkyuu not hane !
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	ENHNDT,Y
		STA	ENHNFG,X
CKKK000		EQU	$
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	PLHNDT,Y
		STA	<HANEFG
;
;;;;		STZ	ENCTCT,X
		LDA	#HPW15
;;		LDY	ENSTAT,X
;;		CPY	#01H
;;		BNE	CKK022
;;		LDA	#HPW10
CKK022		EQU	$
		LDY	<KENMD
		CPY	#09H
		BPL	CKK023
  		LDA	#HPW20
CKK023		EQU	$
		JSR	PSERC2
		LDA	<WORK0
		EOR	#0FFH
		INC	A
;;;		STA	ENYSPD,X
		STA	ENHNYS,X
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	ENHNXS,X
;;;		STA	ENXSPD,X
;
;;		LDA	#HPW05
;;		LDY	ENSTAT,X
;;		CPY	#01H
;;		BNE	CKK030		; Special atack ?
		LDA	#HPW10      ; yes !
CKK030		EQU	$
		LDY	<KENMD
		CPY	#09H
		BPL	CKK040
		LDA	#HPW05
CKK040		EQU	$
PLHNFS          EQU	$
		JSR	PLHNST
;;			JSR		PSERC2
;;			LDA		WORK0
;;			STA		PLYSPD
;;			LDA		WORK1
;;			STA		PLXSPD
;	
;;;;;;;;		STZ	ENSTAT,X	; normal move return !
		JSR	FLSHST		; Kakiiin !!!
		LDA	#10H+80H
		STA	<HANIFG		; Ken furifuri
;;		PLA
;;		PLA
CKK070		EQU	$
		RTS
;------- Player ken vs enemy body ----
CKK060		EQU	$
;;		TXA
;;		EOR	<FRCNT
;;		LSR	A
;;		BCS	CKK080J
;
		JSR	ENCRST
		JSR	CROJCK
		BCS	CKK065
;;;			BCC	    CKK080
CKK080J		EQU	$
		JMP	>CKK080
;
CKK065		EQU	$
;;;;		STZ	ENSTAT,X
ENDMGE		EQU	$
		LDA	ENMYNO,X
		CMP	#SHSAI
		BEQ	PIPIST
		CMP	#NYORO
		BNE	PIPISTF
;
		LDA	>ITMTBL6
		CMP	#03H+1
		BCC	PIPIST
PIPISTF		EQU	$
		CMP	#ZOOL2
		BEQ	PIPIS0
		CMP	#ZOOL1
		BNE	EDS010		; TEST !
;
PIPIS0		EQU	$		; Biri biri !
		LDA	ENTIM0,X
		BEQ	EDS010
;
PIPIST		EQU	$		; Biri biri !
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	EDS010		; Moving ?
;					; yes !
		LDA	PYFLASH
		BNE	PPS010
;
		LDA	#40H
		STA	ENTIM1,X
		STA	PIPIFG
		JSR	PLFLST
;;		PLA
;;		PLA
PPS010		EQU	$
		RTS
;
EDS010		EQU	$
;;                LDA	#20H
;;		STA	ENFLSH,X
;;		LDA	#1FH
;;		STA	ENHNFG,X
;;;		    LDA		#20H
;;;			JSR		PSERC2
;;		LDA	#HPW40
;;		LDA	#HPW20
		LDA	#HPW60
		LDY	<KENMD
		CPY	#09H
		BMI	CKK068
;;		LSR	A
		LDA	#HPW40
CKK068		EQU	$
		JSR	PSERC2
		LDA	<WORK0
		EOR	#0FFH
		INC	A
;;;		STA	ENYSPD,X
		STA	ENHNYS,X
		LDA	<WORK1
		EOR	#0FFH
		INC	A
;;;		STA	ENXSPD,X
		STA	ENHNXS,X
;
;;		PLA
;;		PLA
;
		JSL	>ENDMST
		RTS
;======================================================
ALENDM		EQU	$		; Mahou damage !
		LDA	BMMODE,X
		STA	ENHELP 	
;
		LDX	#ENNO-1
AED010		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BCC	AED020
;
		LDA	ENNOCR,X
		ORA	ENDSPL,X
		BNE	AED020
;
		LDA	ENHELP 
		JSL	>ENDMST22	; Mujyouken damage !!19238

AED020		EQU	$
		DEX
		BPL	AED010
		RTL
;======================================================
BMHTNO		EQU	$   ;-1
;;;			FF 00 01 02 03 04 05 06 07 
		HEX	06,01,0B,00,00,00,00,08,00
;;;			08 09 0A 0B 0C 0D 0E 0F
		HEX	06,00,0C,01,00,00,00,00
;;;			10 01 02 03 04 05 06 07 
		HEX	01,00,00,00,00,00,00,0E
;;;			18 09 0A 0B 0C 0D 0E,0F 
		HEX	0D,00,00,0F,00,00,07,01
;;;			20 01 02 03 04 05 06 07
		HEX	01,01,01,01,01,01,01,01 
;;;			28 09 0A 0B 0C 0D 0E,0F 
		HEX	01,01,01,01,01,01,0B,00
;;;			30 01 02 03 04 05 06 07
		HEX	01,01,01,01,01,01,01,01 
;=============================================================
;;BM00		WORD	BEAM1MV		;1 Ken beam 
;;BM01		WORD	BEAM2MV		;2
;;BM02		WORD	BEAM3MV		;3
;;;;;;;;;;;;;BM03		WORD	BOMBRMV		;
;;B1FL		WORD	BEAM1FL         ;4 beam 1 flash
;;BME0		WORD	BURN1MV         ;5 bumeran
;;HBA0		WORD	HBAN1MV		;6 bumeran hibana
;;BOM0		WORD	BOMBMOV		;7 bomb
;;BOM1		WORD	BMKRMOV		;8 bomb
;;YAM0		WORD	YAMOVE0		;9 ya
;;YAM1		WORD	YAENDMV		;A ya end move
;;DTM0		WORD	DTMOVE0		;B dot beam (ice) move 0
;DTM2		WORD	JPKNMV0		;C new spining beam ! 91/9/28 AM 3:00
;;;;DTM3		WORD	DTMOVE2		;D dot beam move 2
;;;;DTM4		WORD	DTMOVE3		;E dot beam move 3
;;;;DTM5		WORD	DTMOVE4		;F dot beam move (fire tame magic)
;;;;DTM6		WORD	DTMOVE5		;10 dot beam move (ice tame magic)
;;DTM1		WORD	DTENDM0		;11 dot beam (ice) end 0
;;;;DTE0		WORD	DTENDM1		;12 dot beam (fire tame magic) end 1
;;ICFL		WORD	ICEFLMV		;13 ice beam flash
;;;;OPMV		WORD	ONPMOVE		;14 onpu move
;;WTM0		WORD	WATJMD0		;15 water jump move
;;HBA1		WORD	HBAN2MV		;16 scop hibana move
;;SCPM		WORD	SCOPMOV		;17 scop suna move
;;SDM0		WORD	SDERMOV		;18 special magic (sunder)
;;SDM1		WORD	SPBOMOV		;19 special magic (bomber)
;;KANA		WORD	KONAMOV		;1a kona maki move
;;HBA2		WORD	HBAN3MV		;1b ken hibana move
;;SDM2		WORD	JISNMOV		;1c special magic (jishin)
;;YURE		WORD	YUREMOV		;1d dash atari yure move
;;DAKM		WORD	KMRIMOV		;1e dash kemuri move
;;FTS0		WORD	FOTSMOV		;1f foot shot move
;;FUTN		WORD	FUTONST		;20 futon set
;;IBIK		WORD	IBIKIST		;21 ibiki set
;;TAKA		WORD	TAKARST		;22 takara set
;;TTKM		WORD	TORAKST		;23 toraiforse kemuri
;;HAKA		WORD	HAKAMOV		;24 haka move 
;;WTM1		WORD	WATJMD1		;25 water move 
;;KNTN		WORD	KENFLAH		;26 ken tenmetsu move 
;;WPMV		WORD	WARPMOV		;27 okarina warp move 
;;TTNG		WORD	TAKNAGE		;28 takara nage move
;;TTRK		WORD	TAKDOWN		;29 takara down move
;;KNSM		WORD	KNSOMON		;2A ken soromon move
;;KNEN		WORD	ENKNMV		;2B ken soromon en move
;;BOAL		WORD	BOALMOV		;2C boal move
;;BOA1		WORD	BALEDMV		;2D boal shometsu move
;;BOA2		WORD	BALBKMV		;2E boal bakuhatsu move
;;KANT		WORD	KNTEAMV		;2F kantera fire move
;;SBAR		WORD	SBARIMV		;30 soromon bariya move
;;BREN		WORD	BRENMV		;31 soromon bariya en move
;;;
;;BHMV		WORD	BKHMOVE		;32 kabe bomb hahen move
;;KBDM		WORD	KBDMMOV		;33 kabe bomb move
;;RDDM		WORD	RDDMMOV		;34 rod bomb move
;;TKFL		WORD	TKKNMV		;35 takara ken flash move
;=============================================================
ENDMST2		EQU	$
		LDY	ENFLSH,X
		BPL	ED2001		; Ken damage on ?
;					; yes ! Ken yuusen !
		RTL
;
ENDMST22	EQU	$
ED2001		EQU	$
		PHX
		TAX			; (A):BMNO
;;		CMP	#01H
;;		BNE	EDS210		; Ken beam ?
;					; yes !
;;		LDA	>ITMTBL6
;;		TAX
;;		LDA	>KNHTNO-1,X	; Now ken power !!
;;		CMP	#04H
;;		BNE	EDS208
;;		DEC	A
;;EDS208		EQU	$
;;		BRA	EDS220
;;EDS210		EQU	$
		LDA	>BMHTNO,X
;;EDS220		EQU	$
		PLX
		CMP	#06H
		BNE	ENDMST3
;
		PHA
		LDA	>ITEMR01
		CMP	#03H
		PLA
		BCC	ENDMST3
;
		LDA	ENMYNO,X
		CMP	#GANO2
		BNE	DMS310
;
		LDA	#20H
		STA	ENTIM3,X
;
DMS310		EQU	$
		LDA	#09H		; Gin no ya !
ENDMST3		EQU	$
		CMP	#0FH
		BNE	DS3000		; Zishin ?
;					; yes !
		LDY	ENZPSL,X
		BEQ	DS3000		; Enemy jump ?
;					; yes !
		RTL
;
DS3000		EQU	$
		CMP	#00H	; Buumeran !
		BEQ	DS3001		
		CMP	#07H	; Fuck shot !
		BNE	DS3002
DS3001		EQU	$
		JSL	>DS3002
;
		LDA	ENDMPW,X
		BNE	DS3009	;Enemy not damage ?
;				; yes ! flash set !
		LDA	FLMODE
		BNE	DS3009 
;
		LDA	#05H
		STA	FLMODE
;
		LDY	ENHELP2
		LDA	BMXPSL,Y
		ADC	#4
		STA	FLXPOS
		LDA	BMYPSL,Y
		STA	FLYPOS
;
		LDA	<PLBGCKF
		STA	FLCLOR
;
		STZ	SOUND2	; Yuusen !
;
		LDA	#05H
;;		STA	SOUND2	; (S)
		JSL	>SDLRE2
DS3009		EQU	$
		RTL
;
;
;
;---------------------------------------------------
DS3002		EQU	$
		STA	ITHTN0		; kinds of player atatck !
;
;;		LDA	#10H		; for beam
		TAY
		LDA	#00H+20H	; (A): ENFLSH times !
;
		CPY	#08H
		BNE	ED3010		; Bakudan ?
;					; yes !
		LDA	#00H+35H
ED3010		EQU	$
		BRA	ENDS01
;-----------------------------------------------------
KNHTNO		EQU	$
		HEX	1,2,3,4		 ;player ken power table !
		HEX	2,3,4,5
		HEX	1,1,2,3
;- - - - - - - - - - - - - - - - - - - - - -
ENDMST1		EQU	$		; for ken
ENDMST		EQU	$		; for ken
		LDA	ENMOD2,X
		AND	#01000000B
		BEQ	KDS001		; In life ?
;;		BNE	ENDS00		; In life ?
		RTL
KDS001		EQU	$
		LDA	DASHFG
		STA	>ENDSFG,X	; Dash ken -> Enemy fail item nothing !
;
		PHX
;// 03.04.10 //		LDA	KENPNT
		LDA	>ITMTBL6
		DEC	A
		LDX	DASHFG
;;		BEQ	KDS010
		BNE	KDS012
		BRA	KDS010
KDS00C		EQU	$
		ORA	#04H
		BRA	KDS012
KDS010		EQU	$
		LDX	<KENMD
		BMI	KDS00C
		CPX	#09H
		BMI	KDS012 
		ORA	#08H
KDS012		EQU	$
		TAX
		LDA	>KNHTNO,X
		STA	ITHTN0		; kinds of player atatck !
;
                LDA     AITMBT
                AND     #00001010B
                BEQ     KDS013          ; hanmer ?
;
		LDA	#03H
;;		LDA	#01H
		STA	ITHTN0		; kinds of player atatck !
KDS013		EQU	$
;;
		LDA	#04H
		STA	KNSTOP
		PLX
		LDA	#10H
		STA	<HANIFG		; Ken furifuri
;;		LDA	#20H
		LDA	#80H+1DH
ENDS01		EQU	$
		STA	<WORK0
		STZ	ITHTN0+1
;
		LDA	ENMOD2,X
		AND	#01000000B
		BNE	ENDSRTL		; In life ?
;
		LDA	#00H
		XBA
		LDA	ENMYNO,X
		CMP	#ITEMD
		BCC	ENDSA2		;damege on enemy ?
;		
ENDSRTL		EQU	$			
		RTL
;- - - - - - - - - - - - - - - - - - - - - - - -
ENDSA2		EQU	$		; YES !
		MEM16
		REP	#20H
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ORA	ITHTN0  
		PHX
		IDX16
		REP	#10H
		TAX
		MEM8
		SEP	#20H
		LDA	>EDMGDT,X
		STA	<WORK2		; 0~7	
;
		IDX8
		SEP	#10H
;
		LDA	ITHTN0
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK2
		TAX
		LDA	>ATCKDT,X
		PLX
ENDMST4		EQU	$
		CMP	ENDMPW,X
		BCC	ED400 		; After power bigger ?
;					; yes ! next set !
		STA	ENDMPW,X
ED400 		EQU	$
		CMP	#00H
		BNE	ENDSFA
;
		LDA	ENMOD7,X
		AND	#00000100B
		BNE	ENDSFF		; Damege=0 demo hanekairi !
;
		STZ	KNSTOP
		BRA	ENDS113	;00
;		
;;		LDA	ENDMPW,X
;;		BEQ	ENDS00		;damage ?
ENDSFA		EQU	$
		CMP	#0FEH
		BCC	ENDSFE		; ice or stop ?
;					; yes !
		LDA	ENMODE,X
		CMP	#EICE
		BEQ	ENDS113 ;00		; alredy stop ?
;					; no !
;;		BRA	ENDSFF
;- - - - - - - - -
ENDSFE		EQU	$
;;		LDA	ENMOD2,X
;;		AND	#01000000B
;;		BNE	ENDS00		; In life ?
;					; yes !
;;                LDA	#20H
		LDA	<WORK0		; 80-> ken hit !
		STA	ENFLSH,X
;
		LDA	ENMYNO,X
		CMP	#YATAM
		BNE	ENDSEDC
;
		STZ	ENFLSH,X
;
YAFLST		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#05H
;;		STA	SOUND2	;(S)
		LDA	#05H
		JSL	>SDLRE2	;(S)
;
		JSR	ENFLST
		JSL	>EFLSST
		RTL
;
;;;		BRA	ENDSFEC
ENDSEDC		EQU	$
		CMP	#MOTSB
		BNE	ENDSFEC
;	
		LDA	ENWRK2,X
		CMP	#03H
		BCC	ENDSFF
ENDSFEC		EQU	$
		LDY	#21H
;
		LDA	ENMOD7,X
		AND	#00000010B
		BNE	ENDSFEE		; Boss ?
;					; yes !
		LDY	#08H		; sound check !
;
		LDA	ENMOD4,X
		AND	#00010000B
		BEQ	ENDSFEE		; Big enemy ?
;					; yes !
		LDY	#1CH
ENDSFEE		EQU	$
		STY	<WORK1
;LL		TYA
;LL		JSL	>SDLRE3	;(S)
;
		JSL	>SDLRCE
		ORA	<WORK1
		STA	SOUND3	;(S)
ENDSFF		EQU	$
		LDY	ENMYNO,X
;
		LDA	#14H	; eye spin time !
;
		CPY	#HAYAB
		BEQ	ENDWEF
;
		LDA	#0FH	; Long
;
		CPY	#NOMOS
		BEQ	ENDWEE
		CPY	#HAYAM
;;		BEQ	ENDWEE
;;		CPY	#MOTS0
;;		BEQ	ENDWEE
;;		CPY	#MOTS1
		BNE	ENDWEF
ENDWEE		EQU	$
		LDA	#0BH	; short
ENDWEF		EQU	$
;;		LDA	#1FH
		STA	ENHNFG,X
;
ENDS00		EQU	$
		RTL
ENDS113		EQU	$
		STZ	ENDMPW,X
		RTS
;---------------------------------------------------------------------
ENDMS0		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BCC	ENDS0R
;
		STA	ENHELP
;
		LDA	ENDMPW,X
		CMP	#0FDH
		BNE	ENFS010		; Fire beam moeru ? (miira otoko)
;
		STZ	ENDMPW,X
;
;;		JSL	>SDLRCE
;;		ORA	#09H
;;		STA	SOUND3	;(S)
		LDA	#09H
		JSL	>SDLRE2	;(S)
;
		LDA	#EFIRE		; yes !
		STA	ENMODE,X
		LDA	#070H
		STA	ENTIM0,X
		LDA	ENMOD0,X
		INC	A
		INC	A
		STA	ENMOD0,X
		STZ	ENDMPW,X
ENDS0R		EQU	$
		RTS
;
ENFS010		EQU	$
		CMP	#0FBH
;;		CMP	#0FEH
		BCC	EDS001		; FE:Ice FF:Stop
;
		STZ	ENDMPW,X
;
		STA	<WORK0
;
                LDY     ENMODE,X
                CPY     #EICE
                BEQ     ENDS0R  ;F
;
		LDY	#00H
		CMP	#0FEH
		BNE	ENFS011
		INY
ENFS011		EQU	$
		TYA
		STA	>ENICMD,X	; 0:Stop FF:Ice
;;		STA	ENWRK2,X	; 0:Stop FF:Ice
;
		BEQ	EDS0RR
;
		LDA	ENMOD5,X	;cach & shot !
		ORA	#00001000B
		STA	ENMOD5,X
;
		ASL	ENMOD4,X
		LSR	ENMOD4,X	; floor check set !
EDS0RR		EQU	$
                LDA     #EICE
                STA     ENMODE,X
                LDA     #40H
                STA     ENTIM0,X
;
		LDA	<WORK0
		CLC
		ADC	#05H
		TAY
		LDA	ESTPTM,Y
;;		LDA	#0FFH
		STA	ENSTTM,X
                JMP     ENDS0F
; - - - - - - - - - - - - - - - - - - - - - - -
ESTPTM		EQU	$
;;;;			FB FC fe fd FF
		HEX	20,80,00,00,FF
; - - - - - - - - - - - - - - - - - - - - - - -
EDS001		EQU	$
		LDA	ENLIFE,X
		STA	<WORK0
		SEC
		SBC	ENDMPW,X 
		STA	ENLIFE,X
		STZ	ENDMPW,X
		BEQ	ENDS002
		BCS	ENDS0F
;;		LDA	<WORK0
;;		BMI	ENDS90
;;		EOR	ENLIFE,X
;;		BPL	ENDS90
;					; !
ENDS002		EQU	$
		LDA	KAGIFG,X
		BNE	DSCK10
;
		LDA	ENMODE,X
		CMP	#EICE
		BNE	DSCK0C
;
		LDA	#03H
		STA	KAGIFG,X
DSCK0C		EQU	$
		LDA	>ENDSFG,X
		BEQ	DSCK10
;
		LDA	#00H
		STA	>ENDSFG,X
;
		STZ	ENMOD4,X
DSCK10		EQU	$
;;		JSL	>SDLRCE
		LDY	ENMYNO,X
		CPY	#YATAM
		BEQ	YAFL20
;;		BNE	YAFL10
;;;
;;		ORA	#05H
;;		STA	SOUND2	;(S)
;;		BRA	YAFL20
YAFL10		EQU	$
;;		ORA	#09H
;;		STA	SOUND3	;(S)
;
		LDA	#09H
		JSL	>SDLRE3	;(S)
;
YAFL20		EQU	$
;;		LDA	ENMYNO,X
		CPY	#BARI1
		BNE	EDS00B
;
;;		PHA
		PHX
		LDX	<MPDTNO
		LDA	>GNDTBL,X
		ORA	#01000000B
		STA	>GNDTBL,X
		PLX
;;		PLA
;
EDS00B		EQU	$
		TYA
		CMP	#KTOBJ
		BNE	ENDS0D		; katsugu obj ?
		LDY	ENWRK2,X	; yes !
		CPY	#02H
		BNE	ENDS0F		; kusa ?
;					; yes ! break !
		JMP	KTOSUB
ENDS0D		EQU	$
		PHA
		LDA	#EFAIL
		STA	ENMODE,X
		PLA
;
		CMP	#OCTAM
		BNE	ENDS10		;
;
OCTAMFL		EQU	$
		LDA	#EFAIL
		STA	ENMODE,X
		LDA	#1FH
		STA	ENTIM0,X
;;		LDA	ENMOD0,X
;;		CLC
;;		ADC	#03H
;;		STA	ENMOD0,X
		JSR	S3MOD0_X
;;		RTL
ENDS0F		EQU	$
		RTS
ENDS10		EQU	$
		CMP	#MOTSB
		BNE	ENDS17
;
		JSL	>ENALFL		; Another enemy fail !
;
		LDA	#0FFH
		STA	ENTIM0,X
		JMP	BSSDST
ENDS17		EQU	$
		CMP	#KAMBS
		BNE	EFSFF0
;
		JMP	KAMBSFS
;
EFSFF0		EQU	$
		CMP	#KAMBR
		BEQ	EFS000
		CMP	#KAMBB
		BNE	EFS001
;
EFS000		EQU	$
		JMP	KAMBRFS
;
EFS001		EQU	$
		CMP	#NOMOS
		BEQ	NMFLST
		CMP	#RANEM
		BEQ	RNFLST
		CMP	#HAYAB
		BEQ	HBFLST
;;		CMP	#PATAR
;;		BEQ	SHFLST
		CMP	#SHSAI
		BNE	SHFLSTN
		JMP	SHFLST
SHFLSTN		EQU	$
;;		CMP	#MOTSB
;;		BEQ	SHFLST
;;		CMP	#ZORAB
;;		BEQ	SHFLST
;;		CMP	#BIGKO
;;		BEQ	SHFLST
		CMP	#ZOOL1
		BEQ	ZLFLST
		CMP	#OCTBL
		BNE	ENDS20		; 
;	
OCTBLFS		EQU	$
		STZ	ENFLSH,X
;
		LDA	#0FH
		STA	ENTIM0,X
;;		LDA	ENCLOR,X
;;		AND	#11110001B
;;		LDA	#00001010B
;;		STA	ENCLOR,X
;;;		RTL
		RTS
ENDS20		EQU	$
		LDA	ENMOD7,X
		AND	#00000010B
		BNE	BSFLST		; Boss ?
;					; no
;;		LDA	#EFAIL
;;		STA	ENMODE,X
;;		LDA	<WORK0
		LDA	ENFLSH,X
		ASL	A
		LDA	#0FH
		BCC	ENDS22
		LDA	#1FH
ENDS22		EQU	$
		STA	ENTIM0,X
;
		JMP	EFSEND
;
;
;;		RTL
ENDS90		EQU	$
		RTS
;- HAYA mushi boss fail set - - 
HBFLST		EQU	$
		LDA	#03H
		STA	ENSTAT,X
		LDA	#0A0H
		STA	ENTIM3,X
                LDA     #EMOVE
                STA     ENMODE,X
;
;;		STZ	SOUND3
		BRA	BSSDST
;=== Boss fail set ======
BSFLST		EQU	$
		LDA	ENMYNO,X
		CMP	#ICBOS
		BEQ	BFS010
;
		JSL	>ENALFL		; Another enemy fail !
;;SHFLST		EQU	$
BFS010		EQU	$
		LDA	#EBAKU
		STA	ENMODE,X
		STZ	ENWRK0,X
;
		LDA	#0FFH
BFL000		EQU	$
		STA	ENTIM0,X
		STA	ENFLSH,X
;
		BRA	BSSDST
;--ranemora fail set --
RNFLST		EQU	$
		LDA	#05H
		STA	ENSTAT,X
		LDA	#0C0H
		BRA	BFL000
;--Nomos fail set 
NMFLST		EQU	$
		LDA	#01FH+4
		STA	ENTIM0,X
		STZ	ENFLSH,X
		BRA	BSDS00
BSSDST		EQU	$
		INC	BSFLFG		; Player not damage !
;
BSDS00		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#22H
;;		STA	SOUND3		; (S)
;
		STZ	SOUND3		; Mujoken set !
		LDA	#22H
		JSL	>SDLRE3	;(S)
;
		RTS		
;- - ZOOL 1 Bunshin - -
ZLFLST		EQU	$
		LDA	ENWRK2,X
		BNE	ENDS20		; Big ZOOL ?
;					; YES !
		LDA	#02H
		STA	ENSTAT,X
		LDA	#40H-20H
		STA	ENTIM0,X
		LDA	#EMOVE
		STA	ENMODE,X
		STZ	ENFLSH,X
		RTS
;- Kame boss kubi fail set - - 
KAMBRFS		EQU	$
		LDA	#80H
		STA	ENSTAT,X
		LDA	#060H
		STA	ENTIM0,X
                LDA     #EMOVE
                STA     ENMODE,X
;
;;		STZ	SOUND3
		BRA	BSSDST
;;		BRA	BSDS00
;- Kame boss  fail set - - 
KAMBSFS		EQU	$
;;		INC	BSFLFG
;
		LDA	#80H
		STA	ENSTAT,X
		LDA	#080H
		STA	ENTIM0,X
                LDA     #EMOVE
                STA     ENMODE,X
;
;;		STZ	SOUND3
		BRA	BSSDST
;;		BRA	BSDS00
;==================================================
SHFLST		EQU	$
		JSL	>ENALFL
;
		LDA	#EMOVE
		STA	ENMODE,X
		STA	ENNOCR,X
;
		LDA	URAFLG
		BNE	SHF010
;
		LDA	#0AH
		STA	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
		LDA	#020H
		STA	ENZSPD,X
;
		JMP	BSSDST 
;
SHF010		EQU	$
		LDA	#0FFH
		STA	ENTIM0,X
		LDA	#08H
		STA	ENSTAT,X
		INC	A
		STA	ENSTAT+1
		STA	ENSTAT+2
		STZ	ENCHPT+1
		STZ	ENCHPT+2
		JMP	BSSDST	
;==================================================
EFSEND		EQU	$
		LDA	ENMOD0,X	; OAM use count inc (for flash)
		CLC
		ADC	#04H
		STA	ENMOD0,X
;
		LDA	ENHELP
		CMP	#EICE
		BNE	ESE090
;
		LDA	#01H
		STA	ENMOD4,X
ESE090		EQU	$
		RTS
;==================================================
CRENPLL		EQU	$
		PHB
		PHK
		PLB
		JSR	CRENPL
		PLB
		RTL
;--------------------------------------------
CRENPL2L	EQU	$
		PHB
		PHK
		PLB
		JSR	CRENPL2
		PLB
		RTL
;--------------------------------------------
CRENPL3L	EQU	$
		PHB
		PHK
		PLB
		JSR	CRENPL3
		PLB
		RTL
;--------------------------------------------
;;CEPMKD		EQU	$
;;		BYTE	06H,04H,02H,00H
PLMKCK		EQU	$
		BYTE	04H,06H,00H,02H
;
PLTTCK		EQU	$
		HEX	6,4,0,0
EPMKCK		EQU	$
		BYTE	4,6,0,2 
;
CRENPL		EQU	$
		LDA	MRTKFG
		BNE	CEP010A
;
CRENPL4		EQU	$	; For item !
		TXA
		EOR	<FRCNT
		AND	#03H
		ORA	ENFLSH,X
		BNE	CEP010A
;
CRENPL2 	EQU	$
		LDA	PLBGCKF
		CMP	ENKAIF,X
		BNE	CEP010B
;
CRENPL3 	EQU	$
		LDA	ENMOD3,X
		BEQ	EPC010
		JSR	PLCRST1
		JSR     ENCRST
		JSR	CROJCK
		BRA	EPC012
EPC010		EQU	$
		JSR	EPCSUB
EPC012		EQU	$
		LDA	ENMOD0,X
		BMI	CEP020A
;
		BCC	CEP010B
;
		LDA	<DIEFG
		BNE	CEP010B
;
;;		LDA	<KENMD
;;		DEC	A
;;		CMP	#09H-1
;;		BCC	CEP007		; PLAYER Cut ?
;
		LDA     RABFLG
;;;		ORA	DASHFG
;;		ORA	<KENMD
                BNE     CEP007          ; Usagi ?
;
                LDA     PYDMBT
                BMI     CEP007          ; Player cach ?
;
		LDA	ENMOD4,X
		AND	#00100000B
		BEQ	CEP007		; Seeld check !
;
		LDA	>ITMTBL7
		BEQ	CEP007		; Seeld have ?
;					; yes !
		STZ	ENMODE,X
;
		LDA	<PLMKCH
		LDY	<KENMD
		BEQ	CTATE00		; Kakae ?
		LSR	A		; yes !
		TAY
		LDA	PLTTCK,Y
CTATE00		EQU	$
		LDY	ENMUKI,X
		CMP	EPMKCK,Y
		BNE	CEP007		; ENMUKI->TATE ?
;
;;		JSL	>SDLRCE
;;		ORA	#06H
;;		STA	SOUND2		; (S)
		LDA	#06H
		JSL	>SDLRE2	;(S)
;
		JSL	>EFLSST2
;
		LDA	ENMYNO,X
		CMP	#MEMER
		BNE	MMSD00
;
;;		JSL	>SDLRCE
;;		ORA	#26H
;;		STA	SOUND3	;(S)
		LDA	#26H
		JSL	>SDLRE3	;(S)
CEP010A		EQU	$
		CLC
CEP020A		EQU	$
		RTS
;
MMSD00		EQU	$
		CMP	#MAGIC
		BNE	CEP222		; Magician beam ?
;					; yes !
		JSR	ENTURN		; hanekairi !
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
		INC	ENSTAT,X
;
		LDA	#EMOVE
		STA	ENMODE,X
CEP010B		EQU	$
		CLC
		RTS	
;
CEP222		EQU	$
;;;		LDA	ENMYNO,X
		CMP	#YATAM
		BEQ	CEP00B
;
		CMP	#OCTAM
		BEQ	CEP075
;
CEP055		EQU	$		; NO.
		RTS
;
CEP007		EQU	$		; NO.
;
		JSR	PLFLST
		LDA	ENMYNO,X
		CMP	#OCTAM
		BNE	CEP008
;
CEP075		EQU	$
		JSR	OCTAMFL
CEP008		EQU	$
		SEC
		RTS
CEP010		EQU	$
		CLC
CEP020		EQU	$
		RTS
CEP00B		EQU	$
;;ENFLST		EQU	$
;;		LDA	#03H
;;		STA	ENMOD3,X	; OAM suu !
;;		LDA	#EFAIL
;;		STA	ENMODE,X
;;		LDA	#1FH
;;		STA	ENTIM0,X
		JMP	ENFLST
;;		RTS
;========================================
EPCSUB		EQU	$
		LDA	ENZPSL,X
		STA	<WORKC
		STZ	<WORKD
;
		MEM16
		REP	#20H
		LDA	<PLXPS1
		SEC
		SBC	ENXP2L
		CLC
		ADC	#000BH
		CMP	#000BH*2+1
		BCS	EPCS10
		LDA	<PLYPS1
;;		CLC
;;		ADC	#0008H
		SEC
		SBC	ENYP2L
		CLC
		ADC	<WORKC
		CLC
		ADC	#0008H+0008H
		CMP	#0018H
		BCS	EPCS10
;
		MEM8
		SEP	#20H
		SEC
		RTS
;
EPCS10		EQU	$
		MEM8
		SEP	#20H
		CLC
		RTS
;========================================
CACHCK		EQU	$		; for shot enemy katsugi
		LDA	<GAMEMD
		ORA	<KENMD
		ORA	ENSTFG
		BNE	CCCK90
;
		LDA	<PLBGCKF
		CMP	ENKAIF,X
		BNE	CCCK90
;
		LDY	#ENNO-1
CKC010		EQU	$
		LDA	ENMODE,Y
		CMP	#ECACH
		BEQ	CCCK90
		DEY
		BPL	CKC010		; Already cach ?
;					; no !
		LDA	ENMYNO,X
		CMP	#HEBO0
		BEQ	CACHC0
;
		LDA	ENXSPD,X
		ORA	ENYSPD,X
		BNE	CCCK90
CACHC0		EQU	$		; for walking enemy katsugi 
;;		LDA	PYDMBT
;;		AND	#10000000B
		LDA	DASHFG		; player dush 
		BNE	CCCK90
;
;;		LDA	YPSHMD
;;		CMP	#07H
;;		BNE	CCCK90		; CACH MODE ?
;
;;		LDA	<KEYA2L		; yes 
;;		AND	#10000000B
;;		BEQ	CCCK90		; key in ?
;					; yes !
;;		LDA	WCACHOK
;;		BNE	CCCK90		; already cahed ?
;					; no
		LDA	CACHON
		DEC	A
		CMP	ENINDX
		BEQ	CCCKON		; CACH key in ?
;
		JSR	PLCRST		;  
		JSR	ENCRST
		JSR	CROJCK
		BCC	CCCK90		; hit ?
;					; yes !
;;		LDA	#01H		; (1) Hani in !
		TXA
		INC	A
		STA	CACHOK		; for player 
		STA	WCACHOK		; for player 
;
		RTS
;;		LDA	<KEYA2L		; yes 
;;              AND	#10000000B
CCCKON		EQU	$
;;		LDA	CACHON
;;		BEQ	CCCK90		; CACH key in ?
;
		STZ	<KEYA2L
;
;;		LDA	WCACHOK
;;		CMP	#02H
;;		BEQ	CCCK90		; already cahed ?
;;;					; (2) key in !
;;		INC	CACHOK		; for player 
;;		INC	WCACHOK		; for player 
;
		STZ	ENATCT,X	; cross bg  flag clear !
;
;;		JSL	>SDLRCE
;;		ORA	#1DH
;;		STA	SOUND2	;(S)
		LDA	#1DH
		JSL	>SDLRE2	;(S)
;
		LDA	ENMODE,X
		STA	>ENCAMD,X	; recover MODE
;;		STA	ENWRK0,X	; recover MODE
		LDA	#ECACH
		STA	ENMODE,X
		LDA	#10H
		STA	ENTIM0,X
		LDA	#00H
		STA	>ENCACT,X
;;		STZ	ENWRK3,X
;;		STZ	ENSTAT,X
		JSR	EPXYCK
		LDA	PLMKCK,Y
		STA	<PLMKCH
		PLA
		PLA
CCCK90		EQU	$
		RTS
;--
;==================================================
CRKNENL		EQU	$
		PHB
		PHK
		PLB
		JSR	CRKNEN
		TAY
		PLB
		TYA
		RTL
;--------------------------------------------
CRKNEN		EQU	$
;;		TXA
;;		EOR	<FRCNT
;;		AND	#01H
		LDA	ENFLSH,X
		AND	#80H
		BNE	CKE010N
;
		LDA	<PLBGCKF
		CMP	ENKAIF,X		
CKE010N		EQU	$
		BNE	CKE010B
;
		LDA	<KNCRYP
		CMP	#80H
		BEQ	CKE010B		; player cut ?
		JSR	PKNCRS
		JSR     ENCRST
		JSR	CROJCK
		BCC	CKE010B
;
		STZ	HANIFG
;
		LDA	AITMBT1
		AND	#00010000B
		BEQ	CKEFFF		; Ami ?
;					; yes !
		RTS			; Z=0
;
CKEFFF		EQU	$
		LDA	ENMODE,X
		CMP	#EICE
		BNE	CKEE00		; ice or stop  ? (test) hanmer !
;					; yes !
		LDA	>ENICMD,X
		BEQ	CKEE00		; ice ?
;					; yes !
		LDA	AITMBT
		AND	#00001010B
		BEQ	CKEE00		; hanmer ?
;					; yes !
		LDA	#EICBR
		STA	ENMODE,X
		LDA	#20H
		STA	ENTIM0,X
		LDA	ENMOD0,X
		AND	#11100000B
		ORA	#00000011B	; 4 Of OAM use !
		STA	ENMOD0,X
;
		LDA	#1FH
		JSL	>SDLRE2	;(S)
		SEC
		RTS
CKEE00		EQU	$
		LDA	ENMYNO,X
		CMP	#SHTAM
		BNE	CKE033
		LDA	<KENMD
		CMP	#09H
		BMI	CKE009B
CKE010B		EQU	$
		JMP	CKE010
CKE009B		EQU	$
		JMP	CKE009
;-------Motos hit pross !-------------------------------------
CKEMT1		EQU	$
		LDY	ENMUKI,X
		LDA	<PLMKCH
		CMP	EPMKCK,Y
		BNE	CKEMNY		; ENMUKI->TATE ?
;
CKESKH		EQU	$
		JSR	CKEMNY
;
		STZ	ENFLSH,X	; not damege !
		JSR	FLSHST		; Hibana set !
		JMP	CKERT0
;
CKEMNY		EQU	$
		JSR	ENDMGE
;
		LDA	#HPW20          
		JSR	PLHNST
		LDA	#10H   ;+80H
		STA	<HANIFG		; Ken furifuri
		LDA	#10H
		STA	<HANEFG
;
		JMP	CKERT0
;		
;;		BRA	CKE008
CKE033		EQU	$
		CMP	#HAYAB
		BNE	CKE034
;
		LDA	ENWRK0,X
		BNE	CKE009		; Hed hit ?
;					; yes ! hanekairi player !
		JSR	CKEHYB
;
                LDA     #32H
                JSL     >SDLRCE
                STA     SOUND3  :(S)
;
		JMP	CKE0777		; Flash set !
;
CKE034		EQU	$
		CMP	#MOTSB
		BNE	CKE035
;
		JMP	CKEMTB
CKE035		EQU	$
		CMP	#MOTS0
		BEQ	CKEMNY
		CMP	#MOTS1
		BEQ	CKEMT1
		CMP	#SKHED
		BEQ	CKESKH
		CMP	#KAMBS
		BEQ	CKHANE
		CMP	#KAMBB
		BEQ	CKHANE
		CMP	#KAMBR
		BEQ	CKHANE
		CMP	#GANON
		BEQ	CKHANE
		CMP	#GANO2
		BEQ	CKHANE
		CMP	#CTBOS
		BEQ	CKHANE
		CMP	#RANEM
		BNE	CKE009		; mordarm ?
;					; yes !
CKHANE		EQU	$
		LDA	#HPW20          
		JSR	PLHNST
		LDA	#10H+80H
		STA	<HANIFG		; Ken furifuri
		LDA	#10H
		STA	<HANEFG
CKE009		EQU	$
;;		LDA	ENMOD2,X
;;		AND	#01000000B
;;		BNE	CKE077		; muteki ?
		LDA	ENMOD5,X
		AND	#00000100B
		BNE	CKE077
;					; no
;		LDA	ENMODE,X
;		CMP	#EICE
;		BNE	CKE008		; ice or stop  ? (test) hanmer !
;;					; yes !
;		LDA	>ENICMD,X
;		BEQ	CKE008		; ice ?
;;					; yes !
;		LDA	AITMBT
;		AND	#00001010B
;		BEQ	CKE008		; hanmer ?
;;					; yes !
;		LDA	#EICBR
;		STA	ENMODE,X
;		LDA	#20H
;		STA	ENTIM0,X
;		LDA	ENMOD0,X
;		AND	#11100000B
;		ORA	#00000011B	; 4 Of OAM use !
;		STA	ENMOD0,X
;;
;		LDA	#1FH
;		JSL	>SDLRE2	;(S)
;		SEC
;		RTS
;;
CKE008		EQU	$
		JSR	ENDMGE
		SEC
		BRA	CKERT0
CKE010		EQU	$
		CLC
		BRA	CKERT0
;- - - - - - - - - - - - -
CKE077		EQU	$
		LDA	<HANIFG
		BNE	CKE0777
;
		LDA	#HPW03
		JSR	PLHNST
;;		JSR	PLHNFS
		LDA	#10H
		STA	<HANEFG
		LDA	#10H
		STA	<HANIFG		; Ken furifuri
CKE0777		EQU	$
		JSR	FLSHST
		SEC
CKERT0		EQU	$
		LDA	#00H		; Z=1 (Not ami)
		RTS
;------- Enemy ken vs player body ----
CKK080		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		BCS	CTKE010
;
		JSR	EKNCRS
		JSR	PLCRST
		JSR	CROJCK
		BCC	CTKE010
;====player damege============================================			
PLFLST		EQU	$
		LDA	PYFLASH
		ORA	MRTKFG		; Taka... flag !
		BNE	CTKE010
;
;;		LDA	#1FH
		LDA	#13H
		STA	<HANEFG
;;			LDA		#28H
;;			JSR		PSERC2
		LDA	#HPW15
;;		LDY	ENSTAT,X
;;		CPY	#01H
;;		BNE	CKK088
;;		LDA	#HPW20
;;CKK088		EQU	$
		JSR	PLHNST
;
;;		LDA	#20H
;;		STA	CRFLSH		; Player damege !
		LDA	#01H
		STA	<DIEFG
;- - - - - - Player life dec - - - - - 
		LDA	ENMOD6,X
		AND	#0FH
		STA	<WORK0
		ASL	A
		ADC	<WORK0
;;		ADC	ENMOD6,X
		CLC
		ADC	>ITMTBL8
		TAY
		LDA	PLDMDT,Y
		STA	DAMEFG		;damege power dec !
;- - - - - - - - - - - - - - - - - - - 
		LDA	ENMYNO,X
		CMP	#NL777
		BNE	CTKE010		; Medusa beam ?
;
		LDA	ENWRK2,X
		BEQ	CTKE010
;					; yes !
		LDA	ENXSPD,X
		ASL	A
		STA	<PLXSPD
		LDA	ENYSPD,X
		ASL	A
		STA	<PLYSPD
CTKE010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
PLFLSTL		EQU	$
		PHB
		PHK
		PLB
		JSR	PLFLST
		PLB
		RTL
;========================================================
PLDMDT		EQU	$	     ; Player damage table data !
;;;;;;; Fuku color      G B R
		HEX	2,1,1	; 0
		HEX	4,4,4   ; 1
		HEX	0,0,0   ; 2
		HEX	8,4,2   ; 3
		HEX	8,8,8   ; 4
		HEX	10,8,4  ; 5
		HEX	20,10,8 ; 6
		BYTE	32,24,16 ;7
		BYTE	24,16,8  ;8
		BYTE	64,48,24 ;9
;=========== Hayamushi boss ken hit ======
CKEHYB		EQU	$
;;		JSR	ENDMGE
;;;
;;		STZ	ENFLSH,X	; Not damage !
;
		LDA	#HPW30          
		JSR	PLHNST
		LDA	#10H+80H
		STA	<HANIFG		; Ken furifuri
		LDA	#10H
		STA	<HANEFG
;
;;		JSL	>SDLRCE
;;		ORA	#21H
;;		STA	SOUND2		;(S)
		LDA	#21H
		JSL	>SDLRE2	;(S)
;
;
		LDA	#30H
		STA	ENTIM1,X	; Byoyon time !
;
		JMP	CKERT0
;=========== Motos big ken hit ======
CKEMTB		EQU	$
		LDA	ENWRK2,X
		CMP	#03H
		BCS	CMTB90		; On mask ?
;					; yes !
		JMP	CKE077		; Hibana !
;
CMTB90		EQU	$
		JMP	CKE008		; Damage !
;---------------------------------
PKCRXL		EQU	$
;;;	    KENMD        0   1  2  3  4  5  6   7  8  9  A            		
		HEX	00
		HEX	02,00 ,00,F8,00,02,00 ,02,02,01,01,00,00,00,00,00
		HEX	02,04 ,04,00,00,FC,FC ,FA,02,01,01,00,00,00,00,00
		HEX	00,00 ,00,02,02,04,04 ,02,02,02,02,00,00,00,00,00
		HEX	00,00 ,00,FC,FC,F6,00 ,02,02,00,00,00,00,00,00,00
;
PKCRXA		EQU	$
		HEX	0F
;;;	    KENMD        0   1  2  3  4  5  6   7  8  9  A            		
		HEX	04,08 ,08,08,08,0C,08 ,04,04,06,06,00,00,00,00,00
		HEX	04,10 ,0C,08,08,0C,0B ,0C,04,06,06,00,00,00,00,00
		HEX	08,08 ,08,0A,0E,0F,04 ,04,04,06,06,00,00,00,00,00
		HEX	08,08 ,08,0A,0E,0F,04 ,04,04,06,06,00,00,00,00,00
;
PKCRYL		EQU	$
		HEX	00
;;;	    KENMD        0   1  2  3  4  5  6   7  8  9  A            		
		HEX	02,00 ,02,04,04,04,07 ,02,02,01,01,00,00,00,00,00
		HEX	02,00 ,02,FC,FD,F8,00 ,00,02,01,01,00,00,00,00,00
		HEX	00,00 ,00,FE,00,FC,01 ,02,02,01,01,00,00,00,00,00
		HEX	00,00 ,00,FE,00,FC,01 ,02,02,01,01,00,00,00,00,00
;
PKCRYA		EQU	$
		HEX	0F
;;;	    KENMD        0   1  2  3  4  5  6   7  8  9  A            		
		HEX	04,08 ,02,0C,08,0C,08 ,04,04,06,06,00,00,00,00,00
		HEX	04,08 ,04,0C,0C,0C,04 ,08,04,06,04,00,00,00,00,00
		HEX	08,08 ,08,08,08,0C,04 ,04,04,06,06,00,00,00,00,00
		HEX	08,08 ,08,08,08,0C,04 ,04,04,06,06,00,00,00,00,00
;
PKNTEST		EQU	$
;;	KENMD		0 1 2 3 4 5 6 7 8 9 A B C
		HEX	1,1,1,0,0,0,0,1,1,0,0,1,1        
;
;;		HEX	08,08,08,08
;;		HEX	08,04,08,01
;;		HEX	08,08,08,08
;;		HEX	04,00,0A,05
;;		HEX	00,00,00,00
;---------------------------------
PKNCRS2		EQU	$
		PHB
		PHK
		PLB
		JSR	PKNCRS
		PLB
		RTL
;---------------------------------
PKDCX1		EQU	$
		HEX	00,00,F8,08
PKDCX0		EQU	$
		HEX	00,00,FF,00
PKDCY1		EQU	$
		HEX	F8,10,08,08
PKDCY0		EQU	$
		HEX	FF,00,00,00
PKDCXA		EQU	$
		HEX	10,10,10,10
PKDCYA		EQU	$
		HEX	10,10,10,10
;- - - - - - - - - - - - - - - - - - - - - - - - - -
PKCRE0		EQU	$	; spin ken hani set !
		LDA	<PLXPS1
		SEC
		SBC	#00EH
		STA	<WORK0
		LDA	<PLXPS0
		SBC	#00H
		STA	<WORK8
		LDA	<PLYPS1
		SEC
		SBC	#00AH
		STA	<WORK1
		LDA	<PLYPS0
		SBC	#00H
		STA	<WORK9
;
		LDA	#2CH
		STA	<WORK2
		LDA	#2DH
		STA	<WORK3
		PLX
		RTS
;===================================================
PKCRF0		EQU	$	; Dash ken cros hani set !
		LDA	<PLMKCH
		LSR	A
		TAY
		LDA	<PLXPS1
		CLC
		ADC	PKDCX1,Y
		STA	<WORK0
		LDA	<PLXPS0
		ADC	PKDCX0,Y
		STA	<WORK8
		LDA	<PLYPS1
		CLC
		ADC	PKDCY1,Y
		STA	<WORK1
		LDA	<PLYPS0
		ADC	PKDCY0,Y
		STA	<WORK9
;
		LDA	PKDCXA,Y
		STA	<WORK2
		LDA	PKDCYA,Y
		STA	<WORK3
		RTS
;---------------------------------
PKNCRS		EQU	$
		LDA	DASHFG
		BNE	PKCRF0
;		
		PHX
;
		LDX	#00H
		LDA	AITMBT
		AND	#00001010B
		BNE	PKCS10		; Hanmer !
;
		LDA	AITMBT1
		AND	#00010000B
		BNE	PKCS10		; Ami !
;
		LDY	<KENMD
		BMI	PKCRE0		; Spin !!
		LDA	PKNTEST,Y
		BNE	PKCS90
;
		LDA	<PLMKCH
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	<KENMD
		TAX
		INX
;
PKCS10		EQU	$
;;		LDA	<PLMKCH
;;		LSR	A
;;		TAX
;
		LDY	#00H
		LDA	<KNCRXP
		CLC
		ADC	PKCRXL,X
		BPL	PKCR00
		DEY
PKCR00		EQU	$
		CLC
		ADC	<PLXPS1
		STA	<WORK0
		TYA
		ADC	<PLXPS0
		STA	<WORK8
;
		LDY	#00H
		LDA	<KNCRYP
		CLC
		ADC	PKCRYL,X
		BPL	PKCR10
		DEY
PKCR10		EQU	$
		CLC
		ADC	<PLYPS1
		STA	<WORK1
		TYA
		ADC	<PLYPS0
		STA	<WORK9
		LDA	PKCRXA,X
		STA	<WORK2
		LDA	PKCRYA,X
		STA	<WORK3
		PLX
		RTS
PKCS90		EQU	$
		LDA	#80H
		STA	<WORK8
		PLX
		RTS
;---------------------------------
;;EKNHNI		EQU	$
;;		BYTE	004H,010H
;
EKNCRS		EQU	$
		LDA	ENMYNO,X
		CMP	#BARI0
		BEQ	BRSDR0
;
		LDY	#00H
		LDA	ENKNXP
		CMP	#80H
		BEQ	EKCR18		; Enemy cut ?
;;		SEC			; YES !
;;		SBC	#0FEH
		CMP	#00H
		BPL	EKCR00
		DEY
EKCR00		EQU	$
		CLC
		ADC	ENXPSL,X
		STA	<WORK4
		TYA
		ADC	ENXPSH,X
		STA	<WORKA
;
		LDY	#00H
		LDA	ENKNYP
;;		SEC
;;		SBC	#0FEH
		BPL	EKCR10
		DEY
EKCR10		EQU	$
		CLC
		ADC	ENYPSL,X
		STA	<WORK5
		TYA
		ADC	ENYPSH,X
		STA	<WORKB
;
;;		LDA	ENMOD4,X
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		AND	#03H
;;		TAY
;;;;		LDA	#04H
;;;;		LDA	EKNHNI,Y
		LDA	#03H
		STA	<WORK6
		STA	<WORK7
;;;		LDA	ENCTFG,X
;;;		BNE 	EKCR20		; Not cut ?
;								; yes !
		RTS
EKCR18		EQU	$
		LDA	#80H
		STA	<WORKA
EKCR20		EQU	$
		RTS
;--------------------------------------
BRSDR0		EQU	$
		JSL	>BRSDRS
		RTS
;--------------------------------------
PLHNST		EQU	$		; player hanekairi set 
		PHA
		JSR	PSERC2
		LDA	<WORK0
		STA	<PLYSPD
		LDA	<WORK1
		STA	<PLXSPD
		PLA
		LSR	A
;;		NOP		
		STA	<PLZSPD		; Jump set 
		STA	<PLZSPD1 
		STZ	<PLZPS1
		RTS
;--------------------------------------
FLSHST		EQU	$
		LDA	FLMODE
		BNE	FLSS01
;
		LDA	#05H
		STA	FLMODE
		LDA	PLXPS1
		CLC
		ADC	KNCRXP
		STA	FLXPOS
		LDA	PLYPS1
		CLC
		ADC	KNCRYP
		STA	FLYPOS
		LDA	<PLBGCKF
		STA	FLCLOR
;
		JSL	>SDLRCP
		ORA	#05H
		STA	SOUND2	; (S)
FLSS01		EQU	$
		RTS
;--------------------------------------
EFLSST		EQU	$
		LDA	FLMODE
		BNE	EFS010
;
;;		LDA	ENDSPL,X
;;		BNE	EFS010
;;                JSL     >SDLRCE
;;                ORA     #05H
;;                STA     SOUND2  ;(S)
		LDA	#05H
		JSL	>SDLRE2	;(S)
;
EFLSST2		EQU	$
		LDA	ENXPSL,X
		CMP	<SCCH2
		LDA	ENXPSH,X
		SBC	<SCCH21
		BNE	EFS010
;
		LDA	ENYPSL,X
		CMP	<SCCV2
		LDA	ENYPSH,X
		SBC	<SCCV21
		BNE	EFS010	    ; Display in ?
;				    ; yes !
		LDA	ENXPSL,X
		STA	FLXPOS
		LDA	ENYPSL,X
		STA	FLYPOS
		LDA	#05H
		STA	FLMODE
		LDA	ENKAIF,X
		STA	FLCLOR
EFS010		EQU	$
		RTL
;--------------------------------------
PLCRST		EQU	$
		LDA	MRTKFG
		BNE	PCRST00
;
PLCRST1		EQU	$
		LDA	#08H
		STA	<WORK2
		LDA	#08H
		STA	<WORK3
		LDA	<PLXPS1
		CLC
		ADC	#04H
		STA	<WORK0
		LDA	<PLXPS0
		ADC	#00H
		STA	<WORK8
		LDA	<PLYPS1
		CLC
		ADC	#08H
		STA	<WORK1
		LDA	<PLYPS0
		ADC	#00H
		STA	<WORK9
		RTS
PCRST00		EQU	$
		LDA	#080H
		STA	<WORK9
		RTS
;--------------------------------------
;;SWCRST		EQU	$
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	#00H
;;		STA	<WORK4
;;		LDA	ENXPSH,X
;;		ADC	#00H
;;		STA	<WORKA
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	#00H
;;		STA	<WORK5
;;		LDA	ENYPSH,X
;;		ADC	#00H
;;		STA	<WORKB
;;		LDA	#10H
;;		STA	<WORK6
;;		LDA	#10H
;;		STA	<WORK7
;;		RTS
;- - - - - - - - - - - - - - - - - - 
;;;;; OBJCRS ;;
ECRXAD		EQU	$
;			  0     1    2   3    4    5    6   7    8
;		       norml tama octbl ESW Hart YA -   |  Msge OOISU   
		BYTE	002H,003H,000H,0FDH,0FAH,000H,002H,0F8H,000H
;;			  9 oyagi A,B  SUNA C SEKMV; D CHAN0,1(E,F,10,11)
;;		       BOMB
		HEX	FC    ,F8  ,00  ,F8   ,0F0    ,02,02,02,02
;;                      12;heishi 13,ari00 14  15  16  17  18(MOTSB) 19MOTAM
		HEX	02       ,F8       ,02,02,0F0,0F8,0F4        ,04H
;;			1A(BYOYN) 1B(LINE 1C(OCTAM 1D(ICEBG 1E(ATARS 1F(MOTSB eye)
		HEX	FC       ,F4     ,5       ,E0      ,FE      ,04
ECRXAH		EQU	$
		BYTE	000H,000H,000H,0FFH,0FFH,000H,000H,0FFH,000H
		HEX	FF    ,FF  ,00  ,FF   ,0FF    ,00,00,00,00
		HEX	00       ,FF       ,00,00,0FF,0FF,0FF        ,00H
		HEX	FF       ,FF     ,0       ,FF      ,FF      ,0
ECRXRG		EQU	$
		BYTE	00CH,001H,010H,014H,014H,008H,004H,020H,030H
		HEX	18    ,20  ,20  ,20   ,030    ,0C,0C,3C,7C
		HEX	0C       ,20       ,04,0C,030,020,028        ,08H
		HEX	18       ,18     ,5       ,50      ,04      ,8
ECRYAD		EQU	$
		BYTE	000H,003H,004H,0FCH,0F8H,002H,000H,0F0H,00CH
		HEX	FC    ,F8  ,00  ,F6   ,0F0    ,02,02,02,02
		HEX	FD       ,F4       ,02,0A,000,0F4,010        ,04H
		HEX	FC       ,F4     ,3       ,F0      ,F8      ,A
ECRYAH		EQU	$
		BYTE	000H,000H,000H,0FFH,0FFH,000H,000H,0FFH,000H
		HEX	FF    ,FF  ,00  ,FF   ,0FF    ,00,00,00,00 
		HEX	FF       ,FF       ,00,00,000,0FF,000        ,00H
		HEX	FF       ,FF     ,0       ,FF      ,FF      ,0
ECRYRG		EQU	$
		BYTE	00EH,001H,010H,015H,018H,004H,008H,028H,014H
		HEX	18    ,28  ,1D  ,24   ,030    ,3C,7C,0C,0C 
		HEX	11       ,1C       ,04,02,01C,014,00A        ,04H
		HEX	18       ,10     ,5       ,30      ,08      ,C
;--------------------------------------------
ENCRST		EQU	$
		LDA	ENZPSL,X
		BMI	ECRS90		; Under enemy not check !
;
		PHY
		LDA	ENMOD3,X
		AND	#1FH
		TAY
		LDA	ENXPSL,X
		CLC
;;;			ADC		#02H
		ADC	ECRXAD,Y
		STA	<WORK4
		LDA	ENXPSH,X
		ADC	ECRXAH,Y
		STA	<WORKA
;
		LDA	ENYPSL,X
		CLC
		ADC	ECRYAD,Y
		PHP
		SEC
		SBC	ENZPSL,X
		STA	<WORK5
		LDA	ENYPSH,X
		SBC	#00H
		PLP
		ADC	ECRYAH,Y
		STA	<WORKB
;
		LDA	ECRXRG,Y
		STA	<WORK6
		LDA	ECRYRG,Y
		STA	<WORK7
		PLY
		RTS
ECRS90		EQU	$
		LDA	#80H
		STA	<WORKA
		RTS
;--------------------------------------------
CROJCK		EQU	$
		PHX
		LDX	#01H
CROJ10		EQU	$
		LDA	<WORK4,X
		SEC
		SBC	<WORK0,X
		PHA
		PHP
		CLC
		ADC	<WORK6,X
		STA	<WORKF
		PLP
		LDA	<WORKA,X
		SBC	<WORK8,X
		STA	<WORKC
		PLA
		CLC
		ADC	#80H
		LDA	<WORKC
		ADC	#00H
		BNE	CROJRT
;	
;;              LDA	<WORK4,X
;;		SEC
;;		SBC	<WORK0,X
;;		CLC
;;		ADC	<WORK6,X
;;		STA	<WORKF
;
		LDA	<WORK2,X
		CLC
		ADC	<WORK6,X
		CMP	<WORKF
		BCC	CROJRT
		DEX
		BPL	CROJ10
CROJRT		EQU	$
		PLX
		RTS
;=====================================================
OCHECKL		EQU	$
		PHB
		PHK
		PLB
		JSR	OCHECK
		PLB
		RTL
;----------------------------------------
;;OCHECK2		EQU	$
;;		JSR	EPXCHK
;;		BRA	OCK011
OCHECK		EQU	$	; player yuusen obj index set !
		LDA	ENKAIF,X
		CMP	<PLBGCKF
		BNE	EWC010
;
		JSR	EPXCHK
		LDA	<WORKF
		CLC
;;		ADC	#028H
;;		CMP	#50H
		ADC	#010H
		CMP	#20H
		BCS	EWC010
		JSR	EPYCHK
		LDA	<WORKE
		CLC
		ADC	#020H
		CMP	#48H
		BCS	EWC010		; near ?
;					; yes !
;;		LDA	#02H*4
OCK011		EQU	$
		LDA	ENMOD0,X
		AND	#01FH
		INC	A
		ASL	A
		ASL	A
		CPY	#00H
		BEQ	EWC00E		; player y muki check !
;
		JSL	>OAMENT3
		BRA	EWC010
;
EWC00E		EQU	$
		JSL	>OAMENT2
EWC010		EQU	$
		RTS
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;        Enemy fail down !
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
ENFAIL		EQU	$
		LDA	ENMYNO,X
		CMP	#KTOBJ
		BNE	EFL0F0
		JSR	KTOFIL
		RTS
EFL0F0		EQU	$
		CMP	#NOMOS
		BEQ	EFL0MV
		CMP	#RANEM
		BEQ	EFL0MV
		CMP	#MOTSB
		BEQ	EFL0MV
;
		CMP	#HEBO0
		BNE	EFL0F8
;
		LDA	ENWRK2,X
		CMP	#02H
		BCS	EFL0MV
;;L		CMP	#01H
;;L		BNE	EFL0F8		; Enemy bakudan ?
;;;L					; yes ! bakuhatsu !
;;L		INC	ENWRK2,X
;;L		LDA	#09H
;;L		STA	ENMOD3,X
;;L		LDA	#20H
;;L		STA	ENTIM1,X
;;L;;		ASL	A
;;L;;		STA	ENFLSH,X	; not hit check protect !
;;L;;		LDA	#11000000B
;;L;;		STA	ENMOD2,X
;;L		RTS
;
EFL0F8		EQU	$
		LDA	ENTIM0,X
		BEQ	ENF010
;
;;		LDA	ENMYNO,X
;;		CMP	#OCTAM
;;		BEQ	ENF00B
EFLSUB		EQU	$
		LDA	ENMOD2,X
		AND	#10000000B
		BNE	EFL0MV		; fail sub in move routin ?
;					; no. 
		LDA	<FRCNT
		AND	#03H
		ORA	<GAMEMD
		ORA	ENSTFG
		BNE	ENF00A
		INC	ENTIM0,X
ENF00A		EQU	$
		JSR	ENFLCS		; pishi pishi !
;
		LDA	ENMYNO,X
		CMP	#BARI1
		BEQ	ENF00B
;
		LDA	ENTIM0,X
		CMP	#0AH
		BCC	ENF00C
;
ENF00B		EQU	$
		MEM16
		REP	#00100000B
		LDA	<OAMADR
		CLC
		ADC	#0004H*4
		STA	<OAMADR
		LDA	<OSBADR
		CLC
		ADC	#0004H
		STA	<OSBADR
		MEM8
		SEP	#00100000B
;
;;EFL0MV		EQU	$
		LDA	ENMOD0,X
		PHA
		SEC
		SBC	#04H
		STA	ENMOD0,X
		JSR	ENMOVE		; C set !
		PLA
		STA	ENMOD0,X
ENF00C		EQU	$
		RTS
EFL0MV		EQU	$
		JSR	ENMOVE		; C set !
		RTS
;--end 
;===========================================
FILSETL		EQU	$
		PHB
		PHK
		PLB
		JSR	FILSET
		PLB
		RTL
;---------------------------------------
LKITEMD		EQU	$
		BYTE	BOMB1
		BYTE	YAAA1
		BYTE	RUPYR
		BYTE	PTATE
;
ENF010		EQU	$
;		LDA	KAGIFG,X
;		BNE	FILSET
;;
;		LDA	ENMODE,X
;		CMP	#EICE
;		BNE	FILSET
;;
;		LDY	#00H
;		JMP	ENFLIS		; Mujyouken item set !
FILSET		EQU	$
		LDA	ENMYNO,X
		CMP	#LIKE0
		BNE	FS00000
;
		LDY	ENWRK3,X
		BEQ	FS00000
;
		LDA	LKITEMD-1,Y
;
		LDY	HEMODE,X
		PHY
		JSR	enf00f
		PLA
		STA	HEMODE,X
		CMP	#01H
		BNE	FS1000
;
		LDA	#09H
		STA	ENCLOR,X
;
		LDA	#11110000B
		STA	ENMOD2,X
FS1000		EQU	$
;
		INC	ENKBMK,X
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - -
FS00000		EQU	$
		LDY	KAGIFG,X
		BEQ	ENF112		; mujyoken item set ?
;					; yes !
		LDA	ENSWAD,X	; Next data set ok !
		STA	HEMODE,X
		LDA	#0FFH
		STA	ENSWAD,X	; Next data set ok !
;
		LDA	#KAGI0
		CPY	#01H
		BEQ	enf00f
		LDA	#KAGI1
		CPY	#03H
		BNE	enf00f
		LDA	#RUPY1 
;;		LDA	#HART1
		BRA	enf00f
;
ENF112		EQU	$
		LDA	ENMOD4,X
		AND	#00001111B
		BEQ	ENF090J
                DEC     A
		PHA
;
		LDY	URANAIF
		BEQ	EITS098
;
		INC	URANAIC
		LDA	URANAIC
		CMP	#10
		BCC	EITS080
		STZ	URANAIF
EITS080		EQU	$
		PLA
		CPY	#01H
		BEQ	ENFLIS22	; 1:Daikichi 2:Daikyo
ENF090J		EQU	$
		BRA	ENF090
;	
EITS098		EQU	$
		JSL	>RNDSET
		PLY
		AND	ITSTDT,Y
		BNE	ENF090		; item set ?
;					; yes !
ENFLIS		EQU	$
		TYA
ENFLIS22	EQU	$
		ASL	A
		ASL	A
		ASL	A
		ORA	ITSTCT,Y
		PHA
		LDA	ITSTCT,Y
		INC	A
		AND	#07H
		STA	ITSTCT,Y
		PLY
;
		LDA	ITSTNO,Y
enf00f		EQU	$
		STA	ENMYNO,X
		CMP	#KAGI1
		BNE	ENF222
;
		JSR	KAGI1I2		; Save initial & VRAM TR.
		BRA	ENF011
ENF222		EQU	$
		CMP	#KAGI0
		BNE	ENF011
;
		JSR	KAGI0IT2		; Save data index set !
ENF011		EQU	$
		LDA	#EMOVE
		STA	ENMODE,X
;
		LDA	ENZPSL,X
		PHA
		JSL	>ENMDST
		INC	ENNOCR,X
;
		LDY	ENMYNO,X
;
		LDA	ITSTYS-HART1,Y
		PHA
		AND	#0F0H
		STA	ENZSPD,X
;
		PLA
		AND	#0FH
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,X
		LDA	ENXPSH,X
		ADC	#00H
		STA	ENXPSH,X
;
		PLA
		STA	ENZPSL,X
;
		LDA	#15H
		STA	ENTIM3,X
;
		LDA	#0FFH
		STA	ENSTTM,X
;
;;		BRA	ENF0A0
		BRA	ENF093
ENF090		EQU	$
		STZ	ENMODE,X
;
ENF093		EQU	$
		LDA	ENMYNO,X
		CMP	#EYETM
		BNE	ENF098
;
		DEC	ENCTCT+00H	; EYETM counter dec [00:(boss index)
ENF098		EQU	$
		CMP	#ICBOS
		BNE	ENF0A0		; Ice boss fail ?
;					; yes !
		JSL	>EFLCHK
		BCC	ENF0A0		; all fail ?
;					; yes ! item set !
		LDA	#04H
		JSL	>BSITEM
ENF0A0		EQU	$
		JSL	>ENBTON
;
		INC	HIMICT		; Taki fail count !
;
		LDA	ENMYNO,X
		CMP	#HEIS3
		BNE	ENF0A8
;
;;		LDA	ENCLOR,X
;;		CMP	#00001011B
                LDA     >MODTBL0
                CMP     #02H
                BNE     ENF0A7 
;
		LDA	GRNDNO
		CMP	#18H
		BNE	ENF0A7		; HELP0 called City heishi ?
;					; yes !
		LDA	#07H
		STA	SOUND0	;(S)	; BGM remove !
ENF0A7		EQU	$
		RTS
;----------------------------------------------------
ENF0A8		EQU	$
		CMP	#BARI1
		BNE	ENF0B0
;
		LDA	#EMOVE
		STA	ENMODE,X
;
		LDA	#04H
		STA	ENCHPT,X
;
;;		PHX
;;		LDX	<MPDTNO
;;		LDA	>GNDTBL,X
;;		ORA	#01000000B
;;		STA	>GNDTBL,X
;;		PLX
;
		JMP	EFLSUB
ENF0B0		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - -
ENFLIS2		EQU	$
		PHB
		PHK
		PLB
		JSR	ENFLIS
		PLB
		RTL
;- - - - - - - - - - - - - - - -
ITSTDT		EQU	$
		BYTE	1,1,1,0,1,1,1     ; Deru kakuritsu
;;		BYTE	3,1,3,1,1,3     ; Deru kakuritsu
;
ITSTYS		EQU	$
;;;;			 0  1  2  3  4  5  6   
		HEX	00,24,24,24,20,20,20   
;;;;			       A  B            
		HEX	      24,24            
;;;;			         13 14 15 16 17
		HEX	         24,24,00,24,20,20
;
ITSTNO		EQU	$		; Deru mono
		BYTE	HART1,HART1,HART1,HART1,RUPYR,HART1,HART1,RUPYR ;1
		BYTE	RUPY5,RUPY1,RUPY5,RUPYO,RUPY5,RUPY1,RUPY5,RUPY5 ;2
		BYTE	TUBO2,TUBO1,TUBO1,RUPYY,TUBO2,TUBO1,HART1,TUBO1 ;3
		BYTE	BOMB1,BOMB1,BOMB1,BOMB2,BOMB1,BOMB1,BOMB3,BOMB1 ;4
		BYTE	YAAA1,HART1,YAAA1,YAAA2,YAAA1,HART1,YAAA1,YAAA2 ;5
		BYTE	TUBO1,RUPY1,HART1,YAAA1,TUBO1,BOMB1,RUPY1,HART1 ;6
		BYTE	HART1,YOSEI,TUBO2,RUPYO,BOMB3,HART1,RUPYO,YAAA2 ;7
;
;
;
;====================================================
EFCXAD		EQU	$
		BYTE	000H,000H,000H,008H	;0
		BYTE	000H,008H,000H,008H	;1
		BYTE	008H,008H,000H,008H	;2
		BYTE	000H,008H,000H,008H	;3
		BYTE	000H,008H,000H,008H	;4
		BYTE	000H,008H,000H,008H	;5
		BYTE	0FDH,00BH,0FDH,00BH	;6
		BYTE	0FAH,00EH,0FAH,00EH	;7
EFCYAD		EQU	$
		BYTE	000H,000H,008H,008H	;0	
		BYTE	000H,000H,008H,008H	;1	
		BYTE	000H,000H,008H,008H	;2	
		BYTE	000H,000H,008H,008H	;3	
		BYTE	000H,000H,008H,008H	;4	
		BYTE	000H,000H,008H,008H	;5
		BYTE	0FDH,0FDH,00BH,00BH	;6
		BYTE	0FAH,0FAH,00EH,00EH	;7
EFCCDT		EQU	$
		BYTE	000H,0B9H,000H,000H
		BYTE	0B4H,0B5H,0B5H,0B4H
		BYTE	0B9H,000H,000H,000H
		BYTE	0B5H,0B4H,0B4H,0B5H
		BYTE	0A8H,0A8H,0B8H,0B8H
		BYTE	0A8H,0A8H,0B8H,0B8H
		BYTE	0A9H,0A9H,0A9H,0A9H	
		BYTE	09BH,09BH,09BH,09BH	
;
;;		BYTE	000H,0FDH,000H,000H
;;		BYTE	0EEH,0EFH,0EFH,0EEH
;;		BYTE	0FDH,000H,000H,000H
;;		BYTE	0EFH,0EEH,0EEH,0EFH
;;		BYTE	0EAH,0EBH,0FAH,0FBH
;;		BYTE	0ECH,0ECH,0FCH,0FCH
;;		BYTE	0EDH,0EDH,0EDH,0EDH	
;;		BYTE	0EDH,0EDH,0EDH,0EDH	
EFCADT		EQU	$
		BYTE	004H,004H,004H,004H
		BYTE	004H,004H,0C4H,0C4H
		BYTE	044H,004H,004H,004H
		BYTE	044H,044H,084H,084H
		BYTE	004H,044H,004H,044H
		BYTE	004H,044H,004H,044H
		BYTE	044H,004H,0C4H,084H
		BYTE	004H,044H,084H,0C4H
ENFLCS		EQU	$
		LDA	BGALCKF
		CMP	#04H
		BNE	EFCS98
;
		LDA	#30H
		STA	ENFLCL,X
EFCS98		EQU	$
		JSR	OAMCHK
;
		LDA	ENMOD2,X
		AND	#00100000B	; 1;EN1CSS
		LSR	A
		LSR	A
		LSR	A
		STA	<WORKC
;
;;		LDY	ENOMID,X
;
		PHX
		LDA	#03H
		STA	<WORK0
		LDA	ENTIM0,X
		AND	#00011100B
		EOR	#00011100B
		CLC
		ADC	<WORK0
		TAX
		LDY	#00H
EFC010		EQU	$
		PHY
		LDA	EFCCDT,X
		BEQ	EFC050		; nothing ?
;					; yes !
		INY
		INY
		STA	(<OAMADR),Y
		LDA	ENDSYL
		SEC
		SBC	<WORKC
		CLC
		ADC	EFCYAD,X
		DEY
		STA	(<OAMADR),Y
		LDA	ENDSXL
		SEC
		SBC	<WORKC
		CLC
		ADC	EFCXAD,X
		DEY
		STA	(<OAMADR),Y
		LDA	<WORK5
		AND	#00110000B
		ORA	EFCADT,X
;;;		ORA	#24H
		INY
		INY
		INY
		STA	(<OAMADR),Y
EFC050		EQU	$
		PLY
		INY
		INY
		INY
		INY
		DEX
		DEC	<WORK0
		BPL	EFC010
		PLX
;
		LDY	#00H
		LDA	#03H
		JSR	ALOMCK
;
;;		LDA	ENOMID,X
;;		CLC
;;		ADC	#10H
;;		STA	ENOMID,X
		RTS
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;        Enemy hole down !
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
S3		EQU	00H
S7		EQU	00H
SF		EQU	01H
SG		EQU	03H
SH		EQU	07H
SI		EQU	0FH
TTHLMD		EQU	$	; HEIS0
		HEX 	D,D,D,D,D,D,D,C,C,C,C,C,3,3,3,3
		HEX 	3,2,2,2,2,1,1,1,1,0,0,0,0,0,0,0
MNHLMD		EQU	$	; MANY1
		HEX	5,5,5,5,5,5,5,4,4,4,4,4,3,3,3,3
		HEX	3,2,2,2,2,1,1,1,1,0,0,0,0,0,0,0
;;		HEX	7,7,7,7,7,7,7,6,6,6,6,6,5,5,5,5
;;		HEX	5,4,4,4,4,3,3,3,3,2,2,2,2,2,2,2
TTHLTD		EQU	$
		HEX	FF,3F,1F,0F,0F,07,03,01
		HEX	FF,3F,1F,0F,07,03,01,00
;
;;                BYTE	SI,SI,SI,SI,SI,SI,SI,SH,SH,SH,SH,SH,SG,SG,SG,SG
;;        	BYTE	SG,SF,SF,SF,SF,S7,S7,S7,S7,S3,S3,S3,S3,S3,S3,S3
MKCHEK		EQU	$
		HEX	00,04,08,00
;-------------------------------------
ENHOLE		EQU	$
;- - - -
		LDA	ENTIM0,X
		BNE	ENHL00
;
		STZ	ENMODE,X
;
		JSL	>ENBTON		; Bit on !
		RTS
;- - - - - - - - - - - - - - - -
ENHL00		EQU	$
		CMP	#40H
		BCC	ENHL01
;
		LDA	ENCLOR,X
		CMP	#04H+1
		BNE	ENHL0011		; Heishi ice ?
;					; yes ! pata pata nashi !
		LDA	#3FH
		STA	ENTIM0,X
		BRA	ENHL01
ENHL0011	EQU	$
		LDA	ENTIM0,X
		AND	#07H
		ORA	<GAMEMD
		ORA	ENSTFG
		BNE	ENHL001
;
		LDA	#31H
		JSL	>SDLRE3	;(S)
ENHL001		EQU	$
		JSR	ENMOVE
		JSR	OAMCHK
;
		LDA	<WORK2
		SEC
		SBC	#08H
		STA	<WORK2
		LDA	<WORK3
		SBC	#00H
		STA	<WORK3
;
ENHL005  	EQU	$
		LDA	ENTIM0,X
		CLC
		ADC	#14H
		STA	<WORK6
;
		JSL	>BIKRST		; Bikkuri set !
		RTS
;
ENHL01		EQU	$
		CMP	#3DH
		BNE	ENHL012
		PHA
;;		JSL	>SDLRCE
;;		ORA	#20H
;;		STA	SOUND2	;(S)
		LDA	#20H
		JSL	>SDLRE2	;(S)
		PLA
ENHL012		EQU	$
;;;		LDA	ENTIM0,X
		LSR	A
;;		LSR	A
;;		NOP
		TAY
;
		LDA	ENMYNO,X
		CMP	#MOTS0
		BEQ	ENHL010
		CMP	#MOTS1
		BNE	ENHL011
ENHL010		EQU	$
		LDA	MNHLMD,Y
		STA	ENCHPT,X
		JSR	MNHLCS
		BRA	ENHL022
ENHL011		EQU	$
;
		LDA	TTHLMD,Y
		CMP	#0CH
		BCS	ENHL02
		LDY	ENMUKI,X
		CLC
		ADC	MKCHEK,Y
ENHL02		EQU	$
		STA	ENCHPT,X
;
		JSR	EHOLECS
;
ENHL022		EQU	$
		LDA	ENTIM0,X
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	<FRCNT 
		AND	TTHLTD,Y
		ORA	<GAMEMD
		BNE	THLCF0
;
		LDY	#BC1-BC0		; BG MANNAKA  check 
		JSR	UNITR2
		LDA	UNITNO
		CMP	#20H
		BEQ	ENHL023		; nOT HOLE ?
;					; CLEAR !
		STZ	ENHNYS,X
		STZ	ENHNXS,X
ENHL023		EQU	$
		LDA	ENHNYS,X
		STA	ENYSPD,X
		ASL	A
		PHP
		ROR	ENYSPD,X
		PLP
		ROR	ENYSPD,X
;
		LDA	ENHNXS,X
		STA	ENXSPD,X
		ASL	A
		PHP
		ROR	ENXSPD,X
		PLP
		ROR	ENXSPD,X
		JSR	ENMVCL
THLCF0		EQU	$
		RTS
;=========================================================
MNHLCD		EQU	$
		WORD	00000H,00000H
		HEX	46,01,00,02
;
		WORD	00000H,00000H
		HEX	48,01,00,02
;
		WORD	00000H,00000H
		HEX	4A,01,00,02
;
		WORD	00004H,00004H
		HEX	4C,01,00,00
;
		WORD	00004H,00004H
		HEX	B7,00,00,00
;
		WORD	00004H,00004H
		HEX	80,00,00,00
;- - - - - - - - - - - - - - - - - - -
M1HLCD		EQU	$
		WORD	00000H,00000H
		HEX	6C,01,00,02
;
		WORD	00000H,00000H
		HEX	6E,01,00,02
;
		WORD	00000H,00000H
		HEX	4E,01,00,02
;
		WORD	00004H,00004H
		HEX	5C,01,00,00
;
		WORD	00004H,00004H
		HEX	B7,00,00,00
;
		WORD	00004H,00004H
		HEX	80,00,00,00
;- - - - - - - - - - - - - - - - - - -
MNHLCS		EQU	$
		LDA	ENMYNO,X
		CMP	#MOTS1
		BEQ	M1HLCS
;
		LDA	ENCHPT,X
;;DEC	A
;;DEC	A
;
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW MNHLCD
		STA	<WORK8
		LDA	#HIGH MNHLCD
MLH010		EQU	$
		ADC	#00H
		STA	<WORK9	
		LDA	#01H
;;		STA	<WORK6
;;		STZ	<WORK7
		JSL	>SETOAML22
		RTS
;- - - - - - - - - - - - - - -
M1HLCS		EQU	$
		LDA	ENCHPT,X
;;DEC	A
;;DEC	A
;
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW M1HLCD
		STA	<WORK8
		LDA	#HIGH M1HLCD
		BRA	MLH010
;
;		ADC	#00H
;		STA	<WORK9	
;		LDA	#01H
;		STA	<WORK6
;		STZ	<WORK7
;		JSL	>SETOAML2
;		RTS
;=========================================================
EHCXAD		EQU	$
		HEX	FC,04,FC,0C
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
		HEX	04 ,0,0,0
;
		HEX	FC,0C,FC,04
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
		HEX	04 ,0,0,0
;
		HEX	FC,0C,FC,04
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
		HEX	04 ,0,0,0
;
		HEX	04 ,0,0,0
		HEX	04 ,0,0,0
EHCYAD		EQU	$
		HEX	FC,FC,04,0C
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
		HEX	04 ,0,0,0
;
		HEX	FC,FC,0C,04
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
		HEX	04 ,0,0,0
;
		HEX	FC,FC,0C,04
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
		HEX	04 ,0,0,0
;
		HEX	04 ,0,0,0
		HEX	04 ,0,0,0
EHCCDT		EQU	$
		HEX	AE,A8,A6,AF
		HEX	AA ,0,0,0
		HEX	AC ,0,0,0
		HEX	BE ,0,0,0
;
		HEX	A8,AE,AF,A6
		HEX	AA ,0,0,0
		HEX	AC ,0,0,0
		HEX	BE ,0,0,0
;
		HEX	A6,AF,AE,A8
		HEX	AA ,0,0,0
		HEX	AC ,0,0,0
		HEX	BE ,0,0,0
;
		HEX	B6 ,0,0,0
		HEX	80 ,0,0,0
EHCADT		EQU	$
		HEX	00,00,00,00
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
;
		HEX	40,40,40,40
		HEX	40 ,0,0,0
		HEX	40 ,0,0,0
		HEX	40 ,0,0,0
;
		HEX	80,80,80,80
		HEX	80 ,0,0,0
		HEX	80 ,0,0,0
		HEX	80 ,0,0,0
;
		HEX	01 ,0,0,0
		HEX	01 ,0,0,0
EHCSBD		EQU	$
		HEX	00,02,02,00
		HEX	02 ,0,0,0
		HEX	02 ,0,0,0
		HEX	00 ,0,0,0
;
		HEX	02,00,00,02
		HEX	02 ,0,0,0
		HEX	02 ,0,0,0
		HEX	00 ,0,0,0
;
		HEX	02,00,00,02
		HEX	02 ,0,0,0
		HEX	02 ,0,0,0
		HEX	00 ,0,0,0
;
		HEX	00 ,0,0,0
		HEX	00 ,0,0,0
;-------------------------------------------------
EHOLECS		EQU	$
		JSR	OAMCHK
		LDA	ENCHPT,X
		PHA
		ASL	A
		ASL	A
		STA	<WORK6
;
		PLA
		PHX
		LDX	#00H
		CMP	#0CH
		BCS	EHC008
		AND	#03H
		BNE	EHC008
		LDX	#03H
EHC008		EQU	$
		STX	<WORK7
EHC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	EHCXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	EHCYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	EHCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	EHCADT,X
		EOR	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	EHCSBD,X
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	EHC010
		PLX
		LDY	#0FFH
		LDA	<WORK7
		JSR	ALOMCK
;
		RTS
		
;
;
;
;
;
;
;
;
;
;
;		JSR	OAMCHK
;		LDA	ENDSPL,X
;		BNE	ENHL28
;;
;		JSR	TTNHLCS
;		LDA	<FRCNT 
;		AND	#02H
;		ORA	<WORK2
;		ORA	<GAMEMD
;		BNE	ENHL28
;;
;;;		LDY	ENOMID,X
;;;		LDA	OAM+0BH,Y
;;;		ORA	#01000000B
;;;		STA	OAM+0BH,Y
;;;		STA	OAM+0FH,Y
;ENHL28  	EQU	$
;		RTS
;----------------------------------------
;
;
;TTNHLCS		EQU	$
;		LDA	ENTIM0,X
;		LSR	A
;		LSR	A
;;;;;        	LSR	A
;		NOP
;		TAY
;		LDA	<FRCNT 
;		AND	TTHLTD,Y
;		ORA	<GAMEMD
;		BNE	THLCF0
;		PHY
;		JSR	ENYCLC
;		JSR	ENXCLC
;		PLY
;THLCF0		EQU	$
;		LDA	TTHLMD,Y
;		STA	<WORK2
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		STA	<WORK0
;		LDA	ENYPSL,X
;		SEC
;		SBC	<SCCV2
;		STA	<WORK1
;;;;		LDY	ENOMID,X
;		LDY	#00H
;		JMP	>TTHLC0
;;-------------------------------------------------
;TH0XAD		EQU	$
;		BYTE	000H,000H,00H,00H
;		BYTE	0FCH,0FCH,04H,04H
;		BYTE	000H,000H,00H,00H
;		BYTE	000H,000H,00H,00H
;		BYTE	004H,004H,04H,04H
;		BYTE	004H,004H,04H,04H
;TH0YAD		EQU	$
;		BYTE	008H,08H,000H,00H
;		BYTE	0FCH,04H,0FCH,04H
;		BYTE	000H,00H,000H,00H
;		BYTE	000H,00H,000H,00H
;		BYTE	004H,04H,004H,04H
;		BYTE	004H,04H,004H,04H
;TH0CDT		EQU	$
;		BYTE	0A0H,0A0H,080H,080H
;		BYTE	0CDH,0DDH,0CEH,0DEH
;		BYTE	0C0H,0C0H,0C0H,0C0H
;		BYTE	0C2H,0C2H,0C2H,0C2H
;		BYTE	0FDH,0FDH,0FDH,0FDH
;		BYTE	0FEH,0FEH,0FEH,0FEH
;TH0SDT		EQU	$
;		BYTE	02H,02H,02H,02H,00H,00H
;;		
;TTHLC0		EQU	$
;		LDX	#03H
;THC010		EQU	$
;		STX	<WORK3
;;
;		LDA	<WORK2
;		ASL	A
;		ASL	A
;		ADC	<WORK3
;		TAX
;		LDA	<WORK0
;		CLC
;		ADC	TH0XAD,X
;		STA	OAM+00H,Y
;		LDA	<WORK1
;		CLC
;		ADC	TH0YAD,X
;		STA	OAM+01H,Y
;		LDA	TH0CDT,X
;		STA	OAM+02H,Y
;		LDA	#26H+1
;		STA	OAM+03H,Y
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDX	<WORK2
;		LDA	TH0SDT,X
;		STA	OAMSB+00H,Y
;		PLY
;		INY
;		INY
;		INY
;		INY
;;
;		LDX	<WORK3
;		DEX
;		BPL	THC010
;		LDX	ENINDX
;		RTS
;;		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%   		OAM clear check sub.     		%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ALOMCKL		EQU	$
		PHB
		PHK
		PLB
		JSR	ALOMCK
		PLB
		RTL
;--------------------------------------------
ALOMCK		EQU	$
		JSR	ALCKSB
;
		PHX
;
;;		LDY	#00H
		IDX16
		REP	#00010000B
		LDX	<OAMADR
		STX	<WORKC
		LDX	<OSBADR
		STX	<WORKE
GSCL00		EQU	$
		LDX	<WORKE
;
		LDA	<WORKB
		BPL	GSCL08
		LDA	<OAMSB-OAMSB,X
		AND	#00000010B
GSCL08		EQU	$
		STA	<OAMSB-OAMSB,X
GSCL09		EQU	$
;-- X Check ---
		LDY	#0000H
		LDX	<WORKC
		LDA	<OAM-OAM,X
		SEC
		SBC	<WORK7
		BPL	GSCL10
		DEY
GSCL10		EQU	$
		CLC
		ADC	<WORK2
		STA	<WORK4
		TYA
		ADC	<WORK3
		STA	<WORK5
		JSR	ONOMCK
		BCC	GSCL11
		LDX	<WORKE
		INC	<OAMSB-OAMSB,X
;;		ORA	#00000001B
;;		STA	<OAMSB-OAMSB,X
GSCL11		EQU	$
;-- Y check --
		LDY	#0000H
		LDX	<WORKC
		INX
		LDA	<OAM-OAM,X
		SEC
		SBC	<WORK6
		BPL	GSCL12
		DEY
GSCL12		EQU	$
		CLC
		ADC	<WORK0
		STA	<WORK9
		TYA
		ADC	<WORK1
		STA	<WORKA
		JSR	ONOMCV
		BCC	GSCL20
GSCL18		EQU	$
		LDA	#0F0H
		STA	<OAM-OAM,X
GSCL20		EQU	$
		INX
		INX
		INX
		STX	<WORKC
		INC	<WORKE
		DEC	<WORK8
		BPL	GSCL00
;
		IDX8
		SEP	#00010000B
;;		LDX	ENINDX
		PLX
		RTS
;
;-- OLD
;ALOMCK		EQU	$
;		JSR	ALCKSB
;;
;;;		LDY	#00H
;		IDX16
;		REP	#00010000B
;		LDX	<OAMADR
;GSCL00		EQU	$
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY		
;		LDA	<WORKB
;		BPL	GSCL08
;		LDA	(<OSBADR),Y
;		AND	#00000010B
;GSCL08		EQU	$
;		STA	(<OSBADR),Y
;		PLY
;GSCL09		EQU	$
;-- X Check ---
;		LDX	#00H
;		LDA	(<OAMADR),Y
;		SEC
;		SBC	<WORK7
;		BPL	GSCL10
;		DEX
;GSCL10		EQU	$
;		CLC
;		ADC	<WORK2
;		STA	<WORK4
;		TXA
;		ADC	<WORK3
;		STA	<WORK5
;		JSR	ONOMCK
;		BCC	GSCL11
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDA	(<OSBADR),Y
;		ORA	#00000001B
;		STA	(<OSBADR),Y
;		PLY
;GSCL11		EQU	$
;-- Y check --
;		LDX	#00H
;		INY
;		LDA	(<OAMADR),Y
;		SEC
;		SBC	<WORK6
;		BPL	GSCL12
;		DEX
;GSCL12		EQU	$
;		CLC
;		ADC	<WORK0
;		STA	<WORK9
;		TXA
;		ADC	<WORK1
;		STA	<WORKA
;		JSR	ONOMCV
;		BCC	GSCL20
;GSCL18		EQU	$
;		LDA	#0F0H
;		STA	(<OAMADR),Y
;GSCL20		EQU	$
;;;		INY
;		INY
;		INY
;		INY
;		DEC	<WORK8
;		BPL	GSCL00
;		LDX	ENINDX
;		RTS
;--------------------------------------------
;ALO2CK		EQU	$
;		JSR	ALCKSB
;		LDY	<WORKF
;G2CL00		EQU	$
;		TYA
;		LSR	A
;		LSR	A
;		TAX
;		LDA	<WORKB
;		BPL	G2CL08
;		LDA	OAMSB2+00H,X
;		AND	#00000010B
;		STA	OAMSB2+00H,X
;		BRA	G2CL09
;G2CL08		EQU	$
;		STA	OAMSB2+00H,X
;G2CL09		EQU	$
;;-- X Check ---
;		LDX	#00H
;		LDA	OAM2+00H,Y
;		SEC
;		SBC	<WORK7
;		BPL	G2CL10
;		DEX
;G2CL10		EQU	$
;		CLC
;		ADC	<WORK2
;		STA	<WORK4
;		TXA
;		ADC	<WORK3
;		STA	<WORK5
;		JSR	ONOMCK
;		BCC	G2CL11
;		TYA
;		LSR	A
;		LSR	A
;		TAX
;		LDA	OAMSB2+00H,X
;		ORA	#00000001B
;		STA	OAMSB2+00H,X
;G2CL11		EQU	$
;;-- Y check --
;		LDX	#00H
;		LDA	OAM2+01H,Y
;		SEC
;		SBC	<WORK6
;		BPL	G2CL12
;		DEX
;G2CL12		EQU	$
;		CLC
;		ADC	<WORK0
;		STA	<WORK9
;		TXA
;		ADC	<WORK1
;		STA	<WORKA
;		JSR	ONOMCV
;		BCC	G2CL20
;G2CL18		EQU	$
;		LDA	#0F0H
;		STA	OAM2+01H,Y
;G2CL20		EQU	$
;		INY
;		INY
;		INY
;		INY
;		DEC	<WORK8
;		BPL	G2CL00
;		LDX	ENINDX
;		RTS
;---------------------------------------------
ALCKSB		EQU	$
		STY	<WORKB
		STA	<WORK8
		LDA	ENYPSL,X
		STA	<WORK0
		SEC
		SBC	<SCCV2
		STA	<WORK6
		LDA	ENYPSH,X
		STA	<WORK1
		LDA	ENXPSL,X
		STA	<WORK2
		SEC
		SBC	<SCCH2
		STA	<WORK7
		LDA	ENXPSH,X
		STA	<WORK3
		RTS
;------------------------------
ONOMCK		EQU	$
		MEM16
		REP	#00100000B
		LDA	<WORK4
		SEC
		SBC	<SCCH2
		CMP	#0100H
		MEM8
		SEP	#00100000B
		RTS
;-------------------------------
ONOMCV		EQU	$
		MEM16
		REP	#00100000B
		LDA	<WORK9
		PHA
		CLC
		ADC	#10H
		STA	<WORK9
		SEC
		SBC	<SCCV2
		CMP	#0100H
		PLA
		STA	<WORK9
		MEM8
		SEP	#00100000B
		RTS
;=================================================================================================
;ENOXDL		EQU	$
;		BYTE	030H,0C0H
;ENOXDH		EQU	$
;		BYTE	001H,0FFH
;;
;EOT0A0R		EQU	$
;		RTS
;;
;ENSAVE		EQU	$
;		LDA	ENDSPL,X
;		BEQ	EOT0A0R
;;---- X check ---
;		TXA
;		EOR	<FRCNT
;		LSR	A
;		BCC	EOT0A0R
;		AND	#01H
;		STA	<WORK1
;		STA	<WORK2
;		TAY
;		LDA	<SCCH2
;		CLC
;		ADC	ENOXDL,Y
;		ROL	<WORK0
;		CMP	ENXPSL,X
;;
;		PHP
;;
;		LDA	<SCCH2+1
;		LSR	<WORK0
;		ADC	ENOXDH,Y
;;
;		PLP
;		SBC	ENXPSH,X
;		STA	<WORK0
;;
;		LSR	<WORK1
;		BCC	ENOT10
;;
;		EOR	#80H
;		STA	<WORK0
;ENOT10		EQU	$
;		LDA	<WORK0
;		BMI	ENOT38
;;---- Y check ---
;		LDA	<SCCV2
;		CLC
;		ADC	ENOXDL,Y
;		ROL	<WORK0
;		CMP	ENYPSL,X
;;
;		PHP
;;
;		LDA	<SCCV2+1
;		LSR	<WORK0
;		ADC	ENOXDH,Y
;;
;		PLP
;		SBC	ENYPSH,X
;		STA	<WORK0
;;
;		LSR	<WORK2
;		BCC	ENOT30
;;
;		EOR	#80H
;		STA	<WORK0
;ENOT30		EQU	$
;		LDA	<WORK0
;		BPL	EOT0A0
;ENOT38		EQU	$
		JSL	>ENCLER
		RTS
;----		
;- - - - - - - - - - - - - - 
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@		Enemy hanakairi sub 		       @
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
TNHNTM		EQU	$
		BYTE	03,01,00,00
HBCKBT		EQU	$
		BYTE	00001100B
		BYTE	00000011B
;- - - - - - - - - - - - - - - - - - - - - -
ENHNSB		EQU	$	
		LDA	ENHNFG,X
		BEQ	ENHB90
		AND	#7FH
		BEQ	ENHB99
;
		LDA	ENYSPD,X
		PHA
		LDA	ENXSPD,X
		PHA
		DEC	ENHNFG,X
		BNE	EHB001		; End ?
;					; yes !
		LDA	ENHNXS,X
		CLC
		ADC	#20H
		CMP	#40H
		BCS	EHB0FF
;
		LDA	ENHNYS,X
		CLC
		ADC	#20H
		CMP	#40H
		BCC	EHB001
;
EHB0FF		EQU	$
		LDA	#080H+10H	; Stop !
		STA	ENHNFG,X
EHB001		EQU	$
		LDA	ENHNFG,X
		BMI	ENHB08
;
;;		LSR 	A
		LSR 	A
		LSR 	A
		TAY
		LDA	<FRCNT
		AND	TNHNTM,Y
		BNE	ENHB08																
		LDA	ENHNYS,X
		STA	ENYSPD,X
		LDA	ENHNXS,X
		STA	ENXSPD,X
;
		LDA	ENMOD6,X
		BMI	ENHB10		; BG check ?
; 					; Yes !
 		JSL	>ENBGCKL
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	ENHB10
;
		CMP	#00000100B
		BCS	ENHB01
;
		STZ	ENHNXS,X
		STZ	ENXSPD,X
		BRA	ENHB02
ENHB01		EQU	$
		STZ	ENHNYS,X
		STZ	ENYSPD,X
ENHB02		EQU	$
;		LDA	ENXSPD,X
;		BPL	ENHB01
;		EOR	#0FFH
;		INC	A
;ENHB01		EQU	$
;		STA	<WORK0
;		LDA	ENYSPD,X
;		BPL	ENHB02
;		EOR	#0FFH
;		INC	A
;ENHB02		EQU	$
;		LDY	#00H
;		CMP	<WORK0
;		BCS	ENHB03
;;
;		INY
;ENHB03		EQU	$
;		LDA	ENCBFG,X
;		AND	HBCKBT,Y
;		BEQ	ENHB04
;		STZ	ENHNFG,X
;ENHB04		EQU	$
;		CPY	#00H
;		BNE	ENHB05
;		STZ	ENHNXS,X
		BRA	ENHB08
;ENHB05		EQU	$
;		STZ	ENHNYS,X
;		BRA	ENHB08
ENHB10		EQU	$
		JSR	ENMVCL
ENHB08		EQU	$
		PLA
		STA	ENXSPD,X
		PLA
		STA	ENYSPD,X
		PLA
		PLA
ENHB90		EQU	$
		RTS
ENHB99		EQU	$
		STZ	ENHNFG,X
		RTS
;;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;;@		Enemy hanakairi sub 		       @
;;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;TNHNTM		EQU	$
;		BYTE	03,01,00,00
;;;HBCKBT		EQU	$
;;;		BYTE	00001100B
;;;		BYTE	00000011B
;;- - - - - - - - - - - - - - - - - - - - - -
;ENHNSB		EQU	$	
;		LDA	ENHNFG,X
;		BEQ	ENHB90
;;
;		LDA	ENYSPD,X
;		PHA
;		LDA	ENXSPD,X
;		PHA
;		DEC	ENHNFG,X
;		LDA	ENHNFG,X
;;;		LSR 	A
;		LSR 	A
;		LSR 	A
;		TAY
;		LDA	<FRCNT
;		AND	TNHNTM,Y
;		BNE	ENHB08		
;;														
;		LDA	ENHNYS,X
;		STA	ENYSPD,X
;		LDA	ENHNXS,X
;		STA	ENXSPD,X
;;
;;;		LDA	ENMOD4,X
;;;		BMI	ENHB10		; BG check ?
;;;		LDA	ENMYNO,X
;;;		CMP	#GOST0
;;;		BEQ	ENHB10
;		LDA	HEMODE,X
;		CMP	#0FEH
;		BEQ	ENHB10
;; 					; Yes !
 ;		JSL	>ENBGCKL
;		LDA	ENCBFG,X
;		AND	#00001111B
;		BEQ	ENHB10
;;
;		CMP	#00000100B
;		BCS	ENHB01
;;
;		STZ	ENHNXS,X
;		STZ	ENXSPD,X
;		BRA	ENHB02
;ENHB01		EQU	$
;		STZ	ENHNYS,X
;		STZ	ENYSPD,X
;ENHB02		EQU	$
;;		LDA	ENXSPD,X
;;		BPL	ENHB01
;;		EOR	#0FFH
;;		INC	A
;;ENHB01		EQU	$
;;		STA	<WORK0
;;		LDA	ENYSPD,X
;;		BPL	ENHB02
;;		EOR	#0FFH
;;		INC	A
;;ENHB02		EQU	$
;;		LDY	#00H
;;		CMP	<WORK0
;;		BCS	ENHB03
;;;
;;		INY
;;ENHB03		EQU	$
;;		LDA	ENCBFG,X
;;		AND	HBCKBT,Y
;;		BEQ	ENHB04
;;		STZ	ENHNFG,X
;;ENHB04		EQU	$
;;		CPY	#00H
;;		BNE	ENHB05
;;		STZ	ENHNXS,X
;		BRA	ENHB08
;;ENHB05		EQU	$
;;		STZ	ENHNYS,X
;;		BRA	ENHB08
;ENHB10		EQU	$
;		JSR	ENMVCL
;ENHB08		EQU	$
;		PLA
;		STA	ENXSPD,X
;		PLA
;		STA	ENYSPD,X
;		PLA
;		PLA
;ENHB90		EQU	$
;		RTS
;-----------------------------------------------
;ENHLCK		EQU	$
;		LDA	ENCBFG,X
;		AND	#00010000B
;		BEQ	ENHC00
;HOLEDW		EQU	$
;		LDA	#EHOLE
;		STA	ENMODE,X
;		LDA	#80H
;		STA	ENTIM0,X
;		LDA	ENHNFG,X
;		BEQ	ENHC00
;		LDA	ENHNYS,X
;		STA	ENYSPD,X
;		LDA	ENHNXS,X
;		STA	ENXSPD,X
;ENHC00		EQU	$
;		RTS
;=========================================================
;========================================
SINDT2		EQU	$
; 0--127
		WORD	0000H,0003H,0006H,0009H,000CH,000FH,0012H,0015H
		WORD	0019H,001CH,001FH,0022H,0025H,0028H,0028H,002EH
		WORD	0031H,0035H,0038H,003BH,003EH,0041H,0044H,0047H
		WORD	004AH,004DH,0050H,0053H,0056H,0059H,005CH,005FH
		WORD	0061H,0064H,0067H,006AH,006DH,0070H,0073H,0075H
		WORD	0078H,007BH,007EH,0080H,0083H,0086H,0088H,008BH
		WORD	008EH,0090H,0093H,0095H,0098H,009BH,009DH,009FH
		WORD	00A2H,00A4H,00A7H,00A9H,00ABH,00AEH,00B0H,00B2H
		WORD	00B5H,00B7H,00B9H,00BBH,00BDH,00BFH,00C1H,00C3H
		WORD	00C5H,00C7H,00C9H,00CBH,00CDH,00CFH,00D1H,00D3H
		WORD	00D4H,00D6H,00D8H,00D9H,00DBH,00DDH,00DEH,00E0H
		WORD	00E1H,00E3H,00E4H,00E6H,00E7H,00E8H,00EAH,00EBH
		WORD	00ECH,00EDH,00EEH,00EFH,00F1H,00F2H,00F3H,00F4H
		WORD	00F4H,00F5H,00F6H,00F7H,00F8H,00F9H,00F9H,00FAH
		WORD	00FBH,00FBH,00FCH,00FCH,00FDH,00FDH,00FEH,00FEH
		WORD	00FEH,00FFH,00FFH,00FFH,00FFH,00FFH,00FFH,00FFH
;128--255
		WORD	0100H
		WORD	00FFH,00FFH,00FFH,00FFH,00FFH,00FFH,00FFH,00FEH
		WORD	00FEH,00FEH,00FDH,00FDH,00FCH,00FCH,00FBH,00FBH
		WORD	00FAH,00F9H,00F9H,00F8H,00F7H,00F6H,00F5H,00F4H
		WORD	00F4H,00F3H,00F2H,00F1H,00EFH,00EEH,00EDH,00ECH
		WORD	00EBH,00EAH,00E8H,00E7H,00E6H,00E4H,00E3H,00E1H
		WORD	00E0H,00DEH,00DDH,00DBH,00D9H,00D8H,00D6H,00D4H
		WORD	00D3H,00D1H,00CFH,00CDH,00CBH,00C9H,00C7H,00C5H
		WORD	00C3H,00C1H,00BFH,00BDH,00BBH,00B9H,00B7H,00B5H
		WORD	00B2H,00B0H,00AEH,00ABH,00A9H,00A7H,00A4H,00A2H
		WORD	009FH,009DH,009BH,0098H,0095H,0093H,0090H,008EH
		WORD	008BH,0088H,0086H,0083H,0080H,007EH,007BH,0078H
		WORD	0075H,0073H,0070H,006DH,006AH,0067H,0064H,0061H
		WORD	005FH,005CH,0059H,0056H,0053H,0050H,004DH,004AH
		WORD	0047H,0044H,0041H,003EH,003BH,0038H,0035H,0031H
		WORD	002EH,002BH,0028H,0025H,0022H,001FH,001CH,0019H
		WORD	0015H,0012H,000FH,000CH,0009H,0006H,0003H
;----		
;----		
;----		
		END
;
;----		
;----		
;----		Not use prog.	
;----		
;----		    0
;----		  0   0           
;----		00000	   0 0    0
;----		  0         0 0  0
;----		0 0 0           0 
;----	       0  0  0         0
;----		  0           0 
;----		
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
;==============================================
;==============================================
KTFXAD		EQU	$
;-- ishi --
		BYTE	000H,008H,000H,008H
		BYTE	0FEH,009H,0FFH,009H
		BYTE	0FCH,009H,0FFH,00AH
		BYTE	0FAH,009H,0FFH,00CH
		BYTE	0F9H,009H,0FEH,00DH
		BYTE	0F7H,009H,0FDH,00EH
		BYTE	0FCH,0FCH,009H,00FH
		BYTE	0FDH,0FDH,0FDH,009H
;-- kusa --
		BYTE	0FCH,004H,006H,00AH
		BYTE	0FFH,004H,006H,007H
		BYTE	000H,002H,004H,007H
		BYTE	001H,001H,005H,007H
		BYTE	000H,0FEH,008H,009H
		BYTE	0FFH,0FAH,009H,00AH
		BYTE	0FEH,0F9H,00CH,00BH
		BYTE	0FDH,0F7H,004H,006H
KTFYAD		EQU	$
		BYTE	000H,000H,008H,008H
		BYTE	000H,0FFH,00AH,00AH
		BYTE	000H,0FDH,00BH,007H
		BYTE	001H,0FCH,00CH,008H
		BYTE	001H,0FCH,00DH,009H
		BYTE	002H,0FCH,010H,00AH
		BYTE	010H-2,010H-2,0FEH-2,00DH-2
		BYTE	012H-2,012H-2,012H-2,001H-2
;
		BYTE	002H,0FBH,005H,001H
		BYTE	003H,0F9H,008H,002H
		BYTE	004H,0F8H,004H,00AH
		BYTE	0F7H,004H,004H,00CH
		BYTE	0F6H,004H,008H,00EH
		BYTE	0F4H,004H,008H,00FH
		BYTE	0F1H,003H,008H,011H
		BYTE	0EFH,001H,012H,00FH
KTFCDT		EQU	$
		BYTE	0FAH-0A2H,0FAH-0A2H,0FAH-0A2H,0FAH-0A2H
		BYTE	0FAH-0A2H,0FAH-0A2H,0FAH-0A2H,0FAH-0A2H ;,0FAH-0A2H
		BYTE	0FAH-0A2H,0FAH-0A2H,0FAH-0A2H,0FAH-0A2H ;,0FAH-0A2H
		BYTE	0FAH-0A2H,0FAH-0A2H,0FAH-0A2H,0FAH-0A2H ;,0FAH-0A2H
		BYTE	0EAH-0A2H,0FAH-0A2H,0FAH-0A2H,0FAH-0A2H ;,0FAH-0A2H
		BYTE	0EAH-0A2H,0FAH-0A2H,0FAH-0A2H,0EAH-0A2H ;,0EAH-0A2H
		BYTE	0EAH-0A2H,0EAH-0A2H,0FAH-0A2H,0EAH-0A2H ;,0EAH-0A2H
		BYTE	0EAH-0A2H,0EAH-0A2H,0EAH-0A2H,0EAH-0A2H ;,0EAH-0A2H
;
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H ;,0FBH-0A2H
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H ;,0FBH-0A2H
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H ;,0FBH-0A2H
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H ;,0FBH-0A2H
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H ;,0FBH-0A2H
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H ;,0FBH-0A2H
		BYTE	0FBH-0A2H,0FBH-0A2H,0FBH-0A2H,0FBH-0A2H ;,0FBH-0A2H
KTFADT		EQU	$
		BYTE	080H,000H,080H,040H
		BYTE	080H,040H,080H,000H
		BYTE	000H,0C0H,000H,080H
		BYTE	080H,040H,080H,000H
		BYTE	080H,0C0H,000H,080H
		BYTE	000H,000H,080H,000H
		BYTE	080H,080H,080H,080H
		BYTE	000H,000H,000H,000H
;
		BYTE	040H,040H,040H,000H
		BYTE	040H,040H,040H,000H
		BYTE	040H,040H,000H,000H
		BYTE	080H,000H,040H,040H
		BYTE	040H,000H,040H,040H
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,000H,000H
		BYTE	040H,000H,000H,000H
;KTFSBD		EQU	$
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;;
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;		BYTE	0,0,0,0
;;KDFXSD		EQU	$
;;		HEX	E0,20,E0,20
;;KDFYSD		EQU	$
;;		HEX	E0,E0,20,20
;;   OLD KUSA FAIL SUB ! -> endt E2MODE !
		LDA	ENTIM0,X
		BNE	KOF002
;
		STZ	ENMODE,X
KOF002		EQU	$
;;		PHA
;;		DEC	A
;;		BNE	KOF003
;;;
;;		JSR     CRITCK		; see thru item hit check !
;;KOF003		EQU	$
;;		PLA
		LSR	A
		LSR	A
		EOR	#00000111B
		STA	ENCTFG,X
;
;;		LDA	KEYA2
;;		AND	#00001100B
;;		BEQ	RERE
;;		INC	ENCTFG,X
;;		LDA	ENCTFG,X
;;		CMP	#08H
;;		BNE	RERE
;;		STZ	ENCTFG,X
;;RERE		EQU	$
KTOFCS		EQU	$
		JSR	OAMCHK
;
		LDA	OJBKFG
		CMP	#03H
		BCS	KFC010
;
		LDA	ENWRK2,X
		CMP	#03H
		BNE	KTOFF0		; small kusa ?
;
		JSR	KUSAFL
KFC010		EQU	$
		RTS
;
KTOFF0		EQU	$
		STA	ENHELP
		TAY
;;		CMP	#01H
;;		BNE	KTF022	        ; ishi ?
;;;					; yes !
;;		BIT	GRNDNO
;;		BVS	SAKANA		; omote ?
;;
;;KTF022		EQU	$		; yes !
		LDA	ENCTFG,X
		ASL	A
		ASL	A
;;		CLC
;;		ADC	ENCTFG,X
;;;;;;;;;		LDY	ENWRK2,X
		CPY	#04H
		BEQ	KTF006
		CPY	#02H
		BNE	KTFC08	; kusa ?
;
		LDY	<DJFLG
		BNE	KTFC08	; Danjyon tubo ?
KTF006		EQU	$	; no
		CLC
		ADC	#04H*8
KTFC08		EQU	$
		STA	<WORK6
;
		LDY	#00H
		PHX
		LDX	#03H
KOF010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	KTFXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	KTFYAD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	ENHELP
		BNE	KFS077	; Kanban ?
;				; yes !
		LDA	#4EH
		BRA	KFS078
;		
KFS077		EQU	$
		CMP	#80H
		LDA	KTFCDT,X
		BCC	KFS078		; Tail break ?
;					; yes !
		LDA	#0F2H
KFS078		EQU	$
		INY
		STA	(<OAMADR),Y
		LDA	KTFADT,X
		INY
;;		ORA	#2CH
		ORA	<WORK5
		STA	(<OAMADR),Y
;;		PHY
;;		TYA
;;		LSR	A
;;		LSR	A
;;		TAY
;;		LDA	KTFSBD,X
;;		STA	(<OSBADR),Y
;;		PLY
		INY
		PLX
		DEX
		BPL	KOF010
;
		PLX
		LDY	#00H
		LDA	#03H
		JSR	ALOMCK
		RTS
;==============================================
;- - - - - - - - - - - - - - - -
;SAKANA		EQU	$
;		PHX
;		LDA	ENCTFG,X		
;		ASL	A
;		AND	#11111100B
;		STA	<WORK6
;		LDY	#00H
;		LDX	#03H
;SKC010		EQU	$
;		PHX
;		TXA
;		CLC
;		ADC	<WORK6
;		TAX
;		LDA	<WORK0
;		CLC
;		ADC	SKCXAD,X
;		STA	(<OAMADR),Y
;		INY
;		LDA	<WORK2
;		CLC
;		ADC	SKCYAD,X
;		STA	(<OAMADR),Y
;		LDA	SKCCDT,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	SKCADT,X
;		ORA	<WORK5
;		INY
;		STA	(<OAMADR),Y
;		INY
;		PLX
;		DEX
;		BPL	SKC010
;		PLX
;		LDY	#00H
;		LDA	#03H
;		JSR	ALOMCK
;		RTS
;- - - - - - - - - - - - - - - - - - - - -
;SKCXAD		EQU	$
;		HEX	00,08,00,08
;		HEX	00,08,00,08
;		HEX	00,08,00,08
;		HEX	00,08,00,08
;SKCYAD		EQU	$
;		HEX	00,00,08,08
;		HEX	0B,0B,03,03
;		HEX	0B,0B,06,06
;		HEX	08,08,08,08
;SKCCDT		EQU	$
;		HEX	44,44,58,58
;		HEX	58,58,44,44
;		HEX	58,58,44,44
;		HEX	48,48,48,48
;SKCADT		EQU	$
;		HEX	00,40,00,40
;		HEX	00,40,00,40
;		HEX	00,40,00,40
;		HEX	00,40,00,40
;==============================================
KSFXAD		EQU	$
		BYTE	0F8H,008H,010H
		BYTE	0FBH,008H,00FH
		BYTE	0FFH,007H,00BH
		BYTE	001H,003H,008H
KSFYAD		EQU	$
		BYTE	007H,002H,00CH
		BYTE	009H,002H,00AH
		BYTE	00BH,002H,00BH
		BYTE	007H,003H,008H
KSFCDT		EQU	$
		HEX	E2,E2,E2
		HEX	E2,F2,F2
		HEX	F2,E2,E2
		HEX	F2,E2,E2
;
;;		HEX	49,49,49
;;		HEX	49,59,59
;;		HEX	59,49,49
;;		HEX	59,49,49
;
;;		BYTE	0E2H-0A2H,0E2H-0A2H,0E2H-0A2H
;;		BYTE	0E2H-0A2H,0F2H-0A2H,0F2H-0A2H
;;		BYTE	0F2H-0A2H,0E2H-0A2H,0E2H-0A2H
;;		BYTE	0F2H-0A2H,0E2H-0A2H,0E2H-0A2H
KSFADT		EQU	$
		BYTE	000H,000H,000H
		BYTE	000H,080H,040H
		BYTE	000H,080H,040H
		BYTE	000H,000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - - - -
KUSAFL		EQU	$
		LDA	ENTIM0,X
		CMP	#10H
		BNE	KSF000
;
		STZ	ENMODE,X
KSF000		EQU	$	
		AND	#0FH
		LSR	A
		LSR	A
		STA	<WORK6
		ASL	A
		ADC	<WORK6
		STA	<WORK6
;
		LDY	#00H
		PHX
		LDX	#02H
KSF010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	KSFXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	KSFYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	KSFCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	KSFADT,X
		INY
		ORA	#22H
		STA	(<OAMADR),Y
		INY
		PLX
		DEX
		BPL	KSF010
;
		PLX
		LDY	#000H
		LDA	#02H
		JSR	ALOMCK
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;% 			Night   									  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;---------------------------------------
TTN01MV		EQU	$
		LDA	ENCMKI,X
		PHA
		JSR	TN01MV
		PLA
		CMP	ENCMKI,X
		BEQ	T00010
		EOR	ENCMKI,X
		CMP	#01H
		BNE	T00010		; muki chenge ?
;								; yes
		LDA	#08H
		STA	ENTUTM,X
T00010		EQU	$
		JSR	ENHLCK		; Hole down check
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%          NIGHT MOVE   									 %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;
TTXSDT		EQU	$
;			BYTE	000H,008H,0F8H,000H,000H,006H,0FAH,000H
;			BYTE	000H,006H,0FAH,000H,000H,000H,000H,000H
		BYTE	008H,0F8H,00H,00H
TTYSDT		EQU	$
;			BYTE	000H,000H,000H,000H,008H,006H,006H,000H
;			BYTE	0F8H,0FAH,0FAH,000H,000H,000H,000H,000H
		BYTE	000H,000H,008H,0F8H
TTCMDT		EQU	$
;			BYTE	000H,000H,001H,000H,002H,000H,001H,000H
;			BYTE	003H,000H,001H,000H,000H,000H,000H,000H
TTNXMK		EQU	$
;			BYTE	01H,02H,04H,08H
		BYTE	00H,01H,02H,03H
TTWKMD		EQU	$
		BYTE	00H,06H,12H,0CH
;;;		BYTE	00H,05H,0FH,0AH
TNTUMD		EQU	$
		BYTE	03H,03H,01H,01H
;----------------------------------------------------
TN01MV		EQU	$
		LDY	ENCMKI,X
		LDA	ENTUTM,X
		BEQ	TN01M0		; Turn ?
		LDA	TNTUMD,Y	; yes half pause set !
		TAY
TN01M0		EQU	$
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDA	TTWKMD,Y
		ADC	#00H
		STA	ENCHPT,X
;--------------------------------
 		JSR	TTN01CS
		JSR	ENSTCK
		JSR	CRKNKN		; ken vs ken !
;;;;;;;;;;;;		JSR	PLHNCK		; Player hani check !
;
;-- TEST ---
;			LDA		KEYA2
;			AND		#01000000B
;			BEQ		TS00
;			INC		ENCHPT,X
;			LDA		ENCHPT,X
;			CMP		#18H
;			BCC		TS00
;			STZ		ENCHPT,X
;TS00		EQU		$
;		LDA	KEYA2
;		AND	#00000011B
;		BEQ	TSF0
;		LDA	ENCMKI,X
;		INC	A
;		AND	#03H
;		STA	ENCMKI,X
;TSF0		EQU	$
;		LDA	KEYA2
;		AND	#00001000B
;		BEQ	TS10
;		INC	ENCTFG,X
;		LDA	ENCTFG,X
;		CMP	#0CH
;		BNE	TS10
;		LDA	#07H
;		STA	ENCTFG,X
;TS10		EQU	$
;		RTS
;------------------------------------------------
;;;		LDA	<GAMEMD
;;;		BEQ	TN0000      ; scrool ?
;;;;
;;;		RTS
;;;;			JMP		>TTN01CS	; move stop !
TN0000		EQU	$
		LDA	ENHNFG,X
		BEQ	TN0001		; Hanekaeri ?
;---------------------------------------
		CMP	#01H
		BNE	TN0E00
		LDA	<KENMD
		BEQ	TN0E00
		JSL	>RNDSET
		AND	#0FH
		BNE	TN0E00
		INC	ENATCT,X
TN0E00		EQU	$
		JSR	TNHNSB
		JSR	CRTNTN		; Vs night
;
		JSR	EPXYCK
		TYA
		STA	ENCMKI,X
;
;;;; 		RTS
;---------------------------------------
TN0001		EQU	$
		LDA	ENCTCT,X
		BEQ	TCT010        ; do cut ?
;
		LDA	ENCTFG,X	  ; yes
		BNE	TCT010        ; already cut ?
;							      ; no	
		DEC	ENCTCT,X
		LDA	#01H
		STA	ENCTFG,X
;
		LDA	#02H
		LDY	ENSTAT,X
		BNE	TCT008
		INC	A
TCT008		EQU	$
		STA	ENTIM1,X
TCT010		EQU	$
		JSR	CRTNPL		;Cros palyer vs enemy !
;-  -  -  -  -  -  -  -  -  -  -  -  -  -  
		LDA	ENSTAT,X
		BEQ	TTWALK
		CMP	#02H
		BEQ	TTM010
		JMP	>TTATCK
TTM010		EQU	$
		JMP	>TTSTOP
;;			JSL		>JSRSUB
;;			WORD	TTWALK
;;			WORD	TTATCK
;===========================================================
TTWALK		EQU	$
		INC	ENCONT,X
; 
		LDA	ENTIM0,X
		BEQ	TN0010
;
		STZ	ENYSPD,X
		STZ	    ENXSPD,X
		STZ	ENCONT,X
		CMP	#01H
		BNE	TN0008
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	TTNXMK,Y
		STA	ENMUKI,X
TN0008		EQU	$
		BRA	TN0020
TN0010		EQU	$
		LDA	ENHNFG,X
		BNE	TN0021
;
		LDY	ENMUKI,X
		LDA	    TTXSDT,Y
		STA	ENXSPD,X
		LDA	TTYSDT,Y
		STA	    ENYSPD,X
;;;;;;;;	     LDA		TTCMDT,Y
		TYA
		STA	ENCMKI,X
		JSR	ENMVCL
		JSR	ENBGCK
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	TN0020
		JSR	TTMKCG
TN0020		EQU	$
		JSR	TTPLCK		; Player position check
;;;;;			JSR		TTN01CS
TN0021		EQU	$
		RTS
;-----------------------------------
TTATST		EQU	$
		LDY	#0FH
TTAS20		EQU	$
		LDA	ENMODE,Y
		CMP	#EMOVE
		BNE	TTAS30
		LDA	ENSTAT,Y
		CMP	#01H
		BEQ	TTAS90
TTAS30		EQU	$
		DEY
		BPL	TTAS20		; alredy enemy fighting ?
;								; no.
		LDA	#01H
		STA	ENSTAT,X
		STZ	ENWRK0,X
		LDA	#050H
		STA	ENTIM0,X
TTDUSH		EQU	$
		LDA	#10H
		JSR	PSERCH
;;			LDA		<WORK0
;;			STA		ENYSPD,X
;;			LDA		<WORK1
;;			STA		ENXSPD,X
TTAS90		EQU	$
		RTS
;===========================================================
TTATED		EQU	$
		STZ	ENSTAT,X
		RTS
;- - - - ---- - - - - - - --- ---
TTATCK		EQU	$
;;		LDA	ENWRK0,X
;;		CMP	#05H
;;		BEQ	TA0F0
;;;
;;		LDA	ENHNFG,X
;;		BNE	TTAS90
;;;
;;TA0F0		EQU	$
		LDA	ENDSPL,X
		BNE	TTATED
;
		JSR	EPXYCK
;
		LDA	<KENMD
		CMP	#09H
		BCC	TA000		; player kamae ?
;
		LDA	<WORKE
		CLC
		ADC	#40H
		CMP	#080H
		BCS	TA0F0
		LDA	<WORKF
		CLC
		ADC	#40H
		CMP	#080H
		BCS	TA0F0
;
		LDA	ENWRK0,X
		CMP	#05H
		BEQ	TA0F8		; first kamae ?
;					; yes !
		LDA	#05H
		STA	ENWRK0,X
		STZ	ENWRK1,X
		LDA	#0CH
		STA	ENTIM2,X
		LDA	#01H
		STA	ENCTCT,X
		BRA	TA000
TA0F0		EQU	$
		LDA	#02H
		STA	ENCTCT,X
		BRA	TA000
TA0F8		EQU	$		
		LDA	#10H		; yes ! 
		STA	ENTIM0,X
TA000		EQU	$
		LDA 	ENTIM0,X
		BEQ	TTATED
;
;;;		JSR	EPXYCK
		TYA
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		LDA	ENHNFG,X
		BNE	TAT000
		JSR	ENBGCK
;
		LDA	ENCBFG,X
		AND	#0FH
		BEQ	TAT000
;
		LDY	ENWRK0,X
		BNE	TTATED		; Dush ?
;									; yes !
		LDA	#01H
		LDY	ENXSPD,X
		BPL	TAT014
		ASL	A
TAT014		EQU	$
		AND	ENCBFG,X
		BEQ	TAT016
		STZ	ENXSPD,X
TAT016		EQU	$
		LDA	#00000100B
		LDY	ENYSPD,X
		BPL	TAT017
		ASL	A
TAT017		EQU	$
		AND	ENCBFG,X
		BEQ	TAT018
		STZ	ENYSPD,X
TAT018		EQU	$
;;			JSR		TTDUSH
;;;
;;			LDA		<WORK0
;;			STA		ENXSPD,X
;;			LDA		<WORK1	
;;			STA		ENYSPD,X			
TAT020		EQU	$
;;;		BRA	TAT000
;-----------------------------------			
;;TTATED		EQU	$
;;		STZ	ENSTAT,X
;;		RTS
;----------------------------------------------
TAT000		EQU	$
		LDA	ENWRK0,X
		JSL	>JSRSUB
		WORD	TAT100		;Dush!!
		WORD	TAT200      ;Atack 1
		WORD	TAT300      ;Atack 2
		WORD	TAT400		;Atack 3
		WORD	TAT500		;Timer wait !
		WORD	TAT600		;TSUKKOMI !
;-----------------------------------------
TAT600		EQU	$
		LDA	ENHNFG,X
		BNE	TAT650
;
		LDA	#10H
		JSR	PSERCH
		JSR	ENMVCL
;
TAT650		EQU	$
		LDA	ENWRK1,X
		BNE	TAT680		; Kamae ready (cutting) ?
;
		LDA	ENTIM2,X	; yes !
		BNE	TAT660		; cut end ?
;					; yes !
		INC	ENWRK1,X
TAT660		EQU	$
		RTS
;
TAT680		EQU	$		; kamae !
		LDA	ENCTFG,X
		BEQ	TAT688
;;		CMP	#07H
;;		BCC	TAT690		; already cutting ?
		BNE	TAT690
TAT688          EQU	$		; no.
		LDA	#05H
		STA	ENTIM1,X
		LDA	#07H
		STA	ENCTFG,X
TAT690		EQU	$
		RTS
;-----------------------------------------
TTATMD		EQU	$
		BYTE	01H,02H,03H,01H
;
TAT100		EQU	$
		JSR	EPXCHK
		LDA	<WORKF
		CLC
		ADC	#18H
		CMP	#30H
		BCS	TAT120
		JSR	EPYCHK
		LDA	<WORKE
		CLC
		ADC	#18H
		CMP	#30H
		BCS	TAT120		; Near Player ?
;								; yes !
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	TTATMD,Y
		STA	ENWRK0,X	;Atack start !!
		STZ	ENWRK1,X
		STZ	ENATCT,X
TAT120		EQU	$
		INC	ENCONT,X
		INC	ENCONT,X
;
		LDA	ENHNFG,X
		BNE	TTAT20
		JSR	ENMVCL
;;			JSR		ENBGCK
;;			LDA		ENCBFG,X
;;			AND		#00001111B
;;			BNE		TTATED
TTAT20		EQU	$
;;;;			JSR		TTN01CS
		RTS
;;TTATED		EQU		$			
;;			STZ		ENSTAT,X
;;			BRA		TTAT20
;===========Mawarikomi==============================================
PLMKCK2		EQU	$
		BYTE	04H,06H,00H,02H
TTSHXL		EQU	$
		BYTE	0E0H,000H,020H,000H
TTSHXH		EQU	$
		BYTE	0FFH,000H,000H,000H
TTSHYL		EQU	$
		BYTE	000H,0E0H,000H,020H
TTSHYH		EQU	$
		BYTE	000H,0FFH,000H,000H
;- - - - - - - - - - - - - - - -
;
TAT200		EQU	$		; Mawarikomi !!
		LDA	ENHNFG,X
		BNE	TA2128
		LDA	ENWRK1,X
		JSL	>JSRSUB
		WORD	TA2100
		WORD	TA2200
;;			WORD	TA2300
;;			WORD	TA2400
;-----------------------------------------------------
TA2100		EQU	$
		INC	ENCONT,X
		INC	ENCONT,X
;
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#02H
		CMP	#04H
		BCC	TA2110		; AtacK point ?
;
		LDA	<WORKF
		CLC
		ADC	#02H
		CMP	#04H
		BCS	TA2120		; Atack point ?
;
TA2110		EQU	$		; yes !
;;			TYA
;;			ASL		A
		LDA	PLMKCK2,Y
		CMP	PLMKCH
		BEQ	TA2120      ; muki ok ?
		JMP	>TA2130     ; yes ! atack !
;------------------------------;
TA2120		EQU	$
		LDA	#18H
		JSR	PSERCH
		LDA	ENXSPD,X
		PHA
		LDA	ENYSPD,X
		STA	ENXSPD,X
		PLA
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		JSR	ENMVCL
;;			JSR		ENBGCK
;;			LDA		ENCBFG,X
;;			AND		#0FH
;;			BNE		TA2END
TA2128		EQU	$
		RTS
;--------------------------------------
TA2130		EQU	$
		INC	ENWRK1,X
		LDA	#18H
		JSR	PSERCH
;;			LDA		WORK0
;;			STA		ENYSPD,X
;;			LDA		WORK1
;;			STA		ENXSPD,X
		LDA	#08H
		STA	ENTIM2,X
		RTS
;- - - - - - - - - - - - - - - - -
TA2200		EQU	$
		LDA	ENTIM2,X
		BEQ	TA2280
;
;;			LDA		ENCBFG,X
;;			AND		#0FH
;;			BEQ		TA2210
;;			JMP		>TA2END
;;TA2210		EQU		$
		JSR	ENMVCL
;;			JSR		ENBGCK
		RTS
;;TA2END		EQU		$
;;TA2ED2		EQU		$			; y
;;			STZ		ENWRK0,X
;;TA2220		EQU		$
;;			RTS
TA2280		EQU	$
		LDA	#01H
		STA	ENCTCT,X
TATEND		EQU	$
		LDA	#30H
		STA	ENTIM2,X
		LDA	#04H
		STA	ENWRK0,X
;;;			STZ		ENSTAT,X
		RTS
;===========Furimawashi==============================================
TAT300		EQU	$
		LDA	ENHNFG,X
		BNE	TA3120
		LDA	ENWRK1,X
		JSL	>JSRSUB
		WORD	TT3100
		WORD	TT3200
;
TT3100		EQU	$
		JSL	>RNDSET
		AND	#3FH
		ORA	#40H
		STA	ENTIM2,X
		INC	ENWRK1,X
TA3120		EQU	$
		RTS
;------------------------------------
TT3200		EQU	$
		LDA	ENTIM2,X
		BEQ	TT3300
;
		LDA	#04H
		JSR	PSERCH
		JSR	ENMVCL
		LDA	#01H
		STA	ENCTCT,X
		JSR	EPXYCK		; yes !
		TYA
		STA	ENMUKI,X
		STA	ENCMKI,X
		RTS
;------------------------------------
TT3300		EQU	$
		JMP	    >TATEND
;===========Iaigiri==============================================
TAT400		EQU	$
		LDA	#01H
		STA	ENCTCT,X
		JMP	>TATEND
;
;===========Wait=======================================================
TAT500		EQU	$
		LDA	ENTIM2,X
		BNE	TA2310
;
		STZ	ENSTAT,X
TA2310		EQU	$
		RTS
;------------------------------------------------------
TNHNSB		EQU	$	; for Knight 
		LDA	ENYSPD,X
		PHA
		LDA	ENXSPD,X
		PHA
		DEC	ENHNFG,X
		LDA	ENHNFG,X
		LSR 	A
		LSR 	A
		LSR 	A
		TAY
		LDA	<FRCNT
		AND	TNHNTM,Y
		BNE	TNH008																
		LDA	ENHNYS,X
		STA	ENYSPD,X
		LDA	ENHNXS,X
		STA	ENXSPD,X
  		JSR	ENBGCK
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	TNH010
;
		STZ	ENHNFG,X
		BRA	TNH008
TNH010		EQU	$
		JSR	ENMVCL
TNH008		EQU	$
		PLA
		STA	ENXSPD,X
		PLA
		STA	ENYSPD,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%			       			  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TTHDCD		EQU	$
		BYTE	84H,82H,80H,82H,84H,82H,80H,82H
                BYTE	80H,82H,84H,82H,80H,82H,84H,82H
		BYTE	82H,80H,82H,80H,82H,80H,82H,80H
		BYTE	82H,84H,82H,84H,82H,84H,82H,84H
TTHDAD		EQU	$
		BYTE	00H,40H,00H,40H,00H,40H,00H,40H
		BYTE	00H,00H,00H,00H,00H,00H,00H,00H
		BYTE	00H,00H,40H,00H,00H,00H,40H,00H
		BYTE	40H,00H,00H,00H,40H,00H,00H,00H
TTSTOP		EQU	$	; Kubi furifuri !
		JSR	EPXYCK
		JSR	SPATST		; SPECIAL ATACK SET !
;
		LDA	ENTIM0,X
		BEQ	TSTEND
;
		LDY	ENCTFG,X
		BNE	TST0A0
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ADC	<WORK0
;;;		LDY	ENOMID,X
		LDY	#00H
		TAX
		LDA	TTHDCD,X
		STA	OAM+02H,Y
		LDA	OAM+03H,Y
		AND	#00111111B
		ORA	TTHDAD,X
		STA	OAM+03H,Y
		JSR	TTPLCK
		LDX	ENINDX
		RTS
TSTEND		EQU	$
		STZ	ENSTAT,X
;;		JSR	EPXYCK
;;		JSR	SPATST		; SPECIAL ATACK SET !
TST0A0		EQU	$
		RTS
;=========================================
;- - - - - - - - 
TTMKCG		EQU	$
		LDA	#02H
		STA	ENTIM0,X
		RTS
TTPLCK		EQU	$
		LDA	HANEFG
		BNE	TPCRTS
;
		TXA
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CMP	<FRCNT
		BNE	TTPC00
;
		JSL	>RNDSET
		AND	#01H
		BNE	TTPC00
		LDA	#02H
		STA	ENSTAT,X
		JSL	>RNDSET
		AND	#3FH
		ORA	#40H
		STA	ENTIM0,X
		RTS
;-----------------------------------------
TTPC00		EQU	$
;;			LDA		<FRCNT
		LDA	ENDSPL,X
		BNE	TPCRTS
;
		JSR	EPXYCK
;;;;			STY		<WORK0
;
 		TXA
		LSR	A
		ROR	A
		ROR	A
		ADC	<FRCNT
;;;;			LDA		ENCONT,X
		AND	#00100000B
		BNE	TPC010		; Enemy Block ?
;
		LDA	<WORKF
		CLC
		ADC	#18H
		CMP	#30H
		BCS	TPC010
;;			JSR		EPYCHK
		LDA	<WORKE
		CLC
		ADC	#18H
		CMP	#30H
		BCS	TPC010		; Player atack area ?
;									; yes !
		LDA	<WORK0
		STA	ENMUKI,X
		STA	ENCMKI,X
		LDA	#01H
		STA	ENCTCT,X
TPCRTS		EQU	$
		RTS
;---------------------------------------------
TPC010		EQU	$
		INC	ENWRK2,X
		LDA	ENWRK2,X
		BNE	TPC011
;								; Sometime ken furi !
		JSL	>RNDSET
		AND	#03H
		BNE	TPC011
;
		LDA	ENCTCT,X
		INC	A
		STA	ENCTCT,X
TPC011		EQU	$
		LDA	ENWRK2,X
		AND	#01FH
		BNE	TPL090     ; special time ?    
;                              ; yes !
;;;			JSR		EPXCHK
SPATST		EQU	$
		LDA	<WORKF
		CLC
		ADC	#50H
		CMP	#0A0H
		BCS	TPL090
;
;;;			JSR		EPYCHK
		LDA	<WORKE
		CLC
		ADC	#50H
		CMP	#0A0H
		BCS	TPL090
;
		JSL	>RNDSET
		AND	#00H
		BNE	TPL0A0     ; 
;
		JSR	TTATST
TPL090		EQU	$
		RTS
TPL0A0		EQU	$
		JMP	>TTMKCG
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%          Night character set								 %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    	
TNHDCD		EQU	$
;;;;;;;;;;              --walk-- | ---- cut -----             
		BYTE	082H,082H,082H,082H,082H,082H
		BYTE	082H,082H,082H,082H,082H,082H
		BYTE	084H,084H,084H,084H,084H,084H
		BYTE	080H,080H,080H,080H,080H,080H
TNBDCD		EQU	$
		BYTE	0A4H,0A6H,0A8H,0AAH,0ACH,0AEH
		BYTE	0A4H,0A6H,0A8H,0AAH,0ACH,0AEH
		BYTE	0A2H,0A2H,086H,088H,08AH,0C4H
		BYTE	0A0H,0A0H,08CH,08EH,0AEH,0C6H
TNHDXD		EQU	$
		BYTE	000H,000H,000H,001H,002H,001H
		BYTE	000H,000H,000H,0FFH,0FEH,0FFH
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
TNHDYD		EQU	$
		BYTE	000H,001H,001H,001H,001H,001H
		BYTE	000H,001H,001H,001H,001H,001H
		BYTE	000H,000H,000H,000H,000H,0FFH
		BYTE	001H,001H,000H,000H,002H,001H
TNATDT		EQU	$
		BYTE	040H,040H,040H,040H,040H,040H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,040H,000H,000H,000H,000H
		BYTE	000H,040H,000H,000H,000H,000H
;--------------------------------------------------------
TTN01CS		EQU	$
		JSR	OAMCHK
		JSR	TNCSUB
;;		LDA	ENOMID,X
		LDY	#00H
		CLC
		ADC	#14H
		TAY
		JSR	SADWST
		RTS
;---------------------------------------
TNCSUB		EQU	$
;;;		BRA	TCC010
;
		LDA	ENCTFG,X
		BEQ	TNC010		; Cut ?
;
		LDY	ENTIM1,X	; yes !
		BNE	TCC010
		INC	ENCTFG,X
		CMP	#07H
		LDA	#02H
		BCC	TCC003		; Tsuki tsuki ?
		LDA	#05H		; yes !
TCC003		EQU	$
		LDY	ENSTAT,X
		BNE	TCC008
		INC	A
TCC008		EQU	$
		STA	ENTIM1,X
		LDA	ENCTFG,X
;;;;;		CMP	#0AH
		CMP	#0AH
		BEQ	TCC00A
		CMP	#07H
		BNE	TCC010
TCC00A		EQU	$
		STZ	ENCTFG,X
		BRA	TNC010
TCC010		EQU	$
		JMP	>TTCTCS		; Cutting !
;----------------------------------------
TNC010		EQU	$
		LDA	ENSTAT,X
		CMP	#01H
		BNE	TNC018		; Kamae ?
;
		LDA	ENCHPT,X   	; yes !
    		AND	#01H
		CLC
		ADC	#0AH
		STA	ENCTFG,X
		JSR	TTCTCS
		STZ	ENCTFG,X
		RTS
;-------------------------------------
TNC018		EQU	$
;;;;		JSR	OAMCHK
;;		LDY	ENOMID,X
		LDY	#00H
TNC020		EQU	$
;;		LDA	ENFLSH,X
;;		ASL	A
;;		AND	#00001110B
;;		STA	<WORK0		; Color flash set !
		LDA	ENCLOR,X
		STA	<WORK0
;
		LDA	ENCHPT,X
		TAX
		LDA	ENDSXL
		STA	OAM+04H,Y
		CLC
		ADC	TNHDXD,X
		STA	OAM+00H,Y
		LDA	ENDSYL
		CLC
;;		SEC
;;   		CPX	#0DH
;;;;;		CPX	#0BH
;;		BEQ	TNC070		; Up down swing !
;;		CPX	#13H
;;;;;             CPX     #10H
;;		BEQ	TNC070
;;		CLC
;;TNC070		EQU	$
;;		PHP
		ADC	TNHDYD,X
		STA	OAM+01H,Y
;;		LDA	ENDSYL
;;		PLP
		CLC
		ADC	#08H
		STA	OAM+05H,Y
;
		LDA	TNHDCD,X
		STA	OAM+02H,Y
		LDA	TNBDCD,X
		STA	OAM+06H,Y
		LDA	TNATDT,X
;;;		ORA	#20H
		EOR	<WORK0
		STA	OAM+07H,Y
		CPX	#0CH
		BCC	TNC078
		AND	#10111111B
TNC078		EQU	$
		STA	OAM+03H,Y	; HEAD
		LDX	ENINDX
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	ENDSPL,X
		STA	OAMSB+00H,Y
		STA	OAMSB+01H,Y
		RTS
;==================================================
CTMKAD		EQU	$
		BYTE	16H,0BH,00H,21H
KNCTMD		EQU	$
;;;;;;;;;;;;;;             1    2    3    4    5    6 |  7    8    9|  A   B
		BYTE	000H,009H,00AH,00BH,00CH,00DH,016H,017H,018H,018H,018H
		BYTE	006H,004H,003H,002H,001H,000H,010H,011H,012H,012H,012H 
		BYTE	002H,004H,005H,006H,007H,008H,013H,014H,015H,015H,015H
		BYTE	008H,007H,006H,005H,004H,003H,019H,01AH,01BH,01BH,01BH
KNCXAD		EQU	$
		BYTE	0F8H,0F8H,0FCH,003H,008H,00AH,007H,00CH,007H,007H,007H
		BYTE	004H,003H,0FEH,0F7H,0F5H,0F4H,0F2H,0F3H,0FAH,0FAH,0FAH
		BYTE	0FCH,005H,00AH,009H,00BH,00CH,00EH,00DH,006H,006H,006H
		BYTE	00BH,00AH,008H,008H,0FFH,0FCH,0FFH,0FDH,002H,002H,002H
KNCYAD		EQU	$
		BYTE	000H,00EH,00CH,010H,012H,00FH,00FH,00CH,012H,012H,012H
		BYTE	004H,000H,003H,005H,001H,004H,00BH,00FH,00CH,00CH,00CH
		BYTE	004H,000H,003H,005H,001H,004H,00BH,00FH,00CH,00CH,00CH
		BYTE	002H,0FDH,001H,0FDH,0FAH,0FDH,0FFH,003H,0F9H,0F9H,0F9H
KNOMAD		EQU	$
		BYTE	000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H
		BYTE	008H,008H,008H,008H,000H,000H,000H,000H,000H,000H,000H
		BYTE	008H,008H,008H,008H,000H,000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,008H,008H,008H,008H,008H,008H,008H,008H,008H
KNBODY		EQU	$
		BYTE	014H,014H,015H,015H,016H,016H,016H,017H,016H,012H,013H
		BYTE	008H,008H,009H,009H,00AH,00AH,00AH,00AH,006H,006H,007H
		BYTE	002H,002H,003H,003H,004H,004H,004H,004H,000H,000H,001H
		BYTE	00EH,00EH,00FH,00FH,010H,010H,011H,011H,010H,00CH,00DH
;------------------------------------------
TTCTCS		EQU	$
		JSR	OAMCHK
		LDY	ENCMKI,X
		LDA	ENCTFG,X
		CLC
		ADC	CTMKAD,Y
		TAY
		PHY
		LDA	KNCXAD-1,Y
		STA	<WORK0
		LDA	KNCYAD-1,Y
		STA	<WORK1
		LDA	KNCTMD-1,Y
		STA	<WORK2
		LDA	KNOMAD-1,Y
		STA	<WORK3
;
		JSR	TTKNCS
		PLY
		LDA	KNBODY-1,Y
		STA	ENCHPT,X
;;;		LDA	ENOMID,X
		LDA	#00H
		LDY	WORK3
		BNE	TTC010
		CLC
		ADC	#0CH
TTC010      EQU	$
		TAY
		JMP	>TNC020
;-----------------------------------------------
TTKNXD		EQU	$          ;  |              |              |
		BYTE	000H,008H,0FFH,000H,008H,0FFH,000H,008H,008H,000H,000H,0FFH
		BYTE	000H,000H,0FFH,000H,000H,0FFH,008H,000H,000H,008H,000H,0FFH
		BYTE	008H,000H,0FFH,000H,008H,0FFH,000H,008H,008H,000H,000H,0FFH
		BYTE	000H,000H,0FFH,000H,000H,0FFH,008H,000H,000H,008H,000H,0FFH
		BYTE	000H,008H,00EH,000H,008H,00EH,000H,008H,00AH
		BYTE	008H,000H,0FAH,008H,000H,0FAH,008H,000H,0FEH
		BYTE	000H,000H,001H,000H,000H,080H,000H,000H,002H
		BYTE	000H,000H,000H,000H,000H,080H,000H,000H,0FEH
TTKNYD		EQU	$								
		BYTE	008H,008H,080H,008H,008H,080H,000H,000H,008H,000H,008H,080H
		BYTE	000H,008H,080H,000H,008H,080H,000H,000H,008H,008H,008H,080H
		BYTE	008H,008H,080H,000H,000H,080H,008H,008H,000H,008H,000H,080H
		BYTE	008H,000H,080H,008H,000H,080H,008H,008H,000H,008H,008H,080H
		BYTE	000H,000H,000H,000H,000H,0FEH,000H,000H,001H
		BYTE	000H,000H,000H,000H,000H,0FEH,000H,000H,001H
		BYTE	008H,000H,0F9H,008H,000H,080H,008H,000H,0FBH
		BYTE	000H,008H,00CH,000H,008H,080H,000H,008H,00CH
TTKNCD		EQU	$                                                          
		BYTE	018H,019H,000H,008H,009H,000H,006H,007H,017H,00AH,01AH,000H
		BYTE	005H,015H,000H,00AH,01AH,000H,006H,007H,017H,008H,009H,000H
		BYTE	018H,019H,000H,008H,009H,000H,006H,007H,017H,00AH,01AH,000H
                BYTE	005H,015H,000H,00AH,01AH,000H,006H,007H,017H,008H,009H,000H
		BYTE	018H,019H,0CBH,018H,019H,0DBH,008H,009H,0FCH
		BYTE	018H,019H,0CBH,018H,019H,0DBH,008H,009H,0FCH
		BYTE	005H,015H,0DAH,005H,015H,000H,00AH,01AH,0CAH
		BYTE	005H,015H,0DCH,005H,015H,000H,00AH,01AH,0CCH           
TTKNAD		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,040H,040H,040H
		BYTE	040H,080H,080H,080H
		BYTE	080H,0C0H,0C0H,0C0H
		BYTE	000H,000H,000H
		BYTE	040H,040H,040H
		BYTE	080H,080H,080H
		BYTE	000H,000H,040H
;
TTKNCS		EQU	$
;;		LDA	ENOMID,X
		LDA	#00H
		CLC
		ADC	<WORK3
		TAY
		LDA	<WORK2
		ASL	A
		ADC	<WORK2
		TAX
		LDA	ENDSXL
		CLC
		ADC	<WORK0
		PHA
		PHA
		CLC
		ADC	TTKNXD,X
		STA	OAM+00H,Y
		SEC
		SBC	ENDSXL
		STA	ENKNXP
		PLA
		CLC
		ADC	TTKNXD+1,X
		STA	OAM+04H,Y
		PLA
		CLC
		ADC	TTKNXD+2,X
		STA	OAM+08H,Y
;
		LDA	ENDSYL
		CLC
		ADC	<WORK1
		PHA
		STA	<WORK1
		CLC
		ADC	TTKNYD,X
		STA	OAM+01H,Y
		SEC
		SBC	ENDSYL
		STA	ENKNYP
		PLA
		CLC
		ADC	TTKNYD+1,X
		STA	OAM+05H,Y
		LDA	TTKNYD+2,X
		CMP	#80H
		BEQ	TKC030
		CLC
    		ADC	<WORK1
		STA	OAM+09H,Y
;
TKC030		EQU	$
		LDA	TTKNCD,X
		STA	OAM+02H,Y
		LDA	TTKNCD+1,X
		STA	OAM+06H,Y
		LDA	TTKNCD+2,X
		STA	OAM+0AH,Y
;
		STZ	<WORK0
		BPL	TKC040
		LDA	#06H+1
		STA	<WORK0
TKC040		EQU	$
;
;;;;			EOR		#80H
;;;;			ASL		A
;;;;			PHP
		LDX	<WORK2
		LDA	TTKNAD,X
;;;;			CLC
		ORA	#04H
		STA	OAM+03H,Y
		STA	OAM+07H,Y
;;;;			PLP
		ORA	<WORK0
		STA	OAM+0BH,Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDX	ENINDX
		LDA	#00H
		ORA	ENDSPL,X
		STA	OAMSB+00H,Y
		STA	OAMSB+01H,Y
		STA	OAMSB+02H,Y
		RTS 
;
;
;			JSR		OAMCHK
;			LDY		ENOMID,X
;			LDA		ENXPSL,X
;			SEC
;			SBC		SCCH2
;			STA		OAM2+00H,Y
;			LDA		ENYPSL,X
;			SEC
;			SBC		SCCV2
;			STA		OAM2+01H,Y
;			LDA		#0E8H
;			STA		OAM2+02H,Y
;			LDA		ENCONT,X
;			LSR	    A
;			LSR		A
;			LSR		A
;			LSR		A
;			LDA		#2AH
;			BCC		TNC010
;			ORA		#01000000B
;TNC010		EQU		$
;			STA		OAM2+03H,Y			
;			TYA
;			LSR	    A
;			LSR		A
;			TAY
;			LDA		#02H
;			ORA		WORKF
;			STA		OAMSB2+00H,Y
;			RTS
;-----------------------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		keronpa                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
MNYSLM		EQU	$
MNXSLM		EQU	$
		BYTE	018H,0E8H
MNYSAD		EQU	$
MNXSAD		EQU	$
		BYTE	001H,0FFH
;
MANY1MV		EQU	$
		JSR	MANY1CS
;
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	ENTIM0,X
		BNE	MNM00C
;
		JSL	>RNDSET
		AND	#3FH
		ADC	#40H
		STA	ENTIM0,X
;;		AND	#03H
;;		BEQ	MNM008
;
		JSL	>RNDSET
		AND	#7FH
		ADC	#40H
		CLC
		ADC	<SCCH2
		STA	ENWRK1,X
		LDA	<SCCH2+1
		ADC	#00H
		STA	ENWRK0,X
;
		JSL	>RNDSET
		AND	#7FH
		ADC	#40H
		CLC
		ADC	<SCCV2
		STA	ENWRK2,X
		LDA	<SCCV2+1
		ADC	#00H
		STA	ENSTAT,X
;;		BRA	MNM00C
;;MNM008		EQU	$
;;		LDA	<PLXPS1
;;		STA	ENWRK1,X
;;		LDA	<PLXPS0
;;		STA	ENWRK0,X
;;		LDA	<PLYPS1
;;		STA	ENWRK2,X
;;		LDA	<PLYPS0
;;		STA	ENSTAT,X
;;;
MNM00C		EQU	$
		LDY	#00H
		LDA	ENWRK1,X
		CMP	ENXPSL,X
		LDA	ENWRK0,X
		SBC	ENXPSH,X
		BCS	MNM010
		INY
MNM010		EQU	$
		LDA	ENXSPD,X
		CMP	MNXSLM,Y
		BEQ	MNM020
		CLC
		ADC	MNXSAD,Y
		STA	ENXSPD,X
MNM020		EQU	$
;
		LDY	#00H
		LDA	ENWRK2,X
		CMP	ENYPSL,X
		LDA	ENSTAT,X
		SBC	ENYPSH,X
		BCS	MNM030
		INY
MNM030		EQU	$
		LDA	ENYSPD,X
		CMP	MNYSLM,Y
		BEQ	MNM040
		CLC
		ADC	MNYSAD,Y
		STA	ENYSPD,X
MNM040		EQU	$
		JSR	ENXCLC
		JSR	ENYCLC
;
		RTS
;=========================================================================
MANY1CS		EQU	$
		LDA	<GAMEMD
		BNE	MNM048
;
		PHX
		LDA	ENXPSL,X
		PHA
		LDA	ENYPSL,X
		PHA
;
		LDA	ENCONT,X
		STA	<WORK2
		TAX
		PLA
		STA	>KRYBUF,X
		PLA
		STA	>KRXBUF,X
		PLX
		INC	ENCONT,X
;
MNM048		EQU	$
		PHX
		LDA	ENCLOR,X
		STA	<WORK3
;
		LDX	<WORK2
		LDA	>KRXBUF,X
		SEC
		SBC	#08H
		SEC
		SBC	<SCCH2
		LDY	#00H
		STA	(<OAMADR),Y
		LDY	#04H
		STA	(<OAMADR),Y
		CLC
		ADC	#10H
		LDY	#08H
		STA	(<OAMADR),Y
		LDY	#0CH
		STA	(<OAMADR),Y
;
        	LDA	>KRYBUF,X
		SEC
		SBC	<SCCV2
		SEC
		SBC	#08H
		LDY	#01H
		STA	(<OAMADR),Y
		LDY	#09H
		STA	(<OAMADR),Y
		CLC
		ADC	#10H
		LDY	#05H
		STA	(<OAMADR),Y
		LDY	#0DH
		STA	(<OAMADR),Y
;
		LDA	#40H
		LDY	#02H
		STA	(<OAMADR),Y
		LDY	#06H
		STA	(<OAMADR),Y
		LDY	#0AH
		STA	(<OAMADR),Y
		LDY	#0EH
		STA	(<OAMADR),Y
;
		LDA	<WORK3
		LDY	#03H
		STA	(<OAMADR),Y
		LDY	#07H
		STA	(<OAMADR),Y
		LDY	#0BH
		STA	(<OAMADR),Y
		LDY	#0FH
		STA	(<OAMADR),Y
;
		LDY	#00H
		LDA	#02H
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
;
		LDX	#0FH
		LDY	#010H
MNC010		EQU	$
		PHX
		LDA	<WORK2
		SEC
		SBC	#08H
		STA	<WORK2
		TAX
		LDA	>KRXBUF,X
		SEC
		SBC	<SCCH2
		STA	(<OAMADR),Y
		LDA	>KRYBUF,X
		SEC
		SBC	<SCCV2
		INY
		STA	(<OAMADR),Y
		LDA	#42H
		INY
		STA	(<OAMADR),Y		
		LDA	<WORK3
		INY
		STA	(<OAMADR),Y	
		TYA
		PHY
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	MNC010
		PLX
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Foods                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FOOD1MV		EQU	$
FOOD2MV		EQU	$
FOOD3MV		EQU	$
FOOD4MV		EQU	$
		JSR	EN1CST
		JSR	ENSTCK
;
;;		LDA	YPSHMD
;;		CMP	#06H
;;		BNE	FODM90
;
		LDA	KEYA2L
		AND	#01000000B
		BEQ	FODM90
;
		JSR	CRENPL2
		BCC	FODM90
;
		JSL	>EATSET		; player eating set !
		STZ	ENMODE,X
FODM90		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		taru                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TARUVMV		EQU	$
TARUHMV		EQU	$
		JSR	TARUVCS
		JSR	ENSTCK
;
		JSR	ENBDCL		; bound calc !
;
		LDA	ENZPSL,X
		BNE	TRM040
;
		LDA	ENXSPD,X	
		BEQ	TRM020 
                BMI	TRM018
		DEC	ENXSPD,X
		DEC	ENXSPD,X
TRM018		EQU	$
		INC	ENXSPD,X
TRM020		EQU	$
		LDA	ENYSPD,X	
		BEQ	TRM040 
                BMI	TRM038
		DEC	ENYSPD,X
		DEC	ENYSPD,X
TRM038		EQU	$
		INC	ENYSPD,X
TRM040		EQU	$
		JSR	CRENPL
		BCC	TRM060
;
TRM060		EQU	$
		RTS
;===================================================================
TARUVCS		EQU	$
		JSR	EPXCHK
		LDA	<WORKF
		CLC
		ADC	#020H
		CMP	#40H
		BCS	TRC010
		JSR	EPYCHK
		LDA	<WORKE
		CLC
		ADC	#020H
		CMP	#40H
		BCS	TRC010
		CPY	#00H
		BEQ	TRC010
;
		JSR	EN1CST
		RTS
TRC010		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		ITEM1                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ITEM1MV		EQU	$
		JSR	EN1CST
;
		JSR	CRENPL
		BCC	IT1M90
;
		STZ	ENMODE,X	;ITEM GET
IT1M90		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - -
EAMCDT		EQU	$
		HEX	83,C7
ENAME 		EQU	$
		JSR	EN1CSS
;
		LDA	ENTIM0,X
		BNE	EAM010
		STZ	ENMODE,X
EAM010		EQU	$
		LSR	A
		LSR	A
		PHX
		TAX
		LDY	#02H
		LDA	EAMCDT,X
		STA	(<OAMADR),Y
		INY
		LDA	#2CH
		STA	(<OAMADR),Y
		PLX
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		zol gel...                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ZOOL1MV		EQU	$
		LDA	ENCHPT,X
		CMP	#06H
		BCS	ZL1M10
;
		JSR	EN1CST
		BRA	ZL1M20
ZL1M10		EQU	$
		JSR	ZOOL1CS
ZL1M20		EQU	$
		JSR	ENSTCK
		JSR	ENHNSB
;
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		;Vs PL body
;
		JSR	ENXCLC
		JSR	ENYCLC
;
		JSR	ENBGCK
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	ZLWALK
		WORD	ZLSTOP
		WORD	ZLSTP2		; bunshin ready
		WORD	ZLJUMP		; bunsin jump (small)
		WORD	ZLCNGE		; big chenge
		WORD	ZLWALK2
		WORD	ZLSTOP2
;============================================================================
ZLWXSD	 	EQU	$
		BYTE	0C0H,040H,000H,000H
ZLWYSD	 	EQU	$
		BYTE	000H,000H,0C0H,040H
ZLWCDT		EQU	$
		BYTE	0,1,2,1
;
ZLWALK		EQU	$
;
		LDA	ENTIM0,X
		BEQ	ZLWEND
;
		AND	#0FH
		BNE	ZLW010
;
		LDY	ENMUKI,X
		LDA	ZLWXSD,Y
		STA	ENXSPD,X
		LDA	ZLWYSD,Y
		STA	ENYSPD,X
ZLW010		EQU	$
		LDA	ENCBFG,X
		BEQ	ZLW020
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
ZLW020		EQU	$		
ZLWPTS		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	ZLWCDT,Y
		STA	ENCHPT,X
		LDY	ENMUKI,X
		CPY	#02H
		BCS	ZLW050
;
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	ZLWCMK,Y
		STA	ENCLOR,X
ZLW050		EQU	$		
		RTS
;- - - - - - -
ZLWCMK		EQU	$
		BYTE	000H,040H
;
ZLWEND		EQU	$
		LDA	#40H
		STA	ENTIM0,X
;
		LDA	#01H
		STA	ENSTAT,X	
		RTS
;============================================================================
ZLSTOP		EQU	$
		JSR	ZLWPTS
;
		LDA	ENTIM0,X
		BNE	ZLST10
;
		INC	ENWRK0,X
		LDA	ENWRK0,X
		AND	#03H
		BNE	ZLST08
;
;;		JSL	>RNDSET
;;		AND	#00111000B
;;		BNE	ZLST08		; bunshin ?
;					; yes !
		LDA	#02H
		STA	ENSTAT,X
		LDA	#80H	
		STA	ENTIM0,X
		RTS
ZLST08		EQU	$
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X
		JSL	>RNDSET
		AND	#3FH
		ADC	#40H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
ZLST10		EQU	$
		RTS
;============================================================================
ZLS2SD		EQU	$
		BYTE	010H,0F0H
;
ZLSTP2		EQU	$
		LDA	ENTIM0,X
		BEQ	ZLS280
;
		AND	#01H
		TAY
;
		LDA	ZLS2SD,Y
		STA	ENXSPD,X
		LDA	#02H
		STA	ENCHPT,X
		RTS
ZLS280		EQU	$
		LDA	#01H
		STA	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
;
		LDA	#01H
		STA	<WORKE
;
		JSR	ZLSSST		
		DEC	<WORKE
;
ZLSSST		EQU	$
		LDA	#ZOOL1
		JSL	>ENIDSH
		BMI	ZLSS90
;
		LDA	<WORK0
;; 		CLC
;;		ADC	#04H
		STA	ENXPSL,Y
		LDA	<WORK1
;;		ADC	#00H
		STA	ENXPSH,Y
		LDA	<WORK2
;;		CLC
;;		ADC	#04H
		STA	ENYPSL,Y
		LDA	<WORK3
;;		ADC	#00H
		STA	ENYPSH,Y
		LDA	<WORK4
		STA	ENZPSL,Y		
		LDA	#03H
		STA	ENSTAT,Y
		LDA	#002H
		STA	ENZSPD,Y
		LDA	<WORKE
		STA	ENMUKI,Y
;
		LDA	ENMOD2,Y
		ORA	#00100000B
		STA	ENMOD2,Y
;
		LDA	#06H
		STA	ENCHPT,Y
ZLSS90		EQU	$
		RTS
;============================================================================
ZLJUMP		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#07H
		BNE	ZLJ010
		DEC	ENZSPD,X
ZLJ010		EQU	$
		LDA	ENZPSL,X
		CLC
		ADC	ENZSPD,X
		STA	ENZPSL,X
		BPL	ZLJ020

		STZ	ENZPSL,X
		LDA	#40H
		STA	ENTIM0,X
		LDA	#04H
		STA	ENSTAT,X
ZLJ020		EQU	$
		LDA	#06H
		STA	ENCHPT,X
;
		LDY	ENMUKI,X
		LDA	ZLJXSD,Y
		STA	ENXSPD,X
		RTS
ZLJXSD		EQU	$
		BYTE	00CH,0F4H
;============================================================================
ZLCMDD		EQU	$
		BYTE	9,8,8,7,7,7,7,7
;
ZLCNGE		EQU	$
		LDA	ENTIM0,X
		BEQ	ZLC010
		LSR	A
		LSR	A
		LSR	A
;;		BYTE	0EAH,0EAH,0EAH
		TAY
		LDA	ZLCMDD,Y
		STA	ENCHPT,X
		RTS
ZLC010		EQU	$
		LDA	#05H
		STA	ENSTAT,X
		RTS
;===============================================================================
Z2WXSD	 	EQU	$
		BYTE	0E0H,020H,000H,000H
Z2WYSD	 	EQU	$
		BYTE	000H,000H,0E0H,020H
;
ZLWALK2 	EQU	$
		LDA	ENTIM0,X
		BEQ	Z2WEND
;
		AND	#0FH
		BNE	Z2W010
;
		LDY	ENMUKI,X
		LDA	Z2WXSD,Y
		STA	ENXSPD,X
		LDA	Z2WYSD,Y
		STA	ENYSPD,X
Z2W010		EQU	$
		LDA	ENCBFG,X
		BEQ	Z2W020
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
Z2W020		EQU	$
ZLWPTS2		EQU	$		
		JSR	ZLWPTS
		LDA	ENCHPT,X
		CLC
		ADC	#03H
		STA	ENCHPT,X
		RTS
;
Z2WEND		EQU	$
		LDA	#40H
		STA	ENTIM0,X
;
		LDA	#06H
		STA	ENSTAT,X	
		RTS
;============================================================================
ZLSTOP2 	EQU	$
		JSR	ZLWPTS2
;
		LDA	ENTIM0,X
		BNE	Z2ST10
;
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X
		LDA	#80H
		STA	ENTIM0,X
;
		LDA	#05H
		STA	ENSTAT,X
Z2ST10		EQU	$
		RTS
;============================================================================
;============================================================================
;============================================================================
ZLCXAD		EQU	$
		BYTE	004H,004H,004H
		BYTE	000H,008H,008H
		BYTE	000H,000H,008H
		BYTE	000H,000H,008H
ZLCYAD		EQU	$
		BYTE	000H,000H,000H
		BYTE	008H,008H,008H
		BYTE	0FEH,008H,008H
		BYTE	0FEH,008H,008H
ZLCCDT		EQU	$
		BYTE	071H,071H,071H
		BYTE	068H,068H,068H
		BYTE	06EH,068H,068H
		BYTE	06CH,069H,069H
ZLCADT		EQU	$
		BYTE	0,0,0
		BYTE	0,040H,040H
		BYTE	0,0,040H
		BYTE	0,040H,00H
ZLCSBD		EQU	$
		BYTE	0,0,0
		BYTE	0,0,0
        	BYTE	2,0,0
		BYTE	2,0,0
;
ZOOL1CS		EQU	$
		JSR	OAMCHK
;
;;                LDA	ENCLOR,X
;;		STA	<WORK4
		LDA	ENCHPT,X
		SEC
		SBC	#06H
		STA	<WORK6
		ASL	A
		ADC	<WORK6	; *3
		STA	<WORK6
		PHX
		LDY	#00H
		LDX	#00H
ZLCS10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	ZLCXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	ZLCYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	ZLCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		ORA	ZLCADT,X
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	ZLCSBD,X
		STA	(<OSBADR),Y
;
		PLY
		INY
		PLX
		INX
		CPX	#03H
		BNE	ZLCS10
;
		PLX
		LDY	#0FFH
		LDA	#02H
		JSR	ALOMCK
;
		JSR	SADWST
		RTS	
;============================================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		KWAUSO TEST                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KWAUSMV		EQU	$
KWAU1MV		EQU	$
		JSR	EN1CST		; OAM set !
;
		JSR	ENSTCK		; scroll : not return !
		JSR	ENHNSB          ; hanekaeri 
;
;;;;;;;;	JSR	ENXCLC
;;;;;;;;	JSR	ENYCLC
		JSR	ENMVCL		; xclc,yclc,BG check !
                JSR	ENBGCK		; BG check sub !
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		;Vs PL body
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KWUSM0		;move1		
		WORD	KWUSM1		;    2
;----------------------------------------
KWUSM0		EQU	$
		LDA	ENTIM0,X
		BNE	KWM080		; stop end ?
;					; yes ! go walk !
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#00FH
		CLC
		ADC	#20H
		STA	ENTIM0,X
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X	; next muki set !
;
KWM080		EQU	$
		RTS
;--------------------------------------------------------------
KWXSDT		EQU	$
		BYTE	000H,000H,0F8H,008H
		BYTE	000H,000H,0F0H,010H
KWYSDT		EQU	$
		BYTE	0F8H,008H,000H,000H
		BYTE	0F0H,010H,000H,000H
;
KWUSM1		EQU	$
		JSR	KWTAMST		; tama set check !
;
		LDA	ENTIM0,X
		BNE	KWM120		; walk end ?
;					; yes ! goto stop !
		STZ	ENSTAT,X
		STZ	ENTIM0,X
KWM120		EQU	$
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	KWM150		; cros BG ?
;					; yes ! muki turn !
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
KWM150		EQU	$
		LDY	ENMUKI,X
		LDA	ENMYNO,X
		CMP	#KWAU1
		BNE	KWM130
		INY
		INY
		INY
		INY
KWM130		EQU	$
		LDA	KWXSDT,Y
		STA	ENXSPD,X
		LDA	KWYSDT,Y
		STA	ENYSPD,X
		RTS
;--------------------------------------------------------------
;====================			;TAMA
KWTAMST		EQU	$
		LDA	<FRCNT
		BNE	KWTS00
;
		JSR	KWTS10
KWTS00		EQU	$
		RTS
;- - - - - - - - - - - - 
KWTS10		EQU	$
		LDA	#OCTAM
		JSL	>ENIDSH
		BMI	KWTS80
		LDA	<WORK0
		CLC
		ADC	#04H
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#00H
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#04H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#00H
		STA	ENYPSH,Y
		LDA	<WORK4
		STA	ENZPSL,Y		
KWTS80		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		SHIGE set                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SGCDT0		EQU	$
		BYTE	0E0H,0F4H,0F5H
SGCDT1		EQU	$
		BYTE	0E0H,0F5H,0F4H
;SGADT0		EQU	$
;		BYTE	020H+008H+001H,020H+008H+001H,060H+008H+001H
;SGADT1		EQU	$
;		BYTE	060H+008H+001H,020H+008H+001H,060H+008H+001H
;
;SHIGEMV		EQU	$
		JSR	SHIGECS
;----------------------------------------
;	WORK0,1 -- P(X,Y)		P.19 SFX MANIARU
;		     ~
;	WORK2,3 -- P(X,Y)
;		       ~
;	WORK4,5 -- R		(LOW dake tukau)
;
;	WORK6,7 -- kakudo	(LOW dake tukau)
;
;	C(X,Y)  -- WORK8,9
;	  ~
;	C(X,Y)  -- WORKA,B
;	    ~
;
		LDA	<PLXPS1
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	<PLYPS1
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
;
		LDA	#001H
		STA	<WORK4
		STZ	<WORK5
;
		TXA
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	<FRCNT
		STA	<WORK6
		BNE	DDDDDD
		INC	ENWRK0,X
DDDDDD		EQU	$
		LDA	ENWRK0,X
		STA	<WORK7
;
		JSL	>ENENSET
;
		LDA	<WORK8
		STA	ENXPSL,X
;
		LDA	<WORK9
		STA	ENXPSH,X
;
		LDA	<WORKA
		STA	ENYPSL,X
;
		LDA	<WORKB
		STA	ENYPSH,X
;
		RTS
;
;
;
;
		JSR	ENSTCK		; scroll : not return !
		JSR	ENHNSB          ; hanekaeri 
;
		JSR	ENMVCL		; xclc,yclc
		JSR	ENZCLC		; zclc
                JSR	ENBGCK		; BG check sub !
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		;Vs PL body
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SHIGEM0		;move1		
		WORD	SHIGEM1		;    2
		WORD	SHIGEM2		;    3
;----------------------------------------
SHIGEM0		EQU	$		; stop
		STZ	ENWRK0,X	; asi cls
;
		STZ	ENZPSL,X
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		STZ	ENZSPD,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	SHM0010
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#020H
		STA	ENTIM0,X
;
		INC	ENSTAT,X
;
SHM0010		EQU	$
		RTS
;---------------------------------------
SHIGEM1		EQU	$		; move
		LDA	#001H
		STA	ENWRK0,X
;
		LDA	#001H
		STA	ENZPSL,X
;
;		LDA	<FRCNT
;		LSR	A
;		LSR	A
;		LSR	A
;		LSR	A
;		AND	#001H
;		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	SHM1010
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#018H
		STA	ENTIM0,X
;
		JSL	>RNDSET
		AND	#007H
		STA	ENMUKI,X
;
		INC	ENSTAT,X
;
SHM1010		EQU	$
		RTS
;----------------------------------------
SHXSDT		EQU	$
		BYTE	000H,000H,020H,0E0H,0EBH,014H,0EBH,014H
SHYSDT		EQU	$
		BYTE	0E0H,020H,000H,000H,0EBH,014H,014H,0EBH
SHIGEM2		EQU	$		;move
		LDA	<FRCNT
		LSR	A
		AND	#001H
		ORA	#002H
		STA	ENWRK0,X
;
		LDA	#003H
		STA	ENZPSL,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	SHM2010
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#0A0H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
;
SHM2010		EQU	$
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	SHM2020		;atari?
;
		STZ	ENSTAT,X
;		LDA	ENMUKI,X
;		EOR	#001H
;		STA	ENMUKI,X
;
SHM2020		EQU	$
		LDY	ENMUKI,X
		LDA	SHXSDT,Y
		STA	ENXSPD,X
		LDA	SHYSDT,Y
		STA	ENYSPD,X
;
		RTS
;----------------------------------------
SHIGECS		EQU	$		;CHAR SET
		JSR	OAMCHK
;
		JSR	EN1CST		; OAM set !
		LDA	ENWRK0,X
		BEQ	SHIG100
;
		LDY	#04
		LDA	ENDSXL		; x pos set
		STA	(<OAMADR),Y
		CLC
		ADC	#008H
		LDY	#08
		STA	(<OAMADR),Y
;
		LDY	#05		; y pos set
		LDA	ENDSYL
		CLC
		ADC	#009H
		STA	(<OAMADR),Y
		LDY	#09
		STA	(<OAMADR),Y
;		
		PHX
;
		LDA	ENWRK0,X
		DEC	A
		TAX
;
		LDY	#06
		LDA	SGCDT0,X	; char & atr set
		STA	(<OAMADR),Y
		LDY	#010
		LDA	SGCDT1,X
		STA	(<OAMADR),Y
;
		LDY	#07
		LDA	<WORK3
		STA	(<OAMADR),Y
		LDY	#011
		STA	(<OAMADR),Y
;
		PLX
;
		INC	<OSBADR
		LDA	<OAMADR
		CLC
		ADC	#004
		STA	<OAMADR
;
		LDY	#000H		; obj clc?
		LDA	#001H
		JSR	ALOMCK
;
SHIG100		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		SEKZ4 set                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SKZ4CD0		EQU	$			;CHAR data
		BYTE	042H,007H,040H,007H,043H,047H,040H,007H
SKZ4CD1		EQU	$
		BYTE	043H,007H,040H,047H,042H,047H,040H,047H
SKZ4CD2		EQU	$
		BYTE	052H,007H,050H,007H,053H,047H,050H,007H
SKZ4CD3		EQU	$
		BYTE	053H,007H,050H,047H,052H,047H,050H,047H
;
;
SKZ4CD4		EQU	$			;CHAR data (eyes)
		BYTE	072H,007H,074H,007H,073H,047H,074H,007H
SKZ4CD5		EQU	$
		BYTE	073H,007H,074H,47H,072H,047H,074H,047H
;
;
SKZ4XD		EQU	$			;X pos
		BYTE	001H,004H,007H,004H
;
SKZ4YD		EQU	$			;Y pos
		BYTE	004H,005H,004H,005H
;
;
SEKZ4MV		EQU	$
		JSR	SEKZ4CS
;
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
;
		WORD	SEKZ4M0
		WORD	SEKZ4M1
		WORD	SEKZ4M2
;----------------------------------------
SKZ4OIK		EQU	$
		BYTE	002H,000H,001H,001H
;
SEKZ4M0		EQU	$
		LDA	ENTIM0,X
		BNE	SZ4M010
;
		JSR	EPXYCK		; PL point get
;
		LDA	SKZ4OIK,Y
		STA	ENMUKI,X
;
		INC	ENSTAT,X
;
		LDA	#040H
		STA	ENTIM0,X
;
		STZ	ENWRK0,X
;
SZ4M010		EQU	$
		RTS
;----------------------------------------
SEKZ4M1		EQU	$
		STZ	ENWRK2,X
		INC	ENWRK0,X
		LDA	ENWRK0,X
		AND	#008H
		BEQ	SZ4M110
		INC	ENWRK2,X
SZ4M110		EQU	$
		LDA	ENTIM0,X
		BNE	SZ4M120
		INC	ENSTAT,X
		LDA	#010H
		STA	ENTIM0,X
		JSR	SZ4LSET
SZ4M120		EQU	$
		RTS
;----------------------------------------
SEKZ4M2		EQU	$
		LDA	#001H
		STA	ENWRK2,X
		LDA	ENTIM0,X
		BNE	SZ4M210
		STZ	ENSTAT,X
		STZ	ENWRK2,X
		LDA	#0FFH
		STA	ENTIM0,X
;
SZ4M210		EQU	$
		RTS
;----------------------------------------
;====================			;leser set
SZ4LXPS		EQU	$
		BYTE	001H,004H,00FH,004H
SZ4LYPS		EQU	$
		BYTE	00EH,00EH,00EH,00EH
SZ4LMKI		EQU	$
		BYTE	006H,001H,005H,001H
;
SZ4LSET		EQU	$
		LDA	#LESER
		JSL	>ENIDSH
		BMI	SZ4LS10
;
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENYPSL,X
		STA	<WORK1
;
		PHX
		LDA	ENMUKI,X
		TAX
;
		LDA	<WORK0
		CLC
		ADC	SZ4LXPS,X
		STA	ENXPSL,Y
;
		LDA	<WORK1
		CLC
		ADC	SZ4LYPS,X
		STA	ENYPSL,Y
;
		LDA	SZ4LMKI,X
		STA	ENMUKI,Y
		CPX	#000H
		BNE	SZ4LS20
		TYX
		JSR	LSRCST0
		BRA	SZ4LS50
SZ4LS20		EQU	$
		CPX	#001H
		BNE	SZ4LS30
		TYX
		JSR	LSRCST1
		BRA	SZ4LS50
SZ4LS30		EQU	$
		CPX	#002H
		BNE	SZ4LS40
		TYX
		JSR	LSRCST2
		BRA	SZ4LS50
SZ4LS40		EQU	$
		CPX	#003H
		BNE	SZ4LS50
		TYX
		JSR	LSRCST1
SZ4LS50		EQU	$
;
		PLX
;
		LDA	ENXPSH,X
		STA	ENXPSH,Y
;
		LDA	ENYPSH,X
		STA	ENYPSH,Y
;
		LDA	ENZPSL,X
		STA	ENZPSL,Y
;
		LDA	#0FFH
		STA	ENTIM1,Y
;
SZ4LS10		EQU	$
		RTS
;----------------------------------------
SEKZ4CS		EQU	$
		JSR	OAMCHK
;
		PHX
;
		LDA	ENDSXL		;X set
		LDY	#008H
		STA	(<OAMADR),Y
		LDY	#0010H
		STA	(<OAMADR),Y
		CLC
		ADC	#008H
		LDY	#012
		STA	(<OAMADR),Y
		LDY	#020
		STA	(<OAMADR),Y
;
		LDA	ENDSYL		;Y set
		LDY	#9
		STA	(<OAMADR),Y
		LDY	#13
		STA	(<OAMADR),Y
		CLC
		ADC	#008H
		LDY	#017
		STA	(<OAMADR),Y
		LDY	#021
		STA	(<OAMADR),Y
;
		LDA	ENMUKI,X
;
		ASL	A
		TAX
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	SKZ4CD0,X	;CHAR set
		LDY	#010
		ORA	<WORK+02H
		STA	(<OAMADR),Y
		LDA	SKZ4CD1,X
		LDY	#014
		ORA	<WORK+02H
		STA	(<OAMADR),Y
		LDA	SKZ4CD2,X
		LDY	#018
		ORA	<WORK+02H
		STA	(<OAMADR),Y
		LDA	SKZ4CD3,X
		LDY	#022
		ORA	<WORK+02H
		STA	(<OAMADR),Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDY	#0
;
		LDA	#000H
		STA	(<OSBADR),Y	;OAMSB set
		INY
		STA	(<OSBADR),Y	;OAMSB set
		INY
		LDA	#2
		STA	(<OSBADR),Y	;OAMSB set
		INY
		STA	(<OSBADR),Y	;OAMSB set
		INY
		STA	(<OSBADR),Y	;OAMSB set
		INY
		STA	(<OSBADR),Y	;OAMSB set
;
		PLX
;
		LDA	ENWRK2,X
		BEQ	SKZ4M10
;
		PHX
		LDA	ENMUKI,X
		TAX
;
		LDA	SKZ4XD,X	;X set
		CLC
		ADC	ENDSXL
		LDY	#0
		STA	(<OAMADR),Y
		CLC
		ADC	#008H
		LDY	#4
		STA	(<OAMADR),Y
;
		LDA	SKZ4YD,X	;Y set
		CLC
		ADC	ENDSYL
		LDY	#01
		STA	(<OAMADR),Y
		LDY	#5
		STA	(<OAMADR),Y
;
		TXA
		ASL	A
		TAX
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	SKZ4CD4,X	;CHAR set (eyes)
		LDY	#2
		ORA	<WORK+00H
		STA	(<OAMADR),Y
		LDA	SKZ4CD5,X
		LDY	#6
		ORA	<WORK+00H
		STA	(<OAMADR),Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
SKZ4M10		EQU	$		
		LDY	#0FFH		; obj clc?
		LDA	#005H
		JSR	ALOMCK
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	LESER move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LESERMV		EQU	$
		JSR	EN1CSS		;OAM set
;
		JSR	ENSTCK		;scroll : not return !
;
		LDA	ENTIM0,X	;SIPPO SET ?
		BNE	LESER20
;
		LDA	ENTIM1,X	;TIME UP ?
		BEQ	LESER50
;
		STZ	ENWRK2,X	;MOVE SET
		JSR	LSRDMST
		JSR	CRENPL		; Vs PL body check
		BCC	LESER10
LESER50		EQU	$
		STZ	ENMODE,X
		RTS
;
LESER10		EQU	$
		LDA	ENMUKI,X
		JSL	>JSRSUB
;
		WORD	LESERM0
		WORD	LESERM1
		WORD	LESERM2
		WORD	LESERM3
		WORD	LESERM4
		WORD	LESERM5
		WORD	LESERM6
		WORD	LESERM7
;
LSR20DT		EQU	$		;zanzou set
		BYTE	1,1,1,1,2,2,0,0
LESER20		EQU	$
		CMP	#001H
		BNE	LESER25
		STZ	ENMODE,X
LESER25		EQU	$
		LDY	ENMUKI,X
		LDA	LSR20DT,Y
		BEQ	LESER30
		CMP	#001H
		BEQ	LESER40
		BRL	LSRCST2
LESER40		EQU	$
		BRL	LSRCST1
LESER30		EQU	$
		BRL	LSRCST0
;
;---------------------------------------
LSRKAID		EQU	$
		BYTE	001H
LSRMVDT		EQU	$
		BYTE	004H,002H
;----------------------------------------
LSRM0DT		EQU	$
		BYTE	000H,002H,003H,001H,001H,002H,003H,001H
		BYTE	001H,002H,003H,001H,001H,002H,003H,001H
LESERM0		EQU	$		;UP
		JSR	LSRCST1
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM010		EQU	$
		LDA	ENYPSL,X
		SEC
		SBC	LSRMVDT,Y
		STA	ENYPSL,X
		LDA	ENYPSH,X
		SBC	#000H
		STA	ENYPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM020
;
		DEC	<WORKF
		BNE	LSRM010		;MOVE END?
		RTS			;Y
;
LSRM020		EQU	$		;MUKI set
		TAY
		LDA	LSRM0DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRM1DT		EQU	$
		BYTE	001H,002H,003H,000H,000H,002H,003H,000H
		BYTE	000H,002H,003H,000H,000H,002H,003H,000H
LESERM1		EQU	$		;DOWN
		JSR	LSRCST1
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM110		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	LSRMVDT,Y
		STA	ENYPSL,X
		LDA	ENYPSH,X
		ADC	#000H
		STA	ENYPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM120
;
		DEC	<WORKF
		BNE	LSRM110		;MOVE END?
		RTS			;Y
;
LSRM120		EQU	$		;MUKI set
		TAY
		LDA	LSRM1DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRM2DT		EQU	$
		BYTE	002H,003H,003H,003H,000H,000H,000H,000H
		BYTE	001H,001H,001H,001H,003H,003H,003H,003H
LESERM2		EQU	$		;LEFT
		JSR	LSRCST0
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM210		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	LSRMVDT,Y
		STA	ENXPSL,X
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM220
;
		DEC	<WORKF
		BNE	LSRM210		;MOVE END?
		RTS			;Y
;
LSRM220		EQU	$		;MUKI set
		TAY
		LDA	LSRM2DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRM3DT		EQU	$
		BYTE	003H,002H,002H,002H,000H,000H,000H,000H
		BYTE	001H,001H,001H,001H,002H,002H,002H,002H
LESERM3		EQU	$		;RIGHT
		JSR	LSRCST0
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM310		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	LSRMVDT,Y
		STA	ENXPSL,X
		LDA	ENXPSH,X
		ADC	#000H
		STA	ENXPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM320
;
		DEC	<WORKF
		BNE	LSRM310		;MOVE END?
		RTS			;Y
;
LSRM320		EQU	$		;MUKI set
		TAY
		LDA	LSRM3DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRM4DT		EQU	$
		BYTE	004H,006H,007H,007H,007H,005H,007H,007H
		BYTE	006H,006H,005H,006H,006H,006H,007H,005H
LESERM4		EQU	$		;UP
		JSR	LSRCST2
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM410		EQU	$
		LDA	ENYPSL,X
		SEC
		SBC	LSRMVDT,Y
		STA	ENYPSL,X
		LDA	ENYPSH,X
		SBC	#000H
		STA	ENYPSH,X
;
		LDA	ENXPSL,X
		SEC
		SBC	LSRMVDT,Y
		STA	ENXPSL,X
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM420
;
		DEC	<WORKF
		BNE	LSRM410		;MOVE END?
		RTS			;Y
;
LSRM420		EQU	$		;MUKI set
		TAY
		LDA	LSRM4DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRM5DT		EQU	$
		BYTE	005H,006H,007H,006H,007H,004H,007H,007H
		BYTE	006H,006H,004H,006H,007H,006H,007H,004H
LESERM5		EQU	$		;UP
		JSR	LSRCST2
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM510		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	LSRMVDT,Y
		STA	ENYPSL,X
		LDA	ENYPSH,X
		ADC	#000H
		STA	ENYPSH,X
;
		LDA	ENXPSL,X
		CLC
		ADC	LSRMVDT,Y
		STA	ENXPSL,X
		LDA	ENXPSH,X
		ADC	#000H
		STA	ENXPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM520
;
		DEC	<WORKF
		BNE	LSRM510		;MOVE END?
		RTS			;Y
;
LSRM520		EQU	$		;MUKI set
		TAY
		LDA	LSRM5DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRM6DT		EQU	$
		BYTE	006H,004H,005H,005H,007H,004H,007H,004H
		BYTE	005H,004H,005H,005H,004H,004H,005H,007H
LESERM6		EQU	$		;UP
		JSR	LSRCST0
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM610		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	LSRMVDT,Y
		STA	ENYPSL,X
		LDA	ENYPSH,X
		ADC	#000H
		STA	ENYPSH,X
;
		LDA	ENXPSL,X
		SEC
		SBC	LSRMVDT,Y
		STA	ENXPSL,X
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM620
;
		DEC	<WORKF
		BNE	LSRM610		;MOVE END?
		RTS			;Y
;
LSRM620		EQU	$		;MUKI set
		TAY
		LDA	LSRM6DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRM7DT		EQU	$
		BYTE	007H,004H,005H,004H,004H,004H,006H,004H
		BYTE	005H,006H,005H,005H,005H,004H,005H,006H
LESERM7		EQU	$		;UP
		JSR	LSRCST0
		LDA	LSRKAID
		STA	<WORKF
		LDY	ENWRK2,X
;
LSRM710		EQU	$
		LDA	ENYPSL,X
		SEC
		SBC	LSRMVDT,Y
		STA	ENYPSL,X
		LDA	ENYPSH,X
		SBC	#000H
		STA	ENYPSH,X
;
		LDA	ENXPSL,X
		CLC
		ADC	LSRMVDT,Y
		STA	ENXPSL,X
		LDA	ENXPSH,X
		ADC	#000H
		STA	ENXPSH,X
;
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BNE	LSRM720
;
		DEC	<WORKF
		BNE	LSRM710		;MOVE END?
		RTS			;Y
;
LSRM720		EQU	$		;MUKI set
		TAY
		LDA	LSRM7DT,Y
		STA	ENMUKI,X
;
		LDA	#001H
		STA	ENWRK2,X
;
		BRL	LESER10
;
;----------------------------------------
LSRCST0		EQU	$
		STZ	ENCHPT,X
		LDA	ENCLOR,X
		AND	#0BFH
		STA	ENCLOR,X
		RTS
;----------------------------------------
LSRCST1		EQU	$
		LDA	#001H
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#0BFH
		STA	ENCLOR,X
		RTS
;----------------------------------------
LSRCST2		EQU	$
		STZ	ENCHPT,X
		LDA	ENCLOR,X
		ORA	#040H
		STA	ENCLOR,X
		RTS
;====================			;leser set
LSRDMST		EQU	$
		LDA	#LESER
		JSL	>ENIDSH
		BMI	LSRDST1
;
		LDA	ENXPSL,X
		STA	ENXPSL,Y
		LDA	ENXPSH,X
		STA	ENXPSH,Y
;
		LDA	ENYPSL,X
		STA	ENYPSL,Y
		LDA	ENYPSH,X
		STA	ENYPSH,Y
;
		LDA	ENZPSL,X
		STA	ENZPSL,Y
;
		LDA	ENMUKI,X
		STA	ENMUKI,Y
;
		LDA	#00FH
		STA	ENTIM0,Y
;
		PHX
		TYX
		JSR	LESER25
		PLX
LSRDST1		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		SEKZ1                                 %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SEKZ1MV		EQU	$
		JSR	SEKZ1CS
;;;;;;;;		JSR	SLOWMV
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	ENTIM0,X
		BNE	SKOM80		; Muki chenge ?
;					; yes !
		JSL	>RNDSET
		AND	#3FH
		ADC	#40H
		STA	ENTIM0,X
		JSR	SKSDST
SKOM80		EQU	$
		JSR	ENMVCL
		JSR	ENBGCK
;;		LDA	ENCBFG,X
;;		AND	#00001111B
;;		BEQ	SKOM90
;;		JSR	ENTURN
		JSR	ENTUCK
SKOM90  	EQU	$
		JSR	CRENPL		;Vs PL body
		JSR	CRKNEN
;
		STZ	ENCHPT,X
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
;;;;            LSR	A
;;		BYTE	0EAH,0EAH
		AND	#07H
		TAY
		LDA	IWAOYD,Y
		STA	ENZPSL,X		
		RTS
;-----------------------------------
SKZRXS		EQU	$
		BYTE	04H,03H,0FDH,0FCH,0FDH,03H,0F8H,0F8H
SKZRYS		EQU	$
		BYTE	00H,03H,03H,00H,0FDH,0FDH,08H,0F8H
;- - - - - - - - - 
SKSDST		EQU	$
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	SKZRXS,Y
		STA	ENXSPD,X
		LDA	SKZRYS,Y
		STA	ENYSPD,X	
		RTS
;==================================================
SEKZ1CS		EQU	$
		JSR	EN1CST
;
		JSR	OAMCHK
		MEM16
		REP	#00100000B
		LDA	<OAMADR
		CLC
		ADC	#04H
		STA	<OAMADR
		INC	<OSBADR
		MEM8
		SEP	#00100000B
;
		LDA	ENDSXL
		STA	(<OAMADR),Y
		LDA	ENDSYL
		SEC
		SBC	#008H
		INY
		STA	(<OAMADR),Y
		LDA	#0C6H
		INY
		STA	(<OAMADR),Y
		LDA	ENCLOR,X
;;;;		ORA	#20H
		INY
		STA	(<OAMADR),Y
		LDY	#02H
		LDA	#00H
		JSR	ALOMCK
		RTS
;-------------------------------------------------
SKHEDMV		EQU	$
		JSR	SKHEDCS
		JSR	ENSTCK
;;		LDA	<GAMEMD
;;		BEQ	SHD008
;;;
;;		JMP	>SHM090
;
SHD008		EQU	$
		LDA	<FRCNT
		AND	#01H
		BNE	SHD010
;
		LDA	ENWRK1,X
		BEQ	SHD010
		DEC	ENWRK1,X
SHD010		EQU	$
		JSR	ENXCLC
		JSR	ENYCLC
;--- Serch -------
		LDA	ENWRK1,X
		BNE	SHR010		; return ?
;								; yes !
		TXA
		EOR	<FRCNT
		AND	#01H
		BNE	SHM008
;
		JSR	CRSHSB		; Body cros check !
		LDA	<PLXPS1
		PHA
		LDA	<PLXPS0
		PHA
		LDA	<PLYPS1
		PHA
		LDA	<PLYPS0
		PHA
		LDY	ENWRK0,X
		LDA	ENXPSL,Y
		STA	<PLXPS1
		LDA	ENXPSH,Y
		STA	<PLXPS0
		LDA	ENYPSL,Y
		STA	<PLYPS1
		LDA	ENYPSH,Y
		STA	<PLYPS0
		LDA	#18H
		JSR	PSERC2		;******
		PLA
		STA	<PLYPS0
		PLA
		STA	<PLYPS1
		PLA
		STA	<PLXPS0
		PLA
		STA	<PLXPS1
		BRA	SHS00A
SHR010		EQU	$
		TXA
		EOR	<FRCNT
		AND	#01H		; ajast !!
		BNE	SHM008
;
SHR018		EQU	$
;-  -  -  -  -  -  -  -  -  -  -  -  -
SHS008		EQU	$		; player serch 
		LDA	#18H
		JSR	PSERC2
SHS00A		EQU	$
		LDA	ENYSPD,X
		CMP	<WORK0
		BEQ	SHS030
		BPL	SHS010
		INC	ENYSPD,X
		BRA	SHS030
SHS010		EQU	$
		DEC	ENYSPD,X
SHS030		EQU	$
		LDA	ENXSPD,X
		CMP	<WORK1
		BEQ	SHS050
		BPL	SHS040
		INC	ENXSPD,X
		BRA	SHS050
SHS040		EQU	$
		DEC	ENXSPD,X
SHS050		EQU	$
;------------------
SHM008		EQU	$
;;			JSR		ENBGCK
;;			LDA		ENCBFG,X
;;			BEQ		SHM010
;;			STZ		ENMODE,X
SHM010		EQU	$
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		;Vs PL body
;		JSR	CRKNSH		; cross player & ken !
		INC	ENCONT,X
SHM090		EQU	$
		RTS
;- - - - - - - - - - 
CRKNSH		EQU	$
		TXA
		EOR	<FRCNT
		AND	#01H
		ORA	<HANEFG
		BNE	CKS010
;
		LDA	PLBGCKF
		CMP	ENKAIF,X
		BNE	CKS010
;
		JSR	ENCRST
		JSR	PLCRST
		JSR	CROJCK
		BCC	CKS008
;
		LDA	#10H
		STA	<HANEFG
		LDA	#HPW20
		JSR	PLHNST
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
CKS008		EQU	$
		LDA	KNCRYP
		CMP	#80H
		BEQ	CKS010
;
		JSR	PKNCRS
;;;;			JSR		ENCRST
		JSR	CROJCK
		BCC	CKS010
;
		LDA	#20H
		JSR	PSERC2
		LDA	<WORK0
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
;
;;			JSR		FLSHST
CKS010		EQU	$
		RTS
;----------------------------------------------
SHEDCD		EQU	$
		BYTE	45H,47H,49H,47H
SHEDAD		EQU	$
		BYTE	10000000B
		BYTE	10000000B
		BYTE	10000000B
		BYTE	11000000B
;-----------------------------------------------------------
SKHEDCS		EQU	$
		JSR	OAMCHK
		LDA	ENDSPL,X
		BNE	SHM080
		LDA	ENCLOR,X
		STA	<WORK0
		LDY	#000
		LDA	ENDSXL
		STA	(<OAMADR),Y
		INY
		LDA	ENDSYL
		STA	(<OAMADR),Y
		INY
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		PHX
		TAX
		LDA	SHEDCD,X
		STA	(<OAMADR),Y
		INY
		LDA	SHEDAD,X
		ORA	<WORK0
		STA	(<OAMADR),Y
		PLX
		LDY	#000
		LDA	#002H
		STA	(<OSBADR),Y
;
		LDA	#000
		LDY	#002H
		JSR	ALOMCK
		LDA	#012H
		JSR	SADWS2
SHM080		EQU	$
		RTS
;- - - - - - - - - - - - - - - 
CRSHSB		EQU	$
		LDY	ENWRK0,X
		LDA	ENXPSL,Y
		CLC
		ADC	#04H
		STA	<WORK0
		LDA	ENXPSH,Y
		ADC	#00H
		STA	<WORK8
		LDA	#07H
		STA	<WORK2
		STA	<WORK3
		LDA	ENYPSL,Y
		STA	<WORK1
		LDA	ENYPSH,Y
		STA	<WORK9
		LDA	ENXPSL,X
		STA	<WORK4
		LDA	ENXPSH,X
		STA	<WORKA
		LDA	ENYPSL,X
		STA	<WORK5
		LDA	ENYPSH,X
		STA	<WORKB
		LDA	#07H
		STA	<WORK6
		STA	<WORK7
		JSR	CROJCK		;********
		BCC	CRSB80		; cross ?
;								; yes !
		STZ	ENMODE,X
		LDA	#00H
		STA	ENSTAT,Y
		LDA	#09H
		STA	ENCTFG,Y
		LDA	#10H
		STA	ENTIM1,Y
CRSB80		EQU	$
		RTS

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	HEITI move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HEITIMV		EQU	$
		JSR	HEITICS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#LOW  MS_0000
		LDY	#HIGH MS_0000
		JSL	>ENMSGEL
;
		RTS
;----------------------------------------
HEITICD		EQU	$
		BYTE	00EH,006H,0ADH,000H
		BYTE	00EH,00EH,0BDH,000H
		BYTE	000H,000H,080H,000H
		BYTE	000H,007H,082H,000H
;
HEITICS		EQU	$
		JSR	OAMCHK
		JSR	OCHECK
;
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDX	#00000H
		LDY	<OAMADR
;
		LDA	#00003
		STA	<WORK0
HEITC10		EQU	$
		LDA	ENDSXL
		CLC
		ADC	HEITICD,X
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		LDA	HEITICD,X
		ORA	<WORK4
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		DEC	<WORK0
		BPL	HEITC10
;
		LDY	<OSBADR
		LDA	#00000H
		STA	OAMSB-OAMSB,Y
		LDA	#00202H
		STA	OAMSB-OAMSB+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#003H
		LDY	#0FFH
		JMP	ALOMCK
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	GAKII move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GAKIIMV		EQU	$
		JSR	GAKIICS
		JSR	ENSTCK		; scroll : not return !
;
GAKII20		EQU	$
		LDA	#LOW  MS_0000
		LDY	#HIGH MS_0000
		JSL	>ENMSGEL
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		JSR	ENMVCL		; xclc,yclc,BG check !
                JSR	ENBGCK		; BG check sub !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	GAKIIM0
		WORD	GAKIIM1
		WORD	GAKIIM2
;----------------------------------------
GAKIIM0		EQU	$
		LDA	<FRCNT
		AND	#07FH
		BEQ	GAKM020
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	GAKM010
;
GAKM020		EQU	$
		JSL	>RNDSET
		STA	<WORK4
		LDA	ENXPSH,X
		STA	<WORK5
		JSL	>RNDSET
		STA	<WORK6
		LDA	ENYPSH,X
		STA	<WORK7
		LDA	#00CH
		JSR	ESERCH
		LDA	<WORK+00H
		STA	ENYSPD,X
		LDA	<WORK+01H
		STA	ENXSPD,X
;
GAKM010		EQU	$
		RTS
;----------------------------------------
GAKIIM1		EQU	$
;----------------------------------------
GAKIIM2		EQU	$
;----------------------------------------
GAKIICD		EQU	$
		BYTE	000H,000H,0E4H,040H
		BYTE	0FEH,008H,0C8H,040H
;
		BYTE	000H,000H,0E4H,040H
		BYTE	0FEH,007H,0CAH,040H
;
		BYTE	000H,000H,0E4H,000H
		BYTE	002H,008H,0C8H,000H
;
		BYTE	000H,000H,0E4H,000H
		BYTE	002H,007H,0CAH,000H
;
GAKIICS		EQU	$
		JSR	OAMCHK
		JSR	OCHECK
;
		PHX
		LDA	ENXSPD,X
		BPL	GAKIC20
		LDA	#000H
		BRA	GAKIC30
GAKIC20		EQU	$
		LDA	#002H
GAKIC30		EQU	$
		CLC
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
;
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
;
		LDY	<OAMADR
;
		LDA	#00001
		STA	<WORK0
GAKIC10		EQU	$
		LDA	ENDSXL
		CLC
		ADC	GAKIICD,X
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		LDA	GAKIICD,X
		ORA	<WORK4
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		DEC	<WORK0
		BPL	GAKIC10
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JMP	ALOMCK
;----------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	GAKI1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GAKI1MV		EQU	$
		JSR	GAKI1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#LOW  MS_0000
		LDY	#HIGH MS_0000
		JSL	>ENMSGEL
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		JSR	ENMVCL		; xclc,yclc,BG check !
                JSR	ENBGCK		; BG check sub !
;
		TXA
		EOR	<FRCNT
		AND	#01FH
		BNE	GAKI110
;
		LDY	ENWRK0,X
		LDA	ENXPSL,Y
		STA	<WORK4
		LDA	ENXPSH,Y
		STA	<WORK5
		LDA	ENYPSL,Y
		STA	<WORK6
		LDA	ENYPSH,Y
		STA	<WORK7
		LDA	#00CH
		JSR	ESERCH
		LDA	<WORK+00H
		STA	ENYSPD,X
		LDA	<WORK+01H
		STA	ENXSPD,X
;
GAKI110		EQU	$
		RTS
;----------------------------------------
GAKI1CD		EQU	$
		BYTE	000H,000H,0E6H,040H
		BYTE	000H,008H,0E8H,040H
;
		BYTE	000H,000H,0E6H,040H
		BYTE	000H,007H,0EAH,040H
;
		BYTE	000H,000H,0E6H,000H
		BYTE	000H,008H,0E8H,000H
;
		BYTE	000H,000H,0E6H,000H
		BYTE	000H,007H,0EAH,000H
;
GAKI1CS		EQU	$
		JSR	OAMCHK
		JSR	OCHECK
;
		PHX
		LDA	ENXSPD,X
		BPL	GAK1C20
		LDA	#000H
		BRA	GAK1C30
GAK1C20		EQU	$
		LDA	#002H
GAK1C30		EQU	$
		CLC
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
;
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
;
		LDY	<OAMADR
;
		LDA	#00001
		STA	<WORK0
GAK1C10		EQU	$
		LDA	ENDSXL
		CLC
		ADC	GAKI1CD,X
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		LDA	GAKI1CD,X
		ORA	<WORK4
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		DEC	<WORK0
		BPL	GAK1C10
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JMP	ALOMCK
;----------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	HEIT1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HEIT1MV		EQU	$
		JSR	HEIT1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	#LOW  MS_0000
		LDY	#HIGH MS_0000
		JSL	>ENMSGEL
		STA	ENMUKI,X
		STA	ENWRK0,X
		BCC	HEIT110
		STZ	ENSTAT,X
;
HEIT110		EQU	$
		JSR	ENMVCL		; xclc,yclc,BG check !
                JSR	ENBGCK		; BG check sub !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HEIT1M0
		WORD	HEIT1M1
		WORD	HEIT1M2
;----------------------------------------
HEIT1SX		EQU	$
		BYTE	000H,000H,0F4H,00BH
HEIT1SY		EQU	$
		BYTE	0F4H,00BH,000H,000H
HEIT1M0		EQU	$
		LDA	ENTIM0,X
		BNE	HI1M010
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#040H
		STA	ENTIM0,X
;
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
HI1M010		EQU	$
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	HI1M020
		INC	ENSTAT,X
		LDA	#060H
		STA	ENTIM0,X
HI1M020		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDY	ENMUKI,X
		LDA	HEIT1SX,Y
		STA	ENXSPD,X
		LDA	HEIT1SY,Y
		STA	ENYSPD,X
		TYA
		STA	ENWRK0,X
;
		RTS
;----------------------------------------
HEIT1M1		EQU	$
		LDA	ENTIM0,X
		BNE	HI1M120
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#060H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
HI1M120		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	<WORK0
		AND	#001H
		BNE	HI1M110
		LDA	<WORK0
		LSR	A
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENWRK0,X
		RTS
;
HI1M110		EQU	$
		LDA	ENMUKI,X
		STA	ENWRK0,X
		RTS
;----------------------------------------
HEIT1M2		EQU	$
;----------------------------------------
HEIT1HD		EQU	$
		BYTE	000H,000H,0C6H,000H ;0
		BYTE	000H,000H,0C4H,000H ;1
		BYTE	000H,000H,0C8H,000H ;2
		BYTE	000H,000H,0C8H,040H ;3
;
HEIT1BD		EQU	$
		BYTE	000H,008H,0EEH,000H ;0
		BYTE	000H,008H,0EEH,040H ;0
		BYTE	000H,008H,0CAH,000H ;1
		BYTE	000H,008H,0CAH,040H ;1
		BYTE	000H,008H,0CCH,000H ;2
		BYTE	000H,008H,0CEH,000H ;2
		BYTE	000H,008H,0CCH,040H ;3
		BYTE	000H,008H,0CEH,040H ;3
;
HEIT1CS		EQU	$
		JSR	OAMCHK
		JSR	OCHECK
;
		PHX
		LDA	ENMUKI,X
		STA	<WORK2
		STZ	<WORK3
		LDA	ENCHPT,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	<GAMEMD
		BNE	HIT1C10
		LDA	ENSTAT,X
		BNE	HIT1C10
		TXA			;UP DOWN
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		CLC
		ADC	ENDSYL
		STA	ENDSYL
;
HIT1C10		EQU	$
		LDA	ENWRK0,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	HEIT1HD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	HEIT1HD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
;
		LDA	<WORK2
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		TAX
;
		LDA	HEIT1BD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	HEIT1BD+2,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JMP	ALOMCK
;----------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		SARU1 set                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SARU1MV		EQU	$
		JSR	SARU1CS
;
;		LDA	<KEYA2
;		AND	#080H
;		BEQ	SARU120
;		LDA	ENCHPT,X
;		INC	A
;		AND	#003H
;		STA	ENCHPT,X
;SARU120		EQU	$
;		LDA	<KEYA2
;		AND	#040H
;		BEQ	SARU130
;		LDA	ENMUKI,X
;		INC	A
;		AND	#003H
;		STA	ENMUKI,X
;SARU130		EQU	$
;		RTS
;
		JSR	ENSTCK		; scroll : not return !
;
		JSR	ENHNSB          ; hanekaeri 
;
		JSR	CRKNKN		; Vs PL ken check
		JSR	CRENPL		; Vs PL body check
;
		TXA
		EOR	<FRCNT
		AND	#007H
		BNE	SARU110
                JSR	ENBGCK		; BG check sub !
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	SARU110
		LDA	ENMUKI,X
		EOR	#001H
		STA	ENMUKI,X
SARU110		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SARU1M0		;stop		
		WORD	SARU1M1		;move		
		WORD	SARU1M2		;yari		
		WORD	SARU1M3		;yari nasi		
;
;----------------------------------------
SARU1M0		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		STZ	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	SR1M010
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#003H
		STA	ENMUKI,X
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#080H
		STA	ENTIM0,X
;
SR1M010		EQU	$
		RTS
;----------------------------------------
SR1M1SX		EQU	$
		BYTE	000H,000H,0F3H,00CH
SR1M1SY		EQU	$
		BYTE	0F3H,00CH,000H,000H
SARU1M1		EQU	$
		LDY	ENMUKI,X
		LDA	SR1M1SX,Y
		STA	ENXSPD,X
		LDA	SR1M1SY,Y
		STA	ENYSPD,X
		JSR	ENMVCL		; xclc,yclc
;
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		STA	ENZPSL,X
;
		LDA	ENTIM0,X
		BNE	SR1M110
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#00FH
		CLC
		ADC	#010H
		STA	ENTIM0,X
;
SR1M110		EQU	$
		RTS
;----------------------------------------
SARU1M2		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		LDA	#002H
		STA	ENCHPT,X
;
		LDA 	ENTIM0,X
		BNE	SR1M210
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#01FH
		ADC	#020H
		STA	ENTIM0,X
;
		JSR	SRYTMST		;YATAM ENTRY
;
SR1M210		EQU	$
		RTS
;----------------------------------------
SARU1M3		EQU	$
		LDA	#003H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	SR1M310
;
		STZ	ENSTAT,X
		JSL	>RNDSET
		AND	#00FH
		CLC
		ADC	#010H
		STA	ENTIM0,X
;
SR1M310		EQU	$
		RTS
;====================			;YATAM
SR1TMSX		EQU	$
		BYTE	000H,000H,0D0H,030H
SR1TMSY		EQU	$
		BYTE	0D0H,030H,000H,000H
YACRDT		EQU	$
		BYTE	6,6,5,5
; - - - - - - - - - - - - - - -
SRYTMST		EQU	$
		LDA	#YATAM
		JSL	>ENIDSH
		BMI	SRYTS80
		PHX
		LDA	ENMUKI,X
		STA	ENMUKI,Y
		TAX
;
;;         	LDA	ENMOD3,Y
;;		AND	#0F0H
		LDA	YACRDT,X
		STA	ENMOD3,Y
;
		LDA	<WORK0
		CLC
		ADC	SAR1YAX,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	SAR1YAXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	SAR1YAY,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	SAR1YAYH,X
		STA	ENYPSH,Y
		LDA	<WORK4
		STA	ENZPSL,Y
;
		LDA	SR1TMSX,X
		STA	ENXSPD,Y
		LDA	SR1TMSY,X
		STA	ENYSPD,Y
;
		PLX
SRYTS80		EQU	$
		RTS
;----------------------------------------
SAR1YAY         EQU     $
                BYTE    0004,0006,0002,-002
;
SAR1YAYH        EQU     $
                BYTE    0000,0000,0000,-001
;
SAR1YAX         EQU     $
                BYTE    0013,-005,0010,0010
;
SAR1YAXH        EQU     $
                BYTE    0000,-001,0000,0000
;
SARU1CD		EQU	$
		BYTE	0011,0011,042H,080H
		BYTE	0000,-007,044H,000H
		BYTE	-004,0003,04EH,040H
		BYTE	0004,0003,04DH,040H
		BYTE	0011,0002,052H,080H
;
		BYTE	0000,-007,044H,000H
		BYTE	-004,0003,04DH,000H
		BYTE	0004,0003,04EH,000H
		BYTE	0012,-002,052H,080H
		BYTE	0012,0007,042H,080H
;
		BYTE	0008,0004,041H,0C0H
		BYTE	0000,-007,044H,000H
		BYTE	-004,0002,067H,000H
		BYTE	0004,0002,068H,000H
		BYTE	0016,-004,040H,0C0H
;
		BYTE	0000,-007,044H,000H
		BYTE	-004,0003,04DH,000H
		BYTE	0004,0003,04EH,000H
		BYTE	0000,-008,044H,000H;D
		BYTE	0000,-008,044H,000H;D
;
;
;
		BYTE	-003,0008,052H,000H
		BYTE	0000,-007,046H,000H
		BYTE	-004,0003,04AH,000H
		BYTE	0004,0003,04BH,000H
		BYTE	0011,0011,042H,080H;D
;
		BYTE	-003,0012,052H,000H
		BYTE	0000,-007,046H,000H
		BYTE	-004,0003,04BH,040H
		BYTE	0004,0003,04AH,040H
		BYTE	0012,0007,042H,080H;D
;
		BYTE	-009,0005,040H,000H
		BYTE	0000,-007,046H,000H
		BYTE	-004,0002,064H,000H
		BYTE	0004,0002,065H,000H
		BYTE	0008,0004,041H,0C0H;D
;
		BYTE	0000,-007,046H,000H
		BYTE	-004,0003,04BH,040H
		BYTE	0004,0003,04AH,040H
		BYTE	0000,-008,044H,000H;D
		BYTE	0000,-008,044H,000H;D
;
;
;
		BYTE	0011,0010,051H,000H
		BYTE	0000,0010,050H,000H
		BYTE	0000,-008,048H,000H
		BYTE	0000,0003,060H,000H
		BYTE	0011,0011,042H,000H;D
;
		BYTE	0007,0008,051H,000H
		BYTE	-004,0007,050H,000H
		BYTE	0000,-008,048H,000H
		BYTE	0000,0003,062H,000H
		BYTE	0012,0007,042H,000H;D
;
		BYTE	0012,0001,051H,000H
		BYTE	0001,0001,050H,000H
		BYTE	0000,0002,06AH,000H
		BYTE	0000,-008,048H,000H
		BYTE	0008,0004,041H,000H;D
;
		BYTE	0000,-008,048H,000H
		BYTE	0000,0003,062H,000H
		BYTE	0004,0003,04EH,000H;D
		BYTE	0000,-008,044H,000H;D
		BYTE	0000,-008,044H,000H;D
;
;
;
		BYTE	-002,0008,051H,040H
		BYTE	0008,0009,050H,040H
		BYTE	0000,-008,048H,040H
		BYTE	0000,0003,060H,040H
		BYTE	0011,0011,042H,040H;D
;
		BYTE	0011,0008,050H,040H
		BYTE	0000,0008,051H,040H
		BYTE	0000,-008,048H,040H
		BYTE	0000,0003,062H,040H
		BYTE	0012,0007,042H,040H;D
;
		BYTE	0005,0001,050H,040H
		BYTE	-005,0000,051H,040H
		BYTE	0000,0002,06AH,040H
		BYTE	0000,-008,048H,040H
		BYTE	0008,0004,041H,040H;D
;
		BYTE	0000,-008,048H,040H
		BYTE	0000,0003,062H,040H
		BYTE	0004,0003,04EH,040H;D
		BYTE	0000,-008,044H,040H;D
		BYTE	0000,-008,044H,040H;D
;
;
;
SR1CKDT		EQU	$
		BYTE	004H,004H,004H,002H
		BYTE	003H,003H,003H,002H
		BYTE	003H,003H,003H,001H
		BYTE	003H,003H,003H,001H
;
;
;
SARU1SD		EQU	$
		BYTE	000H,002H,002H,002H,000H
		BYTE	002H,002H,002H,000H,000H
		BYTE	000H,002H,002H,002H,000H
		BYTE	002H,002H,002H,000H,000H
;
		BYTE	000H,002H,002H,002H,000H
		BYTE	000H,002H,002H,002H,000H
		BYTE	000H,002H,002H,002H,000H
		BYTE	002H,002H,002H,000H,000H
;
		BYTE	000H,000H,002H,002H,000H
		BYTE	000H,000H,002H,002H,000H
		BYTE	000H,000H,002H,002H,000H
		BYTE	002H,002H,000H,000H,000H
;
		BYTE	000H,000H,002H,002H,000H
		BYTE	000H,000H,002H,002H,000H
		BYTE	000H,000H,002H,002H,000H
		BYTE	002H,002H,000H,000H,000H
;
SARU1CS		EQU	$
		JSR	OAMCHK
;
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ADC	ENCHPT,X
		TAY
		LDA	SR1CKDT,Y
		STA	<WORK2
;
		LDA	ENCLOR,X
		STA	<WORK1
		STZ	<WORK0
		LDA	ENMUKI,X
		STA	<WORK3
		STZ	<WORK4
		LDA	ENCHPT,X
		STA	<WORK5
		STZ	<WORK6
;
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK3
		ASL	A
		ASL	A
		ADC	<WORK3
		ADC	<WORK5
		ASL	A
		ASL	A
		ADC	<WORK5
		STA	<WORK7
		ASL	A
		ASL	A
		TAX
;
		LDA	<WORK2
		AND	#000FFH
		STA	<WORKE
;
		LDY	<OAMADR
;
SR1OM10		EQU	$
		LDA	SARU1CD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
		LDA	SARU1CD,X
		ORA	<WORK0
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
		DEC	<WORKE
		BPL	SR1OM10
;
		LDX	<WORK7
;
		LDY	<OSBADR
		LDA	SARU1SD,X
		STA	OAMSB-OAMSB,Y
		LDA	SARU1SD+2,X
		STA	OAMSB-OAMSB+2,Y
		LDA	SARU1SD+3,X
		STA	OAMSB-OAMSB+3,Y
;
		MEM8
		IDX8
		SEP	#00110000B
		PLX
;
		JSR	SADWST		;KAGE SET
;
		LDA	#005H
		LDY	#0FFH
		JSR	ALOMCK
		RTS
;
;----------------------------------------

SAR3KNT		EQU	$
		BYTE	002H,002H,002H,004H
;
SAR3POT		EQU	$		; yuusen
;			atama,dou,ken1,ken2,ken3
		BYTE	000  ,004,008 ,012 ,016	;up
		BYTE	012  ,016,000 ,004 ,008	;down
		BYTE	000  ,004,008 ,012 ,016	;left
		BYTE	012  ,016,000 ,004 ,008	;right
;
SAR3WAK		EQU	$
SAR3OTM		EQU	$
		BYTE	084H,084H,084H,084H,084H
		BYTE	086H,086H,086H,086H,086H
		BYTE	088H,088H,088H,088H,088H
		BYTE	088H,088H,088H,088H,088H
SAR3KHR		EQU	$
		BYTE	084H,084H,084H,084H,084H
		BYTE	086H,086H,086H,086H,086H
		BYTE	088H,088H,088H,088H,088H
		BYTE	088H,088H,088H,088H,088H
;
SAR3BOD		EQU	$
		BYTE	0CAH,0CCH,0CAH,0CCH,0CAH
		BYTE	0C0H,0C2H,0C0H,0C2H,0C0H
		BYTE	0E4H,0E6H,0E4H,0E6H,0E4H
		BYTE	0E4H,0E6H,0E4H,0E6H,0E4H
		BYTE	0CEH,0E0H,0E0H,0E2H,0E2H
		BYTE	0C4H,0C6H,0C6H,0C8H,0C8H
		BYTE	0E8H,0EAH,0EAH,0ECH,0ECH
		BYTE	0E8H,0EAH,0EAH,0ECH,0ECH
;
SAR3OTMA	EQU	$
		BYTE	001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H
		BYTE	041H,041H,041H,041H,041H
		BYTE	001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H
		BYTE	041H,041H,041H,041H,041H
;
SAR3BODA	EQU	$
		BYTE	001H,001H,001H,041H,001H
		BYTE	001H,001H,001H,041H,001H
		BYTE	001H,001H,001H,001H,001H
		BYTE	041H,041H,041H,041H,041H
		BYTE	001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H
		BYTE	001H,001H,001H,001H,001H
		BYTE	041H,041H,041H,041H,041H
;
SAR3KNY		EQU	$
		BYTE	002H,0FEH,002H,003H,002H
		BYTE	010H,012H,010H,00DH,010H
		BYTE	00FH,00FH,00FH,00FH,00FH
		BYTE	00FH,00FH,00FH,00FH,00FH
		BYTE	008H,004H,0FDH,0F9H,0F8H
		BYTE	00CH,010H,00EH,011H,011H
		BYTE	0FAH,0FBH,001H,008H,00DH
		BYTE	0FAH,0FBH,001H,008H,00DH
;
SAR3KNX		EQU	$
                BYTE    00CH,00BH,00CH,00CH,00CH
                BYTE    0FDH,0FEH,0FDH,0FDH,0FDH
                BYTE    0FAH,0F6H,0FAH,0F6H,0FAH
                BYTE    006H,00AH,006H,00AH,006H
                BYTE    0F9H,0FBH,0FDH,006H,00AH
                BYTE    007H,005H,003H,003H,0FFH
                BYTE    002H,0FEH,0F6H,0F4H,0F2H
                BYTE    006H,00AH,00AH,00CH,00EH
SAR3KNC		EQU	$
		BYTE	000H,000H,000H,000H,000H
		BYTE	001H,001H,001H,001H,001H
		BYTE	002H,002H,002H,002H,002H
		BYTE	003H,003H,003H,003H,003H
		BYTE	002H,004H,005H,006H,000H
		BYTE	003H,007H,008H,009H,001H
		BYTE	000H,006H,005H,004H,002H
		BYTE	00DH,00AH,00BH,00CH,003H
;
SAR3OIK		EQU	$
		BYTE	003H,002H,001H,000H
;
SARU3MV		EQU	$
		JSR	SARU3CS
;
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENCTCT,X
		BEQ	SARU300
		LDA	ENCTFG,X
		BNE	SARU300
		DEC	ENCTCT,X
		LDA	#001H
		STA	ENCTFG,X
		LDA	#002H
		STA	ENTIM0,X
SARU300		EQU	$
		LDA	ENCTFG,X
		BEQ	SARU320
		LDA	ENTIM0,X
		BNE	SARU320
		INC	ENCTFG,X
		LDA	ENCTFG,X
		CMP	#006H
		BCC	SARU310
		STZ	ENCTFG,X
		BRA	SARU320
SARU310		EQU	$
		LDY	ENCTFG,X
		LDA	SAR3KNT-2,Y
		STA	ENTIM0,X
SARU320		EQU	$
;
		JSR	ENHNSB          ; hanekaeri 
;
		JSR	ENMVCL		; xclc,yclc
                JSR	ENBGCK		; BG check sub !
		JSR	CRKNKN		; Vs PL ken check
		JSR	CRENPL		; Vs PL body check
;
		JSR	EPXYCK		; PL point get
		LDA	<WORK+0FH
		CLC
		ADC	#011H
		CMP	#011H+011H
		BCS	SARU340
		LDA	<WORK+0EH
		CLC
		ADC	#011H
		CMP	#011H+011H
		BCS	SARU340		; PL chikai?
		LDA	ENMUKI,X
		AND	#003H
		CMP	SAR3OIK,Y
		BNE	SARU340
		JSL	>RNDSET
		AND	#003H
		BNE	SARU340
		JSR	SR3KNGO		; ken huri go
;
SARU340		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SARU3M0		;stop		
		WORD	SARU3M1		;ken huru		
		WORD	SARU3M2		;move1		
;
;----------------------------------------
KENXPSL		EQU	$
		BYTE	000H,000H,000H	;0
		BYTE	000H,000H,000H	;1
		BYTE	000H,008H,008H	;2
		BYTE	000H,008H,008H	;3
		BYTE	000H,008H,008H	;4
		BYTE	000H,008H,008H	;5
		BYTE	000H,000H,000H	;6
		BYTE	000H,008H,008H	;7
		BYTE	000H,000H,008H	;8
		BYTE	000H,000H,000H	;9
		BYTE	000H,000H,000H	;A
		BYTE	000H,008H,000H	;B
		BYTE	000H,008H,008H	;C
		BYTE	000H,000H,000H	;D
;
KENYPSL		EQU	$
		BYTE	000H,008H,008H	;0
		BYTE	000H,008H,008H	;1
		BYTE	000H,000H,000H	;2
		BYTE	000H,000H,000H	;3
		BYTE	000H,000H,000H	;4
		BYTE	000H,000H,008H	;5
		BYTE	000H,008H,008H	;6
		BYTE	000H,000H,000H	;7
		BYTE	000H,008H,008H	;8
		BYTE	000H,008H,008H	;9
		BYTE	000H,008H,008H	;A
		BYTE	000H,000H,008H	;B
		BYTE	000H,000H,000H	;C
		BYTE	000H,008H,008H	;D
;
KENCHAR		EQU	$
		BYTE	023H,033H,033H	;0
		BYTE	033H,023H,023H	;1
		BYTE	036H,037H,037H	;2
		BYTE	037H,036H,036H	;3
		BYTE	026H,027H,027H	;4
		BYTE	024H,025H,035H	;5
		BYTE	028H,038H,038H	;6
		BYTE	027H,026H,026H	;7
		BYTE	035H,025H,024H	;8
		BYTE	038H,028H,028H	;9
		BYTE	028H,038H,038H	;A
		BYTE	025H,024H,035H	;B
		BYTE	027H,026H,026H	;C
		BYTE	023H,033H,033H	;D
;
KENATRB		EQU	$
		BYTE	02BH,02BH,02BH	;0
		BYTE	0ABH,0ABH,0ABH	;1
		BYTE	02BH,02BH,02BH	;2
		BYTE	06BH,06BH,06BH	;3
		BYTE	02BH,02BH,02BH	;4
		BYTE	02BH,02BH,02BH	;5
		BYTE	02BH,02BH,02BH	;6
		BYTE	0EBH,0EBH,0EBH	;7
		BYTE	0EBH,0EBH,0EBH	;8
		BYTE	0EBH,0EBH,0EBH	;9
		BYTE	06BH,06BH,06BH	;A
		BYTE	06BH,06BH,06BH	;B
		BYTE	06BH,06BH,06BH	;C
		BYTE	06BH,06BH,06BH	;D
;
KENSET1		EQU	$
		LDA	<WORK+0FH
		STA	ENKNYP
		CLC
		ADC	ENDSYL
		STA	<WORK+0FH	; ken check add set Y.
		LDA	<WORK+0EH
		STA	ENKNXP
		CLC
		ADC	ENDSXL
		STA	<WORK+0EH	; ken check add set X.
;
		PHX
		LDY	<WORK+0CH
		LDA	<WORK+0DH
		ASL	A
		CLC
		ADC	<WORK+0DH
		TAX
;
		LDA	<WORK+0EH	;1 OAM
		CLC
		ADC	KENXPSL,X
		STA	(<OAMADR),Y
		LDA	<WORK+0FH
		CLC
		ADC	KENYPSL,X
		INY
		STA	(<OAMADR),Y
		LDA	KENCHAR,X
		INY
		STA	(<OAMADR),Y
		LDA	KENATRB,X
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORK+0EH	;2 OAM
		CLC
		ADC	KENXPSL+1,X
		INY
		STA	(<OAMADR),Y
		LDA	<WORK+0FH
		CLC
		ADC	KENYPSL+1,X
		INY
		STA	(<OAMADR),Y
		LDA	KENCHAR+1,X
		INY
		STA	(<OAMADR),Y
		LDA	KENATRB+1,X
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORK+0EH	;3 OAM
		CLC
		ADC	KENXPSL+2,X
		INY
		STA	(<OAMADR),Y
		LDA	<WORK+0FH
		CLC
		ADC	KENYPSL+2,X
		INY
		STA	(<OAMADR),Y
		LDA	KENCHAR+2,X
		INY
		STA	(<OAMADR),Y
		LDA	KENATRB+2,X
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORK+0CH
		LSR	A
		LSR	A
		TAY
		LDA	#00
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
;
		PLX
;
		RTS
;
;----------------------------------------
SARU3M0		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		
		LDA	ENTIM1,X
		BNE	SR3M010
;
		JSR	SR3KNGO
;
SR3M010		EQU	$
		RTS
;----------------------------------------
SARU3M1		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		LDA	ENCTFG,X
		STA	ENCHPT,X
		LDA	ENCTCT,X
		BNE	SR3M110
		LDA	ENCTFG,X
		BNE	SR3M110
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#0E0H
		STA	ENTIM1,X
;
		JSL	>RNDSET
		AND	#007H
		STA	ENMUKI,X
;
		INC	ENSTAT,X
;
SR3M110		EQU	$
		RTS
;----------------------------------------
SRXSDT		EQU	$
		BYTE	000H,000H,0F0H,010H,0F6H,00AH,0F6H,00AH
SRYSDT		EQU	$
		BYTE	0F0H,010H,000H,000H,0F6H,00AH,00AH,0F6H
SARU3M2		EQU	$
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	ENCHPT,X
		AND	#001H
		STA	ENZPSL,X
;
		LDA	ENTIM1,X
		BNE	SR3M210
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#005H
		STA	ENTIM1,X
;
		STZ	ENSTAT,X
;
SR3M210		EQU	$
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	SR3M220		;atari?
;
		LDA	ENMUKI,X
		EOR	#001H
		STA	ENMUKI,X
;
SR3M220		EQU	$
		LDY	ENMUKI,X
		LDA	SRXSDT,Y
		STA	ENXSPD,X
		LDA	SRYSDT,Y
		STA	ENYSPD,X
;
		RTS
;----------------------------------------
SR3KNGO		EQU	$		;ken huri go
;
		LDA	ENCTCT,X
		BNE	SR3KG10
		JSL	>RNDSET
		AND	#003H
		CLC
		INC	A
		STA	ENCTCT,X
;
		LDA	#001H
		STA	ENSTAT,X
;
SR3KG10		EQU	$
		RTS
;----------------------------------------
SARU3CS		EQU	$
		LDA	ENMUKI,X
		AND	#003H
		STA	<WORK
		ASL	A
		ASL	A
		ADC	<WORK
		STA	<WORK
		STA	<WORK+01H
		LDA	ENCTFG,X
		BEQ	SARU330		;KEN huri?
;					;y
		LDA	<WORK
		CLC
		ADC	#SAR3KHR-SAR3WAK-1
		STA	<WORK
SARU330		EQU	$
		LDA	ENCHPT,X
		CLC
		ADC	<WORK
		STA	<WORK
;
		LDA	ENCLOR,X
		STA	<WORK+02H
		LDA	ENDSXL
		STA	<WORK+03H
		LDA	ENDSYL
		STA	<WORK+04H
		PHX
		LDX	<WORK
;
		LDY	<WORK+01H	;osaru no otum set
		LDA	SAR3POT,Y
		TAY
		LDA	<WORK+03H
		STA	(<OAMADR),Y
		LDA	<WORK+04H
		INY
		STA	(<OAMADR),Y
		LDA	SAR3OTM,X
		INY
		STA	(<OAMADR),Y
		LDA	SAR3OTMA,X
		ORA	<WORK+02H
		INY
		STA	(<OAMADR),Y
		LDY	<WORK+01H
		LDA	SAR3POT,Y
		LSR	A
		LSR	A
		TAY
		LDA	#002H
		STA	(<OSBADR),Y
;
		LDY	<WORK+01H	;osaru no body set
		LDA	SAR3POT+1,Y
		TAY
		LDA	<WORK+03H
		STA	(<OAMADR),Y
		LDA	<WORK+04H
		CLC
		ADC	#008H
		INY
		STA	(<OAMADR),Y
		LDA	SAR3BOD,X
		INY
		STA	(<OAMADR),Y
		LDA	SAR3BODA,X
		ORA	<WORK+02H
		INY
        	STA	(<OAMADR),Y
		LDY	<WORK+01H
		LDA	SAR3POT+1,Y
		LSR	A
		LSR	A
		TAY
		LDA	#002H
		STA	(<OSBADR),Y
;
		PLX
;
		LDY	<WORK+01H	;osaru no ken set
		LDA	SAR3POT+2,Y
;
		STA	<WORK+0CH
		LDY	<WORK
		LDA	SAR3KNY,Y
		STA	<WORK+0FH
		LDA	SAR3KNX,Y
		STA	<WORK+0EH
		LDA	SAR3KNC,Y
		STA	<WORK+0DH
		JSR	KENSET1		;work+0f Y work+0e X work+0d C work+0c oam address set
;
;
		LDY	#0FFH		; obj clc?
		LDA	#005H
		JSR	ALOMCK
;
		LDA	#012H
		JSR	SADWS2
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		OHYES                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OHYESMV		EQU	$
		JSR	OHYESCS
;
		JSR	ENSTCK		; scroll : not return !
;
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		; Vs PL body check
;
		LDA	<FRCNT
		AND	#080H
		BEQ	MANMV30
		LDA	ENZPSL,X
		BEQ	MANMV40
		BPL	MANMV30
		STZ	ENZPSL,X
		STZ	ENZSPD,X
		BRA	MANMV40
MANMV30		EQU	$
		JSR	ENZCLC
		LDA	ENZPSL,X
		BNE	MANMV20
		LDA	#010H
		STA	ENZSPD,X
MANMV20		EQU	$
		DEC	ENZSPD,X
;
MANMV40		EQU	$
		LDA	ENHNFG,X
		BEQ	MANMV10		;BAUND?
		STZ	ENSTAT,X	;Y
MANMV10		EQU	$
		JSR	ENHNSB          ; hanekaeri 
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MANY2M0		;move1		;SEACH
		WORD	MANY2M1		;    2		;LOOK
		WORD	MANY2M2		;stop		
		WORD	MANY2M3		;totugeki!!		
		WORD	MANY2M4		;		
;----------------------------------------
MANY2M0		EQU	$
		JSR	ENMVCL		; xclc,yclc
		TXA
		EOR	<FRCNT
		AND	#003H
		BNE	MANY210
;
		LDA	>KRXBUF,X
		STA	<WORK4
		LDA	>KRXBUF+10H,X
		STA	<WORK5
		LDA	>KRYBUF,X
		STA	<WORK6
		LDA	>KRYBUF+10H,X
		STA	<WORK7
		LDA	#017H
		JSR	ESERCH
		LDA	<WORK+00H
		STA	ENYSPD,X
		LDA	<WORK+01H
		STA	ENXSPD,X
;
MANY210		EQU	$
		LDA	ENXPSL,X
;		SEC
		SBC	>KRXBUF,X
;		CLC
		ADC	#003
		CMP	#007
		BCS	MANY220
;
		LDA	ENYPSL,X
;		SEC
		SBC	>KRYBUF,X
;		CLC
		ADC	#003
		CMP	#007
		BCS	MANY220
;
		INC	ENSTAT,X
MANY220		EQU	$
		RTS
;----------------------------------------
MANY2M1		EQU	$
		TXA
		EOR	<FRCNT
		AND	#00EH
		EOR	ENCLOR,X
		STA	ENCLOR,X
;
		LDA	>KRXBUF,X
		STA	ENXPSL,X
		LDA	>KRXBUF+10H,X
		STA	ENXPSH,X
		LDA	>KRYBUF,X
		STA	ENYPSL,X
		LDA	>KRYBUF+10H,X
		STA	ENYPSH,X
;
		LDA	>KRYBUF+20H
		CMP	#001H
		BNE	MY2M120
		LDA	#003H
		STA	ENSTAT,X
		BRA	MY2M110
;
MY2M120		EQU	$
		JSL	>RNDSET
		ORA	<FRCNT
		AND	#03FH
		BNE	MY2M110
		JSL	>RNDSET
		AND	#00FH
		CLC
		ADC	#0B0H
		STA	ENTIM0,X
;
		INC	ENSTAT,X
MY2M110		EQU	$
		RTS
;
;----------------------------------------
MANY2M2		EQU	$
		LDA	ENTIM0,X
		BNE	MY2M210
;
		LDA	ENZPSL,X
		BNE	MY2M210
;
		STZ	ENSTAT,X
;
MY2M210		EQU	$
		RTS
;
;----------------------------------------
MANY2M3		EQU	$
		LDA	#0C0H
		STA	ENTIM0,X
;
		LDA	#002H
		STA	ENSTAT,X
;
		RTS
;
;----------------------------------------
MANY2M4		EQU	$
		RTS
;
;----------------------------------------
OHYESOD		EQU	$
		WORD	00000,00000
		BYTE	000H,000H,000H,002H
		WORD	00016,00000
		BYTE	000H,000H,000H,002H
		WORD	00032,00000
		BYTE	000H,000H,000H,002H
		WORD	00048,00000
		BYTE	000H,000H,000H,002H
		WORD	00064,00000
		BYTE	000H,000H,000H,002H
		WORD	00000,00008
		BYTE	000H,000H,000H,002H
		WORD	00016,00008
		BYTE	000H,000H,000H,002H
		WORD	00032,00008
		BYTE	000H,000H,000H,002H
		WORD	00048,00008
		BYTE	000H,000H,000H,002H
		WORD	00064,00008
		BYTE	000H,000H,000H,002H
;
		WORD	00000,00000
		BYTE	001H,000H,000H,002H
		WORD	00016,00000
		BYTE	001H,000H,000H,002H
		WORD	00032,00000
		BYTE	001H,000H,000H,002H
		WORD	00048,00000
		BYTE	001H,000H,000H,002H
		WORD	00064,00000
		BYTE	001H,000H,000H,002H
		WORD	00000,00008
		BYTE	001H,000H,000H,002H
		WORD	00016,00008
		BYTE	001H,000H,000H,002H
		WORD	00032,00008
		BYTE	001H,000H,000H,002H
		WORD	00048,00008
		BYTE	001H,000H,000H,002H
		WORD	00064,00008
		BYTE	001H,000H,000H,002H
;
		WORD	00000,00000
		BYTE	002H,000H,000H,002H
		WORD	00016,00000
		BYTE	002H,000H,000H,002H
		WORD	00032,00000
		BYTE	002H,000H,000H,002H
		WORD	00048,00000
		BYTE	002H,000H,000H,002H
		WORD	00064,00000
		BYTE	002H,000H,000H,002H
		WORD	00000,00008
		BYTE	002H,000H,000H,002H
		WORD	00016,00008
		BYTE	002H,000H,000H,002H
		WORD	00032,00008
		BYTE	002H,000H,000H,002H
		WORD	00048,00008
		BYTE	002H,000H,000H,002H
		WORD	00064,00008
		BYTE	002H,000H,000H,002H
;
		WORD	00000,00000
		BYTE	003H,000H,000H,002H
		WORD	00016,00000
		BYTE	003H,000H,000H,002H
		WORD	00032,00000
		BYTE	003H,000H,000H,002H
		WORD	00048,00000
		BYTE	003H,000H,000H,002H
		WORD	00064,00000
		BYTE	003H,000H,000H,002H
		WORD	00000,00008
		BYTE	003H,000H,000H,002H
		WORD	00016,00008
		BYTE	003H,000H,000H,002H
		WORD	00032,00008
		BYTE	003H,000H,000H,002H
		WORD	00048,00008
		BYTE	003H,000H,000H,002H
		WORD	00064,00008
		BYTE	003H,000H,000H,002H
;
OHYESCS		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010		;KAZU
		STA	<WORK6
;
		LDA	ENMUKI,X
		AND	#00001H
		STA	<WORK0
		ASL	A
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
;
		LDA	ENCHPT,X
		AND	#00001H
		STA	<WORK2
		ASL	A
		ASL	A
		ADC	<WORK2
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	<WORK0
		ADC	#OHYESOD
		STA	<WORK8
;		LDA	#BANK OHYESOD
;		ADC	#00000H
;		STA	<WORKA
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSL	>SETOAML
;
		RTS
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		TOTUG set                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TTGBDCD		EQU	$
		BYTE	0A0H,0A2H,0A0H,0A2H	;0
		BYTE	08CH,08EH,08CH,08EH	;1
		BYTE	0A4H,0A6H,0A4H,0A6H	;2
		BYTE	0A4H,0A6H,0A4H,0A6H	;3
		BYTE	084H,084H,084H,084H	;0 atama del del
		BYTE	080H,080H,080H,080H	;1
		BYTE	082H,082H,082H,082H	;2
		BYTE	082H,082H,082H,082H	;3
;
TTGBDAD		EQU	$
		BYTE	007H,007H,007H,047H	;0
		BYTE	007H,007H,007H,047H	;1
		BYTE	007H,007H,007H,007H	;2
		BYTE	047H,047H,047H,047H	;3
		BYTE	007H,007H,007H,007H	;0 atama del del
		BYTE	007H,007H,007H,007H	;1
		BYTE	007H,007H,007H,007H	;2
		BYTE	047H,047H,047H,047H	;3
;
TTGATCD		EQU	$
		BYTE	08AH,08AH,08AH,08AH	;0
		BYTE	086H,086H,086H,086H	;1
		BYTE	088H,088H,088H,088H	;2
		BYTE	088H,088H,088H,088H	;3
TTGATKI		EQU	$
		BYTE	0A0H,0A0H,0A0H,0A0H	;0
		BYTE	08CH,08CH,08CH,08CH	;1
		BYTE	0A4H,0A4H,0A4H,0A4H	;2
		BYTE	0A4H,0A4H,0A4H,0A4H	;3
;
TTGATAD		EQU	$
		BYTE	007H,007H,047H,047H	;0
		BYTE	007H,007H,047H,047H	;1
		BYTE	007H,007H,007H,007H	;2
		BYTE	047H,047H,047H,047H	;3
		BYTE	007H,007H,007H,007H	;0
		BYTE	007H,007H,007H,007H	;1
		BYTE	007H,007H,007H,007H	;2
		BYTE	047H,047H,047H,047H	;3
;
TOTUGMV		EQU	$
		JSR	TOTUGCS
;
		JSR	ENSTCK		; scroll : not return !
;
		JSR	CRENPL		; Vs PL body check
		JSR	ENMVCL		; xclc,yclc
TOTUG20		EQU	$
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
;
		WORD	TOTUGM0
		WORD	TOTUGM1
		WORD	TOTUGM2
		WORD	TOTUGM3
;------------------------------
TOTUMKD		EQU	$
		BYTE	3,2,1,0
TOTUGM0		EQU	$
		LDA	<FRCNT
		AND	#007H
		BNE	TTGM020
;
		JSR	EPXYCK
		LDA	<WORK+0FH
		CLC
		ADC	#008H
		CMP	#008H+008H
		BCC	TTGM030
		LDA	<WORK+0EH
		CLC
		ADC	#008H
		CMP	#008H+008H
		BCS	TTGM010		; PL chikai?
;					;y
TTGM030		EQU	$
		LDA	#010H
		STA	ENTIM0,X
		LDA	TOTUMKD,Y
		STA	ENMUKI,X
		INC	ENSTAT,X
TTGM010		EQU	$
		STZ	ENCHPT,X
		STZ	ENXSPD,X
		STZ	ENYSPD,X
TTGM020		EQU	$
;		JSR	TOTUGSU
		RTS
;------------------------------
TOTUGM1		EQU	$		;ATAMA DEL del
;
;
;		LDA	OAM+1,Y
;		CLC
;		ADC	ENTIM0,X
;		STA	<WORK+00H
;;
;		LDA	OAM+5,Y
;		STA	OAM+1,Y
;		LDA	<WORK+00H
;		STA	OAM+5,Y
;;
		LDY	#01
		LDA	(<OAMADR),Y
		LDY	#05
		STA	(<OAMADR),Y
;
		LDA	ENTIM0,X
		BNE	TTGM110
		INC	ENSTAT,X
;
		LDA	ENXPSL,X	;position save
		STA	ENWRK0,X
		LDA	ENXPSH,X
		STA	ENWRK1,X
		LDA	ENYPSL,X
		STA	ENWRK2,X
		LDA	ENYPSH,X
		STA	ENCMKI,X
TTGM110		EQU	$
		RTS
;------------------------------		;TOTUGEKI
TOTUSPX		EQU	$
		BYTE	000H,000H,0F0H,010H
TOTUSPY		EQU	$
		BYTE	0F0H,010H,000H,000H
TOTUGM2		EQU	$
		LDA	ENTIM0,X
		BNE	TTGM210
;
		LDY	ENMUKI,X
		LDA	TOTUSPX,Y
		STA	ENXSPD,X
		LDA	TOTUSPY,Y
		STA	ENYSPD,X
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	ENCHPT,X
;
TTGM210		EQU	$
		LDA	<FRCNT
		AND	#003H
		BNE	TTGM220
		JSR	ENBGCK          ;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BEQ	TTGM220
		LDA	#003H
		STA	ENSTAT,X
		STZ	ENXSPD,X
		STZ	ENYSPD,X
TTGM220		EQU	$
		RTS
;------------------------------		;KAERU
TOTUGM3		EQU	$
;		LDA	ENTIM0,X
;		BNE	TTGM310
;
		LDA	<FRCNT
		AND	#01FH
		BNE	TTGM320
;
		LDA	<PLYPS1		;moto no toko sagasu
		PHA
		LDA	<PLYPS0
		PHA
		LDA	<PLXPS1
		PHA
		LDA	<PLXPS0
		PHA
		LDA	ENWRK0,X
		STA	<PLXPS1
		LDA	ENWRK1,X
		STA	<PLXPS0
		LDA	ENWRK2,X
		STA	<PLYPS1
		LDA	ENCMKI,X
		STA	<PLYPS0
		LDA	#010H
		JSR	PSERC2
		LDA	<WORK+00H
		STA	ENYSPD,X
		LDA	<WORK+01H
		STA	ENXSPD,X
		PLA
		STA	<PLXPS0
		PLA
		STA	<PLXPS1
		PLA
		STA	<PLYPS0
		PLA
		STA	<PLYPS1
;
;					;muki set
		LDA	<WORK+00H
		BPL	TTGM350
		EOR	#0FFH
		INC	A
TTGM350		EQU	$
		STA	<WORK+02H
		LDA	<WORK+01H
		BPL	TTGM360
		EOR	#0FFH
		INC	A
TTGM360		EQU	$
		STA	<WORK+03H
;
		LDA	<WORK+02H
		CMP	<WORK+03H
		BCC	TTGM330
		LDA	<WORK+00H
		ASL	A
		ROL	A
		AND	#001H
		BRA	TTGM340
TTGM330		EQU	$
		LDA	<WORK+01H
		SEC
		ROL	A
		ROL	A
		AND	#003H
TTGM340		EQU	$
		EOR	#001H
		STA	ENMUKI,X
;
TTGM320		EQU	$		;muki set
		LDA	<FRCNT		;e cng
		LSR	A
		LSR	A
		AND	#003H
		STA	ENCHPT,X
;
		LDA	ENXPSL,X	;moto no toko?
		CMP	ENWRK0,X
		BNE	TTGM310
		LDA	ENYPSL,X
		CMP	ENWRK2,X
		BNE	TTGM310
		LDA	ENXPSH,X
		CMP	ENWRK1,X
		BNE	TTGM310
		LDA	ENYPSH,X
		CMP	ENCMKI,X
		BNE	TTGM310
;
		STZ	ENSTAT,X	;y
		STZ	ENXSPD,X
		STZ	ENYSPD,X
TTGM310		EQU	$
		RTS
;------------------------------
TOTUGSU		EQU	$
		LDA	#001H
		JSR	PSERC2
		LDA	<WORK+00H
		EOR	#0FFH
		SEC
		ADC	<PLYSPD
		STA	<PLYSPD
		LDA	<WORK+01H
		EOR	#0FFH
		SEC
		ADC	<PLXSPD
		STA	<PLXSPD
		RTS
;----------------------------------------
TOTUGCS		EQU	$
		JSR	OAMCHK
;
		LDA	ENMUKI,X		;OAM SET DATA INDEX SET
		ASL	A
		ASL	A
		CLC
		ADC	ENCHPT,X
		TAY
		LDA	ENSTAT,X	
		CMP	#001H
		BNE	TOTUG04			;DEL DEL?
		TYA				;Y
		CLC
		ADC	#TTGATKI-TTGATCD
		TAY
TOTUG04		EQU	$
		LDA	ENSTAT,X		;MOVE ?	SET
		STA	<WORK+00
		PHX
		TYX
		LDA	ENDSXL
		LDY	#00
		STA	(<OAMADR),Y
		LDY	#04
		STA	(<OAMADR),Y
		LDA	<WORK+00H
		CMP	#01H			;MOVE ?
		LDA	ENDSYL
		BCC	TOTUG08
		LDY	#01
		STA	(<OAMADR),Y
TOTUG08		EQU	$
		CLC
		ADC	#008H
		LDY	#05
		STA	(<OAMADR),Y
		LDA	TTGBDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	TTGBDAD,X
		INY
		ORA	<WORK+03H
		STA	(<OAMADR),Y
		LDA	TTGATCD,X
		LDY	#02
		STA	(<OAMADR),Y
		LDA	TTGATAD,X
		INY
		ORA	<WORK+03H
		STA	(<OAMADR),Y
		PLX
;
		LDY	#002H		; obj clc?
		LDA	#001H
		JSR	ALOMCK
;
		LDA	#012H
		JSR	SADWS2
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	PONPK move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PNPKCD0		EQU	$				;char data
		WORD	0007EH,0005EH,0007EH,0405FH	;XO
		WORD	0007EH,0004EH,0007EH,0404FH	;OO
		WORD	0007EH,0406FH,0007EH,0406FH	;OO
		WORD	0007EH,0006EH,0007EH,0006EH
;
PNPKCD1		EQU	$
		WORD	0007FH,0005FH,0007FH,0405EH	;OX
		WORD	0007FH,0004FH,0007FH,0404EH	;OO
		WORD	0007FH,0406EH,0007FH,0406EH	;OO
		WORD	0007FH,0006FH,0007FH,0006FH
;
PNPKCD2		EQU	$
		WORD	0006AH,00062H,0006AH,04062H	;OO
		WORD	00068H,00060H,00068H,04060H	;XX
		WORD	0406CH,04064H,0406CH,04066H	;XX
		WORD	0006CH,00064H,0006CH,00066H
;
PONPKMV		EQU	$
		JSR	PONPKCS
;
		JSR	ENSTCK		; scroll : not return !
;
		JSR	ENHNSB          ; hanekaeri 
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		; Vs PL body check
		JSR	ENMVCL		; xclc,yclc
;
		TXA
		EOR	<FRCNT
		AND	#003H
		BNE	PONPK20
;
		JSR	ENBGCK		;BG check sub
		LDA	ENCBFG,X	;kabe atari
		AND	#00FH
		BEQ	PONPK20
		LDA	ENXSPD,X
		EOR	#0FFH
		STA	ENXSPD,X
		LDA	ENYSPD,X
		EOR	#0FFH
		STA	ENYSPD,X
;
PONPK20		EQU	$
		JSR	PNPSTST		;ENSTAT,X SET
;
		LDA	ENSTAT,X
		CMP	#001
		BEQ	PONPKM1
		JSL	>JSRSUB
;
		WORD	PONPKM0		;stop ( isi )
		WORD	PONPKM1		;move1
		WORD	PONPKM2		;move2
;
;----------------------------------------
PONPKM0		EQU	$
		LDA	ENXSPD,X
		BEQ	PNPM010
		BMI	PNPM020
		DEC	A
		BRA	PNPM010
PNPM020		EQU	$
		INC	A
PNPM010		EQU	$
		STA	ENXSPD,X
;
		LDA	ENYSPD,X
		BEQ	PNPM030
		BMI	PNPM040
		DEC	A
		BRA	PNPM030
PNPM040		EQU	$
		INC	A
PNPM030		EQU	$
		STA	ENYSPD,X
;
		ORA	ENXSPD,X
		BEQ	PNPM050
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#003
		STA	ENCHPT,X
;
PNPM050		EQU	$
		RTS
;----------------------------------------
PNPXSPD		EQU	$
		BYTE	001H,0FFH
		BYTE	002H,0FEH
;
PNPYSPD		EQU	$
		BYTE	001H,0FFH
		BYTE	002H,0FEH
;
PNPXSLM		EQU	$
		BYTE	005H,0FCH
		BYTE	005H,0FCH
;
PNPYSLM		EQU	$
		BYTE	005H,0FCH
		BYTE	005H,0FCH
;
PONPKM1		EQU	$
		TXA
		EOR	<FRCNT
		AND	#007H
		BEQ	PNPM1ST		;MOVE?
		BRL	PNPM1D0		;N
;
PNPM1ST		EQU	$		;Y
;
		LDA	#002H		;PL SEACH
		JSR	PSERC2
		LDA	<WORK+00H
		CLC
		ADC	ENYSPD,X
		STA	ENYSPD,X
		LDA	<WORK+01H
		CLC
		ADC	ENXSPD,X
		STA	ENXSPD,X
;
		LDA	ENWRK0,X	;X SPD SET
		ORA	ENWRK2,X
		TAY
		AND	#001H
		BEQ	PNPM110
;
		LDA	ENXSPD,X
		BPL	PNPM120
		CMP	PNPXSLM,Y
		BCC	PNPM130
		BRA	PNPM120
;
PNPM110		EQU	$
		LDA	ENXSPD,X
		BMI	PNPM120
		CMP	PNPXSLM,Y
		BCS	PNPM130
		BRA	PNPM120
;
PNPM130		EQU	$
		LDA	ENWRK0,X
		EOR	#001H
		STA	ENWRK0,X
		BRA	PNPM140
;
PNPM120		EQU	$
		CLC
		ADC	PNPXSPD,Y
		STA	ENXSPD,X
;
PNPM140		EQU	$
		LDA	ENWRK1,X	;Y SPD SET
		ORA	ENWRK2,X
		TAY
		AND	#001H
		BEQ	PNPM150
;
		LDA	ENYSPD,X
		BPL	PNPM160
		CMP	PNPYSLM,Y
		BCC	PNPM170
		BRA	PNPM160
;
PNPM150		EQU	$
		LDA	ENYSPD,X
		BMI	PNPM160
		CMP	PNPYSLM,Y
		BCS	PNPM170
		BRA	PNPM160
;
PNPM170		EQU	$
		LDA	ENWRK1,X
		EOR	#001H
		STA	ENWRK1,X
		BRA	PNPM180
;
PNPM160		EQU	$
		CLC
		ADC	PNPYSPD,Y
		STA	ENYSPD,X
;
PNPM180		EQU	$
		LDA	ENXSPD,X	;MUKI SET
		BPL	PNPM1A0
		EOR	#0FFH
		INC	A
PNPM1A0		EQU	$
		STA	<WORK0
;
		LDA	ENYSPD,X
		BPL	PNPM1B0
		EOR	#0FFH
		INC	A
PNPM1B0		EQU	$
		STA	<WORK1
;
		LDA	<WORK0
		CMP	<WORK1
		BCC	PNPM1C0
;
		LDA	ENXSPD,X
		SEC
		ROL	A
		ROL	A
		BRA	PNPM1C5
;
PNPM1C0		EQU	$
		LDA	ENYSPD,X
		CLC
		ROL	A
		ROL	A
PNPM1C5		EQU	$
		AND	#003H
		EOR	#001H
		STA	ENMUKI,X
;
PNPM1D0		EQU	$
		LDA	ENWRK2,X
		BNE	PNPM1E0

		LDA	<FRCNT
		LSR	A
		LSR	A
		BRA	PNPM1F0
;
PNPM1E0		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
PNPM1F0		EQU	$
		AND	#003
		STA	ENCHPT,X
PNPM1EX		EQU	$
		RTS
;----------------------------------------
PONPKM2		EQU	$
		LDA	ENWRK2,X
		EOR	#002H
		STA	ENWRK2,X
;
		TAY
		LDA	PNPXSLM,Y
		STA	ENXSPD,X
		STZ	ENYSPD,X
		RTS
;----------------------------------------
PNPSTDT		EQU	$
		BYTE	004H,006H,000H,002H
PNPSTST		EQU	$
		STZ	ENSTAT,X
		JSR	EPXYCK		; PL point get
		LDA	PNPSTDT,Y
		CMP	<PLMKCH
		BEQ	PNPST10
		INC	ENSTAT,X
PNPST10		EQU	$
		LDA	<FRCNT
		AND	#0FFH
		BNE	PNPST20
		INC	ENSTAT,X
PNPST20		EQU	$
		RTS
;----------------------------------------
PONPKCS		EQU	$
		JSR	OAMCHK
;
		STZ	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
		LDA	ENSTAT,X
		BNE	PONPK10
		LDA	#0AH
		TSB	<WORK1
PONPK10		EQU	$
;
		PHX
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		CLC
		ADC	ENCHPT,X
		ASL	A
		TAX	
;
		LDY	#004		;X set
		LDA	ENDSXL
		CLC
		ADC	#008H
		STA	(<OAMADR),Y
;
		LDA	ENDSYL		;Y set
		INY
		STA	(<OAMADR),Y
;
		MEM16
		IDX8
		REP	#00100001B
;
		LDA	ENDSXL		;X,Y set
		LDY	#00
		STA	(<OAMADR),Y
		ADC	#00800H
		LDY	#08
		STA	(<OAMADR),Y
;
;
		LDA	PNPKCD0,X	;CHAR set
		ORA	<WORK0
		LDY	#02
		STA	(<OAMADR),Y
		LDA	PNPKCD1,X
		ORA	<WORK0
		LDY	#06
		STA	(<OAMADR),Y
		LDA	PNPKCD2,X
		ORA	<WORK0
		LDY	#10
		STA	(<OAMADR),Y
;
		LDA	#0000
		TAY
		STA	(<OSBADR),Y	;OAMSB set
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#002H
		TAY
		STA	(<OSBADR),Y
;
		PLX
;
		LDY	#0FFH		; obj clc?
		LDA	#002H
		JSR	ALOMCK
;
		LDA	#013H
		JSR	SADWS2
		RTS
;
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	TAAM1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAAM1MV		EQU	$
		JSR	TAAM1CS
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	TAAM1M0
		WORD	TAAM1M1
		WORD	TAAM1M2
		WORD	TAAM1M3
		WORD	TAAM1M4
		WORD	TAAM1M5
;----------------------------------------
TAAM1M0		EQU	$
		LDA	ENCRTM,X
		CMP	#YAMOV
		BNE	TM1M010
;
		INC	SWCHFG
;
		STZ	ENCRTM,X
		INC	ENSTAT,X
;
		LDA	#007H
		STA	ENTIM0,X
;
		LDA	ENMOD0,X
		AND	#0E0H
		ORA	#003H
		STA	ENMOD0,X
;
TM1M010		EQU	$
		RTS
;----------------------------------------
TAAM1M1		EQU	$
		LDA	ENTIM0,X
		BNE	TM1M110
;
		INC	ENSTAT,X
;
		LDA	#007H
		STA	ENTIM0,X
;
		LDA	ENMOD0,X
		AND	#0E0H
		ORA	#004H
		STA	ENMOD0,X
;
TM1M110		EQU	$
		RTS
;----------------------------------------
TAAM1M2		EQU	$
		LDA	ENTIM0,X
		BNE	TM1M210
;
		INC	ENSTAT,X
;
		LDA	#007H
		STA	ENTIM0,X
;
TM1M210		EQU	$
		RTS
;----------------------------------------
TAAM1M3		EQU	$
		LDA	ENTIM0,X
		BNE	TM1M310
;
		INC	ENSTAT,X
;
		LDA	#007H
		STA	ENTIM0,X
;
TM1M310		EQU	$
		RTS
;----------------------------------------
TAAM1M4		EQU	$
		LDA	ENTIM0,X
		BNE	TM1M410
;
		INC	ENSTAT,X
;
		LDA	#0FFH
		STA	ENTIM0,X
;
		LDA	ENMOD0,X
		AND	#0E0H
		ORA	#001H
		STA	ENMOD0,X
;
TM1M410		EQU	$
		RTS
;----------------------------------------
TAAM1M5		EQU	$
;		LDA	ENTIM0,X
;		BNE	TM1M510
;
;		STZ	ENSTAT,X
;
;		LDA	ENMOD0,X
;		AND	#0F0H
;		ORA	#000H
;		STA	ENMOD0,X
;
TM1M510		EQU	$
		RTS
;----------------------------------------
TM1CSFR		EQU	$
		BYTE	001,003,003,003
TM1CSCL		EQU	$
		BYTE	002,004,006,004
;
TAAM1CS		EQU	$
		LDY	ENMUKI,X
		LDA	<FRCNT
		AND	TM1CSFR,Y
		BNE	TAM1C10		;frm end?
		TYA			;y
		INC	A
		AND	#003H
		STA	ENMUKI,X
		TAY
;
TAM1C10		EQU	$		;COLOR cng
;;		LDA	ENCLOR,X
;;		AND	#11110000B
		LDA	TM1CSCL,Y
		STA	ENCLOR,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	TAAM1C0
		WORD	TAAM1C1
		WORD	TAAM1C2
		WORD	TAAM1C3
		WORD	TAAM1C4
		WORD	TAAM1C5
;----------------------------------------
TAAM1C0		EQU	$
		JSR	OAMCHK
		STZ	ENCHPT,X
		BRL	EN1CST
;----------------------------------------
TM1C1DT		EQU	$
		BYTE	-4,-2,0F3H,000H
		BYTE	01,-8,0F3H,0C0H
		BYTE	12,-5,0F3H,080H
TAAM1C1		EQU	$
;;		JSR	OAMCHK
		LDA	#001H
		STA	ENCHPT,X
		JSR	EN1CST
;
		LDA	<OAMADR
		CLC
		ADC	#004H
		STA	<OAMADR
		LDA	<OAMADR+1
		ADC	#000H
		STA	<OAMADR+1
;
		LDA	<OSBADR
		CLC
		ADC	#001H
		STA	<OSBADR
		LDA	<OSBADR+1
		ADC	#000H
		STA	<OSBADR+1
;
		LDY	#011
;
TM1C110		EQU	$		;HAHEN SET
;;		LDA	ENCLOR,X
		LDA	<WORK5
		ORA	TM1C1DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C1DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C1DT,Y
		CLC
		ADC	ENDSYL
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C1DT,Y
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
		DEY
;
		BPL	TM1C110
;
		LDY	#000
		LDA	#000
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
;
		LDY	#000
		LDA	#002
		JSR	ALOMCK
;
		RTS
;----------------------------------------
TM1C2DT		EQU	$
		BYTE	-9,-5,0E3H,000H
		BYTE	07,-8,0E3H,080H
		BYTE	18,01,0E3H,0C0H
		BYTE	00,08,0E3H,000H
		BYTE	08,08,0F3H,000H
;
TAAM1C2		EQU	$
		JSR	OAMCHK
;
		LDY	#019
;
TM1C210		EQU	$		;HAHEN SET
;;		LDA	ENCLOR,X
		LDA	<WORK5
		ORA	TM1C2DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C2DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C2DT,Y
		CLC
		ADC	ENDSYL
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C2DT,Y
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
		DEY
;
		BPL	TM1C210
;
		LDY	#004
		LDA	#000
;
TM1C220		EQU	$
		STA	(<OSBADR),Y
		DEY
		BPL	TM1C220
;
		LDY	#000
		LDA	#004
		JSR	ALOMCK
;
		RTS
;----------------------------------------
TM1C3DT		EQU	$
		BYTE	-14,01,080H,000H
		BYTE	 15,-4,080H,000H
		BYTE	 24,07,080H,000H
		BYTE	 00,08,0E3H,000H
		BYTE	 08,08,0F3H,000H
;
TAAM1C3		EQU	$
		JSR	OAMCHK
;
		LDY	#019
;
TM1C310		EQU	$		;HAHEN SET
;;		LDA	ENCLOR,X
		LDA	<WORK5
		ORA	TM1C3DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C3DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C3DT,Y
		CLC
		ADC	ENDSYL
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C3DT,Y
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
		DEY
;
		BPL	TM1C310
;
		LDY	#004
		LDA	#000
;
TM1C320		EQU	$
		STA	(<OSBADR),Y
		DEY
		BPL	TM1C320
;
		LDY	#000
		LDA	#004
		JSR	ALOMCK
;
		RTS
;----------------------------------------
TM1C4DT		EQU	$
		BYTE	-16,04,083H,000H
		BYTE	 16,00,083H,000H
		BYTE	 26,10,083H,000H
		BYTE	 00,08,0E3H,000H
		BYTE	 08,08,0F3H,000H
;
TAAM1C4		EQU	$
		JSR	OAMCHK
;
		LDY	#019
;
TM1C410		EQU	$		;HAHEN SET
;;		LDA	ENCLOR,X
		LDA	<WORK5
		ORA	TM1C4DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C4DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C4DT,Y
		CLC
		ADC	ENDSYL
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C4DT,Y
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
		DEY
;
		BPL	TM1C410
;
		LDY	#004
		LDA	#000
;
TM1C420		EQU	$
		STA	(<OSBADR),Y
		DEY
		BPL	TM1C420
;
		LDY	#000
		LDA	#004
		JSR	ALOMCK
;
		RTS
;----------------------------------------
TM1C5DT		EQU	$
		BYTE	00,08,0E3H,000H
		BYTE	08,08,0F3H,000H
;
TAAM1C5		EQU	$
		JSR	OAMCHK
;
		LDY	#007
;
TM1C510		EQU	$		;HAHEN SET
;;		LDA	ENCLOR,X
		LDA	<WORK5
		ORA	TM1C5DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C5DT,Y
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C5DT,Y
		CLC
		ADC	ENDSYL
		STA	(<OAMADR),Y
		DEY
		LDA	TM1C5DT,Y
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
		DEY
;
		BPL	TM1C510
;
		LDY	#001
		LDA	#000
;
TM1C520		EQU	$
		STA	(<OSBADR),Y
		DEY
		BPL	TM1C520
;
		LDY	#000
		LDA	#001
		JSR	ALOMCK
;
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	JAKIO move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JAKIOMV		EQU	$
		JSR	JAKIOCS
;
		JSR	ENSTCK		; scroll : not return !
;
		JSR	ENHNSB          ; hanekaeri 
;
		LDA	#001H
		STA	ENNOCR,X	;TAMA NOT ATARI
;
		LDA	ENWRK0,X
		CMP	#004H
		BNE	JAKIO10
		STZ	ENNOCR,X	;TAMA ATARI
		JSR	CRKNKN		; Vs PL ken check
		JSR	CRENPL		; Vs PL body check
;
JAKIO10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JAKIOM0		; PRINT		
		WORD	JAKIOM1		; DOKO?		
;
;----------------------------------------
JKOM0TM		EQU	$		;TIME
		BYTE	008H,008H,008H,008H
		BYTE	030H,018H,002H,018H
		BYTE	028H,000H,000H,008H
		BYTE	008H,008H,008H,018H
JKOM0W0		EQU	$		;KEMURI
		BYTE	000H,001H,002H,003H
		BYTE	004H,004H,004H,004H
		BYTE	004H,004H,004H,000H
		BYTE	001H,002H,003H,0FFH
JKOM0CT		EQU	$		;CHAR
		BYTE	004H,004H,000H,000H
		BYTE	000H,001H,002H,003H
		BYTE	000H,000H,000H,000H
		BYTE	000H,004H,004H,0FFH
;
JKOM0DX		EQU	$
		BYTE	000H,000H,0ECH,014H,0F0H,010H,0F0H,010H
JKOM0DY		EQU	$
		BYTE	0ECH,014H,000H,000H,0F0H,0F0H,010H,0F0H
JAKIOM0		EQU	$
		LDA	ENTIM0,X
		BNE	JKOM010
;
		LDA	ENWRK2,X
		INC	A
		AND	#00FH
		STA	ENWRK2,X
		CMP	#00FH
		BNE	JKOM020
;
		JSL     >RNDSET		;KIETERU TIME & KYORI
		AND	#03FH
		CLC
		ADC	ENTIM0,X
		STA	ENTIM0,X
;
		INC	ENSTAT,X
;
		LDA	<PLYPS1		;PL point --> enmy
		STA	ENYPSL,X
		LDA	<PLYPS0
		STA	ENYPSH,X
		LDA	<PLXPS1
		STA	ENXPSL,X
		LDA	<PLXPS0
		STA	ENXPSH,X
		LDA	<PLBGCKF
		STA	ENKAIF,X
;
		JSL	>RNDSET
		AND	#007H
		TAY
		LDA	JKOM0DX,Y
		STA	ENXSPD,X
;
		JSL	>RNDSET
		AND	#007H
		TAY
		LDA	JKOM0DY,Y
		STA	ENYSPD,X
;
JKOM020		EQU	$
		LDY	ENWRK2,X
		LDA	JKOM0TM,Y
		STA	ENTIM0,X
;
		LDA	JKOM0W0,Y
		STA	ENWRK0,X
;
		LDA	JKOM0CT,Y
		STA	ENCHPT,X
;
JKOM010		EQU	$
		RTS
;----------------------------------------
JKOM1DT		EQU	$
		BYTE	003H,002H,001H,000H
JAKIOM1		EQU	$
		JSR	ENBGCK		;BG check sub
		LDA	ENCBFG,X
		BNE	JKOM120
;
		JSR	ENMVCL		; xclc,yclc
;
JKOM120		EQU	$
		LDA	ENTIM0,X
		BNE	JKOM110
		STZ	ENSTAT,X
		JSR	EPXYCK		; PL point get
		LDA	JKOM1DT,Y
		STA	ENMUKI,X
;
JKOM110		EQU	$
		RTS
;----------------------------------------
JAKIOCS		EQU	$
		LDA	ENCHPT,X
		BMI	JKOCS10
;
		JSR	OAMCHK		;OAM 
;
		JSR	JAKIOKM		;kemuri set
;
		LDA	ENMUKI,X
		LSR	A
		BCC	JKOCS20
		JSR	JAKIOKA		;kama set
		JSR	JAKIOKR		;karada set
		BRA	JKOCS10
JKOCS20		EQU	$
		JSR	JAKIOKR		;karada set
		JSR	JAKIOKA		;kama set
;
JKOCS10		EQU	$
		RTS
;----------------------------------------
		BYTE	040H,040H,040H,040H,040H,040H
JKOKMCB		EQU	$
		BYTE	2,2,2,2
		BYTE	2,2,2,2
		BYTE	2,2,0,0
		BYTE	0,0,0,0
JKOKMCD		EQU	$
		BYTE	0000,0010,086H,0000
		BYTE	0000,0010,086H,0000
		BYTE	0000,0010,086H,0000
		BYTE	0000,0010,086H,0000
;
		BYTE	-002,-005,086H,0000
		BYTE	-005,0002,086H,0000
		BYTE	0006,0001,086H,0000
		BYTE	0006,0001,086H,0000
;
		BYTE	-008,-015,086H,0000
		BYTE	0005,-010,086H,0000
		BYTE	0004,0004,0A9H,0000
		BYTE	0006,0010,0A9H,0000
;
		BYTE	0002,-023,0A9H,0000
		BYTE	0006,-020,0A9H,0000
		BYTE	0001,-015,0A9H,0000
		BYTE	0003,-006,0A9H,0000
;
JAKIOKM		EQU	$
		LDA	ENWRK0,X
		CMP	#004
		BCS	JKOKM10
;
		PHX
;
		ASL	A		;DATA READ P.
		ASL	A
		STA	<WORK1
		ASL	A
		ASL	A
		TAY
;
		LDA	ENCLOR,X	;COLOR=2
		AND	#0F0H
		ORA	#004H
		STA	<WORK0
;
		TYX
;
		LDY	#000
;
JKOKM20		EQU	$
		LDA	JKOKMCD,X	;X
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
		INX
		INY
		LDA	JKOKMCD,X	;Y
		CLC
		ADC	ENDSYL
		STA	(<OAMADR),Y
		INX
		INY
		LDA	JKOKMCD,X	;C
		STA	(<OAMADR),Y
		INX
		INY
		LDA	<WORK0		;A
		STA	(<OAMADR),Y
		INX
		INY
		CPY	#016
		BCC	JKOKM20
;
		LDX	<WORK1
;
		LDY	#000
;
JKOKM30		EQU	$
		LDA	JKOKMCB,X	;SB SET
		STA	(<OSBADR),Y
		INX
		INY
		CPY	#004
		BCC	JKOKM30
		PLX
;
		LDY	#0FFH		; obj clc?
		LDA	#003H
		JSR	ALOMCK
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<OAMADR
		CLC
		ADC	#00016
		STA	<OAMADR
;
		LDA	<OSBADR
		CLC
		ADC	#00004
		STA	<OSBADR
;
		MEM8
		IDX8
		SEP	#00110000B
;
JKOKM10		EQU	$
		RTS
;----------------------------------------
JKORCD0		EQU	$
		BYTE	09DH,09CH,09CH,09CH
		BYTE	08DH,08CH,08CH,08CH
		BYTE	09EH,08EH,08EH,08EH
		BYTE	09FH,08FH,08FH,08FH
JKORCD1		EQU	$
		BYTE	09DH,09CH,09CH,09CH
		BYTE	08DH,08CH,08CH,08CH
		BYTE	09FH,08FH,08FH,08FH
		BYTE	09EH,08EH,08EH,08EH
JKORCD2		EQU	$
		BYTE	08AH,0A4H,088H,088H
		BYTE	082H,0A0H,080H,080H
		BYTE	086H,0A2H,084H,084H
		BYTE	086H,0A2H,084H,084H
JKORXD0		EQU	$
		BYTE	0000,0000,0000,0000
		BYTE	0000,0000,0000,0000
		BYTE	0000,0000,-001,-001
		BYTE	0000,0000,0001,0001
JKORXD1		EQU	$
		BYTE	0008,0008,0008,0008
		BYTE	0008,0008,0008,0008
		BYTE	0008,0008,0007,0007
		BYTE	0008,0008,0009,0009
JKORXD2		EQU	$
		BYTE	0000,0000,0000,0000
		BYTE	0000,0000,0000,0000
		BYTE	0000,0000,0000,0000
		BYTE	0000,0000,0000,0000
JKORYD0		EQU	$
		BYTE	0000,0001,0000,0000
		BYTE	0000,0000,0001,0001
		BYTE	0000,0000,0000,0000
		BYTE	0000,0000,0000,0000
JKORYD1		EQU	$
		BYTE	0000,0001,0000,0000
		BYTE	0000,0000,0001,0001
		BYTE	0000,0000,0000,0000
		BYTE	0000,0000,0000,0000
JKORYD2		EQU	$
		BYTE	0008,0008,0008,0008
		BYTE	0008,0008,0008,0008
		BYTE	0008,0008,0008,0008
		BYTE	0008,0008,0008,0008
JKORAD0		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	040H,040H,040H,040H
JKORAD1		EQU	$
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
		BYTE	000H,000H,000H,000H
		BYTE	040H,040H,040H,040H
JKORAD2		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	040H,040H,040H,040H
;
JAKIOKR		EQU	$
		LDA	ENCHPT,X
		CMP	#004
		BCS	JKOKR10
;
		STA	<WORK0
;
		LDA	ENCLOR,X
		STA	<WORK1
;
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		CLC
		ADC	<WORK0
;
		PHX
		TAX
		LDY	#000
;
JKOKR30		EQU	$
		LDA	JKORXD0,X
		CLC	
		ADC	ENDSXL
		STA	(<OAMADR),Y
		INY
		LDA	JKORYD0,X
		CLC	
		ADC	ENDSYL
		STA	(<OAMADR),Y
		INY
		LDA	JKORCD0,X
		STA	(<OAMADR),Y
		INY
		LDA	<WORK1
		ORA	JKORAD0,X
		STA	(<OAMADR),Y
		INY
;
		CPY	#012
		BCS	JKOKR20
;
		TXA
		CLC
		ADC	#010H
		TAX
		BRA	JKOKR30
;
JKOKR20		EQU	$
		LDY	#000
		TYA
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
		INY
		LDA	#002
		STA	(<OSBADR),Y
;
		PLX
		LDY	#0FFH		; obj clc?
		LDA	#002H
		JSR	ALOMCK
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<OAMADR
		CLC
		ADC	#012
		STA	<OAMADR
		LDA	<OSBADR
		CLC
		ADC	#003
		STA	<OSBADR
;
		SEP	#00110000B
		MEM8
		IDX8
;
JKOKR10		EQU	$
		RTS
;----------------------------------------
JKOKACP		EQU	$
		BYTE	0,1,2,3,4,5,6,11,7,8,9,10
JKOKACX		EQU	$
		BYTE	-022,-008,0014
		BYTE	0020,0007,-015
		BYTE	0003,-018,-019
		BYTE	-003,0018,0019
JKOKACY		EQU	$
		BYTE	0007,-014,-009
		BYTE	0002,0027,0024
		BYTE	-014,0004,0017
		BYTE	-014,0004,0017
;
JAKIOKA		EQU	$
		LDA	ENCHPT,X
		SEC
		SBC	#001
		CMP	#003
		BCS	JKOKA10
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		CLC
		ADC	ENMUKI,X
		CLC
		ADC	<WORK0
		TAY
		LDA	JKOKACP,Y
		STA	<WORKF
;
		LDA	JKOKACX,Y
		STA	<WORKE
;
		LDA	JKOKACY,Y
		STA	<WORKD
;
		JSR	JKOKAST
;
JKOKA10		EQU	$
		RTS
;----------------------------------------
JKASXD0		EQU	$
		BYTE	0000,-004,0000
		BYTE	0000,0001,0000
		BYTE	0000,0000,0000
		BYTE	-004,0000,0004
;
		BYTE	0013,-004,-008
		BYTE	-012,0001,0016
		BYTE	0002,-001,-002
		BYTE	-004,0009,0004
;
		BYTE	0013,0000,-008
		BYTE	-012,0002,0016
		BYTE	0002,0007,-002
		BYTE	0000,0001,0000
;
		BYTE	0013,-002,-008
		BYTE	-012,0000,0016
		BYTE	0002,0015,-002
		BYTE	-012,-007,0012
;
JKASYD0		EQU	$
		BYTE	0000,0005,0000
		BYTE	0000,-005,0000
		BYTE	0000,0000,0000
		BYTE	-002,0000,-002
;
		BYTE	0002,0005,-001
		BYTE	-002,-005,0009
		BYTE	0012,-008,0012
		BYTE	-002,-008,-002
;
		BYTE	0002,0000,0007
		BYTE	-002,-010,0001
		BYTE	0012,-008,0012
		BYTE	0000,-008,0000
;
		BYTE	0002,0012,0015
		BYTE	-002,0000,-007
		BYTE	0012,-008,0012
		BYTE	-002,-008,-002
;
JKASCD0		EQU	$
		BYTE	009H,00BH,02BH
		BYTE	009H,00BH,02BH
		BYTE	007H,02DH,007H
		BYTE	00BH,02DH,00BH
;
		BYTE	00DH,00BH,03FH
		BYTE	00DH,00BH,03FH
		BYTE	00DH,00FH,00DH
		BYTE	00BH,00FH,00BH
;
		BYTE	00DH,007H,02FH
		BYTE	00DH,00DH,02FH
		BYTE	00DH,01FH,00DH
		BYTE	009H,01FH,009H
;
		BYTE	00DH,00DH,03FH
		BYTE	00DH,007H,03FH
		BYTE	00DH,00FH,00DH
		BYTE	00DH,00FH,00DH
;
JKASAD0		EQU	$
		BYTE	0C2H,008H,002H
		BYTE	002H,0C8H,0C2H
		BYTE	002H,042H,042H
		BYTE	048H,002H,008H
;
		BYTE	0C8H,008H,0C8H
		BYTE	008H,0C8H,008H
		BYTE	008H,008H,048H
		BYTE	048H,048H,008H
;
		BYTE	0C8H,042H,048H
		BYTE	008H,088H,008H
		BYTE	008H,008H,048H
		BYTE	002H,048H,042H
;
		BYTE	0C8H,088H,048H
		BYTE	008H,082H,088H
		BYTE	008H,048H,048H
		BYTE	008H,008H,048H
;
JKASSB0		EQU	$
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
;
JKASSB1		EQU	$
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,000H,002H
		BYTE	002H,000H,002H
;
JKASSB2		EQU	$
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,000H,002H
		BYTE	002H,000H,002H
;
JKASSB3		EQU	$
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,000H,002H
		BYTE	002H,000H,002H
;
JKOKAST		EQU	$
		LDA	ENCLOR,X	;COLOR=0
		AND	#0F1H
		STA	<WORK0
;
		LDA	<WORKD
		STA	ENKNYP
		CLC
		ADC	ENDSYL
		STA	<WORKD
		LDA	<WORKE
		STA	ENKNXP
		CLC
		ADC	ENDSXL
		STA	<WORKE
;
		PHX
;
		LDY	#000
;
		LDX	<WORKF
;
JKAST10		EQU	$
		LDA	JKASXD0,X
		CLC
		ADC	<WORKE
		STA	(<OAMADR),Y
		INY
		LDA	JKASYD0,X
		CLC
		ADC	<WORKD
		STA	(<OAMADR),Y
		INY
		LDA	JKASCD0,X
		STA	(<OAMADR),Y
		INY
		LDA	<WORK0
		ORA	JKASAD0,X
		STA	(<OAMADR),Y
		INY
;
		TXA
		CLC
		ADC	#012
		TAX
;
		CPY	#016
		BCC	JKAST10
;
		LDX	<WORKF
		LDY	#000
		LDA	JKASSB0,X
		STA	(<OSBADR),Y
		INY
		LDA	JKASSB1,X
		STA	(<OSBADR),Y
		INY
		LDA	JKASSB2,X
		STA	(<OSBADR),Y
		INY
		LDA	JKASSB3,X
		STA	(<OSBADR),Y
;
		PLX
		LDY	#0FFH		; obj clc?
		LDA	#003H
		JSR	ALOMCK
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<OAMADR
		CLC
		ADC	#016
		STA	<OAMADR
		LDA	<OSBADR
		CLC
		ADC	#004
		STA	<OSBADR
;
		SEP	#00110000B
		MEM8
		IDX8
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		IWAO                                  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
IWAOYD		EQU	$
		BYTE	00H,01H,02H,03H,03H,03H,02H,01H
;;;             BYTE	0FH,0EH,0DH,0CH,0AH,08H,05H,03H
;- - - -- - - - - - - - - - - - -
IWAOOMV		EQU	$
		JSR	EN1CST
		JSR	ENSTCK
		JSR	ENHNSB
;
		STZ	ENCHPT,X
;
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X	; damage protect
;
		LDA	ENSTAT,X
		AND	#01H
		JSL	>JSRSUB
		WORD	IWAOST	; stop(stand)
		WORD	IWAOJP  ; jumping
;------------------------------------
IWAOST		EQU	$
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X	; damage chance !
;
		LDA	ENTIM0,X
		BNE	IWST00		
;				
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#7FH
		ADC	#60H
		STA	ENTIM0,X
		STZ	ENCONT,X
;
		JSR	IWSDST
IWST00		EQU	$
		INC	ENCHPT,X	
		BRA	IWAO90
;- - - jumping - - - - 
IWAOJP		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
;;;;            LSR	A
;;		BYTE	0EAH,0EAH
		AND	#07H
		TAY
		LDA	IWAOYD,Y
		STA	ENZPSL,X
		BNE	IWJP00		; 
;
		LDA	ENTIM0,X
		BNE	IWJP00
;
		INC	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
IWJP00		EQU	$
		JSR	ENMVCL
		JSR	ENBGCK
;;		LDA	ENCBFG,X
;;		AND	#00001111B
;;		BEQ	IWAO90
;;		JSR	ENTURN
		JSR	ENTUCK
IWAO90		EQU	$
		JSR	CRENPL		;Vs PL body
		JSR	CRKNEN
		RTS
;-----------------------------------
IWSDXD		EQU	$
		BYTE	08H,06H,0FAH,0F8H,0FAH,06H,0CH,0F4H
IWSDYD		EQU	$
		BYTE	00H,06H,06H,00H,0FAH,0FAH,0CH,0F4H
;- - - - - - - - - 
IWSDST		EQU	$
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	IWSDXD,Y
		STA	ENXSPD,X
		LDA	IWSDYD,Y
		STA	ENYSPD,X	
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		BATTA                                 %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;;BATAYD		EQU	$
;;		BYTE	00H,04H,07H,09H,0AH,09H,07H,04H
;;;;;             BYTE	0FH,0EH,0DH,0CH,0AH,08H,05H,03H
;- - - -- - - - - - - - - - - - -
BATTAMV		EQU	$
		JSR	EN1CST
		JSR	ENSTCK
		JSR	ENHNSB
;
		INC	ENCONT,X
		STZ	ENCHPT,X
;
		LDA	ENSTAT,X
		AND	#01H
		JSL	>JSRSUB
		WORD	BATAST	; stop(stand)
		WORD	BATAJP  ; jumping
;------------------------------------
BATAST		EQU	$
		LDA	ENTIM0,X
		BNE	BATS00		
;				
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#7FH
		ADC	#60H
		STA	ENTIM0,X
		STZ	ENCONT,X
;
		JSR	BTSDST
BATS00		EQU	$
		LDA	ENCONT,X
		AND	#00001000B
		BEQ	BATS20
		INC	ENCHPT,X	
BATS20		EQU	$
		BRA	BATA90
;- - - jumping - - - - 
BATAJP		EQU	$
		LDA	ENCONT,X
		LSR	A
                LSR	A
;;		BYTE	0EAH,0EAH
		AND	#07H
		TAY
		CPY	#05H
		BCS	BATJF0
;
		LDA	#02H
		STA	ENCHPT,X	; jump pause !
BATJF0		EQU	$
;;		LDA	BATAYD,Y
;;		STA	ENZPSL,X
;;		BNE	BATJ00		; 
		DEC	ENZSPD,X
		JSR	ENZCLC
		LDA	ENZPSL,X
		BPL	BATJ00		; On floor ?
;					; yes !
		STZ	ENZPSL,X
		LDA	#010H
		STA	ENZSPD,X
;
		LDA	ENTIM0,X
		BNE	BATJ00
;
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#3FH
		ADC	#30H
		STA	ENTIM0,X
BATJ00		EQU	$
		JSR	ENMVCL
		JSR	ENBGCK
;;		LDA	ENCBFG,X
;;		AND	#00001111B
;;		BEQ	BATA90
;;		JSR	ENTURN
		JSR	ENTUCK
BATA90  	EQU	$
		JSR	CRENPL		;Vs PL body
		JSR	CRKNEN
		RTS
;-----------------------------------
BATAXS		EQU	$
		BYTE	10H,0CH,0E8H,0F0H,0F0H,0CH,18H,0E8H
BATAYS		EQU	$
		BYTE	00H,0CH,18H,00H,0F0H,0F4H,18H,0E8H
;- - - - - - - - - 
BTSDST		EQU	$
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	BATAXS,Y
		STA	ENXSPD,X
		LDA	BATAYS,Y
		STA	ENYSPD,X	
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	KOKE1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KOKE1MV		EQU	$
		JSR	KOKE1CS
;
		JSR	ENSTCK		; scroll : not return !
		JSR	ENHNSB          ; hanekaeri 
;
		JSR	ENMVCL		; xclc,yclc,BG check !
                JSR	ENBGCK		; BG check sub !
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		;Vs PL body
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		LDA	ENWRK0,X
		JSL	>JSRSUB
		WORD	KOKWLK
		WORD	KOKSTP
		WORD	KOKHND
;==============================================
KKXSDT		EQU	$
		BYTE	000H,000H,0F8H,008H
KKYSDT		EQU	$
		BYTE	0F8H,008H,000H,000H
;
KOKWLK		EQU	$
		LDA	ENTIM0,X
		BNE	KOKW10
;
		LDA	#01H
		STA	ENTIM0,X
		LDA	#01H
		STA	ENWRK0,X
KOKW10		EQU	$
		LDA	ENCBFG,X
		AND	#00001111B
		BEQ	KOKW20		; cros BG ?
;					; yes ! muki turn !
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
KOKW20		EQU	$
		LDY	ENMUKI,X
		LDA	KKXSDT,Y
		STA	ENXSPD,X
		LDA	KKYSDT,Y
		STA	ENYSPD,X
;
		INC	ENWRK2,X
		LDA	ENWRK2,X
		LSR	A
		LSR	A
		AND	#03H
		STA	ENCHPT,X
		RTS
;
;====================================
KKHDMK		EQU	$
		BYTE	1,0,3,2
;
KOKSTP		EQU	$
;
		LDA	ENTIM0,X
		BNE	KOKS10
;
		JSL	>RNDSET
		AND	#00001100B
		BNE	KOKS08
;				; next hand set
		JSR	EPXYCK
		LDA	KKHDMK,Y
		STA	ENCONT,X
		STZ	ENWRK1,X
		LDA	#02H
		STA	ENWRK0,X
		LDA	#30H
		STA	ENTIM1,X
		RTS
KOKS08		EQU	$	; next walk set
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X		
		JSL	>RNDSET
		AND	#3FH
		ADC	#20H
		STA	ENTIM0,X
;
        	STZ	ENWRK0,X
KOKS10		EQU	$
		RTS		
;=========================================
KOKHAD		EQU	$
		BYTE	01H,06H,0BH,10H
KOKHPT		EQU	$
		BYTE	0,0,1,2,3,4,4,4,4,4,4,4,4,3,2,1,0
;
KOKHND		EQU	$
		LDA	#04H
		STA	ENCHPT,X
;
		LDA	ENTIM1,X
		BNE	KOKH20
;
		LDA	ENTIM0,X
		BNE	KOKH10
;
		LDA	#04H
		STA	ENTIM0,X
;
		INC	ENWRK1,X
		LDA	ENWRK1,X
		CMP	#17
		BEQ	KOKHED
KOKH10		EQU	$
		LDY	ENWRK1,X
		LDA	KOKHPT,Y
		LDY	ENCONT,X
		CLC
		ADC	KOKHAD,Y
		STA	ENSTAT,X
KOKH20		EQU	$
		RTS
KOKHED		EQU	$
		STZ	ENWRK0,X
		LDA	#40H
		STA	ENTIM0,X
		STZ	ENSTAT,X
		RTS
;
;
;
;
;
;
;		LDA	KEYA2
;		AND	#00001000B
;		BEQ	KKM010
;		INC	ENCHPT,X
;		LDA	ENCHPT,X
;		CMP	#05H
;		BCC	KKM010
;		STZ	ENCHPT,X
;KKM010		EQU	$
;		LDA	<KEYA2
;		AND	#00000100B
;		BEQ	KKM020
;		INC	ENSTAT,X
;		LDA	ENSTAT,X
;		CMP	#015H
;		BCC	KKM020
;		STZ	ENSTAT,X
;KKM020		EQU	$
;		JSR	KOKE1CS
;		RTS
;
;----------------------------------------
;-- hand data --
KKHXAD		EQU	$
		BYTE	004H,004H,004H,004H,004H,004H	; left
		BYTE	003H,003H,003H,003H,003H,0FDH
		BYTE	003H,003H,003H,0FEH,0FCH,0F5H
		BYTE	003H,003H,0FBH,0F3H,0F0H,0EDH
		BYTE	003H,0FBH,0F3H,0EBH,0E8H,0E5H
;
		BYTE	004H,004H,004H,004H,004H,004H	; right
		BYTE	005H,005H,005H,005H,005H,00BH
		BYTE	005H,005H,005H,00AH,00CH,013H
		BYTE	005H,005H,00DH,015H,018H,01BH
		BYTE	005H,00DH,015H,01DH,020H,023H
;
		BYTE	004H,004H,004H,004H,004H,004H	; up
		BYTE	004H,004H,004H,004H,004H,004H
		BYTE	004H,004H,004H,004H,004H,004H
		BYTE	004H,004H,004H,004H,004H,004H
		BYTE	004H,004H,004H,004H,004H,004H
;
		BYTE	004H,004H,004H,004H,004H,004H	; down
		BYTE	004H,004H,004H,004H,004H,004H
		BYTE	004H,004H,004H,004H,004H,004H
		BYTE	004H,004H,004H,004H,004H,004H
		BYTE	004H,004H,004H,004H,004H,004H
KKHYAD		EQU	$
		BYTE	0FEH,0FEH,0FEH,0FEH,0FEH,0FEH	; left
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
;
		BYTE	0FEH,0FEH,0FEH,0FEH,0FEH,0FEH	; right
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0FCH
;
		BYTE	0FEH,0FEH,0FEH,0FEH,0FEH,0FEH	; up
		BYTE	0FCH,0FCH,0FCH,0FCH,0FCH,0F6H
		BYTE	0FCH,0FCH,0FCH,0F7H,0F5H,0EEH
		BYTE	0FCH,0FCH,0F4H,0ECH,0E9H,0E6H
		BYTE	0FCH,0F4H,0ECH,0E4H,0E1H,0DEH
;
		BYTE	0FEH,0FEH,0FEH,0FEH,0FEH,0FEH	; down
		BYTE	003H,003H,003H,003H,003H,009H
		BYTE	003H,003H,003H,008H,00AH,011H
		BYTE	003H,003H,00BH,013H,016H,019H
		BYTE	003H,00BH,013H,01BH,01EH,021H
;
KKHCDT		EQU	$
		BYTE	072H,072H,072H,072H,072H,072H
		BYTE	073H,073H,073H,073H,073H,072H
		BYTE	073H,073H,073H,071H,071H,072H
		BYTE	073H,073H,071H,071H,071H,072H
		BYTE	073H,071H,071H,071H,071H,072H
;
		BYTE	072H,072H,072H,072H,072H,072H
		BYTE	073H,073H,073H,073H,073H,072H
		BYTE	073H,073H,073H,071H,071H,072H
		BYTE	073H,073H,071H,071H,071H,072H
		BYTE	073H,071H,071H,071H,071H,072H
;
		BYTE	072H,072H,072H,072H,072H,072H
		BYTE	070H,070H,070H,070H,070H,072H
		BYTE	070H,070H,070H,070H,070H,072H
		BYTE	070H,070H,070H,070H,070H,072H
		BYTE	070H,070H,070H,070H,070H,072H
;
		BYTE	072H,072H,072H,072H,072H,072H
		BYTE	070H,070H,070H,070H,070H,072H
		BYTE	070H,070H,070H,070H,070H,072H
		BYTE	070H,070H,070H,070H,070H,072H
		BYTE	070H,070H,070H,070H,070H,072H
KKHADT		EQU	$
		BYTE	040H,040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H,040H
;
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H,000H
;-- body data --
KOKCDT		EQU	$
		BYTE	040H,050H
		BYTE	042H,052H
		BYTE	040H,050H
		BYTE	042H,052H
		BYTE	044H,054H
KOKYAD		EQU	$
		BYTE	0F8H,000H
KOKADT		EQU	$
		BYTE	0,0
		BYTE	0,0
		BYTE	40H,40H
		BYTE	40H,40H
		BYTE	0,0
KOKE1CS		EQU	$
		JSR	OAMCHK
;;- hands set --
		LDA	ENSTAT,X
		BNE	KKC008
		JMP	KKC030
;
KKC008		EQU	$
		DEC	A
		STA	<WORK2
		ASL	A
		ASL	A
		ADC	<WORK2
		ADC	<WORK2  	;*6
		STA	<WORK2
;
		LDA	<FRCNT
		LSR	A
;;;		LSR	A
		AND	#00001110B
		EOR	ENCLOR,X
		STA	<WORK3
;
		PHX
		LDX	#05H
		LDY	#00H
KHC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK2
		TAX
		LDA	ENDSXL
		CLC
		ADC	KKHXAD,X
		STA	(<OAMADR),Y
		LDA	ENDSYL
		CLC
		ADC	KKHYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	KKHCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	KKHADT,X
		ORA	<WORK3
		INY
		STA	(<OAMADR),Y
		PLX
		INY
		DEX
		BPL	KHC010
		PLX
		LDY	#00H
		LDA	#05H
		JSR	ALOMCK
;		
		LDA	PYFLASH
		BNE	KHCR80
;
		LDA	<PLBGCKF
		CMP	ENKAIF,X
		BNE	KHCR80
;
		LDA	<PLXPS1
		CLC
		ADC	#04H
		SEC
		SBC	<SCCH2
		SEC	
		LDY	#00H
		SBC	(<OAMADR),Y
		CLC
		ADC	#08H
		CMP	#10H
		BCS	KHCR80
		LDA	<PLYPS1
		CLC
		ADC	#04H
		SEC
		SBC	<SCCV2
		SEC
		INY
		SBC	(<OAMADR),Y
		CLC
		ADC	#08H
		CMP	#10H
		BCS	KHCR80		;hand player cross ?
;					; yes !
		LDA	#01H
		STA	<DIEFG
		STA	PIPIFG
		LDA	#08H
		STA	DAMEFG		
KHCR80		EQU	$
;-- body set -----
KKC030		EQU	$
		MEM16
		REP	#00100000B
		LDA	<OAMADR
		CLC
		ADC	#0006H*4
		STA	<OAMADR
		LDA	<OSBADR
		CLC
		ADC	#0006H	
		STA	<OSBADR	
		MEM8
		SEP	#00100000B
		LDA	ENCHPT,X
;;;		STA	<WORK0
		ASL	A
		STA	<WORK1
		LDA	ENCLOR,X
		STA	<WORK2
;
		PHX
		LDX	#01H
		LDY	#00H
KKC010		EQU	$
		LDA	ENDSXL
		STA	(<OAMADR),Y
		LDA	ENDSYL
		CLC
		ADC	KOKYAD,X
		INY
		STA	(<OAMADR),Y
		PHX
		TXA
		CLC
		ADC	<WORK1
		TAX
		LDA	KOKCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	KOKADT,X
		ORA	<WORK2
		INY
		STA	(<OAMADR),Y
		INY
		PLX
		DEX
		BPL	KKC010
		PLX
		LDY	#02H
		LDA	#01H
		JSR	ALOMCK
		RTS
;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;% 			Skelton  									  %
;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SKXSDT		EQU	$
;;                     0    1    2   3    4    5    6    7    8    9    A
		BYTE	000H,008H,0F8H,000H,000H,006H,0FAH,000H,000H,006H,0FAH
SKYSDT		EQU	$
		BYTE	000H,000H,000H,000H,008H,006H,006H,000H,0F8H,0FAH,0FAH
SKCMDT		EQU	$
		BYTE	0,0,1,0,2,2,1,0,3,0,3
SKCPDT		EQU	$
		BYTE	00H,06H,0CH,12H
SKNXMK		EQU	$
		BYTE	1,2,4,5,6,8,9,0AH
;
SKL01MV		EQU	$
;		JSR	CRSKPL		; cros player & ken
		JSR	SKL01CS
		JSR	CRKNEN		;Vs PL ken
		JSR	CRENPL		;Vs PL body
;;;;		JSR	ENHLCK		; Hole down check
;
		JSR	ENSTCK
;;		LDA	<GAMEMD
;;		BNE	SKM090
;
;;		LDA	ENHNFG,X
;;		BEQ	SKM002
;
		JSR	ENHNSB
;;SKM001		EQU	$
;;;		JMP	>SKM090
;;;		RTS
;
SKM002		EQU	$
		LDY	ENMUKI,X
		LDA	SKXSDT,Y
		STA	ENXSPD,X
		LDA	SKYSDT,Y
		STA	ENYSPD,X
		LDA	SKCMDT,Y
		STA	ENCMKI,X
;
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDY	ENCMKI,X
		LDA	SKCPDT,Y
		ADC	#00H
		STA	ENCHPT,X
;
		JSR	SKSHCK		; head shot check
		JSR	SKSHOT		; head shot !
;
		JSR	ENXCLC
		JSR	ENYCLC
;
		JSR	ENBGCK
		LDA	ENCBFG,X
		AND	ENMUKI,X
		BEQ	SKM010
		PHA
		AND	#00000011B
		BEQ	SKM008
		EOR	#00000011B
		STA	ENMUKI,X
;;			BRA		SKM010
SKM008		EQU	$
		PLA
		AND	#00001100B
		BEQ	SKM010
		EOR	#00001100B
		STA	ENMUKI,X
SKM010		EQU	$
		LDA	ENTIM0,X
		ORA	ENCTFG,X
		ORA	ENSTAT,X
		BNE	SKM020		; muki chenge ?
;								; yes !
		JSL	>RNDSET
		AND	#3FH
		ADC	#20H
		STA	ENTIM0,X
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	SKNXMK,Y
		STA	ENMUKI,X
SKM020		EQU	$
;;			LDA		KEYA2
;;			AND		#01000000B
;;			BEQ		SKT010
;;			INC		ENCHPT,X
;;			LDA		ENCHPT,X
;;			CMP		#18H
;;			BCC		SKT010
;;			STZ		ENCHPT,X
;;SKT010		EQU		$
SKM090		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - -
SKSHCK		EQU	$
		TXA
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		EOR	<FRCNT		; test 
		AND	#0FFH
		ORA	ENSTAT,X
		ORA	ENCTFG,X
		ORA	ENDSPL,X
		BNE	SKSC80
;
		INC	ENCTFG,X
		LDA	#10H
		STA	ENTIM1,X
;;			STZ		ENSTAT,X
SKSC80		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - -
SKSHTD		EQU	$
		BYTE	0AH,24H,13H,0CH,0CH,0CH,0FFH; 0FFH dammy!
		BYTE	0FFH,0CH,0CH,18H,18H
;;			BYTE	0CH,28H,18H,10H,10H,10H,0FFH		; 0FFH dammy!
;;			BYTE	0FFH,10H,10H,20H,20H
SKSHMD		EQU	$
		BYTE	00H,02H,02H,03H,04H,05H,00H,0FFH
		BYTE	04H,04H,03H,02H,02H
SKSHOT		EQU	$
		LDY	ENCTFG,X
		BEQ	SKSHA0
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		LDA	ENTIM1,X
		BNE	SKSH80
		CPY	#07H
		BEQ	SKSH90
		CPY	#0DH
		BEQ	SKSH90
		INC	ENCTFG,X
		LDA	SKSHTD-1,Y
		STA	ENTIM1,X
		CPY	#05H
		BNE	SKSH80
;
		INC	ENSTAT,X
		JSR	SKHEDST		; head shot !
SKSH80		EQU	$
		LDY	ENCTFG,X
		LDA	SKSHMD-1,Y
		LDY	ENCMKI,X
		CLC
		ADC	SKCPDT,Y
		STA	ENCHPT,X
		RTS
SKSH90		EQU	$
		STZ	ENCTFG,X
SKSHA0		EQU	$
		RTS
;-----------------------------------------------
SHSXSD		EQU	$
		BYTE	10H,0F0H,00H,00H
SHSYSD		EQU	$
		BYTE	00H,00H,10H,0F0H
;- - - - - - - - - - - - - - - - - - - - - - - -
SKHEDST		EQU	$
;;		LDY	#ENNO-1
;;SKHSF0		EQU	$
;;		LDA	ENMODE,Y
;;		BEQ	SKHS00
;;		DEY
;;		BPL	SKHSF0
;;		RTS
		LDA	#SKHED
		JSL	>ENIDSH
		BMI	SKHS90
;- - - - - - - - - - - - - - - - - - - -
SKHS00		EQU	$
;;		LDA	#EMOVE
;;		STA	ENMODE,Y
;;		LDA	#SKHED
;;		STA	ENMYNO,Y
;;		PHX
;;		TYX
;;;;		JSL	>ENRMCL
;;		JSL	>ENMDST
;;		PLX
		LDA	ENXPSL,X
		CLC
		STA	ENXPSL,Y
		LDA	ENXPSH,X
		ADC	#00H
		STA	ENXPSH,Y
		LDA	ENYPSL,X
		SEC
		SBC	#06H
		STA	ENYPSL,Y
		LDA	ENYPSH,X
		SBC	#00H
		STA	ENYPSH,Y
		PHX
		LDA	ENCMKI,X
		TAX
		LDA	SHSXSD,X
		STA	ENXSPD,Y
		LDA	SHSYSD,X
		STA	ENYSPD,Y
		PLX
		TXA
		STA	ENWRK0,Y
		LDA	#0A0H
;;;			STA		ENTIM0,Y
		STA	ENWRK1,Y	; timer !
SKHS90		EQU	$
		RTS
;==============================================================
SKL01CS		EQU	$
		JSR	OAMCHK
		LDA	ENDSPL,X
		BNE	SKC090
;
		LDA	<OAMADR
		PHA
		LDA	<OAMADR+1
		PHA
		LDA	<OSBADR
		PHA
		LDA	<OSBADR+1
		PHA
		JSR	SKHDCS		;head
		JSR	SKHNCS		;hands
		JSR	SKBDCS		;body
		PLA
		STA	<OSBADR+1
		PLA
		STA	<OSBADR
		PLA
		STA	<OAMADR+1
		PLA
		STA	<OAMADR
;
		LDA	#003
		LDY	#0FFH
		JSR	ALOMCK
		JSR	SADWST
SKC090		EQU	$
		RTS
;--------------------------------------------------
SKHDXD		EQU	$
		BYTE	000H,000H,000H,000H,0FFH,000H
		BYTE	000H,000H,000H,000H,001H,000H
		BYTE	000H,000H,000H,000H,007H,005H
		BYTE	000H,000H,000H,000H,0F9H,0FAH
SKHDYD		EQU	$
		BYTE	0F8H,0F8H,0F8H,0F6H,0F6H,000H
		BYTE	0F8H,0F8H,0F8H,0F6H,0F6H,000H
		BYTE	0F8H,0F8H,0F8H,0F7H,0F6H,0F5H
		BYTE	0F8H,0F8H,0F8H,0F7H,0F8H,0F8H
SKHDCD		EQU	$
		BYTE	047H,047H,047H,047H,047H,047H
		BYTE	047H,047H,047H,047H,047H,047H
		BYTE	045H,045H,045H,045H,045H,045H
		BYTE	049H,049H,049H,049H,049H,049H
SKHDAD		EQU	$
		BYTE	40H,40H,40H,40H,40H,40H
		BYTE	0,0,0,0,0,0
		BYTE	0,0,0,0,0,0
		BYTE	0,0,0,0,0,0
;- - - - - - - - - - - - - - - - - - - - - - - - - - - -
SKHDCS		EQU	$
		LDA	ENSTAT,X
		BNE	SHC090		; with head ?
;
		LDA	ENCLOR,X
		STA	<WORK0
		LDA	ENCTFG,X
		CMP	#03H
		BEQ	SHC018		; Bururu set !
		CMP	#0CH
		CLC
		BNE	SHC020
SHC018		EQU	$
;;;			SEC
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
SHC020 		EQU	$
		LDY	#000
		PHX
		LDA	ENCHPT,X
		TAX
		LDA	ENDSXL
;;;;;			CLC
		ADC	SKHDXD,X
		STA	(<OAMADR),Y
		INY
		LDA	SKHDYD,X
		BEQ	SHC080		; Not set ?
		CLC			; no.
		ADC	ENDSYL
		STA	(<OAMADR),Y
		INY
		LDA	SKHDCD,X
		STA	(<OAMADR),Y
		INY
		LDA	SKHDAD,X
		ORA	<WORK0
		STA	(<OAMADR),Y
		LDY	#00H
		LDA	#002
		STA	(<OSBADR),Y
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<OAMADR
		CLC
		ADC	#004
		STA	<OAMADR
;
		INC	<OSBADR
;
		SEP	#00110000B
		MEM8
		IDX8
;
SHC080		EQU	$
		PLX
SHC090		EQU	$
		RTS
;---------------------------------------------------------
SKHNXL		EQU	$
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	005H,007H,005H,005H,006H,003H
		BYTE	0FEH,0FEH,0FEH,0FEH,0FEH,0FDH
		BYTE	0FEH,0FEH,0FEH,0FEH,0FEH,0FDH
SKHNXR		EQU	$
		BYTE	003H,001H,003H,003H,002H,005H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	00AH,00AH,00AH,00AH,00AH,00BH
		BYTE	00AH,00AH,00AH,00AH,00AH,00BH
SKHNYL		EQU	$
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	005H,005H,002H,0FFH,0FEH,005H
		BYTE	005H,004H,002H,001H,004H,005H
		BYTE	005H,004H,002H,001H,0FFH,0FFH
SKHNYR		EQU	$
		BYTE	005H,005H,002H,0FFH,0FEH,005H
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	003H,004H,002H,001H,0FDH,0FDH
		BYTE	003H,004H,002H,001H,004H,003H
SKHNCL		EQU	$
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	0AEH,0AFH,0BFH,0BFH,0BFH,0BFH
		BYTE	09EH,09FH,08FH,08FH,08FH,08FH
		BYTE	09FH,09EH,08FH,08FH,08FH,09FH
SKHNCR		EQU	$
		BYTE	0AEH,0AFH,0BFH,0BFH,0BFH,0BFH
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	09FH,09EH,08FH,08FH,08FH,09FH
		BYTE	09EH,09FH,08FH,08FH,08FH,08FH
SKHNAL		EQU	$
		BYTE	00H,00H,00H,00H,00H,00H
		BYTE	00H,00H,40H,40H,00H,40H
		BYTE	00H,40H,40H,40H,40H,40H
		BYTE	40H,40H,40H,40H,40H,40H
SKHNAR		EQU	$
		BYTE	40H,40H,00H,00H,40H,00H
		BYTE	00H,00H,00H,00H,00H,00H
		BYTE	00H,40H,00H,00H,00H,00H
		BYTE	00H,00H,00H,40H,40H,40H
;-  - - - - - - - - - - - - - - - - - - - - - - - - -
SKHNCS		EQU	$
		LDA	ENCTFG,X
		CMP	#03H
		BEQ	SHNC18
		CMP	#0CH
		CLC
		BNE	SHNC20		; Bururu set !
SHNC18		EQU	$
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
SHNC20 		EQU	$
		PHX
		LDA	ENCHPT,X
		TAX
		ROL	<WORK0
		LDA	SKHNXL,X
;;;;			CLC
		LSR	<WORK0
		PHP
		ADC	ENDSXL
		LDY	#000
		STA	(<OAMADR),Y
		PLP
		LDA	SKHNXR,X
;;;			CLC
		ADC	ENDSXL
		LDY     #004
		STA	(<OAMADR),Y
		LDA	SKHNYL,X
		BEQ	SHNC82
		CLC
		ADC	ENDSYL
		LDY     #001
		STA	(<OAMADR),Y
SHNC82		EQU	$
		LDA	SKHNYR,X
		BEQ	SHNC85
		CLC
		ADC	ENDSYL
		LDY	#005
		STA	(<OAMADR),Y
SHNC85		EQU	$
		LDA	SKHNCL,X
		LDY	#002
		STA	(<OAMADR),Y
		LDA	SKHNCR,X
		LDY     #006
		STA	(<OAMADR),Y
		LDA	SKHNAL,X
		ORA	#27H
		LDY	#003
		STA	(<OAMADR),Y
		AND	#00111111B
		ORA	SKHNAR,X
		LDY     #007
		STA	(<OAMADR),Y
		LDY	#000H
		TYA
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
SNC080		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<OAMADR
		CLC
		ADC	#008
		STA	<OAMADR
;
		INC	<OSBADR
		INC	<OSBADR
;
		SEP	#00110000B
		MEM8
		IDX8
;
		PLX
		RTS
;----------------------------------------------------------------
SKBDCD		EQU	$
		BYTE	8AH,8CH,8AH,8AH,8AH,8AH
		BYTE	8AH,8CH,8AH,8AH,8AH,8AH
		BYTE	88H,88H,86H,86H,86H,86H
		BYTE	88H,88H,86H,86H,86H,86H
SKBDAD		EQU	$
		BYTE	40H,40H,40H,40H,40H,40H
		BYTE	00H,00H,00H,00H,00H,00H
		BYTE	00H,40H,00H,00H,00H,00H
		BYTE	00H,40H,00H,00H,00H,00H
;- - - - - - - - - - - - - - - - - - - - - - - - - - -
SKBDCS		EQU	$
;;		LDA	ENFLSH,X
;;		ASL	A
;;		AND	#00001110B
;;		STA	<WORK0		; Color flash set !
;
		LDA	ENCLOR,X
		STA	<WORK0
;
		LDY	#000
		LDA	ENDSXL
		STA	(<OAMADR),Y
		INY
		LDA	ENDSYL
		STA	(<OAMADR),Y
		INY
		PHX
		LDA	ENCHPT,X
		TAX
		LDA	SKBDCD,X
		STA	(<OAMADR),Y
		INY
		LDA	SKBDAD,X
;;;		ORA	#20H
		EOR	<WORK0
		STA	(<OAMADR),Y
		LDY	#000
		LDA	#02H
		STA	(<OSBADR),Y
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<OAMADR
		CLC
		ADC	#004
		STA	<OAMADR
;
		INC	<OSBADR
;
		MEM8
		IDX8
		SEP	#00110000B
		PLX
		RTS
;---------------------------------------------
CRSKPL		EQU	$
		TXA
		EOR	<FRCNT
		AND	#01H
		ORA	<HANEFG
		BNE	CKP010
;
		LDA	ENKAIF,X
		CMP	PLBGCKF
		BNE	CKP010
;
		JSR	ENCRST
		JSR	PLCRST
		JSR	CROJCK
		BCC	CKP008
;
		LDA	#08H
		STA	<HANEFG
		LDA	#HPW05
		JSR	PLHNST
CKP008		EQU	$
		LDA	<KNCRYP
		CMP	#80H
		BEQ	CKP010
;
		JSR	PKNCRS
;;;;			JSR		ENCRST
		JSR	CROJCK
		BCC	CKP010
;
		LDA	#20H
		JSR	PSERC2
		LDA	<WORK0
		EOR	#0FFH
		INC	A
;;;		STA	ENYSPD,X
		STA	ENHNYS,X
		LDA	<WORK1
		EOR	#0FFH
		INC	A
;;;		STA	ENXSPD,X
		STA	ENHNXS,X
;
                LDA	#20H
		STA	ENFLSH,X
		LDA	#1FH
		STA	ENHNFG,X
;;			JSR		FLSHST
CKP010		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Dragon 1                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DRPTD0		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	000H,000H,000H,004H
		BYTE	000H,000H,004H,008H
		BYTE	000H,004H,008H,00CH
		BYTE	000H,000H,000H,0FCH
		BYTE	000H,000H,0FCH,0F8H
		BYTE	000H,0FCH,0F8H,0F4H
		
DRPTD1		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	000H,004H,004H,004H
		BYTE	000H,008H,008H,008H
		BYTE	000H,00CH,00CH,00CH
		BYTE	000H,00CH,010H,010H
		BYTE	000H,00CH,014H,014H
		BYTE	000H,00CH,018H,018H
		BYTE	000H,00CH,018H,01CH
		BYTE	000H,00CH,018H,020H
		BYTE	000H,00CH,018H,024H
;
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
		BYTE	000H,00CH,018H,024H
;
;-- fire data --
DRFRXD		EQU	$
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	005H,00BH,011H,018H,020H,02AH
		BYTE	008H,010H,019H,023H,02EH,03CH
		BYTE	005H,00BH,011H,018H,020H,02AH
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	-05H,-0BH,-11H,-18H,-20H,-2AH
		BYTE	-08H,-10H,-19H,-23H,-2EH,-3CH
		BYTE	-05H,-0BH,-11H,-18H,-20H,-2AH
DRFRYD		EQU	$
		BYTE	008H,010H,019H,023H,02EH,03CH
		BYTE	005H,00BH,011H,018H,020H,02AH
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	-05H,-0BH,-11H,-18H,-20H,-2AH
		BYTE	-08H,-10H,-19H,-23H,-2EH,-3CH
		BYTE	-05H,-0BH,-11H,-18H,-20H,-2AH
		BYTE	000H,000H,000H,000H,000H,000H
		BYTE	005H,00BH,011H,018H,020H,02AH
;============================================
DRGN1MV		EQU	$
;;		LDA	<KEYA2
;;		AND	#00001000B
;;		BEQ	DRM00
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#10H
;;		BCC	DRM00
;;		STZ	ENCHPT,X
;;DRM00		EQU	$
;;;
		JSR	DRGN1CT
;
		MEM16
		REP 	#00100000B
		LDA	<OAMADR
		CLC
		ADC	#0018H
		STA	<OAMADR
		LDA	<OSBADR
		ADC	#018H/4
		STA	<OSBADR
		MEM8
		SEP	#00100000B
;
;;		LDA	#0CH*4
;;		STA	<WORKF  	; haikei
;
		STZ	<WORKE		; oam index 
		LDA	#04H
		STA	<WORKD
DRM010		EQU	$
		JSR	DRM020
;
;;		LDA	<WORKF
;;		SEC
;;		SBC	#0CH
;;		STA	<WORKF
;
		LDA	<WORKE
		CLC
		ADC	#04H
		STA	<WORKE
;
		DEC	<WORKD
		BPL	DRM010
;
		LDY	#02H
		LDA	#04H
		JSR	ALOMCK
;-- fire set -----
		LDA	ENTIM1,X
		BEQ	DFC090
;
		PHA
		MEM16
		REP 	#00100000B
		LDA	<OAMADR
		SEC
		SBC	#0018H
		STA	<OAMADR
		LDA	<OSBADR
		SEC
		SBC	#018H/4
		STA	<OSBADR
		MEM8
		SEP	#00100000B
;
		PLA
		LSR	A
;;		LSR	A
		NOP
		TAY
		LDA	DRFRC0,Y
		STA	<WORK1
		LDA	DRFRC1,Y
		STA	<WORK0
;- - - - - - - 
		LDA	ENCMKI,X
		ASL	A
		ASL	A
		ADC	ENCMKI,X
		ADC	ENCMKI,X
		STA	<WORK2
;
		PHX
		LDX	<WORK1
		BMI	DFC070
;
		LDY	#00H
DFC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK2
		TAX
		LDA	ENHELP2
		CLC
		ADC	DRFRXD,X
		STA	(<OAMADR),Y
		LDA	ENHELP
		CLC
		ADC	DRFRYD,X
		INY
		STA	(<OAMADR),Y		
		PLX
		LDA	DRFRCD,X
		INY
		STA	(<OAMADR),Y
		TXA
		EOR	<FRCNT
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		AND	#01000000B
		ORA	#23H
		INY
		STA	(<OAMADR),Y
		INY
		DEX
		CPX	<WORK0
		BNE	DFC010
;
DFC070		EQU	$
		PLX
		LDY	#02H
		LDA	#05H
		JSR	ALOMCK
DFC090		EQU	$
		RTS
;============================================
DRFRC0		EQU	$
		BYTE 	-1,-1,-1,-1,-1,-1,-1,-1,05,05,05,05,05,05,05,05
		BYTE	05,05,05,05,05,05,05,05,05,05,05,05,05,05,05,05
		BYTE	05,05,05,05,05,05,05,05,05,05,05,05,05,05,05,05
		BYTE	05,05,05,04,03,02,01,00,-1,-1,-1,-1,-1,-1,-1,-1
DRFRC1		EQU	$
		BYTE	00,00,00,00,00,00,00,00,04,03,02,01,00,-1,-1,-1
		BYTE	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
		BYTE	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
		BYTE	-1,-1,-1,-1,-1,-1,-1,-1,00,00,00,00,00,00,00,00
;
DRFRCD		EQU	$
		BYTE	06EH,06EH,06CH,06CH,04EH,04CH,04CH,04CH
;- - - - - - - - - - - - - - - - - - -
DRAGRV		EQU	$
		BYTE	0,4,0,0FCH
;
DRM020		EQU	$
		STZ	<WORK2
		STZ	<WORKF
;
		LDY	<WORKD
		BEQ	DRM205
;
		LDA	ENWRK2,X
		PHP
		BPL	DRM190
		EOR	#0FFH
		INC	A
DRM190		EQU	$
		STA	<WORK2
		CPY	#04H
		BEQ	DRM200
		LSR	<WORK2
		LDA	<WORK2
		CPY	#02H
		BEQ	DRM200
		LSR	<WORK2
		CPY	#01H
		BEQ	DRM200
		NOP
		ADC	<WORK2
		STA	<WORK2
DRM200		EQU	$
		PLP
		BMI	DRM201
		LDA	<WORK2
		EOR	#0FFH
		INC	A
		STA	<WORK2
DRM201		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		NOP
		NOP
		CLC
		ADC	<WORKD
		AND	#03H
		PHY
		TAY
		LDA	<WORK2
		CLC
		ADC	DRAGRV,Y
		STA	<WORK2
		PLY
;
		LDA	ENCHPT,X
		STA	<WORKF
		CPY	#04H
		BEQ	DRM300
		LSR	<WORKF
		LDA	<WORKF
		CPY	#02H
		BEQ	DRM300
		LSR	<WORKF
		CPY	#01H
		BEQ	DRM300
		NOP
		ADC	<WORKF
		STA	<WORKF
DRM300		EQU	$
;
;;		STZ	<WORKF
;;;
;;		LDA	#00H
;;		LDY	<WORKD
;;		BEQ	DRM021
;;;
;;		LDA	ENCHPT,X
;;		ASL	A
;;		ASL	A
;;		ADC	<WORKD
;;		DEC	A
;;		TAX
;;		LDA	DRPTD1,X
;;		STA	<WORKF
;;;
DRM205		EQU	$
		LDY	#00H
;;;		LDA	DRPTD0,X
		LDA	<WORK2
		BPL	DRM021
		DEY
DRM021		EQU	$
		CLC
;;		LDX	ENINDX
		ADC	ENWRK1,X	
		STA	<WORK0
		TYA
		ADC	ENWRK0,X
		AND	#01H
		STA	<WORK1
;
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0
		CLC
		ADC	#0020H
		AND	#01FFH
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORKA
;
		LDA	<WORK0
		CLC
		ADC	#0080H
		AND	#01FFH
		STA	<WORK2
;
		LDA	<WORK0
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK4
;
		LDA	<WORK2
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK6
		MEM8
		IDX8
		SEP	#00110000B		
		PLX
;
		LDA	<WORK4
		STA	4202H
		LDA	<WORKF 	    ; Hankei
		LDY	<WORK5
		BNE	KSF0
		STA	4203H
		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		ASL	4216H
		LDA	4217H
		ADC	#00H
KSF0		EQU	$
		LSR	<WORK1
		BCC	KS00
		EOR	#0FFH
		INC	A
KS00		EQU	$
		STA	<WORK4		; XAD
;
		LDA	<WORK6
		STA	4202H
		LDA	<WORKF
		LDY	<WORK7
		BNE	KS08
		STA	4203H
		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		ASL	4216H
		LDA	4217H
		ADC	#00H
KS08		EQU	$
		LSR	<WORK3
		BCC	KS10
		EOR	#0FFH
		INC	A
KS10		EQU	$
		STA	<WORK6		; YAD
;-- oam set -
		JSR	OAMCHK
;
		LDY	<WORKE
		LDA	<WORK0
		CLC
		ADC	<WORK4
		STA	(<OAMADR),Y
		PHA
		LDA	<WORK2
		CLC
		ADC	<WORK6
		INY
		PHA
		STA	(<OAMADR),Y
		PHX
		LDX	<WORKA
		LDA	<WORKD
		CMP	#04H
		BNE	DR1C10
		PLX
		PHX
		LDA	ENTIM1,X
		CMP	#01H
		LDA	ENCMKI,X
		BCC	DR1C0D
		CLC
		ADC	#08H
DR1C0D		EQU	$
		CLC
		ADC	#08H
		TAX
DR1C10		EQU	$
		LDA	DR1CDT,X		
		INY
		STA	(<OAMADR),Y
		TXA
		AND	#07H
		TAX
		LDA	DR1ADT,X		
		PLX
		ORA	<WORK3
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORKD
		CMP	#04H
		BNE	DR1C20
;
		PLA
		STA	ENHELP
		PLA
		STA	ENHELP2
		RTS
DR1C20		EQU	$
		PLA
		PLA
		RTS
;- - - - - - - - - - - - -
DR1CDT		EQU	$
		BYTE	062H,060H,064H,060H,062H,060H,064H,060H
		BYTE	040H,048H,044H,048H,040H,048H,044H,048H
		BYTE	042H,04AH,046H,04AH,042H,04AH,046H,04AH
DR1ADT		EQU	$
		BYTE	000H,000H,000H,080H,080H,0C0H,040H,040H
;----------------------------------------------------------
D1KBMK		EQU	$	; only 80h angle serch data !
;;;;;;;            xspd->
		BYTE	0,0,0,0,0,0,0,2		;  Y
		BYTE	0,0,0,0,0,0,0,2		;  |
		BYTE	0,0,0,0,0,0,0,2		;  V
		BYTE	0,0,0,0,0,0,0,2
		BYTE	0,0,0,0,0,0,0,1
		BYTE	0,0,0,0,0,0,0,1
		BYTE	0,0,0,0,0,0,0,1
		BYTE	0,0,0,0,1,1,1,1
D1KBM2		EQU	$
		BYTE	0,1,2,0
		BYTE	4,3,2,0
		BYTE	0,7,6,0
		BYTE	4,5,6,0
;----
D1KBSH		EQU	$
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	DKS080
;
		LDA	#07H
		JSR	PSERCH
		LDA	<WORK0
		BPL	DKS010
		EOR	#0FFH
		INC	A
DKS010		EQU	$
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK2
		LDA	<WORK1
		BPL	DKS020
		EOR	#0FFH
		INC	A
DKS020		EQU	$
		ORA	<WORK2
		TAY
		LDA	<WORK1
		ASL	A
		LDA	<WORK0
		ROR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#00001100B
		ORA	D1KBMK,Y
		TAY
		LDA	D1KBM2,Y
		STA	ENCMKI,X
DKS080		EQU	$
		RTS
;============================================
D1CTAD		EQU	$
		BYTE	001H,0FFH
D1CTLM		EQU	$
		BYTE	040H,0C0H
;
DRGN1CT		EQU	$
		STZ	ENCTFG,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	D1WAIT
		WORD	D1LONG
		WORD	D1MOVE
		WORD	D1FIRE
;--------------------------------------
D1STAL		EQU	$
		BYTE	080H,080H,000H,000H
D1STAH		EQU	$
		BYTE	000H,001H,000H,001H
;
D1WAIT		EQU	$
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#30H
		CMP	#060H
		BCS	D1W030
		LDA	<WORKF
		CLC
		ADC	#30H
		CMP	#60H
		BCS	D1W030
;
		INC	ENSTAT,X
;
		LDA	D1STAL,Y
		STA	ENWRK1,X
		LDA	D1STAH,Y
		STA	ENWRK0,X
D1W030		EQU	$
		RTS
;--------------------------------------
D1LONG		EQU	$
		LDA	FRCNT
		AND	#01H
		BNE	D1L030
;
		INC	ENCHPT,X
		LDA	ENCHPT,X
		CMP	#20H
		BNE	D1L030
;
		INC	ENSTAT,X
		LDA	#80H
		STA	ENTIM2,X
D1L030		EQU	$
		RTS
;--------------------------------------
;--------------------------------------
;--------------------------------------
D1MOVE		EQU	$
		JSR	D1KBSH		; kubi muki serch !
;
                LDA	ENWRK1,X
	        CLC
		ADC	#00H
		STA	ENWRK1,X	; angle 
		LDA	ENWRK0,X
		ADC	#00H
		AND	#01H
		STA	ENWRK0,X
;
		LDA	ENTIM0,X
		BNE	D1CT12
;
		LDA	ENMUKI,X
		AND	#01H
		TAY
		LDA	ENWRK2,X
		CLC
		ADC	D1CTAD,Y
		STA	ENWRK2,X
		CMP	D1CTLM,Y
		BNE	D1CT12
;
		LDA	#30H
		STA	ENTIM0,X
;
		INC	ENMUKI,X
D1CT12		EQU	$
		LDA	ENTIM2,X
		BNE	D1CT32
;
		LDA	#07FH
		STA	ENTIM1,X
;
		INC	ENSTAT,X
D1CT32		EQU	$
		RTS
;====================================================
D1FIRE		EQU	$
		LDA	#01H
		STA	ENCTFG,X
;
		LDA	ENTIM1,X
		BNE	D1F010
;
		LDA	#080H
		STA	ENTIM2,X
		DEC	ENSTAT,X		
D1F010		EQU	$
		RTS
;============================================================================
;============================================================================
;
;
;
;
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		OHYES                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OHYESMV		EQU	$
;----------------------------------------
;		JSL
;	WORK0,1 -- P(X,Y)		P.19 SFX MANIARU
;		     ~
;	WORK2,3 -- P(X,Y)
;		       ~
;	WORK4,5 -- R		(LOW dake tukau)
;
;	WORK6,7 -- kakudo	(LOW dake tukau)
;
;	C(X,Y)  -- WORK8,9
;	  ~
;	C(X,Y)  -- WORKA,B
;	    ~
;
;----------------------------------------
ENENSET		EQU	$
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
;					;X
		JSR	ENENSSB
;
		LDA	02135H		;X no kyori
		CLC
		ADC	<WORK0
		STA	<WORK8
;
;					;Y
		LDA	<WORK6		;SIN --- > COS
		CLC
		ADC	#00080H
		STA	<WORK6
		LDA	#000H
		ADC	<WORK7
		STA	<WORK7
;
		JSR	ENENSSB
;
		LDA	02135H		;Y no kyori
		CLC
		ADC	<WORK2
		STA	<WORKA
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
		RTL
;----------------------------------------
ENENSSB		EQU	$
		MEM16
		IDX16
;
		LDA	<WORK6		;kakudo o index ni suru
		AND	#000FFH
		ASL	A
		TAX
;
		MEM8
		IDX16
		SEP	#00100000B
;
		LDA	<WORK7
		LSR	A
		BCS	ENENS10		;180 < ?
;					;N
		LDA	>SINDT2,X	;SIN DATA SET(180>kakudo)
		STA	0211BH
		LDA	>SINDT2+1,X
		STA	0211BH
		BRA	ENENS20
;
ENENS10		EQU	$
		LDA	>SINDT2,X	;SIN DATA SET(180<kakudo)
		EOR	#0FFH
		STA	0211BH
		LDA	>SINDT2+1,X
		EOR	#0FFH
		STA	0211BH
;
ENENS20		EQU	$
		LDA	<WORK4		;R SET
		STA	0211CH
;
		MEM16
		IDX16
		REP	#00110000B
;
		RTS
		MEM8
		IDX8
;===========================================================
;===========================================================
;===========================================================
;===========================================================
ESWADT		EQU	$
		BYTE	01H,0FFH
ESWLMT		EQU	$
		BYTE	04H,000H
;- - - - - - - - - - - - - - - - - - - 
ESW01MV		EQU	$
		JSR	ESW01CS
		JSR	CRSWPL
		LDA	ENCONT,X
		BEQ	ESW050
		LDA	<FRCNT
		AND	#07H
		BNE	ESW050
		LDA	ENSTAT,X
		LDY	ENMUKI,X
		CMP	ESWLMT,Y
		BEQ	ESW080
		CLC
		ADC	ESWADT,Y
		STA	ENSTAT,X
ESW050          EQU	$
		RTS
ESW080		EQU	$
		STZ	ENCONT,X
		RTS
;---------------------------------------------------
ESWBXD		EQU	$
		HEX	FA,FD,04,0B,0F
;;		BYTE	0FDH,0FFH,04H,09H,0BH
ESWBYD		EQU	$
		HEX	05,01,FE,01,05
;;		BYTE	0FFH,0FEH,0FDH,0FEH,0FFH
ESWBCD		EQU	$
		BYTE	0F2H,0E2H,0E3H,0E2H,0F2H
;	BYTE	013H,012H,003H,012H,013H
;;		BYTE	0DEH,0DFH,0CEH,0DFH,0DEH
ESWBAD		EQU	$
		BYTE	000H,000H,000H,040H,040H
ESW01CS		EQU	$
		JSR	OAMCHK	
;
		JSR	OCHECK
;
		LDY	#04H
        	LDA	<WORK0
		STA	(<OAMADR),Y
		LDA	<WORK2
		INY
		STA	(<OAMADR),Y
		LDA	#0E0H
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		INY
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
; --- lever set ----
		LDY	#00H
		LDA	ENSTAT,X
		TAX
		LDA	<WORK0
		CLC
		ADC	ESWBXD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	ESWBYD,X
		INY
		STA	(<OAMADR),Y
		LDA	ESWBCD,X
		INY
		STA	(<OAMADR),Y
		LDA	ESWBAD,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		LDX	ENINDX
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#00H
		STA	(<OSBADR),Y
;		
		LDY	#0FFH
		LDA	#01H
		JSR	ALOMCK
		RTS
;;EWC010		EQU	$
;;		JSR	OAMCHK	
;;;;        	LDY	ENOMID,X		
;;		LDA	ENDSXL
;;		STA	OAM+04H,Y
;;		LDA	ENDSYL
;;		STA	OAM+05H,Y
;;		LDA	#004H
;;		STA	OAM+06H,Y
;;		LDA	#27H
;;		STA	OAM+07H,Y
;;		TYA
;;		LSR	A
;;		LSR	A
;;		TAY
;;		LDA	#02H
;;		ORA	ENDSPL,X
;;		STA	OAMSB+01H,Y
;;		LDY	ENOMID,X
;;		LDA	ENSTAT,X
;;		TAX
;;		LDA	ENDSXL
;;		CLC
;;		ADC	ESWBXD,X
;;		STA	OAM+00H,Y
;;		LDA	ENDSYL
;;		CLC
;;		ADC	ESWBYD,X
;;		STA	OAM+01H,Y
;;		LDA	ESWBCD,X
;;		STA	OAM+02H,Y
;;		LDA	ESWBAD,X
;;		ORA	#2BH
;;		STA	OAM+03H,Y
;;		LDX	ENINDX
;;		TYA
;;		LSR	A
;;		LSR	A
;;		TAY
;;		LDA	#00H
;;		ORA	ENDSPL,X
;;		STA	OAMSB+00H,Y		
;;		RTS
;---------------------------------------------------
CRSWPL		EQU	$
;;              JSR	SWCRST
;;		JSR	PLCRST
;;		JSR	CROJCK
		JSR	CRENPL2
		BCC	CRSL10
;
;;		STZ	<PLYSPD
;;		STZ	<PLXSPD
		JSL	>DASHON
;
		LDA	PLYPS1
		SEC
		SBC	ENYPSL,X
		CMP	#002H
		BPL	CRSWDW
		CMP	#0F2H
		BMI	CRSWUP
		LDA	PLXPS1
		CMP	ENXPSL,X
		BPL	CRSWRG
CRSWLF		EQU	$
;;		MEM16
;;		REP	#00100000B
;;		DEC	PLXPS1
;;		DEC	PLXPS1
;;		MEM8
;;		SEP	#00100000B
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<PLXPS1
		LDA	ENXPSH,X
		SBC	#00H
		STA	<PLXPS0
;
		LDA	ENSTAT,X
		BNE	CRSL10		; lever move ! ->
		LDA	ENCONT,X
		BNE	CRSL10
		INC	ENCONT,X
		LDA	#00H
		STA	ENMUKI,X
		BRA     CRSR20
CRSL10		EQU	$
		RTS
CRSWRG		EQU	$
;;		MEM16
;;		REP	#00100000B
;;		INC	PLXPS1
;;		INC	PLXPS1
;;		MEM8
;;		SEP	#00100000B
		LDA	ENXPSL,X
		CLC
		ADC	#0EH
		STA	<PLXPS1
		LDA	ENXPSH,X
		ADC	#00H
		STA	<PLXPS0
;
		LDA	ENSTAT,X
		CMP	#04H
		BNE	CRSR10
		LDA	ENCONT,X
		BNE	CRSR10		; lever move ! <-
		INC	ENCONT,X
		LDA	#01H
		STA	ENMUKI,X
CRSR20		EQU	$
		LDA	#01H
		STA	SWCHFG		; swich flag on !
CRSR10		EQU	$
		RTS
CRSWUP		EQU	$
;;		MEM16
;;		REP	#00100000B
;;		DEC	PLYPS1
;;		DEC	PLYPS1
;;		MEM8
;;		SEP	#00100000B
		LDA	ENYPSL,X
		SEC
		SBC	#15H
		STA	<PLYPS1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<PLYPS0
		RTS
CRSWDW		EQU	$
;;		MEM16
;;		REP	#00100000B
;;		INC	PLYPS1
;;		INC	PLYPS1
;;		MEM8
;;		SEP	#00100000B	
		LDA	ENYPSL,X
		CLC
		ADC	#0AH
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		STA	<PLYPS0
CRSWRT		EQU	$
		RTS
;========================================================
CRTNTN		EQU	$
;;			RTS
		LDY	#09H
CTT008		EQU	$
		CPY	ENINDX
		BEQ	CTT009
;
		TYA
		EOR	<FRCNT
		LSR	A
		BCC	CTT009
;
		LDA	ENMODE,Y
		CMP	#EMOVE
		BNE	CTT009
;
		LDA	ENDSPL,Y
		ORA	ENTIM3,Y
		ORA	ENTIM3,X
		BNE	CTT009
;
		LDA	ENYPSL,X
		STA	<WORK0
		LDA	ENYPSH,X
		STA	<WORK1
		LDA	ENYPSL,Y
		STA	<WORK2
		LDA	ENYPSH,Y
		STA	<WORK3
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		SEC
		SBC	<WORK2
		CLC
		ADC	#0010H
		CMP	#0020H
		MEM8
		SEP	#00100000B
		BCC	CTT012
;
CTT009		EQU	$
		JMP	>CTT010
CTT012		EQU	$
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	ENXPSL,Y
		STA	<WORK2
		LDA	ENXPSH,Y
		STA	<WORK3
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		SEC
		SBC	<WORK2
		CLC
		ADC	#0010H
		CMP	#0020H
		MEM8
		SEP	#00100000B
		BCS	CTT009
;
		LDA	#1FH
		STA	ENHNFG,Y
		LDA	<PLXPS1
		PHA
		LDA	<PLXPS0
		PHA
		LDA	<PLYPS1
		PHA
		LDA	<PLYPS0
		PHA
		LDA	ENXPSL,Y
		STA	<PLXPS1
		LDA	ENXPSH,Y
		STA	<PLXPS0
		LDA	ENYPSL,Y
		STA	<PLYPS1
		LDA	ENYPSH,Y
		STA	<PLYPS0
		LDA	#18H
		JSR	PSERC2 		;;;;;;;;;;
		LDA	<WORK0
;;;		STA	ENYSPD,Y
		STA	ENHNYS,Y
		LDA	<WORK1
;;;		STA	ENXSPD,Y
		STA	ENHNXS,Y
		PLA
		STA	<PLYPS0
		PLA
		STA	<PLYPS1
		PLA
		STA	<PLXPS0
		PLA
		STA	<PLXPS1
;;			LDA		ENXSPD,X
;;			STA		ENXSPD,Y
;;			LDA		ENYSPD,X
;;			STA		ENYSPD,Y
		LDA	#14H
		STA	ENFLSH,Y
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		STZ	ENHNFG,X
		LDA	#0CH
		STA	ENTIM3,X
		STA	ENTIM3,Y
CTT010		EQU	$
		DEY
		BMI	CTTRTS
		JMP	>CTT008
CTTRTS		EQU	$
		RTS
;========================================================
CRTNPL		EQU	$
;;;			RTS
		JSR	PLCRST
		JSR	ENCRST
		JSR	CROJCK
		BCC	CTP080
;
		LDA	ENHNFG,X
		BNE	CTP080
;
		LDA	#07H
		STA	ENHNFG,X
		LDA	#07H
		STA	<HANEFG
		LDA	#20H
		JSR	PSERC2
		LDA	WORK0
		STA	PLYSPD
		EOR	#0FFH
		INC	A
;;;;		STA	ENYSPD,X
		STA	ENHNYS,X
		LDA	WORK1
		STA	PLXSPD
		EOR	#0FFH
		INC	A
;;;;		STA	ENXSPD,X
		STA	ENHNXS,X
		STZ	ENSTAT,X	; normal move return !
		PLA
		PLA
CTP080		EQU	$
		RTS
;===========================================================
