;;   U S A 
;
;
		onbankgroup
;
;==============	バンク０ ================================================
BANK0		GROUP	0
;-------------<	ZCO >-------------
		extern	DATA_MOV,RAMCLR,RAMCL2,RNDSUB,OBJBG,SVOPEN,RAMCL3
		extern	SOUNDCLR,DJITRV,BGMSET,RAMCLR4
;
;-------------<	ZES >-------------
		extern	ENEMY,ENIDSHL,COHTITL,ITEMDPL,ENOMST,EN2CST,ECACH
		extern	EMOVE,EFAIL
;
;-------------<	ZBS >-------------
		extern	BGDTST,ENDTST,BGBKST,DJTKCK
;
;-------------<	ZPL >-------------
		extern	MSGCHK,FDIN,FDOUT,NXGOTO,ENEMYL,GKCHRV,MSCHNOR
		extern	ENEMYL1,PLCSET,GPLAY,NMREG,NMCLR,PSLCT,PINDR2
		extern	NMCPY,GPMAIN
;
;-------------<	ZMA >-------------
		extern	HIMITSU,VRMCL,VRMBT,BKCH2,BKCH3,WINDBGS,RBGST
		extern	PSLBGS,GVCHG,GOVBG,PSLBG2,NSLBGS,NCLBGS,GMAPBGS
		extern	VRMB2,DJBST,GRBST,GMBST,BLVRDS,GMAPCL,BNKTR
		extern	SPTST,BKCHG,TLCHG,ODCHG,NCPBGS,GRCST,TSVBG
;
;==============	バンク１ ================================================
BANK1		GROUP	1
;-------------<	ZS1 >-------------
		extern	GMRESET,CURSDST,CURSDSS,WANWANCK,TBGCST
;
;==============	バンク２ ================================================
BANK2		GROUP	2
;-------------<	ZEX >-------------
		extern	EXSTRA,COINIT,HARTIT,ITEMDP,WINDOW,ITEMDP2
;
;==============	バンク３ ================================================
BANK3		GROUP	3
;-------------<	ZEN >-------------
		extern	ENCAPS,BOMBR,BUMER,KTOBJ,PYAAA
;
;==============	バンク８ ================================================
BANK8		GROUP	8
;-------------<	ZBD >-------------
		extern	GRBGCR,BGUNCH
;
;==============	バンク１４ ==============================================
BANK14		GROUP	14H
;-------------<	ZDB >-------------
		extern	SKY,BKY
;
;========================================================================
	PUBALL
;
BANK1	GROUP	1
	LIB	ZRAM
;;;;;;;;;---sub---------------------------------------
;;;;;;;;	EXTERN	DATA_MOV,ENEMY,EXSTRA,RAMCLR,RAMCL2,BGDTST,GMRESET
;;;;;;;;	EXTERN	ENDTST,COINIT,HARTIT,ITEMDP,RNDSUB,WINDOW,ITEMDP2,MSGCHK
;;;;;;;;	EXTERN	ENIDSHL,OBJBG,ENCAPS,FDIN,FDOUT,NXGOTO,ENEMYL,SVOPEN,GKCHRV
;;;;;;;;	EXTERN	COHTITL,ITEMDPL,RAMCL3,BGBKST,SOUNDCLR,DJITRV,ENOMST,EN2CST
;;;;;;;;	EXTERN	CURSDST,CURSDSS,BGMSET,MSCHNOR
;;;;;;;;	EXTERN	WANWANCK,HIMITSU,RAMCLR4  ;,TOURCK
;;;;;;;;	EXTERN	ENEMYL1,TBGCST,PLCSET
;;;;;;;;	EXTERN	DJTKCK
;;;;;;;;;- -lavel -
;;;;;;;;	EXTERN	VRMCL,VRMBT,BKCH2,BKCH3,WINDBGS,RBGST,BOMBR,BUMER,KTOBJ,GRBGCR
;;;;;;;;	EXTERN	BGUNCH,ECACH,PYAAA,EMOVE,EFAIL,PSLBGS,GPLAY,GVCHG,GOVBG
;;;;;;;;	EXTERN	PSLBG2,NSLBGS,NMREG,NMCLR,NCLBGS,PSLCT,GMAPBGS,VRMB2
;;;;;;;;	EXTERN	PINDR2,DJBST,GRBST,GMBST,BLVRDS,GMAPCL,BNKTR,NMCPY,SPTST
;;;;;;;;	EXTERN	BKCHG,TLCHG,ODCHG,GPMAIN,NCPBGS,GRCST,TSVBG
;;;;;;;;	EXTERN	SKY,BKY
;- - - - - - - - - - - - - - - - - - -
	KANJI
	isdmg
	LIST
	ORG	$4000
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	強制セーブ  			     %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TSAVESB
	LD	A,(ITMODE)
	RST	0
	DW	TSV0800
	DW	TSV1000
	DW	TSV2000
	DW	TSV2800
	DW	TSV3000
	DW	TSV4000
;=====================================
TSV0800
	CALL	PLCSET
	CALL	ENEMYL1
;
	CALL	FDIN
;
	LD	A,(SBHR)
	CP	$04
	JR	NZ,TSV0810
;
	LD	A,$03
	LD	(SLEVEL),A
	LD	A,$30
	LD	(SLEVEL+1),A
;
	CALL	ITMINC
;
	XOR	A
	LD	(SCXAD),A
	LD	(WNDFLG),A
	LD	(FUETM),A
	LD	(FUETM2),A
	LD	(FUEFLG),A
;
	LD	A,VRMB2  ;CL
;;	LD	A,VRMCL
	LD	(BLNKFG),A
TSV0810
	RET
;=====================================
TSV1000
	LD	A,GVCHG
	LD	(BLNKFG),A
;
	XOR	A
	LD	(OVSLCT),A
;
	JP	ITMINC
;=====================================
TSV2000
;;	LD	A,SPTST
;;	LD	(BLNKFG),A
	LD	A,TSVBG
	LD	(VRFLG),A
;
	LD	A,$FF
	LD	(WNDYPS),A
;
	XOR	A
	LD	(SCCH),A
	LD	(SCCV),A
;
	LD	(SBHR),A
	LD	(SBCNT),A
;
	JP	ITMINC
;=====================================
TSV2800
	CALL	FDOUT
;
	LD	A,(SBHR)
	CP	$04
	JR	NZ,TSV2810
;
	CALL	ITMINC
TSV2810
	RET
;=====================================
TSV3000
	CALL	TSSLST	; Slect obj set
;
	LD	A,(KEYA2)
	AND	%10110000
	JR	Z,TSV3010
;
	LD	A,$13
	LD	(SOUND1),A	;(S)
;
	LD	A,(OVSLCT)
	CP	$01
	JR	Z,TSV3008	; Continue ?
;				; yes !
;;	CP	$00
;;	JR	Z,TSV3002	; With Save ?
;				; Yes !
;;;	LD	(SAVEFG),A	; Not continue flag !
	CALL	ITMINC
;
	XOR	A
	LD	(SBHR),A
	LD	(SBCNT),A
;
	LD	A,(DJFLAG)
	AND	A
	JR	Z,SSV0900
;
	XOR	A
	LD	(SHOPFG),A	; Shop BG initial !!
	LD	(ZZZFLG),A	;タリン ｚｚｚ セットフラグ
;
;	LD	A,(ONOFBLF)
;	AND	A
;	JR	Z,SSV0900	; On off block stage ?
;;				; yes !
;	LD	A,$05
;	LD	(ONOFTM),A	; On off block revise set !
;;
;	LD	A,(SWCHTM)
;	AND	A
;	JR	Z,SSV0900	; Swich on ?
;;				; Yes !
;	LD	A,$03 ;F2
;	LD	(CHTRF2),A ;TOURFG),A	; Swich down chr TR.
SSV0900
	RET
;;	JR	TSV3003
;
;;TSV3002
;;	CALL	DTSAVE
TSV3003
	XOR	A
	LD	(OBP0FG),A
	LD	(OBP1FG),A
	LD	(OBP0),A
	LD	(OBP1),A
	LD	(BGPFG),A
	LD	(BGP),A
;
	LD	A,(PLXPSL)
	LD	(WPLXPSL),A
	LD	A,(PLYPSL)
	LD	(WPLYPSL),A
;
	CALL	GMSTART
;
	LD	A,$80
	LD	(PLFLSH),A
	RET
;======================================
TSV3008
	CALL	SOUNDCLR	;(S)
;
	CALL	DTSAVE
;
	CALL	RAMCLR4
	CALL	GMRESET		; Game reset !
;========================================
DSPINT
	LD	A,%11000111	; ＯＢＪ ＢＧ ＯＮ ＬＣＤＣ スタート
	LD	(LCDC),A
	LD	(LCDCB),A
	LD	A,$07
	LD	(WDX),A
	LD	A,$80
	LD	(WNDYPS),A	; Window y pos set !
	LD	(WDY),A
	LD	A,$07
	LD	(SLEVEL),A	; sound level 1 MAX set !
	LD	A,$70
	LD	(SLEVEL2),A	; sound level 2 MAX set !
TSV3010
	RET
;=========================================
TSSLYS
	DB	$48,$58
TSSLST
	LD	HL,OVSLCT
;
	CALL	CURSDST	;(S)
;
	LD	A,(KEYA2)
	AND	%01001100
	JR	Z,TSSL00
;
	LD	A,(HL)
	INC	A
	AND	$01
	LD	(HL),A
TSSL00
;======== TEST =========
;	LD	A,(FRCNT)
;	AND	$07
;	JR	NZ,TSSL111
;;
;	LD	A,(LCDCB)
;	XOR	%00001000
;	LD	(LCDCB),A
;TSSL111
;;
;;
;	RET
;
	LD	E,(HL)
	LD	D,$00
;
	LD	HL,TSSLYS
	ADD	HL,DE
	LD	A,(HL)
;
	LD	HL,OAM+$18
	LD	(HLI),A	
	LD	A,$24
	LD	(HLI),A
	LD	A,$BE
	LD	(HLI),A
	LD	(HL),$00
	RET	
;==========================================
ODEMOSUB
;
MA0010
	LD	A,(PLTIM0)
	AND	A	
	JP	NZ,OD0010
;
;	LD	A,(LY)
;	CP	$60
;	JR	C,MA0010
;
	LD	E,$70
MA00111
	LD	A,$00
	LD	(BGP),A
;
	DB	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	DB	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;
	DEC	E
	JR	NZ,MA00111
;
	LD	E,$30
MA00112
	LD	A,$40
	LD	(BGP),A
	DEC	E
	JR	NZ,MA00112
;
	LD	E,$30
MA00113
	LD	A,$80
	LD	(BGP),A
	DEC	E
	JR	NZ,MA00113
;
	LD	E,$FF
MA00114
	LD	A,$C0
	LD	(BGP),A
;
	DB	0,0,0,0,0,0,0,0,0
	DB	0,0,0,0,0,0,0,0,0
;
	DEC	E
	JR	NZ,MA00114
;
	LD	E,$30
MA00115
	LD	A,$80
	LD	(BGP),A
	DEC	E
	JR	NZ,MA00115
;
;
	LD	E,$30
MA00116
	LD	A,$40
	LD	(BGP),A
	DEC	E
	JR	NZ,MA00116
;
OD0010
	XOR	A
	LD	(BGPFG),A
	LD	(BGP),A
	RET
;=========================================
;=	Game over sub			 =
;=========================================
PLOVERS
	LD	A,(PLSTAT)
	RST	0
	DW	POV1000
	DW	POV1800
	DW	POV1A00
	DW	POV2000
	DW	POV3000
;=====================================
PLOVCD
	DB	$6A,$6A,$6A,$6A
	DB	$6A,$6A,$6A,$6A
	DB	$6A,$6A,$00,$00
	DB	$00,$0A,$04,$06
	DB	$00,$0A,$04,$06
	DB	$00,$0A,$04,$06
;;	DB	$00,$0A,$04,$06
;;	DB	$00,$0A,$04,$06
;;	DB	$00,$0A,$04,$06
;;	DB	$00,$0A,$04,$06
PLOVCL
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1C
	DB	$1B
	DB	$1A
	DB	$19
	DB	$18
	DB	$17
	DB	$16
	DB	$15
	DB	$14
	DB	$13
	DB	$12
	DB	$11
	DB	$10
	DB	$10
	DB	$10
	DB	$10
	DB	$10
	DB	$10
	DB	$10
;
;	DB	%00000000
;	DB	%00000000
;	DB	%00000000
;	DB	%00000000
;	DB	%01010000
;	DB	%10100100
;	DB	%11100100
;	DB	%11100100
;	DB	%11100100
;	DB	%11100100
;	DB	%11100100
;	DB	%11100100
;
POV1000
	XOR	A
	LD	(TILTXD),A
	LD	(TILTYD),A
;
	LD	A,(PLTIM0)
	AND	A
	JR	NZ,POV1010
;
	LD	A,$10
	LD	(PLTIM0),A
;
	LD	A,$01
	LD	(PLSTAT),A
;
	LD	A,VRMB2  ;CL
	LD	(BLNKFG),A
;
	LD	A,$FF
	LD	(PLCHPT),A
;
	LD	A,(DETHCT)
	ADD	A,$01
	DAA
	LD	(DETHCT),A
;
	LD	A,(DETHCT+1)
	ADC	A,$00
	DAA
	LD	(DETHCT+1),A
	CP	$10
	JR	C,POV1008
;
	LD	A,$99
	LD	(DETHCT),A
	LD	A,$09
	LD	(DETHCT+1),A
POV1008
	XOR	A
	LD	(SCXAD),A
	LD	(ENFLCT),A
	LD	(POWRFG),A
	LD	(POWRCT),A
;;;	XOR	A
	LD	(FADEON),A
	LD	(FADECT),A
	LD	(FADECT2),A
;
	RET
POV1010
	RRA
	RRA
	RRA
	AND	%00111111
	LD	E,A
	LD	D,$00
	LD	HL,PLOVCD
	ADD	HL,DE
	LD	A,(HL)
	LD	(PLCHPT),A
;
	LD	A,(PLTIM0)
	RRA
	RRA
	RRA
;;	RRA
;;	RRA
	AND	$1F
	LD	E,A
	LD	HL,PLOVCL
	ADD	HL,DE
	LD	A,(HL)
	LD	(FADECT2),A
;;;;	LD	(FADECT),A
;;;;	LD	(BGPFG),A
;;;;	LD	(OBP1FG),A
;
	LD	A,$01
	LD	(FADEON),A
;
	LD	A,$01C
	LD	(OBP0FG),A
	LD	A,(BGPFG)
	LD	(OBP1FG),A
	RET	
;=====================================
POV1800
	LD	A,GVCHG
	LD	(BLNKFG),A
;
	LD	HL,PLSTAT
	INC	(HL)
	RET
;
;=====================================
POV1A00
	LD	A,$0E4
	LD	(BGPFG),A
;
	LD	A,GOVBG
	LD	(VRFLG),A
;
	LD	A,$FF
	LD	(WNDYPS),A
;
	XOR	A
	LD	(SCCH),A
	LD	(SCCV),A
;
	LD	HL,PLSTAT
	INC	(HL)
;
	CALL	DJITRV
	RET
;=====================================
PIYOYD
	DB	$00,$FE,$FD,$FE
	DB	$00,$02,$03,$02
PIYOXD
	DB	$00,$04,$08,$0C
	DB	$10,$0C,$08,$04
POV2000
	LD	A,(PLTIM0)
	AND	A
	JR	NZ,POV2010
;
	LD	HL,PLSTAT
	INC	(HL)
;
;;	LD	A,$03
;;	LD	($D368),A	;(S)
;	CALL	RNDSUB
;	LD	E,$03
;	AND	$01
;	JR	Z,POV2008
;	LD	E,$05
;POV2008
	LD	A,$03  ;E
	LD	(SOUND4),A	;(S)
POV2010
;PIYOST
;	LD	HL,OAM+$10
;;
;	LD	A,(FRCNT)
;	RRA
;	RRA
;	RRA
;	PUSH	AF
;	AND	%00000111
;;
;	CALL	PIYOSB
;;
;	POP	AF
;	ADD	A,$04
;	AND	%00000111
;PIYOSB
;	PUSH	HL
;;
;	LD	E,A
;	LD	D,$00
;	LD	HL,PIYOYD
;	ADD	HL,DE
;	LD	B,(HL)
;	LD	HL,PIYOXD
;	ADD	HL,DE
;	LD	C,(HL)
;;
;	POP	HL
;;
;	LD	A,(PLYPSL)
;	ADD	A,B
;	ADD	A,$F6
;	LD	(HLI),A
;	LD	A,(PLXPSL)
;	ADD	A,C
;	ADD	A,$FC
;	LD	(HLI),A
;;
;	LD	(HL),$24
;	INC	HL
;	LD	(HL),$00
;	INC	HL
	RET
;=====================================
POV3000
;;	CALL	PIYOST
;
	CALL	OVSLST	; Slect obj set
;
	LD	A,(KEYA2)
	AND	%10110000
	JR	Z,POV3010
;
	LD	A,(OVSLCT)
	CP	$01
	JR	Z,POV3008	; Continue ?
;				; yes !
	CP	$00
	JR	Z,POV3002	; With Save ?
;				; Yes !
	LD	(SAVEFG),A	; Not continue flag !
	JR	POV3003
;
POV3002
;;	LD	A,$01
;;	CALL	PBSET	
	CALL	DTSAVE
POV3003
	XOR	A
;
	LD	HL,ENMODE
	LD	E,ENNO
POV3005
	LD	(HLI),A
	DEC	E
	JR	NZ,POV3005
;
	LD	(OBP0FG),A
	LD	(OBP1FG),A
	LD	(OBP0),A
	LD	(OBP1),A
	LD	(BGPFG),A
	LD	(BGP),A
	LD	(ONOFFG),A
	LD	(WARPFG2),A
;
	LD	A,(PLXPSL)
	LD	(WPLXPSL),A
	LD	A,(PLYPSL)
	LD	(WPLYPSL),A
;
;;	LD	A,$01
;;	CALL	PBSET	
	CALL	GMSTART
