Compucolor.org – Virtual Media

Listing of file='PRINT.SRC;01' on disk='vmedia/chip_114-sector.ccvf'


;	9/19/78 MW CEIGLER
;      10/26/83 AV PINTER

BUFSIZ	EQU	7800H	;INPUT BUFFER SIZE
INPCRT	EQU	81C5H	;JUMP VECTOR NUMBER 31
KBDFL	EQU	81DFH	;HOLDS NUMBER OF JUMP VECTOR
READY	EQU	81FFH
KBCHA	EQU	81FEH

FOPT	EQU	0
FATR	EQU	1
FNAM	EQU	2
FTYP	EQU	8
FVER	EQU	11
FSBK	EQU	12
FSIZ	EQU	14
FLBC	EQU	16
FLAD	EQU	17
FSAD	EQU	19
FSPR	EQU	21
FDBK	EQU	22
FDEN	EQU	23
FAUX	EQU	24
FHAN	EQU	26
FFCN	EQU	28
FDRV	EQU	29
FBLK	EQU	30
FBUF	EQU	32
FXBC	EQU	34
FPTR	EQU	36

;	SPECIAL CONTROL CHARACTERS

BEL	EQU	7
TAB	EQU	9
LF	EQU	10
CR	EQU	13
BS	EQU	26

;	START OF PROGRAM
	ORG	8200H

START:	DW	KBDFL
	LXI	H,0
	DAD	SP
	SHLD	FCSSP
	LXI	SP,STACK
	DI		;SET ROM ADDRESSES
	LDA	1	;VERSION 8/79?
	CPI	0BAH
	JZ	START2	;YES
	LXI	H,NEWTAB
	LXI	D,OLDTAB
	LXI	B,LENTAB

START1:	LDAX	D
	MOV	M,A
	INX	H
	INX	D
	DCX	B
	MOV	A,B
	ORA	C
	JNZ	START1

START2:	EI
	MVI	A,31	;SET UP VECTOR
	STA	KBDFL	;TO INPCRT
	MVI	A,0C3H	;LITERALLY JMP
	STA	INPCRT
	LXI	H,CHRINT	;THUS
			;INPCRT:	JMP	CHRINT
	SHLD	INPCRT+1

START3:	XRA	A
	STA	33265
	STA	INBUF	;CLEAR COUNTER BYTE
	LXI	H,MSG00
	CALL	OSTR
	CALL	CI
	CPI	CR	;WANT DIR?
	JNZ	ST3CAL	;NO
	CALL	DIR01	;YES
	JMP	START3
ST3CAL:	LXI	H,BUFFER
	LXI	B,BUFFER	;COPY FOR
	CALL	SETUP1	;INITIALIZE INPUT FILE

;THIS IS THE MAIN LOOP, READS INPUT, CHECKS FOR BREAK, PRINTS
LOOP:	LXI	H,FPB1
	CALL	GTBYT			;INPUT
	JC	LOOPE1
	CALL	SCREEN			;OUTPUT
ABTEST:	LDA	READY	;SEE IF BREAK
	CPI	50H
	JZ	ABTEST	;HANG UNTIL ANOTHER IS STRUCK
	XRA	A	;CLEAR READY AND CONTINUE
	STA	READY
	JMP	LOOP			;LOOP

BAILOUT:MVI	A,BEL
	CALL	SCREEN
	MVI	B,0	;SETUP NO ERROR
EXIT:	CALL	CRLF
	LXI	H,KBDFL
	SHLD	8200H
	LHLD	FCSSP	;RESTORE FCS STACK
	SPHL
	MVI	A,44H
	JMP	ESC1	;AND EXIT TO FCS

SCREEN:	CPI	128	;ALL CALLS TO LO SHOULD BE THROUGH HERE
	JNC	NOSCRN
	CPI	32
	JNC	LO
	CPI	TAB
	JZ	LO
	CPI	LF
	JZ	LO
	CPI	CR
	JZ	LO
	CPI	BS
	JZ	LO
	CPI	BEL
	JZ	LO
NOSCRN:	PUSH	PSW
	MVI	A,17	;RED
	CALL	LO
	POP	PSW
	CALL	LBYT	;IN HEX
	MVI	A,18	;GREEN AND RETURN
	JMP	LO

