;	PROGRAM STARSET.ASM ADAPTED APRIL 1984 BY TJ OLNEY FROM
;	PROGRAM EPSET.ASM   
;	(SORRY THE MENU NO LONGER FITS 52 COLUMNS)
;
;	WRITTEN BY KENT WALKER
;	OCTOBER, 1982
;	corrected by Jim Woolley, 11/82
;
;	8080 ASSEMBLER CODE
;	USING CP/M BDOS FUNCTIONS
;
;	THIS PROGRAM IS DESIGNED
;	TO SET THE
;	STAR MICRONICS GEMINI 10X (AND POSSIBLY OTHERS)
;	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.
;
;	EACH ESCAPE CODE IS OUTPUT IMMEDIATELY TO THE PRINTER SO
;	IF TWO CONFLICT, THE LAST ONE ISSUED WILL BE IN EFFECT
;
;	NOTE THAT THE TINY PRINT PLACES THE PRINTER 
;	PERMANTLY IN SUBSCRIPT MODE UNTIL CANCELLED BY RESET
;	TURNING THE PRINTER OFF, OR BY ISSUING THE CANCEL SUB/SUPER
;	WHICH IS PART OF THE MENU OPTION A
;
;	THIS PROGRAM IS EASILY ADAPTED TO OTHER PRINTERS BY CHANGING THE TABLE
;	OF ESCAPE CODES  
;	SOME OF THE OPTIONS MAY BE OF LIMITED USE AND CAN BE ELIMINATED TO EASE
;	CONGESTION ON THE MENU
;	
; 	NOTE THAT CHANGING THE NUMBER OF LINES PER INCH ALSO CHANGES THE NUMBER OF
;	LINES PER PAGE BY ISSUING TWO INSTRUCTIONS
;
;	IF SOMEONE WHO KNOWS WHAT THEY'RE DOING IS INTERESTED, IT WOULD BE
;	NICE TO HAVE A PROGRAM LIKE THIS ACCEPT DECIMAL NUMBERS FOR, THE NUMBER OF 
;	LINES PER INCH, NUMBER OF CHARACTER MARGINS, AND THE NUMBER OF LINES TO SKIP 
;	AT A PERFORATION.
;
;
	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,CNCLTNY		;TEST FOR 'A'
	CPI	'A'
	JZ	LIST
;
	LXI	H,COMP		;TEST FOR 'C'
	CPI	'C'
	JZ	LIST
;
	LXI	H,PICA		;TEST FOR 'P'
	CPI	'P'
	JZ	LIST
;
	LXI	H,ELITE		;TEST FOR 'E'
	CPI	'E'
	JZ	LIST
;
	LXI	H,DOZLPI		;TEST FOR 'T'
	CPI	'T'
	JZ	LIST
;
	LXI	H,EMPH		;TEST FOR 'F'
	CPI	'F'
	JZ	LIST
;
	LXI	H,NOEMPH	;TEST FOR 'G'
	CPI	'G'
	JZ	LIST
;
	LXI	H,ENLRG		;TEST FOR 'M'
	CPI	'M'
	JZ	LIST
;
	LXI	H,UNENLRG		;TEST FOR 'N'
	CPI	'N'
	JZ	LIST
;
	LXI	H,UNLINE		;TEST FOR 'U'
	CPI	'U'
	JZ	LIST
;
	LXI	H,NOUNLN		;TEST FOR 'V'
	CPI	'V'
	JZ	LIST
;
	LXI	H,DBLSTR	;TEST FOR 'D'
	CPI	'D'
	JZ	LIST
;
	LXI	H,SNGLSTR	;TEST FOR 'S'
	CPI	'S'
	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
;
	LXI	H,MARTEN	;TEST FOR 'K'
	CPI	'K'
	JZ	LIST
;
	LXI	H,MARSEV	;TEST FOR 'H'
	CPI	'H'
	JZ	LIST
;
	LXI	H,THRELPI	;TEST FOR '3'
	CPI	'3'
	JZ	LIST
;
	LXI	H,FOURLPI	;TEST FOR '4'
	CPI	'4'
	JZ	LIST
;
	LXI	H,FIVELPI	;TEST FOR '5'
	CPI	'5'
	JZ	LIST
;
	LXI	H,PAPOUT	;TEST FOR 'Q'
	CPI	'Q'
	JZ	LIST
;
	LXI	H,SKIPERF	;TEST FOR 'L'
	CPI	'L'
	JZ	LIST