;
;	LD	A,GPLAY
;	LD	(GMMODE),A
;	XOR	A
;	LD	(ITMODE),A
;;
;	LD	A,$17
;	LD	(HARTCT),A
;;
;	XOR	A
;	LD	(PLSTAT),A
;	LD	(HARTDW),A
;	LD	(COINUP),A
;	LD	(COINDW),A
;	INC	A
;	LD	(HARTUP),A	; Becouse Vram write !
;
;;;	CALL	OTDRST
;
	LD	A,$80
	LD	(PLFLSH),A
	RET
;======================================
POV3008
;;	LD	A,$01
;;	CALL	PBSET	
	CALL	DTSAVE
;
	CALL	GMRESET		; Game reset !
POV3010
	RET
;=========================================
OBSLYS
	DB	$50,$60,$70
;- - - - - - - - - - - - - - - - - - - -
OVSLST
	LD	HL,OVSLCT
;
	CALL	CURSDST	;(S)
;
	LD	A,(KEYA2)
	AND	%01001000
	JR	Z,OVSL00
;
	LD	A,(HL)
	INC	A
	CP	$03
	JR	NZ,OVSLF0
	XOR	A
OVSLF0
	LD	(HL),A
OVSL00
	LD	A,(KEYA2)
	AND	%00000100
	JR	Z,OVSL20
;
	LD	A,(HL)
	DEC	A
	CP	$FF
	JR	NZ,OVSL10
	LD	A,$02
OVSL10
	LD	(HL),A
OVSL20
	LD	E,(HL)
	LD	D,$00
;
	LD	HL,OBSLYS
	ADD	HL,DE
	LD	A,(HL)
;
	LD	HL,OAM+$18
	LD	(HLI),A	
	LD	A,$24
	LD	(HLI),A
	LD	A,$BE
	LD	(HLI),A
	LD	(HL),$00
	RET	
;========================================
;========================================
;****************************************
;*       GAME Play initial	        *
;****************************************
GPSUB
	LD	A,(ITMODE)
	RST	0
	DW	PLITF0
	DW	PLIT00
GPMAD	;;DW	PLIT06
	DW	PLIT08
	DW	PLIT10
	DW	PLIT20
	DW	PLIT30
	DW	PLIT40
	DW	GPMAIN
GPM	EQU	$2  ;Return From Map display 1!
GPMA	EQU	$7  ;8  ;Return From Map display 2!
;===========================================
DAMPFGD	; ﾀﾞﾝｼﾞｮﾝ ﾏｯﾌﾟ ｺｳｾｲ ﾃﾞｰﾀ
	DB	%00000000 ;0
	DB	%00000000 ;1
	DB	%00000000 ;2
	DB	%00000000 ;3
	DB	%00000000 ;4
	DB	%00000000 ;5
	DB	%00110000 ;6
	DB	%00000000 ;7
	DB	%00000000
	DB	%00000000
	DB	%00000000
	DB	%00000000
	DB	%00000000
;======================================
PLITF0
	CALL	SOUNDCLR
;
	CALL	ITMINC
;
	LD	A,(DJFLAG)
	AND	A
	JR	Z,PLITF8
;- - Danjyon item buffer set - - -
	LD	A,(DNJNNO)
	LD	E,A
	SLA	A
	SLA	A
	ADD	A,E
	LD	E,A
	LD	D,$00
	LD	HL,DMAPF1
	ADD	HL,DE
	LD	DE,DMAPF
;
	LD	C,$05
PLITF01
	LD	A,(DNJNNO)
	CP	DJMAX ;$20
	LD	A,(DNJNNO)
	CP	$08
	JR	Z,PLITF011
	JR	C,PLITF02	; Danjyon item not display ?
PLITF011
	XOR	A		; yes !
	JR	Z,PLITF03
PLITF02
	LD	A,(HLI)
PLITF03
	LD	(DE),A
	INC	DE
	DEC	C
	JR	NZ,PLITF01
;
	LD	A,(DNJNNO)
	LD	E,A
	LD	D,$00
;
	LD	HL,DAMPFGD
	ADD	HL,DE
	LD	A,(HL)
	LD	(DAMPFG),A
;
	LD	A,E
	CP	$08
	JR	Z,PLITFA
	CP	DJMAX ;$20
	JR	NC,PLITFA	; Normal danjyon ?
;				; yes ! map set !
	CP	$06
	JR	NZ,PLITF7
;
	LD	A,(YKFLAG)
	AND	A
	JR	NZ,PLITFA
PLITF7
;;	LD	A,$1
;;	CALL	PBSET
;
	CALL	DMAPSUB
;
	LD	A,BLVRDS
	LD	(VRFLG),A
;;
;	CALL	RNDSUB
;	LD	HL,FRCNT
;	OR	(HL)
;	AND	$03	
;	LD	(PANELMD),A	;順番パネル秘密テーブルセット
	RET
;--------------------------------
PLITF8
	LD	A,WINDBGS
	LD	(VRFLG),A
;
	CALL	RNDSUB
	LD	HL,FRCNT
	OR	(HL)
	AND	$03	
	LD	(PANELMD),A	;順番パネル秘密テーブルセット
	RET
;--------------------------------
PLITFA	; レベル７雲BGセット！    Window Map clear 
	LD	A,GMAPCL
	LD	(VRFLG),A
	RET
;===========================================
PLIT00
	CALL	RAMCL3
	XOR	A
	LD	(PLMODE),A
;
	CALL	ITMINC
;
	LD	A,(WPLXPSL)
	LD	(PLXPSL),A
	LD	(PLITXS),A
	LD	A,(WPLYPSL)
	LD	(PLYPSL),A
	LD	(PLITYS),A
;
	LD	A,(NXRMPZ)
	LD	(PLZPSL),A
	AND	A
	JR	Z,PLIT011
;
	LD	A,$02
	LD	(PLJPFG),A
PLIT011
	LD	A,$04
	LD	(SCRLMK),A	; Not scroll !
;
	CALL	BGDTST		; BG data set
;
	CALL	ENDTST		; Enemy data set
;
	CALL	WANWANCK	;ワンワンセットチェック
;
;;	CALL	TOURCK
;
	LD	A,$FF
	LD	(CHTRCT),A	;すぐ転送するため！
;
	LD	A,(DJFLAG)
	AND	A
	JR	Z,PI0088
;
	LD	D,A
;
	LD	A,(DNJNNO)
	CP	DJROOM2 ;$20
	JR	NC,PTKS010
	CP	DJROOM ;$20
	JR	C,PTKS010
	INC	D
PTKS010
	LD	A,(GRNDPT)
	LD	E,A
	CALL	DJTKCK
	CP	SKY
	JR	Z,PTKS100
	CP	BKY
	JR	Z,PTKS100
;
	LD	A,(NAZOFG)
	AND	%11100000
	CP	%10000000
	JR	NZ,PI0088 ;カギおってくる謎？
;			;YES !
PTKS100
	LD	A,(KONPF)
	AND	A
	JR	Z,PI0088 ;コンパス？
;
	LD	A,(DJSVBF)
	AND	%00010000
	JR	NZ,PI0088 ;取った？
;
	LD	A,$0C
	LD	(KEYSDON),A
;;	CALL	TOURCK
PI0088
;
	LD	A,(DJFLAG)
	AND	A
	LD	A,DJBST		; Bank set!
	JR	NZ,PI0090	; Danjyon ?
;				; yes !
	LD	A,GRBST		; Bank set!
PI0090
	LD	(BLNKFG),A
PI009A
	RET
;===========================================
;PLIT06
;	LD	A,WINDBGS
;	LD	(VRFLG),A
;;
;;	LD	A,$0F
;;	LD	(BKCHNO),A
;;;
;;	CALL	BGBKST		; BG bank set!
;	JP	ITMINC
;===========================================
PLIT08
	LD	A,$0F
	LD	(BKCHNO),A
;
	CALL	BGBKST		; BG bank set!
	XOR	A
	LD	(BKCHFG),A
	LD	(BKCHF2),A
;;	LD	(FADEON),A
;
;	LD	A,$0
;	LD	(EBANK0),A
;	LD	A,$1
;	LD	(EBANK1),A
;	LD	A,$2
;	LD	(EBANK2),A
;	LD	A,$3
;	LD	(EBANK3),A
;
	LD	A,BNKTR
	LD	(BLNKFG),A
;
;
;
;
;
;	LD	A,$06
;	LD	(BKCHNO),A
;	LD	(BKCHFG),A
;
;	LD	A,$2
;	LD	(ITMODE),A
ITMINC
	LD	HL,ITMODE
	INC	(HL)
;;;	CALL	ITMINC
	RET
;===========================================
PLIT10
	LD	A,RBGST		; Room BG initial set
	LD	(BLNKFG),A
;
	LD	A,(ONOFBLF)
	AND	A
	JR	Z,PI101010	; On off block stage ?
;				; yes !
	LD	A,$05
	LD	(ONOFTM),A	; On off block revise set !
;
	LD	A,(SWCHTM)
	AND	A
	JR	Z,PI101010	; Swich on ?
;				; Yes !
	LD	A,$03 ;F2
	LD	(CHTRF2),A ;TOURFG),A	; Swich down chr TR.
PI101010
	CALL	ITMINC
	RET
;===========================================
PLIT20
;;	LD	A,$2
;;	CALL	PBSET
;
	CALL	COHTITL	 ; Coint & heart display
;
	CALL	ITMINC
	RET
;===========================================
PLIT30
;;	LD	A,$2
;;	CALL	PBSET
;
	CALL	ITEMDPL	; Item window display
;
	CALL	ITMINC
	RET
;===========================================
PLIT40
;	LD	A,$80
;	LD	(WNDYPS),A
;	LD	A,$06
;	LD	(WDX),A		; Item window position initial 
;;
;	LD	A,$08
;	LD	(WNDSPD),A	; Item window speed initial
	CALL	WINDIT ;Window pos initial
;
	LD	A,(LCDC)
	OR	%00100000	; Window on !
	LD	(LCDCB),A
	LD	(LCDC),A
;
;;	LD	A,GPLAY
;;	LD	(GMMODE),A
;	LD	A,$6
;	LD	(ITMODE),A
	CALL	ITMINC
;
;;	LD	A,(GRNDPT)
;;	AND	$0F
;;	CP	$08
;;	LD	A,(DJFLAG)
;;	AND	A
OTDRST
	LD	A,(PLMODE)
	LD	(WPLMODE),A
;
	LD	A,PINDR2
;;	JR	Z,PI4300
;;;
;;	LD	A,POTDR2
;;PI4300
	LD	(PLMODE),A
;
	XOR	A
	LD	(SBHR),A
	LD	(SBCNT),A
;
	LD	A,(FADEON)
	AND	A
	JR	Z,PIT4050
;
	LD	A,(FADEBP)
	LD	(BGPFG),A
;
	LD	A,$1C
	LD	(OBP0FG),A
	LD	A,$E4
	LD	(OBP1FG),A
;
	LD	A,$04
	LD	(SBHR),A
PIT4050
	JP	BGMSET
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%				  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSLCHK
	LD	A,(KEYA2)
	AND	%10010000
	JP	Z,TLM000
;
PSLCTGO
	LD	(STARTFG),A
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PSLGO
	CALL	SVOPEN	;(SV)
;--SAVEDATA => WORK BUFFER 
	LD	A,(NAME+0-SAVEBF+SAVEI1)
	LD	(NAMEBF+00),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+1-SAVEBF+SAVEI1)
	LD	(NAMEBF+01),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+2-SAVEBF+SAVEI1)
	LD	(NAMEBF+02),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+3-SAVEBF+SAVEI1)
	LD	(NAMEBF+03),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+4-SAVEBF+SAVEI1)
	LD	(NAMEBF+04),A
;
	CALL	SVOPEN	;(SV)
	LD	A,(HARTCT-SAVEBF+SAVEI1)
	LD	(HARTCTF),A
	CALL	SVOPEN	;(SV)
	LD	A,(HARTMX-SAVEBF+SAVEI1)
	LD	(HARTMXF),A
;
	CALL	SVOPEN	;(SV)
	LD	A,(DETHCT-SAVEBF+SAVEI1)
	LD	(DETHCTF),A
	CALL	SVOPEN	;(SV)
	LD	A,(DETHCT+1-SAVEBF+SAVEI1)
	LD	(DETHCTF+1),A
;--
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+0-SAVEBF+SAVEI2)
	LD	(NAMEBF+05),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+1-SAVEBF+SAVEI2)
	LD	(NAMEBF+06),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+2-SAVEBF+SAVEI2)
	LD	(NAMEBF+07),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+3-SAVEBF+SAVEI2)
	LD	(NAMEBF+08),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+4-SAVEBF+SAVEI2)
	LD	(NAMEBF+09),A
;
	CALL	SVOPEN	;(SV)
	LD	A,(HARTCT-SAVEBF+SAVEI2)
	LD	(HARTCTF+1),A
	CALL	SVOPEN	;(SV)
	LD	A,(HARTMX-SAVEBF+SAVEI2)
	LD	(HARTMXF+1),A
;
	CALL	SVOPEN	;(SV)
	LD	A,(DETHCT-SAVEBF+SAVEI2)
	LD	(DETHCTF+2),A
	CALL	SVOPEN	;(SV)
	LD	A,(DETHCT+1-SAVEBF+SAVEI2)
	LD	(DETHCTF+3),A
;--
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+0-SAVEBF+SAVEI3)
	LD	(NAMEBF+$0A),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+1-SAVEBF+SAVEI3)
	LD	(NAMEBF+$0B),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+2-SAVEBF+SAVEI3)
	LD	(NAMEBF+$0C),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+3-SAVEBF+SAVEI3)
	LD	(NAMEBF+$0D),A
	CALL	SVOPEN	;(SV)
	LD	A,(NAME+4-SAVEBF+SAVEI3)
	LD	(NAMEBF+$0E),A
;
	CALL	SVOPEN	;(SV)
	LD	A,(HARTCT-SAVEBF+SAVEI3)
	LD	(HARTCTF+2),A
	CALL	SVOPEN	;(SV)
	LD	A,(HARTMX-SAVEBF+SAVEI3)
	LD	(HARTMXF+2),A
;
	CALL	SVOPEN	;(SV)
	LD	A,(DETHCT-SAVEBF+SAVEI3)
	LD	(DETHCTF+4),A
	CALL	SVOPEN	;(SV)
	LD	A,(DETHCT+1-SAVEBF+SAVEI3)
	LD	(DETHCTF+5),A
;--
;
;;	XOR	A
;;	LD	(NMSLPT),A
;
	LD	A,PSLCT   ; Goto player select
	LD	(GMMODE),A
	XOR	A
	LD	(ITMODE),A
;
	XOR	A
	LD	(SCCV),A
	LD	(SCCH),A
;
DISPCL
	LD	A,%00000000	; パレット データ セット
	LD	(BGPFG),A
	LD	(OBP0FG),A
	LD	(OBP1FG),A
TLM000
	RET
;===============================
ITITDT	; Inchiki test data
	DB	1,2,3,4,5,6,7,8,9,10,11,12
	DB	1,1,1,1,0
	DB	1,1,1,1,0
	DB	1,1,1,1,1
	DB	1,1,1,1,2
	DB	1,1,1,1,3
	DB	1,1,1,1,4
	DB	1,1,1,1,5
	DB	1,1,1,1,6
	DB	1,1,1,1,7
	DB	1,1,1,1,8
	DB	1,1,1,1,9
ITITDD
;
NAMESET
;- - Have item initial - - - -
;;	CALL	SVOPEN	;(SV)
;
	LD	DE,$0000
	CALL	SAVECK
	LD	DE,SAVED2-SAVEDT
	CALL	SAVECK
	LD	DE,SAVED3-SAVEDT
	CALL	SAVECK
;
	LD	A,(HIMITSU)
	AND	A
	JP	Z,NMSRET
;
	LD	E,$0
	LD	D,$0
;
	LD	BC,SAVEI1  ;ITEMB
PI3000
	LD	HL,ITITDT
	ADD	HL,DE
	LD	A,(HLI)
	LD	(BC),A
	INC	BC
	INC	E
	LD	A,E
	CP	ITITDD-ITITDT
	JR	NZ,PI3000
;
	LD	A,$01
	LD	(KENLEV-SAVEBF+SAVEI1),A
	LD	A,$01
	LD	(TATLEV-SAVEBF+SAVEI1),A
	LD	A,$02
	LD	(BULLEV-SAVEBF+SAVEI1),A
;
;	LD	HL,GRKEY1-SAVEBF+SAVEI1
;	LD	E,$4
;PI3010
;	LD	(HLI),A
;	DEC	E
;	JR	NZ,PI3010
;
	LD	HL,WARPSV-SAVEBF+SAVEI1
	LD	E,$9
	LD	A,%00000010
PI3011
	LD	(HLI),A
	DEC	E
	JR	NZ,PI3011
;
	LD	A,$60
	LD	(BOMBCT-SAVEBF+SAVEI1),A
	LD	(YAMAX-SAVEBF+SAVEI1),A
	LD	(BOMAX-SAVEBF+SAVEI1),A
	LD	(YAAACT-SAVEBF+SAVEI1),A
;
	LD	A,$40
	LD	(PWMAX-SAVEBF+SAVEI1),A
	LD	(TUBOCT-SAVEBF+SAVEI1),A
;
	LD	A,$89
	LD	(RODCT-SAVEBF+SAVEI1),A
	LD	A,$00
	LD	(CLC20-SAVEBF+SAVEI1),A
	LD	A,%00000111
	LD	(ONPUFG-SAVEBF+SAVEI1),A
;
	LD	A,$5
	LD	(COINC1-SAVEBF+SAVEI1),A
	LD	A,$09
	LD	(COINC2-SAVEBF+SAVEI1),A
	LD	A,$01
	LD	(PAPA0FG-SAVEBF+SAVEI1),A
;
	LD	A,$50
	LD	(HARTCT-SAVEBF+SAVEI1),A
	LD	A,$A
	LD	(HARTMX-SAVEBF+SAVEI1),A
