;************************************************************************
;
;
		INCLUDE tl_macro.h
;
		INCLUDE tl_ram.asm
;
		INCLUDE doscall.h
;
;
;************************************************************************
;
;
		ORG	018000H
;
;
;************************************************************************
;
;
;------------------------------------------------------------------------
		GLB	ICON_CALL
		GLB	ICONRTL
;------------------------------------------------------------------------
;
;
;************************************************************************
;
;
;-------------------------------------------------------tl_main.asm------
		EXT	JSRSUB
		EXT	VRAMCL,URAMCL,BGMDST,CHRST0,BLNKOF,FULINT
		EXT	ROTPST
;
		EXT	PANL,DUMP,ICON,NUTS,KANJ
;-------------------------------------------------------tl_check.asm-----
		EXT	RNDSET
;------------------------------------------------------------------------
;
;
;************************************************************************
;
;
		EXTEND
		MEM8
		IDX8

;
;
;************************************************************************
;
;
;
;
;
;
;
;
;
;
;
;************************************************************************
;*									*
;*	DATA								*
;*									*
;************************************************************************
PLMIDT1		EQU	$
		BYTE	1,-1
;
;
;
;
;
;
;
;************************************************************************
;*									*
;*	SFX DOS MENU (ICON) SELECT					*
;*									*
;*						91/11/20		*
;*									*
;************************************************************************
;
;
;
;========================================
ICON_CALL	EQU	$		;CALL ICON_MAIN
		PHB
		PHK
		PLB
;
		JSR	ICON_MAIN	;ICON_MAIN MOVE
;
		PLB
		RTL
;========================================
ICON_MAIN	EQU	$
		LDA	ICNMODE
		BNE	ICON_MOVE
;
		JSL	>FULINT
		JSL	>URAMCL
;
		JSR	DOS_INIT	;DOS INIT
;
		JSR	FULCHR_C	;DOS INIT
;
		INC	ICNMODE		;NEXT MODE
;
		LDA	#0FFH		;HP INT
		STA	>ICBIGBF
;
		JSL	>BLNKOF
		RTS
;
;----------------------------------------
ICON_MOVE	EQU	$
		LDA	>ICBIGBF
		BNE	IO_MOVE20
		STZ	ICNMODE
IO_MOVE20	EQU	$
;
		LDA	#LOW  OAM	;OAM ADR SET
		STA	ICOAMA
		LDA	#HIGH OAM
		STA	ICOAMA+1
;
;		JSL	>OAMCLR		;OAM CLR
;
		LDX	#ICON_ENTRY-1
IO_MOVE10	EQU	$
		JSR	ICON_ENTY
		DEX
		BPL	IO_MOVE10
;
;		JSL	>OAMCHG		;OAMSB SET
		RTS
;========================================
DOS_INIT	EQU	$
;----------------------------------------RS 232C INIT
		MEM16
		IDX8
		REP	#00100000B
;
;			 1111111
;			 5432109876543210
		LDA	#0110000000001100B	;19200 NON PASS8
		DOS	_AUXRST
;
		MEM8
		IDX8
		SEP	#00110000B
;
		RTS
;----------------------------------------test
		MEM8
		IDX16
		REP	#00010000B
;
		LDY	#00000H
;
DSNIT10		EQU	$
		DOS	_AUXSNS
		AND	#080H
		BEQ	DSNIT10
		TYA
		AND	#00FH
		ORA	#040H
		DOS	_AUXOUT
;
		INY
		BPL	DSNIT10
		LDA	#00DH			;#00AH
		DOS	_AUXOUT
		LDA	#00AH
		DOS	_AUXOUT
;
		MEM8
		IDX8
		SEP	#00110000B
;----------------------------------------
;
;
		RTS
;========================================
ICON_ENTY	EQU	$
		LDA	ICMODE,X
		BEQ	ICONINT
		JMP	ICONMOV
;========================================
ICONINT		EQU	$
		INC	ICMODE,X	;NEXT MOVE MODE
;
		LDA	#030H		;ICON ATR SET
		STA	ICCLOR,X
;
		TXA
		JSL	>JSRSUB
;--
		WORD	NOMOSIT
		WORD	NEWDRIT
;
		WORD	FRMTHIT
		WORD	FRMT9IT
		WORD	FRMT8IT
		WORD	RS232IT
		WORD	GAME0IT
		WORD	KANJIIT
;--
		WORD	CONSLIT		;CONSOLE
;--
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
		WORD	UNIUNIT
;========================================
ICONMOV		EQU	$
		TXA
		JSL	>JSRSUB
;--
		WORD	NOMOSMV
		WORD	NEWDRMV
;
		WORD	FRMTHMV
		WORD	FRMT9MV
		WORD	FRMT8MV
		WORD	RS232MV
		WORD	GAME0MV
		WORD	KANJIMV
;--
		WORD	CONSLMV		;CONSOLE
;--
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
		WORD	UNIUNMV
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
NOMOSIT		EQU	$
;----------------------------------------
NEWDRIT		EQU	$
;----------------------------------------
FRMTHIT		EQU	$
;----------------------------------------
FRMT9IT		EQU	$
;----------------------------------------
FRMT8IT		EQU	$
;----------------------------------------
RS232IT		EQU	$
;----------------------------------------
GAME0IT		EQU	$
;----------------------------------------
KANJIIT		EQU	$
;----------------------------------------
		TXA
		AND	#003H
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	#010H
		STA	ICXPSL,X
		TXA
		AND	#0FCH
		ASL	A
		ASL	A
		ASL	A
		ADC	#008H
		STA	ICYPSL,X
;
		RTS
;----------------------------------------
UNIUNIT		EQU	$
		LDA	#080H
		STA	ICXPSL,X
		STA	ICYPSL,X
		RTS
;----------------------------------------
NOMOSMV		EQU	$
		JSR	NOMOSCS
		JSR	ICSTCK
