;UPRAVA MSX HRY MAGIC TREE
;ADJMAGICT ; 20-OCT-91 ; 17:38

;(C) ROS, 10-SEP-91

	.RADIX 16T

	ORG	0D000

;--------------------------------
MODE	EQU	8FFF
LIVES	EQU	4148
SETINT	EQU	9080
SUBINT	EQU	402C
;--------------------------------
START	DI
	LD	A,(0006)
	CP	10
	LD	HL,TESTM5
	JR	Z,SORDM5
	CALL	0138
	PUSH	AF
	XOR	A
	LD	(MODE),A
	LD	B,4
HLEDEJ	LD	A,(MODE)
	LD	HL,4000
	PUSH	HL
	PUSH	BC
	CALL	0024
	POP	BC
	POP	HL
	LD	A,(HL)
	CPL
	LD	(HL),A
	LD	C,(HL)
	CP	C
	JR	Z,NASEL
	LD	HL,MODE
	INC	(HL)
	DJNZ	HLEDEJ
	POP	AF
	CALL	013B
	EI
	RET
;--------------------------------
NASEL	POP	AF
	LD	A,0A
	LD	(HELP),A
	LD	HL,TESTMX
SORDM5	LD	(SETINT),HL
	LD	HL,0F3E9
	LD	(HL),0F
	INC	HL
	LD	A,4
	LD	(HL),A
	INC	HL
	LD	(HL),A
	CALL	00CC
	CALL	006F
	LD	HL,TEXT
TISK	LD	A,(HL)
	OR	A
	JR	Z,PAUSE
	CALL	00A2
	INC	HL
	JR	TISK
PAUSE	LD	BC,1000
PAUS1	XOR	A
PAUS2	DEC	A
	JR	NZ,PAUS2
	DEC	BC
	OR	B
	JR	NZ,PAUS1
	CALL	EXCLOP
	CALL	013E
	LD	HL,(4002)
	JP	(HL)
;--------------------------------
EXCLOP	DI
	LD	HL,9000
	LD	DE,4000
	LD	B,D
	LD	C,E
EX1	LD	A,(DE)
	LDI
	DEC	HL
	LD	(HL),A
	INC	HL
	JP	PE,EX1
	RET
;--------------------------------
TESTMX	PUSH	AF
	LD	A,78
	OUT	(0AA),A
	IN	A,(0A9)
	BIT	1,A
	LD	A,0
	JR	Z,DEAD1
	IN	A,(0A9)
	BIT	2,A
	LD	A,35
	JR	NZ,VEN
DEAD1	LD	(LIVES),A
	JR	VEN
;---------------
TESTM5	PUSH	AF
	IN	A,(30)
	CPL
	AND	0C
	JR	Z,SHIFTY
	IN	A,(50)
	RLCA
	JR	C,RESET
VEN	POP	AF
	JP	SUBINT
;---------------
SHIFTY	CALL	EXCLOP
	RST	0
;---------------
RESET	IN	A,(50)
	RLCA
	JR	C,RESET
	LD	A,(LIVES)
	XOR	35
	LD	(LIVES),A
	JR	VEN
;--------------------------------
TEXT	DB 0C,0A,0A,0A,0A,0A,0A,09,'Pro SORD m.5',0D,0A,0A,'      upravil LZR Soft',0D,0A,0A,09,20
	DB '20-OCT-91',0D,0A,0A,0A,0A,0A,0A,0A,0A,0A,0A
HELP	DB 0,' Nesmrtelnost:',0D,0A,0A,' HOME - zapne, INS - vypne',0
;--------------------------------
ZKONEC
	END
