ÃÒà¯2ÕéÅ*Cßë!!~æõ~#~æO~æGñ#n,-.Â‹ç! w!y–ÂGç!x–æÊçÅÕÍ¢äÑÁ.:Eß<Ê„ç!q!pÍQä:Eß<ÂçÁÅ.Ê„çÍ$å.:Eß<Ê„çÁ¯ÃßåÍiá6ÀáÁ}2EßÃxáÿÍçÌÁåÉÍçÌæÉëN!~æ€O>ˆG~æ€G!~‡‡‡‡õ€Gõá}áµæÉÍã*Cß!år#r#rÍõáÊèÍ^áÍ¥çáå_y–#xž#{žÚès+p+qÍ-ãÃäçáÉ*Cß Í¥ç!!q#p#wÉ*¯é:BßOÍêàåëÍYßáÌGß}Ø*¯éMDÍá"¯éÃ£â:Öé!Bß¾ÈwÃ!è>ÿ2Þé*Cß~æ=2ÖéþÒuè:Bß2ßé~2àéæàwÍEè:Aß*Cß¶wÉ>"Ãß!"­é"¯é¯2Bß!€"±éÍÚáÃ!èÍráÍQèÃQäÍQèÃ¢äë~þ?ÊÂèÍ¦à~þ?ÄráÍQèÍãÃéá*Ùé"CßÍQèÍ-ãÃéáÍQèÍœãÃãÍQèÃ¼åÍQèÃþåÍráÍQèÃ$åÍQèÍäÃã*¯ to 3102 terminal.
;
escdot:	push	b	; save command
	mvi	c,1bh	; send escape character
	call	conout
	mvi	c,'.'	; send dot command
	call	conout	; send esc command
	pop	b	; get command
	jmp	conout	; send command
			; and return
;
	page
;
; Any special terminal initialization should be done here.
;
interm:	lda	t3102	; get 3102 flag
	ora	a
	rz		; exit if not 3102
	mvi	c,'0'	; enable handshaking on 3102
	call	escdot	; send ESC '.' command
	mvi	c,'4'	; transmit cursor control codes
	call	escdomain part
; of the CBIOS.  It should not be modified and must
; be the last initialization performed.
;
	lhld	1	; get pointer to warm start
	mvi	l,6	; skip to const entry
	xchg		; de > jump table
	lxi	h,cpmcrt+3
	lxi	b,6*3	; number of bytes
	ldir		; move table
	push	h	; save listst jump
	lxi	h,21	; offset to listst entry
	dad	d
	xchg		; de > jump table
	pop	h	; listst jump
	lxi	b,3
	ldir		; move instruction
	ret		; must be last instruction
			; returns to CPMLOAD
;
; Send ESC '.' commandååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååÂÍäìÿ	ë	¾Úåw	ë	~>ÿ2ÒéÃä!Eß5ÉÍTá*Cßå!¬é"CßÍãÍõáá"CßÈë!¯w#ÂFå!wÍŒáÍýãÃxá¯2ÒéÍ¢äÍõáÈ*Cß	~<æwÊƒåG:Åé !Òé¦ÊŽåÃ¬å	4~æÊ¶åÍãÍõáÂ¬å:Óé<Ê¶åÍ$åÍõáÊ¶åÃ¯åÍZäÍ»à¯ÃßÍßÃxá>2Õé>ÿ2ÓéÍ»à:ãé!áé¾Úæåþ€ÂûåÍZå¯2ãé:Eß·ÂûåÍwàÍ„àÊûåÍŠàÍÑßÍ²ßÃÒàÃß>2Õé>2ÓéÍTá*CßÍGáÍ»à:ãéþ€ÒßÍwàÍ„àÂnæÍ>à2×é·Ê;æOÍ^àDMÍ¾ã}´ÂHæ>Ãß"åéë*Cß	:Ýé·:×éÊdæÍdásÃlæO		s#r:Eß·ÀÅÍŠà:Õé==Â»æÁÅy==Â»æå*¹éWw#òŒæÍàá*çé"åéÅÍÑßÁÍ¸ß*åé:ÄéG¥¸#Âšæá"åéÍÚáÍÑßÁÅÍ¸ßÁ:ãé!áé¾ÚÒæw4!ÔõÍiáæwñþÂç:ÕéþÂçÍÒàÍZå!Eß~·Âþæ=2ãé6ny printer initialization should be done here.
;
; At this point, the system data page is at 300h.
; This data page contains the following information.
;
; +0010h - 4 bytes indicating printer type:
;		0 - Unassigned.
;		1 - Centronics parallel.
;		2 - Standard serial.
;		3 - TI-810 w/Tuart mod.
;		4 - ETX/ACK protocol.
;		5 - CROMEMCO 3355.
;		6 - TI-810 w/Cable mod.
;		7 - XON/XOFF protocol (reserved)
;	  8 - 127 - User defined.
;
; +0014h - 4 bytes containing baud rate command byte.
;
; acro	?n,?r
	db	0cbh,?n*8+?r+0c0h
	endm