;		JSR	ICMVCL
;
;		LDA	<FRCNT
;		AND	#007H
;		BNE	NMSMV10
;		JSR	ICSTOP
;
;;;;;;;;;----------------------------------------------------------------
;;;;;;;;;-	rotation pos set					-
;;;;;;;;;-		in  : (WK0,1) <-- center X pos			-
;;;;;;;;;-		      (WK2,3) <--    "   Y  "			-
;;;;;;;;;-		      (WK4,5) <-- R				-
;;;;;;;;;-		      (WK6,7) <-- angle				-
;;;;;;;;;-		out : (WK8,9) <-- ans. X pos			-
;;;;;;;;;-		      (WKA,B) <--   "  Y  "			-
;;;;;;;;;----------------------------------------------------------------
;;;;;;;;		LDA	#072H
;;;;;;;;		STA	<WORK0		;center X Y pos
;;;;;;;;		STA	<WORK2
;;;;;;;;		STZ	<WORK1
;;;;;;;;		STZ	<WORK3
;;;;;;;;		LDA	<FRCNT
;;;;;;;;		BPL	NMSMV50
;;;;;;;;		EOR	#0FFH
;;;;;;;;NMSMV50		EQU	$
;;;;;;;;		STA	<WORK4		;R
;;;;;;;;		STZ	<WORK5
;;;;;;;;		LDA	<FRCNT		;angle
;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		STA	<WORK6
;;;;;;;;		STZ	<WORK7
;;;;;;;;		JSR	ICON_C		;MOVE
;;;;;;;;		LDA	<WORK8
;;;;;;;;		STA	<WORK0
;;;;;;;;		LDA	<WORK9
;;;;;;;;		STA	<WORK1
;;;;;;;;		LDA	<WORKA
;;;;;;;;		STA	<WORK2
;;;;;;;;		LDA	<WORKB
;;;;;;;;		STA	<WORK3
;;;;;;;;;
;;;;;;;;;		LDA	#072H
;;;;;;;;;		STA	<WORK0		;center X Y pos
;;;;;;;;;		STA	<WORK2
;;;;;;;;;		STZ	<WORK1
;;;;;;;;;		STZ	<WORK3
;;;;;;;;		LDA	<FRCNT
;;;;;;;;		BPL	NMSMV30
;;;;;;;;		EOR	#0FFH
;;;;;;;;NMSMV30		EQU	$
;;;;;;;;		STA	<WORK4		;R
;;;;;;;;		STZ	<WORK5
;;;;;;;;		TXA
;;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		CLC
;;;;;;;;		ADC	<FRCNT
;;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		ASL	A
;;;;;;;;		STA	<WORK6		;angle
;;;;;;;;		STZ	<WORK7
;;;;;;;;;
;;;;;;;;		JSR	ICON_C		;MOVE
;;;;;;;;		LDA	<WORK8
;;;;;;;;		STA	ICXPSL,X
;;;;;;;;		LDA	<WORK9
;;;;;;;;		STA	ICXPSH,X
;;;;;;;;		LDA	<WORKA
;;;;;;;;		STA	ICYPSL,X
;;;;;;;;		LDA	<WORKB
;;;;;;;;		STA	ICYPSH,X
;;;;;;;;;
NMSMV10		EQU	$
		LDA	ICSLCT,X
		BNE	NMSMV20
;
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#001H
		STA	ICCHPT,X
;
		RTS
;
;
NMSMV20		EQU	$
		LDA	<KEYC1
		AND	#0C0H
		BEQ	NMSMV40
		LDA	#DUMP
		JSR	ICNEXT		;NEXT MODE SET
NMSMV40		EQU	$
		LDA	<FRCNT
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		AND	#003H
		CLC
		ADC	#002H
		STA	ICCHPT,X
		RTS
;----------------------------------------
NOMOSCD		EQU	$
		WORD	00008,00008
		BYTE	0E4H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
		WORD	00008,00008
		BYTE	0E6H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
		WORD	00008,00008
		BYTE	0E0H,003H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,003H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,043H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,083H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C3H,000H,002H
;
		WORD	00008,00008
		BYTE	0E2H,003H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,003H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,043H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,083H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C3H,000H,002H
;
		WORD	00008,00008
		BYTE	0E0H,003H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,003H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,043H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,083H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C3H,000H,002H
;
		WORD	00008,00008
		BYTE	0E2H,043H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,003H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,043H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,083H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C3H,000H,002H
;
;
NOMOSCS		EQU	$
		LDA	#005H		;#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ICCHPT,X
		ASL	A
		ASL	A
		ADC	ICCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  NOMOSCD
		STA	<WORK8
		LDA	#HIGH NOMOSCD
		ADC	#000H
		STA	<WORK9
;
		JMP	SETOAM2
;========================================
NEWDRMV		EQU	$
		JSR	NEWDRCS
		JSR	ICSTCK
;		JSR	ICMVCL
;
		LDA	ICSLCT,X
		BEQ	NWRMV10
		LDA	<KEYC1
		AND	#0C0H
		BEQ	NWRMV10
		LDA	#PANL
		JSR	ICNEXT		;NEXT MODE SET
NWRMV10		EQU	$
		RTS
;----------------------------------------
NEWDRCD		EQU	$
		WORD	00008,00008
		BYTE	0C0H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
		WORD	00008,00008
		BYTE	0C2H,003H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,003H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,043H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,083H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C3H,000H,002H
;
;
NEWDRCS		EQU	$
		LDA	#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ICSLCT,X
		ASL	A
		ASL	A
		ADC	ICSLCT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  NEWDRCD
		STA	<WORK8
		LDA	#HIGH NEWDRCD
		ADC	#000H
		STA	<WORK9
;
		JMP	SETOAM2
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
FRMTHMV		EQU	$
		JSR	FRMTHCS
		JSR	ICSTCK
		JSR	ICERRCS
;
		LDA	ICSLCT,X
		ASL	A
		STA	ICCLOR,X
		BEQ	FMHMV10
;----------------------------------------;console on
		JSR	FRMTHMS
		LDA	<KEYC2
		AND	#010H
		BEQ	FMHMV20
		LDA	#002H
		DOS	_DSKRST
		DOS	_FORMAT
		CMP	#000H
		BEQ	FMHMV20
		LDA	#080H
		STA	ICERRT,X
FMHMV20		EQU	$
		RTS
;----------------------------------------;console off
FMHMV10		EQU	$
		STZ	ICERRT,X
		RTS
;----------------------------------------
FRMTHCD		EQU	$
		WORD	00008,00008
		BYTE	0C8H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
;
FRMTHCS		EQU	$
		LDA	#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW  FRMTHCD
		STA	<WORK8
		LDA	#HIGH FRMTHCD
		STA	<WORK9
