Compucolor.org – Virtual Media

Listing of file='RICKI.SRC;05' on disk='vmedia/comm_pgms_source_code-sector.ccvf'

;^COMM PROGS>RICKI.SRC;5	1981/03/14	13:00
;
;
;	ROUTINE TO ALLOW THE COMPUCOLOR II
;	TO COMMUNICATE WITH OTHER COMPUTERS
;	USING THE INDUSTRY STANDARD OF EVEN PARITY
;	FOR FULL DUPLEX ASYNCHRONOUS COMMUNICATIONS
;
;
;********************************************************
;							*
;	NOTE:	THE FOLLOWING MODS WERE MADE TO ROM	*
;		ROUTINES AS FURNISHED BY COMPUCOLOR	*
;							*
;	01H	SOH	WAS AUTO(MATIC LOAD MODE)	*
;			NOW MEANS HOME CURSOR		*
;	08H	BS	WAS HOME CURSOR			*
;			NOW MEANS CURSOR LEFT		*
;							*
;********************************************************
;
;
MFIOA	EQU	0	;MULTI FUNCTION I/O ADAPTER ADDRESS
BAUD	EQU	MFIOA+5
COMND	EQU	MFIOA+4
EXTIN	EQU	MFIOA+1
EXTOT	EQU	MFIOA+7
SSOBE	EQU	10H
STAT5	EQU	MFIOA+3
TIME4	EQU	MFIOA+12
TXBUF	EQU	MFIOA+6
;
CRTCHIP	EQU	60H		;CRT CHIP BASE ADDRESS
ROLDA	EQU	CRTCHIP+16+6	; "SLOW" ADDRESSING
CRXDA	EQU	CRTCHIP+16+12	; PREVENTS DG FROM
CRYDA	EQU	CRTCHIP+16+13	; BEING STARVED
;
;
BFILL	EQU	81D0H	;BLIND FILL (+0=A7 BIT, +1=CCI)
BHLAD	EQU	81D4H	;BLIND CURSOR HL ADDRESS
BRATE	EQU	81E2H	;CURRENT BAUD RATE
COLFL	EQU	81E6H	;FLAG (FG/BG)	0=OFF	1=ON
ESCUSE	EQU	33215	;ESCAPE USER JUMP VECTOR
EXTBF	EQU	81D6H	;EXTERNAL OUTPUT PORT BUFFER
INPCRT	EQU	81C5H	;FREE INPUT TABLE JUMP
INPFL	EQU	33251	;RS232 INPUT PORT FLAG
INPUTV	EQU	33221	;USER INPUT ROUTINE JUMP VECTOR
JUMP	EQU	81E7H	;JUMP USED FOR CURSOR POSITIONING
			; LEFT,RIGHT,UP,DOWN
KBDFL	EQU	33247	;KEYBOARD INPUT FLAG
LOFL	EQU	81F9H	;SYSTEM OUTPUT FLAG
MS150	EQU	81FDH	;150 MILLISECOND TIMER COUNTER
MYFLAG	EQU	81F1H	;USE BASIC FLAG FOR MY FLAG
NOCHA	EQU	64	;64 CHARACTERS / LINE
NOLIN	EQU	32	;32 LINES / DISPLAY
READY	EQU	33279	;KEYBOARD READY FLAG
RCOMD	EQU	0017H	;BAUD	1X=08H	8X=18H
ROLFL	EQU	81DCH	;ROLL FLAG => 0= NO ROLL 1= ROLL
ROLLN	EQU	81CDH	;ROLL COUNT (0=NO ROLL)
TEMP0	EQU	81F2H	;TEMPORARY LOCATION
TPROG	EQU	001BH	;150MS
VCRAD	EQU	81CBH	;VISIBLE CURSOR ADDRESS (+0=X,+1=Y)
VFILL	EQU	81CEH	;VISIBLE FILL (+0=A7 BIT,+1=CCI)
VHLAD	EQU	81D2H	;VISIBLE CURSOR HL ADDRESS
X80	EQU	7000H	;START OF DISPLAY MEMORY SLOW RAM
;
;
JMPOPC	EQU	0C3H	;JMP OPCODE
JPOOPC	EQU	0E2H	;JPO OPCODE
JPEOPC	EQU	0EAH	;JPE OPCODE
;
BOT	EQU	09600H	;BOTTOM OF RAM TO BE USED
			; TO STORE INCOMING DATA