LOOPE1:	JZ	START3	;EOF, NO ERROR
ERROR:	CALL	EMESS	;PRINT ERROR MESSAGE
	JMP	START3

;INPUT FSPEC
L02:	CALL	CI	;KEYBOARD
	CPI	CR	;CR?
	JZ	X02	;YES

;START3 COMES HERE AFTER INPUT OF 1ST CHARACTER
SETUP1:	CPI	BS	;BS?
	JZ	G021	;YES
	MOV	M,A	;CHAR TO BUFFER
	INX	H	;NEXT
	JMP	L02	;CONTINUE LOOP

;BACKSPACE
G021:	MOV	A,L	;TEST LO BYTE OF POINTER
	CMP	C	;IF BUFFER EMPTY THEN RESTART READ
	JZ	START3
	MVI	A,' '	;ELSE SPACE OVER
	CALL	SCREEN
	MVI	A,BS	;AND BACK UP AGAIN
	CALL	SCREEN
	DCX	H	;BACK POINTER UP
	JMP	L02	;CONTINUE LOOP

;CARRAIGE RETURN
X02:	MVI	M,0	;TERMINATOR TO BUFFER
	CALL	CRLF
	LXI	H,BUFFER	;SET PFSPC POINTERS
	LXI	D,FPB1
	LXI	B,DEFAULT	;.SRC
	CALL	PFSPC	;PARSE FILE SPEC
	JC	E02	;CARRY=ERROR
	MOV	A,M	;TEST FOR END
	MVI	B,9	;SETUP SYNTAX ERROR
	ORA	A
	JNZ	E02
	LXI	H,FPB1	;POINT AT INPUT FPB
	MVI	M,0	;SETUP AS OLD FILE
	CALL	OPEN	;OPEN INPUT FILE
	JC	E02	;CARRY=ERROR
	LXI	H,IBUF	;INPUT BUFFER
	SHLD	FPB1+FBUF	;INPUT BUFFER ADDRESS
	LXI	H,BUFSIZ	;SETUP BUFFER SIZE
	SHLD	FPB1+FXBC	;INPUT BUFFER SIZE
	LXI	H,FPB1	;INPUT FPB
	JMP	RWSEQI	;REWIND INPUT FILE AND RETURN

CHRINT:	;CHRINT IS CALLED WHENEVER A KEY IS STRUCK
	;THE JUMP IS FROM INPCRT
	;STORES INPUT IN INBUF, ALL ALPHA STORED AS UPPER CASE
	;BUT LCSW=1 IF LOWER CASE WAS INPUT

	PUSH	H
	PUSH	PSW
	LXI	H,INBUF	;TYPE AHEAD BUFFER, IST BYTE IS COUNT
	MVI	A,30	;BUFFER LENGTH
	CMP	M	;BUFFER FULL?
	JC	CHREND	;YES, IGNORE CHAR
	MOV	A,E	;CHAR TO A
	CPI	LF
	JZ	BAILOUT
	CALL	CHEDIT	;CARRY SET IF INVALID CHAR
	JC	CHREND	;EXIT W/O STORING CHR
	INR	M	;INCREMENT COUNTER
	MOV	A,M	;POINT H,L TO NEXT BUFFER POSITION
	CALL	ADHLA

;IF KEYBOARD CHAR IS LOWER CASE CHG TO UPPER AND SET LCSW=1
	PUSH	H	;INBUF POINTER
	LXI	H,LCSW	;INITIALIZE LCSW AT 0
	MVI	M,0
	MOV	A,E	;CHARACTER TO A
	CPI	'a'
	JC	CHRMOV	;< a
	CPI	'z'+1
	JNC	CHRMOV	;> z
;LOWER CASE KEYBOARD INPUT IN A
	INR	M	;LCSW NOW = 1
	ANI	01011111B	;MAKE UPPER CASE

CHRMOV:	POP	H	;INBUF POINTER
	MOV	M,A	;STORE CHAR IN INBUF
CHREND:	POP	PSW
	POP	H
	EI
	RET