;;	LD	A,$06
;;	LD	(KBINF-SAVEBF+SAVEI1),A
;
	LD	A,$5B
	LD	(NAME+0-SAVEBF+SAVEI1),A
	LD	A,$46
	LD	(NAME+1-SAVEBF+SAVEI1),A
	LD	A,$4D
	LD	(NAME+2-SAVEBF+SAVEI1),A
	LD	A,$45
	LD	(NAME+3-SAVEBF+SAVEI1),A
	LD	A,$42
	LD	(NAME+4-SAVEBF+SAVEI1),A
;
	LD	A,$00
	LD	(DETHCT-SAVEBF+SAVEI1),A
	LD	(DETHCT+1-SAVEBF+SAVEI1),A
;
	LD	A,$0  ;$01
	LD	(WANFLG-SAVEBF+SAVEI1),A
	LD	(CONTBF+0-SAVEBF+SAVEI1),A
;
	LD	A,$00
	LD	(CONTBF+1-SAVEBF+SAVEI1),A
;
	LD	A,$92  ;D6 ;7F  ;$50
	LD	(CONTBF+2-SAVEBF+SAVEI1),A
;
	LD	A,$48
	LD	(CONTBF+3-SAVEBF+SAVEI1),A
	LD	A,$62
	LD	(CONTBF+4-SAVEBF+SAVEI1),A
;
	LD	HL,GRRMSV-SAVERM+SAVEB1
	LD	A,$80
	LD	E,$00
NS0090
	LD	(HLI),A
	DEC	E
	JR	NZ,NS0090
;
NMSRET
	RET
;
;====Save data check ==========================
SAVECK
	LD	C,$01
	LD	B,$05
;
	LD	HL,SAVED1
	ADD	HL,DE
SVCK10
	CALL	SVOPEN	;(SV)
	LD	A,(HLI)
	CP	C
	JR	NZ,SVCK20
;
	INC	C
	INC	C
	DEC	B
	JR	NZ,SVCK10	
;
	JR	SVCK50
SVCK20
	PUSH	DE
;
;	LD	HL,SAVED1
;	ADD	HL,DE
;	LD	A,$01
;SVCK30
;	CALL	SVOPEN	;(SV)
;	LD	(HLI),A
;	INC	A
;	INC	A
;	CP	$0B
;	JR	C,SVCK30
;
	LD	HL,SAVED1+5
	ADD	HL,DE
	LD	DE,$100+$200+$7F+$01
SVCK40
	CALL	SVOPEN	;(SV)
	XOR	A
	LD	(HLI),A
	DEC	DE
	LD	A,E
	OR	D
	JR	NZ,SVCK40
;
	POP	DE
	LD	HL,SAVED1
	ADD	HL,DE
	LD	A,$01
SVCK30
	CALL	SVOPEN	;(SV)
	LD	(HLI),A
	INC	A
	INC	A
	CP	$0B
	JR	C,SVCK30
SVCK50
	RET
;****************************************
;*      Player select                   *
;****************************************
PLSLCTS
	CALL	NAMECK
;
	LD	A,(ITMODE)
	RST	0
	DW	PSLINTE
	DW	PSLINTF
	DW	PSLINT01
	DW	PSLINT02
	DW	PSLINT03
	DW	PSLINT0
	DW	PSLINT1
;;	DW	PSLINT2
	DW	PSLMAI0
	DW	PSLMAI1
	DW	PSLMAI2
;---------------------------------------
PSLINTE
	LD	A,BKCH2
	LD	(BLNKFG),A
;
	XOR	A
	LD	(NAMEOK),A
	JP	ITMINC
;---------------------------------------
PSLINTF
	LD	A,VRMBT
	LD	(BLNKFG),A
	JP	ITMINC
;---------------------------------------
;USDTH
;	DB	$98,$98,$98,$98,$99,$99,$99,$99
;USDTL
;	DB	$A7,$A8,$A9,$AA,$07,$08,$09,$0A
;
;---------------------------------------
PSLINT01
	CALL	HART1ST
	CALL	HART2ST
	JP	ITMINC
;---------------------------------------
PSLINT02
	CALL	HART3ST
	JP	ITMINC
;---------------------------------------
PSLINT03
ALLDETHST
	LD	A,(NAMEON)
	AND	%00000001
	JR	Z,DS0010
;
	LD	A,(DETHCTF+0)
	LD	H,A
	LD	A,(DETHCTF+1)
	LD	L,A
;
	LD	DE,$98E7
	CALL	DETHCST
DS0010
	LD	A,(NAMEON)
	AND	%00000010
	JR	Z,DS0020
;
	LD	A,(DETHCTF+2)
	LD	H,A
	LD	A,(DETHCTF+3)
	LD	L,A
;
	LD	DE,$9947
	CALL	DETHCST
;
DS0020
	LD	A,(NAMEON)
	AND	%00000100
	JR	Z,DS0030
;
	LD	A,(DETHCTF+4)
	LD	H,A
	LD	A,(DETHCTF+5)
	LD	L,A
;
	LD	DE,$99A7
	CALL	DETHCST
DS0030
	JP	ITMINC
	RET
;---------------------------------------
PSLINT0
	JP	ALLNMST
;
;	LD	BC,$98C6
;	LD	DE,NAMEBF
;	CALL	NAMEDP
;;
;	LD	BC,$9926
;	LD	DE,NAMEBF+4
;	CALL	NAMEDP
;;
;;	LD	BC,$9986
;;	LD	DE,NAMEBF+8
;;	CALL	NAMEDP
;;
;;	LD	HL,NAMEBF+8
;;	LD	E,$8
;;	XOR	A
;;PSI001
;;	LD	(HLI),A
;;	DEC	E
;;	JR	NZ,PSI001
;;
;	JP	ITMINC
;- - - - - - - - - - - - - - - - - - - - - - - 
NAMEDP
;--- Moji set ---
	PUSH	DE
;
	LD	A,(VRAMD)
	LD	E,A
	LD	D,$0
	LD	HL,VRAMD+1
	ADD	HL,DE
	ADD	A,$10
;;	ADD	A,$E
	LD	(VRAMD),A
;
	LD	A,B
	LD	(HLI),A
	LD	A,C
	LD	(HLI),A
	LD	A,$04
;;	LD	A,$03
	LD	(HLI),A
;
	POP	DE
	PUSH	DE
;
	LD	A,$05
;;	LD	A,$04
NM1D08
	LD	(WORK0),A
;
	LD	A,(DE)
	AND	A
	LD	A,BETA  ;$DF
	JR	Z,NM1D0C	; Not word ?
;				; yes ! beta !
	LD	A,(DE)
	DEC	A
;;	AND	$3F
	PUSH	BC
	PUSH	HL
	LD	C,A
	LD	B,$00
	CALL	MSCHNOR
	POP	HL
	POP	BC
NM1D0C
	LD	(HLI),A
	INC	DE
	LD	A,(WORK0)
	DEC	A
	JR	NZ,NM1D08
;
	LD	A,B
	LD	(HLI),A
	LD	A,C
	SUB	$20
	LD	(HLI),A
	LD	A,$04
;;	LD	A,$03
	LD	(HLI),A
;- - -Daketen set ---
;;	LD	DE,NAMEBF
	POP	DE
	LD	A,$05
;;	LD	A,$04
NM1D18
	LD	(WORK0),A
;
	LD	A,(DE)
	AND	A
	JR	NM1D19
;;	JR	Z,NM1D19
	DEC	A
	AND	%11000000
NM1D19
	LD	A,BETA   ;$DF
	JR	NM1D1E
;;	JR	Z,NM1D1E
;
	LD	A,(DE)		
	AND	%10000000
	LD	A,$C8
	JR	Z,NM1D1E
	INC	A
NM1D1E
	LD	(HLI),A
	INC	DE
	LD	A,(WORK0)
	DEC	A
	JR	NZ,NM1D18
;
	XOR	A
	LD	(HL),A
	RET
;
;
;
;
;
;
;
;;;; 柴原 使えええ！！！
;;
;	LD	C,$0
;	LD	B,C
;	LD	E,C
;	LD	D,C
;	XOR	A
;	LD	(WORK0),A
;	LD	(WORK1),A
;;
;	LD	HL,VRAMD+1
;USSBLP
;	PUSH	HL
;	LD	HL,NAMEBF
;	ADD	HL,BC
;	LD	A,(HL)
;	POP	HL
;	AND	A
;	JR	Z,UBETA
;;
;	LD	A,C
;	AND	A
;	JR	Z,USB2
;;
;	LD	A,(WORK0)
;	AND	A
;	JR	NZ,USB2
;;
;	DEC	BC
;	PUSH	HL
;	LD	HL,NAMEBF
;	ADD	HL,BC
;	LD	A,(HL)
;	POP	HL
;	SUB	$01
;	AND	$3F
;	LD	E,A
;	JR	MOJI
;;
;;
;;
;USB2
;	PUSH	HL
;	LD	HL,NAMEBF
;	ADD	HL,BC
;	LD	A,(HL)
;	POP	HL
;	SUB	$01
;	LD	E,A
;	AND	$C0
;	JR	Z,MOJI
;
; 	XOR	A
;	LD	(WORK0),A
;	BIT	7,E
;	JR	NZ,DAKTEN
;;
;	LD	E,$C8
;	JR	SBVSET
;;
;DAKTEN
;	XOR	A
;	LD	(WORK0),A
;	LD	E,$C7
;	JR	SBVSET
;;
;UBETA
;	LD	E,$DF
;	JR	SBVSET
;;
;MOJI
;	LD	A,$20
;	LD	(WORK0),A
;;
;SBVSET
;	PUSH	HL
;	LD	HL,USDTH
;	ADD	HL,BC
;	LD	A,(HL)
;	POP	HL
;;;	LD	HL,VRAMD+1
;	LD	(HLI),A
;;
;	PUSH	HL
;	LD	HL,USDTL
;	ADD	HL,BC
;	LD	A,(WORK0)
;	ADD	A,(HL)
;;
;	POP	HL
;	LD	(HLI),A
;;
;	XOR	A
;	LD	(HLI),A
;;
;	LD	A,E
;	LD	(HLI),A
;;
;	LD	A,C
;	CP	$07
;	JR	Z,PS0END
;;;
;	INC	BC
;	JR	USSBLP
;;
;PS0END
;;
;	XOR	A
;	LD	(HL),A
;;
;;	LD	A,$1
;;	LD	(ITMODE),A
;	JP	ITMINC
;;	RET
;---------------------------------------
PSLINT1
	LD	A,(STARTFG)
	AND	A
	JR	Z,PSLI110
;
	XOR	A
	LD	(STARTFG),A
;
	LD	A,$11
	LD	(SOUND4),A	;(S)
PSLI110
;	LD	E,$7+4	; 3 of names!
;	LD	C,$0
;	LD	HL,NAMEBF
;PSI100
;	LD	A,(HLI)
;	OR	C
;	LD	C,A
;	DEC	E
;	LD	A,E
;	CP	$FF
;	JR	NZ,PSI100
;;
;	LD	A,C
;	LD	(NAMEON),A
;
	LD	A,(NAMEON)
	AND	A
	LD	A,PSLBGS
	JR	Z,PSI110	; Already name reg. ?
;				; yes ! KILL MODE BG set !
	LD	A,PSLBG2
PSI110
	LD	(VRFLG),A
;
;;	LD	A,$2
;;	LD	(ITMODE),A
;;	RET
;
	LD	A,%11100100	; パレット データ セット
	LD	(BGPFG),A
	LD	A,%00011100	; パレット データ セット
	LD	(OBP0FG),A
	LD	A,%11100100	; パレット データ セット
	LD	(OBP1FG),A
;
	JP	ITMINC
;---------------------------------------
;PSLINT2
;	LD	A,BKCH2
;	LD	(BLNKFG),A
;;
;	LD	A,%11100100	; パレット データ セット
;	LD	(BGPFG),A
;	LD	A,%00011100	; パレット データ セット
;	LD	(OBP0FG),A
;	LD	A,%11100100	; パレット データ セット
;	LD	(OBP1FG),A
;;
;	JP	ITMINC
;---------------------------------------
FYOPDT
	DB	$3B,$53,$6B,$83
;---------------------------------------
PSLMAI0
	CALL	CURSDST	;(S)
;
	LD	A,(KEYA2)
	AND	%10010000
	JR	Z,PSLM10	; Start ?
;				; yes !
	JP	ITMINC
;;	LD	A,$4
;;	LD	(ITMODE),A
;;	RET
PSLM10
;;; 妖精カ−ソル　セット　柴原 やらんかあああ！！！
;;; 誰が  柴原ですねん！！！　い−ですよ，い−ですよ　森田さん！
;;

	LD	A,(KEYA2)
;;;	AND	$0C
	AND	%01001100
	JR	Z,FOJA3
;
	LD	C,$02
	LD	A,(NAMEON)
	AND	A
	JR	Z,FOJA
;
	INC	C
FOJA
	LD	A,(KEYA2)
	BIT	6,A
	JR	NZ,FDOWN2
	BIT	2,A
	JR	NZ,FOUP
;
FDOWN2
	LD	A,(NMSLPT)
	ADD	A,$01
	INC	C
	CP	C
	JR	C,FOJA2
;
	XOR	A
	JR	FOJA2
;
FOUP
	LD	A,(NMSLPT)
	SUB	$01
	JR	NC,FOJA2
;
	LD	A,C
;
FOJA2
	LD	(NMSLPT),A
;
FOJA3
	LD	A,(NMSLPT)
	CP	$03
	JR	NZ,PSLM100
;
	LD	A,(KEYA2)
	AND	%00000011
	JR	Z,SL3020
;
	CALL	CURSDSS	;(S)
;
	LD	A,(NAMEOK)
	XOR	$01
	LD	(NAMEOK),A
SL3020
	LD	A,(FRCNT)
	AND	$10
	JR	NZ,PSLM100
;
	LD	A,(NAMEOK)
	AND	A
	LD	A,$2C
	JR	Z,SL3030
	LD	A,$64
SL3030	
	LD	HL,OAM+$08
	LD	(HL),$88
	INC	HL
	LD	(HLI),A
;
	LD	A,$BE
	LD	(HLI),A
;
	XOR	A
	LD	(HL),A
PSLM100
;===================================
FOAMSET
	LD	A,(NMSLPT)
	LD	E,A
	LD	D,$0
	LD	HL,FYOPDT
	ADD	HL,DE
;
	LD	A,(FRCNT)
	AND	%00001000
	JR	Z,FO0010
;
	LD	A,(HL)
	LD	HL,OAM
	PUSH	AF
	LD	(HLI),A
	LD	A,$18
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
	POP	AF
	LD	(HLI),A
	LD	A,$20
	LD	(HLI),A
;
	LD	A,$02
	LD	(HLI),A
;
	LD	A,$00
	LD	(HL),A
;
	RET
;----------------------------------
FO0010
	LD	A,(HL)
	LD	HL,OAM
	PUSH	AF
	LD	(HLI),A
	LD	A,$18
	LD	(HLI),A
;
	LD	A,$02
	LD	(HLI),A
;
	LD	A,$20
	LD	(HLI),A
	POP	AF
	LD	(HLI),A
	LD	A,$20
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
;
	LD	A,$20
	LD	(HL),A
;
	RET
;
;---------------------------------------
PSLMAI1
	LD	A,(NMSLPT)
	CP	$03
	JR	Z,PSM190	; Name kill ?
;
	LD	A,(NMSLPT)
	LD	E,A
	SLA	A
	SLA	A
	ADD	A,E
	LD	E,A
	LD	D,$00
	LD	C,$05
;;	LD	C,$04
	LD	HL,NAMEBF
	ADD	HL,DE
;
PS1008
	LD	A,(HLI)
	AND	A
	JR	NZ,PS100C
;
	DEC	C
	JR	NZ,PS1008	; Already Name in?
;				; NO ! goto touroku!
	XOR	A
	LD	(ITMODE),A
;
	LD	A,NMREG
	LD	(GMMODE),A
KETTEIS
;決定音セット
	LD	A,$13
	LD	(SOUND1),A	;(S)
	RET
PS100C
	CALL	KETTEIS	;(S)
;
	LD	A,%00000000	; パレット データ セット
	LD	(BGPFG),A
	LD	(OBP0FG),A
	LD	(OBP1FG),A
;
	LD	A,BKCH3
	LD	(BLNKFG),A	; BG bank revise !
;
	JP	ITMINC	; Goto game !!
PSM190
	XOR	A
	LD	(ITMODE),A
;
	LD	A,(NAMEOK)
	AND	A
	LD	A,NMCLR		; KILL
	JR	Z,PSM1A0
;
	LD	A,NMCPY		; COPY
PSM1A0
	LD	(GMMODE),A
	JP	KETTEIS	;(S)
;---------------------------------------
SVDTAD
	DW	SAVEI1
	DW	SAVEI2
	DW	SAVEI3
SVDTAD2
	DW	SAVEB1
	DW	SAVEB2
	DW	SAVEB3
SVDTAD3
	DW	SAVED1
	DW	SAVED2
	DW	SAVED3
;
PSLMAI2
;	LD	A,(NMSLPT)
;	LD	E,A
;	LD	D,$00
;	LD	HL,HARTCTF
;	ADD	HL,DE
;	LD	A,(HL)
;	LD	(HARTCT),A
;	LD	HL,HARTMXF
;	ADD	HL,DE
;	LD	A,(HL)
;	LD	(HARTMX),A
;	SLA	E
;	LD	HL,DETHCTF
;	ADD	HL,DE
;	LD	A,(HL)
;	LD	(DETHCT),A
;;
;	SLA	E
;	LD	HL,NAMEBF
;	ADD	HL,DE
;	LD	A,(HLI)
;	LD	(NAME),A
;	LD	A,(HLI)
;	LD	(NAME+1),A
;	LD	A,(HLI)
;	LD	(NAME+2),A
;	LD	A,(HLI)
;	LD	(NAME+3),A
;
	JP	GMSTART
;****************************************
;*      Name regi                       *
;****************************************
NMREGIS
	LD	A,(ITMODE)
	RST	0
	DW	NRF0000
	DW	NR00000
	DW	NR10000
;;;	DW	NR20000
;--------------------------------------
NRF0000
	CALL	ITMINC