;
		JMP	SETOAM2
;----------------------------------------
FMTHMD0		EQU	$
		BYTE	'D', 'R', 'I', 'V', 'E'
		BYTE	' ', 'A', ':', ' ', 'F'
		BYTE	'O', 'R', 'M', 'A', 'T'
		BYTE	' ', '2', 'H', 'D', ' '
		BYTE	'O', 'K', '?'
;
FMTHMD1		EQU	$
		BYTE	'P', 'U', 'S', 'H', ' '
		BYTE	027H,'S', 'T', 'A', 'R'
		BYTE	'T',027H, ' ', '-', '-'
		BYTE	'>', ' ', 'F', 'O', 'R'
		BYTE	'M', 'A', 'T'
;
;
FRMTHMS		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000B0H			;Y POINT
		STA	<WORK2
;
		LDA	#00023			;KAZU
		STA	<WORK6
;
		LDA	#03000H			;ATR SET
		STA	<WORK4
;
		LDA	#FMTHMD0		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSR	PRINTSB			;MOJI SET
;
;
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000C0H			;Y POINT
		STA	<WORK2
;
		LDA	#00023			;KAZU
		STA	<WORK6
;
		LDA	<FRCNT-1
		AND	#00600H
		ORA	#03000H			;ATR SET
		STA	<WORK4
		STA	<WORK4
;
		LDA	#FMTHMD1		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JMP	PRINTSB			;MOJI SET
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
FRMT9MV		EQU	$
		JSR	FRMT9CS
		JSR	ICSTCK
		JSR	ICERRCS
;
		LDA	ICSLCT,X
		ASL	A
		STA	ICCLOR,X
		BEQ	FM9MV10
;----------------------------------------;console on
		JSR	FRMT9MS
		LDA	<KEYC2
		AND	#010H
		BEQ	FM9MV20
		LDA	#002H
		DOS	_DSKRST
		DOS	_FORMAT
		CMP	#000H
		BEQ	FM9MV20
		LDA	#080H
		STA	ICERRT,X
FM9MV20		EQU	$
		RTS
;----------------------------------------;console off
FM9MV10		EQU	$
		STZ	ICERRT,X
		RTS
;----------------------------------------
FRMT9CD		EQU	$
		WORD	00008,00008
		BYTE	0C4H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
;
FRMT9CS		EQU	$
		LDA	#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW  FRMT9CD
		STA	<WORK8
		LDA	#HIGH FRMT9CD
		STA	<WORK9
;
		JMP	SETOAM2
;----------------------------------------
FMT9MD0		EQU	$
		BYTE	'D', 'R', 'I', 'V', 'E'
		BYTE	' ', 'A', ':', ' ', 'F'
		BYTE	'O', 'R', 'M', 'A', 'T'
		BYTE	' ', '2', 'D', 'D', '('
		BYTE	'9', ')', ' ', 'O', 'K'
		BYTE	'?'
;
FMT9MD1		EQU	$
		BYTE	'P', 'U', 'S', 'H', ' '
		BYTE	027H,'S', 'T', 'A', 'R'
		BYTE	'T',027H, ' ', '-', '-'
		BYTE	'>', ' ', 'F', 'O', 'R'
		BYTE	'M', 'A', 'T'
;
;
FRMT9MS		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000B0H			;Y POINT
		STA	<WORK2
;
		LDA	#00026			;KAZU
		STA	<WORK6
;
		LDA	#03000H			;ATR SET
		STA	<WORK4
;
		LDA	#FMT9MD0		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSR	PRINTSB			;MOJI SET
;
;
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000C0H			;Y POINT
		STA	<WORK2
;
		LDA	#00023			;KAZU
		STA	<WORK6
;
		LDA	<FRCNT-1
		AND	#00600H
		ORA	#03000H			;ATR SET
		STA	<WORK4
		STA	<WORK4
;
		LDA	#FMT9MD1		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JMP	PRINTSB			;MOJI SET
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
FRMT8MV		EQU	$
		JSR	FRMT8CS
		JSR	ICSTCK
		JSR	ICERRCS
;
		LDA	ICSLCT,X
		ASL	A
		STA	ICCLOR,X
		BEQ	FM8MV10
;----------------------------------------;console on
		JSR	FRMT8MS
		LDA	<KEYC2
		AND	#010H
		BEQ	FM8MV20
		LDA	#001H
		DOS	_DSKRST
		DOS	_FORMAT
		CMP	#000H
		BEQ	FM8MV20
		LDA	#080H
		STA	ICERRT,X
FM8MV20		EQU	$
		RTS
;----------------------------------------;console off
FM8MV10		EQU	$
		STZ	ICERRT,X
		RTS
;----------------------------------------
FRMT8CD		EQU	$
		WORD	00008,00008
		BYTE	0C6H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
;
FRMT8CS		EQU	$
		LDA	#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	#LOW  FRMT8CD
		STA	<WORK8
		LDA	#HIGH FRMT8CD
		STA	<WORK9
;
		JMP	SETOAM2
;----------------------------------------
FMT8MD0		EQU	$
		BYTE	'D', 'R', 'I', 'V', 'E'
		BYTE	' ', 'A', ':', ' ', 'F'
		BYTE	'O', 'R', 'M', 'A', 'T'
		BYTE	' ', '2', 'D', 'D', '('
		BYTE	'8', ')', ' ', 'O', 'K'
		BYTE	'?'
;
FMT8MD1		EQU	$
		BYTE	'P', 'U', 'S', 'H', ' '
		BYTE	027H,'S', 'T', 'A', 'R'
		BYTE	'T',027H, ' ', '-', '-'
		BYTE	'>', ' ', 'F', 'O', 'R'
		BYTE	'M', 'A', 'T'
;
;
FRMT8MS		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000B0H			;Y POINT
		STA	<WORK2
;
		LDA	#00026			;KAZU
		STA	<WORK6
;
		LDA	#03000H			;ATR SET
		STA	<WORK4
;
		LDA	#FMT8MD0		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSR	PRINTSB			;MOJI SET
;
;
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000C0H			;Y POINT
		STA	<WORK2
;
		LDA	#00023			;KAZU
		STA	<WORK6
;
		LDA	<FRCNT-1
		AND	#00600H
		ORA	#03000H			;ATR SET
		STA	<WORK4
		STA	<WORK4