;
	LXI	H,ONEDIR	;TEST FOR 'O'
	CPI	'O'
	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,'STAR MICRONICS / EPSON PRINTER FUNCTIONS'	,CR,LF
	DB	TAB,	   'use UPPER case letters'	,CR,LF
	DB	TAB,	   'press RETURN to terminate'	,CR,LF,LF
	DB	TAB,'A = CANCEL TINY PRINT & RESET TO 6 LINES PER INCH' ,CR,LF 
	DB	TAB,'C = COMPRESSED PRINT   E = ELITE PRINT  P = PICA PRINT',CR,LF
       	DB	TAB,'T = TINY PRINT @ 12 LINES PER INCH (CHOOSE COMPRESSED AS WELL)',CR,LF
	DB	'F = EMPHASIZED PRINT         G=NON-EMPHASIZED (default)',CR,LF
	DB	TAB,'M = MONSTROUS ENLARGED PRINT (double current size)'	,CR,LF
	DB	TAB,'N = NORMAL SIZE FOR WHATEVER SIZE YOU ARE IN (default)'	,CR,LF	
	DB	'D = DOUBLE STRUCK PRINT     S = SINGLE STRUCK PRINT (default)'	,CR,LF
	DB	TAB,'U = UNDERLINE EVERYTHING   	V = CANCEL UNDERLNING (default)',CR,LF
	DB	TAB,'I = ITALIC PRINT         J = NON-ITALIC PRINT (default)',CR,LF,LF
	DB	'VERTICAL LINE SPACING:','	3 = 3 LINES PER INCH (PL=33) (double space)',CR,LF
	DB	TAB,'4 = 4 LPI (PL=44) 		5 = 5 LPI (PL=55)',CR,LF
	DB	TAB,'6 = 6 LINES PER INCH (PL=66)',TAB,'8 = 8 LINES PER INCH (PL=88)'	,CR,LF
	DB	LF,'LEFT MARGIN SETTINGS:  H = 17 COLUMNS		K = 10 COLUMNS',CR,LF
	DB	'L = ENABLE SKIP OVER PERFORATION (2 LINES)',TAB,' O = ONE DIRECTION PRINTING',CR,LF
	DB	TAB,'Q = TURN OFF PAPER OUT (use for sheet feeding)',CR,LF,LF
	DB	TAB,'R = RESET PRINTER (set to defaults)'	,CR,LF
	DB	'$'


;
;	TABLE OF PRINTER ESCAPE CODES
;
COMP	DB	0fh,'$'
			;changed from ESC,'P' by Jim W.
PICA	DB	12h,'$' ;CHANGE TO PICA FROM UNCOMP TJ 
			;changed from ESC,'Q' by Jim W.
ELITE	DB	ESC,42H,02H,'$'	;TJ ADDED FOR STAR MICRONICS
EMPH	DB	ESC,'E$'
NOEMPH	DB	ESC,'F$'
DBLSTR	DB	ESC,'G$'
SNGLSTR	DB	ESC,'H$'
ENLRG   DB      ESC,'W',01H,'$'	; STAR MICRONICS CHANGE TJ OLNEY
UNENLRG DB	ESC,'W',00H,'$' ; STAR MICRONICS CHANGE TJ OLNEY
CNCLTNY	DB	ESC,'T',ESC,'2','$' ;CHANGE TJ CANCELS SUBSCRIPT MODE
			;AND RETURNS TO 6 LINES PER INCH 
ITALIC	DB	ESC,'4$'
NOITAL	DB	ESC,'5$'
UNLINE	DB	ESC,'-',01H,'$'	; UNDERLINE STAR CHANGE TJ
NOUNLN	DB	ESC,'-',00H,'$' ; NO UNDERLINE STAR CHANGE TJ
SIXLPI	DB	ESC,'2',ESC,'C',42H,'$'	;TJ ADD THE 66 LINES PER PAGE
EITLPI	DB	ESC,'0',ESC,'C',58H,'$'	;TJ ADD THE 88 LINES PER PAGE	
DOZLPI  DB	ESC,'S',01H,ESC,'3',0CH,'$'; STAR CHANGE TJ
 ;SUBSCRIPT MODE FOR TINY PRINT AND LINE FEED 12/IN  TJ
MARTEN	DB	ESC,'M',0BH,'$'		;TJ ELEVEN SPACE LEFT MARGIN APPROX 1 INCH IN PICA & ELITE 
MARSEV	DB	ESC,'M',11H,'$'		;TJ SEVENTEEN SPACE LEFT MARGIN 
THRELPI	DB	ESC,'3','0',ESC,'C',21H,'$'	;TJ 3 LINES PER INCH (DOUBLE SPACED) 48/144 LINE FEED
						;33 LINES PER PAGE
FOURLPI	DB	ESC,'A',12H,ESC,'C',2CH,'$'	;TJ FOUR LINES PER INCH 18/72 LINE FEED TJ
						;44 LINES PER PAGE
FIVELPI	DB	ESC,'3',1DH,ESC,'C',37H,'$'	;TJ APPROX FIVE LINES PER INCH 29/144 LINE FEED TJ
						;55 LINES PER INCH
PAPOUT	DB	ESC,'8','$'		;TJ DISABLE PAPER OUT (FOR SHEET FEEDING) RESET FOR OFF
ONEDIR	DB	ESC,'U','1','$'		;TJ TURN ON UNIDIRECTIONAL PRINTING RESET FOR OFF
SKIPERF	DB	ESC,'N',02H,ESC,'R',02H,'$'	;TJ ENABLE SKIP AT 2 LINES BEFORE END OF PAGE 
						;& MOVE FIRST LINE TO
						;LINE 2 OF NEXT PAGE TJ  RESET FOR OFF
RESET	DB	ESC,'@$'
;
;	STACK AREA
;
	DS	20H
STACK
;
	END
