
; program to initialize the ids 560g dot matirx printer

;several command files can be set up to preprogram the..
;..automatic functions that the ids has stored in its rom

;written by f.gaude' -- 11/27/1981

SOURCE	ORG	100H	;tbase entry
	JMP	BEGIN	;skip to start of main routine

; equates beginning

TRUE	EQU	0FFFFH	;define value of true
FALSE	EQU	NOT TRUE;define value of false
BDOS	EQU	5	;entry to the cp/m bdos
LIST	EQU	5	;cp/m function for output to list..
PRINT	EQU	9	;..for string output to console
TAB	EQU	9	;the tab character
LF	EQU	0AH	;line feed
CR	EQU	0DH	;carriage return
ESC	EQU	27	;the escape code (01bh) for ids program

; select program to assemble
;set desired one true (see string storage area)

INDENT	EQU	FALSE	;indent left margin 4-spaces to the right
NOJPROP	EQU	FALSE	;proportional spacing (1" & 8" margins)...
JUSPROP EQU	TRUE	;...justified but 1" & 7.1" margins (std)
JUSFIX	EQU	FALSE	;justified and fixed spacing, std margins
DEFAULT	EQU	FALSE	;power-up default features

; main-line routine beginning

BEGIN	CALL	SAVSTAK	 ;save old stack pointer
	LXI	D,STRING ;address of string into the de register
	CALL	TEXTOUT	 ;set up read loop
	CALL	GETSTAK	 ;smooth exit back to cp/m ccp (cbase)

; subroutine beginning

TEXTOUT	LDAX	D	;load character into the a register
	CPI	'$'	;is it the end of string?
	RZ		;if so return..
	PUSH	D	;..or else save the pointer.
	MOV	E,A	;character into the e register for bdos
	MVI	C,LIST	;tell bdos to output to list device
	CALL	BDOS	;do it!
	POP	D	;restore the pointer
	INX	D	;increment it and..
	JMP	TEXTOUT	;..continue until $ is reached.

SAVSTAK	POP	B	;get return address
	LXI	H,00	;clear hl register
	DAD	SP	;get stack pointer
	SHLD	OLDSTAK	;save it
	LHLD	BDOS+1	;get fbase
	MOV	A,H
	SUI	08H	;subtract cbase offset (800h)
	MOV	H,A
	SPHL		;save new stack pointer
	PUSH	B	;set return address
	RET

GETSTAK	LHLD	OLDSTAK	;get old stack pointer
	SPHL		;store it
	RET		;return to cp/m without reboot required

; storage area beginning

;initialization strings (select desired one at assembly time)
;see ids owner's manual for esc and control code functions

	IF	INDENT
STRING	DB	ESC,'J,48,1584',CR   ;indent left 4-spaces (in)
	DB	5,6		;no justify, fixed spacing
	DB	2,29,'$'	;set to normal mode, 10cpi pitch
	ENDIF

	IF	NOJPROP
STRING	DB	ESC,'J,120,960',CR   ;margins set to 1" and 8"
	DB	5,16      ;no justify, proportional spacing (np)
	DB	2,29,'$'  ;set to normal mode, 10cpi pitch
	ENDIF

	IF	JUSPROP
STRING	DB	ESC,'J,120,852',CR   ;margins set to 1" and 7.1"
	DB	4,16	  ;justified, proportional spacing (jp)
	DB	1,31,'$'  ;set to 8.4 cpi enhanced mode (11cpi)
	ENDIF

	IF	JUSFIX
STRING	DB	ESC,'J,120,840',CR   ;margins set to 1" and 7"
	DB	4,6       ;justified, fixed spacing (jf)
	DB	2,29,'$'  ;set to normal mode, 10cpi pitch
	ENDIF

	IF	DEFAULT
STRING	DB	ESC,'J,0,1584',CR  ;default condition of printer
	DB	5,6		;no justify, fixed spacing (df)
	DB	2,29,'$'	;normal mode, 10cpi pitch
	ENDIF

;uninitialized area

OLDSTAK	DS	2	;old stack address

	END	SOURCE
