MOUSE1ASM	;
;***	haftmann#software	***
;***	MOUSE1 f}r 1 V.24-Modul	***
;***	voll verschieblich	***
;***	10.04.92		***
OS	EQU	0F003H
RC	EQU	0F00FH
	ORG	3000H
ISRD
	DEFB	9	;SIOADR
	DEFW	0	;2.ISR
	DEFB	0	;EMPFANGSBYTENR
	DEFB	7	;TASTENSTATI
	DEFB	0F6H	;USERTASTE
	DEFB	0	;FREIGABE
	DEFB	8	;MICKEY X
	DEFB	10H	;STEP X
	DEFB	8	;MICKEY Y
	DEFB	10H	;STEP Y
ISR
	PUSH	HL
	PUSH	AF
	PUSH	DE
	PUSH	BC
	;
	CALL	RC
	DEFW	0
NEXT	POP	HL
	LD	DE,ISRD-NEXT
	ADD	HL,DE	;Datenzeiger
	LD	A,M	;SIOADR
	ADD	2
	LD	C,A
	IN	A,(C)
	RRA		;Bit0
	JR	C,CHAR	;available
	INC	HL
	LD	A,M
	INC	HL
	LD	H,M
	LD	L,A
	POP	BC
	POP	DE
	POP	AF
	EX	(SP),HL
	RET		;Ansprung 2.ISR
	;
CHAR	LD	C,M
	INC	HL
	INC	HL
	IN	D,(C)	;Byte holen
	INC	HL
	;
	XOR	A
	OR	M	;Null?
	JR	NZ,DIRECT
	LD	A,D
	AND	0F8H
	CP	80H
	JR	NZ,EXIT
	INC	M
	INC	HL	;^Tastenstati
	LD	A,D	;gelesenes Byte
	CPL
	AND	M
	LD	M,D
	INC	HL	;^Usertaste
	RRA
	JR	NC,NRIGHT
	LD	C,M
	LD	A,M
	JR	EINTR
NRIGHT	RRA
	JR	NC,NMIDDL
	INC	HL
	LD	A,M
	CPL
	JR	NOVER
NMIDDL	RRA
	JR	NC,EXIT
	LD	C,13
	LD	A,M
	JR	EINTR
DIRECT
	INC	A
	CP	5
	JR	C,DIR1
	XOR	A
DIR1	RR	M
	LD	M,A	;neue Nummer
	INC	HL
	INC	HL
	INC	HL
	LD	B,M	;Freigabe
	INC	HL
	LD	C,8	;CUL
	JR	C,DIR2
	INC	HL
	IN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T
	OR	A
	JR	Z,NSIOK
	LD	A,D
	CP	10H
	JR	NC,USERSIO
	CP	3
	JR	NC,KANNR
	SUB	1
	JR	C,SIOTOT
;
;Fehler:
;	DEC	A
;habe Befehl weggelassen, damit wie
;in der Dokumentation mit Kanal 1/2
;aufgerufen werden kann!
;
KANNR	AND	1
	ADD	8	;V.24
USERSIO	LD	M,A
NSIOK	LD	D,M
SIOTOT	LD	BC,780H
MM03	INC	B
	JR	Z,NM03
	IN	A,(C)
	CP	0EEH
	JR	NZ,MM03	;nicht gef.
	LD	A,1
	OUT	(C),A
	LD	C,B
	LD	B,0B8H
	LD	(BC),A
NM03	LD	A,M
	ADD	4	;CTC
	LD	BC,INITTB-ISRD
	ADD	HL,BC
	LD	C,A
	LD	B,2
	OTIR
	SUB	2
	LD	C,A
	SET	0,C	;f.Kanal B
	LD	B,2
	OTIR
	LD	C,A
	LD	B,9
	OTIR
	LD	A,D
	OR	A
	JR	NZ,NTOT
	LD	B,2
	OTIR
NTOT	EI
	RET
А@Аt(Аp6АnTop of Text: End of Text: Start of MC: ASM-Offset : хЫ€ц$У€сЙхЫ€жЫУ€сЙНNZ,NTOT
	LD	B,2
	OTIR
NTOT	EI
	RET
А@Аt(Аp6АnTop of Text: End of Text: Start of MC: ASM-Offset : хЫ€ц$У€сЙхЫ€жЫУ€сЙН