;
resb	macro	?n,?r
	db	0cbh,?n*8+?r+80h
	endm
;
inp	macro	?r	
	db	0edh,?r*8+40h
	endm
;
outp	macro	?r	
	db	0edh,?r*8+41h
	endm
;
	page
;
; This section is entered upon system initialization.
;
init:	xra	a	; initialize i/o byte
	sta	3
	call	interm	; initialize terminal
	call	inlist	; initialize printers
	mvi	a,0c3h	; jmp instruction
	sta	40h
	lxi	h,crtcmd; entry to special crt functions
	shld	41h
;
; This code replaces the jump table in the åååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååååå+0018h - 4 bytes containing base address.
;
inlist:	lxi	h,ptype	; printer types
	lxi	d,prtype
	lxi	b,4
	ldir		; save locally
;
	lxi	h,pbase	; base addresses
	lxi	d,port
	lxi	b,4
	ldir		; save locally
;
	lxi	d,pbaud	; baud rates
	lxi	h,port	; base addresses
	mvi	b,4	; loop counter
;
	page
;
; Initialize baud rates for printers.
;
inl0:	mov	a,m	; if port address is zero
	ora	a
	jz	inl1	; skip initialization
	ldax	d	; if baud rate is zero
	ora	a
	jz	inl1	; skip initialization
	mov	c,mit until ready
	call	prtjmp	; go to correct driver
	dw	list0	; unassigned
	dw	list1	; Centronics parallel
	dw	list2	; standard serial
	dw	list3	; TI-810 w/Tuart mod
	dw	list4	; ETX/ACK
	dw	list5	; 3355
	dw	list6	; TI-810 w/Cable mod
	dw	list0	; reserved for XON/XOFF
;
; Unassigned.
;
list0:	pop	b	; get character
	ret		; exit
;
; Centronics parallel.
;
list1:	call	getprt	; get port number
	inr	c	; plus 4 for data port number
	inr	c
	inr	c
	inr	c
	pop	d	; get character in e
	setb	7,e	; key processing.
;
crtcmd:	mov	a,c	; get command number
	cpi	ncmd	; test for valid command
	rnc		; exit if bad command
	mvi	b,0	; form index into command table
	lxi	h,cmdjmp
	dad	b
	dad	b
	mov	e,m	; get command address
	inx	h
	mov	d,m
	xchg
	pchl		; execute crt command
;
; Table of address to perform crt functions.
;
cmdjmp:	dw	cmd0	; 0 - Disable function key processing
	dw	cmd1	; 1 - Enable function key processing
ncmd	equ	($ - cmdjmp) / 2
;
; 0 - Disable function key processing.
;
c;
conin:	lda	fipflg	; check for function key
	ora	a	;  processing
	jnz	getfnc	; return char from function key