ENDRAM	EQU	32940	;END OF RAM ALLOCATED TO BASIC
;
RATE	EQU	88H	;1200 BPS (84H = 300BPS)
;
;
;	LEAVE ROOM FOR BASIC DRIVER
;
;	NOTE:	THE STACK GROWS DOWNWARD
;		FROM HERE TOWARDS BASIC
;
;
	ORG	09000H
;
;
;	INITIALIZATION
;
;
;
INIT:
	LXI	H,0		;SAVE FCS STACK POINTER
	DAD	SP
	SHLD	FCSSP
	LXI	SP,INIT-1	;SETUP STACK
;
;	SET THE BAUD RATE
;
	MVI	A,RATE		;GET BAUD RATE CODE
	OUT	BAUD		;LOAD 5501
	STA	BRATE		;SO FCS KNOWS
;
;	SET UP THE JUMP VECTORS
;
	MVI	A,JMPOPC	;JMP OPCODE
	STA	INPUTV		;USER INPUT ROUTINE JUMP VECTOR
	LXI	H,WHICH		;DETERMINE WHICH INPUT
	SHLD	INPUTV+1	;USER INPUT ROUTINE JUMP VECTOR
;
;	SET UP THE FLAGS
;
	MVI	A,31		;USER INPUT ROUTINE VECTOR
	STA	INPFL		;RS232 INPUT PORT FLAG
	MVI	A,31		;USER INPUT ROUTINE VECTOR
	STA	KBDFL		;KEYBOARD INPUT FLAG
	MVI	A,0		;SVCHA
	STA	MYFLAG		;MY INPUT FLAG
;
;	SET UP INITIAL MEMORY POINTER
;
	LXI	H,BOT		;INITIAL MEMORY POINTER
	SHLD	MEMPTR		;WHERE TO STORE CHARACTER
				; IN MEMORY
	MVI	A,0
	STA	MEMFLG		;SET MEMORY EMPTY FLAG
	STA	EXITFG		;SET NOT READY TO EXIT FLAG
;
;	SET UP TOP OF MEMORY
;
	LXI	H,0FFFFH	;64K RAM
	SHLD	TOPMEM
;
;	DISPLAY SIGN ON
;
	LXI	H,PROMPT	;"RICKIS TERMINAL EMULATOR"
	CALL	OSTR		;DISPLAY MESSAGE
LOOP:
	LDA	READY		;IS THERE A CHARACTER FROM
				; THE KEYBOARD
	CPI	50H		;IS IT A BREAK?
	JNZ	LOOP1		;LOOK AT MEMORY STATE FLAG
	XRA	A		;CLEAR A
	STA	READY		;RESET BREAK FLAG
	CALL	BREAK		;SEND BREAK TO HOST
	JMP	LOOP

LOOP1:
	LDA	MEMFLG		;MEMORY STATE
	CPI	0
	JZ	LOOP2		;LOOK FOR EXIT FLAG
	JM	WARNING
	CALL	BELL
	LXI	H,WRAPMSG	;"MEMORY WRAP"
	CALL	OSTR		;DISPLAY MESSAGE ON SCREEN
	CALL	BELL
	MVI	A,0		;SET MEMORY EMPTY
	STA	MEMFLG
	JMP	LOOP

WARNING:
	CALL	BELL
	LXI	H,WARNMSG
	CALL	OSTR
	CALL	BELL
	MVI	A,0
	STA	MEMFLG
	JMP	LOOP

LOOP2:
	LDA	EXITFG		;USER WANTS TO EXIT IF <> 0
	CPI	0
	JZ	LOOP3
	MVI	A,0
	STA	INPFL
	STA	KBDFL
	MOV	B,A
	LHLD	FCSSP
	SPHL
	RET			;RETURN TO CALLER

;
;
;	RESTORE INPUT FLAG	(DESTROYED BY CURSOR ROUTINE)
;
;
LOOP3:
	LDA	INPFL		;GET CURRENT INPUT FLAG
	CPI	0		;SYSTEM DISPLAY ROUTINE
	JNZ	LOOP		;IF NOT REQUIRED - SKIP
	MVI	A,31		;USER INPUT ROUTINE VECTOR
	STA	INPFL		;RS232 INPUT PORT FLAG
	JMP	LOOP

