;	***** GEMINI.ASM *****
;
;	Written by Jim Schenkel, 2/10/83
;
;	Adapted from EPSET2.ASM, written 
;	by Kent Walker, 10/82 and
;	corrected by Jim Woolley, 11/82
;
;	8080 ASSEMBLER CODE
;	USING CP/M BDOS FUNCTIONS
;
;	THIS PROGRAM IS DESIGNED TO SET 
;	GEMINI-15 DOT MATRIX PRINTER 
;	PARAMETERS VIA KEYBOARD INPUT.
;
;	A TABLE OF OPTIONS IS PRESENTED ON THE MONITOR.
;	INPUT IS TERMINATED BY A CARRIAGE RETURN.
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++

	ORG	100H
BDOS	EQU	0005H
INCHR	EQU	1	;KEYBOARD INPUT FUNCTION
LSTCHR	EQU	5	;LIST DEVICE FUNCTION
CR	EQU	0DH	;CARRIAGE RETURN
LF	EQU	0AH	;LINE FEED
TAB	EQU	09H	;TAB CHARACTER
CLRSCR	EQU	1AH	;CLEAR SCREEN - CTRL Z
ESC	EQU	1BH	;ESCAPE CODE
PRSTR	EQU	9	;PRINT STRING FUNCTION
BOOT	EQU	0	;WARM BOOT

	LXI	SP,STACK	;SET UP NEW STACK
	LXI	D,MESAGE	;POINT TO MESSAGE
	MVI	C,PRSTR		;STRING PRINT FUNCTION
	CALL	BDOS

LOOP	MVI	C,INCHR
	CALL	BDOS
	CPI	CR		;CARRIAGE RETURN ENDS INPUT
	JZ	EXIT

;KEYBOARD DISPATCH TABLE
	LXI	H,BELOFF
	CPI	'A'
	JZ	LIST
	CPI	'a'
	JZ	LIST

	LXI	H,BELON
	CPI	'B'
	JZ	LIST
	CPI	'b'
	JZ	LIST

	LXI	H,COMP
	CPI	'C'
	JZ	LIST
	CPI	'c'
	JZ	LIST

	LXI	H,UNCOMP
	CPI	'D'
	JZ	LIST
	CPI	'd'
	JZ	LIST

	LXI	H,EMPH
	CPI	'E'
	JZ	LIST
	CPI	'e'
	JZ	LIST

	LXI	H,NOEMPH
	CPI	'F'
	JZ	LIST
	CPI	'f'
	JZ	LIST

	L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EXIT1	POP	D
	MVI	C,PRSTR
	CALL	BDOS
	JMP	BOOT

;	SUBROUTINE TO OUTPUT ESCAPE CODE TO PRINTER

LIST	MOV	E,M	;MOVE CHAR TO REG E
	PUSH	H	;SAVE STRING POINTER
	MVI	C,LSTCHR ;SET UP FOR LINE PRINTER
	CALL 	BDOS	;PRINT CHARACTER
	POP	H	;RESTORE STRING POINTER
	INX	H	;POINT TO NEXT CHAR
	MOV 	A,M	;MVVE NEXT CHAR TO REG A
	CPI	'$'	;IS IT THE TERMINATOR ($) ?
	JZ	LOOP	;RETURN IF YES
	JMP	LIST	;ELSE REPEAT

;	END OF SUBROUTINE


;		MESSAGES

MESAGE	DB	CLRSCR,TAB,'GEMINI-15 PRINTER FUNCTIONS'	,CR,LF
	DB	TAB	  ,' Press RETURN to terminate'		,CR,LF,LF

	DB	'A = Beeper OFF             B = Beeper ON'			,CR,LF
	DB	'C = Compressed             D = Non-compressed'		,CR,LF
	DB	'E = Emphasized             F = Non-emphasized'		,CR,LF
	DB	'G = Double struck          H = Single struck' 		,CR,LF
	DB	'I = Italics font           J = Regular font'		,CR,LF
	DB	'K = Pica pitch             L = Elite pitch'		,CR,LF
	DB	'M = Bi-directional print   N = Uni-directional print'	,CR,LF
	DB	'S = Paper-end sensor ON    T = Paper-end sensor OFF'	,CR,LF
	DB	'U = Underlining ON         V = Underlining OFF'		,CR,LF
	DB	'W = Double-wide pitch      X = Single-wide pitch'		,CR,LF
	DB	'Y = Slashed zeroes         Z = Unslashed zeroes'		,CR,LF,LF

	DB	'6 =  6   lines per inch'	,CR,LF
	DB	'8 =  8   lines per inch'	,CR,LF
	DB	'9 = 10.2 lines per inch'	,CR,LF,LF

	DB	'R = Reset printer to default settings',CR,LF,LF

	DB	TAB,'Select ==> '
	DB	'$'

;	TABLE OF PRINTER ESCAPE CODES

BELOFF	DB	ESC,'Y',01,'$'
BELON	DB	ESC,'Y',00,'$'
COMP	DB	0FH,'$'
UNCOMP	DB	12H,'$'
PICA	DB	ESC,'B',01,'$'
ELITE	DB	ESC,'B',02,'$'
EMPH	DB	ESC,'E$'
NOEMPH	DB	ESC,'F$'
DBLSTR	DB	ESC,'G$'
SNGLSTR	DB	ESC,'H$'
BIPRN	DB	ESC,'U',00,'$'
UNIPRN	DB	ESC,'U',01,'$'
SLASH	DB	ESC,'V',01,'$'
NOSLSH	DB	ESC,'V',00,'$'
WIDE	DB	ESC,'W',01,'$'
NARROW	DB	ESC,'W',00,'$'
ATELPI	DB	ESC,'0$'
TENLPI	DB	ESC,'1$'
SIXLPI	DB	ESC,'2$'
ITALIC	DB	ESC,'4$'
NOITAL	DB	ESC,'5$'
IGNSEN	DB	ESC,'8$'
SENSOR	DB	ESC,'9$'
RESET	DB	ESC,'@$'
ULINE	DB	ESC,2DH,01,'$'
NOUL	DB	ESC,2DH,00,'$'

;	STACK AREA

	DS	10H
STACK	DW	0
	END