;;
;	LD	A,(NMSLPT)
;	SLA	A
;	SLA	A
;	LD	E,A
;	LD	D,$00
;	LD	C,$4
;	LD	HL,NAMEBF
;	ADD	HL,DE
;;
;NRF008
;	LD	A,(HLI)
;	AND	A
;	JR	NZ,NRF00C
;;
;	DEC	C
;	JR	NZ,NRF008	; Already Name in?
;;				; yes ! goto touroku!
	LD	A,VRMBT
	LD	(BLNKFG),A
;	
;;	LD	A,$4
;;;;	LD	(SCCH),A
;;	LD	(SCCV),A
;
	XOR	A
	LD	(NRNMPT),A
	LD	(NRWDPT),A
	LD	(MRWDPT),A
	RET
;;- - - - - - - - - - - - - - - - - -
;NRF00C
;	CALL	ITMINC 		; Goto game !
;	JP	NR1010
;--------------------------------------
NR00000
	LD	A,NSLBGS
	LD	(VRFLG),A
;
	LD	HL,VRAMD+1
	LD	A,$98
	LD	(HLI),A
	LD	A,$48
	LD	(HLI),A
	XOR	A
	LD	(HLI),A
	LD	A,(NMSLPT)
	ADD	A,$AB
	LD	(HLI),A
	XOR	A
	LD	(HL),A
;
	JP	ITMINC
;--------------------------------------
NRNMAD
	DB	0,$5,$0A
;;	DB	0,4,8
;
NR10000		; Name registration main !
	LD	A,(NMSLPT)
	LD	E,A
	LD	D,$00
	LD	HL,NRNMAD
	ADD	HL,DE
	LD	E,(HL)
	LD	HL,NAMEBF
	ADD	HL,DE
	PUSH	HL
	POP	DE
;
;	LD	DE,NAMEBF	; 1P
;;
;	LD	A,(NMSLPT)
;	CP	$01
;	JR	NZ,NR1008
;;
;	LD	DE,NAMEBF+4	; 2P
;NR1008
	LD	BC,$9849
;;	LD	BC,$984A
	CALL	NAMEDP
;
	LD	A,(KEYA2)
	AND	%10000000
	JR	Z,NMR010
;
NR1010
	CALL	KETTEIS	;(S)
;;;;	DATA SAVE SET
;
;	LD	A,(NMSLPT)
;	LD	E,A
;	LD	D,$00
;
;	CP	$00
;	JR	Z,SSSWW
;;
;	LD	HL,HARTCTF
;	ADD	HL,DE
;	LD	(HL),$18
;	LD	HL,HARTMXF
;	ADD	HL,DE
;	LD	(HL),$03
;;
;SSSWW
;	SLA	E
;	LD	HL,DETHCTF
;	ADD	HL,DE
;	XOR	A
;	LD	(HLI),A
;	LD	(HL),A
;
	LD	A,(NMSLPT)
	SLA	A
	LD	E,A
	LD	D,$00
	LD	HL,SVDTAD
	ADD	HL,DE
	LD	A,(HLI)
	LD	H,(HL)
	LD	L,A
	PUSH	HL
	LD	DE,NAME-SAVEBF
	ADD	HL,DE
	PUSH	HL
;
	LD	A,(NMSLPT)
	LD	E,A
	SLA	A
	SLA	A
	ADD	A,E
	LD	E,A
	LD	D,$00
	LD	HL,NAMEBF
	ADD	HL,DE
	LD	A,(HLI)
	CP	$5B
	JR	NZ,NMSD10
	LD	A,(HLI)
	CP	$46
	JR	NZ,NMSD10
	LD	A,(HLI)
	CP	$4D
	JR	NZ,NMSD10
	LD	A,(HLI)
	CP	$45
	JR	NZ,NMSD10
	LD	A,(HLI)
	CP	$42
	JR	NZ,NMSD10	;Z E L D A ?
;				;YES !
	LD	A,$60
	LD	(SOUND4),A	;(S)
;
NMSD10
	LD	HL,NAMEBF
	ADD	HL,DE
	POP	BC
;
;;	CALL	SVOPEN	;(SV)
;
	LD	E,$05
;;	LD	E,$04
NMS010
	CALL	SVOPEN	;(SV)
	LD	A,(HLI)
	LD	(BC),A
	INC	BC
	DEC	E
	JR	NZ,NMS010
;
	POP	HL
	PUSH	HL
	LD	DE,HARTCT-SAVEBF
	ADD	HL,DE
	LD	(HL),$18
;
	POP	HL
	PUSH	HL
	LD	DE,HARTMX-SAVEBF
	ADD	HL,DE
	LD	(HL),$03
;
	POP	HL
	LD	DE,DETHCT-SAVEBF
	ADD	HL,DE
	XOR	A	
	LD	(HLI),A
	LD	(HL),A
;
	JP	PSLGO	; Back to the player select mode !
;- - - - - - - - - - - - - - - - - - - - - - - -
NMR010
	CALL	NMRSUB
	CALL	NMRSUB2			;;;;;;;;;;;;;;;; BOMB
;;;	CALL	NMRSUB3			;;;;;;;;;;;;;;;; BOMB
	RET
;-----------------------------------------------
CARYDT
	DB	$38,$38,$38,$38,$38,$38,$38,$38,$38,$38,$38,$38,$38,$38,$38,$38
	DB	$48,$48,$48,$48,$48,$48,$48,$48,$48,$48,$48,$48,$48,$48,$48,$48
	DB	$58,$58,$58,$58,$58,$58,$58,$58,$58,$58,$58,$58,$58,$58,$58,$58
	DB	$68,$68,$68,$68,$68,$68,$68,$68,$68,$68,$68,$68,$68,$68,$68,$68
;;	DB	$78,$78,$78,$78,$78,$78,$78,$78,$78,$78,$78,$78,$78,$78,$78,$78
;
CARXDT
	DB	$14,$1C,$24,$2C,$34,$3C,$44,$4C,$54,$5C,$64,$6C,$74,$7C,$84,$8C
	DB	$14,$1C,$24,$2C,$34,$3C,$44,$4C,$54,$5C,$64,$6C,$74,$7C,$84,$8C
	DB	$14,$1C,$24,$2C,$34,$3C,$44,$4C,$54,$5C,$64,$6C,$74,$7C,$84,$8C
	DB	$14,$1C,$24,$2C,$34,$3C,$44,$4C,$54,$5C,$64,$6C,$74,$7C,$84,$8C
;;	DB	$14,$1C,$24,$2C,$34,$3C,$44,$4C,$54,$5C,$64,$6C,$74,$7C,$84,$8C
;
C2XDT
	DB	$4C,$54,$5C,$64,$6C
;
NMZHYO
	DB	$42,$43,$44,$45,$46,$47,$48,0,0,$62,$63,$64,$65,$66,$67,$68
	DB	$49,$4A,$4B,$4C,$4D,$4E,$4F,0,0,$69,$6A,$6B,$6C,$6D,$6E,$6F
	DB	$50,$51,$52,$53,$54,$55,$56,0,0,$70,$71,$72,$73,$74,$75,$76
	DB	$57,$58,$59,$5A,$5B,000,000,0,0,$77,$78,$79,$7A,$7B,000,000
;
;	DB	$01,$06,$0B,$10,$15,$1A,$1F,$24,$27,$2C,$00,$86,$8B,$90,$9A,$5A
;	DB	$02,$07,$0C,$11,$16,$1B,$20,$25,$28,$2D,$00,$87,$8C,$91,$9B,$5B
;	DB	$03,$08,$0D,$12,$17,$1C,$21,$26,$29,$3F,$00,$88,$8D,$92,$9C,$5C
;	DB	$04,$09,$0E,$13,$18,$1D,$22,$2F,$2A,$30,$00,$89,$8E,$93,$9D,$5D
;	DB	$05,$0A,$0F,$14,$19,$1E,$23,$40,$2B,$2E,$00,$8A,$8F,$94,$9E,$5E
;
;SBHDT
;	DB	$0C,$9A,$1A,$27
;===============================================
NMRSUB
;;	さっさとやらんかあ 柴原あああ ！！
;;      フラグが立っていた場合 
;
	LD	A,(KEYA2)
NMRS10
	LD	(WORK0),A
	LD	A,(WORK0)
	AND	$0C
	JR	NZ,UD	
;
	LD	A,(WORK0)
	AND	$03
;;	JR	Z,TLMAIN ;;;;;;;;;COAMSET
	JR	NZ,LR ;;;;;;;;;COAMSET
;
	LD	A,(KEYA1)
	LD	HL,WDMVCT
	AND	$0F
	JR	NZ,NMRS20
;
	XOR	A
	LD	(HL),A
	JR	NMRS30
NMRS20
	LD	A,(HL)
	INC	A
	LD	(HL),A
	CP	$18
	JR	NZ,NMRS30
;
;;	LD	A,$15
	LD	(HL),$15 ;A
	LD	A,(KEYA1)
	JR	NMRS10
NMRS30
	JR	TLMAIN
;===============================
LR
	CALL	CURSDSS	;(S)
;
	BIT	1,A
	JR	NZ,CLEFT
;
	LD	A,(NRWDPT)
	ADD	A,$01
	CP	$40     
	JR	C,LRMAIN
;
	XOR	A
	JR	LRMAIN
;
CLEFT
	LD	A,(NRWDPT)
	SUB	$01
	CP	$FF
	JR	NZ,LRMAIN
;
	LD	A,$3F   
	JR 	LRMAIN
;------------------------------------
UD
	CALL	CURSDSS	;(S)
;
	BIT	2,A
	JR	Z,UE
;
	LD	A,(NRWDPT)
	SUB	$10
	JR	NC,LRMAIN   
;
	ADD	A,$40           
	JR	LRMAIN     
;
UE
	LD	A,(NRWDPT)
	ADD	A,$10
	CP	$40             
	JR	C,LRMAIN   
;
	SUB	$40		
LRMAIN
	LD	(NRWDPT),A
	JR	TL2MAIN
;
TLMAIN
;
;	LD	A,(FRCNT)
;	AND	%00010000
;	JR	Z,COMRET
;
TL2MAIN
	LD	A,(NRWDPT)
	LD	HL,CARXDT
	LD	C,A
	LD	B,$0
	ADD	HL,BC
	LD	E,(HL)
;
	LD	A,(NRWDPT)
	LD	HL,CARYDT
	LD	C,A
	LD	B,$0
	ADD	HL,BC
	LD	D,(HL)
;------------------------------------
COAMSET
	LD	HL,OAM
;
	LD	A,D
	ADD	A,$B
	LD	(HLI),A
;
	LD	A,E
	ADD	A,$4
	LD	(HLI),A
;
	LD	A,$E0
	LD	(HLI),A
;
	XOR	A
	LD	(HL),A
;
COMRET
	RET
;======================================
NMRSUB2
	LD	A,(KEYA2)		
	AND	$30
	JR	Z,T2MAIN
;
	BIT	5,A
	JR	NZ,BACKB
;
INCA
	CALL	KETTEIS	;(S)
	CALL	NMRSUB3
;
	LD	A,(MRWDPT)
	ADD	A,$01
	CP	$05
;;	CP	$04
	JR	C,ABMAIN
;
	LD	A,$04
;;	LD	A,$03
	JR	ABMAIN
;
;===================================
BACKB
	CALL	KETTEIS	;(S)
;
	LD	A,(MRWDPT)
	SUB	$01
	CP	$FF
	JR	NZ,ABMAIN
;
	XOR	A
ABMAIN
	LD	(MRWDPT),A
;
T2MAIN
	LD	A,(MRWDPT)
	LD	HL,C2XDT
	LD	C,A
	LD	B,$0
	ADD	HL,BC
	LD	E,(HL)
;
C2OSET
	LD	A,(FRCNT)
	AND	%00010000
	JR	Z,C2RET
;
	LD	HL,OAM+4
;
	LD	A,$18
	ADD	A,$B
	LD	(HLI),A
;
	LD	A,E
	ADD	A,$4
	LD	(HLI),A
;
	LD	A,$E0
	LD	(HLI),A
;
	XOR	A
	LD	(HL),A
;
C2RET
	RET
;======================================
NMRSUB3
	LD	A,(NRWDPT)
	LD	C,A
	LD	B,$00
	LD	HL,NMZHYO
	ADD	HL,BC
	LD	A,(HL)
	LD	E,A
;--serclet---
;	LD	A,(MRWDPT)
;	LD	C,A
;	LD	HL,SBHDT	
;	ADD	HL,BC
;	LD	E,(HL)
;--
	LD	A,(NMSLPT)
;;	RLCA
;;	RLCA
	LD	C,A
	SLA	A
	SLA	A
	ADD	A,C
	LD	C,A
	LD	HL,NAMEBF
	ADD	HL,BC
	LD	A,(MRWDPT)
	LD	C,A
	ADD	HL,BC
	LD	(HL),E
;
	RET	
;--------------------------------------
;NR20000
;	CALL	GMSTART
;	RET
;****************************************
;*      Name clear                      *
;****************************************
NMCLERS
	CALL	NAMECK
;
	LD	A,(ITMODE)
	RST	0
	DW	NC00000
	DW	NC10000
	DW	NC18000
	DW	NC18002
	DW	NC18003
	DW	NC18004
	DW	NC20000
	DW	NC30000
;--------------------------------------
NC00000
	LD	A,VRMBT
	LD	(BLNKFG),A
;
	XOR	A
	LD	(NMSLPT),A
	LD	(NAMEOK),A
	JP	ITMINC
;--------------------------------------
NC10000
	LD	A,NCLBGS
	LD	(VRFLG),A
	JP	ITMINC
;--------------------------------------
NC18000
ALLNMST
	CALL	NAME1ST
	CALL	NAME2ST
	CALL	NAME3ST
	JP	ITMINC
;--------------------------------------
NC18002
ALLHTST
	CALL	HART1ST
	CALL	HART2ST
	JP	ITMINC
;--------------------------------------
NC18003
	CALL	HART3ST
	JP	ITMINC
;--------------------------------------
NC18004
	JP	ALLDETHST
;-------------------------------------------
NAME1ST
	LD	BC,$98C5
	LD	DE,NAMEBF
	JP	NAMEDP
NAME2ST
	LD	BC,$9925
	LD	DE,NAMEBF+5
	JP	NAMEDP
NAME3ST
	LD	BC,$9985
	LD	DE,NAMEBF+$A
	JP	NAMEDP
;-------------------------------------------
HART1ST
	LD	A,(NAMEON)
	AND	%00000001
	JR	Z,HT1S90	; Name aru ?
;				; yes !
	LD	A,$00
	LD	(WORK4),A
;
	LD	A,(HARTCTF)
	LD	(WORK2),A
	LD	A,(HARTMXF)
	LD	(WORK3),A
	JP	NHARTIT
HT1S90
	RET
;-------------------------------------------
HART2ST
	LD	A,(NAMEON)
	AND	%00000010
	JR	Z,HT1S90
;
	LD	A,$01
	LD	(WORK4),A
;
	LD	A,(HARTCTF+1)
	LD	(WORK2),A
	LD	A,(HARTMXF+1)
	LD	(WORK3),A
	JP	NHARTIT
;-------------------------------------------
HART3ST
	LD	A,(NAMEON)
	AND	%00000100
	JR	Z,HT1S90
;
	LD	A,$02
	LD	(WORK4),A
;
	LD	A,(HARTCTF+2)
	LD	(WORK2),A
	LD	A,(HARTMXF+2)
	LD	(WORK3),A
	JP	NHARTIT
;-------------------------------------------
NMCLD1
	DB	$98,$A5,$44,$7E
	DB	$98,$C5,$44,$7E
;	DB	$98,$E7,$4A,$7E
;	DB	$00,$00,$00,$00
;
NMCLD2
	DB	$99,$05,$44,$7E
	DB	$99,$25,$44,$7E
;	DB	$99,$47,$4A,$7E
;	DB	$00,$00,$00,$00
;
NMCLD3
	DB	$99,$65,$44,$7E
	DB	$99,$85,$44,$7E
;	DB	$99,$A7,$4A,$7E
;	DB	$00,$00,$00,$00
;-----------------------------------------
NC20000
	CALL	CURSDST	;(S)
;
;	LD	A,(KEYA2)
;	AND	%10000000
;	JR	Z,NC2020
;;
;	JP	PSLGO
;NC2020
	LD	A,(KEYA2)
	AND	%01001000
	JR	Z,NC2040
;
	LD	A,(NMSLPT)
	INC	A
	AND	$03
	LD	(NMSLPT),A
;
;	LD	A,(NMSLPT)
;	XOR	$1
;	LD	(NMSLPT),A
NC2040
	LD	A,(KEYA2)
	AND	%00000100
	JR	Z,NC2042
;
	LD	A,(NMSLPT)
	DEC	A
	CP	$FF
	JR	NZ,NC2041
	LD	A,$03
NC2041
	LD	(NMSLPT),A
NC2042
	LD	A,(KEYA2)
	AND	%10010000
	JR	Z,NC2050
;
	LD	A,(NMSLPT)
	CP	$03
	JR	NZ,NC2043
;
	JP	PSLGO
NC2043
	CALL	KETTEIS	;(S)
	CALL	ITMINC
	JR	OKSET
;====================================
QUITOKD
	DB	$99,$E4,$0D
	DB	$7E,$7E
	DB	$10,$14,$08,$13,$7E,$7E,$7E,$7E,$0E,$0A
	DB	$7E,$7E
	DB	$00
;- - - - - - - - - - - - - - - -
OKSET
	LD	HL,VRAMD+1
	LD	DE,QUITOKD
	LD	C,$11
OKST10
	LD	A,(DE)
	INC	DE
	LD	(HLI),A
;
	DEC	C
	LD	A,C
	CP	$FF
	JR	NZ,OKST10
;	
	RET
;;	CALL	ITMINC
NC2050
	CALL	FOAMSET
	RET
;--------------------------------------
NC30000
	LD	A,(KEYA2)
	BIT	5,A
	JR	NZ,NC3001
;
	AND	%10010000
	JR	Z,NC3010
;
	LD	A,(NAMEOK)
	AND	A
	JP	Z,PSLGO ;NC3001	; CLEAR OK ?