;
;
;	ROUTINE TO DETERMINE WHICH SOURCE OF DATA HAS PROVIDED
;	A CHARACTER
;
;
WHICH:
	PUSH	PSW		;SAVE MACHINE STATE
	PUSH	D		;SAVE DE
	LXI	D,KBDFL		;ADDRESS OF KEYBOARD INPUT FLAG
	CALL	CMPHD		;CALL HL:DE COMPARE
	JZ	PARITY		;JUMP IF CALLED FOR
				; KEYBOARD CHARACTER
	LXI	D,INPFL		;ADDRESS OF RS232
				; INPUT PORT FLAG
	CALL	CMPHD		;CALL HL:DE COMPARE
	JZ	EDIT		;JUMP IF CALL WAS FOR
				; HOST CHARACTER
;
;	DONT KNOW SOURCE OF CHARACTER
;
	POP	D		;RESTORE DE
	POP	PSW		;RESTORE MACHINE STATE
	RET			;IGNORE THIS CHARACTER

;
;
;	ROUTINE TO GENERATE PARITY FOR HOST COMPUTERS
;
;
PARITY:
	POP	D		;RESTORE DE
	MOV	A,E
	CPI	241		;"EXIT CHARACTER"
	JNZ	PSET		;SKIP IF USER NOT READY TO EXIT
	STA	EXITFG		;SET EXIT FLAG <>0 FOR EXIT
	POP	PSW		;IGNORE EXIT CHARACTER
	RET

PSET:
	ANI	7FH		;MASK OFF PARITY BIT
PTEST:
	JPE	POK		;THIS INSTRUCTION MAY BE
				; OVERLAID TO RUN OTHER
				; PARITY OPTIONS
				;
	ORI	80H		;SET PARITY BIT ON
POK:
	MOV	E,A		;MOVE CHARACTER TO REGISTER E
				; FOR S1OUT ROUTINE
	POP	PSW		;GET IN SYNCH WITH STACK
	JMP	S1OUT		;TRANSMIT E ON RS232
				; OUTPUT PORT

;
;
;	ROUTINE TO EDIT INPUT FROM HOST
;
;
EDIT:
	POP	D		;RESTORE DE
	PUSH	H
	MOV	A,E
	ANA	A		;SET PARITY BIT
	JPE	INPOK		;JUMP IF INPUT PARITY OK
	NOP			;ROOM TO DO SOMETHING
	NOP			;IF AN ERROR INDICATION
				;IS DESIRED
				;3E3F => MVI	A,03FH "?"
INPOK:
	ANI	7FH
	MOV	E,A		;SAVE CHARACTER WITHOUT PARITY
	CPI	7FH
	JZ	IGNORE		;IGNORE DEL
	CPI	7FH
	JZ	IGNORE		;IGNORE NULL?
	POP	H
	MOV	E,A
	POP	PSW
	CALL	MEMSAV		;SAVE CHARACTER IN MEMORY
	MOV	A,E		;RESTORE CHARACTER
	CALL	SAVE		;SAVE ALL REGISTERS
	LXI	H,MYFLAG	;MY INPUT FLAG
	JMP	PROCES		;ROM ROUTINE TO DISPLAY
				; CHARACTER IN A

BEL:
	CALL	BELL		;RING THE BELL
IGNORE:
	POP	H
	POP	PSW
	RET

;
;
;	ROUTINE TO SAVE CHARACTER IN MEMORY
;
;
MEMSAV:
	PUSH	PSW
	PUSH	H
	PUSH	D
	LHLD	MEMPTR		;GET WHERE TO STORE CHARACTER
	MOV	M,E		;PUT CHARACTER IN MEMORY
	INX	H
	XCHG			;TEMP TO GET TOP
	LHLD	TOPMEM		;TOP OF MEMORY KNOWN TO RICKI
	XCHG			;REARRANGE FOR CMPHD
	CALL	CMPHD		;COMPARE HL:DE
	JZ	MEMFUL		;JUMP IF MEMORY IS NOW FULL
	SHLD	MEMPTR		;SAVE NEW POINTER
	PUSH	B		;NEED ANOTHER 16 BIT REGISTER
	LXI	B,32*64		;ONE PAGE OF DATA
	DAD	B		;H=CURRENT M+1 PAGE
				; (D STILL = END)
	POP	B		;RESTORE B
	CALL	CMPHD
	CZ	WARN		;WARN WITH 1 PAGE LEFT
	POP	D
	POP	H
	POP	PSW
	RET