;
		LDA	#FMT8MD1		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JMP	PRINTSB			;MOJI SET
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
RS232MV		EQU	$
		JSR	RS232CS
		JSR	ICSTCK
		JSR	ICERRCS
;
		LDA	ICSLCT,X
		ASL	A
		STA	ICCLOR,X
;
		BNE	R22MV10
;
		RTS
;----------------------------------------
R22MV10		EQU	$
		JSR	RS232MS
;
		LDA	<KEYC2
		AND	#010H
		BEQ	R22MV20
		LDA	#07FH
		STA	<WORK1
		LDA	#0FFH
		STA	<WORK0
		JSR	RS232CR			;RS232C 7FFFH BYTE READ
;
R22MV20		EQU	$
		RTS
;----------------------------------------
RS232CR		EQU	$
		DOS	_AUXSNS
		AND	#01000000B
		BEQ	RS232CR			;R22CR20
;
		PHX
;
		MEM8
		IDX16
		REP	#00010000B
;
		LDX	#00000H
R22CR10		EQU	$
		DOS	_AUXIN
		STA	>ICBIGBF,X
		INX
		LDY	<WORK0
		DEY
		STY	<WORK0
		BPL	R22CR10
R22CR20		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		RTS
;----------------------------------------
RS232CD		EQU	$
		WORD	00008,00008
		BYTE	0CAH,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
		WORD	00008,00008
		BYTE	0CCH,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
;
RS232CS		EQU	$
		LDA	#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ICSLCT,X
		ASL	A
		ASL	A
		ADC	ICSLCT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  RS232CD
		STA	<WORK8
		LDA	#HIGH RS232CD
		ADC	#000H
		STA	<WORK9
;
		JMP	SETOAM2
;----------------------------------------
RS232MS		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000B0H			;Y POINT
		STA	<WORK2
;
		LDA	#00001			;KAZU
		STA	<WORK6
;
		LDA	#03000H			;ATR SET
		STA	<WORK4
;
		TXA
		AND	#000FFH
		CLC
		ADC	#ICSTAT		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		PHB
		LDA	#BANK ICSTAT
		PHA
		PLB
		JSR	PRINTSB			;MOJI SET
		PLB
		RTS
;
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
USP		EQU	20
;
UNIUNSX		EQU	$
		BYTE	000,000,USP,-USP
UNIUNSY		EQU	$
		BYTE	USP,-USP,000,000
;
UNIUNMV		EQU	$
		RTS
;
		JSR	UNIUNCS
		JSR	ICSTCK
		STZ	ICCLOR,X
		JSR	UNIUNCH
		BCC	UINMV60
		LDA	#002H
		STA	ICCLOR,X
		LDA	>ICBIGBF
		BEQ	UINMV60
		SEC
		SBC	#001H
		STA	>ICBIGBF
UINMV60		EQU	$
		JSR	ICMVCL
;
		TXA
		AND	#00FH
		BEQ	UINMV30
		CLC
		ADC	<FRCNT
		AND	#007H
		BNE	UINMV20
;
		LDA	ICXPSL-1,X
		STA	<WORK0
		LDA	ICXPSH-1,X
		STA	<WORK1
		LDA	ICYPSL-1,X
		STA	<WORK4
		LDA	ICYPSH-1,X
		STA	<WORK5
UINMV40		EQU	$
		LDA	ICXPSL,X
		STA	<WORK2
		LDA	ICXPSH,X
		STA	<WORK3
		LDA	ICYPSL,X
		STA	<WORK6
		LDA	ICYPSH,X
		STA	<WORK7
		LDA	#USP
		JSR	ICFIND
		LDA	<WORK0
		STA	ICXSPD,X
		LDA	<WORK2
		STA	ICYSPD,X
;
UINMV20		EQU	$
		LDA	ICTIM0,X
		BNE	UINMV10
;
		LDA	#009H
		STA	ICTIM0,X
		LDA	ICCHPT,X
		INC	A
		AND	#003H
		STA	ICCHPT,X
;
UINMV10		EQU	$
		RTS
;
UINMV30		EQU	$
		JSL	>RNDSET
		AND	#00FH
;
		BNE	UINMV50
		JSL	>RNDSET
		STA	ICSLCT,X
		JSL	>RNDSET
		STA	ICERRT,X
UINMV50		EQU	$
		LDA	ICSLCT,X
		STA	<WORK0
		LDA	ICXPSH+7
		STA	<WORK1
		LDA	ICERRT,X
		STA	<WORK4
		LDA	ICYPSH+7
		STA	<WORK5
		BRA	UINMV40
;----------------------------------------
UNIUNCD		EQU	$
		WORD	00000,00000
		BYTE	0CEH,001H,000H,000H
		WORD	00000,00000
		BYTE	0CFH,001H,000H,000H
		WORD	00000,00000
		BYTE	0DEH,001H,000H,000H
		WORD	00000,00000
		BYTE	0DFH,001H,000H,000H
;
;
UNIUNCS		EQU	$
		LDA	#001H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ICCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  UNIUNCD
		STA	<WORK8
		LDA	#HIGH UNIUNCD
		ADC	#000H
		STA	<WORK9
;
		JMP	SETOAM2
;----------------------------------------
UNIUNCH		EQU	$
		LDA	ICXPSL,X
		STA	<WORK0
		LDA	ICXPSH,X
		STA	<WORK1
		LDA	ICYPSL,X
		STA	<WORK2
		LDA	ICYPSH,X
		STA	<WORK3
		LDA	ICXPSL+7
		STA	<WORK4
		LDA	ICXPSH+7
		STA	<WORK5
		LDA	ICYPSL+7
		STA	<WORK6
		LDA	ICYPSH+7
		STA	<WORK7
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<WORK0
		SEC
		SBC	<WORK4
		CLC
		ADC	#00008H
		CMP	#00010H
		BCS	UINCH10
;
		LDA	<WORK2
		SEC
		SBC	<WORK6
		CLC
		ADC	#00008H
		CMP	#00010H
		BCS	UINCH10
;
		MEM8			;ATARI
		IDX8
		SEP	#00110000B
		SEC
		RTS
;
UINCH10		EQU	$		;HAZURE
		MEM8
		IDX8
		SEP	#00110000B
		CLC
		RTS
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
GAME0MV		EQU	$
		JSR	GAME0CS
		JSR	ICSTCK