;				; YES !
;	LD	A,(NMSLPT)
;	RLA
;	RLA
;	LD	E,A
;	LD	D,$00
;	LD	HL,NAMEBF
;	ADD	HL,DE
;	LD	C,$04
;	XOR	A
;NC30F0
;	LD	(HLI),A
;	DEC	C
;	JR	NZ,NC30F0
;- - - Save data clear - - - - -
	CALL	KETTEIS		;(S)
;
	LD	A,(NMSLPT)
	SLA	A
	LD	E,A
	LD	D,$00
	LD	HL,SVDTAD2
	ADD	HL,DE
	LD	A,(HLI)
	LD	H,(HL)
	LD	L,A
;
;;	CALL	SVOPEN	;(SV)
;
	LD	DE,$100+$200+$7F+$01
NC30F8
	CALL	SVOPEN	;(SV)
	XOR	A
	LD	(HLI),A
	DEC	DE
	LD	A,E
	OR	D
	JR	NZ,NC30F8
;
	JP	PSLGO
;------------------------------------------
NC3001			; Recover !
	CALL	NMRCVR
;
	CALL	OKCLEAR
NC300F
	LD	HL,ITMODE
	DEC	(HL)
	RET
;- - - - - - - - - - - - - - - -
;-----------------------------------------
OKCLDT
	DB	$99,$E4,$0D
	DB	$11,$04,$13,$14,$11,$0D,$7E,$13,$0E,$7E
	DB	$0C,$04,$0D,$14
	DB	$00
;- - - - - - - - - - - - - - - - - - -
OKCLEAR
	LD	A,(VRAMD)
	LD	E,A
	ADD	A,$11
	LD	(VRAMD),A
	LD	D,$00
;
	LD	HL,VRAMD+1
	ADD	HL,DE
	LD	DE,OKCLDT
	LD	C,$11
OKCL10
	LD	A,(DE)
	INC	DE
	LD	(HLI),A
	DEC	C
	LD	A,C
	CP	$FF
	JR	NZ,OKCL10
;
	RET
;
NC3010
	CALL	OKOAMST
;
	CALL	FOAMSET
;
	LD	A,(FRCNT)
	AND	$10
	JR	Z,NC3008
;-----------------------------------
NMRCVR
	LD	A,(NMSLPT)
	RST	0
	DW	NAME1ST
	DW	NAME2ST
	DW	NAME3ST
;-----------------------------------
NC3008
	LD	A,(NMSLPT)
	RLA
	RLA
	RLA
;;	RLA
	AND	$F8
	LD	E,A
	LD	D,$0
	LD	HL,NMCLD1
	ADD	HL,DE
	LD	DE,VRAMD+1
	LD	C,$08
NC3090
	LD	A,(HLI)
	LD	(DE),A
	INC	DE
	DEC	C
	JR	NZ,NC3090
;
	XOR	A
	LD	(DE),A
	RET
;=========================================
OKOAMST
	LD	A,(KEYA2)
	AND	%01000011
	JR	Z,NC3020
;
	CALL	CURSDSS	;(S)
;
	LD	A,(NAMEOK)
	XOR	$01
	LD	(NAMEOK),A
NC3020
	LD	A,(FRCNT)
	AND	$10
	JR	NZ,NC3038
;
	LD	A,(NAMEOK)
	LD	E,A
;
;	LD	A,(GMMODE)
;	CP	NMCPY
;	LD	A,$1C
;	JR	NZ,NC3028
;	LD	A,$14
;NC3028
	LD	A,$28
	DEC	E
	JR	NZ,NC3030
	LD	A,$6C
NC3030	
	LD	HL,OAM+$0C
	LD	(HL),$88
	INC	HL
	LD	(HLI),A
;
	LD	A,$BE
	LD	(HLI),A
;
	XOR	A
	LD	(HL),A
NC3038
	RET	
;
;=============================================
DENODT
	DB	$B0,$B1,$B2,$B3,$B4,$B5,$B6,$B7,$B8,$B9
;
DETHCST
	PUSH	HL
;
	LD	A,(VRAMD)
	LD	C,A
	ADD	A,$06
	LD	(VRAMD),A
;
	LD	B,$00
	LD	HL,VRAMD+1
	ADD	HL,BC
	LD	A,D
	LD	(HLI),A
;
	LD	A,E
	LD	(HLI),A
;
	LD	A,$02
	LD	(HLI),A
;
	POP	BC
	PUSH	HL
;
	LD	A,C
	AND	$0F
	LD	E,A
	LD	D,$00
	LD	HL,DENODT
	ADD	HL,DE
	LD	A,(HL)
;
	POP	HL
;
	LD	(HLI),A
;
	PUSH	HL
;
	LD	A,B
	AND	$F0
	SWAP	A
	LD	E,A
	LD	D,$00
	LD	HL,DENODT
	ADD	HL,DE
	LD	A,(HL)
;
	POP	HL
;
	LD	(HLI),A
;
	PUSH	HL
;
	LD	A,B
	AND	$0F
	LD	E,A
	LD	D,$00
	LD	HL,DENODT
	ADD	HL,DE
	LD	A,(HL)
;
	POP	HL
;
	LD	(HLI),A
;
	XOR	A
	LD	(HL),A
;
	RET
;****************************************
;*      Name copy                       *
;****************************************
NMCOPYS
	LD	A,(ITMODE)
	RST	0
	DW	NCP0000
	DW	NCP1000
	DW	NCP2000
	DW	NCP2001
	DW	NCP3000
	DW	NCP4000
	DW	NCP5000
;===============================================
NCP0000
	LD	A,VRMBT
	LD	(BLNKFG),A
;
	XOR	A
	LD	(NMSLPT),A
	LD	(NAMEOK),A
	LD	(NMCPP1),A
	LD	(NMCPP2),A
;
	JP	ITMINC
;===============================================
NCP1000
	LD	A,NCPBGS
	LD	(VRFLG),A
	JP	ITMINC
;===============================================
NCP2000
	LD	BC,$98C4
	LD	DE,NAMEBF
	CALL	NAMEDP
	LD	BC,$9924
	LD	DE,NAMEBF+5
	CALL	NAMEDP
	LD	BC,$9984
	LD	DE,NAMEBF+$A
	CALL	NAMEDP
;
	JP	ITMINC
;===============================================
NCP2001
	LD	BC,$98CD
	LD	DE,NAMEBF
	CALL	NAMEDP
	LD	BC,$992D
	LD	DE,NAMEBF+5
	CALL	NAMEDP
	LD	BC,$998D
	LD	DE,NAMEBF+$A
	CALL	NAMEDP
;
	JP	ITMINC
;===============================================
NCP3000
	CALL	CURSDST	;(S)
;
	LD	A,(KEYA2)
	AND	%01001000
	JR	Z,CP3040
;
	LD	A,(NMCPP1)
	INC	A
	AND	$03
	LD	(NMCPP1),A
;
CP3040
	LD	A,(KEYA2)
	AND	%00000100
	JR	Z,CP3042
;
	LD	A,(NMCPP1)
	DEC	A
	CP	$FF
	JR	NZ,CP3041
	LD	A,$03
CP3041
	LD	(NMCPP1),A
CP3042
;===================================
	LD	A,(KEYA2)
	AND	%10010000
	JR	Z,CP3080
;
	LD	A,(NMCPP1)
	CP	$03
	JP	Z,PSLGO
;
	CALL	ITMINC
	CALL	KETTEIS		;(S)
CP3080
;-----------------------------------------
FOAMSET2
	LD	A,(NMCPP1)
	LD	E,A
	LD	D,$0
	LD	HL,FYOPDT
	ADD	HL,DE
;
	LD	A,(FRCNT)
	AND	%00001000
	LD	A,(HL)
	LD	HL,OAM
FO2SUB
	JR	Z,FO2010
;
	PUSH	AF
	LD	(HLI),A
	LD	A,$10
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
	POP	AF
	LD	(HLI),A
	LD	A,$18
	LD	(HLI),A
;
	LD	A,$02
	LD	(HLI),A
;
	LD	A,$00
	LD	(HL),A
;
	RET
;----------------------------------
FO2010
;;	LD	A,(HL)
;;	LD	HL,OAM
	PUSH	AF
	LD	(HLI),A
	LD	A,$10
	LD	(HLI),A
;
	LD	A,$02
	LD	(HLI),A
;
	LD	A,$20
	LD	(HLI),A
	POP	AF
	LD	(HLI),A
	LD	A,$18
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
;
	LD	A,$20
	LD	(HL),A
	RET
;
;-----------------------------------------
FOAMSET2S
;	LD	A,(FRCNT)
;	AND	$10
;	JR	NZ,FO2S90
;
	LD	A,(NMCPP1)
	LD	E,A
	LD	D,$0
	LD	HL,FYOPDT
	ADD	HL,DE
;
	LD	A,(HL)
	LD	HL,OAM
	ADD	A,$05
	LD	(HLI),A
	LD	A,$14
	LD	(HLI),A
;
	LD	A,$BE
	LD	(HLI),A
;
	LD	A,$00
	LD	(HL),A
FO2S90
	RET
;===============================================
;-------------------------------------------
CPCLDT
	DB	$98,$A4,$44,$7E
	DB	$98,$C4,$44,$7E
;
	DB	$99,$04,$44,$7E
	DB	$99,$24,$44,$7E
;
	DB	$99,$64,$44,$7E
	DB	$99,$84,$44,$7E
;-------------------------------------------
CPCLD2
	DB	$98,$AD,$44,$7E
	DB	$98,$CD,$44,$7E
;
	DB	$99,$0D,$44,$7E
	DB	$99,$2D,$44,$7E
;
	DB	$99,$6D,$44,$7E
	DB	$99,$8D,$44,$7E
;-----------------------------------------
NCP4000
	CALL	CURSDST	;(S)
;
	LD	A,(KEYA2)
	AND	%01001000
	JR	Z,CP4040
;
	LD	A,(NMCPP2)
	INC	A
	AND	$03
	LD	(NMCPP2),A
;
CP4040
	LD	A,(KEYA2)
	AND	%00000100
	JR	Z,CP4042
;
	LD	A,(NMCPP2)
	DEC	A
	CP	$FF
	JR	NZ,CP4041
	LD	A,$03
CP4041
	LD	(NMCPP2),A
CP4042
	CALL	FOAMSET2S
;===================================
	LD	A,(KEYA2)
	BIT	5,A
	JR	Z,CP4050
;	
	LD	HL,ITMODE
	DEC	(HL)
;
	JP	CPNMST
;- - - - - - - - - - - - - - - - -
CP4050
	AND	%10010000
	JR	Z,CP4080
;
	LD	A,(NMCPP2)
	CP	$03
	JP	Z,PSLGO
;
	CALL	KETTEIS		;(S)
	CALL	ITMINC
;
	JP	OKSET
CP4080
	CALL	FOAMSET21
;
NCPSUB
	LD	A,(FRCNT)
	AND	%00010000
	JR	Z,CP4090
;
	LD	A,(NMCPP1)
	RLA
	RLA
	RLA
	AND	$F8
	LD	E,A
	LD	D,$0
	LD	HL,CPCLDT
	ADD	HL,DE
	LD	DE,VRAMD+1
	LD	C,$08
CP4082
	LD	A,(HLI)
	LD	(DE),A
	INC	DE
	DEC	C
	JR	NZ,CP4082
;
	XOR	A
	LD	(DE),A
	RET
;- - - - - - - - - - - - - - - - -
CP4090
CPNMST
	LD	A,(NMCPP1)
	CP	$01
	JR	Z,CP4092
	CP	$02
	JR	Z,CP4093
;
	LD	BC,$98C4
	LD	DE,NAMEBF
	JP  	NAMEDP
;
CP4092
	LD	BC,$9924
	LD	DE,NAMEBF+5
	JP  	NAMEDP
;
CP4093
	LD	BC,$9984
	LD	DE,NAMEBF+$A
	JP  	NAMEDP
;
;========================================
FOAMSET21
	LD	A,(NMCPP2)
;
	LD	E,A
	LD	D,$0
	LD	HL,FYOPDT
	ADD	HL,DE
;
	LD	A,(NMCPP2)
	CP	$03
	JP	Z,FO2100
;
	LD	A,(FRCNT)
	AND	%00001000
	JR	Z,F21010
;
	LD	A,(HL)
	LD	HL,OAM+$08
	PUSH	AF
	LD	(HLI),A
	LD	A,$58
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
	POP	AF
	LD	(HLI),A
	LD	A,$60
	LD	(HLI),A
;
	LD	A,$02
	LD	(HLI),A
;
	LD	A,$00
	LD	(HL),A
;
	RET
;----------------------------------
F21010
	LD	A,(HL)
	LD	HL,OAM+$08
	PUSH	AF
	LD	(HLI),A
	LD	A,$58
	LD	(HLI),A
;
	LD	A,$02
	LD	(HLI),A
;
	LD	A,$20
	LD	(HLI),A
	POP	AF
	LD	(HLI),A
	LD	A,$60
	LD	(HLI),A
;
	LD	A,$00
	LD	(HLI),A
;
	LD	A,$20
	LD	(HL),A
	RET
;---------------------------
FO2100
	LD	A,(FRCNT)
	AND	%00001000
	LD	A,(HL)
	LD	HL,OAM+$08
	JP	FO2SUB
;-----------------------------------------
FOAMSET21S
;	LD	A,(FRCNT)
;	AND	$10
;	JR	NZ,F21S90
;
	LD	A,(NMCPP2)
	LD	E,A
	LD	D,$0
	LD	HL,FYOPDT
	ADD	HL,DE
;
	LD	A,(HL)
	LD	HL,OAM+$08
	ADD	A,$05
	LD	(HLI),A
	LD	A,$5C
	LD	(HLI),A
;
	LD	A,$BE
	LD	(HLI),A
;
	LD	A,$00
	LD	(HL),A
F21S90
	RET
;-----------------------------------------
NCP5000
	CALL	FOAMSET2S
	CALL	FOAMSET21S
;
	CALL	OKOAMST
;
	LD	A,(KEYA2)
	AND	%10010000
	JR	Z,CP5010
;
	LD	A,(NAMEOK)
	AND	A
	JP	Z,PSLGO
;
	CALL	KETTEIS		;(S)
;
	LD	A,(NMCPP1)
	SLA	A
	LD	E,A
	LD	D,$00
	LD	HL,SVDTAD3
	ADD	HL,DE
	LD	C,(HL)
	INC	HL
	LD	B,(HL)	
	LD	A,(NMCPP2)
	SLA	A
	LD	E,A
	LD	D,$00
	LD	HL,SVDTAD3
	ADD	HL,DE
	LD	A,(HL)
	INC	HL
	LD	H,(HL)	
	LD	L,A
;
	LD	DE,$05+$100+$200+$7F+$01
CPS001
;	LD	A,$0A
;	LD	($0000),A	;(SV)
;
	CALL	SVOPEN	; (SV)
	LD	A,(BC)
	INC	BC
	CALL	SVOPEN	; (SV)
	LD	(HLI),A
	DEC	DE
	LD	A,E
	OR	D
	JR	NZ,CPS001
;
;
;
;
;
;
;
;
;
;
;	LD	A,(NMCPP1)
;	RLA
;	RLA
;	AND	%11111100
;	LD	E,A
;	LD	D,$0
;	LD	HL,NAMEBF
;	ADD	HL,DE
;	PUSH	HL
;	LD	A,(NMCPP2)
;	RLA
;	RLA
;	AND	%11111100
;	LD	E,A
;	LD	D,$0
;	LD	HL,NAMEBF
;	ADD	HL,DE
;	POP	DE
;;
;	LD	C,$04
;CP5008
;	LD	A,(DE)
;	INC	DE
;	LD	(HLI),A
;	DEC	C
;	JR	NZ,CP5008
;;
;	LD	A,(NMCPP1)
;	LD	E,A
;	LD	D,B
;	LD	HL,HARTCTF
;	ADD	HL,DE
;	PUSH	HL
;	LD	A,(NMCPP2)
;	LD	E,A
;	LD	D,B
;	LD	HL,HARTCTF
;	ADD	HL,DE
;	POP	DE
;	LD	A,(DE)
;	LD	(HL),A
;;
;	LD	A,(NMCPP1)
;	LD	E,A
;	LD	D,B
;	LD	HL,HARTMXF
;	ADD	HL,DE
;	PUSH	HL
;	LD	A,(NMCPP2)
;	LD	E,A
;	LD	D,B
;	LD	HL,HARTMXF
;	ADD	HL,DE
;	POP	DE
;	LD	A,(DE)
;	LD	(HL),A
;;
;	LD	A,(NMCPP1)
;	SLA	A
;	LD	E,A
;	LD	D,B
;	LD	HL,DETHCTF
;	ADD	HL,DE
;	PUSH	HL
;	LD	A,(NMCPP2)
;	SLA	A
;	LD	E,A
;	LD	D,B
;	LD	HL,DETHCTF
;	ADD	HL,DE
;	POP	DE
;	LD	A,(DE)
;	INC	DE
;	LD	(HLI),A
;	LD	A,(DE)
;	LD	(HL),A
;
;
;
;
;
	JP	PSLGO
;
;
CP5010
	LD	A,(KEYA2)
	BIT	5,A
	JR	Z,CP5050
;	
	LD	HL,ITMODE
	DEC	(HL)
;
	XOR	A
	LD	(NAMEOK),A
;
	CALL	OKCLEAR
;
	JP	CPNMST2
;- - - - - - - - - - - - - - - - -
CP5050
	CALL	NCPSUB
;
	LD	A,(FRCNT)
	AND	%00010000
	JR	Z,CP5090
;
	LD	A,(NMCPP2)
	RLA
	RLA
	RLA
	AND	$F8
	LD	E,A
	LD	D,$0
	LD	HL,CPCLD2
	ADD	HL,DE
	LD	DE,VRAMD+1+8
	LD	C,$08
CP5082
	LD	A,(HLI)
	LD	(DE),A
	INC	DE
	DEC	C
	JR	NZ,CP5082
;
	XOR	A
	LD	(DE),A
	RET
;- - - - - - - - - - - - - - - - -
CP5090
CPNMST2
	LD	A,(NMCPP2)
	CP	$01
	JR	Z,CP5092
	CP	$02
	JR	Z,CP5093