;
MEMFUL:
	LXI	H,BOT
	SHLD	MEMPTR		;RESET MEMORY POINTER
	MVI	A,1
	STA	MEMFLG
	POP	D
	POP	H
	POP	PSW
	RET

;
WARN:
	MVI	A,0FFH
	STA	MEMFLG
	RET

;
;
;**************************************************************
;							      *
;	THE REST OF THESE ROUTINES HAVE BEEN COPIED FROM ROM  *
;							      *
;**************************************************************
;
;
	LHLD	VFILL
	XCHG
GETBC:
	LHLD	VCRAD
	MOV	C,L
	MOV	B,H
	LHLD	VHLAD
	RET

ERASE:
	CALL	NOROL
EARS:
	MVI	A,20H	;SPACE
	LXI	H,X80
	MVI	B,0	;NOLIN*NOCHA/8
	PUSH	H
	LHLD	VFILL
	XCHG
	ORA	E
	MOV	E,A
	LXI	H,0
	DAD	SP
	SHLD	TEMP0
	POP	H
	DI
	SPHL
ERALP:
	PUSH	D
	PUSH	D
	PUSH	D
	PUSH	D
	PUSH	D
	PUSH	D
	PUSH	D
	PUSH	D
	DCR	B
	JNZ	ERALP
	LHLD	TEMP0
	SPHL
	EI
	POP	H
	RET

NOROL:
	LXI	H,X80
	SHLD	BHLAD
	XRA	A
	STA	ROLLN
HOME:
	LXI	H,ROLLN
	MOV	B,M
CR:
	MOV	C,A
SVCRS:
	CALL	LN5X
	SHLD	VHLAD
	LXI	H,VCRAD
	MOV	M,C
	INX	H
	MOV	M,B
	INX	H
	MOV	A,M
	DCR	A
	ANI	31
	OUT	ROLDA
	MOV	A,B
	OUT	CRYDA
	MOV	A,C
	OUT	CRXDA
	RET

CRSY:
	CALL	TESTB-2
	LDA	ROLLN
	ADD	B
	CALL	TESTB
LN5X:
	LDA	VFILL
	RLC
	ORA	B
	MOV	B,A
	MOV	A,B
LN5Y:
	RLC
	RLC
;	ADD	B
;	A=5B
	LXI	H,X80/(32)
	ADD	L
	MOV	L,A
	DAD	H
	DAD	H
	DAD	H
	DAD	H
	DAD	H
	MOV	A,C
	RLC
	ADD	L
	MOV	L,A
	RNC
	INR	H
	RET

TAB:
	MVI	A,7
	ORA	C
	MOV	C,A
CRSRT:
	INR	C
	MVI	A,-NOCHA
	ADD	C
	JNC	SVCRS
	MOV	C,A
LF:
	INR	B
	CALL	TESTB+1
IROLL:
	LDA	ROLFL
	ANA	A
	JZ	SVCRS
	LXI	H,ROLLN
	MOV	A,B
	XRA	M
	JNZ	SVCRS
	INR	M
	INR	M
	MVI	A,-NOLIN
	CALL	TESTC+6
	INX	H
	MOV	C,M
	PUSH	B
	XRA	A
	MOV	M,A
	CALL	EARLN
	LXI	B,NOCHA*2
	CALL	EARLN+9
	POP	PSW
	MOV	B,A
	RP
A7ON:
	LXI	H,VFILL
	MVI	M,80H
	JMP	SVCRS

CRSLT:
	DCR	C
	JP	SVCRS
	MVI	C,NOCHA-1
CRSUP:
	LDA	VFILL
	ANA	A
	JP	CRSUP1
	DCR	B
CRSUP1:
	DCR	B
	JP	SVCRS
	MVI	B,NOLIN-1
	JMP	SVCRS

COLOR:
	XTHL
	CALL	GETBC
	MOV	E,A
	LXI	H,TBL00
	CPI	16
	JC	CODE
	CPI	24
	LXI	H,TBL24-48
	JNC	CODE
	POP	H
	MVI	L,COLFL AND 255
	CALL	COLW
	JZ	BKCOL
	MVI	A,0F8H
	MOV	D,B
BKCOL:
	ANA	M
	ORA	D
	MOV	M,A
	RET