;
		LDA	ICSLCT,X
		ASL	A
		STA	ICCLOR,X
;
		BEQ	GM0MV10
		LDA	<KEYC1
		AND	#0C0H
		BEQ	GM0MV10
		LDA	#NUTS
		JSR	ICNEXT		;NEXT MODE SET
;
		JSR	NTINIT
GM0MV10		EQU	$
		RTS
;----------------------------------------
NTINIT		EQU	$
		STZ	NTMODE
		RTS
;----------------------------------------
GAME0CD		EQU	$
		WORD	00008,00008
		BYTE	0A8H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
		WORD	00008,00008
		BYTE	0E8H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
;
GAME0CS		EQU	$
		LDA	#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ICSLCT,X
		ASL	A
		ASL	A
		ADC	ICSLCT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  GAME0CD
		STA	<WORK8
		LDA	#HIGH GAME0CD
		ADC	#000H
		STA	<WORK9
;
		JMP	SETOAM2
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
KANJIMV		EQU	$
		JSR	KANJICS
		JSR	ICSTCK
;
		LDA	ICSLCT,X
		ASL	A
		STA	ICCLOR,X
;
		BEQ	KNIMV10
		LDA	<KEYC1
		AND	#0C0H
		BEQ	KNIMV10
		LDA	#KANJ
		JSR	ICNEXT		;NEXT MODE SET
;
KNIMV10		EQU	$
		RTS
;----------------------------------------
KANJICD		EQU	$
		WORD	00008,00008
		BYTE	0A8H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
		WORD	00008,00008
		BYTE	0E8H,001H,000H,002H
		WORD	00000,00000
		BYTE	0EEH,001H,000H,002H
		WORD	00016,00000
		BYTE	0EEH,041H,000H,002H
		WORD	00000,00016
		BYTE	0EEH,081H,000H,002H
		WORD	00016,00016
		BYTE	0EEH,0C1H,000H,002H
;
;
KANJICS		EQU	$
		LDA	#005H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ICSLCT,X
		ASL	A
		ASL	A
		ADC	ICSLCT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  KANJICD
		STA	<WORK8
		LDA	#HIGH KANJICD
		ADC	#000H
		STA	<WORK9
;
		JMP	SETOAM2
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
ICERRCD		EQU	$
		BYTE	'E', 'R', 'R', 'O', 'R'
;
;
ICERRCS		EQU	$
		LDA	ICERRT,X
		BEQ	IERCS20
		JSR	IERCS10
IERCS20		EQU	$
		RTS
;----------------------------------------
IERCS10		EQU	$
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00070H			;X POINT
		STA	<WORK0
		LDA	#000D0H			;Y POINT
		STA	<WORK2
;
		LDA	#00005			;KAZU
		STA	<WORK6
;
		LDA	#03000H			;ATR SET
		STA	<WORK4
;
		LDA	#ICERRCD		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JMP	PRINTSB			;MOJI SET
;
;
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
CONSLIT		EQU	$
		LDA	#078H
		STA	ICXPSL,X
		STA	ICYPSL,X
;
		STZ	NSSTAT
		STZ	NSSTAT+1
;
		LDA	#0FH
		STA	ICXSPD,X
		LDA	#01H
		STA	ICYSPD,X
		STA	NSYSPD 
		STZ	NSXSPD
		RTS
;----------------------------------------
CNLMVSX		EQU	$
CNLMVSY		EQU	$
		BYTE	000,064,-64,000
;;;ICXSAD		EQU	$
;;;ICYSAD		EQU	$
;;;		HEX	01,FF
;;;ICXSLM		EQU	$
;;;ICYSLM		EQU	$
;;;		HEX	10,F0
;;;;
;;;;
CONSLMV		EQU	$
		JSR	CONSLCS
		JSR	CONSLMS
		JSR	ICSTCK
;
;;;		BIT	<KEYC2
;;;		BPL	IT0008
;;;;
;;;		INC	NSSTAT+1
;;;IT0008		EQU	$
;;;		BVC	IT0009
;;;;
;;;		LDA	NSSTAT+1
;;;		BEQ	IT0009
;;;		DEC	NSSTAT+1
;;;IT0009		EQU	$
;;;;
;;;		DEC	NSSTAT
;;;		BPL	IT0020
;;;;
;;;		LDA	NSSTAT+1
;;;		STA	NSSTAT
;;;;
;;;		LDA	NSXSPD
;;;		AND	#01H
;;;		TAY
;;;		LDA	ICXSPD,X
;;;		CLC
;;;		ADC	ICXSAD,Y
;;;		STA	ICXSPD,X
;;;		CMP	ICXSLM,Y
;;;		BNE	IT0010
;;;		INC	NSXSPD
;;;IT0010		EQU	$
;;;		LDA	NSYSPD
;;;		AND	#01H
;;;		TAY
;;;		LDA	ICYSPD,X
;;;		CLC
;;;		ADC	ICYSAD,Y
;;;		STA	ICYSPD,X
;;;		CMP	ICYSLM,Y
;;;		BNE	IT0020
;;;		INC	NSYSPD
;;;IT0020		EQU	$
;;;		JSR	ICMVCL
;;;		LDA	ICXPSL,X
;;;		STA	<WORK0
;;;		LDA	ICYPSL,X
;;;		STA	<WORK1
;;;		LDA	<FRCNT
;;;		AND	#0C0H
;;;		LSR	A
;;;		LSR	A
;;;		LSR	A
;;;		LSR	A
;;;		LSR	A
;;;		LSR	A
;;;		ORA	#001H
;;;		STA	<WORK2
;;;		JSR	FULCHR_P
;;;		RTS
;;;;=======================================================
		LDA	ICXPSL,X
		STA	<WORK0
		LDA	ICYPSL,X
		STA	<WORK1
		LDA	#000H
		STA	<WORK2
		JSR	FULCHR_L
;
		JSR	ICMVCL
;
		LDA	ICXPSL,X
		STA	<WORK0
		LDA	ICYPSL,X
		STA	<WORK1
		LDA	#001H
		STA	<WORK2
		JSR	FULCHR_L
;		JSR	FULCHR_P
;
		STZ	ICCHPT,X	;CONSOLE SMALL
		JSR	CONSLCK		;ICON TO ATARI CHK
		BCC	CNLMV10
		INC	ICCHPT,X	;CONSOLE BIG
