;	PROGRAM EPSET.ASM
;
;	WRITTEN BY KENT WALKER
;	OCTOBER, 1982
;
;	8080 ASSEMBLER CODE
;	USING CP/M BDOS FUNCTIONS
;
;	THIS PROGRAM IS DESIGNED
;	TO SET THE
;	>>>>>>>>EPSON<<<<<<<<
;	PRINTER PARAMETERS
;	VIA KEYBOARD INPUT.
;
;	A TABLE OF OPTIONS IS PRESENTED ON THE MONITOR.
;	INPUT IS TERMINATED BY A CARRIAGE RETURN.
;	INPUT CHARACTERS MUST BE IN UPPER CASE.
;
	ORG	100H
BDOS	EQU	0005H
INCHR	EQU	1	;KEYBOARD INPUT FUNCTION
LSTCHR	EQU	5	;CHARACTER TO LIST DEVICE FUNCTION
CR	EQU	000DH	;CARRIAGE RETURN
LF	EQU	000AH	;LINE FEED
TAB	EQU	0009H	;TAB CHARACTER
CLRSCR	EQU	001AH	;CLEAR SCREEN - CTRL Z - OSBORNE & TELEVIDEO
ESC	EQU	001BH	;ESCAPE CODE
PRSTR	EQU	9	;PRINT STRING FUNCTION
BOOT	EQU	0	;WARM BOOT
;
	LXI	SP,STACK	;SET UP 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	BOOT
;
	LXI	H,COMP		;TEST FOR 'C'
	CPI	'C'
	JZ	LIST
;
	LXI	H,UNCOMP	;TEST FOR 'D'
	CPI	'D'
	JZ	LIST
;
	LXI	H,EMPH		;TEST FOR 'E'
	CPI	'E'
	JZ	LIST
;
	LXI	H,NOEMPH	;TEST FOR 'F'
	CPI	'F'
	JZ	LIST
;
	LXI	H,DBLSTR	;TEST FOR '2'
	CPI	'2'
	JZ	LIST
;
	LXI	H,SNGLSTR	;TEST FOR '1'
	CPI	'1'
	JZ	LIST
;
	LXI	H,ITALIC	;TEST FOR 'I'
	CPI	'I'
	JZ	LIST
;
	LXI	H,NOITAL	;TEST FOR 'J'
	CPI	'J'
	JZ	LIST
;
	LXI	H,SIXLPI	;TEST FOR '6'
	CPI	'6'
	JZ	LIST
;
	LXI	H,EITLPI	;TEST FOR '8'
	CPI	'8'
	JZ	LIST
;
	LXI	H,RESET		;TEST FOR 'R'
	CPI	'R'
	JZ	LIST
;
	JMP	LOOP
;
;
;	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,'EPSON PRINTER FUNCTIONS'	,CR,LF
	DB	TAB,	   'use UPPER case letters'	,CR,LF
	DB	TAB,	   'press RETURN to terminate'	,CR,LF,LF
	DB	TAB,'C = COMPRESSED PRINT'	,CR,LF
	DB	TAB,'D = NON-COMPRESSED PRINT'	,CR,LF,LF
	DB	TAB,'E = EMPHASIZED PRINT'	,CR,LF
	DB	TAB,'F = NON-EMPHASIZED PRINT' 	,CR,LF,LF
	DB	TAB,'2 = DOUBLE STRUCK PRINT'	,CR,LF
	DB	TAB,'1 = SINGLE STRUCK PRINT'	,CR,LF,LF
	DB	TAB,'I = ITALIC PRINT'		,CR,LF	;GRAPHTRAX ONLY!
	DB	TAB,'J = NON-ITALIC PRINT'	,CR,LF,LF
	DB	TAB,'6 = 6 LINES PER INCH'	,CR,LF
	DB	TAB,'8 = 8 LINES PER INCH'	,CR,LF,LF
	DB	TAB,'R = RESET PRINTER'		,CR,LF,LF
	DB	'$'
;
;	TABLE OF PRINTER ESCAPE CODES
;
COMP	DB	ESC,'P$'
UNCOMP	DB	ESC,'Q$'
EMPH	DB	ESC,'E$'
NOEMPH	DB	ESC,'F$'
DBLSTR	DB	ESC,'G$'
SNGLSTR	DB	ESC,'H$'
ITALIC	DB	ESC,'4$'
NOITAL	DB	ESC,'5$'
SIXLPI	DB	ESC,'2$'
EITLPI	DB	ESC,'0$'
RESET	DB	ESC,'@$'
;
;	STACK AREA
;
	DS	10H
STACK
;
	END
