	TITLE	<Zapple Monitor Extension for MITS ALTAIR>
;
; ADDITIONAL DRIVERS FOR ZAPPLE ON MITS ALTAIR
; IMPLEMENTS LIST DEVICE CONNECTED TO PRINTER
; AND READER/PUNCH DEVICE CONNECTED TO 2SIO B
;
; V1.0 - OCT. 2017 - UDO MUNK
;
BASE	EQU	0F800H
;
; I/O DEFINITIONS
;
LSTAT	EQU	02H		;PRINTER STATUS PORT
LDATA	EQU	03H		;PRINTER DATA PORT
LPTR	EQU	01H		;PRINTER READY BIT
;
SIO2S	EQU	12H		;MITS 2SIO B STATUS PORT
SIO2D	EQU	13H		;MITS 2SIO B DATA PORT
RDA	EQU	01H		;MITS 2SIO RECEIVER DATA AVAILABLE
TBE	EQU	02H		;MITS 2SIO TRANSMIT BUFFER EMPTY
;
	ORG	BASE
;
; JUMP VECTOR EXPECTED BY ZAPPLE
;
CILOC:	JP	CONIN		;CONSOLE INPUT
COLOC:	JP	CONOUT		;CONSOLE OUTPUT
RPTPL:	JP	RDRIN		;READER INPUT
RULOC:	JP	STOIN		;STORAGE INPUT
PTPL:	JP	PUNOUT		;PUNCH OUTPUT
PULOC:	JP	STOOUT		;STORAGE OUTPUT
LNLOC:	JP	LPTOUT		;LINE PRINTER
LULOC:	JP	UPTOUT		;USER DEFINED PRINTER
CSLOC:	JP	CONST		;CONSOLE STATUS
J1:	JP	ICMD		;COMMAND I
J2:	JP	KCMD		;COMMAND K
J3:	JP	OCMD		;COMMAND O
;
; USER DEFINED CONSOLE
;
CONIN:
CONOUT:	RET
CONST:	XOR	A		;NO INPUT WAITING
	RET
;
; USER DEFINED READER/PUNCH
; MITS 2SIO CHANNEL B
;
RDRIN:	IN	A,(SIO2S)	;GET STATUS
	AND	RDA		;DATA AVAILABLE?
	JP	Z,RDRIN		;NO, WAIT
	IN	A,(SIO2D)	;READ DATA
	RET
;
PUNOUT:	IN	A,(SIO2S)	;GET STATUS
	AND	TBE		;TRANSMITT BUFFER EMPTY?
	JP	Z,PUNOUT	;NO, WAIT
	LD	A,C		;GET DATA FROM REGISTER C
	OUT	(SIO2D),A	;AND SEND IT
	RET
;
; USER DEFINED STORAGE
;
STOIN:
STOOUT:	RET
;
; LINE PRINTER
; MITS ALTAIR
;
LPTOUT:	IN	A,(LSTAT)	;GET PRINTER STATUS
	AND	LPTR		;MASK FOR READY
	JP	Z,LPTOUT	;LOOP TILL READY
	LD	A,C		;SEND CHARATER
	OUT	(LDATA),A
	RET
;
; USER DEFINED LINE PRINTER
;
UPTOUT:	RET
;
; ZAPPLE I, K AND O COMMANDS
;
ICMD:
KCMD:
OCMD:	RET

	END