;
CNLMV10		EQU	$		;CONSOLE MOVE
		STZ	ICXPSH,X
		STZ	ICYPSH,X
;
		LDA	<KEYC1		;X SPEED SET
		AND	#003H
		TAY
		LDA	CNLMVSX,Y
		STA	ICXSPD,X
;
		LDA	<KEYC1		;Y SPEED SET
		LSR	A
		LSR	A
		AND	#003H
		TAY
		LDA	CNLMVSY,Y
		STA	ICYSPD,X
;
		RTS
;----------------------------------------
CONSLCK		EQU	$
		LDA	ICXPSL,X
		CLC
		ADC	#003H		;CONSOLE X POS SENTER
		STA	<WORK0
		LDA	ICXPSH,X
		ADC	#000H
		STA	<WORK1
;
		LDA	ICYPSL,X
		CLC
		ADC	#003H		;CONSOLE Y POS SENTER
		STA	<WORK2
		LDA	ICYPSH,X
		ADC	#000H
		STA	<WORK3
;
		TXY			;X SAVE
;
		TXA			;ICON INDEX
		SEC
		SBC	#001H
		TAX
;
CNLCK40		EQU	$
		STZ	ICSLCT,X	;ICON SELECT FLG CLS
		DEX
		BPL	CNLCK40
;
		TAX
CNLCK10		EQU	$
		LDA	ICXPSL,X
		CLC
		ADC	#010H		;ICON X POS SENTER
		STA	<WORK4
		LDA	ICXPSH,X
		ADC	#000H
		STA	<WORK5
;
		LDA	ICYPSL,X
		CLC
		ADC	#010H		;ICON Y POS SENTER
		STA	<WORK6
		LDA	ICYPSH,X
		ADC	#000H
		STA	<WORK7
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	<WORK0
		SEC
		SBC	<WORK4
		BPL	CNLCK20
		EOR	#0FFFFH
		INC	A
CNLCK20		EQU	$
		CMP	#00013H		;(ICON r) + (CONSOLE r)
		BCS	CNLCK80
;
		LDA	<WORK2
		SEC
		SBC	<WORK6
		BPL	CNLCK30
		EOR	#0FFFFH
		INC	A
CNLCK30		EQU	$
		CMP	#00013H		;(ICON r) + (CONSOLE r)
		BCS	CNLCK80
;
		MEM8
		IDX8
		SEP	#00110000B
;
		INC	ICSLCT,X	;ICON SELECT OK
		TYX
		SEC
		RTS
;
CNLCK80		EQU	$
		MEM8
		IDX8
		SEP	#00110000B
;
		DEX
		BPL	CNLCK10
;
		TYX			;ICON SELECT BUT
		CLC
		RTS
;----------------------------------------
CONSLCD		EQU	$
		WORD	00000,00000
		BYTE	0FCH,007H,000H,000H
;
		WORD	00000,-0008
		BYTE	0ECH,007H,000H,002H
;
;
CONSLCS		EQU	$
		LDA	#001H
		STA	<WORK6
		STZ	<WORK7
;
		LDA	ICCHPT,X
		ASL	A
		ASL	A
		ASL	A
		ADC	#LOW  CONSLCD
		STA	<WORK8
		LDA	#HIGH CONSLCD
		ADC	#000H
		STA	<WORK9
;
		JMP	SETOAM2
;----------------------------------------
CONSLMS		EQU	$
		LDA	>ICBIGBF
		LDA	ICXPSL,X
		JSR	ICSUJI			;SUJI OBJ SET
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00010H			;X POINT
		STA	<WORK0
		LDA	#000D0H			;Y POINT
		STA	<WORK2
;
		LDA	#00003			;KAZU
		STA	<WORK6
;
		LDA	#03000H			;ATR SET
		STA	<WORK4
;
		LDA	#ICMINBF		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JSR	PRINTSB			;MOJI SET
;
		LDA	ICYPSL,X
		JSR	ICSUJI			;SUJI OBJ SET
;
		MEM16
		IDX8
		REP	#00100000B
;
		LDA	#00030H			;X POINT
		STA	<WORK0
		LDA	#000D0H			;Y POINT
		STA	<WORK2
;
		LDA	#00003			;KAZU
		STA	<WORK6
;
		LDA	#03000H			;ATR SET
		STA	<WORK4
;
		LDA	#ICMINBF		;ADD SET
		STA	<WORK8
;
		MEM8
		IDX8
		SEP	#00110000B
;
		JMP	PRINTSB			;MOJI SET
;
;========================================
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;========================================
FULCHR_C	EQU	$			;CLS 3
		PHY
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	#00000H
		LDX	#04000H-2
FLHR_C10	EQU	$
		STA	>FULCHR,X
		DEX
		DEX
		BPL	FLHR_C10
;
		MEM8
		IDX8
		SEP	#00110000B
		PLX
		PLY
;
		RTS
;----------------------------------------
FULCHR_L	EQU	$			;LINE
		LDA	<WORK0
		STA	<WORK3
		LDA	<WORK1
		STA	<WORK4
		STZ	<WORK0
		STZ	<WORK1
		PHY
		PHX
;
		LDA	<WORK3
		CMP	<WORK4
		BCC	FLHR_L10
;
		LDA	<WORK3
		LSR	A
		STA	<WORK5
;
FLHR_L30	EQU	$
		LDA	<WORK4
		CLC
		ADC	<WORK5
		STA	<WORK5
;
		BCS	FLHR_L38
		CMP	<WORK3
		BCC	FLHR_L20
FLHR_L38	EQU	$
		SBC	<WORK3
		STA	<WORK5
		INC	<WORK1
FLHR_L20	EQU	$
		INC	<WORK0
;
		JSR	FULCHR_P
;
		LDA	<WORK0
		CMP	<WORK3
		BNE	FLHR_L30
		LDA	<WORK1
		CMP	<WORK4
		BNE	FLHR_L30
		BRA	FLHR_LEX
;
FLHR_L10	EQU	$
		LDA	<WORK4
		LSR	A
		STA	<WORK5
;
FLHR_L50	EQU	$
		LDA	<WORK3
		CLC
		ADC	<WORK5
		STA	<WORK5
