

; OVERLAY FOR CP/M VERSION OF VIDTEX EXECUTIVE


TRUE	EQU	0FFFFH		; DEFINE TRUE
FALSE	EQU	NOT TRUE	; DEFINE FALSE

BBASE	EQU	0000H		; "PAGE 0" ADDRESS
TBASE	EQU	BBASE+100H	; TRANSIENT PROGRAM AREA
OVLOC	EQU	BBASE+1800H	; WHERE THE OVERLAY GOES
STKLEN	EQU	100		;LENGTH OF STACK

; ************************************************************
; ************************************************************

;	THIS BEGINS THE SECTION THAT MUST BE MODIFIED
;	TO YOUR PARTICULAR SYSTEM.  THE FIRST THING YOU
;	SHOULD DO IS PUT YOUR SYSTEM IDENTIFICATION INTO
;	THE PROGRAM.  TO DO THIS, CHANGE THE 'IMSAI 8080'
;	IN THE STATEMENT LABELED "IDMSG:" TO WHATEVER
;	TYPE OF SYSTEM YOU HAVE.  NOTE THAT "IDMSG:" CAN
;	BE NO LONGER THAN 80 CHARACTERS AND THE LAST
;	CHARACTER MUST BE A 0D BYTE.

; ------------------------------------------------------------

;*	THESE ARE THE PORT ADDRESSES USED FOR THE MODEM.

CTL	EQU	06H	; MODEM STATUS (CONTROL) PORT
SIO	EQU	04H	; MODEM DATA PORT

; ------------------------------------------------------------

;	THESE ARE THE MODEM PORT STATUS FLAG MASKS

SIOIR	EQU	01H	; MODEM PORT INPUT DATA READY FLAG
SIOTR	EQU	04H	; MODEM PORT TRANSMITTER READY FLAG

; ------------------------------------------------------------

;	THIS IS SET TO FALSE IF YOUR MODEM PORT READY FLAGS
;	ARE ACTIVE LOW. (ZERO IMPLIES READY)

RDYHI	EQU	TRUE	; TRUE IF UART READY FLAGS ARE
			; ACTIVE HIGH (1=READY). FALSE
			; IF FLAGS ARE ACTIVE LOW (0=READY).

;	THIS ENDS THE SECTION THAT MUST BE
;	MODIFIED TO YOUR PARTICULAR SYSTEM
;	UNLESS YOU NEED UART INITIALIZATION.
;	IF YOU DO NEED TO INITAILIZE YOUR
;	MODEM UART, CHANGE "SIOINI:" (AT THE
;	END OF THIS PROGRAM) TO SET UP YOUR
;	UART TO USE 8 DATA BITS, NO PARITY
;	AND 1 STOP BIT.

; ************************************************************
; ************************************************************

RDYLO	EQU	NOT RDYHI

	ORG	TBASE+3		; OVERLAY TRANSFER VECTOR AND ID STRING

INISIO:	JMP	SIOINI		; INITIALIZE MODEM UART
GETSIO:	JMP	SIOGET		; GET CHAR FROM MODEM UART
PUTSIO:	JMP	SIOPUT		; PUT A CHAR TO MODEM UART

BCDICP:	DW	BCDIC		;POINT TO OVERLAID COMPRESSION DICTIONARY
STACKP:	DW	STACK		;POINT TO LOCATION OF STACK
PRTYES:	DB	FALSE		;TRUE WHEN COPY GOES TO PRINTER

IDPTR:	DW	IDLEN		;POINTER TO ID STRING'S LENGTH
IDMSG:	DB	'#CPM-KAYPRO4 Z80,PB,DT'		;IDENTIFIES YOUR SYSTEM
	DB	0DH				;END OF IDENTIFIER
IDLEN:   EQU     $-IDMSG

	ORG	OVLOC		; MOVE BEYOND EXEC FOR MODEM PORT I/O ROUTINES

; THIS ROUTINE INPUTS A CHARACTER FROM THE MODEM'S UART (OR USART)

SIOGET:	IN	CTL	; GET MIO STATUS FLAGS
	ANI	SIOIR	; ISOLATE INPUT READY FLAG

	IF RDYLO	; INVERT IF ACTIVE LOW
	XRI	SIOIR	; INVERT IT
	ENDIF

	RZ		; RETURN IF Z = 1
	IN	SIO	; ELSE GET MODEM CHARACTER
	RET		; AND RETURN (Z FLAG = 0)

; THIS ROUTINE OUTPUT CONTENTS OF A TO THE MODEM'S UART

SIOPUT:	PUSH	B	;SAVE REGISTERS
	MOV	B,A	;SAVE CHR TO OUTPUT
	IN	CTL	;GET STATUS FLAG
	ANI	SIOTR

	IF RDYLO	; INVERT IF ACTIVE LOW
	XRI	SIOIR	; INVERT IT
	ENDIF

	MOV	A,B	;RESTORE CHR TO ACCUMULATOR
	POP	B	;RESTORE REGS
	RZ		;RETURN IF NOT READY TO OUTPUT YET

	OUT	SIO
	RET

; THIS ROUTINE INITIALIZES THE MODEM UART FOR OPERATION

SIOINI:	MVI	A,1		;INITIALIZE UART HERE
	OUT	12H		;RESET DEVICE B
	MVI	A,0		;MASK FOR INTERRUPTS
	OUT 	13H		;
	MVI	A,88H		;BAUD RATE=1200
	OUT	10H		;
	RET			;

;	STACK AREA

	DS	STKLEN		;DEFINE STACK
STACK	EQU	$

BCDIC	EQU	$		;COMPRESSION DICTIONARY

	END
R MODEM PORT I/O ROUTINES

; THIS ROUT