;			OKISET3.ASM 	
;	            written by Jim Nelden
;			  06/18/84
;
;	Derived from NECSET by Kent Walker (10/82)
;
;	This program is designed to set the OKIDATA
;	M-93 printer parameters	via keyboard input.
;
;	A table of options is presented on the screen.
;	Input is terminated by a carriage return.
;	Input characters must be in upper case.
; ---------------------------------------------------------
;
; 06/18/84 - Modified for OKIDATA M-93 setup 
;		(NAME CHANGED FROM NECSET3.ASM)
;				 - Jim Nelden
; 05/29/84 - Added VFU  option for 60 lines per page
;				- Norman Beeler
; 05/27/84 - Much needed clean-up, expanded options, and
;	     added ability to use lowercase on command line.		
;				- Loren Cook 
; ---------------------------------------------------------
;
BDOS	EQU	5
;
CONIN	EQU	1
LIST	EQU	5
PRSTR	EQU	9
;
TAB	EQU	9	
LF	EQU	0AH
CR	EQU	0DH
ESC	EQU	1BH
RS	EQU	1EH
FS	EQU	1CH
GS	EQU	1DH
US	EQU	1FH
CAN	EQU	18H
SO	EQU	0EH
SI	EQU	0FH
;
CLR	EQU	1AH		;console clear screen code
;
; ---------------------------------------------------------
; Program starts here
;
	ORG	100H
;
START:	LXI	H,0
	DAD	SP		;get old SP
	SHLD	STAK		;save it here
	LXI	SP,STAK		;set up stack
	LXI	D,MENU		;get menu and
	MVI	C,PRSTR		;print it
	CALL	BDOS
;
LOOP:	MVI	C,CONIN
	CALL	BDOS
	CPI	CR		;check for end of input
	LHLD	STAK		;get old stack
	SPHL			;restore SP
	JZ	0
;
UCASE:	CPI	'a'
	JC	TEST
	CPI	'z'+1		;if lowercase convert
	JNC	TEST		;to uppercase
	SUI	' '
	MOV	M,A
;	
TEST:	LXI	H,PICA		;test for 'A'
	CPI	'A'
	JZ	OUTPT
;
	LXI	H,ELITE		;test for 'B'
	CPI	'B'
	JZ	OUTPT
;
	LXI	H,COMPRS	;test for 'C'
	CPI	'C'
	JZ	OUTPT
;
	LXI	H,CORES		;test for 'D'
	CPI	'D'
	JZ	OUTPT
;
	LXI	H,EMPH		;test for 'E'
	CPI	'E'
	JZ	OUTPT
;
	LXI	H,NOEMPH	;test for 'F'
	CPI	'F'
	JZ	OUTPT
;
	LXI	H,DBLWD		;test for 'G'
	CPI	'G'
	JZ	OUTPT
;
	LXI	H,SNGLWD	;test for 'H'
	CPI	'H'
	JZ	OUTPT
;
	LXI	H,SIXLPI	;test for 'I'
	CPI	'I'
	JZ	OUTPT
;
	LXI	H,EITLPI	;test for 'J'
	CPI	'J'
	JZ	OUTPT
;
	LXI	H,LFMGN		;test for 'K'
	CPI	'K'
	JZ	OUTPT
;
	LXI	H,LFMG0		;test for 'L'
	CPI	'L'
	JZ	OUTPT
;
	LXI	H,VFU		;test for 'M'
	CPI	'M'
	JZ	OUTPT
;	
	JMP	LOOP
;
;
; Routine to output code to printer
;
OUTPT:	MOV	E,M	;move char to E
	PUSH	H
	MVI	C,LIST  ;call CP/M list device
	CALL 	BDOS	;and print it
	POP	H
	INX	H	;point to next char
	MOV 	A,M	;move it to A
	CPI	'$'	;finished?
	JZ	LOOP
 	JMP	OUTPT	;No, continue output
;
MENU:	DB	CLR,TAB,'Okidata M-93 Printer Functions',CR,LF,LF
	DB	TAB,ESC,'(','A ',ESC,')','= 10 Characters per inch',CR,LF
	DB	TAB,ESC,'(','B ',ESC,')','= 12 Characters per inch',CR,LF
	DB	TAB,ESC,'(','C ',ESC,')','= 17 Characters per inch',CR,LF
	DB	TAB,ESC,'(','D ',ESC,')','= Correspondance printing',CR,LF,LF
	DB	TAB,ESC,'(','E ',ESC,')','= Emphasized print',CR,LF
	DB	TAB,ESC,'(','F ',ESC,')','= Non-Emphasized print',CR,LF,LF
	DB	TAB,ESC,'(','G ',ESC,')','= Double Width print',CR,LF
	DB	TAB,ESC,'(','H ',ESC,')','= Single Width print',CR,LF,LF
	DB	TAB,ESC,'(','I ',ESC,')','= 6 Lines per inch',CR,LF
	DB	TAB,ESC,'(','J ',ESC,')','= 8 Lines per inch',CR,LF,LF
	DB	TAB,ESC,'(','K ',ESC,')','= Set left margin to 4',CR,LF
	DB	TAB,ESC,'(','L ',ESC,')','= Set left margin to 0',CR,LF,LF
	DB	TAB,ESC,'(','M ',ESC,')','= Set line spacing to 14/144',CR,LF
	DB	TAB,ESC,'(','Enter/Return to Quit',CR,LF,LF
	DB	TAB,'Enter your selections: '
	DB	'$'
;
; Table of printer codes
;
PICA:	DB	RS,'$'		;HEX 1E
ELITE:	DB	FS,'$'		;HEX 1C
COMPRS:	DB	GS,'$'		;HEX 1D
CORES:	DB	ESC,'1$'
EMPH:	DB	ESC,'T$'
NOEMPH:	DB	ESC,'I$'
DBLWD:	DB	US,'$'		;HEX 1F
SNGLWD:	DB	CAN,'$'		;HEX 18
SIXLPI:	DB	ESC,'6$'
EITLPI:	DB	ESC,'8$'
LFMGN:	DB	ESC,'%','C','044$'
LFMG0: 	DB	ESC,'%','C','000$'
VFU:	DB	ESC,'%','9',014,'$'
;
	DS	16
;
STAK:	DS	2
;
	END