;
		BCS	FLHR_L48
		CMP	<WORK4
		BCC	FLHR_L40
FLHR_L48	EQU	$
		SBC	<WORK4
		STA	<WORK5
		INC	<WORK0
FLHR_L40	EQU	$
		INC	<WORK1
;
		JSR	FULCHR_P
;
		LDA	<WORK0
		CMP	<WORK3
		BNE	FLHR_L50
		LDA	<WORK1
		CMP	<WORK4
		BNE	FLHR_L50
;
FLHR_LEX	EQU	$
;
		PLX
		PLY
;
		RTS
;----------------------------------------
FULCHR_PDT	EQU	$
		WORD	00000H,00080H,08000H,08080H
		WORD	00000H,00040H,04000H,04040H
		WORD	00000H,00020H,02000H,02020H
		WORD	00000H,00010H,01000H,01010H
		WORD	00000H,00008H,00800H,00808H
		WORD	00000H,00004H,00400H,00404H
		WORD	00000H,00002H,00200H,00202H
		WORD	00000H,00001H,00100H,00101H
;
FULCHR_PAN	EQU	$
		WORD	07F7FH,07F7FH,07F7FH,07F7FH
		WORD	0BFBFH,0BFBFH,0BFBFH,0BFBFH
		WORD	0DFDFH,0DFDFH,0DFDFH,0DFDFH
		WORD	0EFEFH,0EFEFH,0EFEFH,0EFEFH
		WORD	0F7F7H,0F7F7H,0F7F7H,0F7F7H
		WORD	0FBFBH,0FBFBH,0FBFBH,0FBFBH
		WORD	0FDFDH,0FDFDH,0FDFDH,0FDFDH
		WORD	0FEFEH,0FEFEH,0FEFEH,0FEFEH
;
;		<WORK0		X POS
;		<WORK1		Y POS
;		<WORK2		COLOR (0-3)
;
FULCHR_P	EQU	$			;PSET
		PHY
		PHX
		MEM16
		IDX16
		REP	#00110000B
;
		LDA	<WORK0		;X POS
		ASL	A
		PHA
		ASL	A
		AND	#0001CH
		STA	<WORKE
		LDA	<WORK2
		AND	#0003H
		CLC
		ADC	<WORKE
		ASL	A
		TAY
		PLA
		AND	#001F0H
		STA	<WORKE
;
		LDA	<WORK1		;Y POS
		ASL	A
		PHA
		AND	#0000EH
		ADC	<WORKE
		STA	<WORKE
		PLA
		AND	#001F0H
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		ADC	<WORKE
		TAX
;
		LDA	>FULCHR,X
		AND	FULCHR_PAN,Y
		ORA	FULCHR_PDT,Y
		STA	>FULCHR,X
;
		MEM8
		IDX8
		SEP	#00110000B
		PLX
		PLY
;
		RTS
;========================================
;		<WORK0,1	FIND POINT X
;		<WORK2,3	MY POINT X
;		<WORK4,5	FIND POINT Y
;		<WORK6,7	MY POINT Y
;
;		A		SPEED
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;		<WORK0		X SPEED
;		<WORK2		Y SPEED
;
;----------------------------------------
ICFIND		EQU	$
		STA	<WORKF			;FIND SPEED
		STZ	<WORKE
;
		MEM16
		IDX8
		REP	#00100000B
;
		STZ	<WORKA			;X (+) 0R (-) FLG CLS
		STZ	<WORKC			;Y (+) 0R (-) FLG CLS
;
		LDA	<WORK0			;X
		SEC
		SBC	<WORK2
		BPL	IFND10
		DEC	<WORKA			;(-) FLG SET
		EOR	#0FFFFH
		INC	A
IFND10		EQU	$
		STA	<WORK0
;
		LDA	<WORK4			;Y
		SEC
		SBC	<WORK6
		BPL	IFND20
		DEC	<WORKC			;(-) FLG SET
		EOR	#0FFFFH
		INC	A
IFND20		EQU	$
		STA	<WORK4
;
IFND40		EQU	$
		LDA	<WORK0
		ORA	<WORK4
		CMP	#00100H
		BCC	IFND30
;
		LSR	<WORK0
		LSR	<WORK4
;
		BRA	IFND40
IFND30		EQU	$
		LDA	<WORK0
		CMP	<WORK4
		BEQ	IFNDE0
		BCC	IFND80

;
;
;
		LDA	<WORK4			;X > Y
		ORA	<WORKE
		STA	04202H
		NOP
		NOP
		NOP
		NOP
		LDA	04216H
		STA	04204H
		LDY	<WORK0
		STY	04206H
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		LDA	04214H
		STA	<WORK2
		LDA	<WORKF
		STA	<WORK0
		BRA	IFNDF0
;
;
;
;
;
;
IFND80		EQU	$			;X < Y
		LDA	<WORK0
		ORA	<WORKE
		STA	04202H
		NOP
		NOP
		NOP
		NOP
		LDA	04216H
		STA	04204H
		LDY	<WORK4
		STY	04206H
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		LDA	04214H
		STA	<WORK0
		LDA	<WORKF
		STA	<WORK2
		BRA	IFNDF0
;
;
;
IFNDE0		EQU	$			;X = Y
		LDA	<WORKF
		STA	<WORK0
		STA	<WORK2
;
IFNDF0		EQU	$
		LDA	<WORKA
		BEQ	IFNDD0
		EOR	<WORK0
		INC	A
		STA	<WORK0
IFNDD0		EQU	$
		LDA	<WORKC
		BEQ	IFNDC0
		EOR	<WORK2
		INC	A
		STA	<WORK2
IFNDC0		EQU	$
;
		MEM8
		IDX8
		SEP	#00110000B
		RTS
;========================================
ICSUJI		EQU	$
		LDY	#030H
		STY	ICMINBF+0
		STY	ICMINBF+1
		STZ	ICMINBF+2
ISJI10		EQU	$
		CMP	#0100
		BCC	ISJI20
		SEC
		SBC	#0100
		INC	ICMINBF+0
		BRA	ISJI10
ISJI20		EQU	$
		CMP	#0010
		BCC	ISJI30
		SEC
		SBC	#0010
		INC	ICMINBF+1
		BRA	ISJI20
ISJI30		EQU	$
		ORA	#030H
		STA	ICMINBF+2
		RTS
