;UPRAVA HRY JUNO MSX
;(C) ROS, 1990
;ADJJUNO;6 ; 01-SEP-90 ; 08:55
;
	.RADIX 16T

	ORG	0B000

;--------------------------------
ADR1	EQU	06EC ; LIVE-
ADR2	EQU	098A ; WRAP-
ADR3	EQU	164A ; TIME-
ADR4	EQU	9038 ; INTERRUPT
ADR5	EQU	003B ; SUBR INT
;--------------------------------
START	DI
	LD	A,(0006)
	CP	10
	JR	Z,SORDM5
	IN	A,(0A8)
	AND	0FC
	PUSH	AF
	RR	A
	RR	A
	RR	A
	RR	A
	AND	03
	POP	BC
	ADD	A,B
	OUT	(0A8),A
	LD	HL,9000
	LD	DE,0000
	LD	BC,2000
	LDIR
	LD	HL,(0002)
	JP	(HL)
SORDM5	CALL	00CC
	CALL	006F
	LD	HL,TEXT
TISK	LD	A,(HL)
	PUSH	AF
	CALL	00A2
	POP	AF
	OR	A
	JR	Z,PAUSE
	INC	HL
	JR	TISK
PAUSE	LD	BC,1000
PAUS1	XOR	A
PAUS2	DEC	A
	JR	NZ,PAUS2
	DEC	BC
	OR	B
	JR	NZ,PAUS1
	LD	A,10
	LD	(928E),A
	LD	(9394),A
	LD	(93B4),A
	LD	(93C5),A
	LD	(93CB),A
	LD	(93D2),A
	LD	(93DC),A
	LD	(942D),A
	LD	(975B),A
	LD	(97AA),A
	LD	(0A4FB),A
	LD	(0A53A),A
	LD	(0A693),A
	INC	A
	LD	(902A),A
	LD	(902D),A
	LD	(903D),A
	LD	(0A544),A
	LD	(0A548),A
	LD	(0AD55),A
	LD	A,01
	LD	(0AD4E),A
	LD	A,0E2
	LD	(0AD4F),A
	LD	A,0CD
	LD	HL,M5JOYA
	LD	(917A),A
	LD	(917B),HL
	LD	HL,M5JOYB
	LD	(9161),A
	LD	(9162),HL
	LD	HL,M5KEYS
	LD	(92B3),A
	LD	(92B4),HL
	LD	A,0C3
	LD	(ADR4),A
	LD	HL,TEST
	LD	(ADR4+1),HL
	CALL	EXCLOP
	LD	HL,(0002)
	IN	A,(11)
	JP	(HL)
;--------------------------------
EXCLOP	DI
	LD	HL,9000
	LD	DE,0000
	LD	BC,2000
EX1	LD	A,(DE)
	LDI
	DEC	HL
	LD	(HL),A
	INC	HL
	JP	PE,EX1
	RET
;--------------------------------
TEST	PUSH	AF
	PUSH	BC
	PUSH	DE
	PUSH	HL
	IN	A,(30)
	CPL
	AND	0C
	JR	Z,SHIFTY
	LD	HL,RSTKEY
	IN	A,(50)
	RLCA
	JR	C,RESET
	XOR	A
	LD	(HL),A
VEN	POP	HL
	JP	ADR5
;---------------
SHIFTY	CALL	EXCLOP
	RST	0
;---------------
RESET	LD	A,(HL)
	OR	A
	JR	NZ,VEN
	INC	A
	LD	(HL),A
	LD	A,(ADR2)
	OR	A
	JR	Z,SMRTEL
	XOR	A
	LD	HL,1800
ULOZIT	LD	(ADR2),A
	LD	A,H
	LD	(ADR1),A
	LD	A,L
	LD	(ADR3),A
	JR	VEN
SMRTEL	LD	A,35
	LD	HL,3072
	JR	ULOZIT
;--------------------------------
M5JOYA	LD	HL,JOYA
	IN	A,(31)
	RLCA
	RLCA
	RLCA
	RLCA
	AND	30
	LD	(HL),A
	IN	A,(37)
	RRCA
	RRCA
	RRCA
	RRCA
	JR	M5JAIB
M5JOYB	LD	HL,JOYB
	IN	A,(31)
	AND	30
	LD	(HL),A
	IN	A,(37)
M5JAIB	RLCA
	JR	NC,M5JAB1
	SET	1,(HL)
M5JAB1	RLCA
	JR	NC,M5JAB2
	SET	2,(HL)
M5JAB2	RLCA
	JR	NC,M5JAB3
	SET	0,(HL)
M5JAB3	RLCA
	JR	NC,M5JAB4
	SET	3,(HL)
M5JAB4	LD	A,(HL)
	RET
M5KEYS	CP	03
	JR	NZ,M5KEY2
	IN	A,(31)
	RLCA
M5KEY1	CPL
	CP	(HL)
	RET
M5KEY2	CP	02
	IN	A,(34)
	JR	Z,M5KEY3
	AND	0F1
	JR	M5KEY1
M5KEY3	BIT	1,A
	LD	A,00
	JR	Z,M5KEY1
	LD	A,40
	JR	M5KEY1
;--------------------------------
JOYA	DB	0
JOYB	DB	0
RSTKEY	DB	0
;--------------------------------
TEXT	DB 0C,0A,0A,0A,0A,0A,0A,0D,09
	DB         'Pro SORD m.5'
	DB 0D,0A,0D,0A,09
	DB         'v potu tvare'
	DB 0D,0A,0D,0A
	DB '       pracne upravil'
	DB 0D,0A,0D,0A
	DB '     LZR Soft 31.7.1990'
	DB 0D,0,0
	DW 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;--------------------------------
ZKONEC
	END
