;UPRAVA HRY MSX PINBAL
;ADJPINBAL ; 17-AUG-91 ; 19:08

;(C) ROS, 20-OCT-90

	.RADIX 16T

	ORG	0CE51

GAMES	EQU	1

;--------------------------------
KEYBOA	JP	0141
LEFT	CALL	KEYBOA
	RLCA
	RLCA
	RLCA
	RET
RIGHT	CALL	KEYBOA
	RRCA
	RRCA
	RET
START	DI
	LD	A,(0006)
	CP	10
	JR	NZ,RUN
SORDM5	LD	HL,0F3E9
	LD	A,0F
	LD	(HL),A
	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	B,0E
PAUS1	XOR	A
PAUS2	DEC	A
	JR	NZ,PAUS2
	DEC	BC
	OR	B
	JR	NZ,PAUS1
	DI
	LD	HL,TEST
	LD	(KEYBOA+1),HL
	IN	A,(11)
RUN	EI
	XOR	A
	LD	(0F3DB),A
	JP	9103
;--------------------------------
TEST	DI
	PUSH	AF
	IN	A,(30)
	CPL
	AND	0C
	JP	Z,0000
	POP	AF
	LD	C,A
	PUSH	BC
	CALL	KEYROW
	POP	BC
	EI
	RET
KEYROW	OR	A
	JR	NZ,ROW1
	IN	A,(35)
	RRCA
	RRCA
	IN	A,(31)
	RLA
	CALL	TSCTRL
	RET	NC
	OR	0FE
	RET
ROW1	DEC	C
	JR	NZ,ROW2
	IN	A,(31)
	RLCA
	IN	A,(35)
	RLA
	AND	03
	LD	C,A
	IN	A,(35)
	AND	0C
	OR	C
	LD	C,A
	IN	A,(35)
	RLCA
	JR	NC,ROW11
	SET	4,C
ROW11	IN	A,(36)
	RLCA
	JR	NC,ROW12
	SET	6,C
ROW12	RLCA
	AND	0A0
	CALL	TSTCTR

	COND	GAMES

	JR	C,ROW13
	OR	80
	RET
ROW13	OR	10
	RET

	ELSE

	RET	NC
	OR	90
	RET

	ENDC

ROW2	D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RET
ROW85	OR	0F0
	RET

	ELSE

	RET	C
	OR	0FE
	RET

	ENDC

ROW9	IN	A,(37)
	CPL
	RET
TESTCT	LD	A,C
TSTCTR	OR	C
TSCTRL	CPL
	LD	C,A
	IN	A,(30)
	RRCA
	LD	A,C
	RET
;--------------------------------
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 '17-AUG-91',0
;--------------------------------
ZKONEC
	END