COLW:
	ANI	7
	MOV	B,A
	RLC
	RLC
	RLC
	MOV	D,A
	MOV	L,M
	DCR	L
	MVI	L,VFILL+1 AND 255
	MVI	A,0C7H
	RET

COMON:
	INR	A
COMOF:
	MVI	L,COLFL AND 0FFH
	MOV	M,A
	RET

BLINK:
	MVI	A,40H
	MVI	L,VFILL+1 AND 255
	ORA	M
	MOV	M,A
	RET

BA7OF:
	MVI	L,VFILL AND 255
	MOV	M,A
	MVI	A,0BFH
	INR	L
	ANA	M
	MOV	M,A
	RET

PROCES:
	MOV	E,A
	MVI	A,1
	OUT	EXTOT
ISERX:
	MOV	A,M
	PUSH	H
	LXI	H,INPTB
CODE:
	RLC
	ADD	L
	MOV	L,A
	MOV	A,H
	ACI	0
	MOV	H,A
	MOV	A,M
	INX	H
	MOV	H,M
	MOV	L,A
	XTHL
CODE2:
	LDA	EXTBF
	OUT	EXTOT
	XRA	A
	RET

ZERFL:
	MOV	A,E
	ANI	7FH
	CPI	32
	JC	COLOR
	CPI	96
	RC
SP64C:
	MVI	L,COLFL AND 255
	MOV	L,M
	DCR	L
	RNZ
	SUI	96
	RET

SBCHA:
	CALL	ZERFL	;34 US MIN
	LHLD	BFILL	;41 US MIN WAIT
	XCHG		;52 US MAX
	LHLD	BHLAD	;63 US MAX WAIT
	ORA	E
	MOV	M,A
	INX	H
	MOV	M,D
	INX	H
	CM	STOR2
TESHI:
	MVI	A,(X80+NOLIN*NOCHA*2) SHR 8
	CMP	H
	SHLD	BHLAD
	RNZ
	LXI	H,X80
	SHLD	BHLAD
	RET

SVCHA:
	CALL	ZERFL
	CALL	STOR1-3
	CM	STOR2
	JMP	JUMP

	CALL	GETBC-4
STOR1:
	ORA	E
	MOV	M,A
	INX	H
	MOV	M,D
	INX	H
	RET

STOR2:
	PUSH	H
	PUSH	B
	LXI	B,-NOCHA*2-2
	DAD	B
	POP	B
	MOV	M,A
	INX	H
	MOV	M,D
	POP	H
	RET

CCIX:	MOV	M,A
	MVI	L,VFILL+1 AND 255
	MVI	B,036H			;TRICK
BCCIX:	MVI	M,1
	MVI	L,BFILL+1 AND 255
	MOV	M,E
	RET

ESCAP:
	NOP
	RET

CRSXY:
	MOV	M,E
	RET

CCI:
	MOV	M,E
	RET

FREE:
FREEX:
PLOTX:
AUTOX:
POTON:
PRINT:
BRATX:
CPLOX:
FCSX:
BASEX:
TESTX:
ESCAX:
	RET

CURSO:
	MOV	A,E
	SUI	32		;SUBTRACT STUFF ADDED FOR EMACS
	CPI	65
	MVI	M,7
	JNC	B7ON
	MVI	M,5
	MVI	L,VCRAD AND 255
	MOV	M,A
	RET

B7ON:
	ANI	80H
	MVI	L,BFILL AND 255
	MOV	M,A
	RET

VCRSY:
	MOV	M,A
	MVI	L,VCRAD AND 255
	MOV	C,M
	MOV	A,E
	SUI	32		;SUBTRACT STUFF ADDED FOR EMACS
	CALL	CRSY
	JMP	SVCRS+3

BCRSX:	INR	M
	MVI	L,BHLAD AND 255
TESTC:
	MOV	A,E
	ANI	127
	MOV	M,A
	MVI	A,-NOCHA
	ADD	M
	RNC
	MOV	M,A
	RET

BCRSY:
	INR	M
	MVI	L,BHLAD AND 255
	MOV	C,M
	LDA	VFILL		;FIX BLIND CURSOR A7 BUG <9/78>
	PUSH	PSW
	LDA	BFILL
	STA	VFILL
	MOV	A,E
	CALL	CRSY
	POP	PSW		;<9/78>
	STA	VFILL
	SHLD	BHLAD
	RET

	ANI	31 OR NOLIN