conin0:	call	const0	; get console status
	jz	conin0	; wait for character
	in	1	; read character
	ani	7fh	; clear parity bit
	cpi	2	; check for STX
	rnz		; return with character if not
;
; Check for function key input.
;
	mov	c,a	; save character
	call	conout	; echo STX charactter
	lxi	h,1000h	; counter for time between characters
;
conin1:	call	const0	; check console status
	jnz	co to console.
;
conout:	in	0	; test console status
	ani	80h	; for transmitter empty
	jz	conout	; wait until ready
	mov	a,c	; get character
	out	1	; transmit
	ret
;
; const - return console input status.
;
const:	lda	fipflg	; check for function key
	ora	a	;  processing
	rnz		; exit if function key ready
const0:	in	0	; else read status
	ani	40h	; check character ready flag
	rz		; exit if not ready
	mvi	a,-1	; else return character ready flag
	ret
;
; conin - return character from console.
OMEMCO 3355.
;
lstat5:	call	getprt	; get current port
	mov	a,c
	sta	io3355	; save for 3355 drivers
	jmp	st3355	; external status routine
;
; TI-810 w/Cable mod.
;
lstat6:	call	lstat2	; standard serial
	rz		; exit if not ready
	inp	a	; read status again
	cma		; invert status bit
	ani	4	; test RCV line
	rz		; exit if not ready
	mvi	a,-1	; return ready flag
	ret
	page
;
; list - write character to list device.
;
list:	push	b	; save character
lista:	call	listst	; get status
	jz	lista	; wah	; point to next character
	shld	fncptr	; save pointer
	mov	a,m	; get next character
	sui	-1	; check for end of string
	jnz	getfn0	; return with character if not
	sta	fipflg	; else zero transmission in progress flag
;
getfn0:	mov	a,b	; get character and return
	ret
;
	page
;
; Special crt entry point entered through jump at location 40h,
; with command in C register, additional parameters in de.
; 
; Current defined commands are:
;	0 - Disable function key processing.
;	1 - Enable functioness of character string.
;
conin4:	xchg		; hl > address table
	mov	e,m	; get address into de
	inx	h
	mov	d,m
	mov	a,d	; check for address of zero
	ora	e
	jz	conin	; ignore function key if no address
	xchg
	shld	fncptr	; else save address of string
	lxi	h,fipflg; set function key transmission
	mvi	m,-1	;  in progress flag
;
	page
;
; Return character from function key string.
;
getfnc:	lhld	fncptr	; get pointer into function string
	mov	a,m	; get character
	mov	b,a	; save character
	inx	type
	cpi	5	; check for 3355 printer
	push	h	; save registers
	push	d
	push	b
	cz	in3355	; initialize 3355
	pop	b	; restore registers
	pop	d
	pop	h
	inx	h	; next printer type
	inx	d	; next port address
	dcr	b	; test loop counter
	jnz	inl2	; loop
	ret		; end of printer initialization
;
	page
;
; reader - return character from paper tape reader.
; punch - write character to paper tape punch.
;
reader:	mvi	a,1ah	; return eof character
punch:	ret		; do nothing
;
; conout - write character.
;
lstat2:	call	getprt	; get port number
	inp	a	; read status
	ani	80h	; test for tx empty
	rz		; exit if not
	mvi	a,-1	; else return ready flag
	ret
;
	page
;
; TI-810 w/Tuart mod.
;
lstat3:	call	lstat2	; test tx empty
	rz		; exit if not
	inr	c	; status port plus 4
	inr	c	; for parallel port
	inr	c
	inr	c
	inp	a	; test busy line
	cma
	ani	40h
	rz		; exit if busy
	mvi	a,-1	; else return ready flag
	ret