;========================================
ICSTOP		EQU	$
		JSR	ICSTPX
		JMP	ICSTPY
;----------------------------------------
ICSTPX		EQU	$
		LDA	ICXSPD,X
		BEQ	ISPX10
		BMI	ISPX20
		DEC	ICXSPD,X
		BRA	ISPX10
ISPX20		EQU	$
		INC	ICXSPD,X
ISPX10		EQU	$
		RTS
;----------------------------------------
ICSTPY		EQU	$
		LDA	ICYSPD,X
		BEQ	ISPY10
		BMI	ISPY20
		DEC	ICYSPD,X
		BRA	ISPY10
ISPY20		EQU	$
		INC	ICYSPD,X
ISPY10		EQU	$
		RTS
;========================================
ICNEXT		EQU	$
		STA	MODENO		;NEXT MODE
;
		STZ	ICNMODE
;
		RTS
;
;========================================
ICONRTL		EQU	$
		STZ	ICNMODE
;
		LDA	#ICON
		STA	MODENO
		RTL
;
;========================================
;----------------------------------------------------------------
;-	rotation pos set					-
;-		in  : (WK0,1) <-- center X pos			-
;-		      (WK2,3) <--    "   Y  "			-
;-		      (WK4,5) <-- R				-
;-		      (WK6,7) <-- angle				-
;-		out : (WK8,9) <-- ans. X pos			-
;-		      (WKA,B) <--   "  Y  "			-
;----------------------------------------------------------------
;
ICON_C		EQU	$
		PHX
		JSL	>ROTPST
		PLX
		RTS
;
;========================================
;
;
;
;************************************************************************
;									*
;	oam set								*
;									*
;************************************************************************
SETOAM2		EQU	$
		LDA	ICXPSL,X
		STA	<WORK0
		LDA	ICXPSH,X
		STA	<WORK1
		LDA	ICYPSL,X
		STA	<WORK2
		LDA	ICYPSH,X
		STA	<WORK3
;
		STZ	<WORK4
		LDA	ICCLOR,X
		STA	<WORK5
;
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	#00000H		;DATA READ POINT
		LDX	ICOAMA		;OAM ADR
;
		LDA	<WORK6		;NEXT OAM ADR
		ASL	A
		ASL	A
		ADC	ICOAMA
		STA	ICOAMA
;
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	(<WORK8),Y	;CHAR and ATR SET
		EOR	<WORK4
		STA	OAM-OAM+2,X
;
		MEM8
		SEP	#00100000B
;
		INY			;NEXT READ POINT
		INY
		INY
		LDA	(<WORK8),Y
		ORA	<WORKD
;
		STA	OAMSB-OAM,X
;
		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	$
;
		RTS
;************************************************************************
;									*
;	moji set							*
;									*
;************************************************************************
PRINTSB		EQU	$
		PHX
;
		MEM16
		IDX16
		REP	#00110000B
;
		LDY	#00000H		;DATA READ POINT
		LDX	ICOAMA		;OAM ADR
;
		LDA	<WORK6		;NEXT OAM ADR
		ASL	A
		ASL	A
		ADC	ICOAMA
		STA	ICOAMA
;
PITSB20		EQU	$
;
		LDA	<WORK0		;X pos set
		PHA
		CLC
		ADC	#00008H
		STA	<WORK0
		PLA
		STA	OAM-OAM,X
		AND	#00100H		;OAMSB DATA SET(JUNBI)
		STA	<WORKC
;
		LDA	<WORK2		;Y pos set
		STA	OAM-OAM+1,X
		CLC
		ADC	#00010H
		CMP	#00100H
		BCC	PITSB30		;!(0FFF0H - 000F0H) = CLS
		LDA	#000F0H		;Y pos cls
		STA	OAM-OAM+1,X
;
PITSB30		EQU	$
;
		LDA	(<WORK8),Y	;CHAR and ATR SET
		AND	#000FFH
		EOR	<WORK4
		STA	OAM-OAM+2,X
;
		MEM8
		SEP	#00100000B
;
		INY			;NEXT READ POINT
		LDA	<WORKD
;
		STA	OAMSB-OAM,X
;
		MEM16
		REP	#00100000B
;
		INX
		INX
		INX
		INX
;
		DEC	<WORK6		;? ALL OVRE
		BNE	PITSB20
;					;Y
		MEM8
		IDX8
		SEP	#00110000B
;
		PLX
;
		RTS
;************************************************************************
;									*
;	move sys							*
;									*
;************************************************************************
ICMVCL		EQU	$
		LDA	ICXSPD,X
		BEQ	ICMVL10
;
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ICXPSR,X
		STA	ICXPSR,X
		LDA	ICXSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDY	#000H
		PLP
		BPL	ICMVL15
		ORA	#11110000B
		DEY
ICMVL15		EQU	$
		ADC	ICXPSL,X
		STA	ICXPSL,X
		TYA
		ADC	ICXPSH,X
		STA	ICXPSH,X
;
ICMVL10		EQU	$
		LDA	ICYSPD,X
		BEQ	ICMVL20
;
		ASL	A
		ASL	A
		ASL	A
		ASL	A
		CLC
		ADC	ICYPSR,X
		STA	ICYPSR,X
		LDA	ICYSPD,X
		PHP
		LSR	A
		LSR	A
		LSR	A
		LSR	A
		LDY	#000H
		PLP
		BPL	ICMVL25
		ORA	#11110000B
		DEY
ICMVL25		EQU	$
		ADC	ICYPSL,X
		STA	ICYPSL,X
		TYA
		ADC	ICYPSH,X
		STA	ICYPSH,X
;
ICMVL20		EQU	$
		RTS
;************************************************************************
;									*
;	stak sys							*
;									*
;************************************************************************
;========================================
ICSTCK		EQU	$
		LDA	ICMVOK
		BEQ	ISCK10
		PLA
		PLA
		RTS
;
;
ISCK10		EQU	$
		LDA	ICTIM0,X
		BEQ	ISCK20
		DEC	ICTIM0,X
ISCK20		EQU	$
		LDA	ICERRT,X
		BEQ	ISCK30
		DEC	ICERRT,X
ISCK30		EQU	$
		RTS
;========================================
;
;
;
;
;
;
;
;
;************************************************************************
;									*
		END
;									*
;************************************************************************
;
;