;
	LD	BC,$98CD
	LD	DE,NAMEBF
	JP  	NAMEDP
;
CP5092
	LD	BC,$992D
	LD	DE,NAMEBF+$5
	JP  	NAMEDP
;
CP5093
	LD	BC,$998D
	LD	DE,NAMEBF+$A
	JP  	NAMEDP
;===============================================
HARTSTD
	DB	$18,$18,$18
;;		  3   4   5   6   7   8   9  10  11  12  13  14
	DB	$18,$18,$18,$28,$28,$28,$28,$38,$38,$38,$38,$50
;- - - - - - - - - - - - - - - 
GMSTART
	XOR	A
	LD	(YKFLAG),A	; Yoko gamen flag reset
;
	LD	A,(HARTCT)
	AND	A
	JR	NZ,GMST01	; Game over ?
;				; yes !
	LD	A,(HARTMX)
	LD	E,A
	LD	D,$00
	LD	HL,HARTSTD
	ADD	HL,DE
	LD	A,(HL)
;
;;	LD	A,$18
	LD	(HARTCT),A
GMST01
	LD	HL,SAVEFG
	LD	A,(HL)
	LD	(HL),$00
	AND	A
	JR	NZ,GMST010	; Load ok ?
;				; yes !
	LD	A,(NMSLPT)
	SLA	A
	LD	E,A
	LD	D,$00
	LD	HL,SVDTAD2
	ADD	HL,DE
	LD	C,(HL)
	INC	HL
	LD	B,(HL)	
;
;;	LD	A,$0A
;;	LD	($0000),A	;(SV)
;;	CALL	SVOPEN	;(SV)
;
	LD	HL,SAVERM
	LD	DE,$200+$100+$7F+1	; Game use data set !!
SVDS010
	CALL	SVOPEN	;(SV)
	LD	A,(BC)
	INC	BC
	LD	(HLI),A
	DEC	DE
;
	LD	A,E
	OR	D
	JR	NZ,SVDS010
;
GMST010
;	LD	A,$7F  ;$50
;	LD	(WGRNDPT),A
;	LD	(GRNDPT),A
;	XOR	A
;	LD	(DJFLAG),A
;
;	LD	A,$48
;	LD	(WPLXPSL),A
;	LD	A,$30
;	LD	(WPLYPSL),A
;
;	LD	A,$0A
;	LD	(HARTMX),A
;
;;	LD	A,WINDBGS
;;	LD	(VRFLG),A	; Window BG set 
;;- - Have item initial - - - -
;	LD	E,$0
;	LD	D,$0
;;
;	LD	BC,ITEMB
;PI3000
;	LD	HL,ITITDT
;	ADD	HL,DE
;	LD	A,(HLI)
;	LD	(BC),A
;	INC	BC
;	INC	E
;	LD	A,E
;	CP	12+10
;	JR	NZ,PI3000
;;
;	LD	A,$01
;	LD	(KENLEV),A
;	LD	A,$01
;	LD	(TATLEV),A
;	LD	A,$01
;	LD	(BULLEV),A
;;
;	LD	HL,GRKEY1
;	LD	E,$5
;PI3010
;	LD	(HLI),A
;	DEC	E
;	JR	NZ,PI3010
;;
;	LD	A,$69
;	LD	(BOMBCT),A
;	LD	A,$78
;	LD	(YAAACT),A
;	LD	A,$35
;	LD	(TUBOCT),A
;GMSTST
	LD	A,GPLAY   ;GINIT
	LD	(GMMODE),A
	XOR	A
	LD	(ITMODE),A
;
;	LD	A,$5
;	LD	(COINC1),A
;	LD	A,$09
;	LD	(COINC2),A
;;
;	LD	A,$18
;	LD	(HARTCT),A
;	LD	A,$4
;	LD	(HARTMX),A
;;
;	LD	A,(NMSLPT)
;	AND	A
;	JR	Z,GMSS10
;;
;	LD	A,$50
;	LD	(HARTCT),A
;	LD	A,$A
;	LD	(HARTMX),A
;	LD	A,$06
;	LD	(KBINF),A
GMSS10
	XOR	A
	LD	(PLMODE),A
	LD	(PLSTAT),A
	LD	(HARTUP),A
	LD	(HARTDW),A
	LD	(COINU2),A
	LD	(COINU1),A
	LD	(COIND2),A
	LD	(COIND1),A
;;	INC	A
;;	LD	(HARTUP),A	; Becouse Vram write !
;
;	LD	A,$A3  ;D6 ;7F  ;$50
;	LD	(WGRNDPT),A
;	LD	(GRNDPT),A
;	LD	A,$01 ;$01
;	LD	(DJFLAG),A
;;
;	LD	A,$10 ;DJMAX ;$20
;	LD	(DNJNNO),A
;;
;	LD	A,$50
;	LD	(WPLXPSL),A
;	LD	A,$60
;	LD	(WPLYPSL),A
;;
;	XOR	A
;	LD	(PLCHPT),A
;	LD	A,$3
;	LD	(PLCMKI),A
;;
	LD	A,(TAMA0PT)
	AND	A
	JR	NZ,GMSTRT90	;Level 7 テッキュウ位置セット！
;
	LD	A,$16
	LD	(TAMA0PT),A
;
	LD	A,$50
	LD	(TAMA0XP),A
	LD	A,$27
	LD	(TAMA0YP),A
;
GMSTRT90
	LD	A,(CONTBF+3)
	AND	A
	JR	Z,GMS0B0	; Continue ?
;				; yes !
	LD	(WPLXPSL),A
	LD	A,(CONTBF+4)
	LD	(WPLYPSL),A
	LD	A,(CONTBF+2)
	LD	(GRNDPT),A
	LD	(WGRNDPT),A
	LD	A,(CONTBF+1)
	LD	(DNJNNO),A
	LD	A,(CONTBF+5)
	LD	(DNJNPT),A
;
	XOR	A
	LD	(YKFLAG),A
;
	LD	A,(CONTBF+0)
	AND	$01
	LD	(DJFLAG),A
	JR	Z,GMS098
;
	LD	A,$04
	LD	(PLCHPT),A
	LD	A,$02
	LD	(PLCMKI),A
GMS098
	LD	A,WINDBGS
	LD	(VRFLG),A	; Window BG set 
	RET
;-----------------------------------
GMS0B0	;一番最初！
	LD	A,$30
	LD	(YAMAX),A
	LD	A,$30
	LD	(BOMAX),A
	LD	A,$20
	LD	(PWMAX),A
;
	LD	A,$A3  ;D6 ;7F  ;$50
	LD	(WGRNDPT),A
	LD	(GRNDPT),A
	LD	A,$01 ;$01
	LD	(DJFLAG),A
;
	LD	A,$10 ;DJMAX ;$20
	LD	(DNJNNO),A
;
	LD	A,$50
	LD	(WPLXPSL),A
	LD	A,$60
	LD	(WPLYPSL),A
;
	XOR	A
	LD	(PLCHPT),A
	LD	A,$3
	LD	(PLCMKI),A
;
;	LD	A,(TAMA0PT)
;	AND	A
;	JR	NZ,GMSTRT90	;Level 7 テッキュウ位置セット！
;
	LD	A,$16
	LD	(TAMA0PT),A
;
	LD	A,$50
	LD	(TAMA0XP),A
	LD	A,$27
	LD	(TAMA0YP),A
;GMSTRT90
	JR	GMS098
;====================================
;====================================
;=     地下洞窟白地図出力命令群     =
;====================================
;
DMVH
	DB	$9D,$9D,$9D,$FF
	DB	$9D,$9D,$9D,$FF
	DB	$9D,$9D,$9C,$FF
	DB	$9D,$9D,$9C,$FF
;
DMVL
	DB	$32,$32,$09,$FF
	DB	$2E,$2E,$09,$FF
	DB	$8A,$32,$E9,$FF
	DB	$8A,$2E,$E9,$FF
;
DMSURYO
	DB	$C8,$C8,$00,$FF
	DB	$C8,$C8,$00,$FF
	DB	$48,$C8,$00,$FF
	DB	$48,$C8,$00,$FF
;
DMCHAR
	DB	$7F,$7F,$BA,$FF
	DB	$7F,$7F,$BA,$FF
	DB	$7F,$7F,$BA,$FF
	DB	$7F,$7F,$BA,$FF
;
;------------------------------------------------------------------
DDDHH
	DB	$00,$00,$00,$FF
	DB	$00,$00,$00,$FF
;
	DB	$9D,$9D,$FF,$00
	DB	$9D,$9D,$9D,$FF
;
	DB	$9D,$9C,$FF,$00
	DB	$9D,$9C,$9C,$FF
;
	DB	$9D,$9D,$9C,$9C,$FF,$00,$00,$00,$00,$00,$00
	DB	$9D,$9D,$9C,$9C,$9C,$9C,$FF,$00,$00,$00,$00
	DB	$9D,$9D,$9C,$9C,$9D,$9D,$9C,$9C,$FF,$00,$00
	DB	$9D,$9D,$9C,$9C,$9D,$9D,$9C,$9C,$9C,$9C,$FF
;--------------------------------------------------------------------------------------
DDDLL
	DB	$00,$00,$00,$FF
	DB	$00,$00,$00,$FF
;
	DB	$0D,$12,$FF,$00
	DB	$0D,$11,$12,$FF
;
	DB	$92,$F2,$FF,$00
	DB	$92,$F1,$F2,$FF
;
	DB	$8D,$92,$ED,$F2,$FF,$00,$00,$00,$00,$00,$00
	DB	$8D,$92,$ED,$F2,$F1,$F2,$FF,$00,$00,$00,$00
	DB	$8D,$92,$ED,$F2,$91,$92,$F1,$F2,$FF,$00,$00
	DB	$8D,$92,$ED,$F2,$91,$92,$EC,$ED,$F1,$F2,$FF
;--------------------------------------------------------------------------------------
DDDCC
	DB	$00,$00,$00,$FF
	DB	$00,$00,$00,$FF
;
	DB	$E8,$E9,$FF,$00
	DB	$E8,$EC,$E8,$FF
;
	DB	$E8,$E9,$FF,$00
	DB	$E8,$EC,$E8,$FF
;
	DB	$E8,$EA,$E9,$EB,$FF,$00,$00,$00,$00,$00,$00
	DB	$E8,$EA,$E9,$EB,$EC,$E8,$FF,$00,$00,$00,$00
	DB	$E8,$EA,$E9,$EB,$EC,$E8,$EC,$E9,$FF,$00,$00
	DB	$E8,$EA,$E9,$EB,$EC,$E8,$EC,$EA,$EC,$E9,$FF
;-------------------------------------------------------------------
;===================================================================
DLVH
	DB	$9D,$9C
;
DLVL
	DB	$0A,$EA
;
;DLVSU
;	DB	$B1,$B2,$B3,$B4,$B5,$B6,$B7,$B8,$B9
;===================================================================
;===================================================================
DMCLDT
DCD
	DB	$9C,$E9,$49,$7F
	DB	$9D,$09,$49,$7F
	DB	$9D,$29,$49,$7F
	DB	$9D,$49,$49,$7F
	DB	$9D,$69,$49,$7F
	DB	$9D,$89,$49,$7F
	DB	$9D,$A9,$49,$7F
	DB	$9D,$C9,$49,$7F
	DB	$9D,$E9,$49,$7F
	DB	$9E,$09,$49,$7F
	DB	$00
DCE
;--------------------------------------------
;===================================================================
;===================================================================
;===================================================================
DMAPSUB
	LD	HL,DMCLDT
	LD	DE,VRAMD2+1-1
	LD	C,DCE-DCD
DCS010
	LD	A,(HLI)
	INC	DE	
	LD	(DE),A
	DEC	C
	JR	NZ,DCS010
;
	PUSH	DE
;
	XOR	A
	LD	(WORK0),A
	LD	(WORK1),A
	LD	(WORK2),A
	LD	(WORK3),A
	LD	C,A
	LD	B,A
	LD	E,A
	LD	D,A
;
	LD	A,(DAMPFG)
	SWAP	A
	AND	$03
	LD	E,A
;
	AND	A
	JR	Z,DMVSET
;
DMHNDN
;
	LD	A,C
	ADD	A,$04		;;;;;;;;;;;;;;
	LD	C,A
	DEC	E
	LD	A,E
	AND	A
	JR	NZ,DMHNDN
;
	LD	B,$0
;
DMVSET
;
;;	LD	HL,VRAMD2+1
	POP	HL
;
DMVSET2
;
	PUSH	HL
;
	LD	HL,DMVH
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK0),A
;
	LD	HL,DMVL
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK1),A
;
	LD	HL,DMSURYO
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK2),A
;
	LD	HL,DMCHAR
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK3),A
;
	POP	HL
;
	CALL	DVRSET
;
	PUSH	HL
;
	LD	HL,DMVH
	INC	BC
	ADD	HL,BC
	LD	A,(HL)
;
	POP	HL
;
	INC	HL
;
	CP	$FF
	JR	NZ,DMVSET2
;
	XOR	A
	LD	(HL),A
DMEND
;=====================================
;=====================================
;=====================================
;=====================================
DFDSET
;
	XOR	A
	LD	(WORK0),A
	LD	(WORK1),A
	LD	(WORK2),A
	LD	(WORK3),A
	LD	C,A
	LD	B,A
	LD	E,A
	LD	D,A
;
	LD	A,(DAMPFG)
	SWAP	A
	AND	$03
	LD	E,A
;
	AND	A
	JR	Z,DFDEND
;
DFZLOP
	LD	B,$0
	LD	A,C
	ADD	A,$08
	LD	C,A
	DEC	E
	LD	A,E
	AND	A
	JR	NZ,DFZLOP
;
	LD	A,(DAMPFG)
	AND	$03
	JR	Z,DFMAIN
;
	LD	A,(DAMPFG)
	AND	$30
	CP	$30
	JR	Z,DF3SET
;
	LD	A,C
	ADD	A,$04
	LD	C,A
	LD	B,$0
	JR	DFMAIN
;
DF3SET
	LD	A,(DAMPFG)
	AND	$03
	LD	E,A
;
DF3LOP
;
	LD	B,$0
	LD	A,C
	ADD	A,$0B
	LD	C,A
	DEC	E
	LD	A,E
	AND	A
	JR	NZ,DF3LOP
;
DFMAIN
;
	PUSH	HL
;
	LD	HL,DDDHH
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK0),A
;
	LD	HL,DDDLL
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK1),A
;
	XOR	A
	LD	(WORK2),A
;
	LD	HL,DDDCC
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK3),A
;
	POP	HL
;
	CALL	DVRSET
;
	PUSH	HL
;
	LD	HL,DDDHH
	INC	BC
	ADD	HL,BC
	LD	A,(HL)
;
	POP	HL
;
	INC	HL
;
	CP	$FF
	JR	NZ,DFMAIN
;
;	XOR	A
;	LD	(HL),A
DFDEND
;	RET
;=====================================
;=====================================
DALVSET
	XOR	A
	LD	B,A
	LD	C,A
;
;;	LD	A,(DNJNNO)  ;DALVFG)
;;	SWAP	A
;;	AND	$0F
;;	LD	D,A
;;;
;;	LD	A,(DNJNNO)  ;DALVFG)
;;	AND	$0F
;;	LD	E,A
;
	LD	A,(DAMPFG)
	BIT	5,A
	JR	Z,DLVMAIN
;
	INC	BC
DLVMAIN
;
	PUSH	HL
;
	LD	HL,DLVH
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK0),A
;
	LD	HL,DLVL
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK1),A
;
	LD	A,$01
	LD	(WORK2),A
;
;;	LD	C,D
;;	LD	B,$0
;;	LD	HL,DLVSU
;;	ADD	HL,BC
;;	LD	A,(HL)
	LD	A,(DNJNNO)
	ADD	A,$B1
	LD	(WORK3),A
;
	POP	HL
;
	CALL	DVRSET
;
	PUSH	HL
;
;;	LD	C,E
;;	LD	B,$0
;;	LD	HL,DLVSU
;;	ADD	HL,BC
;;	LD	A,(HL)
;
	POP	HL
	INC	HL
;
	LD	A,$7F
	LD	(HLI),A
;
	XOR	A
	LD	(HL),A
DALEND
	RET
;=====================================
;=====================================
;=====================================
DVRSET
;
	LD	A,(WORK0)
	LD	(HLI),A
;
	LD	A,(WORK1)
	LD	(HLI),A
;
	LD	A,(WORK2)
	LD	(HLI),A
;
	LD	A,(WORK3)
	LD	(HL),A
;
	RET
;=====================================
;=====================================
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	大　地上マップ　ディスプレイ	  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GRMAPSB
	XOR	A
	LD	(ENOMID),A
;
	LD	A,(ITMODE)
	RST	0
	DW	GRMIT00
	DW	GRMIT08
	DW	GRMIT0C
	DW	GRMIT10
	DW	GRMMAIN
	DW	GRMMA00
;=====================================
GRMIT00
	CALL	PLCSET
	CALL	ENEMYL1
;
	CALL	FDIN
;
	LD	A,(SBHR)
	CP	$4
	JR	NZ,GRMI02
;
	LD	A,$03
	LD	(SLEVEL),A
	LD	A,$30
	LD	(SLEVEL+1),A
;
	CALL	ITMINC
;
	XOR	A
	LD	(SBHR),A
	LD	(SBCNT),A
	LD	(SCCH),A
	LD	(SCXAD),A
	LD	(SCCV),A
	LD	(WNDFLG),A
;;;	LD	(ICONFG),A
	LD	(ICONTM),A
	LD	(ICONTM2),A
;
	LD	A,(GRNDPTW)
	LD	(GMAPPT),A
	LD	E,A
	LD	D,$00
	LD	HL,GRPOINT
	ADD	HL,DE
	LD	A,(HL)
	AND	A
	JR	Z,GRMI01
;
	SWAP	A
	AND	$07 ;3
	INC	A
	CP	$01
	JR	NZ,GRMI01	;ふくろう？
;				;YES !
	LD	A,(GMAPFG)
	AND	A
	LD	A,$00
	JR	NZ,GRMI01