;
; ETX/ACK protocol.
;
lstat4:	jmp	lstat2	; same as standard serial
;
; CR Standard serial
	dw	lstat3	; TI-810 w/Tuart mod
	dw	lstat4	; ETX/ACK
	dw	lstat5	; 3355
	dw	lstat6	; TI-810 w/Cable mod
	dw	lstat0	; reserved for XON/XOFF
;
; Unassigned status entry.
;
lstat0:	mvi	a,-1	; return ready condition
	ret
;
; Centronics parallel.
;
lstat1:	call	getprt	; get port number
	inr	c	; plus 4 for parallel
	inr	c
	inr	c
	inr	c
	inp	a	; read status
	cma
	ani	20h	; test for printer busy
	rz		; exit if busy
	mvi	a,-1	; else return ready flag
	ret
;
; Standard serial
	rz		; return with special character if no decoding
	ani	7fh	; else clear function key flag
;
; Search function key table for address of string.
;
	lxi	h,fnctbl; table of function keys
	lxi	d,fncadr; table of function addresses
	mvi	b,nfnc	; get number of entries
;
conin3:	cmp	m	; search table
	inx	h
	jz	conin4	; continue if match found
	dcr	b	; test loop counter
	jz	conin	; exit if invalid function key
	inx	d	; next address entry
	inx	d
	jmp	conin3	; loop
;
; Function key found, get addr	; get port address
	inr	c	; plus 2
	inr	c	;  for commands
	mvi	a,1	; reset TUART
	outp	a
	mov	c,m	; get port address
	ldax	d	; get baud rate
	outp	a	; initialize baud rate
;
inl1:	inx	h	; next port address
	inx	d	; next baud rate
	dcr	b
	jnz	inl0	; loop
;
; If any printers are 3355's, initialize them.
;
	lxi	h,prtype; printer types
	lxi	d,port	; base port table
	mvi	b,4	; number of printers
;
inl2:	ldax	d	; get base port address
	sta	io3355	; save in low memory
	mov	a,m	; get printer  strobe character to printer
	outp	e
	resb	7,e
	outp	e
	setb	7,e
	outp	e
	ret
;
	page
;
; Standard serial.
;
list2:	call	getprt	; get port number
	inr	c	; data port number
	pop	d	; get character in e
	outp	e	; print character
	ret
;
; TI-810 w/Tuart mod.
;
list3:	jmp	list2	; same as standard serial
;
;
; CROMEMCO 3355.
;
list5:	call	getprt	; get current port number
	mov	a,c
	sta	io3355	; save for 3355 drivers
	pop	b	; get character
	jmp	pr3355	; external output routine
;
; TI-md0:	xra	a	; disable function keys
	sta	fncflg
	ret
;
; 1 - Enable function key processing.
;
cmd1:	mvi	a,1	; enable function keys
	sta	fncflg
	ret
;
	page
;
; listst - return status of list device.
;
; Upon exit:
;  If not ready
;    a = 0, z-flag = 1,
;  else
;    a = 0ffh, z-flag = 0.
;
; Note that the printer drivers depend
; on the z-flag being set/reset properly.
;
listst:	call	prtjmp	; go to correct driver
	dw	lstat0	; unassigned
	dw	lstat1	; Centronics parallel
	dw	lstat2	;nin2	; get character if ready
	dcx	h	; else count timer down
	mov	a,h
	ora	l
	jnz	conin1	; loop until timeout
	mvi	a,2	; in case no character ready
	ret		; exit with ^B character
;
	page
;
; Function key was pressed, decode and return value.
;
conin2:	in	1	; read second character of function key
	ori	80h	; set function key flag
	mov	b,a	; save character
	mvi	c,2	; send STX character
	call	conout
	lxi	h,fncflg; check for function key decoding
	mov	a,m
	ora	a
	mov	a,b	; get character back810 w/Cable mod.
;
list6:	jmp	list2	; same as standard serial
;
	page
