
;
;
        	INCLUDE	zel_ram.asm
;
;--------------------------------------------------------------------
;
;		ZELDA-3		1991.05.23(THU)
;
;--------------------------------------------------------------------
;
		ORG	058000H
;
;=============================================== (zel_enmy2) ===========
		GLB	EVCHCKE,ENXSDN,ENYSDN,ENMSG2L,ENMSGEL,ENMSGSL
		GLB	SETOAML,ENMKIST,MSGSET,HEIS0CS2,ASIMZST,ICEF2ST
;----------------------------------------
		GLB	NOPPOMV,PLHIKMV,PLHINMV,ONNAAMV,HIGEEMV,MAJOOMV,HIGEEIT
		GLB	KIANAMV,DEMONMV,BOOK0MV,KEMRIST,YASANIT     
		GLB	TKBOYMV,ESW02MV,SETOAML2,ENSDMV,MIZUSTL
		GLB	BABA1MV,BABA1IT,JITONIT,JITONMV,BSITEM,SETOAML22
		GLB	BARI0MV,HEIS0MV,H0SER00L
		GLB	MZSUB		;;,BRSDRS
;		GLB	PSW01IT,PSW02IT,PINT1IT,MONORIT
;		GLB	PSW01MV,PSW02MV,PINT1MV,MONORMV
		GLB	MONORIT,MONORMV
		GLB	OYAGIMV,OYAGIIT,ONNAAIT
		GLB	BOUSIIT,BOUSIMV,SYOBYIT,SYOBYMV,HELP0IT,HELP0MV
		GLB 	RANEMIT
		GLB 	KINOKIT,KINOKMV,SUKASIT,SUKASMV,MJSY1IT,MJSY1MV
		GLB 	UTUWAIT,UTUWAMV,JOHBBIT,JOHBBMV
		GLB 	UTUBKIT,UTUBKMV,MJSY1CS
;-- DATA --
		GLB	KOMXSD,KOMYSD
;=============================================== (zel_enmy5) ============
		EXT	ASZNZST,BABA1CS,R100,BABACK,YABAACK,YABAAST
;=============================================== (zel_enmy4) ============
		EXT	MKCK16,HIMITU
;=============================================== (zel_enmy3) ============
		EXT	BINCHKL,RNTAMST
;=============================================== (zel_enmy) ============
		EXT	EPXYCK2,EPXCHK2,EPYCHK2,ENIDSH2,PSERC2L
		EXT	EICE,EMOVE,RNDSET,BGDTRD2,ENDMST2,CROJCK2,ENCRST2,BIKRST2
		EXT	ENBGCKL,CRENPLL,CRKNKNL,CRKNENL,OCHECKL,ENCLER
		EXT	ALOMCKL,ENIDSH,SADWSTL,SADWS2L,CRENPL2L,CRENPL3L,OAMENT3,OAMENT1
		EXT	PSERCHL,EN1CSTL,ESERCHL,SSERCH2,CACHCKL,ENBDSBL,PSSAVE2
		EXT	ENENSET,EN1CSSL,OAMENT2,EFLSST,ENDMST3,EHOLE,OAMCHKL
		EXT	EFLSST2,EN12CSL,USFAILL
;--- enmyno --
		EXT	SKHED,SPARL,ATARS,BARI1,ZORAB,CTBOS,HINO0
		EXT	OCTA1,OCTA2,OCTA3,NYORO,OCTBL,OCTSS
		EXT	TARUH,TARUV,BYOYN
		EXT	KWAUS,KWAU1,SHIGE,SARU1,SEKZ4,PONPK
		EXT	REBA1,ZOOL1
		EXT	JIJII,BABAA,HEITI,PENKI,NOKOG,KUTUU,GAKII,GAKI1
		EXT	NOPPO,PLHIK,PLHIN,ONNAA,HIGEE,MAJOO,PLCHK,KIANA,BUBUU
		EXT	YATAM,DEMON,BOOK0,TKBOY,LINE0,LINE1,LINE2,LINE3,BABA1,ESW03,HEIS0,HEI00
		EXT	TAIHO,HEIS1,HEYA0,HEYA1,HEYA2,KTOBJ,HEIS2,NEZU0,HEBI0
		EXT	KOMO0,MONOR,HEBO0,OYAGI,ZAKO0
		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,UTUBK,ARI00,ARI01
		EXT	JOHBB,MOTAM,YASAN,IWAGO
;--------------
		EXT	HEIT1
;-------------- item
                EXT     HART1,RUPYR,RUPYY,RUPYB,BOMB1,BOMB2,BOMB3 
                EXT     TUBO1,TUBO2       
                EXT     YAAA1,YAAA2,YOSEI
;--------------
		EXT	HART1,PORT1,PORT2
		EXT	ESET0,ESET1,ESET2
		EXT	EFAIL,ECACH,EWATR,EBAKU
;=============================================== (zel_endt) ============
									
		EXT	EXSTRA,ENEMY2,ENBTON,EFLCHK,ENCLST
		EXT	SINDT2,ZSZNZST,HEICAL,ENIDPS,ENMDST,OOTSUC2
;=============================================== (zel_main) ============
;		EXT	DTSAVE
		EXT	GDCHCK,JSRSUB,spoj5
;
		EXT	MD_title,MD_djint,MD_djply,MD_gdint,MD_gdply
		EXT	MD_fdout,MD_fdin,MD_etcpl
		EXT	MD_wpout,MD_wpin
;=============================================== (zel_play) ============
		EXT 	DASCLR1,DASHON,DOKAST
		EXT 	EATSET,TKDINT
		EXT 	YAMOV,TKDOW
		EXT	YAIMIT,ITMCBFST
		EXT	ATMSIT,PLOTCK
		EXT	p2_kage,TRFS
		EXT	mesm1,OTIM,LNMD,OPNG,JMDM
		EXT	WAPMV
		EXT	MNSRIT,MNBBIT
		EXT	WPMSCK
;///////		EXT	RDCHCK
;=============================================== (zel_bg3) =============
		EXT	MTRSUB,ITEM0ST
;=============================================== (grnd) =============
		EXT	MKDRPLY
;=============================================== (zel_init) =============
		EXT	p3_msge,MD_endg1
		EXT	MPBTSET1,ROBJCST
;================================================(enmy4)=================
		EXT	MOTAMMVJ,NMSHJP,HIREST,HBBKST,BARI1MV,NZMZSTL
;================================================(enmy3)=================
		EXT	ENPLATR
;================================================(end2)=================
		EXT	GRNDCHK,SDLRCE,SHBGCK,Z2TMSTL,YASANCS,SDLRE1,SDLRE2,SDLRE3
		EXT	HELP0CS,BAKU0CS,MONORCS,SINPUCS,OYAGICS
;================================================(char)=================
		EXT	OPTCBFST,THCGCN0,THCGCN1,THCGCN2
;================================================(endt)=================
		EXT	DEMBMMV
		EXT 	GRENST,EST0SB
		EXT 	DEMBMST,KEMR1ST,KEMR2ST
;================================================(sub0)=================
		EXT	DIECSET
;================================================(exst)=================
                EXT     BEAM1,BEAM2,BUME1,BOMBM,YAMOV,DTMOV     ;;;;,BOMBR
                EXT     DTMV1,DTMV2,OPMOV,WTMV0,HIBA2,SCPMV,DTMV3
                EXT     RAOPIT,RAOPIT1,ATMSIT,OTIM,SODMV,SNDINT,BOGN,KNSP
                EXT     SPBMV,SPBMINT,KONMV,TPHDIT
		EXT	nashi,prnce,jjmov,jjwat,jjsmv,mesmv,babaa,kajy1
		EXT	kajya,hnoji
;================================================(?)=================
		EXT	UGGILWT
;================================================(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
;=============================================================
IF2SXL		EQU	$
IF2SYL		EQU	$
		HEX	FC,00,04,08
IF2SXH		EQU	$
IF2SYH		EQU	$
		HEX	FF,00,00,00
;=====================================================
ICEF2ST		EQU	$
		LDA	<FRCNT
		AND	#03H
		BNE	IF2S30
;	
		PHX
		TXY
;
		JSL	>RNDSET
		AND	#03H
		TAX
		LDA	>IF2SXL,X
		STA	<WORK0
		LDA	>IF2SXH,X
		STA	<WORK1
;
		JSL	>RNDSET
		AND	#03H
		TAX
		LDA	>IF2SXL,X
		STA	<WORK2
		LDA	>IF2SYH,X
		STA	<WORK3
;
		LDX	#E2NO-1
IF2S10		EQU	$
		LDA	>E2MODE,X
		BEQ	IF2S20
		DEX
		BPL	IF2S10
;
		INX
;- - - - - - - - - - - - - - - - - - - - - -
IF2S20		EQU	$
		LDA	#12H
		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	; ZPSL:10H
		CLC
		ADC	<WORK2
		STA	>E2YPSL,X
		LDA	ENYPSH,Y
		ADC	<WORK3
		STA	>E2YPSH,X
;
		TYA
		STA	>E2STAT,X
		LDA	#0FH
		STA	>E2TIM0,X
;
		TXY
		PLX
IF2S30		EQU	$
		RTL
;=============================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	        Big motos tama                 		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MOTAMM		EQU	$
		JSL	>MOTAMMVJ
		RTS
;=================================================
;=================================================
;=================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HODXSD		EQU	$
		HEX	00,00  ;;,F0,10
HODYSD		EQU	$
		HEX	F0,10  ;,00,00
HODPTD		EQU	$
		HEX	00,00,02,02
HODMKD		EQU	$
		HEX	40,00,00,80
;
HODIRM		EQU	$
HODILM		EQU	$
HODIDM		EQU	$
HODIUM		EQU	$
		LDY	ENMUKI,X
		LDA	ENTIM2,X
		CMP	#01H
		LDA	HODPTD,Y
		ADC	#00H
		STA	ENCHPT,X
;
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	HODMKD,Y
		STA	ENCLOR,X
;
		JSL	>EN1CSTL
		JSR	ENSTCK
;
		LDA	ENTIM0,X
		BNE	HOD010
;
		LDA	#80H
		STA	ENTIM0,X
;
		LDA	ENWRK0,X
		EOR	#01H
		STA	ENWRK0,X
HOD010		EQU	$				
		LDY	ENWRK0,X
		LDA	HODXSD,Y
		STA	ENXSPD,X
		LDA	HODYSD,Y
		STA	ENYSPD,X
		JSR	ENMVCL
;
		TXA
		ASL	A
		ASL	A
;;		ASL	A
;;		ASL	A
		CLC
		ADC	<FRCNT
		AND	#1FH
		BNE	HOD090
;
;		JSR	HODISET
;;		JSR	EPXYCK
;;		LDA	<WORKE
;;		CLC
;;		ADC	#20H
;;		CMP	#40H
;;		BCS	HOD030
;;		LDA	<WORKF
;;		CLC
;;		ADC	#20H
;;		CMP	#40H
;;		BCC	HOD090
;;;
;;HOD030		EQU	$
;;		LDA	<WORKF
;;		LDY	ENMUKI,X
;;		CPY	#02H
;;		BCS	HOD040
;;		LDA	<WORKE
;;HOD040		EQU	$
;;		CLC
;;		ADC	#10H
;;		CMP	#20H
;;		BCS	HOD050
;;;
;;		LDA	ENTIM2,X
;;		BNE	HOD050
		LDA	#10H
		STA	ENTIM2,X
;;HOD050		EQU	$
HOD090		EQU	$
		LDA	ENTIM2,X
		CMP	#01H
		BEQ	HOD098		; tama set ?
		RTS
;======
HOD098		EQU	$		; yes !
HODISET		EQU	$
		LDA	ENDSPL,X
		BNE	HTS030
;
		LDA	#TAIHO
		LDY	#0DH
		JSL	>ENIDSH2
		BMI	HTS030
;
;;		JSL	>SDLRCE
;;		ORA	#07H
;;		STA	SOUND3	;(S)
		LDA	#07H
		JSL	>SDLRE3	;(S)
;
		LDA	#01H
		STA	ENWRK2,Y
		STA	ENCHPT,Y
;
		LDA	ENMUKI,X
		PHX
		TAX
                LDA     <WORK0
		CLC
		ADC	HTSXAL,X
                STA     ENXPSL,Y
                LDA     <WORK1
		ADC	HTSXAH,X
                STA     ENXPSH,Y
                LDA     <WORK2
		CLC
		ADC	HTSYAL,X
                STA     ENYPSL,Y
                LDA     <WORK3
		ADC	HTSYAH,X
		STA	ENYPSH,Y
		LDA	HTSXSD,X
		STA	ENXSPD,Y
		LDA	HTSYSD,X
		STA	ENYSPD,Y
;
         	LDA	ENMOD0,Y
		AND	#11110000B
		ORA	#00000001B
		STA	ENMOD0,Y
		LDA	ENMOD2,Y
		ORA	#01000111B
		STA	ENMOD2,Y
		LDA	ENMOD5,Y
		ORA	#01000100B
		STA	ENMOD5,Y
;
		LDA	#20H
		STA	ENTIM0,Y
;
		PLX
HTS030		EQU	$
;- - - KEMRI SET - - - - 
;		LDA	#TAIHO
;		JSL	>ENIDSH
;		BMI	HTS040
;
;		LDA	#20H
;		STA	ENTIM0,Y
;
;		LDA	#02H
;		STA	ENWRK2,Y
;
;		LDA	ENMUKI,X
;		PHX
;		TAX
;               LDA     <WORK0
;		CLC
;		ADC	HTSXAL,X
;               STA     ENXPSL,Y
;                LDA     <WORK1
;		ADC	HTSXAH,X
;               STA     ENXPSH,Y
;                LDA     <WORK2
;		CLC
;		ADC	HTSYAL,X
;               STA     ENYPSL,Y
;                LDA     <WORK3
;		ADC	HTSYAH,X
;		STA	ENYPSH,Y
;
;         	LDA	ENMOD0,Y
;		AND	#11110000B
;		ORA	#00000100B
;		STA	ENMOD0,Y
;		LDA	ENMOD2,Y
;		ORA	#01000111B
;		STA	ENMOD2,Y
;		PLX
HTS040		EQU	$
HOD0A0		EQU	$
		RTS
;
HTSXAL		EQU	$
		BYTE	008H,0F8H,000H,000H
HTSXAH		EQU	$
		BYTE	000H,0FFH,000H,000H
HTSYAL		EQU	$
		BYTE	000H,000H,008H,0F8H
HTSYAH		EQU	$
		BYTE	000H,000H,000H,0FFH
HTSXSD		EQU	$
		BYTE	018H,0E8H,000H,000H
HTSYSD		EQU	$
		BYTE	000H,000H,018H,0E8H
;- - -- - - - -
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;- - - - - - - - - - - - - - - - - -
YASXDT		EQU	$
		HEX	0,40,80,C0   
		HEX	30,60,90,C0      
YASYDT		EQU	$
		HEX	0,4F,4F,4F   
		HEX	5A,5A,5A,5A      
;;		HEX	5C,5C,5C,5C      
YASMDT		EQU	$	; mode
		HEX	0,01,01,01   
		HEX	02,02,02,02      
YASXSD		EQU	$	; initiak x speed
		HEX	F8,0C
YASCRD		EQU	$	; cross data
		HEX	1C,15
;;YASCLD		EQU	$	; color data
;;		HEX	0D,0D
;
YASANIT		EQU	$
		PHB
		PHK
		PLB
;
		STZ	YAHTCT		; YA hit count reset !
;
;;		INC	ENNOCR,X
;
		LDA	ENYPSL,X
		SBC	#08H
		STA	ENYPSL,X
;
		PHX
		LDX	#YASYDT-YASXDT-1
YAS010		EQU	$
		LDA	#YASAN
		STA	ENMYNO,X
		LDA	#EMOVE
		STA	ENMODE,X
;
		JSL	>ENMDST
;
		LDA	<PLXPS0
		STA	ENXPSH,X
		LDA	YASXDT,X
		STA	ENXPSL,X		
		LDA	<PLYPS0
		STA	ENYPSH,X
		LDA	YASYDT,X
		STA	ENYPSL,X
		LDA	YASMDT,X
		STA	ENWRK0,X
		DEC	A
		STA	ENCHPT,X
		TAY
		LDA	YASXSD,Y
		STA	ENXSPD,X
		LDA	YASCRD,Y
		STA	ENMOD3,X
;;		LDA	YASCLD,Y
		LDA	#0DH
		STA	ENCLOR,X
		LDA	<PLBGCKF
		STA	ENKAIF,X
		JSL	>RNDSET
		STA	ENCONT,X
		DEX
		BNE	YAS010
		PLX
		INC	ENNOCR,X
;
		LDA	>ARWCNT
		STA	HEMODE,X	; Ya cont save !!
;
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
YASANM		EQU	$
		LDA	HEMODE,X
		STA	>ARWCNT		; Ya not dec !
;
		LDA	ENWRK0,X
		JSL	>JSRSUB
		WORD	YASANMV
		WORD	TAKOSMV
		WORD	HANDSMV
;====== Ossan move =========
YSPTDT		EQU	$
		HEX	3,4,3,2
;- - - - - - - - - - - - - -
YASANMV		EQU	$
		LDA	YAAACT
		BNE	YS00F0
;
		INC	YAAOFF		; ya not shot !!
YS00F0		EQU	$
;;		LDA	#01H
;;		STA	ENNOCR,X	; zel_enmy
;
		JSL	>YASANCS
		JSR	ENSTCK
;
		LDA	#00000000B
		STA	ENMOD3,X
		JSL	>CRENPL2L
		BCC	YS0210
;
		JSL	>PLOTCK		;PL. POS. recover
		STZ	<PYSPFG		;DASH STOP
		JSL	>DASCLR1
;
YS0210		EQU	$
		LDA	ENTIM0,X
		BEQ	YS0010		
		AND	#07H
		BNE	YS00F2
;
;;		JSL	>SDLRCE
;;		ORA	#21H
;;		STA	SOUND2	;(S)
;
		LDA	#11H
		JSL	>SDLRE2	;(S)
YS00F2		EQU	$
		LDA	ENTIM0,X
		AND	#00000100B	; Dod don !!!!!
		LSR	A
		LSR	A
		BRA	YS0009
;;		STA	ENCHPT,X
;;		RTS
;- - - - - - - - - - - - - - - - - - - - - -
YS0010		EQU	$
		LDA	ENSTAT,X
		BEQ	YS0008		
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
;;		HEX	EA,EA,EA
		AND	#03H
YS0008		EQU	$
		TAY
		LDA	YSPTDT,Y
YS0009		EQU	$
		STA	ENCHPT,X
;
		LDA	ENSTAT,X
		CMP	#02H
		BEQ	YS0090
		CMP	#01H
		BEQ	YS0030
		CMP	#03H
		BNE	YS0200
;
		LDA	MSG_RTS
		BNE	YS0050		; Tutukeru ?
;					; Yes ! money check !
		LDA	#01H
		STA	ENSTAT,X
;
		BRA	CONTINU
;
;-------------------------------------------
YS0200		EQU	$
		LDA	#00001010B
		STA	ENMOD3,X
		JSL	>CRENPL2L
		BCC	YS0020
;
		LDA	<KEYA2L
;		AND	#10000000B
		BPL	YS0020
;
		LDA	#MS_0130
		JSR	YSMSST
;
		INC	ENSTAT,X		
YS0020		EQU	$
		RTS				
;- - - - - - - - - - - - - - - - - - - - - - - -
YS0030		EQU	$
		LDA	MSG_RTS
		BNE	YS0050		; Yes !
;
CONTINU		EQU	$
		MEM16
		REP	#00100000B
		LDA	>CONCNT
		CMP	#0020 
		MEM8
		SEP	#00100000B
		BCC	YS0070		; Have money ?
;					; yes !
		STZ	ENKBMK,X
		STZ	YAHTCT
;
		INC	ENSTAT,X
;
		LDA	#MS_0131
		BRA	YSMSST
;
YS0050		EQU	$
		STZ	ENSTAT,X	; No !
;
		LDA	#MS_0132
YSMSST		EQU	$
		STA	MSGENOL
		STZ	MSGENOH
		JSL	>MSGSET
		STZ	ENTIM0,X
		RTS
;-------------------------------------------
YS0070		EQU	$
		STZ	ENSTAT,X	; No !
;
		LDA	#MS_0132	; shibakuzoo !!!!!!!	
;;		LDA	#MS_0133	; shibakuzoo !!!!!!!	
		BRA	YSMSST
;-------------------------------------------
;-- YA count display --
YS0090		EQU	$
		LDA	ENKBMK,X
		BNE	YD0000
;
		LDA	#05H
		STA	YAAACT		; count set !
;
		LDA	#02H
		JSL	>DOKAST
;;		STA	DOKATA		; Muriyari YA select !
;
		LDA	#27H
		STA	ENTIM1,X
;
;;		LDA	#05H
;;              STA     >UPAWCT		 ;Main ya count inc !
;
		MEM16
		REP	#20H
		LDA	>CONCNT
		SEC
		SBC	#0020 
		STA	>CONCNT
		MEM8
		SEP	#20H
;		
;;		LDA	#20
;;		STA	>DWCNCT		; coin -20
;
		INC	ENKBMK,X
YD0000		EQU	$
		LDA	#0DH*4
		JSL	>OAMENT1
		JSR	OAMCHK
;
		LDY	YAAACT
		STY	<WORKD
;
		LDA	ENTIM1,X		
		BEQ	YD0001
		LSR	A
		LSR	A
		LSR	A
;
		TAY
		LDA	YDDSCT,Y
		STA	<WORKD
YD0001		EQU	$
		PHX
		LDA	<WORKD
		ASL	A
		CLC
		ADC	#07H
		TAX
		LDY	#00H
YDC010		EQU	$
		LDA	<WORK0
		CLC
		ADC	#0ECH
		ADC	YYDXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	#0D0H
		ADC	YYDYAD,X
		INY
		STA	(<OAMADR),Y		
		LDA	YYDCDT,X
		INY
		STA	(<OAMADR),Y		
		LDA	YYDADT,X
		INY
		STA	(<OAMADR),Y		
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#00H
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	YDC010
		PLX
;
		LDA	YAAACT
		ORA	ENTIM3,X
		ORA	BMMODE+0
		ORA	BMMODE+1
		ORA	BMMODE+2
		ORA	BMMODE+3
		ORA	BMMODE+4
		BNE	YDC020		; Game end ?
;					; yes !
		LDA	#00001010B
		STA	ENMOD3,X
		JSL	>CRENPL2L
		BCC	YDC020
;
		LDA	<KEYA2L
;		AND	#10000000B
		BPL	YDC020
;
		LDA	#MS_0133
		JSR	YSMSST
;
		INC	ENSTAT,X		
YDC020		EQU	$
		RTS
;====================================================
YDDSCT		EQU	$
		HEX	5,4,3,2,1,0
;
YYDXAD		EQU	$
		HEX	00,00,00,00,30,30,30,30
		HEX	08,08,10,10,18,18,20,20,28,28
YYDYAD		EQU	$
		HEX	F8,00,08,10,F8,00,08,10
		HEX	00,08,00,08,00,08,00,08,00,08
YYDCDT		EQU	$
		HEX	2B,3B,3B,2B,2B,3B,3B,2B
		HEX	63,73,63,73,63,73,63,73,63,73
YYDADT		EQU	$
		HEX	33,33,B3,B3,73,73,F3,F3
		HEX	32,32,32,32,32,32,32,32,32,32
;
;
;
;
;
;
;
;
;;=====================================
;YSCXAD		EQU	$
;		HEX	00,00,00
;		HEX	00,00,FB
;;
;		HEX	00,FF,FF
;		HEX	00,00,00
;		HEX	00,01,01
;YSCYAD		EQU	$
;		HEX	00,F6,F6
;		HEX	00,F6,FD
;;
;		HEX	00,F6,F6
;		HEX	00,F6,F6
;		HEX	00,F6,F6
;YSCCDT		EQU	$
;		HEX	26,06,06
;		HEX	08,06,3A
;;
;		HEX	26,06,06
;		HEX	26,06,06
;		HEX	26,06,06
;YSCADT		EQU	$
;		HEX	08,06,06
;		HEX	08,06,08
;		HEX	08,06,06
;		HEX	08,06,06
;		HEX	08,06,06
;YSCSBD		EQU	$
;		HEX	02,02,02
;		HEX	02,02,00
;		HEX	02,02,02
;		HEX	02,02,02
;		HEX	02,02,02
;;- - - - - - - - - - - - - - - - - - - - -
;YASANCS		EQU	$
;		JSL	>OCHECKL
;;
;		JSR	OAMCHK
;		LDA	ENCHPT,X
;		ASL	A
;		ADC	ENCHPT,X
;		STA	<WORK6
;		PHX
;		LDX	#02H
;YASC10		EQU	$
;		PHX
;		TXA
;		CLC
;		ADC	<WORK6
;		TAX
;		LDA	<WORK0
;		CLC
;		ADC	YSCXAD,X
;		STA	(<OAMADR),Y
;		LDA	<WORK2
;		CLC
;		ADC	YSCYAD,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	YSCCDT,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	<WORK5
;		ORA	YSCADT,X
;		INY
;		STA	(<OAMADR),Y
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDA	YSCSBD,X
;		STA	(<OSBADR),Y
;		PLY
;		INY
;		PLX
;		DEX
;		BPL	YASC10
;		PLX
;;;		LDY	#0FFH
;;;		LDA	#02H
;;;		JSL	>ALOMCKL
;;
;		JSL	>SADWSTL
;		RTS
;========================================================
TKATCT		EQU	$
		BYTE	04,08,16,32,64,99,99,99,99,99
;;		BYTE	02,04,08,12,20,30,40,50,60,70
;;		BYTE	10,20,30,40,50,60,70,80,90
;
;=====atari tako================================================
TAKOSMV		EQU	$
		LDA	ENCTCT,X
		CMP	#05H
		BCC	TAKM01		; 5 kai renzoku ?
;					; yes ! '99'
		LDA	#06H
		STA	ENWRK1,X
TAKM01		EQU	$
		LDA	ENMOD0,X
		AND	#11100000B
		STA	ENMOD0,X	; oam use !!
;
		LDA	ENTIM2,X
		BNE	TAKM09
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
TAKM09		EQU	$
		AND	#00000100B
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	<WORK0
		STA	ENCLOR,X
;
		LDA	ENYP2L
		SEC
		SBC	#03H
		STA	ENYP2L
		JSL	>EN1CSTL
;
		LDA	ENTIM2,X
		BEQ	TAKM10
;
		PHA
		LDA	ENMOD0,X
		ORA	#05H
		STA	ENMOD0,X	; oam use !!
		PLA
;
		CMP	#60H
		BNE	TAKM08		; COIN COUNTET UP ?
;
		LDA	<GAMEMD
		BNE	TAKM08
;
		LDA	#70H
		STA	ENTIM0+00	; Ossan move !
;
;;		LDY	YAHTCT
		LDY	ENWRK1,X
		LDA	#00H
		XBA
                LDA     TKATCT-1,Y
		MEM16
		REP	#20H
                CLC
                ADC     >CONCNT
                STA     >CONCNT
		MEM8
		SEP	#20H
;;                LDA     #000H
;;                ADC     >UPCNCT+1
TAKM08		EQU	$
		JSR	COINDP		; Coin display !
TAKM10		EQU	$
		BRA	HDM000
;=====hazure hand================================================
HANDSMV		EQU	$
		LDA	ENMOD0,X
		AND	#11100000B
		STA	ENMOD0,X	; oam use !!
;
		LDA	ENYP2L
		CLC
		ADC	#03H
		STA	ENYP2L
;
		JSL	>EN1CSTL
HDM000		EQU	$
;
		JSR	ENSTCK
;
		LDA	ENTUTM,X
		DEC	A
		BNE	HDM001
;
                LDA     #3CH
                STA     SOUND2  ;(S)
HDM001		EQU	$
		INC	ENCONT,X
		JSR	ENXCLC
;
		LDA	ENTIM1,X
		BNE	HDM010
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	HDM020
;
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	HDM010
		LDA	#10H
		STA	ENTIM0,X
		STZ	ENTIM2,X
HDM010		EQU	$
		RTS
;----------------------------------------
HDMXST		EQU	$
		HEX	E8,08
;
HDM020		EQU	$
		CMP	#01H
		BNE	HDM030
;
		LDY	ENCHPT,X
		LDA	HDMXST,Y
		STA	ENXPSL,X
		LDA	<PLXPS0
		STA	ENXPSH,X
;
		LDA	#30H-10H
		STA	ENTIM1,X
		STZ	ENCTCT,X
HDM030		EQU	$
		RTS
;=======================================
CODXAD		EQU	$
		HEX	F8,F8,00,08,10
CODYAD		EQU	$
		HEX	E8,F0,EC,EC,EC
;;		HEX	E5,ED,E9,E9,E9
CODCDT		EQU	$
		HEX	0B,1B,B6,02,30
CODADT		EQU	$
		HEX	38,38,34,35,35
COCCD2		EQU	$
;;;			04 08 16 32 64 99
		HEX	12,32,31,03,22,33
;;;;;;;;;;;			02 04 08 12 20 
;;;;;;;;		HEX	02,12,32,31,02  
COCCD3		EQU	$
;;;			04 08 16 32 64 99
		HEX	7C,7C,22,02,12,33
;;;;;;;;;;			02 04 08 12 20 
;;;;;;;;		HEX	7C,7C,7C,02,30 
;- - - - - - - - - - - - - - -
COINDP		EQU	$
		JSR	OAMCHK
		LDA	ENWRK1,X
		STA	<WORK6
		PHX
		LDX	#04H
		LDY	#04H
COD010		EQU	$
		LDA	<WORK0
		CLC
		ADC	CODXAD,X
		STA	(<OAMADR),Y	
		LDA	<WORK2
		CLC
		ADC	CODYAD,X
		INY
		STA	(<OAMADR),Y
;
		CPX	#04H
		BNE	COD012
		PHX
		LDX	<WORK6
		LDA	COCCD3-1,X
		PLX
		BRA	COD019
COD012		EQU	$
		CPX	#03H
		BNE	COD018
		PHX
		LDX	<WORK6
		LDA	COCCD2-1,X
		PLX
		BRA	COD019
COD018		EQU	$
		LDA	CODCDT,X
COD019		EQU	$
		INY
		STA	(<OAMADR),Y
		CMP	#7CH
		INY
		LDA	CODADT,X
		BCC	COD01A		; Bank 0 (space) ?
;					; yes !
		AND	#11111110B
COD01A		EQU	$
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#00H
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	COD010
		PLX
;
		JSL	>BIKRST2	; Bikkuri set !
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ARMRVL		EQU	$
		HEX	FF,01
ARMRVH		EQU	$
		HEX	FF,00
;- - - - - - - - - - - - - - - - - - - -
;		LDA	ENWRK0,X
;		BEQ	ARI00M		; mushi ?
;;					; yes !
;		JMP	ARMSIMV
;;
ARI00M		EQU	$
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#020H
		CMP	#040H
		BCS	ARM008
		LDA	<WORKF
		CLC
		ADC	#020H
		CMP	#040H
		BCS	ARM008
;
		LDA	#04H*4
		JSL	>OAMENT2
ARM008		EQU	$
		JSR	ARI00CS
;
		JSR	ENSTCK
;
                LDY     ENKBMK,X
                LDA     ENMODE,Y
                CMP     #EFAIL
                BNE     ARM018
;
                STA     ENMODE,X
                LDA     ENTIM0,Y
                STA     ENTIM0,X
;
                LDA     ENMOD0,X
                CLC
                ADC     #04H
                STA     ENMOD0,X
                RTS
;
ARM018		EQU	$
;
;;;
;;		JSR	EPXYCK
;;		LDA	<WORKE
;;		CLC
;;		ADC	#01CH
;;		CMP	#020H
;;		BCS	ARM00C
;;		LDA	<WORKF
;;		CLC
;;		ADC	#014H
;;		CMP	#028H
;;		BCS	ARM00C
		LDA	ENCHPT,X
		CMP	#03H
		BCS	ARM00C
;
		JSL	>CRENPL2L
		BCC	ARM00C
;
		JSL	>DASCLR1	;DASH KINSI!!
;
		LDA	<KEYA2L
		AND	#00010000B
		BNE	ARM088
;
		LDA	#01H
		STA	PLSTOP
ARM088		EQU	$
		LDA	#10H
		JSL	>PSERCHL
;
		LDY	#00H
		LDA	<WORK0
		BPL	ARM00A
		EOR	#0FFH
		INC	A
		INY
ARM00A		EQU	$
		CLC
		ADC	ENWRK0,X
		STA	ENWRK0,X
;;		HEX	EA,EA
		BCC	ARM090
;
		LDA	ARMRVL,Y
		STA	PLYMVD
		LDA	ARMRVH,Y
		STA	PLYMVD+1
ARM090		EQU	$		
		LDY	#00H
		LDA	<WORK1
		BPL	ARM01A
		EOR	#0FFH
		INC	A
		INY
ARM01A		EQU	$
		CLC
		ADC	ENWRK1,X
		STA	ENWRK1,X
;;		HEX	EA,EA
		BCC	ARM091
;
		LDA	ARMRVL,Y
		STA	PLXMVD
		LDA	ARMRVH,Y
		STA	PLXMVD+1
ARM091		EQU	$		
;
ARM00C		EQU	$
;;
;		LDA	<FRCNT
;		AND	#0FH
;		BNE	ARM010
;		INC	ENCHPT,X
;		LDA	ENCHPT,X
;		CMP	#03H
;		BNE	ARM010
;		STZ	ENCHPT,X
;ARM010		EQU	$		
;;		LDA	ENMYNO,X
;;		CMP	#ARI01
;;		BNE	ARM0E0
;;;
;;		LDA	#ARI00
;;		STA	ENMYNO,X
;;;
;;		JSR	ARMSIST		; mushi set !
;;ARM0E0		EQU	$
;;		RTS
;====Character paturn set==========================================
ARICTL		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	A0WAIT
		WORD	A0UP
		WORD	A0SHOT
		WORD	A0DOWN
;-------------------------------------
A0WAIT		EQU	$
		LDA	#06H
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		BNE	A0W010
;
		INC	ENSTAT,X
;;		LDA	#1FH
		LDA	#3FH
		STA	ENTIM0,X
A0W010		EQU	$
		RTS
;----------------------------------------
A0UPTD		EQU	$
		HEX	5,4,3,3
;
A0UP		EQU	$
		LDA	ENTIM0,X
		BNE	A0U010
		INC	ENSTAT,X
;;		LDA	#80H
		LDA	#0FFH
		STA	ENTIM0,X
		RTS
A0U010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	A0UPTD,Y
		STA	ENCHPT,X
		RTS
;----------------------------------------
;
A0SHOT		EQU	$
		LDA	<FRCNT
		AND	#0FH
		BNE	ARM010
		INC	ENCHPT,X
		LDA	ENCHPT,X
		CMP	#03H
		BCC	ARM010
		STZ	ENCHPT,X
ARM010		EQU	$		
		LDA	ENTIM0,X
		BNE	A0S010
;
;;		LDA	#1FH
		LDA	#3FH
		STA	ENTIM0,X
		INC	ENSTAT,X
A0S010		EQU	$
		RTS
;----------------------------------------
A0DPTD		EQU	$
		HEX	3,3,4,5
;
A0DOWN  	EQU	$
		LDA	ENTIM0,X
		BNE	A0D010
		STZ	ENSTAT,X
;;		LDA	#80H
		LDA	#20H
		STA	ENTIM0,X
		RTS
A0D010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	A0DPTD,Y
		STA	ENCHPT,X
		RTS
;;;===========================================
;;ARMSIST		EQU	$
;;;		LDA	ENTIM0,X
;;;		BNE	ARS010
;;;		LDA	#0FFH
;;;		STA	ENTIM0,X
;;;
;;		LDA	#ARI01
;;		JSL	>ENIDSH
;;		BMI	ARS010
;;;
;;		LDA	<WORK0
;;		STA	ENXPSL,Y
;;		LDA	<WORK1
;;		STA	ENXPSH,Y
;;		LDA	<WORK2
;;		STA	ENYPSL,Y
;;		LDA	<WORK3
;;		STA	ENYPSH,Y
;;;;		LDA	#01H
;;;;		STA	ENWRK0,Y
;;;;		LDA	#00H
;;;;		STA	ENCLOR,Y
;;;;		
;;ARS010		EQU	$
;;		RTS
;===========================================
ARCXAD		EQU	$
		WORD	0FFF8H,0008H,0FFF8H,0008H
		WORD	0FFF8H,0008H,0FFF8H,0008H
		WORD	0FFF8H,0008H,0FFF8H,0008H
;
		WORD	00H,08H,00H,08H
		WORD	00H,08H,00H,08H
		WORD	0FFF8H,0008H,0FFF8H,0008H
ARCYAD		EQU	$
		WORD	0FFF8H,0FFF8H,0008H,0008H
		WORD	0FFF8H,0FFF8H,0008H,0008H
		WORD	0FFF8H,0FFF8H,0008H,0008H
;
		WORD	00,00,08,08
		WORD	00,00,08,08
		WORD	0FFF8H,0FFF8H,0008H,0008H
ARCCDT		EQU	$
		HEX	04,04,04,04
		HEX	22,22,22,22
		HEX	02,02,02,02
;
		HEX	29,29,29,29
		HEX	39,39,39,39
		HEX	2A,2A,2A,2A
ARCADT		EQU	$
		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,40,80,C0
;
ARCSBD		EQU	$
		HEX	2,2,2,0,0,2
;
ARI00CS		EQU	$
		JSR	OAMCHK
;
		LDA	ENCHPT,X
		CMP	#06H
		BEQ	ARC900
		PHX
		TAX
		LDA	ARCSBD,X
		STA	<WORKD
		TXA
		ASL	A
		ASL	A
		STA	<WORK6
		LDX	#03H
ARC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	ARCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	ARCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	ARC020
		LDA	#0F0H
		STA	(<OAMADR),Y
ARC020		EQU	$
		PLX
		LDA	ARCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	ARCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
;;		LDA	#02H
		LDA	<WORKD
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	ARC010
		PLX
ARC900		EQU	$
		RTS
;================================================
ARI01M		EQU	$		; with mushi !
ARMSIMV		EQU	$
;;		LDA	ENWRK0,X
;;		BNE	AMM00C
;;;
;;		INC	ENWRK0,X
;;		JSR	ARMSIST		; SUNA set !
;;AMM00C		EQU	$
;
		JSR	ARMSICS
;AMM010		EQU	$
		JSR	ENSTCK
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	AMWAIT
		WORD	AMUP
		WORD	AMSHOT
		WORD	AMDOWN
;-------------------------------------
AMWAIT		EQU	$
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	AMW010
;
		INC	ENSTAT,X
		LDA	#1FH
		STA	ENTIM0,X
AMW010		EQU	$
		RTS
;----------------------------------------
AMUPTD		EQU	$
		HEX	01,00
;
AMUP		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	AMU010
		INC	ENSTAT,X
		LDA	#80H
		STA	ENTIM0,X
		RTS
AMU010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	AMUPTD,Y
		STA	ENCHPT,X
		RTS
;----------------------------------------
AMSHOT		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	AMS010
;
		LDA	#1FH
		STA	ENTIM0,X
		INC	ENSTAT,X
		RTS
AMS010		EQU	$
;;		CMP	#40H
;;		BNE	AMS020
		AND	#1FH
		ORA	ENCTCT,X
		ORA	<GAMEMD
		ORA	ENDSPL,X
		ORA	ENSTFG
		BNE	AMS020
;
		JSL	>Z2TMSTL
AMS020		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		CLC
		ADC	#02H
		STA	ENCHPT,X
		RTS
;----------------------------------------
AMDPTD		EQU	$
		HEX	00,01
;
AMDOWN  	EQU	$
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	AMD010
		STZ	ENSTAT,X
		LDA	#0DFH
		STA	ENTIM0,X
		RTS
AMD010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	AMDPTD,Y
		STA	ENCHPT,X
		RTS
;==============================================
AMCXAD		EQU	$
		WORD	00,08,00,08
		WORD	00,00,00,08
		WORD	0,0,0,0
		WORD	0,0,0,0
AMCYAD		EQU	$
		WORD	02,02,06,06
		WORD	0FFFEH,0FFFEH,06,06
		WORD	0FFFCH,0FFFCH,0FFFCH,0FFFCH
		WORD	0FFFCH,0FFFCH,0FFFCH,0FFFCH
AMCCDT		EQU	$
		HEX	00,00,D8,D8
		HEX	00,00,D9,D9
		HEX	00,00,00,00
		HEX	20,20,20,20
AMCADT		EQU	$
		HEX	01,41,00,40
		HEX	01,01,00,40
		HEX	01,01,01,01
		HEX	01,01,01,01
AMCSBD		EQU	$
		HEX	00,00,00,00
		HEX	02,02,00,00
		HEX	02,02,02,02
		HEX	02,02,02,02
;- - - - - - - - - - - - - - - - - - - - -
ARMSICS		EQU	$
		LDA	ENSTAT,X
		BEQ	ARMC90
;
;;		LDA	#04H*4
;;		JSL	>OAMENT3
;
		JSR	OAMCHK
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORK6
		PHX
		LDX	#03H
ARMC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	AMCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	AMCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	ARMC20
		LDA	#0F0H
		STA	(<OAMADR),Y
ARMC20		EQU	$		
		PLX
		LDA	AMCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	AMCADT,X
		PHA
		AND	#0FH
		CMP	#01H
		PLA
		EOR	<WORK5
		BCS	ARMC22		; Tuchi color ?
;					; yes !
		AND	#0F0H
ARMC22		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	AMCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	ARMC10
		PLX
ARMC90		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ATARSM		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	ATARS00		;KEN
		WORD	ATARS01		;HIKARI 1
		WORD	ATARS02		;HIKARI 2
		WORD	ATARS03		;MONSYO
		WORD	ATARS04		;HIKARI 1'
;----------------------------------------
ATARS00		EQU	$
		LDA	<SLMODE
		CMP	#MD_endg1
		BEQ	ATARS10
;
		PHX
		LDX	<MPDTNO
		LDA	>GNDTBL,X
		PLX
		AND	#01000000B
		BEQ	ATARS10
		JMP	ATRM08		; already have ?
ATARS10		EQU	$
;					; no
		LDA	ENSTAT,X
		CMP	#005H
		BEQ	ATARS20
		JSR	ATARSCS
;---------------------------------------;tottemo ii ?------------
ATARS20		EQU	$
;		JSR	ENSTCK		; scroll : not return !
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	ATARSM0
		WORD	ATARSM00
		WORD	ATARSM1
		WORD	ATARSM2
		WORD	ATARSM3
		WORD	ATARSM4
;----------------------------------------
ATARSM0		EQU	$
		JSL	>WPMSCK
		BCS	ATRM010
;
		JSL	>CRENPL2L
		BCC	ATRM010
;
		LDA	<PLMKCH
		CMP	#02H
		BNE	ATRM010
;
		LDA	<KEYA2L		;? DO BOTTON
;		AND	#080H
		BPL	ATRM010
;
		LDA	>ITEMR53	; PENDANT 
		AND	#007H
		CMP	#007H
		BNE	ATRM010
;
		LDA	#00AH		;OTO
		STA	SOUND0
;// 03.09.16 //		STA	SVSND0
;
		LDA	#001H
		STA	MRTKFG
;
		LDA	#009H
		JSR	MONSYST		;MONSYO SET
		LDA	#00BH
		JSR	MONSYST		;MONSYO SET
		LDA	#00FH
		JSR	MONSYST		;MONSYO SET
;
		JSR	HIKA1ST2
		INC	ENSTAT,X
		LDA	#0F0H
		STA	ENTIM0,X
;
ATRM010		EQU	$
		RTS
;----------------------------------------
ATARSM00	EQU	$
		LDA	ENTIM0,X
		BNE	ATSM0010
		JSR	HIKA1ST
		INC	ENSTAT,X
		LDA	#0C0H
		STA	ENTIM0,X
ATSM0010	EQU	$
		LDA	#00AH
		STA	HIKUFG
		LDA	#001H
		STA	PYALSP
		RTS
;----------------------------------------
ATARSM1		EQU	$
		LDA	ENTIM0,X
		BNE	ATSM110
;		LDA	#000H
		LDY	#0FFH		;TIME
		JSR	HIKA2ST
		INC	ENSTAT,X
		LDA	#008H
		STA	ENTIM0,X
ATSM110		EQU	$
		LDA	#00AH
		BRA	ATSM220
;----------------------------------------
ATARSM2		EQU	$
		LDA	ENTIM0,X
		BNE	ATSM210
		LDA	#001H
		LDY	#0FFH		;TIME
		JSR	HIKA2ST
		INC	ENSTAT,X
		LDA	#010H
		STA	ENTIM0,X
ATSM210		EQU	$
		LDA	#00BH
ATSM220		EQU	$
		STA	HIKUFG
		LDA	#001H
		STA	PYALSP
		RTS
;----------------------------------------
ATARSM3		EQU	$		;GET
		LDA	ENTIM0,X
		BNE	ATRM10
		PHX			; yes !
		LDX	<MPDTNO
		LDA	>GNDTBL,X
		ORA	#01000000B
		STA	>GNDTBL,X
;
		LDY	#01H
		STZ	!ITMVFG
		JSL	>ATMSIT		; jyaaan !
		PLX
		LDA	#005H		;MAP MODE
		STA	>MODTBL2
		STZ	HIKUFG
;		STZ	PYALSP
		INC	ENSTAT,X
ATRM10		EQU	$
		RTS
;----------------------------------------
ATARSM4		EQU	$		;GET
;		LDA	#OTIM		;PL. TIME SET
;		STA	OPMTIM
;		LDA	#mesm1
;		STA	>OPMODE+0
;
ATRM08		EQU	$
		STZ	ENMODE,X
;
		RTS
;======================================================
ATR01DT		EQU	$
		BYTE	0,1,1,2,2,2,1,1,0
ATR01D1		EQU	$
		BYTE	0,0,1,1,2,2,0,0,0
ATARS01		EQU	$
		JSR	HIKA1CS
;		JSR	ENSTCK		; scroll : not return !
;
		INC	ENWRK0,X
		LDA	ENWRK0,X
		BNE	ATA0110
		INC	ENWRK2,X
		STZ	ENMODE,X
ATA0110		EQU	$
		LSR	A
		LSR	A
		AND	#003H
		STA	ENMUKI,X
		LDA	ENWRK0,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#007H
		TAY
		LDA	ATR01DT,Y
		STA	ENCHPT,X
		LDA	ATR01D1,Y
		BEQ	ATA0120
		TAY
		LDA	ENWRK0,X
		LSR	A
		LSR	A
		AND	#001H
		JSR	HIKA2ST
ATA0120		EQU	$
		RTS
;----------------------------------------
ATARS04		EQU	$
		JSR	HIKA1CS
;
		INC	ENWRK0,X
		LDA	ENWRK0,X
		BNE	ATA0410
		INC	ENWRK2,X
		STZ	ENMODE,X
ATA0410		EQU	$
		LSR	A
		LSR	A
		AND	#003H
		STA	ENMUKI,X
		LDA	#000H
		STA	ENCHPT,X
		RTS
;----------------------------------------
HIKA1CD		EQU	$
		WORD	-0006,00004
		BYTE	082H,000H,000H,002H
		WORD	-0006,00004
		BYTE	082H,040H,000H,002H
		WORD	-0006,00004
		BYTE	082H,0C0H,000H,002H
		WORD	-0006,00004
		BYTE	082H,080H,000H,002H
;
		WORD	-0006,00004
		BYTE	0A0H,000H,000H,002H
		WORD	-0006,00004
		BYTE	0A0H,040H,000H,002H
		WORD	-0006,00004
		BYTE	0A0H,0C0H,000H,002H
		WORD	-0006,00004
		BYTE	0A0H,080H,000H,002H
;
		WORD	-0006,00004
		BYTE	080H,000H,000H,002H
		WORD	-0006,00004
		BYTE	080H,040H,000H,002H
		WORD	-0006,00004
		BYTE	080H,0C0H,000H,002H
		WORD	-0006,00004
		BYTE	080H,080H,000H,002H
;
;
HIKA1CS		EQU	$
		LDA	#1*4
		JSL	>OAMENT3
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ADC	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  HIKA1CD
		STA	<WORK8
		LDA	#HIGH HIKA1CD
		ADC	#000H
		STA	<WORK9
;
		LDA	#001H		;KAZU SET
;;		STA	<WORK6
;;		STZ	<WORK7
;
SETO22		EQU	$
		JSL	>SETOAML22
;
		RTS
;----------------------------------------
HIKA1ST2	EQU	$
		LDA	#ATARS
		JSL	>ENIDSH
;
		JSL	>ENIDPS
;
		LDA	#004H
		STA	ENCONT,Y
		LDA	#005H
		STA	ENCLOR,Y
;
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
;
		RTS
;----------------------------------------
HIKA1ST		EQU	$
		LDA	#ATARS
		JSL	>ENIDSH
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;
		LDA	#001H
		STA	ENCONT,Y
		LDA	#005H
		STA	ENCLOR,Y
;
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
;
		RTS
;----------------------------------------
ATARS02		EQU	$
		JSL	>EN1CSTL
;		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENWRK0,X
		BEQ	ATA0210
		JSR	ENMVCL		;xclc,yclc
		LDA	<FRCNT
		AND	#003H
		BNE	ATA0220
		JSR	HIKA3ST
;		RTS
ATA0210		EQU	$
		DEC	ENWRK1,X
		BNE	ATA0220
		STZ	ENMODE,X
ATA0220		EQU	$
		RTS
;----------------------------------------------
HI2STXY		EQU	003

HI2STX0		EQU	$
		BYTE	000*HI2STXY,-16*HI2STXY
HI2STX1		EQU	$
		BYTE	000*HI2STXY,016*HI2STXY
HI2STX2		EQU	$
		BYTE	-32*HI2STXY,-16*HI2STXY
HI2STX3		EQU	$
		BYTE	032*HI2STXY,016*HI2STXY
;
HI2STY0		EQU	$
		BYTE	-32*HI2STXY,-16*HI2STXY
HI2STY1		EQU	$
		BYTE	032*HI2STXY,016*HI2STXY
HI2STY2		EQU	$
		BYTE	000*HI2STXY,016*HI2STXY
HI2STY3		EQU	$
		BYTE	000*HI2STXY,-16*HI2STXY
;
HI2STM0		EQU	$
HI2STM1		EQU	$
		BYTE	001,000
HI2STM2		EQU	$
HI2STM3		EQU	$
		BYTE	003,002
;
HI2STA0		EQU	$
HI2STA1		EQU	$
		BYTE	005H,045H
HI2STA2		EQU	$
HI2STA3		EQU	$
		BYTE	005H,005H
;
HIKA3ST		EQU	$
		LDA	#ATARS
		JSL	>ENIDSH
		BMI	HI3ST10
;
		LDA	<WORK0
		CLC
		ADC	#000H
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	#000H
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#000H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	#002H
		STA	ENCONT,Y
		LDA	#003H
		STA	ENWRK1,Y
;
		LDA	ENCHPT,X
		STA	ENCHPT,Y
;
		LDA	ENCLOR,X
		STA	ENCLOR,Y
;
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
;
HI3ST10		EQU	$
		RTS
;----------------------------------------
HIKA2ST		EQU	$
		PHY
		PHA
		LDA	#ATARS
		JSL	>ENIDSH
		BPL	HI2ST20
		JMP	HI2ST10
;
HI2ST20		EQU	$
		LDA	<WORK0
		SEC
		SBC	#004H
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#000H
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#004H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	#002H
		STA	ENCONT,Y
		STA	ENWRK0,Y
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
;
		PLA
		PHX
		TAX
		LDA	HI2STX0,X
		STA	ENXSPD,Y
		LDA	HI2STY0,X
		STA	ENYSPD,Y
		LDA	HI2STM0,X
		STA	ENCHPT,Y
		LDA	HI2STA0,X
		STA	ENCLOR,Y
		TXA
		PLX
		STA	<WORK0
		PLA
		STA	ENWRK1,Y
		PHA
		LDA	<WORK0
;
		PHA
		LDA	#ATARS
		JSL	>ENIDSH
		BPL	HI2ST30
		JMP	HI2ST10
;
HI2ST30		EQU	$
		LDA	<WORK0
		SEC
		SBC	#004H
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#000H
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#004H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	#002H
		STA	ENCONT,Y
		STA	ENWRK0,Y
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
;
		PLA
		PHX
		TAX
		LDA	HI2STX1,X
		STA	ENXSPD,Y
		LDA	HI2STY1,X
		STA	ENYSPD,Y
		LDA	HI2STM1,X
		STA	ENCHPT,Y
		LDA	HI2STA1,X
		STA	ENCLOR,Y
		TXA
		PLX
		STA	<WORK0
		PLA
		STA	ENWRK1,Y
		PHA
		LDA	<WORK0
;
		PHA
		LDA	#ATARS
		JSL	>ENIDSH
		BPL	HI2ST40
		JMP	HI2ST10
;
HI2ST40		EQU	$
		LDA	<WORK0
		SEC
		SBC	#004H
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#000H
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#004H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	#002H
		STA	ENCONT,Y
		STA	ENWRK0,Y
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
;
		PLA
		PHX
		TAX
		LDA	HI2STX2,X
		STA	ENXSPD,Y
		LDA	HI2STY2,X
		STA	ENYSPD,Y
		LDA	HI2STM2,X
		STA	ENCHPT,Y
		LDA	HI2STA2,X
		STA	ENCLOR,Y
		TXA
		PLX
		STA	<WORK0
		PLA
		STA	ENWRK1,Y
		PHA
		LDA	<WORK0
;
		PHA
		LDA	#ATARS
		JSL	>ENIDSH
		BMI	HI2ST10
;
		LDA	<WORK0
		SEC
		SBC	#004H
		STA	ENXPSL,Y
		LDA	<WORK1
		SBC	#000H
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	#004H
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	#002H
		STA	ENCONT,Y
		STA	ENWRK0,Y
		LDA	#000H
		STA	ENMOD0,Y	;OAM KAZU
;
		PLA
		PHX
		TAX
		LDA	HI2STX3,X
		STA	ENXSPD,Y
		LDA	HI2STY3,X
		STA	ENYSPD,Y
		LDA	HI2STM3,X
		STA	ENCHPT,Y
		LDA	HI2STA3,X
		STA	ENCLOR,Y
		TXA
		PLX
;		STA	<WORK0
		PLA
		STA	ENWRK1,Y
;		PHA
;		LDA	<WORK0
		RTS
;
HI2ST10		EQU	$
		PLA
		PLY
		RTS
;----------------------------------------
MONSYST		EQU	$
		PHA
		LDA	#ATARS
		JSL	>ENIDSH
		PLA
		STA	ENCLOR,Y	;COLOR SET
;
		LDA	<PLXPS1
		STA	ENXPSL,Y
		LDA	<PLXPS0
		STA	ENXPSH,Y
;
		LDA	<PLYPS1
		CLC
		ADC	#008H
		STA	ENYPSL,Y
		LDA	<PLYPS0
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	#004H
		STA	ENCHPT,Y
;
		LDA	#003H
		STA	ENCONT,Y
;
		LDA	#040H
		STA	ENMOD0,Y	;OAM KAZU
;
		LDA	#0E4H
		STA	ENTIM0,Y	;SLOW TIME
;
		PHX
		LDA	ENCLOR,Y
		LSR	A
		AND	#003H
		TAX
		LDA	AAS03SX,X
		STA	ENXSPD,Y
		LDA	AAS03SY,X
		STA	ENYSPD,Y
		PLX
;
		RTS
;----------------------------------------
AAS03SX		EQU	$
		BYTE	0FCH,004H,000H,000H
AAS03SY		EQU	$
		BYTE	0FEH,0FEH,0FCH,0FCH
;
ATARS03		EQU	$
		LDA	#1*4
		JSL	>OAMENT2
		JSL	>EN1CSTL
;		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	AAS03M0
		WORD	AAS03M1
		WORD	AAS03M2
;----------------------------------------
AAS03M0		EQU	$
;
		JSR	ENMVCL		;xclc,yclc
;
		LDA	ENTIM0,X
		BNE	AAS0310
		INC	ENSTAT,X
		LDA	#0D0H
		STA	ENTIM0,X
		LDA	ENCLOR,X
		STA	ENWRK0,X
AAS0310		EQU	$
		RTS
;----------------------------------------------
AAS03M1		EQU	$
		LDA	ENCLOR,X
		AND	#0F1H
		STA	ENCLOR,X
		TXA
		ASL	A
		EOR	<FRCNT
		AND	#0EH
		ORA	ENCLOR,X
		STA	ENCLOR,X
;
		LDA	ENTIM0,X
		BNE	AAS0320
		INC	ENSTAT,X
		LDA	ENWRK0,X
		STA	ENCLOR,X
AAS0320		EQU	$
		RTS
;----------------------------------------------
AAS03M2		EQU	$
		JSR	ENMVCL		;xclc,yclc
		LDA	ENTIM0,X
		BNE	AAS0330
		ASL	ENXSPD,X
		ASL	ENYSPD,X
		LDA	#006H
		STA	ENTIM0,X
AAS0330		EQU	$
		INC	ENWRK3,X
		BNE	AAS0340
		STZ	ENMODE,X
AAS0340		EQU	$
		RTS
;----------------------------------------------
ATRXAD		EQU	$
		HEX	F8,00,F8,00
		HEX	F8,00
ATRYAD		EQU	$
		HEX	F8,F8,00,00
		HEX	08,08
ATRCDT		EQU	$
		HEX	C3,C4,D3,D4
		HEX	E0,F0
;- - - - - - - - - - - - - - - - - - - -
ATARSCS		EQU	$
		JSR	OAMCHK
		PHX
		LDX	#05H
ATRC10		EQU	$
		LDA	<WORK0
		CLC
		ADC	ATRXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	ATRYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	ATRCDT,X
		INY
		STA	(<OAMADR),Y
;;		LDA	ATRADT,X
		INY
		LDA	<WORK5
		STA	(<OAMADR),Y
		INY
		DEX
		BPL	ATRC10
		PLX
		LDY	#00H
		LDA	#05H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CNMXSD		EQU	$
		HEX	F0,10  ;,00,00
CNMYSD		EQU	$
		HEX	00,00,F0,10
;
;;CNMTIM		EQU	$
;;		HEX	40,80
;
CHAN0M		EQU	$
CHAN1M		EQU	$
CHAN2M		EQU	$
CHAN3M		EQU	$
		LDA	ENMUKI,X
		AND	#02H
		STA	<WORK0
		LDA	ENCONT,X
		LSR	A
;;		LSR	A
;;		LSR	A
		AND	#01H
		ORA	<WORK0
		STA	ENCHPT,X
		JSR	CHAN0CS
;
		JSR	ENSTCK
;
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	CHM010
;
;;		LDY	ENSTAT,X
;;		LDA	CNMTIM,Y
		LDA	#70H
		STA	ENTIM0,X
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
CHM010		EQU	$
		LDY	ENMUKI,X
		LDA	CNMXSD,Y
		STA	ENXSPD,X
		LDA	CNMYSD,Y
		STA	ENYSPD,X
		JSR	ENMVCL
		INC	ENCONT,X
		RTS
;
;
;
;
;====================================================
CNCXAD		EQU	$
		WORD	0,0,0,0,0,0,0,0
		WORD	0,0,0,0,0,0,0,0
		WORD	00H,10H,20H,30H,40H,50H,60H,70H 
		WORD	00H,10H,20H,30H,40H,50H,60H,70H 
CNCYAD		EQU	$
		WORD	00H,10H,20H,30H,40H,50H,60H,70H 
		WORD	00H,10H,20H,30H,40H,50H,60H,70H 
		WORD	0,0,0,0,0,0,0,0
		WORD	0,0,0,0,0,0,0,0
CNCCDT		EQU	$
		HEX	8E,9E,9E,9E,9E,9E,9E,8E
		HEX	8E,9E,9E,9E,9E,9E,9E,8E
		HEX	88,89,89,89,89,89,89,88
		HEX	88,89,89,89,89,89,89,88
;
;;		HEX	88,A8,A8,A8,A8,A8,A8,88
;;		HEX	88,A8,A8,A8,A8,A8,A8,88
;;		HEX	8A,AA,AA,AA,AA,AA,AA,8A
;;		HEX	8A,AA,AA,AA,AA,AA,AA,8A
CNCADT		EQU	$
		HEX	00,00,00,80,00,00,00,80
		HEX	40,40,40,C0,40,40,40,C0
		HEX	00,00,00,40,00,00,00,40
		HEX	80,80,80,C0,80,80,80,C0
;----------------------------------------------
CHNSIZ		EQU	$
		HEX	03,07
;
CHAN0CS		EQU	$
CHAN1CS		EQU	$
		JSR	OAMCHK
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK6
		TAY
		LDA	CNCCDT,Y
		STA	<WORK8		; first no.
		PHX
		LDY	ENSTAT,X
		LDX	CHNSIZ,Y
		LDY	#00H
CNC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0	
		CLC	
		ADC	CNCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC		
		ADC	CNCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	CNC020
		LDA	#0F0H
		STA	(<OAMADR),Y
CNC020		EQU	$
		PLX
		LDA	<WORK8
		BNE	CNC028		 ;first set no.
;
		LDA	CNCCDT,X
CNC028		EQU	$
		STZ	<WORK8
		INY
		STA	(<OAMADR),Y
		LDA	CNCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	CNC010
		PLX
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MEDUSM		EQU	$
;;		LDA	#80H
;;		STA	ENMOD0,X
;;		LDA	#00H
;;		STA	ENMOD3,X
;;		JSL	>EN1CSTL
;;		JSL	>CRENPL2L
;;		BCC	MD00000
;;;
;;		MEM16
;;		REP	#20H
;;		LDA	PLSVX1
;;		STA	<PLXPS1
;;		LDA	PLSVY1
;;		STA	<PLYPS1
;;		MEM8
;;		SEP	#20H
;;;
;;MD00000		EQU	$
;;		RTS
;============================================
		LDA	ENWRK2,X
		BEQ	MDM000		; beam ?
;					; yes !
		CMP	#01H
		BNE	MDM0F0
		JMP	MEDBMMV
MDM0F0		EQU	$
		JMP	MBFIRMV		; Atari mark !
;=========================================
MDM000		EQU	$
		JSR	MEDUSCS
;
		JSR	ENSTCK
;
;;		LDA	URAFLG
;;		BEQ	N710	; Belt check !
;
		JSR	ENBGCK
N710		EQU	$
;
		JSL	>CRENPLL
;
		LDA	ENSTAT,X
		BEQ	MDSPIN
		CMP	#03H
		BNE	MDSHOT
;- - - - - - - - - - - - - - - - - - - - -
MDWAIT		EQU	$
		LDA	ENTIM0,X
		BNE	MDW010
		INC	ENSTAT,X
		LDA	#50H
		STA	ENTIM0,X
;;		JSR	MBMSET
		JSL	>ENCLST
		RTS
MDW010		EQU	$
		CMP	#0FH
		BNE	MDW020
		PHA
		JSR	MBMSET
		PLA
MDW020		EQU	$
		LSR	A
		AND	#00001110B
		EOR	ENCLOR,X
		STA	ENCLOR,X
		RTS
;
;- - - - - - - - - - - - - - - - - - - - -
MDSHOT		EQU	$
		LDA	ENTIM0,X
		BNE	MDS010
		STZ	ENSTAT,X
MDS010		EQU	$
		RTS
		
;- - - - - - - - - - - - - - - - - - - - -
MDSPIN		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	MDM010
;
		LDA	ENMUKI,X
		STA	<WORKF
;	
		JSR	H0SER00		; serch beam set !
;
		INC	ENMUKI,X
MDM010		EQU	$
;		LDA	<KEYA2
;		BPL	MDM010
;		INC	ENMUKI,X
;		RTS
;MDM010		EQU	$
;		BIT	<KEYA2
;		BVC	MDM020
;		DEC	ENMUKI,X
;MDM020		EQU	$
		LDA	ENMUKI,X
		AND	#3FH
		STA	ENMUKI,X
MBST90R		EQU	$
		RTS
;-- - - - - - - - - - - - - - - - - - - -
MBMSET		EQU	$
		LDA	MDBMCT
		CMP	#04H
		BCS	MBST90R		; Max 4of beam !
;
		LDA	#MEDUS
		JSL	>ENIDSH
		BMI	MBST90R
;
;;		JSL	>SDLRCE
;;		ORA	#19H
;;		STA	SOUND3	;(S)
		LDA	#19H
		JSL	>SDLRE3	;(S)
;
		PHX
		LDX	#00H
		LDA	ENDSXL
		BPL	MBST10
		DEX
MBST10		EQU	$
		CLC
		ADC	<WORK0
		STA	ENXPSL,Y
		TXA
		ADC	<WORK1
		STA	ENXPSH,Y				
;
		LDX	#00H
		LDA	ENDSYL
		BPL	MBST20
		DEX
MBST20		EQU	$
		CLC
		ADC	<WORK2
		STA	ENYPSL,Y
		TXA
		ADC	<WORK3
		STA	ENYPSH,Y				
;
		TYX
		LDA	#20H
		JSL	>PSERCHL
;;		PLX
;;		PHX
;;		LDA	ENMUKI,X
;;		TAX
;;		LDA	H0SHXD,X
;;		STA	ENXSPD,Y
;;		LDA	H0SHYD,X
;;		STA	ENYSPD,Y
;;		PLX
		LDA	#00111111B
		STA	ENMOD0,Y		
		LDA	#14H+40H
		STA	ENMOD3,Y
		LDA	#01H
		STA	ENWRK2,Y
		LDA	#01001000B 
		STA	ENMOD5,Y	; NOT display out stop
;
		LDA	#02H+1
		STA	ENCLOR,Y
;
		LDA	#04H
		STA	ENMOD6,Y
;
		LDA	#0CH
		STA	ENTIM1,Y
;
		LDA	MDBMCT
		STA	ENCHPT,Y
		INC	MDBMCT		; Set counter !
;
		LDA	#1FH
		STA	<WORK0
;
		LDX	ENCHPT,Y
		CLC
		ADC	MDIDDT,X
		TAX
;;		LDX	#1FH
MDCL10		EQU	$
		LDA	ENXPSL,Y
		STA	>MBXLBF,X		
		LDA	ENXPSH,Y
		STA	>MBXHBF,X		
		LDA	ENYPSL,Y
		STA	>MBYLBF,X		
		LDA	ENYPSH,Y
		STA	>MBYHBF,X		
		DEX
		DEC	<WORK0
		BPL	MDCL10
;
		PLX
MBST90		EQU	$
		RTS
;================================================================
MDCYAD		EQU	$
		WORD	0FFF0H,0000H
MDCCDT		EQU	$
		HEX	48,68
;- - - - - - - - - - - - - - - -
MEDUSCS		EQU	$
		JSR	OAMCHK
		LDY	#00H
		LDA	ENMUKI,X
		CMP	#20H
		BCS	MDC00C
		LDA	#03H*4
		JSL	>OAMENT2
		LDY	#04H
		BRA	MDC010
MDC00C		EQU	$
		LDA	#03H*4
		JSL	>OAMENT3
		LDY	#00H
MDC010		EQU	$
		PHX
		LDX	#01H
MDC020		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	MDCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8	
		SEP	#20H
		BCC	MDC030
		LDA	#0F0H
		STA	(<OAMADR),Y
MDC030		EQU	$
		PLX
		LDA	MDCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	MDC020
		PLX
		JSR	MDEYST
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - -
MDEXAD		EQU	$
		HEX	FF,00,01,02,03,04,05,07
		HEX	08,0A,0B,0C,0D,0E,0F,10
		HEX	11,0F,0E,0D,0C,0B,0A,08
		HEX	07,05,04,03,02,01,00,FE
MDEYAD		EQU	$
		HEX	0B,0C,0D,0E,0E,0F,0F,0F
		HEX	0F,0F,0F,0E,0E,0D,0C,0B
		HEX	0A,09,08,07,07,06,06,06
		HEX	06,06,06,07,07,08,09,0A
MDECDT		EQU	$
		HEX	5B,5B,5A,5A,4B,4B,4A,4A
		HEX	4A,4A,4B,4B,5A,5A,5B,5B
		HEX	5B,5B,4C,4C,4C,4C,4C,4C
		HEX	5B,5B,4C,4C,4C,4C,4C,4C
MDEADT		EQU	$
		HEX	00,00,00,00,00,00,00,00
		HEX	40,40,40,40,40,40,40,40
		HEX	40,40,40,40,40,40,40,40
		HEX	00,00,00,00,00,00,00,00
;
MDEYST		EQU	$
		LDY	#08H
		LDA	ENMUKI,X
		CMP	#20H
		BCS	MDE010
		LDY	#00H
MDE010		EQU	$
		STY	<WORKE
		STZ	<WORKF
;
		LSR	A
		STA	<WORK6
		PHX
		TAX
		LDA	MDEXAD,X
		SEC
		SBC	#03H
		STA	ENDSXL
		CLC
		ADC	<WORK0
		STA	(<OAMADR),Y
		LDA	MDEYAD,X
		SEC
		SBC	#12H
		STA	ENDSYL
		CLC
		ADC	<WORK2
		INY
		STA	(<OAMADR),Y
		LDA	MDECDT,X
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		AND	#00110001B
		ORA	MDEADT,X
		ORA	#05H*2
		INY
		STA	(<OAMADR),Y		
;
		PLX
		MEM16
		REP	#20H
		LDA	<WORKE
		CLC
		ADC	<OAMADR
		STA	<OAMADR
		LDA	<WORKE
		LSR	A
		LSR	A
		CLC
		ADC	<OSBADR
		STA	<OSBADR
		MEM8
		SEP	#20H
		LDY	#00H
		TYA
		JSL	>ALOMCKL
		RTS
;
;
;
;=======================================
MDIDDT		EQU	$
		HEX	00,20,40,60
;
MEDBMMV		EQU	$
		LDA	ENTIM1,X
		BNE	MDB0F0
;
		JSR	MEDBMCS
;
		LDA	ENMODE,X
		BNE	MDB0D0		; display out cleard ?
;					; yes !
		DEC	MDBMCT
		RTS
MDB0D0		EQU	$
		JSR	ENSTCK
;
		LDY	#03H
MDB0E0		EQU	$
		PHY
		PHX
		LDA	ENXPSL,X
		PHA
		LDA	ENXPSH,X
		PHA
		LDA	ENYPSL,X
		PHA
		LDA	ENYPSH,X
		PHA
		LDA	ENCONT,X
		AND	#1FH
		LDY	ENCHPT,X
		CLC
		ADC	MDIDDT,Y
		TAX
		PLA
		STA	>MBYHBF,X
		PLA
		STA	>MBYLBF,X
		PLA
		STA	>MBXHBF,X
		PLA
		STA	>MBXLBF,X
		PLX
;
		INC	ENCONT,X
		JSR	ENMVCL
		PLY
		DEY
		BPL	MDB0E0
;
		LDA	ENTIM0,X
		BEQ	MDB000
		DEC	A
		BNE	MDB0F0
		STZ	ENMODE,X
;
		DEC	MDBMCT		; set count dec !
MDB0F0		EQU	$
		RTS
;
MDB000		EQU	$
;
;;		JSR	CREKEK
		JSL	>CRENPL2L
		BCS	MDB008
;
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	MDB010
;
MDB008		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#26H
;;		STA	SOUND3	;(S)
		LDA	#26H
		JSL	>SDLRE3	;(S)
;
		LDA	#10H
		STA	ENTIM0,X
;
		JSR	H0SDCL
;- - - - flash set - - -
		LDA	#MEDUS
		JSL	>ENIDSH
		BMI	MDB00C
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
		LDA	#10H
		STA	ENTIM0,Y
		LDA	#03H
		STA	ENMOD0,Y
		LDA	#02H
		STA	ENWRK2,Y
		LDA	#40H
		STA	ENMOD2,Y
MDB00C		EQU	$
		LDA	#080H
		STA	ENYPSH,X	; clear !!
MDB010		EQU	$
		RTS
;=================================================
OAMCHKR		EQU	$
		JSR	OAMCHK
		RTS
;- - - - - - - - - - - - - - - - - - -
MEDBMCS		EQU	$
		JSR	OAMCHKR
;
		PHX
		LDA	#1FH
		STA	<WORKD
;
		LDY	ENCHPT,X
		CLC
		ADC	MDIDDT,Y
		TAX
		LDY	#00H
MBC000		EQU	$
		LDA	>MBXLBF,X
		STA	<WORK0
		LDA	>MBXHBF,X
		STA	<WORK1
		LDA	>MBYLBF,X
		STA	<WORK2
		LDA	>MBYHBF,X
		STA	<WORK3
;
		MEM16
		REP	#20H
		LDA	<WORK0
		SEC
		SBC	<SCCH2
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		SEC
		SBC	<SCCV2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	MBC010
		LDA	#0F0H
		STA	(<OAMADR),Y
MBC010		EQU	$
		LDA	#5CH
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY	
		INY
		DEX
		DEC	<WORKD
		BPL	MBC000
		PLX
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MBFXAD		EQU	$
		WORD	0FFFCH,0004H
		WORD	0FFFCH,0004H
MBFYAD		EQU	$
		WORD	0FFFCH,0FFFCH
		WORD	04H,04H
MBFADT		EQU	$
		HEX	06,46,86,C6
;
;- - - - - - - - - - - - - - - - -
MBFIRMV		EQU	$
		LDA	ENTIM0,X
		BNE	MBF010
		STZ	ENMODE,X
MBF010		EQU	$
		JSR	OAMCHK
		PHX
		LDX	#03H
MBF020		EQU	$
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	MBFXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	MBFYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	MBF030
		LDA	#0F0H
		STA	(<OAMADR),Y
MBF030		EQU	$
		PLX
		LDA	#0D6H
		INY
		STA	(<OAMADR),Y
		LDA	<WORK5
		AND	#00110000B
		ORA	MBFADT,X
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	MBF020
		PLX
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;BBLPTD          EQU     $
;                HEX     0,1,0,1
;BBLADT          EQU     $
;                HEX     0,0,40,40
HBATDT		EQU	$
		HEX	00,40,80,C0
SPIMKD          EQU     $
                HEX     1,3,2,0
		HEX	7,5,6,4
;
;- - - - - - - - - - - - - - - - - - - - - -
SPARKM		EQU	$
SPARLM		EQU	$
                JSL     >EN1CSTL
;
                JSR     ENSTCK
;
		LDA	<FRCNT
		AND	#01H
		BNE	SPM001
;
		LDA	ENCLOR,X
		EOR	#00000110B
		STA	ENCLOR,X
SPM001		EQU	$
		LDA	ENSTAT,X
		BNE	SPI010
;- - - Init - -
		INC	ENSTAT,X
;
		LDA	#01H
		STA	ENYSPD,X
		STA	ENXSPD,X
;
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		PHA
;
		LDA	#0FFH
		STA	ENYSPD,X
		STA	ENXSPD,X
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		PLA
		ORA	ENCBFG,X
		CMP	#00000100B
		BCS	SI0020
;
		LDY	#00H
		AND	#00000001B
		BNE	SI0010
		INY
SI0010		EQU	$
		BRA	SI0030
;- - - - - - - - - - - - - - - - -
SI0020		EQU	$
		LDY	#02H
		AND	#00000100B
		BNE	SI0030
		INY
SI0030		EQU	$
		LDA	ENMYNO,X
		CMP	#SPARL
		BEQ	SI0050
		INY
		INY
		INY
		INY
SI0050		EQU	$
		LDA	SPIMKD,Y
		STA	ENMUKI,X
;- - - Move - -
SPI010		EQU	$
;;                INC     ENCONT,X
;;  ;              LDA     ENCONT,X
;;                LSR     A
;;;;              LSR     A
;;                AND     #03H
;;                TAY
;;                LDA     BBLPTD,Y
;;                STA     ENCHPT,X
;;                LDA     ENCLOR,X
;;                AND     #10111111B
;;                ORA     BBLADT,Y
;;                STA     ENCLOR,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	HBATDT,Y
		STA	ENCLOR,X
BBL018          EQU     $
		JSR	ENMVCL
		JSL	>CRENPLL
;
		LDY	ENMUKI,X
		LDA	KBCBXS,Y
		STA	ENXSPD,X
		LDA	KBCBYS,Y
		STA	ENYSPD,X
;
;;                JSL	>ENBGCKL		
		JSR	ENBGCK
;
		LDA	ENTIM2,X
		BEQ	SPM010

                CMP	#0CH/2
;;                CMP	#0CH
		BNE	SPM020
;
		LDY	ENMUKI,X
		LDA	KBNXM2,Y
		STA	ENMUKI,X
		BRA	SPM020
;
SPM010		EQU	$
		LDY	ENMUKI,X
		LDA	ENCBFG,X
		AND	KBCBC2,Y
		BNE	SPM020
;
		LDA	#14H/2
;;		LDA	#14H
		STA	ENTIM2,X
;;		BRA	SPM030
SPM020		EQU	$
		LDY	ENMUKI,X
		LDA	ENCBFG,X
		AND	KBCBCK,Y
		BEQ	SPM030
;
		LDA	KBNXMK,Y
		STA	ENMUKI,X
SPM030		EQU	$
         	LDY	ENMUKI,X
		LDA	KBMVXS,Y
		ASL	A
		STA	ENXSPD,X
		LDA	KBMVYS,Y
		ASL	A
		STA	ENYSPD,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TORI0M 		EQU	$
		LDA	ENTIM1,X
		BNE	TRD020		; move wait !
;
		LDA	ENCLOR,X
		AND	#10111111B
;
		LDY	ENXSPD,X
		BMI	TR0000
		ORA	#40H
TR0000		EQU	$
		STA	ENCLOR,X	; MUKI SET 
;
		JSL	>EN1CSTL
		JSR	ENSTCK
		JSR	ENMVCL
		JSR	ENZCLC
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	TRDOWN
		WORD	TRUP
;--------------------------------------------
TRDOWN		EQU	$
		STZ	ENCHPT,X
;
		LDA	ENZSPD,X
;;		SEC
;;		SBC	#01H
		DEC	A
		STA	ENZSPD,X
		CMP	#0F1H
		BPL	TRD020
;		
		INC	ENSTAT,X
TRD020		EQU	$
		RTS
;-------------------------------------
TRUP		EQU	$
		LDA	ENZSPD,X
;;		CLC
;;		ADC	#02H
		INC	A
		INC	A
		STA	ENZSPD,X	
		CMP	#10H
		BMI	TRU010
;
		STZ	ENSTAT,X
TRU010		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
;;		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RISU0M 		EQU	$
		LDA	ENTIM1,X
		BNE	RIM090
;
		LDA	ENCLOR,X
		AND	#10111111B
;
		LDY	ENXSPD,X
		BMI	RS0000
		ORA	#40H
RS0000		EQU	$
		STA	ENCLOR,X	; MUKI SET 
		JSL	>EN1CSTL
;
		JSR	ENSTCK
		JSR	ENMVCL
		JSR	ENZCLC
		LDA	ENZSPD,X
		DEC	A
		DEC	A
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	RIM010
		STZ	ENZPSL,X
		LDA	#010H
		STA	ENZSPD,X
		LDA	#0CH
		STA	ENTIM0,X
RIM010		EQU	$
		LDA	#00H
		LDY	ENTIM0,X
		BEQ	RIM018
		INC	A
RIM018		EQU	$
		STA	ENCHPT,X
RIM090		EQU	$
		RTS
;
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KNXSPD		EQU	$
		HEX	1C,E4  ;,00,00
KNYSPD		EQU	$
		HEX	00,00,0C,F4
;- - - - - - - - - - - - - - - - -
KANI0M		EQU	$ 
		JSR	KANI0CS
		JSR	ENSTCK
		JSR	ENHNSB
;
		JSR	CREKEK
		JSR	ENMVCL
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BNE	KNM008
;
		LDA	ENTIM0,X
		BNE	KNM010
KNM008		EQU	$
		JSL	>RNDSET
		AND	#3FH
		ADC	#20H
		STA	ENTIM0,X
		AND	#03H
		STA	ENMUKI,X
KNM010		EQU	$
		LDY	ENMUKI,X
		LDA	KNXSPD,Y
		STA	ENXSPD,X
		LDA	KNYSPD,Y
		STA	ENYSPD,X
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
;;		LSR	A
;;		LSR	A
		CPY	#02H
		BCC	KNM020
		LSR	A
		LSR	A
KNM020		EQU	$
		AND	#01H
		STA	ENCHPT,X
		RTS
;===================================
KNCXAD		EQU	$
		WORD	0FFF8H,08H
		WORD	0FFF8H,08H
KNCCDT		EQU	$
		HEX	8E,8E
		HEX	AE,AE
KNCADT		EQU	$
		HEX	00,40
		HEX	00,40
;- - - - - - - - - - - - - - - - - - - -
KANI0CS		EQU	$
		JSR	OAMCHK
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
		PHX
		LDX	#01H
KNC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	KNCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	KNC020
		LDA	#0F0H
		STA	(<OAMADR),Y
KNC020		EQU	$
		PLX
		LDA	KNCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	KNCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	KNC010
		PLX
		JSL	>SADWSTL
		RTS
;==============================================================	
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SEKMVM		EQU	$
		JSR	SEKMVCS
;
		JSR	ENSTCK
		JSL	>CRENPL2L
;
		PHP
		BCC	SKM007
;;		MEM16
;;		REP	#20H
;;		LDA	PLSVX1
;;		STA	<PLXPS1
;;		LDA	PLSVY1
;;		STA	<PLYPS1
;;		MEM8
;;		SEP	#20H
		JSL	>PLOTCK
;
		JSL	>DASHON		; Player dash hanekairi !
SKM007		EQU	$
;;		LDA	ENSTAT,X
		PLP
;
		LDA	ENTIM0,X
		BNE	SKM008
;
		LDA	ENSTAT,X
		BMI	SKM008
		BNE	SKM010
;
		LDA	INTEKI		;  player Inori !!
		BNE	SKM00C
;
;;		LDA	<KEYA2L
;;		AND	#01000000B
;;		BEQ	SKM008
;
;;		LDA	INTEKI		;  player Inori !!
;;		STA	ENSTAT,X
SKM008		EQU	$
		RTS
;=================================
SKM00C		EQU	$
		STA	ENSTAT,X
		LDA	#80H
		STA	ENTIM0,X
;
		LDA	#07H
		STA	SOUND1		; (S)
SKM010		EQU	$
		BCC	SKM015
;
		LDA	<HANEFG
		BNE	SKM015
;
		LDA	#10H
		STA	<HANEFG
;
		LDA	#20H
		JSL	>PSERCHL
		LDA	<WORK1
		STA	<PLXSPD
		LDA	<WORK0
		STA	<PLYSPD
;
SKM015		EQU	$
		LDY	ENMUKI,X
		LDA	SKMXSD,Y
		STA	ENXSPD,X
		LDA	SKMYSD,Y
		STA	ENYSPD,X
		JSR	ENMVCL
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	SKM020
		LDY	ENMUKI,X
		LDA	SKMMKD,Y
		STA	ENMUKI,X
SKM020		EQU	$
		LDA	#01H
		STA	PYALSP
;
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#01H
		BNE	SKM030
;
		INC	ENCTCT,X
		LDA	ENCTCT,X
		CMP	#82H
		BNE	SKM030		; Move limit  ?
;					; yes !
		LDA	#80H
		STA	ENSTAT,X
;
		STZ	PYALSP
SKM030		EQU	$
		RTS
;- - - -- - --- - -
SKMXSD		EQU	$
NOMXSD		EQU	$
RTXL		EQU	$
RMZSLM		EQU	$
		HEX	10,F0  ;,00,00
SKMYSD		EQU	$
		HEX	00,00,10,F0
SKMMKD		EQU	$
		HEX	3,2,0,1
;- - - - - - - - - - - - - - - - - - -
SEKMVCD		EQU	$
		WORD	0FFF8H,0FFF8H
		HEX	8E,00,00,02
		WORD	00008H,0FFF8H
		HEX	8E,40,00,02
		WORD	0FFF8H,00008H
		HEX	AE,00,00,02
		WORD	00008H,00008H
		HEX	AE,40,00,02
;
;SKCXAD		EQU	$
;		WORD	0FFF8H,08H,0FFF8H,0008H
;SKCYAD		EQU	$
;		WORD	0FFF8H,0FFF8H,08H,08H
;SKCCDT		EQU	$
;		HEX	8E,8E,AE,AE
;SKCADT		EQU	$
;		HEX	00,40,00,40
;SKCOMD		EQU	$
;		WORD	OAM+0140H
;		WORD	OAM+0150H
;		WORD	OAM+0160H
;;
;		WORD	OAM+01D0H
;		WORD	OAM+01E0H
;		WORD	OAM+01F0H
;SKCSBD		EQU	$
;		WORD	OAMSB+0140H/4
;		WORD	OAMSB+0150H/4
;		WORD	OAMSB+0160H/4
;;
;		WORD	OAMSB+01D0H/4
;		WORD	OAMSB+01E0H/4
;		WORD	OAMSB+01F0H/4
;
;- - - - - - - - - - - - - - - - - - - - - - -
SEKMVCS		EQU	$
		LDA	ENTIM0,X
		CMP	#01H
		BNE	SKC000
;
		LDY	#1BH
		STY	SOUND3		; (S)
;
		LDY	#05H
		STY	SOUND1		; (S)
SKC000		EQU	$
		LSR	A
		AND	#01H
		CLC
		ADC	ENXP2L
		STA	ENXP2L
;
;;		LDA	ENSTAT,X
;;		BNE	SKC002
;;;
;;		JSL	>OCHECKL
;;;		LDY	#00H
;;SKC002		EQU	$
;;
		JSR	EPXYCK
		LDA	<WORKF
		CLC
		ADC	#20H
		CMP	#40H
		BCS	SKC003
		LDA	<WORKE
		CLC
		ADC	#20H
		CMP	#40H
		BCS	SKC003
;
		LDA	#04H*4
		JSL	>OAMENT2
SKC003		EQU	$
;		PHP
;
;		LDA	#00H
;		XBA
;		LDA	ENCHPT,X
		MEM16
		REP	#20H
;		ASL	A
;		ASL	A
;		ASL	A
;;
;		ASL	A
;		ASL	A
		LDA	#SEKMVCD
		STA	<WORK8
;
;		LDA	ENWRK0,X
;;		AND	#0000FH
;		ASL	A
;;		PLP
;;		REP	#20H
;;		BCS	SKC080
;;		CLC
;;		ADC	#00006H
;;SKC080		EQU	$
;		TAY
;		LDA	SKCOMD,Y
;		STA	<OAMADR
;		LDA	SKCSBD,Y
;		STA	<OSBADR
;
		MEM8
		SEP	#20H
;
		LDA	#004H
;;		STA	<WORK6
;;		STZ	<WORK7
		JMP	SETO22
;		JSL	>SETOAML22
;
;		RTS
;=======================================
;;		JSR	OAMCHK
;		LDA	ENSTAT,X
;		BNE	SKC002
;;
;		JSL	>OCHECKL
;		LDY	#00H
;SKC002		EQU	$
;;
;		PHX
;		LDX	#03H
;SKC010		EQU	$
;		PHX
;		TXA
;		ASL	A
;		TAX
;		MEM16
;		REP	#00100000B
;		LDA	<WORK0		
;		CLC
;		ADC	SKCXAD,X
;		STA	(<OAMADR),Y
;		AND	#0100H
;		STA	<WORKE
;		LDA	<WORK2
;		CLC
;		ADC	SKCYAD,X
;		INY
;		STA	(<OAMADR),Y
;		CLC
;		ADC	#0010H
;		CMP	#0100H
;		MEM8
;		SEP	#00100000B
;		BCC	SKC020
;		LDA	#0F0H
;		STA	(<OAMADR),Y
;SKC020		EQU	$
;		PLX
;		LDA	SKCCDT,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	SKCADT,X
;		ORA	<WORK5
;		INY
;		STA	(<OAMADR),Y
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDA	#02H
;		ORA	<WORKF
;		STA	(<OSBADR),Y
;		PLY
;		INY
;		DEX
;		BPL	SKC010
;		PLX
;		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;--------------------------------------------
ZTHXDL		EQU	$
		HEX	04,04,FC,10
PLTATE2		EQU	$
		HEX	3,2  ;,0,0
ZTHXDH		EQU	$
		HEX	00,00,FF ;,00
ZTHYDL		EQU	$
		HEX	00,10  ;,08,08
ZTHXDA		EQU	$
		HEX	08,08  ;;,04,04
ZTHYDA		EQU	$
		HEX	04,04,08,08
;ZTHYDH		EQU	$
;		HEX	00,00,00,00
;--------------------------------------------
ZORASM		EQU	$
		LDA	ENWRK3,X
		BNE	ZTM000
;
		JMP	Z2MFFF
ZTM000		EQU	$
;-- ZORA TAMA MOVE
		STA	ENNOCR,X
;
		LDA	ENTIM0,X
		BEQ	ZTM010
;
		LDA	#04H*1
		JSL	>OAMENT3
ZTM010		EQU	$
		JSL	>EN1CSSL
		JSR	ENSTCK
;
		JSL	>ZSZNZST		; zanzoo set !
;
;;		LDA	ENSTAT,X
;;		BEQ	ZT0000
;;;
;;		INC	ENSTAT,X
;;		CMP	#09H
;;		BNE	ZT00F0
;;		STZ	ENMODE,X
;;ZT00F0		EQU	$
;;		LSR	A
;;		STA	ENCHPT,X
;;		RTS
;
ZT0000		EQU	$
;
		JSL	>CRENPLL
		BCC	ZTM011
;
;;		STZ	ENMODE,X
ZTM0111		EQU	$
;;		INC	ENSTAT,X
		STZ	ENMODE,X
		RTS
ZTM011		EQU	$
		JSR	ENMVCL
;- - - - Hit tate check ----
		LDA	<DJFLG
		BEQ	ZTM112
;
;;		LDA	ENWRK2,X
;;		BEQ	ZTM1121		; Shisai beam ?
;					; yes ! BG check !
		LDA	ENTIM1,X
		BNE	ZTM111
ZTM1121		EQU	$
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	ZTM111
;
		JSR	ENBGCK
		BNE	ZTM0111
;
;;		BEQ	ZTM111
;;		STZ	ENMODE,X
ZTM111		EQU	$
;;		BRA	ZTH010
;- - - -
ZTM112		EQU	$
;;		LDA	WCACHOK
;
;;		LDA	<KENMD
;;		DEC	A
;;		CMP	#09H-1
;;		BCC	ZTH010		; Player cut ?
;					; yes !
		LDA	RABFLG
;;;		ORA     DASHFG
;;		ORA	<KENMD
		ORA	MRTKFG
		BNE	ZTH010		; Usagi !
;
		LDA	PYDMBT
		BMI	ZTH010		; Player cach ?
;					; no !
		LDA	>ITMTBL7
		CMP	#02H
		BCC	ZTH010		; tate hi power ?
;					; yes !
		LDA	<PLBGCKF
		CMP	ENKAIF,X
		BNE	ZTH010
;
;		LDA	ENMOD4,X
;		AND	#11011111B
;		STA	ENMOD4,X
;
		JSL	>ENCRST2
		LDA	<PLMKCH
		LSR	A
		TAY
		LDA	<KENMD
		BEQ	ZSLD00		; Kamae ?
		LDA	PLTATE2,Y	; yes !
		TAY
ZSLD00		EQU	$
		LDA	<PLXPS1
		CLC
		ADC	ZTHXDL,Y
		STA	<WORK0
		LDA	<PLXPS0
		ADC	ZTHXDH,Y
		STA	<WORK8
		LDA	ZTHXDA,Y
		STA	<WORK2
;
		LDA	<PLYPS1
		CLC
		ADC	ZTHYDL,Y
		STA	<WORK1
		LDA	<PLYPS0
;;		ADC	ZTHYDH,Y
		ADC	#00H
		STA	<WORK9
		LDA	ZTHYDA,Y
		STA	<WORK3
		JSL	>CROJCK2
		BCC	ZTH010
		JSL	>EFLSST2
;
		STZ	ENMODE,X
;
;;		INC	ENSTAT,X
;
;;		JSL	>SDLRCE
;;		ORA	#06H
;;		STA	SOUND2	;(S)
		LDA	#06H
		JSL	>SDLRE2	;(S)
ZTH010		EQU	$
;;		JSL	>CRENPLL
		RTS
;--------------------------------------------
;--------------------------------------------
Z2MFFF		EQU	$
		LDA	ENSTAT,X
		BNE	Z2M0F8
;
Z2M0F0		EQU	$
		JSL	>OAMCHKL
		BRA	Z2M000
Z2M0F8		EQU	$
		JSR	ZORA2CS
Z2M000		EQU	$
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		BEQ	Z2WAIT
;;		PHA
;;		JSR	CREKEK
;;		PLA
;
		DEC	A
		BEQ	Z2UPJ
		DEC	A
		BEQ	Z2SHOTB
		JMP	Z2DOWN
Z2SHOTB		EQU	$
		JMP	Z2SHOT
;;		JSL	>JSRSUB
;;		WORD	Z2WAIT
;;		WORD	Z2UP
;;		WORD	Z2SHOT
;;		WORD	Z2DOWN
;;		RTS
Z2UPJ		EQU	$
		JMP	Z2UP
;- - - - - - - - - - - - - - - - - - - - -
ZSSXAL		EQU	$
ZSSYAL		EQU	$
		HEX	E0,E8,F0,F8,08,10,18,20 
ZSSXAH		EQU	$
ZSSYAH		EQU	$
		HEX	FF,FF,FF,FF,00,00,00,00
;- - - - - - - - - - - - - - - - - - - - -
Z2WAIT		EQU	$
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	Z2W010
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	ENWRK0,X
		CLC
		ADC	ZSSXAL,Y
		STA	ENXPSL,X
		LDA	ENWRK1,X
		ADC	ZSSXAH,Y
		STA	ENXPSH,X
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	ENWRK2,X
		CLC
		ADC	ZSSYAL,Y
		STA	ENYPSL,X
		LDA	ENKBMK,X
		ADC	ZSSYAH,Y
		STA	ENYPSH,X
;
		JSL	>PSSAVE2
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
		LDA	UNITNO
		CMP	#08H
		BNE	Z2W010	; mizu in ?
;				; yes !
		LDA	#7FH
		STA	ENTIM0,X
		INC	ENSTAT,X
;
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X
Z2W010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
Z2UPTD		EQU	$
		HEX	4,3,2,1,2,1,2,1
		HEX	2,1,2,1,2,1,0,0
;
Z2UP		EQU	$
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	Z2U010
;
		INC	ENSTAT,X
;
		LDA	#7FH
		STA	ENTIM0,X
;
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
		RTS
Z2U010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	Z2UPTD,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
Z2SHPT		EQU	$
		HEX	5,5,6,0A,06,5,5,5
;
Z2SHOT		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	Z2S010
		INC	ENSTAT,X
		LDA	#17H 
		STA	ENTIM0,X
		RTS
Z2S010		EQU	$
		CMP	#30H
		BNE	Z2S020	; tama set ?
		PHA		; yes !
		JSL	>Z2TMSTL
		PLA
Z2S020		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	Z2SHPT,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
Z2DPTD		EQU	$
		HEX	C,B,9,8,7
		HEX	0,0,0,0,0,0,0   
;
Z2DOWN		EQU	$
		LDA	ENTIM0,X
		BNE	Z2D010
		LDA	#80H
		STA	ENTIM0,X
		STZ	ENCHPT,X
		STZ	ENSTAT,X
		RTS
Z2D010		EQU	$
		LSR	A
		LSR	A
;;		NOP
;;		NOP
;;		NOP
		TAY
		LDA	Z2DPTD,Y
		STA	ENCHPT,X
		RTS
;================================================
Z2CXAD		EQU	$
		WORD	04H,04H
		WORD	00H,00H
		WORD	00H,00H
		WORD	00H,00H
		WORD	00H,00H
		WORD	00H,00H
		WORD	00H,00H
		WORD	00H,00H
		WORD	00H,00H
		WORD	0FFFCH,0BH
		WORD	00H,04H
		WORD	0FFF8H,012H
		WORD	0FFF8H,012H
Z2CYAD		EQU	$
		WORD	04H,04H
		WORD	00H,00H
		WORD	00H,00H
		WORD	00H,0FFFDH
		WORD	00H,0FFFDH
		WORD	0FFFDH,0FFFDH 
		WORD	0FFFDH,0FFFDH 
		WORD	0FFFDH,0FFFDH 
		WORD	0FFFAH,0FFFAH 
		WORD	0FFF8H,0FFF7H
		WORD	0FFFDH,0FFFDH+8 
		WORD	0FFF6H,0FFF5H
		WORD	0FFF6H,0FFF5H
Z2CCDT		EQU	$
		HEX	A8,A8
		HEX	88,88
		HEX	88,88
		HEX	88,A4
		HEX	88,A4
		HEX	A4,A4
		HEX	A6,A6
		HEX	A4,C0
		HEX	8A,8A
		HEX	AE,AF
		HEX	A6,8D
		HEX	CF,CF
		HEX	DF,DF
Z2CADT		EQU	$
		HEX	25,25
		HEX	25,25
		HEX	E5,E5
		HEX	25,20
		HEX	E5,20
		HEX	20,20
		HEX	20,20
		HEX	20,24
		HEX	25,25
		HEX	24,64
		HEX	20,26
		HEX	24,64
		HEX	24,64
Z2CSBD		EQU	$
		HEX	00,00
		HEX	02,02
		HEX	02,02
		HEX	02,02
		HEX	02,02
		HEX	02,02
		HEX	02,02
		HEX	02,02
		HEX	02,02
		HEX	00,00
		HEX	02,00
		HEX	00,00
		HEX	00,00
;------------------------------------
ZORA2CS		EQU	$
		JSR	OAMCHK
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
		PHX
		LDX	#01H
Z2C010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#20H
		LDA	<WORK0
		CLC
		ADC	Z2CXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	Z2CYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	Z2C020
		LDA	#0F0H
		STA	(<OAMADR),Y
Z2C020		EQU	$
		PLX
		LDA	Z2CCDT,X
		INY
		STA	(<OAMADR),Y
;
		LDA	#0FH
		STA	<WORKD
;
		LDA	Z2CADT,X
		BIT	<WORKD
		BNE	Z2C030
		ORA	<WORK5
Z2C030		EQU	$		
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	Z2CSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	Z2C010
		PLX
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;;ZBTAMCD		EQU	$
;;		WORD	0FFF4H,0FFFEH
;;		HEX	02,44,00,02
;;		WORD	0000CH,0FFFEH
;;		HEX	02,04,00,02
;;		WORD	00004H,0FFFCH
;;		HEX	30,04,00,00
;;		WORD	00004H,0FFF4H
;;		HEX	20,04,00,00
;;		WORD	0,0
;;		HEX	00,02,00,02
;;;
;;		WORD	0FFF4H,0FFFEH
;;		HEX	04,44,00,02
;;		WORD	0000CH,0FFFEH
;;		HEX	04,04,00,02
;;		WORD	00004H,0FFFCH
;;		HEX	30,44,00,00
;;		WORD	00004H,0FFF4H
;;		HEX	20,44,00,00
;;		WORD	0,0
;;		HEX	00,42,00,02
;;;- --
;;ZBTXAD		EQU	$
;;		HEX	01,FF
;
ZORABM		EQU	$
;;		LDA	ENWRK3,X
;;		BEQ	ZB0010
;;;- - - Tama move - - -
;;		LDA	<FRCNT
;;		LSR	A
;;		LSR	A
;;		AND	#01H
;;		ASL	A
;;		ASL	A
;;		ASL	A
;;		STA	<WORK0
;;;
;;		ASL	A
;;		ASL	A
;;		ADC	<WORK0
;;		ADC	#LOW  ZBTAMCD
;;		STA	<WORK8
;;		LDA	#HIGH ZBTAMCD
;;		ADC	#000H
;;		STA	<WORK9
;;;
;;		LDA	#005H
;;		STA	<WORK6
;;		STZ	<WORK7
;;		JSL	>SETOAML2
;;;
;;		JSL	>CRENPLL
;;		JSR	ENMVCL
;;;
;;		JSR	EPXCHK
;;		LDA	<FRCNT
;;		AND	#07H
;;		BNE	ZBT010
;;;
;;		LDA	ENXSPD,X
;;		CLC
;;		ADC	ZBTXAD,Y
;;		STA	ENXSPD,X		
;;ZBT010		EQU	$
;;		RTS
;;;
;- - master move - -
ZB0010		EQU	$
;;		LDA	ENMODE,X
;;		CMP	#EMOVE
;;		BEQ	ZRBM10
;-;; - - FAIL TEST ! --
;;		LDA	#02H
;;		JSL	>BSITEM
;;;
;;		JSR	BOSAVE
;;;
;;		LDY	#ENNO-1
;;ZRBM08		EQU	$
;;		LDA	ENMODE,Y
;;		BEQ	ZRBM09
;;;
;;		LDA	#EFAIL
;		STA	ENMODE,Y
;;		LDA	#0FH
;;		STA	ENTIM0,Y
;;;
;;		LDA	#00H
;;		STA	ENMOD2,Y
;;		LDA	#03H
;;		STA	ENMOD0,Y
;;;
;;ZRBM09		EQU	$
;;		DEY
;;		BPL	ZRBM08
;;;
;;		STZ	ENMODE,X
;;		RTS
;-----------------------------------------
;;ZRBM10		EQU	$
;;		LDA	ENWRK2,X
;;		BEQ	ZB0000
;;;
;;		JMP	ZORA2MV
;- - - - BIG ZORA - - - - - - -
;
ZB0000		EQU	$
;;		LDA	ENFLSH,X
;;		BEQ	ZB0F20
;;;
;;		LSR	A
;;		LSR	A
;;		AND	#01H
;;		INC	A
;;		STA	ENCHPT,X
;;ZB0F20		EQU	$
		JSR	ZORABCS
;
;;		LDA	<KEYA2
;;		AND	#0CH
;;		BEQ	ZBM010
;;;
;;		INC	ENCHPT,X
;;;
;;		LDA	ENCHPT,X
;;		CMP	#0AH
;;		BNE	ZBM010
;;		STZ	ENCHPT,X
;;ZBM010		EQU	$
;;		LDA	<KEYA2
;;		AND	#80H
;;		BEQ	ZBM020
;;		LDA	#0FH
;;		STA	ENTIM2,X
;;ZBM020		EQU	$
;;		RTS
;
		JSR	ENSTCK
;
;		JSR	ZORA2ST
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	ZBWAIT
		WORD	ZBTILT
		WORD	ZBUP
		WORD	ZBSHOT
		WORD	ZBDOWN
;;		RTS
;- - - - - - - - - - - - - - - - - - - - -
ZBSTXS		EQU	$
		HEX	28,78,C8,78
ZBSTYS		EQU	$
		HEX	60,50,70,50
;
;;		HEX	30+30,20+30,40+30,20+30
;
ZBWAIT		EQU	$
;;		LDA	ENTIM0,X
;;		STA	ENNOCR,X
;;		BNE	ZBW010
		MEM16
		REP	#20H
		LDA	<PLXPS1
		SEC
		SBC	ENXP2L
		CLC
		ADC	#0010H
		CMP	#0020H
		BCS	ZBW010
		LDA	<PLYPS1
		SEC
		SBC	ENYP2L
		CLC
		ADC	#0030H
		CMP	#0060H
		BCS	ZBW010		; Area in ?
;					; yes !
		MEM8
		SEP	#20H
;					; Sares start !
		JSL	>DASCLR1	; 
;
		LDA	#7FH
		STA	ENTIM0,X
;
		LDA	#35H
		STA	SOUND2	;(S)
;
		INC	ENSTAT,X
;
;;		JSL	>RNDSET
;;		AND	#03H
;;		TAY
;;		STA	ENKBMK,X
;;		LDA	ZBSTXS,Y
;;		STA	ENXPSL,X
;;		LDA	ZBSTYS,Y
;;		STA	ENYPSL,X
;
		LDY	#ENNO-1
ZBCL10		EQU	$
		CPY	ENINDX
		BEQ	ZBCL20
;
;;		LDA	#00H
;;		STA	ENMODE,Y
		LDA	ENMOD5,Y
		BMI	ZBCL20		; UTUWA not clear !
;
		PHX
		TYX
		PHY
;
		LDA	ENMODE,X
		CMP	#ECACH
		BNE	ZBCL18
;
		STZ	PYDMBT
		STZ	PYDMBT+1
ZBCL18		EQU	$
		JSL	>ENCLER
		PLY
		PLX
ZBCL20		EQU	$
		DEY
		BPL	ZBCL10
;
ZBW010		EQU	$
		MEM8
		SEP	#20H
		RTS
;=================================================
NZTLDT          EQU     $
ZS2XAL		EQU	$
RTXD		EQU	$
		HEX	01,FF
;;;                HEX     01,FF
;
                HEX     00,FF
ZBTILT		EQU	$
		LDA	ENTIM0,X
		BNE	ZBT010
;
		INC	ENSTAT,X
;
		LDA	#7FH
		STA	ENTIM0,X
;
		STZ	YUREXD
		STZ	YUREXD+1
;
		LDA	#04H
		STA	ENCHPT,X
;
;;LDA	#05H
;;STA	SOUND1	;(S)
		RTS
ZBT010		EQU	$
                AND     #01H
                TAY
                LDA     NZTLDT,Y
                STA     YUREXD
                LDA     NZTLDT+2,Y
                STA     YUREXD+1
;
		LDA	#01H
		STA	PYALSP
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
ZBUPTD		EQU	$
		HEX	0,0,0,3,9,8,7,6  
		HEX	9,8,7,6,5,4,5,4
;
ZBUP		EQU	$
		LDA	ENTIM0,X
		BNE	ZBU010
		INC	ENSTAT,X
		LDA	#7FH
		STA	ENTIM0,X
		RTS
ZBU010		EQU	$
		CMP	#01CH
		BNE	ZBU012
		PHA
		LDA	#0FH
		STA	ENTIM2,X
		JSR	MIZUST
		PLA
ZBU012		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	ZBUPTD,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
ZBSHPT		EQU	$
		HEX	0,0,1,02,01,2,0,0
;
ZBSHOT		EQU	$
		LDA	ENTIM0,X
		BNE	ZBS010
		INC	ENSTAT,X
;;		LDA	#08H
		LDA	#24H
		STA	ENTIM0,X
		RTS
ZBS010		EQU	$
;;		CMP	#40H
;;		BNE	ZBS020
;;		PHA
;;;		JSR	ZBTAMST
;;;		MESEGE SET !
;;		PLA
ZBS020		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	ZBSHPT,Y
		STA	ENCHPT,X
;
		LDA	ENTIM0,X
		CMP	#050H
		BEQ	ZBMS00
		CMP	#04FH
		BEQ	ZBMS01
		CMP	#04EH
		BEQ	ZBMS08
		CMP	#04DH
		BEQ	ZBMS10
		RTS
;=============================================
ZBMS00		EQU	$
		LDA	#MS_04E0
ZBMSST		EQU	$
		STA	MSGENOL
		LDA	#01H
		STA	MSGENOH
		JSL	>MSGSET
		RTS
;=============================================
ZBMS01		EQU	$
		LDA	MSG_RTS
		BNE	ZBMS02		; Yes , no
;					; yes !
		LDA	#MS_04E1
		JSR	ZBMSST
		RTS
;
;=============================================
ZBMS08		EQU	$
		LDA	MSG_RTS
		BNE	ZBMS03		; Yes , no
;
                MEM16			; Yes !
                REP     #00100000B
                LDA     >CONCNT
		SEC
                SBC     #0500
                BCC     ZBMS03          ; Have money ?
;
                STA     >CONCNT
                MEM8
                SEP     #20H
;
		LDA	#MS_04E2
		JSR	ZBMSST
;
		INC	ENWRK3,X
		RTS
;
ZBMS02		EQU	$
		LDA	#MS_04E4	; no
		JSR	ZBMSST
		LDA	#30H
		STA	ENTIM0,X
		RTS
;- - - - - - - - - - - - -
ZBMS03		EQU	$		; Not money 
                MEM8
                SEP     #00100000B
		LDA	#MS_04E3
		JSR	ZBMSST
		LDA	#30H
		STA	ENTIM0,X
		RTS
;=============================================
ZBMS10		EQU	$
		LDA	ENWRK3,X
		BEQ	ZBMS20
;
		JSL	>HIREST		; Item hire set !
;
ZBMS20		EQU	$
		RTS
;;- - - - - - - - - - - - - - - - - - - - - -
;ZBTSNO		EQU	$
;		HEX	02,01,02,01
;ZBTSXL		EQU	$
;		HEX	60,90,C0,0
;		HEX	40,B0,0,0
;		HEX	20,70,A0,0
;		HEX	40,B0,0,0
;;
;ZBTAMST		EQU	$
;		LDY	ENKBMK,X
;		LDA	ZBTSNO,Y
;		STA	ENHELP
;;
;ZBTS10		EQU	$
;		LDA	#ZORAB
;		JSL	>ENIDSH
;		BMI	ZBTS20
;;
;		PHX
;;
;		LDA	ENKBMK,X
;		ASL	A
;		ASL	A
;		ORA	ENHELP
;		TAX
;		LDA	ZBTSXL,X
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	#00H
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
;		PLX
;;
;		LDA	#04H
;		STA	ENMOD0,Y
;		LDA	#01000001B
;		STA	ENCLOR,Y
;		LDA	#00H
;		STA	ENMOD3,Y
;		LDA	#20H
;		STA	ENYSPD,Y
;		STA	ENWRK3,Y
;;
;		DEC	ENHELP
;;		BPL	ZBTS10
;ZBTS20		EQU	$
;		RTS
;- - - - - - - - - - - - - - - - - - - - - -
ZBDPTD		EQU	$
		HEX	C,C,C,C,C,C,B,B,B,B,B,A,A,A,A,3  
		HEX	3,3,3,3,3
;
ZBDOWN		EQU	$
		LDA	ENTIM0,X
		BNE	ZBD010
;;		LDA	#80H
;;		STA	ENTIM0,X
;;		STZ	ENSTAT,X
;;		STZ	ENMODE,X
		JSL	>ENCLER
		STZ	PYALSP
;;;;;;;;;		STZ	ENSTFG
		RTS
ZBD010		EQU	$
		CMP	#1DH
		BNE	ZBD012
		PHA
		LDA	#0FH
		STA	ENTIM2,X
		JSR	MIZUST
		PLA
ZBD012		EQU	$
		LSR	A
;	LSR	A
;		NOP
		TAY
		LDA	ZBDPTD,Y
		STA	ENCHPT,X
		RTS
;====================================================
KDFXAD		EQU	$
		HEX	F8,FB,04,0D
		HEX	10,0D,04,FB
KDFXAH		EQU	$
		HEX	FF,FF,00,00
		HEX	00,00,00,FF
KDFYAD		EQU	$
		HEX	04,FB,F8,FB
		HEX	04,0D,10,0D
KDFYAH		EQU	$
		HEX	00,FF,FF,FF
		HEX	00,00,00,00
KDFXSD		EQU	$
		HEX	F8,FA,00,06
		HEX	08,06,00,FA
KDFYSD		EQU	$
		HEX	00,FA,F8,FA
		HEX	00,06,08,06
;====================================================
MIZUSTL		EQU	$
		PHB
		PHK
		PLB
		JSR	MIZUST
		PLB
		RTL
;------------------------------------
MIZUST		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#24H
;;		STA	SOUND2	;(S)
		LDA	#24H
		JSL	>SDLRE2	;(S)
;
		nop
;
		LDA	#07H
		STA	<WORKD
KF00D0		EQU	$
		LDA	#OCTA1
		JSL	>ENIDSH
		BMI	KF00F0
;
		LDA	#EWATR
		STA	ENMODE,Y
;
		PHX
		LDX	<WORKD
		LDA     KDFXAD,X
		SEC
		SBC	#04H
		CLC
		ADC	<WORK0
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	KDFXAH,X
		STA	ENXPSH,Y
		LDA	KDFYAD,X
		SEC
		SBC	#04H
		CLC
		ADC	<WORK2
		STA	ENYPSL,Y
		LDA	<WORK3
		ADC	KDFYAH,X
		STA	ENYPSH,Y
;
		LDA	KDFXSD,X
		STA	ENXSPD,Y
		LDA	KDFYSD,X
		STA	ENYSPD,Y
		TXA
		STA	ENWRK0,Y
		PHY
		JSL	>RNDSET
		PLY
		AND	#0FH
		ADC	#018H
		STA	ENZSPD,Y
		LDA	#01H
		STA	ENSTAT,Y
		LDA	#00H
		STA	ENZPSL,Y
;
		LDA	ENMOD2,Y
		ORA	#01000000B
		STA	ENMOD2,Y
		STA	ENNOCR,Y
;
		PLX
KF00F0		EQU	$
		DEC	<WORKD
		BPL	KF00D0
		RTS
;;====================================================
;ZORA2ST		EQU	$
;;		LDA	<FRCNT
;		AND	#7FH
;		BNE	ZR2S90
;;
;		LDY	#02H		; Kazu !
;		LDA	#ZORA2
;		JSL	>ENIDSH2
;		BMI	ZR2S90
;;
;		JSL	>RNDSET
;		AND	#07H
;		PHX
;		TAX
;		LDA	<SCCH2
;		CLC
;		ADC	ZR2SXL,X
;		STA	ENXPSL,Y
;		LDA	<SCCH2+1
;		ADC	#00H 
;		STA	ENXPSH,Y
;;
;		JSL	>RNDSET
;		AND	#07H
;		TAX
;		LDA	<SCCV2
;		CLC
;		ADC	ZR2SYL,X
;		STA	ENYPSL,Y
;		LDA	<SCCV2+1
;		ADC	#00H 
;		STA	ENYPSH,Y
;;
;		PLX
;ZR2S90		EQU	$
;		RTS
;- - - - - - - - - - - - - - - - - -
;ZR2SXL		EQU	$
;		HEX	60,68,70,78,80,88,90,98
;ZR2SYL		EQU	$
;		HEX	80,88,90,98,A0,A8,B0,B8
;;		HEX	60,68,70,78,80,88,90,98
;====================================================
ZBCXAD		EQU	$
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	00,00,00,00
		HEX	00,00,00,00
;
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
;
		HEX	F7,09,F7,09
		HEX	F6,0A,F6,0A
		HEX	F5,0B,F5,0B
ZBCYAD		EQU	$
		HEX	EE,EE,FE,FE
		HEX	EE,EE,FE,FE
		HEX	EE,EE,FE,FE
		HEX	F4,F4,04,04
		HEX	00,00,00,00
		HEX	00,00,00,00
;
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
		HEX	F8,F8,08,08
;
		HEX	FB,FB,05,05
		HEX	FB,FB,05,05
		HEX	FB,FB,05,05
ZBCCDT		EQU	$
		HEX	C0,C0,E0,E0
		HEX	C2,EA,E2,E2
		HEX	EA,C2,E2,E2
		HEX	C0,C0,E4,E6
		HEX	88,88,88,88
		HEX	88,88,88,88
		HEX	C4,C6,E4,E6
		HEX	C6,C4,E6,E4
		HEX	E6,E4,C6,C4
		HEX	E4,E6,C4,C6
;
		HEX	88,88,88,88
		HEX	88,88,88,88
		HEX	88,88,88,88
ZBCADT		EQU	$
		HEX	00,40,00,40
		HEX	00,40,00,40
		HEX	00,40,00,40
		HEX	00,40,05,05
		HEX	05,05,05,05
		HEX	C5,C5,C5,C5
		HEX	05,05,05,05
		HEX	45,45,45,45
		HEX	C5,C5,C5,C5
		HEX	85,85,85,85
;
		HEX	04,44,84,C4
		HEX	04,44,84,C4
		HEX	04,44,84,C4
;- - - - - - -
ZBWXAD		EQU	$
		HEX	E9,17,17,17
		HEX	EC,F1,0D,12
ZBWYAD		EQU	$
		HEX	F8,F8,F8,F8 
		HEX	F9,00,00,F9
ZBWCDT		EQU	$
		HEX	AE,AE,AE,AE
		HEX	AC,AC,AC,AC
ZBWADT		EQU	$
		HEX	00,40,40,40
		HEX	00,00,40,40
;- - - - - - - - - - - - - - - - - - - - - - - -
ZORABCS		EQU	$
		JSR	OAMCHK
;
		LDA	ENSTAT,X
		CMP	#02H
		BCC	ZB0F00
;
		LDA	ENCHPT,X
;;		ASL	A
		ASL	A
		ASL	A
		STA	<WORK6
		PHX
		LDX	#03H
ZBC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	ZBCXAD,X
		STA	(<OAMADR),Y
		INY
		LDA	ZBCYAD,X
		CLC
		ADC	<WORK2
		STA	(<OAMADR),Y
		LDA	ZBCCDT,X
		INY
		STA	(<OAMADR),Y
;
		LDA	#0FH
		STA	<WORKF
;
		LDA	ZBCADT,X
		BIT	<WORKF
		BNE	ZBC023
		ORA	<WORK5
ZBC023		EQU	$
		INY
		ORA	#20H
		STA	(<OAMADR),Y
;;		PHY
;;		TYA
;;		LSR	A
;;		LSR	A
;;		TAY
;;		LDA	#02H
;;		STA	(<OSBADR),Y
;;		PLY
		INY
		PLX
		DEX
		BPL	ZBC010
		PLX
;
		LDY	#02H
		LDA	#03H
		JSL	>ALOMCKL
;
		JSR	OAMCHK
ZB0F00		EQU	$
		LDA	ENTIM2,X
		BEQ	ZBC030		; mizu shibuki ?
;					; yes !
		LSR	A
		AND	#00000100B
		STA	<WORK6
;
		LDA	#04H*4
		JSL	>OAMENT3
		LDY	#00H
;
		PHX
		LDX	#03H
ZBC028		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	ZBWXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	ZBWYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	ZBWCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	ZBWADT,X
		ORA	#24H
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	ZBC028
		PLX
ZBC030		EQU	$
		RTS
;		
;
;
;
;
;
;
;
;
;=========================================================
;-- ko zora --
ZORA2M		EQU	$
ZORA2MV		EQU	$
;;		STZ	ENMOD3,X
		LDA	ENHNFG,X
		BEQ	ZSM010		; damage ?
;					; yes !
		STZ	ENHNFG,X
;
		LDA	#03H
		STA	ENWRK1,X
		LDA	#0C0H
		STA	ENCTCT,X
		LDA	ENHNXS,X
		STA	ENXSPD,X
		ASL	A
		ROR	ENXSPD,X
		LDA	ENHNYS,X
		STA	ENYSPD,X
		ASL	A
		ROR	ENYSPD,X
ZSM010		EQU	$
;
		LDA	ENWRK1,X
		JSL	>JSRSUB
		WORD	ZSWAIT
		WORD	ZSJUMP
		WORD	ZSWALK
		WORD	ZSSTOP		
;----------------------------------------
ZSWAIT		EQU	$
		JSL	>OAMCHKL
		JSR	ENSTCK
;
		LDA	ENTIM0,X
		BNE	ZSW010
;
		LDA	#7FH
		STA	ENTIM0,X
		INC	ENWRK1,X
;
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X
ZSW010		EQU	$
		RTS
;----------------------------------------
ZSJUMP		EQU	$
		JSR	ZORA2CS		; mizu uzu set !
;
		JSR	ENSTCK
;
		LDA	ENTIM0,X
		STA	ENNOCR,X
		BNE	ZSJ010
;
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
;
;;		JSL	>SDLRCE
;;		ORA	#28H
;;		STA	SOUND2	;(S)
		LDA	#28H
		JSL	>SDLRE2	;(S)
;
		INC	ENWRK1,X
		LDA	#030H
		STA	ENZSPD,X
;;		LDA	#10H
;;		JSL	>PSERCHL
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
		RTS
ZSJ010		EQU	$
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	Z2UPTD,Y
		STA	ENCHPT,X
		RTS
;----------------------------------------
;;ZSWXSD		EQU	$
;;		HEX	08,F8,00,00
;;ZSWYSD		EQU	$
;;		HEX	00,00,08,F8
;- - - - - - -
ZSWALK		EQU	$
		LDA	ENCONT,X
		AND	#00001000B
		LSR	A
		ADC	ENMUKI,X
		TAY
		LDA	ZKCHPT,Y
		STA	ENCHPT,X		
		JSR	ZORASCS
;
		JSR	ENSTCK
;
;;		LDA	#03H
;;		STA	ENCLOR,X
;
;L		LDA	ENHNFG,X
;L		BEQ	ZSM010		; damage ?
;L;					; yes !
;L;;		CMP	#0DH
;L;;		BNE	ZSM00E
;L;;		LDA	#05H
;L;;		STA	ENHNFG,X
;L;;ZSM00E		EQU	$
;L		STZ	ENHNFG,X
;L;
;L		LDA	#03H
;L		STA	ENWRK1,X
;L		LDA	#0C0H
;L		STA	ENCTCT,X
;L		LDA	ENHNXS,X
;L		STA	ENXSPD,X
;L		LDA	ENHNYS,X
;L		STA	ENYSPD,X
;LZSM010		EQU	$
;;;		JSR	ENHNSB
;
		JSR	CREKEK
;
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
;
		LDA	ENZPSL,X
		DEC	A
		BPL	ZSW050		; jump !!
;- - - On foot ------------------
		LDA	ENZSPD,X
		CMP	#0F0H
		BPL	ZSM013
;
		JSR	H0SDCL
;
ZSM013		EQU	$
		STZ	ENZPSL,X
		STZ	ENZSPD,X
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	ZSW050
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	ZSW050
;
		TYA
		STA	ENMUKI,X
;ZS2010		EQU	$	
		LDA	#08H
		JSL	>PSERCHL
;
;;		LDY	ENMUKI,X
;;		LDA	ZSWXSD,Y
;;		STA	ENXSPD,X	
;;		LDA	ZSWYSD,Y
;;		STA	ENYSPD,X
ZSW050		EQU	$
		JSR	ENMVCL	
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		LDA	ENZPSL,X
		DEC	A
		BPL	ZSW060
;
		JSR	Z2MZCK
;
		LDA	UNITNO
		CMP	#08H
		BNE	ZSW060		; MIZU IN ?
;					; YES !
		JSL	>ENCLER		; Data  Bit rivers
;
;;		JSL	>SDLRCE
;;		ORA	#28H
;;		STA	SOUND2	;(S)
		LDA	#28H
		JSL	>SDLRE2	;(S)
;
                LDA     #EWATR          ;  
                STA     ENMODE,X
                LDA     #00001111B
                STA     ENTIM0,X
                STZ     ENSTAT,X
;
                LDA     #03H
                STA     ENMOD0,X
;
ZSW060		EQU	$
		JSR	ZKPTST
		RTS
;- - - - - - - - - - - - - - - -
;----------------------------
ZSSTOP		EQU	$
		JSL	>CRKNENL
;
;;		LDA	#0DH
;;		STA	ENCLOR,X
;;		LDY	ENTIM2,X
		LDA	<FRCNT
		AND	#03H
		BNE	ZSS010
;
		DEC	ENCTCT,X	; Stop time !
		BNE	ZSS010
;
		LDA	#02H
		STA	ENWRK1,X		
		LDY	ENMODE,X
		LDA	#EMOVE
		STA	ENMODE,X
;
;;		LDA	ENMOD5,X
;;		AND	#11110111B
;;		STA	ENMOD5,X
;
		CPY	#ECACH
		BNE	ZSS010
;
         	STZ     PYDMBT
	        STZ     PYDMBT1
ZSS010		EQU	$
		LDA	ENCTCT,X
		CMP	#030H
		BCS	ZSS020
;;		TYA
;;		NOP
		LDA	<FRCNT
		AND	#01H
		BNE	ZSS020
		LDA	<FRCNT
;;		TYA
		LSR	A
		AND	#01H
		TAY
		LDA	ZS2XAL,Y
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,X
		LDA	ZS2XAH,Y
		ADC	ENXPSH,X
		STA	ENXPSH,X
ZSS020		EQU	$
		STZ	ENCHPT,X
		STZ	ENCBFG,X
;
		JSR	Z2MIZST
		DEC	ENMOD0,X
		DEC	ENMOD0,X
		JSL	>EN1CSTL
		INC	ENMOD0,X
		INC	ENMOD0,X
;
		STZ	ENCTFG,X
		JSR	ENSTCK
		JSR	ENHNSB
;
		JSR	ENMVCL
;;;;;		JSL	>ENBGCKL
		JSL	>ENBDSBL
;
Z2MZCK		EQU	$
		STZ	ENCTFG,X
;
		LDA	ENZPSL,X
		BNE	Z2MC10
;
		LDA	UNITNO
		CMP	#09H
		BNE	ZSS022
;
		INC	ENCTFG,X	; Asase in !
Z2MC10		EQU	$
ZSS022		EQU	$
		RTS
;- - - - - - - - - -
;ZS2XAL		EQU	$
;		HEX	01,FF
ZS2XAH		EQU	$
		HEX	00,FF
;=======================================
ZSHDCD		EQU	$
		BYTE	0CEH,0CEH,0A4H,0EEH
ZSHDAD		EQU	$
		BYTE	040H,000H,000H,000H
;
ZSCCDT		EQU	$
		HEX	CC,EC,CC,EC,E8,E8,CA,CA
ZSCADT		EQU	$
		HEX	40,40,00,00,00,40,00,40
;- - - - - - - - - - - - - - - - - - - - - - - -
ZORASCS	        EQU	$
;- - Muzu set - -
		JSR	Z2MIZST
;- Body set 
		JSR	O2TEST
;
		LDY	#00H
		LDA	ENCHPT,X
		STA	<WORK6
		CMP	#04H
		BCS	ZSC000
		LSR	A
		MEM16
		REP	#00100000B
		LDA	<WORK2
		SBC	#00H
		STA	<WORK2
		MEM8
		SEP	#00100000B
ZSC000		EQU	$
;- head -
		PHX
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		SEC
		SBC	#06H
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	ZSC012
		LDA	#00F0H
		STA	(<OAMADR),Y
ZSC012		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	ZSHDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	ZSHDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
;
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR)
; Body --
		LDA	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0 
		INY
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		INC	A
		INC	A
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	ZSBC10
;
		LDA	#00F0H
		STA	(<OAMADR),Y
ZSBC10		EQU	$
		MEM8
		SEP	#00100000B
;
		PLX
		LDA	ZSCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	ZSCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
;
		LDY	#01H
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
;
;;;		LDA	ENZPSL,X
		LDA	ENCTFG,X
		BNE	ZSBC28		; Not mizu ?
;					; yes !
		JSL	>SADWSTL
ZSBC28		EQU	$
		RTS
;========= Ashi mizu set ============
Z2MIZCD		EQU	$
		WORD	00000H,0000AH
		HEX	D8,01,00,00
		WORD	00008H,0000AH
		HEX	D8,41,00,00
;
		WORD	00000H,0000AH
		HEX	D9,01,00,00
		WORD	00008H,0000AH
		HEX	D9,41,00,00
;
		WORD	00000H,0000AH
		HEX	DA,01,00,00
		WORD	00008H,0000AH
		HEX	DA,41,00,00
;
Z2MPTD		EQU	$
		HEX	00,10,20,10
;- - - - - - - - - - - - - - - - - - - - - - - -
Z2MIZST		EQU	$
;;		LDA	ENZPSL,X
		LDA	ENCTFG,X
		BEQ	Z2CC10		; Asase in ?
;					; yes !
Z2MIZST2	EQU	$
		JSL	>MZSUB
;
		MEM16
		REP	#00100000B
		LDA	<OAMADR
		CLC
		ADC	#0008H
		STA	<OAMADR
;
		INC	<OSBADR
		INC	<OSBADR
;
		MEM8
		SEP	#00100000B
;
Z2CC10		EQU	$
		RTS
;====================================
MZSUB		EQU	$
		PHB
		PHK
		PLB
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#03H
		TAY
		LDA	Z2MPTD,Y
;;		ASL	A
;;		ASL	A
;;		ASL	A
;;;
;;		ASL	A
		CLC
		ADC	#LOW  Z2MIZCD
		STA	<WORK8
		LDA	#HIGH Z2MIZCD
		ADC	#000H
		STA	<WORK9
;
		LDA	#002H
;;		STA	<WORK6
;;		STZ	<WORK7
		JSR	SETO22
;;		JSL	>SETOAML22
;
		LDY	#03H
		LDA	(<OAMADR),Y
		AND	#00110000B
		ORA	#00000100B
		STA	(<OAMADR),Y
		LDY	#07H
		ORA	#40H
		STA	(<OAMADR),Y
		PLB
		RTL
;-------------------------------
ASIMZST		EQU	$
		PHB
		PHK
		PLB
		JSR	Z2MIZST2
		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NMFLPT		EQU	$
		HEX	5,4,3,2,1
;
NOMOSM		EQU	$
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
;
		JSR	NOMOSCS
		JSR	ENSTCK2
;
		LDA	ENMODE,X
		CMP	#EMOVE
		BEQ	NMM000
;
		LDA	ENTIM0,X
		BNE	NMF010
;
		DEC	NMFLCT
		LDA	NMFLCT
		CMP	#01H
		BNE	NMF002	; Last one ?
;				; yes !
		LDY	#05H
NMF0111		EQU	$
		LDA	#48
		STA	ENLIFE,Y	; Stats reset !
		LDA	#00H
		STA	ENXSPD,Y
		STA	ENYSPD,Y
		STA	ENZSPD,Y
		DEY
		BPL	NMF0111
;
;;		LDA	#48
;;		STA	ENLIFE
;;		STA	ENLIFE+1
;;		STA	ENLIFE+2
;;		STA	ENLIFE+3
;;		STA	ENLIFE+4
;;		STA	ENLIFE+5
NMF002		EQU	$
		STZ	ENMODE,X
;
		JSL	>EFLCHK
		BCC	NMF008	; All nomos failed ?
;				; yes ! open door !
;;		LDA	#01H
;;		STA	SWCHFG
;;
                LDA     #UTUWA          ; Heart utsuwa set !
                JSR     >ENIDSH
                JSL     >ENIDPS
                LDA     #020H
                STA     ENZSPD,Y
;
		LDA	#01H
		STA	ENWRK0,Y
;;		JSL	>BSITEM
;
;;                LDY     #13H
;;                STY     SOUND0  ;(S)
BOSAVE		EQU	$
;;		LDA	EMYSTT		; Save data on !
;;		ORA	#10000000B
;;		STA	EMYSTT
NMF008		EQU	$
		RTS	
;- - - - - - - - -- - - - - - - - - - --
NMF010		EQU	$
		LSR	A
		LSR	A
		LSR	A
;;;		AND	#03H
		TAY
		LDA	NMFLPT,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - - - - - - - - - -
NMM000		EQU	$
		JSR	ENMVCL
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#04H
		STA	ENZSPD,X
;
		LDA	ENZPSL,X
		BPL	NOM1F0
;
		STZ	ENZSPD,X
		STZ	ENZPSL,X
;
		LDA	NMFLCT
		CMP	#01H
		BEQ	NOM110
;
		LDA	ENWRK0,X
		BEQ	NOM110
;
		LDA	#30H
		STA	ENZSPD,X
;
;;		JSL	>SDLRCE
;;		ORA	#21H
;;		STA	SOUND2	;(S)
		LDA	#16H
		JSL	>SDLRE3	;(S)
;
NOM110		EQU	$
;;		JSR	H0SDCL
NOM1F0		EQU	$
		LDA	ENHNFG,X
		BEQ	NOM1F8
;
		JSR	H0SDCL
;
		STZ	ENSTAT,X
		STZ	ENCTCT,X
NOM1F8		EQU	$
		JSR	ENHNSB
;
		LDA	ENWRK0,X
		BNE	NOM100
;
		LDA	ENTIM0,X
		BNE	NOM000
;
		INC	ENWRK0,X
;
		LDA	ENMOD0,X
		AND	#01111111B
		DEC	A
		DEC	A		; OAM-08H
		STA	ENMOD0,X
;
		LDA	ENMOD5,X
		AND	#11111011B
		STA	ENMOD5,X
;
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
;
;;		LDA	ENCLOR,X
;;		AND	#11110001B
;;		ORA	#08H
;;		LDA	#08H+1
;;		STA	ENCLOR,X
		RTS
;- - - - - - - - - - - - - - - - - - -- -
;NOMXSD		EQU	$
;		HEX	10,F0
;
NOM000		EQU	$
		CMP	#40H
		BNE	NOM001
;
		LDY	#35H
		STY	SOUND2	;(S)
NOM001		EQU	$
		BCS	NOM010
;
		LSR	A
		EOR	ENINDX
		AND	#01H
		TAY
		LDA	NOMXSD,Y
		STA	ENXSPD,X
		JSR	ENXCLC
		STZ	ENXSPD,X
NOM010		EQU	$
		JSL	>CRKNENL
		JSL	>CRENPL2L
		BCC	NOM020
;;		MEM16
;;		REP	#00100000B
;;;
;;		LDA	PLSVX1
;;		STA	<PLXPS1
;;		LDA	PLSVY1
;;		STA	<PLYPS1
;;;
;;		MEM8
;;		SEP	#020H
		JSL	>PLOTCK
;
		JSL	>DASHON		; Player dash hanekairi !
NOM020		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - -- -
NOM100		EQU	$
		LDA	NMFLCT
		CMP	#01H
		BEQ	NOM300
;
		JSR	CREKEK
;
		LDA	ENSTAT,X
		BNE	NOM200
;
;======Serch the way================================================
		JSR	NMSERC
		JSL	>PSSAVE2
		MEM16
		REP	#20H
		LDA	<WORK4
		SEC
		SBC	ENXP2L
		CLC
		ADC	#02H
		CMP	#04H
		BCS	NOM180		
;
		LDA	<WORK6
		SEC
		SBC	ENYP2L
		CLC
		ADC	#02H
		CMP	#04H
		BCS	NOM180
;
		MEM8
		SEP	#20H
		INC	ENSTAT,X
NOM180		EQU	$
		MEM8
		SEP	#20H
		RTS
;======Lock the way================================================
NOM200		EQU	$
		LDA	PTBFXL,X
		STA	ENXPSL,X
		LDA	PTBFXH,X
		STA	ENXPSH,X
		LDA	PTBFYL,X
		STA	ENYPSL,X
		LDA	PTBFYH,X
		STA	ENYPSH,X
		RTS
;=======Last 1 player serch jump===============================================
NOM300		EQU	$
		JSL	>NMSHJP
		RTS
;
;======================================================
NMSERC		EQU	$
		LDA	PTBFXL,X
		STA	<WORK4
		LDA	PTBFXH,X
		STA	<WORK5
		LDA	PTBFYL,X
		STA	<WORK6
		LDA	PTBFYH,X
		STA	<WORK7
;
		LDA	#10H
		JSL	>ESERCHL
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
		RTS
;
;		LDA	#10H
;		JSL	>PSERCHL
;;- - - - NOMOS VS NOMOS HIT CHECK ! - - - - - - - -
;NOM110		EQU	$
;		TXY
;		DEY
;NOM120		EQU	$
;		LDA	ENMODE,Y
;		BEQ	NOM123
;		LDA	ENMYNO,Y
;		CMP	#NOMOS
;		BEQ	NOM125
;;
;NOM123		EQU	$
;		JMP	NOM190
;;
;NOM125		EQU	$
;		LDA	ENXPSL,X
;		STA	<WORK0
;		LDA	ENXPSH,X
;		STA	<WORK1
;		LDA	ENYPSL,X
;		SEC
;		SBC	ENZPSL,X
;		STA	<WORK2
;		LDA	ENYPSH,X
;		SBC	#00H
;		STA	<WORK3
;;
;		LDA	ENXPSL,Y
;		STA	<WORK4
;		LDA	ENXPSH,Y
;		STA	<WORK5
;		LDA	ENYPSL,Y
;		SEC
;		SBC	ENZPSL,Y
;		STA	<WORK6
;		LDA	ENYPSH,Y
;		SBC	#00H
;		STA	<WORK7
;;
;		MEM16
;		REP	#20H
;;
;		LDA	<WORK0
;		SEC
;		SBC	<WORK4
;		CLC
;		ADC	#00018H
;		CMP	#00030H
;		BCS	NOM190
;		LDA	<WORK2
;		SEC
;		SBC	<WORK6
;		CLC
;		ADC	#0018H
;		CMP	#0030H
;		BCS	NOM190
;		MEM8
;		SEP	#20H
;;
;		PHY
;		LDA	#20H
;		JSL	>ESERCHL
;		PLY
;		LDA	<WORK0
;		STA	ENHNXS,Y
;		EOR	#0FFH
;		INC	A
;		STA	ENHNXS,X
;		LDA	<WORK1
;		STA	ENHNYS,Y
;		EOR	#0FFH
;		INC	A
;		STA	ENHNYS,X
;;
;		LDA	#10H
;		STA	ENHNFG,X
;		STA	ENHNFG,Y
;NOM190		EQU	$
;		SEP	#20H
;		DEY
;		BMI	NOM1A0
;		JMP	NOM120
;NOM1A0		EQU	$
;		RTS	
;======================================
NMCXAD		EQU	$
		WORD	0FFF8H,08H,0FFF8H,08H
;
		WORD	0FFF6H,0AH,0FFF6H,0AH
		WORD	0FFF6H,0AH,0FFF6H,0AH
		WORD	0FFF4H,0CH,0FFF4H,0CH
		WORD	0FFF2H,0EH,0FFF2H,0EH
		WORD	0FFF0H,18H,0FFF0H,18H
NMCYAD		EQU	$
		WORD    0FFF8H,0FFF8H,08H,08H
;
		WORD	0FFF6H,0FFF6H,0AH,0AH
		WORD	0FFF6H,0FFF6H,0AH,0AH
		WORD	0FFF4H,0FFF4H,0CH,0CH
		WORD	0FFF2H,0FFF2H,0EH,0EH
		WORD	0FFF0H,0FFF0H,18H,18H
NMCCDT		EQU	$
		HEX	C0,C2,E0,E2
		HEX	C0,C2,E0,E2
		HEX	C4,C4,C4,C4
		HEX	C6,C6,C6,C6
		HEX	C8,C8,C8,C8
		HEX	D8,D8,D8,D8
NMCADT		EQU	$
		HEX	00,00,00,00
		HEX	00,00,00,00
		HEX	40,00,C0,80
		HEX	40,00,C0,80
		HEX	40,00,C0,80
		HEX	40,00,C0,80
NMCSBD		EQU	$
		HEX	2,2,2,2
		HEX	2,2,2,2
		HEX	2,2,2,2
		HEX	2,2,2,2
		HEX	2,2,2,2
		HEX	0,0,0,0
NMCIDT		EQU	$
		WORD	140H+OAM-10H,148H+OAM-10H
		WORD	150H+OAM-10H,158H+OAM-10H
		WORD	160H+OAM-10H,168H+OAM-10H
NMCSDT		EQU	$
		WORD	140H/4+OAMSB-10H/4,148H/4+OAMSB-10H/4
		WORD	150H/4+OAMSB-10H/4,158H/4+OAMSB-10H/4
		WORD	160H/4+OAMSB-10H/4,168H/4+OAMSB-10H/4
;======================================
NOMOSCS		EQU	$
		JSR	OAMCHK
		LDA	ENWRK0,X
		BNE	NMC008
		LDA	<GAMEMD
		CMP	#07H
		BEQ	NMC008
;
		JSL	>OCHECKL
		LDY	#00H
NMC008		EQU	$
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORK6
		PHX
		LDX	#03H
NMC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	NMCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	NMCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	NMC013
		LDA	#0F0H
		STA	(<OAMADR),Y
NMC013		EQU	$
		PLX
		LDA	NMCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	NMCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	NMCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	NMC010
		PLX
;--- kage set -----
		LDA	ENCHPT,X
		BEQ	NMC012
;
		RTS
;
NMC012		EQU	$
		LDA	ENWRK0,X
		BEQ	NMC070		; Move start ?
;					; yes !
		TXA
		ASL	A
		TAY
		MEM16
		REP	#20H
		LDA	NMCIDT,Y	; oam kotei !
		STA	<OAMADR
		LDA	NMCSDT,Y
		STA	<OSBADR

		MEM8
		SEP	#20H
;
NMC070		EQU	$
		LDA	ENZPSL,X
		CMP	#20H
		BCC	NMC078
		LDA	#20H
NMC078		EQU	$
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK7
;
		LDA	ENYPSL,X
		SEC
		SBC	<SCCV2
		STA	<WORK2
		LDA	ENYPSH,X
		SBC	<SCCV2+1
		STA	<WORK3
;
		LDY	#10H
		LDA	<WORK0
		SEC
		SBC	#08H
		PHA
		CLC
		ADC	<WORK7
		STA	(<OAMADR),Y
		PLA
		CLC
		ADC	#10H
		SEC
		SBC	<WORK7
		LDY	#14H
		STA	(<OAMADR),Y
		MEM16
		REP	#20H
		LDA	<WORK2
		CLC
		ADC	#000CH
		LDY	#11H
		STA	(<OAMADR),Y
		LDY	#15H
		STA	(<OAMADR),Y
		CLC		
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	NMC056
		LDA	#0F0H
		STA	(<OAMADR),Y
		LDY	#11H
		STA	(<OAMADR),Y
NMC056		EQU	$
		LDA	#0E4H
		LDY	#12H
		STA	(<OAMADR),Y
		LDY	#16H
		STA	(<OAMADR),Y
		LDA	#25H
		LDY	#13H
		STA	(<OAMADR),Y
		ORA	#40H
		LDY	#17H
		STA	(<OAMADR),Y
		LDA	#02H
		LDY	#10H/4
		STA	(<OSBADR),Y
		INY
		STA	(<OSBADR),Y
NMC090		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%		keronpa                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RMSTIM		EQU	$
		HEX	80,C0,FF
;
RANEMIT		EQU	$
;;		LDA	#0FFH
		LDA	>RMSTIM,X
		STA	ENTIM0,X
		LDA	#0FFH
		STA	ENZPSL,X
;
		PHX
		LDY	#3FH
		LDA	>RMIDDT-00H,X
		TAX
		LDA	#0FFH
RMIT10		EQU	$
		STA	>RMZBUF,X
		INX
		DEY
		BPL	RMIT10
		PLX
		LDA	#07H
		STA	>RMCONT,X
		RTL
;----------------------------------
MNYSLM		EQU	$
MNXSLM		EQU	$
		BYTE	018H,0E8H
MNYSAD		EQU	$
MNXSAD		EQU	$
;;		BYTE	001H,0FFH
;
;;RTXD		EQU	$
;;		HEX	01,FF
;;RTXL		EQU	$
;;		HEX	10,F0
;
RANEMM		EQU	$
;;		STZ	ENDSPL,X
		JSL	>OAMCHKL
;
		JSR	RANEMCS
;
		JSR	ENSTCK2
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	RMINIT   ;0
		WORD	RMSET    ;1
		WORD	RMGOO    ;2
		WORD	RMDOWN   ;3
		WORD	RMEND    ;4
		WORD	RMFAIL   ;5
;--------------------------------------
RMINIT  	EQU	$
		LDA	ENTIM0,X
		ORA	ENDSPL,X
		BNE	RMI010
;
		LDA	#7FH
		STA	ENTIM0,X
		INC	ENSTAT,X
;
		LDA	#35H
		JSL	>SDLRE2	;(S)
RMI010		EQU	$
		RTS
;--------------------------------------
RMSXAL		EQU	$
		HEX	58,50,60,70,80,90,A0,98
RMSYAL		EQU	$
		HEX	68,60,70,80,90,A0,A8,80
;- - - - - -
RMSET		EQU	$
		LDA	ENTIM0,X
		BNE	RMS0A0
;
		JSL	>RNTAMST
;
		LDA	#13H
		STA	SOUND1	;(S)
;;		LDA	#02H
;;		JSL	>SDLRE3	:(S)
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	RMSXAL,Y
		STA	ENWRK1,X
;;		LDA	<PLXPS0
;;		STA	ENWRK0,X
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	RMSYAL,Y
		STA	ENWRK2,X
;;		LDA	<PLYPS0
;;		STA	ENATCT,X
;
;;		JSL	>RNDSET
;;		AND	#7FH
;;		ADC	#40H
;;		CLC
;;		ADC	<SCCH2
;;		STA	ENWRK1,X
;;		LDA	<SCCH2+1
;;		ADC	#00H
;;		STA	ENWRK0,X
;
;;		JSL	>RNDSET
;;		AND	#3FH
;;		ADC	#60H
;;		CLC
;;		ADC	<SCCV2
;;		STA	ENWRK2,X
;;		LDA	<SCCV2+1
;;		ADC	#00H
;;		STA	ENATCT,X
;
		INC	ENSTAT,X
		LDA	#018H
		STA	ENZSPD,X
		STZ	ENCTFG,X
		STZ	ENCTCT,X
TUCIST		EQU	$
		LDA	ENXPSL,X
		STA	ENMUKI,X
		LDA	ENYPSL,X
		STA	ENCBFG,X
		LDA	#4AH
		STA	ENTIM1,X
RMS090		EQU	$
		RTS		
RMS0A0		EQU	$
;;		CMP	#50H
;;		BCS	RMS0B0
;;;
;;		JSL	>RNTAMST
;;RMS0B0		EQU	$
		RTS
;
;=====================================================
RMZSAD		EQU	$
		HEX	02,FE
;;RMZSLM		EQU	$
;;		HEX	10,F0
;---------------------------------
;- - - - - - - - - - - - - - - - - - - - - - - - -
RMGOO		EQU	$
		JSR	CREKEK
		JSR	ENZCLC		  
;-- jump ! --
		LDA	ENCTFG,X
		BNE	RMG000
;
		LDA	ENZSPD,X
		SEC
		SBC	#01H
		STA	ENZSPD,X
		BNE	RMG002
		INC	ENCTFG,X
RMG002		EQU	$
		BRA	RMG008
;- - up down swing ! - - -	
RMG000		EQU	$
		LDA	<FRCNT
		AND	#01H
		BNE	RMG008
;
		LDA	ENCTCT,X
		AND	#01H
		TAY
		LDA	ENZSPD,X
		CLC
		ADC	RMZSAD,Y
		STA	ENZSPD,X
		CMP	RMZSLM,Y
		BNE	RMG008
		INC	ENCTCT,X
RMG008		EQU	$
		LDA	ENWRK1,X
		STA	<WORK4
;;		LDA	ENWRK0,X
		LDA	ENXPSH,X
		STA	<WORK5
		LDA	ENWRK2,X
		STA     <WORK6
;;		LDA	ENATCT,X
		LDA	ENYPSH,X
		STA	<WORK7	
;
;;		LDA	<PLXPS1
;;		STA	<WORK4
;;		LDA	<PLXPS0
;;		STA	<WORK5
;;		LDA	<PLYPS1
;;		STA	<WORK6
;;		LDA	<PLYPS0
;;		STA	<WORK7
;
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	ENYPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		STA	<WORK3
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		SEC
		SBC	<WORK4
		CLC
		ADC	#0002H
		CMP	#0004H
		BCS	RMG090
		LDA	<WORK2
		SEC
		SBC	<WORK6
		CLC
		ADC	#0002H
		CMP	#0004H
		MEM8
		SEP	#00100000B
		BCS	RMG090
;
		INC	ENSTAT,X
RMG090		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	#0AH
		JSL	>ESERCHL
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
         	JSR	ENMVCL
		RTS		
;-----------------------------------------
RMDOWN		EQU	$
		JSR	CREKEK
		JSR	ENMVCL
		JSR	ENZCLC
		LDA	ENZSPD,X
		CMP	#0ECH
		BMI	RMD000
		SEC
		SBC	#01H
		STA	ENZSPD,X
RMD000		EQU	$
		LDA	ENZPSL,X
		BPL	RMD090
;;		STZ	ENZPSL,X
		INC	ENSTAT,X
		LDA	#080H
		STA	ENTIM0,X
		JSR	TUCIST
RMD090		EQU	$
		RTS
;-----------------------------------------
RMEND		EQU	$
		LDA	ENTIM0,X
		BNE	RME090
;;		LDA	#7FH
;;		STA	ENTIM0,X
;;		LDA	#01H
;;		STA	ENSTAT,X
		STZ	ENSTAT,X
;
;;		JSL	>RNDSET
;;		AND	#7FH
;;		ADC	#40H
;;		CLC
;;		ADC	<SCCH2
;;		STA	ENXPSL,X
;;		LDA	<SCCH2+1
;;		ADC	#00H
;;		STA	ENXPSH,X
;;;
;;		JSL	>RNDSET
;;		AND	#7FH
;;		ADC	#20H
;;		CLC
;;		ADC	<SCCV2
;;		STA	ENYPSL,X
;;		LDA	<SCCV2+1
;;		ADC	#00H
;;		STA	ENYPSH,X
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	RMSXAL,Y
		STA	ENXPSL,X
;;		LDA	<PLXPS0
;;		STA	ENXPSH,X
;
		JSL	>RNDSET
		AND	#07H
		TAY
		LDA	RMSYAL,Y
		STA	ENYPSL,X
;;		LDA	<PLYPS0
;;		STA	ENYPSH,X
;
RME090		EQU	$
RMF0902		EQU	$
		RTS
;-----------------------------------------
RMFCDT		EQU	$
		HEX	00,08,10,18,20,28,30,38
;-----------------------------------------
BSITEM		EQU	$	; Boss failed item set !
		PHX
		TAX
		LDY	#04H
		LDA	#TKDOW
		JSL	>TKDINT
		PLX
		RTL
;-----------------------------------------
RMFAIL		EQU	$
		LDY	ENTIM0,X
;;		CPY	#020H
		BNE	RMF000
;
;;		STZ	BSFLFG
;
;;		JSL	>ENBTON
;;		LDA	EMYSTT		; Save data on !
;;		ORA	#10000000B
;;		STA	EMYSTT
		STZ	ENMODE,X
;;;		STZ	ENMYNO,X	; for fail check !
;
;;		LDA	ENMYNO+01H
;;		CMP	#RANEM
;;		BEQ	RMF000
;;		LDA	ENMYNO+00H
;;		CMP	#RANEM
;;		BEQ	RMF000		; all end ?
;					; yes !
		JSL	>EFLCHK
		BCC	RMFF00	; All ENEMY failed ?
;
                LDA     #UTUWA          ; Heart utsuwa set !
                JSR     >ENIDSH
                JSL     >ENIDPS
                LDA     #020H
                STA     ENZSPD,Y
;;                LDA     #01H		; Open door !
;;                STA     SWCHFG
;;;
;;		JSR	BOSAVE
;
		LDA	#03H
		STA	ENWRK0,Y
RMFF00		EQU	$
;;		JSL	>BSITEM
;;;
;;                LDY     #13H
;;                STY     SOUND0  ;(S)
RMF000		EQU	$
		LDA	ENTIM0,X
;;		TYA
		CMP	#20H		;*
		BCC	RMF0902		;*
;;		BNE	RMF0111
;;		STZ	ENMODE,X
;;		RTS
RMF0111		EQU	$
		CMP	#80H+20H
		BCS	RMF0902
;
		AND	#0FH
		BNE	RMF0902
;== kemri set ==
		LDA	>RMCONT,X
		TAY
		LDA	ENCONT,X
		SEC
		SBC	RMFCDT,Y
		AND	#3FH
		CLC
		ADC	RMIDDT-00H,X
		PHX
		TAX
		LDA	>RMXBUF,X
		SEC
		SBC	<SCCH2
		STA	<WORKA
		LDA	>RMYBUF,X
		SEC
		SBC	>RMZBUF,X
		SEC
		SBC	<SCCV2
		STA	<WORKB
		PLX
;-----
;;;		LDA	#OCTA1
;;		LDA	#BYOYN		; All fail check noth. 
		LDA	#00H
		JSL	>ENIDSH
		BMI	RMF090
;
                LDA     #spoj5
                STA     SPOJFG          ; OBJ bank set !
;;
		LDA	#EBAKU
;;		LDA	#EFAIL
		STA	ENMODE,Y
;
;;		LDA	#09H
;;		STA	ENTIM0,Y
;
		LDA	#1FH
		STA	ENTIM0,Y
		STA	ENWRK0,Y
;
		LDA	<WORKA
		CLC
		ADC	<SCCH2
		STA	ENXPSL,Y
		LDA	<SCCH2+1
		ADC	#00H
		STA	ENXPSH,Y
		LDA	<WORKB
		CLC
		ADC	<SCCV2
		STA	ENYPSL,Y
		LDA	<SCCV2+1
		ADC	#00H
		STA	ENYPSH,Y
;
		LDA	#03H
		STA	ENMOD0,Y	; oam kosu !
		LDA	#0CH
		STA	ENCLOR,Y
;
;;		LDA	#03H
;;		STA	ENMOD4,Y	; item dasu !
;
;;		LDA	#03H
;;		STA	KAGIFG,Y	; mujyoken heart dasu !
;
;;		JSL	>SDLRCE
;;		ORA	#0CH
;;		STA	SOUND2		;(S)
		LDA	#0CH
		JSL	>SDLRE2	;(S)
;===
		LDA	>RMCONT,X	; 1 ko zotsu kesu !
		BMI	RMF090
		DEC	A
		STA	>RMCONT,X
RMF090		EQU	$
		RTS
;-----------------------------------------
;-----------------------------------------
;=========================================================================
RMIDDT		EQU	$
		HEX	00,40,80,C0
MNINST		EQU	$
		HEX	00,1C
MNINAD		EQU	$
		HEX	01,F9
;
RMCCDT		EQU	$
		HEX	C4,E2,C2,E0
		HEX	C0,E0,C2,E2
		HEX	C4,E2,C2,E0
		HEX	C0,E0,C2,E2
;
RMCCD2		EQU	$
		HEX	CC,E4,CA,E6
		HEX	C8,E6,CA,E4
		HEX	CC,E4,CA,E6
		HEX	C8,E6,CA,E4
RMCADT		EQU	$
		HEX	C0,C0,C0,C0
		HEX	80,80,80,80
		HEX	00,00,00,00
		HEX	40,40,40,40
;--- tsuchi ---
TMCXAD		EQU	$
		HEX	F8,08
		HEX	F6,0A
		HEX	F0,10
		HEX	E8,20
TMCYAD		EQU	$
		HEX	00,00
		HEX	FF,FF
		HEX	FF,FF
		HEX	03,03
TMCCDT		EQU	$
		HEX	E8,E8
		HEX	E8,E8
		HEX	EA,EA
		HEX	EA,EA
TMCADT		EQU	$
		HEX	00,40
		HEX	00,40
		HEX	00,40
		HEX	00,40
TMCSBD		EQU	$
		HEX	02,02
		HEX	02,02
		HEX	02,02
		HEX	00,00
;- - - - - - - - - - - - - - - - - - - - - -
RNOMID		EQU	$
		WORD	OAM+0130H
		WORD	OAM+00F0H
		WORD	OAM+00B0H
		WORD	OAM+0070H
RNSBID		EQU	$
		WORD	OAMSB+0130H/4
		WORD	OAMSB+00F0H/4
		WORD	OAMSB+00B0H/4
		WORD	OAMSB+0070H/4
RANEMCS		EQU	$
		TXA
		ASL	A
		TAY
		MEM16
		REP	#20H
		LDA	RNOMID,Y	; Kotei OAM set !
		STA	<OAMADR
		LDA	RNSBID,Y
		STA	<OSBADR
		MEM8
		SEP	#20H
;---- body oam --
		LDA	ENYSPD,X	
		SEC
		SBC	ENZSPD,X
		STA	<WORK0
		LDA	ENXSPD,X
		STA	<WORK1
;
		JSL	>MKCK16
		STA	ENCHPT,X	; 16 Ways muki set !		
;
		LDA	RMIDDT-00H,X
		STA	<WORK4
;
		PHX
		LDA	ENXPSL,X
		PHA
		LDA	ENYPSL,X
		PHA
		LDA	ENZPSL,X
		PHA
		LDA	ENCHPT,X
		PHA
;
		LDA	ENCONT,X
		STA	<WORK2
		STA	<WORK5
;
;;		LDA	<WORK2
;;;		STA	<WORK2
;;;		STA	<WORK5
		CLC
		ADC	<WORK4
		TAX
		PLA
		STA	>RMCBUF,X
		PLA
		STA	>RMZBUF,X
		PLA
		STA	>RMYBUF,X
		PLA
		STA	>RMXBUF,X
		PLX
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	MNM048		; move ?
;
		LDA	<GAMEMD
		ORA	ENSTFG		; 
		BNE	MNM048
;					; yes ! move data revise !
		LDA	ENCONT,X
		INC	A
		AND	#03FH
		STA	ENCONT,X
;
MNM048		EQU	$
		LDA	ENCLOR,X
		ORA	ENFLCL,X
		STA	<WORK3
;
		LDA	>RMCONT,X
		BPL	MNM04A
		RTS
;
MNM04A		EQU	$
		PHX
		PHA
		STA	<WORKE
		LDA	ENYSPD,X
		ASL	A
		ROL	A
		AND	#01H
		TAX
		LDA	MNINAD,X
		STA	<WORKC
		LDY	MNINST,X
;
		PLX
		STX	<WORKB
MNC010		EQU	$
		PHX
		STX	<WORKD
		LDA	<WORK2
		CLC
		ADC	<WORK4
		TAX
		LDA	<WORK2
	        SEC
		SBC	#08H
		AND	#03FH
		STA	<WORK2
;
		LDA	>RMXBUF,X
		SEC
		SBC	<SCCH2
		STA	(<OAMADR),Y
;
		INY
		LDA	>RMZBUF,X
		BMI	MNC019
;
		LDA	>RMYBUF,X
		SEC
		SBC	>RMZBUF,X
		SEC
		SBC	<SCCV2
		STA	(<OAMADR),Y
MNC019		EQU	$
		PHY
		LDA	>RMCBUF,X
		TAX
		LDY	<WORKD
		LDA	<WORKB
		CMP	#07H
		BNE	MNC19A
		CPY	#00H
		BEQ	MNC01A
;
MNC19A		EQU	$
		LDA	#0C6H
		CPY	<WORKB
		BNE	MNC01B		
		LDA	RMCCDT,X
		BRA	MNC01B
MNC01A		EQU	$
		LDA	RMCCD2,X
MNC01B		EQU	$
		PLY
		INY
		STA	(<OAMADR),Y		
		LDA	RMCADT,X
		ORA	<WORK3
		INY
		STA	(<OAMADR),Y	
		TYA
		PHY
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
		PLA
		CLC
		ADC	<WORKC
		TAY
		PLX
		DEX
		BPL	MNC010
;-- kage set -- 
		LDX	<WORKE
		LDY	#020H
MNC030		EQU	$
		PHX
		LDA	<WORK5
		CLC
		ADC	<WORK4
		TAX
		LDA	<WORK5
	        SEC
		SBC	#08H
		AND	#03FH
		STA	<WORK5
		LDA	>RMXBUF,X
		SEC
		SBC	<SCCH2
		STA	(<OAMADR),Y
;
		INY
		LDA	>RMZBUF,X
		BMI	MNC039
;
		LDA	>RMYBUF,X
		CLC
		ADC	#0AH
		SEC
		SBC	<SCCV2
		STA	(<OAMADR),Y
MNC039		EQU	$
		LDA	#6CH
		INY
		STA	(<OAMADR),Y		
		LDA	#34H  
		INY
		STA	(<OAMADR),Y	
		TYA
		PHY
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	MNC030
		PLX
;
		LDA	ENSTAT,X
		CMP	#01H
		BNE	RMC099
		JMP	RMC0FE		; mokomoko set !
;
RMC099		EQU	$
		CMP	#05H
		BEQ	RMC0FF	; fail ?
;
		LDA	ENTIM1,X
		BEQ	RMC0FF	; TSUCHI SET ?
;---- tsuchi  oam --		; YES !
		PHA
;
		LDA	ENYSPD,X
;;		SEC
;;		SBC	ENZSPD,X
		ASL	A
		ROL	A
		ASL	A
;
		EOR	ENSTAT,X
		AND	#02H
		BEQ	RTO010		
;
		LDA	#02H*4
		JSL	>OAMENT2
		BRA	RTO020
;
RTO010		EQU	$
		LDA	#02H*4
		JSL	>OAMENT3
;
RTO020		EQU	$
		LDY	#00H
		PLA
		LSR	A
		LSR	A
;;		NOP
;;		NOP
		AND	#03H
		EOR	#03H
		ASL	A
		STA	<WORK6
;
		LDA	ENMUKI,X
		SEC
		SBC	<SCCH2
		STA	<WORK0
		LDA	ENCBFG,X
		SEC
		SBC	<SCCV2
		STA	<WORK2
;
		PHX
		LDX	#01H
RMC090		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	TMCXAD,X
		STA	(<OAMADR),Y
		LDA	<WORK2
		CLC
		ADC	TMCYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	TMCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	TMCADT,X
		ORA	#31H
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY	
		LDA	TMCSBD,X
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	RMC090
		PLX			
;
RMC0FF		EQU	$
		RTS
;
; - Mokomoko set - - - - - - - - - - - - - - - - -
;RMMKID		EQU	$
;		HEX	30,40,50,60
;
RMC0FE		EQU	$
		LDA	#04H*1  ;4
		JSL	>OAMENT2
;
		LDA	ENXPSL,X
		SEC
		SBC	<SCCH2
		STA	<WORK0
		LDA	ENYPSL,X
		SEC
		SBC	<SCCV2
		STA	<WORK2
;
		LDA	ENTIM0,X
		LSR	A
		LSR	A
		LSR	A
		TAY
		PHX
		LDX	RNMKPT,Y
;
;;		ASL	A
;;		ASL	A
;;		STA	<WORK6
		LDY	#00H
;;		LDY	RMMKID,X
;;		LDX	#00H
;;MKC010		EQU	$
;;		PHX
;;		TXA
;;		CLC
;;		ADC	<WORK6
;;		TAX
		LDA	<WORK0
;;		CLC
;;		ADC	MKCXAD,X
		STA	(<OAMADR),Y				
		LDA	<WORK2
;;		CLC
;;		ADC	MKCYAD,X
		INY
		STA	(<OAMADR),Y
		LDA	MKCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	MKCADT,X
		ORA	#31H
		INY
		STA	(<OAMADR),Y
;;		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		STA	(<OSBADR),Y
;;		PLY
;;		INY
;;		PLX
;;		DEX
;;      	BPL	MKC010
		PLX
		RTS
;---------------------------------
;MKCXAD		EQU	$
;		HEX	04,04,05,05
;		HEX	03,05,03,05
;		HEX	02,06,02,06
;		HEX	01,07,01,07
;		HEX	00,08,00,08
;		HEX	00,08,00,08
;MKCYAD		EQU	$
;		HEX	05,05,04,04
;		HEX	03,03,05,05
;		HEX	02,02,06,06
;		HEX	01,01,07,07
;		HEX	00,00,08,08
;		HEX	00,00,08,08
MKCCDT		EQU	$
		HEX	EE
		HEX	EE
		HEX	EC
		HEX	EC
		HEX	CE
		HEX	CE
;
;
;		HEX	DE,DF,DE,DF
;		HEX	CE,CF,DE,DF
;		HEX	CE,CF,DE,CF
;		HEX	CE,CF,DE,CF
;		HEX	CE,CF,DE,DF
;		HEX	DF,DE,CF,CE
MKCADT		EQU	$
		HEX	00,40,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	00,00,00,00
;		HEX	C0,C0,C0,C0
RNMKPT		EQU	$
		HEX	4,5,4,5,4,5,4,5
		HEX	4,3,2,2,1,1,0,0
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;NEZU0MV		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR	NZKMOV
;		PLB
;		RTL
;;- - - - - - - - - - - - - - - - - - - - - - -
;NZKMOV		EQU	$
;		LDA	ENMYNO,X
;		SEC
;		SBC	#NEZU0
;		MEM16
;		IDX16
;		REP	#00110000B
;		AND	#00FFH
;		ASL	A
;		TAY
;		LDA	NZMVAD,Y
;		DEC	A
;		PHA
;		MEM8
;		IDX8
;		SEP	#00110000B
;		RTS
;;----------------------------------------------------
;NZMVAD		EQU	$
;		WORD	NEZU0M	; nezumi
;		WORD	HEBI0M	; hebi move
;		WORD	HEBI1M	; hebi toguro
;		WORD	KOMO0M	; koumori
;============================================
NZPTDT		EQU	$
;;		 ENWRK0 0 1 2 3 4 5 6 7 8 9 A B C D E F
		BYTE	0,0,3,3,1,2,4,5,1,2,4,5,0,0,3,3
NZATDT		EQU	$
;;		 MUKI
		BYTE	00H,40H,00H,40H,00H,00H,00H,00H
		BYTE	40H,40H,40H,40H,80H,0C0H,80H,0C0H
;
NZSTPT		EQU	$
		BYTE	0AH,0BH
		BYTE	06H,07H
		BYTE	02H,03H
		BYTE	0EH,0FH
NZWKPT		EQU	$
		BYTE	08H,09H
		BYTE	04H,05H
		BYTE	00H,01H
		BYTE	0CH,0DH
;- - - - - - - - - - - - - - - - - - - - - - - -
NEZU0M		EQU	$
		LDY	ENWRK0,X
		LDA	NZPTDT,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	NZATDT,Y
		STA	ENCLOR,X
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		JSR	ENHNSB
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
		JSR	CREKEK
		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		LDA	ENSTAT,X
		BNE	NZWALK
;;		JSL	>JSRSUB
;;		WORD	NZSTOP
;;		WORD	NZWALK
;;		RTS
;- - - - - - - -- - - - - - - - -- - - -
;
NZSTOP		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	NZST10
;
		JSL	>RNDSET
		PHA
		AND	#03H
		STA	ENMUKI,X
;
		INC	ENSTAT,X		
;
		PLA
		AND	#7FH
		ADC	#040H
;;		LDA	#80H
		STA	ENTIM0,X
NZST10		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	NZSTPT,Y
		STA	ENWRK0,X
		RTS
;-------------------------------------------------------
NZWKXS		EQU	$
		BYTE	018H,0E8H,000H,000H
NZWKYS		EQU	$
		BYTE	000H,000H,018H,0E8H
NZNXMK		EQU	$
		BYTE	2,3,1,0
;- - - - - - - - - - - - - - - - -
NZWALK		EQU	$
		LDA	ENTIM0,X
		BNE	NZWK10
;
		LDA	URAFLG
		BNE	NZWK08
;
;;		JSL	>SDLRCE
;;		ORA	#17H
;;		STA	SOUND3	;(S)
		LDA	#17H
		JSL	>SDLRE3	;(S)
;
NZWK08		EQU	$
		STZ	ENSTAT,X
		LDA	#50H
		STA	ENTIM0,X
NZWK10		EQU	$
		LDY	ENMUKI,X
;
		LDA	ENCBFG,X
		BEQ	NZWK18
		LDA	NZNXMK,Y
		STA	ENMUKI,X
		TAY
NZWK18		EQU	$
		LDA	NZWKXS,Y
		STA	ENXSPD,X
		LDA	NZWKYS,Y
		STA	ENYSPD,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	NZWKPT,Y
		STA	ENWRK0,X
		RTS
;===============================================
B0PTDT		EQU	$
;;		 ENWRK0 0 1 2 3 4 5 6 7 
		BYTE	0,0,2,3,2,3,1,1
B0ATDT		EQU	$
;;		 MUKI
		BYTE	00H,40H,00H,00H,40H,40H,00H,40H
;
;HBSTPT		EQU	$
;		BYTE	0AH,0BH
;		BYTE	06H,07H
;		BYTE	02H,03H
;		BYTE	0EH,0FH
HBWKPT		EQU	$
		BYTE	04H,05H
		BYTE	02H,03H
		BYTE	00H,01H
		BYTE	06H,07H
;- - - - - - - - - - - - - - - - - - - - - - - - - -
HEBI0M		EQU	$
		LDY	ENWRK0,X
		LDA	B0PTDT,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#00111111B
		ORA	B0ATDT,Y
		STA	ENCLOR,X
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		LDA	ENWRK3,X
		BEQ	HB005A
;- - Tenjyou set (hazure swich) --
		LDY	#03H
		LDA	(<OAMADR),Y
		ORA	#00110000B	; Best yuusen
		STA	(<OAMADR),Y
;
		LDA	ENZPSL,X
		PHA
;
		JSR	ENZCLC
		LDA	ENZSPD,X
		CMP	#0C0H
		BMI	HB000A
		SEC
		SBC	#02H
		STA	ENZSPD,X
HB000A		EQU	$
		PLA
		EOR	ENZPSL,X
		BPL	HB001A
;
		LDA	ENZPSL,X
		BPL	HB001A
;
		STZ	ENZPSL,X
		STZ	ENZSPD,X
		STZ	ENWRK3,X
;
		LDA	ENMOD2,X
		AND	#11101111B
		STA	ENMOD2,X
HB001A		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - -
HB005A		EQU	$
		STZ	ENMOD0,X
;
		JSR	ENHNSB
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
		JSR	CREKEK
		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		LDA	ENSTAT,X
		BNE	HBWALK
;
;;		WORD	HBSTOP
;;		WORD	HBWALK
;----------------------------------------
;
HBSTOP		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	HBST10
;
		STZ	ENCTCT,X
		JSL	>RNDSET
		PHA
		AND	#03H
		STA	ENMUKI,X
;
		INC	ENSTAT,X		
;
		PLA
		AND	#7FH
		ADC	#040H
;;		LDA	#80H
		STA	ENTIM0,X
;
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#10H
		CMP	#20H
		BCC	HBST08
		LDA	<WORKF
		CLC
		ADC	#10H+8
		CMP	#20H
		BCS	HBST10
HBST08		EQU	$
		LDA	#04H
		STA	ENCTCT,X
		TYA
		STA	ENMUKI,X
HBST10		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	HBWKPT,Y
		STA	ENWRK0,X
		RTS
;-------------------------------------------------------
HBWKXS		EQU	$
		BYTE	008H,0F8H,000H,000H
		BYTE	010H,0F0H,000H,000H
HBWKYS		EQU	$
		BYTE	000H,000H,008H,0F8H
		BYTE	000H,000H,010H,0F0H
HBNXMK		EQU	$
		BYTE	2,3,1,0
;- - - - - - - - - - - - - - - - -
HBWALK		EQU	$
		LDA	ENTIM0,X
		BNE	HBWK10
		STZ	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
HBWK10		EQU	$
		LDY	ENMUKI,X
;
		LDA	ENCBFG,X
		BEQ	HBWK18
		LDA	HBNXMK,Y
		STA	ENMUKI,X
		TAY
HBWK18		EQU	$
		TYA
		CLC
		ADC	ENCTCT,X
		TAY
		LDA	HBWKXS,Y
		STA	ENXSPD,X
		LDA	HBWKYS,Y
		STA	ENYSPD,X
;
		LDA	<FRCNT
		CPY	#04H
		BCS	HBWK20
		LSR	A
HBWK20		EQU	$
		LSR	A
		LSR	A
		LDA	ENMUKI,X
		ROL	A
		TAY
		LDA	HBWKPT,Y
		STA	ENWRK0,X
		RTS
;;===============================================
;HEBI1M		EQU	$
;		JSR	HEBI1CS
;;
;		JSR	ENSTCK
;		JSR	ENHNSB
;;;		JSL	>CRENPLL
;;;		JSL	>CRKNENL
;		JSR	CREKEK
;;
;		TXA
;		ASL	A
;		EOR	<FRCNT
;		AND	#03H
;		BNE	HB1010
;;
;		LDA	ENCHPT,X
;		INC	A
;		AND	#03H
;		STA	ENCHPT,X
;HB1010		EQU	$
;		RTS
;
;;- - -- - -- - - - - - - - - - - - - -- -
;HB1XAD		EQU	$
;		WORD	000H,0FFFFH
;		WORD	000H,0FFFEH
;		WORD	000H,0FFFFH
;		WORD	000H,000H
;HB1YAD		EQU	$
;		WORD	000H,0FFFCH
;		WORD	000H,0FFFCH
;		WORD	000H,0FFFBH
;		WORD	000H,0FFFBH
;HB1CDT		EQU	$
;		BYTE	0ACH,0AEH
;		BYTE	0ACH,0AEH
;		BYTE	0ACH,0AEH
;		BYTE	0ACH,0AEH
;;- - - - - - - - - - - - - - - - - - - - - - -
;HEBI1CS		EQU	$
;;;;;;		JSR	OAMCHK
;		JSR	O2TEST
;;
;		LDA	ENCHPT,X
;		ASL	A
;		STA	<WORK6
;		PHX
;		LDX	#01H
;HB1C10		EQU	$
;		PHX
;		TXA
;		CLC
;		ADC	<WORK6
;		PHA
;		ASL	A
;		TAX
;;
;		MEM16
;		REP	#00100000B
;		LDA	<WORK0
;		CLC
;		ADC	HB1XAD,X
;		STA	(<OAMADR),Y
;		AND	#0100H
;		STA	<WORKE
;;
;		LDA	<WORK2
;		CLC
;		ADC	HB1YAD,X
;		INY
;		STA	(<OAMADR),Y
;		CLC
;		ADC	#0010H
;		CMP	#0100H
;		BCC	HB1C18
;		LDA	#00F0H
;		STA	(<OAMADR),Y
;HB1C18		EQU	$
;		MEM8
;		SEP	#00100000B
;		PLX
;		LDA	HB1CDT,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	<WORK5
;		INY
;		STA	(<OAMADR),Y
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDA	#02H
;		ORA	<WORKF
;		STA	(<OSBADR),Y
;		PLY
;		INY
;		PLX
;		DEX
;		BPL	HB1C10
;;
;		PLX
;;;		LDY	#02H
;;;		LDA	#01H
;;;		JSL	>ALOMCKL
;		RTS
;===============================================
KOITMK		EQU	$
		HEX	02,0A,06,0E
;
KOMO0M		EQU	$
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
;
		JSL	>EN1CSTL
;
		JSR	ENSTCK
;
		JSR	ENHNSB
;
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
		JSR	CREKEK
;
		JSR	ENMVCL
;
		LDA	ENSTAT,X
		BNE	KOMOVE
KOSTOP		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		ORA	ENTIM0,X
		BNE	KOS010
;
		JSR	EPXYCK
		LDA	<WORKE
		CLC
		ADC	#28H
		CMP	#50H
		BCS	KOS010
;
		LDA	<WORKF
		CLC
		ADC	#28H
		CMP	#50H
		BCS	KOS010
;
;;		JSL	>SDLRCE
;;		ORA	#1EH
;;		STA	SOUND3	;(S)
		LDA	#1EH
		JSL	>SDLRE3	;(S)
;
		INC	ENSTAT,X
;
		LDA	#40H
		STA	ENTIM0,X
		STA	ENWRK1,X
;
		JSR	EPXYCK
		LDA	KOITMK,Y
		STA	ENWRK0,X
;
;;		JSL	>RNDSET
;;		AND	#7FH
;;		ADC	#70H
;;		STA	ENTIM0,X
;;;
;;		STA	ENWRK0,X
;;		STA	ENWRK1,X
KOS010		EQU	$
		RTS
;-------------------------------------------------------
KOMAAD		EQU	$
		BYTE	001H,0FFH
KOMXSD		EQU	$
		BYTE	000H,008H,00BH,00EH,010H,00EH,00BH,008H
		BYTE	000H,-08H,-0BH,-0EH,-10H,-0EH,-0BH,-08H
KOMYSD		EQU	$
		BYTE	-10H,-0EH,-0BH,-08H,000H,008H,00BH,00EH
		BYTE	010H,00EH,00BH,008H,000H,-09H,-0BH,-0EH
;
KOMOVE		EQU	$
		LDA	ENTIM0,X
		BNE	KOM010
;
		STZ	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
;;;		LDA	#02H
		STZ	ENCHPT,X
		JSR	H0SDCL		; SPEED CLEAR !
		RTS
;- - - - - - - - - - - - - - - - - - - -
KOM010		EQU	$
		AND	#07H
		BNE	KOM020
;
		LDA	ENWRK1,X
		AND	#01H
		TAY
		LDA	ENWRK0,X
		CLC
		ADC	KOMAAD,Y
		STA	ENWRK0,X
;
		JSL	>RNDSET
		AND	#00000011B
		BNE	KOM020
;
		INC	ENWRK1,X
KOM020		EQU	$
		LDA	ENWRK0,X
		AND	#0FH
		TAY
		LDA	KOMXSD,Y
		STA	ENXSPD,X
		LDA	KOMYSD,Y
		STA	ENYSPD,X
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#01H
		INC	A
		STA	ENCHPT,X
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;;TAIHOMV		EQU	$
;;		PHB
;;		PHK
;;		PLB
;;		JSR	TAIH00
;;		PLB
;;		RTL
;------------------------
;=================================================
TTAMAMV		EQU	$
		JSL	>EN1CSTL
;
		JSR	ENSTCK
		JSR	ENMVCL
;
		LDA	ENTIM0,X
		CMP	#1EH
		BNE	TTM008
;
		PHA
		JSL	>KEMRIST
		PLA
;
TTM008		EQU	$
		CMP	#00H
		BNE	TTM010
;
;;		JSL	>ENBGCKL
;
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	TTM010
;
		STZ	ENMODE,X
;
		LDA	ENXPSL,X
		CLC
		ADC	#04H
		STA	ENXPSL,X
		LDA	ENYPSL,X
		CLC
		ADC	#04H
		STA	ENYPSL,X
		JSL	>EFLSST2
;
;;		JSL	>SDLRCE
;;		ORA	#05H
;;		STA	SOUND2	;(S)
		LDA	#05H
		JSL	>SDLRE2	;(S)
TTM010		EQU	$
;
CREKEK		EQU	$
		JSL	>CRKNENL
		JSL	>CRENPLL
;
		RTS
;
;=====================================================
KEMRIST		EQU	$
		PHX
		TXY
;
		LDX	#E2NO-1
KMRS10		EQU	$
		LDA	>E2MODE,X
		BEQ	KMRS20
		DEX
		BPL	KMRS10
;
;;		PLX
		INX
;;		RTL
;- - - - - - - - - - - - - - - - - - - - - -
KMRS20		EQU	$
		LDA	#0AH
		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	ENFLCL,Y
;;		AND	#00110000B
		LDA	ENKAIF,Y
		STA	>E2STAT,X
;
		LDA	#0FH
		STA	>E2TIM0,X
;
		TXY
		PLX
		RTL
;;=====================================================
;KMCXAD		EQU	$
;		BYTE	0FAH,00EH,0FAH,00EH
;		BYTE	0FAH,00EH,0FAH,00EH
;		BYTE	0FAH,00EH,0FAH,00EH
;		BYTE	0FAH,00EH,0FAH,00EH
;		BYTE	0FBH,00DH,0FBH,00DH
;		BYTE	0FCH,00CH,0FCH,00CH
;		BYTE	0FEH,00AH,0FEH,00AH
;		BYTE	000H,008H,000H,008H
;KMCYAD		EQU	$
;		BYTE	0FAH,0FAH,00EH,00EH
;		BYTE	0FAH,0FAH,00EH,00EH
;		BYTE	0FAH,0FAH,00EH,00EH
;		BYTE	0FAH,0FAH,00EH,00EH
;		BYTE	0FBH,0FBH,00DH,00DH
;		BYTE	0FCH,0FCH,00CH,00CH
;		BYTE	0FEH,0FEH,00AH,00AH
;		BYTE	000H,000H,008H,008H
;KMCCDT		EQU	$
;		BYTE	0A5H,0A5H,0A5H,0A5H
;		BYTE	0A5H,0A5H,0A5H,0A5H
;		BYTE	09BH,09BH,09BH,09BH
;		BYTE	09BH,09BH,09BH,09BH
;		BYTE	0A9H,0A9H,0A9H,0A9H
;		BYTE	0A9H,0A9H,0A9H,0A9H
;		BYTE	0A9H,0A9H,0A9H,0A9H
;		BYTE	0A8H,0A8H,0B8H,0B8H
;KMCADT		EQU	$
;		BYTE	000H,040H,080H,0C0H
;		BYTE	000H,040H,080H,0C0H
;		BYTE	000H,040H,080H,0C0H
;		BYTE	000H,040H,080H,0C0H
;		BYTE	000H,000H,000H,000H
;		BYTE	000H,000H,000H,000H
;		BYTE	000H,000H,000H,000H
;		BYTE	000H,000H,040H,040H
;KEMRIMV		EQU	$
;;;		JSR	OAMCHK
;		JSR	O2TEST
;;
;		LDA	ENTIM0,X
;		BNE	KEM008
;;
;		STZ	ENMODE,X
;KEM008		EQU	$
;		LSR	A
;		LSR	A
;		AND	#07H
;		ASL	A
;		ASL	A
;		STA	<WORK5
;;
;		PHX
;		LDX	#03H
;KMM010		EQU	$
;		PHX
;		TXA
;		CLC
;		ADC	<WORK5
;		TAX
;		LDA	<WORK0
;		CLC
;		ADC	KMCXAD,X
;		STA	(<OAMADR),Y
;		LDA	<WORK2
;		CLC
;		ADC	KMCYAD,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	KMCCDT,X
;		INY
;		STA	(<OAMADR),Y
;		LDA	KMCADT,X
;		ORA	#24H
;		INY
;		STA	(<OAMADR),Y
;		INY
;		PLX
;		DEX
;		BPL	KMM010
;;
;		PLX
;		LDY	#00H
;		LDA	#03H
;		JSL	>ALOMCKL
;		RTS
;=====================================================
;---------------------------------------
TAIHOM		EQU	$
TAIH00		EQU	$
		LDA	ENWRK2,X
		BEQ	TAIH010		; tama ?
;					; yes !
;;		CMP	#02H
;;		BEQ	TAIH008
;-----------------------------------------------
		JMP	TTAMAMV
;-----------------------------------------------
;;TAIH008		EQU	$
;;		JMP	KEMRIMV
TAIH010		EQU	$
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	TH0010
;;;
;;		INC     ENCHPT,X
;;		LDA     ENCHPT,X
;;		CMP	#0CH
;;		BNE	TH0010
;;;
;;		STZ	ENCHPT,X
;;TH0010		EQU	$
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	TH0010
;;;
;;		DEC     ENCHPT,X
;;		BPL	TH0020
;;;
;;		LDA	#0BH
;;		STA	ENCHPT,X
;;TH0020		EQU	$
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	THM001
		LDA	H0TURN,Y
		STA	ENMUKI,X
THM001		EQU	$
		JSR	TAIHOCS
		PLA
		STA	ENMUKI,X
;
		JSR	ENSTCK
;;		JSL	>CRKNKNL
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
		JSR	CREKEK
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	THMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
THMVAD		EQU	$
;;		LDA	ENSTAT,X
;;		JSL	>JSRSUB
		WORD	THWAIT
		WORD	THSHOT
		WORD	THSAGA
		WORD	THWAI2
		WORD	THRVSE
;;		RTS
;==========================================
THWAIT		EQU	$
		STZ	ENWRK0,X
		LDA	ENTIM0,X
;;		ORA	MIHAFG
		BNE	THW010
;
		INC	ENSTAT,X
		LDA	#060H
		STA	ENTIM0,X
;
PMSET		EQU	$
		LDA	ENMUKI,X
		PHA
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		PLA
		CMP	ENMUKI,X
		BEQ	THW010
		EOR	ENMUKI,X
		AND	#00000010B
		BNE	THW010
;
		LDA	#0CH
		STA	ENTIM1,X	; turn half pause set !
THW010		EQU	$
		RTS
;==========================================
THSHOT		EQU	$
		LDA	#00H
		LDY	ENTIM0,X
		BEQ	THS020
		CPY	#30H
		BCS	THS010
		LDA	#02H
THS010		EQU	$
		STA	ENWRK0,X
		RTS
;- - - - - - - - - - - - - - - -
THSXAL		EQU	$
		BYTE	010H,0F0H,000H,000H
THSXAH		EQU	$
		BYTE	000H,0FFH,000H,000H
THSYAL		EQU	$
		BYTE	000H,000H,008H,0F0H
THSYAH		EQU	$
		BYTE	000H,000H,000H,0FFH
THSXSD		EQU	$
		BYTE	018H,0E8H,000H,000H
THSYSD		EQU	$
		BYTE	000H,000H,018H,0E8H
;- - -- - - - -
THS020		EQU	$
		INC	ENSTAT,X
		LDA	#04H
		STA	ENTIM0,X
;- - - TAMA SET - - - - 
		LDA	#TAIHO
		JSL	>ENIDSH
		BMI	THS030
;
;;		JSL	>SDLRCE
;;		ORA	#07H
;;		STA	SOUND3	;(S)
		LDA	#07H
		JSL	>SDLRE3	;(S)
;
		LDA	#01H
		STA	ENWRK2,Y
;
		LDA	ENMUKI,X
		PHX
		TAX
                LDA     <WORK0
		CLC
		ADC	THSXAL,X
                STA     ENXPSL,Y
                LDA     <WORK1
		ADC	THSXAH,X
                STA     ENXPSH,Y
                LDA     <WORK2
		CLC
		ADC	THSYAL,X
                STA     ENYPSL,Y
                LDA     <WORK3
		ADC	THSYAH,X
		STA	ENYPSH,Y
		LDA	THSXSD,X
		STA	ENXSPD,Y
		LDA	THSYSD,X
		STA	ENYSPD,Y
;
         	LDA	ENMOD0,Y
		AND	#11110000B
		ORA	#00000001B
		STA	ENMOD0,Y
		LDA	ENMOD2,Y
		ORA	#01000111B
		STA	ENMOD2,Y
		LDA	ENMOD5,Y
		ORA	#01000100B
		STA	ENMOD5,Y
		LDA	#20H
		STA	ENTIM0,Y
		PLX
THS030		EQU	$
		RTS
;;- - - KEMRI SET - - - - 
;		LDA	#TAIHO
;		JSL	>ENIDSH
;		BMI	THS040
;;
;		LDA	#20H
;		STA	ENTIM0,Y
;;
;		LDA	#02H
;		STA	ENWRK2,Y
;;
;		LDA	ENMUKI,X
;		PHX
;		TAX
 ;               LDA     <WORK0
;		CLC
;		ADC	THSXAL,X
 ;               STA     ENXPSL,Y
  ;              LDA     <WORK1
;		ADC	THSXAH,X
 ;               STA     ENXPSH,Y
  ;              LDA     <WORK2
;		CLC
;		ADC	THSYAL,X
 ;               STA     ENYPSL,Y
  ;              LDA     <WORK3
;		ADC	THSYAH,X
;		STA	ENYPSH,Y
;;
  ;       	LDA	ENMOD0,Y
;		AND	#11110000B
;		ORA	#00000100B
;		STA	ENMOD0,Y
;		LDA	ENMOD2,Y
;		ORA	#01000111B
;		STA	ENMOD2,Y
;		PLX
;THS040		EQU	$
;		RTS
;==========================================
THSGXS		EQU	$
		BYTE	0E0H,020H,000H,000H
THSGYS		EQU	$
		BYTE	000H,000H,0E0H,020H
;
THSAGA		EQU	$
		LDA	ENTIM0,X
		BNE	THSG10
;
		INC	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
THSG10		EQU	$
		LDY	ENMUKI,X
		LDA	THSGXS,Y
		STA	ENXSPD,X
		LDA	THSGYS,Y
		STA	ENYSPD,X
		JSR	ENMVCL
		RTS
;==========================================
THWAI2		EQU	$
		LDA	ENTIM0,X
		BNE	THW210
;
		INC	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
THW210		EQU	$
		RTS
;==========================================
THRVXS		EQU	$
		BYTE	008H,0F8H,000H,000H
THRVYS		EQU	$
		BYTE	000H,000H,008H,0F8H
;
THRVSE		EQU	$
		LDA	ENTIM0,X
		BNE	THRV10
		STZ	ENSTAT,X
		LDA	#080H
		STA	ENTIM0,X
THRV10		EQU	$
		LDY	ENMUKI,X
		LDA	THRVXS,Y
		STA	ENXSPD,X
		LDA	THRVYS,Y
		STA	ENYSPD,X
		JSR	ENMVCL
;
		LDA	<FRCNT
		LSR	A
		LSR 	A
		AND	#01H
		STA	ENWRK0,X
		RTS
;==========================================
;==========================================
;==========================================
;==========================================
THCXAD		EQU	$
		WORD	0FFFCH,004H,000H,000H,000H
		WORD	0FFFCH,004H,000H,000H,000H
		WORD	0FFFCH,004H,000H,000H,00CH
;
		WORD	004H,004H,0FFF8H,0FFF8H,0FFF8H
		WORD	004H,004H,0FFF8H,0FFF8H,0FFF8H
		WORD	004H,004H,0FFF8H,009H,009H
;
		WORD	000H,0FFFCH,004H,000H,000H
		WORD	000H,0FFFCH,004H,000H,000H
		WORD	000H,0FFFCH,004H,000H,0FFFBH
;
		WORD	0FFFCH,0FFFCH,008H,008H,008H
		WORD	0FFFCH,0FFFCH,008H,008H,008H
		WORD	0FFFCH,0FFFCH,008H,0FFFFH,0FFFFH
THCYAD		EQU	$
		WORD	000H,000H,0FFF7H,007H,007H
		WORD	000H,000H,0FFF7H,007H,007H
		WORD	000H,000H,0FFF7H,007H,0FFFDH
;
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
;
		WORD	0FFF4H,000H,000H,0FFF7H,0FFF7H
		WORD	0FFF4H,000H,000H,0FFF7H,0FFF7H
		WORD	0FFF4H,000H,000H,0FFF7H,0FFFDH
;
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
		WORD	000H,0FFF7H,000H,000H,000H
THCCDT		EQU	$
		BYTE	046H,046H,000H,024H,024H
		BYTE	048H,049H,000H,024H,024H
		BYTE	046H,006H,000H,024H,02FH
;
		BYTE	04EH,002H,026H,026H,026H
		BYTE	060H,002H,026H,026H,026H
		BYTE	008H,002H,026H,02FH,02FH
;
		BYTE	028H,064H,064H,004H,004H
		BYTE	028H,066H,067H,004H,004H
		BYTE	028H,00AH,064H,004H,02FH
;
		BYTE	04EH,002H,026H,026H,026H
		BYTE	060H,002H,026H,026H,026H
		BYTE	008H,002H,026H,02FH,02FH
THCADT		EQU	$
		BYTE	000H,040H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
;
		BYTE	000H,000H,040H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	000H,000H,040H,000H,040H
;
		BYTE	040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H
		BYTE	040H,040H,040H,040H,040H
THCSBD		EQU	$	
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,000H
;
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,000H,000H
;
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,000H
;
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,002H,002H
		BYTE	002H,002H,002H,000H,000H
;- - - - - -- -
THPTPT		EQU	$
		BYTE	09H,03H,00H,06H
;------------------
TAIHOCS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDY	ENMUKI,X
		LDA	THPTPT,Y
		CLC
		ADC	ENWRK0,X
		STA	<WORK6
;;;		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ADC	<WORK6
		STA	<WORK6
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		PHX
		LDX	#04H
		LDY	#00H
THC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	THCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	THCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	THC011
;
		LDA	#00F0H
		STA	(<OAMADR),Y
THC011		EQU	$
;
		MEM8
		SEP	#00100000B
		PLX
		LDA	THCCDT,X
		INY
		STA	(<OAMADR),Y
		SEC
		SBC	#24H
		CMP	#28H-24H+1
		LDA	THCADT,X
		ORA	<WORK5
		BCS	THC018		; TAIHO COLOR ?
		AND	#11110001B	; YES !
		ORA	#00000110B
;;		PHA
;;		LDA	THCXAD,X
;;		STA	ENKNXP
;;		LDA	THCYAD,X
;;		STA	ENKNYP
;;		PLA
THC018		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A	
		LSR	A
		TAY
		LDA	THCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	THC010
		PLX
;
;;		LDA	#04H
;;		LDY	#0FFH
;;		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	        ON MAP FAILY                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;HYUUUMV		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR	HYU000
;		PLB
;		RTL
;------------------------
HYUUUAD		EQU	$
		BYTE	000H,040H,0C0H,080H
HYUUUM		EQU	$
HYU000		EQU	$
		LDA	>GDTRPF
		BNE	HYUUU50
;
		LDA	<MPDTNO
		CMP	#080H
		BCC	HYUUU90
		RTS
;
HYUUU90		EQU	$
;		LDA	ENCLOR,X
;		AND	#0DFH
;		STA	ENCLOR,X
;		LDA	ENWRK0,X
;		EOR	#001H
;		ASL	A
;		ASL	A
;		ASL	A
;		ASL	A
;		ASL	A
;		ORA	ENCLOR,X
;		STA	ENCLOR,X
		LDA	<GAMEMD
		CMP	#p2_kage
		BEQ	HYUUU70
		LDA	OJBKFG
		CMP	#003H
		BCS	HYUUU70
		JSL	>EN1CSTL
HYUUU70		EQU	$
;
		JSR	ENSTCK		; scroll : not return !
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#003H
		TAY
		LDA	ENCLOR,X
		AND	#03FH
		ORA	HYUUUAD,Y
		STA	ENCLOR,X
;
		JSL	>WPMSCK
		BCS	HYUUU80
;
;		LDA	<FRCNT
;		LSR	A
;		LSR	A
;		LSR	A
;       	AND	#001H
;		STA	ENCHPT,X
;
		JSL	>CRENPL2L	;PL BODY ATARI?
		BCC	HYUUU10
		LDA	ENWRK0,X
		BEQ	HYUUU40
;					;GET !!
		LDA	MRTKFG
		ORA	PYFLASH
		BNE	HYUUU40
;
		LDA	PYALSP
		BNE	HYUUU40
;
		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
;
HYUUU50		EQU	$
;
		STZ	ENMODE,X	;KILL I
;
		BRA	HYUUU40
;
HYUUU10		EQU	$
		LDA	#001H
		STA	ENWRK0,X	;HANARETA = 1
		LDA	ENCLOR,X
		AND	#0FFH
		STA	ENCLOR,X
HYUUU40		EQU	$
		INC	ENWRK1,X
		BNE	HYUUU60
		LDA	#001H
		STA	ENWRK0,X
HYUUU60		EQU	$
		LDA	MEMXPSL+0FH
		STA	ENXPSL,X
		LDA	MEMXPSH+0FH
		STA	ENXPSH,X
		LDA	MEMYPSL+0FH
		CLC
		ADC	#008H
		STA	ENYPSL,X
		LDA	MEMYPSH+0FH
		ADC	#000H
		STA	ENYPSH,X
HYUUU80		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Tekkyu  heishi                         		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;TEKU0MV  	EQU	$
;		PHB
;		PHK
;		PLB
;		JSR	TEK000
;       	PLB
;		RTL
;--------------------------------------------
TKSPIN		EQU	$
		BYTE	22H,10H
;
TEKU0M  	EQU	$
TEK000		EQU	$
		JSR	TEKU0CS
;
		LDA	ENSTAT,X
		CMP	#02H
		BCS	TEKD00
;
		LDA	#80H
		STA	ENKNXP
TEKD00		EQU	$
;
;;		JSL	>CRKNKNL
;
;;		LDA	<KEYA2
;;		AND	#08H
;;		BEQ	TEK010
;;;
;;		INC	ENCHPT,X
;;		LDA	ENCHPT,X
;;		CMP	#14H
;;		BNE	TEK010
;;		STZ	ENCHPT,X
;;TEK010		EQU	$
;;
;;		LDA	<KEYA2
;;		AND	#80H
;;		BEQ	TEK020
;;;
;;		LDA	ENTIM2,X
;;		BNE	TEK020
;;;
;;		LDA	#1FH
;;		STA	ENTIM2,X
;;TEK020		EQU	$
		JSR	ENSTCK
;
		JSL	>CRKNKNL
;
		LDY	ENSTAT,X
		LDA	TKSPIN-2,Y
		CLC
		ADC	ENWRK0,X
		STA	ENWRK0,X
		LDA	ENWRK1,X
		ADC	#00H
		AND	#01H
		STA	ENWRK1,X
;
		JSR	ENHNSB
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
		JSR	ENMVCL
;
		JSL	>CRENPLL
;;		JSR	CREKEK
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	TKM0000
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
TKM0000		EQU	$
;
;;		LDA	ENSTAT,X
;;		JSL	>JSRSUB
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	TKMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
TKMVAD		EQU	$
		WORD	TKWALK
		WORD	TKWAIT
		WORD	TKATWT
		WORD	TKATCK
;=====================================================
TKWALK		EQU	$
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	TKWK10
;
;;		JSR	EPXYCK
;;		TYA
		LDA	ENKBMK,X
		STA	ENMUKI,X
;
		LDA	<WORKE
		CLC
		ADC	#40H
		CMP	#068H
		BCS	TKWK08
		LDA	<WORKF
		CLC
		ADC	#30H
		CMP	#060H
		BCS	TKWK08		; hani ok ?
;					; Go atack !
		INC	ENSTAT,X
		LDA	#18H
		STA	ENTIM0,X
		RTS
TKWK08		EQU	$
		LDA	#08H
		JSL	>PSERCHL
TKWK10		EQU	$
TKWKST		EQU	$
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		AND	#07H
		ORA	<WORK0
		TAY
		LDA	TKWKPT,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - - - - - -
TKWKPT		EQU	$
		BYTE	10H,11H,12H,13H,10H,11H,12H,13H
		BYTE	6,7,8,9,6,7,8,9
		BYTE	0,1,2,3,0,1,4,5
		BYTE	0AH,0BH,0CH,0DH,0AH,0BH,0EH,0FH
;=====================================================
TKWAIT		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	TKW010
;
		LDA	#30H
		STA	ENTIM0,X
		INC	ENSTAT,X
TKW010		EQU	$
		RTS
;===================================
TKACCK		EQU	$
		HEX	03,01,02,00
;
TKATWT		EQU	$
		LDA	ENTIM0,X
		BNE	TKA010
;
		LDA	ENWRK0,X
		ASL	A
		LDA	ENWRK1,X
		ROL	A
		TAY
		LDA	TKACCK,Y
		CMP	ENKBMK,X
		BNE	TKA010		; spin muki player check ok ?
;					; yes !
		INC	ENSTAT,X
		LDA	#1FH
		STA	ENTIM2,X
TKA010		EQU	$
		INC	ENCONT,X
		JSR	TKWKST
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	TKA018
;
TKSDST		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#06H
;;		STA	SOUND3	;(S)	
		LDA	#06H
		JSL	>SDLRE3	;(S)
;
TKA018		EQU	$
		RTS
;;		BRA	TKAC10
;=====================================================
TKATCK		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM2,X
		BNE	TKAC10
;
		STZ	ENSTAT,X
TKAC10		EQU	$
		CMP	#10H
		BCS	TKA010
;
		INC	ENCONT,X
		JSR	TKWKST
;;		TXA
;;		EOR	<FRCNT
;;		AND	#0FH
;;		BNE	TKAC18
;;;
;;		JSL	>SDLRCE
;;		ORA	#06H
;;		STA	SOUND3	;(S)	
;;
;;TKAC18		EQU	$
		RTS
;===============================================
;===============================================
;===============================================
TEKU0CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		JSR	TKHDCS		; head set 
		JSR	TKBDCS		; body set 
;
		JSR	TKWPCS		; wepon set 
;
;;		LDA	ENDSXL
;;		STA	<WORK0
;;		LDA	ENDSYL
;;		STA	<WORK2
;
		JSR	OAMCHK		; WORK0,2 set !
		JMP	HESWST
;;		LDY	#0FFH
;;		LDA	#08H
;;		JSL	>ALOMCKL
;;		RTS
;==============================
TKHDCD		EQU	$
		BYTE	002H,002H,000H,004H
TKHDAD		EQU	$
		BYTE	040H,000H,000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - -
TKHDCS		EQU	$
		LDY	#18H
TKHDC2		EQU	$
;;		LDY	#04H
		PHX
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		SEC
		SBC	#09H
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	TH2C11
		LDA	#00F0H
		STA	(<OAMADR),Y
TH2C11		EQU	$
		MEM8
		SEP	#00100000B
		LDA	TKHDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	TKHDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
		RTS
;==============================
;==============================
TKCXAD		EQU	$
		WORD	0FFFCH,004H,00CH	;0
		WORD	0FFFCH,004H,00DH	;1
		WORD	0FFFCH,004H,00DH	;2
		WORD	0FFFCH,004H,00DH	;3
		WORD	0FFFCH,004H,00DH	;4
		WORD	0FFFCH,004H,00DH	;5
;
		WORD	000H,000H,004H	;6
		WORD	000H,000H,005H	;7
		WORD	000H,000H,006H	;8
		WORD	000H,000H,004H	;9
;
		WORD	0FFFCH,004H,0FFFAH	;A
		WORD	0FFFCH,004H,0FFFBH	;B
		WORD	0FFFCH,004H,0FFFBH	;C
		WORD	0FFFCH,004H,0FFFAH	;D
		WORD	0FFFCH,004H,0FFFBH	;E
		WORD	0FFFCH,004H,0FFFAH	;F
;
		WORD	000H,000H,004H	;10
		WORD	000H,000H,003H	;11
		WORD	000H,000H,002H	;12
		WORD	000H,000H,004H	;13
;-- for ya shot
		WORD	000H,000H,000H	;14
		WORD	000H,000H,000H	;15
		WORD	0FFFCH,004H,004H	;16
		WORD	0FFFCH,004H,004H	;17
TKCYAD		EQU	$
		WORD	000H,000H,0FFFCH	
		WORD	000H,000H,0FFFCH	
		WORD	000H,000H,0FFFDH
		WORD	000H,000H,0FFFEH
		WORD	000H,000H,0FFFDH
		WORD	000H,000H,0FFFEH
;
		WORD	000H,000H,001H
		WORD	000H,000H,001H
		WORD	000H,000H,002H
		WORD	000H,000H,002H
;
		WORD	000H,000H,0FFFEH
		WORD	000H,000H,0FFFEH
		WORD	000H,000H,0FFFFH
		WORD	000H,000H,0FFFFH
		WORD	000H,000H,0FFFFH
		WORD	000H,000H,0FFFFH
;
		WORD	000H,000H,001H
		WORD	000H,000H,001H
		WORD	000H,000H,002H
		WORD	000H,000H,002H
;-- YA
		WORD	000H,000H,000H
		WORD	000H,000H,000H
		WORD	000H,000H,000H
		WORD	000H,000H,000H
TKCCDT		EQU	$
		BYTE	046H,006H,02FH
		BYTE	046H,006H,02FH
		BYTE	048H,00DH,02FH
		BYTE	048H,00DH,02FH
		BYTE	049H,00CH,02FH
		BYTE	049H,00CH,02FH
;
		BYTE	008H,008H,02FH
		BYTE	008H,008H,02FH
		BYTE	022H,022H,02FH
		BYTE	022H,022H,02FH
;
		BYTE	00AH,064H,02FH
		BYTE	00AH,064H,02FH
		BYTE	02CH,067H,02FH
		BYTE	02CH,067H,02FH
		BYTE	02DH,066H,02FH
		BYTE	02DH,066H,02FH
;
		BYTE	008H,008H,02FH
		BYTE	008H,008H,02FH
		BYTE	022H,022H,02FH
		BYTE	022H,022H,02FH
;
		BYTE	062H,062H,062H
		BYTE	062H,062H,062H
		BYTE	046H,04BH,04BH
		BYTE	069H,064H,064H
TKCADT		EQU	$
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	040H,040H,000H
		BYTE	040H,040H,000H
;
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
		BYTE	000H,000H,000H
;
		BYTE	000H,040H,040H
		BYTE	000H,040H,040H
		BYTE	000H,000H,040H
		BYTE	000H,000H,040H
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
;
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
		BYTE	040H,040H,040H
;
		BYTE	040H,040H,040H
		BYTE	000H,000H,000H
		BYTE	000H,040H,040H
		BYTE	000H,040H,040H
TKCSBD		EQU	$
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
		BYTE	002H,002H,000H
;
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
		BYTE	002H,002H,002H
;==================================================
TKBSID		EQU	$
		BYTE	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
		BYTE	1,1,1,1
TKBSI2		EQU	$
		BYTE	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
		BYTE	8,8,8,8
;
TKBDCS		EQU	$
		LDY	#14H
TKBDC2		EQU	$
;
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
;
		PHX
		LDA	ENCHPT,X
		TAX
		TYA
		CLC
		ADC	TKBSI2,X
		TAY
		LDA	TKBSID,X
		TAX
;;;		LDX	#02H
TEKC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	TKCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	TKCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	TEKC12
;
		LDA	#00F0H
		STA	(<OAMADR),Y
TEKC12		EQU	$
		MEM8
		SEP	#00100000B
;
		PLX
		LDA	TKCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	TKCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	TKCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		CPX	#02H
		BNE	TKC030	; next head set ?
		INY		; index entry !
		INY
		INY
		INY
TKC030		EQU	$
		DEX
		BPL	TEKC10
;
		PLX
		RTS
;====================================
TKWPAD		EQU	$
		BYTE	10H,12H,14H,16H,18H,1AH,1CH,1EH
		BYTE	20H,22H,24H,26H,28H,2AH,2CH,2EH
		BYTE	30H,2EH,2CH,2AH,28H,26H,24H,22H
		BYTE	20H,1EH,1CH,1AH,18H,16H,14H,12H
;
TKHDXD		EQU	$
		BYTE	04H,04H,0CH,0FBH
TKHDYD		EQU	$
		BYTE	0FEH,0FEH,0FAH,0FCH
;- - - - -- - - -
TKWPCS		EQU	$
		LDA	<WORK0
		STA	ENDSXL
		LDA	<WORK2
		STA	ENDSYL
;
                LDA	ENWRK0,X
		STA	<WORK0
		LDA	ENWRK1,X
		STA	<WORK1		; angle
;
		LDA	#00H
		LDY	ENSTAT,X
		CPY	#02H
		BCC	TKSP10
;
		LDA	ENTIM2,X
;;		NOP
;;		NOP
		TAY
		LDA	TKWPAD,Y
TKSP10		EQU	$
		STA	<WORKF		; hankei
;
		LDY	ENMUKI,X
		LDA	TKHDXD,Y
		STA	<WORKC
		LDA	TKHDYD,Y
		STA	<WORKD
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0
		AND	#01FFH
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORKA
;
		LDA	<WORK0
		CLC
		ADC	#0080H
		AND	#01FFH
		STA	<WORK2
;
		LDA	<WORK0
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK4
;
		LDA	<WORK2
		AND	#00FFH
		ASL	A
		TAX
		LDA	>SINDT2,X
		STA	<WORK6
		MEM8
		IDX8
		SEP	#00110000B		
		PLX
;
		LDA	<WORK4
		STA	4202H
		LDA	<WORKF 	    ; Hankei
		LDY	<WORK5
		BNE	KSF0
		STA	4203H
		JSR	EAEAEA
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		ASL	4216H
		LDA	4217H
		ADC	#00H
KSF0		EQU	$
		STA	<WORKE
		LSR	<WORK1
		BCC	KS00
		EOR	#0FFH
		INC	A
KS00		EQU	$
		STA	<WORK4		; XAD
;
		LDA	<WORK6
		STA	4202H
		LDA	<WORKF
		LDY	<WORK7
		BNE	KS08
		STA	4203H
		JSR	EAEAEA
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		ASL	4216H
		LDA	4217H
		ADC	#00H
KS08		EQU	$
		STA	<WORKF
		LSR	<WORK3
		BCC	KS10
		EOR	#0FFH
		INC	A
KS10		EQU	$
		STA	<WORK6		; YAD
;-- oam set -
		LDY	#00H
;
		LDA	<WORK4
		SEC
		SBC	#04H
		CLC
		ADC	<WORKC
		STA	ENKNXP
		CLC
		ADC	ENDSXL
		STA	(<OAMADR),Y
;
		LDA	<WORK6
		SEC
		SBC	#04H
		CLC
		ADC	<WORKD
		STA	ENKNYP
		CLC
		ADC	ENDSYL
		INY
		STA	(<OAMADR),Y		
		LDA	#02AH
		INY
		STA	(<OAMADR),Y
		LDA	#00101101B
		INY
		STA	(<OAMADR),Y
		LDA	#02H
		STA	(<OSBADR)
;--- Chaine set ------
		LDY	#04H
		PHX
		LDX	#03H
TWC000		EQU	$
		LDA	<WORKE
		STA	4202H
		LDA	TKBYDT,X
		STA	4203H
		JSR	EAEAEA
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		LDA	<WORK4
		ASL	A
		LDA	4217H
		BCC	TWC010
		EOR	#0FFH
		INC	A
TWC010		EQU	$
		CLC
		ADC	ENDSXL
		CLC
		ADC	<WORKC
		STA	(<OAMADR),Y
;
		LDA	<WORKF
		STA	4202H
		LDA	TKBYDT,X
		STA	4203H
		JSR	EAEAEA
;;		BYTE	0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH,0EAH
		LDA	<WORK6
		ASL	A
		LDA	4217H
		BCC	TWC020
		EOR	#0FFH
		INC	A
TWC020		EQU	$
		CLC
		ADC	ENDSYL
		CLC
		ADC	<WORKD
		INY
		STA	(<OAMADR),Y
;;		LDA	#02AH
		LDA	#03FH
		INY
		STA	(<OAMADR),Y
		LDA	#00101101B
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#00H
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	TWC000
		PLX
;
		LDY	#0FFH
		LDA	#04H
		JSL	>ALOMCKL
		RTS
;- - - -
TKBYDT		EQU	$
		BYTE	33H,66H,99H,0CCH
;===================
EAEAEA		EQU	$
		HEX	EA,EA,EA,EA
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Heishi 0                               		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HEIS0MV  	EQU	$
		PHB
		PHK
		PLB
		JSR	HEI000
        	PLB
		RTL
;=========================================
;HTESTD		EQU	$
;		BYTE	2,2,2,2,1,1,1,3,3,3,3,0,0,0
H0TURN		EQU	$
		BYTE	3,2,0,1
H0TUR2		EQU	$
		BYTE	08H,00H,0CH,05H
;
HEI000		EQU	$
		LDA	ENMYNO,X
		SEC
		SBC	#HEIS0
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	HEMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
HEMVAD		EQU	$
		WORD	HEIS0M
		WORD	HEI00M
		WORD	HEIS1M
		WORD	HEIS2M
		WORD	HEIS3M
		WORD	HEYA0M
		WORD	HEYA1M
		WORD	HEYA2M
		WORD	HEYA3M
		WORD	HEBO0M
		WORD	ZAKO0M
		WORD	SUNA0M
		WORD	USAG0M
		WORD	HANA0M
		WORD	HANA1M
		WORD	TAMA0M
		WORD	DOZOOM
		WORD	ZORABM
		WORD	NOMOSM
		WORD	RANEMM
		WORD	ZORASM
		WORD	ZORA2M
		WORD	SEKMVM 
		WORD	KANI0M 
		WORD	TORI0M 
		WORD	RISU0M 
		WORD	SPARKM 
		WORD	SPARLM 
		WORD	CHAN0M 
		WORD	CHAN1M 
		WORD	CHAN2M 
		WORD	CHAN3M 
		WORD	MEDUSM 
		WORD	ATARSM 
		WORD	ARI00M 
		WORD	ARI01M 
		WORD	YASANM 
		WORD	HODIRM 
		WORD	HODILM 
		WORD	HODIDM 
		WORD	HODIUM 
                WORD    TEKU0M
                WORD    TAIHOM
                WORD    HYUUUM
                WORD    NEZU0M
                WORD    HEBI0M
                WORD    KOMO0M
                WORD    MOTAMM
;;;;		WORD	RIVERM 
;==============================
TAMA0M		EQU	$
		LDA	ENSTAT,X
		BNE	TAMA1MV
		JSL	>EN1CSTL
		BRA	TAMA000
TAMA1MV		EQU	$
		JSR	TAMA1CS
TAMA000		EQU	$
		JSR	ENSTCK
;
		INC	ENCONT,X
		LDA	ENCONT,X
;;		NOP
;;		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
;
		JSR	ENMVCL
;
		LDA	ENTIM0,X
		BEQ	TMM008		; door in ?
;					; yes !
		DEC	A
		BNE	TMM006		; end ?
;					; yes !
		STZ	ENMODE,X
TMM006		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - -
TMM008		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM2,X
		BNE	TMM010
;
;;		JSR	>CRENPLL
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
		JSR	ENBGCK
		BEQ	TMM010
		LDA	#10H
		STA	ENTIM0,X
;
;;		STZ	ENMODE,X
TMM010		EQU	$
		RTS
;-----------------------------------------------
T1CXAD		EQU	$
		WORD	0FFF8H,0008H,0FFF8H,0008H
T1CYAD		EQU	$
		WORD	0FFF8H,0FFF8H,0008H,0008H
T1CCDT		EQU	$
		HEX	84,88,88,88
		HEX	86,88,88,88
T1CADT		EQU	$
		HEX	00,00,C0,80
;- - - - - - - - - - - - - - - - - - -
TAMA1CS		EQU	$
		JSR	OAMCHK
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORK6
;
		PHX
		LDX	#03H
TM1C10		EQU	$
		PHX
		PHX
		TXA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	T1CXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	T1CYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	TM1C20
		LDA	#0F0H
		STA	(<OAMADR),Y
TM1C20		EQU	$		
		PLA
		CLC
		ADC	<WORK6
		TAX
		LDA	T1CCDT,X
		INY
		STA	(<OAMADR),Y
		PLX
		LDA	T1CADT,X
		INY
		ORA	<WORK5
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		ORA	#02H
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	TM1C10
		PLX
		RTS
;==============================
DOZOOM		EQU	$
		JSR	DOZOOCS
;
		LDA	ENHNFG,X
		BEQ	DOM1F8
;
		JSR	H0SDCL
DOM1F8		EQU	$
		JSR	ENSTCK
;
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	DOM1F0
		STZ	ENZPSL,X
		STZ	ENZSPD,X
		JSR	H0SDCL
DOM1F0		EQU	$
;
		LDA	ENSTAT,X
		BEQ	DOM1FE
;
		JMP	DOM100
;
DOM1FE		EQU	$
		LDA	ENMOD2,X
		ORA	#01000000B
		STA	ENMOD2,X
;
		LDY	ENTIM0,X
		CPY	#01H
		BNE	DOM000		; move start ?
;					; yes !
		AND	#10111111B 
		STA	ENMOD2,X
;
		INC	ENSTAT,X
;;		INC	ENKBMK,X
;
		ASL	ENMOD0,X
		LSR	ENMOD0,X
;
		LDA	ENMOD2,X
		AND	#10111111B
		STA	ENMOD2,X
;
;;		LDA	ENCLOR,X
;;		AND	#11110001B
;;		ORA	#08H
		LDA	#0AH+1
		STA	ENCLOR,X
		RTS
;- - - - - - - - - - - - - - - - - - -- -
DOM000		EQU	$
		TXA
		EOR	<FRCNT
		AND	#03H
		BNE	DOM002
;
		MEM16
		REP	#20H
;
		LDA	<PLXPS1
		SEC
		SBC	ENXP2L
;
;;		JSR	EPXYCK
;;		LDA	<WORKF
		CLC
		ADC	#001FH
		CMP	#003EH
		BCS	DOM002
;
		LDA	<PLYPS1
		CLC
		ADC	#0008H
		SEC
		SBC	ENYP2L
;
;;;		LDA	<WORKE
		CLC
		ADC	#030H
		CMP	#058H
		BCS	DOM002
;
		MEM8
		SEP	#20H
;
		LDA	ENTIM0,X
		BNE	DOM002
;
		LDA	#30H
		STA	ENTIM0,X
;
		LDA	#22H
		JSL	>SDLRE2	;(S)
DOM002		EQU	$
		MEM8
		SEP	#20H
;
		JSL	>CRENPL2L
		BCC	DOM010
;;		MEM16
;;		REP	#00100000B
;;;
;;		LDA	PLSVX1
;;		STA	<PLXPS1
;;		LDA	PLSVY1
;;		STA	<PLYPS1
;;;
;;		MEM8
;;		SEP	#020H
		JSL	>PLOTCK
;
		JSL	>DASHON
;;		LDA	ENTIM0,X
;;		BNE	DOM010
;;;
;;		LDA	#80H
;		STA	ENTIM0,X
DOM010		EQU	$
		LDA	ENTIM0,X
		BEQ	DOM030
;
		LSR	A
		AND	#00001110B
		EOR	ENCLOR,X
		STA	ENCLOR,X
DOM030		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - -- -
DOM100		EQU	$
		JSR	CREKEK
		JSR	ENHNSB
;
		JSR	ENMVCL
;
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		LDA	ENTIM0,X
		ORA	ENZPSL,X
		BNE	DOM110
;
		LDA	#08H
		STA	ENTIM0,X
		LDA	#10H
		STA	ENZSPD,X
;
		LDA	#08H+4
		JSL	>PSERCHL
DOM110		EQU	$
		RTS	
;-----------------------
;DOCSYD		EQU	$
;		WORD	0FFF0H,00H
;DOCSCD		EQU	$
;		HEX	C0,E0
;- - - - -- - - - - -
DOZOOCD		EQU	$
		WORD	0,0FFF0H
		HEX	C0,00,00,02
		WORD	0,000H
		HEX	E0,00,00,02
;
DOZOOCS		EQU	$
;;		LDA	#0F0H
;;		JSL	>OOTSUC2
;
		LDA	ENSTAT,X
		BNE	DOCS10
;
		JSR	OAMCHK
DOCS10		EQU	$
		MEM16
		REP	#20H
		LDA	#DOZOOCD
		STA	<WORK8
		MEM8
		SEP	#20H
;
		LDA	#02H
		JSR	SETO22
;;		JSL	>SETOAML22
		JSL	>SADWSTL
		RTS
;
;		JSR	OAMCHK
;;
;		LDA	ENSTAT,X
;		BNE	DOCSF0
;;
;		JSL	>OCHECKL
;		LDY	#00H
;DOCSF0		EQU	$
;		PHX
;		LDX	#01H
;DOCS00		EQU	$
;		PHX
;		TXA
;		ASL	A
;		TAX
;		MEM16
;		REP	#00100000B
;		LDA	<WORK0
;		STA	(<OAMADR),Y
;		AND	#0100H
;		STA	<WORKE
;		LDA	<WORK2
;		CLC
;		ADC	DOCSYD,X
;		INY
;		STA	(<OAMADR),Y
;		CLC
;		ADC	#0010H
;		CMP	#0100H
;		MEM8
;		SEP	#020H
;		BCC	DOCS10
;		LDA	#0F0H
;		STA	(<OAMADR),Y
;DOCS10		EQU	$
;		PLX
;		LDA	DOCSCD,X
;		INY
;		STA	(<OAMADR),Y
;		INY
;		LDA	<WORK5
;		STA	(<OAMADR),Y
;		PHY
;		TYA
;		LSR	A
;		LSR	A
;		TAY
;		LDA	#02H 
;		ORA	<WORKF
;		STA	(<OSBADR),Y
;		PLY
;		INY
;		DEX
;		BPL	DOCS00
;		PLX
;		JSL	>SADWSTL
;		RTS
;==== Hnakatsuo slime  ============
HANA0M		EQU	$
HANA1M		EQU	$
		JSR	HANA0CS
		JSR	ENSTCK
		JSR	ENHNSB
;
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		STA	ENWRK0,X
;
		JSR	CREKEK
;
		LDA	ENSTAT,X
		CMP	#02H
		BEQ	HNWALK
		CMP	#01H
		BEQ	HNWAIT
HNSTOP		EQU	$
		LDA	ENTIM0,X
		BNE	HNS010
;;		LDA	ENMYNO,X
;;		CMP	#HANA0
;;		BEQ	HNS010
;
		INC	ENSTAT,X
		LDA	#069H
		STA	ENTIM0,X
HNS010		EQU	$
		RTS
;---------------------------------------------------
HNWAIT		EQU	$
		INC	ENCONT,X
		LDA	ENTIM0,X
		BNE	HNW010
;
		JSL	>RNDSET
		AND	#3FH
		ADC	#80H
		STA	ENTIM0,X
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#0FH
		TAY
		LDA	KOMXSD,Y
		ASL	A
		ASL	A
		STA	ENXSPD,X
		LDA	KOMYSD,Y
		ASL	A
		ASL	A
		STA	ENYSPD,X
HNW010		EQU	$
		RTS
;--------------------------------------------
HNWALK		EQU	$
		INC	ENCONT,X
		LDA	ENTIM0,X
		BNE	HNWK10
HNWK00		EQU	$
		STZ	ENSTAT,X
		LDA	#50H
		STA	ENTIM0,X
		RTS
HNWK10		EQU	$
		TXA
		EOR	<FRCNT
		AND	ENWRK1,X
;;		AND	#0FH
		BNE	HNWK20
;
		JSR	ENMVCL
		LDA	ENCBFG,X
		BNE	HNWK00
;
HNWK20		EQU	$
ENBGCK		EQU	$
		JSL	>ENBGCKL
		RTS
;==============================================
HNPTDT		EQU	$
		HEX	0,1,0,1
HNMKDT		EQU	$
		HEX	00,00,40,40
;
HANA0CS		EQU	$
		LDY	ENWRK0,X
		LDA	HNPTDT,Y
		STA	ENCHPT,X
		LDA	ENCLOR,X
		AND	#10111111B
		ORA	HNMKDT,Y
		STA	ENCLOR,X
		JSL	>EN1CSTL
		RTS
;==== SUNA OTOKO ============
SUNA0M		EQU	$
		LDA	ENSTAT,X
		CMP	#02H
		BCS	SNM002
;
		JSL	>OAMCHKL	
		BRA	SNM010
;
SNM002		EQU	$
		JSR	SUNA0CS
SNM010		EQU	$
;
;;		LDA	<KEYA2
;;		AND	#0CH
;;		BEQ	SNM010
;;		LDA	ENCHPT,X
;;		INC	A
;;		STA	ENCHPT,X
;;		CMP	#06H
;;		BNE	SNM010
;;		STZ	ENCHPT,X
;;SNM010		EQU	$
;;		RTS
;
		JSR	ENSTCK
		JSR	ENHNSB
;
;;		JSL	>CRKNENL
;
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	SNMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
SNMVAD		EQU	$
		WORD	SNWAIT	;0
		WORD	SNKYRO	;1
		WORD	SNGOO1	;2
		WORD	SNGOO2	;3
		WORD	SNEND 	;4
;------------------------
SNWAIT		EQU	$
		LDA	ENTIM0,X
		BNE	SNW010
;
		LDA	ENWRK0,X
		STA	ENXPSL,X
		LDA	ENWRK1,X
		STA	ENXPSH,X
		LDA	ENWRK2,X
		STA	ENYPSL,X
		LDA	ENKBMK,X
		STA	ENYPSH,X
		INC	ENSTAT,X
SNW010		EQU	$
		RTS
;--------------------------
SNKYRO		EQU	$
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	SNK010
;
		MEM16
		REP	#20H
		LDA	<PLXPS1
		SEC
		SBC	ENXP2L
		CLC
		ADC	#0030H
		CMP	#0060H
		BCS	SNK010
		LDA	<PLYPS1
		SEC
		SBC	ENYP2L
		CLC
		ADC	#0030H
		CMP	#0060H
		BCS	SNK010
;
		MEM8
		SEP	#20H
;
;		JSR	EPXYCK
;		LDA	<WORKE
;		CLC
;		ADC	#30H
;		CMP	#60H
;		BCS	SNK010
;		LDA	<WORKF
;		CLC
;		ADC	#30H
;		CMP	#60H
;		BCS	SNK010
;
SNGNXT		EQU	$
		INC	ENSTAT,X
		LDA	#08H+0FH+8
		STA	ENTIM0,X
SNK010		EQU	$
		MEM8
		SEP	#20H
;;		TXA
;;		EOR	<FRCNT
;;		AND	#00100000B
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		STA	ENCHPT,X
		RTS
;--------------------------
SNGOO1		EQU	$
		LDA	ENTIM0,X
		BNE	SNG100
;
		INC	ENSTAT,X
		LDA	#060H
		STA	ENTIM0,X
		LDA	#10H
		JSL	>PSERCHL
		RTS
SNG100		EQU	$
;;		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	SNG1PT,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - - - -
SNG1PT		EQU	$
		HEX	3,2,0,0,0,0,0,0
SNG2PT		EQU	$
		HEX	4,5
SNEDPT		EQU	$
		HEX	0,1,2,3,3
;;		HEX	0,0,1,1,0,0,2,3
;--------------------------
SNGOO2		EQU	$
		STZ	ENNOCR,X
		LDA	ENTIM0,X
		BNE	SNG200
;
		INC	ENSTAT,X
		LDA	#08H
		STA	ENTIM0,X
		RTS
SNG200		EQU	$
;;		LSR	A
		LSR	A
		LSR	A
		AND	#01H
		TAY
		LDA	SNG2PT,Y
		STA	ENCHPT,X
;;		JSL	>CRENPLL
		JSR	CREKEK
;
		JSR	ENMVCL
		RTS
;--------------------------
SNEND		EQU	$
		LDA	ENTIM0,X
		BNE	SNE010
		STZ	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
		RTS
SNE010		EQU	$
;;              LSR	A
;;		LSR	A
		LSR	A
		TAY	
		LDA	SNEDPT,Y
		STA	ENCHPT,X
		RTS
;--------------------------
;--------------------------
;===========================================
SNCXAD		EQU	$
		WORD	04,04,04
		WORD	04,04,04
		WORD	0FFF8H,08,08
		WORD	0FFF8H,08,08
		WORD	0FFF0H,00,10H
		WORD	0FFF0H,00,10H
SNCYAD		EQU	$
		WORD	08,08,08
		WORD	08,08,08
		WORD	04,04,04
		WORD	00,00,00
		WORD	00,00,00
		WORD	00,00,00
SNCCDT		EQU	$
		HEX	B8,B8,B8
		HEX	B8,B8,B8
		HEX	A6,A6,A6
		HEX	A6,A6,A6
		HEX	A4,A2,A0
		HEX	A0,A2,A4
SNCADT		EQU	$
		HEX	00,00,00
		HEX	40,40,40
		HEX	00,40,40
		HEX	00,40,40
		HEX	40,40,40
		HEX	00,00,00
SNCSBD		EQU	$
		HEX	00,00,00
		HEX	00,00,00
		HEX	02,02,02
		HEX	02,02,02
		HEX	02,02,02
		HEX	02,02,02
;- - - - - - - - - - - - - - - - - - - -
SUNA0CS		EQU	$
		JSR	OAMCHK
;
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
;- head -
		PHX
		LDX	#02H
SNC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	SNCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	SNCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#00100000B
		BCC	SNC012
		LDA	#0F0H
		STA	(<OAMADR),Y
SNC012		EQU	$
		PLX
;
		LDA	SNCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	SNCADT,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
;
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	SNCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	SNC010
		PLX
		RTS
;- Body --
;
;
;
;
;
;
;
;
;==== USAGI MODOKI  ============
USAG0M		EQU	$
		LDA	ENSTAT,X
		BEQ	USM010
;
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
;
		JSR	USAG0CS
USM010		EQU	$
;
		JSR	ENSTCK
;
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	USMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
USMVAD		EQU	$
		WORD	USSET	;0
		WORD	USWAIT	;1
		WORD	USKYRO	;2
		WORD	USJUMP	;3
		WORD	USEND 	;4
		WORD	USFAIL	;5
UFIL		EQU	5
;------------------------
USSXAL		EQU	$
		HEX	E0,20,00,00
USSXAH		EQU	$
		HEX	FF,00,00,00
USSYAL		EQU	$
		HEX	00,00,E0,20
USSYAH		EQU	$
		HEX	00,00,FF,00
;- - - - - - - - - - - - - - - - - - - - - -
USSET		EQU	$
		LDA	ENTIM0,X
		BNE	USS010
		INC	ENSTAT,X
		LDA	#08H
		STA	ENTIM0,X
;
		JSL	>RNDSET
		AND	#03H
		TAY
		LDA	ENWRK0,X
		CLC
		ADC	USSXAL,Y
		STA	ENXPSL,X
		LDA	ENWRK1,X
		ADC	USSXAH,Y
		STA	ENXPSH,X
		LDA	ENWRK2,X
		CLC
		ADC	USSYAL,Y
		STA	ENYPSL,X
		LDA	ENKBMK,X
		ADC	USSYAH,Y
		STA	ENYPSH,X
USS010		EQU	$	
		RTS
;------------------------
USWAIT		EQU	$
		LDA	ENTIM0,X
		BNE	USW010
		INC	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
		RTS
USW010		EQU	$	
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
		JSR	USBGCK
		RTS
;--------------------------------------	
USKYRO		EQU	$
		LDA	ENTIM0,X
		BNE	USK010
;
		INC	ENSTAT,X
		LDA	#040H
		STA	ENZSPD,X
;
USK010		EQU	$
		LDA	#02H
		STA	ENCHPT,X
		JSR	USBGCK
		RTS
;--------------------------------------	
USJUMP		EQU	$
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
		JSR	CREKEK
;
		JSR	ENZCLC
		LDA	ENZSPD,X
		SEC
		SBC	#02H
		STA	ENZSPD,X
		LDA	ENZPSL,X
		BPL	USJ010
		STZ	ENZPSL,X
;
		INC	ENSTAT,X
		LDA	#10H
		STA	ENTIM0,X
;
		JSR	USBGCK
;
USJ010		EQU	$
		RTS
;--------------------------------------	
USEND		EQU	$
		LDA	ENTIM0,X
		BNE	USE010
		STZ	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
		BRA	USE020
USE010		EQU	$	
		LSR	A
		LSR	A
		AND	#01H
		STA	ENCHPT,X
USE020		EQU	$	
		JSR	USBGCK
		RTS
;---------------------------------------------
USFAIL		EQU	$
		JSL	>USFAILL
		RTS
;
;		JSL	>CRKNENL
;;
;		INC	ENCONT,X
;		LDA	ENCONT,X
;		AND	#04H
;		LSR	A
;		LSR	A
;		ADC	#03H
;		STA	ENCHPT,X
;		RTS
;---------------------------------------------
USBGCK		EQU	$
		LDA	ENYPSL,X
		STA	<WORK0
		LDA	ENYPSH,X
		STA	<WORK1
		LDA	ENXPSL,X
		STA	<WORK2
		LDA	ENXPSH,X
		STA	<WORK3
		LDA	#00H
		JSL	>BGDTRD2	; kusa check !
;
		CMP	#40H
		BEQ	USBG00
		LDA	#UFIL
		STA	ENSTAT,X
USBG00		EQU	$
		RTS
;================================================
USCXAD		EQU	$
		WORD	00,08,08
		WORD	00,08,08
		WORD	00,00,08
		WORD	00,00,00
		WORD	00,00,00
USCYAD		EQU	$
		WORD	08,08,08
		WORD	08,08,08
		WORD	00,08,08
		WORD	00,00,00
		WORD	00,00,00
USCCDT		EQU	$
		HEX	C8,C8,C8
		HEX	CA,CA,CA
		HEX	C0,C8,C8
		HEX	C2,C2,C2
		HEX	C2,C2,C2
USCADT		EQU	$
		HEX	00,40,40
		HEX	00,40,40
		HEX	00,00,40
		HEX	00,00,00
		HEX	40,40,40
USCSBD		EQU	$
		HEX	0,0,0
		HEX	0,0,0
		HEX	2,0,0
		HEX	2,2,2
		HEX	2,2,2
;- - - - - - - - - - - - - - - - - - - - - - -
USAG0CS		EQU	$
		JSR	OAMCHK
		LDA	ENYPSL,X
		SEC
		SBC	<SCCV2
		STA	<WORK6
		LDA	ENYPSH,X
		SBC	<SCCV2+1
		STA	<WORK7
;
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK8
;
		PHX
		LDX	#02H
USC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK8
		PHA
		TAX
		LDA	USCSBD,X
		STA	<WORKC
		TXA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	USCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		PHX
		LDX	<WORKC
		CPX	#01H
		PLX
		LDA	<WORK2
		BCS	UNS020
		LDA	<WORK6
UNS020		EQU	$
		CLC
		ADC	USCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8	
		SEP	#00100000B
		BCC	UNS030
		LDA	#0F0H
		STA	(<OAMADR),Y
UNS030		EQU	$
		PLX
		LDA	USCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	<WORKC
		CMP	#01H
		LDA	USCADT,X
		ORA	<WORK5
		BCS	UNC030
		AND	#11110000B
		ORA	#02H
UNC030		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKC
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	USC010
		PLX
		RTS
;--------------------------------------	
;
;
;
		RTS
;==== ZAKO HEISHI ============
ZKXSDT		EQU	$
		HEX	0C,F4,00,00
		HEX	12,EE,00,00
ZKYSDT		EQU	$
		HEX	00,00,0C,F4
		HEX	00,00,12,EE
ZKCHPT		EQU	$
ZSCHPT		EQU	$
		HEX	00,02,04,06
		HEX	01,03,05,07
;
;;		HEX	00,01
;;		HEX	02,03
;;		HEX	04,05
;;		HEX	05,06
;--------------------------------------
ZAKO0M		EQU	$
		LDA	ENCONT,X
		AND	#00001000B
		LSR	A
		ADC	ENMUKI,X
		TAY
		LDA	ZKCHPT,Y
		STA	ENCHPT,X		
		JSR	ZAKO0CS
;
		JSR	ENSTCK
;
;		LDA	ENHNFG,X
;		BEQ	ZK0000		; damege ?
;;					; yes ! fury !!
;		LDA	#01H
;		STA	ENSTAT,X
;		JSR	EPXYCK
;		TYA
;		STA	ENKBMK,X
;		JSR	ZKSDST
;		LDA	#30H
;		STA	ENTIM0,X
;		STA	ENTIM1,X
;ZK0000		EQU	$
;
		JSR	ENHNSB
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
		JSR	CREKEK
;
		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		LDA	ENSTAT,X
		BNE	ZKWALK
;
		LDA	ENTIM0,X
		BNE	ZKS010
;
		JSL	>RNDSET
		AND	#3FH
		ADC	#30H
		STA	ENTIM0,X
		INC	ENSTAT,X
;
ZKSDST		EQU	$
		LDA	ENKBMK,X
		STA	ENMUKI,X
;
		JSR	EPXYCK
		TYA
		LDY	ENMUKI,X
		CMP	ENMUKI,X
		BNE	ZKSS0A		
;
		LDA	<WORKE
		CLC
		ADC	#10H
		CMP	#20H
		BCC	ZKSS08
		LDA	<WORKF
		CLC
		ADC	#10H
		CMP	#20H
		BCS	ZKSS0A		; Muki => Player ?
ZKSS08		EQU	$		; yes !
		INY
		INY
		INY
		INY
		LDA	#80H
		STA	ENTIM0,X	; High speed & long time !
ZKSS0A		EQU	$
;;		LDY	ENMUKI,X
;;		LDA	ENTIM1,X
;;		BEQ	ZSSS10
;;		INY
;;		INY
;;		INY
;;		INY
;;ZSSS10		EQU	$
		LDA	ZKXSDT,Y
		STA	ENXSPD,X
		LDA	ZKYSDT,Y
		STA	ENYSPD,X
ZKS010		EQU	$
		RTS
;============================================
ZKNXMK		EQU	$
		HEX	2,3,2,3,0,1,0,1
;
ZKWALK		EQU	$
		LDA	#10H
;
		LDY	ENCBFG,X
		BNE	ZKW008
;
		LDA	ENTIM0,X
		BNE	ZKW010
;
		LDA	#30H
ZKW008		EQU	$
		STA	ENTIM0,X
;
		JSR	H0SDCL
;
;;		LDA	#30H
;;		STA	ENTIM0,X
;
		JSL	>RNDSET
		AND	#01H
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ORA	<WORK0
		TAY
		LDA	ZKNXMK,Y
		STA	ENKBMK,X
;
		STZ	ENSTAT,X
ZKW010		EQU	$
		LDA	ENTIM1,X
		BEQ	ZKPTST		; HI SPEED ?
;					; YES !
		INC	ENCONT,X
ZKPTST		EQU	$
		INC	ENCONT,X
		RTS
;- - - - - - - - - - - - - - - - - - - - -
Z0HDCD		EQU	$
		BYTE	082H,082H,080H,084H
Z0HDAD		EQU	$
		BYTE	040H,000H,000H,000H
;
ZKCXAD		EQU	$
		WORD	02,02,0FFFEH,0FFFEH,00,00,00,00
;;ZKCYAD		EQU	$
;;		WORD	00,00,00,00,00,00,00,00
ZKCCDT		EQU	$
		HEX	8A,8C,8A,8C,86,88,8E,A0
ZKCADT		EQU	$
		HEX	40,40,00,00,00,00,00,00
ZAKO0CS	        EQU	$
;- - - - - - - - - - - - - - - - - - - - - - - -
;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDA	ENCHPT,X
;;		ASL	A
		STA	<WORK6
;- head -
		PHX
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		SEC
		SBC	#0BH
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	ZKC012
		LDA	#00F0H
		STA	(<OAMADR),Y
ZKC012		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	H0HDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	H0HDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
;
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR)
; Body --
		LDA	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0 
		CLC
		ADC	ZKCXAD,X
		INY
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
;;		CLC
;;		ADC	ZKCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	ZKBC10
;
		LDA	#00F0H
		STA	(<OAMADR),Y
ZKBC10		EQU	$
		MEM8
		SEP	#00100000B
;
		PLX
		LDA	ZKCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	ZKCADT,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
;
		LDY	#01H
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
;;		LDY	#02H
;;		LDA	#01H
;;		JSL	>ALOMCKL
		JSL	>SADWSTL
		RTS
;
;
;
;
;
;-----Tekkyu heishi---------------------------------
HEBO0M		EQU	$
		LDA	ENWRK2,X
		BNE	BOMBMV
;
		JMP	BOM0F0		; bomb ?
;					; yes !
BOMBMV		EQU	$
		CMP	#02H
		BCS	CIE00F
;- - - Bomb - -
		JMP	BB0010
;- - - Bakuhatsu - - -
CIE00F		EQU	$
		BNE	CIE023	    	; From enemy ?
;					; yes ! (3;shsai fail)
		LDY	#ENNO-1
CIE010		EQU	$
        	CPY	ENINDX
		BEQ	CIE020		; myself ?
;
		LDA	ENMODE,Y	; no !
		CMP	#EMOVE
		BCC	CIE020
		TYA
		EOR	<FRCNT
		AND     #07H
		ORA	ENFLSH,Y
		BNE	CIE020
;
		JSR	CIESUB
CIE020		EQU	$
		DEY
		BPL	CIE010
;
		JSL	>CRENPLL
;
CIE023		EQU	$
		JSR	BBBRCS
;
		LDA	ENTIM1,X
		BNE	BBR010
;
		STZ	ENMODE,X
BBR010		EQU	$
 		RTS
;------------------------------------
CIESUB		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<WORK0
		LDA	ENXPSH,X
		SBC	#00H
		STA	<WORK8
		LDA	#30H
		STA	<WORK2
		STA	<WORK3
		LDA	ENYPSL,X
		SEC
		SBC	#10H
		STA	<WORK1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<WORK9
;
		PHX
		TYX
		JSL	>ENCRST2
          	PLX
		JSL	>CROJCK2
		BCC	CIE090
;
		LDA	ENMYNO,Y
		CMP	#HINO0
		BEQ	CIE090
;
		PHX
		TYX
		PHY
		LDA	#08H		;Bomb !
		JSL	>ENDMST3
		PLY
		PLX
		LDA	ENXPSL,X
		STA	<WORK0
		LDA	ENXPSH,X
		STA	<WORK1
		LDA	ENYPSL,X
		SEC
		SBC	ENZPSL,X
		STA	<WORK2
		LDA	ENYPSH,X
		SBC	#00H
		STA	<WORK3
;
		LDA	ENXPSL,Y
		STA	<WORK4
		LDA	ENXPSH,Y
		STA	<WORK5
		LDA	ENYPSL,Y
		SEC
		SBC	ENZPSL,Y
		STA	<WORK6
		LDA	ENYPSH,Y
		SBC	#00H
		STA	<WORK7
		PHY
		LDA	#20H
		JSL	>ESERCHL
		PLY
		LDA	<WORK0
		STA	ENHNYS,Y
		LDA	<WORK1
		STA	ENHNXS,Y
;
CIE090		EQU	$
		RTS
;
;- - - - - - - - - - - - -- - - -- - -- --
BB0010		EQU	$
		LDA	ENWRK3,X
		BEQ	BB0008		; Tenjyon down ?
;					; yes !
		LDA	ENFLCL,X
		ORA	#30H
		STA	ENFLCL,X
BB0008		EQU	$
;;		LDA	OJBKFG
;;		CMP	#03H
;;		BCS	BB0009		; Bank ok ? (Special magic)
;
 		JSL	>EN1CSTL
;
BB0009		EQU	$
		LDA	ENFLSH,X
		BNE	BB0011		
;
		LDA	ENTIM1,X
		CMP	#40H
		BCS	BOMBF0
;
		CMP	#01H
		BNE	BOMBE0		; Bakuhatsu time ?
;					; yes !
BB0011		EQU	$
		STZ	ENFLSH,X
;
		LDA	ENMODE,X
		CMP	#ECACH
		BNE	BB1112 		; Cached ?
;					; yes !
                STZ     PYDMBT1         ; cach reset !
                STZ     PYDMBT          ; cach reset !
;
BB1112		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#0CH
;;		STA	SOUND2	 ;(S)
		LDA	#0CH
		JSL	>SDLRE2	;(S)
;
		INC	ENWRK2,X
;
		LDA	#09H
		STA	ENMOD3,X
;
		LDA	#02H
		STA	ENCLOR,X
;
		LDA	#20H-1
		STA	ENTIM1,X
;
;;		LDA	ENMODE,X
;;		CMP	#ECACH
;;		BNE	BOMBD8
;;;		CACH CLEAR !
		LDA	#EFAIL
		STA	ENMODE,X
		LDA	#03H
		STA	ENMOD0,X
BOMBD8		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - -
BOMBE0		EQU	$
		LSR	A
		AND	#00001110B
		STA	<WORK0
;
		LDA	ENCLOR,X
		AND	#11110001B
		ORA	<WORK0
		STA	ENCLOR,X
;;;		RTS
;
BOMBF0		EQU	$
		JSR	ENSTCK
;
		LDA	ENTUTM,X
		BNE	BOMB0FF
;
		JSL	>CRKNENL
;
BOMB0FF		EQU	$
;;;;;;		JSL	>CACHCKL
;
		JSR	ENMVCL
;
		LDA	<DJFLG
		BEQ	BBM00
;
		JSR	ENBGCK
BBM00		EQU	$
		JSL	>ENBDSBL
;;		JSR	ENBDCL
;
;;		LDA	ENXSPD,X
;;		ORA	ENYSPD,X
;;		BNE	BOMB00		; stop ?
;;;
;;		LDA	#40H		; yes ! bakuhatsu time set !
;;		STA	ENTIM0,X
BOMB00		EQU	$
		RTS
;
;===========================================================
;ENBDCL		EQU	$
;		JSR	ENMVCL
;;
;		JSR	ENZCLC
;;
;		LDA	ENZSPD,X
;		SEC
;		SBC	#02H
;		STA	ENZSPD,X
;		LDA	ENZPSL,X
;		BPL	EIC008
;		STZ	ENZPSL,X
;
;		LDA	ENZSPD,X
;		EOR	#0FFH
;		INC	A
;		LSR	A
;		NOP	
;		CMP	#09H
;		BCS	EIC003
;		LDA	#00H
;EIC003		EQU	$
;		STA	ENZSPD,X
;		LDA	ENXSPD,X
;		ASL	A
;		ROR	ENXSPD,X
;		LDA	ENXSPD,X
;		CMP	#0FFH
;		BNE	EIC005
;		STZ	ENXSPD,X	
;EIC005	 	EQU	$
;		LDA	ENYSPD,X
;		ASL	A
;		ROR	ENYSPD,X
;		LDA	ENYSPD,X
;		CMP	#0FFH
;		BNE	EIC008
;		STZ	ENYSPD,X	
;EIC008		EQU	$
;ENIC10		EQU	$
;		RTS
;
;========================================================================
BOM0F0		EQU	$
		JSR	HEBO0CS
;
		JSR	ENSTCK
;
;;		JSL	>CRKNENL
		JSR	CREKEK
;
;;		LDA	MIHAFG
;;		BNE	BOM000
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
;
		LDA	ENSTAT,X
		BNE	BOM010
;
		LDA	ENTIM0,X
		BNE	BOM000
;
		INC	ENSTAT,X
BOMFFF		EQU	$
		LDA	#70H
		STA	ENTIM0,X
BOM000		EQU	$
		RTS
;====================================================================
BOM010		EQU	$
		LDA	ENTIM0,X
		BNE	BO0010
;
		STZ	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
		RTS
BO0010		EQU	$
		STZ	ENCONT,X
		CMP	#050H
		BCC	BO0018
		INC	ENCONT,X
BO0018		EQU	$
		CMP	#20H
		BNE	BO0020
		PHA
;
		JSR	BOMBSET
		PLA
BO0020		EQU	$
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		CLC
		ADC	#Y2PT1-Y2PT0
		TAY
		LDA	HYYPTD,Y
		STA	ENCHPT,X
		RTS
;==========================================
BBSXAL		EQU	$
		BYTE	000H,001H,009H,0F8H
BBSXAH		EQU	$
		BYTE	000H,000H,000H,0FFH
BBSYAL		EQU	$
		BYTE	0F4H,0F4H,0F1H,0F3H
BBSYAH		EQU	$
		BYTE	0FFH,0FFH,0FFH,0FFH
;BBSXSD		EQU	$
;		BYTE	010H,0F0H,000H,000H
;BBSYSD		EQU	$
;		BYTE	000H,000H,010H,0F0H
;
;- - - - --- - --- - -- - - - --- - - - --
BOMBSET		EQU	$
		LDA	#HEBO0
		JSL	>ENIDSH
		BMI	BBS010
		PHX
		LDA	ENMUKI,X
		TAX
		LDA	<WORK0
		CLC
		ADC	BBSXAL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	BBSXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	BBSYAL,X
		STA	ENYPSL,Y
		LDA	<WORK3	
		ADC	BBSYAH,X
		STA	ENYPSH,Y
;
		TYX
		LDA	#10H
		JSL	>PSERCHL
;;		LDA	BBSXSD,X
;;		STA	ENXSPD,Y
;;		LDA	BBSYSD,X
;;		STA	ENYSPD,Y
		LDA	#01H
		STA	ENWRK2,X
;
		JSR	EPXYCK
		LDA	<WORKF
		BPL	HBS008
		EOR	#0FFH
		INC	A
HBS008		EQU	$
		STA	<WORKF
;
		LDA	<WORKE
		BPL	HBS010
		EOR	#0FFH
		INC	A	
HBS010		EQU	$
		ORA	<WORKF
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	HBSZSD,Y
;;		LDA	#030H
		STA	ENZSPD,X
;
		LDA	ENMOD2,X
		AND	#11101110B
		ORA	#00011000B
		STA	ENMOD2,X
		LDA	#08H
		STA	ENCLOR,X
		LDA	#0FFH
		STA	ENTIM1,X
		STZ	ENLIFE,X
;
;;		JSL	>SDLRCE
;;		ORA	#13H
;;		STA	SOUND3	;(S)
		LDA	#13H
		JSL	>SDLRE3	;(S)
;
		PLX
BBS010		EQU	$
		RTS
;---------------------
HBSZSD		EQU	$
		HEX	20,28,30,38,40,40,40,40 
		HEX	40,40,40,40,40,40,40,40
;=========================================
HEBO0CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	#04H+04H
		JSR	TKHDC2		; head set 
		LDY	#00H+04H
		JSR	TKBDC2		; body set 
		LDA	ENCHPT,X
		CMP	#14H
		BCS	B0C098		; with BOMB ?
;;;					; yes !
		JSR	B0WPCS
B0C098		EQU	$
;
;;		LDY	#0FFH
;;		LDA	#04H
;;		JSL	>ALOMCKL
		LDA	#0AH
		JSL	>SADWS2L
		RTS
;;		JMP	HESWST
;;;		RTS
;- - - - - - - - - - - -
BWCXAD		EQU	$
		WORD	00FFFFH,01
		WORD	02,00
		WORD	09,09
		WORD	0FFF8H,0FFF8H
BWCYAD		EQU	$
		WORD	0FFF4H,0FFF4H
		WORD	0FFF4H,0FFF4H
		WORD	0FFF0H,0FFF2H
		WORD	0FFF4H,0FFF2H
;
B0WPCS		EQU	$
		PHX
		LDA	ENMUKI,X
		ASL	A
		ORA	ENCONT,X
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	BWCXAD,X
		LDY	#00H
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	BWCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	B0WC10
;
		LDA	#00F0H
		STA	(<OAMADR),Y
B0WC10		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	#6EH
		INY
		STA	(<OAMADR),Y
		INY
;;		LDA	#28H
		LDA	<WORK5
		AND	#00110000B
		ORA	#00001000B
		STA	(<OAMADR),Y
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR)
		PLX
		RTS
;
;=========================================
BBBRXD		EQU	$
		HEX	F4,0C,F4,0C
		HEX	F8,08,F8,08
		HEX	F8,08,F8,08
		HEX	00,00,00,00
BBBRYD		EQU	$
		HEX 	F4,F4,0C,0C
		HEX 	F8,F8,08,08
		HEX 	F8,F8,08,08
		HEX 	00,00,00,00
BBBRCD		EQU	$
		HEX 	88,88,88,88
		HEX 	8A,8A,8A,8A
		HEX 	84,84,84,84
		HEX 	86,86,86,86
BBBRAD		EQU	$
		HEX 	00,40,80,C0
		HEX 	00,40,80,C0
		HEX 	00,40,80,C0
		HEX 	00,00,00,00
;
BBBRCS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		LDA	ENTIM1,X
		LSR	A
		AND	#00001100B
		STA	<WORK6
;
		PHX
		LDX	#03H
BBBC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		TAX
		LDA	<WORK0
		CLC
		ADC	BBBRXD,X
		STA	(<OAMADR),Y
;
		LDA	<WORK2
		CLC
		ADC	BBBRYD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	BBBRCD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	BBBRAD,X
;;;		ORA	#22H
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		INY
		PLX
		DEX
		BPL	BBBC10
		PLX
;
		LDY	#02H
		LDA	#03H
		JSL	>ALOMCKL
		RTS
;
;----------------------------------------------------
HEIS0M		EQU	$
HEI00M		EQU	$
HEIS1M		EQU	$
;;		BRA	QWQW
;;;
;;		LDA	ENFLCL,X
;		AND	#0F0H
;		STA	ENFLCL,X
;		JSL	>EN1CSSL
;		LDY	#02H
;		LDA	#029H
;		STA	(<OAMADR),Y
;;
;		LDA	#0AH
;		STA	ENCLOR,X
;		STA	ENLIFE,X
;;
;		JSL	>CRKNENL
;		BCC	WEE
;;
;		LDA	#0CH
;		STA	ENCLOR,X
;WEE		EQU	$
;		RTS
;
;QWQW		EQU	$
		LDA	ENWRK2,X
		BNE	HA0F00
		JMP	HEI001	; serch beam ?
HA0F00		EQU	$
;				; yes !
		LDY	#00H
		LDA	ENXSPD,X
		BPL	HA0100
		DEY
HA0100		EQU	$
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,X
		TYA
		ADC	ENXPSH,X
		STA	ENXPSH,X
;		
		LDY	#00H
		LDA	ENYSPD,X
		BPL	HA0200
		DEY
HA0200		EQU	$
		CLC
		ADC	ENYPSL,X
		STA	ENYPSL,X
		TYA
		ADC	ENYPSH,X
		STA	ENYPSH,X
;
		LDY	ENWRK2,X
		LDA	ENMYNO-1,Y
		CMP	#CTBOS 
		BNE	HA0201		; Machi boss serch ?
;					; yes !
		MEM16
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	<PLXPS1
		CLC
		ADC	#0010H
		CMP	#0020H
		MEM8
		SEP	#00100000B
		BCS	HA0280J
;
		MEM16
		REP	#00100000B
		LDA	<PLYPS1
		SEC
		SBC	ENYP2L
		CLC
		ADC	#0018H
		CMP	#0020H
		MEM8
		SEP	#00100000B
		BCS	HA0280J
;
		JMP	HA2777
HA0280J		EQU	$
		JMP	HA0280
;- - - - - - - - - - - - - - - - - - - - -
HA0201		EQU	$
;;		JSL	>ENBGCKL
;;		LDA	ENCBFG,X
;;		BEQ	HA0207
		JSL	>SHBGCK		; Serch beam BG check !
		BCC	HA0207
;
		LDA	UNITNO
		CMP	#09H
		BNE	HEI002		; Asase -> not check !
;
HA0207		EQU	$
		LDA	KAKUMD		; MUTEKI
		BNE	HEI002
;--- player hit check !( finding )----
HA0208		EQU	$
;;		LDA	<KEYA1
;;		BMI	HA2788
;
		MEM16
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	<PLXPS1
;;		CLC
;;		ADC	#000CH
;;		CMP	#0018H
		CMP	#0010H
		MEM8
		SEP	#00100000B
		BCS	HA0280
;
		MEM16
		REP	#00100000B
		LDA	ENYP2L
		SEC
		SBC	<PLYPS1
;;		CLC
;;		ADC	#000CH
;;		CMP	#0018H+8
		CMP	#0010H
		MEM8
		SEP	#00100000B
		BCS	HA0280
;
		LDA	ENKAIF,X
		CMP	<PLBGCKF
		BNE	HA0280
;
;;		BRA	HA2789
;;;
;;HA2788		EQU	$
;;		JSL	>CRENPL2L
;;		BCC	HA0280		; find player ?
;;					; yes !
;;HA2789		EQU	$
HA2777		EQU	$
		LDA	ENWRK2,X
		DEC	A
		PHX
		TAX
;
		LDA	ENSTAT,X
		CMP	#03H
		BEQ	HA0278
;
		LDA	#03H
		STA	ENSTAT,X	; go atack !
;
		LDA	ENMYNO,X
		CMP	#CTBOS
		BEQ	HA0278
;
		LDA	#10H
		STA	ENTIM0,X
		STZ	ENCONT,X
HA0278		EQU	$
		PLX
		BRA	HEI002
HA0280		EQU	$
		JSR	OAMCHK
		LDA	<WORK1
		ORA	<WORK3
		BEQ	HEI003
HEI002		EQU	$
		STZ	ENMODE,X
;;;		RTS
HEI003		EQU	$
		RTS
;		LDA	<WORK0
;		STA	(<OAMADR),Y
;		INY
;		LDA	<WORK2
;		STA	(<OAMADR),Y
;		INY
;		LDA	#00H
;		STA	(<OAMADR),Y
;		INY
;		LDA	#30H
;		STA	(<OAMADR),Y
;		LDA	#00H
;		STA	(<OSBADR) 
;		RTS		
;
;=================================================
HEI001		EQU	$
;		LDA	<KEYA2
;		AND	#08H
;		BEQ	HEI010
;		INC	ENCHPT,X
;		LDA	ENCHPT,X
;		CMP	#0EH
;		BNE	HEI010
;;
;		STZ	ENCHPT,X
;HEI010		EQU	$
;		LDY	ENCHPT,X
;		LDA	HTESTD,Y
;		STA	ENMUKI,X
;;
;		LDA	<KEYA2
;		AND	#004H
;		BEQ	HEI020
;		LDA	ENKBMK,X
;		INC	A
;		AND	#03H
;		STA	ENKBMK,X
;HEI020		EQU	$
		LDA	ENCHPT,X
		PHA
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	H0M001
		LDA	H0TURN,Y
		STA	ENMUKI,X
		LDA	H0TUR2,Y
		STA	ENCHPT,X
H0M001		EQU	$
		JSR	HEIS0CS
		PLA
		STA	ENMUKI,X
		PLA
		STA	ENCHPT,X
;
		LDA	ENMODE,X
		CMP	#EHOLE
		BNE	H0M012		; Ochiru sunzen ?
;					; yes !
		LDA	<GAMEMD
		BNE	HEI003
;
		JSR	ATWKPS
		JMP	ATWKPS	; x2
;
H0M012		EQU	$
		JSR	ENSTCK
;
		JSL	>CRKNKNL
		JSL	>CRENPLL
		BCS	AWSET		; hannou !
;
		LDA	OTOFLG
		BEQ	H0M112		; Oto ?
;					; yes ! atack wait !
AWSET		EQU	$
		LDA	ENSTAT,X
		CMP	#03H
		BCS	H0M112
;
		LDA	#03H
		STA	ENSTAT,X
		LDA	#20H
		BRA	HFFFF
H0M112		EQU	$
		LDA	ENHNFG,X
		BEQ	H00000		;hanekairi ?
;					; yes ! go atack !
		CMP	#04H
		BCC	H00000	; For Obj SEKZ4 hane !
;;		BCC	HFFFF	; For Obj SEKZ4 hane !
;
		LDA	#04H
		STA	ENSTAT,X
		LDA	#080H
HFFFF		EQU	$
		JSR	HERVSE		; time set,HEMODE cls,MOD3 rvse
;;		STA	ENTIM0,X
;;;
;;		STZ	HEMODE,X
;;		LDA	#060H		; BG hani revise !
;;		STA	ENMOD3,X
H00000		EQU	$
;		LDA	ENHNFG,X
;		BPL	HBKS00
;;
;		STA	<WORK6
;;
;		MEM16
;		REP	#20H
;		LDA	ENXP2L		
;		SEC
;		SBC	<SCCH2
;		STA	<WORK0
;		LDA	ENYP2L
;		SEC
;		SBC	<SCCV2
;		SEC
;		SBC	#0008H
;		STA	<WORK2
;		MEM8
;		SEP	#20H
;HBKS00		EQU	$
		JSR	ENHNSB
;---------------------------------------
;;		JSR	ENMVCL
;;		JSR	HEMVCL
;
		LDA	HEMODE,X
		AND	#00000111B
		CMP	#00000101B
		BCS	H00001
;
		LDA	ENCBFG,X
		BNE	H00005
		JSR	ENMVCL
H00005		EQU	$
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		BRA	H00006
H00001		EQU	$
		JSR	ENMVCL
H00006		EQU	$
;
;		WORD	H0WKWT	;0
;		WORD	H0WALK	;1
;		WORD	H0KYRO	;2
;		WORD	H0ATWT	;3
;		WORD	H0ATCK	;4
;		LDA	ENHNFG,X
;		BNE	H00RTS
;
;;		LDA	ENSTAT,X
;;		JSL	>JSRSUB
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		CMP	#04H
		BEQ	H0009	; Dash sound set flag reset !
;
		STZ	ENCTCT,X
H0009		EQU	$
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	H0MVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
H0MVAD		EQU	$
		WORD	H0WKWT	;0
		WORD	H0WALK	;1
		WORD	H0KYRO	;2
		WORD	H0ATWT	;3
		WORD	H0ATCK	;4
;;----------------------
;H00RTS		EQU	$
;		LDA	#04H
;		STA	ENSTAT,X
;		LDA	#0FFH
;		STA	ENTIM0,X
;		RTS
;- - - - - - - - - - - - - - - - - -
H0WKTM		EQU	$
		HEX	60,C0,FF,40
;
;;		HEX     20,30,40,50
;
H0WKWT		EQU	$
		JSR	H0SDCL
		LDA	ENTIM0,X
		BNE	HWW010
;
		INC	ENSTAT,X
;
		LDA	HEMODE,X
		BEQ	H0WW10
;- - - kotei move - - - - - - -
		AND	#00000111B
		CMP	#00000101B
		BCS	H0WW10		; L R or U D move ?
;					; yes !
		LDA	HEMODE,X
		LSR	A
		LSR	A
		LSR	A
		AND	#00000011B
		TAY
		LDA	H0WKTM,Y
		STA	ENTIM0,X	; move range set !
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
		STZ	ENCONT,X
		BRA	H0TUST
;- - - normal move - - - - 
H0WW10		EQU	$
		JSL	>RNDSET
		AND	#03FH
;
        	ADC	#028H
		STA	ENTIM0,X
;
		LDA	ENMUKI,X
		PHA
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X
		PLA
		CMP	ENMUKI,X
		BEQ	HWW010
		EOR	ENMUKI,X
		AND	#00000010B
		BNE	HWW010
;
H0TUST		EQU	$
		LDA	#0CH
		STA	ENTIM1,X	; turn half pause set !
HWW010		EQU	$
		RTS
;---------------------------------
H0WXSD		EQU	$
		BYTE	008H,0F8H,000H,000H
H0WYSD		EQU	$
		BYTE	000H,000H,008H,0F8H
H0WKPT		EQU	$
Y0WKPT		EQU	$
YWP1		EQU	$
		BYTE	0BH,0CH,0DH,0CH
		BYTE	04H,05H,06H,05H
		BYTE	00H,01H,02H,03H
		BYTE	07H,08H,09H,0AH
YWP0		EQU	$
		BYTE	11H,12H,11H,12H
		BYTE	07H,08H,07H,08H
		BYTE	03H,04H,03H,04H
		BYTE	0DH,0EH,0DH,0EH
;====================================================================
KBCBXS		EQU	$
		HEX	01,01,FF,FF,FF,FF,01,01
KBCBYS		EQU	$
		HEX	FF,01,01,FF,FF,01,01,FF
KBMVXS		EQU	$
		HEX	08,00,F8,00,F8,00,08,00
KBMVYS		EQU	$
		HEX	00,08,00,F8,00,08,00,F8
KBMVMK		EQU	$
		HEX	0,2,1,3,1,2,0,3
KBCBCK		EQU	$
		HEX	1,4,2,8,2,4,1,8
KBCBC2		EQU	$
		BYTE	8,1,4,2,8,2,4,1
KBNXMK		EQU	$
		BYTE	1,2,3,0,5,6,7,4
KBNXM2		EQU	$
		BYTE	3,0,1,2,7,4,5,6
;- - - - - - - - - - - - - - - - - - - - - - - -
KABEMV		EQU	$
		LDY	ENWRK1,X
		LDA	KBCBXS,Y
		STA	ENXSPD,X
		LDA	KBCBYS,Y
		STA	ENYSPD,X
;
;;                JSL	>ENBGCKL		
		JSR	ENBGCK
;
		LDA	ENTIM2,X
		BEQ	KBM010
;
		CMP	#2CH
		BNE	KBM020
;
		LDY	ENWRK1,X
		LDA	KBNXM2,Y
		STA	ENWRK1,X
		BRA	KBM020
;
KBM010		EQU	$
;;		LDY	ENWRK1,X
;;		LDA	KBCBXS,Y
;;		STA	ENXSPD,X
;;		LDA	KBCBYS,Y
;;		STA	ENYSPD,X
;;;
;;;             JSL	>ENBGCKL		
;
		LDY	ENWRK1,X
		LDA	ENCBFG,X
		AND	KBCBC2,Y
		BNE	KBM020
;
		LDA	#58H
		STA	ENTIM2,X
;;		BRA	KBM030
KBM020		EQU	$
		LDY	ENWRK1,X
		LDA	ENCBFG,X
		AND	KBCBCK,Y
		BEQ	KBM030
;
		LDA	KBNXMK,Y
		STA	ENWRK1,X
KBM030		EQU	$
         	LDY	ENWRK1,X
		LDA	KBMVXS,Y
		STA	ENXSPD,X
		LDA	KBMVYS,Y
		STA	ENYSPD,X
		LDA	KBMVMK,Y
		STA	ENMUKI,X
		STA	ENKBMK,X
;
		JMP	H0WKPS
;
;
;
;
;
;
;
;
;====================================================================
H0WALK		EQU	$
		JSR	H0SER2
;
		LDA	HEMODE,X
		AND	#00000111B
		CMP	#00000101B
		BCC	H0W000
;
		JMP	KABEMV			; kabe soi move !
;
H0W000		EQU	$
		LDA	ENTIM0,X
		BNE	H0W010
;
;;		STZ	ENXSPD,X
;;		STZ	ENYSPD,X
;;		JSR	H0SDCL
;
GOKYRO		EQU	$
		JSR	H0SDCL
;
		LDA	#02H
		STA	ENSTAT,X
;
;;		JSL	>RNDSET
;;		AND	#3FH
;
        	LDA	#0A0H
		STA	ENTIM0,X
		RTS
H0W010		EQU	$
		LDA	ENCONT,X
		AND	#01H
		BNE	HOW011
;
		INC	ENTIM0,X	; long timer !
HOW011		EQU	$
		LDA	ENCBFG,X
		AND	#0FH
		BEQ	H0W018
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
;;		LDA	#0AH
;;		STA	ENTIM1,X	; turn half pause set !
		JSR	H0TUST
H0W018		EQU	$
		LDY	ENMUKI,X
		LDA	H0WXSD,Y
		STA	ENXSPD,X
		LDA	H0WYSD,Y
		STA	ENYSPD,X
		TYA
		STA	ENKBMK,X
;
H0WKPS		EQU	$
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
		LSR	A
		LSR	A
		AND	#03H
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ADC	<WORK0
		TAY
		LDA	H0WKPT,Y
		STA	ENCHPT,X
		RTS
;-----------------------
H0KKBD		EQU	$
		BYTE	0,2,2,2,0,3,3,3
		BYTE	1,3,3,3,1,2,2,2
		BYTE	2,0,0,0,2,1,1,1
		BYTE	3,1,1,1,3,0,0,0
;
H0KYRO		EQU	$
		JSR	H0SDCL
		JSR	H0SERC		; player serch !
;
;-- TEST --
;		LDA	<KEYA2
;		AND	#10000000B
;		BEQ	HTS10
;		LDA	#03H
;		STA	ENSTAT,X
;		LDA	#10H
;		STA	ENTIM0,X
;		STZ	ENCONT,X
;		RTS
;HTS10		EQU	$
;-------------------
		LDA	ENTIM0,X
		BNE	H0K010
;
		LDA	#20H
		STA	ENTIM0,X
		LDA	#00H
		STA	ENSTAT,X		
		RTS
H0K010		EQU	$
		CMP	#080H
		BCS	H0K020
;;                LSR	A
;;		NOP
		LSR	A
		LSR	A
		LSR	A
		AND	#00000111B
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	H0KKBD,Y
		STA	ENKBMK,X
H0K020		EQU	$
		RTS
;===========================================
H0ATWT		EQU	$
		JSR	H0SDCL
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;
		LDA	ENTIM0,X
		BNE	H0AW10
;
		LDA	#04H
		STA	ENSTAT,X
		LDA	#0FFH
HERVSE		EQU	$
		STA	ENTIM0,X
		STZ	HEMODE,X
;
		LDA	ENMOD7,X
		AND	#0FH
		ORA	#060H		; BG hani revise !
		STA	ENMOD7,X
H0AW10		EQU	$
		RTS
;===========================================
H0ATCK		EQU	$
		LDA	ENTIM0,X
		BNE	H0AT08
;
		LDY	ENMUKI,X
		LDA	HYSHCT,Y
		STA	ENCTFG,X	; Next serch beam point set !
;
		BRL	GOKYRO
;;		LDA	#0A0H
;;		STA	ENTIM0,X
;;		LDA	#02H
;;		STA	ENSTAT,X
H0SDCL		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		RTS
;
H0AT08		EQU	$
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	H0AT10
;
		LDA	ENCTCT,X
		BNE	H0AT11		; Only sound set 1 !
;
;;		JSL	>SDLRCE
;;		ORA	#04H
;;		STA	SOUND3	;(S)
		LDA	#04H
		JSL	>SDLRE3	;(S)
;
		INC	ENCTCT,X
H0AT11		EQU	$
		TXA
		AND	#03H
		TAY
;;		LDA	#12H
;
		LDA	ENMYNO,X
		CMP	#HEI00
		BEQ	H0AT0F
;
;;		LDA	DJFLG
;;		BEQ	H0AT0F
;;		INY
;;		INY
;;		INY
;;		INY
H0AT0F		EQU	$
		LDA	H0SHSD,Y
		JSL	>PSERCHL
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
H0AT10		EQU	$
		JSL	>ENSDMV
;
ATWKPS		EQU	$
		INC	ENCONT,X
		JSR	H0WKPS
H0AT50		EQU	$
		RTS
;- - - -
HOATTX		EQU	$
		HEX	0E,F2  ;;,00,00
HOATTY		EQU	$
		HEX	00,00,0E,F2
;- - - - -- - -- - --
ENSDMV		EQU	$
		PHB
		PHK
		PLB
;
		LDA	ENCBFG,X
		BEQ	H0AT20
;
		AND	#0000011B
		BEQ	H0AT13
		JSR	EPYCHK
		INY
		INY
		BRA	H0AT18
H0AT13		EQU	$
		JSR	EPXCHK
;
H0AT18		EQU	$
		LDA	HOATTX,Y
		STA	ENXSPD,X
		LDA	HOATTY,Y
		STA	ENYSPD,X
H0AT20		EQU	$
		PLB
		RTL
;
H0SHSD		EQU	$
		BYTE	10H,10H,10H,10H
H2SHSD		EQU	$
		BYTE	12H,12H,12H,12H
;;		BYTE	14H,13H,14H,13H
;;		BYTE	0CH,0EH,0EH,10H
;===========================================
;#################################################
H0SHXD		EQU	$
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
		BYTE	0F0H,0F2H,0F4H,0F6H,0F8H,0FAH,0FCH,0FEH
;
		BYTE	000H,002H,004H,006H,008H,00AH,00CH,00EH
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
;
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
		BYTE	00EH,00CH,00AH,008H,006H,004H,002H,000H
;
		BYTE	0FEH,0FCH,0FAH,0F8H,0F6H,0F4H,0F2H,0F0H
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
H0SHYD		EQU	$
		BYTE	000H,002H,004H,006H,008H,00AH,00CH,00EH
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
;
		BYTE	010H,010H,010H,010H,010H,010H,010H,010H
		BYTE	00EH,00CH,00AH,008H,006H,004H,002H,000H
;
		BYTE	0FEH,0FCH,0FAH,0F8H,0F6H,0F4H,0F2H,0F0H
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
;
		BYTE	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H
		BYTE	0F2H,0F4H,0F6H,0F8H,0FAH,0FCH,0FEH,000H
;===========================================
;#################################################
H0SEDT		EQU	$
		BYTE	10H,30H,00H,20H
;===============================
H0SER2		EQU	$	; walking find
;;		TXA
;;		CLC
;;		ADC	<FRCNT
;;		STA	<WORKF
;;		AND	#03H
;;		ORA	ENDSPL,X
;;		BNE	H0S010
;;;
;;		LDA	<WORKF
;;		LSR	A
;;		LSR	A
;;		AND	#0FH
;;		LDY	ENMUKI,X
;;		CLC
;;		ADC	H0SEDT,Y
;;		CLC
;;		ADC	#08H
;;		AND	#03FH
;;		STA	<WORKF
;;		BRA	H0SER00
;=============================
H0SERC		EQU	$	; kyoro kyoro find
;
		TXA
		CLC
		ADC	<FRCNT
		STA	<WORKF
		AND	#03H
		ORA	ENDSPL,X
		BNE	H0S010
;
;;;		LDA	<WORKF
		LDA	ENCTFG,X
		INC	ENCTFG,X
;		LSR	A
;		LSR	A
		LDY	ENMUKI,X
		CLC
		AND	#01FH
		ADC	H0SEDT,Y
		AND	#03FH
		STA	<WORKF
;- - - -- - - - - - - - - - - - - - - - - - - -
H0SER00		EQU	$
		LDA	#HEIS0
		LDY	#0AH
		JSL	>ENIDSH2
		BMI	H0S010
;
                LDA     <WORK0
		CLC
		ADC	#08H
                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
		PHX
		LDX	<WORKF
		TXA		
		STA	ENMUKI,Y
		LDA	H0SHXD,X
		STA	ENXSPD,Y
		LDA	H0SHYD,X
		STA	ENYSPD,Y
		LDA	ENMOD0,Y
		AND	#11110000B
		ORA	#10100000B
		STA	ENMOD0,Y
		PLX
		TXA
		INC	A
		STA	ENWRK2,Y
		STA	ENNOCR,Y
;
		LDA	#01000000B
		STA	ENMOD3,Y
		STA	ENMOD2,Y
;
		LDA	#00000010B
		STA	ENMOD5,Y
H0S010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - - - - - - - - -
H0SER00L	EQU	$
		PHB
		PHK
		PLB
		JSR	H0SER00
		PLB
		RTL
;- - - - - - - - - - - - - - - - - - - - - - - - - - - -
HEIS0CS2	EQU	$
		PHB
		PHK
		PLB
		PHX
		JSR	HEIS0CS
		PLX
		PLB
		RTL
;- - - - - - - - - - - - - - - - - - - - - - - - - - - -
HEIS0CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		JSR	H0HDCS		; head set 
		JSR	H0BDCS		; body set 
		JSR	H0WPCS		; wepon set 
;
;;		JSR	HESWST
HESWST		EQU	$
		LDA	ENMOD2,X
		AND	#00010000B
		BEQ	HESW10
;
		LDY	ENMUKI,X
;
		LDA	HESWYA,Y   ;#0CH
		JSL	>SADWS2L
;;		LDY	#0FFH
;;		LDA	#06H
;;		JSL	>ALOMCKL
HESW10		EQU	$
		RTS
;- - - - - - - -
HESWYA		EQU	$
		HEX	0C,0C,0A,0A
;==========================
H0HDCD		EQU	$
		BYTE	042H,042H,040H,044H
H0HDAD		EQU	$
		BYTE	040H,000H,000H,000H
HEHDYD		EQU	$
		WORD 	7,8,7,8 
		WORD 	8,7,8  
		WORD 	7,8,7,8 
		WORD    8,7,8 
;
		WORD 	8,8,8  
		WORD 	8,8,8  
		WORD 	8,8,8  
		WORD 	8,8,8  
;- - - - - - - - - - - - - - - - - - - - - - - -
H0HDCS		EQU	$
		LDY	#00H
HEHDCS		EQU	$
		PHX
;;		LDA	ENCONT,X
;;		LSR	A
;;		LSR	A
;;		LSR	A
;;		NOP
;;		NOP
;;		EOR	#01H
;;		LSR	A
;
		LDA	ENCHPT,X
		ASL	A
		STA	<WORKD
		LDA	ENKBMK,X	; kubi muki !
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		PHY
		LDA	<WORK2
        	SEC
		LDY	<WORKD
		SBC	HEHDYD,Y
;;		SBC	#08H
		PLY
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	HC0010
		LDA	#00F0H
		STA	(<OAMADR),Y
HC0010		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	H0HDCD,X
		INY
		STA	(<OAMADR),Y
		LDA	H0HDAD,X
		INY
		ORA	<WORK5		
		STA	(<OAMADR),Y
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLX
		RTS
;=======================================
H0BDXD		EQU	$
		WORD	0FFFCH,004H,00AH,00AH
		WORD	0FFFCH,004H,00AH,00AH
		WORD	0FFFCH,004H,00AH,00AH
		WORD	0FFFCH,004H,00AH,00AH
;
		WORD	0FFFCH,0FFFCH,000H,000H
		WORD	0FFFCH,0FFFCH,000H,000H
		WORD	0FFFDH,0FFFDH,000H,000H
;
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
		WORD	0FFFDH,0FFFDH,0FFFCH,004H
;
		WORD	00CH,00CH,000H,000H
		WORD	00CH,00CH,000H,000H
		WORD	00BH,00BH,000H,000H
;
		WORD	0FFFCH,004H,000H,000H	; ya
		WORD	0FFFCH,004H,000H,000H	 
		WORD	0FFFCH,004H,000H,000H	 
;
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
;
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFCH,004H,000H,000H
;
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
		WORD	000H,000H,000H,000H
H0BDYD		EQU	$
		WORD	000H,000H,002H,00AH
		WORD	000H,000H,002H,00AH
		WORD	000H,000H,001H,009H
		WORD	000H,000H,002H,00AH
;
		WORD	0FFFEH,006H,001H,001H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,001H,001H
;
		WORD	0FFFBH,003H,000H,000H
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFCH,004H,000H,000H
		WORD	0FFFBH,003H,000H,000H
;
		WORD	0FFFEH,006H,001H,001H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,001H,001H
;
		WORD	000H,000H,008H,008H	; YA
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
;
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
;
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
;
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
		WORD	000H,000H,008H,008H
H0BDCD		EQU	$
		BYTE	048H,049H,06DH,07DH
		BYTE	049H,048H,06DH,07DH
		BYTE	046H,046H,06DH,07DH
		BYTE	04BH,046H,06DH,07DH
;
		BYTE	04DH,05DH,04EH,04EH
		BYTE	04DH,05DH,060H,060H
		BYTE	04DH,05DH,062H,062H
;
		BYTE	06DH,07DH,064H,064H
		BYTE	06DH,07DH,066H,067H
		BYTE	06DH,07DH,067H,066H
		BYTE	06DH,07DH,064H,069H
;
		BYTE	04DH,05DH,04EH,04EH
		BYTE	04DH,05DH,060H,060H
		BYTE	04DH,05DH,062H,062H
;
		BYTE	002H,003H,020H,020H
		BYTE	002H,00CH,020H,020H
		BYTE	002H,00CH,020H,020H
;
		BYTE	008H,008H,020H,020H
		BYTE	00EH,00EH,020H,020H
		BYTE	00EH,00EH,020H,020H
;
		BYTE	005H,006H,020H,020H
		BYTE	022H,006H,020H,020H
		BYTE	022H,006H,020H,020H
;
		BYTE	008H,008H,020H,020H
		BYTE	00EH,00EH,020H,020H
		BYTE	00EH,00EH,020H,020H
H0BDAD		EQU	$
		BYTE	000H,000H,000H,000H
		BYTE	040H,040H,000H,000H
		BYTE	000H,040H,000H,000H
		BYTE	000H,040H,000H,000H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	000H,000H,000H,040H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,040H,040H
		BYTE	000H,000H,000H,040H
;
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
		BYTE	000H,000H,000H,000H
;
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
		BYTE	040H,040H,040H,040H
H0BDSD		EQU	$
		BYTE	002H,002H,000H,000H
		BYTE	002H,002H,000H,000H
		BYTE	002H,002H,000H,000H
		BYTE	002H,002H,000H,000H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
;
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
		BYTE	000H,000H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
		BYTE	002H,002H,002H,002H
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
H0BDID		EQU	$
		BYTE	0CH,0CH,0CH,04H
;
H0BDCS		EQU	$
		LDY	ENMUKI,X
		LDA	H0BDID,Y
		TAY
;
HEBDCS		EQU	$
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		STA	<WORK7
;
		LDA	ENMYNO,X
		STA	<WORK8
;
		PHX
		LDX	#03H
H0B010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK7
		TAX
		STX	<WORK6
;
		LDA	<WORK8
		CMP	#HEYA0
		BCC	H0B011		; ya heishi ?
;					; yes !
		LDA	H0BDSD,X
		BEQ     H0B055		; body set  ? (seeld not set )
;
		LDA	H0BDCD,X
		PLX
		PHX
		CPX	#03H
		BNE	H0B011
		CMP	#20H
		BEQ	H0B055		;kusa 1ko dake (only 3)  
H0B011		EQU	$
		LDA	<WORK6		; yes !
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	H0BDXD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	H0BDYD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	BC0010
		LDA	#00F0H
		STA	(<OAMADR),Y
BC0010		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	#00001000B
		STA	<WORKD
;
		LDX	<WORK6
		LDA	H0BDCD,X
		INY
		STA	(<OAMADR),Y
		CMP	#20H
		BNE	H0B012	; kusa set ?
;				; yes !
		LDA	#00000010B
		STA	<WORKD
;
		LDA	<WORK8
		CMP	#HEYA0
		CLC
		BNE	H0B013	; walk heishi ?
;				; yes !
		DEY
		LDA	#0F0H		; kusa clear !
		STA	(<OAMADR),Y
		INY
		BRA	H0B013
H0B012		EQU	$
		LDA	H0BDSD,X
		CMP	#01H
H0B013		EQU	$
		LDA	H0BDAD,X
		ORA	<WORK5
		BCS	H0B020
;
		AND	#11110001B
		ORA	<WORKD  	; tate & kusa color !
;;		ORA	#00001110B	; tate & kusa color !
;;		ORA	#00000010B	; tate & kusa color !
H0B020		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	H0BDSD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
H0B055		EQU	$
		PLX
		DEX
		BMI	H0B090
		JMP	H0B010
;
H0B090		EQU	$
		PLX
		RTS
;=======================================
H0WPXD		EQU	$
		WORD	0FFFDH,0FFFDH
		WORD	0FFFCH,0FFFCH
		WORD	0FFFCH,0FFFCH
		WORD	0FFFCH,0FFFCH
;
		WORD	0FFF5H,0FFFDH
		WORD	0FFF5H,0FFFDH
		WORD	0FFF0H,0FFF8H
;
		WORD	00CH,00CH
		WORD	00CH,00CH
		WORD	00CH,00CH
		WORD	00CH,00CH
;
		WORD	015H,00DH
		WORD	015H,00DH
		WORD	018H,010H
H0WPYD		EQU	$
		WORD	00BH,00BH+8
		WORD	00BH,00BH+8
		WORD	00AH,00AH+8
		WORD	00EH,00EH+8
;
		WORD	008H,008H
		WORD	008H,008H
		WORD	006H,006H
;
		WORD	0FFF6H,0FFFEH
		WORD	0FFF7H,0FFFFH
		WORD	0FFF7H,0FFFFH
		WORD	0FFF0H,0FFF8H
;
		WORD	008H,008H
		WORD	008H,008H
		WORD	006H,006H
H0WPCD		EQU	$
		BYTE	07BH,06BH
		BYTE	07BH,06BH
		BYTE	07BH,06BH
		BYTE	07BH,06BH
;
		BYTE	06CH,07CH
		BYTE	06CH,07CH
		BYTE	06CH,07CH
;
		BYTE	06BH,07BH
		BYTE	06BH,07BH
		BYTE	06BH,07BH
		BYTE	06BH,07BH
;
		BYTE	06CH,07CH
		BYTE	06CH,07CH
		BYTE	06CH,07CH
H0WPAD		EQU	$
		BYTE	080H,080H
		BYTE	080H,080H
		BYTE	080H,080H
		BYTE	080H,080H
;
		BYTE	000H,000H
		BYTE	000H,000H
		BYTE	000H,000H
;
		BYTE	000H,000H
		BYTE	000H,000H
		BYTE	000H,000H
		BYTE	000H,000H
;
		BYTE	040H,040H
		BYTE	040H,040H
		BYTE	040H,040H
H0WPID		EQU	$
		BYTE	04H,04H,04H,14H
;- - - - - - - - - - - - - - - - - 
H0WPCS		EQU	$
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
;
		LDA	ENMYNO,X
		SEC
		SBC	#HEIS0
		STA	<WORK8
;
		LDY	ENMUKI,X
		LDA	H0WPID,Y
		TAY
;
		PHX
		LDX	#01H
H0WC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
;
		LDA	H0WPXD,X
		CLC
		ADC	<WORK0 
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	H0WPYD,X
		CLC
		ADC	<WORK2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	WC0010
;
		LDA	#00F0H
		STA	(<OAMADR),Y
WC0010		EQU	$
		MEM8
		SEP	#00100000B
;
;
		LDA	H0WPXD,X
		STA	ENKNXP
		LDA	H0WPYD,X
		STA	ENKNYP
;
;
		PLX
		LDA	<WORK8
		CMP	#02H
;;		CMP	#01H
		LDA	H0WPCD,X
		BCS	H0WC12
		ADC	#03H    ;-1
H0WC12		EQU	$
		INY
		STA	(<OAMADR),Y
		LDA	H0WPAD,X
		ORA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	H0WC10
;
		PLX
		RTS
;=======================================
;=======================================
HEIS3M		EQU	$
		JSR	HEIS0CS
;
		JSR	ENSTCK
;
		JSR	HESDST		; Set sound set !
;
		JSL	>CRKNKNL
		JSR	ENHNSB
;
		JSR	HEMVCL
;;		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		JSL	>CRENPLL
;;		JSR	CREKEK
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	H3WK10
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
		STA	ENMUKI,X
;
		TXA
		AND	#03H
		TAY
		LDA	H2SHSD,Y
;;;		LDA	H0SHSD,Y
		JSL	>PSERCHL
;
		LDA	ENCBFG,X
		BEQ	H3AT20
;
		AND	#0000011B
		BEQ	H3AT13
		JSR	EPYCHK
		INY
		INY
		BRA	H3AT18
H3AT13		EQU	$
		JSR	EPXCHK
;
H3AT18		EQU	$
		LDA	HOATTX,Y
		STA	ENXSPD,X
		LDA	HOATTY,Y
		STA	ENYSPD,X
H3AT20		EQU	$
H3WK10		EQU	$
		INC	ENCONT,X
		JSR	H0WKPS
		RTS
;
;=====================================================
HESDST		EQU	$
		LDA	ENCTCT,X
		CMP	#10H
		BEQ	H3M000
;
		INC	ENCTCT,X
		CMP	#0FH
		BNE	H3M000
;
;;                JSL     >SDLRCE
  ;;              ORA     #04H
;;		STA	SOUND3	;(S)	
		LDA	#04H
		JSL	>SDLRE3	;(S)
;
;;		LDA	ENCLOR,X
;;		CMP	#00001011B
;
		LDA     >MODTBL0
		CMP	#02H
		BNE	H3M000
;
                LDA     GRNDNO
                CMP     #18H
		BNE	H3M000		; HELP0 called City ?
;					; yes !
                LDA     #0CH
                STA     SOUND0  ;(S)    ; BGM set
;// 03.09.16 //		STA	SVSND0		; Save !
H3M000		EQU	$
		RTS
;=======================================
HEIS2M		EQU	$
		JSR	HEIS2CS
;
;		LDA	ENMODE,X
;		CMP	#EHOLE
;		BNE	H3M012		; Ochiru sunzen ?
;					; yes !
;;;		JSR	ATWKPS
;;		JMP	ATWKPS	; x2
;		JSR	H2WK10
;		JMP	H2WK10
;
H3M012		EQU	$
		JSR	ENSTCK
;
		JSR	HESDST
;
		JSL	>CRKNKNL
		JSR	ENHNSB
;
		JSR	HEMVCL
;;		JSR	ENMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
		JSL	>CRENPLL
;;		JSR	CREKEK
;
		TXA
		EOR	<FRCNT
		AND	#0FH
		BNE	H2WK10
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;H20000		EQU	$
;;= = = = = = = = == = = = = = = = = = = = = = = =
;		LDA	ENSTAT,X
;		MEM16
;		IDX16
;		REP	#00110000B
;		PHY
;		AND	#00FFH
;		ASL	A
;		TAY
;		LDA	H2MVAD,Y
;		PLY
;		DEC	A
;		PHA
;		MEM8
;		IDX8
;		SEP	#00110000B
;		RTS
;;============================================
;H2MVAD		EQU	$
;		WORD	H2WALK
;		WORD	H2ATWT
;		WORD	H2ATCK
;;=====================================================
;H2WALK		EQU	$
;		TXA
;		EOR	<FRCNT
;		AND	#0FH
;		BNE	H2WK10
;
;;;;		JSR	EPXYCK
;;;;		TYA
;		LDA	ENKBMK,X
		STA	ENMUKI,X
;
;;		LDA	#0EH
		TXA
		AND	#03H
		TAY
;;		LDA	H0SHSD,Y
		LDA	H2SHSD,Y
		JSL	>PSERCHL
;
		LDA	ENCBFG,X
		BEQ	H2AT20
;
		AND	#0000011B
		BEQ	H2AT13
		JSR	EPYCHK
		INY
		INY
		BRA	H2AT18
H2AT13		EQU	$
		JSR	EPXCHK
;
H2AT18		EQU	$
		LDA	HOATTX,Y
		STA	ENXSPD,X
		LDA	HOATTY,Y
		STA	ENYSPD,X
H2AT20		EQU	$
H2WK10		EQU	$
;H2WKST		EQU	$
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK0
		INC	ENCONT,X
		LDA	ENCONT,X
		LSR	A
;;		LSR	A
		AND	#07H
		ORA	<WORK0
		TAY
		LDA	TKWKPT,Y
		STA	ENCHPT,X
		RTS
;=====================================================
;=======================================
HEIS2CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	#04H+08H
		JSR	TKHDC2		; head set 
		LDY	#00H+08H
		JSR	TKBDC2		; body set 
		JSR	H2WPCS		; wepon set 
;
		JMP	HESWST
;;		JSL	>SADWSTL
;;		LDY	#0FFH
;;		LDA	#05H
;;		JSL	>ALOMCKL
;;		RTS
;=======================================
H2WXAD		EQU	$
		WORD	00FH,007H
		WORD	011H,009H
;
		WORD	0FFF8H,000H
		WORD	0FFF6H,0FFFEH
;
		WORD	00DH,00DH
		WORD	00DH,00DH
;
		WORD	0FFFCH,0FFFCH
		WORD	0FFFCH,0FFFCH
H2WYAD		EQU	$
		WORD	0FFFEH,0FFFEH
		WORD	0FFFEH,0FFFEH
;
		WORD	0FFFEH,0FFFEH
		WORD	0FFFEH,0FFFEH
;
		WORD	008H,000H
		WORD	00AH,002H
;
		WORD	0FFF2H,0FFFAH
		WORD	0FFF0H,0FFF8H
H2WCDT		EQU	$
		BYTE	06FH,07FH
		BYTE	06FH,07FH
;
		BYTE	06FH,07FH
		BYTE	06FH,07FH
;
		BYTE	06EH,07EH
		BYTE	06EH,07EH
;
		BYTE	06EH,07EH
		BYTE	06EH,07EH
H2WADT		EQU	$
		BYTE	040H,040H
		BYTE	040H,040H
;
		BYTE	000H,000H
		BYTE	000H,000H
;
		BYTE	080H,080H
		BYTE	080H,080H
;
		BYTE	000H,000H
		BYTE	000H,000H
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Y2WPCS		EQU	$
		LDY	#00H
Y2WPC2		EQU	$
;;		LDA	ENCONT,X
;;		LSR	A
;;		LSR	A
		LDA	ENWRK0,X
		BRA	H2W012
;-  -  -  -  -  -  -  -  -  -  -  -  -  
H2WPCS		EQU	$
;;		LDA	ENCONT,X
		LDA	ENWRK0,X
		LDY	#00H
H2W012		EQU	$
		EOR	#01H
		ASL	A
		AND	#02H
		STA	<WORK6
;
		LDA	ENMYNO,X
		STA	<WORK8
;
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ORA	<WORK6
		STA	<WORK6
;
		PHX
		LDX	#01H
H2WC10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	H2WXAD,X
		CLC
		ADC	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	H2WYAD,X
		CLC
		ADC	<WORK2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	H2WC12
		LDA	#00F0H
		STA	(<OAMADR),Y
H2WC12		EQU	$
		MEM8
		SEP	#00100000B
;
		LDA	H2WXAD,X
		STA	ENKNXP
		LDA	H2WYAD,X
		STA	ENKNYP
;
		PLX
;
		LDA	<WORK8
		CMP	#HEYA2
		LDA	H2WCDT,X
		BCC	H2WC11
		SBC	#03H
H2WC11		EQU	$
		INY
		STA	(<OAMADR),Y
		LDA	H2WADT,X
		ORA	<WORK5
		AND	#11110001B
		ORA	#00001000B
		INY
		STA	(<OAMADR),Y
		PLX
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
;;		LDA	#00H
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	H2WC10
		PLX
		RTS
;=======================================
HEMVCL		EQU	$
		LDA	ENCBFG,X
		BNE	HMC010
		JMP	ENMVCL
HMC010		EQU	$
		RTS
;=======================================
Y2TURN		EQU	$
		BYTE	0CH,00H,12H,08H
;=======================================
HEYA2M		EQU	$
		LDA	ENCHPT,X
		PHA
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	HY2001
		LDA	H0TURN,Y
		STA	ENMUKI,X
		LDA	Y2TURN,Y
		STA	ENCHPT,X
HY2001		EQU	$
		JSR	HEYA2CS
		BRA	HYM010
;=======================================
HEYA0M		EQU	$
		LDA	ENCHPT,X
		PHA
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	HY0001
		LDA	H0TURN,Y
		STA	ENMUKI,X
		LDA	H0TUR2,Y
		STA	ENCHPT,X
HY0001		EQU	$
		JSR	HEYA0CS
HYM010		EQU	$
		PLA
		STA	ENMUKI,X
		PLA
		STA	ENCHPT,X
;
		JSR	ENSTCK
;
;L		JSR	HEMVCL
;L;;		JSL	>ENBGCKL
;L		JSR	ENBGCK
;
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
		JSR	CREKEK
		BCS	YAWSET		; hannou !
;
		LDA	OTOFLG
		BEQ	YH0M112		; Oto ?
;					; yes ! atack wait !
YAWSET		EQU	$
		LDA	ENSTAT,X
		CMP	#03H
		BCS	YH0M112
;
		LDA	#03H
		STA	ENSTAT,X
		LDA	#20H
		STA	ENTIM0,X
YH0M112		EQU	$
		LDA	ENHNFG,X
		BEQ	HY0000
		CMP	#04H
		BCC	HY0000		; SEKZ4 hane ?
;					; no !
		JSR	HYGOAT
HY0000		EQU	$
		JSR	ENHNSB
;- - -
		JSR	HEMVCL
;;		JSL	>ENBGCKL
		JSR	ENBGCK
;
;		LDA	ENHNFG,X
;		BNE	HY0RTS		; yarare -> fury !
;
;;              LDA	ENSTAT,X
;;		JSL	>JSRSUB
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	HYMVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
HYMVAD		EQU	$
		WORD	HY0WWT	;0
		WORD	HY0WLK  ;1
		WORD	HY0KYR  ;2
		WORD	HY0ATW	;3
		WORD	HY0ATC	;4
		WORD	HY0YAA	;5
;- - - - - - - - - - - - - - - - - - - - - - -
;HY0RTS		EQU	$		; fury !!
;		JMP	HYGOAT
;- - - - - - - - - - - - - - - - - -
HY0WWT		EQU	$
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	Y0WT10
;
		INC	ENSTAT,X
;
		JSL	>RNDSET
		AND	#07FH
;
        	ADC	#050H
		STA	ENTIM0,X
;
		LDA	ENMUKI,X
		PHA
		JSL	>RNDSET
		AND	#03H
		STA	ENMUKI,X
		PLA
		CMP	ENMUKI,X
		BEQ	Y0WT10
		EOR	ENMUKI,X
		AND	#00000010B
		BNE	Y0WT10
;
		LDA	#0CH
		STA	ENTIM1,X	; turn half pause set !
Y0WT10		EQU	$
		RTS
;---------------------------------
;
HY0WLK		EQU	$
		LDA	ENTIM0,X
		BNE	Y0W010
;
		LDA	#02H
		STA	ENSTAT,X
;
        	LDA	#0A0H
		STA	ENTIM0,X
		RTS
Y0W010		EQU	$
		JSR	H0SER2
;
		LDA	ENCBFG,X
		AND	#0FH
		BEQ	Y0W018
;
		LDA	ENMUKI,X
		EOR	#01H
		STA	ENMUKI,X
;
;;		LDA	#0AH
;;		STA	ENTIM1,X	; turn half pause set !
		JSR	H0TUST
Y0W018		EQU	$
		LDY	ENMUKI,X
		LDA	H0WXSD,Y
		STA	ENXSPD,X
		LDA	H0WYSD,Y
		STA	ENYSPD,X
		TYA
		STA	ENKBMK,X
;- - - - - - - - - - - - - - - - - - - - - 
Y0WKPS		EQU	$
                INC     ENCONT,X
                LDA     ENCONT,X
;;                AND     #07H
                AND     #0FH
                BNE     Y0W020
                INC     ENWRK0,X
                LDA     ENWRK0,X
                CMP     #02H
;;                CMP     #03H
                BNE     Y0W020
                STZ     ENWRK0,X
Y0W020          EQU     $
                LDA     ENMUKI,X
                ASL     A
                ASL     A
                ADC     ENWRK0,X
		LDY	ENMYNO,X
		CPY	#HEYA2
		BNE	Y0W030
		CLC
		ADC	#YWP0-YWP1
Y0W030		EQU	$
                TAY
                LDA     Y0WKPT,Y
                STA     ENCHPT,X
                RTS             
;---------------------------------------------------------------
HY0KYR		EQU	$
		JSR	H0SDCL
		JSR	H0SERC
;
		LDA	ENTIM0,X
		BNE	Y0K010
;
		LDA	#20H
		STA	ENTIM0,X
		LDA	#00H
		STA	ENSTAT,X		
		RTS
Y0K010		EQU	$
		CMP	#80H
		BCS	Y0K028
;;                LSR	A
;;		NOP
		LSR	A
		LSR	A
		LSR	A
		AND	#00000111B
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	H0KKBD,Y
		STA	ENKBMK,X
Y0K028		EQU	$
		RTS
;===========================================
HY0ATW		EQU	$
		JSR	H0SDCL
;
		JSR	EPXYCK
		TYA
		STA	ENKBMK,X
;
		LDA	ENTIM0,X
		BNE	Y0AW10
;
HYGOAT		EQU	$
		LDA	#04H
		STA	ENSTAT,X
;
		LDA	#03CH
		STA	ENTIM0,X
		STZ	ENCONT,X
Y0AW10		EQU	$
		RTS
;===========================================
Y0SHXL		EQU	$
		BYTE	0B0H,050H,000H,0F8H
		BYTE	0B0H,050H,0F8H,008H
Y0SHXH		EQU	$
		BYTE	0FFH,000H,000H,0FFH
		BYTE	0FFH,000H,0FFH,000H
Y0SHYL		EQU	$
		BYTE	008H,008H,0B0H,050H
		BYTE	008H,008H,0B0H,050H
Y0SHYH		EQU	$
		BYTE	000H,000H,0FFH,000H
		BYTE	000H,000H,0FFH,000H
;- - - - - - - - - -
ATCKMK		EQU	$
		BYTE	00000011B
		BYTE	00000011B
		BYTE	00001100B
		BYTE	00001100B
;- - - - -
HY0ATC		EQU	$
		LDY	ENMUKI,X
		LDA	ENCBFG,X
		AND	ATCKMK,Y
		BNE	GOYAAA
;
		LDA	ENTIM0,X
		BNE	Y0AT08
;
GOYAAA		EQU	$
		INC	ENSTAT,X
		LDA	#18H
;;		LDA	#30H
;;		LDA	#60H
		STA	ENTIM0,X
		RTS
;;		JMP	GOKYRO
;
Y0AT08		EQU	$
		TXA
		EOR	<FRCNT
		AND	#07H
		BNE	Y0AT10
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
;		
		LDA	ENMYNO,X
		CMP	#HEYA2
		BNE	Y0AT09
		INY
		INY
		INY
		INY
Y0AT09		EQU	$
		LDA	<PLXPS1
		CLC
		ADC	Y0SHXL,Y
		STA	<WORK4
		LDA	<PLXPS0
		ADC	Y0SHXH,Y
		STA	<WORK5
		LDA	<PLYPS1
		CLC
		ADC	Y0SHYL,Y
		STA	<WORK6
		LDA	<PLYPS0
		ADC	Y0SHYH,Y
		STA	<WORK7
;
		LDA	#18H
		JSL	>ESERCHL
;
		LDA	<WORK0
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		LDA	<WORKE
		CLC
		ADC	#06H
		CMP	#0CH
		BCS	Y0AT10
		LDA	<WORKF
		CLC
		ADC	#06H
		CMP	#0CH
		BCC	GOYAAA
;
Y0AT10		EQU	$
		INC	ENCONT,X
		JSR	Y0WKPS
Y0AT50		EQU	$
		RTS
;=========================================================
HYYPTD		EQU	$
Y2PT0		EQU	$
		BYTE	19H,19H,18H,18H,17H,17H,17H,17H
		BYTE	13H,13H,12H,12H,11H,11H,11H,11H
		BYTE	10H,10H,0FH,0FH,0EH,0EH,0EH,0EH
		BYTE	16H,16H,15H,15H,14H,14H,14H,14H
Y2PT1		EQU	$
		BYTE	14H,14H,12H,12H,12H,10H,10H,10H
		BYTE	15H,15H,08H,08H,08H,06H,06H,06H
		BYTE	16H,16H,04H,04H,04H,03H,03H,03H
		BYTE	17H,17H,0FH,0FH,0FH,0BH,0BH,0BH
;
HYSHCT		EQU	$
		HEX	0D,0D,0C,0C
;
HY0YAA		EQU	$
		LDY	ENMUKI,X
		LDA	HYSHCT,Y
		STA	ENCTFG,X	; Next serch beam point set !
;
		JSR	H0SDCL
;
		LDA	ENTIM0,X
		BNE	HYY010
;
		JMP	GOKYRO
HYY010		EQU	$
		STZ	ENCONT,X	; for yari  no ichi !
		CMP	#028H
;;		CMP	#050H
		BCC	HYY018
		DEC	ENCONT,X
HYY018		EQU	$
		CMP	#0CH
;;		CMP	#10H
;;		CMP	#20H
		BNE	HYY020
		PHA
;
		JSR	HYAASET
		PLA
HYY020		EQU	$
;;		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		LDY	ENMYNO,X
		CPY	#HEYA2
		BNE	HYY030
		CLC
		ADC	#Y2PT1-Y2PT0
HYY030		EQU	$
		TAY
		LDA	HYYPTD,Y
		STA	ENCHPT,X
		RTS
;- - - - - - - -- - - - - -- -
YAYAD		EQU	000H
;
HYSXAL		EQU	$
		BYTE	008H+8,0F8H,003H,00BH
		BYTE	00CH,0FCH,00CH,0FCH
HYSXAH		EQU	$
		BYTE	000H,0FFH,000H,000H
		BYTE	000H,0FFH,000H,0FFH
HYSYAL		EQU	$
		BYTE	002H+YAYAD,002H+YAYAD,008H+YAYAD+8,0F8H+YAYAD
		BYTE	0FEH+YAYAD,0FEH+YAYAD,002H+YAYAD,0F8H+YAYAD
HYSYAH		EQU	$
;;		HEX	0,0,0,0
;;		HEX	0,0,0,0
		BYTE	000H,000H,000H,0FFH
		BYTE	0FFH,0FFH,000H,0FFH
HYSXSD		EQU	$
		BYTE	030H,0D0H,000H,000H
		BYTE	020H,0E0H    ;,000H,000H
HYSYSD		EQU	$
		BYTE	000H,000H,030H,0D0H
		BYTE	000H,000H,020H,0E0H
HYSMKD		EQU	$
		BYTE	3,2,1,0
		BYTE	3,2,1,0
;
YACRDT		EQU	$		; OBJ hit size
		BYTE	5,5,6,6 
;
HYAASET		EQU	$
		LDA	#YATAM
		JSL	>ENIDSH
		BMI	HYS010
;
;;		JSL	>SDLRCE
;;		ORA	#05H
;;		STA	SOUND3	;(S)
		LDA	#05H
		JSL	>SDLRE3	;(S)
;
		PHX
		LDA	ENMYNO,X
		CMP	#HEYA2
		LDA	ENMUKI,X
		BCC	HYS030
		CLC
		ADC	#04H
HYS030		EQU	$
		TAX
		LDA	<WORK0
		CLC
		ADC	HYSXAL,X
		STA	ENXPSL,Y
		LDA	<WORK1
		ADC	HYSXAH,X
		STA	ENXPSH,Y
		LDA	<WORK2
		CLC
		ADC	HYSYAL,X
		STA	ENYPSL,Y
		LDA	<WORK3	
		ADC	HYSYAH,X
		STA	ENYPSH,Y
;
		LDA	HYSXSD,X
		STA	ENXSPD,Y
		LDA	HYSYSD,X
		STA	ENYSPD,Y
;;		LDA	HYSMKD,X
		TXA
		AND	#03H
		STA	ENMUKI,Y
		TAX
;;		LDA	ENMOD3,Y
;;		AND	#0F0H
		LDA	YACRDT,X
		STA	ENMOD3,Y
		LDA	#YAYAD
		STA	ENZPSL,Y
		PLX
		LDA	ENMYNO,X
		CMP	#HEYA2
		LDA	#00H
		BCC	HYS00E
		INC	A
HYS00E		EQU	$
		STA	ENWRK0,Y
		BEQ	HYS010
;
;// 03.04.10 //		LDA	TATPNT
		LDA	>ITMTBL7
		BNE	HYS010		; tate yowai ? -> yari makeru !
;
		LDA	ENMOD4,Y
		AND	#11011111B
		STA	ENMOD4,Y
HYS010		EQU	$
		RTS
;===============================================
HEYA3CS		EQU	$
		LDA	ENCHPT,X
		PHA
		STZ	ENCHPT,X
		LDA	ENCLOR,X
		PHA
		AND	#11110001B
		ORA	#00000010B
		STA	ENCLOR,X
		MEM16
		REP	#00100000B
		LDA	ENYP2L
		PHA
		CLC
		ADC	#0008H
		STA	ENYP2L
		MEM8
		SEP	#00100000B
		JSL	>EN1CSTL
		MEM16
		REP	#00100000B
		PLA	
		STA	ENYP2L
		MEM8
		SEP	#00100000B
		PLA
		STA	ENCLOR,X
		PLA
		STA	ENCHPT,X
;
		JSR	O2TEST
;
		LDY	#04H+08H+4
		JSR	HEHDCS		; head set 
;;		JSR	TKHDC2		; head set 
		LDY	#00H+08H+4
		JSR	TKBDC2		; body set 
		LDA	ENCHPT,X
		CMP	#14H
		BCS	Y3C098		; yari with ?
;					; yes !
		LDY	#04H
		JSR	Y2WPC2		; wepon set 
Y3C098		EQU	$
		JMP	HESWST
;;		JSL	>SADWSTL
;;		RTS
;===============================================
HEYA2CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	#04H+08H
		JSR	TKHDC2		; head set 
		LDY	#00H+08H
		JSR	TKBDC2		; body set 
		LDA	ENCHPT,X
		CMP	#14H
		BCS	Y2C098		; yari with ?
;					; yes !
		JSR	Y2WPCS		; wepon set 
Y2C098		EQU	$
		JMP	HESWST
;;		JSL	>SADWSTL
;;		RTS
;=========================================================
HEYA3M		EQU	$
		LDA	ENSTAT,X
		BEQ	HY3020
;
;;		LDA	ENCHPT,X
;;		CMP	#07H
		CMP	#02H
		BNE	HY3010
		JSR	HEYA3CS
		BRA	HY3020
HY3010		EQU	$
		JSR	HEYA1C2		; gasa gasa set !
HY3020		EQU	$
		BRA	HY1020
;- - - - - - - - - - - - - - - - - - - - - -
HEYA1M		EQU	$
		LDA	ENSTAT,X
		BEQ	HY1020
;
		LDA	ENCHPT,X
		CMP	#0EH
		BCC	HY1010
		JSR	HEYA1CS
		BRA	HY1020
HY1010		EQU	$
		JSR	HEYA1C2		; gasa gasa set !
HY1020		EQU	$
		JSR	ENSTCK
;
;;		JSL	>CRKNENL
;;		JSL	>CRENPLL
;;		JSR	CREKEK
;= = = = = = = = == = = = = = = = = = = = = = = =
		LDA	#01H
		STA	ENNOCR,X
;
		LDA	ENSTAT,X
		MEM16
		IDX16
		REP	#00110000B
		AND	#00FFH
		ASL	A
		TAY
		LDA	H1MVAD,Y
		DEC	A
		PHA
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;============================================
H1MVAD		EQU	$
		WORD	Y1WAIT	;0
		WORD	Y1SET   ;1
		WORD	Y1YAAA	;2
		WORD	Y1END	;3
;===========================================
Y1WAIT		EQU	$
		LDA	ENTIM0,X
		BNE	Y1W010
;
		INC	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
Y1W010		EQU	$
		RTS
;===========================================
Y1STPT		EQU	$
		BYTE	4,4,4,4,4,4,4,4
		BYTE	0,1,0,1,0,1,0,1
		BYTE	0,1,0,1,0,1,0,1
		BYTE	0,1,0,1,0,1,0,1
;
;		BYTE	5,5,5,4,6,6,6,4
;		BYTE	4,3,2,1,0,1,0,1
;		BYTE	0,1,0,1,0,1,0,1
;		BYTE	0,1,0,1,0,1,0,1
;
Y1SET		EQU	$
;;		JSR	CREKEK
		JSL	>CRKNENL
;
		LDA	ENTIM0,X
		BNE	Y1ST10
;
		INC	ENSTAT,X
;
		LDA	#30H
		STA	ENTIM0,X
;
		JSR	EPXYCK
		TYA
		STA	ENMUKI,X
		STA	ENKBMK,X
		RTS
Y1ST10		EQU	$
		CMP	#020H
		BNE	Y1ST20
		PHA
		JSR	Y1KUSA		; Parapara set !
		PLA
Y1ST20		EQU	$
;;		LSR	A
		LSR	A
		LSR	A
;;		NOP
;;		NOP
		TAY
		LDA	Y1STPT,Y
		STA	ENCHPT,X
		RTS	
;- - -- - - - -
Y1KUSA		EQU	$
		LDA	#KTOBJ
		JSL	>ENIDSH
		BMI	Y1KS10
;
		JSL	>ENIDPS
;		LDA	<WORK0
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		STA	ENYPSH,Y
		LDA	#EFAIL
		STA	ENMODE,Y
		LDA	#20H
		STA	ENTIM0,Y
;
		LDA	ENMOD0,Y
		CLC
		ADC	#03H
		STA	ENMOD0,Y
;
		LDA	#02H
		STA	ENWRK2,Y	; kusa !
;;		LDA	#0CH
;;		STA	ENCLOR,Y
Y1KS10		EQU	$
		RTS		
;===========================================
Y1YAAA		EQU	$
		STZ	ENNOCR,X
;
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	Y1Y010
;
		INC	ENSTAT,X
		LDA	#30H
;;		LDA	#80H
		STA	ENTIM0,X
;;		RTS
		BRA	Y1END
;- - - - -
Y1Y010		EQU	$
		STZ	ENWRK0,X	; for yari  no ichi !
		CMP	#028H
;;		CMP	#050H
		BCS	HY3018
		DEC	ENWRK0,X
HY3018		EQU	$
		CMP	#010H
;		CMP	#020H
		BNE	Y1Y020
		PHA
;
		JSR	HYAASET
		PLA
Y1Y020		EQU	$
;;		LSR	A
		LSR	A
		LSR	A
		LSR	A
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		LDY	ENMYNO,X
		CPY	#HEYA3
		BNE	HY3030
		CLC
		ADC	#Y2PT1-Y2PT0
HY3030		EQU	$
		TAY
;;              LDA	HYYPTD,Y
;;		STA	ENCHPT,X
;;		RTS
;;		TAY
		LDA	HYYPTD,Y
		STA	ENCHPT,X
		RTS
;===========================================
Y1EPTD		EQU	$
		BYTE	0,1,0,1,0,1,0,1
		BYTE	0,2,3,4,4,4,4,4 
;;		BYTE	0,1,0,1,0,2,3,4
;
Y1END		EQU	$
		JSR	CREKEK
;
		LDA	ENTIM0,X
		BNE	Y1E010
		STZ	ENSTAT,X
		LDA	#40H
		STA	ENTIM0,X
		RTS
Y1E010		EQU	$
;;		LSR	A
		LSR	A
		LSR	A
		TAY
		LDA	Y1EPTD,Y
		STA	ENCHPT,X
		RTS
;===========================================
Y12CYD		EQU	$
		WORD	000H+08H,000H+08H	;0
		WORD	000H+08H,000H+08H	;1
		WORD	0FFFAH+08H,000H+08H	;2
		WORD	0FFF8H+08H,000H+08H	;3
		WORD	0FFF5H+08H,000H+08H	;4
		WORD	0FFF5H+08H,000H+08H	;5
		WORD	0FFF5H+08H,000H+08H	;6
Y12CCD		EQU	$
;;;;;;;;;;;		BYTE	042H,042H,040H,044H
		BYTE	020H,020H
		BYTE	020H,020H
		BYTE	040H,020H
		BYTE	040H,020H
		BYTE	040H,020H
		BYTE	042H,020H
		BYTE	042H,020H
Y12CAD		EQU	$
		BYTE	009H,003H
		BYTE	049H,043H
		BYTE	009H,003H
		BYTE	049H,043H
		BYTE	009H,003H
		BYTE	049H,043H
		BYTE	009H,003H
HEYA1C2		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDA	ENCHPT,X
		ASL	A
		STA	<WORK6
;
		PHX
		LDX	#01H
HY1C10		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
;
		MEM16
		REP	#00100000B
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	Y12CYD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	HY2C12
;
		LDA	#00F0H
		STA	(<OAMADR),Y
HY2C12		EQU	$
		MEM8
		SEP	#00100000B
;
		PLX
		LDA	Y12CCD,X
		INY
		STA	(<OAMADR),Y
		LDA	Y12CAD,X
		ORA	#20H
		PLX
		BNE	HY1C20
		AND	#11110001B
		ORA	<WORK5
HY1C20		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	HY1C10
		PLX
;
;;		LDY	#02H
;;		LDA	#01H
;;		JSL	>ALOMCKL
		RTS
;
;
;
;
;===========================================
HYWPID		EQU	$
		BYTE	00H,00H,00H  ;,10H
HYHDID		EQU	$
		BYTE	10H,10H,10H,00H
HYBDID		EQU	$
		BYTE	14H,14H,14H,04H
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HEYA1CS		EQU	$
HEYA0CS		EQU	$
		JSR	O2TEST
;;		JSR	OAMCHK
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDY	ENMUKI,X
		LDA	HYHDID,Y
		TAY
		JSR	HEHDCS		; head set 
YC0000		EQU	$
		LDY	ENMUKI,X
		LDA	HYBDID,Y
		TAY
		JSR	HEBDCS		; body set 
		LDY	ENMUKI,X
		LDA	HYWPID,Y
		TAY
		JSR	HYWPCS		; wepon set 
		JMP	HESWST
;;		JSL	>SADWSTL
;;		RTS
;=========================
;HEYA1CS		EQU	$
;		JSR	O2TEST
;;
;		LDY	ENMUKI,X
;		LDA	HYHDID,Y
;		TAY
;		JSR	TKHDC2		; head set 
;		BRA	YC0000
;
;-------------
HYWXAD		EQU	$
		WORD	0FFFFH,007H,003H,003H
		WORD	0FFFFH,007H,003H,003H
		WORD	0FFFFH,007H,007H,007H
;
		WORD	0FFFBH,0FFFBH,0FFF6H,0FFFEH
		WORD	0FFFCH,0FFFCH,0FFFAH,002H
		WORD	0FFFBH,0FFFBH,0FFFBH,0FFFBH
;
		WORD	006H,00EH,00BH,00BH
		WORD	006H,00EH,00BH,00BH
		WORD	006H,00EH,00EH,00EH
;
		WORD	00BH,00BH,012H,00AH
		WORD	00CH,00CH,00EH,006H
		WORD	00BH,00BH,00BH,00BH
HYWYAD		EQU	$
		WORD	007H,007H,003H,00BH
		WORD	006H,006H,001H,009H
		WORD	007H,007H,007H,007H
;
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,006H,006H
;
		WORD	0FFFAH,0FFFAH,0FFF4H,0FFFCH
		WORD	0FFFAH,0FFFAH,0FFF7H,0FFFFH
		WORD	0FFFAH,0FFFAH,0FFFAH,0FFFAH
;
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,002H,002H
		WORD	0FFFEH,006H,006H,006H
HYWCDT		EQU	$
		BYTE	00AH,00AH,02AH,02BH
		BYTE	01AH,01AH,02AH,02BH
		BYTE	00AH,00AH,00AH,00AH
;
		BYTE	00BH,00BH,03DH,03AH
		BYTE	01BH,01BH,03DH,03AH
		BYTE	00BH,00BH,00BH,00BH
;
		BYTE	00AH,00AH,02BH,02AH
		BYTE	00AH,00AH,02BH,02AH
		BYTE	00AH,00AH,00AH,00AH
;
		BYTE	00BH,00BH,03DH,03AH
		BYTE	01BH,01BH,03DH,03AH
		BYTE	00BH,00BH,00BH,00BH
HYWADT		EQU	$
		BYTE	00DH,04DH,008H,008H
		BYTE	00DH,04DH,008H,008H
		BYTE	00DH,04DH,04DH,04DH
;
		BYTE	00DH,08DH,048H,048H
		BYTE	00DH,08DH,048H,048H
		BYTE	00DH,08DH,08DH,08DH
;
		BYTE	08DH,0CDH,088H,088H
		BYTE	08DH,0CDH,088H,088H
		BYTE	08DH,0CDH,0CDH,0CDH
;
		BYTE	04DH,0CDH,008H,008H
		BYTE	04DH,0CDH,008H,008H
		BYTE	04DH,0CDH,0CDH,0CDH
;-----------------------------------------------------------
HYWMKD		EQU	$
		BYTE	17H-0EH,11H-0EH,0EH-0EH,14H-0EH
;
HYWPCS		EQU	$
		LDA	ENCHPT,X
		SEC
		SBC	#0EH
		BCS	HWC010
;
		PHY
		LDY	ENMUKI,X
		LDA	HYWMKD,Y
		PLY
HWC010		EQU	$
		ASL	A
		ASL	A
		STA	<WORK6
;
		PHX
		LDX	#03H
HYW010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
;
		LDA	<WORK0
		CLC
		ADC	HYWXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	<WORK2
		CLC
		ADC	HYWYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	HYW012
;
		LDA	#00F0H
		STA	(<OAMADR),Y
HYW012		EQU	$
		MEM8
		SEP	#00100000B
		PLX
;
		LDA	HYWCDT,X
		INY
		STA	(<OAMADR),Y
;;        	CMP	#20H
        	LDA	HYWADT,X
		ORA	#00100000B
;;		BCS	HWC020
;;		ORA	#01H
;;HWC020		EQU	$
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	HYW010
;
		PLX
		RTS
;====================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Barikade knight                        		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BARI0MV  	EQU	$
		PHB
		PHK
		PLB
		JSR	BR00
		PLB
		RTL
;======================================
;BARIFCD		EQU	$
;		WORD	00000-8,00000-8
;		BYTE	0E6H,000H,000H,002H
;		WORD	00016-8,00000-8
;		BYTE	0E6H,040H,000H,002H
;		WORD	00000-8,00016-8
;		BYTE	0E8H,000H,000H,002H
;		WORD	00016-8,00016-8
;		BYTE	0E8H,040H,000H,002H
;;
;		WORD	00000-8,00000-8
;		BYTE	0CAH,000H,000H,002H
;		WORD	00016-8,00000-8
;		BYTE	0CAH,040H,000H,002H
;		WORD	00000-8,00016-8
;		BYTE	0E8H,000H,000H,002H
;		WORD	00016-8,00016-8
;		BYTE	0E8H,040H,000H,002H
;;----------------------------------------
;BARIFCS		EQU	$
;		LDA	ENCHPT,X
;		ASL	A
;		ASL	A
;		ASL	A
;;
;		ASL	A
;		ASL	A
;		ADC	#LOW  BARIFCD
;		STA	<WORK8
;		LDA	#HIGH BARIFCD
;		ADC	#000H
;		STA	<WORK9
;		LDA	#004H
;;;		STA	<WORK6
;;;		STZ	<WORK7
;		JSL	>SETOAML22
;;
;		JSL	>SADWSTL
;		RTS
;;----------------------------------------
BARIFF		EQU	$
		JSL	>BARI1MV
		RTS
;		JSR	BARIFCS		;INU SET
;		JSR	ENSTCK
;;;		JSR	ENHNSB
;;
;		LDA	>ITMTBL6
;		CMP	#02H
;		BCC	BF0010		; Ken high power ?
;;					; yes ! damage check !
;		JSL	>CRKNENL
;BF0010		EQU	$
;		JSL	>CRENPL2L
;		BCC	BF0018
;;
;		LDA	#20H
;		JSL	>PSERC2L
;		LDA	<WORK0
;		STA	<PLYSPD
;		LDA	<WORK1
;		STA	<PLXSPD
;		LDA	#08H
;		STA	<HANEFG
;;
;		JSL	>DASCLR1	;DASH KINSI!!
;BF0018		EQU	$
;;;		JSL	>CRENPL2L
;;;		BCC	BARIF0
;;;		JSL	>PLOTCK
;;;		STZ	<PYSPFG
;;;		JSL	>DASHON
;;;BARIF0		EQU	$
;		LDA	<FRCNT
;		LSR	A
;		LSR	A
;		LSR	A
;		AND	#001H
;		STA	ENCHPT,X
;		RTS
;----------------------------------------
BRMKDT		EQU	$
		BYTE	2,1,0,3
;
BR00		EQU	$
		LDA	ENMYNO,X
		CMP	#BARI1
		BEQ	BARIFF
;
;;		LDA	DJFLG
;;		BNE	BARIFF
;
		LDY	ENMUKI,X
		PHY
		LDA	ENTIM1,X
		BEQ	BRM001
		LDA	H0TURN,Y
		STA	ENMUKI,X
BRM001		EQU	$
		LDY	ENMUKI,X
		LDA	BRMKDT,Y
		STA	ENCHPT,X
		JSR	BARI0CS
		PLA
		STA	ENMUKI,X
;
		JSR	ENSTCK
;
		JSL	>CRKNENL
;
		LDA	GRNDNO
		CMP	#1BH
		BNE	BRM002
;
		LDA	#MS_0230
		LDY	ENYPSL,X
		CPY	#50H
		BEQ	BRM0011		
;
		LDA	#MS_0231
		CPY	#90H
		BNE	BRM002
;
BRM0011		EQU	$
		LDY	#HIGH MS_0231
		JSL	>MSGCHK
		BRA	BRM00E
;- - - - - - - - - - - - - - - - - - - - - -
BRM002		EQU	$
		LDA	BRMSCT		; MESEGE COUNTER !
		PHA
		CLC
		ADC	#MS_0020
		LDY	#HIGH MS_0020
		JSL	>MSGCHK
		PLA
		BCC	BRM00C		; MSG set ?
		INC	A		; yes !
		CMP	#05H+1+1
		BNE	BRM00C
		LDA	#00H
BRM00C		EQU	$
		STA	BRMSCT
BRM00E		EQU	$
;
;;		JSL	>CRKNENL
;;		JSL	>CRKNKNL
;;		JSL	>CRENPLL
		JSR	CREKEK
;
		TXA
		EOR	<FRCNT
		AND	#1FH
		BNE	BRM010
;
		JSR	PMSET		; muki -> player 
BRM010		EQU	$
		RTS
;================================
BRCXAD		EQU	$	
		WORD	004H,000H,0FFFAH,0FFFAH,0FFFAH+8
		WORD	000H,000H,0FFF9H,0FFF9H,0FFF9H
		WORD	000H,000H,00FH,00FH,00FH
		WORD	006H,006H+8,0FFFCH,004H,000H
BRCYAD		EQU	$
		WORD	000H,0FFF6H,0FFFCH,00CH,00CH
		WORD	000H,0FFF7H,0FFF5H,0FFF5H+8,0FFF5H+10H
		WORD	000H,0FFF7H,0FFF5H,0FFF5H+8,0FFF5H+10H
		WORD	0FFF5H,0FFF5H+10H,000H,000H,0FFF7H
BRCCDT		EQU	$
		BYTE	046H,040H,000H,028H,029H
		BYTE	04EH,042H,039H,02AH,03AH
		BYTE	04EH,042H,039H,02AH,03AH
		BYTE	026H,038H,064H,064H,044H
BRCADT		EQU	$
		BYTE	040H,000H,000H,000H,000H
		BYTE	000H,000H,000H,000H,000H
		BYTE	040H,040H,040H,040H,040H
		BYTE	000H,040H,000H,040H,000H
BRCSBD		EQU	$
		BYTE	002H,002H,002H,000H,000H
		BYTE	002H,002H,000H,000H,000H
		BYTE	002H,002H,000H,000H,000H
		BYTE	002H,000H,002H,002H,002H
BARI0CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
		PHX
		LDX	#04H
BRC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	BRCXAD,X
		CLC
		ADC	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
		LDA	BRCYAD,X
		CLC
		ADC	<WORK2
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	BRC012
;
		LDA	#00F0H
		STA	(<OAMADR),Y
BRC012		EQU	$
		MEM8
		SEP	#00100000B
		PLX
;
		LDA	BRCCDT,X
		INY
		STA	(<OAMADR),Y
		CMP	#40H
		LDA	BRCADT,X
		ORA	<WORK5
		BCS	BRC020
;
;;		PHA
;;		LDA	BRCXAD,X
;;		STA	ENKNXP
;;		LDA	BRCYAD,X
;;		STA	ENKNYP
;;;
;;		PLA
		AND	#11110001B
		ORA	#00001000B
BRC020		EQU	$
		INY		
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	BRCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	BRC010
		PLX
;;		LDY	#0FFH
;;		LDA	#04H
;;		JSL	>ALOMCKL
		LDA	#0CH
		JSL	>SADWS2L
		RTS
;;=============================================================
;BRSDXL		EQU	$
;		BYTE	00CH,0F8H,0F8H,008H
;BRSDXH		EQU	$
;		BYTE	000H,0FFH,0FFH,000H
;BRSDXA		EQU	$
;		BYTE	00CH,00CH,010H,010H
;BRSDYL		EQU	$
;		BYTE	0F8H,0F8H,0FEH,0F8H
;BRSDYH		EQU	$
;		BYTE	0FFH,0FFH,0FFH,0FFH
;BRSDYA		EQU	$
;		BYTE	018H,018H,018H,018H
;;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
;BRSDRS		EQU	$
;		PHB
;		PHK
;		PLB
;;
;		LDY	ENMUKI,X
;;
;		LDA	ENXPSL,X
;		CLC
;		ADC	BRSDXL,Y
;		STA	<WORK4
;		LDA	ENXPSH,X
;		ADC	BRSDXH,Y
;		STA	<WORKA
;;
;		LDA	ENYPSL,X
;		CLC
;		ADC	BRSDYL,Y
;		STA	<WORK5
;		LDA	ENYPSH,X
;		ADC	BRSDYH,Y
;		STA	<WORKB
;;
;		LDA	BRSDXA,Y
;		STA	<WORK6
;		LDA	BRSDYA,Y
;		STA	<WORK7
;		PLB
;		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Only pull swich                     		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ESW02MV		EQU	$
ESW04MV		EQU	$
		PHB
		PHK
		PLB
		LDA	ENMYNO,X
		CMP	#ESW04
		BEQ	ES3SUB
		CMP	#ESW03
		BNE	ESWFFF
;
ES3SUB		EQU	$
		JSR	ES3000
		PLB
		RTL
;- - - - - - - - - - - - - -  - - -
ESWFFF		EQU	$
		JSR	ES2000
		PLB
		RTL
;======================================
ES3000		EQU	$
		JSR	CRS3PL
;
		LDY	ENCHPT,X
		BEQ	S30010
		CPY	#0BH
		BEQ	S30020
;
		LDA	S3PLPT-1,Y
		STA	HIKUFG
		LDA	ENYPSL,X
		SEC
		SBC	#13H
;;		SBC	S3PLYL-1,Y
		STA	<PLYPS1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<PLYPS0
;
;;;;;;		JSR	S3PLDW		; player pos revise !
;
		LDA	ENXPSL,X
		STA	<PLXPS1
		LDA	ENXPSH,X
		STA	<PLXPS0
;
		LDA	ENTIM0,X
		BNE	S30010
;
		INC	ENCHPT,X
		LDY	ENCHPT,X
		CPY	#0BH
		BNE	S30018
;
;7/22		STZ	HIKUFG
;
		LDA	#1BH
		STA	SOUND3	;(S)
                LDA     #01H
                STA     SWCHFG
S30018		EQU	$
		LDA	S3TIME-2,Y
		STA	ENTIM0,X
		BRA	S30010
;
S30020		EQU	$
;;		STZ	HIKUFG
S30010		EQU	$
		LDA	ENMYNO,X
		CMP	#ESW04
		BEQ	S40010
		JSR	ESW03CS
		RTS
S40010		EQU	$
		JSR	ESW04CS
		RTS
;-  - - - - -
S3TIME		EQU	$
		BYTE	8,18H,4,4,4,4,4,4,2,0AH
;;		BYTE	006H,006H,008H,006H,006H,008H,008H,30H                 
S3PLPT		EQU	$
		BYTE	6,7,8,8,8,8,8,9,9,9
;;		BYTE    8,9,7,6,9,7,6,0AH,0BH              
;;S3PLYL		EQU	$
;;		BYTE	10H,10H,10H,10H,10H,10H                                   
;=======================================
;---------------------------------------------------
CRS3PL		EQU	$
		JSL	>CRENPL2L
		BCC	CRS310
;
		STZ	<PLYSPD
		STZ	<PLXSPD
;;		STZ	DASHFG
;;;		JSL	>DASCLR1
		JSL	>DASHON
;
		STZ	<HANIFG1
;
		LDA	PLYPS1
		SEC
		SBC	ENYPSL,X
		CMP	#002H
		BPL	CRS3DW
		CMP	#0F4H
		BMI	CRS3UP
		LDA	PLXPS1
		CMP	ENXPSL,X
		BPL	CRS3RG
CRS3LF		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<PLXPS1
		LDA	ENXPSH,X
		SBC	#00H
		STA	<PLXPS0
;
		RTS
;
CRS3RG		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#0EH
		STA	<PLXPS1
		LDA	ENXPSH,X
		ADC	#00H
		STA	<PLXPS0
;
CRS310		EQU	$
		RTS
;
CRS3UP		EQU	$
		INC	KINSHI		; Not "X" key check !
;
;7/22		STZ	HIKUFG
;
		LDA	<KEYA1L
;		AND	#10000000B
		BPL	CRS3RT
;
;7/22		STZ	HIKUFG
;
		LDA	<KEYA1
		AND	#00000011B
		BNE	CRS3RT		; side move ?
;					; no
		LDA	ENCHPT,X
		BNE	CRS3RT		; move start !
;
		INC	ENCHPT,X
		LDA	#08H
		STA	ENTIM0,X
;
;;		JSL	>SDLRCE
;;		ORA	#22H
;;		STA	SOUND2	;(S)
		LDA	#22H
		JSL	>SDLRE2	;(S)
CRS3RT		EQU	$
		LDA	ENYPSL,X
		SEC
		SBC	#15H
		STA	<PLYPS1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<PLYPS0
		RTS
CRS3DW		EQU	$
S3PLDW		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	#09H
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		STA	<PLYPS0
;
		RTS
;========================
E3CXAD		EQU	$
		BYTE	0FCH,00CH,000H,0FCH,004H,004H
E3CYAD		EQU	$
		BYTE	0FDH,0FDH,000H,005H,005H,005H
E3CCDT		EQU	$
		BYTE	012H+0C0H,012H+0C0H,004H+0C0H,024H+0C0H,024H+0C0H,024H+0C0H
E3CADT		EQU	$
		BYTE	040H,000H,000H,040H  ;,000H,000H
E3CSBD		EQU	$
		BYTE	000H,000H,002H,002H,002H,002H
E3CYRV		EQU	$
E4CYRV		EQU	$
		BYTE	0,1,2,3,4,5,5
E3CHPT		EQU	$
E4CHPT		EQU	$
		BYTE	0,0,1,1,2,2,3,3,4,5,5,5
;;		BYTE	0,0,1,1,2,2,3,3,4,5,5
;- - - -
;E4CYRV		EQU	$
;		BYTE	0,1,2,3,4,5,5
;E4CHPT		EQU	$
;		BYTE	0,0,1,1,2,2,3,3,4,5,5,5
;;;		BYTE	0,0,1,1,2,2,3,3,4,5,5
;
ESW03CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		JSL	>OCHECKL
;
		LDY	ENCHPT,X
		LDA	E3CHPT,Y
		TAY
		LDA	E3CYRV,Y
		STA	<WORK6
;
		PHX
		LDX	#04H
		LDY	#00H
E3C010		EQU	$
		LDA	<WORK0
		CLC
		ADC	E3CXAD,X
		STA	(<OAMADR),Y
;
		LDA	<WORK2
		CLC
		ADC	E3CYAD,X
		INY
		STA	(<OAMADR),Y
;
		LDA	E3CCDT,X
		INY
		STA	(<OAMADR),Y
;
		LDA	E3CADT,X
		ORA	#21H
		INY
		STA	(<OAMADR),Y
		PHY
		CPX	#02H
		BNE	E3C020
;
		DEY
		DEY
		LDA	(<OAMADR),Y
		SEC
		SBC	<WORK6
		STA	(<OAMADR),Y
E3C020		EQU	$
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	E3CSBD,X
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	E3C010
;
		PLX
		LDY	#0FFH
		LDA	#04H
		JSL	>ALOMCKL
		RTS
;========================
E4CCDT		EQU	$
		BYTE	0A2H,0A4H 
;
ESW04CS		EQU	$
		JSR	O2TEST
;
		JSL	>OCHECKL
;
		LDY	ENCHPT,X
		LDA	E4CHPT,Y
		TAY
		LDA	E4CYRV,Y
		STA	<WORK6
		STZ	<WORK7
;
		PHX
		LDX	#01H
		LDY	#00H
E4C010		EQU	$
		MEM16
		REP	#20H
		LDA	<WORK0
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CPX	#00H
		BNE	E4C018
		SEC
		SBC	<WORK6
E4C018		EQU	$
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		MEM8
		SEP	#20H
		BCC	E4C01A
		LDA	#0F0H
		STA	(<OAMADR),Y
E4C01A		EQU	$
;
		LDA	E4CCDT,X
		INY
		STA	(<OAMADR),Y
;
		LDA	<WORK5
		INY
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR	A
		LSR	A
		TAY
		LDA	#02H 
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		DEX
		BPL	E4C010
;
		PLX
		RTS
;==shita ni hipparu swich====================================
ESW02M		EQU	$
ES2000		EQU	$
		JSR	CRS2PL
;
		LDY	ENCHPT,X
		BEQ	S20010
		CPY	#0DH
		BEQ	S20020
;
		LDA	S2PLPT-1,Y
		STA	HIKUFG
		LDA	ENYPSL,X
		CLC
		ADC	S2PLYL-1,Y
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		STA	<PLYPS0
;
;;		JSR	S2PLDW		; player pos revise !
;
		LDA	ENXPSL,X
		STA	<PLXPS1
		LDA	ENXPSH,X
		STA	<PLXPS0
;
		LDA	ENTIM0,X
		BNE	S20010
;
		INC	ENCHPT,X
		LDY	ENCHPT,X
		CPY	#0DH
		BNE	S20018
;
		LDA	ENMYNO,X
		CMP	#ESW12
		BNE	S20015		; Hazure !!
;
		LDA	#01H
		STA	SWCHFG2
		LDA	#3CH
		STA	SOUND2	;(S)
		BRA	S20016
S20015		EQU	$
                LDA     #01H
                STA     SWCHFG
		LDA	#1BH
		STA	SOUND3	;(S)
;
S20016		EQU	$
;7/22		STZ	HIKUFG		
S20018		EQU	$
		LDA	S2TIME-2,Y
		STA	ENTIM0,X
		BRA	S20010
;
S20020		EQU	$
;;		STZ	HIKUFG
S20010		EQU	$
		JSR	ESW02CS
;
		LDA	ENDSPL,X
		BEQ	S21011
;
		STZ	ENCHPT,X
S21011		EQU	$
		RTS
;-  - - - - -
S2TIME		EQU	$
;;		BYTE	10H,0CH,10H,08H,08H,04H,04H,04H,04H,12H
		BYTE	5,5,5,5,5,5,5,5,5,5,5,5
S2PLPT		EQU	$
;;		BYTE	2,3,2,3,2,3,4,5,5,5,5,1
		BYTE	1,1,2,2,3,3,1,1,4,4,5,5
S2PLYL		EQU	$
;;;		BYTE	09H,09H,09H,09H,09H,09H,09H,09H+8,09H+8,09H+8,09H+8,09H+8
		BYTE	9,9,10,10,11,11,12,12,13,13,14,14
;========================================
ES2YDT		EQU	$
;;		BYTE	03H,04H,05H,06H,07H,08H,08H
		BYTE	1,1,2,3,2,3,4,5,6,7,6,7,7,7
;
ESW02CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
		JSL	>OCHECKL
;
		LDY	ENCHPT,X
		LDA	ES2YDT,Y
		STA	<WORK6
;
		LDY	#04H
		LDA	<WORK0
		STA	(<OAMADR),Y
		LDY	#00H
		STA	(<OAMADR),Y
		LDA	<WORK2
		DEC	A
		LDY	#01H
		STA	(<OAMADR),Y
		CLC
		ADC	<WORK6
		LDY	#05H
		STA	(<OAMADR),Y
		LDA	#0EH+0C0H
		LDY	#06H
		STA	(<OAMADR),Y
		LDA	#2EH+0C0H
		LDY	#02H
		STA	(<OAMADR),Y
;;		LDA	#21H
		LDA	<WORK5
		LDY	#03H
		STA	(<OAMADR),Y
		LDY	#07H
		STA	(<OAMADR),Y
;
		LDY	#02H
		LDA	#01H
		JSL	>ALOMCKL
		RTS
;---------------------------------------------------
CRS2PL		EQU	$
		JSL	>CRENPL2L
		BCC	CRSL10
;
		STZ	<PLYSPD
		STZ	<PLXSPD
;;		STZ	DASHFG
;;		JSL	>DASCLR1
		JSL	>DASHON
;
		STZ	<HANIFG1
;
		LDA	PLYPS1
		SEC
		SBC	ENYPSL,X
		CMP	#002H
		BPL	CRSWDW
		CMP	#0F4H
		BMI	CRSWUP
		LDA	PLXPS1
		CMP	ENXPSL,X
		BPL	CRSWRG
CRSWLF		EQU	$
		LDA	ENXPSL,X
		SEC
		SBC	#10H
		STA	<PLXPS1
		LDA	ENXPSH,X
		SBC	#00H
		STA	<PLXPS0
;
CRSL10		EQU	$
		RTS
;
CRSWRG		EQU	$
		LDA	ENXPSL,X
		CLC
		ADC	#0EH
		STA	<PLXPS1
		LDA	ENXPSH,X
		ADC	#00H
		STA	<PLXPS0
;
CRSR10		EQU	$
		RTS
;
CRSWUP		EQU	$
		LDA	ENYPSL,X
		SEC
		SBC	#15H
		STA	<PLYPS1
		LDA	ENYPSH,X
		SBC	#00H
		STA	<PLYPS0
		RTS
CRSWDW		EQU	$
		INC	KINSHI		; Not "X" key check !
;
;7/22		STZ	HIKUFG
;
		LDA	<KEYA1L
;		AND	#10000000B
		BPL	CRSWRT
;
;7/22		STZ	HIKUFG
;
		LDA	<KEYA1
		AND	#00000011B
		BNE	CRSWRT		; side move ?
;					; no
;;;		LDA	#01H
		INC	HIKUFG		; Kamae set !
;
		LDA	<KEYA1
		AND	#00000100B
		BEQ	CRSWRT		; Down key in ?
;					; yes !
		LDA	ENCHPT,X
		BNE	CRSWRT		; move start !
;
		INC	ENCHPT,X
		LDA	#0CH
		STA	ENTIM0,X
;
;;		JSL	>SDLRCE
;;		ORA	#22H
;;		STA	SOUND2	;(S)
		LDA	#22H
		JSL	>SDLRE2	;(S)
CRSWRT		EQU	$
S2PLDW		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	#09H
		STA	<PLYPS1
		LDA	ENYPSH,X
		ADC	#00H
		STA	<PLYPS0
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      OYAGI INIT                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OYAGIIT		EQU	$
		PHB
		PHK
		PLB
		JSR	OYAGI00_I
		PLB
		RTL
;========================================
SINPUPX		EQU	$
		WORD	-0006,-0006,-0006
SINPUPY		EQU	$
		WORD	00000,-0009,00000
OYAGI00_I	EQU	$
;
		LDA	<RMXYCT
		CMP	#012H
		BEQ	OYAGI80_I
		JMP	OYAGI30_I
;
OYAGI80_I	EQU	$
		JSR	KYDAIST		;KYODAI SET
;
		LDA	>MODTBL0
		CMP	#003H
		BCC	OYAGI90_I
		LDA	>MODTBL1
		ORA	#002H
		STA	>MODTBL1
OYAGI90_I	EQU	$
;
		LDA	>MODTBL1
		AND	#002H
		BEQ	OYAGI60_I	;? SINDA
;					;Y
		STZ	ENMODE,X	;KILL I
		RTS
;
OYAGI60_I	EQU	$
		LDA	#001H		;SINPU NO
		STA	ENWRK3,X
;
		LDA	ENMOD0,X	;OAM NO KAZU
		AND	#0F0H
		ORA	#002H
		STA	ENMOD0,X
;
		LDA	#003H		;OBJ HANI
		STA	ENMOD3,X
;
		LDA	>ITMTBL6
		CMP	#002
		BCC	OYAGI70_I
;
		LDA	#004H		;TAORETER SINPU
		STA	ENMUKI,X
		STZ	ENCHPT,X
;
;		LDA	#003H		;OBJ HANI
;		STA	ENMOD3,X
;
		LDA	#000H
		BRA	OYAGI20_I
;
OYAGI70_I	EQU	$
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		LDA	>OPMODE
		CMP	#prnce
		BNE	OYAGI10_I	;? ONNANOKO(HELP0) O TURETERU
		LDA	>MODTBL1
		ORA	#004H		; DOOR MOVE & ONNANOKO HELP FLG(SAVE)
		STA	>MODTBL1
		LDA	>GNDTBL+01BH
		ORA	#020H
		STA	>GNDTBL+01BH
		LDA	#0AAH
		STA	ENTIM0,X	;INIT STOP TIME
		LDA	#001H
		BRA	OYAGI20_I
;
OYAGI10_I	EQU	$
		LDA	#002H		;INIT MODE
OYAGI20_I	EQU	$
		STA	ENCONT,X	;SINPU MOVE MODE
		ASL	A
		TAY
		LDA	SINPUPX,Y	;INIT POS SET X
		CLC
		ADC	ENXPSL,X
		STA	ENXPSL,X
		LDA	SINPUPX+1,Y
		ADC	ENXPSH,X
		STA	ENXPSH,X
;
		LDA	SINPUPY,Y	;INIT POS SET Y
		CLC
		ADC	ENYPSL,X
		STA	ENYPSL,X
		LDA	SINPUPY+1,Y
		ADC	ENYPSH,X
		STA	ENYPSH,X
;
		INC	ENNOCR,X	;beem thru
;
		LDA	#000H
		STA	>KRXBUF+1	;ONNANOKO(HELP0) TALK FLG
;
		RTS
;
;----------------------------------------
OYAGI30_I	EQU	$
		CMP	#004H
		BNE	OYAGI40_I
;
		LDA	>MODTBL1		;PL. SLEEP
		AND	#010H
		BNE	OYAGI50_I
;
;;		LDA	#000H
;;		STZ	ENCONT,X
;
		LDA	ENXPSL,X
		CLC
		ADC	#008H
		STA	ENXPSL,X
;;		LDA	ENXPSH,X
;;		ADC	#000H
;;		STA	ENXPSH,X
;
;;		LDA	#000H
;;		STZ	ENMUKI,X
		RTS
;
OYAGI40_I	EQU	$
		LDA	>MODTBL1		;PL. not SLEEP
		AND	#001H
		BNE	OYAGI50_I
;
		LDA	#003H
		STA	ENMUKI,X
		LSR	A
;;		LDA	#001H
		STA	ENCONT,X
		RTS
OYAGI50_I	EQU	$
		STZ	ENMODE,X	;KILL I
		RTS
;----------------------------------------
KDASTXD		EQU	$
		WORD	004F0H;,00110H,00110H,00110H
KDASTYD		EQU	$
		WORD	00237H;,00837H,00837H,00837H
KYDAIST		EQU	$
		INC	ENMODE+ENNO-1	;ONNANOKO YOU
;
		LDA	#OYAGI
		JSL	>ENIDSH
;;;		BMI	OYGST10
;
		STZ	ENMODE+ENNO-1	;ONNANOKO YOU
;
;		PHX
		LDA	ENMOD0,Y	;OAM NO KAZU
		AND	#0F0H
		ORA	#003H
		STA	ENMOD0,Y
;
;		LDA	>MODTBL1	;INIT MODE
;		LSR	A
;		AND	#003H
;KDAST20		EQU	$
;		STA	ENCONT,Y	;KYODAI MOVE MODE
;		ASL	A
;		TAX
		LDA	KDASTXD+0;,X
		STA	ENXPSL,Y
		LDA	KDASTXD+1;,X
		STA	ENXPSH,Y
		LDA	KDASTYD+0;,X
		STA	ENYPSL,Y
		LDA	KDASTYD+1;,X
		STA	ENYPSH,Y
;		PLX
;
;;KDAST10		EQU	$
		LDA	#002H		;KYDAI NO
		STA	ENWRK3,Y
		LDA	#0BH
		STA	ENMOD3,Y	;OBJ hit hani !
		LDA	ENMOD5,Y	;HUKKU ATARI
		ORA	#020H
		STA	ENMOD5,Y
		LDA	#001H
		STA	ENCONT,Y
;
		LDA	ENYPSL,Y
		STA	<WORK0
		LDA	ENYPSH,Y
		STA	<WORK1
		MEM16
		REP	#00110000B
		LDA	<PLYPS1
		CMP	<WORK0
		MEM8
		SEP	#00110000B
		BCS	KDAST10
		LDA	#001H
		STA	ENWRK2,Y
KDAST10		EQU	$
		RTS
;
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      OYAGI MOVE                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
OYAGIMV		EQU	$
		PHB
		PHK
		PLB
		JSR	OYAGIBR
		PLB
		RTL
;========================================
OYAGIBR		EQU	$
		LDA	ENWRK3,X
		JSL	>JSRSUB
		WORD	OYAGI00
		WORD	SINPU00
		WORD	KYDAI00
;----------------------------------------
;----------------------------------------
;		KYDAI MOVE
;----------------------------------------
KYDAI00		EQU	$
		JSR	KYDAICS
		JSR	ENSTCK          ; scroll : not return !
;
		LDA	ENWRK2,X
		BNE	KYDAI30
;
		JSL	>CRENPL2L
		BCC	KYDAI10
;
;----------------------------------------SAWARI
		JSL	>PLOTCK		;PL. POS. recover
;
		STZ	<PYSPFG		;DASH STOP
		JSL	>DASHON
;
		LDA	#007H
		STA	ENTIM1,X
;
KYDAI20		EQU	$
		STZ	ENCONT,X	;CLS
;
		LDA	#081H		;PL. PUSH E
		STA	<HANIFG1
		LDA	#008H
		STA	<PYSPFG
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KYDF0M0
		WORD	KYDF0M1
		WORD	KYDF0M2
;----------------------------------------SAWARANAI
KYDAI10		EQU	$
		LDA	ENTIM1,X
		BNE	KYDAI20
;
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	KYDF1M0
		WORD	KYDF1M1
;----------------------------------------UE SENYOU
KYDAI30		EQU	$
		LDA	#040H
		STA	ENWRK0,X
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KYDF0M0
		WORD	KYDF0M1
		WORD	KYDF0M2
;----------------------------------------
KYDF1M0		EQU	$
		STZ	ENWRK0,X	;KAUNT CLS
		STZ	<HANIFG1	;PL. PUSH E MOTO NI MODOSU
		STZ	<PYSPFG
		INC	ENCONT,X
KYDF1M1		EQU	$
		RTS
;----------------------------------------
KYDF0M0		EQU	$
;
		LDA	ENXPSL,X
		PHA
		CLC
		ADC	#013H
		STA	ENXPSL,X
		LDA	ENXPSH,X
		PHA
		ADC	#000H
		STA	ENXPSH,X
		JSR	EPXYCK		;pl muki set
		PLA
		STA	ENXPSH,X
		PLA
		STA	ENXPSL,X
		CPY	#003H
		BEQ	KYD0020
		CPY	#001H
		BNE	KYD0010
;
KYD0020		EQU	$
		INC	ENWRK0,X
		LDA	ENWRK0,X
		CMP	#040H
		BCC	KYD0010
;
		INC	ENSTAT,X	;MOVE!!
;		LDA	>MODTBL1	;DOOR OPEN FLG(SAVE)
;		ORA	#002H
;		STA	>MODTBL1
		LDA	#001H		;STOP PL.
		STA	PYALSP
KYD0010		EQU	$
		RTS
;----------------------------------------
KYDF0M1		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#018H		;OTO
;;		STA	SOUND3
		LDA	#18H
		JSL	>SDLRE3	;(S)
;
		INC	ENSTAT,X
		LDA	#0A8H		;X KYORI
		STA	ENTIM0,X
		LDA	#003H		;X SPEED
		STA	ENXSPD,X
		LDA	#002H
		STA	ENTIM1,X
		RTS
;----------------------------------------
KYDF0M2		EQU	$
		JSR	ENMVCL		; xclc,yclc !
		LDA	ENTIM0,X
		BNE	KYD0210
;
		STZ	PYALSP		;PL. MOVE
		STZ	ENXSPD,X	;SPEED OFF
		STZ	ENWRK2,X
		RTS
KYD0210		EQU	$
		LDA	#002H
		STA	ENTIM1,X
		RTS
;----------------------------------------
KYDAICD		EQU	$
		WORD	00000,00000
		BYTE	02CH,016H,000H,002H
		WORD	00016,00000
		BYTE	02CH,056H,000H,002H
		WORD	00000,00016
		BYTE	02EH,006H,000H,002H
		WORD	00016,00016
		BYTE	02EH,046H,000H,002H
;
KYDAICS		EQU	$
;;		LDA	<PLBGCKF	;OBJ YUUSEN
;;		CMP	#003
;;		BNE	KDICS10
;;		STA	ENKAIF,X
;;KDICS10		EQU	$
;
		LDA	#LOW KYDAICD
		STA	<WORK8
		LDA	#HIGH KYDAICD
		STA	<WORK9
;
;;		LDA	#004H			;KAZU SET
;;		STA	<WORK6
;;		STZ	<WORK7
;
		LDA	ENWRK2,X
		BNE	KDICS10
;
;;;;		JSL	>SETOAML		;OAM SET
;
;;;;		RTS
		LDA	#04H*4
		JSL	>OAMENT2
KDICS10		EQU	$
		LDA	#04H
		JMP	SETO22
;;		JSL	>SETOAML22		;OAM SET
;;;
;;		RTS
;----------------------------------------
ENMKIST		EQU	$
;	ENMUKI : NOW MUKI
;	ENCMKI : NEW MUKI
;
;
;
;
		LDA	ENMUKI,X
		CMP	ENCMKI,X
		BEQ	ENMKST1
;
		LDA	<FRCNT
		AND	#01FH
		BNE	ENMKST0
;
		LDA	ENMUKI,X
		EOR	ENCMKI,X
		AND	#002H
		BNE	ENMKST1
		TXA
		EOR	<FRCNT		;MUKI YOKO
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		ORA	#002H
		AND	#003H
		STA	ENMUKI,X
		LDA	ENCMKI,X
		AND	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
ENMKST0		EQU	$
		CLC			;NO
		RTL
ENMKST1		EQU	$
		LDA	ENCMKI,X	;MUKI OK
		STA	ENMUKI,X
		SEC			;OK
		RTL
;
;----------------------------------------
;		SINPU MOVE
;----------------------------------------
SINPUSX		EQU	$
		BYTE	000,000,-09,009
SINPUSY		EQU	$
		BYTE	-09,009,000,000
SINPU00		EQU	$
		LDA	ENWRK0,X
		BNE	SINPU20
		JSL	>SINPUCS
SINPU20		EQU	$
		JSR	ENSTCK          ; scroll : not return !
;
		JSL	>ENPLATR
;		LDA	ENMOD3,X
;		PHA
;		LDA	#000H
;		STA	ENMOD3,X
;		JSL	>CRENPL2L
;		BCC	SINPU10
;		PHX
;		JSL	>PLOTCK		;PL. POS. recover
;		STZ	<PYSPFG		;DASH STOP
;		JSL	>DASCLR1
;		PLX
SINPU10         EQU     $
;		PLA
;		STA	ENMOD3,X
;
		JSL	>ENMKIST	;MUKI SET
		JSR	ENMVCL		; xclc,yclc !
;
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	SINPUF1		; DEMO 1(sinpu down)
		WORD	SINPUF2		; DEMO 2(onna move)
		WORD	SINPUF3		; DEMO 3(onna NARABI)
;----------------------------------------
SINPUF1		EQU	$
		LDA	#004H
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SNPF1M0		; WAIT & MSGE
		WORD	SNPF1M1
		WORD	SNPF1M2
;----------------------------------------
SNPF1M0		EQU	$
		LDA	#LOW  MS_0037	;MSGE NO SET
		LDY	#HIGH MS_0037	;MSGE NO SET
		JSL	>ENMSGEL	;MSGE SET
		BCC	SP1M010
		INC	ENSTAT,X
		INC	ENCHPT,X
		LDA	>MODTBL1
		ORA	#002H
		STA	>MODTBL1
		LDA	#080H
		STA	ENTIM2,X
SP1M010		EQU	$
		RTS
;----------------------------------------
SNPF1M1		EQU	$
		STZ	ENCHPT,X
;
		LDA	ENTIM2,X
		BNE	SP1M110
		INC	ENSTAT,X
SP1M110		EQU	$
		LDA	<FRCNT
		AND	#002H
		STA	ENWRK0,X
;
		LDA	ENTIM2,X
		AND	#007H
		BNE	SP1M120
;
;;		JSL	>SDLRCE
;;		ORA	#033H
;;		STA	SOUND2
		LDA	#33H
		JSL	>SDLRE2	;(S)
;
SP1M120		EQU	$
		RTS
;----------------------------------------
SNPF1M2		EQU	$
		STZ	ENMODE,X
		RTS
;----------------------------------------
SINPUF2		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SNPF2M0		; WAIT & MSGE
		WORD	SNPF2M1
		WORD	SNPF2M2
		WORD	SNPF2M3
;----------------------------------------
SNPF2M0		EQU	$
		LDA	#000H		;KAIDAN MIRU
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		LDA	ENTIM0,X
		BNE	SF2M010
;
		LDA	#LOW  MS_0033	;MSGE NO SET
		LDY	#HIGH MS_0033	;MSGE NO SET
		JSL	>ENMSGSL	;MSGE SET
;
		INC	ENSTAT,X	;NEXT GO
;
		LDA	#001H		;ONNANOKO(HELP0) TALK OK!!
		STA	>KRXBUF+1
;
		JSR	HELP0ST		;ONNANOKO(HELP0) SET & PL.HELP0 CLS
;
		LDA	#001H		;STOP PL.
		STA	PYALSP
;
		LDA	#001H
		STA	>MODTBL2	;TEST GMAP POINT 3 SET(SAVE)
;		LDA	#02DH		;OTO
;		JSL	>SDLRE3
;
SF2M010		EQU	$
		RTS
;----------------------------------------
SNPF2M1		EQU	$
		LDA	>KRXBUF+1
		CMP	#002H
		BNE	SF2M110		;? ONNANOKO(HELP0) MSGE END
;					;Y
		LDA	#LOW  MS_0034	;MSGE NO SET
		LDY	#HIGH MS_0034	;MSGE NO SET
		JSL	>ENMSGSL	;MSGE SET
;
		INC	ENSTAT,X	;NEXT GO
SF2M110		EQU	$
		RTS
;----------------------------------------
SNPF2M2		EQU	$
		LDA	MSG_RTS
		BNE	SF2M210
		INC	ENSTAT,X	;NEXT GO
		STZ	PYALSP		;MOVE PL.
		RTS
SF2M210		EQU	$
		LDA	#001H		;
		STA	ENSTAT,X
		RTS
;----------------------------------------
SNPF2M3		EQU	$
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	#LOW  MS_0032	;MSGE NO
		LDY	#HIGH MS_0032	;MSGE NO
		JSL	>ENMSGEL	;MSGE SET
		BCC	SP2M310
;
		STA	ENMUKI,X	;MUKI SET
		STA	ENCMKI,X
;
SP2M310		EQU	$
		RTS
;----------------------------------------
SP3M0ML		EQU	$
		BYTE	LOW  MS_0032
		BYTE	LOW  MS_0035
		BYTE	LOW  MS_0036
SP3M0MH		EQU	$
		BYTE	HIGH MS_0032
		BYTE	HIGH MS_0035
		BYTE	HIGH MS_0036
;
SINPUF3		EQU	$
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
SNPF3M0		EQU	$
		LDY	#000H
;
SF3M010		EQU	$
		LDA	>ITEMR53
		AND	#007H
		CMP	#007H
		BNE	SF3M020
		LDY	#002H
		BRA	SF3M030
;
SF3M020		EQU	$
		LDA	>MODTBL2
		CMP	#003H
		BCC	SF3M030
		LDY	#001H
;
SF3M030		EQU	$
		LDA	SP3M0ML,Y
		XBA
		LDA	SP3M0MH,Y
		TAY
		XBA
		JSL	>ENMSGEL	;MSGE SET
		BCC	SF3M040
;
		STA	ENMUKI,X	;MUKI SET
		STA	ENCMKI,X
;
		LDA	#0A0H
		STA	>UPLFCT
;
SF3M040		EQU	$
		RTS
;----------------------------------------
;		OYAGI MOVE
;----------------------------------------
OYAGISX		EQU	$
		BYTE	000,000,-12,012
OYAGISY		EQU	$
		BYTE	-12,012,000,000
OYAGI00		EQU	$
		JSL	>OYAGICS
		JSR	ENSTCK          ; scroll : not return !
;
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	OYAGIF0
		WORD	OYAGIF1
;----------------------------------------
OYAGIF0		EQU	$
;
		JSR	ENMVCL		; xclc,yclc !
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	OYGF0M0
		WORD	OYGF0M1
		WORD	OYGF0M2
		WORD	OYGF0M3
		WORD	OYGF0M4
;----------------------------------------
PLPOSDX		EQU	0940H
PLPOSDY		EQU	215AH
;
OYGF0M0		EQU	$
		LDA	#LOW  PLPOSDX	;PL. POS SET
		STA	PLSVX1
		LDA	#HIGH PLPOSDX
		STA	PLSVX1+1
		LDA	#LOW  PLPOSDY
		STA	PLSVY1
		LDA	#HIGH PLPOSDY
		STA	PLSVY1+1
;
		LDA	#LOW  MS_0043	;MSGE NO SET
		LDY	#HIGH MS_0043	;MSGE NO SET
		JSL	>ENMSGSL	;MSGE SET
;
		INC	ENSTAT,X
;
		RTS
;----------------------------------------
OYGF0M1		EQU	$
		LDA	<FRCNT
		AND	#003H
		BNE	OYG0120
		LDA	<WD2132R
		CMP	#020H
		BEQ	OYG0110
		DEC	<WD2132R
		DEC	<WD2132G
;// 03.05.27 //		DEC	<WD2132B
OYG0120		EQU	$
		RTS
OYG0110		EQU	$
		INC	ENSTAT,X
;
		INC	OPNGFG
		INC	OPNGMD
		LDA	#057H		; player y-pos set
		STA	<PLYPS1
		LDA	#021H
		STA	<PLYPS0
;
		LDA	#001H		;PL. STOP
		STA	PYALSP
;
		RTS
;----------------------------------------
OYGF0M2		EQU	$
;
		LDA	#LOW  MS_0010	;MSGE NO SET
		LDY	#HIGH MS_0010	;MSGE NO SET
		JSL	>ENMSGSL	;MSGE SET
;
		INC	ENSTAT,X
;
		LDA	#003H		;OTO
		STA	SOUND0
;// 03.09.16 //		STA	SVSND0
;
		LDA	#001H
		STA	ENCHPT,X
		RTS
;----------------------------------------
OYG03DT		EQU	$
		BYTE	040H,0E0H
OYG03DM		EQU	$
		BYTE	002H,001H
OYGF0M3		EQU	$
		LDA	ENTIM0,X
		BNE	OYG0310
		LDY	ENWRK0,X
		BNE	OYG0320
		LDA	ENYPSL,X
		SEC
		SBC	#002H
		STA	ENYPSL,X
OYG0320		EQU	$
		LDA	OYG03DT,Y
		STA	ENTIM0,X
		LDA	OYG03DM,Y
		STA	ENMUKI,X
		TAY
		LDA	OYAGISX,Y
		STA	ENXSPD,X
		LDA	OYAGISY,Y
		STA	ENYSPD,X
		INC	ENWRK0,X
		LDA	ENWRK0,X
		CMP	#003H
		BNE	OYG0310
		INC	ENSTAT,X
OYG0310		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		RTS
;----------------------------------------
OYGF0M4		EQU	$
		LDA	#mesmv		;PL. OPTION SET
		STA	>OPMODE
		LDA	#LOW  OTIM
		STA	OPMTIM
		LDA	#HIGH OTIM
		STA	OPMTIM+1
;
		LDA	>MODTBL1	;OYAGI KILL
		ORA	#010H
		STA	>MODTBL1
;
		STZ	ENMODE,X	;KILL I
		STZ	PYALSP		;PL. MOVE
		RTS
;----------------------------------------
OYAGIF1		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	OYGF1M0
		WORD	OYGF1M1
		WORD	OYGF1M2
;----------------------------------------
OYGF1M0		EQU	$
		JSL	>CRENPL2L
		BCC	OG1M020
		JSL	>DASCLR1	;DASH KINSI!!
;
OG1M020		EQU	$
		LDA	#LOW  MS_0011	;MSGE NO SET
		LDY	#HIGH MS_0011	;MSGE NO SET
		JSL	>ENMSG2L	;MSGE SET
		BCC	OG1M010
		LDA	#nashi
		STA	>OPMODE		;PL. OPTION OFF
		INC	ENSTAT,X
OG1M010		EQU	$
;----------------------------------------
OYGF1M2		EQU	$
		RTS
;----------------------------------------
OYGF1M1		EQU	$
		LDY	#000H		;PL. KEN & TATE GET
		STZ	!ITMVFG
		JSL	>ATMSIT
		INC	ENSTAT,X
		LDA	#001H
		STA	ENCHPT,X
;
		LDA	#003H		;SAVE 
		STA	>MODTBL3
		LDA	>MODTBL1	;OYAGI KILL
		ORA	#001H
		STA	>MODTBL1
		LDA	#001H
		STA	>MODTBL0	;KEN & TATE OK
;
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      SETOAML		                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	<WORK6,7 <---- KAZU (8BYTE = 1) (0 = NOT TENSOU)
;	<WORK8,9 <--- TFR MOTO
;	     L H
;
;	SETOAML : OAMCHK
;		: OCHECKL
;		: OAM SET
;
;
;	SETOAM2 : OAM SET
;
;
;
SETOAML22	EQU	$
		STA	<WORK6
		STZ	<WORK7
SETOAML2	EQU	$
		JSR	STOAMCK2		;JSR	OAMCHK
		BRA	SO0010
SETOAML		EQU	$
;
;		LDA	<WORK6
;		ORA	<WORK7
;		BEQ	STOAM10		;?KAZU = 0
;					;n
		JSR	STOAMCK		;JSR	OAMCHK
SO0010		EQU	$
		BCS	STOAM10		;? ok
;
SETOAM2		EQU	$		;y
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	#00000H		;DATA READ POINT
		LDX	OAMADR		;OAM ADR
;
STOAM20		EQU	$
;
		LDA	(<WORK8),Y	;X pos set
		CLC
		ADC	<WORK0
		STA	OAM-OAM,X
		AND	#00100H		;OAMSB DATA SET(JUNBI)
		STA	<WORKC
;
		INY			;NEXT READ POINT
		INY
;
		LDA	(<WORK8),Y	;Y pos set
		CLC
		ADC	<WORK2
		STA	OAM-OAM+1,X
		CLC
		ADC	#00010H
		CMP	#00100H
		BCC	STOAM30		;!(0FFF0H - 000F0H) = CLS
		LDA	#000F0H		;Y pos cls
		STA	OAM-OAM+1,X
;
STOAM30		EQU	$
		INY			;NEXT READ POINT
		INY
;
		LDA	EICECKF
		CMP	#01H
;
		LDA	(<WORK8),Y	;CHAR and ATR SET
		EOR	<WORK4
		BCC	STO001		;EICE ?
;						; yes ! kotei color !
		AND	#1111000111111111B
		ORA	#0000010000000000B
STO001		EQU	$
		STA	OAM-OAM+2,X
;
		PHX
		TXA
		SEC
		SBC	#OAM
		LSR	A
		LSR	A
		TAX
		MEM8
		SEP	#00100000B
;
		INY			;NEXT READ POINT
		INY
		INY
		LDA	(<WORK8),Y
		ORA	<WORKD
;
		STA	OAMSB,X
		PLX
;
		MEM16
		REP	#00100000B
;
		INY			;NEXT READ POINT
;
		INX
		INX
		INX
		INX
;
		DEC	<WORK6		;? ALL OVRE
		BNE	STOAM20
;					;Y
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
STOAM10		EQU	$
		RTL
;----------------------------------------
STOAMCK		EQU	$		;JSR	OAMCHK
		JSL	>OCHECKL
STOAMCK2		EQU	$		;JSR	OAMCHK
		JSR	OAMCHK		;BCC --> OK
;
		PHP
;
		STZ	EICECKF
		STZ	EICECKF+1
;
		LDA	ENMODE,X
		CMP	#ECACH
		BNE	STOCKF
;
		LDA	>ENCAMD,X
STOCKF		EQU	$
		CMP	#EICE
		BNE	STOCK0
;
		LDA	>ENICMD,X
;;		LDA	ENWRK2,X
		STA	EICECKF	; 0:Stop 1:Ice
;
STOCK0		EQU	$
		PLP
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	NOPPO move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NOPPOMV		EQU	$
		PHB
		PHK
		PLB
		JSR	NP0000
		PLB
		RTL
NP0000		EQU	$
		JSR	NOPPOCS
		JSR	ENSTCK		; scroll : not return !
;
;		LDA	<DJFLG
;		BEQ	NOPPO10
		JSL	>ENMKIST	;MUKI SET
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	<RMXYCT
		AND	#001H
		BNE	NOPPO30
		LDA	#LOW  MS_04B2	; MSGE NO. SET
		LDY	#HIGH MS_04B2	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	NOPPO40
;
NOPPO30		EQU	$
		LDA	RMSTTT+1
		BNE	NOPPO50
		LDA	#LOW  MS_04B0	; MSGE NO. SET
		LDY	#HIGH MS_04B0	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	NOPPO40
NOPPO50		EQU	$
		LDA	#LOW  MS_04B1	; MSGE NO. SET
		LDY	#HIGH MS_04B1	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
NOPPO40		EQU	$
		JSL	>ENPLATR	;PL. EN. ATARI SET
NOPPO20		EQU	$
		RTS
;
;
;
;NOPPO10		EQU	$
;		LDA	#LOW  MS_0000
;		LDY	#HIGH MS_0000
;		JSL	>ENMSGEL
;		BCC	MURAAMV		;
;		STA	ENWRK0,X	; PL. miru!
;		STA	ENMUKI,X	; PL. miru!
;		STZ	ENSTAT,X	; PL. miru!
;
MURAAMV		EQU	$
		JSR	ENMVCL		; xclc,yclc,BG check !
;		JSL	>ENBGCKL		; BG check sub !
		JSR	ENBGCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	NOPPOM0
		WORD	NOPPOM1
;----------------------------------------
NOPPOSX		EQU	$
		BYTE	000H,000H,0F4H,00BH
NOPPOSY		EQU	$
		BYTE	0F4H,00BH,000H,000H
NOPPOM0		EQU	$
		LDA	ENTIM0,X
		BNE	NOPM010
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#040H
		STA	ENTIM0,X
;
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
NOPM010		EQU	$
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	NOPM020
		INC	ENSTAT,X
		LDA	#060H
		STA	ENTIM0,X
NOPM020		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDY	ENMUKI,X
		LDA	NOPPOSX,Y
		STA	ENXSPD,X
		LDA	NOPPOSY,Y
		STA	ENYSPD,X
		TYA
		STA	ENWRK0,X
;
		RTS
;----------------------------------------
NOPPOM1		EQU	$
		LDA	ENTIM0,X
		BNE	NOPM120
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#060H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
NOPM120		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	<WORK0
		AND	#001H
		BNE	NOPM110
		LDA	<WORK0
		LSR	A
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENWRK0,X
		RTS
;
NOPM110		EQU	$
		LDA	ENMUKI,X
		STA	ENWRK0,X
		RTS
;----------------------------------------
NOPPOCD		EQU	$
		WORD	00000,-0012		;1
		BYTE	004H,000H,000H,002H
		WORD	00000,00000
		BYTE	00AH,000H,000H,002H
;
		WORD	00000,-0011
		BYTE	004H,000H,000H,002H
		WORD	00000,00001
		BYTE	00AH,040H,000H,002H
;
		WORD	00000,-0012		;1
		BYTE	004H,000H,000H,002H
		WORD	00000,00000
		BYTE	00AH,000H,000H,002H
;
		WORD	00000,-0011
		BYTE	004H,000H,000H,002H
		WORD	00000,00001
		BYTE	00AH,040H,000H,002H
;
		WORD	00000,-0012		;2
		BYTE	008H,000H,000H,002H
		WORD	00000,00000
		BYTE	00AH,000H,000H,002H
;
		WORD	00000,-0011
		BYTE	008H,000H,000H,002H
		WORD	00000,00001
		BYTE	00AH,040H,000H,002H
;
		WORD	00000,-0012		;3
		BYTE	008H,040H,000H,002H
		WORD	00000,00000
		BYTE	00AH,000H,000H,002H
;
		WORD	00000,-0011
		BYTE	008H,040H,000H,002H
		WORD	00000,00001
		BYTE	00AH,040H,000H,002H
;
NOPPOCS		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 NOPPOCD
		STA	<WORK8
		LDA	#HIGH NOPPOCD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		RTS
;----------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	ENMSGE		                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
EMGELPM		EQU	$
		BYTE	4,6,0,2
ENMSGEL		EQU	$		;PUSH DO BOTON
;
		STA	!MSGENOL	;msge no set(test)
		STY	!MSGENOH
		JSL	>CRENPL2L
		BCC	ENMSG10
;
		JSL	>WPMSCK
		BCS	ENMSG10
;
		LDA	<KEYA2L		;DO boton?
		BPL	ENMSG10
;
		LDA	ENTIM3,X
		BNE	ENMSG10		;? MSGE NOT SET
;
		LDA	<DIEFG
		CMP	#002H
		BEQ	ENMSG10
;
		JSR	EPXYCK
		PHX
		TYX
		LDA	>EMGELPM,X
		PLX
		CMP	<PLMKCH
		BNE	ENMSG10
		PHY
;
		LDA	!MSGENOL	;MSGE NO GET
		LDY	!MSGENOH	;MSGE NO GET
		JSL	>ENMSGSL	;MSGE SET
;
		LDA	#040H		;TIME SET
		STA	ENTIM3,X
;
		PLA			;pl muki set
		EOR	#003H
		SEC
		RTL
ENMSG10		EQU	$
		LDA	ENMUKI,X
		CLC
		RTL
;----------------------------------------
ENMSG2L		EQU	$		;NO BOTON
;
		STA	!MSGENOL	;msge no set(test)
		STY	!MSGENOH
		JSL	>CRENPL2L
		BCC	ENMS210
;
		LDA	<DIEFG
		CMP	#002H
		BEQ	ENMS210
;
		LDA	!MSGENOL	;MSGE NO GET
		LDY	!MSGENOH	;MSGE NO GET
		JSL	>ENMSGSL	;MSGE SET
;
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		SEC
		RTL
ENMS210		EQU	$
		LDA	ENMUKI,X
		CLC
		RTL
;----------------------------------------
ENMSGSL		EQU	$		;MSGE SET
		STA	!MSGENOL	;msge no set(test)
		STY	!MSGENOH
;
		STZ	!MSGEFG
		STZ	!INITAL
		LDA	#p3_msge
		STA	<GAMEMD
		LDA	<SLMODE
		STA	!NXSLMD
		LDA	#MD_etcpl
		STA	<SLMODE
;
		PHX
		JSL	>PLOTCK		;PL. POS. recover
		STZ	<PYSPFG		;DASH STOP
		JSL	>DASCLR1
		STZ	<DIEFG
		STZ	<HANEFG
		LDA	<LNMODE
		CMP	#JMDM
		BNE	EMGSL10
		LDA	#LNMD
		STA	<LNMODE
EMGSL10		EQU	$
		PLX
;
		RTL
;========================================
;	PLHIK	MOVE
;========================================
PLHIKMV		EQU	$
		PHB
		PHK
		PLB
		JSR	PLHIK00
		PLB
		RTL
;----------------------------------------
PLHIK00		EQU	$
;		LDA	#030H
;		STA	ENFLCL,X
;		JSL	>EN1CSTL
		JSL	>OAMCHKL
		JSR	ENSTCK		; scroll : not return !
		JSL	>WPMSCK
		BCS	PLHIK20
;
		JSL	>CRENPL2L
		BCC	PLHIK10
		LDA	#001H
		STA	ATHKOK
;		LDA	#001H
		STA	ENWRK0,X	;ATARI
		RTS
PLHIK10		EQU	$
		LDA	ENWRK0,X	;ATARI
		BEQ	PLHIK20
		STZ	ATHKOK		;CLS
		LDA	PYDMBT
		AND	#001H
		BEQ	PLHIK20
		STZ	ENMODE,X
;		STZ	ENWRK0,X
		JSL	>HIMITU
		JSL	>KEMRIST
PLHIK20		EQU	$
		RTS
;========================================
;	PLHIN	MOVE
;========================================
PLHINMV		EQU	$
		PHB
		PHK
		PLB
		JSR	PLHIN00
		PLB
		RTL
;----------------------------------------
PLHIN00		EQU	$
;		LDA	#030H
;		STA	ENFLCL,X
;		JSL	>EN1CSTL
		JSL	>OAMCHKL
		JSR	ENSTCK		; scroll : not return !
		JSL	>WPMSCK
		BCS	PLHIN20
;
		JSL	>CRENPL2L
		BCC	PLHIN10
		LDA	#001H
		STA	ATHKOK
;		LDA	#001H
		STA	ENWRK0,X	;ATARI
		RTS
PLHIN10		EQU	$
		LDA	ENWRK0,X	;ATARI
		BEQ	PLHIN20
		STZ	ATHKOK		;CLS
		LDA	PYDMBT
		AND	#001H
		BEQ	PLHIN20
		LDA	#01FH		;OTO
		JSL	>SDLRE2
		PHX
		JSL	>UGGILWT
		PLX
		JSR	BAKU0ST
		LDA	ENXPSL,X
		STA	ENXPSL,Y
		LDA	ENXPSH,X
		STA	ENXPSH,Y
		LDA	ENYPSL,X
		STA	ENYPSL,Y
		LDA	ENYPSH,X
		STA	ENYPSH,Y
		STZ	ENMODE,X
PLHIN20		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	ONNAA move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;ONNAAIT		EQU	$		; goto BABA1IT
;----------------------------------------
ONNAAMV		EQU	$
		PHB
		PHK
		PLB
		JSR	ONNAA00
		PLB
		RTL
ONNAA00		EQU	$
		LDA	ENSTAT,X
		CMP	#002
		BCS	ONNAA10
		JSR	ONNAACS
ONNAA10		EQU	$
		JMP	YOKO_MV		; goto BABA1MV
;
;
;		JSR	ENSTCK		; scroll : not return !
;;
;		LDA	#LOW  MS_0000		; MSGE NO. SET
;		LYA	#HIGH MS_0000		; MSGE NO. SET
;		JSL	>ENMSGEL	; MEGE ?
;		STA	ENWRK0,X	; PL. miru!
;		STA	ENMUKI,X	; PL. miru!
;		BCC	ONNAA10
;		STZ	ENSTAT,X	; PL. miru!
;;
;ONNAA10		EQU	$
;		JSR	MURAAMV
;;
;		RTS
;--------------------------------------
ONNAACD		EQU	$
		WORD	00000,-0008		;0
		BYTE	026H,000H,000H,002H
		WORD	00000,00000
		BYTE	0E8H,000H,000H,002H
		WORD	00000,-0007
		BYTE	026H,000H,000H,002H
		WORD	00000,00001
		BYTE	0E8H,040H,000H,002H
;
		WORD	00000,-0008		;1
		BYTE	024H,000H,000H,002H
		WORD	00000,00000
		BYTE	0C2H,000H,000H,002H
		WORD	00000,-0007
		BYTE	024H,000H,000H,002H
		WORD	00000,00001
		BYTE	0C2H,040H,000H,002H
;
		WORD	00000,-0008		;2
		BYTE	028H,000H,000H,002H
		WORD	00000,00000
		BYTE	0E4H,000H,000H,002H
		WORD	00000,-0007
		BYTE	028H,000H,000H,002H
		WORD	00000,00001
		BYTE	0E6H,000H,000H,002H
;
		WORD	00000,-0008		;3
		BYTE	028H,040H,000H,002H
		WORD	00000,00000
		BYTE	0E4H,040H,000H,002H
		WORD	00000,-0007
		BYTE	028H,040H,000H,002H
		WORD	00000,00001
		BYTE	0E6H,040H,000H,002H
;
ONNAACS		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 ONNAACD
		STA	<WORK8
		LDA	#HIGH ONNAACD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	HIGEE move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;HIGEEIT	EQU	$		; goto BABA1IT
;--------------------------------------
HIGEEML		EQU	$
		BYTE	LOW  MS_05D0
		BYTE	LOW  MS_05D1
HIGEEMH		EQU	$
		BYTE	HIGH MS_05D0
		BYTE	HIGH MS_05D1
;
HIGEEMV		EQU	$
		PHB
		PHK
		PLB
		JSR	HIGEE00
		PLB
		RTL
HIGEE00		EQU	$
		JSR	HIGEECS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	>ITEMR23
		TAY
		LDA	HIGEEML,Y
		XBA
		LDA	HIGEEMH,Y
		TAY
		XBA
		JSL	>ENMSGEL	; MEGE ?
		RTS
;--------------------------------------
HIGEECD		EQU	$
		WORD	00000,-0008		;1
		BYTE	0C4H,000H,000H,002H
		WORD	00000,00000
		BYTE	0CAH,000H,000H,002H
;
HIGEECS		EQU	$
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW  HIGEECD
		STA	<WORK8
		LDA	#HIGH HIGEECD
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		RTS
;----------------------------------------
;;;HIGEEMV		EQU	$
;;;		PHB
;;;		PHK
;;;		PLB
;;;		JSR	HIGEE00
;;;		PLB
;;;		RTL
;;;HIGEE00		EQU	$
;;;		LDA	ENSTAT,X
;;;		CMP	#002
;;;		BCS	HIGEE10
;;;		JSR	HIGEECS
;;;HIGEE10		EQU	$
;;;		JMP	YOKO_MV		; goto BABA1MV
;;;;
;;;;
;;;;		JSR	ENSTCK		; scroll : not return !
;;;;;
;;;;		LDA	#000H		; MSGE NO. SET
;;;;		JSL	>ENMSGEL	; MEGE ?
;;;;		STA	ENWRK0,X	; PL. miru!
;;;;		STA	ENMUKI,X	; PL. miru!
;;;;		BCC	HIGEE10
;;;;		STZ	ENSTAT,X	; PL. miru!
;;;;		LDA	#009H		;
;;;;		STA	CALFLG
;;;;;
;;;;HIGEE10		EQU	$
;;;;		JSR	MURAAMV
;;;;;
;;;;		RTS
;;;;--------------------------------------
;;;HIGEECD		EQU	$
;;;		WORD	00000,-0008		;0
;;;		BYTE	0C6H,000H,000H,002H
;;;		WORD	00000,00000
;;;		BYTE	0EEH,000H,000H,002H
;;;		WORD	00000,-0007
;;;		BYTE	0C6H,000H,000H,002H
;;;		WORD	00000,00001
;;;		BYTE	0EEH,040H,000H,002H
;;;;
;;;		WORD	00000,-0008		;1
;;;		BYTE	0C4H,000H,000H,002H
;;;		WORD	00000,00000
;;;		BYTE	0CAH,000H,000H,002H
;;;		WORD	00000,-0007
;;;		BYTE	0C4H,000H,000H,002H
;;;		WORD	00000,00001
;;;		BYTE	0CAH,040H,000H,002H
;;;;
;;;		WORD	00000,-0008		;2
;;;		BYTE	0C8H,000H,000H,002H
;;;		WORD	00000,00000
;;;		BYTE	0CCH,000H,000H,002H
;;;		WORD	00000,-0007
;;;		BYTE	0C8H,000H,000H,002H
;;;		WORD	00000,00001
;;;		BYTE	0CEH,000H,000H,002H
;;;;
;;;		WORD	00000,-0008		;3
;;;		BYTE	0C8H,040H,000H,002H
;;;		WORD	00000,00000
;;;		BYTE	0CCH,040H,000H,002H
;;;		WORD	00000,-0007
;;;		BYTE	0C8H,040H,000H,002H
;;;		WORD	00000,00001
;;;		BYTE	0CEH,040H,000H,002H
;;;;
;;;HIGEECS		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 HIGEECD
;;;		STA	<WORK8
;;;		LDA	#HIGH HIGEECD
;;;		ADC	#000H
;;;		STA	<WORK9
;;;;
;;;		JSL	>SETOAML
;;;;
;;;		JSL	>SADWSTL
;;;		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MAJOO move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MAJOOMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MAJOO00
		PLB
		RTL
MAJOO00		EQU	$
		JSR	MAJOOCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENMOD3,X
		PHA
		LDA	#002H
		STA	ENMOD3,X
		JSL	>CRENPL2L
		BCC	MAJOO40
		PHX
		JSL	>PLOTCK
		STZ	<PYSPFG
		JSL	>DASCLR1
		PLX
MAJOO40		EQU	$
		PLA
		STA	ENMOD3,X
;
		LDA	<FRCNT		;E MOVE
		BNE	MAJOO20
		JSL	>RNDSET
		AND	#001H
		CLC
		ADC	#002H
		STA	ENWRK0,X
MAJOO20		EQU	$
		LDA	ENWRK0,X
		STA	<WORK0
		LDA	<FRCNT
MAJOO10		EQU	$
		LSR	A
		DEC	<WORK0
		BPL	MAJOO10
		AND	#007H
		STA	ENCHPT,X
;
;					;CHK
		JSL	>WPMSCK
		BCC	MAJOO50
		RTS
MAJOO50		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MAJOOF0
		WORD	MAJOOF1
;----------------------------------------
MAJOOF1		EQU	$
		STZ	ENSTAT,X
;
		LDY	#018H		;BIN 1 2 3
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
		RTS
;----------------------------------------
MAJOOF0		EQU	$
		STZ	<WORK0		;KINOKO KAUNT 
		LDA	>ITEMR05	;KONA KINOKO
		CMP	#001H
		BNE	MAJOO30
		INC	<WORK0
MAJOO30		EQU	$
;;		LDA	>BINCT0		;BIN 1 KINOKO
;;		CMP	#001H
;;		BNE	MAJOO40
;;		INC	<WORK0
;;MAJOO40		EQU	$
;;		LDA	>BINCT1		;BIN 2 KINOKO
;;		CMP	#001H
;;		BNE	MAJOO50
;;		INC	<WORK0
;;MAJOO50		EQU	$
;;		LDA	>BINCT2		;BIN 3 KINOKO
;;		CMP	#001H
;;		BNE	MAJOO60
;;		INC	<WORK0
;;MAJOO60		EQU	$
		LDA	<WORK0
		JSL	>JSRSUB
		WORD	MAJOOM0
		WORD	MAJOOM1
		WORD	MAJOOM2
		WORD	MAJOOM3
		WORD	MAJOOM4
;----------------------------------------
MAJOOM0		EQU	$
		LDA	>ITEMR05
		CMP	#002H
		BNE	MJOM010
MJOM020		EQU	$
		LDA	#LOW  MS_0090	;MSGE NO
		LDY	#HIGH MS_0090	;MSGE NO
		JSL	>ENMSGEL	;MSGE SET
		RTS
MJOM010		EQU	$
		PHX
		MEM8
		IDX16
		REP	#00010000B
		LDX	#ROOM_POTION*2	;ROOM NO * 2
		LDA	>DJNTBL,X
		MEM8
		IDX8
		SEP	#00110000B
		PLX
		CMP	#000H
		BPL	MJOM020
		LDA	#LOW  MS_0091	;MSGE NO
		LDY	#HIGH MS_0091	;MSGE NO
		JSL	>ENMSGEL	;MSGE SET
		RTS
;
;----------------------------------------
MAJOOM1		EQU	$
MAJOOM2		EQU	$
MAJOOM3		EQU	$
MAJOOM4		EQU	$
		LDA	<KEYA1
		AND	#040H
		BEQ	MJOM130		;USE ITEM
;					;Y
		JSL	>CRENPL2L	;? ATRI
		BCC	MJOM110
;
		LDA	GETITM0
		CMP	#005
		BNE	MJOM110		;? KONA
;;		CMP	#016
;;		BEQ	MJOM140		;? BIN
;;		BRA	MJOM110	
MJOM120		EQU	$
		LDA	>ITEMR05
		CMP	#001H
		BNE	MJOM110		;? KINOKO GET
;					;Y
		JSR	MJKNKCK		;KINOKO CHK.
MJOM110		EQU	$
		RTS
;
MJOM130		EQU	$
		LDA	#LOW  MS_0093	;MSGE NO
		LDY	#HIGH MS_0093	;MSGE NO
		JSL	>ENMSGEL	;MSGE SET
		RTS
;
;;MJOM140		EQU	$
;;		PHX
;;		TAX
;;		LDA	>ITEMR01-1,X
;;		TAX
;;		LDA	>BINCT0-1,X
;;		CMP	#001H
;;		BNE	MJOM130		;? KINOKO GET
;;;					;Y
;;		PLX
;;		JSR	MJKNKC1		;KINOKO CHK.
;;		RTS
;;MJOM130		EQU	$
;;		PLX
;;		RTS
;----------------------------------------
MJKNKCK		EQU	$
		LDA	>ITEMR05	;KONA KINOKO
		CMP	#001H
		BNE	MJKCK10
		LDA	#000H
		STA	>ITEMR05
;
		PHX			;POTION FLG SET
		MEM8
		IDX16
		REP	#00010000B
;
		LDX	#ROOM_POTION*2	;ROOM NO * 2
		LDA	>DJNTBL,X
		ORA	#080H		;POTION 1
		STA	>DJNTBL,X
;
		MEM8
		IDX8
		SEP	#00110000B
		STZ	SOUND2
		JSL	>ITEM0ST	;ITEM PRINT SET
		PLX
;
		LDA	#LOW  MS_0091	;MSGE NO
		LDY	#HIGH MS_0091	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
;
;;		JSL	>SDLRCE		;OTO
;;		ORA	#00DH
;;		STA	SOUND1
		LDA	#0DH
		JSL	>SDLRE1	;(S)
;
MJKCK10		EQU	$
		STZ	SCLSFG		;SCROL FLG CLS
		RTS
;
;;MJKNKC1DT	EQU	$
;;		BYTE	040H,020H,010H
;;MJKNKC1		EQU	$
;;		PHX
;;		LDA	>ITEMR16
;;		TAX
;;;
;;;		LDA	>BINCT0-1,X		;BIN 1 KINOKO
;;;		CMP	#001H
;;;		BNE	MJKC140
;;		LDA	#002H
;;		STA	>BINCT0-1,X
;;;
;;		PHX			;POTION FLG SET
;;		TXY
;;		MEM8
;;		IDX16
;;		REP	#00010000B
;;;
;;		LDX	#ROOM_POTION*2	;ROOM NO * 2
;;		LDA	>DJNTBL,X
;;		ORA	MJKNKC1DT-1,Y	;POTION 2
;;		STA	>DJNTBL,X
;;;
;;		MEM8
;;		IDX8
;;		SEP	#00110000B
;;;		LDY	#018H		;BIN 2
;;;		JSL	>ATMSIT		;PL. DEMO SET
;;		PLX
;;		PLX
;;		LDA	#001
;;		STA	ENSTAT,X
;;;
;;		LDA	#LOW  MS_0091	;MSGE NO
;;		LDY	#HIGH MS_0091	;MSGE NO
;;		JSL	>ENMSGSL	;MSGE SET
;;;
;;MJKC140		EQU	$
;;		STZ	SCLSFG		;SCROL FLG CLS
;;		RTS
ROOM_POTION	EQU	00109H
;---------------------------------------
MAJOCUD		EQU	$
		BYTE	-003,0008,0AEH,000H	;0
		BYTE	-003,0016,0BEH,000H
		BYTE	-002,0008,0AEH,000H	;1
		BYTE	-002,0016,0BEH,000H
		BYTE	-001,0008,0AFH,000H	;2
		BYTE	-001,0016,0BFH,000H
		BYTE	0000,0009,0AFH,000H	;3
		BYTE	0000,0017,0BFH,000H
		BYTE	0001,0010,0AFH,000H	;4
		BYTE	0001,0018,0BFH,000H
		BYTE	0000,0011,0AFH,000H	;5
		BYTE	0000,0018,0BFH,000H
		BYTE	-001,0010,0AEH,000H	;6
		BYTE	-001,0018,0BEH,000H
		BYTE	-003,0009,0AEH,000H	;7
		BYTE	-003,0017,0BEH,000H
MAJOCAD		EQU	$
		BYTE	000H,-004,080H,000H	;ATAMA
		BYTE	-011,00FH,086H,004H	;TUBO
		BYTE	-003,00FH,086H,044H	;TUBO
MAJOCBD		EQU	$
		BYTE	0000,0004,084H,000H
		BYTE	0000,0004,082H,000H
;
MAJOOCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		LDA	ENCHPT,X
		STA	<WORK0
		STZ	<WORK1
;
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		ASL	A
		ASL	A
		ASL	A
		AND	#000FFH
		TAX
		LDY	<OAMADR
;
		LDA	MAJOCUD,X		;UDE SET
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	MAJOCUD+1,X
		CLC
		ADC	ENDSXL+1
		STA	OAM-OAM+1,Y
		LDA	MAJOCUD+2,X
		ORA	<WORK4
		STA	OAM-OAM+2,Y
		LDA	MAJOCUD+4,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+4,Y
		LDA	MAJOCUD+5,X
		CLC
		ADC	ENDSXL+1
		STA	OAM-OAM+5,Y
		LDA	MAJOCUD+6,X
		ORA	<WORK4
		STA	OAM-OAM+6,Y
;
		LDX	#00000H
		LDA	#00002H
		STA	<WORKE
MJOCS10		EQU	$
		LDA	MAJOCAD,X		;ATAMA TUBO SET
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+8,Y
		LDA	MAJOCAD+1,X
		CLC
		ADC	ENDSXL+1
		STA	OAM-OAM+9,Y
		LDA	MAJOCAD+2,X
		EOR	<WORK4
		STA	OAM-OAM+10,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	MJOCS10
;
		LDA	<WORK0
		SEC
		SBC	#00003H
		CMP	#00003H
		BCC	MJOCS20
		LDX	#00000H
		BRA	MJOCS30
MJOCS20		EQU	$
		LDX	#00004H
MJOCS30		EQU	$
;
		LDA	MAJOCBD,X		;KARADA SET
		CLC
		ADC	ENDSXL
		STA	OAM-OAM+8,Y
		LDA	MAJOCBD+1,X		;KARADA SET
		CLC
		ADC	ENDSXL+1
		STA	OAM-OAM+9,Y
		LDA	MAJOCBD+2,X
		ORA	<WORK4
		STA	OAM-OAM+10,Y
;
		LDY	<OSBADR
		LDA	#0000H
		STA	OAMSB-OAMSB,Y
		LDA	#0202H
		STA	OAMSB-OAMSB+2,Y
		STA	OAMSB-OAMSB+4,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#005H
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	KIANA move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KIANAMV		EQU	$
		PHB
		PHK
		PLB
		JSR	KIANA00
		PLB
		RTL
;----------------------------------------
KIANA00		EQU	$
		LDA	ENWRK1,X
		BNE	KIANA10
;
		JSL	>OAMCHKL
		JSR	ENSTCK		; scroll : not return !
;
		JSR	EPXYCK		;pl muki set
		CPY	#002H
		BNE	KIANA10
;
		LDA	ENCRTM,X
		CMP	#YAMOV		;? YAAA ATARI
		BNE	KIANA10
		INC	SWCHFG		;Y
		LDA	#001H
		STA	ENWRK1,X
;		STZ	ENMODE,X
;
KIANA10		EQU	$
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BUBUU move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;BUBUUMV		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR	BUBUU00
;		PLB
		RTL
;BUBUU00		EQU	$
;		JSR	BUBUUCS
;		JSR	ENSTCK		; scroll : not return !
;;
;;
;;		LDA	<KEYA2
;;		AND	#080H
;;		BEQ	BUBUU20
;;		LDA	ENCHPT,X
;;		INC	A
;;		AND	#003H
;;		STA	ENCHPT,X
;;BUBUU20		EQU	$
;;		LDA	<KEYA2
;;		AND	#040H
;;		BEQ	BUBUU30
;;		LDA	ENMUKI,X
;;		INC	A
;;		AND	#003H
;;		STA	ENMUKI,X
;;BUBUU30		EQU	$
;;		RTS
;;
;		JSR	ENHNSB          ; hanekaeri 
;;
;		JSL	>CRKNKNL		; Vs PL ken check
;		JSL	>CRENPLL		; Vs PL body check
;;
;		TXA
;		EOR	<FRCNT
;		AND	#007H
;		BNE	BUBUU10
;                JSL	>ENBGCKL		; BG check sub !
;		LDA	ENCBFG,X
;		AND	#00FH
;		BEQ	BUBUU10
;		LDA	ENMUKI,X
;		EOR	#001H
;		STA	ENMUKI,X
;BUBUU10		EQU	$
;		LDA	ENSTAT,X
;		JSL	>JSRSUB
;		WORD	BUBUUM0		;stop		
;		WORD	BUBUUM1		;move		
;		WORD	BUBUUM2		;yari		
;		WORD	BUBUUM3		;yari nasi		
;;
;;----------------------------------------
;BUBUUM0		EQU	$
;		STZ	ENXSPD,X
;		STZ	ENYSPD,X
;		STZ	ENCHPT,X
;;
;		LDA	ENTIM0,X
;		BNE	BUUM010
;;
;		INC	ENSTAT,X
;;
;		JSL	>RNDSET
;		AND	#003H
;		STA	ENMUKI,X
;;
;		JSL	>RNDSET
;		AND	#01FH
;		CLC
;		ADC	#080H
;		STA	ENTIM0,X
;;
;BUUM010		EQU	$
;		RTS
;;----------------------------------------
;BUUM1SX		EQU	$
;		BYTE	000H,000H,0F3H,00CH
;BUUM1SY		EQU	$
;		BYTE	0F3H,00CH,000H,000H
;BUBUUM1		EQU	$
;		LDY	ENMUKI,X
;		LDA	BUUM1SX,Y
;		STA	ENXSPD,X
;		LDA	BUUM1SY,Y
;		STA	ENYSPD,X
;		JSR	ENMVCL		; xclc,yclc
;;
;		TXA
;		EOR	<FRCNT
;		LSR	A
;		LSR	A
;		LSR	A
;		AND	#001H
;		STA	ENCHPT,X
;		STA	ENZPSL,X
;;
;		LDA	ENTIM0,X
;		BNE	BUUM110
;;
;		INC	ENSTAT,X
;;
;		JSL	>RNDSET
;		AND	#00FH
;		CLC
;		ADC	#010H
;		STA	ENTIM0,X
;;
;BUUM110		EQU	$
;		RTS
;;----------------------------------------
;BUBUUM2		EQU	$
;		STZ	ENXSPD,X
;		STZ	ENYSPD,X
;		LDA	#002H
;		STA	ENCHPT,X
;;
;		LDA 	ENTIM0,X
;		BNE	BUUM210
;;
;		INC	ENSTAT,X
;;
;		JSL	>RNDSET
;		AND	#01FH
;		ADC	#020H
;		STA	ENTIM0,X
;;
;		JSR	BUYTMST		;YATAM ENTRY
;;
;BUUM210		EQU	$
;		RTS
;;----------------------------------------
;BUBUUM3		EQU	$
;		LDA	#003H
;		STA	ENCHPT,X
;;
;		LDA	ENTIM0,X
;		BNE	BUUM310
;;
;		STZ	ENSTAT,X
;		JSL	>RNDSET
;		AND	#00FH
;		CLC
;		ADC	#010H
;		STA	ENTIM0,X
;;
;BUUM310		EQU	$
;		RTS
;;====================			;YATAM
;BUYTMSX		EQU	$
;		BYTE	000H,000H,0E0H,020H
;BUYTMSY		EQU	$
;		BYTE	0E0H,020H,000H,000H
;BUYTMST		EQU	$
;		LDA	#YATAM
;		JSL	>ENIDSH
;		BMI	BUYTS80
;		PHX
;		LDA	ENMUKI,X
;		STA	ENMUKI,Y
;		TAX
;;
;;;		LDA	ENMOD3,Y
;;;		AND	#0F0H
;		LDA	YACRDT,X
;		STA	ENMOD3,Y
;;
;		LDA	<WORK0
;		CLC
;		ADC	BUUYAX,X
;		STA	ENXPSL,Y
;		LDA	<WORK1
;		ADC	BUUYAXH,X
;		STA	ENXPSH,Y
;		LDA	<WORK2
;		CLC
;		ADC	BUUYAY,X
;		STA	ENYPSL,Y
;		LDA	<WORK3
;		ADC	BUUYAYH,X
;		STA	ENYPSH,Y
;		LDA	<WORK4
;		STA	ENZPSL,Y
;;
;		LDA	BUYTMSX,X
;		STA	ENXSPD,Y
;		LDA	BUYTMSY,X
;		STA	ENYSPD,Y
;;
;		PLX
;BUYTS80		EQU	$
;		RTS
;;----------------------------------------
;BUUYAY          EQU     $
;                BYTE    0002,0002,0006,0006
;;
;BUUYAYH         EQU     $
;                BYTE    0000,0000,0000,0000
;;
;BUUYAX          EQU     $
;                BYTE    -003,0011,0002,-002
;;
;BUUYAXH         EQU     $
;                BYTE    -001,0000,0000,-001
;;
;;--------------------------------------
;BUBUUCD		EQU	$
;		BYTE	0000,-008,044H,000H		;0
;		BYTE	0000,0000,060H,000H
;		BYTE	-003,0000,052H,080H
;		BYTE	-003,0008,042H,080H
;;
;		BYTE	0000,-008,044H,000H
;		BYTE	0000,0000,060H,040H
;		BYTE	-002,0002,052H,080H
;		BYTE	-002,0010,042H,080H
;;
;		BYTE	0002,0002,041H,080H
;		BYTE	0000,-008,044H,000H
;		BYTE	0000,0000,04EH,000H
;		BYTE	-006,-006,040H,080H
;;
;		BYTE	0000,-008,044H,000H
;		BYTE	0000,0000,060H,000H
;		BYTE	0004,0003,08EH,000H;D
;		BYTE	0000,-008,084H,000H;D
;;
;;
;;
;		BYTE	0011,0007,052H,000H		;1
;		BYTE	0000,-008,046H,000H
;		BYTE	0000,0000,04CH,040H
;		BYTE	0004,0003,08BH,000H;D
;;
;		BYTE	0011,0009,052H,000H
;		BYTE	0000,-008,046H,000H
;		BYTE	0000,0000,04CH,000H
;		BYTE	0004,0003,08AH,040H;D
;;
;		BYTE	0012,0001,040H,040H
;		BYTE	0000,-008,046H,000H
;		BYTE	0000,0000,04AH,000H
;		BYTE	0004,0002,065H,000H;D
;;
;		BYTE	0000,-008,046H,000H
;		BYTE	0000,0000,04CH,000H
;		BYTE	0004,0003,08AH,040H;D
;		BYTE	0000,-008,084H,000H;D
;;
;;
;;
;		BYTE	-001,0007,050H,000H		;2
;		BYTE	0007,0007,051H,000H
;		BYTE	0000,-008,048H,000H
;		BYTE	0000,0000,066H,000H
;;
;		BYTE	-004,0005,050H,000H
;		BYTE	0004,0005,051H,000H
;		BYTE	0000,-008,048H,000H
;		BYTE	0000,0000,064H,000H
;;
;		BYTE	0002,-002,050H,000H
;		BYTE	0010,-002,051H,000H
;		BYTE	0000,-008,048H,000H
;		BYTE	0000,0000,062H,000H
;;
;		BYTE	0000,-008,048H,000H
;		BYTE	0000,0000,064H,000H
;		BYTE	0004,0003,08EH,000H;D
;		BYTE	0000,-008,084H,000H;D
;;
;;
;;
;		BYTE	0001,0007,051H,040H		;3
;		BYTE	0009,0007,050H,040H
;		BYTE	0000,-008,048H,040H
;		BYTE	0000,0000,066H,040H
;;
;		BYTE	0004,0005,051H,040H
;		BYTE	0012,0005,050H,040H
;		BYTE	0000,-008,048H,040H
;		BYTE	0000,0000,064H,040H
;;
;		BYTE	-002,-002,051H,040H
;		BYTE	0006,-002,050H,040H
;		BYTE	0000,-008,048H,040H
;		BYTE	0000,0000,062H,040H
;;
;		BYTE	0000,-008,048H,040H
;		BYTE	0000,0000,064H,040H
;		BYTE	0004,0003,08EH,040H;D
;		BYTE	0000,-008,084H,040H;D
;;
;;
;;
;BUBUUKD		EQU	$
;		BYTE	003H,003H,003H,001H		;KAZU
;		BYTE	002H,002H,002H,001H
;		BYTE	003H,003H,003H,001H
;		BYTE	003H,003H,003H,001H
;;
;;
;;
;BUBUUSD		EQU	$
;		BYTE	002H,002H,000H,000H		;OAMSB
;		BYTE	002H,002H,000H,000H
;		BYTE	000H,002H,002H,000H
;		BYTE	002H,002H,000H,000H
;;
;		BYTE	000H,002H,002H,000H
;		BYTE	000H,002H,002H,000H
;		BYTE	000H,002H,002H,000H
;		BYTE	002H,002H,000H,000H
;;
;		BYTE	000H,000H,002H,002H
;		BYTE	000H,000H,002H,002H
;		BYTE	000H,000H,002H,002H
;		BYTE	002H,002H,000H,000H
;;
;		BYTE	000H,000H,002H,002H
;		BYTE	000H,000H,002H,002H
;		BYTE	000H,000H,002H,002H
;		BYTE	002H,002H,000H,000H
;;
;BUBUUCS		EQU	$
;		JSR	OAMCHK
;;
;		LDA	ENMUKI,X
;		ASL	A
;		ASL	A
;		ADC	ENCHPT,X
;		TAY
;		LDA	BUBUUKD,Y
;		STA	<WORKD		;KAZU OBOERU
;		STA	<WORKE
;		STZ	<WORKF
;;
;		LDA	ENMUKI,X
;		STA	<WORK1
;		STZ	<WORK0
;		LDA	ENCHPT,X
;		STA	<WORK2
;		STZ	<WORK3
;;
;		PHX
;		MEM16
;		IDX16
;		REP	#00110000B
;;
;		LDA	<WORK0
;		ASL	A
;		ASL	A
;		ADC	<WORK2
;		ASL	A
;		ASL	A
;		STA	<WORK6
;		ASL	A
;		ASL	A
;		TAY
;;
;		LDX	<OAMADR
;;
;BUBUUC1		EQU	$
;		LDA	BUBUUCD,Y
;		CLC
;		ADC	ENDSXL
;		STA	<OAM-OAM,X
;		INX
;		INX
;		INY
;		INY
;		LDA	BUBUUCD,Y
;		ORA	<WORK4
;		STA	<OAM-OAM,X
;		INX
;		INX
;		INY
;		INY
;		DEC	<WORKE
;		BPL	BUBUUC1
;;
;		LDY	<WORK6
;;
;		LDX	<OSBADR
;		LDA	BUBUUSD,Y
;		STA	<OAMSB-OAMSB,X
;		LDA	BUBUUSD+2,Y
;		STA	<OAMSB-OAMSB+2,X
;;
;		MEM8
;		IDX8
;		SEP	#00110000B
;		PLX
;;
;		JSL	>SADWSTL		;KAGE SET
;;
;		LDA	<WORKD
;		LDY	#0FFH
;		JSL	>ALOMCKL
;		RTS
;;
;----------------------------------------
ENXSDN		EQU	$
		LDA	ENXSPD,X
		BEQ	ENXDN10
;
		BPL	ENXDN20
		INC	A
		BRA	ENXDN10
ENXDN20		EQU	$
		DEC	A
ENXDN10		EQU	$
		STA	ENXSPD,X
		RTL
;---------------------------------------
ENYSDN		EQU	$
		LDA	ENYSPD,X
		BEQ	ENYDN10
;
		BPL	ENYDN20
		INC	A
		BRA	ENYDN10
ENYDN20		EQU	$
		DEC	A
ENYDN10		EQU	$
		STA	ENYSPD,X
		RTL
;---------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BABA1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BABA1IT		EQU	$
HIGEEIT		EQU	$
ONNAAIT		EQU	$
		PHB
		PHK
		PLB
		JSR	BABA100_I
		PLB
		RTL
BABA100_I	EQU	$
		LDA	#002H
		STA	ENMUKI,X
		STA	ENCMKI,X
;
		INC	ENNOCR,X	; beem thru
;
		LDA	ENXPSL,X
		STA	ENWRK0,X
		LDA	ENXPSH,X
		STA	ENWRK1,X
;
		LDA	#-009
		STA	ENXSPD,X
		RTS
;----------------------------------------
BABA1MV		EQU	$
		PHB
		PHK
		PLB
		JSR	BABA100
		PLB
		RTL
BABA1SX		EQU	$
		BYTE	000,000,-09,009
BABA1SY		EQU	$
		BYTE	-09,009,000,000
BABA100		EQU	$
		LDA	HEMODE,X
		BEQ	BA0000
;
		JSL	>BABACK
;
;;;;;		JSL	>ENPLATR
		RTS
;
BA0000		EQU	$
		LDA	ENSTAT,X
		CMP	#003
		BCS	BABA150
		JSL	>BABA1CS
BABA150		EQU	$
YOKO_MV		EQU	$
		JSR	ENSTCK		; scroll : not return !
		LDA	ENSTAT,X
		CMP	#003
		BCS	BABA110
		LDA	<DJFLG
		BEQ	BABA140
;----------------------------------------
		JSL	>ENMKIST	;MUKI SET	;ROOM IN
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	#LOW  MS_0120	; MSGE NO. SET
		LDY	#HIGH MS_0120	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		RTS
;----------------------------------------
BABA140		EQU	$				;ROOM OUT
		LDA	ENSTAT,X
		BNE	BABA160
;
		JSL	>CRENPL2L
		BCS	BABA120
;
BABA160		EQU	$
		JSL	>ENMKIST	;MUKI SET
		BCC	BABA130
;
		JSR	ENMVCL		; xclc,yclc
;
BABA110		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BABA1M1
		WORD	BABA1M0
		WORD	BABA1M2
		WORD	BABA1M3
;
;
BABA120		EQU	$
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENMUKI,X
;
BABA130		EQU	$
		LDA	#001H		;
		STA	ENTIM0,X
		BRA	BABA110
;----------------------------------------
BB1M1DT		EQU	$
		BYTE	0E0H,020H
BB1M1DH		EQU	$
		BYTE	0FFH,000H
;
BABA1M1		EQU	$
		LDA	ENTIM0,X
		BNE	BB1M110
;
		LDY	ENWRK2,X
		LDA	ENWRK0,X
		CLC
		ADC	BB1M1DT,Y
		CMP	ENXPSL,X
		BNE	BB1M110
		LDA	ENWRK0,X
		CLC
		ADC	BB1M1DT,Y
		LDA	ENWRK1,X
		ADC	BB1M1DH,Y
		CMP	ENXPSH,X
		BNE	BB1M110
;
		LDA	ENMUKI,X	;MUKI SET
		EOR	#001H
		STA	ENCMKI,X
;
		TAY
		LDA	BABA1SX,Y	;SPEED SET
		STA	ENXSPD,X
		LDA	BABA1SY,Y
		STA	ENYSPD,X
;
		LDA	ENWRK2,X
		EOR	#001H
		STA	ENWRK2,X
;
BB1M110		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		LDA	ENMOD3,X
		PHA
		LDA	#003H		;#007H
		STA	ENMOD3,X
		LDA	#LOW  MS_0060	; MSGE NO. SET
		LDY	#HIGH MS_0060	; MSGE NO. SET
		JSL	>ENMSG2L	; MEGE ?
		TAY
		PLA
		STA	ENMOD3,X
		BCC	BB1M120	
		TYA	;
		STA	ENMUKI,X	; PL. miru!
;		STA	ENCMKI,X	; PL. miru!
;
		JSL	>HEICAL		; Hishi call !
;
		INC	ENSTAT,X	;NEXT MOVE
;
BB1M120		EQU	$
		RTS
;----------------------------------------
BABA1M0		EQU	$
		STZ	ENCMKI,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	BB1M010
		INC	ENSTAT,X	;Y
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		LDA	#002H
		STA	ENMOD3,X	;OBJ hit hani !
;
		LDA	ESXPSL,Y
		STA	<WORK2
		LDA	ESXPSH,Y
		STA	<WORK3
		PHX
		MEM16
		IDX16			; DOOR OPEN SET
		REP	#00110000B
		LDA	<WORK0		;Y POS
		SEC
		SBC	GCCKY0
		AND	GCCKY1
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK4
		LDA	<WORK2
		LSR	A
		LSR	A
		LSR	A
		SEC
		SBC	GCCKX0
		AND	GCCKX1
		CLC
		ADC	<WORK4
		TAX
		CLC			;DOOR OPEN FLG
		JSL	>MKDRPLY
		MEM8
		IDX8
		PLX
		LDA	#010H
		STA	ENTIM0,X
		RTS
;
BB1M010		EQU	$
		LDA	#001H
		STA	PYALSP		;PL. STOP
		LDA	ESXPSL,Y	;SERCH POINT SET
		STA	<WORK4
		LDA	ESXPSH,Y
		STA	<WORK5
		LDA	ESYPSL,Y
		STA	<WORK6
		LDA	ESYPSH,Y
		STA	<WORK7
;
		LDA	#040H		;SERCH SPEED SET
		JSL	>ESERCHL	;SERCH
;
		LDA	<WORK0		;SPEED SET
		STA	ENYSPD,X
		LDA	<WORK1
		STA	ENXSPD,X
;
		STZ	ENMUKI,X
		STZ	ENCMKI,X
		TXA			;
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		RTS
;----------------------------------------
BABA1M2		EQU	$
		LDA	ENTIM0,X
		BNE	BB1M210
		LDY	!DOORID
;
		LDA	ESYPSL,Y
		STA	ENYPSL,X
		STA	<WORK0
		LDA	ESYPSH,Y
		STA	ENYPSH,X
		STA	<WORK1
		LDA	ESXPSL,Y
		STA	ENXPSL,X
		STA	<WORK2
		LDA	ESXPSH,Y
		STA	ENXPSH,X
		STA	<WORK3
		PHX
		MEM16
		IDX16			; DOOR CLOSE SET
		REP	#00110000B
		LDA	<WORK0		;Y POS
		SEC
		SBC	GCCKY0
		AND	GCCKY1
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK4
		LDA	<WORK2
		LSR	A
		LSR	A
		LSR	A
		SEC
		SBC	GCCKX0
		AND	GCCKX1
		CLC
		ADC	<WORK4
		TAX
		SEC			;DOOR CLOSE FLG
		JSL	>MKDRPLY
		MEM8
		IDX8
		PLX
		INC	ENSTAT,X
BB1M210		EQU	$
		JSR	ENMVCL		; xclc,yclc
		RTS
;----------------------------------------
BABA1M3		EQU	$
;		JSR	OAMCHK
;
;		LDA	ENMOD5,X	;HUKKU ATARI
;		ORA	#020H
;		STA	ENMOD5,X
;
;		JSL	>CRENPL2L
;		BCC	BB1M310
;
;		MEM16
;		REP	#00100000B
;
;		LDA	PLSVX1		;PL. POS. recover
;		STA	<PLXPS1
;		LDA	PLSVY1
;		STA	<PLYPS1
;
;		MEM8
;		SEP	#00110000B
;
;		STZ	<PYSPFG		;DASH STOP
;		STZ	DASHFG
;
BB1M310		EQU	$
		STZ	ENMODE,X	;KILL I
		STZ	PYALSP		;PL. MOVE
		RTS
;--------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	BOUSI move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BOUSIIT		EQU	$
		PHB
		PHK
		PLB
		JSR	BOUSI00_I
		PLB
		RTL
BOUSI00_I	EQU	$
		LDA	#002H
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		INC	ENNOCR,X	; beem thru
;
		RTS
;========================================
BOUSIMV		EQU	$
		PHB
		PHK
		PLB
		JSR	BOUSI00
		PLB
		RTL
;========================================
BOUSISX		EQU	$
		BYTE	000,000,-54,054
BOUSISY		EQU	$
		BYTE	-54,054,000,000
;
BOUSI00		EQU	$
;
		JSR	BOUSICS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENMKIST	;MUKI SET
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	#0FFH
		STA	HEMODE,X
		JSR	ENBGCK
;
		LDA	ENMOD3,X
		PHA
		LDA	#007H
		STA	ENMOD3,X
		JSL	>CRENPL2L
		BCC	BOUSI10
		LDA	ENSTAT,X
		STA	ENWRK2,X	;ENSTAT SAVE
		LDA	#003H		;MSGE MODE
		STA	ENSTAT,X
BOUSI10		EQU	$
		PLA
		STA	ENMOD3,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BOUSIM0
		WORD	BOUSIM1
		WORD	BOUSIM2
		WORD	BOUSIM3
;========================================
BUSISX0		EQU	$-2
		BYTE	-24,024
;
BOUSIM0		EQU	$
		JSL	>ENMKIST	;MUKI SET
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		JSL	>CRENPL2L
		BCC	BUIM010
;
		JSL	>DASCLR1
;
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENMUKI,X
		EOR	#001H
		ORA	#002H
		STA	ENCMKI,X
		TAY
		AND	#001H
		INC	A
		STA	ENSTAT,X
;
		LDA	BUSISX0,Y
		STA	ENXSPD,X
;
		LDA	#020H		;TIME SET
		STA	ENTIM0,X
;
		RTS
;
BUIM010		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
		RTS
;========================================
;BUIM1TD		EQU	$
;		BYTE	080H,080H,080H
;
;
;
;BUIM1MD		EQU	$
;		BYTE	002H,002H,002H
;		BYTE	0FFH
;
;
;
;
BUIM120		EQU	$
BUIM220		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		JSR	ENMVCL		; xclc,yclc
		RTS
;
BOUSIM1		EQU	$
		LDA	ENTIM0,X
		BNE	BUIM120
		JSR	BOUSIMS
;
;		LDA	#000H
;		STA	ENCONT,X
;BUIM110		EQU	$
;		JSR	BUIM1SB
;		BRA	BUIM1SB
;		DEC	ENCONT,X
;		BPL	BUIM110
;		RTS
;
BUIM1SB		EQU	$
		JSR	BOUSISS		;SPEED SET
;
		LDA	ENWRK0,X	;? TIMER
		BNE	BI1SB10
;
;		LDY	ENWRK1,X	;NEXT TIME & MUKI SET
;		INC	ENWRK1,X
		LDA	#0FFH		;BUIM1TD,Y
		STA	ENWRK0,X
		LDA	#002H		;BUIM1MD,Y
		STA	ENCMKI,X
		RTS
;
;
BI1SB10		EQU	$
		DEC	ENWRK0,X	;TIMER DEC
		RTS
;
BI1SB20		EQU	$		;NEXT MODE
		STZ	ENSTAT,X
		STZ	ENCONT,X
		RTS
;========================================
BUIM2TD		EQU	$
		BYTE	078H,018H,080H

;
;
BUIM2MD		EQU	$
		BYTE	003H,001H,003H
		BYTE	0FFH
;
;
;
;
BOUSIM2		EQU	$
		LDA	ENTIM0,X
		BNE	BUIM220
		JSR	BOUSIMS
;
;		LDA	#000H
;		STA	ENCONT,X
;BUIM210		EQU	$
;		JSR	BUIM2SB
;		DEC	ENCONT,X
;		BPL	BUIM210
;		RTS
;
;
BUIM2SB		EQU	$
		JSR	BOUSISS		;SPEED SET
;
		LDA	ENWRK0,X	;? TIMER
		BNE	BI1SB10
;
		LDY	ENWRK1,X	;NEXT TIME & MUKI SET
		INC	ENWRK1,X
		LDA	BUIM2TD,Y
		STA	ENWRK0,X
		LDA	BUIM2MD,Y
		BMI	BI1SB20
		STA	ENCMKI,X
		RTS
;
;
;========================================
BOUSIM3		EQU	$
		LDA	#LOW  MS_01A0		; MSGE NO. SET
		LDY	#HIGH MS_01A0		; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		BCC	BUIM310
		STA	ENMUKI,X
BUIM310		EQU	$
		LDA	ENWRK2,X
		STA	ENSTAT,X
		RTS
;========================================
BOUSIMS		EQU	$		;E SET
		JSL	>ASZNZST	;KEMURI SET
		LDA	<FRCNT
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		RTS
;========================================
BOUSISS		EQU	$		;SPEED SET
		LDY	ENCMKI,X
		LDA	BOUSISX,Y
		STA	ENXSPD,X
		LDA	BOUSISY,Y
		STA	ENYSPD,X
;
		JSR	ENMVCL		; xclc,yclc
		RTS
;========================================
BOUSICD		EQU	$
		WORD	00000,-0008		;0
		BYTE	02CH,000H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,008H,000H,002H
		WORD	00000,-0007
		BYTE	02CH,000H,000H,002H
		WORD	00000,00001
		BYTE	0EEH,048H,000H,002H
;
		WORD	00000,-0008		;1
		BYTE	02AH,000H,000H,002H
		WORD	00000,00000
		BYTE	0CAH,008H,000H,002H
		WORD	00000,-0007
		BYTE	02AH,000H,000H,002H
		WORD	00000,00001
		BYTE	0CAH,048H,000H,002H
;
		WORD	00000,-0008		;2
		BYTE	02EH,000H,000H,002H
		WORD	00000,00000
		BYTE	0CCH,008H,000H,002H
		WORD	00000,-0007
		BYTE	02EH,000H,000H,002H
		WORD	00000,00001
		BYTE	0CEH,008H,000H,002H
;
		WORD	00000,-0008		;3
		BYTE	02EH,040H,000H,002H
		WORD	00000,00000
		BYTE	0CCH,048H,000H,002H
		WORD	00000,-0007
		BYTE	02EH,040H,000H,002H
		WORD	00000,00001
		BYTE	0CEH,048H,000H,002H
;
BOUSICS		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 BOUSICD
		STA	<WORK8
		LDA	#HIGH BOUSICD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		RTS
;--------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SYOBY move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYOBYIT		EQU	$
;;		PHB
;;		PHK
;;		PLB
;;		JSR	SYOBY00_I
;;		PLB
;;		RTL
;;SYOBY00_I	EQU	$
;;		INC	ENNOCR,X	;beem thru
;;		RTS
;----------------------------------------
SYOBYMV		EQU	$
		PHB
		PHK
		PLB
		JSR	SYOBY00
		PLB
		RTL
SYOBY00		EQU	$
;
		JSR	SYOBYCS
		LDA	<WORK3
		ORA	<WORK1
		STA	ENWRK0,X
		JSR	ENSTCK		; scroll : not return !
		JSL	>YABAACK
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		JSL	>WPMSCK
		BCC	SYOBY50
		RTS
SYOBY50		EQU	$
;
		JSL	>RNDSET
		BNE	SYOBY30
		LDA	#001H
		STA	ENCHPT,X
		LDA	#014H
		STA	ENTIM0,X
SYOBY30		EQU	$
		LDA	ENTIM0,X
		BNE	SYOBY40
		STZ	ENCHPT,X
SYOBY40		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	SYOBYM0
		WORD	SYOBYM1
		WORD	SYOBYM2
		WORD	SYOBYM3
		WORD	SYOBYM4
;
SYOBY20		EQU	$
		LDA	#LOW  MS_0363		; MSGE NO. SET
		LDY	#HIGH MS_0363		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		RTS
;----------------------------------------
SYOBYM0		EQU	$
		LDA	ENWRK0,X
		BNE	SOYM010
;
		LDA	ENWRK3,X
		BEQ	SOYM010
		LDA	#003H
		STA	ENSTAT,X
		RTS
;
SOYM010		EQU	$
		LDA	>MODTBL4
		AND	#002H
		BNE	SYOBY20
;
		LDA	#LOW  MS_0360		; MSGE NO. SET
		LDY	#HIGH MS_0360		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BCC	SOBM020
		INC	ENSTAT,X
SOBM020		EQU	$
		RTS
;----------------------------------------
SYOBYM1		EQU	$
		LDA	MSG_RTS
		BNE	SOBM110
;
		MEM16
		IDX8
		REP	#00100000B
		LDA	>CONCNT			;? OKANE HIKERU
		CMP	#00100
		MEM8
		IDX8
		SEP	#00110000B
		BCC	SOBM110
		LDA	#LOW  MS_0361		; MSGE NO. SET
		LDY	#HIGH MS_0361		; MSGE NO. SET
		JSL	>ENMSGSL
		INC	ENSTAT,X
		RTS
;
SOBM110		EQU	$
		LDA	#LOW  MS_0362		; MSGE NO. SET
		LDY	#HIGH MS_0362		; MSGE NO. SET
		JSL	>ENMSGSL
		STZ	ENSTAT,X
		RTS
;----------------------------------------
SYOBYM2		EQU	$
		LDY	#016H
		STZ	!ITMVFG
		PHX
		JSL	>ATMSIT			;PL. DEMO BIN SET
		PLX
		LDA	>MODTBL4		;SAVE RAM SET
		ORA	#002H
		STA	>MODTBL4
		MEM16
		IDX8
		REP	#00100000B
		LDA	>CONCNT			;OKANE HIKU
		SEC
		SBC	#00100
		STA	>CONCNT
		MEM8
		IDX8
		SEP	#00110000B
		STZ	ENSTAT,X
		RTS
;----------------------------------------
SYOBYM3		EQU	$
		LDA	ENWRK3,X
		BMI	SOYM310
;
		LDA	#LOW  MS_0364		; MSGE NO. SET
		LDY	#HIGH MS_0364		; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		INC	ENSTAT,X
		RTS
;
;
SOYM310		EQU	$
		LDA	#LOW  MS_0365		; MSGE NO. SET
		LDY	#HIGH MS_0365		; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		INC	ENSTAT,X
		RTS
;----------------------------------------
SYOBYM4		EQU	$
		LDY	ENWRK3,X
		BMI	SOYM410
		DEY
		LDA	#000H
		STA	ENMODE,Y
		JSL	>R100
		STZ	ENWRK3,X
		STZ	ENSTAT,X
		RTS
;
;
SOYM410		EQU	$
		TYA
		AND	#00FH
		TAY
		LDA	#000H
		STA	ENMODE,Y
		JSL	>YABAAST
		STZ	ENWRK3,X
		STZ	ENSTAT,X
		RTS
;
;----------------------------------------
SYOBYCD		EQU	$
		WORD	00000,-0007
		BYTE	0ACH,000H,000H,002H
		WORD	00000,00000
		BYTE	088H,000H,000H,002H
;
		WORD	00000,-0006
		BYTE	0ACH,000H,000H,002H
		WORD	00000,00000
		BYTE	0A2H,000H,000H,002H
;
SYOBYCS		EQU	$
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW SYOBYCD
		STA	<WORK8
		LDA	#HIGH SYOBYCD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		RTS
;--------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	HELP0 move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HELP0IT		EQU	$
		PHB
		PHK
		PLB
		JSR	HELP000_I
		PLB
		RTL
HELP000_I	EQU	$
		LDA	>ITMTBL6	;? MASTER KATANA
		CMP	#002H
		BCS	HELP015_I
;
		INC	ENNOCR,X	; beem thru
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		LDA	>OPMODE		;CHAR SET
		PHA
		LDA	#prnce
		STA	>OPMODE
		PHX
		JSL	>OPTCBFST
		PLX
		PLA
		STA	>OPMODE
;
		LDA	<RMXYCT
		CMP	#012H
		BNE	HELP020_I
;----------------------------------------
;					;KYOKAI
		LDA	#002H		;MODE SET
		STA	ENCONT,X
;
		LDA	>MODTBL1
		AND	#004H
		BNE	HELP010_I
HELP015_I	EQU	$
		STZ	ENMODE,X
		RTS
HELP010_I	EQU	$
		LDA	ENYPSL,X	;Y POS HOSEI
		CLC
		ADC	#00FH
		STA	ENYPSL,X
		LDA	ENYPSH,X
		ADC	#000H
		STA	ENYPSH,X
		LDA	ENXPSL,X
		CLC
		ADC	#006H
		STA	ENXPSL,X
		LDA	#003H
		STA	ENMOD3,X
		RTS
;----------------------------------------
HELP020_I	EQU	$		;ROUYA
		LDA	#000H		;MODE SET
		STA	ENCONT,X
;
		LDA	>OPMODE
		CMP	#prnce
		BEQ	HELP023_I
		LDA	>MODTBL1
		AND	#004H
		BEQ	HELP025_I
HELP023_I	EQU	$
		STZ	ENMODE,X
HELP025_I	EQU	$
		RTS
;----------------------------------------
HELP0ST		EQU	$		;KYOKAI PL. SET
		LDA	#HELP0
		JSL	>ENIDSH
;
		PHX
		LDX	OPINDX		;INDEX GET
;
		LDA	OPMUKI,X	;MUKI GET
		AND	#003H
;
		STA	ENCMKI,Y	;MUKI SET
		STA	ENMUKI,Y
;
		LDA	<PLYPS1		;Y POS SET
		STA	ENYPSL,Y
		LDA	<PLYPS0
		STA	ENYPSH,Y
;
		LDA	<PLXPS1		;X POS SET
		STA	ENXPSL,Y
		LDA	<PLXPS0
		STA	ENXPSH,Y
;
		LDA	#001H		;MODE SET
		STA	ENCONT,Y
;
		LDA	#nashi
		STA	>OPMODE		;PL. HELP0 CLS
		LDA	ENNOCR,Y	; beem thru
		INC	A
		STA	ENNOCR,Y
		LDA	#003H
		STA	ENMOD3,Y
		PLX
		RTS
;
;----------------------------------------
HELP0SX		EQU	$
		BYTE	000,000,-09,009
HELP0SY		EQU	$
		BYTE	-09,009,000,000
;
HELP0MV		EQU	$
		PHB
		PHK
		PLB
		JSR	HELP000
		PLB
		RTL
HELP000		EQU	$
;
		JSL	>HELP0CS
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		JSL	>ENMKIST	;MUKI SET
		BCC	HELP010
		JSR	ENMVCL		; xclc,yclc
HELP010		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	HELP0F0		;ROUYA MODE
		WORD	HELP0F1		;HELP MODE
		WORD	HELP0F2		;SINPU & MODE
;----------------------------------------
HELP0F0		EQU	$
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HP0F0M0		;MOVE
		WORD	HP0F0M1		;
		WORD	HP0F0M2		;
		WORD	HP0F0M3		;
		WORD	HP0F0M4		;
;----------------------------------------
HP0F0M0		EQU	$
		JSL	>CRENPL2L
		BCC	HF0M010
;
		INC	ENSTAT,X	;NEXT MODE
;
		INC	PYALSP		;PL. STOP
;
		LDY	ENCMKI,X
		LDA	HELP0SX,Y	;SPEED SET
		STA	ENXSPD,X
		LDA	HELP0SY,Y
		STA	ENYSPD,X
;
		LDA	#010H		;TIME SET
		STA	ENTIM0,X
;
HF0M010		EQU	$
		RTS
;----------------------------------------
HP0F0M1		EQU	$
		LDA	ENTIM0,X
		BNE	HF0M110
;
		INC	ENSTAT,X	;NEXT MODE
;
		LDA	#LOW  MS_0040
		LDY	#HIGH MS_0040
		JSL	>ENMSGSL	;MSGE SET
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		LDA	#019H		;OTO
		STA	SOUND0
;// 03.09.16 //		STA	SVSND0
;
HF0M110		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		RTS
;----------------------------------------
HP0F0M2		EQU	$
		INC	ENSTAT,X	;NEXT MODE
;
		LDA	#LOW  MS_0049
		LDY	#HIGH MS_0049
		JSL	>ENMSGSL	;MSGE SET
;
		RTS
;----------------------------------------
HP0F0M3		EQU	$
		LDA	MSG_RTS		;MSGE YES OR NO
		BNE	H00M210
;
		LDA	#LOW  MS_0048
		LDY	#HIGH MS_0048
		JSL	>ENMSGSL	;MSGE SET
;
		INC	ENSTAT,X
;
		RTS
;
H00M210		EQU	$
		LDA	#002H
		STA	ENSTAT,X
		RTS
;----------------------------------------
HP0F0M4		EQU	$
		STZ	PYALSP		;PL. MOVE OK
;
		LDA	#002H
		STA	>MODTBL3
		JSL	>DIECSET
		LDA	#prnce		;PL. HELP0 MODE
		STA	>OPMODE
;
		PHX
		JSL	>MPBTSET1	; 
		JSL	>RAOPIT1		;PL. OPTION INIT
;		JSL	>DTSAVE		;DATA SAVE
		PLX
		STZ	ENMODE,X	;KILL I
;
		LDA	#010H		;OTO
		STA	SOUND0
;// 03.09.16 //		STA	SVSND0
;
		RTS
;----------------------------------------
HELP0F1		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	HP0F1M0		;MOVE
		WORD	HP0F1M1		;
		WORD	HP0F1M2		;
;----------------------------------------
H0F1M0T		EQU	$
		BYTE	026H,01AH,02CH,001H
H0F1M0M		EQU	$
		BYTE	001H,003H,001H,002H
;
HP0F1M0		EQU	$
		LDA	ENTIM0,X
		BNE	HF1M010
;
		LDY	ENWRK0,X	;MODE SET
		CPY	#004H
		BCC	HF1M020
;
		INC	ENSTAT,X	;NEXT MODE
;
		STZ	ENMUKI,X	;MUKI SET
		STZ	ENCMKI,X
;
		STZ	ENXSPD,X	;SPEED OFF
		STZ	ENYSPD,X
;
		RTS
HF1M020		EQU	$
;
		LDA	H0F1M0T,Y	;NEXT TIME SET
		STA	ENTIM0,X
;
		LDA	H0F1M0M,Y	;NEXT MUKI SET
		STA	ENCMKI,X
		STA	ENMUKI,X
;
		INC	ENWRK0,X	;NEXT SET
;
		TAY
		LDA	HELP0SX,Y	;SPEED SET
		STA	ENXSPD,X
		LDA	HELP0SY,Y
		STA	ENYSPD,X
;
HF1M010		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
		RTS
;----------------------------------------
HP0F1M1		EQU	$
		LDA	#LOW  MS_0041	;MSGE NO
		LDY	#HIGH MS_0041	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
;
		INC	ENSTAT,X
;
		LDA	#002H		;SINPU MSGE GO
		STA	>KRXBUF+1
;
		LDA	#001H
		STA	>MODTBL3
		JSL	>DIECSET
		LDA	#002H		;RAIN UP SET
		STA	>MODTBL0
;
		PHX
		JSL	>ROBJCST
;		JSL	>DTSAVE		;DATA SAVE
		PLX
;
		RTS
;----------------------------------------
HP0F1M2		EQU	$
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	#LOW  MS_0042	;MSGE NO
		LDY	#HIGH MS_0042	;MSGE NO
		JSL	>ENMSGEL	;MSGE SET
		BCC	H01M210
;
		STA	ENMUKI,X	;MUKI SET
		STA	ENCMKI,X
;
H01M210		EQU	$
;
		RTS
;----------------------------------------
HL0F2ML		EQU	$
		BYTE	LOW  MS_0042
		BYTE	LOW  MS_004A
		BYTE	LOW  MS_004B
HL0F2MH		EQU	$
		BYTE	HIGH MS_0042
		BYTE	HIGH MS_004A
		BYTE	HIGH MS_004B
;
HELP0F2		EQU	$
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDY	#000H
;
HL0F210		EQU	$
		LDA	>ITEMR53
		AND	#007H
		CMP	#007H
		BNE	HL0F220
		LDY	#002H
		BRA	HL0F230
;
HL0F220		EQU	$
		LDA	>MODTBL2
		CMP	#003H
		BCC	HL0F230
		LDY	#001H
;
HL0F230		EQU	$
		LDA	HL0F2ML,Y
		XBA
		LDA	HL0F2MH,Y
		TAY
		XBA
		JSL	>ENMSGEL	;MSGE SET
		BCC	HL0F240
;
		STA	ENMUKI,X	;MUKI SET
		STA	ENCMKI,X
;
		LDA	#0A0H
		STA	>UPLFCT
;
HL0F240		EQU	$
		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	KINOK move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KINOKIT		EQU	$
		PHB
		PHK
		PLB
		JSR	KINOK00_I
		PLB
		RTL
KINOK00_I	EQU	$
		LDA	>ITEMR05
		CMP	#002H
		BCC	KINOK10_I
		STZ	ENMODE,X
		RTS
KINOK10_I	EQU	$
		LDA	#000H
		STA	ENCHPT,X	;KINOKO SYURUI(0 - 3)
		LDA	#008H		;COLOR SET
		ORA	ENCLOR,X
		STA	ENCLOR,X
;
		INC	ENNOCR,X	;beem thru
		RTS
;----------------------------------------
KINOKMV		EQU	$
		PHB
		PHK
		PLB
		JSR	KINOK00
		PLB
		RTL
KINOK00		EQU	$
		JSL	>EN1CSTL	;OBJ SET
		JSL	>WPMSCK
		BCS	KINOK20
;
		JSL	>CRENPL2L	;? ATRI
		BCC	KINOK10
		STZ	ENMODE,X	;KILL I
		PHX
		LDY	#029H		;KINOKO 1
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
		PLX
		RTS
KINOK10		EQU	$
		LDA	<FRCNT
		AND	#01FH
		BNE	KINOK20
		LDA	ENCLOR,X	;FRIP
		EOR	#040H
		STA	ENCLOR,X
KINOK20		EQU	$
		RTS
;---------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	SUKAS move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SUKASIT		EQU	$
;;		PHB
;;		PHK
;;		PLB
;;		JSR	SUKAS00_I
;;		PLB
		RTL
;;SUKAS00_I	EQU	$
;;		RTS
;========================================
SUKASMV		EQU	$
		PHB
		PHK
		PLB
		JSR	SUKAS00
		PLB
		RTL
SUKAS00		EQU	$
		JSR	SUKASCS
		JSR	ENSTCK2		; scroll : not return !
;
;;;;		LDA	ENSTAT,X
		LDA	>ENCACT,X
		CMP	#03H
		BNE	SKS010		; Catsugi end ?
;					; yes !
		LDA	ENWRK2,X
		BNE	SKS008
		INC	ENWRK2,X
		LDA	#LOW  MS_00D0	; MSGE NO. SET
		LDY	#HIGH MS_00D0	; MSGE NO. SET
		JSL	>ENMSGSL	; 
SKS008		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - - - - -
SKS010		EQU	$
		JSR	ENMVCL
		JSL	>ENBDSBL	;bound move & chach check !
		RTS
;
;
;
;
;
;
;
;
;
;
;
;	  	LDA	#MS_001F	; MSGE NO. SET
;;		JSL	>ENMSGEL	; MEGE ?
;;		BCC	SUKAS10
;;;
;;		STZ	ENMODE,X	;KILL I
;;SUKAS10		EQU	$
;;		RTS
;---------------------------------------
SUKASCD		EQU	$
		WORD	00004,00000
		BYTE	0F4H,000H,000H,000H
		WORD	00004,00008
		BYTE	0F5H,000H,000H,000H
;
SUKASCS		EQU	$
		LDA	#002H		;KAZU SET
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW  SUKASCD	;ADD SET
		STA	<WORK8
		LDA	#HIGH SUKASCD
		STA	<WORK9
;
		JSL	>SETOAML
		RTS
;---------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	UTUWA move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UTUBKML		EQU	$
		BYTE	LOW  MS_0523
		BYTE	LOW  MS_0520
		BYTE	LOW  MS_0521
		BYTE	LOW  MS_0522
;
UTUBKMH		EQU	$
		BYTE	HIGH  MS_0523
		BYTE	HIGH  MS_0520
		BYTE	HIGH  MS_0521
		BYTE	HIGH  MS_0522
;--------------------------------------
UTUWAIT		EQU	$
UTUBKIT		EQU	$
		PHB
		PHK
		PLB
		JSR	UTUWA00_I
		PLB
		RTL
UTUWA00_I	EQU	$
		LDA	<DJFLG
		BNE	UTUWA10_I
;----------------------------------------
UTUWA20_I	EQU	$		;CHIJO
		LDA	<MPDTNO
		CMP	#03BH
		BNE	UTUWA60_I
		LDA	>GNDTBL+03BH
		AND	#00100000B
		BEQ	UTUWA50_I
UTUWA60_I	EQU	$
		PHX
		LDX	<MPDTNO		;SAVE RAM SET
		LDA	>GNDTBL,X
		AND	#040H
		BEQ	UTUWA30_I
		PLX
UTUWA50_I	EQU	$
		STZ	ENMODE,X	;KILL I
		RTS
UTUWA30_I	EQU	$
		PLX
		RTS
;----------------------------------------
UTUWA10_I	EQU	$		;DANJON
		LDA	ENXPSH,X
		AND	#001H
		TAY
		LDA	EMYSTT+1	;SAVE RAM SET
		AND	UTWF1DT,Y
		BEQ	UTUWA40_I
		STZ	ENMODE,X	;KILL I
UTUWA40_I	EQU	$
		RTS
;========================================
;----------------------------------------
UTUWAMV		EQU	$
		PHB
		PHK
		PLB
		JSR	UTUWA00
		PLB
		RTL
UTUWA00		EQU	$
		LDA	DJNNO
		CMP	#1AH
		BNE	UT00000		; Last danjyon Not utuwa set !
;
		STZ	ENMODE,X
		RTS
;---------------------------------------
UT00000		EQU	$
		LDA	ENCTCT,X
		STA	ENNOCR,X
		BNE	UT0000
;
		LDA	#03H
		PHX
		JSL	>ITMCBFST
		PLX
;
;;		LDA	ENYPSL,X
;;		CLC
;;		ADC	#10H
;;		STA	ENYPSL,X
;;		LDA	ENYPSH,X
;;		ADC	#00H
;;		STA	ENYPSH,X
;;		LDA	#0CH
;;		JSL	>PSERCHL
;
		JSL	>PSSAVE2
		INC	ENCTCT,X
UT0000		EQU	$
		LDA	ERXYCT
		CMP	#06H
		BNE	UT00001
;
		LDA	ENZPSL,X
		BNE	UT00001
;
		JSL	>ASIMZST
;
UT00001		EQU	$
		JSL	>EN1CSTL
		JSR	ENSTCK		; scroll : not return !
;
		DEC	ENZSPD,X
		DEC	ENZSPD,X
		JSR	ENZCLC		;xclc,yclc,zclc
;;		JSR	ENMVCL
;
		LDA	ENZPSL,X
		BPL	UTUWA30
		STZ	ENZPSL,X
		LDA	ENZSPD,X
		EOR	#0FFH
		INC	A
		LSR	A
		LSR	A
		STA	ENZSPD,X
;
		LDA	ERXYCT
		CMP	#06H
		BNE	UTUWA30
;
		LDA	HEMODE,X
		BNE	UTUWA30
;
		LDA	ENMOD0,X
		CLC
		ADC	#02H
		STA	ENMOD0,X
;
		INC	HEMODE,X
		JSL	>NZMZSTL
;;		STZ	ENXSPD,X
;;		STZ	ENYSPD,X
UTUWA30		EQU	$
;
		JSL	>WPMSCK
		BCC	UTUWA20
		RTS
UTUWA20		EQU	$
		JSL	>CRENPL2L	;? ATRI
		BCS	UTUWA10
		RTS
;---------------------------------------
UTUWA40		EQU	$
		PHX			;PL. DEMO
		LDA	#002H
		STA	ITMVFG
		LDY	#03EH
		JSL	>ATMSIT
		PLX
;
		LDA	EMYSTT+1
		ORA	#080H
		STA	EMYSTT+1
		RTS
;----------------------------------------
UTUWA10		EQU	$
		STZ	ENMODE,X	;KILL I
;
		LDA	ENWRK0,X
		BNE	UTUWA40		;BOSS ONRY
;
		PHX
		JSL	>DASCLR1
		LDY	#026H
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
		PLX
;
		LDA	<DJFLG
		BNE	UTUWAF1
;----------------------------------------
UTUWAF0		EQU	$		;CHIJO
		PHX
		LDX	<MPDTNO		;SAVE RAM SET
		LDA	>GNDTBL,X
		ORA	#040H
		STA	>GNDTBL,X
		PLX
		RTS
;----------------------------------------
UTWF1DT		EQU	$
		BYTE	040H,020H
UTUWAF1		EQU	$		;DANJON
		LDA	ENXPSH,X
		AND	#001H
		TAY
		LDA	EMYSTT+1	;SAVE RAM SET
		ORA	UTWF1DT,Y
		STA	EMYSTT+1
		RTS
;---------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	UTUBK move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UTUBKMV		EQU	$
		PHB
		PHK
		PLB
		JSR	UTUBK00
		PLB
		RTL
;----------------------------------------
;
UTUBK00		EQU	$
		LDA	ENSTAT,X
		BNE	UTUBK50
		INC	ENSTAT,X
		JSR	UTUWA00_I
		LDA	ENMODE,X
		BEQ	UTUBK20
UTUBK50		EQU	$
		JSL	>EN1CSTL
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>WPMSCK
		BCS	UTUBK20
;
		JSR	ENBGCK
		LDA	ENCBFG,X
		AND	#003H
		BEQ	UTUBK80
		LDA	ENXSPD,X
		EOR	#0FFH
		INC	A
		STA	ENXSPD,X
UTUBK80		EQU	$
;
		DEC	ENZSPD,X
		JSR	ENZCLC		;xclc,yclc,zclc
		JSR	ENMVCL
;
		LDA	ENZPSL,X
		BPL	UTUBK60
		STZ	ENZPSL,X
		LDA	ENZSPD,X
		EOR	#0FFH
		AND	#0F8H
		LSR	A
		STA	ENZSPD,X
		LDA	ENXSPD,X
		BEQ	UTUBK60
		CMP	#07FH
		ROR	A
		STA	ENXSPD,X
		CMP	#0FFH
		BNE	UTUBK60
		INC	ENXSPD,X
UTUBK60		EQU	$
		LDA	ENTIM3,X
		BNE	UTUBK20
		JSL	>CRENPL2L	;? ATRI
		BCS	UTUBK10
UTUBK20		EQU	$
		RTS
UTUBK10		EQU	$
		LDA	>ITEMR44
		INC	A
		AND	#003H
		STA	>ITEMR44
		BNE	UTUBK30
;					;Y
		PHX
		JSL	>DASCLR1
		LDY	#026H
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
		PLX
		BRA	UTUBK40
;
UTUBK30		EQU	$
;;		JSL	>SDLRCE
;;		ORA	#02DH		;OTO
;;		STA	SOUND3
		LDA	#02DH
		JSL	>SDLRE3	;(S)
;
		LDA	>ITEMR44
		TAY
		LDA	UTUBKML,Y
		XBA
		LDA	UTUBKMH,Y
		TAY
		XBA
		JSL	>ENMSGSL	; MEGE ?
;
UTUBK40		EQU	$
		STZ	ENMODE,X	;KILL I
;
		LDA	<DJFLG
		BEQ	UTUBK70
		JMP	UTUWAF1
UTUBK70		EQU	$
		JMP	UTUWAF0
;---------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	JITON move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JITONIT		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR	JITON00_I
;		PLB
;		RTL
;JITON00_I	EQU	$
;		INC	ENNOCR,X	;beem thru
;		RTS
;========================================
JITONMV		EQU	$
		PHB
		PHK
		PLB
		JSR	JITONFF
		PLB
		RTL
;---------------------------------------
JITONFF		EQU	$
		JSR	JITONCS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	JITON00		;SAHASRARA
		WORD	JITON01		;AJIMNA
;
;----------------------------------------
JITON01		EQU	$
		LDA	>MODTBL1
		AND	#020H
		BEQ	JITO150
;
		LDA	>ITMTBL6
		CMP	#002H
		BCC	JITO130
		LDA	#LOW  MS_0483	; MSGE NO. SET
		LDY	#HIGH MS_0483	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JITO120
JITO130		EQU	$
		LDA	>ITEMR53
		AND	#007H
		CMP	#007H
		BNE	JITO140
		LDA	#LOW  MS_0481	; MSGE NO. SET
		LDY	#HIGH MS_0481	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JITO120
JITO140		EQU	$
		AND	#002H
		CMP	#002H
		BNE	JITO160
		LDA	#LOW  MS_0484	; MSGE NO. SET
		LDY	#HIGH MS_0484	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JITO120
JITO160		EQU	$
		LDA	>ITEMR15
		BEQ	JITO150
		LDA	#LOW  MS_0482	; MSGE NO. SET
		LDY	#HIGH MS_0482	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JITO120
JITO150		EQU	$
		LDA	#LOW  MS_0480	; MSGE NO. SET
		LDY	#HIGH MS_0480	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		LDA	>MODTBL1
		ORA	#020H
		STA	>MODTBL1
JITO120		EQU	$
		JMP	JITON10
;;		BRA	JITON10
;
;----------------------------------------
JITON00		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JITONM0
		WORD	JITONM1
		WORD	JITONM2
		WORD	JITONM3
;----------------------------------------
JTN20ML		EQU	$
		BYTE	LOW  MS_007A,LOW  MS_0079
JTN20MH		EQU	$
		BYTE	HIGH MS_007A,HIGH MS_0079
;
JITONM0		EQU	$
		LDA	>ITEMR53
		AND	#004H
		BNE	JITON20
		LDA	#LOW  MS_0073	; MSGE NO. SET
		LDY	#HIGH MS_0073	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BCC	JITON28
		INC	ENSTAT,X
JITON28		EQU	$
		BRA	JITON10
JITON20		EQU	$
		LDA	>ITEMR22
		BNE	JITON30
		LDA	>MODTBL2
		CMP	#003H
		ROL	A
		AND	#001H
		TAY
		LDA	JTN20ML,Y	; MSGE NO. SET
		XBA
		LDA	JTN20MH,Y
		TAY
		XBA
		JSL	>ENMSGEL	; MEGE ?
		BCC	JITON38
		INC	ENSTAT,X
		INC	ENSTAT,X
JITON38		EQU	$
		BRA	JITON10
JITON30		EQU	$
		LDA	>ITEMR07
		BNE	JITON40
		LDA	#LOW  MS_0078	; MSGE NO. SET
		LDY	#HIGH MS_0078	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JITON10
JITON40		EQU	$
		LDA	>ITEMR53
		AND	#007H
		CMP	#007H
		BEQ	JITON50
		LDA	#LOW  MS_0075	; MSGE NO. SET
		LDY	#HIGH MS_0075	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JITON10
JITON50		EQU	$
		LDA	>ITMTBL6
		CMP	#002
		BCS	JITON60
		LDA	#LOW  MS_0071	; MSGE NO. SET
		LDY	#HIGH MS_0071	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JITON10
JITON60		EQU	$
		LDA	#LOW  MS_0072	; MSGE NO. SET
		LDY	#HIGH MS_0072	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
;
JITON10		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001
		STA	ENCHPT,X
;
		RTS
;---------------------------------------
JITONM1		EQU	$
		LDA	#LOW  MS_0074	; MSGE NO. SET
		LDY	#HIGH MS_0074	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		STZ	ENSTAT,X
		LDA	#003H		;MAP MODE
		STA	>MODTBL2
		RTS
;---------------------------------------
JITONM2		EQU	$
		LDY	#04BH		;KUTU SET
		STZ	ITMVFG
		JSL	>ATMSIT
		INC	ENSTAT,X
		LDA	#003H		;MAP MODE
		STA	>MODTBL2
		RTS
;---------------------------------------
JITONM3		EQU	$
		LDA	#LOW  MS_0078	; MSGE NO. SET
		LDY	#HIGH MS_0078	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		STZ	ENSTAT,X
		RTS
;---------------------------------------
JITONCD		EQU	$
		WORD	00000,-0009
		BYTE	0A0H,000H,000H,002H
		WORD	00000,00000
		BYTE	0A2H,000H,000H,002H
;
		WORD	00000,-0008
		BYTE	0A0H,000H,000H,002H
		WORD	00000,00000
		BYTE	0A4H,040H,000H,002H
;
JITONCS		EQU	$
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW JITONCD
		STA	<WORK8
		LDA	#HIGH JITONCD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		RTS
;--------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MONOR move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MONORIT		EQU	$
		PHB
		PHK
		PLB
		JSR	MONOR00_I
		PLB
		RTL
MONOR00_I	EQU	$
		INC	ENNOCR,X	;beem thru
;
		LDA	<MPDTNO
		CMP	#003H
		BEQ	MONORF0_I
;
		LDA	ENXPSL,X
		CLC
		ADC	#008H
		STA	ENXPSL,X
;
		LDA	>ITEMR08
		BEQ	MONOR10_I
		LDA	#004H
		STA	ENCHPT,X
		LDA	#003H
		STA	ENSTAT,X
		RTS
;
MONORF0_I	EQU	$
		LDA	>ITEMR09
		BEQ	MONOR10_I
		LDA	#004H
		STA	ENCHPT,X
		LDA	#003H
		STA	ENSTAT,X
MONOR10_I	EQU	$
		RTS
;========================================
MONORMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MONORFF
		PLB
		RTL
;---------------------------------------
MONORFF		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	MONOR00
		WORD	BAKU000
;----------------------------------------
BAKU0DT		EQU	$
		BYTE	000H,001H,002H,003H,004H,005H,001H,000H,0FFH
BAKU000		EQU	$
		JSL	>BAKU0CS
		JSR	ENSTCK
;
		LDA	ENTIM0,X
		BNE	BAKU010		;?E KAERU
;					;Y
		LDA	#005H		;NEXT TIME
		STA	ENTIM0,X
;
		LDY	ENWRK0,X	;E SET
		LDA	BAKU0DT,Y
		BPL	BAKU020
		STZ	ENMODE,X	;KILL I
		RTS
;
BAKU020		EQU	$
		STA	ENCHPT,X
		INC	ENWRK0,X
BAKU010		EQU	$
		RTS
;----------------------------------------
BAKU0ST		EQU	$		;SET BAKU0
		LDA	#MONOR
		JSL	>ENIDSH
		BMI	BK0ST10
;
		JSL	>RNDSET
		STA	<WORKF
		JSL	>RNDSET
		MEM16
		IDX8
		REP	#00100000B
;
		AND	#0000FH
		SEC
		SBC	#00008H
		CLC
		ADC	<WORK0
		STA	<WORK0
;
		LDA	<WORKF
		AND	#0000FH
		CLC
		ADC	<WORK2
		STA	<WORK2
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSL	>ENIDPS
;
		LDA	#001H
		STA	ENCONT,Y
;
BK0ST10		EQU	$
		RTS
;----------------------------------------
MONOR00		EQU	$
		JSL	>MONORCS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	AITMBT1		;GISYO READ CLS
		AND	#0DFH
		STA	AITMBT1
;
		STZ	ENWRK0,X
		JSL	>CRENPL2L
		BCC	MONOR10
		JSL	>PLOTCK		;PL. POS. recover
		STZ	<PYSPFG		;DASH STOP
		JSL	>DASHON
		INC	ENWRK0,X
;
MONOR10		EQU	$
		JSL	>WPMSCK
		BCC	MONOR20
		RTS
;
MONOR20		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	MONORM0
		WORD	MONORM1
		WORD	MONORM2
		WORD	MONORM3
;----------------------------------------
MONORML		EQU	$
		BYTE	LOW  MS_0400,LOW  MS_0401
MONORMH		EQU	$
		BYTE	HIGH MS_0400,HIGH MS_0401
;
MONOR1L		EQU	$
		BYTE	LOW  MS_0400,LOW  MS_0402
MONOR1H		EQU	$
		BYTE	HIGH MS_0400,HIGH MS_0402
;
MONORM0		EQU	$
		LDA	<MPDTNO
		CMP	#003H
		BEQ	MORM0F0
;
;----------------------------------------BOMB
		LDA	<PLMKCH		;PL. UP MUKI
		BNE	MORM080
;
		JSR	EPXYCK
		CPY	#002H
		BNE	MORM080
;
		MEM16
		IDX8
		REP	#00100000B
		LDA	ENYP2L
		CLC
		ADC	#00010H
		CMP	<PLYPS1
		MEM8
		IDX8
		SEP	#00110000B
;
		BCC	MORM080
;
		LDA	<KEYA2
		BPL	MORM090
		LDA	>ITMTBL6
		CMP	#002H
		BNE	MORM090
		RTS
MORM090		EQU	$
		LDA	GETITM0
		CMP	#015
		BNE	MORM0A0
;
		LDY	#001H
		LDA	<KEYA2
		AND	#040H
		BNE	MORM0B0
;
MORM0A0		EQU	$
		LDA	<KEYA2L
		BPL	MORM080
		LDY	#000H
MORM0B0		EQU	$
		CPY	#000H		;GISYO READ SET
		BEQ	MORM0C0
		STZ	AITMMD
		LDA	#020H
		STA	AITMBT1
		STZ	SOUND2
		LDA	>ITMTBL6
		BMI	MORM0C0
		CMP	#002H
		BCC	MORM0C0
		INC	ENSTAT,X	;MASTER KATANA USE
		JSL	>MNBBIT
		LDA	#040H
		STA	ENTIM0,X
MORM0C0		EQU	$
		LDA	MONOR1L,Y
		XBA
		LDA	MONOR1H,Y
		TAY
		XBA
;
		JSL	>ENMSGSL	; MEGE ?
;
MORM080		EQU	$
		RTS
;----------------------------------------THANDER
MORM0F0		EQU	$
		LDA	<PLMKCH		;PL. UP MUKI
		BNE	MORM010
;
		JSR	EPXYCK
		CPY	#002H
		BNE	MORM010
;
		LDA	ENYPSL,X
		CLC
		ADC	#010H
		CMP	<PLYPS1
		BCC	MORM010
;
		LDA	<KEYA2
		BPL	MORM020
		LDA	>ITMTBL6
		CMP	#002H
		BNE	MORM020
		RTS
MORM020		EQU	$
		LDA	GETITM0
		CMP	#015
		BNE	MORM030
;
		LDY	#001H
		LDA	<KEYA2
		AND	#040H
		BNE	MORM040
;
MORM030		EQU	$
		LDA	<KEYA2L
		BPL	MORM010
		LDY	#000H
MORM040		EQU	$
		CPY	#000H		;GISYO READ SET
		BEQ	MORM050
		STZ	AITMMD
		LDA	#020H
		STA	AITMBT1
		STZ	SOUND2
		LDA	>ITMTBL6
		BMI	MORM050
		CMP	#002H
		BCC	MORM050
		INC	ENSTAT,X	;MASTER KATANA USE
		JSL	>MNSRIT
		LDA	#040H
		STA	ENTIM0,X
MORM050		EQU	$
		LDA	MONORML,Y
		XBA
		LDA	MONORMH,Y
		TAY
		XBA
;
		JSL	>ENMSGSL	; MEGE ?
;
MORM010		EQU	$
		RTS
;---------------------------------------
MONORM1		EQU	$
		LDA	ENTIM0,X
		BNE	MNRM110
;
		INC	ENSTAT,X
;
;;;		LDA	<PLXPS1
;;;		PHA
;;;		LDA	<PLXPS1+1
;;;		PHA
;;;		LDA	<PLYPS1
;;;		PHA
;;;		LDA	<PLYPS1+1
;;;		PHA
;;;		LDA	ENXPSL,X
;;;		STA	<PLXPS1
;;;		LDA	ENXPSH,X
;;;		STA	<PLXPS1+1
;;;		LDA	ENYPSL,X
;;;		STA	<PLYPS1
;;;		LDA	ENYPSH,X
;;;		STA	<PLYPS1+1
;;;		PHX
;;;;
;;;		LDA	<MPDTNO
;;;		CMP	#003H
;;;		BNE	MORM120
;;;;
;;;		LDY	#000H
;;;		LDA	#SODMV		;THANDER SET
;;;		JSL	>SNDINT
;;;		BRA	MORM110
;;;;
;;;MORM120		EQU	$
;;;		LDY	#000H
;;;		LDA	#SPBMV		;BOMB SET
;;;		JSL	>SPBMINT
;;;MORM110		EQU	$
;;;		PLX
;;;		PLA
;;;		STA	<PLYPS1+1
;;;		PLA
;;;		STA	<PLYPS1
;;;		PLA
;;;		STA	<PLXPS1+1
;;;		PLA
;;;		STA	<PLXPS1
;;;;
		LDA	#080H
		STA	ENTIM0,X
;
;		LDA	#001H		;PL. STOP
;		STA	PYALSP
;
MNRM110		EQU	$
		RTS
;---------------------------------------
MONORM2		EQU	$
;		LDA	#001H		;PL. STOP
;		STA	PYALSP
;
		LDA	ENTIM0,X
		BNE	MORM210
		INC	ENSTAT,X
;
;;;		PHX
;;;		LDX	#000H		;THANDER
;;;		LDA	<MPDTNO
;;;		CMP	#003H
;;;		BEQ	MORM250
;;;		LDX	#005H		;BOMB
;;;MORM250		EQU	$
;;;		LDY	#004H
;;;		LDA	#TKDOW
;;;		JSL	>TKDINT
;;;		PLX
;
		LDA	#0F0H
		STA	ENTIM0,X
		RTS
MORM210		EQU	$
		CMP	#060H
		BEQ	MORM220
		CMP	#040H
		BEQ	MORM220
		CMP	#020H
		BNE	MORM230
MORM220		EQU	$
		INC	ENCHPT,X	;E SET
MORM230		EQU	$
		LDA	<FRCNT
		AND	#007H
		BNE	MORM240
		JSR	BAKU0ST		;BAKU0 SET
MORM240		EQU	$
		RTS
;---------------------------------------
MONORM3		EQU	$
;		LDA	ENTIM0,X
;		BNE	MORM310
;		STZ	PYALSP		;PL. MOVE
MORM310		EQU	$
		LDA	#004H
		STA	ENCHPT,X
		RTS
;---------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	JOHBB move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JOHBBIT		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR	JOHBB00_I
;		PLB
;		RTL
;JOHBB00_I	EQU	$
;		INC	ENNOCR,X	;beem thru
;		RTS
;========================================
JOHBBMV		EQU	$
		PHB
		PHK
		PLB
		JSR	JOHBB00
		PLB
		RTL
;---------------------------------------
JOHBB00		EQU	$
		JSR	JOHBBCS
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JOHBBM0
		WORD	JOHBBM1
		WORD	JOHBBM2
		WORD	JOHBBM3
;----------------------------------------
JOHBBM0		EQU	$
		LDA	>ITMTBL6
		CMP	#002H
		BCS	JOHBB40		;? MASTER KATANA GET
;					;N
		LDA	#LOW  MS_0050	; MSGE NO. SET
		LDY	#HIGH MS_0050	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BCC	JOHBB10
		INC	ENSTAT,X
;
JOHBB10		EQU	$
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001
		STA	ENCHPT,X
;
JOHBB30		EQU	$
		RTS
;
JOHBB40		EQU	$
		LDA	#LOW  MS_0053	; MSGE NO. SET
		LDY	#HIGH MS_0053	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	JOHBB10
;---------------------------------------
JOHBBM1		EQU	$
		LDA	#LOW  MS_0051	; MSGE NO. SET
		LDY	#HIGH MS_0051	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		INC	ENSTAT,X
		RTS
;---------------------------------------
JOHBBM2		EQU	$
		LDA	MSG_RTS
		BNE	JHBM210
		INC	ENSTAT,X
		LDA	#LOW  MS_0052	; MSGE NO. SET
		LDY	#HIGH MS_0052	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		RTS
;
JHBM210		EQU	$
		LDA	#LOW  MS_0051	; MSGE NO. SET
		LDY	#HIGH MS_0051	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		RTS
;---------------------------------------
JOHBBM3		EQU	$
		LDA	#LOW  MS_0052	; MSGE NO. SET
		LDY	#HIGH MS_0052	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
;
		BRA	JOHBB10
;---------------------------------------
JOHBBCD		EQU	$
		WORD	00000,-0005
		BYTE	08EH,000H,000H,002H
		WORD	00000,00005
		BYTE	028H,000H,000H,002H
;
		WORD	00000,-0004
		BYTE	08EH,000H,000H,002H
		WORD	00000,00005
		BYTE	028H,040H,000H,002H
;
JOHBBCS		EQU	$
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW JOHBBCD
		STA	<WORK8
		LDA	#HIGH JOHBBCD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
;		JSL	>SADWSTL
		RTS
;--------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MJSY1 move & init                   		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MJSY1IT		EQU	$
		PHB
		PHK
		PLB
		JSR	MJSY100_I
		PLB
		RTL
MJSY100_I	EQU	$
;		STZ	ENCONT,X	;MJSY1 SET
;		LDA	SCLSFG
;		BEQ	MJSY110_I
;
		JSR	POTN1ST
		JSR	POTN2ST
		JSR	POTN3ST
		JSR	POTN4ST
MJSY110_I	EQU	$
		INC	ENNOCR,X	;beem thru
		RTS
;----------------------------------------
POTN1ST		EQU	$
		LDA	SCLSFG
		BEQ	PN1ST10
;
		LDA	>ITEMR05
		CMP	#002H
		BEQ	PN1ST10		;? KONA MOTTERU
;					;N
		PHX			;POTION FLG GET
		STZ	<WORK0
		MEM8
		IDX16
		REP	#00010000B
;
		LDX	#ROOM_POTION*2	;ROOM NO * 2
		LDA	>DJNTBL,X
		AND	#080H		;POTION 1(KONA)
		STA	<WORK0
;
		MEM8
		IDX8
		SEP	#00110000B
		PLX
;
		LDA	<WORK0
		BEQ	PN1ST10		;? POTION 1 OK
;
		LDA	#MJSY1
		JSL	>ENIDSH
;
		LDA	#001H
		STA	ENCONT,Y	;POTN1 SET
;
		LDA	ENYPSL,X	;Y POS SET
		SEC
		SBC	#000H
		STA	ENYPSL,Y
		LDA	ENYPSH,X
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	ENXPSL,X	;X POS SET
		SEC
		SBC	#010H
		STA	ENXPSL,Y
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,Y
;
;		LDA	#001H
;		STA	ENNOCR,Y	;beem thru
;		LDA	#003H
;		STA	ENMOD3,Y	;OBJ hit hani !
;		LDA	ENMOD5,Y	;HUKKU ATARI
;		ORA	#020H
;		STA	ENMOD5,Y
		JMP	PN1ST20
PN1ST10		EQU	$
		RTS
;
;---------------------------------------
POTN2ST		EQU	$
;		PHX			;POTION FLG GET
;		STZ	<WORK0
;		MEM8
;		IDX16
;		REP	#00010000B
;
;		LDX	#ROOM_POTION*2	;ROOM NO * 2
;		LDA	>DJNTBL,X
;		AND	#040H		;POTION 2
;		STA	<WORK0
;
;		MEM8
;		IDX8
;		SEP	#00110000B
;		PLX
;
;		LDA	<WORK0
;		BEQ	PN2ST10		;? POTION 2 OK
;
		LDA	#MJSY1
		JSL	>ENIDSH
;
		LDA	#002H
		STA	ENCONT,Y	;POTN2 SET
;
		LDA	ENYPSL,X	;Y POS SET
		SEC
		SBC	#048H
		STA	ENYPSL,Y
		LDA	ENYPSH,X
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	ENXPSL,X	;X POS SET
		SEC
		SBC	#028H
		STA	ENXPSL,Y
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,Y
;
;		LDA	#001H
;		STA	ENNOCR,Y	;beem thru
;		LDA	#003H
;		STA	ENMOD3,Y	;OBJ hit hani !
;		LDA	ENMOD5,Y	;HUKKU ATARI
;		ORA	#020H
;		STA	ENMOD5,Y
		JMP	PN2ST20
PN2ST10		EQU	$
		RTS
;
;---------------------------------------
POTN3ST		EQU	$
;		PHX			;POTION FLG GET
;		STZ	<WORK0
;		MEM8
;		IDX16
;		REP	#00010000B
;
;		LDX	#ROOM_POTION*2	;ROOM NO * 2
;		LDA	>DJNTBL,X
;		AND	#020H		;POTION 3
;		STA	<WORK0
;
;		MEM8
;		IDX8
;		SEP	#00110000B
;		PLX
;
;		LDA	<WORK0
;		BEQ	PN3ST10		;? POTION 3 OK
;
		LDA	#MJSY1
		JSL	>ENIDSH
;
		LDA	#003H
		STA	ENCONT,Y	;POTN3 SET
;
		LDA	ENYPSL,X	;Y POS SET
		SEC
		SBC	#048H
		STA	ENYPSL,Y
		LDA	ENYPSH,X
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	ENXPSL,X	;X POS SET
		CLC
		ADC	#008H
		STA	ENXPSL,Y
		LDA	ENXPSH,X
		ADC	#000H
		STA	ENXPSH,Y
;
;		LDA	#001H
;		STA	ENNOCR,Y	;beem thru
;		LDA	#003H
;		STA	ENMOD3,Y	;OBJ hit hani !
;		LDA	ENMOD5,Y	;HUKKU ATARI
;		ORA	#020H
;		STA	ENMOD5,Y
		JMP	PN3ST20
PN3ST10		EQU	$
		RTS
;
;---------------------------------------
POTN4ST		EQU	$
;		PHX			;POTION FLG GET
;		STZ	<WORK0
;		MEM8
;		IDX16
;		REP	#00010000B
;
;		LDX	#ROOM_POTION*2	;ROOM NO * 2
;		LDA	>DJNTBL,X
;		AND	#010H		;POTION 4
;		STA	<WORK0
;
;		MEM8
;		IDX8
;		SEP	#00110000B
;		PLX
;
;		LDA	<WORK0
;		BEQ	PN4ST10		;? POTION 4 OK
;
		LDA	#MJSY1
		JSL	>ENIDSH
;
		LDA	#004H
		STA	ENCONT,Y	;POTN4 SET
;
		LDA	ENYPSL,X	;Y POS SET
		SEC
		SBC	#048H
		STA	ENYPSL,Y
		LDA	ENYPSH,X
		SBC	#000H
		STA	ENYPSH,Y
;
		LDA	ENXPSL,X	;X POS SET
		SEC
		SBC	#058H
		STA	ENXPSL,Y
		LDA	ENXPSH,X
		SBC	#000H
		STA	ENXPSH,Y
;
;		LDA	#001H
;		STA	ENNOCR,Y	;beem thru
PN1ST20		EQU	$
PN2ST20		EQU	$
PN3ST20		EQU	$
		LDA	#003H
		STA	ENMOD3,Y	;OBJ hit hani !
		LDA	ENMOD5,Y	;HUKKU ATARI
		ORA	#020H
		STA	ENMOD5,Y
PN4ST10		EQU	$
		RTS
;
;========================================
MJSY1MV		EQU	$
		PHB
		PHK
		PLB
		JSR	MJSY100
		PLB
		RTL
MJSY100		EQU	$
		LDA	ENCONT,X
		JSL	>JSRSUB
		WORD	MJSY1F0
		WORD	POTN1F0
		WORD	POTN2F0
		WORD	POTN3F0
		WORD	POTN4F0
;========================================
POTN1_YEN	EQU	0000		;NEDAN
POTN1F0		EQU	$		;POTION 1
		JSR	POTN1CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		JSL	>CRENPL2L	;? ATRI
		BCC	PN1F010
;
		LDA	<KEYA2L
		BPL	PN1F010
;
		PHX
		JSL	>DASCLR1
		LDY	#00DH		;KONA
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
		PLX
		STZ	ENMODE,X	;KILL I
PN1F010		EQU	$
		RTS
;---------------------------------------
POTN1CD		EQU	$
		WORD	00000,00000		;TUBO
		BYTE	0E6H,004H,000H,002H
		WORD	00000,00000		;TUBO
		BYTE	0E6H,004H,000H,002H
;
POTN1CS		EQU	$
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW POTN1CD
		STA	<WORK8
		LDA	#HIGH POTN1CD
		STA	<WORK9
;
		JSL	>SETOAML
;
		RTS
;========================================
POTN2_YEN	EQU	0060		;NEDAN
POTN2F0		EQU	$		;POTION 2
		JSR	POTN2CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		LDA	ENTIM0,X
		BNE	PN2F010
;
		JSR	POTONBN
		BCS	PN2F020
		LDA	#LOW  MS_00A2	; MSGE NO. SET
		LDY	#HIGH MS_00A2	; MSGE NO. SET
		JSL	>ENMSG2L	; MEGE ?
		BCC	PN2F010
		JSR	PTITBUT		;ITEM NOT USE
PN2F010		EQU	$
		RTS
;
PN2F020		EQU	$
		JSL	>CRENPL2L	;? ATRI
		BCC	PN2F030
;
		LDA	<KEYA2L
		BPL	PN2F030
;
		MEM16
		REP	#00100000B
		LDA	>CONCNT
		CMP	#POTN2_YEN	;NEDAN
		MEM8
		SEP	#00110000B
		BCC	PN2F050		;? OKANE ARU
;					;Y
		JSL	>BINCHKL
		BMI	PN2F040
		LDA	#1DH
		JSL	>SDLRE3	;(S)
		LDA	#040H
		STA	ENTIM0,X	;NEXT STOP TIME
		MEM16
		REP	#00100000B
		LDA	>CONCNT		;OKANE HIKU
		SEC
		SBC	#POTN2_YEN
		STA	>CONCNT
		MEM8
		SEP	#00110000B
		LDY	#02FH		;GREEN POTION
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
;
PN2F030		EQU	$
		RTS
PN2F040		EQU	$
		LDA	#LOW  MS_00A3	; MSGE NO. SET
		LDY	#HIGH MS_00A3	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		JMP	PTITBUT		;ITEM NOT USE
PN2F050		EQU	$
		JMP	KANENAS		;KANE NASI
;---------------------------------------
POTN2CD		EQU	$
		WORD	00000,00000		;TUBO
		BYTE	0C0H,008H,000H,002H
		WORD	00008,00018		;0
		BYTE	030H,00AH,000H,000H
		WORD	-0001,00018		;6
		BYTE	022H,00AH,000H,000H
;
POTN2CS		EQU	$
		LDA	#003H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW POTN2CD
		STA	<WORK8
		LDA	#HIGH POTN2CD
		STA	<WORK9
;
		JSL	>SETOAML
;
		RTS
;========================================
POTN3_YEN	EQU	0160		;NEDAN
POTN3F0		EQU	$		;POTION 3
		JSR	POTN3CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		LDA	ENTIM0,X
		BNE	PN3F010
;
		JSR	POTONBN
		BCS	PN3F020
		LDA	#LOW  MS_00A2	; MSGE NO. SET
		LDY	#HIGH MS_00A2	; MSGE NO. SET
		JSL	>ENMSG2L	; MEGE ?
		BCC	PN3F010
		JSR	PTITBUT		;ITEM NOT USE
PN3F010		EQU	$
		RTS
;
PN3F020		EQU	$
		JSL	>CRENPL2L	;? ATRI
		BCC	PN3F030
;
		LDA	<KEYA2L
		BPL	PN3F030
;
		MEM16
		REP	#00100000B
		LDA	>CONCNT
		CMP	#POTN3_YEN	;NEDAN
		MEM8
		SEP	#00110000B
		BCC	PN3F050		;? OKANE ARU
;					;Y
		JSL	>BINCHKL
		BMI	PN3F040
		LDA	#1DH
		JSL	>SDLRE3	;(S)
		LDA	#040H
		STA	ENTIM0,X	;NEXT STOP TIME
		MEM16
		REP	#00100000B
		LDA	>CONCNT		;OKANE HIKU
		SEC
		SBC	#POTN3_YEN
		STA	>CONCNT
		MEM8
		SEP	#00110000B
		LDY	#030H		;BLUE POTION
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
;
PN3F030		EQU	$
		RTS
PN3F040		EQU	$
		LDA	#LOW  MS_00A3	; MSGE NO. SET
		LDY	#HIGH MS_00A3	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		JMP	PTITBUT		;ITEM NOT USE
PN3F050		EQU	$
		JMP	KANENAS		;KANE NASI
;---------------------------------------
POTN3CD		EQU	$
		WORD	00000,00000		;TUBO
		BYTE	0C0H,004H,000H,002H
		WORD	00013,00018		;0
		BYTE	030H,00AH,000H,000H
		WORD	00005,00018		;6
		BYTE	022H,00AH,000H,000H
		WORD	-0003,00018		;1
		BYTE	031H,00AH,000H,000H
;
POTN3CS		EQU	$
		LDA	#004H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW POTN3CD
		STA	<WORK8
		LDA	#HIGH POTN3CD
		STA	<WORK9
;
		JSL	>SETOAML
;
		RTS
;========================================
POTN4_YEN	EQU	0120		;NEDAN
POTN4F0		EQU	$		;POTION 4
		JSR	POTN4CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
;
		LDA	ENTIM0,X
		BNE	PN4F010
;
		JSR	POTONBN
		BCS	PN4F020
		LDA	#LOW  MS_00A2	; MSGE NO. SET
		LDY	#HIGH MS_00A2	; MSGE NO. SET
		JSL	>ENMSG2L	; MEGE ?
		BCC	PN4F010
		JSR	PTITBUT		;ITEM NOT USE
PN4F010		EQU	$
		RTS
;
PN4F020		EQU	$
		JSL	>CRENPL2L	;? ATRI
		BCC	PN4F030
;
		LDA	<KEYA2L
		BPL	PN4F030
;
		MEM16
		REP	#00100000B
		LDA	>CONCNT
		CMP	#POTN4_YEN	;NEDAN
		MEM8
		SEP	#00110000B
		BCC	PN4F050		;? OKANE ARU
;					;Y
		JSL	>BINCHKL
		BMI	PN4F040
		LDA	#1DH
		JSL	>SDLRE3	;(S)
		LDA	#040H
		STA	ENTIM0,X	;NEXT STOP TIME
		MEM16
		REP	#00100000B
		LDA	>CONCNT		;OKANE HIKU
		SEC
		SBC	#POTN4_YEN
		STA	>CONCNT
		MEM8
		SEP	#00110000B
		LDY	#02EH		;RED POTION
		STZ	!ITMVFG
		JSL	>ATMSIT		;PL. DEMO SET
;
PN4F030		EQU	$
		RTS
PN4F040		EQU	$
		LDA	#LOW  MS_00A3	; MSGE NO. SET
		LDY	#HIGH MS_00A3	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		BRA	PTITBUT		;ITEM NOT USE
PN4F050		EQU	$
KANENAS         EQU     $
		LDA	#LOW  MS_05B6	;MSGE NO	OKANE NASI
		LDY	#HIGH MS_05B6	;MSGE NO
		JSL	>ENMSGSL	;MSGE SET
;---------------------------------------
PTITBUT		EQU	$		;ITEM NOT USE
		LDA	#03CH
		JSL	>SDLRE2
		RTS
;---------------------------------------
POTN4CD		EQU	$
		WORD	00000,00000		;TUBO
		BYTE	0C0H,002H,000H,002H
		WORD	00013,00018		;0
		BYTE	030H,00AH,000H,000H
		WORD	00005,00018		;2
		BYTE	002H,00AH,000H,000H
		WORD	-0003,00018		;1
		BYTE	031H,00AH,000H,000H
;
POTN4CS		EQU	$
		LDA	#004H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW POTN4CD
		STA	<WORK8
		LDA	#HIGH POTN4CD
		STA	<WORK9
;
		JSL	>SETOAML
;
		RTS
;========================================
POTONBN		EQU	$
		LDA	>BINCT0
		ORA	>BINCT1
		ORA	>BINCT2
		ORA	>BINCT3
		CMP	#002H
		RTS
;========================================
MJSY1F0		EQU	$		;MJSY1 
		JSL	>MJSY1CS
		JSR	ENSTCK		; scroll : not return !
		JSL	>ENPLATR
		JSL	>WPMSCK
		BCS	MJ1F020
;
		LDA	ENSTAT,X
		BEQ	MJ1F040
		LDA	#0A0H
		STA	>UPLFCT
		STZ	ENSTAT,X
MJ1F040		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001
		STA	ENCHPT,X
;
		LDA	>BINCT0
		CMP	#002H
		BCS	MJ1F010
		LDA	>BINCT1
		CMP	#002H
		BCS	MJ1F010
		LDA	>BINCT2
		CMP	#002H
		BCS	MJ1F010
		LDA	>BINCT3
		CMP	#002H
		BCS	MJ1F010
;
		LDA	SCLSFG		;SCROL FLG
		BEQ	MJ1F010
;
		LDA	#LOW  MS_00A0	; MSGE NO. SET
		LDY	#HIGH MS_00A0	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
MJ1F030		EQU	$
		BCC	MJ1F020
		INC	ENSTAT,X
MJ1F020		EQU	$
		RTS
;
MJ1F010		EQU	$
		LDA	#LOW  MS_00A1	; MSGE NO. SET
		LDY	#HIGH MS_00A1	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BRA	MJ1F030
;---------------------------------------
MJSY1CD		EQU	$
		WORD	00000,-0008
		BYTE	000H,00CH,000H,002H
		WORD	00000,00000
		BYTE	010H,00CH,000H,002H
;
		WORD	00000,-0008
		BYTE	000H,00CH,000H,002H
		WORD	00000,00000
		BYTE	010H,04CH,000H,002H
;
MJSY1CS		EQU	$
		PHB
		PHK
		PLB
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW MJSY1CD
		STA	<WORK8
		LDA	#HIGH MJSY1CD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML
;
		JSL	>SADWSTL
		PLB
		RTL
;--------------------------------------
;---------------------------------------
;---------------------------------------
;---------------------------------------
;---------------------------------------
EPXYCK		EQU	$
		JSL	>EPXYCK2
		RTS
;- - - - - - - - - - 
;;		JSR	EPXCHK
;;		STY	<WORK0
;;		JSR	EPYCHK
;;		STY	<WORK1
;;		LDA	<WORKE
;;		BPL	EXY000
;;		EOR	#0FFH
;;		INC	A
;;EXY000		EQU	$
;;		STA	ENHELP
;;		LDA	<WORKF
;;		BPL	EXY010
;;		EOR	#0FFH
;;		INC	A
;;EXY010		EQU	$
;;		CMP	ENHELP
;;		BCC	EXY020
;;		LDY	<WORK0
;;		RTS
;;EXY020		EQU	$
;;		LDA	<WORK1
;;		INC	A
;;		INC	A
;;		TAY
;;		RTS
;================================================================
EPXCHK		EQU	$
		JSL	>EPXCHK2
		RTS
;- - - - - - - -
;;		LDY	#00H
;;		LDA	<PLXPS1
;;		SEC
;;		SBC	ENXPSL,X
;;		STA	<WORKF
;;		LDA	<PLXPS0
;;		SBC	ENXPSH,X
;;		BPL	EPX010
;;		INY
;;EPX010		EQU	$
;;		RTS
;;;
;=================================================================
EPYCHK		EQU	$
		JSL	>EPYCHK2
		RTS
;;;- - - - - - - -
;;		LDY	#00H
;;		LDA	<PLYPS1
;;       	CLC
;;		ADC	ENZPSL,X
;;		PHP
;;		SEC
;;		SBC	ENYPSL,X
;;		STA	<WORKE
;;		LDA	<PLYPS0
;;		SBC	ENYPSH,X
;;		PLP
;;		ADC	#00H
;;		BPL	EPY010
;;		INY
;;EPY010		EQU	$
;;		RTS
;;;================================================================
;;EEXCHK		EQU	$
;;		LDY	#00H
;;		LDA	<WORK4
;;		SEC
;;		SBC	ENXPSL,X
;;		STA	<WORKF
;;		LDA	<WORK5
;;		SBC	ENXPSH,X
;;		BPL	EEX010
;;		INY
;;EEX010		EQU	$
;;		RTS
;;;================================================================
;;EEYCHK		EQU	$   
;;      	LDY	#00H
;;		LDA	<WORK6
;;		SEC
;;		SBC	ENYPSL,X
;;		STA	<WORKE
;;		LDA	<WORK7
;;		SBC	ENYPSH,X
;;		BPL	EEY010
;;		INY
;;EEY010		EQU	$
;;		RTS
;========================================================
;PLHNCK		EQU	$
;;;			TXA
;;;			EOR		<FRCNT
;;;			AND		#07H
;		LDA	ENDSPL,X
;		BNE	PLHN10
;;
;;;;			STZ		HANIFG
;;
;		JSR	EPXYCK
;		STY	<WORK0
;;;			JSR		EPXCHK
;		LDA	<WORKF
;		CLC
;		ADC	#20H
;		CMP	#40H
;		BCS	PLHN10
;;;			JSR		EPYCHK
;		LDA	<WORKE
;		CLC
;		ADC	#20H
;		CMP	#40H
;		BCS	PLHN10		; Player atack area ?
;;;;;			JSR		EPXYCK		; yes !
;;
;;;		LDY	<WORK0
;;;		LDA	PLMKCK,Y
;;;		CMP	PLMKCH
;;;		BNE	PLHN10		; Muki ok ?
;;								; yes !
;		INC	HANIFG		; Player in !
;PLHN10		EQU	$
;		RTS
;===========================================
ENSTCK		EQU	$
		LDA	ENMODE,X
		CMP	#EMOVE
		BNE	ESTC08
ENSTCK2		EQU	$
;;		JSR	PLHNCK		; player hani flag set 
;
		LDA	ENSTFG
		BNE	ESTC08		; enemy all stop !
;
		LDA	<GAMEMD
		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
		PLA
		PLA
ENHB90		EQU	$
		RTS
ENHB99		EQU	$
		STZ	ENHNFG,X
		RTS
;=========================================================
ENMVCL		EQU	$
;;;;;		LDA	ENHNFG,X
;;;;;		BNE	ENMC00
;
		JSR	ENXCLC
		JSR	ENYCLC
ENMC00		EQU	$
		RTS
;
ENXCLC		EQU	$
		TXA
		CLC
		ADC	#10H
		TAX
		JSR	ENYCLC
		LDX	ENINDX
		    RTS
;============================================
ENYCLC		EQU	    $
		LDA	ENYSPD,X
		BEQ	EYCRTS
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENYSDR,X
		STA	ENYSDR,X
;
		LDA	ENYSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDY	#00H
		PLP
		BPL	ENCY60
;
		ORA	#11110000B
		DEY
ENCY60		EQU	$
		ADC	ENYPSL,X
		STA	ENYPSL,X
;
		TYA
		ADC	ENYPSH,X
		STA	ENYPSH,X
EYCRTS		EQU	$
		RTS
;============================================
ENZCLC		EQU	    $
		LDA	ENZSPD,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ENZSDR,X
		STA	ENZSDR,X
;
		LDA	ENZSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		PLP
		BPL	ENCZ60
;
		ORA	#11110000B
ENCZ60		EQU	$
		ADC	ENZPSL,X
		STA	ENZPSL,X
;
		RTS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;OAMCHK		EQU	$
;		STZ	ENDSPL,X
;		LDA	ENYPSL,X
;		SEC
;		SBC	ENZPSL,X
;		SEC
;		SBC	<SCCV2
;		STA	ENDSYL
;;
;               LDA     ENYPSL,X
;               CLC
;                ADC     #10H
;                PHP
;                SEC
;                SBC     ENZPSL,X
;                PHP
;                SEC
;                SBC     <SCCV2
;                LDA     ENYPSH,X
;                SBC     <SCCV21
;                PLP
;                SBC     #00H
;                PLP
;                ADC     #00H
;		BEQ 	OMCK10
;
;OMCK0F		EQU	$
;		PLA
;		PLA
;		BRA	OMCK18
;OMCK10		EQU	$
;		LDA	ENXPSH,X
;		XBA
;		LDA	ENXPSL,X
;		MEM16
;		REP	#00100000B
;		SEC
;		SBC	<SCCH2
;		CLC
;		ADC	#0040H
;		CMP	#0180H
;		MEM8
;		SEP	#00100000B
;		BCS	OMCK0F
;;
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		STA	ENDSXL
;		LDA	ENXPSH,X
;		SBC	<SCCH21
;		BEQ	OMCK20
;OMCK18		EQU	$
;		INC	ENDSPL,X
;OMCK20		EQU	$
;;;;		LDY	ENOMID,X
;;		LDY	#00H
;;		RTS
;		BRA	OMCS20
;-----------------------------------------------------
;OAMCHKS		EQU	$
;		STZ	ENDSPL,X
;		LDA	ENYPSL,X
;		SEC
;		SBC	ENZPSL,X
;		CLC
;		ADC	#04H
;		SEC
;		SBC	<SCCV2
;		STA	ENDSYL
;;
;                LDA     ENYPSL,X
;                CLC
;                ADC     #14H
;                PHP
;                SEC
;                SBC     ENZPSL,X
;                PHP
;                SEC
;                SBC     <SCCV2
;                LDA     ENYPSH,X
;                SBC     <SCCV21
;                PLP
;                SBC     #00H
;                PLP
;                ADC     #00H
;		BEQ 	OMCS10
;OMCS0F		EQU	$
;		PLA
;		PLA
;		BRA	OMCS18
;OMCS10		EQU	$
;		LDA	ENXPSH,X
;		XBA
;		LDA	ENXPSL,X
;		MEM16
;		REP	#00100000B
;		SEC
;		SBC	<SCCH2
;		CLC
;		ADC	#0040H
;		CMP	#0180H
;		MEM8
;		SEP	#00100000B
;		BCS	OMCS0F
;;
;		LDA	ENXPSL,X
;		SEC
;		SBC	<SCCH2
;		PHP
;		CLC
;		ADC	#04H
;		STA	ENDSXL
;		LDA	ENXPSH,X
;		ADC	#00H
;		PLP
;		SBC	<SCCH21
;		BEQ	OMCS20
;OMCS18		EQU	$
;		INC	ENDSPL,X
;OMCS20		EQU	$
;;;		LDY	ENOMID,X
;		LDY	#00H 
;		LDA	ENCLOR,X
;		STA	<WORK3
;		STZ	<WORK2
;		RTS
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
O2TEST		EQU	$	; oam set paramater set & display out check !
OAMCHK		EQU	$
		JSL	>OAMCHKL
		BCC	O2010
		PLA
		PLA
O2010		EQU	$
		RTS
;- - - - - - - - - - - - - - - - - -
;		STZ	ENDSPL,X
;;
;;;		LDA	ENXPSH,X
;;;		XBA
;;;		LDA	ENXPSL,X
;		MEM16
;		REP	#00100000B
;		LDA	ENXP2L
;		SEC
;		SBC	<SCCH2
;		STA	<WORK0
;		CLC
;		ADC	#0040H
;		CMP	#0170H
;		MEM8
;		SEP	#00100000B
;		BCS	O2T010
;;
;		LDA	ENZPSL,X
;		STA	<WORK4
;		STZ	<WORK5
;;
;;;		LDA	ENYPSH,X
;;;		XBA
;;;		LDA	ENYPSL,X
;		MEM16
;		REP	#00100000B
;		LDA	ENYP2L
;		SEC
;		SBC	<SCCV2
;		PHA
;		SEC
;		SBC	<WORK4
;		STA	<WORK2
;		PLA
;		CLC
;		ADC	#0040H
;		CMP	#0170H
;		MEM8
;		SEP	#00100000B
;		BCS	O2T090
;;;		BCS	O2T010
;;
;;;		LDA	ENXPSL,X
;;;		SEC
;;;		SBC	<SCCH2
;;;		STA	<WORK0
;;;		LDA	ENXPSH,X
;;;		SBC	<SCCH21
;;;		STA	<WORK1
;;
;;;                LDA     ENYPSL,X
;;;;              SEC
;;;                SBC     ENZPSL,X
;;;;              PHP
;;;                SEC
;;;                SBC     <SCCV2
;;;		STA	<WORK2
;;;                LDA     ENYPSH,X
;;;                SBC     <SCCV21
;;;                PLP
;;;                SBC     #00H
;;;                PLP
;;;                ADC     #00H
;;;		STA	<WORK3
;;
;;;		LDA	<WORK0
;;;		SEC
;;;		SBC	#10H
;;;		STA	ENDSYL
;;
;O2T038		EQU	$
;		LDA	ENCLOR,X
;		STA	<WORK5
;		STZ	<WORK4
;		LDA	<WORK0
;		STA	ENDSXL
;		LDA	<WORK2
;		STA	ENDSYL
;		LDY	#00H
;		RTS
;O2T010		EQU	$
;;;		LDA	SLMODE
;;;		CMP	#MD_djply
;;;		BEQ	O2T020
;;
;		LDA	ENMOD5,X
;		BMI	O2T020
;;
;		JSL	>ENCLER
;O2T020		EQU	$
;		PLA
;		PLA
;		SEC
;O2T090		EQU	$
;		INC	ENDSPL,X
;		BRA	O2T038
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	                                      		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MSGCHK		EQU	$
		STA	MSGENOL
		STY	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
;;;
;;		MEM8
;;		SEP	#00100000B
;
		PHP
		JSL	>PLOTCK
		PLP
;
		STZ	DASHFG
		STZ	<PYSPFG
;
		LDA	<DIEFG
		BNE	MSC010
;
MSGSET		EQU	$
		STZ	!MSGEFG
		STZ	!INITAL
		LDA	#p3_msge
		STA	<GAMEMD
		LDA	<SLMODE
		STA	!NXSLMD
		LDA	#MD_etcpl
		STA	<SLMODE
MSC010		EQU	$
		RTL
;===============================================
EVCHCKE		EQU	$		;UNIT CHK
		MEM16
		IDX16
		REP	#00110000B	; memory,index 16bit mode
;
		LDA	<WORK0
		SEC
		SBC	!GCCKY0
		AND	!GCCKY1
		ASL	A
		ASL	A
		ASL	A
		STA	<WORK6
;
		LDA	<WORK2
		SEC
		SBC	!GCCKX0
		AND	!GCCKX1
;// 03.07.02 //		CLC
;// 03.07.02 //		ADC	<WORK6
		ORA	<WORK6
;// 02.12.11 //		CMP	#01000H
;// 02.12.11 //		BCC	EVCK40		; buffer-0 ?
;// 02.12.11 //;					; no
;// 02.12.11 //		SBC	#01000H
;// 02.12.11 //		ORA	#02000H
;// 02.12.11 //EVCK40		EQU	$
		TAX
		LDA	>GDBUF0,X
		TAX
		LDA	>GRNDCHK,X
		MEM8
		IDX8
		SEP	#00110000B
		RTL
;----------------------------------------
;
;	DEMON MOVE
;
;----------------------------------------
DEMONMV		EQU	$
		PHB
		PHK
		PLB
		JSR	DEMON00
		PLB
		RTL
;----------------------------------------
DEMON00		EQU	$
		LDA	ENKBMK,X
		BEQ	DMM000		; Beam ?
;					; yes !
		JSL	>DEMBMMV
		RTS
;------------------------------------------
DMM000		EQU	$
		LDA	ENSTAT,X
		BEQ	DEMON10
		JSL	>EN1CSTL
DEMON10		EQU	$
		JSR	ENSTCK		; scroll : not return !
		JSR	ENMVCL		;xclc,yclc
		JSR	ENZCLC		;zclc
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	DEMONM0
		WORD	DEMONM1
		WORD	DEMONM2
		WORD	DEMONM3
		WORD	DEMONM4
;----------------------------------------
DEMONM0		EQU	$
		LDA	>MPLVFG		;DENAI
		CMP	#001H
		BCS	DMNM030
;
		JSL	>CRENPL2L
		BCC	DMNM030		;? TUCH
;					;Y
		LDY	#004H
DMNM010		EQU	$
		LDA	BMMODE,Y
		CMP	#KONMV		;? PL. KONA
		BEQ	DMNM020
		DEY
		BPL	DMNM010
		RTS
;
DMNM020		EQU	$		;Y
		JSL	>KEMR1ST	;KEMURI SET
;;		JSL	>SDLRCE		;OTO
;;		ORA	#00DH
;;		STA	SOUND1
		LDA	#0DH
		JSL	>SDLRE1	;(S)
;
		INC	ENSTAT,X
;
		LDA	#014H		;TIME SET
		STA	ENWRK0,X
;
		LDA	#001H		;PL. STOP
		STA	PYALSP
;
		LDA	ENCLOR,X
		ORA	#020H
		STA	ENCLOR,X
DMNM030		EQU	$
		RTS
;----------------------------------------
DMNM1DT		EQU	$
		BYTE	0F8H,007H
DEMONM1		EQU	$
		LDA	ENTIM0,X
		BNE	DMNM110
;
		DEC	ENWRK0,X	;DEC TIME
		LDA	ENWRK0,X	;NEXT TIME SET
		STA	ENTIM0,X
		CMP	#001H
		BEQ	DMNM120
		LSR	A
		LSR	A
		STA	ENZSPD,X
		LDA	ENWRK0,X
		AND	#001H
		TAY
		LDA	DMNM1DT,Y
		CLC
		ADC	ENXSPD,X
		STA	ENXSPD,X
;
		LDA	ENCHPT,X
		EOR	#001H
		STA	ENCHPT,X
DMNM110		EQU	$
		RTS
;
DMNM120		EQU	$
		LDA	#LOW  MS_0410	; MSGE NO. SET
		LDY	#HIGH MS_0410	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		INC	ENSTAT,X
		STZ	ENCHPT,X
		STZ	ENZSPD,X
		STZ	ENXSPD,X
		LDA	#0FFH
		STA	ENTIM0,X	;LIGHT TIME SET
		RTS
;----------------------------------------
DMNM2CL		EQU	$
		BYTE	00AH,004H,002H,004H,002H,00AH,004H,002H
DEMONM2		EQU	$
		LDA	ENTIM0,X
		BNE	DMNM210
		INC	ENSTAT,X
		LDA	#040H
		STA	ENTIM1,X
		LDA	ENTIM0,X
DMNM210		EQU	$
		LSR	A
		AND	#007H
		TAY
		LDA	ENCLOR,X
		AND	#0F1H
		ORA	DMNM2CL,Y
		STA	ENCLOR,X
;
		LDA	ENTIM0,X
		CMP	#0F0H
		BNE	DMNM220
;
		JSL	>DEMBMST	;BEEM SET
;;		JSL	>DEMBMST
;;		JSL	>DEMBMST
;;		JSL	>DEMBMST
DMNM220		EQU	$
		RTS
;----------------------------------------
DEMONM3		EQU	$
		LDA	ENTIM1,X
		BNE	DMNM310
		LDA	#LOW  MS_0411	; MSGE NO. SET
		LDY	#HIGH MS_0411	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		PHX
		JSL	>THCGCN2
		INC	<CGVMAF
		PLX
		INC	ENSTAT,X
		LDA	#001H		;MP HANBUN
		STA	>MPLVFG
		JSL	>ITEM0ST
		RTS
DMNM310		EQU	$
		CMP	#010H
		BNE	DMNM320
		STA	CGFLTM
DMNM320		EQU	$
		RTS
;----------------------------------------
DEMONM4		EQU	$
		JSL	>KEMR2ST	;KEMURI SET
		STZ	ENMODE,X	;KILL I
		STZ	PYALSP		;PL. MOVE
		RTS
;----------------------------------------
BOOK0MV		EQU	$
		PHB
		PHK
		PLB
		JSR	BOOK000
		PLB
		RTL
;----------------------------------------
BOOK000		EQU	$
		LDA	ENCHPT,X
		JSL	>JSRSUB
		WORD	BOOK0BK
		WORD	KAGI0KI
		WORD	KIIIIMV
;----------------------------------------
KAGI0KI		EQU	$
;		LDA	ENSTAT,X
;		BNE	KAGI030
;		JSL	>EN1CSSL
;		BRA	KAGI040
KAGI030		EQU	$
		JSL	>EN12CSL
KAGI040		EQU	$
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>CRENPL2L	;? ATRI
		BCC	KAGI020
		LDA	#003H
		STA	ENSTAT,X
KAGI020		EQU	$
		JSR	ENMVCL		;xclc,yclc
;
		DEC	ENZSPD,X
		JSR	ENZCLC		;zclc
		LDA	ENZPSL,X
		BPL	KAGI010
		STZ	ENYSPD,X
		STZ	ENZPSL,X
		LDA	ENZSPD,X
		EOR	#0FFH
		INC	A
		LSR	A
		LSR	A
		STA	ENZSPD,X
		AND	#0FEH
		BEQ	KAGI010
;;		JSL	>SDLRCE		;OTO
;;		ORA	#014H
;;		STA	SOUND3
		LDA	#14H
		JSL	>SDLRE3	;(S)
;
KAGI010		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KAGI0M0		;TANA
		WORD	BOOK0M1		;DOWN INIT
		WORD	BOOK0M2		;DOWN
		WORD	KAGI0M3		;TORU
;----------------------------------------
KAGI0M0		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	ENXP2L
		SEC
		SBC	<PLXPS1
		CLC
		ADC	#00010H
		CMP	#00021H
		BCS	KG0M010		;? X HANI
;					;OK
		LDA	ENYP2L
		SEC
		SBC	<PLYPS1
		CLC
		ADC	#00018H
		CMP	#00029H
		BCS	KG0M010		;? Y HANI
;					;OK
		LDA	YUREXD
		ORA	YUREYD
		BEQ	KG0M010		;? YURETEIRU
;					;Y
		INC	ENSTAT,X	;GOTO DOWN
;
KG0M010		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------
KG0M3DT		EQU	$
		BYTE	040H,020H
;
KAGI0M3		EQU	$
		LDA	>ITMTBL9	;KAGI GET
		INC	A
		STA	>ITMTBL9
		STZ	ENMODE,X	;KILL I
;
		LDA	KAGIFG,X
		TAY
		LDA	EMYSTT+1	;SAVE RAM SET
		ORA	KG0M3DT,Y
		STA	EMYSTT+1
;
;;		JSL	>SDLRCE
;;		ORA	#02FH		;OTO
;;		STA	SOUND3
		LDA	#2FH
		JSL	>SDLRE3	;(S)
		RTS
;----------------------------------------
BOOK0BK		EQU	$
		JSL	>EN1CSTL
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>CRENPL2L	;? ATRI
		BCC	BOOK020
		LDA	#003H
		STA	ENSTAT,X
BOOK020		EQU	$
		JSR	ENMVCL		;xclc,yclc
;
		DEC	ENZSPD,X
		JSR	ENZCLC		;zclc
		LDA	ENZPSL,X
		BPL	BOOK010
		STZ	ENYSPD,X
		STZ	ENZPSL,X
		LDA	ENZSPD,X
		EOR	#0FFH
		INC	A
		LSR	A
		LSR	A
		STA	ENZSPD,X
		AND	#0FEH
		BEQ	BOOK010
;
;;		JSL	>SDLRCE		;OTO
;;		ORA	#021H
;;		STA	SOUND2
		LDA	#21H
		JSL	>SDLRE2	;(S)
;
BOOK010		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	BOOK0M0		;TANA
		WORD	BOOK0M1		;DOWN INIT
		WORD	BOOK0M2		;DOWN
		WORD	BOOK0M3		;TORU
;----------------------------------------
BOOK0M0		EQU	$
		LDA	PLMKCH
		BNE	BO0M010
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	ENXP2L
		SEC
		SBC	<PLXPS1
		CLC
		ADC	#00027H
		CMP	#0002FH
		BCS	BO0M010		;? X HANI
;					;OK
		LDA	ENYP2L
		SEC
		SBC	<PLYPS1
		CLC
		ADC	#00028H
		CMP	#0002EH
		BCS	BO0M010		;? Y HANI
;					;OK
		LDA	YUREXD
		ORA	YUREYD
		BEQ	BO0M010		;? YURETEIRU
;					;Y
		INC	ENSTAT,X	;GOTO DOWN
BO0M010		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------
BOOK0M1		EQU	$
		LDA	#020H		;Z POS SET
		STA	ENZSPD,X
;
		LDA	#0FBH		;Y SPEED SET
		STA	ENYSPD,X
;
		INC	ENSTAT,X	;GOTO DOWN
;
		LDA	#01BH
		STA	SOUND3		;OTO
		RTS
;----------------------------------------
BOOK0M2		EQU	$
		LDA	ENZPSL,X
		BNE	BO0M210
		LDA	PLBGCKF
		STA	ENKAIF,X
BO0M210		EQU	$
		RTS
;----------------------------------------
BOOK0M3		EQU	$
		PHX
		JSL	>DASCLR1
		LDY	#01DH
		STZ	!ITMVFG
		JSL	>ATMSIT
		PLX
		STZ	ENMODE,X	;KILL I
;
		RTS
;----------------------------------------
KIIIIMV		EQU	$
		LDA	#08FH
		STA	ENMOD0,X
		LDA	#047H
		STA	ENMOD3,X
		JSR	KIIIICS
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>CRENPL2L
		BCC	KIIII20
		PHX
		JSL	>PLOTCK		;PL. POS. recover
		STZ	<PYSPFG		;DASH STOP
		JSL	>DASHON
		PLX
KIIII20		EQU	$
;
		JSR	ENMVCL		;xclc,yclc
		DEC	ENZSPD,X
		JSR	ENZCLC		;zclc
		LDA	ENZPSL,X
		BPL	KIIII10
		STZ	ENZPSL,X
		LDA	ENZSPD,X
		EOR	#0FFH
		INC	A
		LSR	A
		LSR	A
		STA	ENZSPD,X
KIIII10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	KIIIIM0
		WORD	KIIIIM1
		WORD	KIIIIM2
;----------------------------------------
KIIIIM0		EQU	$
		STZ	ENCONT,X
		MEM16
		IDX8
		REP	#00100000B
		LDA	ENXP2L
		SEC
		SBC	<PLXPS1
		CLC
		ADC	#00018H
		CMP	#00041H
		BCS	KIIM010
		LDA	ENYP2L
		SEC
		SBC	<PLYPS1
		CLC
		ADC	#00020H
		CMP	#00051H
		BCS	KIIM010
		MEM8
		IDX8
		SEP	#00110000B	;ATARI
;
		LDA	YUREXD
		ORA	YUREYD
		BEQ	KIIM010		;? YURETEIRU
		INC	ENSTAT,X
		LDA	#014H
		STA	ENZSPD,X
;;		JSL	>SDLRCE		;OTO
;;		ORA	#01BH
;;		STA	SOUND3
;
KIIM010		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;----------------------------------------
KIIIIM1		EQU	$
		LDA	ENZPSL,X	;BOUND
		BNE	KIIM110
		INC	ENSTAT,X
		LDA	#1BH
		STA	SOUND3		;OTO
		LDA	#0FCH
		STA	ENXSPD,X
		STA	ENYSPD,X
;
		JSR	KIIIIST
		LDA	#005H
		STA	ENXSPD,Y
		STA	ENYSPD,Y
;
		JSR	KIIIIST
		LDA	#005H
		STA	ENXSPD,Y
		LDA	#0FCH
		STA	ENYSPD,Y
;
		JSR	KIIIIST
		LDA	#0FCH
		STA	ENXSPD,Y
		LDA	#004H
		STA	ENYSPD,Y
;
KIIM110		EQU	$
		RTS
;----------------------------------------
KIIIIM2		EQU	$		;KUZURERU
		LDA	ENTIM0,X
		BNE	KIIM210
		LDA	#008H
		STA	ENTIM0,X
		LDA	ENCONT,X
		CMP	#006H
		BNE	KIIM220
		STZ	ENMODE,X
KIIM220		EQU	$
		INC	ENCONT,X
KIIM210		EQU	$
		RTS
;----------------------------------------
KIS10DT		EQU	$
		BYTE	000H,031H , 002H,031H , 002H,071H , 000H,071H
		BYTE	020H,031H , 022H,031H , 022H,071H , 020H,071H
		BYTE	004H,031H , 006H,031H , 006H,071H , 004H,071H
		BYTE	024H,031H , 026H,031H , 026H,071H , 024H,071H
;
KIS80PX		EQU	$
		BYTE	010
		BYTE	022
		BYTE	030
		BYTE	001
		BYTE	034
		BYTE	005
		BYTE	013
		BYTE	029
		BYTE	000
		BYTE	017
		BYTE	027
		BYTE	044
		BYTE	015
		BYTE	033
		BYTE	018
		BYTE	026
KIS80PY		EQU	$
		BYTE	000
		BYTE	004
		BYTE	002
		BYTE	007
		BYTE	010
		BYTE	016
		BYTE	024
		BYTE	023
		BYTE	034
		BYTE	035
		BYTE	030
		BYTE	031
		BYTE	046
		BYTE	042
		BYTE	010
		BYTE	011
KIS80CD		EQU	$
		BYTE	008H
		BYTE	008H
		BYTE	028H
		BYTE	028H
		BYTE	02AH
		BYTE	02AH
KIS80AD		EQU	$
		BYTE	031H
		BYTE	071H
		BYTE	031H
		BYTE	071H
		BYTE	031H
		BYTE	071H
;
KIIIICS		EQU	$
		JSR	OAMCHK
;		JSL	>OCHECKL
		LDA	ENDSXL
		SEC
		SBC	#020H
		STA	ENDSXL
		LDA	ENDSYL
		SEC
		SBC	#020H
		STA	ENDSYL
		PHX
		LDA	ENCONT,X
		BNE	KIICS80
;
		MEM8			;KIIII SET
		IDX16
		REP	#00010000B
;
		LDX	<OAMADR
		LDA	#003H
		STA	<WORK0
		LDA	ENDSXL
KIICS10		EQU	$
		STA	<OAM-OAM+00*4,X
		STA	<OAM-OAM+04*4,X
		STA	<OAM-OAM+08*4,X
		STA	<OAM-OAM+12*4,X
		CLC
		ADC	#010H
		INX
		INX
		INX
		INX
		DEC	<WORK0
		BPL	KIICS10
;
		LDX	<OAMADR
		LDA	ENDSYL
		STA	<OAM-OAM+00*4+1,X
		STA	<OAM-OAM+01*4+1,X
		STA	<OAM-OAM+02*4+1,X
		STA	<OAM-OAM+03*4+1,X
		CLC
		ADC	#010H
		STA	<OAM-OAM+04*4+1,X
		STA	<OAM-OAM+05*4+1,X
		STA	<OAM-OAM+06*4+1,X
		STA	<OAM-OAM+07*4+1,X
		CLC
		ADC	#010H
		STA	<OAM-OAM+08*4+1,X
		STA	<OAM-OAM+09*4+1,X
		STA	<OAM-OAM+10*4+1,X
		STA	<OAM-OAM+11*4+1,X
		CLC
		ADC	#010H
		STA	<OAM-OAM+12*4+1,X
		STA	<OAM-OAM+13*4+1,X
		STA	<OAM-OAM+14*4+1,X
		STA	<OAM-OAM+15*4+1,X
;
		MEM16
		IDX16
		REP	#00110000B
		LDY	#00000H
KIICS20		EQU	$
		LDA	KIS10DT,Y
		STA	<OAM-OAM+00*4+2,X
		INX
		INX
		INX
		INX
		INY
		INY
		CPY	#00020H
		BCC	KIICS20
;
		MEM8
		IDX8
		SEP	#00110000B
		PLX
		LDA	#00FH
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;----------------------------------------
KIICS80		EQU	$		;KUZURERU E
		LDA	ENCONT,X
		DEC	A
		STA	<WORK0
		STZ	<WORK1
		MEM8
		IDX16
		REP	#00010000B
;
		LDX	<OAMADR
		LDY	#0000FH
KIICS90		EQU	$
		LDA	ENDSXL
		CLC
		ADC	KIS80PX,Y
		STA	<OAM-OAM,X
		INX
		LDA	ENDSYL
		CLC
		ADC	KIS80PY,Y
		STA	<OAM-OAM,X
		INX
		PHY
		LDY	<WORK0
		LDA	KIS80CD,Y
		STA	<OAM-OAM,X
		INX
		LDA	KIS80AD,Y
		STA	<OAM-OAM,X
		INX
		PLY
		DEY
		BPL	KIICS90
		MEM8
		IDX8
		SEP	#00110000B
		PLX
		LDA	#00FH
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;----------------------------------------
KIIIIST		EQU	$
		LDA	#BOOK0
		JSL	>ENIDSH
;
		LDA	#002H
		STA	ENCHPT,Y
;
		LDA	ENZSPD,X
		STA	ENZSPD,Y
;
		LDA	#001H
		STA	ENCONT,Y
;
		LDA	#002H
		STA	ENSTAT,Y
;
		LDA	#008H
		STA	ENTIM0,Y
		JSL	>ENIDPS
		RTS
;
;----------------------------------------
TKBOYMV		EQU	$
		PHB
		PHK
		PLB
		JSR	TKBOY00
		PLB
		RTL
;----------------------------------------
TKBOY00		EQU	$
		JSR	TKBOYCS
		JSR	ENSTCK		; scroll : not return !
;
		JSL	>ENPLATR	;PL. EN. ATARI SET
;
		JSL	>ENMKIST	;MUKI SET
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		LDA	>MODTBL2
		CMP	#003H
		BCS	TBYMV20
;
		LDA	#LOW  MS_04F0	; MSGE NO. SET
		LDY	#HIGH MS_04F0	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BCC	TBYMV10
		LDA	#002H
		STA	>MODTBL2
;		LDA	#02DH		;OTO
;		JSL	>SDLRE3
TBYMV10		EQU	$
		RTS
;
TBYMV20		EQU	$
		LDA	#LOW  MS_04F1	; MSGE NO. SET
		LDY	#HIGH MS_04F1	; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		RTS
;----------------------------------------
TKBOYCD		EQU	$
		WORD	00000,-0008
		BYTE	082H,008H,000H,002H
		WORD	00000,00000
		BYTE	0AAH,00AH,000H,002H
;
		WORD	00000,-0008
		BYTE	082H,008H,000H,002H
		WORD	00000,00000
		BYTE	0AAH,00AH,000H,002H
;
		WORD	00000,-0008
		BYTE	080H,048H,000H,002H
		WORD	00000,00000
		BYTE	0AAH,00AH,000H,002H
;
		WORD	00000,-0008
		BYTE	080H,008H,000H,002H
		WORD	00000,00000
		BYTE	0AAH,00AH,000H,002H
;
TKBOYCS		EQU	$
		LDA	#002H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  TKBOYCD
		STA	<WORK8
		LDA	#HIGH TKBOYCD
		ADC	#000H
		STA	<WORK9
;
		JSL	>SETOAML		

		JSL	>SADWSTL
		RTS
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
;=============================================================
		END
;=============================================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW01IT		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR
;		PLB
;		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW02IT		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR
;		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT1IT		EQU	$
		PHB
		PHK
		PLB
		JSR	PINT100_I
		PLB
		RTL
;========================================
PINT100_I	EQU	$
		JSR	PINT1UC		;ENWRK0 - 3 <--- UNIT NO
;
		JSR	PINT1CK		;UNIT CHK.
PNT1I10		EQU	$
		RTS
;----------------------------------------
PT1UD10		EQU	$		;master unit (UL = 000H)
;			UL   UR   DL   DR
		BYTE	000H,002H,000H,001H
		BYTE	000H,002H,001H,001H
		BYTE	000H,000H,001H,002H
		BYTE	000H,001H,000H,002H
		BYTE	000H,001H,002H,001H
		BYTE	000H,000H,002H,001H
PT1UD11		EQU	$		;master unit (UL = 001H)
		BYTE	001H,002H,001H,000H
		BYTE	001H,002H,000H,000H
		BYTE	001H,001H,000H,002H
		BYTE	001H,000H,001H,002H
		BYTE	001H,000H,002H,000H
		BYTE	001H,001H,002H,000H
PT1UD12		EQU	$		;master unit (UL = 002H)
		BYTE	002H,001H,000H,001H
		BYTE	002H,000H,001H,000H
		BYTE	002H,000H,001H,001H
		BYTE	002H,001H,000H,000H
PT1UD13		EQU	$		;master unit (keisan you)
;-  -  -  -  -  -  -  -  -  -  -  -  -  -
PT1UD20		EQU	$		;chenge unit (UL = 000H)
;			U.No not  not  not
		BYTE	001H,000H,000H,000H
		BYTE	004H,000H,000H,000H
		BYTE	007H,000H,000H,000H
		BYTE	009H,000H,000H,000H
		BYTE	00AH,000H,000H,000H
		BYTE	00FH,000H,000H,000H
PT1UD21		EQU	$		;chenge unit (UL = 001H)
		BYTE	000H,000H,000H,000H
		BYTE	005H,000H,000H,000H
		BYTE	006H,000H,000H,000H
		BYTE	008H,000H,000H,000H
		BYTE	00BH,000H,000H,000H
		BYTE	00EH,000H,000H,000H
PT1UD22		EQU	$		;chenge unit (UL = 002H)
		BYTE	002H,000H,000H,000H
		BYTE	003H,000H,000H,000H
		BYTE	00CH,000H,000H,000H
		BYTE	00DH,000H,000H,000H
PT1UD23		EQU	$		;chenge unit (keisan you)
;-  -  -  -  -  -  -  -  -  -  -  -  -  -
PINT1CK		EQU	$
		LDA	ENWRK0,X
		CMP	#000H
		BNE	PT1CK10
		LDY	#PT1UD11-PT1UD10-4
PT1CK40		EQU	$
		LDA	ENWRK1,X		;unit 1 - 3 chk.
		CMP	PT1UD10+1,Y
		BNE	PT1CK50
		LDA	ENWRK2,X
		CMP	PT1UD10+2,Y
		BNE	PT1CK50
		LDA	ENWRK3,X
		CMP	PT1UD10+3,Y
		BNE	PT1CK50
;						;all ok !
		LDA	PT1UD20,Y
		STA	ENSTAT,X
		RTS
PT1CK50		EQU	$
		DEY
		DEY
		DEY
		DEY
		BPL	PT1CK40			;? not unit
;						;y
		BRA	PT1CK30
;
PT1CK10		EQU	$
		CMP	#001H
		BNE	PT1CK20
		LDY	#PT1UD12-PT1UD11-4
PT1CK60		EQU	$
		LDA	ENWRK1,X		;unit 1 - 3 chk.
		CMP	PT1UD11+1,Y
		BNE	PT1CK70
		LDA	ENWRK2,X
		CMP	PT1UD11+2,Y
		BNE	PT1CK70
		LDA	ENWRK3,X
		CMP	PT1UD11+3,Y
		BNE	PT1CK70
;						;all ok !
		LDA	PT1UD21,Y
		STA	ENSTAT,X
		RTS
PT1CK70		EQU	$
		DEY
		DEY
		DEY
		DEY
		BPL	PT1CK60			;? not unit
;						;y
		BRA	PT1CK30
;
PT1CK20		EQU	$
		CMP	#002H
		BNE	PT1CK30
		LDY	#PT1UD13-PT1UD12-4
PT1CK80		EQU	$
		LDA	ENWRK1,X		;unit 1 - 3 chk.
		CMP	PT1UD12+1,Y
		BNE	PT1CK90
		LDA	ENWRK2,X
		CMP	PT1UD12+2,Y
		BNE	PT1CK90
		LDA	ENWRK3,X
		CMP	PT1UD12+3,Y
		BNE	PT1CK90
;						;all ok !
		LDA	PT1UD22,Y
		STA	ENSTAT,X
		RTS
PT1CK90		EQU	$
		DEY
		DEY
		DEY
		DEY
		BPL	PT1CK80			;? not unit
;						;y
;		BRA	PT1CK30
;
PT1CK30		EQU	$
		STZ	ENMODE,X	;not unit
		RTS


;----------------------------------------
PT1YPDT		EQU	$		;UNIT POINT Y
		BYTE	000,000,008,008
PT1XPDT		EQU	$		;UNIT POINT X
		BYTE	000,008,000,008
PINT1UC		EQU	$
		LDY	#003H
PT1UC10		EQU	$
		LDA	ENYPSL,X
		CLC
		ADC	PT1YPDT,Y
		STA	<WORK0
		LDA	ENYPSH,X
		ADC	#000H
		STA     <WORK1
		LDA	ENXPSL,X
		CLC
		ADC	PT1XPDT,Y
		STA	<WORK2
		LDA	ENXPSH,X
		ADC	#000H
		STA	<WORK3
		LDA	#000H		;1 kai or 2 kai (level)
		JSL	>BGDTRD2
;					
		LDA	UNITNO
		STA	WORKC,Y
;
		DEY
		BPL	PT1UC10		;? 4 UNIT END
;					;Y
		LDA	<WORKC		;UNIT NO ---> ENWRK0 - 3
		STA	ENWRK0,X
		LDA	<WORKD
		STA	ENWRK1,X
		LDA	<WORKE
		STA	ENWRK2,X
		LDA	<WORKF
		STA	ENWRK3,X
;
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%      INITIAL                                   %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT2IT		EQU	$
;		PHB
;		PHK
;		PLB
;		JSR
;		PLB
		RTL
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW01MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PSW0100_M
		PLB
		RTL
;========================================
PSW0100_M	EQU	$
		JSR	PSW01CS
		JSR	ENSTCK          ; scroll : not return !
;
		JSL	>CRKNENL
		BCC	PSW0110		;? any atari
		LDA	AITMBT		;y
		AND	#00AH
		BEQ	PSW0110		;? HANMER atari
;					;y
;					;HANMER atari
		LDA	>KRXBUF		;ATARI !!
		EOR	#001H
		STA	>KRXBUF+1
		LDA	#001H
		STA	>KRXBUF
		RTS
PSW0110		EQU	$
		LDA	#000H
		STA	>KRXBUF
		STA	>KRXBUF+1
		RTS
;----------------------------------------
PSW01CS		EQU	$
		JSR	OAMCHK
;
		LDA	#000H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSW02MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PSW0200_M
		PLB
		RTL
;========================================
PSW0200_M	EQU	$
		JSR	PSW02CS
		JSR	ENSTCK          ; scroll : not return !
;
		JSL	>CRKNENL
		BCC	PSW2110		;? any atari
		LDA	AITMBT		;y
		AND	#00AH
		BEQ	PSW2110		;? HANMER atari
;					;y
;					;HANMER atari
		LDA	>KRXBUF+2		;ATARI !!
		EOR	#001H
		STA	>KRXBUF+3
		LDA	#001H
		STA	>KRXBUF+2
		RTS
PSW2110		EQU	$
		LDA	#000H
		STA	>KRXBUF+2
		STA	>KRXBUF+3
		RTS
;----------------------------------------
PSW02CS		EQU	$
		JSR	OAMCHK
;
		LDA	#001H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT1MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PINT100_M
		PLB
		RTL
;========================================
PINT100_M	EQU	$
		JSR	PINT1CS
		JSR	ENSTCK          ; scroll : not return !
;
		RTS
;----------------------------------------
PINT1CS		EQU	$
		JSR	OAMCHK
;
		LDA	#002H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PINT2MV		EQU	$
		PHB
		PHK
		PLB
		JSR	PINT200_M
		PLB
		RTL
;========================================
PINT200_M	EQU	$
		JSR	PINT2CS
		JSR	ENSTCK          ; scroll : not return !
;
		RTS
;----------------------------------------
PINT2CS		EQU	$
		JSR	OAMCHK
;
		LDA	#003H
		STA	<WORK0
		LDA	ENCLOR,X
		STA	<WORK1
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	<OAMADR
;
		LDA	ENDSXL
		STA	OAM-OAM,Y
		LDA	<WORK0
		AND	#0FEFFH
		STA	OAM-OAM+2,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		LDA	#000H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MURON move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MURONTM		EQU	$
		BYTE	060H,03CH,010H,008H,00CH,010H,00CH,020H
MURONDT		EQU	$
		BYTE	000H,001H,002H,001H,003H,001H,002H,001H
MURONMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MURON00
		PLB
		RTL
MURON00		EQU	$
		JSR	MURONCS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#LOW  MS_0000		; MSGE NO. SET
		LDY	#HIGH MS_0000		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
;
		LDA	ENATCT,X
		BNE	MURON60		;MAKI SET OK?
;
		LDA	MURONTM		;Y
		STA	ENTIM0,X
		STZ	ENCHPT,X
;
MURON60		EQU	$
		LDA	ENTIM0,X
		BNE	MURON10
;
		LDA	ENWRK0,X
		INC	A
		AND	#007H
		STA	ENWRK0,X
		STA	ENATCT,X
		TAY
		LDA	MURONTM,Y
		STA	ENTIM0,X
		LDA	MURONDT,Y
		STA	ENCHPT,X
		BNE	MURON10
		JSL	>MURMKST
;
MURON10		EQU	$
		LDA	ENCHPT,X
		BNE	MURON20
;
		STZ	ENWRK1,X
		STZ	ENWRK2,X
		STZ	ENSTAT,X
;
		LDA	#0FAH
		STA	ENMUKI,X
		STZ	ENCMKI,X
		RTS
;
MURONKI		EQU	$		;MAKI JAMP
		BYTE	006,003
;			0   1
MURON20		EQU	$		;MAKI TOBI
		LDA	<FRCNT
		AND	#003H
		BNE	MURON30
		DEC	ENWRK1,X		;MAKI12 X
MURON30		EQU	$
		LDA	<FRCNT
		AND	#007H
		BNE	MURON40
		INC	ENMUKI,X		;MAKI12 Z
		LDY	ENCMKI,X
		LDA	ENMUKI,X
		CMP	MURONKI,Y
		BNE	MURON40
		LDA	#0FDH
		STA	ENMUKI,X
		LDA	#001H
		STA	ENCMKI,X
MURON40		EQU	$
		LDA	<FRCNT
		AND	#001H
		BNE	MURON50
		LDA	ENSTAT,X		;MAKI2 Y
		SEC
		ADC	ENMUKI,X
		STA	ENSTAT,X
		LDA	ENWRK2,X		;MAKI1 Y
		CLC
		ADC	ENMUKI,X
		DEC	A
		STA	ENWRK2,X
MURON50		EQU	$
		RTS
;----------------------------------------
MURONCD		EQU	$
		BYTE	-022,-001,0C2H,000H
		BYTE	-028,-013,0C4H,000H
		BYTE	-016,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0E6H,000H
		BYTE	0004,0009,0E6H,000H
;
		BYTE	-014,0006,0E4H,000H
		BYTE	0000,0008,0C6H,000H
		BYTE	-014,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0EEH,0C0H
		BYTE	0004,0009,0EEH,000H
;
		BYTE	-015,0005,0E4H,000H
		BYTE	-001,0007,0C6H,000H
		BYTE	-015,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0EEH,0C0H
		BYTE	0004,0009,0EEH,000H
;
		BYTE	-014,0007,0E4H,000H
		BYTE	0000,0009,0C6H,000H
		BYTE	-015,-005,0C0H,000H
		BYTE	-018,0009,0E0H,000H
		BYTE	-010,0009,0E1H,000H
		BYTE	0004,0009,0EEH,0C0H
		BYTE	0004,0009,0EEH,000H
;
MURONCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
		LDA	ENCLOR,X
		STA	<WORK1
		STZ	<WORK0
;
		LDA	ENATCT,X		;MAKI SET ?
		STA	<WORKC
		STZ	<WORKD
;
		LDA	ENWRK1,X		;MAKI1 X
		STA	<WORK2
		LDA	ENWRK2,X		;MAKI1 Y
		STA	<WORK3
		LDA	ENWRK1,X		;MAKI2 X
		EOR	#0FFH
		INC	A
		STA	<WORK4
		LDA	ENSTAT,X		;MAKI2 Y
		STA	<WORK5
;
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
		LDY	<OAMADR
		LDA	#00004H
		STA	<WORKE
;
MUONC10		EQU	$
		LDA	MURONCD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	MURONCD+1,X
		CLC
		ADC	ENDSYL
		STA	OAM-OAM+1,Y
		LDA	MURONCD+2,X
		ORA	<WORK0
		STA	OAM-OAM+2,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	MUONC10
;
		LDA	<WORKC			;MAKI SET OK ?
		BEQ	MUONC20
;						;Y
		LDA	MURONCD,X		;MAKI1
		CLC
		ADC	ENDSXL
		CLC
		ADC	<WORK2
		STA	OAM-OAM,Y
		LDA	MURONCD+2,X
		ORA	<WORK0
		STA	OAM-OAM+2,Y
;
		LDA	MURONCD+4,X		;MAKI2
		CLC
		ADC	ENDSXL
		CLC
		ADC	<WORK4
		STA	OAM-OAM+4,Y
		LDA	MURONCD+6,X
		ORA	<WORK0
		STA	OAM-OAM+6,Y
MUONC20		EQU	$
;
;		LDY	<OSBADR
;
;		LDA	#0202H
;		STA	OAMSB-OAMSB,Y
;		STA	OAMSB-OAMSB+2,Y
;		STA	OAMSB-OAMSB+4,Y
;		STA	OAMSB-OAMSB+5,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#006H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;--------------------------------------
MURMKST		EQU	$			;MAKI HAKOBI SET
		LDA	#MURMK
		JSL	>ENIDSH
		BMI	MRMKS80
;
		TYA
		STA	ENCTFG,X
		TXA
		STA	ENCTFG,Y
;
		LDA	<WORK0
		CLC
		ADC	#00FH
		STA	ENXPSL,Y
;
		LDA	<WORK1
		ADC	#000H
		STA	ENXPSH,Y
;
		LDA	<WORK2
		CLC
		ADC	#080H
		STA	ENYPSL,Y
;
		LDA	<WORK3
		ADC	#000H
		STA	ENYPSH,Y
;
		LDA	<WORK4
		STA	ENZPSL,Y
;
		LDA	#000H
		STA	ENMUKI,Y
		STA	ENCHPT,Y
;
MRMKS80		EQU	$
		RTL
;----------------------------------------
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MURYA move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MURYATM		EQU	$
		BYTE	000H,010H,030H,050H
MURYADT		EQU	$
		BYTE	000H,001H,002H,000H
MURYAMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MURYA00
		PLB
		RTL
MURYA00		EQU	$
		JSR	MURYACS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#LOW  MS_0000		; MSGE NO. SET
		LDY	#HIGH MS_0000		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
;
		LDA	<KEYA2
		ROR	A
		AND	#001H
		BEQ	MURYA10		;LEFT ?
;
		LDA	#002H		;Y
		STA	ENMUKI,X
;
MURYA10		EQU	$
		BCC	MURYA20		;RIGHT ?
;
		LDA	#003H		;Y
		STA	ENMUKI,X
;
MURYA20		EQU	$
		LDA	<KEYA2
		AND	#0C0H
		BEQ	MURYA30		; A B ?
;
		INC	ENWRK0,X	;Y
;
MURYA30		EQU	$
		LDA	ENWRK0,X
		BNE	MURYA80
;
		STZ	ENCHPT,X
		STZ	ENTIM0,X
		LDA	#003H
		STA	ENWRK1,X
;
		RTS
;
MURYA80		EQU	$
		LDA	ENTIM0,X
		BNE	MURYA90
;
		LDA	ENWRK1,X
		INC	A
		AND	#003H
		STA	ENWRK1,X
		TAY
		CMP	#003H
		BNE	MURYAA0
		JSR	MURYAST
		DEC	ENWRK0,X
		LDY	ENWRK1,X
MURYAA0		EQU	$
		LDA	MURYATM,Y
		STA	ENTIM0,X
		LDA	MURYADT,Y
		STA	ENCHPT,X
;
MURYA90		EQU	$
		RTS
;----------------------------------------
MRYSTMK		EQU	$
		BYTE	000H,002H,004H,006H
MURYAST		EQU	$		;YA SET(PLY)
		LDA	ENXPSL,X
		STA	<BMWORK+2
		LDA	ENXPSH,X
		STA	<BMWORK+3
		LDA	ENYPSL,X
		STA	<BMWORK+0
		LDA	ENYPSH,X
		STA	<BMWORK+1
;
		PHX
		LDY	ENMUKI,X
		LDX	MRYSTMK,Y
		LDY	#004H		;KAZU
		LDA	#YAMOV
		JSL	>YAIMIT
		PLX
		RTS
;----------------------------------------
MURYACD		EQU	$
		BYTE	-002,0008,0E3H,000H
		BYTE	-002,0016,0E3H,080H
		BYTE	0000,0000,0ECH,000H
		BYTE	0000,0012,0EAH,000H
		BYTE	-010,0009,0E1H,000H;D
		BYTE	0004,0009,0E6H,000H;D
;
		BYTE	-007,0011,03BH,045H
		BYTE	0001,0012,038H,045H
		BYTE	-004,0008,0E3H,000H
		BYTE	-004,0016,0E3H,080H
		BYTE	0000,0000,0ECH,000H
		BYTE	-001,0011,0A6H,000H
;
		BYTE	-003,0011,03BH,045H
		BYTE	0005,0012,038H,045H
		BYTE	-004,0008,0CEH,000H
		BYTE	0000,0000,0ECH,000H
		BYTE	0000,0012,0EAH,000H
		BYTE	0004,0009,0EEH,0C0H;D
;
;
		BYTE	0010,0008,0E3H,040H
		BYTE	0010,0016,0E3H,0C0H
		BYTE	0000,0000,0ECH,040H
		BYTE	0000,0012,0EAH,040H
		BYTE	-010,0009,0E1H,040H;D
		BYTE	0004,0009,0E6H,040H;D
;
		BYTE	0015,0012,03BH,005H
		BYTE	0007,0012,038H,005H
		BYTE	0012,0008,0E3H,040H
		BYTE	0012,0016,0E3H,0C0H
		BYTE	0000,0000,0ECH,040H
		BYTE	0001,0012,0A6H,040H
;
		BYTE	0012,0012,03BH,005H
		BYTE	0004,0012,038H,005H
		BYTE	0004,0008,0CEH,040H
		BYTE	0000,0000,0ECH,040H
		BYTE	0000,0012,0EAH,040H
		BYTE	0004,0009,0EEH,080H;D
;
;
MRYACKD		EQU	$
		BYTE	003H,005H,004H
;
;
MURYASD		EQU	$
		BYTE	000H,000H,002H,002H,002H,002H
		BYTE	000H,000H,000H,000H,002H,002H
		BYTE	000H,000H,002H,002H,002H,002H
MURYACS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
                LDY     ENCHPT,X
                LDA     MRYACKD,Y
                STA     <WORK2
		TYA
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		STA	<WORK7
		STZ	<WORK8
;
                LDA     ENCLOR,X
                STA     <WORK1
                STZ     <WORK0
                LDA     ENMUKI,X
		AND	#001H
                STA     <WORK3
                STZ     <WORK4
                LDA     ENCHPT,X
                STA     <WORK5
                STZ     <WORK6
;
                PHX
                MEM16
                IDX16
                REP     #00110000B
;
                LDA     <WORK3
                ASL     A
                ASL     A
                ADC     <WORK5
                ASL     A
                ADC     <WORK3
                ADC     <WORK5
                ASL     A
                ASL     A
                ASL     A
                TAX
;
                LDA     <WORK2
                AND     #000FFH
                STA     <WORKE
;
                LDY     <OAMADR
MUYAC10		EQU	$
		LDA	MURYACD,X
		CLC
		ADC	ENDSXL
		STA	OAM-OAM,Y
		LDA	MURYACD+2,X
		EOR	<WORK0
		STA	OAM-OAM+2,Y
		INX
		INX
		INX
		INX
		INY
		INY
		INY
		INY
		DEC	<WORKE
		BPL	MUYAC10
;
                LDX     <WORK7
;
                LDY     <OSBADR
                LDA     MURYASD,X
                STA     OAMSB-OAMSB,Y
                LDA     MURYASD+2,X
                STA     OAMSB-OAMSB+2,Y
                LDA     MURYASD+4,X
                STA     OAMSB-OAMSB+4,Y
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	<WORK2
		LDY	#0FFH
		JSL	>ALOMCKL
		RTS
;--------------------------------------
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	MURMK move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MURMKDT		EQU	$-1
		BYTE	000H,004H,000H,005H
MURMKTT		EQU	$-1
		BYTE	0C8H,028H,0FFH,000H
;
MURMKMV		EQU	$
		PHB
		PHK
		PLB
		JSR	MURMK00
		PLB
		RTL
MURMK00		EQU	$
		JSR	MURMKCS
		JSR	ENSTCK		; scroll : not return !
;
;
		LDA	#LOW  MS_0000		; MSGE NO. SET
		LDY	#HIGH MS_0000		; MSGE NO. SET
		JSL	>ENMSGEL		; MEGE ?
;
		LDA	ENTIM0,X	;TIME ?
		BNE	MURMK10
;
		INC	ENWRK0,X	;NEXT MODE
		LDY	ENWRK0,X
		LDA	MURMKDT,Y
		STA	ENSTAT,X
		LDA	MURMKTT,Y
		STA	ENTIM0,X
;
MURMK10		EQU	$
		LDA	ENSTAT,X
		JSL	>JSRSUB
;
		WORD	MURMKM0		;UP MOVE
		WORD	MURMKM1		;DOWN
		WORD	MURMKM2		;LEFT
		WORD	MURMKM3		;RIGHT
		WORD	MURMKM4		;MAKI SET
		WORD	MURMKM5		;KILL I
;----------------------------------------
MRMKSXD		EQU	$
		BYTE	000,000,-10,010
MRMKSYD		EQU	$
		BYTE	-10,010,000,000
MURMKM0		EQU	$
MURMKM1		EQU	$
MURMKM2		EQU	$
MURMKM3		EQU	$
		LDA	ENSTAT,X
		STA	ENMUKI,X
		TAY
		LDA	MRMKSXD,Y
		STA	ENXSPD,X
		LDA	MRMKSYD,Y
		STA	ENYSPD,X
		JSR	ENMVCL		; xclc,yclc
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		AND	#001
		STA	ENCHPT,X
		RTS
;----------------------------------------
MURMKM4		EQU	$		;MAKI SET
		LDA	#002H		;MUKI
		STA	ENMUKI,X
;
		LDY	ENCTFG,X
		LDA	#001H
		STA	ENATCT,Y
;
		RTS
;----------------------------------------
MURMKM5		EQU	$		;KILL I
		STZ	ENMODE,X
		RTS
;----------------------------------------
MURMKCD		EQU	$
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,000H
;
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,040H
;
;
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,000H
;
		BYTE	000H,000H,0CCH,000H
		BYTE	000H,008H,0CAH,040H
;
;
		BYTE	000H,000H,0ECH,000H
		BYTE	000H,008H,0C8H,000H
;
		BYTE	000H,000H,0ECH,000H
		BYTE	000H,008H,0C8H,000H
;
;
		BYTE	000H,000H,0ECH,040H
		BYTE	000H,008H,0C8H,040H
;
		BYTE	000H,000H,0ECH,040H
		BYTE	000H,008H,0C8H,040H
;
;
MURMKCS		EQU	$
		JSR	OAMCHK
		JSL	>OCHECKL
;
		PHX
;
		LDA	ENMUKI,X
		ASL	A
		ADC	ENCHPT,X
		ASL	A
		ASL	A
		ASL	A
;
		MEM16
		IDX16
		REP	#00110000B
;
		AND	#000FFH
		TAX
;
		LDY	<OAMADR
;
		LDA	#00001
		STA	<WORK0
MURMC10		EQU	$
		LDA	ENDSXL
		CLC
		ADC	MURMKCD,X
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		LDA	MURMKCD,X
		ORA	<WORK4
		STA	OAM-OAM,Y
		INX
		INX
		INY
		INY
;
		DEC	<WORK0
		BPL	MURMC10
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		LDA	#001H
		LDY	#002H
		JSL	>ALOMCKL
		RTS
;
;-----Mihari heishi---------------------------------
MHMKDT		EQU	$
		HEX 	0,2,1,3
;
MIHA0M		EQU	$
		JSR	MIHA0CS
;
		JSR	ENSTCK
;
;;		JSL	>CRENPLL
;;		JSL	>CRKNENL
		JSR	CREKEK
;
		LDA	ENSTAT,X
		CMP	#03H
		BNE	MHM000		; found player ?
;					; yes !
		LDA	<FRCNT
		AND	#0FH
		BNE	MHM0F0
;
		LDA	ENMUKI,X
		INC	A
		AND	#03H
		STA	ENMUKI,X
		STA	ENCHPT,X
		STA	ENKBMK,X
		STZ	MIHAFG
MHM0F0		EQU	$
		RTS
;- -- - - - - - - - - - - - - - - - - - - - - - - - - - -
MHM000		EQU	$
		CMP	#00H
		BNE	MHM050
;
		LDA	ENTIM0,X
		BNE	MHW010
;
		LDA	#0A0H
		STA	ENTIM0,X
		INC	ENSTAT,X
;
		INC	ENCONT,X
		LDA	ENCONT,X
		AND	#03H
		TAY
		LDA	MHMKDT,Y
		STA	ENMUKI,X
		STA	ENCHPT,X
MHM010		EQU	$
MHW010		EQU	$
		RTS
;- - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - -
MHM050		EQU	$
		LDA	ENTIM0,X
		BNE	MHKY10
;
		LDA	#20H
		STA	ENTIM0,X
		STZ	ENSTAT,X
		RTS
;
MHKY10		EQU	$
         	JSR	H0SERC		; player serch !
;
		LDA	ENTIM0,X
;;		NOP
		LSR	A
		LSR	A
		LSR	A
		AND	#00000111B
		STA	<WORK0
		LDA	ENMUKI,X
		ASL	A
		ASL	A
		ASL	A
		ORA	<WORK0
		TAY
		LDA	H0KKBD,Y
		STA	ENKBMK,X
;		
		RTS
;- - - - - - - - - - - - - - - - - - - -
MHCXAD		EQU	$
		WORD	00,00,00
;
		WORD	00,00,00
;
		WORD	0FFFCH,04,04
;
		WORD	0FFFCH,04,04
MHCYAD		EQU	$
		WORD	00,00,00
;
		WORD	00,00,00
;
		WORD	00,00,00
;
		WORD	00,00,00
MHCCDT		EQU	$
		HEX	08,08,08
;
		HEX	08,08,08
;
		HEX	46,46,46
;
		HEX	64,64,64
MHCADT		EQU	$
		HEX	40,40,40
;
		HEX	00,00,00
;
		HEX	00,40,40
;
		HEX	00,40,40
MHCSBD		EQU	$
		HEX	02,02,02
;
		HEX	02,02,02
;
		HEX	02,02,02
;
		HEX	02,02,02
;- - - - - - - - - - - - - - - - - - - - - - - - - - -
MIHA0CS		EQU	$
;;		JSR	OAMCHK
		JSR	O2TEST
;
		JSR	H0HDCS
;
		LDY	#04H
		LDA	ENCHPT,X
		ASL	A
		ADC	ENCHPT,X
		STA	<WORK6
;
;;		LDA	ENCLOR,X
;;		STA	<WORK3
;
		PHX
		LDX	#02H
MHC010		EQU	$
		PHX
		TXA
		CLC
		ADC	<WORK6
		PHA
		ASL	A
		TAX
		MEM16
		REP	#00100000B
		LDA	<WORK0
		CLC
		ADC	MHCXAD,X
		STA	(<OAMADR),Y
		AND	#0100H
		STA	<WORKE
;
		LDA	<WORK2
		CLC
		ADC	MHCYAD,X
		INY
		STA	(<OAMADR),Y
		CLC
		ADC	#0010H
		CMP	#0100H
		BCC	MHC012
;
		LDA	#00F0H
		STA	(<OAMADR),Y
MHC012		EQU	$
		MEM8
		SEP	#00100000B
		PLX
		LDA	MHCCDT,X
		INY
		STA	(<OAMADR),Y
		LDA	MHCADT,X
		INY
		ORA	<WORK5
		STA	(<OAMADR),Y
		PHY
		TYA
		LSR 	A
		LSR	A
		TAY
		LDA	MHCSBD,X
		ORA	<WORKF
		STA	(<OSBADR),Y
		PLY
		INY
		PLX
		DEX
		BPL	MHC010
;
		PLX
;;		LDY	#0FFH
;;		LDA	#03H
;;		JSL	>ALOMCKL
		RTS
;
KAGI1DT		EQU	$
		WORD	1000000000000000B
		WORD	0100000000000000B
		WORD	0010000000000000B
		WORD	0001000000000000B
		WORD	0000100000000000B
		WORD	0000010000000000B
		WORD	0000001000000000B
		WORD	0000000100000000B
		WORD	0000000010000000B
		WORD	0000000001000000B
		WORD	0000000000100000B
		WORD	0000000000010000B
		WORD	0000000000001000B
		WORD	0000000000000100B
		WORD	0000000000000010B
		WORD	0000000000000001B
;----------------------------------------
KIANA00		EQU	$
		JSR	KIANACS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	ENSTAT,X
		BNE	KIANA10
;
		JSL	>CRENPL2L
		BCC	KIANA10
;
		MEM16			; S KEY CLS
		REP	#00100000B
		LDY	DJNNO
		LDA	KAGI1DT,Y
		AND	>KEYCNT
		BEQ	KIANA20
;
;;		EOR	>KEYCNT		;KEY CLS
;;		STA	>KEYCNT
;
		MEM8
		SEP	#00110000B
;
		LDA	#014H
		STA	SOUND3
;
		INC	SWCHFG		;SWICH ON
;		STZ	ENMODE,X
;
		INC	ENSTAT,X
;
		RTS
;----------------------------------------
KIANA20		EQU	$
		MEM8
		SEP	#00110000B
;
		LDA	ENTIM0,X
		BNE	KIANA10
;
		LDA	#LOW  MS_00DD	; MSGE NO. SET
		LDY	#HIGH MS_00DD	; MSGE NO. SET
		JSL	>ENMSGSL	; MEGE ?
		LDA	#020H
		STA	ENTIM0,X
KIANA10		EQU	$
		RTS
;----------------------------------------
KIANACD		EQU	$
		WORD	00000,00000
		BYTE	0E8H,000H,000H,002H
;
KIANACS		EQU	$
		LDA	#001H		;KAZU
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW  KIANACD	;ADD
		STA	<WORK8
		LDA	#HIGH KIANACD
		STA	<WORK9
;
		JSL	>SETOAML
		RTS
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	JIJI1 move	                    		  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JIJI1MV		EQU	$
		PHB
		PHK
		PLB
		JSR	JIJI100
		PLB
		RTL
JIJI100		EQU	$
		JSR	JIJI1CS
		JSR	ENSTCK		; scroll : not return !
;
		LDA	<DJFLG
		BEQ	JIJI120
		JSL	>ENMKIST	;MUKI SET
		JSR	EPXYCK		;pl muki set
		TYA
		EOR	#003H
		STA	ENCMKI,X
;
		RTS
JIJI120		EQU	$
		LDA	#LOW  MS_0000		; MSGE NO. SET
		LDY	#HIGH MS_0000		; MSGE NO. SET
		JSL	>ENMSGEL	; MEGE ?
		BCC	JIJI110		;
		STZ	ENSTAT,X	; PL. miru!
		STA	ENWRK0,X	; PL. miru!
		STA	ENMUKI,X	; PL. miru!
;
JIJI110		EQU	$
		JSR	ENMVCL		; xclc,yclc,BG check !
;;		JSL	>ENBGCKL		; BG check sub !
		JSR	ENBGCK
;
		LDA	ENSTAT,X
		JSL	>JSRSUB
		WORD	JIJI1M0
		WORD	JIJI1M1
;----------------------------------------
JIJI1SX		EQU	$
		BYTE	000H,000H,0FCH,003H
JIJI1SY		EQU	$
		BYTE	0FCH,003H,000H,000H
JIJI1M0		EQU	$
		LDA	ENTIM0,X
		BEQ	JI1M010
;
		LDA	ENCBFG,X
		AND	#00FH
		BEQ	JI1M020
JI1M010		EQU	$
		INC	ENSTAT,X
		LDA	#0FFH
		STA	ENTIM0,X
JI1M020		EQU	$
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ENCHPT,X
;
		LDY	ENMUKI,X
		LDA	JIJI1SX,Y
		STA	ENXSPD,X
		LDA	JIJI1SY,Y
		STA	ENYSPD,X
		TYA
		STA	ENWRK0,X
;
		RTS
;----------------------------------------
JIJI1M1		EQU	$
		LDA	ENTIM0,X
		BNE	JI1M120
;
		JSL	>RNDSET
		AND	#01FH
		CLC
		ADC	#0E0H
		STA	ENTIM0,X
;
		STZ	ENSTAT,X
		LDA	<FRCNT
		AND	#001H
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENMUKI,X
JI1M120		EQU	$
		STZ	ENXSPD,X
		STZ	ENYSPD,X
;
		TXA
		EOR	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		STA	<WORK0
		AND	#001H
		BNE	JI1M110
		LDA	<WORK0
		LSR	A
		ORA	#002H
		EOR	ENMUKI,X
		STA	ENWRK0,X
		RTS
;
JI1M110		EQU	$
		LDA	ENMUKI,X
		STA	ENWRK0,X
		RTS
;--------------------------------------
JIJI1CD		EQU	$
JIJI1CS		EQU	$
		RTS
;--------------------------------------
;