;
	LD	HL,GRRMSV
	ADD	HL,DE
	LD	A,(HL)
	AND	%00100000
	LD	A,$00
	JR	Z,GRMI01	;１回でも話した？
;				;YES!
	LD	A,$01
GRMI01
	LD	(ICONFG),A	; Icon initial
;
	LD	A,(GMAPPT)
	LD	(WGMAPPT),A
;
	LD	A,(LCDC)
	AND	%11011111	; Window off !
	LD	(LCDCB),A
	LD	(LCDC),A
;
	CALL	SCRRCLR
;
	LD	A,GMAPBGS
	LD	(VRFLG),A	; Waku BG set
GRMI02
	RET
;=====================================
GRMIT08
	LD	A,GMBST
	LD	(BLNKFG),A	; Bank set
;
	CALL	ITMINC
	RET
;=====================================
GRMIT0C
	LD	A,GRCST
	LD	(BLNKFG),A	; Unit chr set !
;
	CALL	ITMINC
	RET
;=====================================
GRMIT10
;	LD	A,(FADEON)
;	AND	A
;	JR	Z,GRMIT11
;;
;	LD	A,$04
;	LD	(SBHR),A
;;
;	LD	A,(FADEBP)
;	LD	(BGPFG),A
;	JR	GRMIT12
;GRMIT11
	CALL	FDOUT
;
;GRMIT12
	LD	A,(SBHR)
	CP	$4
	JR	NZ,GRMI12
;
	CALL	ITMINC
;
	CALL	KETTEIS	;(S)
GRMI12
	RET
;=====================================
;- - - - - - - - - - - - - - - - - - - -
GRMMAIN
	LD	A,(MSGEFG)
	AND	A
	JP	NZ,SQEED
;
	LD	A,(KEYA2)
	AND	$10
	JR	Z,SQEE
;
;;;;	LD	A,$56
	LD	A,(GMAPPT)
	LD	E,A
	LD	D,$00
	LD	HL,GRPOINT
	ADD	HL,DE
	LD	A,(HL)
	AND	A
	JR	Z,GRMM000
;
	LD	E,A
;
	AND	$F0
	JR	NZ,GAMS02	;ふくろう？
;				;YES !
	LD	A,(GMAPFG)
	AND	A
	JR	NZ,GRMM000
;
	PUSH	DE
	LD	A,(GMAPPT)
	LD	E,A
;
	LD	HL,GRRMSV
	ADD	HL,DE
	POP	DE
	LD	A,(HL)
	AND	%00100000
	JR	Z,GRMM000	;１回でも話した？	
;
GAMS02
	LD	D,$00
	LD	HL,GRMSDT
	ADD	HL,DE
	LD	A,(HL)
	JR	GRMSCK
;
GRMM000
	LD	A,(GMAPPT)
	CP	$24
	JR	Z,GAMS08
	CP	$34
	JR	NZ,GAMS10
GAMS08
	LD	A,$76
	JR	GRMSCK
GAMS10
	RRA
	AND	$07
	LD	E,A
	LD	A,(GMAPPT)
	RRA
	RRA
	AND	%00111000
	OR	E
	LD	E,A
	LD	D,$00
	LD	HL,GRAREA
	ADD	HL,DE
	LD	A,(HL)
;	AND	A
;	JR	Z,SQEE
;;
;	ADD	A,$56-1
;======================================
GRMSCK
	CALL	MSGCHK
;
	LD	A,(GMAPPT)
	CP	$70
	LD	A,$01
	JR	NC,ERT
;
	LD	A,$81
ERT
	LD	(MSGEFG),A
	RET
;- - - - - - - - - - - - - - - -
SQEE
	LD	A,(HIMITSU)
	AND	A
	JR	Z,GRMM08
;
	LD	A,(KEYA1)
	CP	%01100000
	JR	NZ,GRMM08
;
	LD	A,GPLAY
	LD	(GMMODE),A
;
	CALL	NXGOTO
;
	LD	A,$00
	LD	(NXRMMD),A
	LD	(NXDJNO),A
	LD	A,(GMAPPT)
	LD	(NXRMNO),A
	LD	A,$48
	LD	(NXRMPX),A
	LD	A,$52
	LD	(NXRMPY),A
;
	LD	A,(PLXPSL)
	SWAP	A
	AND	$0F
	LD	E,A
	LD	A,(PLYPSL)
	SUB	$08
	AND	$F0
	OR	E
;;	LD	A,$44
	LD	(DRPSBF),A
;
	LD	A,GPMA
	LD	(ITMODE),A
;
	RET
GRMM08
	LD	E,%01000000
	LD	A,(HIMITSU)
	AND	A
	JR	NZ,GRMM09
;
	LD	E,%01100000
GRMM09
	LD	A,(KEYA2)
	AND	E
;;	AND	%01000000	;Select & B
;;	AND	%01100000	;Select & B
	JR	Z,GRMM10
;
	XOR	A
	LD	(SBHR),A
	LD	(SBCNT),A
;
	CALL	ITMINC
GRMM10
SQEED
	CALL	GRMPST
	CALL	GRMCST
;
	CALL	ICONCS
	RET
;=====================================
TBGEND
	CALL	TBGCST 
;=====================================
TSV4000
GRMMA00
	CALL	FDIN
;
	LD	A,(SBHR)
	CP	$4
	JR	NZ,GRMA02
;
;;	CALL	KETTEIS	;(S)
;
	XOR	A
	LD	(SHOPFG),A	; Shop BG initial !!
	LD	(ZZZFLG),A	;タリン ｚｚｚ セットフラグ
	LD	(SCCH),A
	LD	(SCCV),A
	LD	(ITEMNOT),A
;
	LD	A,$07
	LD	(SLEVEL),A
	LD	A,$70
	LD	(SLEVEL+1),A
;
	LD	A,GPLAY
	LD	(GMMODE),A
;
	LD	(BGMNOT),A
;
	LD	A,GPM
	LD	(ITMODE),A
;
	LD	A,(DJFLAG)
	AND	A
	LD	A,DJBST		; Bank set!
	JR	NZ,GRMA01	; Danjyon ?
;				; yes !
	LD	A,GRBST		; Bank set!
GRMA01
	LD	(BLNKFG),A
;
SCRRCLR
	LD	HL,SCRLFG	; Scroll base display reset !
	LD	E,$0
GRMA015
	XOR	A
	LD	(HLI),A
	INC	E
	LD	A,E
	CP	$C
	JR	NZ,GRMA015
;==================================
WINDIT
	LD	A,$80
	LD	(WNDYPS),A
	LD	A,$06
	LD	(WDX),A		; Item window position initial 
;
	LD	A,$08
	LD	(WNDSPD),A	; Item window speed initial
;
	XOR	A
	LD	(WNDFLG),A
GRMA02
	RET
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Player pos set			  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GRMPST
;	LD	A,(FRCNT)
;	AND	%00010000
;	JR	Z,GRMPS10
;;;	JR	NZ,GRMPS10
;
	LD	HL,OAM+$9C
;
	LD	A,(GRNDPTW)
	RRA
	AND	%01111000
	ADD	A,$18
	LD	(HLI),A
	LD	A,(GRNDPTW)
	SWAP	A
	RRA
	AND	%01111000
	ADD	A,$18
	LD	(HLI),A
;
	LD	(HL),$3E
	INC	HL
;
	LD	A,(FRCNT)
	RLA
;	RLA
;	RLA
	AND	%00010000
;
	LD	(HL),A ;$00
GRMPS10
	RET
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Cursol set			  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GRAREA
;;        0   1   2   3   4   5   6   7 
     DB $6C,$6C,$6C,$6B,$6C,$6C,$6C,$6C ;0
     DB $76,$76,$79,$79,$79,$79,$79,$79 ;1
     DB $6A,$6A,$72,$7A,$78,$78,$71,$71 ;2
     DB $6A,$6A,$72,$70,$78,$78,$71,$71 ;3
     DB $6A,$6E,$69,$69,$69,$69,$77,$71 ;4
     DB $6E,$6E,$69,$69,$69,$69,$77,$77 ;5
     DB $7B,$7B,$6D,$62,$74,$74,$6F,$68 ;6
     DB $73,$73,$73,$74,$74,$74,$75,$68 ;7
;---------------------------------------------------
GRMSDT
;;  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
 DB 0,$D9,$C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$CA,$CB,$CC,$CD ;0
 DB 0,$56,$57,$58,$59,$5A,$5B,$5C,$5D,$00,$00,$00,$00,$00,$00,$00 ;1
 DB 0,$7C,$67,$00,$00,$80,$65,$00,$64,$88,$00,$00,$00,$00,$00,$00 ;2
 DB 0,$5E,$5F,$7F,$7E,$7D,$82,$84,$85,$86,$87,$81,$66,$83,$5E,$63 ;3
 DB 0,$61,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;4
GRPOINT
;;;   0x:FukurouMesege 1x:Danjyon 2x:Shop 3x:Nanka 4x:Nanka next
;;    0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
 DB $00,$00,$00,$00,$00,$00,$3E,$00,$0E,$00,$39,$00,$00,$00,$17,$00 ;0
 DB $18,$3D,$00,$00,$00,$00,$06,$0C,$00,$00,$00,$00,$00,$00,$00,$00 ;1
 DB $00,$00,$00,$00,$12,$00,$00,$00,$07,$00,$00,$14,$00,$00,$00,$00 ;2
 DB $33,$3D,$00,$00,$00,$00,$05,$00,$00,$00,$00,$00,$00,$00,$00,$29 ;3
 DB $00,$03,$00,$00,$00,$25,$00,$00,$00,$00,$00,$3D,$00,$00,$00,$00 ;4
 DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;5
 DB $00,$00,$00,$00,$0D,$22,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;6
 DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;7
 DB $02,$21,$3B,$36,$00,$00,$00,$00,$3D,$00,$37,$00,$16,$00,$00,$00 ;8
 DB $00,$00,$00,$26,$00,$00,$00,$00,$00,$00,$00,$09,$0B,$09,$00,$00 ;9 
 DB $00,$35,$3C,$00,$3D,$00,$00,$00,$00,$00,$00,$00,$0A,$00,$00,$00 ;A 
 DB $3A,$34,$3D,$28,$00,$13,$07,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;B 
 DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;C 
 DB $00,$00,$04,$11,$00,$00,$38,$00,$00,$15,$00,$3D,$00,$00,$00,$00 ;D 
 DB $00,$00,$00,$41,$00,$00,$00,$00,$3D,$00,$00,$00,$00,$00,$08,$00 ;E 
 DB $00,$00,$01,$00,$00,$00,$3F,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;F 
;=====================================================
FKMSCKL
	LD	A,(GRNDPT)
	LD	E,A
	LD	D,$00
	LD	HL,GRPOINT 
	ADD	HL,DE
	LD	E,(HL)
	LD	HL,GRMSDT
	ADD	HL,DE
	LD	A,(HL)
	JP  	MSGCHK
;--------------------------------------------------------
GRCSXD
	DB	$00,$01,$FF
GRCSYD
	DB	$00,$F0,$10
;----------------------------------------------
GRMCST
	LD	A,(GMAPPT)
	LD	(WORK0),A
;
	LD	A,(ICONTM2)
	LD	HL,ICONTM
	OR	(HL)
	LD	HL,MSGEFG
	OR	(HL)
	JP	NZ,GRMC60
;
	LD	A,(KEYA1)
	LD	C,A
	LD	HL,WDMVCT
	AND	$0F
	JR	NZ,GRMC20
;
	XOR	A
	LD	(HL),A
	JR	GRMC30
GRMC20
	LD	A,(HL)
	INC	A
	LD	(HL),A
	CP	$18
	JR	NZ,GRMC30
;
;;	LD	A,$15
	LD	(HL),$15 ;A
	JR	GRMC50
GRMC30
	LD	A,(KEYA2)
	LD	C,A
GRMC50
	LD	A,C
	AND	%00000011
	LD	E,A
	LD	D,$0
	LD	HL,GRCSXD
	ADD	HL,DE
	LD	A,(GMAPPT)
	LD	D,A
	AND	$F0
	LD	E,A
	LD	A,D
	ADD	A,(HL)
	AND	$0F
	OR	E
	LD	(GMAPPT),A
;
	LD	A,C ;(KEYA2)
	RRA
	RRA
	AND	%00000011
	LD	E,A
	LD	D,$0
	LD	HL,GRCSYD
	ADD	HL,DE
	LD	A,(GMAPPT)
	ADD	A,(HL)
	LD	HL,WORK0
	LD	(GMAPPT),A
	CP	(HL)
	JR	Z,GRMC60	; Move ?
;				; yes !
	LD	E,A
	LD	D,$00
	LD	HL,GRRMSV
	ADD	HL,DE
;
	LD	A,(GMAPFG)
	AND	A
	JR	NZ,GRMC55
;
	LD	A,(HL)
	AND	%11111111
	JR	NZ,GRMC55	;既に行ったか？
;				;NO
	LD	A,(BGCKOF)
	AND	A
	JR	NZ,GRMC55
;
	LD	A,$09
	LD	(SOUND1),A	;(S)
;
	LD	A,(WORK0)
	LD	(GMAPPT),A
	JR	GRMC60
;
GRMC55
	CALL	CURSDSS	;(S)
;;	AND	$07
;;	CP	$03
;;	JR	NZ,GRMC58
;;	LD	E,A
;;	LD	D,$00
	LD	HL,GRPOINT
	ADD	HL,DE
	LD	A,(HL)
	AND	A
	JR	Z,GRMC58
;
	SWAP	A
	AND	$07 ;3
	INC	A
	LD	C,A
;
	CP	$01
	JR	NZ,GRMC53	;ふくろう？
;				;YES !
	LD	A,(GMAPFG)
	AND	A
	JR	NZ,GRMC58
;
	LD	HL,GRRMSV
	ADD	HL,DE
	LD	A,(HL)
	AND	%00100000
	JR	Z,GRMC58	;１回でも話した？
;				;YES!
GRMC53
	LD	A,(ICONFG)
	AND	A
	JR	NZ,GRMC56
;
	LD	A,$10
	LD	(ICONTM),A
GRMC56
	LD	A,C
	LD	(ICONFG),A
;
	LD	A,(GMAPPT)
	LD	(WGMAPPT),A
;
	JR	GRMC60
GRMC58
	LD	A,(ICONFG)
	AND	A
	JR	Z,GRMC60
;
	XOR	A
	LD	(ICONFG),A
;
	LD	A,$10
	LD	(ICONTM2),A
GRMC60
;- - - - C SET- - - - - -
	LD	HL,OAM+$80
;
	LD	A,(GMAPPT)
	RRA
	AND	%01111000
	ADD	A,$14
;;;	LD	(HLI),A
	LD	E,A
	LD	A,(GMAPPT)
	SWAP	A
	RRA
	AND	%01111000
	ADD	A,$14
;;;	LD	(HLI),A
	LD	D,A
;
;	LD	A,(FRCNT)
;	AND	%00010000
;	JR	NZ,GRMCS70
;
	LD	A,E
	LD	(HLI),A
	LD	A,D
	LD	(HLI),A
;
	LD	(HL),$F0
	INC	HL
;
	LD	(HL),$00
	INC	HL
;
	LD	A,E
	LD	(HLI),A
;
	LD	A,D
	ADD	A,$08
	LD	(HLI),A
;
	LD	(HL),$F0
	INC	HL
;
	LD	(HL),$20
GRMCS70
	LD	A,(FRCNT)
	AND	%00010000
	JR	NZ,GRMCS80
;
	LD	HL,OAM+$88
;
	LD	A,E
	ADD	A,$04
	LD	(HLI),A
	LD	A,D
	ADD	A,$F6
	LD	(HLI),A
	LD	A,$F6
	LD	(HLI),A
	LD	A,$00
	LD	(HLI),A
;
	LD	A,E
	ADD	A,$04
	LD	(HLI),A
	LD	A,D
	ADD	A,$13
	LD	(HLI),A
	LD	A,$F6
	LD	(HLI),A
	LD	A,$20
	LD	(HLI),A
;
	LD	A,E
	ADD	A,$F6
	LD	(HLI),A
	LD	A,D
	ADD	A,$04
	LD	(HLI),A
	LD	A,$F8
	LD	(HLI),A
	LD	A,$00
	LD	(HLI),A
;
	LD	A,E
	ADD	A,$0B
	LD	(HLI),A
	LD	A,D
	ADD	A,$04
	LD	(HLI),A
	LD	A,$F8
	LD	(HLI),A
	LD	A,$40
	LD	(HLI),A
GRMCS80
	RET
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%	Icon  set			  %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ICONCD
;0
	DB	$F8,$F8,$F2,$00
	DB	$F8,$00,$F4,$00
	DB	$F8,$08,$F4,$20
	DB	$F8,$10,$F2,$20
	DB	$08,$F8,$F2,$40
	DB	$08,$00,$F4,$40
	DB	$08,$08,$F4,$60
	DB	$08,$10,$F2,$60
;1
	DB	$FA,$FA,$F2,$00
	DB	$FA,$02,$F4,$00
	DB	$FA,$06,$F4,$20
	DB	$FA,$0E,$F2,$20
	DB	$06,$FA,$F2,$40
	DB	$06,$02,$F4,$40
	DB	$06,$06,$F4,$60
	DB	$06,$0E,$F2,$60
;2
	DB	$FC,$FC,$F2,$00
	DB	$FC,$04,$F4,$00
	DB	$FC,$04,$F4,$20
	DB	$FC,$0C,$F2,$20
	DB	$04,$FC,$F2,$40
	DB	$04,$04,$F4,$40
	DB	$04,$04,$F4,$60
	DB	$04,$0C,$F2,$60
;3
	DB	$FE,$FE,$F2,$00
	DB	$FE,$04,$F4,$00
	DB	$FE,$04,$F4,$20
	DB	$FE,$0A,$F2,$20
	DB	$02,$FE,$F2,$40
	DB	$02,$04,$F4,$40
	DB	$02,$04,$F4,$60
	DB	$02,$0A,$F2,$60
ICONCD2
	DB	$20,$00,$22,$00
	DB	$24,$00,$26,$00
	DB	$28,$00,$2A,$00
	DB	$2C,$00,$2E,$00
	DB	$2C,$00,$2E,$00
