;**************************************************************************
;                                                                         *
; Program       - DUALPORT          Console output modification for       *
; Author        - E. L. Bergh       demos where multiple displays         *
; Date Written  - 02/11/84          are needed.                           *
;                                                                         *
;               ***  Written for the Kaypro II  ***                       *
;                                                                         *
;-------------------------------------------------------------------------*
;                                                                         *
;                     Copyright (c) 1984,  E. L. Bergh II                 *
;                                                                         *
; All rights reserved, permissions to use, modify, and copy are granted   *
; but permission is not granted to sell this program.                     *
;            No warranties are expressed or implied.                      *
;                                                                         *
;-------------------------------------------------------------------------*
;                                                                         *
;       This program modifies the BIOS console output vector              *
;       to pass control thru a "small" program that is                    *
;       installed in the RESTART vector area of memory.  The              *
;       program remains active until a system-reset is done.              *
;									  *
;                    A>DUALPORT<cr>                                       *
;									  *
;**************************************************************************
;
boot	equ	0		;system re-boot vector
iobyte	equ	3		;system i/o byte
bdos	equ	5		;system function call vector
conot	equ	9		;displacement to the CONOT vector
small	equ	8		;where the program will run
baudp	equ	0		;baud rate port
;
	org	100h		;set program origin
;
	call	begin		;go begin the program
	db	13,10,'DUALPORT Vers 1.00  Dual Display Installation'
	db	13,10,'---------------------------------------------'
	db	13,10,10,'$'
;
;********************************************************************
;								    *
;       This is the un-installed copy of the "small" program        *
;       that will be left behind in memory.                         *
;                                                                   *
;********************************************************************
;
smallp	equ	$		;beginning of the small program
	push	b		;save the data byte
	lda	iobyte
	ani	11111100b	;select the TTY: device
	sta	iobyte
call1	call	0		;display on the serial device first
	lda	iobyte
	ori	00000001b	;select the CRT: device
	sta	iobyte
	pop	b
call2	call	0		;display on the screen second
	mov	a,c		;just like a normal call-return
	ret
slen	equ	$-smallp	;figure the module length
;
begin	equ	$		;begin the program
	pop	d		;get the signon msg address
	mvi	c,9		;write buffer command
	call	bdos		;display the signon
;
	lhld	boot+1		;get the address of the BOOT vector
	lxi	d,conot+1	;get the displacement to the CONOT
	dad	d
;
	mov	e,m
	inx	h
	mov	d,m		;get the CONOT address
;
	dcx	h		;fix pointer to the start
	push	h		;save the address
;
	xchg			;get the CONOT address in (hl)
	shld	call1+1
	shld	call2+1		;patch the call statements
;
	lxi	d,smallp	;address of the small program
	lxi	h,small		;where to install the small program
	mvi	b,slen		;length of the small program
;
move	equ	$		;move loop
	ldax	d		
	mov	m,a		;copy a byte
	inx	d
	inx	h		;increment pointers
	dcr	b		;decr counters
	jnz	move		;loop

	pop	h		;restore BIOS-CONOT address
	lxi	d,small		;where to pass control
	mov	m,e
	inx	h
	mov	m,d		;patch the BIOS-CONOT vector
;
	mvi	a,14		;9600 baud rate value
	out	baudp		;set the baudrate
;
	lda	iobyte
	ani	11111101b
	ori	00000001b	;insure CRT: to start with
	sta	iobyte
;
	ret			;all done ...
;
	end
