;
        	INCLUDE	zel_ram.asm
;
;--------------------------------------------------------------------
;
;		PAL_ZELDA-3 (GERMAN)		1991.03.08(FRI)
;
;--------------------------------------------------------------------
;
		ORG	1E8000H
;
;=============================================== (zel_enmy3) ===========
		GLB	YOSEIMJ,ENMY3MV,BINCHKL,HACHISTL,YOSEISTL
		GLB	POLIWCG,BABU2IT,PATAMCTL,DEMBMMV
		GLB	HELP1IT,HELP1ST,ICEFLST,ITMZST,MEMEIT,CHFIRCS,CHFPTD
		GLB	LINE0IT,LINE0MV,SARKKST,SARKKST1,SARKKST2,MOTSBIT,SITO2ST
		GLB	ENPLATR,TKTAMST,MEDAMITJ 
		GLB	SMM10ST,ASMZST
		GLB	SMM10,SMM20,SMM30,SMM40,SMM50,SMM60,SMM70
;----------------------------------------
;=============================================== (zel_enmy5) ===========
		EXT	RYOKICS,BIGKOCS,PTMZCSL
;=============================================== (zel_enmy4) ===========
		EXT	EYEBMST,HBBKST,BIGSWST,SHBUNST,GANSPST,COPYCS
		EXT     TheftCS,HELP1CS,BIGSWST2
;;		EXT     MOTSBIT,MTFTIT
;=============================================== (zel_enmy2) ===========
		EXT	EVCHCKE,ENXSDN,ENYSDN,ENMSG2L,ENMSGEL,ENMSGSL,MSGSET
		EXT	SETOAML,SETOAML2,ENMKIST,MKCK16,BSITEM,EFLCHK,MIZUSTL
		EXT	SETOAML22,MZSUB
		EXT	KEMRIST,KEMR1ST,MJSY1CS
;=============================================== (zel_enmy) ============
		EXT	EPXYCK2,EPXCHK2,EPYCHK2,PLFLSTL,PSSAVE2,PSERC2L,PKNCRS2
                EXT     EMOVE,RNDSET,BGDTRD2,ENDMST2,CROJCK2,ENCRST2,BIKRST2
		EXT	ENBGCKL,CRENPLL,CRKNKNL,CRKNENL,OCHECKL,ENCLER
		EXT	ALOMCKL,ENIDSH,SADWSTL,SADWS2L,CRENPL2L,OAMENT3,OAMENT1
		EXT	PSERCHL,EN1CSTL,ESERCHL,SSERCH2,CACHCKL,ENBDSBL
		EXT	ENENSET,EN1CSSL,OAMENT2,EFLSST,ENDMST3,ENDMST4,EHOLE,OAMCHKL
		EXT	CRENPL3L,ENIDSH2,FILSETL,ENMOVE2,BABULCSL,EFLSST2
;--- enmyno --
		EXT	SKHED,SHTAM,HBTAM,BAAR0,BABUL,TEKI0,TEKI1,SKELB
		EXT	OCTA1,OCTA2,OCTA3,NYORO,OCTBL,OCTSS,CHFIR,BIGKO
		EXT	TARUH,TARUV,SKEL2,PATA0,PATA1,SHSAI
		EXT	KWAUS,KWAU1,SHIGE,SEKZ4,PONPK,MOTSB
		EXT	REBA1,ZOOL1,DRGN1,MANY1,MEDAM
		EXT	JIJII,BABAA,HEITI,PENKI,NOKOG,KUTUU,GAKII,GAKI1
		EXT	NOPPO,ONNAA,HIGEE,MAJOO,JIJI2,KIANA,BUBUU
		EXT	YATAM,MURON,MURYA,MURMK,LINE0,LINE1,LINE2,LINE3,BABA1,ESW03,HEIS0
		EXT	TAIHO,HEIS1,HEYA0,HEYA1,HEYA2,KTOBJ,HEIS2,NEZU0,HEBI0
		EXT	KOMO0,HEBO0,OYAGI,ZAKO0,MEDA2
		EXT	HEIS3,SUNA0,USAG0,HEYA3,HANA0,HANA1,TAMA0,DOZOO
		EXT	BOUSI,SYOBY,HELP0,ESW12,RANEM,ZORAS,NOMOS,KINOK
		EXT	SUKAS,MJSY1,JITON,ESW04,ZORA2,MEDUS,UTUWA,ARI00,ARI01
		EXT	JOHBB,ENMY3,HACHI,POLIW,RINGO,BABU2,HELP1,BKFIR,HARI0,D_0_9
		EXT	MOTAM,MEMER,MAGIC,ICBOS,DOKN0,DOKN1,DOKN2,DOKN3,BEE00,SITO0
		EXT	SEKBN,TAKAR,BAKDN,SARKK,TEKBB,UZUMK,SAMTM,RYOKI
		EXT	MEMED
;--------------
		EXT	HEIT1
;-------------- item
                EXT     HART1,RUPYR,RUPYY,RUPYB,BOMB1,BOMB2,BOMB3
                EXT     TUBO1,TUBO2 
                EXT     YAAA1,YAAA2,YOSEI
;--------------
		EXT	HART1,PORT1,PORT2,ICTAM
		EXT	ESET0,ESET1,ESET2
		EXT	EFAIL,ECACH,EWATR,EICE,EICFL,EBAKU
;=============================================== (zel_endt) ============
									
		EXT	EXSTRA,ENEMY2,ENBTON,EFLCHK2,ENCLST
		EXT	SINDT2,ENIDPS,ICEF2ST
;=============================================== (zel_main) ============
;		EXT	DTSAVE,DJEXTCK
		EXT	TGBLKWT
		EXT	GDCHCK,JSRSUB,MGMCGRS2,MGMCGCNG
;
		EXT	MD_title,MD_djint,MD_djply,MD_gdint,MD_gdply
		EXT	MD_fdout,MD_fdin,MD_etcpl
		EXT	MD_wpout,MD_wpin,p2_warp
;=============================================== (zel_play) ============
		EXT 	DASCLR1,DASHON,PLOTCK,SWSPCL1,PYCRCN,PYSPST
		EXT 	EATSET,MNIRIT,PLYCLR,PLYCLR1
		EXT 	YAMOV
		EXT	YAIMIT
		EXT	ATMSIT
		EXT	OMS000
		EXT	PLOTCK1
		EXT	BMCLER
		EXT	LNMD
		EXT	p2_kage,TRFS
		EXT	WPMSCK
		EXT	DKHDCK
		EXT	MCGTHK
;///////		EXT	RDCHCK
;=============================================== (zel_bg3) =============
		EXT	MTRSUB,ITEM0ST,ICECGCNG,SHSCGCNG,BOMBMAX,YAAAMAX
;=============================================== (grnd) =============
		EXT	MKDRPLY,gif1
;=============================================== (zel_init) =============
		EXT	p3_msge,DJEXTCK,PLRSET,RESTTST
;=============================================== (zel_sub0) =============
		EXT	DJEXTCK
;================================================(end2)=================
		EXT	GRNDCHK,KURORCS,SDLRCE,SDLRCP,MAGICCS,ICMANCS,TEKI0CS,SKEL2CS
		EXT	MGTAMCS,PBBANCS,PATA0CS,CRHCEN,LIKE0CS,ICBOSCS
		EXT	HELP0CS,SINPUCS,MEIR1CS,SDLRE1,SDLRE2,SDLRE3
;================================================(endt)=================
		EXT 	GRENST,EST0SB
;================================================(char)=================
		EXT 	OPTCBFST,PWTRCGS2
;================================================(COMN)=================
		EXT	MGMCGCNG
;================================================(exst)=================
                EXT     BEAM1,BEAM2,BUME1,BOMBM,YAMOV,DTMOV     ;;;;,BOMBR
                EXT     DTMV1,DTMV2,OPMOV,WTMV0,HIBA2,SCPMV,DTMV3
                EXT     RAOPIT,RAOPIT1,ATMSIT,BOGN,KNSP,PGKRITL
		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
;
;=======================================================================
		EXTEND
;
		MEM8
		IDX8
;
;==============================
MOTSBIT		EQU	$
                LDA     #30H
                STA     MTHANK
;
                LDA     #080H
                STA     MTANGL
;;                LDA     #00H
                STZ     MTANGL+1
;
;;		LDA	#00H
		STZ	MTANSD
		STZ	MTTLCT
		STZ	MTANG2
		STZ	MTANG2+1
;-------------------------------------------
MTFTIT		EQU	$
		PHB
		PHK
		PLB
;
		PHX
;
		LDA	ENCONT,X
		STA	<WORK0
;
		LDY	#03H
MBSB10		EQU	$		
		LDA	<WORK0
		CLC
		ADC	MFTYRV,Y
		AND	#1FH
		TAX
		LDA	MFTYDT,X
		STA	MTFOTY,Y
		DEY
		BPL	MBSB10	
;
		PLX
		PLB
		RTL
;
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Motos big Big		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
;MSBRXS		EQU	$
;		HEX	10,F0,10,F0
;MSBRYS		EQU	$
;		HEX	F0,F0,10,10
;
MOTSBMV		EQU	$
		LDA	ENWRK2,X
		BPL	MBM010
MSKBRMV		EQU	$
;------------- Mask break ------
		LDA	ENTIM0,X
		BEQ	MSBRF0		; Smoke clear ?
;					; yes !
		DEC	A
		BNE	MSBRE0
		STZ	ENMODE,X
MSBRE0		EQU	$
;		AND	#01H
;		BNE	MSBRE8
;;
;		JSL	>EN1CSTL
;MSBRE8		EQU	$
;		JSR	ENSTCK
;		RTS
;------------------------------------------------------
MSBRF0		EQU	$
		JSL	>EN1CSTL
		JSR	ENSTCK
;
		LDA	<FRCNT
		AND	#07H
		ORA	ENTIM1,X
		BNE	MSBRF2
;
		LDA	ENCLOR,X
;;		CLC
		EOR	#01000000B
		STA	ENCLOR,X
;
MSBRF2		EQU	$
		JSR	ENMVCL2
		DEC	ENZSPD,X
		DEC	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	MSBR10
;
		STZ	ENZPSL,X
;
;;		LDA	ENSTAT,X
;;		BEQ	MSBR00
;
		LDA	#0CH
		STA	ENTIM0,X
;
		LDA	#018H
		STA	ENZSPD,X
;
		LDA	#06H
		STA	ENCHPT,X
MSBR10		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - -
;MSBR00		EQU	$
;		LDA	#10H
;		STA	ENZSPD,X
;;
;		JSL	>RNDSET
;		AND	#03H
;		TAY
;		LDA	MSBRXS,Y
;		STA	ENXSPD,X
;		LDA	MSBRYS,Y
;		STA	ENYSPD,X
;;
;		INC	ENSTAT,X
;MSBR10		EQU	$
;;
;		RTS
;------------- Master -----------------
MBM010		EQU	$
		CMP	#03H
		BCS	MTE00	; On mask ?
;					; yes !
		LDA	ENFLCL,X
		AND	#11110001B
		STA	ENFLCL,X
;
		LDA	#00001010B
		STA	ENMOD7,X	; Player YA hane !
		BRA	MTE08
MTE00		EQU	$
		LDA	#1FH
		STA	ENMOD3,X	; Kyusho hani !
;
		LDA	#00000010B
		STA	ENMOD7,X
MTE08		EQU	$
		JSR	MOTSBCS
;
		LDA	ENMODE,X
		CMP	#EFAIL
		BNE	MTE500
;
		LDA	ENTIM0,X
		BNE	MTE480
;
		LDA	#EBAKU
		STA	ENMODE,X
		STZ	ENWRK0,X
                LDA     #0E0H
                STA     ENTIM0,X
;
                RTS
;
MTE480		EQU	$
		PHA
		ORA	#0F0H
		STA	ENFLSH,X
		PLA
		CMP	#80H
		BCS	MTE490
		AND	#07H
		BNE	MTE490
;
		LDY	MTTLCT
		CPY	#10H
		BEQ	MTE490
;
		INC	MTTLCT
;
		STZ	<WORK0
		LDA	MTTLXD,Y
		BPL	MTE488
		DEC	<WORK0
MTE488		EQU	$
		CLC
		ADC	ENXPSL,X
		STA	ENXP2L
;
		LDA	ENXPSH,X
		ADC	<WORK0
		STA	ENXP2H
;
		STZ	<WORK0
		LDA	MTTLYD,Y
		BPL	MTE48A
		DEC	<WORK0
MTE48A		EQU	$
		CLC
		ADC	ENYPSL,X
		STA	ENYP2L
;
		LDA	ENYPSH,X
		ADC	<WORK0
		STA	ENYP2H
;
		JSL	>HBBKST		
;
MTE490		EQU	$
		RTS
;=============================================
MTMSDT		EQU	$
;;			0  4  8  12 16 20 24 28 32 36 40 44 48
		HEX	03,03,03,03,03,03,03,03,02,02,01,01,00
; - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MTE500		EQU	$
		JSR	ENSTCK
;
		LDA	ENLIFE,X
		LSR	A
		LSR	A
		TAY
		LDA	MTMSDT,Y
		STA	ENWRK2,X
;
		CMP	#03H
		BNE	MTE00C
;
		CMP	ENWRK3,X
		BEQ	MTE00F
;
		STZ	ENFLSH,X
;
		JSR	MSKBRST		; Mask break set !
		BRA	MTE00F
;
MTE00C		EQU	$
		CMP	ENWRK3,X
		BEQ	MTE00F
;
		JSR	MSKBRS2		; 1 of Mask break set !
;
MTE00F		EQU	$
		LDA	ENWRK2,X
		STA	ENWRK3,X
;
;;		LDA	<KEYA2
;;		AND	#80H
;;		BRA	MTE10
;;;
;;		LDA	ENCTFG,X
;;		BNE	MTE10
;;;
;;		INC	ENCTFG,X
;;MTE10		EQU	$
;;		JSR	CREKEK
		JSL	>CRKNENL
;
		JSR	MBSUB
;
		JSR	CRMBEN		; Body cross ! 
		JSR	CRHMMS		; Hanmer vs mask !
;
		LDA	ENTIM1,X
		BEQ	MT0100		; Tail atack time ?
;					; yes !
		CMP	#60H
		BEQ	TLATST
;
		RTS
;
;=================================================
MT0100		EQU	$
		LDA	ENTIM2,X
		BEQ	MT0180		; Fire shot time ?
;					; yes !
		CMP	#40H
		BNE	MT1030
;
		JSR	MOTAMST
;
		LDA	ENWRK2,X
		CMP	#03H
		BCC	MT1030
;
TLATST		EQU	$
		LDA	ENCTFG,X
		BNE	MT1030
;
		INC	ENCTFG,X
;
		LDA	#20H
		STA	ENTUTM,X
MT1030		EQU	$
		RTS
;=================================================
MT0180		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MTSTOP
		WORD	MTWALK1
		WORD	MTSTOP2
		WORD	MTWALK2
;------------------------------------
MTWXSD		EQU	$
		HEX	F4,F4,FC,00,04,0C,0C,00
MTWYSD		EQU	$
		HEX	00,04,0C,0C,0C,04,00,0C
;
MTSTOP		EQU	$
		LDA	ENFLSH,X
		BNE	MTST02
;
		LDA	ENTIM0,X
		BNE	MTST10
;
MTST02		EQU	$
		JSR	MTATCK
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	MTWXSD,Y
		STA	ENXSPD,X
		LDA	MTWYSD,Y
		STA	ENYSPD,X
;
		LDA	#40H
		STA	ENTIM0,X
;
		LDA	ENWRK2,X
		CMP	#03H
		BCC	MTST08		; High speed !
;
		ASL	ENXSPD,X
		ASL	ENYSPD,X
;
		LSR	ENTIM0,X
MTST08		EQU	$
;
		INC	ENSTAT,X
MTST10		EQU	$
		RTS
;------------------------------------
MTWALK1		EQU	$
		JSR	MTWKCT
;
;		JSR	ENMVCL
;
		LDA	ENTIM0,X
		BNE	MTW110
;
		LDA	#20H
		STA	ENTIM0,X
;
		INC	ENSTAT,X
MTW110		EQU	$
		RTS
;------------------------------------
MTWKCT		EQU	$
;;		INC	ENCONT,X
		JSR	FTSDST		; Foot sound set !
;
		LDA	<FRCNT
		AND	#03H
		BNE	MTW107
;
;;		INC	ENCONT,X
		JSR	FTSDST		; Foot sound set !
MTW107		EQU	$
;
		LDA	ENWRK2,X
		CMP	#03H
		BCC	MTW108
;
;;		INC	ENCONT,X
		JSR	FTSDST		; Foot sound set !
MTW108		EQU	$
		JSR	ENMVCL
		RTS
;------------------------------------
FTSDST		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#0FH
		BNE	FSDS00
;
		LDA	#21H
		STA	SOUND2	;(S)
FSDS00		EQU	$
		RTS
;------------------------------------
MTSTOP2		EQU	$
		LDA	ENFLSH,X
		BNE	MTST22
;
		LDA	ENTIM0,X
		BNE	MTS210
;
MTST22		EQU	$
		JSR	MTATCK
;
		LDA	#40H
		STA	ENTIM0,X
;
		LDA	ENWRK3,X
		CMP	#03H
		BCC	MTS208		; High speed !
;
		LSR	ENTIM0,X
MTS208		EQU	$
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
;
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
;
		INC	ENSTAT,X
;
MTS210		EQU	$
		RTS
;------------------------------------
MTWALK2		EQU	$
		JSR	MTWKCT
;
;		INC	ENCONT,X
;;
;		LDA	ENWRK2,X
;		CMP	#03H
;		BCC	MTW208
;;
;		INC	ENCONT,X
;MTW208		EQU	$
;		JSR	ENMVCL
;
		LDA	ENTIM0,X
		BNE	MTW210
;
		STZ	ENSTAT,X
;
		LDA	#40H
		STA	ENTIM0,X
;
MTW210		EQU	$
		RTS
;--------------------------------------
MTATCK		EQU	$
		INC	HEMODE,X
		LDA	HEMODE,X
		CMP	#04H
		BNE	MTAC18
;
		PLA
		PLA
;
		STZ	HEMODE,X
;
		JSL	>RNDSET
		AND	#01H
		BEQ	MTAC10
;
		LDA	#7FH
		STA	ENTIM2,X
;
		LDA	#2AH
		JSL	>SDLRE3	;(S)
;
		RTS
MTAC10		EQU	$
		LDA	#0A0H
		STA	ENTIM1,X
MTAC18		EQU	$
		RTS
;==============================================
MFTYDT		EQU	$
		HEX	0,1,2,3,4,5,6,7
		HEX	8,8,8,8,8,8,8,8
		HEX	8,8,8,8,8,8,8,8
		HEX	8,7,6,5,4,3,2,1
MFTYRV		EQU	$
		HEX	00,08,10,18
;
MBSUB		EQU	$
;- - - - Eye cont. - - -
		INC	MTEYCT
;- - Foots cont. - - - 
;
		JSL	>MTFTIT		; Foot y pos set
;
;- - tail cont. - - - 
		LDA	#01H
		LDY	ENCTFG,X
		BEQ	MBSB18		; Atack time ?
		LDA	#00H		; yes ! high speed !
MBSB18		EQU	$
		AND	<FRCNT
		BNE	MBSB38
;
		LDA	ENMUKI,X
		AND	#01H
		TAY
;
		LDA	MTANSD
		CLC
		ADC	MTASAD,Y
		STA	MTANSD				
		CMP	MTASLM,Y
		BNE	MBSB20
		INC	ENMUKI,X
MBSB20		EQU	$
		LDY	#00H
		LDA	MTANSD
		BPL	MBSB30
		DEY
MBSB30		EQU	$
		CLC
		ADC	MTANGL
		STA	MTANGL
		TYA
		ADC	MTANGL+1
		AND	#0FFH
		STA	MTANGL+1
MBSB38		EQU	$
;- - Tail atack - - - -
		LDA	ENCTFG,X
		BEQ	MTAT22	; Atack time ?
;				; yes !
		LDA	MTANSD
		BNE	MBSB3A
;
;;		JSL	>SDLRCE
;;		ORA	#06H
;;		STA	SOUND3	;(S)
		LDA	#06H
		JSL	>SDLRE3	;(S)
MBSB3A		EQU	$
		LDA	ENCTFG,X
		CMP	#02H
		BEQ	MTAT10
		CMP	#03H
		BEQ	MTAT20
;-----Atack check ------------------------------------
		LDA	MTANSD
		ORA	ENTUTM,X
		BNE	MTAT90
;
		LDA	MTANGL+1
		AND	#01H
		STA	ENCMKI,X
;
		JSR	EPXCHK
		TYA
		EOR	#01H
		CMP	ENCMKI,X
		BNE	MTAT22		; Muki ok ?
;					; yes !
		INC	ENCTFG,X
;
		JSL	>SDLRCE
		ORA	#26H
		STA	SOUND3	;(S)	; Yuusen !
;;		LDA	#26H
;;		JSL	>SDLRE3	;(S)
MTAT22		EQU	$
		RTS
;-----------------------------------------
MTATAA		EQU	$
		HEX	04,FC
		HEX	00,FF
MTATAL		EQU	$
		HEX	7C,84
;
MTAT10		EQU	$
		LDY	ENCMKI,X
		LDA	MTANG2
		CLC
		ADC	MTATAA,Y
		STA	MTANG2
		PHA
		LDA	MTANG2+1
		ADC	MTATAA+2,Y
		STA	MTANG2+1
		PLA
		CMP	MTATAL,Y
		BNE	MTAT18
		INC	ENCTFG,X
MTAT18		EQU	$
		LDA	MTHANK
		CLC
		ADC	#03H
		STA	MTHANK
		RTS
;-----------------------------------------
MTAT20		EQU	$
		LDA	ENCMKI,X
		EOR	#01H
		TAY
		LDA	MTANG2
		CLC
		ADC	MTATAA,Y
		STA	MTANG2
		PHA
		LDA	MTANG2+1
		ADC	MTATAA+2,Y
		STA	MTANG2+1
		PLA
		CMP	#00H
		BNE	MTAT30
;
		STZ	ENCTFG,X
MTAT30		EQU	$
		LDA	MTHANK
		SEC
		SBC	#03H
		STA	MTHANK
MTAT90		EQU	$
		RTS
;- - - - - - - - - - -
MTASAD		EQU	$
		HEX	01,FF
;=============================================================
CRHMMS		EQU	$
		LDA	ENWRK2,X
		CMP	#03H
		BCS	CHM090
;
		LDA	AITMBT
		AND	#00001010B
		BEQ	CHM090
;
		LDA	<KNCRYP
		CMP	#80H
		BEQ	CHM090
;
		JSL	>PKNCRS2
;
		LDA	ENYPSL,X
		PHA
		CLC
		ADC	#08H
		STA	ENYPSL,X
		JSL	>ENCRST2
		PLA
		STA	ENYPSL,X
;
		JSL	>CROJCK2
		BCC	CHM090
;
		DEC	ENLIFE,X
;		SEC
;		SBC	#01H
;		STA	ENLIFE,X
;
		LDA	#21H
		STA	SOUND3		;(S)
;
		LDA	#30H
		JSL	>PSERC2L
		LDA	<WORK0
		STA	<PLYSPD
		LDA	<WORK1
		STA	<PLXSPD
		LDA	#08H
		STA	HANEFG
;
		LDA	FLMODE
		BNE	CHM08A
;
		LDA	<WORK0
		STA	FLXPOS
		LDA	<WORK1
		STA	FLYPOS
		LDA	#05H
		STA	FLMODE
CHM08A		EQU	$
		LDA	#05H
		JSL	>SDLRE2		;(S)
CHM090		EQU	$
		RTS
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;=============================================================
CRMBEN		EQU	$
		LDA	<FRCNT
		AND	#07H
		BNE	CMB010
;
		MEM16
		REP	#20H
;
		LDA	<PLXPS1
		SEC
		SBC	ENXP2L
		CLC
		ADC	#0024H
		CMP	#0048H
		BCS	CMB010
;
		LDA	<PLYPS1
		SEC
		SBC	ENYP2L
		CLC
		ADC	#0028H
		CMP	#0040H
		BCS	CMB010
		MEM8
		SEP	#20H
;
		JSL	>PLFLSTL
;
CMB010		EQU	$
		MEM8
		SEP	#20H
		RTS
;=============================================================
MSBSYL		EQU	$
		HEX 	18,1B,18         
		HEX 	18,1B,18         
		HEX 	  1B,1B        
		HEX	18   ,18
MSBSYH		EQU	$
		HEX	00,00,00
		HEX	00,00,00
		HEX	  00,00
		HEX	00   ,00
MSBSXL		EQU	$
		HEX	F0,00,10
		HEX	F0,00,10
		HEX	  F8,08
		HEX	F0   ,10
MSBSXH		EQU	$
		HEX	FF,00,00
		HEX	FF,00,00
		HEX	  FF,00
		HEX	FF   ,00
MSBSZL		EQU	$
		HEX	1D,20,1D
		HEX	0D,10,0D
		HEX	 00,00
		HEX	0D   ,0D
MSBSXS		EQU	$
		HEX	F0,FC,0E
		HEX	F4,04,12
		HEX	  FE,02
		HEX	F4   ,12
MSBSYS		EQU	$
		HEX	F8,FC,FA
		HEX	04,02,07
		HEX	  06,08
		HEX	04   ,07
MSBSZS		EQU	$
		HEX	20,28,24
		HEX	25,27,22
		HEX	  1E,21
		HEX	25   ,22
MSBSCL		EQU	$
		HEX	00,00,40
		HEX	00,00,40
		HEX	  00,40
		HEX	00   ,40
MSBSPT		EQU	$
		HEX	0,1,0
		HEX	2,3,2
		HEX	 4,4
		HEX	5  ,5
;
MSKBRS2		EQU	$
		LDA	ENWRK2,X	; 1,2
		CLC
		ADC	#07H
		STA	ENHELP
		JSR	MSBRSB
		BRA	MSBS90
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MSKBRST		EQU	$
		LDY	#ENNO-1
		LDA	#00H
MSBS08		EQU	$
		STA	ENMODE,Y
		DEY
		BNE	MSBS08
;
;;		JSL	>SDLRCE
;;		ORA	#1FH
;;		STA	SOUND2		;(S)
;;		LDA	#1FH
;;		JSL	>SDLRE2	;(S)
;
		LDA	#07H
		STA	ENHELP
MSBS10		EQU	$
		JSR	MSBRSB
;
		DEC	ENHELP
		BPL	MSBS10
;
MSBS90		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#1FH
;;		STA	SOUND2		;(S)
		LDA	#1FH
		JSL	>SDLRE2	;(S)
		RTS		
;
;------------------------------------------------------
MSBRSB		EQU	$
		LDA	#MOTSB
		JSL	>ENIDSH
		BMI	MSBRS0
;
		PHX
		LDX	ENHELP
		LDA	<WORK0
		CLC
		ADC	MSBSXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	MSBSXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	MSBSYL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	MSBSYH,X
		STA	ENYPSH,Y
;
		LDA	MSBSZL,X
		STA	ENZPSL,Y
;
		LDA	MSBSXS,X
		STA	ENXSPD,Y
		LDA	MSBSYS,X
		STA	ENYSPD,Y
		LDA	MSBSZS,X
		STA	ENZSPD,Y
		LDA	MSBSCL,X
		ORA	#00001101B
		STA	ENCLOR,Y
		LDA	MSBSPT,X
		STA	ENCHPT,Y
;
		LDA	#80H
		STA	ENWRK2,Y
		asl	a
;;		LDA	#00H
		STA	ENMOD0,Y
		LDA	#0CH
		STA	ENTIM1,Y
		STA	ENNOCR,Y
		LDA	ENHELP
		STA	HEMODE,Y
		PLX
MSBRS0		EQU	$
		RTS
;
;
;
;
;===========================================================
MOTAMST		EQU	$
		LDA	#MOTAM
		JSL	>ENIDSH
		BMI	MS0010
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#1CH
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#00H
		STA	ENYPSH,Y		
;
		LDA	#20H
		STA	ENTIM0,Y
		STA	ENNOCR,Y
MS0010		EQU	$
		RTS
;=============================================================
MOTSBCS		EQU	$
;;		LDA	#53*4
;;		JSL	>OAMENT1
		MEM16
		REP	#20H
		LDA	#OAM+170H-53*4
		STA	<OAMADR
		LDA	#OAMSB+170H/4-53*4/4
		STA	<OSBADR
		MEM8
		SEP	#20H
;
		JSR	OAMCHK
;
		JSR	MTTLCS
;
		JSR	MTEYCS
		JSR	MTMACS
		JSR	MTBDCS
		JSR	MTFTCS
		JSR	MTMSCS
		RTS
;---EYE-------------------------------------------
; - - Eye data - -
MECXAD		EQU	$
		HEX	FD,0B
MECCDT		EQU	$
		HEX	CE,CF,DE,DE,DE,DE,CF,CE
;
MECADT		EQU	$
		HEX	3B,7B
;
;- - - Eyes set - - -
MTEYCS		EQU	$
		MEM16
		REP	#20H
		LDA	<OAMADR
		CLC
		ADC	#10H*4
		STA	<OAMADR
		LDA	<OSBADR
		CLC
		ADC	#10H
		STA	<OSBADR
		MEM8
		SEP	#20H
;
		PHX
;
		LDY	#00H
		LDX	#01H
MEC010		EQU	$
		PHX
		LDA	<WORK0
		CLC
		ADC	MECXAD,X
		STA	(<OAMADR),Y		
		LDA	<WORK2
		CLC
		ADC	#0014H
		INY
		STA	(<OAMADR),Y
		LDA	MTEYCT
		LSR	A
		LSR	A
		AND	#07H
		TAX
		LDA	MECCDT,X
		INY
		STA	(<OAMADR),Y
		PLX
		LDA	MECADT,X
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#00H
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	MEC010		
;
		PLX
;
		LDA	<GAMEMD
		BEQ	MEC098
;
		LDY	#00H
		LDA	#01H
		JSL	>ALOMCKL
MEC098		EQU	$
		RTS
;---MASK-------------------------------------------
MTMACD		EQU	$
;0
		WORD	0FFF0H,00000H-5
		HEX	AE,0D,00,02
		WORD	00000H,00000H-5
		HEX	C0,0D,00,02
		WORD	00010H,00000H-5
		HEX	AE,4D,00,02
		WORD	0FFF0H,00010H-5
		HEX	C2,0D,00,02
		WORD	00000H,00010H-5
		HEX	C4,0D,00,02
		WORD	00010H,00010H-5
		HEX	C2,4D,00,02
		WORD	0FFF8H,00020H-5
		HEX	C6,0D,00,02
		WORD	00008H,00020H-5
		HEX	C6,4D,00,02
;1
		WORD	0FFF0H,00000H-5
		HEX	AE,0D,00,02
		WORD	00000H,00000H-5
		HEX	C0,0D,00,02
		WORD	00010H,00000H-5
		HEX	AE,4D,00,02
		WORD	0FFF0H,00010H-5
		HEX	C8,0D,00,02
		WORD	00000H,00010H-5
		HEX	C4,0D,00,02
		WORD	00010H,00010H-5
		HEX	C2,4D,00,02
		WORD	0FFF8H,00020H-5
		HEX	C6,0D,00,02
		WORD	00008H,00020H-5
		HEX	C6,4D,00,02
;2
		WORD	0FFF0H,00000H-5
		HEX	AE,0D,00,02
		WORD	00000H,00000H-5
		HEX	C0,0D,00,02
		WORD	00010H,00000H-5
		HEX	AE,4D,00,02
		WORD	0FFF0H,00010H-5
		HEX	C8,0D,00,02
		WORD	00000H,00010H-5
		HEX	C4,0D,00,02
		WORD	00010H,00010H-5
		HEX	C8,4D,00,02
		WORD	0FFF8H,00020H-5
		HEX	C6,0D,00,02
		WORD	00008H,00020H-5
		HEX	C6,4D,00,02
;
MTMACS		EQU	$
		LDA	#00H
		XBA
		LDA	ENWRK2,X
;;		CMP	#03H
;;		BCS	MAC010
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ASL	A
		ASL	A
		ADC	#MTMACD  
		STA	<WORK8
;
		LDA	<OAMADR
		CLC
		ADC	#02H*4
		STA	<OAMADR
;
		INC	<OSBADR
		INC	<OSBADR
;
		MEM8
		SEP	#00100000B
;
		LDA	ENWRK2,X
		CMP	#03H
		BCS	MAC010
;
		LDA	#08H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		MEM16
		REP	#20H
		LDA	<OAMADR
		CLC
		ADC	#08H*4
		STA	<OAMADR
		LDA	<OSBADR
		CLC
		ADC	#08H
		STA	<OSBADR
		MEM8
		SEP	#20H
;- - - - - Player bomb hit check - - - -
		LDA	ENTIM3,X
		BEQ	CRMSBO
;
MAC010		EQU	$
		RTS
;=========================================
CRMSBO		EQU	$
		LDY	#01H
CMSB10		EQU	$
		LDA	BMMODE,Y
		CMP	#07H
		BNE	CMSB20		; Bomb ?
;					; yes !
		LDA	BMXSPD,Y
		ORA	BMYSPD,Y
		BEQ	CMSB20
;
		JSR	CBBSUB
;
CMSB20		EQU	$
		DEY
		BPL	CMSB10
		RTS
;=========================================
CBBSUB		EQU	$
		JSL	>ENCRST2
		LDA	BMXPSL,Y
		CLC
		ADC	#06H
		STA	<WORK0
		LDA	BMXPSH,Y
		ADC	#00H
		STA	<WORK8
		LDA	BMYPSL,Y
		SEC
		SBC	BMZPSL,Y
		STA	<WORK1
		LDA	BMYPSH,Y
		SBC	#00H
		STA	<WORK9
		LDA	#02H
		STA	<WORK2	
		LDA	#0FH
		STA	<WORK3
		JSL	>CROJCK2
		BCC	CBB0F0
;
		LDA	BMXSPD,Y
		EOR	#0FFH
		INC	A
		STA	BMXSPD,Y
;
		LDA	BMYSPD,Y
		EOR	#0FFH
		INC	A
		STA	<WORK0
		ASL	<WORK0
;
		ROR	A
		STA	BMYSPD,Y
;
		LDA	#20H
		STA	ENTIM3,X
;
		LDA	#05H
		STA	FLMODE
		LDA	BMXPSL,Y
		STA	FLXPOS
		LDA	BMYPSL,Y
		SEC
		SBC	BMZPSL,Y
		STA	FLYPOS
;
                LDA     #05H
                STA     SOUND2  ;(S)
CBB0F0		EQU	$
		RTS
;
;
;
;
;---BODY-------------------------------------------
MTBDCD		EQU	$
		WORD	0FFE8H,0FFE0H
		HEX	80,0B,00,02
		WORD	0FFF8H,0FFE0H
		HEX	82,0B,00,02
		WORD	00008H,0FFE0H
		HEX	82,4B,00,02
		WORD	00018H,0FFE0H
		HEX	80,4B,00,02
;
		WORD	0FFE8H,0FFF0H
		HEX	84,0B,00,02
		WORD	0FFF8H,0FFF0H
		HEX	86,0B,00,02
		WORD	00008H,0FFF0H
		HEX	86,4B,00,02
		WORD	00018H,0FFF0H
		HEX	84,4B,00,02
;
		WORD	0FFE8H,00000H
		HEX	88,0B,00,02
		WORD	0FFF8H,00000H
		HEX	8A,0B,00,02
		WORD	00008H,00000H
		HEX	8A,4B,00,02
		WORD	00018H,00000H
		HEX	88,4B,00,02
;
		WORD	0FFE8H,00010H
		HEX	8C,0B,00,02
		WORD	0FFF8H,00010H
		HEX	8E,0B,00,02
		WORD	00008H,00010H
		HEX	8E,4B,00,02
		WORD	00018H,00010H
		HEX	8C,4B,00,02
;
		WORD	0FFF8H,00020H
		HEX	A0,0B,00,02
		WORD	00008H,00020H
		HEX	A0,4B,00,02
;
		WORD	00000H,0FFD8H
		HEX	AC,0B,00,02
;- - - - - - - - - - - - - - - - - - - - - -
MTBDCS		EQU	$
		MEM16
		REP	#00100000B
		LDA	#MTBDCD  
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#13H
;;		STA	<WORK6
;;		STZ	<WORK7
;
SETO22		EQU	$
		JSL	>SETOAML22
		RTS
;---FOOTS-------------------------------------------
MFTXAD		EQU	$
		HEX	E4,E4,1C,1C
MFTYAD		EQU	$
		HEX	E4,04,E4,04
MFTCDT		EQU	$
		HEX	A2,A6,A2,A6
MFTADT		EQU	$
		HEX	0B,0B,4B,4B
;- - - - - - - - - - - - - - - - - - - - - - - - -
MTFTCS		EQU	$
		MEM16
		REP	#00100000B
		LDA	<OAMADR
		CLC
		ADC	#13H*4
		STA	<OAMADR
		LDA	<OSBADR
		CLC
		ADC	#13H
		STA	<OSBADR
		MEM8
		SEP	#00100000B
;
		PHX
		LDY	#00H
;
		LDA	#03H
		STA	ENHELP
MFTC10		EQU	$
		LDX	ENHELP
		LDA	<WORK0	
		CLC
		ADC	MFTXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	MFTYAD,X
		CLC
		ADC	MTFOTY,X
		INY
		STA	(<OAMADR),Y
		LDA	MFTCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	MFTADT,X
		EOR	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
;
		PLY
		INY
;
		LDA	<WORK0	
		CLC
		ADC	MFTXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	MFTYAD,X
		CLC
		ADC	#010H
		CLC
		ADC	MTFOTY,X
		INY
		STA	(<OAMADR),Y
		LDA	MFTCDT,X
		CLC
		ADC	#02H
		INY
		STA	(<OAMADR),Y
		LDA	MFTADT,X
		EOR	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
		PLY
		INY
		DEC	ENHELP
		BPL	MFTC10
		PLX
;
		LDA	<GAMEMD
		BEQ	MFTC20
;
		LDY	#02H
		LDA	#07H
		JSL	>ALOMCKL
;
		JSR	OAMCHK
MFTC20		EQU	$
		RTS
;
;---MOUSE-------------------------------------------
MMSYAD		EQU	$
		HEX	1,2,3,4,5,6,7,8
		HEX	9,A,A,A,A,A,A,A
		HEX	A,A,A,A,A,A,A,9
		HEX	8,7,6,5,4,3,2,1
;
MTMSCS		EQU	$
		LDA	ENTIM2,X
		BEQ	MMSC90
		LSR	A
		LSR	A
		TAY
		LDA	MMSYAD,Y
		STA	<WORK6
;
		LDA	#04H
		JSL	>OAMENT2
;
		LDY	#00H
		LDA	<WORK0
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	#13H
		ADC	<WORK6
		INY
		STA	(<OAMADR),Y
		LDA	#0AAH
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		EOR	#0BH
		INY
		STA	(<OAMADR),Y
		LDA	#02H
		STA	(<OSBADR)
;
MMSC90		EQU	$		
		RTS
;=================================================
;---TAIL-------------------------------------------
MTTLAS		EQU	$
		HEX	FF,F0,E0,D0,C0,B0,A0,90
		HEX	80,70,60,50,40,30,20,10
;
		HEX	FF,F8,F0,E8,E0,D8,D0,C8
		HEX	BC,B0,A0,90,70,40,20,10
;
;;		HEX	FF,E0,C0,A0,80,60,40,20
MTTLSB		EQU	$
		HEX	FF,F0,E0,D0,C0,B0,A0,90
		HEX	80,70,60,50,40,30,20,10
;
;;		HEX	FF,E0,C0,A0,80,60,40,20
;
;
MTTLCS		EQU	$
;- - Angle calc - - -
		STZ	ENHELP
;
MTCT10		EQU	$
		LDY	ENHELP
;;		PHA
;;		ASL	A
;;		TAY
;
		PHY
;
		LDA	ENCTFG,X
		BEQ	MTCT105
;
		TYA
		CLC
		ADC	#10H
		TAY
MTCT105		EQU	$
		MEM16
		REP	#20H
		LDA	MTANGL
		CLC
		ADC	MTANG2
		STA	<WORKD
		MEM8
		SEP	#20H
;
;;		LDA	MTANGL+1
		LDA	<WORKD+1
		CMP	#01H
		PHP
		PHP
;;		LDA	MTANGL
		LDA	<WORKD
		PLP
		BPL	MTCT11
		EOR	#0FFH
		INC	A
MTCT11		EQU	$
		STA	4202H
		LDA	MTTLAS,Y
		STA	4203H
;;		HEX	EA,EA,EA,EA,EA,EA,EA,EA
		JSR	NOPSUB
		LDA	4217H
		PLP
		BPL	MTCT12
		EOR	#0FFH
;;		INC	A
MTCT12		EQU	$
		STA	<WORK0+6
;
                LDA	<WORKD+1
		STA	<WORK0+6+1
;
		PLY
;
		LDA	MTHANK
		STA	4202H
		LDA	MTTLSB,Y
		STA	4203H
;;		HEX	EA,EA,EA,EA,EA,EA,EA,EA
		JSR	NOPSUB
		LDA	4217H
		STA	<WORKF		; hankei X
;
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0+6
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK4+6
;
		LDA	<WORK0+6
		CLC
		ADC	#0080H
		STA	<WORK2+6
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK6+6
		MEM8
		IDX8
		SEP	#00110000B		
;
		PLX
;
		LDA	<WORK4+6
		STA	4202H
		LDA	<WORKF 	    ; Hankei
		LDY	<WORK5+6
		BNE	MKSF0
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		ASL	4216H
		LDA	4217H
		ADC	#00H
MKSF0		EQU	$
		LSR	<WORK1+6
		BCC	MKS00
		EOR	#0FFH
		INC	A
MKS00		EQU	$
		LDY	ENHELP
		STA	MTTLXD,Y	; X AD
;
		LDA	<WORK6+6
		STA	4202H
		LDA	<WORKF
		LDY	<WORK7+6
		BNE	MKS08
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		ASL	4216H
		LDA	4217H
		ADC	#00H
MKS08		EQU	$
		LSR	<WORK3+6
		BCC	MKS10
		EOR	#0FFH
		INC	A
MKS10		EQU	$
		LDY	ENHELP
		SEC
		SBC	#28H
		STA	MTTLYD,Y	; Y AD
;--------------------------------------------
		INC	ENHELP
		LDA	ENHELP
		CMP	#10H
		BEQ	MTCTA0
		JMP	MTCT10
MTCTA0		EQU	$
;-------- OAM SET --------
		LDA	ENCTFG,X
		STA	<WORKA
;
		STZ	<WORKF		; Player hit flag !
;
		PHX
;
		LDX	MTTLCT
		CPX	#10H
		BEQ	MTTC28
;
		LDY	#00H
MTTC10		EQU	$
		LDA	<WORK0
		CLC
		ADC	MTTLXD,X
		STA	(<OAMADR),Y
		STA	<WORK8
		LDA	<WORK2
		CLC
		ADC	MTTLYD,X
		INY
		STA	(<OAMADR),Y
		STA	<WORK9
;
		LDA	#0ACH
		CPY	#01H
		BNE	MTTC11
		LDA	#0E4H		; Tail top !!
MTTC11		EQU	$
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		EOR	#1BH
		INY
		STA	(<OAMADR),Y
;
;;		PHY
;;		TYA
;;		LSR	A
;;		LSR	A
;;		TAY
;;		LDA	#02H
;;		STA	(<OSBADR),Y
;;		PLY
;
		INY
;
                TXA
                EOR     <FRCNT
                AND     #00H
                ORA     PYFLASH
                BNE     EBZM10
;
		LDA	<WORKA
		BEQ	EBZM10
;
                LDA     <PLXPS1
                SBC     <SCCH2
                SBC     <WORK8
                ADC     #0CH
                CMP     #18H
                BCS     EBZM10
;
                LDA     <PLYPS1
                SBC     <SCCV2
                ADC     #08H
                SBC     <WORK9
                ADC     #08H
                CMP     #10H
                BCS     EBZM10
;
;;		JSL	>PLFLSTL
		INC	<WORKF
;
;;		LDA	#10H
;;		LDY	MTANSD
;;		BPL	MTCR10
;;		LDA	#0F0H
;;MTCR10		EQU	$
		STZ	<PLXSPD
		LDA	#38H
		STA	<PLYSPD
;
;                LDA     #01H
;                STA     <DIEFG
;                LDA     #03H
;                STA     DAMEFG
;                LDA     #10H
;                STA     <HANEFG
;;
;                LDA     <PLXSPD
;                EOR     #0FFH
;                STA     <PLXSPD
;                LDA     <PLYSPD
;                EOR     #0FFH
;                STA     <PLYSPD
EBZM10          EQU     $
;
		INX
		CPX	#10H
		BNE	MTTC10
;
MTTC28		EQU	$
		PLX
;
		LDA	<WORKF
		BEQ	MTTC30		; Hit ?
;					; yes !
		LDA	BSFLFG
		BNE	MTTC30
;
		JSL     >PLFLSTL
MTTC30		EQU	$
;;		LDA	<GAMEMD
;;		NOP
;;		NOP
;;		BEQ	MTTC90
;
		LDY	#02H
		LDA	#0FH
		JSL	>ALOMCKL
;
		JSR	OAMCHK	; WORK0,1,2,3,4,5 Set again !
MTTC90		EQU	$
		RTS
;
NOPSUB		EQU	$
		HEX	EA,EA,EA,EA,EA,EA,EA,EA
		RTS
;======Demon beam ======================================================
DEMBMMV		EQU	$
		PHB
		PHK
		PLB
		JSR	DB0010
		PLB
		RTL
;=======================
DB0010		EQU	$
		LDA	ENCONT,X
		AND	#00010000B
		BEQ	DB0020
;
		LDA	#04H
		JSL	>OAMENT2
DB0020		EQU	$
		JSL	>EN1CSSL
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		BNE	DBM020
;
		JSR	ENMVCL
;;		JSR	CRENPL
;;		BCC	DBM010
		LDA	ENTIM0,X
		BNE	DBM010
;
		INC	ENSTAT,X
;
DBM010		EQU	$
		RTS
;-----------------------------------------
DBPLXD		EQU	$
		HEX	0,4,8,C,C,4,8,0
DBPLYD		EQU	$
		HEX	0,4,8,C,C,4,8,0
;
DBM020		EQU	$
		INC	ENSTAT,X
		BNE	DBM030
;
		STZ	ENMODE,X
DBM030		EQU	$
;;		TXA
;;		AND	#03H
;;		TAY
;
		INC	ENCONT,X
		LDA	ENCONT,X
		PHA
		AND	#07H
		BNE	DBM038
;
		LDA	#30H
		STA	SOUND3	;(S)
DBM038		EQU	$
		PLA
		LSR	A
		LSR	A
		PHA
		AND	#00000111B
		TAY
;
		LDA	<PLXPS1
		CLC
		ADC	DBPLXD,Y
		STA	ENXPSL,X		
		LDA	<PLXPS0
		ADC	#00H
		STA	ENXPSH,X		
		PLA
		LSR	A
		LSR	A
		AND	#07H
		TAY
		LDA	<PLYPS1
		CLC
		ADC	DBPLYD,Y
		STA	ENYPSL,X		
		LDA	<PLYPS0
		ADC	#00H
		STA	ENYPSH,X		
		RTS
;=============================================================
ENMY3MV		EQU	$
		PHB
		PHK
		PLB
		JSR	E30000
		PLB
		RTL
;
E30000		EQU	$
		LDA	ENMYNO,X
		SEC
		SBC	#ENMY3
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	E3MVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
ENBGCK		EQU	$
		JSL	>ENBGCKL
		RTS
;============================================
E3MVAD		EQU	$
		WORD	HACHIMV
		WORD	SHSAIMV
		WORD	SHTAMMV
		WORD	TELSAMV
		WORD	TRAP0MV
		WORD	BAAR0MV
		WORD	BAAR1MV
		WORD	HBTAMMV
		WORD	AMENBMV
		WORD	BABU2MV
		WORD	MEDAMMV
		WORD	MEDA2MV
		WORD	SKELTMV
		WORD	CHIBIMV
		WORD	CHFIRMV
		WORD	BIGKOMV
		WORD	BKFIRMV
		WORD	HARI0MV
		WORD	MIIRAMV
		WORD	PATARMV
		WORD	PATAMMV
		WORD	KAM01MV
		WORD	SLIMEMV
		WORD	HANDSMV
		WORD	SKELBMV
		WORD	MOTSBMV
		WORD	BYOYNMV
		WORD	AYASIMV
		WORD	MEMERMV
		WORD	MEMELMV
		WORD	MEMEDMV
		WORD	MEMEUMV
		WORD	PENGIMV
		WORD	FISH0MV
		WORD	MAGICMV
		WORD	KURORMV
		WORD	KURODMV
		WORD	DACHOMV
		WORD	USAGIMV
		WORD	OOOMUMV
		WORD	ICMANMV
		WORD	ICBOSMV
		WORD	ICEBGMV
		WORD	ICTAMMV
		WORD	TEKI0MV
		WORD	TEKI1MV
		WORD	SKEL2MV
		WORD	PATA0MV
		WORD	PATA1MV
		WORD	LIKE0MV
		WORD	POLIWMV
		WORD	RINGOMV
		WORD	HELP1MV
		WORD	DOKN0MV
		WORD	DOKN0MV
		WORD	DOKN0MV
		WORD	DOKN0MV
		WORD	BEE00MV
		WORD	SEKBNMV
		WORD	TAKARMV
		WORD	BAKDNMV
		WORD	SARKKMV
		WORD	TEKBBMV
		WORD	D_0_9MV
		WORD	SITO0MV
		WORD	UZUMKMV
		WORD	SAMTMMV
		WORD	RYOKIMV
		WORD	000
		WORD	000
;===================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Like likk      		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LIKE0MV		EQU	$
		JSR	LIKE0CSS
;
		JSR	ENSTCK
		JSR	ENHNSB
		JSR	CREKEK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	LKSTOP
		WORD	LKJUMP
		WORD	LKSHOT
;- - - - - - - - - - - - - - - - - - -
LKJPXS		EQU	$
MTASLM		EQU	$
ICWXSD		EQU	$
OMGOXS		EQU	$
KSMXSD		EQU	$
BKFZLM		EQU	$
PTBXSD		EQU	$	
PGGXLM		EQU	$
CBWKXS		EQU	$
MDWXSD		EQU	$
TKXSDT		EQU	$
		HEX	10,F0   ;,00,00
LKJPYS		EQU	$
PTBYSD		EQU	$
PGGYLM		EQU	$
CBWKYS		EQU	$
MDWYSD		EQU	$
TKYSDT		EQU	$
		HEX	00,00,10,F0
;
;TKXSDT		EQU	$
;		HEX	10,F0  ,00,00
;TKYSDT		EQU	$
;		HEX	00,00,10,F0
;MDWXSD		EQU	$
;		HEX	10,F0  ;,00,00
;MDWYSD		EQU	$
;		HEX	00,00,10,F0
;CBWKXS		EQU	$
;		HEX	10,F0  ;,00,00
;CBWKYS		EQU	$
;		HEX	00,00,10,F0
;PGGXLM		EQU	$
;		HEX	10,F0  ;,00,00
;PGGYLM		EQU	$
;		HEX	00,00,10,F0
;PTBXSD		EQU	$	
;		HEX	10,F0  ;,00,00
;PTBYSD		EQU	$
;		HEX	00,00,10,F0
;-  -  -  -  -  -  - 
LKSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	LKS010
;
		INC	ENSTAT,X
;
		INC	ENWRK2,X
		LDA	ENWRK2,X
		CMP	#04H
		BNE	LKS008
		STZ	ENWRK2,X
		JSR	EPXYCK
		BRA	LKS00A
LKS008		EQU	$
		JSL	>RNDSET
		AND	#03H
		TAY
LKS00A		EQU	$
		LDA	LKJPXS,Y
		STA	ENXSPD,X
		LDA	LKJPYS,Y
		STA	ENYSPD,X
;
		JSL	>RNDSET
		AND	#07H
		ADC	#13H
		STA	ENZSPD,X
LKS010		EQU	$
LKCHPS		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
		RTS
;-----------------------------------------
LKJUMP		EQU	$
		JSR	ENMVCL2
;;;		JSL	>ENBGCKL
		JSR	ENBGCK
		DEC	ENZSPD,X
		DEC	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	LKJ010
;
		STZ	ENZPSL,X
		STZ	ENZSPD,X
;
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#30H
		CMP	#60H
		BCS	LKJ008
		LDA	<WORKF
		CLC
		ADC	#30H
		CMP	#60H
		BCS	LKJ008
;
		INC	ENSTAT,X
;
		LDA	#1FH
		JSL	>PSERC2L
		JSL	>MKCK16
		LSR	A
		STA	ENMUKI,X
		LDA	#5FH
		STA	ENTIM0,X
		RTS
;
LKJ008		EQU	$
		STZ	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
LKJ010		EQU	$
		BRA	LKCHPS
;-------------------------------------------
LKSHPT		EQU	$
		HEX	02,02,02,02,03,03,03,03
		HEX	03,03,03,03,03,03,03,03
		HEX	03,03,03,03,02,02,02,02
;
LKSHMD		EQU	$
		HEX	00,00,00,00,00,00,00,00
		HEX	00,00,00,00,00,00,00,00
		HEX	00,00,00,00,00,00,00,00
;
		HEX	00,00,00,00,00,00,00,00
		HEX	0C,10,18,20,20,18,10,0C
		HEX	00,00,00,00,00,00,00,00
;
		HEX	00,00,00,00,00,00,00,00
		HEX	F4,F0,E8,E0,E0,E8,F0,F4
		HEX	00,00,00,00,00,00,00,00
;
LKSHXD		EQU	$
		HEX	18,18,00,30,30,30,00,18
;
;;		HEX	0C,10,18,20,20,18,10,0C
;;		HEX	0C,10,18,20,20,18,10,0C
;;		HEX	00,00,00,00,00,00,00,00
;;		HEX	F4,F0,E8,E0,E0,E8,F0,F4
;;		HEX	F4,F0,E8,E0,E0,E8,F0,F4
;;		HEX	F4,F0,E8,E0,E0,E8,F0,F4
;;		HEX	00,00,00,00,00,00,00,00
;;		HEX	0C,10,18,20,20,18,10,0C
LKSHYD		EQU	$
		HEX	00,18,18,18,00,30,30,30
;
;;		HEX	00,00,00,00,00,00,00,00
;;		HEX	0C,10,18,20,20,18,10,0C
;;		HEX	0C,10,18,20,20,18,10,0C
;;		HEX	0C,10,18,20,20,18,10,0C
;;		HEX	00,00,00,00,00,00,00,00
;;		HEX	F4,F0,E8,E0,E0,E8,F0,F4
;;		HEX	F4,F0,E8,E0,E0,E8,F0,F4
;;		HEX	F4,F0,E8,E0,E0,E8,F0,F4
LKSHOT		EQU	$
		LDA	ENTIM0,X
		BNE	LKSH10
;
		STZ	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
		STZ	ENWRK0,X
		STZ	ENWRK1,X
		STZ	ENCTCT,X
;;		STZ	ENKBMK,X
		RTS
LKSH10		EQU	$
		LSR	A
		LSR	A
		PHA
		TAY
		LDA	LKSHPT,Y
		STA	ENCHPT,X
;
		TYA
		LDY	ENMUKI,X
		PHY
		CLC
		ADC	LKSHXD,Y
		TAY
		LDA	LKSHMD,Y
		STA	ENWRK0,X	
		STA	<WORK4
		STZ	<WORK5
		BPL	LKSH20
		DEC	<WORK5
LKSH20		EQU	$
;
;
		PLY
		PLA
		CLC
		ADC	LKSHYD,Y
		TAY
		LDA	LKSHMD,Y
		STA	ENWRK1,X
		STA	<WORK6
		STZ	<WORK7
		STZ	<WORK7
		BPL	LKSH30
		DEC	<WORK7
LKSH30		EQU	$
;- - - - - - - - - - - - - - - - - - - - - - - - -
		LDA	ENCTCT,X
;;		LDA	ENKBMK,X
		BNE	LKSH50		; Not cach ?
;					; yes !
		MEM16
		REP	#20H
;
		LDA	ENXP2L
		CLC
		ADC	<WORK4
		SEC
		SBC	<PLXPS1
		CLC	
		ADC	#000CH
		CMP	#0018H							
		BCS	LKSH50
;
		LDA	ENYP2L
		CLC
		ADC	<WORK6
		SEC
		SBC	<PLYPS1
		CLC	
		ADC	#000CH
		CMP	#0020H							
		BCS	LKSH50		; Hands cros player ?
;					; yes !
		MEM8
		SEP	#20H
;
		LDA	ENTIM0,X
		CMP	#2EH 
		BCS	LKSH50
;
;;		INC	ENKBMK,X	; Cach flag on !
;
		JSL	>SDLRCP
		ORA	#26H
		STA	SOUND2	;(S)
;
		JSL	>RNDSET
		AND	#03H
;;		TAY
;;		LDA	LKITDT,Y
		INC	A
		STA	ENCTCT,X	; 1:Bomb 2:Ya 3:Coin 4:Tate
		STA	ENWRK3,X
		CMP	#01H
		BNE	LKSH48
;
;------------------------------------
		LDA	>BMBCNT
		BEQ	LK01
		DEC	A
		STA	>BMBCNT
		RTS
LK01		EQU	$
		MEM8
		SEP	#20H
		STZ	ENCTCT,X
;;;		STZ	ENKBMK,X
		RTS
LKSH48		EQU	$
		CMP	#02H
		BNE	LKSH4A
;
;------------------------------------
		LDA	>ARWCNT
		BEQ	LK01
		DEC	A
		STA	>ARWCNT
LK02		EQU	$
		RTS
LKSH4A		EQU	$
		CMP	#03H
		BNE	LKSH5A
;------------------------------------
		MEM16
		REP	#20H
		LDA	>CONCNT
		BEQ	LK01
		DEC	A
		STA	>CONCNT
LK03		EQU	$
LKSH50		EQU	$
		MEM8
		SEP	#20H
		RTS
;------------------------------------
LKSH5A		EQU	$
		LDA	>ITMTBL7	;Tate get !
		STA	HEMODE,X	;Save tate no. !
		BEQ	LK01
		CMP	#03H	
		BEQ	LK01	; Max !!
;
		LDA	#00H
		STA	>ITMTBL7	;Tate get !
		RTS
;;- - - - - - - - -
;;LKITDT		EQU	$
;;		HEX	1,2,3,4
;----------------------
LIKE0CSS	EQU	$
		JSR	OAMCHK
		JSL	>LIKE0CS
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Paakuti      		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
PATA0MV		EQU	$
PATA1MV		EQU	$
		LDA	#30H
		STA	ENFLCL,X
		LDA	ENWRK0,X
		BEQ	PT0000
;- - - - Bomb - - -
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	PBDOWN
		WORD	PBBAN
;------------------------------------------------
PBDOWN		EQU	$
		JSL	>EN1CSSL
;
		JSR	ENSTCK
		JSR	ENMVCL
		JSR	ENZCLC
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	PBD010
;
		STZ	ENZPSL,X
;
		INC	ENSTAT,X
;
		LDA	#13H
		STA	ENTIM0,X
;
		INC	ENMOD0,X
;
;;		JSL	>SDLRCE
;;		ORA	#0CH
;;		STA	>SOUND2	   ;(S)
		LDA	#0CH
		JSL	>SDLRE2	;(S)
PBD010		EQU	$
		RTS
;------------------------------------------------
PBBAN		EQU	$
		JSL	>PBBANCS
		JSR	ENSTCK
;
		LDA	<FRCNT
		AND	#03H
		BNE	PBC008
;
		INC	ENTIM0,X
PBC008		EQU	$
		JSL	>CRENPLL
		RTS
;=============================
P0ZSAD		EQU	$
		HEX	01,FF
P0ZSLM		EQU	$
		HEX	08,F8
PTSHPT		EQU	$
		HEX	9,A,8,7
;
PT0000		EQU	$
		LDA	ENTIM1,X
		BEQ	PT0001
;
		LDY	ENMUKI,X
		LDA	PTSHPT,Y
		STA	ENCHPT,X
PT0001		EQU	$
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
;
		JSL	>PATA0CS
;
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	ENTIM1,X
		CMP	#08H
		BNE	PT0010
;
		JSR	PTBMBST		; Bomb set !
PT0010		EQU	$
		JSR	CREKEK
;
                LDA     <FRCNT
                AND     #01H
                BNE     GSFL10
;
                LDA     ENCTCT,X
                AND     #01H
                TAY
                LDA     ENZSPD,X
                CLC
                ADC     P0ZSAD,Y
                STA     ENZSPD,X
                CMP     P0ZSLM,Y
                BNE     GSFL10
;
                INC     ENCTCT,X
GSFL10          EQU     $
                JSR     ENZCLC
;
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#28H
		CMP	#50H
		BCS	P01000
		LDA	<WORKF
		CLC
		ADC	#28H
		CMP	#50H
		BCS	P01000
;
		LDA	<KNCRYP
		CMP	#80H
		BEQ	P01000		; Ken cut ?
;					; yes ! nigeru !
		LDA	DASHFG
		BNE	P0CK10 
;
		LDA	<KENMD
		CMP	#09H
		BPL	P01000 
;
P0CK10		EQU	$
		LDA	#30H
		JSL	>PSERC2L
;
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
;
		LDA	<WORK0
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
;
		LDA	#08H
		STA	ENTIM0,X
		LDA	#02H
		STA	ENSTAT,X
;
P01000		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	P0STOP
		WORD	P0FLY
		WORD	P0SASA
;-------------------------------------------
P0SASA		EQU	$
		LDA	ENTIM0,X
		BNE	P0SA10
;
		STZ	ENSTAT,X
P0SA10		EQU	$
		INC	ENCONT,X
		INC	ENCONT,X
		JSR	P0PTMV		
		RTS
;-------------------------------------------
P0FXSD		EQU	$
		HEX	10,0c,00,f4,f0,f4,00,0c
P0FYSD		EQU	$
		HEX	00,0C,10,0C,00,F4,F0,F4
P0FMKD		EQU	$
		HEX	0,4,2,6
;
P0STOP		EQU	$
		LDA	ENTIM0,X
		BNE	P0S010
;
		INC	ENSTAT,X
;
		INC	ENWRK1,X
		LDA	ENWRK1,X
		CMP	#03H
		BNE	P0S008
;
		STZ	ENWRK1,X
;
		LDA	#30H
		STA	ENTIM0,X
;
		JSR	EPXYCK
		LDA	P0FMKD,Y
		BRA	P0S00C
P0S008		EQU	$
;
		JSL	>RNDSET
		AND	#1FH
		ORA	#20H
		STA	ENTIM0,X
;
		AND	#07H
P0S00C		EQU	$
		TAY
		LDA	P0FXSD,Y
		STA	ENXSPD,X
		LDA	P0FYSD,Y
		STA	ENYSPD,X
P0S010		EQU	$
		BRA	P0PTMV2
;;		RTS
;-----------------------------
P0FLY		EQU	$
		LDA	ENTIM0,X
		BNE	P0F010
;
		STZ	ENSTAT,X
;
		LDA	#0AH
		STA	ENTIM0,X
;
		LDY	ENMYNO,X
		CPY	#PATA0
		BNE	P0F008		; Bomb shot ?
;					; yes !
		LDA	#10H
		STA	ENTIM1,X
P0F008		EQU	$
		RTS
;
P0F010		EQU	$
P0PTMV		EQU	$
		JSR	ENMVCL
P0PTMV2		EQU	$
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
;
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ORA	<WORK0
		STA	ENCHPT,X
		RTS
;===============================
PTBXAL		EQU	$
		HEX	0E,FA,04,04
PTBXAH		EQU	$
		HEX	00,FF,00,00
PTBYAL		EQU	$
		HEX	07,07,0C,FC
PTBYAH		EQU	$
		HEX	00,00,00,FF
;PTBXSD		EQU	$	
;		HEX	10,F0  ;,00,00
;PTBYSD		EQU	$
;		HEX	00,00,10,F0
;
PTBMBST		EQU	$
		LDA	#PATA0
		JSL	>ENIDSH
		BMI	PTBS90
;
;;		JSL	>SDLRCE
;;		ORA	#20H
;;		STA	SOUND2	;(S)
		LDA	#20H
		JSL	>SDLRE2	;(S)
;
		LDA	<WORK4
		STA	ENZPSL,Y
;
		PHX
		LDX	ENMUKI,Y
		LDA	<WORK0
		CLC
		ADC	PTBXAL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	PTBXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	PTBYAL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	PTBYAH,X
		STA	ENYPSH,Y
		LDA	PTBXSD,X
		STA	ENXSPD,Y
		LDA	PTBYSD,X
		STA	ENYSPD,Y
;
		PLX
		LDA	#01H
		STA	ENWRK0,Y
		STA	ENNOCR,Y
;
		LDA	#00001001B
		STA	ENMOD3,Y
		LDA	#00110011B
		STA	ENMOD2,Y
		AND	#0FH
		STA	ENCLOR,Y
PTBS90		EQU	$
		RTS
;		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Zako ura     		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HONEMV		EQU	$
		JSR	HONECS
;
		JSR	ENSTCK
		JSR	CRENPL
;
		INC	ENCONT,X
;
		JSR	ENMVCL
;
		LDA	ENTIM0,X
		BNE	HNM090
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;;		LDA	ENCBFG,X
		BEQ	HNM090
;
		STZ	ENMODE,X
;
		JSL	>EFLSST
HNM090		EQU	$
		RTS
;=======================================
HONECD		EQU	$
;2
		WORD	0FFFCH,0FFFEH
		HEX	2F,80,00,00
		WORD	00004H,00002H
		HEX	2F,40,00,00
;0
		WORD	0FFFCH,00002H
		HEX	2F,00,00,00
		WORD	00004H,0FFFEH
		HEX	2F,C0,00,00
;3
		WORD	00002H,0FFFCH
		HEX	3F,40,00,00
		WORD	0FFFEH,00004H
		HEX	3F,80,00,00
;1
		WORD	0FFFEH,0FFFCH
		HEX	3F,00,00,00
		WORD	00002H,00004H
		HEX	3F,C0,00,00
;
HONECS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#03H
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ADC	#HONECD  
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;;
;;		RTS
;---------------------------------------------
;TKXSDT		EQU	$
;		HEX	10,F0  ,00,00
;TKYSDT		EQU	$
;		HEX	00,00,10,F0
TKWKTM		EQU	$
		HEX	10,20,40,20
;
TKCHPT		EQU	$
		HEX	6,4,0,2
		HEX	7,5,1,3
;
S2JPCP		EQU	$
		HEX	8,9,A,B
;
SKEL2MV		EQU	$
		LDA	ENWRK0,X
		BEQ	S2MFFF
;
		JMP	HONEMV
;
S2MFFF		EQU	$
;;		LDA	ENCTCT,X
		LDA	ENWRK3,X
		BEQ	S2M100		; Initial BG check ?
;					; yes !
		LDA	ENTIM0,X
		BNE	S2M006
;
		LDA	#01H
		STA	ENXSPD,X
		STA	ENYSPD,X
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;;		LDA	ENCBFG,X
		BEQ	S2M002		; In BG ?
;					; YES ! Can't set !
		STZ	ENMODE,X 
		RTS
S2M002		EQU	$
		STZ	ENWRK3,X
;;		STZ	ENCTCT,X
;
;;		JSL	>SDLRCE
;;		ORA	#15H
;;		STA	SOUND2	;(S)
		LDA	#15H
		JSL	>SDLRE2	;(S)
;
		JSL	>KEMRIST
;
		LDA	#08H
;;		LDA	#13H
		STA	ENTIM2,X	; Kemuri time !
		LDA	#40H
		STA	ENTIM0,X	; Walk wait !
;
		STZ	ENYSPD,X
		STZ	ENXSPD,X
;;		LDA	#07H
;;		STA	ENMOD0,X
S2M006		EQU	$
		JSL	>OAMCHKL
		RTS
;===============================
S2JPMK		EQU	$
		HEX	3,2,1,0
;
;--------
S2M100		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	S2CK10
;
;		JSR	EPXYCK
;		LDA	<WORKE
;		CLC
;		ADC	#28H
;		CMP	#50H
;;		BCS	S2CK10
;		LDA	<WORKF
;		CLC
;		ADC	#28H
;		CMP	#50H
;		BCS	S2CK10		; Fighting area in ?
		MEM16
		REP	#20H
		LDA	<PLXPS1
		SEC
		SBC	ENXP2L
		CLC
		ADC	#0028H
		CMP	#0050H
		BCS	S2CK10
;
		LDA	<PLYPS1
		SEC
		SBC	ENYP2L
		CLC
		ADC	#0028H+8
		CMP	#0050H
		BCS	S2CK10
		MEM8
		SEP	#20H
;					; yes !
		LDA	<KNCRYP
		CMP	#80H
		BEQ	S2CK10		; Ken cut ?
;					; yes ! nigeru !
		LDA	ENZPSL,X
		ORA	ENDSPL,X
		BNE	S2CK10
;
		LDA	<PLBGCKF
		CMP	ENKAIF,X
		BNE	S2CK10
;
		JSR	EPXYCK
		STY	<WORK0
;
		LDA	DASHFG
		BNE	S2CK09
;
		LDA	<KENMD
		CMP	#90H
		BCS	S2CK0A
		CMP	#09H
		BPL	S2CK10
;
S2CK09		EQU	$
		LDA	<PLMKCH
		LSR	A
		TAY
		LDA	<WORK0
		CMP	S2JPMK,Y
		BEQ	S2CK10		;Back player ?
;					; not !
S2CK0A		EQU	$
		LDA	<WORK0
		STA	ENMUKI,X
;
		LDA	#20H
		JSL	>PSERC2L
;
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
;
		LDA	<WORK0
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
;
		LDA	#20H
		STA	ENZSPD,X
;
;;		JSL	>SDLRCE
;;		ORA	#20H
;;		STA	SOUND2	;(S)
		LDA	#13H
		JSL	>SDLRE3	;(S)
;
		INC	ENZPSL,X
;
S2CK10		EQU	$
		MEM8
		SEP	#20H
;
		LDA	ENZPSL,X
		BEQ	S2CK30
;
		LDY	ENMUKI,X
		LDA	S2JPCP,Y
		STA	ENCHPT,X
		JSL	>SKEL2CS
		JSR	ENSTCK
;
		LDA	ENHNFG,X
		BEQ	S2CK11
;
		STZ	ENZSPD,X
;
S2CK11		EQU	$
		JSR	ENHNSB
;
		JSR	CREKEK
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
;;		LDA	ENCBFG,X
;
		PHA
		AND	#00000011B
		BEQ	S2CK16
;
		STZ	ENXSPD,X
S2CK16		EQU	$
		PLA
		AND	#00001100B
		BEQ	S2CK18
;
		STZ	ENYSPD,X
;;		JSR	ENSDCL
S2CK18		EQU	$
		JSR	ENMVCL2
		LDA	ENZSPD,X		
		SEC
		SBC	#02H
		STA	ENZSPD,X
;		
		LDA	ENZPSL,X
		DEC	A
		BPL	S2CK28
;
		STZ	ENZPSL,X
;
		JSR	ENSDCL
;
;;		JSL	>SDLRCE
;;		ORA	#21H
;;		STA	SOUND2	;(S)
		LDA	#21H
		JSL	>SDLRE2	;(S)
;
		LDA	HEMODE,X
		BEQ	S2CK28		; Hone shot ?
;					; yes !
		LDA	#10H
		STA	ENTUTM,X
;;		STA	ENTIM3,X
		STZ	ENCONT,X
S2CK28		EQU	$
		RTS
;===========================================
S2CK30		EQU	$
;
ZKMOVE		EQU	$
TEKI0MV		EQU	$
TEKI1MV		EQU	$
		LDA	ENWRK1,X
		BEQ	TK1M01
;- - -  Tama - - - 
;;;		JSL	>EN1CSTL
		JSR	TKTAMCS
;
		JSR	ENSTCK
;
		LDA	<FRCNT
		LSR	A
		AND	#01H
		STA	ENCHPT,X
;
		JSR	CRENPL
;
		JSR	ENMVCL
;
;;		JSL	>ENBGCKL
;
		JSR	ENBGCK
;;		LDA	ENCBFG,X
		BEQ	TTM010
;
		STZ	ENMODE,X
;
		JSL	>EFLSST2
TTM010		EQU	$
		RTS
;- - -  Master - - - 
TK1M01		EQU	$
		LDA	ENTUTM,X
;;		LDA	ENTIM3,X
		BEQ	TK1M02
;
		PHA
		STZ	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
;
		JSR	ENSDCL
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;
		PLA
;
TK1M02		EQU	$
		CMP	#01H
		BNE	S2CK38
;
		JSR	HONEST
		LDA	#01H
		STA	ENCONT,X
S2CK38		EQU	$
		LDA	ENCONT,X
		AND	#00000001B
		ASL	A
		ASL	A
		ADC	ENMUKI,X
		TAY
		LDA	TKCHPT,Y
		STA	ENCHPT,X		
;
		LDA	ENMYNO,X
		CMP	#SKEL2
		BNE	ZM0010
;
		JSL	>SKEL2CS
;
		JSR	ENSTCK
;
		BRA	ZM0020
;
;;		LDA	ENTIM2,X
;;		BEQ	ZM0020
;;		CMP	#01H
;;		BNE	S2M110		; Kemuri end ?
;;;					; yes ! use no revise !
;;		LDA	#00000011B
;;		STA	ENMOD0,X
;;S2M110		EQU	$
;;		RTS
;========================================
ZM0010		EQU	$
		JSL	>TEKI0CS
;
		JSR	ENSTCK
ZM0020		EQU	$
;
		JSR	ENHNSB
		JSR	CREKEK
;
		JSR	ENMVCL
		JSR	ENBGCK
;;		JSL	>ENBGCKL
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	TKSTOP
		WORD	TKWALK
		WORD	TKSHOT
;================================
TKSTOP		EQU	$
;- - - stop - - -
		LDA	ENTIM0,X
		BNE	ZKS010
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	TKWKTM,Y
		STA	ENTIM0,X
		INC	ENSTAT,X
;
ZKSDST		EQU	$
		LDA	ENKBMK,X
		STA	ENMUKI,X
;
		TAY
		LDA	TKXSDT,Y
		STA	ENXSPD,X
		LDA	TKYSDT,Y
		STA	ENYSPD,X
ZKS010		EQU	$
		RTS
;============================================
ZKNXMK		EQU	$
ASNXMK		EQU	$
HBNXMK		EQU	$
		HEX	2,3,2,3,0,1,0,1
;
TKWALK		EQU	$
		LDA	#10H
;
		LDY	ENCBFG,X
		BNE	ZKW008
;
		LDA	ENTIM0,X
		BNE	ZKW010
;
		LDA	ENMYNO,X
		CMP	#TEKI1
		BNE	ZKW018		; Tama shot ?
;					; yes !
		JSR	EPXYCK
		TYA
		CMP	ENMUKI,X
		BNE	ZKW018		; muki->player ?
;					; yes !
		LDA	<PLBGCKF
		CMP	ENKAIF,X
		BNE	ZKW018
;
		INC	ENSTAT,X
		LDA	#30H
		STA	ENTIM0,X
		STA	ENTIM1,X	; Kuchi pause !
;
		BRA	ENSDCL
;- - - - - - - - - -
ZKW018		EQU	$
		LDA	#20H
ZKW008		EQU	$
		STA	ENTIM0,X
;
		JSL	>RNDSET
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	ZKNXMK,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	#18H
		STA	ENTIM0,X
ENSDCL		EQU	$
ZKW00A		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
ZKW00C		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - -
ZKW010		EQU	$
;;		DEC	ENWRK3,X
		DEC	ENCTCT,X
		BPL	ZKW020
;
		LDA	#0BH
;;		STA	ENWRK3,X
		STA	ENCTCT,X
;
		INC	ENCONT,X
ZKW020		EQU	$
		RTS
;=====================================
TKSHOT		EQU	$
		LDA	ENTIM0,X
		BNE	TKS010
;
;;		DEC	ENSTAT,X
		STZ	ENSTAT,X
;;		LDA	#20H
;;		STA	ENTIM0,X
;
;;		JMP	ZKSDST
		RTS
TKS010		EQU	$
		CMP	#18H
		BNE	TKS011
;
		JSL	>TKTAMST
TKS011		EQU	$
		RTS
;=========================================
TKTAMST		EQU	$
		PHB
		PHK
		PLB
;
		LDA	#TEKI0
		JSL	>ENIDSH
		BMI	TKS020
;
;;		JSL	>SDLRCE
;;		ORA	#05H
;;		STA	SOUND3	;(S)
		LDA	#05H
		JSL	>SDLRE3	;(S)
;
		JSL	>ENIDPS
;
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
		PHX
		LDA	ENMUKI,X
		TAX
;
		LDA	<WORK0
		CLC
		ADC	TKTSXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	TKTSXH,X
		STA	ENXPSH,Y
;
		LDA	<WORK2
		CLC
		ADC	TKTSYL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	TKTSYH,X
		STA	ENYPSH,Y
;
		LDA	TKSXSD,X
		STA	ENXSPD,Y
		LDA	TKSYSD,X
		STA	ENYSPD,Y
		LDA	ENMOD2,Y
		ORA	#01000000B
		STA	ENMOD2,Y
		LDA	#01000000B
		STA	ENMOD5,Y
		LDA	#00100001B
		STA	ENMOD0,Y
		STA	ENWRK1,Y
		LDA	#00000010B
		STA	ENCLOR,Y
                LDA     #14H
                STA     ENMOD3,Y
		STA	ENNOCR,Y
		LDA	#25H
		STA	ENMOD6,Y
;
		LDA	>ITMTBL7
		CMP	#03H
		BCC	TKS018		; Tate power 2,3 ?
;					; yes !
		LDA	#20H
		STA	ENMOD4,Y
TKS018		EQU	$
		PLX
TKS020		EQU	$
		PLB
		RTL
;- - - - - - - - -
TKSXSD		EQU	$
		BYTE	30H+9,0D0H-9  ;,00,00
TKSYSD		EQU	$
		BYTE	00,00,30H+9,0D0H-9
TKTSXL		EQU	$
		HEX	10,F8,04,04
TKTSXH		EQU	$
		HEX	00,FF,00,00
TKTSYL		EQU	$
		HEX	FE,FE,08,EC
TKTSYH		EQU	$
		HEX	FF,FF,00,FF
;====================================================================
HONEST		EQU	$
		LDA	#SKEL2
		JSL	>ENIDSH
		BMI	HNS010
;
		LDA	#01H
		STA	ENWRK0,Y
;
		JSL	>ENIDPS
;
		PHX
		TYX
		LDA	#20H
		JSL	>PSERCHL
		LDA	#00100001B
		STA	ENMOD0,X
		STA	ENNOCR,X
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X
		LDA	#01001000B
		STA	ENMOD5,X
		LDA	#10H
		STA	ENTIM0,X
		LDA	#14H
		STA	ENMOD3,X
		LDA	#07H
		STA	ENCLOR,X
		LDA	#00100000B
		STA	ENMOD6,X
		PLX
;
;;		JSL	>SDLRCE
;;		ORA	#02H
;;		STA	SOUND2	;(S)
		LDA	#02H
		JSL	>SDLRE2	;(S)
HNS010		EQU	$
		RTS
;====================================================================
TKTAMCD		EQU	$
;R
		WORD	00000H,00000H
		HEX	C3,00,00,00
		WORD	0FFF8H,0000H
		HEX	C2,00,00,00
		WORD	00000H,00000H
		HEX	C3,80,00,00
		WORD	0FFF8H,0000H
		HEX	C2,80,00,00
;L
		WORD	00000H,00000H
		HEX	C3,40,00,00
		WORD	00008H,00000H
		HEX	C2,40,00,00
		WORD	00000H,00000H
		HEX	C3,C0,00,00
		WORD	00008H,00000H
		HEX	C2,C0,00,00
;D
		WORD	00000H,00000H
		HEX	D4,00,00,00
		WORD	00000H,0FFF8H
		HEX	D3,00,00,00
		WORD	00000H,00000H
		HEX	D4,40,00,00
		WORD	00000H,0FFF8H
		HEX	D3,40,00,00
;U
		WORD	00000H,00000H
		HEX	D4,80,00,00
		WORD	00000H,00008H
		HEX	D3,80,00,00
		WORD	00000H,00000H
		HEX	D4,C0,00,00
		WORD	00000H,00008H
		HEX	D3,C0,00,00
;- - - - - - - - - - - - - - - - - - - - - -
TKTAMCS		EQU	$
		LDA	#00H
		XBA
		LDA	ENMUKI,X
		ASL	A
		CLC
		ADC	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ADC	#TKTAMCD  
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Ice Boss BG    		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ICEBGMV		EQU	$
		JSR	ENSTCK2
;
;;		JSL	>CRENPL2L
;;		BCC	ICB000
;
		JSR	EPXYCK
		LDA	<WORKF
		CLC
		ADC	#020H
		CMP	#040H
		BCS	ICB000
		LDA	<WORKE
		CLC
		ADC	#020H
		CMP	#040H
		BCS	ICB000
;
;;		MEM16
;;		REP	#00100000B
;;;
;;		LDA	PLSVX1
;;		STA	<PLXPS1
;;		LDA	PLSVY1
;;		STA	<PLYPS1
;;;
;;		MEM8
;;		SEP	#00100000B
		JSL	>PLOTCK		; Player revise
;
		JSL	>DASHON
;
ICB000		EQU	$
		JSL	>CRKNENL
;
		LDA	ENSTAT,X
		BNE	ICBG10
;
		LDA	ENMODE,X
		CMP	#EFAIL
		BNE	ICBG08
;
		LDA	#11000000B
		STA	ENMOD2,X
		INC	ENSTAT,X
		LDA	#EMOVE
		STA	ENMODE,X
		RTS
;============================================
ICBGXL		EQU	$
		HEX	01,FF
ICBGXH		EQU	$
		HEX	00,FF
;
ICBG08		EQU	$
		LDA	ENFLSH,X
		BEQ	ICBG0C
		AND	#02H
		LSR	A
		TAY
		LDA	ICBGXL,Y
		STA	BGMVC0
		LDA	ICBGXH,Y
		STA	BGMVC0+1
		LDA	#01H
		STA	B1MFLG
		RTS
;- - - - - - - - - - - -
ICBG0C		EQU	$
		STZ	B1MFLG
		RTS
;============================================================
ICBG10		EQU	$
		INC	ENSTAT,X
;
		CMP	#10H+1+1
		BEQ	ICBG20
;
		PHX
		JSL	>ICECGCNG
		PLX
		RTS
;===================================
ICBG20		EQU	$
		STZ	ENMODE,X
;
		LDA	#02H
		STA	ENSTAT+2	;  Boss Move start !
		LDA	#80H
		STA	ENTIM0+2
		RTS
;===============================================
ICTAMST		EQU	$
;;		LDA	<KEYA2
;;		AND	#10000000B
;;		BEQ	ITS010
;
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#07FH
		ORA	ENTIM1,X
		BNE	ITS010
;
		LDA	#ICTAM
		JSL	>ENIDSH
		BMI	ITS010
;
		LDA	<PLXPS1
		STA	ENXPSL,Y
		LDA	<PLXPS0
		STA	ENXPSH,Y
		LDA	<PLYPS1
		STA	ENYPSL,Y
		LDA	<PLYPS0
		STA	ENYPSH,Y
;
		LDA	#0E0H
		STA	ENZPSL,Y
		STA	ENWRK2,Y
;
		PHX
		TYX
;;		JSL	>SDLRCE
;;		ORA	#20H
;;		STA	SOUND2	;(S)
		LDA	#20H
		JSL	>SDLRE2	;(S)
		PLX
;
ITS010		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Ice Boss      		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;ICZCDT		EQU	$
;		HEX	2,1,0,0
;ICZCLD		EQU	$
;		HEX	1,0,0,0
;
ICBOSMV		EQU	$
;;		LDA	ENWRK1,X
;;		BEQ	ICB000
;;;====== Zanzoo ===============
;;		LDA	ENTIM0,X
;;		DEC	A
;;		BNE	ICZ010
;;;
;;		STZ	ENMODE,X
;;ICZ010		EQU	$
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		NOP
;;		NOP
;;		TAY
;;		LDA	ICZCDT,Y
;;		STA	ENCHPT,X
;;;
;;		LDA	ENCLOR,X
;;		AND	#11111110B
;;		ORA	ICZCLD,Y
;;		STA	ENCLOR,X
;;;
;;		JSL	>EN1CSTL
;;		RTS
;=============== BOSS MAIN ================
;;ICB000		EQU	$
		JSL	>ICBOSCS
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		CMP	#02H
		BCS	ICB010
;
		JSR	ICZNZST
;
		LDA	<FRCNT
		AND	#07H
		BNE	ICB010
;
		LDA	#02H
		STA	SOUND2	;(S)
ICB010		EQU	$
;
		JSR	ENHNSB
;
		DEC	ENCONT,X
		BPL	ICB006
;
		LDA	#0AH
		STA	ENCONT,X
;
		LDA	ENCHPT,X
		INC	A
		AND	#03H
		STA	ENCHPT,X
ICB006		EQU	$
;
		LDA	<FRCNT
		AND	#03H
		BNE	ICB008
;
		LDA	#1FH
		JSL	>PSERC2L
		JSL	>MKCK16
		STA	ENWRK0,X
ICB008		EQU	$
		JSR	ENMVCL
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	IBMOVE
		WORD	IBSTOP
		WORD	IBSTRT
		WORD	IBWAIT
;====================================
IBMOVE		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	IBM010
;
		INC	ENSTAT,X
		JSL	>RNDSET
		AND	#3FH
		ADC	#20H
		STA	ENTIM0,X
		RTS
IBM010		EQU	$
		LDA	ENXSPD,X
		CMP	ENZSPD,X
		BEQ	IBM020
		BPL	IBM018
		INC	ENXSPD,X
		BRA	IBM020
IBM018		EQU	$
		DEC	ENXSPD,X
IBM020		EQU	$
		LDA	ENYSPD,X
		CMP	ENZSDR,X
		BEQ	IBM030
		BPL	IBM028
		INC	ENYSPD,X
		BRA	IBM030
IBM028		EQU	$
		DEC	ENYSPD,X
;- - - - - - - - - - - - -
IBM030		EQU	$
;;		LDA	ENCBFG,X
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		AND	#03H
		BEQ	IBM040
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		LDA	ENZSPD,X
		EOR	#0FFH
		INC	A
		STA	ENZSPD,X
IBM040		EQU	$
		LDA	ENCBFG,X
		AND	#0CH
		BEQ	IBM050
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		LDA	ENZSDR,X
		EOR	#0FFH
		INC	A
		STA	ENZSDR,X
IBM050		EQU	$
		RTS
;====================================
IBMXSD		EQU	$
		HEX	10,10,F0,F0
IBMYSD		EQU	$
		HEX	F0,10,10,F0
;
IBSTOP		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	IBS010
		STZ	ENSTAT,X
		JSL	>RNDSET
		AND	#3FH
		ADC	#60H
		STA	ENTIM0,X
		JSL	>RNDSET
		PHA
		AND	#03H
		TAY
		LDA	IBMXSD,Y
		STA	ENZSPD,X
		LDA	IBMYSD,Y
		STA	ENZSDR,X
		PLA
		AND	#00011100B
		BNE	IBS008		; Player serch time ?
;					; yes !
		LDA	#18H
		JSL	>PSERC2L
		LDA	<WORK0
		STA	ENZSDR,X
		LDA	<WORK1
		STA	ENZSPD,X
IBS008		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IBS010		EQU	$
		LDA	ENXSPD,X
		BEQ	IBS020
		BPL	IBS018
		INC	ENXSPD,X
		BRA	IBS020
IBS018		EQU	$
		DEC	ENXSPD,X
IBS020		EQU	$
		LDA	ENYSPD,X
		BEQ	IBS030
		BPL	IBS028
		INC	ENYSPD,X
		BRA	IBS030
IBS028		EQU	$
		DEC	ENYSPD,X
IBS030		EQU	$
		JMP	IBM030
;====================================
IBSTXS		EQU	$
		HEX	20,E0,00
IBSTYS		EQU	$
		HEX	E0,E0,30
;
IBSTRT		EQU	$
		LDA	ENTIM0,X
		CMP	#01H
		BNE	IBW0A0
;
		STZ	ENMODE,X
		STZ	ENMODE+1,X
		STZ	ENMODE+2,X
;
		LDA	#02H
		STA	ENHELP
IBW010		EQU	$	
		LDA	#ICBOS
		LDY	#04H
		JSL	>ENIDSH2
		BMI	IBW0A0
;
		JSL	>ENIDPS
;
		PHX
		LDX	ENHELP
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;
		LDA	IBSTXS,X
		STA	ENZSPD,Y
		LDA	IBSTYS,X
		STA	ENZSDR,Y
;
		LDA	#20H
		STA	ENTIM0,Y
		PLX
		DEC	ENHELP
		BPL	IBW010
		RTS
;
IBW0A0		EQU	$
		LDA	ENFLSH,X
		ORA	#11100000B
		STA	ENFLSH,X		
		RTS
;==================================================
IBWAIT		EQU	$
;;		LDA	#02H
;;		STA	ENSTAT,X
;;		LDA	#80H
;;		STA	ENTIM0,X
		RTS
;==================================================
ICZXAL		EQU	$
		HEX	F8,FA,FC,FE,00,02,04,06
ICZXAH		EQU	$
		HEX	FF,FF,FF,FF,00,00,00,00
;- - - - - - - - - - - - -
ICZNZST		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
;;		ORA	<GAMEMD
		BNE	IZS090
;
		PHX
		LDX	#E2HF-1
ICZS10		EQU	$
		LDA	>E2MODE,X
		BEQ	ICZS20
		DEX
		BPL	ICZS10
		PLX
		RTS
;- - - - - - - - - - - - - - - - - - -
ICZS20		EQU	$		
		LDA	#07H
		STA	>E2MODE,X
		STA	EN2FLG
;			
		LDA	#1FH
		STA	>E2TIM0,X
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	ENXP2L
		CLC
		ADC	ICZXAL,Y
		STA	>E2XPSL,X
		LDA	ENXP2H
		ADC	ICZXAH,Y
		STA	>E2XPSH,X
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	ENYP2L
		CLC
		ADC	ICZXAL,Y
		PHP
		CLC
		ADC	#10H
		STA	>E2YPSL,X
		LDA	ENYP2H
		ADC	#00H
		PLP
		ADC	ICZXAH,Y
		STA	>E2YPSH,X
;
		LDA	#00H
		STA	>E2WRK0,X
;
		PLX
IZS090		EQU	$
		RTS
;;;----------------------------------
;;		LDA	#ICBOS
;;		JSL	>ENIDSH
;;		BMI	IZS090
;;;
;;		LDA	#01H
;;		STA	ENWRK1,Y
;;		STA	ENNOCR,Y
;;;
;;		LDA	#00H
;;		STA	ENMOD0,Y
;;;
;;		LDA	#3FH
;;		STA	ENTIM0,Y
;;;
;;		PHX
;;		JSL	>RNDSET
;;		AND	#07H
;;		TAX
;;		LDA	<WORK0
;;		CLC
;;		ADC	ICZXAL,X
;;		STA	ENXPSL,Y
;;		LDA	<WORK1
;;		ADC	ICZXAH,X
;;		STA	ENXPSH,Y
;;;
;;		JSL	>RNDSET
;;		AND	#07H
;;		TAX
;;		LDA	<WORK2
;;		CLC
;;		ADC	ICZXAL,X
;;		STA	ENYPSL,Y
;;		LDA	<WORK3
;;		ADC	ICZXAH,X
;;		STA	ENYPSH,Y
;;		PLX
;;;
;;IZS090		EQU	$
;;		RTS
;==================================================
;- - TEST ! - - 
;;		LDA	<KEYA2
;;		AND	#00001100B
;;		BEQ	ICB010
;;;
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		AND	#03H
;;		STA	ENCHPT,X
;;ICB010		EQU	$
;;		LDA	<KEYA2
;;		AND	#00000011B
;;		BEQ	ICB020
;;;
;;		INC	ENWRK0,X
;;		LDA	ENWRK0,X
;;		CMP	#05H
;;		BNE	ICB020
;;		STZ	ENWRK0,X
;;ICB020		EQU	$
;;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Ice Tama      		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
ICTAMMV		EQU	$
		LDA	ENWRK2,X
		BNE	ICTM00
;
		JSR	ENSTCK
;
		LDA	ENMODE+2
		CMP	#EMOVE
		BCS	ICSS
		LDA	ENMODE+3
		CMP	#EMOVE
		BCS	ICSS
		LDA	ENMODE+4
		CMP	#EMOVE
		BCS	ICSS
		STZ	ENMODE,X
ICSS		EQU	$
		JMP	ICTAMST
;------------------------------------------------
ICTM00		EQU	$
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	#30H
		STA	ENFLCL,X
                JSL     >EN1CSTL
;
		LDA	ENSTAT,X
		BNE	ITM002
;
                LDA     ENMOD2,X
                EOR     #00010000B
                STA     ENMOD2,X
ITM002		EQU	$
                JSR     ENSTCK
;
		LDA	ENTIM0,X
		BEQ	ITM005
;
		CMP	#01H
		BNE	ITM003
;
		STZ	ENMODE,X
ITM003		EQU	$
		LSR	A
		LSR	A
		LSR	A
		INC	A
		INC	A
		STA	ENCHPT,X
		RTS
;-------------------------------------
ITM005		EQU	$
                JSR     ENMVCL
;
		LDA	ENSTAT,X		
		BEQ	ITM065
;
                JSR     CRENPL
;
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BNE	ITM080
;
ITM065		EQU	$
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	ITM008
		SEC
		SBC	#03H
		STA	ENZSPD,X
ITM008		EQU	$
		PLA
		EOR	ENZPSL,X
		BPL	ITM090
;
		LDA	ENZPSL,X
		BPL	ITM090
;
		STZ	ENZPSL,X
;
		LDA	ENSTAT,X
		BNE	ITM080
;
		STZ	ENMODE,X		
;
		JSR	ITMBRK
		RTS
ITM080		EQU	$
;;		STZ	ENMODE,X
		LDA	#0FH
		STA	ENTIM0,X
;
		LDA	#04H
		STA	ENCLOR,X
;
		LDA	SOUND2
		BNE	ITM090
;
;;		JSL	>SDLRCE
;;		ORA	#1EH
;;		STA	SOUND2	;(S)
		LDA	#1EH
		JSL	>SDLRE2	;(S)
;
		LDA	#03H
		STA	ENCHPT,X
ITM090		EQU	$
		RTS
;==========================================
ITMBXS		EQU	$
		HEX	00,20,00,E0
		HEX	18,18,E8,E8
ITMBYS		EQU	$
		HEX	E0,00,20,00
		HEX	E8,18,E8,18
;
ITMBRK		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#1FH
;;		STA	SOUND2	;(S)
		LDA	#1FH
		JSL	>SDLRE2	;(S)
;
		JSL	>RNDSET	
		AND	#04H
		STA	<WORKD
;
		LDA	#03H
		STA	ENHELP

ITMB10		EQU	$
		LDA	#ICTAM
		JSL	>ENIDSH
		BMI	ITMB90
;
		JSL	>ENIDPS
		LDA	#01H
		STA	ENSTAT,Y
		STA	ENCHPT,Y
		STA	ENWRK2,Y
;
		LDA	#020H
		STA	ENZSPD,Y
;
		PHX
		LDA	ENHELP
		ORA	<WORKD
		TAX
		LDA	ITMBXS,X
		STA	ENXSPD,Y
		LDA	ITMBYS,X
		STA	ENYSPD,Y
		PLX
;
		LDA	#1CH
		STA	ENMOD3,Y
;
ITMB90		EQU	$
		DEC	ENHELP
		BPL	ITMB10
		RTS		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Ice man      		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ICMANMV		EQU	$
		JSL	>ICMANCS
;
		LDA	ENMODE,X
		CMP	#EMOVE
		BEQ	IC0000
;
		LDA	#03H
		STA	ENSTAT,X
		LDA	#1FH
		STA	ENTIM0,X
		STA	ENNOCR,X
		LDA	#EMOVE
		STA	ENMODE,X
		STZ	ENFLSH,X
;
IC0000		EQU	$
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		CMP	#03H
		BEQ	IC0020
;
		JSR	ENHNSB
;
IC0020		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	ICWAIT
		WORD	ICWAIT2
		WORD	ICMOVE
		WORD	ICFAIL
;=======================================
ICWAIT		EQU	$
		INC	ENNOCR,X
		JSR	EPXCHK
		LDA	<WORKF
		CLC
		ADC	#10H
		CMP	#20H
		BCS	ICW010
;
		INC	ENSTAT,X
;
		LDA	#20H
		STA	ENTIM0,X
ICW010		EQU	$
		RTS
;
;=======================================
;
ICWAIT2		EQU	$
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	ICW210
;
		INC	ENSTAT,X
;
		LDA	ENXPSL,X
		SEC
		SBC	#05H
		STA	<WORK0
		LDA	ENXPSH,X
		SBC	#00H
		STA	<WORK1
		LDA	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
		LDY	#08H
		JSL	>TGBLKWT	; BG set !
		LDA	#60H
		STA	ENTIM1,X
		LDA	#02H
		STA	ENMUKI,X
		LDA	#50H
		STA	ENTIM0,X
		RTS
ICW210		EQU	$
		AND	#01H
		TAY
		LDA	ICWXSD,Y
		STA	ENXSPD,X
		JSR	ENXCLC 
		RTS
;=======================================
ICMXSD		EQU	$
		HEX	08,F8    ;,00,00
ICMYSD		EQU	$
		HEX	00,00,12,EE
ICPTDT		EQU	$
		HEX	1,2,1,3
;- - -  - -
ICSTXL		EQU	$
		HEX	FC,FE,00,02,04,06,08,0A
ICSTXH		EQU	$
		HEX	FF,FF,00,00,00,00,00,00
;
ICMOVE		EQU	$
		JSR	CRENPL
		JSL	>CRKNENL
		BCC	ICM000
;
		STZ	ENFLSH,X
ICM000		EQU	$
		LDA	ENTIM1,X
		BEQ	ICM008
;
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	ICM008
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	ICSTXL,Y
		STA	<WORK0
		LDA	ICSTXH,Y
		STA	<WORK1
		LDA	#0FCH
		STA	<WORK2
		LDA	#0FFH
		STA	<WORK3
;
		JSL	>ICEFLST		; Kira kira set !
;
ICM008		EQU	$
		LDA	ENTIM0,X
		BNE	ICM010
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
ICM010		EQU	$
		LDY	ENMUKI,X
		LDA	ICMXSD,Y
		STA	ENXSPD,X
		LDA	ICMYSD,Y
		STA	ENYSPD,X
;
		LDA	ENCBFG,X
		AND	#0FH
		BNE	ICM011
;
		JSR	ENMVCL
ICM011		EQU	$
;;		JSL	>ENBGCKL
		JSR	ENBGCK
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	ICPTDT,Y
		STA	ENCHPT,X
		RTS
;=======================================
ICFPTD		EQU	$
		HEX	6,5,4,7
;
ICFAIL		EQU	$
		LDA	ENTIM0,X
		BNE	ICF010
;
		PHA
		JSL	>ENBTON
		STZ	ENMODE,X
		PLA
ICF010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	ICFPTD,Y
		STA	ENCHPT,X
		RTS
;
;
;;		LDA	<KEYA2
;;		AND	#0CH
;;		BEQ	IC010
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#08H
;;		BNE	IC010
;;		STZ	ENCHPT,X
;;IC010		EQU	$
;;;
;;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Doobotsu     		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DACHOMV		EQU	$
		JSR	DACHOCS
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	DCSTOP
		WORD	DCGO
;----------------------------------------
DCSTOP		EQU	$
		LDY	#00H
		LDA	<FRCNT
		AND	#00011000B
		BEQ	DCS010
		LDY	#03H
DCS010		EQU	$
		TYA
		STA	ENCHPT,X
;
;;		LDA	<KEYA2
;;		AND	#80H
		LDA	CALFLG
		BEQ	DCS020
;
		INC	ENSTAT,X
		LDA	#0F8H
		STA	ENYSPD,X
		LDA	#0F0H
		STA	ENXSPD,X
DCS020		EQU	$
;
		RTS
;----------------------------------------
DCGPTD		EQU	$
		HEX	0,1,0,2
;
DCGO		EQU	$
		JSR	ENMVCL2
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	DCG010
;
		LDA	#020H
		STA	ENZSPD,X
		STZ	ENZPSL,X
;
		STZ	ENCONT,X
		STZ	ENWRK0,X
DCG010		EQU	$		
		INC	ENCONT,X		
		LDA	ENCONT,X
		AND	#07H
		BNE	DCG020
;
		LDA	ENWRK0,X
		CMP	#03H
		BEQ	DCG020
;
		INC	ENWRK0,X
DCG020		EQU	$
		LDY	ENWRK0,X
		LDA	DCGPTD,Y
		STA	ENCHPT,X
		RTS		
;
;
;
;
;;----------------------------------------
DACHOCD		EQU	$
		WORD	0FFFCH,0FFF8H
		HEX	80,00,00,02
		WORD	00004H,0FFF8H
		HEX	81,00,00,02
		WORD	0FFFCH,00008H
		HEX	A3,00,00,02
		WORD	00004H,00008H
		HEX	A4,00,00,02
;
		WORD	0FFFCH,0FFF8H
		HEX	80,00,00,02
		WORD	00004H,0FFF8H
		HEX	81,00,00,02
		WORD	0FFFCH,00008H
		HEX	A0,00,00,02
		WORD	00004H,00008H
		HEX	A1,00,00,02
;
		WORD	0FFFCH,0FFF8H
		HEX	80,00,00,02
		WORD	00004H,0FFF8H
		HEX	81,00,00,02
		WORD	0FFFCH,00008H
		HEX	83,00,00,02
		WORD	00004H,00008H
		HEX	84,00,00,02
;
		WORD	0FFFCH,0FFF9H
		HEX	80,00,00,02
		WORD	00004H,0FFF9H
		HEX	81,00,00,02
		WORD	0FFFCH,00009H
		HEX	A3,00,00,02
		WORD	00004H,00009H
		HEX	A4,00,00,02
;
DACHOCS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ASL	A
		ADC	#DACHOCD  
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#04H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		LDA	#12H
		JSL	>SADWS2L		
		RTS
;==============================================
USCPCL		EQU	$
OMEATD		EQU	$
		HEX	40,00
;;		HEX	40,00
;
USAGIMV		EQU	$
		LDY	ENMUKI,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	USCPCL,Y
		STA	ENCLOR,X
		JSL	>EN1CSTL
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	USSTOP
		WORD	USGO
;========================================
USSTOP		EQU	$
		LDA	#03H
		STA	ENCHPT,X
;
		LDA	CALFLG
		BEQ	USS020
;
		INC	ENSTAT,X
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
		TAY
		LDA	OMGOXS,Y
		STA	ENXSPD,X
;
		LDA	#0F8H
		STA	ENYSPD,X
USS020		EQU	$		
		RTS
;-------------------------------------------
USGPTD		EQU	$
		HEX	0,1,2
;
USGO		EQU	$
		JSR	ENMVCL2
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
		DEC	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	USG010
;
		LDA	#018H
		STA	ENZSPD,X
		STZ	ENZPSL,X
;
		STZ	ENCONT,X
		STZ	ENWRK0,X
USG010		EQU	$		
		INC	ENCONT,X		
		LDA	ENCONT,X
		AND	#03H
		BNE	USG020
;
		LDA	ENWRK0,X
		CMP	#02H
		BEQ	USG020
;
		INC	ENWRK0,X
USG020		EQU	$
		LDY	ENWRK0,X
		LDA	USGPTD,Y
		STA	ENCHPT,X
		RTS		
;==============================================
OOOMUMV		EQU	$
		LDA	ENCHPT,X
		CMP	#03H
		BNE	OMM010		;With eye ?
;					; yes !
		JSR	OMEYEST
;
OMM010		EQU	$
		LDY	ENMUKI,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	USCPCL,Y
		STA	ENCLOR,X
		MEM16
		REP	#20H
		LDA	<OAMADR
		CLC
		ADC	#0004H
		STA	<OAMADR
		INC	<OSBADR
		MEM8
		SEP	#20H
		DEC	ENMOD0,X
		JSL	>EN1CSTL
		INC	ENMOD0,X
;
		JSR	ENMVCL2
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	OMSTOP
		WORD	OMUP
		WORD	OMDOWN
;- - - - - - - - - - - - - - - - - -
;
OMSTOP		EQU	$
		LDY	#00H
		LDA	<FRCNT
		AND	#00011000B
		BNE	OMS010
		LDY	#03H
OMS010		EQU	$
		TYA
		STA	ENCHPT,X
;
		LDA	CALFLG
		BEQ	OMS020
;
		INC	ENSTAT,X
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
		TAY
		LDA	OMGOXS,Y
		STA	ENXSPD,X
;
		LDA	#020H
		STA	ENTIM0,X
		LDA	#10H
		STA	ENZSPD,X		
		LDA	#0F8H
		STA	ENYSPD,X
OMS020		EQU	$		
		RTS
;-------------------------------------
OMUP		EQU	$
		LDA	ENTIM0,X
		BNE	TRU010
;
		LDA	ENZSPD,X
		CLC
		ADC	#02H
		STA	ENZSPD,X	
		CMP	#10H
		BMI	TRU010
;
		INC	ENSTAT,X
TRU010		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
;;		LSR	A
		LSR	A
		AND	#01H
		INC	A
		STA	ENCHPT,X
		RTS
;-------------------------------------
OMDOWN		EQU	$
		LDA	#01H
		STA	ENCHPT,X
;
		LDA	ENZSPD,X
		SEC
		SBC	#01H
		STA	ENZSPD,X
		CMP	#0F1H
		BPL	TRD020
;		
		DEC	ENSTAT,X
TRD020		EQU	$
		RTS
;=====================
OMEXAD		EQU	$
		HEX	08,00
;
OMEYEST		EQU	$
		JSR	OAMCHK
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	<WORK0
		CLC
		ADC	OMEXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		INY
		STA	(<OAMADR),Y
		LDA	#0AEH
		INY
		STA	(<OAMADR),Y		
		LDA	<WORK5
		ORA	OMEATD,X
		INY
		STA	(<OAMADR),Y
		PLX
;
		LDY	#00H
		LDA	#00H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Kuroi yatsu    		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
KURORMV		EQU	$
KURODMV		EQU	$
		LDA	ENWRK3,X
		BNE	KROF0
;
		JMP	KURO0	; Makkuro kurosuke ?
;
KROF0		EQU	$	; yes !
		LDA	ENWRK2,X
		BNE	KR0F8
;
		INC	ENWRK2,X
		JSR	EPYCHK
		CPY	#00H
		BEQ	KR0F8		; Player lower ?
;					; no uper !
		STZ	ENMODE,X
		RTS
;
KR0F8		EQU	$
		JSL	>EN1CSSL
		JSR	ENSTCK
		JSR	CREKEK
;;		JSL	>CRENPLL
;
		INC	ENCONT,X
;;		TXA
;;		EOR	<FRCNT
		LDA	ENCONT,X
		LSR	A
		AND	#01H
		STA	ENCHPT,X
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
;		NOP
;		NOP
;		NOP
		AND	#01H
		TAY
		LDA	KSMXSD,Y
		STA	ENXSPD,X
;
		JSR	ENMVCL
;
		LDA	ENTIM0,X
		BNE	KSM010
;
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	KSM010
;
		STZ	ENMODE,X
KSM010		EQU	$
		LDA	ENCONT,X
		AND	#03H
		BNE	KSM090
;
		PHX
		TXY
		LDX	#E2NO-1
KZS010		EQU	$
		LDA	>E2MODE,X
		BEQ	KZS020
		DEX
		BPL	KZS010
		PLX
KSM090		EQU	$
		RTS
;- - - - - - - - - - - -- - - - - - - - - -
KZS020		EQU	$
		LDA	#06H
		STA	>E2MODE,X
		STA	EN2FLG
;
		LDA	ENXPSL,Y
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		STA	>E2XPSH,X
		LDA	ENYPSL,Y
		CLC
		ADC	#0010H
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		ADC	#00H
		STA	>E2YPSH,X
;
		LDA	#0AH
		STA	>E2TIM0,X
;
		TYA	
		STA	>E2STAT,X	
;
		LDA	ENKAIF,Y
		STA	>E2WRK0,X
;
		PLX
		RTS
;--------------------------------------------------------
KURO0		EQU	$
;;		JSL	>OAMCHKL
;
;;		LDA	ENSTAT,X
;;		CMP	#02H
;;		BCC	KRO000
;
		JSL	>KURORCS
;;KRO000		EQU	$
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KRSET
		WORD	KRWAIT
		WORD	KREYE
		WORD	KRGO
;===================================================
KRSET		EQU	$
		INC	ENSTAT,X
		LDA	#80H
		STA	ENTIM0,X
		LDA	#0FFH
		STA	ENCHPT,X
		RTS
;===================================================
KRWAIT		EQU	$
		LDA	ENTIM0,X
		BNE	KRW010
;
		INC	ENSTAT,X
;
		LDA	#20H+17H
		STA	ENTIM0,X
KRW010		EQU	$
		RTS
;===================================================
KREYPT		EQU	$
		HEX	5,4,3,2,1,0
KREYAD		EQU	$
		HEX	06,06,00,00
KRGXSD		EQU	$
		HEX	20,E0  ;,00,00
KRGYSD		EQU	$
		HEX	00,00,20,E0
;- - - - - - - - - - - - - - - - - -
KREYE		EQU	$
		LDA	ENTIM0,X
		BNE	KRE010
;
		PHA
		INC	ENSTAT,X
		LDY	ENMUKI,X
		LDA	KRGXSD,Y
		STA	ENXSPD,X
		LDA	KRGYSD,Y
		STA	ENYSPD,X
		LDA	#20H
		STA	ENTIM0,X
		PLA
KRE010		EQU	$
		CMP	#20H
		BCC	KRE011
		SBC	#20H
		LSR	A
		LSR	A
		TAY
		LDA	KREYPT,Y
		LDY	ENMUKI,X
		CLC
		ADC	KREYAD,Y
		STA	ENCHPT,X
		RTS
;
KRE011		EQU	$
		LDA	#0FFH
		STA	ENCHPT,X
		RTS
;===================================================
KRGPAD		EQU	$
		HEX	12,E,C,10
;
KRGO		EQU	$
		JSR	CREKEK
;
		JSR	ENMVCL
		LDA	<FRCNT
		LSR	A
		AND	#01H
		LDY	ENMUKI,X
		CLC
		ADC	KRGPAD,Y
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	KRG010		; First start ?
;					; no !
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
;;		AND	#0FH
		BEQ	KRG010
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
		STZ	ENSTAT,X
KRG010		EQU	$
		RTS
;===================================================
;===================================================
;===================================================
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	KRM010
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#14H
;;		BNE	KRM010
;;		STZ	ENCHPT,X
;;KRM010		EQU	$
;;		LDA	<KEYA2
;;		AND	#04H
;;		BEQ	KRM020
;;		DEC	ENCHPT,X
;;		BPL	KRM020
;;		LDA	#0DH
;;		STA	ENCHPT,X
;;KRM020		EQU	$
;;		RTS
		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Magician    		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MGTCLD		EQU	$
		HEX	03,43,C3,83
;
MAGICMV		EQU	$
		LDA	ENWRK2,X
		BEQ	MGM000
;- - - Tama move - - - - 
;;		LDA	ENCONT,X
;;		LSR	A
;;		AND	#03H
;;		TAY
;;		LDA	ENCLOR,X
;;		AND	#00110001B
;;		ORA	MGTCLD,Y
;;		STA	ENCLOR,X
;;;
;;		JSL	>EN1CSTL
		JSL	>MGTAMCS
;
		JSR	ENSTCK
;
		LDA	ENCLOR,X
		EOR	#00000110B
		STA	ENCLOR,X
;
		INC	ENCONT,X
;
		LDA	ENSTAT,X
		BNE	MGB010
;
		JSR	CRENPL
MGB010		EQU	$
;
		JSR	ENMVCL
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	MTM010
;
		STZ	ENMODE,X
MTM010		EQU	$
		RTS
;============================================
MGM000		EQU	$
		LDA	ENSTAT,X
		BEQ	MGM00C
;
		AND	#01H
		BEQ	MGM010
;
		LDA	ENTIM0,X
		AND	#01H
		BEQ	MGM010
;
MGM00C		EQU	$
		JSL	>OAMCHKL
		BRA	MGM020
;
MGM010		EQU	$
		JSL	>MAGICCS
MGM020		EQU	$
;
		JSR	ENSTCK
		JSR	ENHNSB
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MGSET
		WORD	MGUP
		WORD	MGSHOT
		WORD	MGDOWN
;============================================
MGSMKD		EQU	$
		HEX	4,2,0,6
;
MGSET		EQU	$
		LDA	ENTIM0,X
		BNE	MGST20
;
		LDA	#01H
		STA	ENXSPD,X
		STA	ENYSPD,X
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BNE	MGST10
;
		INC	ENSTAT,X
		LDA	#3FH
		STA	ENTIM0,X		
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		LDA	MGSMKD,Y
		STA	ENCHPT,X
		RTS
;
MGST10		EQU	$
		STZ	ENMODE,X
MGST20		EQU	$
		RTS
;============================================
MGUP		EQU	$
		LDA	ENTIM0,X
		BNE	MGU010
;
		INC	ENSTAT,X
;
;;		LDA	#7FH
		LDA	#3FH
		STA	ENTIM0,X
MGU010		EQU	$
		RTS
;============================================
MGSPTD		EQU	$
		HEX	0,1,1,1,1,1,1,0
MGSPAD		EQU	$
		HEX	04,02,00,06
;;MGSTPD		EQU	$
;;		HEX	0,0,0,0,0,0,0,0
;;		HEX	A,9,8,7,A,9,8,7
;;		HEX	A,9,8,7,A,9,8,7
;;		HEX	A,9,8,7,A,9,8,7
;;		HEX	6,5,4,3,6,5,4,3
;;		HEX	6,5,4,3,6,5,4,3
;;		HEX	2,1,2,1,2,1,2,1
;;		HEX	0,0,0,0,0,0,0,0
;;MGSTAD		EQU	$
;;		HEX	0C,0A,00,00
;
MGSHOT		EQU	$
		STZ	ENNOCR,X
;
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	MGS010
;
		INC	ENSTAT,X
		LDA	#3FH
		STA	ENTIM0,X
		RTS
MGS010		EQU	$
		CMP	#020H
		BNE	MGS011
		PHA
		JSR	MGTAMST
		PLA
MGS011		EQU	$
;;;		LSR	A
;;;		PHA
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	MGSPTD,Y
		LDY	ENMUKI,X
		CLC
		ADC	MGSPAD,Y
		STA	ENCHPT,X
;;;		PLY
;;;		LDA	MGSTPD,Y
;;;		BEQ	MGS050
;;;		CMP	#03H
;;;		BCS	MGS050
;;;		LDY	ENMUKI,X
;;;		CLC
;;;		ADC	MGSTAD,Y
;;;MGS050		EQU	$
;;;		STA	ENWRK0,X
		RTS
;============================================
MGDOWN		EQU	$
		LDA	ENTIM0,X
		BNE	MGD010
;
		LDA	ENWRK1,X
		BEQ	MGD008		; Flag set ?
;					; yes ! clear !
		STZ	ENMODE,X
MGD008		EQU	$
		STZ	ENSTAT,X	; next set !
		JSL	>RNDSET
		AND	#1FH
		ADC	#20H
		STA	ENTIM0,X
MGD010		EQU	$
		RTS
;============================================
MGTSXS		EQU	$
		HEX	20,E0   ;;,00,00
MGTSYS		EQU	$
		HEX	00,00,20,E0
;- - - - - - - - - - - - - - -  - - - -
MGTAMST		EQU	$
		LDA	#MAGIC
		JSL	>ENIDSH
		BMI	MTS010
;
		LDA	#36H	
		JSL	>SDLRE3	;(S)
;
		LDA	#01H
		STA	ENWRK2,Y
		STA	ENNOCR,Y
;
		LDA	<WORK0
		CLC
		ADC	#04H
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#00H
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#00H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#00H
		STA	ENYPSH,Y
;
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	MGTSXS,X
		STA	ENXSPD,Y
		LDA	MGTSYS,X
		STA	ENYSPD,Y
;
		LDA	#01001000B
		STA	ENMOD5,Y
;
		LDA	#00000010B
		STA	ENCLOR,Y
;
		LDA     >ITMTBL7
		TAX
		LDA	#00000000B
		CPX	#03H
		BNE	MTS00C		;Tate maxmam powr ?
;					; yes ! hanekairi check !
		LDA	#00100000B
MTS00C		EQU	$
		STA	ENMOD4,Y
		PLX
;
		LDA	#14H
		STA	ENMOD3,Y
;
MTS010		EQU	$
		RTS
;============================================
;============================================
;============================================
;============================================
;============================================
;============================================
;;		LDA	<KEYA2
;;		AND	#0CH
;;		BEQ	MGM010
;;;
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#08H
;;		BNE	MGM010
;;		STZ	ENCHPT,X		
;;MGM010		EQU	$
;;		LDA	<KEYA2
;;		AND	#03H
;;		BEQ	MGM020
;;;
;;		INC	ENWRK0,X
;;		LDA	ENWRK0,X
;;		CMP	#0FH
;;		BNE	MGM020
;;		STZ	ENWRK0,X		
;;MGM020		EQU	$
;;		RTS
;==================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Water fish    		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FISH0MV		EQU	$
		LDA	ENSTAT,X
;;		CMP	#02H
		BNE	FS0001
;
		JSL	>OAMCHKL
		BRA	FS0000
FS0001		EQU	$
		JSR	FISH0CS
FS0000		EQU	$
;
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	FSSET
		WORD	FSWAIT
		WORD	FSUP
		WORD	FSJUMP
		WORD	FSCLER
;==================================================
FSSET		EQU	$
		LDA	ENTIM0,X
		BNE	FSS010
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#3FH
		ADC	#60H
		STA	ENTIM0,X
;
		LDA	ENWRK0,X
		STA	ENXPSL,X
		LDA	ENWRK1,X
		STA	ENXPSH,X
		LDA	ENWRK2,X
		STA	ENYPSL,X
		LDA	ENKBMK,X
		STA	ENYPSH,X
;
		LDA	#05H
		STA	ENCONT,X
		LDA	#08H
		STA	ENCHPT,X
;
;;		LDA	ENMOD2,X
;;		AND	#11101111B
;;		STA	ENMOD2,X
;
FSS010		EQU	$
		RTS
;==================================================
;;FSJXSD		EQU	$
;;		HEX	10,F0
;
FSWAIT		EQU	$
		LDA	ENTIM0,X
		BNE	FSW010
;
		LDA	#1FH
		STA	ENTIM0,X
;
		INC	ENSTAT,X
;
;;		LDA	ENMOD2,X
;;		ORA	#00010000B
;;		STA	ENMOD2,X
;
;;		JSR	EPXCHK
;;		TYA
;;		STA	ENMUKI,X		
;;;
;;		TAY
;;		LDA	FSJXSD,Y
;;		STA	ENXSPD,X
;;		RTS
FSW010		EQU	$
		DEC	ENCONT,X	
		BPL	FSW011
;
		LDA	#05H
		STA	ENCONT,X
;
		INC	ENCHPT,X
		LDA	ENCHPT,X
		AND	#03H
		CLC
		ADC	#08H
		STA	ENCHPT,X
FSW011		EQU	$
		RTS
;==================================================
FSUCHP		EQU	$
;;		HEX	4,3,2,8,7,6,1,0
		HEX	4,7,E,D,C,6,6,5
FSJPXS		EQU	$
		HEX	20,E0,20,E0
FSJPYS		EQU	$
		HEX	20,20,E0,E0
;
FSUP		EQU	$
		LDA	ENTIM0,X
		BNE	FSU008
;
		INC	ENSTAT,X
;
;;		STZ	ENNOCR,X
;
		JSR	EPYCHK
		TYA
		ASL	A
		STA	<WORK0
		JSR	EPXCHK
		TYA
		ORA	<WORK0
		TAY
		LDA	FSJPXS,Y
		STA	ENXSPD,X
		LDA	FSJPYS,Y
		STA	ENYSPD,X
		RTS
;
FSU008		EQU	$
		CMP	#07H
		BNE	FSU010
;
		PHA
;;		LDA	#1DH
;;		STA	ENZPSL,X
		LDA	ENYPSL,X
		SEC
		SBC	#1DH
		STA	ENYPSL,X
		LDA	ENYPSH,X
		SBC	#00H
		STA	ENYPSH,X
		PLA
FSU010		EQU	$
		LSR	A
		LSR	A
		TAY
		LDA	FSUCHP,Y
		STA	ENCHPT,X
		RTS
;==================================================
FSMCPT		EQU	$
		HEX	3,2,1,0
;
FSJUMP		EQU	$
		STZ	ENNOCR,X
;
		JSR	CREKEK
		BCS	BBM038
;
		JSR	ENMVCL
;
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		AND	#00000011B
		BEQ	BBM020
;
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
;
		INC	ENCTFG,X	; Bound count !
;
		BRA	BBM020
BBM020		EQU	$
		LDA	ENCBFG,X
		AND	#00001100B
		BEQ	BBM030
;
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
;
		INC	ENCTFG,X
BBM030		EQU	$
		LDA	ENCTFG,X
		CMP	#03H
		BCC	BBM048
;
BBM038		EQU	$
		LDA	#04H
		STA	ENSTAT,X
;
		LDA	#0FH
		STA	ENTIM0,X
;
;;		JSL	>SDLRCE
;;		ORA	#28H
;;		STA	SOUND2	;(S)
		LDA	#28H
		JSL	>SDLRE2	;(S)
BBM048		EQU	$
		INC	ENCONT,X
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	FSMCPT,Y
		STA	ENCHPT,X
;;		DEC	ENZSPD,X
;;;
;;		LDA	ENZPSL,X
;;		BPL	FSJ010
;;;
;;		LDA	#10H
;;		STA	ENZSPD,X
;;		STZ	ENZPSL,X
;;FSJ010		EQU	$	
;;		INC	ENCONT,X	
;;		LDA	ENCONT,X
;;		CMP	#06H
;;		BNE	FSJ020
;;;
;;		STZ	ENCONT,X
;;;
;;		LDA	ENCHPT,X
;;		EOR	#01H
;;		STA	ENCHPT,X
;;FSJ020		EQU	$
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	FSJ050
;
		JSL	>RNDSET
		MEM16
		REP	#20H
		AND	#000FH
		SEC
		SBC	#0004H
		STA	<WORK0
		MEM8
		SEP	#20H
;
		JSL	>RNDSET
		MEM16
		REP	#20H
		AND	#000FH
		SEC
		SBC	#0004H
		STA	<WORK2
		MEM8
		SEP	#20H
;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
		JSL	>ICEFLST
FSJ050		EQU	$
		RTS
;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
FSCLER		EQU	$
		LDA	ENTIM0,X
		BNE	FSC010
;
		STZ	ENCTFG,X
		STZ	ENSTAT,X
		STZ	ENZPSL,X
;
		LDA	#40H
		STA	ENTIM0,X
		RTS
FSC010		EQU	$
		LSR	A
		LSR	A
		TAY
		CLC
		ADC	#0FH
		STA	ENCHPT,X
		RTS
;%%%%%%%%%%%%%%%Kira kira set%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ICEFLST2	EQU	$		; Teki yori shita yuusen !
		PHX
		TXY
		LDX	#E2HF-1
		BRA	ICS010
;
ICEFLST		EQU	$
		PHX
		TXY
;
		LDX	#E2NO-1
ICS010		EQU	$
		LDA	>E2MODE,X
		BEQ	ICS020
		DEX
		BPL	ICS010
		STX	<WORKF
		PLX
ICS018		EQU	$
		RTL
;- - - - - - - - - - - -- - - - - - - - - -
ICS020		EQU	$
		STX	<WORKF
		LDA	#05H
		STA	>E2MODE,X
		STA	EN2FLG
;
		LDA	ENXPSL,Y
		CLC
		ADC	<WORK0
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		ADC	<WORK1
		STA	>E2XPSH,X
		LDA	ENYPSL,Y
		SEC
		SBC	ENZPSL,Y
		PHP
		CLC
		ADC	#0010H
		PHP
		CLC
		ADC	<WORK2
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		ADC	<WORK3
		PLP
		ADC	#00H
		PLP
		SBC	#00H
		STA	>E2YPSH,X
;
		LDA	#1FH
		STA	>E2TIM0,X
;
		TYA	
		STA	>E2STAT,X	
;
		LDA	ENKAIF,Y
		STA	>E2WRK0,X
;
		PLX
		RTL
;==================================================
;==================================================
;==================================================
;==================================================
;==================================================
;==================================================
;==================================================
;==================================================
;==================================================
FISH0CD		EQU	$
;C
		WORD	00001H,00008H
		HEX	B4,00,00,00
		WORD	00007H,00008H
		HEX	B5,00,00,00
;
		WORD	00004H,0FFFDH
		HEX	86,00,00,00
;
		WORD	00000H,0FFF3H
		HEX	A2,80,00,02
;D
		WORD	00002H,00008H
		HEX	B4,00,00,00
		WORD	00006H,00008H
		HEX	B5,00,00,00
;
		WORD	00004H,0FFFAH		
		HEX	96,00,00,00
;
		WORD	00000H,0FFECH
		HEX	A2,00,00,02
;E
		WORD	00004H,0FFFFH
		HEX	96,00,00,00
;
		WORD	00000H,0FFE5H
		HEX	A2,00,00,02
		WORD	00000H,0FFE5H
		HEX	A2,00,00,02
		WORD	00000H,0FFE5H
		HEX	A2,00,00,02
;0F - Break pt. - -
		WORD	0FFFAH,0FFFAH
		HEX	DF,01,00,00
		WORD	0000EH,0FFFAH
		HEX	DF,41,00,00
		WORD	0FFFAH,0000EH
		HEX	DF,81,00,00
		WORD	0000EH,0000EH
		HEX	DF,C1,00,00
;10
		WORD	0FFFAH,0FFFAH
		HEX	96,00,00,00
		WORD	0000EH,0FFFAH
		HEX	96,40,00,00
		WORD	0FFFAH,0000EH
		HEX	96,80,00,00
		WORD	0000EH,0000EH
		HEX	96,C0,00,00
;11
		WORD	0FFFCH,0FFFCH
		HEX	8D,01,00,00
		WORD	0000CH,0FFFCH
		HEX	8D,41,00,00
		WORD	0FFFCH,0000CH
		HEX	8D,81,00,00
		WORD	0000CH,0000CH
		HEX	8D,C1,00,00
;12
		WORD	00000H,00000H
		HEX	8D,01,00,00
		WORD	00008H,00000H
		HEX	8D,41,00,00
		WORD	00000H,00008H
		HEX	8D,81,00,00
		WORD	00008H,00008H
		HEX	8D,C1,00,00
;- - - - - -
FSMKAT		EQU	$
		HEX	40,00,00,00
		HEX	00,00,00,00
		HEX	00,40,C0,80
;
FISH0CS		EQU	$
		LDA	ENCHPT,X
		CMP	#0CH
		BCS	FSCS10
;;		CMP	#03H
;;		BCC	FSC008
;
		LDY	ENCHPT,X
		LDA	ENCLOR,X
		PHA
		AND	#00111111B
		ORA	FSMKAT,Y
		STA	ENCLOR,X
;;FSC008		EQU	$
		JSL	>EN1CSTL
		PLA
		STA	ENCLOR,X
		RTS
;- - - - - - - - - - - - - - - - - - - - -
FSCS10		EQU	$
		SEC
		SBC	#0CH
		TAY
		LDA	#00H
		XBA
		TYA
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ASL	A
		ADC	#FISH0CD   ;-06H*20H
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#04H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Ice pengin   		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PGCHAD		EQU	$
		HEX	05,00,0A,0F
;
PENGIMV		EQU	$
		LDY	ENMUKI,X
		LDA	ENWRK0,X
		CLC
		ADC	PGCHAD,Y
		STA	ENCHPT,X
		JSR	PENGICS
;
		LDA	ENHNFG,X
		BNE	PGM018
;
		LDA	ENCBFG,X
		AND	#0FH
		BEQ	PGM030
;
PGM018		EQU	$
		STZ	ENSTAT,X
		STZ	ENXSPD,X
		STZ	ENYSPD,X
PGM030		EQU	$
		JSR	ENSTCK
		JSR	ENHNSB
;
		JSR	CREKEK
;
		JSR	ENMVCL2
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	PGM020
;
		STZ	ENZSPD,X
		STZ	ENZPSL,X
PGM020		EQU	$		
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	PGSET
		WORD	PGGO
		WORD	PGJUMP
		WORD	PGSLID
;=============================================================
PGSET		EQU	$
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
;
		INC	ENSTAT,X
		RTS
;=============================================================
;PGGXLM		EQU	$
;		HEX	10,F0  ;,00,00
;PGGYLM		EQU	$
;		HEX	00,00,10,F0
PGGXAD		EQU	$
		HEX	01,FF  ;,00,00
PGGYAD		EQU	$
		HEX	00,00,01,FF
;- - - - - - - - - - - - - - -
PGGO		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	PGG050
;
		STZ	<WORK0
;
		LDY	ENMUKI,X
		LDA	ENXSPD,X
		CMP	PGGXLM,Y
		BEQ	PGG020
		CLC
		ADC	PGGXAD,Y
		STA	ENXSPD,X
		INC	<WORK0
PGG020		EQU	$
		LDA	ENYSPD,X
		CMP	PGGYLM,Y
		BEQ	PGG030
		CLC
		ADC	PGGYAD,Y
		STA	ENYSPD,X
		INC	<WORK0
PGG030		EQU	$
		LDA	<WORK0
		BNE	PGG050
;
		LDA	#0FH
		STA	ENTIM0,X
;
		INC	ENSTAT,X
PGG050		EQU	$
		LDA	<FRCNT
		AND	#04H
		LSR	A
		LSR	A
		TAY
		STA	ENWRK0,X
;
;;		JSR	OAMCHK
;;;
;;		LDA	<WORK2
;;		SEC
;;		SBC	#08H
;;		STA	<WORK2
;;		LDA	<WORK3
;;		SBC	#00H
;;		STA	<WORK3
;;;
;;		JSL	>BIKRST2
;;;
		RTS
;=============================================================
PGJPTD		EQU	$
		HEX	4,4,3,2
;
PGJUMP		EQU	$
		LDA	ENTIM0,X
		BNE	PGJ010
;
		INC	ENSTAT,X
;
PGJ010		EQU	$
		CMP	#05H
		BNE	PGJ020
;
		PHA
        	LDA	#018H
		STA	ENZSPD,X
		PLA
;
PGJ020		EQU	$
		LSR	A
		LSR	A
		TAY
		LDA	PGJPTD,Y
		STA	ENWRK0,X	
		RTS
;=============================================================
EISTYD		EQU	$
		HEX	08,0A,0C,0E
		HEX	0C,0C,0C,0C
EISTXD		EQU	$
		HEX	04,04,04,04
		HEX	00,04,08,0C
;
PGSLID		EQU	$
KIRAST		EQU	$
		TXA
		EOR	<FRCNT
		AND	#07H
		ORA	ENZPSL,X
		BNE	EIST10
;
;;		JSL	>ENIDSH
;;		BMI	EIST10
;
		LDA	ENMUKI,X
		STA	<WORK6
;
;;		LDA	#EICFL
;;		STA	ENMODE,Y
;;		PHX
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	<WORK6
		CMP	#02H
		BCC	PIS010
		INY
		INY
		INY
		INY
PIS010		EQU	$
		LDA	EISTXD,Y
		STA	<WORK0
		STZ	<WORK1
;;		LDA	<WORK0
;;		CLC
;;		ADC	EISTXD,X
;;		STA	ENXPSL,Y
;;		LDA	<WORK1
;;		ADC	#00H    ;EISTXH,X
;;		STA	ENXPSH,Y
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	<WORK6
		CMP	#02H
		BCC	PIS020
		INY
		INY
		INY
		INY
PIS020		EQU	$
		LDA	EISTYD,Y
		STA	<WORK2
		STZ	<WORK3
;
		JSL	>ICEFLST2		; Kira kira set !
;
;;		LDA	<WORK2
;;		CLC
;;		ADC	EISTYD,X
;;		STA	ENYPSL,Y
;;		LDA	<WORK3
;;		ADC	#00H
;;		STA	ENYPSH,Y
;;;
;;		LDA	#20H
;;		STA	ENTIM0,Y
;;;
;;		PLX
EIST10		EQU	$
		RTS
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;		LDA	<KEYA2
;		AND	#00001000B
;		BEQ	AYM010
;;
;		INC	ENCHPT,X
;		LDA	ENCHPT,X
;		CMP	#014H
;		BNE	AYM010
;;
;		STZ	ENWRK0,X
;;
;AYM010		EQU	$
;		LDA	<KEYA2
;		AND	#00000100B
;		BEQ	AYM020
;
;		DEC	ENCHPT,X
;		BPL	AYM020
;;
;		LDA	#13H
;		STA	ENCHPT,X
;;
;AYM020		EQU	$
;		RTS
;-----------------------------------------
PENGICD		EQU	$
;0
		WORD	0FFFFH,0FFF8H
		HEX	82,00,00,02
		WORD	00000H,00000H
		HEX	88,00,00,02
;1
		WORD	0FFFFH,0FFF9H
		HEX	82,00,00,02
		WORD	00000H,00000H
		HEX	8A,00,00,02
;2
		WORD	0FFFDH,0FFFAH
		HEX	82,00,00,02
		WORD	00000H,00000H
		HEX	88,00,00,02
;3
		WORD	0FFFAH,0FFFCH
		HEX	82,00,00,02
		WORD	00000H,00000H
		HEX	8A,00,00,02
;4
		WORD	0FFFCH,00000H
		HEX	A2,00,00,02
		WORD	00004H,00000H
		HEX	A3,00,00,02
;5
		WORD	00001H,0FFF8H
		HEX	82,40,00,02
		WORD	00000H,00000H
		HEX	88,40,00,02
;6
		WORD	00001H,0FFF9H
		HEX	82,40,00,02
		WORD	00000H,00000H
		HEX	8A,40,00,02
;7
		WORD	00003H,0FFFAH
		HEX	82,40,00,02
		WORD	00000H,00000H
		HEX	88,40,00,02
;8
		WORD	00006H,0FFFCH
		HEX	82,40,00,02
		WORD	00000H,00000H
		HEX	8A,40,00,02
;9
		WORD	00004H,00000H
		HEX	A2,40,00,02
		WORD	0FFFCH,00000H
		HEX	A3,40,00,02
;A
		WORD	00000H,0FFF9H
		HEX	80,00,00,02
		WORD	00000H,00000H
		HEX	86,00,00,02
;B
		WORD	00000H,0FFF9H
		HEX	80,40,00,02
		WORD	00000H,00000H
		HEX	86,40,00,02
;C
		WORD	00000H,0FFFCH
		HEX	80,00,00,02
		WORD	00000H,00000H
		HEX	86,00,00,02
;D
		WORD	00000H,0FFFFH
		HEX	80,00,00,02
		WORD	00000H,00000H
		HEX	86,00,00,02
;E
		WORD	0FFF8H,00000H
		HEX	8E,00,00,02
		WORD	00008H,00000H
		HEX	8E,40,00,02
;F
		WORD	00000H,0FFF8H
		HEX	84,00,00,02
		WORD	00000H,00000H
		HEX	8C,00,00,02
;10
		WORD	00000H,0FFF8H
		HEX	84,40,00,02
		WORD	00000H,00000H
		HEX	8C,40,00,02
;11
		WORD	00000H,0FFF9H
		HEX	84,00,00,02
		WORD	00000H,00000H
		HEX	8C,00,00,02
;12
		WORD	00000H,00000H
		HEX	8C,40,00,02
		WORD	00000H,0FFFAH
		HEX	84,40,00,02
;13
		WORD	0FFF8H,00000H
		HEX	A0,00,00,02
		WORD	00008H,00000H
		HEX	A0,40,00,02
;- - - - - -
PENGIC2		EQU	$
		WORD	00000H,00010H
		HEX	B5,00,00,00
		WORD	00008H,00010H
		HEX	B5,40,00,00
;
		WORD	00000H,0FFF8H
		HEX	A5,00,00,00
		WORD	00008H,0FFF8H
		HEX	A5,40,00,00
;------------------------------------------
PENGICS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ADC	#PENGICD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JSR	SETO22
;;		JSL	>SETOAML22
;- - - -  Buhin set !
		LDY	#00H
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		CMP	#0EH
		BEQ	PG2C10
		INY
		CMP	#13H
		BNE	PGCFFF
PG2C10		EQU	$		
		TYA
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ADC	#PENGIC2
		STA	<WORK8
;
		LDA	<OAMADR
		CLC
		ADC	#0008H
		STA	<OAMADR
		INC	<OSBADR
		INC	<OSBADR
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JSR	SETO22
;;		JSL	>SETOAML22
PGCFFF		EQU	$
;
		JSL	>SADWSTL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Eye beam  		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MMBEMMV		EQU	$
		JSL	>EN1CSSL
;
		JSR	ENSTCK
;
		JSR	MMZNZST
		JSR	ENMVCL	
;
		JSL	>CRENPL2L
;
		LDA	ENTIM0,X
		BNE	MMB010
;
;;		JSR	CRENPL
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
;;		AND	#0FH
		BEQ	MMB010
;
		STZ	ENMODE,X
;
;;		JSL	>SDLRCE
;;		ORA	#26H
;;		STA	SOUND3	;(S)
		LDA	#26H
		JSL	>SDLRE3	;(S)
;
		RTS
MMB010		EQU	$
		RTS
;- - - - - - - - - - - - - -
MMZNZST		EQU	$
;;		INC	ENCONT,X
;- - Zanzo set ! - -
;;		TXA
;;		EOR	<FRCNT
;;		LDA	ENCONT,X
;;		AND	#01H
;;		BNE	MZS018
;
		PHX
		TXY
;
		LDX	#E2NO-1
MZS010		EQU	$
		LDA	>E2MODE,X
		BEQ	MZS020
		DEX
		BPL	MZS010
;;		PLX
;;MZS018		EQU	$
;;		RTS
		DEC	E2STCT
		BPL	MZS012
;
		LDA	#E2NO-1
		STA	E2STCT
MZS012		EQU	$
		LDX	E2STCT
;- - - - - - - - - - - -- - - - - - - - - -
MZS020		EQU	$
		LDA	#04H
		STA	>E2MODE,X
		STA	EN2FLG
;
		LDA	ENXPSL,Y
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		STA	>E2XPSH,X
		LDA	ENYPSL,Y
		CLC
		ADC	#0010H
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		ADC	#00H
		STA	>E2YPSH,X
;
		LDA	#10H
		STA	>E2TIM0,X
;
		LDA	ENCHPT,Y
		STA	>E2CHPT,X
		TYA	
		STA	>E2STAT,X	
;
		LDA	ENKAIF,Y
		STA	>E2WRK0,X
;
		PLX
		RTS
;
;
;
;===========================================
MEMEIT		EQU	$
		PHB
		PHK
		PLB
		JSR	MMI010
		PLB
		RTL
;-----------------------------------------
MMDUYD		EQU	$
MMDUXD		EQU	$
		HEX	F8,08
;
MMI010		EQU	$
		LDA	ENMYNO,X
		CMP	#MEMED
		BCC	MEMERIT
;- - - - - - - - - - - - - - - - - - - - - -
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
;
;
MEMERMV		EQU	$
MEMELMV		EQU	$
MEMEDMV		EQU	$
MEMEUMV		EQU	$
		LDA	ENWRK0,X
		BEQ	MM0000
;
		JMP	MMBEMMV
MM0000		EQU	$
		JSR	MEMERCS
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MMWAIT
		WORD	MMSHOT
;=================================================================
MMMKCK		EQU	$
		HEX	2,3,0,1
;
MMWAIT		EQU	$
;;		JSR	EPXYCK
		MEM16
		REP	#20H
		LDA	<PLYPS1
		SEC
		SBC	ENYP2L
		STA	<WORKC
		LDA	<PLXPS1
		SEC
		SBC	ENXP2L
		STA	<WORKE
		MEM8
		SEP	#20H
;
		LDA	<PLMKCH
		LSR	A
		LDY	ENKBMK,X
		CPY	#01H
		TAY
		LDA	ENMUKI,X
		BCS	MMW005		; Muki check ?
;					; yes !
		CMP	MMMKCK,Y
		BNE	MMW010
;
MMW005		EQU	$
		CMP	#02H
		MEM16
		REP	#20H
		BCS	MMW008
;
		LDA	<WORKC
;;		CLC
;;		ADC	#0010H
		BRA	MMW00C		
;
MMW008		EQU	$
;;		MEM16
;;		REP	#20H
		LDA	<WORKE
MMW00C		EQU	$
		CLC
		ADC	#0010H
		CMP	#0020H
		MEM8
		SEP	#20H
		BCS	MMW010
;
		LDA	#20H
;
		LDY	ENKBMK,X
		BEQ	MMW00E
;
		LDA	#20H
MMW00E		EQU	$
		STA	ENTIM0,X
		INC	ENSTAT,X
		RTS
;
MMW010		EQU	$
		STZ	ENCHPT,X
		RTS
;=================================================================
MBSXAL		EQU	$
		HEX	0C,FC ;,04,04
MBSYAL		EQU	$
		HEX	04,04,0C,FC
MBSXAH		EQU	$
		HEX	00,FF ;,00,00
MBSYAH		EQU	$
		HEX	00,00,00,FF
MBSXSD		EQU	$
		HEX	70,90 ;,00,00
MBSYSD		EQU	$
		HEX	00,00,70,90
;- - - - - - - - - - - - - - - - -
MMSHOT		EQU	$
		LDA	#01H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	MMS010
;
		STZ	ENSTAT,X
;
		JSR	MMBEMST
;
		LDA	#0CH
		STA	ENTIM3,X
MMS010		EQU	$
		RTS
;=================================================================
MMBEMST		EQU	$
		LDA	#MEMER
		JSL	>ENIDSH
		BMI	MMBS010
;
		PHX
		LDA	ENMUKI,X
		TAX
		AND	#02H
		LSR	A
		STA	ENCHPT,Y
		LDA	<WORK0
		CLC
		ADC	MBSXAL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	MBSXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	MBSYAL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	MBSYAH,X
		STA	ENYPSH,Y
;
		LDA	MBSXSD,X
		STA	ENXSPD,Y		
		LDA	MBSYSD,X
		STA	ENYSPD,Y		
;
		LDA	#00100000B
		STA	ENMOD0,Y
		STA	ENWRK0,Y
		LDA	#05H
		STA	ENCLOR,Y
		LDA	#01001000B
		STA	ENMOD5,Y
		STA	ENNOCR,Y
		LDA	#05H
		STA	ENTIM0,Y	; BG check protect !
;
		LDA	>ITMTBL7
		CMP	#03H
		BNE	MMBS009		; Tate max power ?
;					; yes ! Hanekairi !
		LDA	#00100000B
		STA	ENMOD4,Y
MMBS009		EQU	$
		PLX
;
;;		JSL	>SDLRCE
;;		ORA	#19H
;;		STA	SOUND3	;(S)
		LDA	#19H
		JSL	>SDLRE3	;(S)
MMBS010		EQU	$
		RTS
;=================================================================
;=================================================================
;=================================================================
;=================================================================
;=================================================================
MEMERCD		EQU	$
;R
		WORD	00008H,0FFFCH
		HEX	C8,40,00,00
		WORD	00008H,00004H
		HEX	D8,40,00,00
		WORD	00008H,0000CH
		HEX	C8,C0,00,00
;
		WORD	00008H,0FFFCH
		HEX	C9,40,00,00
		WORD	00008H,00004H
		HEX	D9,40,00,00
		WORD	00008H,0000CH
		HEX	C9,C0,00,00
;L
		WORD	00000H,0FFFCH
		HEX	C8,00,00,00
		WORD	00000H,00004H
		HEX	D8,00,00,00
		WORD	00000H,0000CH
		HEX	C8,80,00,00
;
		WORD	00000H,0FFFCH
		HEX	C9,00,00,00
		WORD	00000H,00004H
		HEX	D9,00,00,00
		WORD	00000H,0000CH
		HEX	C9,80,00,00
;D
		WORD	0FFFCH,00008H
		HEX	D6,00,00,00
		WORD	00004H,00008H
		HEX	D7,00,00,00
		WORD	0000CH,00008H
		HEX	D6,40,00,00
;
		WORD	0FFFCH,00008H
		HEX	C6,00,00,00
		WORD	00004H,00008H
		HEX	C7,00,00,00
		WORD	0000CH,00008H
		HEX	C6,40,00,00
;U
		WORD	0FFFCH,00000H
		HEX	D6,80,00,00
		WORD	00004H,00000H
		HEX	D7,80,00,00
		WORD	0000CH,00000H
		HEX	D6,C0,00,00
;
		WORD	0FFFCH,00000H
		HEX	C6,80,00,00
		WORD	00004H,00000H
		HEX	C7,80,00,00
		WORD	0000CH,00000H
		HEX	C6,C0,00,00
;- - - - - - - - - - - - - - - -
MEMERCS		EQU	$
		LDA	ENKBMK,X
		BEQ	MMC010		; Akeppanashi ?
;					; yes !
		LDA	#01H
		STA	ENCHPT,X
;
		LDA	ENTIM3,X
		BEQ	MMC010		; Just beam shot ?
;					; yes ! pachi !
		STZ	ENCHPT,X
MMC010		EQU	$
		LDA	#30H
		STA	ENFLCL,X
;
		LDA	#00H
		XBA
		LDA	ENMUKI,X
		ASL	A
		ADC	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
;
		ASL	A
		ADC	<WORK0		
		ADC	#MEMERCD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#03H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;		RTS
;- - - - - - - - - - - - - - - - - - - - - - - -
TAILMVJ		EQU	$
		JMP	TAILMV		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		AYASHIII YATSU 		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AYASIMV		EQU	$
		LDA	ENWRK3,X
		BNE	TAILMVJ
;
		LDA	ENFLCL,X
		ORA	#00110000B
		STA	ENFLCL,X	;Mujyoken BG yusen !! (for water )
		JSR	AYASICS
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	AYSST0
		WORD	AYSST1
		WORD	AYSDOW
		WORD	AYSGO
;==============================================
AYS0PT		EQU	$
		HEX	02,03,00,01
;
AYSST0		EQU	$
		LDA	ENTIM0,X
		BNE	AYS000
;
		INC	ENSTAT,X
		LDA	#1FH
		STA	ENTIM0,X
AYS000		EQU	$
		STA	ENNOCR,X
		LDY	ENMUKI,X
		LDA	AYS0PT,Y
		STA	ENWRK0,X
;
		RTS
;==============================================
AYS1PT		EQU	$
;R
		HEX	09,0B
;;		HEX	0A,09,09,09
;;		HEX	0A,0B,0B,0B
;;		HEX	0A,09,09,09
;;		HEX	0A,0B,0B,0B
;L
		HEX	05,07
;;		HEX	06,07,07,07
;;		HEX	06,05,05,05
;;		HEX	06,07,07,07
;;		HEX	06,05,05,05
;D
		HEX	05,0B
;;		HEX	04,05,05,05
;;		HEX	04,0B,0B,0B
;;		HEX	04,05,05,05
;;		HEX	04,0B,0B,0B
;U
		HEX	07,09
;;		HEX	08,09,09,09
;;		HEX	08,07,07,07
;;		HEX	08,09,09,09
;;		HEX	08,07,07,07
;- - - - - - - - - - - - - - - - - - - - - 
;;AYS1XL		EQU	$
;;		HEX	40,C0,00,00
;;AYS1YL		EQU	$
;;		HEX	00,00,40,C0
;-  -  -  -  -  -  -  -  -  -  -  -  -  -
ASSTYS		EQU	$
		HEX	00,00
ASSTXS		EQU	$
		HEX	04,FC,00,00
;
AYSST1		EQU	$
		LDA	ENTIM0,X
		BNE	AYS110
;
		INC	ENSTAT,X
;
		LDA	#20H
		STA	ENTIM0,X
;
;;		LDY	ENMUKI,X
;;;
;;		LDA	ENXPSL,X
;;		CLC
;;		ADC	AYS1XL,Y
;;		STA	ENWRK1,X
;;;		
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	AYS1YL,Y
;;		STA	ENWRK2,X
;		
		STZ	ENNOCR,X
		JSR	ENSDCL
		RTS
AYS110		EQU	$
		LDA	ENMUKI,X
		ASL	A
;;		ASL	A
;;		ASL	A
;;		ASL	A
		STA	<WORK0
		LDA	ENTIM0,X
;;		LSR	A
		LSR	A
;;		NOP
		LSR	A
		LSR	A
		AND	#01H
		ORA	<WORK0
		TAY
		LDA	AYS1PT,Y
		STA	ENWRK0,X
;
		LDY	ENMUKI,X
		LDA	ASSTXS,Y
		STA	ENXSPD,X
		LDA	ASSTYS,Y
		STA	ENYSPD,X
		JSR	ENMVCL		
		RTS
;==============================================
;;AYSDXS		EQU	$
;;		HEX	20,E0,00,00
;;AYSDYS		EQU	$
;;		HEX	00,00,20,E0
AYSDPT		EQU	$
		HEX	10,11
		HEX	12,13
		HEX	0C,0D
		HEX	0E,0F
;- - - - - - - - - - - - - -
ASDWXS		EQU	$
		HEX	02,FE  ;,00,00
ASDWYS		EQU	$
		HEX	00,00,02,FE
;
AYSDOW		EQU	$
		JSR	CREKEK
;
;;		LDY	ENMUKI,X
;;		LDA	AYSDXS,Y
;;		STA	ENXSPD,X
;;		LDA	AYSDYS,Y
;;		STA	ENYSPD,X
;
		JSR	ENMVCL
;;		LDA	ENXPSL,X
;;		CMP	ENWRK1,X
;;		BNE	AYSD30
;;		LDA	ENYPSL,X
;;		CMP	ENWRK2,X
;;		BNE	AYSD30
;
		LDY	ENMUKI,X
		LDA	ENXSPD,X
		CLC
		ADC	ASDWXS,Y
		STA	ENXSPD,X
		LDA	ENYSPD,X
		CLC
		ADC	ASDWYS,Y
		STA	ENYSPD,X
;
		LDA	ENTIM0,X
		BNE	AYSD30
;
		JSL	>ASMZST
;
AYSD20		EQU	$
		LDA	#10H
		STA	ENTIM1,X
;
		INC	ENSTAT,X
;;		JSR	EPXYCK
;;		TYA
;;		STA	ENMUKI,X
AYSD30		EQU	$
AYMVPS		EQU	$
		LDA	ENMUKI,X
		ASL	A
		STA	<WORK0
		LDA	<FRCNT
		AND	#04H
		LSR	A
		LSR	A
		ORA	<WORK0
		TAY
		LDA	AYSDPT,Y
		STA	ENWRK0,X
		RTS
;
;==============================================
ASMZST		EQU	$
		LDA	#KTOBJ
		LDY	#0EH
		JSL	>ENIDSH2
		BMI	AMZ010
;
		JSL	>ENIDPS
;
;;                JSL     >SDLRCE
;;                ORA     #28H
;;                STA     SOUND2  ; (S)
		STZ	SOUND2	;(S)
		LDA	#28H
		JSL	>SDLRE2	;(S)
;
                LDA     #EWATR          ; TEST TEST !
                STA     ENMODE,Y
                LDA     #00001111B
                STA     ENTIM0,Y
		LDA	#00H
                STA     ENSTAT,Y
;
                LDA     #03H
                STA     ENMOD0,Y
AMZ010		EQU	$
		RTL
;==============================================
AYSGXS		EQU	$
		HEX	18,E8  ;,00,00
AYSGYS		EQU	$
		HEX	00,00,18,E8
;;ASNXMK		EQU	$
;;		HEX	2,3
;;		HEX	3,2
;;		HEX	0,1
;;		HEX	1,0
;- - - - - - - - - -
AYSGO		EQU	$
		JSR	ENHNSB
;
		JSR	CREKEK
		JSR	AYMVPS
		CLC
		ADC	#08H
		STA	ENWRK0,X
;
		LDA	ENTIM1,X
		BNE	AYSG18
;
;;		JSR	KIRAST
		JSR	AYAFLST
;
		JSR	ENMVCL
		JSR	ENBGCK
;;		JSL	>ENBGCKL
;
;;		LDA	ENTIM0,X
;;		BNE	AYSG10
;;;
;;		JSR	EPXYCK
;;		TYA
;;		STA	ENMUKI,X
;;		LDA	#40H
;;		STA	ENTIM0,X
;;AYSG10		EQU	$
;
;;		LDA	ENCBFG,X
		AND	#0FH
		BEQ	AYSG20
;
		JSL	>RNDSET
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	ASNXMK,Y
		STA	ENMUKI,X
AYSG20		EQU	$
		LDY	ENMUKI,X
		LDA	AYSGXS,Y
		STA	ENXSPD,X	
		LDA	AYSGYS,Y
		STA	ENYSPD,X	
;
AYSG18		EQU	$
		RTS
;==============================================
AFSXAD		EQU	$
AFSYAD		EQU	$
		HEX	3,4,5,4
;
AYAFLST		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	AFS090
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	AFSXAD,Y
		STA	<WORK0
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	AFSYAD,Y
		STA	<WORK1
;
		PHX
		TXY
;
		LDX	#E2HF-1
KMRS10		EQU	$
		LDA	>E2MODE,X
		BEQ	KMRS20
		DEX
		BPL	KMRS10
;
		PLX
AFS090		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
KMRS20		EQU	$
		LDA	#0BH
		STA	>E2MODE,X
		STA	EN2FLG
;
		LDA	ENXPSL,Y
		CLC
		ADC	<WORK0
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		ADC	#00H
		STA	>E2XPSH,X
;
		LDA	ENYPSL,Y
		CLC
		ADC	#10H
		PHP
		CLC
		ADC	<WORK1
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		ADC	#00H
		PLP
		ADC	#00H
		STA	>E2YPSH,X
;
		LDA	#0FH
		STA	>E2TIM0,X
;
		PLX
		RTS

;==============================================
;==============================================
;==============================================
;==============================================
;==============================================
;==============================================
;==============================================
;==============================================
;
;		LDA	<KEYA2
;		AND	#00001000B
;		BEQ	AYM010
;;
;		INC	ENWRK0,X
;		LDA	ENWRK0,X
;		CMP	#014H
;		BNE	AYM010
;;
;		STZ	ENWRK0,X
;;
;AYM010		EQU	$
;		LDA	<KEYA2
;		AND	#00000100B
;		BEQ	AYM020
;;
;		DEC	ENWRK0,X
;		BPL	AYM020
;;
;		LDA	#13H
;		STA	ENWRK0,X
;;
;AYM020		EQU	$
;;
;		RTS
;======================================================================
AY0CMK		EQU	$
		HEX	00,80,40,00
		HEX	00,00,00,80,80,C0,40,40
		HEX	00,40,80,C0,40,C0,00,80
		HEX	00,40,80,C0,40,C0,00,80
AY0CPT		EQU	$
		HEX	00,00,01,01
		HEX	02,03,04,03,02,03,04,03
		HEX	05,05,05,05,07,07,07,07
		HEX	06,06,06,06,08,08,08,08
;
;---------------------------------------
;AYASICD		EQU	$
;		WORD	00000H,0FFF8H
;		HEX	8C,00,00,02
;		WORD	00000H,00000H
;		HEX	8E,00,00,02
;;
;		WORD	00000H,0FFF8H
;		HEX	8C,40,00,02
;		WORD	00000H,00000H
;		HEX	8E,40,00,02
;;
;		WORD	00000H,00008H
;		HEX	8C,80,00,02
;		WORD	00000H,00000H
;		HEX	8E,80,00,02
;;
;		WORD	00000H,00008H
;		HEX	8C,C0,00,02
;		WORD	00000H,00000H
;		HEX	8E,C0,00,02
;;
;		WORD	0FFF8H,00000H
;		HEX	AA,40,00,02
;		WORD	00000H,00000H
;		HEX	AC,40,00,02
;;
;		WORD	0FFF8H,00000H
;		HEX	AA,C0,00,02
;		WORD	00000H,00000H
;		HEX	AC,C0,00,02
;;
;		WORD	00008H,00000H
;		HEX	AA,00,00,02
;		WORD	00000H,00000H
;		HEX	AC,00,00,02
;;
;		WORD	00008H,00000H
;		HEX	AA,80,00,02
;		WORD	00000H,00000H
;		HEX	AC,80,00,02
AYASICS		EQU	$
		LDY	ENWRK0,X
;		CPY	#0CH
;		BCS	AYC200
;
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	AY0CMK,Y
		STA	ENCLOR,X
		LDA	AY0CPT,Y
		STA	ENCHPT,X
;
		CPY	#04H
		BCS	AYC100
;
		LDA	ENXP2L
		CLC
		ADC	#04H
		STA	ENXP2L
		LDA	ENXP2H
		ADC	#00H
		STA	ENXP2H
;	
		LDA	ENYP2L
		CLC
		ADC	#04H
		STA	ENYP2L
		LDA	ENYP2H
		ADC	#00H
		STA	ENYP2H
		JSL	>EN1CSSL
		RTS
;---------------------------------------
AYC100		EQU	$
		JSL	>EN1CSTL
		RTS
;- - - - - - - - - - - - - - - - - - - -
;AYC200		EQU	$
;		LDA	ENCLOR,X
;		AND	#00111111B
;		STA	ENCLOR,X
;;
;		LDA	#00H
;		XBA
;		LDA	ENWRK0,X
;		SEC
;		SBC	#0CH
;		MEM16
;		REP	#00100000B
;		ASL	A
;		ASL	A
;		ASL	A
;;
;		ASL	A		
;		ADC	#AYASICD
;		STA	<WORK8
;;
;		MEM8
;		SEP	#00100000B
;;
;		LDA	#02H
;		STA	<WORK6
;		STZ	<WORK7
;;
;		JSL	>SETOAML2
;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Byoyon block 		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BYRVXD		EQU	$
BYRVYD		EQU	$
		HEX	00,02,FE
;
BYOYNMV		EQU	$
		JSR	BYOYNCS
;
		JSR	ENSTCK
;
		JSR	ENBGCK
;
;;		JSR	CRENPL
                LDA     <KAKUMD
                BNE     BYM010
;
		JSL	>CRENPL2L
		BCC	BYM010
;
		JSL	>DASCLR1
;
;;		LDA	<HANEFG
;;		BNE	BYM010
;
		LDA	#20H
		STA	ENTIM0,X
;
		LDA	#30H
		JSL	>PSERC2L
		LDA	<KEYA1
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	<WORK0
		CLC
		ADC	BYRVYD,Y
		STA	<PLYSPD
;
		LDA	<KEYA1
		AND	#03H
		TAY
		LDA	<WORK1
		CLC
		ADC	BYRVXD,Y
		STA	<PLXSPD
;
		LDA	#14H
		STA	<HANEFG
;
		PHX
		JSL	>SWSPCL1
		PLX
;
;;		JSL	>SDLRCE
;;		ORA	#0BH
;;		STA	SOUND2	;(S)	
		LDA	#32H
		JSL	>SDLRE3	;(S)
;
BYM010		EQU	$
;
;;		RTS
;======================================
CRBYEN		EQU	$
		LDY	#ENNO-1
BCR010		EQU	$
;;		CPY	ENINDX
;;		BEQ	BCR020
;
		TYA
		EOR	<FRCNT
		AND	#03H
		ORA	ENZPSL,Y
		BNE	BCR020
;
		LDA	ENMODE,Y
		CMP	#EMOVE
		BCC	BCR020
;
		LDA	ENMOD2,Y
		ORA	ENMOD3,Y
		AND	#01000000B
		BNE	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	<WORK0
		LDA	ENXP2L
		SEC
		SBC	<WORK4
		CLC
		ADC	#0010H
		CMP	#0020H
		BCS	BCR020
;;		LDA	<WORK2
		LDA	ENYP2L
		SEC
		SBC	<WORK6
		CLC
		ADC	#0010H
		CMP	#0020H
		BCS	BCR020
		MEM8
		SEP	#00100000B
;
		LDA	#0FH
		STA	ENHNFG,Y
;
		PHY
		LDA	#40H
		JSL	>ESERCHL
		PLY
		LDA	<WORK0
		STA	ENHNYS,Y
		LDA	<WORK1
		STA	ENHNXS,Y
;
		LDA	#20H
		STA	ENTIM0,X
;
;;		JSL	>SDLRCE
;;		ORA	#0BH
;;		STA	SOUND2	;(S)	
		LDA	#32H
		JSL	>SDLRE3	;(S)
BCR020		EQU	$
		MEM8
		SEP	#00100000B
		DEY
		BPL	BCR010
;
		RTS
;- - - - - - - - - - - - - - - - -
;======================================================
BYOYNCD		EQU	$
		WORD	0FFF8H,0FFF8H
		HEX	EC,00,00,02
		WORD	00008H,0FFF8H
		HEX	EC,40,00,02
		WORD	0FFF8H,00008H
		HEX	EC,80,00,02
		WORD	00008H,00008H
		HEX	EC,C0,00,02
;
		WORD	0FFF9H,0FFF9H
		HEX	EC,00,00,02
		WORD	00007H,0FFF9H
		HEX	EC,40,00,02
		WORD	0FFF9H,00007H
		HEX	EC,80,00,02
		WORD	00007H,00007H
		HEX	EC,C0,00,02
;--------------------------------------------------
BYOYNCS		EQU	$
		LDA	#00H
		XBA
		LDA	ENTIM0,X
		LSR	A
		AND	#01H
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A		
		ASL	A
		ADC	#BYOYNCD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#04H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;		RTS
;---------------------------
;========================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Skelton Big		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SKELBMV		EQU	$
		LDA	ENSTAT,X
		BNE	SBM010
;
		JSL	>OAMCHKL
		BRA	SBM012
SBM010		EQU	$
		JSR	SKELBCS
SBM012		EQU	$
;
		JSR	ENSTCK
;
;;		LDA	<KEYA2
;;		AND	#0CH
;;		BEQ	SBM010
;;;
;;		INC	ENCHPT,X
;;;
;;		LDA	ENCHPT,X
;;		CMP	#07H
;;		BNE	SBM010
;;;
;;		STZ	ENCHPT,X
;;SBM010		EQU	$
;;		RTS
;
		LDA	ENFLSH,X
		AND	#7FH
		CMP	#01H
		BNE	SBM070
;
;;		LDA	>ITMTBL6
;;		CMP	#02H
;;		BCS	SBM070		; Normal sowrd ?
;;;					; yes ! stop !
		STZ	ENFLSH,X
;
		LDA	#06H
		STA	ENSTAT,X
;
		LDA	#0FFH
		STA	ENTIM0,X
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		LDA	#02H
		STA	>EDMGDT+91H*16+8  ;SKELB*16+8	; Bomb damage on !
SBM070		EQU	$
;
		JSR	ENHNSB
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SBCHEK	;0
		WORD	SBDOWN	;1
		WORD	SBWAIT	;2
		WORD	SBKYOR	;3
		WORD	SBGOWT	;4
		WORD	SBJUMP	;5
		WORD	SBFAIL	;6
		WORD	SBACTN	;7
;===================================================
SBCHEK		EQU	$
		LDA	#09H
		STA	ENMOD3,X
		STA	ENNOCR,X
		LDA	ENMOD0,X
		PHA
		ORA	#80H
		STA	ENMOD0,X
		JSR	CRENPL
		PLA
		STA	ENMOD0,X
		BCC	SBC010
;
		LDA	#090H
		STA	ENZPSL,X
		INC	ENSTAT,X
		LDA	#02H
		STA	ENKBMK,X
		LDA	#02H
		STA	ENCHPT,X
;
;;		JSL	>SDLRCE
;;		ORA	#20H
;;		STA	SOUND2	;(S)
		LDA	#20H
		JSL	>SDLRE2	;(S)
SBC010		EQU	$
		RTS
;================================================
SBDOWN		EQU	$
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	SBD008
		SEC
		SBC	#03H
		STA	ENZSPD,X
SBD008		EQU	$
		PLA
		EOR	ENZPSL,X
		BPL	SBD00C
;
		LDA	ENZPSL,X
		BPL	SBD00C
;
SETWAI		EQU	$
		LDA	#02H
		STA	ENSTAT,X
;
		STZ	ENNOCR,X
;
		STZ	ENZPSL,X
		STZ	ENZSPD,X
;
		LDA	#3FH
		STA	ENTIM0,X
;
SBD00C		EQU	$		
		RTS
		
;================================================
SBWCPT		EQU	$
SBWKYD		EQU	$
		HEX	00,01
;;		HEX	00,01
;
SBWAIT		EQU	$
		LDA	#00H
		STA	>EDMGDT+91H*16+8  ;SKELB*16+8	; Bomb damage oFF !
;
		JSR	CREKEK
		LDA	ENTIM0,X
		BNE	SBW010
;
SETKYO		EQU	$
		LDA	#03H
		STA	ENSTAT,X
;;		LDA	#80H
		JSL	>RNDSET
		AND	#3FH
		STA	ENWRK1,X
		LDA	#7FH
		STA	ENTIM0,X
		RTS
;- - - - - - -
SBW010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	SBWCPT,Y
		STA	ENCHPT,X
		LDA	SBWKYD,Y
		STA	ENWRK2,X
;
		LDA	#02H
		STA	ENKBMK,X
		RTS		
;================================================
SBKYMK		EQU	$
		HEX	0,0,0,2
		HEX	1,1,1,2
		HEX	0,0,0,2
		HEX	1,1,1,2
;
SBKYOR		EQU	$
		JSR	CREKEK
		LDA	ENTIM0,X
		CMP	ENWRK1,X
		BNE	SBK010
		JSR	EPXCHK
		TYA
		STA	ENKBMK,X
		INC	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
		RTS
SBK010		EQU	$
		LSR	A
		LSR	A
		LSR	A
;;		LSR	A
		TAY
		LDA	SBKYMK,Y
		STA	ENKBMK,X
		LDA	#00H
		STA	ENWRK2,X
		LDA	#00H
		STA	ENCHPT,X
		RTS
;================================================
SBGOWT		EQU	$
		JSR	CREKEK
		LDA	ENTIM0,X
		BNE	SBGW10
		INC	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
		LDA	#20H
		STA	ENTIM1,X
SBGW10		EQU	$
;;		RTS		
;;		BRA	SBWCPS
SBWCPS		EQU	$
		LDA	#01H
		STA	ENWRK2,X
		LDA	#01H
		STA	ENCHPT,X
		RTS
;================================================
SBJUMP		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM1,X
		BEQ	SBJ008
		DEC	A
		BNE	SBJ007
		LDA	#30H
		STA	ENZSPD,X
		LDA	#10H
		JSL	>PSERCHL
		JSR	EPXCHK
		TYA
		STA	ENKBMK,X
;
		LDA	#13H
		JSL	>SDLRE3	;(S)
SBJ007		EQU	$
		BRA	SBWCPS
;- - - - - - - - - - - - - - - - - - -
SBJ008		EQU	$
		JSR	ENMVCL2
;;		JSL	>ENBGCKL
;;;		JSR	ENZCLC
		JSR	ENBGCK
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	SBJ010
		SEC
		SBC	#02H
		STA	ENZSPD,X
SBJ010		EQU	$		
		LDA	ENZPSL,X
		DEC	A
		BPL	SBJ020
		STZ	ENZPSL,X
		STZ	ENZSPD,X
		LDA	ENTIM0,X
		BNE	SBJ000
;
		JMP	SETWAI
SBJ000		EQU	$
;
		LDA	#10H
		STA	ENTIM1,X
SBJ020		EQU	$
		LDY	#02H
		LDA	ENZSPD,X
		CMP	#18H
		BMI	SBJ030
		LDY	#00H
SBJ030		EQU	$
		TYA
		STA	ENCHPT,X
		RTS
;================================================
SBFKYD		EQU	$
		HEX	00,04,08,0C,0E,0E,0E,0E
		HEX	0E,0E,0E,0E,0E,0E,0E,0E
		HEX	0E,0E,0E,0E,0E,0E,0E,0E
		HEX	0E,0E,0F,0E,0C,08,04,00
;
SBFAIL		EQU	$
		JSR	ENMVCL2
;;		JSL	>ENBGCKL
;;;		JSR	ENZCLC
		JSR	ENBGCK
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	SBF010
		SEC
		SBC	#02H
		STA	ENZSPD,X
SBF010		EQU	$		
		LDA	ENZPSL,X
		DEC	A
		BPL	SBF020
;
		STZ	ENZPSL,X
		STZ	ENZSPD,X
;;		STZ	ENXSPD,X
;;		STZ	ENYSPD,X
SBF020		EQU	$
		LDA	ENTIM0,X
;;		STA	ENNOCR,X
		BNE	SBF030
;
		JSL	>RNDSET
		AND	#01H
		BNE	SBF028
;
		LDA	#07H
		STA	ENSTAT,X
		LDA	#50H
		STA	ENTIM0,X
		RTS
SBF028		EQU	$
		JMP	SETWAI
SBF030		EQU	$
		CMP	#0E0H
		BCC	SBF038
		PHA
		AND	#03H
		BNE	SBF035
		LDA	#14H
		JSL	>SDLRE3
SBF035		EQU	$	
		PLA
SBF038		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	SBFKYD,Y
		STA	ENWRK2,X
		LDA	#03H
		STA	ENCHPT,X
		LDA	#02H
		STA	ENKBMK,X
		RTS
;================================================
SBAPTD		EQU	$
		HEX	01,04
;
SBACTN		EQU	$
		LDA	ENTIM0,X
		BNE	SBA010
		JMP	SETWAI
SBA010		EQU	$
		LSR	A
		LSR	A
		AND	#01H
		TAY
		LDA	SBAPTD,Y
		STA	ENCHPT,X
		RTS
;================================================
;================================================
;================================================
;================================================
SKELBCD		EQU	$
;0
		WORD	0FFFCH,0FFF8H
		HEX	64,00,00,00
		WORD	0FFFCH,00000H
		HEX	61,00,00,02
		WORD	00004H,00000H
		HEX	62,00,00,02
		WORD	0FFFDH,00010H
		HEX	74,00,00,00
		WORD	0000BH,00010H
		HEX	74,40,00,00
;1
		WORD	0FFFCH,0FFF9H
		HEX	64,00,00,00
		WORD	0FFFCH,00001H
		HEX	61,00,00,02
		WORD	00004H,00001H
		HEX	62,00,00,02
		WORD	0FFFDH,00010H
		HEX	65,00,00,00
		WORD	0000BH,00010H
		HEX	65,40,00,00
;2
		WORD	0FFFCH,0FFF8H
		HEX	48,00,00,02
		WORD	00004H,0FFF8H
		HEX	49,00,00,02
		WORD	0FFFCH,00008H
		HEX	4B,00,00,02
		WORD	00004H,00008H
		HEX	4C,00,00,02
		WORD	00004H,00008H
		HEX	4C,00,00,02
;3
		WORD	0FFFCH,00008H
		HEX	68,00,00,02
		WORD	00004H,00008H			
		HEX	69,00,00,02
		WORD	00004H,00008H			
		HEX	69,00,00,02
		WORD	00004H,00008H			
		HEX	69,00,00,02
		WORD	00004H,00008H			
		HEX	69,00,00,02
;4
		WORD	0000CH,0FFF9H
		HEX	64,40,00,00
		WORD	0FFFCH,00001H
		HEX	62,40,00,02
		WORD	00004H,00001H
		HEX	61,40,00,02
		WORD	0FFFDH,00010H
		HEX	65,00,00,00
		WORD	0000BH,00010H
		HEX	65,40,00,00
;5
		WORD	0000CH,0FFF8H
		HEX	64,40,00,00
		WORD	0FFFCH,00000H
		HEX	62,40,00,02
		WORD	00004H,00000H
		HEX	61,40,00,02
		WORD	0FFFDH,00010H
		HEX	74,00,00,00
		WORD	0000BH,00010H
		HEX	74,40,00,00
;6		
		WORD	0FFFCH,0FFF8H
		HEX	49,40,00,02
		WORD	00004H,0FFF8H
		HEX	48,40,00,02
		WORD	0FFFCH,00008H
		HEX	4C,40,00,02
		WORD	00004H,00008H
		HEX	4B,40,00,02
		WORD	00004H,00008H
		HEX	4B,40,00,02
;- - - - - - - - - - - - - - - - - - -
SKELBCS		EQU	$
		JSR	OAMCHK
		JSR	SBHEDCS		; Head set 
;
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
;
		ASL	A		
		ASL	A
		ADC	<WORK0
		ADC	#SKELBCD
		STA	<WORK8
;
		LDA	<OAMADR
		CLC
		ADC	#04H
		STA	<OAMADR
		INC	<OSBADR
;
		MEM8
		SEP	#00100000B
;
		LDA	#05H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		MEM16
		REP	#20H
		LDA	<OAMADR
		SEC
		SBC	#04H
		STA	<OAMADR
		DEC	<OSBADR
		MEM8
		SEP	#20H
;
		LDA	#12H
		JSL	>SADWS2L
		RTS
;========================================================
SBHCCD		EQU	$
		BYTE	066H,066H,046H,046H
SBHCAD		EQU	$
		BYTE	040H,000H,000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - -
SBHEDCS		EQU	$
		LDA	ENCHPT,X
		CMP	#02H
		BEQ	SBHC90
;
		LDA	ENWRK2,X
		STA	<WORK6		; Kubi y position !
		STZ	<WORK7
;
		LDY	#00H
		PHX
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	<WORK6
		SEC
		SBC	#0000CH		
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	SBHC11
;
		LDA	#00F0H
		STA	(<OAMADR),Y
SBHC11		EQU	$
		MEM8
		SEP	#00100000B
		LDA	SBHCCD,X
		INY
		STA	(<OAMADR),Y
		LDA	SBHCAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
SBHC90		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Hands			    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HANDSMV		EQU	$
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
		JSR	HANDSCS
;
		LDA	ENMODE,X
		CMP	#EMOVE
		BEQ	HD0001 
;
		STZ	PYALSP
		STZ	MRTKFG
HD0001		EQU	$
		JSR	ENSTCK
;
		LDA	ENWRK0,X
		BEQ	HDU050		; Cached player ?
;					; yes !
		LDA	ENXPSL,X
		STA	<PLXPS1
		LDA	ENXPSH,X
		STA	<PLXPS0
;
		LDA	ENYPSL,X
		SEC
		SBC	ENZPSL,X
		PHP
		CLC
		ADC	#03H
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		PLP
		SBC	#00H
		STA	<PLYPS0
;
		LDA	#01H
		STA	PYALSP
		STA	MRTKFG
;
		STZ	<HANEFG		; 91/12/27 REVISED !
		STZ	<PLXSPD
		STZ	<PLYSPD
		STZ	<PLXMVC
		STZ	<PLYMVC
;
		MEM16
		REP	#20H
		LDA	<PLYPS1
		SEC
		SBC	<SCCV2
		SEC
		SBC	#0010H
		CMP	#0100H		
		MEM8
		SEP	#20H
		BCC	HDU060		; up limit ?
;					; yes !
		STZ	PYALSP
		STZ	MRTKFG
;
		PHX
		JSL	>PLRSET		; Player reset !
		JSL	>PLYCLR
		PLX
;
		RTS
;
HDU050		EQU	$
		JSL	>CRKNENL
;
HDU060		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HDDOWN
		WORD	HDCACH
		WORD	HDUP
;------------------------------------------
HDDOWN		EQU	$
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	HDD008
		SEC
		SBC	#03H
		STA	ENZSPD,X
HDD008		EQU	$
		PLA
		EOR	ENZPSL,X
		BPL	HDD00C
;
		LDA	ENZPSL,X
		BPL	HDD00C
;
		INC	ENSTAT,X
;
		STZ	ENZPSL,X
		STZ	ENZSPD,X
;
		LDA	#3FH
		STA	ENTIM0,X
;
HDD00C		EQU	$		
		RTS
;----------------------------------------
HDCACH		EQU	$
		LDA	ENTIM0,X
		BNE	HDCA10
;
		INC	ENSTAT,X
HDCA10		EQU	$
		LDY	#00H
		AND	#00100000B
		BNE	HDCA20
		INY
HDCA20		EQU	$		
		TYA
		STA	ENCHPT,X
;
		JSR	CRENPL
		BCC	HDCA30
;
		LDA	#01H
		STA	ENWRK0,X
;
		LDA	#01000000B
		STA	ENMOD2,X
;
;;		STZ	<PLXMVC		; Player move counter reset !
;;		STZ	<PLYMVC
;
		LDA	#2AH
		JSL	>SDLRE3	;(S)
HDCA30		EQU	$
		RTS
;----------------------------
HDUP		EQU	$
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		CMP	#40H
		BPL	HDU010
;
		INC	A
		INC	A
		STA	ENZSPD,X
HDU010		EQU	$
		PLA	
		EOR	ENZPSL,X
		BPL	HDU030
;
		LDA	ENZPSL,X
		BMI	HDU030
;
		STZ	ENMODE,X
HDU030		EQU	$
		RTS		
;============================================
HANDSCD		EQU	$
		WORD	0FFFCH,0FFFCH+4
		HEX	A6,01,00,02
		WORD	0000CH,0FFFCH+4
		HEX	AA,01,00,00
		WORD	0FFFCH,0000CH+4
		HEX	BA,01,00,00
		WORD	00004H,00004H+4
		HEX	A8,01,00,02
;
		WORD	0FFFCH,0FFFCH+4
		HEX	AB,01,00,02
		WORD	0000CH,0FFFCH+4
		HEX	AF,01,00,00
		WORD	0FFFCH,0000CH+4
		HEX	BF,01,00,00
		WORD	00004H,00004H+4
		HEX	AD,01,00,02
;
HANDSCS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A		
		ASL	A
		ADC	#HANDSCD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#04H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
;;		JSL	>SADWSTL
;
;- - - Kage set - - -
		JSL	>BIGSWST
		RTS
		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Slime			    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SLIMEMV		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	SLM002
;
		LDA	ENWRK3,X
		BEQ	SLM002		; Initial BG check ?(flag down )
;					; yes ! 
		STZ	ENWRK3,X
;
		LDA	#01H
		STA	ENXSPD,X
;;		STA	ENYSPD,X
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		STZ	ENXSPD,X
		BEQ	SLM0012		; In BG ?
;					; YES ! Can't set !
		STZ	ENMODE,X 
		RTS
SLM0012		EQU	$
	        LDA     #20H
                JSL     >SDLRE2 ;(S)	; Down sound !
SLM002		EQU	$
		LDA	ENWRK2,X
		BEQ	SLM0025		; Long down !
;
		LDA	#30H
		STA	ENFLCL,X
SLM0025		EQU	$
		JSR	SLIMECS
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		CMP	#02H
		BCC	SLM003
;
		JSL	>CRKNENL
SLM003		EQU	$
		JSR	ENHNSB
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SLCHEK	;0
		WORD	SLSET0	;1
		WORD	SLSET1	;2
		WORD	SLWALK	;3
;========================================
SLCHEK		EQU	$
		LDA	ENMOD3,X
		PHA
		ORA	#09H
		STA	ENMOD3,X	; OBJ hani big !
		LDA	ENMOD0,X
		ORA	#10000000B
		STA	ENMOD0,X
;
		JSR	CRENPL
		PLA
		STA	ENMOD3,X
		BCC	SLCK10
;
		INC	ENSTAT,X
;
		LDA	#07FH
		STA	ENTIM0,X
;
;;		STZ	ENMOD3,X	; revise !
;
		ASL	ENMOD0,X	 
		LSR	ENMOD0,X
;
		LDA	<PLXPS1
		STA	ENXPSL,X
		LDA	<PLXPS0
		STA	ENXPSH,X
		LDA	<PLYPS1
		CLC
		ADC	#08H
		STA	ENYPSL,X
		LDA	<PLYPS0
		ADC	#00H
		STA	ENYPSH,X
		LDA	#30H
		STA	ENTIM3,X
;
		STZ	ENNOCR,X
SLCK10		EQU	$
		RTS
;========================================
SLS0PT		EQU	$
		HEX	00,01,07,07,06,06,05,05
		HEX	06,06,05,05,04,04,04,04
;- - - - - -
SLSET0		EQU	$
		LDA	ENTIM0,X
		BNE	SLS000
		INC	ENSTAT,X
		LDA	#20H
		STA	ENZSPD,X
		LDA	#10H
		JSL	>PSERCHL
;
		LDA	#30H
		JSL	>SDLRE3	;(S)
		RTS
SLS000		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	SLS0PT,Y
		STA	ENCHPT,X		
		RTS		
;========================================
SLS1PT		EQU	$
		HEX	00,01
;
SLSET1		EQU	$
;;;		JSL	>CRKNENL
;
		LDA	ENTIM0,X
		BEQ	SLS130
		DEC	A
		BNE	SLS110
;
		LDA	#20H
		STA	ENTIM0,X
;
		INC	ENSTAT,X
		STZ	ENCHPT,X
		RTS
SLS110		EQU	$
		LSR	A		
		LSR	A		
		LSR	A		
		LSR	A		
		TAY
		LDA	SLS1PT,Y
		STA	ENCHPT,X	; 0 or 1
;
		LDA	<FRCNT
		LSR	A
		AND	#01H
		TAY
		LDA	SLWBLD,Y
		STA	ENXSPD,X
		JSR	ENXCLC
SLW010		EQU	$		
		RTS
;- - - - -
SLS130		EQU	$
		JSL	>CRKNENL
;
		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
;
;
;
;
;
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	S1M008
		SEC
		SBC	#02H
		STA	ENZSPD,X
S1M008		EQU	$
		PLA
		EOR	ENZPSL,X
		BPL	SLS100
;
		LDA	ENZPSL,X
		BPL	SLS100
;
;
;
;
;
;
;;		LDA	ENZSPD,X
;;		DEC	A
;		DEC	A
;;;		STA	ENZSPD,X
;
;;		LDA	ENZPSL,X
;;		BPL	SLS100
;
		STZ	ENZSPD,X
		STZ	ENZPSL,X
		STZ	ENWRK2,X
;
		LDA	#1FH
		STA	ENTIM0,X
		LDA	#08H
		STA	ENKBMK,X	; Walk counter !
SLS100		EQU	$
		RTS
;========================================
SLWBLD		EQU	$
		HEX	F8,08
;
SLWALK		EQU	$
;;;		JSR	CREKEK
		JSR	CRENPL
;
		LDA	ENTIM1,X
		BNE	SLW020
;
		LDA	#30H
		JSL	>PSERCHL
		JSL	>RNDSET
		AND	#3FH
		ORA	#60H
		STA	ENTIM1,X		
;
		ASL	ENCLOR,X
		ASL	ENCLOR,X
		LDA	ENXSPD,X
		ASL	A
		ROR	ENCLOR,X
		LSR	ENCLOR,X
;
SLW020		EQU	$
		LDA	ENTIM2,X
		BNE	SLW038
;
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#00001110B
		ORA	ENCBFG,X
		BNE	SLW030
;
		JSR	ENMVCL
		INC	ENCTCT,X
		LDA	ENCTCT,X
		CMP	ENKBMK,X
		BNE	SLW030
		STZ	ENCTCT,X
		JSL	>RNDSET
		AND	#1FH
		ADC	#40H
		STA	ENTIM2,X
		JSL	>RNDSET
		AND	#1FH
		ORA	#10H
		STA	ENKBMK,X
SLW030		EQU	$
;;		JSL	>ENBGCKL
		JSR	ENBGCK
		LDA	ENCONT,X
		AND	#00001000B
		LSR	A
		LSR	A
		LSR	A
		STA	ENCHPT,X		
		RTS
SLW038		EQU	$
		LDY	#00H
		AND	#00010000B
		BEQ	SLW050
		INY
SLW050		EQU	$
		TYA
		STA	ENCHPT,X
		RTS
;========================================
;========================================
SLCMKD		EQU	$
		HEX	00,00,40,40
;
SLIMECS		EQU	$
;;;		LDA	HEMODE,X
		LDA	ENCLOR,X
		LSR	A
		BCS	SLC0f1		; Jyou chyuu slime ?
;					; yes !
		LDA	OJBKFG
		CMP	#03H
		BCS	SLC099		; Bank ok ?
;					; yes !
SLC0f1		EQU	$
		LDA	ENTIM3,X
		BEQ	SLC0F0
;
		LDA	#02H*4
		JSL	>OAMENT2
SLC0F0		EQU	$
		LDA	ENSTAT,X
		BEQ	SLC001
;
		LDA	ENCHPT,X
		CMP	#04H
		BCS	SLC010
		PHA
		TAY
		LDA	ENCLOR,X
		PHA
;;		AND	#10111111B
		EOR	SLCMKD,Y
		STA	ENCLOR,X
;
		AND	#01H
		EOR	#01H
		ASL	A
		ASL	A
;
;;;		LDA	HEMODE,X	;4:Jyuotyuu SLIME !
		CLC
		ADC	ENCHPT,X
		STA	ENCHPT,X
		JSL	>EN1CSTL
;
		PLA
		STA	ENCLOR,X
		PLA
		STA	ENCHPT,X
SLC000		EQU	$
		RTS
SLC001		EQU	$
		JSL	>OAMCHKL
SLC099		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
SLIMECD		EQU	$
		WORD	00000H,00008H
		HEX	6C,03,00,00
		WORD	00008H,00008H
		HEX	6D,03,00,00
;
		WORD	00000H,00008H
		HEX	60,00,00,00
		WORD	00008H,00008H
		HEX	70,00,00,00
;
		WORD	00000H,00008H
		HEX	70,40,00,00
		WORD	00008H,00008H
		HEX	60,40,00,00
;
		WORD	00000H,00000H
		HEX	40,00,00,02
		WORD	00000H,00000H
		HEX	40,00,00,02
;
SLC010		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		SEC
		SBC	#04H
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A		
		ADC	#SLIMECD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Kame			    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KAM01MV		EQU	$
		JSL	>EN1CSTL
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
;;		LDA	ENMODE,X
;;		CMP	#ECACH
;;		BNE	KM0001
;;;
;;		JMP	KMST55	; Chr. paturn set !
;KM0001		EQU	$
;
		JSR	ENSTCK
;
		JSR	ENHNSB
;
;;		JSR	CREKEK 
		LDA	ENTIM2,X
		BNE	KM0001
;
		JSL	>CRKNENL
KM0001		EQU	$
;
		JSR	CRHMEN		; Vs hanmer check !
;
;;		JSR	ENZCLC
		JSR	ENMVCL2
;
		LDA	ENWRK1,X
		JSL	>JSRSUB
		WORD	KMWALK
		WORD	KMSTOP
KM0010		EQU	$
		RTS
;============================================================
KMWXSD		EQU	$
		HEX	08,F8,00,00
		HEX	0C,F4,00,00
KMWYSD		EQU	$
		HEX	00,00,08,F8
		HEX	00,00,0C,F4
;
KMWALK		EQU	$
		LDA	ENTIM3,X
		BNE	KMW010
;
		JSL	>RNDSET
		AND	#1FH
		ADC	#20H
		STA	ENTIM3,X
;
		AND	#03H
		STA	ENMUKI,X
;
		AND	#00110000B
		BNE	KMW010
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
KMW010		EQU	$
		LDA	ENMUKI,X
		CLC
		ADC	ENCTCT,X
		TAY
		LDA	KMWXSD,Y
		STA	ENXSPD,X
		LDA	KMWYSD,Y
		STA	ENYSPD,X
;
		LDA	ENZSPD,X
		DEC	A
		DEC	A
		STA	ENZSPD,X
		LDA	ENZPSL,X
;;		DEC	A
		BPL	KMW020
;
		STZ	ENZPSL,X
		STZ	ENZSPD,X
KMW020		EQU	$
		LDA	<FRCNT
		LDY	ENCTCT,X
		BNE	KMW030		; High speed ?
		LSR	A		; low !
KMW030		EQU	$
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
;
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X	; No damege !
;
		LDA	#00000100B
		STA	ENMOD5,X	; katai !
;
		JSR	CRENPL
		RTS
;============================================================
KMSTOP		EQU	$
		LDA	ENMOD2,X	; damage on 
		AND	#10111111B
		STA	ENMOD2,X
		STZ	ENMOD5,X	; yaoi 
;
		LDA	ENTIM3,X
		BNE	KMS010
;
		STZ	ENWRK1,X
		LDA	#20H
		STA	ENZSPD,X
		LDA	#40H
		STA	ENTIM3,X
		RTS
;
KMS010		EQU	$
		LDA	ENZSPD,X
		DEC	A
		DEC	A
		STA	ENZSPD,X
		LDA	ENZPSL,X
;;		DEC	A
		BPL	KMS050
;
		STZ	ENZPSL,X
;
                LDA     ENZSPD,X
                EOR     #0FFH
                INC     A
                LSR     A
;;                NOP
                CMP     #09H
                BCS     EIC033
                LDA     #00H
EIC033          EQU     $
                STA     ENZSPD,X
                LDA     ENXSPD,X
                ASL     A
                ROR     ENXSPD,X
                LDA     ENXSPD,X
                CMP     #0FFH
                BNE     EIC005
                STZ     ENXSPD,X
EIC005          EQU     $
                LDA     ENYSPD,X
                ASL     A
                ROR     ENYSPD,X
                LDA     ENYSPD,X
                CMP     #0FFH
                BNE     EIC008
                STZ     ENYSPD,X
EIC008          EQU     $
KMS050		EQU	$
;;		JSL	>CACHCKL
KMST55		EQU	$
		LDA	ENTIM3,X
		CMP	#40H
		BCS	KMS060
		LSR	A
		AND	#01H
		TAY
		LDA	KMRTXS,Y
		STA	ENXSPD,X
		INC	ENCONT,X
KMS060		EQU	$
KMSTPS		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		TAY
		LDA	#02H
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	KMSCLD,Y
		STA	ENCLOR,X
;
;
;;		LDA	ENMODE,X
;;		CMP	#EFAIL
;;		BNE	KMST90
;;;
;;		LDA	#0FFH
;;		STA	ENTIM3,X
;;;
;;KMST90		EQU	$
		RTS
;- - -
KMSCLD		EQU	$
		HEX	00,40
;
KMRTXS		EQU	$
		HEX	08,F8
;============================================================
CRHMEN		EQU	$
		LDA	ENZPSL,X
		ORA	ENTIM2,X
		BNE	CKE010
;
		LDA	<PLBGCKF
		CMP	ENKAIF,X		
		BNE	CKE010
;
		LDA	KNCRYP
		CMP	#80H
		BEQ	CKE010		; player cut ?
;
		LDA	AITMBT
		AND	#00001010B
		BEQ	CKE010		; hanmer ?
;
;		INC	ENKBMK,X
;		LDA	ENKBMK,X
;		CMP	#10H
;		BNE	CKE020		; Just time ?
;;
;		STZ	ENKBMK,X
;					; yes !
		JSL	>PKNCRS2
		JSR     KMCRST
		JSL	>CROJCK2
		BCC	CKE010
;
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
;
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
;
		LDA	#20H
		STA	ENTIM2,X
;
		LDA	#20H
		STA	ENZSPD,X
;
		LDA	#04H
		STA	ENCTCT,X	; High speed !
;
		LDA	ENWRK1,X
		EOR	#01H
		STA	ENWRK1,X
;
		CMP	#01H
		LDA	#0FFH
		BCS	CKE008
		LDA	#40H
CKE008		EQU	$
		STA	ENTIM3,X
CKE010		EQU	$
		STZ	ENKBMK,X
CKE020		EQU	$
		RTS
;- - - - - - - - - - - - - - -
KMCRST		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<WORK4
		LDA	ENXPSH,X
		SBC	#00H
		STA	<WORKA
		LDA	ENYPSL,X
		SEC
		SBC	#10H
		STA	<WORK5
		LDA	ENYPSH,X
		SBC	#00H
		STA	<WORKB
		LDA	#30H
		STA	<WORK6
		STA	<WORK7
		RTS
;============================================================
;============================================================
;============================================================
;============================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%					    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PTRPTD		EQU	$
		HEX	1,1,1,2
		HEX	2,1,1,0
		HEX	0
;
PATARMV		EQU	$
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
;
		JSR	PATARCS
;
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	P0008
;
		LDA	ENZPSL,X
		CMP	#60H
		BCS	P0010
;;;		BMI	P0010
P0008		EQU	$
		JSR	ENSTCK
P0010		EQU	$
;
		JSR	PATAMCT		; Angle controle etc.
;
		LDA	#01H
		STA	PTSPED
;
		LDA	ENFLSH,X
		AND	#7FH
		CMP	#02H
		BNE	PRA210
;
		JSR	PTUPSET
		LDA	#40H
		STA	ENMOD2,X
PRA210		EQU	$
		JSR	ENHNSB
;
		JSR	CRENPL
;;		JSR	CREKEK
;
;;		LDA	<FRCNT
		LDA	ENCONT,X
		INC	ENCONT,X
		AND	#03H
		BNE	PRM020
;
		INC	ENCTCT,X
		LDA	ENCTCT,X
		CMP	#09H
		BNE	PRM010
		STZ	ENCTCT,X
PRM010		EQU	$
		LDY	ENCTCT,X
		LDA	PTRPTD,Y
		STA	ENCHPT,X
PRM020		EQU	$
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
;;		AND	#0FH
		BEQ	PRM030
;
		LDY	ENSTAT,X
		CPY	#05H
		BNE	PRM028
;
		AND	#03H
		BEQ	PRM025
;
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		BRA	PRM030
PRM025		EQU	$
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		BRA	PRM030
PRM028		EQU	$
		JSR	ENSDCL
PRM030		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	PRMOVE ;0
		WORD	PRSTOP ;1
		WORD	PRATCK ;2	
		WORD	PRUP   ;3	
		WORD	PRDOWN ;4		
		WORD	PRATCK2	;5
;	
;;		WORD	PRBABUL	; Last move !
;================================================
;;PRDXPS		EQU	$
;;		HEX	40,60,80,A0
;;PRDYPS		EQU	$
;;		HEX	50,60,70,80
;================================================
PRUP		EQU	$
		LDA	#78H
		STA	ENZSPD,X
		JSR	ENZCLC
		LDA	ENZPSL,X
		CMP	#0E0H
;;		CMP	#0C0H
		BCC	PRU010
		LDA	#40H
		STA	ENTIM0,X
		INC	ENSTAT,X
;
		STZ	ENZSPD,X
;
;;;		LDA	#78H
;;		JSL	>RNDSET
;;		AND	#03H
;;		TAY
;;		LDA	PRDXPS,Y
;;		STA	ENXPSL,X
;;		JSL	>RNDSET
;;		AND	#03H
;;		TAY
;;		LDA	PRDYPS,Y
;;		STA	ENYPSL,X
;
;;		JSL	>RNDSET
;;		AND	#03H
;;		BNE	PRU010
;
		LDA	<PLXPS1
		STA	ENXPSL,X
		LDA	<PLYPS1
		STA	ENYPSL,X
PRU010		EQU	$
		RTS
;================================================
;================================================
PRDOWN		EQU	$
		LDA	ENTIM0,X
		BNE	PRD010
;
;;		LDA	#30H
;;		JSL	>PSERCHL
;;		JSR	ENMVCL
;
		LDA	#090H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
		PLA
		EOR	ENZPSL,X
		BPL	PRD010
;
		LDA	ENZPSL,X
		BPL	PRD010
;
		STZ	ENZPSL,X
;
		JSL	>MIZUSTL
;
		INC	ENSTAT,X
;
		LDA	#20H
		STA	ENTIM0,X
;
		LDA	#03H
		JSL	>SDLRE3	;(S)
;
		LDA	#20H
		STA	ENXSPD,X
		STA	ENYSPD,X
PRD010		EQU	$
		DEC	A
		BNE	PRD020
;
		LDA	#20H
		JSL	>SDLRE2	;(S)
PRD020		EQU	$
		RTS
;================================================
PRATCK2		EQU	$
		LDA	ENTIM0,X
		BNE	PRA220
;
		STZ	ENMOD2,X
;
		JSR	ENMVCL
		JSL	>CRKNENL
;
		LDA	<FRCNT
		AND	#07H
		BNE	PRA220
;
		LDA	#28H
		JSL	>SDLRE2	;(S)
;
		PHX
		TXY
		LDX	#E2NO-1
		LDA	ENYSPD,Y
		BMI	PRA208
		LDX	#E2HF-1
PRA208		EQU	$
		LDA	>E2MODE,X
		BNE	PRA20A
;
		LDA	#15H
		STA	>E2MODE,X
		STA	EN2FLG
		LDA	ENXPSL,Y
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		STA	>E2XPSH,X
		LDA	ENYPSL,Y
		CLC
		ADC	#18H
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		STA	>E2YPSH,X
		LDA	#0FH
		STA	>E2TIM0,X
		PLX
		RTS
PRA20A		EQU	$
		DEX
		BPL	PRA208
		PLX
PRA220		EQU	$
		RTS
;;- - - - - - - - - - - - - - - 
;PRBABUL		EQU	$
;		INC	ENCONT,X
;;
;		LDA	#05H
;		STA	ENCLOR,X
;;
;		LDA	ENMOD2,X
;		AND	#10111111B
;		STA	ENMOD2,X
;		JSR	ENMVCL
;		JSL	>CRKNENL
;;
;		LDA	ENCBFG,X
;;;		AND	#0FH
;		BEQ	PRBB10
;;
;		LDA	#21H
;		JSL	>SDLRE2	;(S)
;PRBB10		EQU	$
;		RTS
;- - - - - - - - - - - - - - - 
;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
PRMOVE		EQU	$
		LDA	ENTIM0,X
		BNE	PRMV10
;
		INC	ENSTAT,X
		LDA	#30H
;;		LDA	#50H
		STA	ENTIM0,X
;
;;		JSL	>EFLCHK
;;		BCC	PRMV10
;
;;		LDA	#30H
;;		STA	ENTIM0,X
PRMV10		EQU	$
		JSR	ENMVCL
;
		LDA	ENXSPD,X
		CMP	ENKBMK,X
		BEQ	PRMV20
		BPL	PRMV18
		INC	ENXSPD,X
		BRA	PRMV20
PRMV18		EQU	$
		DEC	ENXSPD,X
PRMV20		EQU	$
		LDA	ENYSPD,X
		CMP	ENMUKI,X
		BEQ	PRMV30
		BPL	PRMV28
		INC	ENYSPD,X
		BRA	PRMV30
PRMV28		EQU	$
		DEC	ENYSPD,X
PRMV30		EQU	$
;
		RTS
;- - - - - - - - - - - - - - - 
;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
PRSTOP          EQU	$
		LDA	ENTIM0,X
		BNE	PRST10
;
		STZ	ENSTAT,X
;
;;		LDA	ENMYNO,X
;;		CMP	#ICBOS
;;		BEQ	PRST02
		JSL	>EFLCHK
		BCS	PRST01
;
		INC	PTATTM
		LDA	PTATTM
		CMP	#04H
		BNE	PRST02
;
		STZ	PTATTM
;
		LDA	#02H
		STA	ENSTAT,X
		LDA	#0B0H
		STA	ENTIM0,X
;
		RTS
;- - - - - - - - 
PRST01		EQU	$
;		JSL	>RNDSET
;		AND	#0FH
;		ADC	#10H
;		STA	ENTIM0,X
;;
;		AND	#07H
;		ADC	#10H
;
PTUPSET		EQU	$
		LDA	#03H
		STA	ENSTAT,X
;
		LDA	#32H
		JSL	>SDLRE3
;;		LDA	#30H
;;		STA	ENXSPD,X
;;		STA	ENYSPD,X
;
		STZ	ENCONT,X
		RTS
;;		BRA	PRST05		
;- - - - - - - - 
PRST02		EQU	$
		JSL	>RNDSET
		AND	#3FH
		ADC	#30H
		STA	ENTIM0,X
;
		AND	#03H
		ADC	#08H
PRST05		EQU	$
		JSL	>PSERC2L
		LDA	<WORK0
		STA	ENMUKI,X
		LDA	<WORK1
		STA	ENKBMK,X
		RTS
PRST10		EQU	$
		JSR	ENMVCL
;
		LDA	ENXSPD,X
		BEQ	PRST20
		BPL	PRST18
		INC	ENXSPD,X
		BRA	PRST20
PRST18		EQU	$
		DEC	ENXSPD,X
PRST20		EQU	$
		LDA	ENYSPD,X
		BEQ	PRST30
		BPL	PRST28
		INC	ENYSPD,X
		BRA	PRST30
PRST28		EQU	$
		DEC	ENYSPD,X
PRST30		EQU	$
		RTS
;- - - - - - - - - - - - - - - 
;[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
PRATCK		EQU	$
;;		JSL	>EFLCHK
;;		BCS	PRST01
;
		LDA	#08H
		STA	PTSPED
;
		LDA	ENTIM0,X
		CMP	#20H
		BCC	PRAT20
		CMP	#60H
		BCS	PRAT60
;
;;		STZ	PTSPED
;
;;		LDA	PTHANK
;;		CLC
;;		ADC	#01H
		INC	PTHANK
		RTS
PRAT20		EQU	$
;;		LDA	PTHANK
;;		SEC
;;		SBC	#01H
;;		STA	PTHANK
		DEC	PTHANK
		BMI	PRAT80
		RTS
PRAT60		EQU	$
		BNE	PRAT68
		LDA	#26H
		BRA	PRAT6A
PRAT68		EQU	$
		AND	#0FH
		BNE	PRAT70
;
		LDA	#06H
PRAT6A		EQU	$
		JSL	>SDLRE3		;(S)
PRAT70		EQU	$
		RTS
;
PRAT80		EQU	$
		STZ	PTHANK
;
		DEC	ENSTAT,X
		LDA	#70H
		STA	ENTIM0,X
		RTS
;- - - - - - - - - - - - - - - 
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%					     %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;------------------------------------------------
PTANDT		EQU	$
		WORD	0000H,0040H,0080H,00C0H,0100H,0140H,0180H,01C0H
		WORD	0000H,0066H,00CCH,0132H,0198H
PTANER		EQU	$
		WORD	0000H,0000H,0000H,0000H,0000H,0000H,0000H,0000H
		WORD	01FFH,01FFH,01FFH,01FFH,01FFH
PTHNDT		EQU	$
		HEX	14,14,14,14,14,14,14,14
		HEX	0C,0C,0C,0C,0C
PTHND2		EQU	$
;;			 0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
                HEX	00,FF,FE,FD,FC,FB,FA,FA,FB,FC,FD,FE,FF
                HEX	00,FF,FE,FD,FC,FB,FA,FA,FB,FC,FD,FE,FF
                HEX	00,FF,FE,FD,FC,FB,FA,FA,FB,FC,FD,FE,FF
                HEX	00,FF,FE,FD,FC,FB,FA,FA,FB,FC,FD,FE,FF
; - - - - - - - - - - - - - - - 
PATAMCT		EQU	$
;- Tama Angle set - - -
		LDA	PTANGL
		CLC
		ADC	PTSPED     ;#01H
		STA	PTANGL
		LDA	PTANGL+1
		ADC	#00H
		STA	PTANGL+1
;
		LDA	<FRCNT
		AND	#03H
		BNE	PRM050
;
		INC	ENWRK0,X
		LDA	ENWRK0,X
		CMP	#0DH
		BNE	PRM050
;
		STZ	ENWRK0,X
PRM050		EQU	$
		LDA	<FRCNT
		AND	#07H
		BNE	PRM060
;
		INC	ENWRK1,X
		LDA	ENWRK1,X
		CMP	#0DH
		BNE	PRM060
;
		STZ	ENWRK1,X
PRM060		EQU	$
;- - - - - - - - - -
		STZ	ENHELP
;
PTCT10		EQU	$
		LDA	ENHELP
		PHA
		ASL	A
		TAY
;
		MEM16
		REP	#00100000B
                LDA	PTANGL
		CLC
		ADC	PTANDT,Y
		EOR	PTANER,Y
		STA	<WORK0
		MEM8
		SEP	#00100000B
;
		PLY
		LDA	PTHANK
		CLC
		ADC	PTHNDT,Y
		STA	<WORKE		; hankei Y
		STA	<WORKF		; hankei X
;
		LDA	ENHELP
;;		HEX	EA,EA,EA,EA,EA,EA
		STA	<WORK2
		
;
		LDA	ENWRK0,X
		CLC
		ADC	<WORK2
		TAY
		LDA	<WORKF
		CLC
		ADC	PTHND2,Y
		STA	<WORKF				
;
		LDA	ENWRK1,X
		CLC
		ADC	<WORK2
		TAY
		LDA	<WORKE
		CLC
		ADC	PTHND2,Y
		STA	<WORKE				
;
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK4
;
		LDA	<WORK0
		CLC
		ADC	#0080H
;;		AND	#01FFH
		STA	<WORK2
;;		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	PKSF0
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		ASL	4216H
		LDA	4217H
		ADC	#00H
PKSF0		EQU	$
		LSR	<WORK1
		BCC	PKS00
		EOR	#0FFH
		INC	A
PKS00		EQU	$
;;		STA	<WORK4		; XAD
		STZ	<WORKA
		CMP	#00H
		BPL	PKS007
		DEC	<WORKA
PKS007		EQU	$
		CLC	
		ADC	ENXPSL,X
		LDY	ENHELP
		STA	PTBFXL,Y
		LDA	ENXPSH,X
		ADC	<WORKA
		STA	PTBFXH,Y
;
		LDA	<WORK6
		STA	4202H
		LDA	<WORKE
		LDY	<WORK7
		BNE	PKS08
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		ASL	4216H
		LDA	4217H
		ADC	#00H
PKS08		EQU	$
		LSR	<WORK3
		BCC	PKS10
		EOR	#0FFH
		INC	A
PKS10		EQU	$
;;		STA	<WORK6		; YAD
;
		STZ	<WORKA
		CMP	#00H
		BPL	PKS012
		DEC	<WORKA
PKS012		EQU	$
		CLC	
		ADC	ENYPSL,X
		PHP
		SEC
		SBC	#10H
		LDY	ENHELP
		STA	PTBFYL,Y
;
		LDA	ENYPSH,X
		SBC	#00H
		PLP
		ADC	<WORKA
		STA	PTBFYH,Y
;--------------------------------------------
		INC	ENHELP
		LDA	ENHELP
		CMP	#0DH
		BEQ	PTCTA0
		JMP	PTCT10
PTCTA0		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%					     %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;- - - - - - - - - - - - - - - 
PATARCD		EQU	$
		WORD	0FFF8H,0FFF8H+4
		HEX	80,00,00,02
		WORD	00008H,0FFF8H+4
		HEX	80,40,00,02
		WORD	0FFF8H,00008H+4
		HEX	A0,00,00,02
		WORD	00008H,00008H+4
		HEX	A0,40,00,02
		WORD	00000H,00014H+4
		HEX	A8,00,00,02
;
;PTRXAD		EQU	$
;		HEX	00,F8,08,F8,08
;		HEX	00,F8,08,F8,08
;		HEX	00,F8,08,F8,08
;PTRYAD		EQU	$
;		HEX	14,F8,F8,08,08
;		HEX	14,F8,F8,08,08
;		HEX	14,F8,F8,08,08
;PTRCDT		EQU	$
;		HEX	A8,80,80,A0,A0
;		HEX	A8,82,82,A2,A2
;		HEX	A8,84,84,A4,A4
;PTRADT		EQU	$
;		HEX	00,00,40,00,40
;		HEX	00,00,40,00,40
;		HEX	00,00,40,00,40
;- - - - - - - - - - - - - - - - - - -
PATARCS		EQU	$
;;		JSR	OAMCHK
;
;;		MEM16
;;		REP	#00100000B
;;		LDA	#OAM+014CH
;;		STA	<OAMADR		; OAM adress kotei !
;;		LDA	#OAMSB+014CH/4
;;		STA	<OSBADR
;;		MEM8
;;		SEP	#00100000B
;
		MEM16
		REP	#20H
		LDA	#PATARCD
		STA	<WORK8
		MEM8
		SEP	#20H
		LDA	#05H
		JSR	SETO22
;
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK0
;
		LDY	#02H
PTRC38		EQU	$
		LDA	(<OAMADR),Y
		CLC
		ADC	<WORK0
		STA	(<OAMADR),Y
		INY
		INY
		INY
		INY
		CPY	#12H
		BCC	PTRC38
;----------------------------------
;		LDA	ENCHPT,X
;		ASL	A
;		ASL	A
;		ADC	ENCHPT,X
;		STA	<WORK6
;;
;		PHX
;		LDX	#04H
;PTRC10		EQU	$
;		PHX
;		TXA
;		CLC
;		ADC	<WORK6
;		TAX
;		LDA	<WORK0
;		CLC
;		ADC	PTRXAD,X
;		STA	(<OAMADR),Y
;		LDA	<WORK2
;		CLC
;		ADC	PTRYAD,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	PTRCDT,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	<WORK5
;		ORA	PTRADT,X
;		INY
;		STA	(<OAMADR),Y
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDA	#02H
;		STA	(<OSBADR),Y
;		PLY
;		INY
;		PLX
;		DEX
;		BPL	PTRC10
;		PLX
;- - - - Ashi set - - -
		LDA	ENSTAT,X
		CMP	#05H
		BNE	PTRC88
;
		LDY	#11H
		LDA	#0F0H
		STA	(<OAMADR),Y
PTRC88		EQU	$
		LDA	ENCONT,X
		AND	#00001000B
		BEQ	PTRC90
;
		LDY	#13H
;;		DEY	
		LDA	(<OAMADR),Y
		ORA	#40H
		STA	(<OAMADR),Y
PTRC90		EQU	$
;- - Kage set - - 
		LDA	ENSTAT,X
		CMP	#05H
		BEQ	PTMZCS
;
		MEM16
		REP	#20H
		LDA	<OAMADR
		CLC
		ADC	#04H
		STA	<OAMADR
		INC	<OSBADR
		MEM8
		SEP	#20H
;
		LDA	ENZPSL,X
		CMP	#0A0H
		BCS	PTRC98
;
		LDA	ENCLOR,X
		PHA
		AND	#11111110B
		STA	ENCLOR,X
;
		JSL	>BIGSWST2
		PLA
		STA	ENCLOR,X
PTRC98		EQU	$
		RTS
;
;- - - - - - - - - - - - - - -
;		LDA	<WORK0
;		SEC
;		SBC	#03H
;		STA	OAM+160H
;		SEC
;		SBC	#03H
;		STA	OAM+164H
;		CLC
;		ADC	#09H
;		STA	OAM+168H
;		CLC
;		ADC	#03H
;		STA	OAM+16CH
;;
;		LDA	ENYPSL,X
;		SEC
;		SBC	#10H
;		PHP
;		SEC
;		SBC	<SCCV2
;		STA	<WORKD
;		LDA	ENYPSH,X
;		SBC	<SCCV2+1
;		PLP
;		SBC	#00H
;		BNE	PTRC98
;;
;		LDA	<WORKD
;		CLC
;		ADC	#10H
;		STA	OAM+161H		
;		STA	OAM+165H
;		STA	OAM+169H
;		STA	OAM+16DH
;		LDA	#6CH
;		STA	OAM+162H		
;		STA	OAM+166H
;		STA	OAM+16AH
;		STA	OAM+16EH
;		LDA	#034H
;		STA	OAM+163H		
;		STA	OAM+167H		
;		STA	OAM+16BH		
;		STA	OAM+16FH		
;;
;		LDA	#02H
;		STA	OAMSB+160H/4
;		STA	OAMSB+164H/4
;		STA	OAMSB+168H/4
;		STA	OAMSB+16CH/4
;;
;;
;PTRC98		EQU	$
;;
;;;		JSL	>SADWSTL
;;;;
;		LDA	<GAMEMD
;		BEQ	PTRCA0
;;
;		LDY	#02H
;		LDA	#04H
;		JSL	>ALOMCKL
;PTRCA0		EQU	$
;		RTS
;PTMZCD		EQU	$
;		WORD	0FFF8H,00008H
;		HEX	C0,00,00,02
;		WORD	0FFFBH,0000AH
;		HEX	C0,40,00,02
;		WORD	0FFFEH,0000CH
;		HEX	C0,00,00,02
;		WORD	00002H,0000CH
;		HEX	C0,40,00,02
;		WORD	00005H,0000AH
;		HEX	C0,00,00,02
;		WORD	00008H,00008H
;		HEX	C0,40,00,02
;;
;PTMZMK		EQU	$
;		HEX	04,44
;
PTMZCS		EQU	$
		JSL	>PTMZCSL
		RTS
;
;		LDA	ENCLOR,X
;		PHA
;		LDA	ENCONT,X
;		LSR	A
;		NOP
;		AND	#01H
;		TAY
;		LDA	PTMZMK,Y
;		STA	ENCLOR,X
;		LDA	#04H*6
;		JSL	>OAMENT3
;		MEM16
;		REP	#20H
;		LDA	#PTMZCD
;		STA	<WORK8
;		MEM8
;		SEP	#20H
;		LDA	#06H
;		JSR	SETO22
;		PLA
;		STA	ENCLOR,X
;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%					    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PATAMCTL	EQU	$
		PHB
		PHK
		PLB
		JSR	PATAMCT
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%					    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PTCHPT		EQU	$
		HEX	00,01,02,02,02,02,02,01
;- - - - -
PATAMMV		EQU	$
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
;
		JSL	>EN1CSTL
;
;;		JSR	PATAMCS
;
		JSR	ENSTCK
;
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#07H
		TAY
		LDA	PTCHPT,Y
		STA	ENCHPT,X		
;
                LDA     ENWRK1,X
                BEQ     BCK010		; Fock shot on ?
                TAY			; yes !
                DEY
;
                LDA     BMMODE,Y
                BEQ     BCK020          ; Fock shut 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
;
		LDA	#05H
		STA	ENCLOR,X
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
;
BCK008          EQU     $
		RTS
BCK020          EQU     $
		LDA	#01H
		STA	ENSTAT,X
		STZ	ENWRK1,X
		LDA	#20H
		STA	ENTIM0,X
;-----------------------------------------------
BCK010          EQU     $
		LDA	ENTIM0,X
		BNE	PTM002
;
		JSR	CRENPL
PTM002		EQU	$
		LDA	ENSTAT,X
		BNE	PTM020	
;
		LDA	PTBFXL-1,X
		STA	ENXPSL,X
		LDA	PTBFXH-1,X
		STA	ENXPSH,X
		LDA	PTBFYL-1,X
		STA	ENYPSL,X
		LDA	PTBFYH-1,X
		STA	ENYPSH,X
;
		RTS
;-----------------------------------
PTM020		EQU	$
		JSL	>CRKNENL
;
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	PTM030
;
		LDA	PTBFXL-1,X
		STA	<WORK4
		LDA	PTBFXH-1,X
		STA	<WORK5
		LDA	PTBFYL-1,X
		STA	<WORK6
		LDA	PTBFYH-1,X
		STA	<WORK7
		LDA	#04H
		JSL	>ESERCHL
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		LDA	ENXPSL,X
		SEC
		SBC	PTBFXL-1,X
		CLC
		ADC	#08H
		CMP	#10H
		BCS	PTM030
		LDA	ENYPSL,X
		SEC
		SBC	PTBFYL-1,X
		CLC
		ADC	#08H
		CMP	#10H
		BCS	PTM030
;
		STZ	ENSTAT,X
		LDA	#0DH
		STA	ENCLOR,X
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X
;
PTM030		EQU	$
		JSR	ENMVCL
		RTS
;==================================================
;PTCCDT		EQU	$
;		HEX	A6,88,86
;;
;PATAMCS		EQU	$
;		LDY	#00H
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		STA	(<OAMADR),Y
;		LDA	ENYPSL,X
;		SEC
;		SBC	<SCCV2
;		INY
;		STA	(<OAMADR),Y
;		PHX
;		LDA	ENCHPT,X
;		TAX
;		LDA	PTCCDT,X
;		INY
;		STA	(<OAMADR),Y
;		PLX
;		LDA	ENCLOR,X
;		ORA	ENFLCL,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	#02H
;		STA	(<OSBADR)
;		RTS		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%					    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MIIRAMV		EQU	$
		JSR	MIIRACS
;
		JSR	ENSTCK
		JSR	ENHNSB
		JSR	CREKEK
;;		LDA	<KEYA2
;;		AND	#00001100B
;;		BEQ	MRM010
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#0CH
;;		BNE	MRM010
;;		STZ	ENCHPT,X
;;MRM010		EQU	$
;;;
;;		RTS
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MRSTOP
		WORD	MRWALK
;----------------------------------------
MRCKMK		EQU	$
		HEX	02,06,04,00
MRSTPT		EQU	$
		HEX	04,08,0B,0A,00,06,03,07
;
MRSTOP		EQU	$
		LDY	ENMUKI,X
		LDA	MRSTPT,Y
		STA	ENCHPT,X
;
		LDA	<FRCNT
		AND	#07H
		BNE	MRST20
;
		LDY	ENWRK0,X		
		LDA	ENMUKI,X
		CMP	MRCKMK,Y
		BEQ	MRST30
;
		BPL	MRST10
		INC	ENMUKI,X
		BRA	MRST20
MRST10		EQU	$
		DEC	ENMUKI,X
MRST20		EQU	$
		RTS
MRST30		EQU	$
		JSL	>RNDSET
		AND	#1FH
		ADC	#30H
		STA	ENTIM0,X
		INC	ENSTAT,X
		RTS
;----------------------------------------
MRWKYS		EQU	$
		HEX	F0,00  ;;,00,00,10,00,00,00
MRWKXS		EQU	$
		HEX	00,00,10,00,00,00,F0,00
MRWCPT		EQU	$
		HEX	09,02,00,04
		HEX	0B,03,01,05
;- - - - - - - - - - - - - - - - - - - - - -
MRWALK		EQU	$
		LDY	ENMUKI,X
		LDA	MRWKXS,Y
		STA	ENXSPD,X
		LDA	MRWKYS,Y
		STA	ENYSPD,X
		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
		LDA	ENTIM0,X
		BEQ	MRW00C
;
		LDA	ENCBFG,X
		BEQ	MRW010
;
;;		LDA	#40H
;;		STA	ENTIM0,X
;
MRW00C		EQU	$
		JSR	EPXYCK
		TYA
		CMP	ENWRK0,X
		BEQ	MRW010		; Muki chenge ?
;					; yes !
		STA	ENWRK0,X
		STZ	ENSTAT,X
		RTS
;
MRW010		EQU	$
		DEC	ENWRK1,X
		BPL	MRW012
;
		LDA	#0EH
		STA	ENWRK1,X
		INC	ENCONT,X
MRW012		EQU	$
		LDA	ENCONT,X
		ASL	A
		ASL	A
		AND	#00000100B
		ORA	ENWRK0,X
		TAY
		LDA	MRWCPT,Y
		STA	ENCHPT,X
		RTS
;======================================================
MIIRACD		EQU	$
;0
		WORD	00000H,0FFF7H
		HEX	80,00,00,02
		WORD	00000H,00000H
		HEX	8A,00,00,02
;1
		WORD	00000H,0FFF8H
		HEX	80,00,00,02
		WORD	00000H,00001H
		HEX	8A,40,00,02
;2
		WORD	00000H,0FFF7H
		HEX	82,00,00,02
		WORD	00000H,00000H
		HEX	8C,00,00,02
;3
		WORD	00000H,0FFF8H
		HEX	82,00,00,02
		WORD	00000H,00000H
		HEX	8E,00,00,02
;4
		WORD	00000H,0FFF7H
		HEX	84,00,00,02
		WORD	00000H,00000H
		HEX	A0,00,00,02
;5
		WORD	00000H,0FFF8H
		HEX	84,00,00,02
		WORD	00000H,00001H
		HEX	A0,40,00,02
;6
		WORD	00000H,0FFF7H
		HEX	86,00,00,02
		WORD	00000H,00000H
		HEX	A2,00,00,02
;7
		WORD	00000H,0FFF7H
		HEX	88,00,00,02
		WORD	00000H,00000H
		HEX	A4,00,00,02
;8
		WORD	00000H,0FFF7H
		HEX	88,40,00,02
		WORD	00000H,00000H
		HEX	A4,40,00,02
;9
		WORD	00000H,0FFF7H
		HEX	82,40,00,02
		WORD	00000H,00000H
		HEX	8C,40,00,02
;A
		WORD	00000H,0FFF7H
		HEX	86,40,00,02
		WORD	0000H,00000H
		HEX	A2,40,00,02
;B
		WORD	00000H,0FFF8H
		HEX	82,40,00,02
		WORD	00000H,00001H
		HEX	8E,40,00,02
;- - - - - - - - - - - - - - - - - - - - - - - - - -
MIIRACS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A		
		ADC	#MIIRACD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		LDA	ENDSPL,X
		BNE	MIRC90
;
		JSL	>SADWSTL
MIRC90		EQU	$
		RTS
;======================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%					    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BKFIRMV		EQU	$
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		JSR	CRENPL
;
		LDA	<FRCNT
		AND	#01H
		BNE	BFR010
;
		LDA	ENCLOR,X
		EOR	#10000000B
		STA	ENCLOR,X
BFR010		EQU	$
		JSR	ENMVCL
;
		LDA	ENTIM0,X
		BNE	BFR090
;
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	BFR090
;
		STZ	ENMODE,X
BFR090		EQU	$
;- - Zanzo set ! - -
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	BFS018
;
		PHX
		TXY
;
		LDX	#E2HF-1
BFS010		EQU	$
		LDA	>E2MODE,X
		BEQ	BFS020
		DEX
		BPL	BFS010
		PLX
BFS018		EQU	$
		RTS
;- - - - - - - - - - - -- - - - - - - - - -
BFS020		EQU	$
		LDA	#02H
		STA	>E2MODE,X
		STA	EN2FLG
;
		LDA	ENXPSL,Y
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		STA	>E2XPSH,X
		LDA	ENYPSL,Y
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		STA	>E2YPSH,X
;
		LDA	#10H
		STA	>E2TIM0,X
;
;;		LDA	ENCLOR,Y
;;		EOR	ENFLCL
		TYA
		STA	>E2STAT,X	
;
		LDA	ENKAIF,Y
		STA	>E2WRK0,X
;
		PLX
		RTS
;======================
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Tail					         %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAILMV		EQU	$
		LDA	#30H
		STA	ENFLCL,X
		JSR	TAILCS
;
		JSR	ENSTCK2
;
		LDA	ENFLSH,X
		BNE	TLA008
;
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	TLSET
		WORD	TLUP
		WORD	TLATCK
;=============================
TLSET		EQU	$
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	ENYPSL,X
		CLC
		ADC	#08H
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
		LDY	#06H
		JSL	>TGBLKWT	; Tail off !
;
		INC	ENSTAT,X
;
		LDA	#80H
		STA	ENTIM0,X
		RTS
;=============================
TLATCK		EQU	$
		STZ	ENNOCR,X
;
		LDA	ENTIM0,X
		BEQ	TLA002
;
		AND	#03H
		BNE	TLA002
;
		JSR	TLSH
TLA002		EQU	$
		JSR	CREKEK
		BCS	TLA008
		JSR	ENMVCL
;
		LDA	ENYP2L
		SEC
		SBC	ENZPSL,X
		STA	ENYP2L
		LDA	ENYP2H
		SBC	#00H
		STA	ENYP2H
;
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	TLA010
;
TLA008		EQU	$		; Break !
;;		JSL	>SDLRCE
;;		ORA	#1FH
;;		STA	SOUND2		; (S)
		LDA	#1FH
		JSL	>SDLRE2	;(S)
;
		LDA	#EFAIL
		STA	ENMODE,X
		LDA	#1FH
		STA	ENTIM0,X
		LDA	#KTOBJ
		STA	ENMYNO,X
		STZ	ENFLSH,X
		LDA	#80H
		STA	ENWRK2,X
		RTS
TLA010		EQU	$
		BRA	TLU020
;=============================
TLUP		EQU	$
		LDA	ENTIM0,X
		BNE	TLU010
;
		INC	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
TLSH		EQU	$
		LDA	#20H+15
;;;		LDA	#20H+6
		JSL	>PSERCHL
		RTS
TLU010		EQU	$
		CMP	#40H
		BCC	TLU020
		LDA	#04H
		STA	ENZSPD,X
		JSR	ENZCLC
TLU020		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
;
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	TLU030
;
;;		JSL	>SDLRCE
;;		ORA	#07H
;;		STA	SOUND2	;(S)
		LDA	#07H
		JSL	>SDLRE2	;(S)
TLU030		EQU	$
		RTS
;=============================
;
TAILCD		EQU	$
		WORD	00000H,00000H
		HEX	D3,00,00,00
		WORD	00008H,00000H
		HEX	D3,40,00,00
		WORD	00000H,00008H
		HEX	D3,80,00,00
		WORD	00008H,00008H
		HEX	D3,C0,00,00
;
		WORD	00000H,00000H
		HEX	C3,00,00,00
		WORD	00008H,00000H
		HEX	C3,40,00,00
		WORD	00000H,00008H
		HEX	C3,80,00,00
		WORD	00008H,00008H
		HEX	C3,C0,00,00
;
TAILCS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ASL	A
		ADC	#TAILCD   
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#04H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		JSL	>SADWSTL
		RTS
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%							         %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HARI0MV		EQU	$
		LDA	ENWRK3,X
		BNE	H10000		; Normal trap ?
;- - - - - - - - - -			; yes !
		JSL	>EN1CSTL
;
		JSR	ENSTCK
		JSR	CREKEK
;
		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		LDA	ENTIM0,X
		BNE	H00000
;
		JSR	CRSKEN
		BCC     H000F0
;
		LDA	ENCBFG,X
		AND	#0FH
		BEQ	H00000
;
H000F0		EQU	$
		LDA	#04H
		STA	ENTIM0,X
;
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
;
		LDA	#05H
		JSL	>SDLRE2
H00000		EQU	$		
		RTS
;
;
;========= BIG Komori room trap ==========
H10000		EQU	$
		LDA	#01H*4
		JSL	>OAMENT2
;
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		JSR	CREKEK
;
		LDA	ENSTAT,X
		BNE	HRM010
;- - -  set - - -
		LDY	#00H
		JSR	HRBGST
;	
		INC	ENSTAT,X
;
		LDA	#40H
		STA	ENTIM0,X
		LDA	#069H
		STA	ENTIM1,X
;
		RTS
;- - - - move- - - - - - - - - - 
HRMXRV		EQU	$
		HEX	08,F8
;
HRM010		EQU	$
		LDA	ENTIM0,X
		BEQ	HRM020		;Ready ?
;					; yes !
		CMP	#01H
		BNE	HRM011
;
		LDA	ENWRK0,X
		STA	ENXPSL,X
		LDA	ENWRK1,X
		STA	ENYPSL,X
		RTS
HRM011		EQU	$
		LSR	A
		AND	#01H
		TAY
		LDA	HRMXRV,Y
		STA	ENXSPD,X
		JSR	ENXCLC
		STZ	ENXSPD,X
		RTS
;----------------------------
HRMXLM		EQU	$
		HEX	20,E0  ;;,00,00
HRMYLM		EQU	$
		HEX	00,00,20,E0
HRMXAD		EQU	$
		HEX	01,FF  ;;,00,00
HRMYAD		EQU	$
		HEX	00,00,01,FF
;- - - - - 
HRM020		EQU	$
		LDA	ENSTAT,X
		CMP	#01H
		BNE	HRM100
;
		LDA	<FRCNT
		AND	#00H
		BNE	HRM050
;
		LDY	ENMUKI,X
		LDA	ENXSPD,X
		CMP	HRMXLM,Y
		BEQ	HRM030
		CLC
		ADC	HRMXAD,Y
		STA	ENXSPD,X
HRM030		EQU	$
		LDA	ENYSPD,X
		CMP	HRMYLM,Y
		BEQ	HRM050
		CLC
		ADC	HRMYAD,Y
		STA	ENYSPD,X
HRM050		EQU	$
		JSR	ENMVCL
;
		LDA	ENTIM1,X
		BNE	HRM060
;
		JSL	>PSSAVE2
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	HRM060
;
		INC	ENSTAT,X
;
		LDA	#40H
		STA	ENTIM1,X
HRM060		EQU	$
		RTS
;- Return -BACK - -
HRRXSD		EQU	$
		HEX	F0,10,00,00
HRRYSD		EQU	$
		HEX	00,00,F0,10
;
HRM100		EQU	$
		LDA	ENTIM1,X
		BNE	HRM110
;
		LDY	ENMUKI,X
		LDA	HRRXSD,Y
		STA	ENXSPD,X
		LDA	HRRYSD,Y
		STA	ENYSPD,X
;
		JSR	ENMVCL
;
		LDA	ENXPSL,X
		CMP	ENWRK0,X
		BNE	HRM110
		LDA	ENYPSL,X
		CMP	ENWRK1,X
		BNE	HRM110
;
		STZ	ENMODE,X
		LDY	#02H
		JSR	HRBGST
HRM110		EQU	$
		RTS
;=======================================
HRBGST		EQU	$
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
;
		JSL	>TGBLKWT
		RTS
;----Sekizoo hit check !----------------------------
CRSKEN		EQU	$
		LDY	#ENNO-1
CSK010		EQU	$
		TYA
		EOR	<FRCNT
		AND	#01H
		BNE	CSK020
;
		LDA	ENMODE,Y
		BEQ	CSK020
;
		LDA	ENMYNO,Y
		CMP	#SEKZ4
		BNE	CSK020
;
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		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	<WORK0
		SEC
		SBC	<WORK4
		CLC
		ADC	#0010H
		CMP	#0020H
		BCS	CSK008
;
		LDA	<WORK2
		SEC
		SBC	<WORK6
		CLC
		ADC	#0008H
		CMP	#0010H
		BCS	CSK008
;
;;		LDA	#02H
;;		STA	ENTIM0,X	
;
		MEM8
		SEP	#00100000B
CSK090		EQU	$
		RTS
;- - - - - - - - - - - - - - - - -
CSK008		EQU	$
		MEM8
		SEP	#00100000B
CSK020		EQU	$
		DEY
		BPL	CSK010
CSK0A0		EQU	$
		SEC
		RTS
;
;
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Big Bad               	               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BIGKOMV		EQU	$
		JSR	BKFF00
;
		JSR	ENSTCK
;
		JSR	HARI0CK		; Toge set !
		RTS
;- - - - - - - - - - - - - - - - - -
BKFF00		EQU	$
		JSL	>BIGKOCS
;
		LDA	ENMODE,X
		CMP	#EICE
		BNE	BK0000
;
		STZ	ENSTAT,X
BK0000		EQU	$
		JSR	ENSTCK
;
		STZ	ENMOD2,X
;
		LDA	ENTUTM,X
		BEQ	BK0111
		LDA	#40H
		STA	ENMOD2,X
BK0111		EQU	$		
;
		LDA	ENHNFG,X
		BEQ	BK0122 
		AND	#7FH
		CMP	#06H
		BNE	BK0122 
;
		STZ	ENHNFG,X
		LDA	#20H
		STA	ENTUTM,X
		LDA	#02H
		STA	ENSTAT,X
		STZ	ENTIM0,X
		LDA	#40H
		STA	ENCTCT,X
;
;;;		STA	HEMODE,X	; High speed 
;
BK0122		EQU	$
		JSR	ENHNSB
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BKWAIT
		WORD	BKUP
		WORD	BKFLY
		WORD	BKFIRE
;------------------------------------------------
BKWAIT		EQU	$
		LDA	ENTIM0,X
		BNE	BKW090
;
		INC	ENSTAT,X
BKW090		EQU	$
		RTS
;------------------------------------------------
BKUP		EQU	$
;;		JSR	CREKEK
;
		LDA	#08H
		STA	ENZSPD,X
		JSR	ENZCLC
		STZ	ENZSPD,X
		LDA	ENZPSL,X
		CMP	#18H
		BCC	BKU090
;
		LDA	#080H
		STA	ENCTCT,X
;
		INC	ENSTAT,X
		STZ	ENNOCR,X
;
		LDA	#40H
		STA	ENTIM0,X
BKU090		EQU	$
		JSR	BIGKOPT
		RTS
;------------------------------------------------
BKFZAD		EQU	$
		HEX	01,FF
BKFYSD		EQU	$
		HEX	F0,F4 
BKFXSD		EQU	$
		HEX	00,0C,10,0C,00,F4,F0,F4
;;		HEX	00,06,08,06,00,FA,F8,FA
;;BKFYSD		EQU	$
;;		HEX	F8,FA,00,06,08,06,00,FA
;
BKFLY		EQU	$
;;		LDA	<FRCNT
;;		AND	#01H
;;		BNE	BKF000
;
		LDA	ENCTCT,X
		BNE	BKF0F0
;
;;		LDA	ENCHPT,X
;;		BNE	BKF000
;
		LDA	#3FH
		STA	ENTIM0,X
;
		INC	ENSTAT,X
;
;;		STZ	HEMODE,X
		RTS
BKF0F0		EQU	$
		DEC	ENCTCT,X
BKF000		EQU	$
		JSR	BIGKOPT
;
		LDA	ENWRK0,X
		AND	#01H
		TAY
		LDA	ENZSPD,X
		CLC
		ADC	BKFZAD,Y
		STA	ENZSPD,X
		CMP	BKFZLM,Y
		BNE	BKF010
		INC	ENWRK0,X
BKF010		EQU	$		
		LDA	ENTIM0,X
		BNE	BKF018
;
		INC	ENWRK2,X
		LDA	ENWRK2,X
		CMP	#07H
		BNE	BKF012
;
		STZ	ENWRK2,X
		BRA	BKF020
;
BKF012		EQU	$
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	BKFXSD,Y
		STA	ENXSPD,X
		LDA	BKFYSD,Y
		STA	ENYSPD,X
;
;;		LDA	HEMODE,X
;;		BEQ	BKF013
;;;
;;		ASL	ENXSPD,X
;;		ASL	ENXSPD,X
;;BKF013		EQU	$
		JSL	>RNDSET
		AND	#1FH
		ADC	#040H
		STA	ENTIM0,X
		BRA	BKF018
;- - - - - - - - - - - - - - - - - - - - - - - - - -
BKF020		EQU	$		; Player serch !
;;		JSL	>RNDSET
;;		AND	#01111110B
;;		BNE	BKF018	
;
		LDA	#20H
		JSL	>PSERCHL
;
		LDA	#80H
		STA	ENTIM0,X
;;;		STA	ENTIM2,X
BKF018		EQU	$
		LDA	ENCBFG,X
		BNE	BKF02C
;
		JSR	ENMVCL
BKF02C		EQU	$
		JSR	ENZCLC
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	BKF030
;
		STZ	ENTIM0,X
BKF030		EQU	$
		JSR	CREKEK
;
		INC	ENCONT,X
		INC	ENCONT,X
BKF090		EQU	$
		RTS
;- - - - - - - - - - - - - - -  -
BKPTPT		EQU	$
		HEX	0,1,2,1
;
BIGKOPT		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
;;		LDY	ENTIM2,X
;;		BNE	BKP010
		LSR	A
		LSR	A
BKP010		EQU	$
		AND	#03H
		TAY
		BNE	BKP021
;
		LDA	#02H
		JSL	>SDLRE3	;(S)
BKP021		EQU	$
		LDA	BKPTPT,Y
		STA	ENCHPT,X
		RTS
;------------------------------------------------
;;BKFRPT		EQU	$
;;		HEX	00,00,00,00
;;		HEX	00,00,00,00
;;		HEX	00,00,01,02
;;		HEX	02,02,01,00
;
BKFIRE		EQU	$
;;		LDA	#02H
;;		STA	ENTIM2,X
;
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	BKFR90
		DEC	ENSTAT,X
		JSL	>RNDSET
		AND	#1FH
		ORA	#40H
		STA	ENCTCT,X
		RTS
BKFR90		EQU	$
		CMP	#020H
		BNE	BKFR10
;;		PHA
		JSR	BKFIRST
;;		PLA		
BKFR10		EQU	$
		BRA	BIGKOPT
;
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		TAY	
;;		LDA	BKFRPT,Y
;;		STA	ENCHPT,X
;;		RTS
;- - - - - - - - - - - - - - - - - -
BKFSXL		EQU	$
BKFSXS		EQU	$
;;		HEX	F0,00,10
		HEX	F0,00,10
;;BKFSXH		EQU	$
;;		HEX	FF,00,00
BKFSYS		EQU	$
		HEX	18,20,18
;
BKFIRST		EQU	$
		LDA	#036H
		JSL	>SDLRE3	;(S)
;
		LDA	#02H
		STA	ENHELP
BKFS10		EQU	$
		LDA	#BKFIR
		JSL	>ENIDSH
		BMI	BKFS20
;
		JSL	>ENIDPS
;
		LDA	<WORK2
		SEC
		SBC	<WORK4
;;;		PHP
		CLC
		ADC	#03H
		STA	ENYPSL,Y
;;;		LDA	<WORK3
;;;		ADC	#00H
;;;		PLP
;;;		SBC	#00H
;;;		STA	ENYPSH,Y
;
		LDA	#10H
		STA	ENTIM0,Y
		STA	ENNOCR,Y
;
		PHX
		LDX	ENHELP
		LDA	<WORK0
		CLC
		ADC	BKFSXL,X
		STA	ENXPSL,Y
;;		LDA	<WORK1
;;		ADC	BKFSXH,X
;;		STA	ENXPSH,Y
;
		LDA	BKFSXS,X
		STA	ENXSPD,Y
		LDA	BKFSYS,X
		STA	ENYSPD,Y
;
		LDA	#00H
		STA	ENZPSL,Y
		PLX
BKFS20		EQU	$
		DEC	ENHELP
		BPL	BKFS10
		RTS
;------------------------------------------------
;------------------------------------------------
;------------------------------------------------
;------------------------------------------------
;------------------------------------------------
;====Toge set sub ===========================================
HRSTXL		EQU	$
;;;			 0  1  2  3  4  5  6  7      
		HEX	38,48,58,68,88,98,A8,B8      
;;;			 8  9  A  B  C  D  E
		HEX	C8,C8,C8,C8,C8,C8,C8   
;;;			 F 10 11 12 13 14 15 16
		HEX	B8,A8,98,78,68,58,48,38
;;;			17 18 19 1A 1B 1C 1D 
		HEX	28,28,28,28,28,28,28
HRSTYL		EQU	$
;;;			 0  1  2  3  4  5  6  7      
		HEX	38,38,38,38,38,38,38,38      
;;;			 8  9  A  B  C  D  E
		HEX	48,58,68,78,98,A8,B8   
;;;			 F 10 11 12 13 14 15 16
		HEX	C8,C8,C8,C8,C8,C8,C8,C8
;;;			17 18 19 1A 1B 1C 1D 
		HEX	B8,A8,98,78,68,58,48   
HRSTMK		EQU	$
;;;			 0  1  2  3  4  5  6  7      
		HEX	02,02,02,02,02,02,02,02      
;;;			 8  9  A  B  C  D  E
		HEX	01,01,01,01,01,01,01   
;;;			 F 10 11 12 13 14 15 16
		HEX	03,03,03,03,03,03,03,03
;;;			17 18 19 1A 1B 1C 1D 
		HEX	00,00,00,00,00,00,00   
; - - - - - - - -
HARI0CK		EQU	$
;;		LDA	<FRCNT
;;		AND	#00H
;;		ORA	<GAMEMD
;;		ORA	ENSTFG
;;		BNE	HCK0A0
;
		DEC	ENKBMK,X
		BNE	HCK0A0
;
		LDA	#20H*2
		STA	ENKBMK,X
;
		LDA	#HARI0
		JSL	>ENIDSH
		BMI	HCK0A0
;
		PHX
;
		JSL	>RNDSET
		AND	#1FH
		CMP	#1EH
		BCC	HCK001
		SBC	#1EH
HCK001		EQU	$
		TAX
		LDA	HRSTXL,X
		STA	ENXPSL,Y
		STA	ENWRK0,Y
		LDA	HRSTYL,X
		DEC	A
		STA	ENYPSL,Y
		STA	ENWRK1,Y
;
		LDA	HRSTMK,X
		STA	ENMUKI,Y
;
		LDA	#01H
		STA	ENWRK3,Y
		CLC
		ADC	NOWRMX
		STA	ENXPSH,Y
		LDA	#01H
		CLC
		ADC	NOWRMY
		STA	ENYPSH,Y
		TYX
		LDA	#01H
		STA	ENXSPD,X
		JSL	>PSSAVE2
;;		JSL	>ENBGCKL
		JSR	ENBGCK
		STZ	ENXSPD,X
;
		LDA	ENWRK0,X
		STA	ENXPSL,X
		LDA	ENWRK1,X
		STA	ENYPSL,X
;
		LDA	ENCBFG,X
		BNE	HCK070		; Set ok ?
		STZ	ENMODE,X	; No!
		PLX
		LDA	#01H
		STA	ENKBMK,X	; Next set ready !
		RTS
HCK070		EQU	$
		PLX
HCK0A0		EQU	$
		RTS
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Mini dragon     	               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CHIBIMV		EQU	$
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		JSR	ENHNSB		
;
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
		JSR	CREKEK
;
		STZ	ENMOD7,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	CBSET
		WORD	CBWALK
		WORD	CBFIRE
;-----------------------------------
;CBWKXS		EQU	$
;		HEX	10,F0  ;,00,00
;CBWKYS		EQU	$
;		HEX	00,00,10,F0
;- - - - - - - - - - - - - - - - - - - - -
CBCKXS		EQU	$
		HEX	01,FF,00,00
CBCKYS		EQU	$
		HEX	00,00,01,FF
;
CBSET		EQU	$
		INC	ENSTAT,X
		JSL	>RNDSET
;;		AND	#1FH
;;		ADC	#30H
;;		STA	ENTIM0,X
		AND	#03H
		STA	ENMUKI,X
;;		CLC
;;		ADC	#03H
;;		AND	#03H
;;		INC	A
;;		STA	ENWRK3,X
;
		LDA	#10110000B
		STA	ENMOD7,X	; Wide BG check area !
;
CBS010		EQU	$
		LDY	ENMUKI,X
		LDA	CBCKXS,Y
		STA	ENXSPD,X
		LDA	CBCKYS,Y
		STA	ENYSPD,X
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	CBSDST
		LDA	ENMUKI,X
		INC	A
		AND	#03H
		STA	ENMUKI,X
		BRA	CBS010				
;
;
CBSDST		EQU	$
		LDY	ENMUKI,X
		LDA	CBWKXS,Y
		STA	ENXSPD,X
		LDA	CBWKYS,Y
		STA	ENYSPD,X
		RTS
;-------------------------------------------
CBWCPT		EQU	$	
		HEX	02,02,00,05
		HEX	03,03,00,05
CBWMKD		EQU	$
		HEX	40,00,00,00
		HEX	40,00,40,40
;- - - - - - - - - - - - -
CBWALK		EQU	$		
		JSR	ENMVCL
;
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	CBW020
;
;;		STZ	ENSTAT,X
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
		JSR	CBSDST
CBW020		EQU	$
;;		LDA	ENTIM0,X
;;		BNE	CBW010
		LDA	ENXPSL,X
		AND	#00011111B
		CMP	#04H
		BNE	CBW010
;
		LDA	ENYPSL,X
		AND	#00011111B
		CMP	#1BH
		BNE	CBW010		;Turn point ?
;					; yes !
		JSL	>RNDSET
		AND	#03H
		BNE	CBW010
;
		LDA	#09FH-30H
		STA	ENTIM0,X
		INC	ENSTAT,X
		STZ	ENWRK0,X
CBW010		EQU	$
;
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#04H
		ORA	ENMUKI,X
		TAY
		LDA	CBWCPT,Y
		STA	ENCHPT,X
;
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	CBWMKD,Y
		STA	ENCLOR,X
		RTS
;---------------------------------------------
CBFRPT		EQU	$	
		HEX	02,02,00,05
		HEX	04,04,01,06
;- - - - - - - - - - - - - - -
CBFIRE		EQU	$
		LDA	ENTIM0,X
		BNE	CBF010
;
		STZ	ENSTAT,X
CBF010		EQU	$
		LDY	#00H
		SEC
		SBC	#20H
		CMP	#60H-30H
		BCS	CBF020
		LDY	#04H
CBF020		EQU	$
		CPY	#04H
		BNE	CBF030
;
		LDA	ENTIM0,X
		AND	#0FH
		BNE	CBF030
;
		PHY
		JSR	CHFIRST
		PLY
CBF030		EQU	$
		TYA
		ORA	ENMUKI,X
		TAY
		LDA	CBFRPT,Y
		STA	ENCHPT,X
		RTS
;--------------------------
CHFSXL		EQU	$
		HEX	08,F8,00,00
CHFSXH		EQU	$
		HEX	00,FF,00,00
CHFSYL		EQU	$
		HEX	00,00,08,F8
CHFSYH		EQU	$
		HEX	00,00,00,FF
CHFSXS		EQU	$
		HEX	18,E8,00,00
CHFSYS		EQU	$
		HEX	00,00,18,E8
CHFSZS		EQU	$
		HEX	40,38,30,28,20,18   
;
CHFIRST		EQU	$
		LDA	#CHFIR
		LDY	#0DH
		JSL	>ENIDSH2
		BMI	CHFS10
;
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	<WORK0
		CLC
		ADC	CHFSXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	CHFSXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	CHFSYL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	CHFSYH,X
		STA	ENYPSH,Y
		LDA	CHFSXS,X
		STA	ENXSPD,Y
		LDA	CHFSYS,X
		STA	ENYSPD,Y
		LDA	#01H
		STA	ENNOCR,Y
;;		PLX
;;		PHX
;;		LDA	ENWRK0,X
;;		INC	ENWRK0,X
;;		TAX
;;		LDA	CHFSZS,X
;;		STA	ENZSPD,Y
;;		LDA	#40H
;;		STA	ENTIM1,Y
		PLX
CHFS10		EQU	$
		RTS
;=============
CREKEK		EQU	$
		JSL	>CRKNENL
CRENPL		EQU	$
		JSR	>CRENPLL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Mini dragon fire     	               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CHFCLD		EQU	$
		HEX	00,40,C0,80
;
CHFIRMV		EQU	$
		LDA	ENTIM0,X
		BNE	CHF200
;
;;		LDA	ENTIM1,X
;;		BEQ	CHF001
;;		LDA	#08H*4
;;		JSL	>OAMENT3
;;CHF001		EQU	$
;
		JSL	>EN1CSTL
		JSR	ENSTCK
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	CHFCLD,Y
		STA	ENCLOR,X
;
		JSR	CRENPL
		BCS	CHF003
;
		JSR	ENMVCL  ;2
;;		JSR	ENZCLC
;
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BNE	CHF003
		RTS
;;		BEQ	CHF002
;;;
;;		STZ	ENXSPD,X
;;		STZ	ENYSPD,X
CHF002		EQU	$
;;		LDA	ENZSPD,X
;;		SEC
;;		SBC	#02H
;;		STA	ENZSPD,X
;;		LDA	ENZPSL,X
;;		BPL	CHF010
;
CHF003		EQU	$
;;		STZ	ENZPSL,X
		LDA	#7FH
		STA	ENTIM0,X
;
		LDA	ENCLOR,X
		AND	#00111111B
		STA	ENCLOR,X
;
;;		JSL	>SDLRCE
;;		ORA	#2AH
;;		STA	SOUND2	;(S)
		LDA	#2AH
		JSL	>SDLRE2	;(S)
;
CHF010		EQU	$
		RTS
;===================================
CHFPTD		EQU	$
		HEX	05,04,03,01,02,00,03,00
		HEX	01,02,03,00,01,02,03,00
		HEX	01,02,03,00,01,02,03,00
		HEX	01,02,03,00,01,02,03,00
;- - - - - - - - - - - - - - - 
CHF200		EQU	$
		JSL	>CRKNENL
		BCC	CHF208		; Ken hit ?
;
		DEC	ENTIM0,X	; yes ! high speed !
		BEQ	CHF20A
CHF208		EQU	$
		LDA	ENTIM0,X
		DEC	A
		BNE	CHF210
CHF20A		EQU	$
		STZ	ENMODE,X
CHF210		EQU	$
		LDA	ENTIM0,X
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	CHFPTD,Y
		STA	ENCHPT,X
		JSL	>CHFIRCS
;
		JMP	CRENPL
;;		RTS
;==============================
CHFIRCD		EQU	$
		WORD	00000H,0000H
		HEX	8E,01,00,02
		WORD	00000H,0000H
		HEX	8E,01,00,02
;
		WORD	0000H,0000H
		HEX	A0,01,00,02
		WORD	0000H,0000H
		HEX	A0,01,00,02
;
		WORD	00000H,0000H
		HEX	8E,41,00,02
		WORD	00000H,0000H
		HEX	8E,41,00,02
;
		WORD	0000H,0000H
		HEX	A0,41,00,02
		WORD	0000H,0000H
		HEX	A0,41,00,02
;
		WORD	0000H,0000H
		HEX	A2,01,00,02
		WORD	0000H,0000H
		HEX	A2,01,00,02
;
		WORD	0000H,0FFFAH
		HEX	A4,01,00,0
		WORD	0008H,0FFFAH
		HEX	A5,01,00,00
;
CHFIRCS		EQU	$
		PHB
		PHK
		PLB
;
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A		
		ADC	#CHFIRCD
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JSR	SETO22
		PLB
		RTL
;L		JSL	>SETOAML22
;
;;		LDA	ENDSPL,X
;;		BNE	CHFC90
;;;
;;		JSL	>SADWSTL
;;CHFC90		EQU	$
;L		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Skelton move    	               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SKATDT		EQU	$
		HEX	30,00,00,00,30,00
;
SKELTMV		EQU	$
		LDA	ENWRK0,X
		BNE	SKM003		; Initial OK ?
;					; yes !
		LDA	#01H
		STA	ENXSPD,X
		STA	ENYSPD,X
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	SKM002		; In BG ?
;					; YES ! Can't set !
		STZ	ENMODE,X 
		RTS
SKM002		EQU	$
		INC	ENWRK0,X
		LDA	#0AH
		STA	ENWRK2,X
;
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X
;
;;		JSL	>SDLRCE
;;		ORA	#20H
;;		STA	SOUND2	;(S)
		LDA	#20H
		JSL	>SDLRE2	;(S)
SKM003		EQU	$
		LDY	ENSTAT,X
		LDA	ENFLCL,X
		ORA	SKATDT,Y
		STA	ENFLCL,X
		JSR	SKELTCS
;
		JSR	ENSTCK
;
		LDA	>ITMTBL6
		CMP	#03H
		BCC	SKM004		; ken high power ?
;					; yes ! damage !
		JSR	ENHNSB
		BRA	SKM005
SKM004		EQU	$
		LDA	ENSTAT,X
		CMP	#05H
		BEQ	SKM005		; Tubureru !
;
		LDA	ENFLSH,X
		BEQ	SKM005
;
		STZ	ENFLSH,X
;
;;		LDA	ENMOD2,X
;;		ORA	#01000000B
;;		STA	ENMOD2,X
;
		LDA	#05H
		STA	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
SKM005		EQU	$
;
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SKDOWN
		WORD	SKWAIT
		WORD	SKSHOT
		WORD	SKWAI2
		WORD	SKUP
		WORD	SKFAIL
;--------------------------------------------------------
SKDOWN		EQU	$
		LDA	#02H
		STA	ENKBMK,X
;
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	SKM008
		SEC
		SBC	#03H
		STA	ENZSPD,X
SKM008		EQU	$
		PLA
		EOR	ENZPSL,X
		BPL	SKM00C
;
		LDA	ENZPSL,X
		BPL	SKM00C
;
		INC	ENSTAT,X
;
		STZ	ENZPSL,X
		STZ	ENZSPD,X
;
		LDA	#40H
		STA	ENTIM0,X
;
		JSR	SKPTST
SKM00C		EQU	$		
		RTS
;------------------------------------------------------
SKWAIT		EQU	$
		STZ	ENNOCR,X
		JSR	CREKEK
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
;
		LDA	ENTIM0,X
		BNE	SKW010
		INC	ENSTAT,X
		LDA	#07FH
		STA	ENTIM0,X
SKW010		EQU	$
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
		RTS
;------------------------------------------------------
SKSHPT		EQU	$
		HEX	08,05,01,01
		HEX	08,05,01,01
		HEX	08,05,01,01
		HEX	07,04,02,02
		HEX	07,04,02,02
		HEX	07,04,02,02
		HEX	07,04,02,02
		HEX	07,04,02,02
;
SKSXRV		EQU	$
		HEX	80,80,80,80,80,80,80,80
		HEX	80,80,80,80,00,00,00,00
		HEX	00,00,00,00,FF,00,01,00
		HEX	FF,00,01,00,00,00,00,00
SKSYRV		EQU	$
		HEX	0D,0D,0D,0D,0D,0D,0D,0D
		HEX	0D,0D,0D,0D,0D,0D,0D,0D
		HEX	0D,0C,0B,0A,0A,0A,0A,0A
		HEX	0A,0A,0A,0A,0A,0A,0A,0A
;
SKSHOT		EQU	$
		STZ	ENNOCR,X
		JSR	CREKEK
;;		JSL	>CRENPLL
		LDA	ENTIM0,X
		BNE	SKS010
		INC	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
		RTS
SKS010		EQU	$
		CMP	#30H
		BNE	SKS012
		PHA
		JSR	SKHEDST
		PLA
SKS012		EQU	$
		LSR	A
		LSR	A
;;		LSR	A
;;		LSR	A
;
;;		ASL	A
;;		ASL	A
		AND	#11111100B
		ORA	ENMUKI,X
		TAY
		LDA	SKSHPT,Y
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		LSR	A
		LSR	A
		TAY
		LDA	SKSXRV,Y
		STA	ENWRK1,X		
		LDA	SKSYRV,Y
		STA	ENWRK2,X		
		JMP	SKW010
;------------------------------------------------------
SKW2PT		EQU	$
		HEX	06,03,01,01
;
SKWAI2		EQU	$
		STZ	ENNOCR,X
		JSR	CREKEK
;;		JSL	>CRENPLL
		LDA	ENTIM0,X
		BNE	SKW210
;
		INC	ENSTAT,X
SKW210		EQU	$
SKPTST		EQU	$
		LDY	ENMUKI,X
		LDA	SKW2PT,Y
		STA	ENCHPT,X
;
		JMP	SKW010
;------------------------------------------------------
SKUP		EQU	$
		STZ	ENCHPT,X
		LDA	#02H
		STA	ENKBMK,X
;
		LDA	ENZPSL,X
		PHA
		JSR	ENZCLC
;
		LDA	ENZSPD,X
		CMP	#40H
		BPL	SKU010
;
		INC	A
		INC	A
		STA	ENZSPD,X
SKU010		EQU	$
		PLA	
		EOR	ENZPSL,X
		BPL	SKU030
;
		LDA	ENZPSL,X
		BMI	SKU030
;
		STZ	ENMODE,X
SKU030		EQU	$
		RTS		
;------------------------------------------------------
SKFCDT		EQU	$
		HEX	1,1,1,9,A,A,A,A
		HEX	A,A,A,A,A,A,A,9
SKFYAD		EQU	$
		HEX	A,A,A,7,0,0,0,0
		HEX	0,0,0,0,0,0,0,7
;
SKFAIL		EQU	$
		STZ	ENNOCR,X
		JSL	>CRKNENL
;
		LDA	ENTIM0,X
		BNE	SKF010
		DEC	ENSTAT,X
SKF010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	SKFCDT,Y
		STA	ENCHPT,X
		LDA	SKFYAD,Y
		STA	ENWRK2,X
		RTS
;------------------------------------------------------
;------------------------------------------------------
;------------------------------------------------------
SKHEDST		EQU	$
		LDA	#SKHED
		JSL	>ENIDSH
		BMI	SHS080
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;
		LDA	#0DH
		STA	ENZPSL,Y
;
		PHX
		TYX
		LDA	#10H
		JSL	>PSERCHL
		PLX
		LDA	#0FFH
		STA	ENTIM0,Y
		LDA	#20H
		STA	ENTIM1,Y
SHS080		EQU	$
		RTS
;======================================================
;======================================================
;======================================================
;======================================================
;======================================================
;======================================================
SKELTCD		EQU	$
;0
		WORD	00H,00H
		HEX	0A,00,00,02
		WORD	00H,00H
		HEX	0A,00,00,02
;1
		WORD	00H,00H
		HEX	0C,00,00,02
		WORD	00H,00H
		HEX	0C,00,00,02
;2
		WORD	00H,00H
		HEX	2C,00,00,02
		WORD	00H,00H
		HEX	2C,00,00,02
;3
		WORD	05H,05H
		HEX	2E,00,00,00
		WORD	00H,00H
		HEX	24,00,00,02
;4
		WORD	04H,01H
		HEX	3E,00,00,00
		WORD	00H,00H
		HEX	24,00,00,02
;5
		WORD	00H,00H
		HEX	0E,00,00,02		
		WORD	00H,00H
		HEX	0E,00,00,02		
;6
		WORD	03H,05H
		HEX	2E,40,00,00
		WORD	00H,00H
		HEX	24,40,00,02
;7
		WORD	04H,01H
		HEX	3E,40,00,00
		WORD	00H,00H
		HEX	24,40,00,02
;8
		WORD	00H,00H
		HEX	0E,40,00,02
		WORD	00H,00H
		HEX	0E,40,00,02
;9
		WORD	00H,00H
		HEX	2A,00,00,02
		WORD	00H,00H
		HEX	2A,00,00,02
;A
		WORD	00H,00H
		HEX	2A,00,00,02
		WORD	00H,00H
		HEX	2A,00,00,02
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
;;0
;		WORD	00H,00H
;		HEX	8C,00,00,02
;		WORD	00H,00H
;		HEX	8C,00,00,02
;;1
;		WORD	00H,00H
;		HEX	A0,00,00,02
;		WORD	00H,00H
;		HEX	A0,00,00,02
;;2
;		WORD	00H,00H
;		HEX	AA,00,00,02
;		WORD	00H,00H
;		HEX	AA,00,00,02
;;3
;		WORD	05H,05H
;		HEX	AC,00,00,00
;		WORD	00H,00H
;		HEX	A4,00,00,02
;;4
;		WORD	04H,01H
;		HEX	BC,00,00,00
;		WORD	00H,00H
;		HEX	A4,00,00,02
;;5
;		WORD	00H,00H
;		HEX	A2,00,00,02		
;		WORD	00H,00H
;		HEX	A2,00,00,02		
;;6
;		WORD	03H,05H
;		HEX	AC,40,00,00
;		WORD	00H,00H
;		HEX	A4,40,00,02
;;7
;		WORD	04H,01H
;		HEX	BC,40,00,00
;		WORD	00H,00H
;		HEX	A4,40,00,02
;;8
;		WORD	00H,00H
;		HEX	A2,40,00,02
;		WORD	00H,00H
;		HEX	A2,40,00,02
;;9
;		WORD	00H,00H
;		HEX	A6,00,00,02
;		WORD	00H,00H
;		HEX	A6,00,00,02
;;A
;		WORD	00H,00H
;		HEX	A8,00,00,02
;		WORD	00H,00H
;		HEX	A8,00,00,02
;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
SKELTCS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A		
		ADC	#SKELTCD
		STA	<WORK8
;
		LDA	<OAMADR
		CLC
		ADC	#04H
		STA	<OAMADR
;
		INC	<OSBADR
		MEM8
		SEP	#00100000B
;
		LDA	#02H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		MEM16	
		REP	#00100000B
		LDA	<OAMADR
		SEC
		SBC	#04H
		STA	<OAMADR
;
		DEC	<OSBADR
;
		MEM8
		SEP	#00100000B
;
		LDA	ENDSPL,X
		BNE	SKC099
;
		JSR	SKHEDCS
;
		JSL	>SADWSTL
SKC099		EQU	$
		RTS
;========================
SKHDCD		EQU	$
		BYTE	002H,002H,000H,004H
;;		BYTE	082H,082H,080H,084H
SKHDAD		EQU	$
		BYTE	040H,000H,000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - -
SKHEDCS		EQU	$
		LDA	ENCHPT,X
		CMP	#0AH
		BEQ	SHC090		; Hed nashi ?
;					; no
		LDA	ENWRK1,X	; X hosei !
		STZ	<WORKD
;
		CMP	#80H
		BEQ	SHC090		;Shooted hed ?
		STA	<WORKC		; no
		CMP	#00H
		BPL	SHC000
;
		DEC	<WORKD
SHC000		EQU	$
		LDA	ENWRK2,X	; Y hosei !
		STA	<WORKA
		STZ	<WORKB
;
		LDY	#00H
		PHX
		LDA	ENKBMK,X	; Kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	<WORKC
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		SEC
		SBC	<WORKA
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	TH2C11
		LDA	#00F0H
		STA	(<OAMADR),Y
TH2C11		EQU	$
		MEM8
		SEP	#00100000B
		LDA	SKHDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	SKHDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
SHC090		EQU	$
		RTS
;==============================
;----------------------------------------
MEDAMITJ	EQU	$
                LDA     ERXYCT
                CMP     #00CH
                BEQ     MTEF0I
                CMP     #01BH
                BEQ     MTEF0I
                CMP     #04BH
                BEQ     MTEF0I
                CMP     #06BH
                BNE     MTEF8I
MTEF0I		EQU	$
		INC	ENWRK1,X	; Copy medaman set !
;
		LDA	ENMYNO,X
		CMP	#MEDAM
		BNE	MTEF8I
;
		STZ	ENMOD5,X
MTEF8I		EQU	$
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Medama kun   move	               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;=================================================
;;
;YACRDT		EQU	$		; OBJ hit size
;		BYTE	5,5,6,6 
;YASTXS		EQU	$
;		HEX	20,E0,00,00
;YASTYS		EQU	$
;		HEX	00,00,20,E0
;;
;HYAASET		EQU	$
;		LDA	#YATAM
;		JSL	>ENIDSH
;		BMI	HYS010
;;
;		JSL	>ENIDPS
;		LDA	<WORK0
;		CLC
;		ADC	#04H
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		ADC	#00H
;		STA	ENXPSH,Y
;;
;		JSL	>SDLRCE
;		ORA	#05H
;		STA	SOUND3	;(S)
;;
;		PHX
;		LDA	ENMUKI,X
;		TAX
;		LDA	YACRDT,X
;		STA	ENMOD3,Y
;		LDA	YASTXS,X
;		STA	ENXSPD,Y
;		LDA	YASTYS,X
;		STA	ENYSPD,Y
;		PLX
;HYS010		EQU	$
;		RTS
;
MDTXSD		EQU	$
;;;;			0  1  2  3  4  5  6  7  8  9  A
		HEX	0,10,F0,00,00,0D,F3,00,00,0D,F3
		HEX	0,0,0,0,0
		HEX	0,E8,18,00,00,F0,10,00,00,F0,10
		HEX	0,0,0,0,0
MDTYSD		EQU	$
		HEX	0,00,00,00,F0,FB,FB,00,10,0D,0D
		HEX	0,0,0,0,0
		HEX	0,00,00,00,E8,F0,F0,00,18,10,10
		HEX	0,0,0,0,0
MDTEST		EQU	$
		HEX	0,00,01,00,03,03,03,00,02,02,02
		HEX	0,0,0,0,0
		HEX	0,01,00,00,03,03,03,00,02,02,02
		HEX	0,0,0,0,0
;
CPMVPT		EQU	$
		HEX	8,6,0,3
		HEX	9,7,1,4
		HEX	8,6,0,3
		HEX	9,7,2,5
;
;		HEX	8,9,8,9
;		HEX	6,7,6,7
;		HEX	0,1,2,1
;		HEX	3,4,5,4
;
MDT050		EQU	$
		STZ	ENWRK0,X
;;;		STZ	ENCHPT,X
		JSR	CREKEK
		JSR	ENBGCK
		RTS
MEDAMMV		EQU	$
MEDA2MV		EQU	$	; Red !
;========= Action test ===== 7/19 ======
;		LDA	ERXYCT
;		CMP	#01BH
;		BEQ	MTEF0
;		CMP	#04BH
;		BEQ	MTEF0
;		CMP	#06BH
;		BEQ	MTEF0
;
		LDA	ENWRK1,X
		BNE	MTEF0		; Normal ?
;					; yes !
		JMP	MT0000
;--- Copy dammys --
MTEF0		EQU	$
;;		CPX	#00H
;;		BNE	MTE000
;;		LDA	#00000111B
;;		STA	ENCLOR,X
;;MTE000		EQU	$
;;		JSR	MEDAMCS
		JSL	>COPYCS
;
		JSR	ENSTCK
		JSR	ENHNSB
;
		LDA	ENTIM1,X
		BEQ	MTE001
		CMP	#08H
		BNE	MTE001
;
;;		JSR	HYAASET
		JSL	>TKTAMST
MTE001		EQU	$
		LDA	HANIFG1
		CMP	#00H
		BNE	MDT050	
;
		LDY	ENMYNO,X
;
		LDA	<KEYA1
		AND	#0FH
		BEQ	MDT050
		CPY	#MEDA2
		BNE	MTW000
		ORA	#10H
MTW000		EQU	$
		TAY
;
;;		LDA	#00000100B
;;		STA	ENMOD5,X
;;		LDA	ENMOD2,X
;;		ORA	#01000000B
;;		STA	ENMOD2,X
;
		LDA	MDTEST,Y
		STA	ENMUKI,X
		LDA	MDTXSD,Y
		STA	ENXSPD,X
		LDA	MDTYSD,Y
		STA	ENYSPD,X
;;		ORA	ENXSPD,X
;
;;		BEQ	MTW011
;
;;		STZ	ENMOD5,X
;;		LDA	ENMOD2,X
;;		AND	#10111111B
;;		STA	ENMOD2,X
MTW011		EQU	$
		LDA	ENCBFG,X
		BNE	MTW030
		JSR	ENMVCL
MTW030		EQU	$
		JSR	CREKEK
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
;;		INC	ENCONT,X
;;		LDA	ENCONT,X
;;		AND	#00001100B
;;		ORA	ENMUKI,X
;;		TAY
;;		LDA	MDWKPT,Y
;;		STA	ENCHPT,X
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#00001100B
		ORA	ENMUKI,X
		TAY
		LDA	CPMVPT,Y
		STA	ENCHPT,X

;
;;		CPX	#00H 
;;		BNE	MTE900
		LDA	ENMYNO,X
		CMP	#MEDA2
		BNE	MTE900		; Ya shot ?
;					; yes !
		JSR	EPXYCK
		LDA	<WORKF
		CLC
		ADC	#08H
		CMP	#10H
		BCC	MTE300
;
		LDA	<WORKE
		CLC
		ADC	#08H
		CMP	#10H
		BCS	MTE900
MTE300		EQU	$
		TYA
		CMP	ENMUKI,X
		BNE	MTE900
;
		LDA	ENWRK0,X
		AND	#01FH
		BNE	MTE800
;
		LDA	#10H
		STA	ENTIM1,X
;;		JSR	HYAASET
;
MTE800		EQU	$
		INC	ENWRK0,X
		RTS
;
MTE900		EQU	$
		STZ	ENWRK0,X
		RTS
;
;=============================================
MT0000		EQU	$
		JSR	MEDAMCS
;
		JSR	ENSTCK
		JSR	ENHNSB
;
		JSR	CREKEK
;;		LDA	#01H
;;		STA	ENNOCR,X
;
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X	; Not damage 
;
		LDA	ENMOD5,X
		ORA	#00000100B
		STA	ENMOD5,X	; Katame !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MDSTOP
		WORD	MDWKWT
		WORD	MDWALK
		WORD	MDWKW2
;-----------------------------------------------------
MDMVTM		EQU	$
		HEX	60,80,A0,80
;
MDSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	MDS090
;
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#30H
		CMP	#60H
		BCS	MDS090
		LDA	<WORKF
		CLC
		ADC	#30H
		CMP	#60H
		BCS	MDS090
;
		INC	ENSTAT,X
;
		LDA	#3FH
		STA	ENTIM0,X
MDS090		EQU	$
		RTS
;-----------------------------------------
MDWWPT		EQU	$
		HEX	2,2,2,2,1,1,0,0
;
MDWKWT		EQU	$
		LDA	ENTIM0,X
		BNE	MDWW10
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	MDMVTM,Y
		STA	ENTIM0,X
		RTS
;
MDWW10		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	MDWWPT,Y
		STA	ENCHPT,X
		RTS
;-----------------------------------------
;MDWXSD		EQU	$
;		HEX	10,F0  ;,00,00
;MDWYSD		EQU	$
;		HEX	00,00,10,F0
MDWKPT		EQU	$
		HEX	07,05,02,09
		HEX	08,06,03,0A
		HEX	07,05,02,09
		HEX	08,06,04,0B
;- - - - - - - - - - - - - - - - 
MDWALK		EQU	$
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
;
		LDA	ENMYNO,X
		CMP	#MEDA2
		BEQ	MDW000		; High power ?
;					; no
		LDA	ENMOD5,X	; ken damege on !
		AND	#11111011B
		STA	ENMOD5,X
;
MDW000		EQU	$
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
;
;;		STZ	ENNOCR,X
;
		LDA	ENTIM0,X
		BNE	MDW010
;
		LDA	#3FH
		STA	ENTIM0,X
		INC	ENSTAT,X
		STZ	ENCHPT,X
		RTS
;
MDW010		EQU	$
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	MDW020
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
MDW020		EQU	$
		LDY	ENMUKI,X
		LDA	MDWXSD,Y
		STA	ENXSPD,X
		LDA	MDWYSD,Y
		STA	ENYSPD,X
;
		LDA	ENCBFG,X
		BNE	MDW030
		JSR	ENMVCL
MDW030		EQU	$
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#00001100B
		ORA	ENMUKI,X
		TAY
		LDA	MDWKPT,Y
		STA	ENCHPT,X
		RTS
;------------------------------------------
MDW2PT		EQU	$
		HEX	0,0,1,1,2,2,2,2
;
MDWKW2		EQU	$
		LDA	ENTIM0,X
		BNE	MDW210
;
		STZ	ENSTAT,X
		LDA	#60H
		STA	ENTIM0,X
		RTS
;
MDW210		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	MDW2PT,Y
		STA	ENCHPT,X
		RTS
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;;		LDA	<KEYA2
;;		AND	#00001100B
;;		BEQ	MDM010
;;;
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#0DH
;;		BNE	MDM010
;;;
;;		STZ	ENCHPT,X
;;MDM010		EQU	$
;;		RTS
;==========================================
MEDAMCD		EQU	$
;0
		WORD	0FFFCH,0FFFCH
		HEX	A2,00,00,02
		WORD	00004H,0FFFCH
		HEX	A2,40,00,02
		WORD	0FFFCH,00004H
		HEX	9C,00,00,02
		WORD	00004H,00004H
		HEX	9C,40,00,02
;1
		WORD	0FFFCH,0FFFCH
		HEX	A4,00,00,02
		WORD	00004H,0FFFCH
		HEX	A4,40,00,02
		WORD	0FFFCH,00004H
		HEX	9C,00,00,02
		WORD	00004H,00004H
		HEX	9C,40,00,02
;2
		WORD	0FFFCH,0FFFCH
		HEX	8C,00,00,02
		WORD	00004H,0FFFCH
		HEX	8C,40,00,02
		WORD	0FFFCH,00004H
		HEX	9C,00,00,02
		WORD	00004H,00004H
		HEX	9C,40,00,02
;3
		WORD	0FFFCH,0FFFDH
		HEX	8C,00,00,02
		WORD	0000CH,0FFFDH
		HEX	8C,40,00,00
		WORD	0FFFCH,0000DH
		HEX	BC,00,00,00
		WORD	00004H,00005H
		HEX	8A,40,00,02
;4
		WORD	0FFFCH,0FFFDH
		HEX	8C,00,00,00
		WORD	00004H,0FFFDH
		HEX	8C,40,00,02
		WORD	0FFFCH,00005H
		HEX	8A,00,00,02
		WORD	0000CH,0000DH
		HEX	BC,40,00,00
;5
		WORD	00000H,0FFFCH
		HEX	AA,00,00,02
		WORD	00000H,00004H
		HEX	A6,00,00,02
		WORD	00000H,0FFFCH
		HEX	AA,00,00,02
		WORD	00000H,00004H
		HEX	A6,00,00,02
;6
		WORD	00000H,0FFFDH
		HEX	AA,00,00,02
		WORD	00000H,00004H
		HEX	A8,00,00,02
		WORD	00000H,0FFFDH
		HEX	AA,00,00,02
		WORD	00000H,00004H
		HEX	A8,00,00,02
;7
		WORD	00000H,0FFFCH
		HEX	AA,40,00,02
		WORD	00000H,00004H
		HEX	A6,40,00,02
		WORD	00000H,0FFFCH
		HEX	AA,40,00,02
		WORD	00000H,00004H
		HEX	A6,40,00,02
;8
		WORD	00000H,0FFFDH
		HEX	AA,40,00,02
		WORD	00000H,00004H
		HEX	A8,40,00,02
		WORD	00000H,0FFFDH
		HEX	AA,40,00,02
		WORD	00000H,00004H
		HEX	A8,40,00,02
;9
		WORD	0FFFCH,0FFFCH
		HEX	8E,00,00,02
		WORD	00004H,0FFFCH
		HEX	8E,40,00,02
		WORD	0FFFCH,00004H
		HEX	9E,00,00,02
		WORD	00004H,00004H
		HEX	9E,40,00,02
;A
		WORD	0FFFCH,0FFFDH
		HEX	8E,00,00,02
		WORD	0000CH,0FFFDH
		HEX	8E,40,00,00
		WORD	0FFFCH,0000DH
		HEX	BD,00,00,00
		WORD	00004H,00005H
		HEX	A0,40,00,02
;B
		WORD	0FFFCH,0FFFDH
		HEX	8E,00,00,00
		WORD	00004H,0FFFDH
		HEX	8E,40,00,02
		WORD	0FFFCH,00005H
		HEX	A0,00,00,02
		WORD	0000CH,0000DH
		HEX	BD,40,00,00
;--------------------------------------------
MEDAMCS		EQU	$
		LDA	#00H
		XBA
		LDA	ENCHPT,X
		MEM16
		REP	#00100000B
		ASL	A
		ASL	A
		ASL	A
;
		ASL	A
		ASL	A		
		ADC	#MEDAMCD
		STA	<WORK8
;;		LDA	#HIGH MEDAMCD
;;		ADC	#00H
;;		STA	<WORK9
		MEM8
		SEP	#00100000B
;
		LDA	#04H
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		LDA	ENDSPL,X
		BNE	MDC090
;
		LDA	#0EH
		JSL	>SADWS2L
MDC090		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Spin many babul move	               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BBITXL		EQU	$
		HEX	0A,14,0A
BBITXH		EQU	$
		HEX	00,00,00
BBITYL		EQU	$
		HEX	F6,00,0A
BBITYH		EQU	$
		HEX	FF,00,00
BBITXS		EQU	$
		HEX	12,00,EE
BBITW0		EQU	$
		HEX	01,01,00
BBITYS		EQU	$
		HEX	00,12,00
BBITW1		EQU	$
		HEX	00,01,01
;=========================================================
BABU2IT		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#0AH
		STA	ENXPSL,X
		LDA	ENXPSH,X
		SBC	#00H
		STA	ENXPSH,X
;
		LDA	#0EEH
		STA	ENYSPD,X
		LDA	#00H
		STA	ENXSPD,X
		LDA	#00H
		STA	ENWRK0,X
		LDA	#00H
		STA	ENWRK1,X
;
		LDA	#02H
		STA	ENHELP
;
BBI010		EQU	$
		LDA	#BABU2
		JSL	>ENIDSH
		BMI	BBI090
;
		PHX
		LDX	ENHELP
		LDA	<WORK0
		CLC
		ADC	>BBITXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	>BBITXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	>BBITYL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	>BBITYH,X
		STA	ENYPSH,Y
;
		LDA	>BBITXS,X
		STA	ENXSPD,Y
		LDA	>BBITYS,X
		STA	ENYSPD,Y
		LDA	>BBITW0,X
		STA	ENWRK0,Y
		LDA	>BBITW1,X
		STA	ENWRK1,Y
		PLX
BBI090		EQU	$
		DEC	ENHELP
		BPL	BBI010
;
		RTL
;=========================================================
BBLPTD		EQU	$
		HEX	0,1,0,1
BBLADT		EQU	$
		HEX	00,00,40,40
BBXSAD		EQU	$
BBYSAD		EQU	$
		HEX	01,FF
BBXSLM		EQU	$
BBYSLM		EQU	$
		HEX	12,EE
;
BABU2MV		EQU	$
;;		JSL	>EN1CSTL
		JSL	>BABULCSL
;
		JSR	ENSTCK
;
;;		INC	ENCONT,X
;;		LDA	ENCONT,X
;;		LSR	A
;;		AND	#03H
;;		TAY
;;		LDA	BBLPTD,Y
;;		STA	ENCHPT,X
;;		LDA	ENCLOR,X
;;		AND	#10111111B
;;		ORA	BBLADT,Y
;;		STA	ENCLOR,X
;
;;		LDA	ENCONT,X
;;		AND	#00H
;;		BNE	BB2020
;
		LDA	ENWRK0,X
		AND	#01H
		TAY
		LDA	ENXSPD,X
		CLC
		ADC	BBXSAD,Y
		STA	ENXSPD,X
		CMP	BBXSLM,Y
		BNE	BB2010
		INC	ENWRK0,X
BB2010		EQU	$
		LDA	ENWRK1,X
		AND	#01H
		TAY
		LDA	ENYSPD,X
		CLC
		ADC	BBYSAD,Y
		STA	ENYSPD,X
		CMP	BBYSLM,Y
		BNE	BB2020
		INC	ENWRK1,X
BB2020		EQU	$
		JSR	ENMVCL
;
		LDA	ENXSPD,X
		BEQ	BB2030
		LDA	ENYSPD,X
		BEQ	BB2030
;
;;		LDA	<KEYA2
;;		AND	#10000000B
;;		BEQ	BB2030
		JSL	>EFLCHK2
		BCC	BB2030		; All enemy clear ?
;					; yes ! bunshin !
		LDA	#BABUL
		STA	ENMYNO,X
;
		LDA	#010H
		LDY	ENXSPD,X
		BPL	BB2023
		LDA	#0F0H
BB2023		EQU	$
		STA	ENXSPD,X
;
		LDA	#010H
		LDY	ENYSPD,X
		BPL	BB2025
		LDA	#0F0H
BB2025		EQU	$
		STA	ENYSPD,X
BB2030		EQU	$
		JSR	CRENPL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Amenbo    move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AMENBMV		EQU	$
		LDA	ENFLCL,X
		ORA	#00110000B
		STA	ENFLCL,X	;Mujyoken BG yusen !! (for water )
;
		JSL	>EN1CSTL
;
		JSR	ENSTCK
		LDA	ENHNFG,X
		BEQ	AMB000
;
		STZ	ENSTAT,X
AMB000		EQU	$
		JSR	ENHNSB
;
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
		JSR	CREKEK
;
		LDA	ENCBFG,X
		BNE	AM0010
;
		JSR	ENMVCL
AM0010		EQU	$
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
;;                LDA     ENZPSL,X
;;                BNE     AM0010
;;;
;;		STZ	ENWRK0,X
;;;
;;                LDA     UNITNO
;;                CMP     #08H
;;                BEQ     AM0010          ; MIZU IN ?
;;                CMP     #09H
;;                BEQ     AM0010          ; MIZU IN ?
;;;
;;		INC	ENWRK0,X	; No ! 
;;AM0010		EQU	$
		INC	ENCONT,X
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#02H
		STA	ENCHPT,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	AM0100
		WORD	AM0200
;- - - - - - - - - - - - - - - - - -
AMMKDT		EQU	$
		HEX	40,00,40,00
;
AM0100		EQU	$
		LDA	ENTIM0,X
		BNE	AM0110
;
		INC	ENSTAT,X
		JSR	EPXCHK
		STY	<WORKC
		JSR	EPYCHK
		TYA
		ASL	A
		ORA	<WORKC
		STA	ENMUKI,X
;
		TAY
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	AMMKDT,Y
		STA	ENCLOR,X
;
		JSL	>RNDSET
		AND	#0FH
		ADC	#0CH
;;		LDA	#18H
		STA	ENTIM0,X
;
		JSR	ENSDCL
AM0110		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
AMXSAD		EQU	$
		HEX	01,FF,01,FF
AMYSAD		EQU	$
		HEX	01,01,FF,FF
AMXSA2		EQU	$
		HEX	FF,01,FF,01
AMYSA2		EQU	$
		HEX	FF,FF,01,01
;-------------
AM0200		EQU	$
		LDA	ENTIM0,X
		BEQ	AM0220
;
		LDY	ENMUKI,X
		LDA	ENXSPD,X
		CLC
		ADC	AMXSAD,Y
		STA	ENXSPD,X
		LDA	ENYSPD,X
		CLC
		ADC	AMYSAD,Y
		STA	ENYSPD,X
;
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
		RTS
;- - -
AM0220		EQU	$
		LDY	ENMUKI,X
		LDA	ENXSPD,X
		CLC
		ADC	AMXSA2,Y
		STA	ENXSPD,X
		LDA	ENYSPD,X
		CLC
		ADC	AMYSA2,Y
		STA	ENYSPD,X
		BNE	AM0230
;
		STZ	ENSTAT,X
;
		LDA	#40H
		STA	ENTIM0,X
AM0230		EQU	$
		RTS		
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	POLIW   move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
POLIWSP		EQU	$
;		BYTE	24,25,26,27,28,29,30,31
;		BYTE	32,31,29,28,27,26,25,24
;
;=============== Color datas ===========================================
CLRDT00		EQU	$
		WORD	00000H
		WORD	03821H
		WORD	04463H
		WORD	054A5H
		WORD	05CE7H
		WORD	06D29H
		WORD	079ADH
		WORD	07E10H
;
CLRDT01		EQU	$
;----------------------------------------
POLIWCG		EQU	$
		LDA     #033H		;OBJ KASAN TEST
		STA     <WD2131
		LDA     #000H
		STA     >CCNGCT
		STA     >CCNGFG
		PHX
		JSL     >PWTRCGS2
		JSL	>MGMCGRS2
		PLX
;
		MEM16			;COLOR SET
		IDX8
		REP	#00100000B
;
		LDA	>CLRDT00+000H
		STA	>CGWORK+0E0H+000H
		LDA	>CLRDT00+002H
		STA	>CGWORK+0E0H+002H
		LDA	>CLRDT00+004H
		STA	>CGWORK+0E0H+004H
		LDA	>CLRDT00+006H
		STA	>CGWORK+0E0H+006H
		LDA	>CLRDT00+008H
		STA	>CGWORK+0E0H+008H
		LDA	>CLRDT00+00AH
		STA	>CGWORK+0E0H+00AH
		LDA	>CLRDT00+00CH
		STA	>CGWORK+0E0H+00CH
		LDA	>CLRDT00+00EH
		STA	>CGWORK+0E0H+00EH
;
		MEM8
		IDX8
		SEP	#00110000B
;
		INC	<CGVMAF		;CG SET
;
		JSR	POLIWST
;
		JSR	POLIWIT
;
		RTL
;----------------------------------------
POLIWST		EQU	$		
		LDY	#0FH
		LDA	#00H
PS0001		EQU	$
		STA	ENMODE,Y
		DEY
		BPL	PS0001
;
;		MEM16
;		IDX8
;		REP	#00100000B
;		STZ	ENMODE+00H
;		STZ	ENMODE+02H
;		STZ	ENMODE+04H
;		STZ	ENMODE+06H
;		STZ	ENMODE+08H
;		STZ	ENMODE+0AH
;		STZ	ENMODE+0CH
;		STZ	ENMODE+0EH
;		MEM8
;		IDX8
;		SEP	#00110000B
;
		LDA	#POLIW
		JSL	>ENIDSH
;
		LDA	<PLXPS0		;POLIW INIT
		STA	ENXPSH,Y
		LDA	<PLYPS0
		STA	ENYPSH,Y
		LDA	#078H
		STA	ENXPSL,Y
		LDA	#07CH
		STA	ENYPSL,Y
;
		LDA	#001H
		STA	ENMUKI,Y
;
		LDA	#00BH
		STA	ENCLOR,Y
;
		LDA	#000H
		STA	ENCONT,Y
		STA	ENKAIF,Y
;
		PHY
		JSL	>BMCLER		;PL. CLYSTAL CLS
		STZ	!ITMVFG
		TYA
		PLY
		STA	ENWRK0,Y
;
		LDA	DJNNO
		CMP	#018H
		BNE	PLWST10
		LDA	#009H
		STA	ENCLOR,Y
		LDA	#prnce
		BRA	PLWST20
PLWST10		EQU	$
		LDA	#prnc1
PLWST20		EQU	$
		STA	>OPMODE
		PHX
		JSL	>OPTCBFST
		PLX
		LDA	#nashi
		STA	>OPMODE
;
		STZ	B1MFLG
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<PLXPS1
		SEC
		SBC	<SCCH2
		EOR	#0FFFFH
		SEC
		ADC	#00079H
		STA	BGMVC0		;X MOVE
;
		LDA	<SCCV1
		AND	#000FFH
		STA	<WORK0
		LDA	#00030H
		SEC
		SBC	<WORK0
		STA	BGMVC1		;Y MOVE
;
		MEM8
		IDX8
		SEP	#00110000B
		LDA	#001H
		STA	B1MFLG
		RTS
;----------------------------------------
POLIWIT		EQU	$
;
		LDA	#09CH		;POLIW SIZE (S)
		STA	object_size
;
		LDA	#001H		;light shading
		STA	shading_switch
;
;		LDA	#001H		;POLYGON WRITE FLG(MAIN)
		STA	POLYCFG
;
;		LDA	#001H		;POLYGON WRITE ON
		STA	polygon_flag
;
		LDA	#032		;CENTER X
		STA	center_point_x
;
;		LDA	#032		;CENTER Y
		STA	center_point_y
;
;		LDA	#032		;CENTER Z
		STA	center_point_z
;
;		LDA	#000H
		STZ	object_type
;
		LDA	#010H 
		STA	rotate_angle_x
;
		STZ	<DPSUB
		LDA	#016H
		STA	<DPMAIN
;
		RTS
;----------------------------------------
POLIWMV		EQU	$
;		LDA	<GAMEMD
;		BEQ	PLWMV40
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	ENXP2L		; Scroll revise !
		SEC
		SBC	BGMVC0
		STA	ENXP2L
		LDA	ENYP2L
		SEC
		SBC	BGMVC1
		STA	ENYP2L
;
		MEM8
		IDX8
		SEP	#00110000B
;
PLWMV40		EQU	$
		LDA	ENSTAT,X
		CMP	#003H
		BCC	PLWMV30
		JSL	>HELP0CS
PLWMV30		EQU	$
;
;;		JSR	ENMVCL		;xclc,yclc
;
		LDA	#001H		;POLYGON WRITE FLG(MAIN)
		STA	POLYCFG
;
		LDA	polygon_flag
		BNE	POLIW10		;? POLIW MOVE OK
;					;Y
		JSR	POLIWMN		;POLYGON MAIN
;
		LDA	#001H		;POLYGON WRITE ON
		STA	polygon_flag
;
POLIW10		EQU	$
		RTS
;----------------------------------------
POLIWMN		EQU	$
		INC	ENWRK3,X	;<FRCNT
;
		LDA	rotate_angle_y	;KAITEN
		CLC
		ADC	#006H
		STA	rotate_angle_y
;
		LDA	<GAMEMD
		BEQ	PLWMN10
		RTS
;
PLWMN10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	POLIWM0		;INIT
		WORD	POLIW01		;UP
		WORD	POLIWM1		;UP
		WORD	POLIWM2		;F IN INIT
		WORD	POLIWM3		;F IN
		WORD	POLIWM4		;MSGE
		WORD	POLIWM5		;MSGE YES OR NO
		WORD	POLIWM6		;MSGE
		WORD	POLIWM7		;LIFE UP END
;----------------------------------------
POLIWM0		EQU	$
		STZ	<DPSUB
		INC	ENSTAT,X
		RTS
;----------------------------------------
POLIW01		EQU	$
		LDA	#001H
		STA	<DPSUB
		INC	ENSTAT,X
;
		RTS
;----------------------------------------
POLIWM1		EQU	$
		LDA	object_size
		CMP	#006H
		BCS	POLM010
;
		STZ	object_size	;POLIW (BIG)
;
		INC	ENSTAT,X	;NEXT
;
		RTS
;--
POLM010		EQU	$
		SBC	#003H
		STA	object_size
;
		CMP	#040H
		BCC	POLM030
;
		PHX
		LDA	ENWRK0,X
		TAX
		JSL	>PGKRITL
		PLX
POLM030		EQU	$
;
;		LDA	ENWRK3,X	;<FRCNT
;		AND	#002H
;		BNE	POLM020
;
;		MEM16
;		IDX8
;		REP	#00100000B
;
;		INC	BGMVC1		;Y MOVE
;
;		MEM8
;		IDX8
;		SEP	#00110000B
;
POLM020		EQU	$
		RTS
;----------------------------------------
POLIWM2		EQU	$
		INC	ENSTAT,X
;----------------------------------------
POLIWM3		EQU	$
		LDA	ENWRK3,X	;<FRCNT
		AND	#0001H
		BNE	PLWM310
;
		PHX
		JSL	>MGMCGCNG	;F IN
		PLX
;
		LDA	>CCNGCT
		BNE	PLWM310		;? F IN END
		INC	ENSTAT,X	Y
;
		LDA	#001H
		STA	PYALSP
		STZ	ATMTFG
		STZ	ATMTHK
		STZ	<PYCRCH
		STZ	<PLMKCH		;PL. MUKI SET
;
PLWM310		EQU	$
		RTS
;----------------------------------------
PLWM4MD		EQU	$
		WORD	MS_04C1		;HOKORA
		WORD	MS_04C0		;SINDEN
		WORD	MS_04C5		;NUMA
		WORD	MS_04C2		;MORI
		WORD	MS_04C4		;BWAKO
		WORD	MS_04C0		;YAMA NO TOU
		WORD	MS_04C3		;MACHI
		WORD	MS_04C6		;KAME( 7 koaru )
		WORD	MS_04CA		;KAME( 7 nai )
;
POLIWM4		EQU	$
		LDA	DJNNO
		SEC
		SBC	#00AH
		TAY
		CPY	#002H
		BNE	PLWM410
		LDA	>MODTBL2
		CMP	#007H
		BCS	PLWM410
		LDA	#007H
		STA	>MODTBL2
;		LDA	#02DH		;OTO
;		JSL	>SDLRE3
PLWM410		EQU	$
		CPY	#00EH
		BNE	PLWM420
;		LDA	#02DH		;OTO
;		JSL	>SDLRE3
		LDA	>ITMTBL3
		AND	#07FH
		CMP	#07FH
		BEQ	PLWM420
		LDY	#010H
PLWM420		EQU	$
		LDA	PLWM4MD,Y
		XBA
		LDA	PLWM4MD+1,Y
		TAY
		XBA
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
;
		LDA	>ITMTBL3
		AND	#07FH
		CMP	#07FH
		BNE	PLWM430
		LDA	#008H
		STA	>MODTBL2
PLWM430		EQU	$
		RTS
;----------------------------------------
POLIWM5		EQU	$
		LDA	#LOW  MS_04C8	;MSGE NO
		LDY	#HIGH MS_04C8	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;----------------------------------------
POLIWM6		EQU	$
		LDA	MSG_RTS
		BEQ	PLWM610
;
		LDA	#005H
		STA	ENSTAT,X
		RTS
;
PLWM610		EQU	$
		LDA	#LOW  MS_04C7	;MSGE NO
		LDY	#HIGH MS_04C7	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;----------------------------------------
POLIWM7		EQU	$
		STZ	<DPSUB
		PHX
		JSL	>DJEXTCK
		PLX
		STZ	ENMODE,X	;KILL I
		RTS
;----------------------------------------
;;;;;POLIWCN		EQU	000H
;;;;;;
;;;;;POLIWCD		EQU	$
;;;;;		WORD	00000H,00000H
;;;;;		BYTE	000H+POLIWCN,001H,000H,002H
;;;;;		WORD	00010H,00000H
;;;;;		BYTE	002H+POLIWCN,001H,000H,002H
;;;;;		WORD	00020H,00000H
;;;;;		BYTE	004H+POLIWCN,001H,000H,002H
;;;;;		WORD	00030H,00000H
;;;;;		BYTE	006H+POLIWCN,001H,000H,002H
;;;;;;
;;;;;		WORD	00000H,00010H
;;;;;		BYTE	020H+POLIWCN,001H,000H,002H
;;;;;		WORD	00010H,00010H
;;;;;		BYTE	022H+POLIWCN,001H,000H,002H
;;;;;		WORD	00020H,00010H
;;;;;		BYTE	024H+POLIWCN,001H,000H,002H
;;;;;		WORD	00030H,00010H
;;;;;		BYTE	026H+POLIWCN,001H,000H,002H
;;;;;;
;;;;;		WORD	00000H,00020H
;;;;;		BYTE	008H+POLIWCN,001H,000H,002H
;;;;;		WORD	00010H,00020H
;;;;;		BYTE	00AH+POLIWCN,001H,000H,002H
;;;;;		WORD	00020H,00020H
;;;;;		BYTE	00CH+POLIWCN,001H,000H,002H
;;;;;		WORD	00030H,00020H
;;;;;		BYTE	00EH+POLIWCN,001H,000H,002H
;;;;;;
;;;;;		WORD	00000H,00030H
;;;;;		BYTE	028H+POLIWCN,001H,000H,002H
;;;;;		WORD	00010H,00030H
;;;;;		BYTE	02AH+POLIWCN,001H,000H,002H
;;;;;		WORD	00020H,00030H
;;;;;		BYTE	02CH+POLIWCN,001H,000H,002H
;;;;;		WORD	00030H,00030H
;;;;;		BYTE	02EH+POLIWCN,001H,000H,002H
;;;;;;
;;;;;POLIWCS		EQU	$
;;;;;		LDA	#LOW  POLIWCD
;;;;;		STA	<WORK8
;;;;;		LDA	#HIGH POLIWCD
;;;;;		STA	<WORK9
;;;;;;
;;;;;		LDA	#010H
;;;;;;;		STA	<WORK6
;;;;;;;		STZ	<WORK7
;;;;;;
;;;;;		JSL	>SETOAML22
;;;;;;
;;;;;		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	TRAP    move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TRAP0MV		EQU	$
		JSR	TRAP0CS
		JSR	ENSTCK
		JSR	CREKEK
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
;
		LDA	ENSTAT,X
		BNE	TRP100
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		LDA	<WORKF
		CLC
		ADC	#10H
		CMP	#20H
		BCS	TR0010
;;		LDA	#40H
		BRA	TR0020
TR0010		EQU	$
		LDA	<WORKE
		CLC
		ADC	#10H
		CMP	#20H
		BCS	TR0018
;;		LDA	#38H
TR0020		EQU	$
		LDA	TRATIM,Y
		STA	ENTIM0,X
		INC	ENSTAT,X
		LDA	TRATXS,Y
		STA	ENXSPD,X
		LDA	TRATYS,Y
		STA	ENYSPD,X
TR0018		EQU	$
		RTS
;- - - - - - - - - - - - 
TRATXS		EQU	$
		HEX	20,E0,00,00
		HEX	F0,10,00,00
TRATYS		EQU	$
		HEX	00,00,20,E0
		HEX	00,00,F0,10
TRATIM		EQU	$
		HEX	40,40,38,38
;--------------------------------------
TRP100		EQU	$
		CMP	#01H
		BNE	TRP200
;
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BNE	TRP108
;
		LDA	ENTIM0,X
		BNE	TRP110
;
TRP108		EQU	$
		INC	ENSTAT,X
		LDA	#60H
		STA	ENTIM0,X
TRP110		EQU	$
		JSR	ENMVCL
		RTS
;---------------------------------------
TRP200		EQU	$
		LDA	ENTIM0,X
		BNE	TRP210
;
		LDY	ENMUKI,X
		LDA	TRATXS+4,Y
		STA	ENXSPD,X
		LDA	TRATYS+4,Y
		STA	ENYSPD,X
;
		JSR	ENMVCL
;
		LDA	ENXPSL,X
		CMP	ENWRK0,X
		BNE	TRP210
		LDA	ENYPSL,X
		CMP	ENWRK2,X
		BNE	TRP210
;
		STZ	ENSTAT,X
TRP210		EQU	$
		RTS
;==========================================
TRAP0CD		EQU	$
		WORD	0FFF8H,0FFF8H
		HEX	C4,00,00,02
		WORD	00008H,0FFF8H
		HEX	C4,40,00,02
		WORD	0FFF8H,00008H
		HEX	C4,80,00,02
		WORD	00008H,00008H
		HEX	C4,C0,00,02
;
TRAP0CS		EQU	$
		MEM16
		REP	#00100000B
;
		LDA	#TRAP0CD	;TFR ADD
		STA	<WORK8
;
		LDA	#0004H		;KAZU
		STA	<WORK6
;
		MEM8
		SEP	#00110000B
;
		JSL	>SETOAML2
		
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BAAR    move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BRMVAL		EQU	$
		HEX	FE,02
		HEX	FF,01
BRMVAH		EQU	$
		HEX	FF,00
		HEX	FF,00
; - - - - - - - - - - - - - - - - - - - -
BAAR0MV		EQU	$
BAAR1MV		EQU	$
		JSR	BAARCS
		JSR	ENSTCK
;
		INC	ENCONT,X
;
		LDA	ENMYNO,X
		SEC
		SBC	#BAAR0
		TAY
		LDA	DJNNO
		CMP	#12H
		BNE	BRM010		; Ice danjyon ?
		INY			; yes low speed !
		INY
BRM010		EQU	$
		LDA	ENWRK0,X
		CLC
		ADC	BRMVAL,Y
		STA	ENWRK0,X
		LDA	ENWRK1,X
		ADC	BRMVAH,Y
		AND	#01H
		STA	ENWRK1,X
;
		RTS
;- - - - - - - - - - - - - - 
BAARCS		EQU	$
		JSR	OAMCHK
		LDA	<WORK5
		STA	ENHELP2
;
		LDA	<WORK0
		STA	ENDSXL
		LDA	<WORK2
		STA	ENDSYL
;
                LDA	ENWRK0,X
		STA	<WORK0
		LDA	ENWRK1,X
		STA	<WORK1		; angle
;
		LDA	#40H
		STA	<WORKF		; hankei
;
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0
		AND	#01FFH
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORKA
;
		LDA	<WORK0
		CLC
		ADC	#0080H
		AND	#01FFH
		STA	<WORK2
;
		LDA	<WORK0
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK4
;
		LDA	<WORK2
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK6
		MEM8
		IDX8
		SEP	#00110000B		
		PLX
;
		LDA	<WORK4
		STA	4202H
		LDA	<WORKF 	    ; Hankei
		LDY	<WORK5
		BNE	KSF0
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		ASL	4216H
		LDA	4217H
		ADC	#00H
KSF0		EQU	$
		STA	<WORKE
		LSR	<WORK1
		BCC	KS00
		EOR	#0FFH
		INC	A
KS00		EQU	$
		STA	<WORK4		; XAD
;
		LDA	<WORK6
		STA	4202H
		LDA	<WORKF
		LDY	<WORK7
		BNE	KS08
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		ASL	4216H
		LDA	4217H
		ADC	#00H
KS08		EQU	$
		STA	<WORKF
		LSR	<WORK3
		BCC	KS10
		EOR	#0FFH
		INC	A
KS10		EQU	$
		STA	<WORK6		; YAD
;-- oam set -
		LDA	ENCONT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		AND	#11000000B
		ORA	ENHELP2
		STA	<WORKD
;
		LDY	#00H
;
		LDA	<WORK4
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
;
		LDA	<WORK6
		CLC
		ADC	ENDSYL
		INY
		STA	(<OAMADR),Y		
		LDA	#028H
		INY
		STA	(<OAMADR),Y
		LDA	<WORKD
		INY
		STA	(<OAMADR),Y
		LDA	#02H
		STA	(<OSBADR)
;--- Chaine set ------
		LDY	#04H
		PHX
		LDX	#02H
TWC000		EQU	$
		LDA	<WORKE
		STA	4202H
		LDA	TKBYDT,X
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		LDA	<WORK4
		ASL	A
		LDA	4217H
		BCC	TWC010
		EOR	#0FFH
		INC	A
TWC010		EQU	$
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
;
		LDA	<WORKF
		STA	4202H
		LDA	TKBYDT,X
		STA	4203H
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		JSR	NOPSUB
		LDA	<WORK6
		ASL	A
		LDA	4217H
		BCC	TWC020
		EOR	#0FFH
		INC	A
TWC020		EQU	$
		CLC
		ADC	ENDSYL
		INY
		STA	(<OAMADR),Y
		LDA	#028H
		INY
		STA	(<OAMADR),Y
		LDA	<WORKD
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	TWC000
		PLX
;
		LDY	#0FFH
		LDA	#03H
		JSL	>ALOMCKL
;
		TXA
		EOR	<FRCNT
		AND	#03H
		ORA	<GAMEMD
		ORA	ENSTFG
		BNE	BRCR80
;
		LDY	#00H
BRCR00		EQU	$
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	(<OSBADR),Y
		PLY
		AND	#01H
		BNE	BRCR10
;
		LDA	(<OAMADR),Y
		CLC
		ADC	<SCCH2
		SEC
		SBC	<PLXPS1
		CLC
		ADC	#000CH
		CMP	#0018H
		BCS	BRCR10
;
		INY
		LDA	(<OAMADR),Y
		DEY
		CMP	#0F0H
		BCS	BRCR10
		CLC
		ADC	<SCCV2
		SEC
		SBC	<PLYPS1
		CLC
		ADC	#0004H
		CMP	#0010H
		BCS	BRCR10
		PHY
		JSL	>PLFLSTL
		PLY
BRCR10		EQU	$
		INY
		INY
		INY
		INY
		CPY	#04H*4
		BCC	BRCR00
;
;		LDY	#00H
;BRCR00		EQU	$
;		LDA	#00H
;		XBA
;		LDA	(<OAMADR),Y
;		MEM16
;		REP	#00100000B
;		STA	<WORK0
;		INY
;		MEM8
;		SEP	#00100000B
;		LDA	(<OAMADR),Y
;		MEM16
;		REP	#00100000B
;		STA	<WORK2
;;
;		LDA	<WORK0
;		CLC
;		ADC	<SCCH2
;		SEC
;		SBC	<PLXPS1
;		CLC
;		ADC	#000CH
;		CMP	#0018H
;		BCS	BRCR10
;;
;		LDA	<WORK2
;		CLC
;		ADC	<SCCV2
;		SEC
;		SBC	<PLYPS1
;		CLC
;		ADC	#0004H
;		CMP	#0010H
;		BCS	BRCR10
;		MEM8
;		SEP	#00100000B
;		PHY
;		JSL	>PLFLSTL
;		PLY
;BRCR10		EQU	$
;		MEM8
;		SEP	#00100000B
;		INY
;		INY
;		INY
;		CPY	#04H*4
;		BCC	BRCR00
;;
BRCR80		EQU	$
		RTS
;- - - -
TKBYDT		EQU	$
		HEX	40,80,C0
;;		HEX	00,40,80,C0
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Hebi tama move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HBATDT		EQU	$
		HEX	00,40,80,C0
;
HBTAMMV		EQU	$
		JSL	>EN1CSTL
		JSR	ENSTCK
;
		JSR	ENHNSB
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	HBATDT,Y
		STA	ENCLOR,X
;
		LDA	ENWRK0,X
		BEQ	HBT100		; Zanzoo set !
;
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	HBT010
;
		STZ	ENMODE,X
HBT010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
HBTXSD		EQU	$
		HEX	18,E8,00,00	
HBTYSD		EQU	$
		HEX	00,00,18,E8
;;HBTTIM		EQU	$
;;		HEX	18,28
;
HBT100		EQU	$
		JSR	CREKEK
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
		JSR	HBTAMST		; Zanzoo set !
;
;;		LDA	ENSTAT,X
;;		BNE	HBT120
;;;
;;		LDA	ENTIM0,X
;;		BNE	HBT110
;;;;		JSL	>RNDSET
;;;;		AND	#01H
;;;;		TAY
;;;;		LDA	HBTTIM,Y
;;		LDA	#0FFH
;;		STA	ENTIM0,X
;;		INC	ENSTAT,X
;;		JSL	>RNDSET
;;		AND	#03H
;;		TAY
;;		LDA	HBTXSD,Y
;;		STA	ENXSPD,X
;;		LDA	HBTYSD,Y
;;		STA	ENYSPD,X
;;HBT110		EQU	$
;;		RTS
;;;- - - - - - - - - - - - - -
;;HBT120		EQU	$
;;		LDA	ENTIM0,X
;;		BNE	HBT122
;;;
;;		LDA	#20H
;;		STA	ENTIM0,X
;;HBT121		EQU	$
;;		STZ	ENSTAT,X
;;		RTS
;;;- - - 
;;HBT122		EQU	$
		LDA	ENCBFG,X
		BNE	HBT123
;
		JSR	ENMVCL
HBT123		EQU	$
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	HBT124
;
;;		STZ	ENSTAT,X
;;		STZ	ENTIM0,X
		JSL	>RNDSET
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	HBNXMK,Y
		STA	ENMUKI,X
HBT124		EQU	$
		LDY	ENMUKI,X
		LDA	HBTXSD,Y
		STA	ENXSPD,X
		LDA	HBTYSD,Y
		STA	ENYSPD,X
		RTS
;============================================
HBTAMST		EQU	$
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	HTS020
;
		PHX
		TXY
;
		LDX	#E2NO-1
HBS010		EQU	$
		LDA	>E2MODE,X
		BEQ	HBS020
		DEX
		BPL	HBS010
		PLX
		RTS
;- - - - - - - - - - - -- - - - - - - - - -
HBS020		EQU	$
		LDA	#01H
		STA	>E2MODE,X
		STA	EN2FLG
;
		LDA	ENXPSL,Y
		STA	>E2XPSL,X
		LDA	ENXPSH,Y
		STA	>E2XPSH,X
		LDA	ENYPSL,Y
		CLC
		ADC	#10H
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		ADC	#00H
		STA	>E2YPSH,X
;
		LDA	#20H
		STA	>E2TIM0,X
;
;;		LDA	ENCLOR,Y
;;		EOR	ENFLCL
		TYA
		STA	>E2STAT,X	
;
		LDA	ENKAIF,Y
		STA	>E2WRK0,X
;
		PLX
HTS020		EQU	$
		RTS
;
;;		LDA	#HBTAM
;;		JSL	>ENIDSH
;;		BMI	HTS020
;;;
;;		LDA	<WORK0
;;		STA	ENXPSL,Y
;;		LDA	<WORK1
;;		STA	ENXPSH,Y
;;		LDA	<WORK2
;;		STA	ENYPSL,Y
;;		LDA	<WORK3
;;		STA	ENYPSH,Y
;;		LDA	#18H
;;		STA	ENTIM0,Y
;;		STA	ENWRK0,Y
;;HTS020		EQU	$
;;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	TELSA   move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TLMKCK		EQU	$
		HEX	04,06,00,02
;;TLCHPT		EQU	$
;;		HEX	00,01,02,01
;;		HEX	00,03,00,03,00,03,04,03,04,03,04
TLMKDT		EQU	$
TLEADT		EQU	$
		HEX	40,00,00,00
TLCHPT		EQU	$
		HEX	0,0,1,2 
;;		HEX	02,02,00,04
;
TELSAMV		EQU	$
;;		LDY	ENWRK0,X
;;		LDA	TLCHPT,Y
;;		STA	ENCHPT,X
;;;
;;;
;;		JSR	EPXCHK
;
;;		LDA	ENWRK0,X
;;		BNE	TLM010
;
;		JSR	TLEYEST
;
;;TLM010		EQU	$
;;		MEM16
;;		REP	#20H
;;		LDA	<OAMADR
;;		CLC
;;		ADC	#0004H
;;		STA	<OAMADR
;;		INC	OSBADR
;;		MEM8
;;		SEP	#20H
;
		LDY	ENMUKI,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	TLMKDT,Y
		STA	ENCLOR,X
;
		LDA	TLCHPT,Y
		STA	ENCHPT,X
;
;;		DEC	ENMOD0,X
		JSL	>EN1CSTL
;;		INC	ENMOD0,X
;
		JSR	ENSTCK
		JSR	ENHNSB
;
		JSR	CREKEK
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
;;;
;;		LDA	ENMOD2,X
;;		ORA	#01000000B
;;		STA	ENMOD2,X
;;;
;;		INC	ENCONT,X
;
		STZ	ENWRK0,X
;
		JSR	EPXYCK
		LDA	TLMKCK,Y
		CMP	PLMKCH
		BEQ	TLM008
;- - - Player serch - - -
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	TLM005
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
;
		LDA	ENWRK1,X
		CMP	#04H
		BEQ	TLM045
;
		INC	ENWRK1,X
TLM045		EQU	$
		JSL	>PSERCHL
;
		JSR	EPXCHK
		TYA
		STA	ENMUKI,X
TLM005		EQU	$
		JSR	ENMVCL
;
;;		LDA	ENWRK0,X
;;		CMP	#03H
;;		BCS	TLM001
;;;
;;		LDA	ENCONT,X
;;		LSR	A
;;		LSR	A
;;		AND	#03H
;;		TAY
;;		LDA	TLCHPT,Y
;;		STA	ENWRK0,X
;;		RTS
;;TLM001		EQU	$
;;		LDA	ENCONT,X
;;		AND	#03H
;;		BNE	TLM003
;;;
;;		DEC	ENWRK0,X
;;TLM003		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - -
;- - - Mukai awase - - -
TLM008		EQU	$
		INC	ENWRK0,X
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	TLM056
;
		LDA	ENWRK1,X
		BEQ	TLM055
;
		DEC	ENWRK1,X
TLM055		EQU	$
		JSL	>PSERCHL
;
		JSR	EPXCHK
		TYA
		STA	ENMUKI,X
TLM056		EQU	$
		JSR	ENMVCL
TLM057		EQU	$
;;		LDA	ENWRK0,X
;;		CMP	#0EH
;;		BEQ	TLM010
;;;
;;		LDA	ENCONT,X
;;		AND	#07H
;;		BNE	TLM00C
;;;
;;		INC	ENWRK0,X
;;TLM00C		EQU	$
;;		RTS
;;TLM010		EQU	$
;;		LDA	ENMOD2,X
;;		AND	#10111111B
;;		STA	ENMOD2,X
		RTS
;;========================================
;TLEXAD		EQU	$
;		HEX	8,0
;TLEYEST		EQU	$
;		JSR	OAMCHK
;;
;		PHX
;		LDA	ENMUKI,X
;		PHA
;		ASL	A
;		TAX
;		MEM16
;		REP	#20H
;		LDA	<WORK0
;		CLC
;		ADC	TLEXAD,X
;		STA	(<OAMADR),Y
;		AND	#0100H
;		STA	<WORKE
;		LDA	<WORK2
;		CLC
;		ADC	#05H
;		INY
;		STA	(<OAMADR),Y
;		CLC
;		ADC	#0010H
;		CMP	#0100H
;		MEM8
;		SEP	#20H
;		BCC	TLE010
;;
;		LDA	#0F0H
;		STA	(<OAMADR),Y
;TLE010		EQU	$
;		PLX
;		LDA	#031H
;		INY
;		STA	(<OAMADR),Y
;		LDA	TLEADT,X
;		ORA	<WORK5
;		INY
;		STA	(<OAMADR),Y
;;
;		LDA	<WORKF
;		STA	(<OSBADR)		
;		PLX
;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SHSAI   move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SBCT		EQU	05H	; beam laser set counter !
;
SHMKDT		EQU	$
;;;;;;;;		FE FF 00 01 02 ;X
		HEX	00,00,00,00,00 ;FE ; Y
		HEX	00,00,00,00,00 ;FF
		HEX	05,05,00,01,01 ;00
		HEX	04,04,00,02,02 ;01
		HEX	04,04,03,02,02 ;02
SHCHPT		EQU	$
		HEX	02,0A,08,00,04,06
;
		PLX
SHSAIMV		EQU	$
;		JSR	SHSAICS
;		LDA	#01H
;		STA	ENCHPT,X
;;
;		LDA	<KEYA2
;		AND	#0CH
;		BEQ	ST0010
;;
;		INC	ENCMKI,X
;;
;		LDA	ENCMKI,X
;		CMP	#25H
;;		BNE	ST0010
;;
;		LDA	#00H
;		STA	ENCMKI,X
;ST0010		EQU	$
;		LDY	ENCMKI,X
;		LDA	STESTD,Y
;		STA	ENCHPT,X
;		STA	ENMUKI,X
;		RTS
;STESTD		EQU	$
;		HEX	00
;		HEX	1,1,1,1,1,1
;		HEX	4,4,4,4,4,4
;		HEX	8,8,8,8,8,8
;		HEX	6,6,6,6,6,6
;		HEX	A,A,A,A,A,A
;		HEX	2,2,2,2,2,2				
;- - - - - TEST END - - -
		JSR	SHSAICS
;
		LDA	ENDSPL,X
		BEQ	SHM001		; SET WAIT !!
		LDA	#20H
		STA	ENTIM0,X
		LDA	#00H
		STA	ENCHPT,X
		LDA	#03H
		STA	ENMUKI,X
SHM001		EQU	$
		JSR	ENSTCK
;
		JSR	ENHNSB
;
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
;--- First room ---
		WORD	SHINIT	;0
		WORD	SHSET	;1
		WORD	SHUP	;2
		WORD	SHATCK	;3
		WORD	SHDOWN	;4
		WORD	SHMOVE	;5
;----Last room ------------
		WORD	S2SET	;6
		WORD	S2WAI1	;7
		WORD	S2FAIL	;8
		WORD	S2FAI2	;9
;
		WORD	SHSPIN	;A
;----------------------------------------------------
SHSPPT		EQU	$
		HEX	0,8,A,2,2,6,4
;;		HEX	0,8,A,2,2,2,6,4
;
SHSPIN		EQU	$
		LDA	ENTIM0,X
		BNE	SHSP10
;
		PHX
		STZ	ENMODE,X
		JSL	>DJEXTCK
		PLX
SHSP10		EQU	$
;;		LSR	A
;;		LSR	A
;;		AND	#07H
;;		TAY
		LDA	ENTIM0,X
		CMP	#10H
		BCS	SHSP12
;
                LDA     #7FH
                STA     <WD2131
                LDA     #06H
                STA     <DPMAIN
                LDA     #10H
                STA     <DPSUB          ; Obj color add.!
;
		PHX
		JSL	>MGMCGCNG	; Fade on out !
		PLX		
SHSP12		EQU	$
		LDA	ENTIM0,X
		AND	#00H
		BNE	SHSP18
;
		LDA	ENZSPD,X
		CMP	#0FFH
		BEQ	SHSP18
		CLC
		ADC	#01H
		STA	ENZSPD,X
SHSP18		EQU	$
;
		LDA	ENZSDR,X
		CLC
		ADC	ENZSPD,X
		STA	ENZSDR,X
		BCC	SHSP20
;
		INC	ENCONT,X
		LDA	ENCONT,X
		CMP	#07H
		BNE	SHSP20
;
		STZ	ENCONT,X
;
		LDA	#04H
		JSL	>SDLRE2	;(S)
SHSP20		EQU	$
		LDY	ENCONT,X
		LDA	SHSPPT,Y
		STA	ENCHPT,X
		RTS
;----------------------------------------------------
S2FAIL		EQU	$
		LDA	#02H
		STA	BSFLFG
;
		STZ	ENCMKI,X	; Beam clear !
;
		LDA	ENTIM0,X
		CMP	#40H
		BCC	S2F010
;
		LDA	ENFLSH,X
		ORA	#0E0H
		STA	ENFLSH,X
		RTS
;
S2F010		EQU	$
		CMP	#01H
		BNE	S2F020
;
		JSL	>GANSPST	; Ganon spook set !
;
;;		JSL	>SDLRCE
		LDA	#1DH
		STA	SOUND0	;(S)
;
S2F020		EQU	$
		STZ	ENFLSH,X
;
		LDA	#011H		; Taore !
		STA	ENCHPT,X
		RTS
;----------------------------------------------------
S2FAI2		EQU	$		; Back master body !
		STZ	ENCMKI,X	; Beam clear !
;
		LDA	ENXPSL
		STA	<WORK4
		LDA	ENXPSH
		STA	<WORK5
		LDA	ENYPSL
		STA	<WORK6
		LDA	ENYPSH
		STA	<WORK7
;
		MEM16
		REP	#20H
		LDA	ENXP2L
		SEC
		SBC	<WORK4
		CLC
		ADC	#004H
		CMP	#008H
		BCS	S2F210
;
		LDA	ENYP2L
		SEC
		SBC	<WORK6
		CLC
		ADC	#004H
		CMP	#008H
		BCS	S2F210
;
		MEM8
		SEP	#20H
;
		STZ	ENMODE,X
S2F210		EQU	$
		MEM8
		SEP	#20H
		LDA	#20H
		JSL	>ESERCHL
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
		JSR	ENMVCL
		JSL	>SHBUNST
		RTS
;----------------------------------------------------
S2SET		EQU	$
		LDA	ENTIM0,X
		BNE	S2S010
;
		LDA	#MS_04D4
		STA	MSGENOL
		LDA	#HIGH MS_04D4
		STA	MSGENOH
		JSL	>MSGSET
;
		INC	ENSTAT,X
;
		LDA	#50H
		STA	ENTIM0,X
S2S010		EQU	$
		RTS		
;------------------------------------------
S2BUNXS		EQU	$
		HEX	20,E0
;
S2WAI1		EQU	$
		LDA	ENCTFG,X
		BEQ	S2W100
;
		LDA	ENTIM0,X
		BNE	S2W1E0
;
		JMP	SHATST
S2W1E0		EQU	$
		LDA	S2BUNXS-1,X
		STA	ENXSPD,X
;;		LDA	#20H
;;		STA	ENYSPD,X
		LDA	ENYSPD,X
		CLC
		ADC	#02H
		STA	ENYSPD,X
;
		JSR	ENMVCL
		JSL	>SHBUNST
		BMI	S2W1E8
;
		LDA	#00000100B
		STA	ENCLOR,Y
S2W1E8		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - -
S2CLDT		EQU	$
		HEX	09,0B
;
S2W100		EQU	$
		LDA	ENTIM0,X
		BNE	S2W108
;
		JMP	SHATST
S2W108		EQU	$
		CMP	#40H
		BNE	S2W1A0
;
		LDA	#28H
		STA	SOUND3	;(S)
;
		LDA	#01H
		STA	ENHELP
S2W110		EQU	$
		LDA	#SHSAI
		LDY	#02H
		JSL	>ENIDSH2
;
		JSL	>ENIDPS
;
		LDA	S2CLDT-1,Y
;;		LDA	#01001011B
		STA	ENMOD2,Y
		AND	#0FH
		STA	ENCLOR,Y
		STA	ENCTFG,Y
;
		LDA	ENSTAT,X
		STA	ENSTAT,Y
;
		LDA	#20H
		STA	ENTIM0,Y
;
		DEC	ENHELP
		BPL	S2W110
S2W1A0		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SHITMD		EQU	$
		HEX	01,06
;
SHINIT		EQU	$
;;                PHX
;;                JSL     >MGMCGRS2       ; CG initial !
;;                PLX
;;		LDA	#01H
;
		LDY	URAFLG
		LDA	SHITMD,Y
		STA	ENSTAT,X
		RTS			
;----------------------------------------------------
SHSET		EQU	$
		LDA	ENTIM0,X
		BNE	SHS010
;
		LDA	#MS_04D2
		STA	MSGENOL
		LDA	#HIGH MS_04D2
		STA	MSGENOH
		JSL	>MSGSET
;
SHATST		EQU	$
		LDA	#03H
		STA	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
		RTS		
;;                PHX
;;                JSL     >MGMCGRS2       ; CG initial !
;;                PLX
;
UPSET		EQU	$
		LDA	#02H
		STA	ENSTAT,X
;
		LDA	#27H
		STA	ENTIM0,X
SHS010		EQU	$
		RTS
;--------------------------------------------
SHUCDT		EQU	$
		HEX	0C,0D,0E,0F,10
;
SHUP		EQU	$
		STZ	E2STCT
;
		LDA	ENTIM0,X
		BNE	SHU010
		INC	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
		RTS
;- - - - - - - - - - - - - - - - - - - - -
SHU010		EQU	$
		LSR	A
		LSR	A
		LSR	A
;;		LSR	A
		TAY
		LDA	SHUCDT,Y
		STA	ENCHPT,X
		RTS		
;----------------------------------------------
SHACDT		EQU	$
		HEX	00,00,00,00,00,00,00,01,01,01,01,01,01,01,00,00
;;		HEX	00,00,01,01,01,01,01,00
SHAFPT		EQU	$
		HEX	00,00,00,00,00,00,00,06,05,04,03,02,01,00,00,00
;;		HEX	00,06,05,04,03,02,01,00
SHAFAD		EQU	$
		BYTE	05*6
		BYTE	04*6
		BYTE	02*6
		BYTE	00*6
		BYTE	01*6
		BYTE	03*6
;
SHATCK		EQU	$
;;;		STZ	ENNOCR,X
		LDA	ENTIM0,X
		CMP	#0C0H
		BNE	SHSDST
		PHA
;;		JSL	>SDLRCE
;;		ORA	#27H
;;		STA	SOUND3	;(S)
		LDA	#27H
		JSL	>SDLRE3	;(S)
		PLA
SHSDST		EQU	$
		CMP	#0EFH
		BCS	SHCGST
		CMP	#10H
		BCS	SHATFF
;
SHCGST		EQU	$
;;		CPX	#00H
;;		BNE	SHCG10
;
		PHX
		LDA	URAFLG
		BNE	SHCG00
		LDX	#02H
SHCG00		EQU	$
;;		JSL	>MGMCGCNG	; Fade on out !
		JSL	>SHSCGCNG
		PLX		
;
SHCG10		EQU	$
		BRA	SHATFE
SHATFF		EQU	$
		TXA
		BNE	SHATFE
;
		JSR	CREKEK
		STZ	ENNOCR,X
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
SHATFE		EQU	$
;
		LDA	ENTIM0,X
		BNE	SHA010
		INC	ENSTAT,X
		LDA	#27H
		STA	ENTIM0,X
		RTS
SHA010		EQU	$
		CMP	#80H
		BCC	SHA011
;
		PHA
		LDA	#02H
		JSL	>PSERCHL
		LDY	<WORK1
		LDA	<WORK0
		CLC
		ADC	#02H
		STA	<WORK2
		ASL	A
		ASL	A
		ADC	<WORK2
		ADC	#02H
		CLC
		ADC	<WORK1
		TAY
		LDA	SHMKDT,Y
		STA	ENMUKI,X
		LDA	#20H
		JSL	>PSERCHL	; Beam speed set !
;
		LDA	HEMODE,X
		CMP	#SBCT-1
		BNE	SHA00F		; Beam laser atack time  ?
;					; yes !
		LDA	#03H
		STA	ENMUKI,X	; Shita muki kotei !
SHA00F		EQU	$
		PLA
SHA011		EQU	$
		CMP	#70H
		BNE	SHA012
		PHA
		JSR	SHTAMST
		PLA
SHA012		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	SHACDT,Y
		STA	ENWRK0,X
;
		LDA	SHAFPT,Y
		BEQ	SHA030
		CLC
		LDY	ENMUKI,X
		ADC	SHAFAD,Y		
SHA030		EQU	$
		STA	ENCMKI,X
;
		LDY	ENMUKI,X
		LDA	SHCHPT,Y
		CLC
		ADC	ENWRK0,X
		STA	ENCHPT,X
;
		RTS
;--------------------------------------------
SHDCDT		EQU	$
		HEX	10,0F,0E,0D,0C
SHMXPL		EQU	$
		HEX	38,38,38,58,78,98
		HEX	B8,B8,B8,98,58,58,60,90,98,78
SHMYPL		EQU	$
		HEX	B8,78,58,48,48,48
		HEX	58,78,B8,B8,B8,90,70,70,90,A0
;
SHDOWN		EQU	$
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	SHD010
		INC	ENSTAT,X
;;		STZ	ENSTAT,X
;;		LDA	#040H
;;		STA	ENTIM0,X
;
		LDY	#04H
		LDA	HEMODE,X
		CMP	#SBCT-1
		BEQ	SHD001		; Beam laser ? -> Kotei pos.
;
		JSL	>RNDSET
		AND	#0FH
		TAY
SHD001		EQU	$
		LDA	SHMXPL,Y
		STA	ENWRK2,X
		LDA	SHMYPL,Y
		STA	ENWRK3,X
;
		LDA	#08H
		STA	ENCTCT,X
		RTS
SHD010		EQU	$
		LSR	A
		LSR	A
		LSR	A
;;		LSR	A
		TAY
		LDA	SHDCDT,Y
		STA	ENCHPT,X
		RTS		
;------------------------------------------------
SHTSXL		EQU	$
		HEX	00,0A,08,00,F6,F6
SHTSXH		EQU	$
		HEX	00,00,00,00,FF,FF
SHTSYL		EQU	$
		HEX	F7,FE,FE,F7,FE,FE
;;SHTSYH		EQU	$
;;		HEX	FF,FF,FF,FF,FF,FF
SHTAMST		EQU	$
		CPX	#00H
;;		LDA	URAFLG
		BNE	SHTSF0

		INC	HEMODE,X
;
		LDA	URAFLG
		BEQ	SHTSF0		; Ura ?
;					; yes !
		LDA	HEMODE,X
		AND	#03H
		STA	HEMODE,X	; Not laser !
SHTSF0		EQU	$
		LDA	HEMODE,X
		CMP	#SBCT
		BNE	SHTS00		; Beam laser ?
;					; yes !
		STZ	HEMODE,X
;
;;		JSL	>EYEBMST		
;;		JSL	>SDLRCE
;;		ORA	#26H
;;		STA	SOUND3	;(S)
		LDA	#26H
		JSL	>SDLRE3	;(S)
;
		JSR	SHBMST
SHBMST		EQU	$
		JSL	>EYEBMST		
		JSL	>EYEBMST		
		RTS
SHTS00		EQU	$
		LDA	#SHTAM
		JSL	>ENIDSH
		BMI	SHTS10
;
;;		JSL	>SDLRCE
;;		ORA	#29H
;;		STA	SOUND3	;(S)
		LDA	#29H
		JSL	>SDLRE3	;(S)
;
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	<WORK0
		CLC
		ADC	SHTSXL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	SHTSXH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	SHTSYL,X
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#0FFH
		STA	ENYPSH,Y
		STA	ENNOCR,Y
;;		TYX
;;		LDA	#20H
;;		JSL	>PSERCHL
		PLX
		LDA	ENXSPD,X
		STA	ENXSPD,Y
		LDA	ENYSPD,X
		STA	ENYSPD,Y
;
		LDA	HEMODE,X
		CMP	#02H
		BCC	SHTS10
;
		JSL	>RNDSET
;;		JSL	>RNDSET
;;		JSL	>RNDSET
;;		JSL	>RNDSET
		AND	#01H
		BNE	SHTS10
;
		LDA	#01H
		STA	ENWRK1,Y
		LDA	#20H
		STA	ENTIM0,Y
SHTS10		EQU	$
		RTS
;------------------------------------------------
SHMOVE		EQU	$
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		STA	<WORK5
		LDA	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
		STA	<WORK7
;
		LDA	ENWRK2,X
		STA	<WORK4
		LDA	ENWRK3,X
		STA	<WORK6
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		SEC
		SBC	<WORK4
		CLC
		ADC	#0007H
		CMP	#000EH
		BCS	SHM010
		LDA	<WORK2
		SEC
		SBC	<WORK6
		CLC
		ADC	#0007H
		CMP	#000EH
		BCS	SHM010
		MEM8
		SEP	#00100000B
;
		LDA	ENWRK2,X
		STA	ENXPSL,X
		LDA	ENWRK3,X
		STA	ENYPSL,X
		JMP	UPSET
SHM010		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	ENCTCT,X
		JSL	>ESERCHL		
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;- -- -
;;		LDA	<FRCNT
;;		AND	#00H
;;		BNE	SHM030
;
		LDA	ENCTCT,X
		CMP	#40H
		BCS	SHM030
;
		INC	ENCTCT,X
SHM030		EQU	$
		JSR	ENMVCL
		RTS
;================================================
SHCXAD		EQU	$
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
;
		HEX	F8,08,F8,08
		HEX	FA,06,FA,06
		HEX	F8,08,F8,08
		HEX	FA,06,FA,06
		HEX	00,08,00,08
;
		HEX	F8,08,F8,08
SHCYAD		EQU	$
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
;
		HEX	F8,F8,08,08
		HEX	FA,FA,06,06
		HEX	F8,F8,08,08
		HEX	FA,FA,06,06
		HEX	00,00,08,08
;
		HEX	08,08,08,08
SHCCDT		EQU	$
		HEX	82,82,A2,A2
		HEX	80,80,A0,A0
		HEX	84,84,A4,A4
		HEX	86,86,A6,A6
		HEX	88,8A,A8,AA
		HEX	8C,8E,AC,AE
		HEX	C4,C2,E4,E6
		HEX	C0,C2,E0,E2
;
		HEX	8A,88,AA,A8
		HEX	8E,8C,AE,AC
		HEX	C2,C4,E6,E4
		HEX	C2,C0,E2,E0
;
		HEX	EC,EC,EC,EC
		HEX	EC,EC,EC,EC
		HEX	EE,EE,EE,EE
		HEX	EE,EE,EE,EE
		HEX	DF,DF,DF,DF
;
		HEX	40,42,40,42
SHCADT		EQU	$
		HEX	00,40,00,40
		HEX	00,40,00,40
		HEX	00,40,00,40
		HEX	00,40,00,40
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	00,00,00,00
;
		HEX	40,40,40,40
		HEX	40,40,40,40
		HEX	40,40,40,40
		HEX	40,40,40,40
;
		HEX	00,40,80,C0
		HEX	00,40,80,C0
		HEX	00,40,80,C0
		HEX	00,40,80,C0
		HEX	00,40,80,C0
;
		HEX	00,00,00,00
;--- Fire c set ----
SHFXAD		EQU	$
;- - Muki 3 - -
		HEX	F9,0F
		HEX	F5,0B
		HEX	F5,0B
		HEX	F8,08
		HEX	FC,04
		HEX	00,00
;- - Muki 4 - -
		HEX	F6,FF
		HEX	F2,FB
		HEX	F2,FB
		HEX	F4,F9
		HEX	F6,F9
		HEX	F6,F6
;- - Muki 2 - -
		HEX	10,08
		HEX	0C,04
		HEX	0C,04
		HEX	0A,06
		HEX	09,07
		HEX	08,08
;- - Muki 5 - -
		HEX	FA,FA
		HEX	F6,F6
		HEX	F6,F6
		HEX	F6,F6
		HEX	F6,F6
		HEX	F6,F6
;- - Muki 1 - -
		HEX	0E,0E
		HEX	0A,0A
		HEX	0A,0A
		HEX	0A,0A
		HEX	0A,0A
		HEX	0A,0A
;- - Muki 0 - -
		HEX	F9,0F
		HEX	F5,0B
		HEX	F5,0B
		HEX	F8,08
		HEX	FC,04
		HEX	00,00
SHFYAD		EQU	$
; -- Muki 3 - -
		HEX	FB,FB
		HEX	F7,F7
		HEX	F7,F7
		HEX	F7,F7
		HEX	F7,F7
		HEX	F7,F7
;- - MUKI 4 -
		HEX	FD,09
		HEX	F9,05
		HEX	F9,05
		HEX	FB,03
		HEX	FD,03
		HEX	FE,FE
;- - MUKI 2 -
		HEX	FD,09
		HEX	F9,05
		HEX	F9,05
		HEX	FB,03
		HEX	FD,03
		HEX	FE,FE
;- - MUKI 5 -
		HEX	FD,09
		HEX	F9,05
		HEX	F9,05
		HEX	FB,03
		HEX	FD,03
		HEX	FE,FE
;- - MUKI 1 -
		HEX	FD,09
		HEX	F9,05
		HEX	F9,05
		HEX	FB,03
		HEX	FD,03
		HEX	FE,FE
; -- Muki 0 - -
		HEX	FB,FB
		HEX	F7,F7
		HEX	F7,F7
		HEX	F7,F7
		HEX	F7,F7
		HEX	F7,F7
;
SHFCDT		EQU	$
		HEX	CE,CC,C6,C6,C6,C6
		HEX	CE,CC,C6,C6,C6,C6
		HEX	CE,CC,C6,C6,C6,C6
		HEX	CE,CC,C6,C6,C6,C6
		HEX	CE,CC,C6,C6,C6,C6
		HEX	CE,CC,C6,C6,C6,C6
SHFSBD		EQU	$
		HEX	00,02,02,02,02,02
		HEX	00,02,02,02,02,02
		HEX	00,02,02,02,02,02
		HEX	00,02,02,02,02,02
		HEX	00,02,02,02,02,02
		HEX	00,02,02,02,02,02
;- - - - - - - - - - - - - - - - - -
SHCRTS		EQU	$
		RTS
SHSAICS		EQU	$
		JSR	OAMCHK
;;		LDA	ENSTAT,X
;;		BEQ	SHCRTS		; CHR set ok ?
;- - - - Body set - - - - -		; yes !
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORK6
;
		PHX
		LDX	#03H
SHC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	SHCXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	SHCYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	SHCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	SHCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
;
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		CPX	#11H*4
		BCS	SHC030
		CPX	#10H*4
		BCC	SHC030
		LDA	#00H
SHC030		EQU	$		
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	SHC010
;
		PLX
;
;
		LDA	ENCHPT,X
		CMP	#0CH
		BCS	SHC038
;
		LDA	#12H
		JSL	>SADWS2L
SHC038		EQU	$
		LDA	<GAMEMD
		BEQ	SHC039
;
		LDY	#0FFH
		LDA	#03H
		JSL	>ALOMCKL
SHC039		EQU	$
;
;;		LDY	#0FFH
;;		LDA	#03H
;;		JSL	>ALOMCKL
;
		JSR	OAMCHK
;- - FIRE SET - -
		LDA	#04H*2
		LDY	ENMUKI,X
		BEQ	SHC0A0		; Ue muki ?
;					; yuusen set !
		JSL	>OAMENT3
		BRA	SHC0A8
SHC0A0		EQU	$
		JSL	>OAMENT2
SHC0A8		EQU	$
		LDY	#00H
		LDA	ENCMKI,X
		BEQ	SHC0B0
		DEC	A
		STA	<WORKC
		ASL	A
		STA	<WORK6
;
		LDA	<FRCNT
		LSR	A
		AND	#00000010B
		INC	A
		INC	A
		ORA	#00110001B
		STA	<WORKD
;
		PHX
		LDX	#01H
SHC040		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
;
		LDA	<WORK0
		CLC
		ADC	SHFXAD,X
		STA	(<OAMADR),Y				
;
		LDA	<WORK2
		CLC
		ADC	SHFYAD,X
		INY
		STA	(<OAMADR),Y
;
		LDX	<WORKC
		LDA	SHFCDT,X
		INY
		STA	(<OAMADR),Y
		INY
		LDA	<WORKD
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	SHFSBD,X
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	SHC040		
;
		PLX
SHC0B0		EQU	$
		RTS
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SHSAI TAMA 	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SHTAMMV		EQU	$
		LDA	ENWRK1,X
		BEQ	STM000
;
		LDA	ENTIM0,X
		BEQ	STM0F0
;
		LDA	#20H
		JSL	>PSERCHL
STM0F0		EQU	$
;
		LDA	#04H+1
		BRA	STM111
STM000		EQU	$
		LDA	<FRCNT
		LSR	A
		AND	#00000010B
		INC	A
		INC	A
		ORA	#00000001B
STM111		EQU	$
		STA	ENCLOR,X
;
		LDA	ENSTAT,X
		BEQ	STM001
		JMP	SHZANZ
STM001		EQU	$
		LDA	ENWRK1,X
		BEQ	STM012
;
		JSR	SHTAMCS
		BRA	STM013
STM012		EQU	$
		JSL	>EN1CSTL
STM013		EQU	$
		JSR	ENSTCK
;
		INC	ENCONT,X
;
		JSR	ENMVCL
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	STM005
		STZ	ENMODE,X
		LDA	ENWRK1,X
		BNE	STM555
STM005		EQU	$
;
		LDA	ENWRK0,X
		BEQ	STM008
;
		LDA	ENNOCR+00H
		BNE	STM008
;- - Hnaekairi ---> shisai - -
                LDA     ENXPSL,X
                STA     <WORK0
                LDA     ENXPSH,X
                STA     <WORK8
                LDA     #0FH
                STA     <WORK2
                STA     <WORK3
                LDA     ENYPSL,X
                STA     <WORK1
                LDA     ENYPSH,X
                STA     <WORK9
		PHX
		LDX	#00H
		JSL	>ENCRST2
		PLX
		JSL	>CROJCK2
		BCC	STM007
;
		PHX
;;		LDX	#00H
;;		LDA	#0DH		; Mahou to onagi !
		LDA	#20H+80H
		STA	<WORK0
		LDA	#10H	; Dec power !
		LDX	#00H
		JSL	>ENDMST4
		PLX
		STZ	ENMODE,X
		LDA	ENXSPD,X
		STA	ENHNXS
		LDA	ENYSPD,X
		STA	ENHNYS
STM007		EQU	$
		BRA	STM010
;- - - - - - - - - -
STM008		EQU	$
;;		JSR	CREKEK
		JSR	CRENPL
		JSL	>CRKNENL
		BCC	STM010		; Ken hit ?
;					; yes !
		LDA	ENWRK1,X
		BEQ	STM009
		STZ	ENMODE,X
;
STM555		EQU	$
		LDA	#36H
		JSL	>SDLRE3	;(S)
;
		JSR	BAKUST
;
		RTS
STM009		EQU	$
;;		JSL	>SDLRCE
;;		PHA
;;		ORA	#05H
;;		STA	SOUND2	;(S)
;;		PLA
;;		ORA	#29H
;;		STA	SOUND3	;(S)
;
		LDA	#05H
		JSL	>SDLRE2	;(S)
		LDA	#29H
		JSL	>SDLRE3	;(S)
;
		LDA	#30H		
		JSL	>PSERCHL
		LDA	<WORK1
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		LDA	<WORK0
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		INC	ENWRK0,X
;- - - - - - - - - - - - - - - - - - -
STM010		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		ORA	ENWRK1,X
		BNE	STM020
		LDA	#SHTAM
		JSL	>ENIDSH
		BMI	STM020
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
		LDA	#0FH
		STA	ENTIM0,Y
		STA	ENSTAT,Y
		LDA	ENWRK1,X
		STA	ENWRK1,Y
STM020		EQU	$
		RTS
;- - - - - - - - - - - - - - -
SHZCDT		EQU	$
		HEX	2,2,2,2,2,2,2,1,1,1,1,1,0,0,0,0
SHZANZ		EQU	$
		LDA	ENCHPT,X
		CMP	#02H
		BEQ	SHZ020
		JSL	>EN1CSTL
		BRA	SHZ028
SHZ020		EQU	$
		JSL	>EN1CSSL
SHZ028		EQU	$
		JSR	ENSTCK
;
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	SHZ010
		STZ	ENMODE,X
SHZ010		EQU	$
		TAY
		CMP	#06H
		BNE	SHZ018
;
		LDA	#40H
		STA	ENXSPD,X
		STA	ENYSPD,X
		JSR	ENMVCL
SHZ018		EQU	$
		LDA	SHZCDT,Y
		STA	ENCHPT,X
		RTS
;=======================================
Z2SXSD		EQU	$
		HEX	00,18,18,00,E8,E8 ;,20,E0
Z2SYSD		EQU	$
		HEX	E0,F0,10,20,10,F0 ;,00,00
;
BAKUST		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#36H
;;		STA	SOUND3	;(S)
		LDA	#36H
		JSL	>SDLRE3	;(S)
;
		LDA	#05H
		STA	ENHELP
BS0000		EQU	$
		JSR	BS0010
		DEC	ENHELP
		BNE	BS0000
;		
BS0010		EQU	$
                LDA     #ZORAS
                JSL     >ENIDSH
                BMI     Z2TS90
;
                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     ENMOD2,Y
                AND     #11111110B
                ORA     #01000000B
                STA     ENMOD2,Y
                LDA     #04H
                STA     ENCLOR,Y
		STA	ENTIM1,Y
                LDA     #14H
                STA     ENMOD3,Y
                STA     ENWRK2,Y
                STA     ENWRK3,Y
		PHX
		LDX	ENHELP
		LDA	Z2SXSD,X
		STA	ENXSPD,Y
		LDA	Z2SYSD,X
		STA	ENYSPD,Y
		PLX
Z2TS90          EQU     $
                RTS
;================================================
SHTAMCD		EQU	$
		WORD	00004H,0FFFDH
		HEX	CE,00,00,00
		WORD	0000BH,00004H
		HEX	CE,00,00,00
		WORD	00004H,0000BH
		HEX	CE,00,00,00
		WORD	0FFFDH,00004H
		HEX	CE,00,00,00
;
		WORD	0FFFFH,0FFFFH
		HEX	CE,00,00,00
		WORD	00009H,0FFFFH
		HEX	CE,00,00,00
		WORD	0FFFFH,00009H
		HEX	CE,00,00,00
		WORD	00009H,00009H
		HEX	CE,00,00,00
;
SHTAMCS		EQU	$
		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	#SHTAMCD  
		STA	<WORK8
;
		MEM8
		SEP	#00100000B
;
		LDA	#04H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	HACHI  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HACHIMV		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HACHIF0
		WORD	HACHIF1
		WORD	HACHIF2
;========================================
HACHIF0		EQU	$
		LDA	ENWRK3,X
		BNE	HCIF010
;
		STZ	ENMODE,X	;KILL I
;
		LDY	#00BH
HCIF020		EQU	$
		PHY
		JSR	HACHIST
		PLY
		DEY
		BPL	HCIF020
;
HCIF010		EQU	$
		RTS
;----------------------------------------
HCISTSX		EQU	$
HCISTSY		EQU	$
BEESTSX		EQU	$
BEESTSY		EQU	$
		BYTE	018,006,-06,-18,024,012,-12,-24
BEEPSSX		EQU	$
BEEPSSY		EQU	$
		BYTE	010,002,-02,-10,012,006,-06,-12
;
HCISTTD		EQU	$
;		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,0FFH,0FFH
;
HACHIST		EQU	$
		LDA	#HACHI
		JSL	>ENIDSH
		BMI	HCIST10
;
		JSL	>ENIDPS
;
HCIST20		EQU	$
		PHX
;
		LDA	#001H		;BATTEL HACHI
		STA	ENSTAT,Y
		TYA
		AND	#003H
		TAX
		LDA	HCISTTD,X	;INIT TIME
		STA	ENTIM0,Y	
;		LDA	#040H		;SERCH INIT TIME
		STA	ENWRK0,Y
		LDA	#060H		;NOT TUCH TIME
		STA	ENTIM3,Y
;					;INIT MUKI
		JSL	>RNDSET
		AND	#007H
		TAX
		LDA	HCISTSX,X
		STA	ENXSPD,Y
		JSL	>RNDSET
		AND	#007H
		TAX
		LDA	HCISTSY,X
		STA	ENYSPD,Y
		PLX
HCIST10		EQU	$
		RTS
;----------------------------------------
HACHISTL	EQU	$		;PL. BIN USE
		PHB
		PHK
		PLB
		LDA	#BEE00
		JSL	>ENIDSH
       		BMI	HCISTL30
;
		LDA	<PLBGCKF
		STA	ENKAIF,Y
;
		LDA	<PLXPS1
		CLC
		ADC	#008H
		STA	ENXPSL,Y
		LDA	<PLXPS0
		ADC	#000H
		STA	ENXPSH,Y
		LDA	<PLYPS1
		CLC
		ADC	#010H
		STA	ENYPSL,Y
		LDA	<PLYPS0
		ADC	#000H
		STA	ENYPSH,Y
;
		PHX
		LDX	GETITM0
		LDA	>ITEMR01-1,X
		TAX
		LDA	>BINCT0-1,X
		CMP	#008H
		BNE	HCISTL20
		LDA	#001H
		STA	ENCMKI,Y
HCISTL20	EQU	$
;
		JSR	HCIST20
		JSL	>RNDSET
		AND	#007H
		TAX
		LDA	BEEPSSX,X
		STA	ENXSPD,Y
		JSL	>RNDSET
		AND	#007H
		TAX
		LDA	BEEPSSX,X
		STA	ENYSPD,Y
		LDA	#040H
		STA	ENTIM0,Y
		STA	ENWRK0,Y
		PLX
HCISTL10	EQU	$
		PLB
		LDA	#000H		;SET
		RTL
HCISTL30	EQU	$
		PLB
		LDA	#0FFH		;NOT SET
		RTL
;----------------------------------------
HCIF1PX		EQU	$
HCIF1PY		EQU	$
BEEF1PX		EQU	$
BEEF1PY		EQU	$
		BYTE	000,005,010,015
HACHIF1		EQU	$		;BATTLE	HACHI
		JSR	BEE0ATR
		JSL	>EN1CSSL
;
		JSR	HACHI1T		;1 TIME GET 1
;
		JSR	ENSTCK		;scroll : not return
		JSR	ENHNSB
		LDA	ENCMKI,X
		BEQ	HCIF1F0
		JSL	>ICEF2ST	;KIRA KIRA
HCIF1F0		EQU	$
;
		JSR	HACHIOT		;SOUND SET
		JSR	ENMVCL		;xclc,yclc
		TXA
		EOR	<FRCNT
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENTIM3,X
		BNE	HCIF130
		JSR	CRENPL	 	;PL. BODY CHK
		JSL	>CRKNENL	;PL. KEN CHK
		BEQ	HCIF130
		LDA	#LOW  MS_0340	;MSGE NO
		LDY	#HIGH MS_0340	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X	;YES OR NO
		RTS
HCIF130		EQU	$
;
		LDA	<FRCNT		;SERCH TIME DEC
		BNE	HCIF120
		LDA	ENWRK0,X
		CMP	#010H
		BEQ	HCIF120
		SEC
		SBC	#008H
		STA	ENWRK0,X
HCIF120		EQU	$
;
		LDA	ENTIM0,X
		BNE	HCIF110
;
		JSL	>RNDSET
		AND	#003H
		TAY
		LDA	<PLXPS1
		CLC
		ADC	HCIF1PX,Y
		STA	<WORK4
		LDA	<PLXPS0
		ADC	#000H
		STA	<WORK5
		JSL	>RNDSET
		AND	#003H
		TAY
		LDA	<PLYPS1
		CLC
		ADC	HCIF1PY,Y
		STA	<WORK6
		LDA	<PLYPS0
		ADC	#000H
		STA	<WORK7
;
		LDA	#018H		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
;
		LDA	<WORK0		;SPEED SET
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		BPL	HCIF140		;MUKI SET
		LDA	ENCLOR,X
		AND	#0BFH
		BRA	HCIF150
HCIF140		EQU	$
		LDA	ENCLOR,X
		ORA	#040H
HCIF150		EQU	$
		STA	ENCLOR,X
;
		TXA
		CLC
		ADC	ENWRK0,X
		STA	ENTIM0,X
;
HCIF110		EQU	$
		RTS
;----------------------------------------
HACHIF2		EQU	$
BEE00F2		EQU	$
;		JSL	>EN1CSSL
		JSR	HACHI1T		;1 TIME GET 1
		JSR	ENSTCK		;scroll : not return
;
		LDA	MSG_RTS
		BNE	HCIF210
;
		JSL	>BINCHKL	;BIN AKI CHK (A <- INDEX)
		BMI	HCIF220
		LDA	ENCMKI,X
		STA	<WORK0
		PHX
		TYX
		LDA	#007H
		CLC
		ADC	<WORK0
		STA	>BINCT0,X
		JSL	>ITEM0ST	;meter set
		PLX
		STZ	ENMODE,X	;KILL I
		RTS
HCIF220		EQU	$
		LDA	#LOW  MS_0342	;MSGE NO
		LDY	#HIGH MS_0342	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
;
HCIF210		EQU	$
		LDA	#040H
		STA	ENTIM3,X
		LDA	#001H
		STA	ENSTAT,X
		RTS
;----------------------------------------
BINCHKL		EQU	$
		PHX
		LDX	#000H
BNCHL10		EQU	$
		LDA	>BINCT0,X
		CMP	#002H
		BEQ	BNCHL20
		INX
		CPX	#004H
		BCC	BNCHL10
		LDX	#0FFH
BNCHL20		EQU	$
		TXY
		PLX
		TYA
		RTL
;----------------------------------------
HACHI1T		EQU	$
		LDA	<GAMEMD
		CMP	#002H
		BNE	HCI1T10
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	MSGENOL
		CMP	#MS_0340
		BEQ	HCI1T20
		CMP	#MS_0342
		BNE	HCI1T10
HCI1T20		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		LDA	#028H
		STA	ENTIM3,X
HCI1T10		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BEE00  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BEE00MV		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BEE00F0
		WORD	BEE00F1
		WORD	BEE00F2
;
BEE00F0		EQU	$
		LDA	ENWRK3,X
		BNE	BEEF010
		STZ	ENMODE,X	;KILL I
		LDA	>BINCT0
		ORA	>BINCT1
		ORA	>BINCT2
		ORA	>BINCT3
		AND	#008H
		BNE	BEEF010
		JSR	BEE00ST
BEEF010		EQU	$
		RTS
;----------------------------------------
;BEESTSX		EQU	$
;BEESTSY		EQU	$
;		BYTE	004,002,-02,-04,005,003,-03,-05
;
BEE00ST		EQU	$
		LDA	#HACHI
		JSL	>ENIDSH
		BMI	BEEST10
;
		JSL	>ENIDPS
;
BEEST20		EQU	$
		LDA	#001H		;BATTEL HACHI
		STA	ENSTAT,Y
		LDA	#040H		;INIT TIME
		STA	ENTIM0,Y	
;		LDA	#040H		;SERCH INIT TIME
		STA	ENWRK0,Y
		LDA	#060H		;NOT TUCH TIME
		STA	ENTIM3,Y
		LDA	#001H		;FLASH
		STA	ENCMKI,Y
;

		PHX			;INIT MUKI
		JSL	>RNDSET
		AND	#007H
		TAX
		LDA	BEESTSX,X
		STA	ENXSPD,Y
		JSL	>RNDSET
		AND	#007H
		TAX
		LDA	BEESTSY,X
		STA	ENYSPD,Y
		PLX
BEEST10		EQU	$
		RTS
;----------------------------------------
BEE00AT		EQU	$
		BYTE	010,020
;
BEE00F1		EQU	$		;BATTLE	HACHI
		LDA	#001H
		STA	ENNOCR,X
		JSR	BEE0ATR
		JSL	>EN1CSSL
		JSR	HACHI1T		;1 TIME GET 1
		JSR	ENSTCK		;scroll : not return
		JSR	HACHIOT		;SOUND SET
		JSR	ENMVCL		;xclc,yclc
;
		TXA
		EOR	<FRCNT
		LSR	A
		AND	#001H
		STA	ENCHPT,X	;E SET
;
		LDA	ENCMKI,X
		BEQ	BEEF120
		JSL	>ICEF2ST	;KIRA KIRA
BEEF120		EQU	$
		LDA	ENWRK1,X
		LDY	ENCMKI,X
		CMP	BEE00AT,Y
		BCC	BEEF180
		LDA	#040H		;GAMEN GAI CLS
		STA	ENMOD5,X
		RTS
;
BEEF180		EQU	$
		LDA	ENTIM3,X	;NOT MOVE
		BNE	BEEF140
;
;
		JSL	>CRKNENL	;PL. KEN CHK
		BEQ	BEEF190
		LDA	#LOW  MS_0340	;MSGE NO
		LDY	#HIGH MS_0340	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X	;YES OR NO
		RTS
;
BEEF190		EQU	$
;--
;					;EN. CHK
		TXA
		EOR	<FRCNT
		AND	#003H
		BNE	BEEF140
		JSR	BEE00SH
		BCS	BEEF130
;
;--
;					;NOT ENMY (PL. SERCH)
		TXA
		EOR	<FRCNT
		AND	#003H
		BNE	BEEF140
		JSL	>RNDSET		;NOT ENMY
		AND	#003H		;(PL. SERCH)
		TAY
		LDA	<PLXPS1
		CLC
		ADC	BEEF1PX,Y
		STA	<WORK4
		LDA	<PLXPS0
		ADC	#000H
		STA	<WORK5
		JSL	>RNDSET
		AND	#003H
		TAY
		LDA	<PLYPS1
		CLC
		ADC	BEEF1PY,Y
		STA	<WORK6
		LDA	<PLYPS0
		ADC	#000H
		STA	<WORK7
;
BEEF130		EQU	$
		TXA
		EOR	<FRCNT
		AND	#007H
		BNE	BEEF140
;
		LDA	#026H		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
;
		LDA	<WORK0		;SPEED SET
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		BPL	BEEF160		;MUKI SET
		LDA	ENCLOR,X
		AND	#0BFH
		BRA	BEEF170
BEEF160		EQU	$
		LDA	ENCLOR,X
		ORA	#040H
BEEF170		EQU	$
		STA	ENCLOR,X
;
BEEF140		EQU	$
		RTS
;
;
;
;
;+;+;+;+;BEE00F1		EQU	$		;BATTLE	HACHI
;+;+;+;+;		LDA	ENCMKI,X
;+;+;+;+;		BEQ	BEEF160
;+;+;+;+;		LDA	ENCLOR,X	;FLASH COLOR
;+;+;+;+;		AND	#0F1H
;+;+;+;+;		ORA	#010H
;+;+;+;+;		STA	<WORK0
;+;+;+;+;		LDA	<FRCNT
;+;+;+;+;		ASL	A
;+;+;+;+;		ASL	A
;+;+;+;+;		AND	#00EH
;+;+;+;+;		ORA	<WORK0
;+;+;+;+;		STA	ENCLOR,X
;+;+;+;+;		LDA	ENWRK1,X
;+;+;+;+;		CMP	BEE00AT+1
;+;+;+;+;		BCS	BEEF160
;+;+;+;+;		STZ	ENWRK0,X	;SERCH TIME
;+;+;+;+;BEEF160		EQU	$
;+;+;+;+;		JSL	>EN1CSSL
;+;+;+;+;;
;+;+;+;+;		JSR	HACHI1T		;1 TIME GET 1
;+;+;+;+;;
;+;+;+;+;		JSR	ENSTCK		;scroll : not return
;+;+;+;+;		LDA	ENCMKI,X
;+;+;+;+;		BEQ	BEEF1F0
;+;+;+;+;		JSL	>ICEF2ST	;KIRA KIRA
;+;+;+;+;BEEF1F0		EQU	$
;+;+;+;+;		JSR	HACHIOT		;SOUND SET
;+;+;+;+;		JSR	ENMVCL		;xclc,yclc
;+;+;+;+;		TXA
;+;+;+;+;		EOR	<FRCNT
;+;+;+;+;		LSR	A
;+;+;+;+;		AND	#001H
;+;+;+;+;		STA	ENCHPT,X
;+;+;+;+;;
;+;+;+;+;		LDA	ENTIM3,X
;+;+;+;+;		BNE	BEEF130
;+;+;+;+;;		JSL	>CRHCEN	 	;EN. BODY CHK
;+;+;+;+;BEEF1D0		EQU	$
;+;+;+;+;		JSL	>CRKNENL	;PL. KEN CHK
;+;+;+;+;		BEQ	BEEF130
;+;+;+;+;		LDA	#LOW  MS_0340	;MSGE NO
;+;+;+;+;		LDY	#HIGH MS_0340	;MSGE NO
;+;+;+;+;		JSL	>ENMSGSL	;MSGE SET
;+;+;+;+;		INC	ENSTAT,X	;YES OR NO
;+;+;+;+;		RTS
;+;+;+;+;BEEF130		EQU	$
;+;+;+;+;;
;+;+;+;+;		LDA	<FRCNT		;SERCH TIME DEC
;+;+;+;+;		BNE	BEEF120
;+;+;+;+;		LDA	ENWRK0,X
;+;+;+;+;		BEQ	BEEF120
;+;+;+;+;		SEC
;+;+;+;+;		SBC	#010H
;+;+;+;+;		STA	ENWRK0,X
;+;+;+;+;BEEF120		EQU	$
;+;+;+;+;;
;+;+;+;+;		LDA	ENTIM0,X
;+;+;+;+;		BEQ	BEEF1B0
;+;+;+;+;		RTS
;+;+;+;+;;
;+;+;+;+;BEEF1B0		EQU	$
;+;+;+;+;		LDA	ENWRK1,X
;+;+;+;+;		LDY	ENCMKI,X
;+;+;+;+;		CMP	BEE00AT,Y
;+;+;+;+;		BCS	BEEF1C0
;+;+;+;+;		LDA	#00FH		;EN. CHK
;+;+;+;+;		STA	<WORK0
;+;+;+;+;		TXA
;+;+;+;+;		ASL	A
;+;+;+;+;		ASL	A
;+;+;+;+;		AND	#00FH
;+;+;+;+;		TAY
;+;+;+;+;BEEF170		EQU	$
;+;+;+;+;		JSR	BEE00SH
;+;+;+;+;		BCS	BEEF180
;+;+;+;+;BEEF190		EQU	$
;+;+;+;+;		DEY
;+;+;+;+;		TYA
;+;+;+;+;		AND	#00FH
;+;+;+;+;		TAY
;+;+;+;+;		DEC	<WORK0
;+;+;+;+;		BPL	BEEF170
;+;+;+;+;;
;+;+;+;+;BEEF1C0		EQU	$
;+;+;+;+;		JSL	>RNDSET		;NOT ENMY
;+;+;+;+;		AND	#003H		;(PL. SERCH)
;+;+;+;+;		TAY
;+;+;+;+;		LDA	<PLXPS1
;+;+;+;+;		CLC
;+;+;+;+;		ADC	BEEF1PX,Y
;+;+;+;+;		STA	<WORK4
;+;+;+;+;		LDA	<PLXPS0
;+;+;+;+;		ADC	#000H
;+;+;+;+;		STA	<WORK5
;+;+;+;+;		JSL	>RNDSET
;+;+;+;+;		AND	#003H
;+;+;+;+;		TAY
;+;+;+;+;		LDA	<PLYPS1
;+;+;+;+;		CLC
;+;+;+;+;		ADC	BEEF1PY,Y
;+;+;+;+;		STA	<WORK6
;+;+;+;+;		LDA	<PLYPS0
;+;+;+;+;		ADC	#000H
;+;+;+;+;		STA	<WORK7
;+;+;+;+;;
;+;+;+;+;		LDA	ENWRK1,X
;+;+;+;+;		LDY	ENCMKI,X
;+;+;+;+;		CMP	BEE00AT,Y
;+;+;+;+;		BCC	BEEF1A0
;+;+;+;+;;
;+;+;+;+;		LDA	#0E0H
;+;+;+;+;		STA	ENWRK0,X
;+;+;+;+;		LDA	#040H		;GAMEN GAI CLS
;+;+;+;+;		STA	ENMOD5,X
;+;+;+;+;;
;+;+;+;+;		BRA	BEEF1A0
;+;+;+;+;BEEF180		EQU	$
;+;+;+;+;;					;ENMY SERCH
;+;+;+;+;		PHX
;+;+;+;+;		TYX
;+;+;+;+;		JSL	>RNDSET
;+;+;+;+;		AND	#003H
;+;+;+;+;		TAY
;+;+;+;+;		LDA	ENXPSL,X
;+;+;+;+;		CLC
;+;+;+;+;		ADC	BEEF1PX,Y
;+;+;+;+;		STA	<WORK4
;+;+;+;+;		LDA	ENXPSH,X
;+;+;+;+;		ADC	#000H
;+;+;+;+;		STA	<WORK5
;+;+;+;+;		JSL	>RNDSET
;+;+;+;+;		AND	#003H
;+;+;+;+;		TAY
;+;+;+;+;		LDA	ENYPSL,X
;+;+;+;+;		CLC
;+;+;+;+;		ADC	BEEF1PY,Y
;+;+;+;+;		STA	<WORK6
;+;+;+;+;		LDA	ENYPSH,X
;+;+;+;+;		ADC	#000H
;+;+;+;+;		STA	<WORK7
;+;+;+;+;		PLX
;+;+;+;+;;
;+;+;+;+;BEEF1A0		EQU	$
;+;+;+;+;		LDA	#020H		;SERCH SPEED SET
;+;+;+;+;		JSL	>ESERCHL	;SERCH
;+;+;+;+;;
;+;+;+;+;		LDA	<WORK0		;SPEED SET
;+;+;+;+;		STA	ENYSPD,X
;+;+;+;+;		LDA	<WORK1
;+;+;+;+;		STA	ENXSPD,X
;+;+;+;+;;
;+;+;+;+;		BPL	BEEF140		;MUKI SET
;+;+;+;+;		LDA	ENCLOR,X
;+;+;+;+;		AND	#0BFH
;+;+;+;+;		BRA	BEEF150
;+;+;+;+;BEEF140		EQU	$
;+;+;+;+;		LDA	ENCLOR,X
;+;+;+;+;		ORA	#040H
;+;+;+;+;BEEF150		EQU	$
;+;+;+;+;		STA	ENCLOR,X
;+;+;+;+;;
;+;+;+;+;		TXA
;+;+;+;+;		CLC
;+;+;+;+;		ADC	ENWRK0,X
;+;+;+;+;		STA	ENTIM0,X
;+;+;+;+;;
;+;+;+;+;BEEF110		EQU	$
;+;+;+;+;		RTS
;----------------------------------------
BEE0ATR		EQU	$
		LDA	#010H		;Z POS
		STA	ENZPSL,X
;
		LDA	ENCMKI,X
		BEQ	BEATR10
		LDA	ENCLOR,X
		AND	#0F1H
		STA	<WORK0
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		INC	A
		ASL	A
		ORA	<WORK0
		STA	ENCLOR,X
BEATR10		EQU	$
		RTS
;----------------------------------------
BEE00SH		EQU	$
		LDA	#00FH		;EN. CHK
		STA	<WORK0
		TXA
		ASL	A
		ASL	A
		AND	#00FH
		TAY
BE0SH40		EQU	$
		CPY	ENINDX
		BEQ	BE0SH20
;
		LDA	ENMODE,Y
		CMP	#EMOVE
		BCC	BE0SH20
;
		LDA	ENDSPL,Y
		BNE	BE0SH20
;
		LDA	ENMOD0,Y
		BMI	BE0SH30
;
		LDA	ENKAIF,Y
		CMP	ENKAIF,X
		BNE	BE0SH20
;
		LDA	ENMOD3,Y
		AND	#040H
		BNE	BE0SH20
		LDA	ENNOCR,Y
		BEQ	BE0SH10
		BRA	BE0SH20
BE0SH30		EQU	$
		LDA	ENCMKI,X
		BEQ	BE0SH20
		LDA	ENMOD6,Y
		AND	#040H
		BNE	BE0SH10
;
BE0SH20		EQU	$
		DEY
		TYA
		AND	#00FH
		TAY
		DEC	<WORK0
		BPL	BE0SH40
		CLC
		RTS
;
BE0SH10		EQU	$
		JSL	>CRHCEN
;
		PHX
		JSL	>RNDSET
		AND	#003H
		TAX
		LDA	ENXPSL,Y
		CLC
		ADC	BEEF1PX,X
		STA	<WORK4
		LDA	ENXPSH,Y
		ADC	#000H
		STA	<WORK5
		JSL	>RNDSET
		AND	#003H
		TAX
		LDA	ENYPSL,Y
		CLC
		ADC	BEEF1PY,X
		STA	<WORK6
		LDA	ENYPSH,Y
		ADC	#000H
		STA	<WORK7
		PLX
;
		SEC
		RTS
;
;----------------------------------------
HACHIOT		EQU	$
		TXA
		EOR	<FRCNT
		AND	#01FH
		BNE	HCIOT10
;;		JSL	>SDLRCE
;;		ORA	#02CH
;;		STA	SOUND3
		LDA	#2CH
		JSL	>SDLRE3	;(S)
HCIOT10		EQU	$
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SEKBN  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SKBNM0L		EQU	$
		BYTE	LOW  MS_0242,LOW  MS_0243
SKBNM0H		EQU	$
		BYTE	HIGH MS_0242,HIGH MS_0243
;
SKBNM1L		EQU	$
		BYTE	LOW  MS_0249,LOW  MS_024A
SKBNM1H		EQU	$
		BYTE	HIGH MS_0249,HIGH MS_024A
;
SEKBNMV		EQU	$
		JSL	>OAMCHKL
		JSR	ENSTCK		; scroll : not return !
;
		LDA	PYALSP
		BNE	SKNMV20
		JSL	>WPMSCK
		BCC	SKNMV10
SKNMV20		EQU	$
		RTS
;
SKNMV10		EQU	$
		LDA	AITMBT1
		AND	#0DFH
		STA	AITMBT1
;
		LDA	<MPDTNO
		CMP	#030H
		BEQ	SEKBNM1
;----------------------------------------
SEKBNM0		EQU	$
		LDA	<PLMKCH
		BNE	SKNM010
;
		JSL	>CRENPL2L
		BCC	SKNM010
;
		LDA	GETITM0
		CMP	#015
		BNE	SKNM020
;
		LDY	#001H
		BIT	<KEYA2
		BVS	SKNM030
;
SKNM020		EQU	$
		LDA	<KEYA2L
		BPL	SKNM010
		LDY	#000H
SKNM030		EQU	$
		CPY	#001H
		BNE	SKNM040
		STZ	AITMMD
		LDA	#020H
		STA	AITMBT1
		STZ	SOUND2
SKNM040		EQU	$
		LDA	SKBNM0L,Y	;MSGE NO
		XBA
		LDA	SKBNM0H,Y	;MSGE NO
		TAY
		XBA
		JSL	>ENMSGSL	;MSGE SET
SKNM010		EQU	$
		RTS
;----------------------------------------
SEKBNM1		EQU	$
		LDA	<PLMKCH
		BNE	SKNM110
;
		JSL	>CRENPL2L
		BCC	SKNM110
;
		LDA	GETITM0
		CMP	#015
		BNE	SKNM120
;
		LDY	#001H
		BIT	<KEYA2
		BVS	SKNM130
;
SKNM120		EQU	$
		LDA	<KEYA2L
		BPL	SKNM110
		LDY	#000H
SKNM130		EQU	$
		CPY	#001H
		BNE	SKNM140
		STZ	AITMMD
		LDA	#020H
		STA	AITMBT1
		STZ	SOUND2
		JSL	>MNIRIT
SKNM140		EQU	$
		LDA	SKBNM1L,Y	;MSGE NO
		XBA
		LDA	SKBNM1H,Y	;MSGE NO
		TAY
		XBA
		JSL	>ENMSGSL	;MSGE SET
SKNM110		EQU	$
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	TAKAR  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAKARMV		EQU	$
		JSL	>EN1CSTL
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENSTAT,X
		BNE	TAKAR20
;
		LDA	#LOW  MS_0430
		LDY	#HIGH MS_0430
		JSL	>ENMSG2L	;MSGE SET
		BCC	TAKAR10
;
		LDA	>OPMODE
		BNE	TAKAR10
;
		INC	ENSTAT,X
TAKAR10		EQU	$
		RTS
;
TAKAR20		EQU	$
		STZ	ENMODE,X	;KILL I
;
		LDA	#takar		;PL. TAKARMONO MODE
		STA	>OPMODE
;
		PHX
		JSL	>OPTCBFST
		PLX
		JSL	>RAOPIT1	;PL. OPTION INIT
;
		RTS
;----------------------------------------
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BAKDN  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BAKDNMV		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	BAKDNM0		;MAN
		WORD	BAKDNM1		;S
		WORD	BAKDNM2		;B
		WORD	BAKDNM3		;KEMURI
;----------------------------------------
BKNM0ML		EQU	$
		BYTE	LOW  MS_0440,LOW  MS_0441
BKNM0MH		EQU	$
		BYTE	HIGH MS_0440,HIGH MS_0441
;
BKNM0CD		EQU	$
		BYTE	000H,001H,000H,001H,000H,001H,000H,001H
BKNM0TD		EQU	$
		BYTE	0FFH,020H,0FFH,018H,00FH,018H,0FFH,00FH
BAKDNM0		EQU	$
		JSR	BAKDNCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENTIM0,X
		BNE	BKNM040
;
		LDA	ENWRK3,X
		TAY
		INC	A
		AND	#007H
		STA	ENWRK3,X
		LDA	BKNM0TD,Y
		STA	ENTIM0,X
		LDA	BKNM0CD,Y
		STA	ENCHPT,X
		BNE	BKNM050
;;		JSL	>SDLRCE
;;		ORA	#011H
;;		STA	SOUND3
		LDA	#011H
		JSL	>SDLRE3	;(S)
		JSR	BKNM0ST		;KEMRI SET
		BRA	BKNM040
;
BKNM050		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#012H
;;		STA	SOUND3
		LDA	#012H
		JSL	>SDLRE3	;(S)
;
BKNM040		EQU	$
;
		LDY	#000H
		LDA	>ITMTBL3
		AND	#005H
		CMP	#005H
		BNE	BKNM010		;? BIG BOMB SET
		LDA	>MODTBL4
		AND	#020H
		BEQ	BKNM010
		LDY	#001H		;Y
BKNM010		EQU	$
		LDA	BKNM0ML,Y
		XBA
		LDA	BKNM0MH,Y
		TAY
		XBA
		JSL	>ENMSGEL	; MEGE ?
		JSL	>ENPLATR	;PL. EN. ATARI SET
		RTS
;----------------------------------------
BKNM1YN		EQU	00100
;
BAKDNM1		EQU	$
		JSR	BAKDNCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		JSR	SAMTMKY
		BCC	BKNM120
;
		LDA	>ITEMR49
		PHX
		TAX
		LDA	>BOMBMAX,X
		PLX
		CMP	>BMBCNT
		BEQ	BKNM110
;
		LDA	#LOW  BKNM1YN
		LDY	#HIGH BKNM1YN
		JSR	OKANEDC		;OKANE DEC
		BCC	BKNM130
;
		LDA	#027		;BOMB UP
		STA	>UPBMCT
;
		STZ	ENMODE,X
;
		LDA	#LOW  MS_0442	; MSGE NO. SET
		LDY	#HIGH MS_0442	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
;
		LDY	#028H
		JSR	SAMTMIM
;		STZ	!ITMVFG
;		PHX			;BOMB 1 SET
;		JSL	>ATMSIT
;		PLX
;
BKNM120		EQU	$
		RTS
;
BKNM110		EQU	$
		LDA	#LOW  MS_055F	; MSGE NO. SET
		LDY	#HIGH MS_055F	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		JSR	SMMMBUT		;NOT USE ITEM
		RTS
;
BKNM130		EQU	$
		JMP	KANENAS		;KANE NASI
;
;----------------------------------------
BKNM2YN		EQU	00100
;
BAKDNM2		EQU	$
		JSR	BAKDNCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		JSR	SAMTMKY
		BCC	BKNM210
;
		LDA	#LOW  BKNM2YN
		LDY	#HIGH BKNM2YN
		JSR	OKANEDC		;OKANE DEC
		BCC	BKNM220
;
		LDA	#bakud		;PL. BOMB MODE
		STA	>OPMODE
;
		PHX
		JSL	>OPTCBFST
		PLX
		JSL	>RAOPIT1	;PL. OPTION INIT
;
		STZ	ENMODE,X
;
		LDA	#LOW  MS_0443	; MSGE NO. SET
		LDY	#HIGH MS_0443	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
;
BKNM210		EQU	$
		RTS
;
BKNM220		EQU	$
		JMP	KANENAS		;KANE NASI
;----------------------------------------
BKNM3DT		EQU	$
		BYTE	004H,044H,0C4H,084H
;
BAKDNM3		EQU	$		;KEMURI
		LDA	#1*4
		JSL	>OAMENT3
		JSL	>EN1CSSL
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENCLOR,X
		AND	#030H
		STA	ENCLOR,X
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#003H
		TAY
		LDA	ENCLOR,X
		ORA	BKNM3DT,Y
		STA	ENCLOR,X
;
		INC	ENZSPD,X
		JSR	ENZCLC
		LDA	ENTIM0,X
		BNE	BKNM310
		STZ	ENMODE,X
BKNM310		EQU	$
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	ENCHPT,X
		RTS
;----------------------------------------
BKNM0ST		EQU	$
		LDA	#BAKDN
		JSL	>ENIDSH
;
		LDA	#003H		;KEMURI MODE
		STA	ENCONT,Y
		STA	ENNOCR,Y
;
		LDA	<WORK0
		CLC
		ADC	#004H
		STA	ENXPSL,Y
		LDA	<WORK1
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#010H
		STA	ENYPSL,Y
		LDA	<WORK3
		STA	ENYPSH,Y
;
		LDA	#004H		;Z POS
		STA	ENZPSL,Y
		LDA	#0F4H		;Z SPEED
		STA	ENZSPD,Y
;
		LDA	#017H		;TIME SET
		STA	ENTIM0,Y
;
		LDA	ENMOD2,Y
		AND	#0EEH
		STA	ENMOD2,Y	;KAGE NASI
;
		RTS
;----------------------------------------
BAKDNCD		EQU	$
		WORD	00000,00000		;MAN
		BYTE	048H,00AH,000H,002H
		WORD	00000,00000
		BYTE	04CH,00AH,000H,002H
;
		WORD	00000,00000		;S
		BYTE	0C2H,004H,000H,002H
		WORD	00000,00000
		BYTE	0C2H,004H,000H,002H
;
		WORD	00000,00000		;L
		BYTE	04EH,008H,000H,002H
		WORD	00000,00000
		BYTE	04EH,008H,000H,002H
;
BAKDNCS		EQU	$
		LDA	#001H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENCONT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  BAKDNCD
		STA	<WORK8
		LDA	#HIGH BAKDNCD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SARKK  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SARKKSX		EQU	$
		BYTE	000,000
SARKKSY		EQU	$
		BYTE	-018,018,000,000
;
SARKKMV		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	SARKK00		;TUKU YATU
		WORD	SARKK01		;KEY OPEN
		WORD	SARKK02		;YANKEY SARKK
		WORD	SARKK03		;RUN
;----------------------------------------
SARKK03		EQU	$
		JSR	SARKKCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENZPSL,X
		BNE	SRK0330
;
		MEM16
		IDX8
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	#0C98H
		CMP	#00D0H
		BCS	SRK0330
;
		LDA	ENYP2L
		SEC
		SBC	#06A5H
		CMP	#00D0H
		BCS	SRK0330
;
		LDA	#0FFFFH
		STA	<WORK1
;
SRK0330		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		LDA	<WORK1
		ORA	<WORK3
		BEQ	SRK0320
		STZ	ENMODE,X	;KILL I
;
SRK0320		EQU	$
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
		JSR	ENMVCL2
;
		LDA	ENZPSL,X
		BPL	SRK0310
		STZ	ENZPSL,X
		JSL	>RNDSET
		AND	#00FH
		ORA	#018H
		STA	ENZSPD,X
;
SRK0310		EQU	$
		LDA	#0F5H
		STA	<WORK4
		LDA	#00CH
		STA	<WORK5
		LDA	#0FEH
		STA	<WORK6
		LDA	#006H
		STA	<WORK7
		LDA	#010H
		JSL	>ESERCHL
		LDA	<WORK0		;X Y SPEED
		ASL	A
		STA	ENYSPD,X
		LDA	<WORK1
		ASL	A
		STA	ENXSPD,X
;SRK0310		EQU	$
		LDA	OPMSFG
		AND	#0FCH
		STA	OPMSFG
;
		LDA	<WORK0
		BPL	SRK0340
		EOR	#0FFH
		INC	A
		STA	<WORK0
SRK0340		EQU	$
		LDA	<WORK1
		BPL	SRK0350
		EOR	#0FFH
		INC	A
SRK0350		EQU	$
		CMP	<WORK0
		BCC	SRK0360
		LDA	ENXSPD,X
		ROL	A
		ROL	A
		AND	#001H
		EOR	#003H
		BRA	SRK0370
SRK0360		EQU	$
		LDA	ENYSPD,X
		ROL	A
		ROL	A
		AND	#001H
		EOR	#001H
SRK0370		EQU	$
		STA	ENMUKI,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		RTS
;----------------------------------------
SARKK02		EQU	$
		LDA	ENSTAT,X
		DEC	A
		DEC	A
		BMI	SRK0220
		JSR	SARKKCS
SRK0220		EQU	$
		JSR	ENSTCK		; scroll : not return !
		JSR	ENMVCL2
;		JSR	ENMVCL		;xclc,yclc
;		JSR	ENZCLC		;zclc
		DEC	ENZSPD,X
		LDA	ENZPSL,X
		BPL	SRK0210
;
		STZ	ENZSPD,X
		STZ	ENZPSL,X
;
SRK0210		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SRK02M0
		WORD	SRK02M1
		WORD	SRK02M2
		WORD	SRK02M3
		WORD	SRK02M4
;----------------------------------------
SRK02M0		EQU	$
		LDA	#LOW  MS_0454
		LDY	#HIGH MS_0454
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;----------------------------------------
SK2M1YN		EQU	00010
;
SRK02M1		EQU	$
		LDA	MSG_RTS
		BNE	SK2M110
;
		LDA	#LOW  SK2M1YN
		LDY	#HIGH SMM10YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SK2M110
;
		LDA	#LOW  MS_0455
		LDY	#HIGH MS_0455
		JSL	>ENMSGSL	;MSGE SET
;
		LDA	OPMSFG		;PL. DATA SET
		ORA	#003H
		STA	OPMSFG
;
		STZ	ENMODE,X
		RTS
;
SK2M110		EQU	$
		LDA	#LOW  MS_0456
		LDY	#HIGH MS_0456
		JSL	>ENMSGSL	;MSGE SET
;
		LDA	OPMSFG		;PL. DATA CLS
		AND	#0FCH
		STA	OPMSFG
;
		LDA	#nashi		;KILL SARU
		STA	>OPMODE
;
		INC	ENSTAT,X
		INC	PYALSP		;PL. STOP
;
		RTS
;----------------------------------------
SRK02M2		EQU	$
		INC	ENSTAT,X
;
		LDA	#0F5H
		STA	<WORK4
		LDA	#00CH
		STA	<WORK5
		LDA	#0FEH
		STA	<WORK6
		LDA	#006H
		STA	<WORK7
		LDA	#018
		JSL	>ESERCHL
		LDA	<WORK0		;X Y SPEED
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
		ASL	A
		ROL	A
		AND	#001H
		EOR	#003H
		STA	ENMUKI,X
;
		LDA	#004H		;#020H
		STA	ENTIM0,X
		RTS
;----------------------------------------
SRK02M3		EQU	$
		LDA	ENTIM0,X
		BNE	SK2M310
;
		INC	ENSTAT,X
;
		LDA	#010H
		STA	ENZSPD,X
		STA	ENTIM0,X
;
SK2M310		EQU	$
		RTS
;----------------------------------------
SRK02M4		EQU	$
		LDA	ENTIM0,X
		BNE	SK2M410
;
		LDA	ENZPSL,X
		BNE	SK2M410
		STZ	ENMODE,X	;KILL I
		STZ	PYALSP		;PL. MOVE
SK2M410
		RTS
;----------------------------------------
SARKK00		EQU	$
		JSL	>OAMCHKL
		JSR	ENSTCK		; scroll : not return !
;
		LDA	RABFLG		;? USAGI
		BNE	SARKK10
;
		LDA	MRTKFG
		ORA	PYFLASH
		BNE	SARKK10
;					;N
		LDA	>OPMODE
		CMP	#monky
		BEQ	SARKK10
;
		PHX
		LDX	<MPDTNO
		LDA	>GNDTBL,X
		PLX
		AND	#020H
		BNE	SARKK10
;
		JSL	>CRENPL2L
		BCC	SARKK10
;
SARKK20		EQU	$
;		STZ	ENMODE,X	;KILL I
;
		LDA	#monky		;PL. SARKK MODE
		STA	>OPMODE
;
		PHX
		STZ	OPNOSI
		JSL	>OPTCBFST
		JSL	>RAOPIT		;PL. OPTION INIT
		PLX
;
SARKK10		EQU	$
		RTS
;----------------------------------------
SARKK01		EQU	$
		JSR	SARKKCS
		JSR	ENSTCK		; scroll : not return !
		JSR	ENMVCL2
;		JSR	ENMVCL		;xclc,yclc
;		JSR	ENZCLC		;zclc
		DEC	ENZSPD,X
		DEC	ENZSPD,X
		LDA	ENZPSL,X
		BPL	SRK0110
;
		STZ	ENZSPD,X
		STZ	ENZPSL,X
;
SRK0110		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SARKKM0
		WORD	SARKKM1
		WORD	SARKKM2
		WORD	SARKKM3
		WORD	SARKKM4
		WORD	SARKKM5
		WORD	SARKKM6
		WORD	SARKKM7
		WORD	SARKKM8
		WORD	SARKKM9
		WORD	SARKKMA
;----------------------------------------
SARKKM0		EQU	$
		LDA	#LOW  MS_0450
		LDY	#HIGH MS_0450
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;----------------------------------------
SRKM1YN		EQU	00100
;
SARKKM1		EQU	$
		LDA	MSG_RTS
		BEQ	SRKM110
;
SRKM120		EQU	$
		LDA	#LOW  MS_0451
		LDY	#HIGH MS_0451
		JSL	>ENMSGSL	;MSGE SET
		LDA	#003H
		STA	ENCONT,X
		RTS
;		STZ	ENMODE,X	;KILL I
;		BRA	SARKK20
;
SRKM110		EQU	$
		LDA	#LOW  SRKM1YN
		LDY	#HIGH SRKM1YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SRKM120
;
		LDA	#LOW  MS_0453
		LDY	#HIGH MS_0453
		JSL	>ENMSGSL	;MSGE SET
;
		INC	PYALSP		;PL. STOP
		INC	ENSTAT,X
		STZ	ENMUKI,X
		RTS
;----------------------------------------
SRKM3DT		EQU	$		;Z SPEED
		BYTE	020H,01CH
SARKKM3		EQU	$		;Z CHK
SARKKM5		EQU	$
		LDA	ENTIM1,X
		BNE	SRKM320
;
		LDA	ENSTAT,X
		INC	ENSTAT,X
		LSR	A
		AND	#001H
		TAY
		LDA	SRKM3DT,Y
		STA	ENZSPD,X
;
;;		JSL	>SDLRCE		;OTO
;;		ORA	#020H
;;		STA	SOUND2
		LDA	#20H
		JSL	>SDLRE2	;(S)
;
		LDA	ENSTAT,X
		LSR	A
		AND	#001H
		ORA	#004H
		STA	ENMUKI,X
;
		RTS
SRKM320		EQU	$		;E SET
		LDA	ENSTAT,X
		LSR	A
		AND	#001H
		ORA	#006H
		STA	ENMUKI,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		RTS
;----------------------------------------
SRKM4PY		EQU	$
		WORD	00661H,0064CH,00624H
SRKM4PX		EQU	$
		WORD	00F4FH,00F70H,00F5DH
;
SARKKM2		EQU	$
SARKKM4		EQU	$
SARKKM6		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENSTAT,X
		SEC
		SBC	#002H
		TAY
		LDA	SRKM4PX,Y		;X Y POS SERCH 2 3
		SEC
		SBC	ENXPSL,X
		CLC
		ADC	#002H
		CMP	#004H
		BCS	SRKM410
		LDA	SRKM4PY,Y
		SEC
		SBC	ENYPSL,X
		CLC
		ADC	#002H
		CMP	#004H
		BCS	SRKM410
		INC	ENSTAT,X
		STZ	ENYSPD,X
		STZ	ENXSPD,X
		LDA	#020H		;STOP TIME
		STA	ENTIM1,X
;
;;		JSL	>SDLRCE		;OTO
;;		ORA	#021H
;;		STA	SOUND2
		LDA	#21H
		JSL	>SDLRE2	;(S)
;
		RTS
;
SRKM410		EQU	$
		LDA	SRKM4PX,Y
		STA	<WORK4
		LDA	SRKM4PX+1,Y
		STA	<WORK5
		LDA	SRKM4PY,Y
		STA	<WORK6
		LDA	SRKM4PY+1,Y
		STA	<WORK7
		LDA	#018
		JSL	>ESERCHL
		LDA	<WORK0		;X Y SPEED
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
		RTS
;----------------------------------------
SRKM7MD		EQU	$
		BYTE	002H,001H,0FFH
SRKM7TD		EQU	$
		BYTE	029H,000H
;
SARKKM7		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	ENZPSL,X
		BNE	SRKM710
;
		LDA	ENTIM0,X
		BNE	SRKM710
;
		LDA	ENWRK0,X
		TAY
		INC	ENWRK0,X
		LDA	SRKM7MD,Y
		BMI	SRKM720
		PHA
		STA	ENMUKI,X
		LDA	SRKM7TD,Y
		STA	ENTIM0,X
		PLA
		TAY
		LDA	SARKKSX,Y
		STA	ENXSPD,X
		LDA	SARKKSY,Y
		STA	ENYSPD,X
;
SRKM710		EQU	$
		RTS
;
SRKM720		EQU	$
		INC	ENSTAT,X
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
;		PHX
;		JSL	>USHNDDWT
;		PLX
		LDA	#gif1		;KEY OPEN
		STA	GDINFF
		STZ	<JRSBPT
		STZ	<CWORK0
;
		STZ	ENMUKI,X
		STZ	PYALSP		;PL. MOVE
		RTS
;----------------------------------------
SARKKM8		EQU	$
		LDA	#008H
		STA	ENMUKI,X
		STZ	ENCHPT,X
;
;		LDA	ENZPSL,X
;		AND	#0F8H
;		BEQ	SRKM810
;		INC	ENCHPT,X
SRKM810		EQU	$
;		LDA	ENZPSL,X
;		BEQ	SRKM840
;		CMP	#001H
;		BEQ	SRKM830
;		RTS
;
SRKM840		EQU	$
;		LDA	ENTIM0,X
;		BNE	SRKM850
;
		JSL	>RNDSET
		AND	#00FH
		ADC	#018H
		STA	ENZSPD,X
		INC	ENSTAT,X
;
SRKM850		EQU	$
		RTS
;
SRKM830		EQU	$
;		INC	ENSTAT,X
;
;		JSL	>RNDSET
;		AND	#00FH
;		ADC	#040H
;		STA	ENTIM0,X
;		RTS
;----------------------------------------
SARKKM9		EQU	$
		LDA	ENZSPD,X	;SPEED CHK
		BPL	SRKM910
		LDA	ENZPSL,X
		BNE	SRKM910
		INC	ENSTAT,X
		LDA	#025H		;OTO
		JSL	>SDLRE3
SRKM910		EQU	$
;----------------------------------------
SARKKMA		EQU	$
		RTS
;
;----------------------------------------
SARKKST		EQU	$
		JSR	SARKKSTS
		LDA	#001H		;MODE SET
		STA	ENCONT,Y
;
		LDA	#nashi		;KILL SARU
		STA	>OPMODE
;
		RTL
;----------------------------------------
SARKKSTS	EQU	$
		PHA		;INDEX SAVE
;
		LDA	#SARKK
		JSL	>ENIDSH
		BMI	SRKSTS10
;
		PLA
;
		PHX
;
		TAX			;LDX	OPINDX		;INDEX GET
;
		LDA	OPMUKI,X	;MUKI GET
		AND	#003H
;
		STA	ENCMKI,Y	;MUKI SET
		STA	ENMUKI,Y
;
		LDA	OPYPSL,X	;Y POS SET
		CLC
		ADC	#002H
		STA	ENYPSL,Y
		LDA	OPYPSH,X
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	OPXPSL,X	;X POS SET
		CLC
		ADC	#002H
		STA	ENXPSL,Y
		LDA	OPXPSH,X
		ADC	#000H
		STA	ENXPSH,Y
;
		LDA	<PLBGCKF
		STA	ENKAIF,Y
;
		LDA	#001
		STA	ENNOCR,Y	; beem thru
		INC	A
		STA	ENKAIF,Y	; KAISET
;
		STZ	<PYSPFG		;PL. SPEED CLS
;
		PLX
;
		RTS
;
;
SRKSTS10	EQU	$
		PLA
		RTS
;----------------------------------------
SARKKST1	EQU	$
		JSR	SARKKSTS
;
		LDA	#002H
		STA	ENCONT,Y
;
		RTL
;----------------------------------------
SARKKST2	EQU	$
		JSR	SARKKSTS
;
		LDA	#001H		;Z POS SET
		STA	ENZPSL,Y
;
		LDA	#010H		;Z SPD SET
		STA	ENZSPD,Y
;
		LDA	#003H		;MODE SET
		STA	ENCONT,Y
;
		LDA	#nashi		;KILL SARU
		STA	>OPMODE
;
		RTL
;----------------------------------------
SARKKCY		EQU	-6
SARKKCN		EQU	$
		BYTE	020H,0C0H		;0
		BYTE	020H,0C0H
;
		BYTE	000H,0A0H		;1
		BYTE	000H,0A0H
;
		BYTE	040H,080H		;2
		BYTE	040H,060H
;
		BYTE	040H,080H		;3
		BYTE	040H,060H
;
SARKKCD		EQU	$
		WORD	00000,00000+SARKKCY		;0
		BYTE	020H,000H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,000H,000H,002H
		WORD	00000,00000+SARKKCY
		BYTE	020H,000H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,040H,000H,002H
;
		WORD	00000,00000+SARKKCY		;1
		BYTE	020H,000H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,000H,000H,002H
		WORD	00000,00000+SARKKCY
		BYTE	020H,000H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,040H,000H,002H
;
		WORD	-0001,00000+SARKKCY		;2
		BYTE	020H,000H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,000H,000H,002H
		WORD	-0001,00000+SARKKCY
		BYTE	020H,000H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,000H,000H,002H
;
		WORD	00001,00000+SARKKCY		;3
		BYTE	020H,040H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,040H,000H,002H
		WORD	00001,00000+SARKKCY
		BYTE	020H,040H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	022H,040H,000H,002H
;
		WORD	00000,00000+SARKKCY		;4
		BYTE	0CEH,001H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0EEH,001H,000H,002H
		WORD	00000,00000+SARKKCY
		BYTE	0CEH,001H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0EEH,001H,000H,002H
;
		WORD	00000,00000+SARKKCY		;5
		BYTE	0CEH,041H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00000+SARKKCY
		BYTE	0CEH,041H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0EEH,041H,000H,002H
;
		WORD	-0001,00000+SARKKCY		;6
		BYTE	0CEH,001H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0ECH,001H,000H,002H
		WORD	-0001,00000+SARKKCY
		BYTE	0CEH,041H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0ECH,001H,000H,002H
;
		WORD	00001,00000+SARKKCY		;7
		BYTE	0CEH,041H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0ECH,041H,000H,002H
		WORD	00001,00000+SARKKCY
		BYTE	0CEH,001H,000H,002H
		WORD	00000,00006+SARKKCY
		BYTE	0ECH,041H,000H,002H
;
SARKKC1		EQU	$
		WORD	00000,00000+SARKKCY
		BYTE	0CAH,001H,000H,000H
		WORD	00008,00000+SARKKCY
		BYTE	0CAH,041H,000H,000H
		WORD	00000,00008+SARKKCY
		BYTE	0DAH,001H,000H,000H
		WORD	00008,00008+SARKKCY
		BYTE	0DAH,041H,000H,000H
		WORD	00000,00016+SARKKCY
		BYTE	0CBH,001H,000H,000H
		WORD	00008,00016+SARKKCY
		BYTE	0CBH,041H,000H,000H
;
		WORD	00000,00000+SARKKCY
		BYTE	0DBH,001H,000H,000H
		WORD	00008,00000+SARKKCY
		BYTE	0DBH,041H,000H,000H
		WORD	00000,00008+SARKKCY
		BYTE	0CCH,001H,000H,000H
		WORD	00008,00008+SARKKCY
		BYTE	0CCH,041H,000H,000H
		WORD	00000,00016+SARKKCY
		BYTE	0DCH,001H,000H,000H
		WORD	00008,00016+SARKKCY
		BYTE	0DDH,041H,000H,000H
;
SARKKCS		EQU	$
		LDA	ENMUKI,X
		CMP	#008H
		BCS	SRKCS20
;
		LDA	ENMUKI,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		TAY
;
		LDA	SARKKCN,Y		;OBJ CNG NO SET
		STA	OPTHPT
		LDA	SARKKCN+1,Y
		STA	OPTBPT
;
		TYA
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW SARKKCD
		STA	<WORK8
		LDA	#HIGH SARKKCD
		ADC	#000H
		STA	<WORK9
;
		LDA	#002H			;HUTUU
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		LDA	ENDSPL,X
		BNE	SRKCS10
		JSL	>SADWSTL
SRKCS10		EQU	$
		RTS
;----------------------------------------
SRKCS20		EQU	$
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW SARKKC1
		STA	<WORK8
		LDA	#HIGH SARKKC1
		ADC	#000H
		STA	<WORK9
;
		LDA	#006H			;HUTUU
;;		STA	<WORK6
;;		STZ	<WORK7
;
;;		JSL	>SETOAML22
		JSR	SETO22
;
		LDA	ENDSPL,X
		BNE	SRKCS30
		JSL	>SADWSTL
SRKCS30		EQU	$
		RTS
;----------------------------------------
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	TEKBB  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TEKBBMV		EQU	$
		JSL	>HELP0CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENMKIST	;MUKI SET
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	ENSTAT,X
		BNE	TEKBB20
;
		LDA	#LOW  MS_0460
		LDY	#HIGH MS_0460
		JSL	>ENMSG2L	;MSGE SET
		BCC	TEKBB10
		INC	ENSTAT,X
TEKBB10		EQU	$
		RTS
;
TEKBB20		EQU	$
		STZ	ENMODE,X	;KILL I
;
		LDA	#prnc1		;PL. TAKARMONO MODE
		STA	>OPMODE
;
		PHX
		JSL	>OPTCBFST
		PLX
		JSL	>RAOPIT1	;PL. OPTION INIT
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	HELP1  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HELP1IT		EQU	$
		PHB
		PHK
		PLB
		JSR	HELP100_I
		PLB
		RTL
;----------------------------------------
HELP100_I	EQU	$
		INC	ENNOCR,X	; beem thru
;
		LDA	<RMXYCT
		CMP	#0E4H
		BNE	HELP120_I
;
		LDA	#002H		;MODE SET(IE)
		STA	ENCONT,X
		RTS
;
HELP120_I	EQU	$
		LDA	>OPMODE
		CMP	#nashi
		BNE	HELP110_I
;
		LDA	>ITEMR20	;(DOUKUTU)
		CMP	#002H
		BNE	HELP130_I
		STZ	ENMODE,X	;KILL I
HELP130_I	EQU	$
		LDA	#jjsmv
		STA	>OPMODE
		PHX
		JSL	>OPTCBFST
		PLX
		LDA	#nashi
		STA	>OPMODE
		RTS
;
HELP110_I	EQU	$
		STZ	ENMODE,X	;KILL I
		PHX
		JSL	>OPTCBFST
		PLX
		RTS
;----------------------------------------
HELP1ST		EQU	$
		PHA		;INDEX SAVE
;
		LDA	#HELP1
		JSL	>ENIDSH
;
		PLA
;
		PHX
;
		TAX			;LDX	OPINDX		;INDEX GET
;
		LDA	OPMUKI,X	;MUKI GET
		AND	#003H
;
		STA	ENCMKI,Y	;MUKI SET
		STA	ENMUKI,Y
;
		LDA	OPYPSL,X	;Y POS SET
		CLC
		ADC	#002H
		STA	ENYPSL,Y
		LDA	OPYPSH,X
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	OPXPSL,X	;X POS SET
		CLC
		ADC	#002H
		STA	ENXPSL,Y
		LDA	OPXPSH,X
		ADC	#000H
		STA	ENXPSH,Y
;
		LDA	<PLBGCKF
		STA	ENKAIF,Y
;
		LDA	#001
		STA	ENNOCR,Y	; beem thru
		STA	ENCONT,Y	;MODE SET
		JSR	HELP1SP		;PL. STOP & MUTEK
;
		PLX
;
		LDA	#nashi		;KILL JIJI
		STA	>OPMODE
;
		STZ	<PYSPFG		;PL. SPEED CLS
;
		RTL
;----------------------------------------
HELP1SP		EQU	$
		LDA	#001H
		STA	PYALSP		;PL. STOP
		STA	MRTKFG		;MUTEK
		RTS
;----------------------------------------
HELP1MV		EQU	$
		JSL	>HELP1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	HELP1F0
		WORD	HELP1F1
		WORD	HELP1F2
;----------------------------------------
HELP1F0		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HL1F0M0
		WORD	HL1F0M1
;------------------------------
HL1F0M0		EQU	$
		JSL	>ENMKIST	;MUKI SET
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	#LOW  MS_0153
		LDY	#HIGH MS_0153
		JSL	>ENMSG2L	;MSGE SET
		BCC	HF0M010
;
		STA	ENMUKI,X	;MUKI SET
		STA	ENCMKI,X
;
		INC	ENSTAT,X
;
HF0M010		EQU	$
		RTS
;------------------------------
HL1F0M1		EQU	$
		LDA	#jjsmv		;PL. HELP1 MODE
		STA	>OPMODE
;
		JSL	>RAOPIT1	;PL. OPTION INIT
;
		LDA	#005
		STA	>MODTBL3	;SAVE RAM
;
		STZ	ENMODE,X	;KILL I
;
		JSL	>RESTTST
;
		RTS
;----------------------------------------
HELP1F1		EQU	$
		JSR	ENMVCL		; xclc,yclc !
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HL1F1M0
		WORD	HL1F1M1
		WORD	HL1F1M2
		WORD	HL1F1M3
;------------------------------
HL1F1M0		EQU	$
		INC	ENSTAT,X
;
		LDY	#01AH
		STZ	!ITMVFG
		JSL	>ATMSIT
;
		LDA	#001		;SAVE RAM
		STA	>MODTBL3
		JSR	HELP1SP		;PL. STOP & MUTEK
;
		LDA	#030H		;TIME SET
		STA	ENTIM0,X
;
		LDA	#008H		;SPEED SET
		STA	ENXSPD,X
		LSR	A
		STA	ENYSPD,X
;
		LDA	#003H
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		RTS

;------------------------------
HL1F1M1		EQU	$		;YOKO MOVE
		JSR	HELP1SP		;PL. STOP & MUTEK
;
		LDA	ENTIM0,X
		BNE	HF1M110
		INC	ENSTAT,X
HF1M110		EQU	$
		TXA			;
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		RTS
;------------------------------
HL1F1M2		EQU	$		;YOKO MOVE
		STZ	ENCMKI,X
		STZ	ENMUKI,X
;
		LDY	!DOORID
;
;					;SERCH POINT = ENMY POINT
		LDA	ESYPSL,Y
		STA	<WORK0
		LDA	ESYPSH,Y
		STA	<WORK1
		LDA	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CMP	<WORK2
		MEM8
		SEP	#00110000B
		BCC	HF1M210
		INC	ENSTAT,X	;Y
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		RTS
HF1M210		EQU	$
		LDA	ESXPSL,Y	;SERCH POINT SET
		STA	<WORK4
		LDA	ESXPSH,Y
		STA	<WORK5
		LDA	ESYPSL,Y
		STA	<WORK6
		LDA	ESYPSH,Y
		STA	<WORK7
;
		LDA	#008H		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
;
		LDA	<WORK0		;SPEED SET
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		TXA			;
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		JSR	HELP1SP		;PL. STOP & MUTEK
		RTS
;------------------------------
HL1F1M3		EQU	$
		STZ	ENMODE,X	;KILL I
		STZ	PYALSP		;PL. MOVE
		STZ	MRTKFG		;MUTEK
		RTS
;----------------------------------------
HLP12DL		EQU	$
		BYTE	LOW  MS_0160,LOW  MS_0161,LOW  MS_0162
HLP12DH		EQU	$
		BYTE	HIGH MS_0160,HIGH MS_0161,HIGH MS_0162
;
HELP1F2		EQU	$
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENSTAT,X
		BEQ	HF2M030
		LDA	#0A0H
		STA	>UPLFCT
		STZ	ENSTAT,X
;
HF2M030		EQU	$
		LDY	#002H
		LDA	>MODTBL0
		CMP	#003H
		BCS	HF2M020		;? MASTER KATANA GET
;
		LDA	>ITMTBL4
		TAY
HF2M020		EQU	$
		LDA	HLP12DL,Y
		XBA
		LDA	HLP12DH,Y
		TAY
		XBA
		JSL	>ENMSGEL	;MSGE SET
		BCC	HF2M010
		INC	ENSTAT,X
HF2M010		EQU	$
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	D_0_9  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
D_0_9MV		EQU	$
		JSL	>SINPUCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENWRK0,X
		AND	#003H
		STA	ENMUKI,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	D_0_9M0		;INT
		WORD	D_0_9M1		;MSGE WRITE
		WORD	D_0_9M2		;COUNT NEXT
;----------------------------------------
D_0_9M0		EQU	$
		STZ	ENWRK0,X
		STZ	ENWRK1,X
		INC	ENSTAT,X
;----------------------------------------
D_0_9M1		EQU	$
		LDA	ENWRK0,X
		LDY	ENWRK1,X
		JSL	>ENMSG2L	;MSGE SET
		BCC	D09M110
		INC	ENSTAT,X
D09M110		EQU	$
		RTS
;----------------------------------------
D_0_9M2		EQU	$
		LDA	ENWRK0,X
		CLC
		ADC	#001H
		STA	ENWRK0,X
		LDA	ENWRK1,X
		ADC	#000H
		STA	ENWRK1,X
		LDA	#001H
		STA	ENSTAT,X
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SITO0  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SITO0MV		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	SITO000		;IGIMERARERU
		WORD	SITO100		;NAMIDA
		WORD	SITO200		;IGIMERU
;----------------------------------------
SITO000		EQU	$
		JSL	>OCHECKL
		JSL	>EN1CSTL
		JSR	ENSTCK		;scroll : not return
;
;
		JSR	SITO0MS
;
;
		LDA	ENCLOR,X
		AND	#07FH
		ORA	ENCMKI,X
		STA	ENCLOR,X
;
;
		JSR	ENMVCL2		;xclc,yclc,zclc
;;		JSL	>ENBGCKL		; BG check sub !
;;		LDA	ENCBFG,X
		JSR	ENBGCK
;;		AND	#00FH
		BEQ	SITO050
		AND	#003H
		BNE	SITO060
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		LDA	ENWRK3,X
		BEQ	SITO060
		JSR	SITO0OT		;OTO SET
		BRA	SITO050
SITO060		EQU	$
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		LDA	ENWRK3,X
		BEQ	SITO050
		JSR	SITO0OT		;OTO SET
SITO050		EQU	$
;
		DEC	ENZSPD,X	;G
;
		LDA	ENZPSL,X
		BPL	SITO010		;? GIMEN
;					;Y
		STZ	ENZPSL,X	;Z POS CLS
;
		LDA	ENZSPD,X	;HANERU
		EOR	#0FFH
		INC	A
		LSR	A
		LSR	A
		STA	ENZSPD,X
		AND	#0FCH
		BEQ	SITO0E0
		JSR	SITO0OT		;OTO SET
SITO0E0		EQU	$
;
		JSR	SITO0BK		;SPEED DEC
;
SITO010		EQU	$
		LDA	ENWRK3,X	;? KERARETA
		BNE	SITO080
;
		LDA	ENCMKI,X	;? SAKASAMA
		BEQ	SITO0F0
		JMP	SITO0C0
;
;----------------------------------------
SITO0F0		EQU	$
		JSR	SITO100
;
		TXA			;ARUKU
		EOR	<FRCNT
		PHA
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		PLA
		AND	#03FH
		BNE	SITO040
		JSL	>RNDSET		;LDA	<PLXPS1
		STA	<WORK4
		LDA	<PLXPS0
		STA	<WORK5
		JSL	>RNDSET		;LDA	<PLYPS1
		STA	<WORK6
		LDA	<PLYPS0
		STA	<WORK7
		LDA	#008H		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
		LDA	<WORK1		;SPEED SET
		STA	ENWRK1,X
		LDA	<WORK0
		STA	ENWRK0,X
;
		BEQ	SITO040
;
		LDA	ENCLOR,X	;MUKI SET
		ORA	#040H
		STA	ENCLOR,X
		LDA	ENXSPD,X
		LSR	A
		AND	#040H
		EOR	ENCLOR,X
		STA	ENCLOR,X
;
SITO040		EQU	$
		LDA	ENWRK1,X
		STA	ENXSPD,X
		LDA	ENWRK0,X
		STA	ENYSPD,X
;
		RTS
;----------------------------------------
SITO080		EQU	$		;KERI
		LDA	ENXSPD,X
		ORA	ENYSPD,X
		BNE	SITO090
		STZ	ENWRK3,X	;KERARE END
		RTS
SITO090		EQU	$
;
		TXA			;ARUKU
		EOR	<FRCNT
		PHA
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		PLA
		ASL	A
		ASL	A
		AND	#080H
		STA	ENCMKI,X	;SAKASA SET
		RTS
;----------------------------------------
SITO0C0		EQU	$		;SAKASA
		JSR	SITO100
		TXA
		EOR	<FRCNT
		BEQ	SITO0D0
;
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		RTS
;
SITO0D0		EQU	$
		STZ	ENCMKI,X
		RTS
;----------------------------------------
SITO0BS		EQU	$
		BYTE	0FEH,002H
;
SITO0BK		EQU	$
		LDA	ENXSPD,X	;X BREAK
		BEQ	ST0BK10
		PHA
		ASL	A
		ROL	A
		AND	#001H
		TAY
		PLA
		CLC
		ADC	SITO0BS,Y
		STA	ENXSPD,X
ST0BK10		EQU	$
;
		LDA	ENYSPD,X	;Y BREAK
		BEQ	ST0BK20
		PHA
		ASL	A
		ROL	A
		AND	#001H
		TAY
		PLA
		CLC
		ADC	SITO0BS,Y
		STA	ENYSPD,X
ST0BK20		EQU	$
;
		RTS
;----------------------------------------
SITO100		EQU	$
		JSR	OAMCHK
		JSL	>BIKRST2
		RTS
;
;;;		LDA	ENCLOR,X
;;;		AND	#0FEH
;;;		STA	ENCLOR,X
;;;		LDA	#1*4
;;;		JSL	>OAMENT3
;;;		JSL	>EN1CSSL
;;;		JSR	ENSTCK
;;;		JSR	ENMVCL2		;xclc,yclc,zclc
;;;;
;;;		LDA	ENTIM0,X
;;;		BNE	SITO110
;;;		STZ	ENMODE,X
;;;SITO110		EQU	$
;;;		RTS
;----------------------------------------
SITO200		EQU	$
		JSR	SITO2CS
		JSR	ENSTCK		;scroll : not return
;
;
		JSR	SITO2MS
;
;
		JSR	ENMVCL2		;xclc,yclc,zclc
;;		JSL	>ENBGCKL	; BG check sub !
;;		LDA	ENCBFG,X
		JSR	ENBGCK
;;		AND	#00FH
		BEQ	SITO210
		AND	#003H
		BNE	SITO220
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		BRA	SITO210
SITO220		EQU	$
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
SITO210		EQU	$
;
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SITO2M0
		WORD	SITO2M1
		WORD	SITO2M2
;----------------------------------------
SITO2M0		EQU	$
		TXA			;ARUKU
		EOR	<FRCNT
		PHA
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		PLA
;
		AND	#01FH
		BNE	ST2M010
;
		LDA	ENCMKI,X
		TAY
		LDA	ENXPSL,Y
		STA	<WORK4
		LDA	ENXPSH,Y
		STA	<WORK5
		LDA	ENYPSL,Y
		STA	<WORK6
		LDA	ENYPSH,Y
		STA	<WORK7
		LDA	#00EH		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
		LDA	<WORK0		;SPEED SET
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		BEQ	ST2M010
		LDA	ENXSPD,X
		ASL	A
		ROL	A
		AND	#001H
		STA	ENMUKI,X
;
ST2M010		EQU	$
		LDA	ENCMKI,X
		TAY
;
		LDA	ENZPSL,Y
		BNE	ST2M020
;
		LDA	ENXPSL,X
		SEC
		SBC	ENXPSL,Y
		CLC
		ADC	#008H
		CMP	#010H
		BCS	ST2M020
		LDA	ENYPSL,X
		SEC
		SBC	ENYPSL,Y
		CLC
		ADC	#008H
		CMP	#010H
		BCS	ST2M020
		INC	ENSTAT,X	;KERI !!
		JSR	SITO0OT		;OTO SET
ST2M020		EQU	$
		RTS
;----------------------------------------
SITO2M1		EQU	$
		INC	ENSTAT,X
;
		LDA	ENCMKI,X
		TAY
;
		LDA	ENXSPD,X	;X SPEED SET
		ASL	A
		STA	ENXSPD,Y
;
		LDA	ENYSPD,X	;Y SPEED SET
		ASL	A
		STA	ENYSPD,Y
;
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		JSL	>RNDSET		;Z SPEED SET
		AND	#01FH
		STA	ENZSPD,Y
;
		LDA	#060H		;STOP TIME
		STA	ENTIM0,X
;
		LDA	#001H
		STA	ENCHPT,X	;E SET
		STA	ENWRK3,Y
;
		RTS
;----------------------------------------
SITO2M2		EQU	$
		LDA	ENTIM0,X
		BNE	ST2M210
		STZ	ENSTAT,X
ST2M210		EQU	$
		RTS
;----------------------------------------
SITO2CD		EQU	$
		WORD	00000,-0007
		BYTE	0E0H,046H,000H,002H
		WORD	00000,00000
		BYTE	0E2H,046H,000H,002H
		WORD	00000,-0007
		BYTE	0E0H,046H,000H,002H
		WORD	00000,00000
		BYTE	0C4H,046H,000H,002H
;
		WORD	00000,-0007
		BYTE	0E0H,006H,000H,002H
		WORD	00000,00000
		BYTE	0E2H,006H,000H,002H
		WORD	00000,-0007
		BYTE	0E0H,006H,000H,002H
		WORD	00000,00000
		BYTE	0C4H,006H,000H,002H
;
SITO2CS		EQU	$
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENMUKI,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  SITO2CD
		STA	<WORK8
		LDA	#HIGH SITO2CD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
		JSL	>SADWSTL
;
		RTS
;----------------------------------------
SITO0OT		EQU	$
		LDA	#032H		;OTO
		JSL	>SDLRE3
		RTS
;----------------------------------------
SITO2ST		EQU	$
		LDA	#SITO0
		JSL	>ENIDSH
		BMI	ST2ST10
;
		JSL	>ENIDPS
;
		LDA	#002H		;SITO2 MODE
		STA	ENCONT,Y
;
		TXA
		STA	ENCMKI,Y	;SITO0 INDEX SAVE
;
		LDA	#001H
		STA	ENNOCR,Y	; beem thru
;
ST2ST10		EQU	$
		RTL
;----------------------------------------
;;;ST1STSX		EQU	$
;;;		BYTE	0FCH,004H
;;;ST1STPX		EQU	$
;;;		WORD	0FFF8H,00010H
;;;ST1STMX		EQU	$
;;;		BYTE	040H,000H
;;;SITO1ST		EQU	$
;;;		LDA	#SITO0
;;;		JSL	>ENIDSH
;;;		BMI	ST1ST10
;;;;
;;;		PHX
;;;		JSL	>RNDSET
;;;		AND	#001H
;;;		TAX
;;;;
;;;		LDA	ENCLOR,Y
;;;		AND	#03FH
;;;		ORA	ST1STMX,X
;;;		STA	ENCLOR,Y
;;;;
;;;		LDA	ST1STSX,X
;;;		STA	ENXSPD,X
;;;;
;;;		TXA
;;;		ASL	A
;;;		TAX
;;;;
;;;		LDA	<WORK0
;;;		CLC
;;;		ADC	ST1STPX,X
;;;		STA	ENXPSL,Y
;;;		LDA	<WORK1
;;;		ADC	ST1STPX+1,X
;;;		STA	ENXPSH,Y
;;;		LDA	<WORK2
;;;		STA	ENYPSL,Y
;;;		LDA	<WORK3
;;;		STA	ENYPSH,Y
;;;;
;;;		LDA	#01100100B
;;;		STA	ENMOD2,Y
;;;;
;;;		LDA	#0FCH
;;;		STA	ENZSPD,X
;;;		LDA	#00003H
;;;		STA	ENZPSL,X
;;;;
;;;		LDA	#002H		;CHAR SET
;;;		STA	ENCHPT,Y
;;;;
;;;		LDA	#005H
;;;		STA	ENTIM0,Y
;;;;
;;;		LDA	#001H		;SITO1 MODE
;;;		STA	ENCONT,Y
;;;;
;;;		LDA	#001H
;;;		STA	ENNOCR,Y	; beem thru
;;;		PLX
;;;;
;;;ST1ST10		EQU	$
;;;		RTS
;----------------------------------------
SITO0ML		EQU	$
		BYTE	LOW  MS_0540
		BYTE	LOW  MS_0541
SITO0MH		EQU	$
		BYTE	HIGH MS_0540
		BYTE	HIGH MS_0541
;
SITO0MS		EQU	$
		LDA	ENTIM3,X
		BNE	ST0MS10
;
		LDA	>ITMTBL4
		AND	#001H
		TAY
		LDA	SITO0ML,Y
		XBA
		LDA	SITO0MH,Y
		TAY
		XBA
		JSL	>ENMSG2L	;MSGE SET
		BCC	ST0MS10
;
		LDA	ENXSPD,X
		EOR	#0FFH
		STA	ENXSPD,X
		LDA	ENYSPD,X
		EOR	#0FFH
		STA	ENYSPD,X
;
		LDA	ENWRK3,X
		BEQ	ST0MS20
		JSR	SITO0OT		;OTO SET
ST0MS20		EQU	$
;
		LDA	#040H
		STA	ENTIM3,X
;
ST0MS10		EQU	$
		RTS
;----------------------------------------
SITO2ML		EQU	$
		BYTE	LOW  MS_0542
		BYTE	LOW  MS_0543
SITO2MH		EQU	$
		BYTE	HIGH MS_0542
		BYTE	HIGH MS_0543
;
SITO2MS		EQU	$
		LDA	ENTIM3,X
		BNE	ST2MS10
;
		LDA	>ITMTBL4
		AND	#001H
		TAY
		LDA	SITO2ML,Y
		XBA
		LDA	SITO2MH,Y
		TAY
		XBA
		JSL	>ENMSG2L	;MSGE SET
		BCC	ST2MS10
;
		LDA	ENXSPD,X
		EOR	#0FFH
		STA	ENXSPD,X
		LDA	ENYSPD,X
		EOR	#0FFH
		STA	ENYSPD,X
;
		LDA	#040H
		STA	ENTIM3,X
;
ST2MS10		EQU	$
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	UZUMK  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UUKMVDT		EQU	$
		BYTE	000H,040H,0C0H,080H
UZUMKMV		EQU	$
		LDA	<MPDTNO
		CMP	#01BH
		BNE	UZUMK00
;
;----------------------------------------
		JSL	>OAMCHKL
		JSR	ENSTCK		;scroll : not return
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	ENXP2L
		SEC
		SBC	<PLXPS1
		CLC
		ADC	#00040H
		CMP	#00051H
		BCS	UUKMV80
;
		LDA	ENYP2L
		SEC
		SBC	<PLYPS1
		CLC
		ADC	#0000FH
		CMP	#00012H
		BCS	UUKMV80
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#p2_kage	;WARP
		STA	<GAMEMD
		LDA	#001H
		STA	TRIFFG
		STZ	<JRSBPT
		STZ	<PLYSPD
		STZ	<PLXSPD
		LDA	#TRFS
		STA	<LNMODE
;
		LDA	<MPDTNO
		AND	#040H
		STA	<OMPHZN
;
UUKMV80		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------
UZUMK00		EQU	$
		LDA	ENCLOR,X
		AND	#03FH
		STA	ENCLOR,X
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		TAY
		LDA	UUKMVDT,Y
		ORA	ENCLOR,X
		STA	ENCLOR,X
		LDA	#1*4
		JSL	>OAMENT2
		MEM16
		IDX8
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	#00005H
		STA	ENXP2L
		MEM8
		IDX8
		SEP	#00110000B
		JSL	>EN1CSTL
		JSR	ENSTCK		;scroll : not return
;
		JSL	>CRENPL2L	;PL. BODY CHK
		BCC	UUKMV10
;
		LDA	ENWRK0,X
		BNE	UUKMV20
;
		LDA	#p2_warp
		STA	<GAMEMD
		STZ	<JRSBPT
;
UUKMV20		EQU	$
		RTS
;
UUKMV10		EQU	$
		STZ	ENWRK0,X
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SAMTM  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SMM00		EQU	00000H
SMM01		EQU	SMM00+1
SMM02		EQU	SMM01+1
SMM03		EQU	SMM02+1
SMM04		EQU	SMM03+1
SMM05		EQU	SMM04+1
SMM06		EQU	SMM05+1
;
SMM10		EQU	SMM06+1
SMM20		EQU	SMM10+1
SMM30		EQU	SMM20+1
SMM40		EQU	SMM30+1
SMM50		EQU	SMM40+1
SMM60		EQU	SMM50+1
SMM70		EQU	SMM60+1
;;;;;		EQU	SMM70+1
;
;
SAMTMMV		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	SAMTM00		;MAN
		WORD	SAMTM01		;MAN		TAKARA YA(2)
		WORD	SAMTM02		;MAN		300
		WORD	SAMTM03		;MAN		20 TAKARA YA(1)
		WORD	SAMTM04		;MAN		100 TAKARA YA(1)
		WORD	SAMTM05		;MAN		MSGE ONRY
		WORD	SAMTM06		;MAN		MSGE ONRY
;--
		WORD	SAMTM10		;RED POTION	150
		WORD	SAMTM20		;TATE		50
		WORD	SAMTM30		;TATE		100
		WORD	SAMTM40		;HART		10
		WORD	SAMTM50		;YA*10		30
		WORD	SAMTM60		;BOMB*10	50
		WORD	SAMTM70		;HACHI		100
;========================================
SAMTM00		EQU	$
		LDA	URAFLG
		BEQ	SMM0010
;
		JSL	>OCHECKL
		JSL	>EN1CSTL
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENCLOR,X
		AND	#03FH
		STA	<WORK0
;
		LDA	<FRCNT
		ASL	A
		ASL	A
		ASL	A
		AND	#040H
		ORA	<WORK0
		STA	ENCLOR,X
;
SMM0020		EQU	$
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDY	URAFLG		;? URA
		LDA	SM0M0ML,Y
		XBA
		LDA	SM0M0MH,Y
		TAY
		XBA
		JSL	>ENMSGEL	;MSGE SET
;
		LDA	ENSTAT,X
		BEQ	SMM00M0
		BRA	SMM00M1
;
;
SMM0010		EQU	$
		LDA	#007H
		STA	ENCLOR,X
		JSL	>MJSY1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		BRA	SMM0020
;----------------------------------------
SM0M0ML		EQU	$
		BYTE	LOW  MS_0556
		BYTE	LOW  MS_0550
SM0M0MH		EQU	$
		BYTE	HIGH MS_0556
		BYTE	HIGH MS_0550
SMM00M0		EQU	$
		MEM16
		IDX8
		REP	#00100000B
		LDA	ENYP2L
		CLC
		ADC	#060H
		CMP	<PLYPS1
		MEM8
		IDX8
		SEP	#00110000B
		BCC	SMM00M1
;
		LDY	URAFLG		;? URA
		LDA	SM0M0ML,Y
		XBA
		LDA	SM0M0MH,Y
		TAY
		XBA
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
SMM00M1		EQU	$
		RTS
;========================================
SAMTM01		EQU	$
;
		JSL	>OCHECKL
		JSL	>EN1CSTL
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENCLOR,X
		AND	#03FH
		STA	<WORK0
;
		LDA	<FRCNT
		ASL	A
		ASL	A
		ASL	A
		AND	#040H
		ORA	<WORK0
		STA	ENCLOR,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SMM01M0
		WORD	SMM01M1
		WORD	SMM01M2
;----------------------------------------
SMM01M0		EQU	$
		LDA	ATBXCT
		DEC	A
		CMP	#002H
		BCC	SM1M010
;
		LDA	#LOW  MS_0551
		LDY	#HIGH MS_0551
		JSL	>ENMSGEL	;MSGE SET
		BCC	SM1M010
		INC	ENSTAT,X
SM1M010		EQU	$
		RTS
;----------------------------------------
SMM01M1		EQU	$
;
		LDA	MSG_RTS
		BNE	SM1M110
;
		LDA	#030		;#00030
		LDY	#000
		JSR	OKANEDC		;OKANE DEC
		BCC	SM1M110
;
		LDA	#002H
		STA	ATBXCT		;TAKARA OPEN OK
;
		LDA	#LOW  MS_0555
		LDY	#HIGH MS_0555
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;
SM1M110		EQU	$
		LDA	#LOW  MS_0552
		LDY	#HIGH MS_0552
		JSL	>ENMSGSL	;MSGE SET
		STZ	ENSTAT,X
		RTS
;----------------------------------------
SMM01M2		EQU	$
		LDA	ATBXCT
		BNE	SM1M210
		LDA	#LOW  MS_0554
		LDY	#HIGH MS_0554
		JSL	>ENMSGEL	;MSGE SET
		RTS
SM1M210		EQU	$
		LDA	#LOW  MS_05C1
		LDY	#HIGH MS_05C1
		JSL	>ENMSGEL	;MSGE SET
		RTS
;========================================
THEFTCS		EQU	$
		LDA	<FRCNT
		AND	#003H
		BNE	TETCS20
		LDA	#002H
		STA	ENCHPT,X
		JSR	EPXYCK
		CPY	#003H
		BNE	TETCS10
		LDY	#002H
TETCS10		EQU	$
		TYA
		STA	ENKBMK,X
;
TETCS20		EQU	$
		JSL	>OCHECKL
		JSL	>TheftCS
		RTS
;========================================
SAMTM02		EQU	$
		JSR	THEFTCS
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SMM02M0
		WORD	SMM02M1
		WORD	SMM02M2
;----------------------------------------
SMM02M0		EQU	$
		LDA	#LOW  MS_05B0
		LDY	#HIGH MS_05B0
		JSL	>ENMSGEL	;MSGE SET
		BCC	SM2M010
		INC	ENSTAT,X
SM2M010		EQU	$
		RTS
;----------------------------------------
SMM02M1		EQU	$
		LDA	EMYSTT+1
		AND	#040H
		BNE	SMM02M2
;
		LDA	EMYSTT+1	;SAVE
		ORA	#040H
		STA	EMYSTT+1
;
		INC	ENSTAT,X
		LDY	#046H
		JMP	SAMTMIM
;----------------------------------------
SMM02M2		EQU	$
		STZ	ENSTAT,X
		RTS
;========================================
SAMTM03		EQU	$
		JSR	EPXYCK
		TYA
		EOR	#003H
		STA	ENMUKI,X
		STZ	ENCHPT,X
;
		JSL	>MEIR1CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SMM03M0
		WORD	SMM03M1
		WORD	SMM03M2
;----------------------------------------
SMM03M0		EQU	$
		LDA	ATBXCT
		DEC	A
		CMP	#002H
		BCC	SM3M010
;
		LDA	#LOW  MS_05C0
		LDY	#HIGH MS_05C0
		JSL	>ENMSGEL	;MSGE SET
		BCC	SM3M010
		INC	ENSTAT,X
SM3M010		EQU	$
		RTS
;----------------------------------------
SMM03M1		EQU	$
;
		LDA	MSG_RTS
		BNE	SM3M110
;
		LDA	#020		;#00030
		LDY	#000
		JSR	OKANEDC		;OKANE DEC
		BCC	SM3M110
;
		LDA	#001H
		STA	ATBXCT		;TAKARA OPEN OK
;
		LDA	#LOW  MS_05C1
		LDY	#HIGH MS_05C1
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;
SM3M110		EQU	$
		LDA	#LOW  MS_05C2
		LDY	#HIGH MS_05C2
		JSL	>ENMSGSL	;MSGE SET
		STZ	ENSTAT,X
		RTS
;----------------------------------------
SM3M2ML		EQU	$
		BYTE	LOW  MS_0554
		BYTE	LOW  MS_05C1
SM3M2MH		EQU	$
		BYTE	HIGH MS_0554
		BYTE	HIGH MS_05C1
;
SMM03M2		EQU	$
SMM04M2		EQU	$
		LDA	ATBXCT
		TAY
		LDA	SM3M2ML,Y
		XBA
		LDA	SM3M2MH,Y
		TAY
		XBA
		JSL	>ENMSGEL	;MSGE SET
		RTS
;========================================
SAMTM04		EQU	$
		JSR	THEFTCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SMM04M0
		WORD	SMM04M1
		WORD	SMM04M2
;----------------------------------------
SMM04M0		EQU	$
		LDA	ATBXCT
		DEC	A
		CMP	#002H
		BCC	SM3M010
;
		LDA	#LOW  MS_05C3
		LDY	#HIGH MS_05C3
		JSL	>ENMSGEL	;MSGE SET
		BCC	SM4M010
		INC	ENSTAT,X
SM4M010		EQU	$
		RTS
;----------------------------------------
SMM04M1		EQU	$
;
		LDA	MSG_RTS
		BNE	SM4M110
;
		LDA	#100		;#00030
		LDY	#000
		JSR	OKANEDC		;OKANE DEC
		BCC	SM4M110
;
		LDA	#001H
		STA	ATBXCT		;TAKARA OPEN OK
;
		LDA	#LOW  MS_05C1
		LDY	#HIGH MS_05C1
		JSL	>ENMSGSL	;MSGE SET
		INC	ENSTAT,X
		RTS
;
SM4M110		EQU	$
		LDA	#LOW  MS_05C2
		LDY	#HIGH MS_05C2
		JSL	>ENMSGSL	;MSGE SET
		STZ	ENSTAT,X
		RTS
;========================================
SMM05ML		EQU	$
		BYTE	LOW  MS_05B1
		BYTE	LOW  MS_05B2
SMM05MH		EQU	$
		BYTE	HIGH MS_05B1
		BYTE	HIGH MS_05B2
;
;
SAMTM05		EQU	$
SAMTM06		EQU	$
		JSR	THEFTCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		LDA	ENCONT,X
		SEC
		SBC	#SMM05
		TAY
		LDA	SMM05ML,Y
		XBA
		LDA	SMM05MH,Y
		TAY
		XBA
		JSL	>ENMSGEL	;MSGE SET
		RTS
;========================================
SMM10YN		EQU	00150
;
SAMTM10		EQU	$
		JSR	SAMTMCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSR	SAMTMKY
		BCC	SMM1010
;
		JSL	>BINCHKL	;BIN AKI CHK (A <- INDEX)
		BMI	SMM1020
;
		LDA	#LOW  SMM10YN
		LDY	#HIGH SMM10YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SMM1030
;
		STZ	ENMODE,X
;
		LDY	#02EH		;RED POTION SET
		JSR	SAMTMIM
;
SMM1010		EQU	$
		RTS
;
SMM1020		EQU	$
		LDA	#LOW  MS_055E	;MSGE NO
		LDY	#HIGH MS_055E	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		JSR	SMMMBUT		;NOT USE ITEM
		RTS
;
SMM1030		EQU	$
KANENAS		EQU	$
		LDA	#LOW  MS_05B6	;MSGE NO	OKANE NASI
		LDY	#HIGH MS_05B6	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		JSR	SMMMBUT		;NOT USE ITEM
		RTS
;----------------------------------------
SM0STPX		EQU	$
		WORD	0FFD8H-SAMTMCX,0000CH-SAMTMCX,00040H-SAMTMCX
;
SMM10ST		EQU	$
		PHA			;POS SAVE
		PHY
		LDA	#SAMTM
		LDY	#00CH
		JSL	>ENIDSH2
;
		PLA			;MODE
		STA	ENCONT,Y
		STA	ENNOCR,Y
;
		PLA
		PHX
		ASL	A
		TAX
;
		LDA	<WORK0
		CLC
		ADC	>SM0STPX,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	>SM0STPX+1,X
		STA	ENXPSH,Y
;
		LDA	<WORK2
		CLC
		ADC	#027H
		STA	ENYPSL,Y
		LDA	<WORK3
		STA	ENYPSH,Y
;
		LDA	ENMOD0,Y
		ORA	#004H
		STA	ENMOD0,Y
;
		PLX
		RTL
;========================================
SMM20YN		EQU	00050
;
SAMTM20		EQU	$
		JSR	SAMTMCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSR	SMM30SB		;YA ATARI & KEN ATARI
;
		JSR	SAMTMKY
		BCC	SMM2010
;
		LDA	>ITMTBL7
;		CMP	#001H
;		BCS	SMM2020
		BNE	SMM2020
;
		LDA	#LOW  SMM20YN
		LDY	#HIGH SMM20YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SMM2030
;
		STZ	ENMODE,X
;
		LDY	#004H		;TATE 1 SET
		JSR	SAMTMIM
;
SMM2010		EQU	$
		LDA	#01CH
		STA	ENMOD3,X
		RTS
;
SMM2020		EQU	$
		LDA	#LOW  MS_0557
		LDY	#HIGH MS_0557
		JSL	>ENMSGSL	;MSGE SET
		JSR	SMMMBUT		;NOT USE ITEM
		RTS
;
SMM2030		EQU	$
		JMP	KANENAS		;KANE NASI
;========================================
SMM30YN		EQU	00500
;
SAMTM30		EQU	$
		JSR	SAMTMCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSR	SMM30SB		;YA ATARI & KEN ATARI
;
		JSR	SAMTMKY
		BCC	SMM3010
;
		LDA	>ITMTBL7
		CMP	#002H
		BCS	SMM2020
;
		LDA	#LOW  SMM30YN
		LDY	#HIGH SMM30YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SMM2030
;
		STZ	ENMODE,X
;
		LDY	#005H		;TATE 2 SET
		JSR	SAMTMIM
;
SMM3010		EQU	$
		LDA	#01CH
		STA	ENMOD3,X
		RTS
;
SMM30SB		EQU	$
		STZ	ENNOCR,X
		LDA	#008H
		STA	ENMOD7,X
		LDA	#004H
		STA	ENMOD5,X
;
		LDA	#01CH
		STA	ENMOD3,X
		JSL	>CRKNENL
		LDA	#00AH
		STA	ENMOD3,X
		RTS
;========================================
SMM40YN		EQU	00010
;
SAMTM40		EQU	$
		JSR	SAMTMCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSR	SAMTMKY
		BCC	SMM4010
;
		LDA	>LFITCT		;? LIFE MAX
		CMP	>LFNWCT
		BEQ	SMM4020
;
		LDA	#LOW  SMM40YN
		LDY	#HIGH SMM40YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SMM4030
;
		STZ	ENMODE,X
;
		LDY	#042H		;HART SET
		JSR	SAMTMIM
SMM4010		EQU	$
		RTS
;
SMM4020		EQU	$
		JSR	SMMMBUT		;NOT USE ITEM
		RTS
;
SMM4030		EQU	$
		JMP	KANENAS		;KANE NASI
;========================================
SMM50YN		EQU	00030
;
SAMTM50		EQU	$
		JSR	SAMTMCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSR	SAMTMKY
		BCC	SMM5010
;
		LDA	>ITEMR50
		PHX
		TAX
		LDA	>YAAAMAX,X
		PLX
		CMP	>ARWCNT
		BEQ	SMM5020
;
		LDA	#LOW  SMM50YN
		LDY	#HIGH SMM50YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SMM5030		;DEC KANE
;
		STZ	ENMODE,X
;
		LDY	#044H		;YAAAA*10 SET
		JSR	SAMTMIM
;
SMM5010		EQU	$
		RTS
SMM5020		EQU	$
		LDA	#LOW  MS_055F
		LDY	#HIGH MS_055F
		JSL	>ENMSGEL	;MSGE SET
		JSR	SMMMBUT		;NOT USE ITEM
		RTS
;
SMM5030		EQU	$
		JMP	KANENAS		;KANE NASI
;========================================
SMM60YN		EQU	00050
;
SAMTM60		EQU	$
		JSR	SAMTMCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSR	SAMTMKY
		BCC	SMM6010
;
		LDA	>ITEMR49
		PHX
		TAX
		LDA	>BOMBMAX,X
		PLX
		CMP	>BMBCNT
		BEQ	SMM5020
;
		LDA	#LOW  SMM60YN
		LDY	#HIGH SMM60YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SMM5030
;
		STZ	ENMODE,X
;
		LDY	#031H		;BOMB*10 SET
		JSR	SAMTMIM
;
SMM6010		EQU	$
		RTS
;========================================
SMM70YN		EQU	00010
;
SAMTM70		EQU	$
		JSR	SAMTMCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSR	SAMTMKY
		BCC	SMM7010
;
		JSL	>BINCHKL	;BIN AKI CHK (A <- INDEX)
		BMI	SMM7020
;
		LDA	#LOW  SMM70YN
		LDY	#HIGH SMM70YN
		JSR	OKANEDC		;OKANE DEC
		BCC	SMM7030
;
		STZ	ENMODE,X
;
		LDY	#00EH		;HACHI SET
		JSR	SAMTMIM
;
SMM7010		EQU	$
		RTS
;
SMM7020		EQU	$
		LDA	#LOW  MS_055E	;MSGE NO
		LDY	#HIGH MS_055E	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
		JSR	SMMMBUT		;NOT USE ITEM
		RTS
;
SMM7030		EQU	$
		JMP	KANENAS		;KANE NASI
;
;========================================
SMMIMML		EQU	$
		BYTE	LOW  MS_0559	;RED POTION
		BYTE	LOW  MS_0558	;TATE 1
		BYTE	LOW  MS_0558	;TATE 1
		BYTE	LOW  MS_055D	;HART
		BYTE	LOW  MS_055A	;YAAAA*10
		BYTE	LOW  MS_055B	;BOMB*10
		BYTE	LOW  MS_055C	;HACHI
;
SMMIMMH		EQU	$
		BYTE	HIGH MS_0559	;RED POTION
		BYTE	HIGH MS_0558	;TATE 1
		BYTE	HIGH MS_0558	;TATE 1
		BYTE	HIGH MS_055D	;HART
		BYTE	HIGH MS_055A	;YAAAA*10
		BYTE	HIGH MS_055B	;BOMB*10
		BYTE	HIGH MS_055C	;HACHI
;
SAMTMIM		EQU	$
		STZ	!ITMVFG
		PHX			;
		JSL	>ATMSIT
		PLX
;
		LDA	ENCONT,X
		SEC
		SBC	#SMM10
		BMI	SMMIM10
;
		TAY
		LDA	SMMIMML,Y
		XBA
		LDA	SMMIMMH,Y
		TAY
		XBA
		JSL	>ENMSGSL	;MSGE SET
		JSL	>MCGTHK
;
SMMIM10		EQU	$
		RTS
;========================================
SMMMBUT		EQU	$		;ITEM KAENAI
		LDA	#03CH		;OTO
		JSL	>SDLRE2
		RTS
;========================================
;
;	C <-- YES
;	c <-- NO
;
SAMTMKY		EQU	$
		LDA	<KEYA2L
		BPL	SMMKY10
		JSL	>CRENPL2L
		BCC	SMMKY10
		RTS
SMMKY10		EQU	$
		CLC
		RTS
;========================================
;	A <-- KINGAKU LOW
;	Y <-- KINGAKU HIGH
;
;	C <-- ON
;	c <-- OFF
;
;
OKANEDC		EQU	$
		STA	<WORK0
		STY	<WORK1
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	>CONCNT
		CMP	<WORK0		;? KANE ARU
		BCC	OAEDC10
		SBC	<WORK0		;DEC KANE
		STA	>CONCNT
		SEC
OAEDC10		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
;
		RTS
;========================================
SAMTMCX		EQU	00004H
SAMTMCD		EQU	$
		WORD	-0008+SAMTMCX,00016		;1
		BYTE	031H,002H,000H,000H
		WORD	00000+SAMTMCX,00016		;5
		BYTE	013H,002H,000H,000H
		WORD	00008+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	-0004+SAMTMCX,00000		;RED POTION
		BYTE	0C0H,002H,000H,002H
		WORD	-0004+SAMTMCX,00011		;KAGE
		BYTE	06CH,003H,000H,002H
;
		WORD	-0004+SAMTMCX,00016		;
		BYTE	013H,002H,000H,000H
		WORD	-0004+SAMTMCX,00016		;5
		BYTE	013H,002H,000H,000H
		WORD	00004+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	-0004+SAMTMCX,00000		;TATE
		BYTE	0CEH,004H,000H,002H
		WORD	00000+SAMTMCX,00012		;KAGE
		BYTE	038H,003H,000H,000H
;
		WORD	-0008+SAMTMCX,00016		;5
		BYTE	013H,002H,000H,000H
		WORD	00000+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	00008+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	-0004+SAMTMCX,00000		;TATE
		BYTE	0CCH,008H,000H,002H
		WORD	00000+SAMTMCX,00012		;KAGE
		BYTE	038H,003H,000H,000H
;
		WORD	-0004+SAMTMCX,00016		;
		BYTE	031H,002H,000H,000H
		WORD	-0004+SAMTMCX,00016		;1
		BYTE	031H,002H,000H,000H
		WORD	00004+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	00000+SAMTMCX,00008		;HART
		BYTE	029H,003H,000H,000H
		WORD	00000+SAMTMCX,00011		;KAGE
		BYTE	038H,003H,000H,000H
;
		WORD	-0008+SAMTMCX,00016		;
		BYTE	003H,002H,000H,000H
		WORD	-0008+SAMTMCX,00016		;3
		BYTE	003H,002H,000H,000H
		WORD	00000+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	-0004+SAMTMCX,00000		;YAAAA*10
		BYTE	0C4H,004H,000H,002H
		WORD	-0004+SAMTMCX,00011		;KAGE
		BYTE	038H,003H,000H,000H
;
		WORD	-0004+SAMTMCX,00016		;
		BYTE	013H,002H,000H,000H
		WORD	-0004+SAMTMCX,00016		;5
		BYTE	013H,002H,000H,000H
		WORD	00004+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	-0004+SAMTMCX,00000		;BOMB*10
		BYTE	0E8H,004H,000H,002H
		WORD	-0004+SAMTMCX,00011		;KAGE
		BYTE	06CH,003H,000H,002H
;
		WORD	-0004+SAMTMCX,00016		;
		BYTE	031H,002H,000H,000H
		WORD	-0004+SAMTMCX,00016		;1
		BYTE	031H,002H,000H,000H
		WORD	00004+SAMTMCX,00016		;0
		BYTE	030H,002H,000H,000H
		WORD	00000+SAMTMCX,00008		;HACHI
		BYTE	0F4H,00FH,000H,000H
		WORD	00000+SAMTMCX,00011		;KAGE
		BYTE	038H,003H,000H,000H
;
SAMTMCS		EQU	$
		LDA	ENCONT,X
		SEC
		SBC	#SMM10
		MEM16
		IDX8
		REP	#00100000B
		AND	#000FFH
		STA	<WORK0
		ASL	A
		ASL	A
		ADC	<WORK0
		ASL	A
		ASL	A
		ASL	A
		ADC	#SAMTMCD
		STA	<WORK8
		LDA	#005H
		STA	<WORK6
		MEM8
		IDX8
		SEP	#00110000B
;
		JSL	>SETOAML
		RTS
;========================================
ENPLATR		EQU	$		;PL. EN. ATARI SET
		LDA	ENMOD3,X
		PHA
		STZ	ENMOD3,X
		JSL	>CRENPL2L
		BCC	EPATR10
		JSR	EPATRBK
EPATR10		EQU	$
		PLA
		STA	ENMOD3,X
		RTL
;
EPATRBK		EQU	$
		PHX
		JSL	>PLOTCK		;PL. POS. recover
		STZ	<PYSPFG		;DASH STOP
		JSL	>DASCLR1
		PLX
		RTS
;========================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	RINGO  move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RINGOMV		EQU	$
;		JSL	>EN1CSTL
		LDA	ENSTAT,X
		BNE	RINGOF1
;
		LDA	ENWRK3,X
		BNE	RNGF010
;
		STZ	ENMODE,X	;KILL I
;
		JSL	>RNDSET		;KAZU SET
		AND	#003H
		CLC
		ADC	#002H
		TAY
RNGF020		EQU	$
		PHY
		JSR	RINGOST
		PLY
		DEY
		BPL	RNGF020	
;
RNGF010		EQU	$
		RTS
;----------------------------------------
RINGOST		EQU	$
		LDA	#RINGO
		JSL	>ENIDSH
		BMI	RNGST10
;
		JSL	>ENIDPS
;
		LDA	#001H		;EAT RINGO
		STA	ENSTAT,Y
;
		LDA	#0FFH		;TIME SET
		STA	ENWRK0,Y
;
		LDA	#008H
		STA	ENZPSL,Y
		LDA	#016H		;Z SPEED SET
		STA	ENZSPD,Y
;
		JSL	>RNDSET		;LDA	<PLXPS1
		STA	<WORK4
		LDA	<WORK1
		STA	<WORK5
		JSL	>RNDSET		;LDA	<PLYPS1
		STA	<WORK6
		LDA	<WORK3
		STA	<WORK7
;
		LDA	#00AH		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
;
		LDA	<WORK0		;SPEED SET
		STA	ENYSPD,Y
		LDA	<WORK1
		STA	ENXSPD,Y
;
RNGST10		EQU	$
		RTS
;----------------------------------------
RINGOSP		EQU	$
		BYTE	-01,001
;
RINGOF1		EQU	$		;EAT RINGO
		LDA	ENWRK0,X
		CMP	#010H
		BCS	RNGF180
		LDA	<FRCNT
		AND	#002H
		BEQ	RNGF190
RNGF180		EQU	$	
		JSL	>EN1CSTL
RNGF190		EQU	$
		JSR	ENSTCK		;scroll : not return
		LDA	ENWRK0,X	;? TIME
		BEQ	RNGF160
		JSR	ENMVCL2
;		JSR	ENMVCL		;xclc,yclc
;		JSR	ENZCLC		;zclc
		JSR	CRENPL		;PL. BODY CHK
		BCC	RNGF150
;
;;		JSL	>SDLRCE		;OTO
;;		ORA	#00BH
;;		STA	SOUND3
		LDA	#0BH
		JSL	>SDLRE3	;(S)
;
		LDA	>UPLFCT
		CLC
		ADC	#008H
		STA	>UPLFCT
RNGF160		EQU	$
		STZ	ENMODE,X	;KILL I
		RTS
;----------------------------------------
RNGF150		EQU	$
		LDA	<FRCNT
		AND	#001H
		BNE	RNGF140
;
		DEC	ENWRK0,X	;TIMER DEC
RNGF140		EQU	$
;
		LDA	ENZPSL,X
		DEC	A
		BPL	RNGF110
		STZ	ENZPSL,X	;Z POS SET
		LDA	ENZSPD,X	;Z SPEED SET
		BMI	RNGF170
		LDA	#000H
RNGF170		EQU	$
		EOR	#0FFH
		INC	A
		LSR	A
		STA	ENZSPD,X
;
		LDA	ENXSPD,X	;X SPEED SET
		BEQ	RNGF120
		PHA
		ASL	A
		LDA	#000H
		ROL	A
		TAY
		PLA
		CLC
		ADC	RINGOSP,Y
		STA	ENXSPD,X
RNGF120		EQU	$
		LDA	ENYSPD,X	;Y SPEED SET
		BEQ	RNGF130
		PHA
		ASL	A
		LDA	#000H
		ROL	A
		TAY
		PLA
		CLC
		ADC	RINGOSP,Y
		STA	ENYSPD,X
RNGF130		EQU	$
		RTS
;----------------------------------------
RNGF110		EQU	$
		LDA	ENZSPD,X	;Z SPEED SET
		SEC
		SBC	#001H
		STA	ENZSPD,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	RYOKI MOVE	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RYOKIMV		EQU	$
		JSL	>RYOKICS
		JSR	ENSTCK		;scroll : not return
		JSL	>ENPLATR
;
		JSL	>RNDSET
		BNE	RYOKI10
		LDA	#020H
		STA	ENTIM0,X
RYOKI10		EQU	$
		STZ	ENCHPT,X
		LDA	ENTIM0,X
		BEQ	RYOKI20
		INC	ENCHPT,X
RYOKI20		EQU	$
		LDA	#LOW  MS_05A0
		LDY	#HIGH MS_05A0
		JSL	>ENMSGEL	;MSGE SET
		BCC	RYOKI30
		STZ	ENCHPT,X
RYOKI30		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	LINE0 INITIAL	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LINE0IT		EQU	$
		LDA	#0FFH
		STA	ENSTATS
		LDA	ENMYNO,X
		SEC
		SBC	#DOKN0
		STA	ENMUKI,X
;
;
LE0ITSB		EQU	$
		JSR	LLBGRD
		STA	ENWRK3,X	;INIT unit set
		SEC
		SBC	#0B0H
		BCS	L0TSB10
L0TSB20		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#008H
		STA	ENXPSL,X
		LDA	ENXPSH,X
		ADC	#000H
		STA	ENXPSH,X
;
		LDA	ENYPSL,X
		CLC
		ADC	#008H
		STA	ENYPSL,X
		LDA	ENYPSH,X
		ADC	#000H
		STA	ENYPSH,X
		BRA	LE0ITSB
L0TSB10		EQU	$
		CMP	#00FH
		BCS	L0TSB20
;
		LDA	ENXPSL,X
		AND	#0F8H
		CLC
		ADC	#004H
		STA	ENXPSL,X
		LDA	ENYPSL,X
		AND	#0F8H
		CLC
		ADC	#004H
		STA	ENYPSL,X
		LDA	ENMUKI,X	;MUKI SAVE
		STA	ENCMKI,X
		JSR	LINE0SM
;
		INC	ENNOCR,X	;beem thru
;
		STZ	PSSTOP
;
		LDA	#00EH
		STA	ENTIM3,X
;
		INC	ENCHPT,X	;NEXT MOVE
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	LINE0 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LINE0MV		EQU	$
		PHB
		PHK
		PLB
		JSR	L00000
		PLB
		RTL
;=========================================
;----------------------------------------
LINE0SX		EQU	$
		BYTE	000,000,-16,016,-16,016,016;,-16
LINE0SY		EQU	$
		BYTE	-16,016,000,000,-16,016,-16,016
;
LEPLXDH		EQU	$
		BYTE	000,000,-01,000,-01;,000,000,-01
LEPLXDL		EQU	$
		BYTE	000,000,-01,001,-01,001,001;,-01
;
LEPLYDL		EQU	$
		BYTE	-01,001,000,000,-01,001,-01,001
LEPLYDH		EQU	$
		BYTE	-01,000,000,000,-01,000,-01,000
;
;
L00000		EQU	$
		LDA	ENCHPT,X
		JSL	>JSRSUB
		WORD	LINE0I0
		WORD	L000010
;----------------------------------------
LINE0I0		EQU	$
		JSR	LE0ITSB
		JSL	>KEMR1ST
		LDA	ENXPSL,Y
		SEC
		SBC	#08H
		STA	ENXPSL,Y
		LDA	ENXPSH,Y
		SBC	#00H
		STA	ENXPSH,Y
		LDA	ENYPSL,Y
		SEC
		SBC	#08H
		STA	ENYPSL,Y
		LDA	ENYPSH,Y
		SBC	#00H
		STA	ENYPSH,Y
;
		RTS
;----------------------------------------
L000010		EQU	$
		JSR	LINE0CS
		JSR	ENSTCK          ; scroll : not return !
;
		LDA	PLXMVD
		ORA	PLXMVD+1
		ORA	PLYMVD
		ORA	PLYMVD+1
		BEQ	LINE060
LINE010DM	EQU	$
		JMP	LINE010
;
LINE060		EQU	$
		LDA	<HOLEFG2
		DEC	A
		DEC	A
		BPL	LINE010DM
		JSL	>CRENPL3L
		BCC	LINE010		;? PL. TUCH
;					;Y
		LDA	#001H
		STA	ENWRK2,X
;
		JSL	>DASCLR1
;
		LDA	<LNMODE
		CMP	#BOGN
		BEQ	LINE010		;? BOUGAN
		CMP	#KNSP
		BEQ	LINE010		;? KEN KAITEN
;					;N
		LDA	ENSTAT,X
		BNE	LINE020		;? STOP
;					;N
		INC	ENWRK0,X	;FRCNT (LINE0 SENYOU)
;
		LDA	#002H		;PL. MODE
		STA	PSSTOP
;
		LDA	ENWRK0,X	;HOSEI
		AND	#007H
		BNE	LINE030
;
		JSR	LLBGRD		;bg chk.
		CMP	ENWRK3,X
		BEQ	LINE030		;? unit !=
;					;Y
		STA	ENWRK3,X	;unit save
;
		LDA	ENMUKI,X	;MUKI SAVE
		STA	ENCMKI,X
;
		JSR	LINE0SM		;muki kae & speed
		JSR	LN0MKXY		;X Y HOSEI
;
LINE030		EQU	$
		LDA	<RMXYCT		;TOKUBETU
		CMP	#024H
		BEQ	LINE050
;
		LDY	ENMUKI,X	;PL. MOVE SET
		LDA	LEPLXDL,Y
		CLC
		ADC	PLXMVD
		STA	PLXMVD
		LDA	LEPLXDH,Y
		ADC	PLXMVD+1
		STA	PLXMVD+1
		LDA	LEPLYDL,Y
		CLC
		ADC	PLYMVD
		STA	PLYMVD
		LDA	LEPLYDH,Y
		ADC	PLYMVD+1
		STA	PLYMVD+1
		JSR	ENMVCL		; xclc,yclc !
		JSR	LINE0PL		;PL. HOSEI
		RTS
LINE050		EQU	$
;;		LDA	#001H		;PL. MODE(LINE0)
;;		STA	PSSTOP
;;		RTS
		JMP	LN0BC10
LINE010		EQU	$
		LDA	ENWRK2,X
		BEQ	LINE040
		STZ	PSSTOP
		STZ	ENWRK2,X
LINE040		EQU	$
		RTS
;----------------------------------------
LINE0SM		EQU	$
DOKN0SM		EQU	$
LINE020		EQU	$
		JSR	LINE0MK		;muki kae
;
		LDY	ENMUKI,X	;SPEED	set
		LDA	LINE0SX,Y
		STA	ENXSPD,X
		LDA	LINE0SY,Y
		STA	ENYSPD,X
;
		RTS
;----------------------------------------
LLBGRD		EQU	$
		LDA	ENYPSL,X
		STA	<WORK0
		LDA	ENYPSH,X
		STA     <WORK1
		LDA	ENXPSL,X
		STA	<WORK2
		LDA	ENXPSH,X
		STA	<WORK3
		LDA	#000H		;1 kai or 2 kai (level)
		JSL	>BGDTRD2
;					
		LDA	UNITNO
;
		RTS
;
;----------------------------------------
LINE0CX		EQU	-16
LINE0CY		EQU	-16
;
LINE0CD		EQU	$
		WORD	00000+LINE0CX,00000+LINE0CY
		BYTE	0ACH,000H,000H,002H
		WORD	00016+LINE0CX,00000+LINE0CY
		BYTE	0ACH,040H,000H,002H
		WORD	00000+LINE0CX,00016+LINE0CY
		BYTE	0ACH,080H,000H,002H
		WORD	00016+LINE0CX,00016+LINE0CY
		BYTE	0ACH,0C0H,000H,002H
;
		WORD	00003+LINE0CX,00003+LINE0CY
		BYTE	0ACH,000H,000H,002H
		WORD	00013+LINE0CX,00003+LINE0CY
		BYTE	0ACH,040H,000H,002H
		WORD	00003+LINE0CX,00013+LINE0CY
		BYTE	0ACH,080H,000H,002H
		WORD	00013+LINE0CX,00013+LINE0CY
		BYTE	0ACH,0C0H,000H,002H
;
		WORD	00006+LINE0CX,00006+LINE0CY
		BYTE	0ACH,000H,000H,002H
		WORD	00010+LINE0CX,00006+LINE0CY
		BYTE	0ACH,040H,000H,002H
		WORD	00006+LINE0CX,00010+LINE0CY
		BYTE	0ACH,080H,000H,002H
		WORD	00010+LINE0CX,00010+LINE0CY
		BYTE	0ACH,0C0H,000H,002H
;
		WORD	00008+LINE0CX,00008+LINE0CY
		BYTE	0ACH,000H,000H,002H
		WORD	00008+LINE0CX,00008+LINE0CY
		BYTE	0ACH,040H,000H,002H
		WORD	00008+LINE0CX,00008+LINE0CY
		BYTE	0ACH,080H,000H,002H
		WORD	00008+LINE0CX,00008+LINE0CY
		BYTE	0ACH,0C0H,000H,002H
;
LINE0CS		EQU	$
		LDA	#4*4
		JSL	>OAMENT2
;
		LDA	ENTIM3,X
		AND	#00CH
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  LINE0CD
		STA	<WORK8
		LDA	#HIGH LINE0CD
		ADC	#000H
		STA	<WORK9
;
		LDA	#004H
;;		STA	<WORK6
;;		STZ	<WORK7
;
		JMP	SETO22
;;		JSL	>SETOAML22
;;;
;;		RTS
;----------------------------------------
;
LINE0MK		EQU	$
		LDA	ENWRK3,X
		SEC
		SBC	#0B0H
		BCS	LINE0MK1
		RTS
LINE0MK1	EQU	$
		CMP	#00FH
		BCC	LINE0MK2
		RTS
LINE0MK2	EQU	$
		JSL	>JSRSUB
		WORD	LN0MKB0
		WORD	LN0MKB1
		WORD	LN0MKB2
		WORD	LN0MKB3
		WORD	LN0MKB4
		WORD	LN0MKB5
		WORD	LN0MKB6
		WORD	LN0MKB7
		WORD	LN0MKB8
		WORD	LN0MKB9
		WORD	LN0MKBA
		WORD	LN0MKBB
		WORD	LN0MKBC
		WORD	LN0MKBD
		WORD	LN0MKBE
;
;---------------------------------------
LN0MKXX		EQU	$			;X HOSEI
		LDA	ENMUKI,X
		EOR	ENCMKI,X
		AND	#002H
		BEQ	L0MXX10
		LDA	ENXPSL,X
		AND	#0F8H
		CLC
		ADC	#004H
		STA	<WORK0
		SEC
		SBC	ENXPSL,X
		BEQ	L0MXX10
		STA	PLXMVD
		BPL	L0MXX20
		LDA	#0FFH
		STA	PLXMVD+1
L0MXX20		EQU	$
		LDA	<WORK0
		STA	ENXPSL,X
;
L0MXX10		EQU	$
		RTS
;----------------------------------------
LN0MKYY		EQU	$			;Y HOSEI
		LDA	ENMUKI,X
		EOR	ENCMKI,X
		AND	#002H
		BEQ	L0MYY10
		LDA	ENYPSL,X
		AND	#0F8H
		CLC
		ADC	#004H
		STA	<WORK0
		SEC
		SBC	ENYPSL,X
		BEQ	L0MYY10
		STA	PLYMVD
		BPL	L0MYY20
		LDA	#0FFH
		STA	PLYMVD+1
L0MYY20		EQU	$
		LDA	<WORK0
		STA	ENYPSL,X
;
L0MYY10		EQU	$
		RTS
;----------------------------------------
LN0MKXY		EQU	$			;X Y HOSEI
		JSR	LN0MKXX
		JSR	LN0MKYY
		RTS
;---------------------------------------
LN0MKB0		EQU	$			; |
;						; |
;----------------------------------------
LN0MKB1		EQU	$			;____
;						;
;---------------------------------------
LN0MKBD		EQU	$			;__ | __
;						;   |
		RTS
;----------------------------------------
LN0MKB2		EQU	$			;___
;						;|
;----------------------------------------
LN0MKB5		EQU	$			;  |
;						;--|
		LDA	ENMUKI,X
		EOR	#003H
		STA	ENMUKI,X
;
		RTS
;----------------------------------------
LN0MKB3		EQU	$			;|
;						;|__
;----------------------------------------
LN0MKB4		EQU	$			;__
;						; |
		LDA	ENMUKI,X
		EOR	#002H
		STA	ENMUKI,X
;
		RTS
;----------------------------------------
LN0B6DT		EQU	$
		BYTE	004H,008H,001H,002H
;
LN0MKB6		EQU	$			; ++
;						; ++
		LDA	#001H		;STOP
		STA	ENSTAT,X
;
		LDA	<DIEFG		;? HANE TEIRU
		BNE	LN0B610
;					;N
		LDY	ENMUKI,X
		LDA	<KEYA1
		AND	LN0B6DT,Y
		BEQ	LN0B610
		STZ	ENSTAT,X	;MOVE
		LDA	ENMUKI,X
		EOR	#001H
		STA	ENMUKI,X
;
LN0B610		EQU	$
;;		LDA	#001H		;PL. MODE(LINE0)
;;		STA	PSSTOP
;
;		STZ	PYALSP		;PL. MOVE(DOKN0)
		STZ	<OMSBMD
;
		JMP	LN0BC10
;;		RTS
;----------------------------------------
LN0B7KD		EQU	$
		BYTE	003H,007H,006H,005H
LN0MKB7		EQU	$			;___
;						; |
		LDA	#001H		;STOP
		STA	ENSTAT,X
;
		LDY	ENMUKI,X
		LDA	<KEYA1
		AND	LN0B7KD,Y
		STA	<WORK0
		AND	#008H
		BEQ	LN0B710
		LDA	#000H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B7RT
LN0B710		EQU	$
		LDA	<WORK0
		AND	#004H
		BEQ	LN0B720
		LDA	#001H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B7RT
LN0B720		EQU	$
		LDA	<WORK0
		AND	#002H
		BEQ	LN0B730
		LDA	#002H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B7RT
LN0B730		EQU	$
		LDA	<WORK0
		AND	#001H
		BEQ	LN0B740
		LDA	#003H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
;		BRA	LN0B7RT
LN0B740		EQU	$		;! KEY
		LDA	ENMUKI,X
;		CMP	#000H
		BNE	LN0B745
		LDA	#002H
		STA	ENMUKI,X
LN0B745		EQU	$
		STZ	ENSTAT,X	;MOVE
LN0B7RT		EQU	$
;
		RTS
;----------------------------------------
LN0B8KD		EQU	$
		BYTE	00BH,003H,00AH,009H
LN0MKB8		EQU	$			;__|__
;						;
		LDA	#001H		;STOP
		STA	ENSTAT,X
;
		LDY	ENMUKI,X
		LDA	<KEYA1
		AND	LN0B8KD,Y
		STA	<WORK0
		AND	#008H
		BEQ	LN0B810
		LDA	#000H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B8RT
LN0B810		EQU	$
		LDA	<WORK0
		AND	#004H
		BEQ	LN0B820
		LDA	#001H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B8RT
LN0B820		EQU	$
		LDA	<WORK0
		AND	#002H
		BEQ	LN0B830
		LDA	#002H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B8RT
LN0B830		EQU	$
		LDA	<WORK0
		AND	#001H
		BEQ	LN0B840
		LDA	#003H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
;		BRA	LN0B8RT
LN0B840		EQU	$		;! KEY
		LDA	ENMUKI,X
		CMP	#001H
		BNE	LN0B845
		LDA	#002H
		STA	ENMUKI,X
LN0B845		EQU	$
		STZ	ENSTAT,X	;MOVE
LN0B8RT		EQU	$
;
		RTS
;----------------------------------------
LN0B9KD		EQU	$
		BYTE	009H,005H,00CH,00DH
LN0MKB9		EQU	$			;|__
;						;|
		LDA	#001H		;STOP
		STA	ENSTAT,X
;
		LDY	ENMUKI,X
		LDA	<KEYA1
		AND	LN0B9KD,Y
		STA	<WORK0
		AND	#008H
		BEQ	LN0B910
		LDA	#000H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B9RT
LN0B910		EQU	$
		LDA	<WORK0
		AND	#004H
		BEQ	LN0B920
		LDA	#001H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B9RT
LN0B920		EQU	$
		LDA	<WORK0
		AND	#002H
		BEQ	LN0B930
		LDA	#002H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0B9RT
LN0B930		EQU	$
		LDA	<WORK0
		AND	#001H
		BEQ	LN0B940
		LDA	#003H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
;		BRA	LN0B9RT
LN0B940		EQU	$
		LDA	ENMUKI,X
		CMP	#002H
		BNE	LN0B945
		LDA	#000H
		STA	ENMUKI,X
LN0B945		EQU	$
		STZ	ENSTAT,X	;MOVE
LN0B9RT		EQU	$
;
		RTS
;----------------------------------------
LN0BAKD		EQU	$
		BYTE	00AH,006H,00EH,00CH
LN0MKBA		EQU	$			;__|
;						;  |
		LDA	#001H		;STOP
		STA	ENSTAT,X
;
		LDY	ENMUKI,X
		LDA	<KEYA1
		AND	LN0BAKD,Y
		STA	<WORK0
		AND	#008H
		BEQ	LN0BA10
		LDA	#000H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0BART
LN0BA10		EQU	$
		LDA	<WORK0
		AND	#004H
		BEQ	LN0BA20
		LDA	#001H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0BART
LN0BA20		EQU	$
		LDA	<WORK0
		AND	#002H
		BEQ	LN0BA30
		LDA	#002H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
		BRA	LN0BART
LN0BA30		EQU	$
		LDA	<WORK0
		AND	#001H
		BEQ	LN0BA40
		LDA	#003H
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
;		BRA	LN0BART
LN0BA40		EQU	$
		LDA	ENMUKI,X
		CMP	#003H
		BNE	LN0BA45
		LDA	#000H
		STA	ENMUKI,X
LN0BA45		EQU	$
		STZ	ENSTAT,X	;MOVE
LN0BART		EQU	$
;
		RTS
;----------------------------------------
LN0BBKD		EQU	$
		BYTE	00BH,007H,00EH,00DH
LN0MKBB		EQU	$			;__|__
;						;  |
		LDY	ENMUKI,X
		LDA	<KEYA1
		AND	LN0BBKD,Y
		STA	<WORK0
		AND	#008H
		BEQ	LN0BB10
		LDA	#000H
		STA	ENMUKI,X
		BRA	LN0BBRT
LN0BB10		EQU	$
		LDA	<WORK0
		AND	#004H
		BEQ	LN0BB20
		LDA	#001H
		STA	ENMUKI,X
		BRA	LN0BBRT
LN0BB20		EQU	$
		LDA	<WORK0
		AND	#002H
		BEQ	LN0BB30
		LDA	#002H
		STA	ENMUKI,X
		BRA	LN0BBRT
LN0BB30		EQU	$
		LDA	<WORK0
		AND	#001H
		BEQ	LN0BB40
		LDA	#003H
		STA	ENMUKI,X
;		BRA	LN0BBRT
LN0BB40		EQU	$
LN0BBRT		EQU	$
;
		RTS
;---------------------------------------
LN0BCDT		EQU	$
		BYTE	00CH,00CH,003H,003H
;
LN0MKBC		EQU	$			; --
;						; --
		LDA	#001H		;STOP
		STA	ENSTAT,X
;
		LDY	ENMUKI,X
		LDA	<KEYA1
		AND	LN0BCDT,Y
		BEQ	LN0BC10
		STA	<WORK0
		AND	#008H
		BEQ	LN0BC20
		LDA	#000H
		BRA	LN0BC80
LN0BC20		EQU	$
		LDA	<WORK0
		AND	#004H
		BEQ	LN0BC30
		LDA	#001H
		BRA	LN0BC80
LN0BC30		EQU	$
		LDA	<WORK0
		AND	#002H
		BEQ	LN0BC40
		LDA	#002H
		BRA	LN0BC80
LN0BC40		EQU	$
		LDA	#003H
LN0BC80		EQU	$
		STA	ENMUKI,X
		STZ	ENSTAT,X	;MOVE
;
LN0BC10		EQU	$
		LDA	#001H		;PL. MODE
		STA	PSSTOP
;
		RTS
;---------------------------------------
LN0MKBE		EQU	$
;						; ++
;						; ++
		STZ	ENSTAT,X	;MOVE
		LDA	ENMUKI,X
		EOR	#001H
		STA	ENMUKI,X
;
;;		LDA	#001H		;PL. MODE(LINE0)
;;		STA	PSSTOP
;
;		STZ	PYALSP		;PL. MOVE(DOKN0)
		STZ	<OMSBMD
;
		BRA	LN0BC10
;;		RTS
;----------------------------------------
LINE0PL		EQU	$
		MEM16
		IDX8
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	#00008H
		CMP	<PLXPS1
		BEQ	LN0PL10
		BPL	LN0PL20
		DEC	PLXMVD
		BRA	LN0PL10
LN0PL20		EQU	$
		INC	PLXMVD
LN0PL10		EQU	$
		LDA	ENYP2L
		SEC
		SBC	#00010H
		CMP	<PLYPS1
		BEQ	LN0PL30
		BPL	LN0PL40
		DEC	PLYMVD
		BRA	LN0PL30
LN0PL40		EQU	$
		INC	PLYMVD
LN0PL30		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------
;;LINE0ST		EQU	$
;;		LDA	#LINE0
;;		JSL	>ENIDSH
;;		BMI	LN0ST10
;;;
;;		LDA	BMWORK+0	;Y
;;		AND	#0F8H
;;		ORA	#004H
;;		STA	ENYPSL,Y
;;		LDA	BMWORK+1
;;		STA	ENYPSH,Y
;;;
;;		LDA	BMWORK+2	;X
;;		AND	#0F8H
;;		ORA	#004H
;;		STA	ENXPSL,Y
;;		LDA	BMWORK+3
;;		STA	ENXPSH,Y
;;;
;;		LDA	PLMKCH		;MUKI
;;		LSR	A
;;		STA	ENMUKI,Y
;;;
;;		LDA	<PLBGCKF	;KAI
;;		STA	ENKAIF,Y
;;LN0ST10		EQU	$
;;		RTL
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	DOKN0 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PLDKSX		EQU	$
		BYTE	000,000   ;,001,-01
PLDKSY		EQU	$
		BYTE	001,-01,000,000
;
;----------------------------------------
DOKN0MV		EQU	$
		JSR	ENSTCK          ; scroll : not return !
		LDA	ENCHPT,X
		JSL	>JSRSUB
		WORD	LINE0IT		;INT
		WORD	DOKN0M0		;STOP SERCH
		WORD	DOKN0M1		;? PL. ATARI
		WORD	DOKN0M2		;PL WALK
		WORD	DOKN0M3		;MOVE
		WORD	DOKN0M4		;PL WALK
;----------------------------------------
DOKN0M0		EQU	$
		JSR	LLBGRD		;bg chk.
		CMP	#0BEH		;? STOP
		BNE	DK0M010
		STA	ENWRK3,X	;unit save
		INC	ENCHPT,X
		LDA	ENMUKI,X
		EOR	#001H
		STA	ENMUKI,X
DK0M010		EQU	$
		CMP	ENWRK3,X
		BEQ	DK0M020
		STA	ENWRK3,X	;unit save
DK0M020		EQU	$
		LDA	ENMUKI,X	;MUKI SAVE
		STA	ENCMKI,X
		JSR	DOKN0SM		;muki kae & speed
;		JSR	LN0MKXY		;X Y HOSEI
		JSR	ENMVCL		; xclc,yclc !
		RTS
;----------------------------------------
DOKN0M1		EQU	$
		LDA	ENSTATS
		CMP	#0FFH
		BNE	DK0M110
;
		JSL	>CRENPL3L
		BCC	DK0M110
		PHX
		JSL	>DKHDCK
		PLX
		BCS	DK0M120
		INC	ENCHPT,X
		LDA	#004H		;WALK TIME
		STA	ENTIM1,X
		JSL	>PLYCLR1
		LDA	#001H
		STA	PYALSP
		STA	MRTKFG		;MUTEKI
		TXA
		STA	ENSTATS		;INDEX SAVE
;
DK0M110		EQU	$
		RTS
;
DK0M120		EQU	$
		JSR	EPATRBK
		RTS
;----------------------------------------
DK0M2DT		EQU	$
		BYTE	008H,004H,002H,001H
;
DOKN0M2		EQU	$		;WALK
		LDA	ENTIM1,X
		BNE	DK0M210
		INC	ENCHPT,X
		LDA	#OMS000		;PL. OBJ CLS
		STA	<OMSBMD
		RTS
;
DK0M210		EQU	$
		LDA	#001H
		STA	PYALSP
		STA	MRTKFG		;MUTEKI
		LDY	ENMUKI,X
		LDA	DK0M2DT,Y
		JSR	PLWALK
		RTS
;----------------------------------------
DOKN0M3		EQU	$
		LDA	#003H		;SPEED
		STA	ENCONT,X
;
		LDA	<PLXPS1		; X-pos hozon
		STA	<PLXHN0
		LDA	<PLXPS0
		STA	<PLXHN1
		LDA	<PLYPS1		; Y-pos hozon
		STA	<PLYHN0
		LDA	<PLYPS0
		STA	<PLYHN1
;
DK0M390		EQU	$
		INC	ENWRK0,X	;FRCNT (LINE0 SENYOU)
;
		LDA	ENWRK0,X	;HOSEI
		AND	#007H
		BNE	DK0M330
;
		JSR	LLBGRD		;bg chk.
		PHA
		CMP	#0B2H
		BCC	DK0M320 ;
;;;		BEQ	DK0M310
;;;		CMP	#0B3H
;;;		BEQ	DK0M310
;;;		CMP	#0B4H
;;;		BEQ	DK0M310
		CMP	#0B5H+1
;;;		BNE	DK0M320
		BCS	DK0M320 ;
DK0M310		EQU	$
		LDA	#0BH		;OTO
		JSL	>SDLRE2		;(S)
DK0M320		EQU	$
		PLA
		CMP	ENWRK3,X
		BEQ	DK0M330		;? unit !=
;					;Y
		STA	ENWRK3,X	;unit save
		CMP	#0BEH
		BNE	DK0M340
		INC	ENCHPT,X
		LDA	#018H		;WALK TIME
		STA	ENTIM1,X
DK0M340		EQU	$
;
		LDA	ENMUKI,X	;MUKI SAVE
		STA	ENCMKI,X
;
		JSR	DOKN0SM		;muki kae & speed
		JSR	LN0MKXY		;X Y HOSEI
;
DK0M330		EQU	$
		JSR	ENMVCL		; xclc,yclc !
;
		LDA	ENXPSL,X
		SEC
		SBC	#008H
		STA	<WORK0
		LDA	ENXPSH,X
		SBC	#000H
		STA	<WORK1
		LDA	ENYPSL,X
		SEC
		SBC	#00EH
		STA	<WORK2
		LDA	ENYPSH,X
		SBC	#000H
		STA	<WORK3
;
		MEM16
		IDX8
		REP	#00100000B
		LDA	<WORK0
		CMP	<PLXPS1
		BEQ	DK0M360
		BCS	DK0M350
		DEC	<PLXPS1
		BRA	DK0M360
DK0M350		EQU	$
		INC	<PLXPS1
DK0M360		EQU	$
		LDA	<WORK2
		CMP	<PLYPS1
		BEQ	DK0M380
		BCS	DK0M370
		DEC	<PLYPS1
		BRA	DK0M380
DK0M370		EQU	$
		INC	<PLYPS1
DK0M380		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		DEC	ENCONT,X
		BEQ	DK0M3A0
		JMP	DK0M390
;
DK0M3A0		EQU	$
		LDA	<PLXPS1
		SEC
		SBC	<PLXHN0
		STA	<PLXMVC
		LDA	<PLYPS1
		SEC
		SBC	<PLYHN0
		STA	<PLYMVC
;
		LDY	ENMUKI,X
		LDA	DK0M2DT,Y
		STA	<PLMUKI
		PHX
		JSL	>PYCRCN
		JSL	>PLOTCK1
		JSL	>DASCLR1
		PLX
;
		RTS
;----------------------------------------
DOKN0M4		EQU	$
		LDA	ENTIM1,X
		BNE	DK0M410
;
		STZ	PYALSP
		STZ	PSSTOP
		STZ	MRTKFG		;MUTEKI
		STZ	<OMSBMD
		STZ	<PLXMVC
		STZ	<PLYMVC
		LDA	#0FFH		;INDEX CLS
		STA	ENSTATS
		LDA	#002H
		STA	ENCHPT,X
		RTS
;
DK0M410		EQU	$
		LDA	ENMUKI,X
		EOR	#001H
		TAY
		LDA	DK0M2DT,Y
		JSR	PLWALK
		RTS
;----------------------------------------
;----------------------------------------
PLWALK		EQU	$
		PHX
		STA	<PWORK1		;PL. ARUKI
		STA	<PLMUKI
		JSL	>PYSPST
		JSL	>PYCRCN
		JSL	>PLOTCK1
		PLX
		RTS
;----------------------------------------
;
;
;
;
;
;
;
;
;
;
;
;
;
;DK0M1MK		EQU	$
;;
;DOKN0M1		EQU	$
;		LDA	ENTIM1,X
;		BNE	DK0M110
;		LDA	#001H
;		STA	ENCHPT,X
;		STZ	PYALSP
;		STZ	PSSTOP
;		STZ	MRTKFG		;MUTEKI
;		RTS
;DK0M110		EQU	$
;		JSL	>PLYCLR1
;		LDA	#001H
;		STA	PYALSP
;		STA	MRTKFG		;MUTEKI
;		LDY	ENMUKI,X
;		LDA	DK0M1MK,Y
;		JSL	>PLWALK
;		RTS
;;----------------------------------------
;DOKN000		EQU	$
;;
;		LDA	#0FFH
;		CMP	ENSTATS
;		BEQ	DOKN060
;		CPX	ENSTATS
;		BEQ	DOKN060
;		JMP	DOKN010
;DOKN060		EQU	$
;;
;;;;		MEM16
;;;;		IDX8
;;;;		REP	#00100000B
;;;;;
;;;;		LDA	ENXP2L
;;;;		SEC
;;;;		SBC	<PLXPS1
;;;;		CLC
;;;;		ADC	#00000H
;;;;		CMP	#00011H
;;;;		BCS	DOKN0A0
;;;;;
;;;;		LDA	ENYP2L
;;;;		SEC
;;;;		SBC	<PLYPS1
;;;;		CLC
;;;;		ADC	#00000H
;;;;		CMP	#00020H
;;;;		BCS	DOKN0A0
;;;;;
;;;;		MEM8
;;;;		IDX8
;;;;		SEP	#00110000B
;;;;		BRA	DOKN080
;;;;DOKN0A0		EQU	$
;;;;		MEM8
;;;;		IDX8
;;;;		SEP	#00110000B
;;;;		JMP	DOKN010		;? PL. TUCH
;;					;Y
;		LDA	ENTIM2,X
;		BNE	DOKN090
;		JSL	>CRENPL3L
;		BCS	DOKN080		;? PL. TUCH
;		JMP	DOKN010
;DOKN080		EQU	$
;		PHX
;		JSL	>DKHDCK
;		PLX
;		BCC	DOKN088
;		JSR	EPATRBK
;		RTS
;DOKN088		EQU	$
;		JSL	>DASCLR1
;;
;		LDA	#007H
;		STA	ENTIM2,X
;		LDA	ENTIM0,X
;		BNE	DOKN090
;		LDA	#008H
;		STA	ENTIM1,X
;		INC	ENCHPT,X
;		RTS
;DOKN090		EQU	$
;		LDA	#003H		;SPEED
;		STA	ENCONT,X
;;
;		LDA	#001H
;		STA	ENWRK2,X
;;
;		LDA	<PLXPS1		; X-pos hozon
;		STA	<PLXHN0
;		LDA	<PLXPS0
;		STA	<PLXHN1
;		LDA	<PLYPS1		; Y-pos hozon
;		STA	<PLYHN0
;		LDA	<PLYPS0
;		STA	<PLYHN1
;;
;DOKN050		EQU	$
;		LDA	ENSTAT,X
;		BEQ	DOKN070		;? STOP
;		JMP	DOKN020		;? STOP
;DOKN070		EQU	$
;;					;N
;		INC	ENWRK0,X	;FRCNT (LINE0 SENYOU)
;;
;		LDA	ENTIM1,X
;		BNE	DOKN075
;		LDA	#OMS000		;PL. OBJ CLS
;		STA	<OMSBMD
;DOKN075		EQU	$
;;
;		LDA	ENWRK0,X	;HOSEI
;		AND	#007H
;		BNE	DOKN030
;;
;		JSR	LLBGRD		;bg chk.
;		PHA
;		CMP	#0B2H
;		BEQ	DOKN073
;		CMP	#0B3H
;		BEQ	DOKN073
;		CMP	#0B4H
;		BEQ	DOKN073
;		CMP	#0B5H
;		BNE	DOKN072
;DOKN073		EQU	$
;;;		JSL	>SDLRCE		;OTO
;;;		ORA	#00BH
;;;		STA	SOUND2
;		LDA	#0BH
;		JSL	>SDLRE2	;(S)
;DOKN072		EQU	$
;		PLA
;		CMP	ENWRK3,X
;		BEQ	DOKN030		;? unit !=
;;					;Y
;		STA	ENWRK3,X	;unit save
;;
;		LDA	ENMUKI,X	;MUKI SAVE
;		STA	ENCMKI,X
;;
;		JSR	DOKN0SM		;muki kae & speed
;		JSR	LN0MKXY		;X Y HOSEI
;;
;DOKN030		EQU	$
;		JSR	ENMVCL		; xclc,yclc !
;;
;		LDA	ENXPSL,X
;		SEC
;		SBC	#008H
;		STA	<WORK0
;		LDA	ENXPSH,X
;		SBC	#000H
;		STA	<WORK1
;		LDA	ENYPSL,X
;		SEC
;		SBC	#00EH
;		STA	<WORK2
;		LDA	ENYPSH,X
;		SBC	#000H
;		STA	<WORK3
;;
;		MEM16
;		IDX8
;		REP	#00100000B
;		LDA	<WORK0
;		CMP	<PLXPS1
;		BEQ	DOKN0B0
;		BCS	DOKN0C0
;		DEC	<PLXPS1
;		BRA	DOKN0B0
;DOKN0C0		EQU	$
;		INC	<PLXPS1
;DOKN0B0		EQU	$
;		LDA	<WORK2
;		CMP	<PLYPS1
;		BEQ	DOKN0D0
;		BCS	DOKN0E0
;		DEC	<PLYPS1
;		BRA	DOKN0D0
;DOKN0E0		EQU	$
;		INC	<PLYPS1
;DOKN0D0		EQU	$
;		MEM8
;		IDX8
;		SEP	#00110000B
;;
;		DEC	ENCONT,X
;		LDA	ENCONT,X
;		BEQ	DOKN0D8
;		JMP	DOKN070
;DOKN0D8		EQU	$
;;
;		LDA	#001H		;PL. MODE
;		STA	PYALSP
;;
;		LDA	#003H
;		STA	ENTIM0,X
;;
;		TXA
;		STA	ENSTATS
;;
;		LDA	<PLXPS1
;		SEC
;		SBC	<PLXHN0
;		STA	<PLXMVC
;		LDA	<PLYPS1
;		SEC
;		SBC	<PLYHN0
;		STA	<PLYMVC
;;
;		LDY	ENMUKI,X
;		LDA	DK0M1MK,Y
;		STA	<PLMUKI
;		PHX
;		JSL	>PYCRCN
;		JSL	>PLOTCK1	;
;		JSL	>DASCLR1
;		PLX
;;
;		RTS
;;----------------------------------------
;DOKN010		EQU	$
;		LDA	ENWRK2,X
;		BEQ	DOKN040
;		STZ	PYALSP
;		STZ	<OMSBMD
;		STZ	<PLXMVC
;		STZ	<PLYMVC
;		STZ	ENWRK2,X
;		LDA	#0FFH
;		STA	ENSTATS
;DOKN040		EQU	$
;		LDA	#008H
;		STA	ENTIM1,X
;		LDA	#010H
;		STA	ENTIM0,X
;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	YOSEI move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
YOSEISZ		EQU	$
		BYTE	001,-001
YOSEIMJ		EQU	$
		PHB
		PHK
		PLB
		JSR	YOSEI00
		PLB
		RTL
YOSEI00		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDA	<DJFLG
		BEQ	YOSEI50			;? DANJON
;						;Y
		LDA	ENTIM1,X
		BNE	YOSEI50
;;		JSL	>ENBGCKL		; BG check sub !
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		AND	#003H
		BEQ	YOSEI40
;
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		LDA	ENMUKI,X
		EOR	#0FFH
		INC	A
		STA	ENMUKI,X
		LDA	#020H
		STA	ENTIM1,X
;
YOSEI40		EQU	$
		LDA	ENCBFG,X
		AND	#00CH
		BEQ	YOSEI50
;
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		LDA	ENWRK0,X
		EOR	#0FFH
		INC	A
		STA	ENWRK0,X
		LDA	#020H
		STA	ENTIM1,X
;
YOSEI50		EQU	$
		LDA	ENXSPD,X
		BEQ	YOSEI10
;
		BPL	YOSEI20
		LDA	ENCLOR,X
		AND	#0BFH
		BRA	YOSEI30
YOSEI20		EQU	$
		LDA	ENCLOR,X
		ORA	#040H
YOSEI30		EQU	$
		STA	ENCLOR,X
;
YOSEI10		EQU	$
;		LDA	ENSTAT,X
;		JSL	>JSRSUB
;		WORD	YOSEIM2
;		WORD	YOSEIM1
;		WORD	YOSEIM0
;----------------------------------------
YOSEIM0		EQU	$
		JSR	ENMVCL		;xclc,yclc
;
		LDA	<FRCNT
		AND	#03FH
		BNE	YSIM010
;
		JSL	>RNDSET		;LDA	<PLXPS1
		STA	<WORK4
		LDA	<PLXPS0
		STA	<WORK5
		JSL	>RNDSET		;LDA	<PLYPS1
		STA	<WORK6
		LDA	<PLYPS0
		STA	<WORK7
;
		LDA	#010H		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
;
		LDA	<WORK0		;SPEED SET
		STA	ENWRK0,X
		LDA	<WORK1
		STA	ENMUKI,X
;
YSIM010		EQU	$		;Y SPEED SET
		LDA	<FRCNT
		AND	#00FH
		BNE	YSIM080
;
		LDA	#0FFH
		STA	<WORK1		;YSPD = (YSPD + YSPDM)/2
		STA	<WORK3
		LDA	ENWRK0,X
		STA	<WORK0
		BMI	YSIM020
		STZ	<WORK1
YSIM020		EQU	$
		LDA	ENYSPD,X
		STA	<WORK2
		BMI	YSIM030
		STZ	<WORK3
YSIM030		EQU	$
		MEM16
		REP	#00100001B
;
		LDA	<WORK0
		ADC	<WORK2
		LSR	A
;
		MEM8
		SEP	#00110000B
		STA	ENYSPD,X
;
YSIM040		EQU	$		;X SPEED SET
		LDA	#0FFH
		STA	<WORK1		;XSPD =(XSPD+XSPDM)/2
		STA	<WORK3
		LDA	ENMUKI,X
		STA	<WORK0
		BMI	YSIM050
		STZ	<WORK1
YSIM050		EQU	$
		LDA	ENXSPD,X
		STA	<WORK2
		BMI	YSIM060
		STZ	<WORK3
YSIM060		EQU	$
		MEM16
		REP	#00100001B
;
		LDA	<WORK0
		ADC	<WORK2
		LSR	A
;
		MEM8
		SEP	#00110000B
		STA	ENXSPD,X
;
YSIM080		EQU	$
		JSR	ENZCLC		;zclc
;
		JSL	>RNDSET		;Z SPEED SET
		AND	#001H
		TAY
		LDA	YOSEISZ,Y
		CLC
		ADC	ENZSPD,X
		STA	ENZSPD,X
;
;		LDY	#000H		;Z POS
		LDA	ENZPSL,X	;Z CHK
;		BMI	YSIM070
		LDY	#008H		;Z POS
		CMP	#008H
		BCC	YSIM070
		LDY	#018H		;Z POS
		CMP	#018H
		BCC	YSIM090
;
		TYA
		STA	ENZPSL,X
		LDA	#0FBH
		STA	ENZSPD,X
YSIM090		EQU	$
		RTS
;
YSIM070		EQU	$
		TYA
		STA	ENZPSL,X
		LDA	#005H
		STA	ENZSPD,X
		RTS
;----------------------------------------
YOSEISTL	EQU	$		;PL. BIN USE
		LDA	#YOSEI
		JSL	>ENIDSH
		BMI	YSSTL10
;
		LDA	<PLBGCKF
		STA	ENKAIF,Y
;
		LDA	<PLXPS1
		CLC
		ADC	#008H
		STA	ENXPSL,Y
		LDA	<PLXPS0
		ADC	#000H
		STA	ENXPSH,Y
		LDA	<PLYPS1
		CLC
		ADC	#010H
		STA	ENYPSL,Y
		LDA	<PLYPS0
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	#000H
		STA	ENMUKI,Y
;
		LDA	#060H		;NOT TUCH TIME
		STA	ENTIM3,Y
;
YSSTL10		EQU	$
		RTL
;----------------------------------------
;--------------------------------------
;---------------------------------------
;---------------------------------------
;---------------------------------------
;---------------------------------------
EPXYCK		EQU	$
		JSL	>EPXYCK2
		RTS
;================================================================
EPXCHK		EQU	$
		JSL	>EPXCHK2
		RTS
;- - - - - - - -
;=================================================================
EPYCHK		EQU	$
		JSL	>EPYCHK2
		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
;=====================================================
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@		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
		JSR	ENBGCK
		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
;
		LDA	ENMYNO,X
		CMP	#SHSAI
		BEQ	ENHB90
;
		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 ?
 ;					; Yes !
;		LDA	HEMODE,X
;		CMP	#0FEH
;		BEQ	ENHB10
;;
 ;		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
;=========================================================
ENMVCL2		EQU	$
		JSR	ENZCLC
ENMVCL		EQU	$
;;;;;		LDA	ENHNFG,X
;;;;;		BNE	ENMC00
;
		JSR	ENXCLC
		JSR	ENYCLC
ENMC00		EQU	$
		RTS
;
ENXCLC		EQU	$
		TXA
		CLC
		ADC	#10H
		TAX
		JSR	ENYCLC
		LDX	ENINDX
		    RTS
;============================================
ENYCLC		EQU	    $
		LDA	ENYSPD,X
		BEQ	EYCRTS
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENYSDR,X
		STA	ENYSDR,X
;
		LDA	ENYSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDY	#00H
		PLP
		BPL	ENCY60
;
		ORA	#11110000B
		DEY
ENCY60		EQU	$
		ADC	ENYPSL,X
		STA	ENYPSL,X
;
		TYA
		ADC	ENYPSH,X
		STA	ENYPSH,X
EYCRTS		EQU	$
		RTS
;============================================
ENZCLC		EQU	    $
		LDA	ENZSPD,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENZSDR,X
		STA	ENZSDR,X
;
		LDA	ENZSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		PLP
		BPL	ENCZ60
;
		ORA	#11110000B
ENCZ60		EQU	$
		ADC	ENZPSL,X
		STA	ENZPSL,X
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
O2TEST		EQU	$	; oam set paramater set & display out check !
OAMCHK		EQU	$
		JSL	>OAMCHKL
		BCC	O2010
		PLA
		PLA
O2010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
;===============================================
ITMZST		EQU	$	; Item mizu in hamon set !
		LDA	>ENFRNO,X
		CMP	#08H
		BEQ	ITMZ10
		CMP	#09H
		BNE	ITMZ90	; mizu in ?
ITMZ10		EQU	$		; yes !
		LDA	ENMOD2,X
		AND	#00100000B
		BEQ	ITMZ20		; small size ?
		LDA	ENXP2L		; yes ! xpos rivise !
		SEC
		SBC	#04H
		STA	ENXP2L
		LDA	ENXP2H
		SBC	#00H
		STA	ENXP2H
;
		LDA	ENMYNO,X
		CMP	#TUBO1
		BNE	ITMZ20
;
		LDA	ENYP2L
		SEC
		SBC	#07H
		STA	ENYP2L
		LDA	ENYP2H
		SBC	#00H
		STA	ENYP2H
ITMZ20		EQU	$
		JSL	>MZSUB
		JSL	>PSSAVE2
;;		LDA	#04H*4
		LDA	ENMOD0,X
		AND	#1FH
		INC	A
		ASL	A
		ASL	A
		JSL	>OAMENT1
ITMZ90		EQU	$
;;		LDA	#00H
;;		STA	>ENFRNO,X
		RTL
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
;===============================================
		END
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MSGCHK		EQU	$
		STA	MSGENOL
		STZ	MSGENOH
;
		LDA	ENMOD0,X
		PHA
		LDA	#80H
		STA	ENMOD0,X
		LDA	ENMOD3,X
		PHA
		LDA	#07H
		STA	ENMOD3,X
		JSL	>CRENPL2L
		PLA
		STA	ENMOD3,X
		PLA
		STA	ENMOD0,X
		BCC	MSC010
;
		MEM16
		REP	#00100000B
;
		LDA	PLSVX1
		STA	<PLXPS1
		LDA	PLSVY1
		STA	<PLYPS1
;
		STZ	DASHFG
		STZ	<PYSPFG
;
		MEM8
		SEP	#00100000B
;
MSGSET		EQU	$
		STZ	!MSGEFG
		STZ	!INITAL
		LDA	#p3_msge
		STA	<GAMEMD
		LDA	<SLMODE
		STA	!NXSLMD
		LDA	#MD_etcpl
		STA	<SLMODE
MSC010		EQU	$
		RTL
;
;===========8 bits x 8 bits=========
		LDA	#00H
		STA	<WORK2
		STA	<WORK8
		STA	<WORK9
;
		LDY	#07H
QQWW		EQU	$
		LSR	<WORK0
		BCC	QQS
;
		LDA	<WORK1
		CLC
		ADC	<WORK8
		STA	<WORK8
		LDA	<WORK2
		ADC	<WORK9
		STA	<WORK9
QQS		EQU	$
		ASL	<WORK1
		ROL	<WORK2
;
		DEY
		BPL	QQWW		
;
		NOP
		NOP
		NOP
		NOP
		NOP
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		Motos big Big		    %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MOTSBMV		EQU	$
		JSR	MOTSBCS
;
		JSR	ENSTCK
;;		JSR	ENHNSB
;
		JSR	MBEYEST
;- - ken Tate check - -
		LDA	#16H
		STA	ENMOD3,X
		LDA	ENMOD2,X
		PHA
		ORA	#01000000B
		STA	ENMOD2,X
		LDA	#00000100B
		STA	ENMOD5,X
		JSL	>CRKNENL
;
		PLA
		STA	ENMOD2,X
		INC	ENMOD3,X
		STZ	ENMOD5,X
;
		LDA	FLMODE
		BNE	MB0000
;- - ken Body check - -
		JSL	>CRKNENL
;- - Player body check - -
MB0000		EQU	$
;;		LDA	#18H
		INC	ENMOD3,X
		JSR	CRENPL
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MBWAIT
		WORD	MBSTOP
		WORD	MBWALK
		WORD	MBATCK
;-----Eye set & Tail fulifuri-----------------------------------------------
MESPTD		EQU	$
		HEX	1,2,3,3,3,3,3,2
MBTLAD		EQU	$
		HEX	01,FF
MBTLLM		EQU	$
		HEX	06,00
;
MBEYEST		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#07H
		TAY
		LDA	MESPTD,Y
		STA	ENWRK0,X
;
		LDA	<FRCNT
		AND	#03H
		ORA	ENTIM3,X
		BNE	MBTS10
;
		LDA	ENMUKI,X
		AND	#01H
		TAY
		LDA	ENWRK2,X
		CLC
		ADC	MBTLAD,Y
		STA	ENWRK2,X
		CMP	MBTLLM,Y
		BNE	MBTS10
		INC	ENMUKI,X
		LDA	#0CH
		STA	ENTIM3,X
MBTS10		EQU	$		
		RTS
;===========================================================
MBWAIT		EQU	$
		LDA	ENTIM0,X
		BNE	MBWI10
;
		INC	ENSTAT,X
MBWI10		EQU	$
		RTS
;===========================================================
MBWKXS		EQU	$
		HEX	00,0C,10,0C,00,F4,F0,F4
MBWKYS		EQU	$
		HEX	F0,F4,00,0C,10,0C,00,F4
;
MBSTOP		EQU	$
		LDA	#02H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	MBS010
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#7FH
		ORA	#40H
		STA	ENTIM0,X		
		AND	#07H
		TAY
		LDA	MBWKXS,Y
		STA	ENXSPD,X
		LDA	MBWKYS,Y
		STA	ENYSPD,X
		RTS
MBS010		EQU	$
;XYSDCL		EQU	$
;		STZ	ENXSPD,X
;		STZ	ENYSPD,X
		RTS
;===========================================================
MBWXLM		EQU	$
		HEX	B8,38
MBWYLM		EQU	$
		HEX	70,44
MBWKPT		EQU	$
		HEX	0,1
;
MBWALK		EQU	$
		LDA	ENTIM0,X
		BNE	MBWK10
;
		INC	ENCTFG,X
		LDA	ENCTFG,X
		CMP	#02H
		BNE	MBWK08		; Atack time ?
;					; yes !
		STZ	ENCTFG,X
		INC	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
		BRA	MBWK10
MBWK08		EQU	$
		DEC	ENSTAT,X
		LDA	#30H
		STA	ENTIM0,X
MBWK10		EQU	$
; - - Move limit check - - -
		LDY	#00H
		LDA	ENXSPD,X
		BPL	MBWK18
		INY
MBWK18		EQU	$
		LDA	ENXPSL,X
		CMP	MBWXLM,Y
		BNE	MBWK20
;
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
		JSR	ENXCLC
		JSR	ENXCLC
		LDA	#20H
		STA	ENTIM0,X
MBWK20		EQU	$
		LDY	#00H
		LDA	ENYSPD,X
		BPL	MBWK28
		INY
MBWK28		EQU	$
		LDA	ENYPSL,X
		CMP	MBWYLM,Y
		BNE	MBWK30
;
		LDA	ENYSPD,X
		EOR	#0FFH
		INC	A
		STA	ENYSPD,X
		JSR	ENYCLC
		JSR	ENYCLC
		LDA	#20H
		STA	ENTIM0,X
MBWK30		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#01H
		TAY
		LDA	MBWKPT,Y
		STA	ENCHPT,X
		JSR	ENMVCL
;
		RTS
;===========================================================
MBATPT		EQU	$
		HEX	0,0,0,0,0,0,1,2
		HEX	3,4,4,4,4,4,4,4
		HEX	4,4,4,4,4,3,2,1
		HEX	0,0,0,0,0,0,0,0
;- - - - - -
MBATCK		EQU	$
		LDA	#02H
		STA	ENCHPT,X
		LDA	ENTIM0,X
		BNE	MBA010
;
		LDA	#01H
		STA	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
		RTS
;- - - - - - - - -
MBA010		EQU	$
		CMP	#80H
		BNE	MBA020
		PHA
		JSR	MOTAMST
		PLA
MBA020		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	MBATPT,Y
		STA	ENWRK1,X
		RTS
;===========================================================
MOTAMST		EQU	$
		LDA	#MOTAM
		JSL	>ENIDSH
		BMI	MS0010
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#18H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#00H
		STA	ENYPSH,Y		
;
		LDA	#20H
		STA	ENTIM0,Y
MS0010		EQU	$
		RTS
;===========================================================
;===========================================================
;===========================================================
;===========================================================
;===========================================================
;===========================================================
;===========================================================
;----------------------------------------------------
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	MBM010
;;;
;;		INC	ENCHPT,X
;;;
;;		LDA	ENCHPT,X
;;		CMP	#03H
;;		BNE	MBM010
;;;
;;		STZ	ENCHPT,X
;;MBM010		EQU	$
;;		LDA	<KEYA2
;;		AND	#01H
;;		BEQ	MBM020
;;;
;;		INC	ENWRK0,X
;;;
;;		LDA	ENWRK0,X
;;		CMP	#04H
;;		BNE	MBM020
;;;
;;		STZ	ENWRK0,X
;;MBM020		EQU	$
;;		LDA	<KEYA2
;;		AND	#04H
;;		BEQ	MBM030
;;;
;;		INC	ENWRK2,X
;;;
;;		LDA	ENWRK2,X
;;		CMP	#07H
;;		BNE	MBM030
;;;
;;		STZ	ENWRK2,X
;;MBM030		EQU	$
;;		LDA	<KEYA2
;;		AND	#02H
;;		BEQ	MBM050
;;;
;;		INC	ENWRK1,X
;;;
;;		LDA	ENWRK1,X
;;		CMP	#05H
;;		BNE	MBM050
;;;
;;		STZ	ENWRK1,X
;;MBM050		EQU	$
;;		RTS
;================================================
MBCXAD		EQU	$
		WORD	0FFE8H,0FFF8H,00008H,00018H
		WORD	0FFE8H,0FFF8H,00008H,00018H
		WORD	0FFE8H,0FFF8H,00008H,00018H
MBCYAD		EQU	$
		WORD	0FFF0H,0FFF0H,0FFF0H,0FFF0H
		WORD	00000H,00000H,00000H,00000H
		WORD	00010H,00010H,00010H,00010H
MBCCDT		EQU	$
;0
		HEX	C0,C2,C2,C4
		HEX	E0,E2,E2,E4
		HEX	C8,CA,EA,E8
;1
		HEX	C4,C2,C2,C0
		HEX	E4,E2,E2,E0
		HEX	E8,EA,CA,C8
;2
		HEX	C0,C2,C2,C0
		HEX	E0,E2,E2,E0
		HEX	C8,CA,CA,C8
MBCADT		EQU	$
		HEX	00,00,40,40
		HEX	00,00,40,40
		HEX	00,00,40,40
; - - Eye data - -
MECXAD		EQU	$
		WORD	0FFFDH,0000BH
MECCDT		EQU	$
		HEX	EC,ED,FC
MECADT		EQU	$
		HEX	3B,7B
;- - Kuchi data - - 
MKCIDT		EQU	$
		HEX	58,58,58,24
MKCYAD		EQU	$
		HEX	15,16,17,18
;- - Tail  data - - 
MTCXAD		EQU	$
		WORD	000H,003H,009H,010H,018H	;0
		WORD	000H,002H,007H,00DH,014H	;1
		WORD	000H,001H,004H,009H,00FH	;2
		WORD	000H,000H,000H,000H,000H	;3
		WORD	-00H,-01H,-04H,-09H,-0FH	;4
		WORD	-00H,-02H,-07H,-0DH,-14H	;5
		WORD	-00H,-03H,-09H,-10H,-18H	;6
MTCYAD		EQU	$
		WORD	018H,020H,025H,025H,021H	;0
		WORD	018H,020H,027H,02AH,02CH	;1
		WORD	018H,020H,028H,02FH,034H	;2
		WORD	018H,021H,02AH,034H,03DH	;3
		WORD	018H,020H,028H,02FH,034H	;4
		WORD	018H,020H,027H,02AH,02CH	;5
		WORD	018H,020H,025H,025H,021H	;6
;
MTCCDT		EQU	$
		HEX	C6,C6,C6,C6,E6
;-------------------------------------------------
MOTSBCS		EQU	$
		JSR	OAMCHK
;
		LDA	ENWRK0,X
		STA	<WORK8		; Eye
		LDA	ENWRK1,X
		STA	<WORK9		; Kushi
		LDA	ENWRK2,X
		STA	<WORKA		; Tail
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORK6
		ASL	A
		ADC	<WORK6
		STA	<WORK6
;
		PHX
		LDX	#11
MBC010		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	MBCXAD,X
		STA	OAM+128H,Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	MBCYAD,X
		INY
		STA	OAM+128H,Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	MBC020
		LDA	#0F0H
		STA	OAM+128H,Y
MBC020		EQU	$
		PLA
		PHA
		CLC
		ADC	<WORK6
		TAX
		LDA	MBCCDT,X
		INY
		STA	OAM+128H,Y
		PLX
		LDA	MBCADT,X
		ORA	<WORK5
		INY
		STA	OAM+128H,Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	OAMSB+128H/4,Y
		PLY
		INY
		DEX
		BPL	MBC010
;- - - Eyes set - - -
		LDA	<WORK8
		BEQ	MEC050
		LDY	#00H
		LDX	#01H
MEC010		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	MECXAD,X
		STA	OAM+11CH,Y		
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	#0011H
		INY
		STA	OAM+11CH,Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	MEC020
		LDA	#0F0H
		STA	OAM+11CH,Y
MEC020		EQU	$
		LDX	<WORK8
		LDA	MECCDT-1,X
		INY
		STA	OAM+11CH,Y
		PLX
		LDA	MECADT,X
		INY
		STA	OAM+11CH,Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#00H
		ORA	<WORKF
		STA	OAMSB+11CH/4,Y
		PLY
		INY
		DEX
		BPL	MEC010		
MEC050		EQU	$
;- - - Kuchi set - - -
		LDX	<WORK9
		BEQ	MKC050
;
		LDY	MKCIDT-1,X
		LDA	<WORK0
		STA	OAM+100H,Y
		LDA	<WORK2
		CLC
		ADC	MKCYAD-1,X
		STA	OAM+101H,Y
		LDA	#0CCH
		STA	OAM+102H,Y
		LDA	<WORK5
		STA	OAM+103H,Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORK1
		AND	#01H
		ORA	#02H
		STA	OAMSB+100H/4,Y		
MKC050		EQU	$
;- - - - Tail set - - -
		LDA	<WORKA
		ASL	A
		ASL	A
		ADC	<WORKA
		STA	<WORK6
;
		LDY	#00H
;
		LDX	#00H
MTC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		ASL	A
		TAX
		MEM16
		REP	#20H
;
		LDA	<WORK0
		CLC
		ADC	MTCXAD,X
		STA	OAM+15CH,Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		SEC
		SBC	MTCYAD,X
		INY
		STA	OAM+15CH,Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	MTC020	
;	
		LDA	#0F0H
		STA	OAM+15CH,Y
MTC020		EQU	$
		PLX
		LDA	MTCCDT,X
		INY
		STA	OAM+15CH,Y
		LDA	<WORK5
		INY
		STA	OAM+15CH,Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	OAMSB+15CH/4,Y
		PLY
		INY
		INX
		CPX	#05H
		BNE	MTC010
;
;
;
;
;
;
		PLX
		RTS