;- - - - - - - - - - - - - - - - - -
ICCXDT
	DB	$28,$78
	DB	$28,$78
ICCYDT
	DB	$28,$28
	DB	$78,$78
;- - - - - - - - - - - - - - - - - -
ICONCS
	LD	A,(ENMOD0)
	PUSH	AF
	CALL	ICONCSS
	POP	AF
	LD	(ENMOD0),A
	RET
;=============================================
ICONCSS
	LD	A,(ICONTM2)
	AND	A
	JR	Z,ICC002	
;
	DEC	A
	LD	(ICONTM2),A
	CPL	
	JR	ICC0021
ICC002
	LD	A,(ICONTM)
	AND	A
	JR	Z,ICC003	
;
	DEC	A
	LD	(ICONTM),A
ICC0021
	RRA
	RRA
	AND	$03
	JR	ICC005
ICC003
	LD	A,(ICONFG)
	AND	A
	JP	Z,ICC0A0
;
	LD	A,$00
ICC005
	LD	(ICONWRK),A
	LD	(ENCHPT2),A
;
	LD	A,$00
	LD	(ENOMID),A
;
	LD	A,$08
	LD	(ENMOD0+00),A
;
	LD	A,$00
	LD	(INDEX),A
	LD	(ENFLCL),A
;
	LD	E,$00
	LD	A,(WGMAPPT)
	CP	$70
	JR	C,ICC010
	LD	E,$02
ICC010
	AND	$0F
	CP	$08
	JR	NC,ICC020
	INC	E
ICC020
	LD	D,$00
	LD	HL,ICCXDT
	ADD	HL,DE
	LD	A,(HL)
	LD	(ENSVXL),A
	LD	HL,ICCYDT
	ADD	HL,DE
	LD	A,(HL)
	LD	(ENDSYP),A
;
	LD	A,(ICONWRK)
	RLA
	RLA
	RLA
	RLA
	RLA
	AND	%11100000
	LD	E,A
	LD	D,$00
;
	LD	HL,ICONCD
	ADD	HL,DE
;
	LD	A,$08
	LD	(ENOMID),A
;
	XOR	A
	LD	(ENCHNO),A
	LD	C,$08
	CALL	ENOMST
;
	LD	A,(ICONWRK)
	CP	$00
	JR	NZ,ICC0A0
;
	LD	A,(ICONFG)
	DEC	A
	CP	$80
	JR	NC,ICC0A0
	LD	(ENCHPT2),A
;
;;	LD	DE,ICONCD2
;;;
;;	PUSH	DE	; Chr data addr push !
;
	LD	DE,ENOAM+$00
;
	LD	A,(ENDSYP)  ;(HL)
	LD	(DE),A		; Y L
	INC	DE
;
	LD	A,(ENSVXL)
	LD	(DE),A		; X L
	INC	DE
;
	LD	A,(ENCHPT2)  ;HL)
	LD	C,A
	LD	B,$0
	SLA	C
	RL	B
	SLA	C
	RL	B
;;	POP	HL	; Chrs data addr. !
	LD	HL,ICONCD2
	ADD	HL,BC
	LD	A,(HLI)
	LD	(DE),A		; C L
	INC	DE
	LD	A,(HLI)
;
	LD	(DE),A		; A L
	INC	DE
;- - Right - - - 
	LD	A,(ENDSYP)   ;(HL)
	LD	(DE),A		; Y R
	INC	DE
;
	LD	A,(ENSVXL)   ;$08  ;10
	ADD	A,$08
	LD	(DE),A		; X R
	INC	DE
;
	LD	A,(HLI)
	LD	(DE),A		; C R
	INC	DE
;
	LD	A,(HL)
	LD	(DE),A		; A R
ICC0A0
	RET
;
;
;=====================================
;=======================================
NHARTVD
	DB	$98,$CB,$06
	DB	$7E,$7E,$7E,$7E,$7E,$7E,$7E
	DB	$98,$EB,$06
	DB	$7E,$7E,$7E,$7E,$7E,$7E,$7E
	DB	$00
NHARTVD2
	DB	$99,$2B,$06
	DB	$7E,$7E,$7E,$7E,$7E,$7E,$7E
	DB	$99,$4B,$06
	DB	$7E,$7E,$7E,$7E,$7E,$7E,$7E
	DB	$00
NHARTVD3
	DB	$99,$8B,$06
	DB	$7E,$7E,$7E,$7E,$7E,$7E,$7E
	DB	$99,$AB,$06
	DB	$7E,$7E,$7E,$7E,$7E,$7E,$7E
	DB	$00
;
;-------------------------------------
NHARTIT			; For initial set
	LD	A,(VRAMD)
	LD	E,A
	LD	D,$00
	ADD	A,$14
	LD	(VRAMD),A
;
	LD	HL,VRAMD+1
	ADD	HL,DE
	PUSH	DE
;
	LD	BC,NHARTVD
	LD	A,(WORK4)
	AND	A
	JR	Z,NHTI008
;
	LD	BC,NHARTVD2
	CP	$01
	JR	Z,NHTI008
;
	LD	BC,NHARTVD3
NHTI008
	LD	E,$15
;
NHTI010
	LD	A,(BC)
	INC	BC
	LD	(HLI),A
	DEC	E
	JR	NZ,NHTI010
;
	POP	DE
	LD	HL,VRAMD+4
	ADD	HL,DE
;
	LD	C,$00
;
	LD	A,(WORK2)  ;HARTCT)
	AND	A
	JR	Z,NHTI080
;
	LD	(WORK0),A
;
NQWQW
	LD	A,(WORK0)
	SUB	$8
	LD	(WORK0),A
	JR	C,NSSSS
;
	LD	A,$AE
;;	LD	A,$A9
	LD	(HLI),A
;
	INC	C
	LD	A,C
	CP	$07
	JR	NZ,NEEE
;
	LD	A,L
	ADD	A,$3
	LD	L,A
NEEE
	JR	NQWQW
;
NSSSS
	ADD	A,$8
	JR	Z,NHTI080	; Hasuu ?
;				; yes ! harf !
	LD	A,$AE   ;CE
	LD	(HLI),A
	JR	NHTI088 ;INC	C
NHTI080
;
	LD	A,(WORK3)  ;HARTMX)
	CP	C
	JR	Z,NHTI090
;
	LD	A,$AE   ;CD
	LD	(HLI),A
NHTI088
	INC	C
	LD	A,C
	CP	$07
	JR	NZ,NHTI08A
;
	LD	A,L
	ADD	A,$3
	LD	L,A
NHTI08A
	JR	NHTI080
NHTI090
	RET
;==============================================
NAMECK
	XOR	A
	LD	DE,NAMEON
	LD	(DE),A
;
	LD	B,%00000001
;
	LD	C,$00
	LD	HL,NAMEBF
NCK010
	LD	A,(HLI)
	AND	A
	JR	Z,SSTS
;
	LD	A,(DE)	
	OR	B
	LD	(DE),A
;
SSTS
	INC	C
	LD	A,C
	CP	$05
;;	CP	$04
	JR	NZ,WTWW
;
	LD	B,%00000010
WTWW
	CP	$0A
;;	CP	$08
	JR	NZ,RWWW
;
	LD	B,%00000100
RWWW
	CP	$0F
;;	CP	$0C
	JR	NZ,NCK010
;
	RET
;=====================================
DTSAVE
	LD	A,(HARTCT)
	AND	A
	JR	NZ,DTSAVE2
;
	LD	A,(HARTMX)
	LD	E,A
	LD	D,$00
	LD	HL,HARTSTD
	ADD	HL,DE
	LD	A,(HL)
;;	LD	A,$18
	LD	(HARTCT),A
;
DTSAVE2
	CALL	DJITRV
;
	LD	A,(NMSLPT)
	SLA	A
	LD	E,A
	LD	D,$00
	LD	HL,SVDTAD2
	ADD	HL,DE
	LD	A,(HLI)
	LD	H,(HL)
	LD	L,A
;
	LD	BC,SAVERM
;
	LD	DE,$200+$100+$7F+$01
DTS010
	CALL	SVOPEN	;(SV)
	LD	A,(BC)
	INC	BC
	CALL	SVOPEN	;(SV)
	LD	(HLI),A
	DEC	DE
	LD	A,E
	OR	D
	JR	NZ,DTS010
;
	RET
;==================================
DJITRS
	PUSH	BC
;
	LD	A,(DJFLAG)
	AND	A
	JR	Z,DTS00A
;
	LD	A,(DNJNNO)
	CP	DJMAX ;$20
	JR	NC,DTS00A
	LD	E,A
	SLA	A
	SLA	A
	ADD	A,E
	LD	E,A
	LD	D,$00
	LD	HL,DMAPF1
	ADD	HL,DE
	LD	DE,DMAPF
;
	LD	C,$05
DTS008 
	LD	A,(DE)
	INC	DE
	LD	(HLI),A
	DEC	C
	JR	NZ,DTS008 
;
DTS00A
	POP	BC
	RET
;=====================================
; Enemy data set sub sub
;======================================
ENRVXL
	DB	$A0,$60,$00,$00,0
ENRVXH
	DB	$00,$FF,$00,$00,0
ENRVYL
	DB	$00,$00,$80,$80,0
ENRVYH
	DB	$00,$00,$FF,$00,0
;- - - - - - - - - - - - - - - -
ENISSUB
	LD	HL,ENJYUN
	ADD	HL,DE
	LD	A,(WORKD)
	LD	(HL),A
	INC	A
	LD	(WORKD),A
;--------
	PUSH	BC
;
	LD	A,(SCRLMK)
	LD	C,A
	LD	B,$0
;
	LD	HL,ENRVXL
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK0),A
	LD	HL,ENRVXH
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK1),A
;
	LD	HL,ENRVYL
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK2),A
	LD	HL,ENRVYH
	ADD	HL,BC
	LD	A,(HL)
	LD	(WORK3),A
;
	LD	HL,ENXPSL
	ADD	HL,DE
	LD	A,(WORK0)
	ADD	A,(HL)
	LD	(HL),A
;
	RR	C	; PUSH C
;
	LD	HL,ENXPSH
	ADD	HL,DE
	LD	A,(WORK1)
	RL	C	; POP C
	ADC	A,(HL)
	LD	(HL),A
;
	LD	HL,ENYPSL
	ADD	HL,DE
	LD	A,(WORK2)
	ADD	A,(HL)
	LD	(HL),A
;
	RR	C	; PUSH C
;
	LD	HL,ENYPSH
	ADD	HL,DE
	LD	A,(WORK3)
	RL	C	; POP C
	ADC	A,(HL)
	LD	(HL),A
;
	POP	BC
	RET
;====Enemy data 6 rooms go bit clear check==========
ENBTCK
	LD	C,$06
	LD	A,(GRNDPT)
	LD	HL,ENONBF
EDS001
	CP	(HL)
	JR	Z,EDS002
	INC	HL
	DEC	C
	JR	NZ,EDS001
;
	LD	A,(ENONCT)
	INC	A
	CP	$06
	JR	NZ,EDS000
;
	XOR	A
EDS000
	LD	(ENONCT),A
;
;;;	LD	A,(ENONCT)
	LD	E,A
	LD	D,$00
	LD	HL,ENONBF
	ADD	HL,DE
	LD	E,(HL)
	LD	A,(GRNDPT)
	LD	(HL),A
	LD	HL,ENONOF
	ADD	HL,DE
	LD	(HL),$00
EDS002
	RET
;=====================================
;=====================================================
	END
;
;****************************************
;*      TITLE                           *
;****************************************
TITLMAIN
	LD	A,(ITMODE)
	RST	0
	DW	TLITE0
	DW	TLITF0
	DW	TLIT00
	DW	TLIT01
	DW	TLMV00
	DW	TLMV200
	DW	TLMV220
	DW	TLMV280
;;	DW	TLMV300
	DW	TLMV400
	DW	TLMV500
;====================================
TLITE0
;;	CALL	SOUNDCLR
;
	LD	A,BKCHG
	LD	(BLNKFG),A
;
	XOR	A
	LD	(NMSLPT),A
	LD	(ITEMPT),A
	LD	(GMAPPT),A
;
	CALL	DISPCL	; BGPFG OBP1FG CLER !
;
	JP	ITMINC
;====================================
TLITF0
	LD	A,TLCHG ;BKCH2
	LD	(BLNKFG),A
;
	JP	ITMINC
;====================================
TLIT00
	LD	A,VRMCL  ;BT
	LD	(BLNKFG),A
;
	LD	A,(LCDC)
	AND	%11011111	; Window OFF!
	LD	(LCDCB),A
	LD	(LCDC),A
;
;	CALL	RAMCL2
;	LD	A,%11100100	; パレット データ セット
;	LD	(BGPFG),A
;	LD	A,%00011100	; パレット データ セット
;	LD	(OBP0FG),A
;	LD	A,%11100100	; パレット データ セット
;	LD	(OBP1FG),A
;
;	LD	A,$1
;	LD	(ITMODE),A
;----------------
;
;	LD	A,STEST
;	CALL	ENIDSHL
;;
;	LD	A,$68
;	LD	(ENYPSL+$0F),A
;	LD	A,$50
;	LD	(ENXPSL+$0F),A
;	LD	A,$70
;	LD	(ENTIM3+$0F),A
;
	CALL	ITMINC
	RET
;====================================
TLIT01
;;	LD	A,$01
;;	LD	(SOUND4),A	;(S)
;
	LD	A,TITLBGS
	LD	(VRFLG),A
;
;	LD	A,$2
;	LD	(ITMODE),A
	CALL	ITMINC
;
	LD	A,$E4
	LD	(PLTIM0),A
;- - - - System initial - - -
	LD	A,$E4  ;%00011011	; パレット データ セット
	LD	(BGPFG),A
	LD	(OBP1FG),A
	LD	A,$1C
	LD	(OBP0FG),A
	RET
;====================================
TLMV00
	CALL	TITLSUB
;
;;	CALL	ENEMYL
;
	LD	A,(FRCNT)
	AND	$03
	JR	NZ,TLMV10
;
	LD	HL,PLTIM0
	DEC	(HL)
	JR	NZ,TLMV10
;
	CALL	ITMINC
;
	XOR	A
	LD	(SBHR),A
	LD	(SBCNT),A
TLMV10
	RET
;=============================
TLMV200
;;	CALL	ENEMYL
	CALL	FDIN
;
	LD	A,(SBHR)
	CP	$04
	JR	NZ,TLMV210
;
	CALL	ITMINC
;
	LD	A,VRMCL
	LD	(BLNKFG),A
TLMV210
	RET
;=============================
TLMV220
	XOR	A
	LD	(BGPFG),A
;
	LD	A,ODCHG 
	LD	(BLNKFG),A
	CALL	ITMINC
	RET
;=============================
TLMV280
	LD	A,ODMBG
	LD	(VRFLG),A
;
	LD	A,$AC
	LD	(SCCV),A
ITMSBC
	CALL	ITMINC
;
	XOR	A
	LD	(SBHR),A
	LD	(SBCNT),A
	LD	(BGPFG),A
	LD	(TLSCCT),A
	LD	(TLSCCT2),A
;
	LD	A,$10
	LD	(PLTIM0),A
	RET
;=============================
;TLMV300
;;	CALL	FDOUT
;;;
;;	LD	A,(SBHR)
;;	CP	$04
;;	JR	NZ,TLMV310
;
;	CALL	ITMINC
;TLMV310
;	RET
;=============================
TLMV400
	LD	HL,PLTIM0
	LD	A,(HL)
	AND	A
	JR	Z,TLMV408
;
	DEC	(HL)
TLMV408
;;	LD	A,(FRCNT)
;;	AND	$07
;;	JR	NZ,TLMV410
	LD	HL,TLSCCT2
	DEC	(HL)
	LD	A,(HL)
	AND	%10000000
	JR	Z,TLMV402
;
	LD	(HL),$75
	JR	TLMV40A
TLMV402
	LD	HL,TLSCCT
	INC	(HL)
	LD	A,(HL)
	AND	$07
	JR	NZ,TLMV410
;
TLMV40A
	LD	HL,SCCV
	INC	(HL)
;
	LD	A,(HL)
	CP	$AA
	JP	Z,ITMSBC ;TLMV420
;;	CP	$AB
;;	JP	Z,ITMSBC
;
TLMV410
	CALL	PSLCHK
	RET
;TLMV420
;	CALL	ITMSBC
;;
;	LD	A,$04
;	LD	(PLTIM0),A
;	RET
;=============================
TLMV500
	LD	A,(PLTIM0)
	AND	A
	JR	Z,TLMV510
;
	DEC	A
	LD	(PLTIM0),A
	RET
TLMV510
	JP	GMRESET
;	CALL	FDIN
;;
;	LD	A,(SBHR)
;	CP	$04
;	JP	Z,GMRESET
;
;	RET
;****************************************
;*      Opening                         *
;****************************************
;TLSCVD
;	DB	$0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E,$F
 ;  DB  $10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1A,$1B,$1C,$1D,$1E,$1F
  ; DB  $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F
   ;DB  $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F
   ;DB  $40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E,$4F
;------------------------------------------
TLBGCD
	DB	$E4,$E4,$E4,$E4,$E8,$E8,$EC,$E8
TITLSUB
	LD	A,(FRCNT)
	RRA
	RRA
	RRA
	NOP
	AND	$07
	LD	E,A
	LD	D,$0
	LD	HL,TLBGCD
	ADD	HL,DE
	LD	A,(HL)
	LD	(BGPFG),A
;	NOP
;
;TLS010
;	LD	A,(LY)
;	CP	$20
;	JR	C,TLS010
;;
;	LD	E,$0
;	LD	D,E
;;
;	LD	C,$2
;
;TLS020
;	LD	A,(STAT)
;	AND	%00000011
;	JR	NZ,TLS020	
;
;	LD	HL,TLSCVD
;	ADD	HL,DE
;	LD	A,(HL)
;	LD	(SCY),A
;
;	DEC	C
;	JR	NZ,TLS020
;;
;	INC	E
;	LD	A,E
;	CP	$20
;	JR	NZ,TLS020
;
;
;
;	XOR	A
;	LD	(SCY),A
;
;
;
;
;
;