TESTB:
	MOV	B,A
	MVI	A,-NOLIN
	ADD	B
	RNC
	MOV	B,A
	RET

ELINE:
	CALL	EARLN
	INR	E
	DCR	E
	LXI	B,-NOCHA*2
	JM	EARLN+9
	RET

EARLN:
	CALL	CR
	LHLD	VHLAD
	LXI	B,NOCHA*2-NOCHA*2*NOLIN
	DAD	B
	LXI	B,NOCHA*32
	MVI	A,20H
	JMP	EARS+7

;
;
;	ROUTINE TO RING THE BELL	(FROM ROM)
;
;
BELL:
	MVI	A,40H
	STA	EXTBF
	OUT	EXTOT
BELL1:
	LDA	TPROG
	STA	MS150
	MVI	A,195
	OUT	TIME4
	RET

;
;
;	BREAK KEY PROCESSOR		(FROM ROM)
;
;
BREAK:
	LDA	RCOMD
	ORI	2
	OUT	COMND
	JMP	BELL1

;
;
;	COMPARE HL:DE			(FROM ROM)
;
;
CMPHD:
	MOV	A,H
	CMP	D
	RNZ
	MOV	A,L
	CMP	E
	RET

;
;
;	SAVE ALL REGISTERS		(FROM ROM)
;
;
SAVE:
	XTHL			;SAVE HL WHILE LOADING ADDRESS
	PUSH	D		; TO RESUME EXECUTION AT
	PUSH	B		;THEN SAVE ALL REGISTERS
	PUSH	PSW		; AND STATUS
	CALL	JMPHL		;PUSH $+3 AS RETURN ADDRESS
	POP	PSW		;AND RESUME EXECUTION OF CALLER
	POP	B		;THEN RESTORE ALL REGISTERS
	POP	D		; AND STATUS
	POP	H
	EI			;REENABLE INTERRUPTS
	RET			; AND EXIT FROM INTERRUPT

;
;
JMPHL:
	PCHL			; JUMP THRU HERE TO ROUTINE
;
;
;	SEND A BYTE TO THE SCREEN	(FROM ROM)
;
;
LO:
	CALL	SAVE		;SAVE ALL REGS
	LXI	H,LOFL
	JMP	PROCES

;
;
;	SEND A STRING TO THE SCREEN.	(FROM ROM)
;	BYTE VALUE OF 239 DECIMAL
;	TERMINATES THE STRING.
;	ALSO SUPPORTS REPEAT LOOPS
;	OF THE FORM:
;	...,237,N,D1,D2,...,DM,238,...
;	WHERE N IS THE REPEAT COUNT
;	FOR THE STRING OF BYTES:
;	D1,D2,...,DM
;
;
OSTR:
	MOV	A,M		;GET NEXT BYTE
	INX	H
	CPI	237		;SPECIAL CODE ?
	JC	OSTR1		;A<237: GO SEND BYTE
	JZ	OSTR2		;A=237: START REPEAT LOOP
	CPI	239		;SPECIAL CODE ?
	RZ			;A=239: END: RETURN
	JC	OSTR4		;A=238: END OF REPEAT LOOP
OSTR1:	CALL	LO		;SEND BYTE
	JMP	OSTR		;GET NEXT BYTE

OSTR2:	MOV	D,M		;GET REPEAT COUNT
	INX	H
OSTR3:	PUSH	H		;SAVE START POINTER
	JMP	OSTR		;GET NEXT BYTE

OSTR4:	DCR	D		;FINISHED REPEAT ?
	JZ	OSTR5		;YES!
	POP	H		;RESTORE START POINTER
	JMP	OSTR3		;REPEAT AGAIN!

OSTR5:	POP	PSW		;CLEAN THE STACK
	JMP	OSTR		;GET NEXT BYTE

;
;
;	 TRANSMIT E ON RS232		(FROM ROM)
;
;
S1OUT:
	IN	STAT5		;GET STATUS
	ANI	SSOBE		;CAN WE SEND ?
	JZ	S1OUT		;NO: WAIT!
	IN	EXTIN		;IS CLEAR TO SEND HIGH ?
	ANI	80H
	JZ	S1OUT
	MOV	A,E		;GET CHARACTER TO SEND
	OUT	TXBUF		;SEND THE CHARACTER
	RET			;RETURN