;EXAMINE KEYBOARD CHARACTER AND SET CARRY IF UNAUTHORIZED
CHEDIT:	CPI	128	;'.;: ,0-9,A-Z,a-z' ONLY
	JNC	CHRBAD
	CPI	CR
	JZ	CHAROK
	CPI	BS
	JZ	CHAROK
	CPI	'.'
	JZ	CHAROK
	CPI	';'
	JZ	CHAROK
	CPI	':'
	JZ	CHAROK
	CPI	' '
	JZ	CHAROK
	CPI	'0'
	JC	CHRBAD
	CPI	'9'+1
	JC	CHAROK
	CPI	'A'
	JC	CHRBAD
	CPI	'Z'+1
	JC	CHAROK
	CPI	'a'
	JC	CHRBAD
	CPI	'z'+1
	JC	CHAROK
CHRBAD:	MVI	A,BEL
	CALL	SCREEN
	STC		;SET CARRY
	RET
CHAROK:	XRA	A	;CLEAR CARRY
	RET
;END OF CHRINT:

;CI READS AND ECHOS ONE CHARACTER FROM THE KEYBOARD
CI:	PUSH	H	;SAVE H
	LXI	H,INBUF

CI001:	MOV	A,M	;LOOP AND WAIT FOR KEYBOARD INTERRUPT
	ANA	A	;SO LONG AS BUFFER COUNTER = 0
	JZ	CI001

;KEYBOARD INTERRUPT, CHRINT HAS PUT A CHARACTER IN INBUF
	DI
	PUSH	D
	DCR	M	;DECREMENT BUFFER COUNTER
	MOV	D,M
	INX	H	;INBUF + 1
	MOV	A,M	;READ IT
	PUSH	PSW	;STACK IT
CI002:	DCR	D	;SHIFT COUNTER
	JM	CI003	;WHEN DONE
	INX	H	;CHARACTER TO BE SHIFTED
	MOV	A,M
	DCX	H	;POINT TO NEW HOME
	MOV	M,A	;NEW HOME
	INX	H
	JMP	CI002	;LOOP UNTIL DONE

;IF LCSW=0 PRINT AS IS (UPPER CASE), ELSE CHG TO LOWER FOR PRINT
CI003:	EI
	LDA	LCSW
	CPI	0
	JZ	CI007
	POP	PSW
	PUSH	PSW
	ORI	20H
	CALL	SCREEN
	POP	PSW
	JMP	CI008

CI007:	POP	PSW	;THE CHARACTER
	CALL	SCREEN
CI008:	POP	D
	POP	H
	RET
;END OF CI:

E02:	CALL	EMESS	;EMIT ERROR MESSAGE
	JMP	START3	;READ NEW LINE

;ROM JUMP TABLES

OLDTAB:
	JMP	3392H	;LO
	JMP	33F4H	;OSTR
	JMP	262DH	;EMESS
	JMP	3077H	;PFSPC
	JMP	26A5H	;RESET
	JMP	2DABH	;OPEN
	JMP	30C6H	;RWSEQI
	JMP	322CH	;GTBYT
	JMP	3518H	;ADHLA
	JMP	338BH	;CRLF
	JMP	053AH	;ESC1
	JMP	2799H	;DIR01
	JMP	339BH	;LBYT

LENTAB	EQU	$-OLDTAB
;
NEWTAB:
LO:	JMP	17C8H
OSTR:	JMP	182AH
EMESS:	JMP	0AD6H
PFSPC:	JMP	14ADH
RESET:	JMP	0B48H
OPEN:	JMP	11E1H
RWSEQI:	JMP	14FCH
GTBYT:	JMP	1662H
ADHLA:	JMP	194EH
CRLF:	JMP	17C1H
ESC1:	JMP	2420H
DIR01:	JMP	0C3CH
LBYT:	JMP	17D1H

;	MESSAGES

MSG00:	DB	7,27,11,15,22,CR,LF,'PRINT - '
	DB	18,'FSPEC',19,'=PRINT, '
	DB	18,'RET',19,'=DIR, '
	DB	18,'DOWN ARROW',19,'=EXIT > ',18,0EFH

DEFAULT:DB	'SRC'

;	DATA AREAS

BUFFER:	DS	256
FCSSP:	DS	2	;FCS STACK POINTER
FPB1:	DS	38	;INPUT FPB
INBUF:	DS	32	;STORAGE  AREA FOR TYPE AHEAD
LCSW:	DS	1	;0 IF NOT LOWER CASE, 1 IF LC

	DS	100	;STACK AREA
STACK:

IBUF:	DS	BUFSIZ	;INPUT BUFFER

	END	START