;
; ETX/ACK protocol.
;
bufsiz	equ	128	; printer buffer size
maxsiz	equ	bufsiz/2-1
escsiz	equ	maxsiz-5
;
list4:	pop	d	; get character in e
	lhld	cnt	; get character count
	inr	l	; allow for current character
	mov	a,e	; get character
	cpi	1bh	; test for escape character
	mvi	a,maxsiz; if not esc, max buffer size
	jnz	list4a
	mvi	a,escsiz; don't start esc sequence near end
;
list4a:	cmp	l	; test buffer limit
	jnc	list4
    63   0024 324000    	sta	40h
    64   0027 218D01    	lxi	h,crtcmd; entry to special crt functions
    65   002A 224100    	shld	41h
    66                  ;
    67                  ; This code replaces the jump table in the main part
    68                  ; of the CBIOS.  It should not be modified and must
    69                  ; be the last initialization performed.
    70                  ;
    71   002D 2A0100    	lhld	1	; get pointer to warm start
    72   0030 2E06      	mvi	l,6	; 
     9   0303 =         t3102	equ	303h	; 3102 flag
    10   0310 =         ptype	equ	310h	; printer types
    11   0314 =         pbaud	equ	314h	; printer baud rates
    12   0318 =         pbase	equ	318h	; printer base addresses
    13   0400 =         tfnc	equ	400h	; 3102 function key strings
    14                  ;
    15                  ; Data locations used by 3355 driver.
    16                  ;
    17   0043 =         in3355	equ	43h	; initialize
    18   0046 =         st3355	equ	46h	;; current printer number
prtype:	db	0,0,0,0	; printer types
port:	db	0,0,0,0	; base addresses
;
	page
;
;  Table of function key values received.
;
fnctbl:	db	70h	; f1
	db	71h	; f2
	db	72h	; f3
	db	73h	; f4
	db	74h	; f5
	db	75h	; f6
	db	76h	; f7
	db	77h	; f8
	db	78h	; f9
	db	79h	; f10
	db	7ah	; f11
	db	7bh	; f12
	db	7ch	; f13
	db	7dh	; f14
	db	7eh	; f15
	db	7fh	; f16
	db	6fh	; f17
	db	6eh	; f18
	db	6dh	; f19
	db	6ch	; f20
;
	db	5eh	; CE (Clear Entry)
	db	5fh	; PAUSE
	db	6ah	; xi	h,prtype
	dad	d
	mov	a,m	; get current printer type
	add	a	; * 2 for address table
	mov	e,a	; form index into table
	mvi	d,0
	pop	h	; get table address
	dad	d
	mov	e,m	; get routine address
	inx	h
	mov	d,m
	xchg
	pchl		; go to appropriate routine
;
; Get current port number.
;
getprt:	lhld	curprt	; get current printer number
	lxi	d,port	; index into port table
	dad	d
	mov	c,m	; get port number
	ret
;
; Data storage areas.
;
cnt:	dw	0	; current char count for etx/ack
curprt:	dw	0	 	page
CP/M RMAC ASSEM 1.1	#002	CPMCRT - CP/M 2.2 CONSOLE & PRINTER DRIVERS 03/18/81

    54                  
    55                  ;
    56                  ; This section is entered upon system initialization.
    57                  ;
    58   0018 AF        init:	xra	a	; initialize i/o byte
    59   0019 320300    	sta	3
    60   001C CD5700    	call	interm	; initialize terminal
    61   001F CDA100    	call	inlist	; initialize printers
    62   0022 3EC3      	mvi	a,0c3h	; jmp instructionCP/M RMAC ASSEM 1.1	#001	CPMCRT - CP/M 2.2 CONSOLE & PRINTER DRIVERS 03/18/81

     1                  	title	'cpmcrt - CP/M 2.2 Console & Printer Drivers 03/18/81'
     2                  ;
     3                  ; This module is read in after the initial boot.
     4                  ; The jump table is then modified to point here.
     5                  ;
     6        