;
;
;**************************************************************
;
;
;	CONTROL CHARACTER TABLE		(FROM ROM)
;
;
TBL00:
	DW	FREE	; @  0	HAS NO EFFECT
	DW	HOME	; A  1	WAS AUTO NOW HOME CURSOR
	DW	POTON	; B  2	PLOT
	DW	CRSXY	; C  3	CURSOR XY
	DW	FREE	; D  4	NOT USED
	DW	FREE	; E  5	NOT USED
	DW	CCI	; F  6	CCI FOLLOWS
	DW	BELL	; G  7	RING THE BELL
	DW	CRSLT	; H  8	WAS HOME NOW CURSOR LEFT
	DW	TAB	; I  9	TAB MODULO 8 COLUMNS
	DW	LF	; J  10	LINEFEED AKA DOWN CURSOR
	DW	ELINE	; K  11	ERASE LINE
	DW	ERASE	; L  12	ERASE PAGE
	DW	CR	; M  13	RETURN
	DW	A7ON	; N  14	2X CHAR HEIGHT 1 STP BIT
	DW	BA7OF	; O  15	BLINK & 2X CHAR OFF
TBL24:
	DW	PRINT	; X  24	PRINT THE SCREEN
	DW	CRSRT	; Y  25	CURSOR RIGHT
	DW	CRSLT	; Z  26	CURSOR LEFT
	DW	ESCAP	;ESC 27	ESCAPE
	DW	CRSUP	; \  28	CURSOR UP
	DW	COMOF	; ]  29	FOREGROUND FLAG ON
	DW	COMON	; ^  30	FOREGROUND FLAG OFF
	DW	BLINK	; _  31	BLINK ON
;
;
;	INPUT FLAG TABLE
;
;
INPTB:
	DW	SVCHA	; 0
	DW	SBCHA	; 1
	DW	PLOTX	; 2
	DW	CURSO	; 3
	DW	CPLOX	; 4
	DW	VCRSY	; 5
	DW	CCIX	; 6
	DW	BCRSX	; 7
	DW	BCRSY	; 8
	DW	BCCIX	; 9
	DW	INPCRT	; 10
	DW	INPCRT	; 11
	DW	FREEX	; 12
	DW	FCSX	; 13
	DW	S1OUT	; 14
	DW	FREEX	; 15
	DW	INPCRT	; 16
	DW	INPCRT	; 17
	DW	BRATX	; 18
	DW	INPCRT	; 19
	DW	INPCRT	; 20
	DW	INPCRT	; 21
	DW	INPCRT	; 22
	DW	BASEX	; 23
	DW	INPCRT	; 24
	DW	TESTX	; 25
	DW	INPCRT	; 26
	DW	ESCAX	; 27
	DW	INPCRT	; 28
	DW	INPCRT	; 29
	DW	INPCRT	; 30
	DW	INPCRT	; 31
;
;
;
;
;
;	MEMORY STATE FLAG
;
;	0FFH	=>	WARNING 1 PAGE LEFT
;	0	=>	EVERYTHING IS COOL
;	1	=>	WRAPAROUND OCCURRED
;
;
MEMFLG:	DB	0	;MEMORY STATE FLAG
;
MEMPTR:	DW	0	;WHERE TO STORE CHARACTER IN MEMORY
;
TOPMEM:	DW	0	;TOP OF MEMORY TO USE AS A BUFFER
;
EXITFG:	DB	0	;EXIT IF <> 0
;
FCSSP:	DW	0	;THE STACK POINTER USED BY THE CALLER
;
;
PROMPT:	DB	6,2,11,15,29
	DB	18,'RICKIS '
	DB	19,'TERMINAL '
	DB	20,'EMULATOR '
	DB	23,'VERSION '
	DB	17,'3.0 '
	DB	18,'14Mar81',13,10
	DB	22,'ALL INCOMING DATA IS BEING SAVED IN MEMORY'
	DB	' LOCATIONS 9600-FFFF',13,10
	DB	23,'PRESS EXIT TO EXIT FROM THIS PROGRAM'
	DB	18,13,10,239
WRAPMSG:DB	13,10,17,'MEMORY WRAP',18,13,10,239
WARNMSG:DB	13,10,17,'MEMORY WARN',18,13,10,239
	END	INIT	;Ricki A. Vick