Compucolor.org – Virtual Media

Listing of file='SCNDIG.MAC;01' on disk='vmedia/laser_gun_keyboard-sector.ccvf'

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	SCNDIG - MAKES A SCAN OF THE DIGIT KEYS ON THE
;		 KEYBOARD AND RETURNS THE FIRST KEY IT FINDS
;		 DEPRESSED. DIGITS ARE SCANNED IN ASCENDING
;		 ORDER (SEE BELOW).
;
	ENTRY	SCNDIG
;
;	VALUES ON ENTRY:
;	   IRRELEVANT
;
;	RETURNS:
;	   0-F WHICH ARE THE DIGITS 0-9 AND CHARACTERS
;	:;,-./ RESPECTIVELY. IF NO KEY IS DEPRESSED, FF IS
;	RETURNED.
;
;	FLAGS ARE SET AS FOLLOWS:
;		<C>       INDICATES KEYS 0-9
;	     NO FLAGS SET INDICATES KEYS : TO /
;		<S>       INDICATES NO KEY (ACC IS FF)
;	(<S> IS THE SIGN BIT WHICH IS SET IF NEGATIVE)
;
;	DESTROYS:
;	   A,B
;
;	NOTE:	INTERRUPTS ARE DISABLED DURING THE SCAN TO
;	AVOID THE POSSIBILITY OF CONFLICTS AND AN INCORRECT
;	RESULT.
;
;
;	I/O PORTS FOR KEYBOARD
;

PI	EQU	01	;PARALLEL INPUT ON 5501 CHIP
PO	EQU	07	;PARALLEL OUTPUT


SCNDIG:	XRA	A	;START AT ZERO
	MOV	B,A
	DI
SCND10:	CMA		;OUTPUT PORT COMPLEMENTS THE BYTE
	OUT	PO	;TEST ROW
	IN	PI	;READ RESULT
	ANI	01H	;CHECK COLUMN FOR DEPRESSED KEY
	JZ	SCND20
	INR	B	;GO TO NEXT ROW
	MOV	A,B
	CPI	10H	;DON'T GO PAST ROW 15
	JC	SCND10
	MVI	A,0FFH	;NO KEY DEPRESSED IN THIS GROUP
	ORA	A	;SET <S>
	EI
	RET
SCND20:	MOV	A,B	;FOUND KEY
	CPI	0AH	;SEE IF NOT A DIGIT
	INR	A	;CLEAR <S> BUT NOT <C> - TRICKY!!!
	DCR	A
	EI
	RET

	END